linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] gpio: menz127: add support for 16Z034 and 16Z037 GPIO controllers
@ 2025-11-11 16:18 Jose Javier Rodriguez Barbarin
  2025-11-12 15:48 ` Krzysztof Kozlowski
  0 siblings, 1 reply; 5+ messages in thread
From: Jose Javier Rodriguez Barbarin @ 2025-11-11 16:18 UTC (permalink / raw)
  To: linus.walleij, brgl
  Cc: linux-gpio, linux-kernel, Jose Javier Rodriguez Barbarin,
	Felipe Jensen Casado

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

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

diff --git a/drivers/gpio/gpio-menz127.c b/drivers/gpio/gpio-menz127.c
index da2bf9381cc4..cddf16980817 100644
--- a/drivers/gpio/gpio-menz127.c
+++ b/drivers/gpio/gpio-menz127.c
@@ -24,6 +24,11 @@
 #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)
@@ -140,6 +145,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 +169,21 @@ static int men_z127_probe(struct mcb_device *mdev,
 
 	mcb_set_drvdata(mdev, men_z127_gpio);
 
+	switch (mdev->id) {
+	case MEN_Z127_ID:
+		sz = 4;
+		break;
+	case MEN_Z034_ID:
+	case MEN_Z037_ID:
+		sz = 1;
+		break;
+	default:
+		return dev_err_probe(&mdev->dev, -EINVAL, "no size found for id %d", mdev->id);
+	}
+
 	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 +204,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);
@@ -204,4 +224,6 @@ MODULE_AUTHOR("Andreas Werner <andreas.werner@men.de>");
 MODULE_DESCRIPTION("MEN 16z127 GPIO Controller");
 MODULE_LICENSE("GPL v2");
 MODULE_ALIAS("mcb:16z127");
+MODULE_ALIAS("mcb:16z034");
+MODULE_ALIAS("mcb:16z037");
 MODULE_IMPORT_NS("MCB");
-- 
2.51.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] gpio: menz127: add support for 16Z034 and 16Z037 GPIO controllers
  2025-11-11 16:18 [PATCH v2] gpio: menz127: add support for 16Z034 and 16Z037 GPIO controllers Jose Javier Rodriguez Barbarin
@ 2025-11-12 15:48 ` Krzysztof Kozlowski
  2025-11-17 13:38   ` Jose Javier Rodriguez Barbarin
  0 siblings, 1 reply; 5+ messages in thread
From: Krzysztof Kozlowski @ 2025-11-12 15:48 UTC (permalink / raw)
  To: Jose Javier Rodriguez Barbarin, linus.walleij, brgl
  Cc: linux-gpio, linux-kernel, Felipe Jensen Casado

On 11/11/2025 17:18, Jose Javier Rodriguez Barbarin wrote:
>  
>  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);
> @@ -204,4 +224,6 @@ MODULE_AUTHOR("Andreas Werner <andreas.werner@men.de>");
>  MODULE_DESCRIPTION("MEN 16z127 GPIO Controller");
>  MODULE_LICENSE("GPL v2");
>  MODULE_ALIAS("mcb:16z127");
> +MODULE_ALIAS("mcb:16z034");
> +MODULE_ALIAS("mcb:16z037");

Why do you need these? You have MODULE_DEVICE_TABLE() just few lines above.

>  MODULE_IMPORT_NS("MCB");


Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] gpio: menz127: add support for 16Z034 and 16Z037 GPIO controllers
  2025-11-12 15:48 ` Krzysztof Kozlowski
@ 2025-11-17 13:38   ` Jose Javier Rodriguez Barbarin
  2025-11-17 14:35     ` Krzysztof Kozlowski
  2025-11-19 13:54     ` Linus Walleij
  0 siblings, 2 replies; 5+ messages in thread
From: Jose Javier Rodriguez Barbarin @ 2025-11-17 13:38 UTC (permalink / raw)
  To: Krzysztof Kozlowski; +Cc: linus.walleij, brgl, linux-gpio, linux-kernel

Hi Krzysztof,

Thank you for your review.

On Wed, Nov 12, 2025 at 04:48:53PM +0100, Krzysztof Kozlowski wrote:
> On 11/11/2025 17:18, Jose Javier Rodriguez Barbarin wrote:
> >  
> >  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);
> > @@ -204,4 +224,6 @@ MODULE_AUTHOR("Andreas Werner <andreas.werner@men.de>");
> >  MODULE_DESCRIPTION("MEN 16z127 GPIO Controller");
> >  MODULE_LICENSE("GPL v2");
> >  MODULE_ALIAS("mcb:16z127");
> > +MODULE_ALIAS("mcb:16z034");
> > +MODULE_ALIAS("mcb:16z037");
> 
> Why do you need these? You have MODULE_DEVICE_TABLE() just few lines above.
> 

I added this new MODULE_ALIAS() because it is the mechanism that previous contributors
used to enable autoloading of mcb device drivers. After reading your comment,
I decided to investigate further how the MODULE_DEVICE_TABLE() macro is used and processed.
I discovered that MODULE_DEVICE_TABLE(mcb, ...) was being ignored by the kernel build
system. For this reason, I'm preparing a new patch to add support for MCB devices 
in file2alias.

Therefore, I will send a V3 patch that simply removes these new MODULE_ALIAS() entries,
and another patch to add support for automatically generating module aliases based on 
MODULE_DEVICE_TABLE() instead of MODULE_ALIAS().

> >  MODULE_IMPORT_NS("MCB");
> 
> 
> Best regards,
> Krzysztof

Best regards,

Javier R.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] gpio: menz127: add support for 16Z034 and 16Z037 GPIO controllers
  2025-11-17 13:38   ` Jose Javier Rodriguez Barbarin
