devices.c 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  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 <mach/mx3_camera.h>
  29. #include "devices.h"
  30. static struct resource uart0[] = {
  31. {
  32. .start = UART1_BASE_ADDR,
  33. .end = UART1_BASE_ADDR + 0x0B5,
  34. .flags = IORESOURCE_MEM,
  35. }, {
  36. .start = MXC_INT_UART1,
  37. .end = MXC_INT_UART1,
  38. .flags = IORESOURCE_IRQ,
  39. },
  40. };
  41. struct platform_device mxc_uart_device0 = {
  42. .name = "imx-uart",
  43. .id = 0,
  44. .resource = uart0,
  45. .num_resources = ARRAY_SIZE(uart0),
  46. };
  47. static struct resource uart1[] = {
  48. {
  49. .start = UART2_BASE_ADDR,
  50. .end = UART2_BASE_ADDR + 0x0B5,
  51. .flags = IORESOURCE_MEM,
  52. }, {
  53. .start = MXC_INT_UART2,
  54. .end = MXC_INT_UART2,
  55. .flags = IORESOURCE_IRQ,
  56. },
  57. };
  58. struct platform_device mxc_uart_device1 = {
  59. .name = "imx-uart",
  60. .id = 1,
  61. .resource = uart1,
  62. .num_resources = ARRAY_SIZE(uart1),
  63. };
  64. static struct resource uart2[] = {
  65. {
  66. .start = UART3_BASE_ADDR,
  67. .end = UART3_BASE_ADDR + 0x0B5,
  68. .flags = IORESOURCE_MEM,
  69. }, {
  70. .start = MXC_INT_UART3,
  71. .end = MXC_INT_UART3,
  72. .flags = IORESOURCE_IRQ,
  73. },
  74. };
  75. struct platform_device mxc_uart_device2 = {
  76. .name = "imx-uart",
  77. .id = 2,
  78. .resource = uart2,
  79. .num_resources = ARRAY_SIZE(uart2),
  80. };
  81. #ifdef CONFIG_ARCH_MX31
  82. static struct resource uart3[] = {
  83. {
  84. .start = UART4_BASE_ADDR,
  85. .end = UART4_BASE_ADDR + 0x0B5,
  86. .flags = IORESOURCE_MEM,
  87. }, {
  88. .start = MXC_INT_UART4,
  89. .end = MXC_INT_UART4,
  90. .flags = IORESOURCE_IRQ,
  91. },
  92. };
  93. struct platform_device mxc_uart_device3 = {
  94. .name = "imx-uart",
  95. .id = 3,
  96. .resource = uart3,
  97. .num_resources = ARRAY_SIZE(uart3),
  98. };
  99. static struct resource uart4[] = {
  100. {
  101. .start = UART5_BASE_ADDR,
  102. .end = UART5_BASE_ADDR + 0x0B5,
  103. .flags = IORESOURCE_MEM,
  104. }, {
  105. .start = MXC_INT_UART5,
  106. .end = MXC_INT_UART5,
  107. .flags = IORESOURCE_IRQ,
  108. },
  109. };
  110. struct platform_device mxc_uart_device4 = {
  111. .name = "imx-uart",
  112. .id = 4,
  113. .resource = uart4,
  114. .num_resources = ARRAY_SIZE(uart4),
  115. };
  116. #endif /* CONFIG_ARCH_MX31 */
  117. /* GPIO port description */
  118. static struct mxc_gpio_port imx_gpio_ports[] = {
  119. [0] = {
  120. .chip.label = "gpio-0",
  121. .base = IO_ADDRESS(GPIO1_BASE_ADDR),
  122. .irq = MXC_INT_GPIO1,
  123. .virtual_irq_start = MXC_GPIO_IRQ_START,
  124. },
  125. [1] = {
  126. .chip.label = "gpio-1",
  127. .base = IO_ADDRESS(GPIO2_BASE_ADDR),
  128. .irq = MXC_INT_GPIO2,
  129. .virtual_irq_start = MXC_GPIO_IRQ_START + 32,
  130. },
  131. [2] = {
  132. .chip.label = "gpio-2",
  133. .base = IO_ADDRESS(GPIO3_BASE_ADDR),
  134. .irq = MXC_INT_GPIO3,
  135. .virtual_irq_start = MXC_GPIO_IRQ_START + 64,
  136. }
  137. };
  138. int __init mxc_register_gpios(void)
  139. {
  140. return mxc_gpio_init(imx_gpio_ports, ARRAY_SIZE(imx_gpio_ports));
  141. }
  142. static struct resource mxc_w1_master_resources[] = {
  143. {
  144. .start = OWIRE_BASE_ADDR,
  145. .end = OWIRE_BASE_ADDR + SZ_4K - 1,
  146. .flags = IORESOURCE_MEM,
  147. },
  148. };
  149. struct platform_device mxc_w1_master_device = {
  150. .name = "mxc_w1",
  151. .id = 0,
  152. .num_resources = ARRAY_SIZE(mxc_w1_master_resources),
  153. .resource = mxc_w1_master_resources,
  154. };
  155. static struct resource mxc_nand_resources[] = {
  156. {
  157. .start = 0, /* runtime dependent */
  158. .end = 0,
  159. .flags = IORESOURCE_MEM
  160. }, {
  161. .start = MXC_INT_NANDFC,
  162. .end = MXC_INT_NANDFC,
  163. .flags = IORESOURCE_IRQ
  164. },
  165. };
  166. struct platform_device mxc_nand_device = {
  167. .name = "mxc_nand",
  168. .id = 0,
  169. .num_resources = ARRAY_SIZE(mxc_nand_resources),
  170. .resource = mxc_nand_resources,
  171. };
  172. static struct resource mxc_i2c0_resources[] = {
  173. {
  174. .start = I2C_BASE_ADDR,
  175. .end = I2C_BASE_ADDR + SZ_4K - 1,
  176. .flags = IORESOURCE_MEM,
  177. },
  178. {
  179. .start = MXC_INT_I2C,
  180. .end = MXC_INT_I2C,
  181. .flags = IORESOURCE_IRQ,
  182. },
  183. };
  184. struct platform_device mxc_i2c_device0 = {
  185. .name = "imx-i2c",
  186. .id = 0,
  187. .num_resources = ARRAY_SIZE(mxc_i2c0_resources),
  188. .resource = mxc_i2c0_resources,
  189. };
  190. static struct resource mxc_i2c1_resources[] = {
  191. {
  192. .start = I2C2_BASE_ADDR,
  193. .end = I2C2_BASE_ADDR + SZ_4K - 1,
  194. .flags = IORESOURCE_MEM,
  195. },
  196. {
  197. .start = MXC_INT_I2C2,
  198. .end = MXC_INT_I2C2,
  199. .flags = IORESOURCE_IRQ,
  200. },
  201. };
  202. struct platform_device mxc_i2c_device1 = {
  203. .name = "imx-i2c",
  204. .id = 1,
  205. .num_resources = ARRAY_SIZE(mxc_i2c1_resources),
  206. .resource = mxc_i2c1_resources,
  207. };
  208. static struct resource mxc_i2c2_resources[] = {
  209. {
  210. .start = I2C3_BASE_ADDR,
  211. .end = I2C3_BASE_ADDR + SZ_4K - 1,
  212. .flags = IORESOURCE_MEM,
  213. },
  214. {
  215. .start = MXC_INT_I2C3,
  216. .end = MXC_INT_I2C3,
  217. .flags = IORESOURCE_IRQ,
  218. },
  219. };
  220. struct platform_device mxc_i2c_device2 = {
  221. .name = "imx-i2c",
  222. .id = 2,
  223. .num_resources = ARRAY_SIZE(mxc_i2c2_resources),
  224. .resource = mxc_i2c2_resources,
  225. };
  226. #ifdef CONFIG_ARCH_MX31
  227. static struct resource mxcsdhc0_resources[] = {
  228. {
  229. .start = MMC_SDHC1_BASE_ADDR,
  230. .end = MMC_SDHC1_BASE_ADDR + SZ_16K - 1,
  231. .flags = IORESOURCE_MEM,
  232. }, {
  233. .start = MXC_INT_MMC_SDHC1,
  234. .end = MXC_INT_MMC_SDHC1,
  235. .flags = IORESOURCE_IRQ,
  236. },
  237. };
  238. static struct resource mxcsdhc1_resources[] = {
  239. {
  240. .start = MMC_SDHC2_BASE_ADDR,
  241. .end = MMC_SDHC2_BASE_ADDR + SZ_16K - 1,
  242. .flags = IORESOURCE_MEM,
  243. }, {
  244. .start = MXC_INT_MMC_SDHC2,
  245. .end = MXC_INT_MMC_SDHC2,
  246. .flags = IORESOURCE_IRQ,
  247. },
  248. };
  249. struct platform_device mxcsdhc_device0 = {
  250. .name = "mxc-mmc",
  251. .id = 0,
  252. .num_resources = ARRAY_SIZE(mxcsdhc0_resources),
  253. .resource = mxcsdhc0_resources,
  254. };
  255. struct platform_device mxcsdhc_device1 = {
  256. .name = "mxc-mmc",
  257. .id = 1,
  258. .num_resources = ARRAY_SIZE(mxcsdhc1_resources),
  259. .resource = mxcsdhc1_resources,
  260. };
  261. static struct resource rnga_resources[] = {
  262. {
  263. .start = RNGA_BASE_ADDR,
  264. .end = RNGA_BASE_ADDR + 0x28,
  265. .flags = IORESOURCE_MEM,
  266. },
  267. };
  268. struct platform_device mxc_rnga_device = {
  269. .name = "mxc_rnga",
  270. .id = -1,
  271. .num_resources = 1,
  272. .resource = rnga_resources,
  273. };
  274. #endif /* CONFIG_ARCH_MX31 */
  275. /* i.MX31 Image Processing Unit */
  276. /* The resource order is important! */
  277. static struct resource mx3_ipu_rsrc[] = {
  278. {
  279. .start = IPU_CTRL_BASE_ADDR,
  280. .end = IPU_CTRL_BASE_ADDR + 0x5F,
  281. .flags = IORESOURCE_MEM,
  282. }, {
  283. .start = IPU_CTRL_BASE_ADDR + 0x88,
  284. .end = IPU_CTRL_BASE_ADDR + 0xB3,
  285. .flags = IORESOURCE_MEM,
  286. }, {
  287. .start = MXC_INT_IPU_SYN,
  288. .end = MXC_INT_IPU_SYN,
  289. .flags = IORESOURCE_IRQ,
  290. }, {
  291. .start = MXC_INT_IPU_ERR,
  292. .end = MXC_INT_IPU_ERR,
  293. .flags = IORESOURCE_IRQ,
  294. },
  295. };
  296. struct platform_device mx3_ipu = {
  297. .name = "ipu-core",
  298. .id = -1,
  299. .num_resources = ARRAY_SIZE(mx3_ipu_rsrc),
  300. .resource = mx3_ipu_rsrc,
  301. };
  302. static struct resource fb_resources[] = {
  303. {
  304. .start = IPU_CTRL_BASE_ADDR + 0xB4,
  305. .end = IPU_CTRL_BASE_ADDR + 0x1BF,
  306. .flags = IORESOURCE_MEM,
  307. },
  308. };
  309. struct platform_device mx3_fb = {
  310. .name = "mx3_sdc_fb",
  311. .id = -1,
  312. .num_resources = ARRAY_SIZE(fb_resources),
  313. .resource = fb_resources,
  314. .dev = {
  315. .coherent_dma_mask = DMA_BIT_MASK(32),
  316. },
  317. };
  318. static struct resource camera_resources[] = {
  319. {
  320. .start = IPU_CTRL_BASE_ADDR + 0x60,
  321. .end = IPU_CTRL_BASE_ADDR + 0x87,
  322. .flags = IORESOURCE_MEM,
  323. },
  324. };
  325. struct platform_device mx3_camera = {
  326. .name = "mx3-camera",
  327. .id = 0,
  328. .num_resources = ARRAY_SIZE(camera_resources),
  329. .resource = camera_resources,
  330. .dev = {
  331. .coherent_dma_mask = DMA_BIT_MASK(32),
  332. },
  333. };
  334. static struct resource otg_resources[] = {
  335. {
  336. .start = OTG_BASE_ADDR,
  337. .end = OTG_BASE_ADDR + 0x1ff,
  338. .flags = IORESOURCE_MEM,
  339. }, {
  340. .start = MXC_INT_USB3,
  341. .end = MXC_INT_USB3,
  342. .flags = IORESOURCE_IRQ,
  343. },
  344. };
  345. static u64 otg_dmamask = DMA_BIT_MASK(32);
  346. /* OTG gadget device */
  347. struct platform_device mxc_otg_udc_device = {
  348. .name = "fsl-usb2-udc",
  349. .id = -1,
  350. .dev = {
  351. .dma_mask = &otg_dmamask,
  352. .coherent_dma_mask = DMA_BIT_MASK(32),
  353. },
  354. .resource = otg_resources,
  355. .num_resources = ARRAY_SIZE(otg_resources),
  356. };
  357. #ifdef CONFIG_ARCH_MX35
  358. static struct resource mxc_fec_resources[] = {
  359. {
  360. .start = MXC_FEC_BASE_ADDR,
  361. .end = MXC_FEC_BASE_ADDR + 0xfff,
  362. .flags = IORESOURCE_MEM
  363. }, {
  364. .start = MXC_INT_FEC,
  365. .end = MXC_INT_FEC,
  366. .flags = IORESOURCE_IRQ
  367. },
  368. };
  369. struct platform_device mxc_fec_device = {
  370. .name = "fec",
  371. .id = 0,
  372. .num_resources = ARRAY_SIZE(mxc_fec_resources),
  373. .resource = mxc_fec_resources,
  374. };
  375. #endif
  376. static int mx3_devices_init(void)
  377. {
  378. if (cpu_is_mx31()) {
  379. mxc_nand_resources[0].start = MX31_NFC_BASE_ADDR;
  380. mxc_nand_resources[0].end = MX31_NFC_BASE_ADDR + 0xfff;
  381. mxc_register_device(&mxc_rnga_device, NULL);
  382. }
  383. if (cpu_is_mx35()) {
  384. mxc_nand_resources[0].start = MX35_NFC_BASE_ADDR;
  385. mxc_nand_resources[0].end = MX35_NFC_BASE_ADDR + 0xfff;
  386. }
  387. return 0;
  388. }
  389. subsys_initcall(mx3_devices_init);