Deleted Added
full compact
obio.c (183173) obio.c (202037)
1/* $NetBSD: obio.c,v 1.11 2003/07/15 00:25:05 lukem Exp $ */
2
3/*-
4 * Copyright (c) 2001, 2002, 2003 Wasabi Systems, Inc.
5 * All rights reserved.
6 *
7 * Written by Jason R. Thorpe for Wasabi Systems, Inc.
8 *

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

31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
36 */
37
38#include <sys/cdefs.h>
1/* $NetBSD: obio.c,v 1.11 2003/07/15 00:25:05 lukem Exp $ */
2
3/*-
4 * Copyright (c) 2001, 2002, 2003 Wasabi Systems, Inc.
5 * All rights reserved.
6 *
7 * Written by Jason R. Thorpe for Wasabi Systems, Inc.
8 *

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

31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
36 */
37
38#include <sys/cdefs.h>
39__FBSDID("$FreeBSD: head/sys/mips/adm5120/obio.c 183173 2008-09-19 04:10:09Z imp $");
39__FBSDID("$FreeBSD: head/sys/mips/adm5120/obio.c 202037 2010-01-10 20:11:10Z imp $");
40
41#include <sys/param.h>
42#include <sys/systm.h>
43#include <sys/bus.h>
44#include <sys/interrupt.h>
45#include <sys/kernel.h>
46#include <sys/module.h>
47#include <sys/rman.h>

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

115static int obio_probe(device_t);
116static int obio_release_resource(device_t, device_t, int, int,
117 struct resource *);
118static int obio_setup_intr(device_t, device_t, struct resource *, int,
119 driver_filter_t *, driver_intr_t *, void *, void **);
120static int obio_teardown_intr(device_t, device_t, struct resource *,
121 void *);
122
40
41#include <sys/param.h>
42#include <sys/systm.h>
43#include <sys/bus.h>
44#include <sys/interrupt.h>
45#include <sys/kernel.h>
46#include <sys/module.h>
47#include <sys/rman.h>

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

115static int obio_probe(device_t);
116static int obio_release_resource(device_t, device_t, int, int,
117 struct resource *);
118static int obio_setup_intr(device_t, device_t, struct resource *, int,
119 driver_filter_t *, driver_intr_t *, void *, void **);
120static int obio_teardown_intr(device_t, device_t, struct resource *,
121 void *);
122
123
124static void
125obio_mask_irq(void *source)
126{
127 int irq;
128 uint32_t irqmask;
129 uint32_t reg;
130
131 irq = (int)source;
132 irqmask = 1 << irq;
133
134 /* disable IRQ */
135 reg = REG_READ(ICU_DISABLE_REG);
136 REG_WRITE(ICU_DISABLE_REG, (reg | irqmask));
137}
138
139static void
140obio_unmask_irq(void *source)
141{
142 int irq;
143 uint32_t irqmask;
144 uint32_t reg;
145
146 irq = (int)source;
147 irqmask = 1 << irq;
148
149 /* disable IRQ */
150 reg = REG_READ(ICU_DISABLE_REG);
151 REG_WRITE(ICU_DISABLE_REG, (reg & ~irqmask));
152
153}
154
155
123static int
124obio_probe(device_t dev)
125{
126
127 return (0);
128}
129
130static int

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

