From nobody Tue Sep 16 08:51:53 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B23E4C54EF1 for ; Thu, 5 Jan 2023 00:55:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229871AbjAEAzF (ORCPT ); Wed, 4 Jan 2023 19:55:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230203AbjAEAyh (ORCPT ); Wed, 4 Jan 2023 19:54:37 -0500 Received: from codeconstruct.com.au (pi.codeconstruct.com.au [203.29.241.158]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B3714D701; Wed, 4 Jan 2023 16:51:16 -0800 (PST) Received: by codeconstruct.com.au (Postfix, from userid 10000) id 190672009B; Thu, 5 Jan 2023 08:51:13 +0800 (AWST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codeconstruct.com.au; s=2022a; t=1672879873; bh=adaPG21LWF9KYARFKo+io9g1sMsGa7P4yZ1kIRb0M64=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=KZQagnkHgmxQydGGTXtq2J8RFLX5lYyQOOYNo62WuH3oPBh7P4tNBcUPzfBzJhx/P VvtzsTaAq8NlVRzKbqHAY1fpu/X6f9ukwKjyO9ND7YBtlpJdBMddC+lZqJejdfgOgv Y89wOkCOe5heYXdyNN+n2zArq6l/1qMKYAGsbkMLr3M/gymM5w4WEKOkIb/Q5rPH73 0whgAU8fyHBUC3C32uYLU3QXAN2fYFt3xGo3iKmAFCNzHygNgPd/wT+o6KQYJuvyRh SZtQP9H3f/y3FFz9Jce/UhuqOz+NNykpnc9CfnkQi96Pq7nu0JM9I8njO+PTV01mAN g0wWcH/fzWmyw== From: Jeremy Kerr To: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Lee Jones , Rob Herring , Krzysztof Kozlowski , Arnd Bergmann , Philipp Zabel Cc: Mark Brown Subject: [PATCH v4 1/2] dt-bindings: mfd/syscon: Add resets property Date: Thu, 5 Jan 2023 08:50:09 +0800 Message-Id: <20230105005010.124948-2-jk@codeconstruct.com.au> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230105005010.124948-1-jk@codeconstruct.com.au> References: <20230105005010.124948-1-jk@codeconstruct.com.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Simple syscon devices may require deassertion of a reset signal in order to access their register set. This change adds the `resets` property from reset.yaml#/properties/resets (referenced through core.yaml), specifying a maxItems of 1 for a single (optional) reset descriptor. This will allow a future change to the syscon driver to implement reset control. Signed-off-by: Jeremy Kerr Acked-by: Rob Herring --- Documentation/devicetree/bindings/mfd/syscon.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Documentation/devicetree/bindings/mfd/syscon.yaml b/Documentat= ion/devicetree/bindings/mfd/syscon.yaml index 4e4baf53796d..9dc5984d9147 100644 --- a/Documentation/devicetree/bindings/mfd/syscon.yaml +++ b/Documentation/devicetree/bindings/mfd/syscon.yaml @@ -86,6 +86,9 @@ properties: on the device. enum: [1, 2, 4, 8] =20 + resets: + maxItems: 1 + hwlocks: maxItems: 1 description: --=20 2.38.1 From nobody Tue Sep 16 08:51:53 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D3305C63705 for ; Thu, 5 Jan 2023 00:55:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230058AbjAEAzL (ORCPT ); Wed, 4 Jan 2023 19:55:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230200AbjAEAyh (ORCPT ); Wed, 4 Jan 2023 19:54:37 -0500 Received: from codeconstruct.com.au (pi.codeconstruct.com.au [203.29.241.158]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B6A54D703; Wed, 4 Jan 2023 16:51:16 -0800 (PST) Received: by codeconstruct.com.au (Postfix, from userid 10000) id 792B42009C; Thu, 5 Jan 2023 08:51:13 +0800 (AWST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codeconstruct.com.au; s=2022a; t=1672879873; bh=oGzHlhvKu9MG2lDbw6ME4o3WTMdvBXmIXCmnIL+e+rQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=DLoCE100DP2DbxiNXqV8H+nw/lnpheQm+cfr88kdqK48nPtgTVkgT5fg2FWmgiabN t7RH3pfkmR9qmjjZllC/2KPJ6mJHdpvyMiXcx90uAJi0R/sO0xn56kPmc8XARI0Akv tuq8e+fhOtKUkie8c3s0Xckdrdr7Qlg949tEZ2SkxEibEMl4vSQ0gY8hs6V0l3smbB cA7yeGDGByOKDmftPmyD88IfeqwvQy/MrREwZutPHSXfxd8eJehOVHY4ZMZjkRlqj9 ZgKrM0eNQgMcsoTJeiuqAoao8D9yI/8nmZbd0Ll24KtyPKZUVLOaynrn0cJiq+3abN t8gCpVAIhhlAw== From: Jeremy Kerr To: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Lee Jones , Rob Herring , Krzysztof Kozlowski , Arnd Bergmann , Philipp Zabel Cc: Mark Brown Subject: [PATCH v4 2/2] mfd: syscon: allow reset control for syscon devices Date: Thu, 5 Jan 2023 08:50:10 +0800 Message-Id: <20230105005010.124948-3-jk@codeconstruct.com.au> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230105005010.124948-1-jk@codeconstruct.com.au> References: <20230105005010.124948-1-jk@codeconstruct.com.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Simple syscon devices may require deassertion of a reset signal in order to access their register set. Rather than requiring a custom driver to implement this, we can use the generic "resets" specifiers to link a reset line to the syscon. This change adds an optional reset line to the syscon device description, and deasserts the reset if detected. Signed-off-by: Jeremy Kerr Reviewed-by: Arnd Bergmann --- v2: * do reset control in the early of_syscon_register() path, rather than the platform device init, which isn't used. v3: * use a direct reset_control_deassert rather than handling in the regmap v4: * collapse unnecessary `else` block --- drivers/mfd/syscon.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c index bdb2ce7ff03b..57b29c325131 100644 --- a/drivers/mfd/syscon.c +++ b/drivers/mfd/syscon.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include =20 @@ -31,6 +32,7 @@ static LIST_HEAD(syscon_list); struct syscon { struct device_node *np; struct regmap *regmap; + struct reset_control *reset; struct list_head list; }; =20 @@ -40,7 +42,7 @@ static const struct regmap_config syscon_regmap_config = =3D { .reg_stride =3D 4, }; =20 -static struct syscon *of_syscon_register(struct device_node *np, bool chec= k_clk) +static struct syscon *of_syscon_register(struct device_node *np, bool chec= k_res) { struct clk *clk; struct syscon *syscon; @@ -50,6 +52,7 @@ static struct syscon *of_syscon_register(struct device_no= de *np, bool check_clk) int ret; struct regmap_config syscon_config =3D syscon_regmap_config; struct resource res; + struct reset_control *reset; =20 syscon =3D kzalloc(sizeof(*syscon), GFP_KERNEL); if (!syscon) @@ -114,7 +117,7 @@ static struct syscon *of_syscon_register(struct device_= node *np, bool check_clk) goto err_regmap; } =20 - if (check_clk) { + if (check_res) { clk =3D of_clk_get(np, 0); if (IS_ERR(clk)) { ret =3D PTR_ERR(clk); @@ -124,8 +127,18 @@ static struct syscon *of_syscon_register(struct device= _node *np, bool check_clk) } else { ret =3D regmap_mmio_attach_clk(regmap, clk); if (ret) - goto err_attach; + goto err_attach_clk; } + + reset =3D of_reset_control_get_optional_exclusive(np, NULL); + if (IS_ERR(reset)) { + ret =3D PTR_ERR(reset); + goto err_attach_clk; + } + + ret =3D reset_control_deassert(reset); + if (ret) + goto err_reset; } =20 syscon->regmap =3D regmap; @@ -137,7 +150,9 @@ static struct syscon *of_syscon_register(struct device_= node *np, bool check_clk) =20 return syscon; =20 -err_attach: +err_reset: + reset_control_put(reset); +err_attach_clk: if (!IS_ERR(clk)) clk_put(clk); err_clk: @@ -150,7 +165,7 @@ static struct syscon *of_syscon_register(struct device_= node *np, bool check_clk) } =20 static struct regmap *device_node_get_regmap(struct device_node *np, - bool check_clk) + bool check_res) { struct syscon *entry, *syscon =3D NULL; =20 @@ -165,7 +180,7 @@ static struct regmap *device_node_get_regmap(struct dev= ice_node *np, spin_unlock(&syscon_list_slock); =20 if (!syscon) - syscon =3D of_syscon_register(np, check_clk); + syscon =3D of_syscon_register(np, check_res); =20 if (IS_ERR(syscon)) return ERR_CAST(syscon); --=20 2.38.1