devices.c 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  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. #if defined(CONFIG_ARCH_MX35)
  254. static struct resource mxc_fec_resources[] = {
  255. {
  256. .start = MXC_FEC_BASE_ADDR,
  257. .end = MXC_FEC_BASE_ADDR + 0xfff,
  258. .flags = IORESOURCE_MEM,
  259. }, {
  260. .start = MXC_INT_FEC,
  261. .end = MXC_INT_FEC,
  262. .flags = IORESOURCE_IRQ,
  263. },
  264. };
  265. struct platform_device mxc_fec_device = {
  266. .name = "fec",
  267. .id = 0,
  268. .num_resources = ARRAY_SIZE(mxc_fec_resources),
  269. .resource = mxc_fec_resources,
  270. };
  271. #endif
  272. static struct resource imx_ssi_resources0[] = {
  273. {
  274. .start = SSI1_BASE_ADDR,
  275. .end = SSI1_BASE_ADDR + 0xfff,
  276. .flags = IORESOURCE_MEM,
  277. }, {
  278. .start = MX31_INT_SSI1,
  279. .end = MX31_INT_SSI1,
  280. .flags = IORESOURCE_IRQ,
  281. },
  282. };
  283. static struct resource imx_ssi_resources1[] = {
  284. {
  285. .start = SSI2_BASE_ADDR,
  286. .end = SSI2_BASE_ADDR + 0xfff,
  287. .flags = IORESOURCE_MEM
  288. }, {
  289. .start = MX31_INT_SSI2,
  290. .end = MX31_INT_SSI2,
  291. .flags = IORESOURCE_IRQ,
  292. },
  293. };
  294. struct platform_device imx_ssi_device0 = {
  295. .name = "imx-ssi",
  296. .id = 0,
  297. .num_resources = ARRAY_SIZE(imx_ssi_resources0),
  298. .resource = imx_ssi_resources0,
  299. };
  300. struct platform_device imx_ssi_device1 = {
  301. .name = "imx-ssi",
  302. .id = 1,
  303. .num_resources = ARRAY_SIZE(imx_ssi_resources1),
  304. .resource = imx_ssi_resources1,
  305. };
  306. static struct resource imx_wdt_resources[] = {
  307. {
  308. .flags = IORESOURCE_MEM,
  309. },
  310. };
  311. struct platform_device imx_wdt_device0 = {
  312. .name = "imx2-wdt",
  313. .id = 0,
  314. .num_resources = ARRAY_SIZE(imx_wdt_resources),
  315. .resource = imx_wdt_resources,
  316. };
  317. static struct resource imx_rtc_resources[] = {
  318. {
  319. .start = MX31_RTC_BASE_ADDR,
  320. .end = MX31_RTC_BASE_ADDR + 0x3fff,
  321. .flags = IORESOURCE_MEM,
  322. },
  323. {
  324. .start = MX31_INT_RTC,
  325. .flags = IORESOURCE_IRQ,
  326. },
  327. };
  328. struct platform_device imx_rtc_device0 = {
  329. .name = "mxc_rtc",
  330. .id = -1,
  331. .num_resources = ARRAY_SIZE(imx_rtc_resources),
  332. .resource = imx_rtc_resources,
  333. };
  334. static struct resource imx_kpp_resources[] = {
  335. {
  336. .start = MX3x_KPP_BASE_ADDR,
  337. .end = MX3x_KPP_BASE_ADDR + 0xf,
  338. .flags = IORESOURCE_MEM
  339. }, {
  340. .start = MX3x_INT_KPP,
  341. .end = MX3x_INT_KPP,
  342. .flags = IORESOURCE_IRQ,
  343. },
  344. };
  345. struct platform_device imx_kpp_device = {
  346. .name = "imx-keypad",
  347. .id = -1,
  348. .num_resources = ARRAY_SIZE(imx_kpp_resources),
  349. .resource = imx_kpp_resources,
  350. };
  351. static int __init mx3_devices_init(void)
  352. {
  353. #if defined(CONFIG_ARCH_MX31)
  354. if (cpu_is_mx31()) {
  355. imx_wdt_resources[0].start = MX31_WDOG_BASE_ADDR;
  356. imx_wdt_resources[0].end = MX31_WDOG_BASE_ADDR + 0x3fff;
  357. mxc_register_device(&mxc_rnga_device, NULL);
  358. }
  359. #endif
  360. #if defined(CONFIG_ARCH_MX35)
  361. if (cpu_is_mx35()) {
  362. otg_resources[0].start = MX35_OTG_BASE_ADDR;
  363. otg_resources[0].end = MX35_OTG_BASE_ADDR + 0x1ff;
  364. otg_resources[1].start = MXC_INT_USBOTG;
  365. otg_resources[1].end = MXC_INT_USBOTG;
  366. mxc_usbh1_resources[0].start = MX35_OTG_BASE_ADDR + 0x400;
  367. mxc_usbh1_resources[0].end = MX35_OTG_BASE_ADDR + 0x5ff;
  368. mxc_usbh1_resources[1].start = MXC_INT_USBHS;
  369. mxc_usbh1_resources[1].end = MXC_INT_USBHS;
  370. imx_ssi_resources0[1].start = MX35_INT_SSI1;
  371. imx_ssi_resources0[1].end = MX35_INT_SSI1;
  372. imx_ssi_resources1[1].start = MX35_INT_SSI2;
  373. imx_ssi_resources1[1].end = MX35_INT_SSI2;
  374. imx_wdt_resources[0].start = MX35_WDOG_BASE_ADDR;
  375. imx_wdt_resources[0].end = MX35_WDOG_BASE_ADDR + 0x3fff;
  376. }
  377. #endif
  378. return 0;
  379. }
  380. subsys_initcall(mx3_devices_init);