aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorYaniv Rosner <yaniv.rosner@broadcom.com>2012-09-12 22:56:19 -0400
committerDavid S. Miller <davem@davemloft.net>2012-09-13 15:01:39 -0400
commit5c107fda9698bba6828bbca687ca556fd5e7f50c (patch)
tree722264f87e566f54c071ab50d827376d21d4cff2 /drivers
parentb0e61d98c672a9216d72d2d7430f6dc60795002e (diff)
bnx2x: link code refactoring
Separate the interrupt setting part of each external PHY to a specific function. This allows calling the interrupt setting in case of link-flap avoidance, since some link owners may not enable the interrupt on their own. Signed-off-by: Yaniv Rosner <yaniv.rosner@broadcom.com> Signed-off-by: Yuval Mintz <yuvalmin@broadcom.com> Signed-off-by: Eilon Greenstein <eilong@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c192
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.h1
2 files changed, 114 insertions, 79 deletions
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c
index c660afdbdf56..f7e236e68f17 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c
@@ -7367,6 +7367,22 @@ static void bnx2x_8073_set_pause_cl37(struct link_params *params,
7367 msleep(500); 7367 msleep(500);
7368} 7368}
7369 7369
7370static void bnx2x_8073_specific_func(struct bnx2x_phy *phy,
7371 struct link_params *params,
7372 u32 action)
7373{
7374 struct bnx2x *bp = params->bp;
7375 switch (action) {
7376 case PHY_INIT:
7377 /* Enable LASI */
7378 bnx2x_cl45_write(bp, phy,
7379 MDIO_PMA_DEVAD, MDIO_PMA_LASI_RXCTRL, (1<<2));
7380 bnx2x_cl45_write(bp, phy,
7381 MDIO_PMA_DEVAD, MDIO_PMA_LASI_CTRL, 0x0004);
7382 break;
7383 }
7384}
7385
7370static int bnx2x_8073_config_init(struct bnx2x_phy *phy, 7386static int bnx2x_8073_config_init(struct bnx2x_phy *phy,
7371 struct link_params *params, 7387 struct link_params *params,
7372 struct link_vars *vars) 7388 struct link_vars *vars)
@@ -7387,12 +7403,7 @@ static int bnx2x_8073_config_init(struct bnx2x_phy *phy,
7387 bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_1, 7403 bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_1,
7388 MISC_REGISTERS_GPIO_OUTPUT_HIGH, gpio_port); 7404 MISC_REGISTERS_GPIO_OUTPUT_HIGH, gpio_port);
7389 7405
7390 /* Enable LASI */ 7406 bnx2x_8073_specific_func(phy, params, PHY_INIT);
7391 bnx2x_cl45_write(bp, phy,
7392 MDIO_PMA_DEVAD, MDIO_PMA_LASI_RXCTRL, (1<<2));
7393 bnx2x_cl45_write(bp, phy,
7394 MDIO_PMA_DEVAD, MDIO_PMA_LASI_CTRL, 0x0004);
7395
7396 bnx2x_8073_set_pause_cl37(params, phy, vars); 7407 bnx2x_8073_set_pause_cl37(params, phy, vars);
7397 7408
7398 bnx2x_cl45_read(bp, phy, 7409 bnx2x_cl45_read(bp, phy,
@@ -8427,7 +8438,7 @@ static void bnx2x_8727_specific_func(struct bnx2x_phy *phy,
8427 u32 action) 8438 u32 action)
8428{ 8439{
8429 struct bnx2x *bp = params->bp; 8440 struct bnx2x *bp = params->bp;
8430 8441 u16 val;
8431 switch (action) { 8442 switch (action) {
8432 case DISABLE_TX: 8443 case DISABLE_TX:
8433 bnx2x_sfp_set_transmitter(params, phy, 0); 8444 bnx2x_sfp_set_transmitter(params, phy, 0);
@@ -8436,6 +8447,40 @@ static void bnx2x_8727_specific_func(struct bnx2x_phy *phy,
8436 if (!(phy->flags & FLAGS_SFP_NOT_APPROVED)) 8447 if (!(phy->flags & FLAGS_SFP_NOT_APPROVED))
8437 bnx2x_sfp_set_transmitter(params, phy, 1); 8448 bnx2x_sfp_set_transmitter(params, phy, 1);
8438 break; 8449 break;
8450 case PHY_INIT:
8451 bnx2x_cl45_write(bp, phy,
8452 MDIO_PMA_DEVAD, MDIO_PMA_LASI_RXCTRL,
8453 (1<<2) | (1<<5));
8454 bnx2x_cl45_write(bp, phy,
8455 MDIO_PMA_DEVAD, MDIO_PMA_LASI_TXCTRL,
8456 0);
8457 bnx2x_cl45_write(bp, phy,
8458 MDIO_PMA_DEVAD, MDIO_PMA_LASI_CTRL, 0x0006);
8459 /* Make MOD_ABS give interrupt on change */
8460 bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD,
8461 MDIO_PMA_REG_8727_PCS_OPT_CTRL,
8462 &val);
8463 val |= (1<<12);
8464 if (phy->flags & FLAGS_NOC)
8465 val |= (3<<5);
8466 /* Set 8727 GPIOs to input to allow reading from the 8727 GPIO0
8467 * status which reflect SFP+ module over-current
8468 */
8469 if (!(phy->flags & FLAGS_NOC))
8470 val &= 0xff8f; /* Reset bits 4-6 */
8471 bnx2x_cl45_write(bp, phy,
8472 MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_PCS_OPT_CTRL,
8473 val);
8474
8475 /* Set 2-wire transfer rate of SFP+ module EEPROM
8476 * to 100Khz since some DACs(direct attached cables) do
8477 * not work at 400Khz.
8478 */
8479 bnx2x_cl45_write(bp, phy,
8480 MDIO_PMA_DEVAD,
8481 MDIO_PMA_REG_8727_TWO_WIRE_SLAVE_ADDR,
8482 0xa001);
8483 break;
8439 default: 8484 default:
8440 DP(NETIF_MSG_LINK, "Function 0x%x not supported by 8727\n", 8485 DP(NETIF_MSG_LINK, "Function 0x%x not supported by 8727\n",
8441 action); 8486 action);
@@ -9218,28 +9263,15 @@ static int bnx2x_8727_config_init(struct bnx2x_phy *phy,
9218 struct link_vars *vars) 9263 struct link_vars *vars)
9219{ 9264{
9220 u32 tx_en_mode; 9265 u32 tx_en_mode;
9221 u16 tmp1, val, mod_abs, tmp2; 9266 u16 tmp1, mod_abs, tmp2;
9222 u16 rx_alarm_ctrl_val;
9223 u16 lasi_ctrl_val;
9224 struct bnx2x *bp = params->bp; 9267 struct bnx2x *bp = params->bp;
9225 /* Enable PMD link, MOD_ABS_FLT, and 1G link alarm */ 9268 /* Enable PMD link, MOD_ABS_FLT, and 1G link alarm */
9226 9269
9227 bnx2x_wait_reset_complete(bp, phy, params); 9270 bnx2x_wait_reset_complete(bp, phy, params);
9228 rx_alarm_ctrl_val = (1<<2) | (1<<5) ;
9229 /* Should be 0x6 to enable XS on Tx side. */
9230 lasi_ctrl_val = 0x0006;
9231 9271
9232 DP(NETIF_MSG_LINK, "Initializing BCM8727\n"); 9272 DP(NETIF_MSG_LINK, "Initializing BCM8727\n");
9233 /* Enable LASI */
9234 bnx2x_cl45_write(bp, phy,
9235 MDIO_PMA_DEVAD, MDIO_PMA_LASI_RXCTRL,
9236 rx_alarm_ctrl_val);
9237 bnx2x_cl45_write(bp, phy,
9238 MDIO_PMA_DEVAD, MDIO_PMA_LASI_TXCTRL,
9239 0);
9240 bnx2x_cl45_write(bp, phy,
9241 MDIO_PMA_DEVAD, MDIO_PMA_LASI_CTRL, lasi_ctrl_val);
9242 9273
9274 bnx2x_8727_specific_func(phy, params, PHY_INIT);
9243 /* Initially configure MOD_ABS to interrupt when module is 9275 /* Initially configure MOD_ABS to interrupt when module is
9244 * presence( bit 8) 9276 * presence( bit 8)
9245 */ 9277 */
@@ -9255,25 +9287,9 @@ static int bnx2x_8727_config_init(struct bnx2x_phy *phy,
9255 bnx2x_cl45_write(bp, phy, 9287 bnx2x_cl45_write(bp, phy,
9256 MDIO_PMA_DEVAD, MDIO_PMA_REG_PHY_IDENTIFIER, mod_abs); 9288 MDIO_PMA_DEVAD, MDIO_PMA_REG_PHY_IDENTIFIER, mod_abs);
9257 9289
9258
9259 /* Enable/Disable PHY transmitter output */ 9290 /* Enable/Disable PHY transmitter output */
9260 bnx2x_set_disable_pmd_transmit(params, phy, 0); 9291 bnx2x_set_disable_pmd_transmit(params, phy, 0);
9261 9292
9262 /* Make MOD_ABS give interrupt on change */
9263 bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_PCS_OPT_CTRL,
9264 &val);
9265 val |= (1<<12);
9266 if (phy->flags & FLAGS_NOC)
9267 val |= (3<<5);
9268
9269 /* Set 8727 GPIOs to input to allow reading from the 8727 GPIO0
9270 * status which reflect SFP+ module over-current
9271 */
9272 if (!(phy->flags & FLAGS_NOC))
9273 val &= 0xff8f; /* Reset bits 4-6 */
9274 bnx2x_cl45_write(bp, phy,
9275 MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_PCS_OPT_CTRL, val);
9276
9277 bnx2x_8727_power_module(bp, phy, 1); 9293 bnx2x_8727_power_module(bp, phy, 1);
9278 9294
9279 bnx2x_cl45_read(bp, phy, 9295 bnx2x_cl45_read(bp, phy,
@@ -9283,13 +9299,7 @@ static int bnx2x_8727_config_init(struct bnx2x_phy *phy,
9283 MDIO_PMA_DEVAD, MDIO_PMA_LASI_RXSTAT, &tmp1); 9299 MDIO_PMA_DEVAD, MDIO_PMA_LASI_RXSTAT, &tmp1);
9284 9300
9285 bnx2x_8727_config_speed(phy, params); 9301 bnx2x_8727_config_speed(phy, params);
9286 /* Set 2-wire transfer rate of SFP+ module EEPROM 9302
9287 * to 100Khz since some DACs(direct attached cables) do
9288 * not work at 400Khz.
9289 */
9290 bnx2x_cl45_write(bp, phy,
9291 MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_TWO_WIRE_SLAVE_ADDR,
9292 0xa001);
9293 9303
9294 /* Set TX PreEmphasis if needed */ 9304 /* Set TX PreEmphasis if needed */
9295 if ((params->feature_config_flags & 9305 if ((params->feature_config_flags &
@@ -9718,6 +9728,29 @@ static void bnx2x_848xx_set_led(struct bnx2x *bp,
9718 0xFFFB, 0xFFFD); 9728 0xFFFB, 0xFFFD);
9719} 9729}
9720 9730
9731static void bnx2x_848xx_specific_func(struct bnx2x_phy *phy,
9732 struct link_params *params,
9733 u32 action)
9734{
9735 struct bnx2x *bp = params->bp;
9736 switch (action) {
9737 case PHY_INIT:
9738 if (phy->type != PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833) {
9739 /* Save spirom version */
9740 bnx2x_save_848xx_spirom_version(phy, bp, params->port);
9741 }
9742 /* This phy uses the NIG latch mechanism since link indication
9743 * arrives through its LED4 and not via its LASI signal, so we
9744 * get steady signal instead of clear on read
9745 */
9746 bnx2x_bits_en(bp, NIG_REG_LATCH_BC_0 + params->port*4,
9747 1 << NIG_LATCH_BC_ENABLE_MI_INT);
9748
9749 bnx2x_848xx_set_led(bp, phy);
9750 break;
9751 }
9752}
9753
9721static int bnx2x_848xx_cmn_config_init(struct bnx2x_phy *phy, 9754static int bnx2x_848xx_cmn_config_init(struct bnx2x_phy *phy,
9722 struct link_params *params, 9755 struct link_params *params,
9723 struct link_vars *vars) 9756 struct link_vars *vars)
@@ -9725,22 +9758,10 @@ static int bnx2x_848xx_cmn_config_init(struct bnx2x_phy *phy,
9725 struct bnx2x *bp = params->bp; 9758 struct bnx2x *bp = params->bp;
9726 u16 autoneg_val, an_1000_val, an_10_100_val, an_10g_val; 9759 u16 autoneg_val, an_1000_val, an_10_100_val, an_10g_val;
9727 9760
9728 if (phy->type != PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833) { 9761 bnx2x_848xx_specific_func(phy, params, PHY_INIT);
9729 /* Save spirom version */
9730 bnx2x_save_848xx_spirom_version(phy, bp, params->port);
9731 }
9732 /* This phy uses the NIG latch mechanism since link indication
9733 * arrives through its LED4 and not via its LASI signal, so we
9734 * get steady signal instead of clear on read
9735 */
9736 bnx2x_bits_en(bp, NIG_REG_LATCH_BC_0 + params->port*4,
9737 1 << NIG_LATCH_BC_ENABLE_MI_INT);
9738
9739 bnx2x_cl45_write(bp, phy, 9762 bnx2x_cl45_write(bp, phy,
9740 MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 0x0000); 9763 MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 0x0000);
9741 9764
9742 bnx2x_848xx_set_led(bp, phy);
9743
9744 /* set 1000 speed advertisement */ 9765 /* set 1000 speed advertisement */
9745 bnx2x_cl45_read(bp, phy, 9766 bnx2x_cl45_read(bp, phy,
9746 MDIO_AN_DEVAD, MDIO_AN_REG_8481_1000T_CTRL, 9767 MDIO_AN_DEVAD, MDIO_AN_REG_8481_1000T_CTRL,
@@ -10645,6 +10666,35 @@ static void bnx2x_848xx_set_link_led(struct bnx2x_phy *phy,
10645/******************************************************************/ 10666/******************************************************************/
10646/* 54618SE PHY SECTION */ 10667/* 54618SE PHY SECTION */
10647/******************************************************************/ 10668/******************************************************************/
10669static void bnx2x_54618se_specific_func(struct bnx2x_phy *phy,
10670 struct link_params *params,
10671 u32 action)
10672{
10673 struct bnx2x *bp = params->bp;
10674 u16 temp;
10675 switch (action) {
10676 case PHY_INIT:
10677 /* Configure LED4: set to INTR (0x6). */
10678 /* Accessing shadow register 0xe. */
10679 bnx2x_cl22_write(bp, phy,
10680 MDIO_REG_GPHY_SHADOW,
10681 MDIO_REG_GPHY_SHADOW_LED_SEL2);
10682 bnx2x_cl22_read(bp, phy,
10683 MDIO_REG_GPHY_SHADOW,
10684 &temp);
10685 temp &= ~(0xf << 4);
10686 temp |= (0x6 << 4);
10687 bnx2x_cl22_write(bp, phy,
10688 MDIO_REG_GPHY_SHADOW,
10689 MDIO_REG_GPHY_SHADOW_WR_ENA | temp);
10690 /* Configure INTR based on link status change. */
10691 bnx2x_cl22_write(bp, phy,
10692 MDIO_REG_INTR_MASK,
10693 ~MDIO_REG_INTR_MASK_LINK_STATUS);
10694 break;
10695 }
10696}
10697
10648static int bnx2x_54618se_config_init(struct bnx2x_phy *phy, 10698static int bnx2x_54618se_config_init(struct bnx2x_phy *phy,
10649 struct link_params *params, 10699 struct link_params *params,
10650 struct link_vars *vars) 10700 struct link_vars *vars)
@@ -10682,24 +10732,8 @@ static int bnx2x_54618se_config_init(struct bnx2x_phy *phy,
10682 /* Wait for GPHY to reset */ 10732 /* Wait for GPHY to reset */
10683 msleep(50); 10733 msleep(50);
10684 10734
10685 /* Configure LED4: set to INTR (0x6). */
10686 /* Accessing shadow register 0xe. */
10687 bnx2x_cl22_write(bp, phy,
10688 MDIO_REG_GPHY_SHADOW,
10689 MDIO_REG_GPHY_SHADOW_LED_SEL2);
10690 bnx2x_cl22_read(bp, phy,
10691 MDIO_REG_GPHY_SHADOW,
10692 &temp);
10693 temp &= ~(0xf << 4);
10694 temp |= (0x6 << 4);
10695 bnx2x_cl22_write(bp, phy,
10696 MDIO_REG_GPHY_SHADOW,
10697 MDIO_REG_GPHY_SHADOW_WR_ENA | temp);
10698 /* Configure INTR based on link status change. */
10699 bnx2x_cl22_write(bp, phy,
10700 MDIO_REG_INTR_MASK,
10701 ~MDIO_REG_INTR_MASK_LINK_STATUS);
10702 10735
10736 bnx2x_54618se_specific_func(phy, params, PHY_INIT);
10703 /* Flip the signal detect polarity (set 0x1c.0x1e[8]). */ 10737 /* Flip the signal detect polarity (set 0x1c.0x1e[8]). */
10704 bnx2x_cl22_write(bp, phy, 10738 bnx2x_cl22_write(bp, phy,
10705 MDIO_REG_GPHY_SHADOW, 10739 MDIO_REG_GPHY_SHADOW,
@@ -11434,7 +11468,7 @@ static struct bnx2x_phy phy_8073 = {
11434 .format_fw_ver = (format_fw_ver_t)bnx2x_format_ver, 11468 .format_fw_ver = (format_fw_ver_t)bnx2x_format_ver,
11435 .hw_reset = (hw_reset_t)NULL, 11469 .hw_reset = (hw_reset_t)NULL,
11436 .set_link_led = (set_link_led_t)NULL, 11470 .set_link_led = (set_link_led_t)NULL,
11437 .phy_specific_func = (phy_specific_func_t)NULL 11471 .phy_specific_func = (phy_specific_func_t)bnx2x_8073_specific_func
11438}; 11472};
11439static struct bnx2x_phy phy_8705 = { 11473static struct bnx2x_phy phy_8705 = {
11440 .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8705, 11474 .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8705,
@@ -11627,7 +11661,7 @@ static struct bnx2x_phy phy_84823 = {
11627 .format_fw_ver = (format_fw_ver_t)bnx2x_848xx_format_ver, 11661 .format_fw_ver = (format_fw_ver_t)bnx2x_848xx_format_ver,
11628 .hw_reset = (hw_reset_t)NULL, 11662 .hw_reset = (hw_reset_t)NULL,
11629 .set_link_led = (set_link_led_t)bnx2x_848xx_set_link_led, 11663 .set_link_led = (set_link_led_t)bnx2x_848xx_set_link_led,
11630 .phy_specific_func = (phy_specific_func_t)NULL 11664 .phy_specific_func = (phy_specific_func_t)bnx2x_848xx_specific_func
11631}; 11665};
11632 11666
11633static struct bnx2x_phy phy_84833 = { 11667static struct bnx2x_phy phy_84833 = {
@@ -11662,7 +11696,7 @@ static struct bnx2x_phy phy_84833 = {
11662 .format_fw_ver = (format_fw_ver_t)bnx2x_848xx_format_ver, 11696 .format_fw_ver = (format_fw_ver_t)bnx2x_848xx_format_ver,
11663 .hw_reset = (hw_reset_t)bnx2x_84833_hw_reset_phy, 11697 .hw_reset = (hw_reset_t)bnx2x_84833_hw_reset_phy,
11664 .set_link_led = (set_link_led_t)bnx2x_848xx_set_link_led, 11698 .set_link_led = (set_link_led_t)bnx2x_848xx_set_link_led,
11665 .phy_specific_func = (phy_specific_func_t)NULL 11699 .phy_specific_func = (phy_specific_func_t)bnx2x_848xx_specific_func
11666}; 11700};
11667 11701
11668static struct bnx2x_phy phy_54618se = { 11702static struct bnx2x_phy phy_54618se = {
@@ -11696,7 +11730,7 @@ static struct bnx2x_phy phy_54618se = {
11696 .format_fw_ver = (format_fw_ver_t)NULL, 11730 .format_fw_ver = (format_fw_ver_t)NULL,
11697 .hw_reset = (hw_reset_t)NULL, 11731 .hw_reset = (hw_reset_t)NULL,
11698 .set_link_led = (set_link_led_t)bnx2x_5461x_set_link_led, 11732 .set_link_led = (set_link_led_t)bnx2x_5461x_set_link_led,
11699 .phy_specific_func = (phy_specific_func_t)NULL 11733 .phy_specific_func = (phy_specific_func_t)bnx2x_54618se_specific_func
11700}; 11734};
11701/*****************************************************************/ 11735/*****************************************************************/
11702/* */ 11736/* */
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.h
index 360ecf9e0739..ffc83f3c9123 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.h
@@ -216,6 +216,7 @@ struct bnx2x_phy {
216 phy_specific_func_t phy_specific_func; 216 phy_specific_func_t phy_specific_func;
217#define DISABLE_TX 1 217#define DISABLE_TX 1
218#define ENABLE_TX 2 218#define ENABLE_TX 2
219#define PHY_INIT 3
219}; 220};
220 221
221/* Inputs parameters to the CLC */ 222/* Inputs parameters to the CLC */