1 /* $NetBSD: if_ie_obio.c,v 1.19 2003/07/15 03:36:15 lukem Exp $ */ 2 3 /*- 4 * Copyright (c) 1996 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Gordon W. Ross. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 3. All advertising materials mentioning features or use of this software 19 * must display the following acknowledgement: 20 * This product includes software developed by the NetBSD 21 * Foundation, Inc. and its contributors. 22 * 4. Neither the name of The NetBSD Foundation nor the names of its 23 * contributors may be used to endorse or promote products derived 24 * from this software without specific prior written permission. 25 * 26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36 * POSSIBILITY OF SUCH DAMAGE. 37 */ 38 39 /* 40 * Machine-dependent glue for the Intel Ethernet (ie) driver. 41 */ 42 43 #include <sys/cdefs.h> 44 __KERNEL_RCSID(0, "$NetBSD: if_ie_obio.c,v 1.19 2003/07/15 03:36:15 lukem Exp $"); 45 46 #include "opt_inet.h" 47 48 #include <sys/param.h> 49 #include <sys/systm.h> 50 #include <sys/device.h> 51 #include <sys/protosw.h> 52 #include <sys/socket.h> 53 #include <net/if.h> 54 #include <net/if_ether.h> 55 56 #ifdef INET 57 #include <netinet/in.h> 58 #include <netinet/in_systm.h> 59 #include <netinet/in_var.h> 60 #include <netinet/ip.h> 61 #include <netinet/if_inarp.h> 62 #endif 63 64 #include <machine/autoconf.h> 65 #include <machine/cpu.h> 66 #include <machine/dvma.h> 67 #include <machine/idprom.h> 68 #include <machine/vmparam.h> 69 70 #include "i82586.h" 71 #include "if_iereg.h" 72 #include "if_ievar.h" 73 74 static void ie_obreset __P((struct ie_softc *)); 75 static void ie_obattend __P((struct ie_softc *)); 76 static void ie_obrun __P((struct ie_softc *)); 77 78 /* 79 * New-style autoconfig attachment 80 */ 81 82 static int ie_obio_match __P((struct device *, struct cfdata *, void *)); 83 static void ie_obio_attach __P((struct device *, struct device *, void *)); 84 85 CFATTACH_DECL(ie_obio, sizeof(struct ie_softc), 86 ie_obio_match, ie_obio_attach, NULL, NULL); 87 88 static int 89 ie_obio_match(parent, cf, args) 90 struct device *parent; 91 struct cfdata *cf; 92 void *args; 93 { 94 struct confargs *ca = args; 95 96 /* Make sure there is something there... */ 97 if (bus_peek(ca->ca_bustype, ca->ca_paddr, 1) == -1) 98 return (0); 99 100 /* Default interrupt priority. */ 101 if (ca->ca_intpri == -1) 102 ca->ca_intpri = 3; 103 104 return (1); 105 } 106 107 void 108 ie_obio_attach(parent, self, args) 109 struct device *parent; 110 struct device *self; 111 void *args; 112 { 113 struct ie_softc *sc = (void *) self; 114 struct confargs *ca = args; 115 116 sc->hard_type = IE_OBIO; 117 sc->reset_586 = ie_obreset; 118 sc->chan_attn = ie_obattend; 119 sc->run_586 = ie_obrun; 120 sc->sc_memcpy = memcpy; 121 sc->sc_memset = memset; 122 123 /* Map in the control registers. */ 124 sc->sc_reg = bus_mapin(ca->ca_bustype, 125 ca->ca_paddr, sizeof(struct ieob)); 126 127 /* 128 * The on-board "ie" is wired-up such that its 129 * memory access goes to the high 16 megabytes 130 * of the on-board memory space (on-board DVMA). 131 */ 132 sc->sc_iobase = (caddr_t)DVMA_OBIO_SLAVE_BASE; 133 134 /* 135 * The on-board "ie" just uses main memory, so 136 * we can choose how much memory to give it. 137 * XXX: Would like to use less than 64K... 138 */ 139 sc->sc_msize = 0x8000; /* MEMSIZE 32K */ 140 141 /* Allocate "shared" memory (in DVMA space). */ 142 sc->sc_maddr = dvma_malloc(sc->sc_msize); 143 if (sc->sc_maddr == NULL) 144 panic(": not enough dvma space"); 145 146 /* 147 * Set the System Configuration Pointer (SCP). 148 * Its location is system-dependent because the 149 * i82586 reads it from a fixed physical address. 150 * On this hardware, the i82586 address maps to 151 * a 24-bit offset in on-board DVMA space. The 152 * SCP happens to fall in a page used by the 153 * PROM monitor, which the PROM knows about. 154 */ 155 sc->scp = (volatile void *) (sc->sc_iobase + IE_SCP_ADDR); 156 157 /* 158 * The rest of ram is used for buffers. 159 */ 160 sc->buf_area = sc->sc_maddr; 161 sc->buf_area_sz = sc->sc_msize; 162 163 /* Install interrupt handler. */ 164 isr_add_autovect(ie_intr, (void *)sc, ca->ca_intpri); 165 166 /* Set the ethernet address. */ 167 idprom_etheraddr(sc->sc_addr); 168 169 /* Do machine-independent parts of attach. */ 170 ie_attach(sc); 171 } 172 173 174 /* 175 * onboard ie support 176 */ 177 178 /* Whack the "channel attetion" line. */ 179 void 180 ie_obattend(sc) 181 struct ie_softc *sc; 182 { 183 volatile struct ieob *ieo = (struct ieob *) sc->sc_reg; 184 185 ieo->obctrl |= IEOB_ATTEN; /* flag! */ 186 ieo->obctrl &= ~IEOB_ATTEN; /* down. */ 187 } 188 189 /* 190 * This is called during driver attach. 191 * Reset and initialize. 192 */ 193 void 194 ie_obreset(sc) 195 struct ie_softc *sc; 196 { 197 volatile struct ieob *ieo = (struct ieob *) sc->sc_reg; 198 ieo->obctrl = 0; 199 delay(20); 200 ieo->obctrl = (IEOB_NORSET | IEOB_ONAIR | IEOB_IENAB); 201 } 202 203 /* 204 * This is called at the end of ieinit(). 205 * optional. 206 */ 207 void 208 ie_obrun(sc) 209 struct ie_softc *sc; 210 { 211 /* do it all in reset */ 212 } 213 214