diff options
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/ic/ate_subr.c | 148 | ||||
| -rw-r--r-- | sys/dev/ic/ate_subr.h | 47 | ||||
| -rw-r--r-- | sys/dev/ic/mb86960.c | 84 | ||||
| -rw-r--r-- | sys/dev/ic/mb86960reg.h | 26 | ||||
| -rw-r--r-- | sys/dev/ic/mb86960var.h | 4 | ||||
| -rw-r--r-- | sys/dev/isa/if_ate.c | 17 | ||||
| -rw-r--r-- | sys/dev/mca/if_ate_mca.c | 11 |
7 files changed, 119 insertions, 218 deletions
diff --git a/sys/dev/ic/ate_subr.c b/sys/dev/ic/ate_subr.c deleted file mode 100644 index 73bbc3df0ea..00000000000 --- a/sys/dev/ic/ate_subr.c +++ /dev/null @@ -1,148 +0,0 @@ -/* $NetBSD: ate_subr.c,v 1.3 2002/09/28 18:19:08 tsutsui Exp $ */ - -/* - * All Rights Reserved, Copyright (C) Fujitsu Limited 1995 - * - * This software may be used, modified, copied, distributed, and sold, in - * both source and binary form provided that the above copyright, these - * terms and the following disclaimer are retained. The name of the author - * and/or the contributor 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 AND THE CONTRIBUTOR ``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 OR THE CONTRIBUTOR 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. - */ - -/* - * Portions copyright (C) 1993, David Greenman. This software may be used, - * modified, copied, distributed, and sold, in both source and binary form - * provided that the above copyright and these terms are retained. Under no - * circumstances is the author responsible for the proper functioning of this - * software, nor does the author assume any responsibility for damages - * incurred with its use. - */ - -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ate_subr.c,v 1.3 2002/09/28 18:19:08 tsutsui Exp $"); - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/device.h> -#include <sys/socket.h> -#include <sys/syslog.h> - -#include <machine/bus.h> -#include <machine/intr.h> - -#include <dev/ic/mb86960reg.h> -#include <dev/ic/ate_subr.h> - -static __inline__ void ate_strobe __P((bus_space_tag_t, bus_space_handle_t)); - -/* - * Routines to read all bytes from the config EEPROM through MB86965A. - * I'm not sure what exactly I'm doing here... I was told just to follow - * the steps, and it worked. Could someone tell me why the following - * code works? (Or, why all similar codes I tried previously doesn't - * work.) FIXME. - */ - -static __inline__ void -ate_strobe (iot, ioh) - bus_space_tag_t iot; - bus_space_handle_t ioh; -{ - - /* - * Output same value twice. To speed-down execution? - */ - bus_space_write_1(iot, ioh, FE_BMPR16, FE_B16_SELECT); - bus_space_write_1(iot, ioh, FE_BMPR16, FE_B16_SELECT); - bus_space_write_1(iot, ioh, FE_BMPR16, FE_B16_SELECT | FE_B16_CLOCK); - bus_space_write_1(iot, ioh, FE_BMPR16, FE_B16_SELECT | FE_B16_CLOCK); - bus_space_write_1(iot, ioh, FE_BMPR16, FE_B16_SELECT); - bus_space_write_1(iot, ioh, FE_BMPR16, FE_B16_SELECT); -} - -void -ate_read_eeprom(iot, ioh, data) - bus_space_tag_t iot; - bus_space_handle_t ioh; - u_char *data; -{ - int n, count; - u_char val, bit; - - /* Read bytes from EEPROM; two bytes per an iteration. */ - for (n = 0; n < FE_EEPROM_SIZE / 2; n++) { - /* Reset the EEPROM interface. */ - bus_space_write_1(iot, ioh, FE_BMPR16, 0x00); - bus_space_write_1(iot, ioh, FE_BMPR17, 0x00); - bus_space_write_1(iot, ioh, FE_BMPR16, FE_B16_SELECT); - - /* Start EEPROM access. */ - bus_space_write_1(iot, ioh, FE_BMPR17, FE_B17_DATA); - ate_strobe(iot, ioh); - - /* Pass the iteration count to the chip. */ - count = 0x80 | n; - for (bit = 0x80; bit != 0x00; bit >>= 1) { - bus_space_write_1(iot, ioh, FE_BMPR17, - (count & bit) ? FE_B17_DATA : 0); - ate_strobe(iot, ioh); - } - bus_space_write_1(iot, ioh, FE_BMPR17, 0x00); - - /* Read a byte. */ - val = 0; - for (bit = 0x80; bit != 0x00; bit >>= 1) { - ate_strobe(iot, ioh); - if (bus_space_read_1(iot, ioh, FE_BMPR17) & - FE_B17_DATA) - val |= bit; - } - *data++ = val; - - /* Read one more byte. */ - val = 0; - for (bit = 0x80; bit != 0x00; bit >>= 1) { - ate_strobe(iot, ioh); - if (bus_space_read_1(iot, ioh, FE_BMPR17) & - FE_B17_DATA) - val |= bit; - } - *data++ = val; - } - - /* Make sure the EEPROM is turned off. */ - bus_space_write_1(iot, ioh, FE_BMPR16, 0); - bus_space_write_1(iot, ioh, FE_BMPR17, 0); - -#if ATE_DEBUG >= 3 - /* Report what we got. */ - data -= FE_EEPROM_SIZE; - log(LOG_INFO, "ate_read_eeprom: EEPROM at %04x:" - " %02x%02x%02x%02x %02x%02x%02x%02x -" - " %02x%02x%02x%02x %02x%02x%02x%02x -" - " %02x%02x%02x%02x %02x%02x%02x%02x -" - " %02x%02x%02x%02x %02x%02x%02x%02x\n", - (int) ioh, /* XXX */ - data[ 0], data[ 1], data[ 2], data[ 3], - data[ 4], data[ 5], data[ 6], data[ 7], - data[ 8], data[ 9], data[10], data[11], - data[12], data[13], data[14], data[15], - data[16], data[17], data[18], data[19], - data[20], data[21], data[22], data[23], - data[24], data[25], data[26], data[27], - data[28], data[29], data[30], data[31]); -#endif -} diff --git a/sys/dev/ic/ate_subr.h b/sys/dev/ic/ate_subr.h deleted file mode 100644 index eef8ac1cfb5..00000000000 --- a/sys/dev/ic/ate_subr.h +++ /dev/null @@ -1,47 +0,0 @@ -/* $NetBSD: ate_subr.h,v 1.3 2002/09/28 18:19:08 tsutsui Exp $ */ - -/* - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * - * 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. The name of the author 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 - * 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, - * 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. - */ - -/* - * EEPROM allocation of AT1700/RE2000. - */ -#define FE_ATI_EEP_ADDR 0x08 /* Station address. (8-13) */ -#define FE_ATI_EEP_MEDIA 0x18 /* Media type. */ -#define FE_ATI_EEP_MAGIC 0x19 /* XXX Magic. */ -#define FE_ATI_EEP_MODEL 0x1e /* Hardware type. */ -#define FE_ATI_EEP_REVISION 0x1f /* Hardware revision. */ - -#define FE_ATI_MODEL_AT1700T 0x00 -#define FE_ATI_MODEL_AT1700BT 0x01 -#define FE_ATI_MODEL_AT1700FT 0x02 -#define FE_ATI_MODEL_AT1700AT 0x03 - -void ate_read_eeprom __P((bus_space_tag_t, bus_space_handle_t, u_char *)); diff --git a/sys/dev/ic/mb86960.c b/sys/dev/ic/mb86960.c index 541c310502c..20dc7ca882f 100644 --- a/sys/dev/ic/mb86960.c +++ b/sys/dev/ic/mb86960.c @@ -1,4 +1,4 @@ -/* $NetBSD: mb86960.c,v 1.52 2002/09/29 17:10:37 tsutsui Exp $ */ +/* $NetBSD: mb86960.c,v 1.53 2002/10/04 15:22:29 tsutsui Exp $ */ /* * All Rights Reserved, Copyright (C) Fujitsu Limited 1995 @@ -32,7 +32,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mb86960.c,v 1.52 2002/09/29 17:10:37 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mb86960.c,v 1.53 2002/10/04 15:22:29 tsutsui Exp $"); /* * Device driver for Fujitsu MB86960A/MB86965A based Ethernet cards. @@ -1844,6 +1844,85 @@ mb86960_detach(sc) return (0); } +/* + * Routines to read all bytes from the config EEPROM (93C06) through MB86965A. + */ +void +mb86965_read_eeprom(iot, ioh, data) + bus_space_tag_t iot; + bus_space_handle_t ioh; + u_int8_t *data; +{ + int addr, op, bit; + u_int16_t val; + + /* Read bytes from EEPROM; two bytes per an iteration. */ + for (addr = 0; addr < FE_EEPROM_SIZE / 2; addr++) { + /* Reset the EEPROM interface. */ + bus_space_write_1(iot, ioh, FE_BMPR16, 0x00); + bus_space_write_1(iot, ioh, FE_BMPR17, 0x00); + bus_space_write_1(iot, ioh, FE_BMPR16, FE_B16_SELECT); + + /* Send start bit. */ + bus_space_write_1(iot, ioh, FE_BMPR17, FE_B17_DATA); + FE_EEPROM_DELAY(); + bus_space_write_1(iot, ioh, + FE_BMPR16, FE_B16_SELECT | FE_B16_CLOCK); + FE_EEPROM_DELAY(); + bus_space_write_1(iot, ioh, FE_BMPR16, FE_B16_SELECT); + + /* Send read command and read address. */ + op = 0x80 | addr; /* READ instruction */ + for (bit = 8; bit > 0; bit--) { + bus_space_write_1(iot, ioh, FE_BMPR17, + (op & (1 << (bit - 1))) ? FE_B17_DATA : 0); + FE_EEPROM_DELAY(); + bus_space_write_1(iot, ioh, + FE_BMPR16, FE_B16_SELECT | FE_B16_CLOCK); + FE_EEPROM_DELAY(); + bus_space_write_1(iot, ioh, FE_BMPR16, FE_B16_SELECT); + } + bus_space_write_1(iot, ioh, FE_BMPR17, 0x00); + + /* Read two bytes in each address */ + val = 0; + for (bit = 16; bit > 0; bit--) { + FE_EEPROM_DELAY(); + bus_space_write_1(iot, ioh, + FE_BMPR16, FE_B16_SELECT | FE_B16_CLOCK); + FE_EEPROM_DELAY(); + if (bus_space_read_1(iot, ioh, FE_BMPR17) & + FE_B17_DATA) + val |= 1 << (bit - 1); + bus_space_write_1(iot, ioh, + FE_BMPR16, FE_B16_SELECT); + } + data[addr * 2] = val >> 8; + data[addr * 2 + 1] = val & 0xff; + } + + /* Make sure the EEPROM is turned off. */ + bus_space_write_1(iot, ioh, FE_BMPR16, 0); + bus_space_write_1(iot, ioh, FE_BMPR17, 0); + +#if FE_DEBUG >= 3 + /* Report what we got. */ + log(LOG_INFO, "mb86965_read_eeprom: " + " %02x%02x%02x%02x %02x%02x%02x%02x -" + " %02x%02x%02x%02x %02x%02x%02x%02x -" + " %02x%02x%02x%02x %02x%02x%02x%02x -" + " %02x%02x%02x%02x %02x%02x%02x%02x\n", + data[ 0], data[ 1], data[ 2], data[ 3], + data[ 4], data[ 5], data[ 6], data[ 7], + data[ 8], data[ 9], data[10], data[11], + data[12], data[13], data[14], data[15], + data[16], data[17], data[18], data[19], + data[20], data[21], data[22], data[23], + data[24], data[25], data[26], data[27], + data[28], data[29], data[30], data[31]); +#endif +} + #if FE_DEBUG >= 1 void mb86960_dump(level, sc) @@ -1907,3 +1986,4 @@ mb86960_dump(level, sc) bus_space_write_1(bst, bsh, FE_DLCR7, save_dlcr7); } #endif + diff --git a/sys/dev/ic/mb86960reg.h b/sys/dev/ic/mb86960reg.h index aa1dda1074e..5c7988029ad 100644 --- a/sys/dev/ic/mb86960reg.h +++ b/sys/dev/ic/mb86960reg.h @@ -1,4 +1,4 @@ -/* $NetBSD: mb86960reg.h,v 1.6 2002/09/29 17:10:37 tsutsui Exp $ */ +/* $NetBSD: mb86960reg.h,v 1.7 2002/10/04 15:22:30 tsutsui Exp $ */ /* * All Rights Reserved, Copyright (C) Fujitsu Limited 1995 @@ -292,9 +292,9 @@ /* BMPR17 -- EEPROM data */ #define FE_B17_DATA 0x80 /* EEPROM data bit */ -/* BMPR18 ??? */ +/* BMPR18 I/O Base Address (Only JLI mode) */ -/* BMPR19 -- ISA interface configuration */ +/* BMPR19 -- Jumperless Setting (Only JLI mode) */ #define FE_B19_IRQ 0xC0 #define FE_B19_IRQ_SHIFT 6 @@ -309,10 +309,26 @@ */ /* Number of bytes in an EEPROM accessible through 86965. */ -#define FE_EEPROM_SIZE 32 +#define FE_EEPROM_SIZE 32 /* Offset for JLI config; automatically copied into BMPR19 at startup. */ -#define FE_EEPROM_CONF 0 +#define FE_EEPROM_CONF 0x00 + +/* Delay for 93c06 EEPROM access */ +#define FE_EEPROM_DELAY() DELAY(4) + +/* + * EEPROM allocation of AT1700/RE2000. + */ +#define FE_ATI_EEP_ADDR 0x08 /* Station address (0x08-0x0d) */ +#define FE_ATI_EEP_MEDIA 0x18 /* Media type */ +#define FE_ATI_EEP_MAGIC 0x19 /* XXX Magic */ +#define FE_ATI_EEP_MODEL 0x1e /* Hardware type */ +#define FE_ATI_MODEL_AT1700T 0x00 +#define FE_ATI_MODEL_AT1700BT 0x01 +#define FE_ATI_MODEL_AT1700FT 0x02 +#define FE_ATI_MODEL_AT1700AT 0x03 +#define FE_ATI_EEP_REVISION 0x1f /* Hardware revision */ /* * Some 86960 specific constants. diff --git a/sys/dev/ic/mb86960var.h b/sys/dev/ic/mb86960var.h index 4f76646566e..58ea7064095 100644 --- a/sys/dev/ic/mb86960var.h +++ b/sys/dev/ic/mb86960var.h @@ -1,4 +1,4 @@ -/* $NetBSD: mb86960var.h,v 1.28 2002/09/28 18:02:21 tsutsui Exp $ */ +/* $NetBSD: mb86960var.h,v 1.29 2002/10/04 15:22:30 tsutsui Exp $ */ /* * All Rights Reserved, Copyright (C) Fujitsu Limited 1995 @@ -204,3 +204,5 @@ int mb86960_enable __P((struct mb86960_softc *)); void mb86960_disable __P((struct mb86960_softc *)); int mb86960_activate __P((struct device *, enum devact)); int mb86960_detach __P((struct mb86960_softc *)); +void mb86965_read_eeprom __P((bus_space_tag_t, bus_space_handle_t, + u_int8_t *)); diff --git a/sys/dev/isa/if_ate.c b/sys/dev/isa/if_ate.c index 5841bdedf1a..be796e10026 100644 --- a/sys/dev/isa/if_ate.c +++ b/sys/dev/isa/if_ate.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_ate.c,v 1.35 2002/10/02 03:10:47 thorpej Exp $ */ +/* $NetBSD: if_ate.c,v 1.36 2002/10/04 15:22:30 tsutsui Exp $ */ /* * All Rights Reserved, Copyright (C) Fujitsu Limited 1995 @@ -32,7 +32,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_ate.c,v 1.35 2002/10/02 03:10:47 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ate.c,v 1.36 2002/10/04 15:22:30 tsutsui Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -49,7 +49,6 @@ __KERNEL_RCSID(0, "$NetBSD: if_ate.c,v 1.35 2002/10/02 03:10:47 thorpej Exp $"); #include <dev/ic/mb86960reg.h> #include <dev/ic/mb86960var.h> -#include <dev/ic/ate_subr.h> #include <dev/isa/isavar.h> @@ -224,7 +223,7 @@ ate_find(iot, ioh, iobase, irq) bus_space_handle_t ioh; int *iobase, *irq; { - u_char eeprom[FE_EEPROM_SIZE]; + u_int8_t eeprom[FE_EEPROM_SIZE]; int n; static int const irqmap[4][4] = { @@ -245,7 +244,7 @@ ate_find(iot, ioh, iobase, irq) }; #if ATE_DEBUG >= 4 - log(LOG_INFO, "ate_find: probe (0x%x) for ATI\n", iobase); + log(LOG_INFO, "ate_find: probe (0x%x) for ATE\n", iobase); #if 0 fe_dump(LOG_INFO, sc); #endif @@ -274,7 +273,7 @@ ate_find(iot, ioh, iobase, irq) * at this stage, but I cannot test the presence of the chip * any further without reading EEPROM. FIXME. */ - ate_read_eeprom(iot, ioh, eeprom); + mb86965_read_eeprom(iot, ioh, eeprom); /* Make sure that config info in EEPROM and 86965 agree. */ if (eeprom[FE_EEPROM_CONF] != bus_space_read_1(iot, ioh, FE_BMPR19)) { @@ -322,18 +321,18 @@ ate_detect(iot, ioh, enaddr) bus_space_handle_t ioh; u_int8_t enaddr[ETHER_ADDR_LEN]; { - u_char eeprom[FE_EEPROM_SIZE]; + u_int8_t eeprom[FE_EEPROM_SIZE]; int type; /* Get our station address from EEPROM. */ - ate_read_eeprom(iot, ioh, eeprom); + mb86965_read_eeprom(iot, ioh, eeprom); memcpy(enaddr, eeprom + FE_ATI_EEP_ADDR, ETHER_ADDR_LEN); /* Make sure we got a valid station address. */ if ((enaddr[0] & 0x03) != 0x00 || (enaddr[0] == 0x00 && enaddr[1] == 0x00 && enaddr[2] == 0x00)) { #ifdef ATE_DEBUG - printf("fmv_detect: invalid ethernet address\n"); + printf("ate_detect: invalid ethernet address\n"); #endif return (0); } diff --git a/sys/dev/mca/if_ate_mca.c b/sys/dev/mca/if_ate_mca.c index 8960b085942..77bd1336939 100644 --- a/sys/dev/mca/if_ate_mca.c +++ b/sys/dev/mca/if_ate_mca.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_ate_mca.c,v 1.7 2002/10/02 16:34:10 thorpej Exp $ */ +/* $NetBSD: if_ate_mca.c,v 1.8 2002/10/04 15:22:31 tsutsui Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -41,7 +41,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_ate_mca.c,v 1.7 2002/10/02 16:34:10 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ate_mca.c,v 1.8 2002/10/04 15:22:31 tsutsui Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -58,7 +58,6 @@ __KERNEL_RCSID(0, "$NetBSD: if_ate_mca.c,v 1.7 2002/10/02 16:34:10 thorpej Exp $ #include <dev/ic/mb86960reg.h> #include <dev/ic/mb86960var.h> -#include <dev/ic/ate_subr.h> #include <dev/mca/mcavar.h> #include <dev/mca/mcadevs.h> @@ -228,9 +227,9 @@ ate_mca_detect(iot, ioh, enaddr) bus_space_handle_t ioh; u_int8_t enaddr[ETHER_ADDR_LEN]; { - u_char eeprom[FE_EEPROM_SIZE]; + u_int8_t eeprom[FE_EEPROM_SIZE]; /* Get our station address from EEPROM. */ - ate_read_eeprom(iot, ioh, eeprom); - bcopy(eeprom + FE_ATI_EEP_ADDR, enaddr, ETHER_ADDR_LEN); + mb86965_read_eeprom(iot, ioh, eeprom); + memcpy(enaddr, eeprom + FE_ATI_EEP_ADDR, ETHER_ADDR_LEN); } |
