Ariel Elior | 85b26ea | 2012-01-26 06:01:54 +0000 | [diff] [blame] | 1 | /* Copyright 2008-2012 Broadcom Corporation |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2 | * |
| 3 | * Unless you and Broadcom execute a separate written software license |
| 4 | * agreement governing use of this software, this software is licensed to you |
| 5 | * under the terms of the GNU General Public License version 2, available |
| 6 | * at http://www.gnu.org/licenses/old-licenses/gpl-2.0.html (the "GPL"). |
| 7 | * |
| 8 | * Notwithstanding the above, under no circumstances may you combine this |
| 9 | * software in any way with any other Broadcom software provided under a |
| 10 | * license other than the GPL, without Broadcom's express prior written |
| 11 | * consent. |
| 12 | * |
| 13 | * Written by Yaniv Rosner |
| 14 | * |
| 15 | */ |
| 16 | |
Joe Perches | 7995c64 | 2010-02-17 15:01:52 +0000 | [diff] [blame] | 17 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 18 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 19 | #include <linux/kernel.h> |
| 20 | #include <linux/errno.h> |
| 21 | #include <linux/pci.h> |
| 22 | #include <linux/netdevice.h> |
| 23 | #include <linux/delay.h> |
| 24 | #include <linux/ethtool.h> |
| 25 | #include <linux/mutex.h> |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 26 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 27 | #include "bnx2x.h" |
Vlad Zolotarov | 619c5cb | 2011-06-14 14:33:44 +0300 | [diff] [blame] | 28 | #include "bnx2x_cmn.h" |
| 29 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 30 | /********************************************************/ |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 31 | #define ETH_HLEN 14 |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 32 | /* L2 header size + 2*VLANs (8 bytes) + LLC SNAP (8 bytes) */ |
| 33 | #define ETH_OVREHEAD (ETH_HLEN + 8 + 8) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 34 | #define ETH_MIN_PACKET_SIZE 60 |
| 35 | #define ETH_MAX_PACKET_SIZE 1500 |
| 36 | #define ETH_MAX_JUMBO_PACKET_SIZE 9600 |
| 37 | #define MDIO_ACCESS_TIMEOUT 1000 |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 38 | #define WC_LANE_MAX 4 |
| 39 | #define I2C_SWITCH_WIDTH 2 |
| 40 | #define I2C_BSC0 0 |
| 41 | #define I2C_BSC1 1 |
| 42 | #define I2C_WA_RETRY_CNT 3 |
Yuval Mintz | 50a2984 | 2012-06-16 20:27:14 +0000 | [diff] [blame] | 43 | #define I2C_WA_PWR_ITER (I2C_WA_RETRY_CNT - 1) |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 44 | #define MCPR_IMC_COMMAND_READ_OP 1 |
| 45 | #define MCPR_IMC_COMMAND_WRITE_OP 2 |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 46 | |
Yaniv Rosner | 26ffaf3 | 2011-10-27 05:09:45 +0000 | [diff] [blame] | 47 | /* LED Blink rate that will achieve ~15.9Hz */ |
| 48 | #define LED_BLINK_RATE_VAL_E3 354 |
| 49 | #define LED_BLINK_RATE_VAL_E1X_E2 480 |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 50 | /***********************************************************/ |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 51 | /* Shortcut definitions */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 52 | /***********************************************************/ |
| 53 | |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 54 | #define NIG_LATCH_BC_ENABLE_MI_INT 0 |
| 55 | |
| 56 | #define NIG_STATUS_EMAC0_MI_INT \ |
| 57 | NIG_STATUS_INTERRUPT_PORT0_REG_STATUS_EMAC0_MISC_MI_INT |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 58 | #define NIG_STATUS_XGXS0_LINK10G \ |
| 59 | NIG_STATUS_INTERRUPT_PORT0_REG_STATUS_XGXS0_LINK10G |
| 60 | #define NIG_STATUS_XGXS0_LINK_STATUS \ |
| 61 | NIG_STATUS_INTERRUPT_PORT0_REG_STATUS_XGXS0_LINK_STATUS |
| 62 | #define NIG_STATUS_XGXS0_LINK_STATUS_SIZE \ |
| 63 | NIG_STATUS_INTERRUPT_PORT0_REG_STATUS_XGXS0_LINK_STATUS_SIZE |
| 64 | #define NIG_STATUS_SERDES0_LINK_STATUS \ |
| 65 | NIG_STATUS_INTERRUPT_PORT0_REG_STATUS_SERDES0_LINK_STATUS |
| 66 | #define NIG_MASK_MI_INT \ |
| 67 | NIG_MASK_INTERRUPT_PORT0_REG_MASK_EMAC0_MISC_MI_INT |
| 68 | #define NIG_MASK_XGXS0_LINK10G \ |
| 69 | NIG_MASK_INTERRUPT_PORT0_REG_MASK_XGXS0_LINK10G |
| 70 | #define NIG_MASK_XGXS0_LINK_STATUS \ |
| 71 | NIG_MASK_INTERRUPT_PORT0_REG_MASK_XGXS0_LINK_STATUS |
| 72 | #define NIG_MASK_SERDES0_LINK_STATUS \ |
| 73 | NIG_MASK_INTERRUPT_PORT0_REG_MASK_SERDES0_LINK_STATUS |
| 74 | |
| 75 | #define MDIO_AN_CL73_OR_37_COMPLETE \ |
| 76 | (MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_AUTONEG_COMPLETE | \ |
| 77 | MDIO_GP_STATUS_TOP_AN_STATUS1_CL37_AUTONEG_COMPLETE) |
| 78 | |
| 79 | #define XGXS_RESET_BITS \ |
| 80 | (MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_XGXS0_RSTB_HW | \ |
| 81 | MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_XGXS0_IDDQ | \ |
| 82 | MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_XGXS0_PWRDWN | \ |
| 83 | MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_XGXS0_PWRDWN_SD | \ |
| 84 | MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_XGXS0_TXD_FIFO_RSTB) |
| 85 | |
| 86 | #define SERDES_RESET_BITS \ |
| 87 | (MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_SERDES0_RSTB_HW | \ |
| 88 | MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_SERDES0_IDDQ | \ |
| 89 | MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_SERDES0_PWRDWN | \ |
| 90 | MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_SERDES0_PWRDWN_SD) |
| 91 | |
| 92 | #define AUTONEG_CL37 SHARED_HW_CFG_AN_ENABLE_CL37 |
| 93 | #define AUTONEG_CL73 SHARED_HW_CFG_AN_ENABLE_CL73 |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 94 | #define AUTONEG_BAM SHARED_HW_CFG_AN_ENABLE_BAM |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 95 | #define AUTONEG_PARALLEL \ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 96 | SHARED_HW_CFG_AN_ENABLE_PARALLEL_DETECTION |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 97 | #define AUTONEG_SGMII_FIBER_AUTODET \ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 98 | SHARED_HW_CFG_AN_EN_SGMII_FIBER_AUTO_DETECT |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 99 | #define AUTONEG_REMOTE_PHY SHARED_HW_CFG_AN_ENABLE_REMOTE_PHY |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 100 | |
| 101 | #define GP_STATUS_PAUSE_RSOLUTION_TXSIDE \ |
| 102 | MDIO_GP_STATUS_TOP_AN_STATUS1_PAUSE_RSOLUTION_TXSIDE |
| 103 | #define GP_STATUS_PAUSE_RSOLUTION_RXSIDE \ |
| 104 | MDIO_GP_STATUS_TOP_AN_STATUS1_PAUSE_RSOLUTION_RXSIDE |
| 105 | #define GP_STATUS_SPEED_MASK \ |
| 106 | MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_MASK |
| 107 | #define GP_STATUS_10M MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_10M |
| 108 | #define GP_STATUS_100M MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_100M |
| 109 | #define GP_STATUS_1G MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_1G |
| 110 | #define GP_STATUS_2_5G MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_2_5G |
| 111 | #define GP_STATUS_5G MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_5G |
| 112 | #define GP_STATUS_6G MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_6G |
| 113 | #define GP_STATUS_10G_HIG \ |
| 114 | MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_10G_HIG |
| 115 | #define GP_STATUS_10G_CX4 \ |
| 116 | MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_10G_CX4 |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 117 | #define GP_STATUS_1G_KX MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_1G_KX |
| 118 | #define GP_STATUS_10G_KX4 \ |
| 119 | MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_10G_KX4 |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 120 | #define GP_STATUS_10G_KR MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_10G_KR |
| 121 | #define GP_STATUS_10G_XFI MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_10G_XFI |
| 122 | #define GP_STATUS_20G_DXGXS MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_20G_DXGXS |
| 123 | #define GP_STATUS_10G_SFI MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_10G_SFI |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 124 | #define LINK_10THD LINK_STATUS_SPEED_AND_DUPLEX_10THD |
| 125 | #define LINK_10TFD LINK_STATUS_SPEED_AND_DUPLEX_10TFD |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 126 | #define LINK_100TXHD LINK_STATUS_SPEED_AND_DUPLEX_100TXHD |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 127 | #define LINK_100T4 LINK_STATUS_SPEED_AND_DUPLEX_100T4 |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 128 | #define LINK_100TXFD LINK_STATUS_SPEED_AND_DUPLEX_100TXFD |
| 129 | #define LINK_1000THD LINK_STATUS_SPEED_AND_DUPLEX_1000THD |
| 130 | #define LINK_1000TFD LINK_STATUS_SPEED_AND_DUPLEX_1000TFD |
| 131 | #define LINK_1000XFD LINK_STATUS_SPEED_AND_DUPLEX_1000XFD |
| 132 | #define LINK_2500THD LINK_STATUS_SPEED_AND_DUPLEX_2500THD |
| 133 | #define LINK_2500TFD LINK_STATUS_SPEED_AND_DUPLEX_2500TFD |
| 134 | #define LINK_2500XFD LINK_STATUS_SPEED_AND_DUPLEX_2500XFD |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 135 | #define LINK_10GTFD LINK_STATUS_SPEED_AND_DUPLEX_10GTFD |
| 136 | #define LINK_10GXFD LINK_STATUS_SPEED_AND_DUPLEX_10GXFD |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 137 | #define LINK_20GTFD LINK_STATUS_SPEED_AND_DUPLEX_20GTFD |
| 138 | #define LINK_20GXFD LINK_STATUS_SPEED_AND_DUPLEX_20GXFD |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 139 | |
| 140 | |
| 141 | |
Eilon Greenstein | 589abe3 | 2009-02-12 08:36:55 +0000 | [diff] [blame] | 142 | #define SFP_EEPROM_CON_TYPE_ADDR 0x2 |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 143 | #define SFP_EEPROM_CON_TYPE_VAL_LC 0x7 |
Eilon Greenstein | 589abe3 | 2009-02-12 08:36:55 +0000 | [diff] [blame] | 144 | #define SFP_EEPROM_CON_TYPE_VAL_COPPER 0x21 |
| 145 | |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 146 | |
| 147 | #define SFP_EEPROM_COMP_CODE_ADDR 0x3 |
| 148 | #define SFP_EEPROM_COMP_CODE_SR_MASK (1<<4) |
| 149 | #define SFP_EEPROM_COMP_CODE_LR_MASK (1<<5) |
| 150 | #define SFP_EEPROM_COMP_CODE_LRM_MASK (1<<6) |
| 151 | |
Eilon Greenstein | 589abe3 | 2009-02-12 08:36:55 +0000 | [diff] [blame] | 152 | #define SFP_EEPROM_FC_TX_TECH_ADDR 0x8 |
| 153 | #define SFP_EEPROM_FC_TX_TECH_BITMASK_COPPER_PASSIVE 0x4 |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 154 | #define SFP_EEPROM_FC_TX_TECH_BITMASK_COPPER_ACTIVE 0x8 |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 155 | |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 156 | #define SFP_EEPROM_OPTIONS_ADDR 0x40 |
Eilon Greenstein | 589abe3 | 2009-02-12 08:36:55 +0000 | [diff] [blame] | 157 | #define SFP_EEPROM_OPTIONS_LINEAR_RX_OUT_MASK 0x1 |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 158 | #define SFP_EEPROM_OPTIONS_SIZE 2 |
Eilon Greenstein | 589abe3 | 2009-02-12 08:36:55 +0000 | [diff] [blame] | 159 | |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 160 | #define EDC_MODE_LINEAR 0x0022 |
| 161 | #define EDC_MODE_LIMITING 0x0044 |
| 162 | #define EDC_MODE_PASSIVE_DAC 0x0055 |
Eilon Greenstein | 589abe3 | 2009-02-12 08:36:55 +0000 | [diff] [blame] | 163 | |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 164 | /* BRB default for class 0 E2 */ |
| 165 | #define DEFAULT0_E2_BRB_MAC_PAUSE_XOFF_THR 170 |
| 166 | #define DEFAULT0_E2_BRB_MAC_PAUSE_XON_THR 250 |
| 167 | #define DEFAULT0_E2_BRB_MAC_FULL_XOFF_THR 10 |
| 168 | #define DEFAULT0_E2_BRB_MAC_FULL_XON_THR 50 |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 169 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 170 | /* BRB thresholds for E2*/ |
| 171 | #define PFC_E2_BRB_MAC_PAUSE_XOFF_THR_PAUSE 170 |
| 172 | #define PFC_E2_BRB_MAC_PAUSE_XOFF_THR_NON_PAUSE 0 |
| 173 | |
| 174 | #define PFC_E2_BRB_MAC_PAUSE_XON_THR_PAUSE 250 |
| 175 | #define PFC_E2_BRB_MAC_PAUSE_XON_THR_NON_PAUSE 0 |
| 176 | |
| 177 | #define PFC_E2_BRB_MAC_FULL_XOFF_THR_PAUSE 10 |
| 178 | #define PFC_E2_BRB_MAC_FULL_XOFF_THR_NON_PAUSE 90 |
| 179 | |
| 180 | #define PFC_E2_BRB_MAC_FULL_XON_THR_PAUSE 50 |
| 181 | #define PFC_E2_BRB_MAC_FULL_XON_THR_NON_PAUSE 250 |
| 182 | |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 183 | /* BRB default for class 0 E3A0 */ |
| 184 | #define DEFAULT0_E3A0_BRB_MAC_PAUSE_XOFF_THR 290 |
| 185 | #define DEFAULT0_E3A0_BRB_MAC_PAUSE_XON_THR 410 |
| 186 | #define DEFAULT0_E3A0_BRB_MAC_FULL_XOFF_THR 10 |
| 187 | #define DEFAULT0_E3A0_BRB_MAC_FULL_XON_THR 50 |
| 188 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 189 | /* BRB thresholds for E3A0 */ |
| 190 | #define PFC_E3A0_BRB_MAC_PAUSE_XOFF_THR_PAUSE 290 |
| 191 | #define PFC_E3A0_BRB_MAC_PAUSE_XOFF_THR_NON_PAUSE 0 |
| 192 | |
| 193 | #define PFC_E3A0_BRB_MAC_PAUSE_XON_THR_PAUSE 410 |
| 194 | #define PFC_E3A0_BRB_MAC_PAUSE_XON_THR_NON_PAUSE 0 |
| 195 | |
| 196 | #define PFC_E3A0_BRB_MAC_FULL_XOFF_THR_PAUSE 10 |
| 197 | #define PFC_E3A0_BRB_MAC_FULL_XOFF_THR_NON_PAUSE 170 |
| 198 | |
| 199 | #define PFC_E3A0_BRB_MAC_FULL_XON_THR_PAUSE 50 |
| 200 | #define PFC_E3A0_BRB_MAC_FULL_XON_THR_NON_PAUSE 410 |
| 201 | |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 202 | /* BRB default for E3B0 */ |
| 203 | #define DEFAULT0_E3B0_BRB_MAC_PAUSE_XOFF_THR 330 |
| 204 | #define DEFAULT0_E3B0_BRB_MAC_PAUSE_XON_THR 490 |
| 205 | #define DEFAULT0_E3B0_BRB_MAC_FULL_XOFF_THR 15 |
| 206 | #define DEFAULT0_E3B0_BRB_MAC_FULL_XON_THR 55 |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 207 | |
| 208 | /* BRB thresholds for E3B0 2 port mode*/ |
| 209 | #define PFC_E3B0_2P_BRB_MAC_PAUSE_XOFF_THR_PAUSE 1025 |
| 210 | #define PFC_E3B0_2P_BRB_MAC_PAUSE_XOFF_THR_NON_PAUSE 0 |
| 211 | |
| 212 | #define PFC_E3B0_2P_BRB_MAC_PAUSE_XON_THR_PAUSE 1025 |
| 213 | #define PFC_E3B0_2P_BRB_MAC_PAUSE_XON_THR_NON_PAUSE 0 |
| 214 | |
| 215 | #define PFC_E3B0_2P_BRB_MAC_FULL_XOFF_THR_PAUSE 10 |
| 216 | #define PFC_E3B0_2P_BRB_MAC_FULL_XOFF_THR_NON_PAUSE 1025 |
| 217 | |
| 218 | #define PFC_E3B0_2P_BRB_MAC_FULL_XON_THR_PAUSE 50 |
| 219 | #define PFC_E3B0_2P_BRB_MAC_FULL_XON_THR_NON_PAUSE 1025 |
| 220 | |
| 221 | /* only for E3B0*/ |
| 222 | #define PFC_E3B0_2P_BRB_FULL_LB_XOFF_THR 1025 |
| 223 | #define PFC_E3B0_2P_BRB_FULL_LB_XON_THR 1025 |
| 224 | |
| 225 | /* Lossy +Lossless GUARANTIED == GUART */ |
| 226 | #define PFC_E3B0_2P_MIX_PAUSE_LB_GUART 284 |
| 227 | /* Lossless +Lossless*/ |
| 228 | #define PFC_E3B0_2P_PAUSE_LB_GUART 236 |
| 229 | /* Lossy +Lossy*/ |
| 230 | #define PFC_E3B0_2P_NON_PAUSE_LB_GUART 342 |
| 231 | |
| 232 | /* Lossy +Lossless*/ |
| 233 | #define PFC_E3B0_2P_MIX_PAUSE_MAC_0_CLASS_T_GUART 284 |
| 234 | /* Lossless +Lossless*/ |
| 235 | #define PFC_E3B0_2P_PAUSE_MAC_0_CLASS_T_GUART 236 |
| 236 | /* Lossy +Lossy*/ |
| 237 | #define PFC_E3B0_2P_NON_PAUSE_MAC_0_CLASS_T_GUART 336 |
| 238 | #define PFC_E3B0_2P_BRB_MAC_0_CLASS_T_GUART_HYST 80 |
| 239 | |
| 240 | #define PFC_E3B0_2P_BRB_MAC_1_CLASS_T_GUART 0 |
| 241 | #define PFC_E3B0_2P_BRB_MAC_1_CLASS_T_GUART_HYST 0 |
| 242 | |
| 243 | /* BRB thresholds for E3B0 4 port mode */ |
| 244 | #define PFC_E3B0_4P_BRB_MAC_PAUSE_XOFF_THR_PAUSE 304 |
| 245 | #define PFC_E3B0_4P_BRB_MAC_PAUSE_XOFF_THR_NON_PAUSE 0 |
| 246 | |
| 247 | #define PFC_E3B0_4P_BRB_MAC_PAUSE_XON_THR_PAUSE 384 |
| 248 | #define PFC_E3B0_4P_BRB_MAC_PAUSE_XON_THR_NON_PAUSE 0 |
| 249 | |
| 250 | #define PFC_E3B0_4P_BRB_MAC_FULL_XOFF_THR_PAUSE 10 |
| 251 | #define PFC_E3B0_4P_BRB_MAC_FULL_XOFF_THR_NON_PAUSE 304 |
| 252 | |
| 253 | #define PFC_E3B0_4P_BRB_MAC_FULL_XON_THR_PAUSE 50 |
| 254 | #define PFC_E3B0_4P_BRB_MAC_FULL_XON_THR_NON_PAUSE 384 |
| 255 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 256 | /* only for E3B0*/ |
| 257 | #define PFC_E3B0_4P_BRB_FULL_LB_XOFF_THR 304 |
| 258 | #define PFC_E3B0_4P_BRB_FULL_LB_XON_THR 384 |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 259 | #define PFC_E3B0_4P_LB_GUART 120 |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 260 | |
| 261 | #define PFC_E3B0_4P_BRB_MAC_0_CLASS_T_GUART 120 |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 262 | #define PFC_E3B0_4P_BRB_MAC_0_CLASS_T_GUART_HYST 80 |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 263 | |
| 264 | #define PFC_E3B0_4P_BRB_MAC_1_CLASS_T_GUART 80 |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 265 | #define PFC_E3B0_4P_BRB_MAC_1_CLASS_T_GUART_HYST 120 |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 266 | |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 267 | /* Pause defines*/ |
| 268 | #define DEFAULT_E3B0_BRB_FULL_LB_XOFF_THR 330 |
| 269 | #define DEFAULT_E3B0_BRB_FULL_LB_XON_THR 490 |
| 270 | #define DEFAULT_E3B0_LB_GUART 40 |
| 271 | |
| 272 | #define DEFAULT_E3B0_BRB_MAC_0_CLASS_T_GUART 40 |
| 273 | #define DEFAULT_E3B0_BRB_MAC_0_CLASS_T_GUART_HYST 0 |
| 274 | |
| 275 | #define DEFAULT_E3B0_BRB_MAC_1_CLASS_T_GUART 40 |
| 276 | #define DEFAULT_E3B0_BRB_MAC_1_CLASS_T_GUART_HYST 0 |
| 277 | |
| 278 | /* ETS defines*/ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 279 | #define DCBX_INVALID_COS (0xFF) |
| 280 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 281 | #define ETS_BW_LIMIT_CREDIT_UPPER_BOUND (0x5000) |
| 282 | #define ETS_BW_LIMIT_CREDIT_WEIGHT (0x5000) |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 283 | #define ETS_E3B0_NIG_MIN_W_VAL_UP_TO_10GBPS (1360) |
| 284 | #define ETS_E3B0_NIG_MIN_W_VAL_20GBPS (2720) |
| 285 | #define ETS_E3B0_PBF_MIN_W_VAL (10000) |
| 286 | |
| 287 | #define MAX_PACKET_SIZE (9700) |
Yaniv Rosner | a9077bf | 2011-10-27 05:09:46 +0000 | [diff] [blame] | 288 | #define MAX_KR_LINK_RETRY 4 |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 289 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 290 | /**********************************************************/ |
| 291 | /* INTERFACE */ |
| 292 | /**********************************************************/ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 293 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 294 | #define CL22_WR_OVER_CL45(_bp, _phy, _bank, _addr, _val) \ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 295 | bnx2x_cl45_write(_bp, _phy, \ |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 296 | (_phy)->def_md_devad, \ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 297 | (_bank + (_addr & 0xf)), \ |
| 298 | _val) |
| 299 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 300 | #define CL22_RD_OVER_CL45(_bp, _phy, _bank, _addr, _val) \ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 301 | bnx2x_cl45_read(_bp, _phy, \ |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 302 | (_phy)->def_md_devad, \ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 303 | (_bank + (_addr & 0xf)), \ |
| 304 | _val) |
| 305 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 306 | static u32 bnx2x_bits_en(struct bnx2x *bp, u32 reg, u32 bits) |
| 307 | { |
| 308 | u32 val = REG_RD(bp, reg); |
| 309 | |
| 310 | val |= bits; |
| 311 | REG_WR(bp, reg, val); |
| 312 | return val; |
| 313 | } |
| 314 | |
| 315 | static u32 bnx2x_bits_dis(struct bnx2x *bp, u32 reg, u32 bits) |
| 316 | { |
| 317 | u32 val = REG_RD(bp, reg); |
| 318 | |
| 319 | val &= ~bits; |
| 320 | REG_WR(bp, reg, val); |
| 321 | return val; |
| 322 | } |
| 323 | |
Yaniv Rosner | d3a8f13 | 2012-09-13 02:56:20 +0000 | [diff] [blame] | 324 | /* |
| 325 | * bnx2x_check_lfa - This function checks if link reinitialization is required, |
| 326 | * or link flap can be avoided. |
| 327 | * |
| 328 | * @params: link parameters |
| 329 | * Returns 0 if Link Flap Avoidance conditions are met otherwise, the failed |
| 330 | * condition code. |
| 331 | */ |
| 332 | static int bnx2x_check_lfa(struct link_params *params) |
| 333 | { |
| 334 | u32 link_status, cfg_idx, lfa_mask, cfg_size; |
| 335 | u32 cur_speed_cap_mask, cur_req_fc_auto_adv, additional_config; |
| 336 | u32 saved_val, req_val, eee_status; |
| 337 | struct bnx2x *bp = params->bp; |
| 338 | |
| 339 | additional_config = |
| 340 | REG_RD(bp, params->lfa_base + |
| 341 | offsetof(struct shmem_lfa, additional_config)); |
| 342 | |
| 343 | /* NOTE: must be first condition checked - |
| 344 | * to verify DCC bit is cleared in any case! |
| 345 | */ |
| 346 | if (additional_config & NO_LFA_DUE_TO_DCC_MASK) { |
| 347 | DP(NETIF_MSG_LINK, "No LFA due to DCC flap after clp exit\n"); |
| 348 | REG_WR(bp, params->lfa_base + |
| 349 | offsetof(struct shmem_lfa, additional_config), |
| 350 | additional_config & ~NO_LFA_DUE_TO_DCC_MASK); |
| 351 | return LFA_DCC_LFA_DISABLED; |
| 352 | } |
| 353 | |
| 354 | /* Verify that link is up */ |
| 355 | link_status = REG_RD(bp, params->shmem_base + |
| 356 | offsetof(struct shmem_region, |
| 357 | port_mb[params->port].link_status)); |
| 358 | if (!(link_status & LINK_STATUS_LINK_UP)) |
| 359 | return LFA_LINK_DOWN; |
| 360 | |
| 361 | /* Verify that loopback mode is not set */ |
| 362 | if (params->loopback_mode) |
| 363 | return LFA_LOOPBACK_ENABLED; |
| 364 | |
| 365 | /* Verify that MFW supports LFA */ |
| 366 | if (!params->lfa_base) |
| 367 | return LFA_MFW_IS_TOO_OLD; |
| 368 | |
| 369 | if (params->num_phys == 3) { |
| 370 | cfg_size = 2; |
| 371 | lfa_mask = 0xffffffff; |
| 372 | } else { |
| 373 | cfg_size = 1; |
| 374 | lfa_mask = 0xffff; |
| 375 | } |
| 376 | |
| 377 | /* Compare Duplex */ |
| 378 | saved_val = REG_RD(bp, params->lfa_base + |
| 379 | offsetof(struct shmem_lfa, req_duplex)); |
| 380 | req_val = params->req_duplex[0] | (params->req_duplex[1] << 16); |
| 381 | if ((saved_val & lfa_mask) != (req_val & lfa_mask)) { |
| 382 | DP(NETIF_MSG_LINK, "Duplex mismatch %x vs. %x\n", |
| 383 | (saved_val & lfa_mask), (req_val & lfa_mask)); |
| 384 | return LFA_DUPLEX_MISMATCH; |
| 385 | } |
| 386 | /* Compare Flow Control */ |
| 387 | saved_val = REG_RD(bp, params->lfa_base + |
| 388 | offsetof(struct shmem_lfa, req_flow_ctrl)); |
| 389 | req_val = params->req_flow_ctrl[0] | (params->req_flow_ctrl[1] << 16); |
| 390 | if ((saved_val & lfa_mask) != (req_val & lfa_mask)) { |
| 391 | DP(NETIF_MSG_LINK, "Flow control mismatch %x vs. %x\n", |
| 392 | (saved_val & lfa_mask), (req_val & lfa_mask)); |
| 393 | return LFA_FLOW_CTRL_MISMATCH; |
| 394 | } |
| 395 | /* Compare Link Speed */ |
| 396 | saved_val = REG_RD(bp, params->lfa_base + |
| 397 | offsetof(struct shmem_lfa, req_line_speed)); |
| 398 | req_val = params->req_line_speed[0] | (params->req_line_speed[1] << 16); |
| 399 | if ((saved_val & lfa_mask) != (req_val & lfa_mask)) { |
| 400 | DP(NETIF_MSG_LINK, "Link speed mismatch %x vs. %x\n", |
| 401 | (saved_val & lfa_mask), (req_val & lfa_mask)); |
| 402 | return LFA_LINK_SPEED_MISMATCH; |
| 403 | } |
| 404 | |
| 405 | for (cfg_idx = 0; cfg_idx < cfg_size; cfg_idx++) { |
| 406 | cur_speed_cap_mask = REG_RD(bp, params->lfa_base + |
| 407 | offsetof(struct shmem_lfa, |
| 408 | speed_cap_mask[cfg_idx])); |
| 409 | |
| 410 | if (cur_speed_cap_mask != params->speed_cap_mask[cfg_idx]) { |
| 411 | DP(NETIF_MSG_LINK, "Speed Cap mismatch %x vs. %x\n", |
| 412 | cur_speed_cap_mask, |
| 413 | params->speed_cap_mask[cfg_idx]); |
| 414 | return LFA_SPEED_CAP_MISMATCH; |
| 415 | } |
| 416 | } |
| 417 | |
| 418 | cur_req_fc_auto_adv = |
| 419 | REG_RD(bp, params->lfa_base + |
| 420 | offsetof(struct shmem_lfa, additional_config)) & |
| 421 | REQ_FC_AUTO_ADV_MASK; |
| 422 | |
| 423 | if ((u16)cur_req_fc_auto_adv != params->req_fc_auto_adv) { |
| 424 | DP(NETIF_MSG_LINK, "Flow Ctrl AN mismatch %x vs. %x\n", |
| 425 | cur_req_fc_auto_adv, params->req_fc_auto_adv); |
| 426 | return LFA_FLOW_CTRL_MISMATCH; |
| 427 | } |
| 428 | |
| 429 | eee_status = REG_RD(bp, params->shmem2_base + |
| 430 | offsetof(struct shmem2_region, |
| 431 | eee_status[params->port])); |
| 432 | |
| 433 | if (((eee_status & SHMEM_EEE_LPI_REQUESTED_BIT) ^ |
| 434 | (params->eee_mode & EEE_MODE_ENABLE_LPI)) || |
| 435 | ((eee_status & SHMEM_EEE_REQUESTED_BIT) ^ |
| 436 | (params->eee_mode & EEE_MODE_ADV_LPI))) { |
| 437 | DP(NETIF_MSG_LINK, "EEE mismatch %x vs. %x\n", params->eee_mode, |
| 438 | eee_status); |
| 439 | return LFA_EEE_MISMATCH; |
| 440 | } |
| 441 | |
| 442 | /* LFA conditions are met */ |
| 443 | return 0; |
| 444 | } |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 445 | /******************************************************************/ |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 446 | /* EPIO/GPIO section */ |
| 447 | /******************************************************************/ |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 448 | static void bnx2x_get_epio(struct bnx2x *bp, u32 epio_pin, u32 *en) |
| 449 | { |
| 450 | u32 epio_mask, gp_oenable; |
| 451 | *en = 0; |
| 452 | /* Sanity check */ |
| 453 | if (epio_pin > 31) { |
| 454 | DP(NETIF_MSG_LINK, "Invalid EPIO pin %d to get\n", epio_pin); |
| 455 | return; |
| 456 | } |
| 457 | |
| 458 | epio_mask = 1 << epio_pin; |
| 459 | /* Set this EPIO to output */ |
| 460 | gp_oenable = REG_RD(bp, MCP_REG_MCPR_GP_OENABLE); |
| 461 | REG_WR(bp, MCP_REG_MCPR_GP_OENABLE, gp_oenable & ~epio_mask); |
| 462 | |
| 463 | *en = (REG_RD(bp, MCP_REG_MCPR_GP_INPUTS) & epio_mask) >> epio_pin; |
| 464 | } |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 465 | static void bnx2x_set_epio(struct bnx2x *bp, u32 epio_pin, u32 en) |
| 466 | { |
| 467 | u32 epio_mask, gp_output, gp_oenable; |
| 468 | |
| 469 | /* Sanity check */ |
| 470 | if (epio_pin > 31) { |
| 471 | DP(NETIF_MSG_LINK, "Invalid EPIO pin %d to set\n", epio_pin); |
| 472 | return; |
| 473 | } |
| 474 | DP(NETIF_MSG_LINK, "Setting EPIO pin %d to %d\n", epio_pin, en); |
| 475 | epio_mask = 1 << epio_pin; |
| 476 | /* Set this EPIO to output */ |
| 477 | gp_output = REG_RD(bp, MCP_REG_MCPR_GP_OUTPUTS); |
| 478 | if (en) |
| 479 | gp_output |= epio_mask; |
| 480 | else |
| 481 | gp_output &= ~epio_mask; |
| 482 | |
| 483 | REG_WR(bp, MCP_REG_MCPR_GP_OUTPUTS, gp_output); |
| 484 | |
| 485 | /* Set the value for this EPIO */ |
| 486 | gp_oenable = REG_RD(bp, MCP_REG_MCPR_GP_OENABLE); |
| 487 | REG_WR(bp, MCP_REG_MCPR_GP_OENABLE, gp_oenable | epio_mask); |
| 488 | } |
| 489 | |
| 490 | static void bnx2x_set_cfg_pin(struct bnx2x *bp, u32 pin_cfg, u32 val) |
| 491 | { |
| 492 | if (pin_cfg == PIN_CFG_NA) |
| 493 | return; |
| 494 | if (pin_cfg >= PIN_CFG_EPIO0) { |
| 495 | bnx2x_set_epio(bp, pin_cfg - PIN_CFG_EPIO0, val); |
| 496 | } else { |
| 497 | u8 gpio_num = (pin_cfg - PIN_CFG_GPIO0_P0) & 0x3; |
| 498 | u8 gpio_port = (pin_cfg - PIN_CFG_GPIO0_P0) >> 2; |
| 499 | bnx2x_set_gpio(bp, gpio_num, (u8)val, gpio_port); |
| 500 | } |
| 501 | } |
| 502 | |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 503 | static u32 bnx2x_get_cfg_pin(struct bnx2x *bp, u32 pin_cfg, u32 *val) |
| 504 | { |
| 505 | if (pin_cfg == PIN_CFG_NA) |
| 506 | return -EINVAL; |
| 507 | if (pin_cfg >= PIN_CFG_EPIO0) { |
| 508 | bnx2x_get_epio(bp, pin_cfg - PIN_CFG_EPIO0, val); |
| 509 | } else { |
| 510 | u8 gpio_num = (pin_cfg - PIN_CFG_GPIO0_P0) & 0x3; |
| 511 | u8 gpio_port = (pin_cfg - PIN_CFG_GPIO0_P0) >> 2; |
| 512 | *val = bnx2x_get_gpio(bp, gpio_num, gpio_port); |
| 513 | } |
| 514 | return 0; |
| 515 | |
| 516 | } |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 517 | /******************************************************************/ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 518 | /* ETS section */ |
| 519 | /******************************************************************/ |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 520 | static void bnx2x_ets_e2e3a0_disabled(struct link_params *params) |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 521 | { |
| 522 | /* ETS disabled configuration*/ |
| 523 | struct bnx2x *bp = params->bp; |
| 524 | |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 525 | DP(NETIF_MSG_LINK, "ETS E2E3 disabled configuration\n"); |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 526 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 527 | /* mapping between entry priority to client number (0,1,2 -debug and |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 528 | * management clients, 3 - COS0 client, 4 - COS client)(HIGHEST) |
| 529 | * 3bits client num. |
| 530 | * PRI4 | PRI3 | PRI2 | PRI1 | PRI0 |
| 531 | * cos1-100 cos0-011 dbg1-010 dbg0-001 MCP-000 |
| 532 | */ |
| 533 | |
| 534 | REG_WR(bp, NIG_REG_P0_TX_ARB_PRIORITY_CLIENT, 0x4688); |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 535 | /* Bitmap of 5bits length. Each bit specifies whether the entry behaves |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 536 | * as strict. Bits 0,1,2 - debug and management entries, 3 - |
| 537 | * COS0 entry, 4 - COS1 entry. |
| 538 | * COS1 | COS0 | DEBUG1 | DEBUG0 | MGMT |
| 539 | * bit4 bit3 bit2 bit1 bit0 |
| 540 | * MCP and debug are strict |
| 541 | */ |
| 542 | |
| 543 | REG_WR(bp, NIG_REG_P0_TX_ARB_CLIENT_IS_STRICT, 0x7); |
| 544 | /* defines which entries (clients) are subjected to WFQ arbitration */ |
| 545 | REG_WR(bp, NIG_REG_P0_TX_ARB_CLIENT_IS_SUBJECT2WFQ, 0); |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 546 | /* For strict priority entries defines the number of consecutive |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 547 | * slots for the highest priority. |
| 548 | */ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 549 | REG_WR(bp, NIG_REG_P0_TX_ARB_NUM_STRICT_ARB_SLOTS, 0x100); |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 550 | /* mapping between the CREDIT_WEIGHT registers and actual client |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 551 | * numbers |
| 552 | */ |
| 553 | REG_WR(bp, NIG_REG_P0_TX_ARB_CLIENT_CREDIT_MAP, 0); |
| 554 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_0, 0); |
| 555 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_1, 0); |
| 556 | |
| 557 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_0, 0); |
| 558 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_1, 0); |
| 559 | REG_WR(bp, PBF_REG_HIGH_PRIORITY_COS_NUM, 0); |
| 560 | /* ETS mode disable */ |
| 561 | REG_WR(bp, PBF_REG_ETS_ENABLED, 0); |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 562 | /* If ETS mode is enabled (there is no strict priority) defines a WFQ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 563 | * weight for COS0/COS1. |
| 564 | */ |
| 565 | REG_WR(bp, PBF_REG_COS0_WEIGHT, 0x2710); |
| 566 | REG_WR(bp, PBF_REG_COS1_WEIGHT, 0x2710); |
| 567 | /* Upper bound that COS0_WEIGHT can reach in the WFQ arbiter */ |
| 568 | REG_WR(bp, PBF_REG_COS0_UPPER_BOUND, 0x989680); |
| 569 | REG_WR(bp, PBF_REG_COS1_UPPER_BOUND, 0x989680); |
| 570 | /* Defines the number of consecutive slots for the strict priority */ |
| 571 | REG_WR(bp, PBF_REG_NUM_STRICT_ARB_SLOTS, 0); |
| 572 | } |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 573 | /****************************************************************************** |
| 574 | * Description: |
| 575 | * Getting min_w_val will be set according to line speed . |
| 576 | *. |
| 577 | ******************************************************************************/ |
| 578 | static u32 bnx2x_ets_get_min_w_val_nig(const struct link_vars *vars) |
| 579 | { |
| 580 | u32 min_w_val = 0; |
| 581 | /* Calculate min_w_val.*/ |
| 582 | if (vars->link_up) { |
Yaniv Rosner | de0396f | 2011-11-28 00:49:53 +0000 | [diff] [blame] | 583 | if (vars->line_speed == SPEED_20000) |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 584 | min_w_val = ETS_E3B0_NIG_MIN_W_VAL_20GBPS; |
| 585 | else |
| 586 | min_w_val = ETS_E3B0_NIG_MIN_W_VAL_UP_TO_10GBPS; |
| 587 | } else |
| 588 | min_w_val = ETS_E3B0_NIG_MIN_W_VAL_20GBPS; |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 589 | /* If the link isn't up (static configuration for example ) The |
| 590 | * link will be according to 20GBPS. |
| 591 | */ |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 592 | return min_w_val; |
| 593 | } |
| 594 | /****************************************************************************** |
| 595 | * Description: |
| 596 | * Getting credit upper bound form min_w_val. |
| 597 | *. |
| 598 | ******************************************************************************/ |
| 599 | static u32 bnx2x_ets_get_credit_upper_bound(const u32 min_w_val) |
| 600 | { |
| 601 | const u32 credit_upper_bound = (u32)MAXVAL((150 * min_w_val), |
| 602 | MAX_PACKET_SIZE); |
| 603 | return credit_upper_bound; |
| 604 | } |
| 605 | /****************************************************************************** |
| 606 | * Description: |
| 607 | * Set credit upper bound for NIG. |
| 608 | *. |
| 609 | ******************************************************************************/ |
| 610 | static void bnx2x_ets_e3b0_set_credit_upper_bound_nig( |
| 611 | const struct link_params *params, |
| 612 | const u32 min_w_val) |
| 613 | { |
| 614 | struct bnx2x *bp = params->bp; |
| 615 | const u8 port = params->port; |
| 616 | const u32 credit_upper_bound = |
| 617 | bnx2x_ets_get_credit_upper_bound(min_w_val); |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 618 | |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 619 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CREDIT_UPPER_BOUND_0 : |
| 620 | NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_0, credit_upper_bound); |
| 621 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CREDIT_UPPER_BOUND_1 : |
| 622 | NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_1, credit_upper_bound); |
| 623 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CREDIT_UPPER_BOUND_2 : |
| 624 | NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_2, credit_upper_bound); |
| 625 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CREDIT_UPPER_BOUND_3 : |
| 626 | NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_3, credit_upper_bound); |
| 627 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CREDIT_UPPER_BOUND_4 : |
| 628 | NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_4, credit_upper_bound); |
| 629 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CREDIT_UPPER_BOUND_5 : |
| 630 | NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_5, credit_upper_bound); |
| 631 | |
Yaniv Rosner | de0396f | 2011-11-28 00:49:53 +0000 | [diff] [blame] | 632 | if (!port) { |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 633 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_6, |
| 634 | credit_upper_bound); |
| 635 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_7, |
| 636 | credit_upper_bound); |
| 637 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_8, |
| 638 | credit_upper_bound); |
| 639 | } |
| 640 | } |
| 641 | /****************************************************************************** |
| 642 | * Description: |
| 643 | * Will return the NIG ETS registers to init values.Except |
| 644 | * credit_upper_bound. |
| 645 | * That isn't used in this configuration (No WFQ is enabled) and will be |
| 646 | * configured acording to spec |
| 647 | *. |
| 648 | ******************************************************************************/ |
| 649 | static void bnx2x_ets_e3b0_nig_disabled(const struct link_params *params, |
| 650 | const struct link_vars *vars) |
| 651 | { |
| 652 | struct bnx2x *bp = params->bp; |
| 653 | const u8 port = params->port; |
| 654 | const u32 min_w_val = bnx2x_ets_get_min_w_val_nig(vars); |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 655 | /* Mapping between entry priority to client number (0,1,2 -debug and |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 656 | * management clients, 3 - COS0 client, 4 - COS1, ... 8 - |
| 657 | * COS5)(HIGHEST) 4bits client num.TODO_ETS - Should be done by |
| 658 | * reset value or init tool |
| 659 | */ |
| 660 | if (port) { |
| 661 | REG_WR(bp, NIG_REG_P1_TX_ARB_PRIORITY_CLIENT2_LSB, 0x543210); |
| 662 | REG_WR(bp, NIG_REG_P1_TX_ARB_PRIORITY_CLIENT2_MSB, 0x0); |
| 663 | } else { |
| 664 | REG_WR(bp, NIG_REG_P0_TX_ARB_PRIORITY_CLIENT2_LSB, 0x76543210); |
| 665 | REG_WR(bp, NIG_REG_P0_TX_ARB_PRIORITY_CLIENT2_MSB, 0x8); |
| 666 | } |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 667 | /* For strict priority entries defines the number of consecutive |
| 668 | * slots for the highest priority. |
| 669 | */ |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 670 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_NUM_STRICT_ARB_SLOTS : |
| 671 | NIG_REG_P1_TX_ARB_NUM_STRICT_ARB_SLOTS, 0x100); |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 672 | /* Mapping between the CREDIT_WEIGHT registers and actual client |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 673 | * numbers |
| 674 | */ |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 675 | if (port) { |
| 676 | /*Port 1 has 6 COS*/ |
| 677 | REG_WR(bp, NIG_REG_P1_TX_ARB_CLIENT_CREDIT_MAP2_LSB, 0x210543); |
| 678 | REG_WR(bp, NIG_REG_P1_TX_ARB_CLIENT_CREDIT_MAP2_MSB, 0x0); |
| 679 | } else { |
| 680 | /*Port 0 has 9 COS*/ |
| 681 | REG_WR(bp, NIG_REG_P0_TX_ARB_CLIENT_CREDIT_MAP2_LSB, |
| 682 | 0x43210876); |
| 683 | REG_WR(bp, NIG_REG_P0_TX_ARB_CLIENT_CREDIT_MAP2_MSB, 0x5); |
| 684 | } |
| 685 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 686 | /* Bitmap of 5bits length. Each bit specifies whether the entry behaves |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 687 | * as strict. Bits 0,1,2 - debug and management entries, 3 - |
| 688 | * COS0 entry, 4 - COS1 entry. |
| 689 | * COS1 | COS0 | DEBUG1 | DEBUG0 | MGMT |
| 690 | * bit4 bit3 bit2 bit1 bit0 |
| 691 | * MCP and debug are strict |
| 692 | */ |
| 693 | if (port) |
| 694 | REG_WR(bp, NIG_REG_P1_TX_ARB_CLIENT_IS_STRICT, 0x3f); |
| 695 | else |
| 696 | REG_WR(bp, NIG_REG_P0_TX_ARB_CLIENT_IS_STRICT, 0x1ff); |
| 697 | /* defines which entries (clients) are subjected to WFQ arbitration */ |
| 698 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CLIENT_IS_SUBJECT2WFQ : |
| 699 | NIG_REG_P0_TX_ARB_CLIENT_IS_SUBJECT2WFQ, 0); |
| 700 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 701 | /* Please notice the register address are note continuous and a |
| 702 | * for here is note appropriate.In 2 port mode port0 only COS0-5 |
| 703 | * can be used. DEBUG1,DEBUG1,MGMT are never used for WFQ* In 4 |
| 704 | * port mode port1 only COS0-2 can be used. DEBUG1,DEBUG1,MGMT |
| 705 | * are never used for WFQ |
| 706 | */ |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 707 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CREDIT_WEIGHT_0 : |
| 708 | NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_0, 0x0); |
| 709 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CREDIT_WEIGHT_1 : |
| 710 | NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_1, 0x0); |
| 711 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CREDIT_WEIGHT_2 : |
| 712 | NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_2, 0x0); |
| 713 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CREDIT_WEIGHT_3 : |
| 714 | NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_3, 0x0); |
| 715 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CREDIT_WEIGHT_4 : |
| 716 | NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_4, 0x0); |
| 717 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CREDIT_WEIGHT_5 : |
| 718 | NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_5, 0x0); |
Yaniv Rosner | de0396f | 2011-11-28 00:49:53 +0000 | [diff] [blame] | 719 | if (!port) { |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 720 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_6, 0x0); |
| 721 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_7, 0x0); |
| 722 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_8, 0x0); |
| 723 | } |
| 724 | |
| 725 | bnx2x_ets_e3b0_set_credit_upper_bound_nig(params, min_w_val); |
| 726 | } |
| 727 | /****************************************************************************** |
| 728 | * Description: |
| 729 | * Set credit upper bound for PBF. |
| 730 | *. |
| 731 | ******************************************************************************/ |
| 732 | static void bnx2x_ets_e3b0_set_credit_upper_bound_pbf( |
| 733 | const struct link_params *params, |
| 734 | const u32 min_w_val) |
| 735 | { |
| 736 | struct bnx2x *bp = params->bp; |
| 737 | const u32 credit_upper_bound = |
| 738 | bnx2x_ets_get_credit_upper_bound(min_w_val); |
| 739 | const u8 port = params->port; |
| 740 | u32 base_upper_bound = 0; |
| 741 | u8 max_cos = 0; |
| 742 | u8 i = 0; |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 743 | /* In 2 port mode port0 has COS0-5 that can be used for WFQ.In 4 |
| 744 | * port mode port1 has COS0-2 that can be used for WFQ. |
| 745 | */ |
Yaniv Rosner | de0396f | 2011-11-28 00:49:53 +0000 | [diff] [blame] | 746 | if (!port) { |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 747 | base_upper_bound = PBF_REG_COS0_UPPER_BOUND_P0; |
| 748 | max_cos = DCBX_E3B0_MAX_NUM_COS_PORT0; |
| 749 | } else { |
| 750 | base_upper_bound = PBF_REG_COS0_UPPER_BOUND_P1; |
| 751 | max_cos = DCBX_E3B0_MAX_NUM_COS_PORT1; |
| 752 | } |
| 753 | |
| 754 | for (i = 0; i < max_cos; i++) |
| 755 | REG_WR(bp, base_upper_bound + (i << 2), credit_upper_bound); |
| 756 | } |
| 757 | |
| 758 | /****************************************************************************** |
| 759 | * Description: |
| 760 | * Will return the PBF ETS registers to init values.Except |
| 761 | * credit_upper_bound. |
| 762 | * That isn't used in this configuration (No WFQ is enabled) and will be |
| 763 | * configured acording to spec |
| 764 | *. |
| 765 | ******************************************************************************/ |
| 766 | static void bnx2x_ets_e3b0_pbf_disabled(const struct link_params *params) |
| 767 | { |
| 768 | struct bnx2x *bp = params->bp; |
| 769 | const u8 port = params->port; |
| 770 | const u32 min_w_val_pbf = ETS_E3B0_PBF_MIN_W_VAL; |
| 771 | u8 i = 0; |
| 772 | u32 base_weight = 0; |
| 773 | u8 max_cos = 0; |
| 774 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 775 | /* Mapping between entry priority to client number 0 - COS0 |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 776 | * client, 2 - COS1, ... 5 - COS5)(HIGHEST) 4bits client num. |
| 777 | * TODO_ETS - Should be done by reset value or init tool |
| 778 | */ |
| 779 | if (port) |
| 780 | /* 0x688 (|011|0 10|00 1|000) */ |
| 781 | REG_WR(bp, PBF_REG_ETS_ARB_PRIORITY_CLIENT_P1 , 0x688); |
| 782 | else |
| 783 | /* (10 1|100 |011|0 10|00 1|000) */ |
| 784 | REG_WR(bp, PBF_REG_ETS_ARB_PRIORITY_CLIENT_P0 , 0x2C688); |
| 785 | |
| 786 | /* TODO_ETS - Should be done by reset value or init tool */ |
| 787 | if (port) |
| 788 | /* 0x688 (|011|0 10|00 1|000)*/ |
| 789 | REG_WR(bp, PBF_REG_ETS_ARB_CLIENT_CREDIT_MAP_P1, 0x688); |
| 790 | else |
| 791 | /* 0x2C688 (10 1|100 |011|0 10|00 1|000) */ |
| 792 | REG_WR(bp, PBF_REG_ETS_ARB_CLIENT_CREDIT_MAP_P0, 0x2C688); |
| 793 | |
| 794 | REG_WR(bp, (port) ? PBF_REG_ETS_ARB_NUM_STRICT_ARB_SLOTS_P1 : |
| 795 | PBF_REG_ETS_ARB_NUM_STRICT_ARB_SLOTS_P0 , 0x100); |
| 796 | |
| 797 | |
| 798 | REG_WR(bp, (port) ? PBF_REG_ETS_ARB_CLIENT_IS_STRICT_P1 : |
| 799 | PBF_REG_ETS_ARB_CLIENT_IS_STRICT_P0 , 0); |
| 800 | |
| 801 | REG_WR(bp, (port) ? PBF_REG_ETS_ARB_CLIENT_IS_SUBJECT2WFQ_P1 : |
| 802 | PBF_REG_ETS_ARB_CLIENT_IS_SUBJECT2WFQ_P0 , 0); |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 803 | /* In 2 port mode port0 has COS0-5 that can be used for WFQ. |
| 804 | * In 4 port mode port1 has COS0-2 that can be used for WFQ. |
| 805 | */ |
Yaniv Rosner | de0396f | 2011-11-28 00:49:53 +0000 | [diff] [blame] | 806 | if (!port) { |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 807 | base_weight = PBF_REG_COS0_WEIGHT_P0; |
| 808 | max_cos = DCBX_E3B0_MAX_NUM_COS_PORT0; |
| 809 | } else { |
| 810 | base_weight = PBF_REG_COS0_WEIGHT_P1; |
| 811 | max_cos = DCBX_E3B0_MAX_NUM_COS_PORT1; |
| 812 | } |
| 813 | |
| 814 | for (i = 0; i < max_cos; i++) |
| 815 | REG_WR(bp, base_weight + (0x4 * i), 0); |
| 816 | |
| 817 | bnx2x_ets_e3b0_set_credit_upper_bound_pbf(params, min_w_val_pbf); |
| 818 | } |
| 819 | /****************************************************************************** |
| 820 | * Description: |
| 821 | * E3B0 disable will return basicly the values to init values. |
| 822 | *. |
| 823 | ******************************************************************************/ |
| 824 | static int bnx2x_ets_e3b0_disabled(const struct link_params *params, |
| 825 | const struct link_vars *vars) |
| 826 | { |
| 827 | struct bnx2x *bp = params->bp; |
| 828 | |
| 829 | if (!CHIP_IS_E3B0(bp)) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 830 | DP(NETIF_MSG_LINK, |
| 831 | "bnx2x_ets_e3b0_disabled the chip isn't E3B0\n"); |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 832 | return -EINVAL; |
| 833 | } |
| 834 | |
| 835 | bnx2x_ets_e3b0_nig_disabled(params, vars); |
| 836 | |
| 837 | bnx2x_ets_e3b0_pbf_disabled(params); |
| 838 | |
| 839 | return 0; |
| 840 | } |
| 841 | |
| 842 | /****************************************************************************** |
| 843 | * Description: |
| 844 | * Disable will return basicly the values to init values. |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 845 | * |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 846 | ******************************************************************************/ |
| 847 | int bnx2x_ets_disabled(struct link_params *params, |
| 848 | struct link_vars *vars) |
| 849 | { |
| 850 | struct bnx2x *bp = params->bp; |
| 851 | int bnx2x_status = 0; |
| 852 | |
| 853 | if ((CHIP_IS_E2(bp)) || (CHIP_IS_E3A0(bp))) |
| 854 | bnx2x_ets_e2e3a0_disabled(params); |
| 855 | else if (CHIP_IS_E3B0(bp)) |
| 856 | bnx2x_status = bnx2x_ets_e3b0_disabled(params, vars); |
| 857 | else { |
| 858 | DP(NETIF_MSG_LINK, "bnx2x_ets_disabled - chip not supported\n"); |
| 859 | return -EINVAL; |
| 860 | } |
| 861 | |
| 862 | return bnx2x_status; |
| 863 | } |
| 864 | |
| 865 | /****************************************************************************** |
| 866 | * Description |
| 867 | * Set the COS mappimg to SP and BW until this point all the COS are not |
| 868 | * set as SP or BW. |
| 869 | ******************************************************************************/ |
| 870 | static int bnx2x_ets_e3b0_cli_map(const struct link_params *params, |
| 871 | const struct bnx2x_ets_params *ets_params, |
| 872 | const u8 cos_sp_bitmap, |
| 873 | const u8 cos_bw_bitmap) |
| 874 | { |
| 875 | struct bnx2x *bp = params->bp; |
| 876 | const u8 port = params->port; |
| 877 | const u8 nig_cli_sp_bitmap = 0x7 | (cos_sp_bitmap << 3); |
| 878 | const u8 pbf_cli_sp_bitmap = cos_sp_bitmap; |
| 879 | const u8 nig_cli_subject2wfq_bitmap = cos_bw_bitmap << 3; |
| 880 | const u8 pbf_cli_subject2wfq_bitmap = cos_bw_bitmap; |
| 881 | |
| 882 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CLIENT_IS_STRICT : |
| 883 | NIG_REG_P0_TX_ARB_CLIENT_IS_STRICT, nig_cli_sp_bitmap); |
| 884 | |
| 885 | REG_WR(bp, (port) ? PBF_REG_ETS_ARB_CLIENT_IS_STRICT_P1 : |
| 886 | PBF_REG_ETS_ARB_CLIENT_IS_STRICT_P0 , pbf_cli_sp_bitmap); |
| 887 | |
| 888 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CLIENT_IS_SUBJECT2WFQ : |
| 889 | NIG_REG_P0_TX_ARB_CLIENT_IS_SUBJECT2WFQ, |
| 890 | nig_cli_subject2wfq_bitmap); |
| 891 | |
| 892 | REG_WR(bp, (port) ? PBF_REG_ETS_ARB_CLIENT_IS_SUBJECT2WFQ_P1 : |
| 893 | PBF_REG_ETS_ARB_CLIENT_IS_SUBJECT2WFQ_P0, |
| 894 | pbf_cli_subject2wfq_bitmap); |
| 895 | |
| 896 | return 0; |
| 897 | } |
| 898 | |
| 899 | /****************************************************************************** |
| 900 | * Description: |
| 901 | * This function is needed because NIG ARB_CREDIT_WEIGHT_X are |
| 902 | * not continues and ARB_CREDIT_WEIGHT_0 + offset is suitable. |
| 903 | ******************************************************************************/ |
| 904 | static int bnx2x_ets_e3b0_set_cos_bw(struct bnx2x *bp, |
| 905 | const u8 cos_entry, |
| 906 | const u32 min_w_val_nig, |
| 907 | const u32 min_w_val_pbf, |
| 908 | const u16 total_bw, |
| 909 | const u8 bw, |
| 910 | const u8 port) |
| 911 | { |
| 912 | u32 nig_reg_adress_crd_weight = 0; |
| 913 | u32 pbf_reg_adress_crd_weight = 0; |
David S. Miller | 8decf86 | 2011-09-22 03:23:13 -0400 | [diff] [blame] | 914 | /* Calculate and set BW for this COS - use 1 instead of 0 for BW */ |
| 915 | const u32 cos_bw_nig = ((bw ? bw : 1) * min_w_val_nig) / total_bw; |
| 916 | const u32 cos_bw_pbf = ((bw ? bw : 1) * min_w_val_pbf) / total_bw; |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 917 | |
| 918 | switch (cos_entry) { |
| 919 | case 0: |
| 920 | nig_reg_adress_crd_weight = |
| 921 | (port) ? NIG_REG_P1_TX_ARB_CREDIT_WEIGHT_0 : |
| 922 | NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_0; |
| 923 | pbf_reg_adress_crd_weight = (port) ? |
| 924 | PBF_REG_COS0_WEIGHT_P1 : PBF_REG_COS0_WEIGHT_P0; |
| 925 | break; |
| 926 | case 1: |
| 927 | nig_reg_adress_crd_weight = (port) ? |
| 928 | NIG_REG_P1_TX_ARB_CREDIT_WEIGHT_1 : |
| 929 | NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_1; |
| 930 | pbf_reg_adress_crd_weight = (port) ? |
| 931 | PBF_REG_COS1_WEIGHT_P1 : PBF_REG_COS1_WEIGHT_P0; |
| 932 | break; |
| 933 | case 2: |
| 934 | nig_reg_adress_crd_weight = (port) ? |
| 935 | NIG_REG_P1_TX_ARB_CREDIT_WEIGHT_2 : |
| 936 | NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_2; |
| 937 | |
| 938 | pbf_reg_adress_crd_weight = (port) ? |
| 939 | PBF_REG_COS2_WEIGHT_P1 : PBF_REG_COS2_WEIGHT_P0; |
| 940 | break; |
| 941 | case 3: |
| 942 | if (port) |
| 943 | return -EINVAL; |
| 944 | nig_reg_adress_crd_weight = |
| 945 | NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_3; |
| 946 | pbf_reg_adress_crd_weight = |
| 947 | PBF_REG_COS3_WEIGHT_P0; |
| 948 | break; |
| 949 | case 4: |
| 950 | if (port) |
| 951 | return -EINVAL; |
| 952 | nig_reg_adress_crd_weight = |
| 953 | NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_4; |
| 954 | pbf_reg_adress_crd_weight = PBF_REG_COS4_WEIGHT_P0; |
| 955 | break; |
| 956 | case 5: |
| 957 | if (port) |
| 958 | return -EINVAL; |
| 959 | nig_reg_adress_crd_weight = |
| 960 | NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_5; |
| 961 | pbf_reg_adress_crd_weight = PBF_REG_COS5_WEIGHT_P0; |
| 962 | break; |
| 963 | } |
| 964 | |
| 965 | REG_WR(bp, nig_reg_adress_crd_weight, cos_bw_nig); |
| 966 | |
| 967 | REG_WR(bp, pbf_reg_adress_crd_weight, cos_bw_pbf); |
| 968 | |
| 969 | return 0; |
| 970 | } |
| 971 | /****************************************************************************** |
| 972 | * Description: |
| 973 | * Calculate the total BW.A value of 0 isn't legal. |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 974 | * |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 975 | ******************************************************************************/ |
| 976 | static int bnx2x_ets_e3b0_get_total_bw( |
| 977 | const struct link_params *params, |
Yaniv Rosner | 870516e1 | 2011-11-28 00:49:46 +0000 | [diff] [blame] | 978 | struct bnx2x_ets_params *ets_params, |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 979 | u16 *total_bw) |
| 980 | { |
| 981 | struct bnx2x *bp = params->bp; |
| 982 | u8 cos_idx = 0; |
Yaniv Rosner | 870516e1 | 2011-11-28 00:49:46 +0000 | [diff] [blame] | 983 | u8 is_bw_cos_exist = 0; |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 984 | |
| 985 | *total_bw = 0 ; |
| 986 | /* Calculate total BW requested */ |
| 987 | for (cos_idx = 0; cos_idx < ets_params->num_of_cos; cos_idx++) { |
Yaniv Rosner | de0396f | 2011-11-28 00:49:53 +0000 | [diff] [blame] | 988 | if (ets_params->cos[cos_idx].state == bnx2x_cos_state_bw) { |
Yaniv Rosner | 870516e1 | 2011-11-28 00:49:46 +0000 | [diff] [blame] | 989 | is_bw_cos_exist = 1; |
| 990 | if (!ets_params->cos[cos_idx].params.bw_params.bw) { |
| 991 | DP(NETIF_MSG_LINK, "bnx2x_ets_E3B0_config BW" |
| 992 | "was set to 0\n"); |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 993 | /* This is to prevent a state when ramrods |
Yaniv Rosner | 870516e1 | 2011-11-28 00:49:46 +0000 | [diff] [blame] | 994 | * can't be sent |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 995 | */ |
Yaniv Rosner | 870516e1 | 2011-11-28 00:49:46 +0000 | [diff] [blame] | 996 | ets_params->cos[cos_idx].params.bw_params.bw |
| 997 | = 1; |
| 998 | } |
David S. Miller | 8decf86 | 2011-09-22 03:23:13 -0400 | [diff] [blame] | 999 | *total_bw += |
| 1000 | ets_params->cos[cos_idx].params.bw_params.bw; |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 1001 | } |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 1002 | } |
| 1003 | |
David S. Miller | 8decf86 | 2011-09-22 03:23:13 -0400 | [diff] [blame] | 1004 | /* Check total BW is valid */ |
Yaniv Rosner | de0396f | 2011-11-28 00:49:53 +0000 | [diff] [blame] | 1005 | if ((is_bw_cos_exist == 1) && (*total_bw != 100)) { |
| 1006 | if (*total_bw == 0) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 1007 | DP(NETIF_MSG_LINK, |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 1008 | "bnx2x_ets_E3B0_config total BW shouldn't be 0\n"); |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 1009 | return -EINVAL; |
| 1010 | } |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 1011 | DP(NETIF_MSG_LINK, |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 1012 | "bnx2x_ets_E3B0_config total BW should be 100\n"); |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 1013 | /* We can handle a case whre the BW isn't 100 this can happen |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 1014 | * if the TC are joined. |
| 1015 | */ |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 1016 | } |
| 1017 | return 0; |
| 1018 | } |
| 1019 | |
| 1020 | /****************************************************************************** |
| 1021 | * Description: |
| 1022 | * Invalidate all the sp_pri_to_cos. |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 1023 | * |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 1024 | ******************************************************************************/ |
| 1025 | static void bnx2x_ets_e3b0_sp_pri_to_cos_init(u8 *sp_pri_to_cos) |
| 1026 | { |
| 1027 | u8 pri = 0; |
| 1028 | for (pri = 0; pri < DCBX_MAX_NUM_COS; pri++) |
| 1029 | sp_pri_to_cos[pri] = DCBX_INVALID_COS; |
| 1030 | } |
| 1031 | /****************************************************************************** |
| 1032 | * Description: |
| 1033 | * Calculate and set the SP (ARB_PRIORITY_CLIENT) NIG and PBF registers |
| 1034 | * according to sp_pri_to_cos. |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 1035 | * |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 1036 | ******************************************************************************/ |
| 1037 | static int bnx2x_ets_e3b0_sp_pri_to_cos_set(const struct link_params *params, |
| 1038 | u8 *sp_pri_to_cos, const u8 pri, |
| 1039 | const u8 cos_entry) |
| 1040 | { |
| 1041 | struct bnx2x *bp = params->bp; |
| 1042 | const u8 port = params->port; |
| 1043 | const u8 max_num_of_cos = (port) ? DCBX_E3B0_MAX_NUM_COS_PORT1 : |
| 1044 | DCBX_E3B0_MAX_NUM_COS_PORT0; |
| 1045 | |
Dan Carpenter | 7e5998a | 2012-04-17 20:53:42 +0000 | [diff] [blame] | 1046 | if (pri >= max_num_of_cos) { |
| 1047 | DP(NETIF_MSG_LINK, "bnx2x_ets_e3b0_sp_pri_to_cos_set invalid " |
| 1048 | "parameter Illegal strict priority\n"); |
| 1049 | return -EINVAL; |
| 1050 | } |
| 1051 | |
Yaniv Rosner | de0396f | 2011-11-28 00:49:53 +0000 | [diff] [blame] | 1052 | if (sp_pri_to_cos[pri] != DCBX_INVALID_COS) { |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 1053 | DP(NETIF_MSG_LINK, "bnx2x_ets_e3b0_sp_pri_to_cos_set invalid " |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 1054 | "parameter There can't be two COS's with " |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 1055 | "the same strict pri\n"); |
| 1056 | return -EINVAL; |
| 1057 | } |
| 1058 | |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 1059 | sp_pri_to_cos[pri] = cos_entry; |
| 1060 | return 0; |
| 1061 | |
| 1062 | } |
| 1063 | |
| 1064 | /****************************************************************************** |
| 1065 | * Description: |
| 1066 | * Returns the correct value according to COS and priority in |
| 1067 | * the sp_pri_cli register. |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 1068 | * |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 1069 | ******************************************************************************/ |
| 1070 | static u64 bnx2x_e3b0_sp_get_pri_cli_reg(const u8 cos, const u8 cos_offset, |
| 1071 | const u8 pri_set, |
| 1072 | const u8 pri_offset, |
| 1073 | const u8 entry_size) |
| 1074 | { |
| 1075 | u64 pri_cli_nig = 0; |
| 1076 | pri_cli_nig = ((u64)(cos + cos_offset)) << (entry_size * |
| 1077 | (pri_set + pri_offset)); |
| 1078 | |
| 1079 | return pri_cli_nig; |
| 1080 | } |
| 1081 | /****************************************************************************** |
| 1082 | * Description: |
| 1083 | * Returns the correct value according to COS and priority in the |
| 1084 | * sp_pri_cli register for NIG. |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 1085 | * |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 1086 | ******************************************************************************/ |
| 1087 | static u64 bnx2x_e3b0_sp_get_pri_cli_reg_nig(const u8 cos, const u8 pri_set) |
| 1088 | { |
| 1089 | /* MCP Dbg0 and dbg1 are always with higher strict pri*/ |
| 1090 | const u8 nig_cos_offset = 3; |
| 1091 | const u8 nig_pri_offset = 3; |
| 1092 | |
| 1093 | return bnx2x_e3b0_sp_get_pri_cli_reg(cos, nig_cos_offset, pri_set, |
| 1094 | nig_pri_offset, 4); |
| 1095 | |
| 1096 | } |
| 1097 | /****************************************************************************** |
| 1098 | * Description: |
| 1099 | * Returns the correct value according to COS and priority in the |
| 1100 | * sp_pri_cli register for PBF. |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 1101 | * |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 1102 | ******************************************************************************/ |
| 1103 | static u64 bnx2x_e3b0_sp_get_pri_cli_reg_pbf(const u8 cos, const u8 pri_set) |
| 1104 | { |
| 1105 | const u8 pbf_cos_offset = 0; |
| 1106 | const u8 pbf_pri_offset = 0; |
| 1107 | |
| 1108 | return bnx2x_e3b0_sp_get_pri_cli_reg(cos, pbf_cos_offset, pri_set, |
| 1109 | pbf_pri_offset, 3); |
| 1110 | |
| 1111 | } |
| 1112 | |
| 1113 | /****************************************************************************** |
| 1114 | * Description: |
| 1115 | * Calculate and set the SP (ARB_PRIORITY_CLIENT) NIG and PBF registers |
| 1116 | * according to sp_pri_to_cos.(which COS has higher priority) |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 1117 | * |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 1118 | ******************************************************************************/ |
| 1119 | static int bnx2x_ets_e3b0_sp_set_pri_cli_reg(const struct link_params *params, |
| 1120 | u8 *sp_pri_to_cos) |
| 1121 | { |
| 1122 | struct bnx2x *bp = params->bp; |
| 1123 | u8 i = 0; |
| 1124 | const u8 port = params->port; |
| 1125 | /* MCP Dbg0 and dbg1 are always with higher strict pri*/ |
| 1126 | u64 pri_cli_nig = 0x210; |
| 1127 | u32 pri_cli_pbf = 0x0; |
| 1128 | u8 pri_set = 0; |
| 1129 | u8 pri_bitmask = 0; |
| 1130 | const u8 max_num_of_cos = (port) ? DCBX_E3B0_MAX_NUM_COS_PORT1 : |
| 1131 | DCBX_E3B0_MAX_NUM_COS_PORT0; |
| 1132 | |
| 1133 | u8 cos_bit_to_set = (1 << max_num_of_cos) - 1; |
| 1134 | |
| 1135 | /* Set all the strict priority first */ |
| 1136 | for (i = 0; i < max_num_of_cos; i++) { |
Yaniv Rosner | de0396f | 2011-11-28 00:49:53 +0000 | [diff] [blame] | 1137 | if (sp_pri_to_cos[i] != DCBX_INVALID_COS) { |
| 1138 | if (sp_pri_to_cos[i] >= DCBX_MAX_NUM_COS) { |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 1139 | DP(NETIF_MSG_LINK, |
| 1140 | "bnx2x_ets_e3b0_sp_set_pri_cli_reg " |
| 1141 | "invalid cos entry\n"); |
| 1142 | return -EINVAL; |
| 1143 | } |
| 1144 | |
| 1145 | pri_cli_nig |= bnx2x_e3b0_sp_get_pri_cli_reg_nig( |
| 1146 | sp_pri_to_cos[i], pri_set); |
| 1147 | |
| 1148 | pri_cli_pbf |= bnx2x_e3b0_sp_get_pri_cli_reg_pbf( |
| 1149 | sp_pri_to_cos[i], pri_set); |
| 1150 | pri_bitmask = 1 << sp_pri_to_cos[i]; |
| 1151 | /* COS is used remove it from bitmap.*/ |
Yaniv Rosner | de0396f | 2011-11-28 00:49:53 +0000 | [diff] [blame] | 1152 | if (!(pri_bitmask & cos_bit_to_set)) { |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 1153 | DP(NETIF_MSG_LINK, |
| 1154 | "bnx2x_ets_e3b0_sp_set_pri_cli_reg " |
| 1155 | "invalid There can't be two COS's with" |
| 1156 | " the same strict pri\n"); |
| 1157 | return -EINVAL; |
| 1158 | } |
| 1159 | cos_bit_to_set &= ~pri_bitmask; |
| 1160 | pri_set++; |
| 1161 | } |
| 1162 | } |
| 1163 | |
| 1164 | /* Set all the Non strict priority i= COS*/ |
| 1165 | for (i = 0; i < max_num_of_cos; i++) { |
| 1166 | pri_bitmask = 1 << i; |
| 1167 | /* Check if COS was already used for SP */ |
| 1168 | if (pri_bitmask & cos_bit_to_set) { |
| 1169 | /* COS wasn't used for SP */ |
| 1170 | pri_cli_nig |= bnx2x_e3b0_sp_get_pri_cli_reg_nig( |
| 1171 | i, pri_set); |
| 1172 | |
| 1173 | pri_cli_pbf |= bnx2x_e3b0_sp_get_pri_cli_reg_pbf( |
| 1174 | i, pri_set); |
| 1175 | /* COS is used remove it from bitmap.*/ |
| 1176 | cos_bit_to_set &= ~pri_bitmask; |
| 1177 | pri_set++; |
| 1178 | } |
| 1179 | } |
| 1180 | |
| 1181 | if (pri_set != max_num_of_cos) { |
| 1182 | DP(NETIF_MSG_LINK, "bnx2x_ets_e3b0_sp_set_pri_cli_reg not all " |
| 1183 | "entries were set\n"); |
| 1184 | return -EINVAL; |
| 1185 | } |
| 1186 | |
| 1187 | if (port) { |
| 1188 | /* Only 6 usable clients*/ |
| 1189 | REG_WR(bp, NIG_REG_P1_TX_ARB_PRIORITY_CLIENT2_LSB, |
| 1190 | (u32)pri_cli_nig); |
| 1191 | |
| 1192 | REG_WR(bp, PBF_REG_ETS_ARB_PRIORITY_CLIENT_P1 , pri_cli_pbf); |
| 1193 | } else { |
| 1194 | /* Only 9 usable clients*/ |
| 1195 | const u32 pri_cli_nig_lsb = (u32) (pri_cli_nig); |
| 1196 | const u32 pri_cli_nig_msb = (u32) ((pri_cli_nig >> 32) & 0xF); |
| 1197 | |
| 1198 | REG_WR(bp, NIG_REG_P0_TX_ARB_PRIORITY_CLIENT2_LSB, |
| 1199 | pri_cli_nig_lsb); |
| 1200 | REG_WR(bp, NIG_REG_P0_TX_ARB_PRIORITY_CLIENT2_MSB, |
| 1201 | pri_cli_nig_msb); |
| 1202 | |
| 1203 | REG_WR(bp, PBF_REG_ETS_ARB_PRIORITY_CLIENT_P0 , pri_cli_pbf); |
| 1204 | } |
| 1205 | return 0; |
| 1206 | } |
| 1207 | |
| 1208 | /****************************************************************************** |
| 1209 | * Description: |
| 1210 | * Configure the COS to ETS according to BW and SP settings. |
| 1211 | ******************************************************************************/ |
| 1212 | int bnx2x_ets_e3b0_config(const struct link_params *params, |
| 1213 | const struct link_vars *vars, |
Yaniv Rosner | 870516e1 | 2011-11-28 00:49:46 +0000 | [diff] [blame] | 1214 | struct bnx2x_ets_params *ets_params) |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 1215 | { |
| 1216 | struct bnx2x *bp = params->bp; |
| 1217 | int bnx2x_status = 0; |
| 1218 | const u8 port = params->port; |
| 1219 | u16 total_bw = 0; |
| 1220 | const u32 min_w_val_nig = bnx2x_ets_get_min_w_val_nig(vars); |
| 1221 | const u32 min_w_val_pbf = ETS_E3B0_PBF_MIN_W_VAL; |
| 1222 | u8 cos_bw_bitmap = 0; |
| 1223 | u8 cos_sp_bitmap = 0; |
| 1224 | u8 sp_pri_to_cos[DCBX_MAX_NUM_COS] = {0}; |
| 1225 | const u8 max_num_of_cos = (port) ? DCBX_E3B0_MAX_NUM_COS_PORT1 : |
| 1226 | DCBX_E3B0_MAX_NUM_COS_PORT0; |
| 1227 | u8 cos_entry = 0; |
| 1228 | |
| 1229 | if (!CHIP_IS_E3B0(bp)) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 1230 | DP(NETIF_MSG_LINK, |
| 1231 | "bnx2x_ets_e3b0_disabled the chip isn't E3B0\n"); |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 1232 | return -EINVAL; |
| 1233 | } |
| 1234 | |
| 1235 | if ((ets_params->num_of_cos > max_num_of_cos)) { |
| 1236 | DP(NETIF_MSG_LINK, "bnx2x_ets_E3B0_config the number of COS " |
| 1237 | "isn't supported\n"); |
| 1238 | return -EINVAL; |
| 1239 | } |
| 1240 | |
| 1241 | /* Prepare sp strict priority parameters*/ |
| 1242 | bnx2x_ets_e3b0_sp_pri_to_cos_init(sp_pri_to_cos); |
| 1243 | |
| 1244 | /* Prepare BW parameters*/ |
| 1245 | bnx2x_status = bnx2x_ets_e3b0_get_total_bw(params, ets_params, |
| 1246 | &total_bw); |
Yaniv Rosner | de0396f | 2011-11-28 00:49:53 +0000 | [diff] [blame] | 1247 | if (bnx2x_status) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 1248 | DP(NETIF_MSG_LINK, |
| 1249 | "bnx2x_ets_E3B0_config get_total_bw failed\n"); |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 1250 | return -EINVAL; |
| 1251 | } |
| 1252 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 1253 | /* Upper bound is set according to current link speed (min_w_val |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 1254 | * should be the same for upper bound and COS credit val). |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 1255 | */ |
| 1256 | bnx2x_ets_e3b0_set_credit_upper_bound_nig(params, min_w_val_nig); |
| 1257 | bnx2x_ets_e3b0_set_credit_upper_bound_pbf(params, min_w_val_pbf); |
| 1258 | |
| 1259 | |
| 1260 | for (cos_entry = 0; cos_entry < ets_params->num_of_cos; cos_entry++) { |
| 1261 | if (bnx2x_cos_state_bw == ets_params->cos[cos_entry].state) { |
| 1262 | cos_bw_bitmap |= (1 << cos_entry); |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 1263 | /* The function also sets the BW in HW(not the mappin |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 1264 | * yet) |
| 1265 | */ |
| 1266 | bnx2x_status = bnx2x_ets_e3b0_set_cos_bw( |
| 1267 | bp, cos_entry, min_w_val_nig, min_w_val_pbf, |
| 1268 | total_bw, |
| 1269 | ets_params->cos[cos_entry].params.bw_params.bw, |
| 1270 | port); |
| 1271 | } else if (bnx2x_cos_state_strict == |
| 1272 | ets_params->cos[cos_entry].state){ |
| 1273 | cos_sp_bitmap |= (1 << cos_entry); |
| 1274 | |
| 1275 | bnx2x_status = bnx2x_ets_e3b0_sp_pri_to_cos_set( |
| 1276 | params, |
| 1277 | sp_pri_to_cos, |
| 1278 | ets_params->cos[cos_entry].params.sp_params.pri, |
| 1279 | cos_entry); |
| 1280 | |
| 1281 | } else { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 1282 | DP(NETIF_MSG_LINK, |
| 1283 | "bnx2x_ets_e3b0_config cos state not valid\n"); |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 1284 | return -EINVAL; |
| 1285 | } |
Yaniv Rosner | de0396f | 2011-11-28 00:49:53 +0000 | [diff] [blame] | 1286 | if (bnx2x_status) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 1287 | DP(NETIF_MSG_LINK, |
| 1288 | "bnx2x_ets_e3b0_config set cos bw failed\n"); |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 1289 | return bnx2x_status; |
| 1290 | } |
| 1291 | } |
| 1292 | |
| 1293 | /* Set SP register (which COS has higher priority) */ |
| 1294 | bnx2x_status = bnx2x_ets_e3b0_sp_set_pri_cli_reg(params, |
| 1295 | sp_pri_to_cos); |
| 1296 | |
Yaniv Rosner | de0396f | 2011-11-28 00:49:53 +0000 | [diff] [blame] | 1297 | if (bnx2x_status) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 1298 | DP(NETIF_MSG_LINK, |
| 1299 | "bnx2x_ets_E3B0_config set_pri_cli_reg failed\n"); |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 1300 | return bnx2x_status; |
| 1301 | } |
| 1302 | |
| 1303 | /* Set client mapping of BW and strict */ |
| 1304 | bnx2x_status = bnx2x_ets_e3b0_cli_map(params, ets_params, |
| 1305 | cos_sp_bitmap, |
| 1306 | cos_bw_bitmap); |
| 1307 | |
Yaniv Rosner | de0396f | 2011-11-28 00:49:53 +0000 | [diff] [blame] | 1308 | if (bnx2x_status) { |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 1309 | DP(NETIF_MSG_LINK, "bnx2x_ets_E3B0_config SP failed\n"); |
| 1310 | return bnx2x_status; |
| 1311 | } |
| 1312 | return 0; |
| 1313 | } |
Yaniv Rosner | 65a001b | 2011-01-31 04:22:03 +0000 | [diff] [blame] | 1314 | static void bnx2x_ets_bw_limit_common(const struct link_params *params) |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1315 | { |
| 1316 | /* ETS disabled configuration */ |
| 1317 | struct bnx2x *bp = params->bp; |
| 1318 | DP(NETIF_MSG_LINK, "ETS enabled BW limit configuration\n"); |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 1319 | /* Defines which entries (clients) are subjected to WFQ arbitration |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 1320 | * COS0 0x8 |
| 1321 | * COS1 0x10 |
| 1322 | */ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1323 | REG_WR(bp, NIG_REG_P0_TX_ARB_CLIENT_IS_SUBJECT2WFQ, 0x18); |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 1324 | /* Mapping between the ARB_CREDIT_WEIGHT registers and actual |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 1325 | * client numbers (WEIGHT_0 does not actually have to represent |
| 1326 | * client 0) |
| 1327 | * PRI4 | PRI3 | PRI2 | PRI1 | PRI0 |
| 1328 | * cos1-001 cos0-000 dbg1-100 dbg0-011 MCP-010 |
| 1329 | */ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1330 | REG_WR(bp, NIG_REG_P0_TX_ARB_CLIENT_CREDIT_MAP, 0x111A); |
| 1331 | |
| 1332 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_0, |
| 1333 | ETS_BW_LIMIT_CREDIT_UPPER_BOUND); |
| 1334 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_1, |
| 1335 | ETS_BW_LIMIT_CREDIT_UPPER_BOUND); |
| 1336 | |
| 1337 | /* ETS mode enabled*/ |
| 1338 | REG_WR(bp, PBF_REG_ETS_ENABLED, 1); |
| 1339 | |
| 1340 | /* Defines the number of consecutive slots for the strict priority */ |
| 1341 | REG_WR(bp, PBF_REG_NUM_STRICT_ARB_SLOTS, 0); |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 1342 | /* Bitmap of 5bits length. Each bit specifies whether the entry behaves |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 1343 | * as strict. Bits 0,1,2 - debug and management entries, 3 - COS0 |
| 1344 | * entry, 4 - COS1 entry. |
| 1345 | * COS1 | COS0 | DEBUG21 | DEBUG0 | MGMT |
| 1346 | * bit4 bit3 bit2 bit1 bit0 |
| 1347 | * MCP and debug are strict |
| 1348 | */ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1349 | REG_WR(bp, NIG_REG_P0_TX_ARB_CLIENT_IS_STRICT, 0x7); |
| 1350 | |
| 1351 | /* Upper bound that COS0_WEIGHT can reach in the WFQ arbiter.*/ |
| 1352 | REG_WR(bp, PBF_REG_COS0_UPPER_BOUND, |
| 1353 | ETS_BW_LIMIT_CREDIT_UPPER_BOUND); |
| 1354 | REG_WR(bp, PBF_REG_COS1_UPPER_BOUND, |
| 1355 | ETS_BW_LIMIT_CREDIT_UPPER_BOUND); |
| 1356 | } |
| 1357 | |
| 1358 | void bnx2x_ets_bw_limit(const struct link_params *params, const u32 cos0_bw, |
| 1359 | const u32 cos1_bw) |
| 1360 | { |
| 1361 | /* ETS disabled configuration*/ |
| 1362 | struct bnx2x *bp = params->bp; |
| 1363 | const u32 total_bw = cos0_bw + cos1_bw; |
| 1364 | u32 cos0_credit_weight = 0; |
| 1365 | u32 cos1_credit_weight = 0; |
| 1366 | |
| 1367 | DP(NETIF_MSG_LINK, "ETS enabled BW limit configuration\n"); |
| 1368 | |
Yaniv Rosner | de0396f | 2011-11-28 00:49:53 +0000 | [diff] [blame] | 1369 | if ((!total_bw) || |
| 1370 | (!cos0_bw) || |
| 1371 | (!cos1_bw)) { |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1372 | DP(NETIF_MSG_LINK, "Total BW can't be zero\n"); |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1373 | return; |
| 1374 | } |
| 1375 | |
| 1376 | cos0_credit_weight = (cos0_bw * ETS_BW_LIMIT_CREDIT_WEIGHT)/ |
| 1377 | total_bw; |
| 1378 | cos1_credit_weight = (cos1_bw * ETS_BW_LIMIT_CREDIT_WEIGHT)/ |
| 1379 | total_bw; |
| 1380 | |
| 1381 | bnx2x_ets_bw_limit_common(params); |
| 1382 | |
| 1383 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_0, cos0_credit_weight); |
| 1384 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_1, cos1_credit_weight); |
| 1385 | |
| 1386 | REG_WR(bp, PBF_REG_COS0_WEIGHT, cos0_credit_weight); |
| 1387 | REG_WR(bp, PBF_REG_COS1_WEIGHT, cos1_credit_weight); |
| 1388 | } |
| 1389 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 1390 | int bnx2x_ets_strict(const struct link_params *params, const u8 strict_cos) |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1391 | { |
| 1392 | /* ETS disabled configuration*/ |
| 1393 | struct bnx2x *bp = params->bp; |
| 1394 | u32 val = 0; |
| 1395 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1396 | DP(NETIF_MSG_LINK, "ETS enabled strict configuration\n"); |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 1397 | /* Bitmap of 5bits length. Each bit specifies whether the entry behaves |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1398 | * as strict. Bits 0,1,2 - debug and management entries, |
| 1399 | * 3 - COS0 entry, 4 - COS1 entry. |
| 1400 | * COS1 | COS0 | DEBUG21 | DEBUG0 | MGMT |
| 1401 | * bit4 bit3 bit2 bit1 bit0 |
| 1402 | * MCP and debug are strict |
| 1403 | */ |
| 1404 | REG_WR(bp, NIG_REG_P0_TX_ARB_CLIENT_IS_STRICT, 0x1F); |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 1405 | /* For strict priority entries defines the number of consecutive slots |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1406 | * for the highest priority. |
| 1407 | */ |
| 1408 | REG_WR(bp, NIG_REG_P0_TX_ARB_NUM_STRICT_ARB_SLOTS, 0x100); |
| 1409 | /* ETS mode disable */ |
| 1410 | REG_WR(bp, PBF_REG_ETS_ENABLED, 0); |
| 1411 | /* Defines the number of consecutive slots for the strict priority */ |
| 1412 | REG_WR(bp, PBF_REG_NUM_STRICT_ARB_SLOTS, 0x100); |
| 1413 | |
| 1414 | /* Defines the number of consecutive slots for the strict priority */ |
| 1415 | REG_WR(bp, PBF_REG_HIGH_PRIORITY_COS_NUM, strict_cos); |
| 1416 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 1417 | /* Mapping between entry priority to client number (0,1,2 -debug and |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 1418 | * management clients, 3 - COS0 client, 4 - COS client)(HIGHEST) |
| 1419 | * 3bits client num. |
| 1420 | * PRI4 | PRI3 | PRI2 | PRI1 | PRI0 |
| 1421 | * dbg0-010 dbg1-001 cos1-100 cos0-011 MCP-000 |
| 1422 | * dbg0-010 dbg1-001 cos0-011 cos1-100 MCP-000 |
| 1423 | */ |
Yaniv Rosner | de0396f | 2011-11-28 00:49:53 +0000 | [diff] [blame] | 1424 | val = (!strict_cos) ? 0x2318 : 0x22E0; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1425 | REG_WR(bp, NIG_REG_P0_TX_ARB_PRIORITY_CLIENT, val); |
| 1426 | |
| 1427 | return 0; |
| 1428 | } |
Yuval Mintz | c8c60d8 | 2012-06-06 17:13:07 +0000 | [diff] [blame] | 1429 | |
| 1430 | /******************************************************************/ |
Dmitry Kravkov | e892067 | 2011-05-04 23:52:40 +0000 | [diff] [blame] | 1431 | /* PFC section */ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1432 | /******************************************************************/ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1433 | static void bnx2x_update_pfc_xmac(struct link_params *params, |
| 1434 | struct link_vars *vars, |
| 1435 | u8 is_lb) |
| 1436 | { |
| 1437 | struct bnx2x *bp = params->bp; |
| 1438 | u32 xmac_base; |
| 1439 | u32 pause_val, pfc0_val, pfc1_val; |
| 1440 | |
| 1441 | /* XMAC base adrr */ |
| 1442 | xmac_base = (params->port) ? GRCBASE_XMAC1 : GRCBASE_XMAC0; |
| 1443 | |
| 1444 | /* Initialize pause and pfc registers */ |
| 1445 | pause_val = 0x18000; |
| 1446 | pfc0_val = 0xFFFF8000; |
| 1447 | pfc1_val = 0x2; |
| 1448 | |
| 1449 | /* No PFC support */ |
| 1450 | if (!(params->feature_config_flags & |
| 1451 | FEATURE_CONFIG_PFC_ENABLED)) { |
| 1452 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 1453 | /* RX flow control - Process pause frame in receive direction |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1454 | */ |
| 1455 | if (vars->flow_ctrl & BNX2X_FLOW_CTRL_RX) |
| 1456 | pause_val |= XMAC_PAUSE_CTRL_REG_RX_PAUSE_EN; |
| 1457 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 1458 | /* TX flow control - Send pause packet when buffer is full */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1459 | if (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX) |
| 1460 | pause_val |= XMAC_PAUSE_CTRL_REG_TX_PAUSE_EN; |
| 1461 | } else {/* PFC support */ |
| 1462 | pfc1_val |= XMAC_PFC_CTRL_HI_REG_PFC_REFRESH_EN | |
| 1463 | XMAC_PFC_CTRL_HI_REG_PFC_STATS_EN | |
| 1464 | XMAC_PFC_CTRL_HI_REG_RX_PFC_EN | |
Yaniv Rosner | 27d9129 | 2012-04-04 01:28:54 +0000 | [diff] [blame] | 1465 | XMAC_PFC_CTRL_HI_REG_TX_PFC_EN | |
| 1466 | XMAC_PFC_CTRL_HI_REG_FORCE_PFC_XON; |
| 1467 | /* Write pause and PFC registers */ |
| 1468 | REG_WR(bp, xmac_base + XMAC_REG_PAUSE_CTRL, pause_val); |
| 1469 | REG_WR(bp, xmac_base + XMAC_REG_PFC_CTRL, pfc0_val); |
| 1470 | REG_WR(bp, xmac_base + XMAC_REG_PFC_CTRL_HI, pfc1_val); |
| 1471 | pfc1_val &= ~XMAC_PFC_CTRL_HI_REG_FORCE_PFC_XON; |
| 1472 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1473 | } |
| 1474 | |
| 1475 | /* Write pause and PFC registers */ |
| 1476 | REG_WR(bp, xmac_base + XMAC_REG_PAUSE_CTRL, pause_val); |
| 1477 | REG_WR(bp, xmac_base + XMAC_REG_PFC_CTRL, pfc0_val); |
| 1478 | REG_WR(bp, xmac_base + XMAC_REG_PFC_CTRL_HI, pfc1_val); |
| 1479 | |
Yaniv Rosner | b8d6d08 | 2011-07-05 01:06:27 +0000 | [diff] [blame] | 1480 | |
| 1481 | /* Set MAC address for source TX Pause/PFC frames */ |
| 1482 | REG_WR(bp, xmac_base + XMAC_REG_CTRL_SA_LO, |
| 1483 | ((params->mac_addr[2] << 24) | |
| 1484 | (params->mac_addr[3] << 16) | |
| 1485 | (params->mac_addr[4] << 8) | |
| 1486 | (params->mac_addr[5]))); |
| 1487 | REG_WR(bp, xmac_base + XMAC_REG_CTRL_SA_HI, |
| 1488 | ((params->mac_addr[0] << 8) | |
| 1489 | (params->mac_addr[1]))); |
| 1490 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1491 | udelay(30); |
| 1492 | } |
| 1493 | |
| 1494 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1495 | static void bnx2x_emac_get_pfc_stat(struct link_params *params, |
| 1496 | u32 pfc_frames_sent[2], |
| 1497 | u32 pfc_frames_received[2]) |
| 1498 | { |
| 1499 | /* Read pfc statistic */ |
| 1500 | struct bnx2x *bp = params->bp; |
| 1501 | u32 emac_base = params->port ? GRCBASE_EMAC1 : GRCBASE_EMAC0; |
| 1502 | u32 val_xon = 0; |
| 1503 | u32 val_xoff = 0; |
| 1504 | |
| 1505 | DP(NETIF_MSG_LINK, "pfc statistic read from EMAC\n"); |
| 1506 | |
| 1507 | /* PFC received frames */ |
| 1508 | val_xoff = REG_RD(bp, emac_base + |
| 1509 | EMAC_REG_RX_PFC_STATS_XOFF_RCVD); |
| 1510 | val_xoff &= EMAC_REG_RX_PFC_STATS_XOFF_RCVD_COUNT; |
| 1511 | val_xon = REG_RD(bp, emac_base + EMAC_REG_RX_PFC_STATS_XON_RCVD); |
| 1512 | val_xon &= EMAC_REG_RX_PFC_STATS_XON_RCVD_COUNT; |
| 1513 | |
| 1514 | pfc_frames_received[0] = val_xon + val_xoff; |
| 1515 | |
| 1516 | /* PFC received sent */ |
| 1517 | val_xoff = REG_RD(bp, emac_base + |
| 1518 | EMAC_REG_RX_PFC_STATS_XOFF_SENT); |
| 1519 | val_xoff &= EMAC_REG_RX_PFC_STATS_XOFF_SENT_COUNT; |
| 1520 | val_xon = REG_RD(bp, emac_base + EMAC_REG_RX_PFC_STATS_XON_SENT); |
| 1521 | val_xon &= EMAC_REG_RX_PFC_STATS_XON_SENT_COUNT; |
| 1522 | |
| 1523 | pfc_frames_sent[0] = val_xon + val_xoff; |
| 1524 | } |
| 1525 | |
Yaniv Rosner | b8d6d08 | 2011-07-05 01:06:27 +0000 | [diff] [blame] | 1526 | /* Read pfc statistic*/ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1527 | void bnx2x_pfc_statistic(struct link_params *params, struct link_vars *vars, |
| 1528 | u32 pfc_frames_sent[2], |
| 1529 | u32 pfc_frames_received[2]) |
| 1530 | { |
| 1531 | /* Read pfc statistic */ |
| 1532 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | b8d6d08 | 2011-07-05 01:06:27 +0000 | [diff] [blame] | 1533 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1534 | DP(NETIF_MSG_LINK, "pfc statistic\n"); |
| 1535 | |
| 1536 | if (!vars->link_up) |
| 1537 | return; |
| 1538 | |
Yaniv Rosner | de0396f | 2011-11-28 00:49:53 +0000 | [diff] [blame] | 1539 | if (vars->mac_type == MAC_TYPE_EMAC) { |
Yaniv Rosner | b8d6d08 | 2011-07-05 01:06:27 +0000 | [diff] [blame] | 1540 | DP(NETIF_MSG_LINK, "About to read PFC stats from EMAC\n"); |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1541 | bnx2x_emac_get_pfc_stat(params, pfc_frames_sent, |
| 1542 | pfc_frames_received); |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1543 | } |
| 1544 | } |
| 1545 | /******************************************************************/ |
| 1546 | /* MAC/PBF section */ |
| 1547 | /******************************************************************/ |
Yaniv Rosner | a198c14 | 2011-05-31 21:29:42 +0000 | [diff] [blame] | 1548 | static void bnx2x_set_mdio_clk(struct bnx2x *bp, u32 chip_id, u8 port) |
| 1549 | { |
| 1550 | u32 mode, emac_base; |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 1551 | /* Set clause 45 mode, slow down the MDIO clock to 2.5MHz |
Yaniv Rosner | a198c14 | 2011-05-31 21:29:42 +0000 | [diff] [blame] | 1552 | * (a value of 49==0x31) and make sure that the AUTO poll is off |
| 1553 | */ |
| 1554 | |
| 1555 | if (CHIP_IS_E2(bp)) |
| 1556 | emac_base = GRCBASE_EMAC0; |
| 1557 | else |
| 1558 | emac_base = (port) ? GRCBASE_EMAC1 : GRCBASE_EMAC0; |
| 1559 | mode = REG_RD(bp, emac_base + EMAC_REG_EMAC_MDIO_MODE); |
| 1560 | mode &= ~(EMAC_MDIO_MODE_AUTO_POLL | |
| 1561 | EMAC_MDIO_MODE_CLOCK_CNT); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 1562 | if (USES_WARPCORE(bp)) |
| 1563 | mode |= (74L << EMAC_MDIO_MODE_CLOCK_CNT_BITSHIFT); |
| 1564 | else |
| 1565 | mode |= (49L << EMAC_MDIO_MODE_CLOCK_CNT_BITSHIFT); |
Yaniv Rosner | a198c14 | 2011-05-31 21:29:42 +0000 | [diff] [blame] | 1566 | |
| 1567 | mode |= (EMAC_MDIO_MODE_CLAUSE_45); |
| 1568 | REG_WR(bp, emac_base + EMAC_REG_EMAC_MDIO_MODE, mode); |
| 1569 | |
| 1570 | udelay(40); |
| 1571 | } |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 1572 | static u8 bnx2x_is_4_port_mode(struct bnx2x *bp) |
| 1573 | { |
| 1574 | u32 port4mode_ovwr_val; |
| 1575 | /* Check 4-port override enabled */ |
| 1576 | port4mode_ovwr_val = REG_RD(bp, MISC_REG_PORT4MODE_EN_OVWR); |
| 1577 | if (port4mode_ovwr_val & (1<<0)) { |
| 1578 | /* Return 4-port mode override value */ |
| 1579 | return ((port4mode_ovwr_val & (1<<1)) == (1<<1)); |
| 1580 | } |
| 1581 | /* Return 4-port mode from input pin */ |
| 1582 | return (u8)REG_RD(bp, MISC_REG_PORT4MODE_EN); |
| 1583 | } |
Yaniv Rosner | a198c14 | 2011-05-31 21:29:42 +0000 | [diff] [blame] | 1584 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1585 | static void bnx2x_emac_init(struct link_params *params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1586 | struct link_vars *vars) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1587 | { |
| 1588 | /* reset and unreset the emac core */ |
| 1589 | struct bnx2x *bp = params->bp; |
| 1590 | u8 port = params->port; |
| 1591 | u32 emac_base = port ? GRCBASE_EMAC1 : GRCBASE_EMAC0; |
| 1592 | u32 val; |
| 1593 | u16 timeout; |
| 1594 | |
| 1595 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_CLEAR, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1596 | (MISC_REGISTERS_RESET_REG_2_RST_EMAC0_HARD_CORE << port)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1597 | udelay(5); |
| 1598 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_SET, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1599 | (MISC_REGISTERS_RESET_REG_2_RST_EMAC0_HARD_CORE << port)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1600 | |
| 1601 | /* init emac - use read-modify-write */ |
| 1602 | /* self clear reset */ |
| 1603 | val = REG_RD(bp, emac_base + EMAC_REG_EMAC_MODE); |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 1604 | EMAC_WR(bp, EMAC_REG_EMAC_MODE, (val | EMAC_MODE_RESET)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1605 | |
| 1606 | timeout = 200; |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 1607 | do { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1608 | val = REG_RD(bp, emac_base + EMAC_REG_EMAC_MODE); |
| 1609 | DP(NETIF_MSG_LINK, "EMAC reset reg is %u\n", val); |
| 1610 | if (!timeout) { |
| 1611 | DP(NETIF_MSG_LINK, "EMAC timeout!\n"); |
| 1612 | return; |
| 1613 | } |
| 1614 | timeout--; |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 1615 | } while (val & EMAC_MODE_RESET); |
Yaniv Rosner | a198c14 | 2011-05-31 21:29:42 +0000 | [diff] [blame] | 1616 | bnx2x_set_mdio_clk(bp, params->chip_id, port); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1617 | /* Set mac address */ |
| 1618 | val = ((params->mac_addr[0] << 8) | |
| 1619 | params->mac_addr[1]); |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 1620 | EMAC_WR(bp, EMAC_REG_EMAC_MAC_MATCH, val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1621 | |
| 1622 | val = ((params->mac_addr[2] << 24) | |
| 1623 | (params->mac_addr[3] << 16) | |
| 1624 | (params->mac_addr[4] << 8) | |
| 1625 | params->mac_addr[5]); |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 1626 | EMAC_WR(bp, EMAC_REG_EMAC_MAC_MATCH + 4, val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1627 | } |
| 1628 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1629 | static void bnx2x_set_xumac_nig(struct link_params *params, |
| 1630 | u16 tx_pause_en, |
| 1631 | u8 enable) |
| 1632 | { |
| 1633 | struct bnx2x *bp = params->bp; |
| 1634 | |
| 1635 | REG_WR(bp, params->port ? NIG_REG_P1_MAC_IN_EN : NIG_REG_P0_MAC_IN_EN, |
| 1636 | enable); |
| 1637 | REG_WR(bp, params->port ? NIG_REG_P1_MAC_OUT_EN : NIG_REG_P0_MAC_OUT_EN, |
| 1638 | enable); |
| 1639 | REG_WR(bp, params->port ? NIG_REG_P1_MAC_PAUSE_OUT_EN : |
| 1640 | NIG_REG_P0_MAC_PAUSE_OUT_EN, tx_pause_en); |
| 1641 | } |
| 1642 | |
Yaniv Rosner | d3a8f13 | 2012-09-13 02:56:20 +0000 | [diff] [blame] | 1643 | static void bnx2x_set_umac_rxtx(struct link_params *params, u8 en) |
Yaniv Rosner | ce7c048 | 2011-10-27 05:09:47 +0000 | [diff] [blame] | 1644 | { |
| 1645 | u32 umac_base = params->port ? GRCBASE_UMAC1 : GRCBASE_UMAC0; |
Yaniv Rosner | d3a8f13 | 2012-09-13 02:56:20 +0000 | [diff] [blame] | 1646 | u32 val; |
Yaniv Rosner | ce7c048 | 2011-10-27 05:09:47 +0000 | [diff] [blame] | 1647 | struct bnx2x *bp = params->bp; |
| 1648 | if (!(REG_RD(bp, MISC_REG_RESET_REG_2) & |
| 1649 | (MISC_REGISTERS_RESET_REG_2_UMAC0 << params->port))) |
| 1650 | return; |
Yaniv Rosner | d3a8f13 | 2012-09-13 02:56:20 +0000 | [diff] [blame] | 1651 | val = REG_RD(bp, umac_base + UMAC_REG_COMMAND_CONFIG); |
| 1652 | if (en) |
| 1653 | val |= (UMAC_COMMAND_CONFIG_REG_TX_ENA | |
| 1654 | UMAC_COMMAND_CONFIG_REG_RX_ENA); |
| 1655 | else |
| 1656 | val &= ~(UMAC_COMMAND_CONFIG_REG_TX_ENA | |
| 1657 | UMAC_COMMAND_CONFIG_REG_RX_ENA); |
Yaniv Rosner | ce7c048 | 2011-10-27 05:09:47 +0000 | [diff] [blame] | 1658 | /* Disable RX and TX */ |
Yaniv Rosner | d3a8f13 | 2012-09-13 02:56:20 +0000 | [diff] [blame] | 1659 | REG_WR(bp, umac_base + UMAC_REG_COMMAND_CONFIG, val); |
Yaniv Rosner | ce7c048 | 2011-10-27 05:09:47 +0000 | [diff] [blame] | 1660 | } |
| 1661 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1662 | static void bnx2x_umac_enable(struct link_params *params, |
| 1663 | struct link_vars *vars, u8 lb) |
| 1664 | { |
| 1665 | u32 val; |
| 1666 | u32 umac_base = params->port ? GRCBASE_UMAC1 : GRCBASE_UMAC0; |
| 1667 | struct bnx2x *bp = params->bp; |
| 1668 | /* Reset UMAC */ |
| 1669 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_CLEAR, |
| 1670 | (MISC_REGISTERS_RESET_REG_2_UMAC0 << params->port)); |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 1671 | usleep_range(1000, 2000); |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1672 | |
| 1673 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_SET, |
| 1674 | (MISC_REGISTERS_RESET_REG_2_UMAC0 << params->port)); |
| 1675 | |
| 1676 | DP(NETIF_MSG_LINK, "enabling UMAC\n"); |
| 1677 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1678 | /* This register opens the gate for the UMAC despite its name */ |
| 1679 | REG_WR(bp, NIG_REG_EGRESS_EMAC0_PORT + params->port*4, 1); |
| 1680 | |
| 1681 | val = UMAC_COMMAND_CONFIG_REG_PROMIS_EN | |
| 1682 | UMAC_COMMAND_CONFIG_REG_PAD_EN | |
| 1683 | UMAC_COMMAND_CONFIG_REG_SW_RESET | |
| 1684 | UMAC_COMMAND_CONFIG_REG_NO_LGTH_CHECK; |
| 1685 | switch (vars->line_speed) { |
| 1686 | case SPEED_10: |
| 1687 | val |= (0<<2); |
| 1688 | break; |
| 1689 | case SPEED_100: |
| 1690 | val |= (1<<2); |
| 1691 | break; |
| 1692 | case SPEED_1000: |
| 1693 | val |= (2<<2); |
| 1694 | break; |
| 1695 | case SPEED_2500: |
| 1696 | val |= (3<<2); |
| 1697 | break; |
| 1698 | default: |
| 1699 | DP(NETIF_MSG_LINK, "Invalid speed for UMAC %d\n", |
| 1700 | vars->line_speed); |
| 1701 | break; |
| 1702 | } |
Yaniv Rosner | 9d5b36b | 2011-08-02 22:59:10 +0000 | [diff] [blame] | 1703 | if (!(vars->flow_ctrl & BNX2X_FLOW_CTRL_TX)) |
| 1704 | val |= UMAC_COMMAND_CONFIG_REG_IGNORE_TX_PAUSE; |
| 1705 | |
| 1706 | if (!(vars->flow_ctrl & BNX2X_FLOW_CTRL_RX)) |
| 1707 | val |= UMAC_COMMAND_CONFIG_REG_PAUSE_IGNORE; |
| 1708 | |
Mintz Yuval | e18c56b | 2012-02-15 02:10:23 +0000 | [diff] [blame] | 1709 | if (vars->duplex == DUPLEX_HALF) |
| 1710 | val |= UMAC_COMMAND_CONFIG_REG_HD_ENA; |
| 1711 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1712 | REG_WR(bp, umac_base + UMAC_REG_COMMAND_CONFIG, val); |
| 1713 | udelay(50); |
| 1714 | |
Yuval Mintz | 26964bb | 2012-09-10 05:51:08 +0000 | [diff] [blame] | 1715 | /* Configure UMAC for EEE */ |
| 1716 | if (vars->eee_status & SHMEM_EEE_ADV_STATUS_MASK) { |
| 1717 | DP(NETIF_MSG_LINK, "configured UMAC for EEE\n"); |
| 1718 | REG_WR(bp, umac_base + UMAC_REG_UMAC_EEE_CTRL, |
| 1719 | UMAC_UMAC_EEE_CTRL_REG_EEE_EN); |
| 1720 | REG_WR(bp, umac_base + UMAC_REG_EEE_WAKE_TIMER, 0x11); |
| 1721 | } else { |
| 1722 | REG_WR(bp, umac_base + UMAC_REG_UMAC_EEE_CTRL, 0x0); |
| 1723 | } |
| 1724 | |
Yaniv Rosner | b8d6d08 | 2011-07-05 01:06:27 +0000 | [diff] [blame] | 1725 | /* Set MAC address for source TX Pause/PFC frames (under SW reset) */ |
| 1726 | REG_WR(bp, umac_base + UMAC_REG_MAC_ADDR0, |
| 1727 | ((params->mac_addr[2] << 24) | |
| 1728 | (params->mac_addr[3] << 16) | |
| 1729 | (params->mac_addr[4] << 8) | |
| 1730 | (params->mac_addr[5]))); |
| 1731 | REG_WR(bp, umac_base + UMAC_REG_MAC_ADDR1, |
| 1732 | ((params->mac_addr[0] << 8) | |
| 1733 | (params->mac_addr[1]))); |
| 1734 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1735 | /* Enable RX and TX */ |
| 1736 | val &= ~UMAC_COMMAND_CONFIG_REG_PAD_EN; |
| 1737 | val |= UMAC_COMMAND_CONFIG_REG_TX_ENA | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 1738 | UMAC_COMMAND_CONFIG_REG_RX_ENA; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1739 | REG_WR(bp, umac_base + UMAC_REG_COMMAND_CONFIG, val); |
| 1740 | udelay(50); |
| 1741 | |
| 1742 | /* Remove SW Reset */ |
| 1743 | val &= ~UMAC_COMMAND_CONFIG_REG_SW_RESET; |
| 1744 | |
| 1745 | /* Check loopback mode */ |
| 1746 | if (lb) |
| 1747 | val |= UMAC_COMMAND_CONFIG_REG_LOOP_ENA; |
| 1748 | REG_WR(bp, umac_base + UMAC_REG_COMMAND_CONFIG, val); |
| 1749 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 1750 | /* Maximum Frame Length (RW). Defines a 14-Bit maximum frame |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1751 | * length used by the MAC receive logic to check frames. |
| 1752 | */ |
| 1753 | REG_WR(bp, umac_base + UMAC_REG_MAXFR, 0x2710); |
| 1754 | bnx2x_set_xumac_nig(params, |
| 1755 | ((vars->flow_ctrl & BNX2X_FLOW_CTRL_TX) != 0), 1); |
| 1756 | vars->mac_type = MAC_TYPE_UMAC; |
| 1757 | |
| 1758 | } |
| 1759 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1760 | /* Define the XMAC mode */ |
Yaniv Rosner | ce7c048 | 2011-10-27 05:09:47 +0000 | [diff] [blame] | 1761 | static void bnx2x_xmac_init(struct link_params *params, u32 max_speed) |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1762 | { |
Yaniv Rosner | ce7c048 | 2011-10-27 05:09:47 +0000 | [diff] [blame] | 1763 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1764 | u32 is_port4mode = bnx2x_is_4_port_mode(bp); |
| 1765 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 1766 | /* In 4-port mode, need to set the mode only once, so if XMAC is |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 1767 | * already out of reset, it means the mode has already been set, |
| 1768 | * and it must not* reset the XMAC again, since it controls both |
| 1769 | * ports of the path |
| 1770 | */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1771 | |
Yuval Mintz | c3def94 | 2012-07-23 10:25:43 +0300 | [diff] [blame] | 1772 | if ((CHIP_NUM(bp) == CHIP_NUM_57840_4_10) && |
Yaniv Rosner | ce7c048 | 2011-10-27 05:09:47 +0000 | [diff] [blame] | 1773 | (REG_RD(bp, MISC_REG_RESET_REG_2) & |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1774 | MISC_REGISTERS_RESET_REG_2_XMAC)) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 1775 | DP(NETIF_MSG_LINK, |
| 1776 | "XMAC already out of reset in 4-port mode\n"); |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1777 | return; |
| 1778 | } |
| 1779 | |
| 1780 | /* Hard reset */ |
| 1781 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_CLEAR, |
| 1782 | MISC_REGISTERS_RESET_REG_2_XMAC); |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 1783 | usleep_range(1000, 2000); |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1784 | |
| 1785 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_SET, |
| 1786 | MISC_REGISTERS_RESET_REG_2_XMAC); |
| 1787 | if (is_port4mode) { |
| 1788 | DP(NETIF_MSG_LINK, "Init XMAC to 2 ports x 10G per path\n"); |
| 1789 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 1790 | /* Set the number of ports on the system side to up to 2 */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1791 | REG_WR(bp, MISC_REG_XMAC_CORE_PORT_MODE, 1); |
| 1792 | |
| 1793 | /* Set the number of ports on the Warp Core to 10G */ |
| 1794 | REG_WR(bp, MISC_REG_XMAC_PHY_PORT_MODE, 3); |
| 1795 | } else { |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 1796 | /* Set the number of ports on the system side to 1 */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1797 | REG_WR(bp, MISC_REG_XMAC_CORE_PORT_MODE, 0); |
| 1798 | if (max_speed == SPEED_10000) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 1799 | DP(NETIF_MSG_LINK, |
| 1800 | "Init XMAC to 10G x 1 port per path\n"); |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1801 | /* Set the number of ports on the Warp Core to 10G */ |
| 1802 | REG_WR(bp, MISC_REG_XMAC_PHY_PORT_MODE, 3); |
| 1803 | } else { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 1804 | DP(NETIF_MSG_LINK, |
| 1805 | "Init XMAC to 20G x 2 ports per path\n"); |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1806 | /* Set the number of ports on the Warp Core to 20G */ |
| 1807 | REG_WR(bp, MISC_REG_XMAC_PHY_PORT_MODE, 1); |
| 1808 | } |
| 1809 | } |
| 1810 | /* Soft reset */ |
| 1811 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_CLEAR, |
| 1812 | MISC_REGISTERS_RESET_REG_2_XMAC_SOFT); |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 1813 | usleep_range(1000, 2000); |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1814 | |
| 1815 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_SET, |
| 1816 | MISC_REGISTERS_RESET_REG_2_XMAC_SOFT); |
| 1817 | |
| 1818 | } |
| 1819 | |
Yaniv Rosner | d3a8f13 | 2012-09-13 02:56:20 +0000 | [diff] [blame] | 1820 | static void bnx2x_set_xmac_rxtx(struct link_params *params, u8 en) |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1821 | { |
| 1822 | u8 port = params->port; |
| 1823 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | b507766 | 2011-08-02 22:59:18 +0000 | [diff] [blame] | 1824 | u32 pfc_ctrl, xmac_base = (port) ? GRCBASE_XMAC1 : GRCBASE_XMAC0; |
Yaniv Rosner | d3a8f13 | 2012-09-13 02:56:20 +0000 | [diff] [blame] | 1825 | u32 val; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1826 | |
| 1827 | if (REG_RD(bp, MISC_REG_RESET_REG_2) & |
| 1828 | MISC_REGISTERS_RESET_REG_2_XMAC) { |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 1829 | /* Send an indication to change the state in the NIG back to XON |
Yaniv Rosner | b507766 | 2011-08-02 22:59:18 +0000 | [diff] [blame] | 1830 | * Clearing this bit enables the next set of this bit to get |
| 1831 | * rising edge |
| 1832 | */ |
| 1833 | pfc_ctrl = REG_RD(bp, xmac_base + XMAC_REG_PFC_CTRL_HI); |
| 1834 | REG_WR(bp, xmac_base + XMAC_REG_PFC_CTRL_HI, |
| 1835 | (pfc_ctrl & ~(1<<1))); |
| 1836 | REG_WR(bp, xmac_base + XMAC_REG_PFC_CTRL_HI, |
| 1837 | (pfc_ctrl | (1<<1))); |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1838 | DP(NETIF_MSG_LINK, "Disable XMAC on port %x\n", port); |
Yaniv Rosner | d3a8f13 | 2012-09-13 02:56:20 +0000 | [diff] [blame] | 1839 | val = REG_RD(bp, xmac_base + XMAC_REG_CTRL); |
| 1840 | if (en) |
| 1841 | val |= (XMAC_CTRL_REG_TX_EN | XMAC_CTRL_REG_RX_EN); |
| 1842 | else |
| 1843 | val &= ~(XMAC_CTRL_REG_TX_EN | XMAC_CTRL_REG_RX_EN); |
| 1844 | REG_WR(bp, xmac_base + XMAC_REG_CTRL, val); |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1845 | } |
| 1846 | } |
| 1847 | |
| 1848 | static int bnx2x_xmac_enable(struct link_params *params, |
| 1849 | struct link_vars *vars, u8 lb) |
| 1850 | { |
| 1851 | u32 val, xmac_base; |
| 1852 | struct bnx2x *bp = params->bp; |
| 1853 | DP(NETIF_MSG_LINK, "enabling XMAC\n"); |
| 1854 | |
| 1855 | xmac_base = (params->port) ? GRCBASE_XMAC1 : GRCBASE_XMAC0; |
| 1856 | |
Yaniv Rosner | ce7c048 | 2011-10-27 05:09:47 +0000 | [diff] [blame] | 1857 | bnx2x_xmac_init(params, vars->line_speed); |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1858 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 1859 | /* This register determines on which events the MAC will assert |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1860 | * error on the i/f to the NIG along w/ EOP. |
| 1861 | */ |
| 1862 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 1863 | /* This register tells the NIG whether to send traffic to UMAC |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1864 | * or XMAC |
| 1865 | */ |
| 1866 | REG_WR(bp, NIG_REG_EGRESS_EMAC0_PORT + params->port*4, 0); |
| 1867 | |
| 1868 | /* Set Max packet size */ |
| 1869 | REG_WR(bp, xmac_base + XMAC_REG_RX_MAX_SIZE, 0x2710); |
| 1870 | |
| 1871 | /* CRC append for Tx packets */ |
| 1872 | REG_WR(bp, xmac_base + XMAC_REG_TX_CTRL, 0xC800); |
| 1873 | |
| 1874 | /* update PFC */ |
| 1875 | bnx2x_update_pfc_xmac(params, vars, 0); |
| 1876 | |
Yuval Mintz | c8c60d8 | 2012-06-06 17:13:07 +0000 | [diff] [blame] | 1877 | if (vars->eee_status & SHMEM_EEE_ADV_STATUS_MASK) { |
| 1878 | DP(NETIF_MSG_LINK, "Setting XMAC for EEE\n"); |
| 1879 | REG_WR(bp, xmac_base + XMAC_REG_EEE_TIMERS_HI, 0x1380008); |
| 1880 | REG_WR(bp, xmac_base + XMAC_REG_EEE_CTRL, 0x1); |
| 1881 | } else { |
| 1882 | REG_WR(bp, xmac_base + XMAC_REG_EEE_CTRL, 0x0); |
| 1883 | } |
| 1884 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1885 | /* Enable TX and RX */ |
| 1886 | val = XMAC_CTRL_REG_TX_EN | XMAC_CTRL_REG_RX_EN; |
| 1887 | |
| 1888 | /* Check loopback mode */ |
| 1889 | if (lb) |
David S. Miller | 8decf86 | 2011-09-22 03:23:13 -0400 | [diff] [blame] | 1890 | val |= XMAC_CTRL_REG_LINE_LOCAL_LPBK; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1891 | REG_WR(bp, xmac_base + XMAC_REG_CTRL, val); |
| 1892 | bnx2x_set_xumac_nig(params, |
| 1893 | ((vars->flow_ctrl & BNX2X_FLOW_CTRL_TX) != 0), 1); |
| 1894 | |
| 1895 | vars->mac_type = MAC_TYPE_XMAC; |
| 1896 | |
| 1897 | return 0; |
| 1898 | } |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 1899 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 1900 | static int bnx2x_emac_enable(struct link_params *params, |
Yaniv Rosner | 9045f6b4 | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 1901 | struct link_vars *vars, u8 lb) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1902 | { |
| 1903 | struct bnx2x *bp = params->bp; |
| 1904 | u8 port = params->port; |
| 1905 | u32 emac_base = port ? GRCBASE_EMAC1 : GRCBASE_EMAC0; |
| 1906 | u32 val; |
| 1907 | |
| 1908 | DP(NETIF_MSG_LINK, "enabling EMAC\n"); |
| 1909 | |
Yaniv Rosner | de6f337 | 2011-08-02 22:59:25 +0000 | [diff] [blame] | 1910 | /* Disable BMAC */ |
| 1911 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_CLEAR, |
| 1912 | (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << port)); |
| 1913 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1914 | /* enable emac and not bmac */ |
| 1915 | REG_WR(bp, NIG_REG_EGRESS_EMAC0_PORT + port*4, 1); |
| 1916 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1917 | /* ASIC */ |
| 1918 | if (vars->phy_flags & PHY_XGXS_FLAG) { |
| 1919 | u32 ser_lane = ((params->lane_config & |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1920 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_MASK) >> |
| 1921 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_SHIFT); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1922 | |
| 1923 | DP(NETIF_MSG_LINK, "XGXS\n"); |
| 1924 | /* select the master lanes (out of 0-3) */ |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1925 | REG_WR(bp, NIG_REG_XGXS_LANE_SEL_P0 + port*4, ser_lane); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1926 | /* select XGXS */ |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1927 | REG_WR(bp, NIG_REG_XGXS_SERDES0_MODE_SEL + port*4, 1); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1928 | |
| 1929 | } else { /* SerDes */ |
| 1930 | DP(NETIF_MSG_LINK, "SerDes\n"); |
| 1931 | /* select SerDes */ |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1932 | REG_WR(bp, NIG_REG_XGXS_SERDES0_MODE_SEL + port*4, 0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1933 | } |
| 1934 | |
Eilon Greenstein | 811a2f2 | 2009-02-12 08:37:04 +0000 | [diff] [blame] | 1935 | bnx2x_bits_en(bp, emac_base + EMAC_REG_EMAC_RX_MODE, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1936 | EMAC_RX_MODE_RESET); |
Eilon Greenstein | 811a2f2 | 2009-02-12 08:37:04 +0000 | [diff] [blame] | 1937 | bnx2x_bits_en(bp, emac_base + EMAC_REG_EMAC_TX_MODE, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1938 | EMAC_TX_MODE_RESET); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1939 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1940 | /* pause enable/disable */ |
| 1941 | bnx2x_bits_dis(bp, emac_base + EMAC_REG_EMAC_RX_MODE, |
| 1942 | EMAC_RX_MODE_FLOW_EN); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1943 | |
| 1944 | bnx2x_bits_dis(bp, emac_base + EMAC_REG_EMAC_TX_MODE, |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1945 | (EMAC_TX_MODE_EXT_PAUSE_EN | |
| 1946 | EMAC_TX_MODE_FLOW_EN)); |
| 1947 | if (!(params->feature_config_flags & |
| 1948 | FEATURE_CONFIG_PFC_ENABLED)) { |
| 1949 | if (vars->flow_ctrl & BNX2X_FLOW_CTRL_RX) |
| 1950 | bnx2x_bits_en(bp, emac_base + |
| 1951 | EMAC_REG_EMAC_RX_MODE, |
| 1952 | EMAC_RX_MODE_FLOW_EN); |
| 1953 | |
| 1954 | if (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX) |
| 1955 | bnx2x_bits_en(bp, emac_base + |
| 1956 | EMAC_REG_EMAC_TX_MODE, |
| 1957 | (EMAC_TX_MODE_EXT_PAUSE_EN | |
| 1958 | EMAC_TX_MODE_FLOW_EN)); |
| 1959 | } else |
| 1960 | bnx2x_bits_en(bp, emac_base + EMAC_REG_EMAC_TX_MODE, |
| 1961 | EMAC_TX_MODE_FLOW_EN); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1962 | |
| 1963 | /* KEEP_VLAN_TAG, promiscuous */ |
| 1964 | val = REG_RD(bp, emac_base + EMAC_REG_EMAC_RX_MODE); |
| 1965 | val |= EMAC_RX_MODE_KEEP_VLAN_TAG | EMAC_RX_MODE_PROMISCUOUS; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1966 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 1967 | /* Setting this bit causes MAC control frames (except for pause |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 1968 | * frames) to be passed on for processing. This setting has no |
| 1969 | * affect on the operation of the pause frames. This bit effects |
| 1970 | * all packets regardless of RX Parser packet sorting logic. |
| 1971 | * Turn the PFC off to make sure we are in Xon state before |
| 1972 | * enabling it. |
| 1973 | */ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1974 | EMAC_WR(bp, EMAC_REG_RX_PFC_MODE, 0); |
| 1975 | if (params->feature_config_flags & FEATURE_CONFIG_PFC_ENABLED) { |
| 1976 | DP(NETIF_MSG_LINK, "PFC is enabled\n"); |
| 1977 | /* Enable PFC again */ |
| 1978 | EMAC_WR(bp, EMAC_REG_RX_PFC_MODE, |
| 1979 | EMAC_REG_RX_PFC_MODE_RX_EN | |
| 1980 | EMAC_REG_RX_PFC_MODE_TX_EN | |
| 1981 | EMAC_REG_RX_PFC_MODE_PRIORITIES); |
| 1982 | |
| 1983 | EMAC_WR(bp, EMAC_REG_RX_PFC_PARAM, |
| 1984 | ((0x0101 << |
| 1985 | EMAC_REG_RX_PFC_PARAM_OPCODE_BITSHIFT) | |
| 1986 | (0x00ff << |
| 1987 | EMAC_REG_RX_PFC_PARAM_PRIORITY_EN_BITSHIFT))); |
| 1988 | val |= EMAC_RX_MODE_KEEP_MAC_CONTROL; |
| 1989 | } |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 1990 | EMAC_WR(bp, EMAC_REG_EMAC_RX_MODE, val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1991 | |
| 1992 | /* Set Loopback */ |
| 1993 | val = REG_RD(bp, emac_base + EMAC_REG_EMAC_MODE); |
| 1994 | if (lb) |
| 1995 | val |= 0x810; |
| 1996 | else |
| 1997 | val &= ~0x810; |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 1998 | EMAC_WR(bp, EMAC_REG_EMAC_MODE, val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1999 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 2000 | /* Enable emac */ |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 2001 | REG_WR(bp, NIG_REG_NIG_EMAC0_EN + port*4, 1); |
| 2002 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 2003 | /* Enable emac for jumbo packets */ |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 2004 | EMAC_WR(bp, EMAC_REG_EMAC_RX_MTU_SIZE, |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2005 | (EMAC_RX_MTU_SIZE_JUMBO_ENA | |
| 2006 | (ETH_MAX_JUMBO_PACKET_SIZE + ETH_OVREHEAD))); |
| 2007 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 2008 | /* Strip CRC */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2009 | REG_WR(bp, NIG_REG_NIG_INGRESS_EMAC0_NO_CRC + port*4, 0x1); |
| 2010 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 2011 | /* Disable the NIG in/out to the bmac */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2012 | REG_WR(bp, NIG_REG_BMAC0_IN_EN + port*4, 0x0); |
| 2013 | REG_WR(bp, NIG_REG_BMAC0_PAUSE_OUT_EN + port*4, 0x0); |
| 2014 | REG_WR(bp, NIG_REG_BMAC0_OUT_EN + port*4, 0x0); |
| 2015 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 2016 | /* Enable the NIG in/out to the emac */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2017 | REG_WR(bp, NIG_REG_EMAC0_IN_EN + port*4, 0x1); |
| 2018 | val = 0; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2019 | if ((params->feature_config_flags & |
| 2020 | FEATURE_CONFIG_PFC_ENABLED) || |
| 2021 | (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX)) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2022 | val = 1; |
| 2023 | |
| 2024 | REG_WR(bp, NIG_REG_EMAC0_PAUSE_OUT_EN + port*4, val); |
| 2025 | REG_WR(bp, NIG_REG_EGRESS_EMAC0_OUT_EN + port*4, 0x1); |
| 2026 | |
Yaniv Rosner | 02a2316 | 2011-01-31 04:22:53 +0000 | [diff] [blame] | 2027 | REG_WR(bp, NIG_REG_BMAC0_REGS_OUT_EN + port*4, 0x0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2028 | |
| 2029 | vars->mac_type = MAC_TYPE_EMAC; |
| 2030 | return 0; |
| 2031 | } |
| 2032 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2033 | static void bnx2x_update_pfc_bmac1(struct link_params *params, |
| 2034 | struct link_vars *vars) |
| 2035 | { |
| 2036 | u32 wb_data[2]; |
| 2037 | struct bnx2x *bp = params->bp; |
| 2038 | u32 bmac_addr = params->port ? NIG_REG_INGRESS_BMAC1_MEM : |
| 2039 | NIG_REG_INGRESS_BMAC0_MEM; |
| 2040 | |
| 2041 | u32 val = 0x14; |
| 2042 | if ((!(params->feature_config_flags & |
| 2043 | FEATURE_CONFIG_PFC_ENABLED)) && |
| 2044 | (vars->flow_ctrl & BNX2X_FLOW_CTRL_RX)) |
| 2045 | /* Enable BigMAC to react on received Pause packets */ |
| 2046 | val |= (1<<5); |
| 2047 | wb_data[0] = val; |
| 2048 | wb_data[1] = 0; |
| 2049 | REG_WR_DMAE(bp, bmac_addr + BIGMAC_REGISTER_RX_CONTROL, wb_data, 2); |
| 2050 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 2051 | /* TX control */ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2052 | val = 0xc0; |
| 2053 | if (!(params->feature_config_flags & |
| 2054 | FEATURE_CONFIG_PFC_ENABLED) && |
| 2055 | (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX)) |
| 2056 | val |= 0x800000; |
| 2057 | wb_data[0] = val; |
| 2058 | wb_data[1] = 0; |
| 2059 | REG_WR_DMAE(bp, bmac_addr + BIGMAC_REGISTER_TX_CONTROL, wb_data, 2); |
| 2060 | } |
| 2061 | |
| 2062 | static void bnx2x_update_pfc_bmac2(struct link_params *params, |
| 2063 | struct link_vars *vars, |
| 2064 | u8 is_lb) |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2065 | { |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 2066 | /* Set rx control: Strip CRC and enable BigMAC to relay |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2067 | * control packets to the system as well |
| 2068 | */ |
| 2069 | u32 wb_data[2]; |
| 2070 | struct bnx2x *bp = params->bp; |
| 2071 | u32 bmac_addr = params->port ? NIG_REG_INGRESS_BMAC1_MEM : |
| 2072 | NIG_REG_INGRESS_BMAC0_MEM; |
| 2073 | u32 val = 0x14; |
| 2074 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2075 | if ((!(params->feature_config_flags & |
| 2076 | FEATURE_CONFIG_PFC_ENABLED)) && |
| 2077 | (vars->flow_ctrl & BNX2X_FLOW_CTRL_RX)) |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2078 | /* Enable BigMAC to react on received Pause packets */ |
| 2079 | val |= (1<<5); |
| 2080 | wb_data[0] = val; |
| 2081 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2082 | REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_RX_CONTROL, wb_data, 2); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2083 | udelay(30); |
| 2084 | |
| 2085 | /* Tx control */ |
| 2086 | val = 0xc0; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2087 | if (!(params->feature_config_flags & |
| 2088 | FEATURE_CONFIG_PFC_ENABLED) && |
| 2089 | (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX)) |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2090 | val |= 0x800000; |
| 2091 | wb_data[0] = val; |
| 2092 | wb_data[1] = 0; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2093 | REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_TX_CONTROL, wb_data, 2); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2094 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2095 | if (params->feature_config_flags & FEATURE_CONFIG_PFC_ENABLED) { |
| 2096 | DP(NETIF_MSG_LINK, "PFC is enabled\n"); |
| 2097 | /* Enable PFC RX & TX & STATS and set 8 COS */ |
| 2098 | wb_data[0] = 0x0; |
| 2099 | wb_data[0] |= (1<<0); /* RX */ |
| 2100 | wb_data[0] |= (1<<1); /* TX */ |
| 2101 | wb_data[0] |= (1<<2); /* Force initial Xon */ |
| 2102 | wb_data[0] |= (1<<3); /* 8 cos */ |
| 2103 | wb_data[0] |= (1<<5); /* STATS */ |
| 2104 | wb_data[1] = 0; |
| 2105 | REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_PFC_CONTROL, |
| 2106 | wb_data, 2); |
| 2107 | /* Clear the force Xon */ |
| 2108 | wb_data[0] &= ~(1<<2); |
| 2109 | } else { |
| 2110 | DP(NETIF_MSG_LINK, "PFC is disabled\n"); |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 2111 | /* Disable PFC RX & TX & STATS and set 8 COS */ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2112 | wb_data[0] = 0x8; |
| 2113 | wb_data[1] = 0; |
| 2114 | } |
| 2115 | |
| 2116 | REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_PFC_CONTROL, wb_data, 2); |
| 2117 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 2118 | /* Set Time (based unit is 512 bit time) between automatic |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2119 | * re-sending of PP packets amd enable automatic re-send of |
| 2120 | * Per-Priroity Packet as long as pp_gen is asserted and |
| 2121 | * pp_disable is low. |
| 2122 | */ |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2123 | val = 0x8000; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2124 | if (params->feature_config_flags & FEATURE_CONFIG_PFC_ENABLED) |
| 2125 | val |= (1<<16); /* enable automatic re-send */ |
| 2126 | |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2127 | wb_data[0] = val; |
| 2128 | wb_data[1] = 0; |
| 2129 | REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_TX_PAUSE_CONTROL, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2130 | wb_data, 2); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2131 | |
| 2132 | /* mac control */ |
| 2133 | val = 0x3; /* Enable RX and TX */ |
| 2134 | if (is_lb) { |
| 2135 | val |= 0x4; /* Local loopback */ |
| 2136 | DP(NETIF_MSG_LINK, "enable bmac loopback\n"); |
| 2137 | } |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2138 | /* When PFC enabled, Pass pause frames towards the NIG. */ |
| 2139 | if (params->feature_config_flags & FEATURE_CONFIG_PFC_ENABLED) |
| 2140 | val |= ((1<<6)|(1<<5)); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2141 | |
| 2142 | wb_data[0] = val; |
| 2143 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2144 | REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_BMAC_CONTROL, wb_data, 2); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2145 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2146 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2147 | /* PFC BRB internal port configuration params */ |
| 2148 | struct bnx2x_pfc_brb_threshold_val { |
| 2149 | u32 pause_xoff; |
| 2150 | u32 pause_xon; |
| 2151 | u32 full_xoff; |
| 2152 | u32 full_xon; |
| 2153 | }; |
| 2154 | |
| 2155 | struct bnx2x_pfc_brb_e3b0_val { |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2156 | u32 per_class_guaranty_mode; |
| 2157 | u32 lb_guarantied_hyst; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2158 | u32 full_lb_xoff_th; |
| 2159 | u32 full_lb_xon_threshold; |
| 2160 | u32 lb_guarantied; |
| 2161 | u32 mac_0_class_t_guarantied; |
| 2162 | u32 mac_0_class_t_guarantied_hyst; |
| 2163 | u32 mac_1_class_t_guarantied; |
| 2164 | u32 mac_1_class_t_guarantied_hyst; |
| 2165 | }; |
| 2166 | |
| 2167 | struct bnx2x_pfc_brb_th_val { |
| 2168 | struct bnx2x_pfc_brb_threshold_val pauseable_th; |
| 2169 | struct bnx2x_pfc_brb_threshold_val non_pauseable_th; |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2170 | struct bnx2x_pfc_brb_threshold_val default_class0; |
| 2171 | struct bnx2x_pfc_brb_threshold_val default_class1; |
| 2172 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2173 | }; |
| 2174 | static int bnx2x_pfc_brb_get_config_params( |
| 2175 | struct link_params *params, |
| 2176 | struct bnx2x_pfc_brb_th_val *config_val) |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2177 | { |
| 2178 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2179 | DP(NETIF_MSG_LINK, "Setting PFC BRB configuration\n"); |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2180 | |
| 2181 | config_val->default_class1.pause_xoff = 0; |
| 2182 | config_val->default_class1.pause_xon = 0; |
| 2183 | config_val->default_class1.full_xoff = 0; |
| 2184 | config_val->default_class1.full_xon = 0; |
| 2185 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2186 | if (CHIP_IS_E2(bp)) { |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 2187 | /* Class0 defaults */ |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2188 | config_val->default_class0.pause_xoff = |
| 2189 | DEFAULT0_E2_BRB_MAC_PAUSE_XOFF_THR; |
| 2190 | config_val->default_class0.pause_xon = |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2191 | DEFAULT0_E2_BRB_MAC_PAUSE_XON_THR; |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2192 | config_val->default_class0.full_xoff = |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2193 | DEFAULT0_E2_BRB_MAC_FULL_XOFF_THR; |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2194 | config_val->default_class0.full_xon = |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2195 | DEFAULT0_E2_BRB_MAC_FULL_XON_THR; |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 2196 | /* Pause able*/ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2197 | config_val->pauseable_th.pause_xoff = |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2198 | PFC_E2_BRB_MAC_PAUSE_XOFF_THR_PAUSE; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2199 | config_val->pauseable_th.pause_xon = |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2200 | PFC_E2_BRB_MAC_PAUSE_XON_THR_PAUSE; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2201 | config_val->pauseable_th.full_xoff = |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2202 | PFC_E2_BRB_MAC_FULL_XOFF_THR_PAUSE; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2203 | config_val->pauseable_th.full_xon = |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2204 | PFC_E2_BRB_MAC_FULL_XON_THR_PAUSE; |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 2205 | /* Non pause able*/ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2206 | config_val->non_pauseable_th.pause_xoff = |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2207 | PFC_E2_BRB_MAC_PAUSE_XOFF_THR_NON_PAUSE; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2208 | config_val->non_pauseable_th.pause_xon = |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2209 | PFC_E2_BRB_MAC_PAUSE_XON_THR_NON_PAUSE; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2210 | config_val->non_pauseable_th.full_xoff = |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2211 | PFC_E2_BRB_MAC_FULL_XOFF_THR_NON_PAUSE; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2212 | config_val->non_pauseable_th.full_xon = |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2213 | PFC_E2_BRB_MAC_FULL_XON_THR_NON_PAUSE; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2214 | } else if (CHIP_IS_E3A0(bp)) { |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 2215 | /* Class0 defaults */ |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2216 | config_val->default_class0.pause_xoff = |
| 2217 | DEFAULT0_E3A0_BRB_MAC_PAUSE_XOFF_THR; |
| 2218 | config_val->default_class0.pause_xon = |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2219 | DEFAULT0_E3A0_BRB_MAC_PAUSE_XON_THR; |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2220 | config_val->default_class0.full_xoff = |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2221 | DEFAULT0_E3A0_BRB_MAC_FULL_XOFF_THR; |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2222 | config_val->default_class0.full_xon = |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2223 | DEFAULT0_E3A0_BRB_MAC_FULL_XON_THR; |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 2224 | /* Pause able */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2225 | config_val->pauseable_th.pause_xoff = |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2226 | PFC_E3A0_BRB_MAC_PAUSE_XOFF_THR_PAUSE; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2227 | config_val->pauseable_th.pause_xon = |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2228 | PFC_E3A0_BRB_MAC_PAUSE_XON_THR_PAUSE; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2229 | config_val->pauseable_th.full_xoff = |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2230 | PFC_E3A0_BRB_MAC_FULL_XOFF_THR_PAUSE; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2231 | config_val->pauseable_th.full_xon = |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2232 | PFC_E3A0_BRB_MAC_FULL_XON_THR_PAUSE; |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 2233 | /* Non pause able*/ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2234 | config_val->non_pauseable_th.pause_xoff = |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2235 | PFC_E3A0_BRB_MAC_PAUSE_XOFF_THR_NON_PAUSE; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2236 | config_val->non_pauseable_th.pause_xon = |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2237 | PFC_E3A0_BRB_MAC_PAUSE_XON_THR_NON_PAUSE; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2238 | config_val->non_pauseable_th.full_xoff = |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2239 | PFC_E3A0_BRB_MAC_FULL_XOFF_THR_NON_PAUSE; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2240 | config_val->non_pauseable_th.full_xon = |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2241 | PFC_E3A0_BRB_MAC_FULL_XON_THR_NON_PAUSE; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2242 | } else if (CHIP_IS_E3B0(bp)) { |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 2243 | /* Class0 defaults */ |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2244 | config_val->default_class0.pause_xoff = |
| 2245 | DEFAULT0_E3B0_BRB_MAC_PAUSE_XOFF_THR; |
| 2246 | config_val->default_class0.pause_xon = |
| 2247 | DEFAULT0_E3B0_BRB_MAC_PAUSE_XON_THR; |
| 2248 | config_val->default_class0.full_xoff = |
| 2249 | DEFAULT0_E3B0_BRB_MAC_FULL_XOFF_THR; |
| 2250 | config_val->default_class0.full_xon = |
| 2251 | DEFAULT0_E3B0_BRB_MAC_FULL_XON_THR; |
| 2252 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2253 | if (params->phy[INT_PHY].flags & |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2254 | FLAGS_4_PORT_MODE) { |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2255 | config_val->pauseable_th.pause_xoff = |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2256 | PFC_E3B0_4P_BRB_MAC_PAUSE_XOFF_THR_PAUSE; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2257 | config_val->pauseable_th.pause_xon = |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2258 | PFC_E3B0_4P_BRB_MAC_PAUSE_XON_THR_PAUSE; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2259 | config_val->pauseable_th.full_xoff = |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2260 | PFC_E3B0_4P_BRB_MAC_FULL_XOFF_THR_PAUSE; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2261 | config_val->pauseable_th.full_xon = |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2262 | PFC_E3B0_4P_BRB_MAC_FULL_XON_THR_PAUSE; |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 2263 | /* Non pause able*/ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2264 | config_val->non_pauseable_th.pause_xoff = |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2265 | PFC_E3B0_4P_BRB_MAC_PAUSE_XOFF_THR_NON_PAUSE; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2266 | config_val->non_pauseable_th.pause_xon = |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2267 | PFC_E3B0_4P_BRB_MAC_PAUSE_XON_THR_NON_PAUSE; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2268 | config_val->non_pauseable_th.full_xoff = |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2269 | PFC_E3B0_4P_BRB_MAC_FULL_XOFF_THR_NON_PAUSE; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2270 | config_val->non_pauseable_th.full_xon = |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2271 | PFC_E3B0_4P_BRB_MAC_FULL_XON_THR_NON_PAUSE; |
| 2272 | } else { |
| 2273 | config_val->pauseable_th.pause_xoff = |
| 2274 | PFC_E3B0_2P_BRB_MAC_PAUSE_XOFF_THR_PAUSE; |
| 2275 | config_val->pauseable_th.pause_xon = |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2276 | PFC_E3B0_2P_BRB_MAC_PAUSE_XON_THR_PAUSE; |
| 2277 | config_val->pauseable_th.full_xoff = |
| 2278 | PFC_E3B0_2P_BRB_MAC_FULL_XOFF_THR_PAUSE; |
| 2279 | config_val->pauseable_th.full_xon = |
| 2280 | PFC_E3B0_2P_BRB_MAC_FULL_XON_THR_PAUSE; |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 2281 | /* Non pause able*/ |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2282 | config_val->non_pauseable_th.pause_xoff = |
| 2283 | PFC_E3B0_2P_BRB_MAC_PAUSE_XOFF_THR_NON_PAUSE; |
| 2284 | config_val->non_pauseable_th.pause_xon = |
| 2285 | PFC_E3B0_2P_BRB_MAC_PAUSE_XON_THR_NON_PAUSE; |
| 2286 | config_val->non_pauseable_th.full_xoff = |
| 2287 | PFC_E3B0_2P_BRB_MAC_FULL_XOFF_THR_NON_PAUSE; |
| 2288 | config_val->non_pauseable_th.full_xon = |
| 2289 | PFC_E3B0_2P_BRB_MAC_FULL_XON_THR_NON_PAUSE; |
| 2290 | } |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2291 | } else |
| 2292 | return -EINVAL; |
| 2293 | |
| 2294 | return 0; |
| 2295 | } |
| 2296 | |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2297 | static void bnx2x_pfc_brb_get_e3b0_config_params( |
| 2298 | struct link_params *params, |
| 2299 | struct bnx2x_pfc_brb_e3b0_val |
| 2300 | *e3b0_val, |
| 2301 | struct bnx2x_nig_brb_pfc_port_params *pfc_params, |
| 2302 | const u8 pfc_enabled) |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2303 | { |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2304 | if (pfc_enabled && pfc_params) { |
| 2305 | e3b0_val->per_class_guaranty_mode = 1; |
| 2306 | e3b0_val->lb_guarantied_hyst = 80; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2307 | |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2308 | if (params->phy[INT_PHY].flags & |
| 2309 | FLAGS_4_PORT_MODE) { |
| 2310 | e3b0_val->full_lb_xoff_th = |
| 2311 | PFC_E3B0_4P_BRB_FULL_LB_XOFF_THR; |
| 2312 | e3b0_val->full_lb_xon_threshold = |
| 2313 | PFC_E3B0_4P_BRB_FULL_LB_XON_THR; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2314 | e3b0_val->lb_guarantied = |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2315 | PFC_E3B0_4P_LB_GUART; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2316 | e3b0_val->mac_0_class_t_guarantied = |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2317 | PFC_E3B0_4P_BRB_MAC_0_CLASS_T_GUART; |
| 2318 | e3b0_val->mac_0_class_t_guarantied_hyst = |
| 2319 | PFC_E3B0_4P_BRB_MAC_0_CLASS_T_GUART_HYST; |
| 2320 | e3b0_val->mac_1_class_t_guarantied = |
| 2321 | PFC_E3B0_4P_BRB_MAC_1_CLASS_T_GUART; |
| 2322 | e3b0_val->mac_1_class_t_guarantied_hyst = |
| 2323 | PFC_E3B0_4P_BRB_MAC_1_CLASS_T_GUART_HYST; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2324 | } else { |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2325 | e3b0_val->full_lb_xoff_th = |
| 2326 | PFC_E3B0_2P_BRB_FULL_LB_XOFF_THR; |
| 2327 | e3b0_val->full_lb_xon_threshold = |
| 2328 | PFC_E3B0_2P_BRB_FULL_LB_XON_THR; |
| 2329 | e3b0_val->mac_0_class_t_guarantied_hyst = |
| 2330 | PFC_E3B0_2P_BRB_MAC_0_CLASS_T_GUART_HYST; |
| 2331 | e3b0_val->mac_1_class_t_guarantied = |
| 2332 | PFC_E3B0_2P_BRB_MAC_1_CLASS_T_GUART; |
| 2333 | e3b0_val->mac_1_class_t_guarantied_hyst = |
| 2334 | PFC_E3B0_2P_BRB_MAC_1_CLASS_T_GUART_HYST; |
| 2335 | |
| 2336 | if (pfc_params->cos0_pauseable != |
| 2337 | pfc_params->cos1_pauseable) { |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 2338 | /* Nonpauseable= Lossy + pauseable = Lossless*/ |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2339 | e3b0_val->lb_guarantied = |
| 2340 | PFC_E3B0_2P_MIX_PAUSE_LB_GUART; |
| 2341 | e3b0_val->mac_0_class_t_guarantied = |
| 2342 | PFC_E3B0_2P_MIX_PAUSE_MAC_0_CLASS_T_GUART; |
| 2343 | } else if (pfc_params->cos0_pauseable) { |
| 2344 | /* Lossless +Lossless*/ |
| 2345 | e3b0_val->lb_guarantied = |
| 2346 | PFC_E3B0_2P_PAUSE_LB_GUART; |
| 2347 | e3b0_val->mac_0_class_t_guarantied = |
| 2348 | PFC_E3B0_2P_PAUSE_MAC_0_CLASS_T_GUART; |
| 2349 | } else { |
| 2350 | /* Lossy +Lossy*/ |
| 2351 | e3b0_val->lb_guarantied = |
| 2352 | PFC_E3B0_2P_NON_PAUSE_LB_GUART; |
| 2353 | e3b0_val->mac_0_class_t_guarantied = |
| 2354 | PFC_E3B0_2P_NON_PAUSE_MAC_0_CLASS_T_GUART; |
| 2355 | } |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2356 | } |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2357 | } else { |
| 2358 | e3b0_val->per_class_guaranty_mode = 0; |
| 2359 | e3b0_val->lb_guarantied_hyst = 0; |
| 2360 | e3b0_val->full_lb_xoff_th = |
| 2361 | DEFAULT_E3B0_BRB_FULL_LB_XOFF_THR; |
| 2362 | e3b0_val->full_lb_xon_threshold = |
| 2363 | DEFAULT_E3B0_BRB_FULL_LB_XON_THR; |
| 2364 | e3b0_val->lb_guarantied = |
| 2365 | DEFAULT_E3B0_LB_GUART; |
| 2366 | e3b0_val->mac_0_class_t_guarantied = |
| 2367 | DEFAULT_E3B0_BRB_MAC_0_CLASS_T_GUART; |
| 2368 | e3b0_val->mac_0_class_t_guarantied_hyst = |
| 2369 | DEFAULT_E3B0_BRB_MAC_0_CLASS_T_GUART_HYST; |
| 2370 | e3b0_val->mac_1_class_t_guarantied = |
| 2371 | DEFAULT_E3B0_BRB_MAC_1_CLASS_T_GUART; |
| 2372 | e3b0_val->mac_1_class_t_guarantied_hyst = |
| 2373 | DEFAULT_E3B0_BRB_MAC_1_CLASS_T_GUART_HYST; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2374 | } |
| 2375 | } |
| 2376 | static int bnx2x_update_pfc_brb(struct link_params *params, |
| 2377 | struct link_vars *vars, |
| 2378 | struct bnx2x_nig_brb_pfc_port_params |
| 2379 | *pfc_params) |
| 2380 | { |
| 2381 | struct bnx2x *bp = params->bp; |
| 2382 | struct bnx2x_pfc_brb_th_val config_val = { {0} }; |
| 2383 | struct bnx2x_pfc_brb_threshold_val *reg_th_config = |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2384 | &config_val.pauseable_th; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2385 | struct bnx2x_pfc_brb_e3b0_val e3b0_val = {0}; |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2386 | const int set_pfc = params->feature_config_flags & |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2387 | FEATURE_CONFIG_PFC_ENABLED; |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2388 | const u8 pfc_enabled = (set_pfc && pfc_params); |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2389 | int bnx2x_status = 0; |
| 2390 | u8 port = params->port; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2391 | |
| 2392 | /* default - pause configuration */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2393 | reg_th_config = &config_val.pauseable_th; |
| 2394 | bnx2x_status = bnx2x_pfc_brb_get_config_params(params, &config_val); |
Yaniv Rosner | de0396f | 2011-11-28 00:49:53 +0000 | [diff] [blame] | 2395 | if (bnx2x_status) |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2396 | return bnx2x_status; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2397 | |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2398 | if (pfc_enabled) { |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2399 | /* First COS */ |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2400 | if (pfc_params->cos0_pauseable) |
| 2401 | reg_th_config = &config_val.pauseable_th; |
| 2402 | else |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2403 | reg_th_config = &config_val.non_pauseable_th; |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2404 | } else |
| 2405 | reg_th_config = &config_val.default_class0; |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 2406 | /* The number of free blocks below which the pause signal to class 0 |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2407 | * of MAC #n is asserted. n=0,1 |
| 2408 | */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2409 | REG_WR(bp, (port) ? BRB1_REG_PAUSE_0_XOFF_THRESHOLD_1 : |
| 2410 | BRB1_REG_PAUSE_0_XOFF_THRESHOLD_0 , |
| 2411 | reg_th_config->pause_xoff); |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 2412 | /* The number of free blocks above which the pause signal to class 0 |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2413 | * of MAC #n is de-asserted. n=0,1 |
| 2414 | */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2415 | REG_WR(bp, (port) ? BRB1_REG_PAUSE_0_XON_THRESHOLD_1 : |
| 2416 | BRB1_REG_PAUSE_0_XON_THRESHOLD_0 , reg_th_config->pause_xon); |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 2417 | /* The number of free blocks below which the full signal to class 0 |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2418 | * of MAC #n is asserted. n=0,1 |
| 2419 | */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2420 | REG_WR(bp, (port) ? BRB1_REG_FULL_0_XOFF_THRESHOLD_1 : |
| 2421 | BRB1_REG_FULL_0_XOFF_THRESHOLD_0 , reg_th_config->full_xoff); |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 2422 | /* The number of free blocks above which the full signal to class 0 |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2423 | * of MAC #n is de-asserted. n=0,1 |
| 2424 | */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2425 | REG_WR(bp, (port) ? BRB1_REG_FULL_0_XON_THRESHOLD_1 : |
| 2426 | BRB1_REG_FULL_0_XON_THRESHOLD_0 , reg_th_config->full_xon); |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2427 | |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2428 | if (pfc_enabled) { |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2429 | /* Second COS */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2430 | if (pfc_params->cos1_pauseable) |
| 2431 | reg_th_config = &config_val.pauseable_th; |
| 2432 | else |
| 2433 | reg_th_config = &config_val.non_pauseable_th; |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2434 | } else |
| 2435 | reg_th_config = &config_val.default_class1; |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 2436 | /* The number of free blocks below which the pause signal to |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2437 | * class 1 of MAC #n is asserted. n=0,1 |
| 2438 | */ |
| 2439 | REG_WR(bp, (port) ? BRB1_REG_PAUSE_1_XOFF_THRESHOLD_1 : |
| 2440 | BRB1_REG_PAUSE_1_XOFF_THRESHOLD_0, |
| 2441 | reg_th_config->pause_xoff); |
| 2442 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 2443 | /* The number of free blocks above which the pause signal to |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2444 | * class 1 of MAC #n is de-asserted. n=0,1 |
| 2445 | */ |
| 2446 | REG_WR(bp, (port) ? BRB1_REG_PAUSE_1_XON_THRESHOLD_1 : |
| 2447 | BRB1_REG_PAUSE_1_XON_THRESHOLD_0, |
| 2448 | reg_th_config->pause_xon); |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 2449 | /* The number of free blocks below which the full signal to |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2450 | * class 1 of MAC #n is asserted. n=0,1 |
| 2451 | */ |
| 2452 | REG_WR(bp, (port) ? BRB1_REG_FULL_1_XOFF_THRESHOLD_1 : |
| 2453 | BRB1_REG_FULL_1_XOFF_THRESHOLD_0, |
| 2454 | reg_th_config->full_xoff); |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 2455 | /* The number of free blocks above which the full signal to |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2456 | * class 1 of MAC #n is de-asserted. n=0,1 |
| 2457 | */ |
| 2458 | REG_WR(bp, (port) ? BRB1_REG_FULL_1_XON_THRESHOLD_1 : |
| 2459 | BRB1_REG_FULL_1_XON_THRESHOLD_0, |
| 2460 | reg_th_config->full_xon); |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2461 | |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2462 | if (CHIP_IS_E3B0(bp)) { |
| 2463 | bnx2x_pfc_brb_get_e3b0_config_params( |
| 2464 | params, |
| 2465 | &e3b0_val, |
| 2466 | pfc_params, |
| 2467 | pfc_enabled); |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2468 | |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2469 | REG_WR(bp, BRB1_REG_PER_CLASS_GUARANTY_MODE, |
| 2470 | e3b0_val.per_class_guaranty_mode); |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2471 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 2472 | /* The hysteresis on the guarantied buffer space for the Lb |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2473 | * port before signaling XON. |
| 2474 | */ |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2475 | REG_WR(bp, BRB1_REG_LB_GUARANTIED_HYST, |
| 2476 | e3b0_val.lb_guarantied_hyst); |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2477 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 2478 | /* The number of free blocks below which the full signal to the |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2479 | * LB port is asserted. |
| 2480 | */ |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2481 | REG_WR(bp, BRB1_REG_FULL_LB_XOFF_THRESHOLD, |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2482 | e3b0_val.full_lb_xoff_th); |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 2483 | /* The number of free blocks above which the full signal to the |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2484 | * LB port is de-asserted. |
| 2485 | */ |
| 2486 | REG_WR(bp, BRB1_REG_FULL_LB_XON_THRESHOLD, |
| 2487 | e3b0_val.full_lb_xon_threshold); |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 2488 | /* The number of blocks guarantied for the MAC #n port. n=0,1 |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2489 | */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2490 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 2491 | /* The number of blocks guarantied for the LB port. */ |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2492 | REG_WR(bp, BRB1_REG_LB_GUARANTIED, |
| 2493 | e3b0_val.lb_guarantied); |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2494 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 2495 | /* The number of blocks guarantied for the MAC #n port. */ |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2496 | REG_WR(bp, BRB1_REG_MAC_GUARANTIED_0, |
| 2497 | 2 * e3b0_val.mac_0_class_t_guarantied); |
| 2498 | REG_WR(bp, BRB1_REG_MAC_GUARANTIED_1, |
| 2499 | 2 * e3b0_val.mac_1_class_t_guarantied); |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 2500 | /* The number of blocks guarantied for class #t in MAC0. t=0,1 |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2501 | */ |
| 2502 | REG_WR(bp, BRB1_REG_MAC_0_CLASS_0_GUARANTIED, |
| 2503 | e3b0_val.mac_0_class_t_guarantied); |
| 2504 | REG_WR(bp, BRB1_REG_MAC_0_CLASS_1_GUARANTIED, |
| 2505 | e3b0_val.mac_0_class_t_guarantied); |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 2506 | /* The hysteresis on the guarantied buffer space for class in |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2507 | * MAC0. t=0,1 |
| 2508 | */ |
| 2509 | REG_WR(bp, BRB1_REG_MAC_0_CLASS_0_GUARANTIED_HYST, |
| 2510 | e3b0_val.mac_0_class_t_guarantied_hyst); |
| 2511 | REG_WR(bp, BRB1_REG_MAC_0_CLASS_1_GUARANTIED_HYST, |
| 2512 | e3b0_val.mac_0_class_t_guarantied_hyst); |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2513 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 2514 | /* The number of blocks guarantied for class #t in MAC1.t=0,1 |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2515 | */ |
| 2516 | REG_WR(bp, BRB1_REG_MAC_1_CLASS_0_GUARANTIED, |
| 2517 | e3b0_val.mac_1_class_t_guarantied); |
| 2518 | REG_WR(bp, BRB1_REG_MAC_1_CLASS_1_GUARANTIED, |
| 2519 | e3b0_val.mac_1_class_t_guarantied); |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 2520 | /* The hysteresis on the guarantied buffer space for class #t |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2521 | * in MAC1. t=0,1 |
| 2522 | */ |
| 2523 | REG_WR(bp, BRB1_REG_MAC_1_CLASS_0_GUARANTIED_HYST, |
| 2524 | e3b0_val.mac_1_class_t_guarantied_hyst); |
| 2525 | REG_WR(bp, BRB1_REG_MAC_1_CLASS_1_GUARANTIED_HYST, |
| 2526 | e3b0_val.mac_1_class_t_guarantied_hyst); |
| 2527 | } |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2528 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2529 | return bnx2x_status; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2530 | } |
| 2531 | |
Vlad Zolotarov | 619c5cb | 2011-06-14 14:33:44 +0300 | [diff] [blame] | 2532 | /****************************************************************************** |
| 2533 | * Description: |
| 2534 | * This function is needed because NIG ARB_CREDIT_WEIGHT_X are |
| 2535 | * not continues and ARB_CREDIT_WEIGHT_0 + offset is suitable. |
| 2536 | ******************************************************************************/ |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 2537 | static int bnx2x_pfc_nig_rx_priority_mask(struct bnx2x *bp, |
| 2538 | u8 cos_entry, |
| 2539 | u32 priority_mask, u8 port) |
Vlad Zolotarov | 619c5cb | 2011-06-14 14:33:44 +0300 | [diff] [blame] | 2540 | { |
| 2541 | u32 nig_reg_rx_priority_mask_add = 0; |
| 2542 | |
| 2543 | switch (cos_entry) { |
| 2544 | case 0: |
| 2545 | nig_reg_rx_priority_mask_add = (port) ? |
| 2546 | NIG_REG_P1_RX_COS0_PRIORITY_MASK : |
| 2547 | NIG_REG_P0_RX_COS0_PRIORITY_MASK; |
| 2548 | break; |
| 2549 | case 1: |
| 2550 | nig_reg_rx_priority_mask_add = (port) ? |
| 2551 | NIG_REG_P1_RX_COS1_PRIORITY_MASK : |
| 2552 | NIG_REG_P0_RX_COS1_PRIORITY_MASK; |
| 2553 | break; |
| 2554 | case 2: |
| 2555 | nig_reg_rx_priority_mask_add = (port) ? |
| 2556 | NIG_REG_P1_RX_COS2_PRIORITY_MASK : |
| 2557 | NIG_REG_P0_RX_COS2_PRIORITY_MASK; |
| 2558 | break; |
| 2559 | case 3: |
| 2560 | if (port) |
| 2561 | return -EINVAL; |
| 2562 | nig_reg_rx_priority_mask_add = NIG_REG_P0_RX_COS3_PRIORITY_MASK; |
| 2563 | break; |
| 2564 | case 4: |
| 2565 | if (port) |
| 2566 | return -EINVAL; |
| 2567 | nig_reg_rx_priority_mask_add = NIG_REG_P0_RX_COS4_PRIORITY_MASK; |
| 2568 | break; |
| 2569 | case 5: |
| 2570 | if (port) |
| 2571 | return -EINVAL; |
| 2572 | nig_reg_rx_priority_mask_add = NIG_REG_P0_RX_COS5_PRIORITY_MASK; |
| 2573 | break; |
| 2574 | } |
| 2575 | |
| 2576 | REG_WR(bp, nig_reg_rx_priority_mask_add, priority_mask); |
| 2577 | |
| 2578 | return 0; |
| 2579 | } |
Yaniv Rosner | b8d6d08 | 2011-07-05 01:06:27 +0000 | [diff] [blame] | 2580 | static void bnx2x_update_mng(struct link_params *params, u32 link_status) |
| 2581 | { |
| 2582 | struct bnx2x *bp = params->bp; |
| 2583 | |
| 2584 | REG_WR(bp, params->shmem_base + |
| 2585 | offsetof(struct shmem_region, |
| 2586 | port_mb[params->port].link_status), link_status); |
| 2587 | } |
| 2588 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2589 | static void bnx2x_update_pfc_nig(struct link_params *params, |
| 2590 | struct link_vars *vars, |
| 2591 | struct bnx2x_nig_brb_pfc_port_params *nig_params) |
| 2592 | { |
| 2593 | u32 xcm_mask = 0, ppp_enable = 0, pause_enable = 0, llfc_out_en = 0; |
Yaniv Rosner | 127302b | 2012-01-17 02:33:26 +0000 | [diff] [blame] | 2594 | u32 llfc_enable = 0, xcm_out_en = 0, hwpfc_enable = 0; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2595 | u32 pkt_priority_to_cos = 0; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2596 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2597 | u8 port = params->port; |
| 2598 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2599 | int set_pfc = params->feature_config_flags & |
| 2600 | FEATURE_CONFIG_PFC_ENABLED; |
| 2601 | DP(NETIF_MSG_LINK, "updating pfc nig parameters\n"); |
| 2602 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 2603 | /* When NIG_LLH0_XCM_MASK_REG_LLHX_XCM_MASK_BCN bit is set |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2604 | * MAC control frames (that are not pause packets) |
| 2605 | * will be forwarded to the XCM. |
| 2606 | */ |
Yaniv Rosner | 127302b | 2012-01-17 02:33:26 +0000 | [diff] [blame] | 2607 | xcm_mask = REG_RD(bp, port ? NIG_REG_LLH1_XCM_MASK : |
| 2608 | NIG_REG_LLH0_XCM_MASK); |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 2609 | /* NIG params will override non PFC params, since it's possible to |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2610 | * do transition from PFC to SAFC |
| 2611 | */ |
| 2612 | if (set_pfc) { |
| 2613 | pause_enable = 0; |
| 2614 | llfc_out_en = 0; |
| 2615 | llfc_enable = 0; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2616 | if (CHIP_IS_E3(bp)) |
| 2617 | ppp_enable = 0; |
| 2618 | else |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2619 | ppp_enable = 1; |
| 2620 | xcm_mask &= ~(port ? NIG_LLH1_XCM_MASK_REG_LLH1_XCM_MASK_BCN : |
| 2621 | NIG_LLH0_XCM_MASK_REG_LLH0_XCM_MASK_BCN); |
Yaniv Rosner | 127302b | 2012-01-17 02:33:26 +0000 | [diff] [blame] | 2622 | xcm_out_en = 0; |
| 2623 | hwpfc_enable = 1; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2624 | } else { |
| 2625 | if (nig_params) { |
| 2626 | llfc_out_en = nig_params->llfc_out_en; |
| 2627 | llfc_enable = nig_params->llfc_enable; |
| 2628 | pause_enable = nig_params->pause_enable; |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 2629 | } else /* Default non PFC mode - PAUSE */ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2630 | pause_enable = 1; |
| 2631 | |
| 2632 | xcm_mask |= (port ? NIG_LLH1_XCM_MASK_REG_LLH1_XCM_MASK_BCN : |
| 2633 | NIG_LLH0_XCM_MASK_REG_LLH0_XCM_MASK_BCN); |
Yaniv Rosner | 127302b | 2012-01-17 02:33:26 +0000 | [diff] [blame] | 2634 | xcm_out_en = 1; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2635 | } |
| 2636 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2637 | if (CHIP_IS_E3(bp)) |
| 2638 | REG_WR(bp, port ? NIG_REG_BRB1_PAUSE_IN_EN : |
| 2639 | NIG_REG_BRB0_PAUSE_IN_EN, pause_enable); |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2640 | REG_WR(bp, port ? NIG_REG_LLFC_OUT_EN_1 : |
| 2641 | NIG_REG_LLFC_OUT_EN_0, llfc_out_en); |
| 2642 | REG_WR(bp, port ? NIG_REG_LLFC_ENABLE_1 : |
| 2643 | NIG_REG_LLFC_ENABLE_0, llfc_enable); |
| 2644 | REG_WR(bp, port ? NIG_REG_PAUSE_ENABLE_1 : |
| 2645 | NIG_REG_PAUSE_ENABLE_0, pause_enable); |
| 2646 | |
| 2647 | REG_WR(bp, port ? NIG_REG_PPP_ENABLE_1 : |
| 2648 | NIG_REG_PPP_ENABLE_0, ppp_enable); |
| 2649 | |
| 2650 | REG_WR(bp, port ? NIG_REG_LLH1_XCM_MASK : |
| 2651 | NIG_REG_LLH0_XCM_MASK, xcm_mask); |
| 2652 | |
Yaniv Rosner | 127302b | 2012-01-17 02:33:26 +0000 | [diff] [blame] | 2653 | REG_WR(bp, port ? NIG_REG_LLFC_EGRESS_SRC_ENABLE_1 : |
| 2654 | NIG_REG_LLFC_EGRESS_SRC_ENABLE_0, 0x7); |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2655 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 2656 | /* Output enable for RX_XCM # IF */ |
Yaniv Rosner | 127302b | 2012-01-17 02:33:26 +0000 | [diff] [blame] | 2657 | REG_WR(bp, port ? NIG_REG_XCM1_OUT_EN : |
| 2658 | NIG_REG_XCM0_OUT_EN, xcm_out_en); |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2659 | |
| 2660 | /* HW PFC TX enable */ |
Yaniv Rosner | 127302b | 2012-01-17 02:33:26 +0000 | [diff] [blame] | 2661 | REG_WR(bp, port ? NIG_REG_P1_HWPFC_ENABLE : |
| 2662 | NIG_REG_P0_HWPFC_ENABLE, hwpfc_enable); |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2663 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2664 | if (nig_params) { |
Vlad Zolotarov | 619c5cb | 2011-06-14 14:33:44 +0300 | [diff] [blame] | 2665 | u8 i = 0; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2666 | pkt_priority_to_cos = nig_params->pkt_priority_to_cos; |
| 2667 | |
Vlad Zolotarov | 619c5cb | 2011-06-14 14:33:44 +0300 | [diff] [blame] | 2668 | for (i = 0; i < nig_params->num_of_rx_cos_priority_mask; i++) |
| 2669 | bnx2x_pfc_nig_rx_priority_mask(bp, i, |
| 2670 | nig_params->rx_cos_priority_mask[i], port); |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2671 | |
| 2672 | REG_WR(bp, port ? NIG_REG_LLFC_HIGH_PRIORITY_CLASSES_1 : |
| 2673 | NIG_REG_LLFC_HIGH_PRIORITY_CLASSES_0, |
| 2674 | nig_params->llfc_high_priority_classes); |
| 2675 | |
| 2676 | REG_WR(bp, port ? NIG_REG_LLFC_LOW_PRIORITY_CLASSES_1 : |
| 2677 | NIG_REG_LLFC_LOW_PRIORITY_CLASSES_0, |
| 2678 | nig_params->llfc_low_priority_classes); |
| 2679 | } |
| 2680 | REG_WR(bp, port ? NIG_REG_P1_PKT_PRIORITY_TO_COS : |
| 2681 | NIG_REG_P0_PKT_PRIORITY_TO_COS, |
| 2682 | pkt_priority_to_cos); |
| 2683 | } |
| 2684 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2685 | int bnx2x_update_pfc(struct link_params *params, |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2686 | struct link_vars *vars, |
| 2687 | struct bnx2x_nig_brb_pfc_port_params *pfc_params) |
| 2688 | { |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 2689 | /* The PFC and pause are orthogonal to one another, meaning when |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2690 | * PFC is enabled, the pause are disabled, and when PFC is |
| 2691 | * disabled, pause are set according to the pause result. |
| 2692 | */ |
| 2693 | u32 val; |
| 2694 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2695 | int bnx2x_status = 0; |
| 2696 | u8 bmac_loopback = (params->loopback_mode == LOOPBACK_BMAC); |
Yaniv Rosner | b8d6d08 | 2011-07-05 01:06:27 +0000 | [diff] [blame] | 2697 | |
| 2698 | if (params->feature_config_flags & FEATURE_CONFIG_PFC_ENABLED) |
| 2699 | vars->link_status |= LINK_STATUS_PFC_ENABLED; |
| 2700 | else |
| 2701 | vars->link_status &= ~LINK_STATUS_PFC_ENABLED; |
| 2702 | |
| 2703 | bnx2x_update_mng(params, vars->link_status); |
| 2704 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 2705 | /* Update NIG params */ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2706 | bnx2x_update_pfc_nig(params, vars, pfc_params); |
| 2707 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 2708 | /* Update BRB params */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2709 | bnx2x_status = bnx2x_update_pfc_brb(params, vars, pfc_params); |
Yaniv Rosner | de0396f | 2011-11-28 00:49:53 +0000 | [diff] [blame] | 2710 | if (bnx2x_status) |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2711 | return bnx2x_status; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2712 | |
| 2713 | if (!vars->link_up) |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2714 | return bnx2x_status; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2715 | |
| 2716 | DP(NETIF_MSG_LINK, "About to update PFC in BMAC\n"); |
Yaniv Rosner | 375944c | 2012-09-11 04:34:10 +0000 | [diff] [blame] | 2717 | |
| 2718 | if (CHIP_IS_E3(bp)) { |
| 2719 | if (vars->mac_type == MAC_TYPE_XMAC) |
| 2720 | bnx2x_update_pfc_xmac(params, vars, 0); |
| 2721 | } else { |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2722 | val = REG_RD(bp, MISC_REG_RESET_REG_2); |
| 2723 | if ((val & |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 2724 | (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << params->port)) |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2725 | == 0) { |
| 2726 | DP(NETIF_MSG_LINK, "About to update PFC in EMAC\n"); |
| 2727 | bnx2x_emac_enable(params, vars, 0); |
| 2728 | return bnx2x_status; |
| 2729 | } |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2730 | if (CHIP_IS_E2(bp)) |
| 2731 | bnx2x_update_pfc_bmac2(params, vars, bmac_loopback); |
| 2732 | else |
| 2733 | bnx2x_update_pfc_bmac1(params, vars); |
| 2734 | |
| 2735 | val = 0; |
| 2736 | if ((params->feature_config_flags & |
| 2737 | FEATURE_CONFIG_PFC_ENABLED) || |
| 2738 | (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX)) |
| 2739 | val = 1; |
| 2740 | REG_WR(bp, NIG_REG_BMAC0_PAUSE_OUT_EN + params->port*4, val); |
| 2741 | } |
| 2742 | return bnx2x_status; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2743 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2744 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2745 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 2746 | static int bnx2x_bmac1_enable(struct link_params *params, |
| 2747 | struct link_vars *vars, |
| 2748 | u8 is_lb) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2749 | { |
| 2750 | struct bnx2x *bp = params->bp; |
| 2751 | u8 port = params->port; |
| 2752 | u32 bmac_addr = port ? NIG_REG_INGRESS_BMAC1_MEM : |
| 2753 | NIG_REG_INGRESS_BMAC0_MEM; |
| 2754 | u32 wb_data[2]; |
| 2755 | u32 val; |
| 2756 | |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2757 | DP(NETIF_MSG_LINK, "Enabling BigMAC1\n"); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2758 | |
| 2759 | /* XGXS control */ |
| 2760 | wb_data[0] = 0x3c; |
| 2761 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2762 | REG_WR_DMAE(bp, bmac_addr + BIGMAC_REGISTER_BMAC_XGXS_CONTROL, |
| 2763 | wb_data, 2); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2764 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 2765 | /* TX MAC SA */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2766 | wb_data[0] = ((params->mac_addr[2] << 24) | |
| 2767 | (params->mac_addr[3] << 16) | |
| 2768 | (params->mac_addr[4] << 8) | |
| 2769 | params->mac_addr[5]); |
| 2770 | wb_data[1] = ((params->mac_addr[0] << 8) | |
| 2771 | params->mac_addr[1]); |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2772 | REG_WR_DMAE(bp, bmac_addr + BIGMAC_REGISTER_TX_SOURCE_ADDR, wb_data, 2); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2773 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 2774 | /* MAC control */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2775 | val = 0x3; |
| 2776 | if (is_lb) { |
| 2777 | val |= 0x4; |
| 2778 | DP(NETIF_MSG_LINK, "enable bmac loopback\n"); |
| 2779 | } |
| 2780 | wb_data[0] = val; |
| 2781 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2782 | REG_WR_DMAE(bp, bmac_addr + BIGMAC_REGISTER_BMAC_CONTROL, wb_data, 2); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2783 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 2784 | /* Set rx mtu */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2785 | wb_data[0] = ETH_MAX_JUMBO_PACKET_SIZE + ETH_OVREHEAD; |
| 2786 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2787 | REG_WR_DMAE(bp, bmac_addr + BIGMAC_REGISTER_RX_MAX_SIZE, wb_data, 2); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2788 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2789 | bnx2x_update_pfc_bmac1(params, vars); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2790 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 2791 | /* Set tx mtu */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2792 | wb_data[0] = ETH_MAX_JUMBO_PACKET_SIZE + ETH_OVREHEAD; |
| 2793 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2794 | REG_WR_DMAE(bp, bmac_addr + BIGMAC_REGISTER_TX_MAX_SIZE, wb_data, 2); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2795 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 2796 | /* Set cnt max size */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2797 | wb_data[0] = ETH_MAX_JUMBO_PACKET_SIZE + ETH_OVREHEAD; |
| 2798 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2799 | REG_WR_DMAE(bp, bmac_addr + BIGMAC_REGISTER_CNT_MAX_SIZE, wb_data, 2); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2800 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 2801 | /* Configure SAFC */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2802 | wb_data[0] = 0x1000200; |
| 2803 | wb_data[1] = 0; |
| 2804 | REG_WR_DMAE(bp, bmac_addr + BIGMAC_REGISTER_RX_LLFC_MSG_FLDS, |
| 2805 | wb_data, 2); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2806 | |
| 2807 | return 0; |
| 2808 | } |
| 2809 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 2810 | static int bnx2x_bmac2_enable(struct link_params *params, |
| 2811 | struct link_vars *vars, |
| 2812 | u8 is_lb) |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2813 | { |
| 2814 | struct bnx2x *bp = params->bp; |
| 2815 | u8 port = params->port; |
| 2816 | u32 bmac_addr = port ? NIG_REG_INGRESS_BMAC1_MEM : |
| 2817 | NIG_REG_INGRESS_BMAC0_MEM; |
| 2818 | u32 wb_data[2]; |
| 2819 | |
| 2820 | DP(NETIF_MSG_LINK, "Enabling BigMAC2\n"); |
| 2821 | |
| 2822 | wb_data[0] = 0; |
| 2823 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2824 | REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_BMAC_CONTROL, wb_data, 2); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2825 | udelay(30); |
| 2826 | |
| 2827 | /* XGXS control: Reset phy HW, MDIO registers, PHY PLL and BMAC */ |
| 2828 | wb_data[0] = 0x3c; |
| 2829 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2830 | REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_BMAC_XGXS_CONTROL, |
| 2831 | wb_data, 2); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2832 | |
| 2833 | udelay(30); |
| 2834 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 2835 | /* TX MAC SA */ |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2836 | wb_data[0] = ((params->mac_addr[2] << 24) | |
| 2837 | (params->mac_addr[3] << 16) | |
| 2838 | (params->mac_addr[4] << 8) | |
| 2839 | params->mac_addr[5]); |
| 2840 | wb_data[1] = ((params->mac_addr[0] << 8) | |
| 2841 | params->mac_addr[1]); |
| 2842 | REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_TX_SOURCE_ADDR, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2843 | wb_data, 2); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2844 | |
| 2845 | udelay(30); |
| 2846 | |
| 2847 | /* Configure SAFC */ |
| 2848 | wb_data[0] = 0x1000200; |
| 2849 | wb_data[1] = 0; |
| 2850 | REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_RX_LLFC_MSG_FLDS, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2851 | wb_data, 2); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2852 | udelay(30); |
| 2853 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 2854 | /* Set RX MTU */ |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2855 | wb_data[0] = ETH_MAX_JUMBO_PACKET_SIZE + ETH_OVREHEAD; |
| 2856 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2857 | REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_RX_MAX_SIZE, wb_data, 2); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2858 | udelay(30); |
| 2859 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 2860 | /* Set TX MTU */ |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2861 | wb_data[0] = ETH_MAX_JUMBO_PACKET_SIZE + ETH_OVREHEAD; |
| 2862 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2863 | REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_TX_MAX_SIZE, wb_data, 2); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2864 | udelay(30); |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 2865 | /* Set cnt max size */ |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2866 | wb_data[0] = ETH_MAX_JUMBO_PACKET_SIZE + ETH_OVREHEAD - 2; |
| 2867 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2868 | REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_CNT_MAX_SIZE, wb_data, 2); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2869 | udelay(30); |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2870 | bnx2x_update_pfc_bmac2(params, vars, is_lb); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2871 | |
| 2872 | return 0; |
| 2873 | } |
| 2874 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 2875 | static int bnx2x_bmac_enable(struct link_params *params, |
| 2876 | struct link_vars *vars, |
Yaniv Rosner | d3a8f13 | 2012-09-13 02:56:20 +0000 | [diff] [blame] | 2877 | u8 is_lb, u8 reset_bmac) |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2878 | { |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 2879 | int rc = 0; |
| 2880 | u8 port = params->port; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2881 | struct bnx2x *bp = params->bp; |
| 2882 | u32 val; |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 2883 | /* Reset and unreset the BigMac */ |
Yaniv Rosner | d3a8f13 | 2012-09-13 02:56:20 +0000 | [diff] [blame] | 2884 | if (reset_bmac) { |
| 2885 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_CLEAR, |
| 2886 | (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << port)); |
| 2887 | usleep_range(1000, 2000); |
| 2888 | } |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2889 | |
| 2890 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_SET, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2891 | (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << port)); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2892 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 2893 | /* Enable access for bmac registers */ |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2894 | REG_WR(bp, NIG_REG_BMAC0_REGS_OUT_EN + port*4, 0x1); |
| 2895 | |
| 2896 | /* Enable BMAC according to BMAC type*/ |
| 2897 | if (CHIP_IS_E2(bp)) |
| 2898 | rc = bnx2x_bmac2_enable(params, vars, is_lb); |
| 2899 | else |
| 2900 | rc = bnx2x_bmac1_enable(params, vars, is_lb); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2901 | REG_WR(bp, NIG_REG_XGXS_SERDES0_MODE_SEL + port*4, 0x1); |
| 2902 | REG_WR(bp, NIG_REG_XGXS_LANE_SEL_P0 + port*4, 0x0); |
| 2903 | REG_WR(bp, NIG_REG_EGRESS_EMAC0_PORT + port*4, 0x0); |
| 2904 | val = 0; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2905 | if ((params->feature_config_flags & |
| 2906 | FEATURE_CONFIG_PFC_ENABLED) || |
| 2907 | (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX)) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2908 | val = 1; |
| 2909 | REG_WR(bp, NIG_REG_BMAC0_PAUSE_OUT_EN + port*4, val); |
| 2910 | REG_WR(bp, NIG_REG_EGRESS_EMAC0_OUT_EN + port*4, 0x0); |
| 2911 | REG_WR(bp, NIG_REG_EMAC0_IN_EN + port*4, 0x0); |
| 2912 | REG_WR(bp, NIG_REG_EMAC0_PAUSE_OUT_EN + port*4, 0x0); |
| 2913 | REG_WR(bp, NIG_REG_BMAC0_IN_EN + port*4, 0x1); |
| 2914 | REG_WR(bp, NIG_REG_BMAC0_OUT_EN + port*4, 0x1); |
| 2915 | |
| 2916 | vars->mac_type = MAC_TYPE_BMAC; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2917 | return rc; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2918 | } |
| 2919 | |
Yaniv Rosner | d3a8f13 | 2012-09-13 02:56:20 +0000 | [diff] [blame] | 2920 | static void bnx2x_set_bmac_rx(struct bnx2x *bp, u32 chip_id, u8 port, u8 en) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2921 | { |
| 2922 | u32 bmac_addr = port ? NIG_REG_INGRESS_BMAC1_MEM : |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2923 | NIG_REG_INGRESS_BMAC0_MEM; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2924 | u32 wb_data[2]; |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 2925 | u32 nig_bmac_enable = REG_RD(bp, NIG_REG_BMAC0_REGS_OUT_EN + port*4); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2926 | |
Yaniv Rosner | d3a8f13 | 2012-09-13 02:56:20 +0000 | [diff] [blame] | 2927 | if (CHIP_IS_E2(bp)) |
| 2928 | bmac_addr += BIGMAC2_REGISTER_BMAC_CONTROL; |
| 2929 | else |
| 2930 | bmac_addr += BIGMAC_REGISTER_BMAC_CONTROL; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2931 | /* Only if the bmac is out of reset */ |
| 2932 | if (REG_RD(bp, MISC_REG_RESET_REG_2) & |
| 2933 | (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << port) && |
| 2934 | nig_bmac_enable) { |
Yaniv Rosner | d3a8f13 | 2012-09-13 02:56:20 +0000 | [diff] [blame] | 2935 | /* Clear Rx Enable bit in BMAC_CONTROL register */ |
| 2936 | REG_RD_DMAE(bp, bmac_addr, wb_data, 2); |
| 2937 | if (en) |
| 2938 | wb_data[0] |= BMAC_CONTROL_RX_ENABLE; |
| 2939 | else |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2940 | wb_data[0] &= ~BMAC_CONTROL_RX_ENABLE; |
Yaniv Rosner | d3a8f13 | 2012-09-13 02:56:20 +0000 | [diff] [blame] | 2941 | REG_WR_DMAE(bp, bmac_addr, wb_data, 2); |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 2942 | usleep_range(1000, 2000); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2943 | } |
| 2944 | } |
| 2945 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 2946 | static int bnx2x_pbf_update(struct link_params *params, u32 flow_ctrl, |
| 2947 | u32 line_speed) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2948 | { |
| 2949 | struct bnx2x *bp = params->bp; |
| 2950 | u8 port = params->port; |
| 2951 | u32 init_crd, crd; |
| 2952 | u32 count = 1000; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2953 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 2954 | /* Disable port */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2955 | REG_WR(bp, PBF_REG_DISABLE_NEW_TASK_PROC_P0 + port*4, 0x1); |
| 2956 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 2957 | /* Wait for init credit */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2958 | init_crd = REG_RD(bp, PBF_REG_P0_INIT_CRD + port*4); |
| 2959 | crd = REG_RD(bp, PBF_REG_P0_CREDIT + port*8); |
| 2960 | DP(NETIF_MSG_LINK, "init_crd 0x%x crd 0x%x\n", init_crd, crd); |
| 2961 | |
| 2962 | while ((init_crd != crd) && count) { |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 2963 | usleep_range(5000, 10000); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2964 | crd = REG_RD(bp, PBF_REG_P0_CREDIT + port*8); |
| 2965 | count--; |
| 2966 | } |
| 2967 | crd = REG_RD(bp, PBF_REG_P0_CREDIT + port*8); |
| 2968 | if (init_crd != crd) { |
| 2969 | DP(NETIF_MSG_LINK, "BUG! init_crd 0x%x != crd 0x%x\n", |
| 2970 | init_crd, crd); |
| 2971 | return -EINVAL; |
| 2972 | } |
| 2973 | |
David S. Miller | c0700f9 | 2008-12-16 23:53:20 -0800 | [diff] [blame] | 2974 | if (flow_ctrl & BNX2X_FLOW_CTRL_RX || |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 2975 | line_speed == SPEED_10 || |
| 2976 | line_speed == SPEED_100 || |
| 2977 | line_speed == SPEED_1000 || |
| 2978 | line_speed == SPEED_2500) { |
| 2979 | REG_WR(bp, PBF_REG_P0_PAUSE_ENABLE + port*4, 1); |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 2980 | /* Update threshold */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2981 | REG_WR(bp, PBF_REG_P0_ARB_THRSH + port*4, 0); |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 2982 | /* Update init credit */ |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2983 | init_crd = 778; /* (800-18-4) */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2984 | |
| 2985 | } else { |
| 2986 | u32 thresh = (ETH_MAX_JUMBO_PACKET_SIZE + |
| 2987 | ETH_OVREHEAD)/16; |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 2988 | REG_WR(bp, PBF_REG_P0_PAUSE_ENABLE + port*4, 0); |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 2989 | /* Update threshold */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2990 | REG_WR(bp, PBF_REG_P0_ARB_THRSH + port*4, thresh); |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 2991 | /* Update init credit */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2992 | switch (line_speed) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2993 | case SPEED_10000: |
| 2994 | init_crd = thresh + 553 - 22; |
| 2995 | break; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2996 | default: |
| 2997 | DP(NETIF_MSG_LINK, "Invalid line_speed 0x%x\n", |
| 2998 | line_speed); |
| 2999 | return -EINVAL; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3000 | } |
| 3001 | } |
| 3002 | REG_WR(bp, PBF_REG_P0_INIT_CRD + port*4, init_crd); |
| 3003 | DP(NETIF_MSG_LINK, "PBF updated to speed %d credit %d\n", |
| 3004 | line_speed, init_crd); |
| 3005 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 3006 | /* Probe the credit changes */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3007 | REG_WR(bp, PBF_REG_INIT_P0 + port*4, 0x1); |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 3008 | usleep_range(5000, 10000); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3009 | REG_WR(bp, PBF_REG_INIT_P0 + port*4, 0x0); |
| 3010 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 3011 | /* Enable port */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3012 | REG_WR(bp, PBF_REG_DISABLE_NEW_TASK_PROC_P0 + port*4, 0x0); |
| 3013 | return 0; |
| 3014 | } |
| 3015 | |
Dmitry Kravkov | e892067 | 2011-05-04 23:52:40 +0000 | [diff] [blame] | 3016 | /** |
| 3017 | * bnx2x_get_emac_base - retrive emac base address |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3018 | * |
Dmitry Kravkov | e892067 | 2011-05-04 23:52:40 +0000 | [diff] [blame] | 3019 | * @bp: driver handle |
| 3020 | * @mdc_mdio_access: access type |
| 3021 | * @port: port id |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3022 | * |
| 3023 | * This function selects the MDC/MDIO access (through emac0 or |
| 3024 | * emac1) depend on the mdc_mdio_access, port, port swapped. Each |
| 3025 | * phy has a default access mode, which could also be overridden |
| 3026 | * by nvram configuration. This parameter, whether this is the |
| 3027 | * default phy configuration, or the nvram overrun |
| 3028 | * configuration, is passed here as mdc_mdio_access and selects |
| 3029 | * the emac_base for the CL45 read/writes operations |
| 3030 | */ |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 3031 | static u32 bnx2x_get_emac_base(struct bnx2x *bp, |
| 3032 | u32 mdc_mdio_access, u8 port) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3033 | { |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 3034 | u32 emac_base = 0; |
| 3035 | switch (mdc_mdio_access) { |
| 3036 | case SHARED_HW_CFG_MDC_MDIO_ACCESS1_PHY_TYPE: |
| 3037 | break; |
| 3038 | case SHARED_HW_CFG_MDC_MDIO_ACCESS1_EMAC0: |
| 3039 | if (REG_RD(bp, NIG_REG_PORT_SWAP)) |
| 3040 | emac_base = GRCBASE_EMAC1; |
| 3041 | else |
| 3042 | emac_base = GRCBASE_EMAC0; |
| 3043 | break; |
| 3044 | case SHARED_HW_CFG_MDC_MDIO_ACCESS1_EMAC1: |
Eilon Greenstein | 589abe3 | 2009-02-12 08:36:55 +0000 | [diff] [blame] | 3045 | if (REG_RD(bp, NIG_REG_PORT_SWAP)) |
| 3046 | emac_base = GRCBASE_EMAC0; |
| 3047 | else |
| 3048 | emac_base = GRCBASE_EMAC1; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3049 | break; |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 3050 | case SHARED_HW_CFG_MDC_MDIO_ACCESS1_BOTH: |
| 3051 | emac_base = (port) ? GRCBASE_EMAC1 : GRCBASE_EMAC0; |
| 3052 | break; |
| 3053 | case SHARED_HW_CFG_MDC_MDIO_ACCESS1_SWAPPED: |
Eilon Greenstein | 6378c02 | 2008-08-13 15:59:25 -0700 | [diff] [blame] | 3054 | emac_base = (port) ? GRCBASE_EMAC0 : GRCBASE_EMAC1; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3055 | break; |
| 3056 | default: |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3057 | break; |
| 3058 | } |
| 3059 | return emac_base; |
| 3060 | |
| 3061 | } |
| 3062 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3063 | /******************************************************************/ |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 3064 | /* CL22 access functions */ |
| 3065 | /******************************************************************/ |
| 3066 | static int bnx2x_cl22_write(struct bnx2x *bp, |
| 3067 | struct bnx2x_phy *phy, |
| 3068 | u16 reg, u16 val) |
| 3069 | { |
| 3070 | u32 tmp, mode; |
| 3071 | u8 i; |
| 3072 | int rc = 0; |
| 3073 | /* Switch to CL22 */ |
| 3074 | mode = REG_RD(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_MODE); |
| 3075 | REG_WR(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_MODE, |
| 3076 | mode & ~EMAC_MDIO_MODE_CLAUSE_45); |
| 3077 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 3078 | /* Address */ |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 3079 | tmp = ((phy->addr << 21) | (reg << 16) | val | |
| 3080 | EMAC_MDIO_COMM_COMMAND_WRITE_22 | |
| 3081 | EMAC_MDIO_COMM_START_BUSY); |
| 3082 | REG_WR(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM, tmp); |
| 3083 | |
| 3084 | for (i = 0; i < 50; i++) { |
| 3085 | udelay(10); |
| 3086 | |
| 3087 | tmp = REG_RD(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM); |
| 3088 | if (!(tmp & EMAC_MDIO_COMM_START_BUSY)) { |
| 3089 | udelay(5); |
| 3090 | break; |
| 3091 | } |
| 3092 | } |
| 3093 | if (tmp & EMAC_MDIO_COMM_START_BUSY) { |
| 3094 | DP(NETIF_MSG_LINK, "write phy register failed\n"); |
| 3095 | rc = -EFAULT; |
| 3096 | } |
| 3097 | REG_WR(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_MODE, mode); |
| 3098 | return rc; |
| 3099 | } |
| 3100 | |
| 3101 | static int bnx2x_cl22_read(struct bnx2x *bp, |
| 3102 | struct bnx2x_phy *phy, |
| 3103 | u16 reg, u16 *ret_val) |
| 3104 | { |
| 3105 | u32 val, mode; |
| 3106 | u16 i; |
| 3107 | int rc = 0; |
| 3108 | |
| 3109 | /* Switch to CL22 */ |
| 3110 | mode = REG_RD(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_MODE); |
| 3111 | REG_WR(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_MODE, |
| 3112 | mode & ~EMAC_MDIO_MODE_CLAUSE_45); |
| 3113 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 3114 | /* Address */ |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 3115 | val = ((phy->addr << 21) | (reg << 16) | |
| 3116 | EMAC_MDIO_COMM_COMMAND_READ_22 | |
| 3117 | EMAC_MDIO_COMM_START_BUSY); |
| 3118 | REG_WR(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM, val); |
| 3119 | |
| 3120 | for (i = 0; i < 50; i++) { |
| 3121 | udelay(10); |
| 3122 | |
| 3123 | val = REG_RD(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM); |
| 3124 | if (!(val & EMAC_MDIO_COMM_START_BUSY)) { |
| 3125 | *ret_val = (u16)(val & EMAC_MDIO_COMM_DATA); |
| 3126 | udelay(5); |
| 3127 | break; |
| 3128 | } |
| 3129 | } |
| 3130 | if (val & EMAC_MDIO_COMM_START_BUSY) { |
| 3131 | DP(NETIF_MSG_LINK, "read phy register failed\n"); |
| 3132 | |
| 3133 | *ret_val = 0; |
| 3134 | rc = -EFAULT; |
| 3135 | } |
| 3136 | REG_WR(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_MODE, mode); |
| 3137 | return rc; |
| 3138 | } |
| 3139 | |
| 3140 | /******************************************************************/ |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3141 | /* CL45 access functions */ |
| 3142 | /******************************************************************/ |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 3143 | static int bnx2x_cl45_read(struct bnx2x *bp, struct bnx2x_phy *phy, |
| 3144 | u8 devad, u16 reg, u16 *ret_val) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3145 | { |
Yaniv Rosner | a198c14 | 2011-05-31 21:29:42 +0000 | [diff] [blame] | 3146 | u32 val; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3147 | u16 i; |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 3148 | int rc = 0; |
Yaniv Rosner | 157fa28 | 2011-08-02 22:59:32 +0000 | [diff] [blame] | 3149 | if (phy->flags & FLAGS_MDC_MDIO_WA_B0) |
| 3150 | bnx2x_bits_en(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_STATUS, |
| 3151 | EMAC_MDIO_STATUS_10MB); |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 3152 | /* Address */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3153 | val = ((phy->addr << 21) | (devad << 16) | reg | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3154 | EMAC_MDIO_COMM_COMMAND_ADDRESS | |
| 3155 | EMAC_MDIO_COMM_START_BUSY); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3156 | REG_WR(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM, val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3157 | |
| 3158 | for (i = 0; i < 50; i++) { |
| 3159 | udelay(10); |
| 3160 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3161 | val = REG_RD(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3162 | if (!(val & EMAC_MDIO_COMM_START_BUSY)) { |
| 3163 | udelay(5); |
| 3164 | break; |
| 3165 | } |
| 3166 | } |
| 3167 | if (val & EMAC_MDIO_COMM_START_BUSY) { |
| 3168 | DP(NETIF_MSG_LINK, "read phy register failed\n"); |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 3169 | netdev_err(bp->dev, "MDC/MDIO access timeout\n"); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3170 | *ret_val = 0; |
| 3171 | rc = -EFAULT; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3172 | } else { |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 3173 | /* Data */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3174 | val = ((phy->addr << 21) | (devad << 16) | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3175 | EMAC_MDIO_COMM_COMMAND_READ_45 | |
| 3176 | EMAC_MDIO_COMM_START_BUSY); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3177 | REG_WR(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM, val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3178 | |
| 3179 | for (i = 0; i < 50; i++) { |
| 3180 | udelay(10); |
| 3181 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3182 | val = REG_RD(bp, phy->mdio_ctrl + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3183 | EMAC_REG_EMAC_MDIO_COMM); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3184 | if (!(val & EMAC_MDIO_COMM_START_BUSY)) { |
| 3185 | *ret_val = (u16)(val & EMAC_MDIO_COMM_DATA); |
| 3186 | break; |
| 3187 | } |
| 3188 | } |
| 3189 | if (val & EMAC_MDIO_COMM_START_BUSY) { |
| 3190 | DP(NETIF_MSG_LINK, "read phy register failed\n"); |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 3191 | netdev_err(bp->dev, "MDC/MDIO access timeout\n"); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3192 | *ret_val = 0; |
| 3193 | rc = -EFAULT; |
| 3194 | } |
| 3195 | } |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 3196 | /* Work around for E3 A0 */ |
| 3197 | if (phy->flags & FLAGS_MDC_MDIO_WA) { |
| 3198 | phy->flags ^= FLAGS_DUMMY_READ; |
| 3199 | if (phy->flags & FLAGS_DUMMY_READ) { |
| 3200 | u16 temp_val; |
| 3201 | bnx2x_cl45_read(bp, phy, devad, 0xf, &temp_val); |
| 3202 | } |
| 3203 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3204 | |
Yaniv Rosner | 157fa28 | 2011-08-02 22:59:32 +0000 | [diff] [blame] | 3205 | if (phy->flags & FLAGS_MDC_MDIO_WA_B0) |
| 3206 | bnx2x_bits_dis(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_STATUS, |
| 3207 | EMAC_MDIO_STATUS_10MB); |
Yaniv Rosner | a198c14 | 2011-05-31 21:29:42 +0000 | [diff] [blame] | 3208 | return rc; |
| 3209 | } |
| 3210 | |
| 3211 | static int bnx2x_cl45_write(struct bnx2x *bp, struct bnx2x_phy *phy, |
| 3212 | u8 devad, u16 reg, u16 val) |
| 3213 | { |
| 3214 | u32 tmp; |
| 3215 | u8 i; |
| 3216 | int rc = 0; |
Yaniv Rosner | 157fa28 | 2011-08-02 22:59:32 +0000 | [diff] [blame] | 3217 | if (phy->flags & FLAGS_MDC_MDIO_WA_B0) |
| 3218 | bnx2x_bits_en(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_STATUS, |
| 3219 | EMAC_MDIO_STATUS_10MB); |
Yaniv Rosner | a198c14 | 2011-05-31 21:29:42 +0000 | [diff] [blame] | 3220 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 3221 | /* Address */ |
Yaniv Rosner | a198c14 | 2011-05-31 21:29:42 +0000 | [diff] [blame] | 3222 | tmp = ((phy->addr << 21) | (devad << 16) | reg | |
| 3223 | EMAC_MDIO_COMM_COMMAND_ADDRESS | |
| 3224 | EMAC_MDIO_COMM_START_BUSY); |
| 3225 | REG_WR(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM, tmp); |
| 3226 | |
| 3227 | for (i = 0; i < 50; i++) { |
| 3228 | udelay(10); |
| 3229 | |
| 3230 | tmp = REG_RD(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM); |
| 3231 | if (!(tmp & EMAC_MDIO_COMM_START_BUSY)) { |
| 3232 | udelay(5); |
| 3233 | break; |
| 3234 | } |
| 3235 | } |
| 3236 | if (tmp & EMAC_MDIO_COMM_START_BUSY) { |
| 3237 | DP(NETIF_MSG_LINK, "write phy register failed\n"); |
| 3238 | netdev_err(bp->dev, "MDC/MDIO access timeout\n"); |
| 3239 | rc = -EFAULT; |
Yaniv Rosner | a198c14 | 2011-05-31 21:29:42 +0000 | [diff] [blame] | 3240 | } else { |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 3241 | /* Data */ |
Yaniv Rosner | a198c14 | 2011-05-31 21:29:42 +0000 | [diff] [blame] | 3242 | tmp = ((phy->addr << 21) | (devad << 16) | val | |
| 3243 | EMAC_MDIO_COMM_COMMAND_WRITE_45 | |
| 3244 | EMAC_MDIO_COMM_START_BUSY); |
| 3245 | REG_WR(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM, tmp); |
| 3246 | |
| 3247 | for (i = 0; i < 50; i++) { |
| 3248 | udelay(10); |
| 3249 | |
| 3250 | tmp = REG_RD(bp, phy->mdio_ctrl + |
| 3251 | EMAC_REG_EMAC_MDIO_COMM); |
| 3252 | if (!(tmp & EMAC_MDIO_COMM_START_BUSY)) { |
| 3253 | udelay(5); |
| 3254 | break; |
| 3255 | } |
| 3256 | } |
| 3257 | if (tmp & EMAC_MDIO_COMM_START_BUSY) { |
| 3258 | DP(NETIF_MSG_LINK, "write phy register failed\n"); |
| 3259 | netdev_err(bp->dev, "MDC/MDIO access timeout\n"); |
| 3260 | rc = -EFAULT; |
| 3261 | } |
| 3262 | } |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 3263 | /* Work around for E3 A0 */ |
| 3264 | if (phy->flags & FLAGS_MDC_MDIO_WA) { |
| 3265 | phy->flags ^= FLAGS_DUMMY_READ; |
| 3266 | if (phy->flags & FLAGS_DUMMY_READ) { |
| 3267 | u16 temp_val; |
| 3268 | bnx2x_cl45_read(bp, phy, devad, 0xf, &temp_val); |
| 3269 | } |
| 3270 | } |
Yaniv Rosner | 157fa28 | 2011-08-02 22:59:32 +0000 | [diff] [blame] | 3271 | if (phy->flags & FLAGS_MDC_MDIO_WA_B0) |
| 3272 | bnx2x_bits_dis(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_STATUS, |
| 3273 | EMAC_MDIO_STATUS_10MB); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3274 | return rc; |
| 3275 | } |
Yuval Mintz | ec4010e | 2012-09-10 05:51:06 +0000 | [diff] [blame] | 3276 | |
| 3277 | /******************************************************************/ |
| 3278 | /* EEE section */ |
| 3279 | /******************************************************************/ |
| 3280 | static u8 bnx2x_eee_has_cap(struct link_params *params) |
| 3281 | { |
| 3282 | struct bnx2x *bp = params->bp; |
| 3283 | |
| 3284 | if (REG_RD(bp, params->shmem2_base) <= |
| 3285 | offsetof(struct shmem2_region, eee_status[params->port])) |
| 3286 | return 0; |
| 3287 | |
| 3288 | return 1; |
| 3289 | } |
| 3290 | |
| 3291 | static int bnx2x_eee_nvram_to_time(u32 nvram_mode, u32 *idle_timer) |
| 3292 | { |
| 3293 | switch (nvram_mode) { |
| 3294 | case PORT_FEAT_CFG_EEE_POWER_MODE_BALANCED: |
| 3295 | *idle_timer = EEE_MODE_NVRAM_BALANCED_TIME; |
| 3296 | break; |
| 3297 | case PORT_FEAT_CFG_EEE_POWER_MODE_AGGRESSIVE: |
| 3298 | *idle_timer = EEE_MODE_NVRAM_AGGRESSIVE_TIME; |
| 3299 | break; |
| 3300 | case PORT_FEAT_CFG_EEE_POWER_MODE_LOW_LATENCY: |
| 3301 | *idle_timer = EEE_MODE_NVRAM_LATENCY_TIME; |
| 3302 | break; |
| 3303 | default: |
| 3304 | *idle_timer = 0; |
| 3305 | break; |
| 3306 | } |
| 3307 | |
| 3308 | return 0; |
| 3309 | } |
| 3310 | |
| 3311 | static int bnx2x_eee_time_to_nvram(u32 idle_timer, u32 *nvram_mode) |
| 3312 | { |
| 3313 | switch (idle_timer) { |
| 3314 | case EEE_MODE_NVRAM_BALANCED_TIME: |
| 3315 | *nvram_mode = PORT_FEAT_CFG_EEE_POWER_MODE_BALANCED; |
| 3316 | break; |
| 3317 | case EEE_MODE_NVRAM_AGGRESSIVE_TIME: |
| 3318 | *nvram_mode = PORT_FEAT_CFG_EEE_POWER_MODE_AGGRESSIVE; |
| 3319 | break; |
| 3320 | case EEE_MODE_NVRAM_LATENCY_TIME: |
| 3321 | *nvram_mode = PORT_FEAT_CFG_EEE_POWER_MODE_LOW_LATENCY; |
| 3322 | break; |
| 3323 | default: |
| 3324 | *nvram_mode = PORT_FEAT_CFG_EEE_POWER_MODE_DISABLED; |
| 3325 | break; |
| 3326 | } |
| 3327 | |
| 3328 | return 0; |
| 3329 | } |
| 3330 | |
| 3331 | static u32 bnx2x_eee_calc_timer(struct link_params *params) |
| 3332 | { |
| 3333 | u32 eee_mode, eee_idle; |
| 3334 | struct bnx2x *bp = params->bp; |
| 3335 | |
| 3336 | if (params->eee_mode & EEE_MODE_OVERRIDE_NVRAM) { |
| 3337 | if (params->eee_mode & EEE_MODE_OUTPUT_TIME) { |
| 3338 | /* time value in eee_mode --> used directly*/ |
| 3339 | eee_idle = params->eee_mode & EEE_MODE_TIMER_MASK; |
| 3340 | } else { |
| 3341 | /* hsi value in eee_mode --> time */ |
| 3342 | if (bnx2x_eee_nvram_to_time(params->eee_mode & |
| 3343 | EEE_MODE_NVRAM_MASK, |
| 3344 | &eee_idle)) |
| 3345 | return 0; |
| 3346 | } |
| 3347 | } else { |
| 3348 | /* hsi values in nvram --> time*/ |
| 3349 | eee_mode = ((REG_RD(bp, params->shmem_base + |
| 3350 | offsetof(struct shmem_region, dev_info. |
| 3351 | port_feature_config[params->port]. |
| 3352 | eee_power_mode)) & |
| 3353 | PORT_FEAT_CFG_EEE_POWER_MODE_MASK) >> |
| 3354 | PORT_FEAT_CFG_EEE_POWER_MODE_SHIFT); |
| 3355 | |
| 3356 | if (bnx2x_eee_nvram_to_time(eee_mode, &eee_idle)) |
| 3357 | return 0; |
| 3358 | } |
| 3359 | |
| 3360 | return eee_idle; |
| 3361 | } |
| 3362 | |
| 3363 | static int bnx2x_eee_set_timers(struct link_params *params, |
| 3364 | struct link_vars *vars) |
| 3365 | { |
| 3366 | u32 eee_idle = 0, eee_mode; |
| 3367 | struct bnx2x *bp = params->bp; |
| 3368 | |
| 3369 | eee_idle = bnx2x_eee_calc_timer(params); |
| 3370 | |
| 3371 | if (eee_idle) { |
| 3372 | REG_WR(bp, MISC_REG_CPMU_LP_IDLE_THR_P0 + (params->port << 2), |
| 3373 | eee_idle); |
| 3374 | } else if ((params->eee_mode & EEE_MODE_ENABLE_LPI) && |
| 3375 | (params->eee_mode & EEE_MODE_OVERRIDE_NVRAM) && |
| 3376 | (params->eee_mode & EEE_MODE_OUTPUT_TIME)) { |
| 3377 | DP(NETIF_MSG_LINK, "Error: Tx LPI is enabled with timer 0\n"); |
| 3378 | return -EINVAL; |
| 3379 | } |
| 3380 | |
| 3381 | vars->eee_status &= ~(SHMEM_EEE_TIMER_MASK | SHMEM_EEE_TIME_OUTPUT_BIT); |
| 3382 | if (params->eee_mode & EEE_MODE_OUTPUT_TIME) { |
| 3383 | /* eee_idle in 1u --> eee_status in 16u */ |
| 3384 | eee_idle >>= 4; |
| 3385 | vars->eee_status |= (eee_idle & SHMEM_EEE_TIMER_MASK) | |
| 3386 | SHMEM_EEE_TIME_OUTPUT_BIT; |
| 3387 | } else { |
| 3388 | if (bnx2x_eee_time_to_nvram(eee_idle, &eee_mode)) |
| 3389 | return -EINVAL; |
| 3390 | vars->eee_status |= eee_mode; |
| 3391 | } |
| 3392 | |
| 3393 | return 0; |
| 3394 | } |
| 3395 | |
| 3396 | static int bnx2x_eee_initial_config(struct link_params *params, |
| 3397 | struct link_vars *vars, u8 mode) |
| 3398 | { |
| 3399 | vars->eee_status |= ((u32) mode) << SHMEM_EEE_SUPPORTED_SHIFT; |
| 3400 | |
| 3401 | /* Propogate params' bits --> vars (for migration exposure) */ |
| 3402 | if (params->eee_mode & EEE_MODE_ENABLE_LPI) |
| 3403 | vars->eee_status |= SHMEM_EEE_LPI_REQUESTED_BIT; |
| 3404 | else |
| 3405 | vars->eee_status &= ~SHMEM_EEE_LPI_REQUESTED_BIT; |
| 3406 | |
| 3407 | if (params->eee_mode & EEE_MODE_ADV_LPI) |
| 3408 | vars->eee_status |= SHMEM_EEE_REQUESTED_BIT; |
| 3409 | else |
| 3410 | vars->eee_status &= ~SHMEM_EEE_REQUESTED_BIT; |
| 3411 | |
| 3412 | return bnx2x_eee_set_timers(params, vars); |
| 3413 | } |
| 3414 | |
| 3415 | static int bnx2x_eee_disable(struct bnx2x_phy *phy, |
| 3416 | struct link_params *params, |
| 3417 | struct link_vars *vars) |
| 3418 | { |
| 3419 | struct bnx2x *bp = params->bp; |
| 3420 | |
| 3421 | /* Make Certain LPI is disabled */ |
| 3422 | REG_WR(bp, MISC_REG_CPMU_LP_FW_ENABLE_P0 + (params->port << 2), 0); |
| 3423 | |
| 3424 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_EEE_ADV, 0x0); |
| 3425 | |
| 3426 | vars->eee_status &= ~SHMEM_EEE_ADV_STATUS_MASK; |
| 3427 | |
| 3428 | return 0; |
| 3429 | } |
| 3430 | |
| 3431 | static int bnx2x_eee_advertise(struct bnx2x_phy *phy, |
| 3432 | struct link_params *params, |
| 3433 | struct link_vars *vars, u8 modes) |
| 3434 | { |
| 3435 | struct bnx2x *bp = params->bp; |
| 3436 | u16 val = 0; |
| 3437 | |
| 3438 | /* Mask events preventing LPI generation */ |
| 3439 | REG_WR(bp, MISC_REG_CPMU_LP_MASK_EXT_P0 + (params->port << 2), 0xfc20); |
| 3440 | |
| 3441 | if (modes & SHMEM_EEE_10G_ADV) { |
| 3442 | DP(NETIF_MSG_LINK, "Advertise 10GBase-T EEE\n"); |
| 3443 | val |= 0x8; |
| 3444 | } |
| 3445 | if (modes & SHMEM_EEE_1G_ADV) { |
| 3446 | DP(NETIF_MSG_LINK, "Advertise 1GBase-T EEE\n"); |
| 3447 | val |= 0x4; |
| 3448 | } |
| 3449 | |
| 3450 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_EEE_ADV, val); |
| 3451 | |
| 3452 | vars->eee_status &= ~SHMEM_EEE_ADV_STATUS_MASK; |
| 3453 | vars->eee_status |= (modes << SHMEM_EEE_ADV_STATUS_SHIFT); |
| 3454 | |
| 3455 | return 0; |
| 3456 | } |
| 3457 | |
| 3458 | static void bnx2x_update_mng_eee(struct link_params *params, u32 eee_status) |
| 3459 | { |
| 3460 | struct bnx2x *bp = params->bp; |
| 3461 | |
| 3462 | if (bnx2x_eee_has_cap(params)) |
| 3463 | REG_WR(bp, params->shmem2_base + |
| 3464 | offsetof(struct shmem2_region, |
| 3465 | eee_status[params->port]), eee_status); |
| 3466 | } |
| 3467 | |
| 3468 | static void bnx2x_eee_an_resolve(struct bnx2x_phy *phy, |
| 3469 | struct link_params *params, |
| 3470 | struct link_vars *vars) |
| 3471 | { |
| 3472 | struct bnx2x *bp = params->bp; |
| 3473 | u16 adv = 0, lp = 0; |
| 3474 | u32 lp_adv = 0; |
| 3475 | u8 neg = 0; |
| 3476 | |
| 3477 | bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_EEE_ADV, &adv); |
| 3478 | bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_LP_EEE_ADV, &lp); |
| 3479 | |
| 3480 | if (lp & 0x2) { |
| 3481 | lp_adv |= SHMEM_EEE_100M_ADV; |
| 3482 | if (adv & 0x2) { |
| 3483 | if (vars->line_speed == SPEED_100) |
| 3484 | neg = 1; |
| 3485 | DP(NETIF_MSG_LINK, "EEE negotiated - 100M\n"); |
| 3486 | } |
| 3487 | } |
| 3488 | if (lp & 0x14) { |
| 3489 | lp_adv |= SHMEM_EEE_1G_ADV; |
| 3490 | if (adv & 0x14) { |
| 3491 | if (vars->line_speed == SPEED_1000) |
| 3492 | neg = 1; |
| 3493 | DP(NETIF_MSG_LINK, "EEE negotiated - 1G\n"); |
| 3494 | } |
| 3495 | } |
| 3496 | if (lp & 0x68) { |
| 3497 | lp_adv |= SHMEM_EEE_10G_ADV; |
| 3498 | if (adv & 0x68) { |
| 3499 | if (vars->line_speed == SPEED_10000) |
| 3500 | neg = 1; |
| 3501 | DP(NETIF_MSG_LINK, "EEE negotiated - 10G\n"); |
| 3502 | } |
| 3503 | } |
| 3504 | |
| 3505 | vars->eee_status &= ~SHMEM_EEE_LP_ADV_STATUS_MASK; |
| 3506 | vars->eee_status |= (lp_adv << SHMEM_EEE_LP_ADV_STATUS_SHIFT); |
| 3507 | |
| 3508 | if (neg) { |
| 3509 | DP(NETIF_MSG_LINK, "EEE is active\n"); |
| 3510 | vars->eee_status |= SHMEM_EEE_ACTIVE_BIT; |
| 3511 | } |
| 3512 | |
| 3513 | } |
| 3514 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 3515 | /******************************************************************/ |
| 3516 | /* BSC access functions from E3 */ |
| 3517 | /******************************************************************/ |
| 3518 | static void bnx2x_bsc_module_sel(struct link_params *params) |
| 3519 | { |
| 3520 | int idx; |
| 3521 | u32 board_cfg, sfp_ctrl; |
| 3522 | u32 i2c_pins[I2C_SWITCH_WIDTH], i2c_val[I2C_SWITCH_WIDTH]; |
| 3523 | struct bnx2x *bp = params->bp; |
| 3524 | u8 port = params->port; |
| 3525 | /* Read I2C output PINs */ |
| 3526 | board_cfg = REG_RD(bp, params->shmem_base + |
| 3527 | offsetof(struct shmem_region, |
| 3528 | dev_info.shared_hw_config.board)); |
| 3529 | i2c_pins[I2C_BSC0] = board_cfg & SHARED_HW_CFG_E3_I2C_MUX0_MASK; |
| 3530 | i2c_pins[I2C_BSC1] = (board_cfg & SHARED_HW_CFG_E3_I2C_MUX1_MASK) >> |
| 3531 | SHARED_HW_CFG_E3_I2C_MUX1_SHIFT; |
| 3532 | |
| 3533 | /* Read I2C output value */ |
| 3534 | sfp_ctrl = REG_RD(bp, params->shmem_base + |
| 3535 | offsetof(struct shmem_region, |
| 3536 | dev_info.port_hw_config[port].e3_cmn_pin_cfg)); |
| 3537 | i2c_val[I2C_BSC0] = (sfp_ctrl & PORT_HW_CFG_E3_I2C_MUX0_MASK) > 0; |
| 3538 | i2c_val[I2C_BSC1] = (sfp_ctrl & PORT_HW_CFG_E3_I2C_MUX1_MASK) > 0; |
| 3539 | DP(NETIF_MSG_LINK, "Setting BSC switch\n"); |
| 3540 | for (idx = 0; idx < I2C_SWITCH_WIDTH; idx++) |
| 3541 | bnx2x_set_cfg_pin(bp, i2c_pins[idx], i2c_val[idx]); |
| 3542 | } |
| 3543 | |
| 3544 | static int bnx2x_bsc_read(struct link_params *params, |
| 3545 | struct bnx2x_phy *phy, |
| 3546 | u8 sl_devid, |
| 3547 | u16 sl_addr, |
| 3548 | u8 lc_addr, |
| 3549 | u8 xfer_cnt, |
| 3550 | u32 *data_array) |
| 3551 | { |
| 3552 | u32 val, i; |
| 3553 | int rc = 0; |
| 3554 | struct bnx2x *bp = params->bp; |
| 3555 | |
| 3556 | if ((sl_devid != 0xa0) && (sl_devid != 0xa2)) { |
| 3557 | DP(NETIF_MSG_LINK, "invalid sl_devid 0x%x\n", sl_devid); |
| 3558 | return -EINVAL; |
| 3559 | } |
| 3560 | |
| 3561 | if (xfer_cnt > 16) { |
| 3562 | DP(NETIF_MSG_LINK, "invalid xfer_cnt %d. Max is 16 bytes\n", |
| 3563 | xfer_cnt); |
| 3564 | return -EINVAL; |
| 3565 | } |
| 3566 | bnx2x_bsc_module_sel(params); |
| 3567 | |
| 3568 | xfer_cnt = 16 - lc_addr; |
| 3569 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 3570 | /* Enable the engine */ |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 3571 | val = REG_RD(bp, MCP_REG_MCPR_IMC_COMMAND); |
| 3572 | val |= MCPR_IMC_COMMAND_ENABLE; |
| 3573 | REG_WR(bp, MCP_REG_MCPR_IMC_COMMAND, val); |
| 3574 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 3575 | /* Program slave device ID */ |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 3576 | val = (sl_devid << 16) | sl_addr; |
| 3577 | REG_WR(bp, MCP_REG_MCPR_IMC_SLAVE_CONTROL, val); |
| 3578 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 3579 | /* Start xfer with 0 byte to update the address pointer ???*/ |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 3580 | val = (MCPR_IMC_COMMAND_ENABLE) | |
| 3581 | (MCPR_IMC_COMMAND_WRITE_OP << |
| 3582 | MCPR_IMC_COMMAND_OPERATION_BITSHIFT) | |
| 3583 | (lc_addr << MCPR_IMC_COMMAND_TRANSFER_ADDRESS_BITSHIFT) | (0); |
| 3584 | REG_WR(bp, MCP_REG_MCPR_IMC_COMMAND, val); |
| 3585 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 3586 | /* Poll for completion */ |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 3587 | i = 0; |
| 3588 | val = REG_RD(bp, MCP_REG_MCPR_IMC_COMMAND); |
| 3589 | while (((val >> MCPR_IMC_COMMAND_IMC_STATUS_BITSHIFT) & 0x3) != 1) { |
| 3590 | udelay(10); |
| 3591 | val = REG_RD(bp, MCP_REG_MCPR_IMC_COMMAND); |
| 3592 | if (i++ > 1000) { |
| 3593 | DP(NETIF_MSG_LINK, "wr 0 byte timed out after %d try\n", |
| 3594 | i); |
| 3595 | rc = -EFAULT; |
| 3596 | break; |
| 3597 | } |
| 3598 | } |
| 3599 | if (rc == -EFAULT) |
| 3600 | return rc; |
| 3601 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 3602 | /* Start xfer with read op */ |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 3603 | val = (MCPR_IMC_COMMAND_ENABLE) | |
| 3604 | (MCPR_IMC_COMMAND_READ_OP << |
| 3605 | MCPR_IMC_COMMAND_OPERATION_BITSHIFT) | |
| 3606 | (lc_addr << MCPR_IMC_COMMAND_TRANSFER_ADDRESS_BITSHIFT) | |
| 3607 | (xfer_cnt); |
| 3608 | REG_WR(bp, MCP_REG_MCPR_IMC_COMMAND, val); |
| 3609 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 3610 | /* Poll for completion */ |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 3611 | i = 0; |
| 3612 | val = REG_RD(bp, MCP_REG_MCPR_IMC_COMMAND); |
| 3613 | while (((val >> MCPR_IMC_COMMAND_IMC_STATUS_BITSHIFT) & 0x3) != 1) { |
| 3614 | udelay(10); |
| 3615 | val = REG_RD(bp, MCP_REG_MCPR_IMC_COMMAND); |
| 3616 | if (i++ > 1000) { |
| 3617 | DP(NETIF_MSG_LINK, "rd op timed out after %d try\n", i); |
| 3618 | rc = -EFAULT; |
| 3619 | break; |
| 3620 | } |
| 3621 | } |
| 3622 | if (rc == -EFAULT) |
| 3623 | return rc; |
| 3624 | |
| 3625 | for (i = (lc_addr >> 2); i < 4; i++) { |
| 3626 | data_array[i] = REG_RD(bp, (MCP_REG_MCPR_IMC_DATAREG0 + i*4)); |
| 3627 | #ifdef __BIG_ENDIAN |
| 3628 | data_array[i] = ((data_array[i] & 0x000000ff) << 24) | |
| 3629 | ((data_array[i] & 0x0000ff00) << 8) | |
| 3630 | ((data_array[i] & 0x00ff0000) >> 8) | |
| 3631 | ((data_array[i] & 0xff000000) >> 24); |
| 3632 | #endif |
| 3633 | } |
| 3634 | return rc; |
| 3635 | } |
| 3636 | |
| 3637 | static void bnx2x_cl45_read_or_write(struct bnx2x *bp, struct bnx2x_phy *phy, |
| 3638 | u8 devad, u16 reg, u16 or_val) |
| 3639 | { |
| 3640 | u16 val; |
| 3641 | bnx2x_cl45_read(bp, phy, devad, reg, &val); |
| 3642 | bnx2x_cl45_write(bp, phy, devad, reg, val | or_val); |
| 3643 | } |
| 3644 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 3645 | int bnx2x_phy_read(struct link_params *params, u8 phy_addr, |
| 3646 | u8 devad, u16 reg, u16 *ret_val) |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3647 | { |
| 3648 | u8 phy_index; |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 3649 | /* Probe for the phy according to the given phy_addr, and execute |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3650 | * the read request on it |
| 3651 | */ |
| 3652 | for (phy_index = 0; phy_index < params->num_phys; phy_index++) { |
| 3653 | if (params->phy[phy_index].addr == phy_addr) { |
| 3654 | return bnx2x_cl45_read(params->bp, |
| 3655 | ¶ms->phy[phy_index], devad, |
| 3656 | reg, ret_val); |
| 3657 | } |
| 3658 | } |
| 3659 | return -EINVAL; |
| 3660 | } |
| 3661 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 3662 | int bnx2x_phy_write(struct link_params *params, u8 phy_addr, |
| 3663 | u8 devad, u16 reg, u16 val) |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3664 | { |
| 3665 | u8 phy_index; |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 3666 | /* Probe for the phy according to the given phy_addr, and execute |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3667 | * the write request on it |
| 3668 | */ |
| 3669 | for (phy_index = 0; phy_index < params->num_phys; phy_index++) { |
| 3670 | if (params->phy[phy_index].addr == phy_addr) { |
| 3671 | return bnx2x_cl45_write(params->bp, |
| 3672 | ¶ms->phy[phy_index], devad, |
| 3673 | reg, val); |
| 3674 | } |
| 3675 | } |
| 3676 | return -EINVAL; |
| 3677 | } |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 3678 | static u8 bnx2x_get_warpcore_lane(struct bnx2x_phy *phy, |
| 3679 | struct link_params *params) |
| 3680 | { |
| 3681 | u8 lane = 0; |
| 3682 | struct bnx2x *bp = params->bp; |
| 3683 | u32 path_swap, path_swap_ovr; |
| 3684 | u8 path, port; |
| 3685 | |
| 3686 | path = BP_PATH(bp); |
| 3687 | port = params->port; |
| 3688 | |
| 3689 | if (bnx2x_is_4_port_mode(bp)) { |
| 3690 | u32 port_swap, port_swap_ovr; |
| 3691 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 3692 | /* Figure out path swap value */ |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 3693 | path_swap_ovr = REG_RD(bp, MISC_REG_FOUR_PORT_PATH_SWAP_OVWR); |
| 3694 | if (path_swap_ovr & 0x1) |
| 3695 | path_swap = (path_swap_ovr & 0x2); |
| 3696 | else |
| 3697 | path_swap = REG_RD(bp, MISC_REG_FOUR_PORT_PATH_SWAP); |
| 3698 | |
| 3699 | if (path_swap) |
| 3700 | path = path ^ 1; |
| 3701 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 3702 | /* Figure out port swap value */ |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 3703 | port_swap_ovr = REG_RD(bp, MISC_REG_FOUR_PORT_PORT_SWAP_OVWR); |
| 3704 | if (port_swap_ovr & 0x1) |
| 3705 | port_swap = (port_swap_ovr & 0x2); |
| 3706 | else |
| 3707 | port_swap = REG_RD(bp, MISC_REG_FOUR_PORT_PORT_SWAP); |
| 3708 | |
| 3709 | if (port_swap) |
| 3710 | port = port ^ 1; |
| 3711 | |
| 3712 | lane = (port<<1) + path; |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 3713 | } else { /* Two port mode - no port swap */ |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 3714 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 3715 | /* Figure out path swap value */ |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 3716 | path_swap_ovr = |
| 3717 | REG_RD(bp, MISC_REG_TWO_PORT_PATH_SWAP_OVWR); |
| 3718 | if (path_swap_ovr & 0x1) { |
| 3719 | path_swap = (path_swap_ovr & 0x2); |
| 3720 | } else { |
| 3721 | path_swap = |
| 3722 | REG_RD(bp, MISC_REG_TWO_PORT_PATH_SWAP); |
| 3723 | } |
| 3724 | if (path_swap) |
| 3725 | path = path ^ 1; |
| 3726 | |
| 3727 | lane = path << 1 ; |
| 3728 | } |
| 3729 | return lane; |
| 3730 | } |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3731 | |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 3732 | static void bnx2x_set_aer_mmd(struct link_params *params, |
| 3733 | struct bnx2x_phy *phy) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3734 | { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3735 | u32 ser_lane; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 3736 | u16 offset, aer_val; |
| 3737 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3738 | ser_lane = ((params->lane_config & |
| 3739 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_MASK) >> |
| 3740 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_SHIFT); |
| 3741 | |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 3742 | offset = (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT) ? |
| 3743 | (phy->addr + ser_lane) : 0; |
| 3744 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 3745 | if (USES_WARPCORE(bp)) { |
| 3746 | aer_val = bnx2x_get_warpcore_lane(phy, params); |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 3747 | /* In Dual-lane mode, two lanes are joined together, |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 3748 | * so in order to configure them, the AER broadcast method is |
| 3749 | * used here. |
| 3750 | * 0x200 is the broadcast address for lanes 0,1 |
| 3751 | * 0x201 is the broadcast address for lanes 2,3 |
| 3752 | */ |
| 3753 | if (phy->flags & FLAGS_WC_DUAL_MODE) |
| 3754 | aer_val = (aer_val >> 1) | 0x200; |
| 3755 | } else if (CHIP_IS_E2(bp)) |
Yaniv Rosner | 82a0d47 | 2011-01-18 04:33:52 +0000 | [diff] [blame] | 3756 | aer_val = 0x3800 + offset - 1; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 3757 | else |
| 3758 | aer_val = 0x3800 + offset; |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 3759 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 3760 | CL22_WR_OVER_CL45(bp, phy, MDIO_REG_BANK_AER_BLOCK, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3761 | MDIO_AER_BLOCK_AER_REG, aer_val); |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 3762 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3763 | } |
| 3764 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3765 | /******************************************************************/ |
| 3766 | /* Internal phy section */ |
| 3767 | /******************************************************************/ |
| 3768 | |
| 3769 | static void bnx2x_set_serdes_access(struct bnx2x *bp, u8 port) |
| 3770 | { |
| 3771 | u32 emac_base = (port) ? GRCBASE_EMAC1 : GRCBASE_EMAC0; |
| 3772 | |
| 3773 | /* Set Clause 22 */ |
| 3774 | REG_WR(bp, NIG_REG_SERDES0_CTRL_MD_ST + port*0x10, 1); |
| 3775 | REG_WR(bp, emac_base + EMAC_REG_EMAC_MDIO_COMM, 0x245f8000); |
| 3776 | udelay(500); |
| 3777 | REG_WR(bp, emac_base + EMAC_REG_EMAC_MDIO_COMM, 0x245d000f); |
| 3778 | udelay(500); |
| 3779 | /* Set Clause 45 */ |
| 3780 | REG_WR(bp, NIG_REG_SERDES0_CTRL_MD_ST + port*0x10, 0); |
| 3781 | } |
| 3782 | |
| 3783 | static void bnx2x_serdes_deassert(struct bnx2x *bp, u8 port) |
| 3784 | { |
| 3785 | u32 val; |
| 3786 | |
| 3787 | DP(NETIF_MSG_LINK, "bnx2x_serdes_deassert\n"); |
| 3788 | |
| 3789 | val = SERDES_RESET_BITS << (port*16); |
| 3790 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 3791 | /* Reset and unreset the SerDes/XGXS */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3792 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_3_CLEAR, val); |
| 3793 | udelay(500); |
| 3794 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_3_SET, val); |
| 3795 | |
| 3796 | bnx2x_set_serdes_access(bp, port); |
| 3797 | |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3798 | REG_WR(bp, NIG_REG_SERDES0_CTRL_MD_DEVAD + port*0x10, |
| 3799 | DEFAULT_PHY_DEV_ADDR); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3800 | } |
| 3801 | |
| 3802 | static void bnx2x_xgxs_deassert(struct link_params *params) |
| 3803 | { |
| 3804 | struct bnx2x *bp = params->bp; |
| 3805 | u8 port; |
| 3806 | u32 val; |
| 3807 | DP(NETIF_MSG_LINK, "bnx2x_xgxs_deassert\n"); |
| 3808 | port = params->port; |
| 3809 | |
| 3810 | val = XGXS_RESET_BITS << (port*16); |
| 3811 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 3812 | /* Reset and unreset the SerDes/XGXS */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3813 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_3_CLEAR, val); |
| 3814 | udelay(500); |
| 3815 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_3_SET, val); |
| 3816 | |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3817 | REG_WR(bp, NIG_REG_XGXS0_CTRL_MD_ST + port*0x18, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3818 | REG_WR(bp, NIG_REG_XGXS0_CTRL_MD_DEVAD + port*0x18, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3819 | params->phy[INT_PHY].def_md_devad); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3820 | } |
| 3821 | |
Yaniv Rosner | 9045f6b4 | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 3822 | static void bnx2x_calc_ieee_aneg_adv(struct bnx2x_phy *phy, |
| 3823 | struct link_params *params, u16 *ieee_fc) |
| 3824 | { |
| 3825 | struct bnx2x *bp = params->bp; |
| 3826 | *ieee_fc = MDIO_COMBO_IEEE0_AUTO_NEG_ADV_FULL_DUPLEX; |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 3827 | /* Resolve pause mode and advertisement Please refer to Table |
Yaniv Rosner | 9045f6b4 | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 3828 | * 28B-3 of the 802.3ab-1999 spec |
| 3829 | */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3830 | |
Yaniv Rosner | 9045f6b4 | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 3831 | switch (phy->req_flow_ctrl) { |
| 3832 | case BNX2X_FLOW_CTRL_AUTO: |
| 3833 | if (params->req_fc_auto_adv == BNX2X_FLOW_CTRL_BOTH) |
| 3834 | *ieee_fc |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH; |
| 3835 | else |
| 3836 | *ieee_fc |= |
| 3837 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC; |
| 3838 | break; |
| 3839 | |
| 3840 | case BNX2X_FLOW_CTRL_TX: |
| 3841 | *ieee_fc |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC; |
| 3842 | break; |
| 3843 | |
| 3844 | case BNX2X_FLOW_CTRL_RX: |
| 3845 | case BNX2X_FLOW_CTRL_BOTH: |
| 3846 | *ieee_fc |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH; |
| 3847 | break; |
| 3848 | |
| 3849 | case BNX2X_FLOW_CTRL_NONE: |
| 3850 | default: |
| 3851 | *ieee_fc |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_NONE; |
| 3852 | break; |
| 3853 | } |
| 3854 | DP(NETIF_MSG_LINK, "ieee_fc = 0x%x\n", *ieee_fc); |
| 3855 | } |
| 3856 | |
| 3857 | static void set_phy_vars(struct link_params *params, |
| 3858 | struct link_vars *vars) |
| 3859 | { |
| 3860 | struct bnx2x *bp = params->bp; |
| 3861 | u8 actual_phy_idx, phy_index, link_cfg_idx; |
| 3862 | u8 phy_config_swapped = params->multi_phy_config & |
| 3863 | PORT_HW_CFG_PHY_SWAPPED_ENABLED; |
| 3864 | for (phy_index = INT_PHY; phy_index < params->num_phys; |
| 3865 | phy_index++) { |
| 3866 | link_cfg_idx = LINK_CONFIG_IDX(phy_index); |
| 3867 | actual_phy_idx = phy_index; |
| 3868 | if (phy_config_swapped) { |
| 3869 | if (phy_index == EXT_PHY1) |
| 3870 | actual_phy_idx = EXT_PHY2; |
| 3871 | else if (phy_index == EXT_PHY2) |
| 3872 | actual_phy_idx = EXT_PHY1; |
| 3873 | } |
| 3874 | params->phy[actual_phy_idx].req_flow_ctrl = |
| 3875 | params->req_flow_ctrl[link_cfg_idx]; |
| 3876 | |
| 3877 | params->phy[actual_phy_idx].req_line_speed = |
| 3878 | params->req_line_speed[link_cfg_idx]; |
| 3879 | |
| 3880 | params->phy[actual_phy_idx].speed_cap_mask = |
| 3881 | params->speed_cap_mask[link_cfg_idx]; |
| 3882 | |
| 3883 | params->phy[actual_phy_idx].req_duplex = |
| 3884 | params->req_duplex[link_cfg_idx]; |
| 3885 | |
| 3886 | if (params->req_line_speed[link_cfg_idx] == |
| 3887 | SPEED_AUTO_NEG) |
| 3888 | vars->link_status |= LINK_STATUS_AUTO_NEGOTIATE_ENABLED; |
| 3889 | |
| 3890 | DP(NETIF_MSG_LINK, "req_flow_ctrl %x, req_line_speed %x," |
| 3891 | " speed_cap_mask %x\n", |
| 3892 | params->phy[actual_phy_idx].req_flow_ctrl, |
| 3893 | params->phy[actual_phy_idx].req_line_speed, |
| 3894 | params->phy[actual_phy_idx].speed_cap_mask); |
| 3895 | } |
| 3896 | } |
| 3897 | |
| 3898 | static void bnx2x_ext_phy_set_pause(struct link_params *params, |
| 3899 | struct bnx2x_phy *phy, |
| 3900 | struct link_vars *vars) |
| 3901 | { |
| 3902 | u16 val; |
| 3903 | struct bnx2x *bp = params->bp; |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 3904 | /* Read modify write pause advertizing */ |
Yaniv Rosner | 9045f6b4 | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 3905 | bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_ADV_PAUSE, &val); |
| 3906 | |
| 3907 | val &= ~MDIO_AN_REG_ADV_PAUSE_BOTH; |
| 3908 | |
| 3909 | /* Please refer to Table 28B-3 of 802.3ab-1999 spec. */ |
| 3910 | bnx2x_calc_ieee_aneg_adv(phy, params, &vars->ieee_fc); |
| 3911 | if ((vars->ieee_fc & |
| 3912 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC) == |
| 3913 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC) { |
| 3914 | val |= MDIO_AN_REG_ADV_PAUSE_ASYMMETRIC; |
| 3915 | } |
| 3916 | if ((vars->ieee_fc & |
| 3917 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) == |
| 3918 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) { |
| 3919 | val |= MDIO_AN_REG_ADV_PAUSE_PAUSE; |
| 3920 | } |
| 3921 | DP(NETIF_MSG_LINK, "Ext phy AN advertize 0x%x\n", val); |
| 3922 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_ADV_PAUSE, val); |
| 3923 | } |
| 3924 | |
| 3925 | static void bnx2x_pause_resolve(struct link_vars *vars, u32 pause_result) |
| 3926 | { /* LD LP */ |
| 3927 | switch (pause_result) { /* ASYM P ASYM P */ |
| 3928 | case 0xb: /* 1 0 1 1 */ |
| 3929 | vars->flow_ctrl = BNX2X_FLOW_CTRL_TX; |
| 3930 | break; |
| 3931 | |
| 3932 | case 0xe: /* 1 1 1 0 */ |
| 3933 | vars->flow_ctrl = BNX2X_FLOW_CTRL_RX; |
| 3934 | break; |
| 3935 | |
| 3936 | case 0x5: /* 0 1 0 1 */ |
| 3937 | case 0x7: /* 0 1 1 1 */ |
| 3938 | case 0xd: /* 1 1 0 1 */ |
| 3939 | case 0xf: /* 1 1 1 1 */ |
| 3940 | vars->flow_ctrl = BNX2X_FLOW_CTRL_BOTH; |
| 3941 | break; |
| 3942 | |
| 3943 | default: |
| 3944 | break; |
| 3945 | } |
| 3946 | if (pause_result & (1<<0)) |
| 3947 | vars->link_status |= LINK_STATUS_LINK_PARTNER_SYMMETRIC_PAUSE; |
| 3948 | if (pause_result & (1<<1)) |
| 3949 | vars->link_status |= LINK_STATUS_LINK_PARTNER_ASYMMETRIC_PAUSE; |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 3950 | |
Yaniv Rosner | 9045f6b4 | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 3951 | } |
| 3952 | |
Mintz Yuval | 9e7e839 | 2012-02-15 02:10:24 +0000 | [diff] [blame] | 3953 | static void bnx2x_ext_phy_update_adv_fc(struct bnx2x_phy *phy, |
| 3954 | struct link_params *params, |
| 3955 | struct link_vars *vars) |
| 3956 | { |
| 3957 | u16 ld_pause; /* local */ |
| 3958 | u16 lp_pause; /* link partner */ |
| 3959 | u16 pause_result; |
| 3960 | struct bnx2x *bp = params->bp; |
| 3961 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54618SE) { |
| 3962 | bnx2x_cl22_read(bp, phy, 0x4, &ld_pause); |
| 3963 | bnx2x_cl22_read(bp, phy, 0x5, &lp_pause); |
Yaniv Rosner | ca05f29 | 2012-04-04 01:28:55 +0000 | [diff] [blame] | 3964 | } else if (CHIP_IS_E3(bp) && |
| 3965 | SINGLE_MEDIA_DIRECT(params)) { |
| 3966 | u8 lane = bnx2x_get_warpcore_lane(phy, params); |
| 3967 | u16 gp_status, gp_mask; |
| 3968 | bnx2x_cl45_read(bp, phy, |
| 3969 | MDIO_AN_DEVAD, MDIO_WC_REG_GP2_STATUS_GP_2_4, |
| 3970 | &gp_status); |
| 3971 | gp_mask = (MDIO_WC_REG_GP2_STATUS_GP_2_4_CL73_AN_CMPL | |
| 3972 | MDIO_WC_REG_GP2_STATUS_GP_2_4_CL37_LP_AN_CAP) << |
| 3973 | lane; |
| 3974 | if ((gp_status & gp_mask) == gp_mask) { |
| 3975 | bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD, |
| 3976 | MDIO_AN_REG_ADV_PAUSE, &ld_pause); |
| 3977 | bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD, |
| 3978 | MDIO_AN_REG_LP_AUTO_NEG, &lp_pause); |
| 3979 | } else { |
| 3980 | bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD, |
| 3981 | MDIO_AN_REG_CL37_FC_LD, &ld_pause); |
| 3982 | bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD, |
| 3983 | MDIO_AN_REG_CL37_FC_LP, &lp_pause); |
| 3984 | ld_pause = ((ld_pause & |
| 3985 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) |
| 3986 | << 3); |
| 3987 | lp_pause = ((lp_pause & |
| 3988 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) |
| 3989 | << 3); |
| 3990 | } |
Mintz Yuval | 9e7e839 | 2012-02-15 02:10:24 +0000 | [diff] [blame] | 3991 | } else { |
| 3992 | bnx2x_cl45_read(bp, phy, |
| 3993 | MDIO_AN_DEVAD, |
| 3994 | MDIO_AN_REG_ADV_PAUSE, &ld_pause); |
| 3995 | bnx2x_cl45_read(bp, phy, |
| 3996 | MDIO_AN_DEVAD, |
| 3997 | MDIO_AN_REG_LP_AUTO_NEG, &lp_pause); |
| 3998 | } |
| 3999 | pause_result = (ld_pause & |
| 4000 | MDIO_AN_REG_ADV_PAUSE_MASK) >> 8; |
| 4001 | pause_result |= (lp_pause & |
| 4002 | MDIO_AN_REG_ADV_PAUSE_MASK) >> 10; |
| 4003 | DP(NETIF_MSG_LINK, "Ext PHY pause result 0x%x\n", pause_result); |
| 4004 | bnx2x_pause_resolve(vars, pause_result); |
| 4005 | |
| 4006 | } |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 4007 | |
Yaniv Rosner | 9045f6b4 | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 4008 | static u8 bnx2x_ext_phy_resolve_fc(struct bnx2x_phy *phy, |
| 4009 | struct link_params *params, |
| 4010 | struct link_vars *vars) |
| 4011 | { |
Yaniv Rosner | 9045f6b4 | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 4012 | u8 ret = 0; |
Yaniv Rosner | 9045f6b4 | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 4013 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
Mintz Yuval | 9e7e839 | 2012-02-15 02:10:24 +0000 | [diff] [blame] | 4014 | if (phy->req_flow_ctrl != BNX2X_FLOW_CTRL_AUTO) { |
| 4015 | /* Update the advertised flow-controled of LD/LP in AN */ |
| 4016 | if (phy->req_line_speed == SPEED_AUTO_NEG) |
| 4017 | bnx2x_ext_phy_update_adv_fc(phy, params, vars); |
| 4018 | /* But set the flow-control result as the requested one */ |
Yaniv Rosner | 9045f6b4 | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 4019 | vars->flow_ctrl = phy->req_flow_ctrl; |
Mintz Yuval | 9e7e839 | 2012-02-15 02:10:24 +0000 | [diff] [blame] | 4020 | } else if (phy->req_line_speed != SPEED_AUTO_NEG) |
Yaniv Rosner | 9045f6b4 | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 4021 | vars->flow_ctrl = params->req_fc_auto_adv; |
| 4022 | else if (vars->link_status & LINK_STATUS_AUTO_NEGOTIATE_COMPLETE) { |
| 4023 | ret = 1; |
Mintz Yuval | 9e7e839 | 2012-02-15 02:10:24 +0000 | [diff] [blame] | 4024 | bnx2x_ext_phy_update_adv_fc(phy, params, vars); |
Yaniv Rosner | 9045f6b4 | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 4025 | } |
| 4026 | return ret; |
| 4027 | } |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4028 | /******************************************************************/ |
| 4029 | /* Warpcore section */ |
| 4030 | /******************************************************************/ |
| 4031 | /* The init_internal_warpcore should mirror the xgxs, |
| 4032 | * i.e. reset the lane (if needed), set aer for the |
| 4033 | * init configuration, and set/clear SGMII flag. Internal |
| 4034 | * phy init is done purely in phy_init stage. |
| 4035 | */ |
Yuval Mintz | ec4010e | 2012-09-10 05:51:06 +0000 | [diff] [blame] | 4036 | |
| 4037 | static void bnx2x_warpcore_set_lpi_passthrough(struct bnx2x_phy *phy, |
| 4038 | struct link_params *params) |
| 4039 | { |
| 4040 | struct bnx2x *bp = params->bp; |
| 4041 | |
| 4042 | DP(NETIF_MSG_LINK, "Configure WC for LPI pass through\n"); |
| 4043 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4044 | MDIO_WC_REG_EEE_COMBO_CONTROL0, 0x7c); |
| 4045 | bnx2x_cl45_read_or_write(bp, phy, MDIO_WC_DEVAD, |
| 4046 | MDIO_WC_REG_DIGITAL4_MISC5, 0xc000); |
| 4047 | } |
| 4048 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4049 | static void bnx2x_warpcore_enable_AN_KR(struct bnx2x_phy *phy, |
| 4050 | struct link_params *params, |
| 4051 | struct link_vars *vars) { |
Yuval Mintz | a351d49 | 2012-06-20 19:05:21 +0000 | [diff] [blame] | 4052 | u16 val16 = 0, lane, i; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4053 | struct bnx2x *bp = params->bp; |
Yuval Mintz | a351d49 | 2012-06-20 19:05:21 +0000 | [diff] [blame] | 4054 | static struct bnx2x_reg_set reg_set[] = { |
| 4055 | {MDIO_WC_DEVAD, MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2, 0x7}, |
| 4056 | {MDIO_AN_DEVAD, MDIO_WC_REG_PAR_DET_10G_CTRL, 0}, |
| 4057 | {MDIO_WC_DEVAD, MDIO_WC_REG_CL72_USERB0_CL72_MISC1_CONTROL, 0}, |
| 4058 | {MDIO_WC_DEVAD, MDIO_WC_REG_XGXSBLK1_LANECTRL0, 0xff}, |
| 4059 | {MDIO_WC_DEVAD, MDIO_WC_REG_XGXSBLK1_LANECTRL1, 0x5555}, |
| 4060 | {MDIO_PMA_DEVAD, MDIO_WC_REG_IEEE0BLK_AUTONEGNP, 0x0}, |
| 4061 | {MDIO_WC_DEVAD, MDIO_WC_REG_RX66_CONTROL, 0x7415}, |
| 4062 | {MDIO_WC_DEVAD, MDIO_WC_REG_SERDESDIGITAL_MISC2, 0x6190}, |
| 4063 | /* Disable Autoneg: re-enable it after adv is done. */ |
| 4064 | {MDIO_AN_DEVAD, MDIO_WC_REG_IEEE0BLK_MIICNTL, 0} |
| 4065 | }; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4066 | DP(NETIF_MSG_LINK, "Enable Auto Negotiation for KR\n"); |
Yaniv Rosner | 6a51c0d | 2012-04-04 01:28:56 +0000 | [diff] [blame] | 4067 | /* Set to default registers that may be overriden by 10G force */ |
Yuval Mintz | a351d49 | 2012-06-20 19:05:21 +0000 | [diff] [blame] | 4068 | for (i = 0; i < sizeof(reg_set)/sizeof(struct bnx2x_reg_set); i++) |
| 4069 | bnx2x_cl45_write(bp, phy, reg_set[i].devad, reg_set[i].reg, |
| 4070 | reg_set[i].val); |
Yaniv Rosner | a9077bf | 2011-10-27 05:09:46 +0000 | [diff] [blame] | 4071 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4072 | /* Check adding advertisement for 1G KX */ |
| 4073 | if (((vars->line_speed == SPEED_AUTO_NEG) && |
| 4074 | (phy->speed_cap_mask & PORT_HW_CFG_SPEED_CAPABILITY_D0_1G)) || |
| 4075 | (vars->line_speed == SPEED_1000)) { |
Yuval Mintz | a351d49 | 2012-06-20 19:05:21 +0000 | [diff] [blame] | 4076 | u32 addr = MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4077 | val16 |= (1<<5); |
| 4078 | |
| 4079 | /* Enable CL37 1G Parallel Detect */ |
Yuval Mintz | a351d49 | 2012-06-20 19:05:21 +0000 | [diff] [blame] | 4080 | bnx2x_cl45_read_or_write(bp, phy, MDIO_WC_DEVAD, addr, 0x1); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4081 | DP(NETIF_MSG_LINK, "Advertize 1G\n"); |
| 4082 | } |
| 4083 | if (((vars->line_speed == SPEED_AUTO_NEG) && |
| 4084 | (phy->speed_cap_mask & PORT_HW_CFG_SPEED_CAPABILITY_D0_10G)) || |
| 4085 | (vars->line_speed == SPEED_10000)) { |
| 4086 | /* Check adding advertisement for 10G KR */ |
| 4087 | val16 |= (1<<7); |
| 4088 | /* Enable 10G Parallel Detect */ |
| 4089 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, |
Yuval Mintz | a351d49 | 2012-06-20 19:05:21 +0000 | [diff] [blame] | 4090 | MDIO_WC_REG_PAR_DET_10G_CTRL, 1); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4091 | |
| 4092 | DP(NETIF_MSG_LINK, "Advertize 10G\n"); |
| 4093 | } |
| 4094 | |
| 4095 | /* Set Transmit PMD settings */ |
| 4096 | lane = bnx2x_get_warpcore_lane(phy, params); |
| 4097 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4098 | MDIO_WC_REG_TX0_TX_DRIVER + 0x10*lane, |
| 4099 | ((0x02 << MDIO_WC_REG_TX0_TX_DRIVER_POST2_COEFF_OFFSET) | |
| 4100 | (0x06 << MDIO_WC_REG_TX0_TX_DRIVER_IDRIVER_OFFSET) | |
| 4101 | (0x09 << MDIO_WC_REG_TX0_TX_DRIVER_IPRE_DRIVER_OFFSET))); |
| 4102 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4103 | MDIO_WC_REG_CL72_USERB0_CL72_OS_DEF_CTRL, |
| 4104 | 0x03f0); |
| 4105 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4106 | MDIO_WC_REG_CL72_USERB0_CL72_2P5_DEF_CTRL, |
| 4107 | 0x03f0); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4108 | |
| 4109 | /* Advertised speeds */ |
| 4110 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, |
| 4111 | MDIO_WC_REG_AN_IEEE1BLK_AN_ADVERTISEMENT1, val16); |
| 4112 | |
David S. Miller | 8decf86 | 2011-09-22 03:23:13 -0400 | [diff] [blame] | 4113 | /* Advertised and set FEC (Forward Error Correction) */ |
| 4114 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, |
| 4115 | MDIO_WC_REG_AN_IEEE1BLK_AN_ADVERTISEMENT2, |
| 4116 | (MDIO_WC_REG_AN_IEEE1BLK_AN_ADV2_FEC_ABILITY | |
| 4117 | MDIO_WC_REG_AN_IEEE1BLK_AN_ADV2_FEC_REQ)); |
| 4118 | |
Yaniv Rosner | a34bc96 | 2011-07-05 01:06:41 +0000 | [diff] [blame] | 4119 | /* Enable CL37 BAM */ |
| 4120 | if (REG_RD(bp, params->shmem_base + |
| 4121 | offsetof(struct shmem_region, dev_info. |
| 4122 | port_hw_config[params->port].default_cfg)) & |
| 4123 | PORT_HW_CFG_ENABLE_BAM_ON_KR_ENABLED) { |
Yuval Mintz | a351d49 | 2012-06-20 19:05:21 +0000 | [diff] [blame] | 4124 | bnx2x_cl45_read_or_write(bp, phy, MDIO_WC_DEVAD, |
| 4125 | MDIO_WC_REG_DIGITAL6_MP5_NEXTPAGECTRL, |
| 4126 | 1); |
Yaniv Rosner | a34bc96 | 2011-07-05 01:06:41 +0000 | [diff] [blame] | 4127 | DP(NETIF_MSG_LINK, "Enable CL37 BAM on KR\n"); |
| 4128 | } |
| 4129 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4130 | /* Advertise pause */ |
| 4131 | bnx2x_ext_phy_set_pause(params, phy, vars); |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 4132 | /* Set KR Autoneg Work-Around flag for Warpcore version older than D108 |
Yaniv Rosner | 6ab48a5 | 2012-01-17 02:33:29 +0000 | [diff] [blame] | 4133 | */ |
| 4134 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4135 | MDIO_WC_REG_UC_INFO_B1_VERSION, &val16); |
| 4136 | if (val16 < 0xd108) { |
| 4137 | DP(NETIF_MSG_LINK, "Enable AN KR work-around\n"); |
| 4138 | vars->rx_tx_asic_rst = MAX_KR_LINK_RETRY; |
| 4139 | } |
Yuval Mintz | a351d49 | 2012-06-20 19:05:21 +0000 | [diff] [blame] | 4140 | bnx2x_cl45_read_or_write(bp, phy, MDIO_WC_DEVAD, |
| 4141 | MDIO_WC_REG_DIGITAL5_MISC7, 0x100); |
Yaniv Rosner | a9077bf | 2011-10-27 05:09:46 +0000 | [diff] [blame] | 4142 | |
| 4143 | /* Over 1G - AN local device user page 1 */ |
| 4144 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4145 | MDIO_WC_REG_DIGITAL3_UP1, 0x1f); |
| 4146 | |
| 4147 | /* Enable Autoneg */ |
| 4148 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, |
Mintz Yuval | 1b85ae5 | 2012-02-15 02:10:25 +0000 | [diff] [blame] | 4149 | MDIO_WC_REG_IEEE0BLK_MIICNTL, 0x1200); |
Yaniv Rosner | a9077bf | 2011-10-27 05:09:46 +0000 | [diff] [blame] | 4150 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4151 | } |
| 4152 | |
| 4153 | static void bnx2x_warpcore_set_10G_KR(struct bnx2x_phy *phy, |
| 4154 | struct link_params *params, |
| 4155 | struct link_vars *vars) |
| 4156 | { |
| 4157 | struct bnx2x *bp = params->bp; |
Yuval Mintz | a351d49 | 2012-06-20 19:05:21 +0000 | [diff] [blame] | 4158 | u16 i; |
| 4159 | static struct bnx2x_reg_set reg_set[] = { |
| 4160 | /* Disable Autoneg */ |
| 4161 | {MDIO_WC_DEVAD, MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2, 0x7}, |
| 4162 | {MDIO_AN_DEVAD, MDIO_WC_REG_PAR_DET_10G_CTRL, 0}, |
| 4163 | {MDIO_WC_DEVAD, MDIO_WC_REG_CL72_USERB0_CL72_MISC1_CONTROL, |
| 4164 | 0x3f00}, |
| 4165 | {MDIO_AN_DEVAD, MDIO_WC_REG_AN_IEEE1BLK_AN_ADVERTISEMENT1, 0}, |
| 4166 | {MDIO_AN_DEVAD, MDIO_WC_REG_IEEE0BLK_MIICNTL, 0x0}, |
| 4167 | {MDIO_WC_DEVAD, MDIO_WC_REG_DIGITAL3_UP1, 0x1}, |
| 4168 | {MDIO_WC_DEVAD, MDIO_WC_REG_DIGITAL5_MISC7, 0xa}, |
| 4169 | /* Disable CL36 PCS Tx */ |
| 4170 | {MDIO_WC_DEVAD, MDIO_WC_REG_XGXSBLK1_LANECTRL0, 0x0}, |
| 4171 | /* Double Wide Single Data Rate @ pll rate */ |
| 4172 | {MDIO_WC_DEVAD, MDIO_WC_REG_XGXSBLK1_LANECTRL1, 0xFFFF}, |
| 4173 | /* Leave cl72 training enable, needed for KR */ |
| 4174 | {MDIO_PMA_DEVAD, |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4175 | MDIO_WC_REG_PMD_IEEE9BLK_TENGBASE_KR_PMD_CONTROL_REGISTER_150, |
Yuval Mintz | a351d49 | 2012-06-20 19:05:21 +0000 | [diff] [blame] | 4176 | 0x2} |
| 4177 | }; |
| 4178 | |
| 4179 | for (i = 0; i < sizeof(reg_set)/sizeof(struct bnx2x_reg_set); i++) |
| 4180 | bnx2x_cl45_write(bp, phy, reg_set[i].devad, reg_set[i].reg, |
| 4181 | reg_set[i].val); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4182 | |
| 4183 | /* Leave CL72 enabled */ |
Yuval Mintz | a351d49 | 2012-06-20 19:05:21 +0000 | [diff] [blame] | 4184 | bnx2x_cl45_read_or_write(bp, phy, MDIO_WC_DEVAD, |
| 4185 | MDIO_WC_REG_CL72_USERB0_CL72_MISC1_CONTROL, |
| 4186 | 0x3800); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4187 | |
| 4188 | /* Set speed via PMA/PMD register */ |
| 4189 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, |
| 4190 | MDIO_WC_REG_IEEE0BLK_MIICNTL, 0x2040); |
| 4191 | |
| 4192 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, |
| 4193 | MDIO_WC_REG_IEEE0BLK_AUTONEGNP, 0xB); |
| 4194 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 4195 | /* Enable encoded forced speed */ |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4196 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4197 | MDIO_WC_REG_SERDESDIGITAL_MISC2, 0x30); |
| 4198 | |
| 4199 | /* Turn TX scramble payload only the 64/66 scrambler */ |
| 4200 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4201 | MDIO_WC_REG_TX66_CONTROL, 0x9); |
| 4202 | |
| 4203 | /* Turn RX scramble payload only the 64/66 scrambler */ |
| 4204 | bnx2x_cl45_read_or_write(bp, phy, MDIO_WC_DEVAD, |
| 4205 | MDIO_WC_REG_RX66_CONTROL, 0xF9); |
| 4206 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 4207 | /* Set and clear loopback to cause a reset to 64/66 decoder */ |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4208 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4209 | MDIO_WC_REG_IEEE0BLK_MIICNTL, 0x4000); |
| 4210 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4211 | MDIO_WC_REG_IEEE0BLK_MIICNTL, 0x0); |
| 4212 | |
| 4213 | } |
| 4214 | |
| 4215 | static void bnx2x_warpcore_set_10G_XFI(struct bnx2x_phy *phy, |
| 4216 | struct link_params *params, |
| 4217 | u8 is_xfi) |
| 4218 | { |
| 4219 | struct bnx2x *bp = params->bp; |
| 4220 | u16 misc1_val, tap_val, tx_driver_val, lane, val; |
| 4221 | /* Hold rxSeqStart */ |
Yuval Mintz | a351d49 | 2012-06-20 19:05:21 +0000 | [diff] [blame] | 4222 | bnx2x_cl45_read_or_write(bp, phy, MDIO_WC_DEVAD, |
| 4223 | MDIO_WC_REG_DSC2B0_DSC_MISC_CTRL0, 0x8000); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4224 | |
| 4225 | /* Hold tx_fifo_reset */ |
Yuval Mintz | a351d49 | 2012-06-20 19:05:21 +0000 | [diff] [blame] | 4226 | bnx2x_cl45_read_or_write(bp, phy, MDIO_WC_DEVAD, |
| 4227 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X3, 0x1); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4228 | |
| 4229 | /* Disable CL73 AN */ |
| 4230 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, 0); |
| 4231 | |
| 4232 | /* Disable 100FX Enable and Auto-Detect */ |
| 4233 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4234 | MDIO_WC_REG_FX100_CTRL1, &val); |
| 4235 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4236 | MDIO_WC_REG_FX100_CTRL1, (val & 0xFFFA)); |
| 4237 | |
| 4238 | /* Disable 100FX Idle detect */ |
Yuval Mintz | a351d49 | 2012-06-20 19:05:21 +0000 | [diff] [blame] | 4239 | bnx2x_cl45_read_or_write(bp, phy, MDIO_WC_DEVAD, |
| 4240 | MDIO_WC_REG_FX100_CTRL3, 0x0080); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4241 | |
| 4242 | /* Set Block address to Remote PHY & Clear forced_speed[5] */ |
| 4243 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4244 | MDIO_WC_REG_DIGITAL4_MISC3, &val); |
| 4245 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4246 | MDIO_WC_REG_DIGITAL4_MISC3, (val & 0xFF7F)); |
| 4247 | |
| 4248 | /* Turn off auto-detect & fiber mode */ |
| 4249 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4250 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X1, &val); |
| 4251 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4252 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X1, |
| 4253 | (val & 0xFFEE)); |
| 4254 | |
| 4255 | /* Set filter_force_link, disable_false_link and parallel_detect */ |
| 4256 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4257 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2, &val); |
| 4258 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4259 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2, |
| 4260 | ((val | 0x0006) & 0xFFFE)); |
| 4261 | |
| 4262 | /* Set XFI / SFI */ |
| 4263 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4264 | MDIO_WC_REG_SERDESDIGITAL_MISC1, &misc1_val); |
| 4265 | |
| 4266 | misc1_val &= ~(0x1f); |
| 4267 | |
| 4268 | if (is_xfi) { |
| 4269 | misc1_val |= 0x5; |
| 4270 | tap_val = ((0x08 << MDIO_WC_REG_TX_FIR_TAP_POST_TAP_OFFSET) | |
| 4271 | (0x37 << MDIO_WC_REG_TX_FIR_TAP_MAIN_TAP_OFFSET) | |
| 4272 | (0x00 << MDIO_WC_REG_TX_FIR_TAP_PRE_TAP_OFFSET)); |
| 4273 | tx_driver_val = |
| 4274 | ((0x00 << MDIO_WC_REG_TX0_TX_DRIVER_POST2_COEFF_OFFSET) | |
| 4275 | (0x02 << MDIO_WC_REG_TX0_TX_DRIVER_IDRIVER_OFFSET) | |
| 4276 | (0x03 << MDIO_WC_REG_TX0_TX_DRIVER_IPRE_DRIVER_OFFSET)); |
| 4277 | |
| 4278 | } else { |
| 4279 | misc1_val |= 0x9; |
Yaniv Rosner | 25182fc | 2012-04-04 01:28:57 +0000 | [diff] [blame] | 4280 | tap_val = ((0x0f << MDIO_WC_REG_TX_FIR_TAP_POST_TAP_OFFSET) | |
| 4281 | (0x2b << MDIO_WC_REG_TX_FIR_TAP_MAIN_TAP_OFFSET) | |
| 4282 | (0x02 << MDIO_WC_REG_TX_FIR_TAP_PRE_TAP_OFFSET)); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4283 | tx_driver_val = |
Yaniv Rosner | 25182fc | 2012-04-04 01:28:57 +0000 | [diff] [blame] | 4284 | ((0x03 << MDIO_WC_REG_TX0_TX_DRIVER_POST2_COEFF_OFFSET) | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4285 | (0x02 << MDIO_WC_REG_TX0_TX_DRIVER_IDRIVER_OFFSET) | |
Yaniv Rosner | 25182fc | 2012-04-04 01:28:57 +0000 | [diff] [blame] | 4286 | (0x06 << MDIO_WC_REG_TX0_TX_DRIVER_IPRE_DRIVER_OFFSET)); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4287 | } |
| 4288 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4289 | MDIO_WC_REG_SERDESDIGITAL_MISC1, misc1_val); |
| 4290 | |
| 4291 | /* Set Transmit PMD settings */ |
| 4292 | lane = bnx2x_get_warpcore_lane(phy, params); |
| 4293 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4294 | MDIO_WC_REG_TX_FIR_TAP, |
| 4295 | tap_val | MDIO_WC_REG_TX_FIR_TAP_ENABLE); |
| 4296 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4297 | MDIO_WC_REG_TX0_TX_DRIVER + 0x10*lane, |
| 4298 | tx_driver_val); |
| 4299 | |
| 4300 | /* Enable fiber mode, enable and invert sig_det */ |
Yuval Mintz | a351d49 | 2012-06-20 19:05:21 +0000 | [diff] [blame] | 4301 | bnx2x_cl45_read_or_write(bp, phy, MDIO_WC_DEVAD, |
| 4302 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X1, 0xd); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4303 | |
| 4304 | /* Set Block address to Remote PHY & Set forced_speed[5], 40bit mode */ |
Yuval Mintz | a351d49 | 2012-06-20 19:05:21 +0000 | [diff] [blame] | 4305 | bnx2x_cl45_read_or_write(bp, phy, MDIO_WC_DEVAD, |
| 4306 | MDIO_WC_REG_DIGITAL4_MISC3, 0x8080); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4307 | |
Yuval Mintz | ec4010e | 2012-09-10 05:51:06 +0000 | [diff] [blame] | 4308 | bnx2x_warpcore_set_lpi_passthrough(phy, params); |
Yuval Mintz | c8c60d8 | 2012-06-06 17:13:07 +0000 | [diff] [blame] | 4309 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4310 | /* 10G XFI Full Duplex */ |
| 4311 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4312 | MDIO_WC_REG_IEEE0BLK_MIICNTL, 0x100); |
| 4313 | |
| 4314 | /* Release tx_fifo_reset */ |
| 4315 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4316 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X3, &val); |
| 4317 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4318 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X3, val & 0xFFFE); |
| 4319 | |
| 4320 | /* Release rxSeqStart */ |
| 4321 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4322 | MDIO_WC_REG_DSC2B0_DSC_MISC_CTRL0, &val); |
| 4323 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4324 | MDIO_WC_REG_DSC2B0_DSC_MISC_CTRL0, (val & 0x7FFF)); |
| 4325 | } |
| 4326 | |
| 4327 | static void bnx2x_warpcore_set_20G_KR2(struct bnx2x *bp, |
| 4328 | struct bnx2x_phy *phy) |
| 4329 | { |
| 4330 | DP(NETIF_MSG_LINK, "KR2 still not supported !!!\n"); |
| 4331 | } |
| 4332 | |
| 4333 | static void bnx2x_warpcore_set_20G_DXGXS(struct bnx2x *bp, |
| 4334 | struct bnx2x_phy *phy, |
| 4335 | u16 lane) |
| 4336 | { |
| 4337 | /* Rx0 anaRxControl1G */ |
| 4338 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4339 | MDIO_WC_REG_RX0_ANARXCONTROL1G, 0x90); |
| 4340 | |
| 4341 | /* Rx2 anaRxControl1G */ |
| 4342 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4343 | MDIO_WC_REG_RX2_ANARXCONTROL1G, 0x90); |
| 4344 | |
| 4345 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4346 | MDIO_WC_REG_RX66_SCW0, 0xE070); |
| 4347 | |
| 4348 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4349 | MDIO_WC_REG_RX66_SCW1, 0xC0D0); |
| 4350 | |
| 4351 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4352 | MDIO_WC_REG_RX66_SCW2, 0xA0B0); |
| 4353 | |
| 4354 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4355 | MDIO_WC_REG_RX66_SCW3, 0x8090); |
| 4356 | |
| 4357 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4358 | MDIO_WC_REG_RX66_SCW0_MASK, 0xF0F0); |
| 4359 | |
| 4360 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4361 | MDIO_WC_REG_RX66_SCW1_MASK, 0xF0F0); |
| 4362 | |
| 4363 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4364 | MDIO_WC_REG_RX66_SCW2_MASK, 0xF0F0); |
| 4365 | |
| 4366 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4367 | MDIO_WC_REG_RX66_SCW3_MASK, 0xF0F0); |
| 4368 | |
| 4369 | /* Serdes Digital Misc1 */ |
| 4370 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4371 | MDIO_WC_REG_SERDESDIGITAL_MISC1, 0x6008); |
| 4372 | |
| 4373 | /* Serdes Digital4 Misc3 */ |
| 4374 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4375 | MDIO_WC_REG_DIGITAL4_MISC3, 0x8088); |
| 4376 | |
| 4377 | /* Set Transmit PMD settings */ |
| 4378 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4379 | MDIO_WC_REG_TX_FIR_TAP, |
| 4380 | ((0x12 << MDIO_WC_REG_TX_FIR_TAP_POST_TAP_OFFSET) | |
| 4381 | (0x2d << MDIO_WC_REG_TX_FIR_TAP_MAIN_TAP_OFFSET) | |
| 4382 | (0x00 << MDIO_WC_REG_TX_FIR_TAP_PRE_TAP_OFFSET) | |
| 4383 | MDIO_WC_REG_TX_FIR_TAP_ENABLE)); |
| 4384 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4385 | MDIO_WC_REG_TX0_TX_DRIVER + 0x10*lane, |
| 4386 | ((0x02 << MDIO_WC_REG_TX0_TX_DRIVER_POST2_COEFF_OFFSET) | |
| 4387 | (0x02 << MDIO_WC_REG_TX0_TX_DRIVER_IDRIVER_OFFSET) | |
| 4388 | (0x02 << MDIO_WC_REG_TX0_TX_DRIVER_IPRE_DRIVER_OFFSET))); |
| 4389 | } |
| 4390 | |
| 4391 | static void bnx2x_warpcore_set_sgmii_speed(struct bnx2x_phy *phy, |
| 4392 | struct link_params *params, |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 4393 | u8 fiber_mode, |
| 4394 | u8 always_autoneg) |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4395 | { |
| 4396 | struct bnx2x *bp = params->bp; |
| 4397 | u16 val16, digctrl_kx1, digctrl_kx2; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4398 | |
| 4399 | /* Clear XFI clock comp in non-10G single lane mode. */ |
| 4400 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4401 | MDIO_WC_REG_RX66_CONTROL, &val16); |
| 4402 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4403 | MDIO_WC_REG_RX66_CONTROL, val16 & ~(3<<13)); |
| 4404 | |
Yuval Mintz | 26964bb | 2012-09-10 05:51:08 +0000 | [diff] [blame] | 4405 | bnx2x_warpcore_set_lpi_passthrough(phy, params); |
| 4406 | |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 4407 | if (always_autoneg || phy->req_line_speed == SPEED_AUTO_NEG) { |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4408 | /* SGMII Autoneg */ |
| 4409 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4410 | MDIO_WC_REG_COMBO_IEEE0_MIICTRL, &val16); |
| 4411 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4412 | MDIO_WC_REG_COMBO_IEEE0_MIICTRL, |
| 4413 | val16 | 0x1000); |
| 4414 | DP(NETIF_MSG_LINK, "set SGMII AUTONEG\n"); |
| 4415 | } else { |
| 4416 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4417 | MDIO_WC_REG_COMBO_IEEE0_MIICTRL, &val16); |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 4418 | val16 &= 0xcebf; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4419 | switch (phy->req_line_speed) { |
| 4420 | case SPEED_10: |
| 4421 | break; |
| 4422 | case SPEED_100: |
| 4423 | val16 |= 0x2000; |
| 4424 | break; |
| 4425 | case SPEED_1000: |
| 4426 | val16 |= 0x0040; |
| 4427 | break; |
| 4428 | default: |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 4429 | DP(NETIF_MSG_LINK, |
| 4430 | "Speed not supported: 0x%x\n", phy->req_line_speed); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4431 | return; |
| 4432 | } |
| 4433 | |
| 4434 | if (phy->req_duplex == DUPLEX_FULL) |
| 4435 | val16 |= 0x0100; |
| 4436 | |
| 4437 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4438 | MDIO_WC_REG_COMBO_IEEE0_MIICTRL, val16); |
| 4439 | |
| 4440 | DP(NETIF_MSG_LINK, "set SGMII force speed %d\n", |
| 4441 | phy->req_line_speed); |
| 4442 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4443 | MDIO_WC_REG_COMBO_IEEE0_MIICTRL, &val16); |
| 4444 | DP(NETIF_MSG_LINK, " (readback) %x\n", val16); |
| 4445 | } |
| 4446 | |
| 4447 | /* SGMII Slave mode and disable signal detect */ |
| 4448 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4449 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X1, &digctrl_kx1); |
| 4450 | if (fiber_mode) |
| 4451 | digctrl_kx1 = 1; |
| 4452 | else |
| 4453 | digctrl_kx1 &= 0xff4a; |
| 4454 | |
| 4455 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4456 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X1, |
| 4457 | digctrl_kx1); |
| 4458 | |
| 4459 | /* Turn off parallel detect */ |
| 4460 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4461 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2, &digctrl_kx2); |
| 4462 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4463 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2, |
| 4464 | (digctrl_kx2 & ~(1<<2))); |
| 4465 | |
| 4466 | /* Re-enable parallel detect */ |
| 4467 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4468 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2, |
| 4469 | (digctrl_kx2 | (1<<2))); |
| 4470 | |
| 4471 | /* Enable autodet */ |
| 4472 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4473 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X1, |
| 4474 | (digctrl_kx1 | 0x10)); |
| 4475 | } |
| 4476 | |
| 4477 | static void bnx2x_warpcore_reset_lane(struct bnx2x *bp, |
| 4478 | struct bnx2x_phy *phy, |
| 4479 | u8 reset) |
| 4480 | { |
| 4481 | u16 val; |
| 4482 | /* Take lane out of reset after configuration is finished */ |
| 4483 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4484 | MDIO_WC_REG_DIGITAL5_MISC6, &val); |
| 4485 | if (reset) |
| 4486 | val |= 0xC000; |
| 4487 | else |
| 4488 | val &= 0x3FFF; |
| 4489 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4490 | MDIO_WC_REG_DIGITAL5_MISC6, val); |
| 4491 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4492 | MDIO_WC_REG_DIGITAL5_MISC6, &val); |
| 4493 | } |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 4494 | /* Clear SFI/XFI link settings registers */ |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4495 | static void bnx2x_warpcore_clear_regs(struct bnx2x_phy *phy, |
| 4496 | struct link_params *params, |
| 4497 | u16 lane) |
| 4498 | { |
| 4499 | struct bnx2x *bp = params->bp; |
Yuval Mintz | a351d49 | 2012-06-20 19:05:21 +0000 | [diff] [blame] | 4500 | u16 i; |
| 4501 | static struct bnx2x_reg_set wc_regs[] = { |
| 4502 | {MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, 0}, |
| 4503 | {MDIO_WC_DEVAD, MDIO_WC_REG_FX100_CTRL1, 0x014a}, |
| 4504 | {MDIO_WC_DEVAD, MDIO_WC_REG_FX100_CTRL3, 0x0800}, |
| 4505 | {MDIO_WC_DEVAD, MDIO_WC_REG_DIGITAL4_MISC3, 0x8008}, |
| 4506 | {MDIO_WC_DEVAD, MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X1, |
| 4507 | 0x0195}, |
| 4508 | {MDIO_WC_DEVAD, MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2, |
| 4509 | 0x0007}, |
| 4510 | {MDIO_WC_DEVAD, MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X3, |
| 4511 | 0x0002}, |
| 4512 | {MDIO_WC_DEVAD, MDIO_WC_REG_SERDESDIGITAL_MISC1, 0x6000}, |
| 4513 | {MDIO_WC_DEVAD, MDIO_WC_REG_TX_FIR_TAP, 0x0000}, |
| 4514 | {MDIO_WC_DEVAD, MDIO_WC_REG_IEEE0BLK_MIICNTL, 0x2040}, |
| 4515 | {MDIO_WC_DEVAD, MDIO_WC_REG_COMBO_IEEE0_MIICTRL, 0x0140} |
| 4516 | }; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4517 | /* Set XFI clock comp as default. */ |
Yuval Mintz | a351d49 | 2012-06-20 19:05:21 +0000 | [diff] [blame] | 4518 | bnx2x_cl45_read_or_write(bp, phy, MDIO_WC_DEVAD, |
| 4519 | MDIO_WC_REG_RX66_CONTROL, (3<<13)); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4520 | |
Yuval Mintz | a351d49 | 2012-06-20 19:05:21 +0000 | [diff] [blame] | 4521 | for (i = 0; i < sizeof(wc_regs)/sizeof(struct bnx2x_reg_set); i++) |
| 4522 | bnx2x_cl45_write(bp, phy, wc_regs[i].devad, wc_regs[i].reg, |
| 4523 | wc_regs[i].val); |
| 4524 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4525 | lane = bnx2x_get_warpcore_lane(phy, params); |
| 4526 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4527 | MDIO_WC_REG_TX0_TX_DRIVER + 0x10*lane, 0x0990); |
Yuval Mintz | a351d49 | 2012-06-20 19:05:21 +0000 | [diff] [blame] | 4528 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4529 | } |
| 4530 | |
| 4531 | static int bnx2x_get_mod_abs_int_cfg(struct bnx2x *bp, |
| 4532 | u32 chip_id, |
| 4533 | u32 shmem_base, u8 port, |
| 4534 | u8 *gpio_num, u8 *gpio_port) |
| 4535 | { |
| 4536 | u32 cfg_pin; |
| 4537 | *gpio_num = 0; |
| 4538 | *gpio_port = 0; |
| 4539 | if (CHIP_IS_E3(bp)) { |
| 4540 | cfg_pin = (REG_RD(bp, shmem_base + |
| 4541 | offsetof(struct shmem_region, |
| 4542 | dev_info.port_hw_config[port].e3_sfp_ctrl)) & |
| 4543 | PORT_HW_CFG_E3_MOD_ABS_MASK) >> |
| 4544 | PORT_HW_CFG_E3_MOD_ABS_SHIFT; |
| 4545 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 4546 | /* Should not happen. This function called upon interrupt |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4547 | * triggered by GPIO ( since EPIO can only generate interrupts |
| 4548 | * to MCP). |
| 4549 | * So if this function was called and none of the GPIOs was set, |
| 4550 | * it means the shit hit the fan. |
| 4551 | */ |
| 4552 | if ((cfg_pin < PIN_CFG_GPIO0_P0) || |
| 4553 | (cfg_pin > PIN_CFG_GPIO3_P1)) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 4554 | DP(NETIF_MSG_LINK, |
| 4555 | "ERROR: Invalid cfg pin %x for module detect indication\n", |
| 4556 | cfg_pin); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4557 | return -EINVAL; |
| 4558 | } |
| 4559 | |
| 4560 | *gpio_num = (cfg_pin - PIN_CFG_GPIO0_P0) & 0x3; |
| 4561 | *gpio_port = (cfg_pin - PIN_CFG_GPIO0_P0) >> 2; |
| 4562 | } else { |
| 4563 | *gpio_num = MISC_REGISTERS_GPIO_3; |
| 4564 | *gpio_port = port; |
| 4565 | } |
| 4566 | DP(NETIF_MSG_LINK, "MOD_ABS int GPIO%d_P%d\n", *gpio_num, *gpio_port); |
| 4567 | return 0; |
| 4568 | } |
| 4569 | |
| 4570 | static int bnx2x_is_sfp_module_plugged(struct bnx2x_phy *phy, |
| 4571 | struct link_params *params) |
| 4572 | { |
| 4573 | struct bnx2x *bp = params->bp; |
| 4574 | u8 gpio_num, gpio_port; |
| 4575 | u32 gpio_val; |
| 4576 | if (bnx2x_get_mod_abs_int_cfg(bp, params->chip_id, |
| 4577 | params->shmem_base, params->port, |
| 4578 | &gpio_num, &gpio_port) != 0) |
| 4579 | return 0; |
| 4580 | gpio_val = bnx2x_get_gpio(bp, gpio_num, gpio_port); |
| 4581 | |
| 4582 | /* Call the handling function in case module is detected */ |
| 4583 | if (gpio_val == 0) |
| 4584 | return 1; |
| 4585 | else |
| 4586 | return 0; |
| 4587 | } |
Yaniv Rosner | a9077bf | 2011-10-27 05:09:46 +0000 | [diff] [blame] | 4588 | static int bnx2x_warpcore_get_sigdet(struct bnx2x_phy *phy, |
| 4589 | struct link_params *params) |
| 4590 | { |
| 4591 | u16 gp2_status_reg0, lane; |
| 4592 | struct bnx2x *bp = params->bp; |
| 4593 | |
| 4594 | lane = bnx2x_get_warpcore_lane(phy, params); |
| 4595 | |
| 4596 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, MDIO_WC_REG_GP2_STATUS_GP_2_0, |
| 4597 | &gp2_status_reg0); |
| 4598 | |
| 4599 | return (gp2_status_reg0 >> (8+lane)) & 0x1; |
| 4600 | } |
| 4601 | |
| 4602 | static void bnx2x_warpcore_config_runtime(struct bnx2x_phy *phy, |
| 4603 | struct link_params *params, |
| 4604 | struct link_vars *vars) |
| 4605 | { |
| 4606 | struct bnx2x *bp = params->bp; |
| 4607 | u32 serdes_net_if; |
| 4608 | u16 gp_status1 = 0, lnkup = 0, lnkup_kr = 0; |
| 4609 | u16 lane = bnx2x_get_warpcore_lane(phy, params); |
| 4610 | |
| 4611 | vars->turn_to_run_wc_rt = vars->turn_to_run_wc_rt ? 0 : 1; |
| 4612 | |
| 4613 | if (!vars->turn_to_run_wc_rt) |
| 4614 | return; |
| 4615 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 4616 | /* Return if there is no link partner */ |
Yaniv Rosner | a9077bf | 2011-10-27 05:09:46 +0000 | [diff] [blame] | 4617 | if (!(bnx2x_warpcore_get_sigdet(phy, params))) { |
| 4618 | DP(NETIF_MSG_LINK, "bnx2x_warpcore_get_sigdet false\n"); |
| 4619 | return; |
| 4620 | } |
| 4621 | |
| 4622 | if (vars->rx_tx_asic_rst) { |
| 4623 | serdes_net_if = (REG_RD(bp, params->shmem_base + |
| 4624 | offsetof(struct shmem_region, dev_info. |
| 4625 | port_hw_config[params->port].default_cfg)) & |
| 4626 | PORT_HW_CFG_NET_SERDES_IF_MASK); |
| 4627 | |
| 4628 | switch (serdes_net_if) { |
| 4629 | case PORT_HW_CFG_NET_SERDES_IF_KR: |
| 4630 | /* Do we get link yet? */ |
| 4631 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, 0x81d1, |
| 4632 | &gp_status1); |
| 4633 | lnkup = (gp_status1 >> (8+lane)) & 0x1;/* 1G */ |
| 4634 | /*10G KR*/ |
| 4635 | lnkup_kr = (gp_status1 >> (12+lane)) & 0x1; |
| 4636 | |
| 4637 | DP(NETIF_MSG_LINK, |
| 4638 | "gp_status1 0x%x\n", gp_status1); |
| 4639 | |
| 4640 | if (lnkup_kr || lnkup) { |
| 4641 | vars->rx_tx_asic_rst = 0; |
| 4642 | DP(NETIF_MSG_LINK, |
| 4643 | "link up, rx_tx_asic_rst 0x%x\n", |
| 4644 | vars->rx_tx_asic_rst); |
| 4645 | } else { |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 4646 | /* Reset the lane to see if link comes up.*/ |
Yaniv Rosner | a9077bf | 2011-10-27 05:09:46 +0000 | [diff] [blame] | 4647 | bnx2x_warpcore_reset_lane(bp, phy, 1); |
| 4648 | bnx2x_warpcore_reset_lane(bp, phy, 0); |
| 4649 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 4650 | /* Restart Autoneg */ |
Yaniv Rosner | a9077bf | 2011-10-27 05:09:46 +0000 | [diff] [blame] | 4651 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, |
| 4652 | MDIO_WC_REG_IEEE0BLK_MIICNTL, 0x1200); |
| 4653 | |
| 4654 | vars->rx_tx_asic_rst--; |
| 4655 | DP(NETIF_MSG_LINK, "0x%x retry left\n", |
| 4656 | vars->rx_tx_asic_rst); |
| 4657 | } |
| 4658 | break; |
| 4659 | |
| 4660 | default: |
| 4661 | break; |
| 4662 | } |
| 4663 | |
| 4664 | } /*params->rx_tx_asic_rst*/ |
| 4665 | |
| 4666 | } |
Yuval Mintz | dbef807 | 2012-06-20 19:05:22 +0000 | [diff] [blame] | 4667 | static void bnx2x_warpcore_config_sfi(struct bnx2x_phy *phy, |
| 4668 | struct link_params *params) |
| 4669 | { |
| 4670 | u16 lane = bnx2x_get_warpcore_lane(phy, params); |
| 4671 | struct bnx2x *bp = params->bp; |
| 4672 | bnx2x_warpcore_clear_regs(phy, params, lane); |
| 4673 | if ((params->req_line_speed[LINK_CONFIG_IDX(INT_PHY)] == |
| 4674 | SPEED_10000) && |
| 4675 | (phy->media_type != ETH_PHY_SFP_1G_FIBER)) { |
| 4676 | DP(NETIF_MSG_LINK, "Setting 10G SFI\n"); |
| 4677 | bnx2x_warpcore_set_10G_XFI(phy, params, 0); |
| 4678 | } else { |
| 4679 | DP(NETIF_MSG_LINK, "Setting 1G Fiber\n"); |
| 4680 | bnx2x_warpcore_set_sgmii_speed(phy, params, 1, 0); |
| 4681 | } |
| 4682 | } |
| 4683 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4684 | static void bnx2x_warpcore_config_init(struct bnx2x_phy *phy, |
| 4685 | struct link_params *params, |
| 4686 | struct link_vars *vars) |
| 4687 | { |
| 4688 | struct bnx2x *bp = params->bp; |
| 4689 | u32 serdes_net_if; |
| 4690 | u8 fiber_mode; |
| 4691 | u16 lane = bnx2x_get_warpcore_lane(phy, params); |
| 4692 | serdes_net_if = (REG_RD(bp, params->shmem_base + |
| 4693 | offsetof(struct shmem_region, dev_info. |
| 4694 | port_hw_config[params->port].default_cfg)) & |
| 4695 | PORT_HW_CFG_NET_SERDES_IF_MASK); |
| 4696 | DP(NETIF_MSG_LINK, "Begin Warpcore init, link_speed %d, " |
| 4697 | "serdes_net_if = 0x%x\n", |
| 4698 | vars->line_speed, serdes_net_if); |
| 4699 | bnx2x_set_aer_mmd(params, phy); |
Yaniv Rosner | d3a8f13 | 2012-09-13 02:56:20 +0000 | [diff] [blame] | 4700 | bnx2x_warpcore_reset_lane(bp, phy, 1); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4701 | vars->phy_flags |= PHY_XGXS_FLAG; |
| 4702 | if ((serdes_net_if == PORT_HW_CFG_NET_SERDES_IF_SGMII) || |
| 4703 | (phy->req_line_speed && |
| 4704 | ((phy->req_line_speed == SPEED_100) || |
| 4705 | (phy->req_line_speed == SPEED_10)))) { |
| 4706 | vars->phy_flags |= PHY_SGMII_FLAG; |
| 4707 | DP(NETIF_MSG_LINK, "Setting SGMII mode\n"); |
| 4708 | bnx2x_warpcore_clear_regs(phy, params, lane); |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 4709 | bnx2x_warpcore_set_sgmii_speed(phy, params, 0, 1); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4710 | } else { |
| 4711 | switch (serdes_net_if) { |
| 4712 | case PORT_HW_CFG_NET_SERDES_IF_KR: |
| 4713 | /* Enable KR Auto Neg */ |
Yaniv Rosner | 6a51c0d | 2012-04-04 01:28:56 +0000 | [diff] [blame] | 4714 | if (params->loopback_mode != LOOPBACK_EXT) |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4715 | bnx2x_warpcore_enable_AN_KR(phy, params, vars); |
| 4716 | else { |
| 4717 | DP(NETIF_MSG_LINK, "Setting KR 10G-Force\n"); |
| 4718 | bnx2x_warpcore_set_10G_KR(phy, params, vars); |
| 4719 | } |
| 4720 | break; |
| 4721 | |
| 4722 | case PORT_HW_CFG_NET_SERDES_IF_XFI: |
| 4723 | bnx2x_warpcore_clear_regs(phy, params, lane); |
| 4724 | if (vars->line_speed == SPEED_10000) { |
| 4725 | DP(NETIF_MSG_LINK, "Setting 10G XFI\n"); |
| 4726 | bnx2x_warpcore_set_10G_XFI(phy, params, 1); |
| 4727 | } else { |
| 4728 | if (SINGLE_MEDIA_DIRECT(params)) { |
| 4729 | DP(NETIF_MSG_LINK, "1G Fiber\n"); |
| 4730 | fiber_mode = 1; |
| 4731 | } else { |
| 4732 | DP(NETIF_MSG_LINK, "10/100/1G SGMII\n"); |
| 4733 | fiber_mode = 0; |
| 4734 | } |
| 4735 | bnx2x_warpcore_set_sgmii_speed(phy, |
| 4736 | params, |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 4737 | fiber_mode, |
| 4738 | 0); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4739 | } |
| 4740 | |
| 4741 | break; |
| 4742 | |
| 4743 | case PORT_HW_CFG_NET_SERDES_IF_SFI: |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4744 | /* Issue Module detection */ |
| 4745 | if (bnx2x_is_sfp_module_plugged(phy, params)) |
| 4746 | bnx2x_sfp_module_detection(phy, params); |
Yuval Mintz | dbef807 | 2012-06-20 19:05:22 +0000 | [diff] [blame] | 4747 | |
| 4748 | bnx2x_warpcore_config_sfi(phy, params); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4749 | break; |
| 4750 | |
| 4751 | case PORT_HW_CFG_NET_SERDES_IF_DXGXS: |
| 4752 | if (vars->line_speed != SPEED_20000) { |
| 4753 | DP(NETIF_MSG_LINK, "Speed not supported yet\n"); |
| 4754 | return; |
| 4755 | } |
| 4756 | DP(NETIF_MSG_LINK, "Setting 20G DXGXS\n"); |
| 4757 | bnx2x_warpcore_set_20G_DXGXS(bp, phy, lane); |
| 4758 | /* Issue Module detection */ |
| 4759 | |
| 4760 | bnx2x_sfp_module_detection(phy, params); |
| 4761 | break; |
| 4762 | |
| 4763 | case PORT_HW_CFG_NET_SERDES_IF_KR2: |
| 4764 | if (vars->line_speed != SPEED_20000) { |
| 4765 | DP(NETIF_MSG_LINK, "Speed not supported yet\n"); |
| 4766 | return; |
| 4767 | } |
| 4768 | DP(NETIF_MSG_LINK, "Setting 20G KR2\n"); |
| 4769 | bnx2x_warpcore_set_20G_KR2(bp, phy); |
| 4770 | break; |
| 4771 | |
| 4772 | default: |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 4773 | DP(NETIF_MSG_LINK, |
| 4774 | "Unsupported Serdes Net Interface 0x%x\n", |
| 4775 | serdes_net_if); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4776 | return; |
| 4777 | } |
| 4778 | } |
| 4779 | |
| 4780 | /* Take lane out of reset after configuration is finished */ |
| 4781 | bnx2x_warpcore_reset_lane(bp, phy, 0); |
| 4782 | DP(NETIF_MSG_LINK, "Exit config init\n"); |
| 4783 | } |
| 4784 | |
| 4785 | static void bnx2x_sfp_e3_set_transmitter(struct link_params *params, |
| 4786 | struct bnx2x_phy *phy, |
| 4787 | u8 tx_en) |
| 4788 | { |
| 4789 | struct bnx2x *bp = params->bp; |
| 4790 | u32 cfg_pin; |
| 4791 | u8 port = params->port; |
| 4792 | |
| 4793 | cfg_pin = REG_RD(bp, params->shmem_base + |
| 4794 | offsetof(struct shmem_region, |
| 4795 | dev_info.port_hw_config[port].e3_sfp_ctrl)) & |
| 4796 | PORT_HW_CFG_TX_LASER_MASK; |
| 4797 | /* Set the !tx_en since this pin is DISABLE_TX_LASER */ |
| 4798 | DP(NETIF_MSG_LINK, "Setting WC TX to %d\n", tx_en); |
| 4799 | /* For 20G, the expected pin to be used is 3 pins after the current */ |
| 4800 | |
| 4801 | bnx2x_set_cfg_pin(bp, cfg_pin, tx_en ^ 1); |
| 4802 | if (phy->speed_cap_mask & PORT_HW_CFG_SPEED_CAPABILITY_D0_20G) |
| 4803 | bnx2x_set_cfg_pin(bp, cfg_pin + 3, tx_en ^ 1); |
| 4804 | } |
| 4805 | |
| 4806 | static void bnx2x_warpcore_link_reset(struct bnx2x_phy *phy, |
| 4807 | struct link_params *params) |
| 4808 | { |
| 4809 | struct bnx2x *bp = params->bp; |
| 4810 | u16 val16; |
| 4811 | bnx2x_sfp_e3_set_transmitter(params, phy, 0); |
| 4812 | bnx2x_set_mdio_clk(bp, params->chip_id, params->port); |
| 4813 | bnx2x_set_aer_mmd(params, phy); |
| 4814 | /* Global register */ |
| 4815 | bnx2x_warpcore_reset_lane(bp, phy, 1); |
| 4816 | |
| 4817 | /* Clear loopback settings (if any) */ |
| 4818 | /* 10G & 20G */ |
| 4819 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4820 | MDIO_WC_REG_COMBO_IEEE0_MIICTRL, &val16); |
| 4821 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4822 | MDIO_WC_REG_COMBO_IEEE0_MIICTRL, val16 & |
| 4823 | 0xBFFF); |
| 4824 | |
| 4825 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4826 | MDIO_WC_REG_IEEE0BLK_MIICNTL, &val16); |
| 4827 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4828 | MDIO_WC_REG_IEEE0BLK_MIICNTL, val16 & 0xfffe); |
| 4829 | |
| 4830 | /* Update those 1-copy registers */ |
| 4831 | CL22_WR_OVER_CL45(bp, phy, MDIO_REG_BANK_AER_BLOCK, |
| 4832 | MDIO_AER_BLOCK_AER_REG, 0); |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 4833 | /* Enable 1G MDIO (1-copy) */ |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4834 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4835 | MDIO_WC_REG_XGXSBLK0_XGXSCONTROL, |
| 4836 | &val16); |
| 4837 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4838 | MDIO_WC_REG_XGXSBLK0_XGXSCONTROL, |
| 4839 | val16 & ~0x10); |
| 4840 | |
| 4841 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4842 | MDIO_WC_REG_XGXSBLK1_LANECTRL2, &val16); |
| 4843 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4844 | MDIO_WC_REG_XGXSBLK1_LANECTRL2, |
| 4845 | val16 & 0xff00); |
| 4846 | |
| 4847 | } |
| 4848 | |
| 4849 | static void bnx2x_set_warpcore_loopback(struct bnx2x_phy *phy, |
| 4850 | struct link_params *params) |
| 4851 | { |
| 4852 | struct bnx2x *bp = params->bp; |
| 4853 | u16 val16; |
| 4854 | u32 lane; |
| 4855 | DP(NETIF_MSG_LINK, "Setting Warpcore loopback type %x, speed %d\n", |
| 4856 | params->loopback_mode, phy->req_line_speed); |
| 4857 | |
| 4858 | if (phy->req_line_speed < SPEED_10000) { |
| 4859 | /* 10/100/1000 */ |
| 4860 | |
| 4861 | /* Update those 1-copy registers */ |
| 4862 | CL22_WR_OVER_CL45(bp, phy, MDIO_REG_BANK_AER_BLOCK, |
| 4863 | MDIO_AER_BLOCK_AER_REG, 0); |
| 4864 | /* Enable 1G MDIO (1-copy) */ |
Yuval Mintz | a351d49 | 2012-06-20 19:05:21 +0000 | [diff] [blame] | 4865 | bnx2x_cl45_read_or_write(bp, phy, MDIO_WC_DEVAD, |
| 4866 | MDIO_WC_REG_XGXSBLK0_XGXSCONTROL, |
| 4867 | 0x10); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4868 | /* Set 1G loopback based on lane (1-copy) */ |
| 4869 | lane = bnx2x_get_warpcore_lane(phy, params); |
| 4870 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4871 | MDIO_WC_REG_XGXSBLK1_LANECTRL2, &val16); |
| 4872 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4873 | MDIO_WC_REG_XGXSBLK1_LANECTRL2, |
| 4874 | val16 | (1<<lane)); |
| 4875 | |
| 4876 | /* Switch back to 4-copy registers */ |
| 4877 | bnx2x_set_aer_mmd(params, phy); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4878 | } else { |
| 4879 | /* 10G & 20G */ |
Yuval Mintz | a351d49 | 2012-06-20 19:05:21 +0000 | [diff] [blame] | 4880 | bnx2x_cl45_read_or_write(bp, phy, MDIO_WC_DEVAD, |
| 4881 | MDIO_WC_REG_COMBO_IEEE0_MIICTRL, |
| 4882 | 0x4000); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4883 | |
Yuval Mintz | a351d49 | 2012-06-20 19:05:21 +0000 | [diff] [blame] | 4884 | bnx2x_cl45_read_or_write(bp, phy, MDIO_WC_DEVAD, |
| 4885 | MDIO_WC_REG_IEEE0BLK_MIICNTL, 0x1); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4886 | } |
| 4887 | } |
| 4888 | |
| 4889 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 4890 | |
| 4891 | static void bnx2x_sync_link(struct link_params *params, |
| 4892 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4893 | { |
| 4894 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 4895 | u8 link_10g_plus; |
Yaniv Rosner | de6f337 | 2011-08-02 22:59:25 +0000 | [diff] [blame] | 4896 | if (vars->link_status & LINK_STATUS_PHYSICAL_LINK_FLAG) |
| 4897 | vars->phy_flags |= PHY_PHYSICAL_LINK_FLAG; |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 4898 | vars->link_up = (vars->link_status & LINK_STATUS_LINK_UP); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4899 | if (vars->link_up) { |
| 4900 | DP(NETIF_MSG_LINK, "phy link up\n"); |
| 4901 | |
| 4902 | vars->phy_link_up = 1; |
| 4903 | vars->duplex = DUPLEX_FULL; |
| 4904 | switch (vars->link_status & |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4905 | LINK_STATUS_SPEED_AND_DUPLEX_MASK) { |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 4906 | case LINK_10THD: |
| 4907 | vars->duplex = DUPLEX_HALF; |
| 4908 | /* Fall thru */ |
| 4909 | case LINK_10TFD: |
| 4910 | vars->line_speed = SPEED_10; |
| 4911 | break; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4912 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 4913 | case LINK_100TXHD: |
| 4914 | vars->duplex = DUPLEX_HALF; |
| 4915 | /* Fall thru */ |
| 4916 | case LINK_100T4: |
| 4917 | case LINK_100TXFD: |
| 4918 | vars->line_speed = SPEED_100; |
| 4919 | break; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4920 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 4921 | case LINK_1000THD: |
| 4922 | vars->duplex = DUPLEX_HALF; |
| 4923 | /* Fall thru */ |
| 4924 | case LINK_1000TFD: |
| 4925 | vars->line_speed = SPEED_1000; |
| 4926 | break; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4927 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 4928 | case LINK_2500THD: |
| 4929 | vars->duplex = DUPLEX_HALF; |
| 4930 | /* Fall thru */ |
| 4931 | case LINK_2500TFD: |
| 4932 | vars->line_speed = SPEED_2500; |
| 4933 | break; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4934 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 4935 | case LINK_10GTFD: |
| 4936 | vars->line_speed = SPEED_10000; |
| 4937 | break; |
| 4938 | case LINK_20GTFD: |
| 4939 | vars->line_speed = SPEED_20000; |
| 4940 | break; |
| 4941 | default: |
| 4942 | break; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4943 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4944 | vars->flow_ctrl = 0; |
| 4945 | if (vars->link_status & LINK_STATUS_TX_FLOW_CONTROL_ENABLED) |
| 4946 | vars->flow_ctrl |= BNX2X_FLOW_CTRL_TX; |
| 4947 | |
| 4948 | if (vars->link_status & LINK_STATUS_RX_FLOW_CONTROL_ENABLED) |
| 4949 | vars->flow_ctrl |= BNX2X_FLOW_CTRL_RX; |
| 4950 | |
| 4951 | if (!vars->flow_ctrl) |
| 4952 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 4953 | |
| 4954 | if (vars->line_speed && |
| 4955 | ((vars->line_speed == SPEED_10) || |
| 4956 | (vars->line_speed == SPEED_100))) { |
| 4957 | vars->phy_flags |= PHY_SGMII_FLAG; |
| 4958 | } else { |
| 4959 | vars->phy_flags &= ~PHY_SGMII_FLAG; |
| 4960 | } |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4961 | if (vars->line_speed && |
| 4962 | USES_WARPCORE(bp) && |
| 4963 | (vars->line_speed == SPEED_1000)) |
| 4964 | vars->phy_flags |= PHY_SGMII_FLAG; |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 4965 | /* Anything 10 and over uses the bmac */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 4966 | link_10g_plus = (vars->line_speed >= SPEED_10000); |
| 4967 | |
| 4968 | if (link_10g_plus) { |
| 4969 | if (USES_WARPCORE(bp)) |
| 4970 | vars->mac_type = MAC_TYPE_XMAC; |
| 4971 | else |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4972 | vars->mac_type = MAC_TYPE_BMAC; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 4973 | } else { |
| 4974 | if (USES_WARPCORE(bp)) |
| 4975 | vars->mac_type = MAC_TYPE_UMAC; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4976 | else |
| 4977 | vars->mac_type = MAC_TYPE_EMAC; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 4978 | } |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 4979 | } else { /* Link down */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4980 | DP(NETIF_MSG_LINK, "phy link down\n"); |
| 4981 | |
| 4982 | vars->phy_link_up = 0; |
| 4983 | |
| 4984 | vars->line_speed = 0; |
| 4985 | vars->duplex = DUPLEX_FULL; |
| 4986 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 4987 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 4988 | /* Indicate no mac active */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4989 | vars->mac_type = MAC_TYPE_NONE; |
Yaniv Rosner | de6f337 | 2011-08-02 22:59:25 +0000 | [diff] [blame] | 4990 | if (vars->link_status & LINK_STATUS_PHYSICAL_LINK_FLAG) |
| 4991 | vars->phy_flags |= PHY_HALF_OPEN_CONN_FLAG; |
Yuval Mintz | d0b8a6f | 2012-06-20 19:05:18 +0000 | [diff] [blame] | 4992 | if (vars->link_status & LINK_STATUS_SFP_TX_FAULT) |
| 4993 | vars->phy_flags |= PHY_SFP_TX_FAULT_FLAG; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4994 | } |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 4995 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4996 | |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 4997 | void bnx2x_link_status_update(struct link_params *params, |
| 4998 | struct link_vars *vars) |
| 4999 | { |
| 5000 | struct bnx2x *bp = params->bp; |
| 5001 | u8 port = params->port; |
| 5002 | u32 sync_offset, media_types; |
| 5003 | /* Update PHY configuration */ |
| 5004 | set_phy_vars(params, vars); |
| 5005 | |
| 5006 | vars->link_status = REG_RD(bp, params->shmem_base + |
| 5007 | offsetof(struct shmem_region, |
| 5008 | port_mb[port].link_status)); |
Yuval Mintz | 08e9acc | 2012-09-10 05:51:04 +0000 | [diff] [blame] | 5009 | if (bnx2x_eee_has_cap(params)) |
| 5010 | vars->eee_status = REG_RD(bp, params->shmem2_base + |
| 5011 | offsetof(struct shmem2_region, |
| 5012 | eee_status[params->port])); |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 5013 | |
| 5014 | vars->phy_flags = PHY_XGXS_FLAG; |
| 5015 | bnx2x_sync_link(params, vars); |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 5016 | /* Sync media type */ |
| 5017 | sync_offset = params->shmem_base + |
| 5018 | offsetof(struct shmem_region, |
| 5019 | dev_info.port_hw_config[port].media_type); |
| 5020 | media_types = REG_RD(bp, sync_offset); |
| 5021 | |
| 5022 | params->phy[INT_PHY].media_type = |
| 5023 | (media_types & PORT_HW_CFG_MEDIA_TYPE_PHY0_MASK) >> |
| 5024 | PORT_HW_CFG_MEDIA_TYPE_PHY0_SHIFT; |
| 5025 | params->phy[EXT_PHY1].media_type = |
| 5026 | (media_types & PORT_HW_CFG_MEDIA_TYPE_PHY1_MASK) >> |
| 5027 | PORT_HW_CFG_MEDIA_TYPE_PHY1_SHIFT; |
| 5028 | params->phy[EXT_PHY2].media_type = |
| 5029 | (media_types & PORT_HW_CFG_MEDIA_TYPE_PHY2_MASK) >> |
| 5030 | PORT_HW_CFG_MEDIA_TYPE_PHY2_SHIFT; |
| 5031 | DP(NETIF_MSG_LINK, "media_types = 0x%x\n", media_types); |
| 5032 | |
Yaniv Rosner | 020c7e3 | 2011-05-31 21:28:43 +0000 | [diff] [blame] | 5033 | /* Sync AEU offset */ |
| 5034 | sync_offset = params->shmem_base + |
| 5035 | offsetof(struct shmem_region, |
| 5036 | dev_info.port_hw_config[port].aeu_int_mask); |
| 5037 | |
| 5038 | vars->aeu_int_mask = REG_RD(bp, sync_offset); |
| 5039 | |
Yaniv Rosner | b8d6d08 | 2011-07-05 01:06:27 +0000 | [diff] [blame] | 5040 | /* Sync PFC status */ |
| 5041 | if (vars->link_status & LINK_STATUS_PFC_ENABLED) |
| 5042 | params->feature_config_flags |= |
| 5043 | FEATURE_CONFIG_PFC_ENABLED; |
| 5044 | else |
| 5045 | params->feature_config_flags &= |
| 5046 | ~FEATURE_CONFIG_PFC_ENABLED; |
| 5047 | |
Yaniv Rosner | 020c7e3 | 2011-05-31 21:28:43 +0000 | [diff] [blame] | 5048 | DP(NETIF_MSG_LINK, "link_status 0x%x phy_link_up %x int_mask 0x%x\n", |
| 5049 | vars->link_status, vars->phy_link_up, vars->aeu_int_mask); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5050 | DP(NETIF_MSG_LINK, "line_speed %x duplex %x flow_ctrl 0x%x\n", |
| 5051 | vars->line_speed, vars->duplex, vars->flow_ctrl); |
| 5052 | } |
| 5053 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 5054 | static void bnx2x_set_master_ln(struct link_params *params, |
| 5055 | struct bnx2x_phy *phy) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5056 | { |
| 5057 | struct bnx2x *bp = params->bp; |
| 5058 | u16 new_master_ln, ser_lane; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5059 | ser_lane = ((params->lane_config & |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5060 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_MASK) >> |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5061 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_SHIFT); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5062 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 5063 | /* Set the master_ln for AN */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5064 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5065 | MDIO_REG_BANK_XGXS_BLOCK2, |
| 5066 | MDIO_XGXS_BLOCK2_TEST_MODE_LANE, |
| 5067 | &new_master_ln); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5068 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5069 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5070 | MDIO_REG_BANK_XGXS_BLOCK2 , |
| 5071 | MDIO_XGXS_BLOCK2_TEST_MODE_LANE, |
| 5072 | (new_master_ln | ser_lane)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5073 | } |
| 5074 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 5075 | static int bnx2x_reset_unicore(struct link_params *params, |
| 5076 | struct bnx2x_phy *phy, |
| 5077 | u8 set_serdes) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5078 | { |
| 5079 | struct bnx2x *bp = params->bp; |
| 5080 | u16 mii_control; |
| 5081 | u16 i; |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5082 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5083 | MDIO_REG_BANK_COMBO_IEEE0, |
| 5084 | MDIO_COMBO_IEEE0_MII_CONTROL, &mii_control); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5085 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 5086 | /* Reset the unicore */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5087 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5088 | MDIO_REG_BANK_COMBO_IEEE0, |
| 5089 | MDIO_COMBO_IEEE0_MII_CONTROL, |
| 5090 | (mii_control | |
| 5091 | MDIO_COMBO_IEEO_MII_CONTROL_RESET)); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 5092 | if (set_serdes) |
| 5093 | bnx2x_set_serdes_access(bp, params->port); |
Eilon Greenstein | c1b7399 | 2009-02-12 08:37:07 +0000 | [diff] [blame] | 5094 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 5095 | /* Wait for the reset to self clear */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5096 | for (i = 0; i < MDIO_ACCESS_TIMEOUT; i++) { |
| 5097 | udelay(5); |
| 5098 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 5099 | /* The reset erased the previous bank value */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5100 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5101 | MDIO_REG_BANK_COMBO_IEEE0, |
| 5102 | MDIO_COMBO_IEEE0_MII_CONTROL, |
| 5103 | &mii_control); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5104 | |
| 5105 | if (!(mii_control & MDIO_COMBO_IEEO_MII_CONTROL_RESET)) { |
| 5106 | udelay(5); |
| 5107 | return 0; |
| 5108 | } |
| 5109 | } |
| 5110 | |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 5111 | netdev_err(bp->dev, "Warning: PHY was not initialized," |
| 5112 | " Port %d\n", |
| 5113 | params->port); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5114 | DP(NETIF_MSG_LINK, "BUG! XGXS is still in reset!\n"); |
| 5115 | return -EINVAL; |
| 5116 | |
| 5117 | } |
| 5118 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 5119 | static void bnx2x_set_swap_lanes(struct link_params *params, |
| 5120 | struct bnx2x_phy *phy) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5121 | { |
| 5122 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 5123 | /* Each two bits represents a lane number: |
| 5124 | * No swap is 0123 => 0x1b no need to enable the swap |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5125 | */ |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 5126 | u16 rx_lane_swap, tx_lane_swap; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5127 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5128 | rx_lane_swap = ((params->lane_config & |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5129 | PORT_HW_CFG_LANE_SWAP_CFG_RX_MASK) >> |
| 5130 | PORT_HW_CFG_LANE_SWAP_CFG_RX_SHIFT); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5131 | tx_lane_swap = ((params->lane_config & |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5132 | PORT_HW_CFG_LANE_SWAP_CFG_TX_MASK) >> |
| 5133 | PORT_HW_CFG_LANE_SWAP_CFG_TX_SHIFT); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5134 | |
| 5135 | if (rx_lane_swap != 0x1b) { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5136 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5137 | MDIO_REG_BANK_XGXS_BLOCK2, |
| 5138 | MDIO_XGXS_BLOCK2_RX_LN_SWAP, |
| 5139 | (rx_lane_swap | |
| 5140 | MDIO_XGXS_BLOCK2_RX_LN_SWAP_ENABLE | |
| 5141 | MDIO_XGXS_BLOCK2_RX_LN_SWAP_FORCE_ENABLE)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5142 | } else { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5143 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5144 | MDIO_REG_BANK_XGXS_BLOCK2, |
| 5145 | MDIO_XGXS_BLOCK2_RX_LN_SWAP, 0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5146 | } |
| 5147 | |
| 5148 | if (tx_lane_swap != 0x1b) { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5149 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5150 | MDIO_REG_BANK_XGXS_BLOCK2, |
| 5151 | MDIO_XGXS_BLOCK2_TX_LN_SWAP, |
| 5152 | (tx_lane_swap | |
| 5153 | MDIO_XGXS_BLOCK2_TX_LN_SWAP_ENABLE)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5154 | } else { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5155 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5156 | MDIO_REG_BANK_XGXS_BLOCK2, |
| 5157 | MDIO_XGXS_BLOCK2_TX_LN_SWAP, 0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5158 | } |
| 5159 | } |
| 5160 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 5161 | static void bnx2x_set_parallel_detection(struct bnx2x_phy *phy, |
| 5162 | struct link_params *params) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5163 | { |
| 5164 | struct bnx2x *bp = params->bp; |
| 5165 | u16 control2; |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5166 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5167 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 5168 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL2, |
| 5169 | &control2); |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 5170 | if (phy->speed_cap_mask & PORT_HW_CFG_SPEED_CAPABILITY_D0_1G) |
Yaniv Rosner | 18afb0a | 2009-11-05 19:18:04 +0200 | [diff] [blame] | 5171 | control2 |= MDIO_SERDES_DIGITAL_A_1000X_CONTROL2_PRL_DT_EN; |
| 5172 | else |
| 5173 | control2 &= ~MDIO_SERDES_DIGITAL_A_1000X_CONTROL2_PRL_DT_EN; |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 5174 | DP(NETIF_MSG_LINK, "phy->speed_cap_mask = 0x%x, control2 = 0x%x\n", |
| 5175 | phy->speed_cap_mask, control2); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5176 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5177 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 5178 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL2, |
| 5179 | control2); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5180 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 5181 | if ((phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT) && |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 5182 | (phy->speed_cap_mask & |
Yaniv Rosner | 18afb0a | 2009-11-05 19:18:04 +0200 | [diff] [blame] | 5183 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G)) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5184 | DP(NETIF_MSG_LINK, "XGXS\n"); |
| 5185 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5186 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5187 | MDIO_REG_BANK_10G_PARALLEL_DETECT, |
| 5188 | MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_LINK, |
| 5189 | MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_LINK_CNT); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5190 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5191 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5192 | MDIO_REG_BANK_10G_PARALLEL_DETECT, |
| 5193 | MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_CONTROL, |
| 5194 | &control2); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5195 | |
| 5196 | |
| 5197 | control2 |= |
| 5198 | MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_CONTROL_PARDET10G_EN; |
| 5199 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5200 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5201 | MDIO_REG_BANK_10G_PARALLEL_DETECT, |
| 5202 | MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_CONTROL, |
| 5203 | control2); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5204 | |
| 5205 | /* Disable parallel detection of HiG */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5206 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5207 | MDIO_REG_BANK_XGXS_BLOCK2, |
| 5208 | MDIO_XGXS_BLOCK2_UNICORE_MODE_10G, |
| 5209 | MDIO_XGXS_BLOCK2_UNICORE_MODE_10G_CX4_XGXS | |
| 5210 | MDIO_XGXS_BLOCK2_UNICORE_MODE_10G_HIGIG_XGXS); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5211 | } |
| 5212 | } |
| 5213 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 5214 | static void bnx2x_set_autoneg(struct bnx2x_phy *phy, |
| 5215 | struct link_params *params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5216 | struct link_vars *vars, |
| 5217 | u8 enable_cl73) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5218 | { |
| 5219 | struct bnx2x *bp = params->bp; |
| 5220 | u16 reg_val; |
| 5221 | |
| 5222 | /* CL37 Autoneg */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5223 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5224 | MDIO_REG_BANK_COMBO_IEEE0, |
| 5225 | MDIO_COMBO_IEEE0_MII_CONTROL, ®_val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5226 | |
| 5227 | /* CL37 Autoneg Enabled */ |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 5228 | if (vars->line_speed == SPEED_AUTO_NEG) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5229 | reg_val |= MDIO_COMBO_IEEO_MII_CONTROL_AN_EN; |
| 5230 | else /* CL37 Autoneg Disabled */ |
| 5231 | reg_val &= ~(MDIO_COMBO_IEEO_MII_CONTROL_AN_EN | |
| 5232 | MDIO_COMBO_IEEO_MII_CONTROL_RESTART_AN); |
| 5233 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5234 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5235 | MDIO_REG_BANK_COMBO_IEEE0, |
| 5236 | MDIO_COMBO_IEEE0_MII_CONTROL, reg_val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5237 | |
| 5238 | /* Enable/Disable Autodetection */ |
| 5239 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5240 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5241 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 5242 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL1, ®_val); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5243 | reg_val &= ~(MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_SIGNAL_DETECT_EN | |
| 5244 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_INVERT_SIGNAL_DETECT); |
| 5245 | reg_val |= MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_FIBER_MODE; |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 5246 | if (vars->line_speed == SPEED_AUTO_NEG) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5247 | reg_val |= MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_AUTODET; |
| 5248 | else |
| 5249 | reg_val &= ~MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_AUTODET; |
| 5250 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5251 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5252 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 5253 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL1, reg_val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5254 | |
| 5255 | /* Enable TetonII and BAM autoneg */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5256 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5257 | MDIO_REG_BANK_BAM_NEXT_PAGE, |
| 5258 | MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL, |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5259 | ®_val); |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 5260 | if (vars->line_speed == SPEED_AUTO_NEG) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5261 | /* Enable BAM aneg Mode and TetonII aneg Mode */ |
| 5262 | reg_val |= (MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL_BAM_MODE | |
| 5263 | MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL_TETON_AN); |
| 5264 | } else { |
| 5265 | /* TetonII and BAM Autoneg Disabled */ |
| 5266 | reg_val &= ~(MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL_BAM_MODE | |
| 5267 | MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL_TETON_AN); |
| 5268 | } |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5269 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5270 | MDIO_REG_BANK_BAM_NEXT_PAGE, |
| 5271 | MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL, |
| 5272 | reg_val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5273 | |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5274 | if (enable_cl73) { |
| 5275 | /* Enable Cl73 FSM status bits */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5276 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5277 | MDIO_REG_BANK_CL73_USERB0, |
| 5278 | MDIO_CL73_USERB0_CL73_UCTRL, |
| 5279 | 0xe); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5280 | |
| 5281 | /* Enable BAM Station Manager*/ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5282 | CL22_WR_OVER_CL45(bp, phy, |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5283 | MDIO_REG_BANK_CL73_USERB0, |
| 5284 | MDIO_CL73_USERB0_CL73_BAM_CTRL1, |
| 5285 | MDIO_CL73_USERB0_CL73_BAM_CTRL1_BAM_EN | |
| 5286 | MDIO_CL73_USERB0_CL73_BAM_CTRL1_BAM_STATION_MNGR_EN | |
| 5287 | MDIO_CL73_USERB0_CL73_BAM_CTRL1_BAM_NP_AFTER_BP_EN); |
| 5288 | |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 5289 | /* Advertise CL73 link speeds */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5290 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5291 | MDIO_REG_BANK_CL73_IEEEB1, |
| 5292 | MDIO_CL73_IEEEB1_AN_ADV2, |
| 5293 | ®_val); |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 5294 | if (phy->speed_cap_mask & |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 5295 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G) |
| 5296 | reg_val |= MDIO_CL73_IEEEB1_AN_ADV2_ADVR_10G_KX4; |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 5297 | if (phy->speed_cap_mask & |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 5298 | PORT_HW_CFG_SPEED_CAPABILITY_D0_1G) |
| 5299 | reg_val |= MDIO_CL73_IEEEB1_AN_ADV2_ADVR_1000M_KX; |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5300 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5301 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5302 | MDIO_REG_BANK_CL73_IEEEB1, |
| 5303 | MDIO_CL73_IEEEB1_AN_ADV2, |
| 5304 | reg_val); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5305 | |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5306 | /* CL73 Autoneg Enabled */ |
| 5307 | reg_val = MDIO_CL73_IEEEB0_CL73_AN_CONTROL_AN_EN; |
| 5308 | |
| 5309 | } else /* CL73 Autoneg Disabled */ |
| 5310 | reg_val = 0; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5311 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5312 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5313 | MDIO_REG_BANK_CL73_IEEEB0, |
| 5314 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL, reg_val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5315 | } |
| 5316 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 5317 | /* Program SerDes, forced speed */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 5318 | static void bnx2x_program_serdes(struct bnx2x_phy *phy, |
| 5319 | struct link_params *params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5320 | struct link_vars *vars) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5321 | { |
| 5322 | struct bnx2x *bp = params->bp; |
| 5323 | u16 reg_val; |
| 5324 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 5325 | /* Program duplex, disable autoneg and sgmii*/ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5326 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5327 | MDIO_REG_BANK_COMBO_IEEE0, |
| 5328 | MDIO_COMBO_IEEE0_MII_CONTROL, ®_val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5329 | reg_val &= ~(MDIO_COMBO_IEEO_MII_CONTROL_FULL_DUPLEX | |
Eilon Greenstein | 5793720 | 2009-08-12 08:23:53 +0000 | [diff] [blame] | 5330 | MDIO_COMBO_IEEO_MII_CONTROL_AN_EN | |
| 5331 | MDIO_COMBO_IEEO_MII_CONTROL_MAN_SGMII_SP_MASK); |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 5332 | if (phy->req_duplex == DUPLEX_FULL) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5333 | reg_val |= MDIO_COMBO_IEEO_MII_CONTROL_FULL_DUPLEX; |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5334 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5335 | MDIO_REG_BANK_COMBO_IEEE0, |
| 5336 | MDIO_COMBO_IEEE0_MII_CONTROL, reg_val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5337 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 5338 | /* Program speed |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5339 | * - needed only if the speed is greater than 1G (2.5G or 10G) |
| 5340 | */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5341 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5342 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 5343 | MDIO_SERDES_DIGITAL_MISC1, ®_val); |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 5344 | /* Clearing the speed value before setting the right speed */ |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 5345 | DP(NETIF_MSG_LINK, "MDIO_REG_BANK_SERDES_DIGITAL = 0x%x\n", reg_val); |
| 5346 | |
| 5347 | reg_val &= ~(MDIO_SERDES_DIGITAL_MISC1_FORCE_SPEED_MASK | |
| 5348 | MDIO_SERDES_DIGITAL_MISC1_FORCE_SPEED_SEL); |
| 5349 | |
| 5350 | if (!((vars->line_speed == SPEED_1000) || |
| 5351 | (vars->line_speed == SPEED_100) || |
| 5352 | (vars->line_speed == SPEED_10))) { |
| 5353 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5354 | reg_val |= (MDIO_SERDES_DIGITAL_MISC1_REFCLK_SEL_156_25M | |
| 5355 | MDIO_SERDES_DIGITAL_MISC1_FORCE_SPEED_SEL); |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 5356 | if (vars->line_speed == SPEED_10000) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5357 | reg_val |= |
| 5358 | MDIO_SERDES_DIGITAL_MISC1_FORCE_SPEED_10G_CX4; |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 5359 | } |
| 5360 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5361 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5362 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 5363 | MDIO_SERDES_DIGITAL_MISC1, reg_val); |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 5364 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5365 | } |
| 5366 | |
Yaniv Rosner | 9045f6b4 | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 5367 | static void bnx2x_set_brcm_cl37_advertisement(struct bnx2x_phy *phy, |
| 5368 | struct link_params *params) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5369 | { |
| 5370 | struct bnx2x *bp = params->bp; |
| 5371 | u16 val = 0; |
| 5372 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 5373 | /* Set extended capabilities */ |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 5374 | if (phy->speed_cap_mask & PORT_HW_CFG_SPEED_CAPABILITY_D0_2_5G) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5375 | val |= MDIO_OVER_1G_UP1_2_5G; |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 5376 | if (phy->speed_cap_mask & PORT_HW_CFG_SPEED_CAPABILITY_D0_10G) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5377 | val |= MDIO_OVER_1G_UP1_10G; |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5378 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5379 | MDIO_REG_BANK_OVER_1G, |
| 5380 | MDIO_OVER_1G_UP1, val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5381 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5382 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5383 | MDIO_REG_BANK_OVER_1G, |
| 5384 | MDIO_OVER_1G_UP3, 0x400); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5385 | } |
| 5386 | |
Yaniv Rosner | 9045f6b4 | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 5387 | static void bnx2x_set_ieee_aneg_advertisement(struct bnx2x_phy *phy, |
| 5388 | struct link_params *params, |
| 5389 | u16 ieee_fc) |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 5390 | { |
| 5391 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 5392 | u16 val; |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 5393 | /* For AN, we are always publishing full duplex */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5394 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5395 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5396 | MDIO_REG_BANK_COMBO_IEEE0, |
| 5397 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV, ieee_fc); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5398 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5399 | MDIO_REG_BANK_CL73_IEEEB1, |
| 5400 | MDIO_CL73_IEEEB1_AN_ADV1, &val); |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 5401 | val &= ~MDIO_CL73_IEEEB1_AN_ADV1_PAUSE_BOTH; |
| 5402 | val |= ((ieee_fc<<3) & MDIO_CL73_IEEEB1_AN_ADV1_PAUSE_MASK); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5403 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5404 | MDIO_REG_BANK_CL73_IEEEB1, |
| 5405 | MDIO_CL73_IEEEB1_AN_ADV1, val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5406 | } |
| 5407 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 5408 | static void bnx2x_restart_autoneg(struct bnx2x_phy *phy, |
| 5409 | struct link_params *params, |
| 5410 | u8 enable_cl73) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5411 | { |
| 5412 | struct bnx2x *bp = params->bp; |
Eilon Greenstein | 3a36f2e | 2009-02-12 08:37:09 +0000 | [diff] [blame] | 5413 | u16 mii_control; |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5414 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5415 | DP(NETIF_MSG_LINK, "bnx2x_restart_autoneg\n"); |
Eilon Greenstein | 3a36f2e | 2009-02-12 08:37:09 +0000 | [diff] [blame] | 5416 | /* Enable and restart BAM/CL37 aneg */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5417 | |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5418 | if (enable_cl73) { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5419 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5420 | MDIO_REG_BANK_CL73_IEEEB0, |
| 5421 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL, |
| 5422 | &mii_control); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5423 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5424 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5425 | MDIO_REG_BANK_CL73_IEEEB0, |
| 5426 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL, |
| 5427 | (mii_control | |
| 5428 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL_AN_EN | |
| 5429 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL_RESTART_AN)); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5430 | } else { |
| 5431 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5432 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5433 | MDIO_REG_BANK_COMBO_IEEE0, |
| 5434 | MDIO_COMBO_IEEE0_MII_CONTROL, |
| 5435 | &mii_control); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5436 | DP(NETIF_MSG_LINK, |
| 5437 | "bnx2x_restart_autoneg mii_control before = 0x%x\n", |
| 5438 | mii_control); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5439 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5440 | MDIO_REG_BANK_COMBO_IEEE0, |
| 5441 | MDIO_COMBO_IEEE0_MII_CONTROL, |
| 5442 | (mii_control | |
| 5443 | MDIO_COMBO_IEEO_MII_CONTROL_AN_EN | |
| 5444 | MDIO_COMBO_IEEO_MII_CONTROL_RESTART_AN)); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5445 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5446 | } |
| 5447 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 5448 | static void bnx2x_initialize_sgmii_process(struct bnx2x_phy *phy, |
| 5449 | struct link_params *params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5450 | struct link_vars *vars) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5451 | { |
| 5452 | struct bnx2x *bp = params->bp; |
| 5453 | u16 control1; |
| 5454 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 5455 | /* In SGMII mode, the unicore is always slave */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5456 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5457 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5458 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 5459 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL1, |
| 5460 | &control1); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5461 | control1 |= MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_INVERT_SIGNAL_DETECT; |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 5462 | /* Set sgmii mode (and not fiber) */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5463 | control1 &= ~(MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_FIBER_MODE | |
| 5464 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_AUTODET | |
| 5465 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_MSTR_MODE); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5466 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5467 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 5468 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL1, |
| 5469 | control1); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5470 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 5471 | /* If forced speed */ |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 5472 | if (!(vars->line_speed == SPEED_AUTO_NEG)) { |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 5473 | /* Set speed, disable autoneg */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5474 | u16 mii_control; |
| 5475 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5476 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5477 | MDIO_REG_BANK_COMBO_IEEE0, |
| 5478 | MDIO_COMBO_IEEE0_MII_CONTROL, |
| 5479 | &mii_control); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5480 | mii_control &= ~(MDIO_COMBO_IEEO_MII_CONTROL_AN_EN | |
| 5481 | MDIO_COMBO_IEEO_MII_CONTROL_MAN_SGMII_SP_MASK| |
| 5482 | MDIO_COMBO_IEEO_MII_CONTROL_FULL_DUPLEX); |
| 5483 | |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 5484 | switch (vars->line_speed) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5485 | case SPEED_100: |
| 5486 | mii_control |= |
| 5487 | MDIO_COMBO_IEEO_MII_CONTROL_MAN_SGMII_SP_100; |
| 5488 | break; |
| 5489 | case SPEED_1000: |
| 5490 | mii_control |= |
| 5491 | MDIO_COMBO_IEEO_MII_CONTROL_MAN_SGMII_SP_1000; |
| 5492 | break; |
| 5493 | case SPEED_10: |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 5494 | /* There is nothing to set for 10M */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5495 | break; |
| 5496 | default: |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 5497 | /* Invalid speed for SGMII */ |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 5498 | DP(NETIF_MSG_LINK, "Invalid line_speed 0x%x\n", |
| 5499 | vars->line_speed); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5500 | break; |
| 5501 | } |
| 5502 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 5503 | /* Setting the full duplex */ |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 5504 | if (phy->req_duplex == DUPLEX_FULL) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5505 | mii_control |= |
| 5506 | MDIO_COMBO_IEEO_MII_CONTROL_FULL_DUPLEX; |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5507 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5508 | MDIO_REG_BANK_COMBO_IEEE0, |
| 5509 | MDIO_COMBO_IEEE0_MII_CONTROL, |
| 5510 | mii_control); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5511 | |
| 5512 | } else { /* AN mode */ |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 5513 | /* Enable and restart AN */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 5514 | bnx2x_restart_autoneg(phy, params, 0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5515 | } |
| 5516 | } |
| 5517 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 5518 | /* Link management |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5519 | */ |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 5520 | static int bnx2x_direct_parallel_detect_used(struct bnx2x_phy *phy, |
| 5521 | struct link_params *params) |
Yaniv Rosner | 15ddd2d | 2009-11-05 19:18:12 +0200 | [diff] [blame] | 5522 | { |
| 5523 | struct bnx2x *bp = params->bp; |
| 5524 | u16 pd_10g, status2_1000x; |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 5525 | if (phy->req_line_speed != SPEED_AUTO_NEG) |
| 5526 | return 0; |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5527 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5528 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 5529 | MDIO_SERDES_DIGITAL_A_1000X_STATUS2, |
| 5530 | &status2_1000x); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5531 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5532 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 5533 | MDIO_SERDES_DIGITAL_A_1000X_STATUS2, |
| 5534 | &status2_1000x); |
Yaniv Rosner | 15ddd2d | 2009-11-05 19:18:12 +0200 | [diff] [blame] | 5535 | if (status2_1000x & MDIO_SERDES_DIGITAL_A_1000X_STATUS2_AN_DISABLED) { |
| 5536 | DP(NETIF_MSG_LINK, "1G parallel detect link on port %d\n", |
| 5537 | params->port); |
| 5538 | return 1; |
| 5539 | } |
| 5540 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5541 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5542 | MDIO_REG_BANK_10G_PARALLEL_DETECT, |
| 5543 | MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_STATUS, |
| 5544 | &pd_10g); |
Yaniv Rosner | 15ddd2d | 2009-11-05 19:18:12 +0200 | [diff] [blame] | 5545 | |
| 5546 | if (pd_10g & MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_STATUS_PD_LINK) { |
| 5547 | DP(NETIF_MSG_LINK, "10G parallel detect link on port %d\n", |
| 5548 | params->port); |
| 5549 | return 1; |
| 5550 | } |
| 5551 | return 0; |
| 5552 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5553 | |
Mintz Yuval | 9e7e839 | 2012-02-15 02:10:24 +0000 | [diff] [blame] | 5554 | static void bnx2x_update_adv_fc(struct bnx2x_phy *phy, |
| 5555 | struct link_params *params, |
| 5556 | struct link_vars *vars, |
| 5557 | u32 gp_status) |
| 5558 | { |
| 5559 | u16 ld_pause; /* local driver */ |
| 5560 | u16 lp_pause; /* link partner */ |
| 5561 | u16 pause_result; |
| 5562 | struct bnx2x *bp = params->bp; |
| 5563 | if ((gp_status & |
| 5564 | (MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_AUTONEG_COMPLETE | |
| 5565 | MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_MR_LP_NP_AN_ABLE)) == |
| 5566 | (MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_AUTONEG_COMPLETE | |
| 5567 | MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_MR_LP_NP_AN_ABLE)) { |
| 5568 | |
| 5569 | CL22_RD_OVER_CL45(bp, phy, |
| 5570 | MDIO_REG_BANK_CL73_IEEEB1, |
| 5571 | MDIO_CL73_IEEEB1_AN_ADV1, |
| 5572 | &ld_pause); |
| 5573 | CL22_RD_OVER_CL45(bp, phy, |
| 5574 | MDIO_REG_BANK_CL73_IEEEB1, |
| 5575 | MDIO_CL73_IEEEB1_AN_LP_ADV1, |
| 5576 | &lp_pause); |
| 5577 | pause_result = (ld_pause & |
| 5578 | MDIO_CL73_IEEEB1_AN_ADV1_PAUSE_MASK) >> 8; |
| 5579 | pause_result |= (lp_pause & |
| 5580 | MDIO_CL73_IEEEB1_AN_LP_ADV1_PAUSE_MASK) >> 10; |
| 5581 | DP(NETIF_MSG_LINK, "pause_result CL73 0x%x\n", pause_result); |
| 5582 | } else { |
| 5583 | CL22_RD_OVER_CL45(bp, phy, |
| 5584 | MDIO_REG_BANK_COMBO_IEEE0, |
| 5585 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV, |
| 5586 | &ld_pause); |
| 5587 | CL22_RD_OVER_CL45(bp, phy, |
| 5588 | MDIO_REG_BANK_COMBO_IEEE0, |
| 5589 | MDIO_COMBO_IEEE0_AUTO_NEG_LINK_PARTNER_ABILITY1, |
| 5590 | &lp_pause); |
| 5591 | pause_result = (ld_pause & |
| 5592 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_MASK)>>5; |
| 5593 | pause_result |= (lp_pause & |
| 5594 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_MASK)>>7; |
| 5595 | DP(NETIF_MSG_LINK, "pause_result CL37 0x%x\n", pause_result); |
| 5596 | } |
| 5597 | bnx2x_pause_resolve(vars, pause_result); |
| 5598 | |
| 5599 | } |
| 5600 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 5601 | static void bnx2x_flow_ctrl_resolve(struct bnx2x_phy *phy, |
| 5602 | struct link_params *params, |
| 5603 | struct link_vars *vars, |
| 5604 | u32 gp_status) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5605 | { |
| 5606 | struct bnx2x *bp = params->bp; |
David S. Miller | c0700f9 | 2008-12-16 23:53:20 -0800 | [diff] [blame] | 5607 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5608 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 5609 | /* Resolve from gp_status in case of AN complete and not sgmii */ |
Mintz Yuval | 9e7e839 | 2012-02-15 02:10:24 +0000 | [diff] [blame] | 5610 | if (phy->req_flow_ctrl != BNX2X_FLOW_CTRL_AUTO) { |
| 5611 | /* Update the advertised flow-controled of LD/LP in AN */ |
| 5612 | if (phy->req_line_speed == SPEED_AUTO_NEG) |
| 5613 | bnx2x_update_adv_fc(phy, params, vars, gp_status); |
| 5614 | /* But set the flow-control result as the requested one */ |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 5615 | vars->flow_ctrl = phy->req_flow_ctrl; |
Mintz Yuval | 9e7e839 | 2012-02-15 02:10:24 +0000 | [diff] [blame] | 5616 | } else if (phy->req_line_speed != SPEED_AUTO_NEG) |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 5617 | vars->flow_ctrl = params->req_fc_auto_adv; |
| 5618 | else if ((gp_status & MDIO_AN_CL73_OR_37_COMPLETE) && |
| 5619 | (!(vars->phy_flags & PHY_SGMII_FLAG))) { |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 5620 | if (bnx2x_direct_parallel_detect_used(phy, params)) { |
Yaniv Rosner | 15ddd2d | 2009-11-05 19:18:12 +0200 | [diff] [blame] | 5621 | vars->flow_ctrl = params->req_fc_auto_adv; |
| 5622 | return; |
| 5623 | } |
Mintz Yuval | 9e7e839 | 2012-02-15 02:10:24 +0000 | [diff] [blame] | 5624 | bnx2x_update_adv_fc(phy, params, vars, gp_status); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5625 | } |
| 5626 | DP(NETIF_MSG_LINK, "flow_ctrl 0x%x\n", vars->flow_ctrl); |
| 5627 | } |
| 5628 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 5629 | static void bnx2x_check_fallback_to_cl37(struct bnx2x_phy *phy, |
| 5630 | struct link_params *params) |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5631 | { |
| 5632 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 9045f6b4 | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 5633 | u16 rx_status, ustat_val, cl37_fsm_received; |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5634 | DP(NETIF_MSG_LINK, "bnx2x_check_fallback_to_cl37\n"); |
| 5635 | /* Step 1: Make sure signal is detected */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5636 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5637 | MDIO_REG_BANK_RX0, |
| 5638 | MDIO_RX0_RX_STATUS, |
| 5639 | &rx_status); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5640 | if ((rx_status & MDIO_RX0_RX_STATUS_SIGDET) != |
| 5641 | (MDIO_RX0_RX_STATUS_SIGDET)) { |
| 5642 | DP(NETIF_MSG_LINK, "Signal is not detected. Restoring CL73." |
| 5643 | "rx_status(0x80b0) = 0x%x\n", rx_status); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5644 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5645 | MDIO_REG_BANK_CL73_IEEEB0, |
| 5646 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL, |
| 5647 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL_AN_EN); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5648 | return; |
| 5649 | } |
| 5650 | /* Step 2: Check CL73 state machine */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5651 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5652 | MDIO_REG_BANK_CL73_USERB0, |
| 5653 | MDIO_CL73_USERB0_CL73_USTAT1, |
| 5654 | &ustat_val); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5655 | if ((ustat_val & |
| 5656 | (MDIO_CL73_USERB0_CL73_USTAT1_LINK_STATUS_CHECK | |
| 5657 | MDIO_CL73_USERB0_CL73_USTAT1_AN_GOOD_CHECK_BAM37)) != |
| 5658 | (MDIO_CL73_USERB0_CL73_USTAT1_LINK_STATUS_CHECK | |
| 5659 | MDIO_CL73_USERB0_CL73_USTAT1_AN_GOOD_CHECK_BAM37)) { |
| 5660 | DP(NETIF_MSG_LINK, "CL73 state-machine is not stable. " |
| 5661 | "ustat_val(0x8371) = 0x%x\n", ustat_val); |
| 5662 | return; |
| 5663 | } |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 5664 | /* Step 3: Check CL37 Message Pages received to indicate LP |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5665 | * supports only CL37 |
| 5666 | */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5667 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5668 | MDIO_REG_BANK_REMOTE_PHY, |
| 5669 | MDIO_REMOTE_PHY_MISC_RX_STATUS, |
Yaniv Rosner | 9045f6b4 | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 5670 | &cl37_fsm_received); |
| 5671 | if ((cl37_fsm_received & |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5672 | (MDIO_REMOTE_PHY_MISC_RX_STATUS_CL37_FSM_RECEIVED_OVER1G_MSG | |
| 5673 | MDIO_REMOTE_PHY_MISC_RX_STATUS_CL37_FSM_RECEIVED_BRCM_OUI_MSG)) != |
| 5674 | (MDIO_REMOTE_PHY_MISC_RX_STATUS_CL37_FSM_RECEIVED_OVER1G_MSG | |
| 5675 | MDIO_REMOTE_PHY_MISC_RX_STATUS_CL37_FSM_RECEIVED_BRCM_OUI_MSG)) { |
| 5676 | DP(NETIF_MSG_LINK, "No CL37 FSM were received. " |
| 5677 | "misc_rx_status(0x8330) = 0x%x\n", |
Yaniv Rosner | 9045f6b4 | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 5678 | cl37_fsm_received); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5679 | return; |
| 5680 | } |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 5681 | /* The combined cl37/cl73 fsm state information indicating that |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5682 | * we are connected to a device which does not support cl73, but |
| 5683 | * does support cl37 BAM. In this case we disable cl73 and |
| 5684 | * restart cl37 auto-neg |
| 5685 | */ |
| 5686 | |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5687 | /* Disable CL73 */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5688 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5689 | MDIO_REG_BANK_CL73_IEEEB0, |
| 5690 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL, |
| 5691 | 0); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5692 | /* Restart CL37 autoneg */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 5693 | bnx2x_restart_autoneg(phy, params, 0); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5694 | DP(NETIF_MSG_LINK, "Disabling CL73, and restarting CL37 autoneg\n"); |
| 5695 | } |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 5696 | |
| 5697 | static void bnx2x_xgxs_an_resolve(struct bnx2x_phy *phy, |
| 5698 | struct link_params *params, |
| 5699 | struct link_vars *vars, |
| 5700 | u32 gp_status) |
| 5701 | { |
| 5702 | if (gp_status & MDIO_AN_CL73_OR_37_COMPLETE) |
| 5703 | vars->link_status |= |
| 5704 | LINK_STATUS_AUTO_NEGOTIATE_COMPLETE; |
| 5705 | |
| 5706 | if (bnx2x_direct_parallel_detect_used(phy, params)) |
| 5707 | vars->link_status |= |
| 5708 | LINK_STATUS_PARALLEL_DETECTION_USED; |
| 5709 | } |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5710 | static int bnx2x_get_link_speed_duplex(struct bnx2x_phy *phy, |
| 5711 | struct link_params *params, |
| 5712 | struct link_vars *vars, |
| 5713 | u16 is_link_up, |
| 5714 | u16 speed_mask, |
| 5715 | u16 is_duplex) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5716 | { |
| 5717 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 5718 | if (phy->req_line_speed == SPEED_AUTO_NEG) |
| 5719 | vars->link_status |= LINK_STATUS_AUTO_NEGOTIATE_ENABLED; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5720 | if (is_link_up) { |
| 5721 | DP(NETIF_MSG_LINK, "phy link up\n"); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5722 | |
| 5723 | vars->phy_link_up = 1; |
| 5724 | vars->link_status |= LINK_STATUS_LINK_UP; |
| 5725 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5726 | switch (speed_mask) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5727 | case GP_STATUS_10M: |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5728 | vars->line_speed = SPEED_10; |
Yaniv Rosner | 430d172 | 2012-09-11 04:34:11 +0000 | [diff] [blame] | 5729 | if (is_duplex == DUPLEX_FULL) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5730 | vars->link_status |= LINK_10TFD; |
| 5731 | else |
| 5732 | vars->link_status |= LINK_10THD; |
| 5733 | break; |
| 5734 | |
| 5735 | case GP_STATUS_100M: |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5736 | vars->line_speed = SPEED_100; |
Yaniv Rosner | 430d172 | 2012-09-11 04:34:11 +0000 | [diff] [blame] | 5737 | if (is_duplex == DUPLEX_FULL) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5738 | vars->link_status |= LINK_100TXFD; |
| 5739 | else |
| 5740 | vars->link_status |= LINK_100TXHD; |
| 5741 | break; |
| 5742 | |
| 5743 | case GP_STATUS_1G: |
| 5744 | case GP_STATUS_1G_KX: |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5745 | vars->line_speed = SPEED_1000; |
Yaniv Rosner | 430d172 | 2012-09-11 04:34:11 +0000 | [diff] [blame] | 5746 | if (is_duplex == DUPLEX_FULL) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5747 | vars->link_status |= LINK_1000TFD; |
| 5748 | else |
| 5749 | vars->link_status |= LINK_1000THD; |
| 5750 | break; |
| 5751 | |
| 5752 | case GP_STATUS_2_5G: |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5753 | vars->line_speed = SPEED_2500; |
Yaniv Rosner | 430d172 | 2012-09-11 04:34:11 +0000 | [diff] [blame] | 5754 | if (is_duplex == DUPLEX_FULL) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5755 | vars->link_status |= LINK_2500TFD; |
| 5756 | else |
| 5757 | vars->link_status |= LINK_2500THD; |
| 5758 | break; |
| 5759 | |
| 5760 | case GP_STATUS_5G: |
| 5761 | case GP_STATUS_6G: |
| 5762 | DP(NETIF_MSG_LINK, |
| 5763 | "link speed unsupported gp_status 0x%x\n", |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5764 | speed_mask); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5765 | return -EINVAL; |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 5766 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5767 | case GP_STATUS_10G_KX4: |
| 5768 | case GP_STATUS_10G_HIG: |
| 5769 | case GP_STATUS_10G_CX4: |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5770 | case GP_STATUS_10G_KR: |
| 5771 | case GP_STATUS_10G_SFI: |
| 5772 | case GP_STATUS_10G_XFI: |
| 5773 | vars->line_speed = SPEED_10000; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5774 | vars->link_status |= LINK_10GTFD; |
| 5775 | break; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5776 | case GP_STATUS_20G_DXGXS: |
| 5777 | vars->line_speed = SPEED_20000; |
| 5778 | vars->link_status |= LINK_20GTFD; |
| 5779 | break; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5780 | default: |
| 5781 | DP(NETIF_MSG_LINK, |
| 5782 | "link speed unsupported gp_status 0x%x\n", |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5783 | speed_mask); |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 5784 | return -EINVAL; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5785 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5786 | } else { /* link_down */ |
| 5787 | DP(NETIF_MSG_LINK, "phy link down\n"); |
| 5788 | |
| 5789 | vars->phy_link_up = 0; |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 5790 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5791 | vars->duplex = DUPLEX_FULL; |
David S. Miller | c0700f9 | 2008-12-16 23:53:20 -0800 | [diff] [blame] | 5792 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5793 | vars->mac_type = MAC_TYPE_NONE; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5794 | } |
| 5795 | DP(NETIF_MSG_LINK, " phy_link_up %x line_speed %d\n", |
| 5796 | vars->phy_link_up, vars->line_speed); |
| 5797 | return 0; |
| 5798 | } |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5799 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5800 | static int bnx2x_link_settings_status(struct bnx2x_phy *phy, |
| 5801 | struct link_params *params, |
| 5802 | struct link_vars *vars) |
| 5803 | { |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5804 | struct bnx2x *bp = params->bp; |
| 5805 | |
| 5806 | u16 gp_status, duplex = DUPLEX_HALF, link_up = 0, speed_mask; |
| 5807 | int rc = 0; |
| 5808 | |
| 5809 | /* Read gp_status */ |
| 5810 | CL22_RD_OVER_CL45(bp, phy, |
| 5811 | MDIO_REG_BANK_GP_STATUS, |
| 5812 | MDIO_GP_STATUS_TOP_AN_STATUS1, |
| 5813 | &gp_status); |
| 5814 | if (gp_status & MDIO_GP_STATUS_TOP_AN_STATUS1_DUPLEX_STATUS) |
| 5815 | duplex = DUPLEX_FULL; |
| 5816 | if (gp_status & MDIO_GP_STATUS_TOP_AN_STATUS1_LINK_STATUS) |
| 5817 | link_up = 1; |
| 5818 | speed_mask = gp_status & GP_STATUS_SPEED_MASK; |
| 5819 | DP(NETIF_MSG_LINK, "gp_status 0x%x, is_link_up %d, speed_mask 0x%x\n", |
| 5820 | gp_status, link_up, speed_mask); |
| 5821 | rc = bnx2x_get_link_speed_duplex(phy, params, vars, link_up, speed_mask, |
| 5822 | duplex); |
| 5823 | if (rc == -EINVAL) |
| 5824 | return rc; |
| 5825 | |
| 5826 | if (gp_status & MDIO_GP_STATUS_TOP_AN_STATUS1_LINK_STATUS) { |
| 5827 | if (SINGLE_MEDIA_DIRECT(params)) { |
Yaniv Rosner | 430d172 | 2012-09-11 04:34:11 +0000 | [diff] [blame] | 5828 | vars->duplex = duplex; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5829 | bnx2x_flow_ctrl_resolve(phy, params, vars, gp_status); |
| 5830 | if (phy->req_line_speed == SPEED_AUTO_NEG) |
| 5831 | bnx2x_xgxs_an_resolve(phy, params, vars, |
| 5832 | gp_status); |
| 5833 | } |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 5834 | } else { /* Link_down */ |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 5835 | if ((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 5836 | SINGLE_MEDIA_DIRECT(params)) { |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5837 | /* Check signal is detected */ |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 5838 | bnx2x_check_fallback_to_cl37(phy, params); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5839 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5840 | } |
| 5841 | |
Mintz Yuval | 9e7e839 | 2012-02-15 02:10:24 +0000 | [diff] [blame] | 5842 | /* Read LP advertised speeds*/ |
| 5843 | if (SINGLE_MEDIA_DIRECT(params) && |
| 5844 | (vars->link_status & LINK_STATUS_AUTO_NEGOTIATE_COMPLETE)) { |
| 5845 | u16 val; |
| 5846 | |
| 5847 | CL22_RD_OVER_CL45(bp, phy, MDIO_REG_BANK_CL73_IEEEB1, |
| 5848 | MDIO_CL73_IEEEB1_AN_LP_ADV2, &val); |
| 5849 | |
| 5850 | if (val & MDIO_CL73_IEEEB1_AN_ADV2_ADVR_1000M_KX) |
| 5851 | vars->link_status |= |
| 5852 | LINK_STATUS_LINK_PARTNER_1000TFD_CAPABLE; |
| 5853 | if (val & (MDIO_CL73_IEEEB1_AN_ADV2_ADVR_10G_KX4 | |
| 5854 | MDIO_CL73_IEEEB1_AN_ADV2_ADVR_10G_KR)) |
| 5855 | vars->link_status |= |
| 5856 | LINK_STATUS_LINK_PARTNER_10GXFD_CAPABLE; |
| 5857 | |
| 5858 | CL22_RD_OVER_CL45(bp, phy, MDIO_REG_BANK_OVER_1G, |
| 5859 | MDIO_OVER_1G_LP_UP1, &val); |
| 5860 | |
| 5861 | if (val & MDIO_OVER_1G_UP1_2_5G) |
| 5862 | vars->link_status |= |
| 5863 | LINK_STATUS_LINK_PARTNER_2500XFD_CAPABLE; |
| 5864 | if (val & (MDIO_OVER_1G_UP1_10G | MDIO_OVER_1G_UP1_10GH)) |
| 5865 | vars->link_status |= |
| 5866 | LINK_STATUS_LINK_PARTNER_10GXFD_CAPABLE; |
| 5867 | } |
| 5868 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5869 | DP(NETIF_MSG_LINK, "duplex %x flow_ctrl 0x%x link_status 0x%x\n", |
| 5870 | vars->duplex, vars->flow_ctrl, vars->link_status); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5871 | return rc; |
| 5872 | } |
| 5873 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5874 | static int bnx2x_warpcore_read_status(struct bnx2x_phy *phy, |
| 5875 | struct link_params *params, |
| 5876 | struct link_vars *vars) |
| 5877 | { |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5878 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5879 | u8 lane; |
| 5880 | u16 gp_status1, gp_speed, link_up, duplex = DUPLEX_FULL; |
| 5881 | int rc = 0; |
| 5882 | lane = bnx2x_get_warpcore_lane(phy, params); |
| 5883 | /* Read gp_status */ |
| 5884 | if (phy->req_line_speed > SPEED_10000) { |
| 5885 | u16 temp_link_up; |
| 5886 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 5887 | 1, &temp_link_up); |
| 5888 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 5889 | 1, &link_up); |
| 5890 | DP(NETIF_MSG_LINK, "PCS RX link status = 0x%x-->0x%x\n", |
| 5891 | temp_link_up, link_up); |
| 5892 | link_up &= (1<<2); |
| 5893 | if (link_up) |
| 5894 | bnx2x_ext_phy_resolve_fc(phy, params, vars); |
| 5895 | } else { |
| 5896 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 5897 | MDIO_WC_REG_GP2_STATUS_GP_2_1, &gp_status1); |
| 5898 | DP(NETIF_MSG_LINK, "0x81d1 = 0x%x\n", gp_status1); |
| 5899 | /* Check for either KR or generic link up. */ |
| 5900 | gp_status1 = ((gp_status1 >> 8) & 0xf) | |
| 5901 | ((gp_status1 >> 12) & 0xf); |
| 5902 | link_up = gp_status1 & (1 << lane); |
| 5903 | if (link_up && SINGLE_MEDIA_DIRECT(params)) { |
| 5904 | u16 pd, gp_status4; |
| 5905 | if (phy->req_line_speed == SPEED_AUTO_NEG) { |
| 5906 | /* Check Autoneg complete */ |
| 5907 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 5908 | MDIO_WC_REG_GP2_STATUS_GP_2_4, |
| 5909 | &gp_status4); |
| 5910 | if (gp_status4 & ((1<<12)<<lane)) |
| 5911 | vars->link_status |= |
| 5912 | LINK_STATUS_AUTO_NEGOTIATE_COMPLETE; |
| 5913 | |
| 5914 | /* Check parallel detect used */ |
| 5915 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 5916 | MDIO_WC_REG_PAR_DET_10G_STATUS, |
| 5917 | &pd); |
| 5918 | if (pd & (1<<15)) |
| 5919 | vars->link_status |= |
| 5920 | LINK_STATUS_PARALLEL_DETECTION_USED; |
| 5921 | } |
| 5922 | bnx2x_ext_phy_resolve_fc(phy, params, vars); |
Yaniv Rosner | 430d172 | 2012-09-11 04:34:11 +0000 | [diff] [blame] | 5923 | vars->duplex = duplex; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5924 | } |
| 5925 | } |
| 5926 | |
Mintz Yuval | 9e7e839 | 2012-02-15 02:10:24 +0000 | [diff] [blame] | 5927 | if ((vars->link_status & LINK_STATUS_AUTO_NEGOTIATE_COMPLETE) && |
| 5928 | SINGLE_MEDIA_DIRECT(params)) { |
| 5929 | u16 val; |
| 5930 | |
| 5931 | bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD, |
| 5932 | MDIO_AN_REG_LP_AUTO_NEG2, &val); |
| 5933 | |
| 5934 | if (val & MDIO_CL73_IEEEB1_AN_ADV2_ADVR_1000M_KX) |
| 5935 | vars->link_status |= |
| 5936 | LINK_STATUS_LINK_PARTNER_1000TFD_CAPABLE; |
| 5937 | if (val & (MDIO_CL73_IEEEB1_AN_ADV2_ADVR_10G_KX4 | |
| 5938 | MDIO_CL73_IEEEB1_AN_ADV2_ADVR_10G_KR)) |
| 5939 | vars->link_status |= |
| 5940 | LINK_STATUS_LINK_PARTNER_10GXFD_CAPABLE; |
| 5941 | |
| 5942 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 5943 | MDIO_WC_REG_DIGITAL3_LP_UP1, &val); |
| 5944 | |
| 5945 | if (val & MDIO_OVER_1G_UP1_2_5G) |
| 5946 | vars->link_status |= |
| 5947 | LINK_STATUS_LINK_PARTNER_2500XFD_CAPABLE; |
| 5948 | if (val & (MDIO_OVER_1G_UP1_10G | MDIO_OVER_1G_UP1_10GH)) |
| 5949 | vars->link_status |= |
| 5950 | LINK_STATUS_LINK_PARTNER_10GXFD_CAPABLE; |
| 5951 | |
| 5952 | } |
| 5953 | |
| 5954 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5955 | if (lane < 2) { |
| 5956 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 5957 | MDIO_WC_REG_GP2_STATUS_GP_2_2, &gp_speed); |
| 5958 | } else { |
| 5959 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 5960 | MDIO_WC_REG_GP2_STATUS_GP_2_3, &gp_speed); |
| 5961 | } |
| 5962 | DP(NETIF_MSG_LINK, "lane %d gp_speed 0x%x\n", lane, gp_speed); |
| 5963 | |
| 5964 | if ((lane & 1) == 0) |
| 5965 | gp_speed <<= 8; |
| 5966 | gp_speed &= 0x3f00; |
| 5967 | |
| 5968 | |
| 5969 | rc = bnx2x_get_link_speed_duplex(phy, params, vars, link_up, gp_speed, |
| 5970 | duplex); |
| 5971 | |
| 5972 | DP(NETIF_MSG_LINK, "duplex %x flow_ctrl 0x%x link_status 0x%x\n", |
| 5973 | vars->duplex, vars->flow_ctrl, vars->link_status); |
| 5974 | return rc; |
| 5975 | } |
Eilon Greenstein | ed8680a | 2009-02-12 08:37:12 +0000 | [diff] [blame] | 5976 | static void bnx2x_set_gmii_tx_driver(struct link_params *params) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5977 | { |
| 5978 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 5979 | struct bnx2x_phy *phy = ¶ms->phy[INT_PHY]; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5980 | u16 lp_up2; |
| 5981 | u16 tx_driver; |
Eilon Greenstein | c2c8b03 | 2009-02-12 08:37:14 +0000 | [diff] [blame] | 5982 | u16 bank; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5983 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 5984 | /* Read precomp */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5985 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5986 | MDIO_REG_BANK_OVER_1G, |
| 5987 | MDIO_OVER_1G_LP_UP2, &lp_up2); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5988 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 5989 | /* Bits [10:7] at lp_up2, positioned at [15:12] */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5990 | lp_up2 = (((lp_up2 & MDIO_OVER_1G_LP_UP2_PREEMPHASIS_MASK) >> |
| 5991 | MDIO_OVER_1G_LP_UP2_PREEMPHASIS_SHIFT) << |
| 5992 | MDIO_TX0_TX_DRIVER_PREEMPHASIS_SHIFT); |
| 5993 | |
Eilon Greenstein | c2c8b03 | 2009-02-12 08:37:14 +0000 | [diff] [blame] | 5994 | if (lp_up2 == 0) |
| 5995 | return; |
| 5996 | |
| 5997 | for (bank = MDIO_REG_BANK_TX0; bank <= MDIO_REG_BANK_TX3; |
| 5998 | bank += (MDIO_REG_BANK_TX1 - MDIO_REG_BANK_TX0)) { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5999 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6000 | bank, |
| 6001 | MDIO_TX0_TX_DRIVER, &tx_driver); |
Eilon Greenstein | c2c8b03 | 2009-02-12 08:37:14 +0000 | [diff] [blame] | 6002 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 6003 | /* Replace tx_driver bits [15:12] */ |
Eilon Greenstein | c2c8b03 | 2009-02-12 08:37:14 +0000 | [diff] [blame] | 6004 | if (lp_up2 != |
| 6005 | (tx_driver & MDIO_TX0_TX_DRIVER_PREEMPHASIS_MASK)) { |
| 6006 | tx_driver &= ~MDIO_TX0_TX_DRIVER_PREEMPHASIS_MASK; |
| 6007 | tx_driver |= lp_up2; |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 6008 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6009 | bank, |
| 6010 | MDIO_TX0_TX_DRIVER, tx_driver); |
Eilon Greenstein | c2c8b03 | 2009-02-12 08:37:14 +0000 | [diff] [blame] | 6011 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6012 | } |
| 6013 | } |
| 6014 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6015 | static int bnx2x_emac_program(struct link_params *params, |
| 6016 | struct link_vars *vars) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6017 | { |
| 6018 | struct bnx2x *bp = params->bp; |
| 6019 | u8 port = params->port; |
| 6020 | u16 mode = 0; |
| 6021 | |
| 6022 | DP(NETIF_MSG_LINK, "setting link speed & duplex\n"); |
| 6023 | bnx2x_bits_dis(bp, GRCBASE_EMAC0 + port*0x400 + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6024 | EMAC_REG_EMAC_MODE, |
| 6025 | (EMAC_MODE_25G_MODE | |
| 6026 | EMAC_MODE_PORT_MII_10M | |
| 6027 | EMAC_MODE_HALF_DUPLEX)); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6028 | switch (vars->line_speed) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6029 | case SPEED_10: |
| 6030 | mode |= EMAC_MODE_PORT_MII_10M; |
| 6031 | break; |
| 6032 | |
| 6033 | case SPEED_100: |
| 6034 | mode |= EMAC_MODE_PORT_MII; |
| 6035 | break; |
| 6036 | |
| 6037 | case SPEED_1000: |
| 6038 | mode |= EMAC_MODE_PORT_GMII; |
| 6039 | break; |
| 6040 | |
| 6041 | case SPEED_2500: |
| 6042 | mode |= (EMAC_MODE_25G_MODE | EMAC_MODE_PORT_GMII); |
| 6043 | break; |
| 6044 | |
| 6045 | default: |
| 6046 | /* 10G not valid for EMAC */ |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6047 | DP(NETIF_MSG_LINK, "Invalid line_speed 0x%x\n", |
| 6048 | vars->line_speed); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6049 | return -EINVAL; |
| 6050 | } |
| 6051 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6052 | if (vars->duplex == DUPLEX_HALF) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6053 | mode |= EMAC_MODE_HALF_DUPLEX; |
| 6054 | bnx2x_bits_en(bp, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6055 | GRCBASE_EMAC0 + port*0x400 + EMAC_REG_EMAC_MODE, |
| 6056 | mode); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6057 | |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6058 | bnx2x_set_led(params, vars, LED_MODE_OPER, vars->line_speed); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6059 | return 0; |
| 6060 | } |
| 6061 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6062 | static void bnx2x_set_preemphasis(struct bnx2x_phy *phy, |
| 6063 | struct link_params *params) |
| 6064 | { |
| 6065 | |
| 6066 | u16 bank, i = 0; |
| 6067 | struct bnx2x *bp = params->bp; |
| 6068 | |
| 6069 | for (bank = MDIO_REG_BANK_RX0, i = 0; bank <= MDIO_REG_BANK_RX3; |
| 6070 | bank += (MDIO_REG_BANK_RX1-MDIO_REG_BANK_RX0), i++) { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 6071 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6072 | bank, |
| 6073 | MDIO_RX0_RX_EQ_BOOST, |
| 6074 | phy->rx_preemphasis[i]); |
| 6075 | } |
| 6076 | |
| 6077 | for (bank = MDIO_REG_BANK_TX0, i = 0; bank <= MDIO_REG_BANK_TX3; |
| 6078 | bank += (MDIO_REG_BANK_TX1 - MDIO_REG_BANK_TX0), i++) { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 6079 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6080 | bank, |
| 6081 | MDIO_TX0_TX_DRIVER, |
| 6082 | phy->tx_preemphasis[i]); |
| 6083 | } |
| 6084 | } |
| 6085 | |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 6086 | static void bnx2x_xgxs_config_init(struct bnx2x_phy *phy, |
| 6087 | struct link_params *params, |
| 6088 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6089 | { |
| 6090 | struct bnx2x *bp = params->bp; |
| 6091 | u8 enable_cl73 = (SINGLE_MEDIA_DIRECT(params) || |
| 6092 | (params->loopback_mode == LOOPBACK_XGXS)); |
| 6093 | if (!(vars->phy_flags & PHY_SGMII_FLAG)) { |
| 6094 | if (SINGLE_MEDIA_DIRECT(params) && |
| 6095 | (params->feature_config_flags & |
| 6096 | FEATURE_CONFIG_OVERRIDE_PREEMPHASIS_ENABLED)) |
| 6097 | bnx2x_set_preemphasis(phy, params); |
| 6098 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 6099 | /* Forced speed requested? */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6100 | if (vars->line_speed != SPEED_AUTO_NEG || |
| 6101 | (SINGLE_MEDIA_DIRECT(params) && |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6102 | params->loopback_mode == LOOPBACK_EXT)) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6103 | DP(NETIF_MSG_LINK, "not SGMII, no AN\n"); |
| 6104 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 6105 | /* Disable autoneg */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6106 | bnx2x_set_autoneg(phy, params, vars, 0); |
| 6107 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 6108 | /* Program speed and duplex */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6109 | bnx2x_program_serdes(phy, params, vars); |
| 6110 | |
| 6111 | } else { /* AN_mode */ |
| 6112 | DP(NETIF_MSG_LINK, "not SGMII, AN\n"); |
| 6113 | |
| 6114 | /* AN enabled */ |
Yaniv Rosner | 9045f6b4 | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 6115 | bnx2x_set_brcm_cl37_advertisement(phy, params); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6116 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 6117 | /* Program duplex & pause advertisement (for aneg) */ |
Yaniv Rosner | 9045f6b4 | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 6118 | bnx2x_set_ieee_aneg_advertisement(phy, params, |
| 6119 | vars->ieee_fc); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6120 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 6121 | /* Enable autoneg */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6122 | bnx2x_set_autoneg(phy, params, vars, enable_cl73); |
| 6123 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 6124 | /* Enable and restart AN */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6125 | bnx2x_restart_autoneg(phy, params, enable_cl73); |
| 6126 | } |
| 6127 | |
| 6128 | } else { /* SGMII mode */ |
| 6129 | DP(NETIF_MSG_LINK, "SGMII\n"); |
| 6130 | |
| 6131 | bnx2x_initialize_sgmii_process(phy, params, vars); |
| 6132 | } |
| 6133 | } |
| 6134 | |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 6135 | static int bnx2x_prepare_xgxs(struct bnx2x_phy *phy, |
| 6136 | struct link_params *params, |
| 6137 | struct link_vars *vars) |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6138 | { |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6139 | int rc; |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 6140 | vars->phy_flags |= PHY_XGXS_FLAG; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6141 | if ((phy->req_line_speed && |
| 6142 | ((phy->req_line_speed == SPEED_100) || |
| 6143 | (phy->req_line_speed == SPEED_10))) || |
| 6144 | (!phy->req_line_speed && |
| 6145 | (phy->speed_cap_mask >= |
| 6146 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_FULL) && |
| 6147 | (phy->speed_cap_mask < |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 6148 | PORT_HW_CFG_SPEED_CAPABILITY_D0_1G)) || |
| 6149 | (phy->type == PORT_HW_CFG_SERDES_EXT_PHY_TYPE_DIRECT_SD)) |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6150 | vars->phy_flags |= PHY_SGMII_FLAG; |
| 6151 | else |
| 6152 | vars->phy_flags &= ~PHY_SGMII_FLAG; |
| 6153 | |
| 6154 | bnx2x_calc_ieee_aneg_adv(phy, params, &vars->ieee_fc); |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 6155 | bnx2x_set_aer_mmd(params, phy); |
| 6156 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT) |
| 6157 | bnx2x_set_master_ln(params, phy); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6158 | |
| 6159 | rc = bnx2x_reset_unicore(params, phy, 0); |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 6160 | /* Reset the SerDes and wait for reset bit return low */ |
| 6161 | if (rc) |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6162 | return rc; |
| 6163 | |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 6164 | bnx2x_set_aer_mmd(params, phy); |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 6165 | /* Setting the masterLn_def again after the reset */ |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 6166 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT) { |
| 6167 | bnx2x_set_master_ln(params, phy); |
| 6168 | bnx2x_set_swap_lanes(params, phy); |
| 6169 | } |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6170 | |
| 6171 | return rc; |
| 6172 | } |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 6173 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6174 | static u16 bnx2x_wait_reset_complete(struct bnx2x *bp, |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 6175 | struct bnx2x_phy *phy, |
| 6176 | struct link_params *params) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6177 | { |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6178 | u16 cnt, ctrl; |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 6179 | /* Wait for soft reset to get cleared up to 1 sec */ |
Yaniv Rosner | 62b29a5 | 2010-09-07 11:40:58 +0000 | [diff] [blame] | 6180 | for (cnt = 0; cnt < 1000; cnt++) { |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 6181 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54618SE) |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 6182 | bnx2x_cl22_read(bp, phy, |
| 6183 | MDIO_PMA_REG_CTRL, &ctrl); |
| 6184 | else |
| 6185 | bnx2x_cl45_read(bp, phy, |
| 6186 | MDIO_PMA_DEVAD, |
| 6187 | MDIO_PMA_REG_CTRL, &ctrl); |
Yaniv Rosner | 62b29a5 | 2010-09-07 11:40:58 +0000 | [diff] [blame] | 6188 | if (!(ctrl & (1<<15))) |
| 6189 | break; |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 6190 | usleep_range(1000, 2000); |
Yaniv Rosner | 62b29a5 | 2010-09-07 11:40:58 +0000 | [diff] [blame] | 6191 | } |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 6192 | |
| 6193 | if (cnt == 1000) |
| 6194 | netdev_err(bp->dev, "Warning: PHY was not initialized," |
| 6195 | " Port %d\n", |
| 6196 | params->port); |
Yaniv Rosner | 62b29a5 | 2010-09-07 11:40:58 +0000 | [diff] [blame] | 6197 | DP(NETIF_MSG_LINK, "control reg 0x%x (after %d ms)\n", ctrl, cnt); |
| 6198 | return cnt; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6199 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6200 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6201 | static void bnx2x_link_int_enable(struct link_params *params) |
| 6202 | { |
| 6203 | u8 port = params->port; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6204 | u32 mask; |
| 6205 | struct bnx2x *bp = params->bp; |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 6206 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6207 | /* Setting the status to report on link up for either XGXS or SerDes */ |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6208 | if (CHIP_IS_E3(bp)) { |
| 6209 | mask = NIG_MASK_XGXS0_LINK_STATUS; |
| 6210 | if (!(SINGLE_MEDIA_DIRECT(params))) |
| 6211 | mask |= NIG_MASK_MI_INT; |
| 6212 | } else if (params->switch_cfg == SWITCH_CFG_10G) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6213 | mask = (NIG_MASK_XGXS0_LINK10G | |
| 6214 | NIG_MASK_XGXS0_LINK_STATUS); |
| 6215 | DP(NETIF_MSG_LINK, "enabled XGXS interrupt\n"); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 6216 | if (!(SINGLE_MEDIA_DIRECT(params)) && |
| 6217 | params->phy[INT_PHY].type != |
| 6218 | PORT_HW_CFG_XGXS_EXT_PHY_TYPE_FAILURE) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6219 | mask |= NIG_MASK_MI_INT; |
| 6220 | DP(NETIF_MSG_LINK, "enabled external phy int\n"); |
| 6221 | } |
| 6222 | |
| 6223 | } else { /* SerDes */ |
| 6224 | mask = NIG_MASK_SERDES0_LINK_STATUS; |
| 6225 | DP(NETIF_MSG_LINK, "enabled SerDes interrupt\n"); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 6226 | if (!(SINGLE_MEDIA_DIRECT(params)) && |
| 6227 | params->phy[INT_PHY].type != |
| 6228 | PORT_HW_CFG_SERDES_EXT_PHY_TYPE_NOT_CONN) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6229 | mask |= NIG_MASK_MI_INT; |
| 6230 | DP(NETIF_MSG_LINK, "enabled external phy int\n"); |
| 6231 | } |
| 6232 | } |
| 6233 | bnx2x_bits_en(bp, |
| 6234 | NIG_REG_MASK_INTERRUPT_PORT0 + port*4, |
| 6235 | mask); |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 6236 | |
| 6237 | DP(NETIF_MSG_LINK, "port %x, is_xgxs %x, int_status 0x%x\n", port, |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6238 | (params->switch_cfg == SWITCH_CFG_10G), |
| 6239 | REG_RD(bp, NIG_REG_STATUS_INTERRUPT_PORT0 + port*4)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6240 | DP(NETIF_MSG_LINK, " int_mask 0x%x, MI_INT %x, SERDES_LINK %x\n", |
| 6241 | REG_RD(bp, NIG_REG_MASK_INTERRUPT_PORT0 + port*4), |
| 6242 | REG_RD(bp, NIG_REG_EMAC0_STATUS_MISC_MI_INT + port*0x18), |
| 6243 | REG_RD(bp, NIG_REG_SERDES0_STATUS_LINK_STATUS+port*0x3c)); |
| 6244 | DP(NETIF_MSG_LINK, " 10G %x, XGXS_LINK %x\n", |
| 6245 | REG_RD(bp, NIG_REG_XGXS0_STATUS_LINK10G + port*0x68), |
| 6246 | REG_RD(bp, NIG_REG_XGXS0_STATUS_LINK_STATUS + port*0x68)); |
| 6247 | } |
| 6248 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6249 | static void bnx2x_rearm_latch_signal(struct bnx2x *bp, u8 port, |
| 6250 | u8 exp_mi_int) |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 6251 | { |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6252 | u32 latch_status = 0; |
| 6253 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 6254 | /* Disable the MI INT ( external phy int ) by writing 1 to the |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6255 | * status register. Link down indication is high-active-signal, |
| 6256 | * so in this case we need to write the status to clear the XOR |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 6257 | */ |
| 6258 | /* Read Latched signals */ |
| 6259 | latch_status = REG_RD(bp, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6260 | NIG_REG_LATCH_STATUS_0 + port*8); |
| 6261 | DP(NETIF_MSG_LINK, "latch_status = 0x%x\n", latch_status); |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 6262 | /* Handle only those with latched-signal=up.*/ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6263 | if (exp_mi_int) |
| 6264 | bnx2x_bits_en(bp, |
| 6265 | NIG_REG_STATUS_INTERRUPT_PORT0 |
| 6266 | + port*4, |
| 6267 | NIG_STATUS_EMAC0_MI_INT); |
| 6268 | else |
| 6269 | bnx2x_bits_dis(bp, |
| 6270 | NIG_REG_STATUS_INTERRUPT_PORT0 |
| 6271 | + port*4, |
| 6272 | NIG_STATUS_EMAC0_MI_INT); |
| 6273 | |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 6274 | if (latch_status & 1) { |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6275 | |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 6276 | /* For all latched-signal=up : Re-Arm Latch signals */ |
| 6277 | REG_WR(bp, NIG_REG_LATCH_STATUS_0 + port*8, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6278 | (latch_status & 0xfffe) | (latch_status & 1)); |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 6279 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6280 | /* For all latched-signal=up,Write original_signal to status */ |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 6281 | } |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 6282 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6283 | static void bnx2x_link_int_ack(struct link_params *params, |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6284 | struct link_vars *vars, u8 is_10g_plus) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6285 | { |
| 6286 | struct bnx2x *bp = params->bp; |
| 6287 | u8 port = params->port; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6288 | u32 mask; |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 6289 | /* First reset all status we assume only one line will be |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6290 | * change at a time |
| 6291 | */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6292 | bnx2x_bits_dis(bp, NIG_REG_STATUS_INTERRUPT_PORT0 + port*4, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6293 | (NIG_STATUS_XGXS0_LINK10G | |
| 6294 | NIG_STATUS_XGXS0_LINK_STATUS | |
| 6295 | NIG_STATUS_SERDES0_LINK_STATUS)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6296 | if (vars->phy_link_up) { |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6297 | if (USES_WARPCORE(bp)) |
| 6298 | mask = NIG_STATUS_XGXS0_LINK_STATUS; |
| 6299 | else { |
| 6300 | if (is_10g_plus) |
| 6301 | mask = NIG_STATUS_XGXS0_LINK10G; |
| 6302 | else if (params->switch_cfg == SWITCH_CFG_10G) { |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 6303 | /* Disable the link interrupt by writing 1 to |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6304 | * the relevant lane in the status register |
| 6305 | */ |
| 6306 | u32 ser_lane = |
| 6307 | ((params->lane_config & |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6308 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_MASK) >> |
| 6309 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_SHIFT); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6310 | mask = ((1 << ser_lane) << |
| 6311 | NIG_STATUS_XGXS0_LINK_STATUS_SIZE); |
| 6312 | } else |
| 6313 | mask = NIG_STATUS_SERDES0_LINK_STATUS; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6314 | } |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6315 | DP(NETIF_MSG_LINK, "Ack link up interrupt with mask 0x%x\n", |
| 6316 | mask); |
| 6317 | bnx2x_bits_en(bp, |
| 6318 | NIG_REG_STATUS_INTERRUPT_PORT0 + port*4, |
| 6319 | mask); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6320 | } |
| 6321 | } |
| 6322 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6323 | static int bnx2x_format_ver(u32 num, u8 *str, u16 *len) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6324 | { |
| 6325 | u8 *str_ptr = str; |
| 6326 | u32 mask = 0xf0000000; |
| 6327 | u8 shift = 8*4; |
| 6328 | u8 digit; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6329 | u8 remove_leading_zeros = 1; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6330 | if (*len < 10) { |
Frederik Schwarzer | 025dfda | 2008-10-16 19:02:37 +0200 | [diff] [blame] | 6331 | /* Need more than 10chars for this format */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6332 | *str_ptr = '\0'; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6333 | (*len)--; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6334 | return -EINVAL; |
| 6335 | } |
| 6336 | while (shift > 0) { |
| 6337 | |
| 6338 | shift -= 4; |
| 6339 | digit = ((num & mask) >> shift); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6340 | if (digit == 0 && remove_leading_zeros) { |
| 6341 | mask = mask >> 4; |
| 6342 | continue; |
| 6343 | } else if (digit < 0xa) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6344 | *str_ptr = digit + '0'; |
| 6345 | else |
| 6346 | *str_ptr = digit - 0xa + 'a'; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6347 | remove_leading_zeros = 0; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6348 | str_ptr++; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6349 | (*len)--; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6350 | mask = mask >> 4; |
| 6351 | if (shift == 4*4) { |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6352 | *str_ptr = '.'; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6353 | str_ptr++; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6354 | (*len)--; |
| 6355 | remove_leading_zeros = 1; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6356 | } |
| 6357 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6358 | return 0; |
| 6359 | } |
| 6360 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6361 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6362 | static int bnx2x_null_format_ver(u32 spirom_ver, u8 *str, u16 *len) |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6363 | { |
| 6364 | str[0] = '\0'; |
| 6365 | (*len)--; |
| 6366 | return 0; |
| 6367 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6368 | |
Mintz Yuval | a1e785e | 2012-02-15 02:10:32 +0000 | [diff] [blame] | 6369 | int bnx2x_get_ext_phy_fw_version(struct link_params *params, u8 *version, |
| 6370 | u16 len) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6371 | { |
Julia Lawall | 0376d5b | 2009-07-19 05:26:35 +0000 | [diff] [blame] | 6372 | struct bnx2x *bp; |
Eilon Greenstein | a35da8d | 2009-02-12 08:37:02 +0000 | [diff] [blame] | 6373 | u32 spirom_ver = 0; |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6374 | int status = 0; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6375 | u8 *ver_p = version; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6376 | u16 remain_len = len; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6377 | if (version == NULL || params == NULL) |
| 6378 | return -EINVAL; |
Julia Lawall | 0376d5b | 2009-07-19 05:26:35 +0000 | [diff] [blame] | 6379 | bp = params->bp; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6380 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6381 | /* Extract first external phy*/ |
| 6382 | version[0] = '\0'; |
| 6383 | spirom_ver = REG_RD(bp, params->phy[EXT_PHY1].ver_addr); |
Eilon Greenstein | a35da8d | 2009-02-12 08:37:02 +0000 | [diff] [blame] | 6384 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6385 | if (params->phy[EXT_PHY1].format_fw_ver) { |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6386 | status |= params->phy[EXT_PHY1].format_fw_ver(spirom_ver, |
| 6387 | ver_p, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6388 | &remain_len); |
| 6389 | ver_p += (len - remain_len); |
| 6390 | } |
| 6391 | if ((params->num_phys == MAX_PHYS) && |
| 6392 | (params->phy[EXT_PHY2].ver_addr != 0)) { |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6393 | spirom_ver = REG_RD(bp, params->phy[EXT_PHY2].ver_addr); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6394 | if (params->phy[EXT_PHY2].format_fw_ver) { |
| 6395 | *ver_p = '/'; |
| 6396 | ver_p++; |
| 6397 | remain_len--; |
| 6398 | status |= params->phy[EXT_PHY2].format_fw_ver( |
| 6399 | spirom_ver, |
| 6400 | ver_p, |
| 6401 | &remain_len); |
| 6402 | ver_p = version + (len - remain_len); |
| 6403 | } |
| 6404 | } |
| 6405 | *ver_p = '\0'; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6406 | return status; |
| 6407 | } |
| 6408 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 6409 | static void bnx2x_set_xgxs_loopback(struct bnx2x_phy *phy, |
Yaniv Rosner | 62b29a5 | 2010-09-07 11:40:58 +0000 | [diff] [blame] | 6410 | struct link_params *params) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6411 | { |
| 6412 | u8 port = params->port; |
| 6413 | struct bnx2x *bp = params->bp; |
| 6414 | |
Yaniv Rosner | 62b29a5 | 2010-09-07 11:40:58 +0000 | [diff] [blame] | 6415 | if (phy->req_line_speed != SPEED_1000) { |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6416 | u32 md_devad = 0; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6417 | |
| 6418 | DP(NETIF_MSG_LINK, "XGXS 10G loopback enable\n"); |
| 6419 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6420 | if (!CHIP_IS_E3(bp)) { |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 6421 | /* Change the uni_phy_addr in the nig */ |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6422 | md_devad = REG_RD(bp, (NIG_REG_XGXS0_CTRL_MD_DEVAD + |
| 6423 | port*0x18)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6424 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6425 | REG_WR(bp, NIG_REG_XGXS0_CTRL_MD_DEVAD + port*0x18, |
| 6426 | 0x5); |
| 6427 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6428 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 6429 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6430 | 5, |
| 6431 | (MDIO_REG_BANK_AER_BLOCK + |
| 6432 | (MDIO_AER_BLOCK_AER_REG & 0xf)), |
| 6433 | 0x2800); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6434 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 6435 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6436 | 5, |
| 6437 | (MDIO_REG_BANK_CL73_IEEEB0 + |
| 6438 | (MDIO_CL73_IEEEB0_CL73_AN_CONTROL & 0xf)), |
| 6439 | 0x6041); |
Eilon Greenstein | 3858276 | 2009-01-14 06:44:16 +0000 | [diff] [blame] | 6440 | msleep(200); |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 6441 | /* Set aer mmd back */ |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 6442 | bnx2x_set_aer_mmd(params, phy); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6443 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6444 | if (!CHIP_IS_E3(bp)) { |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 6445 | /* And md_devad */ |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6446 | REG_WR(bp, NIG_REG_XGXS0_CTRL_MD_DEVAD + port*0x18, |
| 6447 | md_devad); |
| 6448 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6449 | } else { |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 6450 | u16 mii_ctrl; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6451 | DP(NETIF_MSG_LINK, "XGXS 1G loopback enable\n"); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 6452 | bnx2x_cl45_read(bp, phy, 5, |
| 6453 | (MDIO_REG_BANK_COMBO_IEEE0 + |
| 6454 | (MDIO_COMBO_IEEE0_MII_CONTROL & 0xf)), |
| 6455 | &mii_ctrl); |
| 6456 | bnx2x_cl45_write(bp, phy, 5, |
| 6457 | (MDIO_REG_BANK_COMBO_IEEE0 + |
| 6458 | (MDIO_COMBO_IEEE0_MII_CONTROL & 0xf)), |
| 6459 | mii_ctrl | |
| 6460 | MDIO_COMBO_IEEO_MII_CONTROL_LOOPBACK); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6461 | } |
| 6462 | } |
| 6463 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6464 | int bnx2x_set_led(struct link_params *params, |
| 6465 | struct link_vars *vars, u8 mode, u32 speed) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6466 | { |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 6467 | u8 port = params->port; |
| 6468 | u16 hw_led_mode = params->hw_led_mode; |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6469 | int rc = 0; |
| 6470 | u8 phy_idx; |
Eilon Greenstein | 345b5d5 | 2008-08-13 15:58:12 -0700 | [diff] [blame] | 6471 | u32 tmp; |
| 6472 | u32 emac_base = port ? GRCBASE_EMAC1 : GRCBASE_EMAC0; |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 6473 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6474 | DP(NETIF_MSG_LINK, "bnx2x_set_led: port %x, mode %d\n", port, mode); |
| 6475 | DP(NETIF_MSG_LINK, "speed 0x%x, hw_led_mode 0x%x\n", |
| 6476 | speed, hw_led_mode); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6477 | /* In case */ |
| 6478 | for (phy_idx = EXT_PHY1; phy_idx < MAX_PHYS; phy_idx++) { |
| 6479 | if (params->phy[phy_idx].set_link_led) { |
| 6480 | params->phy[phy_idx].set_link_led( |
| 6481 | ¶ms->phy[phy_idx], params, mode); |
| 6482 | } |
| 6483 | } |
| 6484 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6485 | switch (mode) { |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6486 | case LED_MODE_FRONT_PANEL_OFF: |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6487 | case LED_MODE_OFF: |
| 6488 | REG_WR(bp, NIG_REG_LED_10G_P0 + port*4, 0); |
| 6489 | REG_WR(bp, NIG_REG_LED_MODE_P0 + port*4, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6490 | SHARED_HW_CFG_LED_MAC1); |
Eilon Greenstein | 345b5d5 | 2008-08-13 15:58:12 -0700 | [diff] [blame] | 6491 | |
| 6492 | tmp = EMAC_RD(bp, EMAC_REG_EMAC_LED); |
Yaniv Rosner | 001cea7 | 2011-10-27 05:09:48 +0000 | [diff] [blame] | 6493 | if (params->phy[EXT_PHY1].type == |
Yaniv Rosner | 9379c9b | 2012-04-04 01:28:58 +0000 | [diff] [blame] | 6494 | PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54618SE) |
| 6495 | tmp &= ~(EMAC_LED_1000MB_OVERRIDE | |
| 6496 | EMAC_LED_100MB_OVERRIDE | |
| 6497 | EMAC_LED_10MB_OVERRIDE); |
| 6498 | else |
| 6499 | tmp |= EMAC_LED_OVERRIDE; |
| 6500 | |
| 6501 | EMAC_WR(bp, EMAC_REG_EMAC_LED, tmp); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6502 | break; |
| 6503 | |
| 6504 | case LED_MODE_OPER: |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 6505 | /* For all other phys, OPER mode is same as ON, so in case |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6506 | * link is down, do nothing |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6507 | */ |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6508 | if (!vars->link_up) |
| 6509 | break; |
| 6510 | case LED_MODE_ON: |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 6511 | if (((params->phy[EXT_PHY1].type == |
| 6512 | PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727) || |
| 6513 | (params->phy[EXT_PHY1].type == |
| 6514 | PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8722)) && |
Yaniv Rosner | 1f48353 | 2011-01-18 04:33:31 +0000 | [diff] [blame] | 6515 | CHIP_IS_E2(bp) && params->num_phys == 2) { |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 6516 | /* This is a work-around for E2+8727 Configurations */ |
Yaniv Rosner | 1f48353 | 2011-01-18 04:33:31 +0000 | [diff] [blame] | 6517 | if (mode == LED_MODE_ON || |
| 6518 | speed == SPEED_10000){ |
| 6519 | REG_WR(bp, NIG_REG_LED_MODE_P0 + port*4, 0); |
| 6520 | REG_WR(bp, NIG_REG_LED_10G_P0 + port*4, 1); |
| 6521 | |
| 6522 | tmp = EMAC_RD(bp, EMAC_REG_EMAC_LED); |
| 6523 | EMAC_WR(bp, EMAC_REG_EMAC_LED, |
| 6524 | (tmp | EMAC_LED_OVERRIDE)); |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 6525 | /* Return here without enabling traffic |
David S. Miller | 8decf86 | 2011-09-22 03:23:13 -0400 | [diff] [blame] | 6526 | * LED blink and setting rate in ON mode. |
Yaniv Rosner | 793bd45 | 2011-08-02 22:59:40 +0000 | [diff] [blame] | 6527 | * In oper mode, enabling LED blink |
| 6528 | * and setting rate is needed. |
| 6529 | */ |
| 6530 | if (mode == LED_MODE_ON) |
| 6531 | return rc; |
Yaniv Rosner | 1f48353 | 2011-01-18 04:33:31 +0000 | [diff] [blame] | 6532 | } |
Yaniv Rosner | 793bd45 | 2011-08-02 22:59:40 +0000 | [diff] [blame] | 6533 | } else if (SINGLE_MEDIA_DIRECT(params)) { |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 6534 | /* This is a work-around for HW issue found when link |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6535 | * is up in CL73 |
| 6536 | */ |
David S. Miller | 8decf86 | 2011-09-22 03:23:13 -0400 | [diff] [blame] | 6537 | if ((!CHIP_IS_E3(bp)) || |
| 6538 | (CHIP_IS_E3(bp) && |
| 6539 | mode == LED_MODE_ON)) |
| 6540 | REG_WR(bp, NIG_REG_LED_10G_P0 + port*4, 1); |
| 6541 | |
Yaniv Rosner | 793bd45 | 2011-08-02 22:59:40 +0000 | [diff] [blame] | 6542 | if (CHIP_IS_E1x(bp) || |
| 6543 | CHIP_IS_E2(bp) || |
| 6544 | (mode == LED_MODE_ON)) |
| 6545 | REG_WR(bp, NIG_REG_LED_MODE_P0 + port*4, 0); |
| 6546 | else |
| 6547 | REG_WR(bp, NIG_REG_LED_MODE_P0 + port*4, |
| 6548 | hw_led_mode); |
Yaniv Rosner | 001cea7 | 2011-10-27 05:09:48 +0000 | [diff] [blame] | 6549 | } else if ((params->phy[EXT_PHY1].type == |
| 6550 | PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54618SE) && |
Yaniv Rosner | 9379c9b | 2012-04-04 01:28:58 +0000 | [diff] [blame] | 6551 | (mode == LED_MODE_ON)) { |
Yaniv Rosner | 001cea7 | 2011-10-27 05:09:48 +0000 | [diff] [blame] | 6552 | REG_WR(bp, NIG_REG_LED_MODE_P0 + port*4, 0); |
| 6553 | tmp = EMAC_RD(bp, EMAC_REG_EMAC_LED); |
Yaniv Rosner | 9379c9b | 2012-04-04 01:28:58 +0000 | [diff] [blame] | 6554 | EMAC_WR(bp, EMAC_REG_EMAC_LED, tmp | |
| 6555 | EMAC_LED_OVERRIDE | EMAC_LED_1000MB_OVERRIDE); |
| 6556 | /* Break here; otherwise, it'll disable the |
| 6557 | * intended override. |
| 6558 | */ |
| 6559 | break; |
Yaniv Rosner | 793bd45 | 2011-08-02 22:59:40 +0000 | [diff] [blame] | 6560 | } else |
Yaniv Rosner | 001cea7 | 2011-10-27 05:09:48 +0000 | [diff] [blame] | 6561 | REG_WR(bp, NIG_REG_LED_MODE_P0 + port*4, |
| 6562 | hw_led_mode); |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 6563 | |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6564 | REG_WR(bp, NIG_REG_LED_CONTROL_OVERRIDE_TRAFFIC_P0 + port*4, 0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6565 | /* Set blinking rate to ~15.9Hz */ |
Yaniv Rosner | 26ffaf3 | 2011-10-27 05:09:45 +0000 | [diff] [blame] | 6566 | if (CHIP_IS_E3(bp)) |
| 6567 | REG_WR(bp, NIG_REG_LED_CONTROL_BLINK_RATE_P0 + port*4, |
| 6568 | LED_BLINK_RATE_VAL_E3); |
| 6569 | else |
| 6570 | REG_WR(bp, NIG_REG_LED_CONTROL_BLINK_RATE_P0 + port*4, |
| 6571 | LED_BLINK_RATE_VAL_E1X_E2); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6572 | REG_WR(bp, NIG_REG_LED_CONTROL_BLINK_RATE_ENA_P0 + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6573 | port*4, 1); |
Yaniv Rosner | 9379c9b | 2012-04-04 01:28:58 +0000 | [diff] [blame] | 6574 | tmp = EMAC_RD(bp, EMAC_REG_EMAC_LED); |
| 6575 | EMAC_WR(bp, EMAC_REG_EMAC_LED, |
| 6576 | (tmp & (~EMAC_LED_OVERRIDE))); |
Eilon Greenstein | 345b5d5 | 2008-08-13 15:58:12 -0700 | [diff] [blame] | 6577 | |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 6578 | if (CHIP_IS_E1(bp) && |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 6579 | ((speed == SPEED_2500) || |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6580 | (speed == SPEED_1000) || |
| 6581 | (speed == SPEED_100) || |
| 6582 | (speed == SPEED_10))) { |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 6583 | /* For speeds less than 10G LED scheme is different */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6584 | REG_WR(bp, NIG_REG_LED_CONTROL_OVERRIDE_TRAFFIC_P0 |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6585 | + port*4, 1); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6586 | REG_WR(bp, NIG_REG_LED_CONTROL_TRAFFIC_P0 + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6587 | port*4, 0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6588 | REG_WR(bp, NIG_REG_LED_CONTROL_BLINK_TRAFFIC_P0 + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6589 | port*4, 1); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6590 | } |
| 6591 | break; |
| 6592 | |
| 6593 | default: |
| 6594 | rc = -EINVAL; |
| 6595 | DP(NETIF_MSG_LINK, "bnx2x_set_led: Invalid led mode %d\n", |
| 6596 | mode); |
| 6597 | break; |
| 6598 | } |
| 6599 | return rc; |
| 6600 | |
| 6601 | } |
| 6602 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 6603 | /* This function comes to reflect the actual link state read DIRECTLY from the |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6604 | * HW |
| 6605 | */ |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6606 | int bnx2x_test_link(struct link_params *params, struct link_vars *vars, |
| 6607 | u8 is_serdes) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6608 | { |
| 6609 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 6610 | u16 gp_status = 0, phy_index = 0; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6611 | u8 ext_phy_link_up = 0, serdes_phy_type; |
| 6612 | struct link_vars temp_vars; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6613 | struct bnx2x_phy *int_phy = ¶ms->phy[INT_PHY]; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6614 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6615 | if (CHIP_IS_E3(bp)) { |
| 6616 | u16 link_up; |
| 6617 | if (params->req_line_speed[LINK_CONFIG_IDX(INT_PHY)] |
| 6618 | > SPEED_10000) { |
| 6619 | /* Check 20G link */ |
| 6620 | bnx2x_cl45_read(bp, int_phy, MDIO_WC_DEVAD, |
| 6621 | 1, &link_up); |
| 6622 | bnx2x_cl45_read(bp, int_phy, MDIO_WC_DEVAD, |
| 6623 | 1, &link_up); |
| 6624 | link_up &= (1<<2); |
| 6625 | } else { |
| 6626 | /* Check 10G link and below*/ |
| 6627 | u8 lane = bnx2x_get_warpcore_lane(int_phy, params); |
| 6628 | bnx2x_cl45_read(bp, int_phy, MDIO_WC_DEVAD, |
| 6629 | MDIO_WC_REG_GP2_STATUS_GP_2_1, |
| 6630 | &gp_status); |
| 6631 | gp_status = ((gp_status >> 8) & 0xf) | |
| 6632 | ((gp_status >> 12) & 0xf); |
| 6633 | link_up = gp_status & (1 << lane); |
| 6634 | } |
| 6635 | if (!link_up) |
| 6636 | return -ESRCH; |
| 6637 | } else { |
| 6638 | CL22_RD_OVER_CL45(bp, int_phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6639 | MDIO_REG_BANK_GP_STATUS, |
| 6640 | MDIO_GP_STATUS_TOP_AN_STATUS1, |
| 6641 | &gp_status); |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 6642 | /* Link is up only if both local phy and external phy are up */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6643 | if (!(gp_status & MDIO_GP_STATUS_TOP_AN_STATUS1_LINK_STATUS)) |
| 6644 | return -ESRCH; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6645 | } |
| 6646 | /* In XGXS loopback mode, do not check external PHY */ |
| 6647 | if (params->loopback_mode == LOOPBACK_XGXS) |
| 6648 | return 0; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6649 | |
| 6650 | switch (params->num_phys) { |
| 6651 | case 1: |
| 6652 | /* No external PHY */ |
| 6653 | return 0; |
| 6654 | case 2: |
| 6655 | ext_phy_link_up = params->phy[EXT_PHY1].read_status( |
| 6656 | ¶ms->phy[EXT_PHY1], |
| 6657 | params, &temp_vars); |
| 6658 | break; |
| 6659 | case 3: /* Dual Media */ |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 6660 | for (phy_index = EXT_PHY1; phy_index < params->num_phys; |
| 6661 | phy_index++) { |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6662 | serdes_phy_type = ((params->phy[phy_index].media_type == |
Yuval Mintz | dbef807 | 2012-06-20 19:05:22 +0000 | [diff] [blame] | 6663 | ETH_PHY_SFPP_10G_FIBER) || |
| 6664 | (params->phy[phy_index].media_type == |
| 6665 | ETH_PHY_SFP_1G_FIBER) || |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6666 | (params->phy[phy_index].media_type == |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 6667 | ETH_PHY_XFP_FIBER) || |
| 6668 | (params->phy[phy_index].media_type == |
| 6669 | ETH_PHY_DA_TWINAX)); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6670 | |
| 6671 | if (is_serdes != serdes_phy_type) |
| 6672 | continue; |
| 6673 | if (params->phy[phy_index].read_status) { |
| 6674 | ext_phy_link_up |= |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 6675 | params->phy[phy_index].read_status( |
| 6676 | ¶ms->phy[phy_index], |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6677 | params, &temp_vars); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6678 | } |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 6679 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6680 | break; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6681 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6682 | if (ext_phy_link_up) |
| 6683 | return 0; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6684 | return -ESRCH; |
| 6685 | } |
| 6686 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6687 | static int bnx2x_link_initialize(struct link_params *params, |
| 6688 | struct link_vars *vars) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6689 | { |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6690 | int rc = 0; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6691 | u8 phy_index, non_ext_phy; |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 6692 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 6693 | /* In case of external phy existence, the line speed would be the |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6694 | * line speed linked up by the external phy. In case it is direct |
| 6695 | * only, then the line_speed during initialization will be |
| 6696 | * equal to the req_line_speed |
| 6697 | */ |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 6698 | vars->line_speed = params->phy[INT_PHY].req_line_speed; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6699 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 6700 | /* Initialize the internal phy in case this is a direct board |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 6701 | * (no external phys), or this board has external phy which requires |
| 6702 | * to first. |
| 6703 | */ |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6704 | if (!USES_WARPCORE(bp)) |
| 6705 | bnx2x_prepare_xgxs(¶ms->phy[INT_PHY], params, vars); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6706 | /* init ext phy and enable link state int */ |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 6707 | non_ext_phy = (SINGLE_MEDIA_DIRECT(params) || |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6708 | (params->loopback_mode == LOOPBACK_XGXS)); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6709 | |
| 6710 | if (non_ext_phy || |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 6711 | (params->phy[EXT_PHY1].flags & FLAGS_INIT_XGXS_FIRST) || |
Eilon Greenstein | 8660d8c | 2009-03-02 08:01:02 +0000 | [diff] [blame] | 6712 | (params->loopback_mode == LOOPBACK_EXT_PHY)) { |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 6713 | struct bnx2x_phy *phy = ¶ms->phy[INT_PHY]; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6714 | if (vars->line_speed == SPEED_AUTO_NEG && |
| 6715 | (CHIP_IS_E1x(bp) || |
| 6716 | CHIP_IS_E2(bp))) |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 6717 | bnx2x_set_parallel_detection(phy, params); |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 6718 | if (params->phy[INT_PHY].config_init) |
| 6719 | params->phy[INT_PHY].config_init(phy, |
| 6720 | params, |
| 6721 | vars); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6722 | } |
| 6723 | |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 6724 | /* Init external phy*/ |
Yaniv Rosner | fd36a2e | 2011-05-31 21:29:05 +0000 | [diff] [blame] | 6725 | if (non_ext_phy) { |
| 6726 | if (params->phy[INT_PHY].supported & |
| 6727 | SUPPORTED_FIBRE) |
| 6728 | vars->link_status |= LINK_STATUS_SERDES_LINK; |
| 6729 | } else { |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6730 | for (phy_index = EXT_PHY1; phy_index < params->num_phys; |
| 6731 | phy_index++) { |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 6732 | /* No need to initialize second phy in case of first |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6733 | * phy only selection. In case of second phy, we do |
| 6734 | * need to initialize the first phy, since they are |
| 6735 | * connected. |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6736 | */ |
Yaniv Rosner | fd36a2e | 2011-05-31 21:29:05 +0000 | [diff] [blame] | 6737 | if (params->phy[phy_index].supported & |
| 6738 | SUPPORTED_FIBRE) |
| 6739 | vars->link_status |= LINK_STATUS_SERDES_LINK; |
| 6740 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6741 | if (phy_index == EXT_PHY2 && |
| 6742 | (bnx2x_phy_selection(params) == |
| 6743 | PORT_HW_CFG_PHY_SELECTION_FIRST_PHY)) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 6744 | DP(NETIF_MSG_LINK, |
| 6745 | "Not initializing second phy\n"); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6746 | continue; |
| 6747 | } |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6748 | params->phy[phy_index].config_init( |
| 6749 | ¶ms->phy[phy_index], |
| 6750 | params, vars); |
| 6751 | } |
Yaniv Rosner | fd36a2e | 2011-05-31 21:29:05 +0000 | [diff] [blame] | 6752 | } |
Yaniv Rosner | d90d96b | 2010-09-07 11:41:04 +0000 | [diff] [blame] | 6753 | /* Reset the interrupt indication after phy was initialized */ |
| 6754 | bnx2x_bits_dis(bp, NIG_REG_STATUS_INTERRUPT_PORT0 + |
| 6755 | params->port*4, |
| 6756 | (NIG_STATUS_XGXS0_LINK10G | |
| 6757 | NIG_STATUS_XGXS0_LINK_STATUS | |
| 6758 | NIG_STATUS_SERDES0_LINK_STATUS | |
| 6759 | NIG_MASK_MI_INT)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6760 | return rc; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6761 | } |
| 6762 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6763 | static void bnx2x_int_link_reset(struct bnx2x_phy *phy, |
| 6764 | struct link_params *params) |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6765 | { |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 6766 | /* Reset the SerDes/XGXS */ |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6767 | REG_WR(params->bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_3_CLEAR, |
| 6768 | (0x1ff << (params->port*16))); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6769 | } |
| 6770 | |
| 6771 | static void bnx2x_common_ext_link_reset(struct bnx2x_phy *phy, |
| 6772 | struct link_params *params) |
| 6773 | { |
| 6774 | struct bnx2x *bp = params->bp; |
| 6775 | u8 gpio_port; |
| 6776 | /* HW reset */ |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 6777 | if (CHIP_IS_E2(bp)) |
| 6778 | gpio_port = BP_PATH(bp); |
| 6779 | else |
| 6780 | gpio_port = params->port; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6781 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6782 | MISC_REGISTERS_GPIO_OUTPUT_LOW, |
| 6783 | gpio_port); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6784 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6785 | MISC_REGISTERS_GPIO_OUTPUT_LOW, |
| 6786 | gpio_port); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6787 | DP(NETIF_MSG_LINK, "reset external PHY\n"); |
| 6788 | } |
| 6789 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6790 | static int bnx2x_update_link_down(struct link_params *params, |
| 6791 | struct link_vars *vars) |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6792 | { |
| 6793 | struct bnx2x *bp = params->bp; |
| 6794 | u8 port = params->port; |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 6795 | |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6796 | DP(NETIF_MSG_LINK, "Port %x: Link is down\n", port); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6797 | bnx2x_set_led(params, vars, LED_MODE_OFF, 0); |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 6798 | vars->phy_flags &= ~PHY_PHYSICAL_LINK_FLAG; |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 6799 | /* Indicate no mac active */ |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6800 | vars->mac_type = MAC_TYPE_NONE; |
| 6801 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 6802 | /* Update shared memory */ |
Yaniv Rosner | fd36a2e | 2011-05-31 21:29:05 +0000 | [diff] [blame] | 6803 | vars->link_status &= ~(LINK_STATUS_SPEED_AND_DUPLEX_MASK | |
| 6804 | LINK_STATUS_LINK_UP | |
Yaniv Rosner | de6f337 | 2011-08-02 22:59:25 +0000 | [diff] [blame] | 6805 | LINK_STATUS_PHYSICAL_LINK_FLAG | |
Yaniv Rosner | fd36a2e | 2011-05-31 21:29:05 +0000 | [diff] [blame] | 6806 | LINK_STATUS_AUTO_NEGOTIATE_COMPLETE | |
| 6807 | LINK_STATUS_RX_FLOW_CONTROL_FLAG_MASK | |
| 6808 | LINK_STATUS_TX_FLOW_CONTROL_FLAG_MASK | |
Mintz Yuval | 9e7e839 | 2012-02-15 02:10:24 +0000 | [diff] [blame] | 6809 | LINK_STATUS_PARALLEL_DETECTION_FLAG_MASK | |
| 6810 | LINK_STATUS_LINK_PARTNER_SYMMETRIC_PAUSE | |
| 6811 | LINK_STATUS_LINK_PARTNER_ASYMMETRIC_PAUSE); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6812 | vars->line_speed = 0; |
| 6813 | bnx2x_update_mng(params, vars->link_status); |
| 6814 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 6815 | /* Activate nig drain */ |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6816 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + port*4, 1); |
| 6817 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 6818 | /* Disable emac */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 6819 | if (!CHIP_IS_E3(bp)) |
| 6820 | REG_WR(bp, NIG_REG_NIG_EMAC0_EN + port*4, 0); |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 6821 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 6822 | usleep_range(10000, 20000); |
| 6823 | /* Reset BigMac/Xmac */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 6824 | if (CHIP_IS_E1x(bp) || |
Yaniv Rosner | d3a8f13 | 2012-09-13 02:56:20 +0000 | [diff] [blame] | 6825 | CHIP_IS_E2(bp)) |
| 6826 | bnx2x_set_bmac_rx(bp, params->chip_id, params->port, 0); |
| 6827 | |
Yaniv Rosner | ce7c048 | 2011-10-27 05:09:47 +0000 | [diff] [blame] | 6828 | if (CHIP_IS_E3(bp)) { |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 6829 | /* Prevent LPI Generation by chip */ |
Yuval Mintz | c8c60d8 | 2012-06-06 17:13:07 +0000 | [diff] [blame] | 6830 | REG_WR(bp, MISC_REG_CPMU_LP_FW_ENABLE_P0 + (params->port << 2), |
| 6831 | 0); |
Yuval Mintz | c8c60d8 | 2012-06-06 17:13:07 +0000 | [diff] [blame] | 6832 | REG_WR(bp, MISC_REG_CPMU_LP_MASK_ENT_P0 + (params->port << 2), |
| 6833 | 0); |
| 6834 | vars->eee_status &= ~(SHMEM_EEE_LP_ADV_STATUS_MASK | |
| 6835 | SHMEM_EEE_ACTIVE_BIT); |
| 6836 | |
| 6837 | bnx2x_update_mng_eee(params, vars->eee_status); |
Yaniv Rosner | d3a8f13 | 2012-09-13 02:56:20 +0000 | [diff] [blame] | 6838 | bnx2x_set_xmac_rxtx(params, 0); |
| 6839 | bnx2x_set_umac_rxtx(params, 0); |
Yaniv Rosner | ce7c048 | 2011-10-27 05:09:47 +0000 | [diff] [blame] | 6840 | } |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 6841 | |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6842 | return 0; |
| 6843 | } |
| 6844 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6845 | static int bnx2x_update_link_up(struct link_params *params, |
| 6846 | struct link_vars *vars, |
| 6847 | u8 link_10g) |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6848 | { |
| 6849 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 55098c5 | 2012-04-03 18:41:27 +0000 | [diff] [blame] | 6850 | u8 phy_idx, port = params->port; |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6851 | int rc = 0; |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 6852 | |
Yaniv Rosner | de6f337 | 2011-08-02 22:59:25 +0000 | [diff] [blame] | 6853 | vars->link_status |= (LINK_STATUS_LINK_UP | |
| 6854 | LINK_STATUS_PHYSICAL_LINK_FLAG); |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 6855 | vars->phy_flags |= PHY_PHYSICAL_LINK_FLAG; |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6856 | |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 6857 | if (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX) |
| 6858 | vars->link_status |= |
| 6859 | LINK_STATUS_TX_FLOW_CONTROL_ENABLED; |
| 6860 | |
| 6861 | if (vars->flow_ctrl & BNX2X_FLOW_CTRL_RX) |
| 6862 | vars->link_status |= |
| 6863 | LINK_STATUS_RX_FLOW_CONTROL_ENABLED; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 6864 | if (USES_WARPCORE(bp)) { |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 6865 | if (link_10g) { |
| 6866 | if (bnx2x_xmac_enable(params, vars, 0) == |
| 6867 | -ESRCH) { |
| 6868 | DP(NETIF_MSG_LINK, "Found errors on XMAC\n"); |
| 6869 | vars->link_up = 0; |
| 6870 | vars->phy_flags |= PHY_HALF_OPEN_CONN_FLAG; |
| 6871 | vars->link_status &= ~LINK_STATUS_LINK_UP; |
| 6872 | } |
| 6873 | } else |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 6874 | bnx2x_umac_enable(params, vars, 0); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6875 | bnx2x_set_led(params, vars, |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 6876 | LED_MODE_OPER, vars->line_speed); |
Yuval Mintz | c8c60d8 | 2012-06-06 17:13:07 +0000 | [diff] [blame] | 6877 | |
| 6878 | if ((vars->eee_status & SHMEM_EEE_ACTIVE_BIT) && |
| 6879 | (vars->eee_status & SHMEM_EEE_LPI_REQUESTED_BIT)) { |
| 6880 | DP(NETIF_MSG_LINK, "Enabling LPI assertion\n"); |
| 6881 | REG_WR(bp, MISC_REG_CPMU_LP_FW_ENABLE_P0 + |
| 6882 | (params->port << 2), 1); |
| 6883 | REG_WR(bp, MISC_REG_CPMU_LP_DR_ENABLE, 1); |
| 6884 | REG_WR(bp, MISC_REG_CPMU_LP_MASK_ENT_P0 + |
| 6885 | (params->port << 2), 0xfc20); |
| 6886 | } |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 6887 | } |
| 6888 | if ((CHIP_IS_E1x(bp) || |
| 6889 | CHIP_IS_E2(bp))) { |
| 6890 | if (link_10g) { |
Yaniv Rosner | d3a8f13 | 2012-09-13 02:56:20 +0000 | [diff] [blame] | 6891 | if (bnx2x_bmac_enable(params, vars, 0, 1) == |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 6892 | -ESRCH) { |
| 6893 | DP(NETIF_MSG_LINK, "Found errors on BMAC\n"); |
| 6894 | vars->link_up = 0; |
| 6895 | vars->phy_flags |= PHY_HALF_OPEN_CONN_FLAG; |
| 6896 | vars->link_status &= ~LINK_STATUS_LINK_UP; |
| 6897 | } |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6898 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 6899 | bnx2x_set_led(params, vars, |
| 6900 | LED_MODE_OPER, SPEED_10000); |
| 6901 | } else { |
| 6902 | rc = bnx2x_emac_program(params, vars); |
| 6903 | bnx2x_emac_enable(params, vars, 0); |
Yaniv Rosner | 0c786f0 | 2009-11-05 19:18:32 +0200 | [diff] [blame] | 6904 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 6905 | /* AN complete? */ |
| 6906 | if ((vars->link_status & |
| 6907 | LINK_STATUS_AUTO_NEGOTIATE_COMPLETE) |
| 6908 | && (!(vars->phy_flags & PHY_SGMII_FLAG)) && |
| 6909 | SINGLE_MEDIA_DIRECT(params)) |
| 6910 | bnx2x_set_gmii_tx_driver(params); |
| 6911 | } |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6912 | } |
| 6913 | |
| 6914 | /* PBF - link up */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 6915 | if (CHIP_IS_E1x(bp)) |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 6916 | rc |= bnx2x_pbf_update(params, vars->flow_ctrl, |
| 6917 | vars->line_speed); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6918 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 6919 | /* Disable drain */ |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6920 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + port*4, 0); |
| 6921 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 6922 | /* Update shared memory */ |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6923 | bnx2x_update_mng(params, vars->link_status); |
Yuval Mintz | c8c60d8 | 2012-06-06 17:13:07 +0000 | [diff] [blame] | 6924 | bnx2x_update_mng_eee(params, vars->eee_status); |
Yaniv Rosner | 55098c5 | 2012-04-03 18:41:27 +0000 | [diff] [blame] | 6925 | /* Check remote fault */ |
| 6926 | for (phy_idx = INT_PHY; phy_idx < MAX_PHYS; phy_idx++) { |
| 6927 | if (params->phy[phy_idx].flags & FLAGS_TX_ERROR_CHECK) { |
| 6928 | bnx2x_check_half_open_conn(params, vars, 0); |
| 6929 | break; |
| 6930 | } |
| 6931 | } |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 6932 | msleep(20); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6933 | return rc; |
| 6934 | } |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 6935 | /* The bnx2x_link_update function should be called upon link |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6936 | * interrupt. |
| 6937 | * Link is considered up as follows: |
| 6938 | * - DIRECT_SINGLE_MEDIA - Only XGXS link (internal link) needs |
| 6939 | * to be up |
| 6940 | * - SINGLE_MEDIA - The link between the 577xx and the external |
| 6941 | * phy (XGXS) need to up as well as the external link of the |
| 6942 | * phy (PHY_EXT1) |
| 6943 | * - DUAL_MEDIA - The link between the 577xx and the first |
| 6944 | * external phy needs to be up, and at least one of the 2 |
| 6945 | * external phy link must be up. |
Yaniv Rosner | 62b29a5 | 2010-09-07 11:40:58 +0000 | [diff] [blame] | 6946 | */ |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6947 | int bnx2x_link_update(struct link_params *params, struct link_vars *vars) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6948 | { |
| 6949 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6950 | struct link_vars phy_vars[MAX_PHYS]; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6951 | u8 port = params->port; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6952 | u8 link_10g_plus, phy_index; |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6953 | u8 ext_phy_link_up = 0, cur_link_up; |
| 6954 | int rc = 0; |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 6955 | u8 is_mi_int = 0; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6956 | u16 ext_phy_line_speed = 0, prev_line_speed = vars->line_speed; |
| 6957 | u8 active_external_phy = INT_PHY; |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 6958 | vars->phy_flags &= ~PHY_HALF_OPEN_CONN_FLAG; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6959 | for (phy_index = INT_PHY; phy_index < params->num_phys; |
| 6960 | phy_index++) { |
| 6961 | phy_vars[phy_index].flow_ctrl = 0; |
| 6962 | phy_vars[phy_index].link_status = 0; |
| 6963 | phy_vars[phy_index].line_speed = 0; |
| 6964 | phy_vars[phy_index].duplex = DUPLEX_FULL; |
| 6965 | phy_vars[phy_index].phy_link_up = 0; |
| 6966 | phy_vars[phy_index].link_up = 0; |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 6967 | phy_vars[phy_index].fault_detected = 0; |
Yuval Mintz | c8c60d8 | 2012-06-06 17:13:07 +0000 | [diff] [blame] | 6968 | /* different consideration, since vars holds inner state */ |
| 6969 | phy_vars[phy_index].eee_status = vars->eee_status; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6970 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6971 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6972 | if (USES_WARPCORE(bp)) |
| 6973 | bnx2x_set_aer_mmd(params, ¶ms->phy[INT_PHY]); |
| 6974 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6975 | DP(NETIF_MSG_LINK, "port %x, XGXS?%x, int_status 0x%x\n", |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 6976 | port, (vars->phy_flags & PHY_XGXS_FLAG), |
| 6977 | REG_RD(bp, NIG_REG_STATUS_INTERRUPT_PORT0 + port*4)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6978 | |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 6979 | is_mi_int = (u8)(REG_RD(bp, NIG_REG_EMAC0_STATUS_MISC_MI_INT + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6980 | port*0x18) > 0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6981 | DP(NETIF_MSG_LINK, "int_mask 0x%x MI_INT %x, SERDES_LINK %x\n", |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 6982 | REG_RD(bp, NIG_REG_MASK_INTERRUPT_PORT0 + port*4), |
| 6983 | is_mi_int, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6984 | REG_RD(bp, NIG_REG_SERDES0_STATUS_LINK_STATUS + port*0x3c)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6985 | |
| 6986 | DP(NETIF_MSG_LINK, " 10G %x, XGXS_LINK %x\n", |
| 6987 | REG_RD(bp, NIG_REG_XGXS0_STATUS_LINK10G + port*0x68), |
| 6988 | REG_RD(bp, NIG_REG_XGXS0_STATUS_LINK_STATUS + port*0x68)); |
| 6989 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 6990 | /* Disable emac */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 6991 | if (!CHIP_IS_E3(bp)) |
| 6992 | REG_WR(bp, NIG_REG_NIG_EMAC0_EN + port*4, 0); |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 6993 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 6994 | /* Step 1: |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6995 | * Check external link change only for external phys, and apply |
| 6996 | * priority selection between them in case the link on both phys |
Yaniv Rosner | 9045f6b4 | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 6997 | * is up. Note that instead of the common vars, a temporary |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6998 | * vars argument is used since each phy may have different link/ |
| 6999 | * speed/duplex result |
| 7000 | */ |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7001 | for (phy_index = EXT_PHY1; phy_index < params->num_phys; |
| 7002 | phy_index++) { |
| 7003 | struct bnx2x_phy *phy = ¶ms->phy[phy_index]; |
| 7004 | if (!phy->read_status) |
| 7005 | continue; |
| 7006 | /* Read link status and params of this ext phy */ |
| 7007 | cur_link_up = phy->read_status(phy, params, |
| 7008 | &phy_vars[phy_index]); |
| 7009 | if (cur_link_up) { |
| 7010 | DP(NETIF_MSG_LINK, "phy in index %d link is up\n", |
| 7011 | phy_index); |
| 7012 | } else { |
| 7013 | DP(NETIF_MSG_LINK, "phy in index %d link is down\n", |
| 7014 | phy_index); |
| 7015 | continue; |
| 7016 | } |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 7017 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7018 | if (!ext_phy_link_up) { |
| 7019 | ext_phy_link_up = 1; |
| 7020 | active_external_phy = phy_index; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7021 | } else { |
| 7022 | switch (bnx2x_phy_selection(params)) { |
| 7023 | case PORT_HW_CFG_PHY_SELECTION_HARDWARE_DEFAULT: |
| 7024 | case PORT_HW_CFG_PHY_SELECTION_FIRST_PHY_PRIORITY: |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 7025 | /* In this option, the first PHY makes sure to pass the |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7026 | * traffic through itself only. |
| 7027 | * Its not clear how to reset the link on the second phy |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7028 | */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7029 | active_external_phy = EXT_PHY1; |
| 7030 | break; |
| 7031 | case PORT_HW_CFG_PHY_SELECTION_SECOND_PHY_PRIORITY: |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 7032 | /* In this option, the first PHY makes sure to pass the |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7033 | * traffic through the second PHY. |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7034 | */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7035 | active_external_phy = EXT_PHY2; |
| 7036 | break; |
| 7037 | default: |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 7038 | /* Link indication on both PHYs with the following cases |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7039 | * is invalid: |
| 7040 | * - FIRST_PHY means that second phy wasn't initialized, |
| 7041 | * hence its link is expected to be down |
| 7042 | * - SECOND_PHY means that first phy should not be able |
| 7043 | * to link up by itself (using configuration) |
| 7044 | * - DEFAULT should be overriden during initialiazation |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7045 | */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7046 | DP(NETIF_MSG_LINK, "Invalid link indication" |
| 7047 | "mpc=0x%x. DISABLING LINK !!!\n", |
| 7048 | params->multi_phy_config); |
| 7049 | ext_phy_link_up = 0; |
| 7050 | break; |
| 7051 | } |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7052 | } |
| 7053 | } |
| 7054 | prev_line_speed = vars->line_speed; |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 7055 | /* Step 2: |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7056 | * Read the status of the internal phy. In case of |
| 7057 | * DIRECT_SINGLE_MEDIA board, this link is the external link, |
| 7058 | * otherwise this is the link between the 577xx and the first |
| 7059 | * external phy |
| 7060 | */ |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7061 | if (params->phy[INT_PHY].read_status) |
| 7062 | params->phy[INT_PHY].read_status( |
| 7063 | ¶ms->phy[INT_PHY], |
| 7064 | params, vars); |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 7065 | /* The INT_PHY flow control reside in the vars. This include the |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7066 | * case where the speed or flow control are not set to AUTO. |
| 7067 | * Otherwise, the active external phy flow control result is set |
| 7068 | * to the vars. The ext_phy_line_speed is needed to check if the |
| 7069 | * speed is different between the internal phy and external phy. |
| 7070 | * This case may be result of intermediate link speed change. |
| 7071 | */ |
| 7072 | if (active_external_phy > INT_PHY) { |
| 7073 | vars->flow_ctrl = phy_vars[active_external_phy].flow_ctrl; |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 7074 | /* Link speed is taken from the XGXS. AN and FC result from |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7075 | * the external phy. |
| 7076 | */ |
| 7077 | vars->link_status |= phy_vars[active_external_phy].link_status; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7078 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 7079 | /* if active_external_phy is first PHY and link is up - disable |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7080 | * disable TX on second external PHY |
| 7081 | */ |
| 7082 | if (active_external_phy == EXT_PHY1) { |
| 7083 | if (params->phy[EXT_PHY2].phy_specific_func) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 7084 | DP(NETIF_MSG_LINK, |
| 7085 | "Disabling TX on EXT_PHY2\n"); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7086 | params->phy[EXT_PHY2].phy_specific_func( |
| 7087 | ¶ms->phy[EXT_PHY2], |
| 7088 | params, DISABLE_TX); |
| 7089 | } |
| 7090 | } |
| 7091 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7092 | ext_phy_line_speed = phy_vars[active_external_phy].line_speed; |
| 7093 | vars->duplex = phy_vars[active_external_phy].duplex; |
| 7094 | if (params->phy[active_external_phy].supported & |
| 7095 | SUPPORTED_FIBRE) |
| 7096 | vars->link_status |= LINK_STATUS_SERDES_LINK; |
Yaniv Rosner | fd36a2e | 2011-05-31 21:29:05 +0000 | [diff] [blame] | 7097 | else |
| 7098 | vars->link_status &= ~LINK_STATUS_SERDES_LINK; |
Yuval Mintz | c8c60d8 | 2012-06-06 17:13:07 +0000 | [diff] [blame] | 7099 | |
| 7100 | vars->eee_status = phy_vars[active_external_phy].eee_status; |
| 7101 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7102 | DP(NETIF_MSG_LINK, "Active external phy selected: %x\n", |
| 7103 | active_external_phy); |
| 7104 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7105 | |
| 7106 | for (phy_index = EXT_PHY1; phy_index < params->num_phys; |
| 7107 | phy_index++) { |
| 7108 | if (params->phy[phy_index].flags & |
| 7109 | FLAGS_REARM_LATCH_SIGNAL) { |
| 7110 | bnx2x_rearm_latch_signal(bp, port, |
| 7111 | phy_index == |
| 7112 | active_external_phy); |
| 7113 | break; |
| 7114 | } |
| 7115 | } |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7116 | DP(NETIF_MSG_LINK, "vars->flow_ctrl = 0x%x, vars->link_status = 0x%x," |
| 7117 | " ext_phy_line_speed = %d\n", vars->flow_ctrl, |
| 7118 | vars->link_status, ext_phy_line_speed); |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 7119 | /* Upon link speed change set the NIG into drain mode. Comes to |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7120 | * deals with possible FIFO glitch due to clk change when speed |
| 7121 | * is decreased without link down indicator |
| 7122 | */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 7123 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7124 | if (vars->phy_link_up) { |
| 7125 | if (!(SINGLE_MEDIA_DIRECT(params)) && ext_phy_link_up && |
| 7126 | (ext_phy_line_speed != vars->line_speed)) { |
| 7127 | DP(NETIF_MSG_LINK, "Internal link speed %d is" |
| 7128 | " different than the external" |
| 7129 | " link speed %d\n", vars->line_speed, |
| 7130 | ext_phy_line_speed); |
| 7131 | vars->phy_link_up = 0; |
| 7132 | } else if (prev_line_speed != vars->line_speed) { |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7133 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + params->port*4, |
| 7134 | 0); |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 7135 | usleep_range(1000, 2000); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7136 | } |
| 7137 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 7138 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 7139 | /* Anything 10 and over uses the bmac */ |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 7140 | link_10g_plus = (vars->line_speed >= SPEED_10000); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 7141 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 7142 | bnx2x_link_int_ack(params, vars, link_10g_plus); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 7143 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 7144 | /* In case external phy link is up, and internal link is down |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7145 | * (not initialized yet probably after link initialization, it |
| 7146 | * needs to be initialized. |
| 7147 | * Note that after link down-up as result of cable plug, the xgxs |
| 7148 | * link would probably become up again without the need |
| 7149 | * initialize it |
| 7150 | */ |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7151 | if (!(SINGLE_MEDIA_DIRECT(params))) { |
| 7152 | DP(NETIF_MSG_LINK, "ext_phy_link_up = %d, int_link_up = %d," |
| 7153 | " init_preceding = %d\n", ext_phy_link_up, |
| 7154 | vars->phy_link_up, |
| 7155 | params->phy[EXT_PHY1].flags & |
| 7156 | FLAGS_INIT_XGXS_FIRST); |
| 7157 | if (!(params->phy[EXT_PHY1].flags & |
| 7158 | FLAGS_INIT_XGXS_FIRST) |
| 7159 | && ext_phy_link_up && !vars->phy_link_up) { |
| 7160 | vars->line_speed = ext_phy_line_speed; |
| 7161 | if (vars->line_speed < SPEED_1000) |
| 7162 | vars->phy_flags |= PHY_SGMII_FLAG; |
| 7163 | else |
| 7164 | vars->phy_flags &= ~PHY_SGMII_FLAG; |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 7165 | |
| 7166 | if (params->phy[INT_PHY].config_init) |
| 7167 | params->phy[INT_PHY].config_init( |
| 7168 | ¶ms->phy[INT_PHY], params, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7169 | vars); |
| 7170 | } |
| 7171 | } |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 7172 | /* Link is up only if both local phy and external phy (in case of |
Yaniv Rosner | 9045f6b4 | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 7173 | * non-direct board) are up and no fault detected on active PHY. |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7174 | */ |
| 7175 | vars->link_up = (vars->phy_link_up && |
| 7176 | (ext_phy_link_up || |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 7177 | SINGLE_MEDIA_DIRECT(params)) && |
| 7178 | (phy_vars[active_external_phy].fault_detected == 0)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 7179 | |
Yaniv Rosner | 27d9129 | 2012-04-04 01:28:54 +0000 | [diff] [blame] | 7180 | /* Update the PFC configuration in case it was changed */ |
| 7181 | if (params->feature_config_flags & FEATURE_CONFIG_PFC_ENABLED) |
| 7182 | vars->link_status |= LINK_STATUS_PFC_ENABLED; |
| 7183 | else |
| 7184 | vars->link_status &= ~LINK_STATUS_PFC_ENABLED; |
| 7185 | |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 7186 | if (vars->link_up) |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 7187 | rc = bnx2x_update_link_up(params, vars, link_10g_plus); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 7188 | else |
| 7189 | rc = bnx2x_update_link_down(params, vars); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 7190 | |
Barak Witkowski | a334872 | 2012-04-23 03:04:46 +0000 | [diff] [blame] | 7191 | /* Update MCP link status was changed */ |
| 7192 | if (params->feature_config_flags & FEATURE_CONFIG_BC_SUPPORTS_AFEX) |
| 7193 | bnx2x_fw_command(bp, DRV_MSG_CODE_LINK_STATUS_CHANGED, 0); |
| 7194 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 7195 | return rc; |
| 7196 | } |
| 7197 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7198 | /*****************************************************************************/ |
| 7199 | /* External Phy section */ |
| 7200 | /*****************************************************************************/ |
| 7201 | void bnx2x_ext_phy_hw_reset(struct bnx2x *bp, u8 port) |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7202 | { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7203 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7204 | MISC_REGISTERS_GPIO_OUTPUT_LOW, port); |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 7205 | usleep_range(1000, 2000); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7206 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7207 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, port); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7208 | } |
| 7209 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7210 | static void bnx2x_save_spirom_version(struct bnx2x *bp, u8 port, |
| 7211 | u32 spirom_ver, u32 ver_addr) |
| 7212 | { |
| 7213 | DP(NETIF_MSG_LINK, "FW version 0x%x:0x%x for port %d\n", |
| 7214 | (u16)(spirom_ver>>16), (u16)spirom_ver, port); |
| 7215 | |
| 7216 | if (ver_addr) |
| 7217 | REG_WR(bp, ver_addr, spirom_ver); |
| 7218 | } |
| 7219 | |
| 7220 | static void bnx2x_save_bcm_spirom_ver(struct bnx2x *bp, |
| 7221 | struct bnx2x_phy *phy, |
| 7222 | u8 port) |
| 7223 | { |
| 7224 | u16 fw_ver1, fw_ver2; |
| 7225 | |
| 7226 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7227 | MDIO_PMA_REG_ROM_VER1, &fw_ver1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7228 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7229 | MDIO_PMA_REG_ROM_VER2, &fw_ver2); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7230 | bnx2x_save_spirom_version(bp, port, (u32)(fw_ver1<<16 | fw_ver2), |
| 7231 | phy->ver_addr); |
| 7232 | } |
| 7233 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7234 | static void bnx2x_ext_phy_10G_an_resolve(struct bnx2x *bp, |
| 7235 | struct bnx2x_phy *phy, |
| 7236 | struct link_vars *vars) |
| 7237 | { |
| 7238 | u16 val; |
| 7239 | bnx2x_cl45_read(bp, phy, |
| 7240 | MDIO_AN_DEVAD, |
| 7241 | MDIO_AN_REG_STATUS, &val); |
| 7242 | bnx2x_cl45_read(bp, phy, |
| 7243 | MDIO_AN_DEVAD, |
| 7244 | MDIO_AN_REG_STATUS, &val); |
| 7245 | if (val & (1<<5)) |
| 7246 | vars->link_status |= LINK_STATUS_AUTO_NEGOTIATE_COMPLETE; |
| 7247 | if ((val & (1<<0)) == 0) |
| 7248 | vars->link_status |= LINK_STATUS_PARALLEL_DETECTION_USED; |
| 7249 | } |
| 7250 | |
| 7251 | /******************************************************************/ |
| 7252 | /* common BCM8073/BCM8727 PHY SECTION */ |
| 7253 | /******************************************************************/ |
| 7254 | static void bnx2x_8073_resolve_fc(struct bnx2x_phy *phy, |
| 7255 | struct link_params *params, |
| 7256 | struct link_vars *vars) |
| 7257 | { |
| 7258 | struct bnx2x *bp = params->bp; |
| 7259 | if (phy->req_line_speed == SPEED_10 || |
| 7260 | phy->req_line_speed == SPEED_100) { |
| 7261 | vars->flow_ctrl = phy->req_flow_ctrl; |
| 7262 | return; |
| 7263 | } |
| 7264 | |
| 7265 | if (bnx2x_ext_phy_resolve_fc(phy, params, vars) && |
| 7266 | (vars->flow_ctrl == BNX2X_FLOW_CTRL_NONE)) { |
| 7267 | u16 pause_result; |
| 7268 | u16 ld_pause; /* local */ |
| 7269 | u16 lp_pause; /* link partner */ |
| 7270 | bnx2x_cl45_read(bp, phy, |
| 7271 | MDIO_AN_DEVAD, |
| 7272 | MDIO_AN_REG_CL37_FC_LD, &ld_pause); |
| 7273 | |
| 7274 | bnx2x_cl45_read(bp, phy, |
| 7275 | MDIO_AN_DEVAD, |
| 7276 | MDIO_AN_REG_CL37_FC_LP, &lp_pause); |
| 7277 | pause_result = (ld_pause & |
| 7278 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) >> 5; |
| 7279 | pause_result |= (lp_pause & |
| 7280 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) >> 7; |
| 7281 | |
| 7282 | bnx2x_pause_resolve(vars, pause_result); |
| 7283 | DP(NETIF_MSG_LINK, "Ext PHY CL37 pause result 0x%x\n", |
| 7284 | pause_result); |
| 7285 | } |
| 7286 | } |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 7287 | static int bnx2x_8073_8727_external_rom_boot(struct bnx2x *bp, |
| 7288 | struct bnx2x_phy *phy, |
| 7289 | u8 port) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7290 | { |
Yaniv Rosner | 5c99274b | 2011-01-18 04:33:36 +0000 | [diff] [blame] | 7291 | u32 count = 0; |
| 7292 | u16 fw_ver1, fw_msgout; |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 7293 | int rc = 0; |
Yaniv Rosner | 5c99274b | 2011-01-18 04:33:36 +0000 | [diff] [blame] | 7294 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7295 | /* Boot port from external ROM */ |
| 7296 | /* EDC grst */ |
| 7297 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7298 | MDIO_PMA_DEVAD, |
| 7299 | MDIO_PMA_REG_GEN_CTRL, |
| 7300 | 0x0001); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7301 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 7302 | /* Ucode reboot and rst */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7303 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7304 | MDIO_PMA_DEVAD, |
| 7305 | MDIO_PMA_REG_GEN_CTRL, |
| 7306 | 0x008c); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7307 | |
| 7308 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7309 | MDIO_PMA_DEVAD, |
| 7310 | MDIO_PMA_REG_MISC_CTRL1, 0x0001); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7311 | |
| 7312 | /* Reset internal microprocessor */ |
| 7313 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7314 | MDIO_PMA_DEVAD, |
| 7315 | MDIO_PMA_REG_GEN_CTRL, |
| 7316 | MDIO_PMA_REG_GEN_CTRL_ROM_MICRO_RESET); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7317 | |
| 7318 | /* Release srst bit */ |
| 7319 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7320 | MDIO_PMA_DEVAD, |
| 7321 | MDIO_PMA_REG_GEN_CTRL, |
| 7322 | MDIO_PMA_REG_GEN_CTRL_ROM_RESET_INTERNAL_MP); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7323 | |
Yaniv Rosner | 5c99274b | 2011-01-18 04:33:36 +0000 | [diff] [blame] | 7324 | /* Delay 100ms per the PHY specifications */ |
| 7325 | msleep(100); |
| 7326 | |
| 7327 | /* 8073 sometimes taking longer to download */ |
| 7328 | do { |
| 7329 | count++; |
| 7330 | if (count > 300) { |
| 7331 | DP(NETIF_MSG_LINK, |
| 7332 | "bnx2x_8073_8727_external_rom_boot port %x:" |
| 7333 | "Download failed. fw version = 0x%x\n", |
| 7334 | port, fw_ver1); |
| 7335 | rc = -EINVAL; |
| 7336 | break; |
| 7337 | } |
| 7338 | |
| 7339 | bnx2x_cl45_read(bp, phy, |
| 7340 | MDIO_PMA_DEVAD, |
| 7341 | MDIO_PMA_REG_ROM_VER1, &fw_ver1); |
| 7342 | bnx2x_cl45_read(bp, phy, |
| 7343 | MDIO_PMA_DEVAD, |
| 7344 | MDIO_PMA_REG_M8051_MSGOUT_REG, &fw_msgout); |
| 7345 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 7346 | usleep_range(1000, 2000); |
Yaniv Rosner | 5c99274b | 2011-01-18 04:33:36 +0000 | [diff] [blame] | 7347 | } while (fw_ver1 == 0 || fw_ver1 == 0x4321 || |
| 7348 | ((fw_msgout & 0xff) != 0x03 && (phy->type == |
| 7349 | PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073))); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7350 | |
| 7351 | /* Clear ser_boot_ctl bit */ |
| 7352 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7353 | MDIO_PMA_DEVAD, |
| 7354 | MDIO_PMA_REG_MISC_CTRL1, 0x0000); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7355 | bnx2x_save_bcm_spirom_ver(bp, phy, port); |
Yaniv Rosner | 5c99274b | 2011-01-18 04:33:36 +0000 | [diff] [blame] | 7356 | |
| 7357 | DP(NETIF_MSG_LINK, |
| 7358 | "bnx2x_8073_8727_external_rom_boot port %x:" |
| 7359 | "Download complete. fw version = 0x%x\n", |
| 7360 | port, fw_ver1); |
| 7361 | |
| 7362 | return rc; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7363 | } |
| 7364 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7365 | /******************************************************************/ |
| 7366 | /* BCM8073 PHY SECTION */ |
| 7367 | /******************************************************************/ |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 7368 | static int bnx2x_8073_is_snr_needed(struct bnx2x *bp, struct bnx2x_phy *phy) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7369 | { |
| 7370 | /* This is only required for 8073A1, version 102 only */ |
| 7371 | u16 val; |
| 7372 | |
| 7373 | /* Read 8073 HW revision*/ |
| 7374 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7375 | MDIO_PMA_DEVAD, |
| 7376 | MDIO_PMA_REG_8073_CHIP_REV, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7377 | |
| 7378 | if (val != 1) { |
| 7379 | /* No need to workaround in 8073 A1 */ |
| 7380 | return 0; |
| 7381 | } |
| 7382 | |
| 7383 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7384 | MDIO_PMA_DEVAD, |
| 7385 | MDIO_PMA_REG_ROM_VER2, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7386 | |
| 7387 | /* SNR should be applied only for version 0x102 */ |
| 7388 | if (val != 0x102) |
| 7389 | return 0; |
| 7390 | |
| 7391 | return 1; |
| 7392 | } |
| 7393 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 7394 | static int bnx2x_8073_xaui_wa(struct bnx2x *bp, struct bnx2x_phy *phy) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7395 | { |
| 7396 | u16 val, cnt, cnt1 ; |
| 7397 | |
| 7398 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7399 | MDIO_PMA_DEVAD, |
| 7400 | MDIO_PMA_REG_8073_CHIP_REV, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7401 | |
| 7402 | if (val > 0) { |
| 7403 | /* No need to workaround in 8073 A1 */ |
| 7404 | return 0; |
| 7405 | } |
| 7406 | /* XAUI workaround in 8073 A0: */ |
| 7407 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 7408 | /* After loading the boot ROM and restarting Autoneg, poll |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7409 | * Dev1, Reg $C820: |
| 7410 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7411 | |
| 7412 | for (cnt = 0; cnt < 1000; cnt++) { |
| 7413 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7414 | MDIO_PMA_DEVAD, |
| 7415 | MDIO_PMA_REG_8073_SPEED_LINK_STATUS, |
| 7416 | &val); |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 7417 | /* If bit [14] = 0 or bit [13] = 0, continue on with |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7418 | * system initialization (XAUI work-around not required, as |
| 7419 | * these bits indicate 2.5G or 1G link up). |
| 7420 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7421 | if (!(val & (1<<14)) || !(val & (1<<13))) { |
| 7422 | DP(NETIF_MSG_LINK, "XAUI work-around not required\n"); |
| 7423 | return 0; |
| 7424 | } else if (!(val & (1<<15))) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7425 | DP(NETIF_MSG_LINK, "bit 15 went off\n"); |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 7426 | /* If bit 15 is 0, then poll Dev1, Reg $C841 until it's |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7427 | * MSB (bit15) goes to 1 (indicating that the XAUI |
| 7428 | * workaround has completed), then continue on with |
| 7429 | * system initialization. |
| 7430 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7431 | for (cnt1 = 0; cnt1 < 1000; cnt1++) { |
| 7432 | bnx2x_cl45_read(bp, phy, |
| 7433 | MDIO_PMA_DEVAD, |
| 7434 | MDIO_PMA_REG_8073_XAUI_WA, &val); |
| 7435 | if (val & (1<<15)) { |
| 7436 | DP(NETIF_MSG_LINK, |
| 7437 | "XAUI workaround has completed\n"); |
| 7438 | return 0; |
| 7439 | } |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 7440 | usleep_range(3000, 6000); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7441 | } |
| 7442 | break; |
| 7443 | } |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 7444 | usleep_range(3000, 6000); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7445 | } |
| 7446 | DP(NETIF_MSG_LINK, "Warning: XAUI work-around timeout !!!\n"); |
| 7447 | return -EINVAL; |
| 7448 | } |
| 7449 | |
| 7450 | static void bnx2x_807x_force_10G(struct bnx2x *bp, struct bnx2x_phy *phy) |
| 7451 | { |
| 7452 | /* Force KR or KX */ |
| 7453 | bnx2x_cl45_write(bp, phy, |
| 7454 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 0x2040); |
| 7455 | bnx2x_cl45_write(bp, phy, |
| 7456 | MDIO_PMA_DEVAD, MDIO_PMA_REG_10G_CTRL2, 0x000b); |
| 7457 | bnx2x_cl45_write(bp, phy, |
| 7458 | MDIO_PMA_DEVAD, MDIO_PMA_REG_BCM_CTRL, 0x0000); |
| 7459 | bnx2x_cl45_write(bp, phy, |
| 7460 | MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, 0x0000); |
| 7461 | } |
| 7462 | |
| 7463 | static void bnx2x_8073_set_pause_cl37(struct link_params *params, |
| 7464 | struct bnx2x_phy *phy, |
| 7465 | struct link_vars *vars) |
| 7466 | { |
| 7467 | u16 cl37_val; |
| 7468 | struct bnx2x *bp = params->bp; |
| 7469 | bnx2x_cl45_read(bp, phy, |
| 7470 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_FC_LD, &cl37_val); |
| 7471 | |
| 7472 | cl37_val &= ~MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH; |
| 7473 | /* Please refer to Table 28B-3 of 802.3ab-1999 spec. */ |
| 7474 | bnx2x_calc_ieee_aneg_adv(phy, params, &vars->ieee_fc); |
| 7475 | if ((vars->ieee_fc & |
| 7476 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_SYMMETRIC) == |
| 7477 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_SYMMETRIC) { |
| 7478 | cl37_val |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_SYMMETRIC; |
| 7479 | } |
| 7480 | if ((vars->ieee_fc & |
| 7481 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC) == |
| 7482 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC) { |
| 7483 | cl37_val |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC; |
| 7484 | } |
| 7485 | if ((vars->ieee_fc & |
| 7486 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) == |
| 7487 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) { |
| 7488 | cl37_val |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH; |
| 7489 | } |
| 7490 | DP(NETIF_MSG_LINK, |
| 7491 | "Ext phy AN advertize cl37 0x%x\n", cl37_val); |
| 7492 | |
| 7493 | bnx2x_cl45_write(bp, phy, |
| 7494 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_FC_LD, cl37_val); |
| 7495 | msleep(500); |
| 7496 | } |
| 7497 | |
Yaniv Rosner | 5c107fd | 2012-09-13 02:56:19 +0000 | [diff] [blame] | 7498 | static void bnx2x_8073_specific_func(struct bnx2x_phy *phy, |
| 7499 | struct link_params *params, |
| 7500 | u32 action) |
| 7501 | { |
| 7502 | struct bnx2x *bp = params->bp; |
| 7503 | switch (action) { |
| 7504 | case PHY_INIT: |
| 7505 | /* Enable LASI */ |
| 7506 | bnx2x_cl45_write(bp, phy, |
| 7507 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_RXCTRL, (1<<2)); |
| 7508 | bnx2x_cl45_write(bp, phy, |
| 7509 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_CTRL, 0x0004); |
| 7510 | break; |
| 7511 | } |
| 7512 | } |
| 7513 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 7514 | static int bnx2x_8073_config_init(struct bnx2x_phy *phy, |
| 7515 | struct link_params *params, |
| 7516 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7517 | { |
| 7518 | struct bnx2x *bp = params->bp; |
| 7519 | u16 val = 0, tmp1; |
| 7520 | u8 gpio_port; |
| 7521 | DP(NETIF_MSG_LINK, "Init 8073\n"); |
| 7522 | |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 7523 | if (CHIP_IS_E2(bp)) |
| 7524 | gpio_port = BP_PATH(bp); |
| 7525 | else |
| 7526 | gpio_port = params->port; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7527 | /* Restore normal power mode*/ |
| 7528 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7529 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, gpio_port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7530 | |
| 7531 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7532 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, gpio_port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7533 | |
Yaniv Rosner | 5c107fd | 2012-09-13 02:56:19 +0000 | [diff] [blame] | 7534 | bnx2x_8073_specific_func(phy, params, PHY_INIT); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7535 | bnx2x_8073_set_pause_cl37(params, phy, vars); |
| 7536 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7537 | bnx2x_cl45_read(bp, phy, |
| 7538 | MDIO_PMA_DEVAD, MDIO_PMA_REG_M8051_MSGOUT_REG, &tmp1); |
| 7539 | |
| 7540 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 7541 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_RXSTAT, &tmp1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7542 | |
| 7543 | DP(NETIF_MSG_LINK, "Before rom RX_ALARM(port1): 0x%x\n", tmp1); |
| 7544 | |
Yaniv Rosner | 74d7a11 | 2011-01-18 04:33:18 +0000 | [diff] [blame] | 7545 | /* Swap polarity if required - Must be done only in non-1G mode */ |
| 7546 | if (params->lane_config & PORT_HW_CFG_SWAP_PHY_POLARITY_ENABLED) { |
| 7547 | /* Configure the 8073 to swap _P and _N of the KR lines */ |
| 7548 | DP(NETIF_MSG_LINK, "Swapping polarity for the 8073\n"); |
| 7549 | /* 10G Rx/Tx and 1G Tx signal polarity swap */ |
| 7550 | bnx2x_cl45_read(bp, phy, |
| 7551 | MDIO_PMA_DEVAD, |
| 7552 | MDIO_PMA_REG_8073_OPT_DIGITAL_CTRL, &val); |
| 7553 | bnx2x_cl45_write(bp, phy, |
| 7554 | MDIO_PMA_DEVAD, |
| 7555 | MDIO_PMA_REG_8073_OPT_DIGITAL_CTRL, |
| 7556 | (val | (3<<9))); |
| 7557 | } |
| 7558 | |
| 7559 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7560 | /* Enable CL37 BAM */ |
Yaniv Rosner | 121839b | 2010-11-01 05:32:38 +0000 | [diff] [blame] | 7561 | if (REG_RD(bp, params->shmem_base + |
| 7562 | offsetof(struct shmem_region, dev_info. |
| 7563 | port_hw_config[params->port].default_cfg)) & |
| 7564 | PORT_HW_CFG_ENABLE_BAM_ON_KR_ENABLED) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7565 | |
Yaniv Rosner | 121839b | 2010-11-01 05:32:38 +0000 | [diff] [blame] | 7566 | bnx2x_cl45_read(bp, phy, |
| 7567 | MDIO_AN_DEVAD, |
| 7568 | MDIO_AN_REG_8073_BAM, &val); |
| 7569 | bnx2x_cl45_write(bp, phy, |
| 7570 | MDIO_AN_DEVAD, |
| 7571 | MDIO_AN_REG_8073_BAM, val | 1); |
| 7572 | DP(NETIF_MSG_LINK, "Enable CL37 BAM on KR\n"); |
| 7573 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7574 | if (params->loopback_mode == LOOPBACK_EXT) { |
| 7575 | bnx2x_807x_force_10G(bp, phy); |
| 7576 | DP(NETIF_MSG_LINK, "Forced speed 10G on 807X\n"); |
| 7577 | return 0; |
| 7578 | } else { |
| 7579 | bnx2x_cl45_write(bp, phy, |
| 7580 | MDIO_PMA_DEVAD, MDIO_PMA_REG_BCM_CTRL, 0x0002); |
| 7581 | } |
| 7582 | if (phy->req_line_speed != SPEED_AUTO_NEG) { |
| 7583 | if (phy->req_line_speed == SPEED_10000) { |
| 7584 | val = (1<<7); |
| 7585 | } else if (phy->req_line_speed == SPEED_2500) { |
| 7586 | val = (1<<5); |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 7587 | /* Note that 2.5G works only when used with 1G |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 7588 | * advertisement |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7589 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7590 | } else |
| 7591 | val = (1<<5); |
| 7592 | } else { |
| 7593 | val = 0; |
| 7594 | if (phy->speed_cap_mask & |
| 7595 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G) |
| 7596 | val |= (1<<7); |
| 7597 | |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 7598 | /* Note that 2.5G works only when used with 1G advertisement */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7599 | if (phy->speed_cap_mask & |
| 7600 | (PORT_HW_CFG_SPEED_CAPABILITY_D0_1G | |
| 7601 | PORT_HW_CFG_SPEED_CAPABILITY_D0_2_5G)) |
| 7602 | val |= (1<<5); |
| 7603 | DP(NETIF_MSG_LINK, "807x autoneg val = 0x%x\n", val); |
| 7604 | } |
| 7605 | |
| 7606 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_ADV, val); |
| 7607 | bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_8073_2_5G, &tmp1); |
| 7608 | |
| 7609 | if (((phy->speed_cap_mask & PORT_HW_CFG_SPEED_CAPABILITY_D0_2_5G) && |
| 7610 | (phy->req_line_speed == SPEED_AUTO_NEG)) || |
| 7611 | (phy->req_line_speed == SPEED_2500)) { |
| 7612 | u16 phy_ver; |
| 7613 | /* Allow 2.5G for A1 and above */ |
| 7614 | bnx2x_cl45_read(bp, phy, |
| 7615 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8073_CHIP_REV, |
| 7616 | &phy_ver); |
| 7617 | DP(NETIF_MSG_LINK, "Add 2.5G\n"); |
| 7618 | if (phy_ver > 0) |
| 7619 | tmp1 |= 1; |
| 7620 | else |
| 7621 | tmp1 &= 0xfffe; |
| 7622 | } else { |
| 7623 | DP(NETIF_MSG_LINK, "Disable 2.5G\n"); |
| 7624 | tmp1 &= 0xfffe; |
| 7625 | } |
| 7626 | |
| 7627 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_8073_2_5G, tmp1); |
| 7628 | /* Add support for CL37 (passive mode) II */ |
| 7629 | |
| 7630 | bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_CL37_FC_LD, &tmp1); |
| 7631 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_CL37_FC_LD, |
| 7632 | (tmp1 | ((phy->req_duplex == DUPLEX_FULL) ? |
| 7633 | 0x20 : 0x40))); |
| 7634 | |
| 7635 | /* Add support for CL37 (passive mode) III */ |
| 7636 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_CL37_AN, 0x1000); |
| 7637 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 7638 | /* The SNR will improve about 2db by changing BW and FEE main |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7639 | * tap. Rest commands are executed after link is up |
| 7640 | * Change FFE main cursor to 5 in EDC register |
| 7641 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7642 | if (bnx2x_8073_is_snr_needed(bp, phy)) |
| 7643 | bnx2x_cl45_write(bp, phy, |
| 7644 | MDIO_PMA_DEVAD, MDIO_PMA_REG_EDC_FFE_MAIN, |
| 7645 | 0xFB0C); |
| 7646 | |
| 7647 | /* Enable FEC (Forware Error Correction) Request in the AN */ |
| 7648 | bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_ADV2, &tmp1); |
| 7649 | tmp1 |= (1<<15); |
| 7650 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_ADV2, tmp1); |
| 7651 | |
| 7652 | bnx2x_ext_phy_set_pause(params, phy, vars); |
| 7653 | |
| 7654 | /* Restart autoneg */ |
| 7655 | msleep(500); |
| 7656 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, 0x1200); |
| 7657 | DP(NETIF_MSG_LINK, "807x Autoneg Restart: Advertise 1G=%x, 10G=%x\n", |
| 7658 | ((val & (1<<5)) > 0), ((val & (1<<7)) > 0)); |
| 7659 | return 0; |
| 7660 | } |
| 7661 | |
| 7662 | static u8 bnx2x_8073_read_status(struct bnx2x_phy *phy, |
| 7663 | struct link_params *params, |
| 7664 | struct link_vars *vars) |
| 7665 | { |
| 7666 | struct bnx2x *bp = params->bp; |
| 7667 | u8 link_up = 0; |
| 7668 | u16 val1, val2; |
| 7669 | u16 link_status = 0; |
| 7670 | u16 an1000_status = 0; |
| 7671 | |
| 7672 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 7673 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_STAT, &val1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7674 | |
| 7675 | DP(NETIF_MSG_LINK, "8703 LASI status 0x%x\n", val1); |
| 7676 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 7677 | /* Clear the interrupt LASI status register */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7678 | bnx2x_cl45_read(bp, phy, |
| 7679 | MDIO_PCS_DEVAD, MDIO_PCS_REG_STATUS, &val2); |
| 7680 | bnx2x_cl45_read(bp, phy, |
| 7681 | MDIO_PCS_DEVAD, MDIO_PCS_REG_STATUS, &val1); |
| 7682 | DP(NETIF_MSG_LINK, "807x PCS status 0x%x->0x%x\n", val2, val1); |
| 7683 | /* Clear MSG-OUT */ |
| 7684 | bnx2x_cl45_read(bp, phy, |
| 7685 | MDIO_PMA_DEVAD, MDIO_PMA_REG_M8051_MSGOUT_REG, &val1); |
| 7686 | |
| 7687 | /* Check the LASI */ |
| 7688 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 7689 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_RXSTAT, &val2); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7690 | |
| 7691 | DP(NETIF_MSG_LINK, "KR 0x9003 0x%x\n", val2); |
| 7692 | |
| 7693 | /* Check the link status */ |
| 7694 | bnx2x_cl45_read(bp, phy, |
| 7695 | MDIO_PCS_DEVAD, MDIO_PCS_REG_STATUS, &val2); |
| 7696 | DP(NETIF_MSG_LINK, "KR PCS status 0x%x\n", val2); |
| 7697 | |
| 7698 | bnx2x_cl45_read(bp, phy, |
| 7699 | MDIO_PMA_DEVAD, MDIO_PMA_REG_STATUS, &val2); |
| 7700 | bnx2x_cl45_read(bp, phy, |
| 7701 | MDIO_PMA_DEVAD, MDIO_PMA_REG_STATUS, &val1); |
| 7702 | link_up = ((val1 & 4) == 4); |
| 7703 | DP(NETIF_MSG_LINK, "PMA_REG_STATUS=0x%x\n", val1); |
| 7704 | |
| 7705 | if (link_up && |
| 7706 | ((phy->req_line_speed != SPEED_10000))) { |
| 7707 | if (bnx2x_8073_xaui_wa(bp, phy) != 0) |
| 7708 | return 0; |
| 7709 | } |
| 7710 | bnx2x_cl45_read(bp, phy, |
| 7711 | MDIO_AN_DEVAD, MDIO_AN_REG_LINK_STATUS, &an1000_status); |
| 7712 | bnx2x_cl45_read(bp, phy, |
| 7713 | MDIO_AN_DEVAD, MDIO_AN_REG_LINK_STATUS, &an1000_status); |
| 7714 | |
| 7715 | /* Check the link status on 1.1.2 */ |
| 7716 | bnx2x_cl45_read(bp, phy, |
| 7717 | MDIO_PMA_DEVAD, MDIO_PMA_REG_STATUS, &val2); |
| 7718 | bnx2x_cl45_read(bp, phy, |
| 7719 | MDIO_PMA_DEVAD, MDIO_PMA_REG_STATUS, &val1); |
| 7720 | DP(NETIF_MSG_LINK, "KR PMA status 0x%x->0x%x," |
| 7721 | "an_link_status=0x%x\n", val2, val1, an1000_status); |
| 7722 | |
| 7723 | link_up = (((val1 & 4) == 4) || (an1000_status & (1<<1))); |
| 7724 | if (link_up && bnx2x_8073_is_snr_needed(bp, phy)) { |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 7725 | /* The SNR will improve about 2dbby changing the BW and FEE main |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7726 | * tap. The 1st write to change FFE main tap is set before |
| 7727 | * restart AN. Change PLL Bandwidth in EDC register |
| 7728 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7729 | bnx2x_cl45_write(bp, phy, |
| 7730 | MDIO_PMA_DEVAD, MDIO_PMA_REG_PLL_BANDWIDTH, |
| 7731 | 0x26BC); |
| 7732 | |
| 7733 | /* Change CDR Bandwidth in EDC register */ |
| 7734 | bnx2x_cl45_write(bp, phy, |
| 7735 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CDR_BANDWIDTH, |
| 7736 | 0x0333); |
| 7737 | } |
| 7738 | bnx2x_cl45_read(bp, phy, |
| 7739 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8073_SPEED_LINK_STATUS, |
| 7740 | &link_status); |
| 7741 | |
| 7742 | /* Bits 0..2 --> speed detected, bits 13..15--> link is down */ |
| 7743 | if ((link_status & (1<<2)) && (!(link_status & (1<<15)))) { |
| 7744 | link_up = 1; |
| 7745 | vars->line_speed = SPEED_10000; |
| 7746 | DP(NETIF_MSG_LINK, "port %x: External link up in 10G\n", |
| 7747 | params->port); |
| 7748 | } else if ((link_status & (1<<1)) && (!(link_status & (1<<14)))) { |
| 7749 | link_up = 1; |
| 7750 | vars->line_speed = SPEED_2500; |
| 7751 | DP(NETIF_MSG_LINK, "port %x: External link up in 2.5G\n", |
| 7752 | params->port); |
| 7753 | } else if ((link_status & (1<<0)) && (!(link_status & (1<<13)))) { |
| 7754 | link_up = 1; |
| 7755 | vars->line_speed = SPEED_1000; |
| 7756 | DP(NETIF_MSG_LINK, "port %x: External link up in 1G\n", |
| 7757 | params->port); |
| 7758 | } else { |
| 7759 | link_up = 0; |
| 7760 | DP(NETIF_MSG_LINK, "port %x: External link is down\n", |
| 7761 | params->port); |
| 7762 | } |
| 7763 | |
| 7764 | if (link_up) { |
Yaniv Rosner | 74d7a11 | 2011-01-18 04:33:18 +0000 | [diff] [blame] | 7765 | /* Swap polarity if required */ |
| 7766 | if (params->lane_config & |
| 7767 | PORT_HW_CFG_SWAP_PHY_POLARITY_ENABLED) { |
| 7768 | /* Configure the 8073 to swap P and N of the KR lines */ |
| 7769 | bnx2x_cl45_read(bp, phy, |
| 7770 | MDIO_XS_DEVAD, |
| 7771 | MDIO_XS_REG_8073_RX_CTRL_PCIE, &val1); |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 7772 | /* Set bit 3 to invert Rx in 1G mode and clear this bit |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7773 | * when it`s in 10G mode. |
| 7774 | */ |
Yaniv Rosner | 74d7a11 | 2011-01-18 04:33:18 +0000 | [diff] [blame] | 7775 | if (vars->line_speed == SPEED_1000) { |
| 7776 | DP(NETIF_MSG_LINK, "Swapping 1G polarity for" |
| 7777 | "the 8073\n"); |
| 7778 | val1 |= (1<<3); |
| 7779 | } else |
| 7780 | val1 &= ~(1<<3); |
| 7781 | |
| 7782 | bnx2x_cl45_write(bp, phy, |
| 7783 | MDIO_XS_DEVAD, |
| 7784 | MDIO_XS_REG_8073_RX_CTRL_PCIE, |
| 7785 | val1); |
| 7786 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7787 | bnx2x_ext_phy_10G_an_resolve(bp, phy, vars); |
| 7788 | bnx2x_8073_resolve_fc(phy, params, vars); |
Yaniv Rosner | 791f18c | 2011-01-18 04:33:42 +0000 | [diff] [blame] | 7789 | vars->duplex = DUPLEX_FULL; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7790 | } |
Mintz Yuval | 9e7e839 | 2012-02-15 02:10:24 +0000 | [diff] [blame] | 7791 | |
| 7792 | if (vars->link_status & LINK_STATUS_AUTO_NEGOTIATE_COMPLETE) { |
| 7793 | bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD, |
| 7794 | MDIO_AN_REG_LP_AUTO_NEG2, &val1); |
| 7795 | |
| 7796 | if (val1 & (1<<5)) |
| 7797 | vars->link_status |= |
| 7798 | LINK_STATUS_LINK_PARTNER_1000TFD_CAPABLE; |
| 7799 | if (val1 & (1<<7)) |
| 7800 | vars->link_status |= |
| 7801 | LINK_STATUS_LINK_PARTNER_10GXFD_CAPABLE; |
| 7802 | } |
| 7803 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7804 | return link_up; |
| 7805 | } |
| 7806 | |
| 7807 | static void bnx2x_8073_link_reset(struct bnx2x_phy *phy, |
| 7808 | struct link_params *params) |
| 7809 | { |
| 7810 | struct bnx2x *bp = params->bp; |
| 7811 | u8 gpio_port; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 7812 | if (CHIP_IS_E2(bp)) |
| 7813 | gpio_port = BP_PATH(bp); |
| 7814 | else |
| 7815 | gpio_port = params->port; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7816 | DP(NETIF_MSG_LINK, "Setting 8073 port %d into low power mode\n", |
| 7817 | gpio_port); |
| 7818 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7819 | MISC_REGISTERS_GPIO_OUTPUT_LOW, |
| 7820 | gpio_port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7821 | } |
| 7822 | |
| 7823 | /******************************************************************/ |
| 7824 | /* BCM8705 PHY SECTION */ |
| 7825 | /******************************************************************/ |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 7826 | static int bnx2x_8705_config_init(struct bnx2x_phy *phy, |
| 7827 | struct link_params *params, |
| 7828 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7829 | { |
| 7830 | struct bnx2x *bp = params->bp; |
| 7831 | DP(NETIF_MSG_LINK, "init 8705\n"); |
| 7832 | /* Restore normal power mode*/ |
| 7833 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7834 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, params->port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7835 | /* HW reset */ |
| 7836 | bnx2x_ext_phy_hw_reset(bp, params->port); |
| 7837 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 0xa040); |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 7838 | bnx2x_wait_reset_complete(bp, phy, params); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7839 | |
| 7840 | bnx2x_cl45_write(bp, phy, |
| 7841 | MDIO_PMA_DEVAD, MDIO_PMA_REG_MISC_CTRL, 0x8288); |
| 7842 | bnx2x_cl45_write(bp, phy, |
| 7843 | MDIO_PMA_DEVAD, MDIO_PMA_REG_PHY_IDENTIFIER, 0x7fbf); |
| 7844 | bnx2x_cl45_write(bp, phy, |
| 7845 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CMU_PLL_BYPASS, 0x0100); |
| 7846 | bnx2x_cl45_write(bp, phy, |
| 7847 | MDIO_WIS_DEVAD, MDIO_WIS_REG_LASI_CNTL, 0x1); |
| 7848 | /* BCM8705 doesn't have microcode, hence the 0 */ |
| 7849 | bnx2x_save_spirom_version(bp, params->port, params->shmem_base, 0); |
| 7850 | return 0; |
| 7851 | } |
| 7852 | |
| 7853 | static u8 bnx2x_8705_read_status(struct bnx2x_phy *phy, |
| 7854 | struct link_params *params, |
| 7855 | struct link_vars *vars) |
| 7856 | { |
| 7857 | u8 link_up = 0; |
| 7858 | u16 val1, rx_sd; |
| 7859 | struct bnx2x *bp = params->bp; |
| 7860 | DP(NETIF_MSG_LINK, "read status 8705\n"); |
| 7861 | bnx2x_cl45_read(bp, phy, |
| 7862 | MDIO_WIS_DEVAD, MDIO_WIS_REG_LASI_STATUS, &val1); |
| 7863 | DP(NETIF_MSG_LINK, "8705 LASI status 0x%x\n", val1); |
| 7864 | |
| 7865 | bnx2x_cl45_read(bp, phy, |
| 7866 | MDIO_WIS_DEVAD, MDIO_WIS_REG_LASI_STATUS, &val1); |
| 7867 | DP(NETIF_MSG_LINK, "8705 LASI status 0x%x\n", val1); |
| 7868 | |
| 7869 | bnx2x_cl45_read(bp, phy, |
| 7870 | MDIO_PMA_DEVAD, MDIO_PMA_REG_RX_SD, &rx_sd); |
| 7871 | |
| 7872 | bnx2x_cl45_read(bp, phy, |
| 7873 | MDIO_PMA_DEVAD, 0xc809, &val1); |
| 7874 | bnx2x_cl45_read(bp, phy, |
| 7875 | MDIO_PMA_DEVAD, 0xc809, &val1); |
| 7876 | |
| 7877 | DP(NETIF_MSG_LINK, "8705 1.c809 val=0x%x\n", val1); |
| 7878 | link_up = ((rx_sd & 0x1) && (val1 & (1<<9)) && ((val1 & (1<<8)) == 0)); |
| 7879 | if (link_up) { |
| 7880 | vars->line_speed = SPEED_10000; |
| 7881 | bnx2x_ext_phy_resolve_fc(phy, params, vars); |
| 7882 | } |
| 7883 | return link_up; |
| 7884 | } |
| 7885 | |
| 7886 | /******************************************************************/ |
| 7887 | /* SFP+ module Section */ |
| 7888 | /******************************************************************/ |
Yaniv Rosner | 85242ee | 2011-07-05 01:06:53 +0000 | [diff] [blame] | 7889 | static void bnx2x_set_disable_pmd_transmit(struct link_params *params, |
| 7890 | struct bnx2x_phy *phy, |
| 7891 | u8 pmd_dis) |
| 7892 | { |
| 7893 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 7894 | /* Disable transmitter only for bootcodes which can enable it afterwards |
Yaniv Rosner | 85242ee | 2011-07-05 01:06:53 +0000 | [diff] [blame] | 7895 | * (for D3 link) |
| 7896 | */ |
| 7897 | if (pmd_dis) { |
| 7898 | if (params->feature_config_flags & |
| 7899 | FEATURE_CONFIG_BC_SUPPORTS_SFP_TX_DISABLED) |
| 7900 | DP(NETIF_MSG_LINK, "Disabling PMD transmitter\n"); |
| 7901 | else { |
| 7902 | DP(NETIF_MSG_LINK, "NOT disabling PMD transmitter\n"); |
| 7903 | return; |
| 7904 | } |
| 7905 | } else |
| 7906 | DP(NETIF_MSG_LINK, "Enabling PMD transmitter\n"); |
| 7907 | bnx2x_cl45_write(bp, phy, |
| 7908 | MDIO_PMA_DEVAD, |
| 7909 | MDIO_PMA_REG_TX_DISABLE, pmd_dis); |
| 7910 | } |
| 7911 | |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 7912 | static u8 bnx2x_get_gpio_port(struct link_params *params) |
| 7913 | { |
| 7914 | u8 gpio_port; |
| 7915 | u32 swap_val, swap_override; |
| 7916 | struct bnx2x *bp = params->bp; |
| 7917 | if (CHIP_IS_E2(bp)) |
| 7918 | gpio_port = BP_PATH(bp); |
| 7919 | else |
| 7920 | gpio_port = params->port; |
| 7921 | swap_val = REG_RD(bp, NIG_REG_PORT_SWAP); |
| 7922 | swap_override = REG_RD(bp, NIG_REG_STRAP_OVERRIDE); |
| 7923 | return gpio_port ^ (swap_val && swap_override); |
| 7924 | } |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 7925 | |
| 7926 | static void bnx2x_sfp_e1e2_set_transmitter(struct link_params *params, |
| 7927 | struct bnx2x_phy *phy, |
| 7928 | u8 tx_en) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7929 | { |
| 7930 | u16 val; |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 7931 | u8 port = params->port; |
| 7932 | struct bnx2x *bp = params->bp; |
| 7933 | u32 tx_en_mode; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7934 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7935 | /* Disable/Enable transmitter ( TX laser of the SFP+ module.)*/ |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 7936 | tx_en_mode = REG_RD(bp, params->shmem_base + |
| 7937 | offsetof(struct shmem_region, |
| 7938 | dev_info.port_hw_config[port].sfp_ctrl)) & |
| 7939 | PORT_HW_CFG_TX_LASER_MASK; |
| 7940 | DP(NETIF_MSG_LINK, "Setting transmitter tx_en=%x for port %x " |
| 7941 | "mode = %x\n", tx_en, port, tx_en_mode); |
| 7942 | switch (tx_en_mode) { |
| 7943 | case PORT_HW_CFG_TX_LASER_MDIO: |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7944 | |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 7945 | bnx2x_cl45_read(bp, phy, |
| 7946 | MDIO_PMA_DEVAD, |
| 7947 | MDIO_PMA_REG_PHY_IDENTIFIER, |
| 7948 | &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7949 | |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 7950 | if (tx_en) |
| 7951 | val &= ~(1<<15); |
| 7952 | else |
| 7953 | val |= (1<<15); |
| 7954 | |
| 7955 | bnx2x_cl45_write(bp, phy, |
| 7956 | MDIO_PMA_DEVAD, |
| 7957 | MDIO_PMA_REG_PHY_IDENTIFIER, |
| 7958 | val); |
| 7959 | break; |
| 7960 | case PORT_HW_CFG_TX_LASER_GPIO0: |
| 7961 | case PORT_HW_CFG_TX_LASER_GPIO1: |
| 7962 | case PORT_HW_CFG_TX_LASER_GPIO2: |
| 7963 | case PORT_HW_CFG_TX_LASER_GPIO3: |
| 7964 | { |
| 7965 | u16 gpio_pin; |
| 7966 | u8 gpio_port, gpio_mode; |
| 7967 | if (tx_en) |
| 7968 | gpio_mode = MISC_REGISTERS_GPIO_OUTPUT_HIGH; |
| 7969 | else |
| 7970 | gpio_mode = MISC_REGISTERS_GPIO_OUTPUT_LOW; |
| 7971 | |
| 7972 | gpio_pin = tx_en_mode - PORT_HW_CFG_TX_LASER_GPIO0; |
| 7973 | gpio_port = bnx2x_get_gpio_port(params); |
| 7974 | bnx2x_set_gpio(bp, gpio_pin, gpio_mode, gpio_port); |
| 7975 | break; |
| 7976 | } |
| 7977 | default: |
| 7978 | DP(NETIF_MSG_LINK, "Invalid TX_LASER_MDIO 0x%x\n", tx_en_mode); |
| 7979 | break; |
| 7980 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7981 | } |
| 7982 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 7983 | static void bnx2x_sfp_set_transmitter(struct link_params *params, |
| 7984 | struct bnx2x_phy *phy, |
| 7985 | u8 tx_en) |
| 7986 | { |
| 7987 | struct bnx2x *bp = params->bp; |
| 7988 | DP(NETIF_MSG_LINK, "Setting SFP+ transmitter to %d\n", tx_en); |
| 7989 | if (CHIP_IS_E3(bp)) |
| 7990 | bnx2x_sfp_e3_set_transmitter(params, phy, tx_en); |
| 7991 | else |
| 7992 | bnx2x_sfp_e1e2_set_transmitter(params, phy, tx_en); |
| 7993 | } |
| 7994 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 7995 | static int bnx2x_8726_read_sfp_module_eeprom(struct bnx2x_phy *phy, |
| 7996 | struct link_params *params, |
| 7997 | u16 addr, u8 byte_cnt, u8 *o_buf) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7998 | { |
| 7999 | struct bnx2x *bp = params->bp; |
| 8000 | u16 val = 0; |
| 8001 | u16 i; |
Yuval Mintz | 24ea818 | 2012-06-20 19:05:23 +0000 | [diff] [blame] | 8002 | if (byte_cnt > SFP_EEPROM_PAGE_SIZE) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 8003 | DP(NETIF_MSG_LINK, |
| 8004 | "Reading from eeprom is limited to 0xf\n"); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8005 | return -EINVAL; |
| 8006 | } |
| 8007 | /* Set the read command byte count */ |
| 8008 | bnx2x_cl45_write(bp, phy, |
| 8009 | MDIO_PMA_DEVAD, MDIO_PMA_REG_SFP_TWO_WIRE_BYTE_CNT, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8010 | (byte_cnt | 0xa000)); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8011 | |
| 8012 | /* Set the read command address */ |
| 8013 | bnx2x_cl45_write(bp, phy, |
| 8014 | MDIO_PMA_DEVAD, MDIO_PMA_REG_SFP_TWO_WIRE_MEM_ADDR, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8015 | addr); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8016 | |
| 8017 | /* Activate read command */ |
| 8018 | bnx2x_cl45_write(bp, phy, |
| 8019 | MDIO_PMA_DEVAD, MDIO_PMA_REG_SFP_TWO_WIRE_CTRL, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8020 | 0x2c0f); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8021 | |
| 8022 | /* Wait up to 500us for command complete status */ |
| 8023 | for (i = 0; i < 100; i++) { |
| 8024 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8025 | MDIO_PMA_DEVAD, |
| 8026 | MDIO_PMA_REG_SFP_TWO_WIRE_CTRL, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8027 | if ((val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK) == |
| 8028 | MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_COMPLETE) |
| 8029 | break; |
| 8030 | udelay(5); |
| 8031 | } |
| 8032 | |
| 8033 | if ((val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK) != |
| 8034 | MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_COMPLETE) { |
| 8035 | DP(NETIF_MSG_LINK, |
| 8036 | "Got bad status 0x%x when reading from SFP+ EEPROM\n", |
| 8037 | (val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK)); |
| 8038 | return -EINVAL; |
| 8039 | } |
| 8040 | |
| 8041 | /* Read the buffer */ |
| 8042 | for (i = 0; i < byte_cnt; i++) { |
| 8043 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8044 | MDIO_PMA_DEVAD, |
| 8045 | MDIO_PMA_REG_8726_TWO_WIRE_DATA_BUF + i, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8046 | o_buf[i] = (u8)(val & MDIO_PMA_REG_8726_TWO_WIRE_DATA_MASK); |
| 8047 | } |
| 8048 | |
| 8049 | for (i = 0; i < 100; i++) { |
| 8050 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8051 | MDIO_PMA_DEVAD, |
| 8052 | MDIO_PMA_REG_SFP_TWO_WIRE_CTRL, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8053 | if ((val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK) == |
| 8054 | MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_IDLE) |
Joe Perches | 6f38ad9 | 2010-11-14 17:04:31 +0000 | [diff] [blame] | 8055 | return 0; |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 8056 | usleep_range(1000, 2000); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8057 | } |
| 8058 | return -EINVAL; |
| 8059 | } |
| 8060 | |
Yuval Mintz | 50a2984 | 2012-06-16 20:27:14 +0000 | [diff] [blame] | 8061 | static void bnx2x_warpcore_power_module(struct link_params *params, |
| 8062 | struct bnx2x_phy *phy, |
| 8063 | u8 power) |
| 8064 | { |
| 8065 | u32 pin_cfg; |
| 8066 | struct bnx2x *bp = params->bp; |
| 8067 | |
| 8068 | pin_cfg = (REG_RD(bp, params->shmem_base + |
| 8069 | offsetof(struct shmem_region, |
| 8070 | dev_info.port_hw_config[params->port].e3_sfp_ctrl)) & |
| 8071 | PORT_HW_CFG_E3_PWR_DIS_MASK) >> |
| 8072 | PORT_HW_CFG_E3_PWR_DIS_SHIFT; |
| 8073 | |
| 8074 | if (pin_cfg == PIN_CFG_NA) |
| 8075 | return; |
| 8076 | DP(NETIF_MSG_LINK, "Setting SFP+ module power to %d using pin cfg %d\n", |
| 8077 | power, pin_cfg); |
| 8078 | /* Low ==> corresponding SFP+ module is powered |
| 8079 | * high ==> the SFP+ module is powered down |
| 8080 | */ |
| 8081 | bnx2x_set_cfg_pin(bp, pin_cfg, power ^ 1); |
| 8082 | } |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8083 | static int bnx2x_warpcore_read_sfp_module_eeprom(struct bnx2x_phy *phy, |
| 8084 | struct link_params *params, |
| 8085 | u16 addr, u8 byte_cnt, |
| 8086 | u8 *o_buf) |
| 8087 | { |
| 8088 | int rc = 0; |
| 8089 | u8 i, j = 0, cnt = 0; |
| 8090 | u32 data_array[4]; |
| 8091 | u16 addr32; |
| 8092 | struct bnx2x *bp = params->bp; |
Yuval Mintz | 24ea818 | 2012-06-20 19:05:23 +0000 | [diff] [blame] | 8093 | |
| 8094 | if (byte_cnt > SFP_EEPROM_PAGE_SIZE) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 8095 | DP(NETIF_MSG_LINK, |
| 8096 | "Reading from eeprom is limited to 16 bytes\n"); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8097 | return -EINVAL; |
| 8098 | } |
| 8099 | |
| 8100 | /* 4 byte aligned address */ |
| 8101 | addr32 = addr & (~0x3); |
| 8102 | do { |
Yuval Mintz | 50a2984 | 2012-06-16 20:27:14 +0000 | [diff] [blame] | 8103 | if (cnt == I2C_WA_PWR_ITER) { |
| 8104 | bnx2x_warpcore_power_module(params, phy, 0); |
| 8105 | /* Note that 100us are not enough here */ |
| 8106 | usleep_range(1000,1000); |
| 8107 | bnx2x_warpcore_power_module(params, phy, 1); |
| 8108 | } |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8109 | rc = bnx2x_bsc_read(params, phy, 0xa0, addr32, 0, byte_cnt, |
| 8110 | data_array); |
| 8111 | } while ((rc != 0) && (++cnt < I2C_WA_RETRY_CNT)); |
| 8112 | |
| 8113 | if (rc == 0) { |
| 8114 | for (i = (addr - addr32); i < byte_cnt + (addr - addr32); i++) { |
| 8115 | o_buf[j] = *((u8 *)data_array + i); |
| 8116 | j++; |
| 8117 | } |
| 8118 | } |
| 8119 | |
| 8120 | return rc; |
| 8121 | } |
| 8122 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 8123 | static int bnx2x_8727_read_sfp_module_eeprom(struct bnx2x_phy *phy, |
| 8124 | struct link_params *params, |
| 8125 | u16 addr, u8 byte_cnt, u8 *o_buf) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8126 | { |
| 8127 | struct bnx2x *bp = params->bp; |
| 8128 | u16 val, i; |
| 8129 | |
Yuval Mintz | 24ea818 | 2012-06-20 19:05:23 +0000 | [diff] [blame] | 8130 | if (byte_cnt > SFP_EEPROM_PAGE_SIZE) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 8131 | DP(NETIF_MSG_LINK, |
| 8132 | "Reading from eeprom is limited to 0xf\n"); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8133 | return -EINVAL; |
| 8134 | } |
| 8135 | |
| 8136 | /* Need to read from 1.8000 to clear it */ |
| 8137 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8138 | MDIO_PMA_DEVAD, |
| 8139 | MDIO_PMA_REG_SFP_TWO_WIRE_CTRL, |
| 8140 | &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8141 | |
| 8142 | /* Set the read command byte count */ |
| 8143 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8144 | MDIO_PMA_DEVAD, |
| 8145 | MDIO_PMA_REG_SFP_TWO_WIRE_BYTE_CNT, |
| 8146 | ((byte_cnt < 2) ? 2 : byte_cnt)); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8147 | |
| 8148 | /* Set the read command address */ |
| 8149 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8150 | MDIO_PMA_DEVAD, |
| 8151 | MDIO_PMA_REG_SFP_TWO_WIRE_MEM_ADDR, |
| 8152 | addr); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8153 | /* Set the destination address */ |
| 8154 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8155 | MDIO_PMA_DEVAD, |
| 8156 | 0x8004, |
| 8157 | MDIO_PMA_REG_8727_TWO_WIRE_DATA_BUF); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8158 | |
| 8159 | /* Activate read command */ |
| 8160 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8161 | MDIO_PMA_DEVAD, |
| 8162 | MDIO_PMA_REG_SFP_TWO_WIRE_CTRL, |
| 8163 | 0x8002); |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 8164 | /* Wait appropriate time for two-wire command to finish before |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8165 | * polling the status register |
| 8166 | */ |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 8167 | usleep_range(1000, 2000); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8168 | |
| 8169 | /* Wait up to 500us for command complete status */ |
| 8170 | for (i = 0; i < 100; i++) { |
| 8171 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8172 | MDIO_PMA_DEVAD, |
| 8173 | MDIO_PMA_REG_SFP_TWO_WIRE_CTRL, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8174 | if ((val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK) == |
| 8175 | MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_COMPLETE) |
| 8176 | break; |
| 8177 | udelay(5); |
| 8178 | } |
| 8179 | |
| 8180 | if ((val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK) != |
| 8181 | MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_COMPLETE) { |
| 8182 | DP(NETIF_MSG_LINK, |
| 8183 | "Got bad status 0x%x when reading from SFP+ EEPROM\n", |
| 8184 | (val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK)); |
Yaniv Rosner | 65a001b | 2011-01-31 04:22:03 +0000 | [diff] [blame] | 8185 | return -EFAULT; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8186 | } |
| 8187 | |
| 8188 | /* Read the buffer */ |
| 8189 | for (i = 0; i < byte_cnt; i++) { |
| 8190 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8191 | MDIO_PMA_DEVAD, |
| 8192 | MDIO_PMA_REG_8727_TWO_WIRE_DATA_BUF + i, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8193 | o_buf[i] = (u8)(val & MDIO_PMA_REG_8727_TWO_WIRE_DATA_MASK); |
| 8194 | } |
| 8195 | |
| 8196 | for (i = 0; i < 100; i++) { |
| 8197 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8198 | MDIO_PMA_DEVAD, |
| 8199 | MDIO_PMA_REG_SFP_TWO_WIRE_CTRL, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8200 | if ((val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK) == |
| 8201 | MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_IDLE) |
Joe Perches | 6f38ad9 | 2010-11-14 17:04:31 +0000 | [diff] [blame] | 8202 | return 0; |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 8203 | usleep_range(1000, 2000); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8204 | } |
| 8205 | |
| 8206 | return -EINVAL; |
| 8207 | } |
| 8208 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 8209 | int bnx2x_read_sfp_module_eeprom(struct bnx2x_phy *phy, |
| 8210 | struct link_params *params, u16 addr, |
| 8211 | u8 byte_cnt, u8 *o_buf) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8212 | { |
Yuval Mintz | 24ea818 | 2012-06-20 19:05:23 +0000 | [diff] [blame] | 8213 | int rc = -EOPNOTSUPP; |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 8214 | switch (phy->type) { |
| 8215 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726: |
| 8216 | rc = bnx2x_8726_read_sfp_module_eeprom(phy, params, addr, |
| 8217 | byte_cnt, o_buf); |
| 8218 | break; |
| 8219 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727: |
| 8220 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8722: |
| 8221 | rc = bnx2x_8727_read_sfp_module_eeprom(phy, params, addr, |
| 8222 | byte_cnt, o_buf); |
| 8223 | break; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8224 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT: |
| 8225 | rc = bnx2x_warpcore_read_sfp_module_eeprom(phy, params, addr, |
| 8226 | byte_cnt, o_buf); |
| 8227 | break; |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 8228 | } |
| 8229 | return rc; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8230 | } |
| 8231 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 8232 | static int bnx2x_get_edc_mode(struct bnx2x_phy *phy, |
| 8233 | struct link_params *params, |
| 8234 | u16 *edc_mode) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8235 | { |
| 8236 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 8237 | u32 sync_offset = 0, phy_idx, media_types; |
Yuval Mintz | dbef807 | 2012-06-20 19:05:22 +0000 | [diff] [blame] | 8238 | u8 val[2], check_limiting_mode = 0; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8239 | *edc_mode = EDC_MODE_LIMITING; |
| 8240 | |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 8241 | phy->media_type = ETH_PHY_UNSPECIFIED; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8242 | /* First check for copper cable */ |
| 8243 | if (bnx2x_read_sfp_module_eeprom(phy, |
| 8244 | params, |
| 8245 | SFP_EEPROM_CON_TYPE_ADDR, |
Yuval Mintz | dbef807 | 2012-06-20 19:05:22 +0000 | [diff] [blame] | 8246 | 2, |
| 8247 | (u8 *)val) != 0) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8248 | DP(NETIF_MSG_LINK, "Failed to read from SFP+ module EEPROM\n"); |
| 8249 | return -EINVAL; |
| 8250 | } |
| 8251 | |
Yuval Mintz | dbef807 | 2012-06-20 19:05:22 +0000 | [diff] [blame] | 8252 | switch (val[0]) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8253 | case SFP_EEPROM_CON_TYPE_VAL_COPPER: |
| 8254 | { |
| 8255 | u8 copper_module_type; |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 8256 | phy->media_type = ETH_PHY_DA_TWINAX; |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 8257 | /* Check if its active cable (includes SFP+ module) |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8258 | * of passive cable |
| 8259 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8260 | if (bnx2x_read_sfp_module_eeprom(phy, |
| 8261 | params, |
| 8262 | SFP_EEPROM_FC_TX_TECH_ADDR, |
| 8263 | 1, |
Yaniv Rosner | 9045f6b4 | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 8264 | &copper_module_type) != 0) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8265 | DP(NETIF_MSG_LINK, |
| 8266 | "Failed to read copper-cable-type" |
| 8267 | " from SFP+ EEPROM\n"); |
| 8268 | return -EINVAL; |
| 8269 | } |
| 8270 | |
| 8271 | if (copper_module_type & |
| 8272 | SFP_EEPROM_FC_TX_TECH_BITMASK_COPPER_ACTIVE) { |
| 8273 | DP(NETIF_MSG_LINK, "Active Copper cable detected\n"); |
| 8274 | check_limiting_mode = 1; |
| 8275 | } else if (copper_module_type & |
| 8276 | SFP_EEPROM_FC_TX_TECH_BITMASK_COPPER_PASSIVE) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 8277 | DP(NETIF_MSG_LINK, |
| 8278 | "Passive Copper cable detected\n"); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8279 | *edc_mode = |
| 8280 | EDC_MODE_PASSIVE_DAC; |
| 8281 | } else { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 8282 | DP(NETIF_MSG_LINK, |
| 8283 | "Unknown copper-cable-type 0x%x !!!\n", |
| 8284 | copper_module_type); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8285 | return -EINVAL; |
| 8286 | } |
| 8287 | break; |
| 8288 | } |
| 8289 | case SFP_EEPROM_CON_TYPE_VAL_LC: |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8290 | check_limiting_mode = 1; |
Yuval Mintz | dbef807 | 2012-06-20 19:05:22 +0000 | [diff] [blame] | 8291 | if ((val[1] & (SFP_EEPROM_COMP_CODE_SR_MASK | |
| 8292 | SFP_EEPROM_COMP_CODE_LR_MASK | |
| 8293 | SFP_EEPROM_COMP_CODE_LRM_MASK)) == 0) { |
| 8294 | DP(NETIF_MSG_LINK, "1G Optic module detected\n"); |
| 8295 | phy->media_type = ETH_PHY_SFP_1G_FIBER; |
| 8296 | phy->req_line_speed = SPEED_1000; |
| 8297 | } else { |
| 8298 | int idx, cfg_idx = 0; |
| 8299 | DP(NETIF_MSG_LINK, "10G Optic module detected\n"); |
| 8300 | for (idx = INT_PHY; idx < MAX_PHYS; idx++) { |
| 8301 | if (params->phy[idx].type == phy->type) { |
| 8302 | cfg_idx = LINK_CONFIG_IDX(idx); |
| 8303 | break; |
| 8304 | } |
| 8305 | } |
| 8306 | phy->media_type = ETH_PHY_SFPP_10G_FIBER; |
| 8307 | phy->req_line_speed = params->req_line_speed[cfg_idx]; |
| 8308 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8309 | break; |
| 8310 | default: |
| 8311 | DP(NETIF_MSG_LINK, "Unable to determine module type 0x%x !!!\n", |
Yuval Mintz | dbef807 | 2012-06-20 19:05:22 +0000 | [diff] [blame] | 8312 | val[0]); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8313 | return -EINVAL; |
| 8314 | } |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 8315 | sync_offset = params->shmem_base + |
| 8316 | offsetof(struct shmem_region, |
| 8317 | dev_info.port_hw_config[params->port].media_type); |
| 8318 | media_types = REG_RD(bp, sync_offset); |
| 8319 | /* Update media type for non-PMF sync */ |
| 8320 | for (phy_idx = INT_PHY; phy_idx < MAX_PHYS; phy_idx++) { |
| 8321 | if (&(params->phy[phy_idx]) == phy) { |
| 8322 | media_types &= ~(PORT_HW_CFG_MEDIA_TYPE_PHY0_MASK << |
| 8323 | (PORT_HW_CFG_MEDIA_TYPE_PHY1_SHIFT * phy_idx)); |
| 8324 | media_types |= ((phy->media_type & |
| 8325 | PORT_HW_CFG_MEDIA_TYPE_PHY0_MASK) << |
| 8326 | (PORT_HW_CFG_MEDIA_TYPE_PHY1_SHIFT * phy_idx)); |
| 8327 | break; |
| 8328 | } |
| 8329 | } |
| 8330 | REG_WR(bp, sync_offset, media_types); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8331 | if (check_limiting_mode) { |
| 8332 | u8 options[SFP_EEPROM_OPTIONS_SIZE]; |
| 8333 | if (bnx2x_read_sfp_module_eeprom(phy, |
| 8334 | params, |
| 8335 | SFP_EEPROM_OPTIONS_ADDR, |
| 8336 | SFP_EEPROM_OPTIONS_SIZE, |
| 8337 | options) != 0) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 8338 | DP(NETIF_MSG_LINK, |
| 8339 | "Failed to read Option field from module EEPROM\n"); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8340 | return -EINVAL; |
| 8341 | } |
| 8342 | if ((options[0] & SFP_EEPROM_OPTIONS_LINEAR_RX_OUT_MASK)) |
| 8343 | *edc_mode = EDC_MODE_LINEAR; |
| 8344 | else |
| 8345 | *edc_mode = EDC_MODE_LIMITING; |
| 8346 | } |
| 8347 | DP(NETIF_MSG_LINK, "EDC mode is set to 0x%x\n", *edc_mode); |
| 8348 | return 0; |
| 8349 | } |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 8350 | /* This function read the relevant field from the module (SFP+), and verify it |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8351 | * is compliant with this board |
| 8352 | */ |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 8353 | static int bnx2x_verify_sfp_module(struct bnx2x_phy *phy, |
| 8354 | struct link_params *params) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8355 | { |
| 8356 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8357 | u32 val, cmd; |
| 8358 | u32 fw_resp, fw_cmd_param; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8359 | char vendor_name[SFP_EEPROM_VENDOR_NAME_SIZE+1]; |
| 8360 | char vendor_pn[SFP_EEPROM_PART_NO_SIZE+1]; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8361 | phy->flags &= ~FLAGS_SFP_NOT_APPROVED; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8362 | val = REG_RD(bp, params->shmem_base + |
| 8363 | offsetof(struct shmem_region, dev_info. |
| 8364 | port_feature_config[params->port].config)); |
| 8365 | if ((val & PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK) == |
| 8366 | PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_NO_ENFORCEMENT) { |
| 8367 | DP(NETIF_MSG_LINK, "NOT enforcing module verification\n"); |
| 8368 | return 0; |
| 8369 | } |
| 8370 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8371 | if (params->feature_config_flags & |
| 8372 | FEATURE_CONFIG_BC_SUPPORTS_DUAL_PHY_OPT_MDL_VRFY) { |
| 8373 | /* Use specific phy request */ |
| 8374 | cmd = DRV_MSG_CODE_VRFY_SPECIFIC_PHY_OPT_MDL; |
| 8375 | } else if (params->feature_config_flags & |
| 8376 | FEATURE_CONFIG_BC_SUPPORTS_OPT_MDL_VRFY) { |
| 8377 | /* Use first phy request only in case of non-dual media*/ |
| 8378 | if (DUAL_MEDIA(params)) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 8379 | DP(NETIF_MSG_LINK, |
| 8380 | "FW does not support OPT MDL verification\n"); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8381 | return -EINVAL; |
| 8382 | } |
| 8383 | cmd = DRV_MSG_CODE_VRFY_FIRST_PHY_OPT_MDL; |
| 8384 | } else { |
| 8385 | /* No support in OPT MDL detection */ |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 8386 | DP(NETIF_MSG_LINK, |
| 8387 | "FW does not support OPT MDL verification\n"); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8388 | return -EINVAL; |
| 8389 | } |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 8390 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8391 | fw_cmd_param = FW_PARAM_SET(phy->addr, phy->type, phy->mdio_ctrl); |
| 8392 | fw_resp = bnx2x_fw_command(bp, cmd, fw_cmd_param); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8393 | if (fw_resp == FW_MSG_CODE_VRFY_OPT_MDL_SUCCESS) { |
| 8394 | DP(NETIF_MSG_LINK, "Approved module\n"); |
| 8395 | return 0; |
| 8396 | } |
| 8397 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 8398 | /* Format the warning message */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8399 | if (bnx2x_read_sfp_module_eeprom(phy, |
| 8400 | params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8401 | SFP_EEPROM_VENDOR_NAME_ADDR, |
| 8402 | SFP_EEPROM_VENDOR_NAME_SIZE, |
| 8403 | (u8 *)vendor_name)) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8404 | vendor_name[0] = '\0'; |
| 8405 | else |
| 8406 | vendor_name[SFP_EEPROM_VENDOR_NAME_SIZE] = '\0'; |
| 8407 | if (bnx2x_read_sfp_module_eeprom(phy, |
| 8408 | params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8409 | SFP_EEPROM_PART_NO_ADDR, |
| 8410 | SFP_EEPROM_PART_NO_SIZE, |
| 8411 | (u8 *)vendor_pn)) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8412 | vendor_pn[0] = '\0'; |
| 8413 | else |
| 8414 | vendor_pn[SFP_EEPROM_PART_NO_SIZE] = '\0'; |
| 8415 | |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 8416 | netdev_err(bp->dev, "Warning: Unqualified SFP+ module detected," |
| 8417 | " Port %d from %s part number %s\n", |
| 8418 | params->port, vendor_name, vendor_pn); |
Yaniv Rosner | 59a2e53 | 2012-04-04 01:28:59 +0000 | [diff] [blame] | 8419 | if ((val & PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK) != |
| 8420 | PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_WARNING_MSG) |
| 8421 | phy->flags |= FLAGS_SFP_NOT_APPROVED; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8422 | return -EINVAL; |
| 8423 | } |
| 8424 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 8425 | static int bnx2x_wait_for_sfp_module_initialized(struct bnx2x_phy *phy, |
| 8426 | struct link_params *params) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8427 | |
| 8428 | { |
| 8429 | u8 val; |
| 8430 | struct bnx2x *bp = params->bp; |
| 8431 | u16 timeout; |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 8432 | /* Initialization time after hot-plug may take up to 300ms for |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8433 | * some phys type ( e.g. JDSU ) |
| 8434 | */ |
| 8435 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8436 | for (timeout = 0; timeout < 60; timeout++) { |
| 8437 | if (bnx2x_read_sfp_module_eeprom(phy, params, 1, 1, &val) |
| 8438 | == 0) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 8439 | DP(NETIF_MSG_LINK, |
| 8440 | "SFP+ module initialization took %d ms\n", |
| 8441 | timeout * 5); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8442 | return 0; |
| 8443 | } |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 8444 | usleep_range(5000, 10000); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8445 | } |
| 8446 | return -EINVAL; |
| 8447 | } |
| 8448 | |
| 8449 | static void bnx2x_8727_power_module(struct bnx2x *bp, |
| 8450 | struct bnx2x_phy *phy, |
| 8451 | u8 is_power_up) { |
| 8452 | /* Make sure GPIOs are not using for LED mode */ |
| 8453 | u16 val; |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 8454 | /* In the GPIO register, bit 4 is use to determine if the GPIOs are |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8455 | * operating as INPUT or as OUTPUT. Bit 1 is for input, and 0 for |
| 8456 | * output |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8457 | * Bits 0-1 determine the GPIOs value for OUTPUT in case bit 4 val is 0 |
| 8458 | * Bits 8-9 determine the GPIOs value for INPUT in case bit 4 val is 1 |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8459 | * where the 1st bit is the over-current(only input), and 2nd bit is |
| 8460 | * for power( only output ) |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8461 | * |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8462 | * In case of NOC feature is disabled and power is up, set GPIO control |
| 8463 | * as input to enable listening of over-current indication |
| 8464 | */ |
| 8465 | if (phy->flags & FLAGS_NOC) |
| 8466 | return; |
Yaniv Rosner | 27d0243 | 2011-05-31 21:27:48 +0000 | [diff] [blame] | 8467 | if (is_power_up) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8468 | val = (1<<4); |
| 8469 | else |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 8470 | /* Set GPIO control to OUTPUT, and set the power bit |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8471 | * to according to the is_power_up |
| 8472 | */ |
Yaniv Rosner | 27d0243 | 2011-05-31 21:27:48 +0000 | [diff] [blame] | 8473 | val = (1<<1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8474 | |
| 8475 | bnx2x_cl45_write(bp, phy, |
| 8476 | MDIO_PMA_DEVAD, |
| 8477 | MDIO_PMA_REG_8727_GPIO_CTRL, |
| 8478 | val); |
| 8479 | } |
| 8480 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 8481 | static int bnx2x_8726_set_limiting_mode(struct bnx2x *bp, |
| 8482 | struct bnx2x_phy *phy, |
| 8483 | u16 edc_mode) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8484 | { |
| 8485 | u16 cur_limiting_mode; |
| 8486 | |
| 8487 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8488 | MDIO_PMA_DEVAD, |
| 8489 | MDIO_PMA_REG_ROM_VER2, |
| 8490 | &cur_limiting_mode); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8491 | DP(NETIF_MSG_LINK, "Current Limiting mode is 0x%x\n", |
| 8492 | cur_limiting_mode); |
| 8493 | |
| 8494 | if (edc_mode == EDC_MODE_LIMITING) { |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8495 | DP(NETIF_MSG_LINK, "Setting LIMITING MODE\n"); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8496 | bnx2x_cl45_write(bp, phy, |
| 8497 | MDIO_PMA_DEVAD, |
| 8498 | MDIO_PMA_REG_ROM_VER2, |
| 8499 | EDC_MODE_LIMITING); |
| 8500 | } else { /* LRM mode ( default )*/ |
| 8501 | |
| 8502 | DP(NETIF_MSG_LINK, "Setting LRM MODE\n"); |
| 8503 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 8504 | /* Changing to LRM mode takes quite few seconds. So do it only |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8505 | * if current mode is limiting (default is LRM) |
| 8506 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8507 | if (cur_limiting_mode != EDC_MODE_LIMITING) |
| 8508 | return 0; |
| 8509 | |
| 8510 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8511 | MDIO_PMA_DEVAD, |
| 8512 | MDIO_PMA_REG_LRM_MODE, |
| 8513 | 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8514 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8515 | MDIO_PMA_DEVAD, |
| 8516 | MDIO_PMA_REG_ROM_VER2, |
| 8517 | 0x128); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8518 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8519 | MDIO_PMA_DEVAD, |
| 8520 | MDIO_PMA_REG_MISC_CTRL0, |
| 8521 | 0x4008); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8522 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8523 | MDIO_PMA_DEVAD, |
| 8524 | MDIO_PMA_REG_LRM_MODE, |
| 8525 | 0xaaaa); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8526 | } |
| 8527 | return 0; |
| 8528 | } |
| 8529 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 8530 | static int bnx2x_8727_set_limiting_mode(struct bnx2x *bp, |
| 8531 | struct bnx2x_phy *phy, |
| 8532 | u16 edc_mode) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8533 | { |
| 8534 | u16 phy_identifier; |
| 8535 | u16 rom_ver2_val; |
| 8536 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8537 | MDIO_PMA_DEVAD, |
| 8538 | MDIO_PMA_REG_PHY_IDENTIFIER, |
| 8539 | &phy_identifier); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8540 | |
| 8541 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8542 | MDIO_PMA_DEVAD, |
| 8543 | MDIO_PMA_REG_PHY_IDENTIFIER, |
| 8544 | (phy_identifier & ~(1<<9))); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8545 | |
| 8546 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8547 | MDIO_PMA_DEVAD, |
| 8548 | MDIO_PMA_REG_ROM_VER2, |
| 8549 | &rom_ver2_val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8550 | /* Keep the MSB 8-bits, and set the LSB 8-bits with the edc_mode */ |
| 8551 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8552 | MDIO_PMA_DEVAD, |
| 8553 | MDIO_PMA_REG_ROM_VER2, |
| 8554 | (rom_ver2_val & 0xff00) | (edc_mode & 0x00ff)); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8555 | |
| 8556 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8557 | MDIO_PMA_DEVAD, |
| 8558 | MDIO_PMA_REG_PHY_IDENTIFIER, |
| 8559 | (phy_identifier | (1<<9))); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8560 | |
| 8561 | return 0; |
| 8562 | } |
| 8563 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8564 | static void bnx2x_8727_specific_func(struct bnx2x_phy *phy, |
| 8565 | struct link_params *params, |
| 8566 | u32 action) |
| 8567 | { |
| 8568 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 5c107fd | 2012-09-13 02:56:19 +0000 | [diff] [blame] | 8569 | u16 val; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8570 | switch (action) { |
| 8571 | case DISABLE_TX: |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8572 | bnx2x_sfp_set_transmitter(params, phy, 0); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8573 | break; |
| 8574 | case ENABLE_TX: |
| 8575 | if (!(phy->flags & FLAGS_SFP_NOT_APPROVED)) |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8576 | bnx2x_sfp_set_transmitter(params, phy, 1); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8577 | break; |
Yaniv Rosner | 5c107fd | 2012-09-13 02:56:19 +0000 | [diff] [blame] | 8578 | case PHY_INIT: |
| 8579 | bnx2x_cl45_write(bp, phy, |
| 8580 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_RXCTRL, |
| 8581 | (1<<2) | (1<<5)); |
| 8582 | bnx2x_cl45_write(bp, phy, |
| 8583 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_TXCTRL, |
| 8584 | 0); |
| 8585 | bnx2x_cl45_write(bp, phy, |
| 8586 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_CTRL, 0x0006); |
| 8587 | /* Make MOD_ABS give interrupt on change */ |
| 8588 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, |
| 8589 | MDIO_PMA_REG_8727_PCS_OPT_CTRL, |
| 8590 | &val); |
| 8591 | val |= (1<<12); |
| 8592 | if (phy->flags & FLAGS_NOC) |
| 8593 | val |= (3<<5); |
| 8594 | /* Set 8727 GPIOs to input to allow reading from the 8727 GPIO0 |
| 8595 | * status which reflect SFP+ module over-current |
| 8596 | */ |
| 8597 | if (!(phy->flags & FLAGS_NOC)) |
| 8598 | val &= 0xff8f; /* Reset bits 4-6 */ |
| 8599 | bnx2x_cl45_write(bp, phy, |
| 8600 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_PCS_OPT_CTRL, |
| 8601 | val); |
| 8602 | |
| 8603 | /* Set 2-wire transfer rate of SFP+ module EEPROM |
| 8604 | * to 100Khz since some DACs(direct attached cables) do |
| 8605 | * not work at 400Khz. |
| 8606 | */ |
| 8607 | bnx2x_cl45_write(bp, phy, |
| 8608 | MDIO_PMA_DEVAD, |
| 8609 | MDIO_PMA_REG_8727_TWO_WIRE_SLAVE_ADDR, |
| 8610 | 0xa001); |
| 8611 | break; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8612 | default: |
| 8613 | DP(NETIF_MSG_LINK, "Function 0x%x not supported by 8727\n", |
| 8614 | action); |
| 8615 | return; |
| 8616 | } |
| 8617 | } |
| 8618 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8619 | static void bnx2x_set_e1e2_module_fault_led(struct link_params *params, |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8620 | u8 gpio_mode) |
| 8621 | { |
| 8622 | struct bnx2x *bp = params->bp; |
| 8623 | |
| 8624 | u32 fault_led_gpio = REG_RD(bp, params->shmem_base + |
| 8625 | offsetof(struct shmem_region, |
| 8626 | dev_info.port_hw_config[params->port].sfp_ctrl)) & |
| 8627 | PORT_HW_CFG_FAULT_MODULE_LED_MASK; |
| 8628 | switch (fault_led_gpio) { |
| 8629 | case PORT_HW_CFG_FAULT_MODULE_LED_DISABLED: |
| 8630 | return; |
| 8631 | case PORT_HW_CFG_FAULT_MODULE_LED_GPIO0: |
| 8632 | case PORT_HW_CFG_FAULT_MODULE_LED_GPIO1: |
| 8633 | case PORT_HW_CFG_FAULT_MODULE_LED_GPIO2: |
| 8634 | case PORT_HW_CFG_FAULT_MODULE_LED_GPIO3: |
| 8635 | { |
| 8636 | u8 gpio_port = bnx2x_get_gpio_port(params); |
| 8637 | u16 gpio_pin = fault_led_gpio - |
| 8638 | PORT_HW_CFG_FAULT_MODULE_LED_GPIO0; |
| 8639 | DP(NETIF_MSG_LINK, "Set fault module-detected led " |
| 8640 | "pin %x port %x mode %x\n", |
| 8641 | gpio_pin, gpio_port, gpio_mode); |
| 8642 | bnx2x_set_gpio(bp, gpio_pin, gpio_mode, gpio_port); |
| 8643 | } |
| 8644 | break; |
| 8645 | default: |
| 8646 | DP(NETIF_MSG_LINK, "Error: Invalid fault led mode 0x%x\n", |
| 8647 | fault_led_gpio); |
| 8648 | } |
| 8649 | } |
| 8650 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8651 | static void bnx2x_set_e3_module_fault_led(struct link_params *params, |
| 8652 | u8 gpio_mode) |
| 8653 | { |
| 8654 | u32 pin_cfg; |
| 8655 | u8 port = params->port; |
| 8656 | struct bnx2x *bp = params->bp; |
| 8657 | pin_cfg = (REG_RD(bp, params->shmem_base + |
| 8658 | offsetof(struct shmem_region, |
| 8659 | dev_info.port_hw_config[port].e3_sfp_ctrl)) & |
| 8660 | PORT_HW_CFG_E3_FAULT_MDL_LED_MASK) >> |
| 8661 | PORT_HW_CFG_E3_FAULT_MDL_LED_SHIFT; |
| 8662 | DP(NETIF_MSG_LINK, "Setting Fault LED to %d using pin cfg %d\n", |
| 8663 | gpio_mode, pin_cfg); |
| 8664 | bnx2x_set_cfg_pin(bp, pin_cfg, gpio_mode); |
| 8665 | } |
| 8666 | |
| 8667 | static void bnx2x_set_sfp_module_fault_led(struct link_params *params, |
| 8668 | u8 gpio_mode) |
| 8669 | { |
| 8670 | struct bnx2x *bp = params->bp; |
| 8671 | DP(NETIF_MSG_LINK, "Setting SFP+ module fault LED to %d\n", gpio_mode); |
| 8672 | if (CHIP_IS_E3(bp)) { |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 8673 | /* Low ==> if SFP+ module is supported otherwise |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8674 | * High ==> if SFP+ module is not on the approved vendor list |
| 8675 | */ |
| 8676 | bnx2x_set_e3_module_fault_led(params, gpio_mode); |
| 8677 | } else |
| 8678 | bnx2x_set_e1e2_module_fault_led(params, gpio_mode); |
| 8679 | } |
| 8680 | |
Yaniv Rosner | 985848f | 2011-07-05 01:06:48 +0000 | [diff] [blame] | 8681 | static void bnx2x_warpcore_hw_reset(struct bnx2x_phy *phy, |
| 8682 | struct link_params *params) |
| 8683 | { |
Yaniv Rosner | b76070b | 2011-11-28 00:49:47 +0000 | [diff] [blame] | 8684 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 985848f | 2011-07-05 01:06:48 +0000 | [diff] [blame] | 8685 | bnx2x_warpcore_power_module(params, phy, 0); |
Yaniv Rosner | b76070b | 2011-11-28 00:49:47 +0000 | [diff] [blame] | 8686 | /* Put Warpcore in low power mode */ |
| 8687 | REG_WR(bp, MISC_REG_WC0_RESET, 0x0c0e); |
| 8688 | |
| 8689 | /* Put LCPLL in low power mode */ |
| 8690 | REG_WR(bp, MISC_REG_LCPLL_E40_PWRDWN, 1); |
| 8691 | REG_WR(bp, MISC_REG_LCPLL_E40_RESETB_ANA, 0); |
| 8692 | REG_WR(bp, MISC_REG_LCPLL_E40_RESETB_DIG, 0); |
Yaniv Rosner | 985848f | 2011-07-05 01:06:48 +0000 | [diff] [blame] | 8693 | } |
| 8694 | |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 8695 | static void bnx2x_power_sfp_module(struct link_params *params, |
| 8696 | struct bnx2x_phy *phy, |
| 8697 | u8 power) |
| 8698 | { |
| 8699 | struct bnx2x *bp = params->bp; |
| 8700 | DP(NETIF_MSG_LINK, "Setting SFP+ power to %x\n", power); |
| 8701 | |
| 8702 | switch (phy->type) { |
| 8703 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727: |
| 8704 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8722: |
| 8705 | bnx2x_8727_power_module(params->bp, phy, power); |
| 8706 | break; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8707 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT: |
| 8708 | bnx2x_warpcore_power_module(params, phy, power); |
| 8709 | break; |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 8710 | default: |
| 8711 | break; |
| 8712 | } |
| 8713 | } |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8714 | static void bnx2x_warpcore_set_limiting_mode(struct link_params *params, |
| 8715 | struct bnx2x_phy *phy, |
| 8716 | u16 edc_mode) |
| 8717 | { |
| 8718 | u16 val = 0; |
| 8719 | u16 mode = MDIO_WC_REG_UC_INFO_B1_FIRMWARE_MODE_DEFAULT; |
| 8720 | struct bnx2x *bp = params->bp; |
| 8721 | |
| 8722 | u8 lane = bnx2x_get_warpcore_lane(phy, params); |
| 8723 | /* This is a global register which controls all lanes */ |
| 8724 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 8725 | MDIO_WC_REG_UC_INFO_B1_FIRMWARE_MODE, &val); |
| 8726 | val &= ~(0xf << (lane << 2)); |
| 8727 | |
| 8728 | switch (edc_mode) { |
| 8729 | case EDC_MODE_LINEAR: |
| 8730 | case EDC_MODE_LIMITING: |
| 8731 | mode = MDIO_WC_REG_UC_INFO_B1_FIRMWARE_MODE_DEFAULT; |
| 8732 | break; |
| 8733 | case EDC_MODE_PASSIVE_DAC: |
| 8734 | mode = MDIO_WC_REG_UC_INFO_B1_FIRMWARE_MODE_SFP_DAC; |
| 8735 | break; |
| 8736 | default: |
| 8737 | break; |
| 8738 | } |
| 8739 | |
| 8740 | val |= (mode << (lane << 2)); |
| 8741 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 8742 | MDIO_WC_REG_UC_INFO_B1_FIRMWARE_MODE, val); |
| 8743 | /* A must read */ |
| 8744 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 8745 | MDIO_WC_REG_UC_INFO_B1_FIRMWARE_MODE, &val); |
| 8746 | |
Yaniv Rosner | 19af03a | 2011-08-02 22:59:47 +0000 | [diff] [blame] | 8747 | /* Restart microcode to re-read the new mode */ |
| 8748 | bnx2x_warpcore_reset_lane(bp, phy, 1); |
| 8749 | bnx2x_warpcore_reset_lane(bp, phy, 0); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8750 | |
| 8751 | } |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 8752 | |
| 8753 | static void bnx2x_set_limiting_mode(struct link_params *params, |
| 8754 | struct bnx2x_phy *phy, |
| 8755 | u16 edc_mode) |
| 8756 | { |
| 8757 | switch (phy->type) { |
| 8758 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726: |
| 8759 | bnx2x_8726_set_limiting_mode(params->bp, phy, edc_mode); |
| 8760 | break; |
| 8761 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727: |
| 8762 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8722: |
| 8763 | bnx2x_8727_set_limiting_mode(params->bp, phy, edc_mode); |
| 8764 | break; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8765 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT: |
| 8766 | bnx2x_warpcore_set_limiting_mode(params, phy, edc_mode); |
| 8767 | break; |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 8768 | } |
| 8769 | } |
| 8770 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 8771 | int bnx2x_sfp_module_detection(struct bnx2x_phy *phy, |
| 8772 | struct link_params *params) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8773 | { |
| 8774 | struct bnx2x *bp = params->bp; |
| 8775 | u16 edc_mode; |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 8776 | int rc = 0; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8777 | |
| 8778 | u32 val = REG_RD(bp, params->shmem_base + |
| 8779 | offsetof(struct shmem_region, dev_info. |
| 8780 | port_feature_config[params->port].config)); |
| 8781 | |
| 8782 | DP(NETIF_MSG_LINK, "SFP+ module plugged in/out detected on port %d\n", |
| 8783 | params->port); |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 8784 | /* Power up module */ |
| 8785 | bnx2x_power_sfp_module(params, phy, 1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8786 | if (bnx2x_get_edc_mode(phy, params, &edc_mode) != 0) { |
| 8787 | DP(NETIF_MSG_LINK, "Failed to get valid module type\n"); |
| 8788 | return -EINVAL; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8789 | } else if (bnx2x_verify_sfp_module(phy, params) != 0) { |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 8790 | /* Check SFP+ module compatibility */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8791 | DP(NETIF_MSG_LINK, "Module verification failed!!\n"); |
| 8792 | rc = -EINVAL; |
| 8793 | /* Turn on fault module-detected led */ |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8794 | bnx2x_set_sfp_module_fault_led(params, |
| 8795 | MISC_REGISTERS_GPIO_HIGH); |
| 8796 | |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 8797 | /* Check if need to power down the SFP+ module */ |
| 8798 | if ((val & PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK) == |
| 8799 | PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_POWER_DOWN) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8800 | DP(NETIF_MSG_LINK, "Shutdown SFP+ module!!\n"); |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 8801 | bnx2x_power_sfp_module(params, phy, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8802 | return rc; |
| 8803 | } |
| 8804 | } else { |
| 8805 | /* Turn off fault module-detected led */ |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8806 | bnx2x_set_sfp_module_fault_led(params, MISC_REGISTERS_GPIO_LOW); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8807 | } |
| 8808 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 8809 | /* Check and set limiting mode / LRM mode on 8726. On 8727 it |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8810 | * is done automatically |
| 8811 | */ |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 8812 | bnx2x_set_limiting_mode(params, phy, edc_mode); |
| 8813 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 8814 | /* Enable transmit for this module if the module is approved, or |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8815 | * if unapproved modules should also enable the Tx laser |
| 8816 | */ |
| 8817 | if (rc == 0 || |
| 8818 | (val & PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK) != |
| 8819 | PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_DISABLE_TX_LASER) |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8820 | bnx2x_sfp_set_transmitter(params, phy, 1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8821 | else |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8822 | bnx2x_sfp_set_transmitter(params, phy, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8823 | |
| 8824 | return rc; |
| 8825 | } |
| 8826 | |
| 8827 | void bnx2x_handle_module_detect_int(struct link_params *params) |
| 8828 | { |
| 8829 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8830 | struct bnx2x_phy *phy; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8831 | u32 gpio_val; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8832 | u8 gpio_num, gpio_port; |
| 8833 | if (CHIP_IS_E3(bp)) |
| 8834 | phy = ¶ms->phy[INT_PHY]; |
| 8835 | else |
| 8836 | phy = ¶ms->phy[EXT_PHY1]; |
| 8837 | |
| 8838 | if (bnx2x_get_mod_abs_int_cfg(bp, params->chip_id, params->shmem_base, |
| 8839 | params->port, &gpio_num, &gpio_port) == |
| 8840 | -EINVAL) { |
| 8841 | DP(NETIF_MSG_LINK, "Failed to get MOD_ABS interrupt config\n"); |
| 8842 | return; |
| 8843 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8844 | |
| 8845 | /* Set valid module led off */ |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8846 | bnx2x_set_sfp_module_fault_led(params, MISC_REGISTERS_GPIO_HIGH); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8847 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8848 | /* Get current gpio val reflecting module plugged in / out*/ |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8849 | gpio_val = bnx2x_get_gpio(bp, gpio_num, gpio_port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8850 | |
| 8851 | /* Call the handling function in case module is detected */ |
| 8852 | if (gpio_val == 0) { |
Yuval Mintz | dbef807 | 2012-06-20 19:05:22 +0000 | [diff] [blame] | 8853 | bnx2x_set_mdio_clk(bp, params->chip_id, params->port); |
| 8854 | bnx2x_set_aer_mmd(params, phy); |
| 8855 | |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 8856 | bnx2x_power_sfp_module(params, phy, 1); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8857 | bnx2x_set_gpio_int(bp, gpio_num, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8858 | MISC_REGISTERS_GPIO_INT_OUTPUT_CLR, |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8859 | gpio_port); |
Yuval Mintz | dbef807 | 2012-06-20 19:05:22 +0000 | [diff] [blame] | 8860 | if (bnx2x_wait_for_sfp_module_initialized(phy, params) == 0) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8861 | bnx2x_sfp_module_detection(phy, params); |
Yuval Mintz | dbef807 | 2012-06-20 19:05:22 +0000 | [diff] [blame] | 8862 | if (CHIP_IS_E3(bp)) { |
| 8863 | u16 rx_tx_in_reset; |
| 8864 | /* In case WC is out of reset, reconfigure the |
| 8865 | * link speed while taking into account 1G |
| 8866 | * module limitation. |
| 8867 | */ |
| 8868 | bnx2x_cl45_read(bp, phy, |
| 8869 | MDIO_WC_DEVAD, |
| 8870 | MDIO_WC_REG_DIGITAL5_MISC6, |
| 8871 | &rx_tx_in_reset); |
| 8872 | if (!rx_tx_in_reset) { |
| 8873 | bnx2x_warpcore_reset_lane(bp, phy, 1); |
| 8874 | bnx2x_warpcore_config_sfi(phy, params); |
| 8875 | bnx2x_warpcore_reset_lane(bp, phy, 0); |
| 8876 | } |
| 8877 | } |
| 8878 | } else { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8879 | DP(NETIF_MSG_LINK, "SFP+ module is not initialized\n"); |
Yuval Mintz | dbef807 | 2012-06-20 19:05:22 +0000 | [diff] [blame] | 8880 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8881 | } else { |
| 8882 | u32 val = REG_RD(bp, params->shmem_base + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8883 | offsetof(struct shmem_region, dev_info. |
| 8884 | port_feature_config[params->port]. |
| 8885 | config)); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8886 | bnx2x_set_gpio_int(bp, gpio_num, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8887 | MISC_REGISTERS_GPIO_INT_OUTPUT_SET, |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8888 | gpio_port); |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 8889 | /* Module was plugged out. |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8890 | * Disable transmit for this module |
| 8891 | */ |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 8892 | phy->media_type = ETH_PHY_NOT_PRESENT; |
Yaniv Rosner | de6f337 | 2011-08-02 22:59:25 +0000 | [diff] [blame] | 8893 | if (((val & PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK) == |
| 8894 | PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_DISABLE_TX_LASER) || |
| 8895 | CHIP_IS_E3(bp)) |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8896 | bnx2x_sfp_set_transmitter(params, phy, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8897 | } |
| 8898 | } |
| 8899 | |
| 8900 | /******************************************************************/ |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 8901 | /* Used by 8706 and 8727 */ |
| 8902 | /******************************************************************/ |
| 8903 | static void bnx2x_sfp_mask_fault(struct bnx2x *bp, |
| 8904 | struct bnx2x_phy *phy, |
| 8905 | u16 alarm_status_offset, |
| 8906 | u16 alarm_ctrl_offset) |
| 8907 | { |
| 8908 | u16 alarm_status, val; |
| 8909 | bnx2x_cl45_read(bp, phy, |
| 8910 | MDIO_PMA_DEVAD, alarm_status_offset, |
| 8911 | &alarm_status); |
| 8912 | bnx2x_cl45_read(bp, phy, |
| 8913 | MDIO_PMA_DEVAD, alarm_status_offset, |
| 8914 | &alarm_status); |
| 8915 | /* Mask or enable the fault event. */ |
| 8916 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, alarm_ctrl_offset, &val); |
| 8917 | if (alarm_status & (1<<0)) |
| 8918 | val &= ~(1<<0); |
| 8919 | else |
| 8920 | val |= (1<<0); |
| 8921 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, alarm_ctrl_offset, val); |
| 8922 | } |
| 8923 | /******************************************************************/ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8924 | /* common BCM8706/BCM8726 PHY SECTION */ |
| 8925 | /******************************************************************/ |
| 8926 | static u8 bnx2x_8706_8726_read_status(struct bnx2x_phy *phy, |
| 8927 | struct link_params *params, |
| 8928 | struct link_vars *vars) |
| 8929 | { |
| 8930 | u8 link_up = 0; |
| 8931 | u16 val1, val2, rx_sd, pcs_status; |
| 8932 | struct bnx2x *bp = params->bp; |
| 8933 | DP(NETIF_MSG_LINK, "XGXS 8706/8726\n"); |
| 8934 | /* Clear RX Alarm*/ |
| 8935 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8936 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_RXSTAT, &val2); |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 8937 | |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8938 | bnx2x_sfp_mask_fault(bp, phy, MDIO_PMA_LASI_TXSTAT, |
| 8939 | MDIO_PMA_LASI_TXCTRL); |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 8940 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 8941 | /* Clear LASI indication*/ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8942 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8943 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_STAT, &val1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8944 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8945 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_STAT, &val2); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8946 | DP(NETIF_MSG_LINK, "8706/8726 LASI status 0x%x--> 0x%x\n", val1, val2); |
| 8947 | |
| 8948 | bnx2x_cl45_read(bp, phy, |
| 8949 | MDIO_PMA_DEVAD, MDIO_PMA_REG_RX_SD, &rx_sd); |
| 8950 | bnx2x_cl45_read(bp, phy, |
| 8951 | MDIO_PCS_DEVAD, MDIO_PCS_REG_STATUS, &pcs_status); |
| 8952 | bnx2x_cl45_read(bp, phy, |
| 8953 | MDIO_AN_DEVAD, MDIO_AN_REG_LINK_STATUS, &val2); |
| 8954 | bnx2x_cl45_read(bp, phy, |
| 8955 | MDIO_AN_DEVAD, MDIO_AN_REG_LINK_STATUS, &val2); |
| 8956 | |
| 8957 | DP(NETIF_MSG_LINK, "8706/8726 rx_sd 0x%x pcs_status 0x%x 1Gbps" |
| 8958 | " link_status 0x%x\n", rx_sd, pcs_status, val2); |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 8959 | /* Link is up if both bit 0 of pmd_rx_sd and bit 0 of pcs_status |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8960 | * are set, or if the autoneg bit 1 is set |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8961 | */ |
| 8962 | link_up = ((rx_sd & pcs_status & 0x1) || (val2 & (1<<1))); |
| 8963 | if (link_up) { |
| 8964 | if (val2 & (1<<1)) |
| 8965 | vars->line_speed = SPEED_1000; |
| 8966 | else |
| 8967 | vars->line_speed = SPEED_10000; |
| 8968 | bnx2x_ext_phy_resolve_fc(phy, params, vars); |
Yaniv Rosner | 791f18c | 2011-01-18 04:33:42 +0000 | [diff] [blame] | 8969 | vars->duplex = DUPLEX_FULL; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8970 | } |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 8971 | |
| 8972 | /* Capture 10G link fault. Read twice to clear stale value. */ |
| 8973 | if (vars->line_speed == SPEED_10000) { |
| 8974 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8975 | MDIO_PMA_LASI_TXSTAT, &val1); |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 8976 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8977 | MDIO_PMA_LASI_TXSTAT, &val1); |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 8978 | if (val1 & (1<<0)) |
| 8979 | vars->fault_detected = 1; |
| 8980 | } |
| 8981 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8982 | return link_up; |
| 8983 | } |
| 8984 | |
| 8985 | /******************************************************************/ |
| 8986 | /* BCM8706 PHY SECTION */ |
| 8987 | /******************************************************************/ |
| 8988 | static u8 bnx2x_8706_config_init(struct bnx2x_phy *phy, |
| 8989 | struct link_params *params, |
| 8990 | struct link_vars *vars) |
| 8991 | { |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8992 | u32 tx_en_mode; |
| 8993 | u16 cnt, val, tmp1; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8994 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 8995 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8996 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8997 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, params->port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8998 | /* HW reset */ |
| 8999 | bnx2x_ext_phy_hw_reset(bp, params->port); |
| 9000 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 0xa040); |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 9001 | bnx2x_wait_reset_complete(bp, phy, params); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9002 | |
| 9003 | /* Wait until fw is loaded */ |
| 9004 | for (cnt = 0; cnt < 100; cnt++) { |
| 9005 | bnx2x_cl45_read(bp, phy, |
| 9006 | MDIO_PMA_DEVAD, MDIO_PMA_REG_ROM_VER1, &val); |
| 9007 | if (val) |
| 9008 | break; |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 9009 | usleep_range(10000, 20000); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9010 | } |
| 9011 | DP(NETIF_MSG_LINK, "XGXS 8706 is initialized after %d ms\n", cnt); |
| 9012 | if ((params->feature_config_flags & |
| 9013 | FEATURE_CONFIG_OVERRIDE_PREEMPHASIS_ENABLED)) { |
| 9014 | u8 i; |
| 9015 | u16 reg; |
| 9016 | for (i = 0; i < 4; i++) { |
| 9017 | reg = MDIO_XS_8706_REG_BANK_RX0 + |
| 9018 | i*(MDIO_XS_8706_REG_BANK_RX1 - |
| 9019 | MDIO_XS_8706_REG_BANK_RX0); |
| 9020 | bnx2x_cl45_read(bp, phy, MDIO_XS_DEVAD, reg, &val); |
| 9021 | /* Clear first 3 bits of the control */ |
| 9022 | val &= ~0x7; |
| 9023 | /* Set control bits according to configuration */ |
| 9024 | val |= (phy->rx_preemphasis[i] & 0x7); |
| 9025 | DP(NETIF_MSG_LINK, "Setting RX Equalizer to BCM8706" |
| 9026 | " reg 0x%x <-- val 0x%x\n", reg, val); |
| 9027 | bnx2x_cl45_write(bp, phy, MDIO_XS_DEVAD, reg, val); |
| 9028 | } |
| 9029 | } |
| 9030 | /* Force speed */ |
| 9031 | if (phy->req_line_speed == SPEED_10000) { |
| 9032 | DP(NETIF_MSG_LINK, "XGXS 8706 force 10Gbps\n"); |
| 9033 | |
| 9034 | bnx2x_cl45_write(bp, phy, |
| 9035 | MDIO_PMA_DEVAD, |
| 9036 | MDIO_PMA_REG_DIGITAL_CTRL, 0x400); |
| 9037 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 9038 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_TXCTRL, |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 9039 | 0); |
| 9040 | /* Arm LASI for link and Tx fault. */ |
| 9041 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 9042 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_CTRL, 3); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9043 | } else { |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 9044 | /* Force 1Gbps using autoneg with 1G advertisement */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9045 | |
| 9046 | /* Allow CL37 through CL73 */ |
| 9047 | DP(NETIF_MSG_LINK, "XGXS 8706 AutoNeg\n"); |
| 9048 | bnx2x_cl45_write(bp, phy, |
| 9049 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_CL73, 0x040c); |
| 9050 | |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 9051 | /* Enable Full-Duplex advertisement on CL37 */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9052 | bnx2x_cl45_write(bp, phy, |
| 9053 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_FC_LP, 0x0020); |
| 9054 | /* Enable CL37 AN */ |
| 9055 | bnx2x_cl45_write(bp, phy, |
| 9056 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_AN, 0x1000); |
| 9057 | /* 1G support */ |
| 9058 | bnx2x_cl45_write(bp, phy, |
| 9059 | MDIO_AN_DEVAD, MDIO_AN_REG_ADV, (1<<5)); |
| 9060 | |
| 9061 | /* Enable clause 73 AN */ |
| 9062 | bnx2x_cl45_write(bp, phy, |
| 9063 | MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, 0x1200); |
| 9064 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 9065 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_RXCTRL, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9066 | 0x0400); |
| 9067 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 9068 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_CTRL, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9069 | 0x0004); |
| 9070 | } |
| 9071 | bnx2x_save_bcm_spirom_ver(bp, phy, params->port); |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 9072 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 9073 | /* If TX Laser is controlled by GPIO_0, do not let PHY go into low |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 9074 | * power mode, if TX Laser is disabled |
| 9075 | */ |
| 9076 | |
| 9077 | tx_en_mode = REG_RD(bp, params->shmem_base + |
| 9078 | offsetof(struct shmem_region, |
| 9079 | dev_info.port_hw_config[params->port].sfp_ctrl)) |
| 9080 | & PORT_HW_CFG_TX_LASER_MASK; |
| 9081 | |
| 9082 | if (tx_en_mode == PORT_HW_CFG_TX_LASER_GPIO0) { |
| 9083 | DP(NETIF_MSG_LINK, "Enabling TXONOFF_PWRDN_DIS\n"); |
| 9084 | bnx2x_cl45_read(bp, phy, |
| 9085 | MDIO_PMA_DEVAD, MDIO_PMA_REG_DIGITAL_CTRL, &tmp1); |
| 9086 | tmp1 |= 0x1; |
| 9087 | bnx2x_cl45_write(bp, phy, |
| 9088 | MDIO_PMA_DEVAD, MDIO_PMA_REG_DIGITAL_CTRL, tmp1); |
| 9089 | } |
| 9090 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9091 | return 0; |
| 9092 | } |
| 9093 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 9094 | static int bnx2x_8706_read_status(struct bnx2x_phy *phy, |
| 9095 | struct link_params *params, |
| 9096 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9097 | { |
| 9098 | return bnx2x_8706_8726_read_status(phy, params, vars); |
| 9099 | } |
| 9100 | |
| 9101 | /******************************************************************/ |
| 9102 | /* BCM8726 PHY SECTION */ |
| 9103 | /******************************************************************/ |
| 9104 | static void bnx2x_8726_config_loopback(struct bnx2x_phy *phy, |
| 9105 | struct link_params *params) |
| 9106 | { |
| 9107 | struct bnx2x *bp = params->bp; |
| 9108 | DP(NETIF_MSG_LINK, "PMA/PMD ext_phy_loopback: 8726\n"); |
| 9109 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 0x0001); |
| 9110 | } |
| 9111 | |
| 9112 | static void bnx2x_8726_external_rom_boot(struct bnx2x_phy *phy, |
| 9113 | struct link_params *params) |
| 9114 | { |
| 9115 | struct bnx2x *bp = params->bp; |
| 9116 | /* Need to wait 100ms after reset */ |
| 9117 | msleep(100); |
| 9118 | |
| 9119 | /* Micro controller re-boot */ |
| 9120 | bnx2x_cl45_write(bp, phy, |
| 9121 | MDIO_PMA_DEVAD, MDIO_PMA_REG_GEN_CTRL, 0x018B); |
| 9122 | |
| 9123 | /* Set soft reset */ |
| 9124 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 9125 | MDIO_PMA_DEVAD, |
| 9126 | MDIO_PMA_REG_GEN_CTRL, |
| 9127 | MDIO_PMA_REG_GEN_CTRL_ROM_MICRO_RESET); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9128 | |
| 9129 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 9130 | MDIO_PMA_DEVAD, |
| 9131 | MDIO_PMA_REG_MISC_CTRL1, 0x0001); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9132 | |
| 9133 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 9134 | MDIO_PMA_DEVAD, |
| 9135 | MDIO_PMA_REG_GEN_CTRL, |
| 9136 | MDIO_PMA_REG_GEN_CTRL_ROM_RESET_INTERNAL_MP); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9137 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 9138 | /* Wait for 150ms for microcode load */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9139 | msleep(150); |
| 9140 | |
| 9141 | /* Disable serial boot control, tristates pins SS_N, SCK, MOSI, MISO */ |
| 9142 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 9143 | MDIO_PMA_DEVAD, |
| 9144 | MDIO_PMA_REG_MISC_CTRL1, 0x0000); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9145 | |
| 9146 | msleep(200); |
| 9147 | bnx2x_save_bcm_spirom_ver(bp, phy, params->port); |
| 9148 | } |
| 9149 | |
| 9150 | static u8 bnx2x_8726_read_status(struct bnx2x_phy *phy, |
| 9151 | struct link_params *params, |
| 9152 | struct link_vars *vars) |
| 9153 | { |
| 9154 | struct bnx2x *bp = params->bp; |
| 9155 | u16 val1; |
| 9156 | u8 link_up = bnx2x_8706_8726_read_status(phy, params, vars); |
| 9157 | if (link_up) { |
| 9158 | bnx2x_cl45_read(bp, phy, |
| 9159 | MDIO_PMA_DEVAD, MDIO_PMA_REG_PHY_IDENTIFIER, |
| 9160 | &val1); |
| 9161 | if (val1 & (1<<15)) { |
| 9162 | DP(NETIF_MSG_LINK, "Tx is disabled\n"); |
| 9163 | link_up = 0; |
| 9164 | vars->line_speed = 0; |
| 9165 | } |
| 9166 | } |
| 9167 | return link_up; |
| 9168 | } |
| 9169 | |
| 9170 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 9171 | static int bnx2x_8726_config_init(struct bnx2x_phy *phy, |
| 9172 | struct link_params *params, |
| 9173 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9174 | { |
| 9175 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9176 | DP(NETIF_MSG_LINK, "Initializing BCM8726\n"); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9177 | |
| 9178 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 1<<15); |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 9179 | bnx2x_wait_reset_complete(bp, phy, params); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9180 | |
| 9181 | bnx2x_8726_external_rom_boot(phy, params); |
| 9182 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 9183 | /* Need to call module detected on initialization since the module |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 9184 | * detection triggered by actual module insertion might occur before |
| 9185 | * driver is loaded, and when driver is loaded, it reset all |
| 9186 | * registers, including the transmitter |
| 9187 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9188 | bnx2x_sfp_module_detection(phy, params); |
| 9189 | |
| 9190 | if (phy->req_line_speed == SPEED_1000) { |
| 9191 | DP(NETIF_MSG_LINK, "Setting 1G force\n"); |
| 9192 | bnx2x_cl45_write(bp, phy, |
| 9193 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 0x40); |
| 9194 | bnx2x_cl45_write(bp, phy, |
| 9195 | MDIO_PMA_DEVAD, MDIO_PMA_REG_10G_CTRL2, 0xD); |
| 9196 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 9197 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_CTRL, 0x5); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9198 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 9199 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_RXCTRL, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9200 | 0x400); |
| 9201 | } else if ((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 9202 | (phy->speed_cap_mask & |
| 9203 | PORT_HW_CFG_SPEED_CAPABILITY_D0_1G) && |
| 9204 | ((phy->speed_cap_mask & |
| 9205 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G) != |
| 9206 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G)) { |
| 9207 | DP(NETIF_MSG_LINK, "Setting 1G clause37\n"); |
| 9208 | /* Set Flow control */ |
| 9209 | bnx2x_ext_phy_set_pause(params, phy, vars); |
| 9210 | bnx2x_cl45_write(bp, phy, |
| 9211 | MDIO_AN_DEVAD, MDIO_AN_REG_ADV, 0x20); |
| 9212 | bnx2x_cl45_write(bp, phy, |
| 9213 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_CL73, 0x040c); |
| 9214 | bnx2x_cl45_write(bp, phy, |
| 9215 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_FC_LD, 0x0020); |
| 9216 | bnx2x_cl45_write(bp, phy, |
| 9217 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_AN, 0x1000); |
| 9218 | bnx2x_cl45_write(bp, phy, |
| 9219 | MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, 0x1200); |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 9220 | /* Enable RX-ALARM control to receive interrupt for 1G speed |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 9221 | * change |
| 9222 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9223 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 9224 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_CTRL, 0x4); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9225 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 9226 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_RXCTRL, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9227 | 0x400); |
| 9228 | |
| 9229 | } else { /* Default 10G. Set only LASI control */ |
| 9230 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 9231 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_CTRL, 1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9232 | } |
| 9233 | |
| 9234 | /* Set TX PreEmphasis if needed */ |
| 9235 | if ((params->feature_config_flags & |
| 9236 | FEATURE_CONFIG_OVERRIDE_PREEMPHASIS_ENABLED)) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 9237 | DP(NETIF_MSG_LINK, |
| 9238 | "Setting TX_CTRL1 0x%x, TX_CTRL2 0x%x\n", |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9239 | phy->tx_preemphasis[0], |
| 9240 | phy->tx_preemphasis[1]); |
| 9241 | bnx2x_cl45_write(bp, phy, |
| 9242 | MDIO_PMA_DEVAD, |
| 9243 | MDIO_PMA_REG_8726_TX_CTRL1, |
| 9244 | phy->tx_preemphasis[0]); |
| 9245 | |
| 9246 | bnx2x_cl45_write(bp, phy, |
| 9247 | MDIO_PMA_DEVAD, |
| 9248 | MDIO_PMA_REG_8726_TX_CTRL2, |
| 9249 | phy->tx_preemphasis[1]); |
| 9250 | } |
| 9251 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9252 | return 0; |
| 9253 | |
| 9254 | } |
| 9255 | |
| 9256 | static void bnx2x_8726_link_reset(struct bnx2x_phy *phy, |
| 9257 | struct link_params *params) |
| 9258 | { |
| 9259 | struct bnx2x *bp = params->bp; |
| 9260 | DP(NETIF_MSG_LINK, "bnx2x_8726_link_reset port %d\n", params->port); |
| 9261 | /* Set serial boot control for external load */ |
| 9262 | bnx2x_cl45_write(bp, phy, |
| 9263 | MDIO_PMA_DEVAD, |
| 9264 | MDIO_PMA_REG_GEN_CTRL, 0x0001); |
| 9265 | } |
| 9266 | |
| 9267 | /******************************************************************/ |
| 9268 | /* BCM8727 PHY SECTION */ |
| 9269 | /******************************************************************/ |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 9270 | |
| 9271 | static void bnx2x_8727_set_link_led(struct bnx2x_phy *phy, |
| 9272 | struct link_params *params, u8 mode) |
| 9273 | { |
| 9274 | struct bnx2x *bp = params->bp; |
| 9275 | u16 led_mode_bitmask = 0; |
| 9276 | u16 gpio_pins_bitmask = 0; |
| 9277 | u16 val; |
| 9278 | /* Only NOC flavor requires to set the LED specifically */ |
| 9279 | if (!(phy->flags & FLAGS_NOC)) |
| 9280 | return; |
| 9281 | switch (mode) { |
| 9282 | case LED_MODE_FRONT_PANEL_OFF: |
| 9283 | case LED_MODE_OFF: |
| 9284 | led_mode_bitmask = 0; |
| 9285 | gpio_pins_bitmask = 0x03; |
| 9286 | break; |
| 9287 | case LED_MODE_ON: |
| 9288 | led_mode_bitmask = 0; |
| 9289 | gpio_pins_bitmask = 0x02; |
| 9290 | break; |
| 9291 | case LED_MODE_OPER: |
| 9292 | led_mode_bitmask = 0x60; |
| 9293 | gpio_pins_bitmask = 0x11; |
| 9294 | break; |
| 9295 | } |
| 9296 | bnx2x_cl45_read(bp, phy, |
| 9297 | MDIO_PMA_DEVAD, |
| 9298 | MDIO_PMA_REG_8727_PCS_OPT_CTRL, |
| 9299 | &val); |
| 9300 | val &= 0xff8f; |
| 9301 | val |= led_mode_bitmask; |
| 9302 | bnx2x_cl45_write(bp, phy, |
| 9303 | MDIO_PMA_DEVAD, |
| 9304 | MDIO_PMA_REG_8727_PCS_OPT_CTRL, |
| 9305 | val); |
| 9306 | bnx2x_cl45_read(bp, phy, |
| 9307 | MDIO_PMA_DEVAD, |
| 9308 | MDIO_PMA_REG_8727_GPIO_CTRL, |
| 9309 | &val); |
| 9310 | val &= 0xffe0; |
| 9311 | val |= gpio_pins_bitmask; |
| 9312 | bnx2x_cl45_write(bp, phy, |
| 9313 | MDIO_PMA_DEVAD, |
| 9314 | MDIO_PMA_REG_8727_GPIO_CTRL, |
| 9315 | val); |
| 9316 | } |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 9317 | static void bnx2x_8727_hw_reset(struct bnx2x_phy *phy, |
| 9318 | struct link_params *params) { |
| 9319 | u32 swap_val, swap_override; |
| 9320 | u8 port; |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 9321 | /* The PHY reset is controlled by GPIO 1. Fake the port number |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 9322 | * to cancel the swap done in set_gpio() |
| 9323 | */ |
| 9324 | struct bnx2x *bp = params->bp; |
| 9325 | swap_val = REG_RD(bp, NIG_REG_PORT_SWAP); |
| 9326 | swap_override = REG_RD(bp, NIG_REG_STRAP_OVERRIDE); |
| 9327 | port = (swap_val && swap_override) ^ 1; |
| 9328 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 9329 | MISC_REGISTERS_GPIO_OUTPUT_LOW, port); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 9330 | } |
| 9331 | |
Yuval Mintz | dbef807 | 2012-06-20 19:05:22 +0000 | [diff] [blame] | 9332 | static void bnx2x_8727_config_speed(struct bnx2x_phy *phy, |
| 9333 | struct link_params *params) |
| 9334 | { |
| 9335 | struct bnx2x *bp = params->bp; |
| 9336 | u16 tmp1, val; |
| 9337 | /* Set option 1G speed */ |
| 9338 | if ((phy->req_line_speed == SPEED_1000) || |
| 9339 | (phy->media_type == ETH_PHY_SFP_1G_FIBER)) { |
| 9340 | DP(NETIF_MSG_LINK, "Setting 1G force\n"); |
| 9341 | bnx2x_cl45_write(bp, phy, |
| 9342 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 0x40); |
| 9343 | bnx2x_cl45_write(bp, phy, |
| 9344 | MDIO_PMA_DEVAD, MDIO_PMA_REG_10G_CTRL2, 0xD); |
| 9345 | bnx2x_cl45_read(bp, phy, |
| 9346 | MDIO_PMA_DEVAD, MDIO_PMA_REG_10G_CTRL2, &tmp1); |
| 9347 | DP(NETIF_MSG_LINK, "1.7 = 0x%x\n", tmp1); |
| 9348 | /* Power down the XAUI until link is up in case of dual-media |
| 9349 | * and 1G |
| 9350 | */ |
| 9351 | if (DUAL_MEDIA(params)) { |
| 9352 | bnx2x_cl45_read(bp, phy, |
| 9353 | MDIO_PMA_DEVAD, |
| 9354 | MDIO_PMA_REG_8727_PCS_GP, &val); |
| 9355 | val |= (3<<10); |
| 9356 | bnx2x_cl45_write(bp, phy, |
| 9357 | MDIO_PMA_DEVAD, |
| 9358 | MDIO_PMA_REG_8727_PCS_GP, val); |
| 9359 | } |
| 9360 | } else if ((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 9361 | ((phy->speed_cap_mask & |
| 9362 | PORT_HW_CFG_SPEED_CAPABILITY_D0_1G)) && |
| 9363 | ((phy->speed_cap_mask & |
| 9364 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G) != |
| 9365 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G)) { |
| 9366 | |
| 9367 | DP(NETIF_MSG_LINK, "Setting 1G clause37\n"); |
| 9368 | bnx2x_cl45_write(bp, phy, |
| 9369 | MDIO_AN_DEVAD, MDIO_AN_REG_8727_MISC_CTRL, 0); |
| 9370 | bnx2x_cl45_write(bp, phy, |
| 9371 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_AN, 0x1300); |
| 9372 | } else { |
| 9373 | /* Since the 8727 has only single reset pin, need to set the 10G |
| 9374 | * registers although it is default |
| 9375 | */ |
| 9376 | bnx2x_cl45_write(bp, phy, |
| 9377 | MDIO_AN_DEVAD, MDIO_AN_REG_8727_MISC_CTRL, |
| 9378 | 0x0020); |
| 9379 | bnx2x_cl45_write(bp, phy, |
| 9380 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_AN, 0x0100); |
| 9381 | bnx2x_cl45_write(bp, phy, |
| 9382 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 0x2040); |
| 9383 | bnx2x_cl45_write(bp, phy, |
| 9384 | MDIO_PMA_DEVAD, MDIO_PMA_REG_10G_CTRL2, |
| 9385 | 0x0008); |
| 9386 | } |
| 9387 | } |
| 9388 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 9389 | static int bnx2x_8727_config_init(struct bnx2x_phy *phy, |
| 9390 | struct link_params *params, |
| 9391 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9392 | { |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 9393 | u32 tx_en_mode; |
Yaniv Rosner | 5c107fd | 2012-09-13 02:56:19 +0000 | [diff] [blame] | 9394 | u16 tmp1, mod_abs, tmp2; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9395 | struct bnx2x *bp = params->bp; |
| 9396 | /* Enable PMD link, MOD_ABS_FLT, and 1G link alarm */ |
| 9397 | |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 9398 | bnx2x_wait_reset_complete(bp, phy, params); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9399 | |
| 9400 | DP(NETIF_MSG_LINK, "Initializing BCM8727\n"); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9401 | |
Yaniv Rosner | 5c107fd | 2012-09-13 02:56:19 +0000 | [diff] [blame] | 9402 | bnx2x_8727_specific_func(phy, params, PHY_INIT); |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 9403 | /* Initially configure MOD_ABS to interrupt when module is |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 9404 | * presence( bit 8) |
| 9405 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9406 | bnx2x_cl45_read(bp, phy, |
| 9407 | MDIO_PMA_DEVAD, MDIO_PMA_REG_PHY_IDENTIFIER, &mod_abs); |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 9408 | /* Set EDC off by setting OPTXLOS signal input to low (bit 9). |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 9409 | * When the EDC is off it locks onto a reference clock and avoids |
| 9410 | * becoming 'lost' |
| 9411 | */ |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 9412 | mod_abs &= ~(1<<8); |
| 9413 | if (!(phy->flags & FLAGS_NOC)) |
| 9414 | mod_abs &= ~(1<<9); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9415 | bnx2x_cl45_write(bp, phy, |
| 9416 | MDIO_PMA_DEVAD, MDIO_PMA_REG_PHY_IDENTIFIER, mod_abs); |
| 9417 | |
Yaniv Rosner | 85242ee | 2011-07-05 01:06:53 +0000 | [diff] [blame] | 9418 | /* Enable/Disable PHY transmitter output */ |
| 9419 | bnx2x_set_disable_pmd_transmit(params, phy, 0); |
| 9420 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9421 | bnx2x_8727_power_module(bp, phy, 1); |
| 9422 | |
| 9423 | bnx2x_cl45_read(bp, phy, |
| 9424 | MDIO_PMA_DEVAD, MDIO_PMA_REG_M8051_MSGOUT_REG, &tmp1); |
| 9425 | |
| 9426 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 9427 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_RXSTAT, &tmp1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9428 | |
Yuval Mintz | dbef807 | 2012-06-20 19:05:22 +0000 | [diff] [blame] | 9429 | bnx2x_8727_config_speed(phy, params); |
Yaniv Rosner | 5c107fd | 2012-09-13 02:56:19 +0000 | [diff] [blame] | 9430 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9431 | |
| 9432 | /* Set TX PreEmphasis if needed */ |
| 9433 | if ((params->feature_config_flags & |
| 9434 | FEATURE_CONFIG_OVERRIDE_PREEMPHASIS_ENABLED)) { |
| 9435 | DP(NETIF_MSG_LINK, "Setting TX_CTRL1 0x%x, TX_CTRL2 0x%x\n", |
| 9436 | phy->tx_preemphasis[0], |
| 9437 | phy->tx_preemphasis[1]); |
| 9438 | bnx2x_cl45_write(bp, phy, |
| 9439 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_TX_CTRL1, |
| 9440 | phy->tx_preemphasis[0]); |
| 9441 | |
| 9442 | bnx2x_cl45_write(bp, phy, |
| 9443 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_TX_CTRL2, |
| 9444 | phy->tx_preemphasis[1]); |
| 9445 | } |
| 9446 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 9447 | /* If TX Laser is controlled by GPIO_0, do not let PHY go into low |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 9448 | * power mode, if TX Laser is disabled |
| 9449 | */ |
| 9450 | tx_en_mode = REG_RD(bp, params->shmem_base + |
| 9451 | offsetof(struct shmem_region, |
| 9452 | dev_info.port_hw_config[params->port].sfp_ctrl)) |
| 9453 | & PORT_HW_CFG_TX_LASER_MASK; |
| 9454 | |
| 9455 | if (tx_en_mode == PORT_HW_CFG_TX_LASER_GPIO0) { |
| 9456 | |
| 9457 | DP(NETIF_MSG_LINK, "Enabling TXONOFF_PWRDN_DIS\n"); |
| 9458 | bnx2x_cl45_read(bp, phy, |
| 9459 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_OPT_CFG_REG, &tmp2); |
| 9460 | tmp2 |= 0x1000; |
| 9461 | tmp2 &= 0xFFEF; |
| 9462 | bnx2x_cl45_write(bp, phy, |
| 9463 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_OPT_CFG_REG, tmp2); |
Yaniv Rosner | 59a2e53 | 2012-04-04 01:28:59 +0000 | [diff] [blame] | 9464 | bnx2x_cl45_read(bp, phy, |
| 9465 | MDIO_PMA_DEVAD, MDIO_PMA_REG_PHY_IDENTIFIER, |
| 9466 | &tmp2); |
| 9467 | bnx2x_cl45_write(bp, phy, |
| 9468 | MDIO_PMA_DEVAD, MDIO_PMA_REG_PHY_IDENTIFIER, |
| 9469 | (tmp2 & 0x7fff)); |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 9470 | } |
| 9471 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9472 | return 0; |
| 9473 | } |
| 9474 | |
| 9475 | static void bnx2x_8727_handle_mod_abs(struct bnx2x_phy *phy, |
| 9476 | struct link_params *params) |
| 9477 | { |
| 9478 | struct bnx2x *bp = params->bp; |
| 9479 | u16 mod_abs, rx_alarm_status; |
| 9480 | u32 val = REG_RD(bp, params->shmem_base + |
| 9481 | offsetof(struct shmem_region, dev_info. |
| 9482 | port_feature_config[params->port]. |
| 9483 | config)); |
| 9484 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 9485 | MDIO_PMA_DEVAD, |
| 9486 | MDIO_PMA_REG_PHY_IDENTIFIER, &mod_abs); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9487 | if (mod_abs & (1<<8)) { |
| 9488 | |
| 9489 | /* Module is absent */ |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 9490 | DP(NETIF_MSG_LINK, |
| 9491 | "MOD_ABS indication show module is absent\n"); |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 9492 | phy->media_type = ETH_PHY_NOT_PRESENT; |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 9493 | /* 1. Set mod_abs to detect next module |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 9494 | * presence event |
| 9495 | * 2. Set EDC off by setting OPTXLOS signal input to low |
| 9496 | * (bit 9). |
| 9497 | * When the EDC is off it locks onto a reference clock and |
| 9498 | * avoids becoming 'lost'. |
| 9499 | */ |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 9500 | mod_abs &= ~(1<<8); |
| 9501 | if (!(phy->flags & FLAGS_NOC)) |
| 9502 | mod_abs &= ~(1<<9); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9503 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 9504 | MDIO_PMA_DEVAD, |
| 9505 | MDIO_PMA_REG_PHY_IDENTIFIER, mod_abs); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9506 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 9507 | /* Clear RX alarm since it stays up as long as |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 9508 | * the mod_abs wasn't changed |
| 9509 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9510 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 9511 | MDIO_PMA_DEVAD, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 9512 | MDIO_PMA_LASI_RXSTAT, &rx_alarm_status); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9513 | |
| 9514 | } else { |
| 9515 | /* Module is present */ |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 9516 | DP(NETIF_MSG_LINK, |
| 9517 | "MOD_ABS indication show module is present\n"); |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 9518 | /* First disable transmitter, and if the module is ok, the |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 9519 | * module_detection will enable it |
| 9520 | * 1. Set mod_abs to detect next module absent event ( bit 8) |
| 9521 | * 2. Restore the default polarity of the OPRXLOS signal and |
| 9522 | * this signal will then correctly indicate the presence or |
| 9523 | * absence of the Rx signal. (bit 9) |
| 9524 | */ |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 9525 | mod_abs |= (1<<8); |
| 9526 | if (!(phy->flags & FLAGS_NOC)) |
| 9527 | mod_abs |= (1<<9); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9528 | bnx2x_cl45_write(bp, phy, |
| 9529 | MDIO_PMA_DEVAD, |
| 9530 | MDIO_PMA_REG_PHY_IDENTIFIER, mod_abs); |
| 9531 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 9532 | /* Clear RX alarm since it stays up as long as the mod_abs |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 9533 | * wasn't changed. This is need to be done before calling the |
| 9534 | * module detection, otherwise it will clear* the link update |
| 9535 | * alarm |
| 9536 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9537 | bnx2x_cl45_read(bp, phy, |
| 9538 | MDIO_PMA_DEVAD, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 9539 | MDIO_PMA_LASI_RXSTAT, &rx_alarm_status); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9540 | |
| 9541 | |
| 9542 | if ((val & PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK) == |
| 9543 | PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_DISABLE_TX_LASER) |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 9544 | bnx2x_sfp_set_transmitter(params, phy, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9545 | |
| 9546 | if (bnx2x_wait_for_sfp_module_initialized(phy, params) == 0) |
| 9547 | bnx2x_sfp_module_detection(phy, params); |
| 9548 | else |
| 9549 | DP(NETIF_MSG_LINK, "SFP+ module is not initialized\n"); |
Yuval Mintz | dbef807 | 2012-06-20 19:05:22 +0000 | [diff] [blame] | 9550 | |
| 9551 | /* Reconfigure link speed based on module type limitations */ |
| 9552 | bnx2x_8727_config_speed(phy, params); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9553 | } |
| 9554 | |
| 9555 | DP(NETIF_MSG_LINK, "8727 RX_ALARM_STATUS 0x%x\n", |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 9556 | rx_alarm_status); |
| 9557 | /* No need to check link status in case of module plugged in/out */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9558 | } |
| 9559 | |
| 9560 | static u8 bnx2x_8727_read_status(struct bnx2x_phy *phy, |
| 9561 | struct link_params *params, |
| 9562 | struct link_vars *vars) |
| 9563 | |
| 9564 | { |
| 9565 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 27d0243 | 2011-05-31 21:27:48 +0000 | [diff] [blame] | 9566 | u8 link_up = 0, oc_port = params->port; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9567 | u16 link_status = 0; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 9568 | u16 rx_alarm_status, lasi_ctrl, val1; |
| 9569 | |
| 9570 | /* If PHY is not initialized, do not check link status */ |
| 9571 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 9572 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_CTRL, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 9573 | &lasi_ctrl); |
| 9574 | if (!lasi_ctrl) |
| 9575 | return 0; |
| 9576 | |
Yaniv Rosner | 9045f6b4 | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 9577 | /* Check the LASI on Rx */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9578 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 9579 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_RXSTAT, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9580 | &rx_alarm_status); |
| 9581 | vars->line_speed = 0; |
| 9582 | DP(NETIF_MSG_LINK, "8727 RX_ALARM_STATUS 0x%x\n", rx_alarm_status); |
| 9583 | |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 9584 | bnx2x_sfp_mask_fault(bp, phy, MDIO_PMA_LASI_TXSTAT, |
| 9585 | MDIO_PMA_LASI_TXCTRL); |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 9586 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9587 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 9588 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_STAT, &val1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9589 | |
| 9590 | DP(NETIF_MSG_LINK, "8727 LASI status 0x%x\n", val1); |
| 9591 | |
| 9592 | /* Clear MSG-OUT */ |
| 9593 | bnx2x_cl45_read(bp, phy, |
| 9594 | MDIO_PMA_DEVAD, MDIO_PMA_REG_M8051_MSGOUT_REG, &val1); |
| 9595 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 9596 | /* If a module is present and there is need to check |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9597 | * for over current |
| 9598 | */ |
| 9599 | if (!(phy->flags & FLAGS_NOC) && !(rx_alarm_status & (1<<5))) { |
| 9600 | /* Check over-current using 8727 GPIO0 input*/ |
| 9601 | bnx2x_cl45_read(bp, phy, |
| 9602 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_GPIO_CTRL, |
| 9603 | &val1); |
| 9604 | |
| 9605 | if ((val1 & (1<<8)) == 0) { |
Yaniv Rosner | 27d0243 | 2011-05-31 21:27:48 +0000 | [diff] [blame] | 9606 | if (!CHIP_IS_E1x(bp)) |
| 9607 | oc_port = BP_PATH(bp) + (params->port << 1); |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 9608 | DP(NETIF_MSG_LINK, |
| 9609 | "8727 Power fault has been detected on port %d\n", |
| 9610 | oc_port); |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 9611 | netdev_err(bp->dev, "Error: Power fault on Port %d has " |
| 9612 | "been detected and the power to " |
| 9613 | "that SFP+ module has been removed " |
| 9614 | "to prevent failure of the card. " |
| 9615 | "Please remove the SFP+ module and " |
| 9616 | "restart the system to clear this " |
| 9617 | "error.\n", |
Yaniv Rosner | 27d0243 | 2011-05-31 21:27:48 +0000 | [diff] [blame] | 9618 | oc_port); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 9619 | /* Disable all RX_ALARMs except for mod_abs */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9620 | bnx2x_cl45_write(bp, phy, |
| 9621 | MDIO_PMA_DEVAD, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 9622 | MDIO_PMA_LASI_RXCTRL, (1<<5)); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9623 | |
| 9624 | bnx2x_cl45_read(bp, phy, |
| 9625 | MDIO_PMA_DEVAD, |
| 9626 | MDIO_PMA_REG_PHY_IDENTIFIER, &val1); |
| 9627 | /* Wait for module_absent_event */ |
| 9628 | val1 |= (1<<8); |
| 9629 | bnx2x_cl45_write(bp, phy, |
| 9630 | MDIO_PMA_DEVAD, |
| 9631 | MDIO_PMA_REG_PHY_IDENTIFIER, val1); |
| 9632 | /* Clear RX alarm */ |
| 9633 | bnx2x_cl45_read(bp, phy, |
| 9634 | MDIO_PMA_DEVAD, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 9635 | MDIO_PMA_LASI_RXSTAT, &rx_alarm_status); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9636 | return 0; |
| 9637 | } |
| 9638 | } /* Over current check */ |
| 9639 | |
| 9640 | /* When module absent bit is set, check module */ |
| 9641 | if (rx_alarm_status & (1<<5)) { |
| 9642 | bnx2x_8727_handle_mod_abs(phy, params); |
| 9643 | /* Enable all mod_abs and link detection bits */ |
| 9644 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 9645 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_RXCTRL, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9646 | ((1<<5) | (1<<2))); |
| 9647 | } |
Yaniv Rosner | 59a2e53 | 2012-04-04 01:28:59 +0000 | [diff] [blame] | 9648 | |
| 9649 | if (!(phy->flags & FLAGS_SFP_NOT_APPROVED)) { |
| 9650 | DP(NETIF_MSG_LINK, "Enabling 8727 TX laser\n"); |
| 9651 | bnx2x_sfp_set_transmitter(params, phy, 1); |
| 9652 | } else { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9653 | DP(NETIF_MSG_LINK, "Tx is disabled\n"); |
| 9654 | return 0; |
| 9655 | } |
| 9656 | |
| 9657 | bnx2x_cl45_read(bp, phy, |
| 9658 | MDIO_PMA_DEVAD, |
| 9659 | MDIO_PMA_REG_8073_SPEED_LINK_STATUS, &link_status); |
| 9660 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 9661 | /* Bits 0..2 --> speed detected, |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 9662 | * Bits 13..15--> link is down |
| 9663 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9664 | if ((link_status & (1<<2)) && (!(link_status & (1<<15)))) { |
| 9665 | link_up = 1; |
| 9666 | vars->line_speed = SPEED_10000; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 9667 | DP(NETIF_MSG_LINK, "port %x: External link up in 10G\n", |
| 9668 | params->port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9669 | } else if ((link_status & (1<<0)) && (!(link_status & (1<<13)))) { |
| 9670 | link_up = 1; |
| 9671 | vars->line_speed = SPEED_1000; |
| 9672 | DP(NETIF_MSG_LINK, "port %x: External link up in 1G\n", |
| 9673 | params->port); |
| 9674 | } else { |
| 9675 | link_up = 0; |
| 9676 | DP(NETIF_MSG_LINK, "port %x: External link is down\n", |
| 9677 | params->port); |
| 9678 | } |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 9679 | |
| 9680 | /* Capture 10G link fault. */ |
| 9681 | if (vars->line_speed == SPEED_10000) { |
| 9682 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 9683 | MDIO_PMA_LASI_TXSTAT, &val1); |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 9684 | |
| 9685 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 9686 | MDIO_PMA_LASI_TXSTAT, &val1); |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 9687 | |
| 9688 | if (val1 & (1<<0)) { |
| 9689 | vars->fault_detected = 1; |
| 9690 | } |
| 9691 | } |
| 9692 | |
Yaniv Rosner | 791f18c | 2011-01-18 04:33:42 +0000 | [diff] [blame] | 9693 | if (link_up) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9694 | bnx2x_ext_phy_resolve_fc(phy, params, vars); |
Yaniv Rosner | 791f18c | 2011-01-18 04:33:42 +0000 | [diff] [blame] | 9695 | vars->duplex = DUPLEX_FULL; |
| 9696 | DP(NETIF_MSG_LINK, "duplex = 0x%x\n", vars->duplex); |
| 9697 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 9698 | |
| 9699 | if ((DUAL_MEDIA(params)) && |
| 9700 | (phy->req_line_speed == SPEED_1000)) { |
| 9701 | bnx2x_cl45_read(bp, phy, |
| 9702 | MDIO_PMA_DEVAD, |
| 9703 | MDIO_PMA_REG_8727_PCS_GP, &val1); |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 9704 | /* In case of dual-media board and 1G, power up the XAUI side, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 9705 | * otherwise power it down. For 10G it is done automatically |
| 9706 | */ |
| 9707 | if (link_up) |
| 9708 | val1 &= ~(3<<10); |
| 9709 | else |
| 9710 | val1 |= (3<<10); |
| 9711 | bnx2x_cl45_write(bp, phy, |
| 9712 | MDIO_PMA_DEVAD, |
| 9713 | MDIO_PMA_REG_8727_PCS_GP, val1); |
| 9714 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9715 | return link_up; |
| 9716 | } |
| 9717 | |
| 9718 | static void bnx2x_8727_link_reset(struct bnx2x_phy *phy, |
| 9719 | struct link_params *params) |
| 9720 | { |
| 9721 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 85242ee | 2011-07-05 01:06:53 +0000 | [diff] [blame] | 9722 | |
| 9723 | /* Enable/Disable PHY transmitter output */ |
| 9724 | bnx2x_set_disable_pmd_transmit(params, phy, 1); |
| 9725 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9726 | /* Disable Transmitter */ |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 9727 | bnx2x_sfp_set_transmitter(params, phy, 0); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 9728 | /* Clear LASI */ |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 9729 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, MDIO_PMA_LASI_CTRL, 0); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 9730 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9731 | } |
| 9732 | |
| 9733 | /******************************************************************/ |
| 9734 | /* BCM8481/BCM84823/BCM84833 PHY SECTION */ |
| 9735 | /******************************************************************/ |
| 9736 | static void bnx2x_save_848xx_spirom_version(struct bnx2x_phy *phy, |
Yaniv Rosner | 11b2ec6 | 2012-01-17 02:33:25 +0000 | [diff] [blame] | 9737 | struct bnx2x *bp, |
| 9738 | u8 port) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9739 | { |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9740 | u16 val, fw_ver1, fw_ver2, cnt; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9741 | |
Yaniv Rosner | 11b2ec6 | 2012-01-17 02:33:25 +0000 | [diff] [blame] | 9742 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833) { |
| 9743 | bnx2x_cl45_read(bp, phy, MDIO_CTL_DEVAD, 0x400f, &fw_ver1); |
Yaniv Rosner | 8267bbb0 | 2012-04-04 01:29:00 +0000 | [diff] [blame] | 9744 | bnx2x_save_spirom_version(bp, port, fw_ver1 & 0xfff, |
Yaniv Rosner | 11b2ec6 | 2012-01-17 02:33:25 +0000 | [diff] [blame] | 9745 | phy->ver_addr); |
| 9746 | } else { |
| 9747 | /* For 32-bit registers in 848xx, access via MDIO2ARM i/f. */ |
| 9748 | /* (1) set reg 0xc200_0014(SPI_BRIDGE_CTRL_2) to 0x03000000 */ |
| 9749 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA819, 0x0014); |
| 9750 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA81A, 0xc200); |
| 9751 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA81B, 0x0000); |
| 9752 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA81C, 0x0300); |
| 9753 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA817, 0x0009); |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 9754 | |
Yaniv Rosner | 11b2ec6 | 2012-01-17 02:33:25 +0000 | [diff] [blame] | 9755 | for (cnt = 0; cnt < 100; cnt++) { |
| 9756 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, 0xA818, &val); |
| 9757 | if (val & 1) |
| 9758 | break; |
| 9759 | udelay(5); |
| 9760 | } |
| 9761 | if (cnt == 100) { |
| 9762 | DP(NETIF_MSG_LINK, "Unable to read 848xx " |
| 9763 | "phy fw version(1)\n"); |
| 9764 | bnx2x_save_spirom_version(bp, port, 0, |
| 9765 | phy->ver_addr); |
| 9766 | return; |
| 9767 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9768 | |
Yaniv Rosner | 11b2ec6 | 2012-01-17 02:33:25 +0000 | [diff] [blame] | 9769 | |
| 9770 | /* 2) read register 0xc200_0000 (SPI_FW_STATUS) */ |
| 9771 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA819, 0x0000); |
| 9772 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA81A, 0xc200); |
| 9773 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA817, 0x000A); |
| 9774 | for (cnt = 0; cnt < 100; cnt++) { |
| 9775 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, 0xA818, &val); |
| 9776 | if (val & 1) |
| 9777 | break; |
| 9778 | udelay(5); |
| 9779 | } |
| 9780 | if (cnt == 100) { |
| 9781 | DP(NETIF_MSG_LINK, "Unable to read 848xx phy fw " |
| 9782 | "version(2)\n"); |
| 9783 | bnx2x_save_spirom_version(bp, port, 0, |
| 9784 | phy->ver_addr); |
| 9785 | return; |
| 9786 | } |
| 9787 | |
| 9788 | /* lower 16 bits of the register SPI_FW_STATUS */ |
| 9789 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, 0xA81B, &fw_ver1); |
| 9790 | /* upper 16 bits of register SPI_FW_STATUS */ |
| 9791 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, 0xA81C, &fw_ver2); |
| 9792 | |
| 9793 | bnx2x_save_spirom_version(bp, port, (fw_ver2<<16) | fw_ver1, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9794 | phy->ver_addr); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9795 | } |
| 9796 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9797 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9798 | static void bnx2x_848xx_set_led(struct bnx2x *bp, |
| 9799 | struct bnx2x_phy *phy) |
| 9800 | { |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 9801 | u16 val, offset; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9802 | |
| 9803 | /* PHYC_CTL_LED_CTL */ |
| 9804 | bnx2x_cl45_read(bp, phy, |
| 9805 | MDIO_PMA_DEVAD, |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9806 | MDIO_PMA_REG_8481_LINK_SIGNAL, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9807 | val &= 0xFE00; |
| 9808 | val |= 0x0092; |
| 9809 | |
| 9810 | bnx2x_cl45_write(bp, phy, |
| 9811 | MDIO_PMA_DEVAD, |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9812 | MDIO_PMA_REG_8481_LINK_SIGNAL, val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9813 | |
| 9814 | bnx2x_cl45_write(bp, phy, |
| 9815 | MDIO_PMA_DEVAD, |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9816 | MDIO_PMA_REG_8481_LED1_MASK, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9817 | 0x80); |
| 9818 | |
| 9819 | bnx2x_cl45_write(bp, phy, |
| 9820 | MDIO_PMA_DEVAD, |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9821 | MDIO_PMA_REG_8481_LED2_MASK, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9822 | 0x18); |
| 9823 | |
Yaniv Rosner | f25b3c8 | 2011-01-18 04:33:47 +0000 | [diff] [blame] | 9824 | /* Select activity source by Tx and Rx, as suggested by PHY AE */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9825 | bnx2x_cl45_write(bp, phy, |
| 9826 | MDIO_PMA_DEVAD, |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9827 | MDIO_PMA_REG_8481_LED3_MASK, |
Yaniv Rosner | f25b3c8 | 2011-01-18 04:33:47 +0000 | [diff] [blame] | 9828 | 0x0006); |
| 9829 | |
| 9830 | /* Select the closest activity blink rate to that in 10/100/1000 */ |
| 9831 | bnx2x_cl45_write(bp, phy, |
| 9832 | MDIO_PMA_DEVAD, |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9833 | MDIO_PMA_REG_8481_LED3_BLINK, |
Yaniv Rosner | f25b3c8 | 2011-01-18 04:33:47 +0000 | [diff] [blame] | 9834 | 0); |
| 9835 | |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 9836 | /* Configure the blink rate to ~15.9 Hz */ |
Yaniv Rosner | f25b3c8 | 2011-01-18 04:33:47 +0000 | [diff] [blame] | 9837 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 9838 | MDIO_PMA_DEVAD, |
| 9839 | MDIO_PMA_REG_84823_CTL_SLOW_CLK_CNT_HIGH, |
| 9840 | MDIO_PMA_REG_84823_BLINK_RATE_VAL_15P9HZ); |
| 9841 | |
| 9842 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833) |
| 9843 | offset = MDIO_PMA_REG_84833_CTL_LED_CTL_1; |
| 9844 | else |
| 9845 | offset = MDIO_PMA_REG_84823_CTL_LED_CTL_1; |
| 9846 | |
| 9847 | bnx2x_cl45_read(bp, phy, |
| 9848 | MDIO_PMA_DEVAD, offset, &val); |
| 9849 | val |= MDIO_PMA_REG_84823_LED3_STRETCH_EN; /* stretch_en for LED3*/ |
| 9850 | bnx2x_cl45_write(bp, phy, |
| 9851 | MDIO_PMA_DEVAD, offset, val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9852 | |
| 9853 | /* 'Interrupt Mask' */ |
| 9854 | bnx2x_cl45_write(bp, phy, |
| 9855 | MDIO_AN_DEVAD, |
| 9856 | 0xFFFB, 0xFFFD); |
| 9857 | } |
| 9858 | |
Yaniv Rosner | 5c107fd | 2012-09-13 02:56:19 +0000 | [diff] [blame] | 9859 | static void bnx2x_848xx_specific_func(struct bnx2x_phy *phy, |
| 9860 | struct link_params *params, |
| 9861 | u32 action) |
| 9862 | { |
| 9863 | struct bnx2x *bp = params->bp; |
| 9864 | switch (action) { |
| 9865 | case PHY_INIT: |
| 9866 | if (phy->type != PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833) { |
| 9867 | /* Save spirom version */ |
| 9868 | bnx2x_save_848xx_spirom_version(phy, bp, params->port); |
| 9869 | } |
| 9870 | /* This phy uses the NIG latch mechanism since link indication |
| 9871 | * arrives through its LED4 and not via its LASI signal, so we |
| 9872 | * get steady signal instead of clear on read |
| 9873 | */ |
| 9874 | bnx2x_bits_en(bp, NIG_REG_LATCH_BC_0 + params->port*4, |
| 9875 | 1 << NIG_LATCH_BC_ENABLE_MI_INT); |
| 9876 | |
| 9877 | bnx2x_848xx_set_led(bp, phy); |
| 9878 | break; |
| 9879 | } |
| 9880 | } |
| 9881 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 9882 | static int bnx2x_848xx_cmn_config_init(struct bnx2x_phy *phy, |
| 9883 | struct link_params *params, |
| 9884 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9885 | { |
| 9886 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 9887 | u16 autoneg_val, an_1000_val, an_10_100_val, an_10g_val; |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9888 | |
Yaniv Rosner | 5c107fd | 2012-09-13 02:56:19 +0000 | [diff] [blame] | 9889 | bnx2x_848xx_specific_func(phy, params, PHY_INIT); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9890 | bnx2x_cl45_write(bp, phy, |
| 9891 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 0x0000); |
| 9892 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9893 | /* set 1000 speed advertisement */ |
| 9894 | bnx2x_cl45_read(bp, phy, |
| 9895 | MDIO_AN_DEVAD, MDIO_AN_REG_8481_1000T_CTRL, |
| 9896 | &an_1000_val); |
| 9897 | |
| 9898 | bnx2x_ext_phy_set_pause(params, phy, vars); |
| 9899 | bnx2x_cl45_read(bp, phy, |
| 9900 | MDIO_AN_DEVAD, |
| 9901 | MDIO_AN_REG_8481_LEGACY_AN_ADV, |
| 9902 | &an_10_100_val); |
| 9903 | bnx2x_cl45_read(bp, phy, |
| 9904 | MDIO_AN_DEVAD, MDIO_AN_REG_8481_LEGACY_MII_CTRL, |
| 9905 | &autoneg_val); |
| 9906 | /* Disable forced speed */ |
| 9907 | autoneg_val &= ~((1<<6) | (1<<8) | (1<<9) | (1<<12) | (1<<13)); |
| 9908 | an_10_100_val &= ~((1<<5) | (1<<6) | (1<<7) | (1<<8)); |
| 9909 | |
| 9910 | if (((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 9911 | (phy->speed_cap_mask & |
| 9912 | PORT_HW_CFG_SPEED_CAPABILITY_D0_1G)) || |
| 9913 | (phy->req_line_speed == SPEED_1000)) { |
| 9914 | an_1000_val |= (1<<8); |
| 9915 | autoneg_val |= (1<<9 | 1<<12); |
| 9916 | if (phy->req_duplex == DUPLEX_FULL) |
| 9917 | an_1000_val |= (1<<9); |
| 9918 | DP(NETIF_MSG_LINK, "Advertising 1G\n"); |
| 9919 | } else |
| 9920 | an_1000_val &= ~((1<<8) | (1<<9)); |
| 9921 | |
| 9922 | bnx2x_cl45_write(bp, phy, |
| 9923 | MDIO_AN_DEVAD, MDIO_AN_REG_8481_1000T_CTRL, |
| 9924 | an_1000_val); |
| 9925 | |
Yaniv Rosner | 0520e63 | 2011-07-05 01:06:59 +0000 | [diff] [blame] | 9926 | /* set 100 speed advertisement */ |
Yaniv Rosner | 7531832 | 2012-01-17 02:33:27 +0000 | [diff] [blame] | 9927 | if ((phy->req_line_speed == SPEED_AUTO_NEG) && |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9928 | (phy->speed_cap_mask & |
Yaniv Rosner | 0520e63 | 2011-07-05 01:06:59 +0000 | [diff] [blame] | 9929 | (PORT_HW_CFG_SPEED_CAPABILITY_D0_100M_FULL | |
Yaniv Rosner | 7531832 | 2012-01-17 02:33:27 +0000 | [diff] [blame] | 9930 | PORT_HW_CFG_SPEED_CAPABILITY_D0_100M_HALF))) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9931 | an_10_100_val |= (1<<7); |
| 9932 | /* Enable autoneg and restart autoneg for legacy speeds */ |
| 9933 | autoneg_val |= (1<<9 | 1<<12); |
| 9934 | |
| 9935 | if (phy->req_duplex == DUPLEX_FULL) |
| 9936 | an_10_100_val |= (1<<8); |
| 9937 | DP(NETIF_MSG_LINK, "Advertising 100M\n"); |
| 9938 | } |
| 9939 | /* set 10 speed advertisement */ |
| 9940 | if (((phy->req_line_speed == SPEED_AUTO_NEG) && |
Yaniv Rosner | 0520e63 | 2011-07-05 01:06:59 +0000 | [diff] [blame] | 9941 | (phy->speed_cap_mask & |
| 9942 | (PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_FULL | |
| 9943 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_HALF)) && |
| 9944 | (phy->supported & |
| 9945 | (SUPPORTED_10baseT_Half | |
| 9946 | SUPPORTED_10baseT_Full)))) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9947 | an_10_100_val |= (1<<5); |
| 9948 | autoneg_val |= (1<<9 | 1<<12); |
| 9949 | if (phy->req_duplex == DUPLEX_FULL) |
| 9950 | an_10_100_val |= (1<<6); |
| 9951 | DP(NETIF_MSG_LINK, "Advertising 10M\n"); |
| 9952 | } |
| 9953 | |
| 9954 | /* Only 10/100 are allowed to work in FORCE mode */ |
Yaniv Rosner | 0520e63 | 2011-07-05 01:06:59 +0000 | [diff] [blame] | 9955 | if ((phy->req_line_speed == SPEED_100) && |
| 9956 | (phy->supported & |
| 9957 | (SUPPORTED_100baseT_Half | |
| 9958 | SUPPORTED_100baseT_Full))) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9959 | autoneg_val |= (1<<13); |
| 9960 | /* Enabled AUTO-MDIX when autoneg is disabled */ |
| 9961 | bnx2x_cl45_write(bp, phy, |
| 9962 | MDIO_AN_DEVAD, MDIO_AN_REG_8481_AUX_CTRL, |
| 9963 | (1<<15 | 1<<9 | 7<<0)); |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 9964 | /* The PHY needs this set even for forced link. */ |
| 9965 | an_10_100_val |= (1<<8) | (1<<7); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9966 | DP(NETIF_MSG_LINK, "Setting 100M force\n"); |
| 9967 | } |
Yaniv Rosner | 0520e63 | 2011-07-05 01:06:59 +0000 | [diff] [blame] | 9968 | if ((phy->req_line_speed == SPEED_10) && |
| 9969 | (phy->supported & |
| 9970 | (SUPPORTED_10baseT_Half | |
| 9971 | SUPPORTED_10baseT_Full))) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9972 | /* Enabled AUTO-MDIX when autoneg is disabled */ |
| 9973 | bnx2x_cl45_write(bp, phy, |
| 9974 | MDIO_AN_DEVAD, MDIO_AN_REG_8481_AUX_CTRL, |
| 9975 | (1<<15 | 1<<9 | 7<<0)); |
| 9976 | DP(NETIF_MSG_LINK, "Setting 10M force\n"); |
| 9977 | } |
| 9978 | |
| 9979 | bnx2x_cl45_write(bp, phy, |
| 9980 | MDIO_AN_DEVAD, MDIO_AN_REG_8481_LEGACY_AN_ADV, |
| 9981 | an_10_100_val); |
| 9982 | |
| 9983 | if (phy->req_duplex == DUPLEX_FULL) |
| 9984 | autoneg_val |= (1<<8); |
| 9985 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 9986 | /* Always write this if this is not 84833. |
Yaniv Rosner | fd38f73e | 2011-08-02 22:59:53 +0000 | [diff] [blame] | 9987 | * For 84833, write it only when it's a forced speed. |
| 9988 | */ |
| 9989 | if ((phy->type != PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833) || |
| 9990 | ((autoneg_val & (1<<12)) == 0)) |
| 9991 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9992 | MDIO_AN_DEVAD, |
| 9993 | MDIO_AN_REG_8481_LEGACY_MII_CTRL, autoneg_val); |
| 9994 | |
| 9995 | if (((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 9996 | (phy->speed_cap_mask & |
| 9997 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G)) || |
| 9998 | (phy->req_line_speed == SPEED_10000)) { |
Yaniv Rosner | 9045f6b4 | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 9999 | DP(NETIF_MSG_LINK, "Advertising 10G\n"); |
| 10000 | /* Restart autoneg for 10G*/ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10001 | |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 10002 | bnx2x_cl45_read(bp, phy, |
| 10003 | MDIO_AN_DEVAD, |
| 10004 | MDIO_AN_REG_8481_10GBASE_T_AN_CTRL, |
| 10005 | &an_10g_val); |
Yaniv Rosner | 9045f6b4 | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 10006 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 10007 | MDIO_AN_DEVAD, |
| 10008 | MDIO_AN_REG_8481_10GBASE_T_AN_CTRL, |
| 10009 | an_10g_val | 0x1000); |
| 10010 | bnx2x_cl45_write(bp, phy, |
| 10011 | MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, |
| 10012 | 0x3200); |
Yaniv Rosner | fd38f73e | 2011-08-02 22:59:53 +0000 | [diff] [blame] | 10013 | } else |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10014 | bnx2x_cl45_write(bp, phy, |
| 10015 | MDIO_AN_DEVAD, |
| 10016 | MDIO_AN_REG_8481_10GBASE_T_AN_CTRL, |
| 10017 | 1); |
Yaniv Rosner | fd38f73e | 2011-08-02 22:59:53 +0000 | [diff] [blame] | 10018 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10019 | return 0; |
| 10020 | } |
| 10021 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 10022 | static int bnx2x_8481_config_init(struct bnx2x_phy *phy, |
| 10023 | struct link_params *params, |
| 10024 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10025 | { |
| 10026 | struct bnx2x *bp = params->bp; |
| 10027 | /* Restore normal power mode*/ |
| 10028 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10029 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, params->port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10030 | |
| 10031 | /* HW reset */ |
| 10032 | bnx2x_ext_phy_hw_reset(bp, params->port); |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 10033 | bnx2x_wait_reset_complete(bp, phy, params); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10034 | |
| 10035 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 1<<15); |
| 10036 | return bnx2x_848xx_cmn_config_init(phy, params, vars); |
| 10037 | } |
| 10038 | |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 10039 | #define PHY84833_CMDHDLR_WAIT 300 |
| 10040 | #define PHY84833_CMDHDLR_MAX_ARGS 5 |
| 10041 | static int bnx2x_84833_cmd_hdlr(struct bnx2x_phy *phy, |
| 10042 | struct link_params *params, |
| 10043 | u16 fw_cmd, |
Yuval Mintz | c8c60d8 | 2012-06-06 17:13:07 +0000 | [diff] [blame] | 10044 | u16 cmd_args[], int argc) |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 10045 | { |
Yuval Mintz | c8c60d8 | 2012-06-06 17:13:07 +0000 | [diff] [blame] | 10046 | int idx; |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 10047 | u16 val; |
| 10048 | struct bnx2x *bp = params->bp; |
| 10049 | /* Write CMD_OPEN_OVERRIDE to STATUS reg */ |
| 10050 | bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD, |
| 10051 | MDIO_84833_CMD_HDLR_STATUS, |
| 10052 | PHY84833_STATUS_CMD_OPEN_OVERRIDE); |
| 10053 | for (idx = 0; idx < PHY84833_CMDHDLR_WAIT; idx++) { |
| 10054 | bnx2x_cl45_read(bp, phy, MDIO_CTL_DEVAD, |
| 10055 | MDIO_84833_CMD_HDLR_STATUS, &val); |
| 10056 | if (val == PHY84833_STATUS_CMD_OPEN_FOR_CMDS) |
| 10057 | break; |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 10058 | usleep_range(1000, 2000); |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 10059 | } |
| 10060 | if (idx >= PHY84833_CMDHDLR_WAIT) { |
| 10061 | DP(NETIF_MSG_LINK, "FW cmd: FW not ready.\n"); |
| 10062 | return -EINVAL; |
| 10063 | } |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 10064 | |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 10065 | /* Prepare argument(s) and issue command */ |
Yuval Mintz | c8c60d8 | 2012-06-06 17:13:07 +0000 | [diff] [blame] | 10066 | for (idx = 0; idx < argc; idx++) { |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 10067 | bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD, |
| 10068 | MDIO_84833_CMD_HDLR_DATA1 + idx, |
| 10069 | cmd_args[idx]); |
| 10070 | } |
| 10071 | bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD, |
| 10072 | MDIO_84833_CMD_HDLR_COMMAND, fw_cmd); |
| 10073 | for (idx = 0; idx < PHY84833_CMDHDLR_WAIT; idx++) { |
| 10074 | bnx2x_cl45_read(bp, phy, MDIO_CTL_DEVAD, |
| 10075 | MDIO_84833_CMD_HDLR_STATUS, &val); |
| 10076 | if ((val == PHY84833_STATUS_CMD_COMPLETE_PASS) || |
| 10077 | (val == PHY84833_STATUS_CMD_COMPLETE_ERROR)) |
| 10078 | break; |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 10079 | usleep_range(1000, 2000); |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 10080 | } |
| 10081 | if ((idx >= PHY84833_CMDHDLR_WAIT) || |
| 10082 | (val == PHY84833_STATUS_CMD_COMPLETE_ERROR)) { |
| 10083 | DP(NETIF_MSG_LINK, "FW cmd failed.\n"); |
| 10084 | return -EINVAL; |
| 10085 | } |
| 10086 | /* Gather returning data */ |
Yuval Mintz | c8c60d8 | 2012-06-06 17:13:07 +0000 | [diff] [blame] | 10087 | for (idx = 0; idx < argc; idx++) { |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 10088 | bnx2x_cl45_read(bp, phy, MDIO_CTL_DEVAD, |
| 10089 | MDIO_84833_CMD_HDLR_DATA1 + idx, |
| 10090 | &cmd_args[idx]); |
| 10091 | } |
| 10092 | bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD, |
| 10093 | MDIO_84833_CMD_HDLR_STATUS, |
| 10094 | PHY84833_STATUS_CMD_CLEAR_COMPLETE); |
| 10095 | return 0; |
| 10096 | } |
| 10097 | |
| 10098 | |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 10099 | static int bnx2x_84833_pair_swap_cfg(struct bnx2x_phy *phy, |
| 10100 | struct link_params *params, |
| 10101 | struct link_vars *vars) |
| 10102 | { |
Yaniv Rosner | 0520e63 | 2011-07-05 01:06:59 +0000 | [diff] [blame] | 10103 | u32 pair_swap; |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 10104 | u16 data[PHY84833_CMDHDLR_MAX_ARGS]; |
| 10105 | int status; |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 10106 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 10107 | |
Yaniv Rosner | 0520e63 | 2011-07-05 01:06:59 +0000 | [diff] [blame] | 10108 | /* Check for configuration. */ |
| 10109 | pair_swap = REG_RD(bp, params->shmem_base + |
| 10110 | offsetof(struct shmem_region, |
| 10111 | dev_info.port_hw_config[params->port].xgbt_phy_cfg)) & |
| 10112 | PORT_HW_CFG_RJ45_PAIR_SWAP_MASK; |
| 10113 | |
| 10114 | if (pair_swap == 0) |
| 10115 | return 0; |
| 10116 | |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 10117 | /* Only the second argument is used for this command */ |
| 10118 | data[1] = (u16)pair_swap; |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 10119 | |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 10120 | status = bnx2x_84833_cmd_hdlr(phy, params, |
Yuval Mintz | c8c60d8 | 2012-06-06 17:13:07 +0000 | [diff] [blame] | 10121 | PHY84833_CMD_SET_PAIR_SWAP, data, PHY84833_CMDHDLR_MAX_ARGS); |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 10122 | if (status == 0) |
| 10123 | DP(NETIF_MSG_LINK, "Pairswap OK, val=0x%x\n", data[1]); |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 10124 | |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 10125 | return status; |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 10126 | } |
| 10127 | |
Yaniv Rosner | 985848f | 2011-07-05 01:06:48 +0000 | [diff] [blame] | 10128 | static u8 bnx2x_84833_get_reset_gpios(struct bnx2x *bp, |
| 10129 | u32 shmem_base_path[], |
| 10130 | u32 chip_id) |
Yaniv Rosner | 0d40f0d | 2011-06-14 01:34:27 +0000 | [diff] [blame] | 10131 | { |
| 10132 | u32 reset_pin[2]; |
| 10133 | u32 idx; |
| 10134 | u8 reset_gpios; |
| 10135 | if (CHIP_IS_E3(bp)) { |
| 10136 | /* Assume that these will be GPIOs, not EPIOs. */ |
| 10137 | for (idx = 0; idx < 2; idx++) { |
| 10138 | /* Map config param to register bit. */ |
| 10139 | reset_pin[idx] = REG_RD(bp, shmem_base_path[idx] + |
| 10140 | offsetof(struct shmem_region, |
| 10141 | dev_info.port_hw_config[0].e3_cmn_pin_cfg)); |
| 10142 | reset_pin[idx] = (reset_pin[idx] & |
| 10143 | PORT_HW_CFG_E3_PHY_RESET_MASK) >> |
| 10144 | PORT_HW_CFG_E3_PHY_RESET_SHIFT; |
| 10145 | reset_pin[idx] -= PIN_CFG_GPIO0_P0; |
| 10146 | reset_pin[idx] = (1 << reset_pin[idx]); |
| 10147 | } |
| 10148 | reset_gpios = (u8)(reset_pin[0] | reset_pin[1]); |
| 10149 | } else { |
| 10150 | /* E2, look from diff place of shmem. */ |
| 10151 | for (idx = 0; idx < 2; idx++) { |
| 10152 | reset_pin[idx] = REG_RD(bp, shmem_base_path[idx] + |
| 10153 | offsetof(struct shmem_region, |
| 10154 | dev_info.port_hw_config[0].default_cfg)); |
| 10155 | reset_pin[idx] &= PORT_HW_CFG_EXT_PHY_GPIO_RST_MASK; |
| 10156 | reset_pin[idx] -= PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO0_P0; |
| 10157 | reset_pin[idx] >>= PORT_HW_CFG_EXT_PHY_GPIO_RST_SHIFT; |
| 10158 | reset_pin[idx] = (1 << reset_pin[idx]); |
| 10159 | } |
| 10160 | reset_gpios = (u8)(reset_pin[0] | reset_pin[1]); |
| 10161 | } |
| 10162 | |
Yaniv Rosner | 985848f | 2011-07-05 01:06:48 +0000 | [diff] [blame] | 10163 | return reset_gpios; |
| 10164 | } |
| 10165 | |
| 10166 | static int bnx2x_84833_hw_reset_phy(struct bnx2x_phy *phy, |
| 10167 | struct link_params *params) |
| 10168 | { |
| 10169 | struct bnx2x *bp = params->bp; |
| 10170 | u8 reset_gpios; |
| 10171 | u32 other_shmem_base_addr = REG_RD(bp, params->shmem2_base + |
| 10172 | offsetof(struct shmem2_region, |
| 10173 | other_shmem_base_addr)); |
| 10174 | |
| 10175 | u32 shmem_base_path[2]; |
Yaniv Rosner | 99bf7f3 | 2012-04-04 01:29:01 +0000 | [diff] [blame] | 10176 | |
| 10177 | /* Work around for 84833 LED failure inside RESET status */ |
| 10178 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, |
| 10179 | MDIO_AN_REG_8481_LEGACY_MII_CTRL, |
| 10180 | MDIO_AN_REG_8481_MII_CTRL_FORCE_1G); |
| 10181 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, |
| 10182 | MDIO_AN_REG_8481_1G_100T_EXT_CTRL, |
| 10183 | MIDO_AN_REG_8481_EXT_CTRL_FORCE_LEDS_OFF); |
| 10184 | |
Yaniv Rosner | 985848f | 2011-07-05 01:06:48 +0000 | [diff] [blame] | 10185 | shmem_base_path[0] = params->shmem_base; |
| 10186 | shmem_base_path[1] = other_shmem_base_addr; |
| 10187 | |
| 10188 | reset_gpios = bnx2x_84833_get_reset_gpios(bp, shmem_base_path, |
| 10189 | params->chip_id); |
| 10190 | |
| 10191 | bnx2x_set_mult_gpio(bp, reset_gpios, MISC_REGISTERS_GPIO_OUTPUT_LOW); |
| 10192 | udelay(10); |
| 10193 | DP(NETIF_MSG_LINK, "84833 hw reset on pin values 0x%x\n", |
| 10194 | reset_gpios); |
| 10195 | |
| 10196 | return 0; |
| 10197 | } |
| 10198 | |
Yuval Mintz | c8c60d8 | 2012-06-06 17:13:07 +0000 | [diff] [blame] | 10199 | static int bnx2x_8483x_disable_eee(struct bnx2x_phy *phy, |
| 10200 | struct link_params *params, |
| 10201 | struct link_vars *vars) |
| 10202 | { |
| 10203 | int rc; |
| 10204 | struct bnx2x *bp = params->bp; |
| 10205 | u16 cmd_args = 0; |
| 10206 | |
| 10207 | DP(NETIF_MSG_LINK, "Don't Advertise 10GBase-T EEE\n"); |
| 10208 | |
Yuval Mintz | c8c60d8 | 2012-06-06 17:13:07 +0000 | [diff] [blame] | 10209 | /* Prevent Phy from working in EEE and advertising it */ |
| 10210 | rc = bnx2x_84833_cmd_hdlr(phy, params, |
| 10211 | PHY84833_CMD_SET_EEE_MODE, &cmd_args, 1); |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 10212 | if (rc) { |
Yuval Mintz | c8c60d8 | 2012-06-06 17:13:07 +0000 | [diff] [blame] | 10213 | DP(NETIF_MSG_LINK, "EEE disable failed.\n"); |
| 10214 | return rc; |
| 10215 | } |
| 10216 | |
Yuval Mintz | ec4010e | 2012-09-10 05:51:06 +0000 | [diff] [blame] | 10217 | return bnx2x_eee_disable(phy, params, vars); |
Yuval Mintz | c8c60d8 | 2012-06-06 17:13:07 +0000 | [diff] [blame] | 10218 | } |
| 10219 | |
| 10220 | static int bnx2x_8483x_enable_eee(struct bnx2x_phy *phy, |
| 10221 | struct link_params *params, |
| 10222 | struct link_vars *vars) |
| 10223 | { |
| 10224 | int rc; |
| 10225 | struct bnx2x *bp = params->bp; |
| 10226 | u16 cmd_args = 1; |
| 10227 | |
Yuval Mintz | c8c60d8 | 2012-06-06 17:13:07 +0000 | [diff] [blame] | 10228 | rc = bnx2x_84833_cmd_hdlr(phy, params, |
| 10229 | PHY84833_CMD_SET_EEE_MODE, &cmd_args, 1); |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 10230 | if (rc) { |
Yuval Mintz | c8c60d8 | 2012-06-06 17:13:07 +0000 | [diff] [blame] | 10231 | DP(NETIF_MSG_LINK, "EEE enable failed.\n"); |
| 10232 | return rc; |
| 10233 | } |
| 10234 | |
Yuval Mintz | ec4010e | 2012-09-10 05:51:06 +0000 | [diff] [blame] | 10235 | return bnx2x_eee_advertise(phy, params, vars, SHMEM_EEE_10G_ADV); |
Yuval Mintz | c8c60d8 | 2012-06-06 17:13:07 +0000 | [diff] [blame] | 10236 | } |
| 10237 | |
Yaniv Rosner | a89a1d4 | 2011-07-05 01:07:05 +0000 | [diff] [blame] | 10238 | #define PHY84833_CONSTANT_LATENCY 1193 |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 10239 | static int bnx2x_848x3_config_init(struct bnx2x_phy *phy, |
| 10240 | struct link_params *params, |
| 10241 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10242 | { |
| 10243 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 6a71bbe | 2010-11-01 05:32:31 +0000 | [diff] [blame] | 10244 | u8 port, initialize = 1; |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 10245 | u16 val; |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 10246 | u32 actual_phy_selection, cms_enable; |
| 10247 | u16 cmd_args[PHY84833_CMDHDLR_MAX_ARGS]; |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 10248 | int rc = 0; |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10249 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 10250 | usleep_range(1000, 2000); |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 10251 | |
Yuval Mintz | 5481388 | 2012-06-16 20:27:15 +0000 | [diff] [blame] | 10252 | if (!(CHIP_IS_E1x(bp))) |
Yaniv Rosner | 6a71bbe | 2010-11-01 05:32:31 +0000 | [diff] [blame] | 10253 | port = BP_PATH(bp); |
| 10254 | else |
| 10255 | port = params->port; |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 10256 | |
| 10257 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84823) { |
| 10258 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_3, |
| 10259 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, |
| 10260 | port); |
| 10261 | } else { |
Yaniv Rosner | 985848f | 2011-07-05 01:06:48 +0000 | [diff] [blame] | 10262 | /* MDIO reset */ |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 10263 | bnx2x_cl45_write(bp, phy, |
| 10264 | MDIO_PMA_DEVAD, |
| 10265 | MDIO_PMA_REG_CTRL, 0x8000); |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 10266 | } |
| 10267 | |
| 10268 | bnx2x_wait_reset_complete(bp, phy, params); |
| 10269 | |
| 10270 | /* Wait for GPHY to come out of reset */ |
| 10271 | msleep(50); |
Yaniv Rosner | 11b2ec6 | 2012-01-17 02:33:25 +0000 | [diff] [blame] | 10272 | if (phy->type != PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833) { |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 10273 | /* BCM84823 requires that XGXS links up first @ 10G for normal |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 10274 | * behavior. |
| 10275 | */ |
| 10276 | u16 temp; |
| 10277 | temp = vars->line_speed; |
| 10278 | vars->line_speed = SPEED_10000; |
| 10279 | bnx2x_set_autoneg(¶ms->phy[INT_PHY], params, vars, 0); |
| 10280 | bnx2x_program_serdes(¶ms->phy[INT_PHY], params, vars); |
| 10281 | vars->line_speed = temp; |
| 10282 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 10283 | |
| 10284 | bnx2x_cl45_read(bp, phy, MDIO_CTL_DEVAD, |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 10285 | MDIO_CTL_REG_84823_MEDIA, &val); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 10286 | val &= ~(MDIO_CTL_REG_84823_MEDIA_MAC_MASK | |
| 10287 | MDIO_CTL_REG_84823_MEDIA_LINE_MASK | |
| 10288 | MDIO_CTL_REG_84823_MEDIA_COPPER_CORE_DOWN | |
| 10289 | MDIO_CTL_REG_84823_MEDIA_PRIORITY_MASK | |
| 10290 | MDIO_CTL_REG_84823_MEDIA_FIBER_1G); |
Yaniv Rosner | 0d40f0d | 2011-06-14 01:34:27 +0000 | [diff] [blame] | 10291 | |
| 10292 | if (CHIP_IS_E3(bp)) { |
| 10293 | val &= ~(MDIO_CTL_REG_84823_MEDIA_MAC_MASK | |
| 10294 | MDIO_CTL_REG_84823_MEDIA_LINE_MASK); |
| 10295 | } else { |
| 10296 | val |= (MDIO_CTL_REG_84823_CTRL_MAC_XFI | |
| 10297 | MDIO_CTL_REG_84823_MEDIA_LINE_XAUI_L); |
| 10298 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 10299 | |
| 10300 | actual_phy_selection = bnx2x_phy_selection(params); |
| 10301 | |
| 10302 | switch (actual_phy_selection) { |
| 10303 | case PORT_HW_CFG_PHY_SELECTION_HARDWARE_DEFAULT: |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 10304 | /* Do nothing. Essentially this is like the priority copper */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 10305 | break; |
| 10306 | case PORT_HW_CFG_PHY_SELECTION_FIRST_PHY_PRIORITY: |
| 10307 | val |= MDIO_CTL_REG_84823_MEDIA_PRIORITY_COPPER; |
| 10308 | break; |
| 10309 | case PORT_HW_CFG_PHY_SELECTION_SECOND_PHY_PRIORITY: |
| 10310 | val |= MDIO_CTL_REG_84823_MEDIA_PRIORITY_FIBER; |
| 10311 | break; |
| 10312 | case PORT_HW_CFG_PHY_SELECTION_FIRST_PHY: |
| 10313 | /* Do nothing here. The first PHY won't be initialized at all */ |
| 10314 | break; |
| 10315 | case PORT_HW_CFG_PHY_SELECTION_SECOND_PHY: |
| 10316 | val |= MDIO_CTL_REG_84823_MEDIA_COPPER_CORE_DOWN; |
| 10317 | initialize = 0; |
| 10318 | break; |
| 10319 | } |
| 10320 | if (params->phy[EXT_PHY2].req_line_speed == SPEED_1000) |
| 10321 | val |= MDIO_CTL_REG_84823_MEDIA_FIBER_1G; |
| 10322 | |
| 10323 | bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD, |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 10324 | MDIO_CTL_REG_84823_MEDIA, val); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 10325 | DP(NETIF_MSG_LINK, "Multi_phy config = 0x%x, Media control = 0x%x\n", |
| 10326 | params->multi_phy_config, val); |
| 10327 | |
Yaniv Rosner | 11b2ec6 | 2012-01-17 02:33:25 +0000 | [diff] [blame] | 10328 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833) { |
| 10329 | bnx2x_84833_pair_swap_cfg(phy, params, vars); |
Yaniv Rosner | a89a1d4 | 2011-07-05 01:07:05 +0000 | [diff] [blame] | 10330 | |
Yaniv Rosner | 096b952 | 2012-01-17 02:33:28 +0000 | [diff] [blame] | 10331 | /* Keep AutogrEEEn disabled. */ |
| 10332 | cmd_args[0] = 0x0; |
Yaniv Rosner | 11b2ec6 | 2012-01-17 02:33:25 +0000 | [diff] [blame] | 10333 | cmd_args[1] = 0x0; |
| 10334 | cmd_args[2] = PHY84833_CONSTANT_LATENCY + 1; |
| 10335 | cmd_args[3] = PHY84833_CONSTANT_LATENCY; |
| 10336 | rc = bnx2x_84833_cmd_hdlr(phy, params, |
Yuval Mintz | c8c60d8 | 2012-06-06 17:13:07 +0000 | [diff] [blame] | 10337 | PHY84833_CMD_SET_EEE_MODE, cmd_args, |
| 10338 | PHY84833_CMDHDLR_MAX_ARGS); |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 10339 | if (rc) |
Yaniv Rosner | 11b2ec6 | 2012-01-17 02:33:25 +0000 | [diff] [blame] | 10340 | DP(NETIF_MSG_LINK, "Cfg AutogrEEEn failed.\n"); |
| 10341 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 10342 | if (initialize) |
| 10343 | rc = bnx2x_848xx_cmn_config_init(phy, params, vars); |
| 10344 | else |
Yaniv Rosner | 11b2ec6 | 2012-01-17 02:33:25 +0000 | [diff] [blame] | 10345 | bnx2x_save_848xx_spirom_version(phy, bp, params->port); |
Yaniv Rosner | a89a1d4 | 2011-07-05 01:07:05 +0000 | [diff] [blame] | 10346 | /* 84833 PHY has a better feature and doesn't need to support this. */ |
| 10347 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84823) { |
| 10348 | cms_enable = REG_RD(bp, params->shmem_base + |
Yaniv Rosner | 1bef68e | 2011-01-31 04:22:46 +0000 | [diff] [blame] | 10349 | offsetof(struct shmem_region, |
| 10350 | dev_info.port_hw_config[params->port].default_cfg)) & |
| 10351 | PORT_HW_CFG_ENABLE_CMS_MASK; |
| 10352 | |
Yaniv Rosner | a89a1d4 | 2011-07-05 01:07:05 +0000 | [diff] [blame] | 10353 | bnx2x_cl45_read(bp, phy, MDIO_CTL_DEVAD, |
| 10354 | MDIO_CTL_REG_84823_USER_CTRL_REG, &val); |
| 10355 | if (cms_enable) |
| 10356 | val |= MDIO_CTL_REG_84823_USER_CTRL_CMS; |
| 10357 | else |
| 10358 | val &= ~MDIO_CTL_REG_84823_USER_CTRL_CMS; |
| 10359 | bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD, |
| 10360 | MDIO_CTL_REG_84823_USER_CTRL_REG, val); |
| 10361 | } |
Yaniv Rosner | 1bef68e | 2011-01-31 04:22:46 +0000 | [diff] [blame] | 10362 | |
Yuval Mintz | c8c60d8 | 2012-06-06 17:13:07 +0000 | [diff] [blame] | 10363 | bnx2x_cl45_read(bp, phy, MDIO_CTL_DEVAD, |
| 10364 | MDIO_84833_TOP_CFG_FW_REV, &val); |
| 10365 | |
| 10366 | /* Configure EEE support */ |
Yuval Mintz | f6b6eb6 | 2012-09-10 05:51:07 +0000 | [diff] [blame] | 10367 | if ((val >= MDIO_84833_TOP_CFG_FW_EEE) && |
| 10368 | (val != MDIO_84833_TOP_CFG_FW_NO_EEE) && |
| 10369 | bnx2x_eee_has_cap(params)) { |
Yuval Mintz | ec4010e | 2012-09-10 05:51:06 +0000 | [diff] [blame] | 10370 | rc = bnx2x_eee_initial_config(params, vars, SHMEM_EEE_10G_ADV); |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 10371 | if (rc) { |
Yuval Mintz | c8c60d8 | 2012-06-06 17:13:07 +0000 | [diff] [blame] | 10372 | DP(NETIF_MSG_LINK, "Failed to configure EEE timers\n"); |
| 10373 | bnx2x_8483x_disable_eee(phy, params, vars); |
| 10374 | return rc; |
| 10375 | } |
| 10376 | |
| 10377 | if ((params->req_duplex[actual_phy_selection] == DUPLEX_FULL) && |
| 10378 | (params->eee_mode & EEE_MODE_ADV_LPI) && |
| 10379 | (bnx2x_eee_calc_timer(params) || |
| 10380 | !(params->eee_mode & EEE_MODE_ENABLE_LPI))) |
| 10381 | rc = bnx2x_8483x_enable_eee(phy, params, vars); |
| 10382 | else |
| 10383 | rc = bnx2x_8483x_disable_eee(phy, params, vars); |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 10384 | if (rc) { |
Yuval Mintz | c8c60d8 | 2012-06-06 17:13:07 +0000 | [diff] [blame] | 10385 | DP(NETIF_MSG_LINK, "Failed to set EEE advertisment\n"); |
| 10386 | return rc; |
| 10387 | } |
| 10388 | } else { |
Yuval Mintz | c8c60d8 | 2012-06-06 17:13:07 +0000 | [diff] [blame] | 10389 | vars->eee_status &= ~SHMEM_EEE_SUPPORTED_MASK; |
| 10390 | } |
| 10391 | |
Yaniv Rosner | 11b2ec6 | 2012-01-17 02:33:25 +0000 | [diff] [blame] | 10392 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833) { |
| 10393 | /* Bring PHY out of super isolate mode as the final step. */ |
| 10394 | bnx2x_cl45_read(bp, phy, |
| 10395 | MDIO_CTL_DEVAD, |
| 10396 | MDIO_84833_TOP_CFG_XGPHY_STRAP1, &val); |
| 10397 | val &= ~MDIO_84833_SUPER_ISOLATE; |
| 10398 | bnx2x_cl45_write(bp, phy, |
| 10399 | MDIO_CTL_DEVAD, |
| 10400 | MDIO_84833_TOP_CFG_XGPHY_STRAP1, val); |
| 10401 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 10402 | return rc; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10403 | } |
| 10404 | |
| 10405 | static u8 bnx2x_848xx_read_status(struct bnx2x_phy *phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10406 | struct link_params *params, |
| 10407 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10408 | { |
| 10409 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 10410 | u16 val, val1, val2; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10411 | u8 link_up = 0; |
| 10412 | |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 10413 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10414 | /* Check 10G-BaseT link status */ |
| 10415 | /* Check PMD signal ok */ |
| 10416 | bnx2x_cl45_read(bp, phy, |
| 10417 | MDIO_AN_DEVAD, 0xFFFA, &val1); |
| 10418 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 10419 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8481_PMD_SIGNAL, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10420 | &val2); |
| 10421 | DP(NETIF_MSG_LINK, "BCM848xx: PMD_SIGNAL 1.a811 = 0x%x\n", val2); |
| 10422 | |
| 10423 | /* Check link 10G */ |
| 10424 | if (val2 & (1<<11)) { |
| 10425 | vars->line_speed = SPEED_10000; |
Yaniv Rosner | 791f18c | 2011-01-18 04:33:42 +0000 | [diff] [blame] | 10426 | vars->duplex = DUPLEX_FULL; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10427 | link_up = 1; |
| 10428 | bnx2x_ext_phy_10G_an_resolve(bp, phy, vars); |
| 10429 | } else { /* Check Legacy speed link */ |
| 10430 | u16 legacy_status, legacy_speed; |
| 10431 | |
| 10432 | /* Enable expansion register 0x42 (Operation mode status) */ |
| 10433 | bnx2x_cl45_write(bp, phy, |
| 10434 | MDIO_AN_DEVAD, |
| 10435 | MDIO_AN_REG_8481_EXPANSION_REG_ACCESS, 0xf42); |
| 10436 | |
| 10437 | /* Get legacy speed operation status */ |
| 10438 | bnx2x_cl45_read(bp, phy, |
| 10439 | MDIO_AN_DEVAD, |
| 10440 | MDIO_AN_REG_8481_EXPANSION_REG_RD_RW, |
| 10441 | &legacy_status); |
| 10442 | |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 10443 | DP(NETIF_MSG_LINK, "Legacy speed status = 0x%x\n", |
| 10444 | legacy_status); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10445 | link_up = ((legacy_status & (1<<11)) == (1<<11)); |
Yuval Mintz | 1440090 | 2012-06-20 19:05:20 +0000 | [diff] [blame] | 10446 | legacy_speed = (legacy_status & (3<<9)); |
| 10447 | if (legacy_speed == (0<<9)) |
| 10448 | vars->line_speed = SPEED_10; |
| 10449 | else if (legacy_speed == (1<<9)) |
| 10450 | vars->line_speed = SPEED_100; |
| 10451 | else if (legacy_speed == (2<<9)) |
| 10452 | vars->line_speed = SPEED_1000; |
| 10453 | else { /* Should not happen: Treat as link down */ |
| 10454 | vars->line_speed = 0; |
| 10455 | link_up = 0; |
| 10456 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10457 | |
Yuval Mintz | 1440090 | 2012-06-20 19:05:20 +0000 | [diff] [blame] | 10458 | if (link_up) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10459 | if (legacy_status & (1<<8)) |
| 10460 | vars->duplex = DUPLEX_FULL; |
| 10461 | else |
| 10462 | vars->duplex = DUPLEX_HALF; |
| 10463 | |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 10464 | DP(NETIF_MSG_LINK, |
| 10465 | "Link is up in %dMbps, is_duplex_full= %d\n", |
| 10466 | vars->line_speed, |
| 10467 | (vars->duplex == DUPLEX_FULL)); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10468 | /* Check legacy speed AN resolution */ |
| 10469 | bnx2x_cl45_read(bp, phy, |
| 10470 | MDIO_AN_DEVAD, |
| 10471 | MDIO_AN_REG_8481_LEGACY_MII_STATUS, |
| 10472 | &val); |
| 10473 | if (val & (1<<5)) |
| 10474 | vars->link_status |= |
| 10475 | LINK_STATUS_AUTO_NEGOTIATE_COMPLETE; |
| 10476 | bnx2x_cl45_read(bp, phy, |
| 10477 | MDIO_AN_DEVAD, |
| 10478 | MDIO_AN_REG_8481_LEGACY_AN_EXPANSION, |
| 10479 | &val); |
| 10480 | if ((val & (1<<0)) == 0) |
| 10481 | vars->link_status |= |
| 10482 | LINK_STATUS_PARALLEL_DETECTION_USED; |
| 10483 | } |
| 10484 | } |
| 10485 | if (link_up) { |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 10486 | DP(NETIF_MSG_LINK, "BCM848x3: link speed is %d\n", |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10487 | vars->line_speed); |
| 10488 | bnx2x_ext_phy_resolve_fc(phy, params, vars); |
Mintz Yuval | 9e7e839 | 2012-02-15 02:10:24 +0000 | [diff] [blame] | 10489 | |
| 10490 | /* Read LP advertised speeds */ |
| 10491 | bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD, |
| 10492 | MDIO_AN_REG_CL37_FC_LP, &val); |
| 10493 | if (val & (1<<5)) |
| 10494 | vars->link_status |= |
| 10495 | LINK_STATUS_LINK_PARTNER_10THD_CAPABLE; |
| 10496 | if (val & (1<<6)) |
| 10497 | vars->link_status |= |
| 10498 | LINK_STATUS_LINK_PARTNER_10TFD_CAPABLE; |
| 10499 | if (val & (1<<7)) |
| 10500 | vars->link_status |= |
| 10501 | LINK_STATUS_LINK_PARTNER_100TXHD_CAPABLE; |
| 10502 | if (val & (1<<8)) |
| 10503 | vars->link_status |= |
| 10504 | LINK_STATUS_LINK_PARTNER_100TXFD_CAPABLE; |
| 10505 | if (val & (1<<9)) |
| 10506 | vars->link_status |= |
| 10507 | LINK_STATUS_LINK_PARTNER_100T4_CAPABLE; |
| 10508 | |
| 10509 | bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD, |
| 10510 | MDIO_AN_REG_1000T_STATUS, &val); |
| 10511 | |
| 10512 | if (val & (1<<10)) |
| 10513 | vars->link_status |= |
| 10514 | LINK_STATUS_LINK_PARTNER_1000THD_CAPABLE; |
| 10515 | if (val & (1<<11)) |
| 10516 | vars->link_status |= |
| 10517 | LINK_STATUS_LINK_PARTNER_1000TFD_CAPABLE; |
| 10518 | |
| 10519 | bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD, |
| 10520 | MDIO_AN_REG_MASTER_STATUS, &val); |
| 10521 | |
| 10522 | if (val & (1<<11)) |
| 10523 | vars->link_status |= |
| 10524 | LINK_STATUS_LINK_PARTNER_10GXFD_CAPABLE; |
Yuval Mintz | c8c60d8 | 2012-06-06 17:13:07 +0000 | [diff] [blame] | 10525 | |
| 10526 | /* Determine if EEE was negotiated */ |
Yuval Mintz | ec4010e | 2012-09-10 05:51:06 +0000 | [diff] [blame] | 10527 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833) |
| 10528 | bnx2x_eee_an_resolve(phy, params, vars); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10529 | } |
| 10530 | |
| 10531 | return link_up; |
| 10532 | } |
| 10533 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 10534 | |
| 10535 | static int bnx2x_848xx_format_ver(u32 raw_ver, u8 *str, u16 *len) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10536 | { |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 10537 | int status = 0; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10538 | u32 spirom_ver; |
| 10539 | spirom_ver = ((raw_ver & 0xF80) >> 7) << 16 | (raw_ver & 0x7F); |
| 10540 | status = bnx2x_format_ver(spirom_ver, str, len); |
| 10541 | return status; |
| 10542 | } |
| 10543 | |
| 10544 | static void bnx2x_8481_hw_reset(struct bnx2x_phy *phy, |
| 10545 | struct link_params *params) |
| 10546 | { |
| 10547 | bnx2x_set_gpio(params->bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10548 | MISC_REGISTERS_GPIO_OUTPUT_LOW, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10549 | bnx2x_set_gpio(params->bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10550 | MISC_REGISTERS_GPIO_OUTPUT_LOW, 1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10551 | } |
| 10552 | |
| 10553 | static void bnx2x_8481_link_reset(struct bnx2x_phy *phy, |
| 10554 | struct link_params *params) |
| 10555 | { |
| 10556 | bnx2x_cl45_write(params->bp, phy, |
| 10557 | MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, 0x0000); |
| 10558 | bnx2x_cl45_write(params->bp, phy, |
| 10559 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 1); |
| 10560 | } |
| 10561 | |
| 10562 | static void bnx2x_848x3_link_reset(struct bnx2x_phy *phy, |
| 10563 | struct link_params *params) |
| 10564 | { |
| 10565 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 6a71bbe | 2010-11-01 05:32:31 +0000 | [diff] [blame] | 10566 | u8 port; |
Yaniv Rosner | 0d40f0d | 2011-06-14 01:34:27 +0000 | [diff] [blame] | 10567 | u16 val16; |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 10568 | |
Yaniv Rosner | f93fb01 | 2012-04-04 01:29:02 +0000 | [diff] [blame] | 10569 | if (!(CHIP_IS_E1x(bp))) |
Yaniv Rosner | 6a71bbe | 2010-11-01 05:32:31 +0000 | [diff] [blame] | 10570 | port = BP_PATH(bp); |
| 10571 | else |
| 10572 | port = params->port; |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 10573 | |
| 10574 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84823) { |
| 10575 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_3, |
| 10576 | MISC_REGISTERS_GPIO_OUTPUT_LOW, |
| 10577 | port); |
| 10578 | } else { |
Yaniv Rosner | 0d40f0d | 2011-06-14 01:34:27 +0000 | [diff] [blame] | 10579 | bnx2x_cl45_read(bp, phy, |
| 10580 | MDIO_CTL_DEVAD, |
Yaniv Rosner | 11b2ec6 | 2012-01-17 02:33:25 +0000 | [diff] [blame] | 10581 | MDIO_84833_TOP_CFG_XGPHY_STRAP1, &val16); |
| 10582 | val16 |= MDIO_84833_SUPER_ISOLATE; |
Yaniv Rosner | fd38f73e | 2011-08-02 22:59:53 +0000 | [diff] [blame] | 10583 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 11b2ec6 | 2012-01-17 02:33:25 +0000 | [diff] [blame] | 10584 | MDIO_CTL_DEVAD, |
| 10585 | MDIO_84833_TOP_CFG_XGPHY_STRAP1, val16); |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 10586 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10587 | } |
| 10588 | |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10589 | static void bnx2x_848xx_set_link_led(struct bnx2x_phy *phy, |
| 10590 | struct link_params *params, u8 mode) |
| 10591 | { |
| 10592 | struct bnx2x *bp = params->bp; |
| 10593 | u16 val; |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 10594 | u8 port; |
| 10595 | |
Yaniv Rosner | f93fb01 | 2012-04-04 01:29:02 +0000 | [diff] [blame] | 10596 | if (!(CHIP_IS_E1x(bp))) |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 10597 | port = BP_PATH(bp); |
| 10598 | else |
| 10599 | port = params->port; |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10600 | |
| 10601 | switch (mode) { |
| 10602 | case LED_MODE_OFF: |
| 10603 | |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 10604 | DP(NETIF_MSG_LINK, "Port 0x%x: LED MODE OFF\n", port); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10605 | |
| 10606 | if ((params->hw_led_mode << SHARED_HW_CFG_LED_MODE_SHIFT) == |
| 10607 | SHARED_HW_CFG_LED_EXTPHY1) { |
| 10608 | |
| 10609 | /* Set LED masks */ |
| 10610 | bnx2x_cl45_write(bp, phy, |
| 10611 | MDIO_PMA_DEVAD, |
| 10612 | MDIO_PMA_REG_8481_LED1_MASK, |
| 10613 | 0x0); |
| 10614 | |
| 10615 | bnx2x_cl45_write(bp, phy, |
| 10616 | MDIO_PMA_DEVAD, |
| 10617 | MDIO_PMA_REG_8481_LED2_MASK, |
| 10618 | 0x0); |
| 10619 | |
| 10620 | bnx2x_cl45_write(bp, phy, |
| 10621 | MDIO_PMA_DEVAD, |
| 10622 | MDIO_PMA_REG_8481_LED3_MASK, |
| 10623 | 0x0); |
| 10624 | |
| 10625 | bnx2x_cl45_write(bp, phy, |
| 10626 | MDIO_PMA_DEVAD, |
| 10627 | MDIO_PMA_REG_8481_LED5_MASK, |
| 10628 | 0x0); |
| 10629 | |
| 10630 | } else { |
| 10631 | bnx2x_cl45_write(bp, phy, |
| 10632 | MDIO_PMA_DEVAD, |
| 10633 | MDIO_PMA_REG_8481_LED1_MASK, |
| 10634 | 0x0); |
| 10635 | } |
| 10636 | break; |
| 10637 | case LED_MODE_FRONT_PANEL_OFF: |
| 10638 | |
| 10639 | DP(NETIF_MSG_LINK, "Port 0x%x: LED MODE FRONT PANEL OFF\n", |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 10640 | port); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10641 | |
| 10642 | if ((params->hw_led_mode << SHARED_HW_CFG_LED_MODE_SHIFT) == |
| 10643 | SHARED_HW_CFG_LED_EXTPHY1) { |
| 10644 | |
| 10645 | /* Set LED masks */ |
| 10646 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10647 | MDIO_PMA_DEVAD, |
| 10648 | MDIO_PMA_REG_8481_LED1_MASK, |
| 10649 | 0x0); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10650 | |
| 10651 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10652 | MDIO_PMA_DEVAD, |
| 10653 | MDIO_PMA_REG_8481_LED2_MASK, |
| 10654 | 0x0); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10655 | |
| 10656 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10657 | MDIO_PMA_DEVAD, |
| 10658 | MDIO_PMA_REG_8481_LED3_MASK, |
| 10659 | 0x0); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10660 | |
| 10661 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10662 | MDIO_PMA_DEVAD, |
| 10663 | MDIO_PMA_REG_8481_LED5_MASK, |
| 10664 | 0x20); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10665 | |
| 10666 | } else { |
| 10667 | bnx2x_cl45_write(bp, phy, |
| 10668 | MDIO_PMA_DEVAD, |
| 10669 | MDIO_PMA_REG_8481_LED1_MASK, |
| 10670 | 0x0); |
| 10671 | } |
| 10672 | break; |
| 10673 | case LED_MODE_ON: |
| 10674 | |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 10675 | DP(NETIF_MSG_LINK, "Port 0x%x: LED MODE ON\n", port); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10676 | |
| 10677 | if ((params->hw_led_mode << SHARED_HW_CFG_LED_MODE_SHIFT) == |
| 10678 | SHARED_HW_CFG_LED_EXTPHY1) { |
| 10679 | /* Set control reg */ |
| 10680 | bnx2x_cl45_read(bp, phy, |
| 10681 | MDIO_PMA_DEVAD, |
| 10682 | MDIO_PMA_REG_8481_LINK_SIGNAL, |
| 10683 | &val); |
| 10684 | val &= 0x8000; |
| 10685 | val |= 0x2492; |
| 10686 | |
| 10687 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10688 | MDIO_PMA_DEVAD, |
| 10689 | MDIO_PMA_REG_8481_LINK_SIGNAL, |
| 10690 | val); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10691 | |
| 10692 | /* Set LED masks */ |
| 10693 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10694 | MDIO_PMA_DEVAD, |
| 10695 | MDIO_PMA_REG_8481_LED1_MASK, |
| 10696 | 0x0); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10697 | |
| 10698 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10699 | MDIO_PMA_DEVAD, |
| 10700 | MDIO_PMA_REG_8481_LED2_MASK, |
| 10701 | 0x20); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10702 | |
| 10703 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10704 | MDIO_PMA_DEVAD, |
| 10705 | MDIO_PMA_REG_8481_LED3_MASK, |
| 10706 | 0x20); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10707 | |
| 10708 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10709 | MDIO_PMA_DEVAD, |
| 10710 | MDIO_PMA_REG_8481_LED5_MASK, |
| 10711 | 0x0); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10712 | } else { |
| 10713 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10714 | MDIO_PMA_DEVAD, |
| 10715 | MDIO_PMA_REG_8481_LED1_MASK, |
| 10716 | 0x20); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10717 | } |
| 10718 | break; |
| 10719 | |
| 10720 | case LED_MODE_OPER: |
| 10721 | |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 10722 | DP(NETIF_MSG_LINK, "Port 0x%x: LED MODE OPER\n", port); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10723 | |
| 10724 | if ((params->hw_led_mode << SHARED_HW_CFG_LED_MODE_SHIFT) == |
| 10725 | SHARED_HW_CFG_LED_EXTPHY1) { |
| 10726 | |
| 10727 | /* Set control reg */ |
| 10728 | bnx2x_cl45_read(bp, phy, |
| 10729 | MDIO_PMA_DEVAD, |
| 10730 | MDIO_PMA_REG_8481_LINK_SIGNAL, |
| 10731 | &val); |
| 10732 | |
| 10733 | if (!((val & |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10734 | MDIO_PMA_REG_8481_LINK_SIGNAL_LED4_ENABLE_MASK) |
| 10735 | >> MDIO_PMA_REG_8481_LINK_SIGNAL_LED4_ENABLE_SHIFT)) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 10736 | DP(NETIF_MSG_LINK, "Setting LINK_SIGNAL\n"); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10737 | bnx2x_cl45_write(bp, phy, |
| 10738 | MDIO_PMA_DEVAD, |
| 10739 | MDIO_PMA_REG_8481_LINK_SIGNAL, |
| 10740 | 0xa492); |
| 10741 | } |
| 10742 | |
| 10743 | /* Set LED masks */ |
| 10744 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10745 | MDIO_PMA_DEVAD, |
| 10746 | MDIO_PMA_REG_8481_LED1_MASK, |
| 10747 | 0x10); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10748 | |
| 10749 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10750 | MDIO_PMA_DEVAD, |
| 10751 | MDIO_PMA_REG_8481_LED2_MASK, |
| 10752 | 0x80); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10753 | |
| 10754 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10755 | MDIO_PMA_DEVAD, |
| 10756 | MDIO_PMA_REG_8481_LED3_MASK, |
| 10757 | 0x98); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10758 | |
| 10759 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10760 | MDIO_PMA_DEVAD, |
| 10761 | MDIO_PMA_REG_8481_LED5_MASK, |
| 10762 | 0x40); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10763 | |
| 10764 | } else { |
| 10765 | bnx2x_cl45_write(bp, phy, |
| 10766 | MDIO_PMA_DEVAD, |
| 10767 | MDIO_PMA_REG_8481_LED1_MASK, |
| 10768 | 0x80); |
Yaniv Rosner | 53eda06 | 2011-01-30 04:14:55 +0000 | [diff] [blame] | 10769 | |
| 10770 | /* Tell LED3 to blink on source */ |
| 10771 | bnx2x_cl45_read(bp, phy, |
| 10772 | MDIO_PMA_DEVAD, |
| 10773 | MDIO_PMA_REG_8481_LINK_SIGNAL, |
| 10774 | &val); |
| 10775 | val &= ~(7<<6); |
| 10776 | val |= (1<<6); /* A83B[8:6]= 1 */ |
| 10777 | bnx2x_cl45_write(bp, phy, |
| 10778 | MDIO_PMA_DEVAD, |
| 10779 | MDIO_PMA_REG_8481_LINK_SIGNAL, |
| 10780 | val); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10781 | } |
| 10782 | break; |
| 10783 | } |
Yaniv Rosner | 0d40f0d | 2011-06-14 01:34:27 +0000 | [diff] [blame] | 10784 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 10785 | /* This is a workaround for E3+84833 until autoneg |
Yaniv Rosner | 0d40f0d | 2011-06-14 01:34:27 +0000 | [diff] [blame] | 10786 | * restart is fixed in f/w |
| 10787 | */ |
| 10788 | if (CHIP_IS_E3(bp)) { |
| 10789 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 10790 | MDIO_WC_REG_GP2_STATUS_GP_2_1, &val); |
| 10791 | } |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10792 | } |
Yaniv Rosner | 0d40f0d | 2011-06-14 01:34:27 +0000 | [diff] [blame] | 10793 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10794 | /******************************************************************/ |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 10795 | /* 54618SE PHY SECTION */ |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 10796 | /******************************************************************/ |
Yaniv Rosner | 5c107fd | 2012-09-13 02:56:19 +0000 | [diff] [blame] | 10797 | static void bnx2x_54618se_specific_func(struct bnx2x_phy *phy, |
| 10798 | struct link_params *params, |
| 10799 | u32 action) |
| 10800 | { |
| 10801 | struct bnx2x *bp = params->bp; |
| 10802 | u16 temp; |
| 10803 | switch (action) { |
| 10804 | case PHY_INIT: |
| 10805 | /* Configure LED4: set to INTR (0x6). */ |
| 10806 | /* Accessing shadow register 0xe. */ |
| 10807 | bnx2x_cl22_write(bp, phy, |
| 10808 | MDIO_REG_GPHY_SHADOW, |
| 10809 | MDIO_REG_GPHY_SHADOW_LED_SEL2); |
| 10810 | bnx2x_cl22_read(bp, phy, |
| 10811 | MDIO_REG_GPHY_SHADOW, |
| 10812 | &temp); |
| 10813 | temp &= ~(0xf << 4); |
| 10814 | temp |= (0x6 << 4); |
| 10815 | bnx2x_cl22_write(bp, phy, |
| 10816 | MDIO_REG_GPHY_SHADOW, |
| 10817 | MDIO_REG_GPHY_SHADOW_WR_ENA | temp); |
| 10818 | /* Configure INTR based on link status change. */ |
| 10819 | bnx2x_cl22_write(bp, phy, |
| 10820 | MDIO_REG_INTR_MASK, |
| 10821 | ~MDIO_REG_INTR_MASK_LINK_STATUS); |
| 10822 | break; |
| 10823 | } |
| 10824 | } |
| 10825 | |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 10826 | static int bnx2x_54618se_config_init(struct bnx2x_phy *phy, |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 10827 | struct link_params *params, |
| 10828 | struct link_vars *vars) |
| 10829 | { |
| 10830 | struct bnx2x *bp = params->bp; |
| 10831 | u8 port; |
| 10832 | u16 autoneg_val, an_1000_val, an_10_100_val, fc_val, temp; |
| 10833 | u32 cfg_pin; |
| 10834 | |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 10835 | DP(NETIF_MSG_LINK, "54618SE cfg init\n"); |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 10836 | usleep_range(1000, 2000); |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 10837 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 10838 | /* This works with E3 only, no need to check the chip |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 10839 | * before determining the port. |
| 10840 | */ |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 10841 | port = params->port; |
| 10842 | |
| 10843 | cfg_pin = (REG_RD(bp, params->shmem_base + |
| 10844 | offsetof(struct shmem_region, |
| 10845 | dev_info.port_hw_config[port].e3_cmn_pin_cfg)) & |
| 10846 | PORT_HW_CFG_E3_PHY_RESET_MASK) >> |
| 10847 | PORT_HW_CFG_E3_PHY_RESET_SHIFT; |
| 10848 | |
| 10849 | /* Drive pin high to bring the GPHY out of reset. */ |
| 10850 | bnx2x_set_cfg_pin(bp, cfg_pin, 1); |
| 10851 | |
| 10852 | /* wait for GPHY to reset */ |
| 10853 | msleep(50); |
| 10854 | |
| 10855 | /* reset phy */ |
| 10856 | bnx2x_cl22_write(bp, phy, |
| 10857 | MDIO_PMA_REG_CTRL, 0x8000); |
| 10858 | bnx2x_wait_reset_complete(bp, phy, params); |
| 10859 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 10860 | /* Wait for GPHY to reset */ |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 10861 | msleep(50); |
| 10862 | |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 10863 | |
Yaniv Rosner | 5c107fd | 2012-09-13 02:56:19 +0000 | [diff] [blame] | 10864 | bnx2x_54618se_specific_func(phy, params, PHY_INIT); |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 10865 | /* Flip the signal detect polarity (set 0x1c.0x1e[8]). */ |
| 10866 | bnx2x_cl22_write(bp, phy, |
| 10867 | MDIO_REG_GPHY_SHADOW, |
| 10868 | MDIO_REG_GPHY_SHADOW_AUTO_DET_MED); |
| 10869 | bnx2x_cl22_read(bp, phy, |
| 10870 | MDIO_REG_GPHY_SHADOW, |
| 10871 | &temp); |
| 10872 | temp |= MDIO_REG_GPHY_SHADOW_INVERT_FIB_SD; |
| 10873 | bnx2x_cl22_write(bp, phy, |
| 10874 | MDIO_REG_GPHY_SHADOW, |
| 10875 | MDIO_REG_GPHY_SHADOW_WR_ENA | temp); |
| 10876 | |
| 10877 | /* Set up fc */ |
| 10878 | /* Please refer to Table 28B-3 of 802.3ab-1999 spec. */ |
| 10879 | bnx2x_calc_ieee_aneg_adv(phy, params, &vars->ieee_fc); |
| 10880 | fc_val = 0; |
| 10881 | if ((vars->ieee_fc & MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC) == |
| 10882 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC) |
| 10883 | fc_val |= MDIO_AN_REG_ADV_PAUSE_ASYMMETRIC; |
| 10884 | |
| 10885 | if ((vars->ieee_fc & MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) == |
| 10886 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) |
| 10887 | fc_val |= MDIO_AN_REG_ADV_PAUSE_PAUSE; |
| 10888 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 10889 | /* Read all advertisement */ |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 10890 | bnx2x_cl22_read(bp, phy, |
| 10891 | 0x09, |
| 10892 | &an_1000_val); |
| 10893 | |
| 10894 | bnx2x_cl22_read(bp, phy, |
| 10895 | 0x04, |
| 10896 | &an_10_100_val); |
| 10897 | |
| 10898 | bnx2x_cl22_read(bp, phy, |
| 10899 | MDIO_PMA_REG_CTRL, |
| 10900 | &autoneg_val); |
| 10901 | |
| 10902 | /* Disable forced speed */ |
| 10903 | autoneg_val &= ~((1<<6) | (1<<8) | (1<<9) | (1<<12) | (1<<13)); |
| 10904 | an_10_100_val &= ~((1<<5) | (1<<6) | (1<<7) | (1<<8) | (1<<10) | |
| 10905 | (1<<11)); |
| 10906 | |
| 10907 | if (((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 10908 | (phy->speed_cap_mask & |
| 10909 | PORT_HW_CFG_SPEED_CAPABILITY_D0_1G)) || |
| 10910 | (phy->req_line_speed == SPEED_1000)) { |
| 10911 | an_1000_val |= (1<<8); |
| 10912 | autoneg_val |= (1<<9 | 1<<12); |
| 10913 | if (phy->req_duplex == DUPLEX_FULL) |
| 10914 | an_1000_val |= (1<<9); |
| 10915 | DP(NETIF_MSG_LINK, "Advertising 1G\n"); |
| 10916 | } else |
| 10917 | an_1000_val &= ~((1<<8) | (1<<9)); |
| 10918 | |
| 10919 | bnx2x_cl22_write(bp, phy, |
| 10920 | 0x09, |
| 10921 | an_1000_val); |
| 10922 | bnx2x_cl22_read(bp, phy, |
| 10923 | 0x09, |
| 10924 | &an_1000_val); |
| 10925 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 10926 | /* Set 100 speed advertisement */ |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 10927 | if (((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 10928 | (phy->speed_cap_mask & |
| 10929 | (PORT_HW_CFG_SPEED_CAPABILITY_D0_100M_FULL | |
| 10930 | PORT_HW_CFG_SPEED_CAPABILITY_D0_100M_HALF)))) { |
| 10931 | an_10_100_val |= (1<<7); |
| 10932 | /* Enable autoneg and restart autoneg for legacy speeds */ |
| 10933 | autoneg_val |= (1<<9 | 1<<12); |
| 10934 | |
| 10935 | if (phy->req_duplex == DUPLEX_FULL) |
| 10936 | an_10_100_val |= (1<<8); |
| 10937 | DP(NETIF_MSG_LINK, "Advertising 100M\n"); |
| 10938 | } |
| 10939 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 10940 | /* Set 10 speed advertisement */ |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 10941 | if (((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 10942 | (phy->speed_cap_mask & |
| 10943 | (PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_FULL | |
| 10944 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_HALF)))) { |
| 10945 | an_10_100_val |= (1<<5); |
| 10946 | autoneg_val |= (1<<9 | 1<<12); |
| 10947 | if (phy->req_duplex == DUPLEX_FULL) |
| 10948 | an_10_100_val |= (1<<6); |
| 10949 | DP(NETIF_MSG_LINK, "Advertising 10M\n"); |
| 10950 | } |
| 10951 | |
| 10952 | /* Only 10/100 are allowed to work in FORCE mode */ |
| 10953 | if (phy->req_line_speed == SPEED_100) { |
| 10954 | autoneg_val |= (1<<13); |
| 10955 | /* Enabled AUTO-MDIX when autoneg is disabled */ |
| 10956 | bnx2x_cl22_write(bp, phy, |
| 10957 | 0x18, |
| 10958 | (1<<15 | 1<<9 | 7<<0)); |
| 10959 | DP(NETIF_MSG_LINK, "Setting 100M force\n"); |
| 10960 | } |
| 10961 | if (phy->req_line_speed == SPEED_10) { |
| 10962 | /* Enabled AUTO-MDIX when autoneg is disabled */ |
| 10963 | bnx2x_cl22_write(bp, phy, |
| 10964 | 0x18, |
| 10965 | (1<<15 | 1<<9 | 7<<0)); |
| 10966 | DP(NETIF_MSG_LINK, "Setting 10M force\n"); |
| 10967 | } |
| 10968 | |
Yuval Mintz | 26964bb | 2012-09-10 05:51:08 +0000 | [diff] [blame] | 10969 | if ((phy->flags & FLAGS_EEE) && bnx2x_eee_has_cap(params)) { |
| 10970 | int rc; |
| 10971 | |
| 10972 | bnx2x_cl22_write(bp, phy, MDIO_REG_GPHY_EXP_ACCESS, |
| 10973 | MDIO_REG_GPHY_EXP_ACCESS_TOP | |
| 10974 | MDIO_REG_GPHY_EXP_TOP_2K_BUF); |
| 10975 | bnx2x_cl22_read(bp, phy, MDIO_REG_GPHY_EXP_ACCESS_GATE, &temp); |
| 10976 | temp &= 0xfffe; |
| 10977 | bnx2x_cl22_write(bp, phy, MDIO_REG_GPHY_EXP_ACCESS_GATE, temp); |
| 10978 | |
| 10979 | rc = bnx2x_eee_initial_config(params, vars, SHMEM_EEE_1G_ADV); |
| 10980 | if (rc) { |
| 10981 | DP(NETIF_MSG_LINK, "Failed to configure EEE timers\n"); |
| 10982 | bnx2x_eee_disable(phy, params, vars); |
| 10983 | } else if ((params->eee_mode & EEE_MODE_ADV_LPI) && |
| 10984 | (phy->req_duplex == DUPLEX_FULL) && |
| 10985 | (bnx2x_eee_calc_timer(params) || |
| 10986 | !(params->eee_mode & EEE_MODE_ENABLE_LPI))) { |
| 10987 | /* Need to advertise EEE only when requested, |
| 10988 | * and either no LPI assertion was requested, |
| 10989 | * or it was requested and a valid timer was set. |
| 10990 | * Also notice full duplex is required for EEE. |
| 10991 | */ |
| 10992 | bnx2x_eee_advertise(phy, params, vars, |
| 10993 | SHMEM_EEE_1G_ADV); |
Yaniv Rosner | a89a1d4 | 2011-07-05 01:07:05 +0000 | [diff] [blame] | 10994 | } else { |
Yuval Mintz | 26964bb | 2012-09-10 05:51:08 +0000 | [diff] [blame] | 10995 | DP(NETIF_MSG_LINK, "Don't Advertise 1GBase-T EEE\n"); |
| 10996 | bnx2x_eee_disable(phy, params, vars); |
Yaniv Rosner | a89a1d4 | 2011-07-05 01:07:05 +0000 | [diff] [blame] | 10997 | } |
Yuval Mintz | 26964bb | 2012-09-10 05:51:08 +0000 | [diff] [blame] | 10998 | } else { |
| 10999 | vars->eee_status &= ~SHMEM_EEE_1G_ADV << |
| 11000 | SHMEM_EEE_SUPPORTED_SHIFT; |
| 11001 | |
| 11002 | if (phy->flags & FLAGS_EEE) { |
| 11003 | /* Handle legacy auto-grEEEn */ |
| 11004 | if (params->feature_config_flags & |
| 11005 | FEATURE_CONFIG_AUTOGREEEN_ENABLED) { |
| 11006 | temp = 6; |
| 11007 | DP(NETIF_MSG_LINK, "Enabling Auto-GrEEEn\n"); |
| 11008 | } else { |
| 11009 | temp = 0; |
| 11010 | DP(NETIF_MSG_LINK, "Don't Adv. EEE\n"); |
| 11011 | } |
| 11012 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, |
| 11013 | MDIO_AN_REG_EEE_ADV, temp); |
| 11014 | } |
Yaniv Rosner | a89a1d4 | 2011-07-05 01:07:05 +0000 | [diff] [blame] | 11015 | } |
| 11016 | |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 11017 | bnx2x_cl22_write(bp, phy, |
| 11018 | 0x04, |
| 11019 | an_10_100_val | fc_val); |
| 11020 | |
| 11021 | if (phy->req_duplex == DUPLEX_FULL) |
| 11022 | autoneg_val |= (1<<8); |
| 11023 | |
| 11024 | bnx2x_cl22_write(bp, phy, |
| 11025 | MDIO_PMA_REG_CTRL, autoneg_val); |
| 11026 | |
| 11027 | return 0; |
| 11028 | } |
| 11029 | |
Yaniv Rosner | 1d125bd | 2011-11-23 03:54:08 +0000 | [diff] [blame] | 11030 | |
| 11031 | static void bnx2x_5461x_set_link_led(struct bnx2x_phy *phy, |
| 11032 | struct link_params *params, u8 mode) |
| 11033 | { |
| 11034 | struct bnx2x *bp = params->bp; |
| 11035 | u16 temp; |
| 11036 | |
| 11037 | bnx2x_cl22_write(bp, phy, |
| 11038 | MDIO_REG_GPHY_SHADOW, |
| 11039 | MDIO_REG_GPHY_SHADOW_LED_SEL1); |
| 11040 | bnx2x_cl22_read(bp, phy, |
| 11041 | MDIO_REG_GPHY_SHADOW, |
| 11042 | &temp); |
| 11043 | temp &= 0xff00; |
| 11044 | |
| 11045 | DP(NETIF_MSG_LINK, "54618x set link led (mode=%x)\n", mode); |
| 11046 | switch (mode) { |
| 11047 | case LED_MODE_FRONT_PANEL_OFF: |
| 11048 | case LED_MODE_OFF: |
| 11049 | temp |= 0x00ee; |
| 11050 | break; |
| 11051 | case LED_MODE_OPER: |
| 11052 | temp |= 0x0001; |
| 11053 | break; |
| 11054 | case LED_MODE_ON: |
| 11055 | temp |= 0x00ff; |
| 11056 | break; |
| 11057 | default: |
| 11058 | break; |
| 11059 | } |
| 11060 | bnx2x_cl22_write(bp, phy, |
| 11061 | MDIO_REG_GPHY_SHADOW, |
| 11062 | MDIO_REG_GPHY_SHADOW_WR_ENA | temp); |
| 11063 | return; |
| 11064 | } |
| 11065 | |
| 11066 | |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 11067 | static void bnx2x_54618se_link_reset(struct bnx2x_phy *phy, |
| 11068 | struct link_params *params) |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 11069 | { |
| 11070 | struct bnx2x *bp = params->bp; |
| 11071 | u32 cfg_pin; |
| 11072 | u8 port; |
| 11073 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 11074 | /* In case of no EPIO routed to reset the GPHY, put it |
Yaniv Rosner | d2059a0 | 2011-08-02 23:00:00 +0000 | [diff] [blame] | 11075 | * in low power mode. |
| 11076 | */ |
| 11077 | bnx2x_cl22_write(bp, phy, MDIO_PMA_REG_CTRL, 0x800); |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 11078 | /* This works with E3 only, no need to check the chip |
Yaniv Rosner | d2059a0 | 2011-08-02 23:00:00 +0000 | [diff] [blame] | 11079 | * before determining the port. |
| 11080 | */ |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 11081 | port = params->port; |
| 11082 | cfg_pin = (REG_RD(bp, params->shmem_base + |
| 11083 | offsetof(struct shmem_region, |
| 11084 | dev_info.port_hw_config[port].e3_cmn_pin_cfg)) & |
| 11085 | PORT_HW_CFG_E3_PHY_RESET_MASK) >> |
| 11086 | PORT_HW_CFG_E3_PHY_RESET_SHIFT; |
| 11087 | |
| 11088 | /* Drive pin low to put GPHY in reset. */ |
| 11089 | bnx2x_set_cfg_pin(bp, cfg_pin, 0); |
| 11090 | } |
| 11091 | |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 11092 | static u8 bnx2x_54618se_read_status(struct bnx2x_phy *phy, |
| 11093 | struct link_params *params, |
| 11094 | struct link_vars *vars) |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 11095 | { |
| 11096 | struct bnx2x *bp = params->bp; |
| 11097 | u16 val; |
| 11098 | u8 link_up = 0; |
| 11099 | u16 legacy_status, legacy_speed; |
| 11100 | |
| 11101 | /* Get speed operation status */ |
| 11102 | bnx2x_cl22_read(bp, phy, |
Yuval Mintz | a351d49 | 2012-06-20 19:05:21 +0000 | [diff] [blame] | 11103 | MDIO_REG_GPHY_AUX_STATUS, |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 11104 | &legacy_status); |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 11105 | DP(NETIF_MSG_LINK, "54618SE read_status: 0x%x\n", legacy_status); |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 11106 | |
| 11107 | /* Read status to clear the PHY interrupt. */ |
| 11108 | bnx2x_cl22_read(bp, phy, |
| 11109 | MDIO_REG_INTR_STATUS, |
| 11110 | &val); |
| 11111 | |
| 11112 | link_up = ((legacy_status & (1<<2)) == (1<<2)); |
| 11113 | |
| 11114 | if (link_up) { |
| 11115 | legacy_speed = (legacy_status & (7<<8)); |
| 11116 | if (legacy_speed == (7<<8)) { |
| 11117 | vars->line_speed = SPEED_1000; |
| 11118 | vars->duplex = DUPLEX_FULL; |
| 11119 | } else if (legacy_speed == (6<<8)) { |
| 11120 | vars->line_speed = SPEED_1000; |
| 11121 | vars->duplex = DUPLEX_HALF; |
| 11122 | } else if (legacy_speed == (5<<8)) { |
| 11123 | vars->line_speed = SPEED_100; |
| 11124 | vars->duplex = DUPLEX_FULL; |
| 11125 | } |
| 11126 | /* Omitting 100Base-T4 for now */ |
| 11127 | else if (legacy_speed == (3<<8)) { |
| 11128 | vars->line_speed = SPEED_100; |
| 11129 | vars->duplex = DUPLEX_HALF; |
| 11130 | } else if (legacy_speed == (2<<8)) { |
| 11131 | vars->line_speed = SPEED_10; |
| 11132 | vars->duplex = DUPLEX_FULL; |
| 11133 | } else if (legacy_speed == (1<<8)) { |
| 11134 | vars->line_speed = SPEED_10; |
| 11135 | vars->duplex = DUPLEX_HALF; |
| 11136 | } else /* Should not happen */ |
| 11137 | vars->line_speed = 0; |
| 11138 | |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 11139 | DP(NETIF_MSG_LINK, |
| 11140 | "Link is up in %dMbps, is_duplex_full= %d\n", |
| 11141 | vars->line_speed, |
| 11142 | (vars->duplex == DUPLEX_FULL)); |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 11143 | |
| 11144 | /* Check legacy speed AN resolution */ |
| 11145 | bnx2x_cl22_read(bp, phy, |
| 11146 | 0x01, |
| 11147 | &val); |
| 11148 | if (val & (1<<5)) |
| 11149 | vars->link_status |= |
| 11150 | LINK_STATUS_AUTO_NEGOTIATE_COMPLETE; |
| 11151 | bnx2x_cl22_read(bp, phy, |
| 11152 | 0x06, |
| 11153 | &val); |
| 11154 | if ((val & (1<<0)) == 0) |
| 11155 | vars->link_status |= |
| 11156 | LINK_STATUS_PARALLEL_DETECTION_USED; |
| 11157 | |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 11158 | DP(NETIF_MSG_LINK, "BCM54618SE: link speed is %d\n", |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 11159 | vars->line_speed); |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 11160 | |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 11161 | bnx2x_ext_phy_resolve_fc(phy, params, vars); |
Mintz Yuval | 9e7e839 | 2012-02-15 02:10:24 +0000 | [diff] [blame] | 11162 | |
| 11163 | if (vars->link_status & LINK_STATUS_AUTO_NEGOTIATE_COMPLETE) { |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 11164 | /* Report LP advertised speeds */ |
Mintz Yuval | 9e7e839 | 2012-02-15 02:10:24 +0000 | [diff] [blame] | 11165 | bnx2x_cl22_read(bp, phy, 0x5, &val); |
| 11166 | |
| 11167 | if (val & (1<<5)) |
| 11168 | vars->link_status |= |
| 11169 | LINK_STATUS_LINK_PARTNER_10THD_CAPABLE; |
| 11170 | if (val & (1<<6)) |
| 11171 | vars->link_status |= |
| 11172 | LINK_STATUS_LINK_PARTNER_10TFD_CAPABLE; |
| 11173 | if (val & (1<<7)) |
| 11174 | vars->link_status |= |
| 11175 | LINK_STATUS_LINK_PARTNER_100TXHD_CAPABLE; |
| 11176 | if (val & (1<<8)) |
| 11177 | vars->link_status |= |
| 11178 | LINK_STATUS_LINK_PARTNER_100TXFD_CAPABLE; |
| 11179 | if (val & (1<<9)) |
| 11180 | vars->link_status |= |
| 11181 | LINK_STATUS_LINK_PARTNER_100T4_CAPABLE; |
| 11182 | |
| 11183 | bnx2x_cl22_read(bp, phy, 0xa, &val); |
| 11184 | if (val & (1<<10)) |
| 11185 | vars->link_status |= |
| 11186 | LINK_STATUS_LINK_PARTNER_1000THD_CAPABLE; |
| 11187 | if (val & (1<<11)) |
| 11188 | vars->link_status |= |
| 11189 | LINK_STATUS_LINK_PARTNER_1000TFD_CAPABLE; |
Yuval Mintz | 26964bb | 2012-09-10 05:51:08 +0000 | [diff] [blame] | 11190 | |
| 11191 | if ((phy->flags & FLAGS_EEE) && |
| 11192 | bnx2x_eee_has_cap(params)) |
| 11193 | bnx2x_eee_an_resolve(phy, params, vars); |
Mintz Yuval | 9e7e839 | 2012-02-15 02:10:24 +0000 | [diff] [blame] | 11194 | } |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 11195 | } |
| 11196 | return link_up; |
| 11197 | } |
| 11198 | |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 11199 | static void bnx2x_54618se_config_loopback(struct bnx2x_phy *phy, |
| 11200 | struct link_params *params) |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 11201 | { |
| 11202 | struct bnx2x *bp = params->bp; |
| 11203 | u16 val; |
| 11204 | u32 umac_base = params->port ? GRCBASE_UMAC1 : GRCBASE_UMAC0; |
| 11205 | |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 11206 | DP(NETIF_MSG_LINK, "2PMA/PMD ext_phy_loopback: 54618se\n"); |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 11207 | |
| 11208 | /* Enable master/slave manual mmode and set to master */ |
| 11209 | /* mii write 9 [bits set 11 12] */ |
| 11210 | bnx2x_cl22_write(bp, phy, 0x09, 3<<11); |
| 11211 | |
| 11212 | /* forced 1G and disable autoneg */ |
| 11213 | /* set val [mii read 0] */ |
| 11214 | /* set val [expr $val & [bits clear 6 12 13]] */ |
| 11215 | /* set val [expr $val | [bits set 6 8]] */ |
| 11216 | /* mii write 0 $val */ |
| 11217 | bnx2x_cl22_read(bp, phy, 0x00, &val); |
| 11218 | val &= ~((1<<6) | (1<<12) | (1<<13)); |
| 11219 | val |= (1<<6) | (1<<8); |
| 11220 | bnx2x_cl22_write(bp, phy, 0x00, val); |
| 11221 | |
| 11222 | /* Set external loopback and Tx using 6dB coding */ |
| 11223 | /* mii write 0x18 7 */ |
| 11224 | /* set val [mii read 0x18] */ |
| 11225 | /* mii write 0x18 [expr $val | [bits set 10 15]] */ |
| 11226 | bnx2x_cl22_write(bp, phy, 0x18, 7); |
| 11227 | bnx2x_cl22_read(bp, phy, 0x18, &val); |
| 11228 | bnx2x_cl22_write(bp, phy, 0x18, val | (1<<10) | (1<<15)); |
| 11229 | |
| 11230 | /* This register opens the gate for the UMAC despite its name */ |
| 11231 | REG_WR(bp, NIG_REG_EGRESS_EMAC0_PORT + params->port*4, 1); |
| 11232 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 11233 | /* Maximum Frame Length (RW). Defines a 14-Bit maximum frame |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 11234 | * length used by the MAC receive logic to check frames. |
| 11235 | */ |
| 11236 | REG_WR(bp, umac_base + UMAC_REG_MAXFR, 0x2710); |
| 11237 | } |
| 11238 | |
| 11239 | /******************************************************************/ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11240 | /* SFX7101 PHY SECTION */ |
| 11241 | /******************************************************************/ |
| 11242 | static void bnx2x_7101_config_loopback(struct bnx2x_phy *phy, |
| 11243 | struct link_params *params) |
| 11244 | { |
| 11245 | struct bnx2x *bp = params->bp; |
| 11246 | /* SFX7101_XGXS_TEST1 */ |
| 11247 | bnx2x_cl45_write(bp, phy, |
| 11248 | MDIO_XS_DEVAD, MDIO_XS_SFX7101_XGXS_TEST1, 0x100); |
| 11249 | } |
| 11250 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 11251 | static int bnx2x_7101_config_init(struct bnx2x_phy *phy, |
| 11252 | struct link_params *params, |
| 11253 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11254 | { |
| 11255 | u16 fw_ver1, fw_ver2, val; |
| 11256 | struct bnx2x *bp = params->bp; |
| 11257 | DP(NETIF_MSG_LINK, "Setting the SFX7101 LASI indication\n"); |
| 11258 | |
| 11259 | /* Restore normal power mode*/ |
| 11260 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11261 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, params->port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11262 | /* HW reset */ |
| 11263 | bnx2x_ext_phy_hw_reset(bp, params->port); |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 11264 | bnx2x_wait_reset_complete(bp, phy, params); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11265 | |
| 11266 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 11267 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_CTRL, 0x1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11268 | DP(NETIF_MSG_LINK, "Setting the SFX7101 LED to blink on traffic\n"); |
| 11269 | bnx2x_cl45_write(bp, phy, |
| 11270 | MDIO_PMA_DEVAD, MDIO_PMA_REG_7107_LED_CNTL, (1<<3)); |
| 11271 | |
| 11272 | bnx2x_ext_phy_set_pause(params, phy, vars); |
| 11273 | /* Restart autoneg */ |
| 11274 | bnx2x_cl45_read(bp, phy, |
| 11275 | MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, &val); |
| 11276 | val |= 0x200; |
| 11277 | bnx2x_cl45_write(bp, phy, |
| 11278 | MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, val); |
| 11279 | |
| 11280 | /* Save spirom version */ |
| 11281 | bnx2x_cl45_read(bp, phy, |
| 11282 | MDIO_PMA_DEVAD, MDIO_PMA_REG_7101_VER1, &fw_ver1); |
| 11283 | |
| 11284 | bnx2x_cl45_read(bp, phy, |
| 11285 | MDIO_PMA_DEVAD, MDIO_PMA_REG_7101_VER2, &fw_ver2); |
| 11286 | bnx2x_save_spirom_version(bp, params->port, |
| 11287 | (u32)(fw_ver1<<16 | fw_ver2), phy->ver_addr); |
| 11288 | return 0; |
| 11289 | } |
| 11290 | |
| 11291 | static u8 bnx2x_7101_read_status(struct bnx2x_phy *phy, |
| 11292 | struct link_params *params, |
| 11293 | struct link_vars *vars) |
| 11294 | { |
| 11295 | struct bnx2x *bp = params->bp; |
| 11296 | u8 link_up; |
| 11297 | u16 val1, val2; |
| 11298 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 11299 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_STAT, &val2); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11300 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 11301 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_STAT, &val1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11302 | DP(NETIF_MSG_LINK, "10G-base-T LASI status 0x%x->0x%x\n", |
| 11303 | val2, val1); |
| 11304 | bnx2x_cl45_read(bp, phy, |
| 11305 | MDIO_PMA_DEVAD, MDIO_PMA_REG_STATUS, &val2); |
| 11306 | bnx2x_cl45_read(bp, phy, |
| 11307 | MDIO_PMA_DEVAD, MDIO_PMA_REG_STATUS, &val1); |
| 11308 | DP(NETIF_MSG_LINK, "10G-base-T PMA status 0x%x->0x%x\n", |
| 11309 | val2, val1); |
| 11310 | link_up = ((val1 & 4) == 4); |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 11311 | /* If link is up print the AN outcome of the SFX7101 PHY */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11312 | if (link_up) { |
| 11313 | bnx2x_cl45_read(bp, phy, |
| 11314 | MDIO_AN_DEVAD, MDIO_AN_REG_MASTER_STATUS, |
| 11315 | &val2); |
| 11316 | vars->line_speed = SPEED_10000; |
Yaniv Rosner | 791f18c | 2011-01-18 04:33:42 +0000 | [diff] [blame] | 11317 | vars->duplex = DUPLEX_FULL; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11318 | DP(NETIF_MSG_LINK, "SFX7101 AN status 0x%x->Master=%x\n", |
| 11319 | val2, (val2 & (1<<14))); |
| 11320 | bnx2x_ext_phy_10G_an_resolve(bp, phy, vars); |
| 11321 | bnx2x_ext_phy_resolve_fc(phy, params, vars); |
Mintz Yuval | 9e7e839 | 2012-02-15 02:10:24 +0000 | [diff] [blame] | 11322 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 11323 | /* Read LP advertised speeds */ |
Mintz Yuval | 9e7e839 | 2012-02-15 02:10:24 +0000 | [diff] [blame] | 11324 | if (val2 & (1<<11)) |
| 11325 | vars->link_status |= |
| 11326 | LINK_STATUS_LINK_PARTNER_10GXFD_CAPABLE; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11327 | } |
| 11328 | return link_up; |
| 11329 | } |
| 11330 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 11331 | static int bnx2x_7101_format_ver(u32 spirom_ver, u8 *str, u16 *len) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11332 | { |
| 11333 | if (*len < 5) |
| 11334 | return -EINVAL; |
| 11335 | str[0] = (spirom_ver & 0xFF); |
| 11336 | str[1] = (spirom_ver & 0xFF00) >> 8; |
| 11337 | str[2] = (spirom_ver & 0xFF0000) >> 16; |
| 11338 | str[3] = (spirom_ver & 0xFF000000) >> 24; |
| 11339 | str[4] = '\0'; |
| 11340 | *len -= 5; |
| 11341 | return 0; |
| 11342 | } |
| 11343 | |
| 11344 | void bnx2x_sfx7101_sp_sw_reset(struct bnx2x *bp, struct bnx2x_phy *phy) |
| 11345 | { |
| 11346 | u16 val, cnt; |
| 11347 | |
| 11348 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11349 | MDIO_PMA_DEVAD, |
| 11350 | MDIO_PMA_REG_7101_RESET, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11351 | |
| 11352 | for (cnt = 0; cnt < 10; cnt++) { |
| 11353 | msleep(50); |
| 11354 | /* Writes a self-clearing reset */ |
| 11355 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11356 | MDIO_PMA_DEVAD, |
| 11357 | MDIO_PMA_REG_7101_RESET, |
| 11358 | (val | (1<<15))); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11359 | /* Wait for clear */ |
| 11360 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11361 | MDIO_PMA_DEVAD, |
| 11362 | MDIO_PMA_REG_7101_RESET, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11363 | |
| 11364 | if ((val & (1<<15)) == 0) |
| 11365 | break; |
| 11366 | } |
| 11367 | } |
| 11368 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11369 | static void bnx2x_7101_hw_reset(struct bnx2x_phy *phy, |
| 11370 | struct link_params *params) { |
| 11371 | /* Low power mode is controlled by GPIO 2 */ |
| 11372 | bnx2x_set_gpio(params->bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11373 | MISC_REGISTERS_GPIO_OUTPUT_LOW, params->port); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11374 | /* The PHY reset is controlled by GPIO 1 */ |
| 11375 | bnx2x_set_gpio(params->bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11376 | MISC_REGISTERS_GPIO_OUTPUT_LOW, params->port); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11377 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11378 | |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 11379 | static void bnx2x_7101_set_link_led(struct bnx2x_phy *phy, |
| 11380 | struct link_params *params, u8 mode) |
| 11381 | { |
| 11382 | u16 val = 0; |
| 11383 | struct bnx2x *bp = params->bp; |
| 11384 | switch (mode) { |
| 11385 | case LED_MODE_FRONT_PANEL_OFF: |
| 11386 | case LED_MODE_OFF: |
| 11387 | val = 2; |
| 11388 | break; |
| 11389 | case LED_MODE_ON: |
| 11390 | val = 1; |
| 11391 | break; |
| 11392 | case LED_MODE_OPER: |
| 11393 | val = 0; |
| 11394 | break; |
| 11395 | } |
| 11396 | bnx2x_cl45_write(bp, phy, |
| 11397 | MDIO_PMA_DEVAD, |
| 11398 | MDIO_PMA_REG_7107_LINK_LED_CNTL, |
| 11399 | val); |
| 11400 | } |
| 11401 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11402 | /******************************************************************/ |
| 11403 | /* STATIC PHY DECLARATION */ |
| 11404 | /******************************************************************/ |
| 11405 | |
| 11406 | static struct bnx2x_phy phy_null = { |
| 11407 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_NOT_CONN, |
| 11408 | .addr = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11409 | .def_md_devad = 0, |
Yaniv Rosner | 9045f6b4 | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 11410 | .flags = FLAGS_INIT_XGXS_FIRST, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11411 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11412 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11413 | .mdio_ctrl = 0, |
| 11414 | .supported = 0, |
| 11415 | .media_type = ETH_PHY_NOT_PRESENT, |
| 11416 | .ver_addr = 0, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11417 | .req_flow_ctrl = 0, |
| 11418 | .req_line_speed = 0, |
| 11419 | .speed_cap_mask = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11420 | .req_duplex = 0, |
| 11421 | .rsrv = 0, |
| 11422 | .config_init = (config_init_t)NULL, |
| 11423 | .read_status = (read_status_t)NULL, |
| 11424 | .link_reset = (link_reset_t)NULL, |
| 11425 | .config_loopback = (config_loopback_t)NULL, |
| 11426 | .format_fw_ver = (format_fw_ver_t)NULL, |
| 11427 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11428 | .set_link_led = (set_link_led_t)NULL, |
| 11429 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11430 | }; |
| 11431 | |
| 11432 | static struct bnx2x_phy phy_serdes = { |
| 11433 | .type = PORT_HW_CFG_SERDES_EXT_PHY_TYPE_DIRECT, |
| 11434 | .addr = 0xff, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11435 | .def_md_devad = 0, |
Yaniv Rosner | 9045f6b4 | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 11436 | .flags = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11437 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11438 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11439 | .mdio_ctrl = 0, |
| 11440 | .supported = (SUPPORTED_10baseT_Half | |
| 11441 | SUPPORTED_10baseT_Full | |
| 11442 | SUPPORTED_100baseT_Half | |
| 11443 | SUPPORTED_100baseT_Full | |
| 11444 | SUPPORTED_1000baseT_Full | |
| 11445 | SUPPORTED_2500baseX_Full | |
| 11446 | SUPPORTED_TP | |
| 11447 | SUPPORTED_Autoneg | |
| 11448 | SUPPORTED_Pause | |
| 11449 | SUPPORTED_Asym_Pause), |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 11450 | .media_type = ETH_PHY_BASE_T, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11451 | .ver_addr = 0, |
| 11452 | .req_flow_ctrl = 0, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11453 | .req_line_speed = 0, |
| 11454 | .speed_cap_mask = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11455 | .req_duplex = 0, |
| 11456 | .rsrv = 0, |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 11457 | .config_init = (config_init_t)bnx2x_xgxs_config_init, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11458 | .read_status = (read_status_t)bnx2x_link_settings_status, |
| 11459 | .link_reset = (link_reset_t)bnx2x_int_link_reset, |
| 11460 | .config_loopback = (config_loopback_t)NULL, |
| 11461 | .format_fw_ver = (format_fw_ver_t)NULL, |
| 11462 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11463 | .set_link_led = (set_link_led_t)NULL, |
| 11464 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11465 | }; |
| 11466 | |
| 11467 | static struct bnx2x_phy phy_xgxs = { |
| 11468 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT, |
| 11469 | .addr = 0xff, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11470 | .def_md_devad = 0, |
Yaniv Rosner | 9045f6b4 | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 11471 | .flags = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11472 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11473 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11474 | .mdio_ctrl = 0, |
| 11475 | .supported = (SUPPORTED_10baseT_Half | |
| 11476 | SUPPORTED_10baseT_Full | |
| 11477 | SUPPORTED_100baseT_Half | |
| 11478 | SUPPORTED_100baseT_Full | |
| 11479 | SUPPORTED_1000baseT_Full | |
| 11480 | SUPPORTED_2500baseX_Full | |
| 11481 | SUPPORTED_10000baseT_Full | |
| 11482 | SUPPORTED_FIBRE | |
| 11483 | SUPPORTED_Autoneg | |
| 11484 | SUPPORTED_Pause | |
| 11485 | SUPPORTED_Asym_Pause), |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 11486 | .media_type = ETH_PHY_CX4, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11487 | .ver_addr = 0, |
| 11488 | .req_flow_ctrl = 0, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11489 | .req_line_speed = 0, |
| 11490 | .speed_cap_mask = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11491 | .req_duplex = 0, |
| 11492 | .rsrv = 0, |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 11493 | .config_init = (config_init_t)bnx2x_xgxs_config_init, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11494 | .read_status = (read_status_t)bnx2x_link_settings_status, |
| 11495 | .link_reset = (link_reset_t)bnx2x_int_link_reset, |
| 11496 | .config_loopback = (config_loopback_t)bnx2x_set_xgxs_loopback, |
| 11497 | .format_fw_ver = (format_fw_ver_t)NULL, |
| 11498 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11499 | .set_link_led = (set_link_led_t)NULL, |
| 11500 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11501 | }; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 11502 | static struct bnx2x_phy phy_warpcore = { |
| 11503 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT, |
| 11504 | .addr = 0xff, |
| 11505 | .def_md_devad = 0, |
Yaniv Rosner | 55098c5 | 2012-04-03 18:41:27 +0000 | [diff] [blame] | 11506 | .flags = (FLAGS_HW_LOCK_REQUIRED | |
| 11507 | FLAGS_TX_ERROR_CHECK), |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 11508 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11509 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11510 | .mdio_ctrl = 0, |
| 11511 | .supported = (SUPPORTED_10baseT_Half | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 11512 | SUPPORTED_10baseT_Full | |
| 11513 | SUPPORTED_100baseT_Half | |
| 11514 | SUPPORTED_100baseT_Full | |
| 11515 | SUPPORTED_1000baseT_Full | |
| 11516 | SUPPORTED_10000baseT_Full | |
| 11517 | SUPPORTED_20000baseKR2_Full | |
| 11518 | SUPPORTED_20000baseMLD2_Full | |
| 11519 | SUPPORTED_FIBRE | |
| 11520 | SUPPORTED_Autoneg | |
| 11521 | SUPPORTED_Pause | |
| 11522 | SUPPORTED_Asym_Pause), |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 11523 | .media_type = ETH_PHY_UNSPECIFIED, |
| 11524 | .ver_addr = 0, |
| 11525 | .req_flow_ctrl = 0, |
| 11526 | .req_line_speed = 0, |
| 11527 | .speed_cap_mask = 0, |
| 11528 | /* req_duplex = */0, |
| 11529 | /* rsrv = */0, |
| 11530 | .config_init = (config_init_t)bnx2x_warpcore_config_init, |
| 11531 | .read_status = (read_status_t)bnx2x_warpcore_read_status, |
| 11532 | .link_reset = (link_reset_t)bnx2x_warpcore_link_reset, |
| 11533 | .config_loopback = (config_loopback_t)bnx2x_set_warpcore_loopback, |
| 11534 | .format_fw_ver = (format_fw_ver_t)NULL, |
Yaniv Rosner | 985848f | 2011-07-05 01:06:48 +0000 | [diff] [blame] | 11535 | .hw_reset = (hw_reset_t)bnx2x_warpcore_hw_reset, |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 11536 | .set_link_led = (set_link_led_t)NULL, |
| 11537 | .phy_specific_func = (phy_specific_func_t)NULL |
| 11538 | }; |
| 11539 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11540 | |
| 11541 | static struct bnx2x_phy phy_7101 = { |
| 11542 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_SFX7101, |
| 11543 | .addr = 0xff, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11544 | .def_md_devad = 0, |
Yaniv Rosner | 9045f6b4 | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 11545 | .flags = FLAGS_FAN_FAILURE_DET_REQ, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11546 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11547 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11548 | .mdio_ctrl = 0, |
| 11549 | .supported = (SUPPORTED_10000baseT_Full | |
| 11550 | SUPPORTED_TP | |
| 11551 | SUPPORTED_Autoneg | |
| 11552 | SUPPORTED_Pause | |
| 11553 | SUPPORTED_Asym_Pause), |
| 11554 | .media_type = ETH_PHY_BASE_T, |
| 11555 | .ver_addr = 0, |
| 11556 | .req_flow_ctrl = 0, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11557 | .req_line_speed = 0, |
| 11558 | .speed_cap_mask = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11559 | .req_duplex = 0, |
| 11560 | .rsrv = 0, |
| 11561 | .config_init = (config_init_t)bnx2x_7101_config_init, |
| 11562 | .read_status = (read_status_t)bnx2x_7101_read_status, |
| 11563 | .link_reset = (link_reset_t)bnx2x_common_ext_link_reset, |
| 11564 | .config_loopback = (config_loopback_t)bnx2x_7101_config_loopback, |
| 11565 | .format_fw_ver = (format_fw_ver_t)bnx2x_7101_format_ver, |
| 11566 | .hw_reset = (hw_reset_t)bnx2x_7101_hw_reset, |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 11567 | .set_link_led = (set_link_led_t)bnx2x_7101_set_link_led, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11568 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11569 | }; |
| 11570 | static struct bnx2x_phy phy_8073 = { |
| 11571 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073, |
| 11572 | .addr = 0xff, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11573 | .def_md_devad = 0, |
Yaniv Rosner | 9045f6b4 | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 11574 | .flags = FLAGS_HW_LOCK_REQUIRED, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11575 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11576 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11577 | .mdio_ctrl = 0, |
| 11578 | .supported = (SUPPORTED_10000baseT_Full | |
| 11579 | SUPPORTED_2500baseX_Full | |
| 11580 | SUPPORTED_1000baseT_Full | |
| 11581 | SUPPORTED_FIBRE | |
| 11582 | SUPPORTED_Autoneg | |
| 11583 | SUPPORTED_Pause | |
| 11584 | SUPPORTED_Asym_Pause), |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 11585 | .media_type = ETH_PHY_KR, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11586 | .ver_addr = 0, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11587 | .req_flow_ctrl = 0, |
| 11588 | .req_line_speed = 0, |
| 11589 | .speed_cap_mask = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11590 | .req_duplex = 0, |
| 11591 | .rsrv = 0, |
Yaniv Rosner | 62b29a5 | 2010-09-07 11:40:58 +0000 | [diff] [blame] | 11592 | .config_init = (config_init_t)bnx2x_8073_config_init, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11593 | .read_status = (read_status_t)bnx2x_8073_read_status, |
| 11594 | .link_reset = (link_reset_t)bnx2x_8073_link_reset, |
| 11595 | .config_loopback = (config_loopback_t)NULL, |
| 11596 | .format_fw_ver = (format_fw_ver_t)bnx2x_format_ver, |
| 11597 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11598 | .set_link_led = (set_link_led_t)NULL, |
Yaniv Rosner | 5c107fd | 2012-09-13 02:56:19 +0000 | [diff] [blame] | 11599 | .phy_specific_func = (phy_specific_func_t)bnx2x_8073_specific_func |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11600 | }; |
| 11601 | static struct bnx2x_phy phy_8705 = { |
| 11602 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8705, |
| 11603 | .addr = 0xff, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11604 | .def_md_devad = 0, |
Yaniv Rosner | 9045f6b4 | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 11605 | .flags = FLAGS_INIT_XGXS_FIRST, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11606 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11607 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11608 | .mdio_ctrl = 0, |
| 11609 | .supported = (SUPPORTED_10000baseT_Full | |
| 11610 | SUPPORTED_FIBRE | |
| 11611 | SUPPORTED_Pause | |
| 11612 | SUPPORTED_Asym_Pause), |
| 11613 | .media_type = ETH_PHY_XFP_FIBER, |
| 11614 | .ver_addr = 0, |
| 11615 | .req_flow_ctrl = 0, |
| 11616 | .req_line_speed = 0, |
| 11617 | .speed_cap_mask = 0, |
| 11618 | .req_duplex = 0, |
| 11619 | .rsrv = 0, |
| 11620 | .config_init = (config_init_t)bnx2x_8705_config_init, |
| 11621 | .read_status = (read_status_t)bnx2x_8705_read_status, |
| 11622 | .link_reset = (link_reset_t)bnx2x_common_ext_link_reset, |
| 11623 | .config_loopback = (config_loopback_t)NULL, |
| 11624 | .format_fw_ver = (format_fw_ver_t)bnx2x_null_format_ver, |
| 11625 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11626 | .set_link_led = (set_link_led_t)NULL, |
| 11627 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11628 | }; |
| 11629 | static struct bnx2x_phy phy_8706 = { |
| 11630 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8706, |
| 11631 | .addr = 0xff, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11632 | .def_md_devad = 0, |
David S. Miller | 8decf86 | 2011-09-22 03:23:13 -0400 | [diff] [blame] | 11633 | .flags = FLAGS_INIT_XGXS_FIRST, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11634 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11635 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11636 | .mdio_ctrl = 0, |
| 11637 | .supported = (SUPPORTED_10000baseT_Full | |
| 11638 | SUPPORTED_1000baseT_Full | |
| 11639 | SUPPORTED_FIBRE | |
| 11640 | SUPPORTED_Pause | |
| 11641 | SUPPORTED_Asym_Pause), |
Yuval Mintz | dbef807 | 2012-06-20 19:05:22 +0000 | [diff] [blame] | 11642 | .media_type = ETH_PHY_SFPP_10G_FIBER, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11643 | .ver_addr = 0, |
| 11644 | .req_flow_ctrl = 0, |
| 11645 | .req_line_speed = 0, |
| 11646 | .speed_cap_mask = 0, |
| 11647 | .req_duplex = 0, |
| 11648 | .rsrv = 0, |
| 11649 | .config_init = (config_init_t)bnx2x_8706_config_init, |
| 11650 | .read_status = (read_status_t)bnx2x_8706_read_status, |
| 11651 | .link_reset = (link_reset_t)bnx2x_common_ext_link_reset, |
| 11652 | .config_loopback = (config_loopback_t)NULL, |
| 11653 | .format_fw_ver = (format_fw_ver_t)bnx2x_format_ver, |
| 11654 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11655 | .set_link_led = (set_link_led_t)NULL, |
| 11656 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11657 | }; |
| 11658 | |
| 11659 | static struct bnx2x_phy phy_8726 = { |
| 11660 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726, |
| 11661 | .addr = 0xff, |
Yaniv Rosner | 9045f6b4 | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 11662 | .def_md_devad = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11663 | .flags = (FLAGS_HW_LOCK_REQUIRED | |
Yaniv Rosner | 55098c5 | 2012-04-03 18:41:27 +0000 | [diff] [blame] | 11664 | FLAGS_INIT_XGXS_FIRST | |
| 11665 | FLAGS_TX_ERROR_CHECK), |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11666 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11667 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11668 | .mdio_ctrl = 0, |
| 11669 | .supported = (SUPPORTED_10000baseT_Full | |
| 11670 | SUPPORTED_1000baseT_Full | |
| 11671 | SUPPORTED_Autoneg | |
| 11672 | SUPPORTED_FIBRE | |
| 11673 | SUPPORTED_Pause | |
| 11674 | SUPPORTED_Asym_Pause), |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 11675 | .media_type = ETH_PHY_NOT_PRESENT, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11676 | .ver_addr = 0, |
| 11677 | .req_flow_ctrl = 0, |
| 11678 | .req_line_speed = 0, |
| 11679 | .speed_cap_mask = 0, |
| 11680 | .req_duplex = 0, |
| 11681 | .rsrv = 0, |
| 11682 | .config_init = (config_init_t)bnx2x_8726_config_init, |
| 11683 | .read_status = (read_status_t)bnx2x_8726_read_status, |
| 11684 | .link_reset = (link_reset_t)bnx2x_8726_link_reset, |
| 11685 | .config_loopback = (config_loopback_t)bnx2x_8726_config_loopback, |
| 11686 | .format_fw_ver = (format_fw_ver_t)bnx2x_format_ver, |
| 11687 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11688 | .set_link_led = (set_link_led_t)NULL, |
| 11689 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11690 | }; |
| 11691 | |
| 11692 | static struct bnx2x_phy phy_8727 = { |
| 11693 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727, |
| 11694 | .addr = 0xff, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11695 | .def_md_devad = 0, |
Yaniv Rosner | 55098c5 | 2012-04-03 18:41:27 +0000 | [diff] [blame] | 11696 | .flags = (FLAGS_FAN_FAILURE_DET_REQ | |
| 11697 | FLAGS_TX_ERROR_CHECK), |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11698 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11699 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11700 | .mdio_ctrl = 0, |
| 11701 | .supported = (SUPPORTED_10000baseT_Full | |
| 11702 | SUPPORTED_1000baseT_Full | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11703 | SUPPORTED_FIBRE | |
| 11704 | SUPPORTED_Pause | |
| 11705 | SUPPORTED_Asym_Pause), |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 11706 | .media_type = ETH_PHY_NOT_PRESENT, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11707 | .ver_addr = 0, |
| 11708 | .req_flow_ctrl = 0, |
| 11709 | .req_line_speed = 0, |
| 11710 | .speed_cap_mask = 0, |
| 11711 | .req_duplex = 0, |
| 11712 | .rsrv = 0, |
| 11713 | .config_init = (config_init_t)bnx2x_8727_config_init, |
| 11714 | .read_status = (read_status_t)bnx2x_8727_read_status, |
| 11715 | .link_reset = (link_reset_t)bnx2x_8727_link_reset, |
| 11716 | .config_loopback = (config_loopback_t)NULL, |
| 11717 | .format_fw_ver = (format_fw_ver_t)bnx2x_format_ver, |
| 11718 | .hw_reset = (hw_reset_t)bnx2x_8727_hw_reset, |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 11719 | .set_link_led = (set_link_led_t)bnx2x_8727_set_link_led, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11720 | .phy_specific_func = (phy_specific_func_t)bnx2x_8727_specific_func |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11721 | }; |
| 11722 | static struct bnx2x_phy phy_8481 = { |
| 11723 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8481, |
| 11724 | .addr = 0xff, |
Yaniv Rosner | 9045f6b4 | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 11725 | .def_md_devad = 0, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11726 | .flags = FLAGS_FAN_FAILURE_DET_REQ | |
| 11727 | FLAGS_REARM_LATCH_SIGNAL, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11728 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11729 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11730 | .mdio_ctrl = 0, |
| 11731 | .supported = (SUPPORTED_10baseT_Half | |
| 11732 | SUPPORTED_10baseT_Full | |
| 11733 | SUPPORTED_100baseT_Half | |
| 11734 | SUPPORTED_100baseT_Full | |
| 11735 | SUPPORTED_1000baseT_Full | |
| 11736 | SUPPORTED_10000baseT_Full | |
| 11737 | SUPPORTED_TP | |
| 11738 | SUPPORTED_Autoneg | |
| 11739 | SUPPORTED_Pause | |
| 11740 | SUPPORTED_Asym_Pause), |
| 11741 | .media_type = ETH_PHY_BASE_T, |
| 11742 | .ver_addr = 0, |
| 11743 | .req_flow_ctrl = 0, |
| 11744 | .req_line_speed = 0, |
| 11745 | .speed_cap_mask = 0, |
| 11746 | .req_duplex = 0, |
| 11747 | .rsrv = 0, |
| 11748 | .config_init = (config_init_t)bnx2x_8481_config_init, |
| 11749 | .read_status = (read_status_t)bnx2x_848xx_read_status, |
| 11750 | .link_reset = (link_reset_t)bnx2x_8481_link_reset, |
| 11751 | .config_loopback = (config_loopback_t)NULL, |
| 11752 | .format_fw_ver = (format_fw_ver_t)bnx2x_848xx_format_ver, |
| 11753 | .hw_reset = (hw_reset_t)bnx2x_8481_hw_reset, |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 11754 | .set_link_led = (set_link_led_t)bnx2x_848xx_set_link_led, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11755 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11756 | }; |
| 11757 | |
| 11758 | static struct bnx2x_phy phy_84823 = { |
| 11759 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84823, |
| 11760 | .addr = 0xff, |
Yaniv Rosner | 9045f6b4 | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 11761 | .def_md_devad = 0, |
Yaniv Rosner | 55098c5 | 2012-04-03 18:41:27 +0000 | [diff] [blame] | 11762 | .flags = (FLAGS_FAN_FAILURE_DET_REQ | |
| 11763 | FLAGS_REARM_LATCH_SIGNAL | |
| 11764 | FLAGS_TX_ERROR_CHECK), |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11765 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11766 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11767 | .mdio_ctrl = 0, |
| 11768 | .supported = (SUPPORTED_10baseT_Half | |
| 11769 | SUPPORTED_10baseT_Full | |
| 11770 | SUPPORTED_100baseT_Half | |
| 11771 | SUPPORTED_100baseT_Full | |
| 11772 | SUPPORTED_1000baseT_Full | |
| 11773 | SUPPORTED_10000baseT_Full | |
| 11774 | SUPPORTED_TP | |
| 11775 | SUPPORTED_Autoneg | |
| 11776 | SUPPORTED_Pause | |
| 11777 | SUPPORTED_Asym_Pause), |
| 11778 | .media_type = ETH_PHY_BASE_T, |
| 11779 | .ver_addr = 0, |
| 11780 | .req_flow_ctrl = 0, |
| 11781 | .req_line_speed = 0, |
| 11782 | .speed_cap_mask = 0, |
| 11783 | .req_duplex = 0, |
| 11784 | .rsrv = 0, |
| 11785 | .config_init = (config_init_t)bnx2x_848x3_config_init, |
| 11786 | .read_status = (read_status_t)bnx2x_848xx_read_status, |
| 11787 | .link_reset = (link_reset_t)bnx2x_848x3_link_reset, |
| 11788 | .config_loopback = (config_loopback_t)NULL, |
| 11789 | .format_fw_ver = (format_fw_ver_t)bnx2x_848xx_format_ver, |
| 11790 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 11791 | .set_link_led = (set_link_led_t)bnx2x_848xx_set_link_led, |
Yaniv Rosner | 5c107fd | 2012-09-13 02:56:19 +0000 | [diff] [blame] | 11792 | .phy_specific_func = (phy_specific_func_t)bnx2x_848xx_specific_func |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11793 | }; |
| 11794 | |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 11795 | static struct bnx2x_phy phy_84833 = { |
| 11796 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833, |
| 11797 | .addr = 0xff, |
Yaniv Rosner | 9045f6b4 | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 11798 | .def_md_devad = 0, |
Yaniv Rosner | 55098c5 | 2012-04-03 18:41:27 +0000 | [diff] [blame] | 11799 | .flags = (FLAGS_FAN_FAILURE_DET_REQ | |
| 11800 | FLAGS_REARM_LATCH_SIGNAL | |
Yuval Mintz | f6b6eb6 | 2012-09-10 05:51:07 +0000 | [diff] [blame] | 11801 | FLAGS_TX_ERROR_CHECK), |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 11802 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11803 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11804 | .mdio_ctrl = 0, |
Yaniv Rosner | 0520e63 | 2011-07-05 01:06:59 +0000 | [diff] [blame] | 11805 | .supported = (SUPPORTED_100baseT_Half | |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 11806 | SUPPORTED_100baseT_Full | |
| 11807 | SUPPORTED_1000baseT_Full | |
| 11808 | SUPPORTED_10000baseT_Full | |
| 11809 | SUPPORTED_TP | |
| 11810 | SUPPORTED_Autoneg | |
| 11811 | SUPPORTED_Pause | |
| 11812 | SUPPORTED_Asym_Pause), |
| 11813 | .media_type = ETH_PHY_BASE_T, |
| 11814 | .ver_addr = 0, |
| 11815 | .req_flow_ctrl = 0, |
| 11816 | .req_line_speed = 0, |
| 11817 | .speed_cap_mask = 0, |
| 11818 | .req_duplex = 0, |
| 11819 | .rsrv = 0, |
| 11820 | .config_init = (config_init_t)bnx2x_848x3_config_init, |
| 11821 | .read_status = (read_status_t)bnx2x_848xx_read_status, |
| 11822 | .link_reset = (link_reset_t)bnx2x_848x3_link_reset, |
| 11823 | .config_loopback = (config_loopback_t)NULL, |
| 11824 | .format_fw_ver = (format_fw_ver_t)bnx2x_848xx_format_ver, |
Yaniv Rosner | 985848f | 2011-07-05 01:06:48 +0000 | [diff] [blame] | 11825 | .hw_reset = (hw_reset_t)bnx2x_84833_hw_reset_phy, |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 11826 | .set_link_led = (set_link_led_t)bnx2x_848xx_set_link_led, |
Yaniv Rosner | 5c107fd | 2012-09-13 02:56:19 +0000 | [diff] [blame] | 11827 | .phy_specific_func = (phy_specific_func_t)bnx2x_848xx_specific_func |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 11828 | }; |
| 11829 | |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 11830 | static struct bnx2x_phy phy_54618se = { |
| 11831 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54618SE, |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 11832 | .addr = 0xff, |
| 11833 | .def_md_devad = 0, |
| 11834 | .flags = FLAGS_INIT_XGXS_FIRST, |
| 11835 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11836 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11837 | .mdio_ctrl = 0, |
| 11838 | .supported = (SUPPORTED_10baseT_Half | |
| 11839 | SUPPORTED_10baseT_Full | |
| 11840 | SUPPORTED_100baseT_Half | |
| 11841 | SUPPORTED_100baseT_Full | |
| 11842 | SUPPORTED_1000baseT_Full | |
| 11843 | SUPPORTED_TP | |
| 11844 | SUPPORTED_Autoneg | |
| 11845 | SUPPORTED_Pause | |
| 11846 | SUPPORTED_Asym_Pause), |
| 11847 | .media_type = ETH_PHY_BASE_T, |
| 11848 | .ver_addr = 0, |
| 11849 | .req_flow_ctrl = 0, |
| 11850 | .req_line_speed = 0, |
| 11851 | .speed_cap_mask = 0, |
| 11852 | /* req_duplex = */0, |
| 11853 | /* rsrv = */0, |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 11854 | .config_init = (config_init_t)bnx2x_54618se_config_init, |
| 11855 | .read_status = (read_status_t)bnx2x_54618se_read_status, |
| 11856 | .link_reset = (link_reset_t)bnx2x_54618se_link_reset, |
| 11857 | .config_loopback = (config_loopback_t)bnx2x_54618se_config_loopback, |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 11858 | .format_fw_ver = (format_fw_ver_t)NULL, |
| 11859 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | 1d125bd | 2011-11-23 03:54:08 +0000 | [diff] [blame] | 11860 | .set_link_led = (set_link_led_t)bnx2x_5461x_set_link_led, |
Yaniv Rosner | 5c107fd | 2012-09-13 02:56:19 +0000 | [diff] [blame] | 11861 | .phy_specific_func = (phy_specific_func_t)bnx2x_54618se_specific_func |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 11862 | }; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11863 | /*****************************************************************/ |
| 11864 | /* */ |
| 11865 | /* Populate the phy according. Main function: bnx2x_populate_phy */ |
| 11866 | /* */ |
| 11867 | /*****************************************************************/ |
| 11868 | |
| 11869 | static void bnx2x_populate_preemphasis(struct bnx2x *bp, u32 shmem_base, |
| 11870 | struct bnx2x_phy *phy, u8 port, |
| 11871 | u8 phy_index) |
| 11872 | { |
| 11873 | /* Get the 4 lanes xgxs config rx and tx */ |
| 11874 | u32 rx = 0, tx = 0, i; |
| 11875 | for (i = 0; i < 2; i++) { |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 11876 | /* INT_PHY and EXT_PHY1 share the same value location in |
| 11877 | * the shmem. When num_phys is greater than 1, than this value |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11878 | * applies only to EXT_PHY1 |
| 11879 | */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11880 | if (phy_index == INT_PHY || phy_index == EXT_PHY1) { |
| 11881 | rx = REG_RD(bp, shmem_base + |
| 11882 | offsetof(struct shmem_region, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11883 | dev_info.port_hw_config[port].xgxs_config_rx[i<<1])); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11884 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11885 | tx = REG_RD(bp, shmem_base + |
| 11886 | offsetof(struct shmem_region, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11887 | dev_info.port_hw_config[port].xgxs_config_tx[i<<1])); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11888 | } else { |
| 11889 | rx = REG_RD(bp, shmem_base + |
| 11890 | offsetof(struct shmem_region, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11891 | dev_info.port_hw_config[port].xgxs_config2_rx[i<<1])); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11892 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11893 | tx = REG_RD(bp, shmem_base + |
| 11894 | offsetof(struct shmem_region, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11895 | dev_info.port_hw_config[port].xgxs_config2_rx[i<<1])); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11896 | } |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11897 | |
| 11898 | phy->rx_preemphasis[i << 1] = ((rx>>16) & 0xffff); |
| 11899 | phy->rx_preemphasis[(i << 1) + 1] = (rx & 0xffff); |
| 11900 | |
| 11901 | phy->tx_preemphasis[i << 1] = ((tx>>16) & 0xffff); |
| 11902 | phy->tx_preemphasis[(i << 1) + 1] = (tx & 0xffff); |
| 11903 | } |
| 11904 | } |
| 11905 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 11906 | static u32 bnx2x_get_ext_phy_config(struct bnx2x *bp, u32 shmem_base, |
| 11907 | u8 phy_index, u8 port) |
| 11908 | { |
| 11909 | u32 ext_phy_config = 0; |
| 11910 | switch (phy_index) { |
| 11911 | case EXT_PHY1: |
| 11912 | ext_phy_config = REG_RD(bp, shmem_base + |
| 11913 | offsetof(struct shmem_region, |
| 11914 | dev_info.port_hw_config[port].external_phy_config)); |
| 11915 | break; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11916 | case EXT_PHY2: |
| 11917 | ext_phy_config = REG_RD(bp, shmem_base + |
| 11918 | offsetof(struct shmem_region, |
| 11919 | dev_info.port_hw_config[port].external_phy_config2)); |
| 11920 | break; |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 11921 | default: |
| 11922 | DP(NETIF_MSG_LINK, "Invalid phy_index %d\n", phy_index); |
| 11923 | return -EINVAL; |
| 11924 | } |
| 11925 | |
| 11926 | return ext_phy_config; |
| 11927 | } |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 11928 | static int bnx2x_populate_int_phy(struct bnx2x *bp, u32 shmem_base, u8 port, |
| 11929 | struct bnx2x_phy *phy) |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11930 | { |
| 11931 | u32 phy_addr; |
| 11932 | u32 chip_id; |
| 11933 | u32 switch_cfg = (REG_RD(bp, shmem_base + |
| 11934 | offsetof(struct shmem_region, |
| 11935 | dev_info.port_feature_config[port].link_config)) & |
| 11936 | PORT_FEATURE_CONNECTED_SWITCH_MASK); |
Yaniv Rosner | ec15b89 | 2011-11-28 00:49:49 +0000 | [diff] [blame] | 11937 | chip_id = (REG_RD(bp, MISC_REG_CHIP_NUM) << 16) | |
| 11938 | ((REG_RD(bp, MISC_REG_CHIP_REV) & 0xf) << 12); |
| 11939 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 11940 | DP(NETIF_MSG_LINK, ":chip_id = 0x%x\n", chip_id); |
| 11941 | if (USES_WARPCORE(bp)) { |
| 11942 | u32 serdes_net_if; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11943 | phy_addr = REG_RD(bp, |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 11944 | MISC_REG_WC0_CTRL_PHY_ADDR); |
| 11945 | *phy = phy_warpcore; |
| 11946 | if (REG_RD(bp, MISC_REG_PORT4MODE_EN_OVWR) == 0x3) |
| 11947 | phy->flags |= FLAGS_4_PORT_MODE; |
| 11948 | else |
| 11949 | phy->flags &= ~FLAGS_4_PORT_MODE; |
| 11950 | /* Check Dual mode */ |
| 11951 | serdes_net_if = (REG_RD(bp, shmem_base + |
| 11952 | offsetof(struct shmem_region, dev_info. |
| 11953 | port_hw_config[port].default_cfg)) & |
| 11954 | PORT_HW_CFG_NET_SERDES_IF_MASK); |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 11955 | /* Set the appropriate supported and flags indications per |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 11956 | * interface type of the chip |
| 11957 | */ |
| 11958 | switch (serdes_net_if) { |
| 11959 | case PORT_HW_CFG_NET_SERDES_IF_SGMII: |
| 11960 | phy->supported &= (SUPPORTED_10baseT_Half | |
| 11961 | SUPPORTED_10baseT_Full | |
| 11962 | SUPPORTED_100baseT_Half | |
| 11963 | SUPPORTED_100baseT_Full | |
| 11964 | SUPPORTED_1000baseT_Full | |
| 11965 | SUPPORTED_FIBRE | |
| 11966 | SUPPORTED_Autoneg | |
| 11967 | SUPPORTED_Pause | |
| 11968 | SUPPORTED_Asym_Pause); |
| 11969 | phy->media_type = ETH_PHY_BASE_T; |
| 11970 | break; |
| 11971 | case PORT_HW_CFG_NET_SERDES_IF_XFI: |
| 11972 | phy->media_type = ETH_PHY_XFP_FIBER; |
| 11973 | break; |
| 11974 | case PORT_HW_CFG_NET_SERDES_IF_SFI: |
| 11975 | phy->supported &= (SUPPORTED_1000baseT_Full | |
| 11976 | SUPPORTED_10000baseT_Full | |
| 11977 | SUPPORTED_FIBRE | |
| 11978 | SUPPORTED_Pause | |
| 11979 | SUPPORTED_Asym_Pause); |
Yuval Mintz | dbef807 | 2012-06-20 19:05:22 +0000 | [diff] [blame] | 11980 | phy->media_type = ETH_PHY_SFPP_10G_FIBER; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 11981 | break; |
| 11982 | case PORT_HW_CFG_NET_SERDES_IF_KR: |
| 11983 | phy->media_type = ETH_PHY_KR; |
| 11984 | phy->supported &= (SUPPORTED_1000baseT_Full | |
| 11985 | SUPPORTED_10000baseT_Full | |
| 11986 | SUPPORTED_FIBRE | |
| 11987 | SUPPORTED_Autoneg | |
| 11988 | SUPPORTED_Pause | |
| 11989 | SUPPORTED_Asym_Pause); |
| 11990 | break; |
| 11991 | case PORT_HW_CFG_NET_SERDES_IF_DXGXS: |
| 11992 | phy->media_type = ETH_PHY_KR; |
| 11993 | phy->flags |= FLAGS_WC_DUAL_MODE; |
| 11994 | phy->supported &= (SUPPORTED_20000baseMLD2_Full | |
| 11995 | SUPPORTED_FIBRE | |
| 11996 | SUPPORTED_Pause | |
| 11997 | SUPPORTED_Asym_Pause); |
| 11998 | break; |
| 11999 | case PORT_HW_CFG_NET_SERDES_IF_KR2: |
| 12000 | phy->media_type = ETH_PHY_KR; |
| 12001 | phy->flags |= FLAGS_WC_DUAL_MODE; |
| 12002 | phy->supported &= (SUPPORTED_20000baseKR2_Full | |
| 12003 | SUPPORTED_FIBRE | |
| 12004 | SUPPORTED_Pause | |
| 12005 | SUPPORTED_Asym_Pause); |
| 12006 | break; |
| 12007 | default: |
| 12008 | DP(NETIF_MSG_LINK, "Unknown WC interface type 0x%x\n", |
| 12009 | serdes_net_if); |
| 12010 | break; |
| 12011 | } |
| 12012 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 12013 | /* Enable MDC/MDIO work-around for E3 A0 since free running MDC |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 12014 | * was not set as expected. For B0, ECO will be enabled so there |
| 12015 | * won't be an issue there |
| 12016 | */ |
| 12017 | if (CHIP_REV(bp) == CHIP_REV_Ax) |
| 12018 | phy->flags |= FLAGS_MDC_MDIO_WA; |
Yaniv Rosner | 157fa28 | 2011-08-02 22:59:32 +0000 | [diff] [blame] | 12019 | else |
| 12020 | phy->flags |= FLAGS_MDC_MDIO_WA_B0; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 12021 | } else { |
| 12022 | switch (switch_cfg) { |
| 12023 | case SWITCH_CFG_1G: |
| 12024 | phy_addr = REG_RD(bp, |
| 12025 | NIG_REG_SERDES0_CTRL_PHY_ADDR + |
| 12026 | port * 0x10); |
| 12027 | *phy = phy_serdes; |
| 12028 | break; |
| 12029 | case SWITCH_CFG_10G: |
| 12030 | phy_addr = REG_RD(bp, |
| 12031 | NIG_REG_XGXS0_CTRL_PHY_ADDR + |
| 12032 | port * 0x18); |
| 12033 | *phy = phy_xgxs; |
| 12034 | break; |
| 12035 | default: |
| 12036 | DP(NETIF_MSG_LINK, "Invalid switch_cfg\n"); |
| 12037 | return -EINVAL; |
| 12038 | } |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 12039 | } |
| 12040 | phy->addr = (u8)phy_addr; |
| 12041 | phy->mdio_ctrl = bnx2x_get_emac_base(bp, |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 12042 | SHARED_HW_CFG_MDC_MDIO_ACCESS1_BOTH, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 12043 | port); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12044 | if (CHIP_IS_E2(bp)) |
| 12045 | phy->def_md_devad = E2_DEFAULT_PHY_DEV_ADDR; |
| 12046 | else |
| 12047 | phy->def_md_devad = DEFAULT_PHY_DEV_ADDR; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 12048 | |
| 12049 | DP(NETIF_MSG_LINK, "Internal phy port=%d, addr=0x%x, mdio_ctl=0x%x\n", |
| 12050 | port, phy->addr, phy->mdio_ctrl); |
| 12051 | |
| 12052 | bnx2x_populate_preemphasis(bp, shmem_base, phy, port, INT_PHY); |
| 12053 | return 0; |
| 12054 | } |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 12055 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 12056 | static int bnx2x_populate_ext_phy(struct bnx2x *bp, |
| 12057 | u8 phy_index, |
| 12058 | u32 shmem_base, |
| 12059 | u32 shmem2_base, |
| 12060 | u8 port, |
| 12061 | struct bnx2x_phy *phy) |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 12062 | { |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 12063 | u32 ext_phy_config, phy_type, config2; |
| 12064 | u32 mdc_mdio_access = SHARED_HW_CFG_MDC_MDIO_ACCESS1_BOTH; |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 12065 | ext_phy_config = bnx2x_get_ext_phy_config(bp, shmem_base, |
| 12066 | phy_index, port); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 12067 | phy_type = XGXS_EXT_PHY_TYPE(ext_phy_config); |
| 12068 | /* Select the phy type */ |
| 12069 | switch (phy_type) { |
| 12070 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073: |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 12071 | mdc_mdio_access = SHARED_HW_CFG_MDC_MDIO_ACCESS1_SWAPPED; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 12072 | *phy = phy_8073; |
| 12073 | break; |
| 12074 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8705: |
| 12075 | *phy = phy_8705; |
| 12076 | break; |
| 12077 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8706: |
| 12078 | *phy = phy_8706; |
| 12079 | break; |
| 12080 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726: |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 12081 | mdc_mdio_access = SHARED_HW_CFG_MDC_MDIO_ACCESS1_EMAC1; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 12082 | *phy = phy_8726; |
| 12083 | break; |
| 12084 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727_NOC: |
| 12085 | /* BCM8727_NOC => BCM8727 no over current */ |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 12086 | mdc_mdio_access = SHARED_HW_CFG_MDC_MDIO_ACCESS1_EMAC1; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 12087 | *phy = phy_8727; |
| 12088 | phy->flags |= FLAGS_NOC; |
| 12089 | break; |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 12090 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8722: |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 12091 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727: |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 12092 | mdc_mdio_access = SHARED_HW_CFG_MDC_MDIO_ACCESS1_EMAC1; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 12093 | *phy = phy_8727; |
| 12094 | break; |
| 12095 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8481: |
| 12096 | *phy = phy_8481; |
| 12097 | break; |
| 12098 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84823: |
| 12099 | *phy = phy_84823; |
| 12100 | break; |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 12101 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833: |
| 12102 | *phy = phy_84833; |
| 12103 | break; |
Yaniv Rosner | 3756a89 | 2011-08-23 06:33:24 +0000 | [diff] [blame] | 12104 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54616: |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 12105 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54618SE: |
| 12106 | *phy = phy_54618se; |
Yuval Mintz | 26964bb | 2012-09-10 05:51:08 +0000 | [diff] [blame] | 12107 | if (phy_type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54618SE) |
| 12108 | phy->flags |= FLAGS_EEE; |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 12109 | break; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 12110 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_SFX7101: |
| 12111 | *phy = phy_7101; |
| 12112 | break; |
| 12113 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_FAILURE: |
| 12114 | *phy = phy_null; |
| 12115 | return -EINVAL; |
| 12116 | default: |
| 12117 | *phy = phy_null; |
Yaniv Rosner | 6db5193 | 2011-11-28 00:49:50 +0000 | [diff] [blame] | 12118 | /* In case external PHY wasn't found */ |
| 12119 | if ((phy_type != PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT) && |
| 12120 | (phy_type != PORT_HW_CFG_XGXS_EXT_PHY_TYPE_NOT_CONN)) |
| 12121 | return -EINVAL; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 12122 | return 0; |
| 12123 | } |
| 12124 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 12125 | phy->addr = XGXS_EXT_PHY_ADDR(ext_phy_config); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 12126 | bnx2x_populate_preemphasis(bp, shmem_base, phy, port, phy_index); |
Yaniv Rosner | 62b29a5 | 2010-09-07 11:40:58 +0000 | [diff] [blame] | 12127 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 12128 | /* The shmem address of the phy version is located on different |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 12129 | * structures. In case this structure is too old, do not set |
| 12130 | * the address |
| 12131 | */ |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 12132 | config2 = REG_RD(bp, shmem_base + offsetof(struct shmem_region, |
| 12133 | dev_info.shared_hw_config.config2)); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12134 | if (phy_index == EXT_PHY1) { |
| 12135 | phy->ver_addr = shmem_base + offsetof(struct shmem_region, |
| 12136 | port_mb[port].ext_phy_fw_version); |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 12137 | |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 12138 | /* Check specific mdc mdio settings */ |
| 12139 | if (config2 & SHARED_HW_CFG_MDC_MDIO_ACCESS1_MASK) |
| 12140 | mdc_mdio_access = config2 & |
| 12141 | SHARED_HW_CFG_MDC_MDIO_ACCESS1_MASK; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12142 | } else { |
| 12143 | u32 size = REG_RD(bp, shmem2_base); |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 12144 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12145 | if (size > |
| 12146 | offsetof(struct shmem2_region, ext_phy_fw_version2)) { |
| 12147 | phy->ver_addr = shmem2_base + |
| 12148 | offsetof(struct shmem2_region, |
| 12149 | ext_phy_fw_version2[port]); |
| 12150 | } |
| 12151 | /* Check specific mdc mdio settings */ |
| 12152 | if (config2 & SHARED_HW_CFG_MDC_MDIO_ACCESS2_MASK) |
| 12153 | mdc_mdio_access = (config2 & |
| 12154 | SHARED_HW_CFG_MDC_MDIO_ACCESS2_MASK) >> |
| 12155 | (SHARED_HW_CFG_MDC_MDIO_ACCESS2_SHIFT - |
| 12156 | SHARED_HW_CFG_MDC_MDIO_ACCESS1_SHIFT); |
| 12157 | } |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 12158 | phy->mdio_ctrl = bnx2x_get_emac_base(bp, mdc_mdio_access, port); |
| 12159 | |
Yaniv Rosner | 7531832 | 2012-01-17 02:33:27 +0000 | [diff] [blame] | 12160 | if ((phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833) && |
| 12161 | (phy->ver_addr)) { |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 12162 | /* Remove 100Mb link supported for BCM84833 when phy fw |
Yaniv Rosner | 7531832 | 2012-01-17 02:33:27 +0000 | [diff] [blame] | 12163 | * version lower than or equal to 1.39 |
| 12164 | */ |
| 12165 | u32 raw_ver = REG_RD(bp, phy->ver_addr); |
| 12166 | if (((raw_ver & 0x7F) <= 39) && |
| 12167 | (((raw_ver & 0xF80) >> 7) <= 1)) |
| 12168 | phy->supported &= ~(SUPPORTED_100baseT_Half | |
| 12169 | SUPPORTED_100baseT_Full); |
| 12170 | } |
| 12171 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 12172 | /* In case mdc/mdio_access of the external phy is different than the |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 12173 | * mdc/mdio access of the XGXS, a HW lock must be taken in each access |
| 12174 | * to prevent one port interfere with another port's CL45 operations. |
| 12175 | */ |
| 12176 | if (mdc_mdio_access != SHARED_HW_CFG_MDC_MDIO_ACCESS1_BOTH) |
| 12177 | phy->flags |= FLAGS_HW_LOCK_REQUIRED; |
| 12178 | DP(NETIF_MSG_LINK, "phy_type 0x%x port %d found in index %d\n", |
| 12179 | phy_type, port, phy_index); |
| 12180 | DP(NETIF_MSG_LINK, " addr=0x%x, mdio_ctl=0x%x\n", |
| 12181 | phy->addr, phy->mdio_ctrl); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 12182 | return 0; |
| 12183 | } |
| 12184 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 12185 | static int bnx2x_populate_phy(struct bnx2x *bp, u8 phy_index, u32 shmem_base, |
| 12186 | u32 shmem2_base, u8 port, struct bnx2x_phy *phy) |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 12187 | { |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 12188 | int status = 0; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 12189 | phy->type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_NOT_CONN; |
| 12190 | if (phy_index == INT_PHY) |
| 12191 | return bnx2x_populate_int_phy(bp, shmem_base, port, phy); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12192 | status = bnx2x_populate_ext_phy(bp, phy_index, shmem_base, shmem2_base, |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 12193 | port, phy); |
| 12194 | return status; |
| 12195 | } |
| 12196 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 12197 | static void bnx2x_phy_def_cfg(struct link_params *params, |
| 12198 | struct bnx2x_phy *phy, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12199 | u8 phy_index) |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 12200 | { |
| 12201 | struct bnx2x *bp = params->bp; |
| 12202 | u32 link_config; |
| 12203 | /* Populate the default phy configuration for MF mode */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12204 | if (phy_index == EXT_PHY2) { |
| 12205 | link_config = REG_RD(bp, params->shmem_base + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 12206 | offsetof(struct shmem_region, dev_info. |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12207 | port_feature_config[params->port].link_config2)); |
| 12208 | phy->speed_cap_mask = REG_RD(bp, params->shmem_base + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 12209 | offsetof(struct shmem_region, |
| 12210 | dev_info. |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12211 | port_hw_config[params->port].speed_capability_mask2)); |
| 12212 | } else { |
| 12213 | link_config = REG_RD(bp, params->shmem_base + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 12214 | offsetof(struct shmem_region, dev_info. |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12215 | port_feature_config[params->port].link_config)); |
| 12216 | phy->speed_cap_mask = REG_RD(bp, params->shmem_base + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 12217 | offsetof(struct shmem_region, |
| 12218 | dev_info. |
| 12219 | port_hw_config[params->port].speed_capability_mask)); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12220 | } |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 12221 | DP(NETIF_MSG_LINK, |
| 12222 | "Default config phy idx %x cfg 0x%x speed_cap_mask 0x%x\n", |
| 12223 | phy_index, link_config, phy->speed_cap_mask); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 12224 | |
| 12225 | phy->req_duplex = DUPLEX_FULL; |
| 12226 | switch (link_config & PORT_FEATURE_LINK_SPEED_MASK) { |
| 12227 | case PORT_FEATURE_LINK_SPEED_10M_HALF: |
| 12228 | phy->req_duplex = DUPLEX_HALF; |
| 12229 | case PORT_FEATURE_LINK_SPEED_10M_FULL: |
| 12230 | phy->req_line_speed = SPEED_10; |
| 12231 | break; |
| 12232 | case PORT_FEATURE_LINK_SPEED_100M_HALF: |
| 12233 | phy->req_duplex = DUPLEX_HALF; |
| 12234 | case PORT_FEATURE_LINK_SPEED_100M_FULL: |
| 12235 | phy->req_line_speed = SPEED_100; |
| 12236 | break; |
| 12237 | case PORT_FEATURE_LINK_SPEED_1G: |
| 12238 | phy->req_line_speed = SPEED_1000; |
| 12239 | break; |
| 12240 | case PORT_FEATURE_LINK_SPEED_2_5G: |
| 12241 | phy->req_line_speed = SPEED_2500; |
| 12242 | break; |
| 12243 | case PORT_FEATURE_LINK_SPEED_10G_CX4: |
| 12244 | phy->req_line_speed = SPEED_10000; |
| 12245 | break; |
| 12246 | default: |
| 12247 | phy->req_line_speed = SPEED_AUTO_NEG; |
| 12248 | break; |
| 12249 | } |
| 12250 | |
| 12251 | switch (link_config & PORT_FEATURE_FLOW_CONTROL_MASK) { |
| 12252 | case PORT_FEATURE_FLOW_CONTROL_AUTO: |
| 12253 | phy->req_flow_ctrl = BNX2X_FLOW_CTRL_AUTO; |
| 12254 | break; |
| 12255 | case PORT_FEATURE_FLOW_CONTROL_TX: |
| 12256 | phy->req_flow_ctrl = BNX2X_FLOW_CTRL_TX; |
| 12257 | break; |
| 12258 | case PORT_FEATURE_FLOW_CONTROL_RX: |
| 12259 | phy->req_flow_ctrl = BNX2X_FLOW_CTRL_RX; |
| 12260 | break; |
| 12261 | case PORT_FEATURE_FLOW_CONTROL_BOTH: |
| 12262 | phy->req_flow_ctrl = BNX2X_FLOW_CTRL_BOTH; |
| 12263 | break; |
| 12264 | default: |
| 12265 | phy->req_flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 12266 | break; |
| 12267 | } |
| 12268 | } |
| 12269 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12270 | u32 bnx2x_phy_selection(struct link_params *params) |
| 12271 | { |
| 12272 | u32 phy_config_swapped, prio_cfg; |
| 12273 | u32 return_cfg = PORT_HW_CFG_PHY_SELECTION_HARDWARE_DEFAULT; |
| 12274 | |
| 12275 | phy_config_swapped = params->multi_phy_config & |
| 12276 | PORT_HW_CFG_PHY_SWAPPED_ENABLED; |
| 12277 | |
| 12278 | prio_cfg = params->multi_phy_config & |
| 12279 | PORT_HW_CFG_PHY_SELECTION_MASK; |
| 12280 | |
| 12281 | if (phy_config_swapped) { |
| 12282 | switch (prio_cfg) { |
| 12283 | case PORT_HW_CFG_PHY_SELECTION_FIRST_PHY_PRIORITY: |
| 12284 | return_cfg = PORT_HW_CFG_PHY_SELECTION_SECOND_PHY_PRIORITY; |
| 12285 | break; |
| 12286 | case PORT_HW_CFG_PHY_SELECTION_SECOND_PHY_PRIORITY: |
| 12287 | return_cfg = PORT_HW_CFG_PHY_SELECTION_FIRST_PHY_PRIORITY; |
| 12288 | break; |
| 12289 | case PORT_HW_CFG_PHY_SELECTION_SECOND_PHY: |
| 12290 | return_cfg = PORT_HW_CFG_PHY_SELECTION_FIRST_PHY; |
| 12291 | break; |
| 12292 | case PORT_HW_CFG_PHY_SELECTION_FIRST_PHY: |
| 12293 | return_cfg = PORT_HW_CFG_PHY_SELECTION_SECOND_PHY; |
| 12294 | break; |
| 12295 | } |
| 12296 | } else |
| 12297 | return_cfg = prio_cfg; |
| 12298 | |
| 12299 | return return_cfg; |
| 12300 | } |
| 12301 | |
| 12302 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 12303 | int bnx2x_phy_probe(struct link_params *params) |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 12304 | { |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 12305 | u8 phy_index, actual_phy_idx; |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 12306 | u32 phy_config_swapped, sync_offset, media_types; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 12307 | struct bnx2x *bp = params->bp; |
| 12308 | struct bnx2x_phy *phy; |
| 12309 | params->num_phys = 0; |
| 12310 | DP(NETIF_MSG_LINK, "Begin phy probe\n"); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12311 | phy_config_swapped = params->multi_phy_config & |
| 12312 | PORT_HW_CFG_PHY_SWAPPED_ENABLED; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 12313 | |
| 12314 | for (phy_index = INT_PHY; phy_index < MAX_PHYS; |
| 12315 | phy_index++) { |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 12316 | actual_phy_idx = phy_index; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12317 | if (phy_config_swapped) { |
| 12318 | if (phy_index == EXT_PHY1) |
| 12319 | actual_phy_idx = EXT_PHY2; |
| 12320 | else if (phy_index == EXT_PHY2) |
| 12321 | actual_phy_idx = EXT_PHY1; |
| 12322 | } |
| 12323 | DP(NETIF_MSG_LINK, "phy_config_swapped %x, phy_index %x," |
| 12324 | " actual_phy_idx %x\n", phy_config_swapped, |
| 12325 | phy_index, actual_phy_idx); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 12326 | phy = ¶ms->phy[actual_phy_idx]; |
| 12327 | if (bnx2x_populate_phy(bp, phy_index, params->shmem_base, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12328 | params->shmem2_base, params->port, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 12329 | phy) != 0) { |
| 12330 | params->num_phys = 0; |
| 12331 | DP(NETIF_MSG_LINK, "phy probe failed in phy index %d\n", |
| 12332 | phy_index); |
| 12333 | for (phy_index = INT_PHY; |
| 12334 | phy_index < MAX_PHYS; |
| 12335 | phy_index++) |
| 12336 | *phy = phy_null; |
| 12337 | return -EINVAL; |
| 12338 | } |
| 12339 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_NOT_CONN) |
| 12340 | break; |
| 12341 | |
Yaniv Rosner | 55098c5 | 2012-04-03 18:41:27 +0000 | [diff] [blame] | 12342 | if (params->feature_config_flags & |
| 12343 | FEATURE_CONFIG_DISABLE_REMOTE_FAULT_DET) |
| 12344 | phy->flags &= ~FLAGS_TX_ERROR_CHECK; |
| 12345 | |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 12346 | sync_offset = params->shmem_base + |
| 12347 | offsetof(struct shmem_region, |
| 12348 | dev_info.port_hw_config[params->port].media_type); |
| 12349 | media_types = REG_RD(bp, sync_offset); |
| 12350 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 12351 | /* Update media type for non-PMF sync only for the first time |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 12352 | * In case the media type changes afterwards, it will be updated |
| 12353 | * using the update_status function |
| 12354 | */ |
| 12355 | if ((media_types & (PORT_HW_CFG_MEDIA_TYPE_PHY0_MASK << |
| 12356 | (PORT_HW_CFG_MEDIA_TYPE_PHY1_SHIFT * |
| 12357 | actual_phy_idx))) == 0) { |
| 12358 | media_types |= ((phy->media_type & |
| 12359 | PORT_HW_CFG_MEDIA_TYPE_PHY0_MASK) << |
| 12360 | (PORT_HW_CFG_MEDIA_TYPE_PHY1_SHIFT * |
| 12361 | actual_phy_idx)); |
| 12362 | } |
| 12363 | REG_WR(bp, sync_offset, media_types); |
| 12364 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12365 | bnx2x_phy_def_cfg(params, phy, phy_index); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 12366 | params->num_phys++; |
| 12367 | } |
| 12368 | |
| 12369 | DP(NETIF_MSG_LINK, "End phy probe. #phys found %x\n", params->num_phys); |
| 12370 | return 0; |
| 12371 | } |
| 12372 | |
Yaniv Rosner | 9045f6b4 | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 12373 | void bnx2x_init_bmac_loopback(struct link_params *params, |
| 12374 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12375 | { |
| 12376 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 9045f6b4 | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 12377 | vars->link_up = 1; |
| 12378 | vars->line_speed = SPEED_10000; |
| 12379 | vars->duplex = DUPLEX_FULL; |
| 12380 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 12381 | vars->mac_type = MAC_TYPE_BMAC; |
| 12382 | |
| 12383 | vars->phy_flags = PHY_XGXS_FLAG; |
| 12384 | |
| 12385 | bnx2x_xgxs_deassert(params); |
| 12386 | |
| 12387 | /* set bmac loopback */ |
Yaniv Rosner | d3a8f13 | 2012-09-13 02:56:20 +0000 | [diff] [blame] | 12388 | bnx2x_bmac_enable(params, vars, 1, 1); |
Yaniv Rosner | 9045f6b4 | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 12389 | |
| 12390 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + params->port*4, 0); |
| 12391 | } |
| 12392 | |
| 12393 | void bnx2x_init_emac_loopback(struct link_params *params, |
| 12394 | struct link_vars *vars) |
| 12395 | { |
| 12396 | struct bnx2x *bp = params->bp; |
| 12397 | vars->link_up = 1; |
| 12398 | vars->line_speed = SPEED_1000; |
| 12399 | vars->duplex = DUPLEX_FULL; |
| 12400 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 12401 | vars->mac_type = MAC_TYPE_EMAC; |
| 12402 | |
| 12403 | vars->phy_flags = PHY_XGXS_FLAG; |
| 12404 | |
| 12405 | bnx2x_xgxs_deassert(params); |
| 12406 | /* set bmac loopback */ |
| 12407 | bnx2x_emac_enable(params, vars, 1); |
| 12408 | bnx2x_emac_program(params, vars); |
| 12409 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + params->port*4, 0); |
| 12410 | } |
| 12411 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 12412 | void bnx2x_init_xmac_loopback(struct link_params *params, |
| 12413 | struct link_vars *vars) |
| 12414 | { |
| 12415 | struct bnx2x *bp = params->bp; |
| 12416 | vars->link_up = 1; |
| 12417 | if (!params->req_line_speed[0]) |
| 12418 | vars->line_speed = SPEED_10000; |
| 12419 | else |
| 12420 | vars->line_speed = params->req_line_speed[0]; |
| 12421 | vars->duplex = DUPLEX_FULL; |
| 12422 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 12423 | vars->mac_type = MAC_TYPE_XMAC; |
| 12424 | vars->phy_flags = PHY_XGXS_FLAG; |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 12425 | /* Set WC to loopback mode since link is required to provide clock |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 12426 | * to the XMAC in 20G mode |
| 12427 | */ |
Yaniv Rosner | afad009 | 2011-08-02 23:00:06 +0000 | [diff] [blame] | 12428 | bnx2x_set_aer_mmd(params, ¶ms->phy[0]); |
| 12429 | bnx2x_warpcore_reset_lane(bp, ¶ms->phy[0], 0); |
| 12430 | params->phy[INT_PHY].config_loopback( |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 12431 | ¶ms->phy[INT_PHY], |
| 12432 | params); |
Yaniv Rosner | afad009 | 2011-08-02 23:00:06 +0000 | [diff] [blame] | 12433 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 12434 | bnx2x_xmac_enable(params, vars, 1); |
| 12435 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + params->port*4, 0); |
| 12436 | } |
| 12437 | |
| 12438 | void bnx2x_init_umac_loopback(struct link_params *params, |
| 12439 | struct link_vars *vars) |
| 12440 | { |
| 12441 | struct bnx2x *bp = params->bp; |
| 12442 | vars->link_up = 1; |
| 12443 | vars->line_speed = SPEED_1000; |
| 12444 | vars->duplex = DUPLEX_FULL; |
| 12445 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 12446 | vars->mac_type = MAC_TYPE_UMAC; |
| 12447 | vars->phy_flags = PHY_XGXS_FLAG; |
| 12448 | bnx2x_umac_enable(params, vars, 1); |
| 12449 | |
| 12450 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + params->port*4, 0); |
| 12451 | } |
| 12452 | |
Yaniv Rosner | 9045f6b4 | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 12453 | void bnx2x_init_xgxs_loopback(struct link_params *params, |
| 12454 | struct link_vars *vars) |
| 12455 | { |
| 12456 | struct bnx2x *bp = params->bp; |
| 12457 | vars->link_up = 1; |
| 12458 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 12459 | vars->duplex = DUPLEX_FULL; |
| 12460 | if (params->req_line_speed[0] == SPEED_1000) |
| 12461 | vars->line_speed = SPEED_1000; |
| 12462 | else |
| 12463 | vars->line_speed = SPEED_10000; |
| 12464 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 12465 | if (!USES_WARPCORE(bp)) |
| 12466 | bnx2x_xgxs_deassert(params); |
Yaniv Rosner | 9045f6b4 | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 12467 | bnx2x_link_initialize(params, vars); |
| 12468 | |
| 12469 | if (params->req_line_speed[0] == SPEED_1000) { |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 12470 | if (USES_WARPCORE(bp)) |
| 12471 | bnx2x_umac_enable(params, vars, 0); |
| 12472 | else { |
| 12473 | bnx2x_emac_program(params, vars); |
| 12474 | bnx2x_emac_enable(params, vars, 0); |
| 12475 | } |
| 12476 | } else { |
| 12477 | if (USES_WARPCORE(bp)) |
| 12478 | bnx2x_xmac_enable(params, vars, 0); |
| 12479 | else |
Yaniv Rosner | d3a8f13 | 2012-09-13 02:56:20 +0000 | [diff] [blame] | 12480 | bnx2x_bmac_enable(params, vars, 0, 1); |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 12481 | } |
Yaniv Rosner | 9045f6b4 | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 12482 | |
| 12483 | if (params->loopback_mode == LOOPBACK_XGXS) { |
| 12484 | /* set 10G XGXS loopback */ |
| 12485 | params->phy[INT_PHY].config_loopback( |
| 12486 | ¶ms->phy[INT_PHY], |
| 12487 | params); |
| 12488 | |
| 12489 | } else { |
| 12490 | /* set external phy loopback */ |
| 12491 | u8 phy_index; |
| 12492 | for (phy_index = EXT_PHY1; |
| 12493 | phy_index < params->num_phys; phy_index++) { |
| 12494 | if (params->phy[phy_index].config_loopback) |
| 12495 | params->phy[phy_index].config_loopback( |
| 12496 | ¶ms->phy[phy_index], |
| 12497 | params); |
| 12498 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12499 | } |
Yaniv Rosner | 9045f6b4 | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 12500 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + params->port*4, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12501 | |
Yaniv Rosner | 9045f6b4 | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 12502 | bnx2x_set_led(params, vars, LED_MODE_OPER, vars->line_speed); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12503 | } |
| 12504 | |
Yaniv Rosner | d3a8f13 | 2012-09-13 02:56:20 +0000 | [diff] [blame] | 12505 | static void bnx2x_set_rx_filter(struct link_params *params, u8 en) |
| 12506 | { |
| 12507 | struct bnx2x *bp = params->bp; |
| 12508 | u8 val = en * 0x1F; |
| 12509 | |
| 12510 | /* Open the gate between the NIG to the BRB */ |
| 12511 | if (!CHIP_IS_E1x(bp)) |
| 12512 | val |= en * 0x20; |
| 12513 | REG_WR(bp, NIG_REG_LLH0_BRB1_DRV_MASK + params->port*4, val); |
| 12514 | |
| 12515 | if (!CHIP_IS_E1(bp)) { |
| 12516 | REG_WR(bp, NIG_REG_LLH0_BRB1_DRV_MASK_MF + params->port*4, |
| 12517 | en*0x3); |
| 12518 | } |
| 12519 | |
| 12520 | REG_WR(bp, (params->port ? NIG_REG_LLH1_BRB1_NOT_MCP : |
| 12521 | NIG_REG_LLH0_BRB1_NOT_MCP), en); |
| 12522 | } |
| 12523 | static int bnx2x_avoid_link_flap(struct link_params *params, |
| 12524 | struct link_vars *vars) |
| 12525 | { |
| 12526 | u32 phy_idx; |
| 12527 | u32 dont_clear_stat, lfa_sts; |
| 12528 | struct bnx2x *bp = params->bp; |
| 12529 | |
| 12530 | /* Sync the link parameters */ |
| 12531 | bnx2x_link_status_update(params, vars); |
| 12532 | |
| 12533 | /* |
| 12534 | * The module verification was already done by previous link owner, |
| 12535 | * so this call is meant only to get warning message |
| 12536 | */ |
| 12537 | |
| 12538 | for (phy_idx = INT_PHY; phy_idx < params->num_phys; phy_idx++) { |
| 12539 | struct bnx2x_phy *phy = ¶ms->phy[phy_idx]; |
| 12540 | if (phy->phy_specific_func) { |
| 12541 | DP(NETIF_MSG_LINK, "Calling PHY specific func\n"); |
| 12542 | phy->phy_specific_func(phy, params, PHY_INIT); |
| 12543 | } |
| 12544 | if ((phy->media_type == ETH_PHY_SFPP_10G_FIBER) || |
| 12545 | (phy->media_type == ETH_PHY_SFP_1G_FIBER) || |
| 12546 | (phy->media_type == ETH_PHY_DA_TWINAX)) |
| 12547 | bnx2x_verify_sfp_module(phy, params); |
| 12548 | } |
| 12549 | lfa_sts = REG_RD(bp, params->lfa_base + |
| 12550 | offsetof(struct shmem_lfa, |
| 12551 | lfa_sts)); |
| 12552 | |
| 12553 | dont_clear_stat = lfa_sts & SHMEM_LFA_DONT_CLEAR_STAT; |
| 12554 | |
| 12555 | /* Re-enable the NIG/MAC */ |
| 12556 | if (CHIP_IS_E3(bp)) { |
| 12557 | if (!dont_clear_stat) { |
| 12558 | REG_WR(bp, GRCBASE_MISC + |
| 12559 | MISC_REGISTERS_RESET_REG_2_CLEAR, |
| 12560 | (MISC_REGISTERS_RESET_REG_2_MSTAT0 << |
| 12561 | params->port)); |
| 12562 | REG_WR(bp, GRCBASE_MISC + |
| 12563 | MISC_REGISTERS_RESET_REG_2_SET, |
| 12564 | (MISC_REGISTERS_RESET_REG_2_MSTAT0 << |
| 12565 | params->port)); |
| 12566 | } |
| 12567 | if (vars->line_speed < SPEED_10000) |
| 12568 | bnx2x_umac_enable(params, vars, 0); |
| 12569 | else |
| 12570 | bnx2x_xmac_enable(params, vars, 0); |
| 12571 | } else { |
| 12572 | if (vars->line_speed < SPEED_10000) |
| 12573 | bnx2x_emac_enable(params, vars, 0); |
| 12574 | else |
| 12575 | bnx2x_bmac_enable(params, vars, 0, !dont_clear_stat); |
| 12576 | } |
| 12577 | |
| 12578 | /* Increment LFA count */ |
| 12579 | lfa_sts = ((lfa_sts & ~LINK_FLAP_AVOIDANCE_COUNT_MASK) | |
| 12580 | (((((lfa_sts & LINK_FLAP_AVOIDANCE_COUNT_MASK) >> |
| 12581 | LINK_FLAP_AVOIDANCE_COUNT_OFFSET) + 1) & 0xff) |
| 12582 | << LINK_FLAP_AVOIDANCE_COUNT_OFFSET)); |
| 12583 | /* Clear link flap reason */ |
| 12584 | lfa_sts &= ~LFA_LINK_FLAP_REASON_MASK; |
| 12585 | |
| 12586 | REG_WR(bp, params->lfa_base + |
| 12587 | offsetof(struct shmem_lfa, lfa_sts), lfa_sts); |
| 12588 | |
| 12589 | /* Disable NIG DRAIN */ |
| 12590 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + params->port*4, 0); |
| 12591 | |
| 12592 | /* Enable interrupts */ |
| 12593 | bnx2x_link_int_enable(params); |
| 12594 | return 0; |
| 12595 | } |
| 12596 | |
| 12597 | static void bnx2x_cannot_avoid_link_flap(struct link_params *params, |
| 12598 | struct link_vars *vars, |
| 12599 | int lfa_status) |
| 12600 | { |
| 12601 | u32 lfa_sts, cfg_idx, tmp_val; |
| 12602 | struct bnx2x *bp = params->bp; |
| 12603 | |
| 12604 | bnx2x_link_reset(params, vars, 1); |
| 12605 | |
| 12606 | if (!params->lfa_base) |
| 12607 | return; |
| 12608 | /* Store the new link parameters */ |
| 12609 | REG_WR(bp, params->lfa_base + |
| 12610 | offsetof(struct shmem_lfa, req_duplex), |
| 12611 | params->req_duplex[0] | (params->req_duplex[1] << 16)); |
| 12612 | |
| 12613 | REG_WR(bp, params->lfa_base + |
| 12614 | offsetof(struct shmem_lfa, req_flow_ctrl), |
| 12615 | params->req_flow_ctrl[0] | (params->req_flow_ctrl[1] << 16)); |
| 12616 | |
| 12617 | REG_WR(bp, params->lfa_base + |
| 12618 | offsetof(struct shmem_lfa, req_line_speed), |
| 12619 | params->req_line_speed[0] | (params->req_line_speed[1] << 16)); |
| 12620 | |
| 12621 | for (cfg_idx = 0; cfg_idx < SHMEM_LINK_CONFIG_SIZE; cfg_idx++) { |
| 12622 | REG_WR(bp, params->lfa_base + |
| 12623 | offsetof(struct shmem_lfa, |
| 12624 | speed_cap_mask[cfg_idx]), |
| 12625 | params->speed_cap_mask[cfg_idx]); |
| 12626 | } |
| 12627 | |
| 12628 | tmp_val = REG_RD(bp, params->lfa_base + |
| 12629 | offsetof(struct shmem_lfa, additional_config)); |
| 12630 | tmp_val &= ~REQ_FC_AUTO_ADV_MASK; |
| 12631 | tmp_val |= params->req_fc_auto_adv; |
| 12632 | |
| 12633 | REG_WR(bp, params->lfa_base + |
| 12634 | offsetof(struct shmem_lfa, additional_config), tmp_val); |
| 12635 | |
| 12636 | lfa_sts = REG_RD(bp, params->lfa_base + |
| 12637 | offsetof(struct shmem_lfa, lfa_sts)); |
| 12638 | |
| 12639 | /* Clear the "Don't Clear Statistics" bit, and set reason */ |
| 12640 | lfa_sts &= ~SHMEM_LFA_DONT_CLEAR_STAT; |
| 12641 | |
| 12642 | /* Set link flap reason */ |
| 12643 | lfa_sts &= ~LFA_LINK_FLAP_REASON_MASK; |
| 12644 | lfa_sts |= ((lfa_status & LFA_LINK_FLAP_REASON_MASK) << |
| 12645 | LFA_LINK_FLAP_REASON_OFFSET); |
| 12646 | |
| 12647 | /* Increment link flap counter */ |
| 12648 | lfa_sts = ((lfa_sts & ~LINK_FLAP_COUNT_MASK) | |
| 12649 | (((((lfa_sts & LINK_FLAP_COUNT_MASK) >> |
| 12650 | LINK_FLAP_COUNT_OFFSET) + 1) & 0xff) |
| 12651 | << LINK_FLAP_COUNT_OFFSET)); |
| 12652 | REG_WR(bp, params->lfa_base + |
| 12653 | offsetof(struct shmem_lfa, lfa_sts), lfa_sts); |
| 12654 | /* Proceed with regular link initialization */ |
| 12655 | } |
| 12656 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 12657 | int bnx2x_phy_init(struct link_params *params, struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12658 | { |
Yaniv Rosner | d3a8f13 | 2012-09-13 02:56:20 +0000 | [diff] [blame] | 12659 | int lfa_status; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12660 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12661 | DP(NETIF_MSG_LINK, "Phy Initialization started\n"); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12662 | DP(NETIF_MSG_LINK, "(1) req_speed %d, req_flowctrl %d\n", |
| 12663 | params->req_line_speed[0], params->req_flow_ctrl[0]); |
| 12664 | DP(NETIF_MSG_LINK, "(2) req_speed %d, req_flowctrl %d\n", |
| 12665 | params->req_line_speed[1], params->req_flow_ctrl[1]); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12666 | vars->link_status = 0; |
| 12667 | vars->phy_link_up = 0; |
| 12668 | vars->link_up = 0; |
| 12669 | vars->line_speed = 0; |
| 12670 | vars->duplex = DUPLEX_FULL; |
| 12671 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 12672 | vars->mac_type = MAC_TYPE_NONE; |
| 12673 | vars->phy_flags = 0; |
Yaniv Rosner | d3a8f13 | 2012-09-13 02:56:20 +0000 | [diff] [blame] | 12674 | /* Driver opens NIG-BRB filters */ |
| 12675 | bnx2x_set_rx_filter(params, 1); |
| 12676 | /* Check if link flap can be avoided */ |
| 12677 | lfa_status = bnx2x_check_lfa(params); |
| 12678 | |
| 12679 | if (lfa_status == 0) { |
| 12680 | DP(NETIF_MSG_LINK, "Link Flap Avoidance in progress\n"); |
| 12681 | return bnx2x_avoid_link_flap(params, vars); |
| 12682 | } |
| 12683 | |
| 12684 | DP(NETIF_MSG_LINK, "Cannot avoid link flap lfa_sta=0x%x\n", |
| 12685 | lfa_status); |
| 12686 | bnx2x_cannot_avoid_link_flap(params, vars, lfa_status); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12687 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 12688 | /* Disable attentions */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12689 | bnx2x_bits_dis(bp, NIG_REG_MASK_INTERRUPT_PORT0 + params->port*4, |
| 12690 | (NIG_MASK_XGXS0_LINK_STATUS | |
| 12691 | NIG_MASK_XGXS0_LINK10G | |
| 12692 | NIG_MASK_SERDES0_LINK_STATUS | |
| 12693 | NIG_MASK_MI_INT)); |
| 12694 | |
| 12695 | bnx2x_emac_init(params, vars); |
| 12696 | |
Yaniv Rosner | 27d9129 | 2012-04-04 01:28:54 +0000 | [diff] [blame] | 12697 | if (params->feature_config_flags & FEATURE_CONFIG_PFC_ENABLED) |
| 12698 | vars->link_status |= LINK_STATUS_PFC_ENABLED; |
| 12699 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12700 | if (params->num_phys == 0) { |
| 12701 | DP(NETIF_MSG_LINK, "No phy found for initialization !!\n"); |
| 12702 | return -EINVAL; |
| 12703 | } |
Yaniv Rosner | 9045f6b4 | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 12704 | set_phy_vars(params, vars); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12705 | |
| 12706 | DP(NETIF_MSG_LINK, "Num of phys on board: %d\n", params->num_phys); |
Yaniv Rosner | 9045f6b4 | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 12707 | switch (params->loopback_mode) { |
| 12708 | case LOOPBACK_BMAC: |
| 12709 | bnx2x_init_bmac_loopback(params, vars); |
| 12710 | break; |
| 12711 | case LOOPBACK_EMAC: |
| 12712 | bnx2x_init_emac_loopback(params, vars); |
| 12713 | break; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 12714 | case LOOPBACK_XMAC: |
| 12715 | bnx2x_init_xmac_loopback(params, vars); |
| 12716 | break; |
| 12717 | case LOOPBACK_UMAC: |
| 12718 | bnx2x_init_umac_loopback(params, vars); |
| 12719 | break; |
Yaniv Rosner | 9045f6b4 | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 12720 | case LOOPBACK_XGXS: |
| 12721 | case LOOPBACK_EXT_PHY: |
| 12722 | bnx2x_init_xgxs_loopback(params, vars); |
| 12723 | break; |
| 12724 | default: |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 12725 | if (!CHIP_IS_E3(bp)) { |
| 12726 | if (params->switch_cfg == SWITCH_CFG_10G) |
| 12727 | bnx2x_xgxs_deassert(params); |
| 12728 | else |
| 12729 | bnx2x_serdes_deassert(bp, params->port); |
| 12730 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12731 | bnx2x_link_initialize(params, vars); |
| 12732 | msleep(30); |
| 12733 | bnx2x_link_int_enable(params); |
Yaniv Rosner | 9045f6b4 | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 12734 | break; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12735 | } |
Yaniv Rosner | 55098c5 | 2012-04-03 18:41:27 +0000 | [diff] [blame] | 12736 | bnx2x_update_mng(params, vars->link_status); |
Yuval Mintz | c8c60d8 | 2012-06-06 17:13:07 +0000 | [diff] [blame] | 12737 | |
| 12738 | bnx2x_update_mng_eee(params, vars->eee_status); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12739 | return 0; |
| 12740 | } |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 12741 | |
| 12742 | int bnx2x_link_reset(struct link_params *params, struct link_vars *vars, |
| 12743 | u8 reset_ext_phy) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12744 | { |
| 12745 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | cf1d972 | 2010-11-01 05:32:34 +0000 | [diff] [blame] | 12746 | u8 phy_index, port = params->port, clear_latch_ind = 0; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12747 | DP(NETIF_MSG_LINK, "Resetting the link of port %d\n", port); |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 12748 | /* Disable attentions */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12749 | vars->link_status = 0; |
| 12750 | bnx2x_update_mng(params, vars->link_status); |
Yuval Mintz | c8c60d8 | 2012-06-06 17:13:07 +0000 | [diff] [blame] | 12751 | vars->eee_status &= ~(SHMEM_EEE_LP_ADV_STATUS_MASK | |
| 12752 | SHMEM_EEE_ACTIVE_BIT); |
| 12753 | bnx2x_update_mng_eee(params, vars->eee_status); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12754 | bnx2x_bits_dis(bp, NIG_REG_MASK_INTERRUPT_PORT0 + port*4, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 12755 | (NIG_MASK_XGXS0_LINK_STATUS | |
| 12756 | NIG_MASK_XGXS0_LINK10G | |
| 12757 | NIG_MASK_SERDES0_LINK_STATUS | |
| 12758 | NIG_MASK_MI_INT)); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12759 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 12760 | /* Activate nig drain */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12761 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + port*4, 1); |
| 12762 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 12763 | /* Disable nig egress interface */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 12764 | if (!CHIP_IS_E3(bp)) { |
| 12765 | REG_WR(bp, NIG_REG_BMAC0_OUT_EN + port*4, 0); |
| 12766 | REG_WR(bp, NIG_REG_EGRESS_EMAC0_OUT_EN + port*4, 0); |
| 12767 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12768 | |
Yaniv Rosner | d3a8f13 | 2012-09-13 02:56:20 +0000 | [diff] [blame] | 12769 | if (!CHIP_IS_E3(bp)) { |
| 12770 | bnx2x_set_bmac_rx(bp, params->chip_id, port, 0); |
| 12771 | } else { |
| 12772 | bnx2x_set_xmac_rxtx(params, 0); |
| 12773 | bnx2x_set_umac_rxtx(params, 0); |
| 12774 | } |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 12775 | /* Disable emac */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 12776 | if (!CHIP_IS_E3(bp)) |
| 12777 | REG_WR(bp, NIG_REG_NIG_EMAC0_EN + port*4, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12778 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 12779 | usleep_range(10000, 20000); |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 12780 | /* The PHY reset is controlled by GPIO 1 |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12781 | * Hold it as vars low |
| 12782 | */ |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 12783 | /* Clear link led */ |
Yaniv Rosner | ca7b91b | 2012-04-04 01:40:02 +0000 | [diff] [blame] | 12784 | bnx2x_set_mdio_clk(bp, params->chip_id, port); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 12785 | bnx2x_set_led(params, vars, LED_MODE_OFF, 0); |
| 12786 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12787 | if (reset_ext_phy) { |
| 12788 | for (phy_index = EXT_PHY1; phy_index < params->num_phys; |
| 12789 | phy_index++) { |
Yaniv Rosner | 28f4881 | 2011-08-02 23:00:12 +0000 | [diff] [blame] | 12790 | if (params->phy[phy_index].link_reset) { |
| 12791 | bnx2x_set_aer_mmd(params, |
| 12792 | ¶ms->phy[phy_index]); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12793 | params->phy[phy_index].link_reset( |
| 12794 | ¶ms->phy[phy_index], |
| 12795 | params); |
Yaniv Rosner | 28f4881 | 2011-08-02 23:00:12 +0000 | [diff] [blame] | 12796 | } |
Yaniv Rosner | cf1d972 | 2010-11-01 05:32:34 +0000 | [diff] [blame] | 12797 | if (params->phy[phy_index].flags & |
| 12798 | FLAGS_REARM_LATCH_SIGNAL) |
| 12799 | clear_latch_ind = 1; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12800 | } |
| 12801 | } |
| 12802 | |
Yaniv Rosner | cf1d972 | 2010-11-01 05:32:34 +0000 | [diff] [blame] | 12803 | if (clear_latch_ind) { |
| 12804 | /* Clear latching indication */ |
| 12805 | bnx2x_rearm_latch_signal(bp, port, 0); |
| 12806 | bnx2x_bits_dis(bp, NIG_REG_LATCH_BC_0 + port*4, |
| 12807 | 1 << NIG_LATCH_BC_ENABLE_MI_INT); |
| 12808 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12809 | if (params->phy[INT_PHY].link_reset) |
| 12810 | params->phy[INT_PHY].link_reset( |
| 12811 | ¶ms->phy[INT_PHY], params); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12812 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 12813 | /* Disable nig ingress interface */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 12814 | if (!CHIP_IS_E3(bp)) { |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 12815 | /* Reset BigMac */ |
Yaniv Rosner | ce7c048 | 2011-10-27 05:09:47 +0000 | [diff] [blame] | 12816 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_CLEAR, |
| 12817 | (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << port)); |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 12818 | REG_WR(bp, NIG_REG_BMAC0_IN_EN + port*4, 0); |
| 12819 | REG_WR(bp, NIG_REG_EMAC0_IN_EN + port*4, 0); |
Yaniv Rosner | ce7c048 | 2011-10-27 05:09:47 +0000 | [diff] [blame] | 12820 | } else { |
| 12821 | u32 xmac_base = (params->port) ? GRCBASE_XMAC1 : GRCBASE_XMAC0; |
| 12822 | bnx2x_set_xumac_nig(params, 0, 0); |
| 12823 | if (REG_RD(bp, MISC_REG_RESET_REG_2) & |
| 12824 | MISC_REGISTERS_RESET_REG_2_XMAC) |
| 12825 | REG_WR(bp, xmac_base + XMAC_REG_CTRL, |
| 12826 | XMAC_CTRL_REG_SOFT_RESET); |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 12827 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12828 | vars->link_up = 0; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 12829 | vars->phy_flags = 0; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12830 | return 0; |
| 12831 | } |
Yaniv Rosner | d3a8f13 | 2012-09-13 02:56:20 +0000 | [diff] [blame] | 12832 | int bnx2x_lfa_reset(struct link_params *params, |
| 12833 | struct link_vars *vars) |
| 12834 | { |
| 12835 | struct bnx2x *bp = params->bp; |
| 12836 | vars->link_up = 0; |
| 12837 | vars->phy_flags = 0; |
| 12838 | if (!params->lfa_base) |
| 12839 | return bnx2x_link_reset(params, vars, 1); |
| 12840 | /* |
| 12841 | * Activate NIG drain so that during this time the device won't send |
| 12842 | * anything while it is unable to response. |
| 12843 | */ |
| 12844 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + params->port*4, 1); |
| 12845 | |
| 12846 | /* |
| 12847 | * Close gracefully the gate from BMAC to NIG such that no half packets |
| 12848 | * are passed. |
| 12849 | */ |
| 12850 | if (!CHIP_IS_E3(bp)) |
| 12851 | bnx2x_set_bmac_rx(bp, params->chip_id, params->port, 0); |
| 12852 | |
| 12853 | if (CHIP_IS_E3(bp)) { |
| 12854 | bnx2x_set_xmac_rxtx(params, 0); |
| 12855 | bnx2x_set_umac_rxtx(params, 0); |
| 12856 | } |
| 12857 | /* Wait 10ms for the pipe to clean up*/ |
| 12858 | usleep_range(10000, 20000); |
| 12859 | |
| 12860 | /* Clean the NIG-BRB using the network filters in a way that will |
| 12861 | * not cut a packet in the middle. |
| 12862 | */ |
| 12863 | bnx2x_set_rx_filter(params, 0); |
| 12864 | |
| 12865 | /* |
| 12866 | * Re-open the gate between the BMAC and the NIG, after verifying the |
| 12867 | * gate to the BRB is closed, otherwise packets may arrive to the |
| 12868 | * firmware before driver had initialized it. The target is to achieve |
| 12869 | * minimum management protocol down time. |
| 12870 | */ |
| 12871 | if (!CHIP_IS_E3(bp)) |
| 12872 | bnx2x_set_bmac_rx(bp, params->chip_id, params->port, 1); |
| 12873 | |
| 12874 | if (CHIP_IS_E3(bp)) { |
| 12875 | bnx2x_set_xmac_rxtx(params, 1); |
| 12876 | bnx2x_set_umac_rxtx(params, 1); |
| 12877 | } |
| 12878 | /* Disable NIG drain */ |
| 12879 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + params->port*4, 0); |
| 12880 | return 0; |
| 12881 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12882 | |
| 12883 | /****************************************************************************/ |
| 12884 | /* Common function */ |
| 12885 | /****************************************************************************/ |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 12886 | static int bnx2x_8073_common_init_phy(struct bnx2x *bp, |
| 12887 | u32 shmem_base_path[], |
| 12888 | u32 shmem2_base_path[], u8 phy_index, |
| 12889 | u32 chip_id) |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12890 | { |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 12891 | struct bnx2x_phy phy[PORT_MAX]; |
| 12892 | struct bnx2x_phy *phy_blk[PORT_MAX]; |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12893 | u16 val; |
Yaniv Rosner | c8e64df | 2011-01-30 04:15:00 +0000 | [diff] [blame] | 12894 | s8 port = 0; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12895 | s8 port_of_path = 0; |
Yaniv Rosner | c8e64df | 2011-01-30 04:15:00 +0000 | [diff] [blame] | 12896 | u32 swap_val, swap_override; |
| 12897 | swap_val = REG_RD(bp, NIG_REG_PORT_SWAP); |
| 12898 | swap_override = REG_RD(bp, NIG_REG_STRAP_OVERRIDE); |
| 12899 | port ^= (swap_val && swap_override); |
| 12900 | bnx2x_ext_phy_hw_reset(bp, port); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12901 | /* PART1 - Reset both phys */ |
| 12902 | for (port = PORT_MAX - 1; port >= PORT_0; port--) { |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12903 | u32 shmem_base, shmem2_base; |
| 12904 | /* In E2, same phy is using for port0 of the two paths */ |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 12905 | if (CHIP_IS_E1x(bp)) { |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12906 | shmem_base = shmem_base_path[0]; |
| 12907 | shmem2_base = shmem2_base_path[0]; |
| 12908 | port_of_path = port; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 12909 | } else { |
| 12910 | shmem_base = shmem_base_path[port]; |
| 12911 | shmem2_base = shmem2_base_path[port]; |
| 12912 | port_of_path = 0; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12913 | } |
| 12914 | |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12915 | /* Extract the ext phy address for the port */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12916 | if (bnx2x_populate_phy(bp, phy_index, shmem_base, shmem2_base, |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12917 | port_of_path, &phy[port]) != |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 12918 | 0) { |
| 12919 | DP(NETIF_MSG_LINK, "populate_phy failed\n"); |
| 12920 | return -EINVAL; |
| 12921 | } |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 12922 | /* Disable attentions */ |
Yaniv Rosner | 6a71bbe | 2010-11-01 05:32:31 +0000 | [diff] [blame] | 12923 | bnx2x_bits_dis(bp, NIG_REG_MASK_INTERRUPT_PORT0 + |
| 12924 | port_of_path*4, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 12925 | (NIG_MASK_XGXS0_LINK_STATUS | |
| 12926 | NIG_MASK_XGXS0_LINK10G | |
| 12927 | NIG_MASK_SERDES0_LINK_STATUS | |
| 12928 | NIG_MASK_MI_INT)); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12929 | |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12930 | /* Need to take the phy out of low power mode in order |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 12931 | * to write to access its registers |
| 12932 | */ |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12933 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 12934 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, |
| 12935 | port); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12936 | |
| 12937 | /* Reset the phy */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 12938 | bnx2x_cl45_write(bp, &phy[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 12939 | MDIO_PMA_DEVAD, |
| 12940 | MDIO_PMA_REG_CTRL, |
| 12941 | 1<<15); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12942 | } |
| 12943 | |
| 12944 | /* Add delay of 150ms after reset */ |
| 12945 | msleep(150); |
| 12946 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 12947 | if (phy[PORT_0].addr & 0x1) { |
| 12948 | phy_blk[PORT_0] = &(phy[PORT_1]); |
| 12949 | phy_blk[PORT_1] = &(phy[PORT_0]); |
| 12950 | } else { |
| 12951 | phy_blk[PORT_0] = &(phy[PORT_0]); |
| 12952 | phy_blk[PORT_1] = &(phy[PORT_1]); |
| 12953 | } |
| 12954 | |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12955 | /* PART2 - Download firmware to both phys */ |
| 12956 | for (port = PORT_MAX - 1; port >= PORT_0; port--) { |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 12957 | if (CHIP_IS_E1x(bp)) |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12958 | port_of_path = port; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 12959 | else |
| 12960 | port_of_path = 0; |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12961 | |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12962 | DP(NETIF_MSG_LINK, "Loading spirom for phy address 0x%x\n", |
| 12963 | phy_blk[port]->addr); |
Yaniv Rosner | 5c99274b | 2011-01-18 04:33:36 +0000 | [diff] [blame] | 12964 | if (bnx2x_8073_8727_external_rom_boot(bp, phy_blk[port], |
| 12965 | port_of_path)) |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12966 | return -EINVAL; |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12967 | |
| 12968 | /* Only set bit 10 = 1 (Tx power down) */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 12969 | bnx2x_cl45_read(bp, phy_blk[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 12970 | MDIO_PMA_DEVAD, |
| 12971 | MDIO_PMA_REG_TX_POWER_DOWN, &val); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12972 | |
| 12973 | /* Phase1 of TX_POWER_DOWN reset */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 12974 | bnx2x_cl45_write(bp, phy_blk[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 12975 | MDIO_PMA_DEVAD, |
| 12976 | MDIO_PMA_REG_TX_POWER_DOWN, |
| 12977 | (val | 1<<10)); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12978 | } |
| 12979 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 12980 | /* Toggle Transmitter: Power down and then up with 600ms delay |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 12981 | * between |
| 12982 | */ |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12983 | msleep(600); |
| 12984 | |
| 12985 | /* PART3 - complete TX_POWER_DOWN process, and set GPIO2 back to low */ |
| 12986 | for (port = PORT_MAX - 1; port >= PORT_0; port--) { |
Eilon Greenstein | f537225 | 2009-02-12 08:38:30 +0000 | [diff] [blame] | 12987 | /* Phase2 of POWER_DOWN_RESET */ |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12988 | /* Release bit 10 (Release Tx power down) */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 12989 | bnx2x_cl45_read(bp, phy_blk[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 12990 | MDIO_PMA_DEVAD, |
| 12991 | MDIO_PMA_REG_TX_POWER_DOWN, &val); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12992 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 12993 | bnx2x_cl45_write(bp, phy_blk[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 12994 | MDIO_PMA_DEVAD, |
| 12995 | MDIO_PMA_REG_TX_POWER_DOWN, (val & (~(1<<10)))); |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 12996 | usleep_range(15000, 30000); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12997 | |
| 12998 | /* Read modify write the SPI-ROM version select register */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 12999 | bnx2x_cl45_read(bp, phy_blk[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 13000 | MDIO_PMA_DEVAD, |
| 13001 | MDIO_PMA_REG_EDC_FFE_MAIN, &val); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 13002 | bnx2x_cl45_write(bp, phy_blk[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 13003 | MDIO_PMA_DEVAD, |
| 13004 | MDIO_PMA_REG_EDC_FFE_MAIN, (val | (1<<12))); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 13005 | |
| 13006 | /* set GPIO2 back to LOW */ |
| 13007 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 13008 | MISC_REGISTERS_GPIO_OUTPUT_LOW, port); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 13009 | } |
| 13010 | return 0; |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 13011 | } |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 13012 | static int bnx2x_8726_common_init_phy(struct bnx2x *bp, |
| 13013 | u32 shmem_base_path[], |
| 13014 | u32 shmem2_base_path[], u8 phy_index, |
| 13015 | u32 chip_id) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 13016 | { |
| 13017 | u32 val; |
| 13018 | s8 port; |
| 13019 | struct bnx2x_phy phy; |
| 13020 | /* Use port1 because of the static port-swap */ |
| 13021 | /* Enable the module detection interrupt */ |
| 13022 | val = REG_RD(bp, MISC_REG_GPIO_EVENT_EN); |
| 13023 | val |= ((1<<MISC_REGISTERS_GPIO_3)| |
| 13024 | (1<<(MISC_REGISTERS_GPIO_3 + MISC_REGISTERS_GPIO_PORT_SHIFT))); |
| 13025 | REG_WR(bp, MISC_REG_GPIO_EVENT_EN, val); |
| 13026 | |
Yaniv Rosner | 650154b | 2010-11-01 05:32:36 +0000 | [diff] [blame] | 13027 | bnx2x_ext_phy_hw_reset(bp, 0); |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 13028 | usleep_range(5000, 10000); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 13029 | for (port = 0; port < PORT_MAX; port++) { |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 13030 | u32 shmem_base, shmem2_base; |
| 13031 | |
| 13032 | /* In E2, same phy is using for port0 of the two paths */ |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 13033 | if (CHIP_IS_E1x(bp)) { |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 13034 | shmem_base = shmem_base_path[0]; |
| 13035 | shmem2_base = shmem2_base_path[0]; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 13036 | } else { |
| 13037 | shmem_base = shmem_base_path[port]; |
| 13038 | shmem2_base = shmem2_base_path[port]; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 13039 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 13040 | /* Extract the ext phy address for the port */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 13041 | if (bnx2x_populate_phy(bp, phy_index, shmem_base, shmem2_base, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 13042 | port, &phy) != |
| 13043 | 0) { |
| 13044 | DP(NETIF_MSG_LINK, "populate phy failed\n"); |
| 13045 | return -EINVAL; |
| 13046 | } |
| 13047 | |
| 13048 | /* Reset phy*/ |
| 13049 | bnx2x_cl45_write(bp, &phy, |
| 13050 | MDIO_PMA_DEVAD, MDIO_PMA_REG_GEN_CTRL, 0x0001); |
| 13051 | |
| 13052 | |
| 13053 | /* Set fault module detected LED on */ |
| 13054 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_0, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 13055 | MISC_REGISTERS_GPIO_HIGH, |
| 13056 | port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 13057 | } |
| 13058 | |
| 13059 | return 0; |
| 13060 | } |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 13061 | static void bnx2x_get_ext_phy_reset_gpio(struct bnx2x *bp, u32 shmem_base, |
| 13062 | u8 *io_gpio, u8 *io_port) |
| 13063 | { |
| 13064 | |
| 13065 | u32 phy_gpio_reset = REG_RD(bp, shmem_base + |
| 13066 | offsetof(struct shmem_region, |
| 13067 | dev_info.port_hw_config[PORT_0].default_cfg)); |
| 13068 | switch (phy_gpio_reset) { |
| 13069 | case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO0_P0: |
| 13070 | *io_gpio = 0; |
| 13071 | *io_port = 0; |
| 13072 | break; |
| 13073 | case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO1_P0: |
| 13074 | *io_gpio = 1; |
| 13075 | *io_port = 0; |
| 13076 | break; |
| 13077 | case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO2_P0: |
| 13078 | *io_gpio = 2; |
| 13079 | *io_port = 0; |
| 13080 | break; |
| 13081 | case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO3_P0: |
| 13082 | *io_gpio = 3; |
| 13083 | *io_port = 0; |
| 13084 | break; |
| 13085 | case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO0_P1: |
| 13086 | *io_gpio = 0; |
| 13087 | *io_port = 1; |
| 13088 | break; |
| 13089 | case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO1_P1: |
| 13090 | *io_gpio = 1; |
| 13091 | *io_port = 1; |
| 13092 | break; |
| 13093 | case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO2_P1: |
| 13094 | *io_gpio = 2; |
| 13095 | *io_port = 1; |
| 13096 | break; |
| 13097 | case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO3_P1: |
| 13098 | *io_gpio = 3; |
| 13099 | *io_port = 1; |
| 13100 | break; |
| 13101 | default: |
| 13102 | /* Don't override the io_gpio and io_port */ |
| 13103 | break; |
| 13104 | } |
| 13105 | } |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 13106 | |
| 13107 | static int bnx2x_8727_common_init_phy(struct bnx2x *bp, |
| 13108 | u32 shmem_base_path[], |
| 13109 | u32 shmem2_base_path[], u8 phy_index, |
| 13110 | u32 chip_id) |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 13111 | { |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 13112 | s8 port, reset_gpio; |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 13113 | u32 swap_val, swap_override; |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 13114 | struct bnx2x_phy phy[PORT_MAX]; |
| 13115 | struct bnx2x_phy *phy_blk[PORT_MAX]; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 13116 | s8 port_of_path; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 13117 | swap_val = REG_RD(bp, NIG_REG_PORT_SWAP); |
| 13118 | swap_override = REG_RD(bp, NIG_REG_STRAP_OVERRIDE); |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 13119 | |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 13120 | reset_gpio = MISC_REGISTERS_GPIO_1; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 13121 | port = 1; |
| 13122 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 13123 | /* Retrieve the reset gpio/port which control the reset. |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 13124 | * Default is GPIO1, PORT1 |
| 13125 | */ |
| 13126 | bnx2x_get_ext_phy_reset_gpio(bp, shmem_base_path[0], |
| 13127 | (u8 *)&reset_gpio, (u8 *)&port); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 13128 | |
| 13129 | /* Calculate the port based on port swap */ |
| 13130 | port ^= (swap_val && swap_override); |
| 13131 | |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 13132 | /* Initiate PHY reset*/ |
| 13133 | bnx2x_set_gpio(bp, reset_gpio, MISC_REGISTERS_GPIO_OUTPUT_LOW, |
| 13134 | port); |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 13135 | usleep_range(1000, 2000); |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 13136 | bnx2x_set_gpio(bp, reset_gpio, MISC_REGISTERS_GPIO_OUTPUT_HIGH, |
| 13137 | port); |
| 13138 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 13139 | usleep_range(5000, 10000); |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 13140 | |
| 13141 | /* PART1 - Reset both phys */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 13142 | for (port = PORT_MAX - 1; port >= PORT_0; port--) { |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 13143 | u32 shmem_base, shmem2_base; |
| 13144 | |
| 13145 | /* In E2, same phy is using for port0 of the two paths */ |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 13146 | if (CHIP_IS_E1x(bp)) { |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 13147 | shmem_base = shmem_base_path[0]; |
| 13148 | shmem2_base = shmem2_base_path[0]; |
| 13149 | port_of_path = port; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 13150 | } else { |
| 13151 | shmem_base = shmem_base_path[port]; |
| 13152 | shmem2_base = shmem2_base_path[port]; |
| 13153 | port_of_path = 0; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 13154 | } |
| 13155 | |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 13156 | /* Extract the ext phy address for the port */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 13157 | if (bnx2x_populate_phy(bp, phy_index, shmem_base, shmem2_base, |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 13158 | port_of_path, &phy[port]) != |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 13159 | 0) { |
| 13160 | DP(NETIF_MSG_LINK, "populate phy failed\n"); |
| 13161 | return -EINVAL; |
| 13162 | } |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 13163 | /* disable attentions */ |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 13164 | bnx2x_bits_dis(bp, NIG_REG_MASK_INTERRUPT_PORT0 + |
| 13165 | port_of_path*4, |
| 13166 | (NIG_MASK_XGXS0_LINK_STATUS | |
| 13167 | NIG_MASK_XGXS0_LINK10G | |
| 13168 | NIG_MASK_SERDES0_LINK_STATUS | |
| 13169 | NIG_MASK_MI_INT)); |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 13170 | |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 13171 | |
| 13172 | /* Reset the phy */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 13173 | bnx2x_cl45_write(bp, &phy[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 13174 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 1<<15); |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 13175 | } |
| 13176 | |
| 13177 | /* Add delay of 150ms after reset */ |
| 13178 | msleep(150); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 13179 | if (phy[PORT_0].addr & 0x1) { |
| 13180 | phy_blk[PORT_0] = &(phy[PORT_1]); |
| 13181 | phy_blk[PORT_1] = &(phy[PORT_0]); |
| 13182 | } else { |
| 13183 | phy_blk[PORT_0] = &(phy[PORT_0]); |
| 13184 | phy_blk[PORT_1] = &(phy[PORT_1]); |
| 13185 | } |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 13186 | /* PART2 - Download firmware to both phys */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 13187 | for (port = PORT_MAX - 1; port >= PORT_0; port--) { |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 13188 | if (CHIP_IS_E1x(bp)) |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 13189 | port_of_path = port; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 13190 | else |
| 13191 | port_of_path = 0; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 13192 | DP(NETIF_MSG_LINK, "Loading spirom for phy address 0x%x\n", |
| 13193 | phy_blk[port]->addr); |
Yaniv Rosner | 5c99274b | 2011-01-18 04:33:36 +0000 | [diff] [blame] | 13194 | if (bnx2x_8073_8727_external_rom_boot(bp, phy_blk[port], |
| 13195 | port_of_path)) |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 13196 | return -EINVAL; |
Yaniv Rosner | 85242ee | 2011-07-05 01:06:53 +0000 | [diff] [blame] | 13197 | /* Disable PHY transmitter output */ |
| 13198 | bnx2x_cl45_write(bp, phy_blk[port], |
| 13199 | MDIO_PMA_DEVAD, |
| 13200 | MDIO_PMA_REG_TX_DISABLE, 1); |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 13201 | |
Yaniv Rosner | 5c99274b | 2011-01-18 04:33:36 +0000 | [diff] [blame] | 13202 | } |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 13203 | return 0; |
| 13204 | } |
| 13205 | |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 13206 | static int bnx2x_84833_common_init_phy(struct bnx2x *bp, |
| 13207 | u32 shmem_base_path[], |
| 13208 | u32 shmem2_base_path[], |
| 13209 | u8 phy_index, |
| 13210 | u32 chip_id) |
| 13211 | { |
| 13212 | u8 reset_gpios; |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 13213 | reset_gpios = bnx2x_84833_get_reset_gpios(bp, shmem_base_path, chip_id); |
| 13214 | bnx2x_set_mult_gpio(bp, reset_gpios, MISC_REGISTERS_GPIO_OUTPUT_LOW); |
| 13215 | udelay(10); |
| 13216 | bnx2x_set_mult_gpio(bp, reset_gpios, MISC_REGISTERS_GPIO_OUTPUT_HIGH); |
| 13217 | DP(NETIF_MSG_LINK, "84833 reset pulse on pin values 0x%x\n", |
| 13218 | reset_gpios); |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 13219 | return 0; |
| 13220 | } |
| 13221 | |
Yaniv Rosner | 11b2ec6 | 2012-01-17 02:33:25 +0000 | [diff] [blame] | 13222 | static int bnx2x_84833_pre_init_phy(struct bnx2x *bp, |
| 13223 | struct bnx2x_phy *phy) |
| 13224 | { |
| 13225 | u16 val, cnt; |
| 13226 | /* Wait for FW completing its initialization. */ |
| 13227 | for (cnt = 0; cnt < 1500; cnt++) { |
| 13228 | bnx2x_cl45_read(bp, phy, |
| 13229 | MDIO_PMA_DEVAD, |
| 13230 | MDIO_PMA_REG_CTRL, &val); |
| 13231 | if (!(val & (1<<15))) |
| 13232 | break; |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 13233 | usleep_range(1000, 2000); |
Yaniv Rosner | 11b2ec6 | 2012-01-17 02:33:25 +0000 | [diff] [blame] | 13234 | } |
| 13235 | if (cnt >= 1500) { |
| 13236 | DP(NETIF_MSG_LINK, "84833 reset timeout\n"); |
| 13237 | return -EINVAL; |
| 13238 | } |
| 13239 | |
| 13240 | /* Put the port in super isolate mode. */ |
| 13241 | bnx2x_cl45_read(bp, phy, |
| 13242 | MDIO_CTL_DEVAD, |
| 13243 | MDIO_84833_TOP_CFG_XGPHY_STRAP1, &val); |
| 13244 | val |= MDIO_84833_SUPER_ISOLATE; |
| 13245 | bnx2x_cl45_write(bp, phy, |
| 13246 | MDIO_CTL_DEVAD, |
| 13247 | MDIO_84833_TOP_CFG_XGPHY_STRAP1, val); |
| 13248 | |
| 13249 | /* Save spirom version */ |
| 13250 | bnx2x_save_848xx_spirom_version(phy, bp, PORT_0); |
| 13251 | return 0; |
| 13252 | } |
| 13253 | |
| 13254 | int bnx2x_pre_init_phy(struct bnx2x *bp, |
| 13255 | u32 shmem_base, |
| 13256 | u32 shmem2_base, |
| 13257 | u32 chip_id) |
| 13258 | { |
| 13259 | int rc = 0; |
| 13260 | struct bnx2x_phy phy; |
| 13261 | bnx2x_set_mdio_clk(bp, chip_id, PORT_0); |
| 13262 | if (bnx2x_populate_phy(bp, EXT_PHY1, shmem_base, shmem2_base, |
| 13263 | PORT_0, &phy)) { |
| 13264 | DP(NETIF_MSG_LINK, "populate_phy failed\n"); |
| 13265 | return -EINVAL; |
| 13266 | } |
| 13267 | switch (phy.type) { |
| 13268 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833: |
| 13269 | rc = bnx2x_84833_pre_init_phy(bp, &phy); |
| 13270 | break; |
| 13271 | default: |
| 13272 | break; |
| 13273 | } |
| 13274 | return rc; |
| 13275 | } |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 13276 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 13277 | static int bnx2x_ext_phy_common_init(struct bnx2x *bp, u32 shmem_base_path[], |
| 13278 | u32 shmem2_base_path[], u8 phy_index, |
| 13279 | u32 ext_phy_type, u32 chip_id) |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 13280 | { |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 13281 | int rc = 0; |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 13282 | |
| 13283 | switch (ext_phy_type) { |
| 13284 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073: |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 13285 | rc = bnx2x_8073_common_init_phy(bp, shmem_base_path, |
| 13286 | shmem2_base_path, |
| 13287 | phy_index, chip_id); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 13288 | break; |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 13289 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8722: |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 13290 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727: |
| 13291 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727_NOC: |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 13292 | rc = bnx2x_8727_common_init_phy(bp, shmem_base_path, |
| 13293 | shmem2_base_path, |
| 13294 | phy_index, chip_id); |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 13295 | break; |
| 13296 | |
Eilon Greenstein | 589abe3 | 2009-02-12 08:36:55 +0000 | [diff] [blame] | 13297 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726: |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 13298 | /* GPIO1 affects both ports, so there's need to pull |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 13299 | * it for single port alone |
| 13300 | */ |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 13301 | rc = bnx2x_8726_common_init_phy(bp, shmem_base_path, |
| 13302 | shmem2_base_path, |
| 13303 | phy_index, chip_id); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 13304 | break; |
Yaniv Rosner | 0d40f0d | 2011-06-14 01:34:27 +0000 | [diff] [blame] | 13305 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833: |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 13306 | /* GPIO3's are linked, and so both need to be toggled |
Yaniv Rosner | 0d40f0d | 2011-06-14 01:34:27 +0000 | [diff] [blame] | 13307 | * to obtain required 2us pulse. |
| 13308 | */ |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 13309 | rc = bnx2x_84833_common_init_phy(bp, shmem_base_path, |
| 13310 | shmem2_base_path, |
| 13311 | phy_index, chip_id); |
Yaniv Rosner | 0d40f0d | 2011-06-14 01:34:27 +0000 | [diff] [blame] | 13312 | break; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 13313 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_FAILURE: |
| 13314 | rc = -EINVAL; |
Yaniv Rosner | 4f60dab | 2009-11-05 19:18:23 +0200 | [diff] [blame] | 13315 | break; |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 13316 | default: |
| 13317 | DP(NETIF_MSG_LINK, |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 13318 | "ext_phy 0x%x common init not required\n", |
| 13319 | ext_phy_type); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 13320 | break; |
| 13321 | } |
| 13322 | |
Yuval Mintz | d231023 | 2012-06-20 19:05:19 +0000 | [diff] [blame] | 13323 | if (rc) |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 13324 | netdev_err(bp->dev, "Warning: PHY was not initialized," |
| 13325 | " Port %d\n", |
| 13326 | 0); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 13327 | return rc; |
| 13328 | } |
| 13329 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 13330 | int bnx2x_common_init_phy(struct bnx2x *bp, u32 shmem_base_path[], |
| 13331 | u32 shmem2_base_path[], u32 chip_id) |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 13332 | { |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 13333 | int rc = 0; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 13334 | u32 phy_ver, val; |
| 13335 | u8 phy_index = 0; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 13336 | u32 ext_phy_type, ext_phy_config; |
Yaniv Rosner | a198c14 | 2011-05-31 21:29:42 +0000 | [diff] [blame] | 13337 | bnx2x_set_mdio_clk(bp, chip_id, PORT_0); |
| 13338 | bnx2x_set_mdio_clk(bp, chip_id, PORT_1); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 13339 | DP(NETIF_MSG_LINK, "Begin common phy init\n"); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 13340 | if (CHIP_IS_E3(bp)) { |
| 13341 | /* Enable EPIO */ |
| 13342 | val = REG_RD(bp, MISC_REG_GEN_PURP_HWG); |
| 13343 | REG_WR(bp, MISC_REG_GEN_PURP_HWG, val | 1); |
| 13344 | } |
Yaniv Rosner | b21a342 | 2011-01-18 04:33:24 +0000 | [diff] [blame] | 13345 | /* Check if common init was already done */ |
| 13346 | phy_ver = REG_RD(bp, shmem_base_path[0] + |
| 13347 | offsetof(struct shmem_region, |
| 13348 | port_mb[PORT_0].ext_phy_fw_version)); |
| 13349 | if (phy_ver) { |
| 13350 | DP(NETIF_MSG_LINK, "Not doing common init; phy ver is 0x%x\n", |
| 13351 | phy_ver); |
| 13352 | return 0; |
| 13353 | } |
| 13354 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 13355 | /* Read the ext_phy_type for arbitrary port(0) */ |
| 13356 | for (phy_index = EXT_PHY1; phy_index < MAX_PHYS; |
| 13357 | phy_index++) { |
| 13358 | ext_phy_config = bnx2x_get_ext_phy_config(bp, |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 13359 | shmem_base_path[0], |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 13360 | phy_index, 0); |
| 13361 | ext_phy_type = XGXS_EXT_PHY_TYPE(ext_phy_config); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 13362 | rc |= bnx2x_ext_phy_common_init(bp, shmem_base_path, |
| 13363 | shmem2_base_path, |
| 13364 | phy_index, ext_phy_type, |
| 13365 | chip_id); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 13366 | } |
| 13367 | return rc; |
| 13368 | } |
| 13369 | |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 13370 | static void bnx2x_check_over_curr(struct link_params *params, |
| 13371 | struct link_vars *vars) |
| 13372 | { |
| 13373 | struct bnx2x *bp = params->bp; |
| 13374 | u32 cfg_pin; |
| 13375 | u8 port = params->port; |
| 13376 | u32 pin_val; |
| 13377 | |
| 13378 | cfg_pin = (REG_RD(bp, params->shmem_base + |
| 13379 | offsetof(struct shmem_region, |
| 13380 | dev_info.port_hw_config[port].e3_cmn_pin_cfg1)) & |
| 13381 | PORT_HW_CFG_E3_OVER_CURRENT_MASK) >> |
| 13382 | PORT_HW_CFG_E3_OVER_CURRENT_SHIFT; |
| 13383 | |
| 13384 | /* Ignore check if no external input PIN available */ |
| 13385 | if (bnx2x_get_cfg_pin(bp, cfg_pin, &pin_val) != 0) |
| 13386 | return; |
| 13387 | |
| 13388 | if (!pin_val) { |
| 13389 | if ((vars->phy_flags & PHY_OVER_CURRENT_FLAG) == 0) { |
| 13390 | netdev_err(bp->dev, "Error: Power fault on Port %d has" |
| 13391 | " been detected and the power to " |
| 13392 | "that SFP+ module has been removed" |
| 13393 | " to prevent failure of the card." |
| 13394 | " Please remove the SFP+ module and" |
| 13395 | " restart the system to clear this" |
| 13396 | " error.\n", |
| 13397 | params->port); |
| 13398 | vars->phy_flags |= PHY_OVER_CURRENT_FLAG; |
| 13399 | } |
| 13400 | } else |
| 13401 | vars->phy_flags &= ~PHY_OVER_CURRENT_FLAG; |
| 13402 | } |
| 13403 | |
Yuval Mintz | d0b8a6f | 2012-06-20 19:05:18 +0000 | [diff] [blame] | 13404 | /* Returns 0 if no change occured since last check; 1 otherwise. */ |
| 13405 | static u8 bnx2x_analyze_link_error(struct link_params *params, |
| 13406 | struct link_vars *vars, u32 status, |
| 13407 | u32 phy_flag, u32 link_flag, u8 notify) |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 13408 | { |
| 13409 | struct bnx2x *bp = params->bp; |
| 13410 | /* Compare new value with previous value */ |
| 13411 | u8 led_mode; |
Yuval Mintz | d0b8a6f | 2012-06-20 19:05:18 +0000 | [diff] [blame] | 13412 | u32 old_status = (vars->phy_flags & phy_flag) ? 1 : 0; |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 13413 | |
Yuval Mintz | d0b8a6f | 2012-06-20 19:05:18 +0000 | [diff] [blame] | 13414 | if ((status ^ old_status) == 0) |
| 13415 | return 0; |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 13416 | |
| 13417 | /* If values differ */ |
Yuval Mintz | d0b8a6f | 2012-06-20 19:05:18 +0000 | [diff] [blame] | 13418 | switch (phy_flag) { |
| 13419 | case PHY_HALF_OPEN_CONN_FLAG: |
| 13420 | DP(NETIF_MSG_LINK, "Analyze Remote Fault\n"); |
| 13421 | break; |
| 13422 | case PHY_SFP_TX_FAULT_FLAG: |
| 13423 | DP(NETIF_MSG_LINK, "Analyze TX Fault\n"); |
| 13424 | break; |
| 13425 | default: |
| 13426 | DP(NETIF_MSG_LINK, "Analyze UNKOWN\n"); |
| 13427 | } |
| 13428 | DP(NETIF_MSG_LINK, "Link changed:[%x %x]->%x\n", vars->link_up, |
| 13429 | old_status, status); |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 13430 | |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 13431 | /* a. Update shmem->link_status accordingly |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 13432 | * b. Update link_vars->link_up |
| 13433 | */ |
Yuval Mintz | d0b8a6f | 2012-06-20 19:05:18 +0000 | [diff] [blame] | 13434 | if (status) { |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 13435 | vars->link_status &= ~LINK_STATUS_LINK_UP; |
Yuval Mintz | d0b8a6f | 2012-06-20 19:05:18 +0000 | [diff] [blame] | 13436 | vars->link_status |= link_flag; |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 13437 | vars->link_up = 0; |
Yuval Mintz | d0b8a6f | 2012-06-20 19:05:18 +0000 | [diff] [blame] | 13438 | vars->phy_flags |= phy_flag; |
Yaniv Rosner | 55098c5 | 2012-04-03 18:41:27 +0000 | [diff] [blame] | 13439 | |
| 13440 | /* activate nig drain */ |
| 13441 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + params->port*4, 1); |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 13442 | /* Set LED mode to off since the PHY doesn't know about these |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 13443 | * errors |
| 13444 | */ |
| 13445 | led_mode = LED_MODE_OFF; |
| 13446 | } else { |
| 13447 | vars->link_status |= LINK_STATUS_LINK_UP; |
Yuval Mintz | d0b8a6f | 2012-06-20 19:05:18 +0000 | [diff] [blame] | 13448 | vars->link_status &= ~link_flag; |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 13449 | vars->link_up = 1; |
Yuval Mintz | d0b8a6f | 2012-06-20 19:05:18 +0000 | [diff] [blame] | 13450 | vars->phy_flags &= ~phy_flag; |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 13451 | led_mode = LED_MODE_OPER; |
Yaniv Rosner | 55098c5 | 2012-04-03 18:41:27 +0000 | [diff] [blame] | 13452 | |
| 13453 | /* Clear nig drain */ |
| 13454 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + params->port*4, 0); |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 13455 | } |
Yaniv Rosner | 55098c5 | 2012-04-03 18:41:27 +0000 | [diff] [blame] | 13456 | bnx2x_sync_link(params, vars); |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 13457 | /* Update the LED according to the link state */ |
| 13458 | bnx2x_set_led(params, vars, led_mode, SPEED_10000); |
| 13459 | |
| 13460 | /* Update link status in the shared memory */ |
| 13461 | bnx2x_update_mng(params, vars->link_status); |
| 13462 | |
| 13463 | /* C. Trigger General Attention */ |
| 13464 | vars->periodic_flags |= PERIODIC_FLAGS_LINK_EVENT; |
Yaniv Rosner | 55098c5 | 2012-04-03 18:41:27 +0000 | [diff] [blame] | 13465 | if (notify) |
| 13466 | bnx2x_notify_link_changed(bp); |
Yuval Mintz | d0b8a6f | 2012-06-20 19:05:18 +0000 | [diff] [blame] | 13467 | |
| 13468 | return 1; |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 13469 | } |
| 13470 | |
Yaniv Rosner | de6f337 | 2011-08-02 22:59:25 +0000 | [diff] [blame] | 13471 | /****************************************************************************** |
| 13472 | * Description: |
| 13473 | * This function checks for half opened connection change indication. |
| 13474 | * When such change occurs, it calls the bnx2x_analyze_link_error |
| 13475 | * to check if Remote Fault is set or cleared. Reception of remote fault |
| 13476 | * status message in the MAC indicates that the peer's MAC has detected |
| 13477 | * a fault, for example, due to break in the TX side of fiber. |
| 13478 | * |
| 13479 | ******************************************************************************/ |
Yaniv Rosner | 55098c5 | 2012-04-03 18:41:27 +0000 | [diff] [blame] | 13480 | int bnx2x_check_half_open_conn(struct link_params *params, |
| 13481 | struct link_vars *vars, |
| 13482 | u8 notify) |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 13483 | { |
| 13484 | struct bnx2x *bp = params->bp; |
| 13485 | u32 lss_status = 0; |
| 13486 | u32 mac_base; |
| 13487 | /* In case link status is physically up @ 10G do */ |
Yaniv Rosner | 55098c5 | 2012-04-03 18:41:27 +0000 | [diff] [blame] | 13488 | if (((vars->phy_flags & PHY_PHYSICAL_LINK_FLAG) == 0) || |
| 13489 | (REG_RD(bp, NIG_REG_EGRESS_EMAC0_PORT + params->port*4))) |
| 13490 | return 0; |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 13491 | |
Yaniv Rosner | de6f337 | 2011-08-02 22:59:25 +0000 | [diff] [blame] | 13492 | if (CHIP_IS_E3(bp) && |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 13493 | (REG_RD(bp, MISC_REG_RESET_REG_2) & |
Yaniv Rosner | de6f337 | 2011-08-02 22:59:25 +0000 | [diff] [blame] | 13494 | (MISC_REGISTERS_RESET_REG_2_XMAC))) { |
| 13495 | /* Check E3 XMAC */ |
Yaniv Rosner | 8f73f0b | 2012-04-03 18:41:31 +0000 | [diff] [blame] | 13496 | /* Note that link speed cannot be queried here, since it may be |
Yaniv Rosner | de6f337 | 2011-08-02 22:59:25 +0000 | [diff] [blame] | 13497 | * zero while link is down. In case UMAC is active, LSS will |
| 13498 | * simply not be set |
| 13499 | */ |
| 13500 | mac_base = (params->port) ? GRCBASE_XMAC1 : GRCBASE_XMAC0; |
| 13501 | |
| 13502 | /* Clear stick bits (Requires rising edge) */ |
| 13503 | REG_WR(bp, mac_base + XMAC_REG_CLEAR_RX_LSS_STATUS, 0); |
| 13504 | REG_WR(bp, mac_base + XMAC_REG_CLEAR_RX_LSS_STATUS, |
| 13505 | XMAC_CLEAR_RX_LSS_STATUS_REG_CLEAR_LOCAL_FAULT_STATUS | |
| 13506 | XMAC_CLEAR_RX_LSS_STATUS_REG_CLEAR_REMOTE_FAULT_STATUS); |
| 13507 | if (REG_RD(bp, mac_base + XMAC_REG_RX_LSS_STATUS)) |
| 13508 | lss_status = 1; |
| 13509 | |
Yuval Mintz | d0b8a6f | 2012-06-20 19:05:18 +0000 | [diff] [blame] | 13510 | bnx2x_analyze_link_error(params, vars, lss_status, |
| 13511 | PHY_HALF_OPEN_CONN_FLAG, |
| 13512 | LINK_STATUS_NONE, notify); |
Yaniv Rosner | de6f337 | 2011-08-02 22:59:25 +0000 | [diff] [blame] | 13513 | } else if (REG_RD(bp, MISC_REG_RESET_REG_2) & |
| 13514 | (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << params->port)) { |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 13515 | /* Check E1X / E2 BMAC */ |
| 13516 | u32 lss_status_reg; |
| 13517 | u32 wb_data[2]; |
| 13518 | mac_base = params->port ? NIG_REG_INGRESS_BMAC1_MEM : |
| 13519 | NIG_REG_INGRESS_BMAC0_MEM; |
| 13520 | /* Read BIGMAC_REGISTER_RX_LSS_STATUS */ |
| 13521 | if (CHIP_IS_E2(bp)) |
| 13522 | lss_status_reg = BIGMAC2_REGISTER_RX_LSS_STAT; |
| 13523 | else |
| 13524 | lss_status_reg = BIGMAC_REGISTER_RX_LSS_STATUS; |
| 13525 | |
| 13526 | REG_RD_DMAE(bp, mac_base + lss_status_reg, wb_data, 2); |
| 13527 | lss_status = (wb_data[0] > 0); |
| 13528 | |
Yuval Mintz | d0b8a6f | 2012-06-20 19:05:18 +0000 | [diff] [blame] | 13529 | bnx2x_analyze_link_error(params, vars, lss_status, |
| 13530 | PHY_HALF_OPEN_CONN_FLAG, |
| 13531 | LINK_STATUS_NONE, notify); |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 13532 | } |
Yaniv Rosner | 55098c5 | 2012-04-03 18:41:27 +0000 | [diff] [blame] | 13533 | return 0; |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 13534 | } |
Yuval Mintz | d0b8a6f | 2012-06-20 19:05:18 +0000 | [diff] [blame] | 13535 | static void bnx2x_sfp_tx_fault_detection(struct bnx2x_phy *phy, |
| 13536 | struct link_params *params, |
| 13537 | struct link_vars *vars) |
| 13538 | { |
| 13539 | struct bnx2x *bp = params->bp; |
| 13540 | u32 cfg_pin, value = 0; |
| 13541 | u8 led_change, port = params->port; |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 13542 | |
Yuval Mintz | d0b8a6f | 2012-06-20 19:05:18 +0000 | [diff] [blame] | 13543 | /* Get The SFP+ TX_Fault controlling pin ([eg]pio) */ |
| 13544 | cfg_pin = (REG_RD(bp, params->shmem_base + offsetof(struct shmem_region, |
| 13545 | dev_info.port_hw_config[port].e3_cmn_pin_cfg)) & |
| 13546 | PORT_HW_CFG_E3_TX_FAULT_MASK) >> |
| 13547 | PORT_HW_CFG_E3_TX_FAULT_SHIFT; |
| 13548 | |
| 13549 | if (bnx2x_get_cfg_pin(bp, cfg_pin, &value)) { |
| 13550 | DP(NETIF_MSG_LINK, "Failed to read pin 0x%02x\n", cfg_pin); |
| 13551 | return; |
| 13552 | } |
| 13553 | |
| 13554 | led_change = bnx2x_analyze_link_error(params, vars, value, |
| 13555 | PHY_SFP_TX_FAULT_FLAG, |
| 13556 | LINK_STATUS_SFP_TX_FAULT, 1); |
| 13557 | |
| 13558 | if (led_change) { |
| 13559 | /* Change TX_Fault led, set link status for further syncs */ |
| 13560 | u8 led_mode; |
| 13561 | |
| 13562 | if (vars->phy_flags & PHY_SFP_TX_FAULT_FLAG) { |
| 13563 | led_mode = MISC_REGISTERS_GPIO_HIGH; |
| 13564 | vars->link_status |= LINK_STATUS_SFP_TX_FAULT; |
| 13565 | } else { |
| 13566 | led_mode = MISC_REGISTERS_GPIO_LOW; |
| 13567 | vars->link_status &= ~LINK_STATUS_SFP_TX_FAULT; |
| 13568 | } |
| 13569 | |
| 13570 | /* If module is unapproved, led should be on regardless */ |
| 13571 | if (!(phy->flags & FLAGS_SFP_NOT_APPROVED)) { |
| 13572 | DP(NETIF_MSG_LINK, "Change TX_Fault LED: ->%x\n", |
| 13573 | led_mode); |
| 13574 | bnx2x_set_e3_module_fault_led(params, led_mode); |
| 13575 | } |
| 13576 | } |
| 13577 | } |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 13578 | void bnx2x_period_func(struct link_params *params, struct link_vars *vars) |
| 13579 | { |
Yaniv Rosner | de6f337 | 2011-08-02 22:59:25 +0000 | [diff] [blame] | 13580 | u16 phy_idx; |
Yaniv Rosner | 55098c5 | 2012-04-03 18:41:27 +0000 | [diff] [blame] | 13581 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | de6f337 | 2011-08-02 22:59:25 +0000 | [diff] [blame] | 13582 | for (phy_idx = INT_PHY; phy_idx < MAX_PHYS; phy_idx++) { |
| 13583 | if (params->phy[phy_idx].flags & FLAGS_TX_ERROR_CHECK) { |
| 13584 | bnx2x_set_aer_mmd(params, ¶ms->phy[phy_idx]); |
Yaniv Rosner | 55098c5 | 2012-04-03 18:41:27 +0000 | [diff] [blame] | 13585 | if (bnx2x_check_half_open_conn(params, vars, 1) != |
| 13586 | 0) |
| 13587 | DP(NETIF_MSG_LINK, "Fault detection failed\n"); |
Yaniv Rosner | de6f337 | 2011-08-02 22:59:25 +0000 | [diff] [blame] | 13588 | break; |
| 13589 | } |
| 13590 | } |
| 13591 | |
Yaniv Rosner | a9077bf | 2011-10-27 05:09:46 +0000 | [diff] [blame] | 13592 | if (CHIP_IS_E3(bp)) { |
| 13593 | struct bnx2x_phy *phy = ¶ms->phy[INT_PHY]; |
| 13594 | bnx2x_set_aer_mmd(params, phy); |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 13595 | bnx2x_check_over_curr(params, vars); |
Yuval Mintz | d0b8a6f | 2012-06-20 19:05:18 +0000 | [diff] [blame] | 13596 | if (vars->rx_tx_asic_rst) |
| 13597 | bnx2x_warpcore_config_runtime(phy, params, vars); |
| 13598 | |
| 13599 | if ((REG_RD(bp, params->shmem_base + |
| 13600 | offsetof(struct shmem_region, dev_info. |
| 13601 | port_hw_config[params->port].default_cfg)) |
| 13602 | & PORT_HW_CFG_NET_SERDES_IF_MASK) == |
| 13603 | PORT_HW_CFG_NET_SERDES_IF_SFI) { |
| 13604 | if (bnx2x_is_sfp_module_plugged(phy, params)) { |
| 13605 | bnx2x_sfp_tx_fault_detection(phy, params, vars); |
| 13606 | } else if (vars->link_status & |
| 13607 | LINK_STATUS_SFP_TX_FAULT) { |
| 13608 | /* Clean trail, interrupt corrects the leds */ |
| 13609 | vars->link_status &= ~LINK_STATUS_SFP_TX_FAULT; |
| 13610 | vars->phy_flags &= ~PHY_SFP_TX_FAULT_FLAG; |
| 13611 | /* Update link status in the shared memory */ |
| 13612 | bnx2x_update_mng(params, vars->link_status); |
| 13613 | } |
| 13614 | } |
| 13615 | |
Yaniv Rosner | a9077bf | 2011-10-27 05:09:46 +0000 | [diff] [blame] | 13616 | } |
| 13617 | |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 13618 | } |
| 13619 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 13620 | u8 bnx2x_hw_lock_required(struct bnx2x *bp, u32 shmem_base, u32 shmem2_base) |
Yaniv Rosner | d90d96b | 2010-09-07 11:41:04 +0000 | [diff] [blame] | 13621 | { |
| 13622 | u8 phy_index; |
| 13623 | struct bnx2x_phy phy; |
| 13624 | for (phy_index = INT_PHY; phy_index < MAX_PHYS; |
| 13625 | phy_index++) { |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 13626 | if (bnx2x_populate_phy(bp, phy_index, shmem_base, shmem2_base, |
Yaniv Rosner | d90d96b | 2010-09-07 11:41:04 +0000 | [diff] [blame] | 13627 | 0, &phy) != 0) { |
| 13628 | DP(NETIF_MSG_LINK, "populate phy failed\n"); |
| 13629 | return 0; |
| 13630 | } |
| 13631 | |
| 13632 | if (phy.flags & FLAGS_HW_LOCK_REQUIRED) |
| 13633 | return 1; |
| 13634 | } |
| 13635 | return 0; |
| 13636 | } |
| 13637 | |
| 13638 | u8 bnx2x_fan_failure_det_req(struct bnx2x *bp, |
| 13639 | u32 shmem_base, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 13640 | u32 shmem2_base, |
Yaniv Rosner | d90d96b | 2010-09-07 11:41:04 +0000 | [diff] [blame] | 13641 | u8 port) |
| 13642 | { |
| 13643 | u8 phy_index, fan_failure_det_req = 0; |
| 13644 | struct bnx2x_phy phy; |
| 13645 | for (phy_index = EXT_PHY1; phy_index < MAX_PHYS; |
| 13646 | phy_index++) { |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 13647 | if (bnx2x_populate_phy(bp, phy_index, shmem_base, shmem2_base, |
Yaniv Rosner | d90d96b | 2010-09-07 11:41:04 +0000 | [diff] [blame] | 13648 | port, &phy) |
| 13649 | != 0) { |
| 13650 | DP(NETIF_MSG_LINK, "populate phy failed\n"); |
| 13651 | return 0; |
| 13652 | } |
| 13653 | fan_failure_det_req |= (phy.flags & |
| 13654 | FLAGS_FAN_FAILURE_DET_REQ); |
| 13655 | } |
| 13656 | return fan_failure_det_req; |
| 13657 | } |
| 13658 | |
| 13659 | void bnx2x_hw_reset_phy(struct link_params *params) |
| 13660 | { |
| 13661 | u8 phy_index; |
Yaniv Rosner | 985848f | 2011-07-05 01:06:48 +0000 | [diff] [blame] | 13662 | struct bnx2x *bp = params->bp; |
| 13663 | bnx2x_update_mng(params, 0); |
| 13664 | bnx2x_bits_dis(bp, NIG_REG_MASK_INTERRUPT_PORT0 + params->port*4, |
| 13665 | (NIG_MASK_XGXS0_LINK_STATUS | |
| 13666 | NIG_MASK_XGXS0_LINK10G | |
| 13667 | NIG_MASK_SERDES0_LINK_STATUS | |
| 13668 | NIG_MASK_MI_INT)); |
| 13669 | |
| 13670 | for (phy_index = INT_PHY; phy_index < MAX_PHYS; |
Yaniv Rosner | d90d96b | 2010-09-07 11:41:04 +0000 | [diff] [blame] | 13671 | phy_index++) { |
| 13672 | if (params->phy[phy_index].hw_reset) { |
| 13673 | params->phy[phy_index].hw_reset( |
| 13674 | ¶ms->phy[phy_index], |
| 13675 | params); |
| 13676 | params->phy[phy_index] = phy_null; |
| 13677 | } |
| 13678 | } |
| 13679 | } |
Yaniv Rosner | 020c7e3 | 2011-05-31 21:28:43 +0000 | [diff] [blame] | 13680 | |
| 13681 | void bnx2x_init_mod_abs_int(struct bnx2x *bp, struct link_vars *vars, |
| 13682 | u32 chip_id, u32 shmem_base, u32 shmem2_base, |
| 13683 | u8 port) |
| 13684 | { |
| 13685 | u8 gpio_num = 0xff, gpio_port = 0xff, phy_index; |
| 13686 | u32 val; |
| 13687 | u32 offset, aeu_mask, swap_val, swap_override, sync_offset; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 13688 | if (CHIP_IS_E3(bp)) { |
| 13689 | if (bnx2x_get_mod_abs_int_cfg(bp, chip_id, |
| 13690 | shmem_base, |
| 13691 | port, |
| 13692 | &gpio_num, |
| 13693 | &gpio_port) != 0) |
| 13694 | return; |
| 13695 | } else { |
Yaniv Rosner | 020c7e3 | 2011-05-31 21:28:43 +0000 | [diff] [blame] | 13696 | struct bnx2x_phy phy; |
| 13697 | for (phy_index = EXT_PHY1; phy_index < MAX_PHYS; |
| 13698 | phy_index++) { |
| 13699 | if (bnx2x_populate_phy(bp, phy_index, shmem_base, |
| 13700 | shmem2_base, port, &phy) |
| 13701 | != 0) { |
| 13702 | DP(NETIF_MSG_LINK, "populate phy failed\n"); |
| 13703 | return; |
| 13704 | } |
| 13705 | if (phy.type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726) { |
| 13706 | gpio_num = MISC_REGISTERS_GPIO_3; |
| 13707 | gpio_port = port; |
| 13708 | break; |
| 13709 | } |
| 13710 | } |
| 13711 | } |
| 13712 | |
| 13713 | if (gpio_num == 0xff) |
| 13714 | return; |
| 13715 | |
| 13716 | /* Set GPIO3 to trigger SFP+ module insertion/removal */ |
| 13717 | bnx2x_set_gpio(bp, gpio_num, MISC_REGISTERS_GPIO_INPUT_HI_Z, gpio_port); |
| 13718 | |
| 13719 | swap_val = REG_RD(bp, NIG_REG_PORT_SWAP); |
| 13720 | swap_override = REG_RD(bp, NIG_REG_STRAP_OVERRIDE); |
| 13721 | gpio_port ^= (swap_val && swap_override); |
| 13722 | |
| 13723 | vars->aeu_int_mask = AEU_INPUTS_ATTN_BITS_GPIO0_FUNCTION_0 << |
| 13724 | (gpio_num + (gpio_port << 2)); |
| 13725 | |
| 13726 | sync_offset = shmem_base + |
| 13727 | offsetof(struct shmem_region, |
| 13728 | dev_info.port_hw_config[port].aeu_int_mask); |
| 13729 | REG_WR(bp, sync_offset, vars->aeu_int_mask); |
| 13730 | |
| 13731 | DP(NETIF_MSG_LINK, "Setting MOD_ABS (GPIO%d_P%d) AEU to 0x%x\n", |
| 13732 | gpio_num, gpio_port, vars->aeu_int_mask); |
| 13733 | |
| 13734 | if (port == 0) |
| 13735 | offset = MISC_REG_AEU_ENABLE1_FUNC_0_OUT_0; |
| 13736 | else |
| 13737 | offset = MISC_REG_AEU_ENABLE1_FUNC_1_OUT_0; |
| 13738 | |
| 13739 | /* Open appropriate AEU for interrupts */ |
| 13740 | aeu_mask = REG_RD(bp, offset); |
| 13741 | aeu_mask |= vars->aeu_int_mask; |
| 13742 | REG_WR(bp, offset, aeu_mask); |
| 13743 | |
| 13744 | /* Enable the GPIO to trigger interrupt */ |
| 13745 | val = REG_RD(bp, MISC_REG_GPIO_EVENT_EN); |
| 13746 | val |= 1 << (gpio_num + (gpio_port << 2)); |
| 13747 | REG_WR(bp, MISC_REG_GPIO_EVENT_EN, val); |
| 13748 | } |