1 #include <linux/sh_intc.h>
3 #include <linux/list.h>
4 #include <linux/kernel.h>
5 #include <linux/types.h>
6 #include <linux/radix-tree.h>
7 #include <linux/sysdev.h>
9 #define _INTC_MK(fn, mode, addr_e, addr_d, width, shift) \
10 ((shift) | ((width) << 5) | ((fn) << 9) | ((mode) << 13) | \
11 ((addr_e) << 16) | ((addr_d << 24)))
13 #define _INTC_SHIFT(h) (h & 0x1f)
14 #define _INTC_WIDTH(h) ((h >> 5) & 0xf)
15 #define _INTC_FN(h) ((h >> 9) & 0xf)
16 #define _INTC_MODE(h) ((h >> 13) & 0x7)
17 #define _INTC_ADDR_E(h) ((h >> 16) & 0xff)
18 #define _INTC_ADDR_D(h) ((h >> 24) & 0xff)
21 #define IS_SMP(x) (x.smp)
22 #define INTC_REG(d, x, c) (d->reg[(x)] + ((d->smp[(x)] & 0xff) * c))
23 #define SMP_NR(d, x) ((d->smp[(x)] >> 8) ? (d->smp[(x)] >> 8) : 1)
26 #define INTC_REG(d, x, c) (d->reg[(x)])
27 #define SMP_NR(d, x) 1
30 struct intc_handle_int
{
41 struct intc_map_entry
{
43 struct intc_desc_int
*desc
;
46 struct intc_subgroup_entry
{
52 struct intc_desc_int
{
53 struct list_head list
;
54 struct sys_device sysdev
;
55 struct radix_tree_root tree
;
63 struct intc_handle_int
*prio
;
65 struct intc_handle_int
*sense
;
66 unsigned int nr_sense
;
67 struct intc_window
*window
;
68 unsigned int nr_windows
;
76 REG_FN_WRITE_BASE
= 5,
77 REG_FN_MODIFY_BASE
= 9
80 enum { MODE_ENABLE_REG
= 0, /* Bit(s) set -> interrupt enabled */
81 MODE_MASK_REG
, /* Bit(s) set -> interrupt disabled */
82 MODE_DUAL_REG
, /* Two registers, set bit to enable / disable */
83 MODE_PRIO_REG
, /* Priority value written to enable interrupt */
84 MODE_PCLR_REG
, /* Above plus all bits set to disable interrupt */
87 static inline struct intc_desc_int
*get_intc_desc(unsigned int irq
)
89 struct irq_chip
*chip
= irq_get_chip(irq
);
91 return container_of(chip
, struct intc_desc_int
, chip
);
97 static inline void activate_irq(int irq
)
100 /* ARM requires an extra step to clear IRQ_NOREQUEST, which it
101 * sets on behalf of every irq_chip. Also sets IRQ_NOPROBE.
103 set_irq_flags(irq
, IRQF_VALID
);
105 /* same effect on other architectures */
106 irq_set_noprobe(irq
);
112 (*intc_reg_fns
[])(unsigned long addr
, unsigned long h
, unsigned long data
);
115 (*intc_enable_fns
[])(unsigned long addr
, unsigned long handle
,
116 unsigned long (*fn
)(unsigned long,
117 unsigned long, unsigned long),
120 (*intc_disable_fns
[])(unsigned long addr
, unsigned long handle
,
121 unsigned long (*fn
)(unsigned long,
122 unsigned long, unsigned long),
125 (*intc_enable_noprio_fns
[])(unsigned long addr
, unsigned long handle
,
126 unsigned long (*fn
)(unsigned long,
127 unsigned long, unsigned long),
130 unsigned long intc_phys_to_virt(struct intc_desc_int
*d
, unsigned long address
);
131 unsigned int intc_get_reg(struct intc_desc_int
*d
, unsigned long address
);
132 unsigned int intc_set_field_from_handle(unsigned int value
,
133 unsigned int field_value
,
134 unsigned int handle
);
135 unsigned long intc_get_field_from_handle(unsigned int value
,
136 unsigned int handle
);
139 #ifdef CONFIG_INTC_BALANCING
140 void intc_balancing_enable(unsigned int irq
);
141 void intc_balancing_disable(unsigned int irq
);
142 void intc_set_dist_handle(unsigned int irq
, struct intc_desc
*desc
,
143 struct intc_desc_int
*d
, intc_enum id
);
145 static inline void intc_balancing_enable(unsigned int irq
) { }
146 static inline void intc_balancing_disable(unsigned int irq
) { }
148 intc_set_dist_handle(unsigned int irq
, struct intc_desc
*desc
,
149 struct intc_desc_int
*d
, intc_enum id
) { }
153 extern struct irq_chip intc_irq_chip
;
154 void _intc_enable(struct irq_data
*data
, unsigned long handle
);
157 extern struct list_head intc_list
;
158 extern raw_spinlock_t intc_big_lock
;
159 extern unsigned int nr_intc_controllers
;
160 extern struct sysdev_class intc_sysdev_class
;
162 unsigned int intc_get_dfl_prio_level(void);
163 unsigned int intc_get_prio_level(unsigned int irq
);
164 void intc_set_prio_level(unsigned int irq
, unsigned int level
);
167 unsigned int intc_get_mask_handle(struct intc_desc
*desc
,
168 struct intc_desc_int
*d
,
169 intc_enum enum_id
, int do_grps
);
170 unsigned int intc_get_prio_handle(struct intc_desc
*desc
,
171 struct intc_desc_int
*d
,
172 intc_enum enum_id
, int do_grps
);
173 unsigned int intc_get_sense_handle(struct intc_desc
*desc
,
174 struct intc_desc_int
*d
,
176 void intc_set_ack_handle(unsigned int irq
, struct intc_desc
*desc
,
177 struct intc_desc_int
*d
, intc_enum id
);
178 unsigned long intc_get_ack_handle(unsigned int irq
);
179 void intc_enable_disable_enum(struct intc_desc
*desc
, struct intc_desc_int
*d
,
180 intc_enum enum_id
, int enable
);
183 void intc_subgroup_init(struct intc_desc
*desc
, struct intc_desc_int
*d
);
184 void intc_irq_xlate_set(unsigned int irq
, intc_enum id
, struct intc_desc_int
*d
);
185 struct intc_map_entry
*intc_irq_xlate_get(unsigned int irq
);