Re: [PATCH v2 17/22] of: irq: add wake capable bit to of_irq_resource()

From: Andy Shevchenko
Date: Thu Dec 21 2023 - 10:27:29 EST


On Wed, Dec 20, 2023 at 04:54:31PM -0700, Mark Hasemeyer wrote:
> Add wake capability information to the IRQ resource. Wake capability is
> assumed based on conventions provided in the devicetree wakeup-source
> binding documentation. An interrupt is considered wake capable if the
> following are true:
> 1. A wakeup-source property exits in the same device node as the
> interrupt.
> 2. The IRQ is marked as dedicated by setting its interrupt-name to
> "wakeup".
>
> The wakeup-source documentation states that dedicated interrupts can use
> device specific interrupt names and device drivers are still welcome to
> use their own naming schemes. This API is provided as a helper if one is
> willing to conform to the above conventions.
>
> The ACPI subsystems already provides similar APIs that allow one to
> query the wake capability of an IRQ. This brings closer feature parity
> to the devicetree.

...

> r->start = r->end = irq;
> r->flags = IORESOURCE_IRQ | irqd_get_trigger_type(irq_get_irq_data(irq));
> + if (__of_irq_wake_capable(dev, index))
> + r->flags |= IORESOURCE_IRQ_WAKECAPABLE;
> r->name = name ? name : of_node_full_name(dev);

irq_flags = irqd_get_trigger_type(irq_get_irq_data(irq));
if (__of_irq_wake_capable(dev, index))
irq_flags |= IORESOURCE_IRQ_WAKECAPABLE;

*r = DEFINE_RES_NAMED(irq, 1, name ?: of_node_full_name(dev), irq_flags);

?

...

Or even refactor ioport.h (in a separate patch) as we seems already have
two users (and might be more in the existing code):

#define DEFINE_RES_IRQ_NAMED_FLAGS(_irq, _name, _flags) \
DEFINE_RES_NAMED((_irq), 1, (_name), (_flags) | IORESOURCE_IRQ)
#define DEFINE_RES_IRQ_NAMED(_irq, _name) \
DEFINE_RES_IRQ_NAMED_FLAGS((_irq), (_name), 0)
#define DEFINE_RES_IRQ(_irq) \
DEFINE_RES_IRQ_NAMED((_irq), NULL)

(Note, I will Ack such a patch once it appears.)

--
With Best Regards,
Andy Shevchenko