Skip to contentSkip to conversation

pinctrl: airoha: add AN7589 support

PATCH In review John Crispin 3 participants 12 messages Nov 24 – Nov 25

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

v4 cover pinctrl: airoha: add AN7589 support

The Airoha AN7589 has a GPIO controller like the EN7581 one, with a third bank for 74 GPIOs in total. Its pin functions are selected
differently: a separate IOMUX block holds a 4 bit mode field per pin, eight pins per register, and mode 0 makes any pin a GPIO.

The first four patches prepare the shared driver and change nothing for the SoCs it serves today:

1. The GPIO register layout moves into the match data, so a SoC can describe more than 64 pins.
2. A function group can carry one IOMUX mode per pin. A SoC describes its IOMUX in the match data: the width of the mode field and, from patch 4, the mode that makes a pin a GPIO.
3. The chip SCU becomes optional, as the AN7589 needs none.
4. A pin requested by gpiolib is put into GPIO mode through the IOMUX, so no per pin gpio function is needed.

Patch 5 adds the IOMUX to the syscon compatibles. Patch 6 adds the binding for the pin controller. Patch 7 adds the binding for the GPIO system controller it sits under, which also holds the PWM controller. Patch 8 moves the GPIO register offsets to the common header, so the AN7589 data can describe its own register table, with no functional change. Patch 9 adds the AN7589 pin data.

The series applies to next-20261123 and has no dependencies.

Changes in v4:
- Patch 6: limit the pins of a conf node to 12, the size of the largest pin group (Conor).
- Patch 7: the commit message no longer names the PWM controller a second child, as it gets no child node (Conor).
- Add the Acked-by of Conor to patches 5 and 7.
- Link to v3: https://lore.kernel.org/r/[email protected]

Changes in v3:
- Split the bindings in three: the syscon compatible (patch 5), the pin controller (patch 6) and the GPIO system controller (patch 7) (Lee, Conor).
- Patch 6: allow one group per node, except for pcm_spi and pcie, whose groups carry different signals of one device. Fix the uart5 example (Conor).
- Patch 7: name the PWM controller in the commit message (Conor).
- Add the Reviewed-by of Lorenzo to patches 3 and 9.
- Link to v2: https://lore.kernel.org/r/[email protected]

Changes in v2:
- Patch 3: look up the airoha,chip-scu phandle before the check for a chip SCU compatible (Lorenzo).
- Patch 6: one function per block type (uart, i2c, spi, pcm, mdio, pcie, pon, sgpio, jtag), with the group selecting the instance, as in the other Airoha pin controller bindings. List the valid groups for the groups property (Conor).
- Patch 9: the function table follows the binding. Name the match data, the OF match table and the platform driver after the AN7589 (Lorenzo).
- Link to v1: https://lore.kernel.org/r/[email protected]

John Crispin (9):
pinctrl: airoha: make gpio register layout per SoC
pinctrl: airoha: add per pin mode field mux
pinctrl: airoha: make the chip SCU optional
pinctrl: airoha: mux a requested GPIO through the IOMUX
dt-bindings: mfd: syscon: add airoha,an7589-iomux
dt-bindings: pinctrl: airoha: add AN7589
dt-bindings: mfd: airoha: add AN7589 GPIO system controller
pinctrl: airoha: move the GPIO register offsets to the common header
pinctrl: airoha: add support of an7589 SoC

 .../mfd/airoha,an7589-gpio-sysctl.yaml        |  66 ++
 .../devicetree/bindings/mfd/syscon.yaml       |   1 +
 .../pinctrl/airoha,an7589-pinctrl.yaml        | 355 ++++++++++
 MAINTAINERS                                   |   3 +
 drivers/pinctrl/airoha/Kconfig                |  11 +
 drivers/pinctrl/airoha/Makefile               |   1 +
 drivers/pinctrl/airoha/airoha-common.h        |  41 +-
 drivers/pinctrl/airoha/pinctrl-airoha.c       | 119 +++-
 drivers/pinctrl/airoha/pinctrl-an7563.c       |   1 +
 drivers/pinctrl/airoha/pinctrl-an7581.c       |   1 +
 drivers/pinctrl/airoha/pinctrl-an7583.c       |   1 +
 drivers/pinctrl/airoha/pinctrl-an7589.c       | 623 ++++++++++++++++++
 drivers/pinctrl/airoha/pinctrl-en7523.c       |   1 +
 drivers/pinctrl/airoha/pinctrl-en7528.c       |   1 +
 14 files changed, 1193 insertions(+), 32 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mfd/airoha,an7589-gpio-sysctl.yaml
 create mode 100644 Documentation/devicetree/bindings/pinctrl/airoha,an7589-pinctrl.yaml
 create mode 100644 drivers/pinctrl/airoha/pinctrl-an7589.c

base-commit: 3191063649dbf7c0d0b768e1f3655e4c5fc6edb5

Signature · 1 line
2.34.1
#1 lore raw

PATCH v4 1/9 pinctrl: airoha: make gpio register layout per SoC

The GPIO register layout is fixed to 64 pins in two 32 pin banks and four 16 pin direction banks. Every SoC uses the single static airoha_gpiochip_regs and the compile time AIROHA_NUM_PINS.

Move the layout into the match data. The gpiochip register table carries its own pin count, and the five existing SoCs point at the shared 64 pin table.

No functional change for the existing SoCs.

---
Changes in v2:
- Add the Acked-by of Lorenzo.

 drivers/pinctrl/airoha/airoha-common.h  |  6 +++++-
 drivers/pinctrl/airoha/pinctrl-airoha.c | 14 ++++++++------
 drivers/pinctrl/airoha/pinctrl-an7563.c |  1 +
 drivers/pinctrl/airoha/pinctrl-an7581.c |  1 +
 drivers/pinctrl/airoha/pinctrl-an7583.c |  1 +
 drivers/pinctrl/airoha/pinctrl-en7523.c |  1 +
 drivers/pinctrl/airoha/pinctrl-en7528.c |  1 +
 7 files changed, 18 insertions(+), 7 deletions(-)
