Message ID | 1271997497-6896-3-git-send-email-afleming@freescale.com |
---|---|
State | RFC, archived |
Delegated to: | David Miller |
Headers | show |
On Thu, 2010-04-22 at 23:38 -0500, Andy Fleming wrote: > Now that we've added somewhat more complete MDIO 45 support to the PHY > Lib, convert the MDIO bitbang driver to use this new infrastructure. > > Signed-off-by: Andy Fleming <afleming@freescale.com> > --- > drivers/net/phy/mdio-bitbang.c | 23 +++++++++++------------ > 1 files changed, 11 insertions(+), 12 deletions(-) > > diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c > index 2f6f02e..4c0c89b 100644 > --- a/drivers/net/phy/mdio-bitbang.c > +++ b/drivers/net/phy/mdio-bitbang.c [...] > @@ -157,9 +154,10 @@ static int mdiobb_read(struct mii_bus *bus, int phy, int devad, int reg) > struct mdiobb_ctrl *ctrl = bus->priv; > int ret, i; > > - if (reg & MII_ADDR_C45) { > - reg = mdiobb_cmd_addr(ctrl, phy, reg); > - mdiobb_cmd(ctrl, MDIO_C45_READ, phy, reg); > + /* Clause 22 PHYs only use devad = 0, and Clause 45 only use nonzero */ > + if (devad) { > + mdiobb_cmd_addr(ctrl, phy, devad, reg); > + mdiobb_cmd(ctrl, MDIO_C45_READ, phy, devad); > } else > mdiobb_cmd(ctrl, MDIO_READ, phy, reg); > [...] I don't believe there's any protocol requirement in clause 45 that devad != 0 (although the address is not allocated). In the mdio module I played safe and defined MDIO_DEVAD_NONE == -1 to indicate a clause 22 request. Ben.
On Apr 23, 2010, at 5:22 AM, Ben Hutchings wrote: > On Thu, 2010-04-22 at 23:38 -0500, Andy Fleming wrote: >> Now that we've added somewhat more complete MDIO 45 support to the PHY >> Lib, convert the MDIO bitbang driver to use this new infrastructure. >> >> Signed-off-by: Andy Fleming <afleming@freescale.com> >> --- >> drivers/net/phy/mdio-bitbang.c | 23 +++++++++++------------ >> 1 files changed, 11 insertions(+), 12 deletions(-) >> >> diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c >> index 2f6f02e..4c0c89b 100644 >> --- a/drivers/net/phy/mdio-bitbang.c >> +++ b/drivers/net/phy/mdio-bitbang.c > [...] >> @@ -157,9 +154,10 @@ static int mdiobb_read(struct mii_bus *bus, int phy, int devad, int reg) >> struct mdiobb_ctrl *ctrl = bus->priv; >> int ret, i; >> >> - if (reg & MII_ADDR_C45) { >> - reg = mdiobb_cmd_addr(ctrl, phy, reg); >> - mdiobb_cmd(ctrl, MDIO_C45_READ, phy, reg); >> + /* Clause 22 PHYs only use devad = 0, and Clause 45 only use nonzero */ >> + if (devad) { >> + mdiobb_cmd_addr(ctrl, phy, devad, reg); >> + mdiobb_cmd(ctrl, MDIO_C45_READ, phy, devad); >> } else >> mdiobb_cmd(ctrl, MDIO_READ, phy, reg); >> > [...] > > I don't believe there's any protocol requirement in clause 45 that > devad != 0 (although the address is not allocated). In the mdio module > I played safe and defined MDIO_DEVAD_NONE == -1 to indicate a clause 22 > request. Yeah, best to play it safe. I'm also realizing that the bus probing code has the implicit assumption that the bus will either support clause 45 and therefore use device addresses, or will not support it, but if we support both on the same bus, the probe will not catch any clause 22 PHYs. I will fix. Also, thank you for your work on the mdio code! Andy Andy-- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c index 2f6f02e..4c0c89b 100644 --- a/drivers/net/phy/mdio-bitbang.c +++ b/drivers/net/phy/mdio-bitbang.c @@ -134,11 +134,10 @@ static void mdiobb_cmd(struct mdiobb_ctrl *ctrl, int op, u8 phy, u8 reg) MII_ADDR_C45 into the address. Theoretically clause 45 and normal devices can exist on the same bus. Normal devices should ignore the MDIO_ADDR phase. */ -static int mdiobb_cmd_addr(struct mdiobb_ctrl *ctrl, int phy, u32 addr) +static void mdiobb_cmd_addr(struct mdiobb_ctrl *ctrl, int phy, int devad, + int reg) { - unsigned int dev_addr = (addr >> 16) & 0x1F; - unsigned int reg = addr & 0xFFFF; - mdiobb_cmd(ctrl, MDIO_C45_ADDR, phy, dev_addr); + mdiobb_cmd(ctrl, MDIO_C45_ADDR, phy, devad); /* send the turnaround (10) */ mdiobb_send_bit(ctrl, 1); @@ -148,8 +147,6 @@ static int mdiobb_cmd_addr(struct mdiobb_ctrl *ctrl, int phy, u32 addr) ctrl->ops->set_mdio_dir(ctrl, 0); mdiobb_get_bit(ctrl); - - return dev_addr; } static int mdiobb_read(struct mii_bus *bus, int phy, int devad, int reg) @@ -157,9 +154,10 @@ static int mdiobb_read(struct mii_bus *bus, int phy, int devad, int reg) struct mdiobb_ctrl *ctrl = bus->priv; int ret, i; - if (reg & MII_ADDR_C45) { - reg = mdiobb_cmd_addr(ctrl, phy, reg); - mdiobb_cmd(ctrl, MDIO_C45_READ, phy, reg); + /* Clause 22 PHYs only use devad = 0, and Clause 45 only use nonzero */ + if (devad) { + mdiobb_cmd_addr(ctrl, phy, devad, reg); + mdiobb_cmd(ctrl, MDIO_C45_READ, phy, devad); } else mdiobb_cmd(ctrl, MDIO_READ, phy, reg); @@ -186,9 +184,10 @@ static int mdiobb_write(struct mii_bus *bus, int phy, int devad, int reg, { struct mdiobb_ctrl *ctrl = bus->priv; - if (reg & MII_ADDR_C45) { - reg = mdiobb_cmd_addr(ctrl, phy, reg); - mdiobb_cmd(ctrl, MDIO_C45_WRITE, phy, reg); + /* Clause 22 PHYs only use devad = 0, and Clause 45 only use nonzero */ + if (devad) { + mdiobb_cmd_addr(ctrl, phy, devad, reg); + mdiobb_cmd(ctrl, MDIO_C45_WRITE, phy, devad); } else mdiobb_cmd(ctrl, MDIO_WRITE, phy, reg);
Now that we've added somewhat more complete MDIO 45 support to the PHY Lib, convert the MDIO bitbang driver to use this new infrastructure. Signed-off-by: Andy Fleming <afleming@freescale.com> --- drivers/net/phy/mdio-bitbang.c | 23 +++++++++++------------ 1 files changed, 11 insertions(+), 12 deletions(-)