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 3/3] net/bitbang_mdio: Use bitbang core for smc91c111 network device
Date: Sat, 19 Jan 2013 18:28:12 -0400 [thread overview]
Message-ID: <1358634492-22627-4-git-send-email-grant.likely@secretlab.ca> (raw)
In-Reply-To: <1358634492-22627-1-git-send-email-grant.likely@secretlab.ca>
The smc91c111 device has bitbanged MDIO access, but the model doesn't
yet implement it. This patch uses the generalized bitbang MDIO support
pulled out of etraxfs Ethernet driver.
The MDIO state machine is driven by changes in state to the clock
control bit in the management register. The PHY model emulated is
currently trivial (being whatever was done for the etraxfs driver), but
it is enough to get an OS to recognize a PHY as being present.
Tested with the versatilepb model with U-Boot and the Linux Kernel as
client software.
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/Makefile.objs | 2 +-
hw/smc91c111.c | 29 +++++++++++++++++++++++++----
2 files changed, 26 insertions(+), 5 deletions(-)
diff --git a/hw/Makefile.objs b/hw/Makefile.objs
index 74b07a7..0104fd4 100644
--- a/hw/Makefile.objs
+++ b/hw/Makefile.objs
@@ -117,7 +117,7 @@ common-obj-$(CONFIG_PCNET_COMMON) += pcnet.o
common-obj-$(CONFIG_E1000_PCI) += e1000.o
common-obj-$(CONFIG_RTL8139_PCI) += rtl8139.o
-common-obj-$(CONFIG_SMC91C111) += smc91c111.o
+common-obj-$(CONFIG_SMC91C111) += smc91c111.o bitbang_mdio.o
common-obj-$(CONFIG_LAN9118) += lan9118.o
common-obj-$(CONFIG_NE2000_ISA) += ne2000-isa.o
common-obj-$(CONFIG_OPENCORES_ETH) += opencores_eth.o
diff --git a/hw/smc91c111.c b/hw/smc91c111.c
index a34698f..715422d 100644
--- a/hw/smc91c111.c
+++ b/hw/smc91c111.c
@@ -10,6 +10,7 @@
#include "sysbus.h"
#include "net/net.h"
#include "devices.h"
+#include "bitbang_mdio.h"
/* For crc32 */
#include <zlib.h>
@@ -44,6 +45,13 @@ typedef struct {
uint8_t int_level;
uint8_t int_mask;
MemoryRegion mmio;
+
+ /* MDIO bus. */
+ struct qemu_mdio mdio_bus;
+ unsigned int phyaddr;
+
+ /* PHY. */
+ struct qemu_phy phy;
} smc91c111_state;
static const VMStateDescription vmstate_smc91c111 = {
@@ -437,8 +445,19 @@ static void smc91c111_writeb(void *opaque, hwaddr offset,
/* Multicast table. */
/* Not implemented. */
return;
- case 8: case 9: /* Management Interface. */
- /* Not implemented. */
+ case 8: /* Management Interface. */
+ /* Update MDIO data line status; but only if output is enabled */
+ if (value & 8) {
+ s->mdio_bus.mdio = !!(value & 1);
+ }
+ /* Process the clock */
+ if (s->mdio_bus.mdc != (value & 4)) {
+ mdio_cycle(&s->mdio_bus);
+ s->mdio_bus.mdc = !!(value & 4);
+ }
+ return;
+ case 9: /* Management Interface. */
+ /* Not implemented */
return;
case 12: /* Early receive. */
s->ercv = value & 0x1f;
@@ -576,8 +595,7 @@ static uint32_t smc91c111_readb(void *opaque, hwaddr offset)
/* Not implemented. */
return 0;
case 8: /* Management Interface. */
- /* Not implemented. */
- return 0x30;
+ return 0x30 | (s->mdio_bus.mdio ? 2 : 0);
case 9:
return 0x33;
case 10: /* Revision. */
@@ -754,6 +772,9 @@ static int smc91c111_init1(SysBusDevice *dev)
s->nic = qemu_new_nic(&net_smc91c111_info, &s->conf,
object_get_typename(OBJECT(dev)), dev->qdev.id, s);
qemu_format_nic_info_str(&s->nic->nc, s->conf.macaddr.a);
+
+ tdk_init(&s->phy);
+ mdio_attach(&s->mdio_bus, &s->phy, 0);
/* ??? Save/restore. */
return 0;
}
--
1.7.10.4
next prev 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 ` [Qemu-devel] [PATCH 2/3] net/bitbang_mdio: Never set PHY RST and ANEG_RST bits on register write Grant Likely
2013-01-19 22:28 ` Grant Likely [this message]
2013-01-20 11:29 ` [Qemu-devel] [PATCH 3/3] net/bitbang_mdio: Use bitbang core for smc91c111 network device 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-4-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).