[PATCH] media: cec: meson: ao-cec: enable the controller clock at probe
From: christian . koever-draxl
Date: Sun Oct 25 2026 - 15:21:43 EST
From: Christian Stefan Kövér-Draxl <ckoever@xxxxxxxxxx>
The CEC core calls .adap_log_addr() before .adap_enable(), so the first
register access can happen while the controller is still in power-off
mode (CEC_GEN_CNTL clock field 0). The probe only pulses the reset bit
and leaves the clock field at zero.
On S4 an access to the powered-off controller never completes: it
stalls the AO bus and hard-hangs the SoC. This triggers on every HDMI
unplug, because that invalidates the physical address and makes the
core rewrite the logical address.
Leave the controller with its clock running after the reset at probe,
as .adap_enable() would.
Fixes: 7ec2c0f72cb1 ("media: platform: Add Amlogic Meson AO CEC Controller driver")
Signed-off-by: Christian Stefan Kövér-Draxl <ckoever@xxxxxxxxxx>
---
Tool use (Documentation/process/generated-content.rst):
This work was done with the help of an AI coding assistant, Claude
(Anthropic), used through Claude Code over many sessions. It did a large
part of the hands-on work: it read the vendor kernel and the firmware
interfaces, probed registers on the board, drafted the code and the
changelogs, and ran the builds, checkpatch, dt_binding_check and the
tests on the hardware. I directed the work, reviewed every change and
the final patches, and take responsibility for them. There is no single
prompt to quote; the sessions were of the form "find out why X fails on
this board, fix it, test it on the box".
Tested on an Amediatech X98Q TV box (Amlogic S905W2, S4 family, 2 GiB),
vendor U-Boot and BL31/OP-TEE, Linux 7.3 plus this work.
drivers/media/cec/platform/meson/ao-cec.c | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/drivers/media/cec/platform/meson/ao-cec.c b/drivers/media/cec/platform/meson/ao-cec.c
index 2df0d3743077..dd4d91d7b927 100644
--- a/drivers/media/cec/platform/meson/ao-cec.c
+++ b/drivers/media/cec/platform/meson/ao-cec.c
@@ -674,8 +674,25 @@ static int meson_ao_cec_probe(struct platform_device *pdev)
if (ret < 0)
goto out_probe_notify;
- /* Setup Hardware */
- writel_relaxed(CEC_GEN_CNTL_RESET,
+ /*
+ * Setup Hardware.
+ *
+ * Leave the controller with its gated clock running. The CEC core
+ * calls .adap_log_addr() before it ever calls .adap_enable(), so the
+ * first register access happens while the block would otherwise still
+ * be in power-off mode (CEC_GEN_CNTL clk field == 0). On Amlogic S4
+ * that access never completes: it stalls the AO bus and hard-hangs the
+ * SoC - every CPU stops, IRQs included - which happens on every HDMI
+ * hot-unplug, because that is what invalidates the CEC physical
+ * address.
+ */
+ writel_relaxed(CEC_GEN_CNTL_RESET |
+ FIELD_PREP(CEC_GEN_CNTL_CLK_CTRL_MASK,
+ CEC_GEN_CNTL_CLK_ENABLE),
+ ao_cec->base + CEC_GEN_CNTL_REG);
+ fsleep(100);
+ writel_relaxed(FIELD_PREP(CEC_GEN_CNTL_CLK_CTRL_MASK,
+ CEC_GEN_CNTL_CLK_ENABLE),
ao_cec->base + CEC_GEN_CNTL_REG);
return 0;
base-commit: 7be4bc52fd9e0e55dc9a2e0232b89427d2c4b614
--
2.56.0