[PATCH v2 08/24] gpio: Add ZTE ZX279128S GPIO driver
Bartosz Golaszewski
brgl at kernel.org
Thu Oct 15 05:25:00 PDT 2026
On Wed, 14 Oct 2026 09:20:48 +0200, Navid Ghahremani
<ghahramani.navid at gmail.com> said:
> Expose the six banks using the generic GPIO implementation and enable
> the register clock before accessing the bank.
>
> Signed-off-by: Navid Ghahremani <ghahramani.navid at gmail.com>
> ---
> drivers/gpio/Kconfig | 12 ++++++
> drivers/gpio/Makefile | 1 +
> drivers/gpio/gpio-zx279128s.c | 79 +++++++++++++++++++++++++++++++++++
> 3 files changed, 92 insertions(+)
> create mode 100644 drivers/gpio/gpio-zx279128s.c
>
> diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
> index a48586bb8e..3ae51a3c10 100644
> --- a/drivers/gpio/Kconfig
> +++ b/drivers/gpio/Kconfig
> @@ -902,6 +902,18 @@ config GPIO_ZEVIO
> help
> Say yes here to support the GPIO controller in LSI ZEVIO SoCs.
>
> +config GPIO_ZX279128S
> + tristate "ZTE zx279128s GPIO support"
> + depends on ARCH_ZTE || COMPILE_TEST
> + select GPIO_GENERIC
> + help
> + Say yes here to support the GPIO controller of the ZTE zx279128s
> + SoC. It has several banks of 16 lines each, which boards such as
> + the ZTE ZXHN H3600 use for LEDs, buttons and reset lines.
> +
> + To compile this driver as a module, choose M here: the module
> + will be called gpio-zx279128s.
> +
> config GPIO_ZYNQ
> tristate "Xilinx Zynq GPIO support"
> depends on ARCH_ZYNQ || ARCH_ZYNQMP || COMPILE_TEST
> diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
> index dc9e6d643b..a57ed7ec71 100644
> --- a/drivers/gpio/Makefile
> +++ b/drivers/gpio/Makefile
> @@ -223,5 +223,6 @@ obj-$(CONFIG_GPIO_XLP) += gpio-xlp.o
> obj-$(CONFIG_GPIO_XRA1403) += gpio-xra1403.o
> obj-$(CONFIG_GPIO_XTENSA) += gpio-xtensa.o
> obj-$(CONFIG_GPIO_ZEVIO) += gpio-zevio.o
> +obj-$(CONFIG_GPIO_ZX279128S) += gpio-zx279128s.o
> obj-$(CONFIG_GPIO_ZYNQ) += gpio-zynq.o
> obj-$(CONFIG_GPIO_ZYNQMP_MODEPIN) += gpio-zynqmp-modepin.o
> diff --git a/drivers/gpio/gpio-zx279128s.c b/drivers/gpio/gpio-zx279128s.c
> new file mode 100644
> index 0000000000..71eb6b5d82
> --- /dev/null
> +++ b/drivers/gpio/gpio-zx279128s.c
> @@ -0,0 +1,79 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * ZTE zx279128s GPIO controller
> + *
> + * Copyright (C) 2026 Navid Ghahremani <ghahramani.navid at gmail.com>
> + */
> +
> +#include <linux/clk.h>
> +#include <linux/err.h>
> +#include <linux/gpio/driver.h>
> +#include <linux/gpio/generic.h>
> +#include <linux/module.h>
> +#include <linux/platform_device.h>
> +
> +/*
> + * Each bank has 16 lines, one bit per line in each register. The registers
> + * at 0x04-0x10 and 0x28-0x34 control the interrupts, which are not supported
> + * yet.
> + */
> +#define ZX279128S_GPIO_DIR 0x00 /* 1: output */
> +#define ZX279128S_GPIO_DATA 0x14 /* line level */
> +#define ZX279128S_GPIO_SET 0x18 /* write 1: drive high */
> +#define ZX279128S_GPIO_CLEAR 0x1c /* write 1: drive low */
> +
> +static int zx279128s_gpio_probe(struct platform_device *pdev)
> +{
> + struct gpio_generic_chip_config config = { };
Don't initialize it here, instead...
> + struct device *dev = &pdev->dev;
> + struct gpio_generic_chip *chip;
> + void __iomem *base;
> + struct clk *clk;
> + int ret;
> +
> + chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
> + if (!chip)
> + return -ENOMEM;
> +
> + base = devm_platform_ioremap_resource(pdev, 0);
> + if (IS_ERR(base))
> + return PTR_ERR(base);
> +
> + clk = devm_clk_get_enabled(dev, NULL);
> + if (IS_ERR(clk))
> + return dev_err_probe(dev, PTR_ERR(clk), "failed to get the clock\n");
> +
> + config.dev = dev;
> + config.sz = 4;
> + config.dat = base + ZX279128S_GPIO_DATA;
> + config.set = base + ZX279128S_GPIO_SET;
> + config.clr = base + ZX279128S_GPIO_CLEAR;
> + config.dirout = base + ZX279128S_GPIO_DIR;
> +
... do:
config = (struct gpio_generic_chip){
.dev = dev,
...
};
> + ret = gpio_generic_chip_init(chip, &config);
> + if (ret)
> + return dev_err_probe(dev, ret, "failed to set up the GPIO chip\n");
> +
> + chip->gc.ngpio = 16;
> +
> + return devm_gpiochip_add_data(dev, &chip->gc, NULL);
> +}
> +
> +static const struct of_device_id zx279128s_gpio_of_match[] = {
> + { .compatible = "zte,zx279128s-gpio" },
> + { }
> +};
> +MODULE_DEVICE_TABLE(of, zx279128s_gpio_of_match);
> +
> +static struct platform_driver zx279128s_gpio_driver = {
> + .probe = zx279128s_gpio_probe,
> + .driver = {
> + .name = "zx279128s-gpio",
> + .of_match_table = zx279128s_gpio_of_match,
> + },
> +};
> +module_platform_driver(zx279128s_gpio_driver);
> +
> +MODULE_AUTHOR("Navid Ghahremani <ghahramani.navid at gmail.com>");
> +MODULE_DESCRIPTION("ZTE zx279128s GPIO controller driver");
> +MODULE_LICENSE("GPL");
> --
> 2.55.0
>
>
Looks pretty good, I love small drivers like this.
Bart
More information about the linux-arm-kernel
mailing list