git: 4f1a78adcd65 - main - aw_ccu: h6: Set the lock enable bit of the PLLs
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 12 Nov 2026 09:51:25 UTC
The branch main has been updated by manu:
URL: https://cgit.FreeBSD.org/src/commit/?id=4f1a78adcd6503778b6d0722713b707382ada3a7
commit 4f1a78adcd6503778b6d0722713b707382ada3a7
Author: Emmanuel Vadot <manu@FreeBSD.org>
AuthorDate: 2026-11-10 14:46:27 +0000
Commit: Emmanuel Vadot <manu@FreeBSD.org>
CommitDate: 2026-11-12 09:47:29 +0000
aw_ccu: h6: Set the lock enable bit of the PLLs
The PLLs have a lock enable bit, bit 29, and the lock status bit, bit
28, is only updated when it is set. The firmware only sets it on the
PLLs that it uses, which are the CPUX, DDR0 and PERIPH0 ones, so the
other PLLs could never be seen as locked.
Set it on all the PLLs when attaching, as Linux does.
Tested on: H6
---
sys/dev/clk/allwinner/ccu_h6.c | 36 +++++++++++++++++++++++++++++++++++-
1 file changed, 35 insertions(+), 1 deletion(-)
diff --git a/sys/dev/clk/allwinner/ccu_h6.c b/sys/dev/clk/allwinner/ccu_h6.c
index f172d85ab07e..5d344a36a50b 100644
--- a/sys/dev/clk/allwinner/ccu_h6.c
+++ b/sys/dev/clk/allwinner/ccu_h6.c
@@ -448,6 +448,25 @@ static struct aw_ccung_clk h6_ccu_clks[] = {
{ .type = AW_CLK_FIXED, .clk.fixed = &pll_video1_clk},
};
+/*
+ * Registers of the PLLs, the lock status bit of a PLL is only updated when
+ * its lock enable bit is set.
+ */
+#define PLL_LOCK_ENABLE (1 << 29)
+
+static const bus_size_t h6_pll_regs[] = {
+ 0x00, /* PLL_CPUX */
+ 0x10, /* PLL_DDR0 */
+ 0x20, /* PLL_PERIPH0 */
+ 0x28, /* PLL_PERIPH1 */
+ 0x30, /* PLL_GPU */
+ 0x40, /* PLL_VIDEO0 */
+ 0x48, /* PLL_VIDEO1 */
+ 0x58, /* PLL_VE */
+ 0x60, /* PLL_DE */
+ 0x70, /* PLL_HSIC */
+};
+
static int
ccu_h6_probe(device_t dev)
{
@@ -466,6 +485,8 @@ static int
ccu_h6_attach(device_t dev)
{
struct aw_ccung_softc *sc;
+ uint32_t val;
+ int error, i;
sc = device_get_softc(dev);
@@ -476,7 +497,20 @@ ccu_h6_attach(device_t dev)
sc->clks = h6_ccu_clks;
sc->nclks = nitems(h6_ccu_clks);
- return (aw_ccung_attach(dev));
+ error = aw_ccung_attach(dev);
+ if (error != 0)
+ return (error);
+
+ /*
+ * Only the PLLs used by the firmware have the lock enable bit set,
+ * set it for all of them so that we can wait for them to lock.
+ */
+ for (i = 0; i < nitems(h6_pll_regs); i++) {
+ val = bus_read_4(sc->res, h6_pll_regs[i]);
+ bus_write_4(sc->res, h6_pll_regs[i], val | PLL_LOCK_ENABLE);
+ }
+
+ return (0);
}
static device_method_t ccu_h6ng_methods[] = {