pinctrl-ab8540.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  1. /*
  2. * Copyright (C) ST-Ericsson SA 2012
  3. *
  4. * Author: Patrice Chotard <patrice.chotard@stericsson.com> for ST-Ericsson.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #include <linux/kernel.h>
  11. #include <linux/gpio.h>
  12. #include <linux/pinctrl/pinctrl.h>
  13. #include <linux/mfd/abx500/ab8500.h>
  14. #include "pinctrl-abx500.h"
  15. /* All the pins that can be used for GPIO and some other functions */
  16. #define ABX500_GPIO(offset) (offset)
  17. #define AB8540_PIN_J16 ABX500_GPIO(1)
  18. #define AB8540_PIN_D17 ABX500_GPIO(2)
  19. #define AB8540_PIN_C12 ABX500_GPIO(3)
  20. #define AB8540_PIN_G12 ABX500_GPIO(4)
  21. /* hole */
  22. #define AB8540_PIN_D16 ABX500_GPIO(14)
  23. #define AB8540_PIN_F15 ABX500_GPIO(15)
  24. #define AB8540_PIN_J8 ABX500_GPIO(16)
  25. #define AB8540_PIN_K16 ABX500_GPIO(17)
  26. #define AB8540_PIN_G15 ABX500_GPIO(18)
  27. #define AB8540_PIN_F17 ABX500_GPIO(19)
  28. #define AB8540_PIN_E17 ABX500_GPIO(20)
  29. /* hole */
  30. #define AB8540_PIN_AA16 ABX500_GPIO(27)
  31. #define AB8540_PIN_W18 ABX500_GPIO(28)
  32. #define AB8540_PIN_Y15 ABX500_GPIO(29)
  33. #define AB8540_PIN_W16 ABX500_GPIO(30)
  34. #define AB8540_PIN_V15 ABX500_GPIO(31)
  35. #define AB8540_PIN_W17 ABX500_GPIO(32)
  36. /* hole */
  37. #define AB8540_PIN_D12 ABX500_GPIO(42)
  38. #define AB8540_PIN_P4 ABX500_GPIO(43)
  39. #define AB8540_PIN_AB1 ABX500_GPIO(44)
  40. #define AB8540_PIN_K7 ABX500_GPIO(45)
  41. #define AB8540_PIN_L7 ABX500_GPIO(46)
  42. #define AB8540_PIN_G10 ABX500_GPIO(47)
  43. #define AB8540_PIN_K12 ABX500_GPIO(48)
  44. /* hole */
  45. #define AB8540_PIN_N8 ABX500_GPIO(51)
  46. #define AB8540_PIN_P12 ABX500_GPIO(52)
  47. #define AB8540_PIN_K8 ABX500_GPIO(53)
  48. #define AB8540_PIN_J11 ABX500_GPIO(54)
  49. #define AB8540_PIN_AC2 ABX500_GPIO(55)
  50. #define AB8540_PIN_AB2 ABX500_GPIO(56)
  51. /* indicates the highest GPIO number */
  52. #define AB8540_GPIO_MAX_NUMBER 56
  53. /*
  54. * The names of the pins are denoted by GPIO number and ball name, even
  55. * though they can be used for other things than GPIO, this is the first
  56. * column in the table of the data sheet and often used on schematics and
  57. * such.
  58. */
  59. static const struct pinctrl_pin_desc ab8540_pins[] = {
  60. PINCTRL_PIN(AB8540_PIN_J16, "GPIO1_J16"),
  61. PINCTRL_PIN(AB8540_PIN_D17, "GPIO2_D17"),
  62. PINCTRL_PIN(AB8540_PIN_C12, "GPIO3_C12"),
  63. PINCTRL_PIN(AB8540_PIN_G12, "GPIO4_G12"),
  64. /* hole */
  65. PINCTRL_PIN(AB8540_PIN_D16, "GPIO14_D16"),
  66. PINCTRL_PIN(AB8540_PIN_F15, "GPIO15_F15"),
  67. PINCTRL_PIN(AB8540_PIN_J8, "GPIO16_J8"),
  68. PINCTRL_PIN(AB8540_PIN_K16, "GPIO17_K16"),
  69. PINCTRL_PIN(AB8540_PIN_G15, "GPIO18_G15"),
  70. PINCTRL_PIN(AB8540_PIN_F17, "GPIO19_F17"),
  71. PINCTRL_PIN(AB8540_PIN_E17, "GPIO20_E17"),
  72. /* hole */
  73. PINCTRL_PIN(AB8540_PIN_AA16, "GPIO27_AA16"),
  74. PINCTRL_PIN(AB8540_PIN_W18, "GPIO28_W18"),
  75. PINCTRL_PIN(AB8540_PIN_Y15, "GPIO29_Y15"),
  76. PINCTRL_PIN(AB8540_PIN_W16, "GPIO30_W16"),
  77. PINCTRL_PIN(AB8540_PIN_V15, "GPIO31_V15"),
  78. PINCTRL_PIN(AB8540_PIN_W17, "GPIO32_W17"),
  79. /* hole */
  80. PINCTRL_PIN(AB8540_PIN_D12, "GPIO42_D12"),
  81. PINCTRL_PIN(AB8540_PIN_P4, "GPIO43_P4"),
  82. PINCTRL_PIN(AB8540_PIN_AB1, "GPIO44_AB1"),
  83. PINCTRL_PIN(AB8540_PIN_K7, "GPIO45_K7"),
  84. PINCTRL_PIN(AB8540_PIN_L7, "GPIO46_L7"),
  85. PINCTRL_PIN(AB8540_PIN_G10, "GPIO47_G10"),
  86. PINCTRL_PIN(AB8540_PIN_K12, "GPIO48_K12"),
  87. /* hole */
  88. PINCTRL_PIN(AB8540_PIN_N8, "GPIO51_N8"),
  89. PINCTRL_PIN(AB8540_PIN_P12, "GPIO52_P12"),
  90. PINCTRL_PIN(AB8540_PIN_K8, "GPIO53_K8"),
  91. PINCTRL_PIN(AB8540_PIN_J11, "GPIO54_J11"),
  92. PINCTRL_PIN(AB8540_PIN_AC2, "GPIO55_AC2"),
  93. PINCTRL_PIN(AB8540_PIN_AB2, "GPIO56_AB2"),
  94. };
  95. /*
  96. * Maps local GPIO offsets to local pin numbers
  97. */
  98. static const struct abx500_pinrange ab8540_pinranges[] = {
  99. ABX500_PINRANGE(1, 4, ABX500_ALT_A),
  100. ABX500_PINRANGE(14, 7, ABX500_ALT_A),
  101. ABX500_PINRANGE(27, 6, ABX500_ALT_A),
  102. ABX500_PINRANGE(42, 7, ABX500_ALT_A),
  103. ABX500_PINRANGE(51, 6, ABX500_ALT_A),
  104. };
  105. /*
  106. * Read the pin group names like this:
  107. * sysclkreq2_d_1 = first groups of pins for sysclkreq2 on default function
  108. *
  109. * The groups are arranged as sets per altfunction column, so we can
  110. * mux in one group at a time by selecting the same altfunction for them
  111. * all. When functions require pins on different altfunctions, you need
  112. * to combine several groups.
  113. */
  114. /* default column */
  115. static const unsigned sysclkreq2_d_1_pins[] = { AB8540_PIN_J16 };
  116. static const unsigned sysclkreq3_d_1_pins[] = { AB8540_PIN_D17 };
  117. static const unsigned sysclkreq4_d_1_pins[] = { AB8540_PIN_C12 };
  118. static const unsigned sysclkreq6_d_1_pins[] = { AB8540_PIN_G12 };
  119. static const unsigned pwmout1_d_1_pins[] = { AB8540_PIN_D16 };
  120. static const unsigned pwmout2_d_1_pins[] = { AB8540_PIN_F15 };
  121. static const unsigned pwmout3_d_1_pins[] = { AB8540_PIN_J8 };
  122. /* audio data interface 1*/
  123. static const unsigned adi1_d_1_pins[] = { AB8540_PIN_K16, AB8540_PIN_G15,
  124. AB8540_PIN_F17, AB8540_PIN_E17 };
  125. /* Digital microphone 1 and 2 */
  126. static const unsigned dmic12_d_1_pins[] = { AB8540_PIN_AA16, AB8540_PIN_W18 };
  127. /* Digital microphone 3 and 4 */
  128. static const unsigned dmic34_d_1_pins[] = { AB8540_PIN_Y15, AB8540_PIN_W16 };
  129. /* Digital microphone 5 and 6 */
  130. static const unsigned dmic56_d_1_pins[] = { AB8540_PIN_V15, AB8540_PIN_W17 };
  131. static const unsigned sysclkreq5_d_1_pins[] = { AB8540_PIN_D12 };
  132. static const unsigned batremn_d_1_pins[] = { AB8540_PIN_P4 };
  133. static const unsigned service_d_1_pins[] = { AB8540_PIN_AB1 };
  134. static const unsigned pwrctrl0_d_1_pins[] = { AB8540_PIN_K7 };
  135. static const unsigned pwrctrl1_d_1_pins[] = { AB8540_PIN_L7 };
  136. static const unsigned pwmextvibra1_d_1_pins[] = { AB8540_PIN_G10 };
  137. static const unsigned pwmextvibra2_d_1_pins[] = { AB8540_PIN_K12 };
  138. static const unsigned gpio1_vbat_d_1_pins[] = { AB8540_PIN_N8 };
  139. static const unsigned gpio2_vbat_d_1_pins[] = { AB8540_PIN_P12 };
  140. static const unsigned gpio3_vbat_d_1_pins[] = { AB8540_PIN_K8 };
  141. static const unsigned gpio4_vbat_d_1_pins[] = { AB8540_PIN_J11 };
  142. static const unsigned pdmclkdat_d_1_pins[] = { AB8540_PIN_AC2, AB8540_PIN_AB2 };
  143. /* Altfunction A column */
  144. static const unsigned gpio1_a_1_pins[] = { AB8540_PIN_J16 };
  145. static const unsigned gpio2_a_1_pins[] = { AB8540_PIN_D17 };
  146. static const unsigned gpio3_a_1_pins[] = { AB8540_PIN_C12 };
  147. static const unsigned gpio4_a_1_pins[] = { AB8540_PIN_G12 };
  148. static const unsigned gpio14_a_1_pins[] = { AB8540_PIN_D16 };
  149. static const unsigned gpio15_a_1_pins[] = { AB8540_PIN_F15 };
  150. static const unsigned gpio16_a_1_pins[] = { AB8540_PIN_J8 };
  151. static const unsigned gpio17_a_1_pins[] = { AB8540_PIN_K16 };
  152. static const unsigned gpio18_a_1_pins[] = { AB8540_PIN_G15 };
  153. static const unsigned gpio19_a_1_pins[] = { AB8540_PIN_F17 };
  154. static const unsigned gpio20_a_1_pins[] = { AB8540_PIN_E17 };
  155. static const unsigned gpio27_a_1_pins[] = { AB8540_PIN_AA16 };
  156. static const unsigned gpio28_a_1_pins[] = { AB8540_PIN_W18 };
  157. static const unsigned gpio29_a_1_pins[] = { AB8540_PIN_Y15 };
  158. static const unsigned gpio30_a_1_pins[] = { AB8540_PIN_W16 };
  159. static const unsigned gpio31_a_1_pins[] = { AB8540_PIN_V15 };
  160. static const unsigned gpio32_a_1_pins[] = { AB8540_PIN_W17 };
  161. static const unsigned gpio42_a_1_pins[] = { AB8540_PIN_D12 };
  162. static const unsigned gpio43_a_1_pins[] = { AB8540_PIN_P4 };
  163. static const unsigned gpio44_a_1_pins[] = { AB8540_PIN_AB1 };
  164. static const unsigned gpio45_a_1_pins[] = { AB8540_PIN_K7 };
  165. static const unsigned gpio46_a_1_pins[] = { AB8540_PIN_L7 };
  166. static const unsigned gpio47_a_1_pins[] = { AB8540_PIN_G10 };
  167. static const unsigned gpio48_a_1_pins[] = { AB8540_PIN_K12 };
  168. static const unsigned gpio51_a_1_pins[] = { AB8540_PIN_N8 };
  169. static const unsigned gpio52_a_1_pins[] = { AB8540_PIN_P12 };
  170. static const unsigned gpio53_a_1_pins[] = { AB8540_PIN_K8 };
  171. static const unsigned gpio54_a_1_pins[] = { AB8540_PIN_J11 };
  172. static const unsigned gpio55_a_1_pins[] = { AB8540_PIN_AC2 };
  173. static const unsigned gpio56_a_1_pins[] = { AB8540_PIN_AB2 };
  174. #define AB8540_PIN_GROUP(a, b) { .name = #a, .pins = a##_pins, \
  175. .npins = ARRAY_SIZE(a##_pins), .altsetting = b }
  176. static const struct abx500_pingroup ab8540_groups[] = {
  177. /* default column */
  178. AB8540_PIN_GROUP(sysclkreq2_d_1, ABX500_DEFAULT),
  179. AB8540_PIN_GROUP(sysclkreq3_d_1, ABX500_DEFAULT),
  180. AB8540_PIN_GROUP(sysclkreq4_d_1, ABX500_DEFAULT),
  181. AB8540_PIN_GROUP(sysclkreq6_d_1, ABX500_DEFAULT),
  182. AB8540_PIN_GROUP(pwmout1_d_1, ABX500_DEFAULT),
  183. AB8540_PIN_GROUP(pwmout2_d_1, ABX500_DEFAULT),
  184. AB8540_PIN_GROUP(pwmout3_d_1, ABX500_DEFAULT),
  185. AB8540_PIN_GROUP(adi1_d_1, ABX500_DEFAULT),
  186. AB8540_PIN_GROUP(dmic12_d_1, ABX500_DEFAULT),
  187. AB8540_PIN_GROUP(dmic34_d_1, ABX500_DEFAULT),
  188. AB8540_PIN_GROUP(dmic56_d_1, ABX500_DEFAULT),
  189. AB8540_PIN_GROUP(sysclkreq5_d_1, ABX500_DEFAULT),
  190. AB8540_PIN_GROUP(batremn_d_1, ABX500_DEFAULT),
  191. AB8540_PIN_GROUP(service_d_1, ABX500_DEFAULT),
  192. AB8540_PIN_GROUP(pwrctrl0_d_1, ABX500_DEFAULT),
  193. AB8540_PIN_GROUP(pwrctrl1_d_1, ABX500_DEFAULT),
  194. AB8540_PIN_GROUP(pwmextvibra1_d_1, ABX500_DEFAULT),
  195. AB8540_PIN_GROUP(pwmextvibra2_d_1, ABX500_DEFAULT),
  196. AB8540_PIN_GROUP(gpio1_vbat_d_1, ABX500_DEFAULT),
  197. AB8540_PIN_GROUP(gpio2_vbat_d_1, ABX500_DEFAULT),
  198. AB8540_PIN_GROUP(gpio3_vbat_d_1, ABX500_DEFAULT),
  199. AB8540_PIN_GROUP(gpio4_vbat_d_1, ABX500_DEFAULT),
  200. AB8540_PIN_GROUP(pdmclkdat_d_1, ABX500_DEFAULT),
  201. /* Altfunction A column */
  202. AB8540_PIN_GROUP(gpio1_a_1, ABX500_ALT_A),
  203. AB8540_PIN_GROUP(gpio2_a_1, ABX500_ALT_A),
  204. AB8540_PIN_GROUP(gpio3_a_1, ABX500_ALT_A),
  205. AB8540_PIN_GROUP(gpio4_a_1, ABX500_ALT_A),
  206. AB8540_PIN_GROUP(gpio14_a_1, ABX500_ALT_A),
  207. AB8540_PIN_GROUP(gpio15_a_1, ABX500_ALT_A),
  208. AB8540_PIN_GROUP(gpio16_a_1, ABX500_ALT_A),
  209. AB8540_PIN_GROUP(gpio17_a_1, ABX500_ALT_A),
  210. AB8540_PIN_GROUP(gpio18_a_1, ABX500_ALT_A),
  211. AB8540_PIN_GROUP(gpio19_a_1, ABX500_ALT_A),
  212. AB8540_PIN_GROUP(gpio20_a_1, ABX500_ALT_A),
  213. AB8540_PIN_GROUP(gpio27_a_1, ABX500_ALT_A),
  214. AB8540_PIN_GROUP(gpio28_a_1, ABX500_ALT_A),
  215. AB8540_PIN_GROUP(gpio29_a_1, ABX500_ALT_A),
  216. AB8540_PIN_GROUP(gpio30_a_1, ABX500_ALT_A),
  217. AB8540_PIN_GROUP(gpio31_a_1, ABX500_ALT_A),
  218. AB8540_PIN_GROUP(gpio32_a_1, ABX500_ALT_A),
  219. AB8540_PIN_GROUP(gpio42_a_1, ABX500_ALT_A),
  220. AB8540_PIN_GROUP(gpio43_a_1, ABX500_ALT_A),
  221. AB8540_PIN_GROUP(gpio44_a_1, ABX500_ALT_A),
  222. AB8540_PIN_GROUP(gpio45_a_1, ABX500_ALT_A),
  223. AB8540_PIN_GROUP(gpio46_a_1, ABX500_ALT_A),
  224. AB8540_PIN_GROUP(gpio47_a_1, ABX500_ALT_A),
  225. AB8540_PIN_GROUP(gpio48_a_1, ABX500_ALT_A),
  226. AB8540_PIN_GROUP(gpio51_a_1, ABX500_ALT_A),
  227. AB8540_PIN_GROUP(gpio52_a_1, ABX500_ALT_A),
  228. AB8540_PIN_GROUP(gpio53_a_1, ABX500_ALT_A),
  229. AB8540_PIN_GROUP(gpio54_a_1, ABX500_ALT_A),
  230. AB8540_PIN_GROUP(gpio55_a_1, ABX500_ALT_A),
  231. AB8540_PIN_GROUP(gpio56_a_1, ABX500_ALT_A),
  232. };
  233. /* We use this macro to define the groups applicable to a function */
  234. #define AB8540_FUNC_GROUPS(a, b...) \
  235. static const char * const a##_groups[] = { b };
  236. AB8540_FUNC_GROUPS(sysclkreq, "sysclkreq2_d_1", "sysclkreq3_d_1",
  237. "sysclkreq4_d_1", "sysclkreq5_d_1", "sysclkreq6_d_1");
  238. AB8540_FUNC_GROUPS(gpio, "gpio1_a_1", "gpio2_a_1", "gpio3_a_1", "gpio4_a_1",
  239. "gpio14_a_1", "gpio15_a_1", "gpio16_a_1", "gpio17_a_1",
  240. "gpio18_a_1", "gpio19_a_1", "gpio20_a_1", "gpio27_a_1",
  241. "gpio28_a_1", "gpio29_a_1", "gpio30_a_1", "gpio31_a_1",
  242. "gpio32_a_1", "gpio42_a_1", "gpio43_a_1", "gpio44_a_1",
  243. "gpio45_a_1", "gpio46_a_1", "gpio47_a_1", "gpio48_a_1",
  244. "gpio51_a_1", "gpio52_a_1", "gpio53_a_1", "gpio54_a_1",
  245. "gpio55_a_1", "gpio56_a_1");
  246. AB8540_FUNC_GROUPS(pwmout, "pwmout1_d_1", "pwmout2_d_1", "pwmout3_d_1");
  247. AB8540_FUNC_GROUPS(adi1, "adi1_d_1");
  248. AB8540_FUNC_GROUPS(dmic, "dmic12_d_1", "dmic34_d_1", "dmic56_d_1");
  249. AB8540_FUNC_GROUPS(batremn, "batremn_d_1");
  250. AB8540_FUNC_GROUPS(service, "service_d_1");
  251. AB8540_FUNC_GROUPS(pwrctrl, "pwrctrl0_d_1", "pwrctrl1_d_1");
  252. AB8540_FUNC_GROUPS(pwmextvibra, "pwmextvibra1_d_1", "pwmextvibra2_d_1");
  253. AB8540_FUNC_GROUPS(gpio_vbat, "gpio1_vbat_d_1", "gpio2_vbat_d_1",
  254. "gpio3_vbat_d_1", "gpio4_vbat_d_1");
  255. AB8540_FUNC_GROUPS(pdm, "pdmclkdat_d_1");
  256. #define FUNCTION(fname) \
  257. { \
  258. .name = #fname, \
  259. .groups = fname##_groups, \
  260. .ngroups = ARRAY_SIZE(fname##_groups), \
  261. }
  262. static const struct abx500_function ab8540_functions[] = {
  263. FUNCTION(sysclkreq),
  264. FUNCTION(gpio),
  265. FUNCTION(pwmout),
  266. FUNCTION(adi1),
  267. FUNCTION(dmic),
  268. FUNCTION(batremn),
  269. FUNCTION(service),
  270. FUNCTION(pwrctrl),
  271. FUNCTION(pwmextvibra),
  272. FUNCTION(gpio_vbat),
  273. FUNCTION(pdm),
  274. };
  275. /*
  276. * this table translates what's is in the AB8540 specification regarding the
  277. * balls alternate functions (as for DB, default, ALT_A, ALT_B and ALT_C).
  278. * ALTERNATE_FUNCTIONS(GPIO_NUMBER, GPIOSEL bit, ALTERNATFUNC bit1,
  279. * ALTERNATEFUNC bit2, ALTA val, ALTB val, ALTC val),
  280. * AB8540 only supports DEFAULT and ALTA functions, so ALTERNATFUNC
  281. * registers is not used
  282. *
  283. */
  284. static struct
  285. alternate_functions ab8540_alternate_functions[AB8540_GPIO_MAX_NUMBER + 1] = {
  286. /* GPIOSEL1 - bit 4-7 reserved */
  287. ALTERNATE_FUNCTIONS(0, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO0 */
  288. ALTERNATE_FUNCTIONS(1, 0, UNUSED, UNUSED, 0, 0, 0), /* GPIO1, altA controlled by bit 0 */
  289. ALTERNATE_FUNCTIONS(2, 1, UNUSED, UNUSED, 0, 0, 0), /* GPIO2, altA controlled by bit 1 */
  290. ALTERNATE_FUNCTIONS(3, 2, UNUSED, UNUSED, 0, 0, 0), /* GPIO3, altA controlled by bit 2*/
  291. ALTERNATE_FUNCTIONS(4, 3, UNUSED, UNUSED, 0, 0, 0), /* GPIO4, altA controlled by bit 3*/
  292. ALTERNATE_FUNCTIONS(5, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO5 */
  293. ALTERNATE_FUNCTIONS(6, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO6 */
  294. ALTERNATE_FUNCTIONS(7, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO7 */
  295. ALTERNATE_FUNCTIONS(8, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO8 */
  296. /* GPIOSEL2 - bit 0-4 reserved */
  297. ALTERNATE_FUNCTIONS(9, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO9 */
  298. ALTERNATE_FUNCTIONS(10, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO10 */
  299. ALTERNATE_FUNCTIONS(11, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO11 */
  300. ALTERNATE_FUNCTIONS(12, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO12 */
  301. ALTERNATE_FUNCTIONS(13, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO13 */
  302. ALTERNATE_FUNCTIONS(14, 5, UNUSED, UNUSED, 0, 0, 0), /* GPIO14, altA controlled by bit 5 */
  303. ALTERNATE_FUNCTIONS(15, 6, UNUSED, UNUSED, 0, 0, 0), /* GPIO15, altA controlled by bit 6 */
  304. ALTERNATE_FUNCTIONS(16, 7, UNUSED, UNUSED, 0, 0, 0), /* GPIO16, altA controlled by bit 7 */
  305. /* GPIOSEL3 - bit 4-7 reserved */
  306. ALTERNATE_FUNCTIONS(17, 0, UNUSED, UNUSED, 0, 0, 0), /* GPIO17, altA controlled by bit 0 */
  307. ALTERNATE_FUNCTIONS(18, 1, UNUSED, UNUSED, 0, 0, 0), /* GPIO18, altA controlled by bit 1 */
  308. ALTERNATE_FUNCTIONS(19, 2, UNUSED, UNUSED, 0, 0, 0), /* GPIO19, altA controlled by bit 2 */
  309. ALTERNATE_FUNCTIONS(20, 3, UNUSED, UNUSED, 0, 0, 0), /* GPIO20, altA controlled by bit 3 */
  310. ALTERNATE_FUNCTIONS(21, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO21 */
  311. ALTERNATE_FUNCTIONS(22, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO22 */
  312. ALTERNATE_FUNCTIONS(23, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO23 */
  313. ALTERNATE_FUNCTIONS(24, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO24 */
  314. /* GPIOSEL4 - bit 0-1 reserved */
  315. ALTERNATE_FUNCTIONS(25, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO25 */
  316. ALTERNATE_FUNCTIONS(26, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO26 */
  317. ALTERNATE_FUNCTIONS(27, 2, UNUSED, UNUSED, 0, 0, 0), /* GPIO27, altA controlled by bit 2 */
  318. ALTERNATE_FUNCTIONS(28, 3, UNUSED, UNUSED, 0, 0, 0), /* GPIO28, altA controlled by bit 3 */
  319. ALTERNATE_FUNCTIONS(29, 4, UNUSED, UNUSED, 0, 0, 0), /* GPIO29, altA controlled by bit 4 */
  320. ALTERNATE_FUNCTIONS(30, 5, UNUSED, UNUSED, 0, 0, 0), /* GPIO30, altA controlled by bit 5 */
  321. ALTERNATE_FUNCTIONS(31, 6, UNUSED, UNUSED, 0, 0, 0), /* GPIO31, altA controlled by bit 6 */
  322. ALTERNATE_FUNCTIONS(32, 7, UNUSED, UNUSED, 0, 0, 0), /* GPIO32, altA controlled by bit 7 */
  323. /* GPIOSEL5 - bit 0-7 reserved */
  324. ALTERNATE_FUNCTIONS(33, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO33 */
  325. ALTERNATE_FUNCTIONS(34, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO34 */
  326. ALTERNATE_FUNCTIONS(35, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO35 */
  327. ALTERNATE_FUNCTIONS(36, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO36 */
  328. ALTERNATE_FUNCTIONS(37, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO37 */
  329. ALTERNATE_FUNCTIONS(38, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO38 */
  330. ALTERNATE_FUNCTIONS(39, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO39 */
  331. ALTERNATE_FUNCTIONS(40, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO40 */
  332. /* GPIOSEL6 - bit 0 reserved */
  333. ALTERNATE_FUNCTIONS(41, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO41 */
  334. ALTERNATE_FUNCTIONS(42, 1, UNUSED, UNUSED, 0, 0, 0), /* GPIO42, altA controlled by bit 1 */
  335. ALTERNATE_FUNCTIONS(43, 2, UNUSED, UNUSED, 0, 0, 0), /* GPIO43, altA controlled by bit 2 */
  336. ALTERNATE_FUNCTIONS(44, 3, UNUSED, UNUSED, 0, 0, 0), /* GPIO44, altA controlled by bit 3 */
  337. ALTERNATE_FUNCTIONS(45, 4, UNUSED, UNUSED, 0, 0, 0), /* GPIO45, altA controlled by bit 4 */
  338. ALTERNATE_FUNCTIONS(46, 5, UNUSED, UNUSED, 0, 0, 0), /* GPIO46, altA controlled by bit 5 */
  339. ALTERNATE_FUNCTIONS(47, 6, UNUSED, UNUSED, 0, 0, 0), /* GPIO47, altA controlled by bit 6 */
  340. ALTERNATE_FUNCTIONS(48, 7, UNUSED, UNUSED, 0, 0, 0), /* GPIO48, altA controlled by bit 7 */
  341. /* GPIOSEL7 - bit 0-1 reserved */
  342. ALTERNATE_FUNCTIONS(49, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO49 */
  343. ALTERNATE_FUNCTIONS(50, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO50 */
  344. ALTERNATE_FUNCTIONS(51, 2, UNUSED, UNUSED, 0, 0, 0), /* GPIO51, altA controlled by bit 2 */
  345. ALTERNATE_FUNCTIONS(52, 3, UNUSED, UNUSED, 0, 0, 0), /* GPIO52, altA controlled by bit 3 */
  346. ALTERNATE_FUNCTIONS(53, 4, UNUSED, UNUSED, 0, 0, 0), /* GPIO53, altA controlled by bit 4 */
  347. ALTERNATE_FUNCTIONS(54, 5, UNUSED, UNUSED, 0, 0, 0), /* GPIO54, altA controlled by bit 5 */
  348. ALTERNATE_FUNCTIONS(55, 6, UNUSED, UNUSED, 0, 0, 0), /* GPIO55, altA controlled by bit 6 */
  349. ALTERNATE_FUNCTIONS(56, 7, UNUSED, UNUSED, 0, 0, 0), /* GPIO56, altA controlled by bit 7 */
  350. };
  351. static struct pullud ab8540_pullud = {
  352. .first_pin = 51, /* GPIO1_VBAT */
  353. .last_pin = 54, /* GPIO4_VBAT */
  354. };
  355. /*
  356. * For AB8540 Only some GPIOs are interrupt capable:
  357. * GPIO43 to GPIO44
  358. * GPIO51 to GPIO54
  359. */
  360. static struct abx500_gpio_irq_cluster ab8540_gpio_irq_cluster[] = {
  361. GPIO_IRQ_CLUSTER(43, 43, AB8540_INT_GPIO43F),
  362. GPIO_IRQ_CLUSTER(44, 44, AB8540_INT_GPIO44F),
  363. GPIO_IRQ_CLUSTER(51, 54, AB9540_INT_GPIO51R),
  364. };
  365. static struct abx500_pinctrl_soc_data ab8540_soc = {
  366. .gpio_ranges = ab8540_pinranges,
  367. .gpio_num_ranges = ARRAY_SIZE(ab8540_pinranges),
  368. .pins = ab8540_pins,
  369. .npins = ARRAY_SIZE(ab8540_pins),
  370. .functions = ab8540_functions,
  371. .nfunctions = ARRAY_SIZE(ab8540_functions),
  372. .groups = ab8540_groups,
  373. .ngroups = ARRAY_SIZE(ab8540_groups),
  374. .alternate_functions = ab8540_alternate_functions,
  375. .pullud = &ab8540_pullud,
  376. .gpio_irq_cluster = ab8540_gpio_irq_cluster,
  377. .ngpio_irq_cluster = ARRAY_SIZE(ab8540_gpio_irq_cluster),
  378. .irq_gpio_rising_offset = AB8540_INT_GPIO43R,
  379. .irq_gpio_falling_offset = AB8540_INT_GPIO43F,
  380. .irq_gpio_factor = 2,
  381. };
  382. void
  383. abx500_pinctrl_ab8540_init(struct abx500_pinctrl_soc_data **soc)
  384. {
  385. *soc = &ab8540_soc;
  386. }