Skip to contentSkip to conversation

ARM: sunxi: add Allwinner B288 and the PocketBook Verse

PATCH Applied Pablo Mazzini 6 participants 23 messages Oct 5 – Oct 20

Subsystems (11)

v3 of 5 Applied Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v3 cover ARM: sunxi: add Allwinner B288 and the PocketBook Verse

The Allwinner B288 (sun8iw10p1) is a dual Cortex-A7 SoC used in e-book readers. This series adds the CCU and pin controller drivers, the RTC, I2C, NMI and watchdog compatibles, the SoC .dtsi, and one board: the PocketBook Verse (PB629), a 6" reader.

The B288 is closest to the A64: most of its PLLs are bit-identical. The clock and pin descriptions come from Allwinner's BSP, cross-checked against ccu-sun50i-a64.c. Tested on a PB629, boots to userspace.

The pin controller relies on "pinctrl: sunxi: dt: number the IRQ banks from the first one that has IRQs" for correct PIO interrupt mapping.

Changes since v2:
- Drop the MMC binding patch, applied by Ulf.
- Rebase onto sunxi/for-next.
- Constrain the RTC clock outputs and pinctrl interrupts in the bindings (Sashiko).
- Add a B288 watchdog compatible (Andre).
- DTS: drop the memory node, the arch timer workaround and the sunxi.c entry; add disable-wp and the eMMC 1.8V modes; DLDO1 no longer always-on; mainline pin function names (Andre).

Changes since v1:
- Add this cover letter.
- Drop both new bindings; add the compatibles to the existing allwinner,sun4i-a10-{ccu,pinctrl}.yaml instead.
- Rewrite the pinctrl driver in the DT-provided pinmux style.

Pablo Mazzini (11):
dt-bindings: clock: sun4i-a10-ccu: add Allwinner B288
clk: sunxi-ng: add Allwinner B288 CCU driver
dt-bindings: pinctrl: sun4i-a10: add Allwinner B288
pinctrl: sunxi: add Allwinner B288 pin controller driver
dt-bindings: rtc: sun6i-a31: add Allwinner B288
rtc: sun6i: add Allwinner B288 compatible
dt-bindings: i2c: mv64xxx: add Allwinner B288
dt-bindings: interrupt-controller: add Allwinner B288 NMI
dt-bindings: watchdog: sun4i-a10-wdt: add Allwinner B288
dt-bindings: arm: sunxi: add PocketBook Verse
ARM: dts: allwinner: add B288 and the PocketBook Verse

 .../devicetree/bindings/arm/sunxi.yaml        |   5 +
 .../clock/allwinner,sun4i-a10-ccu.yaml        |   1 +
 .../bindings/i2c/marvell,mv64xxx-i2c.yaml     |   1 +
 .../allwinner,sun7i-a20-sc-nmi.yaml           |   1 +
 .../pinctrl/allwinner,sun4i-a10-pinctrl.yaml  |  22 +
 .../bindings/rtc/allwinner,sun6i-a31-rtc.yaml |   3 +
 .../watchdog/allwinner,sun4i-a10-wdt.yaml     |   1 +
 arch/arm/boot/dts/allwinner/Makefile          |   1 +
 .../allwinner/sun8i-b288-pocketbook-verse.dts | 114 ++++
 arch/arm/boot/dts/allwinner/sun8i-b288.dtsi   | 290 ++++++++
 drivers/clk/sunxi-ng/Kconfig                  |   5 +
 drivers/clk/sunxi-ng/Makefile                 |   1 +
 drivers/clk/sunxi-ng/ccu-sun8i-b288.c         | 644 ++++++++++++++++++
 drivers/clk/sunxi-ng/ccu-sun8i-b288.h         |  10 +
 drivers/pinctrl/sunxi/Kconfig                 |  10 +
 drivers/pinctrl/sunxi/Makefile                |   1 +
 drivers/pinctrl/sunxi/pinctrl-sun8i-b288.c    |  49 ++
 drivers/rtc/rtc-sun6i.c                       |   1 +
 include/dt-bindings/clock/sun8i-b288-ccu.h    |  82 +++
 include/dt-bindings/reset/sun8i-b288-ccu.h    |  45 ++
 20 files changed, 1287 insertions(+)
 create mode 100644 arch/arm/boot/dts/allwinner/sun8i-b288-pocketbook-verse.dts
 create mode 100644 arch/arm/boot/dts/allwinner/sun8i-b288.dtsi
 create mode 100644 drivers/clk/sunxi-ng/ccu-sun8i-b288.c
 create mode 100644 drivers/clk/sunxi-ng/ccu-sun8i-b288.h
 create mode 100644 drivers/pinctrl/sunxi/pinctrl-sun8i-b288.c
 create mode 100644 include/dt-bindings/clock/sun8i-b288-ccu.h
 create mode 100644 include/dt-bindings/reset/sun8i-b288-ccu.h
