1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-16 10:20:30 +00:00

Add a miibus_statchg and use it to enable Gigabit mode when appropriate.

MFC after:	1 week
This commit is contained in:
Andrew Turner 2015-05-22 14:25:23 +00:00
parent 3723b8bfdb
commit 7c909980ef
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=283287

View File

@ -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.