@ 2025-11-17 14:35     ` Krzysztof Kozlowski
  2025-11-19 13:54     ` Linus Walleij
  1 sibling, 0 replies; 5+ messages in thread
From: Krzysztof Kozlowski @ 2025-11-17 14:35 UTC (permalink / raw)
  To: Jose Javier Rodriguez Barbarin
  Cc: linus.walleij, brgl, linux-gpio, linux-kernel

On 17/11/2025 14:38, Jose Javier Rodriguez Barbarin wrote:
>>>  MODULE_DEVICE_TABLE(mcb, men_z127_ids);
>>> @@ -204,4 +224,6 @@ MODULE_AUTHOR("Andreas Werner <andreas.werner@men.de>");
>>>  MODULE_DESCRIPTION("MEN 16z127 GPIO Controller");
>>>  MODULE_LICENSE("GPL v2");
>>>  MODULE_ALIAS("mcb:16z127");
>>> +MODULE_ALIAS("mcb:16z034");
>>> +MODULE_ALIAS("mcb:16z037");
>>
>> Why do you need these? You have MODULE_DEVICE_TABLE() just few lines above.
>>
> 
> I added this new MODULE_ALIAS() because it is the mechanism that previous contributors
> used to enable autoloading of mcb device drivers. After reading your comment,
> I decided to investigate further how the MODULE_DEVICE_TABLE() macro is used and processed.
> I discovered that MODULE_DEVICE_TABLE(mcb, ...) was being ignored by the kernel build
> system. For this reason, I'm preparing a new patch to add support for MCB devices 
> in file2alias.
> 
> Therefore, I will send a V3 patch that simply removes these new MODULE_ALIAS() entries,
> and another patch to add support for automatically generating module aliases based on 
> MODULE_DEVICE_TABLE() instead of MODULE_ALIAS().

Thanks, looks like good approach.

Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] gpio: menz127: add support for 16Z034 and 16Z037 GPIO controllers
  2025-11-17 13:38   ` Jose Javier Rodriguez Barbarin
  2025-11-17 14:35     ` Krzysztof Kozlowski
@ 2025-11-19 13:54     ` Linus Walleij
  1 sibling, 0 replies; 5+ messages in thread
From: Linus Walleij @ 2025-11-19 13:54 UTC (permalink / raw)
  To: Jose Javier Rodriguez Barbarin
  Cc: Krzysztof Kozlowski, brgl, linux-gpio, linux-kernel

On Mon, Nov 17, 2025 at 2:39 PM Jose Javier Rodriguez Barbarin
<dev-josejavier.rodriguez@duagon.com> wrote:

> I added this new MODULE_ALIAS() because it is the mechanism that previous contributors
> used to enable autoloading of mcb device drivers. After reading your comment,
> I decided to investigate further how the MODULE_DEVICE_TABLE() macro is used and processed.
> I discovered that MODULE_DEVICE_TABLE(mcb, ...) was being ignored by the kernel build
> system. For this reason, I'm preparing a new patch to add support for MCB devices
> in file2alias.
>
> Therefore, I will send a V3 patch that simply removes these new MODULE_ALIAS() entries,
> and another patch to add support for automatically generating module aliases based on
> MODULE_DEVICE_TABLE() instead of MODULE_ALIAS().

Excellent, thanks for doing this!

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-11-19 13:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-11 16:18 [PATCH v2] gpio: menz127: add support for 16Z034 and 16Z037 GPIO controllers Jose Javier Rodriguez Barbarin
2025-11-12 15:48 ` Krzysztof Kozlowski
2025-11-17 13:38   ` Jose Javier Rodriguez Barbarin
2025-11-17 14:35     ` Krzysztof Kozlowski
2025-11-19 13:54     ` Linus Walleij

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).