gpio: move ppc4xx driver to drivers/gpio and modernize
Subsystems (3)
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
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()
--- 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
Signature · 1 line
2.54.0
PATCH 2/7 gpio: ppc44x: Use module platform driver helper for GPIO
In reply to Rosen PenevReplace 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.
--- drivers/gpio/gpio-ppc44x.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/gpio/gpio-ppc44x.c +1 -5
@@ -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
PATCH 3/7 gpio: ppc44x: Set GPIO chip firmware node
In reply to Rosen PenevThe 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.
--- drivers/gpio/gpio-ppc44x.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpio/gpio-ppc44x.c +2 -0
@@ -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
PATCH 4/7 gpio: ppc44x: Use platform resource helper for GPIO MMIO
In reply to Rosen PenevMap 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.
--- drivers/gpio/gpio-ppc44x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-ppc44x.c +1 -1
@@ -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
PATCH 5/7 gpio: ppc44x: Convert GPIO to generic MMIO
In reply to Rosen PenevUse 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.
--- drivers/gpio/gpio-ppc44x.c | 82 +++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 46 deletions(-)
drivers/gpio/gpio-ppc44x.c +36 -46
@@ -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 (®s->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 (®s->or,GPIO_MASK (gpio)); + gen_gc->sdata |=GPIO_MASK (gpio);else -clrbits32 (®s->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 (®s->odr,GPIO_MASK (gpio));/* Float the pin */ clrbits32 (®s->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 (®s->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 (®s->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 (®s->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 = ®s->ir, + .set = ®s->or, + .dirout = ®s->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
Bartosz Golaszewski
maintainerRe: [PATCH 5/7] gpio: ppc44x: Convert GPIO to generic MMIO
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.5Signed-off-by Rosen Penev <[email protected]>---
...
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
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.5Signed-off-by Rosen Penev <[email protected]>---
...
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
Madhavan Srinivasan
maintainerRe: [PATCH 5/7] gpio: ppc44x: Convert GPIO to generic MMIO
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.5Signed-off-by Rosen Penev <[email protected]>---
...
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_datafixes this.Quoted 1 line
Bart
Re: [PATCH 5/7] gpio: ppc44x: Convert GPIO to generic MMIO
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.5Signed-off-by Rosen Penev <[email protected]>---
...
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_datafixes this.Quoted 1 line
Bart
Christophe Leroy (CS GROUP)
reviewerRe: [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.5Signed-off-by Rosen Penev <[email protected]>---
...
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
in the beginning of the series. My thinking is that's for older kernels. I believe either the generic API or
devm_gpiochip_add_datafixes this.Quoted 1 line
Bart
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.5Signed-off-by Rosen Penev <[email protected]>---
...
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
in the beginning of the series. My thinking is that's for older kernels. I believe either the generic API or
devm_gpiochip_add_datafixes this.Quoted 1 line
Bart
PATCH 6/7 gpio: ppc44x: drop PPC-specific IO helpers and rename to ppc44x
In reply to Rosen PenevReplace 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
--- drivers/gpio/Kconfig | 3 +- drivers/gpio/gpio-ppc44x.c | 88 ++++++++++++++++++++++---------------- 2 files changed, 53 insertions(+), 38 deletions(-)
drivers/gpio/Kconfig +1 -2
@@ -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
PATCH 7/7 gpio: ppc44x: add MODULE info
In reply to Rosen PenevFixes:
ERROR: modpost: missing MODULE_LICENSE() in drivers/gpio/gpio-ppc44x.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/gpio/gpio-ppc44x.o
--- drivers/gpio/gpio-ppc44x.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpio/gpio-ppc44x.c +3 -0
@@ -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
Hi Rosen,
Quoted 11 lines · Rosen Penev
This series moves the ppc4xx GPIO driver from
arch/powerpctodrivers/gpio, converts it to be a proper platform driver using generic MMIO helpers, drops architecture-specific accessors, and prepares it for module build andCOMPILE_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 fromarch/powerpctodrivers/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
Quoted 25 lines · Linus Walleij
Hi Rosen,
Quoted 11 lines · Rosen Penev
This series moves the ppc4xx GPIO driver from
arch/powerpctodrivers/gpio, converts it to be a proper platform driver using generic MMIO helpers, drops architecture-specific accessors, and prepares it for module build andCOMPILE_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 fromarch/powerpctodrivers/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:
Reviewed-by Linus Walleij <[email protected]>Yours,
Linus Walleij
Linus Walleij
maintainerQuoted 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
Madhavan Srinivasan
maintainerQuoted 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/powerpctodrivers/gpio, converts it to be a proper platform driver using generic MMIO helpers, drops architecture-specific accessors, and prepares it for module build andCOMPILE_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 fromarch/powerpctodrivers/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:
Reviewed-by Linus Walleij <[email protected]>Yours,
Linus Walleij
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/powerpctodrivers/gpio, converts it to be a proper platform driver using generic MMIO helpers, drops architecture-specific accessors, and prepares it for module build andCOMPILE_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 fromarch/powerpctodrivers/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 infoOverall 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:
Reviewed-by Linus Walleij <[email protected]>Yours,
Linus Walleij