ARM: sunxi: add Allwinner B288 and the PocketBook Verse
Subsystems (11)
v4 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 v3:
- CCU: reference parents with clk_parent_data and clk_hw pointers, as newer sunxi-ng drivers do; add the audio PLL's sigma-delta settings, as on the A64; fix the PLL_24M rate and parent the PLLs to it.
- RTC: register the 32 kHz clocks, reusing the A23 data (Sashiko).
- DTS: take osc32k from the RTC, as on the A64.
- DTS: allow the eMMC up to 150 MHz, as on the A523.
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 | 292 +++++++ drivers/clk/sunxi-ng/Kconfig | 5 + drivers/clk/sunxi-ng/Makefile | 1 + drivers/clk/sunxi-ng/ccu-sun8i-b288.c | 749 ++++++++++++++++++ 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 | 5 + include/dt-bindings/clock/sun8i-b288-ccu.h | 82 ++ include/dt-bindings/reset/sun8i-b288-ccu.h | 45 ++ 20 files changed, 1398 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
PATCH v4 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
@@ -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
PATCH v4 2/11 clk: sunxi-ng: add Allwinner B288 CCU driver
In reply to Pablo MazziniCovers 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 | 749 ++++++++++++++++++++++++++ drivers/clk/sunxi-ng/ccu-sun8i-b288.h | 10 + 4 files changed, 765 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
@@ -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
@@ -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 +749 -0
749 lines not on this page · raw message
drivers/clk/sunxi-ng/ccu-sun8i-b288.h new file +10 -0
@@ -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
PATCH v4 3/11 dt-bindings: pinctrl: sun4i-a10: add Allwinner B288
In reply to Pablo MazziniThe 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
@@ -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
PATCH v4 4/11 pinctrl: sunxi: add Allwinner B288 pin controller driver
In reply to Pablo Mazzini80 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
@@ -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
@@ -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
PATCH v4 5/11 dt-bindings: rtc: sun6i-a31: add Allwinner B288
In reply to Pablo MazziniThe 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
@@ -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
PATCH v4 6/11 rtc: sun6i: add Allwinner B288 compatible
In reply to Pablo MazziniThe 32 kHz clocks are the same as the A23's. Only one alarm interrupt is wired, which is all the driver uses.
--- drivers/rtc/rtc-sun6i.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/rtc/rtc-sun6i.c +5 -0
@@ -350,6 +350,10 @@ static void __init sun8i_a23_rtc_clk_init(struct device_node *node)CLK_OF_DECLARE_DRIVER (sun8i_a23_rtc_clk,"allwinner,sun8i-a23-rtc" , sun8i_a23_rtc_clk_init); +/* The B288 RTC clocks are the same as the A23's */ +CLK_OF_DECLARE_DRIVER (sun8i_b288_rtc_clk,"allwinner,sun8i-b288-rtc" , + sun8i_a23_rtc_clk_init); +static const struct sun6i_rtc_clk_data sun8i_h3_rtc_data = { .rc_osc_rate =16000000 , .fixed_prescaler =32 ,
@@ -859,6 +863,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
PATCH v4 7/11 dt-bindings: i2c: mv64xxx: add Allwinner B288
In reply to Pablo MazziniThe 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
@@ -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
PATCH v4 8/11 dt-bindings: interrupt-controller: add Allwinner B288 NMI
In reply to Pablo MazziniSame 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
@@ -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
PATCH v4 9/11 dt-bindings: watchdog: sun4i-a10-wdt: add Allwinner B288
In reply to Pablo MazziniSame 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
@@ -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
PATCH v4 10/11 dt-bindings: arm: sunxi: add PocketBook Verse
In reply to Pablo MazziniA 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
@@ -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
PATCH v4 11/11 ARM: dts: allwinner: add B288 and the PocketBook Verse
In reply to Pablo MazziniAdd 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 | 292 ++++++++++++++++++ 3 files changed, 407 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
@@ -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 +292 -0
292 lines not on this page · raw message
Signature · 1 line
2.52.0
[email protected]
AI reviewRe: [PATCH v4 05/11] dt-bindings: rtc: sun6i-a31: add Allwinner B288
In reply to Pablo MazziniSashiko has reviewed this patch and found no issues. It looks great!
Quoted 3 lines
The B288 RTC wires one alarm interrupt, not two.
Signed-off-by Pablo Mazzini <[email protected]>
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
[email protected]
AI reviewRe: [PATCH v4 06/11] rtc: sun6i: add Allwinner B288 compatible
In reply to Pablo MazziniThank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider: - [High] rtc: sun6i: missing ERR_PTR check causes crash in probe on clk_register failure - [Medium] rtc…
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] rtc: sun6i: missing ERR_PTR check causes crash in probe on clk_register failure
- [Medium] rtc: sun6i: resource leak of losc clock on initialization error path
- [Low] rtc: sun6i: memory leak of rtc structure in sun6i_rtc_clk_init error path --
commit 903d00f6b5cb6afede9ad6ad5fca01853d776ce4
Author: Pablo Mazzini <[email protected]>
Subject: rtc: sun6i: add Allwinner B288 compatible
This commit adds support for the Allwinner B288 RTC by reusing the A23 clock configuration. It maps the new compatible string allwinner,sun8i-b288-rtc to the existing initialization functions.
drivers/rtc/rtc-sun6i.c static void __init sun8i_a23_rtc_clk_init(struct device_node *node) · line 356
Quoted 12 lines
drivers/rtc/rtc-sun6i.c +4
-0@@ -350,6 +350,10 @@ static void __init sun8i_a23_rtc_clk_init(struct device_node *node)CLK_OF_DECLARE_DRIVER (sun8i_a23_rtc_clk,"allwinner,sun8i-a23-rtc" , sun8i_a23_rtc_clk_init); +/* The B288 RTC clocks are the same as the A23's */ +CLK_OF_DECLARE_DRIVER (sun8i_b288_rtc_clk,"allwinner,sun8i-b288-rtc" , + sun8i_a23_rtc_clk_init); +
[Severity: High]
Does adding this compatible string expose an issue in the error handling of sun6i_rtc_clk_init on registration failure?
If clk_register fails for rtc->losc, the function returns an error pointer and jumps to the err_register label. Since the global sun6i_rtc pointer is already assigned to the allocated rtc struct earlier:
sun6i_rtc_clk_init()
/* Yes, I know, this is ugly. */
sun6i_rtc = rtc;
...
rtc->losc = clk_register(NULL, &rtc->hw);
if (IS_ERR(rtc->losc)) {
pr_crit("Couldn't register the LOSC clock\n");
goto err_register;
}The probe function sun6i_rtc_probe later fetches this dangling pointer:
sun6i_rtc_probe()
struct sun6i_rtc_dev *chip = sun6i_rtc;
...
clk_prepare_enable(chip->losc);Can this lead to a kernel panic when clk_prepare_enable attempts to dereference the error pointer stored in chip->losc?
[Severity: Medium]
Additionally, if clk_register succeeds for rtc->losc but a later clock registration fails, triggering the jump to err_register, does this cleanup path leak the rtc->losc clock?
sun6i_rtc_clk_init()err_register:
clk_hw_unregister_fixed_rate(rtc->int_osc);
err:
kfree(clk_data);The err_register path unregisters rtc->int_osc but appears to omit calling clk_unregister(rtc->losc).
[Severity: Low]
Does the err cleanup path also leak the dynamically allocated rtc structure?
sun6i_rtc_clk_init()
rtc = kzalloc_obj(*rtc);
...
err:
kfree(clk_data);The error path frees clk_data but seems to omit freeing the allocated rtc structure.
[ ... ]
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6
[email protected]
AI reviewRe: [PATCH v4 02/11] clk: sunxi-ng: add Allwinner B288 CCU driver
In reply to Pablo MazziniThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] clk: sunxi-ng: missing parent index table for tcon0_clk --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] clk: sunxi-ng: missing parent index table for tcon0_clk
--
commit 3f9c552550550b015864167770907fa314ac3239
Author: Pablo Mazzini <[email protected]>
clk: sunxi-ng: add Allwinner B288 CCU driver
This commit introduces the Allwinner B288 CCU driver, covering the PLLs, the CPU/AHB/APB tree, module clocks, bus gates, and resets. The driver is noted to be closely related to the A64 CCU.
Quoted 5 lines
drivers/clk/sunxi-ng/ccu-sun8i-b288.c new file +0
-0
[ ... ]
drivers/clk/sunxi-ng/ccu-sun8i-b288.c line 422
Quoted 13 lines
drivers/clk/sunxi-ng/ccu-sun8i-b288.c new file +13
-0+/* DE_CFG @ 0x104, EE_CFG @ 0x108, EDMA_CFG @ 0x10c -- M[3:0] mux[26:24] gate 31 */ +static SUNXI_CCU_M_DATA_WITH_MUX_GATE(de_clk, "de", de_parents, 0x104, + 0, 4, 24, 3, BIT(31), CLK_SET_RATE_PARENT); +static SUNXI_CCU_M_DATA_WITH_MUX_GATE(ee_clk, "ee", de_parents, 0x108, + 0, 4, 24, 3, BIT(31), CLK_SET_RATE_PARENT); +static SUNXI_CCU_M_DATA_WITH_MUX_GATE(edma_clk, "edma", de_parents, 0x10c, + 0, 4, 24, 3, BIT(31), CLK_SET_RATE_PARENT); + +/* TCON_CFG @ 0x118 -- mux[26:24] gate 31, no divider */ +static SUNXI_CCU_MUX_DATA_WITH_GATE(tcon0_clk, "tcon0", tcon0_parents, 0x118, +24 ,3 ,/* mux */ +BIT (31 ),/* gate */ + CLK_SET_RATE_PARENT);
[Severity: Medium]
Does the B288 hardware actually use a 1:1 index mapping (0 and 1) for this TCON mux?
The closely related A64 SoC uses a {0, 2} index mapping for its TCON PLLs. Because SUNXI_CCU_MUX_DATA_WITH_GATE defaults to a 1:1 mapping, if a display driver requests to use pll_video1 for the TCON, the CCU driver will write index 1 to the mux register. If the hardware maps the second parent to index 2 instead of 1, this will result in incorrect clock parent selection and could break video output.
If a custom mapping is needed, it might be slightly tricky to define since the ccu_mux.h framework currently lacks a SUNXI_CCU_MUX_DATA_TABLE_WITH_GATE macro to combine a table with clk_parent_data.
Quoted 4 lines
drivers/clk/sunxi-ng/ccu-sun8i-b288.c new file +4
-0+ +/* MBUS_CFG @ 0x15c -- M[2:0] mux[25:24] gate 31 */ +static SUNXI_CCU_M_DATA_WITH_MUX_GATE(mbus_clk, "mbus", mbus_parents, 0x15c, + 0, 3, 24, 2, BIT(31), CLK_IS_CRITICAL);
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
[email protected]
AI reviewRe: [PATCH v4 04/11] pinctrl: sunxi: add Allwinner B288 pin controller driver
In reply to Pablo MazziniThank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider: - [High] pinctrl: sunxi: out-of-bounds write in irq_array when Bank 0 has 0 pins - [High] pinctrl: sunxi…
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] pinctrl: sunxi: out-of-bounds write in irq_array when Bank 0 has 0 pins
- [High] pinctrl: sunxi: Missing irq_bank_map breaks B288 IRQ offsets and domain size
- [High] pinctrl: sunxi: probe deferral crash due to npins accumulation
--
commit 6057aa70ee139132fe0176fd6bf4d482c87bdc64
Author: Pablo Mazzini <[email protected]>
pinctrl: sunxi: add Allwinner B288 pin controller driver
This commit adds a new pin controller driver for the Allwinner B288 SoC, supporting 80 pins across ports B, C, D, F, and G. It uses DT-provided mux values and specifies 4 banks of external interrupts.
Quoted 6 lines
drivers/pinctrl/sunxi/pinctrl-sun8i-b288.c new file +0
-0@@ -0,0 +1,49 @@
[ ... ]
drivers/pinctrl/sunxi/pinctrl-sun8i-b288.c line 20
Quoted 4 lines
drivers/pinctrl/sunxi/pinctrl-sun8i-b288.c new file +4
-0+/* PH0 exists only on the BSP's FPGA platform and is omitted. */ +static const u8 b288_nr_bank_pins[SUNXI_PINCTRL_MAX_BANKS ] = +/* PA PB PC PD PE PF PG */ + {0 ,17 ,15 ,29 ,0 ,7 ,12 };
[Severity: High]
Since Bank 0 (PA) has 0 pins, does this cause an out-of-bounds write in the core sunxi pinctrl driver?
In drivers/pinctrl/sunxi/pinctrl-sunxi-dt.c:prepare_function_table(), last_bank and irq_bank are initialized to 0. When processing PB (bank 1), the condition (bank > last_bank) evaluates to true (1 > 0), causing irq_bank to erroneously increment to 1.
This shifts the logical IRQ bank indices for PB, PD, PF, and PG to 1, 2, 3, and 4 instead of 0, 1, 2, and 3.
Later, sunxi_pinctrl_build_state() configures the interrupts:
int irqnum = func->irqnum + func->irqbank * IRQ_PER_BANK;
pctl->irq_array[irqnum] = pin->pin.number;For PG (irqbank 4), irqnum will be between 128 and 139. However, irq_array is allocated for exactly 4 banks (128 elements) in sunxi_pinctrl_init_with_flags(), which would result in an out-of-bounds write past the end of the array.
drivers/pinctrl/sunxi/pinctrl-sun8i-b288.c line 28
Quoted 8 lines
drivers/pinctrl/sunxi/pinctrl-sun8i-b288.c new file +8
-0+ +static const u8 b288_irq_bank_muxes[SUNXI_PINCTRL_MAX_BANKS ] = +/* PA PB PC PD PE PF PG */ + {0 ,6 ,0 ,6 ,0 ,6 ,6 }; + +static struct sunxi_pinctrl_desc b288_pinctrl_data = { + .irq_banks =4 , +};
[Severity: High]
Does omitting the irq_bank_map array break external interrupts?
Without an irq_bank_map, drivers/pinctrl/sunxi/pinctrl-sunxi.h:sunxi_irq_hw_bank_num() returns the sequential logical irqbank indices.
Because the irq_bank offset is already shifted to 1, 2, 3, and 4, these logical indices will be used as physical hardware bank offsets.
This incorrectly maps PD, PF, and PG to hardware banks 2, 3, and 4 instead of their actual hardware indices 3, 5, and 6.
Additionally, because PG receives irqbank 4, its out_hwirq is calculated as 4 * 32 + irqnum (>= 128), which exceeds the bounds of the 128-entry IRQ domain created during probe.
drivers/pinctrl/sunxi/pinctrl-sun8i-b288.c line 35
Quoted 7 lines
drivers/pinctrl/sunxi/pinctrl-sun8i-b288.c new file +7
-0+ +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]
Could this lead to a kernel panic during a probe deferral?
The driver passes the static b288_pinctrl_data descriptor to sunxi_pinctrl_dt_table_init(), which calls init_pins_table() and accumulates the total pin count:
desc->npins += pins_per_bank[i];
If the driver probe defers, desc->npins will double on the next attempt (from 80 to 160) because the static descriptor is reused.
The pins array is then allocated for 160 elements, but only the first 80 will have their .pin.name populated.
During DT parsing in fill_pin_function(), if an unrecognized pin name is encountered, the search loops over the oversized array and evaluates:
if (!strcmp(pins[pin].pin.name, name))
break;Iterating past index 79 would call strcmp() with a NULL pointer for .pin.name, causing a panic.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
Re: [PATCH v4 02/11] clk: sunxi-ng: add Allwinner B288 CCU driver
In reply to [email protected]The B288 has pll-video0 and pll-video1 at TCON0 mux values 0 and 1, so the plain mapping is right.
BSP: https://github.com/pocketbook/kernel-b288/blob/e30bb2ed149410ef2d3245ea01192833d44c4e46/drivers/clk/sunxi/clk-sun8iw10.c#L468
Wiki: https://linux-sunxi.org/B288/Clocks
Quoted 58 lines · On Mon, Oct 12, 2026 at 11:21 AM <[email protected]> wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] clk: sunxi-ng: missing parent index table fortcon0_clk
--commit
3f9c552550550b015864167770907fa314ac3239
Author: Pablo Mazzini <[email protected]>clk: sunxi-ng: add Allwinner B288 CCU driver
This commit introduces the Allwinner B288 CCU driver, covering the PLLs, the CPU/AHB/APB tree, module clocks, bus gates, and resets. The driver is noted to be closely related to the A64 CCU.
Quoted 5 lines
drivers/clk/sunxi-ng/ccu-sun8i-b288.c new file +0
-0[ ... ]
drivers/clk/sunxi-ng/ccu-sun8i-b288.c line 422
Quoted 13 lines
drivers/clk/sunxi-ng/ccu-sun8i-b288.c new file +13
-0+/* DE_CFG @ 0x104, EE_CFG @ 0x108, EDMA_CFG @ 0x10c -- M[3:0] mux[26:24] gate 31 */ +static SUNXI_CCU_M_DATA_WITH_MUX_GATE(de_clk, "de", de_parents, 0x104, + 0, 4, 24, 3, BIT(31), CLK_SET_RATE_PARENT); +static SUNXI_CCU_M_DATA_WITH_MUX_GATE(ee_clk, "ee", de_parents, 0x108, + 0, 4, 24, 3, BIT(31), CLK_SET_RATE_PARENT); +static SUNXI_CCU_M_DATA_WITH_MUX_GATE(edma_clk, "edma", de_parents, 0x10c, + 0, 4, 24, 3, BIT(31), CLK_SET_RATE_PARENT); + +/* TCON_CFG @ 0x118 -- mux[26:24] gate 31, no divider */ +static SUNXI_CCU_MUX_DATA_WITH_GATE(tcon0_clk, "tcon0", tcon0_parents, 0x118, +24 ,3 ,/* mux */ +BIT (31 ),/* gate */ + CLK_SET_RATE_PARENT);[Severity: Medium]
Does the B288 hardware actually use a 1:1 index mapping (0 and 1) for this TCON mux?The closely related A64 SoC uses a {0, 2} index mapping for its TCON PLLs. Because
SUNXI_CCU_MUX_DATA_WITH_GATEdefaults to a 1:1 mapping, if a display driver requests to usepll_video1for the TCON, the CCU driver will write index 1 to the mux register. If the hardware maps the second parent to index 2 instead of 1, this will result in incorrect clock parent selection and could break video output.If a custom mapping is needed, it might be slightly tricky to define since the
ccu_mux.hframework currently lacks aSUNXI_CCU_MUX_DATA_TABLE_WITH_GATEmacro to combine a table withclk_parent_data.drivers/clk/sunxi-ng/ccu-sun8i-b288.c line 426
Quoted 4 lines
drivers/clk/sunxi-ng/ccu-sun8i-b288.c new file +4
-0+ +/* MBUS_CFG @ 0x15c -- M[2:0] mux[25:24] gate 31 */ +static SUNXI_CCU_M_DATA_WITH_MUX_GATE(mbus_clk, "mbus", mbus_parents, 0x15c, + 0, 3, 24, 2, BIT(31), CLK_IS_CRITICAL);--
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Re: [PATCH v4 04/11] pinctrl: sunxi: add Allwinner B288 pin controller driver
In reply to [email protected]The first two come from the IRQ bank numbering in prepare_function_table(), which this patch depends on [1]. Andre plans to send a fix after -rc1 [2].
The third is fixed by "pinctrl: sunxi: dt: do not accumulate npins across probe attempts" [3], which Linus has applied.
[1] https://lore.kernel.org/linux-sunxi/[email protected]/
[2] https://lore.kernel.org/r/[email protected]
[3] https://lore.kernel.org/r/[email protected]
Quoted 109 lines · On Mon, Oct 12, 2026 at 11:29 AM <[email protected]> wrote:
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] pinctrl: sunxi: out-of-bounds write inirq_arraywhen Bank 0 has 0 pins
- [High] pinctrl: sunxi: Missingirq_bank_mapbreaks B288 IRQ offsets and domain size
- [High] pinctrl: sunxi: probe deferral crash due to npins accumulation
--commit
6057aa70ee139132fe0176fd6bf4d482c87bdc64
Author: Pablo Mazzini <[email protected]>pinctrl: sunxi: add Allwinner B288 pin controller driver
This commit adds a new pin controller driver for the Allwinner B288 SoC, supporting 80 pins across ports B, C, D, F, and G. It uses DT-provided mux values and specifies 4 banks of external interrupts.
Quoted 6 lines
drivers/pinctrl/sunxi/pinctrl-sun8i-b288.c new file +0
-0@@ -0,0 +1,49 @@[ ... ]
drivers/pinctrl/sunxi/pinctrl-sun8i-b288.c line 20
Quoted 4 lines
drivers/pinctrl/sunxi/pinctrl-sun8i-b288.c new file +4
-0+/* PH0 exists only on the BSP's FPGA platform and is omitted. */ +static const u8 b288_nr_bank_pins[SUNXI_PINCTRL_MAX_BANKS ] = +/* PA PB PC PD PE PF PG */ + {0 ,17 ,15 ,29 ,0 ,7 ,12 };[Severity: High]
Since Bank 0 (PA) has 0 pins, does this cause an out-of-bounds write in the core sunxi pinctrl driver?In drivers/pinctrl/sunxi/pinctrl-sunxi-dt.c:prepare_function_table(),
last_bankandirq_bankare initialized to 0. When processing PB (bank 1), the condition (bank >last_bank) evaluates to true (1 > 0), causingirq_bankto erroneously increment to 1.This shifts the logical IRQ bank indices for PB, PD, PF, and PG to 1, 2, 3, and 4 instead of 0, 1, 2, and 3.
Later,
sunxi_pinctrl_build_state()configures the interrupts:int irqnum = func->irqnum + func->irqbank * IRQ_PER_BANK; pctl->irq_array[irqnum] = pin->pin.number;For PG (irqbank 4), irqnum will be between 128 and 139. However,
irq_arrayis allocated for exactly 4 banks (128 elements) insunxi_pinctrl_init_with_flags(), which would result in an out-of-bounds write past the end of the array.drivers/pinctrl/sunxi/pinctrl-sun8i-b288.c line 28
Quoted 8 lines
drivers/pinctrl/sunxi/pinctrl-sun8i-b288.c new file +8
-0+ +static const u8 b288_irq_bank_muxes[SUNXI_PINCTRL_MAX_BANKS ] = +/* PA PB PC PD PE PF PG */ + {0 ,6 ,0 ,6 ,0 ,6 ,6 }; + +static struct sunxi_pinctrl_desc b288_pinctrl_data = { + .irq_banks =4 , +};[Severity: High]
Does omitting theirq_bank_maparray break external interrupts?Without an
irq_bank_map,drivers/pinctrl/sunxi/pinctrl-sunxi.h:sunxi_irq_hw_bank_num()returns the sequential logical irqbank indices.Because the
irq_bankoffset is already shifted to 1, 2, 3, and 4, these logical indices will be used as physical hardware bank offsets.This incorrectly maps PD, PF, and PG to hardware banks 2, 3, and 4 instead of their actual hardware indices 3, 5, and 6.
Additionally, because PG receives irqbank 4, its
out_hwirqis calculated as 4 * 32 + irqnum (>= 128), which exceeds the bounds of the 128-entry IRQ domain created during probe.drivers/pinctrl/sunxi/pinctrl-sun8i-b288.c line 35
Quoted 7 lines
drivers/pinctrl/sunxi/pinctrl-sun8i-b288.c new file +7
-0+ +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]
Could this lead to a kernel panic during a probe deferral?The driver passes the static
b288_pinctrl_datadescriptor tosunxi_pinctrl_dt_table_init(), which callsinit_pins_table()and accumulates the total pin count:desc->npins += pins_per_bank[i];If the driver probe defers,
desc->npinswill double on the next attempt (from 80 to 160) because the static descriptor is reused.The pins array is then allocated for 160 elements, but only the first 80 will have their .pin.name populated.
During DT parsing in
fill_pin_function(), if an unrecognized pin name is encountered, the search loops over the oversized array and evaluates:if (!strcmp(pins[pin].pin.name, name)) break;Iterating past index 79 would call
strcmp()with a NULL pointer for .pin.name, causing a panic.--
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
Re: [PATCH v4 06/11] rtc: sun6i: add Allwinner B288 compatible
In reply to [email protected]These are in sun6i_rtc_clk_init(), which this patch reuses unchanged for the B288, so they apply to all the SoCs using it. I can look into it separately.
Quoted 87 lines · On Mon, Oct 12, 2026 at 11:19 AM <[email protected]> wrote:
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] rtc: sun6i: missingERR_PTRcheck causes crash in probe onclk_registerfailure
- [Medium] rtc: sun6i: resource leak of losc clock on initialization error path
- [Low] rtc: sun6i: memory leak of rtc structure insun6i_rtc_clk_initerror path --commit
903d00f6b5cb6afede9ad6ad5fca01853d776ce4
Author: Pablo Mazzini <[email protected]>
Subject: rtc: sun6i: add Allwinner B288 compatibleThis commit adds support for the Allwinner B288 RTC by reusing the A23 clock configuration. It maps the new compatible string allwinner,sun8i-b288-rtc to the existing initialization functions.
drivers/rtc/rtc-sun6i.c static void __init sun8i_a23_rtc_clk_init(struct device_node *node) · line 356
Quoted 12 lines
drivers/rtc/rtc-sun6i.c +4
-0@@ -350,6 +350,10 @@ static void __init sun8i_a23_rtc_clk_init(struct device_node *node)CLK_OF_DECLARE_DRIVER (sun8i_a23_rtc_clk,"allwinner,sun8i-a23-rtc" , sun8i_a23_rtc_clk_init); +/* The B288 RTC clocks are the same as the A23's */ +CLK_OF_DECLARE_DRIVER (sun8i_b288_rtc_clk,"allwinner,sun8i-b288-rtc" , + sun8i_a23_rtc_clk_init); +[Severity: High]
Does adding this compatible string expose an issue in the error handling ofsun6i_rtc_clk_initon registration failure?If
clk_registerfails forrtc->losc, the function returns an error pointer and jumps to theerr_registerlabel. Since the globalsun6i_rtcpointer is already assigned to the allocated rtc struct earlier:
sun6i_rtc_clk_init()/* Yes, I know, this is ugly. */ sun6i_rtc = rtc; ... rtc->losc = clk_register(NULL, &rtc->hw); if (IS_ERR(rtc->losc)) { pr_crit("Couldn't register the LOSC clock\n"); goto err_register; }The probe function
sun6i_rtc_probelater fetches this dangling pointer:
sun6i_rtc_probe()struct sun6i_rtc_dev *chip = sun6i_rtc; ... clk_prepare_enable(chip->losc);Can this lead to a kernel panic when
clk_prepare_enableattempts to dereference the error pointer stored inchip->losc?[Severity: Medium]
Additionally, ifclk_registersucceeds forrtc->loscbut a later clock registration fails, triggering the jump toerr_register, does this cleanup path leak thertc->loscclock?
sun6i_rtc_clk_init()err_register:clk_hw_unregister_fixed_rate(rtc->int_osc); err: kfree(clk_data);The
err_registerpath unregistersrtc->int_oscbut appears to omit callingclk_unregister(rtc->losc).[Severity: Low]
Does the err cleanup path also leak the dynamically allocated rtc structure?
sun6i_rtc_clk_init()rtc = kzalloc_obj(*rtc); ... err: kfree(clk_data);The error path frees
clk_databut seems to omit freeing the allocated rtc structure.[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6
Re: [PATCH v4 03/11] dt-bindings: pinctrl: sun4i-a10: add Allwinner B288
In reply to Pablo MazziniQuoted 8 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.
Signed-off-by Pablo Mazzini <[email protected]>--- .../pinctrl/allwinner,sun4i-a10-pinctrl.yaml | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+)
Re: (subset) [PATCH v4 00/11] ARM: sunxi: add Allwinner B288 and the PocketBook Verse
In reply to Pablo MazziniQuoted 10 lines · Pablo Mazzini
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.[...]
Applied, thanks!
[05/11] dt-bindings: rtc: sun6i-a31: add Allwinner B288
https://git.kernel.org/abelloni/c/51f30cb855f0 [06/11] rtc: sun6i: add Allwinner B288 compatible https://git.kernel.org/abelloni/c/3784706c87c2
Best regards,
Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Re: [PATCH v4 09/11] dt-bindings: watchdog: sun4i-a10-wdt: add Allwinner B288
In reply to Pablo MazziniQuoted 4 lines · Pablo Mazzini
Same watchdog as the A31, which it falls back to.
Signed-off-by Pablo Mazzini <[email protected]>
Applied.
Thanks,
Guenter