devices.c 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. /*
  2. * Author: MontaVista Software, Inc.
  3. * <source@mvista.com>
  4. *
  5. * Based on the OMAP devices.c
  6. *
  7. * 2005 (c) MontaVista Software, Inc. This file is licensed under the
  8. * terms of the GNU General Public License version 2. This program is
  9. * licensed "as is" without any warranty of any kind, whether express
  10. * or implied.
  11. *
  12. * Copyright 2006-2007 Freescale Semiconductor, Inc. All Rights Reserved.
  13. * Copyright 2008 Juergen Beisert, kernel@pengutronix.de
  14. * Copyright 2008 Sascha Hauer, kernel@pengutronix.de
  15. * Copyright (c) 2008 Paulius Zaleckas <paulius.zaleckas@teltonika.lt>
  16. * Copyright (c) 2008 Darius Augulis <darius.augulis@teltonika.lt>
  17. *
  18. * This program is free software; you can redistribute it and/or
  19. * modify it under the terms of the GNU General Public License
  20. * as published by the Free Software Foundation; either version 2
  21. * of the License, or (at your option) any later version.
  22. * This program is distributed in the hope that it will be useful,
  23. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. * GNU General Public License for more details.
  26. *
  27. * You should have received a copy of the GNU General Public License
  28. * along with this program; if not, write to the Free Software
  29. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  30. * MA 02110-1301, USA.
  31. */
  32. #include <linux/module.h>
  33. #include <linux/kernel.h>
  34. #include <linux/init.h>
  35. #include <linux/platform_device.h>
  36. #include <linux/gpio.h>
  37. #include <linux/dma-mapping.h>
  38. #include <linux/serial.h>
  39. #include <mach/irqs.h>
  40. #include <mach/hardware.h>
  41. #include <mach/common.h>
  42. #include <mach/mmc.h>
  43. #include "devices.h"
  44. #if defined(CONFIG_ARCH_MX1)
  45. /* GPIO port description */
  46. static struct mxc_gpio_port imx_gpio_ports[] = {
  47. {
  48. .chip.label = "gpio-0",
  49. .base = MX1_IO_ADDRESS(MX1_GPIO_BASE_ADDR),
  50. .irq = MX1_GPIO_INT_PORTA,
  51. .virtual_irq_start = MXC_GPIO_IRQ_START,
  52. }, {
  53. .chip.label = "gpio-1",
  54. .base = MX1_IO_ADDRESS(MX1_GPIO_BASE_ADDR + 0x100),
  55. .irq = MX1_GPIO_INT_PORTB,
  56. .virtual_irq_start = MXC_GPIO_IRQ_START + 32,
  57. }, {
  58. .chip.label = "gpio-2",
  59. .base = MX1_IO_ADDRESS(MX1_GPIO_BASE_ADDR + 0x200),
  60. .irq = MX1_GPIO_INT_PORTC,
  61. .virtual_irq_start = MXC_GPIO_IRQ_START + 64,
  62. }, {
  63. .chip.label = "gpio-3",
  64. .base = MX1_IO_ADDRESS(MX1_GPIO_BASE_ADDR + 0x300),
  65. .irq = MX1_GPIO_INT_PORTD,
  66. .virtual_irq_start = MXC_GPIO_IRQ_START + 96,
  67. }
  68. };
  69. int __init imx1_register_gpios(void)
  70. {
  71. return mxc_gpio_init(imx_gpio_ports, ARRAY_SIZE(imx_gpio_ports));
  72. }
  73. #endif
  74. #if defined(CONFIG_MACH_MX21) || defined(CONFIG_MACH_MX27)
  75. #ifdef CONFIG_MACH_MX27
  76. static struct resource mx27_camera_resources[] = {
  77. {
  78. .start = MX27_CSI_BASE_ADDR,
  79. .end = MX27_CSI_BASE_ADDR + 0x1f,
  80. .flags = IORESOURCE_MEM,
  81. }, {
  82. .start = MX27_EMMA_PRP_BASE_ADDR,
  83. .end = MX27_EMMA_PRP_BASE_ADDR + 0x1f,
  84. .flags = IORESOURCE_MEM,
  85. }, {
  86. .start = MX27_INT_CSI,
  87. .end = MX27_INT_CSI,
  88. .flags = IORESOURCE_IRQ,
  89. },{
  90. .start = MX27_INT_EMMAPRP,
  91. .end = MX27_INT_EMMAPRP,
  92. .flags = IORESOURCE_IRQ,
  93. },
  94. };
  95. struct platform_device mx27_camera_device = {
  96. .name = "mx2-camera",
  97. .id = 0,
  98. .num_resources = ARRAY_SIZE(mx27_camera_resources),
  99. .resource = mx27_camera_resources,
  100. .dev = {
  101. .coherent_dma_mask = 0xffffffff,
  102. },
  103. };
  104. #endif
  105. /* Watchdog: i.MX1 has seperate driver, i.MX21 and i.MX27 are equal */
  106. static struct resource mxc_wdt_resources[] = {
  107. {
  108. .start = MX2x_WDOG_BASE_ADDR,
  109. .end = MX2x_WDOG_BASE_ADDR + SZ_4K - 1,
  110. .flags = IORESOURCE_MEM,
  111. },
  112. };
  113. struct platform_device mxc_wdt = {
  114. .name = "imx2-wdt",
  115. .id = 0,
  116. .num_resources = ARRAY_SIZE(mxc_wdt_resources),
  117. .resource = mxc_wdt_resources,
  118. };
  119. /*
  120. * lcdc:
  121. * - i.MX1: the basic controller
  122. * - i.MX21: to be checked
  123. * - i.MX27: like i.MX1, with slightly variations
  124. */
  125. static struct resource mxc_fb[] = {
  126. {
  127. .start = MX2x_LCDC_BASE_ADDR,
  128. .end = MX2x_LCDC_BASE_ADDR + SZ_4K - 1,
  129. .flags = IORESOURCE_MEM,
  130. }, {
  131. .start = MX2x_INT_LCDC,
  132. .end = MX2x_INT_LCDC,
  133. .flags = IORESOURCE_IRQ,
  134. }
  135. };
  136. /* mxc lcd driver */
  137. struct platform_device mxc_fb_device = {
  138. .name = "imx-fb",
  139. .id = 0,
  140. .num_resources = ARRAY_SIZE(mxc_fb),
  141. .resource = mxc_fb,
  142. .dev = {
  143. .coherent_dma_mask = DMA_BIT_MASK(32),
  144. },
  145. };
  146. static struct resource mxc_pwm_resources[] = {
  147. {
  148. .start = MX2x_PWM_BASE_ADDR,
  149. .end = MX2x_PWM_BASE_ADDR + SZ_4K - 1,
  150. .flags = IORESOURCE_MEM,
  151. }, {
  152. .start = MX2x_INT_PWM,
  153. .end = MX2x_INT_PWM,
  154. .flags = IORESOURCE_IRQ,
  155. }
  156. };
  157. struct platform_device mxc_pwm_device = {
  158. .name = "mxc_pwm",
  159. .id = 0,
  160. .num_resources = ARRAY_SIZE(mxc_pwm_resources),
  161. .resource = mxc_pwm_resources,
  162. };
  163. #define DEFINE_MXC_MMC_DEVICE(n, baseaddr, irq, dmareq) \
  164. static struct resource mxc_sdhc_resources ## n[] = { \
  165. { \
  166. .start = baseaddr, \
  167. .end = baseaddr + SZ_4K - 1, \
  168. .flags = IORESOURCE_MEM, \
  169. }, { \
  170. .start = irq, \
  171. .end = irq, \
  172. .flags = IORESOURCE_IRQ, \
  173. }, { \
  174. .start = dmareq, \
  175. .end = dmareq, \
  176. .flags = IORESOURCE_DMA, \
  177. }, \
  178. }; \
  179. \
  180. static u64 mxc_sdhc ## n ## _dmamask = DMA_BIT_MASK(32); \
  181. \
  182. struct platform_device mxc_sdhc_device ## n = { \
  183. .name = "mxc-mmc", \
  184. .id = n, \
  185. .dev = { \
  186. .dma_mask = &mxc_sdhc ## n ## _dmamask, \
  187. .coherent_dma_mask = DMA_BIT_MASK(32), \
  188. }, \
  189. .num_resources = ARRAY_SIZE(mxc_sdhc_resources ## n), \
  190. .resource = mxc_sdhc_resources ## n, \
  191. }
  192. DEFINE_MXC_MMC_DEVICE(0, MX2x_SDHC1_BASE_ADDR, MX2x_INT_SDHC1, MX2x_DMA_REQ_SDHC1);
  193. DEFINE_MXC_MMC_DEVICE(1, MX2x_SDHC2_BASE_ADDR, MX2x_INT_SDHC2, MX2x_DMA_REQ_SDHC2);
  194. #ifdef CONFIG_MACH_MX27
  195. static struct resource otg_resources[] = {
  196. {
  197. .start = MX27_USBOTG_BASE_ADDR,
  198. .end = MX27_USBOTG_BASE_ADDR + 0x1ff,
  199. .flags = IORESOURCE_MEM,
  200. }, {
  201. .start = MX27_INT_USB3,
  202. .end = MX27_INT_USB3,
  203. .flags = IORESOURCE_IRQ,
  204. },
  205. };
  206. static u64 otg_dmamask = DMA_BIT_MASK(32);
  207. /* OTG gadget device */
  208. struct platform_device mxc_otg_udc_device = {
  209. .name = "fsl-usb2-udc",
  210. .id = -1,
  211. .dev = {
  212. .dma_mask = &otg_dmamask,
  213. .coherent_dma_mask = DMA_BIT_MASK(32),
  214. },
  215. .resource = otg_resources,
  216. .num_resources = ARRAY_SIZE(otg_resources),
  217. };
  218. /* OTG host */
  219. struct platform_device mxc_otg_host = {
  220. .name = "mxc-ehci",
  221. .id = 0,
  222. .dev = {
  223. .coherent_dma_mask = DMA_BIT_MASK(32),
  224. .dma_mask = &otg_dmamask,
  225. },
  226. .resource = otg_resources,
  227. .num_resources = ARRAY_SIZE(otg_resources),
  228. };
  229. /* USB host 1 */
  230. static u64 usbh1_dmamask = DMA_BIT_MASK(32);
  231. static struct resource mxc_usbh1_resources[] = {
  232. {
  233. .start = MX27_USBOTG_BASE_ADDR + 0x200,
  234. .end = MX27_USBOTG_BASE_ADDR + 0x3ff,
  235. .flags = IORESOURCE_MEM,
  236. }, {
  237. .start = MX27_INT_USB1,
  238. .end = MX27_INT_USB1,
  239. .flags = IORESOURCE_IRQ,
  240. },
  241. };
  242. struct platform_device mxc_usbh1 = {
  243. .name = "mxc-ehci",
  244. .id = 1,
  245. .dev = {
  246. .coherent_dma_mask = DMA_BIT_MASK(32),
  247. .dma_mask = &usbh1_dmamask,
  248. },
  249. .resource = mxc_usbh1_resources,
  250. .num_resources = ARRAY_SIZE(mxc_usbh1_resources),
  251. };
  252. /* USB host 2 */
  253. static u64 usbh2_dmamask = DMA_BIT_MASK(32);
  254. static struct resource mxc_usbh2_resources[] = {
  255. {
  256. .start = MX27_USBOTG_BASE_ADDR + 0x400,
  257. .end = MX27_USBOTG_BASE_ADDR + 0x5ff,
  258. .flags = IORESOURCE_MEM,
  259. }, {
  260. .start = MX27_INT_USB2,
  261. .end = MX27_INT_USB2,
  262. .flags = IORESOURCE_IRQ,
  263. },
  264. };
  265. struct platform_device mxc_usbh2 = {
  266. .name = "mxc-ehci",
  267. .id = 2,
  268. .dev = {
  269. .coherent_dma_mask = DMA_BIT_MASK(32),
  270. .dma_mask = &usbh2_dmamask,
  271. },
  272. .resource = mxc_usbh2_resources,
  273. .num_resources = ARRAY_SIZE(mxc_usbh2_resources),
  274. };
  275. #endif
  276. /* GPIO port description */
  277. #define DEFINE_MXC_GPIO_PORT_IRQ(SOC, n, _irq) \
  278. { \
  279. .chip.label = "gpio-" #n, \
  280. .irq = _irq, \
  281. .base = SOC ## _IO_ADDRESS(MX2x_GPIO_BASE_ADDR + \
  282. n * 0x100), \
  283. .virtual_irq_start = MXC_GPIO_IRQ_START + n * 32, \
  284. }
  285. #define DEFINE_MXC_GPIO_PORT(SOC, n) \
  286. { \
  287. .chip.label = "gpio-" #n, \
  288. .base = SOC ## _IO_ADDRESS(MX2x_GPIO_BASE_ADDR + \
  289. n * 0x100), \
  290. .virtual_irq_start = MXC_GPIO_IRQ_START + n * 32, \
  291. }
  292. #define DEFINE_MXC_GPIO_PORTS(SOC, pfx) \
  293. static struct mxc_gpio_port pfx ## _gpio_ports[] = { \
  294. DEFINE_MXC_GPIO_PORT_IRQ(SOC, 0, SOC ## _INT_GPIO), \
  295. DEFINE_MXC_GPIO_PORT(SOC, 1), \
  296. DEFINE_MXC_GPIO_PORT(SOC, 2), \
  297. DEFINE_MXC_GPIO_PORT(SOC, 3), \
  298. DEFINE_MXC_GPIO_PORT(SOC, 4), \
  299. DEFINE_MXC_GPIO_PORT(SOC, 5), \
  300. }
  301. #ifdef CONFIG_MACH_MX21
  302. DEFINE_MXC_GPIO_PORTS(MX21, imx21);
  303. int __init imx21_register_gpios(void)
  304. {
  305. return mxc_gpio_init(imx21_gpio_ports, ARRAY_SIZE(imx21_gpio_ports));
  306. }
  307. #endif
  308. #ifdef CONFIG_MACH_MX27
  309. DEFINE_MXC_GPIO_PORTS(MX27, imx27);
  310. int __init imx27_register_gpios(void)
  311. {
  312. return mxc_gpio_init(imx27_gpio_ports, ARRAY_SIZE(imx27_gpio_ports));
  313. }
  314. #endif
  315. #ifdef CONFIG_MACH_MX21
  316. static struct resource mx21_usbhc_resources[] = {
  317. {
  318. .start = MX21_USBOTG_BASE_ADDR,
  319. .end = MX21_USBOTG_BASE_ADDR + SZ_8K - 1,
  320. .flags = IORESOURCE_MEM,
  321. },
  322. {
  323. .start = MX21_INT_USBHOST,
  324. .end = MX21_INT_USBHOST,
  325. .flags = IORESOURCE_IRQ,
  326. },
  327. };
  328. struct platform_device mx21_usbhc_device = {
  329. .name = "imx21-hcd",
  330. .id = 0,
  331. .dev = {
  332. .dma_mask = &mx21_usbhc_device.dev.coherent_dma_mask,
  333. .coherent_dma_mask = DMA_BIT_MASK(32),
  334. },
  335. .num_resources = ARRAY_SIZE(mx21_usbhc_resources),
  336. .resource = mx21_usbhc_resources,
  337. };
  338. #endif
  339. static struct resource imx_kpp_resources[] = {
  340. {
  341. .start = MX2x_KPP_BASE_ADDR,
  342. .end = MX2x_KPP_BASE_ADDR + 0xf,
  343. .flags = IORESOURCE_MEM
  344. }, {
  345. .start = MX2x_INT_KPP,
  346. .end = MX2x_INT_KPP,
  347. .flags = IORESOURCE_IRQ,
  348. },
  349. };
  350. struct platform_device imx_kpp_device = {
  351. .name = "imx-keypad",
  352. .id = -1,
  353. .num_resources = ARRAY_SIZE(imx_kpp_resources),
  354. .resource = imx_kpp_resources,
  355. };
  356. #endif