Re: [PATCH v5 3/5] mfd: airoha: Add support for Airoha EN7581 MFD

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Oct 02, Lee Jones wrote:
> On Tue, 01 Oct 2024, Lorenzo Bianconi wrote:
> 
> > From: Christian Marangi <ansuelsmth@xxxxxxxxx>
> > 
> > Support for Airoha EN7581 Multi Function Device that
> > expose PINCTRL functionality and PWM functionality.
> 
> The device is a jumble of pinctrl registers, some of which can oscillate.
> 
> This is *still* not an MFD.
> 
> If you wish to spread this functionality over 2 drivers, use syscon to
> obtain the registers and simple-mfd to automatically probe the drivers.

Hi Lee,

IIUC you are suggesting two possible approaches here:

1- have a single driver implementing both pinctrl and pwm functionalities.
   This approach will not let us reuse the code for future devices that
   have just one of them in common, like pwm (but we can live with that).

2- use a device node like the one below (something similar to [0])

system-controller@1fbf0200 {
	compatible = "syscon", "simple-mfd";
	reg = <0x0 0x1fbf0200 0x0 0xc0>;

	interrupt-parent = <&gic>;
	interrupts = <GIC_SPI 26 IRQ_TYPE_LEVEL_HIGH>;

	gpio-controller;
	#gpio-cells = <2>;

	interrupt-controller;
	#interrupt-cells = <2>;

	pio: pinctrl {
		compatible = "airoha,en7581-pinctrl";

		[ some pinctrl properties here ]
	};

	#pwm-cells = <3>;

	pwm {
		compatible = "airoha,en7581-pwm";
	};
};

Please correct me if I am wrong, but using syscon/simple-mfd as compatible
string for the 'parent' device, will require to introduce the compatible strings
even for the child devices in order to probe them, correct? 
If so, as pointed out by Christian, this is something nacked by Rob/Krzysztof/Conor
(this is the main reason why we introduced a full mfd driver here).

@Rob, Krzysztof, Conor: am I right?

I guess we need to find a middle ground here between mfd and dts to support this
uncommon hw device.

Regards,
Lorenzo

[0] https://elixir.bootlin.com/linux/v6.11.2/source/arch/arm64/boot/dts/marvell/armada-ap80x.dtsi#L269

