1155cca1bSÁlvaro Fernández Rojas // SPDX-License-Identifier: GPL-2.0+
2155cca1bSÁlvaro Fernández Rojas /*
3155cca1bSÁlvaro Fernández Rojas * Driver for BCM63268 GPIO unit (pinctrl + GPIO)
4155cca1bSÁlvaro Fernández Rojas *
5155cca1bSÁlvaro Fernández Rojas * Copyright (C) 2021 Álvaro Fernández Rojas <noltari@gmail.com>
6155cca1bSÁlvaro Fernández Rojas * Copyright (C) 2016 Jonas Gorski <jonas.gorski@gmail.com>
7155cca1bSÁlvaro Fernández Rojas */
8155cca1bSÁlvaro Fernández Rojas
9155cca1bSÁlvaro Fernández Rojas #include <linux/bits.h>
10155cca1bSÁlvaro Fernández Rojas #include <linux/gpio/driver.h>
11155cca1bSÁlvaro Fernández Rojas #include <linux/kernel.h>
12155cca1bSÁlvaro Fernández Rojas #include <linux/of.h>
13155cca1bSÁlvaro Fernández Rojas #include <linux/pinctrl/pinmux.h>
14155cca1bSÁlvaro Fernández Rojas #include <linux/platform_device.h>
15155cca1bSÁlvaro Fernández Rojas #include <linux/regmap.h>
16155cca1bSÁlvaro Fernández Rojas
17155cca1bSÁlvaro Fernández Rojas #include "../pinctrl-utils.h"
18155cca1bSÁlvaro Fernández Rojas
19155cca1bSÁlvaro Fernández Rojas #include "pinctrl-bcm63xx.h"
20155cca1bSÁlvaro Fernández Rojas
21155cca1bSÁlvaro Fernández Rojas #define BCM63268_NUM_GPIOS 52
22155cca1bSÁlvaro Fernández Rojas #define BCM63268_NUM_LEDS 24
23155cca1bSÁlvaro Fernández Rojas
24155cca1bSÁlvaro Fernández Rojas #define BCM63268_LED_REG 0x10
25155cca1bSÁlvaro Fernández Rojas #define BCM63268_MODE_REG 0x18
26155cca1bSÁlvaro Fernández Rojas #define BCM63268_CTRL_REG 0x1c
27155cca1bSÁlvaro Fernández Rojas #define BCM63268_BASEMODE_REG 0x38
28155cca1bSÁlvaro Fernández Rojas #define BCM63268_BASEMODE_NAND BIT(2) /* GPIOs 2-7, 24-31 */
29155cca1bSÁlvaro Fernández Rojas #define BCM63268_BASEMODE_GPIO35 BIT(4) /* GPIO 35 */
30155cca1bSÁlvaro Fernández Rojas #define BCM63268_BASEMODE_DECTPD BIT(5) /* GPIOs 8/9 */
31155cca1bSÁlvaro Fernández Rojas #define BCM63268_BASEMODE_VDSL_PHY_0 BIT(6) /* GPIOs 10/11 */
32155cca1bSÁlvaro Fernández Rojas #define BCM63268_BASEMODE_VDSL_PHY_1 BIT(7) /* GPIOs 12/13 */
33155cca1bSÁlvaro Fernández Rojas #define BCM63268_BASEMODE_VDSL_PHY_2 BIT(8) /* GPIOs 24/25 */
34155cca1bSÁlvaro Fernández Rojas #define BCM63268_BASEMODE_VDSL_PHY_3 BIT(9) /* GPIOs 26/27 */
35155cca1bSÁlvaro Fernández Rojas
36155cca1bSÁlvaro Fernández Rojas enum bcm63268_pinctrl_reg {
37155cca1bSÁlvaro Fernández Rojas BCM63268_LEDCTRL,
38155cca1bSÁlvaro Fernández Rojas BCM63268_MODE,
39155cca1bSÁlvaro Fernández Rojas BCM63268_CTRL,
40155cca1bSÁlvaro Fernández Rojas BCM63268_BASEMODE,
41155cca1bSÁlvaro Fernández Rojas };
42155cca1bSÁlvaro Fernández Rojas
43155cca1bSÁlvaro Fernández Rojas struct bcm63268_function {
44155cca1bSÁlvaro Fernández Rojas const char *name;
45155cca1bSÁlvaro Fernández Rojas const char * const *groups;
46155cca1bSÁlvaro Fernández Rojas const unsigned num_groups;
47155cca1bSÁlvaro Fernández Rojas
48155cca1bSÁlvaro Fernández Rojas enum bcm63268_pinctrl_reg reg;
49155cca1bSÁlvaro Fernández Rojas uint32_t mask;
50155cca1bSÁlvaro Fernández Rojas };
51155cca1bSÁlvaro Fernández Rojas
52155cca1bSÁlvaro Fernández Rojas #define BCM63268_PIN(a, b, basemode) \
53155cca1bSÁlvaro Fernández Rojas { \
54155cca1bSÁlvaro Fernández Rojas .number = a, \
55155cca1bSÁlvaro Fernández Rojas .name = b, \
56155cca1bSÁlvaro Fernández Rojas .drv_data = (void *)(basemode) \
57155cca1bSÁlvaro Fernández Rojas }
58155cca1bSÁlvaro Fernández Rojas
59155cca1bSÁlvaro Fernández Rojas static const struct pinctrl_pin_desc bcm63268_pins[] = {
60155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(0, "gpio0"),
61155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(1, "gpio1"),
62155cca1bSÁlvaro Fernández Rojas BCM63268_PIN(2, "gpio2", BCM63268_BASEMODE_NAND),
63155cca1bSÁlvaro Fernández Rojas BCM63268_PIN(3, "gpio3", BCM63268_BASEMODE_NAND),
64155cca1bSÁlvaro Fernández Rojas BCM63268_PIN(4, "gpio4", BCM63268_BASEMODE_NAND),
65155cca1bSÁlvaro Fernández Rojas BCM63268_PIN(5, "gpio5", BCM63268_BASEMODE_NAND),
66155cca1bSÁlvaro Fernández Rojas BCM63268_PIN(6, "gpio6", BCM63268_BASEMODE_NAND),
67155cca1bSÁlvaro Fernández Rojas BCM63268_PIN(7, "gpio7", BCM63268_BASEMODE_NAND),
68155cca1bSÁlvaro Fernández Rojas BCM63268_PIN(8, "gpio8", BCM63268_BASEMODE_DECTPD),
69155cca1bSÁlvaro Fernández Rojas BCM63268_PIN(9, "gpio9", BCM63268_BASEMODE_DECTPD),
70155cca1bSÁlvaro Fernández Rojas BCM63268_PIN(10, "gpio10", BCM63268_BASEMODE_VDSL_PHY_0),
71155cca1bSÁlvaro Fernández Rojas BCM63268_PIN(11, "gpio11", BCM63268_BASEMODE_VDSL_PHY_0),
72155cca1bSÁlvaro Fernández Rojas BCM63268_PIN(12, "gpio12", BCM63268_BASEMODE_VDSL_PHY_1),
73155cca1bSÁlvaro Fernández Rojas BCM63268_PIN(13, "gpio13", BCM63268_BASEMODE_VDSL_PHY_1),
74155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(14, "gpio14"),
75155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(15, "gpio15"),
76155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(16, "gpio16"),
77155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(17, "gpio17"),
78155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(18, "gpio18"),
79155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(19, "gpio19"),
80155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(20, "gpio20"),
81155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(21, "gpio21"),
82155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(22, "gpio22"),
83155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(23, "gpio23"),
84155cca1bSÁlvaro Fernández Rojas BCM63268_PIN(24, "gpio24",
85155cca1bSÁlvaro Fernández Rojas BCM63268_BASEMODE_NAND | BCM63268_BASEMODE_VDSL_PHY_2),
86155cca1bSÁlvaro Fernández Rojas BCM63268_PIN(25, "gpio25",
87155cca1bSÁlvaro Fernández Rojas BCM63268_BASEMODE_NAND | BCM63268_BASEMODE_VDSL_PHY_2),
88155cca1bSÁlvaro Fernández Rojas BCM63268_PIN(26, "gpio26",
89155cca1bSÁlvaro Fernández Rojas BCM63268_BASEMODE_NAND | BCM63268_BASEMODE_VDSL_PHY_3),
90155cca1bSÁlvaro Fernández Rojas BCM63268_PIN(27, "gpio27",
91155cca1bSÁlvaro Fernández Rojas BCM63268_BASEMODE_NAND | BCM63268_BASEMODE_VDSL_PHY_3),
92155cca1bSÁlvaro Fernández Rojas BCM63268_PIN(28, "gpio28", BCM63268_BASEMODE_NAND),
93155cca1bSÁlvaro Fernández Rojas BCM63268_PIN(29, "gpio29", BCM63268_BASEMODE_NAND),
94155cca1bSÁlvaro Fernández Rojas BCM63268_PIN(30, "gpio30", BCM63268_BASEMODE_NAND),
95155cca1bSÁlvaro Fernández Rojas BCM63268_PIN(31, "gpio31", BCM63268_BASEMODE_NAND),
96155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(32, "gpio32"),
97155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(33, "gpio33"),
98155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(34, "gpio34"),
99155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(35, "gpio35"),
100155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(36, "gpio36"),
101155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(37, "gpio37"),
102155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(38, "gpio38"),
103155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(39, "gpio39"),
104155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(40, "gpio40"),
105155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(41, "gpio41"),
106155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(42, "gpio42"),
107155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(43, "gpio43"),
108155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(44, "gpio44"),
109155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(45, "gpio45"),
110155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(46, "gpio46"),
111155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(47, "gpio47"),
112155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(48, "gpio48"),
113155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(49, "gpio49"),
114155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(50, "gpio50"),
115155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(51, "gpio51"),
116155cca1bSÁlvaro Fernández Rojas };
117155cca1bSÁlvaro Fernández Rojas
118155cca1bSÁlvaro Fernández Rojas static unsigned gpio0_pins[] = { 0 };
119155cca1bSÁlvaro Fernández Rojas static unsigned gpio1_pins[] = { 1 };
120155cca1bSÁlvaro Fernández Rojas static unsigned gpio2_pins[] = { 2 };
121155cca1bSÁlvaro Fernández Rojas static unsigned gpio3_pins[] = { 3 };
122155cca1bSÁlvaro Fernández Rojas static unsigned gpio4_pins[] = { 4 };
123155cca1bSÁlvaro Fernández Rojas static unsigned gpio5_pins[] = { 5 };
124155cca1bSÁlvaro Fernández Rojas static unsigned gpio6_pins[] = { 6 };
125155cca1bSÁlvaro Fernández Rojas static unsigned gpio7_pins[] = { 7 };
126155cca1bSÁlvaro Fernández Rojas static unsigned gpio8_pins[] = { 8 };
127155cca1bSÁlvaro Fernández Rojas static unsigned gpio9_pins[] = { 9 };
128155cca1bSÁlvaro Fernández Rojas static unsigned gpio10_pins[] = { 10 };
129155cca1bSÁlvaro Fernández Rojas static unsigned gpio11_pins[] = { 11 };
130155cca1bSÁlvaro Fernández Rojas static unsigned gpio12_pins[] = { 12 };
131155cca1bSÁlvaro Fernández Rojas static unsigned gpio13_pins[] = { 13 };
132155cca1bSÁlvaro Fernández Rojas static unsigned gpio14_pins[] = { 14 };
133155cca1bSÁlvaro Fernández Rojas static unsigned gpio15_pins[] = { 15 };
134155cca1bSÁlvaro Fernández Rojas static unsigned gpio16_pins[] = { 16 };
135155cca1bSÁlvaro Fernández Rojas static unsigned gpio17_pins[] = { 17 };
136155cca1bSÁlvaro Fernández Rojas static unsigned gpio18_pins[] = { 18 };
137155cca1bSÁlvaro Fernández Rojas static unsigned gpio19_pins[] = { 19 };
138155cca1bSÁlvaro Fernández Rojas static unsigned gpio20_pins[] = { 20 };
139155cca1bSÁlvaro Fernández Rojas static unsigned gpio21_pins[] = { 21 };
140155cca1bSÁlvaro Fernández Rojas static unsigned gpio22_pins[] = { 22 };
141155cca1bSÁlvaro Fernández Rojas static unsigned gpio23_pins[] = { 23 };
142155cca1bSÁlvaro Fernández Rojas static unsigned gpio24_pins[] = { 24 };
143155cca1bSÁlvaro Fernández Rojas static unsigned gpio25_pins[] = { 25 };
144155cca1bSÁlvaro Fernández Rojas static unsigned gpio26_pins[] = { 26 };
145155cca1bSÁlvaro Fernández Rojas static unsigned gpio27_pins[] = { 27 };
146155cca1bSÁlvaro Fernández Rojas static unsigned gpio28_pins[] = { 28 };
147155cca1bSÁlvaro Fernández Rojas static unsigned gpio29_pins[] = { 29 };
148155cca1bSÁlvaro Fernández Rojas static unsigned gpio30_pins[] = { 30 };
149155cca1bSÁlvaro Fernández Rojas static unsigned gpio31_pins[] = { 31 };
150155cca1bSÁlvaro Fernández Rojas static unsigned gpio32_pins[] = { 32 };
151155cca1bSÁlvaro Fernández Rojas static unsigned gpio33_pins[] = { 33 };
152155cca1bSÁlvaro Fernández Rojas static unsigned gpio34_pins[] = { 34 };
153155cca1bSÁlvaro Fernández Rojas static unsigned gpio35_pins[] = { 35 };
154155cca1bSÁlvaro Fernández Rojas static unsigned gpio36_pins[] = { 36 };
155155cca1bSÁlvaro Fernández Rojas static unsigned gpio37_pins[] = { 37 };
156155cca1bSÁlvaro Fernández Rojas static unsigned gpio38_pins[] = { 38 };
157155cca1bSÁlvaro Fernández Rojas static unsigned gpio39_pins[] = { 39 };
158155cca1bSÁlvaro Fernández Rojas static unsigned gpio40_pins[] = { 40 };
159155cca1bSÁlvaro Fernández Rojas static unsigned gpio41_pins[] = { 41 };
160155cca1bSÁlvaro Fernández Rojas static unsigned gpio42_pins[] = { 42 };
161155cca1bSÁlvaro Fernández Rojas static unsigned gpio43_pins[] = { 43 };
162155cca1bSÁlvaro Fernández Rojas static unsigned gpio44_pins[] = { 44 };
163155cca1bSÁlvaro Fernández Rojas static unsigned gpio45_pins[] = { 45 };
164155cca1bSÁlvaro Fernández Rojas static unsigned gpio46_pins[] = { 46 };
165155cca1bSÁlvaro Fernández Rojas static unsigned gpio47_pins[] = { 47 };
166155cca1bSÁlvaro Fernández Rojas static unsigned gpio48_pins[] = { 48 };
167155cca1bSÁlvaro Fernández Rojas static unsigned gpio49_pins[] = { 49 };
168155cca1bSÁlvaro Fernández Rojas static unsigned gpio50_pins[] = { 50 };
169155cca1bSÁlvaro Fernández Rojas static unsigned gpio51_pins[] = { 51 };
170155cca1bSÁlvaro Fernández Rojas
171155cca1bSÁlvaro Fernández Rojas static unsigned nand_grp_pins[] = {
172155cca1bSÁlvaro Fernández Rojas 2, 3, 4, 5, 6, 7, 24,
173155cca1bSÁlvaro Fernández Rojas 25, 26, 27, 28, 29, 30, 31,
174155cca1bSÁlvaro Fernández Rojas };
175155cca1bSÁlvaro Fernández Rojas
176155cca1bSÁlvaro Fernández Rojas static unsigned dectpd_grp_pins[] = { 8, 9 };
177155cca1bSÁlvaro Fernández Rojas static unsigned vdsl_phy0_grp_pins[] = { 10, 11 };
178155cca1bSÁlvaro Fernández Rojas static unsigned vdsl_phy1_grp_pins[] = { 12, 13 };
179155cca1bSÁlvaro Fernández Rojas static unsigned vdsl_phy2_grp_pins[] = { 24, 25 };
180155cca1bSÁlvaro Fernández Rojas static unsigned vdsl_phy3_grp_pins[] = { 26, 27 };
181155cca1bSÁlvaro Fernández Rojas
182*0e3db163SAndy Shevchenko static struct pingroup bcm63268_groups[] = {
183*0e3db163SAndy Shevchenko BCM_PIN_GROUP(gpio0),
184*0e3db163SAndy Shevchenko BCM_PIN_GROUP(gpio1),
185*0e3db163SAndy Shevchenko BCM_PIN_GROUP(gpio2),
186*0e3db163SAndy Shevchenko BCM_PIN_GROUP(gpio3),
187*0e3db163SAndy Shevchenko BCM_PIN_GROUP(gpio4),
188*0e3db163SAndy Shevchenko BCM_PIN_GROUP(gpio5),
189*0e3db163SAndy Shevchenko BCM_PIN_GROUP(gpio6),
190*0e3db163SAndy Shevchenko BCM_PIN_GROUP(gpio7),
191*0e3db163SAndy Shevchenko BCM_PIN_GROUP(gpio8),
192*0e3db163SAndy Shevchenko BCM_PIN_GROUP(gpio9),
193*0e3db163SAndy Shevchenko BCM_PIN_GROUP(gpio10),
194*0e3db163SAndy Shevchenko BCM_PIN_GROUP(gpio11),
195*0e3db163SAndy Shevchenko BCM_PIN_GROUP(gpio12),
196*0e3db163SAndy Shevchenko BCM_PIN_GROUP(gpio13),
197*0e3db163SAndy Shevchenko BCM_PIN_GROUP(gpio14),
198*0e3db163SAndy Shevchenko BCM_PIN_GROUP(gpio15),
199*0e3db163SAndy Shevchenko BCM_PIN_GROUP(gpio16),
200*0e3db163SAndy Shevchenko BCM_PIN_GROUP(gpio17),
201*0e3db163SAndy Shevchenko BCM_PIN_GROUP(gpio18),
202*0e3db163SAndy Shevchenko BCM_PIN_GROUP(gpio19),
203*0e3db163SAndy Shevchenko BCM_PIN_GROUP(gpio20),
204*0e3db163SAndy Shevchenko BCM_PIN_GROUP(gpio21),
205*0e3db163SAndy Shevchenko BCM_PIN_GROUP(gpio22),
206*0e3db163SAndy Shevchenko BCM_PIN_GROUP(gpio23),
207*0e3db163SAndy Shevchenko BCM_PIN_GROUP(gpio24),
208*0e3db163SAndy Shevchenko BCM_PIN_GROUP(gpio25),
209*0e3db163SAndy Shevchenko BCM_PIN_GROUP(gpio26),
210*0e3db163SAndy Shevchenko BCM_PIN_GROUP(gpio27),
211*0e3db163SAndy Shevchenko BCM_PIN_GROUP(gpio28),
212*0e3db163SAndy Shevchenko BCM_PIN_GROUP(gpio29),
213*0e3db163SAndy Shevchenko BCM_PIN_GROUP(gpio30),
214*0e3db163SAndy Shevchenko BCM_PIN_GROUP(gpio31),
215*0e3db163SAndy Shevchenko BCM_PIN_GROUP(gpio32),
216*0e3db163SAndy Shevchenko BCM_PIN_GROUP(gpio33),
217*0e3db163SAndy Shevchenko BCM_PIN_GROUP(gpio34),
218*0e3db163SAndy Shevchenko BCM_PIN_GROUP(gpio35),
219*0e3db163SAndy Shevchenko BCM_PIN_GROUP(gpio36),
220*0e3db163SAndy Shevchenko BCM_PIN_GROUP(gpio37),
221*0e3db163SAndy Shevchenko BCM_PIN_GROUP(gpio38),
222*0e3db163SAndy Shevchenko BCM_PIN_GROUP(gpio39),
223*0e3db163SAndy Shevchenko BCM_PIN_GROUP(gpio40),
224*0e3db163SAndy Shevchenko BCM_PIN_GROUP(gpio41),
225*0e3db163SAndy Shevchenko BCM_PIN_GROUP(gpio42),
226*0e3db163SAndy Shevchenko BCM_PIN_GROUP(gpio43),
227*0e3db163SAndy Shevchenko BCM_PIN_GROUP(gpio44),
228*0e3db163SAndy Shevchenko BCM_PIN_GROUP(gpio45),
229*0e3db163SAndy Shevchenko BCM_PIN_GROUP(gpio46),
230*0e3db163SAndy Shevchenko BCM_PIN_GROUP(gpio47),
231*0e3db163SAndy Shevchenko BCM_PIN_GROUP(gpio48),
232*0e3db163SAndy Shevchenko BCM_PIN_GROUP(gpio49),
233*0e3db163SAndy Shevchenko BCM_PIN_GROUP(gpio50),
234*0e3db163SAndy Shevchenko BCM_PIN_GROUP(gpio51),
235155cca1bSÁlvaro Fernández Rojas
236155cca1bSÁlvaro Fernández Rojas /* multi pin groups */
237*0e3db163SAndy Shevchenko BCM_PIN_GROUP(nand_grp),
238*0e3db163SAndy Shevchenko BCM_PIN_GROUP(dectpd_grp),
239*0e3db163SAndy Shevchenko BCM_PIN_GROUP(vdsl_phy0_grp),
240*0e3db163SAndy Shevchenko BCM_PIN_GROUP(vdsl_phy1_grp),
241*0e3db163SAndy Shevchenko BCM_PIN_GROUP(vdsl_phy2_grp),
242*0e3db163SAndy Shevchenko BCM_PIN_GROUP(vdsl_phy3_grp),
243155cca1bSÁlvaro Fernández Rojas };
244155cca1bSÁlvaro Fernández Rojas
245155cca1bSÁlvaro Fernández Rojas static const char * const led_groups[] = {
246155cca1bSÁlvaro Fernández Rojas "gpio0",
247155cca1bSÁlvaro Fernández Rojas "gpio1",
248155cca1bSÁlvaro Fernández Rojas "gpio2",
249155cca1bSÁlvaro Fernández Rojas "gpio3",
250155cca1bSÁlvaro Fernández Rojas "gpio4",
251155cca1bSÁlvaro Fernández Rojas "gpio5",
252155cca1bSÁlvaro Fernández Rojas "gpio6",
253155cca1bSÁlvaro Fernández Rojas "gpio7",
254155cca1bSÁlvaro Fernández Rojas "gpio8",
255155cca1bSÁlvaro Fernández Rojas "gpio9",
256155cca1bSÁlvaro Fernández Rojas "gpio10",
257155cca1bSÁlvaro Fernández Rojas "gpio11",
258155cca1bSÁlvaro Fernández Rojas "gpio12",
259155cca1bSÁlvaro Fernández Rojas "gpio13",
260155cca1bSÁlvaro Fernández Rojas "gpio14",
261155cca1bSÁlvaro Fernández Rojas "gpio15",
262155cca1bSÁlvaro Fernández Rojas "gpio16",
263155cca1bSÁlvaro Fernández Rojas "gpio17",
264155cca1bSÁlvaro Fernández Rojas "gpio18",
265155cca1bSÁlvaro Fernández Rojas "gpio19",
266155cca1bSÁlvaro Fernández Rojas "gpio20",
267155cca1bSÁlvaro Fernández Rojas "gpio21",
268155cca1bSÁlvaro Fernández Rojas "gpio22",
269155cca1bSÁlvaro Fernández Rojas "gpio23",
270155cca1bSÁlvaro Fernández Rojas };
271155cca1bSÁlvaro Fernández Rojas
272155cca1bSÁlvaro Fernández Rojas static const char * const serial_led_clk_groups[] = {
273155cca1bSÁlvaro Fernández Rojas "gpio0",
274155cca1bSÁlvaro Fernández Rojas };
275155cca1bSÁlvaro Fernández Rojas
276155cca1bSÁlvaro Fernández Rojas static const char * const serial_led_data_groups[] = {
277155cca1bSÁlvaro Fernández Rojas "gpio1",
278155cca1bSÁlvaro Fernández Rojas };
279155cca1bSÁlvaro Fernández Rojas
280155cca1bSÁlvaro Fernández Rojas static const char * const hsspi_cs4_groups[] = {
281155cca1bSÁlvaro Fernández Rojas "gpio16",
282155cca1bSÁlvaro Fernández Rojas };
283155cca1bSÁlvaro Fernández Rojas
284155cca1bSÁlvaro Fernández Rojas static const char * const hsspi_cs5_groups[] = {
285155cca1bSÁlvaro Fernández Rojas "gpio17",
286155cca1bSÁlvaro Fernández Rojas };
287155cca1bSÁlvaro Fernández Rojas
288155cca1bSÁlvaro Fernández Rojas static const char * const hsspi_cs6_groups[] = {
289155cca1bSÁlvaro Fernández Rojas "gpio8",
290155cca1bSÁlvaro Fernández Rojas };
291155cca1bSÁlvaro Fernández Rojas
292155cca1bSÁlvaro Fernández Rojas static const char * const hsspi_cs7_groups[] = {
293155cca1bSÁlvaro Fernández Rojas "gpio9",
294155cca1bSÁlvaro Fernández Rojas };
295155cca1bSÁlvaro Fernández Rojas
296155cca1bSÁlvaro Fernández Rojas static const char * const uart1_scts_groups[] = {
297155cca1bSÁlvaro Fernández Rojas "gpio10",
298155cca1bSÁlvaro Fernández Rojas "gpio24",
299155cca1bSÁlvaro Fernández Rojas };
300155cca1bSÁlvaro Fernández Rojas
301155cca1bSÁlvaro Fernández Rojas static const char * const uart1_srts_groups[] = {
302155cca1bSÁlvaro Fernández Rojas "gpio11",
303155cca1bSÁlvaro Fernández Rojas "gpio25",
304155cca1bSÁlvaro Fernández Rojas };
305155cca1bSÁlvaro Fernández Rojas
306155cca1bSÁlvaro Fernández Rojas static const char * const uart1_sdin_groups[] = {
307155cca1bSÁlvaro Fernández Rojas "gpio12",
308155cca1bSÁlvaro Fernández Rojas "gpio26",
309155cca1bSÁlvaro Fernández Rojas };
310155cca1bSÁlvaro Fernández Rojas
311155cca1bSÁlvaro Fernández Rojas static const char * const uart1_sdout_groups[] = {
312155cca1bSÁlvaro Fernández Rojas "gpio13",
313155cca1bSÁlvaro Fernández Rojas "gpio27",
314155cca1bSÁlvaro Fernández Rojas };
315155cca1bSÁlvaro Fernández Rojas
316155cca1bSÁlvaro Fernández Rojas static const char * const ntr_pulse_in_groups[] = {
317155cca1bSÁlvaro Fernández Rojas "gpio14",
318155cca1bSÁlvaro Fernández Rojas "gpio28",
319155cca1bSÁlvaro Fernández Rojas };
320155cca1bSÁlvaro Fernández Rojas
321155cca1bSÁlvaro Fernández Rojas static const char * const dsl_ntr_pulse_out_groups[] = {
322155cca1bSÁlvaro Fernández Rojas "gpio15",
323155cca1bSÁlvaro Fernández Rojas "gpio29",
324155cca1bSÁlvaro Fernández Rojas };
325155cca1bSÁlvaro Fernández Rojas
326155cca1bSÁlvaro Fernández Rojas static const char * const adsl_spi_miso_groups[] = {
327155cca1bSÁlvaro Fernández Rojas "gpio18",
328155cca1bSÁlvaro Fernández Rojas };
329155cca1bSÁlvaro Fernández Rojas
330155cca1bSÁlvaro Fernández Rojas static const char * const adsl_spi_mosi_groups[] = {
331155cca1bSÁlvaro Fernández Rojas "gpio19",
332155cca1bSÁlvaro Fernández Rojas };
333155cca1bSÁlvaro Fernández Rojas
334155cca1bSÁlvaro Fernández Rojas static const char * const vreg_clk_groups[] = {
335155cca1bSÁlvaro Fernández Rojas "gpio22",
336155cca1bSÁlvaro Fernández Rojas };
337155cca1bSÁlvaro Fernández Rojas
338155cca1bSÁlvaro Fernández Rojas static const char * const pcie_clkreq_b_groups[] = {
339155cca1bSÁlvaro Fernández Rojas "gpio23",
340155cca1bSÁlvaro Fernández Rojas };
341155cca1bSÁlvaro Fernández Rojas
342155cca1bSÁlvaro Fernández Rojas static const char * const switch_led_clk_groups[] = {
343155cca1bSÁlvaro Fernández Rojas "gpio30",
344155cca1bSÁlvaro Fernández Rojas };
345155cca1bSÁlvaro Fernández Rojas
346155cca1bSÁlvaro Fernández Rojas static const char * const switch_led_data_groups[] = {
347155cca1bSÁlvaro Fernández Rojas "gpio31",
348155cca1bSÁlvaro Fernández Rojas };
349155cca1bSÁlvaro Fernández Rojas
350155cca1bSÁlvaro Fernández Rojas static const char * const wifi_groups[] = {
351155cca1bSÁlvaro Fernández Rojas "gpio32",
352155cca1bSÁlvaro Fernández Rojas "gpio33",
353155cca1bSÁlvaro Fernández Rojas "gpio34",
354155cca1bSÁlvaro Fernández Rojas "gpio35",
355155cca1bSÁlvaro Fernández Rojas "gpio36",
356155cca1bSÁlvaro Fernández Rojas "gpio37",
357155cca1bSÁlvaro Fernández Rojas "gpio38",
358155cca1bSÁlvaro Fernández Rojas "gpio39",
359155cca1bSÁlvaro Fernández Rojas "gpio40",
360155cca1bSÁlvaro Fernández Rojas "gpio41",
361155cca1bSÁlvaro Fernández Rojas "gpio42",
362155cca1bSÁlvaro Fernández Rojas "gpio43",
363155cca1bSÁlvaro Fernández Rojas "gpio44",
364155cca1bSÁlvaro Fernández Rojas "gpio45",
365155cca1bSÁlvaro Fernández Rojas "gpio46",
366155cca1bSÁlvaro Fernández Rojas "gpio47",
367155cca1bSÁlvaro Fernández Rojas "gpio48",
368155cca1bSÁlvaro Fernández Rojas "gpio49",
369155cca1bSÁlvaro Fernández Rojas "gpio50",
370155cca1bSÁlvaro Fernández Rojas "gpio51",
371155cca1bSÁlvaro Fernández Rojas };
372155cca1bSÁlvaro Fernández Rojas
373155cca1bSÁlvaro Fernández Rojas static const char * const nand_groups[] = {
374155cca1bSÁlvaro Fernández Rojas "nand_grp",
375155cca1bSÁlvaro Fernández Rojas };
376155cca1bSÁlvaro Fernández Rojas
377155cca1bSÁlvaro Fernández Rojas static const char * const dectpd_groups[] = {
378155cca1bSÁlvaro Fernández Rojas "dectpd_grp",
379155cca1bSÁlvaro Fernández Rojas };
380155cca1bSÁlvaro Fernández Rojas
381155cca1bSÁlvaro Fernández Rojas static const char * const vdsl_phy_override_0_groups[] = {
382155cca1bSÁlvaro Fernández Rojas "vdsl_phy_override_0_grp",
383155cca1bSÁlvaro Fernández Rojas };
384155cca1bSÁlvaro Fernández Rojas
385155cca1bSÁlvaro Fernández Rojas static const char * const vdsl_phy_override_1_groups[] = {
386155cca1bSÁlvaro Fernández Rojas "vdsl_phy_override_1_grp",
387155cca1bSÁlvaro Fernández Rojas };
388155cca1bSÁlvaro Fernández Rojas
389155cca1bSÁlvaro Fernández Rojas static const char * const vdsl_phy_override_2_groups[] = {
390155cca1bSÁlvaro Fernández Rojas "vdsl_phy_override_2_grp",
391155cca1bSÁlvaro Fernández Rojas };
392155cca1bSÁlvaro Fernández Rojas
393155cca1bSÁlvaro Fernández Rojas static const char * const vdsl_phy_override_3_groups[] = {
394155cca1bSÁlvaro Fernández Rojas "vdsl_phy_override_3_grp",
395155cca1bSÁlvaro Fernández Rojas };
396155cca1bSÁlvaro Fernández Rojas
397155cca1bSÁlvaro Fernández Rojas #define BCM63268_LED_FUN(n) \
398155cca1bSÁlvaro Fernández Rojas { \
399155cca1bSÁlvaro Fernández Rojas .name = #n, \
400155cca1bSÁlvaro Fernández Rojas .groups = n##_groups, \
401155cca1bSÁlvaro Fernández Rojas .num_groups = ARRAY_SIZE(n##_groups), \
402155cca1bSÁlvaro Fernández Rojas .reg = BCM63268_LEDCTRL, \
403155cca1bSÁlvaro Fernández Rojas }
404155cca1bSÁlvaro Fernández Rojas
405155cca1bSÁlvaro Fernández Rojas #define BCM63268_MODE_FUN(n) \
406155cca1bSÁlvaro Fernández Rojas { \
407155cca1bSÁlvaro Fernández Rojas .name = #n, \
408155cca1bSÁlvaro Fernández Rojas .groups = n##_groups, \
409155cca1bSÁlvaro Fernández Rojas .num_groups = ARRAY_SIZE(n##_groups), \
410155cca1bSÁlvaro Fernández Rojas .reg = BCM63268_MODE, \
411155cca1bSÁlvaro Fernández Rojas }
412155cca1bSÁlvaro Fernández Rojas
413155cca1bSÁlvaro Fernández Rojas #define BCM63268_CTRL_FUN(n) \
414155cca1bSÁlvaro Fernández Rojas { \
415155cca1bSÁlvaro Fernández Rojas .name = #n, \
416155cca1bSÁlvaro Fernández Rojas .groups = n##_groups, \
417155cca1bSÁlvaro Fernández Rojas .num_groups = ARRAY_SIZE(n##_groups), \
418155cca1bSÁlvaro Fernández Rojas .reg = BCM63268_CTRL, \
419155cca1bSÁlvaro Fernández Rojas }
420155cca1bSÁlvaro Fernández Rojas
421155cca1bSÁlvaro Fernández Rojas #define BCM63268_BASEMODE_FUN(n, val) \
422155cca1bSÁlvaro Fernández Rojas { \
423155cca1bSÁlvaro Fernández Rojas .name = #n, \
424155cca1bSÁlvaro Fernández Rojas .groups = n##_groups, \
425155cca1bSÁlvaro Fernández Rojas .num_groups = ARRAY_SIZE(n##_groups), \
426155cca1bSÁlvaro Fernández Rojas .reg = BCM63268_BASEMODE, \
427155cca1bSÁlvaro Fernández Rojas .mask = val, \
428155cca1bSÁlvaro Fernández Rojas }
429155cca1bSÁlvaro Fernández Rojas
430155cca1bSÁlvaro Fernández Rojas static const struct bcm63268_function bcm63268_funcs[] = {
431155cca1bSÁlvaro Fernández Rojas BCM63268_LED_FUN(led),
432155cca1bSÁlvaro Fernández Rojas BCM63268_MODE_FUN(serial_led_clk),
433155cca1bSÁlvaro Fernández Rojas BCM63268_MODE_FUN(serial_led_data),
434155cca1bSÁlvaro Fernández Rojas BCM63268_MODE_FUN(hsspi_cs6),
435155cca1bSÁlvaro Fernández Rojas BCM63268_MODE_FUN(hsspi_cs7),
436155cca1bSÁlvaro Fernández Rojas BCM63268_MODE_FUN(uart1_scts),
437155cca1bSÁlvaro Fernández Rojas BCM63268_MODE_FUN(uart1_srts),
438155cca1bSÁlvaro Fernández Rojas BCM63268_MODE_FUN(uart1_sdin),
439155cca1bSÁlvaro Fernández Rojas BCM63268_MODE_FUN(uart1_sdout),
440155cca1bSÁlvaro Fernández Rojas BCM63268_MODE_FUN(ntr_pulse_in),
441155cca1bSÁlvaro Fernández Rojas BCM63268_MODE_FUN(dsl_ntr_pulse_out),
442155cca1bSÁlvaro Fernández Rojas BCM63268_MODE_FUN(hsspi_cs4),
443155cca1bSÁlvaro Fernández Rojas BCM63268_MODE_FUN(hsspi_cs5),
444155cca1bSÁlvaro Fernández Rojas BCM63268_MODE_FUN(adsl_spi_miso),
445155cca1bSÁlvaro Fernández Rojas BCM63268_MODE_FUN(adsl_spi_mosi),
446155cca1bSÁlvaro Fernández Rojas BCM63268_MODE_FUN(vreg_clk),
447155cca1bSÁlvaro Fernández Rojas BCM63268_MODE_FUN(pcie_clkreq_b),
448155cca1bSÁlvaro Fernández Rojas BCM63268_MODE_FUN(switch_led_clk),
449155cca1bSÁlvaro Fernández Rojas BCM63268_MODE_FUN(switch_led_data),
450155cca1bSÁlvaro Fernández Rojas BCM63268_CTRL_FUN(wifi),
451155cca1bSÁlvaro Fernández Rojas BCM63268_BASEMODE_FUN(nand, BCM63268_BASEMODE_NAND),
452155cca1bSÁlvaro Fernández Rojas BCM63268_BASEMODE_FUN(dectpd, BCM63268_BASEMODE_DECTPD),
453155cca1bSÁlvaro Fernández Rojas BCM63268_BASEMODE_FUN(vdsl_phy_override_0,
454155cca1bSÁlvaro Fernández Rojas BCM63268_BASEMODE_VDSL_PHY_0),
455155cca1bSÁlvaro Fernández Rojas BCM63268_BASEMODE_FUN(vdsl_phy_override_1,
456155cca1bSÁlvaro Fernández Rojas BCM63268_BASEMODE_VDSL_PHY_1),
457155cca1bSÁlvaro Fernández Rojas BCM63268_BASEMODE_FUN(vdsl_phy_override_2,
458155cca1bSÁlvaro Fernández Rojas BCM63268_BASEMODE_VDSL_PHY_2),
459155cca1bSÁlvaro Fernández Rojas BCM63268_BASEMODE_FUN(vdsl_phy_override_3,
460155cca1bSÁlvaro Fernández Rojas BCM63268_BASEMODE_VDSL_PHY_3),
461155cca1bSÁlvaro Fernández Rojas };
462155cca1bSÁlvaro Fernández Rojas
bcm63268_pinctrl_get_group_count(struct pinctrl_dev * pctldev)463155cca1bSÁlvaro Fernández Rojas static int bcm63268_pinctrl_get_group_count(struct pinctrl_dev *pctldev)
464155cca1bSÁlvaro Fernández Rojas {
465155cca1bSÁlvaro Fernández Rojas return ARRAY_SIZE(bcm63268_groups);
466155cca1bSÁlvaro Fernández Rojas }
467155cca1bSÁlvaro Fernández Rojas
bcm63268_pinctrl_get_group_name(struct pinctrl_dev * pctldev,unsigned group)468155cca1bSÁlvaro Fernández Rojas static const char *bcm63268_pinctrl_get_group_name(struct pinctrl_dev *pctldev,
469155cca1bSÁlvaro Fernández Rojas unsigned group)
470155cca1bSÁlvaro Fernández Rojas {
471155cca1bSÁlvaro Fernández Rojas return bcm63268_groups[group].name;
472155cca1bSÁlvaro Fernández Rojas }
473155cca1bSÁlvaro Fernández Rojas
bcm63268_pinctrl_get_group_pins(struct pinctrl_dev * pctldev,unsigned group,const unsigned ** pins,unsigned * npins)474155cca1bSÁlvaro Fernández Rojas static int bcm63268_pinctrl_get_group_pins(struct pinctrl_dev *pctldev,
475155cca1bSÁlvaro Fernández Rojas unsigned group,
476155cca1bSÁlvaro Fernández Rojas const unsigned **pins,
477*0e3db163SAndy Shevchenko unsigned *npins)
478155cca1bSÁlvaro Fernández Rojas {
479155cca1bSÁlvaro Fernández Rojas *pins = bcm63268_groups[group].pins;
480*0e3db163SAndy Shevchenko *npins = bcm63268_groups[group].npins;
481155cca1bSÁlvaro Fernández Rojas
482155cca1bSÁlvaro Fernández Rojas return 0;
483155cca1bSÁlvaro Fernández Rojas }
484155cca1bSÁlvaro Fernández Rojas
bcm63268_pinctrl_get_func_count(struct pinctrl_dev * pctldev)485155cca1bSÁlvaro Fernández Rojas static int bcm63268_pinctrl_get_func_count(struct pinctrl_dev *pctldev)
486155cca1bSÁlvaro Fernández Rojas {
487155cca1bSÁlvaro Fernández Rojas return ARRAY_SIZE(bcm63268_funcs);
488155cca1bSÁlvaro Fernández Rojas }
489155cca1bSÁlvaro Fernández Rojas
bcm63268_pinctrl_get_func_name(struct pinctrl_dev * pctldev,unsigned selector)490155cca1bSÁlvaro Fernández Rojas static const char *bcm63268_pinctrl_get_func_name(struct pinctrl_dev *pctldev,
491155cca1bSÁlvaro Fernández Rojas unsigned selector)
492155cca1bSÁlvaro Fernández Rojas {
493155cca1bSÁlvaro Fernández Rojas return bcm63268_funcs[selector].name;
494155cca1bSÁlvaro Fernández Rojas }
495155cca1bSÁlvaro Fernández Rojas
bcm63268_pinctrl_get_groups(struct pinctrl_dev * pctldev,unsigned selector,const char * const ** groups,unsigned * const num_groups)496155cca1bSÁlvaro Fernández Rojas static int bcm63268_pinctrl_get_groups(struct pinctrl_dev *pctldev,
497155cca1bSÁlvaro Fernández Rojas unsigned selector,
498155cca1bSÁlvaro Fernández Rojas const char * const **groups,
499155cca1bSÁlvaro Fernández Rojas unsigned * const num_groups)
500155cca1bSÁlvaro Fernández Rojas {
501155cca1bSÁlvaro Fernández Rojas *groups = bcm63268_funcs[selector].groups;
502155cca1bSÁlvaro Fernández Rojas *num_groups = bcm63268_funcs[selector].num_groups;
503155cca1bSÁlvaro Fernández Rojas
504155cca1bSÁlvaro Fernández Rojas return 0;
505155cca1bSÁlvaro Fernández Rojas }
506155cca1bSÁlvaro Fernández Rojas
bcm63268_set_gpio(struct bcm63xx_pinctrl * pc,unsigned pin)507155cca1bSÁlvaro Fernández Rojas static void bcm63268_set_gpio(struct bcm63xx_pinctrl *pc, unsigned pin)
508155cca1bSÁlvaro Fernández Rojas {
509155cca1bSÁlvaro Fernández Rojas const struct pinctrl_pin_desc *desc = &bcm63268_pins[pin];
510155cca1bSÁlvaro Fernández Rojas unsigned int basemode = (unsigned long) desc->drv_data;
511155cca1bSÁlvaro Fernández Rojas unsigned int mask = BIT(bcm63xx_bank_pin(pin));
512155cca1bSÁlvaro Fernández Rojas
513155cca1bSÁlvaro Fernández Rojas if (basemode)
514155cca1bSÁlvaro Fernández Rojas regmap_update_bits(pc->regs, BCM63268_BASEMODE_REG, basemode,
515155cca1bSÁlvaro Fernández Rojas 0);
516155cca1bSÁlvaro Fernández Rojas
517155cca1bSÁlvaro Fernández Rojas if (pin < BCM63XX_BANK_GPIOS) {
518155cca1bSÁlvaro Fernández Rojas /* base mode: 0 => gpio, 1 => mux function */
519155cca1bSÁlvaro Fernández Rojas regmap_update_bits(pc->regs, BCM63268_MODE_REG, mask, 0);
520155cca1bSÁlvaro Fernández Rojas
521155cca1bSÁlvaro Fernández Rojas /* pins 0-23 might be muxed to led */
522155cca1bSÁlvaro Fernández Rojas if (pin < BCM63268_NUM_LEDS)
523155cca1bSÁlvaro Fernández Rojas regmap_update_bits(pc->regs, BCM63268_LED_REG, mask,
524155cca1bSÁlvaro Fernández Rojas 0);
525155cca1bSÁlvaro Fernández Rojas } else if (pin < BCM63268_NUM_GPIOS) {
526155cca1bSÁlvaro Fernández Rojas /* ctrl reg: 0 => wifi function, 1 => gpio */
527155cca1bSÁlvaro Fernández Rojas regmap_update_bits(pc->regs, BCM63268_CTRL_REG, mask, mask);
528155cca1bSÁlvaro Fernández Rojas }
529155cca1bSÁlvaro Fernández Rojas }
530155cca1bSÁlvaro Fernández Rojas
bcm63268_pinctrl_set_mux(struct pinctrl_dev * pctldev,unsigned selector,unsigned group)531155cca1bSÁlvaro Fernández Rojas static int bcm63268_pinctrl_set_mux(struct pinctrl_dev *pctldev,
532155cca1bSÁlvaro Fernández Rojas unsigned selector, unsigned group)
533155cca1bSÁlvaro Fernández Rojas {
534155cca1bSÁlvaro Fernández Rojas struct bcm63xx_pinctrl *pc = pinctrl_dev_get_drvdata(pctldev);
535*0e3db163SAndy Shevchenko const struct pingroup *pg = &bcm63268_groups[group];
536155cca1bSÁlvaro Fernández Rojas const struct bcm63268_function *f = &bcm63268_funcs[selector];
537155cca1bSÁlvaro Fernández Rojas unsigned i;
538155cca1bSÁlvaro Fernández Rojas unsigned int reg;
539155cca1bSÁlvaro Fernández Rojas unsigned int val, mask;
540155cca1bSÁlvaro Fernández Rojas
541*0e3db163SAndy Shevchenko for (i = 0; i < pg->npins; i++)
542155cca1bSÁlvaro Fernández Rojas bcm63268_set_gpio(pc, pg->pins[i]);
543155cca1bSÁlvaro Fernández Rojas
544155cca1bSÁlvaro Fernández Rojas switch (f->reg) {
545155cca1bSÁlvaro Fernández Rojas case BCM63268_LEDCTRL:
546155cca1bSÁlvaro Fernández Rojas reg = BCM63268_LED_REG;
547155cca1bSÁlvaro Fernández Rojas mask = BIT(pg->pins[0]);
548155cca1bSÁlvaro Fernández Rojas val = BIT(pg->pins[0]);
549155cca1bSÁlvaro Fernández Rojas break;
550155cca1bSÁlvaro Fernández Rojas case BCM63268_MODE:
551155cca1bSÁlvaro Fernández Rojas reg = BCM63268_MODE_REG;
552155cca1bSÁlvaro Fernández Rojas mask = BIT(pg->pins[0]);
553155cca1bSÁlvaro Fernández Rojas val = BIT(pg->pins[0]);
554155cca1bSÁlvaro Fernández Rojas break;
555155cca1bSÁlvaro Fernández Rojas case BCM63268_CTRL:
556155cca1bSÁlvaro Fernández Rojas reg = BCM63268_CTRL_REG;
557155cca1bSÁlvaro Fernández Rojas mask = BIT(pg->pins[0]);
558155cca1bSÁlvaro Fernández Rojas val = 0;
559155cca1bSÁlvaro Fernández Rojas break;
560155cca1bSÁlvaro Fernández Rojas case BCM63268_BASEMODE:
561155cca1bSÁlvaro Fernández Rojas reg = BCM63268_BASEMODE_REG;
562155cca1bSÁlvaro Fernández Rojas mask = f->mask;
563155cca1bSÁlvaro Fernández Rojas val = f->mask;
564155cca1bSÁlvaro Fernández Rojas break;
565155cca1bSÁlvaro Fernández Rojas default:
566155cca1bSÁlvaro Fernández Rojas WARN_ON(1);
567155cca1bSÁlvaro Fernández Rojas return -EINVAL;
568155cca1bSÁlvaro Fernández Rojas }
569155cca1bSÁlvaro Fernández Rojas
570155cca1bSÁlvaro Fernández Rojas regmap_update_bits(pc->regs, reg, mask, val);
571155cca1bSÁlvaro Fernández Rojas
572155cca1bSÁlvaro Fernández Rojas return 0;
573155cca1bSÁlvaro Fernández Rojas }
574155cca1bSÁlvaro Fernández Rojas
bcm63268_gpio_request_enable(struct pinctrl_dev * pctldev,struct pinctrl_gpio_range * range,unsigned offset)575155cca1bSÁlvaro Fernández Rojas static int bcm63268_gpio_request_enable(struct pinctrl_dev *pctldev,
576155cca1bSÁlvaro Fernández Rojas struct pinctrl_gpio_range *range,
577155cca1bSÁlvaro Fernández Rojas unsigned offset)
578155cca1bSÁlvaro Fernández Rojas {
579155cca1bSÁlvaro Fernández Rojas struct bcm63xx_pinctrl *pc = pinctrl_dev_get_drvdata(pctldev);
580155cca1bSÁlvaro Fernández Rojas
581155cca1bSÁlvaro Fernández Rojas /* disable all functions using this pin */
582155cca1bSÁlvaro Fernández Rojas bcm63268_set_gpio(pc, offset);
583155cca1bSÁlvaro Fernández Rojas
584155cca1bSÁlvaro Fernández Rojas return 0;
585155cca1bSÁlvaro Fernández Rojas }
586155cca1bSÁlvaro Fernández Rojas
587d9779093SRikard Falkeborn static const struct pinctrl_ops bcm63268_pctl_ops = {
588155cca1bSÁlvaro Fernández Rojas .dt_free_map = pinctrl_utils_free_map,
589155cca1bSÁlvaro Fernández Rojas .dt_node_to_map = pinconf_generic_dt_node_to_map_pin,
590155cca1bSÁlvaro Fernández Rojas .get_group_name = bcm63268_pinctrl_get_group_name,
591155cca1bSÁlvaro Fernández Rojas .get_group_pins = bcm63268_pinctrl_get_group_pins,
592155cca1bSÁlvaro Fernández Rojas .get_groups_count = bcm63268_pinctrl_get_group_count,
593155cca1bSÁlvaro Fernández Rojas };
594155cca1bSÁlvaro Fernández Rojas
5950c683876SRikard Falkeborn static const struct pinmux_ops bcm63268_pmx_ops = {
596155cca1bSÁlvaro Fernández Rojas .get_function_groups = bcm63268_pinctrl_get_groups,
597155cca1bSÁlvaro Fernández Rojas .get_function_name = bcm63268_pinctrl_get_func_name,
598155cca1bSÁlvaro Fernández Rojas .get_functions_count = bcm63268_pinctrl_get_func_count,
599155cca1bSÁlvaro Fernández Rojas .gpio_request_enable = bcm63268_gpio_request_enable,
600155cca1bSÁlvaro Fernández Rojas .set_mux = bcm63268_pinctrl_set_mux,
601155cca1bSÁlvaro Fernández Rojas .strict = true,
602155cca1bSÁlvaro Fernández Rojas };
603155cca1bSÁlvaro Fernández Rojas
604155cca1bSÁlvaro Fernández Rojas static const struct bcm63xx_pinctrl_soc bcm63268_soc = {
605155cca1bSÁlvaro Fernández Rojas .ngpios = BCM63268_NUM_GPIOS,
606155cca1bSÁlvaro Fernández Rojas .npins = ARRAY_SIZE(bcm63268_pins),
607155cca1bSÁlvaro Fernández Rojas .pctl_ops = &bcm63268_pctl_ops,
608155cca1bSÁlvaro Fernández Rojas .pins = bcm63268_pins,
609155cca1bSÁlvaro Fernández Rojas .pmx_ops = &bcm63268_pmx_ops,
610155cca1bSÁlvaro Fernández Rojas };
611155cca1bSÁlvaro Fernández Rojas
bcm63268_pinctrl_probe(struct platform_device * pdev)612155cca1bSÁlvaro Fernández Rojas static int bcm63268_pinctrl_probe(struct platform_device *pdev)
613155cca1bSÁlvaro Fernández Rojas {
614155cca1bSÁlvaro Fernández Rojas return bcm63xx_pinctrl_probe(pdev, &bcm63268_soc, NULL);
615155cca1bSÁlvaro Fernández Rojas }
616155cca1bSÁlvaro Fernández Rojas
617155cca1bSÁlvaro Fernández Rojas static const struct of_device_id bcm63268_pinctrl_match[] = {
618155cca1bSÁlvaro Fernández Rojas { .compatible = "brcm,bcm63268-pinctrl", },
619155cca1bSÁlvaro Fernández Rojas { /* sentinel */ }
620155cca1bSÁlvaro Fernández Rojas };
621155cca1bSÁlvaro Fernández Rojas
622155cca1bSÁlvaro Fernández Rojas static struct platform_driver bcm63268_pinctrl_driver = {
623155cca1bSÁlvaro Fernández Rojas .probe = bcm63268_pinctrl_probe,
624155cca1bSÁlvaro Fernández Rojas .driver = {
625155cca1bSÁlvaro Fernández Rojas .name = "bcm63268-pinctrl",
626155cca1bSÁlvaro Fernández Rojas .of_match_table = bcm63268_pinctrl_match,
627155cca1bSÁlvaro Fernández Rojas },
628155cca1bSÁlvaro Fernández Rojas };
629155cca1bSÁlvaro Fernández Rojas
630155cca1bSÁlvaro Fernández Rojas builtin_platform_driver(bcm63268_pinctrl_driver);
631