[U-Boot] [PATCH 1/2] PHY: micrel: helper function for KSZ9031

SARTRE Leo lsartre at adeneo-embedded.com
Thu Jun 20 13:26:31 CEST 2013


micrel.c: Add function ksz9031_phy_extended_write, helper to MDD
		  register write
micrel.h: Prototype and define MDD registers

Signed-off-by: Leo Sartre <lsartre at adeneo-embedded.com>
---
 drivers/net/phy/micrel.c |   29 +++++++++++++++++++++++++++--
 include/micrel.h         |    7 +++++++
 2 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index 2a8b6cb..5b5c11b 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -85,7 +85,7 @@ static int ksz90xx_startup(struct phy_device *phydev)
 }
 #ifdef CONFIG_PHY_MICREL_KSZ9021
 
-/*
+/**
  * KSZ9021
  */
 
@@ -148,9 +148,34 @@ static struct phy_driver ksz9021_driver = {
 };
 #endif
 
-/*
+/**
  * KSZ9031
  */
+
+/* PHY Registers */
+#define MII_KSZ9031_MMD_ACCES_CTRL 0x0d
+#define MII_KSZ9031_MMD_REG_DATA   0x0e
+
+/* Accessors to extended registers*/
+int ksz9031_phy_extended_write(struct phy_device *phydev,
+							   int devaddr,
+							   int regnum,
+							   u16 val)
+{
+	/*select register addr for mmd*/
+	phy_write(phydev, MDIO_DEVAD_NONE,
+			 MII_KSZ9031_MMD_ACCES_CTRL, devaddr);
+	/*select register for mmd*/
+	phy_write(phydev, MDIO_DEVAD_NONE,
+			 MII_KSZ9031_MMD_REG_DATA, regnum);
+	/*setup mode*/
+	phy_write(phydev, MDIO_DEVAD_NONE,
+			 MII_KSZ9031_MMD_ACCES_CTRL, (devaddr | 0xC000));
+	/*write the value*/
+	return phy_write(phydev, MDIO_DEVAD_NONE,
+					 MII_KSZ9031_MMD_REG_DATA, val);
+}
+
 static struct phy_driver ksz9031_driver = {
 	.name = "Micrel ksz9031",
 	.uid  = 0x221620,
diff --git a/include/micrel.h b/include/micrel.h
index 25e8a46..d63ff45 100644
--- a/include/micrel.h
+++ b/include/micrel.h
@@ -9,8 +9,15 @@
 #define MII_KSZ9021_EXT_RGMII_TX_DATA_SKEW	0x106
 #define MII_KSZ9021_EXT_ANALOG_TEST		0x107
 
+#define MII_KSZ9031_EXT_RGMII_CTRL_SIG_SKEW	0x4
+#define MII_KSZ9031_EXT_RGMII_RX_DATA_SKEW	0x5
+#define MII_KSZ9031_EXT_RGMII_TX_DATA_SKEW	0x6
+#define MII_KSZ9031_EXT_RGMII_CLOCK_SKEW	0x8
+
 struct phy_device;
 int ksz9021_phy_extended_write(struct phy_device *phydev, int regnum, u16 val);
 int ksz9021_phy_extended_read(struct phy_device *phydev, int regnum);
 
+int ksz9031_phy_extended_write(struct phy_device *phydev, int devaddr,
+							   int regnum, u16 val);
 #endif
-- 
1.7.10.4


More information about the U-Boot mailing list