pinctrl-bcm6318.c (762f99f4f3cb41a775b5157dd761217beba65873) pinctrl-bcm6318.c (0e3db16300fbae5e47ce6c298bf63a7862e5d576)
1// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Driver for BCM6318 GPIO unit (pinctrl + GPIO)
4 *
5 * Copyright (C) 2021 Álvaro Fernández Rojas <noltari@gmail.com>
6 * Copyright (C) 2016 Jonas Gorski <jonas.gorski@gmail.com>
7 */
8

--- 13 unchanged lines hidden (view full) ---

22#define BCM6318_NUM_MUX 48
23
24#define BCM6318_MODE_REG 0x18
25#define BCM6318_MUX_REG 0x1c
26#define BCM6328_MUX_MASK GENMASK(1, 0)
27#define BCM6318_PAD_REG 0x54
28#define BCM6328_PAD_MASK GENMASK(3, 0)
29
1// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Driver for BCM6318 GPIO unit (pinctrl + GPIO)
4 *
5 * Copyright (C) 2021 Álvaro Fernández Rojas <noltari@gmail.com>
6 * Copyright (C) 2016 Jonas Gorski <jonas.gorski@gmail.com>
7 */
8

--- 13 unchanged lines hidden (view full) ---

22#define BCM6318_NUM_MUX 48
23
24#define BCM6318_MODE_REG 0x18
25#define BCM6318_MUX_REG 0x1c
26#define BCM6328_MUX_MASK GENMASK(1, 0)
27#define BCM6318_PAD_REG 0x54
28#define BCM6328_PAD_MASK GENMASK(3, 0)
29
30struct bcm6318_pingroup {
31 const char *name;
32 const unsigned * const pins;
33 const unsigned num_pins;
34};
35
36struct bcm6318_function {
37 const char *name;
38 const char * const *groups;
39 const unsigned num_groups;
40
41 unsigned mode_val:1;
42 unsigned mux_val:2;
43};

--- 97 unchanged lines hidden (view full) ---

141static unsigned gpio43_pins[] = { 43 };
142static unsigned gpio44_pins[] = { 44 };
143static unsigned gpio45_pins[] = { 45 };
144static unsigned gpio46_pins[] = { 46 };
145static unsigned gpio47_pins[] = { 47 };
146static unsigned gpio48_pins[] = { 48 };
147static unsigned gpio49_pins[] = { 49 };
148
30struct bcm6318_function {
31 const char *name;
32 const char * const *groups;
33 const unsigned num_groups;
34
35 unsigned mode_val:1;
36 unsigned mux_val:2;
37};

--- 97 unchanged lines hidden (view full) ---

