devices.c 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  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/mx3_camera.h>
  28. #include "devices.h"
  29. /* GPIO port description */
  30. static struct mxc_gpio_port imx_gpio_ports[] = {
  31. {
  32. .chip.label = "gpio-0",
  33. .base = MX31_IO_ADDRESS(MX31_GPIO1_BASE_ADDR),
  34. .irq = MX3x_INT_GPIO1,
  35. .virtual_irq_start = MXC_GPIO_IRQ_START,
  36. }, {
  37. .chip.label = "gpio-1",
  38. .base = MX31_IO_ADDRESS(MX31_GPIO2_BASE_ADDR),
  39. .irq = MX3x_INT_GPIO2,
  40. .virtual_irq_start = MXC_GPIO_IRQ_START + 32,
  41. }, {
  42. .chip.label = "gpio-2",
  43. .base = MX31_IO_ADDRESS(MX31_GPIO3_BASE_ADDR),
  44. .irq = MX3x_INT_GPIO3,
  45. .virtual_irq_start = MXC_GPIO_IRQ_START + 64,
  46. }
  47. };
  48. int __init imx3x_register_gpios(void)
  49. {
  50. return mxc_gpio_init(imx_gpio_ports, ARRAY_SIZE(imx_gpio_ports));
  51. }
  52. #ifdef CONFIG_ARCH_MX31
  53. static struct resource mxcsdhc0_resources[] = {
  54. {
  55. .start = MX31_MMC_SDHC1_BASE_ADDR,
  56. .end = MX31_MMC_SDHC1_BASE_ADDR + SZ_16K - 1,
  57. .flags = IORESOURCE_MEM,
  58. }, {
  59. .start = MX31_INT_MMC_SDHC1,
  60. .end = MX31_INT_MMC_SDHC1,
  61. .flags = IORESOURCE_IRQ,
  62. },
  63. };
  64. static struct resource mxcsdhc1_resources[] = {
  65. {
  66. .start = MX31_MMC_SDHC2_BASE_ADDR,
  67. .end = MX31_MMC_SDHC2_BASE_ADDR + SZ_16K - 1,
  68. .flags = IORESOURCE_MEM,
  69. }, {
  70. .start = MX31_INT_MMC_SDHC2,
  71. .end = MX31_INT_MMC_SDHC2,
  72. .flags = IORESOURCE_IRQ,
  73. },
  74. };
  75. struct platform_device mxcsdhc_device0 = {
  76. .name = "mxc-mmc",
  77. .id = 0,
  78. .num_resources = ARRAY_SIZE(mxcsdhc0_resources),
  79. .resource = mxcsdhc0_resources,
  80. };
  81. struct platform_device mxcsdhc_device1 = {
  82. .name = "mxc-mmc",
  83. .id = 1,
  84. .num_resources = ARRAY_SIZE(mxcsdhc1_resources),
  85. .resource = mxcsdhc1_resources,
  86. };
  87. static struct resource rnga_resources[] = {
  88. {
  89. .start = MX3x_RNGA_BASE_ADDR,
  90. .end = MX3x_RNGA_BASE_ADDR + 0x28,
  91. .flags = IORESOURCE_MEM,
  92. },
  93. };
  94. struct platform_device mxc_rnga_device = {
  95. .name = "mxc_rnga",
  96. .id = -1,
  97. .num_resources = 1,
  98. .resource = rnga_resources,
  99. };
  100. #endif /* CONFIG_ARCH_MX31 */
  101. /* i.MX31 Image Processing Unit */
  102. /* The resource order is important! */
  103. static struct resource mx3_ipu_rsrc[] = {
  104. {
  105. .start = MX3x_IPU_CTRL_BASE_ADDR,
  106. .end = MX3x_IPU_CTRL_BASE_ADDR + 0x5F,
  107. .flags = IORESOURCE_MEM,
  108. }, {
  109. .start = MX3x_IPU_CTRL_BASE_ADDR + 0x88,
  110. .end = MX3x_IPU_CTRL_BASE_ADDR + 0xB3,
  111. .flags = IORESOURCE_MEM,
  112. }, {
  113. .start = MX3x_INT_IPU_SYN,
  114. .end = MX3x_INT_IPU_SYN,
  115. .flags = IORESOURCE_IRQ,
  116. }, {
  117. .start = MX3x_INT_IPU_ERR,
  118. .end = MX3x_INT_IPU_ERR,
  119. .flags = IORESOURCE_IRQ,
  120. },
  121. };
  122. struct platform_device mx3_ipu = {
  123. .name = "ipu-core",
  124. .id = -1,
  125. .num_resources = ARRAY_SIZE(mx3_ipu_rsrc),
  126. .resource = mx3_ipu_rsrc,
  127. };
  128. static struct resource fb_resources[] = {
  129. {
  130. .start = MX3x_IPU_CTRL_BASE_ADDR + 0xB4,
  131. .end = MX3x_IPU_CTRL_BASE_ADDR + 0x1BF,
  132. .flags = IORESOURCE_MEM,
  133. },
  134. };
  135. struct platform_device mx3_fb = {
  136. .name = "mx3_sdc_fb",
  137. .id = -1,
  138. .num_resources = ARRAY_SIZE(fb_resources),
  139. .resource = fb_resources,
  140. .dev = {
  141. .coherent_dma_mask = DMA_BIT_MASK(32),
  142. },
  143. };
  144. static struct resource camera_resources[] = {
  145. {
  146. .start = MX3x_IPU_CTRL_BASE_ADDR + 0x60,
  147. .end = MX3x_IPU_CTRL_BASE_ADDR + 0x87,
  148. .flags = IORESOURCE_MEM,
  149. },
  150. };
  151. struct platform_device mx3_camera = {
  152. .name = "mx3-camera",
  153. .id = 0,
  154. .num_resources = ARRAY_SIZE(camera_resources),
  155. .resource = camera_resources,
  156. .dev = {
  157. .coherent_dma_mask = DMA_BIT_MASK(32),
  158. },
  159. };
  160. static struct resource otg_resources[] = {
  161. {
  162. .start = MX31_OTG_BASE_ADDR,
  163. .end = MX31_OTG_BASE_ADDR + 0x1ff,
  164. .flags = IORESOURCE_MEM,
  165. }, {
  166. .start = MX31_INT_USB3,
  167. .end = MX31_INT_USB3,
  168. .flags = IORESOURCE_IRQ,
  169. },
  170. };
  171. static u64 otg_dmamask = DMA_BIT_MASK(32);
  172. /* OTG gadget device */
  173. struct platform_device mxc_otg_udc_device = {
  174. .name = "fsl-usb2-udc",
  175. .id = -1,
  176. .dev = {
  177. .dma_mask = &otg_dmamask,
  178. .coherent_dma_mask = DMA_BIT_MASK(32),
  179. },
  180. .resource = otg_resources,
  181. .num_resources = ARRAY_SIZE(otg_resources),
  182. };
  183. /* OTG host */
  184. struct platform_device mxc_otg_host = {
  185. .name = "mxc-ehci",
  186. .id = 0,
  187. .dev = {
  188. .coherent_dma_mask = 0xffffffff,
  189. .dma_mask = &otg_dmamask,
  190. },
  191. .resource = otg_resources,
  192. .num_resources = ARRAY_SIZE(otg_resources),
  193. };
  194. /* USB host 1 */
  195. static u64 usbh1_dmamask = ~(u32)0;
  196. static struct resource mxc_usbh1_resources[] = {
  197. {
  198. .start = MX31_OTG_BASE_ADDR + 0x200,
  199. .end = MX31_OTG_BASE_ADDR + 0x3ff,
  200. .flags = IORESOURCE_MEM,
  201. }, {
  202. .start = MX31_INT_USB1,
  203. .end = MX31_INT_USB1,
  204. .flags = IORESOURCE_IRQ,
  205. },
  206. };
  207. struct platform_device mxc_usbh1 = {
  208. .name = "mxc-ehci",
  209. .id = 1,
  210. .dev = {
  211. .coherent_dma_mask = 0xffffffff,
  212. .dma_mask = &usbh1_dmamask,
  213. },
  214. .resource = mxc_usbh1_resources,
  215. .num_resources = ARRAY_SIZE(mxc_usbh1_resources),
  216. };
  217. #ifdef CONFIG_ARCH_MX31
  218. /* USB host 2 */
  219. static u64 usbh2_dmamask = ~(u32)0;
  220. static struct resource mxc_usbh2_resources[] = {
  221. {
  222. .start = MX31_OTG_BASE_ADDR + 0x400,
  223. .end = MX31_OTG_BASE_ADDR + 0x5ff,
  224. .flags = IORESOURCE_MEM,
  225. }, {
  226. .start = MX31_INT_USB2,
  227. .end = MX31_INT_USB2,
  228. .flags = IORESOURCE_IRQ,
  229. },
  230. };
  231. struct platform_device mxc_usbh2 = {
  232. .name = "mxc-ehci",
  233. .id = 2,
  234. .dev = {
  235. .coherent_dma_mask = 0xffffffff,
  236. .dma_mask = &usbh2_dmamask,
  237. },
  238. .resource = mxc_usbh2_resources,
  239. .num_resources = ARRAY_SIZE(mxc_usbh2_resources),
  240. };
  241. #endif
  242. static struct resource imx_wdt_resources[] = {
  243. {
  244. .flags = IORESOURCE_MEM,
  245. },
  246. };
  247. struct platform_device imx_wdt_device0 = {
  248. .name = "imx2-wdt",
  249. .id = 0,
  250. .num_resources = ARRAY_SIZE(imx_wdt_resources),
  251. .resource = imx_wdt_resources,
  252. };
  253. static struct resource imx_rtc_resources[] = {
  254. {
  255. .start = MX31_RTC_BASE_ADDR,
  256. .end = MX31_RTC_BASE_ADDR + 0x3fff,
  257. .flags = IORESOURCE_MEM,
  258. },
  259. {
  260. .start = MX31_INT_RTC,
  261. .flags = IORESOURCE_IRQ,
  262. },
  263. };
  264. struct platform_device imx_rtc_device0 = {
  265. .name = "mxc_rtc",
  266. .id = -1,
  267. .num_resources = ARRAY_SIZE(imx_rtc_resources),
  268. .resource = imx_rtc_resources,
  269. };
  270. static struct resource imx_kpp_resources[] = {
  271. {
  272. .start = MX3x_KPP_BASE_ADDR,
  273. .end = MX3x_KPP_BASE_ADDR + 0xf,
  274. .flags = IORESOURCE_MEM
  275. }, {
  276. .start = MX3x_INT_KPP,
  277. .end = MX3x_INT_KPP,
  278. .flags = IORESOURCE_IRQ,
  279. },
  280. };
  281. struct platform_device imx_kpp_device = {
  282. .name = "imx-keypad",
  283. .id = -1,
  284. .num_resources = ARRAY_SIZE(imx_kpp_resources),
  285. .resource = imx_kpp_resources,
  286. };
  287. static int __init mx3_devices_init(void)
  288. {
  289. #if defined(CONFIG_ARCH_MX31)
  290. if (cpu_is_mx31()) {
  291. imx_wdt_resources[0].start = MX31_WDOG_BASE_ADDR;
  292. imx_wdt_resources[0].end = MX31_WDOG_BASE_ADDR + 0x3fff;
  293. mxc_register_device(&mxc_rnga_device, NULL);
  294. }
  295. #endif
  296. #if defined(CONFIG_ARCH_MX35)
  297. if (cpu_is_mx35()) {
  298. imx_gpio_ports[0].base = MX35_IO_ADDRESS(MX35_GPIO1_BASE_ADDR),
  299. imx_gpio_ports[1].base = MX35_IO_ADDRESS(MX35_GPIO2_BASE_ADDR),
  300. imx_gpio_ports[2].base = MX35_IO_ADDRESS(MX35_GPIO3_BASE_ADDR),
  301. otg_resources[0].start = MX35_OTG_BASE_ADDR;
  302. otg_resources[0].end = MX35_OTG_BASE_ADDR + 0x1ff;
  303. otg_resources[1].start = MX35_INT_USBOTG;
  304. otg_resources[1].end = MX35_INT_USBOTG;
  305. mxc_usbh1_resources[0].start = MX35_OTG_BASE_ADDR + 0x400;
  306. mxc_usbh1_resources[0].end = MX35_OTG_BASE_ADDR + 0x5ff;
  307. mxc_usbh1_resources[1].start = MX35_INT_USBHS;
  308. mxc_usbh1_resources[1].end = MX35_INT_USBHS;
  309. imx_wdt_resources[0].start = MX35_WDOG_BASE_ADDR;
  310. imx_wdt_resources[0].end = MX35_WDOG_BASE_ADDR + 0x3fff;
  311. }
  312. #endif
  313. return 0;
  314. }
  315. subsys_initcall(mx3_devices_init);