linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/2] Add new physical regmap bus support
@ 2020-05-16 10:12 Baolin Wang
  2020-05-16 10:12 ` [PATCH v4 1/2] mfd: syscon: Support physical regmap bus Baolin Wang
  2020-05-16 10:12 ` [PATCH v4 2/2] soc: sprd: Add Spreadtrum special bits updating support Baolin Wang
  0 siblings, 2 replies; 7+ messages in thread
From: Baolin Wang @ 2020-05-16 10:12 UTC (permalink / raw)
  To: lee.jones, arnd
  Cc: broonie, baolin.wang7, orsonzhai, zhang.lyra, linux-kernel

The Spreadtrum platform uses a special set/clear method to update
registers' bits, thus this patch set exports a weak function to
allow to register a physical regmap bus to support this feature
instead of using the MMIO bus, which is not a physical regmap bus.

Any comments are welcome. Thanks.

Changes from v3:
 - Remove vendor specific support from the syscon driver, and export
 a weak function to support physical regmap bus.

Changes from v2:
 - Fix building errors without enabling CONFIG_ARCH_SPRD.

Changes from v1:
 - Add WARN_ONCE() for seting bits and clearing bits at the same time.
 - Remove the Spreadtrum SoC syscon driver, instead moving the regmap_bus
 instance into syscon.c driver.

Changes from RFC v2:
 - Drop regmap change, which was applied by Mark.
 - Add more information about how to use set/clear.
 - Add checking to ensure the platform is compatible with
 using a new physical regmap bus.

Changes from RFC v1:
 - Add new helper to registers a physical regmap bus instead of
 using the MMIO bus.

Baolin Wang (2):
  mfd: syscon: Support physical regmap bus
  soc: sprd: Add Spreadtrum special bits updating support

 drivers/mfd/syscon.c           |  9 +++-
 drivers/soc/Kconfig            |  1 +
 drivers/soc/Makefile           |  1 +
 drivers/soc/sprd/Kconfig       | 16 +++++++
 drivers/soc/sprd/Makefile      |  2 +
 drivers/soc/sprd/sprd_syscon.c | 86 ++++++++++++++++++++++++++++++++++
 include/linux/mfd/syscon.h     | 11 +++++
 7 files changed, 125 insertions(+), 1 deletion(-)
 create mode 100644 drivers/soc/sprd/Kconfig
 create mode 100644 drivers/soc/sprd/Makefile
 create mode 100644 drivers/soc/sprd/sprd_syscon.c

-- 
2.17.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v4 1/2] mfd: syscon: Support physical regmap bus
  2020-05-16 10:12 [PATCH v4 0/2] Add new physical regmap bus support Baolin Wang
@ 2020-05-16 10:12 ` Baolin Wang
  2020-05-17  0:08   ` Orson Zhai
  2020-05-19 13:18   ` Arnd Bergmann
  2020-05-16 10:12 ` [PATCH v4 2/2] soc: sprd: Add Spreadtrum special bits updating support Baolin Wang
  1 sibling, 2 replies; 7+ messages in thread
From: Baolin Wang @ 2020-05-16 10:12 UTC (permalink / raw)
  To: lee.jones, arnd
  Cc: broonie, baolin.wang7, orsonzhai, zhang.lyra, linux-kernel

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 a __weak function  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       |  9 ++++++++-
 include/linux/mfd/syscon.h | 11 +++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
index 3a97816d0cba..dc92f3177ceb 100644
--- a/drivers/mfd/syscon.c
+++ b/drivers/mfd/syscon.c
@@ -40,6 +40,13 @@ static const struct regmap_config syscon_regmap_config = {
 	.reg_stride = 4,
 };
 
