Re: [PATCH v4] gpio: amdptpci: add support for AMD PT PCI controller
From: Linus Walleij
Date: Thu Nov 26 2026 - 08:25:27 EST
Hio Szuying,
thanks for your patch!
On Mon, Nov 16, 2026 at 8:55 AM Szuying Chen <Chloe_Chen@xxxxxxxxxxxxxx> wrote:
> The GPIO controller on AMD PT PCI platforms currently has no in-tree
> driver, so its pins cannot be used from Linux.
>
> The existing gpio-amdpt driver cannot be reused. Setting aside ACPI
> vs. PCI probing, the hardware differs significantly:
>
> - Register semantics conflict: offset 0x0C controls the clock rate
> in gpio-amdpt but enables interrupts in this controller.
> - Interrupt controller: gpio-amdpt has no interrupt support, while
> this controller has its own INT_LVL, INT_STAT and INT_MASK
> registers that require a full irq_chip implementation.
> - Wakeup: this controller can wake the system from GPIO interrupts,
> which gpio-amdpt does not support.
>
> Only the basic data registers are common, and they are handled
> through gpio-generic, so little code is left to share.
>
> Add the gpio-amdptpci driver to support the GPIO functionality on
> AMD PT PCI platforms.
>
> Co-developed-by: YD Tseng <Yd_Tseng@xxxxxxxxxxxxxx>
> Signed-off-by: YD Tseng <Yd_Tseng@xxxxxxxxxxxxxx>
> Signed-off-by: Szuying Chen <Chloe_Chen@xxxxxxxxxxxxxx>
(...)
> +config GPIO_AMDPTPCI
> + tristate "AMD Promontory PCI GPIO support"
> + depends on X86
> + select GPIO_GENERIC
Neat!
> +#include <linux/bits.h>
> +#include <linux/gpio/driver.h>
> +#include <linux/gpio/generic.h>
> +static void pt27_irq_ack(struct irq_data *d)
> +{
> + struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
> + struct pt27_gpio *chip = gpiochip_get_data(gc);
> +
> + iowrite32(BIT(irqd_to_hwirq(d)), chip->base + PT27_REG_INT_STAT);
> +}
No need to use the lock here? I think this should probably take a lock
and use read-modify-write, think about what happens if two interrupts
arrive at the same time.
Other than that it looks good, but look into Sashiko's comments too.
Yours,
Linus Walleij