Revision 94410b78 hw/etraxfs_eth.c

b/hw/etraxfs_eth.c
45 45
{
46 46
	uint32_t regs[32];
47 47

  
48
	int link;
49

  
48 50
	unsigned int (*read)(struct qemu_phy *phy, unsigned int req);
49 51
	void (*write)(struct qemu_phy *phy, unsigned int req, 
50 52
		      unsigned int data);
......
59 61

  
60 62
	switch (regnum) {
61 63
		case 1:
64
			if (!phy->link)
65
				break;
62 66
			/* MR1.	 */
63 67
			/* Speeds and modes.  */
64 68
			r |= (1 << 13) | (1 << 14);
65 69
			r |= (1 << 11) | (1 << 12);
66 70
			r |= (1 << 5); /* Autoneg complete.  */
67 71
			r |= (1 << 3); /* Autoneg able.	 */
68
			r |= (1 << 2); /* Link.	 */
72
			r |= (1 << 2); /* link.	 */
69 73
			break;
70 74
		case 5:
71 75
			/* Link partner ability.
......
83 87
			int duplex = 0;
84 88
			int speed_100 = 0;
85 89

  
90
			if (!phy->link)
91
				break;
92

  
86 93
			/* Are we advertising 100 half or 100 duplex ? */
87 94
			speed_100 = !!(phy->regs[4] & ADVERTISE_100HALF);
88 95
			speed_100 |= !!(phy->regs[4] & ADVERTISE_100FULL);
......
125 132
	phy->regs[3] = 0xe400;
126 133
	/* Autonegotiation advertisement reg.  */
127 134
	phy->regs[4] = 0x01E1;
135
	phy->link = 1;
128 136

  
129 137
	phy->read = tdk_read;
130 138
	phy->write = tdk_write;
......
530 538
	return len;
531 539
}
532 540

  
541
static void eth_set_link(VLANClientState *vc)
542
{
543
	struct fs_eth *eth = vc->opaque;
544
	D(printf("%s %d\n", __func__, vc->link_down));
545
	eth->phy.link = !vc->link_down;
546
}
547

  
533 548
static CPUReadMemoryFunc *eth_read[] = {
534 549
	NULL, NULL,
535 550
	&eth_readl,
......
541 556
};
542 557

  
543 558
void *etraxfs_eth_init(NICInfo *nd, CPUState *env, 
544
		       qemu_irq *irq, target_phys_addr_t base)
559
		       qemu_irq *irq, target_phys_addr_t base, int phyaddr)
545 560
{
546 561
	struct etraxfs_dma_client *dma = NULL;	
547 562
	struct fs_eth *eth = NULL;
......
565 580
	eth->dma_in = dma + 1;
566 581

  
567 582
	/* Connect the phy.  */
568
	eth->phyaddr = 1;
583
	eth->phyaddr = phyaddr & 0x1f;
569 584
	tdk_init(&eth->phy);
570 585
	mdio_attach(&eth->mdio_bus, &eth->phy, eth->phyaddr);
571 586

  
......
574 589

  
575 590
	eth->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
576 591
				       eth_receive, eth_can_receive, eth);
592
	eth->vc->opaque = eth;
593
	eth->vc->link_status_changed = eth_set_link;
577 594

  
578 595
	return dma;
579 596
  err:

Also available in: Unified diff