diff --git a/sys/dev/ic/we.c b/sys/dev/ic/we.c index 499293520e0a..68811b447a95 100644 --- a/sys/dev/ic/we.c +++ b/sys/dev/ic/we.c @@ -1,4 +1,4 @@ -/* $NetBSD: we.c,v 1.16 2010/03/19 14:57:52 tsutsui Exp $ */ +/* $NetBSD: we.c,v 1.17 2010/03/19 15:59:22 tsutsui Exp $ */ /*- * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. @@ -49,7 +49,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: we.c,v 1.16 2010/03/19 14:57:52 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: we.c,v 1.17 2010/03/19 15:59:22 tsutsui Exp $"); #include #include @@ -190,21 +190,23 @@ we_config(device_t self, struct we_softc *wsc, const char *typestr) * Set address and enable interface shared memory. */ if (sc->is790) { - /* XXX MAGIC CONSTANTS XXX */ - x = bus_space_read_1(wsc->sc_asict, wsc->sc_asich, 0x04); - bus_space_write_1(wsc->sc_asict, wsc->sc_asich, 0x04, x | 0x80); - bus_space_write_1(wsc->sc_asict, wsc->sc_asich, 0x0b, - ((wsc->sc_maddr >> 13) & 0x0f) | - ((wsc->sc_maddr >> 11) & 0x40) | - (bus_space_read_1(wsc->sc_asict, wsc->sc_asich, 0x0b) & - 0xb0)); - bus_space_write_1(wsc->sc_asict, wsc->sc_asich, 0x04, x); + x = bus_space_read_1(wsc->sc_asict, wsc->sc_asich, WE790_HWR); + bus_space_write_1(wsc->sc_asict, wsc->sc_asich, + WE790_HWR, x | WE790_HWR_SWH); + bus_space_write_1(wsc->sc_asict, wsc->sc_asich, WE790_RAR, + ((wsc->sc_maddr >> WE790_RAR_OFF_SHIFT) & WE790_RAR_OFF) | + ((wsc->sc_maddr & (1 << WE790_RAR_BASE_SHIFT)) != 0 ? + WE790_RAR_BASE1 : WE790_RAR_BASE0) | + (bus_space_read_1(wsc->sc_asict, wsc->sc_asich, WE790_RAR) & + ~(WE790_RAR_OFF | WE790_RAR_BASE))); + bus_space_write_1(wsc->sc_asict, wsc->sc_asich, WE790_HWR, x); wsc->sc_msr_proto = 0x00; sc->cr_proto = 0x00; } else { #ifdef TOSH_ETHER if (wsc->sc_type == WE_TYPE_TOSHIBA1 || wsc->sc_type == WE_TYPE_TOSHIBA4) { + /* XXX MAGIC CONSTANTS XXX */ bus_space_write_1(wsc->sc_asict, wsc->sc_asich, WE_MSR + 1, ((wsc->sc_maddr >> 8) & 0xe0) | 0x04); diff --git a/sys/dev/ic/wereg.h b/sys/dev/ic/wereg.h index 786843f842df..5119ddb0851c 100644 --- a/sys/dev/ic/wereg.h +++ b/sys/dev/ic/wereg.h @@ -1,4 +1,4 @@ -/* $NetBSD: wereg.h,v 1.2 2001/07/04 11:14:10 jdolecek Exp $ */ +/* $NetBSD: wereg.h,v 1.3 2010/03/19 15:59:22 tsutsui Exp $ */ /* * National Semiconductor DS8390 NIC register definitions. @@ -135,10 +135,21 @@ #define WE790_RAR 0x0b +#define WE790_RAR_OFF 0x0f /* memory address offset */ +#define WE790_RAR_SZ 0x30 /* mask of memory buffer size */ #define WE790_RAR_SZ8 0x00 /* 8k memory buffer */ #define WE790_RAR_SZ16 0x10 /* 16k memory buffer */ #define WE790_RAR_SZ32 0x20 /* 32k memory buffer */ #define WE790_RAR_SZ64 0x30 /* 64k memory buffer */ +#define WE790_RAR_BASE 0x40 /* mask of memory base address */ +#define WE790_RAR_BASE0 0x00 /* base is 0x0C0000 */ +#define WE790_RAR_BASE1 0x40 /* base is 0x0E0000 */ +#if 0 +#define WE790_RAR_BASE2 0x80 /* base is 0xFC0000 */ +#define WE790_RAR_BASE3 0xc0 /* base is 0xFE0000 */ +#endif +#define WE790_RAR_BASE_SHIFT 17 /* base is switched by A17 */ +#define WE790_RAR_OFF_SHIFT 13 /* offset is specified by A16-A13 */ /* * General Control Register (GCR)