> 
> > Signed-off-by: Christian Marangi <ansuelsmth@xxxxxxxxx>
> > ---
> >  drivers/mfd/Kconfig                   |  8 ++++
> >  drivers/mfd/Makefile                  |  2 +
> >  drivers/mfd/airoha-en7581-gpio-mfd.c  | 72 +++++++++++++++++++++++++++++++++++
> >  include/linux/mfd/airoha-en7581-mfd.h |  9 +++++
> >  4 files changed, 91 insertions(+)
> > 
> > diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
> > index f9325bcce1b9..eca221351ab7 100644
> > --- a/drivers/mfd/Kconfig
> > +++ b/drivers/mfd/Kconfig
> > @@ -32,6 +32,14 @@ config MFD_ADP5585
> >  	  the core APIs _only_, you have to select individual components like
> >  	  the GPIO and PWM functions under the corresponding menus.
> >  
> > +config MFD_AIROHA_EN7581
> > +	bool "Airoha EN7581 Multi Function Device"
> > +	depends on (ARCH_AIROHA || COMPILE_TEST) && OF
> > +	select MFD_CORE
> > +	help
> > +	  Support for Airoha EN7581 Multi Function Device that
> > +	  expose PINCTRL functionality and PWM functionality.
> > +
> >  config MFD_ALTERA_A10SR
> >  	bool "Altera Arria10 DevKit System Resource chip"
> >  	depends on ARCH_INTEL_SOCFPGA && SPI_MASTER=y && OF
> > diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
> > index 2a9f91e81af8..be8448e81a5b 100644
> > --- a/drivers/mfd/Makefile
> > +++ b/drivers/mfd/Makefile
> > @@ -257,6 +257,8 @@ obj-$(CONFIG_INTEL_SOC_PMIC_CHTWC)	+= intel_soc_pmic_chtwc.o
> >  obj-$(CONFIG_INTEL_SOC_PMIC_CHTDC_TI)	+= intel_soc_pmic_chtdc_ti.o
> >  obj-$(CONFIG_INTEL_SOC_PMIC_MRFLD)	+= intel_soc_pmic_mrfld.o
> >  
> > +obj-$(CONFIG_MFD_AIROHA_EN7581)	+= airoha-en7581-gpio-mfd.o
> > +
> >  obj-$(CONFIG_MFD_ALTERA_A10SR)	+= altera-a10sr.o
> >  obj-$(CONFIG_MFD_ALTERA_SYSMGR) += altera-sysmgr.o
> >  obj-$(CONFIG_MFD_STPMIC1)	+= stpmic1.o
> > diff --git a/drivers/mfd/airoha-en7581-gpio-mfd.c b/drivers/mfd/airoha-en7581-gpio-mfd.c
> > new file mode 100644
> > index 000000000000..88407ce5747e
> > --- /dev/null
> > +++ b/drivers/mfd/airoha-en7581-gpio-mfd.c
> > @@ -0,0 +1,72 @@
> > +// SPDX-License-Identifier: GPL-2.0+
> > +/*
> > + * MFD driver for Airoha EN7581
> > + */
> > +
> > +#include <linux/io.h>
> > +#include <linux/of.h>
> > +#include <linux/mfd/airoha-en7581-mfd.h>
> > +#include <linux/mfd/core.h>
> > +#include <linux/module.h>
> > +
> > +static struct resource airoha_mfd_pinctrl_intr[] = {
> > +	{
> > +		.flags = IORESOURCE_IRQ,
> > +	},
> > +};
> > +
> > +static const struct mfd_cell airoha_mfd_devs[] = {
> > +	{
> > +		.name = "pinctrl-airoha",
> > +		.resources = airoha_mfd_pinctrl_intr,
> > +		.num_resources = ARRAY_SIZE(airoha_mfd_pinctrl_intr),
> > +	}, {
> > +		.name = "pwm-airoha",
> > +	},
> > +};
> > +
> > +static int airoha_mfd_probe(struct platform_device *pdev)
> > +{
> > +	struct device *dev = &pdev->dev;
> > +	struct airoha_mfd *mfd;
> > +	int irq;
> > +
> > +	mfd = devm_kzalloc(dev, sizeof(*mfd), GFP_KERNEL);
> > +	if (!mfd)
> > +		return -ENOMEM;
> > +
> > +	platform_set_drvdata(pdev, mfd);
> > +
> > +	mfd->base = devm_platform_ioremap_resource(pdev, 0);
> > +	if (IS_ERR(mfd->base))
> > +		return PTR_ERR(mfd->base);
> > +
> > +	irq = platform_get_irq(pdev, 0);
> > +	if (irq < 0)
> > +		return irq;
> > +
> > +	airoha_mfd_pinctrl_intr[0].start = irq;
> > +	airoha_mfd_pinctrl_intr[0].end = irq;
> > +
> > +	return devm_mfd_add_devices(dev, PLATFORM_DEVID_AUTO, airoha_mfd_devs,
> > +				    ARRAY_SIZE(airoha_mfd_devs), NULL, 0,
> > +				    NULL);
> > +}
> > +
> > +static const struct of_device_id airoha_mfd_of_match[] = {
> > +	{ .compatible = "airoha,en7581-gpio-sysctl" },
> > +	{ /* sentinel */ }
> > +};
> > +MODULE_DEVICE_TABLE(of, airoha_mfd_of_match);
> > +
> > +static struct platform_driver airoha_mfd_driver = {
> > +	.probe = airoha_mfd_probe,
> > +	.driver = {
> > +		.name = KBUILD_MODNAME,
> > +		.of_match_table = airoha_mfd_of_match,
> > +	},
> > +};
> > +module_platform_driver(airoha_mfd_driver);
> > +
> > +MODULE_AUTHOR("Christian Marangi <ansuelsmth@xxxxxxxxx>");
> > +MODULE_DESCRIPTION("Driver for Airoha EN7581 MFD");
> > diff --git a/include/linux/mfd/airoha-en7581-mfd.h b/include/linux/mfd/airoha-en7581-mfd.h
> > new file mode 100644
> > index 000000000000..25e73952a777
> > --- /dev/null
> > +++ b/include/linux/mfd/airoha-en7581-mfd.h
> > @@ -0,0 +1,9 @@
> > +/* SPDX-License-Identifier: GPL-2.0 */
> > +#ifndef _LINUX_INCLUDE_MFD_AIROHA_EN7581_MFD_H_
> > +#define _LINUX_INCLUDE_MFD_AIROHA_EN7581_MFD_H_
> > +
> > +struct airoha_mfd {
> > +	void __iomem *base;
> > +};
> > +
> > +#endif  /* _LINUX_INCLUDE_MFD_AIROHA_EN7581_MFD_H_ */
> > 
> > -- 
> > 2.46.2
> > 
> 
> -- 
> Lee Jones [李琼斯]

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux