[U-Boot] [PATCH v2 1/3] PHY: micrel: helper function for KSZ9031
SARTRE Leo
lsartre at adeneo-embedded.com
Thu Jun 20 15:46:48 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 | 25 +++++++++++++++++++++++++
include/micrel.h | 7 +++++++
2 files changed, 32 insertions(+)
diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index 2a8b6cb..404faac 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -151,6 +151,31 @@ static struct phy_driver ksz9021_driver = {
/*
* 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