Commit 12966fdf authored by Andre Przywara's avatar Andre Przywara Committed by Linus Walleij
Browse files

pinctrl: sunxi: refactor pinctrl variants into flags



For some Allwinner SoCs we have one pinctrl driver caring for multiple
very similar chips, and are tagging certain pins with a variant bitmask.
The Allwinner D1 introduced a slightly extended register layout, and we
were abusing this variant mask to convey this bit of information into
the common code part.
Now there will be more pinctrl device properties to consider (has PortF
voltage switch, for instance), so shoehorning this into the variant
bitmask will not fly anymore.

Refactor the "variant" field into a more generic "flags" field. It turns
out that we don't need the variant bits to be unique across all SoCs,
but only among those SoCs that share one driver (table), of which there
are at most three variants at the moment. So the actual variant field can
be limited to say 8 bits, and the other bits in the flag register can be
re-purposed to hold other information, like this extended register
layout.
As a side effect we can move the variant definition into the per-SoC
pinctrl driver file, which makes it more obvious that this is just a
private definition, only relevant for this particular table.
This also changes the artificial sun20i-d1 "variant" into the actual
flag bit that we are after.

Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
Reviewed-by: default avatarJernej Skrabec <jernej.skrabec@gmail.com>
Link: https://lore.kernel.org/20250306235827.4895-2-andre.przywara@arm.com


Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent bc9527fb
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -820,15 +820,13 @@ static const struct sunxi_pinctrl_desc d1_pinctrl_data = {

static int d1_pinctrl_probe(struct platform_device *pdev)
{
	unsigned long variant = (unsigned long)of_device_get_match_data(&pdev->dev);

	return sunxi_pinctrl_init_with_variant(pdev, &d1_pinctrl_data, variant);
	return sunxi_pinctrl_init_with_flags(pdev, &d1_pinctrl_data,
					     SUNXI_PINCTRL_NEW_REG_LAYOUT);
}

static const struct of_device_id d1_pinctrl_match[] = {
	{
		.compatible = "allwinner,sun20i-d1-pinctrl",
		.data = (void *)PINCTRL_SUN20I_D1
	},
	{}
};
+6 −2
Original line number Diff line number Diff line
@@ -17,6 +17,10 @@

#include "pinctrl-sunxi.h"

#define PINCTRL_SUN4I_A10	BIT(0)
#define PINCTRL_SUN7I_A20	BIT(1)
#define PINCTRL_SUN8I_R40	BIT(2)

static const struct sunxi_desc_pin sun4i_a10_pins[] = {
	SUNXI_PIN(SUNXI_PINCTRL_PIN(A, 0),
		  SUNXI_FUNCTION(0x0, "gpio_in"),
@@ -1295,7 +1299,7 @@ static int sun4i_a10_pinctrl_probe(struct platform_device *pdev)
{
	unsigned long variant = (unsigned long)of_device_get_match_data(&pdev->dev);

	return sunxi_pinctrl_init_with_variant(pdev, &sun4i_a10_pinctrl_data,
	return sunxi_pinctrl_init_with_flags(pdev, &sun4i_a10_pinctrl_data,
					     variant);
}

+6 −2
Original line number Diff line number Diff line
@@ -16,6 +16,10 @@

#include "pinctrl-sunxi.h"

#define PINCTRL_SUN5I_A10S	BIT(0)
#define PINCTRL_SUN5I_A13	BIT(1)
#define PINCTRL_SUN5I_GR8	BIT(2)

static const struct sunxi_desc_pin sun5i_pins[] = {
	SUNXI_PIN_VARIANT(SUNXI_PINCTRL_PIN(A, 0),
		  PINCTRL_SUN5I_A10S,
@@ -719,7 +723,7 @@ static int sun5i_pinctrl_probe(struct platform_device *pdev)
{
	unsigned long variant = (unsigned long)of_device_get_match_data(&pdev->dev);

	return sunxi_pinctrl_init_with_variant(pdev, &sun5i_pinctrl_data,
	return sunxi_pinctrl_init_with_flags(pdev, &sun5i_pinctrl_data,
					     variant);
}

+5 −3
Original line number Diff line number Diff line
@@ -17,6 +17,9 @@

#include "pinctrl-sunxi.h"

#define PINCTRL_SUN6I_A31	BIT(0)
#define PINCTRL_SUN6I_A31S	BIT(1)

static const struct sunxi_desc_pin sun6i_a31_pins[] = {
	SUNXI_PIN(SUNXI_PINCTRL_PIN(A, 0),
		  SUNXI_FUNCTION(0x0, "gpio_in"),
@@ -972,8 +975,7 @@ static int sun6i_a31_pinctrl_probe(struct platform_device *pdev)
	unsigned long variant =
		(unsigned long)of_device_get_match_data(&pdev->dev);

	return sunxi_pinctrl_init_with_variant(pdev,
					       &sun6i_a31_pinctrl_data,
	return sunxi_pinctrl_init_with_flags(pdev, &sun6i_a31_pinctrl_data,
					     variant);
}

+5 −2
Original line number Diff line number Diff line
@@ -22,6 +22,9 @@

#include "pinctrl-sunxi.h"

#define PINCTRL_SUN8I_V3	BIT(0)
#define PINCTRL_SUN8I_V3S	BIT(1)

static const struct sunxi_desc_pin sun8i_v3s_pins[] = {
	/* Hole */
	SUNXI_PIN(SUNXI_PINCTRL_PIN(B, 0),
@@ -552,7 +555,7 @@ static int sun8i_v3s_pinctrl_probe(struct platform_device *pdev)
{
	unsigned long variant = (unsigned long)of_device_get_match_data(&pdev->dev);

	return sunxi_pinctrl_init_with_variant(pdev, &sun8i_v3s_pinctrl_data,
	return sunxi_pinctrl_init_with_flags(pdev, &sun8i_v3s_pinctrl_data,
					     variant);
}

Loading