* [PATCH 0/7] gpio: move ppc4xx driver to drivers/gpio and modernize
@ 2026-06-02 5:01 Rosen Penev
2026-06-02 5:01 ` [PATCH 1/7] gpio: move ppc4xx gpio driver from arch/powerpc to drivers/gpio Rosen Penev
` (6 more replies)
0 siblings, 7 replies; 10+ messages in thread
From: Rosen Penev @ 2026-06-02 5:01 UTC (permalink / raw)
To: linux-gpio
Cc: Madhavan Srinivasan, chleroy, Michael Ellerman, Nicholas Piggin,
Linus Walleij, Bartosz Golaszewski,
open list:LINUX FOR POWERPC (32-BIT AND 64-BIT), open list
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
--
2.54.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/7] gpio: move ppc4xx gpio driver from arch/powerpc to drivers/gpio
2026-06-02 5:01 [PATCH 0/7] gpio: move ppc4xx driver to drivers/gpio and modernize Rosen Penev
@ 2026-06-02 5:01 ` Rosen Penev
2026-06-02 5:01 ` [PATCH 2/7] gpio: ppc44x: Use module platform driver helper for GPIO Rosen Penev
` (5 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Rosen Penev @ 2026-06-02 5:01 UTC (permalink / raw)
To: linux-gpio
Cc: Madhavan Srinivasan, chleroy, Michael Ellerman, Nicholas Piggin,
Linus Walleij, Bartosz Golaszewski,
open list:LINUX FOR POWERPC (32-BIT AND 64-BIT), open list
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
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
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%)
diff --git a/arch/powerpc/configs/44x/warp_defconfig b/arch/powerpc/configs/44x/warp_defconfig
index 5757625469c4..d6014b9c5708 100644
--- a/arch/powerpc/configs/44x/warp_defconfig
+++ b/arch/powerpc/configs/44x/warp_defconfig
@@ -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
diff --git a/arch/powerpc/configs/ppc44x_defconfig b/arch/powerpc/configs/ppc44x_defconfig
index 41c930f74ed4..b0c7ad8c6d9b 100644
--- a/arch/powerpc/configs/ppc44x_defconfig
+++ b/arch/powerpc/configs/ppc44x_defconfig
@@ -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
diff --git a/arch/powerpc/platforms/44x/Kconfig b/arch/powerpc/platforms/44x/Kconfig
index fc79f8466933..150813cea945 100644
--- a/arch/powerpc/platforms/44x/Kconfig
+++ b/arch/powerpc/platforms/44x/Kconfig
@@ -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
diff --git a/arch/powerpc/platforms/44x/Makefile b/arch/powerpc/platforms/44x/Makefile
index ca7b1bb442d9..4598d8b89bf4 100644
--- a/arch/powerpc/platforms/44x/Makefile
+++ b/arch/powerpc/platforms/44x/Makefile
@@ -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
+
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index 89c77ec6c205..77991da43ec1 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -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
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index 8ec03c9aec20..9e8c9ca1d3fb 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -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
diff --git a/arch/powerpc/platforms/44x/gpio.c b/drivers/gpio/gpio-ppc44x.c
similarity index 100%
rename from arch/powerpc/platforms/44x/gpio.c
rename to drivers/gpio/gpio-ppc44x.c
--
2.54.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/7] gpio: ppc44x: Use module platform driver helper for GPIO
2026-06-02 5:01 [PATCH 0/7] gpio: move ppc4xx driver to drivers/gpio and modernize Rosen Penev
2026-06-02 5:01 ` [PATCH 1/7] gpio: move ppc4xx gpio driver from arch/powerpc to drivers/gpio Rosen Penev
@ 2026-06-02 5:01 ` Rosen Penev
2026-06-02 5:01 ` [PATCH 3/7] gpio: ppc44x: Set GPIO chip firmware node Rosen Penev
` (4 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Rosen Penev @ 2026-06-02 5:01 UTC (permalink / raw)
To: linux-gpio
Cc: Madhavan Srinivasan, chleroy, Michael Ellerman, Nicholas Piggin,
Linus Walleij, Bartosz Golaszewski,
open list:LINUX FOR POWERPC (32-BIT AND 64-BIT), open list
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
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/gpio/gpio-ppc44x.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/drivers/gpio/gpio-ppc44x.c b/drivers/gpio/gpio-ppc44x.c
index aea0d913b59d..0d2244272e32 100644
--- a/drivers/gpio/gpio-ppc44x.c
+++ b/drivers/gpio/gpio-ppc44x.c
@@ -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);
--
2.54.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 3/7] gpio: ppc44x: Set GPIO chip firmware node
2026-06-02 5:01 [PATCH 0/7] gpio: move ppc4xx driver to drivers/gpio and modernize Rosen Penev
2026-06-02 5:01 ` [PATCH 1/7] gpio: move ppc4xx gpio driver from arch/powerpc to drivers/gpio Rosen Penev
2026-06-02 5:01 ` [PATCH 2/7] gpio: ppc44x: Use module platform driver helper for GPIO Rosen Penev
@ 2026-06-02 5:01 ` Rosen Penev
2026-06-02 5:01 ` [PATCH 4/7] gpio: ppc44x: Use platform resource helper for GPIO MMIO Rosen Penev
` (3 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Rosen Penev @ 2026-06-02 5:01 UTC (permalink / raw)
To: linux-gpio
Cc: Madhavan Srinivasan, chleroy, Michael Ellerman, Nicholas Piggin,
Linus Walleij, Bartosz Golaszewski,
open list:LINUX FOR POWERPC (32-BIT AND 64-BIT), open list
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")
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/gpio/gpio-ppc44x.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/gpio/gpio-ppc44x.c b/drivers/gpio/gpio-ppc44x.c
index 0d2244272e32..07b699cc4dd9 100644
--- a/drivers/gpio/gpio-ppc44x.c
+++ b/drivers/gpio/gpio-ppc44x.c
@@ -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;
--
2.54.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 4/7] gpio: ppc44x: Use platform resource helper for GPIO MMIO
2026-06-02 5:01 [PATCH 0/7] gpio: move ppc4xx driver to drivers/gpio and modernize Rosen Penev
` (2 preceding siblings ...)
2026-06-02 5:01 ` [PATCH 3/7] gpio: ppc44x: Set GPIO chip firmware node Rosen Penev
@ 2026-06-02 5:01 ` Rosen Penev
2026-06-02 5:01 ` [PATCH 5/7] gpio: ppc44x: Convert GPIO to generic MMIO Rosen Penev
` (2 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Rosen Penev @ 2026-06-02 5:01 UTC (permalink / raw)
To: linux-gpio
Cc: Madhavan Srinivasan, chleroy, Michael Ellerman, Nicholas Piggin,
Linus Walleij, Bartosz Golaszewski,
open list:LINUX FOR POWERPC (32-BIT AND 64-BIT), open list
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
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/gpio/gpio-ppc44x.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpio/gpio-ppc44x.c b/drivers/gpio/gpio-ppc44x.c
index 07b699cc4dd9..b30ca357ab74 100644
--- a/drivers/gpio/gpio-ppc44x.c
+++ b/drivers/gpio/gpio-ppc44x.c
@@ -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);
--
2.54.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 5/7] gpio: ppc44x: Convert GPIO to generic MMIO
2026-06-02 5:01 [PATCH 0/7] gpio: move ppc4xx driver to drivers/gpio and modernize Rosen Penev
` (3 preceding siblings ...)
2026-06-02 5:01 ` [PATCH 4/7] gpio: ppc44x: Use platform resource helper for GPIO MMIO Rosen Penev
@ 2026-06-02 5:01 ` Rosen Penev
2026-06-02 7:51 ` Bartosz Golaszewski
2026-06-02 5:01 ` [PATCH 6/7] gpio: ppc44x: drop PPC-specific IO helpers and rename to ppc44x Rosen Penev
2026-06-02 5:01 ` [PATCH 7/7] gpio: ppc44x: add MODULE info Rosen Penev
6 siblings, 1 reply; 10+ messages in thread
From: Rosen Penev @ 2026-06-02 5:01 UTC (permalink / raw)
To: linux-gpio
Cc: Madhavan Srinivasan, chleroy, Michael Ellerman, Nicholas Piggin,
Linus Walleij, Bartosz Golaszewski,
open list:LINUX FOR POWERPC (32-BIT AND 64-BIT), open list
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
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/gpio/gpio-ppc44x.c | 82 +++++++++++++++++---------------------
1 file changed, 36 insertions(+), 46 deletions(-)
diff --git a/drivers/gpio/gpio-ppc44x.c b/drivers/gpio/gpio-ppc44x.c
index b30ca357ab74..6b4814ed12b5 100644
--- a/drivers/gpio/gpio-ppc44x.c
+++ b/drivers/gpio/gpio-ppc44x.c
@@ -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);
}
--
2.54.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 6/7] gpio: ppc44x: drop PPC-specific IO helpers and rename to ppc44x
2026-06-02 5:01 [PATCH 0/7] gpio: move ppc4xx driver to drivers/gpio and modernize Rosen Penev
` (4 preceding siblings ...)
2026-06-02 5:01 ` [PATCH 5/7] gpio: ppc44x: Convert GPIO to generic MMIO Rosen Penev
@ 2026-06-02 5:01 ` Rosen Penev
2026-06-02 5:01 ` [PATCH 7/7] gpio: ppc44x: add MODULE info Rosen Penev
6 siblings, 0 replies; 10+ messages in thread
From: Rosen Penev @ 2026-06-02 5:01 UTC (permalink / raw)
To: linux-gpio
Cc: Madhavan Srinivasan, chleroy, Michael Ellerman, Nicholas Piggin,
Linus Walleij, Bartosz Golaszewski,
open list:LINUX FOR POWERPC (32-BIT AND 64-BIT), open list
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
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/gpio/Kconfig | 3 +-
drivers/gpio/gpio-ppc44x.c | 88 ++++++++++++++++++++++----------------
2 files changed, 53 insertions(+), 38 deletions(-)
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index 77991da43ec1..7374f82b7040 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -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.
diff --git a/drivers/gpio/gpio-ppc44x.c b/drivers/gpio/gpio-ppc44x.c
index 6b4814ed12b5..cc7796e0cfbd 100644
--- a/drivers/gpio/gpio-ppc44x.c
+++ b/drivers/gpio/gpio-ppc44x.c
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
- * PPC4xx gpio driver
+ * PPC44x gpio driver
*
* Copyright (c) 2008 Harris Corporation
* Copyright (c) 2008 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
@@ -22,7 +22,7 @@
#define GPIO_MASK2(gpio) (0xc0000000 >> ((gpio) * 2))
/* Physical GPIO register layout */
-struct ppc4xx_gpio {
+struct ppc44x_gpio {
__be32 or;
__be32 tcr;
__be32 osrl;
@@ -43,11 +43,27 @@ struct ppc4xx_gpio {
__be32 isr3h;
};
-struct ppc4xx_gpio_chip {
+struct ppc44x_gpio_chip {
struct gpio_generic_chip chip;
void __iomem *regs;
};
+static inline void ppc44x_clrbits32(void __iomem *addr, u32 mask)
+{
+ u32 val = ioread32be(addr);
+
+ val &= ~mask;
+ iowrite32be(val, addr);
+}
+
+static inline void ppc44x_setbits32(void __iomem *addr, u32 mask)
+{
+ u32 val = ioread32be(addr);
+
+ val |= mask;
+ iowrite32be(val, addr);
+}
+
/*
* GPIO LIB API implementation for GPIOs
*
@@ -55,9 +71,9 @@ struct ppc4xx_gpio_chip {
*/
static inline void
-__ppc4xx_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
+__ppc44x_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
{
- struct ppc4xx_gpio_chip *chip = gpiochip_get_data(gc);
+ struct ppc44x_gpio_chip *chip = gpiochip_get_data(gc);
struct gpio_generic_chip *gen_gc = &chip->chip;
if (val)
@@ -68,29 +84,29 @@ __ppc4xx_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
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)
+static int ppc44x_gpio_dir_in(struct gpio_chip *gc, unsigned int gpio)
{
- struct ppc4xx_gpio_chip *chip = gpiochip_get_data(gc);
+ struct ppc44x_gpio_chip *chip = gpiochip_get_data(gc);
struct gpio_generic_chip *gen_gc = &chip->chip;
- struct ppc4xx_gpio __iomem *regs = chip->regs;
+ struct ppc44x_gpio __iomem *regs = chip->regs;
unsigned long flags;
gpio_generic_chip_lock_irqsave(gen_gc, flags);
/* Disable open-drain function */
- clrbits32(®s->odr, GPIO_MASK(gpio));
+ ppc44x_clrbits32(®s->odr, GPIO_MASK(gpio));
/* Float the pin */
- clrbits32(®s->tcr, GPIO_MASK(gpio));
+ ppc44x_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) {
- clrbits32(®s->osrl, GPIO_MASK2(gpio));
- clrbits32(®s->tsrl, GPIO_MASK2(gpio));
+ ppc44x_clrbits32(®s->osrl, GPIO_MASK2(gpio));
+ ppc44x_clrbits32(®s->tsrl, GPIO_MASK2(gpio));
} else {
- clrbits32(®s->osrh, GPIO_MASK2(gpio));
- clrbits32(®s->tsrh, GPIO_MASK2(gpio));
+ ppc44x_clrbits32(®s->osrh, GPIO_MASK2(gpio));
+ ppc44x_clrbits32(®s->tsrh, GPIO_MASK2(gpio));
}
gpio_generic_chip_unlock_irqrestore(gen_gc, flags);
@@ -99,32 +115,32 @@ static int ppc4xx_gpio_dir_in(struct gpio_chip *gc, unsigned int gpio)
}
static int
-ppc4xx_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
+ppc44x_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
{
- struct ppc4xx_gpio_chip *chip = gpiochip_get_data(gc);
+ struct ppc44x_gpio_chip *chip = gpiochip_get_data(gc);
struct gpio_generic_chip *gen_gc = &chip->chip;
- struct ppc4xx_gpio __iomem *regs = chip->regs;
+ struct ppc44x_gpio __iomem *regs = chip->regs;
unsigned long flags;
gpio_generic_chip_lock_irqsave(gen_gc, flags);
/* First set initial value */
- __ppc4xx_gpio_set(gc, gpio, val);
+ __ppc44x_gpio_set(gc, gpio, val);
/* Disable open-drain function */
- clrbits32(®s->odr, GPIO_MASK(gpio));
+ ppc44x_clrbits32(®s->odr, GPIO_MASK(gpio));
/* Drive the pin */
- setbits32(®s->tcr, GPIO_MASK(gpio));
+ ppc44x_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) {
- clrbits32(®s->osrl, GPIO_MASK2(gpio));
- clrbits32(®s->tsrl, GPIO_MASK2(gpio));
+ ppc44x_clrbits32(®s->osrl, GPIO_MASK2(gpio));
+ ppc44x_clrbits32(®s->tsrl, GPIO_MASK2(gpio));
} else {
- clrbits32(®s->osrh, GPIO_MASK2(gpio));
- clrbits32(®s->tsrh, GPIO_MASK2(gpio));
+ ppc44x_clrbits32(®s->osrh, GPIO_MASK2(gpio));
+ ppc44x_clrbits32(®s->tsrh, GPIO_MASK2(gpio));
}
gpio_generic_chip_unlock_irqrestore(gen_gc, flags);
@@ -134,14 +150,14 @@ ppc4xx_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
return 0;
}
-static int ppc4xx_gpio_probe(struct platform_device *ofdev)
+static int ppc44x_gpio_probe(struct platform_device *ofdev)
{
struct device *dev = &ofdev->dev;
struct device_node *np = dev->of_node;
- struct ppc4xx_gpio_chip *chip;
+ struct ppc44x_gpio_chip *chip;
struct gpio_generic_chip_config config;
struct gpio_chip *gc;
- struct ppc4xx_gpio __iomem *regs;
+ struct ppc44x_gpio __iomem *regs;
int ret;
chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
@@ -169,8 +185,8 @@ static int ppc4xx_gpio_probe(struct platform_device *ofdev)
gc = &chip->chip.gc;
gc->fwnode = dev_fwnode(dev);
- gc->direction_input = ppc4xx_gpio_dir_in;
- gc->direction_output = ppc4xx_gpio_dir_out;
+ gc->direction_input = ppc44x_gpio_dir_in;
+ gc->direction_output = ppc44x_gpio_dir_out;
gc->label = devm_kasprintf(dev, GFP_KERNEL, "%pOF", np);
if (!gc->label)
@@ -179,20 +195,20 @@ static int ppc4xx_gpio_probe(struct platform_device *ofdev)
return devm_gpiochip_add_data(dev, gc, chip);
}
-static const struct of_device_id ppc4xx_gpio_match[] = {
+static const struct of_device_id ppc44x_gpio_match[] = {
{
.compatible = "ibm,ppc4xx-gpio",
},
{},
};
-MODULE_DEVICE_TABLE(of, ppc4xx_gpio_match);
+MODULE_DEVICE_TABLE(of, ppc44x_gpio_match);
-static struct platform_driver ppc4xx_gpio_driver = {
- .probe = ppc4xx_gpio_probe,
+static struct platform_driver ppc44x_gpio_driver = {
+ .probe = ppc44x_gpio_probe,
.driver = {
- .name = "ppc4xx-gpio",
- .of_match_table = ppc4xx_gpio_match,
+ .name = "ppc44x-gpio",
+ .of_match_table = ppc44x_gpio_match,
},
};
-module_platform_driver(ppc4xx_gpio_driver);
+module_platform_driver(ppc44x_gpio_driver);
--
2.54.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 7/7] gpio: ppc44x: add MODULE info
2026-06-02 5:01 [PATCH 0/7] gpio: move ppc4xx driver to drivers/gpio and modernize Rosen Penev
` (5 preceding siblings ...)
2026-06-02 5:01 ` [PATCH 6/7] gpio: ppc44x: drop PPC-specific IO helpers and rename to ppc44x Rosen Penev
@ 2026-06-02 5:01 ` Rosen Penev
6 siblings, 0 replies; 10+ messages in thread
From: Rosen Penev @ 2026-06-02 5:01 UTC (permalink / raw)
To: linux-gpio
Cc: Madhavan Srinivasan, chleroy, Michael Ellerman, Nicholas Piggin,
Linus Walleij, Bartosz Golaszewski,
open list:LINUX FOR POWERPC (32-BIT AND 64-BIT), open list
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
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/gpio/gpio-ppc44x.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/gpio/gpio-ppc44x.c b/drivers/gpio/gpio-ppc44x.c
index cc7796e0cfbd..425ccbc234c8 100644
--- a/drivers/gpio/gpio-ppc44x.c
+++ b/drivers/gpio/gpio-ppc44x.c
@@ -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);
--
2.54.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 5/7] gpio: ppc44x: Convert GPIO to generic MMIO
2026-06-02 5:01 ` [PATCH 5/7] gpio: ppc44x: Convert GPIO to generic MMIO Rosen Penev
@ 2026-06-02 7:51 ` Bartosz Golaszewski
2026-06-02 9:26 ` Rosen Penev
0 siblings, 1 reply; 10+ messages in thread
From: Bartosz Golaszewski @ 2026-06-02 7:51 UTC (permalink / raw)
To: Rosen Penev
Cc: Madhavan Srinivasan, chleroy, Michael Ellerman, Nicholas Piggin,
Linus Walleij, Bartosz Golaszewski,
open list:LINUX FOR POWERPC (32-BIT AND 64-BIT), open list,
linux-gpio
On Tue, 2 Jun 2026 07:01:29 +0200, Rosen Penev <rosenp@gmail.com> said:
> 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
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
> ---
...
> @@ -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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 5/7] gpio: ppc44x: Convert GPIO to generic MMIO
2026-06-02 7:51 ` Bartosz Golaszewski
@ 2026-06-02 9:26 ` Rosen Penev
0 siblings, 0 replies; 10+ messages in thread
From: Rosen Penev @ 2026-06-02 9:26 UTC (permalink / raw)
To: Bartosz Golaszewski, Rosen Penev
Cc: Madhavan Srinivasan, chleroy, Michael Ellerman, Nicholas Piggin,
Linus Walleij, open list:LINUX FOR POWERPC (32-BIT AND 64-BIT),
open list, linux-gpio
On Tue Jun 2, 2026 at 12:51 AM PDT, Bartosz Golaszewski wrote:
> On Tue, 2 Jun 2026 07:01:29 +0200, Rosen Penev <rosenp@gmail.com> said:
>> 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
>> Signed-off-by: Rosen Penev <rosenp@gmail.com>
>> ---
>
> ...
>
>> @@ -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?
Sure. btw, I avoided placing
https://lore.kernel.org/all/20260517063754.21819-1-rosenp@gmail.com/
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.
>
> Bart
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2026-06-02 9:26 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-02 5:01 [PATCH 0/7] gpio: move ppc4xx driver to drivers/gpio and modernize Rosen Penev
2026-06-02 5:01 ` [PATCH 1/7] gpio: move ppc4xx gpio driver from arch/powerpc to drivers/gpio Rosen Penev
2026-06-02 5:01 ` [PATCH 2/7] gpio: ppc44x: Use module platform driver helper for GPIO Rosen Penev
2026-06-02 5:01 ` [PATCH 3/7] gpio: ppc44x: Set GPIO chip firmware node Rosen Penev
2026-06-02 5:01 ` [PATCH 4/7] gpio: ppc44x: Use platform resource helper for GPIO MMIO Rosen Penev
2026-06-02 5:01 ` [PATCH 5/7] gpio: ppc44x: Convert GPIO to generic MMIO Rosen Penev
2026-06-02 7:51 ` Bartosz Golaszewski
2026-06-02 9:26 ` Rosen Penev
2026-06-02 5:01 ` [PATCH 6/7] gpio: ppc44x: drop PPC-specific IO helpers and rename to ppc44x Rosen Penev
2026-06-02 5:01 ` [PATCH 7/7] gpio: ppc44x: add MODULE info Rosen Penev
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.