[1/4] arm64: dts: allwinner: h5: orangepi-zero-plus2: Add LPO clock for AP6212

Message ID 20261120-orangepi-zero-plus2-fixes-v1-1-ecd792189f27@gmail.com (mailing list archive)
State New
Headers
Series arm64: dts: allwinner: h5: orangepi-zero-plus2: Fix Bluetooth and USB gadget |

Commit Message

Ivan Pfarher via B4 Relay Nov. 20, 2026, 11:40 a.m. UTC
From: Ivan Pfarher <ipfarher@gmail.com>

The AP6212 WiFi/BT module needs a 32.768 kHz low power oscillator (LPO)
clock, which on this board comes from the RTC clock output (osc32k-out).
Nothing in the device tree references that clock, so it is disabled as
unused during late boot.

WiFi keeps working without it, but the Bluetooth core does not: with the
LPO gated, the BCM43430A1 ROM answers HCI_Reset and nothing else (no
Read Local Version, no firmware download), so the controller can never
be brought up. Turning the clock output on by hand (RTC LOSC_OUT_GATING)
makes the controller answer normally.

Reference the clock from the WiFi power sequence, as other boards using
the same module do (e.g. sun8i-h2-plus-bananapi-m2-zero.dts).

Tested on an Orange Pi Zero Plus2 (H5) running Linux 6.6.160 with this
change applied: osc32k-out stays enabled and the Bluetooth controller
answers HCI commands. Build-tested only against current mainline.

This problem was investigated, and the patch drafted, in an interactive
session with an AI coding assistant (Claude by Anthropic). The submitter
reviewed the change and ran the tests described above.

Fixes: cf8e19e1ec15 ("arm64: dts: orange-pi-zero-plus2: enable AP6212a WiFi/BT combo")
Signed-off-by: Ivan Pfarher <ipfarher@gmail.com>
---
 arch/arm64/boot/dts/allwinner/sun50i-h5-orangepi-zero-plus2.dts | 3 +++
 1 file changed, 3 insertions(+)
  

Comments

Chen-Yu Tsai Nov. 20, 2026, 3:23 p.m. UTC | #1
On Fri, Nov 20, 2026 at 7:40 PM Ivan Pfarher via B4 Relay
<devnull+ipfarher.gmail.com@kernel.org> wrote:
>
> From: Ivan Pfarher <ipfarher@gmail.com>
>
> The AP6212 WiFi/BT module needs a 32.768 kHz low power oscillator (LPO)
> clock, which on this board comes from the RTC clock output (osc32k-out).
> Nothing in the device tree references that clock, so it is disabled as
> unused during late boot.
>
> WiFi keeps working without it, but the Bluetooth core does not: with the
> LPO gated, the BCM43430A1 ROM answers HCI_Reset and nothing else (no
> Read Local Version, no firmware download), so the controller can never
> be brought up. Turning the clock output on by hand (RTC LOSC_OUT_GATING)
> makes the controller answer normally.
>
> Reference the clock from the WiFi power sequence, as other boards using
> the same module do (e.g. sun8i-h2-plus-bananapi-m2-zero.dts).
>
> Tested on an Orange Pi Zero Plus2 (H5) running Linux 6.6.160 with this
> change applied: osc32k-out stays enabled and the Bluetooth controller
> answers HCI commands. Build-tested only against current mainline.

It stays enabled only if the mmc stuff is working. So besides the changes
in this patch (which technically only covers the WiFi side), you should
add a proper bluetooth node under uart1 with all the resource references.

