Skip to contentSkip to conversation

gpio: move ppc4xx driver to drivers/gpio and modernize

PATCH Superseded Rosen Penev 5 participants 19 messages Jun 2 – Jul 30

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover gpio: move ppc4xx driver to drivers/gpio and modernize

This series moves the ppc4xx GPIO driver from arch/powerpc to drivers/gpio, converts it to be a proper platform driver using generic MMIO helpers, drops architecture-specific accessors, and prepares it for module build and COMPILE_TEST.

Patches 1-4 move the driver and convert it to standard platform driver infrastructure. Patch 5 switches to generic MMIO helpers. Patch 6 drops PPC-specific IO accessors and enables COMPILE_TEST. Patch 7 adds the missing MODULE metadata so the driver can actually be built as a module.

Rosen Penev (7):
gpio: move ppc4xx gpio driver from arch/powerpc to drivers/gpio
gpio: ppc44x: Use module platform driver helper for GPIO
gpio: ppc44x: Set GPIO chip firmware node
gpio: ppc44x: Use platform resource helper for GPIO MMIO
gpio: ppc44x: Convert GPIO to generic MMIO
gpio: ppc44x: drop PPC-specific IO helpers and rename to ppc44x
gpio: ppc44x: add MODULE info

 arch/powerpc/configs/44x/warp_defconfig |   2 +-
 arch/powerpc/configs/ppc44x_defconfig   |   2 +-
 arch/powerpc/platforms/44x/Kconfig      |   7 -
 arch/powerpc/platforms/44x/Makefile     |   2 +-
 arch/powerpc/platforms/44x/gpio.c       | 210 -----------------------
 drivers/gpio/Kconfig                    |   7 +
 drivers/gpio/Makefile                   |   1 +
 drivers/gpio/gpio-ppc44x.c              | 217 ++++++++++++++++++++++++
 8 files changed, 228 insertions(+), 220 deletions(-)
 delete mode 100644 arch/powerpc/platforms/44x/gpio.c
 create mode 100644 drivers/gpio/gpio-ppc44x.c
Signature · 1 line
2.54.0
#1 lore raw

PATCH 1/7 gpio: move ppc4xx gpio driver from arch/powerpc to drivers/gpio

Move the ppc4xx gpio driver out of arch/powerpc/platforms/44x/ into drivers/gpio/gpio-ppc44x.c. The driver has no architecture-specific dependencies and follows the same pattern as other PowerPC GPIO drivers already in drivers/gpio/ (e.g. gpio-mpc8xxx, gpio-mpc5200).

- Renamed Kconfig symbol from PPC4xx_GPIO to GPIO_PPC44X
- Updated ppc44x_defconfig and warp_defconfig to use the new symbol
- Marked the new option as tristate (was bool) since the driver supports module build via module_platform_driver()

Assisted-by opencode:big-pickle
---
 arch/powerpc/configs/44x/warp_defconfig                   | 2 +-
 arch/powerpc/configs/ppc44x_defconfig                     | 2 +-
 arch/powerpc/platforms/44x/Kconfig                        | 7 -------
 arch/powerpc/platforms/44x/Makefile                       | 2 +-
 drivers/gpio/Kconfig                                      | 8 ++++++++
 drivers/gpio/Makefile                                     | 1 +
 .../platforms/44x/gpio.c => drivers/gpio/gpio-ppc44x.c    | 0
 7 files changed, 12 insertions(+), 10 deletions(-)
 rename arch/powerpc/platforms/44x/gpio.c => drivers/gpio/gpio-ppc44x.c (100%)
arch/powerpc/configs/44x/warp_defconfig +1 -1
index 5757625469c4..d6014b9c5708 100644
@@ -12,7 +12,7 @@ CONFIG_MODULE_UNLOAD=y
 # CONFIG_BLK_DEV_BSG is not set
 # CONFIG_EBONY is not set
 CONFIG_WARP=y
-CONFIG_PPC4xx_GPIO=y
+CONFIG_GPIO_PPC44X=y
 CONFIG_HZ_1000=y
 CONFIG_CMDLINE="ip=on"
 # CONFIG_PCI is not set
arch/powerpc/configs/ppc44x_defconfig +1 -1
index 41c930f74ed4..b0c7ad8c6d9b 100644
@@ -22,7 +22,7 @@ CONFIG_GLACIER=y
 CONFIG_REDWOOD=y
 CONFIG_EIGER=y
 CONFIG_YOSEMITE=y
-CONFIG_PPC4xx_GPIO=y
+CONFIG_GPIO_PPC44X=y
 CONFIG_MATH_EMULATION=y
 CONFIG_NET=y
 CONFIG_PACKET=y
arch/powerpc/platforms/44x/Kconfig +0 -7
index fc79f8466933..150813cea945 100644
@@ -227,13 +227,6 @@ config PPC44x_SIMPLE
 	help
 	  This option enables the simple PowerPC 44x platform support.
 
