Re: [v12, 5/8] soc: fsl: add GUTS driver for QorIQ platforms

From: Scott Wood
Date: Wed Oct 26 2016 - 13:09:09 EST


On Wed, 2016-09-21 at 14:57 +0800, Yangbo Lu wrote:
> diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig
> new file mode 100644
> index 0000000..b99764c
> --- /dev/null
> +++ b/drivers/soc/fsl/Kconfig
> @@ -0,0 +1,19 @@
> +#
> +# Freescale SOC drivers
> +#
> +
> +source "drivers/soc/fsl/qe/Kconfig"
> +
> +config FSL_GUTS
> + bool "Freescale QorIQ GUTS driver"
> + select SOC_BUS
> + help
> + ÂÂThe global utilities block controls power management, I/O device
> + ÂÂenabling, power-onreset(POR) configuration monitoring, alternate
> + ÂÂfunction selection for multiplexed signals,and clock control.
> + ÂÂThis driver is to manage and access global utilities block.
> + ÂÂInitially only reading SVR and registering soc device are
> supported.
> + ÂÂOther guts accesses, such as reading RCW, should eventually be
> moved
> + ÂÂinto this driver as well.
> +
> + ÂÂIf you want GUTS driver support, you should say Y here.

This is user-enablable without dependencies, which means it will break some
randconfigs. ÂIf this is to be enabled via select then remove the text after
"bool".

> +/* SoC die attribute definition for QorIQ platform */
> +static const struct fsl_soc_die_attr fsl_soc_die[] = {
> +#ifdef CONFIG_PPC
> + /*
> + Â* Power Architecture-based SoCs T Series
> + Â*/
> +
> + /* Die: T4240, SoC: T4240/T4160/T4080 */
> + { .die = "T4240",
> + ÂÂ.svr = 0x82400000,
> + ÂÂ.mask = 0xfff00000,
> + },
> + /* Die: T1040, SoC: T1040/T1020/T1042/T1022 */
> + { .die = "T1040",
> + ÂÂ.svr = 0x85200000,
> + ÂÂ.mask = 0xfff00000,
> + },
> + /* Die: T2080, SoC: T2080/T2081 */
> + { .die = "T2080",
> + ÂÂ.svr = 0x85300000,
> + ÂÂ.mask = 0xfff00000,
> + },
> + /* Die: T1024, SoC: T1024/T1014/T1023/T1013 */
> + { .die = "T1024",
> + ÂÂ.svr = 0x85400000,
> + ÂÂ.mask = 0xfff00000,
> + },
> +#endif /* CONFIG_PPC */
> +#if defined(CONFIG_ARCH_MXC) || defined(CONFIG_ARCH_LAYERSCAPE)

Will this driver ever be probed on MXC? ÂWhy do we need these ifdefs at all?


> + /*
> + Â* ARM-based SoCs LS Series
> + Â*/
> +
> + /* Die: LS1043A, SoC: LS1043A/LS1023A */
> + { .die = "LS1043A",
> + ÂÂ.svr = 0x87920000,
> + ÂÂ.mask = 0xffff0000,
> + },
> + /* Die: LS2080A, SoC: LS2080A/LS2040A/LS2085A */
> + { .die = "LS2080A",
> + ÂÂ.svr = 0x87010000,
> + ÂÂ.mask = 0xff3f0000,
> + },
> + /* Die: LS1088A, SoC: LS1088A/LS1048A/LS1084A/LS1044A */
> + { .die = "LS1088A",
> + ÂÂ.svr = 0x87030000,
> + ÂÂ.mask = 0xff3f0000,
> + },
> + /* Die: LS1012A, SoC: LS1012A */
> + { .die = "LS1012A",
> + ÂÂ.svr = 0x87040000,
> + ÂÂ.mask = 0xffff0000,
> + },
> + /* Die: LS1046A, SoC: LS1046A/LS1026A */
> + { .die = "LS1046A",
> + ÂÂ.svr = 0x87070000,
> + ÂÂ.mask = 0xffff0000,
> + },
> + /* Die: LS2088A, SoC: LS2088A/LS2048A/LS2084A/LS2044A */
> + { .die = "LS2088A",
> + ÂÂ.svr = 0x87090000,
> + ÂÂ.mask = 0xff3f0000,
> + },
> + /* Die: LS1021A, SoC: LS1021A/LS1020A/LS1022A
> + Â* Note: Put this die at the end in cause of incorrect
> identification
> + Â*/
> + { .die = "LS1021A",
> + ÂÂ.svr = 0x87000000,
> + ÂÂ.mask = 0xfff00000,
> + },
> +#endif /* CONFIG_ARCH_MXC || CONFIG_ARCH_LAYERSCAPE */

Instead of relying on ordering, add more bits to the mask so that there's no
overlap. ÂI think 0xfff70000 would work.

> +out:
> + kfree(soc_dev_attr.machine);
> + kfree(soc_dev_attr.family);
> + kfree(soc_dev_attr.soc_id);
> + kfree(soc_dev_attr.revision);
> + iounmap(guts->regs);
> +out_free:
> + kfree(guts);
> + return ret;
> +}

Please use devm.

-Scott