From nobody Tue Sep 29 11:58:30 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 A004233C1AD; Fri, 7 Aug 2026 15:24:26 +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=1786116268; cv=none; b=sPE+D5+GQb6ofj87NpDzIm8EBgacrR7ZaS7W4SwQBXP6ijsVbPypPIO4gtm6krczvN/4HBpMw0lr9uXr1477FjrtihhzYKSQOIC+QVZsmB3qCWtC1l9jOmmv6i753O1EGyO6+rK020olZp6RUCzVN0NSPJq1memcsoP9JKBbI/s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786116268; c=relaxed/simple; bh=i5qo6wAWZZi28BDqurxnpPB8CHJV06srZ3HQ2FG2z4s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=UnCObn2oRlrZhsypTF4qVG/CR7zd0rFmp2OA2PhXuepHUrazIBSPgY633UrrjOUbRFSP9sGDNYcoyj4lw9unv6WL6BIt1tsBs2LI2eGuwy2ou/PbS5Vea6CabR/ZgftIJ1VrIlpXmcCtNzowG9gigVX4VnObubxhcaPr0nYI5IM= 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=tGSXOq5T; 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="tGSXOq5T" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 146954E41140; Fri, 7 Aug 2026 15:24:25 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id DDF4F603F0; Fri, 7 Aug 2026 15:24:24 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 785A211C37AC1; Fri, 7 Aug 2026 17:24:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1786116259; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=eNH/a49MoQbWQgpYX6dujOb3+PD1cc1o+/U0FHTru1s=; b=tGSXOq5ToHY3ybmvZXRhD7kjBZr95vpZ+cwKr+OkTZvg9SJxd2IOxpVHy9MLQNwWxI43d/ 9i5gDoHX6UJJsmZYiDXCw5zxM23x9eqANlMYtJvUCcl8RUrJeHEU/qvGZCyZKAGWvLHbfI WvpgYaCrtcp0nWXQbb0L5k3FPVc9s6NTRgBy5m01NaiORLJBXvEka4+NcOmfPklKsAsiWx Duo9mtMcYA1ho+mW6lLRTxVOLGUD48/n+pbfF8F1vadQh1FMos/OvgCb1MzA6zK77kiUgw jL4jVl3+lGX9roJW4Uu1F/zuyzVw5s1WoqLQLtELRQwNhyV3AZsSxOeCoKvCXg== From: "Miquel Raynal (Schneider Electric)" Date: Fri, 07 Aug 2026 17:24:02 +0200 Subject: [PATCH v5 1/7] dt-bindings: clock: Introduce nexus nodes 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: <20260807-schneider-v7-2-rc1-eip201-upstream-v5-1-8785f9531cf0@bootlin.com> References: <20260807-schneider-v7-2-rc1-eip201-upstream-v5-0-8785f9531cf0@bootlin.com> In-Reply-To: <20260807-schneider-v7-2-rc1-eip201-upstream-v5-0-8785f9531cf0@bootlin.com> To: Michael Turquette , Stephen Boyd , Brian Masney , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Brendan Higgins , David Gow , Rae Moar Cc: Thomas Petazzoni , Pascal EBERHARD , Wolfram Sang , Fran Li , linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, "Miquel Raynal (Schneider Electric)" , Frank Li X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 Hardware containers can just decouple external resources like clock without any more control. Nexus nodes already exist for PWM and GPIOs, add a binding to allow them for clocks as well. No examples are given, the file is litteraly a copy-paste from Herv=C3=A9 Codina's work on PWM Nexus nodes, hence we just point to the examples there which already illustrate very clearly the concept of the various properties. Signed-off-by: Miquel Raynal (Schneider Electric) Reviewed-by: Rob Herring (Arm) Reviewed-by: Frank Li --- .../bindings/clock/clock-nexus-node.yaml | 30 ++++++++++++++++++= ++++ 1 file changed, 30 insertions(+) diff --git a/Documentation/devicetree/bindings/clock/clock-nexus-node.yaml = b/Documentation/devicetree/bindings/clock/clock-nexus-node.yaml new file mode 100644 index 000000000000..ff3283bd5fb1 --- /dev/null +++ b/Documentation/devicetree/bindings/clock/clock-nexus-node.yaml @@ -0,0 +1,30 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/clock/clock-nexus-node.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Clock Nexus + +description: > + A nexus node allows to remap a clock specifier list in a consumer node + through a container or a connector node in a generic way. With this + remapping, the consumer node needs to know only about the nexus + node. Resources behind the nexus node are decoupled by the nexus node + itself. + +maintainers: + - Miquel Raynal + +select: true + +properties: + clock-map: + $ref: /schemas/types.yaml#/definitions/uint32-matrix + +dependentRequired: + clock-map: ['#clock-cells'] + +additionalProperties: true + +# See the original pwm-nexus-node.yaml description for examples --=20 2.54.0 From nobody Tue Sep 29 11:58:30 2026 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (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 58228397958; Fri, 7 Aug 2026 15:24:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786116275; cv=none; b=O4FqNr6zxfelti8IYEIM0Fj+7oxl2MRjy6cTr1tfdMiQWAP3RlqenY/NyX1KK/fps3LD/29d/NszIMySg78YgnQ7bvJzOnLAdtNer2rVy0PYmROM3zhKtxRsKxB+SyDshk4gGuCUuwN80nnAP4bpV3pwJDhwcHg0/Tg5UMSltv8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786116275; c=relaxed/simple; bh=SqwL52+7XQEG3gedT1KMYbrlbaVXpcJY38355Z1cIMU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Cgq15d9TMwiArquEdzElnL5qIlj2TRjNtyeISgql9l5XeBTkeavIXgd+wLNzpgg32FHwsXPlIpCbTkX6dGJbtdP/xTOYnES2xsF6Oa96/js172079IJqtSYyiwN0Yc89mydsAyc8QlUcuFaOOXT2OX1wzAxoa1nJ8XUufH12sac= 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=P1Jb9ZFO; arc=none smtp.client-ip=185.246.84.56 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="P1Jb9ZFO" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id B88FF1A14B2; Fri, 7 Aug 2026 15:24:31 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 8DF37603F0; Fri, 7 Aug 2026 15:24:31 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id E3B0A11C37AC7; Fri, 7 Aug 2026 17:24:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1786116266; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=5yh8sLUU7nbVpgrrx+0PC5E3UZ5E1089AOER+xaEt6I=; b=P1Jb9ZFOvG56ayKOyaaVHKcNLZMj5CzSv+pG2tKYf5j3nn7V3sQ8mFDq3Z5hBxUeo6ryXf s+t7hpBY08K+R8Ff6Md0wVD2ISYT0aBwsNN+Mv54IpSZniAc/JEVlrtPQx6GACdQYcKdbY LDLByDQyBsJQBjzKgrio76qVYUogiCGtfa3GMKqcjg9AOm13F185jeK1UaRv6y+EvSClUG YC6faOVEWmu+lMYFODDDfosungbXusWJKNwly6mTYT2GrBQcsDtzHWO4t4N68vzPxYT8AH aCSRLUJBi3ECLxnFdmmRStmsm9yZ+Wv1bm1SA5WjMIt1H96KsrS08JFZDiMVXg== From: "Miquel Raynal (Schneider Electric)" Date: Fri, 07 Aug 2026 17:24:03 +0200 Subject: [PATCH v5 2/7] clk: tests: Add clk_parse_clkspec() Kunit testing 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: <20260807-schneider-v7-2-rc1-eip201-upstream-v5-2-8785f9531cf0@bootlin.com> References: <20260807-schneider-v7-2-rc1-eip201-upstream-v5-0-8785f9531cf0@bootlin.com> In-Reply-To: <20260807-schneider-v7-2-rc1-eip201-upstream-v5-0-8785f9531cf0@bootlin.com> To: Michael Turquette , Stephen Boyd , Brian Masney , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Brendan Higgins , David Gow , Rae Moar Cc: Thomas Petazzoni , Pascal EBERHARD , Wolfram Sang , Fran Li , linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, "Miquel Raynal (Schneider Electric)" , Frank Li X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 Create a new set of kunit tests to make sure clk_parse_clkspec() is working as expected. We currently verify if we get a proper device when using indexes and names. If we make an out of bounds request we expect an error. For testing purposes, we must ensure of_clk_get_hw()'s symbol is exported. Suggested-by: Stephen Boyd Signed-off-by: Miquel Raynal (Schneider Electric) Reviewed-by: Brian Masney Reviewed-by: Frank Li --- drivers/clk/Makefile | 1 + drivers/clk/clk.c | 2 + drivers/clk/clk_test.c | 110 +++++++++++++++++++++++++++= ++++ drivers/clk/kunit_clk_parse_clkspec.dtso | 21 ++++++ 4 files changed, 134 insertions(+) diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile index cc108a75a900..035b984db70d 100644 --- a/drivers/clk/Makefile +++ b/drivers/clk/Makefile @@ -19,6 +19,7 @@ clk-test-y :=3D clk_test.o \ kunit_clk_assigned_rates_zero.dtbo.o \ kunit_clk_assigned_rates_zero_consumer.dtbo.o \ kunit_clk_hw_get_dev_of_node.dtbo.o \ + kunit_clk_parse_clkspec.dtbo.o \ kunit_clk_parent_data_test.dtbo.o obj-$(CONFIG_COMMON_CLK) +=3D clk-divider.o obj-$(CONFIG_COMMON_CLK) +=3D clk-fixed-factor.o diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 048adfa86a5d..08874cf9b561 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -24,6 +24,7 @@ #include #include #include +#include =20 #include "clk.h" =20 @@ -5300,6 +5301,7 @@ struct clk_hw *of_clk_get_hw(struct device_node *np, = int index, =20 return hw; } +EXPORT_SYMBOL_IF_KUNIT(of_clk_get_hw); =20 static struct clk *__of_clk_get(struct device_node *np, int index, const char *dev_id, diff --git a/drivers/clk/clk_test.c b/drivers/clk/clk_test.c index b1961daac5e2..f47f81b7d72a 100644 --- a/drivers/clk/clk_test.c +++ b/drivers/clk/clk_test.c @@ -3541,10 +3541,119 @@ static struct kunit_suite clk_hw_get_dev_of_node_t= est_suite =3D { .test_cases =3D clk_hw_get_dev_of_node_test_cases, }; =20 +static const struct clk_init_data clk_parse_clkspec_1_init_data =3D { + .name =3D "clk_parse_clkspec_1", + .ops =3D &empty_clk_ops, +}; + +static const struct clk_init_data clk_parse_clkspec_2_init_data =3D { + .name =3D "clk_parse_clkspec_2", + .ops =3D &empty_clk_ops, +}; + +struct clk_parse_clkspec_ctx { + struct device_node *cons_np; +}; + +static int clk_parse_clkspec_init(struct kunit *test) +{ + struct device_node *prov1_np, *prov2_np; + struct clk_parse_clkspec_ctx *ctx; + struct clk_hw *hw1, *hw2; + + ctx =3D kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); + test->priv =3D ctx; + + KUNIT_ASSERT_EQ(test, 0, of_overlay_apply_kunit(test, kunit_clk_parse_clk= spec)); + + /* Register provider 1 */ + hw1 =3D kunit_kzalloc(test, sizeof(*hw1), GFP_KERNEL); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, hw1); + hw1->init =3D &clk_parse_clkspec_1_init_data; + + prov1_np =3D of_find_compatible_node(NULL, NULL, "test,clock-provider1"); + KUNIT_ASSERT_NOT_NULL(test, prov1_np); + of_node_put_kunit(test, prov1_np); + + KUNIT_ASSERT_EQ(test, 0, of_clk_hw_register_kunit(test, prov1_np, hw1)); + KUNIT_ASSERT_EQ(test, 0, of_clk_add_hw_provider_kunit(test, prov1_np, of_= clk_hw_simple_get, hw1)); + + /* Register provider 2 */ + hw2 =3D kunit_kzalloc(test, sizeof(*hw2), GFP_KERNEL); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, hw2); + hw2->init =3D &clk_parse_clkspec_2_init_data; + + prov2_np =3D of_find_compatible_node(NULL, NULL, "test,clock-provider2"); + KUNIT_ASSERT_NOT_NULL(test, prov2_np); + of_node_put_kunit(test, prov2_np); + + KUNIT_ASSERT_EQ(test, 0, of_clk_hw_register_kunit(test, prov2_np, hw2)); + KUNIT_ASSERT_EQ(test, 0, of_clk_add_hw_provider_kunit(test, prov2_np, of_= clk_hw_simple_get, hw2)); + + ctx->cons_np =3D of_find_compatible_node(NULL, NULL, "test,clock-consumer= "); + KUNIT_ASSERT_NOT_NULL(test, ctx->cons_np); + of_node_put_kunit(test, ctx->cons_np); + + return 0; +} + +/* Test DT phandle lookups using correct index or name succeed */ +static void clk_parse_clkspec_with_correct_index_and_name(struct kunit *te= st) +{ + struct clk_parse_clkspec_ctx *ctx =3D test->priv; + struct clk_hw *hw1, *hw2, *hw3, *hw4; + + /* Get clocks by index */ + hw1 =3D of_clk_get_hw(ctx->cons_np, 0, NULL); + KUNIT_EXPECT_NOT_ERR_OR_NULL(test, hw1); + + hw2 =3D of_clk_get_hw(ctx->cons_np, 1, NULL); + KUNIT_EXPECT_NOT_ERR_OR_NULL(test, hw2); + KUNIT_EXPECT_PTR_NE(test, hw1, hw2); + + /* Get clocks by name */ + hw3 =3D of_clk_get_hw(ctx->cons_np, 0, "first_clock"); + KUNIT_EXPECT_NOT_ERR_OR_NULL(test, hw3); + KUNIT_EXPECT_PTR_EQ(test, hw1, hw3); + + hw4 =3D of_clk_get_hw(ctx->cons_np, 0, "second_clock"); + KUNIT_EXPECT_NOT_ERR_OR_NULL(test, hw4); + KUNIT_EXPECT_PTR_EQ(test, hw2, hw4); +} + +/* Test DT phandle lookups using wrong index or name fail */ +static void clk_parse_clkspec_with_incorrect_index_and_name(struct kunit *= test) +{ + struct clk_parse_clkspec_ctx *ctx =3D test->priv; + struct clk_hw *hw; + + /* Get clock by index */ + hw =3D of_clk_get_hw(ctx->cons_np, 2, NULL); + KUNIT_EXPECT_TRUE(test, IS_ERR(hw)); + + /* Get clock by name */ + hw =3D of_clk_get_hw(ctx->cons_np, 0, "third_clock"); + KUNIT_EXPECT_TRUE(test, IS_ERR(hw)); +} + +static struct kunit_case clk_parse_clkspec_test_cases[] =3D { + KUNIT_CASE(clk_parse_clkspec_with_correct_index_and_name), + KUNIT_CASE(clk_parse_clkspec_with_incorrect_index_and_name), + {} +}; + +/* Test suite to verify clk_parse_clkspec() */ +static struct kunit_suite clk_parse_clkspec_test_suite =3D { + .name =3D "clk_parse_clkspec", + .init =3D clk_parse_clkspec_init, + .test_cases =3D clk_parse_clkspec_test_cases, +}; =20 kunit_test_suites( &clk_assigned_rates_suite, &clk_hw_get_dev_of_node_test_suite, + &clk_parse_clkspec_test_suite, &clk_leaf_mux_set_rate_parent_test_suite, &clk_test_suite, &clk_multiple_parents_mux_test_suite, @@ -3562,4 +3671,5 @@ kunit_test_suites( &clk_uncached_test_suite, ); MODULE_DESCRIPTION("Kunit tests for clk framework"); +MODULE_IMPORT_NS("EXPORTED_FOR_KUNIT_TESTING"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/clk/kunit_clk_parse_clkspec.dtso b/drivers/clk/kunit_c= lk_parse_clkspec.dtso new file mode 100644 index 000000000000..c93feb93e101 --- /dev/null +++ b/drivers/clk/kunit_clk_parse_clkspec.dtso @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0 +/dts-v1/; +/plugin/; + +&{/} { + kunit_clock_provider1: kunit-clock-provider1 { + compatible =3D "test,clock-provider1"; + #clock-cells =3D <1>; + }; + + kunit_clock_provider2: kunit-clock-provider2 { + compatible =3D "test,clock-provider2"; + #clock-cells =3D <1>; + }; + + kunit-clock-consumer { + compatible =3D "test,clock-consumer"; + clocks =3D <&kunit_clock_provider1 0>, <&kunit_clock_provider2 0>; + clock-names =3D "first_clock", "second_clock"; + }; +}; --=20 2.54.0 From nobody Tue Sep 29 11:58:30 2026 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (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 E6BC237AA9A; Fri, 7 Aug 2026 15:24:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786116281; cv=none; b=kQY+jXB3TosvZIkEnyaoIQNSQNFVcVTptK7nbjJ78UTA5LrvMoQuzhmXKPC5G4RXabInUtrcjukknST35jvxPvXTQ/QW3gT767SE+fVev6j4Uq1GrF2J7oWuHz0r+34dKJNNGUic7sFACgT8f0+ApBMGz6o7qgss5zPjqWRF+1I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786116281; c=relaxed/simple; bh=HMRl4W5pDNAuAWEGA817OKkxGf4xWR2JD8IQfGRPkws=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Wu23bN2TrsXSaN4bFCD0h8oHsBAwa4nV9AUv2vsNwATbBxBSOUUUP69qvN14yUD7Kg+C8FlxX8ULBQmlOfb64tI75In4BxMmkteTs2bVhMwSQM7Vtoi8bPtpeCy5nry2TAxLTnoxqpVuewDNmcoZYWvTcQR8st7YQxlVkDClU5A= 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=jdBEShiN; arc=none smtp.client-ip=185.246.84.56 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="jdBEShiN" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 4655F1A14B1; Fri, 7 Aug 2026 15:24:38 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 1CA42603F0; Fri, 7 Aug 2026 15:24:38 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 7F9A611C37ABC; Fri, 7 Aug 2026 17:24:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1786116272; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=0a1N6Q/u1/SiB4FqpZQZYNJEWaehQaXGJU5sGi2JSUA=; b=jdBEShiN5nNOsEn0FxlUFMaBFRMsR1fSTwIfU/70y72ccrhSOucoJOtqUs268pCT69m6r5 IxXzSG0yIzJaUx4oAjfVfsQ/IFzStEBXry/deHEPJPxX5meRqlRYer/Hg9mD0jLpbZwdBf E/bzjuo6iRlz8A94k7B0IP9SK06CPcvTzqpulI8IRfRxAxuwhZ6Pq0dKP9sFD6bfVI8FwF /vxQXCvDDVZ7NG7QwBEJtnMK/I5lbcTsVWW0g6tvxEf4JW8dtJI9ID4O3g2TjPZ/34ROyl 9KwY4TlZlwyqlLT+wMu+gicyeiFhIBJFORzXimyBMuTWABSEOSCsFDjFsNvBgQ== From: "Miquel Raynal (Schneider Electric)" Date: Fri, 07 Aug 2026 17:24:04 +0200 Subject: [PATCH v5 3/7] clk: tests: Add Kunit testing for of_clk_get_parent_name() 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: <20260807-schneider-v7-2-rc1-eip201-upstream-v5-3-8785f9531cf0@bootlin.com> References: <20260807-schneider-v7-2-rc1-eip201-upstream-v5-0-8785f9531cf0@bootlin.com> In-Reply-To: <20260807-schneider-v7-2-rc1-eip201-upstream-v5-0-8785f9531cf0@bootlin.com> To: Michael Turquette , Stephen Boyd , Brian Masney , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Brendan Higgins , David Gow , Rae Moar Cc: Thomas Petazzoni , Pascal EBERHARD , Wolfram Sang , Fran Li , linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, "Miquel Raynal (Schneider Electric)" , Frank Li X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 Ensure this helper remains correct before making upcoming changes to it. Signed-off-by: Miquel Raynal (Schneider Electric) Reviewed-by: Brian Masney Reviewed-by: Frank Li --- drivers/clk/clk_test.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/clk/clk_test.c b/drivers/clk/clk_test.c index f47f81b7d72a..4084559e157d 100644 --- a/drivers/clk/clk_test.c +++ b/drivers/clk/clk_test.c @@ -3637,9 +3637,23 @@ static void clk_parse_clkspec_with_incorrect_index_a= nd_name(struct kunit *test) KUNIT_EXPECT_TRUE(test, IS_ERR(hw)); } =20 +/* + * Verify that of_clk_get_parent_name() returns the correct clock name when + * looking up by index through the consumer's clocks property. + */ +static void of_clk_get_parent_name_gets_parent_name(struct kunit *test) +{ + struct clk_parse_clkspec_ctx *ctx =3D test->priv; + const char *expected_name =3D "clk_parse_clkspec_1"; + + KUNIT_EXPECT_STREQ(test, expected_name, + of_clk_get_parent_name(ctx->cons_np, 0)); +} + static struct kunit_case clk_parse_clkspec_test_cases[] =3D { KUNIT_CASE(clk_parse_clkspec_with_correct_index_and_name), KUNIT_CASE(clk_parse_clkspec_with_incorrect_index_and_name), + KUNIT_CASE(of_clk_get_parent_name_gets_parent_name), {} }; =20 --=20 2.54.0 From nobody Tue Sep 29 11:58:30 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 4CF6E3F327A for ; Fri, 7 Aug 2026 15:24:42 +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=1786116283; cv=none; b=Cd3EPeV0C9cwL7Tax9so6rDRgVwb1Js8g1I0gRyg6sL7KVJilfKhkjU3wqEX8UcNEXDjE6JLP3BDquUiwm4UQ5uTLAb/LT2YDCoEi6Mh9LFo14wAuwaFiB/EVM9wnU6eJaRjAwjDRFAJz6eMvA2MporFNd1Tk78IZbzdMUYa4qc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786116283; c=relaxed/simple; bh=MKXF36B/N58wgTDVUubwpPnEsfYr+reCs2pY25QG5rc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ppcVaDTn5i/PFcfM/LX+pgM4PK2kHumy1itgNOf6n656ly/YAKn7LstrIsdq5X7H/rzcE7abhtYjVpJ5FlooVCdKnC0SkzUzGvgXeLkVdat1AXGYFRLE6SfVZRJvLDrdiTGm+iYNTGaW+1qE+RMN6xwmlc4v9KLI9nFUqk8J0pk= 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=THj0V2/l; 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="THj0V2/l" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id C44724E4113F; Fri, 7 Aug 2026 15:24:40 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 98A43603F0; Fri, 7 Aug 2026 15:24:40 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 25F0211C37ACB; Fri, 7 Aug 2026 17:24:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1786116279; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=nTJU2NJ54O6LZ0hZrhPZm1F5PCgRji3kSdkWz/GfYyE=; b=THj0V2/lEt+d7eiM9wXyfoibWmPpJ6QIwPLZccfCaUZzPY587sEipw5gT0eix9h8usmfs2 dLFSkPi97zpiG+XCKL9gLTIFt6KdYmWHsU9+7UuFYVkwenCmJc9cpBPTrEtsFUiUNFcCkM f1a1nnJlchv0GLonoNOeBc4DVEKA8sjgpdKkU/U8OhRSlKxrreVmlXrnur0VA3fHeZsjqM igcRUww6znmXkfX2wkotctB4pVdxBISCnp1DskSCB6UCl5VCNHQSzbcqDltgjn9KF0Hi9H F80zzEgsn2Ut2Ceeo2eEsSEhoC1kMlDtmlInw89YUfeAyYwBywybl8kfAnNYzA== From: "Miquel Raynal (Schneider Electric)" Date: Fri, 07 Aug 2026 17:24:05 +0200 Subject: [PATCH v5 4/7] clk: Improve a couple of comments 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: <20260807-schneider-v7-2-rc1-eip201-upstream-v5-4-8785f9531cf0@bootlin.com> References: <20260807-schneider-v7-2-rc1-eip201-upstream-v5-0-8785f9531cf0@bootlin.com> In-Reply-To: <20260807-schneider-v7-2-rc1-eip201-upstream-v5-0-8785f9531cf0@bootlin.com> To: Michael Turquette , Stephen Boyd , Brian Masney , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Brendan Higgins , David Gow , Rae Moar Cc: Thomas Petazzoni , Pascal EBERHARD , Wolfram Sang , Fran Li , linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, "Miquel Raynal (Schneider Electric)" X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 Avoid mentioning the function names directly in the comments, it makes them easily out of sync with the rest of the code. Use a more generic wording. Suggested-by: Stephen Boyd Signed-off-by: Miquel Raynal (Schneider Electric) Reviewed-by: Brian Masney Reviewed-by: Frank Li --- drivers/clk/clk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 08874cf9b561..7d63d81ebc09 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -5202,7 +5202,7 @@ static int of_parse_clkspec(const struct device_node = *np, int index, /* * For named clocks, first look up the name in the * "clock-names" property. If it cannot be found, then index - * will be an error code and of_parse_phandle_with_args() will + * will be an error code and the OF phandle parser will * return -EINVAL. */ if (name) @@ -5275,7 +5275,7 @@ of_clk_get_hw_from_clkspec(struct of_phandle_args *cl= kspec) * * This function looks up a struct clk from the registered list of clock * providers, an input is a clock specifier data structure as returned - * from the of_parse_phandle_with_args() function call. + * from the OF phandle parser. */ struct clk *of_clk_get_from_provider(struct of_phandle_args *clkspec) { --=20 2.54.0 From nobody Tue Sep 29 11:58:30 2026 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (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 09366470452; Fri, 7 Aug 2026 15:24:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786116286; cv=none; b=KaX1srzJvqguPfoeA/dShGk/eUtwWRSoEP39HXYPKSqRfH0qgkSUUavWb90ifylMCIyvnjLsQJ8NE9mWnxhMbBI8Ce+JmaVKF3ck8hUBYqgDPYlXDBmJFFY5LCgPqwJ7oI4sDe/alV3U6NZAPs2KM9dmWCf4CWGTh6aZ/lSWFIE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786116286; c=relaxed/simple; bh=4Z5ASawV7KvaJGtXSweO5js3deOZ/JggqDhMsZbkE18=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=cO7qu4M8o98aztQ4gr9EsZ7JPd0v1btkb12K+cR0klEGncOqoujZqRNCkQA9m3MavEqnVG4xjyWVU5NHcTRkSG45drlEzXHd0JGWiF3wc0WQtDlD6A9eJmJwgoAmmsFSE0w43EDTME/or1KDiMCLExDW3bbCW12w7WBxEp9+0XI= 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=DEt0ebtq; arc=none smtp.client-ip=185.246.84.56 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="DEt0ebtq" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 8074F1A14B1; Fri, 7 Aug 2026 15:24:43 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 4E86A603F0; Fri, 7 Aug 2026 15:24:43 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id AF18611C37AC5; Fri, 7 Aug 2026 17:24:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1786116281; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=rGYCq+VkQRoc47FpryIf69RRpxfv8Q4feCXJKvo5Yxs=; b=DEt0ebtqzzOXlYhNqD5Xysv8UVranXvWG7MS7pt8n0voeKQyKmmzuKnpLo1usy8cprZLtU DlTOeT7nLy3XUKaBY8uw7p5U3Qlh6Irt175JTlcX7d86iqowXkANnJ4R6xT6TYZPRkl5Rx Ak0Khj3zVAEgwD6/AZyuKzGT0pixRl2ejsK84+CU0FpsdKYKpm7VPNUxoVfZOQH3L5ZPXG vj1AEBaCkLmpk4jAYck/4cQCAHmfEzMs0AODBUVNAW+2er8/3fx8nJI/JoqVm3Df4V4r89 CN/3hvZJj63J4Rd7SGZI6hS6deo3FYSjwPWrz8Kk6s3FJUl6A5pqVMSo7XmGVw== From: "Miquel Raynal (Schneider Electric)" Date: Fri, 07 Aug 2026 17:24:06 +0200 Subject: [PATCH v5 5/7] clk: Use the generic OF phandle parsing in only one place 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: <20260807-schneider-v7-2-rc1-eip201-upstream-v5-5-8785f9531cf0@bootlin.com> References: <20260807-schneider-v7-2-rc1-eip201-upstream-v5-0-8785f9531cf0@bootlin.com> In-Reply-To: <20260807-schneider-v7-2-rc1-eip201-upstream-v5-0-8785f9531cf0@bootlin.com> To: Michael Turquette , Stephen Boyd , Brian Masney , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Brendan Higgins , David Gow , Rae Moar Cc: Thomas Petazzoni , Pascal EBERHARD , Wolfram Sang , Fran Li , linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, "Miquel Raynal (Schneider Electric)" X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 Ideally, there should be one single entry in the OF world. This way, the DT parsing logic is always identical. At this stage, we call of_parse_phandle_with_args() in: - of_parse_clkspec() - of_clk_get_parent_name() which kinds of defeats the above statement. Furthermore, when this call is done from of_clk_get_parent_name(), we fail to parse the 'clock-ranges' property. Make sure DT world is entered only once by calling of_parse_clkspec() from of_clk_get_parent_name(). Doing so implies that we do not try the "clock-ranges" path if we already found a "clocks" property. Suggested-by: Stephen Boyd Fixes: 4472287a3b2f5 ("clk: Introduce of_clk_get_hw_from_clkspec()") Signed-off-by: Miquel Raynal (Schneider Electric) Reviewed-by: Brian Masney Reviewed-by: Frank Li --- drivers/clk/clk.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 7d63d81ebc09..45f5d7a4ccc1 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -5219,6 +5219,8 @@ static int of_parse_clkspec(const struct device_node = *np, int index, * has a "clock-ranges" property, then we can try one of its * clocks. */ + if (of_property_present(np, "clocks")) + break; np =3D np->parent; if (np && !of_property_present(np, "clock-ranges")) break; @@ -5364,8 +5366,7 @@ const char *of_clk_get_parent_name(const struct devic= e_node *np, int index) int count; struct clk *clk; =20 - rc =3D of_parse_phandle_with_args(np, "clocks", "#clock-cells", index, - &clkspec); + rc =3D of_parse_clkspec(np, index, NULL, &clkspec); if (rc) return NULL; =20 --=20 2.54.0 From nobody Tue Sep 29 11:58:30 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 74245473C9A; Fri, 7 Aug 2026 15:24:51 +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=1786116293; cv=none; b=I0UrPdynJUrYtYuJfnsU3XZDjKYTeXNAvmkzZf9Tg0nJVTYc/nDlbqGV1QEVsZ9GLrWJU0AF/1r+Dekzg69+I1iPFKgzAkvMewcL5xiRS013os08gtlbAMGcRutQRJicIJw0pKSmHugVtoKt5UvdAKCEIAc1KtrwmMtEofIb1EI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786116293; c=relaxed/simple; bh=mbPH+yDTkyf4HUiYmumJ2FL11KCUrSAjeFTHGLRHd0o=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=f8M+m+bsU9H8pZgB/dJTcr99Frr3hi6OOzzsRGVNI8q4+x1hMJL0rGXIlryWcz8Zje/ltDZDTrNmJ84tMRhasUjQQjZ0x2OtodKCjcl+3GPcrD+wYqlIiH/XvW2I6SoMWMJYQkpiaXKRiB+lSJ73F57tAVmakWIXJrBt3xpxOQw= 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=caIolu1N; 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="caIolu1N" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id D07614E4113F; Fri, 7 Aug 2026 15:24:49 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 9F81E603F0; Fri, 7 Aug 2026 15:24:49 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 5387111C37AC6; Fri, 7 Aug 2026 17:24:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1786116284; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=0J1KxenFDZGUE5Mu6uRgHiDCQC8jHOcpWf/cSeow/Y4=; b=caIolu1Na/PpDGYENv7Kzh14HaLXbz+ERZZZqeFVr/rT+CA5SUg+GEPQ7juRX0r5d56Yqn KvV44q5fCrJrTgbQFeYTXv2DuBOBuVv/gmnUOf29HcU24O8JkxNPkF8Nr0nNLgMzI0bH44 fI7qU+rFLNEuBOthAxPAtsQz5RBSNra7TAV5llEljaD+t1SMDbsZzyz52vg9qqkQOvHtQA LGtfifx1zYQzb90KfZ1BSohjek8V9ehDo0xqQEd2DlRCJzrqz1QL1k+4pbs1OFmD+JWKPh m3gc4mmEp6C62/LBQAzFd7H0+35DQdOBLFKLA9c+qO/tk+CDy8KTy6IiC1jeDw== From: "Miquel Raynal (Schneider Electric)" Date: Fri, 07 Aug 2026 17:24:07 +0200 Subject: [PATCH v5 6/7] clk: Add support for clock nexus dt bindings 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: <20260807-schneider-v7-2-rc1-eip201-upstream-v5-6-8785f9531cf0@bootlin.com> References: <20260807-schneider-v7-2-rc1-eip201-upstream-v5-0-8785f9531cf0@bootlin.com> In-Reply-To: <20260807-schneider-v7-2-rc1-eip201-upstream-v5-0-8785f9531cf0@bootlin.com> To: Michael Turquette , Stephen Boyd , Brian Masney , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Brendan Higgins , David Gow , Rae Moar Cc: Thomas Petazzoni , Pascal EBERHARD , Wolfram Sang , Fran Li , linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, "Miquel Raynal (Schneider Electric)" , Herve Codina , Frank Li X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 A nexus node is some kind of parent device abstracting the outer connections. They are particularly useful for describing connectors-like interfaces but not only. Certain IP blocks will typically include inner blocks and distribute resources to them. In the case of clocks, there is already the concept of clock controller, but this usually indicates some kind of control over the said clock, ie. gate or rate control. When there is none of this, an existing approach is to reference the upper clock, which is wrong from a hardware point of view. Nexus nodes are already part of the device-tree specification and clocks are already mentioned: https://github.com/devicetree-org/devicetree-specification/blob/v0.4/source= /chapter2-devicetree-basics.rst#nexus-nodes-and-specifier-mapping Following the introductions of nexus nodes support for interrupts, gpios and pwms, here is the same logic applied again to the clk subsystem, just by transitioning from of_parse_phandle_with_args() to of_parse_phandle_with_args_map(): * Nexus OF support: commit bd6f2fd5a1d5 ("of: Support parsing phandle argument lists through a = nexus node") * GPIO adoption: commit c11e6f0f04db ("gpio: Support gpio nexus dt bindings") * PWM adoption: commit e71e46a6f19c ("pwm: Add support for pwm nexus dt bindings") Only expected Nexus property: - clock-map: maps inner clocks to inlet clocks (the other properties have been judged not relevant for clocks) Here is an example: Example: soc_clk: clock-controller { #clock-cells =3D <1>; }; container: container { #clock-cells =3D <1>; clock-map =3D <0 &soc_clk 2>, <1 &soc_clk 6>; child-device { clocks =3D <&container 1>; /* This is equivalent to <&soc_clk 6> */ }; }; The child device does not need to know about the outer implementation, and only knows about what the nexus provides. The nexus acts as a pass-through, with no extra control. Signed-off-by: Miquel Raynal (Schneider Electric) Reviewed-by: Herve Codina Reviewed-by: Brian Masney Reviewed-by: Frank Li --- drivers/clk/clk-conf.c | 12 ++++++------ drivers/clk/clk.c | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/clk/clk-conf.c b/drivers/clk/clk-conf.c index 303a0bb26e54..5380d43b56a4 100644 --- a/drivers/clk/clk-conf.c +++ b/drivers/clk/clk-conf.c @@ -25,8 +25,8 @@ static int __set_clk_parents(struct device_node *node, bo= ol clk_supplier) node); =20 for (index =3D 0; index < num_parents; index++) { - rc =3D of_parse_phandle_with_args(node, "assigned-clock-parents", - "#clock-cells", index, &clkspec); + rc =3D of_parse_phandle_with_args_map(node, "assigned-clock-parents", + "clock", index, &clkspec); if (rc < 0) { /* skip empty (null) phandles */ if (rc =3D=3D -ENOENT) @@ -47,8 +47,8 @@ static int __set_clk_parents(struct device_node *node, bo= ol clk_supplier) return PTR_ERR(pclk); } =20 - rc =3D of_parse_phandle_with_args(node, "assigned-clocks", - "#clock-cells", index, &clkspec); + rc =3D of_parse_phandle_with_args_map(node, "assigned-clocks", + "clock", index, &clkspec); if (rc < 0) goto err; if (clkspec.np =3D=3D node && !clk_supplier) { @@ -121,8 +121,8 @@ static int __set_clk_rates(struct device_node *node, bo= ol clk_supplier) rate =3D rates[index]; =20 if (rate) { - rc =3D of_parse_phandle_with_args(node, "assigned-clocks", - "#clock-cells", index, &clkspec); + rc =3D of_parse_phandle_with_args_map(node, "assigned-clocks", + "clock", index, &clkspec); if (rc < 0) { /* skip empty (null) phandles */ if (rc =3D=3D -ENOENT) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 45f5d7a4ccc1..6acf042673c3 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -5207,8 +5207,8 @@ static int of_parse_clkspec(const struct device_node = *np, int index, */ if (name) index =3D of_property_match_string(np, "clock-names", name); - ret =3D of_parse_phandle_with_args(np, "clocks", "#clock-cells", - index, out_args); + ret =3D of_parse_phandle_with_args_map(np, "clocks", "clock", + index, out_args); if (!ret) break; if (name && index >=3D 0) --=20 2.54.0 From nobody Tue Sep 29 11:58:30 2026 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (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 EB0294756CC; Fri, 7 Aug 2026 15:24:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786116299; cv=none; b=ERYwbf/VmFTj358CPD8nOA5688DG0s8/46ccTtrO4Z99J/t5g/7jVCM5bdifpzJHrPs8h9reSLN+deQzUHTYBW5hLWguL0+6ZHMknbaoPw3IVSzS1CsPhUi3diSXrbcgcFa4CAMMt/4qnFyOdS7dPKvTZuSCs7OzbHUimS0gaH8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786116299; c=relaxed/simple; bh=aUTcqhiQU+LOUtLD2na1hV1whG+qurl0iTsHGzzbspE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=eKWiWIE3rJmsjyMN65JB1tnBVn4eJEwswIVaUOgrEQ2GRoTnlkjvrVZvMOlblcmkLk/9GCgOoUFhmh5rLzSPcXOInbRvoUQ++9TTd6kQG5NyYPKaZXkRyV8FMigRcCT7Vo6dW1pFuF7zRNGh2JIIu1QRmm/1jmcKkwZJNdzwo2U= 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=stHaQoOx; arc=none smtp.client-ip=185.246.84.56 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="stHaQoOx" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 703E21A14B1; Fri, 7 Aug 2026 15:24:56 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 44B55603F0; Fri, 7 Aug 2026 15:24:56 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id B3F2711C37AC7; Fri, 7 Aug 2026 17:24:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1786116291; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=+5/knxcJlBUKp1ChAv/X70u7U7YXIDT3HlNZuqOXBIU=; b=stHaQoOxBxHlZaLiKKf2VjH+RdwQwxeFojyht4v8pBPJCtN1qq4fh8hA6YuODBSsKG1Wg4 TSCETC458omiK2bRllJHpKOj1wZVQnjvyiGWJotGdVxDgqEregoZqHlDt4JQk86MySpc/H 7pRecZ28M/7NvEtL8jrBw7Rst+TPa0E8ImTZ0PUx55AgRGdhvKZq4PaSqllMM1n8RSfEkb /2qHpnCUw2imX99n5p8Lpe2yPPr68qzSClH0pEKuPkQ9KggZHAvPWxkm1+knKx9Ic+mL5/ 6xgU1tBikn1MIES8qbcqJslfHZqBNOmu+0noQgEb72H6Ur557NuXXWynqv5WDg== From: "Miquel Raynal (Schneider Electric)" Date: Fri, 07 Aug 2026 17:24:08 +0200 Subject: [PATCH v5 7/7] clk: tests: Add Kunit testing for nexus nodes 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: <20260807-schneider-v7-2-rc1-eip201-upstream-v5-7-8785f9531cf0@bootlin.com> References: <20260807-schneider-v7-2-rc1-eip201-upstream-v5-0-8785f9531cf0@bootlin.com> In-Reply-To: <20260807-schneider-v7-2-rc1-eip201-upstream-v5-0-8785f9531cf0@bootlin.com> To: Michael Turquette , Stephen Boyd , Brian Masney , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Brendan Higgins , David Gow , Rae Moar Cc: Thomas Petazzoni , Pascal EBERHARD , Wolfram Sang , Fran Li , linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, "Miquel Raynal (Schneider Electric)" , Frank Li X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 Add a nexus node with a child requesting a mapped clock in the fake DT overlay to verify that the parsing is also correctly working. Create an of_find_node_by_name() like kunit helper to garbage collect the node automatically in case of failed assertion. Suggested-by: Stephen Boyd Signed-off-by: Miquel Raynal (Schneider Electric) Reviewed-by: Frank Li --- drivers/clk/clk_kunit_helpers.c | 31 ++++++++++++++++++++++++++++= +++ drivers/clk/clk_test.c | 15 +++++++++++++++ drivers/clk/kunit_clk_parse_clkspec.dtso | 10 ++++++++++ include/kunit/clk.h | 2 ++ 4 files changed, 58 insertions(+) diff --git a/drivers/clk/clk_kunit_helpers.c b/drivers/clk/clk_kunit_helper= s.c index 68a28e70bb61..ab6b2cffcad6 100644 --- a/drivers/clk/clk_kunit_helpers.c +++ b/drivers/clk/clk_kunit_helpers.c @@ -233,5 +233,36 @@ int of_clk_add_hw_provider_kunit(struct kunit *test, s= truct device_node *np, } EXPORT_SYMBOL_GPL(of_clk_add_hw_provider_kunit); =20 +KUNIT_DEFINE_ACTION_WRAPPER(of_node_put_wrapper, of_node_put, struct devic= e_node *); + +/** + * clk_of_find_node_by_name_kunit() - Test managed of_find_node_by_name() + * @test: The test context + * @from: Parent device node to start searching from, or NULL to search fr= om root + * @name: The name string to match against + * + * Just like of_find_node_by_name(), except the device_node is managed by + * the test case and is automatically put after the test case concludes. + * + * Return: the device_node on success, NULL if not found, or an error poin= ter on failure. + */ +struct device_node *clk_of_find_node_by_name_kunit(struct kunit *test, str= uct device_node *from, + const char *name) +{ + struct device_node *np; + int ret; + + np =3D of_find_node_by_name(from, name); + if (!np) + return NULL; + + ret =3D kunit_add_action_or_reset(test, of_node_put_wrapper, np); + if (ret) + return ERR_PTR(ret); + + return np; +} +EXPORT_SYMBOL_GPL(clk_of_find_node_by_name_kunit); + MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("KUnit helpers for clk providers and consumers"); diff --git a/drivers/clk/clk_test.c b/drivers/clk/clk_test.c index 4084559e157d..37e4137d37c9 100644 --- a/drivers/clk/clk_test.c +++ b/drivers/clk/clk_test.c @@ -3650,10 +3650,25 @@ static void of_clk_get_parent_name_gets_parent_name= (struct kunit *test) of_clk_get_parent_name(ctx->cons_np, 0)); } =20 +static void of_clk_get_hw_maps_thru_nexus(struct kunit *test) +{ + struct clk_parse_clkspec_ctx *ctx =3D test->priv; + struct clk_hw *expected; + struct device_node *np; + + np =3D clk_of_find_node_by_name_kunit(test, NULL, "kunit-clock-nexus-chil= d"); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, np); + expected =3D of_clk_get_hw(ctx->cons_np, 1, NULL); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, expected); + + KUNIT_EXPECT_PTR_EQ(test, expected, of_clk_get_hw(np, 0, NULL)); +} + static struct kunit_case clk_parse_clkspec_test_cases[] =3D { KUNIT_CASE(clk_parse_clkspec_with_correct_index_and_name), KUNIT_CASE(clk_parse_clkspec_with_incorrect_index_and_name), KUNIT_CASE(of_clk_get_parent_name_gets_parent_name), + KUNIT_CASE(of_clk_get_hw_maps_thru_nexus), {} }; =20 diff --git a/drivers/clk/kunit_clk_parse_clkspec.dtso b/drivers/clk/kunit_c= lk_parse_clkspec.dtso index c93feb93e101..a4115216d2aa 100644 --- a/drivers/clk/kunit_clk_parse_clkspec.dtso +++ b/drivers/clk/kunit_clk_parse_clkspec.dtso @@ -18,4 +18,14 @@ kunit-clock-consumer { clocks =3D <&kunit_clock_provider1 0>, <&kunit_clock_provider2 0>; clock-names =3D "first_clock", "second_clock"; }; + + kunit_clock_nexus: kunit-clock-nexus { + clocks =3D <&kunit_clock_provider2 0>; + clock-map =3D <&kunit_clock_provider2 0>; + #clock-cells =3D <0>; + + kunit-clock-nexus-child { + clocks =3D <&kunit_clock_nexus>; + }; + }; }; diff --git a/include/kunit/clk.h b/include/kunit/clk.h index f226044cc78d..0b5ab8e971c9 100644 --- a/include/kunit/clk.h +++ b/include/kunit/clk.h @@ -29,5 +29,7 @@ int of_clk_hw_register_kunit(struct kunit *test, struct d= evice_node *node, int of_clk_add_hw_provider_kunit(struct kunit *test, struct device_node *n= p, struct clk_hw *(*get)(struct of_phandle_args *clkspec, void *data), void *data); +struct device_node *clk_of_find_node_by_name_kunit(struct kunit *test, str= uct device_node *from, + const char *name); =20 #endif --=20 2.54.0