-config PPC4xx_GPIO
-	bool "PPC4xx GPIO support"
-	depends on 44x
-	select GPIOLIB
-	help
-	  Enable gpiolib support for ppc440 based boards
-
 # 44x specific CPU modules, selected based on the board above.
 config 440EP
 	bool
arch/powerpc/platforms/44x/Makefile +1 -1
index ca7b1bb442d9..4598d8b89bf4 100644
@@ -15,4 +15,4 @@ obj-$(CONFIG_FSP2)	+= fsp2.o
 obj-$(CONFIG_PCI)		+= pci.o
 obj-$(CONFIG_PPC4xx_HSTA_MSI)	+= hsta_msi.o
 obj-$(CONFIG_PPC4xx_CPM)	+= cpm.o
-obj-$(CONFIG_PPC4xx_GPIO)	+= gpio.o
+
drivers/gpio/Kconfig +8 -0
index 89c77ec6c205..77991da43ec1 100644
@@ -593,6 +593,14 @@ config GPIO_POLARFIRE_SOC
 	help
 	  Say yes here to support the GPIO controllers on Microchip FPGAs.
 
+config GPIO_PPC44X
+	tristate "PPC44x GPIO support"
+	depends on 44x
+	select GPIO_GENERIC
+	select GPIOLIB
+	help
+	  Enable gpiolib support for ppc440 based boards.
+
 config GPIO_PXA
 	bool "PXA GPIO support"
 	depends on ARCH_PXA || ARCH_MMP || COMPILE_TEST
drivers/gpio/Makefile +1 -0
index 8ec03c9aec20..9e8c9ca1d3fb 100644
@@ -146,6 +146,7 @@ obj-$(CONFIG_GPIO_PCIE_IDIO_24)		+= gpio-pcie-idio-24.o
 obj-$(CONFIG_GPIO_PCI_IDIO_16)		+= gpio-pci-idio-16.o
 obj-$(CONFIG_GPIO_PISOSR)		+= gpio-pisosr.o
 obj-$(CONFIG_GPIO_PL061)		+= gpio-pl061.o
+obj-$(CONFIG_GPIO_PPC44X)		+= gpio-ppc44x.o
 obj-$(CONFIG_GPIO_PMIC_EIC_SPRD)	+= gpio-pmic-eic-sprd.o
 obj-$(CONFIG_GPIO_POLARFIRE_SOC)	+= gpio-mpfs.o
 obj-$(CONFIG_GPIO_PXA)			+= gpio-pxa.o
drivers/gpio/gpio-ppc44x.c renamed from arch/powerpc/platforms/44x/gpio.c +0 -0
similarity index 100%
rename from arch/powerpc/platforms/44x/gpio.c
rename to drivers/gpio/gpio-ppc44x.c
Signature · 1 line
2.54.0
#2 lore raw

PATCH 2/7 gpio: ppc44x: Use module platform driver helper for GPIO

In reply to Rosen Penev

Replace the open-coded arch initcall registration with module_platform_driver(). The initcall level changes from arch_initcall to device_initcall, which is safe since the driver no longer needs architecture-specific ordering.

Assisted-by Codex:GPT-5.5
---
 drivers/gpio/gpio-ppc44x.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/gpio/gpio-ppc44x.c +1 -5
index aea0d913b59d..0d2244272e32 100644
@@ -203,8 +203,4 @@ static struct platform_driver ppc4xx_gpio_driver = {
 	},
 };
 
-static int __init ppc4xx_gpio_init(void)
-{
-	return platform_driver_register(&ppc4xx_gpio_driver);
-}
-arch_initcall(ppc4xx_gpio_init);
+module_platform_driver(ppc4xx_gpio_driver);
Signature · 1 line
2.54.0
#3 lore raw

PATCH 3/7 gpio: ppc44x: Set GPIO chip firmware node

In reply to Rosen Penev

The PPC4xx GPIO driver stopped assigning an explicit firmware node to the gpio_chip when it moved away from of_mm_gpiochip_add_data().

Restore that association from the platform device so OF GPIO lookup can match phandles to the registered gpiochip.

Tested on: Cisco MX60W. No more probe deferral.

Assisted-by Codex:GPT-5.5
Fixes 1044dbaf2a77 ("powerpc/44x: Change GPIO driver to a proper platform driver")
---
 drivers/gpio/gpio-ppc44x.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpio/gpio-ppc44x.c +2 -0
index 0d2244272e32..07b699cc4dd9 100644
@@ -169,6 +169,8 @@ static int ppc4xx_gpio_probe(struct platform_device *ofdev)
 
 	gc = &chip->gc;
 
+	gc->parent = dev;
+	gc->fwnode = dev_fwnode(dev);
 	gc->base = -1;
 	gc->ngpio = 32;
 	gc->direction_input = ppc4xx_gpio_dir_in;
Signature · 1 line
2.54.0
#4 lore raw

PATCH 4/7 gpio: ppc44x: Use platform resource helper for GPIO MMIO

In reply to Rosen Penev

