Skip to contentSkip to conversation

gpio: Add Intel Nova Lake ACPI GPIO events driver

PATCH Superseded Alan Borzeszkowski 2 participants 3 messages Mar 18 – Mar 31

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Alan Borzeszkowski

author maintainer
#0 lore raw

PATCH 1/1 gpio: Add Intel Nova Lake ACPI GPIO events driver

This driver provides support for new way of handling platform events, through the use of GPIO-signaled ACPI events. This mechanism is used on Intel client platforms released in 2026 and later, starting with Intel Nova Lake.

---
 MAINTAINERS                         |   7 +
 drivers/gpio/Kconfig                |  26 +++
 drivers/gpio/Makefile               |   1 +
 drivers/gpio/gpio-novalake-events.c | 324 ++++++++++++++++++++++++++++
 4 files changed, 358 insertions(+)
 create mode 100644 drivers/gpio/gpio-novalake-events.c
MAINTAINERS +7 -0
index 0d718b6274df..039be0519e58 100644
@@ -12847,6 +12847,13 @@ F:	drivers/gpio/gpio-sodaville.c
 F:	drivers/gpio/gpio-tangier.c
 F:	drivers/gpio/gpio-tangier.h
 
+INTEL GPIO GPE DRIVER
+M:	Alan Borzeszkowski <[email protected]>
+R:	Mika Westerberg <[email protected]>
+L:	[email protected]
+S:	Supported
+F:	drivers/gpio/gpio-novalake-events.c
+
 INTEL GVT-g DRIVERS (Intel GPU Virtualization)
 R:	Zhenyu Wang <[email protected]>
 R:	Zhi Wang <[email protected]>
drivers/gpio/Kconfig +26 -0
index b45fb799e36c..c7a80e5189d8 100644
@@ -1057,6 +1057,32 @@ config GPIO_SCH
 	  The Intel Quark X1000 SoC has 2 GPIOs powered by the core
 	  power well and 6 from the suspend power well.
 
+config GPIO_NOVALAKE
+	tristate "Intel Nova Lake GPIO-signaled ACPI events support"
+	depends on (X86 || COMPILE_TEST) && ACPI
+	select GPIOLIB_IRQCHIP
+	help
+	  Select this to enable GPIO-signaled ACPI events support on platforms
+	  with the following SoCs:
+
+	  - Intel Nova Lake
+
+	  This driver adds support for new mode of handling platform events,
+	  through the use of GPIO-signaled ACPI events. Main purpose is to
+	  handle platform IRQs that originate in PCH components, for example
+	  interrupt triggered by Power Management Event (PME).
+
+	  This driver, at this time, is not required to handle platform events.
+	  Listed platform(s) will stay in legacy mode, handling ACPI events as
+	  in previous generations. However, future platforms will eventually
+	  switch to new handling mode, requiring this driver to run events
+	  properly.
+
+	  Driver supports up to 128 GPIO pins per GPE block.
+
+	  To compile this driver as a module, choose M here: the module will
+	  be called gpio-novalake-events.
+
 config GPIO_SCH311X
 	tristate "SMSC SCH311x SuperI/O GPIO"
 	help
drivers/gpio/Makefile +1 -0
index c05f7d795c43..f563917cda83 100644
@@ -134,6 +134,7 @@ obj-$(CONFIG_GPIO_MXC)			+= gpio-mxc.o
 obj-$(CONFIG_GPIO_MXS)			+= gpio-mxs.o
 obj-$(CONFIG_GPIO_NCT6694)		+= gpio-nct6694.o
 obj-$(CONFIG_GPIO_NOMADIK)		+= gpio-nomadik.o
+obj-$(CONFIG_GPIO_NOVALAKE)		+= gpio-novalake-events.o
 obj-$(CONFIG_GPIO_NPCM_SGPIO)		+= gpio-npcm-sgpio.o
 obj-$(CONFIG_GPIO_OCTEON)		+= gpio-octeon.o
 obj-$(CONFIG_GPIO_OMAP)			+= gpio-omap.o
drivers/gpio/gpio-novalake-events.c new file +324 -0

324 lines not on this page · raw message

Signature · 1 line
2.43.0
#1 lore raw
Quoted 4 lines · Alan Borzeszkowski

This driver provides support for new way of handling platform events, through the use of GPIO-signaled ACPI events. This mechanism is used on Intel client platforms released in 2026 and later, starting with Intel Nova Lake.

...

drivers/gpio/gpio-novalake-events.c line 123

Quoted 5 lines
drivers/gpio/gpio-novalake-events.c new file +4 -0
+static void nvl_gpio_irq_mask_unmask(struct gpio_chip *gc, unsigned long hwirq,
+				     bool mask)
 
+	addr = nvl_gpio_get_byte_addr(priv, GPE_EN_REG_OFFSET(priv->blk_size),
+				      byte_idx);

These are only two cases where we go a bit further than 80, so I would just make them a single line each.

...

Quoted 7 lines
drivers/gpio/gpio-novalake-events.c new file +7 -0
+	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
+	if (!priv)
+		return -ENOMEM;
+	raw_spin_lock_init(&priv->lock);
+
+	res = platform_get_resource(pdev, IORESOURCE_IO, 0);
+	if (!res)

