gpio7xx.c 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. /*
  2. * OMAP7xx 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 OMAP7XX_GPIO1_BASE 0xfffbc000
  20. #define OMAP7XX_GPIO2_BASE 0xfffbc800
  21. #define OMAP7XX_GPIO3_BASE 0xfffbd000
  22. #define OMAP7XX_GPIO4_BASE 0xfffbd800
  23. #define OMAP7XX_GPIO5_BASE 0xfffbe000
  24. #define OMAP7XX_GPIO6_BASE 0xfffbe800
  25. #define OMAP1_MPUIO_VBASE OMAP1_MPUIO_BASE
  26. /* mpu gpio */
  27. static struct __initdata resource omap7xx_mpu_gpio_resources[] = {
  28. {
  29. .start = OMAP1_MPUIO_VBASE,
  30. .end = OMAP1_MPUIO_VBASE + SZ_2K - 1,
  31. .flags = IORESOURCE_MEM,
  32. },
  33. {
  34. .start = INT_7XX_MPUIO,
  35. .flags = IORESOURCE_IRQ,
  36. },
  37. };
  38. static struct __initdata omap_gpio_platform_data omap7xx_mpu_gpio_config = {
  39. .virtual_irq_start = IH_MPUIO_BASE,
  40. .bank_type = METHOD_MPUIO,
  41. .bank_width = 32,
  42. };
  43. static struct __initdata platform_device omap7xx_mpu_gpio = {
  44. .name = "omap_gpio",
  45. .id = 0,
  46. .dev = {
  47. .platform_data = &omap7xx_mpu_gpio_config,
  48. },
  49. .num_resources = ARRAY_SIZE(omap7xx_mpu_gpio_resources),
  50. .resource = omap7xx_mpu_gpio_resources,
  51. };
  52. /* gpio1 */
  53. static struct __initdata resource omap7xx_gpio1_resources[] = {
  54. {
  55. .start = OMAP7XX_GPIO1_BASE,
  56. .end = OMAP7XX_GPIO1_BASE + SZ_2K - 1,
  57. .flags = IORESOURCE_MEM,
  58. },
  59. {
  60. .start = INT_7XX_GPIO_BANK1,
  61. .flags = IORESOURCE_IRQ,
  62. },
  63. };
  64. static struct __initdata omap_gpio_platform_data omap7xx_gpio1_config = {
  65. .virtual_irq_start = IH_GPIO_BASE,
  66. .bank_type = METHOD_GPIO_7XX,
  67. .bank_width = 32,
  68. };
  69. static struct __initdata platform_device omap7xx_gpio1 = {
  70. .name = "omap_gpio",
  71. .id = 1,
  72. .dev = {
  73. .platform_data = &omap7xx_gpio1_config,
  74. },
  75. .num_resources = ARRAY_SIZE(omap7xx_gpio1_resources),
  76. .resource = omap7xx_gpio1_resources,
  77. };
  78. /* gpio2 */
  79. static struct __initdata resource omap7xx_gpio2_resources[] = {
  80. {
  81. .start = OMAP7XX_GPIO2_BASE,
  82. .end = OMAP7XX_GPIO2_BASE + SZ_2K - 1,
  83. .flags = IORESOURCE_MEM,
  84. },
  85. {
  86. .start = INT_7XX_GPIO_BANK2,
  87. .flags = IORESOURCE_IRQ,
  88. },
  89. };
  90. static struct __initdata omap_gpio_platform_data omap7xx_gpio2_config = {
  91. .virtual_irq_start = IH_GPIO_BASE + 32,
  92. .bank_type = METHOD_GPIO_7XX,
  93. .bank_width = 32,
  94. };
  95. static struct __initdata platform_device omap7xx_gpio2 = {
  96. .name = "omap_gpio",
  97. .id = 2,
  98. .dev = {
  99. .platform_data = &omap7xx_gpio2_config,
  100. },
  101. .num_resources = ARRAY_SIZE(omap7xx_gpio2_resources),
  102. .resource = omap7xx_gpio2_resources,
  103. };
  104. /* gpio3 */
  105. static struct __initdata resource omap7xx_gpio3_resources[] = {
  106. {
  107. .start = OMAP7XX_GPIO3_BASE,
  108. .end = OMAP7XX_GPIO3_BASE + SZ_2K - 1,
  109. .flags = IORESOURCE_MEM,
  110. },
  111. {
  112. .start = INT_7XX_GPIO_BANK3,
  113. .flags = IORESOURCE_IRQ,
  114. },
  115. };
  116. static struct __initdata omap_gpio_platform_data omap7xx_gpio3_config = {
  117. .virtual_irq_start = IH_GPIO_BASE + 64,
  118. .bank_type = METHOD_GPIO_7XX,
  119. .bank_width = 32,
  120. };
  121. static struct __initdata platform_device omap7xx_gpio3 = {
  122. .name = "omap_gpio",
  123. .id = 3,
  124. .dev = {
  125. .platform_data = &omap7xx_gpio3_config,
  126. },
  127. .num_resources = ARRAY_SIZE(omap7xx_gpio3_resources),
  128. .resource = omap7xx_gpio3_resources,
  129. };
  130. /* gpio4 */
  131. static struct __initdata resource omap7xx_gpio4_resources[] = {
  132. {
  133. .start = OMAP7XX_GPIO4_BASE,
  134. .end = OMAP7XX_GPIO4_BASE + SZ_2K - 1,
  135. .flags = IORESOURCE_MEM,
  136. },
  137. {
  138. .start = INT_7XX_GPIO_BANK4,
  139. .flags = IORESOURCE_IRQ,
  140. },
  141. };
  142. static struct __initdata omap_gpio_platform_data omap7xx_gpio4_config = {
  143. .virtual_irq_start = IH_GPIO_BASE + 96,
  144. .bank_type = METHOD_GPIO_7XX,
  145. .bank_width = 32,
  146. };
  147. static struct __initdata platform_device omap7xx_gpio4 = {
  148. .name = "omap_gpio",
  149. .id = 4,
  150. .dev = {
  151. .platform_data = &omap7xx_gpio4_config,
  152. },
  153. .num_resources = ARRAY_SIZE(omap7xx_gpio4_resources),
  154. .resource = omap7xx_gpio4_resources,
  155. };
  156. /* gpio5 */
  157. static struct __initdata resource omap7xx_gpio5_resources[] = {
  158. {
  159. .start = OMAP7XX_GPIO5_BASE,
  160. .end = OMAP7XX_GPIO5_BASE + SZ_2K - 1,
  161. .flags = IORESOURCE_MEM,
  162. },
  163. {
  164. .start = INT_7XX_GPIO_BANK5,
  165. .flags = IORESOURCE_IRQ,
  166. },
  167. };
  168. static struct __initdata omap_gpio_platform_data omap7xx_gpio5_config = {
  169. .virtual_irq_start = IH_GPIO_BASE + 128,
  170. .bank_type = METHOD_GPIO_7XX,
  171. .bank_width = 32,
  172. };
  173. static struct __initdata platform_device omap7xx_gpio5 = {
  174. .name = "omap_gpio",
  175. .id = 5,
  176. .dev = {
  177. .platform_data = &omap7xx_gpio5_config,
  178. },
  179. .num_resources = ARRAY_SIZE(omap7xx_gpio5_resources),
  180. .resource = omap7xx_gpio5_resources,
  181. };
  182. /* gpio6 */
  183. static struct __initdata resource omap7xx_gpio6_resources[] = {
  184. {
  185. .start = OMAP7XX_GPIO6_BASE,
  186. .end = OMAP7XX_GPIO6_BASE + SZ_2K - 1,
  187. .flags = IORESOURCE_MEM,
  188. },
  189. {
  190. .start = INT_7XX_GPIO_BANK6,
  191. .flags = IORESOURCE_IRQ,
  192. },
  193. };
  194. static struct __initdata omap_gpio_platform_data omap7xx_gpio6_config = {
  195. .virtual_irq_start = IH_GPIO_BASE + 160,
  196. .bank_type = METHOD_GPIO_7XX,
  197. .bank_width = 32,
  198. };
  199. static struct __initdata platform_device omap7xx_gpio6 = {
  200. .name = "omap_gpio",
  201. .id = 6,
  202. .dev = {
  203. .platform_data = &omap7xx_gpio6_config,
  204. },
  205. .num_resources = ARRAY_SIZE(omap7xx_gpio6_resources),
  206. .resource = omap7xx_gpio6_resources,
  207. };
  208. static struct __initdata platform_device * omap7xx_gpio_dev[] = {
  209. &omap7xx_mpu_gpio,
  210. &omap7xx_gpio1,
  211. &omap7xx_gpio2,
  212. &omap7xx_gpio3,
  213. &omap7xx_gpio4,
  214. &omap7xx_gpio5,
  215. &omap7xx_gpio6,
  216. };
  217. /*
  218. * omap7xx_gpio_init needs to be done before
  219. * machine_init functions access gpio APIs.
  220. * Hence omap7xx_gpio_init is a postcore_initcall.
  221. */
  222. static int __init omap7xx_gpio_init(void)
  223. {
  224. int i;
  225. if (!cpu_is_omap7xx())
  226. return -EINVAL;
  227. for (i = 0; i < ARRAY_SIZE(omap7xx_gpio_dev); i++)
  228. platform_device_register(omap7xx_gpio_dev[i]);
  229. gpio_bank_count = ARRAY_SIZE(omap7xx_gpio_dev);
  230. return 0;
  231. }
  232. postcore_initcall(omap7xx_gpio_init);