gpio16xx.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. /*
  2. * OMAP16xx specific gpio init
  3. *
  4. * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
  5. *
  6. * Author:
  7. * Charulatha V <charu@ti.com>
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License as
  11. * published by the Free Software Foundation version 2.
  12. *
  13. * This program is distributed "as is" WITHOUT ANY WARRANTY of any
  14. * kind, whether express or implied; without even the implied warranty
  15. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. */
  18. #include <linux/gpio.h>
  19. #define OMAP1610_GPIO1_BASE 0xfffbe400
  20. #define OMAP1610_GPIO2_BASE 0xfffbec00
  21. #define OMAP1610_GPIO3_BASE 0xfffbb400
  22. #define OMAP1610_GPIO4_BASE 0xfffbbc00
  23. #define OMAP1_MPUIO_VBASE OMAP1_MPUIO_BASE
  24. /* mpu gpio */
  25. static struct __initdata resource omap16xx_mpu_gpio_resources[] = {
  26. {
  27. .start = OMAP1_MPUIO_VBASE,
  28. .end = OMAP1_MPUIO_VBASE + SZ_2K - 1,
  29. .flags = IORESOURCE_MEM,
  30. },
  31. {
  32. .start = INT_MPUIO,
  33. .flags = IORESOURCE_IRQ,
  34. },
  35. };
  36. static struct __initdata omap_gpio_platform_data omap16xx_mpu_gpio_config = {
  37. .virtual_irq_start = IH_MPUIO_BASE,
  38. .bank_type = METHOD_MPUIO,
  39. .bank_width = 16,
  40. .bank_stride = 1,
  41. };
  42. static struct platform_device omap16xx_mpu_gpio = {
  43. .name = "omap_gpio",
  44. .id = 0,
  45. .dev = {
  46. .platform_data = &omap16xx_mpu_gpio_config,
  47. },
  48. .num_resources = ARRAY_SIZE(omap16xx_mpu_gpio_resources),
  49. .resource = omap16xx_mpu_gpio_resources,
  50. };
  51. /* gpio1 */
  52. static struct __initdata resource omap16xx_gpio1_resources[] = {
  53. {
  54. .start = OMAP1610_GPIO1_BASE,
  55. .end = OMAP1610_GPIO1_BASE + SZ_2K - 1,
  56. .flags = IORESOURCE_MEM,
  57. },
  58. {
  59. .start = INT_GPIO_BANK1,
  60. .flags = IORESOURCE_IRQ,
  61. },
  62. };
  63. static struct __initdata omap_gpio_platform_data omap16xx_gpio1_config = {
  64. .virtual_irq_start = IH_GPIO_BASE,
  65. .bank_type = METHOD_GPIO_1610,
  66. .bank_width = 16,
  67. };
  68. static struct platform_device omap16xx_gpio1 = {
  69. .name = "omap_gpio",
  70. .id = 1,
  71. .dev = {
  72. .platform_data = &omap16xx_gpio1_config,
  73. },
  74. .num_resources = ARRAY_SIZE(omap16xx_gpio1_resources),
  75. .resource = omap16xx_gpio1_resources,
  76. };
  77. /* gpio2 */
  78. static struct __initdata resource omap16xx_gpio2_resources[] = {
  79. {
  80. .start = OMAP1610_GPIO2_BASE,
  81. .end = OMAP1610_GPIO2_BASE + SZ_2K - 1,
  82. .flags = IORESOURCE_MEM,
  83. },
  84. {
  85. .start = INT_1610_GPIO_BANK2,
  86. .flags = IORESOURCE_IRQ,
  87. },
  88. };
  89. static struct __initdata omap_gpio_platform_data omap16xx_gpio2_config = {
  90. .virtual_irq_start = IH_GPIO_BASE + 16,
  91. .bank_type = METHOD_GPIO_1610,
  92. .bank_width = 16,
  93. };
  94. static struct platform_device omap16xx_gpio2 = {
  95. .name = "omap_gpio",
  96. .id = 2,
  97. .dev = {
  98. .platform_data = &omap16xx_gpio2_config,
  99. },
  100. .num_resources = ARRAY_SIZE(omap16xx_gpio2_resources),
  101. .resource = omap16xx_gpio2_resources,
  102. };
  103. /* gpio3 */
  104. static struct __initdata resource omap16xx_gpio3_resources[] = {
  105. {
  106. .start = OMAP1610_GPIO3_BASE,
  107. .end = OMAP1610_GPIO3_BASE + SZ_2K - 1,
  108. .flags = IORESOURCE_MEM,
  109. },
  110. {
  111. .start = INT_1610_GPIO_BANK3,
  112. .flags = IORESOURCE_IRQ,
  113. },
  114. };
  115. static struct __initdata omap_gpio_platform_data omap16xx_gpio3_config = {
  116. .virtual_irq_start = IH_GPIO_BASE + 32,
  117. .bank_type = METHOD_GPIO_1610,
  118. .bank_width = 16,
  119. };
  120. static struct platform_device omap16xx_gpio3 = {
  121. .name = "omap_gpio",
  122. .id = 3,
  123. .dev = {
  124. .platform_data = &omap16xx_gpio3_config,
  125. },
  126. .num_resources = ARRAY_SIZE(omap16xx_gpio3_resources),
  127. .resource = omap16xx_gpio3_resources,
  128. };
  129. /* gpio4 */
  130. static struct __initdata resource omap16xx_gpio4_resources[] = {
  131. {
  132. .start = OMAP1610_GPIO4_BASE,
  133. .end = OMAP1610_GPIO4_BASE + SZ_2K - 1,
  134. .flags = IORESOURCE_MEM,
  135. },
  136. {
  137. .start = INT_1610_GPIO_BANK4,
  138. .flags = IORESOURCE_IRQ,
  139. },
  140. };
  141. static struct __initdata omap_gpio_platform_data omap16xx_gpio4_config = {
  142. .virtual_irq_start = IH_GPIO_BASE + 48,
  143. .bank_type = METHOD_GPIO_1610,
  144. .bank_width = 16,
  145. };
  146. static struct platform_device omap16xx_gpio4 = {
  147. .name = "omap_gpio",
  148. .id = 4,
  149. .dev = {
  150. .platform_data = &omap16xx_gpio4_config,
  151. },
  152. .num_resources = ARRAY_SIZE(omap16xx_gpio4_resources),
  153. .resource = omap16xx_gpio4_resources,
  154. };
  155. static struct __initdata platform_device * omap16xx_gpio_dev[] = {
  156. &omap16xx_mpu_gpio,
  157. &omap16xx_gpio1,
  158. &omap16xx_gpio2,
  159. &omap16xx_gpio3,
  160. &omap16xx_gpio4,
  161. };
  162. /*
  163. * omap16xx_gpio_init needs to be done before
  164. * machine_init functions access gpio APIs.
  165. * Hence omap16xx_gpio_init is a postcore_initcall.
  166. */
  167. static int __init omap16xx_gpio_init(void)
  168. {
  169. int i;
  170. if (!cpu_is_omap16xx())
  171. return -EINVAL;
  172. for (i = 0; i < ARRAY_SIZE(omap16xx_gpio_dev); i++)
  173. platform_device_register(omap16xx_gpio_dev[i]);
  174. gpio_bank_count = ARRAY_SIZE(omap16xx_gpio_dev);
  175. return 0;
  176. }
  177. postcore_initcall(omap16xx_gpio_init);