common.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803
  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. .start = I2C_PHYS_BASE,
  336. .end = I2C_PHYS_BASE + 0x1f,
  337. .flags = IORESOURCE_MEM,
  338. }, {
  339. .start = IRQ_KIRKWOOD_TWSI,
  340. .end = IRQ_KIRKWOOD_TWSI,
  341. .flags = IORESOURCE_IRQ,
  342. },
  343. };
  344. static struct platform_device kirkwood_i2c = {
  345. .name = MV64XXX_I2C_CTLR_NAME,
  346. .id = 0,
  347. .num_resources = ARRAY_SIZE(kirkwood_i2c_resources),
  348. .resource = kirkwood_i2c_resources,
  349. .dev = {
  350. .platform_data = &kirkwood_i2c_pdata,
  351. },
  352. };
  353. void __init kirkwood_i2c_init(void)
  354. {
  355. platform_device_register(&kirkwood_i2c);
  356. }
  357. /*****************************************************************************
  358. * UART0
  359. ****************************************************************************/
  360. static struct plat_serial8250_port kirkwood_uart0_data[] = {
  361. {
  362. .mapbase = UART0_PHYS_BASE,
  363. .membase = (char *)UART0_VIRT_BASE,
  364. .irq = IRQ_KIRKWOOD_UART_0,
  365. .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
  366. .iotype = UPIO_MEM,
  367. .regshift = 2,
  368. .uartclk = 0,
  369. }, {
  370. },
  371. };
  372. static struct resource kirkwood_uart0_resources[] = {
  373. {
  374. .start = UART0_PHYS_BASE,
  375. .end = UART0_PHYS_BASE + 0xff,
  376. .flags = IORESOURCE_MEM,
  377. }, {
  378. .start = IRQ_KIRKWOOD_UART_0,
  379. .end = IRQ_KIRKWOOD_UART_0,
  380. .flags = IORESOURCE_IRQ,
  381. },
  382. };
  383. static struct platform_device kirkwood_uart0 = {
  384. .name = "serial8250",
  385. .id = 0,
  386. .dev = {
  387. .platform_data = kirkwood_uart0_data,
  388. },
  389. .resource = kirkwood_uart0_resources,
  390. .num_resources = ARRAY_SIZE(kirkwood_uart0_resources),
  391. };
  392. void __init kirkwood_uart0_init(void)
  393. {
  394. platform_device_register(&kirkwood_uart0);
  395. }
  396. /*****************************************************************************
  397. * UART1
  398. ****************************************************************************/
  399. static struct plat_serial8250_port kirkwood_uart1_data[] = {
  400. {
  401. .mapbase = UART1_PHYS_BASE,
  402. .membase = (char *)UART1_VIRT_BASE,
  403. .irq = IRQ_KIRKWOOD_UART_1,
  404. .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
  405. .iotype = UPIO_MEM,
  406. .regshift = 2,
  407. .uartclk = 0,
  408. }, {
  409. },
  410. };
  411. static struct resource kirkwood_uart1_resources[] = {
  412. {
  413. .start = UART1_PHYS_BASE,
  414. .end = UART1_PHYS_BASE + 0xff,
  415. .flags = IORESOURCE_MEM,
  416. }, {
  417. .start = IRQ_KIRKWOOD_UART_1,
  418. .end = IRQ_KIRKWOOD_UART_1,
  419. .flags = IORESOURCE_IRQ,
  420. },
  421. };
  422. static struct platform_device kirkwood_uart1 = {
  423. .name = "serial8250",
  424. .id = 1,
  425. .dev = {
  426. .platform_data = kirkwood_uart1_data,
  427. },
  428. .resource = kirkwood_uart1_resources,
  429. .num_resources = ARRAY_SIZE(kirkwood_uart1_resources),
  430. };
  431. void __init kirkwood_uart1_init(void)
  432. {
  433. platform_device_register(&kirkwood_uart1);
  434. }
  435. /*****************************************************************************
  436. * XOR
  437. ****************************************************************************/
  438. static struct mv_xor_platform_shared_data kirkwood_xor_shared_data = {
  439. .dram = &kirkwood_mbus_dram_info,
  440. };
  441. static u64 kirkwood_xor_dmamask = DMA_BIT_MASK(32);
  442. /*****************************************************************************
  443. * XOR0
  444. ****************************************************************************/
  445. static struct resource kirkwood_xor0_shared_resources[] = {
  446. {
  447. .name = "xor 0 low",
  448. .start = XOR0_PHYS_BASE,
  449. .end = XOR0_PHYS_BASE + 0xff,
  450. .flags = IORESOURCE_MEM,
  451. }, {
  452. .name = "xor 0 high",
  453. .start = XOR0_HIGH_PHYS_BASE,
  454. .end = XOR0_HIGH_PHYS_BASE + 0xff,
  455. .flags = IORESOURCE_MEM,
  456. },
  457. };
  458. static struct platform_device kirkwood_xor0_shared = {
  459. .name = MV_XOR_SHARED_NAME,
  460. .id = 0,
  461. .dev = {
  462. .platform_data = &kirkwood_xor_shared_data,
  463. },
  464. .num_resources = ARRAY_SIZE(kirkwood_xor0_shared_resources),
  465. .resource = kirkwood_xor0_shared_resources,
  466. };
  467. static struct resource kirkwood_xor00_resources[] = {
  468. [0] = {
  469. .start = IRQ_KIRKWOOD_XOR_00,
  470. .end = IRQ_KIRKWOOD_XOR_00,
  471. .flags = IORESOURCE_IRQ,
  472. },
  473. };
  474. static struct mv_xor_platform_data kirkwood_xor00_data = {
  475. .shared = &kirkwood_xor0_shared,
  476. .hw_id = 0,
  477. .pool_size = PAGE_SIZE,
  478. };
  479. static struct platform_device kirkwood_xor00_channel = {
  480. .name = MV_XOR_NAME,
  481. .id = 0,
  482. .num_resources = ARRAY_SIZE(kirkwood_xor00_resources),
  483. .resource = kirkwood_xor00_resources,
  484. .dev = {
  485. .dma_mask = &kirkwood_xor_dmamask,
  486. .coherent_dma_mask = DMA_BIT_MASK(64),
  487. .platform_data = (void *)&kirkwood_xor00_data,
  488. },
  489. };
  490. static struct resource kirkwood_xor01_resources[] = {
  491. [0] = {
  492. .start = IRQ_KIRKWOOD_XOR_01,
  493. .end = IRQ_KIRKWOOD_XOR_01,
  494. .flags = IORESOURCE_IRQ,
  495. },
  496. };
  497. static struct mv_xor_platform_data kirkwood_xor01_data = {
  498. .shared = &kirkwood_xor0_shared,
  499. .hw_id = 1,
  500. .pool_size = PAGE_SIZE,
  501. };
  502. static struct platform_device kirkwood_xor01_channel = {
  503. .name = MV_XOR_NAME,
  504. .id = 1,
  505. .num_resources = ARRAY_SIZE(kirkwood_xor01_resources),
  506. .resource = kirkwood_xor01_resources,
  507. .dev = {
  508. .dma_mask = &kirkwood_xor_dmamask,
  509. .coherent_dma_mask = DMA_BIT_MASK(64),
  510. .platform_data = (void *)&kirkwood_xor01_data,
  511. },
  512. };
  513. static void __init kirkwood_xor0_init(void)
  514. {
  515. platform_device_register(&kirkwood_xor0_shared);
  516. /*
  517. * two engines can't do memset simultaneously, this limitation
  518. * satisfied by removing memset support from one of the engines.
  519. */
  520. dma_cap_set(DMA_MEMCPY, kirkwood_xor00_data.cap_mask);
  521. dma_cap_set(DMA_XOR, kirkwood_xor00_data.cap_mask);
  522. platform_device_register(&kirkwood_xor00_channel);
  523. dma_cap_set(DMA_MEMCPY, kirkwood_xor01_data.cap_mask);
  524. dma_cap_set(DMA_MEMSET, kirkwood_xor01_data.cap_mask);
  525. dma_cap_set(DMA_XOR, kirkwood_xor01_data.cap_mask);
  526. platform_device_register(&kirkwood_xor01_channel);
  527. }
  528. /*****************************************************************************
  529. * XOR1
  530. ****************************************************************************/
  531. static struct resource kirkwood_xor1_shared_resources[] = {
  532. {
  533. .name = "xor 1 low",
  534. .start = XOR1_PHYS_BASE,
  535. .end = XOR1_PHYS_BASE + 0xff,
  536. .flags = IORESOURCE_MEM,
  537. }, {
  538. .name = "xor 1 high",
  539. .start = XOR1_HIGH_PHYS_BASE,
  540. .end = XOR1_HIGH_PHYS_BASE + 0xff,
  541. .flags = IORESOURCE_MEM,
  542. },
  543. };
  544. static struct platform_device kirkwood_xor1_shared = {
  545. .name = MV_XOR_SHARED_NAME,
  546. .id = 1,
  547. .dev = {
  548. .platform_data = &kirkwood_xor_shared_data,
  549. },
  550. .num_resources = ARRAY_SIZE(kirkwood_xor1_shared_resources),
  551. .resource = kirkwood_xor1_shared_resources,
  552. };
  553. static struct resource kirkwood_xor10_resources[] = {
  554. [0] = {
  555. .start = IRQ_KIRKWOOD_XOR_10,
  556. .end = IRQ_KIRKWOOD_XOR_10,
  557. .flags = IORESOURCE_IRQ,
  558. },
  559. };
  560. static struct mv_xor_platform_data kirkwood_xor10_data = {
  561. .shared = &kirkwood_xor1_shared,
  562. .hw_id = 0,
  563. .pool_size = PAGE_SIZE,
  564. };
  565. static struct platform_device kirkwood_xor10_channel = {
  566. .name = MV_XOR_NAME,
  567. .id = 2,
  568. .num_resources = ARRAY_SIZE(kirkwood_xor10_resources),
  569. .resource = kirkwood_xor10_resources,
  570. .dev = {
  571. .dma_mask = &kirkwood_xor_dmamask,
  572. .coherent_dma_mask = DMA_BIT_MASK(64),
  573. .platform_data = (void *)&kirkwood_xor10_data,
  574. },
  575. };
  576. static struct resource kirkwood_xor11_resources[] = {
  577. [0] = {
  578. .start = IRQ_KIRKWOOD_XOR_11,
  579. .end = IRQ_KIRKWOOD_XOR_11,
  580. .flags = IORESOURCE_IRQ,
  581. },
  582. };
  583. static struct mv_xor_platform_data kirkwood_xor11_data = {
  584. .shared = &kirkwood_xor1_shared,
  585. .hw_id = 1,
  586. .pool_size = PAGE_SIZE,
  587. };
  588. static struct platform_device kirkwood_xor11_channel = {
  589. .name = MV_XOR_NAME,
  590. .id = 3,
  591. .num_resources = ARRAY_SIZE(kirkwood_xor11_resources),
  592. .resource = kirkwood_xor11_resources,
  593. .dev = {
  594. .dma_mask = &kirkwood_xor_dmamask,
  595. .coherent_dma_mask = DMA_BIT_MASK(64),
  596. .platform_data = (void *)&kirkwood_xor11_data,
  597. },
  598. };
  599. static void __init kirkwood_xor1_init(void)
  600. {
  601. platform_device_register(&kirkwood_xor1_shared);
  602. /*
  603. * two engines can't do memset simultaneously, this limitation
  604. * satisfied by removing memset support from one of the engines.
  605. */
  606. dma_cap_set(DMA_MEMCPY, kirkwood_xor10_data.cap_mask);
  607. dma_cap_set(DMA_XOR, kirkwood_xor10_data.cap_mask);
  608. platform_device_register(&kirkwood_xor10_channel);
  609. dma_cap_set(DMA_MEMCPY, kirkwood_xor11_data.cap_mask);
  610. dma_cap_set(DMA_MEMSET, kirkwood_xor11_data.cap_mask);
  611. dma_cap_set(DMA_XOR, kirkwood_xor11_data.cap_mask);
  612. platform_device_register(&kirkwood_xor11_channel);
  613. }
  614. /*****************************************************************************
  615. * Time handling
  616. ****************************************************************************/
  617. int kirkwood_tclk;
  618. int __init kirkwood_find_tclk(void)
  619. {
  620. u32 dev, rev;
  621. kirkwood_pcie_id(&dev, &rev);
  622. if (dev == MV88F6281_DEV_ID && rev == MV88F6281_REV_A0)
  623. return 200000000;
  624. return 166666667;
  625. }
  626. static void kirkwood_timer_init(void)
  627. {
  628. kirkwood_tclk = kirkwood_find_tclk();
  629. orion_time_init(IRQ_KIRKWOOD_BRIDGE, kirkwood_tclk);
  630. }
  631. struct sys_timer kirkwood_timer = {
  632. .init = kirkwood_timer_init,
  633. };
  634. /*****************************************************************************
  635. * General
  636. ****************************************************************************/
  637. /*
  638. * Identify device ID and revision.
  639. */
  640. static char * __init kirkwood_id(void)
  641. {
  642. u32 dev, rev;
  643. kirkwood_pcie_id(&dev, &rev);
  644. if (dev == MV88F6281_DEV_ID) {
  645. if (rev == MV88F6281_REV_Z0)
  646. return "MV88F6281-Z0";
  647. else if (rev == MV88F6281_REV_A0)
  648. return "MV88F6281-A0";
  649. else
  650. return "MV88F6281-Rev-Unsupported";
  651. } else if (dev == MV88F6192_DEV_ID) {
  652. if (rev == MV88F6192_REV_Z0)
  653. return "MV88F6192-Z0";
  654. else if (rev == MV88F6192_REV_A0)
  655. return "MV88F6192-A0";
  656. else
  657. return "MV88F6192-Rev-Unsupported";
  658. } else if (dev == MV88F6180_DEV_ID) {
  659. if (rev == MV88F6180_REV_A0)
  660. return "MV88F6180-Rev-A0";
  661. else
  662. return "MV88F6180-Rev-Unsupported";
  663. } else {
  664. return "Device-Unknown";
  665. }
  666. }
  667. static void __init kirkwood_l2_init(void)
  668. {
  669. #ifdef CONFIG_CACHE_FEROCEON_L2_WRITETHROUGH
  670. writel(readl(L2_CONFIG_REG) | L2_WRITETHROUGH, L2_CONFIG_REG);
  671. feroceon_l2_init(1);
  672. #else
  673. writel(readl(L2_CONFIG_REG) & ~L2_WRITETHROUGH, L2_CONFIG_REG);
  674. feroceon_l2_init(0);
  675. #endif
  676. }
  677. void __init kirkwood_init(void)
  678. {
  679. printk(KERN_INFO "Kirkwood: %s, TCLK=%d.\n",
  680. kirkwood_id(), kirkwood_tclk);
  681. kirkwood_ge00_shared_data.t_clk = kirkwood_tclk;
  682. kirkwood_ge01_shared_data.t_clk = kirkwood_tclk;
  683. kirkwood_spi_plat_data.tclk = kirkwood_tclk;
  684. kirkwood_uart0_data[0].uartclk = kirkwood_tclk;
  685. kirkwood_uart1_data[0].uartclk = kirkwood_tclk;
  686. kirkwood_setup_cpu_mbus();
  687. #ifdef CONFIG_CACHE_FEROCEON_L2
  688. kirkwood_l2_init();
  689. #endif
  690. /* internal devices that every board has */
  691. kirkwood_rtc_init();
  692. kirkwood_xor0_init();
  693. kirkwood_xor1_init();
  694. }