Skip to contentSkip to conversation

pinctrl: sunxi: number the IRQ banks from the first one that has IRQs

PATCH In review Pablo Mazzini 3 participants 7 messages Oct 25 – Nov 10

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

v3 cover pinctrl: sunxi: number the IRQ banks from the first one that has IRQs

The DT pinctrl helper numbers the IRQ banks from PA, even when PA has none. The A523 got a DT interrupt for its unimplemented PA bank to work around that, the A733 would need the same, and on both PK is written past the end of irq_array.

Number the IRQ banks like the static drivers do, with irq_bank_map for the A523 and A733, and drop the PA interrupt from the binding and the A523 DT. The B288 (IRQ banks on PB, PD, PF and PG) then needs no made-up interrupt.

v3:
- apply irq_bank_map to the A733 register layout too (Sashiko)

v2:
- give the A523 and A733 an irq_bank_map, and drop the PA interrupt from the binding and the A523 DT

Pablo Mazzini (3):
pinctrl: sunxi: dt: number the IRQ banks from the first one that has
IRQs
dt-bindings: pinctrl: sun55i-a523: one interrupt per implemented bank
arm64: dts: allwinner: a523: drop the PA GPIO interrupt

 .../bindings/pinctrl/allwinner,sun55i-a523-pinctrl.yaml   | 8 ++++----
 arch/arm64/boot/dts/allwinner/sun55i-a523.dtsi            | 3 +--
 drivers/pinctrl/sunxi/pinctrl-sun55i-a523.c               | 2 +-
 drivers/pinctrl/sunxi/pinctrl-sun60i-a733.c               | 5 ++++-
 drivers/pinctrl/sunxi/pinctrl-sunxi-dt.c                  | 8 +++-----
 drivers/pinctrl/sunxi/pinctrl-sunxi.h                     | 7 ++++---
 6 files changed, 17 insertions(+), 16 deletions(-)

base-commit: 4f0dbdbdb3ad122e8bbfb1d722fd584bac7124db

Signature · 1 line
2.52.0
#1 lore raw

PATCH v3 1/3 pinctrl: sunxi: dt: number the IRQ banks from the first one that has IRQs

prepare_function_table() numbers the IRQ banks from PA, even when PA has none. The static drivers number only the banks that have IRQs, and use irq_bank_map when the IRQ registers do not start at bank 0.

Do the same here, and give the A523 and A733, whose IRQ registers start at PB, the map they need. Apply the map to the A733 register layout too, which so far ignored it. This also fixes PK on both, which was numbered 10 and written past the end of irq_array.

---
 drivers/pinctrl/sunxi/pinctrl-sun55i-a523.c | 2 +-
 drivers/pinctrl/sunxi/pinctrl-sun60i-a733.c | 5 ++++-
 drivers/pinctrl/sunxi/pinctrl-sunxi-dt.c    | 8 +++-----
 drivers/pinctrl/sunxi/pinctrl-sunxi.h       | 7 ++++---
 4 files changed, 12 insertions(+), 10 deletions(-)
drivers/pinctrl/sunxi/pinctrl-sun55i-a523.c +1 -1
index 801f62abc93d..940942bf6f95 100644
@@ -17,7 +17,7 @@ static const u8 a523_nr_bank_pins[SUNXI_PINCTRL_MAX_BANKS] =
 /*	  PA  PB  PC  PD  PE  PF  PG  PH  PI  PJ  PK */
 	{  0, 15, 17, 24, 16,  7, 15, 20, 17, 28, 24 };
 
