@@ -342,7 +342,7 @@ static int fs_eth_init(SysBusDevice *dev)
object_get_typename(OBJECT(s)), dev->qdev.id, s);
qemu_format_nic_info_str(&s->nic->nc, s->conf.macaddr.a);
- tdk_init(&s->phy);
+ mdio_phy_init(&s->phy, 0x0300, 0xe400);
mdio_attach(&s->mdio_bus, &s->phy, s->phyaddr);
return 0;
}
@@ -43,7 +43,7 @@
* linux driver (PHYID and Diagnostics reg).
* TODO: Add friendly names for the register nums.
*/
-static unsigned int tdk_read(struct qemu_phy *phy, unsigned int req)
+static unsigned int mdio_phy_read(struct qemu_phy *phy, unsigned int req)
{
int regnum;
unsigned r = 0;
@@ -107,7 +107,7 @@ static unsigned int tdk_read(struct qemu_phy *phy, unsigned int req)
return r;
}
-static void tdk_write(struct qemu_phy *phy, unsigned int req, unsigned int data)
+static void mdio_phy_write(struct qemu_phy *phy, unsigned int req, unsigned int data)
{
int regnum;
@@ -120,18 +120,18 @@ static void tdk_write(struct qemu_phy *phy, unsigned int req, unsigned int data)
}
}
-void tdk_init(struct qemu_phy *phy)
+void mdio_phy_init(struct qemu_phy *phy, uint16_t id1, uint16_t id2)
{
phy->regs[PHY_CTRL] = 0x3100;
/* PHY Id. */
- phy->regs[PHY_ID1] = 0x0300;
- phy->regs[PHY_ID2] = 0xe400;
+ phy->regs[PHY_ID1] = id1;
+ phy->regs[PHY_ID2] = id2;
/* Autonegotiation advertisement reg. */
phy->regs[PHY_AUTONEG_ADV] = 0x01e1;
phy->link = 1;
- phy->read = tdk_read;
- phy->write = tdk_write;
+ phy->read = mdio_phy_read;
+ phy->write = mdio_phy_write;
}
void mdio_attach(struct qemu_mdio *bus, struct qemu_phy *phy, unsigned int addr)
@@ -88,7 +88,7 @@ struct qemu_mdio {
struct qemu_phy *devs[32];
};
-void tdk_init(struct qemu_phy *phy);
+void mdio_phy_init(struct qemu_phy *phy, uint16_t id1, uint16_t id2);
void mdio_attach(struct qemu_mdio *bus, struct qemu_phy *phy,
unsigned int addr);
uint16_t mdio_read_req(struct qemu_mdio *bus, uint8_t addr, uint8_t req);
@@ -677,7 +677,7 @@ static int xilinx_enet_init(SysBusDevice *dev)
object_get_typename(OBJECT(dev)), dev->qdev.id, s);
qemu_format_nic_info_str(&s->nic->nc, s->conf.macaddr.a);
- tdk_init(&s->TEMAC.phy);
+ mdio_phy_init(&s->TEMAC.phy, 0x0300, 0xe400);
mdio_attach(&s->TEMAC.mdio_bus, &s->TEMAC.phy, s->c_phyaddr);
s->TEMAC.parent = s;
There really isn't anything tdk-specific about tdk_init() other than the phy id registers. The function should instead be generalized for any phy, at least as far as the ID registers are concerned. For the most part the read/write behaviour should be very similar across PHYs. This patch renames tdk_{read,write,init}() to mdio_phy_*() so it can be used for any PHY. More work definitely needs to be done here to make it easy to override the default behaviour for specific PHYs, but this at least is a reasonable start. 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> Cc: Andreas Färber <afaerber@suse.de> Signed-off-by: Grant Likely <grant.likely@secretlab.ca> --- hw/etraxfs_eth.c | 2 +- hw/mdio.c | 14 +++++++------- hw/mdio.h | 2 +- hw/xilinx_axienet.c | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-)