Patchwork [U-Boot,v2,1/3] PHY: micrel: helper function for KSZ9031

login
register
mail settings
Submitter SARTRE Leo
Date June 20, 2013, 1:46 p.m.
Message ID <3465D313FDFB824F9A9C8CD24FA4F6BC0108CD36@frontmail.adetel.com>
Download mbox | patch
Permalink /patch/252934/
State Superseded
Delegated to: Stefano Babic
Headers show

Comments

SARTRE Leo - June 20, 2013, 1:46 p.m.
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@adeneo-embedded.com>
---
 drivers/net/phy/micrel.c |   25 +++++++++++++++++++++++++
 include/micrel.h         |    7 +++++++
 2 files changed, 32 insertions(+)
Otavio Salvador - June 20, 2013, 2:37 p.m.
On Thu, Jun 20, 2013 at 10:46 AM, SARTRE Leo
<lsartre@adeneo-embedded.com> wrote:
> 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@adeneo-embedded.com>

Acked-by: Otavio Salvador <otavio@ossystems.com.br>

--
Otavio Salvador                             O.S. Systems
http://www.ossystems.com.br        http://projetos.ossystems.com.br
Mobile: +55 (53) 9981-7854            Mobile: +1 (347) 903-9750

Patch

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