common.c 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957
  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/mbus.h>
  16. #include <linux/ata_platform.h>
  17. #include <linux/mv643xx_eth.h>
  18. #include <linux/mv643xx_i2c.h>
  19. #include <net/dsa.h>
  20. #include <linux/spi/orion_spi.h>
  21. #include <plat/orion_wdt.h>
  22. #include <plat/mv_xor.h>
  23. #include <plat/ehci-orion.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. struct mbus_dram_target_info *mbus_dram_info, 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->dram = mbus_dram_info;
  188. orion_ge_shared_data->t_clk = tclk;
  189. orion_ge_resource->start = irq;
  190. orion_ge_resource->end = irq;
  191. eth_data->shared = orion_ge_shared;
  192. orion_ge->dev.platform_data = eth_data;
  193. platform_device_register(orion_ge_shared);
  194. platform_device_register(orion_ge);
  195. }
  196. /*****************************************************************************
  197. * GE00
  198. ****************************************************************************/
  199. struct mv643xx_eth_shared_platform_data orion_ge00_shared_data;
  200. static struct resource orion_ge00_shared_resources[] = {
  201. {
  202. .name = "ge00 base",
  203. }, {
  204. .name = "ge00 err irq",
  205. },
  206. };
  207. static struct platform_device orion_ge00_shared = {
  208. .name = MV643XX_ETH_SHARED_NAME,
  209. .id = 0,
  210. .dev = {
  211. .platform_data = &orion_ge00_shared_data,
  212. },
  213. };
  214. static struct resource orion_ge00_resources[] = {
  215. {
  216. .name = "ge00 irq",
  217. .flags = IORESOURCE_IRQ,
  218. },
  219. };
  220. static struct platform_device orion_ge00 = {
  221. .name = MV643XX_ETH_NAME,
  222. .id = 0,
  223. .num_resources = 1,
  224. .resource = orion_ge00_resources,
  225. .dev = {
  226. .coherent_dma_mask = DMA_BIT_MASK(32),
  227. },
  228. };
  229. void __init orion_ge00_init(struct mv643xx_eth_platform_data *eth_data,
  230. struct mbus_dram_target_info *mbus_dram_info,
  231. unsigned long mapbase,
  232. unsigned long irq,
  233. unsigned long irq_err,
  234. int tclk)
  235. {
  236. fill_resources(&orion_ge00_shared, orion_ge00_shared_resources,
  237. mapbase + 0x2000, SZ_16K - 1, irq_err);
  238. ge_complete(&orion_ge00_shared_data, mbus_dram_info, 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. struct mbus_dram_target_info *mbus_dram_info,
  279. unsigned long mapbase,
  280. unsigned long irq,
  281. unsigned long irq_err,
  282. int tclk)
  283. {
  284. fill_resources(&orion_ge01_shared, orion_ge01_shared_resources,
  285. mapbase + 0x2000, SZ_16K - 1, irq_err);
  286. ge_complete(&orion_ge01_shared_data, mbus_dram_info, tclk,
  287. orion_ge01_resources, irq, &orion_ge01_shared,
  288. eth_data, &orion_ge01);
  289. }
  290. /*****************************************************************************
  291. * GE10
  292. ****************************************************************************/
  293. struct mv643xx_eth_shared_platform_data orion_ge10_shared_data = {
  294. .shared_smi = &orion_ge00_shared,
  295. };
  296. static struct resource orion_ge10_shared_resources[] = {
  297. {
  298. .name = "ge10 base",
  299. }, {
  300. .name = "ge10 err irq",
  301. },
  302. };
  303. static struct platform_device orion_ge10_shared = {
  304. .name = MV643XX_ETH_SHARED_NAME,
  305. .id = 1,
  306. .dev = {
  307. .platform_data = &orion_ge10_shared_data,
  308. },
  309. };
  310. static struct resource orion_ge10_resources[] = {
  311. {
  312. .name = "ge10 irq",
  313. .flags = IORESOURCE_IRQ,
  314. },
  315. };
  316. static struct platform_device orion_ge10 = {
  317. .name = MV643XX_ETH_NAME,
  318. .id = 1,
  319. .num_resources = 2,
  320. .resource = orion_ge10_resources,
  321. .dev = {
  322. .coherent_dma_mask = DMA_BIT_MASK(32),
  323. },
  324. };
  325. void __init orion_ge10_init(struct mv643xx_eth_platform_data *eth_data,
  326. struct mbus_dram_target_info *mbus_dram_info,
  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, mbus_dram_info, 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 = 1,
  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 = 1,
  367. .num_resources = 2,
  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. struct mbus_dram_target_info *mbus_dram_info,
  375. unsigned long mapbase,
  376. unsigned long irq,
  377. unsigned long irq_err,
  378. int tclk)
  379. {
  380. fill_resources(&orion_ge11_shared, orion_ge11_shared_resources,
  381. mapbase + 0x2000, SZ_16K - 1, irq_err);
  382. ge_complete(&orion_ge11_shared_data, mbus_dram_info, tclk,
  383. orion_ge11_resources, irq, &orion_ge11_shared,
  384. eth_data, &orion_ge11);
  385. }
  386. /*****************************************************************************
  387. * Ethernet switch
  388. ****************************************************************************/
  389. static struct resource orion_switch_resources[] = {
  390. {
  391. .start = 0,
  392. .end = 0,
  393. .flags = IORESOURCE_IRQ,
  394. },
  395. };
  396. static struct platform_device orion_switch_device = {
  397. .name = "dsa",
  398. .id = 0,
  399. .num_resources = 0,
  400. .resource = orion_switch_resources,
  401. };
  402. void __init orion_ge00_switch_init(struct dsa_platform_data *d, int irq)
  403. {
  404. int i;
  405. if (irq != NO_IRQ) {
  406. orion_switch_resources[0].start = irq;
  407. orion_switch_resources[0].end = irq;
  408. orion_switch_device.num_resources = 1;
  409. }
  410. d->netdev = &orion_ge00.dev;
  411. for (i = 0; i < d->nr_chips; i++)
  412. d->chip[i].mii_bus = &orion_ge00_shared.dev;
  413. orion_switch_device.dev.platform_data = d;
  414. platform_device_register(&orion_switch_device);
  415. }
  416. /*****************************************************************************
  417. * I2C
  418. ****************************************************************************/
  419. static struct mv64xxx_i2c_pdata orion_i2c_pdata = {
  420. .freq_n = 3,
  421. .timeout = 1000, /* Default timeout of 1 second */
  422. };
  423. static struct resource orion_i2c_resources[2];
  424. static struct platform_device orion_i2c = {
  425. .name = MV64XXX_I2C_CTLR_NAME,
  426. .id = 0,
  427. .dev = {
  428. .platform_data = &orion_i2c_pdata,
  429. },
  430. };
  431. static struct mv64xxx_i2c_pdata orion_i2c_1_pdata = {
  432. .freq_n = 3,
  433. .timeout = 1000, /* Default timeout of 1 second */
  434. };
  435. static struct resource orion_i2c_1_resources[2];
  436. static struct platform_device orion_i2c_1 = {
  437. .name = MV64XXX_I2C_CTLR_NAME,
  438. .id = 1,
  439. .dev = {
  440. .platform_data = &orion_i2c_1_pdata,
  441. },
  442. };
  443. void __init orion_i2c_init(unsigned long mapbase,
  444. unsigned long irq,
  445. unsigned long freq_m)
  446. {
  447. orion_i2c_pdata.freq_m = freq_m;
  448. fill_resources(&orion_i2c, orion_i2c_resources, mapbase,
  449. SZ_32 - 1, irq);
  450. platform_device_register(&orion_i2c);
  451. }
  452. void __init orion_i2c_1_init(unsigned long mapbase,
  453. unsigned long irq,
  454. unsigned long freq_m)
  455. {
  456. orion_i2c_1_pdata.freq_m = freq_m;
  457. fill_resources(&orion_i2c_1, orion_i2c_1_resources, mapbase,
  458. SZ_32 - 1, irq);
  459. platform_device_register(&orion_i2c_1);
  460. }
  461. /*****************************************************************************
  462. * SPI
  463. ****************************************************************************/
  464. static struct orion_spi_info orion_spi_plat_data;
  465. static struct resource orion_spi_resources;
  466. static struct platform_device orion_spi = {
  467. .name = "orion_spi",
  468. .id = 0,
  469. .dev = {
  470. .platform_data = &orion_spi_plat_data,
  471. },
  472. };
  473. static struct orion_spi_info orion_spi_1_plat_data;
  474. static struct resource orion_spi_1_resources;
  475. static struct platform_device orion_spi_1 = {
  476. .name = "orion_spi",
  477. .id = 1,
  478. .dev = {
  479. .platform_data = &orion_spi_1_plat_data,
  480. },
  481. };
  482. /* Note: The SPI silicon core does have interrupts. However the
  483. * current Linux software driver does not use interrupts. */
  484. void __init orion_spi_init(unsigned long mapbase,
  485. unsigned long tclk)
  486. {
  487. orion_spi_plat_data.tclk = tclk;
  488. fill_resources(&orion_spi, &orion_spi_resources,
  489. mapbase, SZ_512 - 1, NO_IRQ);
  490. platform_device_register(&orion_spi);
  491. }
  492. void __init orion_spi_1_init(unsigned long mapbase,
  493. unsigned long tclk)
  494. {
  495. orion_spi_1_plat_data.tclk = tclk;
  496. fill_resources(&orion_spi_1, &orion_spi_1_resources,
  497. mapbase, SZ_512 - 1, NO_IRQ);
  498. platform_device_register(&orion_spi_1);
  499. }
  500. /*****************************************************************************
  501. * Watchdog
  502. ****************************************************************************/
  503. static struct orion_wdt_platform_data orion_wdt_data;
  504. static struct platform_device orion_wdt_device = {
  505. .name = "orion_wdt",
  506. .id = -1,
  507. .dev = {
  508. .platform_data = &orion_wdt_data,
  509. },
  510. .num_resources = 0,
  511. };
  512. void __init orion_wdt_init(unsigned long tclk)
  513. {
  514. orion_wdt_data.tclk = tclk;
  515. platform_device_register(&orion_wdt_device);
  516. }
  517. /*****************************************************************************
  518. * XOR
  519. ****************************************************************************/
  520. static struct mv_xor_platform_shared_data orion_xor_shared_data;
  521. static u64 orion_xor_dmamask = DMA_BIT_MASK(32);
  522. void __init orion_xor_init_channels(
  523. struct mv_xor_platform_data *orion_xor0_data,
  524. struct platform_device *orion_xor0_channel,
  525. struct mv_xor_platform_data *orion_xor1_data,
  526. struct platform_device *orion_xor1_channel)
  527. {
  528. /*
  529. * two engines can't do memset simultaneously, this limitation
  530. * satisfied by removing memset support from one of the engines.
  531. */
  532. dma_cap_set(DMA_MEMCPY, orion_xor0_data->cap_mask);
  533. dma_cap_set(DMA_XOR, orion_xor0_data->cap_mask);
  534. platform_device_register(orion_xor0_channel);
  535. dma_cap_set(DMA_MEMCPY, orion_xor1_data->cap_mask);
  536. dma_cap_set(DMA_MEMSET, orion_xor1_data->cap_mask);
  537. dma_cap_set(DMA_XOR, orion_xor1_data->cap_mask);
  538. platform_device_register(orion_xor1_channel);
  539. }
  540. /*****************************************************************************
  541. * XOR0
  542. ****************************************************************************/
  543. static struct resource orion_xor0_shared_resources[] = {
  544. {
  545. .name = "xor 0 low",
  546. .flags = IORESOURCE_MEM,
  547. }, {
  548. .name = "xor 0 high",
  549. .flags = IORESOURCE_MEM,
  550. },
  551. };
  552. static struct platform_device orion_xor0_shared = {
  553. .name = MV_XOR_SHARED_NAME,
  554. .id = 0,
  555. .dev = {
  556. .platform_data = &orion_xor_shared_data,
  557. },
  558. .num_resources = ARRAY_SIZE(orion_xor0_shared_resources),
  559. .resource = orion_xor0_shared_resources,
  560. };
  561. static struct resource orion_xor00_resources[] = {
  562. [0] = {
  563. .flags = IORESOURCE_IRQ,
  564. },
  565. };
  566. static struct mv_xor_platform_data orion_xor00_data = {
  567. .shared = &orion_xor0_shared,
  568. .hw_id = 0,
  569. .pool_size = PAGE_SIZE,
  570. };
  571. static struct platform_device orion_xor00_channel = {
  572. .name = MV_XOR_NAME,
  573. .id = 0,
  574. .num_resources = ARRAY_SIZE(orion_xor00_resources),
  575. .resource = orion_xor00_resources,
  576. .dev = {
  577. .dma_mask = &orion_xor_dmamask,
  578. .coherent_dma_mask = DMA_BIT_MASK(64),
  579. .platform_data = &orion_xor00_data,
  580. },
  581. };
  582. static struct resource orion_xor01_resources[] = {
  583. [0] = {
  584. .flags = IORESOURCE_IRQ,
  585. },
  586. };
  587. static struct mv_xor_platform_data orion_xor01_data = {
  588. .shared = &orion_xor0_shared,
  589. .hw_id = 1,
  590. .pool_size = PAGE_SIZE,
  591. };
  592. static struct platform_device orion_xor01_channel = {
  593. .name = MV_XOR_NAME,
  594. .id = 1,
  595. .num_resources = ARRAY_SIZE(orion_xor01_resources),
  596. .resource = orion_xor01_resources,
  597. .dev = {
  598. .dma_mask = &orion_xor_dmamask,
  599. .coherent_dma_mask = DMA_BIT_MASK(64),
  600. .platform_data = &orion_xor01_data,
  601. },
  602. };
  603. void __init orion_xor0_init(struct mbus_dram_target_info *mbus_dram_info,
  604. unsigned long mapbase_low,
  605. unsigned long mapbase_high,
  606. unsigned long irq_0,
  607. unsigned long irq_1)
  608. {
  609. orion_xor_shared_data.dram = mbus_dram_info;
  610. orion_xor0_shared_resources[0].start = mapbase_low;
  611. orion_xor0_shared_resources[0].end = mapbase_low + 0xff;
  612. orion_xor0_shared_resources[1].start = mapbase_high;
  613. orion_xor0_shared_resources[1].end = mapbase_high + 0xff;
  614. orion_xor00_resources[0].start = irq_0;
  615. orion_xor00_resources[0].end = irq_0;
  616. orion_xor01_resources[0].start = irq_1;
  617. orion_xor01_resources[0].end = irq_1;
  618. platform_device_register(&orion_xor0_shared);
  619. orion_xor_init_channels(&orion_xor00_data, &orion_xor00_channel,
  620. &orion_xor01_data, &orion_xor01_channel);
  621. }
  622. /*****************************************************************************
  623. * XOR1
  624. ****************************************************************************/
  625. static struct resource orion_xor1_shared_resources[] = {
  626. {
  627. .name = "xor 1 low",
  628. .flags = IORESOURCE_MEM,
  629. }, {
  630. .name = "xor 1 high",
  631. .flags = IORESOURCE_MEM,
  632. },
  633. };
  634. static struct platform_device orion_xor1_shared = {
  635. .name = MV_XOR_SHARED_NAME,
  636. .id = 1,
  637. .dev = {
  638. .platform_data = &orion_xor_shared_data,
  639. },
  640. .num_resources = ARRAY_SIZE(orion_xor1_shared_resources),
  641. .resource = orion_xor1_shared_resources,
  642. };
  643. static struct resource orion_xor10_resources[] = {
  644. [0] = {
  645. .flags = IORESOURCE_IRQ,
  646. },
  647. };
  648. static struct mv_xor_platform_data orion_xor10_data = {
  649. .shared = &orion_xor1_shared,
  650. .hw_id = 0,
  651. .pool_size = PAGE_SIZE,
  652. };
  653. static struct platform_device orion_xor10_channel = {
  654. .name = MV_XOR_NAME,
  655. .id = 2,
  656. .num_resources = ARRAY_SIZE(orion_xor10_resources),
  657. .resource = orion_xor10_resources,
  658. .dev = {
  659. .dma_mask = &orion_xor_dmamask,
  660. .coherent_dma_mask = DMA_BIT_MASK(64),
  661. .platform_data = &orion_xor10_data,
  662. },
  663. };
  664. static struct resource orion_xor11_resources[] = {
  665. [0] = {
  666. .flags = IORESOURCE_IRQ,
  667. },
  668. };
  669. static struct mv_xor_platform_data orion_xor11_data = {
  670. .shared = &orion_xor1_shared,
  671. .hw_id = 1,
  672. .pool_size = PAGE_SIZE,
  673. };
  674. static struct platform_device orion_xor11_channel = {
  675. .name = MV_XOR_NAME,
  676. .id = 3,
  677. .num_resources = ARRAY_SIZE(orion_xor11_resources),
  678. .resource = orion_xor11_resources,
  679. .dev = {
  680. .dma_mask = &orion_xor_dmamask,
  681. .coherent_dma_mask = DMA_BIT_MASK(64),
  682. .platform_data = &orion_xor11_data,
  683. },
  684. };
  685. void __init orion_xor1_init(unsigned long mapbase_low,
  686. unsigned long mapbase_high,
  687. unsigned long irq_0,
  688. unsigned long irq_1)
  689. {
  690. orion_xor1_shared_resources[0].start = mapbase_low;
  691. orion_xor1_shared_resources[0].end = mapbase_low + 0xff;
  692. orion_xor1_shared_resources[1].start = mapbase_high;
  693. orion_xor1_shared_resources[1].end = mapbase_high + 0xff;
  694. orion_xor10_resources[0].start = irq_0;
  695. orion_xor10_resources[0].end = irq_0;
  696. orion_xor11_resources[0].start = irq_1;
  697. orion_xor11_resources[0].end = irq_1;
  698. platform_device_register(&orion_xor1_shared);
  699. orion_xor_init_channels(&orion_xor10_data, &orion_xor10_channel,
  700. &orion_xor11_data, &orion_xor11_channel);
  701. }
  702. /*****************************************************************************
  703. * EHCI
  704. ****************************************************************************/
  705. static struct orion_ehci_data orion_ehci_data = {
  706. .phy_version = EHCI_PHY_NA,
  707. };
  708. static u64 ehci_dmamask = DMA_BIT_MASK(32);
  709. /*****************************************************************************
  710. * EHCI0
  711. ****************************************************************************/
  712. static struct resource orion_ehci_resources[2];
  713. static struct platform_device orion_ehci = {
  714. .name = "orion-ehci",
  715. .id = 0,
  716. .dev = {
  717. .dma_mask = &ehci_dmamask,
  718. .coherent_dma_mask = DMA_BIT_MASK(32),
  719. .platform_data = &orion_ehci_data,
  720. },
  721. };
  722. void __init orion_ehci_init(struct mbus_dram_target_info *mbus_dram_info,
  723. unsigned long mapbase,
  724. unsigned long irq)
  725. {
  726. orion_ehci_data.dram = mbus_dram_info;
  727. fill_resources(&orion_ehci, orion_ehci_resources, mapbase, SZ_4K - 1,
  728. irq);
  729. platform_device_register(&orion_ehci);
  730. }
  731. /*****************************************************************************
  732. * EHCI1
  733. ****************************************************************************/
  734. static struct resource orion_ehci_1_resources[2];
  735. static struct platform_device orion_ehci_1 = {
  736. .name = "orion-ehci",
  737. .id = 1,
  738. .dev = {
  739. .dma_mask = &ehci_dmamask,
  740. .coherent_dma_mask = DMA_BIT_MASK(32),
  741. .platform_data = &orion_ehci_data,
  742. },
  743. };
  744. void __init orion_ehci_1_init(struct mbus_dram_target_info *mbus_dram_info,
  745. unsigned long mapbase,
  746. unsigned long irq)
  747. {
  748. orion_ehci_data.dram = mbus_dram_info;
  749. fill_resources(&orion_ehci_1, orion_ehci_1_resources,
  750. mapbase, SZ_4K - 1, irq);
  751. platform_device_register(&orion_ehci_1);
  752. }
  753. /*****************************************************************************
  754. * EHCI2
  755. ****************************************************************************/
  756. static struct resource orion_ehci_2_resources[2];
  757. static struct platform_device orion_ehci_2 = {
  758. .name = "orion-ehci",
  759. .id = 2,
  760. .dev = {
  761. .dma_mask = &ehci_dmamask,
  762. .coherent_dma_mask = DMA_BIT_MASK(32),
  763. .platform_data = &orion_ehci_data,
  764. },
  765. };
  766. void __init orion_ehci_2_init(struct mbus_dram_target_info *mbus_dram_info,
  767. unsigned long mapbase,
  768. unsigned long irq)
  769. {
  770. orion_ehci_data.dram = mbus_dram_info;
  771. fill_resources(&orion_ehci_2, orion_ehci_2_resources,
  772. mapbase, SZ_4K - 1, irq);
  773. platform_device_register(&orion_ehci_2);
  774. }
  775. /*****************************************************************************
  776. * SATA
  777. ****************************************************************************/
  778. static struct resource orion_sata_resources[2] = {
  779. {
  780. .name = "sata base",
  781. }, {
  782. .name = "sata irq",
  783. },
  784. };
  785. static struct platform_device orion_sata = {
  786. .name = "sata_mv",
  787. .id = 0,
  788. .dev = {
  789. .coherent_dma_mask = DMA_BIT_MASK(32),
  790. },
  791. };
  792. void __init orion_sata_init(struct mv_sata_platform_data *sata_data,
  793. struct mbus_dram_target_info *mbus_dram_info,
  794. unsigned long mapbase,
  795. unsigned long irq)
  796. {
  797. sata_data->dram = mbus_dram_info;
  798. orion_sata.dev.platform_data = sata_data;
  799. fill_resources(&orion_sata, orion_sata_resources,
  800. mapbase, 0x5000 - 1, irq);
  801. platform_device_register(&orion_sata);
  802. }
  803. /*****************************************************************************
  804. * Cryptographic Engines and Security Accelerator (CESA)
  805. ****************************************************************************/
  806. static struct resource orion_crypto_resources[] = {
  807. {
  808. .name = "regs",
  809. }, {
  810. .name = "crypto interrupt",
  811. }, {
  812. .name = "sram",
  813. .flags = IORESOURCE_MEM,
  814. },
  815. };
  816. static struct platform_device orion_crypto = {
  817. .name = "mv_crypto",
  818. .id = -1,
  819. };
  820. void __init orion_crypto_init(unsigned long mapbase,
  821. unsigned long srambase,
  822. unsigned long sram_size,
  823. unsigned long irq)
  824. {
  825. fill_resources(&orion_crypto, orion_crypto_resources,
  826. mapbase, 0xffff, irq);
  827. orion_crypto.num_resources = 3;
  828. orion_crypto_resources[2].start = srambase;
  829. orion_crypto_resources[2].end = srambase + sram_size - 1;
  830. platform_device_register(&orion_crypto);
  831. }