Skip to content

Commit

Permalink
devicetree: add APIs to get interrupt priority
Browse files Browse the repository at this point in the history
We have `DT_IRQN` to get a node's (only) interrupt number
(at index 0), and `DT_IRQN_BY_IDX` to get a node's interrupt
number at a given index. It probably makes sense to have a
priority equivalent of that, so add:
- `DT_IRQP`, and
- `DT_IRQP_BY_IDX`

Signed-off-by: Yong Cong Sin <[email protected]>
  • Loading branch information
ycsin committed Oct 3, 2023
1 parent 637c1be commit 06635e6
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions include/zephyr/devicetree.h
Original file line number Diff line number Diff line change
Expand Up @@ -2409,6 +2409,29 @@
*/
#define DT_IRQ(node_id, cell) DT_IRQ_BY_IDX(node_id, 0, cell)

/**
* @brief Get a node's (only) irq priority
*
* Equivalent to DT_IRQ(node_id, priority). This is provided as a convenience
* for the common case where a node generates exactly one interrupt,
* and the IRQ priority is in a cell named `priority`.
*
* @param node_id node identifier
* @return the interrupt priority for the node's only interrupt
*/
#define DT_IRQP(node_id) DT_IRQ(node_id, priority)

/**
* @brief Get a node's irq priority at index
*
* Equivalent to DT_IRQ_BY_IDX(node_id, idx, priority).
*
* @param node_id node identifier
* @param idx node identifier
* @return the interrupt priority for the node's interrupt by the index
*/
#define DT_IRQP_BY_IDX(node_id, idx) DT_IRQ_BY_IDX(node_id, idx, priority)

/* DT helper macro to get interrupt-parent node */
#define Z_DT_PARENT_INTC(node_id) DT_PROP(node_id, interrupt_parent)
/* DT helper macro to get the node's interrupt grandparent node */
Expand Down Expand Up @@ -3891,6 +3914,13 @@
*/
#define DT_INST_IRQN(inst) DT_IRQN(DT_DRV_INST(inst))

/**
* @brief Get a `DT_DRV_COMPAT`'s (only) irq priority
* @param inst instance number
* @return the interrupt priority for the node's only interrupt
*/
#define DT_INST_IRQP(inst) DT_IRQP(DT_DRV_INST(inst))

/**
* @brief Get a `DT_DRV_COMPAT`'s bus node identifier
* @param inst instance number
Expand Down

0 comments on commit 06635e6

Please sign in to comment.