Re: [PATCH 05/23] gpio: nomadik: extract GPIO platform driver from drivers/pinctrl/nomadik/

From: Théo Lebrun
Date: Wed Feb 21 2024 - 11:06:22 EST


Hello Bartosz,

On Mon Feb 19, 2024 at 5:08 PM CET, Bartosz Golaszewski wrote:
> On Wed, Feb 14, 2024 at 5:24 PM Théo Lebrun <theo.lebrun@xxxxxxxxxxx> wrote:
> >
> > Previously, drivers/pinctrl/nomadik/pinctrl-nomadik.c registered two
> > platform drivers: pinctrl & GPIO. Move the GPIO aspect to the
> > drivers/gpio/ folder, as would be expected.
> >
> > Both drivers are intertwined for a reason; pinctrl requires access to
> > GPIO registers for pinmuxing, pull-disable, disabling interrupts while
> > setting the muxing and wakeup control. Information sharing is done
> > through a shared array containing GPIO chips and a few helper
> > functions. That shared array is not touched from gpio-nomadik when
> > CONFIG_PINCTRL_NOMADIK is not defined.
> >
> > Make no change to the code that moved into gpio-nomadik; there should be
> > no behavior change following. A few functions are shared and header
> > comments are added. Checkpatch warnings are addressed. NUM_BANKS is
> > renamed to NMK_MAX_BANKS.
> >
> > It is supported to compile gpio-nomadik without pinctrl-nomadik. The
> > opposite is not true.
> >
> > Signed-off-by: Théo Lebrun <theo.lebrun@xxxxxxxxxxx>
> > ---
> > MAINTAINERS | 1 +
> > drivers/gpio/Kconfig | 12 +
> > drivers/gpio/Makefile | 1 +
> > drivers/gpio/gpio-nomadik.c | 660 +++++++++++++++++++
> > drivers/pinctrl/nomadik/Kconfig | 5 +-
> > drivers/pinctrl/nomadik/pinctrl-nomadik-db8500.c | 3 +-
> > drivers/pinctrl/nomadik/pinctrl-nomadik-stn8815.c | 3 +-
> > drivers/pinctrl/nomadik/pinctrl-nomadik.c | 722 +--------------------
> > .../linux/gpio/gpio-nomadik.h | 122 +++-
> > 9 files changed, 804 insertions(+), 725 deletions(-)
> >
> > diff --git a/MAINTAINERS b/MAINTAINERS
> > index 0cb2c459d1cf..3f864e773267 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -2474,6 +2474,7 @@ F: drivers/clk/clk-nomadik.c
> > F: drivers/clocksource/clksrc-dbx500-prcmu.c
> > F: drivers/dma/ste_dma40*
> > F: drivers/pmdomain/st/ste-ux500-pm-domain.c
> > +F: drivers/gpio/gpio-nomadik.c
> > F: drivers/hwspinlock/u8500_hsem.c
> > F: drivers/i2c/busses/i2c-nomadik.c
> > F: drivers/iio/adc/ab8500-gpadc.c
> > diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
> > index 1301cec94f12..ff83371251c1 100644
> > --- a/drivers/gpio/Kconfig
> > +++ b/drivers/gpio/Kconfig
> > @@ -478,6 +478,18 @@ config GPIO_MXS
> > select GPIO_GENERIC
> > select GENERIC_IRQ_CHIP
> >
> > +config GPIO_NOMADIK
> > + bool "Nomadik GPIO driver"
> > + depends on ARCH_U8500 || ARCH_NOMADIK || COMPILE_TEST
> > + select OF_GPIO
> > + select GPIOLIB_IRQCHIP
> > + help
> > + Say yes here to support the Nomadik SoC GPIO block.
> > +
> > + It handles up to 32 GPIOs per bank, that can all be interrupt sources.
> > + It is deeply interconnected with the associated pinctrl driver as GPIO
> > + registers handle muxing ("alternate functions") as well.
> > +
> > config GPIO_NPCM_SGPIO
> > bool "Nuvoton SGPIO support"
> > depends on ARCH_NPCM || COMPILE_TEST
> > diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
> > index 9e40af196aae..9fc2f5931b22 100644
> > --- a/drivers/gpio/Makefile
> > +++ b/drivers/gpio/Makefile
> > @@ -116,6 +116,7 @@ obj-$(CONFIG_GPIO_MT7621) += gpio-mt7621.o
> > obj-$(CONFIG_GPIO_MVEBU) += gpio-mvebu.o
> > obj-$(CONFIG_GPIO_MXC) += gpio-mxc.o
> > obj-$(CONFIG_GPIO_MXS) += gpio-mxs.o
> > +obj-$(CONFIG_GPIO_NOMADIK) += gpio-nomadik.o
> > obj-$(CONFIG_GPIO_NPCM_SGPIO) += gpio-npcm-sgpio.o
> > obj-$(CONFIG_GPIO_OCTEON) += gpio-octeon.o
> > obj-$(CONFIG_GPIO_OMAP) += gpio-omap.o
> > diff --git a/drivers/gpio/gpio-nomadik.c b/drivers/gpio/gpio-nomadik.c
> > new file mode 100644
> > index 000000000000..e39477e1a58f
> > --- /dev/null
> > +++ b/drivers/gpio/gpio-nomadik.c
> > @@ -0,0 +1,660 @@
> > +// SPDX-License-Identifier: GPL-2.0-only
> > +/*
> > + * GPIO driver for the IP block found in the Nomadik SoC; it is an AMBA device,
> > + * managing 32 pins with alternate functions. It can also handle the STA2X11
> > + * block from ST.
> > + *
> > + * The GPIO chips are shared with pinctrl-nomadik if used; it needs access for
> > + * pinmuxing functionality and others.
> > + *
> > + * Copyright (C) 2008,2009 STMicroelectronics
> > + * Copyright (C) 2009 Alessandro Rubini <rubini@xxxxxxxx>
> > + * Rewritten based on work by Prafulla WADASKAR <prafulla.wadaskar@xxxxxx>
> > + * Copyright (C) 2011-2013 Linus Walleij <linus.walleij@xxxxxxxxxx>
> > + */
>
> Add a newline here.

This commit tries its best to not modify the file too much. It mostly is
a copy-and-paste. The goal is to have a sensible diff between old
drivers/pinctrl/nomadik/pinctrl-nomadik.c and new
drivers/gpio/gpio-nomadik.c. We wait until later commits to fix stuff.

Should below comments "avoid new calls to X" still be taken into
account, knowing that this is old code being moved around?

Thanks,

--
Théo Lebrun, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

------------------------------------------------------------------------