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 AB8505_PIN_N4 ABX500_GPIO(1)
193a198059SLinus Walleij #define AB8505_PIN_R5 ABX500_GPIO(2)
203a198059SLinus Walleij #define AB8505_PIN_P5 ABX500_GPIO(3)
213a198059SLinus Walleij /* hole */
223a198059SLinus Walleij #define AB8505_PIN_B16 ABX500_GPIO(10)
233a198059SLinus Walleij #define AB8505_PIN_B17 ABX500_GPIO(11)
243a198059SLinus Walleij /* hole */
253a198059SLinus Walleij #define AB8505_PIN_D17 ABX500_GPIO(13)
263a198059SLinus Walleij #define AB8505_PIN_C16 ABX500_GPIO(14)
273a198059SLinus Walleij /* hole */
283a198059SLinus Walleij #define AB8505_PIN_P2 ABX500_GPIO(17)
293a198059SLinus Walleij #define AB8505_PIN_N3 ABX500_GPIO(18)
303a198059SLinus Walleij #define AB8505_PIN_T1 ABX500_GPIO(19)
313a198059SLinus Walleij #define AB8505_PIN_P3 ABX500_GPIO(20)
323a198059SLinus Walleij /* hole */
333a198059SLinus Walleij #define AB8505_PIN_H14 ABX500_GPIO(34)
343a198059SLinus Walleij /* hole */
353a198059SLinus Walleij #define AB8505_PIN_J15 ABX500_GPIO(40)
363a198059SLinus Walleij #define AB8505_PIN_J14 ABX500_GPIO(41)
373a198059SLinus Walleij /* hole */
383a198059SLinus Walleij #define AB8505_PIN_L4 ABX500_GPIO(50)
393a198059SLinus Walleij /* hole */
403a198059SLinus Walleij #define AB8505_PIN_D16 ABX500_GPIO(52)
413a198059SLinus Walleij #define AB8505_PIN_D15 ABX500_GPIO(53)
423a198059SLinus Walleij
433a198059SLinus Walleij /* indicates the higher GPIO number */
443a198059SLinus Walleij #define AB8505_GPIO_MAX_NUMBER 53
453a198059SLinus Walleij
463a198059SLinus Walleij /*
473a198059SLinus Walleij * The names of the pins are denoted by GPIO number and ball name, even
483a198059SLinus Walleij * though they can be used for other things than GPIO, this is the first
493a198059SLinus Walleij * column in the table of the data sheet and often used on schematics and
503a198059SLinus Walleij * such.
513a198059SLinus Walleij */
523a198059SLinus Walleij static const struct pinctrl_pin_desc ab8505_pins[] = {
533a198059SLinus Walleij PINCTRL_PIN(AB8505_PIN_N4, "GPIO1_N4"),
543a198059SLinus Walleij PINCTRL_PIN(AB8505_PIN_R5, "GPIO2_R5"),
553a198059SLinus Walleij PINCTRL_PIN(AB8505_PIN_P5, "GPIO3_P5"),
563a198059SLinus Walleij /* hole */
573a198059SLinus Walleij PINCTRL_PIN(AB8505_PIN_B16, "GPIO10_B16"),
583a198059SLinus Walleij PINCTRL_PIN(AB8505_PIN_B17, "GPIO11_B17"),
593a198059SLinus Walleij /* hole */
603a198059SLinus Walleij PINCTRL_PIN(AB8505_PIN_D17, "GPIO13_D17"),
613a198059SLinus Walleij PINCTRL_PIN(AB8505_PIN_C16, "GPIO14_C16"),
623a198059SLinus Walleij /* hole */
633a198059SLinus Walleij PINCTRL_PIN(AB8505_PIN_P2, "GPIO17_P2"),
643a198059SLinus Walleij PINCTRL_PIN(AB8505_PIN_N3, "GPIO18_N3"),
653a198059SLinus Walleij PINCTRL_PIN(AB8505_PIN_T1, "GPIO19_T1"),
663a198059SLinus Walleij PINCTRL_PIN(AB8505_PIN_P3, "GPIO20_P3"),
673a198059SLinus Walleij /* hole */
683a198059SLinus Walleij PINCTRL_PIN(AB8505_PIN_H14, "GPIO34_H14"),
693a198059SLinus Walleij /* hole */
703a198059SLinus Walleij PINCTRL_PIN(AB8505_PIN_J15, "GPIO40_J15"),
713a198059SLinus Walleij PINCTRL_PIN(AB8505_PIN_J14, "GPIO41_J14"),
723a198059SLinus Walleij /* hole */
733a198059SLinus Walleij PINCTRL_PIN(AB8505_PIN_L4, "GPIO50_L4"),
743a198059SLinus Walleij /* hole */
753a198059SLinus Walleij PINCTRL_PIN(AB8505_PIN_D16, "GPIO52_D16"),
763a198059SLinus Walleij PINCTRL_PIN(AB8505_PIN_D15, "GPIO53_D15"),
773a198059SLinus Walleij };
783a198059SLinus Walleij
793a198059SLinus Walleij /*
803a198059SLinus Walleij * Maps local GPIO offsets to local pin numbers
813a198059SLinus Walleij */
823a198059SLinus Walleij static const struct abx500_pinrange ab8505_pinranges[] = {
833a198059SLinus Walleij ABX500_PINRANGE(1, 3, ABX500_ALT_A),
843a198059SLinus Walleij ABX500_PINRANGE(10, 2, ABX500_DEFAULT),
853a198059SLinus Walleij ABX500_PINRANGE(13, 1, ABX500_DEFAULT),
863a198059SLinus Walleij ABX500_PINRANGE(14, 1, ABX500_ALT_A),
873a198059SLinus Walleij ABX500_PINRANGE(17, 4, ABX500_ALT_A),
883a198059SLinus Walleij ABX500_PINRANGE(34, 1, ABX500_ALT_A),
893a198059SLinus Walleij ABX500_PINRANGE(40, 2, ABX500_ALT_A),
903a198059SLinus Walleij ABX500_PINRANGE(50, 1, ABX500_DEFAULT),
913a198059SLinus Walleij ABX500_PINRANGE(52, 2, ABX500_ALT_A),
923a198059SLinus Walleij };
933a198059SLinus Walleij
943a198059SLinus Walleij /*
953a198059SLinus Walleij * Read the pin group names like this:
963a198059SLinus Walleij * sysclkreq2_d_1 = first groups of pins for sysclkreq2 on default function
973a198059SLinus Walleij *
983a198059SLinus Walleij * The groups are arranged as sets per altfunction column, so we can
993a198059SLinus Walleij * mux in one group at a time by selecting the same altfunction for them
1003a198059SLinus Walleij * all. When functions require pins on different altfunctions, you need
1013a198059SLinus Walleij * to combine several groups.
1023a198059SLinus Walleij */
1033a198059SLinus Walleij
1043a198059SLinus Walleij /* default column */
1053a198059SLinus Walleij static const unsigned sysclkreq2_d_1_pins[] = { AB8505_PIN_N4 };
1063a198059SLinus Walleij static const unsigned sysclkreq3_d_1_pins[] = { AB8505_PIN_R5 };
1073a198059SLinus Walleij static const unsigned sysclkreq4_d_1_pins[] = { AB8505_PIN_P5 };
1083a198059SLinus Walleij static const unsigned gpio10_d_1_pins[] = { AB8505_PIN_B16 };
1093a198059SLinus Walleij static const unsigned gpio11_d_1_pins[] = { AB8505_PIN_B17 };
1103a198059SLinus Walleij static const unsigned gpio13_d_1_pins[] = { AB8505_PIN_D17 };
1113a198059SLinus Walleij static const unsigned pwmout1_d_1_pins[] = { AB8505_PIN_C16 };
1123a198059SLinus Walleij /* audio data interface 2*/
1133a198059SLinus Walleij static const unsigned adi2_d_1_pins[] = { AB8505_PIN_P2, AB8505_PIN_N3,
1143a198059SLinus Walleij AB8505_PIN_T1, AB8505_PIN_P3 };
1153a198059SLinus Walleij static const unsigned extcpena_d_1_pins[] = { AB8505_PIN_H14 };
1163a198059SLinus Walleij /* modem SDA/SCL */
1173a198059SLinus Walleij static const unsigned modsclsda_d_1_pins[] = { AB8505_PIN_J15, AB8505_PIN_J14 };
1183a198059SLinus Walleij static const unsigned gpio50_d_1_pins[] = { AB8505_PIN_L4 };
1193a198059SLinus Walleij static const unsigned resethw_d_1_pins[] = { AB8505_PIN_D16 };
1203a198059SLinus Walleij static const unsigned service_d_1_pins[] = { AB8505_PIN_D15 };
1213a198059SLinus Walleij
1223a198059SLinus Walleij /* Altfunction A column */
1233a198059SLinus Walleij static const unsigned gpio1_a_1_pins[] = { AB8505_PIN_N4 };
1243a198059SLinus Walleij static const unsigned gpio2_a_1_pins[] = { AB8505_PIN_R5 };
1253a198059SLinus Walleij static const unsigned gpio3_a_1_pins[] = { AB8505_PIN_P5 };
1263a198059SLinus Walleij static const unsigned hiqclkena_a_1_pins[] = { AB8505_PIN_B16 };
1273a198059SLinus Walleij static const unsigned pdmclk_a_1_pins[] = { AB8505_PIN_B17 };
1283a198059SLinus Walleij static const unsigned uarttxdata_a_1_pins[] = { AB8505_PIN_D17 };
1293a198059SLinus Walleij static const unsigned gpio14_a_1_pins[] = { AB8505_PIN_C16 };
1303a198059SLinus Walleij static const unsigned gpio17_a_1_pins[] = { AB8505_PIN_P2 };
1313a198059SLinus Walleij static const unsigned gpio18_a_1_pins[] = { AB8505_PIN_N3 };
1323a198059SLinus Walleij static const unsigned gpio19_a_1_pins[] = { AB8505_PIN_T1 };
1333a198059SLinus Walleij static const unsigned gpio20_a_1_pins[] = { AB8505_PIN_P3 };
1343a198059SLinus Walleij static const unsigned gpio34_a_1_pins[] = { AB8505_PIN_H14 };
1353a198059SLinus Walleij static const unsigned gpio40_a_1_pins[] = { AB8505_PIN_J15 };
1363a198059SLinus Walleij static const unsigned gpio41_a_1_pins[] = { AB8505_PIN_J14 };
1373a198059SLinus Walleij static const unsigned uartrxdata_a_1_pins[] = { AB8505_PIN_J14 };
1383a198059SLinus Walleij static const unsigned gpio50_a_1_pins[] = { AB8505_PIN_L4 };
1393a198059SLinus Walleij static const unsigned gpio52_a_1_pins[] = { AB8505_PIN_D16 };
1403a198059SLinus Walleij static const unsigned gpio53_a_1_pins[] = { AB8505_PIN_D15 };
1413a198059SLinus Walleij
1423a198059SLinus Walleij /* Altfunction B colum */
1433a198059SLinus Walleij static const unsigned pdmdata_b_1_pins[] = { AB8505_PIN_B16 };
1443a198059SLinus Walleij static const unsigned extvibrapwm1_b_1_pins[] = { AB8505_PIN_D17 };
1453a198059SLinus Walleij static const unsigned extvibrapwm2_b_1_pins[] = { AB8505_PIN_L4 };
1463a198059SLinus Walleij
1473a198059SLinus Walleij /* Altfunction C column */
1483a198059SLinus Walleij static const unsigned usbvdat_c_1_pins[] = { AB8505_PIN_D17 };
1493a198059SLinus Walleij
1503a198059SLinus Walleij #define AB8505_PIN_GROUP(a, b) { .name = #a, .pins = a##_pins, \
1513a198059SLinus Walleij .npins = ARRAY_SIZE(a##_pins), .altsetting = b }
1523a198059SLinus Walleij
1533a198059SLinus Walleij static const struct abx500_pingroup ab8505_groups[] = {
1543a198059SLinus Walleij AB8505_PIN_GROUP(sysclkreq2_d_1, ABX500_DEFAULT),
1553a198059SLinus Walleij AB8505_PIN_GROUP(sysclkreq3_d_1, ABX500_DEFAULT),
1563a198059SLinus Walleij AB8505_PIN_GROUP(sysclkreq4_d_1, ABX500_DEFAULT),
1573a198059SLinus Walleij AB8505_PIN_GROUP(gpio10_d_1, ABX500_DEFAULT),
1583a198059SLinus Walleij AB8505_PIN_GROUP(gpio11_d_1, ABX500_DEFAULT),
1593a198059SLinus Walleij AB8505_PIN_GROUP(gpio13_d_1, ABX500_DEFAULT),
1603a198059SLinus Walleij AB8505_PIN_GROUP(pwmout1_d_1, ABX500_DEFAULT),
1613a198059SLinus Walleij AB8505_PIN_GROUP(adi2_d_1, ABX500_DEFAULT),
1623a198059SLinus Walleij AB8505_PIN_GROUP(extcpena_d_1, ABX500_DEFAULT),
1633a198059SLinus Walleij AB8505_PIN_GROUP(modsclsda_d_1, ABX500_DEFAULT),
1643a198059SLinus Walleij AB8505_PIN_GROUP(gpio50_d_1, ABX500_DEFAULT),
1653a198059SLinus Walleij AB8505_PIN_GROUP(resethw_d_1, ABX500_DEFAULT),
1663a198059SLinus Walleij AB8505_PIN_GROUP(service_d_1, ABX500_DEFAULT),
1673a198059SLinus Walleij AB8505_PIN_GROUP(gpio1_a_1, ABX500_ALT_A),
1683a198059SLinus Walleij AB8505_PIN_GROUP(gpio2_a_1, ABX500_ALT_A),
1693a198059SLinus Walleij AB8505_PIN_GROUP(gpio3_a_1, ABX500_ALT_A),
1703a198059SLinus Walleij AB8505_PIN_GROUP(hiqclkena_a_1, ABX500_ALT_A),
1713a198059SLinus Walleij AB8505_PIN_GROUP(pdmclk_a_1, ABX500_ALT_A),
1723a198059SLinus Walleij AB8505_PIN_GROUP(uarttxdata_a_1, ABX500_ALT_A),
1733a198059SLinus Walleij AB8505_PIN_GROUP(gpio14_a_1, ABX500_ALT_A),
1743a198059SLinus Walleij AB8505_PIN_GROUP(gpio17_a_1, ABX500_ALT_A),
1753a198059SLinus Walleij AB8505_PIN_GROUP(gpio18_a_1, ABX500_ALT_A),
1763a198059SLinus Walleij AB8505_PIN_GROUP(gpio19_a_1, ABX500_ALT_A),
1773a198059SLinus Walleij AB8505_PIN_GROUP(gpio20_a_1, ABX500_ALT_A),
1783a198059SLinus Walleij AB8505_PIN_GROUP(gpio34_a_1, ABX500_ALT_A),
1793a198059SLinus Walleij AB8505_PIN_GROUP(gpio40_a_1, ABX500_ALT_A),
1803a198059SLinus Walleij AB8505_PIN_GROUP(gpio41_a_1, ABX500_ALT_A),
1813a198059SLinus Walleij AB8505_PIN_GROUP(uartrxdata_a_1, ABX500_ALT_A),
182767972b9SLinus Walleij AB8505_PIN_GROUP(gpio50_a_1, ABX500_ALT_A),
1833a198059SLinus Walleij AB8505_PIN_GROUP(gpio52_a_1, ABX500_ALT_A),
1843a198059SLinus Walleij AB8505_PIN_GROUP(gpio53_a_1, ABX500_ALT_A),
1853a198059SLinus Walleij AB8505_PIN_GROUP(pdmdata_b_1, ABX500_ALT_B),
1863a198059SLinus Walleij AB8505_PIN_GROUP(extvibrapwm1_b_1, ABX500_ALT_B),
1873a198059SLinus Walleij AB8505_PIN_GROUP(extvibrapwm2_b_1, ABX500_ALT_B),
1883a198059SLinus Walleij AB8505_PIN_GROUP(usbvdat_c_1, ABX500_ALT_C),
1893a198059SLinus Walleij };
1903a198059SLinus Walleij
1913a198059SLinus Walleij /* We use this macro to define the groups applicable to a function */
1923a198059SLinus Walleij #define AB8505_FUNC_GROUPS(a, b...) \
1933a198059SLinus Walleij static const char * const a##_groups[] = { b };
1943a198059SLinus Walleij
1953a198059SLinus Walleij AB8505_FUNC_GROUPS(sysclkreq, "sysclkreq2_d_1", "sysclkreq3_d_1",
1963a198059SLinus Walleij "sysclkreq4_d_1");
1973a198059SLinus Walleij AB8505_FUNC_GROUPS(gpio, "gpio1_a_1", "gpio2_a_1", "gpio3_a_1",
1983a198059SLinus Walleij "gpio10_d_1", "gpio11_d_1", "gpio13_d_1", "gpio14_a_1",
1993a198059SLinus Walleij "gpio17_a_1", "gpio18_a_1", "gpio19_a_1", "gpio20_a_1",
2003a198059SLinus Walleij "gpio34_a_1", "gpio40_a_1", "gpio41_a_1", "gpio50_d_1",
2013a198059SLinus Walleij "gpio52_a_1", "gpio53_a_1");
2023a198059SLinus Walleij AB8505_FUNC_GROUPS(pwmout, "pwmout1_d_1");
2033a198059SLinus Walleij AB8505_FUNC_GROUPS(adi2, "adi2_d_1");
2043a198059SLinus Walleij AB8505_FUNC_GROUPS(extcpena, "extcpena_d_1");
2053a198059SLinus Walleij AB8505_FUNC_GROUPS(modsclsda, "modsclsda_d_1");
2063a198059SLinus Walleij AB8505_FUNC_GROUPS(resethw, "resethw_d_1");
2073a198059SLinus Walleij AB8505_FUNC_GROUPS(service, "service_d_1");
2083a198059SLinus Walleij AB8505_FUNC_GROUPS(hiqclkena, "hiqclkena_a_1");
2093a198059SLinus Walleij AB8505_FUNC_GROUPS(pdm, "pdmclk_a_1", "pdmdata_b_1");
2103a198059SLinus Walleij AB8505_FUNC_GROUPS(uartdata, "uarttxdata_a_1", "uartrxdata_a_1");
2113a198059SLinus Walleij AB8505_FUNC_GROUPS(extvibra, "extvibrapwm1_b_1", "extvibrapwm2_b_1");
2123a198059SLinus Walleij AB8505_FUNC_GROUPS(usbvdat, "usbvdat_c_1");
2133a198059SLinus Walleij
2143a198059SLinus Walleij #define FUNCTION(fname) \
2153a198059SLinus Walleij { \
2163a198059SLinus Walleij .name = #fname, \
2173a198059SLinus Walleij .groups = fname##_groups, \
2183a198059SLinus Walleij .ngroups = ARRAY_SIZE(fname##_groups), \
2193a198059SLinus Walleij }
2203a198059SLinus Walleij
2213a198059SLinus Walleij static const struct abx500_function ab8505_functions[] = {
2223a198059SLinus Walleij FUNCTION(sysclkreq),
2233a198059SLinus Walleij FUNCTION(gpio),
2243a198059SLinus Walleij FUNCTION(pwmout),
2253a198059SLinus Walleij FUNCTION(adi2),
2263a198059SLinus Walleij FUNCTION(extcpena),
2273a198059SLinus Walleij FUNCTION(modsclsda),
2283a198059SLinus Walleij FUNCTION(resethw),
2293a198059SLinus Walleij FUNCTION(service),
2303a198059SLinus Walleij FUNCTION(hiqclkena),
2313a198059SLinus Walleij FUNCTION(pdm),
2323a198059SLinus Walleij FUNCTION(uartdata),
2333a198059SLinus Walleij FUNCTION(extvibra),
2343a198059SLinus Walleij FUNCTION(extvibra),
2353a198059SLinus Walleij FUNCTION(usbvdat),
2363a198059SLinus Walleij };
2373a198059SLinus Walleij
2383a198059SLinus Walleij /*
2393a198059SLinus Walleij * this table translates what's is in the AB8505 specification regarding the
2403a198059SLinus Walleij * balls alternate functions (as for DB, default, ALT_A, ALT_B and ALT_C).
2413a198059SLinus Walleij * ALTERNATE_FUNCTIONS(GPIO_NUMBER, GPIOSEL bit, ALTERNATFUNC bit1,
2423a198059SLinus Walleij * ALTERNATEFUNC bit2, ALTA val, ALTB val, ALTC val),
2433a198059SLinus Walleij *
2443a198059SLinus Walleij * example :
2453a198059SLinus Walleij *
2463a198059SLinus Walleij * ALTERNATE_FUNCTIONS(13, 4, 3, 4, 1, 0, 2),
2473a198059SLinus Walleij * means that pin AB8505_PIN_D18 (pin 13) supports 4 mux (default/ALT_A,
2483a198059SLinus Walleij * ALT_B and ALT_C), so GPIOSEL and ALTERNATFUNC registers are used to
2493a198059SLinus Walleij * select the mux. ALTA, ALTB and ALTC val indicates values to write in
2503a198059SLinus Walleij * ALTERNATFUNC register. We need to specifies these values as SOC
2513a198059SLinus Walleij * designers didn't apply the same logic on how to select mux in the
2523a198059SLinus Walleij * ABx500 family.
2533a198059SLinus Walleij *
2543a198059SLinus Walleij * As this pins supports at least ALT_B mux, default mux is
2553a198059SLinus Walleij * selected by writing 1 in GPIOSEL bit :
2563a198059SLinus Walleij *
2573a198059SLinus Walleij * | GPIOSEL bit=4 | alternatfunc bit2=4 | alternatfunc bit1=3
2583a198059SLinus Walleij * default | 1 | 0 | 0
2593a198059SLinus Walleij * alt_A | 0 | 0 | 1
2603a198059SLinus Walleij * alt_B | 0 | 0 | 0
2613a198059SLinus Walleij * alt_C | 0 | 1 | 0
2623a198059SLinus Walleij *
2633a198059SLinus Walleij * ALTERNATE_FUNCTIONS(1, 0, UNUSED, UNUSED),
2643a198059SLinus Walleij * means that pin AB9540_PIN_R4 (pin 1) supports 2 mux, so only GPIOSEL
2653a198059SLinus Walleij * register is used to select the mux. As this pins doesn't support at
2663a198059SLinus Walleij * least ALT_B mux, default mux is by writing 0 in GPIOSEL bit :
2673a198059SLinus Walleij *
2683a198059SLinus Walleij * | GPIOSEL bit=0 | alternatfunc bit2= | alternatfunc bit1=
2693a198059SLinus Walleij * default | 0 | 0 | 0
2703a198059SLinus Walleij * alt_A | 1 | 0 | 0
2713a198059SLinus Walleij */
2723a198059SLinus Walleij
2733a198059SLinus Walleij static struct
2743a198059SLinus Walleij alternate_functions ab8505_alternate_functions[AB8505_GPIO_MAX_NUMBER + 1] = {
2753a198059SLinus Walleij ALTERNATE_FUNCTIONS(0, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO0 */
2763a198059SLinus Walleij ALTERNATE_FUNCTIONS(1, 0, UNUSED, UNUSED, 0, 0, 0), /* GPIO1, altA controlled by bit 0 */
2773a198059SLinus Walleij ALTERNATE_FUNCTIONS(2, 1, UNUSED, UNUSED, 0, 0, 0), /* GPIO2, altA controlled by bit 1 */
2783a198059SLinus Walleij ALTERNATE_FUNCTIONS(3, 2, UNUSED, UNUSED, 0, 0, 0), /* GPIO3, altA controlled by bit 2*/
2793a198059SLinus Walleij ALTERNATE_FUNCTIONS(4, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO4, bit 3 reserved */
2803a198059SLinus Walleij ALTERNATE_FUNCTIONS(5, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO5, bit 4 reserved */
2813a198059SLinus Walleij ALTERNATE_FUNCTIONS(6, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO6, bit 5 reserved */
2823a198059SLinus Walleij ALTERNATE_FUNCTIONS(7, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO7, bit 6 reserved */
2833a198059SLinus Walleij ALTERNATE_FUNCTIONS(8, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO8, bit 7 reserved */
2843a198059SLinus Walleij
2853a198059SLinus Walleij ALTERNATE_FUNCTIONS(9, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO9, bit 0 reserved */
2863a198059SLinus Walleij ALTERNATE_FUNCTIONS(10, 1, 0, UNUSED, 1, 0, 0), /* GPIO10, altA and altB controlled by bit 0 */
2873a198059SLinus Walleij ALTERNATE_FUNCTIONS(11, 2, 1, UNUSED, 0, 0, 0), /* GPIO11, altA controlled by bit 2 */
2885b441ebaSGeert Uytterhoeven ALTERNATE_FUNCTIONS(12, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO12, bit3 reserved */
2893a198059SLinus Walleij ALTERNATE_FUNCTIONS(13, 4, 3, 4, 1, 0, 2), /* GPIO13, altA altB and altC controlled by bit 3 and 4 */
2903a198059SLinus Walleij ALTERNATE_FUNCTIONS(14, 5, UNUSED, UNUSED, 0, 0, 0), /* GPIO14, altA controlled by bit 5 */
2913a198059SLinus Walleij ALTERNATE_FUNCTIONS(15, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO15, bit 6 reserved */
2923a198059SLinus Walleij ALTERNATE_FUNCTIONS(16, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO15, bit 7 reserved */
2933a198059SLinus Walleij /*
2943a198059SLinus Walleij * pins 17 to 20 are special case, only bit 0 is used to select
2953a198059SLinus Walleij * alternate function for these 4 pins.
2963a198059SLinus Walleij * bits 1 to 3 are reserved
2973a198059SLinus Walleij */
2983a198059SLinus Walleij ALTERNATE_FUNCTIONS(17, 0, UNUSED, UNUSED, 0, 0, 0), /* GPIO17, altA controlled by bit 0 */
2993a198059SLinus Walleij ALTERNATE_FUNCTIONS(18, 0, UNUSED, UNUSED, 0, 0, 0), /* GPIO18, altA controlled by bit 0 */
3003a198059SLinus Walleij ALTERNATE_FUNCTIONS(19, 0, UNUSED, UNUSED, 0, 0, 0), /* GPIO19, altA controlled by bit 0 */
3013a198059SLinus Walleij ALTERNATE_FUNCTIONS(20, 0, UNUSED, UNUSED, 0, 0, 0), /* GPIO20, altA controlled by bit 0 */
3023a198059SLinus Walleij ALTERNATE_FUNCTIONS(21, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO21, bit 4 reserved */
3033a198059SLinus Walleij ALTERNATE_FUNCTIONS(22, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO22, bit 5 reserved */
3043a198059SLinus Walleij ALTERNATE_FUNCTIONS(23, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO23, bit 6 reserved */
3053a198059SLinus Walleij ALTERNATE_FUNCTIONS(24, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO24, bit 7 reserved */
3063a198059SLinus Walleij
3073a198059SLinus Walleij ALTERNATE_FUNCTIONS(25, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO25, bit 0 reserved */
3083a198059SLinus Walleij ALTERNATE_FUNCTIONS(26, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO26, bit 1 reserved */
3093a198059SLinus Walleij ALTERNATE_FUNCTIONS(27, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO27, bit 2 reserved */
3103a198059SLinus Walleij ALTERNATE_FUNCTIONS(28, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO28, bit 3 reserved */
3113a198059SLinus Walleij ALTERNATE_FUNCTIONS(29, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO29, bit 4 reserved */
3123a198059SLinus Walleij ALTERNATE_FUNCTIONS(30, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO30, bit 5 reserved */
3133a198059SLinus Walleij ALTERNATE_FUNCTIONS(31, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO31, bit 6 reserved */
3143a198059SLinus Walleij ALTERNATE_FUNCTIONS(32, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO32, bit 7 reserved */
3153a198059SLinus Walleij
3163a198059SLinus Walleij ALTERNATE_FUNCTIONS(33, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO33, bit 0 reserved */
3173a198059SLinus Walleij ALTERNATE_FUNCTIONS(34, 1, UNUSED, UNUSED, 0, 0, 0), /* GPIO34, altA controlled by bit 1 */
3183a198059SLinus Walleij ALTERNATE_FUNCTIONS(35, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO35, bit 2 reserved */
3193a198059SLinus Walleij ALTERNATE_FUNCTIONS(36, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO36, bit 2 reserved */
3203a198059SLinus Walleij ALTERNATE_FUNCTIONS(37, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO37, bit 2 reserved */
3213a198059SLinus Walleij ALTERNATE_FUNCTIONS(38, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO38, bit 2 reserved */
3223a198059SLinus Walleij ALTERNATE_FUNCTIONS(39, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO39, bit 2 reserved */
3233a198059SLinus Walleij ALTERNATE_FUNCTIONS(40, 7, UNUSED, UNUSED, 0, 0, 0), /* GPIO40, altA controlled by bit 7*/
3243a198059SLinus Walleij
3253a198059SLinus Walleij ALTERNATE_FUNCTIONS(41, 0, UNUSED, UNUSED, 0, 0, 0), /* GPIO41, altA controlled by bit 0 */
3263a198059SLinus Walleij ALTERNATE_FUNCTIONS(42, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO42, bit 1 reserved */
3273a198059SLinus Walleij ALTERNATE_FUNCTIONS(43, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO43, bit 2 reserved */
3283a198059SLinus Walleij ALTERNATE_FUNCTIONS(44, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO44, bit 3 reserved */
3293a198059SLinus Walleij ALTERNATE_FUNCTIONS(45, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO45, bit 4 reserved */
3303a198059SLinus Walleij ALTERNATE_FUNCTIONS(46, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO46, bit 5 reserved */
3313a198059SLinus Walleij ALTERNATE_FUNCTIONS(47, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO47, bit 6 reserved */
3323a198059SLinus Walleij ALTERNATE_FUNCTIONS(48, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO48, bit 7 reserved */
3333a198059SLinus Walleij
3343a198059SLinus Walleij ALTERNATE_FUNCTIONS(49, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO49, bit 0 reserved */
3353a198059SLinus Walleij ALTERNATE_FUNCTIONS(50, 1, 2, UNUSED, 1, 0, 0), /* GPIO50, altA controlled by bit 1 */
3363a198059SLinus Walleij ALTERNATE_FUNCTIONS(51, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO49, bit 0 reserved */
3373a198059SLinus Walleij ALTERNATE_FUNCTIONS(52, 3, UNUSED, UNUSED, 0, 0, 0), /* GPIO52, altA controlled by bit 3 */
3383a198059SLinus Walleij ALTERNATE_FUNCTIONS(53, 4, UNUSED, UNUSED, 0, 0, 0), /* GPIO53, altA controlled by bit 4 */
3393a198059SLinus Walleij };
3403a198059SLinus Walleij
3413a198059SLinus Walleij /*
3423a198059SLinus Walleij * For AB8505 Only some GPIOs are interrupt capable, and they are
3433a198059SLinus Walleij * organized in discontiguous clusters:
3443a198059SLinus Walleij *
3453a198059SLinus Walleij * GPIO10 to GPIO11
3463a198059SLinus Walleij * GPIO13
3473a198059SLinus Walleij * GPIO40 and GPIO41
3483a198059SLinus Walleij * GPIO50
3493a198059SLinus Walleij * GPIO52 to GPIO53
3503a198059SLinus Walleij */
3513a198059SLinus Walleij static struct abx500_gpio_irq_cluster ab8505_gpio_irq_cluster[] = {
3523a198059SLinus Walleij GPIO_IRQ_CLUSTER(10, 11, AB8500_INT_GPIO10R),
3533a198059SLinus Walleij GPIO_IRQ_CLUSTER(13, 13, AB8500_INT_GPIO13R),
3543a198059SLinus Walleij GPIO_IRQ_CLUSTER(40, 41, AB8500_INT_GPIO40R),
3553a198059SLinus Walleij GPIO_IRQ_CLUSTER(50, 50, AB9540_INT_GPIO50R),
3563a198059SLinus Walleij GPIO_IRQ_CLUSTER(52, 53, AB9540_INT_GPIO52R),
3573a198059SLinus Walleij };
3583a198059SLinus Walleij
3593a198059SLinus Walleij static struct abx500_pinctrl_soc_data ab8505_soc = {
3603a198059SLinus Walleij .gpio_ranges = ab8505_pinranges,
3613a198059SLinus Walleij .gpio_num_ranges = ARRAY_SIZE(ab8505_pinranges),
3623a198059SLinus Walleij .pins = ab8505_pins,
3633a198059SLinus Walleij .npins = ARRAY_SIZE(ab8505_pins),
3643a198059SLinus Walleij .functions = ab8505_functions,
3653a198059SLinus Walleij .nfunctions = ARRAY_SIZE(ab8505_functions),
3663a198059SLinus Walleij .groups = ab8505_groups,
3673a198059SLinus Walleij .ngroups = ARRAY_SIZE(ab8505_groups),
3683a198059SLinus Walleij .alternate_functions = ab8505_alternate_functions,
3693a198059SLinus Walleij .gpio_irq_cluster = ab8505_gpio_irq_cluster,
3703a198059SLinus Walleij .ngpio_irq_cluster = ARRAY_SIZE(ab8505_gpio_irq_cluster),
3713a198059SLinus Walleij .irq_gpio_rising_offset = AB8500_INT_GPIO6R,
3723a198059SLinus Walleij .irq_gpio_falling_offset = AB8500_INT_GPIO6F,
3733a198059SLinus Walleij .irq_gpio_factor = 1,
3743a198059SLinus Walleij };
3753a198059SLinus Walleij
3763a198059SLinus Walleij void
abx500_pinctrl_ab8505_init(struct abx500_pinctrl_soc_data ** soc)3773a198059SLinus Walleij abx500_pinctrl_ab8505_init(struct abx500_pinctrl_soc_data **soc)
3783a198059SLinus Walleij {
3793a198059SLinus Walleij *soc = &ab8505_soc;
3803a198059SLinus Walleij }
381