summaryrefslogtreecommitdiffstats
path: root/drivers/net/phy/phy.c
diff options
context:
space:
mode:
authorJan Weitzel <j.weitzel@phytec.de>2013-08-30 10:01:20 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2013-08-31 12:01:32 +0200
commitf958ffb3cdeabad3f54fceed5d755c160c005671 (patch)
tree750283cfcfce8826521d6dd1c8e6e1bd89da8380 /drivers/net/phy/phy.c
parent93a4a77528b8094ab89d4134b722a7eb1b28f756 (diff)
downloadbarebox-f958ffb3cdeabad3f54fceed5d755c160c005671.tar.gz
barebox-f958ffb3cdeabad3f54fceed5d755c160c005671.tar.xz
net/phy: support of mmd register read and write
Add function for indirect access of the mmd registers, based on linux. phy_read_mmd_indirect phy_write_mmd_indirect Also clean some private mmd functions Signed-off-by: Jan Weitzel <j.weitzel@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/net/phy/phy.c')
-rw-r--r--drivers/net/phy/phy.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 112ff13f77..db00e38bbc 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -632,6 +632,69 @@ int genphy_read_status(struct phy_device *phydev)
return 0;
}
+static inline void mmd_phy_indirect(struct phy_device *phydev, int prtad,
+ int devad)
+{
+ /* Write the desired MMD Devad */
+ phy_write(phydev, MII_MMD_CTRL, devad);
+
+ /* Write the desired MMD register address */
+ phy_write(phydev, MII_MMD_DATA, prtad);
+
+ /* Select the Function : DATA with no post increment */
+ phy_write(phydev, MII_MMD_CTRL, (devad | MII_MMD_CTRL_NOINCR));
+}
+
+/**
+ * phy_read_mmd_indirect - reads data from the MMD registers
+ * @phy_device: phy device
+ * @prtad: MMD Address
+ * @devad: MMD DEVAD
+ *
+ * Description: it reads data from the MMD registers (clause 22 to access to
+ * clause 45) of the specified phy address.
+ * To read these register we have:
+ * 1) Write reg 13 // DEVAD
+ * 2) Write reg 14 // MMD Address
+ * 3) Write reg 13 // MMD Data Command for MMD DEVAD
+ * 3) Read reg 14 // Read MMD data
+ */
+int phy_read_mmd_indirect(struct phy_device *phydev, int prtad, int devad)
+{
+ u32 ret;
+
+ mmd_phy_indirect(phydev, prtad, devad);
+
+ /* Read the content of the MMD's selected register */
+ ret = phy_read(phydev, MII_MMD_DATA);
+
+ return ret;
+}
+
+/**
+ * phy_write_mmd_indirect - writes data to the MMD registers
+ * @phy_device: phy device
+ * @prtad: MMD Address
+ * @devad: MMD DEVAD
+ * @data: data to write in the MMD register
+ *
+ * Description: Write data from the MMD registers of the specified
+ * phy address.
+ * To write these register we have:
+ * 1) Write reg 13 // DEVAD
+ * 2) Write reg 14 // MMD Address
+ * 3) Write reg 13 // MMD Data Command for MMD DEVAD
+ * 3) Write reg 14 // Write MMD data
+ */
+void phy_write_mmd_indirect(struct phy_device *phydev, int prtad, int devad,
+ u16 data)
+{
+ mmd_phy_indirect(phydev, prtad, devad);
+
+ /* Write the data into MMD's selected register */
+ phy_write(phydev, MII_MMD_DATA, data);
+}
+
static int genphy_config_init(struct phy_device *phydev)
{
int val;