summaryrefslogtreecommitdiffstats
path: root/sys/arm/ti
diff options
context:
space:
mode:
authorLuiz Otavio O Souza <luiz@netgate.com>2017-03-12 03:22:10 -0500
committerLuiz Souza <luiz@netgate.com>2017-07-20 21:31:03 -0500
commit9b9e72855f08214947644bc51b3316ca4cd63ec0 (patch)
tree98670345b745842b79e89a913509f9835e577378 /sys/arm/ti
parentba407fd699a0ab3abe46ba8b7072a87237f2824d (diff)
downloadFreeBSD-src-9b9e72855f08214947644bc51b3316ca4cd63ec0.zip
FreeBSD-src-9b9e72855f08214947644bc51b3316ca4cd63ec0.tar.gz
Add read and write support for the PHY registers.
(cherry picked from commit 9a726e85185cf7cc2ed17cd59389dfa45421b61d)
Diffstat (limited to 'sys/arm/ti')
-rw-r--r--sys/arm/ti/cpsw/if_cpsw.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/sys/arm/ti/cpsw/if_cpsw.c b/sys/arm/ti/cpsw/if_cpsw.c
index c385557..fd61cdf 100644
--- a/sys/arm/ti/cpsw/if_cpsw.c
+++ b/sys/arm/ti/cpsw/if_cpsw.c
@@ -2978,16 +2978,36 @@ cpsw_writereg(device_t dev, int addr, int value)
static int
cpsw_readphy(device_t dev, int phy, int reg)
{
+ int i;
+ struct cpsw_softc *sc;
- /* Not supported. */
- return (0);
+ sc = device_get_softc(dev);
+ if (!sc->dualemac)
+ return (0);
+ for (i = 0; i < CPSW_PORTS; i++)
+ if (sc->port[i].phy == phy)
+ break;
+ if (i >= CPSW_PORTS)
+ return (0);
+
+ return (cpswp_miibus_readreg(sc->port[i].dev, phy, reg));
}
static int
cpsw_writephy(device_t dev, int phy, int reg, int data)
{
+ int i;
+ struct cpsw_softc *sc;
- /* Not supported. */
- return (0);
+ sc = device_get_softc(dev);
+ if (!sc->dualemac)
+ return (0);
+ for (i = 0; i < CPSW_PORTS; i++)
+ if (sc->port[i].phy == phy)
+ break;
+ if (i >= CPSW_PORTS)
+ return (0);
+
+ return (cpswp_miibus_writereg(sc->port[i].dev, phy, reg, data));
}
#endif
OpenPOWER on IntegriCloud