common.c 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. /*
  2. * arch/arm/mach-dove/common.c
  3. *
  4. * Core functions for Marvell Dove 88AP510 System On Chip
  5. *
  6. * This file is licensed under the terms of the GNU General Public
  7. * License version 2. This program is licensed "as is" without any
  8. * warranty of any kind, whether express or implied.
  9. */
  10. #include <linux/kernel.h>
  11. #include <linux/delay.h>
  12. #include <linux/init.h>
  13. #include <linux/platform_device.h>
  14. #include <linux/pci.h>
  15. #include <linux/clk-provider.h>
  16. #include <linux/ata_platform.h>
  17. #include <linux/gpio.h>
  18. #include <asm/page.h>
  19. #include <asm/setup.h>
  20. #include <asm/timex.h>
  21. #include <asm/hardware/cache-tauros2.h>
  22. #include <asm/mach/map.h>
  23. #include <asm/mach/time.h>
  24. #include <asm/mach/pci.h>
  25. #include <mach/dove.h>
  26. #include <mach/bridge-regs.h>
  27. #include <asm/mach/arch.h>
  28. #include <linux/irq.h>
  29. #include <plat/time.h>
  30. #include <plat/ehci-orion.h>
  31. #include <plat/common.h>
  32. #include <plat/addr-map.h>
  33. #include "common.h"
  34. static int get_tclk(void);
  35. /*****************************************************************************
  36. * I/O Address Mapping
  37. ****************************************************************************/
  38. static struct map_desc dove_io_desc[] __initdata = {
  39. {
  40. .virtual = DOVE_SB_REGS_VIRT_BASE,
  41. .pfn = __phys_to_pfn(DOVE_SB_REGS_PHYS_BASE),
  42. .length = DOVE_SB_REGS_SIZE,
  43. .type = MT_DEVICE,
  44. }, {
  45. .virtual = DOVE_NB_REGS_VIRT_BASE,
  46. .pfn = __phys_to_pfn(DOVE_NB_REGS_PHYS_BASE),
  47. .length = DOVE_NB_REGS_SIZE,
  48. .type = MT_DEVICE,
  49. }, {
  50. .virtual = DOVE_PCIE0_IO_VIRT_BASE,
  51. .pfn = __phys_to_pfn(DOVE_PCIE0_IO_PHYS_BASE),
  52. .length = DOVE_PCIE0_IO_SIZE,
  53. .type = MT_DEVICE,
  54. }, {
  55. .virtual = DOVE_PCIE1_IO_VIRT_BASE,
  56. .pfn = __phys_to_pfn(DOVE_PCIE1_IO_PHYS_BASE),
  57. .length = DOVE_PCIE1_IO_SIZE,
  58. .type = MT_DEVICE,
  59. },
  60. };
  61. void __init dove_map_io(void)
  62. {
  63. iotable_init(dove_io_desc, ARRAY_SIZE(dove_io_desc));
  64. }
  65. /*****************************************************************************
  66. * CLK tree
  67. ****************************************************************************/
  68. static struct clk *tclk;
  69. static void __init clk_init(void)
  70. {
  71. tclk = clk_register_fixed_rate(NULL, "tclk", NULL, CLK_IS_ROOT,
  72. get_tclk());
  73. orion_clkdev_init(tclk);
  74. }
  75. /*****************************************************************************
  76. * EHCI0
  77. ****************************************************************************/
  78. void __init dove_ehci0_init(void)
  79. {
  80. orion_ehci_init(DOVE_USB0_PHYS_BASE, IRQ_DOVE_USB0, EHCI_PHY_NA);
  81. }
  82. /*****************************************************************************
  83. * EHCI1
  84. ****************************************************************************/
  85. void __init dove_ehci1_init(void)
  86. {
  87. orion_ehci_1_init(DOVE_USB1_PHYS_BASE, IRQ_DOVE_USB1);
  88. }
  89. /*****************************************************************************
  90. * GE00
  91. ****************************************************************************/
  92. void __init dove_ge00_init(struct mv643xx_eth_platform_data *eth_data)
  93. {
  94. orion_ge00_init(eth_data, DOVE_GE00_PHYS_BASE,
  95. IRQ_DOVE_GE00_SUM, IRQ_DOVE_GE00_ERR);
  96. }
  97. /*****************************************************************************
  98. * SoC RTC
  99. ****************************************************************************/
  100. void __init dove_rtc_init(void)
  101. {
  102. orion_rtc_init(DOVE_RTC_PHYS_BASE, IRQ_DOVE_RTC);
  103. }
  104. /*****************************************************************************
  105. * SATA
  106. ****************************************************************************/
  107. void __init dove_sata_init(struct mv_sata_platform_data *sata_data)
  108. {
  109. orion_sata_init(sata_data, DOVE_SATA_PHYS_BASE, IRQ_DOVE_SATA);
  110. }
  111. /*****************************************************************************
  112. * UART0
  113. ****************************************************************************/
  114. void __init dove_uart0_init(void)
  115. {
  116. orion_uart0_init(DOVE_UART0_VIRT_BASE, DOVE_UART0_PHYS_BASE,
  117. IRQ_DOVE_UART_0, tclk);
  118. }
  119. /*****************************************************************************
  120. * UART1
  121. ****************************************************************************/
  122. void __init dove_uart1_init(void)
  123. {
  124. orion_uart1_init(DOVE_UART1_VIRT_BASE, DOVE_UART1_PHYS_BASE,
  125. IRQ_DOVE_UART_1, tclk);
  126. }
  127. /*****************************************************************************
  128. * UART2
  129. ****************************************************************************/
  130. void __init dove_uart2_init(void)
  131. {
  132. orion_uart2_init(DOVE_UART2_VIRT_BASE, DOVE_UART2_PHYS_BASE,
  133. IRQ_DOVE_UART_2, tclk);
  134. }
  135. /*****************************************************************************
  136. * UART3
  137. ****************************************************************************/
  138. void __init dove_uart3_init(void)
  139. {
  140. orion_uart3_init(DOVE_UART3_VIRT_BASE, DOVE_UART3_PHYS_BASE,
  141. IRQ_DOVE_UART_3, tclk);
  142. }
  143. /*****************************************************************************
  144. * SPI
  145. ****************************************************************************/
  146. void __init dove_spi0_init(void)
  147. {
  148. orion_spi_init(DOVE_SPI0_PHYS_BASE);
  149. }
  150. void __init dove_spi1_init(void)
  151. {
  152. orion_spi_1_init(DOVE_SPI1_PHYS_BASE);
  153. }
  154. /*****************************************************************************
  155. * I2C
  156. ****************************************************************************/
  157. void __init dove_i2c_init(void)
  158. {
  159. orion_i2c_init(DOVE_I2C_PHYS_BASE, IRQ_DOVE_I2C, 10);
  160. }
  161. /*****************************************************************************
  162. * Time handling
  163. ****************************************************************************/
  164. void __init dove_init_early(void)
  165. {
  166. orion_time_set_base(TIMER_VIRT_BASE);
  167. }
  168. static int get_tclk(void)
  169. {
  170. /* use DOVE_RESET_SAMPLE_HI/LO to detect tclk */
  171. return 166666667;
  172. }
  173. static void __init dove_timer_init(void)
  174. {
  175. orion_time_init(BRIDGE_VIRT_BASE, BRIDGE_INT_TIMER1_CLR,
  176. IRQ_DOVE_BRIDGE, get_tclk());
  177. }
  178. struct sys_timer dove_timer = {
  179. .init = dove_timer_init,
  180. };
  181. /*****************************************************************************
  182. * XOR 0
  183. ****************************************************************************/
  184. void __init dove_xor0_init(void)
  185. {
  186. orion_xor0_init(DOVE_XOR0_PHYS_BASE, DOVE_XOR0_HIGH_PHYS_BASE,
  187. IRQ_DOVE_XOR_00, IRQ_DOVE_XOR_01);
  188. }
  189. /*****************************************************************************
  190. * XOR 1
  191. ****************************************************************************/
  192. void __init dove_xor1_init(void)
  193. {
  194. orion_xor1_init(DOVE_XOR1_PHYS_BASE, DOVE_XOR1_HIGH_PHYS_BASE,
  195. IRQ_DOVE_XOR_10, IRQ_DOVE_XOR_11);
  196. }
  197. /*****************************************************************************
  198. * SDIO
  199. ****************************************************************************/
  200. static u64 sdio_dmamask = DMA_BIT_MASK(32);
  201. static struct resource dove_sdio0_resources[] = {
  202. {
  203. .start = DOVE_SDIO0_PHYS_BASE,
  204. .end = DOVE_SDIO0_PHYS_BASE + 0xff,
  205. .flags = IORESOURCE_MEM,
  206. }, {
  207. .start = IRQ_DOVE_SDIO0,
  208. .end = IRQ_DOVE_SDIO0,
  209. .flags = IORESOURCE_IRQ,
  210. },
  211. };
  212. static struct platform_device dove_sdio0 = {
  213. .name = "sdhci-dove",
  214. .id = 0,
  215. .dev = {
  216. .dma_mask = &sdio_dmamask,
  217. .coherent_dma_mask = DMA_BIT_MASK(32),
  218. },
  219. .resource = dove_sdio0_resources,
  220. .num_resources = ARRAY_SIZE(dove_sdio0_resources),
  221. };
  222. void __init dove_sdio0_init(void)
  223. {
  224. platform_device_register(&dove_sdio0);
  225. }
  226. static struct resource dove_sdio1_resources[] = {
  227. {
  228. .start = DOVE_SDIO1_PHYS_BASE,
  229. .end = DOVE_SDIO1_PHYS_BASE + 0xff,
  230. .flags = IORESOURCE_MEM,
  231. }, {
  232. .start = IRQ_DOVE_SDIO1,
  233. .end = IRQ_DOVE_SDIO1,
  234. .flags = IORESOURCE_IRQ,
  235. },
  236. };
  237. static struct platform_device dove_sdio1 = {
  238. .name = "sdhci-dove",
  239. .id = 1,
  240. .dev = {
  241. .dma_mask = &sdio_dmamask,
  242. .coherent_dma_mask = DMA_BIT_MASK(32),
  243. },
  244. .resource = dove_sdio1_resources,
  245. .num_resources = ARRAY_SIZE(dove_sdio1_resources),
  246. };
  247. void __init dove_sdio1_init(void)
  248. {
  249. platform_device_register(&dove_sdio1);
  250. }
  251. void __init dove_init(void)
  252. {
  253. printk(KERN_INFO "Dove 88AP510 SoC, ");
  254. printk(KERN_INFO "TCLK = %dMHz\n", (get_tclk() + 499999) / 1000000);
  255. #ifdef CONFIG_CACHE_TAUROS2
  256. tauros2_init();
  257. #endif
  258. dove_setup_cpu_mbus();
  259. /* Setup root of clk tree */
  260. clk_init();
  261. /* internal devices that every board has */
  262. dove_rtc_init();
  263. dove_xor0_init();
  264. dove_xor1_init();
  265. }
  266. void dove_restart(char mode, const char *cmd)
  267. {
  268. /*
  269. * Enable soft reset to assert RSTOUTn.
  270. */
  271. writel(SOFT_RESET_OUT_EN, RSTOUTn_MASK);
  272. /*
  273. * Assert soft reset.
  274. */
  275. writel(SOFT_RESET, SYSTEM_SOFT_RESET);
  276. while (1)
  277. ;
  278. }