135static unsigned gpio43_pins[] = { 43 };
136static unsigned gpio44_pins[] = { 44 };
137static unsigned gpio45_pins[] = { 45 };
138static unsigned gpio46_pins[] = { 46 };
139static unsigned gpio47_pins[] = { 47 };
140static unsigned gpio48_pins[] = { 48 };
141static unsigned gpio49_pins[] = { 49 };
142
149#define BCM6318_GROUP(n) \
150 { \
151 .name = #n, \
152 .pins = n##_pins, \
153 .num_pins = ARRAY_SIZE(n##_pins), \
154 }
155
156static struct bcm6318_pingroup bcm6318_groups[] = {
157 BCM6318_GROUP(gpio0),
158 BCM6318_GROUP(gpio1),
159 BCM6318_GROUP(gpio2),
160 BCM6318_GROUP(gpio3),
161 BCM6318_GROUP(gpio4),
162 BCM6318_GROUP(gpio5),
163 BCM6318_GROUP(gpio6),
164 BCM6318_GROUP(gpio7),
165 BCM6318_GROUP(gpio8),
166 BCM6318_GROUP(gpio9),
167 BCM6318_GROUP(gpio10),
168 BCM6318_GROUP(gpio11),
169 BCM6318_GROUP(gpio12),
170 BCM6318_GROUP(gpio13),
171 BCM6318_GROUP(gpio14),
172 BCM6318_GROUP(gpio15),
173 BCM6318_GROUP(gpio16),
174 BCM6318_GROUP(gpio17),
175 BCM6318_GROUP(gpio18),
176 BCM6318_GROUP(gpio19),
177 BCM6318_GROUP(gpio20),
178 BCM6318_GROUP(gpio21),
179 BCM6318_GROUP(gpio22),
180 BCM6318_GROUP(gpio23),
181 BCM6318_GROUP(gpio24),
182 BCM6318_GROUP(gpio25),
183 BCM6318_GROUP(gpio26),
184 BCM6318_GROUP(gpio27),
185 BCM6318_GROUP(gpio28),
186 BCM6318_GROUP(gpio29),
187 BCM6318_GROUP(gpio30),
188 BCM6318_GROUP(gpio31),
189 BCM6318_GROUP(gpio32),
190 BCM6318_GROUP(gpio33),
191 BCM6318_GROUP(gpio34),
192 BCM6318_GROUP(gpio35),
193 BCM6318_GROUP(gpio36),
194 BCM6318_GROUP(gpio37),
195 BCM6318_GROUP(gpio38),
196 BCM6318_GROUP(gpio39),
197 BCM6318_GROUP(gpio40),
198 BCM6318_GROUP(gpio41),
199 BCM6318_GROUP(gpio42),
200 BCM6318_GROUP(gpio43),
201 BCM6318_GROUP(gpio44),
202 BCM6318_GROUP(gpio45),
203 BCM6318_GROUP(gpio46),
204 BCM6318_GROUP(gpio47),
205 BCM6318_GROUP(gpio48),
206 BCM6318_GROUP(gpio49),
143static struct pingroup bcm6318_groups[] = {
144 BCM_PIN_GROUP(gpio0),
145 BCM_PIN_GROUP(gpio1),
146 BCM_PIN_GROUP(gpio2),
147 BCM_PIN_GROUP(gpio3),
148 BCM_PIN_GROUP(gpio4),
149 BCM_PIN_GROUP(gpio5),
150 BCM_PIN_GROUP(gpio6),
151 BCM_PIN_GROUP(gpio7),
152 BCM_PIN_GROUP(gpio8),
153 BCM_PIN_GROUP(gpio9),
154 BCM_PIN_GROUP(gpio10),
155 BCM_PIN_GROUP(gpio11),
156 BCM_PIN_GROUP(gpio12),
157 BCM_PIN_GROUP(gpio13),
158 BCM_PIN_GROUP(gpio14),
159 BCM_PIN_GROUP(gpio15),
160 BCM_PIN_GROUP(gpio16),
161 BCM_PIN_GROUP(gpio17),
162 BCM_PIN_GROUP(gpio18),
163 BCM_PIN_GROUP(gpio19),
164 BCM_PIN_GROUP(gpio20),
165 BCM_PIN_GROUP(gpio21),
166 BCM_PIN_GROUP(gpio22),
167 BCM_PIN_GROUP(gpio23),
168 BCM_PIN_GROUP(gpio24),
169 BCM_PIN_GROUP(gpio25),
170 BCM_PIN_GROUP(gpio26),
171 BCM_PIN_GROUP(gpio27),
172 BCM_PIN_GROUP(gpio28),
173 BCM_PIN_GROUP(gpio29),
174 BCM_PIN_GROUP(gpio30),
175 BCM_PIN_GROUP(gpio31),
176 BCM_PIN_GROUP(gpio32),
177 BCM_PIN_GROUP(gpio33),
178 BCM_PIN_GROUP(gpio34),
179 BCM_PIN_GROUP(gpio35),
180 BCM_PIN_GROUP(gpio36),
181 BCM_PIN_GROUP(gpio37),
182 BCM_PIN_GROUP(gpio38),
183 BCM_PIN_GROUP(gpio39),
184 BCM_PIN_GROUP(gpio40),
185 BCM_PIN_GROUP(gpio41),
186 BCM_PIN_GROUP(gpio42),
187 BCM_PIN_GROUP(gpio43),
188 BCM_PIN_GROUP(gpio44),
189 BCM_PIN_GROUP(gpio45),
190 BCM_PIN_GROUP(gpio46),
191 BCM_PIN_GROUP(gpio47),
192 BCM_PIN_GROUP(gpio48),
193 BCM_PIN_GROUP(gpio49),
207};
208
209/* GPIO_MODE */
210static const char * const led_groups[] = {
211 "gpio0",
212 "gpio1",
213 "gpio2",
214 "gpio3",

--- 148 unchanged lines hidden (view full) ---

363static const char *bcm6318_pinctrl_get_group_name(struct pinctrl_dev *pctldev,
364 unsigned group)
365{
366 return bcm6318_groups[group].name;
367}
368
369static int bcm6318_pinctrl_get_group_pins(struct pinctrl_dev *pctldev,
370 unsigned group, const unsigned **pins,
194};
195
196/* GPIO_MODE */
197static const char * const led_groups[] = {
198 "gpio0",
199 "gpio1",
200 "gpio2",
201 "gpio3",

--- 148 unchanged lines hidden (view full) ---

350static const char *bcm6318_pinctrl_get_group_name(struct pinctrl_dev *pctldev,
351 unsigned group)
352{
353 return bcm6318_groups[group].name;
354}
355
356static int bcm6318_pinctrl_get_group_pins(struct pinctrl_dev *pctldev,
357 unsigned group, const unsigned **pins,
371 unsigned *num_pins)
358 unsigned *npins)
372{
373 *pins = bcm6318_groups[group].pins;
359{
360 *pins = bcm6318_groups[group].pins;
374 *num_pins = bcm6318_groups[group].num_pins;
361 *npins = bcm6318_groups[group].npins;
375
376 return 0;
377}
378
379static int bcm6318_pinctrl_get_func_count(struct pinctrl_dev *pctldev)
380{
381 return ARRAY_SIZE(bcm6318_funcs);
382}

--- 36 unchanged lines hidden (view full) ---

419 BCM6328_PAD_MASK << ((pin % 8) * 4),
420 val << ((pin % 8) * 4));
421}
422
423static int bcm6318_pinctrl_set_mux(struct pinctrl_dev *pctldev,
424 unsigned selector, unsigned group)
425{
426 struct bcm63xx_pinctrl *pc = pinctrl_dev_get_drvdata(pctldev);
362
363 return 0;
364}
365
366static int bcm6318_pinctrl_get_func_count(struct pinctrl_dev *pctldev)
367{
368 return ARRAY_SIZE(bcm6318_funcs);
369}

--- 36 unchanged lines hidden (view full) ---

406 BCM6328_PAD_MASK << ((pin % 8) * 4),
407 val << ((pin % 8) * 4));
408}
409
410static int bcm6318_pinctrl_set_mux(struct pinctrl_dev *pctldev,
411 unsigned selector, unsigned group)
412{
413 struct bcm63xx_pinctrl *pc = pinctrl_dev_get_drvdata(pctldev);
427 const struct bcm6318_pingroup *pg = &bcm6318_groups[group];
414 const struct pingroup *pg = &bcm6318_groups[group];
428 const struct bcm6318_function *f = &bcm6318_funcs[selector];
429
430 bcm6318_rmw_mux(pc, pg->pins[0], f->mode_val, f->mux_val);
431
432 return 0;
433}
434
435static int bcm6318_gpio_request_enable(struct pinctrl_dev *pctldev,

--- 63 unchanged lines hidden ---
415 const struct bcm6318_function *f = &bcm6318_funcs[selector];
416
417 bcm6318_rmw_mux(pc, pg->pins[0], f->mode_val, f->mux_val);
418
419 return 0;
420}
421
422static int bcm6318_gpio_request_enable(struct pinctrl_dev *pctldev,

--- 63 unchanged lines hidden ---