From nobody Sat Jul 25 04:55:57 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 CC347348C5E; Fri, 17 Jul 2026 15:59:33 +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=1784303975; cv=none; b=Ht3V8BcB3oh7S/6XnU4QaHI5TMHXn3LV2m9O+xBoJs/Nz6jcqes13onbnv2IsaG9HLd1aejuIULvtLIbUXxATACHeexG05mkDNGRnFOaMszc64Zcv9HUACq6jIERfwNNDKj8SKntPEOviJSe84G8EMumIoY5mPKSnP0TDxiaupY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784303975; c=relaxed/simple; bh=fvKp3muxqLO3ZXsRvobuXHT61jNJWSsEw3PxHdgAIVI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=YiGwRe1yK6QFMhAJD1e6joQnbr0Hc1F+S2vKEwJ7czucKLHh5/+8sigpAMiByBaZMNPR7em1bOiFkZ+Cn85YQXad1/yyzr3YXG1eIxmK3JRCiGtPz3P5qeLGOnUavPIIaAzDUcvI4+l6jSWbZ06Z/09DiA7/IOv+Dh4yBCXAoVc= 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=S6pbyxKU; 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="S6pbyxKU" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 6772C4E40E20; Fri, 17 Jul 2026 15:59:32 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 3AE9760361; Fri, 17 Jul 2026 15:59:32 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 0D28311BD0C60; Fri, 17 Jul 2026 17:59:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1784303970; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=R5Jti0bTgzxOr6073sChkcLCtqN2FPsmeK2o9HwQWUI=; b=S6pbyxKUUkegm8iJSNU6ruPxGyYcZRMIEegA8vBhm/p1F9XBXi8saP1ruwbNbCG/Ah69lE GgHd4N1kG7SYApAX0tvx7M37WzeO1wT7bSmu25+ypN/82fRnkOGVvgzqnkI7NYR5ZrSmqk PFM9aqLhB668PiSHz275CAJMdd7Am1CWbYxQA31DLUQJ7x/+lOA07S7ZRfAT5lLBjbBOb0 WbTUBro6Zno7hiXz1KRx03ya1Ppl5pFvVNGzQtQieVMMSFdD+7oPSbAjNgvmPvlOdb3cTv RxCL5ql7SG4RkgWJJaWhB0Cd3DXcEbaJleuI3Tn9tpoV6dhH8ohUq75hzCuQeg== From: "Miquel Raynal (Schneider Electric)" Date: Fri, 17 Jul 2026 17:59:17 +0200 Subject: [PATCH v4 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: <20260717-schneider-v7-2-rc1-eip201-upstream-v4-1-751547e160e5@bootlin.com> References: <20260717-schneider-v7-2-rc1-eip201-upstream-v4-0-751547e160e5@bootlin.com> In-Reply-To: <20260717-schneider-v7-2-rc1-eip201-upstream-v4-0-751547e160e5@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 , 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 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: Frank Li Reviewed-by: Rob Herring (Arm) --- .../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 Sat Jul 25 04:55:57 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 08D162949E0; Fri, 17 Jul 2026 15:59:35 +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=1784303977; cv=none; b=Fkfp/dmCQg14365SiW2noPbqwSTcIRJskp7PLtWEqTfGSdSCpkFRkxuOBLoSyUxsG0yiOlyy22uKbzrmWCmY8lW6S6+q5vTXnPHvcV8dFKJtWn5ApB1XSYskOhYPvN9lp64WSBNZUR3S50eWWozEoSilFRMSIZcB0TOfQyvdwQo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784303977; c=relaxed/simple; bh=K6mdiLxOtIIXWui+pm/umvXk35rEZd3mqjI8z6U7u/w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=K+mwMHnDzBr9UDsQadwm7jTSHx/BACO7XRNj95nAefbj0puh/m6MVhmXq90VWPbcaJFVePCnZbbUL4zC/Gj7xnCDuErxGViU0kcCOHD3ho1lkItkEFHrCAq8aVe4LLUE3mbt94/95elR269OpXXUAYkCCOlzi7ITj6ADt9IATwU= 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=M3lUZEEI; 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="M3lUZEEI" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 831FF1A105C; Fri, 17 Jul 2026 15:59:34 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 5826F60361; Fri, 17 Jul 2026 15:59:34 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 7AF4811BD1C16; Fri, 17 Jul 2026 17:59:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1784303973; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=z9D2f9uQYMAsaU7FuXwgFztKPQtGEZyj2SRcTopOA/Y=; b=M3lUZEEIjOSwaLUprH395DB6wIPpTPEs/uhrrfSa14MsbgN7A9L4ACghjNECKpWNYH7Nge zD1e04yUgABOWYNTpOk66mPqBI8NsaFdni5OFpwf1mxpEfLYI6fEokWni5ZNsSmx9Uvyol 6Xm5FP3hAu99RtZPR4BONDPxxI1cV6avcjVaYUcxzZL23ZcSzf5raembCJoy3b9SH+Vxjh gDJlHIty80TAPeDtCGxPvkq8ksFBkGeObWlfwE0TvXVweHbT7s8v6J67hrmoY7VituezhE FdFxbxCnMqyQWmxTjAnIfGW3fTRjtB7c/m+ImDBWXpekp3wn1y8PbHounqU2Ww== From: "Miquel Raynal (Schneider Electric)" Date: Fri, 17 Jul 2026 17:59:18 +0200 Subject: [PATCH v4 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: <20260717-schneider-v7-2-rc1-eip201-upstream-v4-2-751547e160e5@bootlin.com> References: <20260717-schneider-v7-2-rc1-eip201-upstream-v4-0-751547e160e5@bootlin.com> In-Reply-To: <20260717-schneider-v7-2-rc1-eip201-upstream-v4-0-751547e160e5@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 , 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 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 Sat Jul 25 04:55:57 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 499123ED125; Fri, 17 Jul 2026 15:59:38 +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=1784303979; cv=none; b=WmvSKTC67A059CveIY8EQptldj9VRvQz1g0XE+5zXKEoKziIRMrLtediQyYNtyce4aQVwzPmB7tbZnButgqfe/bBQbHPzn5LUT5iHrBgR2GyD7sixL0/RmlI6YifQ3f0Z8O76v//+ltKwz4oTkxB/9S8wPx0UGM96EFZoH8Cnlw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784303979; c=relaxed/simple; bh=WDtVLHn1TfK0EyDDUA+3N6yMy6JzwOzeEo8zYmSOCqE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=W9b3DHb3UzPbq7FB2lGIjR3jWCSgHTdqowEH+YeI9rmUQCN2q5bKSodTUf8qTojTrK1w3snNxBr5To1KkYorNrTJb2r+QUvBmyFeG4RXlER6eFz3Sl+ZzSqtIfBeD93qQLp1rXVpX449wdSK7ocDIMFYTKlGIyjI/fjHuycW83o= 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=Rnti3WNj; 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="Rnti3WNj" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id BEF231A1068; Fri, 17 Jul 2026 15:59:36 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 92BBC60361; Fri, 17 Jul 2026 15:59:36 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id B467F11BD04D0; Fri, 17 Jul 2026 17:59:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1784303975; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=mhYSjNdEm8uNctigqOpdn31Q0IRlbVuoAOk9I7KUjjE=; b=Rnti3WNjH5FgND6qxhFnehB5XhctNp/6hB6v3PfNOp9IzlArk2FHcqW57ROekX4hzDYDiM dhUg+Asod2VXXY5BJPncqzgMpfMdnChhbHndRnsCTtZYk6mkcW/GWqTFfuBbN9YQ3beJfU /ERUzpItRNRbwC/dTYhXzThCSGcZE4G1/gcd/Jnh1cmqOGbS5T/YPFHQm6CcRZSezSjjq2 LjsePJ8TNyu/otUWfkbEvze/sV8Nnm2da4b4NA26JAMWzaGjFBHoaChfvIHYH5FY/DC6nI zcr18IjWDcDhMn8KA8iuHVPfllzvbzt3jM6YgJBXlpe39pcCcpP34asgg7nQ8w== From: "Miquel Raynal (Schneider Electric)" Date: Fri, 17 Jul 2026 17:59:19 +0200 Subject: [PATCH v4 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: <20260717-schneider-v7-2-rc1-eip201-upstream-v4-3-751547e160e5@bootlin.com> References: <20260717-schneider-v7-2-rc1-eip201-upstream-v4-0-751547e160e5@bootlin.com> In-Reply-To: <20260717-schneider-v7-2-rc1-eip201-upstream-v4-0-751547e160e5@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 , 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 Make sure this helper is never broken, especially since we will soon make some changes in 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 Sat Jul 25 04:55:57 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 7947D3F86E9; Fri, 17 Jul 2026 15:59:40 +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=1784303981; cv=none; b=bHJqlJNi+c7slAsoCcT/B4eJRgmJMzvq82R9Dks5Dx3E8x+Yq10M5BLWsVJqaML8w0eal4a+QIrMSpe9eEzMJjkugBZ/iO9LBdwXxzpj5UG3ul9wLMFqb4daRALwgny9oHvgPn2WUxQGA0lElrM4zvVUUpb8GXbfgHRr+EAUSfI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784303981; c=relaxed/simple; bh=MKXF36B/N58wgTDVUubwpPnEsfYr+reCs2pY25QG5rc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=iMklsw3t8wIiZDbu3T4KGj3/ySY40vmQbxLPR3WtUpazjpgFhSiu8s+mh2LEcomM7lpwhzHi449HY6BWikWjMM4LmAz9S5nwYlvFEWtfdEuuLzxa39O83ymyTchyYUKxyjS8HIkLa7yJ8t6bvgAdrzJY1LJ/BCrzf9Lb1MWGdw8= 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=ENfkWLNP; 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="ENfkWLNP" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 1073F4E40E1F; Fri, 17 Jul 2026 15:59:39 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id D15C460361; Fri, 17 Jul 2026 15:59:38 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 045A811BD24CC; Fri, 17 Jul 2026 17:59:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1784303977; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=nTJU2NJ54O6LZ0hZrhPZm1F5PCgRji3kSdkWz/GfYyE=; b=ENfkWLNPkmygmMIs23aGd3fYVn3bSCWJySnpK9WfgoiWGnQqk2fRlMryfVur1HBfwb+8iO 6LMeI604HJZ7QgR+q/aIHfPJTFie1REbyKWha8g1zpIqyPnifNXQJmkLhTr0FGD8otkzKR mNP7JdQJzOCYhgDmQ+qY9ZO3ys0qookPoGQslaXqJOROK04PIBeQowCtHLYsfu3z+PGhhh zPNOz1gOlNWcypNki9WtqL/Fh7eVhpOqw54AUBRrM7r6baznnUlpeyhhlOK3p98sgD85kg gJAtGFbq//75NS7XLd0rDWsqdITz+JDPGBP0xX0TEAb8fNTc3bQ1kmKnJJGW5g== From: "Miquel Raynal (Schneider Electric)" Date: Fri, 17 Jul 2026 17:59:20 +0200 Subject: [PATCH v4 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: <20260717-schneider-v7-2-rc1-eip201-upstream-v4-4-751547e160e5@bootlin.com> References: <20260717-schneider-v7-2-rc1-eip201-upstream-v4-0-751547e160e5@bootlin.com> In-Reply-To: <20260717-schneider-v7-2-rc1-eip201-upstream-v4-0-751547e160e5@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 , 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 --- 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 Sat Jul 25 04:55:57 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 B69D5373BE0; Fri, 17 Jul 2026 15:59:42 +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=1784303984; cv=none; b=NIcs1fpPaZp0QBo3v8NvmH287XVpIFQIigxTdevq234Mz7IwKw6oW5/5jcvGRytJT4BbwXE3eHgxuVs1Sp1Zthrto+o45JlYU7iBQtQ/8A51DFSytVmOGDV7K73z9M0LHHqKwreZJG/xfFpGjWTjpRPykO0zls9JYY8/rlMJhlE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784303984; c=relaxed/simple; bh=Tqp+lD/Qo+lPH96YWjh5/wMkb1+okgFfH7rhHhQyk/c=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=NNba/UUX3sS/ABAjJBelwRbSKEM8gk9dXC0XCzaJmDPZKHRedFC3eXk99meC+UYqDnSXGF0FUIEM/l14kcaZ9vV9DyEVvJAKw/dmMRmhbN1xabMW6uigcblQbUQOCLXkURJyGzQ6blhfDg0AgNX/9M2Y5GPhDzy/dpYoO7/1MH8= 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=XtEU+0Tw; 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="XtEU+0Tw" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 34F1D1A1063; Fri, 17 Jul 2026 15:59:41 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 083B960361; Fri, 17 Jul 2026 15:59:41 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 33DCE11BD0C60; Fri, 17 Jul 2026 17:59:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1784303979; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=Ql/DV6EXuqLRczapfEXXJkUpHBEjgtfedq/CXp/PoQY=; b=XtEU+0TwkxFGqHy1CuPILeSr3uwNoeqpQP7JqPxNSTogUDQj3B2v3dKObDH1P58iEqqU2d s59tjl74JPJxSbAwnOAH/bZyqsU1e7prTZc3gy+ndHHuBEybfFAEbteS2j7yqa0kgV/+8D 4ohx7Ve9PD8yEau/471h4BMUNXWyN4Hw32luuBUa235cc+oWxy/rRR0BE38EP7rsb6KxVr X6AD9Py3rEtA+nh3xoHqmpliSLMreyHD2ML7MKpGPmKdOIMR15Oj2tCHhzM5p4pZHz1+r1 /sDQAvzeJhh3ci/B9EqG4rfydRmUFo6o81AwKQZqi/O7z8I4wogrKVnzIX71CA== From: "Miquel Raynal (Schneider Electric)" Date: Fri, 17 Jul 2026 17:59:21 +0200 Subject: [PATCH v4 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: <20260717-schneider-v7-2-rc1-eip201-upstream-v4-5-751547e160e5@bootlin.com> References: <20260717-schneider-v7-2-rc1-eip201-upstream-v4-0-751547e160e5@bootlin.com> In-Reply-To: <20260717-schneider-v7-2-rc1-eip201-upstream-v4-0-751547e160e5@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 , 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 There should be one single entry in the OF world, so that the way we parse the DT is always the same. make sure this is the case by avoid calling of_parse_phandle_with_args() from of_clk_get_parent_name(). This is even more relevant as we currently fail to parse clock-ranges. As a result, it seems to be safer to directly call of_parse_clkspec() there, but 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 --- 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 Sat Jul 25 04:55:57 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 05CB234DCE3; Fri, 17 Jul 2026 15:59: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=1784303986; cv=none; b=j2sBLPXP92lxRCcV9emaIzxV5k6nJAes165/74+XRmI0VSksCuF+u2nm67CXhh+ZRagkmIKVynt3WAHI0vTTWj5m0gP71y2kKMz17If7GP4cIt3/IAgwDotBp8ocGqxYDDibx9h5fThrjduanEsnduas/mpziv/duIUvtT/u3hw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784303986; c=relaxed/simple; bh=b0CjsGb9kmZAexs7MyDMPW3zIAktW4SRGSXoUoyHCfY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mkxwIer2YtlnBkBSZ7n2bs+YDO+7ks3l9+3W/qBPqMWBDsm6aaU5OctyIAhntmkTu6kPHbwRrfCJeBFLKHyeCMUKv8fAapBOFXZjeb0h0kNloKWB8DqqCEYAZEM1KK4InVD9eSjltkTpfeNtB0Dmpij5Dc45f+uvnAqEIWWgc20= 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=Agr1VXsY; 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="Agr1VXsY" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 79D3E1A105C; Fri, 17 Jul 2026 15:59:43 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 4D89E60361; Fri, 17 Jul 2026 15:59:43 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 4492511BD2559; Fri, 17 Jul 2026 17:59:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1784303982; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=GZjpVe6V41AU3xoNOUQIWWRtJ354RHz718O41QQI6RQ=; b=Agr1VXsYmfDTklNs+QtsICYZWm/eaDazC3YTC9kQitME1t2EjHVHz+9JXZICh0tNDxvQ6T B7ySet8C62itDMd/DDbH4mAq8VifPqCDmM7K4K1mtBHF7ASZvlLq1bo5r14JzJVGAjW0PH qRikV6h6IW7SmC1FL0pyKzpw+8OCXYrixWP5Kvw6qVISK865uV4MRL61rdaWJZYPi5P3+3 /DI6EeUlKKoUzt72KvS32r+U1YhycsEL81P5vEnNoLMiuu5hxDjxauEvQAqDuoZIGoKpyS rpRkiNKWPY9fYLE7FL+xZHiRPTdzLi1y7tVPQ0yOdxUrwwdoI8CfuOr+qlLWOQ== From: "Miquel Raynal (Schneider Electric)" Date: Fri, 17 Jul 2026 17:59:22 +0200 Subject: [PATCH v4 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: <20260717-schneider-v7-2-rc1-eip201-upstream-v4-6-751547e160e5@bootlin.com> References: <20260717-schneider-v7-2-rc1-eip201-upstream-v4-0-751547e160e5@bootlin.com> In-Reply-To: <20260717-schneider-v7-2-rc1-eip201-upstream-v4-0-751547e160e5@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 , 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 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 Sat Jul 25 04:55:57 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 DE3872F6591; Fri, 17 Jul 2026 15:59:46 +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=1784303988; cv=none; b=SKnQFSorXQ+amlVp7ad+B7n0vsxy0RUoJ8sDVubl5jWaa450+oKaEKVWizqX5TUb6ukM+npZ0pahnRDJyMFTmfCfOkOigecDyP5PSd9H69CHSmY4WUw5ACcJMZriOgYtGdRshbo4ygf835z5q93jM/cTNEuG5XE2GQDKu1f8gO4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784303988; c=relaxed/simple; bh=hm5zNnEPwqUONrgyk4Vb0mT5qLt2h29Hef++RAqWOzs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=NO0L/bBzauRoBfUrGcWa9pT5GhAuDeWZ9UJBhFD/sOs44EUTkrDtYhuXe0OSZeTWbZejBo6aueM0trzPU7Fd4Za85wF5kVNf1SEuuxWMiQ9P0dEk930NODkUX8A1JVJgnY/b09ya2nw0WxHx8hrDLBPiosLSCN4jPbXeqXjHlok= 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=MGnhFktf; 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="MGnhFktf" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 6CB891A1063; Fri, 17 Jul 2026 15:59:45 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 3FEB760361; Fri, 17 Jul 2026 15:59:45 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id B0BBB11BD2635; Fri, 17 Jul 2026 17:59:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1784303984; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=6dmtcyA4tztmbUkoOE4VBkGPmZReS7qFIfSkMOL+N4U=; b=MGnhFktfZKyovY4JpuAXpg7FBR54ypoh67L/HHl+m5ZXh6Tlrm0zvrQv4zjMs8U5XcrRB9 L3w0AvIBe94Q6hVSCJA/DsEsJc9pRlP/PzTdsFMjMHJMw5y0cv5vA9/rF6zXvVE/8aeLpx R2l7PR6KYUtp84nJ5ILmLwUg0pZaDRUp+FFikpilnOAxMo19+kdHbLFA0rclYk+IMCpSc/ TVyyAxPQEu9LrcLWDNZx5D7J4ceYUGncIGxzikTUJFd7TnErZK5q74po3HSdHZxCYCXAND 0BSn3WoU3LewNSmEphAUq94viKF6V8gqbDStoBzEVbMKnSniE/xvlgbwu847Ww== From: "Miquel Raynal (Schneider Electric)" Date: Fri, 17 Jul 2026 17:59:23 +0200 Subject: [PATCH v4 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: <20260717-schneider-v7-2-rc1-eip201-upstream-v4-7-751547e160e5@bootlin.com> References: <20260717-schneider-v7-2-rc1-eip201-upstream-v4-0-751547e160e5@bootlin.com> In-Reply-To: <20260717-schneider-v7-2-rc1-eip201-upstream-v4-0-751547e160e5@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 , 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 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..daaf1cf1546c 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 *); + +/** + * 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_noded 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 a negative er= rno value on failure. + */ +struct device_node *of_find_node_by_name_kunit(struct kunit *test, struct = 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(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..0c2f1efdaa8e 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 of_find_node_by_name_kunit(test, NULL, "kunit-clock-nexus-child"); + 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..ab24f7747516 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 *of_find_node_by_name_kunit(struct kunit *test, struct = device_node *from, + const char *name); =20 #endif --=20 2.54.0