drivers/gpio/gpio-novalake-events.c line 269

Quoted 10 lines
drivers/gpio/gpio-novalake-events.c new file +10 -0
+		return -ENXIO;
+	/*
+	 * GPE block length should be non-negative multiple of two and allow up
+	 * to 128 pins. ACPI v6.6 section 5.2.9 and 5.6.4.
+	 */
+	ioresource_size = resource_size(res);
+	if (!ioresource_size || ioresource_size % 2 || ioresource_size > 0x20)
+		return dev_err_probe(dev, -EINVAL,
+				     "invalid GPE block length, resource: %pR\n",
+				     res);

There is no point to even allocate memory if the resource is not available or invalid.

	..._get_resource()
	...validate...
	...map, as we still have local variable for that...

	priv = devm_kzalloc(...);
	...
	_init_lock(...);

drivers/gpio/gpio-novalake-events.c line 282

Quoted 12 lines
drivers/gpio/gpio-novalake-events.c new file +12 -0
+	regs = devm_ioport_map(dev, res->start, ioresource_size);
+	if (!regs)
+		return -ENOMEM;
+	priv->reg_base = regs;
+	priv->blk_size = ioresource_size;
+
+	irq = platform_get_irq(pdev, 0);
+	if (irq < 0)
+		return irq;
+
+	ret = devm_request_irq(dev, irq, nvl_gpio_irq, IRQF_SHARED,
+			       dev_name(dev), priv);

I would also go with a single line here:

	ret = devm_request_irq(dev, irq, nvl_gpio_irq, IRQF_SHARED, dev_name(dev), priv);

One Q though, is it indeed shared? Or can it be shared?

Quoted 2 lines
(quoted diff) +2 -0
+	if (ret)
+		return ret;
Signature · 2 lines
With Best Regards,
Andy Shevchenko
author maintainer
#2 lore raw

Hi Andy,

Quoted 76 lines · Andy Shevchenko
Quoted 7 lines · Alan Borzeszkowski

This driver provides support for new way of handling platform events,
through the use of GPIO-signaled ACPI events. This mechanism is used on
Intel client platforms released in 2026 and later, starting with Intel
Nova Lake.

...

drivers/gpio/gpio-novalake-events.c line 123

Quoted 7 lines

+static void nvl_gpio_irq_mask_unmask(struct gpio_chip *gc, unsigned long hwirq,

(quoted diff) +2 -0
+				     bool mask)
 
+	addr = nvl_gpio_get_byte_addr(priv,

GPE_EN_REG_OFFSET(priv->blk_size),

drivers/gpio/gpio-novalake-events.c new file +1 -0
+				      byte_idx);

These are only two cases where we go a bit further than 80, so I would just
make them a single line each.

...

Quoted 19 lines
drivers/gpio/gpio-novalake-events.c new file +10 -0
+	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
+	if (!priv)
+		return -ENOMEM;
+	raw_spin_lock_init(&priv->lock);
+
+	res = platform_get_resource(pdev, IORESOURCE_IO, 0);
+	if (!res)
+		return -ENXIO;
+	/*
+	 * GPE block length should be non-negative multiple of two

and allow up

drivers/gpio/gpio-novalake-events.c new file +4 -0
+	 * to 128 pins. ACPI v6.6 section 5.2.9 and 5.6.4.
+	 */
+	ioresource_size = resource_size(res);
+	if (!ioresource_size || ioresource_size % 2 ||

ioresource_size > 0x20)

(quoted diff) +2 -0
+		return dev_err_probe(dev, -EINVAL,
+				     "invalid GPE block length,

resource: %pR\n",

drivers/gpio/gpio-novalake-events.c line 269

Quoted 1 line
drivers/gpio/gpio-novalake-events.c new file +1 -0
+				     res);

There is no point to even allocate memory if the resource is not available or
invalid.

	..._get_resource()
	...validate...
	...map, as we still have local variable for that...

	priv = devm_kzalloc(...);
	...
	_init_lock(...);

drivers/gpio/gpio-novalake-events.c line 282

Quoted 13 lines
drivers/gpio/gpio-novalake-events.c new file +11 -0
+	regs = devm_ioport_map(dev, res->start, ioresource_size);
+	if (!regs)
+		return -ENOMEM;
+	priv->reg_base = regs;
+	priv->blk_size = ioresource_size;
+
+	irq = platform_get_irq(pdev, 0);
+	if (irq < 0)
+		return irq;
+
+	ret = devm_request_irq(dev, irq, nvl_gpio_irq,

IRQF_SHARED,

drivers/gpio/gpio-novalake-events.c new file +1 -0
+			       dev_name(dev), priv);

I would also go with a single line here:

Quoted 4 lines

ret = devm_request_irq(dev, irq, nvl_gpio_irq, IRQF_SHARED,
dev_name(dev), priv);

One Q though, is it indeed shared? Or can it be shared?

It can be shared.

Quoted 4 lines
Quoted 3 lines
(quoted diff) +2 -0
+	if (ret)
+		return ret;