Patchwork [V2,3/6] hw/mdio: Never set PHY RST and ANEG_RST bits on register write

login
register
mail settings
Submitter Grant Likely
Date Jan. 23, 2013, 4:15 p.m.
Message ID <1358957730-17897-4-git-send-email-grant.likely@secretlab.ca>
Download mbox | patch
Permalink /patch/215057/
State New
Headers show

Comments

Grant Likely - Jan. 23, 2013, 4:15 p.m.
The RST and ANEG_RST bits are commands, not settings. An operating
system will get confused (or at least u-boot does) if those bits remain
set after writing to them. Therefore, mask them out on write.

Cc: Peter Maydell <peter.maydell@linaro.org>
Cc: Paul Brook <paul@codesourcery.com>
Cc: Edgar E. Iglesias <edgar.iglesias@gmail.com>
Cc: Anthony Liguori <aliguori@us.ibm.com>
Cc: Andreas Färber <afaerber@suse.de>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
 hw/mdio.c |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

Patch

diff --git a/hw/mdio.c b/hw/mdio.c
index 20d7603..b138efa 100644
--- a/hw/mdio.c
+++ b/hw/mdio.c
@@ -30,6 +30,10 @@ 
 #define D(x)
 
 /* Advertisement control register. */
+#define PHY_CNTL_REG            0
+#define PHY_CNTL_RST            0x8000 /* PHY reset command */
+#define PHY_CNTL_ANEG_RST       0x0200 /* Autonegotiation reset command */
+
 #define ADVERTISE_10HALF        0x0020  /* Try for 10mbps half-duplex  */
 #define ADVERTISE_10FULL        0x0040  /* Try for 10mbps full-duplex  */
 #define ADVERTISE_100HALF       0x0080  /* Try for 100mbps half-duplex */
@@ -111,6 +115,10 @@  static void tdk_write(struct qemu_phy *phy, unsigned int req, unsigned int data)
     regnum = req & 0x1f;
     D(printf("%s reg[%d] = %x\n", __func__, regnum, data));
     switch (regnum) {
+    case PHY_CNTL_REG:
+        /* Don't ever store the RST or ANEG_RST bits; they are commands */
+        phy->regs[regnum] = data & ~(PHY_CNTL_RST | PHY_CNTL_ANEG_RST);
+        break;
     default:
         phy->regs[regnum] = data;
         break;
@@ -119,7 +127,7 @@  static void tdk_write(struct qemu_phy *phy, unsigned int req, unsigned int data)
 
 void tdk_init(struct qemu_phy *phy)
 {
-    phy->regs[0] = 0x3100;
+    phy->regs[PHY_CNTL_REG] = 0x3100;
     /* PHY Id. */
     phy->regs[2] = 0x0300;
     phy->regs[3] = 0xe400;