devices.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662
  1. #include <linux/module.h>
  2. #include <linux/kernel.h>
  3. #include <linux/init.h>
  4. #include <linux/platform_device.h>
  5. #include <linux/dma-mapping.h>
  6. #include <asm/arch/gpio.h>
  7. #include <asm/arch/udc.h>
  8. #include <asm/arch/pxafb.h>
  9. #include <asm/arch/mmc.h>
  10. #include <asm/arch/irda.h>
  11. #include <asm/arch/i2c.h>
  12. #include "devices.h"
  13. void __init pxa_register_device(struct platform_device *dev, void *data)
  14. {
  15. int ret;
  16. dev->dev.platform_data = data;
  17. ret = platform_device_register(dev);
  18. if (ret)
  19. dev_err(&dev->dev, "unable to register device: %d\n", ret);
  20. }
  21. static struct resource pxamci_resources[] = {
  22. [0] = {
  23. .start = 0x41100000,
  24. .end = 0x41100fff,
  25. .flags = IORESOURCE_MEM,
  26. },
  27. [1] = {
  28. .start = IRQ_MMC,
  29. .end = IRQ_MMC,
  30. .flags = IORESOURCE_IRQ,
  31. },
  32. [2] = {
  33. .start = 21,
  34. .end = 21,
  35. .flags = IORESOURCE_DMA,
  36. },
  37. [3] = {
  38. .start = 22,
  39. .end = 22,
  40. .flags = IORESOURCE_DMA,
  41. },
  42. };
  43. static u64 pxamci_dmamask = 0xffffffffUL;
  44. struct platform_device pxa_device_mci = {
  45. .name = "pxa2xx-mci",
  46. .id = 0,
  47. .dev = {
  48. .dma_mask = &pxamci_dmamask,
  49. .coherent_dma_mask = 0xffffffff,
  50. },
  51. .num_resources = ARRAY_SIZE(pxamci_resources),
  52. .resource = pxamci_resources,
  53. };
  54. void __init pxa_set_mci_info(struct pxamci_platform_data *info)
  55. {
  56. pxa_register_device(&pxa_device_mci, info);
  57. }
  58. static struct pxa2xx_udc_mach_info pxa_udc_info;
  59. void __init pxa_set_udc_info(struct pxa2xx_udc_mach_info *info)
  60. {
  61. memcpy(&pxa_udc_info, info, sizeof *info);
  62. }
  63. static struct resource pxa2xx_udc_resources[] = {
  64. [0] = {
  65. .start = 0x40600000,
  66. .end = 0x4060ffff,
  67. .flags = IORESOURCE_MEM,
  68. },
  69. [1] = {
  70. .start = IRQ_USB,
  71. .end = IRQ_USB,
  72. .flags = IORESOURCE_IRQ,
  73. },
  74. };
  75. static u64 udc_dma_mask = ~(u32)0;
  76. struct platform_device pxa_device_udc = {
  77. .name = "pxa2xx-udc",
  78. .id = -1,
  79. .resource = pxa2xx_udc_resources,
  80. .num_resources = ARRAY_SIZE(pxa2xx_udc_resources),
  81. .dev = {
  82. .platform_data = &pxa_udc_info,
  83. .dma_mask = &udc_dma_mask,
  84. }
  85. };
  86. static struct resource pxafb_resources[] = {
  87. [0] = {
  88. .start = 0x44000000,
  89. .end = 0x4400ffff,
  90. .flags = IORESOURCE_MEM,
  91. },
  92. [1] = {
  93. .start = IRQ_LCD,
  94. .end = IRQ_LCD,
  95. .flags = IORESOURCE_IRQ,
  96. },
  97. };
  98. static u64 fb_dma_mask = ~(u64)0;
  99. struct platform_device pxa_device_fb = {
  100. .name = "pxa2xx-fb",
  101. .id = -1,
  102. .dev = {
  103. .dma_mask = &fb_dma_mask,
  104. .coherent_dma_mask = 0xffffffff,
  105. },
  106. .num_resources = ARRAY_SIZE(pxafb_resources),
  107. .resource = pxafb_resources,
  108. };
  109. void __init set_pxa_fb_info(struct pxafb_mach_info *info)
  110. {
  111. pxa_register_device(&pxa_device_fb, info);
  112. }
  113. void __init set_pxa_fb_parent(struct device *parent_dev)
  114. {
  115. pxa_device_fb.dev.parent = parent_dev;
  116. }
  117. static struct resource pxa_resource_ffuart[] = {
  118. {
  119. .start = __PREG(FFUART),
  120. .end = __PREG(FFUART) + 35,
  121. .flags = IORESOURCE_MEM,
  122. }, {
  123. .start = IRQ_FFUART,
  124. .end = IRQ_FFUART,
  125. .flags = IORESOURCE_IRQ,
  126. }
  127. };
  128. struct platform_device pxa_device_ffuart= {
  129. .name = "pxa2xx-uart",
  130. .id = 0,
  131. .resource = pxa_resource_ffuart,
  132. .num_resources = ARRAY_SIZE(pxa_resource_ffuart),
  133. };
  134. static struct resource pxa_resource_btuart[] = {
  135. {
  136. .start = __PREG(BTUART),
  137. .end = __PREG(BTUART) + 35,
  138. .flags = IORESOURCE_MEM,
  139. }, {
  140. .start = IRQ_BTUART,
  141. .end = IRQ_BTUART,
  142. .flags = IORESOURCE_IRQ,
  143. }
  144. };
  145. struct platform_device pxa_device_btuart = {
  146. .name = "pxa2xx-uart",
  147. .id = 1,
  148. .resource = pxa_resource_btuart,
  149. .num_resources = ARRAY_SIZE(pxa_resource_btuart),
  150. };
  151. static struct resource pxa_resource_stuart[] = {
  152. {
  153. .start = __PREG(STUART),
  154. .end = __PREG(STUART) + 35,
  155. .flags = IORESOURCE_MEM,
  156. }, {
  157. .start = IRQ_STUART,
  158. .end = IRQ_STUART,
  159. .flags = IORESOURCE_IRQ,
  160. }
  161. };
  162. struct platform_device pxa_device_stuart = {
  163. .name = "pxa2xx-uart",
  164. .id = 2,
  165. .resource = pxa_resource_stuart,
  166. .num_resources = ARRAY_SIZE(pxa_resource_stuart),
  167. };
  168. static struct resource pxa_resource_hwuart[] = {
  169. {
  170. .start = __PREG(HWUART),
  171. .end = __PREG(HWUART) + 47,
  172. .flags = IORESOURCE_MEM,
  173. }, {
  174. .start = IRQ_HWUART,
  175. .end = IRQ_HWUART,
  176. .flags = IORESOURCE_IRQ,
  177. }
  178. };
  179. struct platform_device pxa_device_hwuart = {
  180. .name = "pxa2xx-uart",
  181. .id = 3,
  182. .resource = pxa_resource_hwuart,
  183. .num_resources = ARRAY_SIZE(pxa_resource_hwuart),
  184. };
  185. static struct resource pxai2c_resources[] = {
  186. {
  187. .start = 0x40301680,
  188. .end = 0x403016a3,
  189. .flags = IORESOURCE_MEM,
  190. }, {
  191. .start = IRQ_I2C,
  192. .end = IRQ_I2C,
  193. .flags = IORESOURCE_IRQ,
  194. },
  195. };
  196. struct platform_device pxa_device_i2c = {
  197. .name = "pxa2xx-i2c",
  198. .id = 0,
  199. .resource = pxai2c_resources,
  200. .num_resources = ARRAY_SIZE(pxai2c_resources),
  201. };
  202. void __init pxa_set_i2c_info(struct i2c_pxa_platform_data *info)
  203. {
  204. pxa_register_device(&pxa_device_i2c, info);
  205. }
  206. static struct resource pxai2s_resources[] = {
  207. {
  208. .start = 0x40400000,
  209. .end = 0x40400083,
  210. .flags = IORESOURCE_MEM,
  211. }, {
  212. .start = IRQ_I2S,
  213. .end = IRQ_I2S,
  214. .flags = IORESOURCE_IRQ,
  215. },
  216. };
  217. struct platform_device pxa_device_i2s = {
  218. .name = "pxa2xx-i2s",
  219. .id = -1,
  220. .resource = pxai2s_resources,
  221. .num_resources = ARRAY_SIZE(pxai2s_resources),
  222. };
  223. static u64 pxaficp_dmamask = ~(u32)0;
  224. struct platform_device pxa_device_ficp = {
  225. .name = "pxa2xx-ir",
  226. .id = -1,
  227. .dev = {
  228. .dma_mask = &pxaficp_dmamask,
  229. .coherent_dma_mask = 0xffffffff,
  230. },
  231. };
  232. void __init pxa_set_ficp_info(struct pxaficp_platform_data *info)
  233. {
  234. pxa_register_device(&pxa_device_ficp, info);
  235. }
  236. struct platform_device pxa_device_rtc = {
  237. .name = "sa1100-rtc",
  238. .id = -1,
  239. };
  240. #ifdef CONFIG_PXA25x
  241. static u64 pxa25x_ssp_dma_mask = DMA_BIT_MASK(32);
  242. static struct resource pxa25x_resource_ssp[] = {
  243. [0] = {
  244. .start = 0x41000000,
  245. .end = 0x4100001f,
  246. .flags = IORESOURCE_MEM,
  247. },
  248. [1] = {
  249. .start = IRQ_SSP,
  250. .end = IRQ_SSP,
  251. .flags = IORESOURCE_IRQ,
  252. },
  253. [2] = {
  254. /* DRCMR for RX */
  255. .start = 13,
  256. .end = 13,
  257. .flags = IORESOURCE_DMA,
  258. },
  259. [3] = {
  260. /* DRCMR for TX */
  261. .start = 14,
  262. .end = 14,
  263. .flags = IORESOURCE_DMA,
  264. },
  265. };
  266. struct platform_device pxa25x_device_ssp = {
  267. .name = "pxa25x-ssp",
  268. .id = 0,
  269. .dev = {
  270. .dma_mask = &pxa25x_ssp_dma_mask,
  271. .coherent_dma_mask = DMA_BIT_MASK(32),
  272. },
  273. .resource = pxa25x_resource_ssp,
  274. .num_resources = ARRAY_SIZE(pxa25x_resource_ssp),
  275. };
  276. static u64 pxa25x_nssp_dma_mask = DMA_BIT_MASK(32);
  277. static struct resource pxa25x_resource_nssp[] = {
  278. [0] = {
  279. .start = 0x41400000,
  280. .end = 0x4140002f,
  281. .flags = IORESOURCE_MEM,
  282. },
  283. [1] = {
  284. .start = IRQ_NSSP,
  285. .end = IRQ_NSSP,
  286. .flags = IORESOURCE_IRQ,
  287. },
  288. [2] = {
  289. /* DRCMR for RX */
  290. .start = 15,
  291. .end = 15,
  292. .flags = IORESOURCE_DMA,
  293. },
  294. [3] = {
  295. /* DRCMR for TX */
  296. .start = 16,
  297. .end = 16,
  298. .flags = IORESOURCE_DMA,
  299. },
  300. };
  301. struct platform_device pxa25x_device_nssp = {
  302. .name = "pxa25x-nssp",
  303. .id = 1,
  304. .dev = {
  305. .dma_mask = &pxa25x_nssp_dma_mask,
  306. .coherent_dma_mask = DMA_BIT_MASK(32),
  307. },
  308. .resource = pxa25x_resource_nssp,
  309. .num_resources = ARRAY_SIZE(pxa25x_resource_nssp),
  310. };
  311. static u64 pxa25x_assp_dma_mask = DMA_BIT_MASK(32);
  312. static struct resource pxa25x_resource_assp[] = {
  313. [0] = {
  314. .start = 0x41500000,
  315. .end = 0x4150002f,
  316. .flags = IORESOURCE_MEM,
  317. },
  318. [1] = {
  319. .start = IRQ_ASSP,
  320. .end = IRQ_ASSP,
  321. .flags = IORESOURCE_IRQ,
  322. },
  323. [2] = {
  324. /* DRCMR for RX */
  325. .start = 23,
  326. .end = 23,
  327. .flags = IORESOURCE_DMA,
  328. },
  329. [3] = {
  330. /* DRCMR for TX */
  331. .start = 24,
  332. .end = 24,
  333. .flags = IORESOURCE_DMA,
  334. },
  335. };
  336. struct platform_device pxa25x_device_assp = {
  337. /* ASSP is basically equivalent to NSSP */
  338. .name = "pxa25x-nssp",
  339. .id = 2,
  340. .dev = {
  341. .dma_mask = &pxa25x_assp_dma_mask,
  342. .coherent_dma_mask = DMA_BIT_MASK(32),
  343. },
  344. .resource = pxa25x_resource_assp,
  345. .num_resources = ARRAY_SIZE(pxa25x_resource_assp),
  346. };
  347. #endif /* CONFIG_PXA25x */
  348. #if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx)
  349. static u64 pxa27x_ohci_dma_mask = DMA_BIT_MASK(32);
  350. static struct resource pxa27x_resource_ohci[] = {
  351. [0] = {
  352. .start = 0x4C000000,
  353. .end = 0x4C00ff6f,
  354. .flags = IORESOURCE_MEM,
  355. },
  356. [1] = {
  357. .start = IRQ_USBH1,
  358. .end = IRQ_USBH1,
  359. .flags = IORESOURCE_IRQ,
  360. },
  361. };
  362. struct platform_device pxa27x_device_ohci = {
  363. .name = "pxa27x-ohci",
  364. .id = -1,
  365. .dev = {
  366. .dma_mask = &pxa27x_ohci_dma_mask,
  367. .coherent_dma_mask = DMA_BIT_MASK(32),
  368. },
  369. .num_resources = ARRAY_SIZE(pxa27x_resource_ohci),
  370. .resource = pxa27x_resource_ohci,
  371. };
  372. void __init pxa_set_ohci_info(struct pxaohci_platform_data *info)
  373. {
  374. pxa_register_device(&pxa27x_device_ohci, info);
  375. }
  376. static u64 pxa27x_ssp1_dma_mask = DMA_BIT_MASK(32);
  377. static struct resource pxa27x_resource_ssp1[] = {
  378. [0] = {
  379. .start = 0x41000000,
  380. .end = 0x4100003f,
  381. .flags = IORESOURCE_MEM,
  382. },
  383. [1] = {
  384. .start = IRQ_SSP,
  385. .end = IRQ_SSP,
  386. .flags = IORESOURCE_IRQ,
  387. },
  388. [2] = {
  389. /* DRCMR for RX */
  390. .start = 13,
  391. .end = 13,
  392. .flags = IORESOURCE_DMA,
  393. },
  394. [3] = {
  395. /* DRCMR for TX */
  396. .start = 14,
  397. .end = 14,
  398. .flags = IORESOURCE_DMA,
  399. },
  400. };
  401. struct platform_device pxa27x_device_ssp1 = {
  402. .name = "pxa27x-ssp",
  403. .id = 0,
  404. .dev = {
  405. .dma_mask = &pxa27x_ssp1_dma_mask,
  406. .coherent_dma_mask = DMA_BIT_MASK(32),
  407. },
  408. .resource = pxa27x_resource_ssp1,
  409. .num_resources = ARRAY_SIZE(pxa27x_resource_ssp1),
  410. };
  411. static u64 pxa27x_ssp2_dma_mask = DMA_BIT_MASK(32);
  412. static struct resource pxa27x_resource_ssp2[] = {
  413. [0] = {
  414. .start = 0x41700000,
  415. .end = 0x4170003f,
  416. .flags = IORESOURCE_MEM,
  417. },
  418. [1] = {
  419. .start = IRQ_SSP2,
  420. .end = IRQ_SSP2,
  421. .flags = IORESOURCE_IRQ,
  422. },
  423. [2] = {
  424. /* DRCMR for RX */
  425. .start = 15,
  426. .end = 15,
  427. .flags = IORESOURCE_DMA,
  428. },
  429. [3] = {
  430. /* DRCMR for TX */
  431. .start = 16,
  432. .end = 16,
  433. .flags = IORESOURCE_DMA,
  434. },
  435. };
  436. struct platform_device pxa27x_device_ssp2 = {
  437. .name = "pxa27x-ssp",
  438. .id = 1,
  439. .dev = {
  440. .dma_mask = &pxa27x_ssp2_dma_mask,
  441. .coherent_dma_mask = DMA_BIT_MASK(32),
  442. },
  443. .resource = pxa27x_resource_ssp2,
  444. .num_resources = ARRAY_SIZE(pxa27x_resource_ssp2),
  445. };
  446. static u64 pxa27x_ssp3_dma_mask = DMA_BIT_MASK(32);
  447. static struct resource pxa27x_resource_ssp3[] = {
  448. [0] = {
  449. .start = 0x41900000,
  450. .end = 0x4190003f,
  451. .flags = IORESOURCE_MEM,
  452. },
  453. [1] = {
  454. .start = IRQ_SSP3,
  455. .end = IRQ_SSP3,
  456. .flags = IORESOURCE_IRQ,
  457. },
  458. [2] = {
  459. /* DRCMR for RX */
  460. .start = 66,
  461. .end = 66,
  462. .flags = IORESOURCE_DMA,
  463. },
  464. [3] = {
  465. /* DRCMR for TX */
  466. .start = 67,
  467. .end = 67,
  468. .flags = IORESOURCE_DMA,
  469. },
  470. };
  471. struct platform_device pxa27x_device_ssp3 = {
  472. .name = "pxa27x-ssp",
  473. .id = 2,
  474. .dev = {
  475. .dma_mask = &pxa27x_ssp3_dma_mask,
  476. .coherent_dma_mask = DMA_BIT_MASK(32),
  477. },
  478. .resource = pxa27x_resource_ssp3,
  479. .num_resources = ARRAY_SIZE(pxa27x_resource_ssp3),
  480. };
  481. #endif /* CONFIG_PXA27x || CONFIG_PXA3xx */
  482. #ifdef CONFIG_PXA3xx
  483. static u64 pxa3xx_ssp4_dma_mask = DMA_BIT_MASK(32);
  484. static struct resource pxa3xx_resource_ssp4[] = {
  485. [0] = {
  486. .start = 0x41a00000,
  487. .end = 0x41a0003f,
  488. .flags = IORESOURCE_MEM,
  489. },
  490. [1] = {
  491. .start = IRQ_SSP4,
  492. .end = IRQ_SSP4,
  493. .flags = IORESOURCE_IRQ,
  494. },
  495. [2] = {
  496. /* DRCMR for RX */
  497. .start = 2,
  498. .end = 2,
  499. .flags = IORESOURCE_DMA,
  500. },
  501. [3] = {
  502. /* DRCMR for TX */
  503. .start = 3,
  504. .end = 3,
  505. .flags = IORESOURCE_DMA,
  506. },
  507. };
  508. struct platform_device pxa3xx_device_ssp4 = {
  509. /* PXA3xx SSP is basically equivalent to PXA27x */
  510. .name = "pxa27x-ssp",
  511. .id = 3,
  512. .dev = {
  513. .dma_mask = &pxa3xx_ssp4_dma_mask,
  514. .coherent_dma_mask = DMA_BIT_MASK(32),
  515. },
  516. .resource = pxa3xx_resource_ssp4,
  517. .num_resources = ARRAY_SIZE(pxa3xx_resource_ssp4),
  518. };
  519. static struct resource pxa3xx_resources_mci2[] = {
  520. [0] = {
  521. .start = 0x42000000,
  522. .end = 0x42000fff,
  523. .flags = IORESOURCE_MEM,
  524. },
  525. [1] = {
  526. .start = IRQ_MMC2,
  527. .end = IRQ_MMC2,
  528. .flags = IORESOURCE_IRQ,
  529. },
  530. [2] = {
  531. .start = 93,
  532. .end = 93,
  533. .flags = IORESOURCE_DMA,
  534. },
  535. [3] = {
  536. .start = 94,
  537. .end = 94,
  538. .flags = IORESOURCE_DMA,
  539. },
  540. };
  541. struct platform_device pxa3xx_device_mci2 = {
  542. .name = "pxa2xx-mci",
  543. .id = 1,
  544. .dev = {
  545. .dma_mask = &pxamci_dmamask,
  546. .coherent_dma_mask = 0xffffffff,
  547. },
  548. .num_resources = ARRAY_SIZE(pxa3xx_resources_mci2),
  549. .resource = pxa3xx_resources_mci2,
  550. };
  551. void __init pxa3xx_set_mci2_info(struct pxamci_platform_data *info)
  552. {
  553. pxa_register_device(&pxa3xx_device_mci2, info);
  554. }
  555. static struct resource pxa3xx_resources_mci3[] = {
  556. [0] = {
  557. .start = 0x42500000,
  558. .end = 0x42500fff,
  559. .flags = IORESOURCE_MEM,
  560. },
  561. [1] = {
  562. .start = IRQ_MMC3,
  563. .end = IRQ_MMC3,
  564. .flags = IORESOURCE_IRQ,
  565. },
  566. [2] = {
  567. .start = 100,
  568. .end = 100,
  569. .flags = IORESOURCE_DMA,
  570. },
  571. [3] = {
  572. .start = 101,
  573. .end = 101,
  574. .flags = IORESOURCE_DMA,
  575. },
  576. };
  577. struct platform_device pxa3xx_device_mci3 = {
  578. .name = "pxa2xx-mci",
  579. .id = 2,
  580. .dev = {
  581. .dma_mask = &pxamci_dmamask,
  582. .coherent_dma_mask = 0xffffffff,
  583. },
  584. .num_resources = ARRAY_SIZE(pxa3xx_resources_mci3),
  585. .resource = pxa3xx_resources_mci3,
  586. };
  587. void __init pxa3xx_set_mci3_info(struct pxamci_platform_data *info)
  588. {
  589. pxa_register_device(&pxa3xx_device_mci3, info);
  590. }
  591. #endif /* CONFIG_PXA3xx */