diff options
author | Yaniv Rosner <yaniv.rosner@broadcom.com> | 2010-09-07 07:41:04 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-09-07 16:15:30 -0400 |
commit | d90d96baf0cc044bcdedc9ee9e925b5937865673 (patch) | |
tree | 7d0861e20126ac481be80454ae33521aaed9f81d /drivers/net/bnx2x | |
parent | 7aa0711f32bf911add9e2ced165f8006864f973e (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')
-rw-r--r-- | drivers/net/bnx2x/bnx2x_link.c | 95 | ||||
-rw-r--r-- | drivers/net/bnx2x/bnx2x_link.h | 8 | ||||
-rw-r--r-- | drivers/net/bnx2x/bnx2x_main.c | 103 |
3 files changed, 108 insertions, 98 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 | /*****************************************************************************/ |
2084 | void bnx2x_ext_phy_hw_reset(struct bnx2x *bp, u8 port) | 2084 | void 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 | ||
4890 | static u8 bnx2x_link_initialize(struct link_params *params, | 4917 | static 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 = ¶ms->phy[EXT_PHY1]; | 4923 | struct bnx2x_phy *ext_phy = ¶ms->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 | |||
6548 | u8 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 | |||
6566 | u8 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 | |||
6586 | void 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 | ¶ms->phy[phy_index], | ||
6594 | params); | ||
6595 | params->phy[phy_index] = phy_null; | ||
6596 | } | ||
6597 | } | ||
6598 | } | ||
diff --git a/drivers/net/bnx2x/bnx2x_link.h b/drivers/net/bnx2x/bnx2x_link.h index 9717cb1fbad0..d663c4f3c265 100644 --- a/drivers/net/bnx2x/bnx2x_link.h +++ b/drivers/net/bnx2x/bnx2x_link.h | |||
@@ -311,8 +311,16 @@ void bnx2x_sfx7101_sp_sw_reset(struct bnx2x *bp, struct bnx2x_phy *phy); | |||
311 | u8 bnx2x_read_sfp_module_eeprom(struct bnx2x_phy *phy, | 311 | u8 bnx2x_read_sfp_module_eeprom(struct bnx2x_phy *phy, |
312 | struct link_params *params, u16 addr, | 312 | struct link_params *params, u16 addr, |
313 | u8 byte_cnt, u8 *o_buf); | 313 | u8 byte_cnt, u8 *o_buf); |
314 | |||
315 | void bnx2x_hw_reset_phy(struct link_params *params); | ||
316 | |||
317 | /* Checks if HW lock is required for this phy/board type */ | ||
318 | u8 bnx2x_hw_lock_required(struct bnx2x *bp, u32 shmem_base); | ||
314 | /* Returns the aggregative supported attributes of the phys on board */ | 319 | /* Returns the aggregative supported attributes of the phys on board */ |
315 | u32 bnx2x_supported_attr(struct link_params *params, u8 phy_idx); | 320 | u32 bnx2x_supported_attr(struct link_params *params, u8 phy_idx); |
316 | /* Probe the phys on board, and populate them in "params" */ | 321 | /* Probe the phys on board, and populate them in "params" */ |
317 | u8 bnx2x_phy_probe(struct link_params *params); | 322 | u8 bnx2x_phy_probe(struct link_params *params); |
323 | /* Checks if fan failure detection is required on one of the phys on board */ | ||
324 | u8 bnx2x_fan_failure_det_req(struct bnx2x *bp, u32 shmem_base, u8 port); | ||
325 | |||
318 | #endif /* BNX2X_LINK_H */ | 326 | #endif /* BNX2X_LINK_H */ |
diff --git a/drivers/net/bnx2x/bnx2x_main.c b/drivers/net/bnx2x/bnx2x_main.c index 1184677640e5..0210dde760d9 100644 --- a/drivers/net/bnx2x/bnx2x_main.c +++ b/drivers/net/bnx2x/bnx2x_main.c | |||
@@ -1981,7 +1981,7 @@ static inline void bnx2x_attn_int_deasserted0(struct bnx2x *bp, u32 attn) | |||
1981 | { | 1981 | { |
1982 | int port = BP_PORT(bp); | 1982 | int port = BP_PORT(bp); |
1983 | int reg_offset; | 1983 | int reg_offset; |
1984 | u32 val, swap_val, swap_override; | 1984 | u32 val; |
1985 | 1985 | ||
1986 | reg_offset = (port ? MISC_REG_AEU_ENABLE1_FUNC_1_OUT_0 : | 1986 | reg_offset = (port ? MISC_REG_AEU_ENABLE1_FUNC_1_OUT_0 : |
1987 | MISC_REG_AEU_ENABLE1_FUNC_0_OUT_0); | 1987 | MISC_REG_AEU_ENABLE1_FUNC_0_OUT_0); |
@@ -1995,30 +1995,7 @@ static inline void bnx2x_attn_int_deasserted0(struct bnx2x *bp, u32 attn) | |||
1995 | BNX2X_ERR("SPIO5 hw attention\n"); | 1995 | BNX2X_ERR("SPIO5 hw attention\n"); |
1996 | 1996 | ||
1997 | /* Fan failure attention */ | 1997 | /* Fan failure attention */ |
1998 | switch (bp->link_params.phy[EXT_PHY1].type) { | 1998 | bnx2x_hw_reset_phy(&bp->link_params); |
1999 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_SFX7101: | ||
2000 | /* Low power mode is controlled by GPIO 2 */ | ||
2001 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, | ||
2002 | MISC_REGISTERS_GPIO_OUTPUT_LOW, port); | ||
2003 | /* The PHY reset is controlled by GPIO 1 */ | ||
2004 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_1, | ||
2005 | MISC_REGISTERS_GPIO_OUTPUT_LOW, port); | ||
2006 | break; | ||
2007 | |||
2008 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727: | ||
2009 | /* The PHY reset is controlled by GPIO 1 */ | ||
2010 | /* fake the port number to cancel the swap done in | ||
2011 | set_gpio() */ | ||
2012 | swap_val = REG_RD(bp, NIG_REG_PORT_SWAP); | ||
2013 | swap_override = REG_RD(bp, NIG_REG_STRAP_OVERRIDE); | ||
2014 | port = (swap_val && swap_override) ^ 1; | ||
2015 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_1, | ||
2016 | MISC_REGISTERS_GPIO_OUTPUT_LOW, port); | ||
2017 | break; | ||
2018 | |||
2019 | default: | ||
2020 | break; | ||
2021 | } | ||
2022 | bnx2x_fan_failure(bp); | 1999 | bnx2x_fan_failure(bp); |
2023 | } | 2000 | } |
2024 | 2001 | ||
@@ -3867,17 +3844,11 @@ static void bnx2x_setup_fan_failure_detection(struct bnx2x *bp) | |||
3867 | */ | 3844 | */ |
3868 | else if (val == SHARED_HW_CFG_FAN_FAILURE_PHY_TYPE) | 3845 | else if (val == SHARED_HW_CFG_FAN_FAILURE_PHY_TYPE) |
3869 | for (port = PORT_0; port < PORT_MAX; port++) { | 3846 | for (port = PORT_0; port < PORT_MAX; port++) { |
3870 | u32 phy_type = | ||
3871 | SHMEM_RD(bp, dev_info.port_hw_config[port]. | ||
3872 | external_phy_config) & | ||
3873 | PORT_HW_CFG_XGXS_EXT_PHY_TYPE_MASK; | ||
3874 | is_required |= | 3847 | is_required |= |
3875 | ((phy_type == | 3848 | bnx2x_fan_failure_det_req( |
3876 | PORT_HW_CFG_XGXS_EXT_PHY_TYPE_SFX7101) || | 3849 | bp, |
3877 | (phy_type == | 3850 | bp->common.shmem_base, |
3878 | PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727) || | 3851 | port); |
3879 | (phy_type == | ||
3880 | PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8481)); | ||
3881 | } | 3852 | } |
3882 | 3853 | ||
3883 | DP(NETIF_MSG_HW, "fan detection setting: %d\n", is_required); | 3854 | DP(NETIF_MSG_HW, "fan detection setting: %d\n", is_required); |
@@ -4144,17 +4115,8 @@ static int bnx2x_init_common(struct bnx2x *bp) | |||
4144 | return -EBUSY; | 4115 | return -EBUSY; |
4145 | } | 4116 | } |
4146 | 4117 | ||
4147 | switch (bp->link_params.phy[EXT_PHY1].type) { | 4118 | bp->port.need_hw_lock = bnx2x_hw_lock_required(bp, |
4148 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8072: | 4119 | bp->common.shmem_base); |
4149 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073: | ||
4150 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726: | ||
4151 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727: | ||
4152 | bp->port.need_hw_lock = 1; | ||
4153 | break; | ||
4154 | |||
4155 | default: | ||
4156 | break; | ||
4157 | } | ||
4158 | 4120 | ||
4159 | bnx2x_setup_fan_failure_detection(bp); | 4121 | bnx2x_setup_fan_failure_detection(bp); |
4160 | 4122 | ||
@@ -4302,57 +4264,16 @@ static int bnx2x_init_port(struct bnx2x *bp) | |||
4302 | 4264 | ||
4303 | bnx2x_init_block(bp, MCP_BLOCK, init_stage); | 4265 | bnx2x_init_block(bp, MCP_BLOCK, init_stage); |
4304 | bnx2x_init_block(bp, DMAE_BLOCK, init_stage); | 4266 | bnx2x_init_block(bp, DMAE_BLOCK, init_stage); |
4267 | bp->port.need_hw_lock = bnx2x_hw_lock_required(bp, | ||
4268 | bp->common.shmem_base); | ||
4305 | 4269 | ||
4306 | switch (bp->link_params.phy[EXT_PHY1].type) { | 4270 | if (bnx2x_fan_failure_det_req(bp, bp->common.shmem_base, |
4307 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726: | 4271 | port)) { |
4308 | { | ||
4309 | u32 swap_val, swap_override, aeu_gpio_mask, offset; | ||
4310 | |||
4311 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_3, | ||
4312 | MISC_REGISTERS_GPIO_INPUT_HI_Z, port); | ||
4313 | |||
4314 | /* The GPIO should be swapped if the swap register is | ||
4315 | set and active */ | ||
4316 | swap_val = REG_RD(bp, NIG_REG_PORT_SWAP); | ||
4317 | swap_override = REG_RD(bp, NIG_REG_STRAP_OVERRIDE); | ||
4318 | |||
4319 | /* Select function upon port-swap configuration */ | ||
4320 | if (port == 0) { | ||
4321 | offset = MISC_REG_AEU_ENABLE1_FUNC_0_OUT_0; | ||
4322 | aeu_gpio_mask = (swap_val && swap_override) ? | ||
4323 | AEU_INPUTS_ATTN_BITS_GPIO3_FUNCTION_1 : | ||
4324 | AEU_INPUTS_ATTN_BITS_GPIO3_FUNCTION_0; | ||
4325 | } else { | ||
4326 | offset = MISC_REG_AEU_ENABLE1_FUNC_1_OUT_0; | ||
4327 | aeu_gpio_mask = (swap_val && swap_override) ? | ||
4328 | AEU_INPUTS_ATTN_BITS_GPIO3_FUNCTION_0 : | ||
4329 | AEU_INPUTS_ATTN_BITS_GPIO3_FUNCTION_1; | ||
4330 | } | ||
4331 | val = REG_RD(bp, offset); | ||
4332 | /* add GPIO3 to group */ | ||
4333 | val |= aeu_gpio_mask; | ||
4334 | REG_WR(bp, offset, val); | ||
4335 | } | ||
4336 | bp->port.need_hw_lock = 1; | ||
4337 | break; | ||
4338 | |||
4339 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727: | ||
4340 | bp->port.need_hw_lock = 1; | ||
4341 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_SFX7101: | ||
4342 | /* add SPIO 5 to group 0 */ | ||
4343 | { | ||
4344 | u32 reg_addr = (port ? MISC_REG_AEU_ENABLE1_FUNC_1_OUT_0 : | 4272 | u32 reg_addr = (port ? MISC_REG_AEU_ENABLE1_FUNC_1_OUT_0 : |
4345 | MISC_REG_AEU_ENABLE1_FUNC_0_OUT_0); | 4273 | MISC_REG_AEU_ENABLE1_FUNC_0_OUT_0); |
4346 | val = REG_RD(bp, reg_addr); | 4274 | val = REG_RD(bp, reg_addr); |
4347 | val |= AEU_INPUTS_ATTN_BITS_SPIO5; | 4275 | val |= AEU_INPUTS_ATTN_BITS_SPIO5; |
4348 | REG_WR(bp, reg_addr, val); | 4276 | REG_WR(bp, reg_addr, val); |
4349 | } | ||
4350 | break; | ||
4351 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073: | ||
4352 | bp->port.need_hw_lock = 1; | ||
4353 | break; | ||
4354 | default: | ||
4355 | break; | ||
4356 | } | 4277 | } |
4357 | bnx2x__link_reset(bp); | 4278 | bnx2x__link_reset(bp); |
4358 | 4279 | ||