mach-ox820.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. #include <linux/init.h>
  2. #include <linux/kernel.h>
  3. #include <linux/bug.h>
  4. #include <linux/of_platform.h>
  5. #include <linux/clocksource.h>
  6. #include <linux/clk-provider.h>
  7. #include <linux/clk.h>
  8. #include <linux/slab.h>
  9. #include <linux/gfp.h>
  10. #include <linux/reset.h>
  11. #include <asm/mach-types.h>
  12. #include <asm/mach/map.h>
  13. #include <asm/mach/arch.h>
  14. #include <asm/page.h>
  15. #include <mach/iomap.h>
  16. #include <mach/hardware.h>
  17. #include <mach/utils.h>
  18. #include <mach/smp.h>
  19. static struct map_desc ox820_io_desc[] __initdata = {
  20. {
  21. .virtual = (unsigned long)OXNAS_PERCPU_BASE_VA,
  22. .pfn = __phys_to_pfn(OXNAS_PERCPU_BASE),
  23. .length = OXNAS_PERCPU_SIZE,
  24. .type = MT_DEVICE,
  25. },
  26. {
  27. .virtual = (unsigned long)OXNAS_SYSCRTL_BASE_VA,
  28. .pfn = __phys_to_pfn(OXNAS_SYSCRTL_BASE),
  29. .length = OXNAS_SYSCRTL_SIZE,
  30. .type = MT_DEVICE,
  31. },
  32. {
  33. .virtual = (unsigned long)OXNAS_SECCRTL_BASE_VA,
  34. .pfn = __phys_to_pfn(OXNAS_SECCRTL_BASE),
  35. .length = OXNAS_SECCRTL_SIZE,
  36. .type = MT_DEVICE,
  37. },
  38. {
  39. .virtual = (unsigned long)OXNAS_RPSA_BASE_VA,
  40. .pfn = __phys_to_pfn(OXNAS_RPSA_BASE),
  41. .length = OXNAS_RPSA_SIZE,
  42. .type = MT_DEVICE,
  43. },
  44. {
  45. .virtual = (unsigned long)OXNAS_RPSC_BASE_VA,
  46. .pfn = __phys_to_pfn(OXNAS_RPSC_BASE),
  47. .length = OXNAS_RPSC_SIZE,
  48. .type = MT_DEVICE,
  49. },
  50. };
  51. void __init ox820_map_common_io(void)
  52. {
  53. debug_ll_io_init();
  54. iotable_init(ox820_io_desc, ARRAY_SIZE(ox820_io_desc));
  55. }
  56. static void __init ox820_dt_init(void)
  57. {
  58. int ret;
  59. ret = of_platform_populate(NULL, of_default_bus_match_table, NULL,
  60. NULL);
  61. if (ret) {
  62. pr_err("of_platform_populate failed: %d\n", ret);
  63. BUG();
  64. }
  65. }
  66. static void __init ox820_timer_init(void)
  67. {
  68. of_clk_init(NULL);
  69. clocksource_probe();
  70. }
  71. void ox820_init_early(void)
  72. {
  73. }
  74. void ox820_assert_system_reset(enum reboot_mode mode, const char *cmd)
  75. {
  76. u32 value;
  77. /* Assert reset to cores as per power on defaults
  78. * Don't touch the DDR interface as things will come to an impromptu stop
  79. * NB Possibly should be asserting reset for PLLB, but there are timing
  80. * concerns here according to the docs */
  81. value = BIT(SYS_CTRL_RST_COPRO) |
  82. BIT(SYS_CTRL_RST_USBHS) |
  83. BIT(SYS_CTRL_RST_USBHSPHYA) |
  84. BIT(SYS_CTRL_RST_MACA) |
  85. BIT(SYS_CTRL_RST_PCIEA) |
  86. BIT(SYS_CTRL_RST_SGDMA) |
  87. BIT(SYS_CTRL_RST_CIPHER) |
  88. BIT(SYS_CTRL_RST_SATA) |
  89. BIT(SYS_CTRL_RST_SATA_LINK) |
  90. BIT(SYS_CTRL_RST_SATA_PHY) |
  91. BIT(SYS_CTRL_RST_PCIEPHY) |
  92. BIT(SYS_CTRL_RST_STATIC) |
  93. BIT(SYS_CTRL_RST_UART1) |
  94. BIT(SYS_CTRL_RST_UART2) |
  95. BIT(SYS_CTRL_RST_MISC) |
  96. BIT(SYS_CTRL_RST_I2S) |
  97. BIT(SYS_CTRL_RST_SD) |
  98. BIT(SYS_CTRL_RST_MACB) |
  99. BIT(SYS_CTRL_RST_PCIEB) |
  100. BIT(SYS_CTRL_RST_VIDEO) |
  101. BIT(SYS_CTRL_RST_USBHSPHYB) |
  102. BIT(SYS_CTRL_RST_USBDEV);
  103. writel(value, SYS_CTRL_RST_SET_CTRL);
  104. /* Release reset to cores as per power on defaults */
  105. writel(BIT(SYS_CTRL_RST_GPIO), SYS_CTRL_RST_CLR_CTRL);
  106. /* Disable clocks to cores as per power-on defaults - must leave DDR
  107. * related clocks enabled otherwise we'll stop rather abruptly. */
  108. value =
  109. BIT(SYS_CTRL_CLK_COPRO) |
  110. BIT(SYS_CTRL_CLK_DMA) |
  111. BIT(SYS_CTRL_CLK_CIPHER) |
  112. BIT(SYS_CTRL_CLK_SD) |
  113. BIT(SYS_CTRL_CLK_SATA) |
  114. BIT(SYS_CTRL_CLK_I2S) |
  115. BIT(SYS_CTRL_CLK_USBHS) |
  116. BIT(SYS_CTRL_CLK_MAC) |
  117. BIT(SYS_CTRL_CLK_PCIEA) |
  118. BIT(SYS_CTRL_CLK_STATIC) |
  119. BIT(SYS_CTRL_CLK_MACB) |
  120. BIT(SYS_CTRL_CLK_PCIEB) |
  121. BIT(SYS_CTRL_CLK_REF600) |
  122. BIT(SYS_CTRL_CLK_USBDEV);
  123. writel(value, SYS_CTRL_CLK_CLR_CTRL);
  124. /* Enable clocks to cores as per power-on defaults */
  125. /* Set sys-control pin mux'ing as per power-on defaults */
  126. writel(0, SYS_CTRL_SECONDARY_SEL);
  127. writel(0, SYS_CTRL_TERTIARY_SEL);
  128. writel(0, SYS_CTRL_QUATERNARY_SEL);
  129. writel(0, SYS_CTRL_DEBUG_SEL);
  130. writel(0, SYS_CTRL_ALTERNATIVE_SEL);
  131. writel(0, SYS_CTRL_PULLUP_SEL);
  132. writel(0, SEC_CTRL_SECONDARY_SEL);
  133. writel(0, SEC_CTRL_TERTIARY_SEL);
  134. writel(0, SEC_CTRL_QUATERNARY_SEL);
  135. writel(0, SEC_CTRL_DEBUG_SEL);
  136. writel(0, SEC_CTRL_ALTERNATIVE_SEL);
  137. writel(0, SEC_CTRL_PULLUP_SEL);
  138. /* No need to save any state, as the ROM loader can determine whether
  139. * reset is due to power cycling or programatic action, just hit the
  140. * (self-clearing) CPU reset bit of the block reset register */
  141. value =
  142. BIT(SYS_CTRL_RST_SCU) |
  143. BIT(SYS_CTRL_RST_ARM0) |
  144. BIT(SYS_CTRL_RST_ARM1);
  145. writel(value, SYS_CTRL_RST_SET_CTRL);
  146. }
  147. static const char * const ox820_dt_board_compat[] = {
  148. "plxtech,nas7820",
  149. "plxtech,nas7821",
  150. "plxtech,nas7825",
  151. NULL
  152. };
  153. DT_MACHINE_START(OX820_DT, "PLXTECH NAS782X SoC (Flattened Device Tree)")
  154. .map_io = ox820_map_common_io,
  155. .smp = smp_ops(ox820_smp_ops),
  156. .init_early = ox820_init_early,
  157. .init_time = ox820_timer_init,
  158. .init_machine = ox820_dt_init,
  159. .restart = ox820_assert_system_reset,
  160. .dt_compat = ox820_dt_board_compat,
  161. MACHINE_END