gpio7xx.c 6.3 KB

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