From patchwork Fri Dec 9 01:33:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Kerr X-Patchwork-Id: 31578 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp529267wrr; Thu, 8 Dec 2022 17:56:08 -0800 (PST) X-Google-Smtp-Source: AA0mqf7zSCER1nAlnzOR9bieYbtndcIqQK1SwjxxrqBxgRyp0fYz2COlNjVIab4ZznesF8aBpsOu X-Received: by 2002:a50:ed0a:0:b0:46b:19ab:68d8 with SMTP id j10-20020a50ed0a000000b0046b19ab68d8mr4098515eds.40.1670550968476; Thu, 08 Dec 2022 17:56:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670550968; cv=none; d=google.com; s=arc-20160816; b=L3JhObnWAWu3v8+uFuqGeOQ0WAqrXY0Owa452qpqPBIbNELwOCNtJ+0XHepZEhjrOc bCTD2i7hshj+DjySlVu094/0z1gnpJK9vWpC68+dgEbAvi/1pxrFRvLK73Jyo/IlrcKo N92+Qna5ejaP0cpXeKy7IDlMDE7yVopRntjZeDCleaypdCJc+cIY1e0H/r8VYh2xjdwC cfuQvRnLJUYFCh3HUkZYkGr+6DWvx8UhdfjuEeHIGuCpaph7n/4P3x1nyAKDKgqYvrT/ z6AyrfdbkC68L0Ax2h6osT9KB4ILD/XlyfOWfJz0avXXfai0i7YeCWvVSL9qJb7Tm/ir enxA== 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:to:from :dkim-signature; bh=oPERloVDACX37C/EgAVnKfvFY7AD1n20mfLsVbn2Wrk=; b=za91PZnu0GhoCCyH40D+lOQMbMNqfJlezvA0leDMoogskjMsfq3D1fCN+LCi8HJ6q1 2KCzIogcp4UEcDvt6QgqNSvw5GU4bxybaixDRS6onLlBetL39568zK5ubjw/uA5HbjKk 3TOjaz6cUUd9pLJuuzgJuh1cf/YUo7Sks6QIU8FSE+CiJc8sVjY7pj/kH0fIGjVPOZ4j 4y6YzN8rEEJP87CPCUL+3ExfbMSqTRs8bOu4XTmUDdJHWeSzccqMMNceKYnmrMg1OXCS WRo+6uyKfg1tjIR+ZKa1ziK7rpmI1hw9uBSLyvVrhvPU6o3LGrbFJ83XRGbi2WXAEJrO mAFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeconstruct.com.au header.s=2022a header.b=RYi4g9RZ; 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 h17-20020a05640250d100b00468b9d932c6si292413edb.258.2022.12.08.17.55.45; Thu, 08 Dec 2022 17:56:08 -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=RYi4g9RZ; 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 S229910AbiLIBdh (ORCPT + 99 others); Thu, 8 Dec 2022 20:33:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229631AbiLIBd3 (ORCPT ); Thu, 8 Dec 2022 20:33:29 -0500 Received: from codeconstruct.com.au (pi.codeconstruct.com.au [203.29.241.158]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8DA786F70; Thu, 8 Dec 2022 17:33:27 -0800 (PST) Received: by codeconstruct.com.au (Postfix, from userid 10000) id 2F05820203; Fri, 9 Dec 2022 09:33:22 +0800 (AWST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codeconstruct.com.au; s=2022a; t=1670549602; bh=oPERloVDACX37C/EgAVnKfvFY7AD1n20mfLsVbn2Wrk=; h=From:To:Subject:Date:In-Reply-To:References; b=RYi4g9RZnovzNqtlqDppYdmbhj54VvJ45Ob+87b7qqkRac2SGPF2fdEdy0P/VIOMz 5voE2Ph0fkIW13xnZRqIuF4ttPSxDKyzaYdvsILAcn2z0DqyTchIYRH4R91EYhHlJO srxdMZ9uOWKE41VYCRG0TJ93KwzcSvWQE0y8CygNN4H+xroQ9eYrea6dgUf51smhxC MFdheASfsQgaq5+6qNoj7pf8WAdmHD0fX6o6GxgvXotcvN146zECF1ThOQUUjLyNqE e/QbO0TeOoSm1/rR9KMFGcIh1yN264fJ5EU3HVT5LfmKETXMrSTpY8aKAquWpyfh07 F3FS5qgViMFmw== From: Jeremy Kerr To: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Lee Jones , Rob Herring , Krzysztof Kozlowski , Arnd Bergmann , Philipp Zabel , Mark Brown Subject: [RFC PATCH v2 1/3] dt-bindings: mfd/syscon: Add resets property Date: Fri, 9 Dec 2022 09:33:07 +0800 Message-Id: <20221209013309.407879-2-jk@codeconstruct.com.au> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221209013309.407879-1-jk@codeconstruct.com.au> References: <20221209013309.407879-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?1751699652276769706?= X-GMAIL-MSGID: =?utf-8?q?1751699652276769706?= 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 Fri Dec 9 01:33:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Kerr X-Patchwork-Id: 31576 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp528968wrr; Thu, 8 Dec 2022 17:55:06 -0800 (PST) X-Google-Smtp-Source: AA0mqf4zdiQ+NpaTI6GBiwAYZLBnl78WC11JUUtr7WbXlYTY9wz3ysSPzibVFSlcHx8ZP6F8iQrS X-Received: by 2002:a05:6402:10c3:b0:462:9baa:e3b6 with SMTP id p3-20020a05640210c300b004629baae3b6mr3717741edu.29.1670550906023; Thu, 08 Dec 2022 17:55:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670550906; cv=none; d=google.com; s=arc-20160816; b=qHYcZej87b8v7jcAZM5fH9A+eyb18XnxvQAvRLm3v5HX5S/Kh8WIo7ABNFOnmf8aF4 ne11CkFx1efxozj9ApQzP8dAHbwQfmNO54s9Hb77s3LrT2707CcdRObxkaN+OUt8hkuX /UzQL/q/Y/yH+FfHUfrAfGbaCelGYO99Rg80y46wlF9VVi9Xl9BcFAeNTv1v6wHKDCYe 9OBuTTNxobdHlnNaL+3O2JOJrYgl1iMJvUg8Bbwo1Kk46AW6t8/IaivqoFeaUvcJVVcQ /fhW0Y+aDfR+U1I4AAsMQSUkwg76zxIKs0uZne3rzwZgPRQTQ0MttI5cY8f9yj08O+1W 6FRw== 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:to:from :dkim-signature; bh=IkGVS2PJsNQ8Fz8xWlYZQ0kWD9mENnWbK7wsUfipyCE=; b=MmvOF+WRwIUQ9cs/aDmGadCkjGaVWmpGRdJWE/9jwWQMrqv1RHYZmkP6ijH//AjJvf YVZ08/9fI72gF1lw3D3Nxd/8CS0isOroSErFN5yk99LF4qrgjlZ4cSE5rwTKRbaCPg1X PxVssc/RCQX1UZL+mGW/Wezz13iBCtDUB22kecmIQpH90zV6isOV2AANrUTWt3ui6Zrf IGMPE3KmTu0A37qvmTfKimlmxm9X4rBW8wnWDoKKbtotzTpfZBVelTUMDtQEQZLx+LdJ SIxLjBX3me9v6xZFmktaT02OinvqVy9N7bw8f9EA9cMWVuGbskPkOMLaI1H7h00d6iTS AhIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeconstruct.com.au header.s=2022a header.b=W5dBrtKG; 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 o8-20020a50fd88000000b0046a8fe6d173si197703edt.456.2022.12.08.17.54.42; Thu, 08 Dec 2022 17:55:06 -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=W5dBrtKG; 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 S229840AbiLIBdc (ORCPT + 99 others); Thu, 8 Dec 2022 20:33:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229612AbiLIBd2 (ORCPT ); Thu, 8 Dec 2022 20:33:28 -0500 Received: from codeconstruct.com.au (pi.codeconstruct.com.au [203.29.241.158]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C244D86F5C; Thu, 8 Dec 2022 17:33:27 -0800 (PST) Received: by codeconstruct.com.au (Postfix, from userid 10000) id 7EE852024C; Fri, 9 Dec 2022 09:33:22 +0800 (AWST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codeconstruct.com.au; s=2022a; t=1670549602; bh=IkGVS2PJsNQ8Fz8xWlYZQ0kWD9mENnWbK7wsUfipyCE=; h=From:To:Subject:Date:In-Reply-To:References; b=W5dBrtKGyoCUCd2wO3m9YX5eKIvbdHgOV3OvhM0Ad67I9VCz+f9jvHn3fP6Py9XEt B202ka2cyxF+FK/Ngv2HiV72noahjwOhwBnDtodvIM+zi6EItTEvw96JMQ5i9Gq8E9 Gwrd/FlNL8JI7gBerXXviTKdteA7sRMvgQvFSFQgpBe7/7ZdtZp9rlcQWTEJbRsa9n 0FEonYEXcpJaoR7j1CxT2GBNZ20qvzbWVX3cFT8Zh8B93qAxEDkketEB393+Y7rQE0 OaTInq6Pb7QyZ/2tWUnijhtPWC9xNpsWrBF4JJHgIp9Kf5/Au1zEK3tYAB9EztKDc0 E8w+Id42UfUZg== From: Jeremy Kerr To: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Lee Jones , Rob Herring , Krzysztof Kozlowski , Arnd Bergmann , Philipp Zabel , Mark Brown Subject: [RFC PATCH v2 2/3] regmap: mmio: allow reset control in a MMIO regmap Date: Fri, 9 Dec 2022 09:33:08 +0800 Message-Id: <20221209013309.407879-3-jk@codeconstruct.com.au> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221209013309.407879-1-jk@codeconstruct.com.au> References: <20221209013309.407879-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?1751699586669947262?= X-GMAIL-MSGID: =?utf-8?q?1751699586669947262?= A syscon device may need to be taken out of reset before functioning - this change adds a facility to attach a reset control to a mmio regmap, and performs the necessary deassert/assert operations on the reset controller on attach/detach. Signed-off-by: Jeremy Kerr --- drivers/base/regmap/regmap-mmio.c | 22 ++++++++++++++++++++++ include/linux/regmap.h | 3 +++ 2 files changed, 25 insertions(+) diff --git a/drivers/base/regmap/regmap-mmio.c b/drivers/base/regmap/regmap-mmio.c index 3ccdd86a97e7..e2611de73b42 100644 --- a/drivers/base/regmap/regmap-mmio.c +++ b/drivers/base/regmap/regmap-mmio.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -22,6 +23,8 @@ struct regmap_mmio_context { bool attached_clk; struct clk *clk; + struct reset_control *reset; + void (*reg_write)(struct regmap_mmio_context *ctx, unsigned int reg, unsigned int val); unsigned int (*reg_read)(struct regmap_mmio_context *ctx, @@ -633,4 +636,23 @@ void regmap_mmio_detach_clk(struct regmap *map) } EXPORT_SYMBOL_GPL(regmap_mmio_detach_clk); +int regmap_mmio_attach_reset(struct regmap *map, struct reset_control *reset) +{ + struct regmap_mmio_context *ctx = map->bus_context; + + ctx->reset = reset; + + return reset_control_deassert(ctx->reset); +} +EXPORT_SYMBOL_GPL(regmap_mmio_attach_reset); + +void regmap_mmio_detach_reset(struct regmap *map) +{ + struct regmap_mmio_context *ctx = map->bus_context; + + reset_control_assert(ctx->reset); + ctx->reset = NULL; +} +EXPORT_SYMBOL_GPL(regmap_mmio_detach_reset); + MODULE_LICENSE("GPL v2"); diff --git a/include/linux/regmap.h b/include/linux/regmap.h index ca3434dca3a0..b0c7a747c06f 100644 --- a/include/linux/regmap.h +++ b/include/linux/regmap.h @@ -34,6 +34,7 @@ struct spmi_device; struct regmap; struct regmap_range_cfg; struct regmap_field; +struct reset_control; struct snd_ac97; struct sdw_slave; @@ -1150,6 +1151,8 @@ bool regmap_ac97_default_volatile(struct device *dev, unsigned int reg); int regmap_mmio_attach_clk(struct regmap *map, struct clk *clk); void regmap_mmio_detach_clk(struct regmap *map); +int regmap_mmio_attach_reset(struct regmap *map, struct reset_control *reset); +void regmap_mmio_detach_reset(struct regmap *map); void regmap_exit(struct regmap *map); int regmap_reinit_cache(struct regmap *map, const struct regmap_config *config); From patchwork Fri Dec 9 01:33:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Kerr X-Patchwork-Id: 31574 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp528731wrr; Thu, 8 Dec 2022 17:54:17 -0800 (PST) X-Google-Smtp-Source: AA0mqf5o9cDcrEQlqGbDf9geHT9eELQ4IJhDHkZuMhKui4EAAhOFIBLmjHurK2TC5rQKemmBjt3b X-Received: by 2002:a05:6402:3985:b0:461:3ae6:8bfc with SMTP id fk5-20020a056402398500b004613ae68bfcmr4053090edb.34.1670550856943; Thu, 08 Dec 2022 17:54:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670550856; cv=none; d=google.com; s=arc-20160816; b=ogsBE8IZVG+PU8ONfeAW3bZsLxT2aMlT39fieMfl6bVTaMxF1k3IHMTBDPfGsVNz7V QPiLRrN2rDBxjCswy5zsIzmXLPW+rIxmgqCg8kmkJ9jrWEZ6eZUEOtDw3j/VyQ+gmqnQ Sids7QONQbCuypVGUhmCr2NNDIxgYRFahDWD2NbtI6yUwcJacxJ/wjxqrIQ28bKRupxq Yr0jFNhj7p+Nsy3oBRt10T6L8l7f3lmOuYtezmS/m++9ic06w/XNiDHnew8wVs9FjoEF ADNpemMhGRoz56HRkeBje6tErGmZOFzYaXJw8llsQkt60gJPo8bJD2rlsTgwILAkpbWl 4dOg== 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:to:from :dkim-signature; bh=arOEJsM/yx+o1Y+f81ge85whdOVlDOd7/7bivSC46z8=; b=UxaoCuu1pFdW0dbRttiVCf3eniXSo7Af1ssQNTaGmiuPgwswaqLl45xP9i+qwPEy7n BxwjxsNuOV3sTc/d0TmOeqFQoQIWXQ89SMv83LoRHcL2sHL2RJBpDpvQ+hlKMR74DcNb O9XrsRb+IOnrscMPid5Uj+bSeWkyS6C9Gz47DhKsuXPe34GR0PAOeGVKzY5BuPueO5AW 6025NpRxPGvjThvNpJ+mNpEe2aRZCm3pQEW+n5P4zGoJ/AM1DtKlb+Fzd7huZv6/zMbc RnVRg+74s5wibjMjk9XNLEZlOenVyVpIYTLOss9idKuI5GNHXIIUzrEWRRgiCgXgvqpg ESew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeconstruct.com.au header.s=2022a header.b=YLyrgmMa; 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 l16-20020a056402125000b0046ab9b37cf2si237273edw.116.2022.12.08.17.53.53; Thu, 08 Dec 2022 17:54:16 -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=YLyrgmMa; 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 S229929AbiLIBdk (ORCPT + 99 others); Thu, 8 Dec 2022 20:33:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229643AbiLIBd3 (ORCPT ); Thu, 8 Dec 2022 20:33:29 -0500 Received: from codeconstruct.com.au (pi.codeconstruct.com.au [203.29.241.158]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8D2A86F66; Thu, 8 Dec 2022 17:33:27 -0800 (PST) Received: by codeconstruct.com.au (Postfix, from userid 10000) id DAF5B21689; Fri, 9 Dec 2022 09:33:22 +0800 (AWST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codeconstruct.com.au; s=2022a; t=1670549602; bh=arOEJsM/yx+o1Y+f81ge85whdOVlDOd7/7bivSC46z8=; h=From:To:Subject:Date:In-Reply-To:References; b=YLyrgmMag9QrLadwsXZCXpKtNZ9cAdK3Miagysxb39wkRrREMV6fQC6Nj5PBcngt+ WPTa1D9q3HdJN4pDzJKHi7VyRwqLN5PekDCvTPaywzl4rjshJBp78QjE7o0wzXSbBo k4rL58FSDnFa0fwQCOfY1gB3w78ZkSLEzLalcYX2c8Mlc6ZrlD+QxE4oWFN4mAUrf1 K4sri46vNwpb842p5h4ulUTE0fwqJPCYXzCb+bAgSzenusjDIhdFVezab8pV08hZxf ikWS3a13GGLepRIt6c65EJAniQwK65uLuq5Cmel+wTqpm7U91ITBduSJuFrqHP4kVV 65efjLWTFHVfw== From: Jeremy Kerr To: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Lee Jones , Rob Herring , Krzysztof Kozlowski , Arnd Bergmann , Philipp Zabel , Mark Brown Subject: [RFC PATCH v2 3/3] mfd: syscon: allow reset control for syscon devices Date: Fri, 9 Dec 2022 09:33:09 +0800 Message-Id: <20221209013309.407879-4-jk@codeconstruct.com.au> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221209013309.407879-1-jk@codeconstruct.com.au> References: <20221209013309.407879-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?1751699535618314533?= X-GMAIL-MSGID: =?utf-8?q?1751699535618314533?= 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 --- v2: * do reset control in the early of_syscon_register() path, rather than the platform device init, which isn't used. --- 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..6b99488d05a6 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 if (reset) { + ret = regmap_mmio_attach_reset(regmap, reset); + if (ret) + goto err_attach_reset; } } @@ -137,7 +150,9 @@ static struct syscon *of_syscon_register(struct device_node *np, bool check_clk) return syscon; -err_attach: +err_attach_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);