Signature · 1 line
2.52.0
#1 lore raw

PATCH v3 1/11 dt-bindings: clock: sun4i-a10-ccu: add Allwinner B288

The B288 (sun8iw10p1) is a dual Cortex-A7 SoC used in e-book readers. Its CCU needs only the two oscillator inputs, so it fits the existing schema without changes.

---
 .../clock/allwinner,sun4i-a10-ccu.yaml        |  1 +
 include/dt-bindings/clock/sun8i-b288-ccu.h    | 82 +++++++++++++++++++
 include/dt-bindings/reset/sun8i-b288-ccu.h    | 45 ++++++++++
 3 files changed, 128 insertions(+)
 create mode 100644 include/dt-bindings/clock/sun8i-b288-ccu.h
 create mode 100644 include/dt-bindings/reset/sun8i-b288-ccu.h
Documentation/devicetree/bindings/clock/allwinner,sun4i-a10-ccu.yaml +1 -0
index 1690b9d99c3d..cc3f62d3554c 100644
@@ -28,6 +28,7 @@ properties:
       - allwinner,sun8i-a33-ccu
       - allwinner,sun8i-a83t-ccu
       - allwinner,sun8i-a83t-r-ccu
+      - allwinner,sun8i-b288-ccu
       - allwinner,sun8i-h3-ccu
       - allwinner,sun8i-h3-r-ccu
       - allwinner,sun8i-r40-ccu
include/dt-bindings/clock/sun8i-b288-ccu.h new file +82 -0

82 lines not on this page · raw message

include/dt-bindings/reset/sun8i-b288-ccu.h new file +45 -0

45 lines not on this page · raw message

Signature · 1 line
2.52.0
#2 lore raw

PATCH v3 2/11 clk: sunxi-ng: add Allwinner B288 CCU driver

In reply to Pablo Mazzini

Covers the PLLs, the CPU/AHB/APB tree, the module clocks and the bus gates and resets.

---
 drivers/clk/sunxi-ng/Kconfig          |   5 +
 drivers/clk/sunxi-ng/Makefile         |   1 +
 drivers/clk/sunxi-ng/ccu-sun8i-b288.c | 644 ++++++++++++++++++++++++++
 drivers/clk/sunxi-ng/ccu-sun8i-b288.h |  10 +
 4 files changed, 660 insertions(+)
 create mode 100644 drivers/clk/sunxi-ng/ccu-sun8i-b288.c
 create mode 100644 drivers/clk/sunxi-ng/ccu-sun8i-b288.h
drivers/clk/sunxi-ng/Kconfig +5 -0
index 6af2d020e03e..5bdfb8574794 100644
@@ -88,6 +88,11 @@ config SUN6I_RTC_CCU
 	default ARCH_SUNXI
 	depends on MACH_SUN8I || ARM64 || RISCV || COMPILE_TEST
 
+config SUN8I_B288_CCU
+	tristate "Support for the Allwinner B288 CCU"
+	default ARCH_SUNXI
+	depends on MACH_SUN8I || COMPILE_TEST
+
 config SUN8I_A23_CCU
 	tristate "Support for the Allwinner A23 CCU"
 	default ARCH_SUNXI
drivers/clk/sunxi-ng/Makefile +1 -0
index a1c4087d7241..dcc377a09ccc 100644
@@ -40,6 +40,7 @@ obj-$(CONFIG_SUN4I_A10_CCU)	+= sun4i-a10-ccu.o
 obj-$(CONFIG_SUN5I_CCU)		+= sun5i-ccu.o
 obj-$(CONFIG_SUN6I_A31_CCU)	+= sun6i-a31-ccu.o
 obj-$(CONFIG_SUN6I_RTC_CCU)	+= sun6i-rtc-ccu.o
+obj-$(CONFIG_SUN8I_B288_CCU)	+= ccu-sun8i-b288.o
 obj-$(CONFIG_SUN8I_A23_CCU)	+= sun8i-a23-ccu.o
 obj-$(CONFIG_SUN8I_A33_CCU)	+= sun8i-a33-ccu.o
 obj-$(CONFIG_SUN8I_A83T_CCU)	+= sun8i-a83t-ccu.o
drivers/clk/sunxi-ng/ccu-sun8i-b288.c new file +644 -0

644 lines not on this page · raw message

