Secondary interrupt controller class.
More...
|
| #define | PBL_INTC_STATE_DEFINE(sym, _num_irqs) |
| | Define the class state of interrupt controller sym, for the driver's define macro.
|
| |
| #define | PBL_INTC_INIT(sym, _name, _init, _parent, _ops) |
| | Initializer for the struct pbl_intc of controller sym.
|
| |
| #define | PBL_IRQ_SPEC(_intc, _hwirq, _type) {.intc = (_intc), .hwirq = (_hwirq), .type = (_type)} |
| | Initializer for a struct pbl_irq_spec.
|
| |
Secondary interrupt controller class.
A secondary interrupt controller, a GPIO port or a peripheral that funnels several interrupt sources into one SoC line, is a struct pbl_intc device. SoC lines themselves are bound at build time with PBL_IRQ_CONNECT() (see Interrupts) and are not part of this class.
A consumer holds a struct pbl_irq_spec naming the controller, the line on it and its trigger type, as wired on the board, and lists the controller among its device dependencies. It requests the line once and enables it while it wants interrupts:
static void prv_int1_handler(void *arg) {
}
#define SF32LB_GPIO1_INTC
Interrupt controller of port GPIO1.
Definition sf32lb.h:48
int pbl_intc_enable(const struct pbl_irq_spec *spec)
Enable a requested line.
#define PBL_IRQ_TYPE_EDGE_RISING
Rising edge.
Definition intc.h:46
int pbl_intc_request(const struct pbl_irq_spec *spec, pbl_intc_handler_t handler, void *arg)
Install the handler of a line and set its trigger type.
#define PBL_IRQ_SPEC(_intc, _hwirq, _type)
Initializer for a struct pbl_irq_spec.
Definition intc.h:144
The controller driver calls pbl_intc_dispatch() from its SoC interrupt handler for each pending line.
◆ pbl_intc_line
| Data Fields |
|
void * |
arg |
Handler argument. |
|
bool |
enabled |
Whether the line is enabled. |
|
pbl_intc_handler_t |
handler |
Handler, NULL if the line is free. |
|
uint8_t |
type |
Trigger type. |
◆ pbl_intc
| Data Fields |
|
struct pbl_device |
dev |
Device. |
|
struct pbl_intc_line * |
lines |
State of each line. |
|
uint16_t |
num_irqs |
Number of lines. |
|
const struct pbl_intc_ops * |
ops |
Driver operations. |
◆ pbl_irq_spec
An interrupt line, as used by a consumer.
| Data Fields |
|
uint16_t |
hwirq |
Line number on the controller. |
|
const struct pbl_intc * |
intc |
Controller, NULL if not connected. |
|
uint8_t |
type |
Trigger type. |
◆ PBL_INTC_INIT
| #define PBL_INTC_INIT |
( |
|
sym, |
|
|
|
_name, |
|
|
|
_init, |
|
|
|
_parent, |
|
|
|
_ops |
|
) |
| |
Value: { \
.ops = (_ops), \
.lines = sym##_intc_lines, \
}
#define PBL_DEVICE_INIT_CLASS(sym, _name, _init, _parent, _deps, _cls)
Initializer for the struct pbl_device of device instance sym, in class _cls.
Definition device.h:123
const struct pbl_device_class pbl_intc_class
Class of the interrupt controllers.
#define ARRAY_LENGTH(array)
Calculate the length of an array, based on the size of the element type.
Definition size.h:18
Initializer for the struct pbl_intc of controller sym.
- Parameters
-
| sym | Symbol of the controller instance, with its state defined by PBL_INTC_STATE_DEFINE(). |
| _name | Name. |
| _init | Device init function, or NULL. |
| _parent | Parent device, or NULL. |
| _ops | Driver operations. |
◆ PBL_INTC_STATE_DEFINE
| #define PBL_INTC_STATE_DEFINE |
( |
|
sym, |
|
|
|
_num_irqs |
|
) |
| |
Value:
#define PBL_DEVICE_STATE_DEFINE(sym)
Define the runtime state of device instance sym.
Definition device.h:109
Runtime state of a line.
Definition intc.h:76
Define the class state of interrupt controller sym, for the driver's define macro.
- Parameters
-
| sym | Symbol of the controller instance. |
| _num_irqs | Number of lines. |
◆ PBL_IRQ_SPEC
| #define PBL_IRQ_SPEC |
( |
|
_intc, |
|
|
|
_hwirq, |
|
|
|
_type |
|
) |
| {.intc = (_intc), .hwirq = (_hwirq), .type = (_type)} |
Initializer for a struct pbl_irq_spec.
- Parameters
-
| _intc | Interrupt controller. |
| _hwirq | Line number on the controller. |
| _type | Trigger type. |
◆ PBL_IRQ_TYPE_EDGE_BOTH
◆ PBL_IRQ_TYPE_EDGE_FALLING
| #define PBL_IRQ_TYPE_EDGE_FALLING 2U |
◆ PBL_IRQ_TYPE_EDGE_RISING
| #define PBL_IRQ_TYPE_EDGE_RISING 1U |
◆ PBL_IRQ_TYPE_LEVEL_HIGH
| #define PBL_IRQ_TYPE_LEVEL_HIGH 4U |
◆ PBL_IRQ_TYPE_LEVEL_LOW
| #define PBL_IRQ_TYPE_LEVEL_LOW 8U |
◆ pbl_intc_handler_t
| typedef void(* pbl_intc_handler_t) (void *arg) |
Line handler, called in ISR context.
◆ pbl_intc_disable()
Disable a requested line.
- Parameters
-
- Returns
- 0,
-EINVAL if the line is not requested, or another negative errno.
◆ pbl_intc_dispatch()
| void pbl_intc_dispatch |
( |
const struct pbl_intc * |
intc, |
|
|
uint32_t |
hwirq |
|
) |
| |
Run the handler of a pending line, for the controller driver.
A line without a handler is disabled.
- Parameters
-
| intc | Controller. |
| hwirq | Pending line. |
◆ pbl_intc_enable()
Enable a requested line.
- Parameters
-
- Returns
- 0,
-EINVAL if the line is not requested, or another negative errno.
◆ pbl_intc_free()
Disable a line and remove its handler.
- Parameters
-
- Returns
- 0,
-EINVAL if the line is not requested, or another negative errno.
◆ pbl_intc_request()
Install the handler of a line and set its trigger type.
The line is left disabled.
- Parameters
-
| spec | Line, on a ready controller. |
| handler | Handler, called in ISR context. |
| arg | Handler argument. |
- Returns
- 0,
-EBUSY if the line is already requested, -EINVAL for an invalid line or type, -ENOTSUP if the controller does not support the type, or another negative errno.
◆ pbl_irq_spec_is_connected()
| static bool pbl_irq_spec_is_connected |
( |
const struct pbl_irq_spec * |
spec | ) |
|
|
inlinestatic |
Check whether an interrupt line is connected.
- Parameters
-
- Returns
- True if the line has a controller.
References pbl_irq_spec::intc.
◆ pbl_intc_class
Class of the interrupt controllers.