pinctrl-ab8500.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485
  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 AB8500_PIN_T10 ABX500_GPIO(1)
  18. #define AB8500_PIN_T9 ABX500_GPIO(2)
  19. #define AB8500_PIN_U9 ABX500_GPIO(3)
  20. #define AB8500_PIN_W2 ABX500_GPIO(4)
  21. /* hole */
  22. #define AB8500_PIN_Y18 ABX500_GPIO(6)
  23. #define AB8500_PIN_AA20 ABX500_GPIO(7)
  24. #define AB8500_PIN_W18 ABX500_GPIO(8)
  25. #define AB8500_PIN_AA19 ABX500_GPIO(9)
  26. #define AB8500_PIN_U17 ABX500_GPIO(10)
  27. #define AB8500_PIN_AA18 ABX500_GPIO(11)
  28. #define AB8500_PIN_U16 ABX500_GPIO(12)
  29. #define AB8500_PIN_W17 ABX500_GPIO(13)
  30. #define AB8500_PIN_F14 ABX500_GPIO(14)
  31. #define AB8500_PIN_B17 ABX500_GPIO(15)
  32. #define AB8500_PIN_F15 ABX500_GPIO(16)
  33. #define AB8500_PIN_P5 ABX500_GPIO(17)
  34. #define AB8500_PIN_R5 ABX500_GPIO(18)
  35. #define AB8500_PIN_U5 ABX500_GPIO(19)
  36. #define AB8500_PIN_T5 ABX500_GPIO(20)
  37. #define AB8500_PIN_H19 ABX500_GPIO(21)
  38. #define AB8500_PIN_G20 ABX500_GPIO(22)
  39. #define AB8500_PIN_G19 ABX500_GPIO(23)
  40. #define AB8500_PIN_T14 ABX500_GPIO(24)
  41. #define AB8500_PIN_R16 ABX500_GPIO(25)
  42. #define AB8500_PIN_M16 ABX500_GPIO(26)
  43. #define AB8500_PIN_J6 ABX500_GPIO(27)
  44. #define AB8500_PIN_K6 ABX500_GPIO(28)
  45. #define AB8500_PIN_G6 ABX500_GPIO(29)
  46. #define AB8500_PIN_H6 ABX500_GPIO(30)
  47. #define AB8500_PIN_F5 ABX500_GPIO(31)
  48. #define AB8500_PIN_G5 ABX500_GPIO(32)
  49. /* hole */
  50. #define AB8500_PIN_R17 ABX500_GPIO(34)
  51. #define AB8500_PIN_W15 ABX500_GPIO(35)
  52. #define AB8500_PIN_A17 ABX500_GPIO(36)
  53. #define AB8500_PIN_E15 ABX500_GPIO(37)
  54. #define AB8500_PIN_C17 ABX500_GPIO(38)
  55. #define AB8500_PIN_E16 ABX500_GPIO(39)
  56. #define AB8500_PIN_T19 ABX500_GPIO(40)
  57. #define AB8500_PIN_U19 ABX500_GPIO(41)
  58. #define AB8500_PIN_U2 ABX500_GPIO(42)
  59. /* indicates the highest GPIO number */
  60. #define AB8500_GPIO_MAX_NUMBER 42
  61. /*
  62. * The names of the pins are denoted by GPIO number and ball name, even
  63. * though they can be used for other things than GPIO, this is the first
  64. * column in the table of the data sheet and often used on schematics and
  65. * such.
  66. */
  67. static const struct pinctrl_pin_desc ab8500_pins[] = {
  68. PINCTRL_PIN(AB8500_PIN_T10, "GPIO1_T10"),
  69. PINCTRL_PIN(AB8500_PIN_T9, "GPIO2_T9"),
  70. PINCTRL_PIN(AB8500_PIN_U9, "GPIO3_U9"),
  71. PINCTRL_PIN(AB8500_PIN_W2, "GPIO4_W2"),
  72. /* hole */
  73. PINCTRL_PIN(AB8500_PIN_Y18, "GPIO6_Y18"),
  74. PINCTRL_PIN(AB8500_PIN_AA20, "GPIO7_AA20"),
  75. PINCTRL_PIN(AB8500_PIN_W18, "GPIO8_W18"),
  76. PINCTRL_PIN(AB8500_PIN_AA19, "GPIO9_AA19"),
  77. PINCTRL_PIN(AB8500_PIN_U17, "GPIO10_U17"),
  78. PINCTRL_PIN(AB8500_PIN_AA18, "GPIO11_AA18"),
  79. PINCTRL_PIN(AB8500_PIN_U16, "GPIO12_U16"),
  80. PINCTRL_PIN(AB8500_PIN_W17, "GPIO13_W17"),
  81. PINCTRL_PIN(AB8500_PIN_F14, "GPIO14_F14"),
  82. PINCTRL_PIN(AB8500_PIN_B17, "GPIO15_B17"),
  83. PINCTRL_PIN(AB8500_PIN_F15, "GPIO16_F15"),
  84. PINCTRL_PIN(AB8500_PIN_P5, "GPIO17_P5"),
  85. PINCTRL_PIN(AB8500_PIN_R5, "GPIO18_R5"),
  86. PINCTRL_PIN(AB8500_PIN_U5, "GPIO19_U5"),
  87. PINCTRL_PIN(AB8500_PIN_T5, "GPIO20_T5"),
  88. PINCTRL_PIN(AB8500_PIN_H19, "GPIO21_H19"),
  89. PINCTRL_PIN(AB8500_PIN_G20, "GPIO22_G20"),
  90. PINCTRL_PIN(AB8500_PIN_G19, "GPIO23_G19"),
  91. PINCTRL_PIN(AB8500_PIN_T14, "GPIO24_T14"),
  92. PINCTRL_PIN(AB8500_PIN_R16, "GPIO25_R16"),
  93. PINCTRL_PIN(AB8500_PIN_M16, "GPIO26_M16"),
  94. PINCTRL_PIN(AB8500_PIN_J6, "GPIO27_J6"),
  95. PINCTRL_PIN(AB8500_PIN_K6, "GPIO28_K6"),
  96. PINCTRL_PIN(AB8500_PIN_G6, "GPIO29_G6"),
  97. PINCTRL_PIN(AB8500_PIN_H6, "GPIO30_H6"),
  98. PINCTRL_PIN(AB8500_PIN_F5, "GPIO31_F5"),
  99. PINCTRL_PIN(AB8500_PIN_G5, "GPIO32_G5"),
  100. /* hole */
  101. PINCTRL_PIN(AB8500_PIN_R17, "GPIO34_R17"),
  102. PINCTRL_PIN(AB8500_PIN_W15, "GPIO35_W15"),
  103. PINCTRL_PIN(AB8500_PIN_A17, "GPIO36_A17"),
  104. PINCTRL_PIN(AB8500_PIN_E15, "GPIO37_E15"),
  105. PINCTRL_PIN(AB8500_PIN_C17, "GPIO38_C17"),
  106. PINCTRL_PIN(AB8500_PIN_E16, "GPIO39_E16"),
  107. PINCTRL_PIN(AB8500_PIN_T19, "GPIO40_T19"),
  108. PINCTRL_PIN(AB8500_PIN_U19, "GPIO41_U19"),
  109. PINCTRL_PIN(AB8500_PIN_U2, "GPIO42_U2"),
  110. };
  111. /*
  112. * Maps local GPIO offsets to local pin numbers
  113. */
  114. static const struct abx500_pinrange ab8500_pinranges[] = {
  115. ABX500_PINRANGE(1, 4, ABX500_ALT_A),
  116. ABX500_PINRANGE(6, 4, ABX500_ALT_A),
  117. ABX500_PINRANGE(10, 4, ABX500_DEFAULT),
  118. ABX500_PINRANGE(14, 12, ABX500_ALT_A),
  119. ABX500_PINRANGE(26, 1, ABX500_DEFAULT),
  120. ABX500_PINRANGE(27, 6, ABX500_ALT_A),
  121. ABX500_PINRANGE(34, 1, ABX500_ALT_A),
  122. ABX500_PINRANGE(35, 1, ABX500_DEFAULT),
  123. ABX500_PINRANGE(36, 7, ABX500_ALT_A),
  124. };
  125. /*
  126. * Read the pin group names like this:
  127. * sysclkreq2_d_1 = first groups of pins for sysclkreq2 on default function
  128. *
  129. * The groups are arranged as sets per altfunction column, so we can
  130. * mux in one group at a time by selecting the same altfunction for them
  131. * all. When functions require pins on different altfunctions, you need
  132. * to combine several groups.
  133. */
  134. /* default column */
  135. static const unsigned sysclkreq2_d_1_pins[] = { AB8500_PIN_T10 };
  136. static const unsigned sysclkreq3_d_1_pins[] = { AB8500_PIN_T9 };
  137. static const unsigned sysclkreq4_d_1_pins[] = { AB8500_PIN_U9 };
  138. static const unsigned sysclkreq6_d_1_pins[] = { AB8500_PIN_W2 };
  139. static const unsigned ycbcr0123_d_1_pins[] = { AB8500_PIN_Y18, AB8500_PIN_AA20,
  140. AB8500_PIN_W18, AB8500_PIN_AA19};
  141. static const unsigned gpio10_d_1_pins[] = { AB8500_PIN_U17 };
  142. static const unsigned gpio11_d_1_pins[] = { AB8500_PIN_AA18 };
  143. static const unsigned gpio12_d_1_pins[] = { AB8500_PIN_U16 };
  144. static const unsigned gpio13_d_1_pins[] = { AB8500_PIN_W17 };
  145. static const unsigned pwmout1_d_1_pins[] = { AB8500_PIN_F14 };
  146. static const unsigned pwmout2_d_1_pins[] = { AB8500_PIN_B17 };
  147. static const unsigned pwmout3_d_1_pins[] = { AB8500_PIN_F15 };
  148. /* audio data interface 1*/
  149. static const unsigned adi1_d_1_pins[] = { AB8500_PIN_P5, AB8500_PIN_R5,
  150. AB8500_PIN_U5, AB8500_PIN_T5 };
  151. /* USBUICC */
  152. static const unsigned usbuicc_d_1_pins[] = { AB8500_PIN_H19, AB8500_PIN_G20,
  153. AB8500_PIN_G19 };
  154. static const unsigned sysclkreq7_d_1_pins[] = { AB8500_PIN_T14 };
  155. static const unsigned sysclkreq8_d_1_pins[] = { AB8500_PIN_R16 };
  156. static const unsigned gpio26_d_1_pins[] = { AB8500_PIN_M16 };
  157. /* Digital microphone 1 and 2 */
  158. static const unsigned dmic12_d_1_pins[] = { AB8500_PIN_J6, AB8500_PIN_K6 };
  159. /* Digital microphone 3 and 4 */
  160. static const unsigned dmic34_d_1_pins[] = { AB8500_PIN_G6, AB8500_PIN_H6 };
  161. /* Digital microphone 5 and 6 */
  162. static const unsigned dmic56_d_1_pins[] = { AB8500_PIN_F5, AB8500_PIN_G5 };
  163. static const unsigned extcpena_d_1_pins[] = { AB8500_PIN_R17 };
  164. static const unsigned gpio35_d_1_pins[] = { AB8500_PIN_W15 };
  165. /* APE SPI */
  166. static const unsigned apespi_d_1_pins[] = { AB8500_PIN_A17, AB8500_PIN_E15,
  167. AB8500_PIN_C17, AB8500_PIN_E16};
  168. /* modem SDA/SCL */
  169. static const unsigned modsclsda_d_1_pins[] = { AB8500_PIN_T19, AB8500_PIN_U19 };
  170. static const unsigned sysclkreq5_d_1_pins[] = { AB8500_PIN_U2 };
  171. /* Altfunction A column */
  172. static const unsigned gpio1_a_1_pins[] = { AB8500_PIN_T10 };
  173. static const unsigned gpio2_a_1_pins[] = { AB8500_PIN_T9 };
  174. static const unsigned gpio3_a_1_pins[] = { AB8500_PIN_U9 };
  175. static const unsigned gpio4_a_1_pins[] = { AB8500_PIN_W2 };
  176. static const unsigned gpio6_a_1_pins[] = { AB8500_PIN_Y18 };
  177. static const unsigned gpio7_a_1_pins[] = { AB8500_PIN_AA20 };
  178. static const unsigned gpio8_a_1_pins[] = { AB8500_PIN_W18 };
  179. static const unsigned gpio9_a_1_pins[] = { AB8500_PIN_AA19 };
  180. /* YCbCr4 YCbCr5 YCbCr6 YCbCr7*/
  181. static const unsigned ycbcr4567_a_1_pins[] = { AB8500_PIN_U17, AB8500_PIN_AA18,
  182. AB8500_PIN_U16, AB8500_PIN_W17};
  183. static const unsigned gpio14_a_1_pins[] = { AB8500_PIN_F14 };
  184. static const unsigned gpio15_a_1_pins[] = { AB8500_PIN_B17 };
  185. static const unsigned gpio16_a_1_pins[] = { AB8500_PIN_F15 };
  186. static const unsigned gpio17_a_1_pins[] = { AB8500_PIN_P5 };
  187. static const unsigned gpio18_a_1_pins[] = { AB8500_PIN_R5 };
  188. static const unsigned gpio19_a_1_pins[] = { AB8500_PIN_U5 };
  189. static const unsigned gpio20_a_1_pins[] = { AB8500_PIN_T5 };
  190. static const unsigned gpio21_a_1_pins[] = { AB8500_PIN_H19 };
  191. static const unsigned gpio22_a_1_pins[] = { AB8500_PIN_G20 };
  192. static const unsigned gpio23_a_1_pins[] = { AB8500_PIN_G19 };
  193. static const unsigned gpio24_a_1_pins[] = { AB8500_PIN_T14 };
  194. static const unsigned gpio25_a_1_pins[] = { AB8500_PIN_R16 };
  195. static const unsigned gpio27_a_1_pins[] = { AB8500_PIN_J6 };
  196. static const unsigned gpio28_a_1_pins[] = { AB8500_PIN_K6 };
  197. static const unsigned gpio29_a_1_pins[] = { AB8500_PIN_G6 };
  198. static const unsigned gpio30_a_1_pins[] = { AB8500_PIN_H6 };
  199. static const unsigned gpio31_a_1_pins[] = { AB8500_PIN_F5 };
  200. static const unsigned gpio32_a_1_pins[] = { AB8500_PIN_G5 };
  201. static const unsigned gpio34_a_1_pins[] = { AB8500_PIN_R17 };
  202. static const unsigned gpio36_a_1_pins[] = { AB8500_PIN_A17 };
  203. static const unsigned gpio37_a_1_pins[] = { AB8500_PIN_E15 };
  204. static const unsigned gpio38_a_1_pins[] = { AB8500_PIN_C17 };
  205. static const unsigned gpio39_a_1_pins[] = { AB8500_PIN_E16 };
  206. static const unsigned gpio40_a_1_pins[] = { AB8500_PIN_T19 };
  207. static const unsigned gpio41_a_1_pins[] = { AB8500_PIN_U19 };
  208. static const unsigned gpio42_a_1_pins[] = { AB8500_PIN_U2 };
  209. /* Altfunction B colum */
  210. static const unsigned hiqclkena_b_1_pins[] = { AB8500_PIN_U17 };
  211. static const unsigned usbuiccpd_b_1_pins[] = { AB8500_PIN_AA18 };
  212. static const unsigned i2ctrig1_b_1_pins[] = { AB8500_PIN_U16 };
  213. static const unsigned i2ctrig2_b_1_pins[] = { AB8500_PIN_W17 };
  214. /* Altfunction C column */
  215. static const unsigned usbvdat_c_1_pins[] = { AB8500_PIN_W17 };
  216. #define AB8500_PIN_GROUP(a, b) { .name = #a, .pins = a##_pins, \
  217. .npins = ARRAY_SIZE(a##_pins), .altsetting = b }
  218. static const struct abx500_pingroup ab8500_groups[] = {
  219. /* default column */
  220. AB8500_PIN_GROUP(sysclkreq2_d_1, ABX500_DEFAULT),
  221. AB8500_PIN_GROUP(sysclkreq3_d_1, ABX500_DEFAULT),
  222. AB8500_PIN_GROUP(sysclkreq4_d_1, ABX500_DEFAULT),
  223. AB8500_PIN_GROUP(sysclkreq6_d_1, ABX500_DEFAULT),
  224. AB8500_PIN_GROUP(ycbcr0123_d_1, ABX500_DEFAULT),
  225. AB8500_PIN_GROUP(gpio10_d_1, ABX500_DEFAULT),
  226. AB8500_PIN_GROUP(gpio11_d_1, ABX500_DEFAULT),
  227. AB8500_PIN_GROUP(gpio12_d_1, ABX500_DEFAULT),
  228. AB8500_PIN_GROUP(gpio13_d_1, ABX500_DEFAULT),
  229. AB8500_PIN_GROUP(pwmout1_d_1, ABX500_DEFAULT),
  230. AB8500_PIN_GROUP(pwmout2_d_1, ABX500_DEFAULT),
  231. AB8500_PIN_GROUP(pwmout3_d_1, ABX500_DEFAULT),
  232. AB8500_PIN_GROUP(adi1_d_1, ABX500_DEFAULT),
  233. AB8500_PIN_GROUP(usbuicc_d_1, ABX500_DEFAULT),
  234. AB8500_PIN_GROUP(sysclkreq7_d_1, ABX500_DEFAULT),
  235. AB8500_PIN_GROUP(sysclkreq8_d_1, ABX500_DEFAULT),
  236. AB8500_PIN_GROUP(gpio26_d_1, ABX500_DEFAULT),
  237. AB8500_PIN_GROUP(dmic12_d_1, ABX500_DEFAULT),
  238. AB8500_PIN_GROUP(dmic34_d_1, ABX500_DEFAULT),
  239. AB8500_PIN_GROUP(dmic56_d_1, ABX500_DEFAULT),
  240. AB8500_PIN_GROUP(extcpena_d_1, ABX500_DEFAULT),
  241. AB8500_PIN_GROUP(gpio35_d_1, ABX500_DEFAULT),
  242. AB8500_PIN_GROUP(apespi_d_1, ABX500_DEFAULT),
  243. AB8500_PIN_GROUP(modsclsda_d_1, ABX500_DEFAULT),
  244. AB8500_PIN_GROUP(sysclkreq5_d_1, ABX500_DEFAULT),
  245. /* Altfunction A column */
  246. AB8500_PIN_GROUP(gpio1_a_1, ABX500_ALT_A),
  247. AB8500_PIN_GROUP(gpio2_a_1, ABX500_ALT_A),
  248. AB8500_PIN_GROUP(gpio3_a_1, ABX500_ALT_A),
  249. AB8500_PIN_GROUP(gpio4_a_1, ABX500_ALT_A),
  250. AB8500_PIN_GROUP(gpio6_a_1, ABX500_ALT_A),
  251. AB8500_PIN_GROUP(gpio7_a_1, ABX500_ALT_A),
  252. AB8500_PIN_GROUP(gpio8_a_1, ABX500_ALT_A),
  253. AB8500_PIN_GROUP(gpio9_a_1, ABX500_ALT_A),
  254. AB8500_PIN_GROUP(ycbcr4567_a_1, ABX500_ALT_A),
  255. AB8500_PIN_GROUP(gpio14_a_1, ABX500_ALT_A),
  256. AB8500_PIN_GROUP(gpio15_a_1, ABX500_ALT_A),
  257. AB8500_PIN_GROUP(gpio16_a_1, ABX500_ALT_A),
  258. AB8500_PIN_GROUP(gpio17_a_1, ABX500_ALT_A),
  259. AB8500_PIN_GROUP(gpio18_a_1, ABX500_ALT_A),
  260. AB8500_PIN_GROUP(gpio19_a_1, ABX500_ALT_A),
  261. AB8500_PIN_GROUP(gpio20_a_1, ABX500_ALT_A),
  262. AB8500_PIN_GROUP(gpio21_a_1, ABX500_ALT_A),
  263. AB8500_PIN_GROUP(gpio22_a_1, ABX500_ALT_A),
  264. AB8500_PIN_GROUP(gpio23_a_1, ABX500_ALT_A),
  265. AB8500_PIN_GROUP(gpio24_a_1, ABX500_ALT_A),
  266. AB8500_PIN_GROUP(gpio25_a_1, ABX500_ALT_A),
  267. AB8500_PIN_GROUP(gpio27_a_1, ABX500_ALT_A),
  268. AB8500_PIN_GROUP(gpio28_a_1, ABX500_ALT_A),
  269. AB8500_PIN_GROUP(gpio29_a_1, ABX500_ALT_A),
  270. AB8500_PIN_GROUP(gpio30_a_1, ABX500_ALT_A),
  271. AB8500_PIN_GROUP(gpio31_a_1, ABX500_ALT_A),
  272. AB8500_PIN_GROUP(gpio32_a_1, ABX500_ALT_A),
  273. AB8500_PIN_GROUP(gpio34_a_1, ABX500_ALT_A),
  274. AB8500_PIN_GROUP(gpio36_a_1, ABX500_ALT_A),
  275. AB8500_PIN_GROUP(gpio37_a_1, ABX500_ALT_A),
  276. AB8500_PIN_GROUP(gpio38_a_1, ABX500_ALT_A),
  277. AB8500_PIN_GROUP(gpio39_a_1, ABX500_ALT_A),
  278. AB8500_PIN_GROUP(gpio40_a_1, ABX500_ALT_A),
  279. AB8500_PIN_GROUP(gpio41_a_1, ABX500_ALT_A),
  280. AB8500_PIN_GROUP(gpio42_a_1, ABX500_ALT_A),
  281. /* Altfunction B column */
  282. AB8500_PIN_GROUP(hiqclkena_b_1, ABX500_ALT_B),
  283. AB8500_PIN_GROUP(usbuiccpd_b_1, ABX500_ALT_B),
  284. AB8500_PIN_GROUP(i2ctrig1_b_1, ABX500_ALT_B),
  285. AB8500_PIN_GROUP(i2ctrig2_b_1, ABX500_ALT_B),
  286. /* Altfunction C column */
  287. AB8500_PIN_GROUP(usbvdat_c_1, ABX500_ALT_C),
  288. };
  289. /* We use this macro to define the groups applicable to a function */
  290. #define AB8500_FUNC_GROUPS(a, b...) \
  291. static const char * const a##_groups[] = { b };
  292. AB8500_FUNC_GROUPS(sysclkreq, "sysclkreq2_d_1", "sysclkreq3_d_1",
  293. "sysclkreq4_d_1", "sysclkreq5_d_1", "sysclkreq6_d_1",
  294. "sysclkreq7_d_1", "sysclkreq8_d_1");
  295. AB8500_FUNC_GROUPS(ycbcr, "ycbcr0123_d_1", "ycbcr4567_a_1");
  296. AB8500_FUNC_GROUPS(gpio, "gpio1_a_1", "gpio2_a_1", "gpio3_a_1", "gpio4_a_1",
  297. "gpio6_a_1", "gpio7_a_1", "gpio8_a_1", "gpio9_a_1",
  298. "gpio10_d_1", "gpio11_d_1", "gpio12_d_1", "gpio13_d_1",
  299. "gpio14_a_1", "gpio15_a_1", "gpio16_a_1", "gpio17_a_1",
  300. "gpio18_a_1", "gpio19_a_1", "gpio20_a_1", "gpio21_a_1",
  301. "gpio22_a_1", "gpio23_a_1", "gpio24_a_1", "gpio25_a_1",
  302. "gpio26_d_1", "gpio27_a_1", "gpio28_a_1", "gpio29_a_1",
  303. "gpio30_a_1", "gpio31_a_1", "gpio32_a_1", "gpio34_a_1",
  304. "gpio35_d_1", "gpio36_a_1", "gpio37_a_1", "gpio38_a_1",
  305. "gpio39_a_1", "gpio40_a_1", "gpio41_a_1", "gpio42_a_1");
  306. AB8500_FUNC_GROUPS(pwmout, "pwmout1_d_1", "pwmout2_d_1", "pwmout3_d_1");
  307. AB8500_FUNC_GROUPS(adi1, "adi1_d_1");
  308. AB8500_FUNC_GROUPS(usbuicc, "usbuicc_d_1", "usbuiccpd_b_1");
  309. AB8500_FUNC_GROUPS(dmic, "dmic12_d_1", "dmic34_d_1", "dmic56_d_1");
  310. AB8500_FUNC_GROUPS(extcpena, "extcpena_d_1");
  311. AB8500_FUNC_GROUPS(apespi, "apespi_d_1");
  312. AB8500_FUNC_GROUPS(modsclsda, "modsclsda_d_1");
  313. AB8500_FUNC_GROUPS(hiqclkena, "hiqclkena_b_1");
  314. AB8500_FUNC_GROUPS(i2ctrig, "i2ctrig1_b_1", "i2ctrig2_b_1");
  315. AB8500_FUNC_GROUPS(usbvdat, "usbvdat_c_1");
  316. #define FUNCTION(fname) \
  317. { \
  318. .name = #fname, \
  319. .groups = fname##_groups, \
  320. .ngroups = ARRAY_SIZE(fname##_groups), \
  321. }
  322. static const struct abx500_function ab8500_functions[] = {
  323. FUNCTION(sysclkreq),
  324. FUNCTION(ycbcr),
  325. FUNCTION(gpio),
  326. FUNCTION(pwmout),
  327. FUNCTION(adi1),
  328. FUNCTION(usbuicc),
  329. FUNCTION(dmic),
  330. FUNCTION(extcpena),
  331. FUNCTION(apespi),
  332. FUNCTION(modsclsda),
  333. FUNCTION(hiqclkena),
  334. FUNCTION(i2ctrig),
  335. FUNCTION(usbvdat),
  336. };
  337. /*
  338. * this table translates what's is in the AB8500 specification regarding the
  339. * balls alternate functions (as for DB, default, ALT_A, ALT_B and ALT_C).
  340. * ALTERNATE_FUNCTIONS(GPIO_NUMBER, GPIOSEL bit, ALTERNATFUNC bit1,
  341. * ALTERNATEFUNC bit2, ALTA val, ALTB val, ALTC val),
  342. *
  343. * example :
  344. *
  345. * ALTERNATE_FUNCTIONS(13, 4, 3, 4, 0, 1 ,2),
  346. * means that pin AB8500_PIN_W17 (pin 13) supports 4 mux (default/ALT_A,
  347. * ALT_B and ALT_C), so GPIOSEL and ALTERNATFUNC registers are used to
  348. * select the mux. ALTA, ALTB and ALTC val indicates values to write in
  349. * ALTERNATFUNC register. We need to specifies these values as SOC
  350. * designers didn't apply the same logic on how to select mux in the
  351. * ABx500 family.
  352. *
  353. * As this pins supports at least ALT_B mux, default mux is
  354. * selected by writing 1 in GPIOSEL bit :
  355. *
  356. * | GPIOSEL bit=4 | alternatfunc bit2=4 | alternatfunc bit1=3
  357. * default | 1 | 0 | 0
  358. * alt_A | 0 | 0 | 0
  359. * alt_B | 0 | 0 | 1
  360. * alt_C | 0 | 1 | 0
  361. *
  362. * ALTERNATE_FUNCTIONS(8, 7, UNUSED, UNUSED),
  363. * means that pin AB8500_PIN_W18 (pin 8) supports 2 mux, so only GPIOSEL
  364. * register is used to select the mux. As this pins doesn't support at
  365. * least ALT_B mux, default mux is by writing 0 in GPIOSEL bit :
  366. *
  367. * | GPIOSEL bit=7 | alternatfunc bit2= | alternatfunc bit1=
  368. * default | 0 | 0 | 0
  369. * alt_A | 1 | 0 | 0
  370. */
  371. static struct
  372. alternate_functions ab8500_alternate_functions[AB8500_GPIO_MAX_NUMBER + 1] = {
  373. ALTERNATE_FUNCTIONS(0, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO0 */
  374. ALTERNATE_FUNCTIONS(1, 0, UNUSED, UNUSED, 0, 0, 0), /* GPIO1, altA controlled by bit 0 */
  375. ALTERNATE_FUNCTIONS(2, 1, UNUSED, UNUSED, 0, 0, 0), /* GPIO2, altA controlled by bit 1 */
  376. ALTERNATE_FUNCTIONS(3, 2, UNUSED, UNUSED, 0, 0, 0), /* GPIO3, altA controlled by bit 2*/
  377. ALTERNATE_FUNCTIONS(4, 3, UNUSED, UNUSED, 0, 0, 0), /* GPIO4, altA controlled by bit 3*/
  378. /* bit 4 reserved */
  379. ALTERNATE_FUNCTIONS(5, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO5 */
  380. ALTERNATE_FUNCTIONS(6, 5, UNUSED, UNUSED, 0, 0, 0), /* GPIO6, altA controlled by bit 5*/
  381. ALTERNATE_FUNCTIONS(7, 6, UNUSED, UNUSED, 0, 0, 0), /* GPIO7, altA controlled by bit 6*/
  382. ALTERNATE_FUNCTIONS(8, 7, UNUSED, UNUSED, 0, 0, 0), /* GPIO8, altA controlled by bit 7*/
  383. ALTERNATE_FUNCTIONS(9, 0, UNUSED, UNUSED, 0, 0, 0), /* GPIO9, altA controlled by bit 0*/
  384. ALTERNATE_FUNCTIONS(10, 1, 0, UNUSED, 0, 1, 0), /* GPIO10, altA and altB controlled by bit 0 */
  385. ALTERNATE_FUNCTIONS(11, 2, 1, UNUSED, 0, 1, 0), /* GPIO11, altA and altB controlled by bit 1 */
  386. ALTERNATE_FUNCTIONS(12, 3, 2, UNUSED, 0, 1, 0), /* GPIO12, altA and altB controlled by bit 2 */
  387. ALTERNATE_FUNCTIONS(13, 4, 3, 4, 0, 1, 2), /* GPIO13, altA altB and altC controlled by bit 3 and 4 */
  388. ALTERNATE_FUNCTIONS(14, 5, UNUSED, UNUSED, 0, 0, 0), /* GPIO14, altA controlled by bit 5 */
  389. ALTERNATE_FUNCTIONS(15, 6, UNUSED, UNUSED, 0, 0, 0), /* GPIO15, altA controlled by bit 6 */
  390. ALTERNATE_FUNCTIONS(16, 7, UNUSED, UNUSED, 0, 0, 0), /* GPIO16, altA controlled by bit 7 */
  391. /*
  392. * pins 17 to 20 are special case, only bit 0 is used to select
  393. * alternate function for these 4 pins.
  394. * bits 1 to 3 are reserved
  395. */
  396. ALTERNATE_FUNCTIONS(17, 0, UNUSED, UNUSED, 0, 0, 0), /* GPIO17, altA controlled by bit 0 */
  397. ALTERNATE_FUNCTIONS(18, 0, UNUSED, UNUSED, 0, 0, 0), /* GPIO18, altA controlled by bit 0 */
  398. ALTERNATE_FUNCTIONS(19, 0, UNUSED, UNUSED, 0, 0, 0), /* GPIO19, altA controlled by bit 0 */
  399. ALTERNATE_FUNCTIONS(20, 0, UNUSED, UNUSED, 0, 0, 0), /* GPIO20, altA controlled by bit 0 */
  400. ALTERNATE_FUNCTIONS(21, 4, UNUSED, UNUSED, 0, 0, 0), /* GPIO21, altA controlled by bit 4 */
  401. ALTERNATE_FUNCTIONS(22, 5, UNUSED, UNUSED, 0, 0, 0), /* GPIO22, altA controlled by bit 5 */
  402. ALTERNATE_FUNCTIONS(23, 6, UNUSED, UNUSED, 0, 0, 0), /* GPIO23, altA controlled by bit 6 */
  403. ALTERNATE_FUNCTIONS(24, 7, UNUSED, UNUSED, 0, 0, 0), /* GPIO24, altA controlled by bit 7 */
  404. ALTERNATE_FUNCTIONS(25, 0, UNUSED, UNUSED, 0, 0, 0), /* GPIO25, altA controlled by bit 0 */
  405. /* pin 26 special case, no alternate function, bit 1 reserved */
  406. ALTERNATE_FUNCTIONS(26, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* GPIO26 */
  407. ALTERNATE_FUNCTIONS(27, 2, UNUSED, UNUSED, 0, 0, 0), /* GPIO27, altA controlled by bit 2 */
  408. ALTERNATE_FUNCTIONS(28, 3, UNUSED, UNUSED, 0, 0, 0), /* GPIO28, altA controlled by bit 3 */
  409. ALTERNATE_FUNCTIONS(29, 4, UNUSED, UNUSED, 0, 0, 0), /* GPIO29, altA controlled by bit 4 */
  410. ALTERNATE_FUNCTIONS(30, 5, UNUSED, UNUSED, 0, 0, 0), /* GPIO30, altA controlled by bit 5 */
  411. ALTERNATE_FUNCTIONS(31, 6, UNUSED, UNUSED, 0, 0, 0), /* GPIO31, altA controlled by bit 6 */
  412. ALTERNATE_FUNCTIONS(32, 7, UNUSED, UNUSED, 0, 0, 0), /* GPIO32, altA controlled by bit 7 */
  413. ALTERNATE_FUNCTIONS(33, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO33 */
  414. ALTERNATE_FUNCTIONS(34, 1, UNUSED, UNUSED, 0, 0, 0), /* GPIO34, altA controlled by bit 1 */
  415. /* pin 35 special case, no alternate function, bit 2 reserved */
  416. ALTERNATE_FUNCTIONS(35, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* GPIO35 */
  417. ALTERNATE_FUNCTIONS(36, 3, UNUSED, UNUSED, 0, 0, 0), /* GPIO36, altA controlled by bit 3 */
  418. ALTERNATE_FUNCTIONS(37, 4, UNUSED, UNUSED, 0, 0, 0), /* GPIO37, altA controlled by bit 4 */
  419. ALTERNATE_FUNCTIONS(38, 5, UNUSED, UNUSED, 0, 0, 0), /* GPIO38, altA controlled by bit 5 */
  420. ALTERNATE_FUNCTIONS(39, 6, UNUSED, UNUSED, 0, 0, 0), /* GPIO39, altA controlled by bit 6 */
  421. ALTERNATE_FUNCTIONS(40, 7, UNUSED, UNUSED, 0, 0, 0), /* GPIO40, altA controlled by bit 7 */
  422. ALTERNATE_FUNCTIONS(41, 0, UNUSED, UNUSED, 0, 0, 0), /* GPIO41, altA controlled by bit 0 */
  423. ALTERNATE_FUNCTIONS(42, 1, UNUSED, UNUSED, 0, 0, 0), /* GPIO42, altA controlled by bit 1 */
  424. };
  425. /*
  426. * Only some GPIOs are interrupt capable, and they are
  427. * organized in discontiguous clusters:
  428. *
  429. * GPIO6 to GPIO13
  430. * GPIO24 and GPIO25
  431. * GPIO36 to GPIO41
  432. */
  433. static struct abx500_gpio_irq_cluster ab8500_gpio_irq_cluster[] = {
  434. GPIO_IRQ_CLUSTER(6, 13, AB8500_INT_GPIO6R),
  435. GPIO_IRQ_CLUSTER(24, 25, AB8500_INT_GPIO24R),
  436. GPIO_IRQ_CLUSTER(36, 41, AB8500_INT_GPIO36R),
  437. };
  438. static struct abx500_pinctrl_soc_data ab8500_soc = {
  439. .gpio_ranges = ab8500_pinranges,
  440. .gpio_num_ranges = ARRAY_SIZE(ab8500_pinranges),
  441. .pins = ab8500_pins,
  442. .npins = ARRAY_SIZE(ab8500_pins),
  443. .functions = ab8500_functions,
  444. .nfunctions = ARRAY_SIZE(ab8500_functions),
  445. .groups = ab8500_groups,
  446. .ngroups = ARRAY_SIZE(ab8500_groups),
  447. .alternate_functions = ab8500_alternate_functions,
  448. .gpio_irq_cluster = ab8500_gpio_irq_cluster,
  449. .ngpio_irq_cluster = ARRAY_SIZE(ab8500_gpio_irq_cluster),
  450. .irq_gpio_rising_offset = AB8500_INT_GPIO6R,
  451. .irq_gpio_falling_offset = AB8500_INT_GPIO6F,
  452. .irq_gpio_factor = 1,
  453. };
  454. void abx500_pinctrl_ab8500_init(struct abx500_pinctrl_soc_data **soc)
  455. {
  456. *soc = &ab8500_soc;
  457. }