Deleted Added
full compact
lpc_intc.c (261410) lpc_intc.c (276023)
1/*-
2 * Copyright (c) 2010 Jakub Wojciech Klama <jceel@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 12 unchanged lines hidden (view full) ---

21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 */
27
28#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2010 Jakub Wojciech Klama <jceel@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 12 unchanged lines hidden (view full) ---

21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 */
27
28#include <sys/cdefs.h>
29__FBSDID("$FreeBSD: head/sys/arm/lpc/lpc_intc.c 261410 2014-02-02 19:17:28Z ian $");
29__FBSDID("$FreeBSD: head/sys/arm/lpc/lpc_intc.c 276023 2014-12-21 16:59:41Z andrew $");
30
31#include <sys/param.h>
32#include <sys/systm.h>
33#include <sys/bus.h>
34#include <sys/kernel.h>
35#include <sys/module.h>
36#include <sys/malloc.h>
37#include <sys/rman.h>

--- 16 unchanged lines hidden (view full) ---

54};
55
56static int lpc_intc_probe(device_t);
57static int lpc_intc_attach(device_t);
58static void lpc_intc_eoi(void *);
59
60static struct lpc_intc_softc *intc_softc = NULL;
61
30
31#include <sys/param.h>
32#include <sys/systm.h>
33#include <sys/bus.h>
34#include <sys/kernel.h>
35#include <sys/module.h>
36#include <sys/malloc.h>
37#include <sys/rman.h>

--- 16 unchanged lines hidden (view full) ---

54};
55
56static int lpc_intc_probe(device_t);
57static int lpc_intc_attach(device_t);
58static void lpc_intc_eoi(void *);
59
60static struct lpc_intc_softc *intc_softc = NULL;
61
62#define intc_read_4(reg) \
63 bus_space_read_4(intc_softc->li_bst, intc_softc->li_bsh, reg)
64#define intc_write_4(reg, val) \
65 bus_space_write_4(intc_softc->li_bst, intc_softc->li_bsh, reg, val)
62#define intc_read_4(_sc, _reg) \
63 bus_space_read_4((_sc)->li_bst, (_sc)->li_bsh, (_reg))
64#define intc_write_4(_sc, _reg, _val) \
65 bus_space_write_4((_sc)->li_bst, (_sc)->li_bsh, (_reg), (_val))
66
67static int
68lpc_intc_probe(device_t dev)
69{
70
71 if (!ofw_bus_status_okay(dev))
72 return (ENXIO);
73

--- 21 unchanged lines hidden (view full) ---

95 }
96
97 sc->li_bst = rman_get_bustag(sc->li_res);
98 sc->li_bsh = rman_get_bushandle(sc->li_res);
99 intc_softc = sc;
100 arm_post_filter = lpc_intc_eoi;
101
102 /* Clear interrupt status registers and disable all interrupts */
66
67static int
68lpc_intc_probe(device_t dev)
69{
70
71 if (!ofw_bus_status_okay(dev))
72 return (ENXIO);
73

--- 21 unchanged lines hidden (view full) ---

95 }
96
97 sc->li_bst = rman_get_bustag(sc->li_res);
98 sc->li_bsh = rman_get_bushandle(sc->li_res);
99 intc_softc = sc;
100 arm_post_filter = lpc_intc_eoi;
101
102 /* Clear interrupt status registers and disable all interrupts */
103 intc_write_4(LPC_INTC_MIC_ER, 0);
104 intc_write_4(LPC_INTC_SIC1_ER, 0);
105 intc_write_4(LPC_INTC_SIC2_ER, 0);
106 intc_write_4(LPC_INTC_MIC_RSR, ~0);
107 intc_write_4(LPC_INTC_SIC1_RSR, ~0);
108 intc_write_4(LPC_INTC_SIC2_RSR, ~0);
103 intc_write_4(sc, LPC_INTC_MIC_ER, 0);
104 intc_write_4(sc, LPC_INTC_SIC1_ER, 0);
105 intc_write_4(sc, LPC_INTC_SIC2_ER, 0);
106 intc_write_4(sc, LPC_INTC_MIC_RSR, ~0);
107 intc_write_4(sc, LPC_INTC_SIC1_RSR, ~0);
108 intc_write_4(sc, LPC_INTC_SIC2_RSR, ~0);
109 return (0);
110}
111
112static device_method_t lpc_intc_methods[] = {
113 DEVMETHOD(device_probe, lpc_intc_probe),
114 DEVMETHOD(device_attach, lpc_intc_attach),
115 { 0, 0 }
116};

--- 6 unchanged lines hidden (view full) ---

123
124static devclass_t lpc_intc_devclass;
125
126DRIVER_MODULE(pic, simplebus, lpc_intc_driver, lpc_intc_devclass, 0, 0);
127
128int
129arm_get_next_irq(int last)
130{
109 return (0);
110}
111
112static device_method_t lpc_intc_methods[] = {
113 DEVMETHOD(device_probe, lpc_intc_probe),
114 DEVMETHOD(device_attach, lpc_intc_attach),
115 { 0, 0 }
116};

--- 6 unchanged lines hidden (view full) ---

