Re: [PATCH 1/2] mfd: syscon: Support physical regmap bus

From: Lee Jones
Date: Fri Apr 24 2020 - 04:11:44 EST


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@xxxxxxxxx>
> ---
> 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