devices.c 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  1. /*
  2. * Copyright 2006-2007 Freescale Semiconductor, Inc. All Rights Reserved.
  3. * Copyright 2008 Sascha Hauer, kernel@pengutronix.de
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * as published by the Free Software Foundation; either version 2
  8. * of the License, or (at your option) any later version.
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor,
  17. * Boston, MA 02110-1301, USA.
  18. */
  19. #include <linux/dma-mapping.h>
  20. #include <linux/module.h>
  21. #include <linux/platform_device.h>
  22. #include <linux/serial.h>
  23. #include <linux/gpio.h>
  24. #include <mach/hardware.h>
  25. #include <mach/irqs.h>
  26. #include <mach/common.h>
  27. #include <mach/imx-uart.h>
  28. #include "devices.h"
  29. static struct resource uart0[] = {
  30. {
  31. .start = UART1_BASE_ADDR,
  32. .end = UART1_BASE_ADDR + 0x0B5,
  33. .flags = IORESOURCE_MEM,
  34. }, {
  35. .start = MXC_INT_UART1,
  36. .end = MXC_INT_UART1,
  37. .flags = IORESOURCE_IRQ,
  38. },
  39. };
  40. struct platform_device mxc_uart_device0 = {
  41. .name = "imx-uart",
  42. .id = 0,
  43. .resource = uart0,
  44. .num_resources = ARRAY_SIZE(uart0),
  45. };
  46. static struct resource uart1[] = {
  47. {
  48. .start = UART2_BASE_ADDR,
  49. .end = UART2_BASE_ADDR + 0x0B5,
  50. .flags = IORESOURCE_MEM,
  51. }, {
  52. .start = MXC_INT_UART2,
  53. .end = MXC_INT_UART2,
  54. .flags = IORESOURCE_IRQ,
  55. },
  56. };
  57. struct platform_device mxc_uart_device1 = {
  58. .name = "imx-uart",
  59. .id = 1,
  60. .resource = uart1,
  61. .num_resources = ARRAY_SIZE(uart1),
  62. };
  63. static struct resource uart2[] = {
  64. {
  65. .start = UART3_BASE_ADDR,
  66. .end = UART3_BASE_ADDR + 0x0B5,
  67. .flags = IORESOURCE_MEM,
  68. }, {
  69. .start = MXC_INT_UART3,
  70. .end = MXC_INT_UART3,
  71. .flags = IORESOURCE_IRQ,
  72. },
  73. };
  74. struct platform_device mxc_uart_device2 = {
  75. .name = "imx-uart",
  76. .id = 2,
  77. .resource = uart2,
  78. .num_resources = ARRAY_SIZE(uart2),
  79. };
  80. #ifdef CONFIG_ARCH_MX31
  81. static struct resource uart3[] = {
  82. {
  83. .start = UART4_BASE_ADDR,
  84. .end = UART4_BASE_ADDR + 0x0B5,
  85. .flags = IORESOURCE_MEM,
  86. }, {
  87. .start = MXC_INT_UART4,
  88. .end = MXC_INT_UART4,
  89. .flags = IORESOURCE_IRQ,
  90. },
  91. };
  92. struct platform_device mxc_uart_device3 = {
  93. .name = "imx-uart",
  94. .id = 3,
  95. .resource = uart3,
  96. .num_resources = ARRAY_SIZE(uart3),
  97. };
  98. static struct resource uart4[] = {
  99. {
  100. .start = UART5_BASE_ADDR,
  101. .end = UART5_BASE_ADDR + 0x0B5,
  102. .flags = IORESOURCE_MEM,
  103. }, {
  104. .start = MXC_INT_UART5,
  105. .end = MXC_INT_UART5,
  106. .flags = IORESOURCE_IRQ,
  107. },
  108. };
  109. struct platform_device mxc_uart_device4 = {
  110. .name = "imx-uart",
  111. .id = 4,
  112. .resource = uart4,
  113. .num_resources = ARRAY_SIZE(uart4),
  114. };
  115. #endif /* CONFIG_ARCH_MX31 */
  116. /* GPIO port description */
  117. static struct mxc_gpio_port imx_gpio_ports[] = {
  118. [0] = {
  119. .chip.label = "gpio-0",
  120. .base = IO_ADDRESS(GPIO1_BASE_ADDR),
  121. .irq = MXC_INT_GPIO1,
  122. .virtual_irq_start = MXC_GPIO_IRQ_START,
  123. },
  124. [1] = {
  125. .chip.label = "gpio-1",
  126. .base = IO_ADDRESS(GPIO2_BASE_ADDR),
  127. .irq = MXC_INT_GPIO2,
  128. .virtual_irq_start = MXC_GPIO_IRQ_START + 32,
  129. },
  130. [2] = {
  131. .chip.label = "gpio-2",
  132. .base = IO_ADDRESS(GPIO3_BASE_ADDR),
  133. .irq = MXC_INT_GPIO3,
  134. .virtual_irq_start = MXC_GPIO_IRQ_START + 64,
  135. }
  136. };
  137. int __init mxc_register_gpios(void)
  138. {
  139. return mxc_gpio_init(imx_gpio_ports, ARRAY_SIZE(imx_gpio_ports));
  140. }
  141. static struct resource mxc_w1_master_resources[] = {
  142. {
  143. .start = OWIRE_BASE_ADDR,
  144. .end = OWIRE_BASE_ADDR + SZ_4K - 1,
  145. .flags = IORESOURCE_MEM,
  146. },
  147. };
  148. struct platform_device mxc_w1_master_device = {
  149. .name = "mxc_w1",
  150. .id = 0,
  151. .num_resources = ARRAY_SIZE(mxc_w1_master_resources),
  152. .resource = mxc_w1_master_resources,
  153. };
  154. static struct resource mxc_nand_resources[] = {
  155. {
  156. .start = 0, /* runtime dependent */
  157. .end = 0,
  158. .flags = IORESOURCE_MEM
  159. }, {
  160. .start = MXC_INT_NANDFC,
  161. .end = MXC_INT_NANDFC,
  162. .flags = IORESOURCE_IRQ
  163. },
  164. };
  165. struct platform_device mxc_nand_device = {
  166. .name = "mxc_nand",
  167. .id = 0,
  168. .num_resources = ARRAY_SIZE(mxc_nand_resources),
  169. .resource = mxc_nand_resources,
  170. };
  171. static struct resource mxc_i2c0_resources[] = {
  172. {
  173. .start = I2C_BASE_ADDR,
  174. .end = I2C_BASE_ADDR + SZ_4K - 1,
  175. .flags = IORESOURCE_MEM,
  176. },
  177. {
  178. .start = MXC_INT_I2C,
  179. .end = MXC_INT_I2C,
  180. .flags = IORESOURCE_IRQ,
  181. },
  182. };
  183. struct platform_device mxc_i2c_device0 = {
  184. .name = "imx-i2c",
  185. .id = 0,
  186. .num_resources = ARRAY_SIZE(mxc_i2c0_resources),
  187. .resource = mxc_i2c0_resources,
  188. };
  189. static struct resource mxc_i2c1_resources[] = {
  190. {
  191. .start = I2C2_BASE_ADDR,
  192. .end = I2C2_BASE_ADDR + SZ_4K - 1,
  193. .flags = IORESOURCE_MEM,
  194. },
  195. {
  196. .start = MXC_INT_I2C2,
  197. .end = MXC_INT_I2C2,
  198. .flags = IORESOURCE_IRQ,
  199. },
  200. };
  201. struct platform_device mxc_i2c_device1 = {
  202. .name = "imx-i2c",
  203. .id = 1,
  204. .num_resources = ARRAY_SIZE(mxc_i2c1_resources),
  205. .resource = mxc_i2c1_resources,
  206. };
  207. static struct resource mxc_i2c2_resources[] = {
  208. {
  209. .start = I2C3_BASE_ADDR,
  210. .end = I2C3_BASE_ADDR + SZ_4K - 1,
  211. .flags = IORESOURCE_MEM,
  212. },
  213. {
  214. .start = MXC_INT_I2C3,
  215. .end = MXC_INT_I2C3,
  216. .flags = IORESOURCE_IRQ,
  217. },
  218. };
  219. struct platform_device mxc_i2c_device2 = {
  220. .name = "imx-i2c",
  221. .id = 2,
  222. .num_resources = ARRAY_SIZE(mxc_i2c2_resources),
  223. .resource = mxc_i2c2_resources,
  224. };
  225. #ifdef CONFIG_ARCH_MX31
  226. static struct resource mxcsdhc0_resources[] = {
  227. {
  228. .start = MMC_SDHC1_BASE_ADDR,
  229. .end = MMC_SDHC1_BASE_ADDR + SZ_16K - 1,
  230. .flags = IORESOURCE_MEM,
  231. }, {
  232. .start = MXC_INT_MMC_SDHC1,
  233. .end = MXC_INT_MMC_SDHC1,
  234. .flags = IORESOURCE_IRQ,
  235. },
  236. };
  237. static struct resource mxcsdhc1_resources[] = {
  238. {
  239. .start = MMC_SDHC2_BASE_ADDR,
  240. .end = MMC_SDHC2_BASE_ADDR + SZ_16K - 1,
  241. .flags = IORESOURCE_MEM,
  242. }, {
  243. .start = MXC_INT_MMC_SDHC2,
  244. .end = MXC_INT_MMC_SDHC2,
  245. .flags = IORESOURCE_IRQ,
  246. },
  247. };
  248. struct platform_device mxcsdhc_device0 = {
  249. .name = "mxc-mmc",
  250. .id = 0,
  251. .num_resources = ARRAY_SIZE(mxcsdhc0_resources),
  252. .resource = mxcsdhc0_resources,
  253. };
  254. struct platform_device mxcsdhc_device1 = {
  255. .name = "mxc-mmc",
  256. .id = 1,
  257. .num_resources = ARRAY_SIZE(mxcsdhc1_resources),
  258. .resource = mxcsdhc1_resources,
  259. };
  260. static struct resource rnga_resources[] = {
  261. {
  262. .start = RNGA_BASE_ADDR,
  263. .end = RNGA_BASE_ADDR + 0x28,
  264. .flags = IORESOURCE_MEM,
  265. },
  266. };
  267. struct platform_device mxc_rnga_device = {
  268. .name = "mxc_rnga",
  269. .id = -1,
  270. .num_resources = 1,
  271. .resource = rnga_resources,
  272. };
  273. #endif /* CONFIG_ARCH_MX31 */
  274. /* i.MX31 Image Processing Unit */
  275. /* The resource order is important! */
  276. static struct resource mx3_ipu_rsrc[] = {
  277. {
  278. .start = IPU_CTRL_BASE_ADDR,
  279. .end = IPU_CTRL_BASE_ADDR + 0x5F,
  280. .flags = IORESOURCE_MEM,
  281. }, {
  282. .start = IPU_CTRL_BASE_ADDR + 0x88,
  283. .end = IPU_CTRL_BASE_ADDR + 0xB3,
  284. .flags = IORESOURCE_MEM,
  285. }, {
  286. .start = MXC_INT_IPU_SYN,
  287. .end = MXC_INT_IPU_SYN,
  288. .flags = IORESOURCE_IRQ,
  289. }, {
  290. .start = MXC_INT_IPU_ERR,
  291. .end = MXC_INT_IPU_ERR,
  292. .flags = IORESOURCE_IRQ,
  293. },
  294. };
  295. struct platform_device mx3_ipu = {
  296. .name = "ipu-core",
  297. .id = -1,
  298. .num_resources = ARRAY_SIZE(mx3_ipu_rsrc),
  299. .resource = mx3_ipu_rsrc,
  300. };
  301. static struct resource fb_resources[] = {
  302. {
  303. .start = IPU_CTRL_BASE_ADDR + 0xB4,
  304. .end = IPU_CTRL_BASE_ADDR + 0x1BF,
  305. .flags = IORESOURCE_MEM,
  306. },
  307. };
  308. struct platform_device mx3_fb = {
  309. .name = "mx3_sdc_fb",
  310. .id = -1,
  311. .num_resources = ARRAY_SIZE(fb_resources),
  312. .resource = fb_resources,
  313. .dev = {
  314. .coherent_dma_mask = 0xffffffff,
  315. },
  316. };
  317. static struct resource otg_resources[] = {
  318. {
  319. .start = OTG_BASE_ADDR,
  320. .end = OTG_BASE_ADDR + 0x1ff,
  321. .flags = IORESOURCE_MEM,
  322. }, {
  323. .start = MXC_INT_USB3,
  324. .end = MXC_INT_USB3,
  325. .flags = IORESOURCE_IRQ,
  326. },
  327. };
  328. static u64 otg_dmamask = DMA_BIT_MASK(32);
  329. /* OTG gadget device */
  330. struct platform_device mxc_otg_udc_device = {
  331. .name = "fsl-usb2-udc",
  332. .id = -1,
  333. .dev = {
  334. .dma_mask = &otg_dmamask,
  335. .coherent_dma_mask = DMA_BIT_MASK(32),
  336. },
  337. .resource = otg_resources,
  338. .num_resources = ARRAY_SIZE(otg_resources),
  339. };
  340. #ifdef CONFIG_ARCH_MX35
  341. static struct resource mxc_fec_resources[] = {
  342. {
  343. .start = MXC_FEC_BASE_ADDR,
  344. .end = MXC_FEC_BASE_ADDR + 0xfff,
  345. .flags = IORESOURCE_MEM
  346. }, {
  347. .start = MXC_INT_FEC,
  348. .end = MXC_INT_FEC,
  349. .flags = IORESOURCE_IRQ
  350. },
  351. };
  352. struct platform_device mxc_fec_device = {
  353. .name = "fec",
  354. .id = 0,
  355. .num_resources = ARRAY_SIZE(mxc_fec_resources),
  356. .resource = mxc_fec_resources,
  357. };
  358. #endif
  359. static int mx3_devices_init(void)
  360. {
  361. if (cpu_is_mx31()) {
  362. mxc_nand_resources[0].start = MX31_NFC_BASE_ADDR;
  363. mxc_nand_resources[0].end = MX31_NFC_BASE_ADDR + 0xfff;
  364. mxc_register_device(&mxc_rnga_device, NULL);
  365. }
  366. if (cpu_is_mx35()) {
  367. mxc_nand_resources[0].start = MX35_NFC_BASE_ADDR;
  368. mxc_nand_resources[0].end = MX35_NFC_BASE_ADDR + 0xfff;
  369. }
  370. return 0;
  371. }
  372. subsys_initcall(mx3_devices_init);