[PATCH v3 08/10] ASoC: renesas: fsi: add fsi_clk_prepare/unprepare()
From: phucduc . bui
Date: Sun May 10 2026 - 04:48:16 EST
From: bui duc phuc <phucduc.bui@xxxxxxxxx>
Add helper functions for preparing and unpreparing FSI clocks.
These helpers centralize clock prepare/unprepare handling and
will be used by subsequent patches to move clock management
into sleepable contexts.
Suggested-by: Kuninori Morimoto <kuninori.morimoto.gx@xxxxxxxxxxx>
Signed-off-by: bui duc phuc <phucduc.bui@xxxxxxxxx>
---
sound/soc/renesas/fsi.c | 66 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 66 insertions(+)
diff --git a/sound/soc/renesas/fsi.c b/sound/soc/renesas/fsi.c
index 8c46d6806958..b93809b5da15 100644
--- a/sound/soc/renesas/fsi.c
+++ b/sound/soc/renesas/fsi.c
@@ -732,6 +732,72 @@ static int fsi_clk_is_valid(struct fsi_priv *fsi)
fsi->clock.rate;
}
+static int fsi_clk_prepare(struct fsi_priv *fsi)
+{
+ struct fsi_clk *clock = &fsi->clock;
+ struct clk *spu = fsi->master->clk_spu;
+ struct clk *xck = clock->xck;
+ struct clk *ick = clock->ick;
+ struct clk *div = clock->div;
+ int ret;
+
+ if (!IS_ERR_OR_NULL(spu) && fsi->master->spu_count == 0) {
+ ret = clk_prepare(spu);
+ if (ret)
+ return ret;
+ }
+
+ if (!IS_ERR_OR_NULL(xck)) {
+ ret = clk_prepare(xck);
+ if (ret)
+ goto err_spu;
+ }
+
+ if (!IS_ERR_OR_NULL(ick)) {
+ ret = clk_prepare(ick);
+ if (ret)
+ goto err_xck;
+ }
+
+ if (!IS_ERR_OR_NULL(div)) {
+ ret = clk_prepare(div);
+ if (ret)
+ goto err_ick;
+ }
+
+ return 0;
+
+err_ick:
+ clk_unprepare(ick);
+err_xck:
+ clk_unprepare(xck);
+err_spu:
+ clk_unprepare(spu);
+
+ return ret;
+}
+
+static void fsi_clk_unprepare(struct fsi_priv *fsi)
+{
+ struct fsi_clk *clock = &fsi->clock;
+ struct clk *spu = fsi->master->clk_spu;
+ struct clk *xck = clock->xck;
+ struct clk *ick = clock->ick;
+ struct clk *div = clock->div;
+
+ if (!IS_ERR_OR_NULL(div))
+ clk_unprepare(div);
+
+ if (!IS_ERR_OR_NULL(ick))
+ clk_unprepare(ick);
+
+ if (!IS_ERR_OR_NULL(xck))
+ clk_unprepare(xck);
+
+ if (!IS_ERR_OR_NULL(spu) && fsi->master->spu_count == 0)
+ clk_unprepare(spu);
+}
+
static int fsi_clk_enable(struct device *dev,
struct fsi_priv *fsi)
{
--
2.43.0