From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C9B9F404BE7 for ; Tue, 9 Jun 2026 11:39:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781005187; cv=none; b=hj2Oa8tx7a8U9YYyxhAYExkRBxAaACJfhHlUuB54A770/Zj+mngSGshTua96FOUoOs/IWk2UjbyfYfMVXRmub+Z/GkkN4ORYqOVFR2BpH0jI6vpMcLewAlmD3Mmii5G/35OoFbwEZQ9hzn7WRBZilQrqmZzm+mGQGMOhFI1gG/Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781005187; c=relaxed/simple; bh=kTAg9q9u6VoW+qN869GenvQcA+UPoEV0Jn/gySZyMr0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fSrvUMNYGit67WDKM+E+WgH4Z/izmCGlbArCQsbZHeLamH15AI5JnMxHb/6WRF/OmWj+kDvA5DJBVGTNP1poJKDNeBdmIM6zXkDxEzrXxNOXi8sKeJm0mVtVep3LjGayGa1XG991Fg1lRC2qaUxFmH9RK62LXMvzw0PZNUea9zg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ADf8QRM9; arc=none smtp.client-ip=209.85.214.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ADf8QRM9" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-2bf22d29dabso35812875ad.2 for ; Tue, 09 Jun 2026 04:39:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781005185; x=1781609985; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=O3igX93L19Hd9A1VIL7yayX5x/YnSKR6u0HXaQm3XtM=; b=ADf8QRM9I/Dn+EnWodaEHM/QAmnovXtJWlFfFdUGOtHAknGN0WSw92OitysZMdi5/o aGv4z9YW7Sz2S4ayyszXbNij30TaHuBi1iwNUyJ01TAllbHFW5k7zR4DgmBsBBLqpEDD QhPhYnC4nqQkmtSGgsflU8hjFt4l9lR/UXIEvaVxQirNQLKtTyX/yVl866DoXm9Ko2Jq eJX7Op8fHZLC94ESl8IetHgSEU/C5Up4b9tCvksWp2XlHe/bqBjQzUsMi1XQqV6bZZMz GzjgP+0Ju2i+qsIE8j0joUQX1bbo+ES1ClNkwsj25y/RR8mJKE8SaWBtx5vsESqAUiUH tv5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781005185; x=1781609985; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=O3igX93L19Hd9A1VIL7yayX5x/YnSKR6u0HXaQm3XtM=; b=EgYLzy/2+kkNkV0UyT8fOlKCehOM5siC2LccTfhwxXnhKgYEh3XL+rR/M+aBgxdqhp npQadvaZaIOF/MPjsdL07s6B0GOcn3mO3iR2yGjO1DyxdSXiJ6X5TxScd0UCIlb3bWY4 iKk7Lg88wtnGEH7jEjQ6BhfW+rwmFUjz5gbK7rPa0tpq9NI/KQGL8fg7yfmWuFH0kh2p bbpucXFhizM/c4SDzZD+WFhsaBRUAnw/Wau6aTQ69B+qFhDNQD5nN5SIqyzw2TlV9xQt IJC2CHCSiKWs3ilAwGU4uBe99hD0w8THOfpeGQJopwveIKHaUiEj0o5cHLwKh54hSqk/ ok6A== X-Forwarded-Encrypted: i=1; AFNElJ9ATRr6FYP3eMM09BghfrRHzSrA2HFkYTmppaZnvWL8PMLe1ZSmlCCGpm8m4FkJlYzyhwovQkQCfnEal/w=@vger.kernel.org X-Gm-Message-State: AOJu0YxXB8r7DXQvbd/x99wMLCsAeMsKkRMGHdhnPwk8eyw4vYwAG2t7 aUaqvLZyfInfcCxR7ZVvjqGOqSm6u2R/86Snl+64hHco8w/+GgLcWOgP X-Gm-Gg: Acq92OG73nYQNretqr4Z/rHDZOJnZLOg2+4wmKvHNOMA0sSIzEiAAQmY9oV80/yA4mv kiNveHMvvvsSh7Lw/GN1axyVy97UmJPBmCZ9oKEt2d32RgQyiUQO0RjD76TstxN8thmkTXjK37g ZrvL4zDHN0Mx61uCzqFMeZdjquBmssjPbqiXZJqNw/ux7CCnp4Sl6pYfULewtApFfEBSr4cPenI aEhDfMXzJCoO3nx/A1VvL5Oy1bHqksnjyxzUo/OZM4XhKXjfhoq2Sook89gGCng2spwu51m6tc8 nbdsjBBkgEQntWyM+ikurxh3AA0NZzHH1XPLLyf3S1BJDAA+iTSKuNcBF/S8M+4FmBy9DgFNo6W uiAIlr/4eYXpYVxH7rkEjlDeZU9Odv0PlUwWmYsR96GKIo9xnqDcqkUH/tkQMoVFBWNJYlFTQzK Mhu2mt/P00NOQmx3m8f/gctFxLcZXgK+S1WS+ETGjaDhvCJl+f6XxdEULHlv9aEwK8UtIK X-Received: by 2002:a17:903:908:b0:2bf:2d0:887b with SMTP id d9443c01a7336-2c2a1bc8420mr37204835ad.9.1781005185183; Tue, 09 Jun 2026 04:39:45 -0700 (PDT) Received: from phuc-desktop.. ([183.91.15.56]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2c164f70660sm210755635ad.11.2026.06.09.04.39.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jun 2026 04:39:44 -0700 (PDT) From: phucduc.bui@gmail.com To: Kuninori Morimoto , Mark Brown , Geert Uytterhoeven Cc: Liam Girdwood , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Magnus Damm , Jaroslav Kysela , Takashi Iwai , linux-sound@vger.kernel.org, linux-renesas-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, bui duc phuc Subject: [PATCH v6 10/11] ASoC: renesas: fsi: add fsi_clk_prepare/unprepare() Date: Tue, 9 Jun 2026 18:38:35 +0700 Message-ID: <20260609113836.45079-11-phucduc.bui@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260609113836.45079-1-phucduc.bui@gmail.com> References: <20260609113836.45079-1-phucduc.bui@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: bui duc phuc Add fsi_clk_prepare() and fsi_clk_unprepare() helpers and call them from fsi_dai_startup() and fsi_dai_shutdown(). This ensures clk_prepare() and clk_unprepare() are executed from sleepable contexts and keeps clocks prepared only while audio streams are active. Acked-by: Kuninori Morimoto Suggested-by: Kuninori Morimoto Signed-off-by: bui duc phuc --- Changes in v6: - Add Acked-by tag from Kuninori Morimoto. Changes in v5: - Drop count & spu_count and rely on the clk core for clock reference counting. Changes in v4: - Move clock->count early return check to the beginning of fsi_clk_[un]prepare() to simplify the code. sound/soc/renesas/fsi.c | 51 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/sound/soc/renesas/fsi.c b/sound/soc/renesas/fsi.c index 716ecf0401fe..e26f39dfe059 100644 --- a/sound/soc/renesas/fsi.c +++ b/sound/soc/renesas/fsi.c @@ -730,6 +730,54 @@ 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; + + ret = clk_prepare(spu); + if (ret) + return ret; + ret = clk_prepare(xck); + if (ret) + goto err_spu; + ret = clk_prepare(ick); + if (ret) + goto err_xck; + 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; + + clk_unprepare(div); + clk_unprepare(ick); + clk_unprepare(xck); + clk_unprepare(spu); +} + static int fsi_clk_enable(struct device *dev, struct fsi_priv *fsi) { @@ -1580,7 +1628,7 @@ static int fsi_dai_startup(struct snd_pcm_substream *substream, fsi_clk_invalid(fsi); - return 0; + return fsi_clk_prepare(fsi); } static void fsi_dai_shutdown(struct snd_pcm_substream *substream, @@ -1588,6 +1636,7 @@ static void fsi_dai_shutdown(struct snd_pcm_substream *substream, { struct fsi_priv *fsi = fsi_get_priv(substream); + fsi_clk_unprepare(fsi); fsi_clk_invalid(fsi); } -- 2.43.0