Commit 0f07c4ee authored by Ben Hutchings's avatar Ben Hutchings Committed by David S. Miller

cxgb3: Use generic MDIO definitions and mdio_mii_ioctl()

Compile-tested only.
Signed-off-by: default avatarBen Hutchings <bhutchings@solarflare.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 23c3320c
...@@ -2483,6 +2483,7 @@ config CHELSIO_T3 ...@@ -2483,6 +2483,7 @@ config CHELSIO_T3
tristate "Chelsio Communications T3 10Gb Ethernet support" tristate "Chelsio Communications T3 10Gb Ethernet support"
depends on CHELSIO_T3_DEPENDS depends on CHELSIO_T3_DEPENDS
select FW_LOADER select FW_LOADER
select MDIO
help help
This driver supports Chelsio T3-based gigabit and 10Gb Ethernet This driver supports Chelsio T3-based gigabit and 10Gb Ethernet
adapters. adapters.
......
This diff is collapsed.
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/ethtool.h> #include <linux/ethtool.h>
#include <linux/mii.h> #include <linux/mdio.h>
#include "version.h" #include "version.h"
#define CH_ERR(adap, fmt, ...) dev_err(&adap->pdev->dev, fmt, ## __VA_ARGS__) #define CH_ERR(adap, fmt, ...) dev_err(&adap->pdev->dev, fmt, ## __VA_ARGS__)
...@@ -184,10 +184,11 @@ struct cphy; ...@@ -184,10 +184,11 @@ struct cphy;
struct adapter; struct adapter;
struct mdio_ops { struct mdio_ops {
int (*read)(struct adapter *adapter, int phy_addr, int mmd_addr, int (*read)(struct net_device *dev, int phy_addr, int mmd_addr,
int reg_addr, unsigned int *val); u16 reg_addr);
int (*write)(struct adapter *adapter, int phy_addr, int mmd_addr, int (*write)(struct net_device *dev, int phy_addr, int mmd_addr,
int reg_addr, unsigned int val); u16 reg_addr, u16 val);
unsigned mode_support;
}; };
struct adapter_info { struct adapter_info {
...@@ -520,17 +521,6 @@ enum { ...@@ -520,17 +521,6 @@ enum {
MAC_RXFIFO_SIZE = 32768 MAC_RXFIFO_SIZE = 32768
}; };
/* IEEE 802.3 specified MDIO devices */
enum {
MDIO_DEV_PMA_PMD = 1,
MDIO_DEV_WIS = 2,
MDIO_DEV_PCS = 3,
MDIO_DEV_XGXS = 4,
MDIO_DEV_ANEG = 7,
MDIO_DEV_VEND1 = 30,
MDIO_DEV_VEND2 = 31
};
/* LASI control and status registers */ /* LASI control and status registers */
enum { enum {
RX_ALARM_CTRL = 0x9000, RX_ALARM_CTRL = 0x9000,
...@@ -583,11 +573,12 @@ struct cphy_ops { ...@@ -583,11 +573,12 @@ struct cphy_ops {
int (*get_link_status)(struct cphy *phy, int *link_ok, int *speed, int (*get_link_status)(struct cphy *phy, int *link_ok, int *speed,
int *duplex, int *fc); int *duplex, int *fc);
int (*power_down)(struct cphy *phy, int enable); int (*power_down)(struct cphy *phy, int enable);
u32 mmds;
}; };
/* A PHY instance */ /* A PHY instance */
struct cphy { struct cphy {
u8 addr; /* PHY address */
u8 modtype; /* PHY module type */ u8 modtype; /* PHY module type */
short priv; /* scratch pad */ short priv; /* scratch pad */
unsigned int caps; /* PHY capabilities */ unsigned int caps; /* PHY capabilities */
...@@ -595,23 +586,23 @@ struct cphy { ...@@ -595,23 +586,23 @@ struct cphy {
const char *desc; /* PHY description */ const char *desc; /* PHY description */
unsigned long fifo_errors; /* FIFO over/under-flows */ unsigned long fifo_errors; /* FIFO over/under-flows */
const struct cphy_ops *ops; /* PHY operations */ const struct cphy_ops *ops; /* PHY operations */
int (*mdio_read)(struct adapter *adapter, int phy_addr, int mmd_addr, struct mdio_if_info mdio;
int reg_addr, unsigned int *val);
int (*mdio_write)(struct adapter *adapter, int phy_addr, int mmd_addr,
int reg_addr, unsigned int val);
}; };
/* Convenience MDIO read/write wrappers */ /* Convenience MDIO read/write wrappers */
static inline int mdio_read(struct cphy *phy, int mmd, int reg, static inline int t3_mdio_read(struct cphy *phy, int mmd, int reg,
unsigned int *valp) unsigned int *valp)
{ {
return phy->mdio_read(phy->adapter, phy->addr, mmd, reg, valp); int rc = phy->mdio.mdio_read(phy->mdio.dev, phy->mdio.prtad, mmd, reg);
*valp = (rc >= 0) ? rc : -1;
return (rc >= 0) ? 0 : rc;
} }
static inline int mdio_write(struct cphy *phy, int mmd, int reg, static inline int t3_mdio_write(struct cphy *phy, int mmd, int reg,
unsigned int val) unsigned int val)
{ {
return phy->mdio_write(phy->adapter, phy->addr, mmd, reg, val); return phy->mdio.mdio_write(phy->mdio.dev, phy->mdio.prtad, mmd,
reg, val);
} }
/* Convenience initializer */ /* Convenience initializer */
...@@ -620,14 +611,16 @@ static inline void cphy_init(struct cphy *phy, struct adapter *adapter, ...@@ -620,14 +611,16 @@ static inline void cphy_init(struct cphy *phy, struct adapter *adapter,
const struct mdio_ops *mdio_ops, const struct mdio_ops *mdio_ops,
unsigned int caps, const char *desc) unsigned int caps, const char *desc)
{ {
phy->addr = phy_addr;
phy->caps = caps; phy->caps = caps;
phy->adapter = adapter; phy->adapter = adapter;
phy->desc = desc; phy->desc = desc;
phy->ops = phy_ops; phy->ops = phy_ops;
if (mdio_ops) { if (mdio_ops) {
phy->mdio_read = mdio_ops->read; phy->mdio.prtad = phy_addr;
phy->mdio_write = mdio_ops->write; phy->mdio.mmds = phy_ops->mmds;
phy->mdio.mode_support = mdio_ops->mode_support;
phy->mdio.mdio_read = mdio_ops->read;
phy->mdio.mdio_write = mdio_ops->write;
} }
} }
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
#include <linux/if_vlan.h> #include <linux/if_vlan.h>
#include <linux/mii.h> #include <linux/mdio.h>
#include <linux/sockios.h> #include <linux/sockios.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
...@@ -1593,7 +1593,7 @@ static int get_settings(struct net_device *dev, struct ethtool_cmd *cmd) ...@@ -1593,7 +1593,7 @@ static int get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
} }
cmd->port = (cmd->supported & SUPPORTED_TP) ? PORT_TP : PORT_FIBRE; cmd->port = (cmd->supported & SUPPORTED_TP) ? PORT_TP : PORT_FIBRE;
cmd->phy_address = p->phy.addr; cmd->phy_address = p->phy.mdio.prtad;
cmd->transceiver = XCVR_EXTERNAL; cmd->transceiver = XCVR_EXTERNAL;
cmd->autoneg = p->link_config.autoneg; cmd->autoneg = p->link_config.autoneg;
cmd->maxtxpkt = 0; cmd->maxtxpkt = 0;
...@@ -2308,70 +2308,25 @@ static int cxgb_ioctl(struct net_device *dev, struct ifreq *req, int cmd) ...@@ -2308,70 +2308,25 @@ static int cxgb_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
struct mii_ioctl_data *data = if_mii(req); struct mii_ioctl_data *data = if_mii(req);
struct port_info *pi = netdev_priv(dev); struct port_info *pi = netdev_priv(dev);
struct adapter *adapter = pi->adapter; struct adapter *adapter = pi->adapter;
int ret, mmd;
switch (cmd) { switch (cmd) {
case SIOCGMIIPHY: case SIOCGMIIREG:
data->phy_id = pi->phy.addr; case SIOCSMIIREG:
/* Convert phy_id from older PRTAD/DEVAD format */
if (is_10G(adapter) &&
!mdio_phy_id_is_c45(data->phy_id) &&
(data->phy_id & 0x1f00) &&
!(data->phy_id & 0xe0e0))
data->phy_id = mdio_phy_id_c45(data->phy_id >> 8,
data->phy_id & 0x1f);
/* FALLTHRU */ /* FALLTHRU */
case SIOCGMIIREG:{ case SIOCGMIIPHY:
u32 val; return mdio_mii_ioctl(&pi->phy.mdio, data, cmd);
struct cphy *phy = &pi->phy;
if (!phy->mdio_read)
return -EOPNOTSUPP;
if (is_10G(adapter)) {
mmd = data->phy_id >> 8;
if (!mmd)
mmd = MDIO_DEV_PCS;
else if (mmd > MDIO_DEV_VEND2)
return -EINVAL;
ret =
phy->mdio_read(adapter, data->phy_id & 0x1f,
mmd, data->reg_num, &val);
} else
ret =
phy->mdio_read(adapter, data->phy_id & 0x1f,
0, data->reg_num & 0x1f,
&val);
if (!ret)
data->val_out = val;
break;
}
case SIOCSMIIREG:{
struct cphy *phy = &pi->phy;
if (!capable(CAP_NET_ADMIN))
return -EPERM;
if (!phy->mdio_write)
return -EOPNOTSUPP;
if (is_10G(adapter)) {
mmd = data->phy_id >> 8;
if (!mmd)
mmd = MDIO_DEV_PCS;
else if (mmd > MDIO_DEV_VEND2)
return -EINVAL;
ret =
phy->mdio_write(adapter,
data->phy_id & 0x1f, mmd,
data->reg_num,
data->val_in);
} else
ret =
phy->mdio_write(adapter,
data->phy_id & 0x1f, 0,
data->reg_num & 0x1f,
data->val_in);
break;
}
case SIOCCHIOCTL: case SIOCCHIOCTL:
return cxgb_extension_ioctl(dev, req->ifr_data); return cxgb_extension_ioctl(dev, req->ifr_data);
default: default:
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
return ret;
} }
static int cxgb_change_mtu(struct net_device *dev, int new_mtu) static int cxgb_change_mtu(struct net_device *dev, int new_mtu)
......
...@@ -204,35 +204,33 @@ static void mi1_init(struct adapter *adap, const struct adapter_info *ai) ...@@ -204,35 +204,33 @@ static void mi1_init(struct adapter *adap, const struct adapter_info *ai)
/* /*
* MI1 read/write operations for clause 22 PHYs. * MI1 read/write operations for clause 22 PHYs.
*/ */
static int t3_mi1_read(struct adapter *adapter, int phy_addr, int mmd_addr, static int t3_mi1_read(struct net_device *dev, int phy_addr, int mmd_addr,
int reg_addr, unsigned int *valp) u16 reg_addr)
{ {
struct port_info *pi = netdev_priv(dev);
struct adapter *adapter = pi->adapter;
int ret; int ret;
u32 addr = V_REGADDR(reg_addr) | V_PHYADDR(phy_addr); u32 addr = V_REGADDR(reg_addr) | V_PHYADDR(phy_addr);
if (mmd_addr)
return -EINVAL;
mutex_lock(&adapter->mdio_lock); mutex_lock(&adapter->mdio_lock);
t3_set_reg_field(adapter, A_MI1_CFG, V_ST(M_ST), V_ST(1)); t3_set_reg_field(adapter, A_MI1_CFG, V_ST(M_ST), V_ST(1));
t3_write_reg(adapter, A_MI1_ADDR, addr); t3_write_reg(adapter, A_MI1_ADDR, addr);
t3_write_reg(adapter, A_MI1_OP, V_MDI_OP(2)); t3_write_reg(adapter, A_MI1_OP, V_MDI_OP(2));
ret = t3_wait_op_done(adapter, A_MI1_OP, F_BUSY, 0, MDIO_ATTEMPTS, 10); ret = t3_wait_op_done(adapter, A_MI1_OP, F_BUSY, 0, MDIO_ATTEMPTS, 10);
if (!ret) if (!ret)
*valp = t3_read_reg(adapter, A_MI1_DATA); ret = t3_read_reg(adapter, A_MI1_DATA);
mutex_unlock(&adapter->mdio_lock); mutex_unlock(&adapter->mdio_lock);
return ret; return ret;
} }
static int t3_mi1_write(struct adapter *adapter, int phy_addr, int mmd_addr, static int t3_mi1_write(struct net_device *dev, int phy_addr, int mmd_addr,
int reg_addr, unsigned int val) u16 reg_addr, u16 val)
{ {
struct port_info *pi = netdev_priv(dev);
struct adapter *adapter = pi->adapter;
int ret; int ret;
u32 addr = V_REGADDR(reg_addr) | V_PHYADDR(phy_addr); u32 addr = V_REGADDR(reg_addr) | V_PHYADDR(phy_addr);
if (mmd_addr)
return -EINVAL;
mutex_lock(&adapter->mdio_lock); mutex_lock(&adapter->mdio_lock);
t3_set_reg_field(adapter, A_MI1_CFG, V_ST(M_ST), V_ST(1)); t3_set_reg_field(adapter, A_MI1_CFG, V_ST(M_ST), V_ST(1));
t3_write_reg(adapter, A_MI1_ADDR, addr); t3_write_reg(adapter, A_MI1_ADDR, addr);
...@@ -244,8 +242,9 @@ static int t3_mi1_write(struct adapter *adapter, int phy_addr, int mmd_addr, ...@@ -244,8 +242,9 @@ static int t3_mi1_write(struct adapter *adapter, int phy_addr, int mmd_addr,
} }
static const struct mdio_ops mi1_mdio_ops = { static const struct mdio_ops mi1_mdio_ops = {
t3_mi1_read, .read = t3_mi1_read,
t3_mi1_write .write = t3_mi1_write,
.mode_support = MDIO_SUPPORTS_C22
}; };
/* /*
...@@ -268,9 +267,11 @@ static int mi1_wr_addr(struct adapter *adapter, int phy_addr, int mmd_addr, ...@@ -268,9 +267,11 @@ static int mi1_wr_addr(struct adapter *adapter, int phy_addr, int mmd_addr,
/* /*
* MI1 read/write operations for indirect-addressed PHYs. * MI1 read/write operations for indirect-addressed PHYs.
*/ */
static int mi1_ext_read(struct adapter *adapter, int phy_addr, int mmd_addr, static int mi1_ext_read(struct net_device *dev, int phy_addr, int mmd_addr,
int reg_addr, unsigned int *valp) u16 reg_addr)
{ {
struct port_info *pi = netdev_priv(dev);
struct adapter *adapter = pi->adapter;
int ret; int ret;
mutex_lock(&adapter->mdio_lock); mutex_lock(&adapter->mdio_lock);
...@@ -280,15 +281,17 @@ static int mi1_ext_read(struct adapter *adapter, int phy_addr, int mmd_addr, ...@@ -280,15 +281,17 @@ static int mi1_ext_read(struct adapter *adapter, int phy_addr, int mmd_addr,
ret = t3_wait_op_done(adapter, A_MI1_OP, F_BUSY, 0, ret = t3_wait_op_done(adapter, A_MI1_OP, F_BUSY, 0,
MDIO_ATTEMPTS, 10); MDIO_ATTEMPTS, 10);
if (!ret) if (!ret)
*valp = t3_read_reg(adapter, A_MI1_DATA); ret = t3_read_reg(adapter, A_MI1_DATA);
} }
mutex_unlock(&adapter->mdio_lock); mutex_unlock(&adapter->mdio_lock);
return ret; return ret;
} }
static int mi1_ext_write(struct adapter *adapter, int phy_addr, int mmd_addr, static int mi1_ext_write(struct net_device *dev, int phy_addr, int mmd_addr,
int reg_addr, unsigned int val) u16 reg_addr, u16 val)
{ {
struct port_info *pi = netdev_priv(dev);
struct adapter *adapter = pi->adapter;
int ret; int ret;
mutex_lock(&adapter->mdio_lock); mutex_lock(&adapter->mdio_lock);
...@@ -304,8 +307,9 @@ static int mi1_ext_write(struct adapter *adapter, int phy_addr, int mmd_addr, ...@@ -304,8 +307,9 @@ static int mi1_ext_write(struct adapter *adapter, int phy_addr, int mmd_addr,
} }
static const struct mdio_ops mi1_mdio_ext_ops = { static const struct mdio_ops mi1_mdio_ext_ops = {
mi1_ext_read, .read = mi1_ext_read,
mi1_ext_write .write = mi1_ext_write,
.mode_support = MDIO_SUPPORTS_C45 | MDIO_EMULATE_C22
}; };
/** /**
...@@ -325,10 +329,10 @@ int t3_mdio_change_bits(struct cphy *phy, int mmd, int reg, unsigned int clear, ...@@ -325,10 +329,10 @@ int t3_mdio_change_bits(struct cphy *phy, int mmd, int reg, unsigned int clear,
int ret; int ret;
unsigned int val; unsigned int val;
ret = mdio_read(phy, mmd, reg, &val); ret = t3_mdio_read(phy, mmd, reg, &val);
if (!ret) { if (!ret) {
val &= ~clear; val &= ~clear;
ret = mdio_write(phy, mmd, reg, val | set); ret = t3_mdio_write(phy, mmd, reg, val | set);
} }
return ret; return ret;
} }
...@@ -348,15 +352,16 @@ int t3_phy_reset(struct cphy *phy, int mmd, int wait) ...@@ -348,15 +352,16 @@ int t3_phy_reset(struct cphy *phy, int mmd, int wait)
int err; int err;
unsigned int ctl; unsigned int ctl;
err = t3_mdio_change_bits(phy, mmd, MII_BMCR, BMCR_PDOWN, BMCR_RESET); err = t3_mdio_change_bits(phy, mmd, MDIO_CTRL1, MDIO_CTRL1_LPOWER,
MDIO_CTRL1_RESET);
if (err || !wait) if (err || !wait)
return err; return err;
do { do {
err = mdio_read(phy, mmd, MII_BMCR, &ctl); err = t3_mdio_read(phy, mmd, MDIO_CTRL1, &ctl);
if (err) if (err)
return err; return err;
ctl &= BMCR_RESET; ctl &= MDIO_CTRL1_RESET;
if (ctl) if (ctl)
msleep(1); msleep(1);
} while (ctl && --wait); } while (ctl && --wait);
...@@ -377,7 +382,7 @@ int t3_phy_advertise(struct cphy *phy, unsigned int advert) ...@@ -377,7 +382,7 @@ int t3_phy_advertise(struct cphy *phy, unsigned int advert)
int err; int err;
unsigned int val = 0; unsigned int val = 0;
err = mdio_read(phy, 0, MII_CTRL1000, &val); err = t3_mdio_read(phy, MDIO_DEVAD_NONE, MII_CTRL1000, &val);
if (err) if (err)
return err; return err;
...@@ -387,7 +392,7 @@ int t3_phy_advertise(struct cphy *phy, unsigned int advert) ...@@ -387,7 +392,7 @@ int t3_phy_advertise(struct cphy *phy, unsigned int advert)
if (advert & ADVERTISED_1000baseT_Full) if (advert & ADVERTISED_1000baseT_Full)
val |= ADVERTISE_1000FULL; val |= ADVERTISE_1000FULL;
err = mdio_write(phy, 0, MII_CTRL1000, val); err = t3_mdio_write(phy, MDIO_DEVAD_NONE, MII_CTRL1000, val);
if (err) if (err)
return err; return err;
...@@ -404,7 +409,7 @@ int t3_phy_advertise(struct cphy *phy, unsigned int advert) ...@@ -404,7 +409,7 @@ int t3_phy_advertise(struct cphy *phy, unsigned int advert)
val |= ADVERTISE_PAUSE_CAP; val |= ADVERTISE_PAUSE_CAP;
if (advert & ADVERTISED_Asym_Pause) if (advert & ADVERTISED_Asym_Pause)
val |= ADVERTISE_PAUSE_ASYM; val |= ADVERTISE_PAUSE_ASYM;
return mdio_write(phy, 0, MII_ADVERTISE, val); return t3_mdio_write(phy, MDIO_DEVAD_NONE, MII_ADVERTISE, val);
} }
/** /**
...@@ -427,7 +432,7 @@ int t3_phy_advertise_fiber(struct cphy *phy, unsigned int advert) ...@@ -427,7 +432,7 @@ int t3_phy_advertise_fiber(struct cphy *phy, unsigned int advert)
val |= ADVERTISE_1000XPAUSE; val |= ADVERTISE_1000XPAUSE;
if (advert & ADVERTISED_Asym_Pause) if (advert & ADVERTISED_Asym_Pause)
val |= ADVERTISE_1000XPSE_ASYM; val |= ADVERTISE_1000XPSE_ASYM;
return mdio_write(phy, 0, MII_ADVERTISE, val); return t3_mdio_write(phy, MDIO_DEVAD_NONE, MII_ADVERTISE, val);
} }
/** /**
...@@ -444,7 +449,7 @@ int t3_set_phy_speed_duplex(struct cphy *phy, int speed, int duplex) ...@@ -444,7 +449,7 @@ int t3_set_phy_speed_duplex(struct cphy *phy, int speed, int duplex)
int err; int err;
unsigned int ctl; unsigned int ctl;
err = mdio_read(phy, 0, MII_BMCR, &ctl); err = t3_mdio_read(phy, MDIO_DEVAD_NONE, MII_BMCR, &ctl);
if (err) if (err)
return err; return err;
...@@ -462,30 +467,30 @@ int t3_set_phy_speed_duplex(struct cphy *phy, int speed, int duplex) ...@@ -462,30 +467,30 @@ int t3_set_phy_speed_duplex(struct cphy *phy, int speed, int duplex)
} }
if (ctl & BMCR_SPEED1000) /* auto-negotiation required for GigE */ if (ctl & BMCR_SPEED1000) /* auto-negotiation required for GigE */
ctl |= BMCR_ANENABLE; ctl |= BMCR_ANENABLE;
return mdio_write(phy, 0, MII_BMCR, ctl); return t3_mdio_write(phy, MDIO_DEVAD_NONE, MII_BMCR, ctl);
} }
int t3_phy_lasi_intr_enable(struct cphy *phy) int t3_phy_lasi_intr_enable(struct cphy *phy)
{ {
return mdio_write(phy, MDIO_DEV_PMA_PMD, LASI_CTRL, 1); return t3_mdio_write(phy, MDIO_MMD_PMAPMD, LASI_CTRL, 1);
} }
int t3_phy_lasi_intr_disable(struct cphy *phy) int t3_phy_lasi_intr_disable(struct cphy *phy)
{ {
return mdio_write(phy, MDIO_DEV_PMA_PMD, LASI_CTRL, 0); return t3_mdio_write(phy, MDIO_MMD_PMAPMD, LASI_CTRL, 0);
} }
int t3_phy_lasi_intr_clear(struct cphy *phy) int t3_phy_lasi_intr_clear(struct cphy *phy)
{ {
u32 val; u32 val;
return mdio_read(phy, MDIO_DEV_PMA_PMD, LASI_STAT, &val); return t3_mdio_read(phy, MDIO_MMD_PMAPMD, LASI_STAT, &val);
} }
int t3_phy_lasi_intr_handler(struct cphy *phy) int t3_phy_lasi_intr_handler(struct cphy *phy)
{ {
unsigned int status; unsigned int status;
int err = mdio_read(phy, MDIO_DEV_PMA_PMD, LASI_STAT, &status); int err = t3_mdio_read(phy, MDIO_MMD_PMAPMD, LASI_STAT, &status);
if (err) if (err)
return err; return err;
...@@ -3863,6 +3868,7 @@ int t3_prep_adapter(struct adapter *adapter, const struct adapter_info *ai, ...@@ -3863,6 +3868,7 @@ int t3_prep_adapter(struct adapter *adapter, const struct adapter_info *ai,
ai->mdio_ops); ai->mdio_ops);
if (ret) if (ret)
return ret; return ret;
p->phy.mdio.dev = adapter->port[i];
mac_prep(&p->mac, adapter, j); mac_prep(&p->mac, adapter, j);
/* /*
...@@ -3918,7 +3924,7 @@ int t3_replay_prep_adapter(struct adapter *adapter) ...@@ -3918,7 +3924,7 @@ int t3_replay_prep_adapter(struct adapter *adapter)
; ;
pti = &port_types[adapter->params.vpd.port_type[j]]; pti = &port_types[adapter->params.vpd.port_type[j]];
ret = pti->phy_prep(&p->phy, adapter, p->phy.addr, NULL); ret = pti->phy_prep(&p->phy, adapter, p->phy.mdio.prtad, NULL);
if (ret) if (ret)
return ret; return ret;
p->phy.ops->power_down(&p->phy, 1); p->phy.ops->power_down(&p->phy, 1);
......
...@@ -91,17 +91,18 @@ enum { ...@@ -91,17 +91,18 @@ enum {
*/ */
static int vsc8211_reset(struct cphy *cphy, int wait) static int vsc8211_reset(struct cphy *cphy, int wait)
{ {
return t3_phy_reset(cphy, 0, 0); return t3_phy_reset(cphy, MDIO_DEVAD_NONE, 0);
} }
static int vsc8211_intr_enable(struct cphy *cphy) static int vsc8211_intr_enable(struct cphy *cphy)
{ {
return mdio_write(cphy, 0, VSC8211_INTR_ENABLE, INTR_MASK); return t3_mdio_write(cphy, MDIO_DEVAD_NONE, VSC8211_INTR_ENABLE,
INTR_MASK);
} }
static int vsc8211_intr_disable(struct cphy *cphy) static int vsc8211_intr_disable(struct cphy *cphy)
{ {
return mdio_write(cphy, 0, VSC8211_INTR_ENABLE, 0); return t3_mdio_write(cphy, MDIO_DEVAD_NONE, VSC8211_INTR_ENABLE, 0);
} }
static int vsc8211_intr_clear(struct cphy *cphy) static int vsc8211_intr_clear(struct cphy *cphy)
...@@ -109,18 +110,20 @@ static int vsc8211_intr_clear(struct cphy *cphy) ...@@ -109,18 +110,20 @@ static int vsc8211_intr_clear(struct cphy *cphy)
u32 val; u32 val;
/* Clear PHY interrupts by reading the register. */ /* Clear PHY interrupts by reading the register. */
return mdio_read(cphy, 0, VSC8211_INTR_STATUS, &val); return t3_mdio_read(cphy, MDIO_DEVAD_NONE, VSC8211_INTR_STATUS, &val);
} }
static int vsc8211_autoneg_enable(struct cphy *cphy) static int vsc8211_autoneg_enable(struct cphy *cphy)
{ {
return t3_mdio_change_bits(cphy, 0, MII_BMCR, BMCR_PDOWN | BMCR_ISOLATE, return t3_mdio_change_bits(cphy, MDIO_DEVAD_NONE, MII_BMCR,
BMCR_PDOWN | BMCR_ISOLATE,
BMCR_ANENABLE | BMCR_ANRESTART); BMCR_ANENABLE | BMCR_ANRESTART);
} }
static int vsc8211_autoneg_restart(struct cphy *cphy) static int vsc8211_autoneg_restart(struct cphy *cphy)
{ {
return t3_mdio_change_bits(cphy, 0, MII_BMCR, BMCR_PDOWN | BMCR_ISOLATE, return t3_mdio_change_bits(cphy, MDIO_DEVAD_NONE, MII_BMCR,
BMCR_PDOWN | BMCR_ISOLATE,
BMCR_ANRESTART); BMCR_ANRESTART);
} }
...@@ -130,9 +133,9 @@ static int vsc8211_get_link_status(struct cphy *cphy, int *link_ok, ...@@ -130,9 +133,9 @@ static int vsc8211_get_link_status(struct cphy *cphy, int *link_ok,
unsigned int bmcr, status, lpa, adv; unsigned int bmcr, status, lpa, adv;
int err, sp = -1, dplx = -1, pause = 0; int err, sp = -1, dplx = -1, pause = 0;
err = mdio_read(cphy, 0, MII_BMCR, &bmcr); err = t3_mdio_read(cphy, MDIO_DEVAD_NONE, MII_BMCR, &bmcr);
if (!err) if (!err)
err = mdio_read(cphy, 0, MII_BMSR, &status); err = t3_mdio_read(cphy, MDIO_DEVAD_NONE, MII_BMSR, &status);
if (err) if (err)
return err; return err;
...@@ -142,7 +145,8 @@ static int vsc8211_get_link_status(struct cphy *cphy, int *link_ok, ...@@ -142,7 +145,8 @@ static int vsc8211_get_link_status(struct cphy *cphy, int *link_ok,
* once more to get the current link state. * once more to get the current link state.
*/ */
if (!(status & BMSR_LSTATUS)) if (!(status & BMSR_LSTATUS))
err = mdio_read(cphy, 0, MII_BMSR, &status); err = t3_mdio_read(cphy, MDIO_DEVAD_NONE, MII_BMSR,
&status);
if (err) if (err)
return err; return err;
*link_ok = (status & BMSR_LSTATUS) != 0; *link_ok = (status & BMSR_LSTATUS) != 0;
...@@ -156,7 +160,8 @@ static int vsc8211_get_link_status(struct cphy *cphy, int *link_ok, ...@@ -156,7 +160,8 @@ static int vsc8211_get_link_status(struct cphy *cphy, int *link_ok,
else else
sp = SPEED_10; sp = SPEED_10;
} else if (status & BMSR_ANEGCOMPLETE) { } else if (status & BMSR_ANEGCOMPLETE) {
err = mdio_read(cphy, 0, VSC8211_AUX_CTRL_STAT, &status); err = t3_mdio_read(cphy, MDIO_DEVAD_NONE, VSC8211_AUX_CTRL_STAT,
&status);
if (err) if (err)
return err; return err;
...@@ -170,9 +175,11 @@ static int vsc8211_get_link_status(struct cphy *cphy, int *link_ok, ...@@ -170,9 +175,11 @@ static int vsc8211_get_link_status(struct cphy *cphy, int *link_ok,
sp = SPEED_1000; sp = SPEED_1000;
if (fc && dplx == DUPLEX_FULL) { if (fc && dplx == DUPLEX_FULL) {
err = mdio_read(cphy, 0, MII_LPA, &lpa); err = t3_mdio_read(cphy, MDIO_DEVAD_NONE, MII_LPA,
&lpa);
if (!err) if (!err)
err = mdio_read(cphy, 0, MII_ADVERTISE, &adv); err = t3_mdio_read(cphy, MDIO_DEVAD_NONE,
MII_ADVERTISE, &adv);
if (err) if (err)
return err; return err;
...@@ -202,9 +209,9 @@ static int vsc8211_get_link_status_fiber(struct cphy *cphy, int *link_ok, ...@@ -202,9 +209,9 @@ static int vsc8211_get_link_status_fiber(struct cphy *cphy, int *link_ok,
unsigned int bmcr, status, lpa, adv; unsigned int bmcr, status, lpa, adv;
int err, sp = -1, dplx = -1, pause = 0; int err, sp = -1, dplx = -1, pause = 0;
err = mdio_read(cphy, 0, MII_BMCR, &bmcr); err = t3_mdio_read(cphy, MDIO_DEVAD_NONE, MII_BMCR, &bmcr);
if (!err) if (!err)
err = mdio_read(cphy, 0, MII_BMSR, &status); err = t3_mdio_read(cphy, MDIO_DEVAD_NONE, MII_BMSR, &status);
if (err) if (err)
return err; return err;
...@@ -214,7 +221,8 @@ static int vsc8211_get_link_status_fiber(struct cphy *cphy, int *link_ok, ...@@ -214,7 +221,8 @@ static int vsc8211_get_link_status_fiber(struct cphy *cphy, int *link_ok,
* once more to get the current link state. * once more to get the current link state.
*/ */
if (!(status & BMSR_LSTATUS)) if (!(status & BMSR_LSTATUS))
err = mdio_read(cphy, 0, MII_BMSR, &status); err = t3_mdio_read(cphy, MDIO_DEVAD_NONE, MII_BMSR,
&status);
if (err) if (err)
return err; return err;
*link_ok = (status & BMSR_LSTATUS) != 0; *link_ok = (status & BMSR_LSTATUS) != 0;
...@@ -228,9 +236,10 @@ static int vsc8211_get_link_status_fiber(struct cphy *cphy, int *link_ok, ...@@ -228,9 +236,10 @@ static int vsc8211_get_link_status_fiber(struct cphy *cphy, int *link_ok,
else else
sp = SPEED_10; sp = SPEED_10;
} else if (status & BMSR_ANEGCOMPLETE) { } else if (status & BMSR_ANEGCOMPLETE) {
err = mdio_read(cphy, 0, MII_LPA, &lpa); err = t3_mdio_read(cphy, MDIO_DEVAD_NONE, MII_LPA, &lpa);
if (!err) if (!err)
err = mdio_read(cphy, 0, MII_ADVERTISE, &adv); err = t3_mdio_read(cphy, MDIO_DEVAD_NONE, MII_ADVERTISE,
&adv);
if (err) if (err)
return err; return err;
...@@ -270,23 +279,23 @@ static int vsc8211_set_automdi(struct cphy *phy, int enable) ...@@ -270,23 +279,23 @@ static int vsc8211_set_automdi(struct cphy *phy, int enable)
{ {
int err; int err;
err = mdio_write(phy, 0, VSC8211_EXT_PAGE_AXS, 0x52b5); err = t3_mdio_write(phy, MDIO_DEVAD_NONE, VSC8211_EXT_PAGE_AXS, 0x52b5);
if (err) if (err)
return err; return err;
err = mdio_write(phy, 0, 18, 0x12); err = t3_mdio_write(phy, MDIO_DEVAD_NONE, 18, 0x12);
if (err) if (err)
return err; return err;
err = mdio_write(phy, 0, 17, enable ? 0x2803 : 0x3003); err = t3_mdio_write(phy, MDIO_DEVAD_NONE, 17, enable ? 0x2803 : 0x3003);
if (err) if (err)
return err; return err;
err = mdio_write(phy, 0, 16, 0x87fa); err = t3_mdio_write(phy, MDIO_DEVAD_NONE, 16, 0x87fa);
if (err) if (err)
return err; return err;
err = mdio_write(phy, 0, VSC8211_EXT_PAGE_AXS, 0); err = t3_mdio_write(phy, MDIO_DEVAD_NONE, VSC8211_EXT_PAGE_AXS, 0);
if (err) if (err)
return err; return err;
...@@ -315,7 +324,7 @@ static int vsc8211_intr_handler(struct cphy *cphy) ...@@ -315,7 +324,7 @@ static int vsc8211_intr_handler(struct cphy *cphy)
unsigned int cause; unsigned int cause;
int err, cphy_cause = 0; int err, cphy_cause = 0;
err = mdio_read(cphy, 0, VSC8211_INTR_STATUS, &cause); err = t3_mdio_read(cphy, MDIO_DEVAD_NONE, VSC8211_INTR_STATUS, &cause);
if (err) if (err)
return err; return err;
...@@ -367,12 +376,13 @@ int t3_vsc8211_phy_prep(struct cphy *phy, struct adapter *adapter, ...@@ -367,12 +376,13 @@ int t3_vsc8211_phy_prep(struct cphy *phy, struct adapter *adapter,
SUPPORTED_TP | SUPPORTED_IRQ, "10/100/1000BASE-T"); SUPPORTED_TP | SUPPORTED_IRQ, "10/100/1000BASE-T");
msleep(20); /* PHY needs ~10ms to start responding to MDIO */ msleep(20); /* PHY needs ~10ms to start responding to MDIO */
err = mdio_read(phy, 0, VSC8211_EXT_CTRL, &val); err = t3_mdio_read(phy, MDIO_DEVAD_NONE, VSC8211_EXT_CTRL, &val);
if (err) if (err)
return err; return err;
if (val & VSC_CTRL_MEDIA_MODE_HI) { if (val & VSC_CTRL_MEDIA_MODE_HI) {
/* copper interface, just need to configure the LEDs */ /* copper interface, just need to configure the LEDs */
return mdio_write(phy, 0, VSC8211_LED_CTRL, 0x100); return t3_mdio_write(phy, MDIO_DEVAD_NONE, VSC8211_LED_CTRL,
0x100);
} }
phy->caps = SUPPORTED_1000baseT_Full | SUPPORTED_Autoneg | phy->caps = SUPPORTED_1000baseT_Full | SUPPORTED_Autoneg |
...@@ -380,19 +390,19 @@ int t3_vsc8211_phy_prep(struct cphy *phy, struct adapter *adapter, ...@@ -380,19 +390,19 @@ int t3_vsc8211_phy_prep(struct cphy *phy, struct adapter *adapter,
phy->desc = "1000BASE-X"; phy->desc = "1000BASE-X";
phy->ops = &vsc8211_fiber_ops; phy->ops = &vsc8211_fiber_ops;
err = mdio_write(phy, 0, VSC8211_EXT_PAGE_AXS, 1); err = t3_mdio_write(phy, MDIO_DEVAD_NONE, VSC8211_EXT_PAGE_AXS, 1);
if (err) if (err)
return err; return err;
err = mdio_write(phy, 0, VSC8211_SIGDET_CTRL, 1); err = t3_mdio_write(phy, MDIO_DEVAD_NONE, VSC8211_SIGDET_CTRL, 1);
if (err) if (err)
return err; return err;
err = mdio_write(phy, 0, VSC8211_EXT_PAGE_AXS, 0); err = t3_mdio_write(phy, MDIO_DEVAD_NONE, VSC8211_EXT_PAGE_AXS, 0);
if (err) if (err)
return err; return err;
err = mdio_write(phy, 0, VSC8211_EXT_CTRL, err = t3_mdio_write(phy, MDIO_DEVAD_NONE, VSC8211_EXT_CTRL,
val | VSC_CTRL_CLAUSE37_VIEW); val | VSC_CTRL_CLAUSE37_VIEW);
if (err) if (err)
return err; return err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment