drivers/gpio/gpio-menz127.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-)
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
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
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.
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
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
© 2016 - 2026 Red Hat, Inc.