diff options
| author | pk <pk@NetBSD.org> | 1999-01-16 12:46:08 +0000 |
|---|---|---|
| committer | pk <pk@NetBSD.org> | 1999-01-16 12:46:08 +0000 |
| commit | c830c88dd265b082f43bd3f471cf6efd92c478d9 (patch) | |
| tree | 411411d82618ebfea7cf65227457b386c8c1874d /sys/dev | |
| parent | e0e761e42039c070821666a7befd278bae596b70 (diff) | |
Convert to bus_space(9).
Add buffer allocations needed by the be driver.
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/sbus/qec.c | 49 | ||||
| -rw-r--r-- | sys/dev/sbus/qecreg.h | 92 | ||||
| -rw-r--r-- | sys/dev/sbus/qecvar.h | 8 |
3 files changed, 129 insertions, 20 deletions
diff --git a/sys/dev/sbus/qec.c b/sys/dev/sbus/qec.c index 620ab7930a2..9dc1263e41b 100644 --- a/sys/dev/sbus/qec.c +++ b/sys/dev/sbus/qec.c @@ -1,4 +1,4 @@ -/* $NetBSD: qec.c,v 1.6 1998/08/30 21:25:30 pk Exp $ */ +/* $NetBSD: qec.c,v 1.7 1999/01/16 12:46:08 pk Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -54,6 +54,7 @@ static int qecprint __P((void *, const char *)); static int qecmatch __P((struct device *, struct cfdata *, void *)); static void qecattach __P((struct device *, struct device *, void *)); +void qec_init __P((struct qec_softc *)); static int qec_bus_map __P(( bus_space_tag_t, @@ -125,11 +126,10 @@ qecattach(parent, self, aux) sa->sa_reg[0].sbr_slot, sa->sa_reg[0].sbr_offset, sa->sa_reg[0].sbr_size, - BUS_SPACE_MAP_LINEAR, 0, &bh) != 0) { + BUS_SPACE_MAP_LINEAR, 0, &sc->sc_regs) != 0) { printf("%s: attach: cannot map registers\n", self->dv_xname); return; } - sc->sc_regs = (void *)bh; /* * This device's "register space 1" is just a buffer where the @@ -147,6 +147,13 @@ qecattach(parent, self, aux) sc->sc_buffer = (caddr_t)bh; sc->sc_bufsiz = (bus_size_t)sa->sa_reg[1].sbr_size; + /* Get number of on-board channels */ + sc->sc_nchannels = getpropint(node, "#channels", -1); + if (sc->sc_nchannels == -1) { + printf(": no channels\n"); + return; + } + /* * Get transfer burst size from PROM */ @@ -164,7 +171,6 @@ qecattach(parent, self, aux) sbus_establish(&sc->sc_sd, &sc->sc_dev); - /* * Collect address translations from the OBP. */ @@ -199,6 +205,8 @@ qecattach(parent, self, aux) printf(": %dK memory\n", sc->sc_bufsiz / 1024); + qec_init(sc); + /* search through children */ for (node = firstchild(node); node; node = nextsibling(node)) { struct sbus_attach_args sa; @@ -239,3 +247,36 @@ qec_bus_map(t, btype, offset, size, flags, vaddr, hp) return (EINVAL); } + +void +qec_init(sc) + struct qec_softc *sc; +{ + bus_space_tag_t t = sc->sc_bustag; + bus_space_handle_t qr = sc->sc_regs; + u_int32_t v, burst = 0; + + /* + * Cut available buffer size into receive and transmit buffers. + * XXX - should probably be done in be & qe driver... + */ + v = sc->sc_msize = sc->sc_bufsiz / sc->sc_nchannels; + bus_space_write_4(t, qr, QEC_QRI_MSIZE, v); + + v = sc->sc_rsize = sc->sc_bufsiz / (sc->sc_nchannels * 2); + bus_space_write_4(t, qr, QEC_QRI_RSIZE, v); + bus_space_write_4(t, qr, QEC_QRI_TSIZE, v); + + bus_space_write_4(t, qr, QEC_QRI_PSIZE, QEC_PSIZE_2048); + + if (sc->sc_burst & SBUS_BURST_64) + burst = QEC_CTRL_B64; + else if (sc->sc_burst & SBUS_BURST_32) + burst = QEC_CTRL_B32; + else + burst = QEC_CTRL_B16; + + v = bus_space_read_4(t, qr, QEC_QRI_CTRL); + v = (v & QEC_CTRL_MODEMASK) | burst; + bus_space_write_4(t, qr, QEC_QRI_CTRL, v); +} diff --git a/sys/dev/sbus/qecreg.h b/sys/dev/sbus/qecreg.h index 57cfccbc134..982a002d44c 100644 --- a/sys/dev/sbus/qecreg.h +++ b/sys/dev/sbus/qecreg.h @@ -1,7 +1,44 @@ -/* $NetBSD: qecreg.h,v 1.1 1998/07/27 19:27:19 pk Exp $ */ +/* $NetBSD: qecreg.h,v 1.2 1999/01/16 12:46:08 pk Exp $ */ + +/*- + * Copyright (c) 1998 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Paul Kranenburg. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``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 FOUNDATION OR CONTRIBUTORS + * 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 THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ /* - * 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 +48,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 @@ -26,18 +63,28 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* QEC registers */ +/* + * QEC registers layout + *- struct qecregs { - volatile u_int32_t ctrl; /* control */ - volatile u_int32_t stat; /* status */ - volatile u_int32_t psize; /* packet size */ - volatile u_int32_t msize; /* local-mem size (64K) */ - volatile u_int32_t rsize; /* receive partition size */ - volatile u_int32_t tsize; /* transmit partition size */ + u_int32_t qec_ctrl; // control + u_int32_t qec_stat; // status + u_int32_t qec_psize; // packet size + u_int32_t qec_msize; // local-mem size (64K) + u_int32_t qec_rsize; // receive partition size + u_int32_t qec_tsize; // transmit partition size }; + */ +#define QEC_QRI_CTRL (0*4) +#define QEC_QRI_STAT (1*4) +#define QEC_QRI_PSIZE (2*4) +#define QEC_QRI_MSIZE (3*4) +#define QEC_QRI_RSIZE (4*4) +#define QEC_QRI_TSIZE (5*4) -#define QEC_CTRL_MMODE 0x40000000 /* MACE qec mode */ -#define QEC_CTRL_BMODE 0x10000000 /* BE qec mode */ +#define QEC_CTRL_MODEMASK 0xf0000000 /* QEC mode: */ +#define QEC_CTRL_MMODE 0x40000000 /* MACE qec mode */ +#define QEC_CTRL_BMODE 0x10000000 /* BE qec mode */ #define QEC_CTRL_EPAR 0x00000020 /* enable parity */ #define QEC_CTRL_ACNTRL 0x00000018 /* sbus arbitration control */ #define QEC_CTRL_B64 0x00000004 /* 64 byte dvma bursts */ @@ -54,3 +101,20 @@ struct qecregs { #define QEC_PSIZE_4096 0x01 /* 4k packet size */ #define QEC_PSIZE_6144 0x10 /* 6k packet size */ #define QEC_PSIZE_8192 0x11 /* 8k packet size */ + + + +/* + * Transmit & receive buffer descriptor. + */ +struct qec_xd { + volatile u_int32_t xd_flags; /* see below */ + volatile u_int32_t xd_addr; /* Buffer address (DMA) */ +}; +#define QEC_XD_OWN 0x80000000 /* ownership: 1=hw, 0=sw */ +#define QEC_XD_SOP 0x40000000 /* start of packet marker (xmit) */ +#define QEC_XD_EOP 0x20000000 /* end of packet marker (xmit) */ +#define QEC_XD_UPDATE 0x10000000 /* being updated? */ +#define QEC_XD_LENGTH 0x00001fff /* packet length mask */ +/* Descriptor ring size is fixed */ +#define QEC_XD_RING_MAXSIZE 256 /* maximum ring size */ diff --git a/sys/dev/sbus/qecvar.h b/sys/dev/sbus/qecvar.h index 2eeedc691c7..0a366ed7093 100644 --- a/sys/dev/sbus/qecvar.h +++ b/sys/dev/sbus/qecvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: qecvar.h,v 1.2 1998/07/29 18:32:54 pk Exp $ */ +/* $NetBSD: qecvar.h,v 1.3 1999/01/16 12:46:08 pk Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -44,8 +44,12 @@ struct qec_softc { struct sbus_range *sc_range; /* PROM ranges */ int sc_nrange; /* */ - struct qecregs *sc_regs; /* QEC registers */ + bus_space_handle_t sc_regs; /* QEC registers */ + int sc_nchannels; /* # of channels on board */ int sc_burst; /* DVMA burst size in effect */ caddr_t sc_buffer; /* VA of the buffer we provide */ int sc_bufsiz; /* Size of buffer */ + + u_int sc_msize; /* QEC buffer offset per channel */ + u_int sc_rsize; /* QEC buffer size for receive */ }; |