drivers/clk/sunxi-ng/ccu-sun8i-b288.h new file +10 -0
new file mode 100644
index 000000000000..805df2d6d99c
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _CCU_SUN8I_B288_H_
+#define _CCU_SUN8I_B288_H_
+
+#include <dt-bindings/clock/sun8i-b288-ccu.h>
+#include <dt-bindings/reset/sun8i-b288-ccu.h>
+
+#define CLK_NUMBER		(CLK_MMC1_OUTPUT + 1)
+
+#endif /* _CCU_SUN8I_B288_H_ */
Signature · 1 line
2.52.0
#3 lore raw

PATCH v3 3/11 dt-bindings: pinctrl: sun4i-a10: add Allwinner B288

In reply to Pablo Mazzini

The B288 driver takes its mux values from the DT, so allwinner,pinmux becomes an allowed property here, required for this compatible only.

---
 .../pinctrl/allwinner,sun4i-a10-pinctrl.yaml  | 22 +++++++++++++++++++
 1 file changed, 22 insertions(+)
Documentation/devicetree/bindings/pinctrl/allwinner,sun4i-a10-pinctrl.yaml +22 -0
index 45b7a0b6c626..b1f093d218f5 100644
@@ -39,6 +39,7 @@ properties:
       - allwinner,sun8i-a33-pinctrl
       - allwinner,sun8i-a83t-pinctrl
       - allwinner,sun8i-a83t-r-pinctrl
+      - allwinner,sun8i-b288-pinctrl
       - allwinner,sun8i-h3-pinctrl
       - allwinner,sun8i-h3-r-pinctrl
       - allwinner,sun8i-r40-pinctrl
@@ -120,6 +121,15 @@ patternProperties:
         $ref: /schemas/types.yaml#/definitions/uint32
         enum: [10, 20, 30, 40]
 
+      allwinner,pinmux:
+        $ref: /schemas/types.yaml#/definitions/uint32-array
+        description:
+          Pinmux selector value, for each pin. Only used by SoCs whose
+          driver takes the mux values from the DT instead of an in-driver
+          table. Almost every time this value is the same for all pins, so
+          any array shorter than the number of pins will repeat the last
+          value, to allow just specifying a single cell, for all cells.
+
     required:
       - pins
       - function
@@ -144,6 +154,17 @@ allOf:
   # warnings.
 
   - $ref: pinctrl.yaml#
+
+  - if:
+      properties:
+        compatible:
+          const: allwinner,sun8i-b288-pinctrl
+
+    then:
+      patternProperties:
+        "^([rs]-)?(([a-z0-9]{3,}|[a-oq-z0-9][a-z0-9]*?)?-)+?(p[a-ilm][0-9]*?-)??pins?$":
+          required:
+            - allwinner,pinmux
   - if:
       not:
         properties:
@@ -222,6 +243,7 @@ allOf:
           enum:
             - allwinner,sun6i-a31-pinctrl
             - allwinner,sun6i-a31s-pinctrl
+            - allwinner,sun8i-b288-pinctrl
             - allwinner,sun50i-h6-pinctrl
 
     then:
Signature · 1 line
2.52.0
#9 lore raw

PATCH v3 4/11 pinctrl: sunxi: add Allwinner B288 pin controller driver

In reply to Pablo Mazzini

80 pins across ports B, C, D, F and G; the mux values come from the DT. Port C has no external interrupts. PH0 is BSP FPGA-only and omitted.

---
 drivers/pinctrl/sunxi/Kconfig              | 10 +++++
 drivers/pinctrl/sunxi/Makefile             |  1 +
 drivers/pinctrl/sunxi/pinctrl-sun8i-b288.c | 49 ++++++++++++++++++++++
 3 files changed, 60 insertions(+)
 create mode 100644 drivers/pinctrl/sunxi/pinctrl-sun8i-b288.c
drivers/pinctrl/sunxi/Kconfig +10 -0
index dc62eba96348..a08186133090 100644
@@ -56,6 +56,16 @@ config PINCTRL_SUN8I_A23_R
 	default MACH_SUN8I
 	select PINCTRL_SUNXI
 
+config PINCTRL_SUN8I_B288
+	bool "Support for the Allwinner B288 PIO"
+	default MACH_SUN8I
+	select PINCTRL_SUNXI
+	help
+	  Say Y here to enable pin controller and GPIO support for the
+	  Allwinner B288 (sun8iw10p1) SoC, as used in e-book readers such
+	  as the PocketBook Verse. This covers ports B, C, D, F and G,
+	  including the four banks of external interrupt capable pins.
+
 config PINCTRL_SUN8I_H3
 	bool "Support for the Allwinner H3 PIO"
 	default MACH_SUN8I
