m5441x.c 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. /*
  2. * m5441x.c -- support for Coldfire m5441x processors
  3. *
  4. * (C) Copyright Steven King <sfking@fdwdc.com>
  5. */
  6. #include <linux/kernel.h>
  7. #include <linux/param.h>
  8. #include <linux/init.h>
  9. #include <linux/io.h>
  10. #include <linux/clk.h>
  11. #include <asm/machdep.h>
  12. #include <asm/coldfire.h>
  13. #include <asm/mcfsim.h>
  14. #include <asm/mcfuart.h>
  15. #include <asm/mcfdma.h>
  16. #include <asm/mcfclk.h>
  17. DEFINE_CLK(0, "flexbus", 2, MCF_CLK);
  18. DEFINE_CLK(0, "mcfcan.0", 8, MCF_CLK);
  19. DEFINE_CLK(0, "mcfcan.1", 9, MCF_CLK);
  20. DEFINE_CLK(0, "mcfi2c.1", 14, MCF_CLK);
  21. DEFINE_CLK(0, "mcfdspi.1", 15, MCF_CLK);
  22. DEFINE_CLK(0, "edma", 17, MCF_CLK);
  23. DEFINE_CLK(0, "intc.0", 18, MCF_CLK);
  24. DEFINE_CLK(0, "intc.1", 19, MCF_CLK);
  25. DEFINE_CLK(0, "intc.2", 20, MCF_CLK);
  26. DEFINE_CLK(0, "mcfi2c.0", 22, MCF_CLK);
  27. DEFINE_CLK(0, "mcfdspi.0", 23, MCF_CLK);
  28. DEFINE_CLK(0, "mcfuart.0", 24, MCF_BUSCLK);
  29. DEFINE_CLK(0, "mcfuart.1", 25, MCF_BUSCLK);
  30. DEFINE_CLK(0, "mcfuart.2", 26, MCF_BUSCLK);
  31. DEFINE_CLK(0, "mcfuart.3", 27, MCF_BUSCLK);
  32. DEFINE_CLK(0, "mcftmr.0", 28, MCF_CLK);
  33. DEFINE_CLK(0, "mcftmr.1", 29, MCF_CLK);
  34. DEFINE_CLK(0, "mcftmr.2", 30, MCF_CLK);
  35. DEFINE_CLK(0, "mcftmr.3", 31, MCF_CLK);
  36. DEFINE_CLK(0, "mcfpit.0", 32, MCF_CLK);
  37. DEFINE_CLK(0, "mcfpit.1", 33, MCF_CLK);
  38. DEFINE_CLK(0, "mcfpit.2", 34, MCF_CLK);
  39. DEFINE_CLK(0, "mcfpit.3", 35, MCF_CLK);
  40. DEFINE_CLK(0, "mcfeport.0", 37, MCF_CLK);
  41. DEFINE_CLK(0, "mcfadc.0", 38, MCF_CLK);
  42. DEFINE_CLK(0, "mcfdac.0", 39, MCF_CLK);
  43. DEFINE_CLK(0, "mcfrtc.0", 42, MCF_CLK);
  44. DEFINE_CLK(0, "mcfsim.0", 43, MCF_CLK);
  45. DEFINE_CLK(0, "mcfusb-otg.0", 44, MCF_CLK);
  46. DEFINE_CLK(0, "mcfusb-host.0", 45, MCF_CLK);
  47. DEFINE_CLK(0, "mcfddr-sram.0", 46, MCF_CLK);
  48. DEFINE_CLK(0, "mcfssi.0", 47, MCF_CLK);
  49. DEFINE_CLK(0, "pll.0", 48, MCF_CLK);
  50. DEFINE_CLK(0, "mcfrng.0", 49, MCF_CLK);
  51. DEFINE_CLK(0, "mcfssi.1", 50, MCF_CLK);
  52. DEFINE_CLK(0, "mcfsdhc.0", 51, MCF_CLK);
  53. DEFINE_CLK(0, "enet-fec.0", 53, MCF_CLK);
  54. DEFINE_CLK(0, "enet-fec.1", 54, MCF_CLK);
  55. DEFINE_CLK(0, "switch.0", 55, MCF_CLK);
  56. DEFINE_CLK(0, "switch.1", 56, MCF_CLK);
  57. DEFINE_CLK(0, "nand.0", 63, MCF_CLK);
  58. DEFINE_CLK(1, "mcfow.0", 2, MCF_CLK);
  59. DEFINE_CLK(1, "mcfi2c.2", 4, MCF_CLK);
  60. DEFINE_CLK(1, "mcfi2c.3", 5, MCF_CLK);
  61. DEFINE_CLK(1, "mcfi2c.4", 6, MCF_CLK);
  62. DEFINE_CLK(1, "mcfi2c.5", 7, MCF_CLK);
  63. DEFINE_CLK(1, "mcfuart.4", 24, MCF_BUSCLK);
  64. DEFINE_CLK(1, "mcfuart.5", 25, MCF_BUSCLK);
  65. DEFINE_CLK(1, "mcfuart.6", 26, MCF_BUSCLK);
  66. DEFINE_CLK(1, "mcfuart.7", 27, MCF_BUSCLK);
  67. DEFINE_CLK(1, "mcfuart.8", 28, MCF_BUSCLK);
  68. DEFINE_CLK(1, "mcfuart.9", 29, MCF_BUSCLK);
  69. DEFINE_CLK(1, "mcfpwm.0", 34, MCF_BUSCLK);
  70. DEFINE_CLK(1, "sys.0", 36, MCF_BUSCLK);
  71. DEFINE_CLK(1, "gpio.0", 37, MCF_BUSCLK);
  72. struct clk *mcf_clks[] = {
  73. &__clk_0_2,
  74. &__clk_0_8,
  75. &__clk_0_9,
  76. &__clk_0_14,
  77. &__clk_0_15,
  78. &__clk_0_17,
  79. &__clk_0_18,
  80. &__clk_0_19,
  81. &__clk_0_20,
  82. &__clk_0_22,
  83. &__clk_0_23,
  84. &__clk_0_24,
  85. &__clk_0_25,
  86. &__clk_0_26,
  87. &__clk_0_27,
  88. &__clk_0_28,
  89. &__clk_0_29,
  90. &__clk_0_30,
  91. &__clk_0_31,
  92. &__clk_0_32,
  93. &__clk_0_33,
  94. &__clk_0_34,
  95. &__clk_0_35,
  96. &__clk_0_37,
  97. &__clk_0_38,
  98. &__clk_0_39,
  99. &__clk_0_42,
  100. &__clk_0_43,
  101. &__clk_0_44,
  102. &__clk_0_45,
  103. &__clk_0_46,
  104. &__clk_0_47,
  105. &__clk_0_48,
  106. &__clk_0_49,
  107. &__clk_0_50,
  108. &__clk_0_51,
  109. &__clk_0_53,
  110. &__clk_0_54,
  111. &__clk_0_55,
  112. &__clk_0_56,
  113. &__clk_0_63,
  114. &__clk_1_2,
  115. &__clk_1_4,
  116. &__clk_1_5,
  117. &__clk_1_6,
  118. &__clk_1_7,
  119. &__clk_1_24,
  120. &__clk_1_25,
  121. &__clk_1_26,
  122. &__clk_1_27,
  123. &__clk_1_28,
  124. &__clk_1_29,
  125. &__clk_1_34,
  126. &__clk_1_36,
  127. &__clk_1_37,
  128. NULL,
  129. };
  130. static struct clk * const enable_clks[] __initconst = {
  131. /* make sure these clocks are enabled */
  132. &__clk_0_18, /* intc0 */
  133. &__clk_0_19, /* intc0 */
  134. &__clk_0_20, /* intc0 */
  135. &__clk_0_24, /* uart0 */
  136. &__clk_0_25, /* uart1 */
  137. &__clk_0_26, /* uart2 */
  138. &__clk_0_27, /* uart3 */
  139. &__clk_0_33, /* pit.1 */
  140. &__clk_0_37, /* eport */
  141. &__clk_0_48, /* pll */
  142. &__clk_1_36, /* CCM/reset module/Power management */
  143. &__clk_1_37, /* gpio */
  144. };
  145. static struct clk * const disable_clks[] __initconst = {
  146. &__clk_0_8, /* can.0 */
  147. &__clk_0_9, /* can.1 */
  148. &__clk_0_14, /* i2c.1 */
  149. &__clk_0_15, /* dspi.1 */
  150. &__clk_0_17, /* eDMA */
  151. &__clk_0_22, /* i2c.0 */
  152. &__clk_0_23, /* dspi.0 */
  153. &__clk_0_28, /* tmr.1 */
  154. &__clk_0_29, /* tmr.2 */
  155. &__clk_0_30, /* tmr.2 */
  156. &__clk_0_31, /* tmr.3 */
  157. &__clk_0_32, /* pit.0 */
  158. &__clk_0_34, /* pit.2 */
  159. &__clk_0_35, /* pit.3 */
  160. &__clk_0_38, /* adc */
  161. &__clk_0_39, /* dac */
  162. &__clk_0_44, /* usb otg */
  163. &__clk_0_45, /* usb host */
  164. &__clk_0_47, /* ssi.0 */
  165. &__clk_0_49, /* rng */
  166. &__clk_0_50, /* ssi.1 */
  167. &__clk_0_51, /* eSDHC */
  168. &__clk_0_53, /* enet-fec */
  169. &__clk_0_54, /* enet-fec */
  170. &__clk_0_55, /* switch.0 */
  171. &__clk_0_56, /* switch.1 */
  172. &__clk_1_2, /* 1-wire */
  173. &__clk_1_4, /* i2c.2 */
  174. &__clk_1_5, /* i2c.3 */
  175. &__clk_1_6, /* i2c.4 */
  176. &__clk_1_7, /* i2c.5 */
  177. &__clk_1_24, /* uart 4 */
  178. &__clk_1_25, /* uart 5 */
  179. &__clk_1_26, /* uart 6 */
  180. &__clk_1_27, /* uart 7 */
  181. &__clk_1_28, /* uart 8 */
  182. &__clk_1_29, /* uart 9 */
  183. };
  184. static void __init m5441x_clk_init(void)
  185. {
  186. unsigned i;
  187. for (i = 0; i < ARRAY_SIZE(enable_clks); ++i)
  188. __clk_init_enabled(enable_clks[i]);
  189. /* make sure these clocks are disabled */
  190. for (i = 0; i < ARRAY_SIZE(disable_clks); ++i)
  191. __clk_init_disabled(disable_clks[i]);
  192. }
  193. static void __init m5441x_uarts_init(void)
  194. {
  195. __raw_writeb(0x0f, MCFGPIO_PAR_UART0);
  196. __raw_writeb(0x00, MCFGPIO_PAR_UART1);
  197. __raw_writeb(0x00, MCFGPIO_PAR_UART2);
  198. }
  199. static void __init m5441x_fec_init(void)
  200. {
  201. __raw_writeb(0x03, MCFGPIO_PAR_FEC);
  202. }
  203. void __init config_BSP(char *commandp, int size)
  204. {
  205. m5441x_clk_init();
  206. mach_sched_init = hw_timer_init;
  207. m5441x_uarts_init();
  208. m5441x_fec_init();
  209. }
  210. #if IS_ENABLED(CONFIG_RTC_DRV_M5441x)
  211. static struct resource m5441x_rtc_resources[] = {
  212. {
  213. .start = MCFRTC_BASE,
  214. .end = MCFRTC_BASE + MCFRTC_SIZE - 1,
  215. .flags = IORESOURCE_MEM,
  216. },
  217. {
  218. .start = MCF_IRQ_RTC,
  219. .end = MCF_IRQ_RTC,
  220. .flags = IORESOURCE_IRQ,
  221. },
  222. };
  223. static struct platform_device m5441x_rtc = {
  224. .name = "mcfrtc",
  225. .id = 0,
  226. .resource = m5441x_rtc_resources,
  227. .num_resources = ARRAY_SIZE(m5441x_rtc_resources),
  228. };
  229. #endif
  230. static struct platform_device *m5441x_devices[] __initdata = {
  231. #if IS_ENABLED(CONFIG_RTC_DRV_M5441x)
  232. &m5441x_rtc,
  233. #endif
  234. };
  235. static int __init init_BSP(void)
  236. {
  237. platform_add_devices(m5441x_devices, ARRAY_SIZE(m5441x_devices));
  238. return 0;
  239. }
  240. arch_initcall(init_BSP);