17 #include <linux/module.h>
18 #include <linux/sched.h>
20 #include <linux/ptrace.h>
25 #include <asm/cacheflush.h>
27 #include <mach/hardware.h>
40 static int msm_irq_debug_mask;
44 #define VIC_REG(off) (MSM_VIC_BASE + (off))
45 #define VIC_INT_TO_REG_ADDR(base, irq) (base + (irq / 32) * 4)
46 #define VIC_INT_TO_REG_INDEX(irq) ((irq >> 5) & 3)
48 #define VIC_INT_SELECT0 VIC_REG(0x0000)
49 #define VIC_INT_SELECT1 VIC_REG(0x0004)
50 #define VIC_INT_SELECT2 VIC_REG(0x0008)
51 #define VIC_INT_SELECT3 VIC_REG(0x000C)
52 #define VIC_INT_EN0 VIC_REG(0x0010)
53 #define VIC_INT_EN1 VIC_REG(0x0014)
54 #define VIC_INT_EN2 VIC_REG(0x0018)
55 #define VIC_INT_EN3 VIC_REG(0x001C)
56 #define VIC_INT_ENCLEAR0 VIC_REG(0x0020)
57 #define VIC_INT_ENCLEAR1 VIC_REG(0x0024)
58 #define VIC_INT_ENCLEAR2 VIC_REG(0x0028)
59 #define VIC_INT_ENCLEAR3 VIC_REG(0x002C)
60 #define VIC_INT_ENSET0 VIC_REG(0x0030)
61 #define VIC_INT_ENSET1 VIC_REG(0x0034)
62 #define VIC_INT_ENSET2 VIC_REG(0x0038)
63 #define VIC_INT_ENSET3 VIC_REG(0x003C)
64 #define VIC_INT_TYPE0 VIC_REG(0x0040)
65 #define VIC_INT_TYPE1 VIC_REG(0x0044)
66 #define VIC_INT_TYPE2 VIC_REG(0x0048)
67 #define VIC_INT_TYPE3 VIC_REG(0x004C)
68 #define VIC_INT_POLARITY0 VIC_REG(0x0050)
69 #define VIC_INT_POLARITY1 VIC_REG(0x0054)
70 #define VIC_INT_POLARITY2 VIC_REG(0x0058)
71 #define VIC_INT_POLARITY3 VIC_REG(0x005C)
72 #define VIC_NO_PEND_VAL VIC_REG(0x0060)
74 #if defined(CONFIG_ARCH_MSM_SCORPION)
75 #define VIC_NO_PEND_VAL_FIQ VIC_REG(0x0064)
76 #define VIC_INT_MASTEREN VIC_REG(0x0068)
77 #define VIC_CONFIG VIC_REG(0x006C)
79 #define VIC_INT_MASTEREN VIC_REG(0x0064)
80 #define VIC_PROTECTION VIC_REG(0x006C)
81 #define VIC_CONFIG VIC_REG(0x0068)
84 #define VIC_IRQ_STATUS0 VIC_REG(0x0080)
85 #define VIC_IRQ_STATUS1 VIC_REG(0x0084)
86 #define VIC_IRQ_STATUS2 VIC_REG(0x0088)
87 #define VIC_IRQ_STATUS3 VIC_REG(0x008C)
88 #define VIC_FIQ_STATUS0 VIC_REG(0x0090)
89 #define VIC_FIQ_STATUS1 VIC_REG(0x0094)
90 #define VIC_FIQ_STATUS2 VIC_REG(0x0098)
91 #define VIC_FIQ_STATUS3 VIC_REG(0x009C)
92 #define VIC_RAW_STATUS0 VIC_REG(0x00A0)
93 #define VIC_RAW_STATUS1 VIC_REG(0x00A4)
94 #define VIC_RAW_STATUS2 VIC_REG(0x00A8)
95 #define VIC_RAW_STATUS3 VIC_REG(0x00AC)
96 #define VIC_INT_CLEAR0 VIC_REG(0x00B0)
97 #define VIC_INT_CLEAR1 VIC_REG(0x00B4)
98 #define VIC_INT_CLEAR2 VIC_REG(0x00B8)
99 #define VIC_INT_CLEAR3 VIC_REG(0x00BC)
100 #define VIC_SOFTINT0 VIC_REG(0x00C0)
101 #define VIC_SOFTINT1 VIC_REG(0x00C4)
102 #define VIC_SOFTINT2 VIC_REG(0x00C8)
103 #define VIC_SOFTINT3 VIC_REG(0x00CC)
104 #define VIC_IRQ_VEC_RD VIC_REG(0x00D0)
105 #define VIC_IRQ_VEC_PEND_RD VIC_REG(0x00D4)
106 #define VIC_IRQ_VEC_WR VIC_REG(0x00D8)
108 #if defined(CONFIG_ARCH_MSM_SCORPION)
109 #define VIC_FIQ_VEC_RD VIC_REG(0x00DC)
110 #define VIC_FIQ_VEC_PEND_RD VIC_REG(0x00E0)
111 #define VIC_FIQ_VEC_WR VIC_REG(0x00E4)
112 #define VIC_IRQ_IN_SERVICE VIC_REG(0x00E8)
113 #define VIC_IRQ_IN_STACK VIC_REG(0x00EC)
114 #define VIC_FIQ_IN_SERVICE VIC_REG(0x00F0)
115 #define VIC_FIQ_IN_STACK VIC_REG(0x00F4)
116 #define VIC_TEST_BUS_SEL VIC_REG(0x00F8)
117 #define VIC_IRQ_CTRL_CONFIG VIC_REG(0x00FC)
119 #define VIC_IRQ_IN_SERVICE VIC_REG(0x00E0)
120 #define VIC_IRQ_IN_STACK VIC_REG(0x00E4)
121 #define VIC_TEST_BUS_SEL VIC_REG(0x00E8)
124 #define VIC_VECTPRIORITY(n) VIC_REG(0x0200+((n) * 4))
125 #define VIC_VECTADDR(n) VIC_REG(0x0400+((n) * 4))
127 #if defined(CONFIG_ARCH_MSM7X30)
128 #define VIC_NUM_REGS 4
130 #define VIC_NUM_REGS 2
133 #if VIC_NUM_REGS == 2
134 #define DPRINT_REGS(base_reg, format, ...) \
135 printk(KERN_INFO format " %x %x\n", ##__VA_ARGS__, \
136 readl(base_reg ## 0), readl(base_reg ## 1))
137 #define DPRINT_ARRAY(array, format, ...) \
138 printk(KERN_INFO format " %x %x\n", ##__VA_ARGS__, \
140 #elif VIC_NUM_REGS == 4
141 #define DPRINT_REGS(base_reg, format, ...) \
142 printk(KERN_INFO format " %x %x %x %x\n", ##__VA_ARGS__, \
143 readl(base_reg ## 0), readl(base_reg ## 1), \
144 readl(base_reg ## 2), readl(base_reg ## 3))
145 #define DPRINT_ARRAY(array, format, ...) \
146 printk(KERN_INFO format " %x %x %x %x\n", ##__VA_ARGS__, \
147 array[0], array[1], \
150 #error "VIC_NUM_REGS set to illegal value"
153 static uint32_t msm_irq_smsm_wake_enable[2];
162 #define SMSM_FAKE_IRQ (0xff)
187 #if !defined(CONFIG_ARCH_MSM7X30)
215 #ifdef CONFIG_ARCH_QSD8X50
221 static inline void msm_irq_write_all_regs(
void __iomem *base,
unsigned int val)
226 writel(val, base + (i * 4));
229 static void msm_irq_ack(
struct irq_data *
d)
235 static void msm_irq_mask(
struct irq_data *d)
240 int smsm_irq = msm_irq_to_smsm[d->
irq];
242 msm_irq_shadow_reg[
index].int_en[0] &= ~mask;
245 msm_irq_idle_disable[
index] &= ~mask;
247 mask = 1
UL << (smsm_irq - 1);
248 msm_irq_smsm_wake_enable[0] &= ~mask;
252 static void msm_irq_unmask(
struct irq_data *d)
257 int smsm_irq = msm_irq_to_smsm[d->
irq];
259 msm_irq_shadow_reg[
index].int_en[0] |=
mask;
265 mask = 1
UL << (smsm_irq - 1);
266 msm_irq_smsm_wake_enable[0] |=
mask;
270 static int msm_irq_set_wake(
struct irq_data *d,
unsigned int on)
274 int smsm_irq = msm_irq_to_smsm[d->
irq];
281 msm_irq_shadow_reg[
index].int_en[1] |=
mask;
283 msm_irq_shadow_reg[
index].int_en[1] &= ~mask;
288 mask = 1
UL << (smsm_irq - 1);
290 msm_irq_smsm_wake_enable[1] |=
mask;
292 msm_irq_smsm_wake_enable[1] &= ~mask;
296 static int msm_irq_set_type(
struct irq_data *d,
unsigned int flow_type)
301 int b = 1 << (d->
irq & 31);
305 polarity = msm_irq_shadow_reg[
index].int_polarity;
313 type = msm_irq_shadow_reg[
index].int_type;
323 msm_irq_shadow_reg[
index].int_type =
type;
327 static struct irq_chip msm_irq_chip = {
329 .irq_disable = msm_irq_mask,
330 .irq_ack = msm_irq_ack,
331 .irq_mask = msm_irq_mask,
332 .irq_unmask = msm_irq_unmask,
333 .irq_set_wake = msm_irq_set_wake,
334 .irq_set_type = msm_irq_set_type,