common.c 16 KB

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