Map the PPC44x GPIO register block through the platform device resource instead of reparsing the firmware node directly.

The GPIO node now probes as a platform device, so use the platform helper to keep resource handling aligned with the converted driver model and to report mapping failures with the platform device context.

Assisted-by Codex:GPT-5.5
---
 drivers/gpio/gpio-ppc44x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-ppc44x.c +1 -1
index 07b699cc4dd9..b30ca357ab74 100644
@@ -182,7 +182,7 @@ static int ppc4xx_gpio_probe(struct platform_device *ofdev)
 	if (!gc->label)
 		return -ENOMEM;
 
-	chip->regs = devm_of_iomap(dev, np, 0, NULL);
+	chip->regs = devm_platform_ioremap_resource(ofdev, 0);
 	if (IS_ERR(chip->regs))
 		return PTR_ERR(chip->regs);
 
Signature · 1 line
2.54.0
#5 lore raw

PATCH 5/7 gpio: ppc44x: Convert GPIO to generic MMIO

In reply to Rosen Penev

Use gpio_generic_chip_init() to set up the PPC44x GPIO chip instead of open-coding the basic get, set, locking and state handling.

Keep the PPC44x-specific direction callbacks because they still need to program ODR and the OSR/TSR registers around the generic data and direction registers.

Assisted-by Codex:GPT-5.5
---
 drivers/gpio/gpio-ppc44x.c | 82 +++++++++++++++++---------------------
 1 file changed, 36 insertions(+), 46 deletions(-)
drivers/gpio/gpio-ppc44x.c +36 -46
index b30ca357ab74..6b4814ed12b5 100644
@@ -11,10 +11,9 @@
 
 #include <linux/kernel.h>
 #include <linux/init.h>
-#include <linux/spinlock.h>
 #include <linux/io.h>
 #include <linux/of.h>
-#include <linux/gpio/driver.h>
+#include <linux/gpio/generic.h>
 #include <linux/types.h>
 #include <linux/slab.h>
 #include <linux/platform_device.h>
@@ -45,9 +44,8 @@ struct ppc4xx_gpio {
 };
 
 struct ppc4xx_gpio_chip {
-	struct gpio_chip gc;
+	struct gpio_generic_chip chip;
 	void __iomem *regs;
-	spinlock_t lock;
 };
 
 /*
@@ -56,55 +54,35 @@ struct ppc4xx_gpio_chip {
  * There are a maximum of 32 gpios in each gpio controller.
  */
 
-static int ppc4xx_gpio_get(struct gpio_chip *gc, unsigned int gpio)
-{
-	struct ppc4xx_gpio_chip *chip = gpiochip_get_data(gc);
-	struct ppc4xx_gpio __iomem *regs = chip->regs;
-
-	return !!(in_be32(&regs->ir) & GPIO_MASK(gpio));
-}
-
 static inline void
 __ppc4xx_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
 {
 	struct ppc4xx_gpio_chip *chip = gpiochip_get_data(gc);
-	struct ppc4xx_gpio __iomem *regs = chip->regs;
+	struct gpio_generic_chip *gen_gc = &chip->chip;
 
 	if (val)
-		setbits32(&regs->or, GPIO_MASK(gpio));
+		gen_gc->sdata |= GPIO_MASK(gpio);
 	else
-		clrbits32(&regs->or, GPIO_MASK(gpio));
-}
+		gen_gc->sdata &= ~GPIO_MASK(gpio);
 
-static int ppc4xx_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
-{
-	struct ppc4xx_gpio_chip *chip = gpiochip_get_data(gc);
-	unsigned long flags;
-
-	spin_lock_irqsave(&chip->lock, flags);
-
-	__ppc4xx_gpio_set(gc, gpio, val);
-
-	spin_unlock_irqrestore(&chip->lock, flags);
-
-	pr_debug("%s: gpio: %d val: %d\n", __func__, gpio, val);
-
-	return 0;
+	gpio_generic_write_reg(gen_gc, gen_gc->reg_set, gen_gc->sdata);
 }
 
 static int ppc4xx_gpio_dir_in(struct gpio_chip *gc, unsigned int gpio)
 {
 	struct ppc4xx_gpio_chip *chip = gpiochip_get_data(gc);
+	struct gpio_generic_chip *gen_gc = &chip->chip;
 	struct ppc4xx_gpio __iomem *regs = chip->regs;
 	unsigned long flags;
 
-	spin_lock_irqsave(&chip->lock, flags);
+	gpio_generic_chip_lock_irqsave(gen_gc, flags);
 
 	/* Disable open-drain function */
 	clrbits32(&regs->odr, GPIO_MASK(gpio));
 
 	/* Float the pin */
 	clrbits32(&regs->tcr, GPIO_MASK(gpio));
+	gen_gc->sdir &= ~GPIO_MASK(gpio);
 
 	/* Bits 0-15 use TSRL/OSRL, bits 16-31 use TSRH/OSRH */
 	if (gpio < 16) {
@@ -115,7 +93,7 @@ static int ppc4xx_gpio_dir_in(struct gpio_chip *gc, unsigned int gpio)
 		clrbits32(&regs->tsrh, GPIO_MASK2(gpio));
 	}
 
-	spin_unlock_irqrestore(&chip->lock, flags);
+	gpio_generic_chip_unlock_irqrestore(gen_gc, flags);
 
 	return 0;
 }
