MII access routines for ASIX AX88190.

This commit is contained in:
enami 2001-08-04 11:38:57 +00:00
parent 845203d519
commit 97ceb61316
8 changed files with 339 additions and 21 deletions

@ -1,4 +1,4 @@
# $NetBSD: files,v 1.452 2001/07/14 02:05:54 christos Exp $
# $NetBSD: files,v 1.453 2001/08/04 11:38:58 enami Exp $
# @(#)files.newconf 7.5 (Berkeley) 5/10/93
@ -562,6 +562,10 @@ file dev/ic/mm58167.c mm58167
define dl10019
file dev/ic/dl10019.c dl10019
# ASIX AX88190 NE2000-compatible network interface subroutines
define ax88190
file dev/ic/ax88190.c ax88190
# WD/SMC 80x3 family, SMC Elite Ultra [8216], SMC EtherEZ
device we: ether, ifnet, arp, dp8390nic
file dev/ic/we.c we

191
sys/dev/ic/ax88190.c Normal file

@ -0,0 +1,191 @@
/* $NetBSD: ax88190.c,v 1.1 2001/08/04 11:38:57 enami Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Enami Tsugutomo.
*
* 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.
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <sys/socket.h>
#include <net/if.h>
#include <net/if_dl.h>
#include <net/if_types.h>
#include <net/if_media.h>
#include <net/if_ether.h>
#include <machine/bus.h>
#include <dev/mii/miivar.h>
#include <dev/mii/mii.h>
#include <dev/mii/mii_bitbang.h>
#include <dev/ic/dp8390reg.h>
#include <dev/ic/dp8390var.h>
#include <dev/ic/ne2000reg.h>
#include <dev/ic/ne2000var.h>
#include <dev/ic/ax88190reg.h>
#include <dev/ic/ax88190var.h>
int ax88190_mii_readreg(struct device *, int, int);
void ax88190_mii_writereg(struct device *, int, int, int);
void ax88190_mii_statchg(struct device *);
/*
* MII bit-bang glue.
*/
u_int32_t ax88190_mii_bitbang_read(struct device *);
void ax88190_mii_bitbang_write(struct device *, u_int32_t);
const struct mii_bitbang_ops ax88190_mii_bitbang_ops = {
ax88190_mii_bitbang_read,
ax88190_mii_bitbang_write,
{
AX88190_MEMR_MDO, /* MII_BIT_MDO */
AX88190_MEMR_MDI, /* MII_BIT_MDI */
AX88190_MEMR_MDC, /* MII_BIT_MDC */
0, /* MII_BIT_DIR_HOST_PHY */
AX88190_MEMR_MDIR, /* MII_BIT_DIR_PHY_HOST */
}
};
void
ax88190_media_init(struct dp8390_softc *sc)
{
struct ifnet *ifp = &sc->sc_ec.ec_if;
sc->sc_mii.mii_ifp = ifp;
sc->sc_mii.mii_readreg = ax88190_mii_readreg;
sc->sc_mii.mii_writereg = ax88190_mii_writereg;
sc->sc_mii.mii_statchg = ax88190_mii_statchg;
ifmedia_init(&sc->sc_mii.mii_media, 0, dp8390_mediachange,
dp8390_mediastatus);
mii_attach(&sc->sc_dev, &sc->sc_mii, 0xffffffff, MII_PHY_ANY,
MII_OFFSET_ANY, 0);
if (LIST_FIRST(&sc->sc_mii.mii_phys) == NULL) {
ifmedia_add(&sc->sc_mii.mii_media, IFM_ETHER|IFM_NONE, 0,
NULL);
ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_NONE);
} else
ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_AUTO);
}
void
ax88190_media_fini(struct dp8390_softc *sc)
{
mii_detach(&sc->sc_mii, MII_PHY_ANY, MII_OFFSET_ANY);
}
int
ax88190_mediachange(struct dp8390_softc *sc)
{
mii_mediachg(&sc->sc_mii);
return (0);
}
void
ax88190_mediastatus(struct dp8390_softc *sc, struct ifmediareq *ifmr)
{
mii_pollstat(&sc->sc_mii);
ifmr->ifm_status = sc->sc_mii.mii_media_status;
ifmr->ifm_active = sc->sc_mii.mii_media_active;
}
void
ax88190_init_card(struct dp8390_softc *sc)
{
mii_mediachg(&sc->sc_mii);
}
void
ax88190_stop_card(struct dp8390_softc *sc)
{
mii_down(&sc->sc_mii);
}
u_int32_t
ax88190_mii_bitbang_read(self)
struct device *self;
{
struct ne2000_softc *sc = (void *)self;
return (bus_space_read_1(sc->sc_asict, sc->sc_asich, AX88190_MEMR));
}
void
ax88190_mii_bitbang_write(self, val)
struct device *self;
u_int32_t val;
{
struct ne2000_softc *sc = (void *)self;
bus_space_write_1(sc->sc_asict, sc->sc_asich, AX88190_MEMR, val);
}
int
ax88190_mii_readreg(self, phy, reg)
struct device *self;
int phy, reg;
{
return (mii_bitbang_readreg(self, &ax88190_mii_bitbang_ops, phy, reg));
}
void
ax88190_mii_writereg(self, phy, reg, val)
struct device *self;
int phy, reg, val;
{
mii_bitbang_writereg(self, &ax88190_mii_bitbang_ops, phy, reg, val);
}
void
ax88190_mii_statchg(self)
struct device *self;
{
/* XXX */
}

