common.c 24 KB

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