Linux GPIO subsystem development
 help / color / mirror / Atom feed
From: Jose Javier Rodriguez Barbarin <dev-josejavier.rodriguez@duagon.com>
To: linus.walleij@linaro.org, brgl@bgdev.pl
Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] gpio: menz127: add support for 16Z034 and 16Z037 GPIO controllers
Date: Fri, 31 Oct 2025 11:07:53 +0100	[thread overview]
Message-ID: <e6107389-ce76-66c9-b390-4ce79a19c0d1@duagon.com> (raw)

From 7655a73f3888a5d164d1f287ba1f2989bb2aadd2 Mon Sep 17 00:00:00 2001
From: Javier Rodriguez <josejavier.rodriguez@duagon.com>
Date: Tue, 28 Oct 2025 17:40:14 +0100
Subject: [PATCH] gpio: menz127: add support for 16Z034 and 16Z037 GPIO
 controllers

The 16Z034 and 16Z037 are 8 bits GPIO controllers that share the
same registers and features of the 16Z127 GPIO controller.

Reviewed-by: Felipe Fensen Casado <felipe.jensen@duagon.com>
Signed-off-by: Javier Rodriguez <josejavier.rodriguez@duagon.com>
---
 drivers/gpio/gpio-menz127.c | 36 ++++++++++++++++++++++++++++++++++--
 1 file changed, 34 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/gpio-menz127.c b/drivers/gpio/gpio-menz127.c
index da2bf9381cc4..ec9228f1e631 100644
--- a/drivers/gpio/gpio-menz127.c
+++ b/drivers/gpio/gpio-menz127.c
@@ -24,6 +24,12 @@
 #define MEN_Z127_ODER	0x1C
 #define GPIO_TO_DBCNT_REG(gpio)	((gpio * 4) + 0x80)
 
+
+/* MEN Z127 supported model ids*/
+#define MEN_Z127_ID	0x7f
+#define MEN_Z034_ID	0x22
+#define MEN_Z037_ID	0x25
+
 #define MEN_Z127_DB_MIN_US	50
 /* 16 bit compare register. Each bit represents 50us */
 #define MEN_Z127_DB_MAX_US	(0xffff * MEN_Z127_DB_MIN_US)
@@ -36,6 +42,25 @@ struct men_z127_gpio {
 	struct resource *mem;
 };
 
+static int men_z127_lookup_gpio_size(struct mcb_device *mdev,
+				     unsigned long *sz)
+{
+	switch (mdev->id) {
+	case MEN_Z127_ID:
+		*sz = 4;
+		break;
+	case MEN_Z034_ID:
+	case MEN_Z037_ID:
+		*sz = 1;
+		break;
+	default:
+		dev_err(&mdev->dev, "no size found for id %d", mdev->id);
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
 static int men_z127_debounce(struct gpio_chip *gc, unsigned gpio,
 			     unsigned debounce)
 {
@@ -140,6 +165,7 @@ static int men_z127_probe(struct mcb_device *mdev,
 	struct men_z127_gpio *men_z127_gpio;
 	struct device *dev = &mdev->dev;
 	int ret;
+	unsigned long sz;
 
 	men_z127_gpio = devm_kzalloc(dev, sizeof(struct men_z127_gpio),
 				     GFP_KERNEL);
@@ -163,9 +189,13 @@ static int men_z127_probe(struct mcb_device *mdev,
 
 	mcb_set_drvdata(mdev, men_z127_gpio);
 
+	ret = men_z127_lookup_gpio_size(mdev, &sz);
+	if (ret)
+		return ret;
+
 	config = (struct gpio_generic_chip_config) {
 		.dev = &mdev->dev,
-		.sz = 4,
+		.sz = sz,
 		.dat = men_z127_gpio->reg_base + MEN_Z127_PSR,
 		.set = men_z127_gpio->reg_base + MEN_Z127_CTRL,
 		.dirout = men_z127_gpio->reg_base + MEN_Z127_GPIODR,
@@ -186,7 +216,9 @@ static int men_z127_probe(struct mcb_device *mdev,
 }
 
 static const struct mcb_device_id men_z127_ids[] = {
-	{ .device = 0x7f },
+	{ .device = MEN_Z127_ID },
+	{ .device = MEN_Z034_ID },
+	{ .device = MEN_Z037_ID },
 	{ }
 };
 MODULE_DEVICE_TABLE(mcb, men_z127_ids);
-- 
2.51.0

             reply	other threads:[~2025-10-31 10:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-31 10:07 Jose Javier Rodriguez Barbarin [this message]
2025-11-05  8:36 ` [PATCH] gpio: menz127: add support for 16Z034 and 16Z037 GPIO controllers Bartosz Golaszewski
2025-11-07 13:25   ` Jose Javier Rodriguez Barbarin

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=e6107389-ce76-66c9-b390-4ce79a19c0d1@duagon.com \
    --to=dev-josejavier.rodriguez@duagon.com \
    --cc=brgl@bgdev.pl \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.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