69
sys/dev/ic/ax88190reg.h Normal file

@ -0,0 +1,69 @@
/* $NetBSD: ax88190reg.h,v 1.1 2001/08/04 11:38:57 enami Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Enami Tsugutomo.
*
* 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.
*/
#ifndef _DEV_IC_AX88190REG_H_
#define _DEV_IC_AX88190REG_H_
#define AX88190_MEMR 0x04 /* MII/EEPROM/ Management Register */
#define AX88190_MEMR_MDC 0x01 /* MII Clock */
#define AX88190_MEMR_MDIR 0x02 /* MII STA MDIO signal direction
assert -> input */
#define AX88190_MEMR_MDI 0x04 /* MII Data In */
#define AX88190_MEMR_MDO 0x08 /* MII Data Out */
#define AX88190_MEMR_EECS 0x10 /* EEPROM Chip Select */
#define AX88190_MEMR_EEI 0x20 /* EEPROM Data In */
#define AX88190_MEMR_EEO 0x40 /* EEPROM Data Out */
#define AX88190_MEMR_EECLK 0x80 /* EEPROM Clock */
/*
* Offset of LAN IOBASE0 and IOBASE1, and its size.
*/
#define AX88190_LAN_IOBASE 0x3ca
#define AX88190_LAN_IOSIZE 4
/*
* Offset of NODE ID in SRAM memory of ASIX AX88190.
*/
#define AX88190_NODEID_OFFSET 0x400
/*
* Start of SRAM buffer.
*/
#define AX88190_BUFFER_START 0x800
#endif /* _DEV_IC_AX88190REG_H_ */

52
sys/dev/ic/ax88190var.h Normal file

@ -0,0 +1,52 @@
/* $NetBSD: ax88190var.h,v 1.1 2001/08/04 11:38:57 enami Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Enami Tsugutomo.
*
* 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.
*/
#ifndef _DEV_IC_AX88190VAR_H_
#define _DEV_IC_AX88190VAR_H_
#ifdef _KERNEL
void ax88190_media_init(struct dp8390_softc *);
void ax88190_media_fini(struct dp8390_softc *);
int ax88190_mediachange(struct dp8390_softc *);
void ax88190_mediastatus(struct dp8390_softc *, struct ifmediareq *ifmr);
void ax88190_init_card(struct dp8390_softc *);
void ax88190_stop_card(struct dp8390_softc *);
#endif /* _KERNEL */
#endif /* _DEV_IC_AX88190VAR_H_ */

