mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-05-13 18:10:19 +08:00
mii: Add phy devices
This commit is contained in:
parent
4ccf797155
commit
710d2a1e1d
3
Makefile
3
Makefile
@ -414,6 +414,9 @@ LIB_C_FILES += freebsd/sys/dev/mii/mii_physubr.c
|
||||
LIB_C_FILES += freebsd/sys/dev/mii/icsphy.c
|
||||
LIB_C_FILES += freebsd/sys/dev/mii/e1000phy.c
|
||||
LIB_C_FILES += freebsd/sys/dev/mii/brgphy.c
|
||||
LIB_C_FILES += freebsd/sys/dev/mii/micphy.c
|
||||
LIB_C_FILES += freebsd/sys/dev/mii/ukphy.c
|
||||
LIB_C_FILES += freebsd/sys/dev/mii/ukphy_subr.c
|
||||
LIB_C_FILES += freebsd/sys/dev/tsec/if_tsec.c
|
||||
LIB_C_FILES += freebsd/sys/dev/cadence/if_cgem.c
|
||||
LIB_C_FILES += freebsd/sys/arm/xilinx/zy7_slcr.c
|
||||
|
@ -1301,6 +1301,9 @@ devNet.addKernelSpaceSourceFiles(
|
||||
'sys/dev/mii/icsphy.c',
|
||||
'sys/dev/mii/e1000phy.c',
|
||||
'sys/dev/mii/brgphy.c',
|
||||
'sys/dev/mii/micphy.c',
|
||||
'sys/dev/mii/ukphy.c',
|
||||
'sys/dev/mii/ukphy_subr.c',
|
||||
'sys/dev/tsec/if_tsec.c',
|
||||
'sys/dev/cadence/if_cgem.c',
|
||||
'sys/arm/xilinx/zy7_slcr.c',
|
||||
|
226
freebsd/sys/dev/mii/micphy.c
Normal file
226
freebsd/sys/dev/mii/micphy.c
Normal file
@ -0,0 +1,226 @@
|
||||
#include <machine/rtems-bsd-kernel-space.h>
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2014 Ruslan Bukin <br@bsdpad.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software was developed by SRI International and the University of
|
||||
* Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
|
||||
* ("CTSRD"), as part of the DARPA CRASH research programme.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
/*
|
||||
* Micrel KSZ9021 Gigabit Ethernet Transceiver
|
||||
*/
|
||||
|
||||
#include <rtems/bsd/sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/errno.h>
|
||||
#include <sys/module.h>
|
||||
#include <sys/bus.h>
|
||||
#include <sys/malloc.h>
|
||||
|
||||
#include <machine/bus.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_media.h>
|
||||
|
||||
#include <dev/mii/mii.h>
|
||||
#include <dev/mii/miivar.h>
|
||||
#include <rtems/bsd/local/miidevs.h>
|
||||
|
||||
#include <rtems/bsd/local/miibus_if.h>
|
||||
|
||||
#ifndef __rtems__
|
||||
#include <dev/fdt/fdt_common.h>
|
||||
#include <dev/ofw/openfirm.h>
|
||||
#include <dev/ofw/ofw_bus.h>
|
||||
#include <dev/ofw/ofw_bus_subr.h>
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#define MII_KSZPHY_EXTREG 0x0b
|
||||
#define KSZPHY_EXTREG_WRITE (1 << 15)
|
||||
#define MII_KSZPHY_EXTREG_WRITE 0x0c
|
||||
#define MII_KSZPHY_EXTREG_READ 0x0d
|
||||
#define MII_KSZPHY_CLK_CONTROL_PAD_SKEW 0x104
|
||||
#define MII_KSZPHY_RX_DATA_PAD_SKEW 0x105
|
||||
#define MII_KSZPHY_TX_DATA_PAD_SKEW 0x106
|
||||
|
||||
#define PS_TO_REG(p) ((p) / 200)
|
||||
|
||||
static int micphy_probe(device_t);
|
||||
static int micphy_attach(device_t);
|
||||
static int micphy_service(struct mii_softc *, struct mii_data *, int);
|
||||
|
||||
static device_method_t micphy_methods[] = {
|
||||
/* device interface */
|
||||
DEVMETHOD(device_probe, micphy_probe),
|
||||
DEVMETHOD(device_attach, micphy_attach),
|
||||
DEVMETHOD(device_detach, mii_phy_detach),
|
||||
DEVMETHOD(device_shutdown, bus_generic_shutdown),
|
||||
DEVMETHOD_END
|
||||
};
|
||||
|
||||
static devclass_t micphy_devclass;
|
||||
|
||||
static driver_t micphy_driver = {
|
||||
"micphy",
|
||||
micphy_methods,
|
||||
sizeof(struct mii_softc)
|
||||
};
|
||||
|
||||
DRIVER_MODULE(micphy, miibus, micphy_driver, micphy_devclass, 0, 0);
|
||||
|
||||
static const struct mii_phydesc micphys[] = {
|
||||
MII_PHY_DESC(MICREL, KSZ9021),
|
||||
MII_PHY_END
|
||||
};
|
||||
|
||||
static const struct mii_phy_funcs micphy_funcs = {
|
||||
micphy_service,
|
||||
ukphy_status,
|
||||
mii_phy_reset
|
||||
};
|
||||
|
||||
static void
|
||||
micphy_write(struct mii_softc *sc, uint32_t reg, uint32_t val)
|
||||
{
|
||||
|
||||
PHY_WRITE(sc, MII_KSZPHY_EXTREG, KSZPHY_EXTREG_WRITE | reg);
|
||||
PHY_WRITE(sc, MII_KSZPHY_EXTREG_WRITE, val);
|
||||
}
|
||||
|
||||
#ifndef __rtems__
|
||||
static int
|
||||
ksz9021_load_values(struct mii_softc *sc, phandle_t node, uint32_t reg,
|
||||
char *field1, char *field2,
|
||||
char *field3, char *field4)
|
||||
{
|
||||
pcell_t dts_value[1];
|
||||
int len;
|
||||
int val;
|
||||
|
||||
val = 0;
|
||||
|
||||
if ((len = OF_getproplen(node, field1)) > 0) {
|
||||
OF_getencprop(node, field1, dts_value, len);
|
||||
val = PS_TO_REG(dts_value[0]);
|
||||
}
|
||||
|
||||
if ((len = OF_getproplen(node, field2)) > 0) {
|
||||
OF_getencprop(node, field2, dts_value, len);
|
||||
val |= PS_TO_REG(dts_value[0]) << 4;
|
||||
}
|
||||
|
||||
if ((len = OF_getproplen(node, field3)) > 0) {
|
||||
OF_getencprop(node, field3, dts_value, len);
|
||||
val |= PS_TO_REG(dts_value[0]) << 8;
|
||||
}
|
||||
|
||||
if ((len = OF_getproplen(node, field4)) > 0) {
|
||||
OF_getencprop(node, field4, dts_value, len);
|
||||
val |= PS_TO_REG(dts_value[0]) << 12;
|
||||
}
|
||||
|
||||
micphy_write(sc, reg, val);
|
||||
|
||||
return (0);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
static int
|
||||
micphy_probe(device_t dev)
|
||||
{
|
||||
|
||||
return (mii_phy_dev_probe(dev, micphys, BUS_PROBE_DEFAULT));
|
||||
}
|
||||
|
||||
static int
|
||||
micphy_attach(device_t dev)
|
||||
{
|
||||
struct mii_softc *sc;
|
||||
#ifndef __rtems__
|
||||
phandle_t node;
|
||||
device_t miibus;
|
||||
device_t parent;
|
||||
#endif /* __rtems__ */
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
|
||||
mii_phy_dev_attach(dev, MIIF_NOMANPAUSE, &micphy_funcs, 1);
|
||||
mii_phy_setmedia(sc);
|
||||
|
||||
#ifndef __rtems__
|
||||
miibus = device_get_parent(dev);
|
||||
parent = device_get_parent(miibus);
|
||||
|
||||
if ((node = ofw_bus_get_node(parent)) == -1)
|
||||
return (ENXIO);
|
||||
|
||||
ksz9021_load_values(sc, node, MII_KSZPHY_CLK_CONTROL_PAD_SKEW,
|
||||
"txen-skew-ps", "txc-skew-ps",
|
||||
"rxdv-skew-ps", "rxc-skew-ps");
|
||||
|
||||
ksz9021_load_values(sc, node, MII_KSZPHY_RX_DATA_PAD_SKEW,
|
||||
"rxd0-skew-ps", "rxd1-skew-ps",
|
||||
"rxd2-skew-ps", "rxd3-skew-ps");
|
||||
|
||||
ksz9021_load_values(sc, node, MII_KSZPHY_TX_DATA_PAD_SKEW,
|
||||
"txd0-skew-ps", "txd1-skew-ps",
|
||||
"txd2-skew-ps", "txd3-skew-ps");
|
||||
#endif /* __rtems__ */
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
micphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
{
|
||||
|
||||
switch (cmd) {
|
||||
case MII_POLLSTAT:
|
||||
break;
|
||||
|
||||
case MII_MEDIACHG:
|
||||
mii_phy_setmedia(sc);
|
||||
break;
|
||||
|
||||
case MII_TICK:
|
||||
if (mii_phy_tick(sc) == EJUSTRETURN)
|
||||
return (0);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Update the media status. */
|
||||
PHY_STATUS(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
mii_phy_update(sc, cmd);
|
||||
return (0);
|
||||
}
|
160
freebsd/sys/dev/mii/ukphy.c
Normal file
160
freebsd/sys/dev/mii/ukphy.c
Normal file
@ -0,0 +1,160 @@
|
||||
#include <machine/rtems-bsd-kernel-space.h>
|
||||
|
||||
/* $NetBSD: ukphy.c,v 1.2 1999/04/23 04:24:32 thorpej Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
|
||||
* NASA Ames Research Center, and by Frank van der Linden.
|
||||
*
|
||||
* 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 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.
|
||||
*/
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997 Manuel Bouyer. 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 ``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.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
/*
|
||||
* driver for generic unknown PHYs
|
||||
*/
|
||||
|
||||
#include <rtems/bsd/sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/errno.h>
|
||||
#include <sys/module.h>
|
||||
#include <sys/bus.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_media.h>
|
||||
|
||||
#include <dev/mii/mii.h>
|
||||
#include <dev/mii/miivar.h>
|
||||
|
||||
#include <rtems/bsd/local/miibus_if.h>
|
||||
|
||||
static int ukphy_probe(device_t);
|
||||
static int ukphy_attach(device_t);
|
||||
|
||||
static device_method_t ukphy_methods[] = {
|
||||
/* device interface */
|
||||
DEVMETHOD(device_probe, ukphy_probe),
|
||||
DEVMETHOD(device_attach, ukphy_attach),
|
||||
DEVMETHOD(device_detach, mii_phy_detach),
|
||||
DEVMETHOD(device_shutdown, bus_generic_shutdown),
|
||||
DEVMETHOD_END
|
||||
};
|
||||
|
||||
static devclass_t ukphy_devclass;
|
||||
|
||||
static driver_t ukphy_driver = {
|
||||
"ukphy",
|
||||
ukphy_methods,
|
||||
sizeof(struct mii_softc)
|
||||
};
|
||||
|
||||
DRIVER_MODULE(ukphy, miibus, ukphy_driver, ukphy_devclass, 0, 0);
|
||||
|
||||
static int ukphy_service(struct mii_softc *, struct mii_data *, int);
|
||||
|
||||
static const struct mii_phy_funcs ukphy_funcs = {
|
||||
ukphy_service,
|
||||
ukphy_status,
|
||||
mii_phy_reset
|
||||
};
|
||||
|
||||
static int
|
||||
ukphy_probe(device_t dev)
|
||||
{
|
||||
|
||||
/*
|
||||
* We know something is here, so always match at a low priority.
|
||||
*/
|
||||
device_set_desc(dev, "Generic IEEE 802.3u media interface");
|
||||
return (BUS_PROBE_GENERIC);
|
||||
}
|
||||
|
||||
static int
|
||||
ukphy_attach(device_t dev)
|
||||
{
|
||||
struct mii_softc *sc;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
|
||||
mii_phy_dev_attach(dev, MIIF_NOMANPAUSE, &ukphy_funcs, 1);
|
||||
mii_phy_setmedia(sc);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
ukphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
{
|
||||
|
||||
switch (cmd) {
|
||||
case MII_POLLSTAT:
|
||||
break;
|
||||
|
||||
case MII_MEDIACHG:
|
||||
mii_phy_setmedia(sc);
|
||||
break;
|
||||
|
||||
case MII_TICK:
|
||||
if (mii_phy_tick(sc) == EJUSTRETURN)
|
||||
return (0);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Update the media status. */
|
||||
PHY_STATUS(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
mii_phy_update(sc, cmd);
|
||||
return (0);
|
||||
}
|
131
freebsd/sys/dev/mii/ukphy_subr.c
Normal file
131
freebsd/sys/dev/mii/ukphy_subr.c
Normal file
@ -0,0 +1,131 @@
|
||||
#include <machine/rtems-bsd-kernel-space.h>
|
||||
|
||||
/* $NetBSD: ukphy_subr.c,v 1.2 1998/11/05 04:08:02 thorpej Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
|
||||
* NASA Ames Research Center, and by Frank van der Linden.
|
||||
*
|
||||
* 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 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/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
/*
|
||||
* Subroutines shared by the ukphy driver and other PHY drivers.
|
||||
*/
|
||||
|
||||
#include <rtems/bsd/sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/module.h>
|
||||
#include <sys/bus.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_media.h>
|
||||
|
||||
#include <dev/mii/mii.h>
|
||||
#include <dev/mii/miivar.h>
|
||||
|
||||
#include <rtems/bsd/local/miibus_if.h>
|
||||
|
||||
/*
|
||||
* Media status subroutine. If a PHY driver does media detection simply
|
||||
* by decoding the NWay autonegotiation, use this routine.
|
||||
*/
|
||||
void
|
||||
ukphy_status(struct mii_softc *phy)
|
||||
{
|
||||
struct mii_data *mii = phy->mii_pdata;
|
||||
struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
|
||||
int bmsr, bmcr, anlpar, gtcr, gtsr;
|
||||
|
||||
mii->mii_media_status = IFM_AVALID;
|
||||
mii->mii_media_active = IFM_ETHER;
|
||||
|
||||
bmsr = PHY_READ(phy, MII_BMSR) | PHY_READ(phy, MII_BMSR);
|
||||
if (bmsr & BMSR_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;
|
||||
}
|
||||
|
||||
if (bmcr & BMCR_LOOP)
|
||||
mii->mii_media_active |= IFM_LOOP;
|
||||
|
||||
if (bmcr & BMCR_AUTOEN) {
|
||||
/*
|
||||
* NWay autonegotiation takes the highest-order common
|
||||
* bit of the ANAR and ANLPAR (i.e. best media advertised
|
||||
* both by us and our link partner).
|
||||
*/
|
||||
if ((bmsr & BMSR_ACOMP) == 0) {
|
||||
/* Erg, still trying, I guess... */
|
||||
mii->mii_media_active |= IFM_NONE;
|
||||
return;
|
||||
}
|
||||
|
||||
anlpar = PHY_READ(phy, MII_ANAR) & PHY_READ(phy, MII_ANLPAR);
|
||||
if ((phy->mii_flags & MIIF_HAVE_GTCR) != 0 &&
|
||||
(phy->mii_extcapabilities &
|
||||
(EXTSR_1000THDX | EXTSR_1000TFDX)) != 0) {
|
||||
gtcr = PHY_READ(phy, MII_100T2CR);
|
||||
gtsr = PHY_READ(phy, MII_100T2SR);
|
||||
} else
|
||||
gtcr = gtsr = 0;
|
||||
|
||||
if ((gtcr & GTCR_ADV_1000TFDX) && (gtsr & GTSR_LP_1000TFDX))
|
||||
mii->mii_media_active |= IFM_1000_T|IFM_FDX;
|
||||
else if ((gtcr & GTCR_ADV_1000THDX) &&
|
||||
(gtsr & GTSR_LP_1000THDX))
|
||||
mii->mii_media_active |= IFM_1000_T|IFM_HDX;
|
||||
else if (anlpar & ANLPAR_TX_FD)
|
||||
mii->mii_media_active |= IFM_100_TX|IFM_FDX;
|
||||
else if (anlpar & ANLPAR_T4)
|
||||
mii->mii_media_active |= IFM_100_T4|IFM_HDX;
|
||||
else if (anlpar & ANLPAR_TX)
|
||||
mii->mii_media_active |= IFM_100_TX|IFM_HDX;
|
||||
else if (anlpar & ANLPAR_10_FD)
|
||||
mii->mii_media_active |= IFM_10_T|IFM_FDX;
|
||||
else if (anlpar & ANLPAR_10)
|
||||
mii->mii_media_active |= IFM_10_T|IFM_HDX;
|
||||
else
|
||||
mii->mii_media_active |= IFM_NONE;
|
||||
|
||||
if ((mii->mii_media_active & IFM_1000_T) != 0 &&
|
||||
(gtsr & GTSR_MS_RES) != 0)
|
||||
mii->mii_media_active |= IFM_ETH_MASTER;
|
||||
|
||||
if ((mii->mii_media_active & IFM_FDX) != 0)
|
||||
mii->mii_media_active |= mii_phy_flowstatus(phy);
|
||||
} else
|
||||
mii->mii_media_active = ife->ifm_media;
|
||||
}
|
@ -60,7 +60,7 @@
|
||||
#define MII_OUI_BROADCOM2 0x000af7 /* Broadcom Corporation */
|
||||
#define MII_OUI_BROADCOM3 0x001be9 /* Broadcom Corporation */
|
||||
#define MII_OUI_BROADCOM4 0x18c086 /* Broadcom Corporation */
|
||||
#define MII_OUI_CICADA 0x0003F1 /* Cicada Semiconductor */
|
||||
#define MII_OUI_CICADA 0x0003f1 /* Cicada Semiconductor */
|
||||
#define MII_OUI_DAVICOM 0x00606e /* Davicom Semiconductor */
|
||||
#define MII_OUI_ENABLESEMI 0x0010dd /* Enable Semiconductor */
|
||||
#define MII_OUI_ICPLUS 0x0090c3 /* IC Plus Corp. */
|
||||
@ -69,6 +69,7 @@
|
||||
#define MII_OUI_JMICRON 0x00d831 /* JMicron Technologies */
|
||||
#define MII_OUI_LEVEL1 0x00207b /* Level 1 */
|
||||
#define MII_OUI_MARVELL 0x005043 /* Marvell Semiconductor */
|
||||
#define MII_OUI_MICREL 0x0010a1 /* Micrel */
|
||||
#define MII_OUI_MYSON 0x00c0b4 /* Myson Technology */
|
||||
#define MII_OUI_NATSEMI 0x080017 /* National Semiconductor */
|
||||
#define MII_OUI_PMCSIERRA 0x00e004 /* PMC-Sierra */
|
||||
@ -77,8 +78,10 @@
|
||||
#define MII_OUI_REALTEK 0x00e04c /* RealTek Semicondctor */
|
||||
#define MII_OUI_SEEQ 0x00a07d /* Seeq Technology */
|
||||
#define MII_OUI_SIS 0x00e006 /* Silicon Integrated Systems */
|
||||
#define MII_OUI_SMC 0x00800f /* SMC */
|
||||
#define MII_OUI_TI 0x080028 /* Texas Instruments */
|
||||
#define MII_OUI_TSC 0x00c039 /* TDK Semiconductor */
|
||||
#define MII_OUI_VITESSE 0x0001c1 /* Vitesse Semiconductor */
|
||||
#define MII_OUI_XAQTI 0x00e0ae /* XaQti Corp. */
|
||||
|
||||
/* Some Intel 82553's use an alternative OUI. */
|
||||
@ -154,6 +157,8 @@
|
||||
#define MII_STR_xxATHEROS_F1 "Atheros F1 10/100/1000 PHY"
|
||||
#define MII_MODEL_xxATHEROS_F2 0x0002
|
||||
#define MII_STR_xxATHEROS_F2 "Atheros F2 10/100 PHY"
|
||||
#define MII_MODEL_xxATHEROS_AR8021 0x0004
|
||||
#define MII_STR_xxATHEROS_AR8021 "Atheros AR8021 10/100/1000 PHY"
|
||||
#define MII_MODEL_xxATHEROS_F1_7 0x0007
|
||||
#define MII_STR_xxATHEROS_F1_7 "Atheros F1 10/100/1000 PHY"
|
||||
|
||||
@ -264,6 +269,8 @@
|
||||
#define MII_STR_xxCICADA_CS8204 "Cicada CS8204 10/100/1000TX PHY"
|
||||
#define MII_MODEL_xxCICADA_VSC8211 0x000b
|
||||
#define MII_STR_xxCICADA_VSC8211 "Cicada VSC8211 10/100/1000TX PHY"
|
||||
#define MII_MODEL_xxCICADA_VSC8221 0x0015
|
||||
#define MII_STR_xxCICADA_VSC8221 "Cicada CS8201 10/100/1000TX PHY"
|
||||
#define MII_MODEL_xxCICADA_CS8201A 0x0020
|
||||
#define MII_STR_xxCICADA_CS8201A "Cicada CS8201 10/100/1000TX PHY"
|
||||
#define MII_MODEL_xxCICADA_CS8201B 0x0021
|
||||
@ -401,6 +408,10 @@
|
||||
#define MII_MODEL_MARVELL_E1111 0x000c
|
||||
#define MII_STR_MARVELL_E1111 "Marvell 88E1111 Gigabit PHY"
|
||||
|
||||
/* Micrel PHYs */
|
||||
#define MII_MODEL_MICREL_KSZ9021 0x0021
|
||||
#define MII_STR_MICREL_KSZ9021 "Micrel KSZ9021 10/100/1000 PHY"
|
||||
|
||||
/* Myson Technology PHYs */
|
||||
#define MII_MODEL_xxMYSON_MTD972 0x0000
|
||||
#define MII_STR_xxMYSON_MTD972 "MTD972 10/100 media interface"
|
||||
@ -483,6 +494,14 @@
|
||||
#define MII_MODEL_xxTSC_78Q2121 0x0015
|
||||
#define MII_STR_xxTSC_78Q2121 "78Q2121 100BASE-TX media interface"
|
||||
|
||||
/* Vitesse Semiconductor */
|
||||
#define MII_MODEL_xxVITESSE_VSC8641 0x0003
|
||||
#define MII_STR_xxVITESSE_VSC8641 "Vitesse VSC8641 10/100/1000TX PHY"
|
||||
|
||||
/* XaQti Corp. PHYs */
|
||||
#define MII_MODEL_xxXAQTI_XMACII 0x0000
|
||||
#define MII_STR_xxXAQTI_XMACII "XaQti Corp. XMAC II gigabit interface"
|
||||
|
||||
/* SMC */
|
||||
#define MII_MODEL_SMC_LAN8710A 0x000F
|
||||
#define MII_STR_SMC_LAN8710A "SMC LAN8710A 10/100 interface"
|
||||
|
Loading…
x
Reference in New Issue
Block a user