The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@baylibre.com>
To: Shubham Paralikar <shubham.paralikar@mediatek.com>
Cc: Sean Wang <sean.wang@kernel.org>,
	Linus Walleij <linusw@kernel.org>,
	 Matthias Brugger <matthias.bgg@gmail.com>,
	 AngeloGioacchino Del Regno
	<angelogioacchino.delregno@collabora.com>,
	Bartosz Golaszewski <brgl@kernel.org>,
	 linux-kernel@vger.kernel.org,
	linux-mediatek@lists.infradead.org, linux-gpio@vger.kernel.org,
	 linux-arm-kernel@lists.infradead.org, Arnab.Layek@mediatek.com,
	Fred-WY.Chen@mediatek.com
Subject: Re: [PATCH v4 1/1] pinctrl: mediatek: Add MT8901/MT8971 ACPI driver
Date: Mon, 23 Nov 2026 10:13:20 +0100	[thread overview]
Message-ID: <awQBpBFVPoFtGLhm@monoceros> (raw)
In-Reply-To: <20261120165908.3204369-2-shubham.paralikar@mediatek.com>

[-- Attachment #1: Type: text/plain, Size: 23915 bytes --]

Hello,

On Sat, Nov 21, 2026 at 12:58:32AM +0800, Shubham Paralikar wrote:
> MT8901 and MT8971 are booted with ACPI firmware and both describe their
> GPIO controller with the same _HID, NVDA9221. The existing MediaTek
> Paris pinctrl drivers only probe from devicetree and pick their SoC
> data from the match table, so neither SoC gets pin control, GPIOs or
> EINT interrupts.
> 
> Add pinctrl-mtk-acpi, a helper for Paris pin controllers on ACPI. Each
> SoC driver matches NVDA9221 itself and calls mtk_pinctrl_acpi_probe()
> with its own mtk_pin_soc and the "ChipId" value that identifies its
> SoC. The helper reads ChipId from the controller's vendor _DSD and
> returns -ENODEV when it belongs to another SoC, so the driver core
> moves on to the next driver matching the same _HID. Adding a SoC only
> needs a new SoC driver; the helper has no per-SoC table.
> 
> The _DSD uses a MediaTek UUID rather than the Device Properties UUID,
> so device_property_read_u32() cannot read it. The helper evaluates
> _DSD and walks the package directly.
> 
> Add pinctrl-mt8901 and pinctrl-mt8971 as separate drivers, each with
> its own Kconfig symbol, built on top of the helper.
> 
> Make the shared Paris, common-v2 and EINT code work on ACPI and with
> these SoCs:
> 
> - paris: add mtk_paris_pinctrl_probe_soc() for drivers that pick the
>   SoC data themselves. ACPI resources have no names, so map the pin
>   register bases by resource index on ACPI. Register a GPIO range and
>   request the ACPI _AEI event interrupts, and support
>   PIN_CONFIG_BIAS_BUS_HOLD.
> - common-v2: on ACPI, count the EINT banks from the MEM resources and
>   take the IRQ from the platform device instead of from DT. Add
>   reg_order[] field tables for SoCs whose per-pin registers sit at a
>   fixed stride (MT8971), wake-event EINT lists and bus-hold bias
>   (PU=1, PD=1).
> - mtk-eint: add a skip list so the init-time mask sweep leaves
>   firmware-owned EINTs alone (MT8971 EINT215, PROCHOT), and add the
>   MT8901 debounce table. On SoCs with a wake-event mask (MT8901),
>   unmask the event for the static event list at init and for EINTs
>   armed through irq_set_wake(), mask it again when wake is disabled,
>   and re-apply both on resume.
> - MT8901: add EINT-only virtual GPIOs 182-208, such as the xHCI wake
>   events, which firmware describes as GpioInt resources on this
>   controller. Skip pinmux, direction and pinconf for them, and report
>   debounce as unsupported on EINTs without debounce hardware.
> - gpio: declare acpi_gpiochip_request_interrupts() and
>   acpi_gpiochip_free_interrupts() in linux/gpio/driver.h. MediaTek
>   EINT provides .to_irq instead of a gpio_irq_chip, so gpiolib does
>   not request the _AEI interrupts for this controller by itself.
> 
> Signed-off-by: Shubham Paralikar <shubham.paralikar@mediatek.com>
> ---
> Changes in v4:
> - Rename pinctrl-mt89xx to pinctrl-mtk-acpi, no wildcard names
>   (AngeloGioacchino)
> - Fold the _DSD parser (pinctrl-mtk-dsd) into pinctrl-mtk-acpi and read
>   only the properties that are used (AngeloGioacchino)
> - Let each SoC driver match NVDA9221 and pass its own mtk_pin_soc to
>   pinctrl-mtk-acpi, dropping the ChipId to SoC table; split into
>   PINCTRL_MT8901 and PINCTRL_MT8971 (AngeloGioacchino)
> - Drop include/linux/soc/mediatek/mtk-pinctrl.h and
>   mtk_pinctrl_program_bias_by_gpio(), along with the controller
>   registry behind it. SoundWire pad bus-keeper setup is left to
>   firmware or will be addressed separately (AngeloGioacchino)
> - Remove probe trace dev_info() prints (AngeloGioacchino)
> - Report debounce as unsupported (-ENOTSUPP) on SoCs without a debounce
>   table and skip debounce processing in the EINT handler there. On
>   MT8971 the -EOPNOTSUPP from the EINT code made every ACPI GpioInt on
>   a debounce-capable pin fail (Sashiko)
> - Return -ENOTSUPP for virtual GPIOs in the reg_order field lookup
>   instead of computing an offset past the pad registers (Sashiko)
> - Allocate hw->eint only after the EINT resource count checks, so a
>   failed EINT setup no longer leaves a half-initialised hw->eint
>   (Sashiko)
> - Set nfuncs to 16 for MT8971, whose pins use functions 8 to 10
>   (Sashiko)
> - Register the GPIO pin range only on ACPI, via gpiochip_add_pin_range();
>   on DT it comes from gpio-ranges
> - Check platform_get_resource() before mapping ACPI EINT banks
> - Drop the unused .gpio_set_direction pinmux op, the reg_in_order flag
>   (reg_order being set is enough), redundant error prints and overflow
>   checks on static tables, and unrelated copyright and message churn
> - Expand the PINCTRL_MT8901 and PINCTRL_MT8971 Kconfig help text
> 
> Known issue: MT8971 suspend behaviour of EINT215 (PROCHOT, owned by
> firmware) is still under investigation. It is kept unmasked at init
> and resume, but the suspend path may mask it while the system sleeps.
> 
> The changes marked (Sashiko) fix problems reported by the Sashiko AI
> review of v3. The v4 rework was done with the help of an AI coding
> assistant (Claude Opus 5.5). Build tested on arm64 with both drivers
> as modules and built-in, with W=1 for drivers/pinctrl/mediatek/.
> ---
>  drivers/pinctrl/mediatek/Kconfig              |   33 +-
>  drivers/pinctrl/mediatek/Makefile             |    3 +
>  drivers/pinctrl/mediatek/mtk-eint.c           |  217 +-
>  drivers/pinctrl/mediatek/mtk-eint.h           |   16 +-
>  drivers/pinctrl/mediatek/pinctrl-mt8901.c     | 1471 +++++++++++
>  drivers/pinctrl/mediatek/pinctrl-mt8971.c     |   91 +
>  drivers/pinctrl/mediatek/pinctrl-mtk-acpi.c   |  153 ++
>  drivers/pinctrl/mediatek/pinctrl-mtk-acpi.h   |   17 +
>  .../pinctrl/mediatek/pinctrl-mtk-common-v2.c  |  124 +-
>  .../pinctrl/mediatek/pinctrl-mtk-common-v2.h  |   31 +
>  drivers/pinctrl/mediatek/pinctrl-mtk-mt8901.h | 2296 +++++++++++++++++
>  drivers/pinctrl/mediatek/pinctrl-mtk-mt8971.h | 1646 ++++++++++++
>  drivers/pinctrl/mediatek/pinctrl-paris.c      |   95 +-
>  drivers/pinctrl/mediatek/pinctrl-paris.h      |    2 +
>  include/linux/gpio/driver.h                   |    5 +
>  15 files changed, 6162 insertions(+), 38 deletions(-)
>  create mode 100644 drivers/pinctrl/mediatek/pinctrl-mt8901.c
>  create mode 100644 drivers/pinctrl/mediatek/pinctrl-mt8971.c
>  create mode 100644 drivers/pinctrl/mediatek/pinctrl-mtk-acpi.c
>  create mode 100644 drivers/pinctrl/mediatek/pinctrl-mtk-acpi.h
>  create mode 100644 drivers/pinctrl/mediatek/pinctrl-mtk-mt8901.h
>  create mode 100644 drivers/pinctrl/mediatek/pinctrl-mtk-mt8971.h
> 
> diff --git a/drivers/pinctrl/mediatek/Kconfig b/drivers/pinctrl/mediatek/Kconfig
> index 912d782fb6a5..e7a11a5c99af 100644
> --- a/drivers/pinctrl/mediatek/Kconfig
> +++ b/drivers/pinctrl/mediatek/Kconfig
> @@ -39,13 +39,18 @@ config PINCTRL_MTK_MOORE
>  
>  config PINCTRL_MTK_PARIS
>  	tristate
> -	depends on OF
> +	depends on OF || ACPI
>  	select PINMUX
>  	select GENERIC_PINCONF
>  	select GPIOLIB
>  	select EINT_MTK
>  	select PINCTRL_MTK_V2
>  
> +config PINCTRL_MTK_ACPI
> +	tristate
> +	depends on ACPI
> +	select PINCTRL_MTK_PARIS
> +
>  # For MIPS SoCs
>  config PINCTRL_MT7620
>  	tristate "MediaTek MT7620 pin control"
> @@ -323,6 +328,32 @@ config PINCTRL_MT8516
>  	default ARM64 && ARCH_MEDIATEK
>  	select PINCTRL_MTK
>  
> +config PINCTRL_MT8901
> +	tristate "MediaTek MT8901 pin control"
> +	depends on ACPI
> +	depends on ARM64 || COMPILE_TEST
> +	default ARM64 && ARCH_MEDIATEK
> +	select PINCTRL_MTK_ACPI
> +	help
> +	  Say yes here to support the pin controller and GPIO driver on
> +	  MediaTek MT8901 SoC with ACPI firmware. The driver provides pin
> +	  multiplexing, pin configuration, GPIOs and EINT interrupts. It
> +	  also exposes virtual GPIOs for EINTs that have no GPIO pad, such
> +	  as the xHCI wake events.
> +
> +config PINCTRL_MT8971
> +	tristate "MediaTek MT8971 pin control"
> +	depends on ACPI
> +	depends on ARM64 || COMPILE_TEST
> +	default ARM64 && ARCH_MEDIATEK
> +	select PINCTRL_MTK_ACPI
> +	help
> +	  Say yes here to support the pin controller and GPIO driver on
> +	  MediaTek MT8971 SoC with ACPI firmware. The driver provides pin
> +	  multiplexing, pin configuration, GPIOs and EINT interrupts.
> +	  Both this and the MT8901 driver match the same ACPI _HID; the
> +	  _DSD ChipId selects which one binds.
> +
>  # For PMIC
>  config PINCTRL_MT6397
>  	tristate "MediaTek MT6397 pin control"
> diff --git a/drivers/pinctrl/mediatek/Makefile b/drivers/pinctrl/mediatek/Makefile
> index 9982866359af..18e061df0981 100644
> --- a/drivers/pinctrl/mediatek/Makefile
> +++ b/drivers/pinctrl/mediatek/Makefile
> @@ -6,6 +6,7 @@ obj-$(CONFIG_PINCTRL_MTK_V2)		+= pinctrl-mtk-common-v2.o
>  obj-$(CONFIG_PINCTRL_MTK_MTMIPS)	+= pinctrl-mtmips.o
>  obj-$(CONFIG_PINCTRL_MTK_MOORE)		+= pinctrl-moore.o
>  obj-$(CONFIG_PINCTRL_MTK_PARIS)		+= pinctrl-paris.o
> +obj-$(CONFIG_PINCTRL_MTK_ACPI)		+= pinctrl-mtk-acpi.o
>  
>  # SoC Drivers
>  obj-$(CONFIG_PINCTRL_MT7620)		+= pinctrl-mt7620.o
> @@ -43,4 +44,6 @@ obj-$(CONFIG_PINCTRL_MT8195)		+= pinctrl-mt8195.o
>  obj-$(CONFIG_PINCTRL_MT8196)		+= pinctrl-mt8196.o
>  obj-$(CONFIG_PINCTRL_MT8365)		+= pinctrl-mt8365.o
>  obj-$(CONFIG_PINCTRL_MT8516)		+= pinctrl-mt8516.o
> +obj-$(CONFIG_PINCTRL_MT8901)		+= pinctrl-mt8901.o
> +obj-$(CONFIG_PINCTRL_MT8971)		+= pinctrl-mt8971.o
>  obj-$(CONFIG_PINCTRL_MT6397)		+= pinctrl-mt6397.o
> diff --git a/drivers/pinctrl/mediatek/mtk-eint.c b/drivers/pinctrl/mediatek/mtk-eint.c
> index 389ceaffcee4..1f8d68673725 100644
> --- a/drivers/pinctrl/mediatek/mtk-eint.c
> +++ b/drivers/pinctrl/mediatek/mtk-eint.c
> @@ -51,6 +51,9 @@ static const struct mtk_eint_regs mtk_generic_eint_regs = {
>  	.dbnc_ctrl = 0x500,
>  	.dbnc_set  = 0x600,
>  	.dbnc_clr  = 0x700,
> +	.event     = 0x800,
> +	.event_set = 0x840,
> +	.event_clr = 0x880,
>  };
>  
>  const unsigned int debounce_time_mt2701[] = {
> @@ -73,14 +76,23 @@ const unsigned int debounce_time_mt6878[] = {
>  };
>  EXPORT_SYMBOL_GPL(debounce_time_mt6878);
>  
> +const unsigned int debounce_time_mt8901[] = {
> +	156, 313, 625, 1250, 20000, 40000, 80000, 160000, 320000, 640000, 0
> +};
> +EXPORT_SYMBOL_GPL(debounce_time_mt8901);
> +
>  static void __iomem *mtk_eint_get_offset(struct mtk_eint *eint,
> -					 unsigned int eint_num,
> +					 unsigned long eint_num,
>  					 unsigned int offset)
>  {
>  	unsigned int idx = eint->pins[eint_num].index;
>  	unsigned int inst = eint->pins[eint_num].instance;
>  	void __iomem *reg;
>  
> +	/* Pins without EINT hardware have instance >= nbase. */
> +	if (inst >= eint->nbase)
> +		return NULL;
> +
>  	reg = eint->base[inst] + offset + (idx / 32 * 4);
>  
>  	return reg;
> @@ -94,6 +106,10 @@ static unsigned int mtk_eint_can_en_debounce(struct mtk_eint *eint,
>  	void __iomem *reg = mtk_eint_get_offset(eint, eint_num,
>  						eint->regs->sens);
>  
> +	/* Pins without EINT hardware cannot debounce. */
> +	if (!reg)
> +		return 0;
> +
>  	if (readl(reg) & bit)
>  		sens = MTK_EINT_LEVEL_SENSITIVE;
>  	else
> @@ -111,7 +127,14 @@ static int mtk_eint_flip_edge(struct mtk_eint *eint, int hwirq)
>  	unsigned int reg_offset;
>  	unsigned int mask = BIT(eint->pins[hwirq].index & 0x1f);
>  	unsigned int port = (eint->pins[hwirq].index >> 5) & eint->hw->port_mask;
> -	void __iomem *reg = eint->base[eint->pins[hwirq].instance] + (port << 2);
> +	unsigned int inst = eint->pins[hwirq].instance;
> +	void __iomem *reg;
> +
> +	/* Pins without EINT hardware have nothing to flip. */
> +	if (inst >= eint->nbase)
> +		return 0;
> +
> +	reg = eint->base[inst] + (port << 2);
>  
>  	curr_level = eint->gpio_xlate->get_gpio_state(eint->pctl, hwirq);
>  
> @@ -136,9 +159,13 @@ static void mtk_eint_mask(struct irq_data *d)
>  	unsigned int idx = eint->pins[d->hwirq].index;
>  	unsigned int inst = eint->pins[d->hwirq].instance;
>  	unsigned int mask = BIT(idx & 0x1f);
> -	void __iomem *reg = mtk_eint_get_offset(eint, d->hwirq,
> -						eint->regs->mask_set);
> +	void __iomem *reg;
> +
> +	/* Pins without EINT hardware cannot be masked. */
> +	if (inst >= eint->nbase)
> +		return;
>  
> +	reg = mtk_eint_get_offset(eint, d->hwirq, eint->regs->mask_set);
>  	eint->cur_mask[inst][idx >> 5] &= ~mask;
>  
>  	writel(mask, reg);
> @@ -150,9 +177,13 @@ static void mtk_eint_unmask(struct irq_data *d)
>  	unsigned int idx = eint->pins[d->hwirq].index;
>  	unsigned int inst = eint->pins[d->hwirq].instance;
>  	unsigned int mask = BIT(idx & 0x1f);
> -	void __iomem *reg = mtk_eint_get_offset(eint, d->hwirq,
> -						eint->regs->mask_clr);
> +	void __iomem *reg;
> +
> +	/* Pins without EINT hardware cannot be unmasked. */
> +	if (inst >= eint->nbase)
> +		return;
>  
> +	reg = mtk_eint_get_offset(eint, d->hwirq, eint->regs->mask_clr);
>  	eint->cur_mask[inst][idx >> 5] |= mask;
>  
>  	writel(mask, reg);
> @@ -161,6 +192,94 @@ static void mtk_eint_unmask(struct irq_data *d)
>  		mtk_eint_flip_edge(eint, d->hwirq);
>  }
>  
> +static void mtk_eint_write_event_mask(struct mtk_eint *eint,
> +				      unsigned long eint_num,
> +				      unsigned int reg_offset)
> +{
> +	unsigned int idx, inst;
> +	unsigned int mask;
> +	void __iomem *reg;
> +
> +	if (!eint->hw->has_event_mask)
> +		return;
> +
> +	if (eint_num >= eint->hw->ap_num)
> +		return;
> +
> +	idx  = eint->pins[eint_num].index;
> +	inst = eint->pins[eint_num].instance;
> +
> +	if (inst >= eint->nbase)
> +		return;
> +
> +	mask = BIT(idx & 0x1f);
> +	reg = mtk_eint_get_offset(eint, eint_num, reg_offset);
> +	writel(mask, reg);
> +}
> +
> +/* Unmask the wake event of one EINT. */
> +static void mtk_eint_event_unmask_one(struct mtk_eint *eint,
> +				      unsigned long eint_num)
> +{
> +	mtk_eint_write_event_mask(eint, eint_num, eint->regs->event_clr);
> +}
> +
> +static bool mtk_eint_is_static_event_unmask_pin(struct mtk_eint *eint,
> +						unsigned long eint_num)
> +{
> +	unsigned int i;
> +
> +	for (i = 0; i < eint->num_event_pins; i++) {
> +		if (eint->event_pins[i] == eint_num)
> +			return true;
> +	}
> +
> +	return false;
> +}
> +
> +/* Mask the wake event of one EINT. Not for pins in the static event list. */
> +static void mtk_eint_event_mask_one(struct mtk_eint *eint,
> +				    unsigned long eint_num)
> +{
> +	mtk_eint_write_event_mask(eint, eint_num, eint->regs->event_set);
> +}
> +
> +/* Unmask the wake events of the SoC's static event list. */
> +static void mtk_eint_apply_event_unmask(struct mtk_eint *eint)
> +{
> +	unsigned int i;
> +
> +	for (i = 0; i < eint->num_event_pins; i++)
> +		mtk_eint_event_unmask_one(eint, eint->event_pins[i]);
> +}
> +
> +static void mtk_eint_apply_wake_event_unmask(struct mtk_eint *eint)
> +{
> +	unsigned int eint_num, pin, shift;
> +	unsigned int inst, port, port_num;
> +	u32 bits;
> +
> +	if (!eint->hw->has_event_mask)
> +		return;
> +
> +	for (inst = 0; inst < eint->nbase; inst++) {
> +		port_num = DIV_ROUND_UP(eint->base_pin_num[inst], 32);
> +		for (port = 0; port < port_num; port++) {
> +			bits = eint->wake_mask[inst][port];
> +			while (bits) {
> +				shift = __ffs(bits);
> +				bits &= ~BIT(shift);
> +				pin = port * 32 + shift;
> +				if (pin >= eint->base_pin_num[inst])
> +					continue;
> +
> +				eint_num = eint->pin_list[inst][pin];
> +				mtk_eint_event_unmask_one(eint, eint_num);
> +			}
> +		}
> +	}
> +}
> +
>  static unsigned int mtk_eint_get_mask(struct mtk_eint *eint,
>  				      unsigned int eint_num)
>  {
> @@ -239,10 +358,18 @@ static int mtk_eint_irq_set_wake(struct irq_data *d, unsigned int on)
>  	unsigned int shift = idx & 0x1f;
>  	unsigned int port = idx >> 5;
>  
> -	if (on)
> +	/* Pins without EINT hardware cannot wake. */
> +	if (inst >= eint->nbase)
> +		return 0;
> +
> +	if (on) {
>  		eint->wake_mask[inst][port] |= BIT(shift);
> -	else
> +		mtk_eint_event_unmask_one(eint, d->hwirq);
> +	} else {
>  		eint->wake_mask[inst][port] &= ~BIT(shift);
> +		if (!mtk_eint_is_static_event_unmask_pin(eint, d->hwirq))
> +			mtk_eint_event_mask_one(eint, d->hwirq);
> +	}
>  
>  	return 0;
>  }
> @@ -250,7 +377,7 @@ static int mtk_eint_irq_set_wake(struct irq_data *d, unsigned int on)
>  static void mtk_eint_chip_write_mask(const struct mtk_eint *eint,
>  				     unsigned int **buf)
>  {
> -	int inst, port, port_num;
> +	unsigned int inst, port, port_num;
>  	void __iomem *reg;
>  
>  	for (inst = 0; inst < eint->nbase; inst++) {
> @@ -270,6 +397,13 @@ static int mtk_eint_irq_request_resources(struct irq_data *d)
>  	unsigned int gpio_n;
>  	int err;
>  
> +	/* Pins without EINT hardware cannot be used as interrupts. */
> +	if (eint->pins[d->hwirq].instance >= eint->nbase) {
> +		dev_dbg(eint->dev, "EINT %lu has no EINT hardware\n",
> +			d->hwirq);
> +		return -ENXIO;
> +	}
> +
>  	err = eint->gpio_xlate->get_gpio_n(eint->pctl, d->hwirq,
>  					   &gpio_n, &gpio_c);
>  	if (err < 0) {
> @@ -317,6 +451,31 @@ static struct irq_chip mtk_eint_irq_chip = {
>  	.irq_release_resources = mtk_eint_irq_release_resources,
>  };
>  
> +/*
> + * Return the mask_set value for a 32-bit word of bank @inst, leaving
> + * skip-listed EINTs unmasked. dom_en is still set for all EINTs.
> + */
> +static unsigned int mtk_eint_mask_word_for_skip(struct mtk_eint *eint,
> +						unsigned int inst,
> +						unsigned int word_base)
> +{
> +	unsigned int mask = 0xffffffff;
> +	unsigned int k, eint_num, idx;
> +
> +	for (k = 0; k < eint->num_skip_eint; k++) {
> +		eint_num = eint->skip_eint_list[k];
> +		if (eint_num >= eint->hw->ap_num)
> +			continue;
> +		if (eint->pins[eint_num].instance != inst)
> +			continue;
> +		idx = eint->pins[eint_num].index;
> +		if ((idx & ~0x1fu) != word_base)
> +			continue;
> +		mask &= ~BIT(idx & 0x1f);
> +	}
> +	return mask;
> +}
> +
>  static unsigned int mtk_eint_hw_init(struct mtk_eint *eint)
>  {
>  	void __iomem *dom_reg, *mask_reg;
> @@ -327,12 +486,38 @@ static unsigned int mtk_eint_hw_init(struct mtk_eint *eint)
>  		mask_reg = eint->base[i] + eint->regs->mask_set;
>  		for (j = 0; j < eint->base_pin_num[i]; j += 32) {
>  			writel(0xffffffff, dom_reg);
> -			writel(0xffffffff, mask_reg);
> +			writel(mtk_eint_mask_word_for_skip(eint, i, j), mask_reg);
>  			dom_reg += 4;
>  			mask_reg += 4;
>  		}
>  	}
> +	return 0;
> +}
>  
> +/* Make sure skip-listed EINTs are unmasked and domain enabled. */
> +static int mtk_eint_restore_skip_list(struct mtk_eint *eint)
> +{
> +	unsigned int k, eint_num, inst, idx;
> +	void __iomem *reg;
> +
> +	if (!eint->skip_eint_list || !eint->num_skip_eint)
> +		return 0;
> +
> +	for (k = 0; k < eint->num_skip_eint; k++) {
> +		eint_num = eint->skip_eint_list[k];
> +		if (eint_num >= eint->hw->ap_num)
> +			continue;
> +		inst = eint->pins[eint_num].instance;
> +		if (inst >= eint->nbase)
> +			continue;
> +		idx = eint->pins[eint_num].index;
> +
> +		reg = mtk_eint_get_offset(eint, eint_num, eint->regs->mask_clr);
> +		writel(BIT(idx & 0x1f), reg);
> +
> +		reg = mtk_eint_get_offset(eint, eint_num, eint->regs->dom_en);
> +		writel(BIT(idx & 0x1f), reg);
> +	}
>  	return 0;
>  }
>  
> @@ -371,6 +556,8 @@ static void mtk_eint_irq_handler(struct irq_desc *desc)
>  				shift = __ffs(status);
>  				status &= ~BIT(shift);
>  				mask = BIT(shift);
> +				if (shift + j >= eint->base_pin_num[i])
> +					continue;
>  				eint_num = eint->pin_list[i][shift + j];
>  
>  				/*
> @@ -417,7 +604,7 @@ static void mtk_eint_irq_handler(struct irq_desc *desc)
>  					}
>  				}
>  
> -				if (eint->pins[eint_num].debounce)
> +				if (eint->hw->db_time && eint->pins[eint_num].debounce)
>  					mtk_eint_debounce_process(eint, eint_num);
>  			}
>  		}
> @@ -436,6 +623,8 @@ EXPORT_SYMBOL_GPL(mtk_eint_do_suspend);
>  int mtk_eint_do_resume(struct mtk_eint *eint)
>  {
>  	mtk_eint_chip_write_mask(eint, eint->cur_mask);
> +	mtk_eint_apply_event_unmask(eint);
> +	mtk_eint_apply_wake_event_unmask(eint);
>  
>  	return 0;
>  }
> @@ -610,6 +799,7 @@ int mtk_eint_do_init(struct mtk_eint *eint, struct mtk_eint_pin *eint_pin)
>  	}
>  
>  	mtk_eint_hw_init(eint);
> +	mtk_eint_restore_skip_list(eint);
>  	for (i = 0; i < eint->hw->ap_num; i++) {
>  		inst = eint->pins[i].instance;
>  		if (inst >= eint->nbase)
> @@ -624,9 +814,14 @@ int mtk_eint_do_init(struct mtk_eint *eint, struct mtk_eint_pin *eint_pin)
>  	irq_set_chained_handler_and_data(eint->irq, mtk_eint_irq_handler,
>  					 eint);
>  
> +	mtk_eint_apply_event_unmask(eint);
>  	return devm_add_action_or_reset(eint->dev, mtk_eint_teardown, eint);
>  
>  err_eint:
> +	if (eint->domain) {
> +		irq_domain_remove(eint->domain);
> +		eint->domain = NULL;
> +	}
>  	for (i = 0; i < eint->nbase; i++) {
>  		devm_kfree(eint->dev, eint->cur_mask[i]);
>  		devm_kfree(eint->dev, eint->wake_mask[i]);
> diff --git a/drivers/pinctrl/mediatek/mtk-eint.h b/drivers/pinctrl/mediatek/mtk-eint.h
> index 3cdd6f6310cd..bc98b0cf335a 100644
> --- a/drivers/pinctrl/mediatek/mtk-eint.h
> +++ b/drivers/pinctrl/mediatek/mtk-eint.h
> @@ -31,6 +31,9 @@ struct mtk_eint_regs {
>  	unsigned int	dbnc_ctrl;
>  	unsigned int	dbnc_set;
>  	unsigned int	dbnc_clr;
> +	unsigned int	event;
> +	unsigned int	event_set;
> +	unsigned int	event_clr;
>  };
>  
>  struct mtk_eint_hw {
> @@ -39,6 +42,7 @@ struct mtk_eint_hw {
>  	unsigned int	ap_num;
>  	unsigned int	db_cnt;
>  	const unsigned int *db_time;
> +	bool		has_event_mask;
>  };
>  
>  struct mtk_eint_pin {
> @@ -53,8 +57,10 @@ extern const unsigned int debounce_time_mt2701[];
>  extern const unsigned int debounce_time_mt6765[];
>  extern const unsigned int debounce_time_mt6795[];
>  extern const unsigned int debounce_time_mt6878[];
> +extern const unsigned int debounce_time_mt8901[];
>  
>  struct mtk_eint;
> +struct gpio_chip;
>  
>  struct mtk_eint_xt {
>  	int (*get_gpio_n)(void *data, unsigned long eint_n,
> @@ -67,7 +73,7 @@ struct mtk_eint_xt {
>  struct mtk_eint {
>  	struct device *dev;
>  	void __iomem **base;
> -	int nbase;
> +	unsigned int nbase;
>  	u16 *base_pin_num;
>  	struct irq_domain *domain;
>  	int irq;
> @@ -83,6 +89,14 @@ struct mtk_eint {
>  	struct mtk_eint_pin *pins;
>  	u16 num_db_time;
>  
> +	/* EINTs whose wake event is unmasked after init and resume */
> +	const unsigned int *event_pins;
> +	unsigned int num_event_pins;
> +
> +	/* EINTs owned by firmware that must never be masked */
> +	const unsigned int *skip_eint_list;
> +	unsigned int num_skip_eint;
> +
>  	/* Used to fit into various pinctrl device */
>  	void *pctl;
>  	const struct mtk_eint_xt *gpio_xlate;
> diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8901.c b/drivers/pinctrl/mediatek/pinctrl-mt8901.c
> new file mode 100644
> index 000000000000..1d8338f72a9e
> --- /dev/null
> +++ b/drivers/pinctrl/mediatek/pinctrl-mt8901.c
> @@ -0,0 +1,1471 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (C) 2025 MediaTek Inc.
> + *
> + */
> +
> +#include <linux/mod_devicetable.h>

Please don't add new users of <linux/mod_devicetable.h>.
<linux/platform_device.h> already provides acpi_device_id without
introducing a lot of unneeded dependencies. So <linux/mod_devicetable.h>
can just be dropped.

> +#include <linux/module.h>
> +#include <linux/platform_device.h>
> [...]
> +static const struct acpi_device_id mt8901_pinctrl_acpi_match[] = {
> +	{ "NVDA9221" },

	{ .id = "NVDA9221" },

please

> +	{ }
> +};
> +MODULE_DEVICE_TABLE(acpi, mt8901_pinctrl_acpi_match);

Best regards
Uwe

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

      reply	other threads:[~2026-11-23  9:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20 16:58 [PATCH v4 0/1] pinctrl: mediatek: Add MT8901/MT8971 ACPI driver Shubham Paralikar
2026-11-20 16:58 ` [PATCH v4 1/1] " Shubham Paralikar
2026-11-23  9:13   ` Uwe Kleine-König [this message]

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=awQBpBFVPoFtGLhm@monoceros \
    --to=u.kleine-koenig@baylibre.com \
    --cc=Arnab.Layek@mediatek.com \
    --cc=Fred-WY.Chen@mediatek.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=brgl@kernel.org \
    --cc=linusw@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=matthias.bgg@gmail.com \
    --cc=sean.wang@kernel.org \
    --cc=shubham.paralikar@mediatek.com \
    /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