@ -1,4 +1,4 @@
/* $NetBSD: ne2000.c,v 1.35 2001/07/07 15:53:20 thorpej Exp $ */
/* $NetBSD: ne2000.c,v 1.36 2001/08/04 11:38:57 enami Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@ -89,6 +89,8 @@
#include <dev/ic/ne2000reg.h>
#include <dev/ic/ne2000var.h>
#include <dev/ic/ax88190reg.h>
#if BYTE_ORDER == BIG_ENDIAN
#include <machine/bswap.h>
#endif
@ -265,7 +267,7 @@ ne2000_attach(nsc, myea)
bus_space_write_1(nict, nich, ED_P0_DCR, ED_DCR_WTS);
NIC_BARRIER(nict, nich);
ne2000_readmem(nict, nich, asict, asich,
NE2000_AX88190_NODEID_OFFSET, dsc->sc_enaddr,
AX88190_NODEID_OFFSET, dsc->sc_enaddr,
ETHER_ADDR_LEN, useword);
} else {
ne2000_readmem(nict, nich, asict, asich, 0, romdata,
@ -893,7 +895,7 @@ ne2000_ipkdb_attach(kip)
/* Select word transfer */
bus_space_write_1(nict, nich, ED_P0_DCR, ED_DCR_WTS);
ne2000_readmem(nict, nich, np->sc_asict, np->sc_asich,
NE2000_AX88190_NODEID_OFFSET, kip->myenetaddr,
AX88190_NODEID_OFFSET, kip->myenetaddr,
ETHER_ADDR_LEN, useword);
} else {
ne2000_readmem(nict, nich, np->sc_asict, np->sc_asich,

@ -1,4 +1,4 @@
/* $NetBSD: ne2000reg.h,v 1.3 2000/02/09 15:40:24 enami Exp $ */
/* $NetBSD: ne2000reg.h,v 1.4 2001/08/04 11:38:57 enami Exp $ */
/*
* National Semiconductor DS8390 NIC register definitions.
@ -29,15 +29,4 @@
#define NE2000_ASIC_DATA 0x00 /* remote DMA/data register */
#define NE2000_ASIC_RESET 0x0f /* reset on read */
/*
* Offset of NODE ID in SRAM memory of ASIX AX88190.
*/
#define NE2000_AX88190_NODEID_OFFSET 0x400
/*
* Offset of LAN IOBASE0 and IOBASE1, and its size.
*/
#define NE2000_AX88190_LAN_IOBASE 0x3ca
#define NE2000_AX88190_LAN_IOSIZE 4
#endif /* _DEV_IC_NE2000REG_H_ */

@ -1,4 +1,4 @@
# $NetBSD: files.pcmcia,v 1.38 2001/05/06 03:26:39 ichiro Exp $
# $NetBSD: files.pcmcia,v 1.39 2001/08/04 11:38:58 enami Exp $
#
# Config.new file and device description for machine-independent PCMCIA code.
# Included by ports that need it.
@ -21,7 +21,7 @@ file dev/pcmcia/if_ep_pcmcia.c ep_pcmcia
# National Semiconductor DS8390/WD83C690-based boards
# (NE[12]000, and clones)
attach ne at pcmcia with ne_pcmcia: rtl80x9, dl10019, mii_bitbang
attach ne at pcmcia with ne_pcmcia: rtl80x9, dl10019, ax88190, mii_bitbang
file dev/pcmcia/if_ne_pcmcia.c ne_pcmcia
# Adaptec APA-1460 SCSI Host Adapter

@ -1,4 +1,4 @@
/* $NetBSD: if_ne_pcmcia.c,v 1.79 2001/07/31 17:01:15 christos Exp $ */
/* $NetBSD: if_ne_pcmcia.c,v 1.80 2001/08/04 11:38:58 enami Exp $ */
/*
* Copyright (c) 1997 Marc Horowitz. All rights reserved.
@ -58,6 +58,9 @@
#include <dev/ic/dl10019var.h>
#include <dev/ic/ax88190reg.h>
#include <dev/ic/ax88190var.h>
int ne_pcmcia_match __P((struct device *, struct cfdata *, void *));
void ne_pcmcia_attach __P((struct device *, struct device *, void *));
int ne_pcmcia_detach __P((struct device *, int));
@ -694,6 +697,14 @@ again:
++i;
goto again;
}
dsc->sc_mediachange = ax88190_mediachange;
dsc->sc_mediastatus = ax88190_mediastatus;
dsc->init_card = ax88190_init_card;
dsc->stop_card = ax88190_stop_card;
dsc->sc_media_init = ax88190_media_init;
dsc->sc_media_fini = ax88190_media_fini;
nsc->sc_type = NE2000_TYPE_AX88190;
typestr = " (AX88190)";
}
@ -897,7 +908,7 @@ ne_pcmcia_ax88190_set_iobase(psc)
int rv = 1, mwindow;
u_int last_liobase, new_liobase;
if (pcmcia_mem_alloc(psc->sc_pf, NE2000_AX88190_LAN_IOSIZE, &pcmh)) {
if (pcmcia_mem_alloc(psc->sc_pf, AX88190_LAN_IOSIZE, &pcmh)) {
#if 0
printf("%s: can't alloc mem for LAN iobase\n",
dsc->sc_dev.dv_xname);
@ -905,7 +916,7 @@ ne_pcmcia_ax88190_set_iobase(psc)
goto fail_1;
}
if (pcmcia_mem_map(psc->sc_pf, PCMCIA_MEM_ATTR,
NE2000_AX88190_LAN_IOBASE, NE2000_AX88190_LAN_IOSIZE,
AX88190_LAN_IOBASE, AX88190_LAN_IOSIZE,
&pcmh, &offset, &mwindow)) {
printf("%s: can't map mem for LAN iobase\n",
dsc->sc_dev.dv_xname);