From 4d65db2d978a7b84efa4821893da4c2072219c1e Mon Sep 17 00:00:00 2001 From: is Date: Thu, 11 May 2000 19:24:35 +0000 Subject: [PATCH] RATOC REX-R280 (another if_mbe_pcmcia card) support by UCHIYAMA Yasushi. Originally part of pr 6789, reworked by the submitter to fit into -current. --- sys/dev/pcmcia/if_mbe_pcmcia.c | 109 +++++++++++++++++++++++-------- sys/dev/pcmcia/pcmciadevs | 6 +- sys/dev/pcmcia/pcmciadevs.h | 8 ++- sys/dev/pcmcia/pcmciadevs_data.h | 16 ++++- 4 files changed, 108 insertions(+), 31 deletions(-) diff --git a/sys/dev/pcmcia/if_mbe_pcmcia.c b/sys/dev/pcmcia/if_mbe_pcmcia.c index 06e0a41d3fcb..7ce909fee8be 100644 --- a/sys/dev/pcmcia/if_mbe_pcmcia.c +++ b/sys/dev/pcmcia/if_mbe_pcmcia.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_mbe_pcmcia.c,v 1.17 2000/02/04 09:30:28 enami Exp $ */ +/* $NetBSD: if_mbe_pcmcia.c,v 1.18 2000/05/11 19:24:35 is Exp $ */ /*- * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. @@ -79,37 +79,45 @@ void mbe_pcmcia_disable __P((struct mb86960_softc *)); struct mbe_pcmcia_get_enaddr_args { u_int8_t enaddr[ETHER_ADDR_LEN]; + int maddr; }; -int mbe_pcmcia_get_enaddr __P((struct pcmcia_tuple *, void *)); +int mbe_pcmcia_get_enaddr_from_cis __P((struct pcmcia_tuple *, void *)); +int mbe_pcmcia_get_enaddr_from_mem __P((struct mbe_pcmcia_softc *, + struct mbe_pcmcia_get_enaddr_args *)); const struct mbe_pcmcia_product { struct pcmcia_product mpp_product; u_int32_t mpp_ioalign; /* required alignment */ + int enet_maddr; } mbe_pcmcia_products[] = { { { PCMCIA_STR_TDK_LAK_CD021BX, PCMCIA_VENDOR_TDK, PCMCIA_PRODUCT_TDK_LAK_CD021BX, 0 }, - 0 }, + 0, -1}, { { PCMCIA_STR_TDK_LAK_CF010, PCMCIA_VENDOR_TDK, PCMCIA_PRODUCT_TDK_LAK_CF010, 0 }, - 0 }, + 0, -1}, #if 0 /* XXX 86960-based? */ { { PCMCIA_STR_TDK_LAK_DFL9610, PCMCIA_VENDOR_TDK, PCMCIA_PRODUCT_TDK_LAK_DFL9610, 1 }, - 0 }, + 0, -1 }, #endif { { PCMCIA_STR_CONTEC_CNETPC, PCMCIA_VENDOR_CONTEC, PCMCIA_PRODUCT_CONTEC_CNETPC, 0 }, - 0 }, + 0, -1 }, { { PCMCIA_STR_FUJITSU_LA501, PCMCIA_VENDOR_FUJITSU, PCMCIA_PRODUCT_FUJITSU_LA501, 0 }, - 0x20 }, + 0x20, -1 }, { { PCMCIA_STR_FUJITSU_LA10S, PCMCIA_VENDOR_FUJITSU, PCMCIA_PRODUCT_FUJITSU_LA10S, 0 }, - 0 }, + 0, -1 }, + + { { PCMCIA_STR_RATOC_REX_R280, PCMCIA_VENDOR_RATOC, + PCMCIA_PRODUCT_RATOC_REX_R280, 0 }, + 0, 0x1fc }, { { NULL } } }; @@ -188,27 +196,36 @@ mbe_pcmcia_attach(parent, self, aux) printf(": %s\n", mpp->mpp_product.pp_name); - /* Read station address from CIS. */ - rv = pcmcia_scan_cis(parent, mbe_pcmcia_get_enaddr, &pgea); - if (rv == -1) { - printf("%s: Couldn't read CIS to get ethernet address\n", - sc->sc_dev.dv_xname); - goto no_enaddr; - } else if (rv == 0) { - printf("%s: Couldn't get ethernet address from CIS\n", - sc->sc_dev.dv_xname); - goto no_enaddr; - } - + /* Read station address from mem or CIS. */ + if (mpp->enet_maddr >= 0) { + pgea.maddr = mpp->enet_maddr; + if (mbe_pcmcia_get_enaddr_from_mem(psc, &pgea) != 0) { + printf("%s: Couldn't get ethernet address " + "from mem\n", sc->sc_dev.dv_xname); + goto no_enaddr; + } + } else { + rv = pcmcia_scan_cis(parent, + mbe_pcmcia_get_enaddr_from_cis, &pgea); + if (rv == -1) { + printf("%s: Couldn't read CIS to get ethernet " + "address\n", sc->sc_dev.dv_xname); + goto no_enaddr; + } else if (rv == 0) { + printf("%s: Couldn't get ethernet address " + "from CIS\n", sc->sc_dev.dv_xname); + goto no_enaddr; + } #ifdef DIAGNOSTIC - if (rv != 1) { - printf("%s: pcmcia_scan_cis returns %d\n", sc->sc_dev.dv_xname, - rv); - panic("mbe_pcmcia_attach"); - } - printf("%s: Ethernet address from CIS: %s\n", - sc->sc_dev.dv_xname, ether_sprintf(pgea.enaddr)); + if (rv != 1) { + printf("%s: pcmcia_scan_cis returns %d\n", + sc->sc_dev.dv_xname, rv); + panic("mbe_pcmcia_attach"); + } + printf("%s: Ethernet address from CIS: %s\n", + sc->sc_dev.dv_xname, ether_sprintf(pgea.enaddr)); #endif + } /* Perform generic initialization. */ mb86960_attach(sc, MB86960_TYPE_86965, pgea.enaddr); @@ -292,7 +309,7 @@ mbe_pcmcia_disable(sc) } int -mbe_pcmcia_get_enaddr(tuple, arg) +mbe_pcmcia_get_enaddr_from_cis(tuple, arg) struct pcmcia_tuple *tuple; void *arg; { @@ -314,3 +331,39 @@ mbe_pcmcia_get_enaddr(tuple, arg) } return (0); } + +int +mbe_pcmcia_get_enaddr_from_mem(psc, ea) + struct mbe_pcmcia_softc *psc; + struct mbe_pcmcia_get_enaddr_args *ea; +{ + struct mb86960_softc *sc = &psc->sc_mb86960; + struct pcmcia_mem_handle pcmh; + bus_addr_t offset; + int i, mwindow; + + if (ea->maddr < 0) + return (1); + + if (pcmcia_mem_alloc(psc->sc_pf, ETHER_ADDR_LEN * 2, &pcmh)) { + printf("%s: can't alloc mem for enet addr\n", + sc->sc_dev.dv_xname); + return (1); + } + + if (pcmcia_mem_map(psc->sc_pf, PCMCIA_MEM_ATTR, ea->maddr, + ETHER_ADDR_LEN * 2, &pcmh, &offset, &mwindow)) { + printf("%s: can't map mem for enet addr\n", + sc->sc_dev.dv_xname); + return (1); + } + + for (i = 0; i < ETHER_ADDR_LEN; i++) + ea->enaddr[i] = bus_space_read_1(pcmh.memt, pcmh.memh, + offset + (i * 2)); + + pcmcia_mem_unmap(psc->sc_pf, mwindow); + pcmcia_mem_free(psc->sc_pf, &pcmh); + + return (0); +} diff --git a/sys/dev/pcmcia/pcmciadevs b/sys/dev/pcmcia/pcmciadevs index 991d689e9d91..e81f1a74dd38 100644 --- a/sys/dev/pcmcia/pcmciadevs +++ b/sys/dev/pcmcia/pcmciadevs @@ -1,4 +1,4 @@ -$NetBSD: pcmciadevs,v 1.88 2000/04/17 12:00:35 joda Exp $ +$NetBSD: pcmciadevs,v 1.89 2000/05/11 19:24:35 is Exp $ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -75,6 +75,7 @@ vendor CONTEC 0xc001 Contec vendor COREGA 0xc00f Corega K.K. vendor ALLIEDTELESIS 0xc00f Allied Telesis K.K. vendor HAGIWARASYSCOM 0xc012 Hagiwara SYS-COM +vendor RATOC 0xc015 RATOC System Inc. /* * List of known products. Grouped by vendor. @@ -218,6 +219,9 @@ product BAY STACK_660 0x0807 BayStack 660 Wireless LAN /* Raylink/WebGear */ product RAYTHEON WLAN 0x0000 WLAN Adapter +/* RATOC System Inc. Products */ +product RATOC REX_R280 0x1 RATOC REX-R280 + /* Cards we know only by their cis */ vendor PREMAX -1 Premax vendor PLANET -1 Planet diff --git a/sys/dev/pcmcia/pcmciadevs.h b/sys/dev/pcmcia/pcmciadevs.h index 38aa4ef2c996..cb2b0f5a4a7b 100644 --- a/sys/dev/pcmcia/pcmciadevs.h +++ b/sys/dev/pcmcia/pcmciadevs.h @@ -1,4 +1,4 @@ -/* $NetBSD: pcmciadevs.h,v 1.88 2000/04/17 12:01:20 joda Exp $ */ +/* $NetBSD: pcmciadevs.h,v 1.89 2000/05/11 19:24:36 is Exp $ */ /* * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT. @@ -82,6 +82,7 @@ #define PCMCIA_VENDOR_COREGA 0xc00f /* Corega K.K. */ #define PCMCIA_VENDOR_ALLIEDTELESIS 0xc00f /* Allied Telesis K.K. */ #define PCMCIA_VENDOR_HAGIWARASYSCOM 0xc012 /* Hagiwara SYS-COM */ +#define PCMCIA_VENDOR_RATOC 0xc015 /* RATOC System Inc. */ /* * List of known products. Grouped by vendor. @@ -369,6 +370,11 @@ #define PCMCIA_PRODUCT_RAYTHEON_WLAN 0x0000 #define PCMCIA_STR_RAYTHEON_WLAN "WLAN Adapter" +/* RATOC System Inc. Products */ +#define PCMCIA_CIS_RATOC_REX_R280 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_RATOC_REX_R280 0x1 +#define PCMCIA_STR_RATOC_REX_R280 "RATOC REX-R280" + /* Cards we know only by their cis */ #define PCMCIA_VENDOR_PREMAX -1 /* Premax */ #define PCMCIA_VENDOR_PLANET -1 /* Planet */ diff --git a/sys/dev/pcmcia/pcmciadevs_data.h b/sys/dev/pcmcia/pcmciadevs_data.h index 927713ec466e..83527405c07e 100644 --- a/sys/dev/pcmcia/pcmciadevs_data.h +++ b/sys/dev/pcmcia/pcmciadevs_data.h @@ -1,4 +1,4 @@ -/* $NetBSD: pcmciadevs_data.h,v 1.88 2000/04/17 12:01:21 joda Exp $ */ +/* $NetBSD: pcmciadevs_data.h,v 1.89 2000/05/11 19:24:36 is Exp $ */ /* * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT. @@ -548,6 +548,13 @@ struct pcmcia_knowndev pcmcia_knowndevs[] = { "Raytheon", "WLAN Adapter" }, }, + { + PCMCIA_VENDOR_RATOC, PCMCIA_PRODUCT_RATOC_REX_R280, + PCMCIA_CIS_RATOC_REX_R280, + 0, + "RATOC System Inc.", + "RATOC REX-R280" }, + }, { PCMCIA_VENDOR_UNKNOWN, PCMCIA_PRODUCT_MEGAHERTZ_XJ2288, PCMCIA_CIS_MEGAHERTZ_XJ2288, @@ -1003,6 +1010,13 @@ struct pcmcia_knowndev pcmcia_knowndevs[] = { "Hagiwara SYS-COM", NULL, }, + { + PCMCIA_VENDOR_RATOC, 0, + PCMCIA_KNOWNDEV_NOPROD, + PCMCIA_CIS_INVALID, + "RATOC System Inc.", + NULL, + }, { PCMCIA_VENDOR_PREMAX, 0, PCMCIA_KNOWNDEV_NOPROD,