From nobody Sun Apr 12 00:06:35 2026 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9BDFA3A5E83 for ; Tue, 7 Apr 2026 14:25:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775571931; cv=none; b=PqIfJvJUz4jAyDz9T1ZXFnyUD2HsEKLg0Osd120ibAjNdqr0OyV0Zap0sh4qjJn8HAIC6HdKBqSz66HkdObpZiyZeEN8hTTE2NvqgwpwG+3gWSVOHytqLQh9sZZxmATV1He33lHneMRXNu+NJ8Gmpjqxf9hB3LoV0fho3IHk7wo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775571931; c=relaxed/simple; bh=mDjS8QRxemHKE4dtUqVTtgu7ZlOc10UI+0F5GphJtUA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Zlsih0XHSCATBMSJUx+dJgbTP76s6NWlWso26r+wrfdNluEb2eIHRIdklwBttBCJl/+jtgX8UVqpIwfSxWiH26san9wsoZ1vYCOjuOFcSk4Lcw+0TOVDScfJucKU7i5CLq/b/SFNGx1377ZjPlXHKJfmwrRAl6VSXrs+7olZlYc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=GJF1ltdl; arc=none smtp.client-ip=185.246.85.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="GJF1ltdl" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 16C764E42944; Tue, 7 Apr 2026 14:25:28 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id DBCB7603C7; Tue, 7 Apr 2026 14:25:27 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 478401045017A; Tue, 7 Apr 2026 16:25:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1775571926; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=iMJ932icSsAvixcpk7bfZVoJ+QQ+IxSzkCPu6ctaCgQ=; b=GJF1ltdls/1X1//AzlFXJbKPAN03vdapfCZk+2+kriDG9NOlOVp9u+6hCCEYhjp7+F1Q+m /sv3V4a4alyBZLfAM7WCH06R7liVycvurfOU1D1kIknkcHbpfaDUWcqr1mU2mJmeNB6nZW eu+tavofWl6kYSy7nwE0V9bIDT/341IwGTmJxDY4AK2LZuFKSfEV+9tUzd019tFWiMcyCk 4lsckMRt1PJbWkmy/tjgdbuehTYd/QNUxfwUiNf4XYDVn4PvjNDiICtM5AjJOdHTuYwTRr r+Gvtk93QWx+MUmANmWkdfoQLTV2doTYvECjsBmcLWkGQSeAslsFfMOqCPp2LA== From: "Thomas Richard (TI)" Date: Tue, 07 Apr 2026 16:25:08 +0200 Subject: [PATCH v5 3/4] clk: keystone: sci-clk: add restore_context() operation Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260407-ti-sci-jacinto-s2r-restore-irq-v5-3-97b28f2d93f9@bootlin.com> References: <20260407-ti-sci-jacinto-s2r-restore-irq-v5-0-97b28f2d93f9@bootlin.com> In-Reply-To: <20260407-ti-sci-jacinto-s2r-restore-irq-v5-0-97b28f2d93f9@bootlin.com> To: Nishanth Menon , Tero Kristo , Santosh Shilimkar , Michael Turquette , Stephen Boyd Cc: Gregory CLEMENT , richard.genoud@bootlin.com, Udit Kumar , Prasanth Mantena , Abhash Kumar , Thomas Petazzoni , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, "Thomas Richard (TI)" , Dhruva Gole X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 Implement the restore_context() operation to restore the clock rate and the clock parent state. The clock rate is saved in sci_clk struct during set_rate() operation. The parent index is saved in sci_clk struct during set_parent() operation. During clock registration, the core retrieves each clock=E2=80=99s parent using get_parent() operation to ensure the internal = clock tree reflects the actual hardware state, including any configurations made by the bootloader. So we also save the parent index in get_parent(). Reviewed-by: Dhruva Gole Signed-off-by: Thomas Richard (TI) --- drivers/clk/keystone/sci-clk.c | 42 ++++++++++++++++++++++++++++++++++----= ---- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/drivers/clk/keystone/sci-clk.c b/drivers/clk/keystone/sci-clk.c index 9d5071223f4c..428050a05de3 100644 --- a/drivers/clk/keystone/sci-clk.c +++ b/drivers/clk/keystone/sci-clk.c @@ -47,6 +47,8 @@ struct sci_clk_provider { * @node: Link for handling clocks probed via DT * @cached_req: Cached requested freq for determine rate calls * @cached_res: Cached result freq for determine rate calls + * @parent_id: Parent index for this clock + * @rate: Clock rate */ struct sci_clk { struct clk_hw hw; @@ -58,6 +60,8 @@ struct sci_clk { struct list_head node; unsigned long cached_req; unsigned long cached_res; + u8 parent_id; + unsigned long rate; }; =20 #define to_sci_clk(_hw) container_of(_hw, struct sci_clk, hw) @@ -210,10 +214,16 @@ static int sci_clk_set_rate(struct clk_hw *hw, unsign= ed long rate, unsigned long parent_rate) { struct sci_clk *clk =3D to_sci_clk(hw); + int ret; + + ret =3D clk->provider->ops->set_freq(clk->provider->sci, clk->dev_id, + clk->clk_id, rate / 10 * 9, rate, + rate / 10 * 11); =20 - return clk->provider->ops->set_freq(clk->provider->sci, clk->dev_id, - clk->clk_id, rate / 10 * 9, rate, - rate / 10 * 11); + if (!ret) + clk->rate =3D rate; + + return ret; } =20 /** @@ -237,9 +247,9 @@ static u8 sci_clk_get_parent(struct clk_hw *hw) return 0; } =20 - parent_id =3D parent_id - clk->clk_id - 1; + clk->parent_id =3D (u8)(parent_id - clk->clk_id - 1); =20 - return (u8)parent_id; + return clk->parent_id; } =20 /** @@ -252,12 +262,27 @@ static u8 sci_clk_get_parent(struct clk_hw *hw) static int sci_clk_set_parent(struct clk_hw *hw, u8 index) { struct sci_clk *clk =3D to_sci_clk(hw); + int ret; =20 clk->cached_req =3D 0; =20 - return clk->provider->ops->set_parent(clk->provider->sci, clk->dev_id, - clk->clk_id, - index + 1 + clk->clk_id); + ret =3D clk->provider->ops->set_parent(clk->provider->sci, clk->dev_id, + clk->clk_id, + index + 1 + clk->clk_id); + if (!ret) + clk->parent_id =3D index; + + return ret; +} + +static void sci_clk_restore_context(struct clk_hw *hw) +{ + struct sci_clk *clk =3D to_sci_clk(hw); + + sci_clk_set_parent(hw, clk->parent_id); + + if (clk->rate) + sci_clk_set_rate(hw, clk->rate, 0); } =20 static const struct clk_ops sci_clk_ops =3D { @@ -269,6 +294,7 @@ static const struct clk_ops sci_clk_ops =3D { .set_rate =3D sci_clk_set_rate, .get_parent =3D sci_clk_get_parent, .set_parent =3D sci_clk_set_parent, + .restore_context =3D sci_clk_restore_context, }; =20 /** --=20 2.53.0