From nobody Thu Sep 18 05:26:21 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 9D0E0C4332F for ; Sun, 11 Dec 2022 02:57:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230039AbiLKC5b (ORCPT ); Sat, 10 Dec 2022 21:57:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229965AbiLKC5R (ORCPT ); Sat, 10 Dec 2022 21:57:17 -0500 Received: from codeconstruct.com.au (pi.codeconstruct.com.au [203.29.241.158]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E04113FA7; Sat, 10 Dec 2022 18:57:13 -0800 (PST) Received: by codeconstruct.com.au (Postfix, from userid 10000) id A6C6A20366; Sun, 11 Dec 2022 10:57:11 +0800 (AWST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codeconstruct.com.au; s=2022a; t=1670727431; bh=2KxYV7qUxfmM3CWkNEq3vFHfqI4ATKEVxtdwDMBLNnY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=hS6BXVkMEY41Wt/K6t1Z2qIvZ9AuamPWJ+GUMHue5nkJaSD1VzBXs80BwoRN7Te06 IrTKkIZMSk1DzVXZ/HY5RQ/OKlgAs+SJ/KHfkkdK0O1owKN7+6J9m4Sf+W/XH1UI6j 8yiY2n4z/pqZI+6uSNgNbhVPsHN6/IHC0LsGqzyicOmO7D8VUxNJiwFnGpcDEvfgaA SOY5RnB4r90PhrjRTG6Bcjn+PYW+UJR1UudQFGHK43A+oXSUtVLr+D9+SDL2UtPLjz 6sE/Chba2SUlvZ05ZRhkiesVRUjVqs9EaVil1Lir5EVeILUzZe2n/EcL/KBQ7BQGkZ U8JKJ4fUWzZ/g== 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: [RFC PATCH v3 2/2] mfd: syscon: allow reset control for syscon devices Date: Sun, 11 Dec 2022 10:57:00 +0800 Message-Id: <20221211025700.1180843-3-jk@codeconstruct.com.au> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221211025700.1180843-1-jk@codeconstruct.com.au> References: <20221211025700.1180843-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 --- 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..05e286a69dbe 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 { + ret =3D reset_control_deassert(reset); + if (ret) + goto err_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_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