]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * linux/arch/arm/mach-sa1100/irq.c | |
3 | * | |
4 | * Copyright (C) 1999-2001 Nicolas Pitre | |
5 | * | |
6 | * Generic IRQ handling for the SA11x0, GPIO 11-27 IRQ demultiplexing. | |
7 | * | |
8 | * This program is free software; you can redistribute it and/or modify | |
9 | * it under the terms of the GNU General Public License version 2 as | |
10 | * published by the Free Software Foundation. | |
11 | */ | |
12 | #include <linux/init.h> | |
13 | #include <linux/module.h> | |
119c641c | 14 | #include <linux/interrupt.h> |
3169663a | 15 | #include <linux/io.h> |
119c641c | 16 | #include <linux/irq.h> |
1eca42b4 | 17 | #include <linux/irqdomain.h> |
1da177e4 | 18 | #include <linux/ioport.h> |
90533980 | 19 | #include <linux/syscore_ops.h> |
1da177e4 | 20 | |
a657d7f6 DES |
21 | #include <soc/sa1100/pwer.h> |
22 | ||
a09e64fb | 23 | #include <mach/hardware.h> |
f314f33b | 24 | #include <mach/irqs.h> |
1da177e4 | 25 | #include <asm/mach/irq.h> |
affcab32 | 26 | #include <asm/exception.h> |
1da177e4 LT |
27 | |
28 | #include "generic.h" | |
29 | ||
30 | ||
ab71f99f DES |
31 | /* |
32 | * We don't need to ACK IRQs on the SA1100 unless they're GPIOs | |
33 | * this is for internal IRQs i.e. from IRQ LCD to RTCAlrm. | |
34 | */ | |
35 | static void sa1100_mask_irq(struct irq_data *d) | |
36 | { | |
37 | ICMR &= ~BIT(d->hwirq); | |
38 | } | |
39 | ||
40 | static void sa1100_unmask_irq(struct irq_data *d) | |
41 | { | |
42 | ICMR |= BIT(d->hwirq); | |
43 | } | |
44 | ||
ab71f99f DES |
45 | static int sa1100_set_wake(struct irq_data *d, unsigned int on) |
46 | { | |
a657d7f6 | 47 | return sa11x0_sc_set_wake(d->hwirq, on); |
ab71f99f DES |
48 | } |
49 | ||
50 | static struct irq_chip sa1100_normal_chip = { | |
51 | .name = "SC", | |
52 | .irq_ack = sa1100_mask_irq, | |
53 | .irq_mask = sa1100_mask_irq, | |
54 | .irq_unmask = sa1100_unmask_irq, | |
55 | .irq_set_wake = sa1100_set_wake, | |
56 | }; | |
57 | ||
58 | static int sa1100_normal_irqdomain_map(struct irq_domain *d, | |
59 | unsigned int irq, irq_hw_number_t hwirq) | |
60 | { | |
61 | irq_set_chip_and_handler(irq, &sa1100_normal_chip, | |
62 | handle_level_irq); | |
63 | set_irq_flags(irq, IRQF_VALID); | |
64 | ||
65 | return 0; | |
66 | } | |
67 | ||
68 | static struct irq_domain_ops sa1100_normal_irqdomain_ops = { | |
69 | .map = sa1100_normal_irqdomain_map, | |
70 | .xlate = irq_domain_xlate_onetwocell, | |
71 | }; | |
72 | ||
73 | static struct irq_domain *sa1100_normal_irqdomain; | |
74 | ||
a181099e RK |
75 | static struct resource irq_resource = |
76 | DEFINE_RES_MEM_NAMED(0x90050000, SZ_64K, "irqs"); | |
1da177e4 LT |
77 | |
78 | static struct sa1100irq_state { | |
79 | unsigned int saved; | |
80 | unsigned int icmr; | |
81 | unsigned int iclr; | |
82 | unsigned int iccr; | |
83 | } sa1100irq_state; | |
84 | ||
90533980 | 85 | static int sa1100irq_suspend(void) |
1da177e4 LT |
86 | { |
87 | struct sa1100irq_state *st = &sa1100irq_state; | |
88 | ||
89 | st->saved = 1; | |
90 | st->icmr = ICMR; | |
91 | st->iclr = ICLR; | |
92 | st->iccr = ICCR; | |
93 | ||
94 | /* | |
95 | * Disable all GPIO-based interrupts. | |
96 | */ | |
97 | ICMR &= ~(IC_GPIO11_27|IC_GPIO10|IC_GPIO9|IC_GPIO8|IC_GPIO7| | |
98 | IC_GPIO6|IC_GPIO5|IC_GPIO4|IC_GPIO3|IC_GPIO2| | |
99 | IC_GPIO1|IC_GPIO0); | |
100 | ||
1da177e4 LT |
101 | return 0; |
102 | } | |
103 | ||
90533980 | 104 | static void sa1100irq_resume(void) |
1da177e4 LT |
105 | { |
106 | struct sa1100irq_state *st = &sa1100irq_state; | |
107 | ||
108 | if (st->saved) { | |
109 | ICCR = st->iccr; | |
110 | ICLR = st->iclr; | |
111 | ||
1da177e4 LT |
112 | ICMR = st->icmr; |
113 | } | |
1da177e4 LT |
114 | } |
115 | ||
90533980 | 116 | static struct syscore_ops sa1100irq_syscore_ops = { |
1da177e4 LT |
117 | .suspend = sa1100irq_suspend, |
118 | .resume = sa1100irq_resume, | |
119 | }; | |
120 | ||
1da177e4 LT |
121 | static int __init sa1100irq_init_devicefs(void) |
122 | { | |
90533980 RW |
123 | register_syscore_ops(&sa1100irq_syscore_ops); |
124 | return 0; | |
1da177e4 LT |
125 | } |
126 | ||
127 | device_initcall(sa1100irq_init_devicefs); | |
128 | ||
affcab32 DES |
129 | static asmlinkage void __exception_irq_entry |
130 | sa1100_handle_irq(struct pt_regs *regs) | |
131 | { | |
132 | uint32_t icip, icmr, mask; | |
133 | ||
134 | do { | |
135 | icip = (ICIP); | |
136 | icmr = (ICMR); | |
137 | mask = icip & icmr; | |
138 | ||
139 | if (mask == 0) | |
140 | break; | |
141 | ||
364e3869 DES |
142 | handle_domain_irq(sa1100_normal_irqdomain, |
143 | ffs(mask) - 1, regs); | |
affcab32 DES |
144 | } while (1); |
145 | } | |
146 | ||
1da177e4 LT |
147 | void __init sa1100_init_irq(void) |
148 | { | |
1da177e4 LT |
149 | request_resource(&iomem_resource, &irq_resource); |
150 | ||
151 | /* disable all IRQs */ | |
152 | ICMR = 0; | |
153 | ||
154 | /* all IRQs are IRQ, not FIQ */ | |
155 | ICLR = 0; | |
156 | ||
1da177e4 LT |
157 | /* |
158 | * Whatever the doc says, this has to be set for the wait-on-irq | |
159 | * instruction to work... on a SA1100 rev 9 at least. | |
160 | */ | |
161 | ICCR = 1; | |
162 | ||
a82be3f0 DES |
163 | sa1100_normal_irqdomain = irq_domain_add_simple(NULL, |
164 | 32, IRQ_GPIO0_SC, | |
83508093 DES |
165 | &sa1100_normal_irqdomain_ops, NULL); |
166 | ||
affcab32 DES |
167 | set_handle_irq(sa1100_handle_irq); |
168 | ||
45528e38 | 169 | sa1100_init_gpio(); |
1da177e4 | 170 | } |