This source file includes following definitions.
- disable_systemasic_irq
- enable_systemasic_irq
- mask_ack_systemasic_irq
- systemasic_irq_demux
- systemasic_irq_init
1
2
3
4
5
6
7
8
9
10
11 #include <linux/irq.h>
12 #include <linux/io.h>
13 #include <linux/export.h>
14 #include <linux/err.h>
15 #include <mach/sysasic.h>
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45 #define ESR_BASE 0x005f6900
46 #define EMR_BASE 0x005f6910
47
48
49
50
51
52 #define LEVEL(event) (((event) - HW_EVENT_IRQ_BASE) / 32)
53
54
55 #define EVENT_BIT(event) (((event) - HW_EVENT_IRQ_BASE) & 31)
56
57
58
59
60
61
62
63 static inline void disable_systemasic_irq(struct irq_data *data)
64 {
65 unsigned int irq = data->irq;
66 __u32 emr = EMR_BASE + (LEVEL(irq) << 4) + (LEVEL(irq) << 2);
67 __u32 mask;
68
69 mask = inl(emr);
70 mask &= ~(1 << EVENT_BIT(irq));
71 outl(mask, emr);
72 }
73
74
75 static inline void enable_systemasic_irq(struct irq_data *data)
76 {
77 unsigned int irq = data->irq;
78 __u32 emr = EMR_BASE + (LEVEL(irq) << 4) + (LEVEL(irq) << 2);
79 __u32 mask;
80
81 mask = inl(emr);
82 mask |= (1 << EVENT_BIT(irq));
83 outl(mask, emr);
84 }
85
86
87 static void mask_ack_systemasic_irq(struct irq_data *data)
88 {
89 unsigned int irq = data->irq;
90 __u32 esr = ESR_BASE + (LEVEL(irq) << 2);
91 disable_systemasic_irq(data);
92 outl((1 << EVENT_BIT(irq)), esr);
93 }
94
95 struct irq_chip systemasic_int = {
96 .name = "System ASIC",
97 .irq_mask = disable_systemasic_irq,
98 .irq_mask_ack = mask_ack_systemasic_irq,
99 .irq_unmask = enable_systemasic_irq,
100 };
101
102
103
104
105 int systemasic_irq_demux(int irq)
106 {
107 __u32 emr, esr, status, level;
108 __u32 j, bit;
109
110 switch (irq) {
111 case 13:
112 level = 0;
113 break;
114 case 11:
115 level = 1;
116 break;
117 case 9:
118 level = 2;
119 break;
120 default:
121 return irq;
122 }
123 emr = EMR_BASE + (level << 4) + (level << 2);
124 esr = ESR_BASE + (level << 2);
125
126
127 status = inl(esr);
128 status &= inl(emr);
129
130
131 for (bit = 1, j = 0; j < 32; bit <<= 1, j++) {
132 if (status & bit) {
133 irq = HW_EVENT_IRQ_BASE + j + (level << 5);
134 return irq;
135 }
136 }
137
138
139 return irq;
140 }
141
142 void systemasic_irq_init(void)
143 {
144 int irq_base, i;
145
146 irq_base = irq_alloc_descs(HW_EVENT_IRQ_BASE, HW_EVENT_IRQ_BASE,
147 HW_EVENT_IRQ_MAX - HW_EVENT_IRQ_BASE, -1);
148 if (IS_ERR_VALUE(irq_base)) {
149 pr_err("%s: failed hooking irqs\n", __func__);
150 return;
151 }
152
153 for (i = HW_EVENT_IRQ_BASE; i < HW_EVENT_IRQ_MAX; i++)
154 irq_set_chip_and_handler(i, &systemasic_int, handle_level_irq);
155 }