diff options
author | Jason Wright <jason@cvs.openbsd.org> | 1998-08-26 00:57:08 +0000 |
---|---|---|
committer | Jason Wright <jason@cvs.openbsd.org> | 1998-08-26 00:57:08 +0000 |
commit | b8957a20d10b8bea41754a128b781d24771d2a18 (patch) | |
tree | d827caefc09f9900a4ea56c60f7bbcaf0704eff7 /sys/arch/sparc/dev | |
parent | fea06c4caf038d9dc8e6716028b6560bc61fbef6 (diff) |
o Fix up address ranges
o Added qec_translate for translating addresses of prom children
o Added qec_reset to do a generic reset of the card
Diffstat (limited to 'sys/arch/sparc/dev')
-rw-r--r-- | sys/arch/sparc/dev/qec.c | 104 | ||||
-rw-r--r-- | sys/arch/sparc/dev/qecreg.h | 14 | ||||
-rw-r--r-- | sys/arch/sparc/dev/qecvar.h | 19 |
3 files changed, 117 insertions, 20 deletions
diff --git a/sys/arch/sparc/dev/qec.c b/sys/arch/sparc/dev/qec.c index 963894d9620..8599a9183eb 100644 --- a/sys/arch/sparc/dev/qec.c +++ b/sys/arch/sparc/dev/qec.c @@ -1,7 +1,8 @@ -/* $OpenBSD: qec.c,v 1.4 1998/07/05 09:24:22 deraadt Exp $ */ +/* $OpenBSD: qec.c,v 1.5 1998/08/26 00:57:04 jason Exp $ */ /* - * Copyright (c) 1998 Theo de Raadt. All rights reserved. + * Copyright (c) 1998 Theo de Raadt and Jason L. Wright. + * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -11,13 +12,13 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products + * 3. The name of the authors may not be used to endorse or promote products * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY @@ -46,8 +47,10 @@ #include <sparc/dev/qecreg.h> #include <sparc/dev/qecvar.h> -int qecprint __P((void *, const char *)); -void qecattach __P((struct device *, struct device *, void *)); +int qecprint __P((void *, const char *)); +void qecattach __P((struct device *, struct device *, void *)); +void qec_fix_range __P((struct qec_softc *, struct sbus_softc *)); +void qec_translate __P((struct qec_softc *, struct confargs *)); struct cfattach qec_ca = { sizeof(struct qec_softc), matchbyname, qecattach @@ -95,6 +98,10 @@ qecattach(parent, self, aux) ca->ca_ra.ra_reg[1].rr_len); sc->sc_bufsiz = ca->ca_ra.ra_reg[1].rr_len; + node = sc->sc_node = ca->ca_ra.ra_node; + + qec_fix_range(sc, (struct sbus_softc *)parent); + /* * Get transfer burst size from PROM */ @@ -131,8 +138,89 @@ qecattach(parent, self, aux) if (!romprop(&oca.ca_ra, name, node)) continue; - sbus_translate(parent, &oca); + qec_translate(sc, &oca); oca.ca_bustype = BUS_SBUS; (void) config_found(&sc->sc_dev, (void *)&oca, qecprint); } } + +void +qec_fix_range(sc, sbp) + struct qec_softc *sc; + struct sbus_softc *sbp; +{ + int rlen, i, j; + + rlen = getproplen(sc->sc_node, "ranges"); + sc->sc_range = + (struct rom_range *)malloc(rlen, M_DEVBUF, M_NOWAIT); + if (sc->sc_range == NULL) { + printf("%s: PROM ranges too large: %d\n", + sc->sc_dev.dv_xname, rlen); + return; + } + sc->sc_nrange = rlen / sizeof(struct rom_range); + (void)getprop(sc->sc_node, "ranges", sc->sc_range, rlen); + + for (i = 0; i < sc->sc_nrange; i++) { + for (j = 0; j < sbp->sc_nrange; j++) { + if (sc->sc_range[i].pspace == sbp->sc_range[j].cspace) { + sc->sc_range[i].poffset += + sbp->sc_range[j].poffset; + sc->sc_range[i].pspace = + sbp->sc_range[j].pspace; + break; + } + } + } +} + +/* + * Translate the register addresses of our children + */ +void +qec_translate(sc, ca) + struct qec_softc *sc; + struct confargs *ca; +{ + register int i; + + ca->ca_slot = ca->ca_ra.ra_iospace; + ca->ca_offset = (int)ca->ca_ra.ra_paddr; + + /* Translate into parent address spaces */ + for (i = 0; i < ca->ca_ra.ra_nreg; i++) { + int j, cspace = ca->ca_ra.ra_reg[i].rr_iospace; + + for (j = 0; j < sc->sc_nrange; j++) { + if (sc->sc_range[j].cspace == cspace) { + (int)ca->ca_ra.ra_reg[i].rr_paddr += + sc->sc_range[j].poffset; + (int)ca->ca_ra.ra_reg[i].rr_iospace = + sc->sc_range[j].pspace; + break; + } + } + } +} + +/* + * Reset the QEC + */ +void +qec_reset(sc) + struct qec_softc *sc; +{ + int i = 200; + + sc->sc_regs->ctrl = QEC_CTRL_RESET; + while (--i) { + if ((sc->sc_regs->ctrl & QEC_CTRL_RESET) == 0) + break; + DELAY(20); + } + if (i == 0) { + printf("%s: reset failed.\n", sc->sc_dev.dv_xname); + return; + } +} diff --git a/sys/arch/sparc/dev/qecreg.h b/sys/arch/sparc/dev/qecreg.h index f20a5be9431..243ba316b02 100644 --- a/sys/arch/sparc/dev/qecreg.h +++ b/sys/arch/sparc/dev/qecreg.h @@ -1,7 +1,8 @@ -/* $OpenBSD: qecreg.h,v 1.1 1998/07/04 07:07:22 deraadt Exp $ */ +/* $OpenBSD: qecreg.h,v 1.2 1998/08/26 00:57:05 jason Exp $ */ /* - * Copyright (c) 1998 Theo de Raadt. All rights reserved. + * Copyright (c) 1998 Theo de Raadt and Jason L. Wright. + * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -11,13 +12,13 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products + * 3. The name of the authors may not be used to endorse or promote products * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY @@ -36,6 +37,7 @@ struct qecregs { volatile u_int32_t tsize; /* transmit partition size */ }; +/* qecregs.ctrl: control. */ #define QEC_CTRL_MMODE 0x40000000 /* MACE qec mode */ #define QEC_CTRL_BMODE 0x10000000 /* BE qec mode */ #define QEC_CTRL_EPAR 0x00000020 /* enable parity */ @@ -45,11 +47,13 @@ struct qecregs { #define QEC_CTRL_B16 0x00000000 /* 16 byte dvma bursts */ #define QEC_CTRL_RESET 0x00000001 /* reset the qec */ +/* qecregs.stat: status. */ #define QEC_STAT_TX 0x00000008 /* bigmac transmit irq */ #define QEC_STAT_RX 0x00000004 /* bigmac receive irq */ #define QEC_STAT_BM 0x00000002 /* bigmac qec irq */ #define QEC_STAT_ER 0x00000001 /* bigmac error irq */ +/* qecregs.stat: packet size. */ #define QEC_PSIZE_2048 0x00 /* 2k packet size */ #define QEC_PSIZE_4096 0x01 /* 4k packet size */ #define QEC_PSIZE_6144 0x10 /* 6k packet size */ diff --git a/sys/arch/sparc/dev/qecvar.h b/sys/arch/sparc/dev/qecvar.h index 35a6826ae0e..f7a56440751 100644 --- a/sys/arch/sparc/dev/qecvar.h +++ b/sys/arch/sparc/dev/qecvar.h @@ -1,7 +1,8 @@ -/* $OpenBSD: qecvar.h,v 1.3 1998/07/04 07:57:01 deraadt Exp $ */ +/* $OpenBSD: qecvar.h,v 1.4 1998/08/26 00:57:07 jason Exp $ */ /* - * Copyright (c) 1998 Theo de Raadt. All rights reserved. + * Copyright (c) 1998 Theo de Raadt and Jason L. Wright. + * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -11,13 +12,13 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products + * 3. The name of the authors may not be used to endorse or promote products * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY @@ -27,11 +28,15 @@ */ struct qec_softc { - struct device sc_dev; /* us as a device */ - struct sbusdev sc_sd; /* sbus device */ + struct device sc_dev; /* us as a device */ + struct sbusdev sc_sd; /* sbus device */ struct qecregs *sc_regs; /* QEC registers */ int sc_node; /* PROM node ID */ int sc_burst; /* DVMA burst size in effect */ caddr_t sc_buffer; /* VA of the buffer we provide */ int sc_bufsiz; /* Size of buffer */ + int sc_nrange; /* number of ranges */ + struct rom_range *sc_range; /* array of ranges */ }; + +void qec_reset __P((struct qec_softc *)); |