diff options
author | Ben Hutchings <bhutchings@solarflare.com> | 2009-04-29 04:08:58 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-04-29 20:32:33 -0400 |
commit | 6b73e10d2d89f9ce773f9b47d61b195936d059ba (patch) | |
tree | 108a5d6ad55cb795d6afb0e0846c6782f42f5c90 /drivers/net | |
parent | 0f07c4ee8c800923ae7918c231532a9256233eed (diff) |
ixgbe: Use generic MDIO definitions and functions
Compile-tested only.
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/Kconfig | 1 | ||||
-rw-r--r-- | drivers/net/ixgbe/ixgbe_82598.c | 33 | ||||
-rw-r--r-- | drivers/net/ixgbe/ixgbe_82599.c | 17 | ||||
-rw-r--r-- | drivers/net/ixgbe/ixgbe_main.c | 42 | ||||
-rw-r--r-- | drivers/net/ixgbe/ixgbe_phy.c | 95 | ||||
-rw-r--r-- | drivers/net/ixgbe/ixgbe_type.h | 33 |
6 files changed, 102 insertions, 119 deletions
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 435bbc96444f..b8727d54bdbb 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig | |||
@@ -2519,6 +2519,7 @@ config ENIC | |||
2519 | config IXGBE | 2519 | config IXGBE |
2520 | tristate "Intel(R) 10GbE PCI Express adapters support" | 2520 | tristate "Intel(R) 10GbE PCI Express adapters support" |
2521 | depends on PCI && INET | 2521 | depends on PCI && INET |
2522 | select MDIO | ||
2522 | ---help--- | 2523 | ---help--- |
2523 | This driver supports Intel(R) 10GbE PCI Express family of | 2524 | This driver supports Intel(R) 10GbE PCI Express family of |
2524 | adapters. For more information on how to identify your adapter, go | 2525 | adapters. For more information on how to identify your adapter, go |
diff --git a/drivers/net/ixgbe/ixgbe_82598.c b/drivers/net/ixgbe/ixgbe_82598.c index 03eb54f4f1cc..e051964347e4 100644 --- a/drivers/net/ixgbe/ixgbe_82598.c +++ b/drivers/net/ixgbe/ixgbe_82598.c | |||
@@ -229,14 +229,13 @@ static s32 ixgbe_get_copper_link_capabilities_82598(struct ixgbe_hw *hw, | |||
229 | *speed = 0; | 229 | *speed = 0; |
230 | *autoneg = true; | 230 | *autoneg = true; |
231 | 231 | ||
232 | status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_SPEED_ABILITY, | 232 | status = hw->phy.ops.read_reg(hw, MDIO_SPEED, MDIO_MMD_PMAPMD, |
233 | IXGBE_MDIO_PMA_PMD_DEV_TYPE, | ||
234 | &speed_ability); | 233 | &speed_ability); |
235 | 234 | ||
236 | if (status == 0) { | 235 | if (status == 0) { |
237 | if (speed_ability & IXGBE_MDIO_PHY_SPEED_10G) | 236 | if (speed_ability & MDIO_SPEED_10G) |
238 | *speed |= IXGBE_LINK_SPEED_10GB_FULL; | 237 | *speed |= IXGBE_LINK_SPEED_10GB_FULL; |
239 | if (speed_ability & IXGBE_MDIO_PHY_SPEED_1G) | 238 | if (speed_ability & MDIO_PMA_SPEED_1000) |
240 | *speed |= IXGBE_LINK_SPEED_1GB_FULL; | 239 | *speed |= IXGBE_LINK_SPEED_1GB_FULL; |
241 | } | 240 | } |
242 | 241 | ||
@@ -526,9 +525,9 @@ static s32 ixgbe_check_mac_link_82598(struct ixgbe_hw *hw, | |||
526 | * clear indicates active; set indicates inactive. | 525 | * clear indicates active; set indicates inactive. |
527 | */ | 526 | */ |
528 | if (hw->phy.type == ixgbe_phy_nl) { | 527 | if (hw->phy.type == ixgbe_phy_nl) { |
529 | hw->phy.ops.read_reg(hw, 0xC79F, IXGBE_TWINAX_DEV, &link_reg); | 528 | hw->phy.ops.read_reg(hw, 0xC79F, MDIO_MMD_PMAPMD, &link_reg); |
530 | hw->phy.ops.read_reg(hw, 0xC79F, IXGBE_TWINAX_DEV, &link_reg); | 529 | hw->phy.ops.read_reg(hw, 0xC79F, MDIO_MMD_PMAPMD, &link_reg); |
531 | hw->phy.ops.read_reg(hw, 0xC00C, IXGBE_TWINAX_DEV, | 530 | hw->phy.ops.read_reg(hw, 0xC00C, MDIO_MMD_PMAPMD, |
532 | &adapt_comp_reg); | 531 | &adapt_comp_reg); |
533 | if (link_up_wait_to_complete) { | 532 | if (link_up_wait_to_complete) { |
534 | for (i = 0; i < IXGBE_LINK_UP_TIME; i++) { | 533 | for (i = 0; i < IXGBE_LINK_UP_TIME; i++) { |
@@ -541,10 +540,10 @@ static s32 ixgbe_check_mac_link_82598(struct ixgbe_hw *hw, | |||
541 | } | 540 | } |
542 | msleep(100); | 541 | msleep(100); |
543 | hw->phy.ops.read_reg(hw, 0xC79F, | 542 | hw->phy.ops.read_reg(hw, 0xC79F, |
544 | IXGBE_TWINAX_DEV, | 543 | MDIO_MMD_PMAPMD, |
545 | &link_reg); | 544 | &link_reg); |
546 | hw->phy.ops.read_reg(hw, 0xC00C, | 545 | hw->phy.ops.read_reg(hw, 0xC00C, |
547 | IXGBE_TWINAX_DEV, | 546 | MDIO_MMD_PMAPMD, |
548 | &adapt_comp_reg); | 547 | &adapt_comp_reg); |
549 | } | 548 | } |
550 | } else { | 549 | } else { |
@@ -990,14 +989,14 @@ static s32 ixgbe_read_i2c_eeprom_82598(struct ixgbe_hw *hw, u8 byte_offset, | |||
990 | sfp_addr = (sfp_addr | IXGBE_I2C_EEPROM_READ_MASK); | 989 | sfp_addr = (sfp_addr | IXGBE_I2C_EEPROM_READ_MASK); |
991 | hw->phy.ops.write_reg(hw, | 990 | hw->phy.ops.write_reg(hw, |
992 | IXGBE_MDIO_PMA_PMD_SDA_SCL_ADDR, | 991 | IXGBE_MDIO_PMA_PMD_SDA_SCL_ADDR, |
993 | IXGBE_MDIO_PMA_PMD_DEV_TYPE, | 992 | MDIO_MMD_PMAPMD, |
994 | sfp_addr); | 993 | sfp_addr); |
995 | 994 | ||
996 | /* Poll status */ | 995 | /* Poll status */ |
997 | for (i = 0; i < 100; i++) { | 996 | for (i = 0; i < 100; i++) { |
998 | hw->phy.ops.read_reg(hw, | 997 | hw->phy.ops.read_reg(hw, |
999 | IXGBE_MDIO_PMA_PMD_SDA_SCL_STAT, | 998 | IXGBE_MDIO_PMA_PMD_SDA_SCL_STAT, |
1000 | IXGBE_MDIO_PMA_PMD_DEV_TYPE, | 999 | MDIO_MMD_PMAPMD, |
1001 | &sfp_stat); | 1000 | &sfp_stat); |
1002 | sfp_stat = sfp_stat & IXGBE_I2C_EEPROM_STATUS_MASK; | 1001 | sfp_stat = sfp_stat & IXGBE_I2C_EEPROM_STATUS_MASK; |
1003 | if (sfp_stat != IXGBE_I2C_EEPROM_STATUS_IN_PROGRESS) | 1002 | if (sfp_stat != IXGBE_I2C_EEPROM_STATUS_IN_PROGRESS) |
@@ -1013,7 +1012,7 @@ static s32 ixgbe_read_i2c_eeprom_82598(struct ixgbe_hw *hw, u8 byte_offset, | |||
1013 | 1012 | ||
1014 | /* Read data */ | 1013 | /* Read data */ |
1015 | hw->phy.ops.read_reg(hw, IXGBE_MDIO_PMA_PMD_SDA_SCL_DATA, | 1014 | hw->phy.ops.read_reg(hw, IXGBE_MDIO_PMA_PMD_SDA_SCL_DATA, |
1016 | IXGBE_MDIO_PMA_PMD_DEV_TYPE, &sfp_data); | 1015 | MDIO_MMD_PMAPMD, &sfp_data); |
1017 | 1016 | ||
1018 | *eeprom_data = (u8)(sfp_data >> 8); | 1017 | *eeprom_data = (u8)(sfp_data >> 8); |
1019 | } else { | 1018 | } else { |
@@ -1045,13 +1044,13 @@ static u32 ixgbe_get_supported_physical_layer_82598(struct ixgbe_hw *hw) | |||
1045 | * physical layer because 10GBase-T PHYs use LMS = KX4/KX */ | 1044 | * physical layer because 10GBase-T PHYs use LMS = KX4/KX */ |
1046 | if (hw->phy.type == ixgbe_phy_tn || | 1045 | if (hw->phy.type == ixgbe_phy_tn || |
1047 | hw->phy.type == ixgbe_phy_cu_unknown) { | 1046 | hw->phy.type == ixgbe_phy_cu_unknown) { |
1048 | hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_EXT_ABILITY, | 1047 | hw->phy.ops.read_reg(hw, MDIO_PMA_EXTABLE, MDIO_MMD_PMAPMD, |
1049 | IXGBE_MDIO_PMA_PMD_DEV_TYPE, &ext_ability); | 1048 | &ext_ability); |
1050 | if (ext_ability & IXGBE_MDIO_PHY_10GBASET_ABILITY) | 1049 | if (ext_ability & MDIO_PMA_EXTABLE_10GBT) |
1051 | physical_layer |= IXGBE_PHYSICAL_LAYER_10GBASE_T; | 1050 | physical_layer |= IXGBE_PHYSICAL_LAYER_10GBASE_T; |
1052 | if (ext_ability & IXGBE_MDIO_PHY_1000BASET_ABILITY) | 1051 | if (ext_ability & MDIO_PMA_EXTABLE_1000BT) |
1053 | physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_T; | 1052 | physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_T; |
1054 | if (ext_ability & IXGBE_MDIO_PHY_100BASETX_ABILITY) | 1053 | if (ext_ability & MDIO_PMA_EXTABLE_100BTX) |
1055 | physical_layer |= IXGBE_PHYSICAL_LAYER_100BASE_TX; | 1054 | physical_layer |= IXGBE_PHYSICAL_LAYER_100BASE_TX; |
1056 | goto out; | 1055 | goto out; |
1057 | } | 1056 | } |
diff --git a/drivers/net/ixgbe/ixgbe_82599.c b/drivers/net/ixgbe/ixgbe_82599.c index 9e824b450416..6038ed14c9f9 100644 --- a/drivers/net/ixgbe/ixgbe_82599.c +++ b/drivers/net/ixgbe/ixgbe_82599.c | |||
@@ -314,14 +314,13 @@ static s32 ixgbe_get_copper_link_capabilities_82599(struct ixgbe_hw *hw, | |||
314 | *speed = 0; | 314 | *speed = 0; |
315 | *autoneg = true; | 315 | *autoneg = true; |
316 | 316 | ||
317 | status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_SPEED_ABILITY, | 317 | status = hw->phy.ops.read_reg(hw, MDIO_SPEED, MDIO_MMD_PMAPMD, |
318 | IXGBE_MDIO_PMA_PMD_DEV_TYPE, | ||
319 | &speed_ability); | 318 | &speed_ability); |
320 | 319 | ||
321 | if (status == 0) { | 320 | if (status == 0) { |
322 | if (speed_ability & IXGBE_MDIO_PHY_SPEED_10G) | 321 | if (speed_ability & MDIO_SPEED_10G) |
323 | *speed |= IXGBE_LINK_SPEED_10GB_FULL; | 322 | *speed |= IXGBE_LINK_SPEED_10GB_FULL; |
324 | if (speed_ability & IXGBE_MDIO_PHY_SPEED_1G) | 323 | if (speed_ability & MDIO_PMA_SPEED_1000) |
325 | *speed |= IXGBE_LINK_SPEED_1GB_FULL; | 324 | *speed |= IXGBE_LINK_SPEED_1GB_FULL; |
326 | } | 325 | } |
327 | 326 | ||
@@ -1153,13 +1152,13 @@ u32 ixgbe_get_supported_physical_layer_82599(struct ixgbe_hw *hw) | |||
1153 | 1152 | ||
1154 | if (hw->phy.type == ixgbe_phy_tn || | 1153 | if (hw->phy.type == ixgbe_phy_tn || |
1155 | hw->phy.type == ixgbe_phy_cu_unknown) { | 1154 | hw->phy.type == ixgbe_phy_cu_unknown) { |
1156 | hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_EXT_ABILITY, | 1155 | hw->phy.ops.read_reg(hw, MDIO_PMA_EXTABLE, MDIO_MMD_PMAPMD, |
1157 | IXGBE_MDIO_PMA_PMD_DEV_TYPE, &ext_ability); | 1156 | &ext_ability); |
1158 | if (ext_ability & IXGBE_MDIO_PHY_10GBASET_ABILITY) | 1157 | if (ext_ability & MDIO_PMA_EXTABLE_10GBT) |
1159 | physical_layer |= IXGBE_PHYSICAL_LAYER_10GBASE_T; | 1158 | physical_layer |= IXGBE_PHYSICAL_LAYER_10GBASE_T; |
1160 | if (ext_ability & IXGBE_MDIO_PHY_1000BASET_ABILITY) | 1159 | if (ext_ability & MDIO_PMA_EXTABLE_1000BT) |
1161 | physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_T; | 1160 | physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_T; |
1162 | if (ext_ability & IXGBE_MDIO_PHY_100BASETX_ABILITY) | 1161 | if (ext_ability & MDIO_PMA_EXTABLE_100BTX) |
1163 | physical_layer |= IXGBE_PHYSICAL_LAYER_100BASE_TX; | 1162 | physical_layer |= IXGBE_PHYSICAL_LAYER_100BASE_TX; |
1164 | goto out; | 1163 | goto out; |
1165 | } | 1164 | } |
diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c index 01a88265d401..661bed64407f 100644 --- a/drivers/net/ixgbe/ixgbe_main.c +++ b/drivers/net/ixgbe/ixgbe_main.c | |||
@@ -4642,6 +4642,40 @@ static int ixgbe_set_mac(struct net_device *netdev, void *p) | |||
4642 | return 0; | 4642 | return 0; |
4643 | } | 4643 | } |
4644 | 4644 | ||
4645 | static int | ||
4646 | ixgbe_mdio_read(struct net_device *netdev, int prtad, int devad, u16 addr) | ||
4647 | { | ||
4648 | struct ixgbe_adapter *adapter = netdev_priv(netdev); | ||
4649 | struct ixgbe_hw *hw = &adapter->hw; | ||
4650 | u16 value; | ||
4651 | int rc; | ||
4652 | |||
4653 | if (prtad != hw->phy.mdio.prtad) | ||
4654 | return -EINVAL; | ||
4655 | rc = hw->phy.ops.read_reg(hw, addr, devad, &value); | ||
4656 | if (!rc) | ||
4657 | rc = value; | ||
4658 | return rc; | ||
4659 | } | ||
4660 | |||
4661 | static int ixgbe_mdio_write(struct net_device *netdev, int prtad, int devad, | ||
4662 | u16 addr, u16 value) | ||
4663 | { | ||
4664 | struct ixgbe_adapter *adapter = netdev_priv(netdev); | ||
4665 | struct ixgbe_hw *hw = &adapter->hw; | ||
4666 | |||
4667 | if (prtad != hw->phy.mdio.prtad) | ||
4668 | return -EINVAL; | ||
4669 | return hw->phy.ops.write_reg(hw, addr, devad, value); | ||
4670 | } | ||
4671 | |||
4672 | static int ixgbe_ioctl(struct net_device *netdev, struct ifreq *req, int cmd) | ||
4673 | { | ||
4674 | struct ixgbe_adapter *adapter = netdev_priv(netdev); | ||
4675 | |||
4676 | return mdio_mii_ioctl(&adapter->hw.phy.mdio, if_mii(req), cmd); | ||
4677 | } | ||
4678 | |||
4645 | #ifdef CONFIG_NET_POLL_CONTROLLER | 4679 | #ifdef CONFIG_NET_POLL_CONTROLLER |
4646 | /* | 4680 | /* |
4647 | * Polling 'interrupt' - used by things like netconsole to send skbs | 4681 | * Polling 'interrupt' - used by things like netconsole to send skbs |
@@ -4675,6 +4709,7 @@ static const struct net_device_ops ixgbe_netdev_ops = { | |||
4675 | .ndo_vlan_rx_register = ixgbe_vlan_rx_register, | 4709 | .ndo_vlan_rx_register = ixgbe_vlan_rx_register, |
4676 | .ndo_vlan_rx_add_vid = ixgbe_vlan_rx_add_vid, | 4710 | .ndo_vlan_rx_add_vid = ixgbe_vlan_rx_add_vid, |
4677 | .ndo_vlan_rx_kill_vid = ixgbe_vlan_rx_kill_vid, | 4711 | .ndo_vlan_rx_kill_vid = ixgbe_vlan_rx_kill_vid, |
4712 | .ndo_do_ioctl = ixgbe_ioctl, | ||
4678 | #ifdef CONFIG_NET_POLL_CONTROLLER | 4713 | #ifdef CONFIG_NET_POLL_CONTROLLER |
4679 | .ndo_poll_controller = ixgbe_netpoll, | 4714 | .ndo_poll_controller = ixgbe_netpoll, |
4680 | #endif | 4715 | #endif |
@@ -4789,6 +4824,13 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev, | |||
4789 | /* PHY */ | 4824 | /* PHY */ |
4790 | memcpy(&hw->phy.ops, ii->phy_ops, sizeof(hw->phy.ops)); | 4825 | memcpy(&hw->phy.ops, ii->phy_ops, sizeof(hw->phy.ops)); |
4791 | hw->phy.sfp_type = ixgbe_sfp_type_unknown; | 4826 | hw->phy.sfp_type = ixgbe_sfp_type_unknown; |
4827 | /* ixgbe_identify_phy_generic will set prtad and mmds properly */ | ||
4828 | hw->phy.mdio.prtad = MDIO_PRTAD_NONE; | ||
4829 | hw->phy.mdio.mmds = 0; | ||
4830 | hw->phy.mdio.mode_support = MDIO_SUPPORTS_C45 | MDIO_EMULATE_C22; | ||
4831 | hw->phy.mdio.dev = netdev; | ||
4832 | hw->phy.mdio.mdio_read = ixgbe_mdio_read; | ||
4833 | hw->phy.mdio.mdio_write = ixgbe_mdio_write; | ||
4792 | 4834 | ||
4793 | /* set up this timer and work struct before calling get_invariants | 4835 | /* set up this timer and work struct before calling get_invariants |
4794 | * which might start the timer | 4836 | * which might start the timer |
diff --git a/drivers/net/ixgbe/ixgbe_phy.c b/drivers/net/ixgbe/ixgbe_phy.c index 2543c32ca84a..6d385ea3c2a1 100644 --- a/drivers/net/ixgbe/ixgbe_phy.c +++ b/drivers/net/ixgbe/ixgbe_phy.c | |||
@@ -44,7 +44,6 @@ static void ixgbe_lower_i2c_clk(struct ixgbe_hw *hw, u32 *i2cctl); | |||
44 | static s32 ixgbe_set_i2c_data(struct ixgbe_hw *hw, u32 *i2cctl, bool data); | 44 | static s32 ixgbe_set_i2c_data(struct ixgbe_hw *hw, u32 *i2cctl, bool data); |
45 | static bool ixgbe_get_i2c_data(u32 *i2cctl); | 45 | static bool ixgbe_get_i2c_data(u32 *i2cctl); |
46 | static void ixgbe_i2c_bus_clear(struct ixgbe_hw *hw); | 46 | static void ixgbe_i2c_bus_clear(struct ixgbe_hw *hw); |
47 | static bool ixgbe_validate_phy_addr(struct ixgbe_hw *hw, u32 phy_addr); | ||
48 | static enum ixgbe_phy_type ixgbe_get_phy_type_from_id(u32 phy_id); | 47 | static enum ixgbe_phy_type ixgbe_get_phy_type_from_id(u32 phy_id); |
49 | static s32 ixgbe_get_phy_id(struct ixgbe_hw *hw); | 48 | static s32 ixgbe_get_phy_id(struct ixgbe_hw *hw); |
50 | 49 | ||
@@ -61,8 +60,7 @@ s32 ixgbe_identify_phy_generic(struct ixgbe_hw *hw) | |||
61 | 60 | ||
62 | if (hw->phy.type == ixgbe_phy_unknown) { | 61 | if (hw->phy.type == ixgbe_phy_unknown) { |
63 | for (phy_addr = 0; phy_addr < IXGBE_MAX_PHY_ADDR; phy_addr++) { | 62 | for (phy_addr = 0; phy_addr < IXGBE_MAX_PHY_ADDR; phy_addr++) { |
64 | if (ixgbe_validate_phy_addr(hw, phy_addr)) { | 63 | if (mdio45_probe(&hw->phy.mdio, phy_addr) == 0) { |
65 | hw->phy.addr = phy_addr; | ||
66 | ixgbe_get_phy_id(hw); | 64 | ixgbe_get_phy_id(hw); |
67 | hw->phy.type = | 65 | hw->phy.type = |
68 | ixgbe_get_phy_type_from_id(hw->phy.id); | 66 | ixgbe_get_phy_type_from_id(hw->phy.id); |
@@ -78,26 +76,6 @@ s32 ixgbe_identify_phy_generic(struct ixgbe_hw *hw) | |||
78 | } | 76 | } |
79 | 77 | ||
80 | /** | 78 | /** |
81 | * ixgbe_validate_phy_addr - Determines phy address is valid | ||
82 | * @hw: pointer to hardware structure | ||
83 | * | ||
84 | **/ | ||
85 | static bool ixgbe_validate_phy_addr(struct ixgbe_hw *hw, u32 phy_addr) | ||
86 | { | ||
87 | u16 phy_id = 0; | ||
88 | bool valid = false; | ||
89 | |||
90 | hw->phy.addr = phy_addr; | ||
91 | hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_ID_HIGH, | ||
92 | IXGBE_MDIO_PMA_PMD_DEV_TYPE, &phy_id); | ||
93 | |||
94 | if (phy_id != 0xFFFF && phy_id != 0x0) | ||
95 | valid = true; | ||
96 | |||
97 | return valid; | ||
98 | } | ||
99 | |||
100 | /** | ||
101 | * ixgbe_get_phy_id - Get the phy type | 79 | * ixgbe_get_phy_id - Get the phy type |
102 | * @hw: pointer to hardware structure | 80 | * @hw: pointer to hardware structure |
103 | * | 81 | * |
@@ -108,14 +86,12 @@ static s32 ixgbe_get_phy_id(struct ixgbe_hw *hw) | |||
108 | u16 phy_id_high = 0; | 86 | u16 phy_id_high = 0; |
109 | u16 phy_id_low = 0; | 87 | u16 phy_id_low = 0; |
110 | 88 | ||
111 | status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_ID_HIGH, | 89 | status = hw->phy.ops.read_reg(hw, MDIO_DEVID1, MDIO_MMD_PMAPMD, |
112 | IXGBE_MDIO_PMA_PMD_DEV_TYPE, | ||
113 | &phy_id_high); | 90 | &phy_id_high); |
114 | 91 | ||
115 | if (status == 0) { | 92 | if (status == 0) { |
116 | hw->phy.id = (u32)(phy_id_high << 16); | 93 | hw->phy.id = (u32)(phy_id_high << 16); |
117 | status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_ID_LOW, | 94 | status = hw->phy.ops.read_reg(hw, MDIO_DEVID2, MDIO_MMD_PMAPMD, |
118 | IXGBE_MDIO_PMA_PMD_DEV_TYPE, | ||
119 | &phy_id_low); | 95 | &phy_id_low); |
120 | hw->phy.id |= (u32)(phy_id_low & IXGBE_PHY_REVISION_MASK); | 96 | hw->phy.id |= (u32)(phy_id_low & IXGBE_PHY_REVISION_MASK); |
121 | hw->phy.revision = (u32)(phy_id_low & ~IXGBE_PHY_REVISION_MASK); | 97 | hw->phy.revision = (u32)(phy_id_low & ~IXGBE_PHY_REVISION_MASK); |
@@ -160,9 +136,8 @@ s32 ixgbe_reset_phy_generic(struct ixgbe_hw *hw) | |||
160 | * Perform soft PHY reset to the PHY_XS. | 136 | * Perform soft PHY reset to the PHY_XS. |
161 | * This will cause a soft reset to the PHY | 137 | * This will cause a soft reset to the PHY |
162 | */ | 138 | */ |
163 | return hw->phy.ops.write_reg(hw, IXGBE_MDIO_PHY_XS_CONTROL, | 139 | return hw->phy.ops.write_reg(hw, MDIO_CTRL1, MDIO_MMD_PHYXS, |
164 | IXGBE_MDIO_PHY_XS_DEV_TYPE, | 140 | MDIO_CTRL1_RESET); |
165 | IXGBE_MDIO_PHY_XS_RESET); | ||
166 | } | 141 | } |
167 | 142 | ||
168 | /** | 143 | /** |
@@ -192,7 +167,7 @@ s32 ixgbe_read_phy_reg_generic(struct ixgbe_hw *hw, u32 reg_addr, | |||
192 | /* Setup and write the address cycle command */ | 167 | /* Setup and write the address cycle command */ |
193 | command = ((reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT) | | 168 | command = ((reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT) | |
194 | (device_type << IXGBE_MSCA_DEV_TYPE_SHIFT) | | 169 | (device_type << IXGBE_MSCA_DEV_TYPE_SHIFT) | |
195 | (hw->phy.addr << IXGBE_MSCA_PHY_ADDR_SHIFT) | | 170 | (hw->phy.mdio.prtad << IXGBE_MSCA_PHY_ADDR_SHIFT) | |
196 | (IXGBE_MSCA_ADDR_CYCLE | IXGBE_MSCA_MDI_COMMAND)); | 171 | (IXGBE_MSCA_ADDR_CYCLE | IXGBE_MSCA_MDI_COMMAND)); |
197 | 172 | ||
198 | IXGBE_WRITE_REG(hw, IXGBE_MSCA, command); | 173 | IXGBE_WRITE_REG(hw, IXGBE_MSCA, command); |
@@ -223,7 +198,8 @@ s32 ixgbe_read_phy_reg_generic(struct ixgbe_hw *hw, u32 reg_addr, | |||
223 | */ | 198 | */ |
224 | command = ((reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT) | | 199 | command = ((reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT) | |
225 | (device_type << IXGBE_MSCA_DEV_TYPE_SHIFT) | | 200 | (device_type << IXGBE_MSCA_DEV_TYPE_SHIFT) | |
226 | (hw->phy.addr << IXGBE_MSCA_PHY_ADDR_SHIFT) | | 201 | (hw->phy.mdio.prtad << |
202 | IXGBE_MSCA_PHY_ADDR_SHIFT) | | ||
227 | (IXGBE_MSCA_READ | IXGBE_MSCA_MDI_COMMAND)); | 203 | (IXGBE_MSCA_READ | IXGBE_MSCA_MDI_COMMAND)); |
228 | 204 | ||
229 | IXGBE_WRITE_REG(hw, IXGBE_MSCA, command); | 205 | IXGBE_WRITE_REG(hw, IXGBE_MSCA, command); |
@@ -292,7 +268,7 @@ s32 ixgbe_write_phy_reg_generic(struct ixgbe_hw *hw, u32 reg_addr, | |||
292 | /* Setup and write the address cycle command */ | 268 | /* Setup and write the address cycle command */ |
293 | command = ((reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT) | | 269 | command = ((reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT) | |
294 | (device_type << IXGBE_MSCA_DEV_TYPE_SHIFT) | | 270 | (device_type << IXGBE_MSCA_DEV_TYPE_SHIFT) | |
295 | (hw->phy.addr << IXGBE_MSCA_PHY_ADDR_SHIFT) | | 271 | (hw->phy.mdio.prtad << IXGBE_MSCA_PHY_ADDR_SHIFT) | |
296 | (IXGBE_MSCA_ADDR_CYCLE | IXGBE_MSCA_MDI_COMMAND)); | 272 | (IXGBE_MSCA_ADDR_CYCLE | IXGBE_MSCA_MDI_COMMAND)); |
297 | 273 | ||
298 | IXGBE_WRITE_REG(hw, IXGBE_MSCA, command); | 274 | IXGBE_WRITE_REG(hw, IXGBE_MSCA, command); |
@@ -323,7 +299,8 @@ s32 ixgbe_write_phy_reg_generic(struct ixgbe_hw *hw, u32 reg_addr, | |||
323 | */ | 299 | */ |
324 | command = ((reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT) | | 300 | command = ((reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT) | |
325 | (device_type << IXGBE_MSCA_DEV_TYPE_SHIFT) | | 301 | (device_type << IXGBE_MSCA_DEV_TYPE_SHIFT) | |
326 | (hw->phy.addr << IXGBE_MSCA_PHY_ADDR_SHIFT) | | 302 | (hw->phy.mdio.prtad << |
303 | IXGBE_MSCA_PHY_ADDR_SHIFT) | | ||
327 | (IXGBE_MSCA_WRITE | IXGBE_MSCA_MDI_COMMAND)); | 304 | (IXGBE_MSCA_WRITE | IXGBE_MSCA_MDI_COMMAND)); |
328 | 305 | ||
329 | IXGBE_WRITE_REG(hw, IXGBE_MSCA, command); | 306 | IXGBE_WRITE_REG(hw, IXGBE_MSCA, command); |
@@ -365,7 +342,7 @@ s32 ixgbe_setup_phy_link_generic(struct ixgbe_hw *hw) | |||
365 | s32 status = IXGBE_NOT_IMPLEMENTED; | 342 | s32 status = IXGBE_NOT_IMPLEMENTED; |
366 | u32 time_out; | 343 | u32 time_out; |
367 | u32 max_time_out = 10; | 344 | u32 max_time_out = 10; |
368 | u16 autoneg_reg = IXGBE_MII_AUTONEG_REG; | 345 | u16 autoneg_reg; |
369 | 346 | ||
370 | /* | 347 | /* |
371 | * Set advertisement settings in PHY based on autoneg_advertised | 348 | * Set advertisement settings in PHY based on autoneg_advertised |
@@ -373,36 +350,31 @@ s32 ixgbe_setup_phy_link_generic(struct ixgbe_hw *hw) | |||
373 | * tnx devices cannot be "forced" to a autoneg 10G and fail. But can | 350 | * tnx devices cannot be "forced" to a autoneg 10G and fail. But can |
374 | * for a 1G. | 351 | * for a 1G. |
375 | */ | 352 | */ |
376 | hw->phy.ops.read_reg(hw, IXGBE_MII_SPEED_SELECTION_REG, | 353 | hw->phy.ops.read_reg(hw, MDIO_AN_ADVERTISE, MDIO_MMD_AN, &autoneg_reg); |
377 | IXGBE_MDIO_AUTO_NEG_DEV_TYPE, &autoneg_reg); | ||
378 | 354 | ||
379 | if (hw->phy.autoneg_advertised == IXGBE_LINK_SPEED_1GB_FULL) | 355 | if (hw->phy.autoneg_advertised == IXGBE_LINK_SPEED_1GB_FULL) |
380 | autoneg_reg &= 0xEFFF; /* 0 in bit 12 is 1G operation */ | 356 | autoneg_reg &= ~MDIO_AN_10GBT_CTRL_ADV10G; |
381 | else | 357 | else |
382 | autoneg_reg |= 0x1000; /* 1 in bit 12 is 10G/1G operation */ | 358 | autoneg_reg |= MDIO_AN_10GBT_CTRL_ADV10G; |
383 | 359 | ||
384 | hw->phy.ops.write_reg(hw, IXGBE_MII_SPEED_SELECTION_REG, | 360 | hw->phy.ops.write_reg(hw, MDIO_AN_ADVERTISE, MDIO_MMD_AN, autoneg_reg); |
385 | IXGBE_MDIO_AUTO_NEG_DEV_TYPE, autoneg_reg); | ||
386 | 361 | ||
387 | /* Restart PHY autonegotiation and wait for completion */ | 362 | /* Restart PHY autonegotiation and wait for completion */ |
388 | hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_CONTROL, | 363 | hw->phy.ops.read_reg(hw, MDIO_CTRL1, MDIO_MMD_AN, &autoneg_reg); |
389 | IXGBE_MDIO_AUTO_NEG_DEV_TYPE, &autoneg_reg); | ||
390 | 364 | ||
391 | autoneg_reg |= IXGBE_MII_RESTART; | 365 | autoneg_reg |= MDIO_AN_CTRL1_RESTART; |
392 | 366 | ||
393 | hw->phy.ops.write_reg(hw, IXGBE_MDIO_AUTO_NEG_CONTROL, | 367 | hw->phy.ops.write_reg(hw, MDIO_CTRL1, MDIO_MMD_AN, autoneg_reg); |
394 | IXGBE_MDIO_AUTO_NEG_DEV_TYPE, autoneg_reg); | ||
395 | 368 | ||
396 | /* Wait for autonegotiation to finish */ | 369 | /* Wait for autonegotiation to finish */ |
397 | for (time_out = 0; time_out < max_time_out; time_out++) { | 370 | for (time_out = 0; time_out < max_time_out; time_out++) { |
398 | udelay(10); | 371 | udelay(10); |
399 | /* Restart PHY autonegotiation and wait for completion */ | 372 | /* Restart PHY autonegotiation and wait for completion */ |
400 | status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS, | 373 | status = hw->phy.ops.read_reg(hw, MDIO_STAT1, MDIO_MMD_AN, |
401 | IXGBE_MDIO_AUTO_NEG_DEV_TYPE, | ||
402 | &autoneg_reg); | 374 | &autoneg_reg); |
403 | 375 | ||
404 | autoneg_reg &= IXGBE_MII_AUTONEG_COMPLETE; | 376 | autoneg_reg &= MDIO_AN_STAT1_COMPLETE; |
405 | if (autoneg_reg == IXGBE_MII_AUTONEG_COMPLETE) { | 377 | if (autoneg_reg == MDIO_AN_STAT1_COMPLETE) { |
406 | status = 0; | 378 | status = 0; |
407 | break; | 379 | break; |
408 | } | 380 | } |
@@ -457,23 +429,21 @@ s32 ixgbe_reset_phy_nl(struct ixgbe_hw *hw) | |||
457 | s32 ret_val = 0; | 429 | s32 ret_val = 0; |
458 | u32 i; | 430 | u32 i; |
459 | 431 | ||
460 | hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_XS_CONTROL, | 432 | hw->phy.ops.read_reg(hw, MDIO_CTRL1, MDIO_MMD_PHYXS, &phy_data); |
461 | IXGBE_MDIO_PHY_XS_DEV_TYPE, &phy_data); | ||
462 | 433 | ||
463 | /* reset the PHY and poll for completion */ | 434 | /* reset the PHY and poll for completion */ |
464 | hw->phy.ops.write_reg(hw, IXGBE_MDIO_PHY_XS_CONTROL, | 435 | hw->phy.ops.write_reg(hw, MDIO_CTRL1, MDIO_MMD_PHYXS, |
465 | IXGBE_MDIO_PHY_XS_DEV_TYPE, | 436 | (phy_data | MDIO_CTRL1_RESET)); |
466 | (phy_data | IXGBE_MDIO_PHY_XS_RESET)); | ||
467 | 437 | ||
468 | for (i = 0; i < 100; i++) { | 438 | for (i = 0; i < 100; i++) { |
469 | hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_XS_CONTROL, | 439 | hw->phy.ops.read_reg(hw, MDIO_CTRL1, MDIO_MMD_PHYXS, |
470 | IXGBE_MDIO_PHY_XS_DEV_TYPE, &phy_data); | 440 | &phy_data); |
471 | if ((phy_data & IXGBE_MDIO_PHY_XS_RESET) == 0) | 441 | if ((phy_data & MDIO_CTRL1_RESET) == 0) |
472 | break; | 442 | break; |
473 | msleep(10); | 443 | msleep(10); |
474 | } | 444 | } |
475 | 445 | ||
476 | if ((phy_data & IXGBE_MDIO_PHY_XS_RESET) != 0) { | 446 | if ((phy_data & MDIO_CTRL1_RESET) != 0) { |
477 | hw_dbg(hw, "PHY reset did not complete.\n"); | 447 | hw_dbg(hw, "PHY reset did not complete.\n"); |
478 | ret_val = IXGBE_ERR_PHY; | 448 | ret_val = IXGBE_ERR_PHY; |
479 | goto out; | 449 | goto out; |
@@ -509,7 +479,7 @@ s32 ixgbe_reset_phy_nl(struct ixgbe_hw *hw) | |||
509 | for (i = 0; i < edata; i++) { | 479 | for (i = 0; i < edata; i++) { |
510 | hw->eeprom.ops.read(hw, data_offset, &eword); | 480 | hw->eeprom.ops.read(hw, data_offset, &eword); |
511 | hw->phy.ops.write_reg(hw, phy_offset, | 481 | hw->phy.ops.write_reg(hw, phy_offset, |
512 | IXGBE_TWINAX_DEV, eword); | 482 | MDIO_MMD_PMAPMD, eword); |
513 | hw_dbg(hw, "Wrote %4.4x to %4.4x\n", eword, | 483 | hw_dbg(hw, "Wrote %4.4x to %4.4x\n", eword, |
514 | phy_offset); | 484 | phy_offset); |
515 | data_offset++; | 485 | data_offset++; |
@@ -1302,7 +1272,7 @@ s32 ixgbe_check_phy_link_tnx(struct ixgbe_hw *hw, ixgbe_link_speed *speed, | |||
1302 | udelay(10); | 1272 | udelay(10); |
1303 | status = hw->phy.ops.read_reg(hw, | 1273 | status = hw->phy.ops.read_reg(hw, |
1304 | IXGBE_MDIO_VENDOR_SPECIFIC_1_STATUS, | 1274 | IXGBE_MDIO_VENDOR_SPECIFIC_1_STATUS, |
1305 | IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, | 1275 | MDIO_MMD_VEND1, |
1306 | &phy_data); | 1276 | &phy_data); |
1307 | phy_link = phy_data & | 1277 | phy_link = phy_data & |
1308 | IXGBE_MDIO_VENDOR_SPECIFIC_1_LINK_STATUS; | 1278 | IXGBE_MDIO_VENDOR_SPECIFIC_1_LINK_STATUS; |
@@ -1330,8 +1300,7 @@ s32 ixgbe_get_phy_firmware_version_tnx(struct ixgbe_hw *hw, | |||
1330 | { | 1300 | { |
1331 | s32 status = 0; | 1301 | s32 status = 0; |
1332 | 1302 | ||
1333 | status = hw->phy.ops.read_reg(hw, TNX_FW_REV, | 1303 | status = hw->phy.ops.read_reg(hw, TNX_FW_REV, MDIO_MMD_VEND1, |
1334 | IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, | ||
1335 | firmware_version); | 1304 | firmware_version); |
1336 | 1305 | ||
1337 | return status; | 1306 | return status; |
diff --git a/drivers/net/ixgbe/ixgbe_type.h b/drivers/net/ixgbe/ixgbe_type.h index bdfdf3bca273..e49e8af59eda 100644 --- a/drivers/net/ixgbe/ixgbe_type.h +++ b/drivers/net/ixgbe/ixgbe_type.h | |||
@@ -29,6 +29,7 @@ | |||
29 | #define _IXGBE_TYPE_H_ | 29 | #define _IXGBE_TYPE_H_ |
30 | 30 | ||
31 | #include <linux/types.h> | 31 | #include <linux/types.h> |
32 | #include <linux/mdio.h> | ||
32 | 33 | ||
33 | /* Vendor ID */ | 34 | /* Vendor ID */ |
34 | #define IXGBE_INTEL_VENDOR_ID 0x8086 | 35 | #define IXGBE_INTEL_VENDOR_ID 0x8086 |
@@ -848,13 +849,7 @@ | |||
848 | /* Omer bit masks */ | 849 | /* Omer bit masks */ |
849 | #define IXGBE_CORECTL_WRITE_CMD 0x00010000 | 850 | #define IXGBE_CORECTL_WRITE_CMD 0x00010000 |
850 | 851 | ||
851 | /* Device Type definitions for new protocol MDIO commands */ | 852 | /* MDIO definitions */ |
852 | #define IXGBE_MDIO_PMA_PMD_DEV_TYPE 0x1 | ||
853 | #define IXGBE_MDIO_PCS_DEV_TYPE 0x3 | ||
854 | #define IXGBE_MDIO_PHY_XS_DEV_TYPE 0x4 | ||
855 | #define IXGBE_MDIO_AUTO_NEG_DEV_TYPE 0x7 | ||
856 | #define IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE 0x1E /* Device 30 */ | ||
857 | #define IXGBE_TWINAX_DEV 1 | ||
858 | 853 | ||
859 | #define IXGBE_MDIO_COMMAND_TIMEOUT 100 /* PHY Timeout for 1 GB mode */ | 854 | #define IXGBE_MDIO_COMMAND_TIMEOUT 100 /* PHY Timeout for 1 GB mode */ |
860 | 855 | ||
@@ -865,32 +860,10 @@ | |||
865 | #define IXGBE_MDIO_VENDOR_SPECIFIC_1_10G_SPEED 0x0018 | 860 | #define IXGBE_MDIO_VENDOR_SPECIFIC_1_10G_SPEED 0x0018 |
866 | #define IXGBE_MDIO_VENDOR_SPECIFIC_1_1G_SPEED 0x0010 | 861 | #define IXGBE_MDIO_VENDOR_SPECIFIC_1_1G_SPEED 0x0010 |
867 | 862 | ||
868 | #define IXGBE_MDIO_AUTO_NEG_CONTROL 0x0 /* AUTO_NEG Control Reg */ | ||
869 | #define IXGBE_MDIO_AUTO_NEG_STATUS 0x1 /* AUTO_NEG Status Reg */ | ||
870 | #define IXGBE_MDIO_PHY_XS_CONTROL 0x0 /* PHY_XS Control Reg */ | ||
871 | #define IXGBE_MDIO_PHY_XS_RESET 0x8000 /* PHY_XS Reset */ | ||
872 | #define IXGBE_MDIO_PHY_ID_HIGH 0x2 /* PHY ID High Reg*/ | ||
873 | #define IXGBE_MDIO_PHY_ID_LOW 0x3 /* PHY ID Low Reg*/ | ||
874 | #define IXGBE_MDIO_PHY_SPEED_ABILITY 0x4 /* Speed Ability Reg */ | ||
875 | #define IXGBE_MDIO_PHY_SPEED_10G 0x0001 /* 10G capable */ | ||
876 | #define IXGBE_MDIO_PHY_SPEED_1G 0x0010 /* 1G capable */ | ||
877 | #define IXGBE_MDIO_PHY_EXT_ABILITY 0xB /* Ext Ability Reg */ | ||
878 | #define IXGBE_MDIO_PHY_10GBASET_ABILITY 0x0004 /* 10GBaseT capable */ | ||
879 | #define IXGBE_MDIO_PHY_1000BASET_ABILITY 0x0020 /* 1000BaseT capable */ | ||
880 | #define IXGBE_MDIO_PHY_100BASETX_ABILITY 0x0080 /* 100BaseTX capable */ | ||
881 | |||
882 | #define IXGBE_MDIO_PMA_PMD_SDA_SCL_ADDR 0xC30A /* PHY_XS SDA/SCL Addr Reg */ | 863 | #define IXGBE_MDIO_PMA_PMD_SDA_SCL_ADDR 0xC30A /* PHY_XS SDA/SCL Addr Reg */ |
883 | #define IXGBE_MDIO_PMA_PMD_SDA_SCL_DATA 0xC30B /* PHY_XS SDA/SCL Data Reg */ | 864 | #define IXGBE_MDIO_PMA_PMD_SDA_SCL_DATA 0xC30B /* PHY_XS SDA/SCL Data Reg */ |
884 | #define IXGBE_MDIO_PMA_PMD_SDA_SCL_STAT 0xC30C /* PHY_XS SDA/SCL Status Reg */ | 865 | #define IXGBE_MDIO_PMA_PMD_SDA_SCL_STAT 0xC30C /* PHY_XS SDA/SCL Status Reg */ |
885 | 866 | ||
886 | /* MII clause 22/28 definitions */ | ||
887 | #define IXGBE_MDIO_PHY_LOW_POWER_MODE 0x0800 | ||
888 | |||
889 | #define IXGBE_MII_SPEED_SELECTION_REG 0x10 | ||
890 | #define IXGBE_MII_RESTART 0x200 | ||
891 | #define IXGBE_MII_AUTONEG_COMPLETE 0x20 | ||
892 | #define IXGBE_MII_AUTONEG_REG 0x0 | ||
893 | |||
894 | #define IXGBE_PHY_REVISION_MASK 0xFFFFFFF0 | 867 | #define IXGBE_PHY_REVISION_MASK 0xFFFFFFF0 |
895 | #define IXGBE_MAX_PHY_ADDR 32 | 868 | #define IXGBE_MAX_PHY_ADDR 32 |
896 | 869 | ||
@@ -2214,8 +2187,8 @@ struct ixgbe_mac_info { | |||
2214 | 2187 | ||
2215 | struct ixgbe_phy_info { | 2188 | struct ixgbe_phy_info { |
2216 | struct ixgbe_phy_operations ops; | 2189 | struct ixgbe_phy_operations ops; |
2190 | struct mdio_if_info mdio; | ||
2217 | enum ixgbe_phy_type type; | 2191 | enum ixgbe_phy_type type; |
2218 | u32 addr; | ||
2219 | u32 id; | 2192 | u32 id; |
2220 | enum ixgbe_sfp_type sfp_type; | 2193 | enum ixgbe_sfp_type sfp_type; |
2221 | bool sfp_setup_needed; | 2194 | bool sfp_setup_needed; |