+struct regmap * __weak syscon_regmap_init(struct device_node *np,
+					  void __iomem *base,
+					  struct regmap_config *syscon_config)
+{
+	return regmap_init_mmio(NULL, base, syscon_config);
+}
+
 static struct syscon *of_syscon_register(struct device_node *np, bool check_clk)
 {
 	struct clk *clk;
@@ -106,7 +113,7 @@ 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);
+	regmap = syscon_regmap_init(np, base, &syscon_config);
 	if (IS_ERR(regmap)) {
 		pr_err("regmap init failed\n");
 		ret = PTR_ERR(regmap);
diff --git a/include/linux/mfd/syscon.h b/include/linux/mfd/syscon.h
index 7f20e9b502a5..85088e44fe7c 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,9 @@ extern struct regmap *syscon_regmap_lookup_by_phandle_args(
 					const char *property,
 					int arg_count,
 					unsigned int *out_args);
+extern struct regmap *syscon_regmap_init(struct device_node *np,
+					 void __iomem *base,
+					 struct regmap_config *syscon_config);
 #else
 static inline struct regmap *device_node_to_regmap(struct device_node *np)
 {
@@ -59,6 +63,13 @@ static inline struct regmap *syscon_regmap_lookup_by_phandle_args(
 {
 	return ERR_PTR(-ENOTSUPP);
 }
+
+static inline struct regmap *syscon_regmap_init(struct device_node *np,
+						void __iomem *base,
+						struct regmap_config *syscon_config)
+{
+	return ERR_PTR(-ENOTSUPP);
+}
 #endif
 
 #endif /* __LINUX_MFD_SYSCON_H__ */
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v4 2/2] soc: sprd: Add Spreadtrum special bits updating support
  2020-05-16 10:12 [PATCH v4 0/2] Add new physical regmap bus support Baolin Wang
  2020-05-16 10:12 ` [PATCH v4 1/2] mfd: syscon: Support physical regmap bus Baolin Wang
@ 2020-05-16 10:12 ` Baolin Wang
  1 sibling, 0 replies; 7+ messages in thread
From: Baolin Wang @ 2020-05-16 10:12 UTC (permalink / raw)
  To: lee.jones, arnd
  Cc: broonie, baolin.wang7, orsonzhai, zhang.lyra, linux-kernel

The spreadtrum platform uses a special set/clear method to update
registers' bits, which can remove the race of updating the global
registers between the multiple subsystems. Thus we can register
a physical regmap bus into syscon core to support this.

Signed-off-by: Baolin Wang <baolin.wang7@gmail.com>
---
 drivers/soc/Kconfig            |  1 +
 drivers/soc/Makefile           |  1 +
 drivers/soc/sprd/Kconfig       | 16 +++++++
 drivers/soc/sprd/Makefile      |  2 +
 drivers/soc/sprd/sprd_syscon.c | 86 ++++++++++++++++++++++++++++++++++
 5 files changed, 106 insertions(+)
 create mode 100644 drivers/soc/sprd/Kconfig
 create mode 100644 drivers/soc/sprd/Makefile
 create mode 100644 drivers/soc/sprd/sprd_syscon.c

diff --git a/drivers/soc/Kconfig b/drivers/soc/Kconfig
index 425ab6f7e375..8cfbf2dc518d 100644
--- a/drivers/soc/Kconfig
+++ b/drivers/soc/Kconfig
@@ -23,5 +23,6 @@ source "drivers/soc/versatile/Kconfig"
 source "drivers/soc/xilinx/Kconfig"
 source "drivers/soc/zte/Kconfig"
 source "drivers/soc/kendryte/Kconfig"
+source "drivers/soc/sprd/Kconfig"
 
 endmenu
diff --git a/drivers/soc/Makefile b/drivers/soc/Makefile
index 36452bed86ef..7d156a6dd536 100644
--- a/drivers/soc/Makefile
+++ b/drivers/soc/Makefile
@@ -29,3 +29,4 @@ obj-$(CONFIG_PLAT_VERSATILE)	+= versatile/
 obj-y				+= xilinx/
 obj-$(CONFIG_ARCH_ZX)		+= zte/
 obj-$(CONFIG_SOC_KENDRYTE)	+= kendryte/
+obj-$(CONFIG_ARCH_SPRD)		+= sprd/
diff --git a/drivers/soc/sprd/Kconfig b/drivers/soc/sprd/Kconfig
new file mode 100644
index 000000000000..38d1f5971a28
--- /dev/null
+++ b/drivers/soc/sprd/Kconfig
@@ -0,0 +1,16 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# SPRD SoC drivers
+#
+
+menu "Spreadtrum SoC drivers"
+	depends on ARCH_SPRD || COMPILE_TEST
+
+config SPRD_SYSCON
+	tristate "Spreadtrum syscon support"
+	depends on ARCH_SPRD || COMPILE_TEST
+	help
+	  Say yes here to add support for the Spreadtrum syscon driver,
+	  which is used to implement the atomic method of bits updating.
+
+endmenu
diff --git a/drivers/soc/sprd/Makefile b/drivers/soc/sprd/Makefile
new file mode 100644
index 000000000000..4d7715553cf6
--- /dev/null
+++ b/drivers/soc/sprd/Makefile
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0-only
+obj-$(CONFIG_SPRD_SYSCON) += sprd_syscon.o
diff --git a/drivers/soc/sprd/sprd_syscon.c b/drivers/soc/sprd/sprd_syscon.c
new file mode 100644
index 000000000000..cdc326ef94e5
--- /dev/null
+++ b/drivers/soc/sprd/sprd_syscon.c
@@ -0,0 +1,86 @@
+//SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2020 Spreadtrum Communications Inc.
+ */
+#include <linux/io.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/mfd/syscon.h>
+#include <linux/of.h>
+#include <linux/regmap.h>
+
+#define SPRD_REG_SET_OFFSET	0x1000
+#define SPRD_REG_CLR_OFFSET	0x2000
+
+/*
+ * The Spreadtrum platform defines a special set/clear method to update
+ * registers' bits, which means it can write values to the register's SET
+ * address (offset is 0x1000) to set bits, and write values to the register's
+ * CLEAR address (offset is 0x2000) to clear bits.
+ *
+ * This set/clear method can help to remove the race of accessing the global
+ * registers between the multiple subsystems instead of using hardware
+ * spinlocks.
+ *
+ * Note: there is a potential risk when users want to set and clear bits
+ * at the same time, since the set/clear method will always do bits setting
+ * before bits clearing, which may cause some unexpected results if the
+ * operation sequence is strict. Thus we recommend that do not set and
+ * clear bits at the same time if you are not sure about the results.
+ */
+static int sprd_syscon_update_bits(void *context, unsigned int reg,
+				   unsigned int mask, unsigned int val)
+{
+	void __iomem *base = context;
+	unsigned int set, clr;
+
+	set = val & mask;
+	clr = ~set & mask;
+
+	if (set)
+		writel(set, base + reg + SPRD_REG_SET_OFFSET);
+
+	if (clr)
+		writel(clr, base + reg + SPRD_REG_CLR_OFFSET);
+
+	WARN_ONCE(set && clr, "%s: non-atomic update", __func__);
+	return 0;
+}
+
+static int sprd_syscon_read(void *context, unsigned int reg, unsigned int *val)
+{
+	void __iomem *base = context;
+
+	*val = readl(base + reg);
+	return 0;
+}
+
+static int sprd_syscon_write(void *context, unsigned int reg, unsigned int val)
+{
+	void __iomem *base = context;
+
+	writel(val, base + reg);
+	return 0;
+}
+
+static struct regmap_bus sprd_syscon_regmap = {
+	.fast_io = true,
+	.reg_write = sprd_syscon_write,
+	.reg_read = sprd_syscon_read,
+	.reg_update_bits = sprd_syscon_update_bits,
+	.val_format_endian_default = REGMAP_ENDIAN_LITTLE,
+};
+
+struct regmap *syscon_regmap_init(struct device_node *np, void __iomem *base,
+				  struct regmap_config *syscon_config)
+{
+	if (of_device_is_compatible(np, "sprd,atomic-syscon"))
+		return regmap_init(NULL, &sprd_syscon_regmap, base,
+				   syscon_config);
+
+	return regmap_init_mmio(NULL, base, syscon_config);
+}
+
+MODULE_DESCRIPTION("Spreadtrum syscon support");
+MODULE_AUTHOR("Baolin Wang <baolin.wang@unisoc.com>");
+MODULE_LICENSE("GPL v2");
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v4 1/2] mfd: syscon: Support physical regmap bus
  2020-05-16 10:12 ` [PATCH v4 1/2] mfd: syscon: Support physical regmap bus Baolin Wang
@ 2020-05-17  0:08   ` Orson Zhai
  2020-05-17  8:56     ` Baolin Wang
  2020-05-19 13:18   ` Arnd Bergmann
  1 sibling, 1 reply; 7+ messages in thread
From: Orson Zhai @ 2020-05-17  0:08 UTC (permalink / raw)
  To: Baolin Wang
  Cc: lee.jones, arnd, Mark Brown, Lyra Zhang, Linux Kernel Mailing List

On Sat, May 16, 2020 at 6:13 PM Baolin Wang <baolin.wang7@gmail.com> wrote:
>
> 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 a __weak function  for the syscon driver to allow to register

Typo -- duplicated "a".

It seems to be a better idea than before.

-Orson

> a physical regmap bus to support this new requirement.
>
> Signed-off-by: Baolin Wang <baolin.wang7@gmail.com>
> ---
>  drivers/mfd/syscon.c       |  9 ++++++++-
>  include/linux/mfd/syscon.h | 11 +++++++++++
>  2 files changed, 19 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
> index 3a97816d0cba..dc92f3177ceb 100644
> --- a/drivers/mfd/syscon.c
> +++ b/drivers/mfd/syscon.c
> @@ -40,6 +40,13 @@ static const struct regmap_config syscon_regmap_config = {
>         .reg_stride = 4,
>  };
>
> +struct regmap * __weak syscon_regmap_init(struct device_node *np,
> +                                         void __iomem *base,
> +                                         struct regmap_config *syscon_config)
> +{
> +       return regmap_init_mmio(NULL, base, syscon_config);
> +}
> +
>  static struct syscon *of_syscon_register(struct device_node *np, bool check_clk)
>  {
>         struct clk *clk;
> @@ -106,7 +113,7 @@ 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);
> +       regmap = syscon_regmap_init(np, base, &syscon_config);
>         if (IS_ERR(regmap)) {
>                 pr_err("regmap init failed\n");
>                 ret = PTR_ERR(regmap);
> diff --git a/include/linux/mfd/syscon.h b/include/linux/mfd/syscon.h
> index 7f20e9b502a5..85088e44fe7c 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,9 @@ extern struct regmap *syscon_regmap_lookup_by_phandle_args(
>                                         const char *property,
>                                         int arg_count,
>                                         unsigned int *out_args);
> +extern struct regmap *syscon_regmap_init(struct device_node *np,
> +                                        void __iomem *base,
> +                                        struct regmap_config *syscon_config);
>  #else
>  static inline struct regmap *device_node_to_regmap(struct device_node *np)
>  {
> @@ -59,6 +63,13 @@ static inline struct regmap *syscon_regmap_lookup_by_phandle_args(
>  {
>         return ERR_PTR(-ENOTSUPP);
>  }
> +
> +static inline struct regmap *syscon_regmap_init(struct device_node *np,
> +                                               void __iomem *base,
> +                                               struct regmap_config *syscon_config)
> +{
> +       return ERR_PTR(-ENOTSUPP);
> +}
>  #endif
>
>  #endif /* __LINUX_MFD_SYSCON_H__ */
> --
> 2.17.1
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v4 1/2] mfd: syscon: Support physical regmap bus
  2020-05-17  0:08   ` Orson Zhai
@ 2020-05-17  8:56     ` Baolin Wang
  0 siblings, 0 replies; 7+ messages in thread
From: Baolin Wang @ 2020-05-17  8:56 UTC (permalink / raw)
  To: Orson Zhai
  Cc: lee.jones, arnd, Mark Brown, Lyra Zhang, Linux Kernel Mailing List

On Sun, May 17, 2020 at 8:08 AM Orson Zhai <orsonzhai@gmail.com> wrote:
>
> On Sat, May 16, 2020 at 6:13 PM Baolin Wang <baolin.wang7@gmail.com> wrote:
> >
> > 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 a __weak function  for the syscon driver to allow to register
>
> Typo -- duplicated "a".

Ah, right, will fix.

>
> It seems to be a better idea than before.

Let's see Arnd and Lee's opinion.

>
> -Orson
>
> > a physical regmap bus to support this new requirement.
> >
> > Signed-off-by: Baolin Wang <baolin.wang7@gmail.com>
> > ---
> >  drivers/mfd/syscon.c       |  9 ++++++++-
> >  include/linux/mfd/syscon.h | 11 +++++++++++
> >  2 files changed, 19 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
> > index 3a97816d0cba..dc92f3177ceb 100644
> > --- a/drivers/mfd/syscon.c
> > +++ b/drivers/mfd/syscon.c
> > @@ -40,6 +40,13 @@ static const struct regmap_config syscon_regmap_config = {
> >         .reg_stride = 4,
> >  };
> >
> > +struct regmap * __weak syscon_regmap_init(struct device_node *np,
> > +                                         void __iomem *base,
> > +                                         struct regmap_config *syscon_config)
> > +{
> > +       return regmap_init_mmio(NULL, base, syscon_config);
> > +}
> > +
> >  static struct syscon *of_syscon_register(struct device_node *np, bool check_clk)
> >  {
> >         struct clk *clk;
> > @@ -106,7 +113,7 @@ 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);
> > +       regmap = syscon_regmap_init(np, base, &syscon_config);
> >         if (IS_ERR(regmap)) {
> >                 pr_err("regmap init failed\n");
> >                 ret = PTR_ERR(regmap);
> > diff --git a/include/linux/mfd/syscon.h b/include/linux/mfd/syscon.h
> > index 7f20e9b502a5..85088e44fe7c 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,9 @@ extern struct regmap *syscon_regmap_lookup_by_phandle_args(
> >                                         const char *property,
> >                                         int arg_count,
> >                                         unsigned int *out_args);
> > +extern struct regmap *syscon_regmap_init(struct device_node *np,
> > +                                        void __iomem *base,
> > +                                        struct regmap_config *syscon_config);
> >  #else
> >  static inline struct regmap *device_node_to_regmap(struct device_node *np)
> >  {
> > @@ -59,6 +63,13 @@ static inline struct regmap *syscon_regmap_lookup_by_phandle_args(
> >  {
> >         return ERR_PTR(-ENOTSUPP);
> >  }
> > +
> > +static inline struct regmap *syscon_regmap_init(struct device_node *np,
> > +                                               void __iomem *base,
> > +                                               struct regmap_config *syscon_config)
> > +{
> > +       return ERR_PTR(-ENOTSUPP);
> > +}
> >  #endif
> >
> >  #endif /* __LINUX_MFD_SYSCON_H__ */
> > --
> > 2.17.1
> >



-- 
Baolin Wang

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v4 1/2] mfd: syscon: Support physical regmap bus
  2020-05-16 10:12 ` [PATCH v4 1/2] mfd: syscon: Support physical regmap bus Baolin Wang
  2020-05-17  0:08   ` Orson Zhai
@ 2020-05-19 13:18   ` Arnd Bergmann
  2020-05-21  1:08     ` Orson Zhai
  1 sibling, 1 reply; 7+ messages in thread
From: Arnd Bergmann @ 2020-05-19 13:18 UTC (permalink / raw)
  To: Baolin Wang; +Cc: Lee Jones, Mark Brown, Orson Zhai, Lyra Zhang, linux-kernel

On Sat, May 16, 2020 at 12:13 PM Baolin Wang <baolin.wang7@gmail.com> wrote:
>
> 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 a __weak function  for the syscon driver to allow to register
> a physical regmap bus to support this new requirement.
>
>  };
>
> +struct regmap * __weak syscon_regmap_init(struct device_node *np,
> +                                         void __iomem *base,
> +                                         struct regmap_config *syscon_config)
> +{
> +       return regmap_init_mmio(NULL, base, syscon_config);
> +}
> +

Sorry, I don't think the __weak function is going to help here. I'm not
sure whether it actually does what you want when both syscon and
sprd_syscon are loadable modules (I would guess not), but it clearly
won't work when syscon is built-in and sprd_syscon is a module, and
even if the module loader knows how to resolve __weak symbols,
I would not want to rely on module load ordering to make it behave
the right way.

      Arnd

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v4 1/2] mfd: syscon: Support physical regmap bus
  2020-05-19 13:18   ` Arnd Bergmann
@ 2020-05-21  1:08     ` Orson Zhai
  0 siblings, 0 replies; 7+ messages in thread
From: Orson Zhai @ 2020-05-21  1:08 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Baolin Wang, Lee Jones, Mark Brown, Lyra Zhang, linux-kernel

On Tue, May 19, 2020 at 9:19 PM Arnd Bergmann <arnd@arndb.de> wrote:
>
> On Sat, May 16, 2020 at 12:13 PM Baolin Wang <baolin.wang7@gmail.com> wrote:
> >
> > 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 a __weak function  for the syscon driver to allow to register
> > a physical regmap bus to support this new requirement.
> >
> >  };
> >
> > +struct regmap * __weak syscon_regmap_init(struct device_node *np,
> > +                                         void __iomem *base,
> > +                                         struct regmap_config *syscon_config)
> > +{
> > +       return regmap_init_mmio(NULL, base, syscon_config);
> > +}
> > +
>
> Sorry, I don't think the __weak function is going to help here. I'm not
> sure whether it actually does what you want when both syscon and
> sprd_syscon are loadable modules (I would guess not), but it clearly
> won't work when syscon is built-in and sprd_syscon is a module, and
> even if the module loader knows how to resolve __weak symbols,


I happened to see module.c last week. It seems there's some code to handle
weak symbols by checking about STB_WEAK. But it is not in this case.
When syscon.c is built-in and sprd_syscon is module, this would not
work because the
__weak one has been built into kernel already. Maybe live patch
feature may work it out.
But it seems over expensive  to do things like this.

> I would not want to rely on module load ordering to make it behave
> the right way.

Agree. All other sprd modules would must be loaded behind sprd_syscon
and this will not be
handled by modprobe.

Thanks to pointing out this.

Best,
Orson

>
>       Arnd

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-05-21  1:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-16 10:12 [PATCH v4 0/2] Add new physical regmap bus support Baolin Wang
2020-05-16 10:12 ` [PATCH v4 1/2] mfd: syscon: Support physical regmap bus Baolin Wang
2020-05-17  0:08   ` Orson Zhai
2020-05-17  8:56     ` Baolin Wang
2020-05-19 13:18   ` Arnd Bergmann
2020-05-21  1:08     ` Orson Zhai
2020-05-16 10:12 ` [PATCH v4 2/2] soc: sprd: Add Spreadtrum special bits updating support Baolin Wang

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).