Skip to content

Commit 42e0668

Browse files
Andre-ARMlinusw
authored andcommitted
pinctrl: sunxi: pass down flags to pinctrl routines
Recent changes in the Allwinner pinctrl/GPIO IP made us add some quirks, which the new SoCs (A523 family) need to use. We now have a comfortable "flags" field on the per-SoC setup side, to tag those quirks we need, but were translating those flag bits into specific fields for runtime use, in the init routine. Now the newest Allwinner GPIO IP adds even more quirks and exceptions, some of a boolean nature. To avoid inventing various new boolean flags for the runtime struct sunxi_pinctrl, let's just directly pass on the flags variable used by the setup code, so runtime can check for those various quirk bits directly. Rename the "variant" member to "flags", and directly copy the value from the setup code into there. Move the variant masking from the init routine to the functions which actually use the "variant" value. This mostly paves the way for the new A733 IP generation, which needs more quirks to be checked at runtime. Reviewed-by: Chen-Yu Tsai <[email protected]> Signed-off-by: Andre Przywara <[email protected]> Signed-off-by: Michal Piekos <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
1 parent 8f9f64c commit 42e0668

2 files changed

Lines changed: 15 additions & 10 deletions

File tree

drivers/pinctrl/sunxi/pinctrl-sunxi.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ sunxi_pinctrl_desc_find_function_by_name(struct sunxi_pinctrl *pctl,
157157
const char *pin_name,
158158
const char *func_name)
159159
{
160+
unsigned long variant = pctl->flags & SUNXI_PINCTRL_VARIANT_MASK;
160161
int i;
161162

162163
for (i = 0; i < pctl->desc->npins; i++) {
@@ -168,7 +169,7 @@ sunxi_pinctrl_desc_find_function_by_name(struct sunxi_pinctrl *pctl,
168169
while (func->name) {
169170
if (!strcmp(func->name, func_name) &&
170171
(!func->variant ||
171-
func->variant & pctl->variant))
172+
func->variant & variant))
172173
return func;
173174

174175
func++;
@@ -209,14 +210,16 @@ sunxi_pinctrl_desc_find_function_by_pin_and_mux(struct sunxi_pinctrl *pctl,
209210
const u16 pin_num,
210211
const u8 muxval)
211212
{
213+
unsigned long variant = pctl->flags & SUNXI_PINCTRL_VARIANT_MASK;
214+
212215
for (unsigned int i = 0; i < pctl->desc->npins; i++) {
213216
const struct sunxi_desc_pin *pin = pctl->desc->pins + i;
214217
struct sunxi_desc_function *func = pin->functions;
215218

216219
if (pin->pin.number != pin_num)
217220
continue;
218221

219-
if (pin->variant && !(pctl->variant & pin->variant))
222+
if (pin->variant && !(variant & pin->variant))
220223
continue;
221224

222225
while (func->name) {
@@ -1338,6 +1341,7 @@ static int sunxi_pinctrl_add_function(struct sunxi_pinctrl *pctl,
13381341
static int sunxi_pinctrl_build_state(struct platform_device *pdev)
13391342
{
13401343
struct sunxi_pinctrl *pctl = platform_get_drvdata(pdev);
1344+
unsigned long variant = pctl->flags & SUNXI_PINCTRL_VARIANT_MASK;
13411345
void *ptr;
13421346
int i;
13431347

@@ -1362,7 +1366,7 @@ static int sunxi_pinctrl_build_state(struct platform_device *pdev)
13621366
const struct sunxi_desc_pin *pin = pctl->desc->pins + i;
13631367
struct sunxi_pinctrl_group *group = pctl->groups + pctl->ngroups;
13641368

1365-
if (pin->variant && !(pctl->variant & pin->variant))
1369+
if (pin->variant && !(variant & pin->variant))
13661370
continue;
13671371

13681372
group->name = pin->pin.name;
@@ -1387,11 +1391,11 @@ static int sunxi_pinctrl_build_state(struct platform_device *pdev)
13871391
const struct sunxi_desc_pin *pin = pctl->desc->pins + i;
13881392
struct sunxi_desc_function *func;
13891393

1390-
if (pin->variant && !(pctl->variant & pin->variant))
1394+
if (pin->variant && !(variant & pin->variant))
13911395
continue;
13921396

13931397
for (func = pin->functions; func->name; func++) {
1394-
if (func->variant && !(pctl->variant & func->variant))
1398+
if (func->variant && !(variant & func->variant))
13951399
continue;
13961400

13971401
/* Create interrupt mapping while we're at it */
@@ -1419,14 +1423,14 @@ static int sunxi_pinctrl_build_state(struct platform_device *pdev)
14191423
const struct sunxi_desc_pin *pin = pctl->desc->pins + i;
14201424
struct sunxi_desc_function *func;
14211425

1422-
if (pin->variant && !(pctl->variant & pin->variant))
1426+
if (pin->variant && !(variant & pin->variant))
14231427
continue;
14241428

14251429
for (func = pin->functions; func->name; func++) {
14261430
struct sunxi_pinctrl_function *func_item;
14271431
const char **func_grp;
14281432

1429-
if (func->variant && !(pctl->variant & func->variant))
1433+
if (func->variant && !(variant & func->variant))
14301434
continue;
14311435

14321436
func_item = sunxi_pinctrl_find_function_by_name(pctl,
@@ -1568,7 +1572,7 @@ int sunxi_pinctrl_init_with_flags(struct platform_device *pdev,
15681572

15691573
pctl->dev = &pdev->dev;
15701574
pctl->desc = desc;
1571-
pctl->variant = flags & SUNXI_PINCTRL_VARIANT_MASK;
1575+
pctl->flags = flags;
15721576
if (flags & SUNXI_PINCTRL_NEW_REG_LAYOUT) {
15731577
pctl->bank_mem_size = D1_BANK_MEM_SIZE;
15741578
pctl->pull_regs_offset = D1_PULL_REGS_OFFSET;
@@ -1604,8 +1608,9 @@ int sunxi_pinctrl_init_with_flags(struct platform_device *pdev,
16041608

16051609
for (i = 0, pin_idx = 0; i < pctl->desc->npins; i++) {
16061610
const struct sunxi_desc_pin *pin = pctl->desc->pins + i;
1611+
unsigned long variant = pctl->flags & SUNXI_PINCTRL_VARIANT_MASK;
16071612

1608-
if (pin->variant && !(pctl->variant & pin->variant))
1613+
if (pin->variant && !(variant & pin->variant))
16091614
continue;
16101615

16111616
pins[pin_idx++] = pin->pin;

drivers/pinctrl/sunxi/pinctrl-sunxi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ struct sunxi_pinctrl {
174174
unsigned *irq_array;
175175
raw_spinlock_t lock;
176176
struct pinctrl_dev *pctl_dev;
177-
unsigned long variant;
177+
unsigned long flags;
178178
u32 bank_mem_size;
179179
u32 pull_regs_offset;
180180
u32 dlevel_field_width;

0 commit comments

Comments
 (0)