Add RealTek RTL8150 USB to fast Ethernet controller driver.
This driver now supports the Melco LUA-KTX and the GREEN HOUSE GH-USB100B. Reviewed by: imp MFC after: 2 weeks
This commit is contained in:
parent
97daf7ec12
commit
11e04b0528
@ -19,7 +19,7 @@ options {
|
||||
# Setup some shorthand for regex that we use later in the file.
|
||||
set ethernet-nic-regex
|
||||
"(an|ar|ath|aue|awi|bge|cm|cnw|cs|cue|dc|de|ed|el|em|ep|ex|\
|
||||
fe|fxp|gem|gx|hme|ie|kue|lge|lnc|my|nge|pcn|ray|rl|\
|
||||
fe|fxp|gem|gx|hme|ie|kue|lge|lnc|my|nge|pcn|ray|rl|rue|\
|
||||
sf|sis|sk|sn|snc|ste|ti|tl|tx|txp|vr|vx|wb|wi|xe|xl)[0-9]+";
|
||||
set scsi-controller-regex
|
||||
"(adv|advw|aic|aha|ahb|ahc|ahd|bt|ct|iir|isp|mly|mpt|ncv|nsp|\
|
||||
|
@ -27,7 +27,7 @@ device "Entrega Serial with UART"
|
||||
# it shouldn't be too big a deal :-)
|
||||
#
|
||||
device "USB ethernet"
|
||||
devname "[ack]ue[0-9]+"
|
||||
devname "[ackr]ue[0-9]+"
|
||||
attach "/etc/pccard_ether ${DEVNAME} start"
|
||||
detach "/etc/pccard_ether ${DEVNAME} stop"
|
||||
|
||||
|
@ -185,6 +185,7 @@ MAN= aac.4 \
|
||||
rndtest.4 \
|
||||
route.4 \
|
||||
rp.4 \
|
||||
rue.4 \
|
||||
sa.4 \
|
||||
sbc.4 \
|
||||
sbp.4 \
|
||||
|
128
share/man/man4/rue.4
Normal file
128
share/man/man4/rue.4
Normal file
@ -0,0 +1,128 @@
|
||||
.\"
|
||||
.\" Copyright (c) 2001-2003, Shunsuke Akiyama <akiyama@FreeBSD.org>.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" 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.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd May 3, 2003
|
||||
.Dt RUE 4
|
||||
.Os FreeBSD
|
||||
.Sh NAME
|
||||
.Nm rue
|
||||
.Nd
|
||||
RealTek RTL8150 USB To Fast Ethernet controller driver
|
||||
.Sh SYNOPSIS
|
||||
.Cd "device uhci"
|
||||
.Cd "device ohci"
|
||||
.Cd "device usb"
|
||||
.Cd "device miibus"
|
||||
.Cd "device rue"
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
driver provides support for USB Ethernet adapters based on the RealTek
|
||||
RTL8150 USB to Fast Ethernet controller chip.
|
||||
This includes the Melco Inc. LUA-KTX and the GREEN HOUSE GH-USB100B.
|
||||
.Pp
|
||||
The RTL8150 contains a integrated Fast Ethernet MAC, which supports
|
||||
both 10 and 100Mbps speeds in either full or half duplex.
|
||||
Although designed to interface with
|
||||
100Mbps peripheral, the existing USB standard specifies a maximum
|
||||
transfer speed of 12Mbps.
|
||||
Users should therefore not expect to actually
|
||||
achieve 100Mbps speeds with this device.
|
||||
.Pp
|
||||
The
|
||||
.Nm
|
||||
driver supports the following media types:
|
||||
.Pp
|
||||
.Bl -tag -width xxxxxxxxxxxxxxxx
|
||||
.It autoselect
|
||||
Enable auto selection of the media type and options.
|
||||
The user can manually override
|
||||
the auto selected mode by adding media options to the
|
||||
.Pa /etc/rc.conf
|
||||
file.
|
||||
.It 10baseT/UTP
|
||||
Set 10Mbps operation.
|
||||
The
|
||||
.Ar mediaopt
|
||||
option can also be used to select either
|
||||
.Ar full-duplex
|
||||
or
|
||||
.Ar half-duplex
|
||||
modes.
|
||||
.It 100baseTX
|
||||
Set 100Mbps (Fast Ethernet) operation.
|
||||
The
|
||||
.Ar mediaopt
|
||||
option can also be used to select either
|
||||
.Ar full-duplex
|
||||
or
|
||||
.Ar half-duplex
|
||||
modes.
|
||||
.El
|
||||
.Pp
|
||||
The
|
||||
.Nm
|
||||
driver supports the following media options:
|
||||
.Pp
|
||||
.Bl -tag -width xxxxxxxxxxxxxxxx
|
||||
.It full-duplex
|
||||
Force full duplex operation.
|
||||
.It half-duplex
|
||||
Force half duplex operation.
|
||||
.El
|
||||
.Pp
|
||||
For more information on configuring this device, see
|
||||
.Xr ifconfig 8 .
|
||||
.Sh DIAGNOSTICS
|
||||
.Bl -diag
|
||||
.It "rue%d: watchdog timeout"
|
||||
A packet was queued for transmission and a transmit command was
|
||||
issued, however the device failed to acknowledge the transmission
|
||||
before a timeout expired.
|
||||
.It "rue%d: rx list init failed"
|
||||
The driver failed to allocate an mbuf for the transmitter ring.
|
||||
.It "rue%d: no memory for rx list"
|
||||
The driver failed to allocate an mbuf for the receiver ring.
|
||||
.Sh SEE ALSO
|
||||
.Xr arp 4 ,
|
||||
.Xr netintro 4 ,
|
||||
.Xr ng_ether 4 ,
|
||||
.Xr ifconfig 8
|
||||
.Rs
|
||||
.%T ReakTek RTL8150 data sheet
|
||||
.%O ftp://ftp.realtek.com.tw/lancard/data_sheet/8150/
|
||||
.Re
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm
|
||||
device driver first appeared in
|
||||
.Fx 5.1 .
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Nm
|
||||
driver was written by
|
||||
.An Shunsuke Akiyama Aq akiyama@FreeBSD.org .
|
@ -2131,6 +2131,10 @@ device cue
|
||||
# the Netgear EA101, the D-Link DSB-650, the SMC 2102USB
|
||||
# and 2104USB, and the Corega USB-T.
|
||||
device kue
|
||||
#
|
||||
# RealTek RTL8150 USB to fast ethernet. Supports the Melco LUA-KTX
|
||||
# and the GREEN HOUSE GH-USB100B.
|
||||
device rue
|
||||
|
||||
# debugging options for the USB subsystem
|
||||
#
|
||||
|
@ -498,6 +498,7 @@ dev/mii/nsgphy.c optional miibus
|
||||
dev/mii/pnphy.c optional miibus
|
||||
dev/mii/pnaphy.c optional miibus
|
||||
dev/mii/rlphy.c optional miibus
|
||||
dev/mii/ruephy.c optional miibus
|
||||
dev/mii/tdkphy.c optional miibus
|
||||
dev/mii/tlphy.c optional miibus
|
||||
dev/mii/ukphy.c optional miibus
|
||||
@ -760,6 +761,7 @@ dev/usb/if_aue.c optional aue
|
||||
dev/usb/if_axe.c optional axe
|
||||
dev/usb/if_cue.c optional cue
|
||||
dev/usb/if_kue.c optional kue
|
||||
dev/usb/if_rue.c optional rue
|
||||
dev/usb/ehci.c optional ehci
|
||||
dev/usb/ehci_pci.c optional ehci pci
|
||||
dev/usb/ohci.c optional ohci
|
||||
|
297
sys/dev/mii/ruephy.c
Normal file
297
sys/dev/mii/ruephy.c
Normal file
@ -0,0 +1,297 @@
|
||||
/*-
|
||||
* Copyright (c) 2001-2003, Shunsuke Akiyama <akiyama@FreeBSD.org>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
/*
|
||||
* driver for RealTek RTL8150 internal PHY
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/bus.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_arp.h>
|
||||
#include <net/if_media.h>
|
||||
|
||||
#include <dev/mii/mii.h>
|
||||
#include <dev/mii/miivar.h>
|
||||
#include "miidevs.h"
|
||||
|
||||
#include <machine/bus.h>
|
||||
#include <dev/mii/ruephyreg.h>
|
||||
|
||||
#include "miibus_if.h"
|
||||
|
||||
static int ruephy_probe(device_t);
|
||||
static int ruephy_attach(device_t);
|
||||
|
||||
static device_method_t ruephy_methods[] = {
|
||||
/* device interface */
|
||||
DEVMETHOD(device_probe, ruephy_probe),
|
||||
DEVMETHOD(device_attach, ruephy_attach),
|
||||
DEVMETHOD(device_detach, mii_phy_detach),
|
||||
DEVMETHOD(device_shutdown, bus_generic_shutdown),
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
static devclass_t ruephy_devclass;
|
||||
|
||||
static driver_t ruephy_driver = {
|
||||
"ruephy",
|
||||
ruephy_methods,
|
||||
sizeof(struct mii_softc)
|
||||
};
|
||||
|
||||
DRIVER_MODULE(ruephy, miibus, ruephy_driver, ruephy_devclass, 0, 0);
|
||||
|
||||
static int ruephy_service(struct mii_softc *, struct mii_data *, int);
|
||||
static void ruephy_reset(struct mii_softc *);
|
||||
static void ruephy_status(struct mii_softc *);
|
||||
|
||||
static int
|
||||
ruephy_probe(device_t dev)
|
||||
{
|
||||
struct mii_attach_args *ma;
|
||||
device_t parent;
|
||||
|
||||
ma = device_get_ivars(dev);
|
||||
parent = device_get_parent(device_get_parent(dev));
|
||||
|
||||
/*
|
||||
* RealTek RTL8150 PHY doesn't have vendor/device ID registers:
|
||||
* the rue driver fakes up a return value of all zeros.
|
||||
*/
|
||||
if (MII_OUI(ma->mii_id1, ma->mii_id2) != 0 ||
|
||||
MII_MODEL(ma->mii_id2) != 0)
|
||||
return (ENXIO);
|
||||
|
||||
/*
|
||||
* Make sure the parent is an 'rue'.
|
||||
*/
|
||||
if (strcmp(device_get_name(parent), "rue") != 0)
|
||||
return (ENXIO);
|
||||
|
||||
device_set_desc(dev, "RealTek RTL8150 internal media interface");
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
ruephy_attach(device_t dev)
|
||||
{
|
||||
struct mii_softc *sc;
|
||||
struct mii_attach_args *ma;
|
||||
struct mii_data *mii;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
ma = device_get_ivars(dev);
|
||||
sc->mii_dev = device_get_parent(dev);
|
||||
mii = device_get_softc(sc->mii_dev);
|
||||
|
||||
/*
|
||||
* The RealTek PHY can never be isolated, so never allow non-zero
|
||||
* instances!
|
||||
*/
|
||||
if (mii->mii_instance != 0) {
|
||||
device_printf(dev, "ignoring this PHY, non-zero instance\n");
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_inst = mii->mii_instance;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = ruephy_service;
|
||||
sc->mii_pdata = mii;
|
||||
mii->mii_instance++;
|
||||
|
||||
sc->mii_flags |= MIIF_NOISOLATE;
|
||||
|
||||
#define ADD(m, c) ifmedia_add(&mii->mii_media, (m), (c), NULL)
|
||||
|
||||
ruephy_reset(sc);
|
||||
|
||||
sc->mii_capabilities =
|
||||
PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
device_printf(dev, " ");
|
||||
mii_phy_add_media(sc);
|
||||
printf("\n");
|
||||
#undef ADD
|
||||
|
||||
MIIBUS_MEDIAINIT(sc->mii_dev);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
ruephy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
{
|
||||
struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
|
||||
int reg;
|
||||
|
||||
/*
|
||||
* We can't isolate the RealTek RTL8150 PHY,
|
||||
* so it has to be the only one!
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
panic("ruephy_service: can't isolate RealTek RTL8150 PHY");
|
||||
|
||||
switch (cmd) {
|
||||
case MII_POLLSTAT:
|
||||
break;
|
||||
|
||||
case MII_MEDIACHG:
|
||||
/*
|
||||
* If the interface is not up, don't do anything.
|
||||
*/
|
||||
if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
|
||||
break;
|
||||
|
||||
switch (IFM_SUBTYPE(ife->ifm_media)) {
|
||||
case IFM_AUTO:
|
||||
/*
|
||||
* If we're already in auto mode, just return.
|
||||
*/
|
||||
if (PHY_READ(sc, MII_BMCR) & BMCR_AUTOEN)
|
||||
return (0);
|
||||
(void) mii_phy_auto(sc);
|
||||
break;
|
||||
case IFM_100_T4:
|
||||
/*
|
||||
* XXX Not supported as a manual setting right now.
|
||||
*/
|
||||
return (EINVAL);
|
||||
default:
|
||||
/*
|
||||
* BMCR data is stored in the ifmedia entry.
|
||||
*/
|
||||
PHY_WRITE(sc, MII_ANAR,
|
||||
mii_anar(ife->ifm_media));
|
||||
PHY_WRITE(sc, MII_BMCR, ife->ifm_data);
|
||||
}
|
||||
break;
|
||||
|
||||
case MII_TICK:
|
||||
/*
|
||||
* Is the interface even up?
|
||||
*/
|
||||
if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Only used for autonegotiation.
|
||||
*/
|
||||
if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO)
|
||||
break;
|
||||
|
||||
/*
|
||||
* Check to see if we have link. If we do, we don't
|
||||
* need to restart the autonegotiation process. Read
|
||||
* the MSR twice in case it's latched.
|
||||
*/
|
||||
reg = PHY_READ(sc, RUEPHY_MII_MSR) |
|
||||
PHY_READ(sc, RUEPHY_MII_MSR);
|
||||
if (reg & RUEPHY_MSR_LINK)
|
||||
break;
|
||||
|
||||
/*
|
||||
* Only retry autonegotiation every 5 seconds.
|
||||
*/
|
||||
if (++sc->mii_ticks != 5)
|
||||
return (0);
|
||||
|
||||
sc->mii_ticks = 0;
|
||||
ruephy_reset(sc);
|
||||
if (mii_phy_auto(sc) == EJUSTRETURN)
|
||||
return (0);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Update the media status. */
|
||||
ruephy_status(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
mii_phy_update(sc, cmd);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static void
|
||||
ruephy_reset(struct mii_softc *sc)
|
||||
{
|
||||
|
||||
mii_phy_reset(sc);
|
||||
|
||||
/*
|
||||
* XXX RealTek RTL8150 PHY doesn't set the BMCR properly after
|
||||
* XXX reset, which breaks autonegotiation.
|
||||
*/
|
||||
PHY_WRITE(sc, MII_BMCR, (BMCR_S100 | BMCR_AUTOEN | BMCR_FDX));
|
||||
}
|
||||
|
||||
static void
|
||||
ruephy_status(struct mii_softc *phy)
|
||||
{
|
||||
struct mii_data *mii = phy->mii_pdata;
|
||||
int bmsr, bmcr, msr;
|
||||
|
||||
mii->mii_media_status = IFM_AVALID;
|
||||
mii->mii_media_active = IFM_ETHER;
|
||||
|
||||
msr = PHY_READ(phy, RUEPHY_MII_MSR) | PHY_READ(phy, RUEPHY_MII_MSR);
|
||||
if (msr & RUEPHY_MSR_LINK)
|
||||
mii->mii_media_status |= IFM_ACTIVE;
|
||||
|
||||
bmcr = PHY_READ(phy, MII_BMCR);
|
||||
if (bmcr & BMCR_ISO) {
|
||||
mii->mii_media_active |= IFM_NONE;
|
||||
mii->mii_media_status = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
bmsr = PHY_READ(phy, MII_BMSR) | PHY_READ(phy, MII_BMSR);
|
||||
|
||||
if (bmcr & BMCR_AUTOEN) {
|
||||
if ((bmsr & BMSR_ACOMP) == 0) {
|
||||
/* Erg, still trying, I guess... */
|
||||
mii->mii_media_active |= IFM_NONE;
|
||||
return;
|
||||
}
|
||||
|
||||
if (msr & RUEPHY_MSR_SPEED100)
|
||||
mii->mii_media_active |= IFM_100_TX;
|
||||
else
|
||||
mii->mii_media_active |= IFM_10_T;
|
||||
|
||||
if (msr & RUEPHY_MSR_DUPLEX)
|
||||
mii->mii_media_active |= IFM_FDX;
|
||||
} else
|
||||
mii->mii_media_active = mii_media_from_bmcr(bmcr);
|
||||
}
|
38
sys/dev/mii/ruephyreg.h
Normal file
38
sys/dev/mii/ruephyreg.h
Normal file
@ -0,0 +1,38 @@
|
||||
/*-
|
||||
* Copyright (c) 2001-2003, Shunsuke Akiyama <akiyama@FreeBSD.org>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef _RUEPHYREG_H_
|
||||
#define _RUEPHYREG_H_
|
||||
|
||||
#define RUEPHY_MII_MSR 0x0137 /* B, R/W */
|
||||
#define RUEPHY_MSR_RXFCE 0x40
|
||||
#define RUEPHY_MSR_DUPLEX 0x10
|
||||
#define RUEPHY_MSR_SPEED100 0x08
|
||||
#define RUEPHY_MSR_LINK 0x04
|
||||
|
||||
#endif /* _RUEPHYREG_H_ */
|
1477
sys/dev/usb/if_rue.c
Normal file
1477
sys/dev/usb/if_rue.c
Normal file
File diff suppressed because it is too large
Load Diff
247
sys/dev/usb/if_ruereg.h
Normal file
247
sys/dev/usb/if_ruereg.h
Normal file
@ -0,0 +1,247 @@
|
||||
/*-
|
||||
* Copyright (c) 2001-2003, Shunsuke Akiyama <akiyama@FreeBSD.org>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef _IF_RUEREG_H_
|
||||
#define _IF_RUEREG_H_
|
||||
|
||||
#define RUE_INTR_PIPE 1 /* Use INTR PIPE */
|
||||
|
||||
#define RUE_CONFIG_NO 1
|
||||
#define RUE_IFACE_IDX 0
|
||||
|
||||
#define RUE_ENDPT_RX 0x0
|
||||
#define RUE_ENDPT_TX 0x1
|
||||
#define RUE_ENDPT_INTR 0x2
|
||||
#define RUE_ENDPT_MAX 0x3
|
||||
|
||||
#define RUE_INTR_PKTLEN 0x8
|
||||
|
||||
#define RUE_TIMEOUT 1000
|
||||
#define ETHER_ALIGN 2
|
||||
#define RUE_BUFSZ 1536
|
||||
#define RUE_MIN_FRAMELEN 60
|
||||
#define RUE_INTR_INTERVAL 100 /* ms */
|
||||
|
||||
/*
|
||||
* Registers
|
||||
*/
|
||||
|
||||
#define RUE_IDR0 0x0120
|
||||
#define RUE_IDR1 0x0121
|
||||
#define RUE_IDR2 0x0122
|
||||
#define RUE_IDR3 0x0123
|
||||
#define RUE_IDR4 0x0124
|
||||
#define RUE_IDR5 0x0125
|
||||
|
||||
#define RUE_MAR0 0x0126
|
||||
#define RUE_MAR1 0x0127
|
||||
#define RUE_MAR2 0x0128
|
||||
#define RUE_MAR3 0x0129
|
||||
#define RUE_MAR4 0x012A
|
||||
#define RUE_MAR5 0x012B
|
||||
#define RUE_MAR6 0x012C
|
||||
#define RUE_MAR7 0x012D
|
||||
|
||||
#define RUE_CR 0x012E /* B, R/W */
|
||||
#define RUE_CR_SOFT_RST 0x10
|
||||
#define RUE_CR_RE 0x08
|
||||
#define RUE_CR_TE 0x04
|
||||
#define RUE_CR_EP3CLREN 0x02
|
||||
|
||||
#define RUE_TCR 0x012F /* B, R/W */
|
||||
#define RUE_TCR_TXRR1 0x80
|
||||
#define RUE_TCR_TXRR0 0x40
|
||||
#define RUE_TCR_IFG1 0x10
|
||||
#define RUE_TCR_IFG0 0x08
|
||||
#define RUE_TCR_NOCRC 0x01
|
||||
#define RUE_TCR_CONFIG (RUE_TCR_TXRR1|RUE_TCR_TXRR0|RUE_TCR_IFG1|RUE_TCR_IFG0)
|
||||
|
||||
#define RUE_RCR 0x0130 /* W, R/W */
|
||||
#define RUE_RCR_TAIL 0x80
|
||||
#define RUE_RCR_AER 0x40
|
||||
#define RUE_RCR_AR 0x20
|
||||
#define RUE_RCR_AM 0x10
|
||||
#define RUE_RCR_AB 0x08
|
||||
#define RUE_RCR_AD 0x04
|
||||
#define RUE_RCR_AAM 0x02
|
||||
#define RUE_RCR_AAP 0x01
|
||||
#define RUE_RCR_CONFIG (RUE_RCR_TAIL|RUE_RCR_AD)
|
||||
|
||||
#define RUE_TSR 0x0132
|
||||
#define RUE_RSR 0x0133
|
||||
#define RUE_CON0 0x0135
|
||||
#define RUE_CON1 0x0136
|
||||
#define RUE_MSR 0x0137
|
||||
#define RUE_PHYADD 0x0138
|
||||
#define RUE_PHYDAT 0x0139
|
||||
|
||||
#define RUE_PHYCNT 0x013B /* B, R/W */
|
||||
#define RUE_PHYCNT_PHYOWN 0x40
|
||||
#define RUE_PHYCNT_RWCR 0x20
|
||||
|
||||
#define RUE_GPPC 0x013D
|
||||
#define RUE_WAKECNT 0x013E
|
||||
|
||||
#define RUE_BMCR 0x0140
|
||||
#define RUE_BMCR_SPD_SET 0x2000
|
||||
#define RUE_BMCR_DUPLEX 0x0100
|
||||
|
||||
#define RUE_BMSR 0x0142
|
||||
|
||||
#define RUE_ANAR 0x0144 /* W, R/W */
|
||||
#define RUE_ANAR_PAUSE 0x0400
|
||||
|
||||
#define RUE_ANLP 0x0146 /* W, R/O */
|
||||
#define RUE_ANLP_PAUSE 0x0400
|
||||
|
||||
#define RUE_AER 0x0148
|
||||
|
||||
#define RUE_NWAYT 0x014A
|
||||
#define RUE_CSCR 0x014C
|
||||
|
||||
#define RUE_CRC0 0x014E
|
||||
#define RUE_CRC1 0x0150
|
||||
#define RUE_CRC2 0x0152
|
||||
#define RUE_CRC3 0x0154
|
||||
#define RUE_CRC4 0x0156
|
||||
|
||||
#define RUE_BYTEMASK0 0x0158
|
||||
#define RUE_BYTEMASK1 0x0160
|
||||
#define RUE_BYTEMASK2 0x0168
|
||||
#define RUE_BYTEMASK3 0x0170
|
||||
#define RUE_BYTEMASK4 0x0178
|
||||
|
||||
#define RUE_PHY1 0x0180
|
||||
#define RUE_PHY2 0x0184
|
||||
|
||||
#define RUE_TW1 0x0186
|
||||
|
||||
#define RUE_REG_MIN 0x0120
|
||||
#define RUE_REG_MAX 0x0189
|
||||
|
||||
/*
|
||||
* EEPROM address declarations
|
||||
*/
|
||||
|
||||
#define RUE_EEPROM_BASE 0x1200
|
||||
|
||||
#define RUE_EEPROM_IDR0 (RUE_EEPROM_BASE + 0x02)
|
||||
#define RUE_EEPROM_IDR1 (RUE_EEPROM_BASE + 0x03)
|
||||
#define RUE_EEPROM_IDR2 (RUE_EEPROM_BASE + 0x03)
|
||||
#define RUE_EEPROM_IDR3 (RUE_EEPROM_BASE + 0x03)
|
||||
#define RUE_EEPROM_IDR4 (RUE_EEPROM_BASE + 0x03)
|
||||
#define RUE_EEPROM_IDR5 (RUE_EEPROM_BASE + 0x03)
|
||||
|
||||
#define RUE_EEPROM_INTERVAL (RUE_EEPROM_BASE + 0x17)
|
||||
|
||||
struct rue_intrpkt {
|
||||
u_int8_t rue_tsr;
|
||||
u_int8_t rue_rsr;
|
||||
u_int8_t rue_gep_msr;
|
||||
u_int8_t rue_waksr;
|
||||
u_int8_t rue_txok_cnt;
|
||||
u_int8_t rue_rxlost_cnt;
|
||||
u_int8_t rue_crcerr_cnt;
|
||||
u_int8_t rue_col_cnt;
|
||||
};
|
||||
|
||||
struct rue_rxpkt {
|
||||
u_int16_t rue_pktlen : 12;
|
||||
u_int16_t rue_rxstat : 4;
|
||||
};
|
||||
|
||||
#define RUE_RXSTAT_VALID 0x01
|
||||
#define RUE_RXSTAT_RUNT 0x02
|
||||
#define RUE_RXSTAT_PMATCH 0x04
|
||||
#define RUE_RXSTAT_MCAST 0x08
|
||||
|
||||
#define RUE_RXSTAT_MASK RUE_RXSTAT_VALID
|
||||
|
||||
struct rue_type {
|
||||
u_int16_t rue_vid;
|
||||
u_int16_t rue_did;
|
||||
};
|
||||
|
||||
#define RUE_TX_LIST_CNT 1
|
||||
#define RUE_RX_LIST_CNT 1
|
||||
|
||||
struct rue_softc;
|
||||
|
||||
struct rue_chain {
|
||||
struct rue_softc *rue_sc;
|
||||
usbd_xfer_handle rue_xfer;
|
||||
char *rue_buf;
|
||||
struct mbuf *rue_mbuf;
|
||||
int rue_idx;
|
||||
};
|
||||
|
||||
struct rue_cdata {
|
||||
struct rue_chain rue_tx_chain[RUE_TX_LIST_CNT];
|
||||
struct rue_chain rue_rx_chain[RUE_RX_LIST_CNT];
|
||||
struct rue_intrpkt *rue_ibuf;
|
||||
int rue_tx_prod;
|
||||
int rue_tx_cons;
|
||||
int rue_tx_cnt;
|
||||
int rue_rx_prod;
|
||||
};
|
||||
|
||||
struct rue_softc {
|
||||
struct arpcom arpcom;
|
||||
device_t rue_miibus;
|
||||
usbd_device_handle rue_udev;
|
||||
usbd_interface_handle rue_iface;
|
||||
struct rue_type *rue_info;
|
||||
int rue_ed[RUE_ENDPT_MAX];
|
||||
usbd_pipe_handle rue_ep[RUE_ENDPT_MAX];
|
||||
int rue_unit;
|
||||
u_int8_t rue_link;
|
||||
int rue_if_flags;
|
||||
struct rue_cdata rue_cdata;
|
||||
struct callout_handle rue_stat_ch;
|
||||
struct mtx rue_mtx;
|
||||
char rue_dying;
|
||||
struct timeval rue_rx_notice;
|
||||
};
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
#define GET_MII(sc) (device_get_softc((sc)->rue_miibus))
|
||||
#elif defined(__NetBSD__)
|
||||
#define GET_MII(sc) (&(sc)->rue_mii)
|
||||
#elif defined(__OpenBSD__)
|
||||
#define GET_MII(sc) (&(sc)->rue_mii)
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#define RUE_LOCK(_sc) mtx_lock(&(_sc)->rue_mtx)
|
||||
#define RUE_UNLOCK(_sc) mtx_unlock(&(_sc)->rue_mtx)
|
||||
#else
|
||||
#define RUE_LOCK(_sc)
|
||||
#define RUE_UNLOCK(_sc)
|
||||
#endif
|
||||
|
||||
#endif /* _IF_RUEREG_H_ */
|
@ -335,6 +335,7 @@ vendor TODOS 0x0b0c Todos Data System
|
||||
vendor NEC2 0x0b62 NEC
|
||||
vendor ATI2 0x0b6f ATI
|
||||
vendor ASIX 0x0b95 ASIX Electronics
|
||||
vendor REALTEK 0x0bda RealTek
|
||||
vendor AGATE 0x0c08 Agate Technologies
|
||||
vendor DMI 0x0c0b DMI
|
||||
vendor LUWEN 0x0c76 Luwen
|
||||
@ -823,6 +824,7 @@ product MCT SITECOM_USB232 0x0230 Sitecom USB-232 Products
|
||||
product MELCO LUATX1 0x0001 LUA-TX Ethernet
|
||||
product MELCO LUATX5 0x0005 LUA-TX Ethernet
|
||||
product MELCO LUA2TX5 0x0009 LUA2-TX Ethernet
|
||||
product MELCO LUAKTX 0x0012 LUA-KTX Ethernet
|
||||
product MELCO DUBPXXG 0x001c USB-IDE Bridge: DUB-PxxG
|
||||
|
||||
/* Metricom products */
|
||||
@ -985,6 +987,9 @@ product QUICKSHOT STRIKEPAD 0x6238 USB StrikePad
|
||||
/* Rainbow Technologies products */
|
||||
product RAINBOW IKEY2000 0x1200 i-Key 2000
|
||||
|
||||
/* ReakTek products */
|
||||
product REALTEK USBKR100 0x8150 USBKR100 USB Ethernet (GREEN HOUSE)
|
||||
|
||||
/* Roland products */
|
||||
product ROLAND UM1 0x0009 UM-1 MIDI I/F
|
||||
product ROLAND UM880N 0x0014 EDIROL UM-880 MIDI I/F (native)
|
||||
|
@ -96,6 +96,7 @@ SUBDIR= accf_data \
|
||||
rc4 \
|
||||
rl \
|
||||
rp \
|
||||
rue \
|
||||
sbsh \
|
||||
sf \
|
||||
sis \
|
||||
|
@ -7,6 +7,7 @@ SRCS= mii.c mii_physubr.c ukphy.c ukphy_subr.c bus_if.h pci_if.h
|
||||
SRCS+= miibus_if.h miidevs.h device_if.h miibus_if.c e1000phy.c exphy.c nsphy.c
|
||||
SRCS+= mlphy.c tlphy.c rlphy.c amphy.c dcphy.c pnphy.c inphy.c
|
||||
SRCS+= bmtphy.c brgphy.c xmphy.c pnaphy.c lxtphy.c qsphy.c acphy.c nsgphy.c
|
||||
SRCS+= ruephy.c
|
||||
|
||||
EXPORT_SYMS= mii_mediachg \
|
||||
mii_tick \
|
||||
|
10
sys/modules/rue/Makefile
Normal file
10
sys/modules/rue/Makefile
Normal file
@ -0,0 +1,10 @@
|
||||
# $FreeBSD$
|
||||
|
||||
S= ${.CURDIR}/../..
|
||||
.PATH: $S/dev/usb
|
||||
|
||||
KMOD= if_rue
|
||||
SRCS= if_rue.c opt_bdg.h opt_usb.h device_if.h bus_if.h
|
||||
SRCS+= miibus_if.h
|
||||
|
||||
.include <bsd.kmod.mk>
|
Loading…
Reference in New Issue
Block a user