common.c 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941
  1. /*
  2. * arch/arm/plat-orion/common.c
  3. *
  4. * Marvell Orion SoC common setup code used by multiple mach-/common.c
  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/dma-mapping.h>
  14. #include <linux/serial_8250.h>
  15. #include <linux/ata_platform.h>
  16. #include <linux/mv643xx_eth.h>
  17. #include <linux/mv643xx_i2c.h>
  18. #include <net/dsa.h>
  19. #include <linux/spi/orion_spi.h>
  20. #include <plat/orion_wdt.h>
  21. #include <plat/mv_xor.h>
  22. #include <plat/ehci-orion.h>
  23. #include <mach/bridge-regs.h>
  24. /* Fill in the resources structure and link it into the platform
  25. device structure. There is always a memory region, and nearly
  26. always an interrupt.*/
  27. static void fill_resources(struct platform_device *device,
  28. struct resource *resources,
  29. resource_size_t mapbase,
  30. resource_size_t size,
  31. unsigned int irq)
  32. {
  33. device->resource = resources;
  34. device->num_resources = 1;
  35. resources[0].flags = IORESOURCE_MEM;
  36. resources[0].start = mapbase;
  37. resources[0].end = mapbase + size;
  38. if (irq != NO_IRQ) {
  39. device->num_resources++;
  40. resources[1].flags = IORESOURCE_IRQ;
  41. resources[1].start = irq;
  42. resources[1].end = irq;
  43. }
  44. }
  45. /*****************************************************************************
  46. * UART
  47. ****************************************************************************/
  48. static void __init uart_complete(
  49. struct platform_device *orion_uart,
  50. struct plat_serial8250_port *data,
  51. struct resource *resources,
  52. unsigned int membase,
  53. resource_size_t mapbase,
  54. unsigned int irq,
  55. unsigned int uartclk)
  56. {
  57. data->mapbase = mapbase;
  58. data->membase = (void __iomem *)membase;
  59. data->irq = irq;
  60. data->uartclk = uartclk;
  61. orion_uart->dev.platform_data = data;
  62. fill_resources(orion_uart, resources, mapbase, 0xff, irq);
  63. platform_device_register(orion_uart);
  64. }
  65. /*****************************************************************************
  66. * UART0
  67. ****************************************************************************/
  68. static struct plat_serial8250_port orion_uart0_data[] = {
  69. {
  70. .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
  71. .iotype = UPIO_MEM,
  72. .regshift = 2,
  73. }, {
  74. },
  75. };
  76. static struct resource orion_uart0_resources[2];
  77. static struct platform_device orion_uart0 = {
  78. .name = "serial8250",
  79. .id = PLAT8250_DEV_PLATFORM,
  80. };
  81. void __init orion_uart0_init(unsigned int membase,
  82. resource_size_t mapbase,
  83. unsigned int irq,
  84. unsigned int uartclk)
  85. {
  86. uart_complete(&orion_uart0, orion_uart0_data, orion_uart0_resources,
  87. membase, mapbase, irq, uartclk);
  88. }
  89. /*****************************************************************************
  90. * UART1
  91. ****************************************************************************/
  92. static struct plat_serial8250_port orion_uart1_data[] = {
  93. {
  94. .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
  95. .iotype = UPIO_MEM,
  96. .regshift = 2,
  97. }, {
  98. },
  99. };
  100. static struct resource orion_uart1_resources[2];
  101. static struct platform_device orion_uart1 = {
  102. .name = "serial8250",
  103. .id = PLAT8250_DEV_PLATFORM1,
  104. };
  105. void __init orion_uart1_init(unsigned int membase,
  106. resource_size_t mapbase,
  107. unsigned int irq,
  108. unsigned int uartclk)
  109. {
  110. uart_complete(&orion_uart1, orion_uart1_data, orion_uart1_resources,
  111. membase, mapbase, irq, uartclk);
  112. }
  113. /*****************************************************************************
  114. * UART2
  115. ****************************************************************************/
  116. static struct plat_serial8250_port orion_uart2_data[] = {
  117. {
  118. .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
  119. .iotype = UPIO_MEM,
  120. .regshift = 2,
  121. }, {
  122. },
  123. };
  124. static struct resource orion_uart2_resources[2];
  125. static struct platform_device orion_uart2 = {
  126. .name = "serial8250",
  127. .id = PLAT8250_DEV_PLATFORM2,
  128. };
  129. void __init orion_uart2_init(unsigned int membase,
  130. resource_size_t mapbase,
  131. unsigned int irq,
  132. unsigned int uartclk)
  133. {
  134. uart_complete(&orion_uart2, orion_uart2_data, orion_uart2_resources,
  135. membase, mapbase, irq, uartclk);
  136. }
  137. /*****************************************************************************
  138. * UART3
  139. ****************************************************************************/
  140. static struct plat_serial8250_port orion_uart3_data[] = {
  141. {
  142. .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
  143. .iotype = UPIO_MEM,
  144. .regshift = 2,
  145. }, {
  146. },
  147. };
  148. static struct resource orion_uart3_resources[2];
  149. static struct platform_device orion_uart3 = {
  150. .name = "serial8250",
  151. .id = 3,
  152. };
  153. void __init orion_uart3_init(unsigned int membase,
  154. resource_size_t mapbase,
  155. unsigned int irq,
  156. unsigned int uartclk)
  157. {
  158. uart_complete(&orion_uart3, orion_uart3_data, orion_uart3_resources,
  159. membase, mapbase, irq, uartclk);
  160. }
  161. /*****************************************************************************
  162. * SoC RTC
  163. ****************************************************************************/
  164. static struct resource orion_rtc_resource[2];
  165. void __init orion_rtc_init(unsigned long mapbase,
  166. unsigned long irq)
  167. {
  168. orion_rtc_resource[0].start = mapbase;
  169. orion_rtc_resource[0].end = mapbase + SZ_32 - 1;
  170. orion_rtc_resource[0].flags = IORESOURCE_MEM;
  171. orion_rtc_resource[1].start = irq;
  172. orion_rtc_resource[1].end = irq;
  173. orion_rtc_resource[1].flags = IORESOURCE_IRQ;
  174. platform_device_register_simple("rtc-mv", -1, orion_rtc_resource, 2);
  175. }
  176. /*****************************************************************************
  177. * GE
  178. ****************************************************************************/
  179. static __init void ge_complete(
  180. struct mv643xx_eth_shared_platform_data *orion_ge_shared_data,
  181. int tclk,
  182. struct resource *orion_ge_resource, unsigned long irq,
  183. struct platform_device *orion_ge_shared,
  184. struct mv643xx_eth_platform_data *eth_data,
  185. struct platform_device *orion_ge)
  186. {
  187. orion_ge_shared_data->t_clk = tclk;
  188. orion_ge_resource->start = irq;
  189. orion_ge_resource->end = irq;
  190. eth_data->shared = orion_ge_shared;
  191. orion_ge->dev.platform_data = eth_data;
  192. platform_device_register(orion_ge_shared);
  193. platform_device_register(orion_ge);
  194. }
  195. /*****************************************************************************
  196. * GE00
  197. ****************************************************************************/
  198. struct mv643xx_eth_shared_platform_data orion_ge00_shared_data;
  199. static struct resource orion_ge00_shared_resources[] = {
  200. {
  201. .name = "ge00 base",
  202. }, {
  203. .name = "ge00 err irq",
  204. },
  205. };
  206. static struct platform_device orion_ge00_shared = {
  207. .name = MV643XX_ETH_SHARED_NAME,
  208. .id = 0,
  209. .dev = {
  210. .platform_data = &orion_ge00_shared_data,
  211. },
  212. };
  213. static struct resource orion_ge00_resources[] = {
  214. {
  215. .name = "ge00 irq",
  216. .flags = IORESOURCE_IRQ,
  217. },
  218. };
  219. static struct platform_device orion_ge00 = {
  220. .name = MV643XX_ETH_NAME,
  221. .id = 0,
  222. .num_resources = 1,
  223. .resource = orion_ge00_resources,
  224. .dev = {
  225. .coherent_dma_mask = DMA_BIT_MASK(32),
  226. },
  227. };
  228. void __init orion_ge00_init(struct mv643xx_eth_platform_data *eth_data,
  229. unsigned long mapbase,
  230. unsigned long irq,
  231. unsigned long irq_err,
  232. int tclk,
  233. unsigned int tx_csum_limit)
  234. {
  235. fill_resources(&orion_ge00_shared, orion_ge00_shared_resources,
  236. mapbase + 0x2000, SZ_16K - 1, irq_err);
  237. orion_ge00_shared_data.tx_csum_limit = tx_csum_limit;
  238. ge_complete(&orion_ge00_shared_data, tclk,
  239. orion_ge00_resources, irq, &orion_ge00_shared,
  240. eth_data, &orion_ge00);
  241. }
  242. /*****************************************************************************
  243. * GE01
  244. ****************************************************************************/
  245. struct mv643xx_eth_shared_platform_data orion_ge01_shared_data = {
  246. .shared_smi = &orion_ge00_shared,
  247. };
  248. static struct resource orion_ge01_shared_resources[] = {
  249. {
  250. .name = "ge01 base",
  251. }, {
  252. .name = "ge01 err irq",
  253. },
  254. };
  255. static struct platform_device orion_ge01_shared = {
  256. .name = MV643XX_ETH_SHARED_NAME,
  257. .id = 1,
  258. .dev = {
  259. .platform_data = &orion_ge01_shared_data,
  260. },
  261. };
  262. static struct resource orion_ge01_resources[] = {
  263. {
  264. .name = "ge01 irq",
  265. .flags = IORESOURCE_IRQ,
  266. },
  267. };
  268. static struct platform_device orion_ge01 = {
  269. .name = MV643XX_ETH_NAME,
  270. .id = 1,
  271. .num_resources = 1,
  272. .resource = orion_ge01_resources,
  273. .dev = {
  274. .coherent_dma_mask = DMA_BIT_MASK(32),
  275. },
  276. };
  277. void __init orion_ge01_init(struct mv643xx_eth_platform_data *eth_data,
  278. unsigned long mapbase,
  279. unsigned long irq,
  280. unsigned long irq_err,
  281. int tclk,
  282. unsigned int tx_csum_limit)
  283. {
  284. fill_resources(&orion_ge01_shared, orion_ge01_shared_resources,
  285. mapbase + 0x2000, SZ_16K - 1, irq_err);
  286. orion_ge01_shared_data.tx_csum_limit = tx_csum_limit;
  287. ge_complete(&orion_ge01_shared_data, tclk,
  288. orion_ge01_resources, irq, &orion_ge01_shared,
  289. eth_data, &orion_ge01);
  290. }
  291. /*****************************************************************************
  292. * GE10
  293. ****************************************************************************/
  294. struct mv643xx_eth_shared_platform_data orion_ge10_shared_data = {
  295. .shared_smi = &orion_ge00_shared,
  296. };
  297. static struct resource orion_ge10_shared_resources[] = {
  298. {
  299. .name = "ge10 base",
  300. }, {
  301. .name = "ge10 err irq",
  302. },
  303. };
  304. static struct platform_device orion_ge10_shared = {
  305. .name = MV643XX_ETH_SHARED_NAME,
  306. .id = 2,
  307. .dev = {
  308. .platform_data = &orion_ge10_shared_data,
  309. },
  310. };
  311. static struct resource orion_ge10_resources[] = {
  312. {
  313. .name = "ge10 irq",
  314. .flags = IORESOURCE_IRQ,
  315. },
  316. };
  317. static struct platform_device orion_ge10 = {
  318. .name = MV643XX_ETH_NAME,
  319. .id = 2,
  320. .num_resources = 1,
  321. .resource = orion_ge10_resources,
  322. .dev = {
  323. .coherent_dma_mask = DMA_BIT_MASK(32),
  324. },
  325. };
  326. void __init orion_ge10_init(struct mv643xx_eth_platform_data *eth_data,
  327. unsigned long mapbase,
  328. unsigned long irq,
  329. unsigned long irq_err,
  330. int tclk)
  331. {
  332. fill_resources(&orion_ge10_shared, orion_ge10_shared_resources,
  333. mapbase + 0x2000, SZ_16K - 1, irq_err);
  334. ge_complete(&orion_ge10_shared_data, tclk,
  335. orion_ge10_resources, irq, &orion_ge10_shared,
  336. eth_data, &orion_ge10);
  337. }
  338. /*****************************************************************************
  339. * GE11
  340. ****************************************************************************/
  341. struct mv643xx_eth_shared_platform_data orion_ge11_shared_data = {
  342. .shared_smi = &orion_ge00_shared,
  343. };
  344. static struct resource orion_ge11_shared_resources[] = {
  345. {
  346. .name = "ge11 base",
  347. }, {
  348. .name = "ge11 err irq",
  349. },
  350. };
  351. static struct platform_device orion_ge11_shared = {
  352. .name = MV643XX_ETH_SHARED_NAME,
  353. .id = 3,
  354. .dev = {
  355. .platform_data = &orion_ge11_shared_data,
  356. },
  357. };
  358. static struct resource orion_ge11_resources[] = {
  359. {
  360. .name = "ge11 irq",
  361. .flags = IORESOURCE_IRQ,
  362. },
  363. };
  364. static struct platform_device orion_ge11 = {
  365. .name = MV643XX_ETH_NAME,
  366. .id = 3,
  367. .num_resources = 1,
  368. .resource = orion_ge11_resources,
  369. .dev = {
  370. .coherent_dma_mask = DMA_BIT_MASK(32),
  371. },
  372. };
  373. void __init orion_ge11_init(struct mv643xx_eth_platform_data *eth_data,
  374. unsigned long mapbase,
  375. unsigned long irq,
  376. unsigned long irq_err,
  377. int tclk)
  378. {
  379. fill_resources(&orion_ge11_shared, orion_ge11_shared_resources,
  380. mapbase + 0x2000, SZ_16K - 1, irq_err);
  381. ge_complete(&orion_ge11_shared_data, tclk,
  382. orion_ge11_resources, irq, &orion_ge11_shared,
  383. eth_data, &orion_ge11);
  384. }
  385. /*****************************************************************************
  386. * Ethernet switch
  387. ****************************************************************************/
  388. static struct resource orion_switch_resources[] = {
  389. {
  390. .start = 0,
  391. .end = 0,
  392. .flags = IORESOURCE_IRQ,
  393. },
  394. };
  395. static struct platform_device orion_switch_device = {
  396. .name = "dsa",
  397. .id = 0,
  398. .num_resources = 0,
  399. .resource = orion_switch_resources,
  400. };
  401. void __init orion_ge00_switch_init(struct dsa_platform_data *d, int irq)
  402. {
  403. int i;
  404. if (irq != NO_IRQ) {
  405. orion_switch_resources[0].start = irq;
  406. orion_switch_resources[0].end = irq;
  407. orion_switch_device.num_resources = 1;
  408. }
  409. d->netdev = &orion_ge00.dev;
  410. for (i = 0; i < d->nr_chips; i++)
  411. d->chip[i].mii_bus = &orion_ge00_shared.dev;
  412. orion_switch_device.dev.platform_data = d;
  413. platform_device_register(&orion_switch_device);
  414. }
  415. /*****************************************************************************
  416. * I2C
  417. ****************************************************************************/
  418. static struct mv64xxx_i2c_pdata orion_i2c_pdata = {
  419. .freq_n = 3,
  420. .timeout = 1000, /* Default timeout of 1 second */
  421. };
  422. static struct resource orion_i2c_resources[2];
  423. static struct platform_device orion_i2c = {
  424. .name = MV64XXX_I2C_CTLR_NAME,
  425. .id = 0,
  426. .dev = {
  427. .platform_data = &orion_i2c_pdata,
  428. },
  429. };
  430. static struct mv64xxx_i2c_pdata orion_i2c_1_pdata = {
  431. .freq_n = 3,
  432. .timeout = 1000, /* Default timeout of 1 second */
  433. };
  434. static struct resource orion_i2c_1_resources[2];
  435. static struct platform_device orion_i2c_1 = {
  436. .name = MV64XXX_I2C_CTLR_NAME,
  437. .id = 1,
  438. .dev = {
  439. .platform_data = &orion_i2c_1_pdata,
  440. },
  441. };
  442. void __init orion_i2c_init(unsigned long mapbase,
  443. unsigned long irq,
  444. unsigned long freq_m)
  445. {
  446. orion_i2c_pdata.freq_m = freq_m;
  447. fill_resources(&orion_i2c, orion_i2c_resources, mapbase,
  448. SZ_32 - 1, irq);
  449. platform_device_register(&orion_i2c);
  450. }
  451. void __init orion_i2c_1_init(unsigned long mapbase,
  452. unsigned long irq,
  453. unsigned long freq_m)
  454. {
  455. orion_i2c_1_pdata.freq_m = freq_m;
  456. fill_resources(&orion_i2c_1, orion_i2c_1_resources, mapbase,
  457. SZ_32 - 1, irq);
  458. platform_device_register(&orion_i2c_1);
  459. }
  460. /*****************************************************************************
  461. * SPI
  462. ****************************************************************************/
  463. static struct orion_spi_info orion_spi_plat_data;
  464. static struct resource orion_spi_resources;
  465. static struct platform_device orion_spi = {
  466. .name = "orion_spi",
  467. .id = 0,
  468. .dev = {
  469. .platform_data = &orion_spi_plat_data,
  470. },
  471. };
  472. static struct orion_spi_info orion_spi_1_plat_data;
  473. static struct resource orion_spi_1_resources;
  474. static struct platform_device orion_spi_1 = {
  475. .name = "orion_spi",
  476. .id = 1,
  477. .dev = {
  478. .platform_data = &orion_spi_1_plat_data,
  479. },
  480. };
  481. /* Note: The SPI silicon core does have interrupts. However the
  482. * current Linux software driver does not use interrupts. */
  483. void __init orion_spi_init(unsigned long mapbase,
  484. unsigned long tclk)
  485. {
  486. orion_spi_plat_data.tclk = tclk;
  487. fill_resources(&orion_spi, &orion_spi_resources,
  488. mapbase, SZ_512 - 1, NO_IRQ);
  489. platform_device_register(&orion_spi);
  490. }
  491. void __init orion_spi_1_init(unsigned long mapbase,
  492. unsigned long tclk)
  493. {
  494. orion_spi_1_plat_data.tclk = tclk;
  495. fill_resources(&orion_spi_1, &orion_spi_1_resources,
  496. mapbase, SZ_512 - 1, NO_IRQ);
  497. platform_device_register(&orion_spi_1);
  498. }
  499. /*****************************************************************************
  500. * Watchdog
  501. ****************************************************************************/
  502. static struct orion_wdt_platform_data orion_wdt_data;
  503. static struct resource orion_wdt_resource =
  504. DEFINE_RES_MEM(TIMER_PHYS_BASE, 0x28);
  505. static struct platform_device orion_wdt_device = {
  506. .name = "orion_wdt",
  507. .id = -1,
  508. .dev = {
  509. .platform_data = &orion_wdt_data,
  510. },
  511. .resource = &orion_wdt_resource,
  512. .num_resources = 1,
  513. };
  514. void __init orion_wdt_init(unsigned long tclk)
  515. {
  516. orion_wdt_data.tclk = tclk;
  517. platform_device_register(&orion_wdt_device);
  518. }
  519. /*****************************************************************************
  520. * XOR
  521. ****************************************************************************/
  522. static u64 orion_xor_dmamask = DMA_BIT_MASK(32);
  523. void __init orion_xor_init_channels(
  524. struct mv_xor_platform_data *orion_xor0_data,
  525. struct platform_device *orion_xor0_channel,
  526. struct mv_xor_platform_data *orion_xor1_data,
  527. struct platform_device *orion_xor1_channel)
  528. {
  529. /*
  530. * two engines can't do memset simultaneously, this limitation
  531. * satisfied by removing memset support from one of the engines.
  532. */
  533. dma_cap_set(DMA_MEMCPY, orion_xor0_data->cap_mask);
  534. dma_cap_set(DMA_XOR, orion_xor0_data->cap_mask);
  535. platform_device_register(orion_xor0_channel);
  536. dma_cap_set(DMA_MEMCPY, orion_xor1_data->cap_mask);
  537. dma_cap_set(DMA_MEMSET, orion_xor1_data->cap_mask);
  538. dma_cap_set(DMA_XOR, orion_xor1_data->cap_mask);
  539. platform_device_register(orion_xor1_channel);
  540. }
  541. /*****************************************************************************
  542. * XOR0
  543. ****************************************************************************/
  544. static struct resource orion_xor0_shared_resources[] = {
  545. {
  546. .name = "xor 0 low",
  547. .flags = IORESOURCE_MEM,
  548. }, {
  549. .name = "xor 0 high",
  550. .flags = IORESOURCE_MEM,
  551. },
  552. };
  553. static struct platform_device orion_xor0_shared = {
  554. .name = MV_XOR_SHARED_NAME,
  555. .id = 0,
  556. .num_resources = ARRAY_SIZE(orion_xor0_shared_resources),
  557. .resource = orion_xor0_shared_resources,
  558. };
  559. static struct resource orion_xor00_resources[] = {
  560. [0] = {
  561. .flags = IORESOURCE_IRQ,
  562. },
  563. };
  564. static struct mv_xor_platform_data orion_xor00_data = {
  565. .shared = &orion_xor0_shared,
  566. .hw_id = 0,
  567. .pool_size = PAGE_SIZE,
  568. };
  569. static struct platform_device orion_xor00_channel = {
  570. .name = MV_XOR_NAME,
  571. .id = 0,
  572. .num_resources = ARRAY_SIZE(orion_xor00_resources),
  573. .resource = orion_xor00_resources,
  574. .dev = {
  575. .dma_mask = &orion_xor_dmamask,
  576. .coherent_dma_mask = DMA_BIT_MASK(64),
  577. .platform_data = &orion_xor00_data,
  578. },
  579. };
  580. static struct resource orion_xor01_resources[] = {
  581. [0] = {
  582. .flags = IORESOURCE_IRQ,
  583. },
  584. };
  585. static struct mv_xor_platform_data orion_xor01_data = {
  586. .shared = &orion_xor0_shared,
  587. .hw_id = 1,
  588. .pool_size = PAGE_SIZE,
  589. };
  590. static struct platform_device orion_xor01_channel = {
  591. .name = MV_XOR_NAME,
  592. .id = 1,
  593. .num_resources = ARRAY_SIZE(orion_xor01_resources),
  594. .resource = orion_xor01_resources,
  595. .dev = {
  596. .dma_mask = &orion_xor_dmamask,
  597. .coherent_dma_mask = DMA_BIT_MASK(64),
  598. .platform_data = &orion_xor01_data,
  599. },
  600. };
  601. void __init orion_xor0_init(unsigned long mapbase_low,
  602. unsigned long mapbase_high,
  603. unsigned long irq_0,
  604. unsigned long irq_1)
  605. {
  606. orion_xor0_shared_resources[0].start = mapbase_low;
  607. orion_xor0_shared_resources[0].end = mapbase_low + 0xff;
  608. orion_xor0_shared_resources[1].start = mapbase_high;
  609. orion_xor0_shared_resources[1].end = mapbase_high + 0xff;
  610. orion_xor00_resources[0].start = irq_0;
  611. orion_xor00_resources[0].end = irq_0;
  612. orion_xor01_resources[0].start = irq_1;
  613. orion_xor01_resources[0].end = irq_1;
  614. platform_device_register(&orion_xor0_shared);
  615. orion_xor_init_channels(&orion_xor00_data, &orion_xor00_channel,
  616. &orion_xor01_data, &orion_xor01_channel);
  617. }
  618. /*****************************************************************************
  619. * XOR1
  620. ****************************************************************************/
  621. static struct resource orion_xor1_shared_resources[] = {
  622. {
  623. .name = "xor 1 low",
  624. .flags = IORESOURCE_MEM,
  625. }, {
  626. .name = "xor 1 high",
  627. .flags = IORESOURCE_MEM,
  628. },
  629. };
  630. static struct platform_device orion_xor1_shared = {
  631. .name = MV_XOR_SHARED_NAME,
  632. .id = 1,
  633. .num_resources = ARRAY_SIZE(orion_xor1_shared_resources),
  634. .resource = orion_xor1_shared_resources,
  635. };
  636. static struct resource orion_xor10_resources[] = {
  637. [0] = {
  638. .flags = IORESOURCE_IRQ,
  639. },
  640. };
  641. static struct mv_xor_platform_data orion_xor10_data = {
  642. .shared = &orion_xor1_shared,
  643. .hw_id = 0,
  644. .pool_size = PAGE_SIZE,
  645. };
  646. static struct platform_device orion_xor10_channel = {
  647. .name = MV_XOR_NAME,
  648. .id = 2,
  649. .num_resources = ARRAY_SIZE(orion_xor10_resources),
  650. .resource = orion_xor10_resources,
  651. .dev = {
  652. .dma_mask = &orion_xor_dmamask,
  653. .coherent_dma_mask = DMA_BIT_MASK(64),
  654. .platform_data = &orion_xor10_data,
  655. },
  656. };
  657. static struct resource orion_xor11_resources[] = {
  658. [0] = {
  659. .flags = IORESOURCE_IRQ,
  660. },
  661. };
  662. static struct mv_xor_platform_data orion_xor11_data = {
  663. .shared = &orion_xor1_shared,
  664. .hw_id = 1,
  665. .pool_size = PAGE_SIZE,
  666. };
  667. static struct platform_device orion_xor11_channel = {
  668. .name = MV_XOR_NAME,
  669. .id = 3,
  670. .num_resources = ARRAY_SIZE(orion_xor11_resources),
  671. .resource = orion_xor11_resources,
  672. .dev = {
  673. .dma_mask = &orion_xor_dmamask,
  674. .coherent_dma_mask = DMA_BIT_MASK(64),
  675. .platform_data = &orion_xor11_data,
  676. },
  677. };
  678. void __init orion_xor1_init(unsigned long mapbase_low,
  679. unsigned long mapbase_high,
  680. unsigned long irq_0,
  681. unsigned long irq_1)
  682. {
  683. orion_xor1_shared_resources[0].start = mapbase_low;
  684. orion_xor1_shared_resources[0].end = mapbase_low + 0xff;
  685. orion_xor1_shared_resources[1].start = mapbase_high;
  686. orion_xor1_shared_resources[1].end = mapbase_high + 0xff;
  687. orion_xor10_resources[0].start = irq_0;
  688. orion_xor10_resources[0].end = irq_0;
  689. orion_xor11_resources[0].start = irq_1;
  690. orion_xor11_resources[0].end = irq_1;
  691. platform_device_register(&orion_xor1_shared);
  692. orion_xor_init_channels(&orion_xor10_data, &orion_xor10_channel,
  693. &orion_xor11_data, &orion_xor11_channel);
  694. }
  695. /*****************************************************************************
  696. * EHCI
  697. ****************************************************************************/
  698. static struct orion_ehci_data orion_ehci_data;
  699. static u64 ehci_dmamask = DMA_BIT_MASK(32);
  700. /*****************************************************************************
  701. * EHCI0
  702. ****************************************************************************/
  703. static struct resource orion_ehci_resources[2];
  704. static struct platform_device orion_ehci = {
  705. .name = "orion-ehci",
  706. .id = 0,
  707. .dev = {
  708. .dma_mask = &ehci_dmamask,
  709. .coherent_dma_mask = DMA_BIT_MASK(32),
  710. .platform_data = &orion_ehci_data,
  711. },
  712. };
  713. void __init orion_ehci_init(unsigned long mapbase,
  714. unsigned long irq,
  715. enum orion_ehci_phy_ver phy_version)
  716. {
  717. orion_ehci_data.phy_version = phy_version;
  718. fill_resources(&orion_ehci, orion_ehci_resources, mapbase, SZ_4K - 1,
  719. irq);
  720. platform_device_register(&orion_ehci);
  721. }
  722. /*****************************************************************************
  723. * EHCI1
  724. ****************************************************************************/
  725. static struct resource orion_ehci_1_resources[2];
  726. static struct platform_device orion_ehci_1 = {
  727. .name = "orion-ehci",
  728. .id = 1,
  729. .dev = {
  730. .dma_mask = &ehci_dmamask,
  731. .coherent_dma_mask = DMA_BIT_MASK(32),
  732. .platform_data = &orion_ehci_data,
  733. },
  734. };
  735. void __init orion_ehci_1_init(unsigned long mapbase,
  736. unsigned long irq)
  737. {
  738. fill_resources(&orion_ehci_1, orion_ehci_1_resources,
  739. mapbase, SZ_4K - 1, irq);
  740. platform_device_register(&orion_ehci_1);
  741. }
  742. /*****************************************************************************
  743. * EHCI2
  744. ****************************************************************************/
  745. static struct resource orion_ehci_2_resources[2];
  746. static struct platform_device orion_ehci_2 = {
  747. .name = "orion-ehci",
  748. .id = 2,
  749. .dev = {
  750. .dma_mask = &ehci_dmamask,
  751. .coherent_dma_mask = DMA_BIT_MASK(32),
  752. .platform_data = &orion_ehci_data,
  753. },
  754. };
  755. void __init orion_ehci_2_init(unsigned long mapbase,
  756. unsigned long irq)
  757. {
  758. fill_resources(&orion_ehci_2, orion_ehci_2_resources,
  759. mapbase, SZ_4K - 1, irq);
  760. platform_device_register(&orion_ehci_2);
  761. }
  762. /*****************************************************************************
  763. * SATA
  764. ****************************************************************************/
  765. static struct resource orion_sata_resources[2] = {
  766. {
  767. .name = "sata base",
  768. }, {
  769. .name = "sata irq",
  770. },
  771. };
  772. static struct platform_device orion_sata = {
  773. .name = "sata_mv",
  774. .id = 0,
  775. .dev = {
  776. .coherent_dma_mask = DMA_BIT_MASK(32),
  777. },
  778. };
  779. void __init orion_sata_init(struct mv_sata_platform_data *sata_data,
  780. unsigned long mapbase,
  781. unsigned long irq)
  782. {
  783. orion_sata.dev.platform_data = sata_data;
  784. fill_resources(&orion_sata, orion_sata_resources,
  785. mapbase, 0x5000 - 1, irq);
  786. platform_device_register(&orion_sata);
  787. }
  788. /*****************************************************************************
  789. * Cryptographic Engines and Security Accelerator (CESA)
  790. ****************************************************************************/
  791. static struct resource orion_crypto_resources[] = {
  792. {
  793. .name = "regs",
  794. }, {
  795. .name = "crypto interrupt",
  796. }, {
  797. .name = "sram",
  798. .flags = IORESOURCE_MEM,
  799. },
  800. };
  801. static struct platform_device orion_crypto = {
  802. .name = "mv_crypto",
  803. .id = -1,
  804. };
  805. void __init orion_crypto_init(unsigned long mapbase,
  806. unsigned long srambase,
  807. unsigned long sram_size,
  808. unsigned long irq)
  809. {
  810. fill_resources(&orion_crypto, orion_crypto_resources,
  811. mapbase, 0xffff, irq);
  812. orion_crypto.num_resources = 3;
  813. orion_crypto_resources[2].start = srambase;
  814. orion_crypto_resources[2].end = srambase + sram_size - 1;
  815. platform_device_register(&orion_crypto);
  816. }