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> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6255 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
parent
5ab09f3349
commit
94410b78be
|
@ -304,10 +304,11 @@ void axisdev88_init (ram_addr_t ram_size, int vga_ram_size,
|
||||||
|
|
||||||
/* Add the two ethernet blocks. */
|
/* Add the two ethernet blocks. */
|
||||||
nd_table[0].model = nd_table[0].model ? nd_table[0].model : "fseth";
|
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) {
|
if (nb_nics > 1) {
|
||||||
nd_table[1].model = nd_table[1].model ? nd_table[1].model : "fseth";
|
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. */
|
/* The DMA Connector block is missing, hardwire things for now. */
|
||||||
|
|
|
@ -95,10 +95,11 @@ void bareetraxfs_init (ram_addr_t ram_size, int vga_ram_size,
|
||||||
|
|
||||||
/* Add the two ethernet blocks. */
|
/* Add the two ethernet blocks. */
|
||||||
nd_table[0].model = nd_table[0].model ? nd_table[0].model : "fseth";
|
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) {
|
if (nb_nics > 1) {
|
||||||
nd_table[1].model = nd_table[1].model ? nd_table[1].model : "fseth";
|
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. */
|
/* The DMA Connector block is missing, hardwire things for now. */
|
||||||
|
|
|
@ -37,6 +37,6 @@ struct etraxfs_pic *etraxfs_pic_init(CPUState *env, target_phys_addr_t base);
|
||||||
void etraxfs_timer_init(CPUState *env, qemu_irq *irqs, qemu_irq *nmi,
|
void etraxfs_timer_init(CPUState *env, qemu_irq *irqs, qemu_irq *nmi,
|
||||||
target_phys_addr_t base);
|
target_phys_addr_t base);
|
||||||
void *etraxfs_eth_init(NICInfo *nd, CPUState *env,
|
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,
|
void etraxfs_ser_init(CPUState *env, qemu_irq *irq, CharDriverState *chr,
|
||||||
target_phys_addr_t base);
|
target_phys_addr_t base);
|
||||||
|
|
|
@ -45,6 +45,8 @@ struct qemu_phy
|
||||||
{
|
{
|
||||||
uint32_t regs[32];
|
uint32_t regs[32];
|
||||||
|
|
||||||
|
int link;
|
||||||
|
|
||||||
unsigned int (*read)(struct qemu_phy *phy, unsigned int req);
|
unsigned int (*read)(struct qemu_phy *phy, unsigned int req);
|
||||||
void (*write)(struct qemu_phy *phy, unsigned int req,
|
void (*write)(struct qemu_phy *phy, unsigned int req,
|
||||||
unsigned int data);
|
unsigned int data);
|
||||||
|
@ -59,13 +61,15 @@ static unsigned int tdk_read(struct qemu_phy *phy, unsigned int req)
|
||||||
|
|
||||||
switch (regnum) {
|
switch (regnum) {
|
||||||
case 1:
|
case 1:
|
||||||
|
if (!phy->link)
|
||||||
|
break;
|
||||||
/* MR1. */
|
/* MR1. */
|
||||||
/* Speeds and modes. */
|
/* Speeds and modes. */
|
||||||
r |= (1 << 13) | (1 << 14);
|
r |= (1 << 13) | (1 << 14);
|
||||||
r |= (1 << 11) | (1 << 12);
|
r |= (1 << 11) | (1 << 12);
|
||||||
r |= (1 << 5); /* Autoneg complete. */
|
r |= (1 << 5); /* Autoneg complete. */
|
||||||
r |= (1 << 3); /* Autoneg able. */
|
r |= (1 << 3); /* Autoneg able. */
|
||||||
r |= (1 << 2); /* Link. */
|
r |= (1 << 2); /* link. */
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
/* Link partner ability.
|
/* Link partner ability.
|
||||||
|
@ -83,6 +87,9 @@ static unsigned int tdk_read(struct qemu_phy *phy, unsigned int req)
|
||||||
int duplex = 0;
|
int duplex = 0;
|
||||||
int speed_100 = 0;
|
int speed_100 = 0;
|
||||||
|
|
||||||
|
if (!phy->link)
|
||||||
|
break;
|
||||||
|
|
||||||
/* Are we advertising 100 half or 100 duplex ? */
|
/* Are we advertising 100 half or 100 duplex ? */
|
||||||
speed_100 = !!(phy->regs[4] & ADVERTISE_100HALF);
|
speed_100 = !!(phy->regs[4] & ADVERTISE_100HALF);
|
||||||
speed_100 |= !!(phy->regs[4] & ADVERTISE_100FULL);
|
speed_100 |= !!(phy->regs[4] & ADVERTISE_100FULL);
|
||||||
|
@ -125,6 +132,7 @@ tdk_init(struct qemu_phy *phy)
|
||||||
phy->regs[3] = 0xe400;
|
phy->regs[3] = 0xe400;
|
||||||
/* Autonegotiation advertisement reg. */
|
/* Autonegotiation advertisement reg. */
|
||||||
phy->regs[4] = 0x01E1;
|
phy->regs[4] = 0x01E1;
|
||||||
|
phy->link = 1;
|
||||||
|
|
||||||
phy->read = tdk_read;
|
phy->read = tdk_read;
|
||||||
phy->write = tdk_write;
|
phy->write = tdk_write;
|
||||||
|
@ -530,6 +538,13 @@ static int eth_tx_push(void *opaque, unsigned char *buf, int len)
|
||||||
return len;
|
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[] = {
|
static CPUReadMemoryFunc *eth_read[] = {
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
ð_readl,
|
ð_readl,
|
||||||
|
@ -541,7 +556,7 @@ static CPUWriteMemoryFunc *eth_write[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
void *etraxfs_eth_init(NICInfo *nd, CPUState *env,
|
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 etraxfs_dma_client *dma = NULL;
|
||||||
struct fs_eth *eth = NULL;
|
struct fs_eth *eth = NULL;
|
||||||
|
@ -565,7 +580,7 @@ void *etraxfs_eth_init(NICInfo *nd, CPUState *env,
|
||||||
eth->dma_in = dma + 1;
|
eth->dma_in = dma + 1;
|
||||||
|
|
||||||
/* Connect the phy. */
|
/* Connect the phy. */
|
||||||
eth->phyaddr = 1;
|
eth->phyaddr = phyaddr & 0x1f;
|
||||||
tdk_init(ð->phy);
|
tdk_init(ð->phy);
|
||||||
mdio_attach(ð->mdio_bus, ð->phy, eth->phyaddr);
|
mdio_attach(ð->mdio_bus, ð->phy, eth->phyaddr);
|
||||||
|
|
||||||
|
@ -574,6 +589,8 @@ void *etraxfs_eth_init(NICInfo *nd, CPUState *env,
|
||||||
|
|
||||||
eth->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
|
eth->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
|
||||||
eth_receive, eth_can_receive, eth);
|
eth_receive, eth_can_receive, eth);
|
||||||
|
eth->vc->opaque = eth;
|
||||||
|
eth->vc->link_status_changed = eth_set_link;
|
||||||
|
|
||||||
return dma;
|
return dma;
|
||||||
err:
|
err:
|
||||||
|
|
Loading…
Reference in a new issue