@@ -124,10 +102,11 @@ static int
 ppc4xx_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
 {
 	struct ppc4xx_gpio_chip *chip = gpiochip_get_data(gc);
+	struct gpio_generic_chip *gen_gc = &chip->chip;
 	struct ppc4xx_gpio __iomem *regs = chip->regs;
 	unsigned long flags;
 
-	spin_lock_irqsave(&chip->lock, flags);
+	gpio_generic_chip_lock_irqsave(gen_gc, flags);
 
 	/* First set initial value */
 	__ppc4xx_gpio_set(gc, gpio, val);
@@ -137,6 +116,7 @@ ppc4xx_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
 
 	/* Drive the pin */
 	setbits32(&regs->tcr, GPIO_MASK(gpio));
+	gen_gc->sdir |= GPIO_MASK(gpio);
 
 	/* Bits 0-15 use TSRL, bits 16-31 use TSRH */
 	if (gpio < 16) {
@@ -147,7 +127,7 @@ ppc4xx_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
 		clrbits32(&regs->tsrh, GPIO_MASK2(gpio));
 	}
 
-	spin_unlock_irqrestore(&chip->lock, flags);
+	gpio_generic_chip_unlock_irqrestore(gen_gc, flags);
 
 	pr_debug("%s: gpio: %d val: %d\n", __func__, gpio, val);
 
@@ -159,33 +139,43 @@ static int ppc4xx_gpio_probe(struct platform_device *ofdev)
 	struct device *dev = &ofdev->dev;
 	struct device_node *np = dev->of_node;
 	struct ppc4xx_gpio_chip *chip;
+	struct gpio_generic_chip_config config;
 	struct gpio_chip *gc;
+	struct ppc4xx_gpio __iomem *regs;
+	int ret;
 
 	chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
 	if (!chip)
 		return -ENOMEM;
 
-	spin_lock_init(&chip->lock);
-
-	gc = &chip->gc;
+	chip->regs = devm_platform_ioremap_resource(ofdev, 0);
+	if (IS_ERR(chip->regs))
+		return PTR_ERR(chip->regs);
 
-	gc->parent = dev;
+	regs = chip->regs;
+	config = (struct gpio_generic_chip_config) {
+		.dev = dev,
+		.sz = 4,
+		.dat = &regs->ir,
+		.set = &regs->or,
+		.dirout = &regs->tcr,
+		.flags = GPIO_GENERIC_BIG_ENDIAN |
+			 GPIO_GENERIC_BIG_ENDIAN_BYTE_ORDER,
+	};
+
+	ret = gpio_generic_chip_init(&chip->chip, &config);
+	if (ret)
+		return ret;
+
+	gc = &chip->chip.gc;
 	gc->fwnode = dev_fwnode(dev);
-	gc->base = -1;
-	gc->ngpio = 32;
 	gc->direction_input = ppc4xx_gpio_dir_in;
 	gc->direction_output = ppc4xx_gpio_dir_out;
-	gc->get = ppc4xx_gpio_get;
-	gc->set = ppc4xx_gpio_set;
 
 	gc->label = devm_kasprintf(dev, GFP_KERNEL, "%pOF", np);
 	if (!gc->label)
 		return -ENOMEM;
 
-	chip->regs = devm_platform_ioremap_resource(ofdev, 0);
-	if (IS_ERR(chip->regs))
-		return PTR_ERR(chip->regs);
-
 	return devm_gpiochip_add_data(dev, gc, chip);
 }
 
Signature · 1 line
2.54.0
#12 lore raw

PATCH 6/7 gpio: ppc44x: drop PPC-specific IO helpers and rename to ppc44x

In reply to Rosen Penev

Replace PPC-specific clrbits32()/setbits32() with local helpers using ioread32be()/iowrite32be() which are equivalent on PPC since commit 894fa235eb4c ("powerpc: inline iomap accessors"). This allows the driver to be compiled on any architecture with COMPILE_TEST.

- Changed Kconfig dependency to depends on 44x || COMPILE_TEST

Assisted-by opencode:big-pickle
---
 drivers/gpio/Kconfig       |  3 +-
 drivers/gpio/gpio-ppc44x.c | 88 ++++++++++++++++++++++----------------
 2 files changed, 53 insertions(+), 38 deletions(-)
drivers/gpio/Kconfig +1 -2
index 77991da43ec1..7374f82b7040 100644
@@ -595,9 +595,8 @@ config GPIO_POLARFIRE_SOC
 
 config GPIO_PPC44X
 	tristate "PPC44x GPIO support"
