From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (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 978F236C5BF for ; Sun, 10 May 2026 08:44:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778402663; cv=none; b=mOFvckL9rpQ9EuyyU5N6r8koVB/nIl9eA9nF4KVfAKYGrlaTZhkIwYafwmtwimED213MQUDFCNRbAemeyIK7REczkDFY2slaLYUdexulQxkG3siSU7ZEtD1ONRKrJcYn4tKnHjXsBqO14etcweRYcGiAyHKQaVe47nPfvRWgL4c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778402663; c=relaxed/simple; bh=hAz9cVk/REbCqtvF14qK2qb5B2E/7eVaibiWkjmIo8g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gZQVhvx9TcWeH5mVBWLKkoAi5iUjEl/dl9xy8G7AJC0hy61hy/0hNxzmQnt6XxnZC1odRg3hUMKVk/JxYRxgrAutXNWkFlVcC/SpMmAriMmwPScVtIgaadYHUoIT5sjWF07hic3bLIrEEDF6AhkPDPkp4onZLArUIG+/ns1CEbw= 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=ZuqfS2kt; arc=none smtp.client-ip=209.85.214.174 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="ZuqfS2kt" Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-2b9fcf7c91bso32774675ad.0 for ; Sun, 10 May 2026 01:44:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778402661; x=1779007461; 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=R2/zYcrseTTot6/6qcImxSuA8kM1CWD/r6OyNv/RP/c=; b=ZuqfS2ktak3H8/wpGlvN/oR9G6PeJSWihXJxKqWvWGVMWTFmxHF7+GItfSk3Uvh9oj Xbtphv/I0JYqohufOtIvjd6KXQLIlYkbqWWZgiCZkAnkKnI58uFSlAWXjhkpPjkIDunB mHHj13HFY68B1GdNDkvhzA/S7K+gy+iBmQgsMP6MwyYdqpLzpyNP4ycmiCP5L9517Imb BJe7TWabFuErDbIW5AhupqjotMmwpTMgSB72yyPOLxET2iBUUigpKSA/pO1ASgCfYCZu jUyxSezrjOliE8onjutuay6Bmjy2fuPts7IFRHwxStJWVMI10hJPRDGhYVw+vAcpQIQl GrHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778402661; x=1779007461; 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=R2/zYcrseTTot6/6qcImxSuA8kM1CWD/r6OyNv/RP/c=; b=RF1rKHIlO6qIBBFXoVZWp6y0iAJheyiZTaXABxi02zaiS9umu554DFt/Lk5LGDTVGY W/AV7wPzbMnLSyBVhz0/3BXB7mxX807/xcdHkAR+lnJrr5H93Bhxh6fIp9sXQoTKrqHp m6nP5iX24Rg+vHL62BprolhRvx11auuSp1j3NZ8Q4mckm0KLmSBOMCso5fAngEES8eMN hy3L+xKkE+uj5W4/R94F3zr6/1fsk/DxsiI6m48OPutKcyLKejH865HtOBo4JF+w92LY 8Up1zqky1RVCHwuOI5cxXrUTsAcwADKXtj/bYY0crY5LmIvOp+TpvE3B05fzG9Ht/qZx VLZw== X-Forwarded-Encrypted: i=1; AFNElJ/gpsCoQcERY63Et6JnKF3avUjsLqpp56oBBPeRyKx69MKMmTgvUNuhzp5sc76G8uRk6INyiLZzdvmFRqI=@vger.kernel.org X-Gm-Message-State: AOJu0Yyw8MVLg0gTSeQLFveQFspdUWIi+uJiLJ2DfZsysLg462+Xw55b T1bqcUdjzzbY3SeEklHRvU/r0cBLxCRwnT9aVM+FT6dRWHL3VcENCUMi X-Gm-Gg: Acq92OG3KHGNAyFVT8jOFAZGhwYTMX8bFd2ouCbG9XMim5ImJgxpL7sxmQHV5DqiZsi fCm2ZGEzOkkZ+hdZgRLx6WRN2lqo0D/rTwDDzbLVB2FulV9+K94Q6fMHhODuugGdaZlV3Od9AdZ E+dicYrz1rjWa7UJF4wDMzYdI/UfF1HzlqSLs2ZhJXRBUbjcqHB+AQeTu321NDhNoJDC3sjMFUD FFveFblLMGOEAfZuPyRNT4aWUxtjnN8yyZleRymht2bsPq3b3AZ7HnQQGIEHD/w97C2CZYTGULW XhPXNtOwteeQqU537ZUi9m0cSOIDVQNEoOFm4QXkKrnrMVkO6AvAuMMOUFek6RC9NOvtp2uFUdY vEJeeM61ILjuNNWskf579HDUT99hTu7x1E+8yiQgYplDJAV19JBu8C6vOIqn4r8fyJ6IjNJKuny 5TxtRRNv0dW1aOgRM4mrqsiM5/Kb+EScxhiAarhUnkEs9NAVRRD1qe6MQjLw== X-Received: by 2002:a17:902:fb0f:b0:2ba:6ca2:bca with SMTP id d9443c01a7336-2ba79c20dd6mr140989945ad.26.1778402660935; Sun, 10 May 2026 01:44:20 -0700 (PDT) Received: from phuc-desktop.. ([183.91.15.56]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2baf1d3ffa0sm70471005ad.25.2026.05.10.01.44.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 May 2026 01:44:20 -0700 (PDT) From: phucduc.bui@gmail.com To: kuninori.morimoto.gx@renesas.com Cc: broonie@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org, geert+renesas@glider.be, krzk+dt@kernel.org, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-sound@vger.kernel.org, magnus.damm@gmail.com, perex@perex.cz, robh@kernel.org, tiwai@suse.com, bui duc phuc Subject: [PATCH v3 08/10] ASoC: renesas: fsi: add fsi_clk_prepare/unprepare() Date: Sun, 10 May 2026 15:43:01 +0700 Message-ID: <20260510084303.122426-9-phucduc.bui@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260510084303.122426-1-phucduc.bui@gmail.com> References: <20260510084303.122426-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 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 Signed-off-by: bui duc phuc --- 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