devices.c 8.4 KB

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