gpio7xx.c 6.6 KB

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