-static const unsigned int a523_irq_bank_map[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
+static const unsigned int a523_irq_bank_map[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
 
 static const u8 a523_irq_bank_muxes[SUNXI_PINCTRL_MAX_BANKS] =
 /*	  PA  PB  PC  PD  PE  PF  PG  PH  PI  PJ  PK */
drivers/pinctrl/sunxi/pinctrl-sun60i-a733.c +4 -1
index ca82f08a3a65..3ebe926a1bc6 100644
@@ -21,8 +21,11 @@ static const u8 a733_irq_bank_muxes[SUNXI_PINCTRL_MAX_BANKS] =
 /*	  PA  PB  PC  PD  PE  PF  PG  PH  PI  PJ  PK */
 	{  0, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14};
 
+static const unsigned int a733_irq_bank_map[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
+
 static struct sunxi_pinctrl_desc a733_pinctrl_data = {
-	.irq_banks = 10,
+	.irq_banks = ARRAY_SIZE(a733_irq_bank_map),
+	.irq_bank_map = a733_irq_bank_map,
 	.irq_read_needs_mux = true,
 	.io_bias_cfg_variant = BIAS_VOLTAGE_PIO_POW_MODE_SEL,
 };
drivers/pinctrl/sunxi/pinctrl-sunxi-dt.c +3 -5
index 50a16f3bd131..9c5eb21a86a5 100644
@@ -208,7 +208,7 @@ static int prepare_function_table(struct device *dev, struct device_node *pnode,
 	 * The extra functions will be filled in later.
 	 */
 	irq_bank = 0;
-	last_bank = 0;
+	last_bank = -1;
 	for (i = 0; i < npins; i++) {
 		struct sunxi_desc_pin *pin = &pins[i];
 		int bank = (pin->pin.number - pin_base) / PINS_PER_BANK;
@@ -221,16 +221,14 @@ static int prepare_function_table(struct device *dev, struct device_node *pnode,
 		func[1].muxval = 1;
 
 		if (irq_mux) {
-			if (bank > last_bank)
+			if (last_bank >= 0 && bank > last_bank)
 				irq_bank++;
 			func[lastfunc].muxval = irq_mux;
 			func[lastfunc].irqbank = irq_bank;
 			func[lastfunc].irqnum = pin->pin.number % PINS_PER_BANK;
 			func[lastfunc].name = "irq";
-		}
-
-		if (bank > last_bank)
 			last_bank = bank;
+		}
 
 		pin->functions = func;
 
drivers/pinctrl/sunxi/pinctrl-sunxi.h +4 -3
index d09467ed437a..57a1e5e48f35 100644
@@ -248,12 +248,13 @@ static inline u32 sunxi_irq_hw_bank_num(const struct sunxi_pinctrl_desc *desc,
 
 static inline u32 sunxi_irq_base_reg(const struct sunxi_pinctrl *pctl, u16 bank)
 {
+	u32 hw_bank = sunxi_irq_hw_bank_num(pctl->desc, bank);
+
 	if (pctl->flags & SUNXI_PINCTRL_NCAT3_REG_LAYOUT)
-		return pctl->bank_offset + bank * pctl->bank_mem_size +
+		return pctl->bank_offset + hw_bank * pctl->bank_mem_size +
 		       A733_IRQ_REGS_OFFSET;
 
-	return IRQ_REGS_OFFSET +
-	       sunxi_irq_hw_bank_num(pctl->desc, bank) * IRQ_MEM_SIZE;
+	return IRQ_REGS_OFFSET + hw_bank * IRQ_MEM_SIZE;
 }
 
 static inline u32 sunxi_irq_cfg_reg(const struct sunxi_pinctrl *pctl,
Signature · 1 line
2.52.0
#2 lore raw

PATCH v3 2/3 dt-bindings: pinctrl: sun55i-a523: one interrupt per implemented bank

In reply to Pablo Mazzini

The A523 and A733 have no PA pins, the A523's PA IRQ bank is not implemented, and the driver no longer counts it. Go back to one interrupt, and one debounce period, per implemented bank: 10 for both.

This reverts commit 11f25ac56372 ("dt-bindings: pinctrl: sun55i-a523:
increase IRQ banks number").

---
 .../bindings/pinctrl/allwinner,sun55i-a523-pinctrl.yaml   | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
Documentation/devicetree/bindings/pinctrl/allwinner,sun55i-a523-pinctrl.yaml +4 -4
index d7d0ba32ced4..c04b04acf6e4 100644
@@ -36,7 +36,7 @@ properties:
 
   interrupts:
     minItems: 2
-    maxItems: 11
+    maxItems: 10
     description:
       One interrupt per external interrupt bank supported on the
       controller, sorted by bank number ascending order.
@@ -63,7 +63,7 @@ properties:
       bank found in the controller
     $ref: /schemas/types.yaml#/definitions/uint32-array
     minItems: 2
-    maxItems: 11
+    maxItems: 10
 
 patternProperties:
   # It's pretty scary, but the basic idea is that:
@@ -133,8 +133,8 @@ allOf:
     then:
       properties:
         interrupts:
-          minItems: 11
-          maxItems: 11
+          minItems: 10
+          maxItems: 10
 
   - if:
       properties:
Signature · 1 line
2.52.0
#4 lore raw

PATCH v3 3/3 arm64: dts: allwinner: a523: drop the PA GPIO interrupt

In reply to Pablo Mazzini

The PA IRQ bank is not implemented, and the driver now numbers the IRQ banks from PB. Drop its interrupt.

This reverts commit 6b81aa0c8a4f ("arm64: dts: allwinner: a523: Add missing GPIO interrupt").

---
 arch/arm64/boot/dts/allwinner/sun55i-a523.dtsi | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm64/boot/dts/allwinner/sun55i-a523.dtsi +1 -2
index 85ef492ffeae..fc4d714a96ea 100644
@@ -129,8 +129,7 @@ gpu: gpu@1800000 {
 		pio: pinctrl@2000000 {
 			compatible = "allwinner,sun55i-a523-pinctrl";
 			reg = <0x2000000 0x800>;
-			interrupts = <GIC_SPI 67 IRQ_TYPE_LEVEL_HIGH>,
-				     <GIC_SPI 69 IRQ_TYPE_LEVEL_HIGH>,
+			interrupts = <GIC_SPI 69 IRQ_TYPE_LEVEL_HIGH>,
 				     <GIC_SPI 71 IRQ_TYPE_LEVEL_HIGH>,
 				     <GIC_SPI 73 IRQ_TYPE_LEVEL_HIGH>,
 				     <GIC_SPI 75 IRQ_TYPE_LEVEL_HIGH>,
Signature · 1 line
2.52.0
#5 lore raw
In reply to Pablo Mazzini

Hi Pablo,

just some heads up about process:
- Please do not repost that quickly! The kernel doc says to wait at least a day, but that's only the lower limit, in case the series is almost ready and there were only minor comments from real(!) reviewers.
I would wait for a couple of days, after you got some proper reviews.
The reason is that reviews (by humans) take time, and it's not like people are bored waiting for some patches to look at. So they might be interrupted by something or need to do some checks and research. It's pretty bad if their effort is ambushed by a new revision, which now means they need to start over.
- Please do not repost just because Sashiko said something. Wait for a proper review. It's probably a good idea to acknowledge the comment, but don't just re-post then.
- Try to avoid posting inside the merge window. Depending on the subsystem and maintainer, your posts might just be ignored, because they might be busy fixing up conflicts. But more importantly: you are missing the correct base: you should always base your patches on an -rc1, unless being told otherwise explicitly. And since -rc1 won't be out till Sunday, this is not a good timing.

I will comment on the patch set separately.

Cheers,
Andre

Quoted 33 lines · Pablo Mazzini

The DT pinctrl helper numbers the IRQ banks from PA, even when PA has none. The A523 got a DT interrupt for its unimplemented PA bank to work around that, the A733 would need the same, and on both PK is written past the end of irq_array.

Number the IRQ banks like the static drivers do, with irq_bank_map for the A523 and A733, and drop the PA interrupt from the binding and the A523 DT. The B288 (IRQ banks on PB, PD, PF and PG) then needs no made-up interrupt.

v3:
- apply irq_bank_map to the A733 register layout too (Sashiko)

v2:
- give the A523 and A733 an irq_bank_map, and drop the PA interrupt from the binding and the A523 DT

Pablo Mazzini (3):
pinctrl: sunxi: dt: number the IRQ banks from the first one that has
IRQs
dt-bindings: pinctrl: sun55i-a523: one interrupt per implemented bank
arm64: dts: allwinner: a523: drop the PA GPIO interrupt

  .../bindings/pinctrl/allwinner,sun55i-a523-pinctrl.yaml   | 8 ++++----
  arch/arm64/boot/dts/allwinner/sun55i-a523.dtsi            | 3 +--
  drivers/pinctrl/sunxi/pinctrl-sun55i-a523.c               | 2 +-
  drivers/pinctrl/sunxi/pinctrl-sun60i-a733.c               | 5 ++++-
  drivers/pinctrl/sunxi/pinctrl-sunxi-dt.c                  | 8 +++-----
  drivers/pinctrl/sunxi/pinctrl-sunxi.h                     | 7 ++++---
  6 files changed, 17 insertions(+), 16 deletions(-)

base-commit: 4f0dbdbdb3ad122e8bbfb1d722fd584bac7124db

#6 lore raw

Hi Andre,

Thanks, understood. I will wait for proper reviews and for -rc1 before posting again.

Pablo

Quoted 64 lines · Andre Przywara

Hi Pablo,

just some heads up about process:
- Please do not repost that quickly! The kernel doc says to wait at least a day, but that's only the lower limit, in case the series is almost ready and there were only minor comments from real(!) reviewers. I would wait for a couple of days, after you got some proper reviews. The reason is that reviews (by humans) take time, and it's not like people are bored waiting for some patches to look at. So they might be interrupted by something or need to do some checks and research. It's pretty bad if their effort is ambushed by a new revision, which now means they need to start over.
- Please do not repost just because Sashiko said something. Wait for a proper review. It's probably a good idea to acknowledge the comment, but don't just re-post then.
- Try to avoid posting inside the merge window. Depending on the subsystem and maintainer, your posts might just be ignored, because they might be busy fixing up conflicts. But more importantly: you are missing the correct base: you should always base your patches on an -rc1, unless being told otherwise explicitly. And since -rc1 won't be out till Sunday, this is not a good timing.

I will comment on the patch set separately.

Cheers,
Andre

Quoted 33 lines · Pablo Mazzini

The DT pinctrl helper numbers the IRQ banks from PA, even when PA has none. The A523 got a DT interrupt for its unimplemented PA bank to work around that, the A733 would need the same, and on both PK is written past the end of irq_array.

Number the IRQ banks like the static drivers do, with irq_bank_map for the A523 and A733, and drop the PA interrupt from the binding and the A523 DT. The B288 (IRQ banks on PB, PD, PF and PG) then needs no made-up interrupt.

v3:
- apply irq_bank_map to the A733 register layout too (Sashiko)

v2:
- give the A523 and A733 an irq_bank_map, and drop the PA interrupt from the binding and the A523 DT

Pablo Mazzini (3):
pinctrl: sunxi: dt: number the IRQ banks from the first one that has
IRQs
dt-bindings: pinctrl: sun55i-a523: one interrupt per implemented bank
arm64: dts: allwinner: a523: drop the PA GPIO interrupt

  .../bindings/pinctrl/allwinner,sun55i-a523-pinctrl.yaml   | 8 ++++----
  arch/arm64/boot/dts/allwinner/sun55i-a523.dtsi            | 3 +--
  drivers/pinctrl/sunxi/pinctrl-sun55i-a523.c               | 2 +-
  drivers/pinctrl/sunxi/pinctrl-sun60i-a733.c               | 5 ++++-
  drivers/pinctrl/sunxi/pinctrl-sunxi-dt.c                  | 8 +++-----
  drivers/pinctrl/sunxi/pinctrl-sunxi.h                     | 7 ++++---
  6 files changed, 17 insertions(+), 16 deletions(-)

base-commit: 4f0dbdbdb3ad122e8bbfb1d722fd584bac7124db

maintainer Acked-by on v3 2/3
#3 lore raw

Re: [PATCH v3 2/3] dt-bindings: pinctrl: sun55i-a523: one interrupt per implemented bank

In reply to Pablo Mazzini
Quoted 4 lines · Pablo Mazzini

The A523 and A733 have no PA pins, the A523's PA IRQ bank is not implemented, and the driver no longer counts it. Go back to one interrupt, and one debounce period, per implemented bank: 10 for both.

Quoted 8 lines

This reverts commit 11f25ac56372 ("dt-bindings: pinctrl: sun55i-a523:
increase IRQ banks number").

---
 .../bindings/pinctrl/allwinner,sun55i-a523-pinctrl.yaml   | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)