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: [PATCH 1/2] mfd: syscon: Support physical regmap bus
Date: Fri, 17 Apr 2020 10:14:14 +0800 [thread overview]
Message-ID: <96d444cd73239e0166316bd8f44082031cf72491.1587088646.git.baolin.wang7@gmail.com> (raw)
In-Reply-To: <cover.1587088646.git.baolin.wang7@gmail.com>
In-Reply-To: <cover.1587088646.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 | 23 +++++++++++++++++++++--
include/linux/mfd/syscon.h | 7 +++++++
2 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
index 3a97816d0cba..92bfe87038ca 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,25 @@ 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);
+ /*
+ * The Spreadtrum syscon need register a real physical regmap bus
+ * with new atomic bits updating operation instead of using
+ * read-modify-write.
+ */
+ if (IS_ENABLED(CONFIG_ARCH_SPRD) &&
+ of_device_is_compatible(np, "sprd,atomic-syscon") &&
+ 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 +184,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-17 2:14 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-17 2:14 [PATCH 0/2] Add new reg_update_bits() support Baolin Wang
2020-04-17 2:14 ` Baolin Wang [this message]
2020-04-24 8:11 ` [PATCH 1/2] mfd: syscon: Support physical regmap bus Lee Jones
2020-04-24 8:24 ` Arnd Bergmann
2020-04-24 8:32 ` Lee Jones
2020-04-24 8:42 ` Baolin Wang
2020-04-24 8:43 ` Baolin Wang
2020-04-17 2:14 ` [PATCH 2/2] soc: sprd: Add Spreadtrum special bits updating support Baolin Wang
2020-04-17 13:38 ` Arnd Bergmann
2020-04-17 14:10 ` Baolin Wang
2020-04-17 15:03 ` Arnd Bergmann
2020-04-18 1:52 ` 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=96d444cd73239e0166316bd8f44082031cf72491.1587088646.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;
as well as URLs for NNTP newsgroup(s).