[PATCH v3 10/10] ASoC: renesas: fsi: Add SPU clock control in hw_startup/shutdown

From: phucduc . bui

Date: Sun May 10 2026 - 04:49:14 EST


From: bui duc phuc <phucduc.bui@xxxxxxxxx>

Enable and disable the SPU clock in fsi_hw_startup() and
fsi_hw_shutdown() to ensure the clock is active while the
driver accesses hardware registers.

Previously, the SPU clock was enabled by the bootloader and
remained active during operation. However, after adding the
SPU clock to the device tree, it is disabled automatically
once the system initialization completes.

As a result, register accesses may occur while the clock is
disabled, which can lead to system hangs. Manage the SPU
clock explicitly in the driver to ensure correct behavior.

Suggested-by: Kuninori Morimoto <kuninori.morimoto.gx@xxxxxxxxxxx>
Signed-off-by: bui duc phuc <phucduc.bui@xxxxxxxxx>
---
sound/soc/renesas/fsi.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)

diff --git a/sound/soc/renesas/fsi.c b/sound/soc/renesas/fsi.c
index c3ac8b30f342..5307085c0615 100644
--- a/sound/soc/renesas/fsi.c
+++ b/sound/soc/renesas/fsi.c
@@ -1579,6 +1579,19 @@ static int fsi_hw_startup(struct fsi_priv *fsi,
struct device *dev)
{
u32 data = 0;
+ int ret;
+
+ /* enable spu clock */
+ if (fsi->master->clk_spu) {
+ scoped_guard(spinlock_irqsave, &fsi->master->lock) {
+ if (fsi->master->spu_count == 0) {
+ ret = clk_enable(fsi->master->clk_spu);
+ if (ret < 0)
+ return ret;
+ }
+ fsi->master->spu_count++;
+ }
+ }

/* clock setting */
if (fsi_is_clk_master(fsi))
@@ -1636,6 +1649,12 @@ static int fsi_hw_shutdown(struct fsi_priv *fsi,
/* stop master clock */
if (fsi_is_clk_master(fsi))
return fsi_clk_disable(dev, fsi);
+ if (fsi->master->clk_spu) {
+ scoped_guard(spinlock_irqsave, &fsi->master->lock) {
+ if (--fsi->master->spu_count == 0)
+ clk_disable(fsi->master->clk_spu);
+ }
+ }

return 0;
}
--
2.43.0