-	depends on 44x
+	depends on 44x || COMPILE_TEST
 	select GPIO_GENERIC
-	select GPIOLIB
 	help
 	  Enable gpiolib support for ppc440 based boards.
 
drivers/gpio/gpio-ppc44x.c +52 -36

188 lines not on this page · raw message

Signature · 1 line
2.54.0
#13 lore raw

PATCH 7/7 gpio: ppc44x: add MODULE info

In reply to Rosen Penev

Fixes:

ERROR: modpost: missing MODULE_LICENSE() in drivers/gpio/gpio-ppc44x.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/gpio/gpio-ppc44x.o

Assisted-by opencode:big-pickle
---
 drivers/gpio/gpio-ppc44x.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpio/gpio-ppc44x.c +3 -0
index cc7796e0cfbd..425ccbc234c8 100644
@@ -211,4 +211,7 @@ static struct platform_driver ppc44x_gpio_driver = {
 	},
 };
 
+MODULE_DESCRIPTION("PPC44x gpio driver");
+MODULE_LICENSE("GPL");
+
 module_platform_driver(ppc44x_gpio_driver);
Signature · 1 line
2.54.0
#6 lore raw

Re: [PATCH 5/7] gpio: ppc44x: Convert GPIO to generic MMIO

In reply to Rosen Penev
Quoted 10 lines · Rosen Penev

Use gpio_generic_chip_init() to set up the PPC44x GPIO chip instead of open-coding the basic get, set, locking and state handling.

Keep the PPC44x-specific direction callbacks because they still need to program ODR and the OSR/TSR registers around the generic data and direction registers.

Assisted-by Codex:GPT-5.5

---

...

drivers/gpio/gpio-ppc44x.c static int · line 109

