1d2912cb1SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
23a198059SLinus Walleij /*
33a198059SLinus Walleij * Copyright (C) ST-Ericsson SA 2012
43a198059SLinus Walleij *
53a198059SLinus Walleij * Author: Patrice Chotard <patrice.chotard@stericsson.com> for ST-Ericsson.
63a198059SLinus Walleij */
73a198059SLinus Walleij
83a198059SLinus Walleij #include <linux/kernel.h>
93a198059SLinus Walleij #include <linux/pinctrl/pinctrl.h>
10*937e7a39SAndy Shevchenko
113a198059SLinus Walleij #include <linux/mfd/abx500/ab8500.h>
12*937e7a39SAndy Shevchenko
133a198059SLinus Walleij #include "pinctrl-abx500.h"
143a198059SLinus Walleij
153a198059SLinus Walleij /* All the pins that can be used for GPIO and some other functions */
163a198059SLinus Walleij #define ABX500_GPIO(offset) (offset)
173a198059SLinus Walleij
183a198059SLinus Walleij #define AB8500_PIN_T10 ABX500_GPIO(1)
193a198059SLinus Walleij #define AB8500_PIN_T9 ABX500_GPIO(2)
203a198059SLinus Walleij #define AB8500_PIN_U9 ABX500_GPIO(3)
213a198059SLinus Walleij #define AB8500_PIN_W2 ABX500_GPIO(4)
223a198059SLinus Walleij /* hole */
233a198059SLinus Walleij #define AB8500_PIN_Y18 ABX500_GPIO(6)
243a198059SLinus Walleij #define AB8500_PIN_AA20 ABX500_GPIO(7)
253a198059SLinus Walleij #define AB8500_PIN_W18 ABX500_GPIO(8)
263a198059SLinus Walleij #define AB8500_PIN_AA19 ABX500_GPIO(9)
273a198059SLinus Walleij #define AB8500_PIN_U17 ABX500_GPIO(10)
283a198059SLinus Walleij #define AB8500_PIN_AA18 ABX500_GPIO(11)
293a198059SLinus Walleij #define AB8500_PIN_U16 ABX500_GPIO(12)
303a198059SLinus Walleij #define AB8500_PIN_W17 ABX500_GPIO(13)
313a198059SLinus Walleij #define AB8500_PIN_F14 ABX500_GPIO(14)
323a198059SLinus Walleij #define AB8500_PIN_B17 ABX500_GPIO(15)
333a198059SLinus Walleij #define AB8500_PIN_F15 ABX500_GPIO(16)
343a198059SLinus Walleij #define AB8500_PIN_P5 ABX500_GPIO(17)
353a198059SLinus Walleij #define AB8500_PIN_R5 ABX500_GPIO(18)
363a198059SLinus Walleij #define AB8500_PIN_U5 ABX500_GPIO(19)
373a198059SLinus Walleij #define AB8500_PIN_T5 ABX500_GPIO(20)
383a198059SLinus Walleij #define AB8500_PIN_H19 ABX500_GPIO(21)
393a198059SLinus Walleij #define AB8500_PIN_G20 ABX500_GPIO(22)
403a198059SLinus Walleij #define AB8500_PIN_G19 ABX500_GPIO(23)
413a198059SLinus Walleij #define AB8500_PIN_T14 ABX500_GPIO(24)
423a198059SLinus Walleij #define AB8500_PIN_R16 ABX500_GPIO(25)
433a198059SLinus Walleij #define AB8500_PIN_M16 ABX500_GPIO(26)
443a198059SLinus Walleij #define AB8500_PIN_J6 ABX500_GPIO(27)
453a198059SLinus Walleij #define AB8500_PIN_K6 ABX500_GPIO(28)
463a198059SLinus Walleij #define AB8500_PIN_G6 ABX500_GPIO(29)
473a198059SLinus Walleij #define AB8500_PIN_H6 ABX500_GPIO(30)
483a198059SLinus Walleij #define AB8500_PIN_F5 ABX500_GPIO(31)
493a198059SLinus Walleij #define AB8500_PIN_G5 ABX500_GPIO(32)
503a198059SLinus Walleij /* hole */
513a198059SLinus Walleij #define AB8500_PIN_R17 ABX500_GPIO(34)
523a198059SLinus Walleij #define AB8500_PIN_W15 ABX500_GPIO(35)
533a198059SLinus Walleij #define AB8500_PIN_A17 ABX500_GPIO(36)
543a198059SLinus Walleij #define AB8500_PIN_E15 ABX500_GPIO(37)
553a198059SLinus Walleij #define AB8500_PIN_C17 ABX500_GPIO(38)
563a198059SLinus Walleij #define AB8500_PIN_E16 ABX500_GPIO(39)
573a198059SLinus Walleij #define AB8500_PIN_T19 ABX500_GPIO(40)
583a198059SLinus Walleij #define AB8500_PIN_U19 ABX500_GPIO(41)
593a198059SLinus Walleij #define AB8500_PIN_U2 ABX500_GPIO(42)
603a198059SLinus Walleij
613a198059SLinus Walleij /* indicates the highest GPIO number */
623a198059SLinus Walleij #define AB8500_GPIO_MAX_NUMBER 42
633a198059SLinus Walleij
643a198059SLinus Walleij /*
653a198059SLinus Walleij * The names of the pins are denoted by GPIO number and ball name, even
663a198059SLinus Walleij * though they can be used for other things than GPIO, this is the first
673a198059SLinus Walleij * column in the table of the data sheet and often used on schematics and
683a198059SLinus Walleij * such.
693a198059SLinus Walleij */
703a198059SLinus Walleij static const struct pinctrl_pin_desc ab8500_pins[] = {
713a198059SLinus Walleij PINCTRL_PIN(AB8500_PIN_T10, "GPIO1_T10"),
723a198059SLinus Walleij PINCTRL_PIN(AB8500_PIN_T9, "GPIO2_T9"),
733a198059SLinus Walleij PINCTRL_PIN(AB8500_PIN_U9, "GPIO3_U9"),
743a198059SLinus Walleij PINCTRL_PIN(AB8500_PIN_W2, "GPIO4_W2"),
753a198059SLinus Walleij /* hole */
763a198059SLinus Walleij PINCTRL_PIN(AB8500_PIN_Y18, "GPIO6_Y18"),
773a198059SLinus Walleij PINCTRL_PIN(AB8500_PIN_AA20, "GPIO7_AA20"),
783a198059SLinus Walleij PINCTRL_PIN(AB8500_PIN_W18, "GPIO8_W18"),
793a198059SLinus Walleij PINCTRL_PIN(AB8500_PIN_AA19, "GPIO9_AA19"),
803a198059SLinus Walleij PINCTRL_PIN(AB8500_PIN_U17, "GPIO10_U17"),
813a198059SLinus Walleij PINCTRL_PIN(AB8500_PIN_AA18, "GPIO11_AA18"),
823a198059SLinus Walleij PINCTRL_PIN(AB8500_PIN_U16, "GPIO12_U16"),
833a198059SLinus Walleij PINCTRL_PIN(AB8500_PIN_W17, "GPIO13_W17"),
843a198059SLinus Walleij PINCTRL_PIN(AB8500_PIN_F14, "GPIO14_F14"),
853a198059SLinus Walleij PINCTRL_PIN(AB8500_PIN_B17, "GPIO15_B17"),
863a198059SLinus Walleij PINCTRL_PIN(AB8500_PIN_F15, "GPIO16_F15"),
873a198059SLinus Walleij PINCTRL_PIN(AB8500_PIN_P5, "GPIO17_P5"),
883a198059SLinus Walleij PINCTRL_PIN(AB8500_PIN_R5, "GPIO18_R5"),
893a198059SLinus Walleij PINCTRL_PIN(AB8500_PIN_U5, "GPIO19_U5"),
903a198059SLinus Walleij PINCTRL_PIN(AB8500_PIN_T5, "GPIO20_T5"),
913a198059SLinus Walleij PINCTRL_PIN(AB8500_PIN_H19, "GPIO21_H19"),
923a198059SLinus Walleij PINCTRL_PIN(AB8500_PIN_G20, "GPIO22_G20"),
933a198059SLinus Walleij PINCTRL_PIN(AB8500_PIN_G19, "GPIO23_G19"),
943a198059SLinus Walleij PINCTRL_PIN(AB8500_PIN_T14, "GPIO24_T14"),
953a198059SLinus Walleij PINCTRL_PIN(AB8500_PIN_R16, "GPIO25_R16"),
963a198059SLinus Walleij PINCTRL_PIN(AB8500_PIN_M16, "GPIO26_M16"),
973a198059SLinus Walleij PINCTRL_PIN(AB8500_PIN_J6, "GPIO27_J6"),
983a198059SLinus Walleij PINCTRL_PIN(AB8500_PIN_K6, "GPIO28_K6"),
993a198059SLinus Walleij PINCTRL_PIN(AB8500_PIN_G6, "GPIO29_G6"),
1003a198059SLinus Walleij PINCTRL_PIN(AB8500_PIN_H6, "GPIO30_H6"),
1013a198059SLinus Walleij PINCTRL_PIN(AB8500_PIN_F5, "GPIO31_F5"),
1023a198059SLinus Walleij PINCTRL_PIN(AB8500_PIN_G5, "GPIO32_G5"),
1033a198059SLinus Walleij /* hole */
1043a198059SLinus Walleij PINCTRL_PIN(AB8500_PIN_R17, "GPIO34_R17"),
1053a198059SLinus Walleij PINCTRL_PIN(AB8500_PIN_W15, "GPIO35_W15"),
1063a198059SLinus Walleij PINCTRL_PIN(AB8500_PIN_A17, "GPIO36_A17"),
1073a198059SLinus Walleij PINCTRL_PIN(AB8500_PIN_E15, "GPIO37_E15"),
1083a198059SLinus Walleij PINCTRL_PIN(AB8500_PIN_C17, "GPIO38_C17"),
1093a198059SLinus Walleij PINCTRL_PIN(AB8500_PIN_E16, "GPIO39_E16"),
1103a198059SLinus Walleij PINCTRL_PIN(AB8500_PIN_T19, "GPIO40_T19"),
1113a198059SLinus Walleij PINCTRL_PIN(AB8500_PIN_U19, "GPIO41_U19"),
1123a198059SLinus Walleij PINCTRL_PIN(AB8500_PIN_U2, "GPIO42_U2"),
1133a198059SLinus Walleij };
1143a198059SLinus Walleij
1153a198059SLinus Walleij /*
1163a198059SLinus Walleij * Maps local GPIO offsets to local pin numbers
1173a198059SLinus Walleij */
1183a198059SLinus Walleij static const struct abx500_pinrange ab8500_pinranges[] = {
1193a198059SLinus Walleij ABX500_PINRANGE(1, 4, ABX500_ALT_A),
1203a198059SLinus Walleij ABX500_PINRANGE(6, 4, ABX500_ALT_A),
1213a198059SLinus Walleij ABX500_PINRANGE(10, 4, ABX500_DEFAULT),
1223a198059SLinus Walleij ABX500_PINRANGE(14, 12, ABX500_ALT_A),
1233a198059SLinus Walleij ABX500_PINRANGE(26, 1, ABX500_DEFAULT),
1243a198059SLinus Walleij ABX500_PINRANGE(27, 6, ABX500_ALT_A),
1253a198059SLinus Walleij ABX500_PINRANGE(34, 1, ABX500_ALT_A),
1263a198059SLinus Walleij ABX500_PINRANGE(35, 1, ABX500_DEFAULT),
1273a198059SLinus Walleij ABX500_PINRANGE(36, 7, ABX500_ALT_A),
1283a198059SLinus Walleij };
1293a198059SLinus Walleij
1303a198059SLinus Walleij /*
1313a198059SLinus Walleij * Read the pin group names like this:
1323a198059SLinus Walleij * sysclkreq2_d_1 = first groups of pins for sysclkreq2 on default function
1333a198059SLinus Walleij *
1343a198059SLinus Walleij * The groups are arranged as sets per altfunction column, so we can
1353a198059SLinus Walleij * mux in one group at a time by selecting the same altfunction for them
1363a198059SLinus Walleij * all. When functions require pins on different altfunctions, you need
1373a198059SLinus Walleij * to combine several groups.
1383a198059SLinus Walleij */
1393a198059SLinus Walleij
1403a198059SLinus Walleij /* default column */
1413a198059SLinus Walleij static const unsigned sysclkreq2_d_1_pins[] = { AB8500_PIN_T10 };
1423a198059SLinus Walleij static const unsigned sysclkreq3_d_1_pins[] = { AB8500_PIN_T9 };
1433a198059SLinus Walleij static const unsigned sysclkreq4_d_1_pins[] = { AB8500_PIN_U9 };
1443a198059SLinus Walleij static const unsigned sysclkreq6_d_1_pins[] = { AB8500_PIN_W2 };
1453a198059SLinus Walleij static const unsigned ycbcr0123_d_1_pins[] = { AB8500_PIN_Y18, AB8500_PIN_AA20,
1463a198059SLinus Walleij AB8500_PIN_W18, AB8500_PIN_AA19};
1473a198059SLinus Walleij static const unsigned gpio10_d_1_pins[] = { AB8500_PIN_U17 };
1483a198059SLinus Walleij static const unsigned gpio11_d_1_pins[] = { AB8500_PIN_AA18 };
1493a198059SLinus Walleij static const unsigned gpio12_d_1_pins[] = { AB8500_PIN_U16 };
1503a198059SLinus Walleij static const unsigned gpio13_d_1_pins[] = { AB8500_PIN_W17 };
1513a198059SLinus Walleij static const unsigned pwmout1_d_1_pins[] = { AB8500_PIN_F14 };
1523a198059SLinus Walleij static const unsigned pwmout2_d_1_pins[] = { AB8500_PIN_B17 };
1533a198059SLinus Walleij static const unsigned pwmout3_d_1_pins[] = { AB8500_PIN_F15 };
1543a198059SLinus Walleij
1553a198059SLinus Walleij /* audio data interface 1*/
1563a198059SLinus Walleij static const unsigned adi1_d_1_pins[] = { AB8500_PIN_P5, AB8500_PIN_R5,
1573a198059SLinus Walleij AB8500_PIN_U5, AB8500_PIN_T5 };
1583a198059SLinus Walleij /* USBUICC */
1593a198059SLinus Walleij static const unsigned usbuicc_d_1_pins[] = { AB8500_PIN_H19, AB8500_PIN_G20,
1603a198059SLinus Walleij AB8500_PIN_G19 };
1613a198059SLinus Walleij static const unsigned sysclkreq7_d_1_pins[] = { AB8500_PIN_T14 };
1623a198059SLinus Walleij static const unsigned sysclkreq8_d_1_pins[] = { AB8500_PIN_R16 };
1633a198059SLinus Walleij static const unsigned gpio26_d_1_pins[] = { AB8500_PIN_M16 };
1643a198059SLinus Walleij /* Digital microphone 1 and 2 */
1653a198059SLinus Walleij static const unsigned dmic12_d_1_pins[] = { AB8500_PIN_J6, AB8500_PIN_K6 };
1663a198059SLinus Walleij /* Digital microphone 3 and 4 */
1673a198059SLinus Walleij static const unsigned dmic34_d_1_pins[] = { AB8500_PIN_G6, AB8500_PIN_H6 };
1683a198059SLinus Walleij /* Digital microphone 5 and 6 */
1693a198059SLinus Walleij static const unsigned dmic56_d_1_pins[] = { AB8500_PIN_F5, AB8500_PIN_G5 };
1703a198059SLinus Walleij static const unsigned extcpena_d_1_pins[] = { AB8500_PIN_R17 };
1713a198059SLinus Walleij static const unsigned gpio35_d_1_pins[] = { AB8500_PIN_W15 };
1723a198059SLinus Walleij /* APE SPI */
1733a198059SLinus Walleij static const unsigned apespi_d_1_pins[] = { AB8500_PIN_A17, AB8500_PIN_E15,
1743a198059SLinus Walleij AB8500_PIN_C17, AB8500_PIN_E16};
1753a198059SLinus Walleij /* modem SDA/SCL */
1763a198059SLinus Walleij static const unsigned modsclsda_d_1_pins[] = { AB8500_PIN_T19, AB8500_PIN_U19 };
1773a198059SLinus Walleij static const unsigned sysclkreq5_d_1_pins[] = { AB8500_PIN_U2 };
1783a198059SLinus Walleij
1793a198059SLinus Walleij /* Altfunction A column */
1803a198059SLinus Walleij static const unsigned gpio1_a_1_pins[] = { AB8500_PIN_T10 };
1813a198059SLinus Walleij static const unsigned gpio2_a_1_pins[] = { AB8500_PIN_T9 };
1823a198059SLinus Walleij static const unsigned gpio3_a_1_pins[] = { AB8500_PIN_U9 };
1833a198059SLinus Walleij static const unsigned gpio4_a_1_pins[] = { AB8500_PIN_W2 };
1843a198059SLinus Walleij static const unsigned gpio6_a_1_pins[] = { AB8500_PIN_Y18 };
1853a198059SLinus Walleij static const unsigned gpio7_a_1_pins[] = { AB8500_PIN_AA20 };
1863a198059SLinus Walleij static const unsigned gpio8_a_1_pins[] = { AB8500_PIN_W18 };
1873a198059SLinus Walleij static const unsigned gpio9_a_1_pins[] = { AB8500_PIN_AA19 };
1883a198059SLinus Walleij /* YCbCr4 YCbCr5 YCbCr6 YCbCr7*/
1893a198059SLinus Walleij static const unsigned ycbcr4567_a_1_pins[] = { AB8500_PIN_U17, AB8500_PIN_AA18,
1903a198059SLinus Walleij AB8500_PIN_U16, AB8500_PIN_W17};
1913a198059SLinus Walleij static const unsigned gpio14_a_1_pins[] = { AB8500_PIN_F14 };
1923a198059SLinus Walleij static const unsigned gpio15_a_1_pins[] = { AB8500_PIN_B17 };
1933a198059SLinus Walleij static const unsigned gpio16_a_1_pins[] = { AB8500_PIN_F15 };
1943a198059SLinus Walleij static const unsigned gpio17_a_1_pins[] = { AB8500_PIN_P5 };
1953a198059SLinus Walleij static const unsigned gpio18_a_1_pins[] = { AB8500_PIN_R5 };
1963a198059SLinus Walleij static const unsigned gpio19_a_1_pins[] = { AB8500_PIN_U5 };
1973a198059SLinus Walleij static const unsigned gpio20_a_1_pins[] = { AB8500_PIN_T5 };
1983a198059SLinus Walleij static const unsigned gpio21_a_1_pins[] = { AB8500_PIN_H19 };
1993a198059SLinus Walleij static const unsigned gpio22_a_1_pins[] = { AB8500_PIN_G20 };
2003a198059SLinus Walleij static const unsigned gpio23_a_1_pins[] = { AB8500_PIN_G19 };
2013a198059SLinus Walleij static const unsigned gpio24_a_1_pins[] = { AB8500_PIN_T14 };
2023a198059SLinus Walleij static const unsigned gpio25_a_1_pins[] = { AB8500_PIN_R16 };
2033a198059SLinus Walleij static const unsigned gpio27_a_1_pins[] = { AB8500_PIN_J6 };
2043a198059SLinus Walleij static const unsigned gpio28_a_1_pins[] = { AB8500_PIN_K6 };
2053a198059SLinus Walleij static const unsigned gpio29_a_1_pins[] = { AB8500_PIN_G6 };
2063a198059SLinus Walleij static const unsigned gpio30_a_1_pins[] = { AB8500_PIN_H6 };
2073a198059SLinus Walleij static const unsigned gpio31_a_1_pins[] = { AB8500_PIN_F5 };
2083a198059SLinus Walleij static const unsigned gpio32_a_1_pins[] = { AB8500_PIN_G5 };
2093a198059SLinus Walleij static const unsigned gpio34_a_1_pins[] = { AB8500_PIN_R17 };
2103a198059SLinus Walleij static const unsigned gpio36_a_1_pins[] = { AB8500_PIN_A17 };
2113a198059SLinus Walleij static const unsigned gpio37_a_1_pins[] = { AB8500_PIN_E15 };
2123a198059SLinus Walleij static const unsigned gpio38_a_1_pins[] = { AB8500_PIN_C17 };
2133a198059SLinus Walleij static const unsigned gpio39_a_1_pins[] = { AB8500_PIN_E16 };
2143a198059SLinus Walleij static const unsigned gpio40_a_1_pins[] = { AB8500_PIN_T19 };
2153a198059SLinus Walleij static const unsigned gpio41_a_1_pins[] = { AB8500_PIN_U19 };
2163a198059SLinus Walleij static const unsigned gpio42_a_1_pins[] = { AB8500_PIN_U2 };
2173a198059SLinus Walleij
2183a198059SLinus Walleij /* Altfunction B colum */
2193a198059SLinus Walleij static const unsigned hiqclkena_b_1_pins[] = { AB8500_PIN_U17 };
2203a198059SLinus Walleij static const unsigned usbuiccpd_b_1_pins[] = { AB8500_PIN_AA18 };
2213a198059SLinus Walleij static const unsigned i2ctrig1_b_1_pins[] = { AB8500_PIN_U16 };
2223a198059SLinus Walleij static const unsigned i2ctrig2_b_1_pins[] = { AB8500_PIN_W17 };
2233a198059SLinus Walleij
2243a198059SLinus Walleij /* Altfunction C column */
2253a198059SLinus Walleij static const unsigned usbvdat_c_1_pins[] = { AB8500_PIN_W17 };
2263a198059SLinus Walleij
2273a198059SLinus Walleij
2283a198059SLinus Walleij #define AB8500_PIN_GROUP(a, b) { .name = #a, .pins = a##_pins, \
2293a198059SLinus Walleij .npins = ARRAY_SIZE(a##_pins), .altsetting = b }
2303a198059SLinus Walleij
2313a198059SLinus Walleij static const struct abx500_pingroup ab8500_groups[] = {
2323a198059SLinus Walleij /* default column */
2333a198059SLinus Walleij AB8500_PIN_GROUP(sysclkreq2_d_1, ABX500_DEFAULT),
2343a198059SLinus Walleij AB8500_PIN_GROUP(sysclkreq3_d_1, ABX500_DEFAULT),
2353a198059SLinus Walleij AB8500_PIN_GROUP(sysclkreq4_d_1, ABX500_DEFAULT),
2363a198059SLinus Walleij AB8500_PIN_GROUP(sysclkreq6_d_1, ABX500_DEFAULT),
2373a198059SLinus Walleij AB8500_PIN_GROUP(ycbcr0123_d_1, ABX500_DEFAULT),
2383a198059SLinus Walleij AB8500_PIN_GROUP(gpio10_d_1, ABX500_DEFAULT),
2393a198059SLinus Walleij AB8500_PIN_GROUP(gpio11_d_1, ABX500_DEFAULT),
2403a198059SLinus Walleij AB8500_PIN_GROUP(gpio12_d_1, ABX500_DEFAULT),
2413a198059SLinus Walleij AB8500_PIN_GROUP(gpio13_d_1, ABX500_DEFAULT),
2423a198059SLinus Walleij AB8500_PIN_GROUP(pwmout1_d_1, ABX500_DEFAULT),
2433a198059SLinus Walleij AB8500_PIN_GROUP(pwmout2_d_1, ABX500_DEFAULT),
2443a198059SLinus Walleij AB8500_PIN_GROUP(pwmout3_d_1, ABX500_DEFAULT),
2453a198059SLinus Walleij AB8500_PIN_GROUP(adi1_d_1, ABX500_DEFAULT),
2463a198059SLinus Walleij AB8500_PIN_GROUP(usbuicc_d_1, ABX500_DEFAULT),
2473a198059SLinus Walleij AB8500_PIN_GROUP(sysclkreq7_d_1, ABX500_DEFAULT),
2483a198059SLinus Walleij AB8500_PIN_GROUP(sysclkreq8_d_1, ABX500_DEFAULT),
2493a198059SLinus Walleij AB8500_PIN_GROUP(gpio26_d_1, ABX500_DEFAULT),
2503a198059SLinus Walleij AB8500_PIN_GROUP(dmic12_d_1, ABX500_DEFAULT),
2513a198059SLinus Walleij AB8500_PIN_GROUP(dmic34_d_1, ABX500_DEFAULT),
2523a198059SLinus Walleij AB8500_PIN_GROUP(dmic56_d_1, ABX500_DEFAULT),
2533a198059SLinus Walleij AB8500_PIN_GROUP(extcpena_d_1, ABX500_DEFAULT),
2543a198059SLinus Walleij AB8500_PIN_GROUP(gpio35_d_1, ABX500_DEFAULT),
2553a198059SLinus Walleij AB8500_PIN_GROUP(apespi_d_1, ABX500_DEFAULT),
2563a198059SLinus Walleij AB8500_PIN_GROUP(modsclsda_d_1, ABX500_DEFAULT),
2573a198059SLinus Walleij AB8500_PIN_GROUP(sysclkreq5_d_1, ABX500_DEFAULT),
2583a198059SLinus Walleij /* Altfunction A column */
2593a198059SLinus Walleij AB8500_PIN_GROUP(gpio1_a_1, ABX500_ALT_A),
2603a198059SLinus Walleij AB8500_PIN_GROUP(gpio2_a_1, ABX500_ALT_A),
2613a198059SLinus Walleij AB8500_PIN_GROUP(gpio3_a_1, ABX500_ALT_A),
2623a198059SLinus Walleij AB8500_PIN_GROUP(gpio4_a_1, ABX500_ALT_A),
2633a198059SLinus Walleij AB8500_PIN_GROUP(gpio6_a_1, ABX500_ALT_A),
2643a198059SLinus Walleij AB8500_PIN_GROUP(gpio7_a_1, ABX500_ALT_A),
2653a198059SLinus Walleij AB8500_PIN_GROUP(gpio8_a_1, ABX500_ALT_A),
2663a198059SLinus Walleij AB8500_PIN_GROUP(gpio9_a_1, ABX500_ALT_A),
2673a198059SLinus Walleij AB8500_PIN_GROUP(ycbcr4567_a_1, ABX500_ALT_A),
2683a198059SLinus Walleij AB8500_PIN_GROUP(gpio14_a_1, ABX500_ALT_A),
2693a198059SLinus Walleij AB8500_PIN_GROUP(gpio15_a_1, ABX500_ALT_A),
2703a198059SLinus Walleij AB8500_PIN_GROUP(gpio16_a_1, ABX500_ALT_A),
2713a198059SLinus Walleij AB8500_PIN_GROUP(gpio17_a_1, ABX500_ALT_A),
2723a198059SLinus Walleij AB8500_PIN_GROUP(gpio18_a_1, ABX500_ALT_A),
2733a198059SLinus Walleij AB8500_PIN_GROUP(gpio19_a_1, ABX500_ALT_A),
2743a198059SLinus Walleij AB8500_PIN_GROUP(gpio20_a_1, ABX500_ALT_A),
2753a198059SLinus Walleij AB8500_PIN_GROUP(gpio21_a_1, ABX500_ALT_A),
2763a198059SLinus Walleij AB8500_PIN_GROUP(gpio22_a_1, ABX500_ALT_A),
2773a198059SLinus Walleij AB8500_PIN_GROUP(gpio23_a_1, ABX500_ALT_A),
2783a198059SLinus Walleij AB8500_PIN_GROUP(gpio24_a_1, ABX500_ALT_A),
2793a198059SLinus Walleij AB8500_PIN_GROUP(gpio25_a_1, ABX500_ALT_A),
2803a198059SLinus Walleij AB8500_PIN_GROUP(gpio27_a_1, ABX500_ALT_A),
2813a198059SLinus Walleij AB8500_PIN_GROUP(gpio28_a_1, ABX500_ALT_A),
2823a198059SLinus Walleij AB8500_PIN_GROUP(gpio29_a_1, ABX500_ALT_A),
2833a198059SLinus Walleij AB8500_PIN_GROUP(gpio30_a_1, ABX500_ALT_A),
2843a198059SLinus Walleij AB8500_PIN_GROUP(gpio31_a_1, ABX500_ALT_A),
2853a198059SLinus Walleij AB8500_PIN_GROUP(gpio32_a_1, ABX500_ALT_A),
2863a198059SLinus Walleij AB8500_PIN_GROUP(gpio34_a_1, ABX500_ALT_A),
2873a198059SLinus Walleij AB8500_PIN_GROUP(gpio36_a_1, ABX500_ALT_A),
2883a198059SLinus Walleij AB8500_PIN_GROUP(gpio37_a_1, ABX500_ALT_A),
2893a198059SLinus Walleij AB8500_PIN_GROUP(gpio38_a_1, ABX500_ALT_A),
2903a198059SLinus Walleij AB8500_PIN_GROUP(gpio39_a_1, ABX500_ALT_A),
2913a198059SLinus Walleij AB8500_PIN_GROUP(gpio40_a_1, ABX500_ALT_A),
2923a198059SLinus Walleij AB8500_PIN_GROUP(gpio41_a_1, ABX500_ALT_A),
2933a198059SLinus Walleij AB8500_PIN_GROUP(gpio42_a_1, ABX500_ALT_A),
2943a198059SLinus Walleij /* Altfunction B column */
2953a198059SLinus Walleij AB8500_PIN_GROUP(hiqclkena_b_1, ABX500_ALT_B),
2963a198059SLinus Walleij AB8500_PIN_GROUP(usbuiccpd_b_1, ABX500_ALT_B),
2973a198059SLinus Walleij AB8500_PIN_GROUP(i2ctrig1_b_1, ABX500_ALT_B),
2983a198059SLinus Walleij AB8500_PIN_GROUP(i2ctrig2_b_1, ABX500_ALT_B),
2993a198059SLinus Walleij /* Altfunction C column */
3003a198059SLinus Walleij AB8500_PIN_GROUP(usbvdat_c_1, ABX500_ALT_C),
3013a198059SLinus Walleij };
3023a198059SLinus Walleij
3033a198059SLinus Walleij /* We use this macro to define the groups applicable to a function */
3043a198059SLinus Walleij #define AB8500_FUNC_GROUPS(a, b...) \
3053a198059SLinus Walleij static const char * const a##_groups[] = { b };
3063a198059SLinus Walleij
3073a198059SLinus Walleij AB8500_FUNC_GROUPS(sysclkreq, "sysclkreq2_d_1", "sysclkreq3_d_1",
3083a198059SLinus Walleij "sysclkreq4_d_1", "sysclkreq5_d_1", "sysclkreq6_d_1",
3093a198059SLinus Walleij "sysclkreq7_d_1", "sysclkreq8_d_1");
3103a198059SLinus Walleij AB8500_FUNC_GROUPS(ycbcr, "ycbcr0123_d_1", "ycbcr4567_a_1");
3113a198059SLinus Walleij AB8500_FUNC_GROUPS(gpio, "gpio1_a_1", "gpio2_a_1", "gpio3_a_1", "gpio4_a_1",
3123a198059SLinus Walleij "gpio6_a_1", "gpio7_a_1", "gpio8_a_1", "gpio9_a_1",
3133a198059SLinus Walleij "gpio10_d_1", "gpio11_d_1", "gpio12_d_1", "gpio13_d_1",
3143a198059SLinus Walleij "gpio14_a_1", "gpio15_a_1", "gpio16_a_1", "gpio17_a_1",
3153a198059SLinus Walleij "gpio18_a_1", "gpio19_a_1", "gpio20_a_1", "gpio21_a_1",
3163a198059SLinus Walleij "gpio22_a_1", "gpio23_a_1", "gpio24_a_1", "gpio25_a_1",
3173a198059SLinus Walleij "gpio26_d_1", "gpio27_a_1", "gpio28_a_1", "gpio29_a_1",
3183a198059SLinus Walleij "gpio30_a_1", "gpio31_a_1", "gpio32_a_1", "gpio34_a_1",
3193a198059SLinus Walleij "gpio35_d_1", "gpio36_a_1", "gpio37_a_1", "gpio38_a_1",
3203a198059SLinus Walleij "gpio39_a_1", "gpio40_a_1", "gpio41_a_1", "gpio42_a_1");
3213a198059SLinus Walleij AB8500_FUNC_GROUPS(pwmout, "pwmout1_d_1", "pwmout2_d_1", "pwmout3_d_1");
3223a198059SLinus Walleij AB8500_FUNC_GROUPS(adi1, "adi1_d_1");
3233a198059SLinus Walleij AB8500_FUNC_GROUPS(usbuicc, "usbuicc_d_1", "usbuiccpd_b_1");
3243a198059SLinus Walleij AB8500_FUNC_GROUPS(dmic, "dmic12_d_1", "dmic34_d_1", "dmic56_d_1");
3253a198059SLinus Walleij AB8500_FUNC_GROUPS(extcpena, "extcpena_d_1");
3263a198059SLinus Walleij AB8500_FUNC_GROUPS(apespi, "apespi_d_1");
3273a198059SLinus Walleij AB8500_FUNC_GROUPS(modsclsda, "modsclsda_d_1");
3283a198059SLinus Walleij AB8500_FUNC_GROUPS(hiqclkena, "hiqclkena_b_1");
3293a198059SLinus Walleij AB8500_FUNC_GROUPS(i2ctrig, "i2ctrig1_b_1", "i2ctrig2_b_1");
3303a198059SLinus Walleij AB8500_FUNC_GROUPS(usbvdat, "usbvdat_c_1");
3313a198059SLinus Walleij
3323a198059SLinus Walleij #define FUNCTION(fname) \
3333a198059SLinus Walleij { \
3343a198059SLinus Walleij .name = #fname, \
3353a198059SLinus Walleij .groups = fname##_groups, \
3363a198059SLinus Walleij .ngroups = ARRAY_SIZE(fname##_groups), \
3373a198059SLinus Walleij }
3383a198059SLinus Walleij
3393a198059SLinus Walleij static const struct abx500_function ab8500_functions[] = {
3403a198059SLinus Walleij FUNCTION(sysclkreq),
3413a198059SLinus Walleij FUNCTION(ycbcr),
3423a198059SLinus Walleij FUNCTION(gpio),
3433a198059SLinus Walleij FUNCTION(pwmout),
3443a198059SLinus Walleij FUNCTION(adi1),
3453a198059SLinus Walleij FUNCTION(usbuicc),
3463a198059SLinus Walleij FUNCTION(dmic),
3473a198059SLinus Walleij FUNCTION(extcpena),
3483a198059SLinus Walleij FUNCTION(apespi),
3493a198059SLinus Walleij FUNCTION(modsclsda),
3503a198059SLinus Walleij FUNCTION(hiqclkena),
3513a198059SLinus Walleij FUNCTION(i2ctrig),
3523a198059SLinus Walleij FUNCTION(usbvdat),
3533a198059SLinus Walleij };
3543a198059SLinus Walleij
3553a198059SLinus Walleij /*
3563a198059SLinus Walleij * this table translates what's is in the AB8500 specification regarding the
3573a198059SLinus Walleij * balls alternate functions (as for DB, default, ALT_A, ALT_B and ALT_C).
3583a198059SLinus Walleij * ALTERNATE_FUNCTIONS(GPIO_NUMBER, GPIOSEL bit, ALTERNATFUNC bit1,
3593a198059SLinus Walleij * ALTERNATEFUNC bit2, ALTA val, ALTB val, ALTC val),
3603a198059SLinus Walleij *
3613a198059SLinus Walleij * example :
3623a198059SLinus Walleij *
3633a198059SLinus Walleij * ALTERNATE_FUNCTIONS(13, 4, 3, 4, 0, 1 ,2),
3643a198059SLinus Walleij * means that pin AB8500_PIN_W17 (pin 13) supports 4 mux (default/ALT_A,
3653a198059SLinus Walleij * ALT_B and ALT_C), so GPIOSEL and ALTERNATFUNC registers are used to
3663a198059SLinus Walleij * select the mux. ALTA, ALTB and ALTC val indicates values to write in
3673a198059SLinus Walleij * ALTERNATFUNC register. We need to specifies these values as SOC
3683a198059SLinus Walleij * designers didn't apply the same logic on how to select mux in the
3693a198059SLinus Walleij * ABx500 family.
3703a198059SLinus Walleij *
3713a198059SLinus Walleij * As this pins supports at least ALT_B mux, default mux is
3723a198059SLinus Walleij * selected by writing 1 in GPIOSEL bit :
3733a198059SLinus Walleij *
3743a198059SLinus Walleij * | GPIOSEL bit=4 | alternatfunc bit2=4 | alternatfunc bit1=3
3753a198059SLinus Walleij * default | 1 | 0 | 0
3763a198059SLinus Walleij * alt_A | 0 | 0 | 0
3773a198059SLinus Walleij * alt_B | 0 | 0 | 1
3783a198059SLinus Walleij * alt_C | 0 | 1 | 0
3793a198059SLinus Walleij *
3803a198059SLinus Walleij * ALTERNATE_FUNCTIONS(8, 7, UNUSED, UNUSED),
3813a198059SLinus Walleij * means that pin AB8500_PIN_W18 (pin 8) supports 2 mux, so only GPIOSEL
3823a198059SLinus Walleij * register is used to select the mux. As this pins doesn't support at
3833a198059SLinus Walleij * least ALT_B mux, default mux is by writing 0 in GPIOSEL bit :
3843a198059SLinus Walleij *
3853a198059SLinus Walleij * | GPIOSEL bit=7 | alternatfunc bit2= | alternatfunc bit1=
3863a198059SLinus Walleij * default | 0 | 0 | 0
3873a198059SLinus Walleij * alt_A | 1 | 0 | 0
3883a198059SLinus Walleij */
3893a198059SLinus Walleij
3903a198059SLinus Walleij static struct
3913a198059SLinus Walleij alternate_functions ab8500_alternate_functions[AB8500_GPIO_MAX_NUMBER + 1] = {
3923a198059SLinus Walleij ALTERNATE_FUNCTIONS(0, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO0 */
3933a198059SLinus Walleij ALTERNATE_FUNCTIONS(1, 0, UNUSED, UNUSED, 0, 0, 0), /* GPIO1, altA controlled by bit 0 */
3943a198059SLinus Walleij ALTERNATE_FUNCTIONS(2, 1, UNUSED, UNUSED, 0, 0, 0), /* GPIO2, altA controlled by bit 1 */
3953a198059SLinus Walleij ALTERNATE_FUNCTIONS(3, 2, UNUSED, UNUSED, 0, 0, 0), /* GPIO3, altA controlled by bit 2*/
3963a198059SLinus Walleij ALTERNATE_FUNCTIONS(4, 3, UNUSED, UNUSED, 0, 0, 0), /* GPIO4, altA controlled by bit 3*/
3973a198059SLinus Walleij /* bit 4 reserved */
3983a198059SLinus Walleij ALTERNATE_FUNCTIONS(5, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO5 */
3993a198059SLinus Walleij ALTERNATE_FUNCTIONS(6, 5, UNUSED, UNUSED, 0, 0, 0), /* GPIO6, altA controlled by bit 5*/
4003a198059SLinus Walleij ALTERNATE_FUNCTIONS(7, 6, UNUSED, UNUSED, 0, 0, 0), /* GPIO7, altA controlled by bit 6*/
4013a198059SLinus Walleij ALTERNATE_FUNCTIONS(8, 7, UNUSED, UNUSED, 0, 0, 0), /* GPIO8, altA controlled by bit 7*/
4023a198059SLinus Walleij
4033a198059SLinus Walleij ALTERNATE_FUNCTIONS(9, 0, UNUSED, UNUSED, 0, 0, 0), /* GPIO9, altA controlled by bit 0*/
4043a198059SLinus Walleij ALTERNATE_FUNCTIONS(10, 1, 0, UNUSED, 0, 1, 0), /* GPIO10, altA and altB controlled by bit 0 */
4053a198059SLinus Walleij ALTERNATE_FUNCTIONS(11, 2, 1, UNUSED, 0, 1, 0), /* GPIO11, altA and altB controlled by bit 1 */
4063a198059SLinus Walleij ALTERNATE_FUNCTIONS(12, 3, 2, UNUSED, 0, 1, 0), /* GPIO12, altA and altB controlled by bit 2 */
4073a198059SLinus Walleij ALTERNATE_FUNCTIONS(13, 4, 3, 4, 0, 1, 2), /* GPIO13, altA altB and altC controlled by bit 3 and 4 */
4083a198059SLinus Walleij ALTERNATE_FUNCTIONS(14, 5, UNUSED, UNUSED, 0, 0, 0), /* GPIO14, altA controlled by bit 5 */
4093a198059SLinus Walleij ALTERNATE_FUNCTIONS(15, 6, UNUSED, UNUSED, 0, 0, 0), /* GPIO15, altA controlled by bit 6 */
4103a198059SLinus Walleij ALTERNATE_FUNCTIONS(16, 7, UNUSED, UNUSED, 0, 0, 0), /* GPIO16, altA controlled by bit 7 */
4113a198059SLinus Walleij /*
4123a198059SLinus Walleij * pins 17 to 20 are special case, only bit 0 is used to select
4133a198059SLinus Walleij * alternate function for these 4 pins.
4143a198059SLinus Walleij * bits 1 to 3 are reserved
4153a198059SLinus Walleij */
4163a198059SLinus Walleij ALTERNATE_FUNCTIONS(17, 0, UNUSED, UNUSED, 0, 0, 0), /* GPIO17, altA controlled by bit 0 */
4173a198059SLinus Walleij ALTERNATE_FUNCTIONS(18, 0, UNUSED, UNUSED, 0, 0, 0), /* GPIO18, altA controlled by bit 0 */
4183a198059SLinus Walleij ALTERNATE_FUNCTIONS(19, 0, UNUSED, UNUSED, 0, 0, 0), /* GPIO19, altA controlled by bit 0 */
4193a198059SLinus Walleij ALTERNATE_FUNCTIONS(20, 0, UNUSED, UNUSED, 0, 0, 0), /* GPIO20, altA controlled by bit 0 */
4203a198059SLinus Walleij ALTERNATE_FUNCTIONS(21, 4, UNUSED, UNUSED, 0, 0, 0), /* GPIO21, altA controlled by bit 4 */
4213a198059SLinus Walleij ALTERNATE_FUNCTIONS(22, 5, UNUSED, UNUSED, 0, 0, 0), /* GPIO22, altA controlled by bit 5 */
4223a198059SLinus Walleij ALTERNATE_FUNCTIONS(23, 6, UNUSED, UNUSED, 0, 0, 0), /* GPIO23, altA controlled by bit 6 */
4233a198059SLinus Walleij ALTERNATE_FUNCTIONS(24, 7, UNUSED, UNUSED, 0, 0, 0), /* GPIO24, altA controlled by bit 7 */
4243a198059SLinus Walleij
4253a198059SLinus Walleij ALTERNATE_FUNCTIONS(25, 0, UNUSED, UNUSED, 0, 0, 0), /* GPIO25, altA controlled by bit 0 */
4263a198059SLinus Walleij /* pin 26 special case, no alternate function, bit 1 reserved */
4273a198059SLinus Walleij ALTERNATE_FUNCTIONS(26, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* GPIO26 */
4283a198059SLinus Walleij ALTERNATE_FUNCTIONS(27, 2, UNUSED, UNUSED, 0, 0, 0), /* GPIO27, altA controlled by bit 2 */
4293a198059SLinus Walleij ALTERNATE_FUNCTIONS(28, 3, UNUSED, UNUSED, 0, 0, 0), /* GPIO28, altA controlled by bit 3 */
4303a198059SLinus Walleij ALTERNATE_FUNCTIONS(29, 4, UNUSED, UNUSED, 0, 0, 0), /* GPIO29, altA controlled by bit 4 */
4313a198059SLinus Walleij ALTERNATE_FUNCTIONS(30, 5, UNUSED, UNUSED, 0, 0, 0), /* GPIO30, altA controlled by bit 5 */
4323a198059SLinus Walleij ALTERNATE_FUNCTIONS(31, 6, UNUSED, UNUSED, 0, 0, 0), /* GPIO31, altA controlled by bit 6 */
4333a198059SLinus Walleij ALTERNATE_FUNCTIONS(32, 7, UNUSED, UNUSED, 0, 0, 0), /* GPIO32, altA controlled by bit 7 */
4343a198059SLinus Walleij
4353a198059SLinus Walleij ALTERNATE_FUNCTIONS(33, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO33 */
4363a198059SLinus Walleij ALTERNATE_FUNCTIONS(34, 1, UNUSED, UNUSED, 0, 0, 0), /* GPIO34, altA controlled by bit 1 */
4373a198059SLinus Walleij /* pin 35 special case, no alternate function, bit 2 reserved */
4383a198059SLinus Walleij ALTERNATE_FUNCTIONS(35, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* GPIO35 */
4393a198059SLinus Walleij ALTERNATE_FUNCTIONS(36, 3, UNUSED, UNUSED, 0, 0, 0), /* GPIO36, altA controlled by bit 3 */
4403a198059SLinus Walleij ALTERNATE_FUNCTIONS(37, 4, UNUSED, UNUSED, 0, 0, 0), /* GPIO37, altA controlled by bit 4 */
4413a198059SLinus Walleij ALTERNATE_FUNCTIONS(38, 5, UNUSED, UNUSED, 0, 0, 0), /* GPIO38, altA controlled by bit 5 */
4423a198059SLinus Walleij ALTERNATE_FUNCTIONS(39, 6, UNUSED, UNUSED, 0, 0, 0), /* GPIO39, altA controlled by bit 6 */
4433a198059SLinus Walleij ALTERNATE_FUNCTIONS(40, 7, UNUSED, UNUSED, 0, 0, 0), /* GPIO40, altA controlled by bit 7 */
4443a198059SLinus Walleij
4453a198059SLinus Walleij ALTERNATE_FUNCTIONS(41, 0, UNUSED, UNUSED, 0, 0, 0), /* GPIO41, altA controlled by bit 0 */
4463a198059SLinus Walleij ALTERNATE_FUNCTIONS(42, 1, UNUSED, UNUSED, 0, 0, 0), /* GPIO42, altA controlled by bit 1 */
4473a198059SLinus Walleij };
4483a198059SLinus Walleij
4493a198059SLinus Walleij /*
4503a198059SLinus Walleij * Only some GPIOs are interrupt capable, and they are
4513a198059SLinus Walleij * organized in discontiguous clusters:
4523a198059SLinus Walleij *
4533a198059SLinus Walleij * GPIO6 to GPIO13
4543a198059SLinus Walleij * GPIO24 and GPIO25
4553a198059SLinus Walleij * GPIO36 to GPIO41
4563a198059SLinus Walleij */
4573a198059SLinus Walleij static struct abx500_gpio_irq_cluster ab8500_gpio_irq_cluster[] = {
4583a198059SLinus Walleij GPIO_IRQ_CLUSTER(6, 13, AB8500_INT_GPIO6R),
4593a198059SLinus Walleij GPIO_IRQ_CLUSTER(24, 25, AB8500_INT_GPIO24R),
4603a198059SLinus Walleij GPIO_IRQ_CLUSTER(36, 41, AB8500_INT_GPIO36R),
4613a198059SLinus Walleij };
4623a198059SLinus Walleij
4633a198059SLinus Walleij static struct abx500_pinctrl_soc_data ab8500_soc = {
4643a198059SLinus Walleij .gpio_ranges = ab8500_pinranges,
4653a198059SLinus Walleij .gpio_num_ranges = ARRAY_SIZE(ab8500_pinranges),
4663a198059SLinus Walleij .pins = ab8500_pins,
4673a198059SLinus Walleij .npins = ARRAY_SIZE(ab8500_pins),
4683a198059SLinus Walleij .functions = ab8500_functions,
4693a198059SLinus Walleij .nfunctions = ARRAY_SIZE(ab8500_functions),
4703a198059SLinus Walleij .groups = ab8500_groups,
4713a198059SLinus Walleij .ngroups = ARRAY_SIZE(ab8500_groups),
4723a198059SLinus Walleij .alternate_functions = ab8500_alternate_functions,
4733a198059SLinus Walleij .gpio_irq_cluster = ab8500_gpio_irq_cluster,
4743a198059SLinus Walleij .ngpio_irq_cluster = ARRAY_SIZE(ab8500_gpio_irq_cluster),
4753a198059SLinus Walleij .irq_gpio_rising_offset = AB8500_INT_GPIO6R,
4763a198059SLinus Walleij .irq_gpio_falling_offset = AB8500_INT_GPIO6F,
4773a198059SLinus Walleij .irq_gpio_factor = 1,
4783a198059SLinus Walleij };
4793a198059SLinus Walleij
abx500_pinctrl_ab8500_init(struct abx500_pinctrl_soc_data ** soc)4803a198059SLinus Walleij void abx500_pinctrl_ab8500_init(struct abx500_pinctrl_soc_data **soc)
4813a198059SLinus Walleij {
4823a198059SLinus Walleij *soc = &ab8500_soc;
4833a198059SLinus Walleij }
484