qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Grant Likely <grant.likely@secretlab.ca>
To: qemu-devel@nongnu.org
Cc: Grant Likely <grant.likely@secretlab.ca>,
	Peter Maydell <peter.maydell@linaro.org>,
	Anthony Liguori <aliguori@us.ibm.com>,
	Paul Brook <paul@codesourcery.com>,
	"Edgar E. Iglesias" <edgar.iglesias@gmail.com>
Subject: [Qemu-devel] [PATCH 2/3] net/bitbang_mdio: Never set PHY RST and ANEG_RST bits on register write
Date: Sat, 19 Jan 2013 18:28:11 -0400	[thread overview]
Message-ID: <1358634492-22627-3-git-send-email-grant.likely@secretlab.ca> (raw)
In-Reply-To: <1358634492-22627-1-git-send-email-grant.likely@secretlab.ca>

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>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
 hw/bitbang_mdio.c |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/hw/bitbang_mdio.c b/hw/bitbang_mdio.c
index f0ee6af..28ac695 100644
--- a/hw/bitbang_mdio.c
+++ b/hw/bitbang_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 */
@@ -106,6 +110,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;
@@ -114,7 +122,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;
-- 
1.7.10.4

  parent reply	other threads:[~2013-01-20  0:20 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-19 22:28 [Qemu-devel] [PATCH 0/3] Generalize bitbang MDIO and use for versatile-pb Grant Likely
2013-01-19 22:28 ` [Qemu-devel] [PATCH 1/3] net/bitbang_mdio: Generalize etraxfs MDIO bitbanging emulation Grant Likely
2013-01-20 17:29   ` Andreas Färber
2013-01-21 12:51   ` Edgar E. Iglesias
2013-01-19 22:28 ` Grant Likely [this message]
2013-01-19 22:28 ` [Qemu-devel] [PATCH 3/3] net/bitbang_mdio: Use bitbang core for smc91c111 network device Grant Likely
2013-01-20 11:29   ` Peter Maydell
2013-01-21 13:12     ` Grant Likely
2013-01-20 17:26 ` [Qemu-devel] [PATCH 0/3] Generalize bitbang MDIO and use for versatile-pb Andreas Färber

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1358634492-22627-3-git-send-email-grant.likely@secretlab.ca \
    --to=grant.likely@secretlab.ca \
    --cc=aliguori@us.ibm.com \
    --cc=edgar.iglesias@gmail.com \
    --cc=paul@codesourcery.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).