common.c 20 KB

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