qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Cédric Le Goater" <clg@kaod.org>
To: Jason Wang <jasowang@redhat.com>, qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	"Cédric Le Goater" <clg@kaod.org>,
	"Edgar E . Iglesias" <edgar.iglesias@gmail.com>
Subject: [Qemu-devel] [PATCH v2 02/11] net: etraxfs_eth: add a reset method
Date: Mon,  1 Oct 2018 08:37:54 +0200	[thread overview]
Message-ID: <20181001063803.22330-3-clg@kaod.org> (raw)
In-Reply-To: <20181001063803.22330-1-clg@kaod.org>

Cc: Edgar E. Iglesias <edgar.iglesias@gmail.com>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 hw/net/etraxfs_eth.c | 31 +++++++++++++++++++++++++------
 1 file changed, 25 insertions(+), 6 deletions(-)

diff --git a/hw/net/etraxfs_eth.c b/hw/net/etraxfs_eth.c
index 64ab3df1ae38..36855804dba0 100644
--- a/hw/net/etraxfs_eth.c
+++ b/hw/net/etraxfs_eth.c
@@ -127,7 +127,7 @@ tdk_write(struct qemu_phy *phy, unsigned int req, unsigned int data)
 }
 
 static void
-tdk_init(struct qemu_phy *phy)
+tdk_reset(struct qemu_phy *phy)
 {
     phy->regs[0] = 0x3100;
     /* PHY Id.  */
@@ -136,9 +136,6 @@ tdk_init(struct qemu_phy *phy)
     /* Autonegotiation advertisement reg.  */
     phy->regs[4] = 0x01E1;
     phy->link = 1;
-
-    phy->read = tdk_read;
-    phy->write = tdk_write;
 }
 
 struct qemu_mdio
@@ -585,6 +582,27 @@ static NetClientInfo net_etraxfs_info = {
     .link_status_changed = eth_set_link,
 };
 
+static void etraxfs_eth_reset(DeviceState *dev)
+{
+    ETRAXFSEthState *s = ETRAX_FS_ETH(dev);
+
+    memset(s->regs, 0, sizeof(s->regs));
+    memset(s->macaddr, 0, sizeof(s->macaddr));
+    s->duplex_mismatch = 0;
+
+    s->mdio_bus.mdc = 0;
+    s->mdio_bus.mdio = 0;
+    s->mdio_bus.state = 0;
+    s->mdio_bus.drive = 0;
+    s->mdio_bus.cnt = 0;
+    s->mdio_bus.addr = 0;
+    s->mdio_bus.opc = 0;
+    s->mdio_bus.req = 0;
+    s->mdio_bus.data = 0;
+
+    tdk_reset(&s->phy);
+}
+
 static void etraxfs_eth_realize(DeviceState *dev, Error **errp)
 {
     SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
@@ -609,8 +627,8 @@ static void etraxfs_eth_realize(DeviceState *dev, Error **errp)
                           object_get_typename(OBJECT(s)), dev->id, s);
     qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a);
 
-
-    tdk_init(&s->phy);
+    s->phy.read = tdk_read;
+    s->phy.write = tdk_write;
     mdio_attach(&s->mdio_bus, &s->phy, s->phyaddr);
 }
 
@@ -627,6 +645,7 @@ static void etraxfs_eth_class_init(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     dc->realize = etraxfs_eth_realize;
+    dc->reset = etraxfs_eth_reset;
     dc->props = etraxfs_eth_properties;
     /* Reason: pointer properties "dma_out", "dma_in" */
     dc->user_creatable = false;
-- 
2.17.1

  parent reply	other threads:[~2018-10-01  6:38 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-01  6:37 [Qemu-devel] [PATCH v2 00/11] net: convert SysBus init method to a realize method Cédric Le Goater
2018-10-01  6:37 ` [Qemu-devel] [PATCH v2 01/11] net: etraxfs_eth: " Cédric Le Goater
2018-10-01  7:57   ` Philippe Mathieu-Daudé
2018-10-01  6:37 ` Cédric Le Goater [this message]
2018-10-01  8:00   ` [Qemu-devel] [PATCH v2 02/11] net: etraxfs_eth: add a reset method Philippe Mathieu-Daudé
2018-10-01  6:37 ` [Qemu-devel] [PATCH v2 03/11] net: lan9118: convert SysBus init method to a realize method Cédric Le Goater
2018-10-01  8:01   ` Philippe Mathieu-Daudé
2018-10-01  6:37 ` [Qemu-devel] [PATCH v2 04/11] net: lance: " Cédric Le Goater
2018-10-01  6:37 ` [Qemu-devel] [PATCH v2 05/11] net: milkymist_minimac2: " Cédric Le Goater
2018-10-01  7:46   ` Michael Walle
2018-10-01  6:37 ` [Qemu-devel] [PATCH v2 06/11] net: mipsnet: " Cédric Le Goater
2018-10-01  6:37 ` [Qemu-devel] [PATCH v2 07/11] net: opencores_eth: " Cédric Le Goater
2018-10-01  7:51   ` Max Filippov
2018-10-01  6:38 ` [Qemu-devel] [PATCH v2 08/11] net: smc91c111: " Cédric Le Goater
2018-10-01  8:01   ` Philippe Mathieu-Daudé
2018-10-01  6:38 ` [Qemu-devel] [PATCH v2 09/11] net: stellaris_enet: " Cédric Le Goater
2018-10-01  6:38 ` [Qemu-devel] [PATCH v2 10/11] net: stellaris_enet: add a reset method Cédric Le Goater
2018-10-01  6:38 ` [Qemu-devel] [PATCH v2 11/11] net: xgmac: convert SysBus init method to a realize method Cédric Le Goater
2018-10-10 13:30 ` [Qemu-devel] [PATCH v2 00/11] net: " Philippe Mathieu-Daudé
2018-10-11 17:47   ` Eduardo Habkost

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=20181001063803.22330-3-clg@kaod.org \
    --to=clg@kaod.org \
    --cc=edgar.iglesias@gmail.com \
    --cc=f4bug@amsat.org \
    --cc=jasowang@redhat.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).