Annotation of sys/arch/aviion/dev/dart_syscon.c, Revision 1.1
1.1 ! nbrk 1: /* $OpenBSD: dart_syscon.c,v 1.1.1.1 2006/05/09 18:13:37 miod Exp $ */
! 2: /*
! 3: * Copyright (c) 2006, Miodrag Vallat
! 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
! 9: * notice, this list of conditions and the following disclaimer.
! 10: * 2. Redistributions in binary form must reproduce the above copyright
! 11: * notice, this list of conditions and the following disclaimer in the
! 12: * documentation and/or other materials provided with the distribution.
! 13: *
! 14: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
! 15: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
! 16: * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
! 17: * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
! 18: * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
! 19: * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
! 20: * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
! 21: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
! 22: * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
! 23: * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
! 24: * POSSIBILITY OF SUCH DAMAGE.
! 25: */
! 26:
! 27: #include <sys/param.h>
! 28: #include <sys/systm.h>
! 29: #include <sys/device.h>
! 30:
! 31: #include <machine/autoconf.h>
! 32: #include <machine/cpu.h>
! 33:
! 34: #include <machine/av400.h>
! 35:
! 36: #include <aviion/dev/sysconreg.h>
! 37: #include <aviion/dev/dartvar.h>
! 38:
! 39: int dart_syscon_match(struct device *parent, void *self, void *aux);
! 40: void dart_syscon_attach(struct device *parent, struct device *self, void *aux);
! 41:
! 42: struct cfattach dart_syscon_ca = {
! 43: sizeof(struct dartsoftc), dart_syscon_match, dart_syscon_attach
! 44: };
! 45:
! 46: int
! 47: dart_syscon_match(struct device *parent, void *cf, void *aux)
! 48: {
! 49: struct confargs *ca = aux;
! 50: bus_space_handle_t ioh;
! 51: int rc;
! 52:
! 53: /*
! 54: * We do not accept empty locators here...
! 55: */
! 56: if (ca->ca_paddr == (paddr_t)-1)
! 57: return (0);
! 58:
! 59: if (bus_space_map(ca->ca_iot, ca->ca_paddr, DART_SIZE, 0, &ioh) != 0)
! 60: return (0);
! 61: rc = badaddr((vaddr_t)bus_space_vaddr(ca->ca_iot, ioh), 4);
! 62: bus_space_unmap(ca->ca_iot, ca->ca_paddr, DART_SIZE);
! 63:
! 64: return (rc == 0);
! 65: }
! 66:
! 67: void
! 68: dart_syscon_attach(struct device *parent, struct device *self, void *aux)
! 69: {
! 70: struct dartsoftc *sc = (struct dartsoftc *)self;
! 71: struct confargs *ca = aux;
! 72: bus_space_handle_t ioh;
! 73: u_int vec;
! 74:
! 75: if (ca->ca_ipl < 0)
! 76: ca->ca_ipl = IPL_TTY;
! 77:
! 78: sc->sc_iot = ca->ca_iot;
! 79: if (bus_space_map(sc->sc_iot, ca->ca_paddr, DART_SIZE, 0, &ioh) != 0) {
! 80: printf(": can't map registers!\n");
! 81: return;
! 82: }
! 83: sc->sc_ioh = ioh;
! 84:
! 85: if (ca->ca_paddr == DART_BASE) {
! 86: vec = SYSCV_SCC;
! 87: sc->sc_console = 1; /* XXX for now */
! 88: printf(": console");
! 89: } else {
! 90: vec = SYSCV_SCC2;
! 91: sc->sc_console = 0;
! 92: }
! 93:
! 94: /* enable interrupts */
! 95: sc->sc_ih.ih_fn = dartintr;
! 96: sc->sc_ih.ih_arg = sc;
! 97: sc->sc_ih.ih_wantframe = 0;
! 98: sc->sc_ih.ih_ipl = ca->ca_ipl;
! 99:
! 100: sysconintr_establish(vec, &sc->sc_ih, self->dv_xname);
! 101:
! 102: dart_common_attach(sc);
! 103: }
CVSweb