blob: 0d6cd38e673ddb2486711517047a3c7fd544ad14 [file] [log] [blame]
Paul Mundtbbfbd8b2008-10-01 16:13:54 +09001#ifndef __SH_INTC_H
2#define __SH_INTC_H
3
Magnus Dammdec710b2010-03-19 16:48:01 +09004#include <linux/ioport.h>
5
Paul Mundtbbfbd8b2008-10-01 16:13:54 +09006typedef unsigned char intc_enum;
7
8struct intc_vect {
9 intc_enum enum_id;
10 unsigned short vect;
11};
12
13#define INTC_VECT(enum_id, vect) { enum_id, vect }
14#define INTC_IRQ(enum_id, irq) INTC_VECT(enum_id, irq2evt(irq))
15
16struct intc_group {
17 intc_enum enum_id;
18 intc_enum enum_ids[32];
19};
20
21#define INTC_GROUP(enum_id, ids...) { enum_id, { ids } }
22
23struct intc_mask_reg {
24 unsigned long set_reg, clr_reg, reg_width;
25 intc_enum enum_ids[32];
Paul Mundtdc825b12010-04-15 13:13:52 +090026#ifdef CONFIG_INTC_BALANCING
27 unsigned long dist_reg;
28#endif
Paul Mundtbbfbd8b2008-10-01 16:13:54 +090029#ifdef CONFIG_SMP
30 unsigned long smp;
31#endif
32};
33
34struct intc_prio_reg {
35 unsigned long set_reg, clr_reg, reg_width, field_width;
36 intc_enum enum_ids[16];
37#ifdef CONFIG_SMP
38 unsigned long smp;
39#endif
40};
41
42struct intc_sense_reg {
43 unsigned long reg, reg_width, field_width;
44 intc_enum enum_ids[16];
45};
46
Paul Mundtdc825b12010-04-15 13:13:52 +090047#ifdef CONFIG_INTC_BALANCING
48#define INTC_SMP_BALANCING(reg) .dist_reg = (reg)
49#else
50#define INTC_SMP_BALANCING(reg)
51#endif
52
Paul Mundtbbfbd8b2008-10-01 16:13:54 +090053#ifdef CONFIG_SMP
Paul Mundtdc825b12010-04-15 13:13:52 +090054#define INTC_SMP(stride, nr) .smp = (stride) | ((nr) << 8)
Paul Mundtbbfbd8b2008-10-01 16:13:54 +090055#else
56#define INTC_SMP(stride, nr)
57#endif
58
Magnus Damm577cd752010-02-09 04:24:46 +000059struct intc_hw_desc {
Paul Mundtbbfbd8b2008-10-01 16:13:54 +090060 struct intc_vect *vectors;
61 unsigned int nr_vectors;
62 struct intc_group *groups;
63 unsigned int nr_groups;
64 struct intc_mask_reg *mask_regs;
65 unsigned int nr_mask_regs;
66 struct intc_prio_reg *prio_regs;
67 unsigned int nr_prio_regs;
68 struct intc_sense_reg *sense_regs;
69 unsigned int nr_sense_regs;
Paul Mundtbbfbd8b2008-10-01 16:13:54 +090070 struct intc_mask_reg *ack_regs;
71 unsigned int nr_ack_regs;
Paul Mundtbbfbd8b2008-10-01 16:13:54 +090072};
73
74#define _INTC_ARRAY(a) a, sizeof(a)/sizeof(*a)
Magnus Damm577cd752010-02-09 04:24:46 +000075#define INTC_HW_DESC(vectors, groups, mask_regs, \
76 prio_regs, sense_regs, ack_regs) \
77{ \
78 _INTC_ARRAY(vectors), _INTC_ARRAY(groups), \
79 _INTC_ARRAY(mask_regs), _INTC_ARRAY(prio_regs), \
80 _INTC_ARRAY(sense_regs), _INTC_ARRAY(ack_regs), \
81}
82
83struct intc_desc {
84 char *name;
Magnus Dammdec710b2010-03-19 16:48:01 +090085 struct resource *resource;
86 unsigned int num_resources;
Magnus Dammd5190952010-02-09 04:29:22 +000087 intc_enum force_enable;
Magnus Dammd85429a2010-02-15 11:40:25 +000088 intc_enum force_disable;
Magnus Damm577cd752010-02-09 04:24:46 +000089 struct intc_hw_desc hw;
90};
91
Paul Mundtbbfbd8b2008-10-01 16:13:54 +090092#define DECLARE_INTC_DESC(symbol, chipname, vectors, groups, \
93 mask_regs, prio_regs, sense_regs) \
94struct intc_desc symbol __initdata = { \
Magnus Damm577cd752010-02-09 04:24:46 +000095 .name = chipname, \
96 .hw = INTC_HW_DESC(vectors, groups, mask_regs, \
97 prio_regs, sense_regs, NULL), \
Paul Mundtbbfbd8b2008-10-01 16:13:54 +090098}
99
Paul Mundtbbfbd8b2008-10-01 16:13:54 +0900100#define DECLARE_INTC_DESC_ACK(symbol, chipname, vectors, groups, \
101 mask_regs, prio_regs, sense_regs, ack_regs) \
102struct intc_desc symbol __initdata = { \
Magnus Damm577cd752010-02-09 04:24:46 +0000103 .name = chipname, \
104 .hw = INTC_HW_DESC(vectors, groups, mask_regs, \
105 prio_regs, sense_regs, ack_regs), \
Paul Mundtbbfbd8b2008-10-01 16:13:54 +0900106}
Paul Mundtbbfbd8b2008-10-01 16:13:54 +0900107
Magnus Damm01e96512010-03-10 09:31:01 +0000108int __init register_intc_controller(struct intc_desc *desc);
Paul Mundtbbfbd8b2008-10-01 16:13:54 +0900109int intc_set_priority(unsigned int irq, unsigned int prio);
110
Paul Mundt43b87742010-04-13 14:43:03 +0900111#ifdef CONFIG_INTC_USERIMASK
112int register_intc_userimask(unsigned long addr);
113#else
114static inline int register_intc_userimask(unsigned long addr)
115{
116 return 0;
117}
118#endif
119
Paul Mundt45b9dea2009-11-02 15:43:20 +0900120int reserve_irq_vector(unsigned int irq);
121void reserve_irq_legacy(void);
122
Paul Mundtbbfbd8b2008-10-01 16:13:54 +0900123#endif /* __SH_INTC_H */