Quoted 10 lines
drivers/gpio/gpio-ppc44x.c +2 -1
@@ -124,10 +102,11 @@ static int
 ppc4xx_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
 {
 	struct ppc4xx_gpio_chip *chip = gpiochip_get_data(gc);
+	struct gpio_generic_chip *gen_gc = &chip->chip;
 	struct ppc4xx_gpio __iomem *regs = chip->regs;
 	unsigned long flags;
 
-	spin_lock_irqsave(&chip->lock, flags);
+	gpio_generic_chip_lock_irqsave(gen_gc, flags);

If you're already doing it, can you use lock guards too?

Bart

#7 lore raw

Re: [PATCH 5/7] gpio: ppc44x: Convert GPIO to generic MMIO

Quoted 22 lines · Bartosz Golaszewski
Quoted 10 lines · Rosen Penev

Use gpio_generic_chip_init() to set up the PPC44x GPIO chip instead of open-coding the basic get, set, locking and state handling.

Keep the PPC44x-specific direction callbacks because they still need to program ODR and the OSR/TSR registers around the generic data and direction registers.

Assisted-by Codex:GPT-5.5

---

...

Quoted 8 lines
drivers/gpio/gpio-ppc44x.c +1 -0
@@ -124,10 +102,11 @@ static int
 ppc4xx_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
 {
 	struct ppc4xx_gpio_chip *chip = gpiochip_get_data(gc);
+	struct gpio_generic_chip *gen_gc = &chip->chip;
 	struct ppc4xx_gpio __iomem *regs = chip->regs;
 	unsigned long flags;
 
Quoted 4 lines

Review static int · line 109

Quoted 2 lines
(quoted diff) +1 -1
-	spin_lock_irqsave(&chip->lock, flags);
+	gpio_generic_chip_lock_irqsave(gen_gc, flags);

If you're already doing it, can you use lock guards too?

Sure. btw, I avoided placing

https://lore.kernel.org/all/[email protected]/

in the beginning of the series. My thinking is that's for older kernels. I believe either the generic API or devm_gpiochip_add_data fixes this.

Quoted 2 lines

Bart

maintainer Reviewed-by on the v1 series
#14 lore raw
In reply to Rosen Penev

Hi Rosen,

Quoted 11 lines · Rosen Penev

This series moves the ppc4xx GPIO driver from arch/powerpc to drivers/gpio, converts it to be a proper platform driver using generic MMIO helpers, drops architecture-specific accessors, and prepares it for module build and COMPILE_TEST.

Patches 1-4 move the driver and convert it to standard platform driver infrastructure. Patch 5 switches to generic MMIO helpers. Patch 6 drops PPC-specific IO accessors and enables COMPILE_TEST. Patch 7 adds the missing MODULE metadata so the driver can actually be built as a module.

Quoted 8 lines

Rosen Penev (7):
gpio: move ppc4xx gpio driver from arch/powerpc to drivers/gpio
gpio: ppc44x: Use module platform driver helper for GPIO
gpio: ppc44x: Set GPIO chip firmware node
gpio: ppc44x: Use platform resource helper for GPIO MMIO
gpio: ppc44x: Convert GPIO to generic MMIO
gpio: ppc44x: drop PPC-specific IO helpers and rename to ppc44x
gpio: ppc44x: add MODULE info

Overall a very nice patch series and happy to see that AI can assist with this kind of refactoring!

I guess we should provide some slack so someone from the PPC camp can test it, and if they don't test it, then it is abandoned and we should then just apply it anyway.

The series:

Yours,
Linus Walleij

#15 lore raw
Quoted 25 lines · Linus Walleij

Hi Rosen,

Quoted 11 lines · Rosen Penev

This series moves the ppc4xx GPIO driver from arch/powerpc to drivers/gpio, converts it to be a proper platform driver using generic MMIO helpers, drops architecture-specific accessors, and prepares it for module build and COMPILE_TEST.

Patches 1-4 move the driver and convert it to standard platform driver infrastructure. Patch 5 switches to generic MMIO helpers. Patch 6 drops PPC-specific IO accessors and enables COMPILE_TEST. Patch 7 adds the missing MODULE metadata so the driver can actually be built as a module.

Quoted 8 lines

Rosen Penev (7):
gpio: move ppc4xx gpio driver from arch/powerpc to drivers/gpio
gpio: ppc44x: Use module platform driver helper for GPIO
gpio: ppc44x: Set GPIO chip firmware node
gpio: ppc44x: Use platform resource helper for GPIO MMIO
gpio: ppc44x: Convert GPIO to generic MMIO
gpio: ppc44x: drop PPC-specific IO helpers and rename to ppc44x
gpio: ppc44x: add MODULE info

Quoted 6 lines

Overall a very nice patch series and happy to see that AI can assist with this kind of refactoring!

I guess we should provide some slack so someone from the PPC camp can test it, and if they don't test it, then it is abandoned and we should then just apply it anyway.

Hmm? I have the hardware. It works fine.

Quoted 6 lines

The series:

Yours,
Linus Walleij

maintainer
#16 lore raw
Quoted 5 lines · Rosen Penev
Quoted 3 lines

I guess we should provide some slack so someone from the PPC camp can test it, and if they don't test it, then it is abandoned and we should then just apply it anyway.

Hmm? I have the hardware. It works fine.

I missed it because it's only mentioned briefly in patch 3. But sounds all solid then!

Yours,
Linus Walleij

#17 lore raw
In reply to Rosen Penev
Quoted 24 lines · Rosen Penev
Quoted 23 lines · Linus Walleij

Hi Rosen,

Quoted 19 lines · Rosen Penev

This series moves the ppc4xx GPIO driver from arch/powerpc to drivers/gpio, converts it to be a proper platform driver using generic MMIO helpers, drops architecture-specific accessors, and prepares it for module build and COMPILE_TEST.

Patches 1-4 move the driver and convert it to standard platform driver infrastructure. Patch 5 switches to generic MMIO helpers. Patch 6 drops PPC-specific IO accessors and enables COMPILE_TEST. Patch 7 adds the missing MODULE metadata so the driver can actually be built as a module.

Rosen Penev (7):
gpio: move ppc4xx gpio driver from arch/powerpc to drivers/gpio
gpio: ppc44x: Use module platform driver helper for GPIO
gpio: ppc44x: Set GPIO chip firmware node
gpio: ppc44x: Use platform resource helper for GPIO MMIO
gpio: ppc44x: Convert GPIO to generic MMIO
gpio: ppc44x: drop PPC-specific IO helpers and rename to ppc44x
gpio: ppc44x: add MODULE info

Quoted 7 lines
Quoted 6 lines

Overall a very nice patch series and happy to see that AI can assist with this kind of refactoring!

I guess we should provide some slack so someone from the PPC camp can test it, and if they don't test it, then it is abandoned and we should then just apply it anyway.

Hmm? I have the hardware. It works fine.

Honestly I dont have the hardware to test this,
but thanks for the confirming, i will pull this for the next merge.

Maddy

Quoted 5 lines
Quoted 5 lines

The series:

Yours,
Linus Walleij

#8 lore raw

Re: [PATCH 5/7] gpio: ppc44x: Convert GPIO to generic MMIO

In reply to Rosen Penev
Quoted 22 lines · Rosen Penev
Quoted 21 lines · Bartosz Golaszewski
Quoted 10 lines · Rosen Penev

Use gpio_generic_chip_init() to set up the PPC44x GPIO chip instead of open-coding the basic get, set, locking and state handling.

Keep the PPC44x-specific direction callbacks because they still need to program ODR and the OSR/TSR registers around the generic data and direction registers.

Assisted-by Codex:GPT-5.5

---

...

Quoted 8 lines
drivers/gpio/gpio-ppc44x.c +1 -0
@@ -124,10 +102,11 @@ static int
  ppc4xx_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
  {
  	struct ppc4xx_gpio_chip *chip = gpiochip_get_data(gc);
+	struct gpio_generic_chip *gen_gc = &chip->chip;
  	struct ppc4xx_gpio __iomem *regs = chip->regs;
  	unsigned long flags;
 
Quoted 4 lines
Quoted 3 lines

Review static int · line 109

Quoted 2 lines
(quoted diff) +1 -1
-	spin_lock_irqsave(&chip->lock, flags);
+	gpio_generic_chip_lock_irqsave(gen_gc, flags);

If you're already doing it, can you use lock guards too?

Sure. btw, I avoided placing

Do you have plan to address this comment in v2

Maddy

Quoted 7 lines

https://lore.kernel.org/all/[email protected]/

in the beginning of the series. My thinking is that's for older kernels. I believe either the generic API or devm_gpiochip_add_data fixes this.

Quoted 1 line

Bart

#18 lore raw
In reply to Madhavan Srinivasan
Quoted 30 lines · Madhavan Srinivasan
Quoted 27 lines · Rosen Penev
Quoted 26 lines · Linus Walleij

Hi Rosen,

Quoted 11 lines · Rosen Penev

This series moves the ppc4xx GPIO driver from arch/powerpc to drivers/gpio, converts it to be a proper platform driver using generic MMIO helpers, drops architecture-specific accessors, and prepares it for module build and COMPILE_TEST.

Patches 1-4 move the driver and convert it to standard platform driver infrastructure. Patch 5 switches to generic MMIO helpers. Patch 6 drops PPC-specific IO accessors and enables COMPILE_TEST. Patch 7 adds the missing MODULE metadata so the driver can actually be built as a module.

Quoted 8 lines

Rosen Penev (7):
gpio: move ppc4xx gpio driver from arch/powerpc to drivers/gpio
gpio: ppc44x: Use module platform driver helper for GPIO
gpio: ppc44x: Set GPIO chip firmware node
gpio: ppc44x: Use platform resource helper for GPIO MMIO
gpio: ppc44x: Convert GPIO to generic MMIO
gpio: ppc44x: drop PPC-specific IO helpers and rename to ppc44x
gpio: ppc44x: add MODULE info

Overall a very nice patch series and happy to see that AI can assist with this kind of refactoring!

Quoted 6 lines
Quoted 4 lines
Quoted 3 lines

I guess we should provide some slack so someone from the PPC camp can test it, and if they don't test it, then it is abandoned and we should then just apply it anyway.

Hmm? I have the hardware. It works fine.

Honestly I dont have the hardware to test this,
but thanks for the confirming, i will pull this for the next merge.

Can't tell if you mean next merge window or not.

Anyway, https://lore.kernel.org/linuxppc-dev/[email protected]/
needs handling first IMO.

It's needed for kernel 6.18. Otherwise my buttons and LEDs don't work properly.

Quoted 7 lines

Maddy

Quoted 5 lines
Quoted 5 lines

The series:

Yours,
Linus Walleij

#9 lore raw

Re: [PATCH 5/7] gpio: ppc44x: Convert GPIO to generic MMIO

In reply to Madhavan Srinivasan
Quoted 25 lines · Madhavan Srinivasan
Quoted 22 lines · Rosen Penev
Quoted 21 lines · Bartosz Golaszewski
Quoted 10 lines · Rosen Penev

Use gpio_generic_chip_init() to set up the PPC44x GPIO chip instead of open-coding the basic get, set, locking and state handling.

Keep the PPC44x-specific direction callbacks because they still need to program ODR and the OSR/TSR registers around the generic data and direction registers.

Assisted-by Codex:GPT-5.5

---

...

Quoted 8 lines
drivers/gpio/gpio-ppc44x.c +1 -0
@@ -124,10 +102,11 @@ static int
  ppc4xx_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
  {
    struct ppc4xx_gpio_chip *chip = gpiochip_get_data(gc);
+   struct gpio_generic_chip *gen_gc = &chip->chip;
    struct ppc4xx_gpio __iomem *regs = chip->regs;
    unsigned long flags;
 
Quoted 6 lines
Quoted 4 lines
Quoted 3 lines

Review static int · line 109

Quoted 2 lines
(quoted diff) +1 -1
-   spin_lock_irqsave(&chip->lock, flags);
+   gpio_generic_chip_lock_irqsave(gen_gc, flags);

If you're already doing it, can you use lock guards too?

Sure. btw, I avoided placing

Do you have plan to address this comment in v2

Yeah I have it fixed locally.

I'm not sure if this has to do through the PPC or GPIO tree.

Quoted 9 lines

Maddy

Quoted 7 lines

https://lore.kernel.org/all/[email protected]/

in the beginning of the series. My thinking is that's for older kernels. I believe either the generic API or devm_gpiochip_add_data fixes this.

Quoted 1 line

Bart

#10 lore raw

Re: [PATCH 5/7] gpio: ppc44x: Convert GPIO to generic MMIO

Le 29/07/2026 à 20:32, Rosen Penev a écrit :

Quoted 26 lines · Madhavan Srinivasan
Quoted 25 lines · Rosen Penev
Quoted 22 lines · Bartosz Golaszewski
Quoted 21 lines · Rosen Penev
Quoted 10 lines

Use gpio_generic_chip_init() to set up the PPC44x GPIO chip instead of open-coding the basic get, set, locking and state handling.

Keep the PPC44x-specific direction callbacks because they still need to program ODR and the OSR/TSR registers around the generic data and direction registers.

Assisted-by Codex:GPT-5.5

---

...

Quoted 8 lines
drivers/gpio/gpio-ppc44x.c +1 -0
@@ -124,10 +102,11 @@ static int
   ppc4xx_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
   {
     struct ppc4xx_gpio_chip *chip = gpiochip_get_data(gc);
+   struct gpio_generic_chip *gen_gc = &chip->chip;
     struct ppc4xx_gpio __iomem *regs = chip->regs;
     unsigned long flags;
 
Quoted 7 lines
Quoted 6 lines
Quoted 4 lines
Quoted 3 lines

Review static int · line 109

Quoted 2 lines
(quoted diff) +1 -1
-   spin_lock_irqsave(&chip->lock, flags);
+   gpio_generic_chip_lock_irqsave(gen_gc, flags);

If you're already doing it, can you use lock guards too?

Sure. btw, I avoided placing

Do you have plan to address this comment in v2

Yeah I have it fixed locally.

You should probably put patch https://patchwork.ozlabs.org/project/linuxppc-dev/patch/[email protected]/ as first patch in this series in order to enable applying the fix to 6.18 without applying the entire series and to avoid any future conflict.

Christophe

Quoted 11 lines

I'm not sure if this has to do through the PPC or GPIO tree.

Quoted 9 lines

Maddy

Quoted 7 lines

https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Fall%2F20260517063754.21819-1-rosenp%40gmail.com%2F&data=05%7C02%7Cchristophe.leroy%40csgroup.eu%7C2ac0ec525c7045cd969508deed9fc7e0%7C8b87af7d86474dc78df45f69a2011bb5%7C0%7C0%7C639209467691381845%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=iqGebSy%2BbKMBFZz%2FZwZ9N2Jf8v63FkGPNhrdUf864fE%3D&reserved=0

in the beginning of the series. My thinking is that's for older kernels. I believe either the generic API or devm_gpiochip_add_data fixes this.

Quoted 1 line

Bart

#11 lore raw

Re: [PATCH 5/7] gpio: ppc44x: Convert GPIO to generic MMIO

Quoted 35 lines · Christophe Leroy (CS GROUP)
Quoted 31 lines · Rosen Penev
Quoted 30 lines · Madhavan Srinivasan
Quoted 26 lines · Rosen Penev
Quoted 21 lines · Bartosz Golaszewski
Quoted 10 lines · Rosen Penev

Use gpio_generic_chip_init() to set up the PPC44x GPIO chip instead of open-coding the basic get, set, locking and state handling.

Keep the PPC44x-specific direction callbacks because they still need to program ODR and the OSR/TSR registers around the generic data and direction registers.

Assisted-by Codex:GPT-5.5

---

...

Quoted 8 lines
drivers/gpio/gpio-ppc44x.c +1 -0
@@ -124,10 +102,11 @@ static int
   ppc4xx_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
   {
     struct ppc4xx_gpio_chip *chip = gpiochip_get_data(gc);
+   struct gpio_generic_chip *gen_gc = &chip->chip;
     struct ppc4xx_gpio __iomem *regs = chip->regs;
     unsigned long flags;
 
Quoted 3 lines

Review static int · line 109

Quoted 2 lines
(quoted diff) +1 -1
-   spin_lock_irqsave(&chip->lock, flags);
+   gpio_generic_chip_lock_irqsave(gen_gc, flags);

If you're already doing it, can you use lock guards too?

Sure. btw, I avoided placing

Quoted 7 lines
Quoted 2 lines
Quoted 1 line

Do you have plan to address this comment in v2

Yeah I have it fixed locally.

You should probably put patch
https://patchwork.ozlabs.org/project/linuxppc-dev/patch/[email protected]/
as first patch in this series in order to enable applying the fix to 6.18 without applying the entire series and to avoid any future conflict.

Not sure what you mean by this.

I assume the simplest way to proceed is to wait for that patch to be merged first and then proceed with this patch series.

Quoted 16 lines

Christophe

Quoted 11 lines

I'm not sure if this has to do through the PPC or GPIO tree.

Quoted 9 lines

Maddy

Quoted 7 lines

https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Fall%2F20260517063754.21819-1-rosenp%40gmail.com%2F&data=05%7C02%7Cchristophe.leroy%40csgroup.eu%7C2ac0ec525c7045cd969508deed9fc7e0%7C8b87af7d86474dc78df45f69a2011bb5%7C0%7C0%7C639209467691381845%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=iqGebSy%2BbKMBFZz%2FZwZ9N2Jf8v63FkGPNhrdUf864fE%3D&reserved=0

in the beginning of the series. My thinking is that's for older kernels. I believe either the generic API or devm_gpiochip_add_data fixes this.

Quoted 1 line

Bart