From: Ioana Ciornei <ioana.ciornei@nxp.com>
To: Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Linus Walleij <linus.walleij@linaro.org>,
Bartosz Golaszewski <brgl@bgdev.pl>,
Shawn Guo <shawnguo@kernel.org>,
Michael Walle <mwalle@kernel.org>, Lee Jones <lee@kernel.org>,
devicetree@vger.kernel.org, linux-gpio@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: Frank Li <Frank.Li@nxp.com>
Subject: [PATCH v5 08/12] gpio: add QIXIS FPGA GPIO controller
Date: Mon, 22 Sep 2025 17:24:23 +0300 [thread overview]
Message-ID: <20250922142427.3310221-9-ioana.ciornei@nxp.com> (raw)
In-Reply-To: <20250922142427.3310221-1-ioana.ciornei@nxp.com>
Add support for the GPIO controller found on some QIXIS FPGAs in
Layerscape boards such as LX2160ARDB and LS1046AQDS. This driver is
using gpio-regmap.
A GPIO controller has a maximum of 8 lines (all found in the same
register). Even within the same controller, the GPIO lines' direction is
fixed, which mean that both input and output lines are found in the same
register. This is why the driver also passed to gpio-regmap the newly
added .fixed_direction_output bitmap to represent the true direction of
the lines.
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
---
Changes in v2:
- Use the newly added .fixed_direction_output bitmap representing
the fixed direction of the GPIO lines.
Changes in v3:
- Remove 'drivers' from the commit title.
- Remove the qixis_cpld_gpio_type enum since its not needed.
- Remove the NULL check for device_get_match_data().
- Use a bitmap declared on the stack as the config field passed to
gpio-regmap.
Changes in v4:
- none
Changes in v5:
- none
drivers/gpio/Kconfig | 9 +++
drivers/gpio/Makefile | 1 +
drivers/gpio/gpio-qixis-fpga.c | 107 +++++++++++++++++++++++++++++++++
3 files changed, 117 insertions(+)
create mode 100644 drivers/gpio/gpio-qixis-fpga.c
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index 7ee3afbc2b05..c9f18ef3cc3d 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -1986,6 +1986,15 @@ config GPIO_LATCH
Say yes here to enable a driver for GPIO multiplexers based on latches
connected to other GPIOs.
+config GPIO_QIXIS_FPGA
+ tristate "NXP QIXIS FPGA GPIO support"
+ depends on MFD_SIMPLE_MFD_I2C || COMPILE_TEST
+ select GPIO_REGMAP
+ help
+ This enables support for the GPIOs found in the QIXIS FPGA which is
+ integrated on some NXP Layerscape boards such as LX2160ARDB and
+ LS1046AQDS.
+
config GPIO_MOCKUP
tristate "GPIO Testing Driver (DEPRECATED)"
select IRQ_SIM
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index ec296fa14bfd..ee260a0809d3 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -146,6 +146,7 @@ obj-$(CONFIG_GPIO_PL061) += gpio-pl061.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
+obj-$(CONFIG_GPIO_QIXIS_FPGA) += gpio-qixis-fpga.o
obj-$(CONFIG_GPIO_RASPBERRYPI_EXP) += gpio-raspberrypi-exp.o
obj-$(CONFIG_GPIO_RC5T583) += gpio-rc5t583.o
obj-$(CONFIG_GPIO_RCAR) += gpio-rcar.o
diff --git a/drivers/gpio/gpio-qixis-fpga.c b/drivers/gpio/gpio-qixis-fpga.c
new file mode 100644
index 000000000000..048a2cac4f0f
--- /dev/null
+++ b/drivers/gpio/gpio-qixis-fpga.c
@@ -0,0 +1,107 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Layerscape GPIO QIXIS FPGA driver
+ *
+ * Copyright 2025 NXP
+ */
+
+#include <linux/device.h>
+#include <linux/gpio/driver.h>
+#include <linux/gpio/regmap.h>
+#include <linux/kernel.h>
+#include <linux/mod_devicetable.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/regmap.h>
+
+struct qixis_cpld_gpio_config {
+ u64 output_lines;
+};
+
+static const struct qixis_cpld_gpio_config lx2160ardb_sfp_cfg = {
+ .output_lines = BIT(0),
+};
+
+static const struct qixis_cpld_gpio_config ls1046aqds_stat_pres2_cfg = {
+ .output_lines = 0x0,
+};
+
+static const struct regmap_config regmap_config_8r_8v = {
+ .reg_bits = 8,
+ .val_bits = 8,
+};
+
+static int qixis_cpld_gpio_probe(struct platform_device *pdev)
+{
+ DECLARE_BITMAP(fixed_direction_output, 8);
+ const struct qixis_cpld_gpio_config *cfg;
+ struct gpio_regmap_config config = {0};
+ struct regmap *regmap;
+ void __iomem *reg;
+ u32 base;
+ int ret;
+
+ if (!pdev->dev.parent)
+ return -ENODEV;
+
+ cfg = device_get_match_data(&pdev->dev);
+
+ ret = device_property_read_u32(&pdev->dev, "reg", &base);
+ if (ret)
+ return ret;
+
+ regmap = dev_get_regmap(pdev->dev.parent, NULL);
+ if (!regmap) {
+ /* In case there is no regmap configured by the parent device,
+ * create our own from the MMIO space.
+ */
+ reg = devm_platform_ioremap_resource(pdev, 0);
+ if (!reg)
+ return -ENODEV;
+
+ regmap = devm_regmap_init_mmio(&pdev->dev, reg, ®map_config_8r_8v);
+ if (!regmap)
+ return -ENODEV;
+
+ /* In this case, the offset of our register is 0 inside the
+ * regmap area that we just created.
+ */
+ base = 0;
+ }
+ config.reg_dat_base = GPIO_REGMAP_ADDR(base);
+ config.reg_set_base = GPIO_REGMAP_ADDR(base);
+
+ config.drvdata = (void *)cfg;
+ config.regmap = regmap;
+ config.parent = &pdev->dev;
+ config.ngpio_per_reg = 8;
+ config.ngpio = 8;
+
+ bitmap_from_u64(fixed_direction_output, cfg->output_lines);
+ config.fixed_direction_output = fixed_direction_output;
+
+ return PTR_ERR_OR_ZERO(devm_gpio_regmap_register(&pdev->dev, &config));
+}
+
+static const struct of_device_id qixis_cpld_gpio_of_match[] = {
+ {
+ .compatible = "fsl,lx2160ardb-fpga-gpio-sfp",
+ .data = &lx2160ardb_sfp_cfg,
+ },
+ {
+ .compatible = "fsl,ls1046aqds-fpga-gpio-stat-pres2",
+ .data = &ls1046aqds_stat_pres2_cfg,
+ },
+
+ {}
+};
+MODULE_DEVICE_TABLE(of, qixis_cpld_gpio_of_match);
+
+static struct platform_driver qixis_cpld_gpio_driver = {
+ .probe = qixis_cpld_gpio_probe,
+ .driver = {
+ .name = "gpio-qixis-cpld",
+ .of_match_table = qixis_cpld_gpio_of_match,
+ },
+};
+module_platform_driver(qixis_cpld_gpio_driver);
--
2.25.1
next prev parent reply other threads:[~2025-09-22 14:24 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-22 14:24 [PATCH v5 00/12] drivers: gpio: and the QIXIS FPGA GPIO controller Ioana Ciornei
2025-09-22 14:24 ` [PATCH v5 01/12] dt-bindings: gpio: add QIXIS FPGA based " Ioana Ciornei
2025-09-22 14:40 ` Bartosz Golaszewski
2025-09-22 14:24 ` [PATCH v5 02/12] dt-bindings: fsl,fpga-qixis-i2c: add support for LX2160ARDB FPGA Ioana Ciornei
2025-09-22 14:24 ` [PATCH v5 03/12] dt-bindings: fsl,fpga-qixis: describe the gpio child node found on LS1046AQDS Ioana Ciornei
2025-09-23 14:37 ` Rob Herring (Arm)
2025-09-22 14:24 ` [PATCH v5 04/12] mfd: simple-mfd-i2c: keep compatible strings in alphabetical order Ioana Ciornei
2025-09-25 12:13 ` Lee Jones
2025-09-22 14:24 ` [PATCH v5 05/12] mfd: simple-mfd-i2c: add compatible string for LX2160ARDB Ioana Ciornei
2025-09-22 14:24 ` [PATCH v5 06/12] gpio: regmap: fix memory leak of gpio_regmap structure Ioana Ciornei
2025-09-22 14:31 ` Michael Walle
2025-09-22 14:24 ` [PATCH v5 07/12] gpio: regmap: add the .fixed_direction_output configuration parameter Ioana Ciornei
2025-09-22 14:32 ` Michael Walle
2025-09-22 14:39 ` Bartosz Golaszewski
2025-09-22 14:24 ` Ioana Ciornei [this message]
2025-09-22 14:34 ` [PATCH v5 08/12] gpio: add QIXIS FPGA GPIO controller Michael Walle
2025-09-22 14:39 ` Bartosz Golaszewski
2025-09-30 23:00 ` Linus Walleij
2025-09-22 14:24 ` [PATCH v5 09/12] arm64: dts: lx2160a-rdb: describe the QIXIS FPGA and two child GPIO controllers Ioana Ciornei
2025-09-22 14:24 ` [PATCH v5 10/12] arm64: dts: ls1046a-qds: describe the FPGA based GPIO controller Ioana Ciornei
2025-09-22 14:24 ` [PATCH v5 11/12] arm64: dts: lx2160a-rdb: fully describe the two SFP+ cages Ioana Ciornei
2025-09-22 14:24 ` [PATCH v5 12/12] arm64: dts: ls1046a-qds: describe the two on-board " Ioana Ciornei
2025-09-22 14:36 ` (subset) [PATCH v5 00/12] drivers: gpio: and the QIXIS FPGA GPIO controller Bartosz Golaszewski
2025-09-22 14:41 ` Ioana Ciornei
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250922142427.3310221-9-ioana.ciornei@nxp.com \
--to=ioana.ciornei@nxp.com \
--cc=Frank.Li@nxp.com \
--cc=brgl@bgdev.pl \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=lee@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mwalle@kernel.org \
--cc=robh@kernel.org \
--cc=shawnguo@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).