Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp4952765rwb; Sat, 10 Dec 2022 19:30:21 -0800 (PST) X-Google-Smtp-Source: AA0mqf5kc3AjJboFHcDTDof/ya2mKTBksPk47tWOu9TPubvJNCaIJ0E73bOTyLgj8naxBx6k/9tx X-Received: by 2002:a05:6a00:1953:b0:56c:f21f:5e0d with SMTP id s19-20020a056a00195300b0056cf21f5e0dmr15166789pfk.3.1670729421181; Sat, 10 Dec 2022 19:30:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670729421; cv=none; d=google.com; s=arc-20160816; b=Q5zPy9KIpyfPpKwMQcI1sLy6Op0W7iqj02pXhLwPN0cnZohalDCzsurdrD4s3OV+V1 Ivk+63eH2nXbrZqVwqs/Db1EiznHusOZyOgZSGfPt3j3G9AIRflxRE+NAU+uPdQqXLY6 j5r9oxvQRMZfrGuGBj3Yp49vzBeRNqE6fjhzZqQLm8OSsEQoRQdi9TQe6OqtmbxwPJ4Z Yr8xKUBi/IBskoVQngFQmSR9PcCapQsErO3M71tK3h3v5vqLaZD4Bhd0VDfiySrxreN3 LkmaIiZts+P9PE0+3OMf3tBkXUxKjfkDiYFyGhdEGIo4EJOTr3F+dXBxjnGo3JCqMoiB ZddQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2KxYV7qUxfmM3CWkNEq3vFHfqI4ATKEVxtdwDMBLNnY=; b=EwALg3bWLZ4jK6trEmvGaVbRxeokNIRp69f9cG+QKhJ91iUyA/GstFXvFQhRJEDwZ8 OnmQzEfaanUH7JO6KA19l9xlLqOtI+HtgdslnF0CwmuYWd2d6ZBUOgIeCqfoZ6uTRjPR zRFyx3HORz02MaLrq8HqR15bW5ZPfANR4MOW9lEyik7KLK6+b9EhBHXzeTdR5CgWOFIR 1tZSl6VWeRBA6SL0icfIQSNhq+wdrTqmtkkFHi43Xq3X4R7So+qD1JhZFla6+eAs9PNN YbPGP8zIoJ0r2W759BxrPHiaVB8YdSjxqJqKa70Vb45jUpY8tBdw+3uVTBJWMEGcLROC FPEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeconstruct.com.au header.s=2022a header.b=hS6BXVkM; 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=codeconstruct.com.au Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y29-20020a056a001c9d00b00567719e34aesi5768663pfw.49.2022.12.10.19.30.08; Sat, 10 Dec 2022 19:30:21 -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=@codeconstruct.com.au header.s=2022a header.b=hS6BXVkM; 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=codeconstruct.com.au Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230037AbiLKC5a (ORCPT + 76 others); Sat, 10 Dec 2022 21:57:30 -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: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,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 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; } } @@ -137,7 +150,9 @@ static struct syscon *of_syscon_register(struct device_node *np, bool check_clk) return syscon; -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) } static struct regmap *device_node_get_regmap(struct device_node *np, - bool check_clk) + bool check_res) { struct syscon *entry, *syscon = NULL; @@ -165,7 +180,7 @@ static struct regmap *device_node_get_regmap(struct device_node *np, spin_unlock(&syscon_list_slock); if (!syscon) - syscon = of_syscon_register(np, check_clk); + syscon = of_syscon_register(np, check_res); if (IS_ERR(syscon)) return ERR_CAST(syscon); -- 2.35.1