* [PATCH 0/2] Add new reg_update_bits() support @ 2020-04-17 2:14 Baolin Wang 2020-04-17 2:14 ` [PATCH 1/2] mfd: syscon: Support physical regmap bus Baolin Wang 2020-04-17 2:14 ` [PATCH 2/2] soc: sprd: Add Spreadtrum special bits updating support Baolin Wang 0 siblings, 2 replies; 12+ messages in thread From: Baolin Wang @ 2020-04-17 2:14 UTC (permalink / raw) To: lee.jones, arnd, broonie Cc: baolin.wang7, orsonzhai, zhang.lyra, linux-kernel The Spreadtrum platform uses a special set/clear method to update registers' bits, thus this patch set registers a physical regmap bus into syscon core to support this feature instead of using the MMIO bus, which is not a physical regmap bus. Any comments are welcome. Thanks. 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 | 23 +++++++++- drivers/soc/Kconfig | 1 + drivers/soc/Makefile | 1 + drivers/soc/sprd/Kconfig | 16 +++++++ drivers/soc/sprd/Makefile | 2 + drivers/soc/sprd/sprd_syscon.c | 82 ++++++++++++++++++++++++++++++++++ include/linux/mfd/syscon.h | 7 +++ 7 files changed, 130 insertions(+), 2 deletions(-) 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] 12+ messages in thread
* [PATCH 1/2] mfd: syscon: Support physical regmap bus 2020-04-17 2:14 [PATCH 0/2] Add new reg_update_bits() support Baolin Wang @ 2020-04-17 2:14 ` Baolin Wang 2020-04-24 8:11 ` Lee Jones 2020-04-17 2:14 ` [PATCH 2/2] soc: sprd: Add Spreadtrum special bits updating support Baolin Wang 1 sibling, 1 reply; 12+ messages in thread From: Baolin Wang @ 2020-04-17 2:14 UTC (permalink / raw) To: lee.jones, arnd, broonie Cc: 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 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 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 1/2] mfd: syscon: Support physical regmap bus 2020-04-17 2:14 ` [PATCH 1/2] mfd: syscon: Support physical regmap bus Baolin Wang @ 2020-04-24 8:11 ` Lee Jones 2020-04-24 8:24 ` Arnd Bergmann 0 siblings, 1 reply; 12+ messages in thread From: Lee Jones @ 2020-04-24 8:11 UTC (permalink / raw) To: Baolin Wang; +Cc: arnd, broonie, orsonzhai, zhang.lyra, linux-kernel On Fri, 17 Apr 2020, Baolin Wang 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 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") && Please find a more generic way of supporting your use-case. This is a generic driver, and as such I am vehemently against adding any sort of vendor specific code in here. > + syscon_phy_regmap_bus) > + regmap = regmap_init(NULL, syscon_phy_regmap_bus, base, > + &syscon_config); > + else > + regmap = regmap_init_mmio(NULL, base, &syscon_config); -- Lee Jones [李琼斯] Linaro Services Technical Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/2] mfd: syscon: Support physical regmap bus 2020-04-24 8:11 ` Lee Jones @ 2020-04-24 8:24 ` Arnd Bergmann 2020-04-24 8:32 ` Lee Jones 0 siblings, 1 reply; 12+ messages in thread From: Arnd Bergmann @ 2020-04-24 8:24 UTC (permalink / raw) To: Lee Jones Cc: Baolin Wang, Mark Brown, Orson Zhai, Lyra Zhang, linux-kernel@vger.kernel.org On Fri, Apr 24, 2020 at 10:11 AM Lee Jones <lee.jones@linaro.org> wrote: > On Fri, 17 Apr 2020, Baolin Wang wrote: > > @@ -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") && > > Please find a more generic way of supporting your use-case. This is a > generic driver, and as such I am vehemently against adding any sort of > vendor specific code in here. I suggested doing it this way, as all alternatives seemed worse than this. Arnd ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/2] mfd: syscon: Support physical regmap bus 2020-04-24 8:24 ` Arnd Bergmann @ 2020-04-24 8:32 ` Lee Jones 2020-04-24 8:42 ` Baolin Wang 0 siblings, 1 reply; 12+ messages in thread From: Lee Jones @ 2020-04-24 8:32 UTC (permalink / raw) To: Arnd Bergmann Cc: Baolin Wang, Mark Brown, Orson Zhai, Lyra Zhang, linux-kernel@vger.kernel.org On Fri, 24 Apr 2020, Arnd Bergmann wrote: > On Fri, Apr 24, 2020 at 10:11 AM Lee Jones <lee.jones@linaro.org> wrote: > > On Fri, 17 Apr 2020, Baolin Wang wrote: > > > @@ -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") && > > > > Please find a more generic way of supporting your use-case. This is a > > generic driver, and as such I am vehemently against adding any sort of > > vendor specific code in here. > > I suggested doing it this way, as all alternatives seemed worse than this. If we're using a registration function (could probably be swapped out for or accompanied by a Device Tree property) anyway, then why conduct the vendor platform checks? -- Lee Jones [李琼斯] Linaro Services Technical Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/2] mfd: syscon: Support physical regmap bus 2020-04-24 8:32 ` Lee Jones @ 2020-04-24 8:42 ` Baolin Wang 2020-04-24 8:43 ` Baolin Wang 0 siblings, 1 reply; 12+ messages in thread From: Baolin Wang @ 2020-04-24 8:42 UTC (permalink / raw) To: Lee Jones Cc: Arnd Bergmann, Mark Brown, Orson Zhai, Lyra Zhang, linux-kernel@vger.kernel.org On Fri, Apr 24, 2020 at 4:32 PM Lee Jones <lee.jones@linaro.org> wrote: > > On Fri, 24 Apr 2020, Arnd Bergmann wrote: > > > On Fri, Apr 24, 2020 at 10:11 AM Lee Jones <lee.jones@linaro.org> wrote: > > > On Fri, 17 Apr 2020, Baolin Wang wrote: > > > > @@ -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") && > > > > > > Please find a more generic way of supporting your use-case. This is a > > > generic driver, and as such I am vehemently against adding any sort of > > > vendor specific code in here. > > > > I suggested doing it this way, as all alternatives seemed worse than this. > > If we're using a registration function (could probably be swapped out > for or accompanied by a Device Tree property) anyway, then why conduct > the vendor platform checks? Actually I've send out the v3 patch according to Arnd's suggestion. In v3 patch, I removed the registration function, but we agreed that adding the vendor specific support in the syscon driver seems a better way than others. -- Baolin Wang ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/2] mfd: syscon: Support physical regmap bus 2020-04-24 8:42 ` Baolin Wang @ 2020-04-24 8:43 ` Baolin Wang 0 siblings, 0 replies; 12+ messages in thread From: Baolin Wang @ 2020-04-24 8:43 UTC (permalink / raw) To: Lee Jones Cc: Arnd Bergmann, Mark Brown, Orson Zhai, Lyra Zhang, linux-kernel@vger.kernel.org On Fri, Apr 24, 2020 at 4:42 PM Baolin Wang <baolin.wang7@gmail.com> wrote: > > On Fri, Apr 24, 2020 at 4:32 PM Lee Jones <lee.jones@linaro.org> wrote: > > > > On Fri, 24 Apr 2020, Arnd Bergmann wrote: > > > > > On Fri, Apr 24, 2020 at 10:11 AM Lee Jones <lee.jones@linaro.org> wrote: > > > > On Fri, 17 Apr 2020, Baolin Wang wrote: > > > > > @@ -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") && > > > > > > > > Please find a more generic way of supporting your use-case. This is a > > > > generic driver, and as such I am vehemently against adding any sort of > > > > vendor specific code in here. > > > > > > I suggested doing it this way, as all alternatives seemed worse than this. > > > > If we're using a registration function (could probably be swapped out > > for or accompanied by a Device Tree property) anyway, then why conduct > > the vendor platform checks? > > Actually I've send out the v3 patch according to Arnd's suggestion. In > v3 patch, I removed the registration function, but we agreed that > adding the vendor specific support in the syscon driver seems a better > way than others. Sorry, I forgot the link: https://lore.kernel.org/patchwork/patch/1228160/ -- Baolin Wang ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 2/2] soc: sprd: Add Spreadtrum special bits updating support 2020-04-17 2:14 [PATCH 0/2] Add new reg_update_bits() support Baolin Wang 2020-04-17 2:14 ` [PATCH 1/2] mfd: syscon: Support physical regmap bus Baolin Wang @ 2020-04-17 2:14 ` Baolin Wang 2020-04-17 13:38 ` Arnd Bergmann 1 sibling, 1 reply; 12+ messages in thread From: Baolin Wang @ 2020-04-17 2:14 UTC (permalink / raw) To: lee.jones, arnd, broonie Cc: 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 | 82 ++++++++++++++++++++++++++++++++++ 5 files changed, 102 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..9b98127f1adb --- /dev/null +++ b/drivers/soc/sprd/sprd_syscon.c @@ -0,0 +1,82 @@ +//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/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 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); + + 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, +}; + +static int sprd_syscon_init(void) +{ + syscon_register_phys_regmap_bus(&sprd_syscon_regmap); + + return 0; +} +core_initcall_sync(sprd_syscon_init); + +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] 12+ messages in thread
* Re: [PATCH 2/2] soc: sprd: Add Spreadtrum special bits updating support 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 0 siblings, 1 reply; 12+ messages in thread From: Arnd Bergmann @ 2020-04-17 13:38 UTC (permalink / raw) To: Baolin Wang Cc: Lee Jones, Mark Brown, Orson Zhai, Lyra Zhang, linux-kernel@vger.kernel.org On Fri, Apr 17, 2020 at 4:14 AM Baolin Wang <baolin.wang7@gmail.com> wrote: > + * > + * 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 the results. Would it make sense to have a WARN_ONCE(set && clk, "%s: non-atomic update", __func__); in the code to check for this? > +static int sprd_syscon_init(void) > +{ > + syscon_register_phys_regmap_bus(&sprd_syscon_regmap); > + > + return 0; > +} > +core_initcall_sync(sprd_syscon_init); This no longer breaks at runtime based on the changes in the other patch, but I still don't like how you have to manually load this module on spreadtrum platforms. What I meant to suggest in my previous reply was to add the regmap_bus instance into drivers/mfd/syscon.c itself. Arnd ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/2] soc: sprd: Add Spreadtrum special bits updating support 2020-04-17 13:38 ` Arnd Bergmann @ 2020-04-17 14:10 ` Baolin Wang 2020-04-17 15:03 ` Arnd Bergmann 0 siblings, 1 reply; 12+ messages in thread From: Baolin Wang @ 2020-04-17 14:10 UTC (permalink / raw) To: Arnd Bergmann Cc: Lee Jones, Mark Brown, Orson Zhai, Lyra Zhang, linux-kernel@vger.kernel.org On Fri, Apr 17, 2020 at 9:39 PM Arnd Bergmann <arnd@arndb.de> wrote: > > On Fri, Apr 17, 2020 at 4:14 AM Baolin Wang <baolin.wang7@gmail.com> wrote: > > + * > > + * 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 the results. > > Would it make sense to have a > > WARN_ONCE(set && clk, "%s: non-atomic update", __func__); > > in the code to check for this? Yes, will add. > > > +static int sprd_syscon_init(void) > > +{ > > + syscon_register_phys_regmap_bus(&sprd_syscon_regmap); > > + > > + return 0; > > +} > > +core_initcall_sync(sprd_syscon_init); > > This no longer breaks at runtime based on the changes in the other > patch, but I still don't like how you have to manually load this module > on spreadtrum platforms. > > What I meant to suggest in my previous reply was to add the regmap_bus > instance into drivers/mfd/syscon.c itself. Sorry, I misunderstood your meaning before, but what you suggested will add some vendor-specific things into the common syscon driver, if other platforms have different update bits method, we will add another vendor-specific regmap bus into the syscon.c, which will make syscon.c more complicated. But if you still prefer to add these vendor-specific things into the syscon.c, I will follow your suggestion in next version. Thanks. -- Baolin Wang ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/2] soc: sprd: Add Spreadtrum special bits updating support 2020-04-17 14:10 ` Baolin Wang @ 2020-04-17 15:03 ` Arnd Bergmann 2020-04-18 1:52 ` Baolin Wang 0 siblings, 1 reply; 12+ messages in thread From: Arnd Bergmann @ 2020-04-17 15:03 UTC (permalink / raw) To: Baolin Wang Cc: Lee Jones, Mark Brown, Orson Zhai, Lyra Zhang, linux-kernel@vger.kernel.org On Fri, Apr 17, 2020 at 4:10 PM Baolin Wang <baolin.wang7@gmail.com> wrote: > On Fri, Apr 17, 2020 at 9:39 PM Arnd Bergmann <arnd@arndb.de> wrote: > > On Fri, Apr 17, 2020 at 4:14 AM Baolin Wang <baolin.wang7@gmail.com> wrote: > > > +static int sprd_syscon_init(void) > > > +{ > > > + syscon_register_phys_regmap_bus(&sprd_syscon_regmap); > > > + > > > + return 0; > > > +} > > > +core_initcall_sync(sprd_syscon_init); > > > > This no longer breaks at runtime based on the changes in the other > > patch, but I still don't like how you have to manually load this module > > on spreadtrum platforms. > > > > What I meant to suggest in my previous reply was to add the regmap_bus > > instance into drivers/mfd/syscon.c itself. > > Sorry, I misunderstood your meaning before, but what you suggested > will add some vendor-specific things into the common syscon driver, if > other platforms have different update bits method, we will add another > vendor-specific regmap bus into the syscon.c, which will make syscon.c > more complicated. I think we can always deal with this once it gets too complex, as long as the DT binding allows it. > But if you still prefer to add these vendor-specific things into the > syscon.c, I will follow your suggestion in next version. Thanks. Yes, please do. Arnd ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/2] soc: sprd: Add Spreadtrum special bits updating support 2020-04-17 15:03 ` Arnd Bergmann @ 2020-04-18 1:52 ` Baolin Wang 0 siblings, 0 replies; 12+ messages in thread From: Baolin Wang @ 2020-04-18 1:52 UTC (permalink / raw) To: Arnd Bergmann Cc: Lee Jones, Mark Brown, Orson Zhai, Lyra Zhang, linux-kernel@vger.kernel.org On Fri, Apr 17, 2020 at 11:03 PM Arnd Bergmann <arnd@arndb.de> wrote: > > On Fri, Apr 17, 2020 at 4:10 PM Baolin Wang <baolin.wang7@gmail.com> wrote: > > On Fri, Apr 17, 2020 at 9:39 PM Arnd Bergmann <arnd@arndb.de> wrote: > > > On Fri, Apr 17, 2020 at 4:14 AM Baolin Wang <baolin.wang7@gmail.com> wrote: > > > > +static int sprd_syscon_init(void) > > > > +{ > > > > + syscon_register_phys_regmap_bus(&sprd_syscon_regmap); > > > > + > > > > + return 0; > > > > +} > > > > +core_initcall_sync(sprd_syscon_init); > > > > > > This no longer breaks at runtime based on the changes in the other > > > patch, but I still don't like how you have to manually load this module > > > on spreadtrum platforms. > > > > > > What I meant to suggest in my previous reply was to add the regmap_bus > > > instance into drivers/mfd/syscon.c itself. > > > > Sorry, I misunderstood your meaning before, but what you suggested > > will add some vendor-specific things into the common syscon driver, if > > other platforms have different update bits method, we will add another > > vendor-specific regmap bus into the syscon.c, which will make syscon.c > > more complicated. > > I think we can always deal with this once it gets too complex, as long > as the DT binding allows it. > > > But if you still prefer to add these vendor-specific things into the > > syscon.c, I will follow your suggestion in next version. Thanks. > > Yes, please do. Sure. Thanks. -- Baolin Wang ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2020-04-24 8:43 UTC | newest] Thread overview: 12+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2020-04-17 2:14 [PATCH 0/2] Add new reg_update_bits() support Baolin Wang 2020-04-17 2:14 ` [PATCH 1/2] mfd: syscon: Support physical regmap bus Baolin Wang 2020-04-24 8:11 ` 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
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).