Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp13528436rwl; Wed, 4 Jan 2023 09:18:36 -0800 (PST) X-Google-Smtp-Source: AMrXdXvj3XBprCCRWqUtcv+lnHON0K25hjsxMrK+I5U/Ela6sZcwZlSwfOe8LMe/GaiVU089++Qs X-Received: by 2002:a05:6402:cb4:b0:483:6d73:ad02 with SMTP id cn20-20020a0564020cb400b004836d73ad02mr39973184edb.35.1672852716701; Wed, 04 Jan 2023 09:18:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672852716; cv=none; d=google.com; s=arc-20160816; b=BpshCtUieMCLX8tfGwrkMjWolMYSkhWMiVx1CDI+fFQKGMgf57IGW4cx7ldp6LL+M2 2fXx/4Y0fBMC2H38hpDgRIJaNhcpW0kHwDINcVLP1pec68N807kI2YkCTibbWd5S//Ml GOo52R4lKjVJOPLneYuLsEaUurM6hrb/XgEj2DV+wq+sLST+ViEzWZqrxEF1xyJjIg0p N3h1Vjd567vZUX1mdtZdCWiigwzJTR1mJ+1kMk45MUmroKxCNaiOs4pTTiN2MYbyuDdy h4OcFicv7snA/Qz52eXyYpEeGTOOVTuOQdR4tAa+g3wapMmMi3tugB6iaOYDswGGLOi6 mmqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=YZKQoCbg+dGw8jgO9sO5GdokgxQ2ke7NqRquQVM6xSw=; b=bGdgOLltDxOJGMDixfXSH2aAYRc6SVj6uN4z2Ec4NLmxlWTzF8qWKMaS4szp/sjJDD SoxTPKw65QkzAJ3zJJ5muwpEUFYXtGrI4XRKvEIN8bwl/hyPgRP39RjX4WC2J/nil39W a1sGNCCQ+RFsyIS3qUd28g9fMKAcgGZppnGB7IQ6FBSokPTn99OR6tk+8FGmgmm5uK7j zbJ55M0umyMvJMqWk4sZdPyy9KVvL7O+MneHmZTpyXq1qSNbBQGRLxO3BSI6U+ZKSY1V gGMqREdKiPot2TK6bPTupbyb0nZurDsvCWM1BJx72MbC6A9XXjvc3Zr8mSxp/CsoneDe E9XQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Yflc5IqA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b20-20020a056402279400b00484d2a31c84si26237794ede.473.2023.01.04.09.18.23; Wed, 04 Jan 2023 09:18:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Yflc5IqA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240084AbjADQ5y (ORCPT + 57 others); Wed, 4 Jan 2023 11:57:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240356AbjADQ5V (ORCPT ); Wed, 4 Jan 2023 11:57:21 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96A81C00; Wed, 4 Jan 2023 08:55:01 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3434B617B3; Wed, 4 Jan 2023 16:55:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 401AFC433EF; Wed, 4 Jan 2023 16:54:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1672851300; bh=PRT9pyRYXkxTWpB3lRIbo0OKaSnhV5A3KNAJsop1Qhw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Yflc5IqAZB+mr3pTNLZaIWWHnHQzKqJIK8gXyn7fIxTuSZ4pUmH878QlnmTz4dfcX 56gjGE+gKKaNFA2Kj3+Zb3FQGICuY9nJnXJTR/DweCBmGXxJxGRecoDldf9SU0xSJN 9u7O/9gNnMelBN0OGIQHou0lTsXgBDa0wIFG+UgR3RPxyK0PJMNIc8hq28zAqHzlXQ Rw+qvFzlrE294xQFEAoWefHhFGC4Q9mMo9NVfcdS06OG38R/5w8N0IHUdo9CIUaadz bVOKG187B8Y/3ZYdUC/WqqYfiN/MrXtEXMJ/r+7TJz9P/ER+bK3tsbWfIBzKPXStEv vgW8OsZGYnIJA== Date: Wed, 4 Jan 2023 16:54:53 +0000 From: Lee Jones To: Jeremy Kerr Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Rob Herring , Krzysztof Kozlowski , Arnd Bergmann , Philipp Zabel , Mark Brown Subject: Re: [RFC PATCH v3 2/2] mfd: syscon: allow reset control for syscon devices Message-ID: References: <20221211025700.1180843-1-jk@codeconstruct.com.au> <20221211025700.1180843-3-jk@codeconstruct.com.au> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20221211025700.1180843-3-jk@codeconstruct.com.au> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 11 Dec 2022, Jeremy Kerr wrote: > 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 > > --- > 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 > > @@ -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; > }; > > @@ -40,7 +42,7 @@ static const struct regmap_config syscon_regmap_config = { > .reg_stride = 4, > }; > > -static struct syscon *of_syscon_register(struct device_node *np, bool check_clk) > +static struct syscon *of_syscon_register(struct device_node *np, bool check_res) > { > struct clk *clk; > struct syscon *syscon; > @@ -50,6 +52,7 @@ static struct syscon *of_syscon_register(struct device_node *np, bool check_clk) > int ret; > struct regmap_config syscon_config = syscon_regmap_config; > struct resource res; > + struct reset_control *reset; > > syscon = 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; > } > > - if (check_clk) { > + if (check_res) { > clk = of_clk_get(np, 0); > if (IS_ERR(clk)) { > ret = PTR_ERR(clk); > @@ -124,7 +127,17 @@ static struct syscon *of_syscon_register(struct device_node *np, bool check_clk) > } else { > ret = regmap_mmio_attach_clk(regmap, clk); > if (ret) > - goto err_attach; > + goto err_attach_clk; > + } > + > + reset = of_reset_control_get_optional_exclusive(np, NULL); > + if (IS_ERR(reset)) { > + ret = PTR_ERR(reset); > + goto err_attach_clk; > + } else { > + ret = reset_control_deassert(reset); > + if (ret) > + goto err_reset; > } The else is superfluous, right? Arnd, besides this are you happy with the patch? -- Lee Jones [李琼斯]