123
124static devclass_t lpc_intc_devclass;
125
126DRIVER_MODULE(pic, simplebus, lpc_intc_driver, lpc_intc_devclass, 0, 0);
127
128int
129arm_get_next_irq(int last)
130{
131 struct lpc_intc_softc *sc = intc_softc;
131 uint32_t value;
132 int i;
133
134 /* IRQs 0-31 are mapped to LPC_INTC_MIC_SR */
132 uint32_t value;
133 int i;
134
135 /* IRQs 0-31 are mapped to LPC_INTC_MIC_SR */
135 value = intc_read_4(LPC_INTC_MIC_SR);
136 value = intc_read_4(sc, LPC_INTC_MIC_SR);
136 for (i = 0; i < 32; i++) {
137 if (value & (1 << i))
138 return (i);
139 }
140
141 /* IRQs 32-63 are mapped to LPC_INTC_SIC1_SR */
137 for (i = 0; i < 32; i++) {
138 if (value & (1 << i))
139 return (i);
140 }
141
142 /* IRQs 32-63 are mapped to LPC_INTC_SIC1_SR */
142 value = intc_read_4(LPC_INTC_SIC1_SR);
143 value = intc_read_4(sc, LPC_INTC_SIC1_SR);
143 for (i = 0; i < 32; i++) {
144 if (value & (1 << i))
145 return (i + 32);
146 }
147
148 /* IRQs 64-95 are mapped to LPC_INTC_SIC2_SR */
144 for (i = 0; i < 32; i++) {
145 if (value & (1 << i))
146 return (i + 32);
147 }
148
149 /* IRQs 64-95 are mapped to LPC_INTC_SIC2_SR */
149 value = intc_read_4(LPC_INTC_SIC2_SR);
150 value = intc_read_4(sc, LPC_INTC_SIC2_SR);
150 for (i = 0; i < 32; i++) {
151 if (value & (1 << i))
152 return (i + 64);
153 }
154
155 return (-1);
156}
157
158void
159arm_mask_irq(uintptr_t nb)
160{
151 for (i = 0; i < 32; i++) {
152 if (value & (1 << i))
153 return (i + 64);
154 }
155
156 return (-1);
157}
158
159void
160arm_mask_irq(uintptr_t nb)
161{
162 struct lpc_intc_softc *sc = intc_softc;
161 int reg;
162 uint32_t value;
163
164 /* Make sure that interrupt isn't active already */
165 lpc_intc_eoi((void *)nb);
166
167 if (nb > 63) {
168 nb -= 64;
169 reg = LPC_INTC_SIC2_ER;
170 } else if (nb > 31) {
171 nb -= 32;
172 reg = LPC_INTC_SIC1_ER;
173 } else
174 reg = LPC_INTC_MIC_ER;
175
176 /* Clear bit in ER register */
163 int reg;
164 uint32_t value;
165
166 /* Make sure that interrupt isn't active already */
167 lpc_intc_eoi((void *)nb);
168
169 if (nb > 63) {
170 nb -= 64;
171 reg = LPC_INTC_SIC2_ER;
172 } else if (nb > 31) {
173 nb -= 32;
174 reg = LPC_INTC_SIC1_ER;
175 } else
176 reg = LPC_INTC_MIC_ER;
177
178 /* Clear bit in ER register */
177 value = intc_read_4(reg);
179 value = intc_read_4(sc, reg);
178 value &= ~(1 << nb);
180 value &= ~(1 << nb);
179 intc_write_4(reg, value);
181 intc_write_4(sc, reg, value);
180}
181
182void
183arm_unmask_irq(uintptr_t nb)
184{
182}
183
184void
185arm_unmask_irq(uintptr_t nb)
186{
187 struct lpc_intc_softc *sc = intc_softc;
185 int reg;
186 uint32_t value;
187
188 if (nb > 63) {
189 nb -= 64;
190 reg = LPC_INTC_SIC2_ER;
191 } else if (nb > 31) {
192 nb -= 32;
193 reg = LPC_INTC_SIC1_ER;
194 } else
195 reg = LPC_INTC_MIC_ER;
196
197 /* Set bit in ER register */
188 int reg;
189 uint32_t value;
190
191 if (nb > 63) {
192 nb -= 64;
193 reg = LPC_INTC_SIC2_ER;
194 } else if (nb > 31) {
195 nb -= 32;
196 reg = LPC_INTC_SIC1_ER;
197 } else
198 reg = LPC_INTC_MIC_ER;
199
200 /* Set bit in ER register */
198 value = intc_read_4(reg);
201 value = intc_read_4(sc, reg);
199 value |= (1 << nb);
202 value |= (1 << nb);
200 intc_write_4(reg, value);
203 intc_write_4(sc, reg, value);
201}
202
203static void
204lpc_intc_eoi(void *data)
205{
204}
205
206static void
207lpc_intc_eoi(void *data)
208{
209 struct lpc_intc_softc *sc = intc_softc;
206 int reg;
207 int nb = (int)data;
208 uint32_t value;
209
210 if (nb > 63) {
211 nb -= 64;
212 reg = LPC_INTC_SIC2_RSR;
213 } else if (nb > 31) {
214 nb -= 32;
215 reg = LPC_INTC_SIC1_RSR;
216 } else
217 reg = LPC_INTC_MIC_RSR;
218
219 /* Set bit in RSR register */
210 int reg;
211 int nb = (int)data;
212 uint32_t value;
213
214 if (nb > 63) {
215 nb -= 64;
216 reg = LPC_INTC_SIC2_RSR;
217 } else if (nb > 31) {
218 nb -= 32;
219 reg = LPC_INTC_SIC1_RSR;
220 } else
221 reg = LPC_INTC_MIC_RSR;
222
223 /* Set bit in RSR register */
220 value = intc_read_4(reg);
224 value = intc_read_4(sc, reg);
221 value |= (1 << nb);
225 value |= (1 << nb);
222 intc_write_4(reg, value);
226 intc_write_4(sc, reg, value);
223
224}
225
226struct fdt_fixup_entry fdt_fixup_table[] = {
227 { NULL, NULL }
228};
229
230static int

--- 16 unchanged lines hidden ---
227
228}
229
230struct fdt_fixup_entry fdt_fixup_table[] = {
231 { NULL, NULL }
232};
233
234static int

--- 16 unchanged lines hidden ---