devices.c 9.2 KB

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