aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bnx2x/bnx2x_link.c
diff options
context:
space:
mode:
authorYaniv Rosner <yaniv.rosner@broadcom.com>2010-09-07 07:41:04 -0400
committerDavid S. Miller <davem@davemloft.net>2010-09-07 16:15:30 -0400
commitd90d96baf0cc044bcdedc9ee9e925b5937865673 (patch)
tree7d0861e20126ac481be80454ae33521aaed9f81d /drivers/net/bnx2x/bnx2x_link.c
parent7aa0711f32bf911add9e2ced165f8006864f973e (diff)
bnx2x: Move common function into aggregated function
Move all PHY specific logic from bnx2x_main into bnx2x_link. Signed-off-by: Yaniv Rosner <yanivr@broadcom.com> Signed-off-by: Eilon Greenstein <eilong@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bnx2x/bnx2x_link.c')
-rw-r--r--drivers/net/bnx2x/bnx2x_link.c95
1 files changed, 88 insertions, 7 deletions
diff --git a/drivers/net/bnx2x/bnx2x_link.c b/drivers/net/bnx2x/bnx2x_link.c
index bb42104b2377..72ac8dcf6e20 100644
--- a/drivers/net/bnx2x/bnx2x_link.c
+++ b/drivers/net/bnx2x/bnx2x_link.c
@@ -2079,7 +2079,7 @@ static u8 bnx2x_init_xgxs(struct bnx2x_phy *phy,
2079 return rc; 2079 return rc;
2080} 2080}
2081/*****************************************************************************/ 2081/*****************************************************************************/
2082/* External Phy section */ 2082/* External Phy section */
2083/*****************************************************************************/ 2083/*****************************************************************************/
2084void bnx2x_ext_phy_hw_reset(struct bnx2x *bp, u8 port) 2084void bnx2x_ext_phy_hw_reset(struct bnx2x *bp, u8 port)
2085{ 2085{
@@ -3271,6 +3271,8 @@ static u8 bnx2x_8726_config_init(struct bnx2x_phy *phy,
3271 struct link_vars *vars) 3271 struct link_vars *vars)
3272{ 3272{
3273 struct bnx2x *bp = params->bp; 3273 struct bnx2x *bp = params->bp;
3274 u32 val;
3275 u32 swap_val, swap_override, aeu_gpio_mask, offset;
3274 DP(NETIF_MSG_LINK, "Initializing BCM8726\n"); 3276 DP(NETIF_MSG_LINK, "Initializing BCM8726\n");
3275 /* Restore normal power mode*/ 3277 /* Restore normal power mode*/
3276 bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, 3278 bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2,
@@ -3351,6 +3353,31 @@ static u8 bnx2x_8726_config_init(struct bnx2x_phy *phy,
3351 MDIO_PMA_REG_8726_TX_CTRL2, 3353 MDIO_PMA_REG_8726_TX_CTRL2,
3352 phy->tx_preemphasis[1]); 3354 phy->tx_preemphasis[1]);
3353 } 3355 }
3356
3357 /* Set GPIO3 to trigger SFP+ module insertion/removal */
3358 bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_3,
3359 MISC_REGISTERS_GPIO_INPUT_HI_Z, params->port);
3360
3361 /* The GPIO should be swapped if the swap register is set and active */
3362 swap_val = REG_RD(bp, NIG_REG_PORT_SWAP);
3363 swap_override = REG_RD(bp, NIG_REG_STRAP_OVERRIDE);
3364
3365 /* Select function upon port-swap configuration */
3366 if (params->port == 0) {
3367 offset = MISC_REG_AEU_ENABLE1_FUNC_0_OUT_0;
3368 aeu_gpio_mask = (swap_val && swap_override) ?
3369 AEU_INPUTS_ATTN_BITS_GPIO3_FUNCTION_1 :
3370 AEU_INPUTS_ATTN_BITS_GPIO3_FUNCTION_0;
3371 } else {
3372 offset = MISC_REG_AEU_ENABLE1_FUNC_1_OUT_0;
3373 aeu_gpio_mask = (swap_val && swap_override) ?
3374 AEU_INPUTS_ATTN_BITS_GPIO3_FUNCTION_0 :
3375 AEU_INPUTS_ATTN_BITS_GPIO3_FUNCTION_1;
3376 }
3377 val = REG_RD(bp, offset);
3378 /* add GPIO3 to group */
3379 val |= aeu_gpio_mask;
3380 REG_WR(bp, offset, val);
3354 return 0; 3381 return 0;
3355 3382
3356} 3383}
@@ -4888,10 +4915,9 @@ u8 bnx2x_test_link(struct link_params *params, struct link_vars *vars)
4888} 4915}
4889 4916
4890static u8 bnx2x_link_initialize(struct link_params *params, 4917static u8 bnx2x_link_initialize(struct link_params *params,
4891 struct link_vars *vars) 4918 struct link_vars *vars)
4892{ 4919{
4893 struct bnx2x *bp = params->bp; 4920 struct bnx2x *bp = params->bp;
4894 u8 port = params->port;
4895 u8 rc = 0; 4921 u8 rc = 0;
4896 u8 phy_index, non_ext_phy; 4922 u8 phy_index, non_ext_phy;
4897 struct bnx2x_phy *ext_phy = &params->phy[EXT_PHY1]; 4923 struct bnx2x_phy *ext_phy = &params->phy[EXT_PHY1];
@@ -4964,10 +4990,13 @@ static u8 bnx2x_link_initialize(struct link_params *params,
4964 params, vars); 4990 params, vars);
4965 } 4991 }
4966 4992
4967 bnx2x_bits_dis(bp, NIG_REG_STATUS_INTERRUPT_PORT0 + port*4, 4993 /* Reset the interrupt indication after phy was initialized */
4968 (NIG_STATUS_XGXS0_LINK10G | 4994 bnx2x_bits_dis(bp, NIG_REG_STATUS_INTERRUPT_PORT0 +
4969 NIG_STATUS_XGXS0_LINK_STATUS | 4995 params->port*4,
4970 NIG_STATUS_SERDES0_LINK_STATUS)); 4996 (NIG_STATUS_XGXS0_LINK10G |
4997 NIG_STATUS_XGXS0_LINK_STATUS |
4998 NIG_STATUS_SERDES0_LINK_STATUS |
4999 NIG_MASK_MI_INT));
4971 5000
4972 return rc; 5001 return rc;
4973} 5002}
@@ -6515,3 +6544,55 @@ void bnx2x_sfx7101_sp_sw_reset(struct bnx2x *bp, struct bnx2x_phy *phy)
6515 break; 6544 break;
6516 } 6545 }
6517} 6546}
6547
6548u8 bnx2x_hw_lock_required(struct bnx2x *bp, u32 shmem_base)
6549{
6550 u8 phy_index;
6551 struct bnx2x_phy phy;
6552 for (phy_index = INT_PHY; phy_index < MAX_PHYS;
6553 phy_index++) {
6554 if (bnx2x_populate_phy(bp, phy_index, shmem_base,
6555 0, &phy) != 0) {
6556 DP(NETIF_MSG_LINK, "populate phy failed\n");
6557 return 0;
6558 }
6559
6560 if (phy.flags & FLAGS_HW_LOCK_REQUIRED)
6561 return 1;
6562 }
6563 return 0;
6564}
6565
6566u8 bnx2x_fan_failure_det_req(struct bnx2x *bp,
6567 u32 shmem_base,
6568 u8 port)
6569{
6570 u8 phy_index, fan_failure_det_req = 0;
6571 struct bnx2x_phy phy;
6572 for (phy_index = EXT_PHY1; phy_index < MAX_PHYS;
6573 phy_index++) {
6574 if (bnx2x_populate_phy(bp, phy_index, shmem_base,
6575 port, &phy)
6576 != 0) {
6577 DP(NETIF_MSG_LINK, "populate phy failed\n");
6578 return 0;
6579 }
6580 fan_failure_det_req |= (phy.flags &
6581 FLAGS_FAN_FAILURE_DET_REQ);
6582 }
6583 return fan_failure_det_req;
6584}
6585
6586void bnx2x_hw_reset_phy(struct link_params *params)
6587{
6588 u8 phy_index;
6589 for (phy_index = EXT_PHY1; phy_index < MAX_PHYS;
6590 phy_index++) {
6591 if (params->phy[phy_index].hw_reset) {
6592 params->phy[phy_index].hw_reset(
6593 &params->phy[phy_index],
6594 params);
6595 params->phy[phy_index] = phy_null;
6596 }
6597 }
6598}