qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [6255] ETRAX: Let the ethernet PHY report the current link-state.
Date: Fri, 09 Jan 2009 00:04:36 +0000	[thread overview]
Message-ID: <E1LL4rc-0003kR-36@cvs.savannah.gnu.org> (raw)

Revision: 6255
          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6255
Author:   edgar_igl
Date:     2009-01-09 00:04:35 +0000 (Fri, 09 Jan 2009)

Log Message:
-----------
ETRAX: Let the ethernet PHY report the current link-state.

* PHY reports correct link-state.
* Allow the board description to assign separate addresses to each PHY.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>

Modified Paths:
--------------
    trunk/hw/axis_dev88.c
    trunk/hw/etraxfs.c
    trunk/hw/etraxfs.h
    trunk/hw/etraxfs_eth.c

Modified: trunk/hw/axis_dev88.c
===================================================================
--- trunk/hw/axis_dev88.c	2009-01-08 23:19:50 UTC (rev 6254)
+++ trunk/hw/axis_dev88.c	2009-01-09 00:04:35 UTC (rev 6255)
@@ -304,10 +304,11 @@
 
     /* Add the two ethernet blocks.  */
     nd_table[0].model = nd_table[0].model ? nd_table[0].model : "fseth";
-    eth[0] = etraxfs_eth_init(&nd_table[0], env, pic->irq + 25, 0x30034000);
+    eth[0] = etraxfs_eth_init(&nd_table[0], env, pic->irq + 25, 0x30034000, 1);
     if (nb_nics > 1) {
         nd_table[1].model = nd_table[1].model ? nd_table[1].model : "fseth";
-        eth[1] = etraxfs_eth_init(&nd_table[1], env, pic->irq + 26, 0x30036000);
+        eth[1] = etraxfs_eth_init(&nd_table[1], env,
+                                  pic->irq + 26, 0x30036000, 2);
     }
 
     /* The DMA Connector block is missing, hardwire things for now.  */

Modified: trunk/hw/etraxfs.c
===================================================================
--- trunk/hw/etraxfs.c	2009-01-08 23:19:50 UTC (rev 6254)
+++ trunk/hw/etraxfs.c	2009-01-09 00:04:35 UTC (rev 6255)
@@ -95,10 +95,11 @@
 
     /* Add the two ethernet blocks.  */
     nd_table[0].model = nd_table[0].model ? nd_table[0].model : "fseth";
-    eth[0] = etraxfs_eth_init(&nd_table[0], env, pic->irq + 25, 0x30034000);
+    eth[0] = etraxfs_eth_init(&nd_table[0], env, pic->irq + 25, 0x30034000, 1);
     if (nb_nics > 1) {
         nd_table[1].model = nd_table[1].model ? nd_table[1].model : "fseth";
-        eth[1] = etraxfs_eth_init(&nd_table[1], env, pic->irq + 26, 0x30036000);
+        eth[1] = etraxfs_eth_init(&nd_table[1], env,
+                                  pic->irq + 26, 0x30036000, 2);
     }
 
     /* The DMA Connector block is missing, hardwire things for now.  */

Modified: trunk/hw/etraxfs.h
===================================================================
--- trunk/hw/etraxfs.h	2009-01-08 23:19:50 UTC (rev 6254)
+++ trunk/hw/etraxfs.h	2009-01-09 00:04:35 UTC (rev 6255)
@@ -37,6 +37,6 @@
 void etraxfs_timer_init(CPUState *env, qemu_irq *irqs, qemu_irq *nmi,
                         target_phys_addr_t base);
 void *etraxfs_eth_init(NICInfo *nd, CPUState *env,
-                       qemu_irq *irq, target_phys_addr_t base);
+                       qemu_irq *irq, target_phys_addr_t base, int phyaddr);
 void etraxfs_ser_init(CPUState *env, qemu_irq *irq, CharDriverState *chr,
                       target_phys_addr_t base);

Modified: trunk/hw/etraxfs_eth.c
===================================================================
--- trunk/hw/etraxfs_eth.c	2009-01-08 23:19:50 UTC (rev 6254)
+++ trunk/hw/etraxfs_eth.c	2009-01-09 00:04:35 UTC (rev 6255)
@@ -45,6 +45,8 @@
 {
 	uint32_t regs[32];
 
+	int link;
+
 	unsigned int (*read)(struct qemu_phy *phy, unsigned int req);
 	void (*write)(struct qemu_phy *phy, unsigned int req, 
 		      unsigned int data);
@@ -59,13 +61,15 @@
 
 	switch (regnum) {
 		case 1:
+			if (!phy->link)
+				break;
 			/* MR1.	 */
 			/* Speeds and modes.  */
 			r |= (1 << 13) | (1 << 14);
 			r |= (1 << 11) | (1 << 12);
 			r |= (1 << 5); /* Autoneg complete.  */
 			r |= (1 << 3); /* Autoneg able.	 */
-			r |= (1 << 2); /* Link.	 */
+			r |= (1 << 2); /* link.	 */
 			break;
 		case 5:
 			/* Link partner ability.
@@ -83,6 +87,9 @@
 			int duplex = 0;
 			int speed_100 = 0;
 
+			if (!phy->link)
+				break;
+
 			/* Are we advertising 100 half or 100 duplex ? */
 			speed_100 = !!(phy->regs[4] & ADVERTISE_100HALF);
 			speed_100 |= !!(phy->regs[4] & ADVERTISE_100FULL);
@@ -125,6 +132,7 @@
 	phy->regs[3] = 0xe400;
 	/* Autonegotiation advertisement reg.  */
 	phy->regs[4] = 0x01E1;
+	phy->link = 1;
 
 	phy->read = tdk_read;
 	phy->write = tdk_write;
@@ -530,6 +538,13 @@
 	return len;
 }
 
+static void eth_set_link(VLANClientState *vc)
+{
+	struct fs_eth *eth = vc->opaque;
+	D(printf("%s %d\n", __func__, vc->link_down));
+	eth->phy.link = !vc->link_down;
+}
+
 static CPUReadMemoryFunc *eth_read[] = {
 	NULL, NULL,
 	&eth_readl,
@@ -541,7 +556,7 @@
 };
 
 void *etraxfs_eth_init(NICInfo *nd, CPUState *env, 
-		       qemu_irq *irq, target_phys_addr_t base)
+		       qemu_irq *irq, target_phys_addr_t base, int phyaddr)
 {
 	struct etraxfs_dma_client *dma = NULL;	
 	struct fs_eth *eth = NULL;
@@ -565,7 +580,7 @@
 	eth->dma_in = dma + 1;
 
 	/* Connect the phy.  */
-	eth->phyaddr = 1;
+	eth->phyaddr = phyaddr & 0x1f;
 	tdk_init(&eth->phy);
 	mdio_attach(&eth->mdio_bus, &eth->phy, eth->phyaddr);
 
@@ -574,6 +589,8 @@
 
 	eth->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
 				       eth_receive, eth_can_receive, eth);
+	eth->vc->opaque = eth;
+	eth->vc->link_status_changed = eth_set_link;
 
 	return dma;
   err:

                 reply	other threads:[~2009-01-09  0:04 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=E1LL4rc-0003kR-36@cvs.savannah.gnu.org \
    --to=edgar.iglesias@gmail.com \
    --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).