cpu.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2016 Stefan Roese <sr@denx.de>
  4. */
  5. #include <common.h>
  6. #include <dm.h>
  7. #include <fdtdec.h>
  8. #include <linux/libfdt.h>
  9. #include <asm/io.h>
  10. #include <asm/system.h>
  11. #include <asm/arch/cpu.h>
  12. #include <asm/arch/soc.h>
  13. #include <asm/armv8/mmu.h>
  14. /* Armada 7k/8k */
  15. #define MVEBU_RFU_BASE (MVEBU_REGISTER(0x6f0000))
  16. #define RFU_GLOBAL_SW_RST (MVEBU_RFU_BASE + 0x84)
  17. #define RFU_SW_RESET_OFFSET 0
  18. /*
  19. * The following table includes all memory regions for Armada 7k and
  20. * 8k SoCs. The Armada 7k is missing the CP110 slave regions here. Lets
  21. * define these regions at the beginning of the struct so that they
  22. * can be easier removed later dynamically if an Armada 7k device is detected.
  23. * For a detailed memory map, please see doc/mvebu/armada-8k-memory.txt
  24. */
  25. #define ARMADA_7K8K_COMMON_REGIONS_START 2
  26. static struct mm_region mvebu_mem_map[] = {
  27. /* Armada 80x0 memory regions include the CP1 (slave) units */
  28. {
  29. /* SRAM, MMIO regions - CP110 slave region */
  30. .phys = 0xf4000000UL,
  31. .virt = 0xf4000000UL,
  32. .size = 0x02000000UL, /* 32MiB internal registers */
  33. .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
  34. PTE_BLOCK_NON_SHARE
  35. },
  36. {
  37. /* PCI CP1 regions */
  38. .phys = 0xfa000000UL,
  39. .virt = 0xfa000000UL,
  40. .size = 0x04000000UL, /* 64MiB CP110 slave PCI space */
  41. .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
  42. PTE_BLOCK_NON_SHARE
  43. },
  44. /* Armada 80x0 and 70x0 common memory regions start here */
  45. {
  46. /* RAM */
  47. .phys = 0x0UL,
  48. .virt = 0x0UL,
  49. .size = 0x80000000UL,
  50. .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
  51. PTE_BLOCK_INNER_SHARE
  52. },
  53. {
  54. /* SRAM, MMIO regions - AP806 region */
  55. .phys = 0xf0000000UL,
  56. .virt = 0xf0000000UL,
  57. .size = 0x01000000UL, /* 16MiB internal registers */
  58. .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
  59. PTE_BLOCK_NON_SHARE
  60. },
  61. {
  62. /* SRAM, MMIO regions - CP110 master region */
  63. .phys = 0xf2000000UL,
  64. .virt = 0xf2000000UL,
  65. .size = 0x02000000UL, /* 32MiB internal registers */
  66. .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
  67. PTE_BLOCK_NON_SHARE
  68. },
  69. {
  70. /* PCI CP0 regions */
  71. .phys = 0xf6000000UL,
  72. .virt = 0xf6000000UL,
  73. .size = 0x04000000UL, /* 64MiB CP110 master PCI space */
  74. .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
  75. PTE_BLOCK_NON_SHARE
  76. },
  77. {
  78. 0,
  79. }
  80. };
  81. struct mm_region *mem_map = mvebu_mem_map;
  82. void enable_caches(void)
  83. {
  84. /*
  85. * Armada 7k is not equipped with the CP110 slave CP. In case this
  86. * code runs on an Armada 7k device, lets remove the CP110 slave
  87. * entries from the memory mapping by moving the start to the
  88. * common regions.
  89. */
  90. if (of_machine_is_compatible("marvell,armada7040"))
  91. mem_map = &mvebu_mem_map[ARMADA_7K8K_COMMON_REGIONS_START];
  92. icache_enable();
  93. dcache_enable();
  94. }
  95. void reset_cpu(ulong ignored)
  96. {
  97. u32 reg;
  98. reg = readl(RFU_GLOBAL_SW_RST);
  99. reg &= ~(1 << RFU_SW_RESET_OFFSET);
  100. writel(reg, RFU_GLOBAL_SW_RST);
  101. }
  102. /*
  103. * TODO - implement this functionality using platform
  104. * clock driver once it gets available
  105. * Return NAND clock in Hz
  106. */
  107. u32 mvebu_get_nand_clock(void)
  108. {
  109. unsigned long NAND_FLASH_CLK_CTRL = 0xF2440700UL;
  110. unsigned long NF_CLOCK_SEL_MASK = 0x1;
  111. u32 reg;
  112. reg = readl(NAND_FLASH_CLK_CTRL);
  113. if (reg & NF_CLOCK_SEL_MASK)
  114. return 400 * 1000000;
  115. else
  116. return 250 * 1000000;
  117. }