blob: c958fdaa00957ec835f2b7b1803baef4f5eb12d7 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef __ASM_SH_HW_IRQ_H
2#define __ASM_SH_HW_IRQ_H
3
Magnus Damm02ab3f72007-07-18 17:25:09 +09004#include <linux/init.h>
Paul Mundt35f3c512006-10-06 15:31:16 +09005#include <asm/atomic.h>
6
7extern atomic_t irq_err_count;
8
Magnus Damm68abdbb2007-06-15 18:56:19 +09009struct ipr_data {
10 unsigned char irq;
11 unsigned char ipr_idx; /* Index for the IPR registered */
12 unsigned char shift; /* Number of bits to shift the data */
13 unsigned char priority; /* The priority */
14};
15
16struct ipr_desc {
17 unsigned long *ipr_offsets;
18 unsigned int nr_offsets;
19 struct ipr_data *ipr_data;
20 unsigned int nr_irqs;
21 struct irq_chip chip;
22};
23
24void register_ipr_controller(struct ipr_desc *);
Magnus Damm68abdbb2007-06-15 18:56:19 +090025
Magnus Damm02ab3f72007-07-18 17:25:09 +090026typedef unsigned char intc_enum;
27
28struct intc_vect {
29 intc_enum enum_id;
30 unsigned short vect;
31};
32
33#define INTC_VECT(enum_id, vect) { enum_id, vect }
Magnus Damm51da6422007-08-03 14:25:32 +090034#define INTC_IRQ(enum_id, irq) INTC_VECT(enum_id, irq2evt(irq))
Magnus Damm02ab3f72007-07-18 17:25:09 +090035
Magnus Damm02ab3f72007-07-18 17:25:09 +090036struct intc_group {
37 intc_enum enum_id;
Magnus Damm5c37e022007-08-17 00:45:35 +090038 intc_enum enum_ids[32];
Magnus Damm02ab3f72007-07-18 17:25:09 +090039};
40
Magnus Damm5c37e022007-08-17 00:45:35 +090041#define INTC_GROUP(enum_id, ids...) { enum_id, { ids } }
Magnus Damm02ab3f72007-07-18 17:25:09 +090042
43struct intc_mask_reg {
44 unsigned long set_reg, clr_reg, reg_width;
45 intc_enum enum_ids[32];
Magnus Dammf18d5332007-09-21 18:16:42 +090046#ifdef CONFIG_SMP
47 unsigned long smp;
48#endif
Magnus Damm02ab3f72007-07-18 17:25:09 +090049};
50
51struct intc_prio_reg {
Magnus Damm6ef5fb22007-08-12 15:22:02 +090052 unsigned long set_reg, clr_reg, reg_width, field_width;
Magnus Damm02ab3f72007-07-18 17:25:09 +090053 intc_enum enum_ids[16];
Magnus Dammf18d5332007-09-21 18:16:42 +090054#ifdef CONFIG_SMP
55 unsigned long smp;
56#endif
Magnus Damm02ab3f72007-07-18 17:25:09 +090057};
58
59struct intc_sense_reg {
60 unsigned long reg, reg_width, field_width;
61 intc_enum enum_ids[16];
62};
63
Magnus Dammf18d5332007-09-21 18:16:42 +090064#ifdef CONFIG_SMP
65#define INTC_SMP(stride, nr) .smp = (stride) | ((nr) << 8)
66#else
67#define INTC_SMP(stride, nr)
68#endif
69
Magnus Damm02ab3f72007-07-18 17:25:09 +090070struct intc_desc {
71 struct intc_vect *vectors;
72 unsigned int nr_vectors;
73 struct intc_group *groups;
74 unsigned int nr_groups;
Magnus Damm02ab3f72007-07-18 17:25:09 +090075 struct intc_mask_reg *mask_regs;
76 unsigned int nr_mask_regs;
77 struct intc_prio_reg *prio_regs;
78 unsigned int nr_prio_regs;
79 struct intc_sense_reg *sense_regs;
80 unsigned int nr_sense_regs;
Magnus Damm73505b42007-08-12 15:26:12 +090081 char *name;
Magnus Damm02ab3f72007-07-18 17:25:09 +090082};
83
84#define _INTC_ARRAY(a) a, sizeof(a)/sizeof(*a)
85#define DECLARE_INTC_DESC(symbol, chipname, vectors, groups, \
Magnus Damm7f3edee2008-01-10 14:08:55 +090086 mask_regs, prio_regs, sense_regs) \
Magnus Damm5c37e022007-08-17 00:45:35 +090087struct intc_desc symbol __initdata = { \
Magnus Damm02ab3f72007-07-18 17:25:09 +090088 _INTC_ARRAY(vectors), _INTC_ARRAY(groups), \
Magnus Damm02ab3f72007-07-18 17:25:09 +090089 _INTC_ARRAY(mask_regs), _INTC_ARRAY(prio_regs), \
90 _INTC_ARRAY(sense_regs), \
Magnus Damm73505b42007-08-12 15:26:12 +090091 chipname, \
Magnus Damm02ab3f72007-07-18 17:25:09 +090092}
93
94void __init register_intc_controller(struct intc_desc *desc);
Magnus Damm3d37d942007-08-17 00:50:44 +090095int intc_set_priority(unsigned int irq, unsigned int prio);
Magnus Damm02ab3f72007-07-18 17:25:09 +090096
Magnus Damm90015c82007-07-18 17:57:34 +090097void __init plat_irq_setup(void);
98
Magnus Damma0e23262007-07-31 17:11:21 +090099enum { IRQ_MODE_IRQ, IRQ_MODE_IRQ7654, IRQ_MODE_IRQ3210,
Magnus Damm953c8ef2007-09-10 12:03:50 +0900100 IRQ_MODE_IRL7654_MASK, IRQ_MODE_IRL3210_MASK,
Magnus Damma0e23262007-07-31 17:11:21 +0900101 IRQ_MODE_IRL7654, IRQ_MODE_IRL3210 };
Magnus Damm39c7aa92007-07-20 12:10:29 +0900102void __init plat_irq_setup_pins(int mode);
103
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104#endif /* __ASM_SH_HW_IRQ_H */