drivers/pinctrl/sunxi/Makefile +1 -0
index 951b3f1e4b4f..5129c0f19f3e 100644
@@ -18,6 +18,7 @@ obj-$(CONFIG_PINCTRL_SUN50I_A100)	+= pinctrl-sun50i-a100.o
 obj-$(CONFIG_PINCTRL_SUN50I_A100_R)	+= pinctrl-sun50i-a100-r.o
 obj-$(CONFIG_PINCTRL_SUN8I_A83T)	+= pinctrl-sun8i-a83t.o
 obj-$(CONFIG_PINCTRL_SUN8I_A83T_R)	+= pinctrl-sun8i-a83t-r.o
+obj-$(CONFIG_PINCTRL_SUN8I_B288)	+= pinctrl-sun8i-b288.o
 obj-$(CONFIG_PINCTRL_SUN8I_H3)		+= pinctrl-sun8i-h3.o
 obj-$(CONFIG_PINCTRL_SUN8I_H3_R)	+= pinctrl-sun8i-h3-r.o
 obj-$(CONFIG_PINCTRL_SUN8I_V3S)		+= pinctrl-sun8i-v3s.o
drivers/pinctrl/sunxi/pinctrl-sun8i-b288.c new file +49 -0

49 lines not on this page · raw message

Signature · 1 line
2.52.0
#14 lore raw

PATCH v3 6/11 rtc: sun6i: add Allwinner B288 compatible

In reply to Pablo Mazzini

The driver only uses one alarm interrupt, so no functional change.

---
 drivers/rtc/rtc-sun6i.c | 1 +
 1 file changed, 1 insertion(+)
