]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-client.git/commitdiff
pinctrl: sunxi: pass down flags to pinctrl routines
authorAndre Przywara <andre.przywara@arm.com>
Fri, 20 Mar 2026 17:52:30 +0000 (18:52 +0100)
committerLinus Walleij <linusw@kernel.org>
Mon, 23 Mar 2026 13:23:08 +0000 (14:23 +0100)
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 <wens@kernel.org>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Michal Piekos <michal.piekos@mmpsystems.pl>
Signed-off-by: Linus Walleij <linusw@kernel.org>
drivers/pinctrl/sunxi/pinctrl-sunxi.c
drivers/pinctrl/sunxi/pinctrl-sunxi.h

index c990b611817292d6ceb64a97fc4597a34f70d2b0..685b79fc0bf8b2bbdf7d478fbe921b442d27dffb 100644 (file)
@@ -157,6 +157,7 @@ sunxi_pinctrl_desc_find_function_by_name(struct sunxi_pinctrl *pctl,
                                         const char *pin_name,
                                         const char *func_name)
 {
+       unsigned long variant = pctl->flags & SUNXI_PINCTRL_VARIANT_MASK;
        int i;
 
        for (i = 0; i < pctl->desc->npins; i++) {
@@ -168,7 +169,7 @@ sunxi_pinctrl_desc_find_function_by_name(struct sunxi_pinctrl *pctl,
                        while (func->name) {
                                if (!strcmp(func->name, func_name) &&
                                        (!func->variant ||
-                                       func->variant & pctl->variant))
+                                       func->variant & variant))
                                        return func;
 
                                func++;
@@ -209,6 +210,8 @@ sunxi_pinctrl_desc_find_function_by_pin_and_mux(struct sunxi_pinctrl *pctl,
                                                const u16 pin_num,
                                                const u8 muxval)
 {
+       unsigned long variant = pctl->flags & SUNXI_PINCTRL_VARIANT_MASK;
+
        for (unsigned int i = 0; i < pctl->desc->npins; i++) {
                const struct sunxi_desc_pin *pin = pctl->desc->pins + i;
                struct sunxi_desc_function *func = pin->functions;
@@ -216,7 +219,7 @@ sunxi_pinctrl_desc_find_function_by_pin_and_mux(struct sunxi_pinctrl *pctl,
                if (pin->pin.number != pin_num)
                        continue;
 
-               if (pin->variant && !(pctl->variant & pin->variant))
+               if (pin->variant && !(variant & pin->variant))
                        continue;
 
                while (func->name) {
@@ -1338,6 +1341,7 @@ static int sunxi_pinctrl_add_function(struct sunxi_pinctrl *pctl,
 static int sunxi_pinctrl_build_state(struct platform_device *pdev)
 {
        struct sunxi_pinctrl *pctl = platform_get_drvdata(pdev);
+       unsigned long variant = pctl->flags & SUNXI_PINCTRL_VARIANT_MASK;
        void *ptr;
        int i;
 
@@ -1362,7 +1366,7 @@ static int sunxi_pinctrl_build_state(struct platform_device *pdev)
                const struct sunxi_desc_pin *pin = pctl->desc->pins + i;
                struct sunxi_pinctrl_group *group = pctl->groups + pctl->ngroups;
 
-               if (pin->variant && !(pctl->variant & pin->variant))
+               if (pin->variant && !(variant & pin->variant))
                        continue;
 
                group->name = pin->pin.name;
@@ -1387,11 +1391,11 @@ static int sunxi_pinctrl_build_state(struct platform_device *pdev)
                const struct sunxi_desc_pin *pin = pctl->desc->pins + i;
                struct sunxi_desc_function *func;
 
-               if (pin->variant && !(pctl->variant & pin->variant))
+               if (pin->variant && !(variant & pin->variant))
                        continue;
 
                for (func = pin->functions; func->name; func++) {
-                       if (func->variant && !(pctl->variant & func->variant))
+                       if (func->variant && !(variant & func->variant))
                                continue;
 
                        /* Create interrupt mapping while we're at it */
@@ -1419,14 +1423,14 @@ static int sunxi_pinctrl_build_state(struct platform_device *pdev)
                const struct sunxi_desc_pin *pin = pctl->desc->pins + i;
                struct sunxi_desc_function *func;
 
-               if (pin->variant && !(pctl->variant & pin->variant))
+               if (pin->variant && !(variant & pin->variant))
                        continue;
 
                for (func = pin->functions; func->name; func++) {
                        struct sunxi_pinctrl_function *func_item;
                        const char **func_grp;
 
-                       if (func->variant && !(pctl->variant & func->variant))
+                       if (func->variant && !(variant & func->variant))
                                continue;
 
                        func_item = sunxi_pinctrl_find_function_by_name(pctl,
@@ -1568,7 +1572,7 @@ int sunxi_pinctrl_init_with_flags(struct platform_device *pdev,
 
        pctl->dev = &pdev->dev;
        pctl->desc = desc;
-       pctl->variant = flags & SUNXI_PINCTRL_VARIANT_MASK;
+       pctl->flags = flags;
        if (flags & SUNXI_PINCTRL_NEW_REG_LAYOUT) {
                pctl->bank_mem_size = D1_BANK_MEM_SIZE;
                pctl->pull_regs_offset = D1_PULL_REGS_OFFSET;
@@ -1604,8 +1608,9 @@ int sunxi_pinctrl_init_with_flags(struct platform_device *pdev,
 
        for (i = 0, pin_idx = 0; i < pctl->desc->npins; i++) {
                const struct sunxi_desc_pin *pin = pctl->desc->pins + i;
+               unsigned long variant = pctl->flags & SUNXI_PINCTRL_VARIANT_MASK;
 
-               if (pin->variant && !(pctl->variant & pin->variant))
+               if (pin->variant && !(variant & pin->variant))
                        continue;
 
                pins[pin_idx++] = pin->pin;
index ad26e4de16a85e344034f4c4e1d6d7ca5fb8a5c5..22bffac1c3f001b4040d967ebc37bd36042788c6 100644 (file)
@@ -174,7 +174,7 @@ struct sunxi_pinctrl {
        unsigned                        *irq_array;
        raw_spinlock_t                  lock;
        struct pinctrl_dev              *pctl_dev;
-       unsigned long                   variant;
+       unsigned long                   flags;
        u32                             bank_mem_size;
        u32                             pull_regs_offset;
        u32                             dlevel_field_width;