common.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  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/serial_8250.h>
  16. #include <linux/clk.h>
  17. #include <linux/mbus.h>
  18. #include <linux/ata_platform.h>
  19. #include <linux/serial_8250.h>
  20. #include <linux/gpio.h>
  21. #include <asm/page.h>
  22. #include <asm/setup.h>
  23. #include <asm/timex.h>
  24. #include <asm/hardware/cache-tauros2.h>
  25. #include <asm/mach/map.h>
  26. #include <asm/mach/time.h>
  27. #include <asm/mach/pci.h>
  28. #include <mach/dove.h>
  29. #include <mach/bridge-regs.h>
  30. #include <asm/mach/arch.h>
  31. #include <linux/irq.h>
  32. #include <plat/mv_xor.h>
  33. #include <plat/ehci-orion.h>
  34. #include <plat/time.h>
  35. #include <plat/common.h>
  36. #include "common.h"
  37. static int get_tclk(void);
  38. /*****************************************************************************
  39. * I/O Address Mapping
  40. ****************************************************************************/
  41. static struct map_desc dove_io_desc[] __initdata = {
  42. {
  43. .virtual = DOVE_SB_REGS_VIRT_BASE,
  44. .pfn = __phys_to_pfn(DOVE_SB_REGS_PHYS_BASE),
  45. .length = DOVE_SB_REGS_SIZE,
  46. .type = MT_DEVICE,
  47. }, {
  48. .virtual = DOVE_NB_REGS_VIRT_BASE,
  49. .pfn = __phys_to_pfn(DOVE_NB_REGS_PHYS_BASE),
  50. .length = DOVE_NB_REGS_SIZE,
  51. .type = MT_DEVICE,
  52. }, {
  53. .virtual = DOVE_PCIE0_IO_VIRT_BASE,
  54. .pfn = __phys_to_pfn(DOVE_PCIE0_IO_PHYS_BASE),
  55. .length = DOVE_PCIE0_IO_SIZE,
  56. .type = MT_DEVICE,
  57. }, {
  58. .virtual = DOVE_PCIE1_IO_VIRT_BASE,
  59. .pfn = __phys_to_pfn(DOVE_PCIE1_IO_PHYS_BASE),
  60. .length = DOVE_PCIE1_IO_SIZE,
  61. .type = MT_DEVICE,
  62. },
  63. };
  64. void __init dove_map_io(void)
  65. {
  66. iotable_init(dove_io_desc, ARRAY_SIZE(dove_io_desc));
  67. }
  68. /*****************************************************************************
  69. * EHCI
  70. ****************************************************************************/
  71. static struct orion_ehci_data dove_ehci_data = {
  72. .dram = &dove_mbus_dram_info,
  73. .phy_version = EHCI_PHY_NA,
  74. };
  75. static u64 ehci_dmamask = DMA_BIT_MASK(32);
  76. /*****************************************************************************
  77. * EHCI0
  78. ****************************************************************************/
  79. static struct resource dove_ehci0_resources[] = {
  80. {
  81. .start = DOVE_USB0_PHYS_BASE,
  82. .end = DOVE_USB0_PHYS_BASE + SZ_4K - 1,
  83. .flags = IORESOURCE_MEM,
  84. }, {
  85. .start = IRQ_DOVE_USB0,
  86. .end = IRQ_DOVE_USB0,
  87. .flags = IORESOURCE_IRQ,
  88. },
  89. };
  90. static struct platform_device dove_ehci0 = {
  91. .name = "orion-ehci",
  92. .id = 0,
  93. .dev = {
  94. .dma_mask = &ehci_dmamask,
  95. .coherent_dma_mask = DMA_BIT_MASK(32),
  96. .platform_data = &dove_ehci_data,
  97. },
  98. .resource = dove_ehci0_resources,
  99. .num_resources = ARRAY_SIZE(dove_ehci0_resources),
  100. };
  101. void __init dove_ehci0_init(void)
  102. {
  103. platform_device_register(&dove_ehci0);
  104. }
  105. /*****************************************************************************
  106. * EHCI1
  107. ****************************************************************************/
  108. static struct resource dove_ehci1_resources[] = {
  109. {
  110. .start = DOVE_USB1_PHYS_BASE,
  111. .end = DOVE_USB1_PHYS_BASE + SZ_4K - 1,
  112. .flags = IORESOURCE_MEM,
  113. }, {
  114. .start = IRQ_DOVE_USB1,
  115. .end = IRQ_DOVE_USB1,
  116. .flags = IORESOURCE_IRQ,
  117. },
  118. };
  119. static struct platform_device dove_ehci1 = {
  120. .name = "orion-ehci",
  121. .id = 1,
  122. .dev = {
  123. .dma_mask = &ehci_dmamask,
  124. .coherent_dma_mask = DMA_BIT_MASK(32),
  125. .platform_data = &dove_ehci_data,
  126. },
  127. .resource = dove_ehci1_resources,
  128. .num_resources = ARRAY_SIZE(dove_ehci1_resources),
  129. };
  130. void __init dove_ehci1_init(void)
  131. {
  132. platform_device_register(&dove_ehci1);
  133. }
  134. /*****************************************************************************
  135. * GE00
  136. ****************************************************************************/
  137. void __init dove_ge00_init(struct mv643xx_eth_platform_data *eth_data)
  138. {
  139. orion_ge00_init(eth_data, &dove_mbus_dram_info,
  140. DOVE_GE00_PHYS_BASE, IRQ_DOVE_GE00_SUM,
  141. 0, get_tclk());
  142. }
  143. /*****************************************************************************
  144. * SoC RTC
  145. ****************************************************************************/
  146. void __init dove_rtc_init(void)
  147. {
  148. orion_rtc_init(DOVE_RTC_PHYS_BASE, IRQ_DOVE_RTC);
  149. }
  150. /*****************************************************************************
  151. * SATA
  152. ****************************************************************************/
  153. static struct resource dove_sata_resources[] = {
  154. {
  155. .name = "sata base",
  156. .start = DOVE_SATA_PHYS_BASE,
  157. .end = DOVE_SATA_PHYS_BASE + 0x5000 - 1,
  158. .flags = IORESOURCE_MEM,
  159. }, {
  160. .name = "sata irq",
  161. .start = IRQ_DOVE_SATA,
  162. .end = IRQ_DOVE_SATA,
  163. .flags = IORESOURCE_IRQ,
  164. },
  165. };
  166. static struct platform_device dove_sata = {
  167. .name = "sata_mv",
  168. .id = 0,
  169. .dev = {
  170. .coherent_dma_mask = DMA_BIT_MASK(32),
  171. },
  172. .num_resources = ARRAY_SIZE(dove_sata_resources),
  173. .resource = dove_sata_resources,
  174. };
  175. void __init dove_sata_init(struct mv_sata_platform_data *sata_data)
  176. {
  177. sata_data->dram = &dove_mbus_dram_info;
  178. dove_sata.dev.platform_data = sata_data;
  179. platform_device_register(&dove_sata);
  180. }
  181. /*****************************************************************************
  182. * UART0
  183. ****************************************************************************/
  184. void __init dove_uart0_init(void)
  185. {
  186. orion_uart0_init(DOVE_UART0_VIRT_BASE, DOVE_UART0_PHYS_BASE,
  187. IRQ_DOVE_UART_0, get_tclk());
  188. }
  189. /*****************************************************************************
  190. * UART1
  191. ****************************************************************************/
  192. void __init dove_uart1_init(void)
  193. {
  194. orion_uart1_init(DOVE_UART1_VIRT_BASE, DOVE_UART1_PHYS_BASE,
  195. IRQ_DOVE_UART_1, get_tclk());
  196. }
  197. /*****************************************************************************
  198. * UART2
  199. ****************************************************************************/
  200. void __init dove_uart2_init(void)
  201. {
  202. orion_uart2_init(DOVE_UART2_VIRT_BASE, DOVE_UART2_PHYS_BASE,
  203. IRQ_DOVE_UART_2, get_tclk());
  204. }
  205. /*****************************************************************************
  206. * UART3
  207. ****************************************************************************/
  208. void __init dove_uart3_init(void)
  209. {
  210. orion_uart3_init(DOVE_UART3_VIRT_BASE, DOVE_UART3_PHYS_BASE,
  211. IRQ_DOVE_UART_3, get_tclk());
  212. }
  213. /*****************************************************************************
  214. * SPI
  215. ****************************************************************************/
  216. void __init dove_spi0_init(void)
  217. {
  218. orion_spi_init(DOVE_SPI0_PHYS_BASE, get_tclk());
  219. }
  220. void __init dove_spi1_init(void)
  221. {
  222. orion_spi_init(DOVE_SPI1_PHYS_BASE, get_tclk());
  223. }
  224. /*****************************************************************************
  225. * I2C
  226. ****************************************************************************/
  227. void __init dove_i2c_init(void)
  228. {
  229. orion_i2c_init(DOVE_I2C_PHYS_BASE, IRQ_DOVE_I2C, 10);
  230. }
  231. /*****************************************************************************
  232. * Time handling
  233. ****************************************************************************/
  234. void __init dove_init_early(void)
  235. {
  236. orion_time_set_base(TIMER_VIRT_BASE);
  237. }
  238. static int get_tclk(void)
  239. {
  240. /* use DOVE_RESET_SAMPLE_HI/LO to detect tclk */
  241. return 166666667;
  242. }
  243. static void dove_timer_init(void)
  244. {
  245. orion_time_init(BRIDGE_VIRT_BASE, BRIDGE_INT_TIMER1_CLR,
  246. IRQ_DOVE_BRIDGE, get_tclk());
  247. }
  248. struct sys_timer dove_timer = {
  249. .init = dove_timer_init,
  250. };
  251. /*****************************************************************************
  252. * XOR
  253. ****************************************************************************/
  254. static struct mv_xor_platform_shared_data dove_xor_shared_data = {
  255. .dram = &dove_mbus_dram_info,
  256. };
  257. /*****************************************************************************
  258. * XOR 0
  259. ****************************************************************************/
  260. static u64 dove_xor0_dmamask = DMA_BIT_MASK(32);
  261. static struct resource dove_xor0_shared_resources[] = {
  262. {
  263. .name = "xor 0 low",
  264. .start = DOVE_XOR0_PHYS_BASE,
  265. .end = DOVE_XOR0_PHYS_BASE + 0xff,
  266. .flags = IORESOURCE_MEM,
  267. }, {
  268. .name = "xor 0 high",
  269. .start = DOVE_XOR0_HIGH_PHYS_BASE,
  270. .end = DOVE_XOR0_HIGH_PHYS_BASE + 0xff,
  271. .flags = IORESOURCE_MEM,
  272. },
  273. };
  274. static struct platform_device dove_xor0_shared = {
  275. .name = MV_XOR_SHARED_NAME,
  276. .id = 0,
  277. .dev = {
  278. .platform_data = &dove_xor_shared_data,
  279. },
  280. .num_resources = ARRAY_SIZE(dove_xor0_shared_resources),
  281. .resource = dove_xor0_shared_resources,
  282. };
  283. static struct resource dove_xor00_resources[] = {
  284. [0] = {
  285. .start = IRQ_DOVE_XOR_00,
  286. .end = IRQ_DOVE_XOR_00,
  287. .flags = IORESOURCE_IRQ,
  288. },
  289. };
  290. static struct mv_xor_platform_data dove_xor00_data = {
  291. .shared = &dove_xor0_shared,
  292. .hw_id = 0,
  293. .pool_size = PAGE_SIZE,
  294. };
  295. static struct platform_device dove_xor00_channel = {
  296. .name = MV_XOR_NAME,
  297. .id = 0,
  298. .num_resources = ARRAY_SIZE(dove_xor00_resources),
  299. .resource = dove_xor00_resources,
  300. .dev = {
  301. .dma_mask = &dove_xor0_dmamask,
  302. .coherent_dma_mask = DMA_BIT_MASK(64),
  303. .platform_data = &dove_xor00_data,
  304. },
  305. };
  306. static struct resource dove_xor01_resources[] = {
  307. [0] = {
  308. .start = IRQ_DOVE_XOR_01,
  309. .end = IRQ_DOVE_XOR_01,
  310. .flags = IORESOURCE_IRQ,
  311. },
  312. };
  313. static struct mv_xor_platform_data dove_xor01_data = {
  314. .shared = &dove_xor0_shared,
  315. .hw_id = 1,
  316. .pool_size = PAGE_SIZE,
  317. };
  318. static struct platform_device dove_xor01_channel = {
  319. .name = MV_XOR_NAME,
  320. .id = 1,
  321. .num_resources = ARRAY_SIZE(dove_xor01_resources),
  322. .resource = dove_xor01_resources,
  323. .dev = {
  324. .dma_mask = &dove_xor0_dmamask,
  325. .coherent_dma_mask = DMA_BIT_MASK(64),
  326. .platform_data = &dove_xor01_data,
  327. },
  328. };
  329. void __init dove_xor0_init(void)
  330. {
  331. platform_device_register(&dove_xor0_shared);
  332. /*
  333. * two engines can't do memset simultaneously, this limitation
  334. * satisfied by removing memset support from one of the engines.
  335. */
  336. dma_cap_set(DMA_MEMCPY, dove_xor00_data.cap_mask);
  337. dma_cap_set(DMA_XOR, dove_xor00_data.cap_mask);
  338. platform_device_register(&dove_xor00_channel);
  339. dma_cap_set(DMA_MEMCPY, dove_xor01_data.cap_mask);
  340. dma_cap_set(DMA_MEMSET, dove_xor01_data.cap_mask);
  341. dma_cap_set(DMA_XOR, dove_xor01_data.cap_mask);
  342. platform_device_register(&dove_xor01_channel);
  343. }
  344. /*****************************************************************************
  345. * XOR 1
  346. ****************************************************************************/
  347. static u64 dove_xor1_dmamask = DMA_BIT_MASK(32);
  348. static struct resource dove_xor1_shared_resources[] = {
  349. {
  350. .name = "xor 0 low",
  351. .start = DOVE_XOR1_PHYS_BASE,
  352. .end = DOVE_XOR1_PHYS_BASE + 0xff,
  353. .flags = IORESOURCE_MEM,
  354. }, {
  355. .name = "xor 0 high",
  356. .start = DOVE_XOR1_HIGH_PHYS_BASE,
  357. .end = DOVE_XOR1_HIGH_PHYS_BASE + 0xff,
  358. .flags = IORESOURCE_MEM,
  359. },
  360. };
  361. static struct platform_device dove_xor1_shared = {
  362. .name = MV_XOR_SHARED_NAME,
  363. .id = 1,
  364. .dev = {
  365. .platform_data = &dove_xor_shared_data,
  366. },
  367. .num_resources = ARRAY_SIZE(dove_xor1_shared_resources),
  368. .resource = dove_xor1_shared_resources,
  369. };
  370. static struct resource dove_xor10_resources[] = {
  371. [0] = {
  372. .start = IRQ_DOVE_XOR_10,
  373. .end = IRQ_DOVE_XOR_10,
  374. .flags = IORESOURCE_IRQ,
  375. },
  376. };
  377. static struct mv_xor_platform_data dove_xor10_data = {
  378. .shared = &dove_xor1_shared,
  379. .hw_id = 0,
  380. .pool_size = PAGE_SIZE,
  381. };
  382. static struct platform_device dove_xor10_channel = {
  383. .name = MV_XOR_NAME,
  384. .id = 2,
  385. .num_resources = ARRAY_SIZE(dove_xor10_resources),
  386. .resource = dove_xor10_resources,
  387. .dev = {
  388. .dma_mask = &dove_xor1_dmamask,
  389. .coherent_dma_mask = DMA_BIT_MASK(64),
  390. .platform_data = &dove_xor10_data,
  391. },
  392. };
  393. static struct resource dove_xor11_resources[] = {
  394. [0] = {
  395. .start = IRQ_DOVE_XOR_11,
  396. .end = IRQ_DOVE_XOR_11,
  397. .flags = IORESOURCE_IRQ,
  398. },
  399. };
  400. static struct mv_xor_platform_data dove_xor11_data = {
  401. .shared = &dove_xor1_shared,
  402. .hw_id = 1,
  403. .pool_size = PAGE_SIZE,
  404. };
  405. static struct platform_device dove_xor11_channel = {
  406. .name = MV_XOR_NAME,
  407. .id = 3,
  408. .num_resources = ARRAY_SIZE(dove_xor11_resources),
  409. .resource = dove_xor11_resources,
  410. .dev = {
  411. .dma_mask = &dove_xor1_dmamask,
  412. .coherent_dma_mask = DMA_BIT_MASK(64),
  413. .platform_data = &dove_xor11_data,
  414. },
  415. };
  416. void __init dove_xor1_init(void)
  417. {
  418. platform_device_register(&dove_xor1_shared);
  419. /*
  420. * two engines can't do memset simultaneously, this limitation
  421. * satisfied by removing memset support from one of the engines.
  422. */
  423. dma_cap_set(DMA_MEMCPY, dove_xor10_data.cap_mask);
  424. dma_cap_set(DMA_XOR, dove_xor10_data.cap_mask);
  425. platform_device_register(&dove_xor10_channel);
  426. dma_cap_set(DMA_MEMCPY, dove_xor11_data.cap_mask);
  427. dma_cap_set(DMA_MEMSET, dove_xor11_data.cap_mask);
  428. dma_cap_set(DMA_XOR, dove_xor11_data.cap_mask);
  429. platform_device_register(&dove_xor11_channel);
  430. }
  431. /*****************************************************************************
  432. * SDIO
  433. ****************************************************************************/
  434. static u64 sdio_dmamask = DMA_BIT_MASK(32);
  435. static struct resource dove_sdio0_resources[] = {
  436. {
  437. .start = DOVE_SDIO0_PHYS_BASE,
  438. .end = DOVE_SDIO0_PHYS_BASE + 0xff,
  439. .flags = IORESOURCE_MEM,
  440. }, {
  441. .start = IRQ_DOVE_SDIO0,
  442. .end = IRQ_DOVE_SDIO0,
  443. .flags = IORESOURCE_IRQ,
  444. },
  445. };
  446. static struct platform_device dove_sdio0 = {
  447. .name = "sdhci-dove",
  448. .id = 0,
  449. .dev = {
  450. .dma_mask = &sdio_dmamask,
  451. .coherent_dma_mask = DMA_BIT_MASK(32),
  452. },
  453. .resource = dove_sdio0_resources,
  454. .num_resources = ARRAY_SIZE(dove_sdio0_resources),
  455. };
  456. void __init dove_sdio0_init(void)
  457. {
  458. platform_device_register(&dove_sdio0);
  459. }
  460. static struct resource dove_sdio1_resources[] = {
  461. {
  462. .start = DOVE_SDIO1_PHYS_BASE,
  463. .end = DOVE_SDIO1_PHYS_BASE + 0xff,
  464. .flags = IORESOURCE_MEM,
  465. }, {
  466. .start = IRQ_DOVE_SDIO1,
  467. .end = IRQ_DOVE_SDIO1,
  468. .flags = IORESOURCE_IRQ,
  469. },
  470. };
  471. static struct platform_device dove_sdio1 = {
  472. .name = "sdhci-dove",
  473. .id = 1,
  474. .dev = {
  475. .dma_mask = &sdio_dmamask,
  476. .coherent_dma_mask = DMA_BIT_MASK(32),
  477. },
  478. .resource = dove_sdio1_resources,
  479. .num_resources = ARRAY_SIZE(dove_sdio1_resources),
  480. };
  481. void __init dove_sdio1_init(void)
  482. {
  483. platform_device_register(&dove_sdio1);
  484. }
  485. void __init dove_init(void)
  486. {
  487. int tclk;
  488. tclk = get_tclk();
  489. printk(KERN_INFO "Dove 88AP510 SoC, ");
  490. printk(KERN_INFO "TCLK = %dMHz\n", (tclk + 499999) / 1000000);
  491. #ifdef CONFIG_CACHE_TAUROS2
  492. tauros2_init();
  493. #endif
  494. dove_setup_cpu_mbus();
  495. /* internal devices that every board has */
  496. dove_rtc_init();
  497. dove_xor0_init();
  498. dove_xor1_init();
  499. }