From: Jeremy Kerr <jk@codeconstruct.com.au>
To: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
Lee Jones <lee@kernel.org>, Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Arnd Bergmann <arnd@arndb.de>,
Philipp Zabel <p.zabel@pengutronix.de>,
Mark Brown <broonie@kernel.org>
Subject: [RFC PATCH v2 2/3] regmap: mmio: allow reset control in a MMIO regmap
Date: Fri, 9 Dec 2022 09:33:08 +0800 [thread overview]
Message-ID: <20221209013309.407879-3-jk@codeconstruct.com.au> (raw)
In-Reply-To: <20221209013309.407879-1-jk@codeconstruct.com.au>
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 <jk@codeconstruct.com.au>
---
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 <linux/err.h>
#include <linux/io.h>
#include <linux/module.h>
+#include <linux/reset.h>
#include <linux/regmap.h>
#include <linux/slab.h>
#include <linux/swab.h>
@@ -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);
--
2.35.1
next prev parent reply other threads:[~2022-12-09 1:33 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-09 1:33 [RFC PATCH v2 0/3] Add reset control for mfd syscon devices Jeremy Kerr
2022-12-09 1:33 ` [RFC PATCH v2 1/3] dt-bindings: mfd/syscon: Add resets property Jeremy Kerr
2022-12-09 1:33 ` Jeremy Kerr [this message]
2022-12-09 12:51 ` [RFC PATCH v2 2/3] regmap: mmio: allow reset control in a MMIO regmap Mark Brown
2022-12-11 2:23 ` Jeremy Kerr
2022-12-09 1:33 ` [RFC PATCH v2 3/3] mfd: syscon: allow reset control for syscon devices Jeremy Kerr
2022-12-09 11:17 ` [RFC PATCH v2 0/3] Add reset control for mfd " Arnd Bergmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221209013309.407879-3-jk@codeconstruct.com.au \
--to=jk@codeconstruct.com.au \
--cc=arnd@arndb.de \
--cc=broonie@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=lee@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=p.zabel@pengutronix.de \
--cc=robh+dt@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).