> This problem was investigated, and the patch drafted, in an interactive
> session with an AI coding assistant (Claude by Anthropic). The submitter
> reviewed the change and ran the tests described above.
>
> Fixes: cf8e19e1ec15 ("arm64: dts: orange-pi-zero-plus2: enable AP6212a WiFi/BT combo")
> Signed-off-by: Ivan Pfarher <ipfarher@gmail.com>
> ---
>  arch/arm64/boot/dts/allwinner/sun50i-h5-orangepi-zero-plus2.dts | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h5-orangepi-zero-plus2.dts b/arch/arm64/boot/dts/allwinner/sun50i-h5-orangepi-zero-plus2.dts
> index 3eb986c35..34d6c1468 100644
> --- a/arch/arm64/boot/dts/allwinner/sun50i-h5-orangepi-zero-plus2.dts
> +++ b/arch/arm64/boot/dts/allwinner/sun50i-h5-orangepi-zero-plus2.dts
> @@ -5,6 +5,7 @@
>
>  #include "sun50i-h5.dtsi"
>
> +#include <dt-bindings/clock/sun6i-rtc.h>
>  #include <dt-bindings/gpio/gpio.h>
>
>  / {
> @@ -54,6 +55,8 @@
>
>         wifi_pwrseq: pwrseq {
>                 compatible = "mmc-pwrseq-simple";
> +               clocks = <&rtc CLK_OSC32K_FANOUT>;
> +               clock-names = "ext_clock";
>                 reset-gpios = <&pio 0 9 GPIO_ACTIVE_LOW>; /* PA9 */
>                 post-power-on-delay-ms = <200>;
>         };
>
> --
> 2.43.0
>
>
  
Chen-Yu Tsai Nov. 20, 2026, 3:24 p.m. UTC | #2
On Fri, Nov 20, 2026 at 11:23 PM Chen-Yu Tsai <wens@kernel.org> wrote:
>
> On Fri, Nov 20, 2026 at 7:40 PM Ivan Pfarher via B4 Relay
> <devnull+ipfarher.gmail.com@kernel.org> wrote:
> >
> > From: Ivan Pfarher <ipfarher@gmail.com>
> >
> > The AP6212 WiFi/BT module needs a 32.768 kHz low power oscillator (LPO)
> > clock, which on this board comes from the RTC clock output (osc32k-out).
> > Nothing in the device tree references that clock, so it is disabled as
> > unused during late boot.
> >
> > WiFi keeps working without it, but the Bluetooth core does not: with the
> > LPO gated, the BCM43430A1 ROM answers HCI_Reset and nothing else (no
> > Read Local Version, no firmware download), so the controller can never
> > be brought up. Turning the clock output on by hand (RTC LOSC_OUT_GATING)
> > makes the controller answer normally.
> >
> > Reference the clock from the WiFi power sequence, as other boards using
> > the same module do (e.g. sun8i-h2-plus-bananapi-m2-zero.dts).
> >
> > Tested on an Orange Pi Zero Plus2 (H5) running Linux 6.6.160 with this
> > change applied: osc32k-out stays enabled and the Bluetooth controller
> > answers HCI commands. Build-tested only against current mainline.
>
> It stays enabled only if the mmc stuff is working. So besides the changes
> in this patch (which technically only covers the WiFi side), you should
> add a proper bluetooth node under uart1 with all the resource references.

And that's the next patch. Sorry for the noise.

> > This problem was investigated, and the patch drafted, in an interactive
> > session with an AI coding assistant (Claude by Anthropic). The submitter
> > reviewed the change and ran the tests described above.
> >
> > Fixes: cf8e19e1ec15 ("arm64: dts: orange-pi-zero-plus2: enable AP6212a WiFi/BT combo")
> > Signed-off-by: Ivan Pfarher <ipfarher@gmail.com>
> > ---
> >  arch/arm64/boot/dts/allwinner/sun50i-h5-orangepi-zero-plus2.dts | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h5-orangepi-zero-plus2.dts b/arch/arm64/boot/dts/allwinner/sun50i-h5-orangepi-zero-plus2.dts
> > index 3eb986c35..34d6c1468 100644
> > --- a/arch/arm64/boot/dts/allwinner/sun50i-h5-orangepi-zero-plus2.dts
> > +++ b/arch/arm64/boot/dts/allwinner/sun50i-h5-orangepi-zero-plus2.dts
> > @@ -5,6 +5,7 @@
> >
> >  #include "sun50i-h5.dtsi"
> >
> > +#include <dt-bindings/clock/sun6i-rtc.h>
> >  #include <dt-bindings/gpio/gpio.h>
> >
> >  / {
> > @@ -54,6 +55,8 @@
> >
> >         wifi_pwrseq: pwrseq {
> >                 compatible = "mmc-pwrseq-simple";
> > +               clocks = <&rtc CLK_OSC32K_FANOUT>;
> > +               clock-names = "ext_clock";
> >                 reset-gpios = <&pio 0 9 GPIO_ACTIVE_LOW>; /* PA9 */
> >                 post-power-on-delay-ms = <200>;
> >         };
> >
> > --
> > 2.43.0
> >
> >
  
Chen-Yu Tsai Nov. 20, 2026, 3:33 p.m. UTC | #3
On Fri, Nov 20, 2026 at 7:40 PM Ivan Pfarher via B4 Relay
<devnull+ipfarher.gmail.com@kernel.org> wrote:
>
> From: Ivan Pfarher <ipfarher@gmail.com>
>
> The AP6212 WiFi/BT module needs a 32.768 kHz low power oscillator (LPO)
> clock, which on this board comes from the RTC clock output (osc32k-out).
> Nothing in the device tree references that clock, so it is disabled as
> unused during late boot.
>
> WiFi keeps working without it, but the Bluetooth core does not: with the
> LPO gated, the BCM43430A1 ROM answers HCI_Reset and nothing else (no
> Read Local Version, no firmware download), so the controller can never
> be brought up. Turning the clock output on by hand (RTC LOSC_OUT_GATING)
> makes the controller answer normally.
>
> Reference the clock from the WiFi power sequence, as other boards using
> the same module do (e.g. sun8i-h2-plus-bananapi-m2-zero.dts).
>
> Tested on an Orange Pi Zero Plus2 (H5) running Linux 6.6.160 with this
> change applied: osc32k-out stays enabled and the Bluetooth controller
> answers HCI commands. Build-tested only against current mainline.
>
> This problem was investigated, and the patch drafted, in an interactive
> session with an AI coding assistant (Claude by Anthropic). The submitter
> reviewed the change and ran the tests described above.
>
> Fixes: cf8e19e1ec15 ("arm64: dts: orange-pi-zero-plus2: enable AP6212a WiFi/BT combo")
> Signed-off-by: Ivan Pfarher <ipfarher@gmail.com>

Reviewed-by: Chen-Yu Tsai <wens@kernel.org>
  

Patch

diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h5-orangepi-zero-plus2.dts b/arch/arm64/boot/dts/allwinner/sun50i-h5-orangepi-zero-plus2.dts
index 3eb986c35..34d6c1468 100644
--- a/arch/arm64/boot/dts/allwinner/sun50i-h5-orangepi-zero-plus2.dts
+++ b/arch/arm64/boot/dts/allwinner/sun50i-h5-orangepi-zero-plus2.dts
@@ -5,6 +5,7 @@ 
 
 #include "sun50i-h5.dtsi"
 
+#include <dt-bindings/clock/sun6i-rtc.h>
 #include <dt-bindings/gpio/gpio.h>
 
 / {
@@ -54,6 +55,8 @@ 
 
 	wifi_pwrseq: pwrseq {
 		compatible = "mmc-pwrseq-simple";
+		clocks = <&rtc CLK_OSC32K_FANOUT>;
+		clock-names = "ext_clock";
 		reset-gpios = <&pio 0 9 GPIO_ACTIVE_LOW>; /* PA9 */
 		post-power-on-delay-ms = <200>;
 	};