devices.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /*
  2. * Copyright 2009 Amit Kucheria <amit.kucheria@canonical.com>
  3. * Copyright (C) 2010 Freescale Semiconductor, Inc.
  4. *
  5. * The code contained herein is licensed under the GNU General Public
  6. * License. You may obtain a copy of the GNU General Public License
  7. * Version 2 or later at the following locations:
  8. *
  9. * http://www.opensource.org/licenses/gpl-license.html
  10. * http://www.gnu.org/copyleft/gpl.html
  11. */
  12. #include <linux/platform_device.h>
  13. #include <linux/dma-mapping.h>
  14. #include <linux/gpio.h>
  15. #include <mach/hardware.h>
  16. #include <mach/imx-uart.h>
  17. #include <mach/irqs.h>
  18. static struct resource mxc_hsi2c_resources[] = {
  19. {
  20. .start = MX51_HSI2C_DMA_BASE_ADDR,
  21. .end = MX51_HSI2C_DMA_BASE_ADDR + SZ_16K - 1,
  22. .flags = IORESOURCE_MEM,
  23. },
  24. {
  25. .start = MX51_MXC_INT_HS_I2C,
  26. .end = MX51_MXC_INT_HS_I2C,
  27. .flags = IORESOURCE_IRQ,
  28. },
  29. };
  30. struct platform_device mxc_hsi2c_device = {
  31. .name = "imx-i2c",
  32. .id = 2,
  33. .num_resources = ARRAY_SIZE(mxc_hsi2c_resources),
  34. .resource = mxc_hsi2c_resources
  35. };
  36. static u64 usb_dma_mask = DMA_BIT_MASK(32);
  37. static struct resource usbotg_resources[] = {
  38. {
  39. .start = MX51_OTG_BASE_ADDR,
  40. .end = MX51_OTG_BASE_ADDR + 0x1ff,
  41. .flags = IORESOURCE_MEM,
  42. },
  43. {
  44. .start = MX51_MXC_INT_USB_OTG,
  45. .flags = IORESOURCE_IRQ,
  46. },
  47. };
  48. /* OTG gadget device */
  49. struct platform_device mxc_usbdr_udc_device = {
  50. .name = "fsl-usb2-udc",
  51. .id = -1,
  52. .num_resources = ARRAY_SIZE(usbotg_resources),
  53. .resource = usbotg_resources,
  54. .dev = {
  55. .dma_mask = &usb_dma_mask,
  56. .coherent_dma_mask = DMA_BIT_MASK(32),
  57. },
  58. };
  59. struct platform_device mxc_usbdr_host_device = {
  60. .name = "mxc-ehci",
  61. .id = 0,
  62. .num_resources = ARRAY_SIZE(usbotg_resources),
  63. .resource = usbotg_resources,
  64. .dev = {
  65. .dma_mask = &usb_dma_mask,
  66. .coherent_dma_mask = DMA_BIT_MASK(32),
  67. },
  68. };
  69. static struct resource usbh1_resources[] = {
  70. {
  71. .start = MX51_OTG_BASE_ADDR + 0x200,
  72. .end = MX51_OTG_BASE_ADDR + 0x200 + 0x1ff,
  73. .flags = IORESOURCE_MEM,
  74. },
  75. {
  76. .start = MX51_MXC_INT_USB_H1,
  77. .flags = IORESOURCE_IRQ,
  78. },
  79. };
  80. struct platform_device mxc_usbh1_device = {
  81. .name = "mxc-ehci",
  82. .id = 1,
  83. .num_resources = ARRAY_SIZE(usbh1_resources),
  84. .resource = usbh1_resources,
  85. .dev = {
  86. .dma_mask = &usb_dma_mask,
  87. .coherent_dma_mask = DMA_BIT_MASK(32),
  88. },
  89. };
  90. static struct resource mxc_wdt_resources[] = {
  91. {
  92. .start = MX51_WDOG_BASE_ADDR,
  93. .end = MX51_WDOG_BASE_ADDR + SZ_16K - 1,
  94. .flags = IORESOURCE_MEM,
  95. },
  96. };
  97. struct platform_device mxc_wdt = {
  98. .name = "imx2-wdt",
  99. .id = 0,
  100. .num_resources = ARRAY_SIZE(mxc_wdt_resources),
  101. .resource = mxc_wdt_resources,
  102. };
  103. static struct resource mxc_kpp_resources[] = {
  104. {
  105. .start = MX51_MXC_INT_KPP,
  106. .end = MX51_MXC_INT_KPP,
  107. .flags = IORESOURCE_IRQ,
  108. } , {
  109. .start = MX51_KPP_BASE_ADDR,
  110. .end = MX51_KPP_BASE_ADDR + 0x8 - 1,
  111. .flags = IORESOURCE_MEM,
  112. },
  113. };
  114. struct platform_device mxc_keypad_device = {
  115. .name = "imx-keypad",
  116. .id = 0,
  117. .num_resources = ARRAY_SIZE(mxc_kpp_resources),
  118. .resource = mxc_kpp_resources,
  119. };
  120. static struct mxc_gpio_port mxc_gpio_ports[] = {
  121. {
  122. .chip.label = "gpio-0",
  123. .base = MX51_IO_ADDRESS(MX51_GPIO1_BASE_ADDR),
  124. .irq = MX51_MXC_INT_GPIO1_LOW,
  125. .irq_high = MX51_MXC_INT_GPIO1_HIGH,
  126. .virtual_irq_start = MXC_GPIO_IRQ_START
  127. },
  128. {
  129. .chip.label = "gpio-1",
  130. .base = MX51_IO_ADDRESS(MX51_GPIO2_BASE_ADDR),
  131. .irq = MX51_MXC_INT_GPIO2_LOW,
  132. .irq_high = MX51_MXC_INT_GPIO2_HIGH,
  133. .virtual_irq_start = MXC_GPIO_IRQ_START + 32 * 1
  134. },
  135. {
  136. .chip.label = "gpio-2",
  137. .base = MX51_IO_ADDRESS(MX51_GPIO3_BASE_ADDR),
  138. .irq = MX51_MXC_INT_GPIO3_LOW,
  139. .irq_high = MX51_MXC_INT_GPIO3_HIGH,
  140. .virtual_irq_start = MXC_GPIO_IRQ_START + 32 * 2
  141. },
  142. {
  143. .chip.label = "gpio-3",
  144. .base = MX51_IO_ADDRESS(MX51_GPIO4_BASE_ADDR),
  145. .irq = MX51_MXC_INT_GPIO4_LOW,
  146. .irq_high = MX51_MXC_INT_GPIO4_HIGH,
  147. .virtual_irq_start = MXC_GPIO_IRQ_START + 32 * 3
  148. },
  149. };
  150. int __init imx51_register_gpios(void)
  151. {
  152. return mxc_gpio_init(mxc_gpio_ports, ARRAY_SIZE(mxc_gpio_ports));
  153. }