From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B7D47CF0429 for ; Tue, 8 Oct 2024 22:06:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ftZBiJ2+BWlNhoPFooXyX2hIQpyNbRxXcdaqaeWC2x0=; b=Cevya5HtgL2GoUPMC989bNMSeF DjggcDWxMiFZdsiRrOLapAPf4VUICM7ShQ7MpRJAqrqRorw+88HMS5BFRFPt+acHKUzHF7m3X5Fc7 u0H834RaDRxq/BqMIQOqvqLUjIK87rO4jdvNnGL+S5b43d74n/pR3C+hlYr4fk0pZ9H4w0oTDHSse 5VZy8ISUMS3Ut/4DPZxCt9ZiT9+ZPIgit08tuKTAe2UtNAgS1TGEs7N/vpwOOqUGYBSdRi7W2GzAA UA1bXLnzQ/vPJEHYyrgF7MUBBTfWy5OKnK1qSchIuckFfYqRt8c6Bzl2sItPmflOjuD1QFKqvL7Uh g0VB+n+Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1syIL9-00000007EoZ-3PEN; Tue, 08 Oct 2024 22:05:59 +0000 Received: from nyc.source.kernel.org ([147.75.193.91]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1syIJp-00000007Ed9-1f4I; Tue, 08 Oct 2024 22:04:38 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 49C97A436BC; Tue, 8 Oct 2024 22:04:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 394CDC4CECF; Tue, 8 Oct 2024 22:04:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728425075; bh=ms7y13SKSl3l6x54yKv0dqYa0hkXrQlTObop68w2TTI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=clxtKb6uPWfUDdD1z+NjKt4020Xf1psaH3OQVC3cD4jDYPJWXAHFmHyJcBvcZ5DYw r2yUu15NRPsHpKLM48JiRf8G4jN5hXP15K03DUppXPtn7rAH9bKT75MIdg3VFVzhb0 hYT2IL21c5XIRJECdGWnNfUegiUMWKvu6zAut6bGuIV0RydpOqOjcVz8VGwDKlIP1H IDI2Cwc8Qa/N/BvMSM1vp0g2Jy1cyaiPdoU3CJ0Bx/zNXrkN0mrSieEoX+m9OXo3R9 Arcqd9hwGNKGfX9Nst20wL/IJ2giwlTEwU6ooSENHogKWxiWXcO0nyuweXFRBznC9o NdMgHmAoRYFYw== Date: Wed, 9 Oct 2024 00:04:33 +0200 From: Lorenzo Bianconi To: Lee Jones Cc: Linus Walleij , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sean Wang , Matthias Brugger , AngeloGioacchino Del Regno , Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= , linux-mediatek@lists.infradead.org, linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, upstream@airoha.com, benjamin.larsson@genexis.eu, ansuelsmth@gmail.com, linux-pwm@vger.kernel.org Subject: Re: [PATCH v5 3/5] mfd: airoha: Add support for Airoha EN7581 MFD Message-ID: References: <20241001-en7581-pinctrl-v5-0-dc1ce542b6c6@kernel.org> <20241001-en7581-pinctrl-v5-3-dc1ce542b6c6@kernel.org> <20241002132518.GD7504@google.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="Ck0ElvyZLVpyJemd" Content-Disposition: inline In-Reply-To: <20241002132518.GD7504@google.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241008_150437_596212_9AAC4BD3 X-CRM114-Status: GOOD ( 35.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org --Ck0ElvyZLVpyJemd Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Oct 02, Lee Jones wrote: > On Tue, 01 Oct 2024, Lorenzo Bianconi wrote: >=20 > > From: Christian Marangi > >=20 > > Support for Airoha EN7581 Multi Function Device that > > expose PINCTRL functionality and PWM functionality. >=20 > The device is a jumble of pinctrl registers, some of which can oscillate. >=20 > This is *still* not an MFD. >=20 > 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 =3D "syscon", "simple-mfd"; reg =3D <0x0 0x1fbf0200 0x0 0xc0>; interrupt-parent =3D <&gic>; interrupts =3D ; gpio-controller; #gpio-cells =3D <2>; interrupt-controller; #interrupt-cells =3D <2>; pio: pinctrl { compatible =3D "airoha,en7581-pinctrl"; [ some pinctrl properties here ] }; #pwm-cells =3D <3>; pwm { compatible =3D "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 st= rings even for the child devices in order to probe them, correct?=20 If so, as pointed out by Christian, this is something nacked by Rob/Krzyszt= of/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/mar= vell/armada-ap80x.dtsi#L269 >=20 > > Signed-off-by: Christian Marangi > > --- > > 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(+) > >=20 > > 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. > > =20 > > +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=3Dy && 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) +=3D intel_soc_p= mic_chtwc.o > > obj-$(CONFIG_INTEL_SOC_PMIC_CHTDC_TI) +=3D intel_soc_pmic_chtdc_ti.o > > obj-$(CONFIG_INTEL_SOC_PMIC_MRFLD) +=3D intel_soc_pmic_mrfld.o > > =20 > > +obj-$(CONFIG_MFD_AIROHA_EN7581) +=3D airoha-en7581-gpio-mfd.o > > + > > obj-$(CONFIG_MFD_ALTERA_A10SR) +=3D altera-a10sr.o > > obj-$(CONFIG_MFD_ALTERA_SYSMGR) +=3D altera-sysmgr.o > > obj-$(CONFIG_MFD_STPMIC1) +=3D 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 > > +#include > > +#include > > +#include > > +#include > > + > > +static struct resource airoha_mfd_pinctrl_intr[] =3D { > > + { > > + .flags =3D IORESOURCE_IRQ, > > + }, > > +}; > > + > > +static const struct mfd_cell airoha_mfd_devs[] =3D { > > + { > > + .name =3D "pinctrl-airoha", > > + .resources =3D airoha_mfd_pinctrl_intr, > > + .num_resources =3D ARRAY_SIZE(airoha_mfd_pinctrl_intr), > > + }, { > > + .name =3D "pwm-airoha", > > + }, > > +}; > > + > > +static int airoha_mfd_probe(struct platform_device *pdev) > > +{ > > + struct device *dev =3D &pdev->dev; > > + struct airoha_mfd *mfd; > > + int irq; > > + > > + mfd =3D devm_kzalloc(dev, sizeof(*mfd), GFP_KERNEL); > > + if (!mfd) > > + return -ENOMEM; > > + > > + platform_set_drvdata(pdev, mfd); > > + > > + mfd->base =3D devm_platform_ioremap_resource(pdev, 0); > > + if (IS_ERR(mfd->base)) > > + return PTR_ERR(mfd->base); > > + > > + irq =3D platform_get_irq(pdev, 0); > > + if (irq < 0) > > + return irq; > > + > > + airoha_mfd_pinctrl_intr[0].start =3D irq; > > + airoha_mfd_pinctrl_intr[0].end =3D 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[] =3D { > > + { .compatible =3D "airoha,en7581-gpio-sysctl" }, > > + { /* sentinel */ } > > +}; > > +MODULE_DEVICE_TABLE(of, airoha_mfd_of_match); > > + > > +static struct platform_driver airoha_mfd_driver =3D { > > + .probe =3D airoha_mfd_probe, > > + .driver =3D { > > + .name =3D KBUILD_MODNAME, > > + .of_match_table =3D airoha_mfd_of_match, > > + }, > > +}; > > +module_platform_driver(airoha_mfd_driver); > > + > > +MODULE_AUTHOR("Christian Marangi "); > > +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_ */ > >=20 > > --=20 > > 2.46.2 > >=20 >=20 > --=20 > Lee Jones [=E6=9D=8E=E7=90=BC=E6=96=AF] --Ck0ElvyZLVpyJemd Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQTquNwa3Txd3rGGn7Y6cBh0uS2trAUCZwWscAAKCRA6cBh0uS2t rEz/AQCFBJOOtzJqJ2Zgfn+hqeD0mG44RsxTxw/hCr8oWqE2TAD8CvJfaYJ/spUO GPey9tflRamTmCSiSKdx1wZE17e4Gwc= =OMHu -----END PGP SIGNATURE----- --Ck0ElvyZLVpyJemd--