1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0-only
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun * Copyright (C) ST-Ericsson SA 2012
4*4882a593Smuzhiyun *
5*4882a593Smuzhiyun * Author: Patrice Chotard <patrice.chotard@stericsson.com> for ST-Ericsson.
6*4882a593Smuzhiyun */
7*4882a593Smuzhiyun
8*4882a593Smuzhiyun #include <linux/kernel.h>
9*4882a593Smuzhiyun #include <linux/gpio/driver.h>
10*4882a593Smuzhiyun #include <linux/pinctrl/pinctrl.h>
11*4882a593Smuzhiyun #include <linux/mfd/abx500/ab8500.h>
12*4882a593Smuzhiyun #include "pinctrl-abx500.h"
13*4882a593Smuzhiyun
14*4882a593Smuzhiyun /* All the pins that can be used for GPIO and some other functions */
15*4882a593Smuzhiyun #define ABX500_GPIO(offset) (offset)
16*4882a593Smuzhiyun
17*4882a593Smuzhiyun #define AB8505_PIN_N4 ABX500_GPIO(1)
18*4882a593Smuzhiyun #define AB8505_PIN_R5 ABX500_GPIO(2)
19*4882a593Smuzhiyun #define AB8505_PIN_P5 ABX500_GPIO(3)
20*4882a593Smuzhiyun /* hole */
21*4882a593Smuzhiyun #define AB8505_PIN_B16 ABX500_GPIO(10)
22*4882a593Smuzhiyun #define AB8505_PIN_B17 ABX500_GPIO(11)
23*4882a593Smuzhiyun /* hole */
24*4882a593Smuzhiyun #define AB8505_PIN_D17 ABX500_GPIO(13)
25*4882a593Smuzhiyun #define AB8505_PIN_C16 ABX500_GPIO(14)
26*4882a593Smuzhiyun /* hole */
27*4882a593Smuzhiyun #define AB8505_PIN_P2 ABX500_GPIO(17)
28*4882a593Smuzhiyun #define AB8505_PIN_N3 ABX500_GPIO(18)
29*4882a593Smuzhiyun #define AB8505_PIN_T1 ABX500_GPIO(19)
30*4882a593Smuzhiyun #define AB8505_PIN_P3 ABX500_GPIO(20)
31*4882a593Smuzhiyun /* hole */
32*4882a593Smuzhiyun #define AB8505_PIN_H14 ABX500_GPIO(34)
33*4882a593Smuzhiyun /* hole */
34*4882a593Smuzhiyun #define AB8505_PIN_J15 ABX500_GPIO(40)
35*4882a593Smuzhiyun #define AB8505_PIN_J14 ABX500_GPIO(41)
36*4882a593Smuzhiyun /* hole */
37*4882a593Smuzhiyun #define AB8505_PIN_L4 ABX500_GPIO(50)
38*4882a593Smuzhiyun /* hole */
39*4882a593Smuzhiyun #define AB8505_PIN_D16 ABX500_GPIO(52)
40*4882a593Smuzhiyun #define AB8505_PIN_D15 ABX500_GPIO(53)
41*4882a593Smuzhiyun
42*4882a593Smuzhiyun /* indicates the higher GPIO number */
43*4882a593Smuzhiyun #define AB8505_GPIO_MAX_NUMBER 53
44*4882a593Smuzhiyun
45*4882a593Smuzhiyun /*
46*4882a593Smuzhiyun * The names of the pins are denoted by GPIO number and ball name, even
47*4882a593Smuzhiyun * though they can be used for other things than GPIO, this is the first
48*4882a593Smuzhiyun * column in the table of the data sheet and often used on schematics and
49*4882a593Smuzhiyun * such.
50*4882a593Smuzhiyun */
51*4882a593Smuzhiyun static const struct pinctrl_pin_desc ab8505_pins[] = {
52*4882a593Smuzhiyun PINCTRL_PIN(AB8505_PIN_N4, "GPIO1_N4"),
53*4882a593Smuzhiyun PINCTRL_PIN(AB8505_PIN_R5, "GPIO2_R5"),
54*4882a593Smuzhiyun PINCTRL_PIN(AB8505_PIN_P5, "GPIO3_P5"),
55*4882a593Smuzhiyun /* hole */
56*4882a593Smuzhiyun PINCTRL_PIN(AB8505_PIN_B16, "GPIO10_B16"),
57*4882a593Smuzhiyun PINCTRL_PIN(AB8505_PIN_B17, "GPIO11_B17"),
58*4882a593Smuzhiyun /* hole */
59*4882a593Smuzhiyun PINCTRL_PIN(AB8505_PIN_D17, "GPIO13_D17"),
60*4882a593Smuzhiyun PINCTRL_PIN(AB8505_PIN_C16, "GPIO14_C16"),
61*4882a593Smuzhiyun /* hole */
62*4882a593Smuzhiyun PINCTRL_PIN(AB8505_PIN_P2, "GPIO17_P2"),
63*4882a593Smuzhiyun PINCTRL_PIN(AB8505_PIN_N3, "GPIO18_N3"),
64*4882a593Smuzhiyun PINCTRL_PIN(AB8505_PIN_T1, "GPIO19_T1"),
65*4882a593Smuzhiyun PINCTRL_PIN(AB8505_PIN_P3, "GPIO20_P3"),
66*4882a593Smuzhiyun /* hole */
67*4882a593Smuzhiyun PINCTRL_PIN(AB8505_PIN_H14, "GPIO34_H14"),
68*4882a593Smuzhiyun /* hole */
69*4882a593Smuzhiyun PINCTRL_PIN(AB8505_PIN_J15, "GPIO40_J15"),
70*4882a593Smuzhiyun PINCTRL_PIN(AB8505_PIN_J14, "GPIO41_J14"),
71*4882a593Smuzhiyun /* hole */
72*4882a593Smuzhiyun PINCTRL_PIN(AB8505_PIN_L4, "GPIO50_L4"),
73*4882a593Smuzhiyun /* hole */
74*4882a593Smuzhiyun PINCTRL_PIN(AB8505_PIN_D16, "GPIO52_D16"),
75*4882a593Smuzhiyun PINCTRL_PIN(AB8505_PIN_D15, "GPIO53_D15"),
76*4882a593Smuzhiyun };
77*4882a593Smuzhiyun
78*4882a593Smuzhiyun /*
79*4882a593Smuzhiyun * Maps local GPIO offsets to local pin numbers
80*4882a593Smuzhiyun */
81*4882a593Smuzhiyun static const struct abx500_pinrange ab8505_pinranges[] = {
82*4882a593Smuzhiyun ABX500_PINRANGE(1, 3, ABX500_ALT_A),
83*4882a593Smuzhiyun ABX500_PINRANGE(10, 2, ABX500_DEFAULT),
84*4882a593Smuzhiyun ABX500_PINRANGE(13, 1, ABX500_DEFAULT),
85*4882a593Smuzhiyun ABX500_PINRANGE(14, 1, ABX500_ALT_A),
86*4882a593Smuzhiyun ABX500_PINRANGE(17, 4, ABX500_ALT_A),
87*4882a593Smuzhiyun ABX500_PINRANGE(34, 1, ABX500_ALT_A),
88*4882a593Smuzhiyun ABX500_PINRANGE(40, 2, ABX500_ALT_A),
89*4882a593Smuzhiyun ABX500_PINRANGE(50, 1, ABX500_DEFAULT),
90*4882a593Smuzhiyun ABX500_PINRANGE(52, 2, ABX500_ALT_A),
91*4882a593Smuzhiyun };
92*4882a593Smuzhiyun
93*4882a593Smuzhiyun /*
94*4882a593Smuzhiyun * Read the pin group names like this:
95*4882a593Smuzhiyun * sysclkreq2_d_1 = first groups of pins for sysclkreq2 on default function
96*4882a593Smuzhiyun *
97*4882a593Smuzhiyun * The groups are arranged as sets per altfunction column, so we can
98*4882a593Smuzhiyun * mux in one group at a time by selecting the same altfunction for them
99*4882a593Smuzhiyun * all. When functions require pins on different altfunctions, you need
100*4882a593Smuzhiyun * to combine several groups.
101*4882a593Smuzhiyun */
102*4882a593Smuzhiyun
103*4882a593Smuzhiyun /* default column */
104*4882a593Smuzhiyun static const unsigned sysclkreq2_d_1_pins[] = { AB8505_PIN_N4 };
105*4882a593Smuzhiyun static const unsigned sysclkreq3_d_1_pins[] = { AB8505_PIN_R5 };
106*4882a593Smuzhiyun static const unsigned sysclkreq4_d_1_pins[] = { AB8505_PIN_P5 };
107*4882a593Smuzhiyun static const unsigned gpio10_d_1_pins[] = { AB8505_PIN_B16 };
108*4882a593Smuzhiyun static const unsigned gpio11_d_1_pins[] = { AB8505_PIN_B17 };
109*4882a593Smuzhiyun static const unsigned gpio13_d_1_pins[] = { AB8505_PIN_D17 };
110*4882a593Smuzhiyun static const unsigned pwmout1_d_1_pins[] = { AB8505_PIN_C16 };
111*4882a593Smuzhiyun /* audio data interface 2*/
112*4882a593Smuzhiyun static const unsigned adi2_d_1_pins[] = { AB8505_PIN_P2, AB8505_PIN_N3,
113*4882a593Smuzhiyun AB8505_PIN_T1, AB8505_PIN_P3 };
114*4882a593Smuzhiyun static const unsigned extcpena_d_1_pins[] = { AB8505_PIN_H14 };
115*4882a593Smuzhiyun /* modem SDA/SCL */
116*4882a593Smuzhiyun static const unsigned modsclsda_d_1_pins[] = { AB8505_PIN_J15, AB8505_PIN_J14 };
117*4882a593Smuzhiyun static const unsigned gpio50_d_1_pins[] = { AB8505_PIN_L4 };
118*4882a593Smuzhiyun static const unsigned resethw_d_1_pins[] = { AB8505_PIN_D16 };
119*4882a593Smuzhiyun static const unsigned service_d_1_pins[] = { AB8505_PIN_D15 };
120*4882a593Smuzhiyun
121*4882a593Smuzhiyun /* Altfunction A column */
122*4882a593Smuzhiyun static const unsigned gpio1_a_1_pins[] = { AB8505_PIN_N4 };
123*4882a593Smuzhiyun static const unsigned gpio2_a_1_pins[] = { AB8505_PIN_R5 };
124*4882a593Smuzhiyun static const unsigned gpio3_a_1_pins[] = { AB8505_PIN_P5 };
125*4882a593Smuzhiyun static const unsigned hiqclkena_a_1_pins[] = { AB8505_PIN_B16 };
126*4882a593Smuzhiyun static const unsigned pdmclk_a_1_pins[] = { AB8505_PIN_B17 };
127*4882a593Smuzhiyun static const unsigned uarttxdata_a_1_pins[] = { AB8505_PIN_D17 };
128*4882a593Smuzhiyun static const unsigned gpio14_a_1_pins[] = { AB8505_PIN_C16 };
129*4882a593Smuzhiyun static const unsigned gpio17_a_1_pins[] = { AB8505_PIN_P2 };
130*4882a593Smuzhiyun static const unsigned gpio18_a_1_pins[] = { AB8505_PIN_N3 };
131*4882a593Smuzhiyun static const unsigned gpio19_a_1_pins[] = { AB8505_PIN_T1 };
132*4882a593Smuzhiyun static const unsigned gpio20_a_1_pins[] = { AB8505_PIN_P3 };
133*4882a593Smuzhiyun static const unsigned gpio34_a_1_pins[] = { AB8505_PIN_H14 };
134*4882a593Smuzhiyun static const unsigned gpio40_a_1_pins[] = { AB8505_PIN_J15 };
135*4882a593Smuzhiyun static const unsigned gpio41_a_1_pins[] = { AB8505_PIN_J14 };
136*4882a593Smuzhiyun static const unsigned uartrxdata_a_1_pins[] = { AB8505_PIN_J14 };
137*4882a593Smuzhiyun static const unsigned gpio50_a_1_pins[] = { AB8505_PIN_L4 };
138*4882a593Smuzhiyun static const unsigned gpio52_a_1_pins[] = { AB8505_PIN_D16 };
139*4882a593Smuzhiyun static const unsigned gpio53_a_1_pins[] = { AB8505_PIN_D15 };
140*4882a593Smuzhiyun
141*4882a593Smuzhiyun /* Altfunction B colum */
142*4882a593Smuzhiyun static const unsigned pdmdata_b_1_pins[] = { AB8505_PIN_B16 };
143*4882a593Smuzhiyun static const unsigned extvibrapwm1_b_1_pins[] = { AB8505_PIN_D17 };
144*4882a593Smuzhiyun static const unsigned extvibrapwm2_b_1_pins[] = { AB8505_PIN_L4 };
145*4882a593Smuzhiyun
146*4882a593Smuzhiyun /* Altfunction C column */
147*4882a593Smuzhiyun static const unsigned usbvdat_c_1_pins[] = { AB8505_PIN_D17 };
148*4882a593Smuzhiyun
149*4882a593Smuzhiyun #define AB8505_PIN_GROUP(a, b) { .name = #a, .pins = a##_pins, \
150*4882a593Smuzhiyun .npins = ARRAY_SIZE(a##_pins), .altsetting = b }
151*4882a593Smuzhiyun
152*4882a593Smuzhiyun static const struct abx500_pingroup ab8505_groups[] = {
153*4882a593Smuzhiyun AB8505_PIN_GROUP(sysclkreq2_d_1, ABX500_DEFAULT),
154*4882a593Smuzhiyun AB8505_PIN_GROUP(sysclkreq3_d_1, ABX500_DEFAULT),
155*4882a593Smuzhiyun AB8505_PIN_GROUP(sysclkreq4_d_1, ABX500_DEFAULT),
156*4882a593Smuzhiyun AB8505_PIN_GROUP(gpio10_d_1, ABX500_DEFAULT),
157*4882a593Smuzhiyun AB8505_PIN_GROUP(gpio11_d_1, ABX500_DEFAULT),
158*4882a593Smuzhiyun AB8505_PIN_GROUP(gpio13_d_1, ABX500_DEFAULT),
159*4882a593Smuzhiyun AB8505_PIN_GROUP(pwmout1_d_1, ABX500_DEFAULT),
160*4882a593Smuzhiyun AB8505_PIN_GROUP(adi2_d_1, ABX500_DEFAULT),
161*4882a593Smuzhiyun AB8505_PIN_GROUP(extcpena_d_1, ABX500_DEFAULT),
162*4882a593Smuzhiyun AB8505_PIN_GROUP(modsclsda_d_1, ABX500_DEFAULT),
163*4882a593Smuzhiyun AB8505_PIN_GROUP(gpio50_d_1, ABX500_DEFAULT),
164*4882a593Smuzhiyun AB8505_PIN_GROUP(resethw_d_1, ABX500_DEFAULT),
165*4882a593Smuzhiyun AB8505_PIN_GROUP(service_d_1, ABX500_DEFAULT),
166*4882a593Smuzhiyun AB8505_PIN_GROUP(gpio1_a_1, ABX500_ALT_A),
167*4882a593Smuzhiyun AB8505_PIN_GROUP(gpio2_a_1, ABX500_ALT_A),
168*4882a593Smuzhiyun AB8505_PIN_GROUP(gpio3_a_1, ABX500_ALT_A),
169*4882a593Smuzhiyun AB8505_PIN_GROUP(hiqclkena_a_1, ABX500_ALT_A),
170*4882a593Smuzhiyun AB8505_PIN_GROUP(pdmclk_a_1, ABX500_ALT_A),
171*4882a593Smuzhiyun AB8505_PIN_GROUP(uarttxdata_a_1, ABX500_ALT_A),
172*4882a593Smuzhiyun AB8505_PIN_GROUP(gpio14_a_1, ABX500_ALT_A),
173*4882a593Smuzhiyun AB8505_PIN_GROUP(gpio17_a_1, ABX500_ALT_A),
174*4882a593Smuzhiyun AB8505_PIN_GROUP(gpio18_a_1, ABX500_ALT_A),
175*4882a593Smuzhiyun AB8505_PIN_GROUP(gpio19_a_1, ABX500_ALT_A),
176*4882a593Smuzhiyun AB8505_PIN_GROUP(gpio20_a_1, ABX500_ALT_A),
177*4882a593Smuzhiyun AB8505_PIN_GROUP(gpio34_a_1, ABX500_ALT_A),
178*4882a593Smuzhiyun AB8505_PIN_GROUP(gpio40_a_1, ABX500_ALT_A),
179*4882a593Smuzhiyun AB8505_PIN_GROUP(gpio41_a_1, ABX500_ALT_A),
180*4882a593Smuzhiyun AB8505_PIN_GROUP(uartrxdata_a_1, ABX500_ALT_A),
181*4882a593Smuzhiyun AB8505_PIN_GROUP(gpio50_a_1, ABX500_ALT_A),
182*4882a593Smuzhiyun AB8505_PIN_GROUP(gpio52_a_1, ABX500_ALT_A),
183*4882a593Smuzhiyun AB8505_PIN_GROUP(gpio53_a_1, ABX500_ALT_A),
184*4882a593Smuzhiyun AB8505_PIN_GROUP(pdmdata_b_1, ABX500_ALT_B),
185*4882a593Smuzhiyun AB8505_PIN_GROUP(extvibrapwm1_b_1, ABX500_ALT_B),
186*4882a593Smuzhiyun AB8505_PIN_GROUP(extvibrapwm2_b_1, ABX500_ALT_B),
187*4882a593Smuzhiyun AB8505_PIN_GROUP(usbvdat_c_1, ABX500_ALT_C),
188*4882a593Smuzhiyun };
189*4882a593Smuzhiyun
190*4882a593Smuzhiyun /* We use this macro to define the groups applicable to a function */
191*4882a593Smuzhiyun #define AB8505_FUNC_GROUPS(a, b...) \
192*4882a593Smuzhiyun static const char * const a##_groups[] = { b };
193*4882a593Smuzhiyun
194*4882a593Smuzhiyun AB8505_FUNC_GROUPS(sysclkreq, "sysclkreq2_d_1", "sysclkreq3_d_1",
195*4882a593Smuzhiyun "sysclkreq4_d_1");
196*4882a593Smuzhiyun AB8505_FUNC_GROUPS(gpio, "gpio1_a_1", "gpio2_a_1", "gpio3_a_1",
197*4882a593Smuzhiyun "gpio10_d_1", "gpio11_d_1", "gpio13_d_1", "gpio14_a_1",
198*4882a593Smuzhiyun "gpio17_a_1", "gpio18_a_1", "gpio19_a_1", "gpio20_a_1",
199*4882a593Smuzhiyun "gpio34_a_1", "gpio40_a_1", "gpio41_a_1", "gpio50_d_1",
200*4882a593Smuzhiyun "gpio52_a_1", "gpio53_a_1");
201*4882a593Smuzhiyun AB8505_FUNC_GROUPS(pwmout, "pwmout1_d_1");
202*4882a593Smuzhiyun AB8505_FUNC_GROUPS(adi2, "adi2_d_1");
203*4882a593Smuzhiyun AB8505_FUNC_GROUPS(extcpena, "extcpena_d_1");
204*4882a593Smuzhiyun AB8505_FUNC_GROUPS(modsclsda, "modsclsda_d_1");
205*4882a593Smuzhiyun AB8505_FUNC_GROUPS(resethw, "resethw_d_1");
206*4882a593Smuzhiyun AB8505_FUNC_GROUPS(service, "service_d_1");
207*4882a593Smuzhiyun AB8505_FUNC_GROUPS(hiqclkena, "hiqclkena_a_1");
208*4882a593Smuzhiyun AB8505_FUNC_GROUPS(pdm, "pdmclk_a_1", "pdmdata_b_1");
209*4882a593Smuzhiyun AB8505_FUNC_GROUPS(uartdata, "uarttxdata_a_1", "uartrxdata_a_1");
210*4882a593Smuzhiyun AB8505_FUNC_GROUPS(extvibra, "extvibrapwm1_b_1", "extvibrapwm2_b_1");
211*4882a593Smuzhiyun AB8505_FUNC_GROUPS(usbvdat, "usbvdat_c_1");
212*4882a593Smuzhiyun
213*4882a593Smuzhiyun #define FUNCTION(fname) \
214*4882a593Smuzhiyun { \
215*4882a593Smuzhiyun .name = #fname, \
216*4882a593Smuzhiyun .groups = fname##_groups, \
217*4882a593Smuzhiyun .ngroups = ARRAY_SIZE(fname##_groups), \
218*4882a593Smuzhiyun }
219*4882a593Smuzhiyun
220*4882a593Smuzhiyun static const struct abx500_function ab8505_functions[] = {
221*4882a593Smuzhiyun FUNCTION(sysclkreq),
222*4882a593Smuzhiyun FUNCTION(gpio),
223*4882a593Smuzhiyun FUNCTION(pwmout),
224*4882a593Smuzhiyun FUNCTION(adi2),
225*4882a593Smuzhiyun FUNCTION(extcpena),
226*4882a593Smuzhiyun FUNCTION(modsclsda),
227*4882a593Smuzhiyun FUNCTION(resethw),
228*4882a593Smuzhiyun FUNCTION(service),
229*4882a593Smuzhiyun FUNCTION(hiqclkena),
230*4882a593Smuzhiyun FUNCTION(pdm),
231*4882a593Smuzhiyun FUNCTION(uartdata),
232*4882a593Smuzhiyun FUNCTION(extvibra),
233*4882a593Smuzhiyun FUNCTION(extvibra),
234*4882a593Smuzhiyun FUNCTION(usbvdat),
235*4882a593Smuzhiyun };
236*4882a593Smuzhiyun
237*4882a593Smuzhiyun /*
238*4882a593Smuzhiyun * this table translates what's is in the AB8505 specification regarding the
239*4882a593Smuzhiyun * balls alternate functions (as for DB, default, ALT_A, ALT_B and ALT_C).
240*4882a593Smuzhiyun * ALTERNATE_FUNCTIONS(GPIO_NUMBER, GPIOSEL bit, ALTERNATFUNC bit1,
241*4882a593Smuzhiyun * ALTERNATEFUNC bit2, ALTA val, ALTB val, ALTC val),
242*4882a593Smuzhiyun *
243*4882a593Smuzhiyun * example :
244*4882a593Smuzhiyun *
245*4882a593Smuzhiyun * ALTERNATE_FUNCTIONS(13, 4, 3, 4, 1, 0, 2),
246*4882a593Smuzhiyun * means that pin AB8505_PIN_D18 (pin 13) supports 4 mux (default/ALT_A,
247*4882a593Smuzhiyun * ALT_B and ALT_C), so GPIOSEL and ALTERNATFUNC registers are used to
248*4882a593Smuzhiyun * select the mux. ALTA, ALTB and ALTC val indicates values to write in
249*4882a593Smuzhiyun * ALTERNATFUNC register. We need to specifies these values as SOC
250*4882a593Smuzhiyun * designers didn't apply the same logic on how to select mux in the
251*4882a593Smuzhiyun * ABx500 family.
252*4882a593Smuzhiyun *
253*4882a593Smuzhiyun * As this pins supports at least ALT_B mux, default mux is
254*4882a593Smuzhiyun * selected by writing 1 in GPIOSEL bit :
255*4882a593Smuzhiyun *
256*4882a593Smuzhiyun * | GPIOSEL bit=4 | alternatfunc bit2=4 | alternatfunc bit1=3
257*4882a593Smuzhiyun * default | 1 | 0 | 0
258*4882a593Smuzhiyun * alt_A | 0 | 0 | 1
259*4882a593Smuzhiyun * alt_B | 0 | 0 | 0
260*4882a593Smuzhiyun * alt_C | 0 | 1 | 0
261*4882a593Smuzhiyun *
262*4882a593Smuzhiyun * ALTERNATE_FUNCTIONS(1, 0, UNUSED, UNUSED),
263*4882a593Smuzhiyun * means that pin AB9540_PIN_R4 (pin 1) supports 2 mux, so only GPIOSEL
264*4882a593Smuzhiyun * register is used to select the mux. As this pins doesn't support at
265*4882a593Smuzhiyun * least ALT_B mux, default mux is by writing 0 in GPIOSEL bit :
266*4882a593Smuzhiyun *
267*4882a593Smuzhiyun * | GPIOSEL bit=0 | alternatfunc bit2= | alternatfunc bit1=
268*4882a593Smuzhiyun * default | 0 | 0 | 0
269*4882a593Smuzhiyun * alt_A | 1 | 0 | 0
270*4882a593Smuzhiyun */
271*4882a593Smuzhiyun
272*4882a593Smuzhiyun static struct
273*4882a593Smuzhiyun alternate_functions ab8505_alternate_functions[AB8505_GPIO_MAX_NUMBER + 1] = {
274*4882a593Smuzhiyun ALTERNATE_FUNCTIONS(0, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO0 */
275*4882a593Smuzhiyun ALTERNATE_FUNCTIONS(1, 0, UNUSED, UNUSED, 0, 0, 0), /* GPIO1, altA controlled by bit 0 */
276*4882a593Smuzhiyun ALTERNATE_FUNCTIONS(2, 1, UNUSED, UNUSED, 0, 0, 0), /* GPIO2, altA controlled by bit 1 */
277*4882a593Smuzhiyun ALTERNATE_FUNCTIONS(3, 2, UNUSED, UNUSED, 0, 0, 0), /* GPIO3, altA controlled by bit 2*/
278*4882a593Smuzhiyun ALTERNATE_FUNCTIONS(4, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO4, bit 3 reserved */
279*4882a593Smuzhiyun ALTERNATE_FUNCTIONS(5, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO5, bit 4 reserved */
280*4882a593Smuzhiyun ALTERNATE_FUNCTIONS(6, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO6, bit 5 reserved */
281*4882a593Smuzhiyun ALTERNATE_FUNCTIONS(7, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO7, bit 6 reserved */
282*4882a593Smuzhiyun ALTERNATE_FUNCTIONS(8, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO8, bit 7 reserved */
283*4882a593Smuzhiyun
284*4882a593Smuzhiyun ALTERNATE_FUNCTIONS(9, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO9, bit 0 reserved */
285*4882a593Smuzhiyun ALTERNATE_FUNCTIONS(10, 1, 0, UNUSED, 1, 0, 0), /* GPIO10, altA and altB controlled by bit 0 */
286*4882a593Smuzhiyun ALTERNATE_FUNCTIONS(11, 2, 1, UNUSED, 0, 0, 0), /* GPIO11, altA controlled by bit 2 */
287*4882a593Smuzhiyun ALTERNATE_FUNCTIONS(12, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO12, bit3 reserved */
288*4882a593Smuzhiyun ALTERNATE_FUNCTIONS(13, 4, 3, 4, 1, 0, 2), /* GPIO13, altA altB and altC controlled by bit 3 and 4 */
289*4882a593Smuzhiyun ALTERNATE_FUNCTIONS(14, 5, UNUSED, UNUSED, 0, 0, 0), /* GPIO14, altA controlled by bit 5 */
290*4882a593Smuzhiyun ALTERNATE_FUNCTIONS(15, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO15, bit 6 reserved */
291*4882a593Smuzhiyun ALTERNATE_FUNCTIONS(16, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO15, bit 7 reserved */
292*4882a593Smuzhiyun /*
293*4882a593Smuzhiyun * pins 17 to 20 are special case, only bit 0 is used to select
294*4882a593Smuzhiyun * alternate function for these 4 pins.
295*4882a593Smuzhiyun * bits 1 to 3 are reserved
296*4882a593Smuzhiyun */
297*4882a593Smuzhiyun ALTERNATE_FUNCTIONS(17, 0, UNUSED, UNUSED, 0, 0, 0), /* GPIO17, altA controlled by bit 0 */
298*4882a593Smuzhiyun ALTERNATE_FUNCTIONS(18, 0, UNUSED, UNUSED, 0, 0, 0), /* GPIO18, altA controlled by bit 0 */
299*4882a593Smuzhiyun ALTERNATE_FUNCTIONS(19, 0, UNUSED, UNUSED, 0, 0, 0), /* GPIO19, altA controlled by bit 0 */
300*4882a593Smuzhiyun ALTERNATE_FUNCTIONS(20, 0, UNUSED, UNUSED, 0, 0, 0), /* GPIO20, altA controlled by bit 0 */
301*4882a593Smuzhiyun ALTERNATE_FUNCTIONS(21, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO21, bit 4 reserved */
302*4882a593Smuzhiyun ALTERNATE_FUNCTIONS(22, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO22, bit 5 reserved */
303*4882a593Smuzhiyun ALTERNATE_FUNCTIONS(23, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO23, bit 6 reserved */
304*4882a593Smuzhiyun ALTERNATE_FUNCTIONS(24, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO24, bit 7 reserved */
305*4882a593Smuzhiyun
306*4882a593Smuzhiyun ALTERNATE_FUNCTIONS(25, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO25, bit 0 reserved */
307*4882a593Smuzhiyun ALTERNATE_FUNCTIONS(26, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO26, bit 1 reserved */
308*4882a593Smuzhiyun ALTERNATE_FUNCTIONS(27, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO27, bit 2 reserved */
309*4882a593Smuzhiyun ALTERNATE_FUNCTIONS(28, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO28, bit 3 reserved */
310*4882a593Smuzhiyun ALTERNATE_FUNCTIONS(29, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO29, bit 4 reserved */
311*4882a593Smuzhiyun ALTERNATE_FUNCTIONS(30, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO30, bit 5 reserved */
312*4882a593Smuzhiyun ALTERNATE_FUNCTIONS(31, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO31, bit 6 reserved */
313*4882a593Smuzhiyun ALTERNATE_FUNCTIONS(32, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO32, bit 7 reserved */
314*4882a593Smuzhiyun
315*4882a593Smuzhiyun ALTERNATE_FUNCTIONS(33, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO33, bit 0 reserved */
316*4882a593Smuzhiyun ALTERNATE_FUNCTIONS(34, 1, UNUSED, UNUSED, 0, 0, 0), /* GPIO34, altA controlled by bit 1 */
317*4882a593Smuzhiyun ALTERNATE_FUNCTIONS(35, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO35, bit 2 reserved */
318*4882a593Smuzhiyun ALTERNATE_FUNCTIONS(36, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO36, bit 2 reserved */
319*4882a593Smuzhiyun ALTERNATE_FUNCTIONS(37, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO37, bit 2 reserved */
320*4882a593Smuzhiyun ALTERNATE_FUNCTIONS(38, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO38, bit 2 reserved */
321*4882a593Smuzhiyun ALTERNATE_FUNCTIONS(39, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO39, bit 2 reserved */
322*4882a593Smuzhiyun ALTERNATE_FUNCTIONS(40, 7, UNUSED, UNUSED, 0, 0, 0), /* GPIO40, altA controlled by bit 7*/
323*4882a593Smuzhiyun
324*4882a593Smuzhiyun ALTERNATE_FUNCTIONS(41, 0, UNUSED, UNUSED, 0, 0, 0), /* GPIO41, altA controlled by bit 0 */
325*4882a593Smuzhiyun ALTERNATE_FUNCTIONS(42, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO42, bit 1 reserved */
326*4882a593Smuzhiyun ALTERNATE_FUNCTIONS(43, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO43, bit 2 reserved */
327*4882a593Smuzhiyun ALTERNATE_FUNCTIONS(44, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO44, bit 3 reserved */
328*4882a593Smuzhiyun ALTERNATE_FUNCTIONS(45, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO45, bit 4 reserved */
329*4882a593Smuzhiyun ALTERNATE_FUNCTIONS(46, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO46, bit 5 reserved */
330*4882a593Smuzhiyun ALTERNATE_FUNCTIONS(47, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO47, bit 6 reserved */
331*4882a593Smuzhiyun ALTERNATE_FUNCTIONS(48, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO48, bit 7 reserved */
332*4882a593Smuzhiyun
333*4882a593Smuzhiyun ALTERNATE_FUNCTIONS(49, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO49, bit 0 reserved */
334*4882a593Smuzhiyun ALTERNATE_FUNCTIONS(50, 1, 2, UNUSED, 1, 0, 0), /* GPIO50, altA controlled by bit 1 */
335*4882a593Smuzhiyun ALTERNATE_FUNCTIONS(51, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO49, bit 0 reserved */
336*4882a593Smuzhiyun ALTERNATE_FUNCTIONS(52, 3, UNUSED, UNUSED, 0, 0, 0), /* GPIO52, altA controlled by bit 3 */
337*4882a593Smuzhiyun ALTERNATE_FUNCTIONS(53, 4, UNUSED, UNUSED, 0, 0, 0), /* GPIO53, altA controlled by bit 4 */
338*4882a593Smuzhiyun };
339*4882a593Smuzhiyun
340*4882a593Smuzhiyun /*
341*4882a593Smuzhiyun * For AB8505 Only some GPIOs are interrupt capable, and they are
342*4882a593Smuzhiyun * organized in discontiguous clusters:
343*4882a593Smuzhiyun *
344*4882a593Smuzhiyun * GPIO10 to GPIO11
345*4882a593Smuzhiyun * GPIO13
346*4882a593Smuzhiyun * GPIO40 and GPIO41
347*4882a593Smuzhiyun * GPIO50
348*4882a593Smuzhiyun * GPIO52 to GPIO53
349*4882a593Smuzhiyun */
350*4882a593Smuzhiyun static struct abx500_gpio_irq_cluster ab8505_gpio_irq_cluster[] = {
351*4882a593Smuzhiyun GPIO_IRQ_CLUSTER(10, 11, AB8500_INT_GPIO10R),
352*4882a593Smuzhiyun GPIO_IRQ_CLUSTER(13, 13, AB8500_INT_GPIO13R),
353*4882a593Smuzhiyun GPIO_IRQ_CLUSTER(40, 41, AB8500_INT_GPIO40R),
354*4882a593Smuzhiyun GPIO_IRQ_CLUSTER(50, 50, AB9540_INT_GPIO50R),
355*4882a593Smuzhiyun GPIO_IRQ_CLUSTER(52, 53, AB9540_INT_GPIO52R),
356*4882a593Smuzhiyun };
357*4882a593Smuzhiyun
358*4882a593Smuzhiyun static struct abx500_pinctrl_soc_data ab8505_soc = {
359*4882a593Smuzhiyun .gpio_ranges = ab8505_pinranges,
360*4882a593Smuzhiyun .gpio_num_ranges = ARRAY_SIZE(ab8505_pinranges),
361*4882a593Smuzhiyun .pins = ab8505_pins,
362*4882a593Smuzhiyun .npins = ARRAY_SIZE(ab8505_pins),
363*4882a593Smuzhiyun .functions = ab8505_functions,
364*4882a593Smuzhiyun .nfunctions = ARRAY_SIZE(ab8505_functions),
365*4882a593Smuzhiyun .groups = ab8505_groups,
366*4882a593Smuzhiyun .ngroups = ARRAY_SIZE(ab8505_groups),
367*4882a593Smuzhiyun .alternate_functions = ab8505_alternate_functions,
368*4882a593Smuzhiyun .gpio_irq_cluster = ab8505_gpio_irq_cluster,
369*4882a593Smuzhiyun .ngpio_irq_cluster = ARRAY_SIZE(ab8505_gpio_irq_cluster),
370*4882a593Smuzhiyun .irq_gpio_rising_offset = AB8500_INT_GPIO6R,
371*4882a593Smuzhiyun .irq_gpio_falling_offset = AB8500_INT_GPIO6F,
372*4882a593Smuzhiyun .irq_gpio_factor = 1,
373*4882a593Smuzhiyun };
374*4882a593Smuzhiyun
375*4882a593Smuzhiyun void
abx500_pinctrl_ab8505_init(struct abx500_pinctrl_soc_data ** soc)376*4882a593Smuzhiyun abx500_pinctrl_ab8505_init(struct abx500_pinctrl_soc_data **soc)
377*4882a593Smuzhiyun {
378*4882a593Smuzhiyun *soc = &ab8505_soc;
379*4882a593Smuzhiyun }
380