drivers/rtc/rtc-sun6i.c +1 -0
index 7fc60880e409..cd6ac5bb20cd 100644
@@ -859,6 +859,7 @@ static int sun6i_rtc_probe(struct platform_device *pdev)
 static const struct of_device_id sun6i_rtc_dt_ids[] = {
 	{ .compatible = "allwinner,sun6i-a31-rtc" },
 	{ .compatible = "allwinner,sun8i-a23-rtc" },
+	{ .compatible = "allwinner,sun8i-b288-rtc" },
 	{ .compatible = "allwinner,sun8i-h3-rtc" },
 	{ .compatible = "allwinner,sun8i-r40-rtc" },
 	{ .compatible = "allwinner,sun8i-v3-rtc" },
Signature · 1 line
2.52.0
#11 lore raw

PATCH v3 5/11 dt-bindings: rtc: sun6i-a31: add Allwinner B288

In reply to Pablo Mazzini

The B288 RTC wires one alarm interrupt, not two.

---
 .../devicetree/bindings/rtc/allwinner,sun6i-a31-rtc.yaml       | 3 +++
 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/rtc/allwinner,sun6i-a31-rtc.yaml +3 -0
index f2b91186ed37..ebe35f893f8c 100644
@@ -19,6 +19,7 @@ properties:
       - enum:
           - allwinner,sun6i-a31-rtc
           - allwinner,sun8i-a23-rtc
+          - allwinner,sun8i-b288-rtc
           - allwinner,sun8i-h3-rtc
           - allwinner,sun8i-r40-rtc
           - allwinner,sun8i-v3-rtc
@@ -82,6 +83,7 @@ allOf:
           contains:
             enum:
               - allwinner,sun8i-a23-rtc
+              - allwinner,sun8i-b288-rtc
               - allwinner,sun8i-r40-rtc
               - allwinner,sun8i-v3-rtc
 
@@ -162,6 +164,7 @@ allOf:
         compatible:
           contains:
             enum:
+              - allwinner,sun8i-b288-rtc
               - allwinner,sun8i-r40-rtc
               - allwinner,sun50i-h616-rtc
               - allwinner,sun50i-r329-rtc
Signature · 1 line
2.52.0
#16 lore raw

PATCH v3 7/11 dt-bindings: i2c: mv64xxx: add Allwinner B288

In reply to Pablo Mazzini

The B288 controller follows the existing Allwinner variant.

---
 Documentation/devicetree/bindings/i2c/marvell,mv64xxx-i2c.yaml | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/i2c/marvell,mv64xxx-i2c.yaml +1 -0
index c4efcef59133..d3b6f7668621 100644
@@ -21,6 +21,7 @@ properties:
           - enum:
               - allwinner,suniv-f1c100s-i2c
               - allwinner,sun8i-a23-i2c
+              - allwinner,sun8i-b288-i2c
               - allwinner,sun8i-a83t-i2c
               - allwinner,sun8i-v536-i2c
               - allwinner,sun50i-a64-i2c
Signature · 1 line
2.52.0
#17 lore raw

PATCH v3 8/11 dt-bindings: interrupt-controller: add Allwinner B288 NMI

In reply to Pablo Mazzini

Same register layout as the sun9i-a80 NMI, like the V3s.

---
 .../interrupt-controller/allwinner,sun7i-a20-sc-nmi.yaml         | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/interrupt-controller/allwinner,sun7i-a20-sc-nmi.yaml +1 -0
index bb9273ec2457..179e7842bf46 100644
@@ -29,6 +29,7 @@ properties:
       - const: allwinner,sun55i-a523-nmi
       - items:
           - enum:
+              - allwinner,sun8i-b288-nmi
               - allwinner,sun8i-v3s-nmi
               - allwinner,sun50i-a100-nmi
               - allwinner,sun50i-h616-nmi
Signature · 1 line
2.52.0
#18 lore raw

PATCH v3 9/11 dt-bindings: watchdog: sun4i-a10-wdt: add Allwinner B288

In reply to Pablo Mazzini

Same watchdog as the A31, which it falls back to.

---
 .../devicetree/bindings/watchdog/allwinner,sun4i-a10-wdt.yaml    | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/watchdog/allwinner,sun4i-a10-wdt.yaml +1 -0
index b35ac03d5172..b70a6b45a33d 100644
@@ -20,6 +20,7 @@ properties:
       - const: allwinner,sun6i-a31-wdt
       - items:
           - enum:
+              - allwinner,sun8i-b288-wdt
               - allwinner,sun50i-a64-wdt
               - allwinner,sun50i-a100-wdt
               - allwinner,sun50i-h6-wdt
Signature · 1 line
2.52.0
#21 lore raw

PATCH v3 10/11 dt-bindings: arm: sunxi: add PocketBook Verse

In reply to Pablo Mazzini

A 6" e-book reader built around the Allwinner B288.

---
 Documentation/devicetree/bindings/arm/sunxi.yaml | 5 +++++
 1 file changed, 5 insertions(+)
Documentation/devicetree/bindings/arm/sunxi.yaml +5 -0
index 28437c47ac01..fa34786f0652 100644
@@ -811,6 +811,11 @@ properties:
           - const: pocketbook,614-plus
           - const: allwinner,sun5i-a13
 
+      - description: PocketBook Verse (PB629)
+        items:
+          - const: pocketbook,verse
+          - const: allwinner,sun8i-b288
+
       - description: Point of View Protab2-IPS9
         items:
           - const: pov,protab2-ips9
Signature · 1 line
2.52.0
#22 lore raw

PATCH v3 11/11 ARM: dts: allwinner: add B288 and the PocketBook Verse

In reply to Pablo Mazzini

Add the B288 SoC .dtsi and the PocketBook Verse (PB629) board.

---
 arch/arm/boot/dts/allwinner/Makefile          |   1 +
 .../allwinner/sun8i-b288-pocketbook-verse.dts | 114 +++++++
 arch/arm/boot/dts/allwinner/sun8i-b288.dtsi   | 290 ++++++++++++++++++
 3 files changed, 405 insertions(+)
 create mode 100644 arch/arm/boot/dts/allwinner/sun8i-b288-pocketbook-verse.dts
 create mode 100644 arch/arm/boot/dts/allwinner/sun8i-b288.dtsi
arch/arm/boot/dts/allwinner/Makefile +1 -0
index 75b2b6a2f7a6..2dfdc01e4825 100644
@@ -227,6 +227,7 @@ dtb-$(CONFIG_MACH_SUN8I) += \
 	sun8i-a83t-bananapi-m3.dtb \
 	sun8i-a83t-cubietruck-plus.dtb \
 	sun8i-a83t-tbs-a711.dtb \
+	sun8i-b288-pocketbook-verse.dtb \
 	sun8i-h2-plus-bananapi-m2-zero.dtb \
 	sun8i-h2-plus-libretech-all-h3-cc.dtb \
 	sun8i-h2-plus-orangepi-r1.dtb \
arch/arm/boot/dts/allwinner/sun8i-b288-pocketbook-verse.dts new file +114 -0

114 lines not on this page · raw message

arch/arm/boot/dts/allwinner/sun8i-b288.dtsi new file +290 -0

290 lines not on this page · raw message

Signature · 1 line
2.52.0
#12 lore raw

Re: [PATCH v3 05/11] dt-bindings: rtc: sun6i-a31: add Allwinner B288

In reply to Pablo Mazzini
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 3 lines

The B288 RTC wires one alarm interrupt, not two.

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
#15 lore raw

Re: [PATCH v3 06/11] rtc: sun6i: add Allwinner B288 compatible

In reply to Pablo Mazzini
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] rtc: sun6i: missing clock provider initialization for b288 --

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] rtc: sun6i: missing clock provider initialization for b288
--

