summaryrefslogtreecommitdiffstats
path: root/sys/dev/msk/if_msk.c
diff options
context:
space:
mode:
authoryongari <yongari@FreeBSD.org>2009-09-28 21:03:28 +0000
committeryongari <yongari@FreeBSD.org>2009-09-28 21:03:28 +0000
commit7139323b97db2431031665257e19c2277ac858b2 (patch)
treedd58f27c1c39d788de3e84609f0ac3c360da8886 /sys/dev/msk/if_msk.c
parentac4cfae59ca38cdb6e04d4ff7a214f405f17430e (diff)
downloadFreeBSD-src-7139323b97db2431031665257e19c2277ac858b2.zip
FreeBSD-src-7139323b97db2431031665257e19c2277ac858b2.tar.gz
Add hack to pass controller specific information to phy driver.
Unlike most other PHYs there is no easy way to know which media type the PHY supports on Marvell PHYs. MIIF_HAVEFIBER flags is now passed via bus-specific instance variable of a device. While I'm here add 88E1112 specific work around to set SIGDET polarity low. Many thanks "Eugene Perevyazko <john <> dnepro dot net>" who kindly gave remote access to system with DGE-560SX.
Diffstat (limited to 'sys/dev/msk/if_msk.c')
-rw-r--r--sys/dev/msk/if_msk.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/sys/dev/msk/if_msk.c b/sys/dev/msk/if_msk.c
index c6c5f20..6ce22c8 100644
--- a/sys/dev/msk/if_msk.c
+++ b/sys/dev/msk/if_msk.c
@@ -1445,6 +1445,7 @@ msk_attach(device_t dev)
struct msk_softc *sc;
struct msk_if_softc *sc_if;
struct ifnet *ifp;
+ struct msk_mii_data *mmd;
int i, port, error;
uint8_t eaddr[6];
@@ -1454,7 +1455,8 @@ msk_attach(device_t dev)
error = 0;
sc_if = device_get_softc(dev);
sc = device_get_softc(device_get_parent(dev));
- port = *(int *)device_get_ivars(dev);
+ mmd = device_get_ivars(dev);
+ port = mmd->port;
sc_if->msk_if_dev = dev;
sc_if->msk_port = port;
@@ -1600,7 +1602,8 @@ static int
mskc_attach(device_t dev)
{
struct msk_softc *sc;
- int error, msic, msir, *port, reg;
+ struct msk_mii_data *mmd;
+ int error, msic, msir, reg;
sc = device_get_softc(dev);
sc->msk_dev = dev;
@@ -1669,10 +1672,6 @@ mskc_attach(device_t dev)
CSR_WRITE_2(sc, B0_CTST, CS_RST_SET);
CSR_WRITE_2(sc, B0_CTST, CS_RST_CLR);
sc->msk_pmd = CSR_READ_1(sc, B2_PMD_TYP);
- if (sc->msk_pmd == 'L' || sc->msk_pmd == 'S')
- sc->msk_coppertype = 0;
- else
- sc->msk_coppertype = 1;
/* Check number of MACs. */
sc->msk_num_port = 1;
if ((CSR_READ_1(sc, B2_Y2_HW_RES) & CFG_DUAL_MAC_MSK) ==
@@ -1812,15 +1811,18 @@ mskc_attach(device_t dev)
error = ENXIO;
goto fail;
}
- port = malloc(sizeof(int), M_DEVBUF, M_WAITOK);
- if (port == NULL) {
+ mmd = malloc(sizeof(struct msk_mii_data), M_DEVBUF, M_WAITOK | M_ZERO);
+ if (mmd == NULL) {
device_printf(dev, "failed to allocate memory for "
"ivars of PORT_A\n");
error = ENXIO;
goto fail;
}
- *port = MSK_PORT_A;
- device_set_ivars(sc->msk_devs[MSK_PORT_A], port);
+ mmd->port = MSK_PORT_A;
+ mmd->pmd = sc->msk_pmd;
+ if (sc->msk_pmd == 'L' || sc->msk_pmd == 'S' || sc->msk_pmd == 'P')
+ mmd->mii_flags |= MIIF_HAVEFIBER;
+ device_set_ivars(sc->msk_devs[MSK_PORT_A], mmd);
if (sc->msk_num_port > 1) {
sc->msk_devs[MSK_PORT_B] = device_add_child(dev, "msk", -1);
@@ -1829,15 +1831,18 @@ mskc_attach(device_t dev)
error = ENXIO;
goto fail;
}
- port = malloc(sizeof(int), M_DEVBUF, M_WAITOK);
- if (port == NULL) {
+ mmd = malloc(sizeof(struct msk_mii_data), M_DEVBUF, M_WAITOK | M_ZERO);
+ if (mmd == NULL) {
device_printf(dev, "failed to allocate memory for "
"ivars of PORT_B\n");
error = ENXIO;
goto fail;
}
- *port = MSK_PORT_B;
- device_set_ivars(sc->msk_devs[MSK_PORT_B], port);
+ mmd->port = MSK_PORT_B;
+ mmd->pmd = sc->msk_pmd;
+ if (sc->msk_pmd == 'L' || sc->msk_pmd == 'S' || sc->msk_pmd == 'P')
+ mmd->mii_flags |= MIIF_HAVEFIBER;
+ device_set_ivars(sc->msk_devs[MSK_PORT_B], mmd);
}
error = bus_generic_attach(dev);
OpenPOWER on IntegriCloud