summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorandrew <andrew@FreeBSD.org>2015-05-22 14:25:23 +0000
committerandrew <andrew@FreeBSD.org>2015-05-22 14:25:23 +0000
commit6dd15cbdde29a049cf977dcc251ad09a1758fa41 (patch)
treecae93cbf635bb29901a6aa15c1b072a14de9a6b0 /sys
parent5bfa8a196eead269d42033a4d9267d915b39a45a (diff)
downloadFreeBSD-src-6dd15cbdde29a049cf977dcc251ad09a1758fa41.zip
FreeBSD-src-6dd15cbdde29a049cf977dcc251ad09a1758fa41.tar.gz
Add a miibus_statchg and use it to enable Gigabit mode when appropriate.
MFC after: 1 week
Diffstat (limited to 'sys')
-rw-r--r--sys/arm/ti/cpsw/if_cpsw.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/sys/arm/ti/cpsw/if_cpsw.c b/sys/arm/ti/cpsw/if_cpsw.c
index f746095..a27393d 100644
--- a/sys/arm/ti/cpsw/if_cpsw.c
+++ b/sys/arm/ti/cpsw/if_cpsw.c
@@ -113,6 +113,7 @@ static int cpsw_ioctl(struct ifnet *, u_long command, caddr_t data);
static int cpsw_miibus_readreg(device_t, int phy, int reg);
static int cpsw_miibus_writereg(device_t, int phy, int reg, int value);
+static void cpsw_miibus_statchg(device_t);
/* Send/Receive packets. */
static void cpsw_intr_rx(void *arg);
@@ -179,6 +180,7 @@ static device_method_t cpsw_methods[] = {
/* MII interface */
DEVMETHOD(miibus_readreg, cpsw_miibus_readreg),
DEVMETHOD(miibus_writereg, cpsw_miibus_writereg),
+ DEVMETHOD(miibus_statchg, cpsw_miibus_statchg),
{ 0, 0 }
};
@@ -1265,6 +1267,36 @@ cpsw_miibus_writereg(device_t dev, int phy, int reg, int value)
return 0;
}
+static void
+cpsw_miibus_statchg(device_t dev)
+{
+ struct cpsw_softc *sc = device_get_softc(dev);
+ uint32_t mac_control;
+ int i;
+
+ CPSW_DEBUGF((""));
+
+ for (i = 0; i < 2; i++) {
+ mac_control = cpsw_read_4(sc, CPSW_SL_MACCONTROL(i));
+ mac_control &= ~(1 << 15 | 1 << 7);
+
+ switch(IFM_SUBTYPE(sc->mii->mii_media_active)) {
+ case IFM_1000_SX:
+ case IFM_1000_LX:
+ case IFM_1000_CX:
+ case IFM_1000_T:
+ mac_control |= 1 << 7;
+ break;
+
+ default:
+ mac_control |= 1 << 15;
+ break;
+ }
+
+ cpsw_write_4(sc, CPSW_SL_MACCONTROL(i), mac_control);
+ }
+}
+
/*
*
* Transmit/Receive Packets.
OpenPOWER on IntegriCloud