Re: [PATCH 4/6] mfd: sprd-sc27xx: Switch to devm_mfd_add_devices()
From: Lee Jones
Date: Mon Mar 09 2026 - 15:00:42 EST
On Sun, 22 Feb 2026, Otto Pflüger wrote:
> To allow instantiating subdevices such as the regulator and poweroff
> devices that do not have corresponding device tree nodes with a
> "compatible" property, use devm_mfd_add_devices() with MFD cells instead
> of devm_of_platform_populate(). Since different PMICs in the SC27xx
> series contain different components, use separate MFD cell tables for
> each PMIC model. Define cells for all components that have upstream
> drivers at this point.
We're not passing one device registration API's data (MFD)
through another (Device Tree).
Pass an identifier through and match on that instead.
Look at how all of the other drivers in MFD do it.
> Signed-off-by: Otto Pflüger <otto.pflueger@xxxxxxxxx>
> ---
> drivers/mfd/sprd-sc27xx-spi.c | 33 ++++++++++++++++++++++++++++++++-
> 1 file changed, 32 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mfd/sprd-sc27xx-spi.c b/drivers/mfd/sprd-sc27xx-spi.c
> index d6b4350779e6..57941bec4c2e 100644
> --- a/drivers/mfd/sprd-sc27xx-spi.c
> +++ b/drivers/mfd/sprd-sc27xx-spi.c
> @@ -48,6 +48,31 @@ struct sprd_pmic_data {
> u32 irq_base;
> u32 num_irqs;
> u32 charger_det;
> + const struct mfd_cell *cells;
> + int num_cells;
> +};
> +
> +static const struct mfd_cell sc2730_devices[] = {
> + MFD_CELL_OF("sc2730-adc", NULL, NULL, 0, 0, "sprd,sc2730-adc"),
> + MFD_CELL_OF("sc2730-bltc", NULL, NULL, 0, 0, "sprd,sc2730-bltc"),
> + MFD_CELL_OF("sc2730-efuse", NULL, NULL, 0, 0, "sprd,sc2730-efuse"),
> + MFD_CELL_OF("sc2730-eic", NULL, NULL, 0, 0, "sprd,sc2730-eic"),
> + MFD_CELL_OF("sc2730-fgu", NULL, NULL, 0, 0, "sprd,sc2730-fgu"),
> + MFD_CELL_OF("sc2730-rtc", NULL, NULL, 0, 0, "sprd,sc2730-rtc"),
> + MFD_CELL_OF("sc2730-vibrator", NULL, NULL, 0, 0, "sprd,sc2730-vibrator"),
> +};
> +
> +static const struct mfd_cell sc2731_devices[] = {
> + MFD_CELL_OF("sc2731-adc", NULL, NULL, 0, 0, "sprd,sc2731-adc"),
> + MFD_CELL_OF("sc2731-bltc", NULL, NULL, 0, 0, "sprd,sc2731-bltc"),
> + MFD_CELL_OF("sc2731-charger", NULL, NULL, 0, 0, "sprd,sc2731-charger"),
> + MFD_CELL_OF("sc2731-efuse", NULL, NULL, 0, 0, "sprd,sc2731-efuse"),
> + MFD_CELL_OF("sc2731-eic", NULL, NULL, 0, 0, "sprd,sc2731-eic"),
> + MFD_CELL_OF("sc2731-fgu", NULL, NULL, 0, 0, "sprd,sc2731-fgu"),
> + MFD_CELL_NAME("sc2731-poweroff"),
> + MFD_CELL_NAME("sc2731-regulator"),
> + MFD_CELL_OF("sc2731-rtc", NULL, NULL, 0, 0, "sprd,sc2731-rtc"),
> + MFD_CELL_OF("sc2731-vibrator", NULL, NULL, 0, 0, "sprd,sc2731-vibrator"),
> };
>
> /*
> @@ -59,12 +84,16 @@ static const struct sprd_pmic_data sc2730_data = {
> .irq_base = SPRD_SC2730_IRQ_BASE,
> .num_irqs = SPRD_SC2730_IRQ_NUMS,
> .charger_det = SPRD_SC2730_CHG_DET,
> + .cells = sc2730_devices,
> + .num_cells = ARRAY_SIZE(sc2730_devices),
> };
>
> static const struct sprd_pmic_data sc2731_data = {
> .irq_base = SPRD_SC2731_IRQ_BASE,
> .num_irqs = SPRD_SC2731_IRQ_NUMS,
> .charger_det = SPRD_SC2731_CHG_DET,
> + .cells = sc2731_devices,
> + .num_cells = ARRAY_SIZE(sc2731_devices),
> };
>
> enum usb_charger_type sprd_pmic_detect_charger_type(struct device *dev)
> @@ -204,7 +233,9 @@ static int sprd_pmic_probe(struct spi_device *spi)
> return ret;
> }
>
> - ret = devm_of_platform_populate(&spi->dev);
> + ret = devm_mfd_add_devices(&spi->dev, PLATFORM_DEVID_AUTO,
> + pdata->cells, pdata->num_cells, NULL, 0,
> + regmap_irq_get_domain(ddata->irq_data));
> if (ret) {
> dev_err(&spi->dev, "Failed to populate sub-devices %d\n", ret);
> return ret;
>
> --
> 2.51.0
>
--
Lee Jones [李琼斯]