commit e9a7236a84b632280651176f5049d0cbdc7cb29a
Author: Pablo Mazzini <[email protected]>

rtc: sun6i: add Allwinner B288 compatible

This commit adds the "allwinner,sun8i-b288-rtc" compatible string to the sun6i RTC driver's device tree match table. This enables the driver to probe on the Allwinner B288 platform.

drivers/rtc/rtc-sun6i.c static int sun6i_rtc_probe(struct platform_device *pdev) · line 862

Quoted 9 lines
drivers/rtc/rtc-sun6i.c +1 -0
index 7fc60880e4094..cd6ac5bb20cdc 100644
@@ -859,6 +859,7 @@ static int sun6i_rtc_probe(struct platform_device *pdev)
 static const struct of_device_id sun6i_rtc_dt_ids[] = {
 	{ .compatible = "allwinner,sun6i-a31-rtc" },
 	{ .compatible = "allwinner,sun8i-a23-rtc" },
+	{ .compatible = "allwinner,sun8i-b288-rtc" },

[Severity: Medium]
Does this compatible string also need a corresponding CLK_OF_DECLARE_DRIVER() declaration to initialize the early clocks?

Without the declaration, the RTC driver fails to register as a clock provider, rendering its clocks unavailable to the Common Clock Framework even though the device tree binding specifies #clock-cells = <1> and clock-output-names.

While the current in-tree sun8i-b288.dtsi added later in the series relies on a root fixed-clock for osc32k and does not consume the RTC clocks directly, any future board or peripheral attempting to legitimately consume them will fail to resolve the clocks and hang with -EPROBE_DEFER.

Quoted 3 lines
drivers/rtc/rtc-sun6i.c +0 -0
 	{ .compatible = "allwinner,sun8i-h3-rtc" },
 	{ .compatible = "allwinner,sun8i-r40-rtc" },
 	{ .compatible = "allwinner,sun8i-v3-rtc" },
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6
#10 lore raw

Re: [PATCH v3 04/11] pinctrl: sunxi: add Allwinner B288 pin controller driver

In reply to Pablo Mazzini
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] pinctrl: sunxi: NULL ptr deref on probe deferral due to npins accumulation --

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] pinctrl: sunxi: NULL ptr deref on probe deferral due to npins accumulation --

commit 23f0ad979270766cafcf25e2ddff2cd81bb51adc
Author: Pablo Mazzini <[email protected]>

pinctrl: sunxi: add Allwinner B288 pin controller driver

This commit introduces pin controller and GPIO support for the Allwinner B288 SoC. It covers configuration for 80 pins across ports B, C, D, F, and G, including external interrupts.

Quoted 5 lines
drivers/pinctrl/sunxi/pinctrl-sun8i-b288.c new file +0 -0
new file mode 100644
index 0000000000000..f973c2b3f2eba

[ ... ]

drivers/pinctrl/sunxi/pinctrl-sun8i-b288.c line 35

Quoted 10 lines
drivers/pinctrl/sunxi/pinctrl-sun8i-b288.c new file +10 -0
+static struct sunxi_pinctrl_desc b288_pinctrl_data = {
+	.irq_banks	= 4,
+};
+
+static int b288_pinctrl_probe(struct platform_device *pdev)
+{
+	return sunxi_pinctrl_dt_table_init(pdev, b288_nr_bank_pins,
+					   b288_irq_bank_muxes,
+					   &b288_pinctrl_data, 0);
+}

[Severity: High]
If b288_pinctrl_probe() fails and defers, will b288_pinctrl_data.npins accumulate indefinitely and cause a NULL pointer dereference?

Since b288_pinctrl_data is defined as a static global variable, its state persists across multiple probe attempts. Looking at sunxi_pinctrl_dt_table_init(), it forwards this struct to init_pins_table() which modifies desc->npins:

init_pins_table() {
        ...
        desc->npins += pins_per_bank[i];
        ...
}

If the probe fails and defers, or if the driver is unbound and rebound, desc->npins is not reset to 0, so its value will double on the next probe attempt.

This leads to the pins array being allocated for the doubled size, but only the first 80 elements are actually initialized. The rest are zeroed out by the allocation. Later, in prepare_function_table(), a loop iterates over the doubled npins value and calls strcmp(pins[i].pin.name, name). For indexes beyond the actual number of pins, pins[i].pin.name is NULL, which triggers a crash.

