hsdk.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * Copyright (C) 2017 Synopsys, Inc. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #include <common.h>
  7. #include <dwmmc.h>
  8. #include <malloc.h>
  9. DECLARE_GLOBAL_DATA_PTR;
  10. #define CREG_BASE (ARC_PERIPHERAL_BASE + 0x1000)
  11. #define CREG_PAE (CREG_BASE + 0x180)
  12. #define CREG_PAE_UPDATE (CREG_BASE + 0x194)
  13. #define CREG_CPU_START (CREG_BASE + 0x400)
  14. int board_early_init_f(void)
  15. {
  16. /* In current chip PAE support for DMA is broken, disabling it. */
  17. writel(0, (void __iomem *) CREG_PAE);
  18. /* Really apply settings made above */
  19. writel(1, (void __iomem *) CREG_PAE_UPDATE);
  20. return 0;
  21. }
  22. #define SDIO_BASE (ARC_PERIPHERAL_BASE + 0xA000)
  23. #define SDIO_UHS_REG_EXT (SDIO_BASE + 0x108)
  24. #define SDIO_UHS_REG_EXT_DIV_2 (2 << 30)
  25. int board_mmc_init(bd_t *bis)
  26. {
  27. struct dwmci_host *host = NULL;
  28. host = malloc(sizeof(struct dwmci_host));
  29. if (!host) {
  30. printf("dwmci_host malloc fail!\n");
  31. return 1;
  32. }
  33. /*
  34. * Switch SDIO external ciu clock divider from default div-by-8 to
  35. * minimum possible div-by-2.
  36. */
  37. writel(SDIO_UHS_REG_EXT_DIV_2, (void __iomem *) SDIO_UHS_REG_EXT);
  38. memset(host, 0, sizeof(struct dwmci_host));
  39. host->name = "Synopsys Mobile storage";
  40. host->ioaddr = (void *)ARC_DWMMC_BASE;
  41. host->buswidth = 4;
  42. host->dev_index = 0;
  43. host->bus_hz = 50000000;
  44. add_dwmci(host, host->bus_hz / 2, 400000);
  45. return 0;
  46. }
  47. #define RESET_VECTOR_ADDR 0x0
  48. void smp_set_core_boot_addr(unsigned long addr, int corenr)
  49. {
  50. /* All cores have reset vector pointing to 0 */
  51. writel(addr, (void __iomem *)RESET_VECTOR_ADDR);
  52. /* Make sure other cores see written value in memory */
  53. flush_dcache_all();
  54. }
  55. void smp_kick_all_cpus(void)
  56. {
  57. #define BITS_START_CORE1 1
  58. #define BITS_START_CORE2 2
  59. #define BITS_START_CORE3 3
  60. int cmd = readl((void __iomem *)CREG_CPU_START);
  61. cmd |= (1 << BITS_START_CORE1) |
  62. (1 << BITS_START_CORE2) |
  63. (1 << BITS_START_CORE3);
  64. writel(cmd, (void __iomem *)CREG_CPU_START);
  65. }