mirror of
https://github.com/torvalds/linux.git
synced 2024-11-12 07:01:57 +00:00
[BNX2]: Improve SerDes handling.
1. Add support for 2.5Gbps forced speed setting. 2. Remove a long udelay() loop and change to msleep(). 3. Other misc. SerDes fixes. Signed-off-by: Michael Chan <mchan@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
7510873d86
commit
80be44348e
@ -860,7 +860,7 @@ bnx2_set_link(struct bnx2 *bp)
|
|||||||
u32 bmsr;
|
u32 bmsr;
|
||||||
u8 link_up;
|
u8 link_up;
|
||||||
|
|
||||||
if (bp->loopback == MAC_LOOPBACK) {
|
if (bp->loopback == MAC_LOOPBACK || bp->loopback == PHY_LOOPBACK) {
|
||||||
bp->link_up = 1;
|
bp->link_up = 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -902,6 +902,7 @@ bnx2_set_link(struct bnx2 *bp)
|
|||||||
u32 bmcr;
|
u32 bmcr;
|
||||||
|
|
||||||
bnx2_read_phy(bp, MII_BMCR, &bmcr);
|
bnx2_read_phy(bp, MII_BMCR, &bmcr);
|
||||||
|
bmcr &= ~BCM5708S_BMCR_FORCE_2500;
|
||||||
if (!(bmcr & BMCR_ANENABLE)) {
|
if (!(bmcr & BMCR_ANENABLE)) {
|
||||||
bnx2_write_phy(bp, MII_BMCR, bmcr |
|
bnx2_write_phy(bp, MII_BMCR, bmcr |
|
||||||
BMCR_ANENABLE);
|
BMCR_ANENABLE);
|
||||||
@ -988,7 +989,21 @@ bnx2_setup_serdes_phy(struct bnx2 *bp)
|
|||||||
u32 new_bmcr;
|
u32 new_bmcr;
|
||||||
int force_link_down = 0;
|
int force_link_down = 0;
|
||||||
|
|
||||||
if (CHIP_NUM(bp) == CHIP_NUM_5708) {
|
bnx2_read_phy(bp, MII_ADVERTISE, &adv);
|
||||||
|
adv &= ~(ADVERTISE_1000XFULL | ADVERTISE_1000XHALF);
|
||||||
|
|
||||||
|
bnx2_read_phy(bp, MII_BMCR, &bmcr);
|
||||||
|
new_bmcr = bmcr & ~(BMCR_ANENABLE | BCM5708S_BMCR_FORCE_2500);
|
||||||
|
new_bmcr |= BMCR_SPEED1000;
|
||||||
|
if (bp->req_line_speed == SPEED_2500) {
|
||||||
|
new_bmcr |= BCM5708S_BMCR_FORCE_2500;
|
||||||
|
bnx2_read_phy(bp, BCM5708S_UP1, &up1);
|
||||||
|
if (!(up1 & BCM5708S_UP1_2G5)) {
|
||||||
|
up1 |= BCM5708S_UP1_2G5;
|
||||||
|
bnx2_write_phy(bp, BCM5708S_UP1, up1);
|
||||||
|
force_link_down = 1;
|
||||||
|
}
|
||||||
|
} else if (CHIP_NUM(bp) == CHIP_NUM_5708) {
|
||||||
bnx2_read_phy(bp, BCM5708S_UP1, &up1);
|
bnx2_read_phy(bp, BCM5708S_UP1, &up1);
|
||||||
if (up1 & BCM5708S_UP1_2G5) {
|
if (up1 & BCM5708S_UP1_2G5) {
|
||||||
up1 &= ~BCM5708S_UP1_2G5;
|
up1 &= ~BCM5708S_UP1_2G5;
|
||||||
@ -997,12 +1012,6 @@ bnx2_setup_serdes_phy(struct bnx2 *bp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bnx2_read_phy(bp, MII_ADVERTISE, &adv);
|
|
||||||
adv &= ~(ADVERTISE_1000XFULL | ADVERTISE_1000XHALF);
|
|
||||||
|
|
||||||
bnx2_read_phy(bp, MII_BMCR, &bmcr);
|
|
||||||
new_bmcr = bmcr & ~BMCR_ANENABLE;
|
|
||||||
new_bmcr |= BMCR_SPEED1000;
|
|
||||||
if (bp->req_duplex == DUPLEX_FULL) {
|
if (bp->req_duplex == DUPLEX_FULL) {
|
||||||
adv |= ADVERTISE_1000XFULL;
|
adv |= ADVERTISE_1000XFULL;
|
||||||
new_bmcr |= BMCR_FULLDPLX;
|
new_bmcr |= BMCR_FULLDPLX;
|
||||||
@ -1023,6 +1032,7 @@ bnx2_setup_serdes_phy(struct bnx2 *bp)
|
|||||||
bp->link_up = 0;
|
bp->link_up = 0;
|
||||||
netif_carrier_off(bp->dev);
|
netif_carrier_off(bp->dev);
|
||||||
bnx2_write_phy(bp, MII_BMCR, new_bmcr);
|
bnx2_write_phy(bp, MII_BMCR, new_bmcr);
|
||||||
|
bnx2_report_link(bp);
|
||||||
}
|
}
|
||||||
bnx2_write_phy(bp, MII_ADVERTISE, adv);
|
bnx2_write_phy(bp, MII_ADVERTISE, adv);
|
||||||
bnx2_write_phy(bp, MII_BMCR, new_bmcr);
|
bnx2_write_phy(bp, MII_BMCR, new_bmcr);
|
||||||
@ -1048,12 +1058,10 @@ bnx2_setup_serdes_phy(struct bnx2 *bp)
|
|||||||
if ((adv != new_adv) || ((bmcr & BMCR_ANENABLE) == 0)) {
|
if ((adv != new_adv) || ((bmcr & BMCR_ANENABLE) == 0)) {
|
||||||
/* Force a link down visible on the other side */
|
/* Force a link down visible on the other side */
|
||||||
if (bp->link_up) {
|
if (bp->link_up) {
|
||||||
int i;
|
|
||||||
|
|
||||||
bnx2_write_phy(bp, MII_BMCR, BMCR_LOOPBACK);
|
bnx2_write_phy(bp, MII_BMCR, BMCR_LOOPBACK);
|
||||||
for (i = 0; i < 110; i++) {
|
spin_unlock_bh(&bp->phy_lock);
|
||||||
udelay(100);
|
msleep(20);
|
||||||
}
|
spin_lock_bh(&bp->phy_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
bnx2_write_phy(bp, MII_ADVERTISE, new_adv);
|
bnx2_write_phy(bp, MII_ADVERTISE, new_adv);
|
||||||
@ -1397,7 +1405,7 @@ bnx2_set_phy_loopback(struct bnx2 *bp)
|
|||||||
for (i = 0; i < 10; i++) {
|
for (i = 0; i < 10; i++) {
|
||||||
if (bnx2_test_link(bp) == 0)
|
if (bnx2_test_link(bp) == 0)
|
||||||
break;
|
break;
|
||||||
udelay(10);
|
msleep(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
mac_mode = REG_RD(bp, BNX2_EMAC_MODE);
|
mac_mode = REG_RD(bp, BNX2_EMAC_MODE);
|
||||||
@ -3713,7 +3721,9 @@ bnx2_init_nic(struct bnx2 *bp)
|
|||||||
if ((rc = bnx2_reset_nic(bp, BNX2_DRV_MSG_CODE_RESET)) != 0)
|
if ((rc = bnx2_reset_nic(bp, BNX2_DRV_MSG_CODE_RESET)) != 0)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
|
spin_lock_bh(&bp->phy_lock);
|
||||||
bnx2_init_phy(bp);
|
bnx2_init_phy(bp);
|
||||||
|
spin_unlock_bh(&bp->phy_lock);
|
||||||
bnx2_set_link(bp);
|
bnx2_set_link(bp);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -3953,7 +3963,7 @@ bnx2_run_loopback(struct bnx2 *bp, int loopback_mode)
|
|||||||
bnx2_set_mac_loopback(bp);
|
bnx2_set_mac_loopback(bp);
|
||||||
}
|
}
|
||||||
else if (loopback_mode == BNX2_PHY_LOOPBACK) {
|
else if (loopback_mode == BNX2_PHY_LOOPBACK) {
|
||||||
bp->loopback = 0;
|
bp->loopback = PHY_LOOPBACK;
|
||||||
bnx2_set_phy_loopback(bp);
|
bnx2_set_phy_loopback(bp);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -4744,10 +4754,14 @@ bnx2_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (bp->phy_flags & PHY_SERDES_FLAG) {
|
if (bp->phy_flags & PHY_SERDES_FLAG) {
|
||||||
if ((cmd->speed != SPEED_1000) ||
|
if ((cmd->speed != SPEED_1000 &&
|
||||||
(cmd->duplex != DUPLEX_FULL)) {
|
cmd->speed != SPEED_2500) ||
|
||||||
|
(cmd->duplex != DUPLEX_FULL))
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
if (cmd->speed == SPEED_2500 &&
|
||||||
|
!(bp->phy_flags & PHY_2_5G_CAPABLE_FLAG))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (cmd->speed == SPEED_1000) {
|
else if (cmd->speed == SPEED_1000) {
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
@ -5289,6 +5303,8 @@ bnx2_self_test(struct net_device *dev, struct ethtool_test *etest, u64 *buf)
|
|||||||
|
|
||||||
memset(buf, 0, sizeof(u64) * BNX2_NUM_TESTS);
|
memset(buf, 0, sizeof(u64) * BNX2_NUM_TESTS);
|
||||||
if (etest->flags & ETH_TEST_FL_OFFLINE) {
|
if (etest->flags & ETH_TEST_FL_OFFLINE) {
|
||||||
|
int i;
|
||||||
|
|
||||||
bnx2_netif_stop(bp);
|
bnx2_netif_stop(bp);
|
||||||
bnx2_reset_chip(bp, BNX2_DRV_MSG_CODE_DIAG);
|
bnx2_reset_chip(bp, BNX2_DRV_MSG_CODE_DIAG);
|
||||||
bnx2_free_skbs(bp);
|
bnx2_free_skbs(bp);
|
||||||
@ -5313,9 +5329,11 @@ bnx2_self_test(struct net_device *dev, struct ethtool_test *etest, u64 *buf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* wait for link up */
|
/* wait for link up */
|
||||||
msleep_interruptible(3000);
|
for (i = 0; i < 7; i++) {
|
||||||
if ((!bp->link_up) && !(bp->phy_flags & PHY_SERDES_FLAG))
|
if (bp->link_up)
|
||||||
msleep_interruptible(4000);
|
break;
|
||||||
|
msleep_interruptible(1000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bnx2_test_nvram(bp) != 0) {
|
if (bnx2_test_nvram(bp) != 0) {
|
||||||
|
@ -3696,6 +3696,8 @@ struct l2_fhdr {
|
|||||||
|
|
||||||
/* 5708 Serdes PHY registers */
|
/* 5708 Serdes PHY registers */
|
||||||
|
|
||||||
|
#define BCM5708S_BMCR_FORCE_2500 0x20
|
||||||
|
|
||||||
#define BCM5708S_UP1 0xb
|
#define BCM5708S_UP1 0xb
|
||||||
|
|
||||||
#define BCM5708S_UP1_2G5 0x1
|
#define BCM5708S_UP1_2G5 0x1
|
||||||
|
Loading…
Reference in New Issue
Block a user