[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <a3187ff166bf4434362b92d91149a8e445c4ed0c.1586757922.git.baolin.wang7@gmail.com>
Date: Mon, 13 Apr 2020 14:13:19 +0800
From: Baolin Wang <baolin.wang7@...il.com>
To: lee.jones@...aro.org, arnd@...db.de, broonie@...nel.org
Cc: baolin.wang7@...il.com, orsonzhai@...il.com, zhang.lyra@...il.com,
linux-kernel@...r.kernel.org
Subject: [RFC PATCH v2 1/3] mfd: syscon: Support physical regmap bus
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@...il.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
Powered by blists - more mailing lists