1 /* SPDX-License-Identifier: GPL-2.0 */
5 #include <linux/ioport.h>
8 #define INTC_NR_IRQS 512
10 #define INTC_NR_IRQS 1024
14 * Convert back and forth between INTEVT and IRQ values.
16 #ifdef CONFIG_CPU_HAS_INTEVT /* Avoid IRQ0 (invalid for platform devices) */
17 #define evt2irq(evt) ((evt) >> 5)
18 #define irq2evt(irq) ((irq) << 5)
20 #define evt2irq(evt) (evt)
21 #define irq2evt(irq) (irq)
24 typedef unsigned char intc_enum;
31 #define INTC_VECT(enum_id, vect) { enum_id, vect }
32 #define INTC_IRQ(enum_id, irq) INTC_VECT(enum_id, irq2evt(irq))
36 intc_enum enum_ids[32];
39 #define INTC_GROUP(enum_id, ids...) { enum_id, { ids } }
41 struct intc_subgroup {
42 unsigned long reg, reg_width;
44 intc_enum enum_ids[32];
47 struct intc_mask_reg {
48 unsigned long set_reg, clr_reg, reg_width;
49 intc_enum enum_ids[32];
50 #ifdef CONFIG_INTC_BALANCING
51 unsigned long dist_reg;
58 struct intc_prio_reg {
59 unsigned long set_reg, clr_reg, reg_width, field_width;
60 intc_enum enum_ids[16];
66 struct intc_sense_reg {
67 unsigned long reg, reg_width, field_width;
68 intc_enum enum_ids[16];
71 #ifdef CONFIG_INTC_BALANCING
72 #define INTC_SMP_BALANCING(reg) .dist_reg = (reg)
74 #define INTC_SMP_BALANCING(reg)
78 #define INTC_SMP(stride, nr) .smp = (stride) | ((nr) << 8)
80 #define INTC_SMP(stride, nr)
84 struct intc_vect *vectors;
85 unsigned int nr_vectors;
86 struct intc_group *groups;
87 unsigned int nr_groups;
88 struct intc_mask_reg *mask_regs;
89 unsigned int nr_mask_regs;
90 struct intc_prio_reg *prio_regs;
91 unsigned int nr_prio_regs;
92 struct intc_sense_reg *sense_regs;
93 unsigned int nr_sense_regs;
94 struct intc_mask_reg *ack_regs;
95 unsigned int nr_ack_regs;
96 struct intc_subgroup *subgroups;
97 unsigned int nr_subgroups;
100 #define _INTC_SIZEOF_OR_ZERO(a) (_Generic(a, \
103 #define _INTC_ARRAY(a) a, _INTC_SIZEOF_OR_ZERO(a)/sizeof(*a)
105 #define INTC_HW_DESC(vectors, groups, mask_regs, \
106 prio_regs, sense_regs, ack_regs) \
108 _INTC_ARRAY(vectors), _INTC_ARRAY(groups), \
109 _INTC_ARRAY(mask_regs), _INTC_ARRAY(prio_regs), \
110 _INTC_ARRAY(sense_regs), _INTC_ARRAY(ack_regs), \
115 struct resource *resource;
116 unsigned int num_resources;
117 intc_enum force_enable;
118 intc_enum force_disable;
119 bool skip_syscore_suspend;
120 struct intc_hw_desc hw;
123 #define DECLARE_INTC_DESC(symbol, chipname, vectors, groups, \
124 mask_regs, prio_regs, sense_regs) \
125 struct intc_desc symbol __initdata = { \
127 .hw = INTC_HW_DESC(vectors, groups, mask_regs, \
128 prio_regs, sense_regs, NULL), \
131 #define DECLARE_INTC_DESC_ACK(symbol, chipname, vectors, groups, \
132 mask_regs, prio_regs, sense_regs, ack_regs) \
133 struct intc_desc symbol __initdata = { \
135 .hw = INTC_HW_DESC(vectors, groups, mask_regs, \
136 prio_regs, sense_regs, ack_regs), \
139 int register_intc_controller(struct intc_desc *desc);
140 int intc_set_priority(unsigned int irq, unsigned int prio);
141 int intc_irq_lookup(const char *chipname, intc_enum enum_id);
142 void intc_finalize(void);
144 #ifdef CONFIG_INTC_USERIMASK
145 int register_intc_userimask(unsigned long addr);
147 static inline int register_intc_userimask(unsigned long addr)
153 #endif /* __SH_INTC_H */