devices.c 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. #include <linux/platform_device.h>
  2. #include <linux/gpio.h>
  3. #include <mach/mx25.h>
  4. #include <mach/irqs.h>
  5. static struct resource uart0[] = {
  6. {
  7. .start = 0x43f90000,
  8. .end = 0x43f93fff,
  9. .flags = IORESOURCE_MEM,
  10. }, {
  11. .start = 45,
  12. .end = 45,
  13. .flags = IORESOURCE_IRQ,
  14. },
  15. };
  16. struct platform_device mxc_uart_device0 = {
  17. .name = "imx-uart",
  18. .id = 0,
  19. .resource = uart0,
  20. .num_resources = ARRAY_SIZE(uart0),
  21. };
  22. static struct resource uart1[] = {
  23. {
  24. .start = 0x43f94000,
  25. .end = 0x43f97fff,
  26. .flags = IORESOURCE_MEM,
  27. }, {
  28. .start = 32,
  29. .end = 32,
  30. .flags = IORESOURCE_IRQ,
  31. },
  32. };
  33. struct platform_device mxc_uart_device1 = {
  34. .name = "imx-uart",
  35. .id = 1,
  36. .resource = uart1,
  37. .num_resources = ARRAY_SIZE(uart1),
  38. };
  39. static struct resource uart2[] = {
  40. {
  41. .start = 0x5000c000,
  42. .end = 0x5000ffff,
  43. .flags = IORESOURCE_MEM,
  44. }, {
  45. .start = 18,
  46. .end = 18,
  47. .flags = IORESOURCE_IRQ,
  48. },
  49. };
  50. struct platform_device mxc_uart_device2 = {
  51. .name = "imx-uart",
  52. .id = 2,
  53. .resource = uart2,
  54. .num_resources = ARRAY_SIZE(uart2),
  55. };
  56. static struct resource uart3[] = {
  57. {
  58. .start = 0x50008000,
  59. .end = 0x5000bfff,
  60. .flags = IORESOURCE_MEM,
  61. }, {
  62. .start = 5,
  63. .end = 5,
  64. .flags = IORESOURCE_IRQ,
  65. },
  66. };
  67. struct platform_device mxc_uart_device3 = {
  68. .name = "imx-uart",
  69. .id = 3,
  70. .resource = uart3,
  71. .num_resources = ARRAY_SIZE(uart3),
  72. };
  73. static struct resource uart4[] = {
  74. {
  75. .start = 0x5002c000,
  76. .end = 0x5002ffff,
  77. .flags = IORESOURCE_MEM,
  78. }, {
  79. .start = 40,
  80. .end = 40,
  81. .flags = IORESOURCE_IRQ,
  82. },
  83. };
  84. struct platform_device mxc_uart_device4 = {
  85. .name = "imx-uart",
  86. .id = 4,
  87. .resource = uart4,
  88. .num_resources = ARRAY_SIZE(uart4),
  89. };
  90. #define MX25_OTG_BASE_ADDR 0x53FF4000
  91. static u64 otg_dmamask = DMA_BIT_MASK(32);
  92. static struct resource mxc_otg_resources[] = {
  93. {
  94. .start = MX25_OTG_BASE_ADDR,
  95. .end = MX25_OTG_BASE_ADDR + 0x1ff,
  96. .flags = IORESOURCE_MEM,
  97. }, {
  98. .start = 37,
  99. .end = 37,
  100. .flags = IORESOURCE_IRQ,
  101. },
  102. };
  103. struct platform_device mxc_otg = {
  104. .name = "mxc-ehci",
  105. .id = 0,
  106. .dev = {
  107. .coherent_dma_mask = 0xffffffff,
  108. .dma_mask = &otg_dmamask,
  109. },
  110. .resource = mxc_otg_resources,
  111. .num_resources = ARRAY_SIZE(mxc_otg_resources),
  112. };
  113. /* OTG gadget device */
  114. struct platform_device otg_udc_device = {
  115. .name = "fsl-usb2-udc",
  116. .id = -1,
  117. .dev = {
  118. .dma_mask = &otg_dmamask,
  119. .coherent_dma_mask = 0xffffffff,
  120. },
  121. .resource = mxc_otg_resources,
  122. .num_resources = ARRAY_SIZE(mxc_otg_resources),
  123. };
  124. static u64 usbh2_dmamask = DMA_BIT_MASK(32);
  125. static struct resource mxc_usbh2_resources[] = {
  126. {
  127. .start = MX25_OTG_BASE_ADDR + 0x400,
  128. .end = MX25_OTG_BASE_ADDR + 0x5ff,
  129. .flags = IORESOURCE_MEM,
  130. }, {
  131. .start = 35,
  132. .end = 35,
  133. .flags = IORESOURCE_IRQ,
  134. },
  135. };
  136. struct platform_device mxc_usbh2 = {
  137. .name = "mxc-ehci",
  138. .id = 1,
  139. .dev = {
  140. .coherent_dma_mask = 0xffffffff,
  141. .dma_mask = &usbh2_dmamask,
  142. },
  143. .resource = mxc_usbh2_resources,
  144. .num_resources = ARRAY_SIZE(mxc_usbh2_resources),
  145. };
  146. static struct resource mxc_spi_resources0[] = {
  147. {
  148. .start = 0x43fa4000,
  149. .end = 0x43fa7fff,
  150. .flags = IORESOURCE_MEM,
  151. }, {
  152. .start = 14,
  153. .end = 14,
  154. .flags = IORESOURCE_IRQ,
  155. },
  156. };
  157. struct platform_device mxc_spi_device0 = {
  158. .name = "spi_imx",
  159. .id = 0,
  160. .num_resources = ARRAY_SIZE(mxc_spi_resources0),
  161. .resource = mxc_spi_resources0,
  162. };
  163. static struct resource mxc_spi_resources1[] = {
  164. {
  165. .start = 0x50010000,
  166. .end = 0x50013fff,
  167. .flags = IORESOURCE_MEM,
  168. }, {
  169. .start = 13,
  170. .end = 13,
  171. .flags = IORESOURCE_IRQ,
  172. },
  173. };
  174. struct platform_device mxc_spi_device1 = {
  175. .name = "spi_imx",
  176. .id = 1,
  177. .num_resources = ARRAY_SIZE(mxc_spi_resources1),
  178. .resource = mxc_spi_resources1,
  179. };
  180. static struct resource mxc_spi_resources2[] = {
  181. {
  182. .start = 0x50004000,
  183. .end = 0x50007fff,
  184. .flags = IORESOURCE_MEM,
  185. }, {
  186. .start = 0,
  187. .end = 0,
  188. .flags = IORESOURCE_IRQ,
  189. },
  190. };
  191. struct platform_device mxc_spi_device2 = {
  192. .name = "spi_imx",
  193. .id = 2,
  194. .num_resources = ARRAY_SIZE(mxc_spi_resources2),
  195. .resource = mxc_spi_resources2,
  196. };
  197. static struct resource mxc_pwm_resources0[] = {
  198. {
  199. .start = 0x53fe0000,
  200. .end = 0x53fe3fff,
  201. .flags = IORESOURCE_MEM,
  202. }, {
  203. .start = 26,
  204. .end = 26,
  205. .flags = IORESOURCE_IRQ,
  206. }
  207. };
  208. struct platform_device mxc_pwm_device0 = {
  209. .name = "mxc_pwm",
  210. .id = 0,
  211. .num_resources = ARRAY_SIZE(mxc_pwm_resources0),
  212. .resource = mxc_pwm_resources0,
  213. };
  214. static struct resource mxc_pwm_resources1[] = {
  215. {
  216. .start = 0x53fa0000,
  217. .end = 0x53fa3fff,
  218. .flags = IORESOURCE_MEM,
  219. }, {
  220. .start = 36,
  221. .end = 36,
  222. .flags = IORESOURCE_IRQ,
  223. }
  224. };
  225. struct platform_device mxc_pwm_device1 = {
  226. .name = "mxc_pwm",
  227. .id = 1,
  228. .num_resources = ARRAY_SIZE(mxc_pwm_resources1),
  229. .resource = mxc_pwm_resources1,
  230. };
  231. static struct resource mxc_pwm_resources2[] = {
  232. {
  233. .start = 0x53fa8000,
  234. .end = 0x53fabfff,
  235. .flags = IORESOURCE_MEM,
  236. }, {
  237. .start = 41,
  238. .end = 41,
  239. .flags = IORESOURCE_IRQ,
  240. }
  241. };
  242. struct platform_device mxc_pwm_device2 = {
  243. .name = "mxc_pwm",
  244. .id = 2,
  245. .num_resources = ARRAY_SIZE(mxc_pwm_resources2),
  246. .resource = mxc_pwm_resources2,
  247. };
  248. static struct resource mxc_keypad_resources[] = {
  249. {
  250. .start = 0x43fa8000,
  251. .end = 0x43fabfff,
  252. .flags = IORESOURCE_MEM,
  253. }, {
  254. .start = 24,
  255. .end = 24,
  256. .flags = IORESOURCE_IRQ,
  257. }
  258. };
  259. struct platform_device mxc_keypad_device = {
  260. .name = "mxc-keypad",
  261. .id = -1,
  262. .num_resources = ARRAY_SIZE(mxc_keypad_resources),
  263. .resource = mxc_keypad_resources,
  264. };
  265. static struct resource mxc_pwm_resources3[] = {
  266. {
  267. .start = 0x53fc8000,
  268. .end = 0x53fcbfff,
  269. .flags = IORESOURCE_MEM,
  270. }, {
  271. .start = 42,
  272. .end = 42,
  273. .flags = IORESOURCE_IRQ,
  274. }
  275. };
  276. struct platform_device mxc_pwm_device3 = {
  277. .name = "mxc_pwm",
  278. .id = 3,
  279. .num_resources = ARRAY_SIZE(mxc_pwm_resources3),
  280. .resource = mxc_pwm_resources3,
  281. };
  282. static struct resource mxc_i2c_1_resources[] = {
  283. {
  284. .start = 0x43f80000,
  285. .end = 0x43f83fff,
  286. .flags = IORESOURCE_MEM,
  287. }, {
  288. .start = 3,
  289. .end = 3,
  290. .flags = IORESOURCE_IRQ,
  291. }
  292. };
  293. struct platform_device mxc_i2c_device0 = {
  294. .name = "imx-i2c",
  295. .id = 0,
  296. .num_resources = ARRAY_SIZE(mxc_i2c_1_resources),
  297. .resource = mxc_i2c_1_resources,
  298. };
  299. static struct resource mxc_i2c_2_resources[] = {
  300. {
  301. .start = 0x43f98000,
  302. .end = 0x43f9bfff,
  303. .flags = IORESOURCE_MEM,
  304. }, {
  305. .start = 4,
  306. .end = 4,
  307. .flags = IORESOURCE_IRQ,
  308. }
  309. };
  310. struct platform_device mxc_i2c_device1 = {
  311. .name = "imx-i2c",
  312. .id = 1,
  313. .num_resources = ARRAY_SIZE(mxc_i2c_2_resources),
  314. .resource = mxc_i2c_2_resources,
  315. };
  316. static struct resource mxc_i2c_3_resources[] = {
  317. {
  318. .start = 0x43f84000,
  319. .end = 0x43f87fff,
  320. .flags = IORESOURCE_MEM,
  321. }, {
  322. .start = 10,
  323. .end = 10,
  324. .flags = IORESOURCE_IRQ,
  325. }
  326. };
  327. struct platform_device mxc_i2c_device2 = {
  328. .name = "imx-i2c",
  329. .id = 2,
  330. .num_resources = ARRAY_SIZE(mxc_i2c_3_resources),
  331. .resource = mxc_i2c_3_resources,
  332. };
  333. static struct mxc_gpio_port imx_gpio_ports[] = {
  334. {
  335. .chip.label = "gpio-0",
  336. .base = (void __iomem *)MX25_GPIO1_BASE_ADDR_VIRT,
  337. .irq = 52,
  338. .virtual_irq_start = MXC_GPIO_IRQ_START,
  339. }, {
  340. .chip.label = "gpio-1",
  341. .base = (void __iomem *)MX25_GPIO2_BASE_ADDR_VIRT,
  342. .irq = 51,
  343. .virtual_irq_start = MXC_GPIO_IRQ_START + 32,
  344. }, {
  345. .chip.label = "gpio-2",
  346. .base = (void __iomem *)MX25_GPIO3_BASE_ADDR_VIRT,
  347. .irq = 16,
  348. .virtual_irq_start = MXC_GPIO_IRQ_START + 64,
  349. }, {
  350. .chip.label = "gpio-3",
  351. .base = (void __iomem *)MX25_GPIO4_BASE_ADDR_VIRT,
  352. .irq = 23,
  353. .virtual_irq_start = MXC_GPIO_IRQ_START + 96,
  354. }
  355. };
  356. int __init mxc_register_gpios(void)
  357. {
  358. return mxc_gpio_init(imx_gpio_ports, ARRAY_SIZE(imx_gpio_ports));
  359. }