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
17 #define evt2irq(evt) (((evt) >> 5) - 16)
18 #define irq2evt(irq) (((irq) + 16) << 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_ARRAY(a) a, __same_type(a, NULL) ? 0 : sizeof(a)/sizeof(*a)
102 #define INTC_HW_DESC(vectors, groups, mask_regs, \
103 prio_regs, sense_regs, ack_regs) \
105 _INTC_ARRAY(vectors), _INTC_ARRAY(groups), \
106 _INTC_ARRAY(mask_regs), _INTC_ARRAY(prio_regs), \
107 _INTC_ARRAY(sense_regs), _INTC_ARRAY(ack_regs), \
112 struct resource
*resource
;
113 unsigned int num_resources
;
114 intc_enum force_enable
;
115 intc_enum force_disable
;
116 bool skip_syscore_suspend
;
117 struct intc_hw_desc hw
;
120 #define DECLARE_INTC_DESC(symbol, chipname, vectors, groups, \
121 mask_regs, prio_regs, sense_regs) \
122 struct intc_desc symbol __initdata = { \
124 .hw = INTC_HW_DESC(vectors, groups, mask_regs, \
125 prio_regs, sense_regs, NULL), \
128 #define DECLARE_INTC_DESC_ACK(symbol, chipname, vectors, groups, \
129 mask_regs, prio_regs, sense_regs, ack_regs) \
130 struct intc_desc symbol __initdata = { \
132 .hw = INTC_HW_DESC(vectors, groups, mask_regs, \
133 prio_regs, sense_regs, ack_regs), \
136 int register_intc_controller(struct intc_desc
*desc
);
137 int intc_set_priority(unsigned int irq
, unsigned int prio
);
138 int intc_irq_lookup(const char *chipname
, intc_enum enum_id
);
139 void intc_finalize(void);
141 #ifdef CONFIG_INTC_USERIMASK
142 int register_intc_userimask(unsigned long addr
);
144 static inline int register_intc_userimask(unsigned long addr
)
150 #endif /* __SH_INTC_H */