From nobody Mon Dec 1 22:36:50 2025 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 4C96C3242D8 for ; Thu, 27 Nov 2025 08:39:20 +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=1764232764; cv=none; b=u3Axdx1ks9Q7IjdXlYvUaI24d8q70+Q9+EcJ7G++ytxWWKMI+PR45dnHmiErhxU1MlX79D2xonQNwKrvNLv0V31SHWsnrE4XYj05uLTcYYp32ox5u32aVdt5+7GfB/Uav1RHBpa6lYGr+95KFEt9dqsaBv6nPAUC22JTgbIoSMI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764232764; c=relaxed/simple; bh=aProAx5VL9C8t/GV0kAIP1skLnL0Hs664rC2YSLwxNs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Ho+Pxc16IUGynn0uBXWQBI8LUk2X91G5X1YVeyKqPUif+r1qYAPaZ+MpdfY8bJ2zil6kescMWzrcfs+9bCqRb1IkApxnnhiA6SW7T5/hkATizzqAqeN8ll6yqSjZTui/SEkrqtqXkObr9B55OXKmy6XWV9frbZspeNEgftiW8oU= 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=GDSY87Dh; 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="GDSY87Dh" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 854004E41919; Thu, 27 Nov 2025 08:39:18 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 5AF106068C; Thu, 27 Nov 2025 08:39:18 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 77E1D102F2751; Thu, 27 Nov 2025 09:39:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1764232757; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=XxlcfNeRaRWZTwXU0NT8kH+GHpvE/vl/i3zb2pJZvTQ=; b=GDSY87DhyMjqWSjbdiANf57fcC8hDx8BNRcoDp9crZ/ex1R+DePu29R+7pG0nEAKRHwkiA +sPsEeSscmiQz5QvJhccnAp4lnceRs5FXiZHFneHOQWognVetSNohaHUHcHyAXsQPJ0WrC +Jj1O0rHW0rEe2tTefEidFjAR4BQHowsUOkdsFsmKlfzoF+yEx0Xu+Y5s8VPULt21eOeS0 Er6ZgUAkGB1+6rl/0An0eaq3XvG/Qg5MKtKe+Ipxe4i7cc2Yz8YJXTrNqU14vkJlwbEyBZ nXdEFk4Pe4Rr1q4kpiYXsuWMnP/EavHqeQ8FAdcqAkXFUTT5QFX/tPdBfAa/EQ== From: "Thomas Richard (TI.com)" Date: Thu, 27 Nov 2025 09:38:57 +0100 Subject: [PATCH RFC v2 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: <20251127-ti-sci-jacinto-s2r-restore-irq-v2-3-a487fa3ff221@bootlin.com> References: <20251127-ti-sci-jacinto-s2r-restore-irq-v2-0-a487fa3ff221@bootlin.com> In-Reply-To: <20251127-ti-sci-jacinto-s2r-restore-irq-v2-0-a487fa3ff221@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.com)" X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 Implement the restore_context() operation to restore the clock parent state. The parent index is saved in sci_clk struct during set_parent(). During clock registration, the core retrieves each clock=E2=80=99s parent u= sing 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(). Signed-off-by: Thomas Richard (TI.com) --- drivers/clk/keystone/sci-clk.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/drivers/clk/keystone/sci-clk.c b/drivers/clk/keystone/sci-clk.c index a4b42811de55d..1e5dd01484d1c 100644 --- a/drivers/clk/keystone/sci-clk.c +++ b/drivers/clk/keystone/sci-clk.c @@ -47,6 +47,7 @@ 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 */ struct sci_clk { struct clk_hw hw; @@ -58,6 +59,7 @@ struct sci_clk { struct list_head node; unsigned long cached_req; unsigned long cached_res; + u8 parent_id; }; =20 #define to_sci_clk(_hw) container_of(_hw, struct sci_clk, hw) @@ -237,9 +239,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 +254,24 @@ 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); } =20 static const struct clk_ops sci_clk_ops =3D { @@ -269,6 +283,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.51.0