drivers/pinctrl/airoha/airoha-common.h +5 -1
index 16f7abcdfb83..850e733db15a 100644
@@ -89,6 +89,7 @@ struct airoha_pinctrl_conf {
 };
 
 struct airoha_gpiochip_regs {
+	unsigned int ngpio;
 	/* gpio */
 	const u32 *data;
 	const u32 *dir;
@@ -99,6 +100,8 @@ struct airoha_gpiochip_regs {
 	const u32 *edge;
 };
 
+extern const struct airoha_gpiochip_regs airoha_gpiochip_regs_64;
+
 struct airoha_pinctrl_confs_info {
 	const struct airoha_pinctrl_conf *confs;
 	unsigned int num_confs;
@@ -126,7 +129,7 @@ struct airoha_pinctrl {
 	struct regmap *regmap;
 
 	struct gpio_chip gpiochip;
-	struct airoha_gpiochip_regs *gpio_regs;
+	const struct airoha_gpiochip_regs *gpio_regs;
 	unsigned int num_irq_pins;
 };
 
@@ -134,6 +137,7 @@ struct airoha_pinctrl_match_data {
 	const char *chip_scu_compatible;
 	const char *pinctrl_name;
 	struct module *pinctrl_owner;
+	const struct airoha_gpiochip_regs *gpio_regs;
 	const struct pinctrl_pin_desc *pins;
 	const unsigned int num_pins;
 	const struct pingroup *grps;
drivers/pinctrl/airoha/pinctrl-airoha.c +8 -6
index 32d4af044ae1..5ae29e80da69 100644
@@ -94,7 +94,8 @@ static const u32 irq_edge_regs[] = {
 	REG_GPIO_INT_EDGE3
 };
 
-static struct airoha_gpiochip_regs airoha_gpiochip_regs = {
+const struct airoha_gpiochip_regs airoha_gpiochip_regs_64 = {
+	.ngpio = AIROHA_NUM_PINS,
 	.data = gpio_data_regs,
 	.dir = gpio_dir_regs,
 	.out = gpio_out_regs,
@@ -102,6 +103,7 @@ static struct airoha_gpiochip_regs airoha_gpiochip_regs = {
 	.level = irq_level_regs,
 	.edge = irq_edge_regs,
 };
+EXPORT_SYMBOL_GPL(airoha_gpiochip_regs_64);
 
 static int airoha_convert_pin_to_reg_offset(struct pinctrl_dev *pctrl_dev,
 					    struct pinctrl_gpio_range *range,
@@ -207,7 +209,7 @@ static void airoha_irq_unmask(struct irq_data *data)
 {
 	struct gpio_chip *gc = irq_data_get_irq_chip_data(data);
 	struct airoha_pinctrl *pinctrl = gpiochip_get_data(gc);
-	struct airoha_gpiochip_regs *gpio_regs = pinctrl->gpio_regs;
+	const struct airoha_gpiochip_regs *gpio_regs = pinctrl->gpio_regs;
 	u8 offset = data->hwirq % AIROHA_REG_GPIOCTRL_NUM_PIN;
 	u8 index = data->hwirq / AIROHA_REG_GPIOCTRL_NUM_PIN;
 	u32 mask = GENMASK(2 * offset + 1, 2 * offset);
@@ -244,7 +246,7 @@ static void airoha_irq_mask(struct irq_data *data)
 {
 	struct gpio_chip *gc = irq_data_get_irq_chip_data(data);
 	struct airoha_pinctrl *pinctrl = gpiochip_get_data(gc);
-	struct airoha_gpiochip_regs *gpio_regs = pinctrl->gpio_regs;
+	const struct airoha_gpiochip_regs *gpio_regs = pinctrl->gpio_regs;
 	u8 offset = data->hwirq % AIROHA_REG_GPIOCTRL_NUM_PIN;
 	u8 index = data->hwirq / AIROHA_REG_GPIOCTRL_NUM_PIN;
 	u32 mask = GENMASK(2 * offset + 1, 2 * offset);
@@ -261,7 +263,7 @@ static void airoha_irq_ack(struct irq_data *data)
 {
 	struct gpio_chip *gc = irq_data_get_irq_chip_data(data);
 	struct airoha_pinctrl *pinctrl = gpiochip_get_data(gc);
-	struct airoha_gpiochip_regs *gpio_regs = pinctrl->gpio_regs;
+	const struct airoha_gpiochip_regs *gpio_regs = pinctrl->gpio_regs;
 	u8 offset = data->hwirq % AIROHA_PIN_BANK_SIZE;
 	u8 index = data->hwirq / AIROHA_PIN_BANK_SIZE;
 
@@ -379,7 +381,7 @@ static int airoha_pinctrl_add_gpiochip(struct airoha_pinctrl *pinctrl,
 	gc->set = airoha_gpio_set;
 	gc->get = airoha_gpio_get;
 	gc->base = -1;
-	gc->ngpio = AIROHA_NUM_PINS;
+	gc->ngpio = pinctrl->gpio_regs->ngpio;
 
 	girq->default_type = IRQ_TYPE_NONE;
 	girq->handler = handle_bad_irq;
@@ -831,7 +833,7 @@ int airoha_pinctrl_probe(struct platform_device *pdev)
 	pinctrl->desc.pins = data->pins;
 	pinctrl->desc.npins = data->num_pins;
 
-	pinctrl->gpio_regs = &airoha_gpiochip_regs;
+	pinctrl->gpio_regs = data->gpio_regs;
 
 	err = devm_pinctrl_register_and_init(dev, &pinctrl->desc,
 					     pinctrl, &pinctrl->ctrl);
drivers/pinctrl/airoha/pinctrl-an7563.c +1 -0
index f011c6c9ccce..6a2a307807e3 100644
@@ -1063,6 +1063,7 @@ static const struct airoha_pinctrl_match_data pinctrl_match_data = {
 	.chip_scu_compatible = "airoha,en7581-chip-scu",
 	.pinctrl_name = KBUILD_MODNAME,
 	.pinctrl_owner = THIS_MODULE,
+	.gpio_regs = &airoha_gpiochip_regs_64,
 	.pins = pinctrl_pins,
 	.num_pins = ARRAY_SIZE(pinctrl_pins),
 	.grps = pinctrl_groups,
drivers/pinctrl/airoha/pinctrl-an7581.c +1 -0
index bfb777594811..6bec1d44b8a0 100644
@@ -1435,6 +1435,7 @@ static const struct airoha_pinctrl_match_data pinctrl_match_data = {
 	.chip_scu_compatible = "airoha,en7581-chip-scu",
 	.pinctrl_name = KBUILD_MODNAME,
 	.pinctrl_owner = THIS_MODULE,
+	.gpio_regs = &airoha_gpiochip_regs_64,
 	.pins = pinctrl_pins,
 	.num_pins = ARRAY_SIZE(pinctrl_pins),
 	.grps = pinctrl_groups,
drivers/pinctrl/airoha/pinctrl-an7583.c +1 -0
index 1cd0f442ddc1..2689bbd9ebba 100644
@@ -1465,6 +1465,7 @@ static const struct airoha_pinctrl_match_data pinctrl_match_data = {
 	.chip_scu_compatible = "airoha,en7581-chip-scu",
 	.pinctrl_name = KBUILD_MODNAME,
 	.pinctrl_owner = THIS_MODULE,
+	.gpio_regs = &airoha_gpiochip_regs_64,
 	.pins = pinctrl_pins,
 	.num_pins = ARRAY_SIZE(pinctrl_pins),
 	.grps = pinctrl_groups,
drivers/pinctrl/airoha/pinctrl-en7523.c +1 -0
index b0c5e60f0aeb..1589acef683f 100644
@@ -1107,6 +1107,7 @@ static const struct airoha_pinctrl_match_data pinctrl_match_data = {
 	.chip_scu_compatible = "airoha,en7523-chip-scu",
 	.pinctrl_name = KBUILD_MODNAME,
 	.pinctrl_owner = THIS_MODULE,
+	.gpio_regs = &airoha_gpiochip_regs_64,
 	.pins = pinctrl_pins,
 	.num_pins = ARRAY_SIZE(pinctrl_pins),
 	.grps = pinctrl_groups,
drivers/pinctrl/airoha/pinctrl-en7528.c +1 -0
index f6c8f834421f..9854e9530219 100644
@@ -1155,6 +1155,7 @@ static const struct airoha_pinctrl_match_data pinctrl_match_data = {
 	.chip_scu_compatible = "econet,en7528-chip-scu",
 	.pinctrl_name = KBUILD_MODNAME,
 	.pinctrl_owner = THIS_MODULE,
+	.gpio_regs = &airoha_gpiochip_regs_64,
 	.pins = pinctrl_pins,
 	.num_pins = ARRAY_SIZE(pinctrl_pins),
 	.grps = pinctrl_groups,
Signature · 1 line
2.34.1
#2 lore raw

PATCH v4 2/9 pinctrl: airoha: add per pin mode field mux

In reply to John Crispin

Newer Airoha SoCs select the function of a pin through a mode field in a dedicated IOMUX block instead of through function specific bits in the chip SCU. The AN7589 has a 4 bit field per pin, eight pins per 32 bit register. A group can then need one register write per pin, and the two entry regmap[] of a function group cannot carry that.

Let a function group supply a pin_modes[] array, parallel to the pins of the group. When it is set, set_mux writes each mode into the IOMUX regmap and then applies the regmap[] entries of the group, so a group can combine its pin modes with a register write in the GPIO block.

A SoC with an IOMUX describes it in its match data with struct airoha_pinctrl_iomux, which holds the width of the mode field. Probe then takes the regmap from the airoha,iomux phandle.

No functional change for the existing SoCs.

---
 drivers/pinctrl/airoha/airoha-common.h  | 14 ++++++++
 drivers/pinctrl/airoha/pinctrl-airoha.c | 48 +++++++++++++++++++++++++
 2 files changed, 62 insertions(+)
drivers/pinctrl/airoha/airoha-common.h +14 -0
index 850e733db15a..7a0cb8924e71 100644
@@ -49,6 +49,12 @@
 		.group_size = ARRAY_SIZE(table##_func_group),		\
 	}
 
+#define PINCTRL_MODE_FUNC_GROUP(id, table)				\
+	{								\
+		.name = id,						\
+		.pin_modes = table##_modes,				\
+	}
+
 #define PINCTRL_CONF_DESC(p, offset, mask)				\
 	{								\
 		.pin = p,						\
@@ -75,6 +81,7 @@ struct airoha_pinctrl_func_group {
 		u32 val;
 	} regmap[2];
 	int regmap_size;
+	const u8 *pin_modes;
 };
 
 struct airoha_pinctrl_func {
@@ -102,6 +109,10 @@ struct airoha_gpiochip_regs {
 
 extern const struct airoha_gpiochip_regs airoha_gpiochip_regs_64;
 
+struct airoha_pinctrl_iomux {
+	u8 mode_bits;
+};
+
 struct airoha_pinctrl_confs_info {
 	const struct airoha_pinctrl_conf *confs;
 	unsigned int num_confs;
@@ -126,6 +137,8 @@ struct airoha_pinctrl {
 	const struct airoha_pinctrl_confs_info *confs_info;
 
 	struct regmap *chip_scu;
+	struct regmap *iomux;
+	const struct airoha_pinctrl_iomux *iomux_info;
 	struct regmap *regmap;
 
 	struct gpio_chip gpiochip;
@@ -135,6 +148,7 @@ struct airoha_pinctrl {
 
 struct airoha_pinctrl_match_data {
 	const char *chip_scu_compatible;
+	const struct airoha_pinctrl_iomux *iomux_info;
 	const char *pinctrl_name;
 	struct module *pinctrl_owner;
 	const struct airoha_gpiochip_regs *gpio_regs;
drivers/pinctrl/airoha/pinctrl-airoha.c +48 -0

66 lines not on this page · raw message

Signature · 1 line
2.34.1
#3 lore raw

PATCH v4 3/9 pinctrl: airoha: make the chip SCU optional

In reply to John Crispin

A SoC that muxes every pin through the IOMUX block and describes no pin configuration has no use for the chip SCU. Skip the lookup when the match data names no chip SCU compatible, instead of handing a NULL compatible to syscon_regmap_lookup_by_compatible().

No functional change for the existing SoCs, which all name one.

---
Changes in v3:
- Add the Reviewed-by of Lorenzo.

Changes in v2:
- Look up the airoha,chip-scu phandle before the check for a chip SCU compatible (Lorenzo).

 drivers/pinctrl/airoha/pinctrl-airoha.c | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)
drivers/pinctrl/airoha/pinctrl-airoha.c +19 -6
index 615b48a056c4..c879e3009ee8 100644
@@ -833,6 +833,22 @@ static const struct pinctrl_ops airoha_pctlops = {
 	.dt_free_map = pinconf_generic_dt_free_map,
 };
 
+static struct regmap *
+airoha_pinctrl_chip_scu(struct device *dev,
+			const struct airoha_pinctrl_match_data *data)
+{
+	struct regmap *map;
+
+	map = syscon_regmap_lookup_by_phandle(dev->of_node, "airoha,chip-scu");
+	if (!IS_ERR_OR_NULL(map))
+		return map;
+
+	if (!data->chip_scu_compatible)
+		return NULL;
+
+	return syscon_regmap_lookup_by_compatible(data->chip_scu_compatible);
+}
+
 int airoha_pinctrl_probe(struct platform_device *pdev)
 {
 	const struct airoha_pinctrl_match_data *data;
@@ -853,12 +869,9 @@ int airoha_pinctrl_probe(struct platform_device *pdev)
 	if (IS_ERR(pinctrl->regmap))
 		return PTR_ERR(pinctrl->regmap);
 
-	map = syscon_regmap_lookup_by_phandle(pdev->dev.of_node, "airoha,chip-scu");
-	if (IS_ERR_OR_NULL(map)) {
-		map = syscon_regmap_lookup_by_compatible(data->chip_scu_compatible);
-		if (IS_ERR(map))
-			return PTR_ERR(map);
-	}
+	map = airoha_pinctrl_chip_scu(dev, data);
+	if (IS_ERR(map))
+		return PTR_ERR(map);
 
 	pinctrl->chip_scu = map;
 
Signature · 1 line
2.34.1
#4 lore raw

PATCH v4 4/9 pinctrl: airoha: mux a requested GPIO through the IOMUX

In reply to John Crispin

On a SoC with an IOMUX block every pin turns into a GPIO with one mode value, mode 0 on the AN7589. Add that value to struct airoha_pinctrl_iomux and write it when gpiolib requests a pin, so no SoC needs a gpio function with one group per pin.

Without an IOMUX the callback does nothing, so the existing SoCs keep their explicit gpio functions and their behavior.

---
 drivers/pinctrl/airoha/airoha-common.h  |  1 +
 drivers/pinctrl/airoha/pinctrl-airoha.c | 14 ++++++++++++++
 2 files changed, 15 insertions(+)
drivers/pinctrl/airoha/airoha-common.h +1 -0
index 7a0cb8924e71..adfce89493f0 100644
@@ -111,6 +111,7 @@ extern const struct airoha_gpiochip_regs airoha_gpiochip_regs_64;
 
 struct airoha_pinctrl_iomux {
 	u8 mode_bits;
+	u8 gpio_mode;
 };
 
 struct airoha_pinctrl_confs_info {
drivers/pinctrl/airoha/pinctrl-airoha.c +14 -0
index c879e3009ee8..917fd948a9dc 100644
@@ -430,6 +430,19 @@ static int airoha_pinmux_set_pin_modes(struct airoha_pinctrl *pinctrl,
 	return 0;
 }
 
+static int airoha_pinmux_gpio_request_enable(struct pinctrl_dev *pctrl_dev,
+					     struct pinctrl_gpio_range *range,
+					     unsigned int pin)
+{
+	struct airoha_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrl_dev);
+
+	if (!pinctrl->iomux_info)
+		return 0;
+
+	return airoha_pinmux_set_pin_mode(pinctrl, pin,
+					  pinctrl->iomux_info->gpio_mode);
+}
+
 static int airoha_pinmux_set_mux(struct pinctrl_dev *pctrl_dev,
 				 unsigned int selector,
 				 unsigned int group)
@@ -510,6 +523,7 @@ static const struct pinmux_ops airoha_pmxops = {
 	.get_functions_count = pinmux_generic_get_function_count,
 	.get_function_name = pinmux_generic_get_function_name,
 	.get_function_groups = pinmux_generic_get_function_groups,
+	.gpio_request_enable = airoha_pinmux_gpio_request_enable,
 	.gpio_set_direction = airoha_pinmux_set_direction,
 	.set_mux = airoha_pinmux_set_mux,
 	.strict = true,
Signature · 1 line
2.34.1
#5 lore raw

PATCH v4 5/9 dt-bindings: mfd: syscon: add airoha,an7589-iomux

In reply to John Crispin

The Airoha AN7589 IOMUX block holds the 4 bit mode field of each pin. The pin controller reaches it through the airoha,iomux phandle. Add it to the syscon compatibles.

---
Changes in v4:
- Add the Acked-by of Conor.

Changes in v3:
- New patch, split out of the pinctrl binding (Lee, Conor).

 Documentation/devicetree/bindings/mfd/syscon.yaml | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/mfd/syscon.yaml +1 -0
index 4d0cf16fa820..8bd9e8b8a8a8 100644
@@ -24,6 +24,7 @@ properties:
     oneOf:
       - items:
           - enum:
+              - airoha,an7589-iomux
               - airoha,en7581-pbus-csr
               - al,alpine-sysfabric-service
               - allwinner,sun8i-a83t-system-controller
Signature · 1 line
2.34.1
#6 lore raw

PATCH v4 6/9 dt-bindings: pinctrl: airoha: add AN7589

In reply to John Crispin

Document the AN7589 pin controller. It lives under the GPIO system controller and selects functions through a separate IOMUX syscon, referenced by the airoha,iomux phandle. Every pin is a GPIO in mode 0.

The AN7589 has no chip SCU dependency and the vendor SDK carries no pull or drive registers for it. Groups follow the SDK naming without its _grp suffix. As in the other Airoha pin controller bindings, a function names a block type, such as uart or i2c, and the group selects the instance. A node selects one group, except for pcm_spi and pcie, whose groups carry different signals of one device. The PON groups keep the working mode
only: the SDK encodes the driver reset sequence as extra pinctrl states, which belongs in the consumer driver.

The pwm function routes a PWM channel to one of GPIO0 to GPIO15, with one group per pin. The pin also needs its GPIO output enabled, so conf nodes allow the GPIO direction and output level. Pull and drive properties are not allowed, as no registers for them are known.

---
Changes in v4:
- Limit the pins of a conf node to 12, the size of the largest pin group (Conor).

Changes in v3:
- Move the IOMUX syscon compatible and the GPIO system controller to patches of their own (Lee, Conor).
- Allow one group per node, except for pcm_spi and pcie, whose groups carry different signals of one device (Conor).
- Fix the uart5 example, which listed uart5 and uart5_full together.

Changes in v2:
- One function per block type, with the group selecting the instance, as in the other Airoha pin controller bindings (Conor).
- List the valid groups for the groups property (Conor).

 .../pinctrl/airoha,an7589-pinctrl.yaml        | 355 ++++++++++++++++++
 MAINTAINERS                                   |   1 +
 2 files changed, 356 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/airoha,an7589-pinctrl.yaml
Documentation/devicetree/bindings/pinctrl/airoha,an7589-pinctrl.yaml new file +355 -0
new file mode 100644
index 000000000000..a343e0c36d1d
@@ -0,0 +1,355 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/pinctrl/airoha,an7589-pinctrl.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Airoha AN7589 Pin Controller
+
+maintainers:
+  - John Crispin <[email protected]>
+
+description:
+  The Airoha AN7589 pin controller is used to control SoC pins. Pin
+  functions are selected through a separate IOMUX register block, one
+  mode field per pin. Every pin is a GPIO in mode 0.
+
+properties:
+  compatible:
+    const: airoha,an7589-pinctrl
+
+  airoha,iomux:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description:
+      Phandle to the IOMUX syscon holding the per pin mode fields.
+
+  interrupts:
+    maxItems: 1
+
+  gpio-controller: true
+
+  '#gpio-cells':
+    const: 2
+
+  gpio-ranges:
+    maxItems: 1
+
+  interrupt-controller: true
+
+  '#interrupt-cells':
+    const: 2
+
+allOf:
+  - $ref: pinctrl.yaml#
+
+required:
+  - compatible
+  - airoha,iomux
+  - interrupts
+  - gpio-controller
+  - "#gpio-cells"
+  - interrupt-controller
+  - "#interrupt-cells"
+
+patternProperties:
+  '-pins$':
+    type: object
+
+    patternProperties:
+      '^mux(-|$)':
+        type: object
+
+        description:
+          pinmux configuration nodes.
+
+        $ref: /schemas/pinctrl/pinmux-node.yaml
+
+        properties:
+          function:
+            description:
+              A string containing the name of the function to mux to the group.
+            enum: [uart, i2c, spi, pcm, pcm_spi, i2s, mdio, mdcs, mdios, emmc,
+                   pcie, pon, sgpio, watchdog, shiftmux_spi, tod, sync_e, jtag,
+                   pwm]
+
+          groups:
+            description:
+              An array of strings. Each string contains the name of a group.
+            items:
+              enum: [uart1, uart2, uart3, uart3_alt, uart4, uart5, uart5_alt,
+                     uart5_full, uart6, uart6_full, i2c0, i2c1, i2c2, i2c3,
+                     i2c4, spi0, ext_spi0_full, ext_spi1, ext_spi1_full,
+                     ext_spi2, ext_spi2_full, ext_spi3, ext_spi3_full, pcm1,
+                     pcm2, pcm_spi, pcm_spi_cs, pcm_ctrl, i2s, mdio0, mdio1,
+                     mdio2, mdcs, mdios, emmc, pcie0_rst, pcie0_clkreq,
+                     pcie0_wake, pcie1_rst, pcie1_clkreq, pcie1_wake, pcie2_rst,
+                     pcie2_clkreq, pcie2_wake, pon1, pon2, sgpio0, sgpio1,
+                     watchdog, shiftmux_spi, tod, sync_e, cpu_jtag,
+                     cpu_jtag_alt, npu_jtag, ibex_jtag, pma50eth_jtag,
+                     ainpu_jtag, pma50pon_jtag, gpio0, gpio1, gpio2, gpio3,
+                     gpio4, gpio5, gpio6, gpio7, gpio8, gpio9, gpio10, gpio11,
+                     gpio12, gpio13, gpio14, gpio15]
+
+        required:
+          - function
+          - groups
+
+        allOf:
+          - if:
+              properties:
+                function:
+                  const: uart
+            then:
+              properties:
+                groups:
+                  items:
+                    enum: [uart1, uart2, uart3, uart3_alt, uart4, uart5,
+                           uart5_alt, uart5_full, uart6, uart6_full]
+                  maxItems: 1
+          - if:
+              properties:
+                function:
+                  const: i2c
+            then:
+              properties:
+                groups:
+                  items:
+                    enum: [i2c0, i2c1, i2c2, i2c3, i2c4]
+                  maxItems: 1
+          - if:
+              properties:
+                function:
+                  const: spi
+            then:
+              properties:
+                groups:
+                  items:
+                    enum: [spi0, ext_spi0_full, ext_spi1, ext_spi1_full,
+                           ext_spi2, ext_spi2_full, ext_spi3, ext_spi3_full]
+                  maxItems: 1
+          - if:
+              properties:
+                function:
+                  const: pcm
+            then:
+              properties:
+                groups:
+                  items:
+                    enum: [pcm1, pcm2]
+                  maxItems: 1
+          - if:
+              properties:
+                function:
+                  const: pcm_spi
+            then:
+              properties:
+                groups:
+                  items:
+                    enum: [pcm_spi, pcm_spi_cs, pcm_ctrl]
+                  maxItems: 3
+          - if:
+              properties:
+                function:
+                  const: i2s
+            then:
+              properties:
+                groups:
+                  enum: [i2s]
+          - if:
+              properties:
+                function:
+                  const: mdio
+            then:
+              properties:
+                groups:
+                  items:
+                    enum: [mdio0, mdio1, mdio2]
+                  maxItems: 1
+          - if:
+              properties:
+                function:
+                  const: mdcs
+            then:
+              properties:
+                groups:
+                  enum: [mdcs]
+          - if:
+              properties:
+                function:
+                  const: mdios
+            then:
+              properties:
+                groups:
+                  enum: [mdios]
+          - if:
+              properties:
+                function:
+                  const: emmc
+            then:
+              properties:
+                groups:
+                  enum: [emmc]
+          - if:
+              properties:
+                function:
+                  const: pcie
+            then:
+              properties:
+                groups:
+                  items:
+                    enum: [pcie0_rst, pcie0_clkreq, pcie0_wake, pcie1_rst,
+                           pcie1_clkreq, pcie1_wake, pcie2_rst, pcie2_clkreq,
+                           pcie2_wake]
+                  maxItems: 3
+          - if:
+              properties:
+                function:
+                  const: pon
+            then:
+              properties:
+                groups:
+                  items:
+                    enum: [pon1, pon2]
+                  maxItems: 1
+          - if:
+              properties:
+                function:
+                  const: sgpio
+            then:
+              properties:
+                groups:
+                  items:
+                    enum: [sgpio0, sgpio1]
+                  maxItems: 1
+          - if:
+              properties:
+                function:
+                  const: watchdog
+            then:
+              properties:
+                groups:
+                  enum: [watchdog]
+          - if:
+              properties:
+                function:
+                  const: shiftmux_spi
+            then:
+              properties:
+                groups:
+                  enum: [shiftmux_spi]
+          - if:
+              properties:
+                function:
+                  const: tod
+            then:
+              properties:
+                groups:
+                  enum: [tod]
+          - if:
+              properties:
+                function:
+                  const: sync_e
+            then:
+              properties:
+                groups:
+                  enum: [sync_e]
+          - if:
+              properties:
+                function:
+                  const: jtag
+            then:
+              properties:
+                groups:
+                  items:
+                    enum: [cpu_jtag, cpu_jtag_alt, npu_jtag, ibex_jtag,
+                           pma50eth_jtag, ainpu_jtag, pma50pon_jtag]
+                  maxItems: 1
+          - if:
+              properties:
+                function:
+                  const: pwm
+            then:
+              properties:
+                groups:
+                  items:
+                    enum: [gpio0, gpio1, gpio2, gpio3, gpio4, gpio5, gpio6,
+                           gpio7, gpio8, gpio9, gpio10, gpio11, gpio12, gpio13,
+                           gpio14, gpio15]
+                  maxItems: 1
+
+        additionalProperties: false
+
+      '^conf(-|$)':
+        type: object
+
+        description:
+          pinconf configuration nodes.
+
+        $ref: /schemas/pinctrl/pincfg-node.yaml
+
+        properties:
+          pins:
+            description:
+              An array of strings. Each string contains the name of a pin.
+            items:
+              pattern: '^gpio([0-9]|[1-6][0-9]|7[0-3])$'
+            minItems: 1
+            maxItems: 12
+
+          input-enable: true
+
+          output-enable: true
+
+          output-low: true
+
+          output-high: true
+
+        required:
+          - pins
+
+        additionalProperties: false
+
+    additionalProperties: false
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+
+    pinctrl {
+      compatible = "airoha,an7589-pinctrl";
+      airoha,iomux = <&iomux>;
+
+      interrupt-parent = <&gic>;
+      interrupts = <GIC_SPI 82 IRQ_TYPE_LEVEL_HIGH>;
+
+      gpio-controller;
+      #gpio-cells = <2>;
+
+      interrupt-controller;
+      #interrupt-cells = <2>;
+
+      gpio-ranges = <&pinctrl 0 0 74>;
+
+      mmc-pins {
+        mux {
+          function = "emmc";
+          groups = "emmc";
+        };
+      };
+
+      pcie0-pins {
+        mux {
+          function = "pcie";
+          groups = "pcie0_rst", "pcie0_clkreq", "pcie0_wake";
+        };
+      };
+
+      uart5-pins {
+        mux {
+          function = "uart";
+          groups = "uart5_full";
+        };
+      };
+    };
MAINTAINERS +1 -0
index 193e1056c523..c6396842f6c3 100644
@@ -22269,6 +22269,7 @@ PIN CONTROLLER - AIROHA
 M:	Lorenzo Bianconi <[email protected]>
 L:	[email protected] (moderated for non-subscribers)
 S:	Maintained
+F:	Documentation/devicetree/bindings/pinctrl/airoha,an7589-pinctrl.yaml
 F:	Documentation/devicetree/bindings/pinctrl/airoha,en7581-pinctrl.yaml
 F:	drivers/pinctrl/airoha/pinctrl-airoha.c
 
Signature · 1 line
2.34.1
#7 lore raw

PATCH v4 7/9 dt-bindings: mfd: airoha: add AN7589 GPIO system controller

In reply to John Crispin

Document the AN7589 GPIO system controller. It is a syscon with the pin controller as its child node. The block also holds the PWM controller, which a later series adds.

---
Changes in v4:
- Add the Acked-by of Conor.
- Commit message: the PWM controller is no longer named a second child, as it gets no child node (Conor).

Changes in v3:
- New patch, split out of the pinctrl binding (Lee, Conor).
- Name the PWM controller, the second child of the block, in the commit message (Conor).

 .../mfd/airoha,an7589-gpio-sysctl.yaml        | 66 +++++++++++++++++++
 MAINTAINERS                                   |  1 +
 2 files changed, 67 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/airoha,an7589-gpio-sysctl.yaml
Documentation/devicetree/bindings/mfd/airoha,an7589-gpio-sysctl.yaml new file +66 -0
new file mode 100644
index 000000000000..0785b61bdda3
@@ -0,0 +1,66 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mfd/airoha,an7589-gpio-sysctl.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Airoha AN7589 GPIO System Controller
+
+maintainers:
+  - John Crispin <[email protected]>
+
+description:
+  Airoha AN7589 SoC GPIO system controller which provides a register map
+  for controlling the GPIO and pins of the SoC.
+
+properties:
+  compatible:
+    items:
+      - const: airoha,an7589-gpio-sysctl
+      - const: syscon
+      - const: simple-mfd
+
+  reg:
+    maxItems: 1
+
+  pinctrl:
+    type: object
+    $ref: /schemas/pinctrl/airoha,an7589-pinctrl.yaml
+    description:
+      Child node definition for AN7589 Pin controller
+
+required:
+  - compatible
+  - reg
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+
+    system-controller@1fbf0200 {
+      compatible = "airoha,an7589-gpio-sysctl", "syscon", "simple-mfd";
+      reg = <0x1fbf0200 0x100>;
+
+      pinctrl {
+        compatible = "airoha,an7589-pinctrl";
+        airoha,iomux = <&iomux>;
+
+        interrupt-parent = <&gic>;
+        interrupts = <GIC_SPI 82 IRQ_TYPE_LEVEL_HIGH>;
+
+        gpio-controller;
+        #gpio-cells = <2>;
+
+        interrupt-controller;
+        #interrupt-cells = <2>;
+
+        mmc-pins {
+          mux {
+            function = "emmc";
+            groups = "emmc";
+          };
+        };
+      };
+    };
MAINTAINERS +1 -0
index c6396842f6c3..93eb6bdb077e 100644
@@ -22269,6 +22269,7 @@ PIN CONTROLLER - AIROHA
 M:	Lorenzo Bianconi <[email protected]>
 L:	[email protected] (moderated for non-subscribers)
 S:	Maintained
+F:	Documentation/devicetree/bindings/mfd/airoha,an7589-gpio-sysctl.yaml
 F:	Documentation/devicetree/bindings/pinctrl/airoha,an7589-pinctrl.yaml
 F:	Documentation/devicetree/bindings/pinctrl/airoha,en7581-pinctrl.yaml
 F:	drivers/pinctrl/airoha/pinctrl-airoha.c
Signature · 1 line
2.34.1
#8 lore raw

PATCH v4 8/9 pinctrl: airoha: move the GPIO register offsets to the common header

In reply to John Crispin

The GPIO register offsets are private to pinctrl-airoha.c, which builds the shared 64 pin register table from them. A SoC with more GPIO banks needs its own table, built from the same offsets and its own for the extra banks.

Move the offsets to airoha-common.h so the SoC drivers can use them.

No functional change.

---
Changes in v2:
- Add the Acked-by of Lorenzo.

 drivers/pinctrl/airoha/airoha-common.h  | 20 ++++++++++++++++++++
 drivers/pinctrl/airoha/pinctrl-airoha.c | 20 --------------------
 2 files changed, 20 insertions(+), 20 deletions(-)
drivers/pinctrl/airoha/airoha-common.h +20 -0
index adfce89493f0..dc9b897ea77c 100644
@@ -34,6 +34,26 @@
 #include "../pinconf.h"
 #include "../pinmux.h"
 
+/* GPIOs */
+#define REG_GPIO_CTRL				0x0000
+#define REG_GPIO_DATA				0x0004
+#define REG_GPIO_INT				0x0008
+#define REG_GPIO_INT_EDGE			0x000c
+#define REG_GPIO_INT_LEVEL			0x0010
+#define REG_GPIO_OE				0x0014
+#define REG_GPIO_CTRL1				0x0020
+#define REG_GPIO_CTRL2				0x0060
+#define REG_GPIO_CTRL3				0x0064
+#define REG_GPIO_DATA1				0x0070
+#define REG_GPIO_OE1				0x0078
+#define REG_GPIO_INT1				0x007c
+#define REG_GPIO_INT_EDGE1			0x0080
+#define REG_GPIO_INT_EDGE2			0x0084
+#define REG_GPIO_INT_EDGE3			0x0088
+#define REG_GPIO_INT_LEVEL1			0x008c
+#define REG_GPIO_INT_LEVEL2			0x0090
+#define REG_GPIO_INT_LEVEL3			0x0094
+
 #define AIROHA_NUM_PINS				64
 #define AIROHA_PIN_BANK_SIZE			(AIROHA_NUM_PINS / 2)
 #define AIROHA_REG_GPIOCTRL_NUM_PIN		(AIROHA_NUM_PINS / 4)
drivers/pinctrl/airoha/pinctrl-airoha.c +0 -20
index 917fd948a9dc..1508890960e4 100644
@@ -7,26 +7,6 @@
 
 #include "airoha-common.h"
 
-/* GPIOs */
-#define REG_GPIO_CTRL				0x0000
-#define REG_GPIO_DATA				0x0004
-#define REG_GPIO_INT				0x0008
-#define REG_GPIO_INT_EDGE			0x000c
-#define REG_GPIO_INT_LEVEL			0x0010
-#define REG_GPIO_OE				0x0014
-#define REG_GPIO_CTRL1				0x0020
-#define REG_GPIO_CTRL2				0x0060
-#define REG_GPIO_CTRL3				0x0064
-#define REG_GPIO_DATA1				0x0070
-#define REG_GPIO_OE1				0x0078
-#define REG_GPIO_INT1				0x007c
-#define REG_GPIO_INT_EDGE1			0x0080
-#define REG_GPIO_INT_EDGE2			0x0084
-#define REG_GPIO_INT_EDGE3			0x0088
-#define REG_GPIO_INT_LEVEL1			0x008c
-#define REG_GPIO_INT_LEVEL2			0x0090
-#define REG_GPIO_INT_LEVEL3			0x0094
-
 #define airoha_pinctrl_get_pullup_conf(pinctrl, pin, val)			\
 	airoha_pinctrl_get_conf((pinctrl), AIROHA_PINCTRL_CONFS_PULLUP,		\
 				(pin), (val))
Signature · 1 line
2.34.1
#9 lore raw

PATCH v4 9/9 pinctrl: airoha: add support of an7589 SoC

In reply to John Crispin

Add pin controller support for the Airoha AN7589. Its GPIO block is the EN7581 one with a third bank, giving 74 GPIOs. Pin functions are selected through a separate IOMUX block holding a 4 bit mode per pin, where mode 0 is GPIO.

As on the EN7581, the pwm function is available on GPIO0 to GPIO15 through the GPIO flash mode register.

Unlike on the other SoCs, the pull and drive registers of the AN7589 are not known, so no pull or drive configuration is provided.

---
Changes in v3:
- Add the Reviewed-by of Lorenzo.

Changes in v2:
- Merge the functions as in the binding: uart, i2c, spi, pcm, mdio, pcie, pon, sgpio and jtag each cover all instances.
- Name the match data, the OF match table and the platform driver after the AN7589 (Lorenzo).

 MAINTAINERS                             |   1 +
 drivers/pinctrl/airoha/Kconfig          |  11 +
 drivers/pinctrl/airoha/Makefile         |   1 +
 drivers/pinctrl/airoha/pinctrl-an7589.c | 623 ++++++++++++++++++++++++
 4 files changed, 636 insertions(+)
 create mode 100644 drivers/pinctrl/airoha/pinctrl-an7589.c
MAINTAINERS +1 -0
index 93eb6bdb077e..ca2aed8dd6e7 100644
@@ -22273,6 +22273,7 @@ F:	Documentation/devicetree/bindings/mfd/airoha,an7589-gpio-sysctl.yaml
 F:	Documentation/devicetree/bindings/pinctrl/airoha,an7589-pinctrl.yaml
 F:	Documentation/devicetree/bindings/pinctrl/airoha,en7581-pinctrl.yaml
 F:	drivers/pinctrl/airoha/pinctrl-airoha.c
+F:	drivers/pinctrl/airoha/pinctrl-an7589.c
 
 PIN CONTROLLER - AMD
 M:	Basavaraj Natikar <[email protected]>
drivers/pinctrl/airoha/Kconfig +11 -0
index 0f0986c81219..1948101ae5ac 100644
@@ -16,6 +16,7 @@ config PINCTRL_AIROHA
 	imply PINCTRL_AIROHA_AN7563
 	imply PINCTRL_AIROHA_AN7581
 	imply PINCTRL_AIROHA_AN7583
+	imply PINCTRL_AIROHA_AN7589
 	imply PINCTRL_AIROHA_EN7523
 	imply PINCTRL_AIROHA_EN7528
 	help
@@ -46,6 +47,16 @@ config PINCTRL_AIROHA_AN7583
 	  Say yes here to support pin controller and gpio driver
 	  on Airoha AN7583, AN7553, AN7567 and other compatible SoCs.
 
+config PINCTRL_AIROHA_AN7589
+	tristate "AN7589 pinctrl"
+	depends on ARM64 || COMPILE_TEST
+	depends on PINCTRL_AIROHA
+	help
+	  Say yes here to support pin controller and gpio driver
+	  on Airoha AN7589 and other compatible SoCs. The AN7589
+	  selects pin functions through its IOMUX block and has
+	  74 GPIOs in three banks.
+
 config PINCTRL_AIROHA_EN7523
 	tristate "EN7523 pinctrl"
 	depends on ARM || COMPILE_TEST
drivers/pinctrl/airoha/Makefile +1 -0
index 4dc7c556ce4d..550803cbd5b6 100644
@@ -7,5 +7,6 @@ obj-$(CONFIG_PINCTRL_AIROHA)		+= pinctrl-airoha.o
 obj-$(CONFIG_PINCTRL_AIROHA_AN7563)	+= pinctrl-an7563.o
 obj-$(CONFIG_PINCTRL_AIROHA_AN7581)	+= pinctrl-an7581.o
 obj-$(CONFIG_PINCTRL_AIROHA_AN7583)	+= pinctrl-an7583.o
+obj-$(CONFIG_PINCTRL_AIROHA_AN7589)	+= pinctrl-an7589.o
 obj-$(CONFIG_PINCTRL_AIROHA_EN7523)	+= pinctrl-en7523.o
 obj-$(CONFIG_PINCTRL_AIROHA_EN7528)	+= pinctrl-en7528.o
drivers/pinctrl/airoha/pinctrl-an7589.c new file +623 -0

623 lines not on this page · raw message

Signature · 1 line
2.34.1
maintainer
#11 lore raw
In reply to John Crispin
Quoted 6 lines · John Crispin

Patch 5 adds the IOMUX to the syscon compatibles. Patch 6 adds the binding for the pin controller. Patch 7 adds the binding for the GPIO system controller it sits under, which also holds the PWM controller. Patch 8 moves the GPIO register offsets to the common header, so the AN7589 data can describe its own register table, with no functional change. Patch 9 adds the AN7589 pin data.

(...)

Quoted 3 lines

- Split the bindings in three: the syscon compatible (patch 5), the pin controller (patch 6) and the GPIO system controller (patch 7) (Lee, Conor).

Once Lee merges patch 5 with the syscon bindings I can merge the rest to the pinctrl tree.

Yours,
Linus Walleij