devices.c 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  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. #ifdef CONFIG_MACH_MX27
  75. static struct resource otg_resources[] = {
  76. {
  77. .start = MX27_USBOTG_BASE_ADDR,
  78. .end = MX27_USBOTG_BASE_ADDR + 0x1ff,
  79. .flags = IORESOURCE_MEM,
  80. }, {
  81. .start = MX27_INT_USB3,
  82. .end = MX27_INT_USB3,
  83. .flags = IORESOURCE_IRQ,
  84. },
  85. };
  86. static u64 otg_dmamask = DMA_BIT_MASK(32);
  87. /* OTG gadget device */
  88. struct platform_device mxc_otg_udc_device = {
  89. .name = "fsl-usb2-udc",
  90. .id = -1,
  91. .dev = {
  92. .dma_mask = &otg_dmamask,
  93. .coherent_dma_mask = DMA_BIT_MASK(32),
  94. },
  95. .resource = otg_resources,
  96. .num_resources = ARRAY_SIZE(otg_resources),
  97. };
  98. /* OTG host */
  99. struct platform_device mxc_otg_host = {
  100. .name = "mxc-ehci",
  101. .id = 0,
  102. .dev = {
  103. .coherent_dma_mask = DMA_BIT_MASK(32),
  104. .dma_mask = &otg_dmamask,
  105. },
  106. .resource = otg_resources,
  107. .num_resources = ARRAY_SIZE(otg_resources),
  108. };
  109. /* USB host 1 */
  110. static u64 usbh1_dmamask = DMA_BIT_MASK(32);
  111. static struct resource mxc_usbh1_resources[] = {
  112. {
  113. .start = MX27_USBOTG_BASE_ADDR + 0x200,
  114. .end = MX27_USBOTG_BASE_ADDR + 0x3ff,
  115. .flags = IORESOURCE_MEM,
  116. }, {
  117. .start = MX27_INT_USB1,
  118. .end = MX27_INT_USB1,
  119. .flags = IORESOURCE_IRQ,
  120. },
  121. };
  122. struct platform_device mxc_usbh1 = {
  123. .name = "mxc-ehci",
  124. .id = 1,
  125. .dev = {
  126. .coherent_dma_mask = DMA_BIT_MASK(32),
  127. .dma_mask = &usbh1_dmamask,
  128. },
  129. .resource = mxc_usbh1_resources,
  130. .num_resources = ARRAY_SIZE(mxc_usbh1_resources),
  131. };
  132. /* USB host 2 */
  133. static u64 usbh2_dmamask = DMA_BIT_MASK(32);
  134. static struct resource mxc_usbh2_resources[] = {
  135. {
  136. .start = MX27_USBOTG_BASE_ADDR + 0x400,
  137. .end = MX27_USBOTG_BASE_ADDR + 0x5ff,
  138. .flags = IORESOURCE_MEM,
  139. }, {
  140. .start = MX27_INT_USB2,
  141. .end = MX27_INT_USB2,
  142. .flags = IORESOURCE_IRQ,
  143. },
  144. };
  145. struct platform_device mxc_usbh2 = {
  146. .name = "mxc-ehci",
  147. .id = 2,
  148. .dev = {
  149. .coherent_dma_mask = DMA_BIT_MASK(32),
  150. .dma_mask = &usbh2_dmamask,
  151. },
  152. .resource = mxc_usbh2_resources,
  153. .num_resources = ARRAY_SIZE(mxc_usbh2_resources),
  154. };
  155. #endif
  156. #if defined(CONFIG_MACH_MX21) || defined(CONFIG_MACH_MX27)
  157. /* GPIO port description */
  158. #define DEFINE_MXC_GPIO_PORT_IRQ(SOC, n, _irq) \
  159. { \
  160. .chip.label = "gpio-" #n, \
  161. .irq = _irq, \
  162. .base = SOC ## _IO_ADDRESS(MX2x_GPIO_BASE_ADDR + \
  163. n * 0x100), \
  164. .virtual_irq_start = MXC_GPIO_IRQ_START + n * 32, \
  165. }
  166. #define DEFINE_MXC_GPIO_PORT(SOC, n) \
  167. { \
  168. .chip.label = "gpio-" #n, \
  169. .base = SOC ## _IO_ADDRESS(MX2x_GPIO_BASE_ADDR + \
  170. n * 0x100), \
  171. .virtual_irq_start = MXC_GPIO_IRQ_START + n * 32, \
  172. }
  173. #define DEFINE_MXC_GPIO_PORTS(SOC, pfx) \
  174. static struct mxc_gpio_port pfx ## _gpio_ports[] = { \
  175. DEFINE_MXC_GPIO_PORT_IRQ(SOC, 0, SOC ## _INT_GPIO), \
  176. DEFINE_MXC_GPIO_PORT(SOC, 1), \
  177. DEFINE_MXC_GPIO_PORT(SOC, 2), \
  178. DEFINE_MXC_GPIO_PORT(SOC, 3), \
  179. DEFINE_MXC_GPIO_PORT(SOC, 4), \
  180. DEFINE_MXC_GPIO_PORT(SOC, 5), \
  181. }
  182. #ifdef CONFIG_MACH_MX21
  183. DEFINE_MXC_GPIO_PORTS(MX21, imx21);
  184. int __init imx21_register_gpios(void)
  185. {
  186. return mxc_gpio_init(imx21_gpio_ports, ARRAY_SIZE(imx21_gpio_ports));
  187. }
  188. #endif
  189. #ifdef CONFIG_MACH_MX27
  190. DEFINE_MXC_GPIO_PORTS(MX27, imx27);
  191. int __init imx27_register_gpios(void)
  192. {
  193. return mxc_gpio_init(imx27_gpio_ports, ARRAY_SIZE(imx27_gpio_ports));
  194. }
  195. #endif
  196. #ifdef CONFIG_MACH_MX21
  197. static struct resource mx21_usbhc_resources[] = {
  198. {
  199. .start = MX21_USBOTG_BASE_ADDR,
  200. .end = MX21_USBOTG_BASE_ADDR + SZ_8K - 1,
  201. .flags = IORESOURCE_MEM,
  202. },
  203. {
  204. .start = MX21_INT_USBHOST,
  205. .end = MX21_INT_USBHOST,
  206. .flags = IORESOURCE_IRQ,
  207. },
  208. };
  209. struct platform_device mx21_usbhc_device = {
  210. .name = "imx21-hcd",
  211. .id = 0,
  212. .dev = {
  213. .dma_mask = &mx21_usbhc_device.dev.coherent_dma_mask,
  214. .coherent_dma_mask = DMA_BIT_MASK(32),
  215. },
  216. .num_resources = ARRAY_SIZE(mx21_usbhc_resources),
  217. .resource = mx21_usbhc_resources,
  218. };
  219. #endif
  220. static struct resource imx_kpp_resources[] = {
  221. {
  222. .start = MX2x_KPP_BASE_ADDR,
  223. .end = MX2x_KPP_BASE_ADDR + 0xf,
  224. .flags = IORESOURCE_MEM
  225. }, {
  226. .start = MX2x_INT_KPP,
  227. .end = MX2x_INT_KPP,
  228. .flags = IORESOURCE_IRQ,
  229. },
  230. };
  231. struct platform_device imx_kpp_device = {
  232. .name = "imx-keypad",
  233. .id = -1,
  234. .num_resources = ARRAY_SIZE(imx_kpp_resources),
  235. .resource = imx_kpp_resources,
  236. };
  237. #endif