264 * If this is a memory resource, track the direct mapping
265 * in the uncached MIPS KSEG1 segment.
266 */
267 if (type == SYS_RES_MEMORY) {
268 void *vaddr;
269
270 vaddr = (void *)MIPS_PHYS_TO_KSEG1((intptr_t)rman_get_start(r));
271 rman_set_virtual(r, vaddr);
156static int
157obio_probe(device_t dev)
158{
159
160 return (0);
161}
162
163static int

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

297 * If this is a memory resource, track the direct mapping
298 * in the uncached MIPS KSEG1 segment.
299 */
300 if (type == SYS_RES_MEMORY) {
301 void *vaddr;
302
303 vaddr = (void *)MIPS_PHYS_TO_KSEG1((intptr_t)rman_get_start(r));
304 rman_set_virtual(r, vaddr);
272 rman_set_bustag(r, MIPS_BUS_SPACE_MEM);
305 rman_set_bustag(r, mips_bus_space_generic);
273 rman_set_bushandle(r, (bus_space_handle_t)vaddr);
274 }
275
276 return (rman_activate_resource(r));
277}
278
279static int
280obio_deactivate_resource(device_t bus, device_t child, int type, int rid,

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

316 irq = rman_get_start(ires);
317
318 if (irq >= NIRQS)
319 panic("%s: bad irq %d", __func__, irq);
320
321 event = sc->sc_eventstab[irq];
322 if (event == NULL) {
323 error = intr_event_create(&event, (void *)irq, 0, irq,
306 rman_set_bushandle(r, (bus_space_handle_t)vaddr);
307 }
308
309 return (rman_activate_resource(r));
310}
311
312static int
313obio_deactivate_resource(device_t bus, device_t child, int type, int rid,

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

349 irq = rman_get_start(ires);
350
351 if (irq >= NIRQS)
352 panic("%s: bad irq %d", __func__, irq);
353
354 event = sc->sc_eventstab[irq];
355 if (event == NULL) {
356 error = intr_event_create(&event, (void *)irq, 0, irq,
324 (mask_fn)mips_mask_irq, (mask_fn)mips_unmask_irq,
357 obio_mask_irq, obio_unmask_irq,
325 NULL, NULL, "obio intr%d:", irq);
326
327 sc->sc_eventstab[irq] = event;
328 }
329 else
330 panic("obio: Can't share IRQs");
331
332 intr_event_add_handler(event, device_get_nameunit(child), filt,

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

338 if (priority == INTR_FIQ)
339 REG_WRITE(ICU_MODE_REG, REG_READ(ICU_MODE_REG) | irqmask);
340 else
341 REG_WRITE(ICU_MODE_REG, REG_READ(ICU_MODE_REG) & ~irqmask);
342
343 /* enable */
344 REG_WRITE(ICU_ENABLE_REG, irqmask);
345
358 NULL, NULL, "obio intr%d:", irq);
359
360 sc->sc_eventstab[irq] = event;
361 }
362 else
363 panic("obio: Can't share IRQs");
364
365 intr_event_add_handler(event, device_get_nameunit(child), filt,

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

371 if (priority == INTR_FIQ)
372 REG_WRITE(ICU_MODE_REG, REG_READ(ICU_MODE_REG) | irqmask);
373 else
374 REG_WRITE(ICU_MODE_REG, REG_READ(ICU_MODE_REG) & ~irqmask);
375
376 /* enable */
377 REG_WRITE(ICU_ENABLE_REG, irqmask);
378
379 obio_unmask_irq((void*)irq);
380
346 return (0);
347}
348
349static int
350obio_teardown_intr(device_t dev, device_t child, struct resource *ires,
351 void *cookie)
352{
353 struct obio_softc *sc = device_get_softc(dev);
381 return (0);
382}
383
384static int
385obio_teardown_intr(device_t dev, device_t child, struct resource *ires,
386 void *cookie)
387{
388 struct obio_softc *sc = device_get_softc(dev);
354 int irq, result;
389 int irq, result, priority;
355 uint32_t irqmask;
356
357 irq = rman_get_start(ires);
358 if (irq >= NIRQS)
359 panic("%s: bad irq %d", __func__, irq);
360
361 if (sc->sc_eventstab[irq] == NULL)
362 panic("Trying to teardown unoccupied IRQ");
363
390 uint32_t irqmask;
391
392 irq = rman_get_start(ires);
393 if (irq >= NIRQS)
394 panic("%s: bad irq %d", __func__, irq);
395
396 if (sc->sc_eventstab[irq] == NULL)
397 panic("Trying to teardown unoccupied IRQ");
398
364 irqmask = 1 << irq; /* only used as a mask from here on */
399 irqmask = (1 << irq);
400 priority = irq_priorities[irq];
365
401
366 /* disable this irq in HW */
367 REG_WRITE(ICU_DISABLE_REG, irqmask);
402 if (priority == INTR_FIQ)
403 REG_WRITE(ICU_MODE_REG, REG_READ(ICU_MODE_REG) & ~irqmask);
404 else
405 REG_WRITE(ICU_MODE_REG, REG_READ(ICU_MODE_REG) | irqmask);
368
406
407 /* disable */
408 irqmask = REG_READ(ICU_ENABLE_REG);
409 irqmask &= ~(1 << irq);
410 REG_WRITE(ICU_ENABLE_REG, irqmask);
411
369 result = intr_event_remove_handler(cookie);
370 if (!result) {
371 sc->sc_eventstab[irq] = NULL;
372 }
373
374 return (result);
375}
376

--- 125 unchanged lines hidden ---
412 result = intr_event_remove_handler(cookie);
413 if (!result) {
414 sc->sc_eventstab[irq] = NULL;
415 }
416
417 return (result);
418}
419

--- 125 unchanged lines hidden ---