Should npins be cleared to 0 before initialization, or should the static struct be treated as read-only and copied to a local device structure?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
maintainer
#4 lore raw

Re: [PATCH v3 03/11] dt-bindings: pinctrl: sun4i-a10: add Allwinner B288

In reply to Pablo Mazzini
Quoted 22 lines · Pablo Mazzini

The B288 driver takes its mux values from the DT, so allwinner,pinmux becomes an allowed property here, required for this compatible only.

---
 .../pinctrl/allwinner,sun4i-a10-pinctrl.yaml  | 22 +++++++++++++++++++
 1 file changed, 22 insertions(+)
Documentation/devicetree/bindings/pinctrl/allwinner,sun4i-a10-pinctrl.yaml +1 -0
index 45b7a0b6c626..b1f093d218f5 100644
@@ -39,6 +39,7 @@ properties:
       - allwinner,sun8i-a33-pinctrl
       - allwinner,sun8i-a83t-pinctrl
       - allwinner,sun8i-a83t-r-pinctrl
+      - allwinner,sun8i-b288-pinctrl
       - allwinner,sun8i-h3-pinctrl
       - allwinner,sun8i-h3-r-pinctrl
       - allwinner,sun8i-r40-pinctrl
@@ -120,6 +121,15 @@ patternProperties:
         $ref: /schemas/types.yaml#/definitions/uint32

Documentation/devicetree/bindings/pinctrl/allwinner,sun4i-a10-pinctrl.yaml patternProperties: · line 131

Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/allwinner,sun4i-a10-pinctrl.yaml +8 -0
         enum: [10, 20, 30, 40]
 
+      allwinner,pinmux:
+        $ref: /schemas/types.yaml#/definitions/uint32-array
+        description:
+          Pinmux selector value, for each pin. Only used by SoCs whose
+          driver takes the mux values from the DT instead of an in-driver
+          table. Almost every time this value is the same for all pins, so
+          any array shorter than the number of pins will repeat the last
+          value, to allow just specifying a single cell, for all cells.

Perhaps new platforms should move to the common 'pinmux' property?

Rob

#5 lore raw

Re: [PATCH v3 03/11] dt-bindings: pinctrl: sun4i-a10: add Allwinner B288

In reply to Rob Herring

Hi Rob,

The B288 uses the same scheme as the A523, and the A733 queued for 7.4, which the shared pinctrl-sunxi-dt helper parses, so I'd rather stay consistent with them.
Andre, what do you think?

Thanks,
Pablo

Quoted 38 lines · Rob Herring
Quoted 22 lines · Pablo Mazzini

The B288 driver takes its mux values from the DT, so allwinner,pinmux becomes an allowed property here, required for this compatible only.

---
 .../pinctrl/allwinner,sun4i-a10-pinctrl.yaml  | 22 +++++++++++++++++++
 1 file changed, 22 insertions(+)
Documentation/devicetree/bindings/pinctrl/allwinner,sun4i-a10-pinctrl.yaml +1 -0
index 45b7a0b6c626..b1f093d218f5 100644
@@ -39,6 +39,7 @@ properties:
       - allwinner,sun8i-a33-pinctrl
       - allwinner,sun8i-a83t-pinctrl
       - allwinner,sun8i-a83t-r-pinctrl
+      - allwinner,sun8i-b288-pinctrl
       - allwinner,sun8i-h3-pinctrl
       - allwinner,sun8i-h3-r-pinctrl
       - allwinner,sun8i-r40-pinctrl
@@ -120,6 +121,15 @@ patternProperties:
         $ref: /schemas/types.yaml#/definitions/uint32

Documentation/devicetree/bindings/pinctrl/allwinner,sun4i-a10-pinctrl.yaml patternProperties: · line 131

Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/allwinner,sun4i-a10-pinctrl.yaml +8 -0
         enum: [10, 20, 30, 40]
 
+      allwinner,pinmux:
+        $ref: /schemas/types.yaml#/definitions/uint32-array
+        description:
+          Pinmux selector value, for each pin. Only used by SoCs whose
+          driver takes the mux values from the DT instead of an in-driver
+          table. Almost every time this value is the same for all pins, so
+          any array shorter than the number of pins will repeat the last
+          value, to allow just specifying a single cell, for all cells.

Perhaps new platforms should move to the common 'pinmux' property?

Rob

#6 lore raw

Re: [PATCH v3 03/11] dt-bindings: pinctrl: sun4i-a10: add Allwinner B288

In reply to Rob Herring

Hi,

Quoted 25 lines · Rob Herring
Quoted 24 lines · Pablo Mazzini

