phylib: Add support for MDIO clause 45
Subsystems (7)
v2 cover phylib: Add support for MDIO clause 45
MDIO Clause 45 adds a new argument for accessing PHY registers, so that you need the PHY address, the "device" address, and the register address (which can now be up to 65,535). It's best if, moving forward we add this new device address argument to the MDIO read/write functions, which means all of the current bus drivers need to be modified.
I opted not to modify the phy read/write functions mostly because all of the existing code which calls those functions is correct as-is, and any code which accesses the new 10G PHYs must do so in a fashion quite distinct from that of accessing older PHYs (the registers are layed out differently, and the initialization sequences are also quite different).
However, the MDIO buses are technically allowed to use both access mechanisms on the same bus, so there's an advantage to adding support to all of the current implementations.
Changes in v2:
Instead of using device address "0" to indicate a Clause 22 transaction, we use Ben's suggestion of using MDIO_DEVAD_NONE. Also, modify the PHY identification code to allow Clauses 22 and 45 to coexist on the same bus.
Andy Fleming (2):
phylib: Convert MDIO and PHY Lib drivers to support 10G
phylib: Convert MDIO bitbang to new MDIO 45 format
Documentation/networking/phy.txt | 13 +- arch/powerpc/platforms/pasemi/gpio_mdio.c | 6 +- drivers/net/arm/ixp4xx_eth.c | 7 +- drivers/net/au1000_eth.c | 7 +- drivers/net/bcm63xx_enet.c | 4 +- drivers/net/bfin_mac.c | 7 +- drivers/net/cpmac.c | 4 +- drivers/net/davinci_emac.c | 5 +- drivers/net/dnet.c | 7 +- drivers/net/ethoc.c | 5 +- drivers/net/fec.c | 7 +- drivers/net/fec_mpc52xx_phy.c | 7 +- drivers/net/fs_enet/mii-fec.c | 6 +- drivers/net/fsl_pq_mdio.c | 13 +- drivers/net/fsl_pq_mdio.h | 11 +- drivers/net/greth.c | 5 +- drivers/net/ll_temac_mdio.c | 5 +- drivers/net/macb.c | 7 +- drivers/net/mv643xx_eth.c | 5 +- drivers/net/phy/fixed.c | 5 +- drivers/net/phy/icplus.c | 15 ++- drivers/net/phy/mdio-bitbang.c | 34 +++--- drivers/net/phy/mdio-octeon.c | 5 +- drivers/net/phy/mdio_bus.c | 8 +- drivers/net/phy/phy_device.c | 170 ++++++++++++++++++++++++++--- drivers/net/s6gmac.c | 5 +- drivers/net/sb1250-mac.c | 14 ++- drivers/net/smsc911x.c | 19 ++-- drivers/net/smsc9420.c | 9 +- drivers/net/stmmac/stmmac_mdio.c | 9 +- drivers/net/tc35815.c | 5 +- drivers/net/tg3.c | 5 +- drivers/net/xilinx_emaclite.c | 9 +- include/linux/phy.h | 57 ++++++++-- 34 files changed, 358 insertions(+), 142 deletions(-)
PATCH v2 1/2 phylib: Convert MDIO and PHY Lib drivers to support 10G
10G MDIO is a totally different protocol (clause 45 of 802.3). Supporting this new protocol requires a couple of changes:
* Add a new parameter to the mdiobus_read functions to specify the "device address" inside the PHY.
* Add a phy45_read command which takes advantage of that new parameter
* Add a generic PHY driver for 10G PHYs
* Convert all of the existing drivers to use the new format
--- Documentation/networking/phy.txt | 13 +- arch/powerpc/platforms/pasemi/gpio_mdio.c | 6 +- drivers/net/arm/ixp4xx_eth.c | 7 +- drivers/net/au1000_eth.c | 7 +- drivers/net/bcm63xx_enet.c | 4 +- drivers/net/bfin_mac.c | 7 +- drivers/net/cpmac.c | 4 +- drivers/net/davinci_emac.c | 5 +- drivers/net/dnet.c | 7 +- drivers/net/ethoc.c | 5 +- drivers/net/fec.c | 7 +- drivers/net/fec_mpc52xx_phy.c | 7 +- drivers/net/fs_enet/mii-fec.c | 6 +- drivers/net/fsl_pq_mdio.c | 13 +- drivers/net/fsl_pq_mdio.h | 11 +- drivers/net/greth.c | 5 +- drivers/net/ll_temac_mdio.c | 5 +- drivers/net/macb.c | 7 +- drivers/net/mv643xx_eth.c | 5 +- drivers/net/phy/fixed.c | 5 +- drivers/net/phy/icplus.c | 15 ++- drivers/net/phy/mdio-bitbang.c | 5 +- drivers/net/phy/mdio-octeon.c | 5 +- drivers/net/phy/mdio_bus.c | 8 +- drivers/net/phy/phy_device.c | 170 ++++++++++++++++++++++++++--- drivers/net/s6gmac.c | 5 +- drivers/net/sb1250-mac.c | 14 ++- drivers/net/smsc911x.c | 19 ++-- drivers/net/smsc9420.c | 9 +- drivers/net/stmmac/stmmac_mdio.c | 9 +- drivers/net/tc35815.c | 5 +- drivers/net/tg3.c | 5 +- drivers/net/xilinx_emaclite.c | 9 +- include/linux/phy.h | 57 ++++++++-- 34 files changed, 343 insertions(+), 128 deletions(-)
Documentation/networking/phy.txt +8 -7
@@ -40,13 +40,14 @@ The MDIO bus 1) read and write functions must be implemented. Their prototypes are: - int write(struct mii_bus *bus, int mii_id, int regnum, u16 value); - int read(struct mii_bus *bus, int mii_id, int regnum); - - mii_id is the address on the bus for the PHY, and regnum is the register - number. These functions are guaranteed not to be called from interrupt - time, so it is safe for them to block, waiting for an interrupt to signal - the operation is complete + int write(struct mii_bus *bus, int addr, int devad, u16 regnum, + u16 value); + int read(struct mii_bus *bus, int addr, int devad, u16 regnum); + + addr is the address on the bus for the PHY, devad is the address of the + internal device, and regnum is the register number. These functions are + guaranteed not to be called from interrupt time, so it is safe for them + to block, waiting for an interrupt to signal the operation is complete 2) A reset function is necessary. This is used to return the bus to an initialized state.
arch/powerpc/platforms/pasemi/gpio_mdio.c +4 -2
@@ -124,7 +124,8 @@ static void bitbang_pre(struct mii_bus *bus, int read, u8 addr, u8 reg) } } -static int gpio_mdio_read (struct mii_bus *bus,int phy_id,int location) +static int gpio_mdio_read (struct mii_bus *bus,int phy_id,int devad, +int location) {u16 rdreg;int ret, i;
@@ -163,7 +164,8 @@ static int gpio_mdio_read(struct mii_bus *bus, int phy_id, int location)return ret; } -static int gpio_mdio_write (struct mii_bus *bus,int phy_id,int location,u16 val) +static int gpio_mdio_write (struct mii_bus *bus,int phy_id,int devad, +int location,u16 val) {int i;
drivers/net/arm/ixp4xx_eth.c +4 -3
@@ -298,7 +298,8 @@ static int ixp4xx_mdio_cmd(struct mii_bus *bus, int phy_id, int location, ((__raw_readl (&mdio_regs->mdio_status[1 ]) &0xFF ) <<8 ); } -static int ixp4xx_mdio_read (struct mii_bus *bus,int phy_id,int location) +static int ixp4xx_mdio_read (struct mii_bus *bus,int phy_id,int devad, +int location) {unsigned long flags;int ret;
@@ -313,8 +314,8 @@ static int ixp4xx_mdio_read(struct mii_bus *bus, int phy_id, int location)return ret; } -static int ixp4xx_mdio_write (struct mii_bus *bus,int phy_id,int location, -u16 val) +static int ixp4xx_mdio_write (struct mii_bus *bus,int phy_id,int devad, +int location,u16 val) {unsigned long flags;int ret;
drivers/net/au1000_eth.c +4 -3
@@ -232,7 +232,8 @@ static void au1000_mdio_write(struct net_device *dev, int phy_addr, *mii_control_reg = mii_control; } -static int au1000_mdiobus_read (struct mii_bus *bus,int phy_addr,int regnum) +static int au1000_mdiobus_read (struct mii_bus *bus,int phy_addr,int devad, +int regnum) {/* WARNING: bus->phy_map[phy_addr].attached_dev == dev does * _NOT_ hold (e.g. when PHY is accessed through other MAC's MII bus) */
@@ -243,8 +244,8 @@ static int au1000_mdiobus_read(struct mii_bus *bus, int phy_addr, int regnum)return au1000_mdio_read (dev, phy_addr, regnum); } -static int au1000_mdiobus_write (struct mii_bus *bus,int phy_addr,int regnum, -u16 value) +static int au1000_mdiobus_write (struct mii_bus *bus,int phy_addr,int devad, +int regnum,u16 value) {struct net_device *const dev = bus->priv;
drivers/net/bcm63xx_enet.c +2 -2
@@ -139,7 +139,7 @@ static int bcm_enet_mdio_write(struct bcm_enet_priv *priv, int mii_id,* MII read callback from phylib */ static int bcm_enet_mdio_read_phylib (struct mii_bus *bus,int mii_id, -int regnum) +int devad,int regnum) {return bcm_enet_mdio_read (bus->priv, mii_id, regnum); }
@@ -148,7 +148,7 @@ static int bcm_enet_mdio_read_phylib(struct mii_bus *bus, int mii_id,* MII write callback from phylib */ static int bcm_enet_mdio_write_phylib (struct mii_bus *bus,int mii_id, -int regnum,u16 value) +int devad,int regnum,u16 value) {return bcm_enet_mdio_write (bus->priv, mii_id, regnum, value); }
drivers/net/bfin_mac.c +4 -3
@@ -275,7 +275,8 @@ static int bfin_mdio_poll(void) }/* Read an off-chip register in a PHY through the MDC/MDIO port */ -static int bfin_mdiobus_read (struct mii_bus *bus,int phy_addr,int regnum) +static int bfin_mdiobus_read (struct mii_bus *bus,int phy_addr, +int devad,int regnum) {int ret;
@@ -296,8 +297,8 @@ static int bfin_mdiobus_read(struct mii_bus *bus, int phy_addr, int regnum) }/* Write an off-chip register in a PHY through the MDC/MDIO port */ -static int bfin_mdiobus_write (struct mii_bus *bus,int phy_addr,int regnum, -u16 value) +static int bfin_mdiobus_write (struct mii_bus *bus,int phy_addr,int devad, +int regnum,u16 value) {int ret;
drivers/net/cpmac.c +2 -2
@@ -271,7 +271,7 @@ static void cpmac_dump_skb(struct net_device *dev, struct sk_buff *skb)printk ("\n" ); } -static int cpmac_mdio_read (struct mii_bus *bus,int phy_id,int reg) +static int cpmac_mdio_read (struct mii_bus *bus,int phy_id,int devad,int reg) {u32 val;
@@ -285,7 +285,7 @@ static int cpmac_mdio_read(struct mii_bus *bus, int phy_id, int reg) }static int cpmac_mdio_write (struct mii_bus *bus,int phy_id, -int reg,u16 val) +int devad,int reg,u16 val) {while (cpmac_read (bus->priv,CPMAC_MDIO_ACCESS (0 )) &MDIO_BUSY )cpu_relax ();
drivers/net/davinci_emac.c +3 -2
@@ -2240,7 +2240,8 @@ void emac_poll_controller(struct net_device *ndev)while ((emac_mdio_read ((MDIO_USERACCESS (0 ))) &\MDIO_USERACCESS_GO ) !=0 ) -static int emac_mii_read(struct mii_bus *bus, int phy_id, int phy_reg) +static int emac_mii_read(struct mii_bus *bus, int phy_id, int devad, +int phy_reg) {unsigned int phy_data =0 ;unsigned int phy_control;
@@ -2263,7 +2264,7 @@ static int emac_mii_read(struct mii_bus *bus, int phy_id, int phy_reg) }static int emac_mii_write (struct mii_bus *bus,int phy_id, -int phy_reg,u16 phy_data) +int devad,int phy_reg,u16 phy_data) {unsigned int control;
drivers/net/dnet.c +4 -3
@@ -99,7 +99,8 @@ static void __devinit dnet_get_hwaddr(struct dnet *bp)memcpy (bp->dev->dev_addr, addr,sizeof (addr)); } -static int dnet_mdio_read (struct mii_bus *bus,int mii_id,int regnum) +static int dnet_mdio_read (struct mii_bus *bus,int mii_id,int devad, +int regnum) {struct dnet *bp = bus->priv;u16 value;
@@ -131,8 +132,8 @@ static int dnet_mdio_read(struct mii_bus *bus, int mii_id, int regnum)return value; } -static int dnet_mdio_write (struct mii_bus *bus,int mii_id,int regnum, -u16 value) +static int dnet_mdio_write (struct mii_bus *bus,int mii_id,int devad, +int regnum,u16 value) {struct dnet *bp = bus->priv;u16 tmp;
drivers/net/ethoc.c +3 -2
@@ -564,7 +564,7 @@ static int ethoc_poll(struct napi_struct *napi, int budget)return work_done; } -static int ethoc_mdio_read (struct mii_bus *bus,int phy,int reg) +static int ethoc_mdio_read (struct mii_bus *bus,int phy,int devad,int reg) {unsigned long timeout = jiffies +ETHOC_MII_TIMEOUT ;struct ethoc *priv = bus->priv;
@@ -587,7 +587,8 @@ static int ethoc_mdio_read(struct mii_bus *bus, int phy, int reg)return -EBUSY ; } -static int ethoc_mdio_write (struct mii_bus *bus,int phy,int reg,u16 val) +static int ethoc_mdio_write (struct mii_bus *bus,int phy,int devad, +int reg,u16 val) {unsigned long timeout = jiffies +ETHOC_MII_TIMEOUT ;struct ethoc *priv = bus->priv;
drivers/net/fec.c +4 -3
@@ -609,7 +609,8 @@ spin_unlock:/* * NOTE: a MII transaction is during around 25 us, so polling it... */ -static int fec_enet_mdio_read (struct mii_bus *bus,int mii_id,int regnum) +static int fec_enet_mdio_read (struct mii_bus *bus,int mii_id,int devad, +int regnum) {struct fec_enet_private *fep = bus->priv;int timeout =FEC_MII_TIMEOUT ;
@@ -638,8 +639,8 @@ static int fec_enet_mdio_read(struct mii_bus *bus, int mii_id, int regnum)return FEC_MMFR_DATA (readl (fep->hwp +FEC_MII_DATA )); } -static int fec_enet_mdio_write (struct mii_bus *bus,int mii_id,int regnum, -u16 value) +static int fec_enet_mdio_write (struct mii_bus *bus,int mii_id,int devad, +int regnum,u16 value) {struct fec_enet_private *fep = bus->priv;int timeout =FEC_MII_TIMEOUT ;
drivers/net/fec_mpc52xx_phy.c +4 -3
@@ -50,13 +50,14 @@ static int mpc52xx_fec_mdio_transfer(struct mii_bus *bus, int phy_id, in_be32(&priv->regs->mii_data) & FEC_MII_DATA_DATAMSK : 0; } -static int mpc52xx_fec_mdio_read (struct mii_bus *bus,int phy_id,int reg) +static int mpc52xx_fec_mdio_read (struct mii_bus *bus,int phy_id,int devad, +int reg) {return mpc52xx_fec_mdio_transfer (bus, phy_id, reg,FEC_MII_READ_FRAME ); } -static int mpc52xx_fec_mdio_write (struct mii_bus *bus,int phy_id,int reg, -u16 data) +static int mpc52xx_fec_mdio_write (struct mii_bus *bus,int phy_id,int devad, +int reg,u16 data) {return mpc52xx_fec_mdio_transfer (bus, phy_id, reg, data |FEC_MII_WRITE_FRAME );
drivers/net/fs_enet/mii-fec.c +4 -2
@@ -49,7 +49,8 @@#define FEC_MII_LOOPS 10000 -static int fs_enet_fec_mii_read (struct mii_bus *bus ,int phy_id,int location) +static int fs_enet_fec_mii_read (struct mii_bus *bus ,int phy_id,int devad, +int location) {struct fec_info * fec = bus->priv;struct fec __iomem *fecp = fec->fecp;
@@ -72,7 +73,8 @@ static int fs_enet_fec_mii_read(struct mii_bus *bus , int phy_id, int location)return ret; } -static int fs_enet_fec_mii_write (struct mii_bus *bus,int phy_id,int location,u16 val) +static int fs_enet_fec_mii_write (struct mii_bus *bus,int phy_id,int devad, +int location,u16 val) {struct fec_info * fec = bus->priv;struct fec __iomem *fecp = fec->fecp;
drivers/net/fsl_pq_mdio.c +7 -6
@@ -61,7 +61,7 @@ struct fsl_pq_mdio_priv {* controlling the external PHYs, for example. */ int fsl_pq_local_mdio_write (struct fsl_pq_mdio __iomem *regs,int mii_id, -int regnum,u16 value) +int regnum,u16 value) {/* Set the PHY address and the register address we want to write */ out_be32 (®s->miimadd, (mii_id <<8 ) | regnum);
@@ -86,8 +86,8 @@ int fsl_pq_local_mdio_write(struct fsl_pq_mdio __iomem *regs, int mii_id,* and are always tied to the local mdio pins, which may not be the * same as system mdio bus, used for controlling the external PHYs, for eg. */ -int fsl_pq_local_mdio_read (struct fsl_pq_mdio __iomem *regs, -int mii_id,int regnum) +int fsl_pq_local_mdio_read (struct fsl_pq_mdio __iomem *regs,int mii_id, +int regnum) {u16 value;
@@ -119,7 +119,8 @@ static struct fsl_pq_mdio __iomem *fsl_pq_mdio_get_regs(struct mii_bus *bus)* Write value to the PHY at mii_id at register regnum, * on the bus, waiting until the write is done before returning. */ -int fsl_pq_mdio_write (struct mii_bus *bus,int mii_id,int regnum,u16 value) +int fsl_pq_mdio_write (struct mii_bus *bus,int mii_id,int devad,int regnum, +u16 value) {struct fsl_pq_mdio __iomem *regs =fsl_pq_mdio_get_regs (bus);
@@ -131,7 +132,7 @@ int fsl_pq_mdio_write(struct mii_bus *bus, int mii_id, int regnum, u16 value)* Read the bus for PHY at addr mii_id, register regnum, and * return the value. Clears miimcom first. */ -int fsl_pq_mdio_read (struct mii_bus *bus,int mii_id,int regnum) +int fsl_pq_mdio_read (struct mii_bus *bus,int mii_id,int devad,int regnum) {struct fsl_pq_mdio __iomem *regs =fsl_pq_mdio_get_regs (bus);
@@ -190,7 +191,7 @@ static int fsl_pq_mdio_find_free(struct mii_bus *new_bus)for (i =PHY_MAX_ADDR ; i >0 ; i--) {u32 phy_id; -if (get_phy_id (new_bus, i, &phy_id)) +if (get_phy_id (new_bus, i,MDIO_DEVAD_NONE , &phy_id))return -1 ;if (phy_id ==0xffffffff )
drivers/net/fsl_pq_mdio.h +7 -4
@@ -41,11 +41,14 @@ struct fsl_pq_mdio {u8 res4[2728 ]; } __attribute__ ((packed)); -int fsl_pq_mdio_read (struct mii_bus *bus,int mii_id,int regnum); -int fsl_pq_mdio_write (struct mii_bus *bus,int mii_id,int regnum,u16 value); + +int fsl_pq_mdio_read (struct mii_bus *bus,int mii_id,int devad,int regnum); +int fsl_pq_mdio_write (struct mii_bus *bus,int mii_id,int devad,int regnum, +u16 value);int fsl_pq_local_mdio_write (struct fsl_pq_mdio __iomem *regs,int mii_id, -int regnum,u16 value); -int fsl_pq_local_mdio_read (struct fsl_pq_mdio __iomem *regs,int mii_id,int regnum); +int regnum,u16 value); +int fsl_pq_local_mdio_read (struct fsl_pq_mdio __iomem *regs,int mii_id, +int regnum);int __init fsl_pq_mdio_init (void );void fsl_pq_mdio_exit (void );void fsl_pq_mdio_bus_name (char *name,struct device_node *np);
drivers/net/greth.c +3 -2
@@ -1169,7 +1169,7 @@ static inline int wait_for_mdio(struct greth_private *greth)return 1 ; } -static int greth_mdio_read (struct mii_bus *bus,int phy,int reg) +static int greth_mdio_read (struct mii_bus *bus,int phy,int devad,int reg) {struct greth_private *greth = bus->priv;int data;
@@ -1191,7 +1191,8 @@ static int greth_mdio_read(struct mii_bus *bus, int phy, int reg) } } -static int greth_mdio_write (struct mii_bus *bus,int phy,int reg,u16 val) +static int greth_mdio_write (struct mii_bus *bus,int phy,int devad,int reg, +u16 val) {struct greth_private *greth = bus->priv;
drivers/net/ll_temac_mdio.c +3 -2
@@ -18,7 +18,7 @@/* --------------------------------------------------------------------- * MDIO Bus functions */ -static int temac_mdio_read (struct mii_bus *bus,int phy_id,int reg) +static int temac_mdio_read (struct mii_bus *bus,int phy_id,int devad,int reg) {struct temac_local *lp = bus->priv;u32 rc;
@@ -37,7 +37,8 @@ static int temac_mdio_read(struct mii_bus *bus, int phy_id, int reg)return rc; } -static int temac_mdio_write (struct mii_bus *bus,int phy_id,int reg,u16 val) +static int temac_mdio_write (struct mii_bus *bus,int phy_id,int devad,int reg, +u16 val) {struct temac_local *lp = bus->priv;
drivers/net/macb.c +4 -3
@@ -88,7 +88,8 @@ static void __init macb_get_hwaddr(struct macb *bp) } } -static int macb_mdio_read (struct mii_bus *bus,int mii_id,int regnum) +static int macb_mdio_read (struct mii_bus *bus,int mii_id,int devad, +int regnum) {struct macb *bp = bus->priv;int value;
@@ -108,8 +109,8 @@ static int macb_mdio_read(struct mii_bus *bus, int mii_id, int regnum)return value; } -static int macb_mdio_write (struct mii_bus *bus,int mii_id,int regnum, -u16 value) +static int macb_mdio_write (struct mii_bus *bus,int mii_id,int devad, +int regnum,u16 value) {struct macb *bp = bus->priv;
drivers/net/mv643xx_eth.c +3 -2
@@ -1111,7 +1111,7 @@ static int smi_wait_ready(struct mv643xx_eth_shared_private *msp)return 0 ; } -static int smi_bus_read (struct mii_bus *bus,int addr,int reg) +static int smi_bus_read (struct mii_bus *bus,int addr,int devad,int reg) {struct mv643xx_eth_shared_private *msp = bus->priv;void __iomem *smi_reg = msp->base +SMI_REG ;
@@ -1138,7 +1138,8 @@ static int smi_bus_read(struct mii_bus *bus, int addr, int reg)return ret &0xffff ; } -static int smi_bus_write (struct mii_bus *bus,int addr,int reg,u16 val) +static int smi_bus_write (struct mii_bus *bus,int addr,int devad,int reg, +u16 val) {struct mv643xx_eth_shared_private *msp = bus->priv;void __iomem *smi_reg = msp->base +SMI_REG ;
drivers/net/phy/fixed.c +3 -2
@@ -115,7 +115,8 @@ static int fixed_phy_update_regs(struct fixed_phy *fp)return 0 ; } -static int fixed_mdio_read (struct mii_bus *bus,int phy_id,int reg_num) +static int fixed_mdio_read (struct mii_bus *bus,int phy_id,int devad, +int reg_num) {struct fixed_mdio_bus *fmb = bus->priv;struct fixed_phy *fp;
@@ -139,7 +140,7 @@ static int fixed_mdio_read(struct mii_bus *bus, int phy_id, int reg_num) }static int fixed_mdio_write (struct mii_bus *bus,int phy_id,int reg_num, -u16 val) +int devad,u16 val) {return 0 ; }
drivers/net/phy/icplus.c +10 -5
@@ -42,36 +42,41 @@ static int ip175c_config_init(struct phy_device *phydev)if (full_reset_performed ==0 ) {/* master reset */ - err = phydev->bus->write (phydev->bus,30 ,0 ,0x175c ); + err = phydev->bus->write (phydev->bus,30 ,MDIO_DEVAD_NONE ,0 , +0x175c );if (err <0 )return err;/* ensure no bus delays overlap reset period */ - err = phydev->bus->read (phydev->bus,30 ,0 ); + err = phydev->bus->read (phydev->bus,30 ,MDIO_DEVAD_NONE ,0 );/* data sheet specifies reset period is 2 msec */ mdelay (2 );/* enable IP175C mode */ - err = phydev->bus->write (phydev->bus,29 ,31 ,0x175c ); + err = phydev->bus->write (phydev->bus,29 ,MDIO_DEVAD_NONE ,31 , +0x175c );if (err <0 )return err;/* Set MII0 speed and duplex (in PHY mode) */ - err = phydev->bus->write (phydev->bus,29 ,22 ,0x420 ); + err = phydev->bus->write (phydev->bus,29 ,MDIO_DEVAD_NONE ,22 , +0x420 );if (err <0 )return err;/* reset switch ports */ for (i =0 ; i <5 ; i++) { err = phydev->bus->write (phydev->bus, i, +MDIO_DEVAD_NONE ,MII_BMCR ,BMCR_RESET );if (err <0 )return err; }for (i =0 ; i <5 ; i++) - err = phydev->bus->read (phydev->bus, i,MII_BMCR ); + err = phydev->bus->read (phydev->bus, i,MDIO_DEVAD_NONE , +MII_BMCR );mdelay (2 );
drivers/net/phy/mdio-bitbang.c +3 -2
@@ -152,7 +152,7 @@ static int mdiobb_cmd_addr(struct mdiobb_ctrl *ctrl, int phy, u32 addr)return dev_addr; } -static int mdiobb_read (struct mii_bus *bus,int phy,int reg) +static int mdiobb_read (struct mii_bus *bus,int phy,int devad,int reg) {struct mdiobb_ctrl *ctrl = bus->priv;int ret, i;
@@ -181,7 +181,8 @@ static int mdiobb_read(struct mii_bus *bus, int phy, int reg)return ret; } -static int mdiobb_write (struct mii_bus *bus,int phy,int reg,u16 val) +static int mdiobb_write (struct mii_bus *bus,int phy,int devad,int reg, +u16 val) {struct mdiobb_ctrl *ctrl = bus->priv;
drivers/net/phy/mdio-octeon.c +3 -2
@@ -24,7 +24,8 @@ struct octeon_mdiobus {int phy_irq[PHY_MAX_ADDR ]; }; -static int octeon_mdiobus_read (struct mii_bus *bus,int phy_id,int regnum) +static int octeon_mdiobus_read (struct mii_bus *bus,int phy_id,int devad, +int regnum) {struct octeon_mdiobus *p = bus->priv;union cvmx_smix_cmd smi_cmd;
@@ -52,7 +53,7 @@ static int octeon_mdiobus_read(struct mii_bus *bus, int phy_id, int regnum)return -EIO ; } -static int octeon_mdiobus_write (struct mii_bus *bus,int phy_id, +static int octeon_mdiobus_write(struct mii_bus *bus, int phy_id, int devad int regnum, u16 val) {struct octeon_mdiobus *p = bus->priv;
drivers/net/phy/mdio_bus.c +4 -4
@@ -208,14 +208,14 @@ EXPORT_SYMBOL(mdiobus_scan);* because the bus read/write functions may wait for an interrupt * to conclude the operation. */ -int mdiobus_read (struct mii_bus *bus,int addr,u32 regnum) +int mdiobus_read (struct mii_bus *bus,int addr,int devad,u16 regnum) {int retval;BUG_ON (in_interrupt ());mutex_lock (&bus->mdio_lock); - retval = bus->read (bus, addr, regnum); + retval = bus->read (bus, addr, devad, regnum);mutex_unlock (&bus->mdio_lock);return retval;
@@ -233,14 +233,14 @@ EXPORT_SYMBOL(mdiobus_read);* because the bus read/write functions may wait for an interrupt * to conclude the operation. */ -int mdiobus_write (struct mii_bus *bus,int addr,u32 regnum,u16 val) +int mdiobus_write (struct mii_bus *bus,int addr,int devad,u16 regnum,u16 val) {int err;BUG_ON (in_interrupt ());mutex_lock (&bus->mdio_lock); - err = bus->write (bus, addr, regnum, val); + err = bus->write (bus, addr, devad, regnum, val);mutex_unlock (&bus->mdio_lock);return err;
drivers/net/phy/phy_device.c +153 -17
304 lines not on this page · raw message
drivers/net/s6gmac.c +3 -2
@@ -661,7 +661,7 @@ static int s6mii_busy(struct s6gmac *pd, int tmo)return 0 ; } -static int s6mii_read (struct mii_bus *bus,int phy_addr,int regnum) +static int s6mii_read (struct mii_bus *bus,int phy_addr,int devad,int regnum) {struct s6gmac *pd = bus->priv;s6mii_enable (pd);
@@ -677,7 +677,8 @@ static int s6mii_read(struct mii_bus *bus, int phy_addr, int regnum)return (u16 )readl (pd->reg +S6_GMAC_MACMIISTAT ); } -static int s6mii_write (struct mii_bus *bus,int phy_addr,int regnum,u16 value) +static int s6mii_write (struct mii_bus *bus,int phy_addr,int devad, +int regnum,u16 value) {struct s6gmac *pd = bus->priv;s6mii_enable (pd);
drivers/net/sb1250-mac.c +8 -6
@@ -322,9 +322,10 @@ static int sbmac_mii_probe(struct net_device *dev);static void sbmac_mii_sync (void __iomem *sbm_mdio);static void sbmac_mii_senddata (void __iomem *sbm_mdio,unsigned int data,int bitcnt); -static int sbmac_mii_read (struct mii_bus *bus,int phyaddr,int regidx); -static int sbmac_mii_write (struct mii_bus *bus,int phyaddr,int regidx, -u16 val); +static int sbmac_mii_read (struct mii_bus *bus,int phyaddr,int devad, +int regidx); +static int sbmac_mii_write (struct mii_bus *bus,int phyaddr,int devad, +int regidx,u16 val);/**********************************************************************
@@ -434,7 +435,8 @@ static void sbmac_mii_senddata(void __iomem *sbm_mdio, unsigned int data,* value read, or 0xffff if an error occurred. ********************************************************************* */ -static int sbmac_mii_read (struct mii_bus *bus,int phyaddr,int regidx) +static int sbmac_mii_read (struct mii_bus *bus,int phyaddr,int devad, +int regidx) {struct sbmac_softc *sc = (struct sbmac_softc *)bus->priv;void __iomem *sbm_mdio = sc->sbm_mdio;
@@ -527,8 +529,8 @@ static int sbmac_mii_read(struct mii_bus *bus, int phyaddr, int regidx)* 0 for success ********************************************************************* */ -static int sbmac_mii_write (struct mii_bus *bus,int phyaddr,int regidx, -u16 regval) +static int sbmac_mii_write (struct mii_bus *bus,int phyaddr,int devad, +int regidx,u16 regval) {struct sbmac_softc *sc = (struct sbmac_softc *)bus->priv;void __iomem *sbm_mdio = sc->sbm_mdio;
drivers/net/smsc911x.c +9 -10
@@ -302,7 +302,8 @@ static void smsc911x_mac_write(struct smsc911x_data *pdata, }/* Get a phy register */ -static int smsc911x_mii_read (struct mii_bus *bus,int phyaddr,int regidx) +static int smsc911x_mii_read (struct mii_bus *bus,int phyaddr,int devad, +int regidx) {struct smsc911x_data *pdata = (struct smsc911x_data *)bus->priv;unsigned long flags;
@@ -339,8 +340,8 @@ out: }/* Set a phy register */ -static int smsc911x_mii_write (struct mii_bus *bus,int phyaddr,int regidx, -u16 val) +static int smsc911x_mii_write (struct mii_bus *bus,int phyaddr,int devad, +int regidx,u16 val) {struct smsc911x_data *pdata = (struct smsc911x_data *)bus->priv;unsigned long flags;
@@ -570,11 +571,10 @@ static int smsc911x_phy_reset(struct smsc911x_data *pdata)BUG_ON (!phy_dev->bus);SMSC_TRACE (HW ,"Performing PHY BCR Reset" ); -smsc911x_mii_write (phy_dev->bus, phy_dev->addr,MII_BMCR ,BMCR_RESET ); +phy_write (phy_dev,MII_BMCR ,BMCR_RESET );do {msleep (1 ); - temp =smsc911x_mii_read (phy_dev->bus, phy_dev->addr, -MII_BMCR ); + temp =phy_read (phy_dev,MII_BMCR ); }while ((i--) && (temp &BMCR_RESET ));if (temp &BMCR_RESET ) {
@@ -622,8 +622,7 @@ static int smsc911x_phy_loopbacktest(struct net_device *dev)for (i =0 ; i <10 ; i++) {/* Set PHY to 10/FD, no ANEG, and loopback mode */ -smsc911x_mii_write (phy_dev->bus, phy_dev->addr,MII_BMCR , -BMCR_LOOPBACK |BMCR_FULLDPLX ); +phy_write (phy_dev,MII_BMCR ,BMCR_LOOPBACK |BMCR_FULLDPLX );/* Enable MAC tx/rx, FD */ spin_lock_irqsave (&pdata->mac_lock, flags);
@@ -651,7 +650,7 @@ static int smsc911x_phy_loopbacktest(struct net_device *dev)spin_unlock_irqrestore (&pdata->mac_lock, flags);/* Cancel PHY loopback mode */ -smsc911x_mii_write (phy_dev->bus, phy_dev->addr,MII_BMCR ,0 ); +phy_write (phy_dev,MII_BMCR ,0 );smsc911x_reg_write (pdata,TX_CFG ,0 );smsc911x_reg_write (pdata,RX_CFG ,0 );
@@ -1615,7 +1614,7 @@ smsc911x_ethtool_getregs(struct net_device *dev, struct ethtool_regs *regs, }for (i =0 ; i <=31 ; i++) - data[j++] =smsc911x_mii_read (phy_dev->bus, phy_dev->addr, i); + data[j++] =phy_read (phy_dev, i); }static void smsc911x_eeprom_enable_access (struct smsc911x_data *pdata)
drivers/net/smsc9420.c +5 -4
@@ -127,7 +127,8 @@ static inline void smsc9420_pci_flush_write(struct smsc9420_pdata *pd)smsc9420_reg_read (pd,ID_REV ); } -static int smsc9420_mii_read (struct mii_bus *bus,int phyaddr,int regidx) +static int smsc9420_mii_read (struct mii_bus *bus,int phyaddr,int devad, +int regidx) {struct smsc9420_pdata *pd = (struct smsc9420_pdata *)bus->priv;unsigned long flags;
@@ -164,8 +165,8 @@ out:return reg; } -static int smsc9420_mii_write (struct mii_bus *bus,int phyaddr,int regidx, -u16 val) +static int smsc9420_mii_write (struct mii_bus *bus,int phyaddr,int devad, +int regidx,u16 val) {struct smsc9420_pdata *pd = (struct smsc9420_pdata *)bus->priv;unsigned long flags;
@@ -328,7 +329,7 @@ smsc9420_ethtool_getregs(struct net_device *dev, struct ethtool_regs *regs,return ;for (i =0 ; i <=31 ; i++) - data[j++] =smsc9420_mii_read (phy_dev->bus, phy_dev->addr, i); + data[j++] =phy_read (phy_dev, i); }static void smsc9420_eeprom_enable_access (struct smsc9420_pdata *pd)
drivers/net/stmmac/stmmac_mdio.c +6 -3
@@ -37,13 +37,15 @@* stmmac_mdio_read * @bus: points to the mii_bus structure * @phyaddr: MII addr reg bits 15-11 +* @devad: unused * @phyreg: MII addr reg bits 10-6 * Description: it reads data from the MII register from within the phy device. * For the 7111 GMAC, we must set the bit 0 in the MII address register while * accessing the PHY registers. * Fortunately, it seems this has no drawback for the 7109 MAC. */ -static int stmmac_mdio_read (struct mii_bus *bus,int phyaddr,int phyreg) +static int stmmac_mdio_read (struct mii_bus *bus,int phyaddr,int devad, +int phyreg) {struct net_device *ndev = bus->priv;struct stmmac_priv *priv =netdev_priv (ndev);
@@ -70,12 +72,13 @@ static int stmmac_mdio_read(struct mii_bus *bus, int phyaddr, int phyreg)* stmmac_mdio_write * @bus: points to the mii_bus structure * @phyaddr: MII addr reg bits 15-11 +* @devad: unused * @phyreg: MII addr reg bits 10-6 * @phydata: phy data * Description: it writes the data into the MII register from within the device. */ -static int stmmac_mdio_write (struct mii_bus *bus,int phyaddr,int phyreg, -u16 phydata) +static int stmmac_mdio_write (struct mii_bus *bus,int phyaddr,int devad, +int phyreg,u16 phydata) {struct net_device *ndev = bus->priv;struct stmmac_priv *priv =netdev_priv (ndev);
drivers/net/tc35815.c +3 -2
@@ -500,7 +500,7 @@ static void panic_queues(struct net_device *dev);static void tc35815_restart_work (struct work_struct *work); -static int tc_mdio_read (struct mii_bus *bus,int mii_id,int regnum) +static int tc_mdio_read (struct mii_bus *bus,int mii_id,int devad,int regnum) {struct net_device *dev = bus->priv; struct tc35815_regs __iomem *tr =
@@ -517,7 +517,8 @@ static int tc_mdio_read(struct mii_bus *bus, int mii_id, int regnum)return tc_readl (&tr->MD_Data) &0xffff ; } -static int tc_mdio_write (struct mii_bus *bus,int mii_id,int regnum,u16 val) +static int tc_mdio_write (struct mii_bus *bus,int mii_id,int devad, +int regnum,u16 val) {struct net_device *dev = bus->priv; struct tc35815_regs __iomem *tr =
drivers/net/tg3.c +3 -2
@@ -936,7 +936,7 @@ static int tg3_bmcr_reset(struct tg3 *tp)return 0 ; } -static int tg3_mdio_read (struct mii_bus *bp,int mii_id,int reg) +static int tg3_mdio_read (struct mii_bus *bp,int mii_id,int devad,int reg) {struct tg3 *tp = bp->priv;u32 val;
@@ -951,7 +951,8 @@ static int tg3_mdio_read(struct mii_bus *bp, int mii_id, int reg)return val; } -static int tg3_mdio_write (struct mii_bus *bp,int mii_id,int reg,u16 val) +static int tg3_mdio_write (struct mii_bus *bp,int mii_id,int devad, +int reg,u16 val) {struct tg3 *tp = bp->priv;u32 ret =0 ;
drivers/net/xilinx_emaclite.c +6 -3
@@ -738,6 +738,7 @@ static int xemaclite_mdio_wait(struct net_local *lp)* xemaclite_mdio_read - Read from a given MII management register * @bus: the mii_bus struct * @phy_id: the phy address +* @devad: unused * @reg: register number to read from * * This function waits till the device is ready to accept a new MDIO
@@ -746,7 +747,8 @@ static int xemaclite_mdio_wait(struct net_local *lp)* * Return: Value read from the MII management register */ -static int xemaclite_mdio_read (struct mii_bus *bus,int phy_id,int reg) +static int xemaclite_mdio_read (struct mii_bus *bus,int phy_id,int devad, +int reg) {struct net_local *lp = bus->priv;u32 ctrl_reg;
@@ -782,14 +784,15 @@ static int xemaclite_mdio_read(struct mii_bus *bus, int phy_id, int reg)* xemaclite_mdio_write - Write to a given MII management register * @bus: the mii_bus struct * @phy_id: the phy address +* @devad: unused * @reg: register number to write to * @val: value to write to the register number specified by reg * * This fucntion waits till the device is ready to accept a new MDIO * request and then writes the val to the MDIO Write Data register. */ -static int xemaclite_mdio_write (struct mii_bus *bus,int phy_id,int reg, -u16 val) +static int xemaclite_mdio_write (struct mii_bus *bus,int phy_id,int devad, +int reg,u16 val) {struct net_local *lp = bus->priv;u32 ctrl_reg;
include/linux/phy.h +48 -9
107 lines not on this page · raw message
Signature · 1 line
1.6.5.2.g6ff9a
PATCH v2 2/2 phylib: Convert MDIO bitbang to new MDIO 45 format
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.
--- drivers/net/phy/mdio-bitbang.c | 29 +++++++++++++++-------------- 1 files changed, 15 insertions(+), 14 deletions(-)
drivers/net/phy/mdio-bitbang.c +15 -14
@@ -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,11 +154,13 @@ 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); - }else +/* Clause 22 PHYs only use devad = 0, and Clause 45 only use nonzero */ +if (devad ==MDIO_DEVAD_NONE )mdiobb_cmd (ctrl,MDIO_READ , phy, reg); +else { +mdiobb_cmd_addr (ctrl, phy, devad, reg); +mdiobb_cmd (ctrl,MDIO_C45_READ , phy, devad); + } ctrl->ops->set_mdio_dir (ctrl,0 );
@@ -186,11 +185,13 @@ 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); - }else +/* Clause 22 PHYs only use devad = 0, and Clause 45 only use nonzero */ +if (devad ==MDIO_DEVAD_NONE )mdiobb_cmd (ctrl,MDIO_WRITE , phy, reg); +else { +mdiobb_cmd_addr (ctrl, phy, devad, reg); +mdiobb_cmd (ctrl,MDIO_C45_WRITE , phy, devad); + }/* send the turnaround (10) */ mdiobb_send_bit (ctrl,1 );
Signature · 1 line
1.6.5.2.g6ff9a
Re: [PATCH v2 1/2] phylib: Convert MDIO and PHY Lib drivers to support 10G
In reply to Andy FlemingOn Fri, 2010-05-21 at 13:31 -0500, Andy Fleming wrote:
[...]
Quoted 4 lines
drivers/net/phy/phy_device.c +0
-0
[...]
drivers/net/phy/phy_device.c static int genphy_config_init(struct phy_device *phydev) · line 950
Quoted 11 lines
drivers/net/phy/phy_device.c +7
-0@@ -873,6 +941,36 @@ static int genphy_config_init(struct phy_device *phydev)return 0 ; } + +/* Replicate mdio45_probe */ +int gen10g_config_init (struct phy_device *phydev) +{ +int mmd, stat2, devs1, devs2; + + phydev->supported = phydev->advertising = SUPPORTED_10000baseT_Full;
[...]
Whyever are you assuming that?
Quoted 4 lines
include/linux/phy.h +0
-0
[...]
include/linux/phy.h typedef enum { · line 68
Quoted 8 lines
include/linux/phy.h +2
-1@@ -62,7 +63,8 @@ typedef enum {PHY_INTERFACE_MODE_RGMII_ID ,PHY_INTERFACE_MODE_RGMII_RXID ,PHY_INTERFACE_MODE_RGMII_TXID , - PHY_INTERFACE_MODE_RTBI +PHY_INTERFACE_MODE_RTBI , + PHY_INTERFACE_MODE_XGMII } phy_interface_t;
[...]
What about XAUI and XFI? I don't think anyone uses XGMII other than as an on-chip interface.
Ben.
Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare Communications Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
Re: [PATCH v2 2/2] phylib: Convert MDIO bitbang to new MDIO 45 format
In reply to Andy FlemingQuoted 12 lines · Andy Fleming
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 <[email protected]>--- drivers/net/phy/mdio-bitbang.c | 29 +++++++++++++++-------------- 1 files changed, 15 insertions(+), 14 deletions(-)drivers/net/phy/mdio-bitbang.c +0
-0
[...]
Quoted 5 lines
drivers/net/phy/mdio-bitbang.c +0
-1@@ -157,11 +154,13 @@ 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 ) {
drivers/net/phy/mdio-bitbang.c static int mdiobb_read(struct mii_bus *bus, int phy, int devad, int reg) · line 163
Quoted 10 lines
drivers/net/phy/mdio-bitbang.c +6
-3- reg =mdiobb_cmd_addr (ctrl, phy, reg); -mdiobb_cmd (ctrl,MDIO_C45_READ , phy, reg); - }else +/* Clause 22 PHYs only use devad = 0, and Clause 45 only use nonzero */ +if (devad ==MDIO_DEVAD_NONE )mdiobb_cmd (ctrl,MDIO_READ , phy, reg); +else { +mdiobb_cmd_addr (ctrl, phy, devad, reg); +mdiobb_cmd (ctrl,MDIO_C45_READ , phy, devad); + }
[...]
This comment is now wrong.
Ben.
Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare Communications Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.