common.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804
  1. /*
  2. * arch/arm/mach-kirkwood/common.c
  3. *
  4. * Core functions for Marvell Kirkwood SoCs
  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/init.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/serial_8250.h>
  14. #include <linux/mbus.h>
  15. #include <linux/mv643xx_eth.h>
  16. #include <linux/mv643xx_i2c.h>
  17. #include <linux/ata_platform.h>
  18. #include <linux/spi/orion_spi.h>
  19. #include <net/dsa.h>
  20. #include <asm/page.h>
  21. #include <asm/timex.h>
  22. #include <asm/mach/map.h>
  23. #include <asm/mach/time.h>
  24. #include <mach/kirkwood.h>
  25. #include <plat/cache-feroceon-l2.h>
  26. #include <plat/ehci-orion.h>
  27. #include <plat/mvsdio.h>
  28. #include <plat/mv_xor.h>
  29. #include <plat/orion_nand.h>
  30. #include <plat/time.h>
  31. #include "common.h"
  32. /*****************************************************************************
  33. * I/O Address Mapping
  34. ****************************************************************************/
  35. static struct map_desc kirkwood_io_desc[] __initdata = {
  36. {
  37. .virtual = KIRKWOOD_PCIE_IO_VIRT_BASE,
  38. .pfn = __phys_to_pfn(KIRKWOOD_PCIE_IO_PHYS_BASE),
  39. .length = KIRKWOOD_PCIE_IO_SIZE,
  40. .type = MT_DEVICE,
  41. }, {
  42. .virtual = KIRKWOOD_REGS_VIRT_BASE,
  43. .pfn = __phys_to_pfn(KIRKWOOD_REGS_PHYS_BASE),
  44. .length = KIRKWOOD_REGS_SIZE,
  45. .type = MT_DEVICE,
  46. },
  47. };
  48. void __init kirkwood_map_io(void)
  49. {
  50. iotable_init(kirkwood_io_desc, ARRAY_SIZE(kirkwood_io_desc));
  51. }
  52. /*****************************************************************************
  53. * EHCI
  54. ****************************************************************************/
  55. static struct orion_ehci_data kirkwood_ehci_data = {
  56. .dram = &kirkwood_mbus_dram_info,
  57. .phy_version = EHCI_PHY_NA,
  58. };
  59. static u64 ehci_dmamask = 0xffffffffUL;
  60. /*****************************************************************************
  61. * EHCI0
  62. ****************************************************************************/
  63. static struct resource kirkwood_ehci_resources[] = {
  64. {
  65. .start = USB_PHYS_BASE,
  66. .end = USB_PHYS_BASE + 0x0fff,
  67. .flags = IORESOURCE_MEM,
  68. }, {
  69. .start = IRQ_KIRKWOOD_USB,
  70. .end = IRQ_KIRKWOOD_USB,
  71. .flags = IORESOURCE_IRQ,
  72. },
  73. };
  74. static struct platform_device kirkwood_ehci = {
  75. .name = "orion-ehci",
  76. .id = 0,
  77. .dev = {
  78. .dma_mask = &ehci_dmamask,
  79. .coherent_dma_mask = 0xffffffff,
  80. .platform_data = &kirkwood_ehci_data,
  81. },
  82. .resource = kirkwood_ehci_resources,
  83. .num_resources = ARRAY_SIZE(kirkwood_ehci_resources),
  84. };
  85. void __init kirkwood_ehci_init(void)
  86. {
  87. platform_device_register(&kirkwood_ehci);
  88. }
  89. /*****************************************************************************
  90. * GE00
  91. ****************************************************************************/
  92. struct mv643xx_eth_shared_platform_data kirkwood_ge00_shared_data = {
  93. .dram = &kirkwood_mbus_dram_info,
  94. };
  95. static struct resource kirkwood_ge00_shared_resources[] = {
  96. {
  97. .name = "ge00 base",
  98. .start = GE00_PHYS_BASE + 0x2000,
  99. .end = GE00_PHYS_BASE + 0x3fff,
  100. .flags = IORESOURCE_MEM,
  101. }, {
  102. .name = "ge00 err irq",
  103. .start = IRQ_KIRKWOOD_GE00_ERR,
  104. .end = IRQ_KIRKWOOD_GE00_ERR,
  105. .flags = IORESOURCE_IRQ,
  106. },
  107. };
  108. static struct platform_device kirkwood_ge00_shared = {
  109. .name = MV643XX_ETH_SHARED_NAME,
  110. .id = 0,
  111. .dev = {
  112. .platform_data = &kirkwood_ge00_shared_data,
  113. },
  114. .num_resources = ARRAY_SIZE(kirkwood_ge00_shared_resources),
  115. .resource = kirkwood_ge00_shared_resources,
  116. };
  117. static struct resource kirkwood_ge00_resources[] = {
  118. {
  119. .name = "ge00 irq",
  120. .start = IRQ_KIRKWOOD_GE00_SUM,
  121. .end = IRQ_KIRKWOOD_GE00_SUM,
  122. .flags = IORESOURCE_IRQ,
  123. },
  124. };
  125. static struct platform_device kirkwood_ge00 = {
  126. .name = MV643XX_ETH_NAME,
  127. .id = 0,
  128. .num_resources = 1,
  129. .resource = kirkwood_ge00_resources,
  130. };
  131. void __init kirkwood_ge00_init(struct mv643xx_eth_platform_data *eth_data)
  132. {
  133. eth_data->shared = &kirkwood_ge00_shared;
  134. kirkwood_ge00.dev.platform_data = eth_data;
  135. platform_device_register(&kirkwood_ge00_shared);
  136. platform_device_register(&kirkwood_ge00);
  137. }
  138. /*****************************************************************************
  139. * GE01
  140. ****************************************************************************/
  141. struct mv643xx_eth_shared_platform_data kirkwood_ge01_shared_data = {
  142. .dram = &kirkwood_mbus_dram_info,
  143. .shared_smi = &kirkwood_ge00_shared,
  144. };
  145. static struct resource kirkwood_ge01_shared_resources[] = {
  146. {
  147. .name = "ge01 base",
  148. .start = GE01_PHYS_BASE + 0x2000,
  149. .end = GE01_PHYS_BASE + 0x3fff,
  150. .flags = IORESOURCE_MEM,
  151. }, {
  152. .name = "ge01 err irq",
  153. .start = IRQ_KIRKWOOD_GE01_ERR,
  154. .end = IRQ_KIRKWOOD_GE01_ERR,
  155. .flags = IORESOURCE_IRQ,
  156. },
  157. };
  158. static struct platform_device kirkwood_ge01_shared = {
  159. .name = MV643XX_ETH_SHARED_NAME,
  160. .id = 1,
  161. .dev = {
  162. .platform_data = &kirkwood_ge01_shared_data,
  163. },
  164. .num_resources = ARRAY_SIZE(kirkwood_ge01_shared_resources),
  165. .resource = kirkwood_ge01_shared_resources,
  166. };
  167. static struct resource kirkwood_ge01_resources[] = {
  168. {
  169. .name = "ge01 irq",
  170. .start = IRQ_KIRKWOOD_GE01_SUM,
  171. .end = IRQ_KIRKWOOD_GE01_SUM,
  172. .flags = IORESOURCE_IRQ,
  173. },
  174. };
  175. static struct platform_device kirkwood_ge01 = {
  176. .name = MV643XX_ETH_NAME,
  177. .id = 1,
  178. .num_resources = 1,
  179. .resource = kirkwood_ge01_resources,
  180. };
  181. void __init kirkwood_ge01_init(struct mv643xx_eth_platform_data *eth_data)
  182. {
  183. eth_data->shared = &kirkwood_ge01_shared;
  184. kirkwood_ge01.dev.platform_data = eth_data;
  185. platform_device_register(&kirkwood_ge01_shared);
  186. platform_device_register(&kirkwood_ge01);
  187. }
  188. /*****************************************************************************
  189. * Ethernet switch
  190. ****************************************************************************/
  191. static struct resource kirkwood_switch_resources[] = {
  192. {
  193. .start = 0,
  194. .end = 0,
  195. .flags = IORESOURCE_IRQ,
  196. },
  197. };
  198. static struct platform_device kirkwood_switch_device = {
  199. .name = "dsa",
  200. .id = 0,
  201. .num_resources = 0,
  202. .resource = kirkwood_switch_resources,
  203. };
  204. void __init kirkwood_ge00_switch_init(struct dsa_platform_data *d, int irq)
  205. {
  206. int i;
  207. if (irq != NO_IRQ) {
  208. kirkwood_switch_resources[0].start = irq;
  209. kirkwood_switch_resources[0].end = irq;
  210. kirkwood_switch_device.num_resources = 1;
  211. }
  212. d->netdev = &kirkwood_ge00.dev;
  213. for (i = 0; i < d->nr_chips; i++)
  214. d->chip[i].mii_bus = &kirkwood_ge00_shared.dev;
  215. kirkwood_switch_device.dev.platform_data = d;
  216. platform_device_register(&kirkwood_switch_device);
  217. }
  218. /*****************************************************************************
  219. * SoC RTC
  220. ****************************************************************************/
  221. static struct resource kirkwood_rtc_resource = {
  222. .start = RTC_PHYS_BASE,
  223. .end = RTC_PHYS_BASE + SZ_16 - 1,
  224. .flags = IORESOURCE_MEM,
  225. };
  226. static void __init kirkwood_rtc_init(void)
  227. {
  228. platform_device_register_simple("rtc-mv", -1, &kirkwood_rtc_resource, 1);
  229. }
  230. /*****************************************************************************
  231. * SATA
  232. ****************************************************************************/
  233. static struct resource kirkwood_sata_resources[] = {
  234. {
  235. .name = "sata base",
  236. .start = SATA_PHYS_BASE,
  237. .end = SATA_PHYS_BASE + 0x5000 - 1,
  238. .flags = IORESOURCE_MEM,
  239. }, {
  240. .name = "sata irq",
  241. .start = IRQ_KIRKWOOD_SATA,
  242. .end = IRQ_KIRKWOOD_SATA,
  243. .flags = IORESOURCE_IRQ,
  244. },
  245. };
  246. static struct platform_device kirkwood_sata = {
  247. .name = "sata_mv",
  248. .id = 0,
  249. .dev = {
  250. .coherent_dma_mask = 0xffffffff,
  251. },
  252. .num_resources = ARRAY_SIZE(kirkwood_sata_resources),
  253. .resource = kirkwood_sata_resources,
  254. };
  255. void __init kirkwood_sata_init(struct mv_sata_platform_data *sata_data)
  256. {
  257. sata_data->dram = &kirkwood_mbus_dram_info;
  258. kirkwood_sata.dev.platform_data = sata_data;
  259. platform_device_register(&kirkwood_sata);
  260. }
  261. /*****************************************************************************
  262. * SD/SDIO/MMC
  263. ****************************************************************************/
  264. static struct resource mvsdio_resources[] = {
  265. [0] = {
  266. .start = SDIO_PHYS_BASE,
  267. .end = SDIO_PHYS_BASE + SZ_1K - 1,
  268. .flags = IORESOURCE_MEM,
  269. },
  270. [1] = {
  271. .start = IRQ_KIRKWOOD_SDIO,
  272. .end = IRQ_KIRKWOOD_SDIO,
  273. .flags = IORESOURCE_IRQ,
  274. },
  275. };
  276. static u64 mvsdio_dmamask = 0xffffffffUL;
  277. static struct platform_device kirkwood_sdio = {
  278. .name = "mvsdio",
  279. .id = -1,
  280. .dev = {
  281. .dma_mask = &mvsdio_dmamask,
  282. .coherent_dma_mask = 0xffffffff,
  283. },
  284. .num_resources = ARRAY_SIZE(mvsdio_resources),
  285. .resource = mvsdio_resources,
  286. };
  287. void __init kirkwood_sdio_init(struct mvsdio_platform_data *mvsdio_data)
  288. {
  289. u32 dev, rev;
  290. kirkwood_pcie_id(&dev, &rev);
  291. if (rev == 0) /* catch all Kirkwood Z0's */
  292. mvsdio_data->clock = 100000000;
  293. else
  294. mvsdio_data->clock = 200000000;
  295. mvsdio_data->dram = &kirkwood_mbus_dram_info;
  296. kirkwood_sdio.dev.platform_data = mvsdio_data;
  297. platform_device_register(&kirkwood_sdio);
  298. }
  299. /*****************************************************************************
  300. * SPI
  301. ****************************************************************************/
  302. static struct orion_spi_info kirkwood_spi_plat_data = {
  303. };
  304. static struct resource kirkwood_spi_resources[] = {
  305. {
  306. .start = SPI_PHYS_BASE,
  307. .end = SPI_PHYS_BASE + SZ_512 - 1,
  308. .flags = IORESOURCE_MEM,
  309. },
  310. };
  311. static struct platform_device kirkwood_spi = {
  312. .name = "orion_spi",
  313. .id = 0,
  314. .resource = kirkwood_spi_resources,
  315. .dev = {
  316. .platform_data = &kirkwood_spi_plat_data,
  317. },
  318. .num_resources = ARRAY_SIZE(kirkwood_spi_resources),
  319. };
  320. void __init kirkwood_spi_init()
  321. {
  322. platform_device_register(&kirkwood_spi);
  323. }
  324. /*****************************************************************************
  325. * I2C
  326. ****************************************************************************/
  327. static struct mv64xxx_i2c_pdata kirkwood_i2c_pdata = {
  328. .freq_m = 8, /* assumes 166 MHz TCLK */
  329. .freq_n = 3,
  330. .timeout = 1000, /* Default timeout of 1 second */
  331. };
  332. static struct resource kirkwood_i2c_resources[] = {
  333. {
  334. .name = "i2c",
  335. .start = I2C_PHYS_BASE,
  336. .end = I2C_PHYS_BASE + 0x1f,
  337. .flags = IORESOURCE_MEM,
  338. }, {
  339. .name = "i2c",
  340. .start = IRQ_KIRKWOOD_TWSI,
  341. .end = IRQ_KIRKWOOD_TWSI,
  342. .flags = IORESOURCE_IRQ,
  343. },
  344. };
  345. static struct platform_device kirkwood_i2c = {
  346. .name = MV64XXX_I2C_CTLR_NAME,
  347. .id = 0,
  348. .num_resources = ARRAY_SIZE(kirkwood_i2c_resources),
  349. .resource = kirkwood_i2c_resources,
  350. .dev = {
  351. .platform_data = &kirkwood_i2c_pdata,
  352. },
  353. };
  354. void __init kirkwood_i2c_init(void)
  355. {
  356. platform_device_register(&kirkwood_i2c);
  357. }
  358. /*****************************************************************************
  359. * UART0
  360. ****************************************************************************/
  361. static struct plat_serial8250_port kirkwood_uart0_data[] = {
  362. {
  363. .mapbase = UART0_PHYS_BASE,
  364. .membase = (char *)UART0_VIRT_BASE,
  365. .irq = IRQ_KIRKWOOD_UART_0,
  366. .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
  367. .iotype = UPIO_MEM,
  368. .regshift = 2,
  369. .uartclk = 0,
  370. }, {
  371. },
  372. };
  373. static struct resource kirkwood_uart0_resources[] = {
  374. {
  375. .start = UART0_PHYS_BASE,
  376. .end = UART0_PHYS_BASE + 0xff,
  377. .flags = IORESOURCE_MEM,
  378. }, {
  379. .start = IRQ_KIRKWOOD_UART_0,
  380. .end = IRQ_KIRKWOOD_UART_0,
  381. .flags = IORESOURCE_IRQ,
  382. },
  383. };
  384. static struct platform_device kirkwood_uart0 = {
  385. .name = "serial8250",
  386. .id = 0,
  387. .dev = {
  388. .platform_data = kirkwood_uart0_data,
  389. },
  390. .resource = kirkwood_uart0_resources,
  391. .num_resources = ARRAY_SIZE(kirkwood_uart0_resources),
  392. };
  393. void __init kirkwood_uart0_init(void)
  394. {
  395. platform_device_register(&kirkwood_uart0);
  396. }
  397. /*****************************************************************************
  398. * UART1
  399. ****************************************************************************/
  400. static struct plat_serial8250_port kirkwood_uart1_data[] = {
  401. {
  402. .mapbase = UART1_PHYS_BASE,
  403. .membase = (char *)UART1_VIRT_BASE,
  404. .irq = IRQ_KIRKWOOD_UART_1,
  405. .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
  406. .iotype = UPIO_MEM,
  407. .regshift = 2,
  408. .uartclk = 0,
  409. }, {
  410. },
  411. };
  412. static struct resource kirkwood_uart1_resources[] = {
  413. {
  414. .start = UART1_PHYS_BASE,
  415. .end = UART1_PHYS_BASE + 0xff,
  416. .flags = IORESOURCE_MEM,
  417. }, {
  418. .start = IRQ_KIRKWOOD_UART_1,
  419. .end = IRQ_KIRKWOOD_UART_1,
  420. .flags = IORESOURCE_IRQ,
  421. },
  422. };
  423. static struct platform_device kirkwood_uart1 = {
  424. .name = "serial8250",
  425. .id = 1,
  426. .dev = {
  427. .platform_data = kirkwood_uart1_data,
  428. },
  429. .resource = kirkwood_uart1_resources,
  430. .num_resources = ARRAY_SIZE(kirkwood_uart1_resources),
  431. };
  432. void __init kirkwood_uart1_init(void)
  433. {
  434. platform_device_register(&kirkwood_uart1);
  435. }
  436. /*****************************************************************************
  437. * XOR
  438. ****************************************************************************/
  439. static struct mv_xor_platform_shared_data kirkwood_xor_shared_data = {
  440. .dram = &kirkwood_mbus_dram_info,
  441. };
  442. static u64 kirkwood_xor_dmamask = DMA_BIT_MASK(32);
  443. /*****************************************************************************
  444. * XOR0
  445. ****************************************************************************/
  446. static struct resource kirkwood_xor0_shared_resources[] = {
  447. {
  448. .name = "xor 0 low",
  449. .start = XOR0_PHYS_BASE,
  450. .end = XOR0_PHYS_BASE + 0xff,
  451. .flags = IORESOURCE_MEM,
  452. }, {
  453. .name = "xor 0 high",
  454. .start = XOR0_HIGH_PHYS_BASE,
  455. .end = XOR0_HIGH_PHYS_BASE + 0xff,
  456. .flags = IORESOURCE_MEM,
  457. },
  458. };
  459. static struct platform_device kirkwood_xor0_shared = {
  460. .name = MV_XOR_SHARED_NAME,
  461. .id = 0,
  462. .dev = {
  463. .platform_data = &kirkwood_xor_shared_data,
  464. },
  465. .num_resources = ARRAY_SIZE(kirkwood_xor0_shared_resources),
  466. .resource = kirkwood_xor0_shared_resources,
  467. };
  468. static struct resource kirkwood_xor00_resources[] = {
  469. [0] = {
  470. .start = IRQ_KIRKWOOD_XOR_00,
  471. .end = IRQ_KIRKWOOD_XOR_00,
  472. .flags = IORESOURCE_IRQ,
  473. },
  474. };
  475. static struct mv_xor_platform_data kirkwood_xor00_data = {
  476. .shared = &kirkwood_xor0_shared,
  477. .hw_id = 0,
  478. .pool_size = PAGE_SIZE,
  479. };
  480. static struct platform_device kirkwood_xor00_channel = {
  481. .name = MV_XOR_NAME,
  482. .id = 0,
  483. .num_resources = ARRAY_SIZE(kirkwood_xor00_resources),
  484. .resource = kirkwood_xor00_resources,
  485. .dev = {
  486. .dma_mask = &kirkwood_xor_dmamask,
  487. .coherent_dma_mask = DMA_BIT_MASK(64),
  488. .platform_data = (void *)&kirkwood_xor00_data,
  489. },
  490. };
  491. static struct resource kirkwood_xor01_resources[] = {
  492. [0] = {
  493. .start = IRQ_KIRKWOOD_XOR_01,
  494. .end = IRQ_KIRKWOOD_XOR_01,
  495. .flags = IORESOURCE_IRQ,
  496. },
  497. };
  498. static struct mv_xor_platform_data kirkwood_xor01_data = {
  499. .shared = &kirkwood_xor0_shared,
  500. .hw_id = 1,
  501. .pool_size = PAGE_SIZE,
  502. };
  503. static struct platform_device kirkwood_xor01_channel = {
  504. .name = MV_XOR_NAME,
  505. .id = 1,
  506. .num_resources = ARRAY_SIZE(kirkwood_xor01_resources),
  507. .resource = kirkwood_xor01_resources,
  508. .dev = {
  509. .dma_mask = &kirkwood_xor_dmamask,
  510. .coherent_dma_mask = DMA_BIT_MASK(64),
  511. .platform_data = (void *)&kirkwood_xor01_data,
  512. },
  513. };
  514. static void __init kirkwood_xor0_init(void)
  515. {
  516. platform_device_register(&kirkwood_xor0_shared);
  517. /*
  518. * two engines can't do memset simultaneously, this limitation
  519. * satisfied by removing memset support from one of the engines.
  520. */
  521. dma_cap_set(DMA_MEMCPY, kirkwood_xor00_data.cap_mask);
  522. dma_cap_set(DMA_XOR, kirkwood_xor00_data.cap_mask);
  523. platform_device_register(&kirkwood_xor00_channel);
  524. dma_cap_set(DMA_MEMCPY, kirkwood_xor01_data.cap_mask);
  525. dma_cap_set(DMA_MEMSET, kirkwood_xor01_data.cap_mask);
  526. dma_cap_set(DMA_XOR, kirkwood_xor01_data.cap_mask);
  527. platform_device_register(&kirkwood_xor01_channel);
  528. }
  529. /*****************************************************************************
  530. * XOR1
  531. ****************************************************************************/
  532. static struct resource kirkwood_xor1_shared_resources[] = {
  533. {
  534. .name = "xor 1 low",
  535. .start = XOR1_PHYS_BASE,
  536. .end = XOR1_PHYS_BASE + 0xff,
  537. .flags = IORESOURCE_MEM,
  538. }, {
  539. .name = "xor 1 high",
  540. .start = XOR1_HIGH_PHYS_BASE,
  541. .end = XOR1_HIGH_PHYS_BASE + 0xff,
  542. .flags = IORESOURCE_MEM,
  543. },
  544. };
  545. static struct platform_device kirkwood_xor1_shared = {
  546. .name = MV_XOR_SHARED_NAME,
  547. .id = 1,
  548. .dev = {
  549. .platform_data = &kirkwood_xor_shared_data,
  550. },
  551. .num_resources = ARRAY_SIZE(kirkwood_xor1_shared_resources),
  552. .resource = kirkwood_xor1_shared_resources,
  553. };
  554. static struct resource kirkwood_xor10_resources[] = {
  555. [0] = {
  556. .start = IRQ_KIRKWOOD_XOR_10,
  557. .end = IRQ_KIRKWOOD_XOR_10,
  558. .flags = IORESOURCE_IRQ,
  559. },
  560. };
  561. static struct mv_xor_platform_data kirkwood_xor10_data = {
  562. .shared = &kirkwood_xor1_shared,
  563. .hw_id = 0,
  564. .pool_size = PAGE_SIZE,
  565. };
  566. static struct platform_device kirkwood_xor10_channel = {
  567. .name = MV_XOR_NAME,
  568. .id = 2,
  569. .num_resources = ARRAY_SIZE(kirkwood_xor10_resources),
  570. .resource = kirkwood_xor10_resources,
  571. .dev = {
  572. .dma_mask = &kirkwood_xor_dmamask,
  573. .coherent_dma_mask = DMA_BIT_MASK(64),
  574. .platform_data = (void *)&kirkwood_xor10_data,
  575. },
  576. };
  577. static struct resource kirkwood_xor11_resources[] = {
  578. [0] = {
  579. .start = IRQ_KIRKWOOD_XOR_11,
  580. .end = IRQ_KIRKWOOD_XOR_11,
  581. .flags = IORESOURCE_IRQ,
  582. },
  583. };
  584. static struct mv_xor_platform_data kirkwood_xor11_data = {
  585. .shared = &kirkwood_xor1_shared,
  586. .hw_id = 1,
  587. .pool_size = PAGE_SIZE,
  588. };
  589. static struct platform_device kirkwood_xor11_channel = {
  590. .name = MV_XOR_NAME,
  591. .id = 3,
  592. .num_resources = ARRAY_SIZE(kirkwood_xor11_resources),
  593. .resource = kirkwood_xor11_resources,
  594. .dev = {
  595. .dma_mask = &kirkwood_xor_dmamask,
  596. .coherent_dma_mask = DMA_BIT_MASK(64),
  597. .platform_data = (void *)&kirkwood_xor11_data,
  598. },
  599. };
  600. static void __init kirkwood_xor1_init(void)
  601. {
  602. platform_device_register(&kirkwood_xor1_shared);
  603. /*
  604. * two engines can't do memset simultaneously, this limitation
  605. * satisfied by removing memset support from one of the engines.
  606. */
  607. dma_cap_set(DMA_MEMCPY, kirkwood_xor10_data.cap_mask);
  608. dma_cap_set(DMA_XOR, kirkwood_xor10_data.cap_mask);
  609. platform_device_register(&kirkwood_xor10_channel);
  610. dma_cap_set(DMA_MEMCPY, kirkwood_xor11_data.cap_mask);
  611. dma_cap_set(DMA_MEMSET, kirkwood_xor11_data.cap_mask);
  612. dma_cap_set(DMA_XOR, kirkwood_xor11_data.cap_mask);
  613. platform_device_register(&kirkwood_xor11_channel);
  614. }
  615. /*****************************************************************************
  616. * Time handling
  617. ****************************************************************************/
  618. int kirkwood_tclk;
  619. int __init kirkwood_find_tclk(void)
  620. {
  621. u32 dev, rev;
  622. kirkwood_pcie_id(&dev, &rev);
  623. if (dev == MV88F6281_DEV_ID && rev == MV88F6281_REV_A0)
  624. return 200000000;
  625. return 166666667;
  626. }
  627. static void kirkwood_timer_init(void)
  628. {
  629. kirkwood_tclk = kirkwood_find_tclk();
  630. orion_time_init(IRQ_KIRKWOOD_BRIDGE, kirkwood_tclk);
  631. }
  632. struct sys_timer kirkwood_timer = {
  633. .init = kirkwood_timer_init,
  634. };
  635. /*****************************************************************************
  636. * General
  637. ****************************************************************************/
  638. /*
  639. * Identify device ID and revision.
  640. */
  641. static char * __init kirkwood_id(void)
  642. {
  643. u32 dev, rev;
  644. kirkwood_pcie_id(&dev, &rev);
  645. if (dev == MV88F6281_DEV_ID) {
  646. if (rev == MV88F6281_REV_Z0)
  647. return "MV88F6281-Z0";
  648. else if (rev == MV88F6281_REV_A0)
  649. return "MV88F6281-A0";
  650. else
  651. return "MV88F6281-Rev-Unsupported";
  652. } else if (dev == MV88F6192_DEV_ID) {
  653. if (rev == MV88F6192_REV_Z0)
  654. return "MV88F6192-Z0";
  655. else if (rev == MV88F6192_REV_A0)
  656. return "MV88F6192-A0";
  657. else
  658. return "MV88F6192-Rev-Unsupported";
  659. } else if (dev == MV88F6180_DEV_ID) {
  660. if (rev == MV88F6180_REV_A0)
  661. return "MV88F6180-Rev-A0";
  662. else
  663. return "MV88F6180-Rev-Unsupported";
  664. } else {
  665. return "Device-Unknown";
  666. }
  667. }
  668. static void __init kirkwood_l2_init(void)
  669. {
  670. #ifdef CONFIG_CACHE_FEROCEON_L2_WRITETHROUGH
  671. writel(readl(L2_CONFIG_REG) | L2_WRITETHROUGH, L2_CONFIG_REG);
  672. feroceon_l2_init(1);
  673. #else
  674. writel(readl(L2_CONFIG_REG) & ~L2_WRITETHROUGH, L2_CONFIG_REG);
  675. feroceon_l2_init(0);
  676. #endif
  677. }
  678. void __init kirkwood_init(void)
  679. {
  680. printk(KERN_INFO "Kirkwood: %s, TCLK=%d.\n",
  681. kirkwood_id(), kirkwood_tclk);
  682. kirkwood_ge00_shared_data.t_clk = kirkwood_tclk;
  683. kirkwood_ge01_shared_data.t_clk = kirkwood_tclk;
  684. kirkwood_spi_plat_data.tclk = kirkwood_tclk;
  685. kirkwood_uart0_data[0].uartclk = kirkwood_tclk;
  686. kirkwood_uart1_data[0].uartclk = kirkwood_tclk;
  687. kirkwood_setup_cpu_mbus();
  688. #ifdef CONFIG_CACHE_FEROCEON_L2
  689. kirkwood_l2_init();
  690. #endif
  691. /* internal devices that every board has */
  692. kirkwood_rtc_init();
  693. kirkwood_xor0_init();
  694. kirkwood_xor1_init();
  695. }