From: Baolin Wang <baolin.wang7@gmail.com>
To: lee.jones@linaro.org, arnd@arndb.de, broonie@kernel.org
Cc: baolin.wang7@gmail.com, orsonzhai@gmail.com,
zhang.lyra@gmail.com, linux-kernel@vger.kernel.org
Subject: [RFC PATCH v2 1/3] mfd: syscon: Support physical regmap bus
Date: Mon, 13 Apr 2020 14:13:19 +0800 [thread overview]
Message-ID: <a3187ff166bf4434362b92d91149a8e445c4ed0c.1586757922.git.baolin.wang7@gmail.com> (raw)
In-Reply-To: <cover.1586757922.git.baolin.wang7@gmail.com>
In-Reply-To: <cover.1586757922.git.baolin.wang7@gmail.com>
Some platforms such as Spreadtrum platform, define a special method to
update bits of the registers instead of reading and writing, which means
we should use a physical regmap bus to define the reg_update_bits()
operation instead of the MMIO regmap bus.
Thus add a new helper for the syscon driver to allow to register a physical
regmap bus to support this new requirement.
Signed-off-by: Baolin Wang <baolin.wang7@gmail.com>
---
drivers/mfd/syscon.c | 16 ++++++++++++++--
include/linux/mfd/syscon.h | 7 +++++++
2 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
index 3a97816d0cba..5de74e1b6634 100644
--- a/drivers/mfd/syscon.c
+++ b/drivers/mfd/syscon.c
@@ -24,6 +24,7 @@
#include <linux/slab.h>
static struct platform_driver syscon_driver;
+static struct regmap_bus *syscon_phy_regmap_bus;
static DEFINE_SPINLOCK(syscon_list_slock);
static LIST_HEAD(syscon_list);
@@ -106,14 +107,18 @@ static struct syscon *of_syscon_register(struct device_node *np, bool check_clk)
syscon_config.val_bits = reg_io_width * 8;
syscon_config.max_register = resource_size(&res) - reg_io_width;
- regmap = regmap_init_mmio(NULL, base, &syscon_config);
+ if (syscon_phy_regmap_bus)
+ regmap = regmap_init(NULL, syscon_phy_regmap_bus, base,
+ &syscon_config);
+ else
+ regmap = regmap_init_mmio(NULL, base, &syscon_config);
if (IS_ERR(regmap)) {
pr_err("regmap init failed\n");
ret = PTR_ERR(regmap);
goto err_regmap;
}
- if (check_clk) {
+ if (check_clk && !syscon_phy_regmap_bus) {
clk = of_clk_get(np, 0);
if (IS_ERR(clk)) {
ret = PTR_ERR(clk);
@@ -172,6 +177,13 @@ static struct regmap *device_node_get_regmap(struct device_node *np,
return syscon->regmap;
}
+void syscon_register_phys_regmap_bus(struct regmap_bus *phy_regmap_bus)
+{
+ if (phy_regmap_bus)
+ syscon_phy_regmap_bus = phy_regmap_bus;
+}
+EXPORT_SYMBOL_GPL(syscon_register_phys_regmap_bus);
+
struct regmap *device_node_to_regmap(struct device_node *np)
{
return device_node_get_regmap(np, false);
diff --git a/include/linux/mfd/syscon.h b/include/linux/mfd/syscon.h
index 7f20e9b502a5..fbc2a2f0f414 100644
--- a/include/linux/mfd/syscon.h
+++ b/include/linux/mfd/syscon.h
@@ -13,6 +13,7 @@
#include <linux/err.h>
#include <linux/errno.h>
+#include <linux/regmap.h>
struct device_node;
@@ -28,6 +29,7 @@ extern struct regmap *syscon_regmap_lookup_by_phandle_args(
const char *property,
int arg_count,
unsigned int *out_args);
+extern void syscon_register_phys_regmap_bus(struct regmap_bus *phy_regmap_bus);
#else
static inline struct regmap *device_node_to_regmap(struct device_node *np)
{
@@ -59,6 +61,11 @@ static inline struct regmap *syscon_regmap_lookup_by_phandle_args(
{
return ERR_PTR(-ENOTSUPP);
}
+
+static inline void
+syscon_register_phys_regmap_bus(struct regmap_bus *phy_regmap_bus)
+{
+}
#endif
#endif /* __LINUX_MFD_SYSCON_H__ */
--
2.17.1
next prev parent reply other threads:[~2020-04-13 6:13 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-13 6:13 [RFC PATCH v2 0/3] Add new reg_update_bits() support Baolin Wang
2020-04-13 6:13 ` Baolin Wang [this message]
2020-04-13 6:13 ` [RFC PATCH v2 2/3] regmap: Add bus " Baolin Wang
2020-04-14 15:37 ` Applied "regmap: Add bus reg_update_bits() support" to the regmap tree Mark Brown
2020-04-14 17:12 ` [RFC PATCH v2 2/3] regmap: Add bus reg_update_bits() support Mark Brown
2020-04-13 6:13 ` [RFC PATCH v2 3/3] soc: sprd: Add Spreadtrum special bits updating support Baolin Wang
2020-04-15 15:36 ` Arnd Bergmann
2020-04-16 3:49 ` Baolin Wang
2020-04-16 12:54 ` Arnd Bergmann
2020-04-16 13:49 ` Baolin Wang
2020-04-16 14:38 ` Arnd Bergmann
2020-04-17 1:20 ` Baolin Wang
2020-04-15 12:59 ` [RFC PATCH v2 0/3] Add new reg_update_bits() support Baolin Wang
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=a3187ff166bf4434362b92d91149a8e445c4ed0c.1586757922.git.baolin.wang7@gmail.com \
--to=baolin.wang7@gmail.com \
--cc=arnd@arndb.de \
--cc=broonie@kernel.org \
--cc=lee.jones@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=orsonzhai@gmail.com \
--cc=zhang.lyra@gmail.com \
/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
all inboxes | Powered by JetHome®