From patchwork Tue Dec 6 07:39:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Kerr X-Patchwork-Id: 631415 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 ACAFFC352A1 for ; Tue, 6 Dec 2022 07:56:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230280AbiLFH4T (ORCPT ); Tue, 6 Dec 2022 02:56:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231882AbiLFH4K (ORCPT ); Tue, 6 Dec 2022 02:56:10 -0500 X-Greylist: delayed 603 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Mon, 05 Dec 2022 23:56:06 PST Received: from codeconstruct.com.au (pi.codeconstruct.com.au [203.29.241.158]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36C4D164BD; Mon, 5 Dec 2022 23:56:05 -0800 (PST) Received: by codeconstruct.com.au (Postfix, from userid 10000) id 44EC52024D; Tue, 6 Dec 2022 15:39:53 +0800 (AWST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codeconstruct.com.au; s=2022a; t=1670312393; bh=lP2H0rsOAxY33TRBDl1BU0Pc1uc9tW/ct6bXhJl98YA=; h=From:To:Subject:Date:In-Reply-To:References; b=K6hrDV+xVhnjOZBiyvJ2zqEafHBgRPN/SET/47guQ2zGTVqOckq2wQ59RnRAFDhwe 5l07IPlnI0JvNjP8vOrr2LaaTlw8bocAXmi9G6WLy+9NASQwLAtFw7lw8DeOqeuDhm oBEXDkK3pV8ZiRsTaATSUuSzvuUJttenoayK+AprI1MwfMMkhb+kYejCVKiKPDb+X/ H2YOMmkgyHDlm+FmhNbSaouS6eNgoKcOw3V73qNAoHKkW5OQQ2VcBI/cVYL8pLMmth v8NGHrqwVK3JKuuPbqdgw583E2fY+iBNgm2gZUcXLveVXqIucIG0XIZF4/tYUM7j17 pMNCQNpzZSEGA== From: Jeremy Kerr To: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Lee Jones , Rob Herring , Krzysztof Kozlowski , Arnd Bergmann , Philipp Zabel Subject: [RFC PATCH 2/2] mfd: syscon: allow reset control for syscon devices Date: Tue, 6 Dec 2022 15:39:16 +0800 Message-Id: <20221206073916.1606125-3-jk@codeconstruct.com.au> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221206073916.1606125-1-jk@codeconstruct.com.au> References: <20221206073916.1606125-1-jk@codeconstruct.com.au> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@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 code to perform the deassertion/assertion on probe/remove. Signed-off-by: Jeremy Kerr --- drivers/mfd/syscon.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c index bdb2ce7ff03b..a0483dbfe17a 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; }; @@ -280,6 +282,7 @@ static int syscon_probe(struct platform_device *pdev) struct regmap_config syscon_config = syscon_regmap_config; struct resource *res; void __iomem *base; + int rc; syscon = devm_kzalloc(dev, sizeof(*syscon), GFP_KERNEL); if (!syscon) @@ -302,13 +305,32 @@ static int syscon_probe(struct platform_device *pdev) return PTR_ERR(syscon->regmap); } + syscon->reset = devm_reset_control_get_optional_exclusive(&pdev->dev, + "reset"); + if (IS_ERR(syscon->reset)) + return PTR_ERR(syscon->reset); + platform_set_drvdata(pdev, syscon); + rc = reset_control_deassert(syscon->reset); + if (rc) { + dev_err(dev, "failed to deassert reset line! rc: %d\n", rc); + return rc; + } + dev_dbg(dev, "regmap %pR registered\n", res); return 0; } +static int syscon_remove(struct platform_device *pdev) +{ + struct syscon *syscon = platform_get_drvdata(pdev); + + reset_control_assert(syscon->reset); + return 0; +} + static const struct platform_device_id syscon_ids[] = { { "syscon", }, { } @@ -319,6 +341,7 @@ static struct platform_driver syscon_driver = { .name = "syscon", }, .probe = syscon_probe, + .remove = syscon_remove, .id_table = syscon_ids, };