gpio16xx.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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. };
  41. static struct __initdata platform_device omap16xx_mpu_gpio = {
  42. .name = "omap_gpio",
  43. .id = 0,
  44. .dev = {
  45. .platform_data = &omap16xx_mpu_gpio_config,
  46. },
  47. .num_resources = ARRAY_SIZE(omap16xx_mpu_gpio_resources),
  48. .resource = omap16xx_mpu_gpio_resources,
  49. };
  50. /* gpio1 */
  51. static struct __initdata resource omap16xx_gpio1_resources[] = {
  52. {
  53. .start = OMAP1610_GPIO1_BASE,
  54. .end = OMAP1610_GPIO1_BASE + SZ_2K - 1,
  55. .flags = IORESOURCE_MEM,
  56. },
  57. {
  58. .start = INT_GPIO_BANK1,
  59. .flags = IORESOURCE_IRQ,
  60. },
  61. };
  62. static struct __initdata omap_gpio_platform_data omap16xx_gpio1_config = {
  63. .virtual_irq_start = IH_GPIO_BASE,
  64. .bank_type = METHOD_GPIO_1610,
  65. .bank_width = 16,
  66. };
  67. static struct __initdata platform_device omap16xx_gpio1 = {
  68. .name = "omap_gpio",
  69. .id = 1,
  70. .dev = {
  71. .platform_data = &omap16xx_gpio1_config,
  72. },
  73. .num_resources = ARRAY_SIZE(omap16xx_gpio1_resources),
  74. .resource = omap16xx_gpio1_resources,
  75. };
  76. /* gpio2 */
  77. static struct __initdata resource omap16xx_gpio2_resources[] = {
  78. {
  79. .start = OMAP1610_GPIO2_BASE,
  80. .end = OMAP1610_GPIO2_BASE + SZ_2K - 1,
  81. .flags = IORESOURCE_MEM,
  82. },
  83. {
  84. .start = INT_1610_GPIO_BANK2,
  85. .flags = IORESOURCE_IRQ,
  86. },
  87. };
  88. static struct __initdata omap_gpio_platform_data omap16xx_gpio2_config = {
  89. .virtual_irq_start = IH_GPIO_BASE + 16,
  90. .bank_type = METHOD_GPIO_1610,
  91. .bank_width = 16,
  92. };
  93. static struct __initdata platform_device omap16xx_gpio2 = {
  94. .name = "omap_gpio",
  95. .id = 2,
  96. .dev = {
  97. .platform_data = &omap16xx_gpio2_config,
  98. },
  99. .num_resources = ARRAY_SIZE(omap16xx_gpio2_resources),
  100. .resource = omap16xx_gpio2_resources,
  101. };
  102. /* gpio3 */
  103. static struct __initdata resource omap16xx_gpio3_resources[] = {
  104. {
  105. .start = OMAP1610_GPIO3_BASE,
  106. .end = OMAP1610_GPIO3_BASE + SZ_2K - 1,
  107. .flags = IORESOURCE_MEM,
  108. },
  109. {
  110. .start = INT_1610_GPIO_BANK3,
  111. .flags = IORESOURCE_IRQ,
  112. },
  113. };
  114. static struct __initdata omap_gpio_platform_data omap16xx_gpio3_config = {
  115. .virtual_irq_start = IH_GPIO_BASE + 32,
  116. .bank_type = METHOD_GPIO_1610,
  117. .bank_width = 16,
  118. };
  119. static struct __initdata platform_device omap16xx_gpio3 = {
  120. .name = "omap_gpio",
  121. .id = 3,
  122. .dev = {
  123. .platform_data = &omap16xx_gpio3_config,
  124. },
  125. .num_resources = ARRAY_SIZE(omap16xx_gpio3_resources),
  126. .resource = omap16xx_gpio3_resources,
  127. };
  128. /* gpio4 */
  129. static struct __initdata resource omap16xx_gpio4_resources[] = {
  130. {
  131. .start = OMAP1610_GPIO4_BASE,
  132. .end = OMAP1610_GPIO4_BASE + SZ_2K - 1,
  133. .flags = IORESOURCE_MEM,
  134. },
  135. {
  136. .start = INT_1610_GPIO_BANK4,
  137. .flags = IORESOURCE_IRQ,
  138. },
  139. };
  140. static struct __initdata omap_gpio_platform_data omap16xx_gpio4_config = {
  141. .virtual_irq_start = IH_GPIO_BASE + 48,
  142. .bank_type = METHOD_GPIO_1610,
  143. .bank_width = 16,
  144. };
  145. static struct __initdata platform_device omap16xx_gpio4 = {
  146. .name = "omap_gpio",
  147. .id = 4,
  148. .dev = {
  149. .platform_data = &omap16xx_gpio4_config,
  150. },
  151. .num_resources = ARRAY_SIZE(omap16xx_gpio4_resources),
  152. .resource = omap16xx_gpio4_resources,
  153. };
  154. static struct __initdata platform_device * omap16xx_gpio_dev[] = {
  155. &omap16xx_mpu_gpio,
  156. &omap16xx_gpio1,
  157. &omap16xx_gpio2,
  158. &omap16xx_gpio3,
  159. &omap16xx_gpio4,
  160. };
  161. /*
  162. * omap16xx_gpio_init needs to be done before
  163. * machine_init functions access gpio APIs.
  164. * Hence omap16xx_gpio_init is a postcore_initcall.
  165. */
  166. static int __init omap16xx_gpio_init(void)
  167. {
  168. int i;
  169. if (!cpu_is_omap16xx())
  170. return -EINVAL;
  171. for (i = 0; i < ARRAY_SIZE(omap16xx_gpio_dev); i++)
  172. platform_device_register(omap16xx_gpio_dev[i]);
  173. gpio_bank_count = ARRAY_SIZE(omap16xx_gpio_dev);
  174. return 0;
  175. }
  176. postcore_initcall(omap16xx_gpio_init);