From patchwork Sun Dec 11 02:56:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Kerr X-Patchwork-Id: 32128 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1599932wrr; Sat, 10 Dec 2022 19:30:35 -0800 (PST) X-Google-Smtp-Source: AA0mqf43IyuraMsEaoOcN/ph/KZc6HXBgevbDLJttE1qohnO+QdgOCOuRYuXFRBPct2OrOGDYOm5 X-Received: by 2002:a17:902:ab07:b0:189:529d:a464 with SMTP id ik7-20020a170902ab0700b00189529da464mr11295465plb.17.1670729435612; Sat, 10 Dec 2022 19:30:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670729435; cv=none; d=google.com; s=arc-20160816; b=hC9ryLPQPsN2SA57OCT92uIqu37u/l8HM/yRn+XYxoXE2kPmAZI7+SFdgdQu2mmunA o34Krm+JTlhd85ei5TplTt+vv7MAOWqaLFtlDTckND4eTJjYxSUOCjC7q6ADpko9vJff rDHOYGZqaQRjZ6gg47WKpMWHaCET8g8qQ8sB5BUvuseQMSsmBGjO2J2gyR5tZzJ5evK5 6PhqRnYwgn60wFAwWqUuPtnVfYw4N1C+DZADG8T9Fz9EIXVFpij3xiZLr9dJEGta9Ptn jceO0Js8nsAsCTrssTqlnU1+5Xiq6pPVXr4JOW/MyhIwepPYMzJBk3RY4N2NfZ0RXXEv iFzg== 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=oPERloVDACX37C/EgAVnKfvFY7AD1n20mfLsVbn2Wrk=; b=r8vxoWAVnZy2ddVqoSFMTXCja8YD7xasq6uTe2/yaTO1gd6LHwxncuAXnQ5YaZ1TYy Ki6hhV3iFP9bJWnz/eSJ7oFOk0OTfjg62LEFgu6Qy8AgGdr6b/srOIyB0prwKHIU2FmC GM7yZdjsPr3dROYu5H85GsY3ILZUgNu1LAgoZP0Pzcw8oswOnIVAqnruouYAIhz0DJE+ pA35Nj1Mvcwt7k5U8zocT4K92MLyxHaSH8wasbbDsja5YKrHXs145osbcUiT2bq/ZR5p n7LwdlRPyLUrp3H2HGlFvjOOkpgBRkKvVWxBzajIW/wB7nH0AU1A7OsYpvjODS9gIO1Q NMrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeconstruct.com.au header.s=2022a header.b="MkK/2c2i"; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f21-20020a170902f39500b00186bc66d2cdsi5259326ple.75.2022.12.10.19.30.21; Sat, 10 Dec 2022 19:30:35 -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="MkK/2c2i"; 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 S230025AbiLKC5Z (ORCPT + 99 others); Sat, 10 Dec 2022 21:57:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229560AbiLKC5P (ORCPT ); Sat, 10 Dec 2022 21:57:15 -0500 Received: from codeconstruct.com.au (pi.codeconstruct.com.au [203.29.241.158]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1EEB113FA2; Sat, 10 Dec 2022 18:57:12 -0800 (PST) Received: by codeconstruct.com.au (Postfix, from userid 10000) id 4A10E20354; 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=oPERloVDACX37C/EgAVnKfvFY7AD1n20mfLsVbn2Wrk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=MkK/2c2iyP1MybzC0kOXMHe226O5SponW1t/oUZMVXW99ewF1hn4lTcOfdJJ36kf4 zPyseAjirHZk2G40uqxk44kfnOczYdKR88TbIH8y0TUInk72qF4eObWpP7cxhAaGj4 cnLH8R6inZ8uJr1Iryf94u2emiB953IM/MucptwWX2i/gSwTMgAuRjCtFkj4Sdx8df 0bTeKlTTvj2ikxyrFQa4ABK6HGas1fbOtptAITrkkI6ZH9AyL2glfBx5qlKzoH6+TR iFQ92JEAvHMS2MdDWraupl/n7oMGWxSoPEXdAa/JuVmx3HJtGKXotMhkyg1QTvjclq ClADiaWq5IxSQ== 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 1/2] dt-bindings: mfd/syscon: Add resets property Date: Sun, 11 Dec 2022 10:56:59 +0800 Message-Id: <20221211025700.1180843-2-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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751886788630622170?= X-GMAIL-MSGID: =?utf-8?q?1751886788630622170?= 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/Documentation/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] + resets: + maxItems: 1 + hwlocks: maxItems: 1 description: From patchwork Sun Dec 11 02:57:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Kerr X-Patchwork-Id: 32127 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1599695wrr; Sat, 10 Dec 2022 19:29:37 -0800 (PST) X-Google-Smtp-Source: AA0mqf6mpczPCgWGGKfyyktN7IgQ2kdt5CRjzT22Lw5tb1AqyCdpsSvqK/Jbxjqv0hAFGkvAua2w X-Received: by 2002:a62:7bd2:0:b0:576:f334:6740 with SMTP id w201-20020a627bd2000000b00576f3346740mr13767454pfc.23.1670729377628; Sat, 10 Dec 2022 19:29:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670729377; cv=none; d=google.com; s=arc-20160816; b=Qm+WroXmKZFYBbF7k2XGXzhZnC+CHnUfUXHbFfxYniRkgrCWOPOqwJEqs9mMYHuHkm lZnt6a0XR8ynmQQWYE00MhsPtSZH7Dnv3QyP5wYCBILQeFUrjzizKQm6t6uVh9EU9ir+ 3amN1fDffDNk0SnlyS4eBXHPIaQ4mnNnLmEsPJsv+SrswKZt9afVR2Y0B44NazCku1X6 4hLpcw8oqEQ4ESQHv4291Q8xFj9GpV9DzrPQo9k0INSCxnYtt/vjfn0Ksx8nuJI9zMc5 ZJ25jyLxBOPUif27zZ2PQo5hgIVxVJP8WeZEJ2pNa/72J7fclSqBRp2FPzJOFWIBZw1z VHaA== 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 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.29.18; Sat, 10 Dec 2022 19:29:37 -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 + 99 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751886727973317999?= X-GMAIL-MSGID: =?utf-8?q?1751886727973317999?= 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 @@ -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);