Re: [RFC PATCH v2 3/3] soc: sprd: Add Spreadtrum special bits updating support

From: Arnd Bergmann
Date: Thu Apr 16 2020 - 10:39:11 EST


On Thu, Apr 16, 2020 at 3:49 PM Baolin Wang <baolin.wang7@xxxxxxxxx> wrote:

>
> OK, I think adding a Spreadtrum compatible string will be an easy and
> clear way, so what about below sample code?
>
> DT:
> ap_ahb_regs: syscon@20210000 {
> compatible = "sprd,sc9860-syscon", "syscon";
> reg = <0 0x20210000 0 0x10000>;
> };
>
> /* The Spreadtrum syscon need register a real physical regmap bus with
> new bits updating method. */
> if (of_device_is_compatible(np, "sprd,sc9860-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);

Ok, sounds good. Maybe also define another compatible string that
is more generic than "sprd,sc9860-syscon" (but less generic than
"syscon") so you can still identify the chip specific syscon area if
necessary, while not having to list each future chip individually.

Something like

compatible = "sprd,sc9860-syscon", "sprd,atomic-syscon", "syscon";

Also I'd add an IS_ENABLED() check so it gets the 'else' path
at compile-time when CONFIG_ARCH_SPRD is disabled.

Arnd