common.c 20 KB

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