From nobody Thu Sep 18 05:53:35 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 F0D3BC001B2 for ; Fri, 9 Dec 2022 01:33:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229915AbiLIBdi (ORCPT ); Thu, 8 Dec 2022 20:33:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229631AbiLIBd3 (ORCPT ); Thu, 8 Dec 2022 20:33:29 -0500 Received: from codeconstruct.com.au (pi.codeconstruct.com.au [203.29.241.158]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8DA786F70; Thu, 8 Dec 2022 17:33:27 -0800 (PST) Received: by codeconstruct.com.au (Postfix, from userid 10000) id 2F05820203; Fri, 9 Dec 2022 09:33:22 +0800 (AWST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codeconstruct.com.au; s=2022a; t=1670549602; bh=oPERloVDACX37C/EgAVnKfvFY7AD1n20mfLsVbn2Wrk=; h=From:To:Subject:Date:In-Reply-To:References; b=RYi4g9RZnovzNqtlqDppYdmbhj54VvJ45Ob+87b7qqkRac2SGPF2fdEdy0P/VIOMz 5voE2Ph0fkIW13xnZRqIuF4ttPSxDKyzaYdvsILAcn2z0DqyTchIYRH4R91EYhHlJO srxdMZ9uOWKE41VYCRG0TJ93KwzcSvWQE0y8CygNN4H+xroQ9eYrea6dgUf51smhxC MFdheASfsQgaq5+6qNoj7pf8WAdmHD0fX6o6GxgvXotcvN146zECF1ThOQUUjLyNqE e/QbO0TeOoSm1/rR9KMFGcIh1yN264fJ5EU3HVT5LfmKETXMrSTpY8aKAquWpyfh07 F3FS5qgViMFmw== From: Jeremy Kerr To: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Lee Jones , Rob Herring , Krzysztof Kozlowski , Arnd Bergmann , Philipp Zabel , Mark Brown Subject: [RFC PATCH v2 1/3] dt-bindings: mfd/syscon: Add resets property Date: Fri, 9 Dec 2022 09:33:07 +0800 Message-Id: <20221209013309.407879-2-jk@codeconstruct.com.au> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221209013309.407879-1-jk@codeconstruct.com.au> References: <20221209013309.407879-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 Reviewed-by: Arnd Bergmann --- 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.35.1 From nobody Thu Sep 18 05:53:35 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 C7839C4332F for ; Fri, 9 Dec 2022 01:33:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229841AbiLIBdc (ORCPT ); Thu, 8 Dec 2022 20:33:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229612AbiLIBd2 (ORCPT ); Thu, 8 Dec 2022 20:33:28 -0500 Received: from codeconstruct.com.au (pi.codeconstruct.com.au [203.29.241.158]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C244D86F5C; Thu, 8 Dec 2022 17:33:27 -0800 (PST) Received: by codeconstruct.com.au (Postfix, from userid 10000) id 7EE852024C; Fri, 9 Dec 2022 09:33:22 +0800 (AWST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codeconstruct.com.au; s=2022a; t=1670549602; bh=IkGVS2PJsNQ8Fz8xWlYZQ0kWD9mENnWbK7wsUfipyCE=; h=From:To:Subject:Date:In-Reply-To:References; b=W5dBrtKGyoCUCd2wO3m9YX5eKIvbdHgOV3OvhM0Ad67I9VCz+f9jvHn3fP6Py9XEt B202ka2cyxF+FK/Ngv2HiV72noahjwOhwBnDtodvIM+zi6EItTEvw96JMQ5i9Gq8E9 Gwrd/FlNL8JI7gBerXXviTKdteA7sRMvgQvFSFQgpBe7/7ZdtZp9rlcQWTEJbRsa9n 0FEonYEXcpJaoR7j1CxT2GBNZ20qvzbWVX3cFT8Zh8B93qAxEDkketEB393+Y7rQE0 OaTInq6Pb7QyZ/2tWUnijhtPWC9xNpsWrBF4JJHgIp9Kf5/Au1zEK3tYAB9EztKDc0 E8w+Id42UfUZg== From: Jeremy Kerr To: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Lee Jones , Rob Herring , Krzysztof Kozlowski , Arnd Bergmann , Philipp Zabel , Mark Brown Subject: [RFC PATCH v2 2/3] regmap: mmio: allow reset control in a MMIO regmap Date: Fri, 9 Dec 2022 09:33:08 +0800 Message-Id: <20221209013309.407879-3-jk@codeconstruct.com.au> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221209013309.407879-1-jk@codeconstruct.com.au> References: <20221209013309.407879-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" A syscon device may need to be taken out of reset before functioning - this change adds a facility to attach a reset control to a mmio regmap, and performs the necessary deassert/assert operations on the reset controller on attach/detach. Signed-off-by: Jeremy Kerr Reviewed-by: Arnd Bergmann --- drivers/base/regmap/regmap-mmio.c | 22 ++++++++++++++++++++++ include/linux/regmap.h | 3 +++ 2 files changed, 25 insertions(+) diff --git a/drivers/base/regmap/regmap-mmio.c b/drivers/base/regmap/regmap= -mmio.c index 3ccdd86a97e7..e2611de73b42 100644 --- a/drivers/base/regmap/regmap-mmio.c +++ b/drivers/base/regmap/regmap-mmio.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -22,6 +23,8 @@ struct regmap_mmio_context { bool attached_clk; struct clk *clk; =20 + struct reset_control *reset; + void (*reg_write)(struct regmap_mmio_context *ctx, unsigned int reg, unsigned int val); unsigned int (*reg_read)(struct regmap_mmio_context *ctx, @@ -633,4 +636,23 @@ void regmap_mmio_detach_clk(struct regmap *map) } EXPORT_SYMBOL_GPL(regmap_mmio_detach_clk); =20 +int regmap_mmio_attach_reset(struct regmap *map, struct reset_control *res= et) +{ + struct regmap_mmio_context *ctx =3D map->bus_context; + + ctx->reset =3D reset; + + return reset_control_deassert(ctx->reset); +} +EXPORT_SYMBOL_GPL(regmap_mmio_attach_reset); + +void regmap_mmio_detach_reset(struct regmap *map) +{ + struct regmap_mmio_context *ctx =3D map->bus_context; + + reset_control_assert(ctx->reset); + ctx->reset =3D NULL; +} +EXPORT_SYMBOL_GPL(regmap_mmio_detach_reset); + MODULE_LICENSE("GPL v2"); diff --git a/include/linux/regmap.h b/include/linux/regmap.h index ca3434dca3a0..b0c7a747c06f 100644 --- a/include/linux/regmap.h +++ b/include/linux/regmap.h @@ -34,6 +34,7 @@ struct spmi_device; struct regmap; struct regmap_range_cfg; struct regmap_field; +struct reset_control; struct snd_ac97; struct sdw_slave; =20 @@ -1150,6 +1151,8 @@ bool regmap_ac97_default_volatile(struct device *dev,= unsigned int reg); =20 int regmap_mmio_attach_clk(struct regmap *map, struct clk *clk); void regmap_mmio_detach_clk(struct regmap *map); +int regmap_mmio_attach_reset(struct regmap *map, struct reset_control *res= et); +void regmap_mmio_detach_reset(struct regmap *map); void regmap_exit(struct regmap *map); int regmap_reinit_cache(struct regmap *map, const struct regmap_config *config); --=20 2.35.1 From nobody Thu Sep 18 05:53:35 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 9E60DC4332F for ; Fri, 9 Dec 2022 01:33:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229932AbiLIBdm (ORCPT ); Thu, 8 Dec 2022 20:33:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229643AbiLIBd3 (ORCPT ); Thu, 8 Dec 2022 20:33:29 -0500 Received: from codeconstruct.com.au (pi.codeconstruct.com.au [203.29.241.158]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8D2A86F66; Thu, 8 Dec 2022 17:33:27 -0800 (PST) Received: by codeconstruct.com.au (Postfix, from userid 10000) id DAF5B21689; Fri, 9 Dec 2022 09:33:22 +0800 (AWST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codeconstruct.com.au; s=2022a; t=1670549602; bh=arOEJsM/yx+o1Y+f81ge85whdOVlDOd7/7bivSC46z8=; h=From:To:Subject:Date:In-Reply-To:References; b=YLyrgmMag9QrLadwsXZCXpKtNZ9cAdK3Miagysxb39wkRrREMV6fQC6Nj5PBcngt+ WPTa1D9q3HdJN4pDzJKHi7VyRwqLN5PekDCvTPaywzl4rjshJBp78QjE7o0wzXSbBo k4rL58FSDnFa0fwQCOfY1gB3w78ZkSLEzLalcYX2c8Mlc6ZrlD+QxE4oWFN4mAUrf1 K4sri46vNwpb842p5h4ulUTE0fwqJPCYXzCb+bAgSzenusjDIhdFVezab8pV08hZxf ikWS3a13GGLepRIt6c65EJAniQwK65uLuq5Cmel+wTqpm7U91ITBduSJuFrqHP4kVV 65efjLWTFHVfw== From: Jeremy Kerr To: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Lee Jones , Rob Herring , Krzysztof Kozlowski , Arnd Bergmann , Philipp Zabel , Mark Brown Subject: [RFC PATCH v2 3/3] mfd: syscon: allow reset control for syscon devices Date: Fri, 9 Dec 2022 09:33:09 +0800 Message-Id: <20221209013309.407879-4-jk@codeconstruct.com.au> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221209013309.407879-1-jk@codeconstruct.com.au> References: <20221209013309.407879-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 code to perform the deassertion/assertion on probe/remove. 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. --- 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..6b99488d05a6 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,7 +127,17 @@ 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; + } else if (reset) { + ret =3D regmap_mmio_attach_reset(regmap, reset); + if (ret) + goto err_attach_reset; } } =20 @@ -137,7 +150,9 @@ static struct syscon *of_syscon_register(struct device_= node *np, bool check_clk) =20 return syscon; =20 -err_attach: +err_attach_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.35.1