gpio-s5pv210.c 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. /*
  2. * S5PV210 - GPIOlib support
  3. *
  4. * Copyright (c) 2010 Samsung Electronics Co., Ltd.
  5. * http://www.samsung.com/
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. */
  11. #include <linux/kernel.h>
  12. #include <linux/irq.h>
  13. #include <linux/io.h>
  14. #include <linux/gpio.h>
  15. #include <plat/gpio-core.h>
  16. #include <plat/gpio-cfg.h>
  17. #include <plat/gpio-cfg-helpers.h>
  18. #include <mach/map.h>
  19. static struct s3c_gpio_cfg gpio_cfg = {
  20. .set_config = s3c_gpio_setcfg_s3c64xx_4bit,
  21. .set_pull = s3c_gpio_setpull_updown,
  22. .get_pull = s3c_gpio_getpull_updown,
  23. };
  24. static struct s3c_gpio_cfg gpio_cfg_noint = {
  25. .set_config = s3c_gpio_setcfg_s3c64xx_4bit,
  26. .set_pull = s3c_gpio_setpull_updown,
  27. .get_pull = s3c_gpio_getpull_updown,
  28. };
  29. /* GPIO bank's base address given the index of the bank in the
  30. * list of all gpio banks.
  31. */
  32. #define S5PV210_BANK_BASE(bank_nr) (S5P_VA_GPIO + ((bank_nr) * 0x20))
  33. /*
  34. * Following are the gpio banks in v210.
  35. *
  36. * The 'config' member when left to NULL, is initialized to the default
  37. * structure gpio_cfg in the init function below.
  38. *
  39. * The 'base' member is also initialized in the init function below.
  40. * Note: The initialization of 'base' member of s3c_gpio_chip structure
  41. * uses the above macro and depends on the banks being listed in order here.
  42. */
  43. static struct s3c_gpio_chip s5pv210_gpio_4bit[] = {
  44. {
  45. .chip = {
  46. .base = S5PV210_GPA0(0),
  47. .ngpio = S5PV210_GPIO_A0_NR,
  48. .label = "GPA0",
  49. },
  50. }, {
  51. .chip = {
  52. .base = S5PV210_GPA1(0),
  53. .ngpio = S5PV210_GPIO_A1_NR,
  54. .label = "GPA1",
  55. },
  56. }, {
  57. .chip = {
  58. .base = S5PV210_GPB(0),
  59. .ngpio = S5PV210_GPIO_B_NR,
  60. .label = "GPB",
  61. },
  62. }, {
  63. .chip = {
  64. .base = S5PV210_GPC0(0),
  65. .ngpio = S5PV210_GPIO_C0_NR,
  66. .label = "GPC0",
  67. },
  68. }, {
  69. .chip = {
  70. .base = S5PV210_GPC1(0),
  71. .ngpio = S5PV210_GPIO_C1_NR,
  72. .label = "GPC1",
  73. },
  74. }, {
  75. .chip = {
  76. .base = S5PV210_GPD0(0),
  77. .ngpio = S5PV210_GPIO_D0_NR,
  78. .label = "GPD0",
  79. },
  80. }, {
  81. .chip = {
  82. .base = S5PV210_GPD1(0),
  83. .ngpio = S5PV210_GPIO_D1_NR,
  84. .label = "GPD1",
  85. },
  86. }, {
  87. .chip = {
  88. .base = S5PV210_GPE0(0),
  89. .ngpio = S5PV210_GPIO_E0_NR,
  90. .label = "GPE0",
  91. },
  92. }, {
  93. .chip = {
  94. .base = S5PV210_GPE1(0),
  95. .ngpio = S5PV210_GPIO_E1_NR,
  96. .label = "GPE1",
  97. },
  98. }, {
  99. .chip = {
  100. .base = S5PV210_GPF0(0),
  101. .ngpio = S5PV210_GPIO_F0_NR,
  102. .label = "GPF0",
  103. },
  104. }, {
  105. .chip = {
  106. .base = S5PV210_GPF1(0),
  107. .ngpio = S5PV210_GPIO_F1_NR,
  108. .label = "GPF1",
  109. },
  110. }, {
  111. .chip = {
  112. .base = S5PV210_GPF2(0),
  113. .ngpio = S5PV210_GPIO_F2_NR,
  114. .label = "GPF2",
  115. },
  116. }, {
  117. .chip = {
  118. .base = S5PV210_GPF3(0),
  119. .ngpio = S5PV210_GPIO_F3_NR,
  120. .label = "GPF3",
  121. },
  122. }, {
  123. .chip = {
  124. .base = S5PV210_GPG0(0),
  125. .ngpio = S5PV210_GPIO_G0_NR,
  126. .label = "GPG0",
  127. },
  128. }, {
  129. .chip = {
  130. .base = S5PV210_GPG1(0),
  131. .ngpio = S5PV210_GPIO_G1_NR,
  132. .label = "GPG1",
  133. },
  134. }, {
  135. .chip = {
  136. .base = S5PV210_GPG2(0),
  137. .ngpio = S5PV210_GPIO_G2_NR,
  138. .label = "GPG2",
  139. },
  140. }, {
  141. .chip = {
  142. .base = S5PV210_GPG3(0),
  143. .ngpio = S5PV210_GPIO_G3_NR,
  144. .label = "GPG3",
  145. },
  146. }, {
  147. .config = &gpio_cfg_noint,
  148. .chip = {
  149. .base = S5PV210_GPI(0),
  150. .ngpio = S5PV210_GPIO_I_NR,
  151. .label = "GPI",
  152. },
  153. }, {
  154. .chip = {
  155. .base = S5PV210_GPJ0(0),
  156. .ngpio = S5PV210_GPIO_J0_NR,
  157. .label = "GPJ0",
  158. },
  159. }, {
  160. .chip = {
  161. .base = S5PV210_GPJ1(0),
  162. .ngpio = S5PV210_GPIO_J1_NR,
  163. .label = "GPJ1",
  164. },
  165. }, {
  166. .chip = {
  167. .base = S5PV210_GPJ2(0),
  168. .ngpio = S5PV210_GPIO_J2_NR,
  169. .label = "GPJ2",
  170. },
  171. }, {
  172. .chip = {
  173. .base = S5PV210_GPJ3(0),
  174. .ngpio = S5PV210_GPIO_J3_NR,
  175. .label = "GPJ3",
  176. },
  177. }, {
  178. .chip = {
  179. .base = S5PV210_GPJ4(0),
  180. .ngpio = S5PV210_GPIO_J4_NR,
  181. .label = "GPJ4",
  182. },
  183. }, {
  184. .config = &gpio_cfg_noint,
  185. .chip = {
  186. .base = S5PV210_MP01(0),
  187. .ngpio = S5PV210_GPIO_MP01_NR,
  188. .label = "MP01",
  189. },
  190. }, {
  191. .config = &gpio_cfg_noint,
  192. .chip = {
  193. .base = S5PV210_MP02(0),
  194. .ngpio = S5PV210_GPIO_MP02_NR,
  195. .label = "MP02",
  196. },
  197. }, {
  198. .config = &gpio_cfg_noint,
  199. .chip = {
  200. .base = S5PV210_MP03(0),
  201. .ngpio = S5PV210_GPIO_MP03_NR,
  202. .label = "MP03",
  203. },
  204. }, {
  205. .config = &gpio_cfg_noint,
  206. .chip = {
  207. .base = S5PV210_MP04(0),
  208. .ngpio = S5PV210_GPIO_MP04_NR,
  209. .label = "MP04",
  210. },
  211. }, {
  212. .config = &gpio_cfg_noint,
  213. .chip = {
  214. .base = S5PV210_MP05(0),
  215. .ngpio = S5PV210_GPIO_MP05_NR,
  216. .label = "MP05",
  217. },
  218. }, {
  219. .base = (S5P_VA_GPIO + 0xC00),
  220. .config = &gpio_cfg_noint,
  221. .irq_base = IRQ_EINT(0),
  222. .chip = {
  223. .base = S5PV210_GPH0(0),
  224. .ngpio = S5PV210_GPIO_H0_NR,
  225. .label = "GPH0",
  226. .to_irq = samsung_gpiolib_to_irq,
  227. },
  228. }, {
  229. .base = (S5P_VA_GPIO + 0xC20),
  230. .config = &gpio_cfg_noint,
  231. .irq_base = IRQ_EINT(8),
  232. .chip = {
  233. .base = S5PV210_GPH1(0),
  234. .ngpio = S5PV210_GPIO_H1_NR,
  235. .label = "GPH1",
  236. .to_irq = samsung_gpiolib_to_irq,
  237. },
  238. }, {
  239. .base = (S5P_VA_GPIO + 0xC40),
  240. .config = &gpio_cfg_noint,
  241. .irq_base = IRQ_EINT(16),
  242. .chip = {
  243. .base = S5PV210_GPH2(0),
  244. .ngpio = S5PV210_GPIO_H2_NR,
  245. .label = "GPH2",
  246. .to_irq = samsung_gpiolib_to_irq,
  247. },
  248. }, {
  249. .base = (S5P_VA_GPIO + 0xC60),
  250. .config = &gpio_cfg_noint,
  251. .irq_base = IRQ_EINT(24),
  252. .chip = {
  253. .base = S5PV210_GPH3(0),
  254. .ngpio = S5PV210_GPIO_H3_NR,
  255. .label = "GPH3",
  256. .to_irq = samsung_gpiolib_to_irq,
  257. },
  258. },
  259. };
  260. static __init int s5pv210_gpiolib_init(void)
  261. {
  262. struct s3c_gpio_chip *chip = s5pv210_gpio_4bit;
  263. int nr_chips = ARRAY_SIZE(s5pv210_gpio_4bit);
  264. int gpioint_group = 0;
  265. int i = 0;
  266. for (i = 0; i < nr_chips; i++, chip++) {
  267. if (chip->config == NULL) {
  268. chip->config = &gpio_cfg;
  269. chip->group = gpioint_group++;
  270. }
  271. if (chip->base == NULL)
  272. chip->base = S5PV210_BANK_BASE(i);
  273. }
  274. samsung_gpiolib_add_4bit_chips(s5pv210_gpio_4bit, nr_chips);
  275. s5p_register_gpioint_bank(IRQ_GPIOINT, 0, S5P_GPIOINT_GROUP_MAXNR);
  276. return 0;
  277. }
  278. core_initcall(s5pv210_gpiolib_init);