devices.c 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  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. #ifdef CONFIG_ARCH_MX31
  30. static struct resource rnga_resources[] = {
  31. {
  32. .start = MX3x_RNGA_BASE_ADDR,
  33. .end = MX3x_RNGA_BASE_ADDR + 0x28,
  34. .flags = IORESOURCE_MEM,
  35. },
  36. };
  37. struct platform_device mxc_rnga_device = {
  38. .name = "mxc_rnga",
  39. .id = -1,
  40. .num_resources = 1,
  41. .resource = rnga_resources,
  42. };
  43. #endif /* CONFIG_ARCH_MX31 */
  44. /* i.MX31 Image Processing Unit */
  45. /* The resource order is important! */
  46. static struct resource mx3_ipu_rsrc[] = {
  47. {
  48. .start = MX3x_IPU_CTRL_BASE_ADDR,
  49. .end = MX3x_IPU_CTRL_BASE_ADDR + 0x5F,
  50. .flags = IORESOURCE_MEM,
  51. }, {
  52. .start = MX3x_IPU_CTRL_BASE_ADDR + 0x88,
  53. .end = MX3x_IPU_CTRL_BASE_ADDR + 0xB3,
  54. .flags = IORESOURCE_MEM,
  55. }, {
  56. .start = MX3x_INT_IPU_SYN,
  57. .end = MX3x_INT_IPU_SYN,
  58. .flags = IORESOURCE_IRQ,
  59. }, {
  60. .start = MX3x_INT_IPU_ERR,
  61. .end = MX3x_INT_IPU_ERR,
  62. .flags = IORESOURCE_IRQ,
  63. },
  64. };
  65. struct platform_device mx3_ipu = {
  66. .name = "ipu-core",
  67. .id = -1,
  68. .num_resources = ARRAY_SIZE(mx3_ipu_rsrc),
  69. .resource = mx3_ipu_rsrc,
  70. };
  71. static struct resource fb_resources[] = {
  72. {
  73. .start = MX3x_IPU_CTRL_BASE_ADDR + 0xB4,
  74. .end = MX3x_IPU_CTRL_BASE_ADDR + 0x1BF,
  75. .flags = IORESOURCE_MEM,
  76. },
  77. };
  78. struct platform_device mx3_fb = {
  79. .name = "mx3_sdc_fb",
  80. .id = -1,
  81. .num_resources = ARRAY_SIZE(fb_resources),
  82. .resource = fb_resources,
  83. .dev = {
  84. .coherent_dma_mask = DMA_BIT_MASK(32),
  85. },
  86. };
  87. static struct resource camera_resources[] = {
  88. {
  89. .start = MX3x_IPU_CTRL_BASE_ADDR + 0x60,
  90. .end = MX3x_IPU_CTRL_BASE_ADDR + 0x87,
  91. .flags = IORESOURCE_MEM,
  92. },
  93. };
  94. struct platform_device mx3_camera = {
  95. .name = "mx3-camera",
  96. .id = 0,
  97. .num_resources = ARRAY_SIZE(camera_resources),
  98. .resource = camera_resources,
  99. .dev = {
  100. .coherent_dma_mask = DMA_BIT_MASK(32),
  101. },
  102. };
  103. static struct resource otg_resources[] = {
  104. {
  105. .start = MX31_OTG_BASE_ADDR,
  106. .end = MX31_OTG_BASE_ADDR + 0x1ff,
  107. .flags = IORESOURCE_MEM,
  108. }, {
  109. .start = MX31_INT_USB3,
  110. .end = MX31_INT_USB3,
  111. .flags = IORESOURCE_IRQ,
  112. },
  113. };
  114. static u64 otg_dmamask = DMA_BIT_MASK(32);
  115. /* OTG gadget device */
  116. struct platform_device mxc_otg_udc_device = {
  117. .name = "fsl-usb2-udc",
  118. .id = -1,
  119. .dev = {
  120. .dma_mask = &otg_dmamask,
  121. .coherent_dma_mask = DMA_BIT_MASK(32),
  122. },
  123. .resource = otg_resources,
  124. .num_resources = ARRAY_SIZE(otg_resources),
  125. };
  126. /* OTG host */
  127. struct platform_device mxc_otg_host = {
  128. .name = "mxc-ehci",
  129. .id = 0,
  130. .dev = {
  131. .coherent_dma_mask = 0xffffffff,
  132. .dma_mask = &otg_dmamask,
  133. },
  134. .resource = otg_resources,
  135. .num_resources = ARRAY_SIZE(otg_resources),
  136. };
  137. /* USB host 1 */
  138. static u64 usbh1_dmamask = ~(u32)0;
  139. static struct resource mxc_usbh1_resources[] = {
  140. {
  141. .start = MX31_OTG_BASE_ADDR + 0x200,
  142. .end = MX31_OTG_BASE_ADDR + 0x3ff,
  143. .flags = IORESOURCE_MEM,
  144. }, {
  145. .start = MX31_INT_USB1,
  146. .end = MX31_INT_USB1,
  147. .flags = IORESOURCE_IRQ,
  148. },
  149. };
  150. struct platform_device mxc_usbh1 = {
  151. .name = "mxc-ehci",
  152. .id = 1,
  153. .dev = {
  154. .coherent_dma_mask = 0xffffffff,
  155. .dma_mask = &usbh1_dmamask,
  156. },
  157. .resource = mxc_usbh1_resources,
  158. .num_resources = ARRAY_SIZE(mxc_usbh1_resources),
  159. };
  160. #ifdef CONFIG_ARCH_MX31
  161. /* USB host 2 */
  162. static u64 usbh2_dmamask = ~(u32)0;
  163. static struct resource mxc_usbh2_resources[] = {
  164. {
  165. .start = MX31_OTG_BASE_ADDR + 0x400,
  166. .end = MX31_OTG_BASE_ADDR + 0x5ff,
  167. .flags = IORESOURCE_MEM,
  168. }, {
  169. .start = MX31_INT_USB2,
  170. .end = MX31_INT_USB2,
  171. .flags = IORESOURCE_IRQ,
  172. },
  173. };
  174. struct platform_device mxc_usbh2 = {
  175. .name = "mxc-ehci",
  176. .id = 2,
  177. .dev = {
  178. .coherent_dma_mask = 0xffffffff,
  179. .dma_mask = &usbh2_dmamask,
  180. },
  181. .resource = mxc_usbh2_resources,
  182. .num_resources = ARRAY_SIZE(mxc_usbh2_resources),
  183. };
  184. #endif
  185. static struct resource imx_wdt_resources[] = {
  186. {
  187. .flags = IORESOURCE_MEM,
  188. },
  189. };
  190. struct platform_device imx_wdt_device0 = {
  191. .name = "imx2-wdt",
  192. .id = 0,
  193. .num_resources = ARRAY_SIZE(imx_wdt_resources),
  194. .resource = imx_wdt_resources,
  195. };
  196. static struct resource imx_rtc_resources[] = {
  197. {
  198. .start = MX31_RTC_BASE_ADDR,
  199. .end = MX31_RTC_BASE_ADDR + 0x3fff,
  200. .flags = IORESOURCE_MEM,
  201. },
  202. {
  203. .start = MX31_INT_RTC,
  204. .flags = IORESOURCE_IRQ,
  205. },
  206. };
  207. struct platform_device imx_rtc_device0 = {
  208. .name = "mxc_rtc",
  209. .id = -1,
  210. .num_resources = ARRAY_SIZE(imx_rtc_resources),
  211. .resource = imx_rtc_resources,
  212. };
  213. static struct resource imx_kpp_resources[] = {
  214. {
  215. .start = MX3x_KPP_BASE_ADDR,
  216. .end = MX3x_KPP_BASE_ADDR + 0xf,
  217. .flags = IORESOURCE_MEM
  218. }, {
  219. .start = MX3x_INT_KPP,
  220. .end = MX3x_INT_KPP,
  221. .flags = IORESOURCE_IRQ,
  222. },
  223. };
  224. struct platform_device imx_kpp_device = {
  225. .name = "imx-keypad",
  226. .id = -1,
  227. .num_resources = ARRAY_SIZE(imx_kpp_resources),
  228. .resource = imx_kpp_resources,
  229. };
  230. static int __init mx3_devices_init(void)
  231. {
  232. #if defined(CONFIG_ARCH_MX31)
  233. if (cpu_is_mx31()) {
  234. imx_wdt_resources[0].start = MX31_WDOG_BASE_ADDR;
  235. imx_wdt_resources[0].end = MX31_WDOG_BASE_ADDR + 0x3fff;
  236. mxc_register_device(&mxc_rnga_device, NULL);
  237. }
  238. #endif
  239. #if defined(CONFIG_ARCH_MX35)
  240. if (cpu_is_mx35()) {
  241. otg_resources[0].start = MX35_OTG_BASE_ADDR;
  242. otg_resources[0].end = MX35_OTG_BASE_ADDR + 0x1ff;
  243. otg_resources[1].start = MX35_INT_USBOTG;
  244. otg_resources[1].end = MX35_INT_USBOTG;
  245. mxc_usbh1_resources[0].start = MX35_OTG_BASE_ADDR + 0x400;
  246. mxc_usbh1_resources[0].end = MX35_OTG_BASE_ADDR + 0x5ff;
  247. mxc_usbh1_resources[1].start = MX35_INT_USBHS;
  248. mxc_usbh1_resources[1].end = MX35_INT_USBHS;
  249. imx_wdt_resources[0].start = MX35_WDOG_BASE_ADDR;
  250. imx_wdt_resources[0].end = MX35_WDOG_BASE_ADDR + 0x3fff;
  251. }
  252. #endif
  253. return 0;
  254. }
  255. subsys_initcall(mx3_devices_init);