[{"id":3674617,"web_url":"http://patchwork.ozlabs.org/comment/3674617/","msgid":"<CAMRc=MfUh_OuxS4SC6QzSOg_PMNc9i9crGYgBASrbVUgHDHSCw@mail.gmail.com>","list_archive_url":null,"date":"2026-04-08T07:31:29","subject":"Re: [PATCH v2 3/4] gpio: realtek: Add driver for Realtek DHC RTD1625\n SoC","submitter":{"id":92191,"url":"http://patchwork.ozlabs.org/api/people/92191/","name":"Bartosz Golaszewski","email":"brgl@kernel.org"},"content":"On Wed, 8 Apr 2026 04:52:42 +0200, Yu-Chun Lin <eleanor.lin@realtek.com> said:\n> From: Tzuyi Chang <tychang@realtek.com>\n>\n> Add support for the GPIO controller found on Realtek DHC RTD1625 SoCs.\n>\n> Unlike the existing Realtek GPIO driver (drivers/gpio/gpio-rtd.c),\n> which manages pins via shared bank registers, the RTD1625 introduces\n> a per-pin register architecture. Each GPIO line now has its own\n> dedicated 32-bit control register to manage configuration independently,\n> including direction, output value, input value, interrupt enable, and\n> debounce. Therefore, this distinct hardware design requires a separate\n> driver.\n>\n> Reviewed-by: Linus Walleij <linusw@kernel.org>\n> Signed-off-by: Tzuyi Chang <tychang@realtek.com>\n> Signed-off-by: Yu-Chun Lin <eleanor.lin@realtek.com>\n> ---\n> Changes in v2:\n> - Remove \"default y\".\n> - Add base_offset member to struct rtd1625_gpio_info to handle merged regions.\n> ---\n>  drivers/gpio/Kconfig        |  11 +\n>  drivers/gpio/Makefile       |   1 +\n>  drivers/gpio/gpio-rtd1625.c | 584 ++++++++++++++++++++++++++++++++++++\n>  3 files changed, 596 insertions(+)\n>  create mode 100644 drivers/gpio/gpio-rtd1625.c\n>\n> diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig\n> index 5ee11a889867..281549ad72ac 100644\n> --- a/drivers/gpio/Kconfig\n> +++ b/drivers/gpio/Kconfig\n> @@ -638,6 +638,17 @@ config GPIO_RTD\n>  \t  Say yes here to support GPIO functionality and GPIO interrupt on\n>  \t  Realtek DHC SoCs.\n>\n> +config GPIO_RTD1625\n> +\ttristate \"Realtek DHC RTD1625 GPIO support\"\n> +\tdepends on ARCH_REALTEK || COMPILE_TEST\n> +\tselect GPIOLIB_IRQCHIP\n> +\thelp\n> +\t  This option enables support for the GPIO controller on Realtek\n> +\t  DHC (Digital Home Center) RTD1625 SoC.\n> +\n> +\t  Say yes here to support both basic GPIO line functionality\n> +\t  and GPIO interrupt handling capabilities for this platform.\n> +\n>  config GPIO_SAMA5D2_PIOBU\n>  \ttristate \"SAMA5D2 PIOBU GPIO support\"\n>  \tdepends on MFD_SYSCON\n> diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile\n> index c05f7d795c43..c95ba218d53a 100644\n> --- a/drivers/gpio/Makefile\n> +++ b/drivers/gpio/Makefile\n> @@ -159,6 +159,7 @@ obj-$(CONFIG_GPIO_REALTEK_OTTO)\t\t+= gpio-realtek-otto.o\n>  obj-$(CONFIG_GPIO_REG)\t\t\t+= gpio-reg.o\n>  obj-$(CONFIG_GPIO_ROCKCHIP)\t+= gpio-rockchip.o\n>  obj-$(CONFIG_GPIO_RTD)\t\t\t+= gpio-rtd.o\n> +obj-$(CONFIG_GPIO_RTD1625)\t\t+= gpio-rtd1625.o\n>  obj-$(CONFIG_ARCH_SA1100)\t\t+= gpio-sa1100.o\n>  obj-$(CONFIG_GPIO_SAMA5D2_PIOBU)\t+= gpio-sama5d2-piobu.o\n>  obj-$(CONFIG_GPIO_SCH311X)\t\t+= gpio-sch311x.o\n> diff --git a/drivers/gpio/gpio-rtd1625.c b/drivers/gpio/gpio-rtd1625.c\n> new file mode 100644\n> index 000000000000..bcc1bbb115fa\n> --- /dev/null\n> +++ b/drivers/gpio/gpio-rtd1625.c\n> @@ -0,0 +1,584 @@\n> +// SPDX-License-Identifier: GPL-2.0-or-later\n> +/*\n> + * Realtek DHC RTD1625 gpio driver\n> + *\n> + * Copyright (c) 2023 Realtek Semiconductor Corp.\n\nNo modifications since 2023?\n\n> + */\n> +\n> +#include <linux/bitfield.h>\n> +#include <linux/bitops.h>\n> +#include <linux/gpio/driver.h>\n> +#include <linux/interrupt.h>\n> +#include <linux/irqchip.h>\n> +#include <linux/irqchip/chained_irq.h>\n> +#include <linux/irqdomain.h>\n> +#include <linux/module.h>\n> +#include <linux/platform_device.h>\n> +#include <linux/property.h>\n> +#include <linux/spinlock.h>\n> +#include <linux/types.h>\n> +\n> +#define RTD1625_GPIO_DIR BIT(0)\n> +#define RTD1625_GPIO_OUT BIT(2)\n> +#define RTD1625_GPIO_IN BIT(4)\n> +#define RTD1625_GPIO_EDGE_INT_DP BIT(6)\n> +#define RTD1625_GPIO_EDGE_INT_EN BIT(8)\n> +#define RTD1625_GPIO_LEVEL_INT_EN BIT(16)\n> +#define RTD1625_GPIO_LEVEL_INT_DP BIT(18)\n> +#define RTD1625_GPIO_DEBOUNCE GENMASK(30, 28)\n> +#define RTD1625_GPIO_DEBOUNCE_WREN BIT(31)\n> +\n> +#define RTD1625_GPIO_WREN(x) ((x) << 1)\n> +\n> +/* Write-enable masks for all GPIO configs and reserved hardware bits */\n> +#define RTD1625_ISO_GPIO_WREN_ALL 0x8000aa8a\n> +#define RTD1625_ISOM_GPIO_WREN_ALL 0x800aaa8a\n> +\n> +#define RTD1625_GPIO_DEBOUNCE_1US 0\n> +#define RTD1625_GPIO_DEBOUNCE_10US 1\n> +#define RTD1625_GPIO_DEBOUNCE_100US 2\n> +#define RTD1625_GPIO_DEBOUNCE_1MS 3\n> +#define RTD1625_GPIO_DEBOUNCE_10MS 4\n> +#define RTD1625_GPIO_DEBOUNCE_20MS 5\n> +#define RTD1625_GPIO_DEBOUNCE_30MS 6\n> +#define RTD1625_GPIO_DEBOUNCE_50MS 7\n> +\n> +#define GPIO_CONTROL(gpio) ((gpio) * 4)\n> +\n> +/**\n> + * struct rtd1625_gpio_info - Specific GPIO register information\n> + * @num_gpios: The number of GPIOs\n> + * @irq_type_support: Supported IRQ types\n> + * @gpa_offset: Offset for GPIO assert interrupt status registers\n> + * @gpda_offset: Offset for GPIO deassert interrupt status registers\n> + * @level_offset: Offset of level interrupt status register\n> + * @write_en_all: Write-enable mask for all configurable bits\n> + */\n> +struct rtd1625_gpio_info {\n> +\tunsigned int\tnum_gpios;\n> +\tunsigned int\tirq_type_support;\n> +\tunsigned int\tbase_offset;\n> +\tunsigned int\tgpa_offset;\n> +\tunsigned int\tgpda_offset;\n> +\tunsigned int\tlevel_offset;\n> +\tunsigned int\twrite_en_all;\n> +};\n\nPlease remove the tabs in the above struct.\n\n> +\n> +struct rtd1625_gpio {\n> +\tstruct gpio_chip\t\tgpio_chip;\n> +\tconst struct rtd1625_gpio_info\t*info;\n> +\tvoid __iomem\t\t\t*base;\n> +\tvoid __iomem\t\t\t*irq_base;\n> +\tunsigned int\t\t\tirqs[3];\n> +\traw_spinlock_t\t\t\tlock;\n> +\tunsigned int\t\t\t*save_regs;\n> +};\n\nI'd also personally remove these tabs here but won't die on that hill.\n\n> +\n> +static unsigned int rtd1625_gpio_gpa_offset(struct rtd1625_gpio *data, unsigned int offset)\n> +{\n> +\treturn data->info->gpa_offset + ((offset / 32) * 4);\n> +}\n> +\n> +static unsigned int rtd1625_gpio_gpda_offset(struct rtd1625_gpio *data, unsigned int offset)\n> +{\n> +\treturn data->info->gpda_offset + ((offset / 32) * 4);\n> +}\n> +\n> +static unsigned int rtd1625_gpio_level_offset(struct rtd1625_gpio *data, unsigned int offset)\n> +{\n> +\treturn data->info->level_offset + ((offset / 32) * 4);\n> +}\n\nLooking at these, I'm under the impression that this driver could quite easily\nbe converted to using gpio-mmio or even gpio-regmap with an MMIO regmap, have\nyou looked into it by any chance?\n\nBart","headers":{"Return-Path":"\n <linux-gpio+bounces-34867-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-gpio@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=V2dJR7dQ;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=172.234.253.10; helo=sea.lore.kernel.org;\n envelope-from=linux-gpio+bounces-34867-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=\"V2dJR7dQ\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=10.30.226.201"],"Received":["from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4frFBz4tVCz1xtJ\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 08 Apr 2026 17:32:27 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id D39793017274\n\tfor <incoming@patchwork.ozlabs.org>; Wed,  8 Apr 2026 07:31:33 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 973EB382381;\n\tWed,  8 Apr 2026 07:31:32 +0000 (UTC)","from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org\n [10.30.226.201])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 58AD9359A8A\n\tfor <linux-gpio@vger.kernel.org>; Wed,  8 Apr 2026 07:31:32 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id 1C262C2BCB3\n\tfor <linux-gpio@vger.kernel.org>; Wed,  8 Apr 2026 07:31:32 +0000 (UTC)","by mail-lj1-f172.google.com with SMTP id\n 38308e7fff4ca-38dd9c6840aso36832011fa.0\n        for <linux-gpio@vger.kernel.org>;\n Wed, 08 Apr 2026 00:31:31 -0700 (PDT)","from 969154062570 named unknown by gmailapi.google.com with\n HTTPREST; Wed, 8 Apr 2026 00:31:29 -0700","from 969154062570 named unknown by gmailapi.google.com with\n HTTPREST; Wed, 8 Apr 2026 00:31:29 -0700"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1775633492; cv=none;\n b=lT2BQq+zUozvI3+jz89+QsFMq9+jByQ+QsuLDnEqPJk7qG1cvUikCQgb1YXBmM9c+pJOX4X1bexkazB86rFaKrGdEE53Hvev5BpE190zrvJE4g7ByKldVJ0/JPsIiyiDQHJqo5HDfkpvA6N83BgmKmvYwXom93Pt49u9R7duI8E=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1775633492; c=relaxed/simple;\n\tbh=kTCKrQL00F1TtK9Lwc24qq0fGDc6kjFjWFKBMs3ppAI=;\n\th=From:In-Reply-To:MIME-Version:References:Date:Message-ID:Subject:\n\t To:Cc:Content-Type;\n b=VJbFKYgmRVkKgT47tATE5KSEuE4wBdcpHZxx88WCp1NuQV/g5xqDaAqh8zCph4DU0JIQucjT73oUDOUl2FvzAtYb224Kv4s/nHClOvLHpYxFpKxibfSnHCd8815sdJcgBY9/PKL0G8kxWzuc04KUiSdXLXTbWHgAD68qVW2ynWk=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=V2dJR7dQ; arc=none smtp.client-ip=10.30.226.201","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;\n\ts=k20201202; t=1775633492;\n\tbh=kTCKrQL00F1TtK9Lwc24qq0fGDc6kjFjWFKBMs3ppAI=;\n\th=From:In-Reply-To:References:Date:Subject:To:Cc:From;\n\tb=V2dJR7dQPnPRwc13ZdP55Rlj1GFe4mgJhxJ6yZkIcek7h8pamPD7FeqI+osD7Gp5g\n\t udUrN7iGrBo94H7sJ0AwHlqzA1+2K5bnTeRueNwXPWqzfoafJsManetQ2AsrB2rFCI\n\t Ju7gA52R+mngm/6yQFaGaWxyrrhLdMcVNz/YOuiN7lBAdhdwXpG75VuUoJOPco0p2U\n\t G93sboc+zXveOLyYEE4YHKc7VaJiKXudCCL8RQsmEfIq3YrO/VESiru8soc8HrUMwy\n\t aRHylJ3ZXNa4c+4UnszFw0qyR0plSc+XZWaJNeizU9XTmenBY1HmlTlYINhbLJE+sX\n\t dNbX8iZ3Ommog==","X-Gm-Message-State":"AOJu0YzfjQ0bdtYGhsevC8NRsggNx++HlStZs89ZEDvG7Q2LbQ5Ybcyg\n\tkdJEYChzHjx3XH1Xj16xo+EdBysOtp3I6OE0E6rHsvTHHduSsiomPz67PEJBJhgcZbif0KGK/Uh\n\tQaxonECJNy6V+7oOLpDCoxNUdymp1NfgZsiiUJG+lOA==","X-Received":"by 2002:a05:651c:154c:b0:38e:1714:b64e with SMTP id\n 38308e7fff4ca-38e1714bf45mr17377281fa.3.1775633490684; Wed, 08 Apr 2026\n 00:31:30 -0700 (PDT)","From":"Bartosz Golaszewski <brgl@kernel.org>","In-Reply-To":"<20260408025243.1155482-4-eleanor.lin@realtek.com>","Precedence":"bulk","X-Mailing-List":"linux-gpio@vger.kernel.org","List-Id":"<linux-gpio.vger.kernel.org>","List-Subscribe":"<mailto:linux-gpio+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-gpio+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","References":"<20260408025243.1155482-1-eleanor.lin@realtek.com>\n <20260408025243.1155482-4-eleanor.lin@realtek.com>","Date":"Wed, 8 Apr 2026 00:31:29 -0700","X-Gmail-Original-Message-ID":"\n <CAMRc=MfUh_OuxS4SC6QzSOg_PMNc9i9crGYgBASrbVUgHDHSCw@mail.gmail.com>","X-Gm-Features":"AQROBzB5exLZ5SG0QSPEWBvRd7DGoi1G63K1Vi7bJ14rkJY_dk0S6b0kTI6vPfY","Message-ID":"\n <CAMRc=MfUh_OuxS4SC6QzSOg_PMNc9i9crGYgBASrbVUgHDHSCw@mail.gmail.com>","Subject":"Re: [PATCH v2 3/4] gpio: realtek: Add driver for Realtek DHC RTD1625\n SoC","To":"Yu-Chun Lin <eleanor.lin@realtek.com>","Cc":"linux-gpio@vger.kernel.org, devicetree@vger.kernel.org,\n\tlinux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org,\n\tlinux-realtek-soc@lists.infradead.org, cy.huang@realtek.com,\n\tstanley_chang@realtek.com, james.tai@realtek.com, linusw@kernel.org,\n\tbrgl@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org,\n\tafaerber@suse.com, tychang@realtek.com","Content-Type":"text/plain; charset=\"UTF-8\""}},{"id":3675761,"web_url":"http://patchwork.ozlabs.org/comment/3675761/","msgid":"<52bf9ce2b7754af8af69b0afee0d07b2@realtek.com>","list_archive_url":null,"date":"2026-04-10T09:39:51","subject":"RE: [PATCH v2 3/4] gpio: realtek: Add driver for Realtek DHC RTD1625\n SoC","submitter":{"id":92797,"url":"http://patchwork.ozlabs.org/api/people/92797/","name":"Yu-Chun Lin [林祐君]","email":"eleanor.lin@realtek.com"},"content":"Hi Bart,\n\n> On Wed, 8 Apr 2026 04:52:42 +0200, Yu-Chun Lin <eleanor.lin@realtek.com>\n> said:\n> > From: Tzuyi Chang <tychang@realtek.com>\n> >\n> > Add support for the GPIO controller found on Realtek DHC RTD1625 SoCs.\n> >\n> > Unlike the existing Realtek GPIO driver (drivers/gpio/gpio-rtd.c),\n> > which manages pins via shared bank registers, the RTD1625 introduces a\n> > per-pin register architecture. Each GPIO line now has its own\n> > dedicated 32-bit control register to manage configuration\n> > independently, including direction, output value, input value,\n> > interrupt enable, and debounce. Therefore, this distinct hardware\n> > design requires a separate driver.\n> >\n> > Reviewed-by: Linus Walleij <linusw@kernel.org>\n> > Signed-off-by: Tzuyi Chang <tychang@realtek.com>\n> > Signed-off-by: Yu-Chun Lin <eleanor.lin@realtek.com>\n> > ---\n> > Changes in v2:\n> > - Remove \"default y\".\n> > - Add base_offset member to struct rtd1625_gpio_info to handle merged\n> regions.\n> > ---\n> >  drivers/gpio/Kconfig        |  11 +\n> >  drivers/gpio/Makefile       |   1 +\n> >  drivers/gpio/gpio-rtd1625.c | 584\n> > ++++++++++++++++++++++++++++++++++++\n> >  3 files changed, 596 insertions(+)\n> >  create mode 100644 drivers/gpio/gpio-rtd1625.c\n> >\n> > diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index\n> > 5ee11a889867..281549ad72ac 100644\n> > --- a/drivers/gpio/Kconfig\n> > +++ b/drivers/gpio/Kconfig\n> > @@ -638,6 +638,17 @@ config GPIO_RTD\n> >         Say yes here to support GPIO functionality and GPIO interrupt on\n> >         Realtek DHC SoCs.\n> >\n> > +config GPIO_RTD1625\n> > +     tristate \"Realtek DHC RTD1625 GPIO support\"\n> > +     depends on ARCH_REALTEK || COMPILE_TEST\n> > +     select GPIOLIB_IRQCHIP\n> > +     help\n> > +       This option enables support for the GPIO controller on Realtek\n> > +       DHC (Digital Home Center) RTD1625 SoC.\n> > +\n> > +       Say yes here to support both basic GPIO line functionality\n> > +       and GPIO interrupt handling capabilities for this platform.\n> > +\n> >  config GPIO_SAMA5D2_PIOBU\n> >       tristate \"SAMA5D2 PIOBU GPIO support\"\n> >       depends on MFD_SYSCON\n> > diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index\n> > c05f7d795c43..c95ba218d53a 100644\n> > --- a/drivers/gpio/Makefile\n> > +++ b/drivers/gpio/Makefile\n> > @@ -159,6 +159,7 @@ obj-$(CONFIG_GPIO_REALTEK_OTTO)\n> += gpio-realtek-otto.o\n> >  obj-$(CONFIG_GPIO_REG)                       += gpio-reg.o\n> >  obj-$(CONFIG_GPIO_ROCKCHIP)  += gpio-rockchip.o\n> >  obj-$(CONFIG_GPIO_RTD)                       += gpio-rtd.o\n> > +obj-$(CONFIG_GPIO_RTD1625)           += gpio-rtd1625.o\n> >  obj-$(CONFIG_ARCH_SA1100)            += gpio-sa1100.o\n> >  obj-$(CONFIG_GPIO_SAMA5D2_PIOBU)     += gpio-sama5d2-piobu.o\n> >  obj-$(CONFIG_GPIO_SCH311X)           += gpio-sch311x.o\n> > diff --git a/drivers/gpio/gpio-rtd1625.c b/drivers/gpio/gpio-rtd1625.c\n> > new file mode 100644 index 000000000000..bcc1bbb115fa\n> > --- /dev/null\n> > +++ b/drivers/gpio/gpio-rtd1625.c\n> > @@ -0,0 +1,584 @@\n> > +// SPDX-License-Identifier: GPL-2.0-or-later\n> > +/*\n> > + * Realtek DHC RTD1625 gpio driver\n> > + *\n> > + * Copyright (c) 2023 Realtek Semiconductor Corp.\n> \n> No modifications since 2023?\n> \n\nWill include 2026.\n\n> > + */\n> > +\n> > +#include <linux/bitfield.h>\n> > +#include <linux/bitops.h>\n> > +#include <linux/gpio/driver.h>\n> > +#include <linux/interrupt.h>\n> > +#include <linux/irqchip.h>\n> > +#include <linux/irqchip/chained_irq.h> #include <linux/irqdomain.h>\n> > +#include <linux/module.h> #include <linux/platform_device.h> #include\n> > +<linux/property.h> #include <linux/spinlock.h> #include\n> > +<linux/types.h>\n> > +\n> > +#define RTD1625_GPIO_DIR BIT(0)\n> > +#define RTD1625_GPIO_OUT BIT(2)\n> > +#define RTD1625_GPIO_IN BIT(4)\n> > +#define RTD1625_GPIO_EDGE_INT_DP BIT(6) #define\n> > +RTD1625_GPIO_EDGE_INT_EN BIT(8) #define\n> RTD1625_GPIO_LEVEL_INT_EN\n> > +BIT(16) #define RTD1625_GPIO_LEVEL_INT_DP BIT(18) #define\n> > +RTD1625_GPIO_DEBOUNCE GENMASK(30, 28) #define\n> > +RTD1625_GPIO_DEBOUNCE_WREN BIT(31)\n> > +\n> > +#define RTD1625_GPIO_WREN(x) ((x) << 1)\n> > +\n> > +/* Write-enable masks for all GPIO configs and reserved hardware bits\n> > +*/ #define RTD1625_ISO_GPIO_WREN_ALL 0x8000aa8a #define\n> > +RTD1625_ISOM_GPIO_WREN_ALL 0x800aaa8a\n> > +\n> > +#define RTD1625_GPIO_DEBOUNCE_1US 0\n> > +#define RTD1625_GPIO_DEBOUNCE_10US 1\n> > +#define RTD1625_GPIO_DEBOUNCE_100US 2 #define\n> > +RTD1625_GPIO_DEBOUNCE_1MS 3 #define\n> RTD1625_GPIO_DEBOUNCE_10MS 4\n> > +#define RTD1625_GPIO_DEBOUNCE_20MS 5 #define\n> > +RTD1625_GPIO_DEBOUNCE_30MS 6 #define\n> RTD1625_GPIO_DEBOUNCE_50MS 7\n> > +\n> > +#define GPIO_CONTROL(gpio) ((gpio) * 4)\n> > +\n> > +/**\n> > + * struct rtd1625_gpio_info - Specific GPIO register information\n> > + * @num_gpios: The number of GPIOs\n> > + * @irq_type_support: Supported IRQ types\n> > + * @gpa_offset: Offset for GPIO assert interrupt status registers\n> > + * @gpda_offset: Offset for GPIO deassert interrupt status registers\n> > + * @level_offset: Offset of level interrupt status register\n> > + * @write_en_all: Write-enable mask for all configurable bits  */\n> > +struct rtd1625_gpio_info {\n> > +     unsigned int    num_gpios;\n> > +     unsigned int    irq_type_support;\n> > +     unsigned int    base_offset;\n> > +     unsigned int    gpa_offset;\n> > +     unsigned int    gpda_offset;\n> > +     unsigned int    level_offset;\n> > +     unsigned int    write_en_all;\n> > +};\n> \n> Please remove the tabs in the above struct.\n> \n\nAck.\n\n> > +\n> > +struct rtd1625_gpio {\n> > +     struct gpio_chip                gpio_chip;\n> > +     const struct rtd1625_gpio_info  *info;\n> > +     void __iomem                    *base;\n> > +     void __iomem                    *irq_base;\n> > +     unsigned int                    irqs[3];\n> > +     raw_spinlock_t                  lock;\n> > +     unsigned int                    *save_regs;\n> > +};\n> \n> I'd also personally remove these tabs here but won't die on that hill.\n> \n\nAck.\n\n> > +\n> > +static unsigned int rtd1625_gpio_gpa_offset(struct rtd1625_gpio\n> > +*data, unsigned int offset) {\n> > +     return data->info->gpa_offset + ((offset / 32) * 4); }\n> > +\n> > +static unsigned int rtd1625_gpio_gpda_offset(struct rtd1625_gpio\n> > +*data, unsigned int offset) {\n> > +     return data->info->gpda_offset + ((offset / 32) * 4); }\n> > +\n> > +static unsigned int rtd1625_gpio_level_offset(struct rtd1625_gpio\n> > +*data, unsigned int offset) {\n> > +     return data->info->level_offset + ((offset / 32) * 4); }\n> \n> Looking at these, I'm under the impression that this driver could quite easily be\n> converted to using gpio-mmio or even gpio-regmap with an MMIO regmap,\n> have you looked into it by any chance?\n> \n> Bart\n\n\nWe did look into gpio-mmio and gpio-regmap, but they are not quite suitable for\nour platform due to the specific hardware design:\n\n1. Per-GPIO Dedicated Registers: Unlike typical GPIO controllers that pack 32 pins\ninto a single 32-bit register (1 bit per pin), our hardware uses a dedicated 32-bit\nregister for each individual GPIO. This single register controls the\ninput/output state, direction, and interrupt trigger type for that specific pin.\n\n2. Write-Enable (WREN) Mask Mechanism: Our hardware requires a specific Write-Enable\nmask to be written simultaneously when updating the register values.\n\n3. Hardware Debounce: We also need to support hardware debounce settings per pin,\nwhich requires custom configuration via set_config mapped to these specific per-pin\nregisters.\n\nBecause of these hardware constraints, manually implementing the gpio_chip callbacks\nseems to be the most straightforward\n\nBest Regards,\nYu-Chun","headers":{"Return-Path":"\n <linux-gpio+bounces-34992-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-gpio@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=realtek.com header.i=@realtek.com header.a=rsa-sha256\n header.s=dkim header.b=MaHrQpcP;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c04:e001:36c::12fc:5321; helo=tor.lore.kernel.org;\n envelope-from=linux-gpio+bounces-34992-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=realtek.com header.i=@realtek.com\n header.b=\"MaHrQpcP\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=211.75.126.72","smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=realtek.com","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=realtek.com"],"Received":["from tor.lore.kernel.org (tor.lore.kernel.org\n [IPv6:2600:3c04:e001:36c::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fsX8z6vSDz1yGb\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 10 Apr 2026 19:50:11 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby tor.lore.kernel.org (Postfix) with ESMTP id F32DD3060A05\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 10 Apr 2026 09:42:31 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id C003C33D6DD;\n\tFri, 10 Apr 2026 09:42:30 +0000 (UTC)","from rtits2.realtek.com.tw (rtits2.realtek.com [211.75.126.72])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 7ED1B329365;\n\tFri, 10 Apr 2026 09:42:28 +0000 (UTC)","from mail.realtek.com (rtkexhmbs03.realtek.com.tw[10.21.1.53])\n\tby rtits2.realtek.com.tw (8.15.2/3.26/5.94) with ESMTPS id 63A9dpN832780663\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK);\n\tFri, 10 Apr 2026 17:39:51 +0800","from RTKEXHMBS06.realtek.com.tw (10.21.1.56) by\n RTKEXHMBS03.realtek.com.tw (10.21.1.53) with Microsoft SMTP Server\n (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id\n 15.2.1748.10; Fri, 10 Apr 2026 17:39:51 +0800","from RTKEXHMBS06.realtek.com.tw ([fe80::ed72:3015:2840:4458]) by\n RTKEXHMBS06.realtek.com.tw ([fe80::ed72:3015:2840:4458%10]) with mapi id\n 15.02.1748.010; Fri, 10 Apr 2026 17:39:51 +0800"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1775814150; cv=none;\n b=skU/1Mvaw73Vmj/T6YXYwZVkXDM6ATNDdzeTgwJvejLa1NQZVrJne65KQgieDpbtCuVpcRzJEcO02xKDJYDGwEQxcTd8phDr05nT4r65Ugn6prLZnwo308r2Sbq7SPE19Ne6wOMtxqO1naxXkbnr0L6sIa5VoaqT55mPSGwRM+w=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1775814150; c=relaxed/simple;\n\tbh=7gzBtVJjeD1hDezHdgdhXKaFhiBwbSLacPSztQDBiTs=;\n\th=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To:\n\t Content-Type:MIME-Version;\n b=SJfc1yJsLQ5DwcZbQFDZcbFtvyYwpNDOgoZlFUisAaVM2wspSxEL5LHb279S9baWQxQ7ymmL0vL9/V4V4ys8RScD0vehYWLVlL4H7/+lBbrdwVUospovraMEC1qEIdbgnurq/qlmaPteLx9BSgdsNUCEkwlw1n6oU1SM9mBpxRI=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=realtek.com;\n spf=pass smtp.mailfrom=realtek.com;\n dkim=pass (2048-bit key) header.d=realtek.com header.i=@realtek.com\n header.b=MaHrQpcP; arc=none smtp.client-ip=211.75.126.72","X-SpamFilter-By":"ArmorX SpamTrap 5.80 with qID 63A9dpN832780663,\n This message is accepted by code: ctloc85258","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=realtek.com; s=dkim;\n\tt=1775813991; bh=7gzBtVJjeD1hDezHdgdhXKaFhiBwbSLacPSztQDBiTs=;\n\th=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To:\n\t Content-Type:Content-Transfer-Encoding:MIME-Version;\n\tb=MaHrQpcP7R0Dxglo5Ptn/aRDyF7TRXA1F/jpgaVvs2UeWGlTRsnUJUoQPmsrgC1qV\n\t iHMYJwAssYGZtlaWYwBK1aEh+IyCsD6SMibsF7jRcGqj38GbUbfVvj8qpgRKiaAPTq\n\t ZBpcRM+DoCBy/M6p1Fd4kmDj2/MaSHziTQ4MOoJCdcw++qQq7c+YPA9eySvdr1i/z3\n\t QyQdofinuRLqjF+olKKmmtHrBOfFOBtc1nwcA3IcAuOQy1uWQHrexGBvAVGbWMqJ6s\n\t BIiA9n1OiDqBuMdnrH/dKt47BD3c2vdXOggFWpyMX2YlnDU9djnne9Xml+xDsw1ZQn\n\t hsb9XmubPgrJg==","From":"=?utf-8?b?WXUtQ2h1biBMaW4gW+ael+elkOWQm10=?= <eleanor.lin@realtek.com>","To":"Bartosz Golaszewski <brgl@kernel.org>","CC":"\"linux-gpio@vger.kernel.org\" <linux-gpio@vger.kernel.org>,\n \"devicetree@vger.kernel.org\" <devicetree@vger.kernel.org>,\n \"linux-kernel@vger.kernel.org\" <linux-kernel@vger.kernel.org>,\n \"linux-arm-kernel@lists.infradead.org\"\n <linux-arm-kernel@lists.infradead.org>,\n \"linux-realtek-soc@lists.infradead.org\"\n <linux-realtek-soc@lists.infradead.org>, =?utf-8?b?Q1lfSHVhbmdb6buD6Ymm5pmP?=\n\t=?utf-8?b?XQ==?= <cy.huang@realtek.com>, =?utf-8?b?U3RhbmxleSBDaGFuZ1vmmIw=?=\n\t=?utf-8?b?6IKy5b63XQ==?= <stanley_chang@realtek.com>, =?utf-8?b?SmFtZXMg?=\n\t=?utf-8?b?VGFpIFvmiLTlv5fls7Bd?= <james.tai@realtek.com>,\n \"linusw@kernel.org\" <linusw@kernel.org>, \"robh@kernel.org\" <robh@kernel.org>,\n \"krzk+dt@kernel.org\" <krzk+dt@kernel.org>,\n \"conor+dt@kernel.org\" <conor+dt@kernel.org>,\n \"afaerber@suse.com\" <afaerber@suse.com>, =?utf-8?b?VFlfQ2hhbmdb5by15a2Q6YC4?=\n\t=?utf-8?b?XQ==?= <tychang@realtek.com>","Subject":"RE: [PATCH v2 3/4] gpio: realtek: Add driver for Realtek DHC RTD1625\n SoC","Thread-Topic":"[PATCH v2 3/4] gpio: realtek: Add driver for Realtek DHC RTD1625\n SoC","Thread-Index":"AQHcxwLHJ5/eWVH9pU2ZY37QYpQGurXUP0uAgAPMV8A=","Date":"Fri, 10 Apr 2026 09:39:51 +0000","Message-ID":"<52bf9ce2b7754af8af69b0afee0d07b2@realtek.com>","References":"<20260408025243.1155482-1-eleanor.lin@realtek.com>\n <20260408025243.1155482-4-eleanor.lin@realtek.com>\n <CAMRc=MfUh_OuxS4SC6QzSOg_PMNc9i9crGYgBASrbVUgHDHSCw@mail.gmail.com>","In-Reply-To":"\n <CAMRc=MfUh_OuxS4SC6QzSOg_PMNc9i9crGYgBASrbVUgHDHSCw@mail.gmail.com>","Accept-Language":"zh-TW, en-US","Content-Language":"zh-TW","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Precedence":"bulk","X-Mailing-List":"linux-gpio@vger.kernel.org","List-Id":"<linux-gpio.vger.kernel.org>","List-Subscribe":"<mailto:linux-gpio+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-gpio+unsubscribe@vger.kernel.org>","MIME-Version":"1.0"}},{"id":3679142,"web_url":"http://patchwork.ozlabs.org/comment/3679142/","msgid":"<CAD++jLkpS-T9yK=ctSwpLvXkj7s7ivmwu1KKwzy4KS40LVYeyA@mail.gmail.com>","list_archive_url":null,"date":"2026-04-19T21:19:40","subject":"Re: [PATCH v2 3/4] gpio: realtek: Add driver for Realtek DHC RTD1625\n SoC","submitter":{"id":92050,"url":"http://patchwork.ozlabs.org/api/people/92050/","name":"Linus Walleij","email":"linusw@kernel.org"},"content":"Hi Yu-Chun,\n\nOn Fri, Apr 10, 2026 at 11:39 AM Yu-Chun Lin [林祐君]\n<eleanor.lin@realtek.com> wrote:\n\n> We did look into gpio-mmio and gpio-regmap, but they are not quite suitable for\n> our platform due to the specific hardware design:\n>\n> 1. Per-GPIO Dedicated Registers: Unlike typical GPIO controllers that pack 32 pins\n> into a single 32-bit register (1 bit per pin), our hardware uses a dedicated 32-bit\n> register for each individual GPIO. This single register controls the\n> input/output state, direction, and interrupt trigger type for that specific pin.\n\nIsn't that attainable by:\n\n- setting .ngpio_per_reg to 1 in struct gpio_regmap_config\n\n- extend .reg_mask_xlate callback with an enum for each operation\n  (need to change all users of the .reg_mask_xlate callback but\n  who cares, they are not many):\n\ne.g.\n\nenum gpio_regmap_operation {\n    GPIO_REGMAP_GET_OP,\n    GPIO_REGMAP_SET_OP,\n    GPIO_REGMAP_SET_WITH_CLEAR_OP,\n    GPIO_REGMAP_GET_DIR_OP,\n    GPIO_REGMAP_SET_DIR_OP,\n};\n\n int (*reg_mask_xlate)(struct gpio_regmap *gpio,\n                              enum_gpio_regmap_operation op,\n                              unsigned int base,\n                              unsigned int offset, unsigned int *reg,\n                              unsigned int *mask);\n\nThis way .reg_mask_xlate() can hit different bits in the returned\n*mask depending on operation and it will be find to pack all of\nthe bits into one 32bit register.\n\nAdded Michael Walle to the the thread, he will know if this is a\ngood idea.\n\n> 2. Write-Enable (WREN) Mask Mechanism: Our hardware requires a specific Write-Enable\n> mask to be written simultaneously when updating the register values.\n\nWhich is to just set bit 31.\n\nWith the above scheme your .reg_mask_xlate callback can just set bit 31\nno matter what operating you're doing. Piece of cake.\n\n> 3. Hardware Debounce: We also need to support hardware debounce settings per pin,\n> which requires custom configuration via set_config mapped to these specific per-pin\n> registers.\n\nJust add a version of an optional .set_config() call to gpio-regmap.c\nto handle this using .reg_mask_xlate() per above and add a new\nGPIO_REGMAP_CONFIG_OP to the above enum, problem solved.\n\nIf it seems too hard I can write patch 1 & 2 adding this infrastructure\nbut I bet you can easily see what can be done with gpio-regmap.c\nhere provided Michael W approves the idea.\n\nYours,\nLinus Walleij","headers":{"Return-Path":"\n <linux-gpio+bounces-35237-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-gpio@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=EBLgetj9;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=172.234.253.10; helo=sea.lore.kernel.org;\n envelope-from=linux-gpio+bounces-35237-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=\"EBLgetj9\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=10.30.226.201"],"Received":["from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fzM2m1cXjz1yHB\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 20 Apr 2026 07:20:00 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id 5CEAA3019F15\n\tfor <incoming@patchwork.ozlabs.org>; Sun, 19 Apr 2026 21:19:55 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 317D92F39C2;\n\tSun, 19 Apr 2026 21:19:54 +0000 (UTC)","from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org\n [10.30.226.201])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id E7CE326E706\n\tfor <linux-gpio@vger.kernel.org>; Sun, 19 Apr 2026 21:19:53 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id A10EAC2BCC7\n\tfor <linux-gpio@vger.kernel.org>; Sun, 19 Apr 2026 21:19:53 +0000 (UTC)","by mail-lf1-f53.google.com with SMTP id\n 2adb3069b0e04-5a0ff30b240so3438932e87.0\n        for <linux-gpio@vger.kernel.org>;\n Sun, 19 Apr 2026 14:19:53 -0700 (PDT)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1776633594; cv=none;\n b=caShGJrsxTMZQL563AwYMPnMbDFoQ0Yni44gVnmX80cMKZQoS3CxPJEfqJ2QRK8RNFjB5Z9jmioNESEmkJzx06Gxv/SEtG7B57DXhjHytpGrrEkcjfm+81bfr2Dm3w0pHLav3ZEfq6yraMMg1UVq5KPX6M/nVGLF9c6emYOWzFg=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1776633594; c=relaxed/simple;\n\tbh=z9YbvWBNcBN/kiRFkQ6KPbSsQhW/tBBXUVGnpF4Bmp8=;\n\th=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject:\n\t To:Cc:Content-Type;\n b=j+vqfwihCA14In0Zedb4xKaGHC4TRZObesRAFvLFizoEwA7Bo2Fm4QBgidVfLso/QjJ0uQW57/cqIuVpuwQTSGcyCuFqrufEC7I52ivDDNenqYrflAvaGTdGpYJ1T3YFZ7CI2haDKzUhfhZOR8W0muK9WUXeiZ/YY6W/3YGt5VQ=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=EBLgetj9; arc=none smtp.client-ip=10.30.226.201","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;\n\ts=k20201202; t=1776633593;\n\tbh=z9YbvWBNcBN/kiRFkQ6KPbSsQhW/tBBXUVGnpF4Bmp8=;\n\th=References:In-Reply-To:From:Date:Subject:To:Cc:From;\n\tb=EBLgetj9NxEaAOYhlFeKYGK4lGLnbVmRASOWvmVhBRsyIPQhrMOwZ5KWaLROJdv5k\n\t MA8IG8AJWcIYLALvFc1iS6yV97tskuiGJD0BHr5wfBXSziCGItvYeGoMsFJ2WNm+nm\n\t moZklfet4zaMrHYF4XNT5uAQ6NKOfB/Va66TkwYqHAg8ExLX8sKH3Iz3RNAoNLrVFq\n\t lmfAsD4BLMVHgBnx49J5/Q3pP6N2z1j+f1Oy9sW4hQHtv/c9mJManCMx2URT7Gudo9\n\t YTdM3+LSbdnp2+xEpZJU9eJ3qQL23cOoPulh2d5cxsWThnqO/EF39rnL47ZaZ9J5bp\n\t afbCo17nvO0Zw==","X-Forwarded-Encrypted":"i=1;\n AFNElJ+fM47VFeZEY3RO+QH0eXH2GRdVAHlmwtFBo91wM4Kypi3K39Zb8ZpTGx0YlKYaCIjWe5pi1BBhYNik@vger.kernel.org","X-Gm-Message-State":"AOJu0YzUc4ugvkC1ZG31nP5oILfd58qmxnblNyh86hYP1lIrcglNwo7f\n\tjrgfdsnTvgX3gTOkjwggermsBbHbjyZYt8oG6isBMzQzKzY4+KSKe4HKbzynAeG0ArLQ0f6KznZ\n\tiOFx0FEIvL35NuC3UoVoBPfeKwKPLWJw=","X-Received":"by 2002:a05:6512:ad1:b0:5a3:ff5a:d6c with SMTP id\n 2adb3069b0e04-5a4172c756amr3690813e87.14.1776633592265; Sun, 19 Apr 2026\n 14:19:52 -0700 (PDT)","Precedence":"bulk","X-Mailing-List":"linux-gpio@vger.kernel.org","List-Id":"<linux-gpio.vger.kernel.org>","List-Subscribe":"<mailto:linux-gpio+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-gpio+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","References":"<20260408025243.1155482-1-eleanor.lin@realtek.com>\n <20260408025243.1155482-4-eleanor.lin@realtek.com>\n <CAMRc=MfUh_OuxS4SC6QzSOg_PMNc9i9crGYgBASrbVUgHDHSCw@mail.gmail.com>\n <52bf9ce2b7754af8af69b0afee0d07b2@realtek.com>","In-Reply-To":"<52bf9ce2b7754af8af69b0afee0d07b2@realtek.com>","From":"Linus Walleij <linusw@kernel.org>","Date":"Sun, 19 Apr 2026 23:19:40 +0200","X-Gmail-Original-Message-ID":"\n <CAD++jLkpS-T9yK=ctSwpLvXkj7s7ivmwu1KKwzy4KS40LVYeyA@mail.gmail.com>","X-Gm-Features":"AQROBzAE2Y02h6LgmsVRXzFjBD7tYm8hngF_phTFw6dYL2PfXyxOmjtiC-kfPNE","Message-ID":"\n <CAD++jLkpS-T9yK=ctSwpLvXkj7s7ivmwu1KKwzy4KS40LVYeyA@mail.gmail.com>","Subject":"Re: [PATCH v2 3/4] gpio: realtek: Add driver for Realtek DHC RTD1625\n SoC","To":"=?utf-8?b?WXUtQ2h1biBMaW4gW+ael+elkOWQm10=?= <eleanor.lin@realtek.com>,\n  Michael Walle <mwalle@kernel.org>","Cc":"Bartosz Golaszewski <brgl@kernel.org>,\n  \"linux-gpio@vger.kernel.org\" <linux-gpio@vger.kernel.org>,\n  \"devicetree@vger.kernel.org\" <devicetree@vger.kernel.org>,\n  \"linux-kernel@vger.kernel.org\" <linux-kernel@vger.kernel.org>,\n  \"linux-arm-kernel@lists.infradead.org\"\n <linux-arm-kernel@lists.infradead.org>,\n  \"linux-realtek-soc@lists.infradead.org\"\n <linux-realtek-soc@lists.infradead.org>, =?utf-8?b?Q1lfSHVhbmdb6buD6Ymm5pmP?=\n\t=?utf-8?b?XQ==?= <cy.huang@realtek.com>, =?utf-8?b?U3RhbmxleSBDaGFuZ1vmmIw=?=\n\t=?utf-8?b?6IKy5b63XQ==?= <stanley_chang@realtek.com>, =?utf-8?b?SmFtZXMg?=\n\t=?utf-8?b?VGFpIFvmiLTlv5fls7Bd?= <james.tai@realtek.com>,\n  \"robh@kernel.org\" <robh@kernel.org>,\n \"krzk+dt@kernel.org\" <krzk+dt@kernel.org>,\n  \"conor+dt@kernel.org\" <conor+dt@kernel.org>,\n \"afaerber@suse.com\" <afaerber@suse.com>, =?utf-8?b?VFlfQ2hhbmdb5by15a2Q6YC4?=\n\t=?utf-8?b?XQ==?= <tychang@realtek.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Content-Transfer-Encoding":"quoted-printable"}},{"id":3679261,"web_url":"http://patchwork.ozlabs.org/comment/3679261/","msgid":"<DHXSUW3NJU22.1RUYUHQZSZ53S@kernel.org>","list_archive_url":null,"date":"2026-04-20T07:22:13","subject":"Re: [PATCH v2 3/4] gpio: realtek: Add driver for Realtek DHC\n RTD1625 SoC","submitter":{"id":86646,"url":"http://patchwork.ozlabs.org/api/people/86646/","name":"Michael Walle","email":"mwalle@kernel.org"},"content":"Hi,\n\nOn Sun Apr 19, 2026 at 11:19 PM CEST, Linus Walleij wrote:\n> Hi Yu-Chun,\n>\n> On Fri, Apr 10, 2026 at 11:39 AM Yu-Chun Lin [林祐君]\n> <eleanor.lin@realtek.com> wrote:\n>\n>> We did look into gpio-mmio and gpio-regmap, but they are not quite suitable for\n>> our platform due to the specific hardware design:\n>>\n>> 1. Per-GPIO Dedicated Registers: Unlike typical GPIO controllers that pack 32 pins\n>> into a single 32-bit register (1 bit per pin), our hardware uses a dedicated 32-bit\n>> register for each individual GPIO. This single register controls the\n>> input/output state, direction, and interrupt trigger type for that specific pin.\n>\n> Isn't that attainable by:\n>\n> - setting .ngpio_per_reg to 1 in struct gpio_regmap_config\n\nWhich is just used by the gpio_regmap_simple_xlate() anyway. So it\ndoesn't really matter. But yeah, 1 would be the correct value here,\nassuming that the registers are consecutive.\n\n> - extend .reg_mask_xlate callback with an enum for each operation\n>   (need to change all users of the .reg_mask_xlate callback but\n>   who cares, they are not many):\n>\n> e.g.\n>\n> enum gpio_regmap_operation {\n>     GPIO_REGMAP_GET_OP,\n>     GPIO_REGMAP_SET_OP,\n>     GPIO_REGMAP_SET_WITH_CLEAR_OP,\n>     GPIO_REGMAP_GET_DIR_OP,\n>     GPIO_REGMAP_SET_DIR_OP,\n> };\n>\n>  int (*reg_mask_xlate)(struct gpio_regmap *gpio,\n>                               enum_gpio_regmap_operation op,\n>                               unsigned int base,\n>                               unsigned int offset, unsigned int *reg,\n>                               unsigned int *mask);\n>\n> This way .reg_mask_xlate() can hit different bits in the returned\n> *mask depending on operation and it will be find to pack all of\n> the bits into one 32bit register.\n>\n> Added Michael Walle to the the thread, he will know if this is a\n> good idea.\n\nNice idea, though the information is then redundant in the usual\ncase, i.e. drivers which need to translate specific registers\nwill do a \"switch (base)\" at the moment. These should be converted\nto \"switch (op)\" just to keep all the drivers aligned and prevent\nnew drivers from using the old method. You'd need to touch them\nanyway.\n\nI was briefly thinking about making it somewhat possible to embed\nthe op into the base, if it would otherwise be all the same. That\nway, you could gpio-regmap as is. A special case like\nGPIO_REGMAP_ADDR_ZERO, that could be used by these kind of drivers,\nbut that is probably too hacky.\n\nI'm fine with either way.\n\n>> 2. Write-Enable (WREN) Mask Mechanism: Our hardware requires a specific Write-Enable\n>> mask to be written simultaneously when updating the register values.\n>\n> Which is to just set bit 31.\n>\n> With the above scheme your .reg_mask_xlate callback can just set bit 31\n> no matter what operating you're doing. Piece of cake.\n\nKeep in mind, that this will make reading and writing somewhat\ndifferent. reading assumes there is only one bit set in mask,\nbecause of the \"!!(val & mask)\" op, which is hardcoded. I'm not\nagainst using the write like that though.\n\n-michael\n\n>> 3. Hardware Debounce: We also need to support hardware debounce settings per pin,\n>> which requires custom configuration via set_config mapped to these specific per-pin\n>> registers.\n>\n> Just add a version of an optional .set_config() call to gpio-regmap.c\n> to handle this using .reg_mask_xlate() per above and add a new\n> GPIO_REGMAP_CONFIG_OP to the above enum, problem solved.\n>\n> If it seems too hard I can write patch 1 & 2 adding this infrastructure\n> but I bet you can easily see what can be done with gpio-regmap.c\n> here provided Michael W approves the idea.\n>\n> Yours,\n> Linus Walleij","headers":{"Return-Path":"\n <linux-gpio+bounces-35240-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-gpio@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=IMey3crY;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c04:e001:36c::12fc:5321; helo=tor.lore.kernel.org;\n envelope-from=linux-gpio+bounces-35240-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=\"IMey3crY\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=10.30.226.201"],"Received":["from tor.lore.kernel.org (tor.lore.kernel.org\n [IPv6:2600:3c04:e001:36c::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fzcQN0tZ5z1yD4\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 20 Apr 2026 17:22:52 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby tor.lore.kernel.org (Postfix) with ESMTP id 64608301DDB5\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 20 Apr 2026 07:22:19 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 4546B383C99;\n\tMon, 20 Apr 2026 07:22:18 +0000 (UTC)","from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org\n [10.30.226.201])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 04E4E2FD7D3;\n\tMon, 20 Apr 2026 07:22:18 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id 805D0C19425;\n\tMon, 20 Apr 2026 07:22:17 +0000 (UTC)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1776669738; cv=none;\n b=i/+DI5VRI3Krd7Neoxh9NQVhqAe7coZiWqIfEw0J97BU674xsrYJtlJDyuMZ9qtObf1tCXlrA0UkaOyg+4pNf5wW5b6wtOrFszaghVQNxfFZBLxwHMhEWuMvDfc7sVALNG4PfxmJzMzNVLit2JLB0u1zuORJUIGmmBldzx8Ts2s=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1776669738; c=relaxed/simple;\n\tbh=OfvTvpLPvCOhEfrZP20Fdwx6Oml0HCemcKq7lCtxkyE=;\n\th=Mime-Version:Content-Type:Date:Message-Id:Subject:Cc:From:To:\n\t References:In-Reply-To;\n b=CtGcEA20VRHAtCreG3inKFfe8ttb/FAuHDL6pxnOAUD46h2Shk8GSVrksL2yV3QDzj3lon0mixPk5btKcShzaI1THTyGhoseaywMPfMbjiL2pcNDSOUwfBSYL7LfhKFrWU2/8rZrBaAvIc8ijLjs1b+buyPJunHQoWIvm7ErfWw=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=IMey3crY; arc=none smtp.client-ip=10.30.226.201","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;\n\ts=k20201202; t=1776669737;\n\tbh=OfvTvpLPvCOhEfrZP20Fdwx6Oml0HCemcKq7lCtxkyE=;\n\th=Date:Subject:Cc:From:To:References:In-Reply-To:From;\n\tb=IMey3crYn7faai6rgUGWKlY+8hRpsd9v7aeDXyOpQyfZoHGJbsfz6R50DB40aPfGA\n\t scmZDevIY5KrT+Xtm5F1Q5W7GkcKH3TlcudlihDzXyEZfC4uJ+ID9uoHTpOITXJddl\n\t kPx9P7oi2FNemZrjdUBG2macvC/BHf5ra7cx++oyuddBTo2iO556nLVT08mYazZN8b\n\t kq8Y2FBt/k3RZKnO/cCH2ywt+sead2cswjBkqqCIbMaGQuWEMezh9nYE6zLs2AS0ig\n\t MkwDgIBIrtcF0tjJEpppzUi+REL0BbYUsRRA2xXYQ+DadjTO2xLi/VT7fa+E54lIGL\n\t OczJRz0NsD0+Q==","Precedence":"bulk","X-Mailing-List":"linux-gpio@vger.kernel.org","List-Id":"<linux-gpio.vger.kernel.org>","List-Subscribe":"<mailto:linux-gpio+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-gpio+unsubscribe@vger.kernel.org>","Mime-Version":"1.0","Content-Type":"multipart/signed;\n boundary=90b98803b27b5277d55f5c028db99ddc444d61087c0fc38a687673f1b0fc;\n micalg=pgp-sha384; protocol=\"application/pgp-signature\"","Date":"Mon, 20 Apr 2026 09:22:13 +0200","Message-Id":"<DHXSUW3NJU22.1RUYUHQZSZ53S@kernel.org>","Subject":"Re: [PATCH v2 3/4] gpio: realtek: Add driver for Realtek DHC\n RTD1625 SoC","Cc":"\"Bartosz Golaszewski\" <brgl@kernel.org>,\n \"linux-gpio@vger.kernel.org\" <linux-gpio@vger.kernel.org>,\n \"devicetree@vger.kernel.org\" <devicetree@vger.kernel.org>,\n \"linux-kernel@vger.kernel.org\" <linux-kernel@vger.kernel.org>,\n \"linux-arm-kernel@lists.infradead.org\"\n <linux-arm-kernel@lists.infradead.org>,\n \"linux-realtek-soc@lists.infradead.org\"\n <linux-realtek-soc@lists.infradead.org>, =?utf-8?b?Q1lfSHVhbmdb6buD6Ymm5pmP?=\n\t=?utf-8?b?XQ==?= <cy.huang@realtek.com>, =?utf-8?b?U3RhbmxleSBDaGFuZ1vmmIw=?=\n\t=?utf-8?b?6IKy5b63XQ==?= <stanley_chang@realtek.com>, =?utf-8?b?SmFtZXMg?=\n\t=?utf-8?b?VGFpIFvmiLTlv5fls7Bd?= <james.tai@realtek.com>,\n \"robh@kernel.org\" <robh@kernel.org>,\n \"krzk+dt@kernel.org\" <krzk+dt@kernel.org>,\n \"conor+dt@kernel.org\" <conor+dt@kernel.org>,\n \"afaerber@suse.com\" <afaerber@suse.com>, =?utf-8?b?VFlfQ2hhbmdb5by15a2Q6YC4?=\n\t=?utf-8?b?XQ==?= <tychang@realtek.com>","From":"\"Michael Walle\" <mwalle@kernel.org>","To":"\"Linus Walleij\" <linusw@kernel.org>, =?utf-8?b?WXUtQ2h1biBMaW4gW+aelw==?=\n\t=?utf-8?b?56WQ5ZCbXQ==?= <eleanor.lin@realtek.com>","X-Mailer":"aerc 0.20.0","References":"<20260408025243.1155482-1-eleanor.lin@realtek.com>\n <20260408025243.1155482-4-eleanor.lin@realtek.com>\n <CAMRc=MfUh_OuxS4SC6QzSOg_PMNc9i9crGYgBASrbVUgHDHSCw@mail.gmail.com>\n <52bf9ce2b7754af8af69b0afee0d07b2@realtek.com>\n <CAD++jLkpS-T9yK=ctSwpLvXkj7s7ivmwu1KKwzy4KS40LVYeyA@mail.gmail.com>","In-Reply-To":"\n <CAD++jLkpS-T9yK=ctSwpLvXkj7s7ivmwu1KKwzy4KS40LVYeyA@mail.gmail.com>"}}]