devices.c 8.2 KB

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