The B288 driver takes its mux values from the DT, so allwinner,pinmux becomes an allowed property here, required for this compatible only.

---
  .../pinctrl/allwinner,sun4i-a10-pinctrl.yaml  | 22 +++++++++++++++++++
  1 file changed, 22 insertions(+)
Documentation/devicetree/bindings/pinctrl/allwinner,sun4i-a10-pinctrl.yaml +1 -0
index 45b7a0b6c626..b1f093d218f5 100644
@@ -39,6 +39,7 @@ properties:
        - allwinner,sun8i-a33-pinctrl
        - allwinner,sun8i-a83t-pinctrl
        - allwinner,sun8i-a83t-r-pinctrl
+      - allwinner,sun8i-b288-pinctrl
        - allwinner,sun8i-h3-pinctrl
        - allwinner,sun8i-h3-r-pinctrl
        - allwinner,sun8i-r40-pinctrl
@@ -120,6 +121,15 @@ patternProperties:
          $ref: /schemas/types.yaml#/definitions/uint32
          enum: [10, 20, 30, 40]
 
Quoted 10 lines

Documentation/devicetree/bindings/pinctrl/allwinner,sun4i-a10-pinctrl.yaml patternProperties: · line 131

Quoted 8 lines
Documentation/devicetree/bindings/pinctrl/allwinner,sun4i-a10-pinctrl.yaml +8 -0
+      allwinner,pinmux:
+        $ref: /schemas/types.yaml#/definitions/uint32-array
+        description:
+          Pinmux selector value, for each pin. Only used by SoCs whose
+          driver takes the mux values from the DT instead of an in-driver
+          table. Almost every time this value is the same for all pins, so
+          any array shorter than the number of pins will repeat the last
+          value, to allow just specifying a single cell, for all cells.

Perhaps new platforms should move to the common 'pinmux' property?

If you mean to just drop the allwinner prefix: this has been discussed, but NAKed, because the generic property carries a different semantic. And implementing that generic behaviour in the existing sunxi pinctrl driver would be quite some effort (read: a rewrite), without any obvious win, so we decided back then to not boil the ocean here, and just go with a special property.

Cheers,
Andre

maintainer
#7 lore raw

Re: [PATCH v3 03/11] dt-bindings: pinctrl: sun4i-a10: add Allwinner B288

Quoted 6 lines · Andre Przywara

If you mean to just drop the allwinner prefix: this has been discussed, but NAKed, because the generic property carries a different semantic. And implementing that generic behaviour in the existing sunxi pinctrl driver would be quite some effort (read: a rewrite), without any obvious win, so we decided back then to not boil the ocean here, and just go with a special property.

The point to switch over to the generic "pinmux" property would be when a completely new SoC series with new hardware arrives, so that it is significantly different from earlier iterations.

I don't know which semantic with the standard "pinmux" property you got hung up on though remind me?

The bindings just state this:

pinmux:
description:
The list of numeric pin ids and their mux settings that properties in the node apply to (either this, "pins" or "groups" have to be specified)
$ref: /schemas/types.yaml#/definitions/uint32-array

It's just an opaque u32 array controlling all muxing for a device. There could be one single element in the array.

Yours,
Linus Walleij

#8 lore raw

Re: [PATCH v3 03/11] dt-bindings: pinctrl: sun4i-a10: add Allwinner B288

Hi Linus,

Quoted 13 lines · Linus Walleij
Quoted 6 lines · Andre Przywara

If you mean to just drop the allwinner prefix: this has been discussed, but NAKed, because the generic property carries a different semantic. And implementing that generic behaviour in the existing sunxi pinctrl driver would be quite some effort (read: a rewrite), without any obvious win, so we decided back then to not boil the ocean here, and just go with a special property.

The point to switch over to the generic "pinmux" property would be when a completely new SoC series with new hardware arrives, so that it is significantly different from earlier iterations.

Quoted 8 lines

I don't know which semantic with the standard "pinmux" property you got hung up on though remind me?

The bindings just state this:

pinmux:
description:
The list of numeric pin ids and their mux settings that properties in the

                     ^^^^^^^^^^^^^^^^^^^

it combines the pin number *and* its pinmux. For allwinner,pinmux we just carry the pinmux bits. The generic binding makes a lot of sense, it's just not very appealing to the existing sunxi pinctrl driver.

Cheers,
Andre

Quoted 8 lines

node apply to (either this, "pins" or "groups" have to be specified)
$ref: /schemas/types.yaml#/definitions/uint32-array

It's just an opaque u32 array controlling all muxing for a device. There could be one single element in the array.

Yours,
Linus Walleij