Skip to content

Commit 77a823b

Browse files
committed
drivers: intc_dw: support multiple instances
Update the initializers to support platforms with multiple instances of the DesignWare interrupt aggregator. Also ensure that the initialize function calls irq_enable(). The calculation of the _sw_isr_table entry also now takes CONFIG_GEN_IRQ_START_VECTOR into account. Signed-off-by: Aaron Fong <afong@tenstorrent.com>
1 parent bb20f35 commit 77a823b

File tree

2 files changed

+27
-26
lines changed

2 files changed

+27
-26
lines changed

drivers/interrupt_controller/intc_dw.c

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ static ALWAYS_INLINE void dw_ictl_dispatch_child_isrs(uint32_t intr_status,
3030
while (intr_status) {
3131
intr_bitpos = find_lsb_set(intr_status) - 1;
3232
intr_status &= ~(1 << intr_bitpos);
33-
intr_offset = isr_base_offset + intr_bitpos;
33+
intr_offset = isr_base_offset + intr_bitpos - CONFIG_GEN_IRQ_START_VECTOR;
3434
_sw_isr_table[intr_offset].isr(
3535
_sw_isr_table[intr_offset].arg);
3636
}
@@ -46,6 +46,8 @@ static int dw_ictl_initialize(const struct device *dev)
4646
regs->irq_inten_l = 0U;
4747
regs->irq_inten_h = 0U;
4848

49+
config->config_func();
50+
4951
return 0;
5052
}
5153

@@ -130,34 +132,33 @@ static int dw_ictl_intr_get_line_state(const struct device *dev,
130132
return 0;
131133
}
132134

133-
static void dw_ictl_config_irq(const struct device *dev);
134-
135-
static const struct dw_ictl_config dw_config = {
136-
.base_addr = DT_INST_REG_ADDR(0),
137-
.numirqs = DT_INST_PROP(0, num_irqs),
138-
.isr_table_offset = CONFIG_DW_ISR_TBL_OFFSET,
139-
.config_func = dw_ictl_config_irq,
140-
};
141-
142135
static const struct irq_next_level_api dw_ictl_apis = {
143136
.intr_enable = dw_ictl_intr_enable,
144137
.intr_disable = dw_ictl_intr_disable,
145138
.intr_get_state = dw_ictl_intr_get_state,
146139
.intr_get_line_state = dw_ictl_intr_get_line_state,
147140
};
148141

149-
DEVICE_DT_INST_DEFINE(0, dw_ictl_initialize, NULL,
150-
NULL, &dw_config, PRE_KERNEL_1,
151-
CONFIG_DW_ICTL_INIT_PRIORITY, &dw_ictl_apis);
152-
153-
static void dw_ictl_config_irq(const struct device *port)
154-
{
155-
IRQ_CONNECT(DT_INST_IRQN(0),
156-
DT_INST_IRQ(0, priority),
157-
dw_ictl_isr,
158-
DEVICE_DT_INST_GET(0),
159-
DT_INST_IRQ(0, sense));
160-
}
161-
162-
IRQ_PARENT_ENTRY_DEFINE(intc_dw, DEVICE_DT_INST_GET(0), DT_INST_IRQN(0),
163-
INTC_INST_ISR_TBL_OFFSET(0), DT_INST_INTC_GET_AGGREGATOR_LEVEL(0));
142+
#define INTC_DW_DEVICE_INIT(inst) \
143+
\
144+
static void dw_ictl_config_irq_##inst(void) \
145+
{ \
146+
IRQ_CONNECT(DT_INST_IRQN(inst), DT_INST_IRQ(inst, priority), dw_ictl_isr, \
147+
DEVICE_DT_INST_GET(inst), DT_INST_IRQ(inst, sense)); \
148+
irq_enable(DT_INST_IRQN(inst)); \
149+
} \
150+
IRQ_PARENT_ENTRY_DEFINE(intc_dw##inst, DEVICE_DT_INST_GET(inst), DT_INST_IRQN(inst), \
151+
INTC_INST_ISR_TBL_OFFSET(inst), \
152+
DT_INST_INTC_GET_AGGREGATOR_LEVEL(inst)); \
153+
\
154+
static const struct dw_ictl_config dw_config_##inst = { \
155+
.base_addr = DT_INST_REG_ADDR(inst), \
156+
.numirqs = DT_INST_PROP(inst, num_irqs), \
157+
.isr_table_offset = INTC_INST_ISR_TBL_OFFSET(inst), \
158+
.config_func = dw_ictl_config_irq_##inst, \
159+
}; \
160+
\
161+
DEVICE_DT_INST_DEFINE(inst, dw_ictl_initialize, NULL, NULL, &dw_config_##inst, \
162+
PRE_KERNEL_1, CONFIG_DW_ICTL_INIT_PRIORITY, &dw_ictl_apis);
163+
164+
DT_INST_FOREACH_STATUS_OKAY(INTC_DW_DEVICE_INIT)

drivers/interrupt_controller/intc_dw.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
extern "C" {
1414
#endif
1515

16-
typedef void (*dw_ictl_config_irq_t)(const struct device *dev);
16+
typedef void (*dw_ictl_config_irq_t)(void);
1717

1818
struct dw_ictl_config {
1919
uint32_t base_addr;

0 commit comments

Comments
 (0)