1 /* Copyright 2008-2011 Broadcom Corporation
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").
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
13 * Written by Yaniv Rosner
17 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
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>
28 #include "bnx2x_cmn.h"
30 /********************************************************/
32 /* L2 header size + 2*VLANs (8 bytes) + LLC SNAP (8 bytes) */
33 #define ETH_OVREHEAD (ETH_HLEN + 8 + 8)
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
38 #define BMAC_CONTROL_RX_ENABLE 2
40 #define I2C_SWITCH_WIDTH 2
43 #define I2C_WA_RETRY_CNT 3
44 #define MCPR_IMC_COMMAND_READ_OP 1
45 #define MCPR_IMC_COMMAND_WRITE_OP 2
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
50 /***********************************************************/
51 /* Shortcut definitions */
52 /***********************************************************/
54 #define NIG_LATCH_BC_ENABLE_MI_INT 0
56 #define NIG_STATUS_EMAC0_MI_INT \
57 NIG_STATUS_INTERRUPT_PORT0_REG_STATUS_EMAC0_MISC_MI_INT
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
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)
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)
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)
92 #define AUTONEG_CL37 SHARED_HW_CFG_AN_ENABLE_CL37
93 #define AUTONEG_CL73 SHARED_HW_CFG_AN_ENABLE_CL73
94 #define AUTONEG_BAM SHARED_HW_CFG_AN_ENABLE_BAM
95 #define AUTONEG_PARALLEL \
96 SHARED_HW_CFG_AN_ENABLE_PARALLEL_DETECTION
97 #define AUTONEG_SGMII_FIBER_AUTODET \
98 SHARED_HW_CFG_AN_EN_SGMII_FIBER_AUTO_DETECT
99 #define AUTONEG_REMOTE_PHY SHARED_HW_CFG_AN_ENABLE_REMOTE_PHY
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
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
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
124 #define LINK_10THD LINK_STATUS_SPEED_AND_DUPLEX_10THD
125 #define LINK_10TFD LINK_STATUS_SPEED_AND_DUPLEX_10TFD
126 #define LINK_100TXHD LINK_STATUS_SPEED_AND_DUPLEX_100TXHD
127 #define LINK_100T4 LINK_STATUS_SPEED_AND_DUPLEX_100T4
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
135 #define LINK_10GTFD LINK_STATUS_SPEED_AND_DUPLEX_10GTFD
136 #define LINK_10GXFD LINK_STATUS_SPEED_AND_DUPLEX_10GXFD
137 #define LINK_20GTFD LINK_STATUS_SPEED_AND_DUPLEX_20GTFD
138 #define LINK_20GXFD LINK_STATUS_SPEED_AND_DUPLEX_20GXFD
143 #define SFP_EEPROM_CON_TYPE_ADDR 0x2
144 #define SFP_EEPROM_CON_TYPE_VAL_LC 0x7
145 #define SFP_EEPROM_CON_TYPE_VAL_COPPER 0x21
148 #define SFP_EEPROM_COMP_CODE_ADDR 0x3
149 #define SFP_EEPROM_COMP_CODE_SR_MASK (1<<4)
150 #define SFP_EEPROM_COMP_CODE_LR_MASK (1<<5)
151 #define SFP_EEPROM_COMP_CODE_LRM_MASK (1<<6)
153 #define SFP_EEPROM_FC_TX_TECH_ADDR 0x8
154 #define SFP_EEPROM_FC_TX_TECH_BITMASK_COPPER_PASSIVE 0x4
155 #define SFP_EEPROM_FC_TX_TECH_BITMASK_COPPER_ACTIVE 0x8
157 #define SFP_EEPROM_OPTIONS_ADDR 0x40
158 #define SFP_EEPROM_OPTIONS_LINEAR_RX_OUT_MASK 0x1
159 #define SFP_EEPROM_OPTIONS_SIZE 2
161 #define EDC_MODE_LINEAR 0x0022
162 #define EDC_MODE_LIMITING 0x0044
163 #define EDC_MODE_PASSIVE_DAC 0x0055
165 /* BRB default for class 0 E2 */
166 #define DEFAULT0_E2_BRB_MAC_PAUSE_XOFF_THR 170
167 #define DEFAULT0_E2_BRB_MAC_PAUSE_XON_THR 250
168 #define DEFAULT0_E2_BRB_MAC_FULL_XOFF_THR 10
169 #define DEFAULT0_E2_BRB_MAC_FULL_XON_THR 50
171 /* BRB thresholds for E2*/
172 #define PFC_E2_BRB_MAC_PAUSE_XOFF_THR_PAUSE 170
173 #define PFC_E2_BRB_MAC_PAUSE_XOFF_THR_NON_PAUSE 0
175 #define PFC_E2_BRB_MAC_PAUSE_XON_THR_PAUSE 250
176 #define PFC_E2_BRB_MAC_PAUSE_XON_THR_NON_PAUSE 0
178 #define PFC_E2_BRB_MAC_FULL_XOFF_THR_PAUSE 10
179 #define PFC_E2_BRB_MAC_FULL_XOFF_THR_NON_PAUSE 90
181 #define PFC_E2_BRB_MAC_FULL_XON_THR_PAUSE 50
182 #define PFC_E2_BRB_MAC_FULL_XON_THR_NON_PAUSE 250
184 /* BRB default for class 0 E3A0 */
185 #define DEFAULT0_E3A0_BRB_MAC_PAUSE_XOFF_THR 290
186 #define DEFAULT0_E3A0_BRB_MAC_PAUSE_XON_THR 410
187 #define DEFAULT0_E3A0_BRB_MAC_FULL_XOFF_THR 10
188 #define DEFAULT0_E3A0_BRB_MAC_FULL_XON_THR 50
190 /* BRB thresholds for E3A0 */
191 #define PFC_E3A0_BRB_MAC_PAUSE_XOFF_THR_PAUSE 290
192 #define PFC_E3A0_BRB_MAC_PAUSE_XOFF_THR_NON_PAUSE 0
194 #define PFC_E3A0_BRB_MAC_PAUSE_XON_THR_PAUSE 410
195 #define PFC_E3A0_BRB_MAC_PAUSE_XON_THR_NON_PAUSE 0
197 #define PFC_E3A0_BRB_MAC_FULL_XOFF_THR_PAUSE 10
198 #define PFC_E3A0_BRB_MAC_FULL_XOFF_THR_NON_PAUSE 170
200 #define PFC_E3A0_BRB_MAC_FULL_XON_THR_PAUSE 50
201 #define PFC_E3A0_BRB_MAC_FULL_XON_THR_NON_PAUSE 410
203 /* BRB default for E3B0 */
204 #define DEFAULT0_E3B0_BRB_MAC_PAUSE_XOFF_THR 330
205 #define DEFAULT0_E3B0_BRB_MAC_PAUSE_XON_THR 490
206 #define DEFAULT0_E3B0_BRB_MAC_FULL_XOFF_THR 15
207 #define DEFAULT0_E3B0_BRB_MAC_FULL_XON_THR 55
209 /* BRB thresholds for E3B0 2 port mode*/
210 #define PFC_E3B0_2P_BRB_MAC_PAUSE_XOFF_THR_PAUSE 1025
211 #define PFC_E3B0_2P_BRB_MAC_PAUSE_XOFF_THR_NON_PAUSE 0
213 #define PFC_E3B0_2P_BRB_MAC_PAUSE_XON_THR_PAUSE 1025
214 #define PFC_E3B0_2P_BRB_MAC_PAUSE_XON_THR_NON_PAUSE 0
216 #define PFC_E3B0_2P_BRB_MAC_FULL_XOFF_THR_PAUSE 10
217 #define PFC_E3B0_2P_BRB_MAC_FULL_XOFF_THR_NON_PAUSE 1025
219 #define PFC_E3B0_2P_BRB_MAC_FULL_XON_THR_PAUSE 50
220 #define PFC_E3B0_2P_BRB_MAC_FULL_XON_THR_NON_PAUSE 1025
223 #define PFC_E3B0_2P_BRB_FULL_LB_XOFF_THR 1025
224 #define PFC_E3B0_2P_BRB_FULL_LB_XON_THR 1025
226 /* Lossy +Lossless GUARANTIED == GUART */
227 #define PFC_E3B0_2P_MIX_PAUSE_LB_GUART 284
228 /* Lossless +Lossless*/
229 #define PFC_E3B0_2P_PAUSE_LB_GUART 236
231 #define PFC_E3B0_2P_NON_PAUSE_LB_GUART 342
234 #define PFC_E3B0_2P_MIX_PAUSE_MAC_0_CLASS_T_GUART 284
235 /* Lossless +Lossless*/
236 #define PFC_E3B0_2P_PAUSE_MAC_0_CLASS_T_GUART 236
238 #define PFC_E3B0_2P_NON_PAUSE_MAC_0_CLASS_T_GUART 336
239 #define PFC_E3B0_2P_BRB_MAC_0_CLASS_T_GUART_HYST 80
241 #define PFC_E3B0_2P_BRB_MAC_1_CLASS_T_GUART 0
242 #define PFC_E3B0_2P_BRB_MAC_1_CLASS_T_GUART_HYST 0
244 /* BRB thresholds for E3B0 4 port mode */
245 #define PFC_E3B0_4P_BRB_MAC_PAUSE_XOFF_THR_PAUSE 304
246 #define PFC_E3B0_4P_BRB_MAC_PAUSE_XOFF_THR_NON_PAUSE 0
248 #define PFC_E3B0_4P_BRB_MAC_PAUSE_XON_THR_PAUSE 384
249 #define PFC_E3B0_4P_BRB_MAC_PAUSE_XON_THR_NON_PAUSE 0
251 #define PFC_E3B0_4P_BRB_MAC_FULL_XOFF_THR_PAUSE 10
252 #define PFC_E3B0_4P_BRB_MAC_FULL_XOFF_THR_NON_PAUSE 304
254 #define PFC_E3B0_4P_BRB_MAC_FULL_XON_THR_PAUSE 50
255 #define PFC_E3B0_4P_BRB_MAC_FULL_XON_THR_NON_PAUSE 384
258 #define PFC_E3B0_4P_BRB_FULL_LB_XOFF_THR 304
259 #define PFC_E3B0_4P_BRB_FULL_LB_XON_THR 384
260 #define PFC_E3B0_4P_LB_GUART 120
262 #define PFC_E3B0_4P_BRB_MAC_0_CLASS_T_GUART 120
263 #define PFC_E3B0_4P_BRB_MAC_0_CLASS_T_GUART_HYST 80
265 #define PFC_E3B0_4P_BRB_MAC_1_CLASS_T_GUART 80
266 #define PFC_E3B0_4P_BRB_MAC_1_CLASS_T_GUART_HYST 120
269 #define DEFAULT_E3B0_BRB_FULL_LB_XOFF_THR 330
270 #define DEFAULT_E3B0_BRB_FULL_LB_XON_THR 490
271 #define DEFAULT_E3B0_LB_GUART 40
273 #define DEFAULT_E3B0_BRB_MAC_0_CLASS_T_GUART 40
274 #define DEFAULT_E3B0_BRB_MAC_0_CLASS_T_GUART_HYST 0
276 #define DEFAULT_E3B0_BRB_MAC_1_CLASS_T_GUART 40
277 #define DEFAULT_E3B0_BRB_MAC_1_CLASS_T_GUART_HYST 0
280 #define DCBX_INVALID_COS (0xFF)
282 #define ETS_BW_LIMIT_CREDIT_UPPER_BOUND (0x5000)
283 #define ETS_BW_LIMIT_CREDIT_WEIGHT (0x5000)
284 #define ETS_E3B0_NIG_MIN_W_VAL_UP_TO_10GBPS (1360)
285 #define ETS_E3B0_NIG_MIN_W_VAL_20GBPS (2720)
286 #define ETS_E3B0_PBF_MIN_W_VAL (10000)
288 #define MAX_PACKET_SIZE (9700)
289 #define WC_UC_TIMEOUT 100
290 #define MAX_KR_LINK_RETRY 4
292 /**********************************************************/
294 /**********************************************************/
296 #define CL22_WR_OVER_CL45(_bp, _phy, _bank, _addr, _val) \
297 bnx2x_cl45_write(_bp, _phy, \
298 (_phy)->def_md_devad, \
299 (_bank + (_addr & 0xf)), \
302 #define CL22_RD_OVER_CL45(_bp, _phy, _bank, _addr, _val) \
303 bnx2x_cl45_read(_bp, _phy, \
304 (_phy)->def_md_devad, \
305 (_bank + (_addr & 0xf)), \
308 static u32
bnx2x_bits_en(struct bnx2x
*bp
, u32 reg
, u32 bits
)
310 u32 val
= REG_RD(bp
, reg
);
313 REG_WR(bp
, reg
, val
);
317 static u32
bnx2x_bits_dis(struct bnx2x
*bp
, u32 reg
, u32 bits
)
319 u32 val
= REG_RD(bp
, reg
);
322 REG_WR(bp
, reg
, val
);
326 /******************************************************************/
327 /* EPIO/GPIO section */
328 /******************************************************************/
329 static void bnx2x_get_epio(struct bnx2x
*bp
, u32 epio_pin
, u32
*en
)
331 u32 epio_mask
, gp_oenable
;
335 DP(NETIF_MSG_LINK
, "Invalid EPIO pin %d to get\n", epio_pin
);
339 epio_mask
= 1 << epio_pin
;
340 /* Set this EPIO to output */
341 gp_oenable
= REG_RD(bp
, MCP_REG_MCPR_GP_OENABLE
);
342 REG_WR(bp
, MCP_REG_MCPR_GP_OENABLE
, gp_oenable
& ~epio_mask
);
344 *en
= (REG_RD(bp
, MCP_REG_MCPR_GP_INPUTS
) & epio_mask
) >> epio_pin
;
346 static void bnx2x_set_epio(struct bnx2x
*bp
, u32 epio_pin
, u32 en
)
348 u32 epio_mask
, gp_output
, gp_oenable
;
352 DP(NETIF_MSG_LINK
, "Invalid EPIO pin %d to set\n", epio_pin
);
355 DP(NETIF_MSG_LINK
, "Setting EPIO pin %d to %d\n", epio_pin
, en
);
356 epio_mask
= 1 << epio_pin
;
357 /* Set this EPIO to output */
358 gp_output
= REG_RD(bp
, MCP_REG_MCPR_GP_OUTPUTS
);
360 gp_output
|= epio_mask
;
362 gp_output
&= ~epio_mask
;
364 REG_WR(bp
, MCP_REG_MCPR_GP_OUTPUTS
, gp_output
);
366 /* Set the value for this EPIO */
367 gp_oenable
= REG_RD(bp
, MCP_REG_MCPR_GP_OENABLE
);
368 REG_WR(bp
, MCP_REG_MCPR_GP_OENABLE
, gp_oenable
| epio_mask
);
371 static void bnx2x_set_cfg_pin(struct bnx2x
*bp
, u32 pin_cfg
, u32 val
)
373 if (pin_cfg
== PIN_CFG_NA
)
375 if (pin_cfg
>= PIN_CFG_EPIO0
) {
376 bnx2x_set_epio(bp
, pin_cfg
- PIN_CFG_EPIO0
, val
);
378 u8 gpio_num
= (pin_cfg
- PIN_CFG_GPIO0_P0
) & 0x3;
379 u8 gpio_port
= (pin_cfg
- PIN_CFG_GPIO0_P0
) >> 2;
380 bnx2x_set_gpio(bp
, gpio_num
, (u8
)val
, gpio_port
);
384 static u32
bnx2x_get_cfg_pin(struct bnx2x
*bp
, u32 pin_cfg
, u32
*val
)
386 if (pin_cfg
== PIN_CFG_NA
)
388 if (pin_cfg
>= PIN_CFG_EPIO0
) {
389 bnx2x_get_epio(bp
, pin_cfg
- PIN_CFG_EPIO0
, val
);
391 u8 gpio_num
= (pin_cfg
- PIN_CFG_GPIO0_P0
) & 0x3;
392 u8 gpio_port
= (pin_cfg
- PIN_CFG_GPIO0_P0
) >> 2;
393 *val
= bnx2x_get_gpio(bp
, gpio_num
, gpio_port
);
398 /******************************************************************/
400 /******************************************************************/
401 static void bnx2x_ets_e2e3a0_disabled(struct link_params
*params
)
403 /* ETS disabled configuration*/
404 struct bnx2x
*bp
= params
->bp
;
406 DP(NETIF_MSG_LINK
, "ETS E2E3 disabled configuration\n");
409 * mapping between entry priority to client number (0,1,2 -debug and
410 * management clients, 3 - COS0 client, 4 - COS client)(HIGHEST)
412 * PRI4 | PRI3 | PRI2 | PRI1 | PRI0
413 * cos1-100 cos0-011 dbg1-010 dbg0-001 MCP-000
416 REG_WR(bp
, NIG_REG_P0_TX_ARB_PRIORITY_CLIENT
, 0x4688);
418 * Bitmap of 5bits length. Each bit specifies whether the entry behaves
419 * as strict. Bits 0,1,2 - debug and management entries, 3 -
420 * COS0 entry, 4 - COS1 entry.
421 * COS1 | COS0 | DEBUG1 | DEBUG0 | MGMT
422 * bit4 bit3 bit2 bit1 bit0
423 * MCP and debug are strict
426 REG_WR(bp
, NIG_REG_P0_TX_ARB_CLIENT_IS_STRICT
, 0x7);
427 /* defines which entries (clients) are subjected to WFQ arbitration */
428 REG_WR(bp
, NIG_REG_P0_TX_ARB_CLIENT_IS_SUBJECT2WFQ
, 0);
430 * For strict priority entries defines the number of consecutive
431 * slots for the highest priority.
433 REG_WR(bp
, NIG_REG_P0_TX_ARB_NUM_STRICT_ARB_SLOTS
, 0x100);
435 * mapping between the CREDIT_WEIGHT registers and actual client
438 REG_WR(bp
, NIG_REG_P0_TX_ARB_CLIENT_CREDIT_MAP
, 0);
439 REG_WR(bp
, NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_0
, 0);
440 REG_WR(bp
, NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_1
, 0);
442 REG_WR(bp
, NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_0
, 0);
443 REG_WR(bp
, NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_1
, 0);
444 REG_WR(bp
, PBF_REG_HIGH_PRIORITY_COS_NUM
, 0);
445 /* ETS mode disable */
446 REG_WR(bp
, PBF_REG_ETS_ENABLED
, 0);
448 * If ETS mode is enabled (there is no strict priority) defines a WFQ
449 * weight for COS0/COS1.
451 REG_WR(bp
, PBF_REG_COS0_WEIGHT
, 0x2710);
452 REG_WR(bp
, PBF_REG_COS1_WEIGHT
, 0x2710);
453 /* Upper bound that COS0_WEIGHT can reach in the WFQ arbiter */
454 REG_WR(bp
, PBF_REG_COS0_UPPER_BOUND
, 0x989680);
455 REG_WR(bp
, PBF_REG_COS1_UPPER_BOUND
, 0x989680);
456 /* Defines the number of consecutive slots for the strict priority */
457 REG_WR(bp
, PBF_REG_NUM_STRICT_ARB_SLOTS
, 0);
459 /******************************************************************************
461 * Getting min_w_val will be set according to line speed .
463 ******************************************************************************/
464 static u32
bnx2x_ets_get_min_w_val_nig(const struct link_vars
*vars
)
467 /* Calculate min_w_val.*/
469 if (vars
->line_speed
== SPEED_20000
)
470 min_w_val
= ETS_E3B0_NIG_MIN_W_VAL_20GBPS
;
472 min_w_val
= ETS_E3B0_NIG_MIN_W_VAL_UP_TO_10GBPS
;
474 min_w_val
= ETS_E3B0_NIG_MIN_W_VAL_20GBPS
;
476 * If the link isn't up (static configuration for example ) The
477 * link will be according to 20GBPS.
481 /******************************************************************************
483 * Getting credit upper bound form min_w_val.
485 ******************************************************************************/
486 static u32
bnx2x_ets_get_credit_upper_bound(const u32 min_w_val
)
488 const u32 credit_upper_bound
= (u32
)MAXVAL((150 * min_w_val
),
490 return credit_upper_bound
;
492 /******************************************************************************
494 * Set credit upper bound for NIG.
496 ******************************************************************************/
497 static void bnx2x_ets_e3b0_set_credit_upper_bound_nig(
498 const struct link_params
*params
,
501 struct bnx2x
*bp
= params
->bp
;
502 const u8 port
= params
->port
;
503 const u32 credit_upper_bound
=
504 bnx2x_ets_get_credit_upper_bound(min_w_val
);
506 REG_WR(bp
, (port
) ? NIG_REG_P1_TX_ARB_CREDIT_UPPER_BOUND_0
:
507 NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_0
, credit_upper_bound
);
508 REG_WR(bp
, (port
) ? NIG_REG_P1_TX_ARB_CREDIT_UPPER_BOUND_1
:
509 NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_1
, credit_upper_bound
);
510 REG_WR(bp
, (port
) ? NIG_REG_P1_TX_ARB_CREDIT_UPPER_BOUND_2
:
511 NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_2
, credit_upper_bound
);
512 REG_WR(bp
, (port
) ? NIG_REG_P1_TX_ARB_CREDIT_UPPER_BOUND_3
:
513 NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_3
, credit_upper_bound
);
514 REG_WR(bp
, (port
) ? NIG_REG_P1_TX_ARB_CREDIT_UPPER_BOUND_4
:
515 NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_4
, credit_upper_bound
);
516 REG_WR(bp
, (port
) ? NIG_REG_P1_TX_ARB_CREDIT_UPPER_BOUND_5
:
517 NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_5
, credit_upper_bound
);
520 REG_WR(bp
, NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_6
,
522 REG_WR(bp
, NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_7
,
524 REG_WR(bp
, NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_8
,
528 /******************************************************************************
530 * Will return the NIG ETS registers to init values.Except
531 * credit_upper_bound.
532 * That isn't used in this configuration (No WFQ is enabled) and will be
533 * configured acording to spec
535 ******************************************************************************/
536 static void bnx2x_ets_e3b0_nig_disabled(const struct link_params
*params
,
537 const struct link_vars
*vars
)
539 struct bnx2x
*bp
= params
->bp
;
540 const u8 port
= params
->port
;
541 const u32 min_w_val
= bnx2x_ets_get_min_w_val_nig(vars
);
543 * mapping between entry priority to client number (0,1,2 -debug and
544 * management clients, 3 - COS0 client, 4 - COS1, ... 8 -
545 * COS5)(HIGHEST) 4bits client num.TODO_ETS - Should be done by
546 * reset value or init tool
549 REG_WR(bp
, NIG_REG_P1_TX_ARB_PRIORITY_CLIENT2_LSB
, 0x543210);
550 REG_WR(bp
, NIG_REG_P1_TX_ARB_PRIORITY_CLIENT2_MSB
, 0x0);
552 REG_WR(bp
, NIG_REG_P0_TX_ARB_PRIORITY_CLIENT2_LSB
, 0x76543210);
553 REG_WR(bp
, NIG_REG_P0_TX_ARB_PRIORITY_CLIENT2_MSB
, 0x8);
556 * For strict priority entries defines the number of consecutive
557 * slots for the highest priority.
559 /* TODO_ETS - Should be done by reset value or init tool */
560 REG_WR(bp
, (port
) ? NIG_REG_P1_TX_ARB_NUM_STRICT_ARB_SLOTS
:
561 NIG_REG_P1_TX_ARB_NUM_STRICT_ARB_SLOTS
, 0x100);
563 * mapping between the CREDIT_WEIGHT registers and actual client
566 /* TODO_ETS - Should be done by reset value or init tool */
569 REG_WR(bp
, NIG_REG_P1_TX_ARB_CLIENT_CREDIT_MAP2_LSB
, 0x210543);
570 REG_WR(bp
, NIG_REG_P1_TX_ARB_CLIENT_CREDIT_MAP2_MSB
, 0x0);
573 REG_WR(bp
, NIG_REG_P0_TX_ARB_CLIENT_CREDIT_MAP2_LSB
,
575 REG_WR(bp
, NIG_REG_P0_TX_ARB_CLIENT_CREDIT_MAP2_MSB
, 0x5);
579 * Bitmap of 5bits length. Each bit specifies whether the entry behaves
580 * as strict. Bits 0,1,2 - debug and management entries, 3 -
581 * COS0 entry, 4 - COS1 entry.
582 * COS1 | COS0 | DEBUG1 | DEBUG0 | MGMT
583 * bit4 bit3 bit2 bit1 bit0
584 * MCP and debug are strict
587 REG_WR(bp
, NIG_REG_P1_TX_ARB_CLIENT_IS_STRICT
, 0x3f);
589 REG_WR(bp
, NIG_REG_P0_TX_ARB_CLIENT_IS_STRICT
, 0x1ff);
590 /* defines which entries (clients) are subjected to WFQ arbitration */
591 REG_WR(bp
, (port
) ? NIG_REG_P1_TX_ARB_CLIENT_IS_SUBJECT2WFQ
:
592 NIG_REG_P0_TX_ARB_CLIENT_IS_SUBJECT2WFQ
, 0);
595 * Please notice the register address are note continuous and a
596 * for here is note appropriate.In 2 port mode port0 only COS0-5
597 * can be used. DEBUG1,DEBUG1,MGMT are never used for WFQ* In 4
598 * port mode port1 only COS0-2 can be used. DEBUG1,DEBUG1,MGMT
599 * are never used for WFQ
601 REG_WR(bp
, (port
) ? NIG_REG_P1_TX_ARB_CREDIT_WEIGHT_0
:
602 NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_0
, 0x0);
603 REG_WR(bp
, (port
) ? NIG_REG_P1_TX_ARB_CREDIT_WEIGHT_1
:
604 NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_1
, 0x0);
605 REG_WR(bp
, (port
) ? NIG_REG_P1_TX_ARB_CREDIT_WEIGHT_2
:
606 NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_2
, 0x0);
607 REG_WR(bp
, (port
) ? NIG_REG_P1_TX_ARB_CREDIT_WEIGHT_3
:
608 NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_3
, 0x0);
609 REG_WR(bp
, (port
) ? NIG_REG_P1_TX_ARB_CREDIT_WEIGHT_4
:
610 NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_4
, 0x0);
611 REG_WR(bp
, (port
) ? NIG_REG_P1_TX_ARB_CREDIT_WEIGHT_5
:
612 NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_5
, 0x0);
614 REG_WR(bp
, NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_6
, 0x0);
615 REG_WR(bp
, NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_7
, 0x0);
616 REG_WR(bp
, NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_8
, 0x0);
619 bnx2x_ets_e3b0_set_credit_upper_bound_nig(params
, min_w_val
);
621 /******************************************************************************
623 * Set credit upper bound for PBF.
625 ******************************************************************************/
626 static void bnx2x_ets_e3b0_set_credit_upper_bound_pbf(
627 const struct link_params
*params
,
630 struct bnx2x
*bp
= params
->bp
;
631 const u32 credit_upper_bound
=
632 bnx2x_ets_get_credit_upper_bound(min_w_val
);
633 const u8 port
= params
->port
;
634 u32 base_upper_bound
= 0;
638 * In 2 port mode port0 has COS0-5 that can be used for WFQ.In 4
639 * port mode port1 has COS0-2 that can be used for WFQ.
642 base_upper_bound
= PBF_REG_COS0_UPPER_BOUND_P0
;
643 max_cos
= DCBX_E3B0_MAX_NUM_COS_PORT0
;
645 base_upper_bound
= PBF_REG_COS0_UPPER_BOUND_P1
;
646 max_cos
= DCBX_E3B0_MAX_NUM_COS_PORT1
;
649 for (i
= 0; i
< max_cos
; i
++)
650 REG_WR(bp
, base_upper_bound
+ (i
<< 2), credit_upper_bound
);
653 /******************************************************************************
655 * Will return the PBF ETS registers to init values.Except
656 * credit_upper_bound.
657 * That isn't used in this configuration (No WFQ is enabled) and will be
658 * configured acording to spec
660 ******************************************************************************/
661 static void bnx2x_ets_e3b0_pbf_disabled(const struct link_params
*params
)
663 struct bnx2x
*bp
= params
->bp
;
664 const u8 port
= params
->port
;
665 const u32 min_w_val_pbf
= ETS_E3B0_PBF_MIN_W_VAL
;
671 * mapping between entry priority to client number 0 - COS0
672 * client, 2 - COS1, ... 5 - COS5)(HIGHEST) 4bits client num.
673 * TODO_ETS - Should be done by reset value or init tool
676 /* 0x688 (|011|0 10|00 1|000) */
677 REG_WR(bp
, PBF_REG_ETS_ARB_PRIORITY_CLIENT_P1
, 0x688);
679 /* (10 1|100 |011|0 10|00 1|000) */
680 REG_WR(bp
, PBF_REG_ETS_ARB_PRIORITY_CLIENT_P0
, 0x2C688);
682 /* TODO_ETS - Should be done by reset value or init tool */
684 /* 0x688 (|011|0 10|00 1|000)*/
685 REG_WR(bp
, PBF_REG_ETS_ARB_CLIENT_CREDIT_MAP_P1
, 0x688);
687 /* 0x2C688 (10 1|100 |011|0 10|00 1|000) */
688 REG_WR(bp
, PBF_REG_ETS_ARB_CLIENT_CREDIT_MAP_P0
, 0x2C688);
690 REG_WR(bp
, (port
) ? PBF_REG_ETS_ARB_NUM_STRICT_ARB_SLOTS_P1
:
691 PBF_REG_ETS_ARB_NUM_STRICT_ARB_SLOTS_P0
, 0x100);
694 REG_WR(bp
, (port
) ? PBF_REG_ETS_ARB_CLIENT_IS_STRICT_P1
:
695 PBF_REG_ETS_ARB_CLIENT_IS_STRICT_P0
, 0);
697 REG_WR(bp
, (port
) ? PBF_REG_ETS_ARB_CLIENT_IS_SUBJECT2WFQ_P1
:
698 PBF_REG_ETS_ARB_CLIENT_IS_SUBJECT2WFQ_P0
, 0);
700 * In 2 port mode port0 has COS0-5 that can be used for WFQ.
701 * In 4 port mode port1 has COS0-2 that can be used for WFQ.
704 base_weight
= PBF_REG_COS0_WEIGHT_P0
;
705 max_cos
= DCBX_E3B0_MAX_NUM_COS_PORT0
;
707 base_weight
= PBF_REG_COS0_WEIGHT_P1
;
708 max_cos
= DCBX_E3B0_MAX_NUM_COS_PORT1
;
711 for (i
= 0; i
< max_cos
; i
++)
712 REG_WR(bp
, base_weight
+ (0x4 * i
), 0);
714 bnx2x_ets_e3b0_set_credit_upper_bound_pbf(params
, min_w_val_pbf
);
716 /******************************************************************************
718 * E3B0 disable will return basicly the values to init values.
720 ******************************************************************************/
721 static int bnx2x_ets_e3b0_disabled(const struct link_params
*params
,
722 const struct link_vars
*vars
)
724 struct bnx2x
*bp
= params
->bp
;
726 if (!CHIP_IS_E3B0(bp
)) {
728 "bnx2x_ets_e3b0_disabled the chip isn't E3B0\n");
732 bnx2x_ets_e3b0_nig_disabled(params
, vars
);
734 bnx2x_ets_e3b0_pbf_disabled(params
);
739 /******************************************************************************
741 * Disable will return basicly the values to init values.
743 ******************************************************************************/
744 int bnx2x_ets_disabled(struct link_params
*params
,
745 struct link_vars
*vars
)
747 struct bnx2x
*bp
= params
->bp
;
748 int bnx2x_status
= 0;
750 if ((CHIP_IS_E2(bp
)) || (CHIP_IS_E3A0(bp
)))
751 bnx2x_ets_e2e3a0_disabled(params
);
752 else if (CHIP_IS_E3B0(bp
))
753 bnx2x_status
= bnx2x_ets_e3b0_disabled(params
, vars
);
755 DP(NETIF_MSG_LINK
, "bnx2x_ets_disabled - chip not supported\n");
762 /******************************************************************************
764 * Set the COS mappimg to SP and BW until this point all the COS are not
766 ******************************************************************************/
767 static int bnx2x_ets_e3b0_cli_map(const struct link_params
*params
,
768 const struct bnx2x_ets_params
*ets_params
,
769 const u8 cos_sp_bitmap
,
770 const u8 cos_bw_bitmap
)
772 struct bnx2x
*bp
= params
->bp
;
773 const u8 port
= params
->port
;
774 const u8 nig_cli_sp_bitmap
= 0x7 | (cos_sp_bitmap
<< 3);
775 const u8 pbf_cli_sp_bitmap
= cos_sp_bitmap
;
776 const u8 nig_cli_subject2wfq_bitmap
= cos_bw_bitmap
<< 3;
777 const u8 pbf_cli_subject2wfq_bitmap
= cos_bw_bitmap
;
779 REG_WR(bp
, (port
) ? NIG_REG_P1_TX_ARB_CLIENT_IS_STRICT
:
780 NIG_REG_P0_TX_ARB_CLIENT_IS_STRICT
, nig_cli_sp_bitmap
);
782 REG_WR(bp
, (port
) ? PBF_REG_ETS_ARB_CLIENT_IS_STRICT_P1
:
783 PBF_REG_ETS_ARB_CLIENT_IS_STRICT_P0
, pbf_cli_sp_bitmap
);
785 REG_WR(bp
, (port
) ? NIG_REG_P1_TX_ARB_CLIENT_IS_SUBJECT2WFQ
:
786 NIG_REG_P0_TX_ARB_CLIENT_IS_SUBJECT2WFQ
,
787 nig_cli_subject2wfq_bitmap
);
789 REG_WR(bp
, (port
) ? PBF_REG_ETS_ARB_CLIENT_IS_SUBJECT2WFQ_P1
:
790 PBF_REG_ETS_ARB_CLIENT_IS_SUBJECT2WFQ_P0
,
791 pbf_cli_subject2wfq_bitmap
);
796 /******************************************************************************
798 * This function is needed because NIG ARB_CREDIT_WEIGHT_X are
799 * not continues and ARB_CREDIT_WEIGHT_0 + offset is suitable.
800 ******************************************************************************/
801 static int bnx2x_ets_e3b0_set_cos_bw(struct bnx2x
*bp
,
803 const u32 min_w_val_nig
,
804 const u32 min_w_val_pbf
,
809 u32 nig_reg_adress_crd_weight
= 0;
810 u32 pbf_reg_adress_crd_weight
= 0;
811 /* Calculate and set BW for this COS - use 1 instead of 0 for BW */
812 const u32 cos_bw_nig
= ((bw
? bw
: 1) * min_w_val_nig
) / total_bw
;
813 const u32 cos_bw_pbf
= ((bw
? bw
: 1) * min_w_val_pbf
) / total_bw
;
817 nig_reg_adress_crd_weight
=
818 (port
) ? NIG_REG_P1_TX_ARB_CREDIT_WEIGHT_0
:
819 NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_0
;
820 pbf_reg_adress_crd_weight
= (port
) ?
821 PBF_REG_COS0_WEIGHT_P1
: PBF_REG_COS0_WEIGHT_P0
;
824 nig_reg_adress_crd_weight
= (port
) ?
825 NIG_REG_P1_TX_ARB_CREDIT_WEIGHT_1
:
826 NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_1
;
827 pbf_reg_adress_crd_weight
= (port
) ?
828 PBF_REG_COS1_WEIGHT_P1
: PBF_REG_COS1_WEIGHT_P0
;
831 nig_reg_adress_crd_weight
= (port
) ?
832 NIG_REG_P1_TX_ARB_CREDIT_WEIGHT_2
:
833 NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_2
;
835 pbf_reg_adress_crd_weight
= (port
) ?
836 PBF_REG_COS2_WEIGHT_P1
: PBF_REG_COS2_WEIGHT_P0
;
841 nig_reg_adress_crd_weight
=
842 NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_3
;
843 pbf_reg_adress_crd_weight
=
844 PBF_REG_COS3_WEIGHT_P0
;
849 nig_reg_adress_crd_weight
=
850 NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_4
;
851 pbf_reg_adress_crd_weight
= PBF_REG_COS4_WEIGHT_P0
;
856 nig_reg_adress_crd_weight
=
857 NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_5
;
858 pbf_reg_adress_crd_weight
= PBF_REG_COS5_WEIGHT_P0
;
862 REG_WR(bp
, nig_reg_adress_crd_weight
, cos_bw_nig
);
864 REG_WR(bp
, pbf_reg_adress_crd_weight
, cos_bw_pbf
);
868 /******************************************************************************
870 * Calculate the total BW.A value of 0 isn't legal.
872 ******************************************************************************/
873 static int bnx2x_ets_e3b0_get_total_bw(
874 const struct link_params
*params
,
875 struct bnx2x_ets_params
*ets_params
,
878 struct bnx2x
*bp
= params
->bp
;
880 u8 is_bw_cos_exist
= 0;
884 /* Calculate total BW requested */
885 for (cos_idx
= 0; cos_idx
< ets_params
->num_of_cos
; cos_idx
++) {
886 if (ets_params
->cos
[cos_idx
].state
== bnx2x_cos_state_bw
) {
888 if (!ets_params
->cos
[cos_idx
].params
.bw_params
.bw
) {
889 DP(NETIF_MSG_LINK
, "bnx2x_ets_E3B0_config BW"
892 * This is to prevent a state when ramrods
895 ets_params
->cos
[cos_idx
].params
.bw_params
.bw
899 ets_params
->cos
[cos_idx
].params
.bw_params
.bw
;
903 /* Check total BW is valid */
904 if ((is_bw_cos_exist
== 1) && (*total_bw
!= 100)) {
905 if (*total_bw
== 0) {
907 "bnx2x_ets_E3B0_config total BW shouldn't be 0\n");
911 "bnx2x_ets_E3B0_config total BW should be 100\n");
913 * We can handle a case whre the BW isn't 100 this can happen
914 * if the TC are joined.
920 /******************************************************************************
922 * Invalidate all the sp_pri_to_cos.
924 ******************************************************************************/
925 static void bnx2x_ets_e3b0_sp_pri_to_cos_init(u8
*sp_pri_to_cos
)
928 for (pri
= 0; pri
< DCBX_MAX_NUM_COS
; pri
++)
929 sp_pri_to_cos
[pri
] = DCBX_INVALID_COS
;
931 /******************************************************************************
933 * Calculate and set the SP (ARB_PRIORITY_CLIENT) NIG and PBF registers
934 * according to sp_pri_to_cos.
936 ******************************************************************************/
937 static int bnx2x_ets_e3b0_sp_pri_to_cos_set(const struct link_params
*params
,
938 u8
*sp_pri_to_cos
, const u8 pri
,
941 struct bnx2x
*bp
= params
->bp
;
942 const u8 port
= params
->port
;
943 const u8 max_num_of_cos
= (port
) ? DCBX_E3B0_MAX_NUM_COS_PORT1
:
944 DCBX_E3B0_MAX_NUM_COS_PORT0
;
946 if (sp_pri_to_cos
[pri
] != DCBX_INVALID_COS
) {
947 DP(NETIF_MSG_LINK
, "bnx2x_ets_e3b0_sp_pri_to_cos_set invalid "
948 "parameter There can't be two COS's with "
949 "the same strict pri\n");
953 if (pri
> max_num_of_cos
) {
954 DP(NETIF_MSG_LINK
, "bnx2x_ets_e3b0_sp_pri_to_cos_set invalid "
955 "parameter Illegal strict priority\n");
959 sp_pri_to_cos
[pri
] = cos_entry
;
964 /******************************************************************************
966 * Returns the correct value according to COS and priority in
967 * the sp_pri_cli register.
969 ******************************************************************************/
970 static u64
bnx2x_e3b0_sp_get_pri_cli_reg(const u8 cos
, const u8 cos_offset
,
976 pri_cli_nig
= ((u64
)(cos
+ cos_offset
)) << (entry_size
*
977 (pri_set
+ pri_offset
));
981 /******************************************************************************
983 * Returns the correct value according to COS and priority in the
984 * sp_pri_cli register for NIG.
986 ******************************************************************************/
987 static u64
bnx2x_e3b0_sp_get_pri_cli_reg_nig(const u8 cos
, const u8 pri_set
)
989 /* MCP Dbg0 and dbg1 are always with higher strict pri*/
990 const u8 nig_cos_offset
= 3;
991 const u8 nig_pri_offset
= 3;
993 return bnx2x_e3b0_sp_get_pri_cli_reg(cos
, nig_cos_offset
, pri_set
,
997 /******************************************************************************
999 * Returns the correct value according to COS and priority in the
1000 * sp_pri_cli register for PBF.
1002 ******************************************************************************/
1003 static u64
bnx2x_e3b0_sp_get_pri_cli_reg_pbf(const u8 cos
, const u8 pri_set
)
1005 const u8 pbf_cos_offset
= 0;
1006 const u8 pbf_pri_offset
= 0;
1008 return bnx2x_e3b0_sp_get_pri_cli_reg(cos
, pbf_cos_offset
, pri_set
,
1013 /******************************************************************************
1015 * Calculate and set the SP (ARB_PRIORITY_CLIENT) NIG and PBF registers
1016 * according to sp_pri_to_cos.(which COS has higher priority)
1018 ******************************************************************************/
1019 static int bnx2x_ets_e3b0_sp_set_pri_cli_reg(const struct link_params
*params
,
1022 struct bnx2x
*bp
= params
->bp
;
1024 const u8 port
= params
->port
;
1025 /* MCP Dbg0 and dbg1 are always with higher strict pri*/
1026 u64 pri_cli_nig
= 0x210;
1027 u32 pri_cli_pbf
= 0x0;
1030 const u8 max_num_of_cos
= (port
) ? DCBX_E3B0_MAX_NUM_COS_PORT1
:
1031 DCBX_E3B0_MAX_NUM_COS_PORT0
;
1033 u8 cos_bit_to_set
= (1 << max_num_of_cos
) - 1;
1035 /* Set all the strict priority first */
1036 for (i
= 0; i
< max_num_of_cos
; i
++) {
1037 if (sp_pri_to_cos
[i
] != DCBX_INVALID_COS
) {
1038 if (sp_pri_to_cos
[i
] >= DCBX_MAX_NUM_COS
) {
1040 "bnx2x_ets_e3b0_sp_set_pri_cli_reg "
1041 "invalid cos entry\n");
1045 pri_cli_nig
|= bnx2x_e3b0_sp_get_pri_cli_reg_nig(
1046 sp_pri_to_cos
[i
], pri_set
);
1048 pri_cli_pbf
|= bnx2x_e3b0_sp_get_pri_cli_reg_pbf(
1049 sp_pri_to_cos
[i
], pri_set
);
1050 pri_bitmask
= 1 << sp_pri_to_cos
[i
];
1051 /* COS is used remove it from bitmap.*/
1052 if (!(pri_bitmask
& cos_bit_to_set
)) {
1054 "bnx2x_ets_e3b0_sp_set_pri_cli_reg "
1055 "invalid There can't be two COS's with"
1056 " the same strict pri\n");
1059 cos_bit_to_set
&= ~pri_bitmask
;
1064 /* Set all the Non strict priority i= COS*/
1065 for (i
= 0; i
< max_num_of_cos
; i
++) {
1066 pri_bitmask
= 1 << i
;
1067 /* Check if COS was already used for SP */
1068 if (pri_bitmask
& cos_bit_to_set
) {
1069 /* COS wasn't used for SP */
1070 pri_cli_nig
|= bnx2x_e3b0_sp_get_pri_cli_reg_nig(
1073 pri_cli_pbf
|= bnx2x_e3b0_sp_get_pri_cli_reg_pbf(
1075 /* COS is used remove it from bitmap.*/
1076 cos_bit_to_set
&= ~pri_bitmask
;
1081 if (pri_set
!= max_num_of_cos
) {
1082 DP(NETIF_MSG_LINK
, "bnx2x_ets_e3b0_sp_set_pri_cli_reg not all "
1083 "entries were set\n");
1088 /* Only 6 usable clients*/
1089 REG_WR(bp
, NIG_REG_P1_TX_ARB_PRIORITY_CLIENT2_LSB
,
1092 REG_WR(bp
, PBF_REG_ETS_ARB_PRIORITY_CLIENT_P1
, pri_cli_pbf
);
1094 /* Only 9 usable clients*/
1095 const u32 pri_cli_nig_lsb
= (u32
) (pri_cli_nig
);
1096 const u32 pri_cli_nig_msb
= (u32
) ((pri_cli_nig
>> 32) & 0xF);
1098 REG_WR(bp
, NIG_REG_P0_TX_ARB_PRIORITY_CLIENT2_LSB
,
1100 REG_WR(bp
, NIG_REG_P0_TX_ARB_PRIORITY_CLIENT2_MSB
,
1103 REG_WR(bp
, PBF_REG_ETS_ARB_PRIORITY_CLIENT_P0
, pri_cli_pbf
);
1108 /******************************************************************************
1110 * Configure the COS to ETS according to BW and SP settings.
1111 ******************************************************************************/
1112 int bnx2x_ets_e3b0_config(const struct link_params
*params
,
1113 const struct link_vars
*vars
,
1114 struct bnx2x_ets_params
*ets_params
)
1116 struct bnx2x
*bp
= params
->bp
;
1117 int bnx2x_status
= 0;
1118 const u8 port
= params
->port
;
1120 const u32 min_w_val_nig
= bnx2x_ets_get_min_w_val_nig(vars
);
1121 const u32 min_w_val_pbf
= ETS_E3B0_PBF_MIN_W_VAL
;
1122 u8 cos_bw_bitmap
= 0;
1123 u8 cos_sp_bitmap
= 0;
1124 u8 sp_pri_to_cos
[DCBX_MAX_NUM_COS
] = {0};
1125 const u8 max_num_of_cos
= (port
) ? DCBX_E3B0_MAX_NUM_COS_PORT1
:
1126 DCBX_E3B0_MAX_NUM_COS_PORT0
;
1129 if (!CHIP_IS_E3B0(bp
)) {
1131 "bnx2x_ets_e3b0_disabled the chip isn't E3B0\n");
1135 if ((ets_params
->num_of_cos
> max_num_of_cos
)) {
1136 DP(NETIF_MSG_LINK
, "bnx2x_ets_E3B0_config the number of COS "
1137 "isn't supported\n");
1141 /* Prepare sp strict priority parameters*/
1142 bnx2x_ets_e3b0_sp_pri_to_cos_init(sp_pri_to_cos
);
1144 /* Prepare BW parameters*/
1145 bnx2x_status
= bnx2x_ets_e3b0_get_total_bw(params
, ets_params
,
1149 "bnx2x_ets_E3B0_config get_total_bw failed\n");
1154 * Upper bound is set according to current link speed (min_w_val
1155 * should be the same for upper bound and COS credit val).
1157 bnx2x_ets_e3b0_set_credit_upper_bound_nig(params
, min_w_val_nig
);
1158 bnx2x_ets_e3b0_set_credit_upper_bound_pbf(params
, min_w_val_pbf
);
1161 for (cos_entry
= 0; cos_entry
< ets_params
->num_of_cos
; cos_entry
++) {
1162 if (bnx2x_cos_state_bw
== ets_params
->cos
[cos_entry
].state
) {
1163 cos_bw_bitmap
|= (1 << cos_entry
);
1165 * The function also sets the BW in HW(not the mappin
1168 bnx2x_status
= bnx2x_ets_e3b0_set_cos_bw(
1169 bp
, cos_entry
, min_w_val_nig
, min_w_val_pbf
,
1171 ets_params
->cos
[cos_entry
].params
.bw_params
.bw
,
1173 } else if (bnx2x_cos_state_strict
==
1174 ets_params
->cos
[cos_entry
].state
){
1175 cos_sp_bitmap
|= (1 << cos_entry
);
1177 bnx2x_status
= bnx2x_ets_e3b0_sp_pri_to_cos_set(
1180 ets_params
->cos
[cos_entry
].params
.sp_params
.pri
,
1185 "bnx2x_ets_e3b0_config cos state not valid\n");
1190 "bnx2x_ets_e3b0_config set cos bw failed\n");
1191 return bnx2x_status
;
1195 /* Set SP register (which COS has higher priority) */
1196 bnx2x_status
= bnx2x_ets_e3b0_sp_set_pri_cli_reg(params
,
1201 "bnx2x_ets_E3B0_config set_pri_cli_reg failed\n");
1202 return bnx2x_status
;
1205 /* Set client mapping of BW and strict */
1206 bnx2x_status
= bnx2x_ets_e3b0_cli_map(params
, ets_params
,
1211 DP(NETIF_MSG_LINK
, "bnx2x_ets_E3B0_config SP failed\n");
1212 return bnx2x_status
;
1216 static void bnx2x_ets_bw_limit_common(const struct link_params
*params
)
1218 /* ETS disabled configuration */
1219 struct bnx2x
*bp
= params
->bp
;
1220 DP(NETIF_MSG_LINK
, "ETS enabled BW limit configuration\n");
1222 * defines which entries (clients) are subjected to WFQ arbitration
1226 REG_WR(bp
, NIG_REG_P0_TX_ARB_CLIENT_IS_SUBJECT2WFQ
, 0x18);
1228 * mapping between the ARB_CREDIT_WEIGHT registers and actual
1229 * client numbers (WEIGHT_0 does not actually have to represent
1231 * PRI4 | PRI3 | PRI2 | PRI1 | PRI0
1232 * cos1-001 cos0-000 dbg1-100 dbg0-011 MCP-010
1234 REG_WR(bp
, NIG_REG_P0_TX_ARB_CLIENT_CREDIT_MAP
, 0x111A);
1236 REG_WR(bp
, NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_0
,
1237 ETS_BW_LIMIT_CREDIT_UPPER_BOUND
);
1238 REG_WR(bp
, NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_1
,
1239 ETS_BW_LIMIT_CREDIT_UPPER_BOUND
);
1241 /* ETS mode enabled*/
1242 REG_WR(bp
, PBF_REG_ETS_ENABLED
, 1);
1244 /* Defines the number of consecutive slots for the strict priority */
1245 REG_WR(bp
, PBF_REG_NUM_STRICT_ARB_SLOTS
, 0);
1247 * Bitmap of 5bits length. Each bit specifies whether the entry behaves
1248 * as strict. Bits 0,1,2 - debug and management entries, 3 - COS0
1249 * entry, 4 - COS1 entry.
1250 * COS1 | COS0 | DEBUG21 | DEBUG0 | MGMT
1251 * bit4 bit3 bit2 bit1 bit0
1252 * MCP and debug are strict
1254 REG_WR(bp
, NIG_REG_P0_TX_ARB_CLIENT_IS_STRICT
, 0x7);
1256 /* Upper bound that COS0_WEIGHT can reach in the WFQ arbiter.*/
1257 REG_WR(bp
, PBF_REG_COS0_UPPER_BOUND
,
1258 ETS_BW_LIMIT_CREDIT_UPPER_BOUND
);
1259 REG_WR(bp
, PBF_REG_COS1_UPPER_BOUND
,
1260 ETS_BW_LIMIT_CREDIT_UPPER_BOUND
);
1263 void bnx2x_ets_bw_limit(const struct link_params
*params
, const u32 cos0_bw
,
1266 /* ETS disabled configuration*/
1267 struct bnx2x
*bp
= params
->bp
;
1268 const u32 total_bw
= cos0_bw
+ cos1_bw
;
1269 u32 cos0_credit_weight
= 0;
1270 u32 cos1_credit_weight
= 0;
1272 DP(NETIF_MSG_LINK
, "ETS enabled BW limit configuration\n");
1277 DP(NETIF_MSG_LINK
, "Total BW can't be zero\n");
1281 cos0_credit_weight
= (cos0_bw
* ETS_BW_LIMIT_CREDIT_WEIGHT
)/
1283 cos1_credit_weight
= (cos1_bw
* ETS_BW_LIMIT_CREDIT_WEIGHT
)/
1286 bnx2x_ets_bw_limit_common(params
);
1288 REG_WR(bp
, NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_0
, cos0_credit_weight
);
1289 REG_WR(bp
, NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_1
, cos1_credit_weight
);
1291 REG_WR(bp
, PBF_REG_COS0_WEIGHT
, cos0_credit_weight
);
1292 REG_WR(bp
, PBF_REG_COS1_WEIGHT
, cos1_credit_weight
);
1295 int bnx2x_ets_strict(const struct link_params
*params
, const u8 strict_cos
)
1297 /* ETS disabled configuration*/
1298 struct bnx2x
*bp
= params
->bp
;
1301 DP(NETIF_MSG_LINK
, "ETS enabled strict configuration\n");
1303 * Bitmap of 5bits length. Each bit specifies whether the entry behaves
1304 * as strict. Bits 0,1,2 - debug and management entries,
1305 * 3 - COS0 entry, 4 - COS1 entry.
1306 * COS1 | COS0 | DEBUG21 | DEBUG0 | MGMT
1307 * bit4 bit3 bit2 bit1 bit0
1308 * MCP and debug are strict
1310 REG_WR(bp
, NIG_REG_P0_TX_ARB_CLIENT_IS_STRICT
, 0x1F);
1312 * For strict priority entries defines the number of consecutive slots
1313 * for the highest priority.
1315 REG_WR(bp
, NIG_REG_P0_TX_ARB_NUM_STRICT_ARB_SLOTS
, 0x100);
1316 /* ETS mode disable */
1317 REG_WR(bp
, PBF_REG_ETS_ENABLED
, 0);
1318 /* Defines the number of consecutive slots for the strict priority */
1319 REG_WR(bp
, PBF_REG_NUM_STRICT_ARB_SLOTS
, 0x100);
1321 /* Defines the number of consecutive slots for the strict priority */
1322 REG_WR(bp
, PBF_REG_HIGH_PRIORITY_COS_NUM
, strict_cos
);
1325 * mapping between entry priority to client number (0,1,2 -debug and
1326 * management clients, 3 - COS0 client, 4 - COS client)(HIGHEST)
1328 * PRI4 | PRI3 | PRI2 | PRI1 | PRI0
1329 * dbg0-010 dbg1-001 cos1-100 cos0-011 MCP-000
1330 * dbg0-010 dbg1-001 cos0-011 cos1-100 MCP-000
1332 val
= (!strict_cos
) ? 0x2318 : 0x22E0;
1333 REG_WR(bp
, NIG_REG_P0_TX_ARB_PRIORITY_CLIENT
, val
);
1337 /******************************************************************/
1339 /******************************************************************/
1340 static void bnx2x_update_pfc_xmac(struct link_params
*params
,
1341 struct link_vars
*vars
,
1344 struct bnx2x
*bp
= params
->bp
;
1346 u32 pause_val
, pfc0_val
, pfc1_val
;
1348 /* XMAC base adrr */
1349 xmac_base
= (params
->port
) ? GRCBASE_XMAC1
: GRCBASE_XMAC0
;
1351 /* Initialize pause and pfc registers */
1352 pause_val
= 0x18000;
1353 pfc0_val
= 0xFFFF8000;
1356 /* No PFC support */
1357 if (!(params
->feature_config_flags
&
1358 FEATURE_CONFIG_PFC_ENABLED
)) {
1361 * RX flow control - Process pause frame in receive direction
1363 if (vars
->flow_ctrl
& BNX2X_FLOW_CTRL_RX
)
1364 pause_val
|= XMAC_PAUSE_CTRL_REG_RX_PAUSE_EN
;
1367 * TX flow control - Send pause packet when buffer is full
1369 if (vars
->flow_ctrl
& BNX2X_FLOW_CTRL_TX
)
1370 pause_val
|= XMAC_PAUSE_CTRL_REG_TX_PAUSE_EN
;
1371 } else {/* PFC support */
1372 pfc1_val
|= XMAC_PFC_CTRL_HI_REG_PFC_REFRESH_EN
|
1373 XMAC_PFC_CTRL_HI_REG_PFC_STATS_EN
|
1374 XMAC_PFC_CTRL_HI_REG_RX_PFC_EN
|
1375 XMAC_PFC_CTRL_HI_REG_TX_PFC_EN
;
1378 /* Write pause and PFC registers */
1379 REG_WR(bp
, xmac_base
+ XMAC_REG_PAUSE_CTRL
, pause_val
);
1380 REG_WR(bp
, xmac_base
+ XMAC_REG_PFC_CTRL
, pfc0_val
);
1381 REG_WR(bp
, xmac_base
+ XMAC_REG_PFC_CTRL_HI
, pfc1_val
);
1384 /* Set MAC address for source TX Pause/PFC frames */
1385 REG_WR(bp
, xmac_base
+ XMAC_REG_CTRL_SA_LO
,
1386 ((params
->mac_addr
[2] << 24) |
1387 (params
->mac_addr
[3] << 16) |
1388 (params
->mac_addr
[4] << 8) |
1389 (params
->mac_addr
[5])));
1390 REG_WR(bp
, xmac_base
+ XMAC_REG_CTRL_SA_HI
,
1391 ((params
->mac_addr
[0] << 8) |
1392 (params
->mac_addr
[1])));
1398 static void bnx2x_emac_get_pfc_stat(struct link_params
*params
,
1399 u32 pfc_frames_sent
[2],
1400 u32 pfc_frames_received
[2])
1402 /* Read pfc statistic */
1403 struct bnx2x
*bp
= params
->bp
;
1404 u32 emac_base
= params
->port
? GRCBASE_EMAC1
: GRCBASE_EMAC0
;
1408 DP(NETIF_MSG_LINK
, "pfc statistic read from EMAC\n");
1410 /* PFC received frames */
1411 val_xoff
= REG_RD(bp
, emac_base
+
1412 EMAC_REG_RX_PFC_STATS_XOFF_RCVD
);
1413 val_xoff
&= EMAC_REG_RX_PFC_STATS_XOFF_RCVD_COUNT
;
1414 val_xon
= REG_RD(bp
, emac_base
+ EMAC_REG_RX_PFC_STATS_XON_RCVD
);
1415 val_xon
&= EMAC_REG_RX_PFC_STATS_XON_RCVD_COUNT
;
1417 pfc_frames_received
[0] = val_xon
+ val_xoff
;
1419 /* PFC received sent */
1420 val_xoff
= REG_RD(bp
, emac_base
+
1421 EMAC_REG_RX_PFC_STATS_XOFF_SENT
);
1422 val_xoff
&= EMAC_REG_RX_PFC_STATS_XOFF_SENT_COUNT
;
1423 val_xon
= REG_RD(bp
, emac_base
+ EMAC_REG_RX_PFC_STATS_XON_SENT
);
1424 val_xon
&= EMAC_REG_RX_PFC_STATS_XON_SENT_COUNT
;
1426 pfc_frames_sent
[0] = val_xon
+ val_xoff
;
1429 /* Read pfc statistic*/
1430 void bnx2x_pfc_statistic(struct link_params
*params
, struct link_vars
*vars
,
1431 u32 pfc_frames_sent
[2],
1432 u32 pfc_frames_received
[2])
1434 /* Read pfc statistic */
1435 struct bnx2x
*bp
= params
->bp
;
1437 DP(NETIF_MSG_LINK
, "pfc statistic\n");
1442 if (vars
->mac_type
== MAC_TYPE_EMAC
) {
1443 DP(NETIF_MSG_LINK
, "About to read PFC stats from EMAC\n");
1444 bnx2x_emac_get_pfc_stat(params
, pfc_frames_sent
,
1445 pfc_frames_received
);
1448 /******************************************************************/
1449 /* MAC/PBF section */
1450 /******************************************************************/
1451 static void bnx2x_set_mdio_clk(struct bnx2x
*bp
, u32 chip_id
, u8 port
)
1453 u32 mode
, emac_base
;
1455 * Set clause 45 mode, slow down the MDIO clock to 2.5MHz
1456 * (a value of 49==0x31) and make sure that the AUTO poll is off
1460 emac_base
= GRCBASE_EMAC0
;
1462 emac_base
= (port
) ? GRCBASE_EMAC1
: GRCBASE_EMAC0
;
1463 mode
= REG_RD(bp
, emac_base
+ EMAC_REG_EMAC_MDIO_MODE
);
1464 mode
&= ~(EMAC_MDIO_MODE_AUTO_POLL
|
1465 EMAC_MDIO_MODE_CLOCK_CNT
);
1466 if (USES_WARPCORE(bp
))
1467 mode
|= (74L << EMAC_MDIO_MODE_CLOCK_CNT_BITSHIFT
);
1469 mode
|= (49L << EMAC_MDIO_MODE_CLOCK_CNT_BITSHIFT
);
1471 mode
|= (EMAC_MDIO_MODE_CLAUSE_45
);
1472 REG_WR(bp
, emac_base
+ EMAC_REG_EMAC_MDIO_MODE
, mode
);
1476 static u8
bnx2x_is_4_port_mode(struct bnx2x
*bp
)
1478 u32 port4mode_ovwr_val
;
1479 /* Check 4-port override enabled */
1480 port4mode_ovwr_val
= REG_RD(bp
, MISC_REG_PORT4MODE_EN_OVWR
);
1481 if (port4mode_ovwr_val
& (1<<0)) {
1482 /* Return 4-port mode override value */
1483 return ((port4mode_ovwr_val
& (1<<1)) == (1<<1));
1485 /* Return 4-port mode from input pin */
1486 return (u8
)REG_RD(bp
, MISC_REG_PORT4MODE_EN
);
1489 static void bnx2x_emac_init(struct link_params
*params
,
1490 struct link_vars
*vars
)
1492 /* reset and unreset the emac core */
1493 struct bnx2x
*bp
= params
->bp
;
1494 u8 port
= params
->port
;
1495 u32 emac_base
= port
? GRCBASE_EMAC1
: GRCBASE_EMAC0
;
1499 REG_WR(bp
, GRCBASE_MISC
+ MISC_REGISTERS_RESET_REG_2_CLEAR
,
1500 (MISC_REGISTERS_RESET_REG_2_RST_EMAC0_HARD_CORE
<< port
));
1502 REG_WR(bp
, GRCBASE_MISC
+ MISC_REGISTERS_RESET_REG_2_SET
,
1503 (MISC_REGISTERS_RESET_REG_2_RST_EMAC0_HARD_CORE
<< port
));
1505 /* init emac - use read-modify-write */
1506 /* self clear reset */
1507 val
= REG_RD(bp
, emac_base
+ EMAC_REG_EMAC_MODE
);
1508 EMAC_WR(bp
, EMAC_REG_EMAC_MODE
, (val
| EMAC_MODE_RESET
));
1512 val
= REG_RD(bp
, emac_base
+ EMAC_REG_EMAC_MODE
);
1513 DP(NETIF_MSG_LINK
, "EMAC reset reg is %u\n", val
);
1515 DP(NETIF_MSG_LINK
, "EMAC timeout!\n");
1519 } while (val
& EMAC_MODE_RESET
);
1520 bnx2x_set_mdio_clk(bp
, params
->chip_id
, port
);
1521 /* Set mac address */
1522 val
= ((params
->mac_addr
[0] << 8) |
1523 params
->mac_addr
[1]);
1524 EMAC_WR(bp
, EMAC_REG_EMAC_MAC_MATCH
, val
);
1526 val
= ((params
->mac_addr
[2] << 24) |
1527 (params
->mac_addr
[3] << 16) |
1528 (params
->mac_addr
[4] << 8) |
1529 params
->mac_addr
[5]);
1530 EMAC_WR(bp
, EMAC_REG_EMAC_MAC_MATCH
+ 4, val
);
1533 static void bnx2x_set_xumac_nig(struct link_params
*params
,
1537 struct bnx2x
*bp
= params
->bp
;
1539 REG_WR(bp
, params
->port
? NIG_REG_P1_MAC_IN_EN
: NIG_REG_P0_MAC_IN_EN
,
1541 REG_WR(bp
, params
->port
? NIG_REG_P1_MAC_OUT_EN
: NIG_REG_P0_MAC_OUT_EN
,
1543 REG_WR(bp
, params
->port
? NIG_REG_P1_MAC_PAUSE_OUT_EN
:
1544 NIG_REG_P0_MAC_PAUSE_OUT_EN
, tx_pause_en
);
1547 static void bnx2x_umac_disable(struct link_params
*params
)
1549 u32 umac_base
= params
->port
? GRCBASE_UMAC1
: GRCBASE_UMAC0
;
1550 struct bnx2x
*bp
= params
->bp
;
1551 if (!(REG_RD(bp
, MISC_REG_RESET_REG_2
) &
1552 (MISC_REGISTERS_RESET_REG_2_UMAC0
<< params
->port
)))
1555 /* Disable RX and TX */
1556 REG_WR(bp
, umac_base
+ UMAC_REG_COMMAND_CONFIG
, 0);
1559 static void bnx2x_umac_enable(struct link_params
*params
,
1560 struct link_vars
*vars
, u8 lb
)
1563 u32 umac_base
= params
->port
? GRCBASE_UMAC1
: GRCBASE_UMAC0
;
1564 struct bnx2x
*bp
= params
->bp
;
1566 REG_WR(bp
, GRCBASE_MISC
+ MISC_REGISTERS_RESET_REG_2_CLEAR
,
1567 (MISC_REGISTERS_RESET_REG_2_UMAC0
<< params
->port
));
1568 usleep_range(1000, 1000);
1570 REG_WR(bp
, GRCBASE_MISC
+ MISC_REGISTERS_RESET_REG_2_SET
,
1571 (MISC_REGISTERS_RESET_REG_2_UMAC0
<< params
->port
));
1573 DP(NETIF_MSG_LINK
, "enabling UMAC\n");
1576 * This register determines on which events the MAC will assert
1577 * error on the i/f to the NIG along w/ EOP.
1581 * BD REG_WR(bp, NIG_REG_P0_MAC_RSV_ERR_MASK +
1582 * params->port*0x14, 0xfffff.
1584 /* This register opens the gate for the UMAC despite its name */
1585 REG_WR(bp
, NIG_REG_EGRESS_EMAC0_PORT
+ params
->port
*4, 1);
1587 val
= UMAC_COMMAND_CONFIG_REG_PROMIS_EN
|
1588 UMAC_COMMAND_CONFIG_REG_PAD_EN
|
1589 UMAC_COMMAND_CONFIG_REG_SW_RESET
|
1590 UMAC_COMMAND_CONFIG_REG_NO_LGTH_CHECK
;
1591 switch (vars
->line_speed
) {
1605 DP(NETIF_MSG_LINK
, "Invalid speed for UMAC %d\n",
1609 if (!(vars
->flow_ctrl
& BNX2X_FLOW_CTRL_TX
))
1610 val
|= UMAC_COMMAND_CONFIG_REG_IGNORE_TX_PAUSE
;
1612 if (!(vars
->flow_ctrl
& BNX2X_FLOW_CTRL_RX
))
1613 val
|= UMAC_COMMAND_CONFIG_REG_PAUSE_IGNORE
;
1615 REG_WR(bp
, umac_base
+ UMAC_REG_COMMAND_CONFIG
, val
);
1618 /* Set MAC address for source TX Pause/PFC frames (under SW reset) */
1619 REG_WR(bp
, umac_base
+ UMAC_REG_MAC_ADDR0
,
1620 ((params
->mac_addr
[2] << 24) |
1621 (params
->mac_addr
[3] << 16) |
1622 (params
->mac_addr
[4] << 8) |
1623 (params
->mac_addr
[5])));
1624 REG_WR(bp
, umac_base
+ UMAC_REG_MAC_ADDR1
,
1625 ((params
->mac_addr
[0] << 8) |
1626 (params
->mac_addr
[1])));
1628 /* Enable RX and TX */
1629 val
&= ~UMAC_COMMAND_CONFIG_REG_PAD_EN
;
1630 val
|= UMAC_COMMAND_CONFIG_REG_TX_ENA
|
1631 UMAC_COMMAND_CONFIG_REG_RX_ENA
;
1632 REG_WR(bp
, umac_base
+ UMAC_REG_COMMAND_CONFIG
, val
);
1635 /* Remove SW Reset */
1636 val
&= ~UMAC_COMMAND_CONFIG_REG_SW_RESET
;
1638 /* Check loopback mode */
1640 val
|= UMAC_COMMAND_CONFIG_REG_LOOP_ENA
;
1641 REG_WR(bp
, umac_base
+ UMAC_REG_COMMAND_CONFIG
, val
);
1644 * Maximum Frame Length (RW). Defines a 14-Bit maximum frame
1645 * length used by the MAC receive logic to check frames.
1647 REG_WR(bp
, umac_base
+ UMAC_REG_MAXFR
, 0x2710);
1648 bnx2x_set_xumac_nig(params
,
1649 ((vars
->flow_ctrl
& BNX2X_FLOW_CTRL_TX
) != 0), 1);
1650 vars
->mac_type
= MAC_TYPE_UMAC
;
1654 /* Define the XMAC mode */
1655 static void bnx2x_xmac_init(struct link_params
*params
, u32 max_speed
)
1657 struct bnx2x
*bp
= params
->bp
;
1658 u32 is_port4mode
= bnx2x_is_4_port_mode(bp
);
1661 * In 4-port mode, need to set the mode only once, so if XMAC is
1662 * already out of reset, it means the mode has already been set,
1663 * and it must not* reset the XMAC again, since it controls both
1667 if ((CHIP_NUM(bp
) == CHIP_NUM_57840
) &&
1668 (REG_RD(bp
, MISC_REG_RESET_REG_2
) &
1669 MISC_REGISTERS_RESET_REG_2_XMAC
)) {
1671 "XMAC already out of reset in 4-port mode\n");
1676 REG_WR(bp
, GRCBASE_MISC
+ MISC_REGISTERS_RESET_REG_2_CLEAR
,
1677 MISC_REGISTERS_RESET_REG_2_XMAC
);
1678 usleep_range(1000, 1000);
1680 REG_WR(bp
, GRCBASE_MISC
+ MISC_REGISTERS_RESET_REG_2_SET
,
1681 MISC_REGISTERS_RESET_REG_2_XMAC
);
1683 DP(NETIF_MSG_LINK
, "Init XMAC to 2 ports x 10G per path\n");
1685 /* Set the number of ports on the system side to up to 2 */
1686 REG_WR(bp
, MISC_REG_XMAC_CORE_PORT_MODE
, 1);
1688 /* Set the number of ports on the Warp Core to 10G */
1689 REG_WR(bp
, MISC_REG_XMAC_PHY_PORT_MODE
, 3);
1691 /* Set the number of ports on the system side to 1 */
1692 REG_WR(bp
, MISC_REG_XMAC_CORE_PORT_MODE
, 0);
1693 if (max_speed
== SPEED_10000
) {
1695 "Init XMAC to 10G x 1 port per path\n");
1696 /* Set the number of ports on the Warp Core to 10G */
1697 REG_WR(bp
, MISC_REG_XMAC_PHY_PORT_MODE
, 3);
1700 "Init XMAC to 20G x 2 ports per path\n");
1701 /* Set the number of ports on the Warp Core to 20G */
1702 REG_WR(bp
, MISC_REG_XMAC_PHY_PORT_MODE
, 1);
1706 REG_WR(bp
, GRCBASE_MISC
+ MISC_REGISTERS_RESET_REG_2_CLEAR
,
1707 MISC_REGISTERS_RESET_REG_2_XMAC_SOFT
);
1708 usleep_range(1000, 1000);
1710 REG_WR(bp
, GRCBASE_MISC
+ MISC_REGISTERS_RESET_REG_2_SET
,
1711 MISC_REGISTERS_RESET_REG_2_XMAC_SOFT
);
1715 static void bnx2x_xmac_disable(struct link_params
*params
)
1717 u8 port
= params
->port
;
1718 struct bnx2x
*bp
= params
->bp
;
1719 u32 pfc_ctrl
, xmac_base
= (port
) ? GRCBASE_XMAC1
: GRCBASE_XMAC0
;
1721 if (REG_RD(bp
, MISC_REG_RESET_REG_2
) &
1722 MISC_REGISTERS_RESET_REG_2_XMAC
) {
1724 * Send an indication to change the state in the NIG back to XON
1725 * Clearing this bit enables the next set of this bit to get
1728 pfc_ctrl
= REG_RD(bp
, xmac_base
+ XMAC_REG_PFC_CTRL_HI
);
1729 REG_WR(bp
, xmac_base
+ XMAC_REG_PFC_CTRL_HI
,
1730 (pfc_ctrl
& ~(1<<1)));
1731 REG_WR(bp
, xmac_base
+ XMAC_REG_PFC_CTRL_HI
,
1732 (pfc_ctrl
| (1<<1)));
1733 DP(NETIF_MSG_LINK
, "Disable XMAC on port %x\n", port
);
1734 REG_WR(bp
, xmac_base
+ XMAC_REG_CTRL
, 0);
1738 static int bnx2x_xmac_enable(struct link_params
*params
,
1739 struct link_vars
*vars
, u8 lb
)
1742 struct bnx2x
*bp
= params
->bp
;
1743 DP(NETIF_MSG_LINK
, "enabling XMAC\n");
1745 xmac_base
= (params
->port
) ? GRCBASE_XMAC1
: GRCBASE_XMAC0
;
1747 bnx2x_xmac_init(params
, vars
->line_speed
);
1750 * This register determines on which events the MAC will assert
1751 * error on the i/f to the NIG along w/ EOP.
1755 * This register tells the NIG whether to send traffic to UMAC
1758 REG_WR(bp
, NIG_REG_EGRESS_EMAC0_PORT
+ params
->port
*4, 0);
1760 /* Set Max packet size */
1761 REG_WR(bp
, xmac_base
+ XMAC_REG_RX_MAX_SIZE
, 0x2710);
1763 /* CRC append for Tx packets */
1764 REG_WR(bp
, xmac_base
+ XMAC_REG_TX_CTRL
, 0xC800);
1767 bnx2x_update_pfc_xmac(params
, vars
, 0);
1769 /* Enable TX and RX */
1770 val
= XMAC_CTRL_REG_TX_EN
| XMAC_CTRL_REG_RX_EN
;
1772 /* Check loopback mode */
1774 val
|= XMAC_CTRL_REG_LINE_LOCAL_LPBK
;
1775 REG_WR(bp
, xmac_base
+ XMAC_REG_CTRL
, val
);
1776 bnx2x_set_xumac_nig(params
,
1777 ((vars
->flow_ctrl
& BNX2X_FLOW_CTRL_TX
) != 0), 1);
1779 vars
->mac_type
= MAC_TYPE_XMAC
;
1784 static int bnx2x_emac_enable(struct link_params
*params
,
1785 struct link_vars
*vars
, u8 lb
)
1787 struct bnx2x
*bp
= params
->bp
;
1788 u8 port
= params
->port
;
1789 u32 emac_base
= port
? GRCBASE_EMAC1
: GRCBASE_EMAC0
;
1792 DP(NETIF_MSG_LINK
, "enabling EMAC\n");
1795 REG_WR(bp
, GRCBASE_MISC
+ MISC_REGISTERS_RESET_REG_2_CLEAR
,
1796 (MISC_REGISTERS_RESET_REG_2_RST_BMAC0
<< port
));
1798 /* enable emac and not bmac */
1799 REG_WR(bp
, NIG_REG_EGRESS_EMAC0_PORT
+ port
*4, 1);
1802 if (vars
->phy_flags
& PHY_XGXS_FLAG
) {
1803 u32 ser_lane
= ((params
->lane_config
&
1804 PORT_HW_CFG_LANE_SWAP_CFG_MASTER_MASK
) >>
1805 PORT_HW_CFG_LANE_SWAP_CFG_MASTER_SHIFT
);
1807 DP(NETIF_MSG_LINK
, "XGXS\n");
1808 /* select the master lanes (out of 0-3) */
1809 REG_WR(bp
, NIG_REG_XGXS_LANE_SEL_P0
+ port
*4, ser_lane
);
1811 REG_WR(bp
, NIG_REG_XGXS_SERDES0_MODE_SEL
+ port
*4, 1);
1813 } else { /* SerDes */
1814 DP(NETIF_MSG_LINK
, "SerDes\n");
1816 REG_WR(bp
, NIG_REG_XGXS_SERDES0_MODE_SEL
+ port
*4, 0);
1819 bnx2x_bits_en(bp
, emac_base
+ EMAC_REG_EMAC_RX_MODE
,
1820 EMAC_RX_MODE_RESET
);
1821 bnx2x_bits_en(bp
, emac_base
+ EMAC_REG_EMAC_TX_MODE
,
1822 EMAC_TX_MODE_RESET
);
1824 if (CHIP_REV_IS_SLOW(bp
)) {
1825 /* config GMII mode */
1826 val
= REG_RD(bp
, emac_base
+ EMAC_REG_EMAC_MODE
);
1827 EMAC_WR(bp
, EMAC_REG_EMAC_MODE
, (val
| EMAC_MODE_PORT_GMII
));
1829 /* pause enable/disable */
1830 bnx2x_bits_dis(bp
, emac_base
+ EMAC_REG_EMAC_RX_MODE
,
1831 EMAC_RX_MODE_FLOW_EN
);
1833 bnx2x_bits_dis(bp
, emac_base
+ EMAC_REG_EMAC_TX_MODE
,
1834 (EMAC_TX_MODE_EXT_PAUSE_EN
|
1835 EMAC_TX_MODE_FLOW_EN
));
1836 if (!(params
->feature_config_flags
&
1837 FEATURE_CONFIG_PFC_ENABLED
)) {
1838 if (vars
->flow_ctrl
& BNX2X_FLOW_CTRL_RX
)
1839 bnx2x_bits_en(bp
, emac_base
+
1840 EMAC_REG_EMAC_RX_MODE
,
1841 EMAC_RX_MODE_FLOW_EN
);
1843 if (vars
->flow_ctrl
& BNX2X_FLOW_CTRL_TX
)
1844 bnx2x_bits_en(bp
, emac_base
+
1845 EMAC_REG_EMAC_TX_MODE
,
1846 (EMAC_TX_MODE_EXT_PAUSE_EN
|
1847 EMAC_TX_MODE_FLOW_EN
));
1849 bnx2x_bits_en(bp
, emac_base
+ EMAC_REG_EMAC_TX_MODE
,
1850 EMAC_TX_MODE_FLOW_EN
);
1853 /* KEEP_VLAN_TAG, promiscuous */
1854 val
= REG_RD(bp
, emac_base
+ EMAC_REG_EMAC_RX_MODE
);
1855 val
|= EMAC_RX_MODE_KEEP_VLAN_TAG
| EMAC_RX_MODE_PROMISCUOUS
;
1858 * Setting this bit causes MAC control frames (except for pause
1859 * frames) to be passed on for processing. This setting has no
1860 * affect on the operation of the pause frames. This bit effects
1861 * all packets regardless of RX Parser packet sorting logic.
1862 * Turn the PFC off to make sure we are in Xon state before
1865 EMAC_WR(bp
, EMAC_REG_RX_PFC_MODE
, 0);
1866 if (params
->feature_config_flags
& FEATURE_CONFIG_PFC_ENABLED
) {
1867 DP(NETIF_MSG_LINK
, "PFC is enabled\n");
1868 /* Enable PFC again */
1869 EMAC_WR(bp
, EMAC_REG_RX_PFC_MODE
,
1870 EMAC_REG_RX_PFC_MODE_RX_EN
|
1871 EMAC_REG_RX_PFC_MODE_TX_EN
|
1872 EMAC_REG_RX_PFC_MODE_PRIORITIES
);
1874 EMAC_WR(bp
, EMAC_REG_RX_PFC_PARAM
,
1876 EMAC_REG_RX_PFC_PARAM_OPCODE_BITSHIFT
) |
1878 EMAC_REG_RX_PFC_PARAM_PRIORITY_EN_BITSHIFT
)));
1879 val
|= EMAC_RX_MODE_KEEP_MAC_CONTROL
;
1881 EMAC_WR(bp
, EMAC_REG_EMAC_RX_MODE
, val
);
1884 val
= REG_RD(bp
, emac_base
+ EMAC_REG_EMAC_MODE
);
1889 EMAC_WR(bp
, EMAC_REG_EMAC_MODE
, val
);
1892 REG_WR(bp
, NIG_REG_NIG_EMAC0_EN
+ port
*4, 1);
1894 /* enable emac for jumbo packets */
1895 EMAC_WR(bp
, EMAC_REG_EMAC_RX_MTU_SIZE
,
1896 (EMAC_RX_MTU_SIZE_JUMBO_ENA
|
1897 (ETH_MAX_JUMBO_PACKET_SIZE
+ ETH_OVREHEAD
)));
1900 REG_WR(bp
, NIG_REG_NIG_INGRESS_EMAC0_NO_CRC
+ port
*4, 0x1);
1902 /* disable the NIG in/out to the bmac */
1903 REG_WR(bp
, NIG_REG_BMAC0_IN_EN
+ port
*4, 0x0);
1904 REG_WR(bp
, NIG_REG_BMAC0_PAUSE_OUT_EN
+ port
*4, 0x0);
1905 REG_WR(bp
, NIG_REG_BMAC0_OUT_EN
+ port
*4, 0x0);
1907 /* enable the NIG in/out to the emac */
1908 REG_WR(bp
, NIG_REG_EMAC0_IN_EN
+ port
*4, 0x1);
1910 if ((params
->feature_config_flags
&
1911 FEATURE_CONFIG_PFC_ENABLED
) ||
1912 (vars
->flow_ctrl
& BNX2X_FLOW_CTRL_TX
))
1915 REG_WR(bp
, NIG_REG_EMAC0_PAUSE_OUT_EN
+ port
*4, val
);
1916 REG_WR(bp
, NIG_REG_EGRESS_EMAC0_OUT_EN
+ port
*4, 0x1);
1918 REG_WR(bp
, NIG_REG_BMAC0_REGS_OUT_EN
+ port
*4, 0x0);
1920 vars
->mac_type
= MAC_TYPE_EMAC
;
1924 static void bnx2x_update_pfc_bmac1(struct link_params
*params
,
1925 struct link_vars
*vars
)
1928 struct bnx2x
*bp
= params
->bp
;
1929 u32 bmac_addr
= params
->port
? NIG_REG_INGRESS_BMAC1_MEM
:
1930 NIG_REG_INGRESS_BMAC0_MEM
;
1933 if ((!(params
->feature_config_flags
&
1934 FEATURE_CONFIG_PFC_ENABLED
)) &&
1935 (vars
->flow_ctrl
& BNX2X_FLOW_CTRL_RX
))
1936 /* Enable BigMAC to react on received Pause packets */
1940 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC_REGISTER_RX_CONTROL
, wb_data
, 2);
1944 if (!(params
->feature_config_flags
&
1945 FEATURE_CONFIG_PFC_ENABLED
) &&
1946 (vars
->flow_ctrl
& BNX2X_FLOW_CTRL_TX
))
1950 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC_REGISTER_TX_CONTROL
, wb_data
, 2);
1953 static void bnx2x_update_pfc_bmac2(struct link_params
*params
,
1954 struct link_vars
*vars
,
1958 * Set rx control: Strip CRC and enable BigMAC to relay
1959 * control packets to the system as well
1962 struct bnx2x
*bp
= params
->bp
;
1963 u32 bmac_addr
= params
->port
? NIG_REG_INGRESS_BMAC1_MEM
:
1964 NIG_REG_INGRESS_BMAC0_MEM
;
1967 if ((!(params
->feature_config_flags
&
1968 FEATURE_CONFIG_PFC_ENABLED
)) &&
1969 (vars
->flow_ctrl
& BNX2X_FLOW_CTRL_RX
))
1970 /* Enable BigMAC to react on received Pause packets */
1974 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC2_REGISTER_RX_CONTROL
, wb_data
, 2);
1979 if (!(params
->feature_config_flags
&
1980 FEATURE_CONFIG_PFC_ENABLED
) &&
1981 (vars
->flow_ctrl
& BNX2X_FLOW_CTRL_TX
))
1985 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC2_REGISTER_TX_CONTROL
, wb_data
, 2);
1987 if (params
->feature_config_flags
& FEATURE_CONFIG_PFC_ENABLED
) {
1988 DP(NETIF_MSG_LINK
, "PFC is enabled\n");
1989 /* Enable PFC RX & TX & STATS and set 8 COS */
1991 wb_data
[0] |= (1<<0); /* RX */
1992 wb_data
[0] |= (1<<1); /* TX */
1993 wb_data
[0] |= (1<<2); /* Force initial Xon */
1994 wb_data
[0] |= (1<<3); /* 8 cos */
1995 wb_data
[0] |= (1<<5); /* STATS */
1997 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC2_REGISTER_PFC_CONTROL
,
1999 /* Clear the force Xon */
2000 wb_data
[0] &= ~(1<<2);
2002 DP(NETIF_MSG_LINK
, "PFC is disabled\n");
2003 /* disable PFC RX & TX & STATS and set 8 COS */
2008 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC2_REGISTER_PFC_CONTROL
, wb_data
, 2);
2011 * Set Time (based unit is 512 bit time) between automatic
2012 * re-sending of PP packets amd enable automatic re-send of
2013 * Per-Priroity Packet as long as pp_gen is asserted and
2014 * pp_disable is low.
2017 if (params
->feature_config_flags
& FEATURE_CONFIG_PFC_ENABLED
)
2018 val
|= (1<<16); /* enable automatic re-send */
2022 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC2_REGISTER_TX_PAUSE_CONTROL
,
2026 val
= 0x3; /* Enable RX and TX */
2028 val
|= 0x4; /* Local loopback */
2029 DP(NETIF_MSG_LINK
, "enable bmac loopback\n");
2031 /* When PFC enabled, Pass pause frames towards the NIG. */
2032 if (params
->feature_config_flags
& FEATURE_CONFIG_PFC_ENABLED
)
2033 val
|= ((1<<6)|(1<<5));
2037 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC2_REGISTER_BMAC_CONTROL
, wb_data
, 2);
2040 /* PFC BRB internal port configuration params */
2041 struct bnx2x_pfc_brb_threshold_val
{
2048 struct bnx2x_pfc_brb_e3b0_val
{
2049 u32 per_class_guaranty_mode
;
2050 u32 lb_guarantied_hyst
;
2051 u32 full_lb_xoff_th
;
2052 u32 full_lb_xon_threshold
;
2054 u32 mac_0_class_t_guarantied
;
2055 u32 mac_0_class_t_guarantied_hyst
;
2056 u32 mac_1_class_t_guarantied
;
2057 u32 mac_1_class_t_guarantied_hyst
;
2060 struct bnx2x_pfc_brb_th_val
{
2061 struct bnx2x_pfc_brb_threshold_val pauseable_th
;
2062 struct bnx2x_pfc_brb_threshold_val non_pauseable_th
;
2063 struct bnx2x_pfc_brb_threshold_val default_class0
;
2064 struct bnx2x_pfc_brb_threshold_val default_class1
;
2067 static int bnx2x_pfc_brb_get_config_params(
2068 struct link_params
*params
,
2069 struct bnx2x_pfc_brb_th_val
*config_val
)
2071 struct bnx2x
*bp
= params
->bp
;
2072 DP(NETIF_MSG_LINK
, "Setting PFC BRB configuration\n");
2074 config_val
->default_class1
.pause_xoff
= 0;
2075 config_val
->default_class1
.pause_xon
= 0;
2076 config_val
->default_class1
.full_xoff
= 0;
2077 config_val
->default_class1
.full_xon
= 0;
2079 if (CHIP_IS_E2(bp
)) {
2080 /* class0 defaults */
2081 config_val
->default_class0
.pause_xoff
=
2082 DEFAULT0_E2_BRB_MAC_PAUSE_XOFF_THR
;
2083 config_val
->default_class0
.pause_xon
=
2084 DEFAULT0_E2_BRB_MAC_PAUSE_XON_THR
;
2085 config_val
->default_class0
.full_xoff
=
2086 DEFAULT0_E2_BRB_MAC_FULL_XOFF_THR
;
2087 config_val
->default_class0
.full_xon
=
2088 DEFAULT0_E2_BRB_MAC_FULL_XON_THR
;
2090 config_val
->pauseable_th
.pause_xoff
=
2091 PFC_E2_BRB_MAC_PAUSE_XOFF_THR_PAUSE
;
2092 config_val
->pauseable_th
.pause_xon
=
2093 PFC_E2_BRB_MAC_PAUSE_XON_THR_PAUSE
;
2094 config_val
->pauseable_th
.full_xoff
=
2095 PFC_E2_BRB_MAC_FULL_XOFF_THR_PAUSE
;
2096 config_val
->pauseable_th
.full_xon
=
2097 PFC_E2_BRB_MAC_FULL_XON_THR_PAUSE
;
2099 config_val
->non_pauseable_th
.pause_xoff
=
2100 PFC_E2_BRB_MAC_PAUSE_XOFF_THR_NON_PAUSE
;
2101 config_val
->non_pauseable_th
.pause_xon
=
2102 PFC_E2_BRB_MAC_PAUSE_XON_THR_NON_PAUSE
;
2103 config_val
->non_pauseable_th
.full_xoff
=
2104 PFC_E2_BRB_MAC_FULL_XOFF_THR_NON_PAUSE
;
2105 config_val
->non_pauseable_th
.full_xon
=
2106 PFC_E2_BRB_MAC_FULL_XON_THR_NON_PAUSE
;
2107 } else if (CHIP_IS_E3A0(bp
)) {
2108 /* class0 defaults */
2109 config_val
->default_class0
.pause_xoff
=
2110 DEFAULT0_E3A0_BRB_MAC_PAUSE_XOFF_THR
;
2111 config_val
->default_class0
.pause_xon
=
2112 DEFAULT0_E3A0_BRB_MAC_PAUSE_XON_THR
;
2113 config_val
->default_class0
.full_xoff
=
2114 DEFAULT0_E3A0_BRB_MAC_FULL_XOFF_THR
;
2115 config_val
->default_class0
.full_xon
=
2116 DEFAULT0_E3A0_BRB_MAC_FULL_XON_THR
;
2118 config_val
->pauseable_th
.pause_xoff
=
2119 PFC_E3A0_BRB_MAC_PAUSE_XOFF_THR_PAUSE
;
2120 config_val
->pauseable_th
.pause_xon
=
2121 PFC_E3A0_BRB_MAC_PAUSE_XON_THR_PAUSE
;
2122 config_val
->pauseable_th
.full_xoff
=
2123 PFC_E3A0_BRB_MAC_FULL_XOFF_THR_PAUSE
;
2124 config_val
->pauseable_th
.full_xon
=
2125 PFC_E3A0_BRB_MAC_FULL_XON_THR_PAUSE
;
2127 config_val
->non_pauseable_th
.pause_xoff
=
2128 PFC_E3A0_BRB_MAC_PAUSE_XOFF_THR_NON_PAUSE
;
2129 config_val
->non_pauseable_th
.pause_xon
=
2130 PFC_E3A0_BRB_MAC_PAUSE_XON_THR_NON_PAUSE
;
2131 config_val
->non_pauseable_th
.full_xoff
=
2132 PFC_E3A0_BRB_MAC_FULL_XOFF_THR_NON_PAUSE
;
2133 config_val
->non_pauseable_th
.full_xon
=
2134 PFC_E3A0_BRB_MAC_FULL_XON_THR_NON_PAUSE
;
2135 } else if (CHIP_IS_E3B0(bp
)) {
2136 /* class0 defaults */
2137 config_val
->default_class0
.pause_xoff
=
2138 DEFAULT0_E3B0_BRB_MAC_PAUSE_XOFF_THR
;
2139 config_val
->default_class0
.pause_xon
=
2140 DEFAULT0_E3B0_BRB_MAC_PAUSE_XON_THR
;
2141 config_val
->default_class0
.full_xoff
=
2142 DEFAULT0_E3B0_BRB_MAC_FULL_XOFF_THR
;
2143 config_val
->default_class0
.full_xon
=
2144 DEFAULT0_E3B0_BRB_MAC_FULL_XON_THR
;
2146 if (params
->phy
[INT_PHY
].flags
&
2147 FLAGS_4_PORT_MODE
) {
2148 config_val
->pauseable_th
.pause_xoff
=
2149 PFC_E3B0_4P_BRB_MAC_PAUSE_XOFF_THR_PAUSE
;
2150 config_val
->pauseable_th
.pause_xon
=
2151 PFC_E3B0_4P_BRB_MAC_PAUSE_XON_THR_PAUSE
;
2152 config_val
->pauseable_th
.full_xoff
=
2153 PFC_E3B0_4P_BRB_MAC_FULL_XOFF_THR_PAUSE
;
2154 config_val
->pauseable_th
.full_xon
=
2155 PFC_E3B0_4P_BRB_MAC_FULL_XON_THR_PAUSE
;
2157 config_val
->non_pauseable_th
.pause_xoff
=
2158 PFC_E3B0_4P_BRB_MAC_PAUSE_XOFF_THR_NON_PAUSE
;
2159 config_val
->non_pauseable_th
.pause_xon
=
2160 PFC_E3B0_4P_BRB_MAC_PAUSE_XON_THR_NON_PAUSE
;
2161 config_val
->non_pauseable_th
.full_xoff
=
2162 PFC_E3B0_4P_BRB_MAC_FULL_XOFF_THR_NON_PAUSE
;
2163 config_val
->non_pauseable_th
.full_xon
=
2164 PFC_E3B0_4P_BRB_MAC_FULL_XON_THR_NON_PAUSE
;
2166 config_val
->pauseable_th
.pause_xoff
=
2167 PFC_E3B0_2P_BRB_MAC_PAUSE_XOFF_THR_PAUSE
;
2168 config_val
->pauseable_th
.pause_xon
=
2169 PFC_E3B0_2P_BRB_MAC_PAUSE_XON_THR_PAUSE
;
2170 config_val
->pauseable_th
.full_xoff
=
2171 PFC_E3B0_2P_BRB_MAC_FULL_XOFF_THR_PAUSE
;
2172 config_val
->pauseable_th
.full_xon
=
2173 PFC_E3B0_2P_BRB_MAC_FULL_XON_THR_PAUSE
;
2175 config_val
->non_pauseable_th
.pause_xoff
=
2176 PFC_E3B0_2P_BRB_MAC_PAUSE_XOFF_THR_NON_PAUSE
;
2177 config_val
->non_pauseable_th
.pause_xon
=
2178 PFC_E3B0_2P_BRB_MAC_PAUSE_XON_THR_NON_PAUSE
;
2179 config_val
->non_pauseable_th
.full_xoff
=
2180 PFC_E3B0_2P_BRB_MAC_FULL_XOFF_THR_NON_PAUSE
;
2181 config_val
->non_pauseable_th
.full_xon
=
2182 PFC_E3B0_2P_BRB_MAC_FULL_XON_THR_NON_PAUSE
;
2190 static void bnx2x_pfc_brb_get_e3b0_config_params(
2191 struct link_params
*params
,
2192 struct bnx2x_pfc_brb_e3b0_val
2194 struct bnx2x_nig_brb_pfc_port_params
*pfc_params
,
2195 const u8 pfc_enabled
)
2197 if (pfc_enabled
&& pfc_params
) {
2198 e3b0_val
->per_class_guaranty_mode
= 1;
2199 e3b0_val
->lb_guarantied_hyst
= 80;
2201 if (params
->phy
[INT_PHY
].flags
&
2202 FLAGS_4_PORT_MODE
) {
2203 e3b0_val
->full_lb_xoff_th
=
2204 PFC_E3B0_4P_BRB_FULL_LB_XOFF_THR
;
2205 e3b0_val
->full_lb_xon_threshold
=
2206 PFC_E3B0_4P_BRB_FULL_LB_XON_THR
;
2207 e3b0_val
->lb_guarantied
=
2208 PFC_E3B0_4P_LB_GUART
;
2209 e3b0_val
->mac_0_class_t_guarantied
=
2210 PFC_E3B0_4P_BRB_MAC_0_CLASS_T_GUART
;
2211 e3b0_val
->mac_0_class_t_guarantied_hyst
=
2212 PFC_E3B0_4P_BRB_MAC_0_CLASS_T_GUART_HYST
;
2213 e3b0_val
->mac_1_class_t_guarantied
=
2214 PFC_E3B0_4P_BRB_MAC_1_CLASS_T_GUART
;
2215 e3b0_val
->mac_1_class_t_guarantied_hyst
=
2216 PFC_E3B0_4P_BRB_MAC_1_CLASS_T_GUART_HYST
;
2218 e3b0_val
->full_lb_xoff_th
=
2219 PFC_E3B0_2P_BRB_FULL_LB_XOFF_THR
;
2220 e3b0_val
->full_lb_xon_threshold
=
2221 PFC_E3B0_2P_BRB_FULL_LB_XON_THR
;
2222 e3b0_val
->mac_0_class_t_guarantied_hyst
=
2223 PFC_E3B0_2P_BRB_MAC_0_CLASS_T_GUART_HYST
;
2224 e3b0_val
->mac_1_class_t_guarantied
=
2225 PFC_E3B0_2P_BRB_MAC_1_CLASS_T_GUART
;
2226 e3b0_val
->mac_1_class_t_guarantied_hyst
=
2227 PFC_E3B0_2P_BRB_MAC_1_CLASS_T_GUART_HYST
;
2229 if (pfc_params
->cos0_pauseable
!=
2230 pfc_params
->cos1_pauseable
) {
2231 /* nonpauseable= Lossy + pauseable = Lossless*/
2232 e3b0_val
->lb_guarantied
=
2233 PFC_E3B0_2P_MIX_PAUSE_LB_GUART
;
2234 e3b0_val
->mac_0_class_t_guarantied
=
2235 PFC_E3B0_2P_MIX_PAUSE_MAC_0_CLASS_T_GUART
;
2236 } else if (pfc_params
->cos0_pauseable
) {
2237 /* Lossless +Lossless*/
2238 e3b0_val
->lb_guarantied
=
2239 PFC_E3B0_2P_PAUSE_LB_GUART
;
2240 e3b0_val
->mac_0_class_t_guarantied
=
2241 PFC_E3B0_2P_PAUSE_MAC_0_CLASS_T_GUART
;
2244 e3b0_val
->lb_guarantied
=
2245 PFC_E3B0_2P_NON_PAUSE_LB_GUART
;
2246 e3b0_val
->mac_0_class_t_guarantied
=
2247 PFC_E3B0_2P_NON_PAUSE_MAC_0_CLASS_T_GUART
;
2251 e3b0_val
->per_class_guaranty_mode
= 0;
2252 e3b0_val
->lb_guarantied_hyst
= 0;
2253 e3b0_val
->full_lb_xoff_th
=
2254 DEFAULT_E3B0_BRB_FULL_LB_XOFF_THR
;
2255 e3b0_val
->full_lb_xon_threshold
=
2256 DEFAULT_E3B0_BRB_FULL_LB_XON_THR
;
2257 e3b0_val
->lb_guarantied
=
2258 DEFAULT_E3B0_LB_GUART
;
2259 e3b0_val
->mac_0_class_t_guarantied
=
2260 DEFAULT_E3B0_BRB_MAC_0_CLASS_T_GUART
;
2261 e3b0_val
->mac_0_class_t_guarantied_hyst
=
2262 DEFAULT_E3B0_BRB_MAC_0_CLASS_T_GUART_HYST
;
2263 e3b0_val
->mac_1_class_t_guarantied
=
2264 DEFAULT_E3B0_BRB_MAC_1_CLASS_T_GUART
;
2265 e3b0_val
->mac_1_class_t_guarantied_hyst
=
2266 DEFAULT_E3B0_BRB_MAC_1_CLASS_T_GUART_HYST
;
2269 static int bnx2x_update_pfc_brb(struct link_params
*params
,
2270 struct link_vars
*vars
,
2271 struct bnx2x_nig_brb_pfc_port_params
2274 struct bnx2x
*bp
= params
->bp
;
2275 struct bnx2x_pfc_brb_th_val config_val
= { {0} };
2276 struct bnx2x_pfc_brb_threshold_val
*reg_th_config
=
2277 &config_val
.pauseable_th
;
2278 struct bnx2x_pfc_brb_e3b0_val e3b0_val
= {0};
2279 const int set_pfc
= params
->feature_config_flags
&
2280 FEATURE_CONFIG_PFC_ENABLED
;
2281 const u8 pfc_enabled
= (set_pfc
&& pfc_params
);
2282 int bnx2x_status
= 0;
2283 u8 port
= params
->port
;
2285 /* default - pause configuration */
2286 reg_th_config
= &config_val
.pauseable_th
;
2287 bnx2x_status
= bnx2x_pfc_brb_get_config_params(params
, &config_val
);
2289 return bnx2x_status
;
2293 if (pfc_params
->cos0_pauseable
)
2294 reg_th_config
= &config_val
.pauseable_th
;
2296 reg_th_config
= &config_val
.non_pauseable_th
;
2298 reg_th_config
= &config_val
.default_class0
;
2300 * The number of free blocks below which the pause signal to class 0
2301 * of MAC #n is asserted. n=0,1
2303 REG_WR(bp
, (port
) ? BRB1_REG_PAUSE_0_XOFF_THRESHOLD_1
:
2304 BRB1_REG_PAUSE_0_XOFF_THRESHOLD_0
,
2305 reg_th_config
->pause_xoff
);
2307 * The number of free blocks above which the pause signal to class 0
2308 * of MAC #n is de-asserted. n=0,1
2310 REG_WR(bp
, (port
) ? BRB1_REG_PAUSE_0_XON_THRESHOLD_1
:
2311 BRB1_REG_PAUSE_0_XON_THRESHOLD_0
, reg_th_config
->pause_xon
);
2313 * The number of free blocks below which the full signal to class 0
2314 * of MAC #n is asserted. n=0,1
2316 REG_WR(bp
, (port
) ? BRB1_REG_FULL_0_XOFF_THRESHOLD_1
:
2317 BRB1_REG_FULL_0_XOFF_THRESHOLD_0
, reg_th_config
->full_xoff
);
2319 * The number of free blocks above which the full signal to class 0
2320 * of MAC #n is de-asserted. n=0,1
2322 REG_WR(bp
, (port
) ? BRB1_REG_FULL_0_XON_THRESHOLD_1
:
2323 BRB1_REG_FULL_0_XON_THRESHOLD_0
, reg_th_config
->full_xon
);
2327 if (pfc_params
->cos1_pauseable
)
2328 reg_th_config
= &config_val
.pauseable_th
;
2330 reg_th_config
= &config_val
.non_pauseable_th
;
2332 reg_th_config
= &config_val
.default_class1
;
2334 * The number of free blocks below which the pause signal to
2335 * class 1 of MAC #n is asserted. n=0,1
2337 REG_WR(bp
, (port
) ? BRB1_REG_PAUSE_1_XOFF_THRESHOLD_1
:
2338 BRB1_REG_PAUSE_1_XOFF_THRESHOLD_0
,
2339 reg_th_config
->pause_xoff
);
2342 * The number of free blocks above which the pause signal to
2343 * class 1 of MAC #n is de-asserted. n=0,1
2345 REG_WR(bp
, (port
) ? BRB1_REG_PAUSE_1_XON_THRESHOLD_1
:
2346 BRB1_REG_PAUSE_1_XON_THRESHOLD_0
,
2347 reg_th_config
->pause_xon
);
2349 * The number of free blocks below which the full signal to
2350 * class 1 of MAC #n is asserted. n=0,1
2352 REG_WR(bp
, (port
) ? BRB1_REG_FULL_1_XOFF_THRESHOLD_1
:
2353 BRB1_REG_FULL_1_XOFF_THRESHOLD_0
,
2354 reg_th_config
->full_xoff
);
2356 * The number of free blocks above which the full signal to
2357 * class 1 of MAC #n is de-asserted. n=0,1
2359 REG_WR(bp
, (port
) ? BRB1_REG_FULL_1_XON_THRESHOLD_1
:
2360 BRB1_REG_FULL_1_XON_THRESHOLD_0
,
2361 reg_th_config
->full_xon
);
2363 if (CHIP_IS_E3B0(bp
)) {
2364 bnx2x_pfc_brb_get_e3b0_config_params(
2370 REG_WR(bp
, BRB1_REG_PER_CLASS_GUARANTY_MODE
,
2371 e3b0_val
.per_class_guaranty_mode
);
2374 * The hysteresis on the guarantied buffer space for the Lb
2375 * port before signaling XON.
2377 REG_WR(bp
, BRB1_REG_LB_GUARANTIED_HYST
,
2378 e3b0_val
.lb_guarantied_hyst
);
2381 * The number of free blocks below which the full signal to the
2382 * LB port is asserted.
2384 REG_WR(bp
, BRB1_REG_FULL_LB_XOFF_THRESHOLD
,
2385 e3b0_val
.full_lb_xoff_th
);
2387 * The number of free blocks above which the full signal to the
2388 * LB port is de-asserted.
2390 REG_WR(bp
, BRB1_REG_FULL_LB_XON_THRESHOLD
,
2391 e3b0_val
.full_lb_xon_threshold
);
2393 * The number of blocks guarantied for the MAC #n port. n=0,1
2396 /* The number of blocks guarantied for the LB port.*/
2397 REG_WR(bp
, BRB1_REG_LB_GUARANTIED
,
2398 e3b0_val
.lb_guarantied
);
2401 * The number of blocks guarantied for the MAC #n port.
2403 REG_WR(bp
, BRB1_REG_MAC_GUARANTIED_0
,
2404 2 * e3b0_val
.mac_0_class_t_guarantied
);
2405 REG_WR(bp
, BRB1_REG_MAC_GUARANTIED_1
,
2406 2 * e3b0_val
.mac_1_class_t_guarantied
);
2408 * The number of blocks guarantied for class #t in MAC0. t=0,1
2410 REG_WR(bp
, BRB1_REG_MAC_0_CLASS_0_GUARANTIED
,
2411 e3b0_val
.mac_0_class_t_guarantied
);
2412 REG_WR(bp
, BRB1_REG_MAC_0_CLASS_1_GUARANTIED
,
2413 e3b0_val
.mac_0_class_t_guarantied
);
2415 * The hysteresis on the guarantied buffer space for class in
2418 REG_WR(bp
, BRB1_REG_MAC_0_CLASS_0_GUARANTIED_HYST
,
2419 e3b0_val
.mac_0_class_t_guarantied_hyst
);
2420 REG_WR(bp
, BRB1_REG_MAC_0_CLASS_1_GUARANTIED_HYST
,
2421 e3b0_val
.mac_0_class_t_guarantied_hyst
);
2424 * The number of blocks guarantied for class #t in MAC1.t=0,1
2426 REG_WR(bp
, BRB1_REG_MAC_1_CLASS_0_GUARANTIED
,
2427 e3b0_val
.mac_1_class_t_guarantied
);
2428 REG_WR(bp
, BRB1_REG_MAC_1_CLASS_1_GUARANTIED
,
2429 e3b0_val
.mac_1_class_t_guarantied
);
2431 * The hysteresis on the guarantied buffer space for class #t
2434 REG_WR(bp
, BRB1_REG_MAC_1_CLASS_0_GUARANTIED_HYST
,
2435 e3b0_val
.mac_1_class_t_guarantied_hyst
);
2436 REG_WR(bp
, BRB1_REG_MAC_1_CLASS_1_GUARANTIED_HYST
,
2437 e3b0_val
.mac_1_class_t_guarantied_hyst
);
2440 return bnx2x_status
;
2443 /******************************************************************************
2445 * This function is needed because NIG ARB_CREDIT_WEIGHT_X are
2446 * not continues and ARB_CREDIT_WEIGHT_0 + offset is suitable.
2447 ******************************************************************************/
2448 int bnx2x_pfc_nig_rx_priority_mask(struct bnx2x
*bp
,
2450 u32 priority_mask
, u8 port
)
2452 u32 nig_reg_rx_priority_mask_add
= 0;
2454 switch (cos_entry
) {
2456 nig_reg_rx_priority_mask_add
= (port
) ?
2457 NIG_REG_P1_RX_COS0_PRIORITY_MASK
:
2458 NIG_REG_P0_RX_COS0_PRIORITY_MASK
;
2461 nig_reg_rx_priority_mask_add
= (port
) ?
2462 NIG_REG_P1_RX_COS1_PRIORITY_MASK
:
2463 NIG_REG_P0_RX_COS1_PRIORITY_MASK
;
2466 nig_reg_rx_priority_mask_add
= (port
) ?
2467 NIG_REG_P1_RX_COS2_PRIORITY_MASK
:
2468 NIG_REG_P0_RX_COS2_PRIORITY_MASK
;
2473 nig_reg_rx_priority_mask_add
= NIG_REG_P0_RX_COS3_PRIORITY_MASK
;
2478 nig_reg_rx_priority_mask_add
= NIG_REG_P0_RX_COS4_PRIORITY_MASK
;
2483 nig_reg_rx_priority_mask_add
= NIG_REG_P0_RX_COS5_PRIORITY_MASK
;
2487 REG_WR(bp
, nig_reg_rx_priority_mask_add
, priority_mask
);
2491 static void bnx2x_update_mng(struct link_params
*params
, u32 link_status
)
2493 struct bnx2x
*bp
= params
->bp
;
2495 REG_WR(bp
, params
->shmem_base
+
2496 offsetof(struct shmem_region
,
2497 port_mb
[params
->port
].link_status
), link_status
);
2500 static void bnx2x_update_pfc_nig(struct link_params
*params
,
2501 struct link_vars
*vars
,
2502 struct bnx2x_nig_brb_pfc_port_params
*nig_params
)
2504 u32 xcm_mask
= 0, ppp_enable
= 0, pause_enable
= 0, llfc_out_en
= 0;
2505 u32 llfc_enable
= 0, xcm_out_en
= 0, hwpfc_enable
= 0;
2506 u32 pkt_priority_to_cos
= 0;
2507 struct bnx2x
*bp
= params
->bp
;
2508 u8 port
= params
->port
;
2510 int set_pfc
= params
->feature_config_flags
&
2511 FEATURE_CONFIG_PFC_ENABLED
;
2512 DP(NETIF_MSG_LINK
, "updating pfc nig parameters\n");
2515 * When NIG_LLH0_XCM_MASK_REG_LLHX_XCM_MASK_BCN bit is set
2516 * MAC control frames (that are not pause packets)
2517 * will be forwarded to the XCM.
2519 xcm_mask
= REG_RD(bp
, port
? NIG_REG_LLH1_XCM_MASK
:
2520 NIG_REG_LLH0_XCM_MASK
);
2522 * nig params will override non PFC params, since it's possible to
2523 * do transition from PFC to SAFC
2533 xcm_mask
&= ~(port
? NIG_LLH1_XCM_MASK_REG_LLH1_XCM_MASK_BCN
:
2534 NIG_LLH0_XCM_MASK_REG_LLH0_XCM_MASK_BCN
);
2539 llfc_out_en
= nig_params
->llfc_out_en
;
2540 llfc_enable
= nig_params
->llfc_enable
;
2541 pause_enable
= nig_params
->pause_enable
;
2542 } else /*defaul non PFC mode - PAUSE */
2545 xcm_mask
|= (port
? NIG_LLH1_XCM_MASK_REG_LLH1_XCM_MASK_BCN
:
2546 NIG_LLH0_XCM_MASK_REG_LLH0_XCM_MASK_BCN
);
2551 REG_WR(bp
, port
? NIG_REG_BRB1_PAUSE_IN_EN
:
2552 NIG_REG_BRB0_PAUSE_IN_EN
, pause_enable
);
2553 REG_WR(bp
, port
? NIG_REG_LLFC_OUT_EN_1
:
2554 NIG_REG_LLFC_OUT_EN_0
, llfc_out_en
);
2555 REG_WR(bp
, port
? NIG_REG_LLFC_ENABLE_1
:
2556 NIG_REG_LLFC_ENABLE_0
, llfc_enable
);
2557 REG_WR(bp
, port
? NIG_REG_PAUSE_ENABLE_1
:
2558 NIG_REG_PAUSE_ENABLE_0
, pause_enable
);
2560 REG_WR(bp
, port
? NIG_REG_PPP_ENABLE_1
:
2561 NIG_REG_PPP_ENABLE_0
, ppp_enable
);
2563 REG_WR(bp
, port
? NIG_REG_LLH1_XCM_MASK
:
2564 NIG_REG_LLH0_XCM_MASK
, xcm_mask
);
2566 REG_WR(bp
, port
? NIG_REG_LLFC_EGRESS_SRC_ENABLE_1
:
2567 NIG_REG_LLFC_EGRESS_SRC_ENABLE_0
, 0x7);
2569 /* output enable for RX_XCM # IF */
2570 REG_WR(bp
, port
? NIG_REG_XCM1_OUT_EN
:
2571 NIG_REG_XCM0_OUT_EN
, xcm_out_en
);
2573 /* HW PFC TX enable */
2574 REG_WR(bp
, port
? NIG_REG_P1_HWPFC_ENABLE
:
2575 NIG_REG_P0_HWPFC_ENABLE
, hwpfc_enable
);
2579 pkt_priority_to_cos
= nig_params
->pkt_priority_to_cos
;
2581 for (i
= 0; i
< nig_params
->num_of_rx_cos_priority_mask
; i
++)
2582 bnx2x_pfc_nig_rx_priority_mask(bp
, i
,
2583 nig_params
->rx_cos_priority_mask
[i
], port
);
2585 REG_WR(bp
, port
? NIG_REG_LLFC_HIGH_PRIORITY_CLASSES_1
:
2586 NIG_REG_LLFC_HIGH_PRIORITY_CLASSES_0
,
2587 nig_params
->llfc_high_priority_classes
);
2589 REG_WR(bp
, port
? NIG_REG_LLFC_LOW_PRIORITY_CLASSES_1
:
2590 NIG_REG_LLFC_LOW_PRIORITY_CLASSES_0
,
2591 nig_params
->llfc_low_priority_classes
);
2593 REG_WR(bp
, port
? NIG_REG_P1_PKT_PRIORITY_TO_COS
:
2594 NIG_REG_P0_PKT_PRIORITY_TO_COS
,
2595 pkt_priority_to_cos
);
2598 int bnx2x_update_pfc(struct link_params
*params
,
2599 struct link_vars
*vars
,
2600 struct bnx2x_nig_brb_pfc_port_params
*pfc_params
)
2603 * The PFC and pause are orthogonal to one another, meaning when
2604 * PFC is enabled, the pause are disabled, and when PFC is
2605 * disabled, pause are set according to the pause result.
2608 struct bnx2x
*bp
= params
->bp
;
2609 int bnx2x_status
= 0;
2610 u8 bmac_loopback
= (params
->loopback_mode
== LOOPBACK_BMAC
);
2612 if (params
->feature_config_flags
& FEATURE_CONFIG_PFC_ENABLED
)
2613 vars
->link_status
|= LINK_STATUS_PFC_ENABLED
;
2615 vars
->link_status
&= ~LINK_STATUS_PFC_ENABLED
;
2617 bnx2x_update_mng(params
, vars
->link_status
);
2619 /* update NIG params */
2620 bnx2x_update_pfc_nig(params
, vars
, pfc_params
);
2622 /* update BRB params */
2623 bnx2x_status
= bnx2x_update_pfc_brb(params
, vars
, pfc_params
);
2625 return bnx2x_status
;
2628 return bnx2x_status
;
2630 DP(NETIF_MSG_LINK
, "About to update PFC in BMAC\n");
2632 bnx2x_update_pfc_xmac(params
, vars
, 0);
2634 val
= REG_RD(bp
, MISC_REG_RESET_REG_2
);
2636 (MISC_REGISTERS_RESET_REG_2_RST_BMAC0
<< params
->port
))
2638 DP(NETIF_MSG_LINK
, "About to update PFC in EMAC\n");
2639 bnx2x_emac_enable(params
, vars
, 0);
2640 return bnx2x_status
;
2643 bnx2x_update_pfc_bmac2(params
, vars
, bmac_loopback
);
2645 bnx2x_update_pfc_bmac1(params
, vars
);
2648 if ((params
->feature_config_flags
&
2649 FEATURE_CONFIG_PFC_ENABLED
) ||
2650 (vars
->flow_ctrl
& BNX2X_FLOW_CTRL_TX
))
2652 REG_WR(bp
, NIG_REG_BMAC0_PAUSE_OUT_EN
+ params
->port
*4, val
);
2654 return bnx2x_status
;
2658 static int bnx2x_bmac1_enable(struct link_params
*params
,
2659 struct link_vars
*vars
,
2662 struct bnx2x
*bp
= params
->bp
;
2663 u8 port
= params
->port
;
2664 u32 bmac_addr
= port
? NIG_REG_INGRESS_BMAC1_MEM
:
2665 NIG_REG_INGRESS_BMAC0_MEM
;
2669 DP(NETIF_MSG_LINK
, "Enabling BigMAC1\n");
2674 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC_REGISTER_BMAC_XGXS_CONTROL
,
2678 wb_data
[0] = ((params
->mac_addr
[2] << 24) |
2679 (params
->mac_addr
[3] << 16) |
2680 (params
->mac_addr
[4] << 8) |
2681 params
->mac_addr
[5]);
2682 wb_data
[1] = ((params
->mac_addr
[0] << 8) |
2683 params
->mac_addr
[1]);
2684 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC_REGISTER_TX_SOURCE_ADDR
, wb_data
, 2);
2690 DP(NETIF_MSG_LINK
, "enable bmac loopback\n");
2694 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC_REGISTER_BMAC_CONTROL
, wb_data
, 2);
2697 wb_data
[0] = ETH_MAX_JUMBO_PACKET_SIZE
+ ETH_OVREHEAD
;
2699 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC_REGISTER_RX_MAX_SIZE
, wb_data
, 2);
2701 bnx2x_update_pfc_bmac1(params
, vars
);
2704 wb_data
[0] = ETH_MAX_JUMBO_PACKET_SIZE
+ ETH_OVREHEAD
;
2706 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC_REGISTER_TX_MAX_SIZE
, wb_data
, 2);
2708 /* set cnt max size */
2709 wb_data
[0] = ETH_MAX_JUMBO_PACKET_SIZE
+ ETH_OVREHEAD
;
2711 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC_REGISTER_CNT_MAX_SIZE
, wb_data
, 2);
2713 /* configure safc */
2714 wb_data
[0] = 0x1000200;
2716 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC_REGISTER_RX_LLFC_MSG_FLDS
,
2722 static int bnx2x_bmac2_enable(struct link_params
*params
,
2723 struct link_vars
*vars
,
2726 struct bnx2x
*bp
= params
->bp
;
2727 u8 port
= params
->port
;
2728 u32 bmac_addr
= port
? NIG_REG_INGRESS_BMAC1_MEM
:
2729 NIG_REG_INGRESS_BMAC0_MEM
;
2732 DP(NETIF_MSG_LINK
, "Enabling BigMAC2\n");
2736 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC2_REGISTER_BMAC_CONTROL
, wb_data
, 2);
2739 /* XGXS control: Reset phy HW, MDIO registers, PHY PLL and BMAC */
2742 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC2_REGISTER_BMAC_XGXS_CONTROL
,
2748 wb_data
[0] = ((params
->mac_addr
[2] << 24) |
2749 (params
->mac_addr
[3] << 16) |
2750 (params
->mac_addr
[4] << 8) |
2751 params
->mac_addr
[5]);
2752 wb_data
[1] = ((params
->mac_addr
[0] << 8) |
2753 params
->mac_addr
[1]);
2754 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC2_REGISTER_TX_SOURCE_ADDR
,
2759 /* Configure SAFC */
2760 wb_data
[0] = 0x1000200;
2762 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC2_REGISTER_RX_LLFC_MSG_FLDS
,
2767 wb_data
[0] = ETH_MAX_JUMBO_PACKET_SIZE
+ ETH_OVREHEAD
;
2769 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC2_REGISTER_RX_MAX_SIZE
, wb_data
, 2);
2773 wb_data
[0] = ETH_MAX_JUMBO_PACKET_SIZE
+ ETH_OVREHEAD
;
2775 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC2_REGISTER_TX_MAX_SIZE
, wb_data
, 2);
2777 /* set cnt max size */
2778 wb_data
[0] = ETH_MAX_JUMBO_PACKET_SIZE
+ ETH_OVREHEAD
- 2;
2780 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC2_REGISTER_CNT_MAX_SIZE
, wb_data
, 2);
2782 bnx2x_update_pfc_bmac2(params
, vars
, is_lb
);
2787 static int bnx2x_bmac_enable(struct link_params
*params
,
2788 struct link_vars
*vars
,
2792 u8 port
= params
->port
;
2793 struct bnx2x
*bp
= params
->bp
;
2795 /* reset and unreset the BigMac */
2796 REG_WR(bp
, GRCBASE_MISC
+ MISC_REGISTERS_RESET_REG_2_CLEAR
,
2797 (MISC_REGISTERS_RESET_REG_2_RST_BMAC0
<< port
));
2800 REG_WR(bp
, GRCBASE_MISC
+ MISC_REGISTERS_RESET_REG_2_SET
,
2801 (MISC_REGISTERS_RESET_REG_2_RST_BMAC0
<< port
));
2803 /* enable access for bmac registers */
2804 REG_WR(bp
, NIG_REG_BMAC0_REGS_OUT_EN
+ port
*4, 0x1);
2806 /* Enable BMAC according to BMAC type*/
2808 rc
= bnx2x_bmac2_enable(params
, vars
, is_lb
);
2810 rc
= bnx2x_bmac1_enable(params
, vars
, is_lb
);
2811 REG_WR(bp
, NIG_REG_XGXS_SERDES0_MODE_SEL
+ port
*4, 0x1);
2812 REG_WR(bp
, NIG_REG_XGXS_LANE_SEL_P0
+ port
*4, 0x0);
2813 REG_WR(bp
, NIG_REG_EGRESS_EMAC0_PORT
+ port
*4, 0x0);
2815 if ((params
->feature_config_flags
&
2816 FEATURE_CONFIG_PFC_ENABLED
) ||
2817 (vars
->flow_ctrl
& BNX2X_FLOW_CTRL_TX
))
2819 REG_WR(bp
, NIG_REG_BMAC0_PAUSE_OUT_EN
+ port
*4, val
);
2820 REG_WR(bp
, NIG_REG_EGRESS_EMAC0_OUT_EN
+ port
*4, 0x0);
2821 REG_WR(bp
, NIG_REG_EMAC0_IN_EN
+ port
*4, 0x0);
2822 REG_WR(bp
, NIG_REG_EMAC0_PAUSE_OUT_EN
+ port
*4, 0x0);
2823 REG_WR(bp
, NIG_REG_BMAC0_IN_EN
+ port
*4, 0x1);
2824 REG_WR(bp
, NIG_REG_BMAC0_OUT_EN
+ port
*4, 0x1);
2826 vars
->mac_type
= MAC_TYPE_BMAC
;
2830 static void bnx2x_bmac_rx_disable(struct bnx2x
*bp
, u8 port
)
2832 u32 bmac_addr
= port
? NIG_REG_INGRESS_BMAC1_MEM
:
2833 NIG_REG_INGRESS_BMAC0_MEM
;
2835 u32 nig_bmac_enable
= REG_RD(bp
, NIG_REG_BMAC0_REGS_OUT_EN
+ port
*4);
2837 /* Only if the bmac is out of reset */
2838 if (REG_RD(bp
, MISC_REG_RESET_REG_2
) &
2839 (MISC_REGISTERS_RESET_REG_2_RST_BMAC0
<< port
) &&
2842 if (CHIP_IS_E2(bp
)) {
2843 /* Clear Rx Enable bit in BMAC_CONTROL register */
2844 REG_RD_DMAE(bp
, bmac_addr
+
2845 BIGMAC2_REGISTER_BMAC_CONTROL
,
2847 wb_data
[0] &= ~BMAC_CONTROL_RX_ENABLE
;
2848 REG_WR_DMAE(bp
, bmac_addr
+
2849 BIGMAC2_REGISTER_BMAC_CONTROL
,
2852 /* Clear Rx Enable bit in BMAC_CONTROL register */
2853 REG_RD_DMAE(bp
, bmac_addr
+
2854 BIGMAC_REGISTER_BMAC_CONTROL
,
2856 wb_data
[0] &= ~BMAC_CONTROL_RX_ENABLE
;
2857 REG_WR_DMAE(bp
, bmac_addr
+
2858 BIGMAC_REGISTER_BMAC_CONTROL
,
2865 static int bnx2x_pbf_update(struct link_params
*params
, u32 flow_ctrl
,
2868 struct bnx2x
*bp
= params
->bp
;
2869 u8 port
= params
->port
;
2874 REG_WR(bp
, PBF_REG_DISABLE_NEW_TASK_PROC_P0
+ port
*4, 0x1);
2876 /* wait for init credit */
2877 init_crd
= REG_RD(bp
, PBF_REG_P0_INIT_CRD
+ port
*4);
2878 crd
= REG_RD(bp
, PBF_REG_P0_CREDIT
+ port
*8);
2879 DP(NETIF_MSG_LINK
, "init_crd 0x%x crd 0x%x\n", init_crd
, crd
);
2881 while ((init_crd
!= crd
) && count
) {
2884 crd
= REG_RD(bp
, PBF_REG_P0_CREDIT
+ port
*8);
2887 crd
= REG_RD(bp
, PBF_REG_P0_CREDIT
+ port
*8);
2888 if (init_crd
!= crd
) {
2889 DP(NETIF_MSG_LINK
, "BUG! init_crd 0x%x != crd 0x%x\n",
2894 if (flow_ctrl
& BNX2X_FLOW_CTRL_RX
||
2895 line_speed
== SPEED_10
||
2896 line_speed
== SPEED_100
||
2897 line_speed
== SPEED_1000
||
2898 line_speed
== SPEED_2500
) {
2899 REG_WR(bp
, PBF_REG_P0_PAUSE_ENABLE
+ port
*4, 1);
2900 /* update threshold */
2901 REG_WR(bp
, PBF_REG_P0_ARB_THRSH
+ port
*4, 0);
2902 /* update init credit */
2903 init_crd
= 778; /* (800-18-4) */
2906 u32 thresh
= (ETH_MAX_JUMBO_PACKET_SIZE
+
2908 REG_WR(bp
, PBF_REG_P0_PAUSE_ENABLE
+ port
*4, 0);
2909 /* update threshold */
2910 REG_WR(bp
, PBF_REG_P0_ARB_THRSH
+ port
*4, thresh
);
2911 /* update init credit */
2912 switch (line_speed
) {
2914 init_crd
= thresh
+ 553 - 22;
2917 DP(NETIF_MSG_LINK
, "Invalid line_speed 0x%x\n",
2922 REG_WR(bp
, PBF_REG_P0_INIT_CRD
+ port
*4, init_crd
);
2923 DP(NETIF_MSG_LINK
, "PBF updated to speed %d credit %d\n",
2924 line_speed
, init_crd
);
2926 /* probe the credit changes */
2927 REG_WR(bp
, PBF_REG_INIT_P0
+ port
*4, 0x1);
2929 REG_WR(bp
, PBF_REG_INIT_P0
+ port
*4, 0x0);
2932 REG_WR(bp
, PBF_REG_DISABLE_NEW_TASK_PROC_P0
+ port
*4, 0x0);
2937 * bnx2x_get_emac_base - retrive emac base address
2939 * @bp: driver handle
2940 * @mdc_mdio_access: access type
2943 * This function selects the MDC/MDIO access (through emac0 or
2944 * emac1) depend on the mdc_mdio_access, port, port swapped. Each
2945 * phy has a default access mode, which could also be overridden
2946 * by nvram configuration. This parameter, whether this is the
2947 * default phy configuration, or the nvram overrun
2948 * configuration, is passed here as mdc_mdio_access and selects
2949 * the emac_base for the CL45 read/writes operations
2951 static u32
bnx2x_get_emac_base(struct bnx2x
*bp
,
2952 u32 mdc_mdio_access
, u8 port
)
2955 switch (mdc_mdio_access
) {
2956 case SHARED_HW_CFG_MDC_MDIO_ACCESS1_PHY_TYPE
:
2958 case SHARED_HW_CFG_MDC_MDIO_ACCESS1_EMAC0
:
2959 if (REG_RD(bp
, NIG_REG_PORT_SWAP
))
2960 emac_base
= GRCBASE_EMAC1
;
2962 emac_base
= GRCBASE_EMAC0
;
2964 case SHARED_HW_CFG_MDC_MDIO_ACCESS1_EMAC1
:
2965 if (REG_RD(bp
, NIG_REG_PORT_SWAP
))
2966 emac_base
= GRCBASE_EMAC0
;
2968 emac_base
= GRCBASE_EMAC1
;
2970 case SHARED_HW_CFG_MDC_MDIO_ACCESS1_BOTH
:
2971 emac_base
= (port
) ? GRCBASE_EMAC1
: GRCBASE_EMAC0
;
2973 case SHARED_HW_CFG_MDC_MDIO_ACCESS1_SWAPPED
:
2974 emac_base
= (port
) ? GRCBASE_EMAC0
: GRCBASE_EMAC1
;
2983 /******************************************************************/
2984 /* CL22 access functions */
2985 /******************************************************************/
2986 static int bnx2x_cl22_write(struct bnx2x
*bp
,
2987 struct bnx2x_phy
*phy
,
2993 /* Switch to CL22 */
2994 mode
= REG_RD(bp
, phy
->mdio_ctrl
+ EMAC_REG_EMAC_MDIO_MODE
);
2995 REG_WR(bp
, phy
->mdio_ctrl
+ EMAC_REG_EMAC_MDIO_MODE
,
2996 mode
& ~EMAC_MDIO_MODE_CLAUSE_45
);
2999 tmp
= ((phy
->addr
<< 21) | (reg
<< 16) | val
|
3000 EMAC_MDIO_COMM_COMMAND_WRITE_22
|
3001 EMAC_MDIO_COMM_START_BUSY
);
3002 REG_WR(bp
, phy
->mdio_ctrl
+ EMAC_REG_EMAC_MDIO_COMM
, tmp
);
3004 for (i
= 0; i
< 50; i
++) {
3007 tmp
= REG_RD(bp
, phy
->mdio_ctrl
+ EMAC_REG_EMAC_MDIO_COMM
);
3008 if (!(tmp
& EMAC_MDIO_COMM_START_BUSY
)) {
3013 if (tmp
& EMAC_MDIO_COMM_START_BUSY
) {
3014 DP(NETIF_MSG_LINK
, "write phy register failed\n");
3017 REG_WR(bp
, phy
->mdio_ctrl
+ EMAC_REG_EMAC_MDIO_MODE
, mode
);
3021 static int bnx2x_cl22_read(struct bnx2x
*bp
,
3022 struct bnx2x_phy
*phy
,
3023 u16 reg
, u16
*ret_val
)
3029 /* Switch to CL22 */
3030 mode
= REG_RD(bp
, phy
->mdio_ctrl
+ EMAC_REG_EMAC_MDIO_MODE
);
3031 REG_WR(bp
, phy
->mdio_ctrl
+ EMAC_REG_EMAC_MDIO_MODE
,
3032 mode
& ~EMAC_MDIO_MODE_CLAUSE_45
);
3035 val
= ((phy
->addr
<< 21) | (reg
<< 16) |
3036 EMAC_MDIO_COMM_COMMAND_READ_22
|
3037 EMAC_MDIO_COMM_START_BUSY
);
3038 REG_WR(bp
, phy
->mdio_ctrl
+ EMAC_REG_EMAC_MDIO_COMM
, val
);
3040 for (i
= 0; i
< 50; i
++) {
3043 val
= REG_RD(bp
, phy
->mdio_ctrl
+ EMAC_REG_EMAC_MDIO_COMM
);
3044 if (!(val
& EMAC_MDIO_COMM_START_BUSY
)) {
3045 *ret_val
= (u16
)(val
& EMAC_MDIO_COMM_DATA
);
3050 if (val
& EMAC_MDIO_COMM_START_BUSY
) {
3051 DP(NETIF_MSG_LINK
, "read phy register failed\n");
3056 REG_WR(bp
, phy
->mdio_ctrl
+ EMAC_REG_EMAC_MDIO_MODE
, mode
);
3060 /******************************************************************/
3061 /* CL45 access functions */
3062 /******************************************************************/
3063 static int bnx2x_cl45_read(struct bnx2x
*bp
, struct bnx2x_phy
*phy
,
3064 u8 devad
, u16 reg
, u16
*ret_val
)
3069 if (phy
->flags
& FLAGS_MDC_MDIO_WA_B0
)
3070 bnx2x_bits_en(bp
, phy
->mdio_ctrl
+ EMAC_REG_EMAC_MDIO_STATUS
,
3071 EMAC_MDIO_STATUS_10MB
);
3073 val
= ((phy
->addr
<< 21) | (devad
<< 16) | reg
|
3074 EMAC_MDIO_COMM_COMMAND_ADDRESS
|
3075 EMAC_MDIO_COMM_START_BUSY
);
3076 REG_WR(bp
, phy
->mdio_ctrl
+ EMAC_REG_EMAC_MDIO_COMM
, val
);
3078 for (i
= 0; i
< 50; i
++) {
3081 val
= REG_RD(bp
, phy
->mdio_ctrl
+ EMAC_REG_EMAC_MDIO_COMM
);
3082 if (!(val
& EMAC_MDIO_COMM_START_BUSY
)) {
3087 if (val
& EMAC_MDIO_COMM_START_BUSY
) {
3088 DP(NETIF_MSG_LINK
, "read phy register failed\n");
3089 netdev_err(bp
->dev
, "MDC/MDIO access timeout\n");
3094 val
= ((phy
->addr
<< 21) | (devad
<< 16) |
3095 EMAC_MDIO_COMM_COMMAND_READ_45
|
3096 EMAC_MDIO_COMM_START_BUSY
);
3097 REG_WR(bp
, phy
->mdio_ctrl
+ EMAC_REG_EMAC_MDIO_COMM
, val
);
3099 for (i
= 0; i
< 50; i
++) {
3102 val
= REG_RD(bp
, phy
->mdio_ctrl
+
3103 EMAC_REG_EMAC_MDIO_COMM
);
3104 if (!(val
& EMAC_MDIO_COMM_START_BUSY
)) {
3105 *ret_val
= (u16
)(val
& EMAC_MDIO_COMM_DATA
);
3109 if (val
& EMAC_MDIO_COMM_START_BUSY
) {
3110 DP(NETIF_MSG_LINK
, "read phy register failed\n");
3111 netdev_err(bp
->dev
, "MDC/MDIO access timeout\n");
3116 /* Work around for E3 A0 */
3117 if (phy
->flags
& FLAGS_MDC_MDIO_WA
) {
3118 phy
->flags
^= FLAGS_DUMMY_READ
;
3119 if (phy
->flags
& FLAGS_DUMMY_READ
) {
3121 bnx2x_cl45_read(bp
, phy
, devad
, 0xf, &temp_val
);
3125 if (phy
->flags
& FLAGS_MDC_MDIO_WA_B0
)
3126 bnx2x_bits_dis(bp
, phy
->mdio_ctrl
+ EMAC_REG_EMAC_MDIO_STATUS
,
3127 EMAC_MDIO_STATUS_10MB
);
3131 static int bnx2x_cl45_write(struct bnx2x
*bp
, struct bnx2x_phy
*phy
,
3132 u8 devad
, u16 reg
, u16 val
)
3137 if (phy
->flags
& FLAGS_MDC_MDIO_WA_B0
)
3138 bnx2x_bits_en(bp
, phy
->mdio_ctrl
+ EMAC_REG_EMAC_MDIO_STATUS
,
3139 EMAC_MDIO_STATUS_10MB
);
3143 tmp
= ((phy
->addr
<< 21) | (devad
<< 16) | reg
|
3144 EMAC_MDIO_COMM_COMMAND_ADDRESS
|
3145 EMAC_MDIO_COMM_START_BUSY
);
3146 REG_WR(bp
, phy
->mdio_ctrl
+ EMAC_REG_EMAC_MDIO_COMM
, tmp
);
3148 for (i
= 0; i
< 50; i
++) {
3151 tmp
= REG_RD(bp
, phy
->mdio_ctrl
+ EMAC_REG_EMAC_MDIO_COMM
);
3152 if (!(tmp
& EMAC_MDIO_COMM_START_BUSY
)) {
3157 if (tmp
& EMAC_MDIO_COMM_START_BUSY
) {
3158 DP(NETIF_MSG_LINK
, "write phy register failed\n");
3159 netdev_err(bp
->dev
, "MDC/MDIO access timeout\n");
3163 tmp
= ((phy
->addr
<< 21) | (devad
<< 16) | val
|
3164 EMAC_MDIO_COMM_COMMAND_WRITE_45
|
3165 EMAC_MDIO_COMM_START_BUSY
);
3166 REG_WR(bp
, phy
->mdio_ctrl
+ EMAC_REG_EMAC_MDIO_COMM
, tmp
);
3168 for (i
= 0; i
< 50; i
++) {
3171 tmp
= REG_RD(bp
, phy
->mdio_ctrl
+
3172 EMAC_REG_EMAC_MDIO_COMM
);
3173 if (!(tmp
& EMAC_MDIO_COMM_START_BUSY
)) {
3178 if (tmp
& EMAC_MDIO_COMM_START_BUSY
) {
3179 DP(NETIF_MSG_LINK
, "write phy register failed\n");
3180 netdev_err(bp
->dev
, "MDC/MDIO access timeout\n");
3184 /* Work around for E3 A0 */
3185 if (phy
->flags
& FLAGS_MDC_MDIO_WA
) {
3186 phy
->flags
^= FLAGS_DUMMY_READ
;
3187 if (phy
->flags
& FLAGS_DUMMY_READ
) {
3189 bnx2x_cl45_read(bp
, phy
, devad
, 0xf, &temp_val
);
3192 if (phy
->flags
& FLAGS_MDC_MDIO_WA_B0
)
3193 bnx2x_bits_dis(bp
, phy
->mdio_ctrl
+ EMAC_REG_EMAC_MDIO_STATUS
,
3194 EMAC_MDIO_STATUS_10MB
);
3197 /******************************************************************/
3198 /* BSC access functions from E3 */
3199 /******************************************************************/
3200 static void bnx2x_bsc_module_sel(struct link_params
*params
)
3203 u32 board_cfg
, sfp_ctrl
;
3204 u32 i2c_pins
[I2C_SWITCH_WIDTH
], i2c_val
[I2C_SWITCH_WIDTH
];
3205 struct bnx2x
*bp
= params
->bp
;
3206 u8 port
= params
->port
;
3207 /* Read I2C output PINs */
3208 board_cfg
= REG_RD(bp
, params
->shmem_base
+
3209 offsetof(struct shmem_region
,
3210 dev_info
.shared_hw_config
.board
));
3211 i2c_pins
[I2C_BSC0
] = board_cfg
& SHARED_HW_CFG_E3_I2C_MUX0_MASK
;
3212 i2c_pins
[I2C_BSC1
] = (board_cfg
& SHARED_HW_CFG_E3_I2C_MUX1_MASK
) >>
3213 SHARED_HW_CFG_E3_I2C_MUX1_SHIFT
;
3215 /* Read I2C output value */
3216 sfp_ctrl
= REG_RD(bp
, params
->shmem_base
+
3217 offsetof(struct shmem_region
,
3218 dev_info
.port_hw_config
[port
].e3_cmn_pin_cfg
));
3219 i2c_val
[I2C_BSC0
] = (sfp_ctrl
& PORT_HW_CFG_E3_I2C_MUX0_MASK
) > 0;
3220 i2c_val
[I2C_BSC1
] = (sfp_ctrl
& PORT_HW_CFG_E3_I2C_MUX1_MASK
) > 0;
3221 DP(NETIF_MSG_LINK
, "Setting BSC switch\n");
3222 for (idx
= 0; idx
< I2C_SWITCH_WIDTH
; idx
++)
3223 bnx2x_set_cfg_pin(bp
, i2c_pins
[idx
], i2c_val
[idx
]);
3226 static int bnx2x_bsc_read(struct link_params
*params
,
3227 struct bnx2x_phy
*phy
,
3236 struct bnx2x
*bp
= params
->bp
;
3238 if ((sl_devid
!= 0xa0) && (sl_devid
!= 0xa2)) {
3239 DP(NETIF_MSG_LINK
, "invalid sl_devid 0x%x\n", sl_devid
);
3243 if (xfer_cnt
> 16) {
3244 DP(NETIF_MSG_LINK
, "invalid xfer_cnt %d. Max is 16 bytes\n",
3248 bnx2x_bsc_module_sel(params
);
3250 xfer_cnt
= 16 - lc_addr
;
3252 /* enable the engine */
3253 val
= REG_RD(bp
, MCP_REG_MCPR_IMC_COMMAND
);
3254 val
|= MCPR_IMC_COMMAND_ENABLE
;
3255 REG_WR(bp
, MCP_REG_MCPR_IMC_COMMAND
, val
);
3257 /* program slave device ID */
3258 val
= (sl_devid
<< 16) | sl_addr
;
3259 REG_WR(bp
, MCP_REG_MCPR_IMC_SLAVE_CONTROL
, val
);
3261 /* start xfer with 0 byte to update the address pointer ???*/
3262 val
= (MCPR_IMC_COMMAND_ENABLE
) |
3263 (MCPR_IMC_COMMAND_WRITE_OP
<<
3264 MCPR_IMC_COMMAND_OPERATION_BITSHIFT
) |
3265 (lc_addr
<< MCPR_IMC_COMMAND_TRANSFER_ADDRESS_BITSHIFT
) | (0);
3266 REG_WR(bp
, MCP_REG_MCPR_IMC_COMMAND
, val
);
3268 /* poll for completion */
3270 val
= REG_RD(bp
, MCP_REG_MCPR_IMC_COMMAND
);
3271 while (((val
>> MCPR_IMC_COMMAND_IMC_STATUS_BITSHIFT
) & 0x3) != 1) {
3273 val
= REG_RD(bp
, MCP_REG_MCPR_IMC_COMMAND
);
3275 DP(NETIF_MSG_LINK
, "wr 0 byte timed out after %d try\n",
3284 /* start xfer with read op */
3285 val
= (MCPR_IMC_COMMAND_ENABLE
) |
3286 (MCPR_IMC_COMMAND_READ_OP
<<
3287 MCPR_IMC_COMMAND_OPERATION_BITSHIFT
) |
3288 (lc_addr
<< MCPR_IMC_COMMAND_TRANSFER_ADDRESS_BITSHIFT
) |
3290 REG_WR(bp
, MCP_REG_MCPR_IMC_COMMAND
, val
);
3292 /* poll for completion */
3294 val
= REG_RD(bp
, MCP_REG_MCPR_IMC_COMMAND
);
3295 while (((val
>> MCPR_IMC_COMMAND_IMC_STATUS_BITSHIFT
) & 0x3) != 1) {
3297 val
= REG_RD(bp
, MCP_REG_MCPR_IMC_COMMAND
);
3299 DP(NETIF_MSG_LINK
, "rd op timed out after %d try\n", i
);
3307 for (i
= (lc_addr
>> 2); i
< 4; i
++) {
3308 data_array
[i
] = REG_RD(bp
, (MCP_REG_MCPR_IMC_DATAREG0
+ i
*4));
3310 data_array
[i
] = ((data_array
[i
] & 0x000000ff) << 24) |
3311 ((data_array
[i
] & 0x0000ff00) << 8) |
3312 ((data_array
[i
] & 0x00ff0000) >> 8) |
3313 ((data_array
[i
] & 0xff000000) >> 24);
3319 static void bnx2x_cl45_read_or_write(struct bnx2x
*bp
, struct bnx2x_phy
*phy
,
3320 u8 devad
, u16 reg
, u16 or_val
)
3323 bnx2x_cl45_read(bp
, phy
, devad
, reg
, &val
);
3324 bnx2x_cl45_write(bp
, phy
, devad
, reg
, val
| or_val
);
3327 int bnx2x_phy_read(struct link_params
*params
, u8 phy_addr
,
3328 u8 devad
, u16 reg
, u16
*ret_val
)
3332 * Probe for the phy according to the given phy_addr, and execute
3333 * the read request on it
3335 for (phy_index
= 0; phy_index
< params
->num_phys
; phy_index
++) {
3336 if (params
->phy
[phy_index
].addr
== phy_addr
) {
3337 return bnx2x_cl45_read(params
->bp
,
3338 ¶ms
->phy
[phy_index
], devad
,
3345 int bnx2x_phy_write(struct link_params
*params
, u8 phy_addr
,
3346 u8 devad
, u16 reg
, u16 val
)
3350 * Probe for the phy according to the given phy_addr, and execute
3351 * the write request on it
3353 for (phy_index
= 0; phy_index
< params
->num_phys
; phy_index
++) {
3354 if (params
->phy
[phy_index
].addr
== phy_addr
) {
3355 return bnx2x_cl45_write(params
->bp
,
3356 ¶ms
->phy
[phy_index
], devad
,
3362 static u8
bnx2x_get_warpcore_lane(struct bnx2x_phy
*phy
,
3363 struct link_params
*params
)
3366 struct bnx2x
*bp
= params
->bp
;
3367 u32 path_swap
, path_swap_ovr
;
3371 port
= params
->port
;
3373 if (bnx2x_is_4_port_mode(bp
)) {
3374 u32 port_swap
, port_swap_ovr
;
3376 /*figure out path swap value */
3377 path_swap_ovr
= REG_RD(bp
, MISC_REG_FOUR_PORT_PATH_SWAP_OVWR
);
3378 if (path_swap_ovr
& 0x1)
3379 path_swap
= (path_swap_ovr
& 0x2);
3381 path_swap
= REG_RD(bp
, MISC_REG_FOUR_PORT_PATH_SWAP
);
3386 /*figure out port swap value */
3387 port_swap_ovr
= REG_RD(bp
, MISC_REG_FOUR_PORT_PORT_SWAP_OVWR
);
3388 if (port_swap_ovr
& 0x1)
3389 port_swap
= (port_swap_ovr
& 0x2);
3391 port_swap
= REG_RD(bp
, MISC_REG_FOUR_PORT_PORT_SWAP
);
3396 lane
= (port
<<1) + path
;
3397 } else { /* two port mode - no port swap */
3399 /*figure out path swap value */
3401 REG_RD(bp
, MISC_REG_TWO_PORT_PATH_SWAP_OVWR
);
3402 if (path_swap_ovr
& 0x1) {
3403 path_swap
= (path_swap_ovr
& 0x2);
3406 REG_RD(bp
, MISC_REG_TWO_PORT_PATH_SWAP
);
3416 static void bnx2x_set_aer_mmd(struct link_params
*params
,
3417 struct bnx2x_phy
*phy
)
3420 u16 offset
, aer_val
;
3421 struct bnx2x
*bp
= params
->bp
;
3422 ser_lane
= ((params
->lane_config
&
3423 PORT_HW_CFG_LANE_SWAP_CFG_MASTER_MASK
) >>
3424 PORT_HW_CFG_LANE_SWAP_CFG_MASTER_SHIFT
);
3426 offset
= (phy
->type
== PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT
) ?
3427 (phy
->addr
+ ser_lane
) : 0;
3429 if (USES_WARPCORE(bp
)) {
3430 aer_val
= bnx2x_get_warpcore_lane(phy
, params
);
3432 * In Dual-lane mode, two lanes are joined together,
3433 * so in order to configure them, the AER broadcast method is
3435 * 0x200 is the broadcast address for lanes 0,1
3436 * 0x201 is the broadcast address for lanes 2,3
3438 if (phy
->flags
& FLAGS_WC_DUAL_MODE
)
3439 aer_val
= (aer_val
>> 1) | 0x200;
3440 } else if (CHIP_IS_E2(bp
))
3441 aer_val
= 0x3800 + offset
- 1;
3443 aer_val
= 0x3800 + offset
;
3445 CL22_WR_OVER_CL45(bp
, phy
, MDIO_REG_BANK_AER_BLOCK
,
3446 MDIO_AER_BLOCK_AER_REG
, aer_val
);
3450 /******************************************************************/
3451 /* Internal phy section */
3452 /******************************************************************/
3454 static void bnx2x_set_serdes_access(struct bnx2x
*bp
, u8 port
)
3456 u32 emac_base
= (port
) ? GRCBASE_EMAC1
: GRCBASE_EMAC0
;
3459 REG_WR(bp
, NIG_REG_SERDES0_CTRL_MD_ST
+ port
*0x10, 1);
3460 REG_WR(bp
, emac_base
+ EMAC_REG_EMAC_MDIO_COMM
, 0x245f8000);
3462 REG_WR(bp
, emac_base
+ EMAC_REG_EMAC_MDIO_COMM
, 0x245d000f);
3465 REG_WR(bp
, NIG_REG_SERDES0_CTRL_MD_ST
+ port
*0x10, 0);
3468 static void bnx2x_serdes_deassert(struct bnx2x
*bp
, u8 port
)
3472 DP(NETIF_MSG_LINK
, "bnx2x_serdes_deassert\n");
3474 val
= SERDES_RESET_BITS
<< (port
*16);
3476 /* reset and unreset the SerDes/XGXS */
3477 REG_WR(bp
, GRCBASE_MISC
+ MISC_REGISTERS_RESET_REG_3_CLEAR
, val
);
3479 REG_WR(bp
, GRCBASE_MISC
+ MISC_REGISTERS_RESET_REG_3_SET
, val
);
3481 bnx2x_set_serdes_access(bp
, port
);
3483 REG_WR(bp
, NIG_REG_SERDES0_CTRL_MD_DEVAD
+ port
*0x10,
3484 DEFAULT_PHY_DEV_ADDR
);
3487 static void bnx2x_xgxs_deassert(struct link_params
*params
)
3489 struct bnx2x
*bp
= params
->bp
;
3492 DP(NETIF_MSG_LINK
, "bnx2x_xgxs_deassert\n");
3493 port
= params
->port
;
3495 val
= XGXS_RESET_BITS
<< (port
*16);
3497 /* reset and unreset the SerDes/XGXS */
3498 REG_WR(bp
, GRCBASE_MISC
+ MISC_REGISTERS_RESET_REG_3_CLEAR
, val
);
3500 REG_WR(bp
, GRCBASE_MISC
+ MISC_REGISTERS_RESET_REG_3_SET
, val
);
3502 REG_WR(bp
, NIG_REG_XGXS0_CTRL_MD_ST
+ port
*0x18, 0);
3503 REG_WR(bp
, NIG_REG_XGXS0_CTRL_MD_DEVAD
+ port
*0x18,
3504 params
->phy
[INT_PHY
].def_md_devad
);
3507 static void bnx2x_calc_ieee_aneg_adv(struct bnx2x_phy
*phy
,
3508 struct link_params
*params
, u16
*ieee_fc
)
3510 struct bnx2x
*bp
= params
->bp
;
3511 *ieee_fc
= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_FULL_DUPLEX
;
3513 * resolve pause mode and advertisement Please refer to Table
3514 * 28B-3 of the 802.3ab-1999 spec
3517 switch (phy
->req_flow_ctrl
) {
3518 case BNX2X_FLOW_CTRL_AUTO
:
3519 if (params
->req_fc_auto_adv
== BNX2X_FLOW_CTRL_BOTH
)
3520 *ieee_fc
|= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH
;
3523 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC
;
3526 case BNX2X_FLOW_CTRL_TX
:
3527 *ieee_fc
|= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC
;
3530 case BNX2X_FLOW_CTRL_RX
:
3531 case BNX2X_FLOW_CTRL_BOTH
:
3532 *ieee_fc
|= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH
;
3535 case BNX2X_FLOW_CTRL_NONE
:
3537 *ieee_fc
|= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_NONE
;
3540 DP(NETIF_MSG_LINK
, "ieee_fc = 0x%x\n", *ieee_fc
);
3543 static void set_phy_vars(struct link_params
*params
,
3544 struct link_vars
*vars
)
3546 struct bnx2x
*bp
= params
->bp
;
3547 u8 actual_phy_idx
, phy_index
, link_cfg_idx
;
3548 u8 phy_config_swapped
= params
->multi_phy_config
&
3549 PORT_HW_CFG_PHY_SWAPPED_ENABLED
;
3550 for (phy_index
= INT_PHY
; phy_index
< params
->num_phys
;
3552 link_cfg_idx
= LINK_CONFIG_IDX(phy_index
);
3553 actual_phy_idx
= phy_index
;
3554 if (phy_config_swapped
) {
3555 if (phy_index
== EXT_PHY1
)
3556 actual_phy_idx
= EXT_PHY2
;
3557 else if (phy_index
== EXT_PHY2
)
3558 actual_phy_idx
= EXT_PHY1
;
3560 params
->phy
[actual_phy_idx
].req_flow_ctrl
=
3561 params
->req_flow_ctrl
[link_cfg_idx
];
3563 params
->phy
[actual_phy_idx
].req_line_speed
=
3564 params
->req_line_speed
[link_cfg_idx
];
3566 params
->phy
[actual_phy_idx
].speed_cap_mask
=
3567 params
->speed_cap_mask
[link_cfg_idx
];
3569 params
->phy
[actual_phy_idx
].req_duplex
=
3570 params
->req_duplex
[link_cfg_idx
];
3572 if (params
->req_line_speed
[link_cfg_idx
] ==
3574 vars
->link_status
|= LINK_STATUS_AUTO_NEGOTIATE_ENABLED
;
3576 DP(NETIF_MSG_LINK
, "req_flow_ctrl %x, req_line_speed %x,"
3577 " speed_cap_mask %x\n",
3578 params
->phy
[actual_phy_idx
].req_flow_ctrl
,
3579 params
->phy
[actual_phy_idx
].req_line_speed
,
3580 params
->phy
[actual_phy_idx
].speed_cap_mask
);
3584 static void bnx2x_ext_phy_set_pause(struct link_params
*params
,
3585 struct bnx2x_phy
*phy
,
3586 struct link_vars
*vars
)
3589 struct bnx2x
*bp
= params
->bp
;
3590 /* read modify write pause advertizing */
3591 bnx2x_cl45_read(bp
, phy
, MDIO_AN_DEVAD
, MDIO_AN_REG_ADV_PAUSE
, &val
);
3593 val
&= ~MDIO_AN_REG_ADV_PAUSE_BOTH
;
3595 /* Please refer to Table 28B-3 of 802.3ab-1999 spec. */
3596 bnx2x_calc_ieee_aneg_adv(phy
, params
, &vars
->ieee_fc
);
3597 if ((vars
->ieee_fc
&
3598 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC
) ==
3599 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC
) {
3600 val
|= MDIO_AN_REG_ADV_PAUSE_ASYMMETRIC
;
3602 if ((vars
->ieee_fc
&
3603 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH
) ==
3604 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH
) {
3605 val
|= MDIO_AN_REG_ADV_PAUSE_PAUSE
;
3607 DP(NETIF_MSG_LINK
, "Ext phy AN advertize 0x%x\n", val
);
3608 bnx2x_cl45_write(bp
, phy
, MDIO_AN_DEVAD
, MDIO_AN_REG_ADV_PAUSE
, val
);
3611 static void bnx2x_pause_resolve(struct link_vars
*vars
, u32 pause_result
)
3613 switch (pause_result
) { /* ASYM P ASYM P */
3614 case 0xb: /* 1 0 1 1 */
3615 vars
->flow_ctrl
= BNX2X_FLOW_CTRL_TX
;
3618 case 0xe: /* 1 1 1 0 */
3619 vars
->flow_ctrl
= BNX2X_FLOW_CTRL_RX
;
3622 case 0x5: /* 0 1 0 1 */
3623 case 0x7: /* 0 1 1 1 */
3624 case 0xd: /* 1 1 0 1 */
3625 case 0xf: /* 1 1 1 1 */
3626 vars
->flow_ctrl
= BNX2X_FLOW_CTRL_BOTH
;
3632 if (pause_result
& (1<<0))
3633 vars
->link_status
|= LINK_STATUS_LINK_PARTNER_SYMMETRIC_PAUSE
;
3634 if (pause_result
& (1<<1))
3635 vars
->link_status
|= LINK_STATUS_LINK_PARTNER_ASYMMETRIC_PAUSE
;
3638 static u8
bnx2x_ext_phy_resolve_fc(struct bnx2x_phy
*phy
,
3639 struct link_params
*params
,
3640 struct link_vars
*vars
)
3642 struct bnx2x
*bp
= params
->bp
;
3643 u16 ld_pause
; /* local */
3644 u16 lp_pause
; /* link partner */
3649 vars
->flow_ctrl
= BNX2X_FLOW_CTRL_NONE
;
3651 if (phy
->req_flow_ctrl
!= BNX2X_FLOW_CTRL_AUTO
)
3652 vars
->flow_ctrl
= phy
->req_flow_ctrl
;
3653 else if (phy
->req_line_speed
!= SPEED_AUTO_NEG
)
3654 vars
->flow_ctrl
= params
->req_fc_auto_adv
;
3655 else if (vars
->link_status
& LINK_STATUS_AUTO_NEGOTIATE_COMPLETE
) {
3657 if (phy
->type
== PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54618SE
) {
3658 bnx2x_cl22_read(bp
, phy
,
3660 bnx2x_cl22_read(bp
, phy
,
3663 bnx2x_cl45_read(bp
, phy
,
3665 MDIO_AN_REG_ADV_PAUSE
, &ld_pause
);
3666 bnx2x_cl45_read(bp
, phy
,
3668 MDIO_AN_REG_LP_AUTO_NEG
, &lp_pause
);
3670 pause_result
= (ld_pause
&
3671 MDIO_AN_REG_ADV_PAUSE_MASK
) >> 8;
3672 pause_result
|= (lp_pause
&
3673 MDIO_AN_REG_ADV_PAUSE_MASK
) >> 10;
3674 DP(NETIF_MSG_LINK
, "Ext PHY pause result 0x%x\n",
3676 bnx2x_pause_resolve(vars
, pause_result
);
3680 /******************************************************************/
3681 /* Warpcore section */
3682 /******************************************************************/
3683 /* The init_internal_warpcore should mirror the xgxs,
3684 * i.e. reset the lane (if needed), set aer for the
3685 * init configuration, and set/clear SGMII flag. Internal
3686 * phy init is done purely in phy_init stage.
3688 static void bnx2x_warpcore_enable_AN_KR(struct bnx2x_phy
*phy
,
3689 struct link_params
*params
,
3690 struct link_vars
*vars
) {
3691 u16 val16
= 0, lane
, bam37
= 0;
3692 struct bnx2x
*bp
= params
->bp
;
3693 DP(NETIF_MSG_LINK
, "Enable Auto Negotiation for KR\n");
3695 /* Disable Autoneg: re-enable it after adv is done. */
3696 bnx2x_cl45_write(bp
, phy
, MDIO_AN_DEVAD
,
3697 MDIO_WC_REG_IEEE0BLK_MIICNTL
, 0);
3699 /* Check adding advertisement for 1G KX */
3700 if (((vars
->line_speed
== SPEED_AUTO_NEG
) &&
3701 (phy
->speed_cap_mask
& PORT_HW_CFG_SPEED_CAPABILITY_D0_1G
)) ||
3702 (vars
->line_speed
== SPEED_1000
)) {
3706 /* Enable CL37 1G Parallel Detect */
3707 bnx2x_cl45_read(bp
, phy
, MDIO_WC_DEVAD
,
3708 MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2
, &sd_digital
);
3709 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
3710 MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2
,
3711 (sd_digital
| 0x1));
3713 DP(NETIF_MSG_LINK
, "Advertize 1G\n");
3715 if (((vars
->line_speed
== SPEED_AUTO_NEG
) &&
3716 (phy
->speed_cap_mask
& PORT_HW_CFG_SPEED_CAPABILITY_D0_10G
)) ||
3717 (vars
->line_speed
== SPEED_10000
)) {
3718 /* Check adding advertisement for 10G KR */
3720 /* Enable 10G Parallel Detect */
3721 bnx2x_cl45_write(bp
, phy
, MDIO_AN_DEVAD
,
3722 MDIO_WC_REG_PAR_DET_10G_CTRL
, 1);
3724 DP(NETIF_MSG_LINK
, "Advertize 10G\n");
3727 /* Set Transmit PMD settings */
3728 lane
= bnx2x_get_warpcore_lane(phy
, params
);
3729 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
3730 MDIO_WC_REG_TX0_TX_DRIVER
+ 0x10*lane
,
3731 ((0x02 << MDIO_WC_REG_TX0_TX_DRIVER_POST2_COEFF_OFFSET
) |
3732 (0x06 << MDIO_WC_REG_TX0_TX_DRIVER_IDRIVER_OFFSET
) |
3733 (0x09 << MDIO_WC_REG_TX0_TX_DRIVER_IPRE_DRIVER_OFFSET
)));
3734 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
3735 MDIO_WC_REG_CL72_USERB0_CL72_OS_DEF_CTRL
,
3737 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
3738 MDIO_WC_REG_CL72_USERB0_CL72_2P5_DEF_CTRL
,
3741 /* Advertised speeds */
3742 bnx2x_cl45_write(bp
, phy
, MDIO_AN_DEVAD
,
3743 MDIO_WC_REG_AN_IEEE1BLK_AN_ADVERTISEMENT1
, val16
);
3745 /* Advertised and set FEC (Forward Error Correction) */
3746 bnx2x_cl45_write(bp
, phy
, MDIO_AN_DEVAD
,
3747 MDIO_WC_REG_AN_IEEE1BLK_AN_ADVERTISEMENT2
,
3748 (MDIO_WC_REG_AN_IEEE1BLK_AN_ADV2_FEC_ABILITY
|
3749 MDIO_WC_REG_AN_IEEE1BLK_AN_ADV2_FEC_REQ
));
3751 /* Enable CL37 BAM */
3752 if (REG_RD(bp
, params
->shmem_base
+
3753 offsetof(struct shmem_region
, dev_info
.
3754 port_hw_config
[params
->port
].default_cfg
)) &
3755 PORT_HW_CFG_ENABLE_BAM_ON_KR_ENABLED
) {
3756 bnx2x_cl45_read(bp
, phy
, MDIO_WC_DEVAD
,
3757 MDIO_WC_REG_DIGITAL6_MP5_NEXTPAGECTRL
, &bam37
);
3758 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
3759 MDIO_WC_REG_DIGITAL6_MP5_NEXTPAGECTRL
, bam37
| 1);
3760 DP(NETIF_MSG_LINK
, "Enable CL37 BAM on KR\n");
3763 /* Advertise pause */
3764 bnx2x_ext_phy_set_pause(params
, phy
, vars
);
3767 * Set KR Autoneg Work-Around flag for Warpcore version older than D108
3769 bnx2x_cl45_read(bp
, phy
, MDIO_WC_DEVAD
,
3770 MDIO_WC_REG_UC_INFO_B1_VERSION
, &val16
);
3771 if (val16
< 0xd108) {
3772 DP(NETIF_MSG_LINK
, "Enable AN KR work-around\n");
3773 vars
->rx_tx_asic_rst
= MAX_KR_LINK_RETRY
;
3776 bnx2x_cl45_read(bp
, phy
, MDIO_WC_DEVAD
,
3777 MDIO_WC_REG_DIGITAL5_MISC7
, &val16
);
3779 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
3780 MDIO_WC_REG_DIGITAL5_MISC7
, val16
| 0x100);
3782 /* Over 1G - AN local device user page 1 */
3783 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
3784 MDIO_WC_REG_DIGITAL3_UP1
, 0x1f);
3786 /* Enable Autoneg */
3787 bnx2x_cl45_write(bp
, phy
, MDIO_AN_DEVAD
,
3788 MDIO_WC_REG_IEEE0BLK_MIICNTL
, 0x1000);
3792 static void bnx2x_warpcore_set_10G_KR(struct bnx2x_phy
*phy
,
3793 struct link_params
*params
,
3794 struct link_vars
*vars
)
3796 struct bnx2x
*bp
= params
->bp
;
3799 /* Disable Autoneg */
3800 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
3801 MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2
, 0x7);
3803 bnx2x_cl45_write(bp
, phy
, MDIO_AN_DEVAD
,
3804 MDIO_WC_REG_PAR_DET_10G_CTRL
, 0);
3806 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
3807 MDIO_WC_REG_CL72_USERB0_CL72_MISC1_CONTROL
, 0x3f00);
3809 bnx2x_cl45_write(bp
, phy
, MDIO_AN_DEVAD
,
3810 MDIO_WC_REG_AN_IEEE1BLK_AN_ADVERTISEMENT1
, 0);
3812 bnx2x_cl45_write(bp
, phy
, MDIO_AN_DEVAD
,
3813 MDIO_WC_REG_IEEE0BLK_MIICNTL
, 0x0);
3815 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
3816 MDIO_WC_REG_DIGITAL3_UP1
, 0x1);
3818 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
3819 MDIO_WC_REG_DIGITAL5_MISC7
, 0xa);
3821 /* Disable CL36 PCS Tx */
3822 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
3823 MDIO_WC_REG_XGXSBLK1_LANECTRL0
, 0x0);
3825 /* Double Wide Single Data Rate @ pll rate */
3826 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
3827 MDIO_WC_REG_XGXSBLK1_LANECTRL1
, 0xFFFF);
3829 /* Leave cl72 training enable, needed for KR */
3830 bnx2x_cl45_write(bp
, phy
, MDIO_PMA_DEVAD
,
3831 MDIO_WC_REG_PMD_IEEE9BLK_TENGBASE_KR_PMD_CONTROL_REGISTER_150
,
3834 /* Leave CL72 enabled */
3835 bnx2x_cl45_read(bp
, phy
, MDIO_WC_DEVAD
,
3836 MDIO_WC_REG_CL72_USERB0_CL72_MISC1_CONTROL
,
3838 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
3839 MDIO_WC_REG_CL72_USERB0_CL72_MISC1_CONTROL
,
3842 /* Set speed via PMA/PMD register */
3843 bnx2x_cl45_write(bp
, phy
, MDIO_PMA_DEVAD
,
3844 MDIO_WC_REG_IEEE0BLK_MIICNTL
, 0x2040);
3846 bnx2x_cl45_write(bp
, phy
, MDIO_PMA_DEVAD
,
3847 MDIO_WC_REG_IEEE0BLK_AUTONEGNP
, 0xB);
3849 /*Enable encoded forced speed */
3850 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
3851 MDIO_WC_REG_SERDESDIGITAL_MISC2
, 0x30);
3853 /* Turn TX scramble payload only the 64/66 scrambler */
3854 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
3855 MDIO_WC_REG_TX66_CONTROL
, 0x9);
3857 /* Turn RX scramble payload only the 64/66 scrambler */
3858 bnx2x_cl45_read_or_write(bp
, phy
, MDIO_WC_DEVAD
,
3859 MDIO_WC_REG_RX66_CONTROL
, 0xF9);
3861 /* set and clear loopback to cause a reset to 64/66 decoder */
3862 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
3863 MDIO_WC_REG_IEEE0BLK_MIICNTL
, 0x4000);
3864 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
3865 MDIO_WC_REG_IEEE0BLK_MIICNTL
, 0x0);
3869 static void bnx2x_warpcore_set_10G_XFI(struct bnx2x_phy
*phy
,
3870 struct link_params
*params
,
3873 struct bnx2x
*bp
= params
->bp
;
3874 u16 misc1_val
, tap_val
, tx_driver_val
, lane
, val
;
3875 /* Hold rxSeqStart */
3876 bnx2x_cl45_read(bp
, phy
, MDIO_WC_DEVAD
,
3877 MDIO_WC_REG_DSC2B0_DSC_MISC_CTRL0
, &val
);
3878 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
3879 MDIO_WC_REG_DSC2B0_DSC_MISC_CTRL0
, (val
| 0x8000));
3881 /* Hold tx_fifo_reset */
3882 bnx2x_cl45_read(bp
, phy
, MDIO_WC_DEVAD
,
3883 MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X3
, &val
);
3884 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
3885 MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X3
, (val
| 0x1));
3887 /* Disable CL73 AN */
3888 bnx2x_cl45_write(bp
, phy
, MDIO_AN_DEVAD
, MDIO_AN_REG_CTRL
, 0);
3890 /* Disable 100FX Enable and Auto-Detect */
3891 bnx2x_cl45_read(bp
, phy
, MDIO_WC_DEVAD
,
3892 MDIO_WC_REG_FX100_CTRL1
, &val
);
3893 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
3894 MDIO_WC_REG_FX100_CTRL1
, (val
& 0xFFFA));
3896 /* Disable 100FX Idle detect */
3897 bnx2x_cl45_read(bp
, phy
, MDIO_WC_DEVAD
,
3898 MDIO_WC_REG_FX100_CTRL3
, &val
);
3899 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
3900 MDIO_WC_REG_FX100_CTRL3
, (val
| 0x0080));
3902 /* Set Block address to Remote PHY & Clear forced_speed[5] */
3903 bnx2x_cl45_read(bp
, phy
, MDIO_WC_DEVAD
,
3904 MDIO_WC_REG_DIGITAL4_MISC3
, &val
);
3905 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
3906 MDIO_WC_REG_DIGITAL4_MISC3
, (val
& 0xFF7F));
3908 /* Turn off auto-detect & fiber mode */
3909 bnx2x_cl45_read(bp
, phy
, MDIO_WC_DEVAD
,
3910 MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X1
, &val
);
3911 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
3912 MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X1
,
3915 /* Set filter_force_link, disable_false_link and parallel_detect */
3916 bnx2x_cl45_read(bp
, phy
, MDIO_WC_DEVAD
,
3917 MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2
, &val
);
3918 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
3919 MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2
,
3920 ((val
| 0x0006) & 0xFFFE));
3923 bnx2x_cl45_read(bp
, phy
, MDIO_WC_DEVAD
,
3924 MDIO_WC_REG_SERDESDIGITAL_MISC1
, &misc1_val
);
3926 misc1_val
&= ~(0x1f);
3930 tap_val
= ((0x08 << MDIO_WC_REG_TX_FIR_TAP_POST_TAP_OFFSET
) |
3931 (0x37 << MDIO_WC_REG_TX_FIR_TAP_MAIN_TAP_OFFSET
) |
3932 (0x00 << MDIO_WC_REG_TX_FIR_TAP_PRE_TAP_OFFSET
));
3934 ((0x00 << MDIO_WC_REG_TX0_TX_DRIVER_POST2_COEFF_OFFSET
) |
3935 (0x02 << MDIO_WC_REG_TX0_TX_DRIVER_IDRIVER_OFFSET
) |
3936 (0x03 << MDIO_WC_REG_TX0_TX_DRIVER_IPRE_DRIVER_OFFSET
));
3940 tap_val
= ((0x12 << MDIO_WC_REG_TX_FIR_TAP_POST_TAP_OFFSET
) |
3941 (0x2d << MDIO_WC_REG_TX_FIR_TAP_MAIN_TAP_OFFSET
) |
3942 (0x00 << MDIO_WC_REG_TX_FIR_TAP_PRE_TAP_OFFSET
));
3944 ((0x02 << MDIO_WC_REG_TX0_TX_DRIVER_POST2_COEFF_OFFSET
) |
3945 (0x02 << MDIO_WC_REG_TX0_TX_DRIVER_IDRIVER_OFFSET
) |
3946 (0x02 << MDIO_WC_REG_TX0_TX_DRIVER_IPRE_DRIVER_OFFSET
));
3948 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
3949 MDIO_WC_REG_SERDESDIGITAL_MISC1
, misc1_val
);
3951 /* Set Transmit PMD settings */
3952 lane
= bnx2x_get_warpcore_lane(phy
, params
);
3953 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
3954 MDIO_WC_REG_TX_FIR_TAP
,
3955 tap_val
| MDIO_WC_REG_TX_FIR_TAP_ENABLE
);
3956 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
3957 MDIO_WC_REG_TX0_TX_DRIVER
+ 0x10*lane
,
3960 /* Enable fiber mode, enable and invert sig_det */
3961 bnx2x_cl45_read(bp
, phy
, MDIO_WC_DEVAD
,
3962 MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X1
, &val
);
3963 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
3964 MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X1
, val
| 0xd);
3966 /* Set Block address to Remote PHY & Set forced_speed[5], 40bit mode */
3967 bnx2x_cl45_read(bp
, phy
, MDIO_WC_DEVAD
,
3968 MDIO_WC_REG_DIGITAL4_MISC3
, &val
);
3969 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
3970 MDIO_WC_REG_DIGITAL4_MISC3
, val
| 0x8080);
3972 /* 10G XFI Full Duplex */
3973 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
3974 MDIO_WC_REG_IEEE0BLK_MIICNTL
, 0x100);
3976 /* Release tx_fifo_reset */
3977 bnx2x_cl45_read(bp
, phy
, MDIO_WC_DEVAD
,
3978 MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X3
, &val
);
3979 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
3980 MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X3
, val
& 0xFFFE);
3982 /* Release rxSeqStart */
3983 bnx2x_cl45_read(bp
, phy
, MDIO_WC_DEVAD
,
3984 MDIO_WC_REG_DSC2B0_DSC_MISC_CTRL0
, &val
);
3985 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
3986 MDIO_WC_REG_DSC2B0_DSC_MISC_CTRL0
, (val
& 0x7FFF));
3989 static void bnx2x_warpcore_set_20G_KR2(struct bnx2x
*bp
,
3990 struct bnx2x_phy
*phy
)
3992 DP(NETIF_MSG_LINK
, "KR2 still not supported !!!\n");
3995 static void bnx2x_warpcore_set_20G_DXGXS(struct bnx2x
*bp
,
3996 struct bnx2x_phy
*phy
,
3999 /* Rx0 anaRxControl1G */
4000 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
4001 MDIO_WC_REG_RX0_ANARXCONTROL1G
, 0x90);
4003 /* Rx2 anaRxControl1G */
4004 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
4005 MDIO_WC_REG_RX2_ANARXCONTROL1G
, 0x90);
4007 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
4008 MDIO_WC_REG_RX66_SCW0
, 0xE070);
4010 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
4011 MDIO_WC_REG_RX66_SCW1
, 0xC0D0);
4013 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
4014 MDIO_WC_REG_RX66_SCW2
, 0xA0B0);
4016 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
4017 MDIO_WC_REG_RX66_SCW3
, 0x8090);
4019 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
4020 MDIO_WC_REG_RX66_SCW0_MASK
, 0xF0F0);
4022 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
4023 MDIO_WC_REG_RX66_SCW1_MASK
, 0xF0F0);
4025 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
4026 MDIO_WC_REG_RX66_SCW2_MASK
, 0xF0F0);
4028 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
4029 MDIO_WC_REG_RX66_SCW3_MASK
, 0xF0F0);
4031 /* Serdes Digital Misc1 */
4032 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
4033 MDIO_WC_REG_SERDESDIGITAL_MISC1
, 0x6008);
4035 /* Serdes Digital4 Misc3 */
4036 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
4037 MDIO_WC_REG_DIGITAL4_MISC3
, 0x8088);
4039 /* Set Transmit PMD settings */
4040 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
4041 MDIO_WC_REG_TX_FIR_TAP
,
4042 ((0x12 << MDIO_WC_REG_TX_FIR_TAP_POST_TAP_OFFSET
) |
4043 (0x2d << MDIO_WC_REG_TX_FIR_TAP_MAIN_TAP_OFFSET
) |
4044 (0x00 << MDIO_WC_REG_TX_FIR_TAP_PRE_TAP_OFFSET
) |
4045 MDIO_WC_REG_TX_FIR_TAP_ENABLE
));
4046 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
4047 MDIO_WC_REG_TX0_TX_DRIVER
+ 0x10*lane
,
4048 ((0x02 << MDIO_WC_REG_TX0_TX_DRIVER_POST2_COEFF_OFFSET
) |
4049 (0x02 << MDIO_WC_REG_TX0_TX_DRIVER_IDRIVER_OFFSET
) |
4050 (0x02 << MDIO_WC_REG_TX0_TX_DRIVER_IPRE_DRIVER_OFFSET
)));
4053 static void bnx2x_warpcore_set_sgmii_speed(struct bnx2x_phy
*phy
,
4054 struct link_params
*params
,
4058 struct bnx2x
*bp
= params
->bp
;
4059 u16 val16
, digctrl_kx1
, digctrl_kx2
;
4061 /* Clear XFI clock comp in non-10G single lane mode. */
4062 bnx2x_cl45_read(bp
, phy
, MDIO_WC_DEVAD
,
4063 MDIO_WC_REG_RX66_CONTROL
, &val16
);
4064 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
4065 MDIO_WC_REG_RX66_CONTROL
, val16
& ~(3<<13));
4067 if (always_autoneg
|| phy
->req_line_speed
== SPEED_AUTO_NEG
) {
4069 bnx2x_cl45_read(bp
, phy
, MDIO_WC_DEVAD
,
4070 MDIO_WC_REG_COMBO_IEEE0_MIICTRL
, &val16
);
4071 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
4072 MDIO_WC_REG_COMBO_IEEE0_MIICTRL
,
4074 DP(NETIF_MSG_LINK
, "set SGMII AUTONEG\n");
4076 bnx2x_cl45_read(bp
, phy
, MDIO_WC_DEVAD
,
4077 MDIO_WC_REG_COMBO_IEEE0_MIICTRL
, &val16
);
4079 switch (phy
->req_line_speed
) {
4090 "Speed not supported: 0x%x\n", phy
->req_line_speed
);
4094 if (phy
->req_duplex
== DUPLEX_FULL
)
4097 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
4098 MDIO_WC_REG_COMBO_IEEE0_MIICTRL
, val16
);
4100 DP(NETIF_MSG_LINK
, "set SGMII force speed %d\n",
4101 phy
->req_line_speed
);
4102 bnx2x_cl45_read(bp
, phy
, MDIO_WC_DEVAD
,
4103 MDIO_WC_REG_COMBO_IEEE0_MIICTRL
, &val16
);
4104 DP(NETIF_MSG_LINK
, " (readback) %x\n", val16
);
4107 /* SGMII Slave mode and disable signal detect */
4108 bnx2x_cl45_read(bp
, phy
, MDIO_WC_DEVAD
,
4109 MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X1
, &digctrl_kx1
);
4113 digctrl_kx1
&= 0xff4a;
4115 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
4116 MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X1
,
4119 /* Turn off parallel detect */
4120 bnx2x_cl45_read(bp
, phy
, MDIO_WC_DEVAD
,
4121 MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2
, &digctrl_kx2
);
4122 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
4123 MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2
,
4124 (digctrl_kx2
& ~(1<<2)));
4126 /* Re-enable parallel detect */
4127 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
4128 MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2
,
4129 (digctrl_kx2
| (1<<2)));
4131 /* Enable autodet */
4132 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
4133 MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X1
,
4134 (digctrl_kx1
| 0x10));
4137 static void bnx2x_warpcore_reset_lane(struct bnx2x
*bp
,
4138 struct bnx2x_phy
*phy
,
4142 /* Take lane out of reset after configuration is finished */
4143 bnx2x_cl45_read(bp
, phy
, MDIO_WC_DEVAD
,
4144 MDIO_WC_REG_DIGITAL5_MISC6
, &val
);
4149 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
4150 MDIO_WC_REG_DIGITAL5_MISC6
, val
);
4151 bnx2x_cl45_read(bp
, phy
, MDIO_WC_DEVAD
,
4152 MDIO_WC_REG_DIGITAL5_MISC6
, &val
);
4154 /* Clear SFI/XFI link settings registers */
4155 static void bnx2x_warpcore_clear_regs(struct bnx2x_phy
*phy
,
4156 struct link_params
*params
,
4159 struct bnx2x
*bp
= params
->bp
;
4162 /* Set XFI clock comp as default. */
4163 bnx2x_cl45_read(bp
, phy
, MDIO_WC_DEVAD
,
4164 MDIO_WC_REG_RX66_CONTROL
, &val16
);
4165 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
4166 MDIO_WC_REG_RX66_CONTROL
, val16
| (3<<13));
4168 bnx2x_warpcore_reset_lane(bp
, phy
, 1);
4169 bnx2x_cl45_write(bp
, phy
, MDIO_AN_DEVAD
, MDIO_AN_REG_CTRL
, 0);
4170 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
4171 MDIO_WC_REG_FX100_CTRL1
, 0x014a);
4172 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
4173 MDIO_WC_REG_FX100_CTRL3
, 0x0800);
4174 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
4175 MDIO_WC_REG_DIGITAL4_MISC3
, 0x8008);
4176 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
4177 MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X1
, 0x0195);
4178 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
4179 MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2
, 0x0007);
4180 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
4181 MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X3
, 0x0002);
4182 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
4183 MDIO_WC_REG_SERDESDIGITAL_MISC1
, 0x6000);
4184 lane
= bnx2x_get_warpcore_lane(phy
, params
);
4185 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
4186 MDIO_WC_REG_TX_FIR_TAP
, 0x0000);
4187 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
4188 MDIO_WC_REG_TX0_TX_DRIVER
+ 0x10*lane
, 0x0990);
4189 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
4190 MDIO_WC_REG_IEEE0BLK_MIICNTL
, 0x2040);
4191 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
4192 MDIO_WC_REG_COMBO_IEEE0_MIICTRL
, 0x0140);
4193 bnx2x_warpcore_reset_lane(bp
, phy
, 0);
4196 static int bnx2x_get_mod_abs_int_cfg(struct bnx2x
*bp
,
4198 u32 shmem_base
, u8 port
,
4199 u8
*gpio_num
, u8
*gpio_port
)
4204 if (CHIP_IS_E3(bp
)) {
4205 cfg_pin
= (REG_RD(bp
, shmem_base
+
4206 offsetof(struct shmem_region
,
4207 dev_info
.port_hw_config
[port
].e3_sfp_ctrl
)) &
4208 PORT_HW_CFG_E3_MOD_ABS_MASK
) >>
4209 PORT_HW_CFG_E3_MOD_ABS_SHIFT
;
4212 * Should not happen. This function called upon interrupt
4213 * triggered by GPIO ( since EPIO can only generate interrupts
4215 * So if this function was called and none of the GPIOs was set,
4216 * it means the shit hit the fan.
4218 if ((cfg_pin
< PIN_CFG_GPIO0_P0
) ||
4219 (cfg_pin
> PIN_CFG_GPIO3_P1
)) {
4221 "ERROR: Invalid cfg pin %x for module detect indication\n",
4226 *gpio_num
= (cfg_pin
- PIN_CFG_GPIO0_P0
) & 0x3;
4227 *gpio_port
= (cfg_pin
- PIN_CFG_GPIO0_P0
) >> 2;
4229 *gpio_num
= MISC_REGISTERS_GPIO_3
;
4232 DP(NETIF_MSG_LINK
, "MOD_ABS int GPIO%d_P%d\n", *gpio_num
, *gpio_port
);
4236 static int bnx2x_is_sfp_module_plugged(struct bnx2x_phy
*phy
,
4237 struct link_params
*params
)
4239 struct bnx2x
*bp
= params
->bp
;
4240 u8 gpio_num
, gpio_port
;
4242 if (bnx2x_get_mod_abs_int_cfg(bp
, params
->chip_id
,
4243 params
->shmem_base
, params
->port
,
4244 &gpio_num
, &gpio_port
) != 0)
4246 gpio_val
= bnx2x_get_gpio(bp
, gpio_num
, gpio_port
);
4248 /* Call the handling function in case module is detected */
4254 static int bnx2x_warpcore_get_sigdet(struct bnx2x_phy
*phy
,
4255 struct link_params
*params
)
4257 u16 gp2_status_reg0
, lane
;
4258 struct bnx2x
*bp
= params
->bp
;
4260 lane
= bnx2x_get_warpcore_lane(phy
, params
);
4262 bnx2x_cl45_read(bp
, phy
, MDIO_WC_DEVAD
, MDIO_WC_REG_GP2_STATUS_GP_2_0
,
4265 return (gp2_status_reg0
>> (8+lane
)) & 0x1;
4268 static void bnx2x_warpcore_config_runtime(struct bnx2x_phy
*phy
,
4269 struct link_params
*params
,
4270 struct link_vars
*vars
)
4272 struct bnx2x
*bp
= params
->bp
;
4274 u16 gp_status1
= 0, lnkup
= 0, lnkup_kr
= 0;
4275 u16 lane
= bnx2x_get_warpcore_lane(phy
, params
);
4277 vars
->turn_to_run_wc_rt
= vars
->turn_to_run_wc_rt
? 0 : 1;
4279 if (!vars
->turn_to_run_wc_rt
)
4282 /* return if there is no link partner */
4283 if (!(bnx2x_warpcore_get_sigdet(phy
, params
))) {
4284 DP(NETIF_MSG_LINK
, "bnx2x_warpcore_get_sigdet false\n");
4288 if (vars
->rx_tx_asic_rst
) {
4289 serdes_net_if
= (REG_RD(bp
, params
->shmem_base
+
4290 offsetof(struct shmem_region
, dev_info
.
4291 port_hw_config
[params
->port
].default_cfg
)) &
4292 PORT_HW_CFG_NET_SERDES_IF_MASK
);
4294 switch (serdes_net_if
) {
4295 case PORT_HW_CFG_NET_SERDES_IF_KR
:
4296 /* Do we get link yet? */
4297 bnx2x_cl45_read(bp
, phy
, MDIO_WC_DEVAD
, 0x81d1,
4299 lnkup
= (gp_status1
>> (8+lane
)) & 0x1;/* 1G */
4301 lnkup_kr
= (gp_status1
>> (12+lane
)) & 0x1;
4304 "gp_status1 0x%x\n", gp_status1
);
4306 if (lnkup_kr
|| lnkup
) {
4307 vars
->rx_tx_asic_rst
= 0;
4309 "link up, rx_tx_asic_rst 0x%x\n",
4310 vars
->rx_tx_asic_rst
);
4312 /*reset the lane to see if link comes up.*/
4313 bnx2x_warpcore_reset_lane(bp
, phy
, 1);
4314 bnx2x_warpcore_reset_lane(bp
, phy
, 0);
4316 /* restart Autoneg */
4317 bnx2x_cl45_write(bp
, phy
, MDIO_AN_DEVAD
,
4318 MDIO_WC_REG_IEEE0BLK_MIICNTL
, 0x1200);
4320 vars
->rx_tx_asic_rst
--;
4321 DP(NETIF_MSG_LINK
, "0x%x retry left\n",
4322 vars
->rx_tx_asic_rst
);
4330 } /*params->rx_tx_asic_rst*/
4334 static void bnx2x_warpcore_config_init(struct bnx2x_phy
*phy
,
4335 struct link_params
*params
,
4336 struct link_vars
*vars
)
4338 struct bnx2x
*bp
= params
->bp
;
4341 u16 lane
= bnx2x_get_warpcore_lane(phy
, params
);
4342 serdes_net_if
= (REG_RD(bp
, params
->shmem_base
+
4343 offsetof(struct shmem_region
, dev_info
.
4344 port_hw_config
[params
->port
].default_cfg
)) &
4345 PORT_HW_CFG_NET_SERDES_IF_MASK
);
4346 DP(NETIF_MSG_LINK
, "Begin Warpcore init, link_speed %d, "
4347 "serdes_net_if = 0x%x\n",
4348 vars
->line_speed
, serdes_net_if
);
4349 bnx2x_set_aer_mmd(params
, phy
);
4351 vars
->phy_flags
|= PHY_XGXS_FLAG
;
4352 if ((serdes_net_if
== PORT_HW_CFG_NET_SERDES_IF_SGMII
) ||
4353 (phy
->req_line_speed
&&
4354 ((phy
->req_line_speed
== SPEED_100
) ||
4355 (phy
->req_line_speed
== SPEED_10
)))) {
4356 vars
->phy_flags
|= PHY_SGMII_FLAG
;
4357 DP(NETIF_MSG_LINK
, "Setting SGMII mode\n");
4358 bnx2x_warpcore_clear_regs(phy
, params
, lane
);
4359 bnx2x_warpcore_set_sgmii_speed(phy
, params
, 0, 1);
4361 switch (serdes_net_if
) {
4362 case PORT_HW_CFG_NET_SERDES_IF_KR
:
4363 /* Enable KR Auto Neg */
4364 if (params
->loopback_mode
== LOOPBACK_NONE
)
4365 bnx2x_warpcore_enable_AN_KR(phy
, params
, vars
);
4367 DP(NETIF_MSG_LINK
, "Setting KR 10G-Force\n");
4368 bnx2x_warpcore_set_10G_KR(phy
, params
, vars
);
4372 case PORT_HW_CFG_NET_SERDES_IF_XFI
:
4373 bnx2x_warpcore_clear_regs(phy
, params
, lane
);
4374 if (vars
->line_speed
== SPEED_10000
) {
4375 DP(NETIF_MSG_LINK
, "Setting 10G XFI\n");
4376 bnx2x_warpcore_set_10G_XFI(phy
, params
, 1);
4378 if (SINGLE_MEDIA_DIRECT(params
)) {
4379 DP(NETIF_MSG_LINK
, "1G Fiber\n");
4382 DP(NETIF_MSG_LINK
, "10/100/1G SGMII\n");
4385 bnx2x_warpcore_set_sgmii_speed(phy
,
4393 case PORT_HW_CFG_NET_SERDES_IF_SFI
:
4395 bnx2x_warpcore_clear_regs(phy
, params
, lane
);
4396 if (vars
->line_speed
== SPEED_10000
) {
4397 DP(NETIF_MSG_LINK
, "Setting 10G SFI\n");
4398 bnx2x_warpcore_set_10G_XFI(phy
, params
, 0);
4399 } else if (vars
->line_speed
== SPEED_1000
) {
4400 DP(NETIF_MSG_LINK
, "Setting 1G Fiber\n");
4401 bnx2x_warpcore_set_sgmii_speed(
4404 /* Issue Module detection */
4405 if (bnx2x_is_sfp_module_plugged(phy
, params
))
4406 bnx2x_sfp_module_detection(phy
, params
);
4409 case PORT_HW_CFG_NET_SERDES_IF_DXGXS
:
4410 if (vars
->line_speed
!= SPEED_20000
) {
4411 DP(NETIF_MSG_LINK
, "Speed not supported yet\n");
4414 DP(NETIF_MSG_LINK
, "Setting 20G DXGXS\n");
4415 bnx2x_warpcore_set_20G_DXGXS(bp
, phy
, lane
);
4416 /* Issue Module detection */
4418 bnx2x_sfp_module_detection(phy
, params
);
4421 case PORT_HW_CFG_NET_SERDES_IF_KR2
:
4422 if (vars
->line_speed
!= SPEED_20000
) {
4423 DP(NETIF_MSG_LINK
, "Speed not supported yet\n");
4426 DP(NETIF_MSG_LINK
, "Setting 20G KR2\n");
4427 bnx2x_warpcore_set_20G_KR2(bp
, phy
);
4432 "Unsupported Serdes Net Interface 0x%x\n",
4438 /* Take lane out of reset after configuration is finished */
4439 bnx2x_warpcore_reset_lane(bp
, phy
, 0);
4440 DP(NETIF_MSG_LINK
, "Exit config init\n");
4443 static void bnx2x_sfp_e3_set_transmitter(struct link_params
*params
,
4444 struct bnx2x_phy
*phy
,
4447 struct bnx2x
*bp
= params
->bp
;
4449 u8 port
= params
->port
;
4451 cfg_pin
= REG_RD(bp
, params
->shmem_base
+
4452 offsetof(struct shmem_region
,
4453 dev_info
.port_hw_config
[port
].e3_sfp_ctrl
)) &
4454 PORT_HW_CFG_TX_LASER_MASK
;
4455 /* Set the !tx_en since this pin is DISABLE_TX_LASER */
4456 DP(NETIF_MSG_LINK
, "Setting WC TX to %d\n", tx_en
);
4457 /* For 20G, the expected pin to be used is 3 pins after the current */
4459 bnx2x_set_cfg_pin(bp
, cfg_pin
, tx_en
^ 1);
4460 if (phy
->speed_cap_mask
& PORT_HW_CFG_SPEED_CAPABILITY_D0_20G
)
4461 bnx2x_set_cfg_pin(bp
, cfg_pin
+ 3, tx_en
^ 1);
4464 static void bnx2x_warpcore_link_reset(struct bnx2x_phy
*phy
,
4465 struct link_params
*params
)
4467 struct bnx2x
*bp
= params
->bp
;
4469 bnx2x_sfp_e3_set_transmitter(params
, phy
, 0);
4470 bnx2x_set_mdio_clk(bp
, params
->chip_id
, params
->port
);
4471 bnx2x_set_aer_mmd(params
, phy
);
4472 /* Global register */
4473 bnx2x_warpcore_reset_lane(bp
, phy
, 1);
4475 /* Clear loopback settings (if any) */
4477 bnx2x_cl45_read(bp
, phy
, MDIO_WC_DEVAD
,
4478 MDIO_WC_REG_COMBO_IEEE0_MIICTRL
, &val16
);
4479 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
4480 MDIO_WC_REG_COMBO_IEEE0_MIICTRL
, val16
&
4483 bnx2x_cl45_read(bp
, phy
, MDIO_WC_DEVAD
,
4484 MDIO_WC_REG_IEEE0BLK_MIICNTL
, &val16
);
4485 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
4486 MDIO_WC_REG_IEEE0BLK_MIICNTL
, val16
& 0xfffe);
4488 /* Update those 1-copy registers */
4489 CL22_WR_OVER_CL45(bp
, phy
, MDIO_REG_BANK_AER_BLOCK
,
4490 MDIO_AER_BLOCK_AER_REG
, 0);
4491 /* Enable 1G MDIO (1-copy) */
4492 bnx2x_cl45_read(bp
, phy
, MDIO_WC_DEVAD
,
4493 MDIO_WC_REG_XGXSBLK0_XGXSCONTROL
,
4495 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
4496 MDIO_WC_REG_XGXSBLK0_XGXSCONTROL
,
4499 bnx2x_cl45_read(bp
, phy
, MDIO_WC_DEVAD
,
4500 MDIO_WC_REG_XGXSBLK1_LANECTRL2
, &val16
);
4501 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
4502 MDIO_WC_REG_XGXSBLK1_LANECTRL2
,
4507 static void bnx2x_set_warpcore_loopback(struct bnx2x_phy
*phy
,
4508 struct link_params
*params
)
4510 struct bnx2x
*bp
= params
->bp
;
4513 DP(NETIF_MSG_LINK
, "Setting Warpcore loopback type %x, speed %d\n",
4514 params
->loopback_mode
, phy
->req_line_speed
);
4516 if (phy
->req_line_speed
< SPEED_10000
) {
4519 /* Update those 1-copy registers */
4520 CL22_WR_OVER_CL45(bp
, phy
, MDIO_REG_BANK_AER_BLOCK
,
4521 MDIO_AER_BLOCK_AER_REG
, 0);
4522 /* Enable 1G MDIO (1-copy) */
4523 bnx2x_cl45_read(bp
, phy
, MDIO_WC_DEVAD
,
4524 MDIO_WC_REG_XGXSBLK0_XGXSCONTROL
,
4526 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
4527 MDIO_WC_REG_XGXSBLK0_XGXSCONTROL
,
4529 /* Set 1G loopback based on lane (1-copy) */
4530 lane
= bnx2x_get_warpcore_lane(phy
, params
);
4531 bnx2x_cl45_read(bp
, phy
, MDIO_WC_DEVAD
,
4532 MDIO_WC_REG_XGXSBLK1_LANECTRL2
, &val16
);
4533 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
4534 MDIO_WC_REG_XGXSBLK1_LANECTRL2
,
4537 /* Switch back to 4-copy registers */
4538 bnx2x_set_aer_mmd(params
, phy
);
4541 bnx2x_cl45_read(bp
, phy
, MDIO_WC_DEVAD
,
4542 MDIO_WC_REG_COMBO_IEEE0_MIICTRL
, &val16
);
4543 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
4544 MDIO_WC_REG_COMBO_IEEE0_MIICTRL
, val16
|
4547 bnx2x_cl45_read(bp
, phy
, MDIO_WC_DEVAD
,
4548 MDIO_WC_REG_IEEE0BLK_MIICNTL
, &val16
);
4549 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
4550 MDIO_WC_REG_IEEE0BLK_MIICNTL
, val16
| 0x1);
4555 void bnx2x_sync_link(struct link_params
*params
,
4556 struct link_vars
*vars
)
4558 struct bnx2x
*bp
= params
->bp
;
4560 if (vars
->link_status
& LINK_STATUS_PHYSICAL_LINK_FLAG
)
4561 vars
->phy_flags
|= PHY_PHYSICAL_LINK_FLAG
;
4562 vars
->link_up
= (vars
->link_status
& LINK_STATUS_LINK_UP
);
4563 if (vars
->link_up
) {
4564 DP(NETIF_MSG_LINK
, "phy link up\n");
4566 vars
->phy_link_up
= 1;
4567 vars
->duplex
= DUPLEX_FULL
;
4568 switch (vars
->link_status
&
4569 LINK_STATUS_SPEED_AND_DUPLEX_MASK
) {
4571 vars
->duplex
= DUPLEX_HALF
;
4574 vars
->line_speed
= SPEED_10
;
4578 vars
->duplex
= DUPLEX_HALF
;
4582 vars
->line_speed
= SPEED_100
;
4586 vars
->duplex
= DUPLEX_HALF
;
4589 vars
->line_speed
= SPEED_1000
;
4593 vars
->duplex
= DUPLEX_HALF
;
4596 vars
->line_speed
= SPEED_2500
;
4600 vars
->line_speed
= SPEED_10000
;
4603 vars
->line_speed
= SPEED_20000
;
4608 vars
->flow_ctrl
= 0;
4609 if (vars
->link_status
& LINK_STATUS_TX_FLOW_CONTROL_ENABLED
)
4610 vars
->flow_ctrl
|= BNX2X_FLOW_CTRL_TX
;
4612 if (vars
->link_status
& LINK_STATUS_RX_FLOW_CONTROL_ENABLED
)
4613 vars
->flow_ctrl
|= BNX2X_FLOW_CTRL_RX
;
4615 if (!vars
->flow_ctrl
)
4616 vars
->flow_ctrl
= BNX2X_FLOW_CTRL_NONE
;
4618 if (vars
->line_speed
&&
4619 ((vars
->line_speed
== SPEED_10
) ||
4620 (vars
->line_speed
== SPEED_100
))) {
4621 vars
->phy_flags
|= PHY_SGMII_FLAG
;
4623 vars
->phy_flags
&= ~PHY_SGMII_FLAG
;
4625 if (vars
->line_speed
&&
4626 USES_WARPCORE(bp
) &&
4627 (vars
->line_speed
== SPEED_1000
))
4628 vars
->phy_flags
|= PHY_SGMII_FLAG
;
4629 /* anything 10 and over uses the bmac */
4630 link_10g_plus
= (vars
->line_speed
>= SPEED_10000
);
4632 if (link_10g_plus
) {
4633 if (USES_WARPCORE(bp
))
4634 vars
->mac_type
= MAC_TYPE_XMAC
;
4636 vars
->mac_type
= MAC_TYPE_BMAC
;
4638 if (USES_WARPCORE(bp
))
4639 vars
->mac_type
= MAC_TYPE_UMAC
;
4641 vars
->mac_type
= MAC_TYPE_EMAC
;
4643 } else { /* link down */
4644 DP(NETIF_MSG_LINK
, "phy link down\n");
4646 vars
->phy_link_up
= 0;
4648 vars
->line_speed
= 0;
4649 vars
->duplex
= DUPLEX_FULL
;
4650 vars
->flow_ctrl
= BNX2X_FLOW_CTRL_NONE
;
4652 /* indicate no mac active */
4653 vars
->mac_type
= MAC_TYPE_NONE
;
4654 if (vars
->link_status
& LINK_STATUS_PHYSICAL_LINK_FLAG
)
4655 vars
->phy_flags
|= PHY_HALF_OPEN_CONN_FLAG
;
4659 void bnx2x_link_status_update(struct link_params
*params
,
4660 struct link_vars
*vars
)
4662 struct bnx2x
*bp
= params
->bp
;
4663 u8 port
= params
->port
;
4664 u32 sync_offset
, media_types
;
4665 /* Update PHY configuration */
4666 set_phy_vars(params
, vars
);
4668 vars
->link_status
= REG_RD(bp
, params
->shmem_base
+
4669 offsetof(struct shmem_region
,
4670 port_mb
[port
].link_status
));
4672 vars
->phy_flags
= PHY_XGXS_FLAG
;
4673 bnx2x_sync_link(params
, vars
);
4674 /* Sync media type */
4675 sync_offset
= params
->shmem_base
+
4676 offsetof(struct shmem_region
,
4677 dev_info
.port_hw_config
[port
].media_type
);
4678 media_types
= REG_RD(bp
, sync_offset
);
4680 params
->phy
[INT_PHY
].media_type
=
4681 (media_types
& PORT_HW_CFG_MEDIA_TYPE_PHY0_MASK
) >>
4682 PORT_HW_CFG_MEDIA_TYPE_PHY0_SHIFT
;
4683 params
->phy
[EXT_PHY1
].media_type
=
4684 (media_types
& PORT_HW_CFG_MEDIA_TYPE_PHY1_MASK
) >>
4685 PORT_HW_CFG_MEDIA_TYPE_PHY1_SHIFT
;
4686 params
->phy
[EXT_PHY2
].media_type
=
4687 (media_types
& PORT_HW_CFG_MEDIA_TYPE_PHY2_MASK
) >>
4688 PORT_HW_CFG_MEDIA_TYPE_PHY2_SHIFT
;
4689 DP(NETIF_MSG_LINK
, "media_types = 0x%x\n", media_types
);
4691 /* Sync AEU offset */
4692 sync_offset
= params
->shmem_base
+
4693 offsetof(struct shmem_region
,
4694 dev_info
.port_hw_config
[port
].aeu_int_mask
);
4696 vars
->aeu_int_mask
= REG_RD(bp
, sync_offset
);
4698 /* Sync PFC status */
4699 if (vars
->link_status
& LINK_STATUS_PFC_ENABLED
)
4700 params
->feature_config_flags
|=
4701 FEATURE_CONFIG_PFC_ENABLED
;
4703 params
->feature_config_flags
&=
4704 ~FEATURE_CONFIG_PFC_ENABLED
;
4706 DP(NETIF_MSG_LINK
, "link_status 0x%x phy_link_up %x int_mask 0x%x\n",
4707 vars
->link_status
, vars
->phy_link_up
, vars
->aeu_int_mask
);
4708 DP(NETIF_MSG_LINK
, "line_speed %x duplex %x flow_ctrl 0x%x\n",
4709 vars
->line_speed
, vars
->duplex
, vars
->flow_ctrl
);
4712 static void bnx2x_set_master_ln(struct link_params
*params
,
4713 struct bnx2x_phy
*phy
)
4715 struct bnx2x
*bp
= params
->bp
;
4716 u16 new_master_ln
, ser_lane
;
4717 ser_lane
= ((params
->lane_config
&
4718 PORT_HW_CFG_LANE_SWAP_CFG_MASTER_MASK
) >>
4719 PORT_HW_CFG_LANE_SWAP_CFG_MASTER_SHIFT
);
4721 /* set the master_ln for AN */
4722 CL22_RD_OVER_CL45(bp
, phy
,
4723 MDIO_REG_BANK_XGXS_BLOCK2
,
4724 MDIO_XGXS_BLOCK2_TEST_MODE_LANE
,
4727 CL22_WR_OVER_CL45(bp
, phy
,
4728 MDIO_REG_BANK_XGXS_BLOCK2
,
4729 MDIO_XGXS_BLOCK2_TEST_MODE_LANE
,
4730 (new_master_ln
| ser_lane
));
4733 static int bnx2x_reset_unicore(struct link_params
*params
,
4734 struct bnx2x_phy
*phy
,
4737 struct bnx2x
*bp
= params
->bp
;
4740 CL22_RD_OVER_CL45(bp
, phy
,
4741 MDIO_REG_BANK_COMBO_IEEE0
,
4742 MDIO_COMBO_IEEE0_MII_CONTROL
, &mii_control
);
4744 /* reset the unicore */
4745 CL22_WR_OVER_CL45(bp
, phy
,
4746 MDIO_REG_BANK_COMBO_IEEE0
,
4747 MDIO_COMBO_IEEE0_MII_CONTROL
,
4749 MDIO_COMBO_IEEO_MII_CONTROL_RESET
));
4751 bnx2x_set_serdes_access(bp
, params
->port
);
4753 /* wait for the reset to self clear */
4754 for (i
= 0; i
< MDIO_ACCESS_TIMEOUT
; i
++) {
4757 /* the reset erased the previous bank value */
4758 CL22_RD_OVER_CL45(bp
, phy
,
4759 MDIO_REG_BANK_COMBO_IEEE0
,
4760 MDIO_COMBO_IEEE0_MII_CONTROL
,
4763 if (!(mii_control
& MDIO_COMBO_IEEO_MII_CONTROL_RESET
)) {
4769 netdev_err(bp
->dev
, "Warning: PHY was not initialized,"
4772 DP(NETIF_MSG_LINK
, "BUG! XGXS is still in reset!\n");
4777 static void bnx2x_set_swap_lanes(struct link_params
*params
,
4778 struct bnx2x_phy
*phy
)
4780 struct bnx2x
*bp
= params
->bp
;
4782 * Each two bits represents a lane number:
4783 * No swap is 0123 => 0x1b no need to enable the swap
4785 u16 rx_lane_swap
, tx_lane_swap
;
4787 rx_lane_swap
= ((params
->lane_config
&
4788 PORT_HW_CFG_LANE_SWAP_CFG_RX_MASK
) >>
4789 PORT_HW_CFG_LANE_SWAP_CFG_RX_SHIFT
);
4790 tx_lane_swap
= ((params
->lane_config
&
4791 PORT_HW_CFG_LANE_SWAP_CFG_TX_MASK
) >>
4792 PORT_HW_CFG_LANE_SWAP_CFG_TX_SHIFT
);
4794 if (rx_lane_swap
!= 0x1b) {
4795 CL22_WR_OVER_CL45(bp
, phy
,
4796 MDIO_REG_BANK_XGXS_BLOCK2
,
4797 MDIO_XGXS_BLOCK2_RX_LN_SWAP
,
4799 MDIO_XGXS_BLOCK2_RX_LN_SWAP_ENABLE
|
4800 MDIO_XGXS_BLOCK2_RX_LN_SWAP_FORCE_ENABLE
));
4802 CL22_WR_OVER_CL45(bp
, phy
,
4803 MDIO_REG_BANK_XGXS_BLOCK2
,
4804 MDIO_XGXS_BLOCK2_RX_LN_SWAP
, 0);
4807 if (tx_lane_swap
!= 0x1b) {
4808 CL22_WR_OVER_CL45(bp
, phy
,
4809 MDIO_REG_BANK_XGXS_BLOCK2
,
4810 MDIO_XGXS_BLOCK2_TX_LN_SWAP
,
4812 MDIO_XGXS_BLOCK2_TX_LN_SWAP_ENABLE
));
4814 CL22_WR_OVER_CL45(bp
, phy
,
4815 MDIO_REG_BANK_XGXS_BLOCK2
,
4816 MDIO_XGXS_BLOCK2_TX_LN_SWAP
, 0);
4820 static void bnx2x_set_parallel_detection(struct bnx2x_phy
*phy
,
4821 struct link_params
*params
)
4823 struct bnx2x
*bp
= params
->bp
;
4825 CL22_RD_OVER_CL45(bp
, phy
,
4826 MDIO_REG_BANK_SERDES_DIGITAL
,
4827 MDIO_SERDES_DIGITAL_A_1000X_CONTROL2
,
4829 if (phy
->speed_cap_mask
& PORT_HW_CFG_SPEED_CAPABILITY_D0_1G
)
4830 control2
|= MDIO_SERDES_DIGITAL_A_1000X_CONTROL2_PRL_DT_EN
;
4832 control2
&= ~MDIO_SERDES_DIGITAL_A_1000X_CONTROL2_PRL_DT_EN
;
4833 DP(NETIF_MSG_LINK
, "phy->speed_cap_mask = 0x%x, control2 = 0x%x\n",
4834 phy
->speed_cap_mask
, control2
);
4835 CL22_WR_OVER_CL45(bp
, phy
,
4836 MDIO_REG_BANK_SERDES_DIGITAL
,
4837 MDIO_SERDES_DIGITAL_A_1000X_CONTROL2
,
4840 if ((phy
->type
== PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT
) &&
4841 (phy
->speed_cap_mask
&
4842 PORT_HW_CFG_SPEED_CAPABILITY_D0_10G
)) {
4843 DP(NETIF_MSG_LINK
, "XGXS\n");
4845 CL22_WR_OVER_CL45(bp
, phy
,
4846 MDIO_REG_BANK_10G_PARALLEL_DETECT
,
4847 MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_LINK
,
4848 MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_LINK_CNT
);
4850 CL22_RD_OVER_CL45(bp
, phy
,
4851 MDIO_REG_BANK_10G_PARALLEL_DETECT
,
4852 MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_CONTROL
,
4857 MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_CONTROL_PARDET10G_EN
;
4859 CL22_WR_OVER_CL45(bp
, phy
,
4860 MDIO_REG_BANK_10G_PARALLEL_DETECT
,
4861 MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_CONTROL
,
4864 /* Disable parallel detection of HiG */
4865 CL22_WR_OVER_CL45(bp
, phy
,
4866 MDIO_REG_BANK_XGXS_BLOCK2
,
4867 MDIO_XGXS_BLOCK2_UNICORE_MODE_10G
,
4868 MDIO_XGXS_BLOCK2_UNICORE_MODE_10G_CX4_XGXS
|
4869 MDIO_XGXS_BLOCK2_UNICORE_MODE_10G_HIGIG_XGXS
);
4873 static void bnx2x_set_autoneg(struct bnx2x_phy
*phy
,
4874 struct link_params
*params
,
4875 struct link_vars
*vars
,
4878 struct bnx2x
*bp
= params
->bp
;
4882 CL22_RD_OVER_CL45(bp
, phy
,
4883 MDIO_REG_BANK_COMBO_IEEE0
,
4884 MDIO_COMBO_IEEE0_MII_CONTROL
, ®_val
);
4886 /* CL37 Autoneg Enabled */
4887 if (vars
->line_speed
== SPEED_AUTO_NEG
)
4888 reg_val
|= MDIO_COMBO_IEEO_MII_CONTROL_AN_EN
;
4889 else /* CL37 Autoneg Disabled */
4890 reg_val
&= ~(MDIO_COMBO_IEEO_MII_CONTROL_AN_EN
|
4891 MDIO_COMBO_IEEO_MII_CONTROL_RESTART_AN
);
4893 CL22_WR_OVER_CL45(bp
, phy
,
4894 MDIO_REG_BANK_COMBO_IEEE0
,
4895 MDIO_COMBO_IEEE0_MII_CONTROL
, reg_val
);
4897 /* Enable/Disable Autodetection */
4899 CL22_RD_OVER_CL45(bp
, phy
,
4900 MDIO_REG_BANK_SERDES_DIGITAL
,
4901 MDIO_SERDES_DIGITAL_A_1000X_CONTROL1
, ®_val
);
4902 reg_val
&= ~(MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_SIGNAL_DETECT_EN
|
4903 MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_INVERT_SIGNAL_DETECT
);
4904 reg_val
|= MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_FIBER_MODE
;
4905 if (vars
->line_speed
== SPEED_AUTO_NEG
)
4906 reg_val
|= MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_AUTODET
;
4908 reg_val
&= ~MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_AUTODET
;
4910 CL22_WR_OVER_CL45(bp
, phy
,
4911 MDIO_REG_BANK_SERDES_DIGITAL
,
4912 MDIO_SERDES_DIGITAL_A_1000X_CONTROL1
, reg_val
);
4914 /* Enable TetonII and BAM autoneg */
4915 CL22_RD_OVER_CL45(bp
, phy
,
4916 MDIO_REG_BANK_BAM_NEXT_PAGE
,
4917 MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL
,
4919 if (vars
->line_speed
== SPEED_AUTO_NEG
) {
4920 /* Enable BAM aneg Mode and TetonII aneg Mode */
4921 reg_val
|= (MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL_BAM_MODE
|
4922 MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL_TETON_AN
);
4924 /* TetonII and BAM Autoneg Disabled */
4925 reg_val
&= ~(MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL_BAM_MODE
|
4926 MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL_TETON_AN
);
4928 CL22_WR_OVER_CL45(bp
, phy
,
4929 MDIO_REG_BANK_BAM_NEXT_PAGE
,
4930 MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL
,
4934 /* Enable Cl73 FSM status bits */
4935 CL22_WR_OVER_CL45(bp
, phy
,
4936 MDIO_REG_BANK_CL73_USERB0
,
4937 MDIO_CL73_USERB0_CL73_UCTRL
,
4940 /* Enable BAM Station Manager*/
4941 CL22_WR_OVER_CL45(bp
, phy
,
4942 MDIO_REG_BANK_CL73_USERB0
,
4943 MDIO_CL73_USERB0_CL73_BAM_CTRL1
,
4944 MDIO_CL73_USERB0_CL73_BAM_CTRL1_BAM_EN
|
4945 MDIO_CL73_USERB0_CL73_BAM_CTRL1_BAM_STATION_MNGR_EN
|
4946 MDIO_CL73_USERB0_CL73_BAM_CTRL1_BAM_NP_AFTER_BP_EN
);
4948 /* Advertise CL73 link speeds */
4949 CL22_RD_OVER_CL45(bp
, phy
,
4950 MDIO_REG_BANK_CL73_IEEEB1
,
4951 MDIO_CL73_IEEEB1_AN_ADV2
,
4953 if (phy
->speed_cap_mask
&
4954 PORT_HW_CFG_SPEED_CAPABILITY_D0_10G
)
4955 reg_val
|= MDIO_CL73_IEEEB1_AN_ADV2_ADVR_10G_KX4
;
4956 if (phy
->speed_cap_mask
&
4957 PORT_HW_CFG_SPEED_CAPABILITY_D0_1G
)
4958 reg_val
|= MDIO_CL73_IEEEB1_AN_ADV2_ADVR_1000M_KX
;
4960 CL22_WR_OVER_CL45(bp
, phy
,
4961 MDIO_REG_BANK_CL73_IEEEB1
,
4962 MDIO_CL73_IEEEB1_AN_ADV2
,
4965 /* CL73 Autoneg Enabled */
4966 reg_val
= MDIO_CL73_IEEEB0_CL73_AN_CONTROL_AN_EN
;
4968 } else /* CL73 Autoneg Disabled */
4971 CL22_WR_OVER_CL45(bp
, phy
,
4972 MDIO_REG_BANK_CL73_IEEEB0
,
4973 MDIO_CL73_IEEEB0_CL73_AN_CONTROL
, reg_val
);
4976 /* program SerDes, forced speed */
4977 static void bnx2x_program_serdes(struct bnx2x_phy
*phy
,
4978 struct link_params
*params
,
4979 struct link_vars
*vars
)
4981 struct bnx2x
*bp
= params
->bp
;
4984 /* program duplex, disable autoneg and sgmii*/
4985 CL22_RD_OVER_CL45(bp
, phy
,
4986 MDIO_REG_BANK_COMBO_IEEE0
,
4987 MDIO_COMBO_IEEE0_MII_CONTROL
, ®_val
);
4988 reg_val
&= ~(MDIO_COMBO_IEEO_MII_CONTROL_FULL_DUPLEX
|
4989 MDIO_COMBO_IEEO_MII_CONTROL_AN_EN
|
4990 MDIO_COMBO_IEEO_MII_CONTROL_MAN_SGMII_SP_MASK
);
4991 if (phy
->req_duplex
== DUPLEX_FULL
)
4992 reg_val
|= MDIO_COMBO_IEEO_MII_CONTROL_FULL_DUPLEX
;
4993 CL22_WR_OVER_CL45(bp
, phy
,
4994 MDIO_REG_BANK_COMBO_IEEE0
,
4995 MDIO_COMBO_IEEE0_MII_CONTROL
, reg_val
);
4999 * - needed only if the speed is greater than 1G (2.5G or 10G)
5001 CL22_RD_OVER_CL45(bp
, phy
,
5002 MDIO_REG_BANK_SERDES_DIGITAL
,
5003 MDIO_SERDES_DIGITAL_MISC1
, ®_val
);
5004 /* clearing the speed value before setting the right speed */
5005 DP(NETIF_MSG_LINK
, "MDIO_REG_BANK_SERDES_DIGITAL = 0x%x\n", reg_val
);
5007 reg_val
&= ~(MDIO_SERDES_DIGITAL_MISC1_FORCE_SPEED_MASK
|
5008 MDIO_SERDES_DIGITAL_MISC1_FORCE_SPEED_SEL
);
5010 if (!((vars
->line_speed
== SPEED_1000
) ||
5011 (vars
->line_speed
== SPEED_100
) ||
5012 (vars
->line_speed
== SPEED_10
))) {
5014 reg_val
|= (MDIO_SERDES_DIGITAL_MISC1_REFCLK_SEL_156_25M
|
5015 MDIO_SERDES_DIGITAL_MISC1_FORCE_SPEED_SEL
);
5016 if (vars
->line_speed
== SPEED_10000
)
5018 MDIO_SERDES_DIGITAL_MISC1_FORCE_SPEED_10G_CX4
;
5021 CL22_WR_OVER_CL45(bp
, phy
,
5022 MDIO_REG_BANK_SERDES_DIGITAL
,
5023 MDIO_SERDES_DIGITAL_MISC1
, reg_val
);
5027 static void bnx2x_set_brcm_cl37_advertisement(struct bnx2x_phy
*phy
,
5028 struct link_params
*params
)
5030 struct bnx2x
*bp
= params
->bp
;
5033 /* configure the 48 bits for BAM AN */
5035 /* set extended capabilities */
5036 if (phy
->speed_cap_mask
& PORT_HW_CFG_SPEED_CAPABILITY_D0_2_5G
)
5037 val
|= MDIO_OVER_1G_UP1_2_5G
;
5038 if (phy
->speed_cap_mask
& PORT_HW_CFG_SPEED_CAPABILITY_D0_10G
)
5039 val
|= MDIO_OVER_1G_UP1_10G
;
5040 CL22_WR_OVER_CL45(bp
, phy
,
5041 MDIO_REG_BANK_OVER_1G
,
5042 MDIO_OVER_1G_UP1
, val
);
5044 CL22_WR_OVER_CL45(bp
, phy
,
5045 MDIO_REG_BANK_OVER_1G
,
5046 MDIO_OVER_1G_UP3
, 0x400);
5049 static void bnx2x_set_ieee_aneg_advertisement(struct bnx2x_phy
*phy
,
5050 struct link_params
*params
,
5053 struct bnx2x
*bp
= params
->bp
;
5055 /* for AN, we are always publishing full duplex */
5057 CL22_WR_OVER_CL45(bp
, phy
,
5058 MDIO_REG_BANK_COMBO_IEEE0
,
5059 MDIO_COMBO_IEEE0_AUTO_NEG_ADV
, ieee_fc
);
5060 CL22_RD_OVER_CL45(bp
, phy
,
5061 MDIO_REG_BANK_CL73_IEEEB1
,
5062 MDIO_CL73_IEEEB1_AN_ADV1
, &val
);
5063 val
&= ~MDIO_CL73_IEEEB1_AN_ADV1_PAUSE_BOTH
;
5064 val
|= ((ieee_fc
<<3) & MDIO_CL73_IEEEB1_AN_ADV1_PAUSE_MASK
);
5065 CL22_WR_OVER_CL45(bp
, phy
,
5066 MDIO_REG_BANK_CL73_IEEEB1
,
5067 MDIO_CL73_IEEEB1_AN_ADV1
, val
);
5070 static void bnx2x_restart_autoneg(struct bnx2x_phy
*phy
,
5071 struct link_params
*params
,
5074 struct bnx2x
*bp
= params
->bp
;
5077 DP(NETIF_MSG_LINK
, "bnx2x_restart_autoneg\n");
5078 /* Enable and restart BAM/CL37 aneg */
5081 CL22_RD_OVER_CL45(bp
, phy
,
5082 MDIO_REG_BANK_CL73_IEEEB0
,
5083 MDIO_CL73_IEEEB0_CL73_AN_CONTROL
,
5086 CL22_WR_OVER_CL45(bp
, phy
,
5087 MDIO_REG_BANK_CL73_IEEEB0
,
5088 MDIO_CL73_IEEEB0_CL73_AN_CONTROL
,
5090 MDIO_CL73_IEEEB0_CL73_AN_CONTROL_AN_EN
|
5091 MDIO_CL73_IEEEB0_CL73_AN_CONTROL_RESTART_AN
));
5094 CL22_RD_OVER_CL45(bp
, phy
,
5095 MDIO_REG_BANK_COMBO_IEEE0
,
5096 MDIO_COMBO_IEEE0_MII_CONTROL
,
5099 "bnx2x_restart_autoneg mii_control before = 0x%x\n",
5101 CL22_WR_OVER_CL45(bp
, phy
,
5102 MDIO_REG_BANK_COMBO_IEEE0
,
5103 MDIO_COMBO_IEEE0_MII_CONTROL
,
5105 MDIO_COMBO_IEEO_MII_CONTROL_AN_EN
|
5106 MDIO_COMBO_IEEO_MII_CONTROL_RESTART_AN
));
5110 static void bnx2x_initialize_sgmii_process(struct bnx2x_phy
*phy
,
5111 struct link_params
*params
,
5112 struct link_vars
*vars
)
5114 struct bnx2x
*bp
= params
->bp
;
5117 /* in SGMII mode, the unicore is always slave */
5119 CL22_RD_OVER_CL45(bp
, phy
,
5120 MDIO_REG_BANK_SERDES_DIGITAL
,
5121 MDIO_SERDES_DIGITAL_A_1000X_CONTROL1
,
5123 control1
|= MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_INVERT_SIGNAL_DETECT
;
5124 /* set sgmii mode (and not fiber) */
5125 control1
&= ~(MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_FIBER_MODE
|
5126 MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_AUTODET
|
5127 MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_MSTR_MODE
);
5128 CL22_WR_OVER_CL45(bp
, phy
,
5129 MDIO_REG_BANK_SERDES_DIGITAL
,
5130 MDIO_SERDES_DIGITAL_A_1000X_CONTROL1
,
5133 /* if forced speed */
5134 if (!(vars
->line_speed
== SPEED_AUTO_NEG
)) {
5135 /* set speed, disable autoneg */
5138 CL22_RD_OVER_CL45(bp
, phy
,
5139 MDIO_REG_BANK_COMBO_IEEE0
,
5140 MDIO_COMBO_IEEE0_MII_CONTROL
,
5142 mii_control
&= ~(MDIO_COMBO_IEEO_MII_CONTROL_AN_EN
|
5143 MDIO_COMBO_IEEO_MII_CONTROL_MAN_SGMII_SP_MASK
|
5144 MDIO_COMBO_IEEO_MII_CONTROL_FULL_DUPLEX
);
5146 switch (vars
->line_speed
) {
5149 MDIO_COMBO_IEEO_MII_CONTROL_MAN_SGMII_SP_100
;
5153 MDIO_COMBO_IEEO_MII_CONTROL_MAN_SGMII_SP_1000
;
5156 /* there is nothing to set for 10M */
5159 /* invalid speed for SGMII */
5160 DP(NETIF_MSG_LINK
, "Invalid line_speed 0x%x\n",
5165 /* setting the full duplex */
5166 if (phy
->req_duplex
== DUPLEX_FULL
)
5168 MDIO_COMBO_IEEO_MII_CONTROL_FULL_DUPLEX
;
5169 CL22_WR_OVER_CL45(bp
, phy
,
5170 MDIO_REG_BANK_COMBO_IEEE0
,
5171 MDIO_COMBO_IEEE0_MII_CONTROL
,
5174 } else { /* AN mode */
5175 /* enable and restart AN */
5176 bnx2x_restart_autoneg(phy
, params
, 0);
5185 static int bnx2x_direct_parallel_detect_used(struct bnx2x_phy
*phy
,
5186 struct link_params
*params
)
5188 struct bnx2x
*bp
= params
->bp
;
5189 u16 pd_10g
, status2_1000x
;
5190 if (phy
->req_line_speed
!= SPEED_AUTO_NEG
)
5192 CL22_RD_OVER_CL45(bp
, phy
,
5193 MDIO_REG_BANK_SERDES_DIGITAL
,
5194 MDIO_SERDES_DIGITAL_A_1000X_STATUS2
,
5196 CL22_RD_OVER_CL45(bp
, phy
,
5197 MDIO_REG_BANK_SERDES_DIGITAL
,
5198 MDIO_SERDES_DIGITAL_A_1000X_STATUS2
,
5200 if (status2_1000x
& MDIO_SERDES_DIGITAL_A_1000X_STATUS2_AN_DISABLED
) {
5201 DP(NETIF_MSG_LINK
, "1G parallel detect link on port %d\n",
5206 CL22_RD_OVER_CL45(bp
, phy
,
5207 MDIO_REG_BANK_10G_PARALLEL_DETECT
,
5208 MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_STATUS
,
5211 if (pd_10g
& MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_STATUS_PD_LINK
) {
5212 DP(NETIF_MSG_LINK
, "10G parallel detect link on port %d\n",
5219 static void bnx2x_flow_ctrl_resolve(struct bnx2x_phy
*phy
,
5220 struct link_params
*params
,
5221 struct link_vars
*vars
,
5224 struct bnx2x
*bp
= params
->bp
;
5225 u16 ld_pause
; /* local driver */
5226 u16 lp_pause
; /* link partner */
5229 vars
->flow_ctrl
= BNX2X_FLOW_CTRL_NONE
;
5231 /* resolve from gp_status in case of AN complete and not sgmii */
5232 if (phy
->req_flow_ctrl
!= BNX2X_FLOW_CTRL_AUTO
)
5233 vars
->flow_ctrl
= phy
->req_flow_ctrl
;
5234 else if (phy
->req_line_speed
!= SPEED_AUTO_NEG
)
5235 vars
->flow_ctrl
= params
->req_fc_auto_adv
;
5236 else if ((gp_status
& MDIO_AN_CL73_OR_37_COMPLETE
) &&
5237 (!(vars
->phy_flags
& PHY_SGMII_FLAG
))) {
5238 if (bnx2x_direct_parallel_detect_used(phy
, params
)) {
5239 vars
->flow_ctrl
= params
->req_fc_auto_adv
;
5243 (MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_AUTONEG_COMPLETE
|
5244 MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_MR_LP_NP_AN_ABLE
)) ==
5245 (MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_AUTONEG_COMPLETE
|
5246 MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_MR_LP_NP_AN_ABLE
)) {
5248 CL22_RD_OVER_CL45(bp
, phy
,
5249 MDIO_REG_BANK_CL73_IEEEB1
,
5250 MDIO_CL73_IEEEB1_AN_ADV1
,
5252 CL22_RD_OVER_CL45(bp
, phy
,
5253 MDIO_REG_BANK_CL73_IEEEB1
,
5254 MDIO_CL73_IEEEB1_AN_LP_ADV1
,
5256 pause_result
= (ld_pause
&
5257 MDIO_CL73_IEEEB1_AN_ADV1_PAUSE_MASK
)
5259 pause_result
|= (lp_pause
&
5260 MDIO_CL73_IEEEB1_AN_LP_ADV1_PAUSE_MASK
)
5262 DP(NETIF_MSG_LINK
, "pause_result CL73 0x%x\n",
5265 CL22_RD_OVER_CL45(bp
, phy
,
5266 MDIO_REG_BANK_COMBO_IEEE0
,
5267 MDIO_COMBO_IEEE0_AUTO_NEG_ADV
,
5269 CL22_RD_OVER_CL45(bp
, phy
,
5270 MDIO_REG_BANK_COMBO_IEEE0
,
5271 MDIO_COMBO_IEEE0_AUTO_NEG_LINK_PARTNER_ABILITY1
,
5273 pause_result
= (ld_pause
&
5274 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_MASK
)>>5;
5275 pause_result
|= (lp_pause
&
5276 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_MASK
)>>7;
5277 DP(NETIF_MSG_LINK
, "pause_result CL37 0x%x\n",
5280 bnx2x_pause_resolve(vars
, pause_result
);
5282 DP(NETIF_MSG_LINK
, "flow_ctrl 0x%x\n", vars
->flow_ctrl
);
5285 static void bnx2x_check_fallback_to_cl37(struct bnx2x_phy
*phy
,
5286 struct link_params
*params
)
5288 struct bnx2x
*bp
= params
->bp
;
5289 u16 rx_status
, ustat_val
, cl37_fsm_received
;
5290 DP(NETIF_MSG_LINK
, "bnx2x_check_fallback_to_cl37\n");
5291 /* Step 1: Make sure signal is detected */
5292 CL22_RD_OVER_CL45(bp
, phy
,
5296 if ((rx_status
& MDIO_RX0_RX_STATUS_SIGDET
) !=
5297 (MDIO_RX0_RX_STATUS_SIGDET
)) {
5298 DP(NETIF_MSG_LINK
, "Signal is not detected. Restoring CL73."
5299 "rx_status(0x80b0) = 0x%x\n", rx_status
);
5300 CL22_WR_OVER_CL45(bp
, phy
,
5301 MDIO_REG_BANK_CL73_IEEEB0
,
5302 MDIO_CL73_IEEEB0_CL73_AN_CONTROL
,
5303 MDIO_CL73_IEEEB0_CL73_AN_CONTROL_AN_EN
);
5306 /* Step 2: Check CL73 state machine */
5307 CL22_RD_OVER_CL45(bp
, phy
,
5308 MDIO_REG_BANK_CL73_USERB0
,
5309 MDIO_CL73_USERB0_CL73_USTAT1
,
5312 (MDIO_CL73_USERB0_CL73_USTAT1_LINK_STATUS_CHECK
|
5313 MDIO_CL73_USERB0_CL73_USTAT1_AN_GOOD_CHECK_BAM37
)) !=
5314 (MDIO_CL73_USERB0_CL73_USTAT1_LINK_STATUS_CHECK
|
5315 MDIO_CL73_USERB0_CL73_USTAT1_AN_GOOD_CHECK_BAM37
)) {
5316 DP(NETIF_MSG_LINK
, "CL73 state-machine is not stable. "
5317 "ustat_val(0x8371) = 0x%x\n", ustat_val
);
5321 * Step 3: Check CL37 Message Pages received to indicate LP
5322 * supports only CL37
5324 CL22_RD_OVER_CL45(bp
, phy
,
5325 MDIO_REG_BANK_REMOTE_PHY
,
5326 MDIO_REMOTE_PHY_MISC_RX_STATUS
,
5327 &cl37_fsm_received
);
5328 if ((cl37_fsm_received
&
5329 (MDIO_REMOTE_PHY_MISC_RX_STATUS_CL37_FSM_RECEIVED_OVER1G_MSG
|
5330 MDIO_REMOTE_PHY_MISC_RX_STATUS_CL37_FSM_RECEIVED_BRCM_OUI_MSG
)) !=
5331 (MDIO_REMOTE_PHY_MISC_RX_STATUS_CL37_FSM_RECEIVED_OVER1G_MSG
|
5332 MDIO_REMOTE_PHY_MISC_RX_STATUS_CL37_FSM_RECEIVED_BRCM_OUI_MSG
)) {
5333 DP(NETIF_MSG_LINK
, "No CL37 FSM were received. "
5334 "misc_rx_status(0x8330) = 0x%x\n",
5339 * The combined cl37/cl73 fsm state information indicating that
5340 * we are connected to a device which does not support cl73, but
5341 * does support cl37 BAM. In this case we disable cl73 and
5342 * restart cl37 auto-neg
5346 CL22_WR_OVER_CL45(bp
, phy
,
5347 MDIO_REG_BANK_CL73_IEEEB0
,
5348 MDIO_CL73_IEEEB0_CL73_AN_CONTROL
,
5350 /* Restart CL37 autoneg */
5351 bnx2x_restart_autoneg(phy
, params
, 0);
5352 DP(NETIF_MSG_LINK
, "Disabling CL73, and restarting CL37 autoneg\n");
5355 static void bnx2x_xgxs_an_resolve(struct bnx2x_phy
*phy
,
5356 struct link_params
*params
,
5357 struct link_vars
*vars
,
5360 if (gp_status
& MDIO_AN_CL73_OR_37_COMPLETE
)
5361 vars
->link_status
|=
5362 LINK_STATUS_AUTO_NEGOTIATE_COMPLETE
;
5364 if (bnx2x_direct_parallel_detect_used(phy
, params
))
5365 vars
->link_status
|=
5366 LINK_STATUS_PARALLEL_DETECTION_USED
;
5368 static int bnx2x_get_link_speed_duplex(struct bnx2x_phy
*phy
,
5369 struct link_params
*params
,
5370 struct link_vars
*vars
,
5375 struct bnx2x
*bp
= params
->bp
;
5376 if (phy
->req_line_speed
== SPEED_AUTO_NEG
)
5377 vars
->link_status
|= LINK_STATUS_AUTO_NEGOTIATE_ENABLED
;
5379 DP(NETIF_MSG_LINK
, "phy link up\n");
5381 vars
->phy_link_up
= 1;
5382 vars
->link_status
|= LINK_STATUS_LINK_UP
;
5384 switch (speed_mask
) {
5386 vars
->line_speed
= SPEED_10
;
5387 if (vars
->duplex
== DUPLEX_FULL
)
5388 vars
->link_status
|= LINK_10TFD
;
5390 vars
->link_status
|= LINK_10THD
;
5393 case GP_STATUS_100M
:
5394 vars
->line_speed
= SPEED_100
;
5395 if (vars
->duplex
== DUPLEX_FULL
)
5396 vars
->link_status
|= LINK_100TXFD
;
5398 vars
->link_status
|= LINK_100TXHD
;
5402 case GP_STATUS_1G_KX
:
5403 vars
->line_speed
= SPEED_1000
;
5404 if (vars
->duplex
== DUPLEX_FULL
)
5405 vars
->link_status
|= LINK_1000TFD
;
5407 vars
->link_status
|= LINK_1000THD
;
5410 case GP_STATUS_2_5G
:
5411 vars
->line_speed
= SPEED_2500
;
5412 if (vars
->duplex
== DUPLEX_FULL
)
5413 vars
->link_status
|= LINK_2500TFD
;
5415 vars
->link_status
|= LINK_2500THD
;
5421 "link speed unsupported gp_status 0x%x\n",
5425 case GP_STATUS_10G_KX4
:
5426 case GP_STATUS_10G_HIG
:
5427 case GP_STATUS_10G_CX4
:
5428 case GP_STATUS_10G_KR
:
5429 case GP_STATUS_10G_SFI
:
5430 case GP_STATUS_10G_XFI
:
5431 vars
->line_speed
= SPEED_10000
;
5432 vars
->link_status
|= LINK_10GTFD
;
5434 case GP_STATUS_20G_DXGXS
:
5435 vars
->line_speed
= SPEED_20000
;
5436 vars
->link_status
|= LINK_20GTFD
;
5440 "link speed unsupported gp_status 0x%x\n",
5444 } else { /* link_down */
5445 DP(NETIF_MSG_LINK
, "phy link down\n");
5447 vars
->phy_link_up
= 0;
5449 vars
->duplex
= DUPLEX_FULL
;
5450 vars
->flow_ctrl
= BNX2X_FLOW_CTRL_NONE
;
5451 vars
->mac_type
= MAC_TYPE_NONE
;
5453 DP(NETIF_MSG_LINK
, " phy_link_up %x line_speed %d\n",
5454 vars
->phy_link_up
, vars
->line_speed
);
5458 static int bnx2x_link_settings_status(struct bnx2x_phy
*phy
,
5459 struct link_params
*params
,
5460 struct link_vars
*vars
)
5462 struct bnx2x
*bp
= params
->bp
;
5464 u16 gp_status
, duplex
= DUPLEX_HALF
, link_up
= 0, speed_mask
;
5467 /* Read gp_status */
5468 CL22_RD_OVER_CL45(bp
, phy
,
5469 MDIO_REG_BANK_GP_STATUS
,
5470 MDIO_GP_STATUS_TOP_AN_STATUS1
,
5472 if (gp_status
& MDIO_GP_STATUS_TOP_AN_STATUS1_DUPLEX_STATUS
)
5473 duplex
= DUPLEX_FULL
;
5474 if (gp_status
& MDIO_GP_STATUS_TOP_AN_STATUS1_LINK_STATUS
)
5476 speed_mask
= gp_status
& GP_STATUS_SPEED_MASK
;
5477 DP(NETIF_MSG_LINK
, "gp_status 0x%x, is_link_up %d, speed_mask 0x%x\n",
5478 gp_status
, link_up
, speed_mask
);
5479 rc
= bnx2x_get_link_speed_duplex(phy
, params
, vars
, link_up
, speed_mask
,
5484 if (gp_status
& MDIO_GP_STATUS_TOP_AN_STATUS1_LINK_STATUS
) {
5485 if (SINGLE_MEDIA_DIRECT(params
)) {
5486 bnx2x_flow_ctrl_resolve(phy
, params
, vars
, gp_status
);
5487 if (phy
->req_line_speed
== SPEED_AUTO_NEG
)
5488 bnx2x_xgxs_an_resolve(phy
, params
, vars
,
5491 } else { /* link_down */
5492 if ((phy
->req_line_speed
== SPEED_AUTO_NEG
) &&
5493 SINGLE_MEDIA_DIRECT(params
)) {
5494 /* Check signal is detected */
5495 bnx2x_check_fallback_to_cl37(phy
, params
);
5499 DP(NETIF_MSG_LINK
, "duplex %x flow_ctrl 0x%x link_status 0x%x\n",
5500 vars
->duplex
, vars
->flow_ctrl
, vars
->link_status
);
5504 static int bnx2x_warpcore_read_status(struct bnx2x_phy
*phy
,
5505 struct link_params
*params
,
5506 struct link_vars
*vars
)
5508 struct bnx2x
*bp
= params
->bp
;
5510 u16 gp_status1
, gp_speed
, link_up
, duplex
= DUPLEX_FULL
;
5512 lane
= bnx2x_get_warpcore_lane(phy
, params
);
5513 /* Read gp_status */
5514 if (phy
->req_line_speed
> SPEED_10000
) {
5516 bnx2x_cl45_read(bp
, phy
, MDIO_WC_DEVAD
,
5518 bnx2x_cl45_read(bp
, phy
, MDIO_WC_DEVAD
,
5520 DP(NETIF_MSG_LINK
, "PCS RX link status = 0x%x-->0x%x\n",
5521 temp_link_up
, link_up
);
5524 bnx2x_ext_phy_resolve_fc(phy
, params
, vars
);
5526 bnx2x_cl45_read(bp
, phy
, MDIO_WC_DEVAD
,
5527 MDIO_WC_REG_GP2_STATUS_GP_2_1
, &gp_status1
);
5528 DP(NETIF_MSG_LINK
, "0x81d1 = 0x%x\n", gp_status1
);
5529 /* Check for either KR or generic link up. */
5530 gp_status1
= ((gp_status1
>> 8) & 0xf) |
5531 ((gp_status1
>> 12) & 0xf);
5532 link_up
= gp_status1
& (1 << lane
);
5533 if (link_up
&& SINGLE_MEDIA_DIRECT(params
)) {
5535 if (phy
->req_line_speed
== SPEED_AUTO_NEG
) {
5536 /* Check Autoneg complete */
5537 bnx2x_cl45_read(bp
, phy
, MDIO_WC_DEVAD
,
5538 MDIO_WC_REG_GP2_STATUS_GP_2_4
,
5540 if (gp_status4
& ((1<<12)<<lane
))
5541 vars
->link_status
|=
5542 LINK_STATUS_AUTO_NEGOTIATE_COMPLETE
;
5544 /* Check parallel detect used */
5545 bnx2x_cl45_read(bp
, phy
, MDIO_WC_DEVAD
,
5546 MDIO_WC_REG_PAR_DET_10G_STATUS
,
5549 vars
->link_status
|=
5550 LINK_STATUS_PARALLEL_DETECTION_USED
;
5552 bnx2x_ext_phy_resolve_fc(phy
, params
, vars
);
5557 bnx2x_cl45_read(bp
, phy
, MDIO_WC_DEVAD
,
5558 MDIO_WC_REG_GP2_STATUS_GP_2_2
, &gp_speed
);
5560 bnx2x_cl45_read(bp
, phy
, MDIO_WC_DEVAD
,
5561 MDIO_WC_REG_GP2_STATUS_GP_2_3
, &gp_speed
);
5563 DP(NETIF_MSG_LINK
, "lane %d gp_speed 0x%x\n", lane
, gp_speed
);
5565 if ((lane
& 1) == 0)
5570 rc
= bnx2x_get_link_speed_duplex(phy
, params
, vars
, link_up
, gp_speed
,
5573 DP(NETIF_MSG_LINK
, "duplex %x flow_ctrl 0x%x link_status 0x%x\n",
5574 vars
->duplex
, vars
->flow_ctrl
, vars
->link_status
);
5577 static void bnx2x_set_gmii_tx_driver(struct link_params
*params
)
5579 struct bnx2x
*bp
= params
->bp
;
5580 struct bnx2x_phy
*phy
= ¶ms
->phy
[INT_PHY
];
5586 CL22_RD_OVER_CL45(bp
, phy
,
5587 MDIO_REG_BANK_OVER_1G
,
5588 MDIO_OVER_1G_LP_UP2
, &lp_up2
);
5590 /* bits [10:7] at lp_up2, positioned at [15:12] */
5591 lp_up2
= (((lp_up2
& MDIO_OVER_1G_LP_UP2_PREEMPHASIS_MASK
) >>
5592 MDIO_OVER_1G_LP_UP2_PREEMPHASIS_SHIFT
) <<
5593 MDIO_TX0_TX_DRIVER_PREEMPHASIS_SHIFT
);
5598 for (bank
= MDIO_REG_BANK_TX0
; bank
<= MDIO_REG_BANK_TX3
;
5599 bank
+= (MDIO_REG_BANK_TX1
- MDIO_REG_BANK_TX0
)) {
5600 CL22_RD_OVER_CL45(bp
, phy
,
5602 MDIO_TX0_TX_DRIVER
, &tx_driver
);
5604 /* replace tx_driver bits [15:12] */
5606 (tx_driver
& MDIO_TX0_TX_DRIVER_PREEMPHASIS_MASK
)) {
5607 tx_driver
&= ~MDIO_TX0_TX_DRIVER_PREEMPHASIS_MASK
;
5608 tx_driver
|= lp_up2
;
5609 CL22_WR_OVER_CL45(bp
, phy
,
5611 MDIO_TX0_TX_DRIVER
, tx_driver
);
5616 static int bnx2x_emac_program(struct link_params
*params
,
5617 struct link_vars
*vars
)
5619 struct bnx2x
*bp
= params
->bp
;
5620 u8 port
= params
->port
;
5623 DP(NETIF_MSG_LINK
, "setting link speed & duplex\n");
5624 bnx2x_bits_dis(bp
, GRCBASE_EMAC0
+ port
*0x400 +
5626 (EMAC_MODE_25G_MODE
|
5627 EMAC_MODE_PORT_MII_10M
|
5628 EMAC_MODE_HALF_DUPLEX
));
5629 switch (vars
->line_speed
) {
5631 mode
|= EMAC_MODE_PORT_MII_10M
;
5635 mode
|= EMAC_MODE_PORT_MII
;
5639 mode
|= EMAC_MODE_PORT_GMII
;
5643 mode
|= (EMAC_MODE_25G_MODE
| EMAC_MODE_PORT_GMII
);
5647 /* 10G not valid for EMAC */
5648 DP(NETIF_MSG_LINK
, "Invalid line_speed 0x%x\n",
5653 if (vars
->duplex
== DUPLEX_HALF
)
5654 mode
|= EMAC_MODE_HALF_DUPLEX
;
5656 GRCBASE_EMAC0
+ port
*0x400 + EMAC_REG_EMAC_MODE
,
5659 bnx2x_set_led(params
, vars
, LED_MODE_OPER
, vars
->line_speed
);
5663 static void bnx2x_set_preemphasis(struct bnx2x_phy
*phy
,
5664 struct link_params
*params
)
5668 struct bnx2x
*bp
= params
->bp
;
5670 for (bank
= MDIO_REG_BANK_RX0
, i
= 0; bank
<= MDIO_REG_BANK_RX3
;
5671 bank
+= (MDIO_REG_BANK_RX1
-MDIO_REG_BANK_RX0
), i
++) {
5672 CL22_WR_OVER_CL45(bp
, phy
,
5674 MDIO_RX0_RX_EQ_BOOST
,
5675 phy
->rx_preemphasis
[i
]);
5678 for (bank
= MDIO_REG_BANK_TX0
, i
= 0; bank
<= MDIO_REG_BANK_TX3
;
5679 bank
+= (MDIO_REG_BANK_TX1
- MDIO_REG_BANK_TX0
), i
++) {
5680 CL22_WR_OVER_CL45(bp
, phy
,
5683 phy
->tx_preemphasis
[i
]);
5687 static void bnx2x_xgxs_config_init(struct bnx2x_phy
*phy
,
5688 struct link_params
*params
,
5689 struct link_vars
*vars
)
5691 struct bnx2x
*bp
= params
->bp
;
5692 u8 enable_cl73
= (SINGLE_MEDIA_DIRECT(params
) ||
5693 (params
->loopback_mode
== LOOPBACK_XGXS
));
5694 if (!(vars
->phy_flags
& PHY_SGMII_FLAG
)) {
5695 if (SINGLE_MEDIA_DIRECT(params
) &&
5696 (params
->feature_config_flags
&
5697 FEATURE_CONFIG_OVERRIDE_PREEMPHASIS_ENABLED
))
5698 bnx2x_set_preemphasis(phy
, params
);
5700 /* forced speed requested? */
5701 if (vars
->line_speed
!= SPEED_AUTO_NEG
||
5702 (SINGLE_MEDIA_DIRECT(params
) &&
5703 params
->loopback_mode
== LOOPBACK_EXT
)) {
5704 DP(NETIF_MSG_LINK
, "not SGMII, no AN\n");
5706 /* disable autoneg */
5707 bnx2x_set_autoneg(phy
, params
, vars
, 0);
5709 /* program speed and duplex */
5710 bnx2x_program_serdes(phy
, params
, vars
);
5712 } else { /* AN_mode */
5713 DP(NETIF_MSG_LINK
, "not SGMII, AN\n");
5716 bnx2x_set_brcm_cl37_advertisement(phy
, params
);
5718 /* program duplex & pause advertisement (for aneg) */
5719 bnx2x_set_ieee_aneg_advertisement(phy
, params
,
5722 /* enable autoneg */
5723 bnx2x_set_autoneg(phy
, params
, vars
, enable_cl73
);
5725 /* enable and restart AN */
5726 bnx2x_restart_autoneg(phy
, params
, enable_cl73
);
5729 } else { /* SGMII mode */
5730 DP(NETIF_MSG_LINK
, "SGMII\n");
5732 bnx2x_initialize_sgmii_process(phy
, params
, vars
);
5736 static int bnx2x_prepare_xgxs(struct bnx2x_phy
*phy
,
5737 struct link_params
*params
,
5738 struct link_vars
*vars
)
5741 vars
->phy_flags
|= PHY_XGXS_FLAG
;
5742 if ((phy
->req_line_speed
&&
5743 ((phy
->req_line_speed
== SPEED_100
) ||
5744 (phy
->req_line_speed
== SPEED_10
))) ||
5745 (!phy
->req_line_speed
&&
5746 (phy
->speed_cap_mask
>=
5747 PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_FULL
) &&
5748 (phy
->speed_cap_mask
<
5749 PORT_HW_CFG_SPEED_CAPABILITY_D0_1G
)) ||
5750 (phy
->type
== PORT_HW_CFG_SERDES_EXT_PHY_TYPE_DIRECT_SD
))
5751 vars
->phy_flags
|= PHY_SGMII_FLAG
;
5753 vars
->phy_flags
&= ~PHY_SGMII_FLAG
;
5755 bnx2x_calc_ieee_aneg_adv(phy
, params
, &vars
->ieee_fc
);
5756 bnx2x_set_aer_mmd(params
, phy
);
5757 if (phy
->type
== PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT
)
5758 bnx2x_set_master_ln(params
, phy
);
5760 rc
= bnx2x_reset_unicore(params
, phy
, 0);
5761 /* reset the SerDes and wait for reset bit return low */
5765 bnx2x_set_aer_mmd(params
, phy
);
5766 /* setting the masterLn_def again after the reset */
5767 if (phy
->type
== PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT
) {
5768 bnx2x_set_master_ln(params
, phy
);
5769 bnx2x_set_swap_lanes(params
, phy
);
5775 static u16
bnx2x_wait_reset_complete(struct bnx2x
*bp
,
5776 struct bnx2x_phy
*phy
,
5777 struct link_params
*params
)
5780 /* Wait for soft reset to get cleared up to 1 sec */
5781 for (cnt
= 0; cnt
< 1000; cnt
++) {
5782 if (phy
->type
== PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54618SE
)
5783 bnx2x_cl22_read(bp
, phy
,
5784 MDIO_PMA_REG_CTRL
, &ctrl
);
5786 bnx2x_cl45_read(bp
, phy
,
5788 MDIO_PMA_REG_CTRL
, &ctrl
);
5789 if (!(ctrl
& (1<<15)))
5795 netdev_err(bp
->dev
, "Warning: PHY was not initialized,"
5798 DP(NETIF_MSG_LINK
, "control reg 0x%x (after %d ms)\n", ctrl
, cnt
);
5802 static void bnx2x_link_int_enable(struct link_params
*params
)
5804 u8 port
= params
->port
;
5806 struct bnx2x
*bp
= params
->bp
;
5808 /* Setting the status to report on link up for either XGXS or SerDes */
5809 if (CHIP_IS_E3(bp
)) {
5810 mask
= NIG_MASK_XGXS0_LINK_STATUS
;
5811 if (!(SINGLE_MEDIA_DIRECT(params
)))
5812 mask
|= NIG_MASK_MI_INT
;
5813 } else if (params
->switch_cfg
== SWITCH_CFG_10G
) {
5814 mask
= (NIG_MASK_XGXS0_LINK10G
|
5815 NIG_MASK_XGXS0_LINK_STATUS
);
5816 DP(NETIF_MSG_LINK
, "enabled XGXS interrupt\n");
5817 if (!(SINGLE_MEDIA_DIRECT(params
)) &&
5818 params
->phy
[INT_PHY
].type
!=
5819 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_FAILURE
) {
5820 mask
|= NIG_MASK_MI_INT
;
5821 DP(NETIF_MSG_LINK
, "enabled external phy int\n");
5824 } else { /* SerDes */
5825 mask
= NIG_MASK_SERDES0_LINK_STATUS
;
5826 DP(NETIF_MSG_LINK
, "enabled SerDes interrupt\n");
5827 if (!(SINGLE_MEDIA_DIRECT(params
)) &&
5828 params
->phy
[INT_PHY
].type
!=
5829 PORT_HW_CFG_SERDES_EXT_PHY_TYPE_NOT_CONN
) {
5830 mask
|= NIG_MASK_MI_INT
;
5831 DP(NETIF_MSG_LINK
, "enabled external phy int\n");
5835 NIG_REG_MASK_INTERRUPT_PORT0
+ port
*4,
5838 DP(NETIF_MSG_LINK
, "port %x, is_xgxs %x, int_status 0x%x\n", port
,
5839 (params
->switch_cfg
== SWITCH_CFG_10G
),
5840 REG_RD(bp
, NIG_REG_STATUS_INTERRUPT_PORT0
+ port
*4));
5841 DP(NETIF_MSG_LINK
, " int_mask 0x%x, MI_INT %x, SERDES_LINK %x\n",
5842 REG_RD(bp
, NIG_REG_MASK_INTERRUPT_PORT0
+ port
*4),
5843 REG_RD(bp
, NIG_REG_EMAC0_STATUS_MISC_MI_INT
+ port
*0x18),
5844 REG_RD(bp
, NIG_REG_SERDES0_STATUS_LINK_STATUS
+port
*0x3c));
5845 DP(NETIF_MSG_LINK
, " 10G %x, XGXS_LINK %x\n",
5846 REG_RD(bp
, NIG_REG_XGXS0_STATUS_LINK10G
+ port
*0x68),
5847 REG_RD(bp
, NIG_REG_XGXS0_STATUS_LINK_STATUS
+ port
*0x68));
5850 static void bnx2x_rearm_latch_signal(struct bnx2x
*bp
, u8 port
,
5853 u32 latch_status
= 0;
5856 * Disable the MI INT ( external phy int ) by writing 1 to the
5857 * status register. Link down indication is high-active-signal,
5858 * so in this case we need to write the status to clear the XOR
5860 /* Read Latched signals */
5861 latch_status
= REG_RD(bp
,
5862 NIG_REG_LATCH_STATUS_0
+ port
*8);
5863 DP(NETIF_MSG_LINK
, "latch_status = 0x%x\n", latch_status
);
5864 /* Handle only those with latched-signal=up.*/
5867 NIG_REG_STATUS_INTERRUPT_PORT0
5869 NIG_STATUS_EMAC0_MI_INT
);
5872 NIG_REG_STATUS_INTERRUPT_PORT0
5874 NIG_STATUS_EMAC0_MI_INT
);
5876 if (latch_status
& 1) {
5878 /* For all latched-signal=up : Re-Arm Latch signals */
5879 REG_WR(bp
, NIG_REG_LATCH_STATUS_0
+ port
*8,
5880 (latch_status
& 0xfffe) | (latch_status
& 1));
5882 /* For all latched-signal=up,Write original_signal to status */
5885 static void bnx2x_link_int_ack(struct link_params
*params
,
5886 struct link_vars
*vars
, u8 is_10g_plus
)
5888 struct bnx2x
*bp
= params
->bp
;
5889 u8 port
= params
->port
;
5892 * First reset all status we assume only one line will be
5895 bnx2x_bits_dis(bp
, NIG_REG_STATUS_INTERRUPT_PORT0
+ port
*4,
5896 (NIG_STATUS_XGXS0_LINK10G
|
5897 NIG_STATUS_XGXS0_LINK_STATUS
|
5898 NIG_STATUS_SERDES0_LINK_STATUS
));
5899 if (vars
->phy_link_up
) {
5900 if (USES_WARPCORE(bp
))
5901 mask
= NIG_STATUS_XGXS0_LINK_STATUS
;
5904 mask
= NIG_STATUS_XGXS0_LINK10G
;
5905 else if (params
->switch_cfg
== SWITCH_CFG_10G
) {
5907 * Disable the link interrupt by writing 1 to
5908 * the relevant lane in the status register
5911 ((params
->lane_config
&
5912 PORT_HW_CFG_LANE_SWAP_CFG_MASTER_MASK
) >>
5913 PORT_HW_CFG_LANE_SWAP_CFG_MASTER_SHIFT
);
5914 mask
= ((1 << ser_lane
) <<
5915 NIG_STATUS_XGXS0_LINK_STATUS_SIZE
);
5917 mask
= NIG_STATUS_SERDES0_LINK_STATUS
;
5919 DP(NETIF_MSG_LINK
, "Ack link up interrupt with mask 0x%x\n",
5922 NIG_REG_STATUS_INTERRUPT_PORT0
+ port
*4,
5927 static int bnx2x_format_ver(u32 num
, u8
*str
, u16
*len
)
5930 u32 mask
= 0xf0000000;
5933 u8 remove_leading_zeros
= 1;
5935 /* Need more than 10chars for this format */
5943 digit
= ((num
& mask
) >> shift
);
5944 if (digit
== 0 && remove_leading_zeros
) {
5947 } else if (digit
< 0xa)
5948 *str_ptr
= digit
+ '0';
5950 *str_ptr
= digit
- 0xa + 'a';
5951 remove_leading_zeros
= 0;
5959 remove_leading_zeros
= 1;
5966 static int bnx2x_null_format_ver(u32 spirom_ver
, u8
*str
, u16
*len
)
5973 int bnx2x_get_ext_phy_fw_version(struct link_params
*params
, u8 driver_loaded
,
5974 u8
*version
, u16 len
)
5979 u8
*ver_p
= version
;
5980 u16 remain_len
= len
;
5981 if (version
== NULL
|| params
== NULL
)
5985 /* Extract first external phy*/
5987 spirom_ver
= REG_RD(bp
, params
->phy
[EXT_PHY1
].ver_addr
);
5989 if (params
->phy
[EXT_PHY1
].format_fw_ver
) {
5990 status
|= params
->phy
[EXT_PHY1
].format_fw_ver(spirom_ver
,
5993 ver_p
+= (len
- remain_len
);
5995 if ((params
->num_phys
== MAX_PHYS
) &&
5996 (params
->phy
[EXT_PHY2
].ver_addr
!= 0)) {
5997 spirom_ver
= REG_RD(bp
, params
->phy
[EXT_PHY2
].ver_addr
);
5998 if (params
->phy
[EXT_PHY2
].format_fw_ver
) {
6002 status
|= params
->phy
[EXT_PHY2
].format_fw_ver(
6006 ver_p
= version
+ (len
- remain_len
);
6013 static void bnx2x_set_xgxs_loopback(struct bnx2x_phy
*phy
,
6014 struct link_params
*params
)
6016 u8 port
= params
->port
;
6017 struct bnx2x
*bp
= params
->bp
;
6019 if (phy
->req_line_speed
!= SPEED_1000
) {
6022 DP(NETIF_MSG_LINK
, "XGXS 10G loopback enable\n");
6024 if (!CHIP_IS_E3(bp
)) {
6025 /* change the uni_phy_addr in the nig */
6026 md_devad
= REG_RD(bp
, (NIG_REG_XGXS0_CTRL_MD_DEVAD
+
6029 REG_WR(bp
, NIG_REG_XGXS0_CTRL_MD_DEVAD
+ port
*0x18,
6033 bnx2x_cl45_write(bp
, phy
,
6035 (MDIO_REG_BANK_AER_BLOCK
+
6036 (MDIO_AER_BLOCK_AER_REG
& 0xf)),
6039 bnx2x_cl45_write(bp
, phy
,
6041 (MDIO_REG_BANK_CL73_IEEEB0
+
6042 (MDIO_CL73_IEEEB0_CL73_AN_CONTROL
& 0xf)),
6045 /* set aer mmd back */
6046 bnx2x_set_aer_mmd(params
, phy
);
6048 if (!CHIP_IS_E3(bp
)) {
6050 REG_WR(bp
, NIG_REG_XGXS0_CTRL_MD_DEVAD
+ port
*0x18,
6055 DP(NETIF_MSG_LINK
, "XGXS 1G loopback enable\n");
6056 bnx2x_cl45_read(bp
, phy
, 5,
6057 (MDIO_REG_BANK_COMBO_IEEE0
+
6058 (MDIO_COMBO_IEEE0_MII_CONTROL
& 0xf)),
6060 bnx2x_cl45_write(bp
, phy
, 5,
6061 (MDIO_REG_BANK_COMBO_IEEE0
+
6062 (MDIO_COMBO_IEEE0_MII_CONTROL
& 0xf)),
6064 MDIO_COMBO_IEEO_MII_CONTROL_LOOPBACK
);
6068 int bnx2x_set_led(struct link_params
*params
,
6069 struct link_vars
*vars
, u8 mode
, u32 speed
)
6071 u8 port
= params
->port
;
6072 u16 hw_led_mode
= params
->hw_led_mode
;
6076 u32 emac_base
= port
? GRCBASE_EMAC1
: GRCBASE_EMAC0
;
6077 struct bnx2x
*bp
= params
->bp
;
6078 DP(NETIF_MSG_LINK
, "bnx2x_set_led: port %x, mode %d\n", port
, mode
);
6079 DP(NETIF_MSG_LINK
, "speed 0x%x, hw_led_mode 0x%x\n",
6080 speed
, hw_led_mode
);
6082 for (phy_idx
= EXT_PHY1
; phy_idx
< MAX_PHYS
; phy_idx
++) {
6083 if (params
->phy
[phy_idx
].set_link_led
) {
6084 params
->phy
[phy_idx
].set_link_led(
6085 ¶ms
->phy
[phy_idx
], params
, mode
);
6090 case LED_MODE_FRONT_PANEL_OFF
:
6092 REG_WR(bp
, NIG_REG_LED_10G_P0
+ port
*4, 0);
6093 REG_WR(bp
, NIG_REG_LED_MODE_P0
+ port
*4,
6094 SHARED_HW_CFG_LED_MAC1
);
6096 tmp
= EMAC_RD(bp
, EMAC_REG_EMAC_LED
);
6097 if (params
->phy
[EXT_PHY1
].type
==
6098 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54618SE
)
6099 EMAC_WR(bp
, EMAC_REG_EMAC_LED
, tmp
& 0xfff1);
6101 EMAC_WR(bp
, EMAC_REG_EMAC_LED
,
6102 (tmp
| EMAC_LED_OVERRIDE
));
6108 * For all other phys, OPER mode is same as ON, so in case
6109 * link is down, do nothing
6114 if (((params
->phy
[EXT_PHY1
].type
==
6115 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727
) ||
6116 (params
->phy
[EXT_PHY1
].type
==
6117 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8722
)) &&
6118 CHIP_IS_E2(bp
) && params
->num_phys
== 2) {
6120 * This is a work-around for E2+8727 Configurations
6122 if (mode
== LED_MODE_ON
||
6123 speed
== SPEED_10000
){
6124 REG_WR(bp
, NIG_REG_LED_MODE_P0
+ port
*4, 0);
6125 REG_WR(bp
, NIG_REG_LED_10G_P0
+ port
*4, 1);
6127 tmp
= EMAC_RD(bp
, EMAC_REG_EMAC_LED
);
6128 EMAC_WR(bp
, EMAC_REG_EMAC_LED
,
6129 (tmp
| EMAC_LED_OVERRIDE
));
6131 * return here without enabling traffic
6132 * LED blink and setting rate in ON mode.
6133 * In oper mode, enabling LED blink
6134 * and setting rate is needed.
6136 if (mode
== LED_MODE_ON
)
6139 } else if (SINGLE_MEDIA_DIRECT(params
)) {
6141 * This is a work-around for HW issue found when link
6144 if ((!CHIP_IS_E3(bp
)) ||
6146 mode
== LED_MODE_ON
))
6147 REG_WR(bp
, NIG_REG_LED_10G_P0
+ port
*4, 1);
6149 if (CHIP_IS_E1x(bp
) ||
6151 (mode
== LED_MODE_ON
))
6152 REG_WR(bp
, NIG_REG_LED_MODE_P0
+ port
*4, 0);
6154 REG_WR(bp
, NIG_REG_LED_MODE_P0
+ port
*4,
6156 } else if ((params
->phy
[EXT_PHY1
].type
==
6157 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54618SE
) &&
6158 (mode
!= LED_MODE_OPER
)) {
6159 REG_WR(bp
, NIG_REG_LED_MODE_P0
+ port
*4, 0);
6160 tmp
= EMAC_RD(bp
, EMAC_REG_EMAC_LED
);
6161 EMAC_WR(bp
, EMAC_REG_EMAC_LED
, tmp
| 0x3);
6163 REG_WR(bp
, NIG_REG_LED_MODE_P0
+ port
*4,
6166 REG_WR(bp
, NIG_REG_LED_CONTROL_OVERRIDE_TRAFFIC_P0
+ port
*4, 0);
6167 /* Set blinking rate to ~15.9Hz */
6169 REG_WR(bp
, NIG_REG_LED_CONTROL_BLINK_RATE_P0
+ port
*4,
6170 LED_BLINK_RATE_VAL_E3
);
6172 REG_WR(bp
, NIG_REG_LED_CONTROL_BLINK_RATE_P0
+ port
*4,
6173 LED_BLINK_RATE_VAL_E1X_E2
);
6174 REG_WR(bp
, NIG_REG_LED_CONTROL_BLINK_RATE_ENA_P0
+
6176 if ((params
->phy
[EXT_PHY1
].type
!=
6177 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54618SE
) &&
6178 (mode
!= LED_MODE_OPER
)) {
6179 tmp
= EMAC_RD(bp
, EMAC_REG_EMAC_LED
);
6180 EMAC_WR(bp
, EMAC_REG_EMAC_LED
,
6181 (tmp
& (~EMAC_LED_OVERRIDE
)));
6184 if (CHIP_IS_E1(bp
) &&
6185 ((speed
== SPEED_2500
) ||
6186 (speed
== SPEED_1000
) ||
6187 (speed
== SPEED_100
) ||
6188 (speed
== SPEED_10
))) {
6190 * On Everest 1 Ax chip versions for speeds less than
6191 * 10G LED scheme is different
6193 REG_WR(bp
, NIG_REG_LED_CONTROL_OVERRIDE_TRAFFIC_P0
6195 REG_WR(bp
, NIG_REG_LED_CONTROL_TRAFFIC_P0
+
6197 REG_WR(bp
, NIG_REG_LED_CONTROL_BLINK_TRAFFIC_P0
+
6204 DP(NETIF_MSG_LINK
, "bnx2x_set_led: Invalid led mode %d\n",
6213 * This function comes to reflect the actual link state read DIRECTLY from the
6216 int bnx2x_test_link(struct link_params
*params
, struct link_vars
*vars
,
6219 struct bnx2x
*bp
= params
->bp
;
6220 u16 gp_status
= 0, phy_index
= 0;
6221 u8 ext_phy_link_up
= 0, serdes_phy_type
;
6222 struct link_vars temp_vars
;
6223 struct bnx2x_phy
*int_phy
= ¶ms
->phy
[INT_PHY
];
6225 if (CHIP_IS_E3(bp
)) {
6227 if (params
->req_line_speed
[LINK_CONFIG_IDX(INT_PHY
)]
6229 /* Check 20G link */
6230 bnx2x_cl45_read(bp
, int_phy
, MDIO_WC_DEVAD
,
6232 bnx2x_cl45_read(bp
, int_phy
, MDIO_WC_DEVAD
,
6236 /* Check 10G link and below*/
6237 u8 lane
= bnx2x_get_warpcore_lane(int_phy
, params
);
6238 bnx2x_cl45_read(bp
, int_phy
, MDIO_WC_DEVAD
,
6239 MDIO_WC_REG_GP2_STATUS_GP_2_1
,
6241 gp_status
= ((gp_status
>> 8) & 0xf) |
6242 ((gp_status
>> 12) & 0xf);
6243 link_up
= gp_status
& (1 << lane
);
6248 CL22_RD_OVER_CL45(bp
, int_phy
,
6249 MDIO_REG_BANK_GP_STATUS
,
6250 MDIO_GP_STATUS_TOP_AN_STATUS1
,
6252 /* link is up only if both local phy and external phy are up */
6253 if (!(gp_status
& MDIO_GP_STATUS_TOP_AN_STATUS1_LINK_STATUS
))
6256 /* In XGXS loopback mode, do not check external PHY */
6257 if (params
->loopback_mode
== LOOPBACK_XGXS
)
6260 switch (params
->num_phys
) {
6262 /* No external PHY */
6265 ext_phy_link_up
= params
->phy
[EXT_PHY1
].read_status(
6266 ¶ms
->phy
[EXT_PHY1
],
6267 params
, &temp_vars
);
6269 case 3: /* Dual Media */
6270 for (phy_index
= EXT_PHY1
; phy_index
< params
->num_phys
;
6272 serdes_phy_type
= ((params
->phy
[phy_index
].media_type
==
6273 ETH_PHY_SFP_FIBER
) ||
6274 (params
->phy
[phy_index
].media_type
==
6275 ETH_PHY_XFP_FIBER
) ||
6276 (params
->phy
[phy_index
].media_type
==
6277 ETH_PHY_DA_TWINAX
));
6279 if (is_serdes
!= serdes_phy_type
)
6281 if (params
->phy
[phy_index
].read_status
) {
6283 params
->phy
[phy_index
].read_status(
6284 ¶ms
->phy
[phy_index
],
6285 params
, &temp_vars
);
6290 if (ext_phy_link_up
)
6295 static int bnx2x_link_initialize(struct link_params
*params
,
6296 struct link_vars
*vars
)
6299 u8 phy_index
, non_ext_phy
;
6300 struct bnx2x
*bp
= params
->bp
;
6302 * In case of external phy existence, the line speed would be the
6303 * line speed linked up by the external phy. In case it is direct
6304 * only, then the line_speed during initialization will be
6305 * equal to the req_line_speed
6307 vars
->line_speed
= params
->phy
[INT_PHY
].req_line_speed
;
6310 * Initialize the internal phy in case this is a direct board
6311 * (no external phys), or this board has external phy which requires
6314 if (!USES_WARPCORE(bp
))
6315 bnx2x_prepare_xgxs(¶ms
->phy
[INT_PHY
], params
, vars
);
6316 /* init ext phy and enable link state int */
6317 non_ext_phy
= (SINGLE_MEDIA_DIRECT(params
) ||
6318 (params
->loopback_mode
== LOOPBACK_XGXS
));
6321 (params
->phy
[EXT_PHY1
].flags
& FLAGS_INIT_XGXS_FIRST
) ||
6322 (params
->loopback_mode
== LOOPBACK_EXT_PHY
)) {
6323 struct bnx2x_phy
*phy
= ¶ms
->phy
[INT_PHY
];
6324 if (vars
->line_speed
== SPEED_AUTO_NEG
&&
6327 bnx2x_set_parallel_detection(phy
, params
);
6328 if (params
->phy
[INT_PHY
].config_init
)
6329 params
->phy
[INT_PHY
].config_init(phy
,
6334 /* Init external phy*/
6336 if (params
->phy
[INT_PHY
].supported
&
6338 vars
->link_status
|= LINK_STATUS_SERDES_LINK
;
6340 for (phy_index
= EXT_PHY1
; phy_index
< params
->num_phys
;
6343 * No need to initialize second phy in case of first
6344 * phy only selection. In case of second phy, we do
6345 * need to initialize the first phy, since they are
6348 if (params
->phy
[phy_index
].supported
&
6350 vars
->link_status
|= LINK_STATUS_SERDES_LINK
;
6352 if (phy_index
== EXT_PHY2
&&
6353 (bnx2x_phy_selection(params
) ==
6354 PORT_HW_CFG_PHY_SELECTION_FIRST_PHY
)) {
6356 "Not initializing second phy\n");
6359 params
->phy
[phy_index
].config_init(
6360 ¶ms
->phy
[phy_index
],
6364 /* Reset the interrupt indication after phy was initialized */
6365 bnx2x_bits_dis(bp
, NIG_REG_STATUS_INTERRUPT_PORT0
+
6367 (NIG_STATUS_XGXS0_LINK10G
|
6368 NIG_STATUS_XGXS0_LINK_STATUS
|
6369 NIG_STATUS_SERDES0_LINK_STATUS
|
6371 bnx2x_update_mng(params
, vars
->link_status
);
6375 static void bnx2x_int_link_reset(struct bnx2x_phy
*phy
,
6376 struct link_params
*params
)
6378 /* reset the SerDes/XGXS */
6379 REG_WR(params
->bp
, GRCBASE_MISC
+ MISC_REGISTERS_RESET_REG_3_CLEAR
,
6380 (0x1ff << (params
->port
*16)));
6383 static void bnx2x_common_ext_link_reset(struct bnx2x_phy
*phy
,
6384 struct link_params
*params
)
6386 struct bnx2x
*bp
= params
->bp
;
6390 gpio_port
= BP_PATH(bp
);
6392 gpio_port
= params
->port
;
6393 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_1
,
6394 MISC_REGISTERS_GPIO_OUTPUT_LOW
,
6396 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_2
,
6397 MISC_REGISTERS_GPIO_OUTPUT_LOW
,
6399 DP(NETIF_MSG_LINK
, "reset external PHY\n");
6402 static int bnx2x_update_link_down(struct link_params
*params
,
6403 struct link_vars
*vars
)
6405 struct bnx2x
*bp
= params
->bp
;
6406 u8 port
= params
->port
;
6408 DP(NETIF_MSG_LINK
, "Port %x: Link is down\n", port
);
6409 bnx2x_set_led(params
, vars
, LED_MODE_OFF
, 0);
6410 vars
->phy_flags
&= ~PHY_PHYSICAL_LINK_FLAG
;
6411 /* indicate no mac active */
6412 vars
->mac_type
= MAC_TYPE_NONE
;
6414 /* update shared memory */
6415 vars
->link_status
&= ~(LINK_STATUS_SPEED_AND_DUPLEX_MASK
|
6416 LINK_STATUS_LINK_UP
|
6417 LINK_STATUS_PHYSICAL_LINK_FLAG
|
6418 LINK_STATUS_AUTO_NEGOTIATE_COMPLETE
|
6419 LINK_STATUS_RX_FLOW_CONTROL_FLAG_MASK
|
6420 LINK_STATUS_TX_FLOW_CONTROL_FLAG_MASK
|
6421 LINK_STATUS_PARALLEL_DETECTION_FLAG_MASK
);
6422 vars
->line_speed
= 0;
6423 bnx2x_update_mng(params
, vars
->link_status
);
6425 /* activate nig drain */
6426 REG_WR(bp
, NIG_REG_EGRESS_DRAIN0_MODE
+ port
*4, 1);
6429 if (!CHIP_IS_E3(bp
))
6430 REG_WR(bp
, NIG_REG_NIG_EMAC0_EN
+ port
*4, 0);
6433 /* reset BigMac/Xmac */
6434 if (CHIP_IS_E1x(bp
) ||
6436 bnx2x_bmac_rx_disable(bp
, params
->port
);
6437 REG_WR(bp
, GRCBASE_MISC
+
6438 MISC_REGISTERS_RESET_REG_2_CLEAR
,
6439 (MISC_REGISTERS_RESET_REG_2_RST_BMAC0
<< port
));
6441 if (CHIP_IS_E3(bp
)) {
6442 bnx2x_xmac_disable(params
);
6443 bnx2x_umac_disable(params
);
6449 static int bnx2x_update_link_up(struct link_params
*params
,
6450 struct link_vars
*vars
,
6453 struct bnx2x
*bp
= params
->bp
;
6454 u8 port
= params
->port
;
6457 vars
->link_status
|= (LINK_STATUS_LINK_UP
|
6458 LINK_STATUS_PHYSICAL_LINK_FLAG
);
6459 vars
->phy_flags
|= PHY_PHYSICAL_LINK_FLAG
;
6461 if (vars
->flow_ctrl
& BNX2X_FLOW_CTRL_TX
)
6462 vars
->link_status
|=
6463 LINK_STATUS_TX_FLOW_CONTROL_ENABLED
;
6465 if (vars
->flow_ctrl
& BNX2X_FLOW_CTRL_RX
)
6466 vars
->link_status
|=
6467 LINK_STATUS_RX_FLOW_CONTROL_ENABLED
;
6468 if (USES_WARPCORE(bp
)) {
6470 if (bnx2x_xmac_enable(params
, vars
, 0) ==
6472 DP(NETIF_MSG_LINK
, "Found errors on XMAC\n");
6474 vars
->phy_flags
|= PHY_HALF_OPEN_CONN_FLAG
;
6475 vars
->link_status
&= ~LINK_STATUS_LINK_UP
;
6478 bnx2x_umac_enable(params
, vars
, 0);
6479 bnx2x_set_led(params
, vars
,
6480 LED_MODE_OPER
, vars
->line_speed
);
6482 if ((CHIP_IS_E1x(bp
) ||
6485 if (bnx2x_bmac_enable(params
, vars
, 0) ==
6487 DP(NETIF_MSG_LINK
, "Found errors on BMAC\n");
6489 vars
->phy_flags
|= PHY_HALF_OPEN_CONN_FLAG
;
6490 vars
->link_status
&= ~LINK_STATUS_LINK_UP
;
6493 bnx2x_set_led(params
, vars
,
6494 LED_MODE_OPER
, SPEED_10000
);
6496 rc
= bnx2x_emac_program(params
, vars
);
6497 bnx2x_emac_enable(params
, vars
, 0);
6500 if ((vars
->link_status
&
6501 LINK_STATUS_AUTO_NEGOTIATE_COMPLETE
)
6502 && (!(vars
->phy_flags
& PHY_SGMII_FLAG
)) &&
6503 SINGLE_MEDIA_DIRECT(params
))
6504 bnx2x_set_gmii_tx_driver(params
);
6509 if (CHIP_IS_E1x(bp
))
6510 rc
|= bnx2x_pbf_update(params
, vars
->flow_ctrl
,
6514 REG_WR(bp
, NIG_REG_EGRESS_DRAIN0_MODE
+ port
*4, 0);
6516 /* update shared memory */
6517 bnx2x_update_mng(params
, vars
->link_status
);
6522 * The bnx2x_link_update function should be called upon link
6524 * Link is considered up as follows:
6525 * - DIRECT_SINGLE_MEDIA - Only XGXS link (internal link) needs
6527 * - SINGLE_MEDIA - The link between the 577xx and the external
6528 * phy (XGXS) need to up as well as the external link of the
6530 * - DUAL_MEDIA - The link between the 577xx and the first
6531 * external phy needs to be up, and at least one of the 2
6532 * external phy link must be up.
6534 int bnx2x_link_update(struct link_params
*params
, struct link_vars
*vars
)
6536 struct bnx2x
*bp
= params
->bp
;
6537 struct link_vars phy_vars
[MAX_PHYS
];
6538 u8 port
= params
->port
;
6539 u8 link_10g_plus
, phy_index
;
6540 u8 ext_phy_link_up
= 0, cur_link_up
;
6543 u16 ext_phy_line_speed
= 0, prev_line_speed
= vars
->line_speed
;
6544 u8 active_external_phy
= INT_PHY
;
6545 vars
->phy_flags
&= ~PHY_HALF_OPEN_CONN_FLAG
;
6546 for (phy_index
= INT_PHY
; phy_index
< params
->num_phys
;
6548 phy_vars
[phy_index
].flow_ctrl
= 0;
6549 phy_vars
[phy_index
].link_status
= 0;
6550 phy_vars
[phy_index
].line_speed
= 0;
6551 phy_vars
[phy_index
].duplex
= DUPLEX_FULL
;
6552 phy_vars
[phy_index
].phy_link_up
= 0;
6553 phy_vars
[phy_index
].link_up
= 0;
6554 phy_vars
[phy_index
].fault_detected
= 0;
6557 if (USES_WARPCORE(bp
))
6558 bnx2x_set_aer_mmd(params
, ¶ms
->phy
[INT_PHY
]);
6560 DP(NETIF_MSG_LINK
, "port %x, XGXS?%x, int_status 0x%x\n",
6561 port
, (vars
->phy_flags
& PHY_XGXS_FLAG
),
6562 REG_RD(bp
, NIG_REG_STATUS_INTERRUPT_PORT0
+ port
*4));
6564 is_mi_int
= (u8
)(REG_RD(bp
, NIG_REG_EMAC0_STATUS_MISC_MI_INT
+
6566 DP(NETIF_MSG_LINK
, "int_mask 0x%x MI_INT %x, SERDES_LINK %x\n",
6567 REG_RD(bp
, NIG_REG_MASK_INTERRUPT_PORT0
+ port
*4),
6569 REG_RD(bp
, NIG_REG_SERDES0_STATUS_LINK_STATUS
+ port
*0x3c));
6571 DP(NETIF_MSG_LINK
, " 10G %x, XGXS_LINK %x\n",
6572 REG_RD(bp
, NIG_REG_XGXS0_STATUS_LINK10G
+ port
*0x68),
6573 REG_RD(bp
, NIG_REG_XGXS0_STATUS_LINK_STATUS
+ port
*0x68));
6576 if (!CHIP_IS_E3(bp
))
6577 REG_WR(bp
, NIG_REG_NIG_EMAC0_EN
+ port
*4, 0);
6581 * Check external link change only for external phys, and apply
6582 * priority selection between them in case the link on both phys
6583 * is up. Note that instead of the common vars, a temporary
6584 * vars argument is used since each phy may have different link/
6585 * speed/duplex result
6587 for (phy_index
= EXT_PHY1
; phy_index
< params
->num_phys
;
6589 struct bnx2x_phy
*phy
= ¶ms
->phy
[phy_index
];
6590 if (!phy
->read_status
)
6592 /* Read link status and params of this ext phy */
6593 cur_link_up
= phy
->read_status(phy
, params
,
6594 &phy_vars
[phy_index
]);
6596 DP(NETIF_MSG_LINK
, "phy in index %d link is up\n",
6599 DP(NETIF_MSG_LINK
, "phy in index %d link is down\n",
6604 if (!ext_phy_link_up
) {
6605 ext_phy_link_up
= 1;
6606 active_external_phy
= phy_index
;
6608 switch (bnx2x_phy_selection(params
)) {
6609 case PORT_HW_CFG_PHY_SELECTION_HARDWARE_DEFAULT
:
6610 case PORT_HW_CFG_PHY_SELECTION_FIRST_PHY_PRIORITY
:
6612 * In this option, the first PHY makes sure to pass the
6613 * traffic through itself only.
6614 * Its not clear how to reset the link on the second phy
6616 active_external_phy
= EXT_PHY1
;
6618 case PORT_HW_CFG_PHY_SELECTION_SECOND_PHY_PRIORITY
:
6620 * In this option, the first PHY makes sure to pass the
6621 * traffic through the second PHY.
6623 active_external_phy
= EXT_PHY2
;
6627 * Link indication on both PHYs with the following cases
6629 * - FIRST_PHY means that second phy wasn't initialized,
6630 * hence its link is expected to be down
6631 * - SECOND_PHY means that first phy should not be able
6632 * to link up by itself (using configuration)
6633 * - DEFAULT should be overriden during initialiazation
6635 DP(NETIF_MSG_LINK
, "Invalid link indication"
6636 "mpc=0x%x. DISABLING LINK !!!\n",
6637 params
->multi_phy_config
);
6638 ext_phy_link_up
= 0;
6643 prev_line_speed
= vars
->line_speed
;
6646 * Read the status of the internal phy. In case of
6647 * DIRECT_SINGLE_MEDIA board, this link is the external link,
6648 * otherwise this is the link between the 577xx and the first
6651 if (params
->phy
[INT_PHY
].read_status
)
6652 params
->phy
[INT_PHY
].read_status(
6653 ¶ms
->phy
[INT_PHY
],
6656 * The INT_PHY flow control reside in the vars. This include the
6657 * case where the speed or flow control are not set to AUTO.
6658 * Otherwise, the active external phy flow control result is set
6659 * to the vars. The ext_phy_line_speed is needed to check if the
6660 * speed is different between the internal phy and external phy.
6661 * This case may be result of intermediate link speed change.
6663 if (active_external_phy
> INT_PHY
) {
6664 vars
->flow_ctrl
= phy_vars
[active_external_phy
].flow_ctrl
;
6666 * Link speed is taken from the XGXS. AN and FC result from
6669 vars
->link_status
|= phy_vars
[active_external_phy
].link_status
;
6672 * if active_external_phy is first PHY and link is up - disable
6673 * disable TX on second external PHY
6675 if (active_external_phy
== EXT_PHY1
) {
6676 if (params
->phy
[EXT_PHY2
].phy_specific_func
) {
6678 "Disabling TX on EXT_PHY2\n");
6679 params
->phy
[EXT_PHY2
].phy_specific_func(
6680 ¶ms
->phy
[EXT_PHY2
],
6681 params
, DISABLE_TX
);
6685 ext_phy_line_speed
= phy_vars
[active_external_phy
].line_speed
;
6686 vars
->duplex
= phy_vars
[active_external_phy
].duplex
;
6687 if (params
->phy
[active_external_phy
].supported
&
6689 vars
->link_status
|= LINK_STATUS_SERDES_LINK
;
6691 vars
->link_status
&= ~LINK_STATUS_SERDES_LINK
;
6692 DP(NETIF_MSG_LINK
, "Active external phy selected: %x\n",
6693 active_external_phy
);
6696 for (phy_index
= EXT_PHY1
; phy_index
< params
->num_phys
;
6698 if (params
->phy
[phy_index
].flags
&
6699 FLAGS_REARM_LATCH_SIGNAL
) {
6700 bnx2x_rearm_latch_signal(bp
, port
,
6702 active_external_phy
);
6706 DP(NETIF_MSG_LINK
, "vars->flow_ctrl = 0x%x, vars->link_status = 0x%x,"
6707 " ext_phy_line_speed = %d\n", vars
->flow_ctrl
,
6708 vars
->link_status
, ext_phy_line_speed
);
6710 * Upon link speed change set the NIG into drain mode. Comes to
6711 * deals with possible FIFO glitch due to clk change when speed
6712 * is decreased without link down indicator
6715 if (vars
->phy_link_up
) {
6716 if (!(SINGLE_MEDIA_DIRECT(params
)) && ext_phy_link_up
&&
6717 (ext_phy_line_speed
!= vars
->line_speed
)) {
6718 DP(NETIF_MSG_LINK
, "Internal link speed %d is"
6719 " different than the external"
6720 " link speed %d\n", vars
->line_speed
,
6721 ext_phy_line_speed
);
6722 vars
->phy_link_up
= 0;
6723 } else if (prev_line_speed
!= vars
->line_speed
) {
6724 REG_WR(bp
, NIG_REG_EGRESS_DRAIN0_MODE
+ params
->port
*4,
6730 /* anything 10 and over uses the bmac */
6731 link_10g_plus
= (vars
->line_speed
>= SPEED_10000
);
6733 bnx2x_link_int_ack(params
, vars
, link_10g_plus
);
6736 * In case external phy link is up, and internal link is down
6737 * (not initialized yet probably after link initialization, it
6738 * needs to be initialized.
6739 * Note that after link down-up as result of cable plug, the xgxs
6740 * link would probably become up again without the need
6743 if (!(SINGLE_MEDIA_DIRECT(params
))) {
6744 DP(NETIF_MSG_LINK
, "ext_phy_link_up = %d, int_link_up = %d,"
6745 " init_preceding = %d\n", ext_phy_link_up
,
6747 params
->phy
[EXT_PHY1
].flags
&
6748 FLAGS_INIT_XGXS_FIRST
);
6749 if (!(params
->phy
[EXT_PHY1
].flags
&
6750 FLAGS_INIT_XGXS_FIRST
)
6751 && ext_phy_link_up
&& !vars
->phy_link_up
) {
6752 vars
->line_speed
= ext_phy_line_speed
;
6753 if (vars
->line_speed
< SPEED_1000
)
6754 vars
->phy_flags
|= PHY_SGMII_FLAG
;
6756 vars
->phy_flags
&= ~PHY_SGMII_FLAG
;
6758 if (params
->phy
[INT_PHY
].config_init
)
6759 params
->phy
[INT_PHY
].config_init(
6760 ¶ms
->phy
[INT_PHY
], params
,
6765 * Link is up only if both local phy and external phy (in case of
6766 * non-direct board) are up and no fault detected on active PHY.
6768 vars
->link_up
= (vars
->phy_link_up
&&
6770 SINGLE_MEDIA_DIRECT(params
)) &&
6771 (phy_vars
[active_external_phy
].fault_detected
== 0));
6774 rc
= bnx2x_update_link_up(params
, vars
, link_10g_plus
);
6776 rc
= bnx2x_update_link_down(params
, vars
);
6781 /*****************************************************************************/
6782 /* External Phy section */
6783 /*****************************************************************************/
6784 void bnx2x_ext_phy_hw_reset(struct bnx2x
*bp
, u8 port
)
6786 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_1
,
6787 MISC_REGISTERS_GPIO_OUTPUT_LOW
, port
);
6789 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_1
,
6790 MISC_REGISTERS_GPIO_OUTPUT_HIGH
, port
);
6793 static void bnx2x_save_spirom_version(struct bnx2x
*bp
, u8 port
,
6794 u32 spirom_ver
, u32 ver_addr
)
6796 DP(NETIF_MSG_LINK
, "FW version 0x%x:0x%x for port %d\n",
6797 (u16
)(spirom_ver
>>16), (u16
)spirom_ver
, port
);
6800 REG_WR(bp
, ver_addr
, spirom_ver
);
6803 static void bnx2x_save_bcm_spirom_ver(struct bnx2x
*bp
,
6804 struct bnx2x_phy
*phy
,
6807 u16 fw_ver1
, fw_ver2
;
6809 bnx2x_cl45_read(bp
, phy
, MDIO_PMA_DEVAD
,
6810 MDIO_PMA_REG_ROM_VER1
, &fw_ver1
);
6811 bnx2x_cl45_read(bp
, phy
, MDIO_PMA_DEVAD
,
6812 MDIO_PMA_REG_ROM_VER2
, &fw_ver2
);
6813 bnx2x_save_spirom_version(bp
, port
, (u32
)(fw_ver1
<<16 | fw_ver2
),
6817 static void bnx2x_ext_phy_10G_an_resolve(struct bnx2x
*bp
,
6818 struct bnx2x_phy
*phy
,
6819 struct link_vars
*vars
)
6822 bnx2x_cl45_read(bp
, phy
,
6824 MDIO_AN_REG_STATUS
, &val
);
6825 bnx2x_cl45_read(bp
, phy
,
6827 MDIO_AN_REG_STATUS
, &val
);
6829 vars
->link_status
|= LINK_STATUS_AUTO_NEGOTIATE_COMPLETE
;
6830 if ((val
& (1<<0)) == 0)
6831 vars
->link_status
|= LINK_STATUS_PARALLEL_DETECTION_USED
;
6834 /******************************************************************/
6835 /* common BCM8073/BCM8727 PHY SECTION */
6836 /******************************************************************/
6837 static void bnx2x_8073_resolve_fc(struct bnx2x_phy
*phy
,
6838 struct link_params
*params
,
6839 struct link_vars
*vars
)
6841 struct bnx2x
*bp
= params
->bp
;
6842 if (phy
->req_line_speed
== SPEED_10
||
6843 phy
->req_line_speed
== SPEED_100
) {
6844 vars
->flow_ctrl
= phy
->req_flow_ctrl
;
6848 if (bnx2x_ext_phy_resolve_fc(phy
, params
, vars
) &&
6849 (vars
->flow_ctrl
== BNX2X_FLOW_CTRL_NONE
)) {
6851 u16 ld_pause
; /* local */
6852 u16 lp_pause
; /* link partner */
6853 bnx2x_cl45_read(bp
, phy
,
6855 MDIO_AN_REG_CL37_FC_LD
, &ld_pause
);
6857 bnx2x_cl45_read(bp
, phy
,
6859 MDIO_AN_REG_CL37_FC_LP
, &lp_pause
);
6860 pause_result
= (ld_pause
&
6861 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH
) >> 5;
6862 pause_result
|= (lp_pause
&
6863 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH
) >> 7;
6865 bnx2x_pause_resolve(vars
, pause_result
);
6866 DP(NETIF_MSG_LINK
, "Ext PHY CL37 pause result 0x%x\n",
6870 static int bnx2x_8073_8727_external_rom_boot(struct bnx2x
*bp
,
6871 struct bnx2x_phy
*phy
,
6875 u16 fw_ver1
, fw_msgout
;
6878 /* Boot port from external ROM */
6880 bnx2x_cl45_write(bp
, phy
,
6882 MDIO_PMA_REG_GEN_CTRL
,
6885 /* ucode reboot and rst */
6886 bnx2x_cl45_write(bp
, phy
,
6888 MDIO_PMA_REG_GEN_CTRL
,
6891 bnx2x_cl45_write(bp
, phy
,
6893 MDIO_PMA_REG_MISC_CTRL1
, 0x0001);
6895 /* Reset internal microprocessor */
6896 bnx2x_cl45_write(bp
, phy
,
6898 MDIO_PMA_REG_GEN_CTRL
,
6899 MDIO_PMA_REG_GEN_CTRL_ROM_MICRO_RESET
);
6901 /* Release srst bit */
6902 bnx2x_cl45_write(bp
, phy
,
6904 MDIO_PMA_REG_GEN_CTRL
,
6905 MDIO_PMA_REG_GEN_CTRL_ROM_RESET_INTERNAL_MP
);
6907 /* Delay 100ms per the PHY specifications */
6910 /* 8073 sometimes taking longer to download */
6915 "bnx2x_8073_8727_external_rom_boot port %x:"
6916 "Download failed. fw version = 0x%x\n",
6922 bnx2x_cl45_read(bp
, phy
,
6924 MDIO_PMA_REG_ROM_VER1
, &fw_ver1
);
6925 bnx2x_cl45_read(bp
, phy
,
6927 MDIO_PMA_REG_M8051_MSGOUT_REG
, &fw_msgout
);
6930 } while (fw_ver1
== 0 || fw_ver1
== 0x4321 ||
6931 ((fw_msgout
& 0xff) != 0x03 && (phy
->type
==
6932 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073
)));
6934 /* Clear ser_boot_ctl bit */
6935 bnx2x_cl45_write(bp
, phy
,
6937 MDIO_PMA_REG_MISC_CTRL1
, 0x0000);
6938 bnx2x_save_bcm_spirom_ver(bp
, phy
, port
);
6941 "bnx2x_8073_8727_external_rom_boot port %x:"
6942 "Download complete. fw version = 0x%x\n",
6948 /******************************************************************/
6949 /* BCM8073 PHY SECTION */
6950 /******************************************************************/
6951 static int bnx2x_8073_is_snr_needed(struct bnx2x
*bp
, struct bnx2x_phy
*phy
)
6953 /* This is only required for 8073A1, version 102 only */
6956 /* Read 8073 HW revision*/
6957 bnx2x_cl45_read(bp
, phy
,
6959 MDIO_PMA_REG_8073_CHIP_REV
, &val
);
6962 /* No need to workaround in 8073 A1 */
6966 bnx2x_cl45_read(bp
, phy
,
6968 MDIO_PMA_REG_ROM_VER2
, &val
);
6970 /* SNR should be applied only for version 0x102 */
6977 static int bnx2x_8073_xaui_wa(struct bnx2x
*bp
, struct bnx2x_phy
*phy
)
6979 u16 val
, cnt
, cnt1
;
6981 bnx2x_cl45_read(bp
, phy
,
6983 MDIO_PMA_REG_8073_CHIP_REV
, &val
);
6986 /* No need to workaround in 8073 A1 */
6989 /* XAUI workaround in 8073 A0: */
6992 * After loading the boot ROM and restarting Autoneg, poll
6996 for (cnt
= 0; cnt
< 1000; cnt
++) {
6997 bnx2x_cl45_read(bp
, phy
,
6999 MDIO_PMA_REG_8073_SPEED_LINK_STATUS
,
7002 * If bit [14] = 0 or bit [13] = 0, continue on with
7003 * system initialization (XAUI work-around not required, as
7004 * these bits indicate 2.5G or 1G link up).
7006 if (!(val
& (1<<14)) || !(val
& (1<<13))) {
7007 DP(NETIF_MSG_LINK
, "XAUI work-around not required\n");
7009 } else if (!(val
& (1<<15))) {
7010 DP(NETIF_MSG_LINK
, "bit 15 went off\n");
7012 * If bit 15 is 0, then poll Dev1, Reg $C841 until it's
7013 * MSB (bit15) goes to 1 (indicating that the XAUI
7014 * workaround has completed), then continue on with
7015 * system initialization.
7017 for (cnt1
= 0; cnt1
< 1000; cnt1
++) {
7018 bnx2x_cl45_read(bp
, phy
,
7020 MDIO_PMA_REG_8073_XAUI_WA
, &val
);
7021 if (val
& (1<<15)) {
7023 "XAUI workaround has completed\n");
7032 DP(NETIF_MSG_LINK
, "Warning: XAUI work-around timeout !!!\n");
7036 static void bnx2x_807x_force_10G(struct bnx2x
*bp
, struct bnx2x_phy
*phy
)
7038 /* Force KR or KX */
7039 bnx2x_cl45_write(bp
, phy
,
7040 MDIO_PMA_DEVAD
, MDIO_PMA_REG_CTRL
, 0x2040);
7041 bnx2x_cl45_write(bp
, phy
,
7042 MDIO_PMA_DEVAD
, MDIO_PMA_REG_10G_CTRL2
, 0x000b);
7043 bnx2x_cl45_write(bp
, phy
,
7044 MDIO_PMA_DEVAD
, MDIO_PMA_REG_BCM_CTRL
, 0x0000);
7045 bnx2x_cl45_write(bp
, phy
,
7046 MDIO_AN_DEVAD
, MDIO_AN_REG_CTRL
, 0x0000);
7049 static void bnx2x_8073_set_pause_cl37(struct link_params
*params
,
7050 struct bnx2x_phy
*phy
,
7051 struct link_vars
*vars
)
7054 struct bnx2x
*bp
= params
->bp
;
7055 bnx2x_cl45_read(bp
, phy
,
7056 MDIO_AN_DEVAD
, MDIO_AN_REG_CL37_FC_LD
, &cl37_val
);
7058 cl37_val
&= ~MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH
;
7059 /* Please refer to Table 28B-3 of 802.3ab-1999 spec. */
7060 bnx2x_calc_ieee_aneg_adv(phy
, params
, &vars
->ieee_fc
);
7061 if ((vars
->ieee_fc
&
7062 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_SYMMETRIC
) ==
7063 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_SYMMETRIC
) {
7064 cl37_val
|= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_SYMMETRIC
;
7066 if ((vars
->ieee_fc
&
7067 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC
) ==
7068 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC
) {
7069 cl37_val
|= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC
;
7071 if ((vars
->ieee_fc
&
7072 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH
) ==
7073 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH
) {
7074 cl37_val
|= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH
;
7077 "Ext phy AN advertize cl37 0x%x\n", cl37_val
);
7079 bnx2x_cl45_write(bp
, phy
,
7080 MDIO_AN_DEVAD
, MDIO_AN_REG_CL37_FC_LD
, cl37_val
);
7084 static int bnx2x_8073_config_init(struct bnx2x_phy
*phy
,
7085 struct link_params
*params
,
7086 struct link_vars
*vars
)
7088 struct bnx2x
*bp
= params
->bp
;
7091 DP(NETIF_MSG_LINK
, "Init 8073\n");
7094 gpio_port
= BP_PATH(bp
);
7096 gpio_port
= params
->port
;
7097 /* Restore normal power mode*/
7098 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_2
,
7099 MISC_REGISTERS_GPIO_OUTPUT_HIGH
, gpio_port
);
7101 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_1
,
7102 MISC_REGISTERS_GPIO_OUTPUT_HIGH
, gpio_port
);
7105 bnx2x_cl45_write(bp
, phy
,
7106 MDIO_PMA_DEVAD
, MDIO_PMA_LASI_RXCTRL
, (1<<2));
7107 bnx2x_cl45_write(bp
, phy
,
7108 MDIO_PMA_DEVAD
, MDIO_PMA_LASI_CTRL
, 0x0004);
7110 bnx2x_8073_set_pause_cl37(params
, phy
, vars
);
7112 bnx2x_cl45_read(bp
, phy
,
7113 MDIO_PMA_DEVAD
, MDIO_PMA_REG_M8051_MSGOUT_REG
, &tmp1
);
7115 bnx2x_cl45_read(bp
, phy
,
7116 MDIO_PMA_DEVAD
, MDIO_PMA_LASI_RXSTAT
, &tmp1
);
7118 DP(NETIF_MSG_LINK
, "Before rom RX_ALARM(port1): 0x%x\n", tmp1
);
7120 /* Swap polarity if required - Must be done only in non-1G mode */
7121 if (params
->lane_config
& PORT_HW_CFG_SWAP_PHY_POLARITY_ENABLED
) {
7122 /* Configure the 8073 to swap _P and _N of the KR lines */
7123 DP(NETIF_MSG_LINK
, "Swapping polarity for the 8073\n");
7124 /* 10G Rx/Tx and 1G Tx signal polarity swap */
7125 bnx2x_cl45_read(bp
, phy
,
7127 MDIO_PMA_REG_8073_OPT_DIGITAL_CTRL
, &val
);
7128 bnx2x_cl45_write(bp
, phy
,
7130 MDIO_PMA_REG_8073_OPT_DIGITAL_CTRL
,
7135 /* Enable CL37 BAM */
7136 if (REG_RD(bp
, params
->shmem_base
+
7137 offsetof(struct shmem_region
, dev_info
.
7138 port_hw_config
[params
->port
].default_cfg
)) &
7139 PORT_HW_CFG_ENABLE_BAM_ON_KR_ENABLED
) {
7141 bnx2x_cl45_read(bp
, phy
,
7143 MDIO_AN_REG_8073_BAM
, &val
);
7144 bnx2x_cl45_write(bp
, phy
,
7146 MDIO_AN_REG_8073_BAM
, val
| 1);
7147 DP(NETIF_MSG_LINK
, "Enable CL37 BAM on KR\n");
7149 if (params
->loopback_mode
== LOOPBACK_EXT
) {
7150 bnx2x_807x_force_10G(bp
, phy
);
7151 DP(NETIF_MSG_LINK
, "Forced speed 10G on 807X\n");
7154 bnx2x_cl45_write(bp
, phy
,
7155 MDIO_PMA_DEVAD
, MDIO_PMA_REG_BCM_CTRL
, 0x0002);
7157 if (phy
->req_line_speed
!= SPEED_AUTO_NEG
) {
7158 if (phy
->req_line_speed
== SPEED_10000
) {
7160 } else if (phy
->req_line_speed
== SPEED_2500
) {
7163 * Note that 2.5G works only when used with 1G
7170 if (phy
->speed_cap_mask
&
7171 PORT_HW_CFG_SPEED_CAPABILITY_D0_10G
)
7174 /* Note that 2.5G works only when used with 1G advertisement */
7175 if (phy
->speed_cap_mask
&
7176 (PORT_HW_CFG_SPEED_CAPABILITY_D0_1G
|
7177 PORT_HW_CFG_SPEED_CAPABILITY_D0_2_5G
))
7179 DP(NETIF_MSG_LINK
, "807x autoneg val = 0x%x\n", val
);
7182 bnx2x_cl45_write(bp
, phy
, MDIO_AN_DEVAD
, MDIO_AN_REG_ADV
, val
);
7183 bnx2x_cl45_read(bp
, phy
, MDIO_AN_DEVAD
, MDIO_AN_REG_8073_2_5G
, &tmp1
);
7185 if (((phy
->speed_cap_mask
& PORT_HW_CFG_SPEED_CAPABILITY_D0_2_5G
) &&
7186 (phy
->req_line_speed
== SPEED_AUTO_NEG
)) ||
7187 (phy
->req_line_speed
== SPEED_2500
)) {
7189 /* Allow 2.5G for A1 and above */
7190 bnx2x_cl45_read(bp
, phy
,
7191 MDIO_PMA_DEVAD
, MDIO_PMA_REG_8073_CHIP_REV
,
7193 DP(NETIF_MSG_LINK
, "Add 2.5G\n");
7199 DP(NETIF_MSG_LINK
, "Disable 2.5G\n");
7203 bnx2x_cl45_write(bp
, phy
, MDIO_AN_DEVAD
, MDIO_AN_REG_8073_2_5G
, tmp1
);
7204 /* Add support for CL37 (passive mode) II */
7206 bnx2x_cl45_read(bp
, phy
, MDIO_AN_DEVAD
, MDIO_AN_REG_CL37_FC_LD
, &tmp1
);
7207 bnx2x_cl45_write(bp
, phy
, MDIO_AN_DEVAD
, MDIO_AN_REG_CL37_FC_LD
,
7208 (tmp1
| ((phy
->req_duplex
== DUPLEX_FULL
) ?
7211 /* Add support for CL37 (passive mode) III */
7212 bnx2x_cl45_write(bp
, phy
, MDIO_AN_DEVAD
, MDIO_AN_REG_CL37_AN
, 0x1000);
7215 * The SNR will improve about 2db by changing BW and FEE main
7216 * tap. Rest commands are executed after link is up
7217 * Change FFE main cursor to 5 in EDC register
7219 if (bnx2x_8073_is_snr_needed(bp
, phy
))
7220 bnx2x_cl45_write(bp
, phy
,
7221 MDIO_PMA_DEVAD
, MDIO_PMA_REG_EDC_FFE_MAIN
,
7224 /* Enable FEC (Forware Error Correction) Request in the AN */
7225 bnx2x_cl45_read(bp
, phy
, MDIO_AN_DEVAD
, MDIO_AN_REG_ADV2
, &tmp1
);
7227 bnx2x_cl45_write(bp
, phy
, MDIO_AN_DEVAD
, MDIO_AN_REG_ADV2
, tmp1
);
7229 bnx2x_ext_phy_set_pause(params
, phy
, vars
);
7231 /* Restart autoneg */
7233 bnx2x_cl45_write(bp
, phy
, MDIO_AN_DEVAD
, MDIO_AN_REG_CTRL
, 0x1200);
7234 DP(NETIF_MSG_LINK
, "807x Autoneg Restart: Advertise 1G=%x, 10G=%x\n",
7235 ((val
& (1<<5)) > 0), ((val
& (1<<7)) > 0));
7239 static u8
bnx2x_8073_read_status(struct bnx2x_phy
*phy
,
7240 struct link_params
*params
,
7241 struct link_vars
*vars
)
7243 struct bnx2x
*bp
= params
->bp
;
7246 u16 link_status
= 0;
7247 u16 an1000_status
= 0;
7249 bnx2x_cl45_read(bp
, phy
,
7250 MDIO_PMA_DEVAD
, MDIO_PMA_LASI_STAT
, &val1
);
7252 DP(NETIF_MSG_LINK
, "8703 LASI status 0x%x\n", val1
);
7254 /* clear the interrupt LASI status register */
7255 bnx2x_cl45_read(bp
, phy
,
7256 MDIO_PCS_DEVAD
, MDIO_PCS_REG_STATUS
, &val2
);
7257 bnx2x_cl45_read(bp
, phy
,
7258 MDIO_PCS_DEVAD
, MDIO_PCS_REG_STATUS
, &val1
);
7259 DP(NETIF_MSG_LINK
, "807x PCS status 0x%x->0x%x\n", val2
, val1
);
7261 bnx2x_cl45_read(bp
, phy
,
7262 MDIO_PMA_DEVAD
, MDIO_PMA_REG_M8051_MSGOUT_REG
, &val1
);
7264 /* Check the LASI */
7265 bnx2x_cl45_read(bp
, phy
,
7266 MDIO_PMA_DEVAD
, MDIO_PMA_LASI_RXSTAT
, &val2
);
7268 DP(NETIF_MSG_LINK
, "KR 0x9003 0x%x\n", val2
);
7270 /* Check the link status */
7271 bnx2x_cl45_read(bp
, phy
,
7272 MDIO_PCS_DEVAD
, MDIO_PCS_REG_STATUS
, &val2
);
7273 DP(NETIF_MSG_LINK
, "KR PCS status 0x%x\n", val2
);
7275 bnx2x_cl45_read(bp
, phy
,
7276 MDIO_PMA_DEVAD
, MDIO_PMA_REG_STATUS
, &val2
);
7277 bnx2x_cl45_read(bp
, phy
,
7278 MDIO_PMA_DEVAD
, MDIO_PMA_REG_STATUS
, &val1
);
7279 link_up
= ((val1
& 4) == 4);
7280 DP(NETIF_MSG_LINK
, "PMA_REG_STATUS=0x%x\n", val1
);
7283 ((phy
->req_line_speed
!= SPEED_10000
))) {
7284 if (bnx2x_8073_xaui_wa(bp
, phy
) != 0)
7287 bnx2x_cl45_read(bp
, phy
,
7288 MDIO_AN_DEVAD
, MDIO_AN_REG_LINK_STATUS
, &an1000_status
);
7289 bnx2x_cl45_read(bp
, phy
,
7290 MDIO_AN_DEVAD
, MDIO_AN_REG_LINK_STATUS
, &an1000_status
);
7292 /* Check the link status on 1.1.2 */
7293 bnx2x_cl45_read(bp
, phy
,
7294 MDIO_PMA_DEVAD
, MDIO_PMA_REG_STATUS
, &val2
);
7295 bnx2x_cl45_read(bp
, phy
,
7296 MDIO_PMA_DEVAD
, MDIO_PMA_REG_STATUS
, &val1
);
7297 DP(NETIF_MSG_LINK
, "KR PMA status 0x%x->0x%x,"
7298 "an_link_status=0x%x\n", val2
, val1
, an1000_status
);
7300 link_up
= (((val1
& 4) == 4) || (an1000_status
& (1<<1)));
7301 if (link_up
&& bnx2x_8073_is_snr_needed(bp
, phy
)) {
7303 * The SNR will improve about 2dbby changing the BW and FEE main
7304 * tap. The 1st write to change FFE main tap is set before
7305 * restart AN. Change PLL Bandwidth in EDC register
7307 bnx2x_cl45_write(bp
, phy
,
7308 MDIO_PMA_DEVAD
, MDIO_PMA_REG_PLL_BANDWIDTH
,
7311 /* Change CDR Bandwidth in EDC register */
7312 bnx2x_cl45_write(bp
, phy
,
7313 MDIO_PMA_DEVAD
, MDIO_PMA_REG_CDR_BANDWIDTH
,
7316 bnx2x_cl45_read(bp
, phy
,
7317 MDIO_PMA_DEVAD
, MDIO_PMA_REG_8073_SPEED_LINK_STATUS
,
7320 /* Bits 0..2 --> speed detected, bits 13..15--> link is down */
7321 if ((link_status
& (1<<2)) && (!(link_status
& (1<<15)))) {
7323 vars
->line_speed
= SPEED_10000
;
7324 DP(NETIF_MSG_LINK
, "port %x: External link up in 10G\n",
7326 } else if ((link_status
& (1<<1)) && (!(link_status
& (1<<14)))) {
7328 vars
->line_speed
= SPEED_2500
;
7329 DP(NETIF_MSG_LINK
, "port %x: External link up in 2.5G\n",
7331 } else if ((link_status
& (1<<0)) && (!(link_status
& (1<<13)))) {
7333 vars
->line_speed
= SPEED_1000
;
7334 DP(NETIF_MSG_LINK
, "port %x: External link up in 1G\n",
7338 DP(NETIF_MSG_LINK
, "port %x: External link is down\n",
7343 /* Swap polarity if required */
7344 if (params
->lane_config
&
7345 PORT_HW_CFG_SWAP_PHY_POLARITY_ENABLED
) {
7346 /* Configure the 8073 to swap P and N of the KR lines */
7347 bnx2x_cl45_read(bp
, phy
,
7349 MDIO_XS_REG_8073_RX_CTRL_PCIE
, &val1
);
7351 * Set bit 3 to invert Rx in 1G mode and clear this bit
7352 * when it`s in 10G mode.
7354 if (vars
->line_speed
== SPEED_1000
) {
7355 DP(NETIF_MSG_LINK
, "Swapping 1G polarity for"
7361 bnx2x_cl45_write(bp
, phy
,
7363 MDIO_XS_REG_8073_RX_CTRL_PCIE
,
7366 bnx2x_ext_phy_10G_an_resolve(bp
, phy
, vars
);
7367 bnx2x_8073_resolve_fc(phy
, params
, vars
);
7368 vars
->duplex
= DUPLEX_FULL
;
7373 static void bnx2x_8073_link_reset(struct bnx2x_phy
*phy
,
7374 struct link_params
*params
)
7376 struct bnx2x
*bp
= params
->bp
;
7379 gpio_port
= BP_PATH(bp
);
7381 gpio_port
= params
->port
;
7382 DP(NETIF_MSG_LINK
, "Setting 8073 port %d into low power mode\n",
7384 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_2
,
7385 MISC_REGISTERS_GPIO_OUTPUT_LOW
,
7389 /******************************************************************/
7390 /* BCM8705 PHY SECTION */
7391 /******************************************************************/
7392 static int bnx2x_8705_config_init(struct bnx2x_phy
*phy
,
7393 struct link_params
*params
,
7394 struct link_vars
*vars
)
7396 struct bnx2x
*bp
= params
->bp
;
7397 DP(NETIF_MSG_LINK
, "init 8705\n");
7398 /* Restore normal power mode*/
7399 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_2
,
7400 MISC_REGISTERS_GPIO_OUTPUT_HIGH
, params
->port
);
7402 bnx2x_ext_phy_hw_reset(bp
, params
->port
);
7403 bnx2x_cl45_write(bp
, phy
, MDIO_PMA_DEVAD
, MDIO_PMA_REG_CTRL
, 0xa040);
7404 bnx2x_wait_reset_complete(bp
, phy
, params
);
7406 bnx2x_cl45_write(bp
, phy
,
7407 MDIO_PMA_DEVAD
, MDIO_PMA_REG_MISC_CTRL
, 0x8288);
7408 bnx2x_cl45_write(bp
, phy
,
7409 MDIO_PMA_DEVAD
, MDIO_PMA_REG_PHY_IDENTIFIER
, 0x7fbf);
7410 bnx2x_cl45_write(bp
, phy
,
7411 MDIO_PMA_DEVAD
, MDIO_PMA_REG_CMU_PLL_BYPASS
, 0x0100);
7412 bnx2x_cl45_write(bp
, phy
,
7413 MDIO_WIS_DEVAD
, MDIO_WIS_REG_LASI_CNTL
, 0x1);
7414 /* BCM8705 doesn't have microcode, hence the 0 */
7415 bnx2x_save_spirom_version(bp
, params
->port
, params
->shmem_base
, 0);
7419 static u8
bnx2x_8705_read_status(struct bnx2x_phy
*phy
,
7420 struct link_params
*params
,
7421 struct link_vars
*vars
)
7425 struct bnx2x
*bp
= params
->bp
;
7426 DP(NETIF_MSG_LINK
, "read status 8705\n");
7427 bnx2x_cl45_read(bp
, phy
,
7428 MDIO_WIS_DEVAD
, MDIO_WIS_REG_LASI_STATUS
, &val1
);
7429 DP(NETIF_MSG_LINK
, "8705 LASI status 0x%x\n", val1
);
7431 bnx2x_cl45_read(bp
, phy
,
7432 MDIO_WIS_DEVAD
, MDIO_WIS_REG_LASI_STATUS
, &val1
);
7433 DP(NETIF_MSG_LINK
, "8705 LASI status 0x%x\n", val1
);
7435 bnx2x_cl45_read(bp
, phy
,
7436 MDIO_PMA_DEVAD
, MDIO_PMA_REG_RX_SD
, &rx_sd
);
7438 bnx2x_cl45_read(bp
, phy
,
7439 MDIO_PMA_DEVAD
, 0xc809, &val1
);
7440 bnx2x_cl45_read(bp
, phy
,
7441 MDIO_PMA_DEVAD
, 0xc809, &val1
);
7443 DP(NETIF_MSG_LINK
, "8705 1.c809 val=0x%x\n", val1
);
7444 link_up
= ((rx_sd
& 0x1) && (val1
& (1<<9)) && ((val1
& (1<<8)) == 0));
7446 vars
->line_speed
= SPEED_10000
;
7447 bnx2x_ext_phy_resolve_fc(phy
, params
, vars
);
7452 /******************************************************************/
7453 /* SFP+ module Section */
7454 /******************************************************************/
7455 static void bnx2x_set_disable_pmd_transmit(struct link_params
*params
,
7456 struct bnx2x_phy
*phy
,
7459 struct bnx2x
*bp
= params
->bp
;
7461 * Disable transmitter only for bootcodes which can enable it afterwards
7465 if (params
->feature_config_flags
&
7466 FEATURE_CONFIG_BC_SUPPORTS_SFP_TX_DISABLED
)
7467 DP(NETIF_MSG_LINK
, "Disabling PMD transmitter\n");
7469 DP(NETIF_MSG_LINK
, "NOT disabling PMD transmitter\n");
7473 DP(NETIF_MSG_LINK
, "Enabling PMD transmitter\n");
7474 bnx2x_cl45_write(bp
, phy
,
7476 MDIO_PMA_REG_TX_DISABLE
, pmd_dis
);
7479 static u8
bnx2x_get_gpio_port(struct link_params
*params
)
7482 u32 swap_val
, swap_override
;
7483 struct bnx2x
*bp
= params
->bp
;
7485 gpio_port
= BP_PATH(bp
);
7487 gpio_port
= params
->port
;
7488 swap_val
= REG_RD(bp
, NIG_REG_PORT_SWAP
);
7489 swap_override
= REG_RD(bp
, NIG_REG_STRAP_OVERRIDE
);
7490 return gpio_port
^ (swap_val
&& swap_override
);
7493 static void bnx2x_sfp_e1e2_set_transmitter(struct link_params
*params
,
7494 struct bnx2x_phy
*phy
,
7498 u8 port
= params
->port
;
7499 struct bnx2x
*bp
= params
->bp
;
7502 /* Disable/Enable transmitter ( TX laser of the SFP+ module.)*/
7503 tx_en_mode
= REG_RD(bp
, params
->shmem_base
+
7504 offsetof(struct shmem_region
,
7505 dev_info
.port_hw_config
[port
].sfp_ctrl
)) &
7506 PORT_HW_CFG_TX_LASER_MASK
;
7507 DP(NETIF_MSG_LINK
, "Setting transmitter tx_en=%x for port %x "
7508 "mode = %x\n", tx_en
, port
, tx_en_mode
);
7509 switch (tx_en_mode
) {
7510 case PORT_HW_CFG_TX_LASER_MDIO
:
7512 bnx2x_cl45_read(bp
, phy
,
7514 MDIO_PMA_REG_PHY_IDENTIFIER
,
7522 bnx2x_cl45_write(bp
, phy
,
7524 MDIO_PMA_REG_PHY_IDENTIFIER
,
7527 case PORT_HW_CFG_TX_LASER_GPIO0
:
7528 case PORT_HW_CFG_TX_LASER_GPIO1
:
7529 case PORT_HW_CFG_TX_LASER_GPIO2
:
7530 case PORT_HW_CFG_TX_LASER_GPIO3
:
7533 u8 gpio_port
, gpio_mode
;
7535 gpio_mode
= MISC_REGISTERS_GPIO_OUTPUT_HIGH
;
7537 gpio_mode
= MISC_REGISTERS_GPIO_OUTPUT_LOW
;
7539 gpio_pin
= tx_en_mode
- PORT_HW_CFG_TX_LASER_GPIO0
;
7540 gpio_port
= bnx2x_get_gpio_port(params
);
7541 bnx2x_set_gpio(bp
, gpio_pin
, gpio_mode
, gpio_port
);
7545 DP(NETIF_MSG_LINK
, "Invalid TX_LASER_MDIO 0x%x\n", tx_en_mode
);
7550 static void bnx2x_sfp_set_transmitter(struct link_params
*params
,
7551 struct bnx2x_phy
*phy
,
7554 struct bnx2x
*bp
= params
->bp
;
7555 DP(NETIF_MSG_LINK
, "Setting SFP+ transmitter to %d\n", tx_en
);
7557 bnx2x_sfp_e3_set_transmitter(params
, phy
, tx_en
);
7559 bnx2x_sfp_e1e2_set_transmitter(params
, phy
, tx_en
);
7562 static int bnx2x_8726_read_sfp_module_eeprom(struct bnx2x_phy
*phy
,
7563 struct link_params
*params
,
7564 u16 addr
, u8 byte_cnt
, u8
*o_buf
)
7566 struct bnx2x
*bp
= params
->bp
;
7569 if (byte_cnt
> 16) {
7571 "Reading from eeprom is limited to 0xf\n");
7574 /* Set the read command byte count */
7575 bnx2x_cl45_write(bp
, phy
,
7576 MDIO_PMA_DEVAD
, MDIO_PMA_REG_SFP_TWO_WIRE_BYTE_CNT
,
7577 (byte_cnt
| 0xa000));
7579 /* Set the read command address */
7580 bnx2x_cl45_write(bp
, phy
,
7581 MDIO_PMA_DEVAD
, MDIO_PMA_REG_SFP_TWO_WIRE_MEM_ADDR
,
7584 /* Activate read command */
7585 bnx2x_cl45_write(bp
, phy
,
7586 MDIO_PMA_DEVAD
, MDIO_PMA_REG_SFP_TWO_WIRE_CTRL
,
7589 /* Wait up to 500us for command complete status */
7590 for (i
= 0; i
< 100; i
++) {
7591 bnx2x_cl45_read(bp
, phy
,
7593 MDIO_PMA_REG_SFP_TWO_WIRE_CTRL
, &val
);
7594 if ((val
& MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK
) ==
7595 MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_COMPLETE
)
7600 if ((val
& MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK
) !=
7601 MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_COMPLETE
) {
7603 "Got bad status 0x%x when reading from SFP+ EEPROM\n",
7604 (val
& MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK
));
7608 /* Read the buffer */
7609 for (i
= 0; i
< byte_cnt
; i
++) {
7610 bnx2x_cl45_read(bp
, phy
,
7612 MDIO_PMA_REG_8726_TWO_WIRE_DATA_BUF
+ i
, &val
);
7613 o_buf
[i
] = (u8
)(val
& MDIO_PMA_REG_8726_TWO_WIRE_DATA_MASK
);
7616 for (i
= 0; i
< 100; i
++) {
7617 bnx2x_cl45_read(bp
, phy
,
7619 MDIO_PMA_REG_SFP_TWO_WIRE_CTRL
, &val
);
7620 if ((val
& MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK
) ==
7621 MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_IDLE
)
7628 static int bnx2x_warpcore_read_sfp_module_eeprom(struct bnx2x_phy
*phy
,
7629 struct link_params
*params
,
7630 u16 addr
, u8 byte_cnt
,
7634 u8 i
, j
= 0, cnt
= 0;
7637 struct bnx2x
*bp
= params
->bp
;
7638 /*DP(NETIF_MSG_LINK, "bnx2x_direct_read_sfp_module_eeprom:"
7639 " addr %d, cnt %d\n",
7641 if (byte_cnt
> 16) {
7643 "Reading from eeprom is limited to 16 bytes\n");
7647 /* 4 byte aligned address */
7648 addr32
= addr
& (~0x3);
7650 rc
= bnx2x_bsc_read(params
, phy
, 0xa0, addr32
, 0, byte_cnt
,
7652 } while ((rc
!= 0) && (++cnt
< I2C_WA_RETRY_CNT
));
7655 for (i
= (addr
- addr32
); i
< byte_cnt
+ (addr
- addr32
); i
++) {
7656 o_buf
[j
] = *((u8
*)data_array
+ i
);
7664 static int bnx2x_8727_read_sfp_module_eeprom(struct bnx2x_phy
*phy
,
7665 struct link_params
*params
,
7666 u16 addr
, u8 byte_cnt
, u8
*o_buf
)
7668 struct bnx2x
*bp
= params
->bp
;
7671 if (byte_cnt
> 16) {
7673 "Reading from eeprom is limited to 0xf\n");
7677 /* Need to read from 1.8000 to clear it */
7678 bnx2x_cl45_read(bp
, phy
,
7680 MDIO_PMA_REG_SFP_TWO_WIRE_CTRL
,
7683 /* Set the read command byte count */
7684 bnx2x_cl45_write(bp
, phy
,
7686 MDIO_PMA_REG_SFP_TWO_WIRE_BYTE_CNT
,
7687 ((byte_cnt
< 2) ? 2 : byte_cnt
));
7689 /* Set the read command address */
7690 bnx2x_cl45_write(bp
, phy
,
7692 MDIO_PMA_REG_SFP_TWO_WIRE_MEM_ADDR
,
7694 /* Set the destination address */
7695 bnx2x_cl45_write(bp
, phy
,
7698 MDIO_PMA_REG_8727_TWO_WIRE_DATA_BUF
);
7700 /* Activate read command */
7701 bnx2x_cl45_write(bp
, phy
,
7703 MDIO_PMA_REG_SFP_TWO_WIRE_CTRL
,
7706 * Wait appropriate time for two-wire command to finish before
7707 * polling the status register
7711 /* Wait up to 500us for command complete status */
7712 for (i
= 0; i
< 100; i
++) {
7713 bnx2x_cl45_read(bp
, phy
,
7715 MDIO_PMA_REG_SFP_TWO_WIRE_CTRL
, &val
);
7716 if ((val
& MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK
) ==
7717 MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_COMPLETE
)
7722 if ((val
& MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK
) !=
7723 MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_COMPLETE
) {
7725 "Got bad status 0x%x when reading from SFP+ EEPROM\n",
7726 (val
& MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK
));
7730 /* Read the buffer */
7731 for (i
= 0; i
< byte_cnt
; i
++) {
7732 bnx2x_cl45_read(bp
, phy
,
7734 MDIO_PMA_REG_8727_TWO_WIRE_DATA_BUF
+ i
, &val
);
7735 o_buf
[i
] = (u8
)(val
& MDIO_PMA_REG_8727_TWO_WIRE_DATA_MASK
);
7738 for (i
= 0; i
< 100; i
++) {
7739 bnx2x_cl45_read(bp
, phy
,
7741 MDIO_PMA_REG_SFP_TWO_WIRE_CTRL
, &val
);
7742 if ((val
& MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK
) ==
7743 MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_IDLE
)
7751 int bnx2x_read_sfp_module_eeprom(struct bnx2x_phy
*phy
,
7752 struct link_params
*params
, u16 addr
,
7753 u8 byte_cnt
, u8
*o_buf
)
7756 switch (phy
->type
) {
7757 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726
:
7758 rc
= bnx2x_8726_read_sfp_module_eeprom(phy
, params
, addr
,
7761 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727
:
7762 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8722
:
7763 rc
= bnx2x_8727_read_sfp_module_eeprom(phy
, params
, addr
,
7766 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT
:
7767 rc
= bnx2x_warpcore_read_sfp_module_eeprom(phy
, params
, addr
,
7774 static int bnx2x_get_edc_mode(struct bnx2x_phy
*phy
,
7775 struct link_params
*params
,
7778 struct bnx2x
*bp
= params
->bp
;
7779 u32 sync_offset
= 0, phy_idx
, media_types
;
7780 u8 val
, check_limiting_mode
= 0;
7781 *edc_mode
= EDC_MODE_LIMITING
;
7783 phy
->media_type
= ETH_PHY_UNSPECIFIED
;
7784 /* First check for copper cable */
7785 if (bnx2x_read_sfp_module_eeprom(phy
,
7787 SFP_EEPROM_CON_TYPE_ADDR
,
7790 DP(NETIF_MSG_LINK
, "Failed to read from SFP+ module EEPROM\n");
7795 case SFP_EEPROM_CON_TYPE_VAL_COPPER
:
7797 u8 copper_module_type
;
7798 phy
->media_type
= ETH_PHY_DA_TWINAX
;
7800 * Check if its active cable (includes SFP+ module)
7803 if (bnx2x_read_sfp_module_eeprom(phy
,
7805 SFP_EEPROM_FC_TX_TECH_ADDR
,
7807 &copper_module_type
) != 0) {
7809 "Failed to read copper-cable-type"
7810 " from SFP+ EEPROM\n");
7814 if (copper_module_type
&
7815 SFP_EEPROM_FC_TX_TECH_BITMASK_COPPER_ACTIVE
) {
7816 DP(NETIF_MSG_LINK
, "Active Copper cable detected\n");
7817 check_limiting_mode
= 1;
7818 } else if (copper_module_type
&
7819 SFP_EEPROM_FC_TX_TECH_BITMASK_COPPER_PASSIVE
) {
7821 "Passive Copper cable detected\n");
7823 EDC_MODE_PASSIVE_DAC
;
7826 "Unknown copper-cable-type 0x%x !!!\n",
7827 copper_module_type
);
7832 case SFP_EEPROM_CON_TYPE_VAL_LC
:
7833 phy
->media_type
= ETH_PHY_SFP_FIBER
;
7834 DP(NETIF_MSG_LINK
, "Optic module detected\n");
7835 check_limiting_mode
= 1;
7838 DP(NETIF_MSG_LINK
, "Unable to determine module type 0x%x !!!\n",
7842 sync_offset
= params
->shmem_base
+
7843 offsetof(struct shmem_region
,
7844 dev_info
.port_hw_config
[params
->port
].media_type
);
7845 media_types
= REG_RD(bp
, sync_offset
);
7846 /* Update media type for non-PMF sync */
7847 for (phy_idx
= INT_PHY
; phy_idx
< MAX_PHYS
; phy_idx
++) {
7848 if (&(params
->phy
[phy_idx
]) == phy
) {
7849 media_types
&= ~(PORT_HW_CFG_MEDIA_TYPE_PHY0_MASK
<<
7850 (PORT_HW_CFG_MEDIA_TYPE_PHY1_SHIFT
* phy_idx
));
7851 media_types
|= ((phy
->media_type
&
7852 PORT_HW_CFG_MEDIA_TYPE_PHY0_MASK
) <<
7853 (PORT_HW_CFG_MEDIA_TYPE_PHY1_SHIFT
* phy_idx
));
7857 REG_WR(bp
, sync_offset
, media_types
);
7858 if (check_limiting_mode
) {
7859 u8 options
[SFP_EEPROM_OPTIONS_SIZE
];
7860 if (bnx2x_read_sfp_module_eeprom(phy
,
7862 SFP_EEPROM_OPTIONS_ADDR
,
7863 SFP_EEPROM_OPTIONS_SIZE
,
7866 "Failed to read Option field from module EEPROM\n");
7869 if ((options
[0] & SFP_EEPROM_OPTIONS_LINEAR_RX_OUT_MASK
))
7870 *edc_mode
= EDC_MODE_LINEAR
;
7872 *edc_mode
= EDC_MODE_LIMITING
;
7874 DP(NETIF_MSG_LINK
, "EDC mode is set to 0x%x\n", *edc_mode
);
7878 * This function read the relevant field from the module (SFP+), and verify it
7879 * is compliant with this board
7881 static int bnx2x_verify_sfp_module(struct bnx2x_phy
*phy
,
7882 struct link_params
*params
)
7884 struct bnx2x
*bp
= params
->bp
;
7886 u32 fw_resp
, fw_cmd_param
;
7887 char vendor_name
[SFP_EEPROM_VENDOR_NAME_SIZE
+1];
7888 char vendor_pn
[SFP_EEPROM_PART_NO_SIZE
+1];
7889 phy
->flags
&= ~FLAGS_SFP_NOT_APPROVED
;
7890 val
= REG_RD(bp
, params
->shmem_base
+
7891 offsetof(struct shmem_region
, dev_info
.
7892 port_feature_config
[params
->port
].config
));
7893 if ((val
& PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK
) ==
7894 PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_NO_ENFORCEMENT
) {
7895 DP(NETIF_MSG_LINK
, "NOT enforcing module verification\n");
7899 if (params
->feature_config_flags
&
7900 FEATURE_CONFIG_BC_SUPPORTS_DUAL_PHY_OPT_MDL_VRFY
) {
7901 /* Use specific phy request */
7902 cmd
= DRV_MSG_CODE_VRFY_SPECIFIC_PHY_OPT_MDL
;
7903 } else if (params
->feature_config_flags
&
7904 FEATURE_CONFIG_BC_SUPPORTS_OPT_MDL_VRFY
) {
7905 /* Use first phy request only in case of non-dual media*/
7906 if (DUAL_MEDIA(params
)) {
7908 "FW does not support OPT MDL verification\n");
7911 cmd
= DRV_MSG_CODE_VRFY_FIRST_PHY_OPT_MDL
;
7913 /* No support in OPT MDL detection */
7915 "FW does not support OPT MDL verification\n");
7919 fw_cmd_param
= FW_PARAM_SET(phy
->addr
, phy
->type
, phy
->mdio_ctrl
);
7920 fw_resp
= bnx2x_fw_command(bp
, cmd
, fw_cmd_param
);
7921 if (fw_resp
== FW_MSG_CODE_VRFY_OPT_MDL_SUCCESS
) {
7922 DP(NETIF_MSG_LINK
, "Approved module\n");
7926 /* format the warning message */
7927 if (bnx2x_read_sfp_module_eeprom(phy
,
7929 SFP_EEPROM_VENDOR_NAME_ADDR
,
7930 SFP_EEPROM_VENDOR_NAME_SIZE
,
7932 vendor_name
[0] = '\0';
7934 vendor_name
[SFP_EEPROM_VENDOR_NAME_SIZE
] = '\0';
7935 if (bnx2x_read_sfp_module_eeprom(phy
,
7937 SFP_EEPROM_PART_NO_ADDR
,
7938 SFP_EEPROM_PART_NO_SIZE
,
7940 vendor_pn
[0] = '\0';
7942 vendor_pn
[SFP_EEPROM_PART_NO_SIZE
] = '\0';
7944 netdev_err(bp
->dev
, "Warning: Unqualified SFP+ module detected,"
7945 " Port %d from %s part number %s\n",
7946 params
->port
, vendor_name
, vendor_pn
);
7947 phy
->flags
|= FLAGS_SFP_NOT_APPROVED
;
7951 static int bnx2x_wait_for_sfp_module_initialized(struct bnx2x_phy
*phy
,
7952 struct link_params
*params
)
7956 struct bnx2x
*bp
= params
->bp
;
7959 * Initialization time after hot-plug may take up to 300ms for
7960 * some phys type ( e.g. JDSU )
7963 for (timeout
= 0; timeout
< 60; timeout
++) {
7964 if (bnx2x_read_sfp_module_eeprom(phy
, params
, 1, 1, &val
)
7967 "SFP+ module initialization took %d ms\n",
7976 static void bnx2x_8727_power_module(struct bnx2x
*bp
,
7977 struct bnx2x_phy
*phy
,
7979 /* Make sure GPIOs are not using for LED mode */
7982 * In the GPIO register, bit 4 is use to determine if the GPIOs are
7983 * operating as INPUT or as OUTPUT. Bit 1 is for input, and 0 for
7985 * Bits 0-1 determine the GPIOs value for OUTPUT in case bit 4 val is 0
7986 * Bits 8-9 determine the GPIOs value for INPUT in case bit 4 val is 1
7987 * where the 1st bit is the over-current(only input), and 2nd bit is
7988 * for power( only output )
7990 * In case of NOC feature is disabled and power is up, set GPIO control
7991 * as input to enable listening of over-current indication
7993 if (phy
->flags
& FLAGS_NOC
)
7999 * Set GPIO control to OUTPUT, and set the power bit
8000 * to according to the is_power_up
8004 bnx2x_cl45_write(bp
, phy
,
8006 MDIO_PMA_REG_8727_GPIO_CTRL
,
8010 static int bnx2x_8726_set_limiting_mode(struct bnx2x
*bp
,
8011 struct bnx2x_phy
*phy
,
8014 u16 cur_limiting_mode
;
8016 bnx2x_cl45_read(bp
, phy
,
8018 MDIO_PMA_REG_ROM_VER2
,
8019 &cur_limiting_mode
);
8020 DP(NETIF_MSG_LINK
, "Current Limiting mode is 0x%x\n",
8023 if (edc_mode
== EDC_MODE_LIMITING
) {
8024 DP(NETIF_MSG_LINK
, "Setting LIMITING MODE\n");
8025 bnx2x_cl45_write(bp
, phy
,
8027 MDIO_PMA_REG_ROM_VER2
,
8029 } else { /* LRM mode ( default )*/
8031 DP(NETIF_MSG_LINK
, "Setting LRM MODE\n");
8034 * Changing to LRM mode takes quite few seconds. So do it only
8035 * if current mode is limiting (default is LRM)
8037 if (cur_limiting_mode
!= EDC_MODE_LIMITING
)
8040 bnx2x_cl45_write(bp
, phy
,
8042 MDIO_PMA_REG_LRM_MODE
,
8044 bnx2x_cl45_write(bp
, phy
,
8046 MDIO_PMA_REG_ROM_VER2
,
8048 bnx2x_cl45_write(bp
, phy
,
8050 MDIO_PMA_REG_MISC_CTRL0
,
8052 bnx2x_cl45_write(bp
, phy
,
8054 MDIO_PMA_REG_LRM_MODE
,
8060 static int bnx2x_8727_set_limiting_mode(struct bnx2x
*bp
,
8061 struct bnx2x_phy
*phy
,
8066 bnx2x_cl45_read(bp
, phy
,
8068 MDIO_PMA_REG_PHY_IDENTIFIER
,
8071 bnx2x_cl45_write(bp
, phy
,
8073 MDIO_PMA_REG_PHY_IDENTIFIER
,
8074 (phy_identifier
& ~(1<<9)));
8076 bnx2x_cl45_read(bp
, phy
,
8078 MDIO_PMA_REG_ROM_VER2
,
8080 /* Keep the MSB 8-bits, and set the LSB 8-bits with the edc_mode */
8081 bnx2x_cl45_write(bp
, phy
,
8083 MDIO_PMA_REG_ROM_VER2
,
8084 (rom_ver2_val
& 0xff00) | (edc_mode
& 0x00ff));
8086 bnx2x_cl45_write(bp
, phy
,
8088 MDIO_PMA_REG_PHY_IDENTIFIER
,
8089 (phy_identifier
| (1<<9)));
8094 static void bnx2x_8727_specific_func(struct bnx2x_phy
*phy
,
8095 struct link_params
*params
,
8098 struct bnx2x
*bp
= params
->bp
;
8102 bnx2x_sfp_set_transmitter(params
, phy
, 0);
8105 if (!(phy
->flags
& FLAGS_SFP_NOT_APPROVED
))
8106 bnx2x_sfp_set_transmitter(params
, phy
, 1);
8109 DP(NETIF_MSG_LINK
, "Function 0x%x not supported by 8727\n",
8115 static void bnx2x_set_e1e2_module_fault_led(struct link_params
*params
,
8118 struct bnx2x
*bp
= params
->bp
;
8120 u32 fault_led_gpio
= REG_RD(bp
, params
->shmem_base
+
8121 offsetof(struct shmem_region
,
8122 dev_info
.port_hw_config
[params
->port
].sfp_ctrl
)) &
8123 PORT_HW_CFG_FAULT_MODULE_LED_MASK
;
8124 switch (fault_led_gpio
) {
8125 case PORT_HW_CFG_FAULT_MODULE_LED_DISABLED
:
8127 case PORT_HW_CFG_FAULT_MODULE_LED_GPIO0
:
8128 case PORT_HW_CFG_FAULT_MODULE_LED_GPIO1
:
8129 case PORT_HW_CFG_FAULT_MODULE_LED_GPIO2
:
8130 case PORT_HW_CFG_FAULT_MODULE_LED_GPIO3
:
8132 u8 gpio_port
= bnx2x_get_gpio_port(params
);
8133 u16 gpio_pin
= fault_led_gpio
-
8134 PORT_HW_CFG_FAULT_MODULE_LED_GPIO0
;
8135 DP(NETIF_MSG_LINK
, "Set fault module-detected led "
8136 "pin %x port %x mode %x\n",
8137 gpio_pin
, gpio_port
, gpio_mode
);
8138 bnx2x_set_gpio(bp
, gpio_pin
, gpio_mode
, gpio_port
);
8142 DP(NETIF_MSG_LINK
, "Error: Invalid fault led mode 0x%x\n",
8147 static void bnx2x_set_e3_module_fault_led(struct link_params
*params
,
8151 u8 port
= params
->port
;
8152 struct bnx2x
*bp
= params
->bp
;
8153 pin_cfg
= (REG_RD(bp
, params
->shmem_base
+
8154 offsetof(struct shmem_region
,
8155 dev_info
.port_hw_config
[port
].e3_sfp_ctrl
)) &
8156 PORT_HW_CFG_E3_FAULT_MDL_LED_MASK
) >>
8157 PORT_HW_CFG_E3_FAULT_MDL_LED_SHIFT
;
8158 DP(NETIF_MSG_LINK
, "Setting Fault LED to %d using pin cfg %d\n",
8159 gpio_mode
, pin_cfg
);
8160 bnx2x_set_cfg_pin(bp
, pin_cfg
, gpio_mode
);
8163 static void bnx2x_set_sfp_module_fault_led(struct link_params
*params
,
8166 struct bnx2x
*bp
= params
->bp
;
8167 DP(NETIF_MSG_LINK
, "Setting SFP+ module fault LED to %d\n", gpio_mode
);
8168 if (CHIP_IS_E3(bp
)) {
8170 * Low ==> if SFP+ module is supported otherwise
8171 * High ==> if SFP+ module is not on the approved vendor list
8173 bnx2x_set_e3_module_fault_led(params
, gpio_mode
);
8175 bnx2x_set_e1e2_module_fault_led(params
, gpio_mode
);
8178 static void bnx2x_warpcore_power_module(struct link_params
*params
,
8179 struct bnx2x_phy
*phy
,
8183 struct bnx2x
*bp
= params
->bp
;
8185 pin_cfg
= (REG_RD(bp
, params
->shmem_base
+
8186 offsetof(struct shmem_region
,
8187 dev_info
.port_hw_config
[params
->port
].e3_sfp_ctrl
)) &
8188 PORT_HW_CFG_E3_PWR_DIS_MASK
) >>
8189 PORT_HW_CFG_E3_PWR_DIS_SHIFT
;
8191 if (pin_cfg
== PIN_CFG_NA
)
8193 DP(NETIF_MSG_LINK
, "Setting SFP+ module power to %d using pin cfg %d\n",
8196 * Low ==> corresponding SFP+ module is powered
8197 * high ==> the SFP+ module is powered down
8199 bnx2x_set_cfg_pin(bp
, pin_cfg
, power
^ 1);
8202 static void bnx2x_warpcore_hw_reset(struct bnx2x_phy
*phy
,
8203 struct link_params
*params
)
8205 struct bnx2x
*bp
= params
->bp
;
8206 bnx2x_warpcore_power_module(params
, phy
, 0);
8207 /* Put Warpcore in low power mode */
8208 REG_WR(bp
, MISC_REG_WC0_RESET
, 0x0c0e);
8210 /* Put LCPLL in low power mode */
8211 REG_WR(bp
, MISC_REG_LCPLL_E40_PWRDWN
, 1);
8212 REG_WR(bp
, MISC_REG_LCPLL_E40_RESETB_ANA
, 0);
8213 REG_WR(bp
, MISC_REG_LCPLL_E40_RESETB_DIG
, 0);
8216 static void bnx2x_power_sfp_module(struct link_params
*params
,
8217 struct bnx2x_phy
*phy
,
8220 struct bnx2x
*bp
= params
->bp
;
8221 DP(NETIF_MSG_LINK
, "Setting SFP+ power to %x\n", power
);
8223 switch (phy
->type
) {
8224 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727
:
8225 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8722
:
8226 bnx2x_8727_power_module(params
->bp
, phy
, power
);
8228 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT
:
8229 bnx2x_warpcore_power_module(params
, phy
, power
);
8235 static void bnx2x_warpcore_set_limiting_mode(struct link_params
*params
,
8236 struct bnx2x_phy
*phy
,
8240 u16 mode
= MDIO_WC_REG_UC_INFO_B1_FIRMWARE_MODE_DEFAULT
;
8241 struct bnx2x
*bp
= params
->bp
;
8243 u8 lane
= bnx2x_get_warpcore_lane(phy
, params
);
8244 /* This is a global register which controls all lanes */
8245 bnx2x_cl45_read(bp
, phy
, MDIO_WC_DEVAD
,
8246 MDIO_WC_REG_UC_INFO_B1_FIRMWARE_MODE
, &val
);
8247 val
&= ~(0xf << (lane
<< 2));
8250 case EDC_MODE_LINEAR
:
8251 case EDC_MODE_LIMITING
:
8252 mode
= MDIO_WC_REG_UC_INFO_B1_FIRMWARE_MODE_DEFAULT
;
8254 case EDC_MODE_PASSIVE_DAC
:
8255 mode
= MDIO_WC_REG_UC_INFO_B1_FIRMWARE_MODE_SFP_DAC
;
8261 val
|= (mode
<< (lane
<< 2));
8262 bnx2x_cl45_write(bp
, phy
, MDIO_WC_DEVAD
,
8263 MDIO_WC_REG_UC_INFO_B1_FIRMWARE_MODE
, val
);
8265 bnx2x_cl45_read(bp
, phy
, MDIO_WC_DEVAD
,
8266 MDIO_WC_REG_UC_INFO_B1_FIRMWARE_MODE
, &val
);
8268 /* Restart microcode to re-read the new mode */
8269 bnx2x_warpcore_reset_lane(bp
, phy
, 1);
8270 bnx2x_warpcore_reset_lane(bp
, phy
, 0);
8274 static void bnx2x_set_limiting_mode(struct link_params
*params
,
8275 struct bnx2x_phy
*phy
,
8278 switch (phy
->type
) {
8279 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726
:
8280 bnx2x_8726_set_limiting_mode(params
->bp
, phy
, edc_mode
);
8282 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727
:
8283 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8722
:
8284 bnx2x_8727_set_limiting_mode(params
->bp
, phy
, edc_mode
);
8286 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT
:
8287 bnx2x_warpcore_set_limiting_mode(params
, phy
, edc_mode
);
8292 int bnx2x_sfp_module_detection(struct bnx2x_phy
*phy
,
8293 struct link_params
*params
)
8295 struct bnx2x
*bp
= params
->bp
;
8299 u32 val
= REG_RD(bp
, params
->shmem_base
+
8300 offsetof(struct shmem_region
, dev_info
.
8301 port_feature_config
[params
->port
].config
));
8303 DP(NETIF_MSG_LINK
, "SFP+ module plugged in/out detected on port %d\n",
8305 /* Power up module */
8306 bnx2x_power_sfp_module(params
, phy
, 1);
8307 if (bnx2x_get_edc_mode(phy
, params
, &edc_mode
) != 0) {
8308 DP(NETIF_MSG_LINK
, "Failed to get valid module type\n");
8310 } else if (bnx2x_verify_sfp_module(phy
, params
) != 0) {
8311 /* check SFP+ module compatibility */
8312 DP(NETIF_MSG_LINK
, "Module verification failed!!\n");
8314 /* Turn on fault module-detected led */
8315 bnx2x_set_sfp_module_fault_led(params
,
8316 MISC_REGISTERS_GPIO_HIGH
);
8318 /* Check if need to power down the SFP+ module */
8319 if ((val
& PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK
) ==
8320 PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_POWER_DOWN
) {
8321 DP(NETIF_MSG_LINK
, "Shutdown SFP+ module!!\n");
8322 bnx2x_power_sfp_module(params
, phy
, 0);
8326 /* Turn off fault module-detected led */
8327 bnx2x_set_sfp_module_fault_led(params
, MISC_REGISTERS_GPIO_LOW
);
8331 * Check and set limiting mode / LRM mode on 8726. On 8727 it
8332 * is done automatically
8334 bnx2x_set_limiting_mode(params
, phy
, edc_mode
);
8337 * Enable transmit for this module if the module is approved, or
8338 * if unapproved modules should also enable the Tx laser
8341 (val
& PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK
) !=
8342 PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_DISABLE_TX_LASER
)
8343 bnx2x_sfp_set_transmitter(params
, phy
, 1);
8345 bnx2x_sfp_set_transmitter(params
, phy
, 0);
8350 void bnx2x_handle_module_detect_int(struct link_params
*params
)
8352 struct bnx2x
*bp
= params
->bp
;
8353 struct bnx2x_phy
*phy
;
8355 u8 gpio_num
, gpio_port
;
8357 phy
= ¶ms
->phy
[INT_PHY
];
8359 phy
= ¶ms
->phy
[EXT_PHY1
];
8361 if (bnx2x_get_mod_abs_int_cfg(bp
, params
->chip_id
, params
->shmem_base
,
8362 params
->port
, &gpio_num
, &gpio_port
) ==
8364 DP(NETIF_MSG_LINK
, "Failed to get MOD_ABS interrupt config\n");
8368 /* Set valid module led off */
8369 bnx2x_set_sfp_module_fault_led(params
, MISC_REGISTERS_GPIO_HIGH
);
8371 /* Get current gpio val reflecting module plugged in / out*/
8372 gpio_val
= bnx2x_get_gpio(bp
, gpio_num
, gpio_port
);
8374 /* Call the handling function in case module is detected */
8375 if (gpio_val
== 0) {
8376 bnx2x_power_sfp_module(params
, phy
, 1);
8377 bnx2x_set_gpio_int(bp
, gpio_num
,
8378 MISC_REGISTERS_GPIO_INT_OUTPUT_CLR
,
8380 if (bnx2x_wait_for_sfp_module_initialized(phy
, params
) == 0)
8381 bnx2x_sfp_module_detection(phy
, params
);
8383 DP(NETIF_MSG_LINK
, "SFP+ module is not initialized\n");
8385 u32 val
= REG_RD(bp
, params
->shmem_base
+
8386 offsetof(struct shmem_region
, dev_info
.
8387 port_feature_config
[params
->port
].
8389 bnx2x_set_gpio_int(bp
, gpio_num
,
8390 MISC_REGISTERS_GPIO_INT_OUTPUT_SET
,
8393 * Module was plugged out.
8394 * Disable transmit for this module
8396 phy
->media_type
= ETH_PHY_NOT_PRESENT
;
8397 if (((val
& PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK
) ==
8398 PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_DISABLE_TX_LASER
) ||
8400 bnx2x_sfp_set_transmitter(params
, phy
, 0);
8404 /******************************************************************/
8405 /* Used by 8706 and 8727 */
8406 /******************************************************************/
8407 static void bnx2x_sfp_mask_fault(struct bnx2x
*bp
,
8408 struct bnx2x_phy
*phy
,
8409 u16 alarm_status_offset
,
8410 u16 alarm_ctrl_offset
)
8412 u16 alarm_status
, val
;
8413 bnx2x_cl45_read(bp
, phy
,
8414 MDIO_PMA_DEVAD
, alarm_status_offset
,
8416 bnx2x_cl45_read(bp
, phy
,
8417 MDIO_PMA_DEVAD
, alarm_status_offset
,
8419 /* Mask or enable the fault event. */
8420 bnx2x_cl45_read(bp
, phy
, MDIO_PMA_DEVAD
, alarm_ctrl_offset
, &val
);
8421 if (alarm_status
& (1<<0))
8425 bnx2x_cl45_write(bp
, phy
, MDIO_PMA_DEVAD
, alarm_ctrl_offset
, val
);
8427 /******************************************************************/
8428 /* common BCM8706/BCM8726 PHY SECTION */
8429 /******************************************************************/
8430 static u8
bnx2x_8706_8726_read_status(struct bnx2x_phy
*phy
,
8431 struct link_params
*params
,
8432 struct link_vars
*vars
)
8435 u16 val1
, val2
, rx_sd
, pcs_status
;
8436 struct bnx2x
*bp
= params
->bp
;
8437 DP(NETIF_MSG_LINK
, "XGXS 8706/8726\n");
8439 bnx2x_cl45_read(bp
, phy
,
8440 MDIO_PMA_DEVAD
, MDIO_PMA_LASI_RXSTAT
, &val2
);
8442 bnx2x_sfp_mask_fault(bp
, phy
, MDIO_PMA_LASI_TXSTAT
,
8443 MDIO_PMA_LASI_TXCTRL
);
8445 /* clear LASI indication*/
8446 bnx2x_cl45_read(bp
, phy
,
8447 MDIO_PMA_DEVAD
, MDIO_PMA_LASI_STAT
, &val1
);
8448 bnx2x_cl45_read(bp
, phy
,
8449 MDIO_PMA_DEVAD
, MDIO_PMA_LASI_STAT
, &val2
);
8450 DP(NETIF_MSG_LINK
, "8706/8726 LASI status 0x%x--> 0x%x\n", val1
, val2
);
8452 bnx2x_cl45_read(bp
, phy
,
8453 MDIO_PMA_DEVAD
, MDIO_PMA_REG_RX_SD
, &rx_sd
);
8454 bnx2x_cl45_read(bp
, phy
,
8455 MDIO_PCS_DEVAD
, MDIO_PCS_REG_STATUS
, &pcs_status
);
8456 bnx2x_cl45_read(bp
, phy
,
8457 MDIO_AN_DEVAD
, MDIO_AN_REG_LINK_STATUS
, &val2
);
8458 bnx2x_cl45_read(bp
, phy
,
8459 MDIO_AN_DEVAD
, MDIO_AN_REG_LINK_STATUS
, &val2
);
8461 DP(NETIF_MSG_LINK
, "8706/8726 rx_sd 0x%x pcs_status 0x%x 1Gbps"
8462 " link_status 0x%x\n", rx_sd
, pcs_status
, val2
);
8464 * link is up if both bit 0 of pmd_rx_sd and bit 0 of pcs_status
8465 * are set, or if the autoneg bit 1 is set
8467 link_up
= ((rx_sd
& pcs_status
& 0x1) || (val2
& (1<<1)));
8470 vars
->line_speed
= SPEED_1000
;
8472 vars
->line_speed
= SPEED_10000
;
8473 bnx2x_ext_phy_resolve_fc(phy
, params
, vars
);
8474 vars
->duplex
= DUPLEX_FULL
;
8477 /* Capture 10G link fault. Read twice to clear stale value. */
8478 if (vars
->line_speed
== SPEED_10000
) {
8479 bnx2x_cl45_read(bp
, phy
, MDIO_PMA_DEVAD
,
8480 MDIO_PMA_LASI_TXSTAT
, &val1
);
8481 bnx2x_cl45_read(bp
, phy
, MDIO_PMA_DEVAD
,
8482 MDIO_PMA_LASI_TXSTAT
, &val1
);
8484 vars
->fault_detected
= 1;
8490 /******************************************************************/
8491 /* BCM8706 PHY SECTION */
8492 /******************************************************************/
8493 static u8
bnx2x_8706_config_init(struct bnx2x_phy
*phy
,
8494 struct link_params
*params
,
8495 struct link_vars
*vars
)
8499 struct bnx2x
*bp
= params
->bp
;
8501 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_2
,
8502 MISC_REGISTERS_GPIO_OUTPUT_HIGH
, params
->port
);
8504 bnx2x_ext_phy_hw_reset(bp
, params
->port
);
8505 bnx2x_cl45_write(bp
, phy
, MDIO_PMA_DEVAD
, MDIO_PMA_REG_CTRL
, 0xa040);
8506 bnx2x_wait_reset_complete(bp
, phy
, params
);
8508 /* Wait until fw is loaded */
8509 for (cnt
= 0; cnt
< 100; cnt
++) {
8510 bnx2x_cl45_read(bp
, phy
,
8511 MDIO_PMA_DEVAD
, MDIO_PMA_REG_ROM_VER1
, &val
);
8516 DP(NETIF_MSG_LINK
, "XGXS 8706 is initialized after %d ms\n", cnt
);
8517 if ((params
->feature_config_flags
&
8518 FEATURE_CONFIG_OVERRIDE_PREEMPHASIS_ENABLED
)) {
8521 for (i
= 0; i
< 4; i
++) {
8522 reg
= MDIO_XS_8706_REG_BANK_RX0
+
8523 i
*(MDIO_XS_8706_REG_BANK_RX1
-
8524 MDIO_XS_8706_REG_BANK_RX0
);
8525 bnx2x_cl45_read(bp
, phy
, MDIO_XS_DEVAD
, reg
, &val
);
8526 /* Clear first 3 bits of the control */
8528 /* Set control bits according to configuration */
8529 val
|= (phy
->rx_preemphasis
[i
] & 0x7);
8530 DP(NETIF_MSG_LINK
, "Setting RX Equalizer to BCM8706"
8531 " reg 0x%x <-- val 0x%x\n", reg
, val
);
8532 bnx2x_cl45_write(bp
, phy
, MDIO_XS_DEVAD
, reg
, val
);
8536 if (phy
->req_line_speed
== SPEED_10000
) {
8537 DP(NETIF_MSG_LINK
, "XGXS 8706 force 10Gbps\n");
8539 bnx2x_cl45_write(bp
, phy
,
8541 MDIO_PMA_REG_DIGITAL_CTRL
, 0x400);
8542 bnx2x_cl45_write(bp
, phy
,
8543 MDIO_PMA_DEVAD
, MDIO_PMA_LASI_TXCTRL
,
8545 /* Arm LASI for link and Tx fault. */
8546 bnx2x_cl45_write(bp
, phy
,
8547 MDIO_PMA_DEVAD
, MDIO_PMA_LASI_CTRL
, 3);
8549 /* Force 1Gbps using autoneg with 1G advertisement */
8551 /* Allow CL37 through CL73 */
8552 DP(NETIF_MSG_LINK
, "XGXS 8706 AutoNeg\n");
8553 bnx2x_cl45_write(bp
, phy
,
8554 MDIO_AN_DEVAD
, MDIO_AN_REG_CL37_CL73
, 0x040c);
8556 /* Enable Full-Duplex advertisement on CL37 */
8557 bnx2x_cl45_write(bp
, phy
,
8558 MDIO_AN_DEVAD
, MDIO_AN_REG_CL37_FC_LP
, 0x0020);
8559 /* Enable CL37 AN */
8560 bnx2x_cl45_write(bp
, phy
,
8561 MDIO_AN_DEVAD
, MDIO_AN_REG_CL37_AN
, 0x1000);
8563 bnx2x_cl45_write(bp
, phy
,
8564 MDIO_AN_DEVAD
, MDIO_AN_REG_ADV
, (1<<5));
8566 /* Enable clause 73 AN */
8567 bnx2x_cl45_write(bp
, phy
,
8568 MDIO_AN_DEVAD
, MDIO_AN_REG_CTRL
, 0x1200);
8569 bnx2x_cl45_write(bp
, phy
,
8570 MDIO_PMA_DEVAD
, MDIO_PMA_LASI_RXCTRL
,
8572 bnx2x_cl45_write(bp
, phy
,
8573 MDIO_PMA_DEVAD
, MDIO_PMA_LASI_CTRL
,
8576 bnx2x_save_bcm_spirom_ver(bp
, phy
, params
->port
);
8579 * If TX Laser is controlled by GPIO_0, do not let PHY go into low
8580 * power mode, if TX Laser is disabled
8583 tx_en_mode
= REG_RD(bp
, params
->shmem_base
+
8584 offsetof(struct shmem_region
,
8585 dev_info
.port_hw_config
[params
->port
].sfp_ctrl
))
8586 & PORT_HW_CFG_TX_LASER_MASK
;
8588 if (tx_en_mode
== PORT_HW_CFG_TX_LASER_GPIO0
) {
8589 DP(NETIF_MSG_LINK
, "Enabling TXONOFF_PWRDN_DIS\n");
8590 bnx2x_cl45_read(bp
, phy
,
8591 MDIO_PMA_DEVAD
, MDIO_PMA_REG_DIGITAL_CTRL
, &tmp1
);
8593 bnx2x_cl45_write(bp
, phy
,
8594 MDIO_PMA_DEVAD
, MDIO_PMA_REG_DIGITAL_CTRL
, tmp1
);
8600 static int bnx2x_8706_read_status(struct bnx2x_phy
*phy
,
8601 struct link_params
*params
,
8602 struct link_vars
*vars
)
8604 return bnx2x_8706_8726_read_status(phy
, params
, vars
);
8607 /******************************************************************/
8608 /* BCM8726 PHY SECTION */
8609 /******************************************************************/
8610 static void bnx2x_8726_config_loopback(struct bnx2x_phy
*phy
,
8611 struct link_params
*params
)
8613 struct bnx2x
*bp
= params
->bp
;
8614 DP(NETIF_MSG_LINK
, "PMA/PMD ext_phy_loopback: 8726\n");
8615 bnx2x_cl45_write(bp
, phy
, MDIO_PMA_DEVAD
, MDIO_PMA_REG_CTRL
, 0x0001);
8618 static void bnx2x_8726_external_rom_boot(struct bnx2x_phy
*phy
,
8619 struct link_params
*params
)
8621 struct bnx2x
*bp
= params
->bp
;
8622 /* Need to wait 100ms after reset */
8625 /* Micro controller re-boot */
8626 bnx2x_cl45_write(bp
, phy
,
8627 MDIO_PMA_DEVAD
, MDIO_PMA_REG_GEN_CTRL
, 0x018B);
8629 /* Set soft reset */
8630 bnx2x_cl45_write(bp
, phy
,
8632 MDIO_PMA_REG_GEN_CTRL
,
8633 MDIO_PMA_REG_GEN_CTRL_ROM_MICRO_RESET
);
8635 bnx2x_cl45_write(bp
, phy
,
8637 MDIO_PMA_REG_MISC_CTRL1
, 0x0001);
8639 bnx2x_cl45_write(bp
, phy
,
8641 MDIO_PMA_REG_GEN_CTRL
,
8642 MDIO_PMA_REG_GEN_CTRL_ROM_RESET_INTERNAL_MP
);
8644 /* wait for 150ms for microcode load */
8647 /* Disable serial boot control, tristates pins SS_N, SCK, MOSI, MISO */
8648 bnx2x_cl45_write(bp
, phy
,
8650 MDIO_PMA_REG_MISC_CTRL1
, 0x0000);
8653 bnx2x_save_bcm_spirom_ver(bp
, phy
, params
->port
);
8656 static u8
bnx2x_8726_read_status(struct bnx2x_phy
*phy
,
8657 struct link_params
*params
,
8658 struct link_vars
*vars
)
8660 struct bnx2x
*bp
= params
->bp
;
8662 u8 link_up
= bnx2x_8706_8726_read_status(phy
, params
, vars
);
8664 bnx2x_cl45_read(bp
, phy
,
8665 MDIO_PMA_DEVAD
, MDIO_PMA_REG_PHY_IDENTIFIER
,
8667 if (val1
& (1<<15)) {
8668 DP(NETIF_MSG_LINK
, "Tx is disabled\n");
8670 vars
->line_speed
= 0;
8677 static int bnx2x_8726_config_init(struct bnx2x_phy
*phy
,
8678 struct link_params
*params
,
8679 struct link_vars
*vars
)
8681 struct bnx2x
*bp
= params
->bp
;
8682 DP(NETIF_MSG_LINK
, "Initializing BCM8726\n");
8684 bnx2x_cl45_write(bp
, phy
, MDIO_PMA_DEVAD
, MDIO_PMA_REG_CTRL
, 1<<15);
8685 bnx2x_wait_reset_complete(bp
, phy
, params
);
8687 bnx2x_8726_external_rom_boot(phy
, params
);
8690 * Need to call module detected on initialization since the module
8691 * detection triggered by actual module insertion might occur before
8692 * driver is loaded, and when driver is loaded, it reset all
8693 * registers, including the transmitter
8695 bnx2x_sfp_module_detection(phy
, params
);
8697 if (phy
->req_line_speed
== SPEED_1000
) {
8698 DP(NETIF_MSG_LINK
, "Setting 1G force\n");
8699 bnx2x_cl45_write(bp
, phy
,
8700 MDIO_PMA_DEVAD
, MDIO_PMA_REG_CTRL
, 0x40);
8701 bnx2x_cl45_write(bp
, phy
,
8702 MDIO_PMA_DEVAD
, MDIO_PMA_REG_10G_CTRL2
, 0xD);
8703 bnx2x_cl45_write(bp
, phy
,
8704 MDIO_PMA_DEVAD
, MDIO_PMA_LASI_CTRL
, 0x5);
8705 bnx2x_cl45_write(bp
, phy
,
8706 MDIO_PMA_DEVAD
, MDIO_PMA_LASI_RXCTRL
,
8708 } else if ((phy
->req_line_speed
== SPEED_AUTO_NEG
) &&
8709 (phy
->speed_cap_mask
&
8710 PORT_HW_CFG_SPEED_CAPABILITY_D0_1G
) &&
8711 ((phy
->speed_cap_mask
&
8712 PORT_HW_CFG_SPEED_CAPABILITY_D0_10G
) !=
8713 PORT_HW_CFG_SPEED_CAPABILITY_D0_10G
)) {
8714 DP(NETIF_MSG_LINK
, "Setting 1G clause37\n");
8715 /* Set Flow control */
8716 bnx2x_ext_phy_set_pause(params
, phy
, vars
);
8717 bnx2x_cl45_write(bp
, phy
,
8718 MDIO_AN_DEVAD
, MDIO_AN_REG_ADV
, 0x20);
8719 bnx2x_cl45_write(bp
, phy
,
8720 MDIO_AN_DEVAD
, MDIO_AN_REG_CL37_CL73
, 0x040c);
8721 bnx2x_cl45_write(bp
, phy
,
8722 MDIO_AN_DEVAD
, MDIO_AN_REG_CL37_FC_LD
, 0x0020);
8723 bnx2x_cl45_write(bp
, phy
,
8724 MDIO_AN_DEVAD
, MDIO_AN_REG_CL37_AN
, 0x1000);
8725 bnx2x_cl45_write(bp
, phy
,
8726 MDIO_AN_DEVAD
, MDIO_AN_REG_CTRL
, 0x1200);
8728 * Enable RX-ALARM control to receive interrupt for 1G speed
8731 bnx2x_cl45_write(bp
, phy
,
8732 MDIO_PMA_DEVAD
, MDIO_PMA_LASI_CTRL
, 0x4);
8733 bnx2x_cl45_write(bp
, phy
,
8734 MDIO_PMA_DEVAD
, MDIO_PMA_LASI_RXCTRL
,
8737 } else { /* Default 10G. Set only LASI control */
8738 bnx2x_cl45_write(bp
, phy
,
8739 MDIO_PMA_DEVAD
, MDIO_PMA_LASI_CTRL
, 1);
8742 /* Set TX PreEmphasis if needed */
8743 if ((params
->feature_config_flags
&
8744 FEATURE_CONFIG_OVERRIDE_PREEMPHASIS_ENABLED
)) {
8746 "Setting TX_CTRL1 0x%x, TX_CTRL2 0x%x\n",
8747 phy
->tx_preemphasis
[0],
8748 phy
->tx_preemphasis
[1]);
8749 bnx2x_cl45_write(bp
, phy
,
8751 MDIO_PMA_REG_8726_TX_CTRL1
,
8752 phy
->tx_preemphasis
[0]);
8754 bnx2x_cl45_write(bp
, phy
,
8756 MDIO_PMA_REG_8726_TX_CTRL2
,
8757 phy
->tx_preemphasis
[1]);
8764 static void bnx2x_8726_link_reset(struct bnx2x_phy
*phy
,
8765 struct link_params
*params
)
8767 struct bnx2x
*bp
= params
->bp
;
8768 DP(NETIF_MSG_LINK
, "bnx2x_8726_link_reset port %d\n", params
->port
);
8769 /* Set serial boot control for external load */
8770 bnx2x_cl45_write(bp
, phy
,
8772 MDIO_PMA_REG_GEN_CTRL
, 0x0001);
8775 /******************************************************************/
8776 /* BCM8727 PHY SECTION */
8777 /******************************************************************/
8779 static void bnx2x_8727_set_link_led(struct bnx2x_phy
*phy
,
8780 struct link_params
*params
, u8 mode
)
8782 struct bnx2x
*bp
= params
->bp
;
8783 u16 led_mode_bitmask
= 0;
8784 u16 gpio_pins_bitmask
= 0;
8786 /* Only NOC flavor requires to set the LED specifically */
8787 if (!(phy
->flags
& FLAGS_NOC
))
8790 case LED_MODE_FRONT_PANEL_OFF
:
8792 led_mode_bitmask
= 0;
8793 gpio_pins_bitmask
= 0x03;
8796 led_mode_bitmask
= 0;
8797 gpio_pins_bitmask
= 0x02;
8800 led_mode_bitmask
= 0x60;
8801 gpio_pins_bitmask
= 0x11;
8804 bnx2x_cl45_read(bp
, phy
,
8806 MDIO_PMA_REG_8727_PCS_OPT_CTRL
,
8809 val
|= led_mode_bitmask
;
8810 bnx2x_cl45_write(bp
, phy
,
8812 MDIO_PMA_REG_8727_PCS_OPT_CTRL
,
8814 bnx2x_cl45_read(bp
, phy
,
8816 MDIO_PMA_REG_8727_GPIO_CTRL
,
8819 val
|= gpio_pins_bitmask
;
8820 bnx2x_cl45_write(bp
, phy
,
8822 MDIO_PMA_REG_8727_GPIO_CTRL
,
8825 static void bnx2x_8727_hw_reset(struct bnx2x_phy
*phy
,
8826 struct link_params
*params
) {
8827 u32 swap_val
, swap_override
;
8830 * The PHY reset is controlled by GPIO 1. Fake the port number
8831 * to cancel the swap done in set_gpio()
8833 struct bnx2x
*bp
= params
->bp
;
8834 swap_val
= REG_RD(bp
, NIG_REG_PORT_SWAP
);
8835 swap_override
= REG_RD(bp
, NIG_REG_STRAP_OVERRIDE
);
8836 port
= (swap_val
&& swap_override
) ^ 1;
8837 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_1
,
8838 MISC_REGISTERS_GPIO_OUTPUT_LOW
, port
);
8841 static int bnx2x_8727_config_init(struct bnx2x_phy
*phy
,
8842 struct link_params
*params
,
8843 struct link_vars
*vars
)
8846 u16 tmp1
, val
, mod_abs
, tmp2
;
8847 u16 rx_alarm_ctrl_val
;
8849 struct bnx2x
*bp
= params
->bp
;
8850 /* Enable PMD link, MOD_ABS_FLT, and 1G link alarm */
8852 bnx2x_wait_reset_complete(bp
, phy
, params
);
8853 rx_alarm_ctrl_val
= (1<<2) | (1<<5) ;
8854 /* Should be 0x6 to enable XS on Tx side. */
8855 lasi_ctrl_val
= 0x0006;
8857 DP(NETIF_MSG_LINK
, "Initializing BCM8727\n");
8859 bnx2x_cl45_write(bp
, phy
,
8860 MDIO_PMA_DEVAD
, MDIO_PMA_LASI_RXCTRL
,
8862 bnx2x_cl45_write(bp
, phy
,
8863 MDIO_PMA_DEVAD
, MDIO_PMA_LASI_TXCTRL
,
8865 bnx2x_cl45_write(bp
, phy
,
8866 MDIO_PMA_DEVAD
, MDIO_PMA_LASI_CTRL
, lasi_ctrl_val
);
8869 * Initially configure MOD_ABS to interrupt when module is
8872 bnx2x_cl45_read(bp
, phy
,
8873 MDIO_PMA_DEVAD
, MDIO_PMA_REG_PHY_IDENTIFIER
, &mod_abs
);
8875 * Set EDC off by setting OPTXLOS signal input to low (bit 9).
8876 * When the EDC is off it locks onto a reference clock and avoids
8880 if (!(phy
->flags
& FLAGS_NOC
))
8882 bnx2x_cl45_write(bp
, phy
,
8883 MDIO_PMA_DEVAD
, MDIO_PMA_REG_PHY_IDENTIFIER
, mod_abs
);
8886 /* Enable/Disable PHY transmitter output */
8887 bnx2x_set_disable_pmd_transmit(params
, phy
, 0);
8889 /* Make MOD_ABS give interrupt on change */
8890 bnx2x_cl45_read(bp
, phy
, MDIO_PMA_DEVAD
, MDIO_PMA_REG_8727_PCS_OPT_CTRL
,
8893 if (phy
->flags
& FLAGS_NOC
)
8897 * Set 8727 GPIOs to input to allow reading from the 8727 GPIO0
8898 * status which reflect SFP+ module over-current
8900 if (!(phy
->flags
& FLAGS_NOC
))
8901 val
&= 0xff8f; /* Reset bits 4-6 */
8902 bnx2x_cl45_write(bp
, phy
,
8903 MDIO_PMA_DEVAD
, MDIO_PMA_REG_8727_PCS_OPT_CTRL
, val
);
8905 bnx2x_8727_power_module(bp
, phy
, 1);
8907 bnx2x_cl45_read(bp
, phy
,
8908 MDIO_PMA_DEVAD
, MDIO_PMA_REG_M8051_MSGOUT_REG
, &tmp1
);
8910 bnx2x_cl45_read(bp
, phy
,
8911 MDIO_PMA_DEVAD
, MDIO_PMA_LASI_RXSTAT
, &tmp1
);
8913 /* Set option 1G speed */
8914 if (phy
->req_line_speed
== SPEED_1000
) {
8915 DP(NETIF_MSG_LINK
, "Setting 1G force\n");
8916 bnx2x_cl45_write(bp
, phy
,
8917 MDIO_PMA_DEVAD
, MDIO_PMA_REG_CTRL
, 0x40);
8918 bnx2x_cl45_write(bp
, phy
,
8919 MDIO_PMA_DEVAD
, MDIO_PMA_REG_10G_CTRL2
, 0xD);
8920 bnx2x_cl45_read(bp
, phy
,
8921 MDIO_PMA_DEVAD
, MDIO_PMA_REG_10G_CTRL2
, &tmp1
);
8922 DP(NETIF_MSG_LINK
, "1.7 = 0x%x\n", tmp1
);
8924 * Power down the XAUI until link is up in case of dual-media
8927 if (DUAL_MEDIA(params
)) {
8928 bnx2x_cl45_read(bp
, phy
,
8930 MDIO_PMA_REG_8727_PCS_GP
, &val
);
8932 bnx2x_cl45_write(bp
, phy
,
8934 MDIO_PMA_REG_8727_PCS_GP
, val
);
8936 } else if ((phy
->req_line_speed
== SPEED_AUTO_NEG
) &&
8937 ((phy
->speed_cap_mask
&
8938 PORT_HW_CFG_SPEED_CAPABILITY_D0_1G
)) &&
8939 ((phy
->speed_cap_mask
&
8940 PORT_HW_CFG_SPEED_CAPABILITY_D0_10G
) !=
8941 PORT_HW_CFG_SPEED_CAPABILITY_D0_10G
)) {
8943 DP(NETIF_MSG_LINK
, "Setting 1G clause37\n");
8944 bnx2x_cl45_write(bp
, phy
,
8945 MDIO_AN_DEVAD
, MDIO_AN_REG_8727_MISC_CTRL
, 0);
8946 bnx2x_cl45_write(bp
, phy
,
8947 MDIO_AN_DEVAD
, MDIO_AN_REG_CL37_AN
, 0x1300);
8950 * Since the 8727 has only single reset pin, need to set the 10G
8951 * registers although it is default
8953 bnx2x_cl45_write(bp
, phy
,
8954 MDIO_AN_DEVAD
, MDIO_AN_REG_8727_MISC_CTRL
,
8956 bnx2x_cl45_write(bp
, phy
,
8957 MDIO_AN_DEVAD
, MDIO_AN_REG_CL37_AN
, 0x0100);
8958 bnx2x_cl45_write(bp
, phy
,
8959 MDIO_PMA_DEVAD
, MDIO_PMA_REG_CTRL
, 0x2040);
8960 bnx2x_cl45_write(bp
, phy
,
8961 MDIO_PMA_DEVAD
, MDIO_PMA_REG_10G_CTRL2
,
8966 * Set 2-wire transfer rate of SFP+ module EEPROM
8967 * to 100Khz since some DACs(direct attached cables) do
8968 * not work at 400Khz.
8970 bnx2x_cl45_write(bp
, phy
,
8971 MDIO_PMA_DEVAD
, MDIO_PMA_REG_8727_TWO_WIRE_SLAVE_ADDR
,
8974 /* Set TX PreEmphasis if needed */
8975 if ((params
->feature_config_flags
&
8976 FEATURE_CONFIG_OVERRIDE_PREEMPHASIS_ENABLED
)) {
8977 DP(NETIF_MSG_LINK
, "Setting TX_CTRL1 0x%x, TX_CTRL2 0x%x\n",
8978 phy
->tx_preemphasis
[0],
8979 phy
->tx_preemphasis
[1]);
8980 bnx2x_cl45_write(bp
, phy
,
8981 MDIO_PMA_DEVAD
, MDIO_PMA_REG_8727_TX_CTRL1
,
8982 phy
->tx_preemphasis
[0]);
8984 bnx2x_cl45_write(bp
, phy
,
8985 MDIO_PMA_DEVAD
, MDIO_PMA_REG_8727_TX_CTRL2
,
8986 phy
->tx_preemphasis
[1]);
8990 * If TX Laser is controlled by GPIO_0, do not let PHY go into low
8991 * power mode, if TX Laser is disabled
8993 tx_en_mode
= REG_RD(bp
, params
->shmem_base
+
8994 offsetof(struct shmem_region
,
8995 dev_info
.port_hw_config
[params
->port
].sfp_ctrl
))
8996 & PORT_HW_CFG_TX_LASER_MASK
;
8998 if (tx_en_mode
== PORT_HW_CFG_TX_LASER_GPIO0
) {
9000 DP(NETIF_MSG_LINK
, "Enabling TXONOFF_PWRDN_DIS\n");
9001 bnx2x_cl45_read(bp
, phy
,
9002 MDIO_PMA_DEVAD
, MDIO_PMA_REG_8727_OPT_CFG_REG
, &tmp2
);
9005 bnx2x_cl45_write(bp
, phy
,
9006 MDIO_PMA_DEVAD
, MDIO_PMA_REG_8727_OPT_CFG_REG
, tmp2
);
9012 static void bnx2x_8727_handle_mod_abs(struct bnx2x_phy
*phy
,
9013 struct link_params
*params
)
9015 struct bnx2x
*bp
= params
->bp
;
9016 u16 mod_abs
, rx_alarm_status
;
9017 u32 val
= REG_RD(bp
, params
->shmem_base
+
9018 offsetof(struct shmem_region
, dev_info
.
9019 port_feature_config
[params
->port
].
9021 bnx2x_cl45_read(bp
, phy
,
9023 MDIO_PMA_REG_PHY_IDENTIFIER
, &mod_abs
);
9024 if (mod_abs
& (1<<8)) {
9026 /* Module is absent */
9028 "MOD_ABS indication show module is absent\n");
9029 phy
->media_type
= ETH_PHY_NOT_PRESENT
;
9031 * 1. Set mod_abs to detect next module
9033 * 2. Set EDC off by setting OPTXLOS signal input to low
9035 * When the EDC is off it locks onto a reference clock and
9036 * avoids becoming 'lost'.
9039 if (!(phy
->flags
& FLAGS_NOC
))
9041 bnx2x_cl45_write(bp
, phy
,
9043 MDIO_PMA_REG_PHY_IDENTIFIER
, mod_abs
);
9046 * Clear RX alarm since it stays up as long as
9047 * the mod_abs wasn't changed
9049 bnx2x_cl45_read(bp
, phy
,
9051 MDIO_PMA_LASI_RXSTAT
, &rx_alarm_status
);
9054 /* Module is present */
9056 "MOD_ABS indication show module is present\n");
9058 * First disable transmitter, and if the module is ok, the
9059 * module_detection will enable it
9060 * 1. Set mod_abs to detect next module absent event ( bit 8)
9061 * 2. Restore the default polarity of the OPRXLOS signal and
9062 * this signal will then correctly indicate the presence or
9063 * absence of the Rx signal. (bit 9)
9066 if (!(phy
->flags
& FLAGS_NOC
))
9068 bnx2x_cl45_write(bp
, phy
,
9070 MDIO_PMA_REG_PHY_IDENTIFIER
, mod_abs
);
9073 * Clear RX alarm since it stays up as long as the mod_abs
9074 * wasn't changed. This is need to be done before calling the
9075 * module detection, otherwise it will clear* the link update
9078 bnx2x_cl45_read(bp
, phy
,
9080 MDIO_PMA_LASI_RXSTAT
, &rx_alarm_status
);
9083 if ((val
& PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK
) ==
9084 PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_DISABLE_TX_LASER
)
9085 bnx2x_sfp_set_transmitter(params
, phy
, 0);
9087 if (bnx2x_wait_for_sfp_module_initialized(phy
, params
) == 0)
9088 bnx2x_sfp_module_detection(phy
, params
);
9090 DP(NETIF_MSG_LINK
, "SFP+ module is not initialized\n");
9093 DP(NETIF_MSG_LINK
, "8727 RX_ALARM_STATUS 0x%x\n",
9095 /* No need to check link status in case of module plugged in/out */
9098 static u8
bnx2x_8727_read_status(struct bnx2x_phy
*phy
,
9099 struct link_params
*params
,
9100 struct link_vars
*vars
)
9103 struct bnx2x
*bp
= params
->bp
;
9104 u8 link_up
= 0, oc_port
= params
->port
;
9105 u16 link_status
= 0;
9106 u16 rx_alarm_status
, lasi_ctrl
, val1
;
9108 /* If PHY is not initialized, do not check link status */
9109 bnx2x_cl45_read(bp
, phy
,
9110 MDIO_PMA_DEVAD
, MDIO_PMA_LASI_CTRL
,
9115 /* Check the LASI on Rx */
9116 bnx2x_cl45_read(bp
, phy
,
9117 MDIO_PMA_DEVAD
, MDIO_PMA_LASI_RXSTAT
,
9119 vars
->line_speed
= 0;
9120 DP(NETIF_MSG_LINK
, "8727 RX_ALARM_STATUS 0x%x\n", rx_alarm_status
);
9122 bnx2x_sfp_mask_fault(bp
, phy
, MDIO_PMA_LASI_TXSTAT
,
9123 MDIO_PMA_LASI_TXCTRL
);
9125 bnx2x_cl45_read(bp
, phy
,
9126 MDIO_PMA_DEVAD
, MDIO_PMA_LASI_STAT
, &val1
);
9128 DP(NETIF_MSG_LINK
, "8727 LASI status 0x%x\n", val1
);
9131 bnx2x_cl45_read(bp
, phy
,
9132 MDIO_PMA_DEVAD
, MDIO_PMA_REG_M8051_MSGOUT_REG
, &val1
);
9135 * If a module is present and there is need to check
9138 if (!(phy
->flags
& FLAGS_NOC
) && !(rx_alarm_status
& (1<<5))) {
9139 /* Check over-current using 8727 GPIO0 input*/
9140 bnx2x_cl45_read(bp
, phy
,
9141 MDIO_PMA_DEVAD
, MDIO_PMA_REG_8727_GPIO_CTRL
,
9144 if ((val1
& (1<<8)) == 0) {
9145 if (!CHIP_IS_E1x(bp
))
9146 oc_port
= BP_PATH(bp
) + (params
->port
<< 1);
9148 "8727 Power fault has been detected on port %d\n",
9150 netdev_err(bp
->dev
, "Error: Power fault on Port %d has "
9151 "been detected and the power to "
9152 "that SFP+ module has been removed "
9153 "to prevent failure of the card. "
9154 "Please remove the SFP+ module and "
9155 "restart the system to clear this "
9158 /* Disable all RX_ALARMs except for mod_abs */
9159 bnx2x_cl45_write(bp
, phy
,
9161 MDIO_PMA_LASI_RXCTRL
, (1<<5));
9163 bnx2x_cl45_read(bp
, phy
,
9165 MDIO_PMA_REG_PHY_IDENTIFIER
, &val1
);
9166 /* Wait for module_absent_event */
9168 bnx2x_cl45_write(bp
, phy
,
9170 MDIO_PMA_REG_PHY_IDENTIFIER
, val1
);
9171 /* Clear RX alarm */
9172 bnx2x_cl45_read(bp
, phy
,
9174 MDIO_PMA_LASI_RXSTAT
, &rx_alarm_status
);
9177 } /* Over current check */
9179 /* When module absent bit is set, check module */
9180 if (rx_alarm_status
& (1<<5)) {
9181 bnx2x_8727_handle_mod_abs(phy
, params
);
9182 /* Enable all mod_abs and link detection bits */
9183 bnx2x_cl45_write(bp
, phy
,
9184 MDIO_PMA_DEVAD
, MDIO_PMA_LASI_RXCTRL
,
9187 DP(NETIF_MSG_LINK
, "Enabling 8727 TX laser if SFP is approved\n");
9188 bnx2x_8727_specific_func(phy
, params
, ENABLE_TX
);
9189 /* If transmitter is disabled, ignore false link up indication */
9190 bnx2x_cl45_read(bp
, phy
,
9191 MDIO_PMA_DEVAD
, MDIO_PMA_REG_PHY_IDENTIFIER
, &val1
);
9192 if (val1
& (1<<15)) {
9193 DP(NETIF_MSG_LINK
, "Tx is disabled\n");
9197 bnx2x_cl45_read(bp
, phy
,
9199 MDIO_PMA_REG_8073_SPEED_LINK_STATUS
, &link_status
);
9202 * Bits 0..2 --> speed detected,
9203 * Bits 13..15--> link is down
9205 if ((link_status
& (1<<2)) && (!(link_status
& (1<<15)))) {
9207 vars
->line_speed
= SPEED_10000
;
9208 DP(NETIF_MSG_LINK
, "port %x: External link up in 10G\n",
9210 } else if ((link_status
& (1<<0)) && (!(link_status
& (1<<13)))) {
9212 vars
->line_speed
= SPEED_1000
;
9213 DP(NETIF_MSG_LINK
, "port %x: External link up in 1G\n",
9217 DP(NETIF_MSG_LINK
, "port %x: External link is down\n",
9221 /* Capture 10G link fault. */
9222 if (vars
->line_speed
== SPEED_10000
) {
9223 bnx2x_cl45_read(bp
, phy
, MDIO_PMA_DEVAD
,
9224 MDIO_PMA_LASI_TXSTAT
, &val1
);
9226 bnx2x_cl45_read(bp
, phy
, MDIO_PMA_DEVAD
,
9227 MDIO_PMA_LASI_TXSTAT
, &val1
);
9229 if (val1
& (1<<0)) {
9230 vars
->fault_detected
= 1;
9235 bnx2x_ext_phy_resolve_fc(phy
, params
, vars
);
9236 vars
->duplex
= DUPLEX_FULL
;
9237 DP(NETIF_MSG_LINK
, "duplex = 0x%x\n", vars
->duplex
);
9240 if ((DUAL_MEDIA(params
)) &&
9241 (phy
->req_line_speed
== SPEED_1000
)) {
9242 bnx2x_cl45_read(bp
, phy
,
9244 MDIO_PMA_REG_8727_PCS_GP
, &val1
);
9246 * In case of dual-media board and 1G, power up the XAUI side,
9247 * otherwise power it down. For 10G it is done automatically
9253 bnx2x_cl45_write(bp
, phy
,
9255 MDIO_PMA_REG_8727_PCS_GP
, val1
);
9260 static void bnx2x_8727_link_reset(struct bnx2x_phy
*phy
,
9261 struct link_params
*params
)
9263 struct bnx2x
*bp
= params
->bp
;
9265 /* Enable/Disable PHY transmitter output */
9266 bnx2x_set_disable_pmd_transmit(params
, phy
, 1);
9268 /* Disable Transmitter */
9269 bnx2x_sfp_set_transmitter(params
, phy
, 0);
9271 bnx2x_cl45_write(bp
, phy
, MDIO_PMA_DEVAD
, MDIO_PMA_LASI_CTRL
, 0);
9275 /******************************************************************/
9276 /* BCM8481/BCM84823/BCM84833 PHY SECTION */
9277 /******************************************************************/
9278 static void bnx2x_save_848xx_spirom_version(struct bnx2x_phy
*phy
,
9282 u16 val
, fw_ver1
, fw_ver2
, cnt
;
9284 if (phy
->type
== PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833
) {
9285 bnx2x_cl45_read(bp
, phy
, MDIO_CTL_DEVAD
, 0x400f, &fw_ver1
);
9286 bnx2x_save_spirom_version(bp
, port
,
9287 ((fw_ver1
& 0xf000)>>5) | (fw_ver1
& 0x7f),
9290 /* For 32-bit registers in 848xx, access via MDIO2ARM i/f. */
9291 /* (1) set reg 0xc200_0014(SPI_BRIDGE_CTRL_2) to 0x03000000 */
9292 bnx2x_cl45_write(bp
, phy
, MDIO_PMA_DEVAD
, 0xA819, 0x0014);
9293 bnx2x_cl45_write(bp
, phy
, MDIO_PMA_DEVAD
, 0xA81A, 0xc200);
9294 bnx2x_cl45_write(bp
, phy
, MDIO_PMA_DEVAD
, 0xA81B, 0x0000);
9295 bnx2x_cl45_write(bp
, phy
, MDIO_PMA_DEVAD
, 0xA81C, 0x0300);
9296 bnx2x_cl45_write(bp
, phy
, MDIO_PMA_DEVAD
, 0xA817, 0x0009);
9298 for (cnt
= 0; cnt
< 100; cnt
++) {
9299 bnx2x_cl45_read(bp
, phy
, MDIO_PMA_DEVAD
, 0xA818, &val
);
9305 DP(NETIF_MSG_LINK
, "Unable to read 848xx "
9306 "phy fw version(1)\n");
9307 bnx2x_save_spirom_version(bp
, port
, 0,
9313 /* 2) read register 0xc200_0000 (SPI_FW_STATUS) */
9314 bnx2x_cl45_write(bp
, phy
, MDIO_PMA_DEVAD
, 0xA819, 0x0000);
9315 bnx2x_cl45_write(bp
, phy
, MDIO_PMA_DEVAD
, 0xA81A, 0xc200);
9316 bnx2x_cl45_write(bp
, phy
, MDIO_PMA_DEVAD
, 0xA817, 0x000A);
9317 for (cnt
= 0; cnt
< 100; cnt
++) {
9318 bnx2x_cl45_read(bp
, phy
, MDIO_PMA_DEVAD
, 0xA818, &val
);
9324 DP(NETIF_MSG_LINK
, "Unable to read 848xx phy fw "
9326 bnx2x_save_spirom_version(bp
, port
, 0,
9331 /* lower 16 bits of the register SPI_FW_STATUS */
9332 bnx2x_cl45_read(bp
, phy
, MDIO_PMA_DEVAD
, 0xA81B, &fw_ver1
);
9333 /* upper 16 bits of register SPI_FW_STATUS */
9334 bnx2x_cl45_read(bp
, phy
, MDIO_PMA_DEVAD
, 0xA81C, &fw_ver2
);
9336 bnx2x_save_spirom_version(bp
, port
, (fw_ver2
<<16) | fw_ver1
,
9341 static void bnx2x_848xx_set_led(struct bnx2x
*bp
,
9342 struct bnx2x_phy
*phy
)
9346 /* PHYC_CTL_LED_CTL */
9347 bnx2x_cl45_read(bp
, phy
,
9349 MDIO_PMA_REG_8481_LINK_SIGNAL
, &val
);
9353 bnx2x_cl45_write(bp
, phy
,
9355 MDIO_PMA_REG_8481_LINK_SIGNAL
, val
);
9357 bnx2x_cl45_write(bp
, phy
,
9359 MDIO_PMA_REG_8481_LED1_MASK
,
9362 bnx2x_cl45_write(bp
, phy
,
9364 MDIO_PMA_REG_8481_LED2_MASK
,
9367 /* Select activity source by Tx and Rx, as suggested by PHY AE */
9368 bnx2x_cl45_write(bp
, phy
,
9370 MDIO_PMA_REG_8481_LED3_MASK
,
9373 /* Select the closest activity blink rate to that in 10/100/1000 */
9374 bnx2x_cl45_write(bp
, phy
,
9376 MDIO_PMA_REG_8481_LED3_BLINK
,
9379 /* Configure the blink rate to ~15.9 Hz */
9380 bnx2x_cl45_write(bp
, phy
,
9382 MDIO_PMA_REG_84823_CTL_SLOW_CLK_CNT_HIGH
,
9383 MDIO_PMA_REG_84823_BLINK_RATE_VAL_15P9HZ
);
9385 if (phy
->type
== PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833
)
9386 offset
= MDIO_PMA_REG_84833_CTL_LED_CTL_1
;
9388 offset
= MDIO_PMA_REG_84823_CTL_LED_CTL_1
;
9390 bnx2x_cl45_read(bp
, phy
,
9391 MDIO_PMA_DEVAD
, offset
, &val
);
9392 val
|= MDIO_PMA_REG_84823_LED3_STRETCH_EN
; /* stretch_en for LED3*/
9393 bnx2x_cl45_write(bp
, phy
,
9394 MDIO_PMA_DEVAD
, offset
, val
);
9396 /* 'Interrupt Mask' */
9397 bnx2x_cl45_write(bp
, phy
,
9402 static int bnx2x_848xx_cmn_config_init(struct bnx2x_phy
*phy
,
9403 struct link_params
*params
,
9404 struct link_vars
*vars
)
9406 struct bnx2x
*bp
= params
->bp
;
9407 u16 autoneg_val
, an_1000_val
, an_10_100_val
, an_10g_val
;
9408 u16 tmp_req_line_speed
;
9410 tmp_req_line_speed
= phy
->req_line_speed
;
9411 if (phy
->type
== PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833
) {
9412 if (phy
->req_line_speed
== SPEED_10000
)
9413 phy
->req_line_speed
= SPEED_AUTO_NEG
;
9415 /* Save spirom version */
9416 bnx2x_save_848xx_spirom_version(phy
, bp
, params
->port
);
9419 * This phy uses the NIG latch mechanism since link indication
9420 * arrives through its LED4 and not via its LASI signal, so we
9421 * get steady signal instead of clear on read
9423 bnx2x_bits_en(bp
, NIG_REG_LATCH_BC_0
+ params
->port
*4,
9424 1 << NIG_LATCH_BC_ENABLE_MI_INT
);
9426 bnx2x_cl45_write(bp
, phy
,
9427 MDIO_PMA_DEVAD
, MDIO_PMA_REG_CTRL
, 0x0000);
9429 bnx2x_848xx_set_led(bp
, phy
);
9431 /* set 1000 speed advertisement */
9432 bnx2x_cl45_read(bp
, phy
,
9433 MDIO_AN_DEVAD
, MDIO_AN_REG_8481_1000T_CTRL
,
9436 bnx2x_ext_phy_set_pause(params
, phy
, vars
);
9437 bnx2x_cl45_read(bp
, phy
,
9439 MDIO_AN_REG_8481_LEGACY_AN_ADV
,
9441 bnx2x_cl45_read(bp
, phy
,
9442 MDIO_AN_DEVAD
, MDIO_AN_REG_8481_LEGACY_MII_CTRL
,
9444 /* Disable forced speed */
9445 autoneg_val
&= ~((1<<6) | (1<<8) | (1<<9) | (1<<12) | (1<<13));
9446 an_10_100_val
&= ~((1<<5) | (1<<6) | (1<<7) | (1<<8));
9448 if (((phy
->req_line_speed
== SPEED_AUTO_NEG
) &&
9449 (phy
->speed_cap_mask
&
9450 PORT_HW_CFG_SPEED_CAPABILITY_D0_1G
)) ||
9451 (phy
->req_line_speed
== SPEED_1000
)) {
9452 an_1000_val
|= (1<<8);
9453 autoneg_val
|= (1<<9 | 1<<12);
9454 if (phy
->req_duplex
== DUPLEX_FULL
)
9455 an_1000_val
|= (1<<9);
9456 DP(NETIF_MSG_LINK
, "Advertising 1G\n");
9458 an_1000_val
&= ~((1<<8) | (1<<9));
9460 bnx2x_cl45_write(bp
, phy
,
9461 MDIO_AN_DEVAD
, MDIO_AN_REG_8481_1000T_CTRL
,
9464 /* set 100 speed advertisement */
9465 if ((phy
->req_line_speed
== SPEED_AUTO_NEG
) &&
9466 (phy
->speed_cap_mask
&
9467 (PORT_HW_CFG_SPEED_CAPABILITY_D0_100M_FULL
|
9468 PORT_HW_CFG_SPEED_CAPABILITY_D0_100M_HALF
))) {
9469 an_10_100_val
|= (1<<7);
9470 /* Enable autoneg and restart autoneg for legacy speeds */
9471 autoneg_val
|= (1<<9 | 1<<12);
9473 if (phy
->req_duplex
== DUPLEX_FULL
)
9474 an_10_100_val
|= (1<<8);
9475 DP(NETIF_MSG_LINK
, "Advertising 100M\n");
9477 /* set 10 speed advertisement */
9478 if (((phy
->req_line_speed
== SPEED_AUTO_NEG
) &&
9479 (phy
->speed_cap_mask
&
9480 (PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_FULL
|
9481 PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_HALF
)) &&
9483 (SUPPORTED_10baseT_Half
|
9484 SUPPORTED_10baseT_Full
)))) {
9485 an_10_100_val
|= (1<<5);
9486 autoneg_val
|= (1<<9 | 1<<12);
9487 if (phy
->req_duplex
== DUPLEX_FULL
)
9488 an_10_100_val
|= (1<<6);
9489 DP(NETIF_MSG_LINK
, "Advertising 10M\n");
9492 /* Only 10/100 are allowed to work in FORCE mode */
9493 if ((phy
->req_line_speed
== SPEED_100
) &&
9495 (SUPPORTED_100baseT_Half
|
9496 SUPPORTED_100baseT_Full
))) {
9497 autoneg_val
|= (1<<13);
9498 /* Enabled AUTO-MDIX when autoneg is disabled */
9499 bnx2x_cl45_write(bp
, phy
,
9500 MDIO_AN_DEVAD
, MDIO_AN_REG_8481_AUX_CTRL
,
9501 (1<<15 | 1<<9 | 7<<0));
9502 /* The PHY needs this set even for forced link. */
9503 an_10_100_val
|= (1<<8) | (1<<7);
9504 DP(NETIF_MSG_LINK
, "Setting 100M force\n");
9506 if ((phy
->req_line_speed
== SPEED_10
) &&
9508 (SUPPORTED_10baseT_Half
|
9509 SUPPORTED_10baseT_Full
))) {
9510 /* Enabled AUTO-MDIX when autoneg is disabled */
9511 bnx2x_cl45_write(bp
, phy
,
9512 MDIO_AN_DEVAD
, MDIO_AN_REG_8481_AUX_CTRL
,
9513 (1<<15 | 1<<9 | 7<<0));
9514 DP(NETIF_MSG_LINK
, "Setting 10M force\n");
9517 bnx2x_cl45_write(bp
, phy
,
9518 MDIO_AN_DEVAD
, MDIO_AN_REG_8481_LEGACY_AN_ADV
,
9521 if (phy
->req_duplex
== DUPLEX_FULL
)
9522 autoneg_val
|= (1<<8);
9525 * Always write this if this is not 84833.
9526 * For 84833, write it only when it's a forced speed.
9528 if ((phy
->type
!= PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833
) ||
9529 ((autoneg_val
& (1<<12)) == 0))
9530 bnx2x_cl45_write(bp
, phy
,
9532 MDIO_AN_REG_8481_LEGACY_MII_CTRL
, autoneg_val
);
9534 if (((phy
->req_line_speed
== SPEED_AUTO_NEG
) &&
9535 (phy
->speed_cap_mask
&
9536 PORT_HW_CFG_SPEED_CAPABILITY_D0_10G
)) ||
9537 (phy
->req_line_speed
== SPEED_10000
)) {
9538 DP(NETIF_MSG_LINK
, "Advertising 10G\n");
9539 /* Restart autoneg for 10G*/
9541 bnx2x_cl45_read(bp
, phy
,
9543 MDIO_AN_REG_8481_10GBASE_T_AN_CTRL
,
9545 bnx2x_cl45_write(bp
, phy
,
9547 MDIO_AN_REG_8481_10GBASE_T_AN_CTRL
,
9548 an_10g_val
| 0x1000);
9549 bnx2x_cl45_write(bp
, phy
,
9550 MDIO_AN_DEVAD
, MDIO_AN_REG_CTRL
,
9553 bnx2x_cl45_write(bp
, phy
,
9555 MDIO_AN_REG_8481_10GBASE_T_AN_CTRL
,
9558 phy
->req_line_speed
= tmp_req_line_speed
;
9563 static int bnx2x_8481_config_init(struct bnx2x_phy
*phy
,
9564 struct link_params
*params
,
9565 struct link_vars
*vars
)
9567 struct bnx2x
*bp
= params
->bp
;
9568 /* Restore normal power mode*/
9569 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_2
,
9570 MISC_REGISTERS_GPIO_OUTPUT_HIGH
, params
->port
);
9573 bnx2x_ext_phy_hw_reset(bp
, params
->port
);
9574 bnx2x_wait_reset_complete(bp
, phy
, params
);
9576 bnx2x_cl45_write(bp
, phy
, MDIO_PMA_DEVAD
, MDIO_PMA_REG_CTRL
, 1<<15);
9577 return bnx2x_848xx_cmn_config_init(phy
, params
, vars
);
9580 #define PHY84833_CMDHDLR_WAIT 300
9581 #define PHY84833_CMDHDLR_MAX_ARGS 5
9582 static int bnx2x_84833_cmd_hdlr(struct bnx2x_phy
*phy
,
9583 struct link_params
*params
,
9589 struct bnx2x
*bp
= params
->bp
;
9590 /* Write CMD_OPEN_OVERRIDE to STATUS reg */
9591 bnx2x_cl45_write(bp
, phy
, MDIO_CTL_DEVAD
,
9592 MDIO_84833_CMD_HDLR_STATUS
,
9593 PHY84833_STATUS_CMD_OPEN_OVERRIDE
);
9594 for (idx
= 0; idx
< PHY84833_CMDHDLR_WAIT
; idx
++) {
9595 bnx2x_cl45_read(bp
, phy
, MDIO_CTL_DEVAD
,
9596 MDIO_84833_CMD_HDLR_STATUS
, &val
);
9597 if (val
== PHY84833_STATUS_CMD_OPEN_FOR_CMDS
)
9601 if (idx
>= PHY84833_CMDHDLR_WAIT
) {
9602 DP(NETIF_MSG_LINK
, "FW cmd: FW not ready.\n");
9606 /* Prepare argument(s) and issue command */
9607 for (idx
= 0; idx
< PHY84833_CMDHDLR_MAX_ARGS
; idx
++) {
9608 bnx2x_cl45_write(bp
, phy
, MDIO_CTL_DEVAD
,
9609 MDIO_84833_CMD_HDLR_DATA1
+ idx
,
9612 bnx2x_cl45_write(bp
, phy
, MDIO_CTL_DEVAD
,
9613 MDIO_84833_CMD_HDLR_COMMAND
, fw_cmd
);
9614 for (idx
= 0; idx
< PHY84833_CMDHDLR_WAIT
; idx
++) {
9615 bnx2x_cl45_read(bp
, phy
, MDIO_CTL_DEVAD
,
9616 MDIO_84833_CMD_HDLR_STATUS
, &val
);
9617 if ((val
== PHY84833_STATUS_CMD_COMPLETE_PASS
) ||
9618 (val
== PHY84833_STATUS_CMD_COMPLETE_ERROR
))
9622 if ((idx
>= PHY84833_CMDHDLR_WAIT
) ||
9623 (val
== PHY84833_STATUS_CMD_COMPLETE_ERROR
)) {
9624 DP(NETIF_MSG_LINK
, "FW cmd failed.\n");
9627 /* Gather returning data */
9628 for (idx
= 0; idx
< PHY84833_CMDHDLR_MAX_ARGS
; idx
++) {
9629 bnx2x_cl45_read(bp
, phy
, MDIO_CTL_DEVAD
,
9630 MDIO_84833_CMD_HDLR_DATA1
+ idx
,
9633 bnx2x_cl45_write(bp
, phy
, MDIO_CTL_DEVAD
,
9634 MDIO_84833_CMD_HDLR_STATUS
,
9635 PHY84833_STATUS_CMD_CLEAR_COMPLETE
);
9640 static int bnx2x_84833_pair_swap_cfg(struct bnx2x_phy
*phy
,
9641 struct link_params
*params
,
9642 struct link_vars
*vars
)
9645 u16 data
[PHY84833_CMDHDLR_MAX_ARGS
];
9647 struct bnx2x
*bp
= params
->bp
;
9649 /* Check for configuration. */
9650 pair_swap
= REG_RD(bp
, params
->shmem_base
+
9651 offsetof(struct shmem_region
,
9652 dev_info
.port_hw_config
[params
->port
].xgbt_phy_cfg
)) &
9653 PORT_HW_CFG_RJ45_PAIR_SWAP_MASK
;
9658 /* Only the second argument is used for this command */
9659 data
[1] = (u16
)pair_swap
;
9661 status
= bnx2x_84833_cmd_hdlr(phy
, params
,
9662 PHY84833_CMD_SET_PAIR_SWAP
, data
);
9664 DP(NETIF_MSG_LINK
, "Pairswap OK, val=0x%x\n", data
[1]);
9669 static u8
bnx2x_84833_get_reset_gpios(struct bnx2x
*bp
,
9670 u32 shmem_base_path
[],
9676 if (CHIP_IS_E3(bp
)) {
9677 /* Assume that these will be GPIOs, not EPIOs. */
9678 for (idx
= 0; idx
< 2; idx
++) {
9679 /* Map config param to register bit. */
9680 reset_pin
[idx
] = REG_RD(bp
, shmem_base_path
[idx
] +
9681 offsetof(struct shmem_region
,
9682 dev_info
.port_hw_config
[0].e3_cmn_pin_cfg
));
9683 reset_pin
[idx
] = (reset_pin
[idx
] &
9684 PORT_HW_CFG_E3_PHY_RESET_MASK
) >>
9685 PORT_HW_CFG_E3_PHY_RESET_SHIFT
;
9686 reset_pin
[idx
] -= PIN_CFG_GPIO0_P0
;
9687 reset_pin
[idx
] = (1 << reset_pin
[idx
]);
9689 reset_gpios
= (u8
)(reset_pin
[0] | reset_pin
[1]);
9691 /* E2, look from diff place of shmem. */
9692 for (idx
= 0; idx
< 2; idx
++) {
9693 reset_pin
[idx
] = REG_RD(bp
, shmem_base_path
[idx
] +
9694 offsetof(struct shmem_region
,
9695 dev_info
.port_hw_config
[0].default_cfg
));
9696 reset_pin
[idx
] &= PORT_HW_CFG_EXT_PHY_GPIO_RST_MASK
;
9697 reset_pin
[idx
] -= PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO0_P0
;
9698 reset_pin
[idx
] >>= PORT_HW_CFG_EXT_PHY_GPIO_RST_SHIFT
;
9699 reset_pin
[idx
] = (1 << reset_pin
[idx
]);
9701 reset_gpios
= (u8
)(reset_pin
[0] | reset_pin
[1]);
9707 static int bnx2x_84833_hw_reset_phy(struct bnx2x_phy
*phy
,
9708 struct link_params
*params
)
9710 struct bnx2x
*bp
= params
->bp
;
9712 u32 other_shmem_base_addr
= REG_RD(bp
, params
->shmem2_base
+
9713 offsetof(struct shmem2_region
,
9714 other_shmem_base_addr
));
9716 u32 shmem_base_path
[2];
9717 shmem_base_path
[0] = params
->shmem_base
;
9718 shmem_base_path
[1] = other_shmem_base_addr
;
9720 reset_gpios
= bnx2x_84833_get_reset_gpios(bp
, shmem_base_path
,
9723 bnx2x_set_mult_gpio(bp
, reset_gpios
, MISC_REGISTERS_GPIO_OUTPUT_LOW
);
9725 DP(NETIF_MSG_LINK
, "84833 hw reset on pin values 0x%x\n",
9731 #define PHY84833_CONSTANT_LATENCY 1193
9732 static int bnx2x_848x3_config_init(struct bnx2x_phy
*phy
,
9733 struct link_params
*params
,
9734 struct link_vars
*vars
)
9736 struct bnx2x
*bp
= params
->bp
;
9737 u8 port
, initialize
= 1;
9739 u32 actual_phy_selection
, cms_enable
;
9740 u16 cmd_args
[PHY84833_CMDHDLR_MAX_ARGS
];
9745 if (!(CHIP_IS_E1(bp
)))
9748 port
= params
->port
;
9750 if (phy
->type
== PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84823
) {
9751 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_3
,
9752 MISC_REGISTERS_GPIO_OUTPUT_HIGH
,
9756 bnx2x_cl45_write(bp
, phy
,
9758 MDIO_PMA_REG_CTRL
, 0x8000);
9761 bnx2x_wait_reset_complete(bp
, phy
, params
);
9763 /* Wait for GPHY to come out of reset */
9765 if (phy
->type
!= PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833
) {
9767 * BCM84823 requires that XGXS links up first @ 10G for normal
9771 temp
= vars
->line_speed
;
9772 vars
->line_speed
= SPEED_10000
;
9773 bnx2x_set_autoneg(¶ms
->phy
[INT_PHY
], params
, vars
, 0);
9774 bnx2x_program_serdes(¶ms
->phy
[INT_PHY
], params
, vars
);
9775 vars
->line_speed
= temp
;
9778 bnx2x_cl45_read(bp
, phy
, MDIO_CTL_DEVAD
,
9779 MDIO_CTL_REG_84823_MEDIA
, &val
);
9780 val
&= ~(MDIO_CTL_REG_84823_MEDIA_MAC_MASK
|
9781 MDIO_CTL_REG_84823_MEDIA_LINE_MASK
|
9782 MDIO_CTL_REG_84823_MEDIA_COPPER_CORE_DOWN
|
9783 MDIO_CTL_REG_84823_MEDIA_PRIORITY_MASK
|
9784 MDIO_CTL_REG_84823_MEDIA_FIBER_1G
);
9786 if (CHIP_IS_E3(bp
)) {
9787 val
&= ~(MDIO_CTL_REG_84823_MEDIA_MAC_MASK
|
9788 MDIO_CTL_REG_84823_MEDIA_LINE_MASK
);
9790 val
|= (MDIO_CTL_REG_84823_CTRL_MAC_XFI
|
9791 MDIO_CTL_REG_84823_MEDIA_LINE_XAUI_L
);
9794 actual_phy_selection
= bnx2x_phy_selection(params
);
9796 switch (actual_phy_selection
) {
9797 case PORT_HW_CFG_PHY_SELECTION_HARDWARE_DEFAULT
:
9798 /* Do nothing. Essentially this is like the priority copper */
9800 case PORT_HW_CFG_PHY_SELECTION_FIRST_PHY_PRIORITY
:
9801 val
|= MDIO_CTL_REG_84823_MEDIA_PRIORITY_COPPER
;
9803 case PORT_HW_CFG_PHY_SELECTION_SECOND_PHY_PRIORITY
:
9804 val
|= MDIO_CTL_REG_84823_MEDIA_PRIORITY_FIBER
;
9806 case PORT_HW_CFG_PHY_SELECTION_FIRST_PHY
:
9807 /* Do nothing here. The first PHY won't be initialized at all */
9809 case PORT_HW_CFG_PHY_SELECTION_SECOND_PHY
:
9810 val
|= MDIO_CTL_REG_84823_MEDIA_COPPER_CORE_DOWN
;
9814 if (params
->phy
[EXT_PHY2
].req_line_speed
== SPEED_1000
)
9815 val
|= MDIO_CTL_REG_84823_MEDIA_FIBER_1G
;
9817 bnx2x_cl45_write(bp
, phy
, MDIO_CTL_DEVAD
,
9818 MDIO_CTL_REG_84823_MEDIA
, val
);
9819 DP(NETIF_MSG_LINK
, "Multi_phy config = 0x%x, Media control = 0x%x\n",
9820 params
->multi_phy_config
, val
);
9822 if (phy
->type
== PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833
) {
9823 bnx2x_84833_pair_swap_cfg(phy
, params
, vars
);
9825 /* Keep AutogrEEEn disabled. */
9828 cmd_args
[2] = PHY84833_CONSTANT_LATENCY
+ 1;
9829 cmd_args
[3] = PHY84833_CONSTANT_LATENCY
;
9830 rc
= bnx2x_84833_cmd_hdlr(phy
, params
,
9831 PHY84833_CMD_SET_EEE_MODE
, cmd_args
);
9833 DP(NETIF_MSG_LINK
, "Cfg AutogrEEEn failed.\n");
9836 rc
= bnx2x_848xx_cmn_config_init(phy
, params
, vars
);
9838 bnx2x_save_848xx_spirom_version(phy
, bp
, params
->port
);
9839 /* 84833 PHY has a better feature and doesn't need to support this. */
9840 if (phy
->type
== PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84823
) {
9841 cms_enable
= REG_RD(bp
, params
->shmem_base
+
9842 offsetof(struct shmem_region
,
9843 dev_info
.port_hw_config
[params
->port
].default_cfg
)) &
9844 PORT_HW_CFG_ENABLE_CMS_MASK
;
9846 bnx2x_cl45_read(bp
, phy
, MDIO_CTL_DEVAD
,
9847 MDIO_CTL_REG_84823_USER_CTRL_REG
, &val
);
9849 val
|= MDIO_CTL_REG_84823_USER_CTRL_CMS
;
9851 val
&= ~MDIO_CTL_REG_84823_USER_CTRL_CMS
;
9852 bnx2x_cl45_write(bp
, phy
, MDIO_CTL_DEVAD
,
9853 MDIO_CTL_REG_84823_USER_CTRL_REG
, val
);
9856 if (phy
->type
== PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833
) {
9857 /* Bring PHY out of super isolate mode as the final step. */
9858 bnx2x_cl45_read(bp
, phy
,
9860 MDIO_84833_TOP_CFG_XGPHY_STRAP1
, &val
);
9861 val
&= ~MDIO_84833_SUPER_ISOLATE
;
9862 bnx2x_cl45_write(bp
, phy
,
9864 MDIO_84833_TOP_CFG_XGPHY_STRAP1
, val
);
9869 static u8
bnx2x_848xx_read_status(struct bnx2x_phy
*phy
,
9870 struct link_params
*params
,
9871 struct link_vars
*vars
)
9873 struct bnx2x
*bp
= params
->bp
;
9874 u16 val
, val1
, val2
;
9878 /* Check 10G-BaseT link status */
9879 /* Check PMD signal ok */
9880 bnx2x_cl45_read(bp
, phy
,
9881 MDIO_AN_DEVAD
, 0xFFFA, &val1
);
9882 bnx2x_cl45_read(bp
, phy
,
9883 MDIO_PMA_DEVAD
, MDIO_PMA_REG_8481_PMD_SIGNAL
,
9885 DP(NETIF_MSG_LINK
, "BCM848xx: PMD_SIGNAL 1.a811 = 0x%x\n", val2
);
9887 /* Check link 10G */
9888 if (val2
& (1<<11)) {
9889 vars
->line_speed
= SPEED_10000
;
9890 vars
->duplex
= DUPLEX_FULL
;
9892 bnx2x_ext_phy_10G_an_resolve(bp
, phy
, vars
);
9893 } else { /* Check Legacy speed link */
9894 u16 legacy_status
, legacy_speed
;
9896 /* Enable expansion register 0x42 (Operation mode status) */
9897 bnx2x_cl45_write(bp
, phy
,
9899 MDIO_AN_REG_8481_EXPANSION_REG_ACCESS
, 0xf42);
9901 /* Get legacy speed operation status */
9902 bnx2x_cl45_read(bp
, phy
,
9904 MDIO_AN_REG_8481_EXPANSION_REG_RD_RW
,
9907 DP(NETIF_MSG_LINK
, "Legacy speed status = 0x%x\n",
9909 link_up
= ((legacy_status
& (1<<11)) == (1<<11));
9911 legacy_speed
= (legacy_status
& (3<<9));
9912 if (legacy_speed
== (0<<9))
9913 vars
->line_speed
= SPEED_10
;
9914 else if (legacy_speed
== (1<<9))
9915 vars
->line_speed
= SPEED_100
;
9916 else if (legacy_speed
== (2<<9))
9917 vars
->line_speed
= SPEED_1000
;
9918 else /* Should not happen */
9919 vars
->line_speed
= 0;
9921 if (legacy_status
& (1<<8))
9922 vars
->duplex
= DUPLEX_FULL
;
9924 vars
->duplex
= DUPLEX_HALF
;
9927 "Link is up in %dMbps, is_duplex_full= %d\n",
9929 (vars
->duplex
== DUPLEX_FULL
));
9930 /* Check legacy speed AN resolution */
9931 bnx2x_cl45_read(bp
, phy
,
9933 MDIO_AN_REG_8481_LEGACY_MII_STATUS
,
9936 vars
->link_status
|=
9937 LINK_STATUS_AUTO_NEGOTIATE_COMPLETE
;
9938 bnx2x_cl45_read(bp
, phy
,
9940 MDIO_AN_REG_8481_LEGACY_AN_EXPANSION
,
9942 if ((val
& (1<<0)) == 0)
9943 vars
->link_status
|=
9944 LINK_STATUS_PARALLEL_DETECTION_USED
;
9948 DP(NETIF_MSG_LINK
, "BCM84823: link speed is %d\n",
9950 bnx2x_ext_phy_resolve_fc(phy
, params
, vars
);
9957 static int bnx2x_848xx_format_ver(u32 raw_ver
, u8
*str
, u16
*len
)
9961 spirom_ver
= ((raw_ver
& 0xF80) >> 7) << 16 | (raw_ver
& 0x7F);
9962 status
= bnx2x_format_ver(spirom_ver
, str
, len
);
9966 static void bnx2x_8481_hw_reset(struct bnx2x_phy
*phy
,
9967 struct link_params
*params
)
9969 bnx2x_set_gpio(params
->bp
, MISC_REGISTERS_GPIO_1
,
9970 MISC_REGISTERS_GPIO_OUTPUT_LOW
, 0);
9971 bnx2x_set_gpio(params
->bp
, MISC_REGISTERS_GPIO_1
,
9972 MISC_REGISTERS_GPIO_OUTPUT_LOW
, 1);
9975 static void bnx2x_8481_link_reset(struct bnx2x_phy
*phy
,
9976 struct link_params
*params
)
9978 bnx2x_cl45_write(params
->bp
, phy
,
9979 MDIO_AN_DEVAD
, MDIO_AN_REG_CTRL
, 0x0000);
9980 bnx2x_cl45_write(params
->bp
, phy
,
9981 MDIO_PMA_DEVAD
, MDIO_PMA_REG_CTRL
, 1);
9984 static void bnx2x_848x3_link_reset(struct bnx2x_phy
*phy
,
9985 struct link_params
*params
)
9987 struct bnx2x
*bp
= params
->bp
;
9991 if (!(CHIP_IS_E1(bp
)))
9994 port
= params
->port
;
9996 if (phy
->type
== PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84823
) {
9997 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_3
,
9998 MISC_REGISTERS_GPIO_OUTPUT_LOW
,
10001 bnx2x_cl45_read(bp
, phy
,
10003 MDIO_84833_TOP_CFG_XGPHY_STRAP1
, &val16
);
10004 val16
|= MDIO_84833_SUPER_ISOLATE
;
10005 bnx2x_cl45_write(bp
, phy
,
10007 MDIO_84833_TOP_CFG_XGPHY_STRAP1
, val16
);
10011 static void bnx2x_848xx_set_link_led(struct bnx2x_phy
*phy
,
10012 struct link_params
*params
, u8 mode
)
10014 struct bnx2x
*bp
= params
->bp
;
10018 if (!(CHIP_IS_E1(bp
)))
10019 port
= BP_PATH(bp
);
10021 port
= params
->port
;
10026 DP(NETIF_MSG_LINK
, "Port 0x%x: LED MODE OFF\n", port
);
10028 if ((params
->hw_led_mode
<< SHARED_HW_CFG_LED_MODE_SHIFT
) ==
10029 SHARED_HW_CFG_LED_EXTPHY1
) {
10031 /* Set LED masks */
10032 bnx2x_cl45_write(bp
, phy
,
10034 MDIO_PMA_REG_8481_LED1_MASK
,
10037 bnx2x_cl45_write(bp
, phy
,
10039 MDIO_PMA_REG_8481_LED2_MASK
,
10042 bnx2x_cl45_write(bp
, phy
,
10044 MDIO_PMA_REG_8481_LED3_MASK
,
10047 bnx2x_cl45_write(bp
, phy
,
10049 MDIO_PMA_REG_8481_LED5_MASK
,
10053 bnx2x_cl45_write(bp
, phy
,
10055 MDIO_PMA_REG_8481_LED1_MASK
,
10059 case LED_MODE_FRONT_PANEL_OFF
:
10061 DP(NETIF_MSG_LINK
, "Port 0x%x: LED MODE FRONT PANEL OFF\n",
10064 if ((params
->hw_led_mode
<< SHARED_HW_CFG_LED_MODE_SHIFT
) ==
10065 SHARED_HW_CFG_LED_EXTPHY1
) {
10067 /* Set LED masks */
10068 bnx2x_cl45_write(bp
, phy
,
10070 MDIO_PMA_REG_8481_LED1_MASK
,
10073 bnx2x_cl45_write(bp
, phy
,
10075 MDIO_PMA_REG_8481_LED2_MASK
,
10078 bnx2x_cl45_write(bp
, phy
,
10080 MDIO_PMA_REG_8481_LED3_MASK
,
10083 bnx2x_cl45_write(bp
, phy
,
10085 MDIO_PMA_REG_8481_LED5_MASK
,
10089 bnx2x_cl45_write(bp
, phy
,
10091 MDIO_PMA_REG_8481_LED1_MASK
,
10097 DP(NETIF_MSG_LINK
, "Port 0x%x: LED MODE ON\n", port
);
10099 if ((params
->hw_led_mode
<< SHARED_HW_CFG_LED_MODE_SHIFT
) ==
10100 SHARED_HW_CFG_LED_EXTPHY1
) {
10101 /* Set control reg */
10102 bnx2x_cl45_read(bp
, phy
,
10104 MDIO_PMA_REG_8481_LINK_SIGNAL
,
10109 bnx2x_cl45_write(bp
, phy
,
10111 MDIO_PMA_REG_8481_LINK_SIGNAL
,
10114 /* Set LED masks */
10115 bnx2x_cl45_write(bp
, phy
,
10117 MDIO_PMA_REG_8481_LED1_MASK
,
10120 bnx2x_cl45_write(bp
, phy
,
10122 MDIO_PMA_REG_8481_LED2_MASK
,
10125 bnx2x_cl45_write(bp
, phy
,
10127 MDIO_PMA_REG_8481_LED3_MASK
,
10130 bnx2x_cl45_write(bp
, phy
,
10132 MDIO_PMA_REG_8481_LED5_MASK
,
10135 bnx2x_cl45_write(bp
, phy
,
10137 MDIO_PMA_REG_8481_LED1_MASK
,
10142 case LED_MODE_OPER
:
10144 DP(NETIF_MSG_LINK
, "Port 0x%x: LED MODE OPER\n", port
);
10146 if ((params
->hw_led_mode
<< SHARED_HW_CFG_LED_MODE_SHIFT
) ==
10147 SHARED_HW_CFG_LED_EXTPHY1
) {
10149 /* Set control reg */
10150 bnx2x_cl45_read(bp
, phy
,
10152 MDIO_PMA_REG_8481_LINK_SIGNAL
,
10156 MDIO_PMA_REG_8481_LINK_SIGNAL_LED4_ENABLE_MASK
)
10157 >> MDIO_PMA_REG_8481_LINK_SIGNAL_LED4_ENABLE_SHIFT
)) {
10158 DP(NETIF_MSG_LINK
, "Setting LINK_SIGNAL\n");
10159 bnx2x_cl45_write(bp
, phy
,
10161 MDIO_PMA_REG_8481_LINK_SIGNAL
,
10165 /* Set LED masks */
10166 bnx2x_cl45_write(bp
, phy
,
10168 MDIO_PMA_REG_8481_LED1_MASK
,
10171 bnx2x_cl45_write(bp
, phy
,
10173 MDIO_PMA_REG_8481_LED2_MASK
,
10176 bnx2x_cl45_write(bp
, phy
,
10178 MDIO_PMA_REG_8481_LED3_MASK
,
10181 bnx2x_cl45_write(bp
, phy
,
10183 MDIO_PMA_REG_8481_LED5_MASK
,
10187 bnx2x_cl45_write(bp
, phy
,
10189 MDIO_PMA_REG_8481_LED1_MASK
,
10192 /* Tell LED3 to blink on source */
10193 bnx2x_cl45_read(bp
, phy
,
10195 MDIO_PMA_REG_8481_LINK_SIGNAL
,
10198 val
|= (1<<6); /* A83B[8:6]= 1 */
10199 bnx2x_cl45_write(bp
, phy
,
10201 MDIO_PMA_REG_8481_LINK_SIGNAL
,
10208 * This is a workaround for E3+84833 until autoneg
10209 * restart is fixed in f/w
10211 if (CHIP_IS_E3(bp
)) {
10212 bnx2x_cl45_read(bp
, phy
, MDIO_WC_DEVAD
,
10213 MDIO_WC_REG_GP2_STATUS_GP_2_1
, &val
);
10217 /******************************************************************/
10218 /* 54618SE PHY SECTION */
10219 /******************************************************************/
10220 static int bnx2x_54618se_config_init(struct bnx2x_phy
*phy
,
10221 struct link_params
*params
,
10222 struct link_vars
*vars
)
10224 struct bnx2x
*bp
= params
->bp
;
10226 u16 autoneg_val
, an_1000_val
, an_10_100_val
, fc_val
, temp
;
10229 DP(NETIF_MSG_LINK
, "54618SE cfg init\n");
10230 usleep_range(1000, 1000);
10233 * This works with E3 only, no need to check the chip
10234 * before determining the port.
10236 port
= params
->port
;
10238 cfg_pin
= (REG_RD(bp
, params
->shmem_base
+
10239 offsetof(struct shmem_region
,
10240 dev_info
.port_hw_config
[port
].e3_cmn_pin_cfg
)) &
10241 PORT_HW_CFG_E3_PHY_RESET_MASK
) >>
10242 PORT_HW_CFG_E3_PHY_RESET_SHIFT
;
10244 /* Drive pin high to bring the GPHY out of reset. */
10245 bnx2x_set_cfg_pin(bp
, cfg_pin
, 1);
10247 /* wait for GPHY to reset */
10251 bnx2x_cl22_write(bp
, phy
,
10252 MDIO_PMA_REG_CTRL
, 0x8000);
10253 bnx2x_wait_reset_complete(bp
, phy
, params
);
10255 /*wait for GPHY to reset */
10258 /* Configure LED4: set to INTR (0x6). */
10259 /* Accessing shadow register 0xe. */
10260 bnx2x_cl22_write(bp
, phy
,
10261 MDIO_REG_GPHY_SHADOW
,
10262 MDIO_REG_GPHY_SHADOW_LED_SEL2
);
10263 bnx2x_cl22_read(bp
, phy
,
10264 MDIO_REG_GPHY_SHADOW
,
10266 temp
&= ~(0xf << 4);
10267 temp
|= (0x6 << 4);
10268 bnx2x_cl22_write(bp
, phy
,
10269 MDIO_REG_GPHY_SHADOW
,
10270 MDIO_REG_GPHY_SHADOW_WR_ENA
| temp
);
10271 /* Configure INTR based on link status change. */
10272 bnx2x_cl22_write(bp
, phy
,
10273 MDIO_REG_INTR_MASK
,
10274 ~MDIO_REG_INTR_MASK_LINK_STATUS
);
10276 /* Flip the signal detect polarity (set 0x1c.0x1e[8]). */
10277 bnx2x_cl22_write(bp
, phy
,
10278 MDIO_REG_GPHY_SHADOW
,
10279 MDIO_REG_GPHY_SHADOW_AUTO_DET_MED
);
10280 bnx2x_cl22_read(bp
, phy
,
10281 MDIO_REG_GPHY_SHADOW
,
10283 temp
|= MDIO_REG_GPHY_SHADOW_INVERT_FIB_SD
;
10284 bnx2x_cl22_write(bp
, phy
,
10285 MDIO_REG_GPHY_SHADOW
,
10286 MDIO_REG_GPHY_SHADOW_WR_ENA
| temp
);
10289 /* Please refer to Table 28B-3 of 802.3ab-1999 spec. */
10290 bnx2x_calc_ieee_aneg_adv(phy
, params
, &vars
->ieee_fc
);
10292 if ((vars
->ieee_fc
& MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC
) ==
10293 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC
)
10294 fc_val
|= MDIO_AN_REG_ADV_PAUSE_ASYMMETRIC
;
10296 if ((vars
->ieee_fc
& MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH
) ==
10297 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH
)
10298 fc_val
|= MDIO_AN_REG_ADV_PAUSE_PAUSE
;
10300 /* read all advertisement */
10301 bnx2x_cl22_read(bp
, phy
,
10305 bnx2x_cl22_read(bp
, phy
,
10309 bnx2x_cl22_read(bp
, phy
,
10313 /* Disable forced speed */
10314 autoneg_val
&= ~((1<<6) | (1<<8) | (1<<9) | (1<<12) | (1<<13));
10315 an_10_100_val
&= ~((1<<5) | (1<<6) | (1<<7) | (1<<8) | (1<<10) |
10318 if (((phy
->req_line_speed
== SPEED_AUTO_NEG
) &&
10319 (phy
->speed_cap_mask
&
10320 PORT_HW_CFG_SPEED_CAPABILITY_D0_1G
)) ||
10321 (phy
->req_line_speed
== SPEED_1000
)) {
10322 an_1000_val
|= (1<<8);
10323 autoneg_val
|= (1<<9 | 1<<12);
10324 if (phy
->req_duplex
== DUPLEX_FULL
)
10325 an_1000_val
|= (1<<9);
10326 DP(NETIF_MSG_LINK
, "Advertising 1G\n");
10328 an_1000_val
&= ~((1<<8) | (1<<9));
10330 bnx2x_cl22_write(bp
, phy
,
10333 bnx2x_cl22_read(bp
, phy
,
10337 /* set 100 speed advertisement */
10338 if (((phy
->req_line_speed
== SPEED_AUTO_NEG
) &&
10339 (phy
->speed_cap_mask
&
10340 (PORT_HW_CFG_SPEED_CAPABILITY_D0_100M_FULL
|
10341 PORT_HW_CFG_SPEED_CAPABILITY_D0_100M_HALF
)))) {
10342 an_10_100_val
|= (1<<7);
10343 /* Enable autoneg and restart autoneg for legacy speeds */
10344 autoneg_val
|= (1<<9 | 1<<12);
10346 if (phy
->req_duplex
== DUPLEX_FULL
)
10347 an_10_100_val
|= (1<<8);
10348 DP(NETIF_MSG_LINK
, "Advertising 100M\n");
10351 /* set 10 speed advertisement */
10352 if (((phy
->req_line_speed
== SPEED_AUTO_NEG
) &&
10353 (phy
->speed_cap_mask
&
10354 (PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_FULL
|
10355 PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_HALF
)))) {
10356 an_10_100_val
|= (1<<5);
10357 autoneg_val
|= (1<<9 | 1<<12);
10358 if (phy
->req_duplex
== DUPLEX_FULL
)
10359 an_10_100_val
|= (1<<6);
10360 DP(NETIF_MSG_LINK
, "Advertising 10M\n");
10363 /* Only 10/100 are allowed to work in FORCE mode */
10364 if (phy
->req_line_speed
== SPEED_100
) {
10365 autoneg_val
|= (1<<13);
10366 /* Enabled AUTO-MDIX when autoneg is disabled */
10367 bnx2x_cl22_write(bp
, phy
,
10369 (1<<15 | 1<<9 | 7<<0));
10370 DP(NETIF_MSG_LINK
, "Setting 100M force\n");
10372 if (phy
->req_line_speed
== SPEED_10
) {
10373 /* Enabled AUTO-MDIX when autoneg is disabled */
10374 bnx2x_cl22_write(bp
, phy
,
10376 (1<<15 | 1<<9 | 7<<0));
10377 DP(NETIF_MSG_LINK
, "Setting 10M force\n");
10380 /* Check if we should turn on Auto-GrEEEn */
10381 bnx2x_cl22_read(bp
, phy
, MDIO_REG_GPHY_PHYID_LSB
, &temp
);
10382 if (temp
== MDIO_REG_GPHY_ID_54618SE
) {
10383 if (params
->feature_config_flags
&
10384 FEATURE_CONFIG_AUTOGREEEN_ENABLED
) {
10386 DP(NETIF_MSG_LINK
, "Enabling Auto-GrEEEn\n");
10389 DP(NETIF_MSG_LINK
, "Disabling Auto-GrEEEn\n");
10391 bnx2x_cl22_write(bp
, phy
,
10392 MDIO_REG_GPHY_CL45_ADDR_REG
, MDIO_AN_DEVAD
);
10393 bnx2x_cl22_write(bp
, phy
,
10394 MDIO_REG_GPHY_CL45_DATA_REG
,
10395 MDIO_REG_GPHY_EEE_ADV
);
10396 bnx2x_cl22_write(bp
, phy
,
10397 MDIO_REG_GPHY_CL45_ADDR_REG
,
10398 (0x1 << 14) | MDIO_AN_DEVAD
);
10399 bnx2x_cl22_write(bp
, phy
,
10400 MDIO_REG_GPHY_CL45_DATA_REG
,
10404 bnx2x_cl22_write(bp
, phy
,
10406 an_10_100_val
| fc_val
);
10408 if (phy
->req_duplex
== DUPLEX_FULL
)
10409 autoneg_val
|= (1<<8);
10411 bnx2x_cl22_write(bp
, phy
,
10412 MDIO_PMA_REG_CTRL
, autoneg_val
);
10418 static void bnx2x_5461x_set_link_led(struct bnx2x_phy
*phy
,
10419 struct link_params
*params
, u8 mode
)
10421 struct bnx2x
*bp
= params
->bp
;
10424 bnx2x_cl22_write(bp
, phy
,
10425 MDIO_REG_GPHY_SHADOW
,
10426 MDIO_REG_GPHY_SHADOW_LED_SEL1
);
10427 bnx2x_cl22_read(bp
, phy
,
10428 MDIO_REG_GPHY_SHADOW
,
10432 DP(NETIF_MSG_LINK
, "54618x set link led (mode=%x)\n", mode
);
10434 case LED_MODE_FRONT_PANEL_OFF
:
10438 case LED_MODE_OPER
:
10447 bnx2x_cl22_write(bp
, phy
,
10448 MDIO_REG_GPHY_SHADOW
,
10449 MDIO_REG_GPHY_SHADOW_WR_ENA
| temp
);
10454 static void bnx2x_54618se_link_reset(struct bnx2x_phy
*phy
,
10455 struct link_params
*params
)
10457 struct bnx2x
*bp
= params
->bp
;
10462 * In case of no EPIO routed to reset the GPHY, put it
10463 * in low power mode.
10465 bnx2x_cl22_write(bp
, phy
, MDIO_PMA_REG_CTRL
, 0x800);
10467 * This works with E3 only, no need to check the chip
10468 * before determining the port.
10470 port
= params
->port
;
10471 cfg_pin
= (REG_RD(bp
, params
->shmem_base
+
10472 offsetof(struct shmem_region
,
10473 dev_info
.port_hw_config
[port
].e3_cmn_pin_cfg
)) &
10474 PORT_HW_CFG_E3_PHY_RESET_MASK
) >>
10475 PORT_HW_CFG_E3_PHY_RESET_SHIFT
;
10477 /* Drive pin low to put GPHY in reset. */
10478 bnx2x_set_cfg_pin(bp
, cfg_pin
, 0);
10481 static u8
bnx2x_54618se_read_status(struct bnx2x_phy
*phy
,
10482 struct link_params
*params
,
10483 struct link_vars
*vars
)
10485 struct bnx2x
*bp
= params
->bp
;
10488 u16 legacy_status
, legacy_speed
;
10490 /* Get speed operation status */
10491 bnx2x_cl22_read(bp
, phy
,
10494 DP(NETIF_MSG_LINK
, "54618SE read_status: 0x%x\n", legacy_status
);
10496 /* Read status to clear the PHY interrupt. */
10497 bnx2x_cl22_read(bp
, phy
,
10498 MDIO_REG_INTR_STATUS
,
10501 link_up
= ((legacy_status
& (1<<2)) == (1<<2));
10504 legacy_speed
= (legacy_status
& (7<<8));
10505 if (legacy_speed
== (7<<8)) {
10506 vars
->line_speed
= SPEED_1000
;
10507 vars
->duplex
= DUPLEX_FULL
;
10508 } else if (legacy_speed
== (6<<8)) {
10509 vars
->line_speed
= SPEED_1000
;
10510 vars
->duplex
= DUPLEX_HALF
;
10511 } else if (legacy_speed
== (5<<8)) {
10512 vars
->line_speed
= SPEED_100
;
10513 vars
->duplex
= DUPLEX_FULL
;
10515 /* Omitting 100Base-T4 for now */
10516 else if (legacy_speed
== (3<<8)) {
10517 vars
->line_speed
= SPEED_100
;
10518 vars
->duplex
= DUPLEX_HALF
;
10519 } else if (legacy_speed
== (2<<8)) {
10520 vars
->line_speed
= SPEED_10
;
10521 vars
->duplex
= DUPLEX_FULL
;
10522 } else if (legacy_speed
== (1<<8)) {
10523 vars
->line_speed
= SPEED_10
;
10524 vars
->duplex
= DUPLEX_HALF
;
10525 } else /* Should not happen */
10526 vars
->line_speed
= 0;
10529 "Link is up in %dMbps, is_duplex_full= %d\n",
10531 (vars
->duplex
== DUPLEX_FULL
));
10533 /* Check legacy speed AN resolution */
10534 bnx2x_cl22_read(bp
, phy
,
10538 vars
->link_status
|=
10539 LINK_STATUS_AUTO_NEGOTIATE_COMPLETE
;
10540 bnx2x_cl22_read(bp
, phy
,
10543 if ((val
& (1<<0)) == 0)
10544 vars
->link_status
|=
10545 LINK_STATUS_PARALLEL_DETECTION_USED
;
10547 DP(NETIF_MSG_LINK
, "BCM54618SE: link speed is %d\n",
10550 /* Report whether EEE is resolved. */
10551 bnx2x_cl22_read(bp
, phy
, MDIO_REG_GPHY_PHYID_LSB
, &val
);
10552 if (val
== MDIO_REG_GPHY_ID_54618SE
) {
10553 if (vars
->link_status
&
10554 LINK_STATUS_AUTO_NEGOTIATE_COMPLETE
)
10557 bnx2x_cl22_write(bp
, phy
,
10558 MDIO_REG_GPHY_CL45_ADDR_REG
,
10560 bnx2x_cl22_write(bp
, phy
,
10561 MDIO_REG_GPHY_CL45_DATA_REG
,
10562 MDIO_REG_GPHY_EEE_RESOLVED
);
10563 bnx2x_cl22_write(bp
, phy
,
10564 MDIO_REG_GPHY_CL45_ADDR_REG
,
10565 (0x1 << 14) | MDIO_AN_DEVAD
);
10566 bnx2x_cl22_read(bp
, phy
,
10567 MDIO_REG_GPHY_CL45_DATA_REG
,
10570 DP(NETIF_MSG_LINK
, "EEE resolution: 0x%x\n", val
);
10573 bnx2x_ext_phy_resolve_fc(phy
, params
, vars
);
10578 static void bnx2x_54618se_config_loopback(struct bnx2x_phy
*phy
,
10579 struct link_params
*params
)
10581 struct bnx2x
*bp
= params
->bp
;
10583 u32 umac_base
= params
->port
? GRCBASE_UMAC1
: GRCBASE_UMAC0
;
10585 DP(NETIF_MSG_LINK
, "2PMA/PMD ext_phy_loopback: 54618se\n");
10587 /* Enable master/slave manual mmode and set to master */
10588 /* mii write 9 [bits set 11 12] */
10589 bnx2x_cl22_write(bp
, phy
, 0x09, 3<<11);
10591 /* forced 1G and disable autoneg */
10592 /* set val [mii read 0] */
10593 /* set val [expr $val & [bits clear 6 12 13]] */
10594 /* set val [expr $val | [bits set 6 8]] */
10595 /* mii write 0 $val */
10596 bnx2x_cl22_read(bp
, phy
, 0x00, &val
);
10597 val
&= ~((1<<6) | (1<<12) | (1<<13));
10598 val
|= (1<<6) | (1<<8);
10599 bnx2x_cl22_write(bp
, phy
, 0x00, val
);
10601 /* Set external loopback and Tx using 6dB coding */
10602 /* mii write 0x18 7 */
10603 /* set val [mii read 0x18] */
10604 /* mii write 0x18 [expr $val | [bits set 10 15]] */
10605 bnx2x_cl22_write(bp
, phy
, 0x18, 7);
10606 bnx2x_cl22_read(bp
, phy
, 0x18, &val
);
10607 bnx2x_cl22_write(bp
, phy
, 0x18, val
| (1<<10) | (1<<15));
10609 /* This register opens the gate for the UMAC despite its name */
10610 REG_WR(bp
, NIG_REG_EGRESS_EMAC0_PORT
+ params
->port
*4, 1);
10613 * Maximum Frame Length (RW). Defines a 14-Bit maximum frame
10614 * length used by the MAC receive logic to check frames.
10616 REG_WR(bp
, umac_base
+ UMAC_REG_MAXFR
, 0x2710);
10619 /******************************************************************/
10620 /* SFX7101 PHY SECTION */
10621 /******************************************************************/
10622 static void bnx2x_7101_config_loopback(struct bnx2x_phy
*phy
,
10623 struct link_params
*params
)
10625 struct bnx2x
*bp
= params
->bp
;
10626 /* SFX7101_XGXS_TEST1 */
10627 bnx2x_cl45_write(bp
, phy
,
10628 MDIO_XS_DEVAD
, MDIO_XS_SFX7101_XGXS_TEST1
, 0x100);
10631 static int bnx2x_7101_config_init(struct bnx2x_phy
*phy
,
10632 struct link_params
*params
,
10633 struct link_vars
*vars
)
10635 u16 fw_ver1
, fw_ver2
, val
;
10636 struct bnx2x
*bp
= params
->bp
;
10637 DP(NETIF_MSG_LINK
, "Setting the SFX7101 LASI indication\n");
10639 /* Restore normal power mode*/
10640 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_2
,
10641 MISC_REGISTERS_GPIO_OUTPUT_HIGH
, params
->port
);
10643 bnx2x_ext_phy_hw_reset(bp
, params
->port
);
10644 bnx2x_wait_reset_complete(bp
, phy
, params
);
10646 bnx2x_cl45_write(bp
, phy
,
10647 MDIO_PMA_DEVAD
, MDIO_PMA_LASI_CTRL
, 0x1);
10648 DP(NETIF_MSG_LINK
, "Setting the SFX7101 LED to blink on traffic\n");
10649 bnx2x_cl45_write(bp
, phy
,
10650 MDIO_PMA_DEVAD
, MDIO_PMA_REG_7107_LED_CNTL
, (1<<3));
10652 bnx2x_ext_phy_set_pause(params
, phy
, vars
);
10653 /* Restart autoneg */
10654 bnx2x_cl45_read(bp
, phy
,
10655 MDIO_AN_DEVAD
, MDIO_AN_REG_CTRL
, &val
);
10657 bnx2x_cl45_write(bp
, phy
,
10658 MDIO_AN_DEVAD
, MDIO_AN_REG_CTRL
, val
);
10660 /* Save spirom version */
10661 bnx2x_cl45_read(bp
, phy
,
10662 MDIO_PMA_DEVAD
, MDIO_PMA_REG_7101_VER1
, &fw_ver1
);
10664 bnx2x_cl45_read(bp
, phy
,
10665 MDIO_PMA_DEVAD
, MDIO_PMA_REG_7101_VER2
, &fw_ver2
);
10666 bnx2x_save_spirom_version(bp
, params
->port
,
10667 (u32
)(fw_ver1
<<16 | fw_ver2
), phy
->ver_addr
);
10671 static u8
bnx2x_7101_read_status(struct bnx2x_phy
*phy
,
10672 struct link_params
*params
,
10673 struct link_vars
*vars
)
10675 struct bnx2x
*bp
= params
->bp
;
10678 bnx2x_cl45_read(bp
, phy
,
10679 MDIO_PMA_DEVAD
, MDIO_PMA_LASI_STAT
, &val2
);
10680 bnx2x_cl45_read(bp
, phy
,
10681 MDIO_PMA_DEVAD
, MDIO_PMA_LASI_STAT
, &val1
);
10682 DP(NETIF_MSG_LINK
, "10G-base-T LASI status 0x%x->0x%x\n",
10684 bnx2x_cl45_read(bp
, phy
,
10685 MDIO_PMA_DEVAD
, MDIO_PMA_REG_STATUS
, &val2
);
10686 bnx2x_cl45_read(bp
, phy
,
10687 MDIO_PMA_DEVAD
, MDIO_PMA_REG_STATUS
, &val1
);
10688 DP(NETIF_MSG_LINK
, "10G-base-T PMA status 0x%x->0x%x\n",
10690 link_up
= ((val1
& 4) == 4);
10691 /* if link is up print the AN outcome of the SFX7101 PHY */
10693 bnx2x_cl45_read(bp
, phy
,
10694 MDIO_AN_DEVAD
, MDIO_AN_REG_MASTER_STATUS
,
10696 vars
->line_speed
= SPEED_10000
;
10697 vars
->duplex
= DUPLEX_FULL
;
10698 DP(NETIF_MSG_LINK
, "SFX7101 AN status 0x%x->Master=%x\n",
10699 val2
, (val2
& (1<<14)));
10700 bnx2x_ext_phy_10G_an_resolve(bp
, phy
, vars
);
10701 bnx2x_ext_phy_resolve_fc(phy
, params
, vars
);
10706 static int bnx2x_7101_format_ver(u32 spirom_ver
, u8
*str
, u16
*len
)
10710 str
[0] = (spirom_ver
& 0xFF);
10711 str
[1] = (spirom_ver
& 0xFF00) >> 8;
10712 str
[2] = (spirom_ver
& 0xFF0000) >> 16;
10713 str
[3] = (spirom_ver
& 0xFF000000) >> 24;
10719 void bnx2x_sfx7101_sp_sw_reset(struct bnx2x
*bp
, struct bnx2x_phy
*phy
)
10723 bnx2x_cl45_read(bp
, phy
,
10725 MDIO_PMA_REG_7101_RESET
, &val
);
10727 for (cnt
= 0; cnt
< 10; cnt
++) {
10729 /* Writes a self-clearing reset */
10730 bnx2x_cl45_write(bp
, phy
,
10732 MDIO_PMA_REG_7101_RESET
,
10734 /* Wait for clear */
10735 bnx2x_cl45_read(bp
, phy
,
10737 MDIO_PMA_REG_7101_RESET
, &val
);
10739 if ((val
& (1<<15)) == 0)
10744 static void bnx2x_7101_hw_reset(struct bnx2x_phy
*phy
,
10745 struct link_params
*params
) {
10746 /* Low power mode is controlled by GPIO 2 */
10747 bnx2x_set_gpio(params
->bp
, MISC_REGISTERS_GPIO_2
,
10748 MISC_REGISTERS_GPIO_OUTPUT_LOW
, params
->port
);
10749 /* The PHY reset is controlled by GPIO 1 */
10750 bnx2x_set_gpio(params
->bp
, MISC_REGISTERS_GPIO_1
,
10751 MISC_REGISTERS_GPIO_OUTPUT_LOW
, params
->port
);
10754 static void bnx2x_7101_set_link_led(struct bnx2x_phy
*phy
,
10755 struct link_params
*params
, u8 mode
)
10758 struct bnx2x
*bp
= params
->bp
;
10760 case LED_MODE_FRONT_PANEL_OFF
:
10767 case LED_MODE_OPER
:
10771 bnx2x_cl45_write(bp
, phy
,
10773 MDIO_PMA_REG_7107_LINK_LED_CNTL
,
10777 /******************************************************************/
10778 /* STATIC PHY DECLARATION */
10779 /******************************************************************/
10781 static struct bnx2x_phy phy_null
= {
10782 .type
= PORT_HW_CFG_XGXS_EXT_PHY_TYPE_NOT_CONN
,
10785 .flags
= FLAGS_INIT_XGXS_FIRST
,
10786 .rx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
10787 .tx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
10790 .media_type
= ETH_PHY_NOT_PRESENT
,
10792 .req_flow_ctrl
= 0,
10793 .req_line_speed
= 0,
10794 .speed_cap_mask
= 0,
10797 .config_init
= (config_init_t
)NULL
,
10798 .read_status
= (read_status_t
)NULL
,
10799 .link_reset
= (link_reset_t
)NULL
,
10800 .config_loopback
= (config_loopback_t
)NULL
,
10801 .format_fw_ver
= (format_fw_ver_t
)NULL
,
10802 .hw_reset
= (hw_reset_t
)NULL
,
10803 .set_link_led
= (set_link_led_t
)NULL
,
10804 .phy_specific_func
= (phy_specific_func_t
)NULL
10807 static struct bnx2x_phy phy_serdes
= {
10808 .type
= PORT_HW_CFG_SERDES_EXT_PHY_TYPE_DIRECT
,
10812 .rx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
10813 .tx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
10815 .supported
= (SUPPORTED_10baseT_Half
|
10816 SUPPORTED_10baseT_Full
|
10817 SUPPORTED_100baseT_Half
|
10818 SUPPORTED_100baseT_Full
|
10819 SUPPORTED_1000baseT_Full
|
10820 SUPPORTED_2500baseX_Full
|
10822 SUPPORTED_Autoneg
|
10824 SUPPORTED_Asym_Pause
),
10825 .media_type
= ETH_PHY_BASE_T
,
10827 .req_flow_ctrl
= 0,
10828 .req_line_speed
= 0,
10829 .speed_cap_mask
= 0,
10832 .config_init
= (config_init_t
)bnx2x_xgxs_config_init
,
10833 .read_status
= (read_status_t
)bnx2x_link_settings_status
,
10834 .link_reset
= (link_reset_t
)bnx2x_int_link_reset
,
10835 .config_loopback
= (config_loopback_t
)NULL
,
10836 .format_fw_ver
= (format_fw_ver_t
)NULL
,
10837 .hw_reset
= (hw_reset_t
)NULL
,
10838 .set_link_led
= (set_link_led_t
)NULL
,
10839 .phy_specific_func
= (phy_specific_func_t
)NULL
10842 static struct bnx2x_phy phy_xgxs
= {
10843 .type
= PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT
,
10847 .rx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
10848 .tx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
10850 .supported
= (SUPPORTED_10baseT_Half
|
10851 SUPPORTED_10baseT_Full
|
10852 SUPPORTED_100baseT_Half
|
10853 SUPPORTED_100baseT_Full
|
10854 SUPPORTED_1000baseT_Full
|
10855 SUPPORTED_2500baseX_Full
|
10856 SUPPORTED_10000baseT_Full
|
10858 SUPPORTED_Autoneg
|
10860 SUPPORTED_Asym_Pause
),
10861 .media_type
= ETH_PHY_CX4
,
10863 .req_flow_ctrl
= 0,
10864 .req_line_speed
= 0,
10865 .speed_cap_mask
= 0,
10868 .config_init
= (config_init_t
)bnx2x_xgxs_config_init
,
10869 .read_status
= (read_status_t
)bnx2x_link_settings_status
,
10870 .link_reset
= (link_reset_t
)bnx2x_int_link_reset
,
10871 .config_loopback
= (config_loopback_t
)bnx2x_set_xgxs_loopback
,
10872 .format_fw_ver
= (format_fw_ver_t
)NULL
,
10873 .hw_reset
= (hw_reset_t
)NULL
,
10874 .set_link_led
= (set_link_led_t
)NULL
,
10875 .phy_specific_func
= (phy_specific_func_t
)NULL
10877 static struct bnx2x_phy phy_warpcore
= {
10878 .type
= PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT
,
10881 .flags
= FLAGS_HW_LOCK_REQUIRED
,
10882 .rx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
10883 .tx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
10885 .supported
= (SUPPORTED_10baseT_Half
|
10886 SUPPORTED_10baseT_Full
|
10887 SUPPORTED_100baseT_Half
|
10888 SUPPORTED_100baseT_Full
|
10889 SUPPORTED_1000baseT_Full
|
10890 SUPPORTED_10000baseT_Full
|
10891 SUPPORTED_20000baseKR2_Full
|
10892 SUPPORTED_20000baseMLD2_Full
|
10894 SUPPORTED_Autoneg
|
10896 SUPPORTED_Asym_Pause
),
10897 .media_type
= ETH_PHY_UNSPECIFIED
,
10899 .req_flow_ctrl
= 0,
10900 .req_line_speed
= 0,
10901 .speed_cap_mask
= 0,
10902 /* req_duplex = */0,
10904 .config_init
= (config_init_t
)bnx2x_warpcore_config_init
,
10905 .read_status
= (read_status_t
)bnx2x_warpcore_read_status
,
10906 .link_reset
= (link_reset_t
)bnx2x_warpcore_link_reset
,
10907 .config_loopback
= (config_loopback_t
)bnx2x_set_warpcore_loopback
,
10908 .format_fw_ver
= (format_fw_ver_t
)NULL
,
10909 .hw_reset
= (hw_reset_t
)bnx2x_warpcore_hw_reset
,
10910 .set_link_led
= (set_link_led_t
)NULL
,
10911 .phy_specific_func
= (phy_specific_func_t
)NULL
10915 static struct bnx2x_phy phy_7101
= {
10916 .type
= PORT_HW_CFG_XGXS_EXT_PHY_TYPE_SFX7101
,
10919 .flags
= FLAGS_FAN_FAILURE_DET_REQ
,
10920 .rx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
10921 .tx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
10923 .supported
= (SUPPORTED_10000baseT_Full
|
10925 SUPPORTED_Autoneg
|
10927 SUPPORTED_Asym_Pause
),
10928 .media_type
= ETH_PHY_BASE_T
,
10930 .req_flow_ctrl
= 0,
10931 .req_line_speed
= 0,
10932 .speed_cap_mask
= 0,
10935 .config_init
= (config_init_t
)bnx2x_7101_config_init
,
10936 .read_status
= (read_status_t
)bnx2x_7101_read_status
,
10937 .link_reset
= (link_reset_t
)bnx2x_common_ext_link_reset
,
10938 .config_loopback
= (config_loopback_t
)bnx2x_7101_config_loopback
,
10939 .format_fw_ver
= (format_fw_ver_t
)bnx2x_7101_format_ver
,
10940 .hw_reset
= (hw_reset_t
)bnx2x_7101_hw_reset
,
10941 .set_link_led
= (set_link_led_t
)bnx2x_7101_set_link_led
,
10942 .phy_specific_func
= (phy_specific_func_t
)NULL
10944 static struct bnx2x_phy phy_8073
= {
10945 .type
= PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073
,
10948 .flags
= FLAGS_HW_LOCK_REQUIRED
,
10949 .rx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
10950 .tx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
10952 .supported
= (SUPPORTED_10000baseT_Full
|
10953 SUPPORTED_2500baseX_Full
|
10954 SUPPORTED_1000baseT_Full
|
10956 SUPPORTED_Autoneg
|
10958 SUPPORTED_Asym_Pause
),
10959 .media_type
= ETH_PHY_KR
,
10961 .req_flow_ctrl
= 0,
10962 .req_line_speed
= 0,
10963 .speed_cap_mask
= 0,
10966 .config_init
= (config_init_t
)bnx2x_8073_config_init
,
10967 .read_status
= (read_status_t
)bnx2x_8073_read_status
,
10968 .link_reset
= (link_reset_t
)bnx2x_8073_link_reset
,
10969 .config_loopback
= (config_loopback_t
)NULL
,
10970 .format_fw_ver
= (format_fw_ver_t
)bnx2x_format_ver
,
10971 .hw_reset
= (hw_reset_t
)NULL
,
10972 .set_link_led
= (set_link_led_t
)NULL
,
10973 .phy_specific_func
= (phy_specific_func_t
)NULL
10975 static struct bnx2x_phy phy_8705
= {
10976 .type
= PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8705
,
10979 .flags
= FLAGS_INIT_XGXS_FIRST
,
10980 .rx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
10981 .tx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
10983 .supported
= (SUPPORTED_10000baseT_Full
|
10986 SUPPORTED_Asym_Pause
),
10987 .media_type
= ETH_PHY_XFP_FIBER
,
10989 .req_flow_ctrl
= 0,
10990 .req_line_speed
= 0,
10991 .speed_cap_mask
= 0,
10994 .config_init
= (config_init_t
)bnx2x_8705_config_init
,
10995 .read_status
= (read_status_t
)bnx2x_8705_read_status
,
10996 .link_reset
= (link_reset_t
)bnx2x_common_ext_link_reset
,
10997 .config_loopback
= (config_loopback_t
)NULL
,
10998 .format_fw_ver
= (format_fw_ver_t
)bnx2x_null_format_ver
,
10999 .hw_reset
= (hw_reset_t
)NULL
,
11000 .set_link_led
= (set_link_led_t
)NULL
,
11001 .phy_specific_func
= (phy_specific_func_t
)NULL
11003 static struct bnx2x_phy phy_8706
= {
11004 .type
= PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8706
,
11007 .flags
= FLAGS_INIT_XGXS_FIRST
,
11008 .rx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
11009 .tx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
11011 .supported
= (SUPPORTED_10000baseT_Full
|
11012 SUPPORTED_1000baseT_Full
|
11015 SUPPORTED_Asym_Pause
),
11016 .media_type
= ETH_PHY_SFP_FIBER
,
11018 .req_flow_ctrl
= 0,
11019 .req_line_speed
= 0,
11020 .speed_cap_mask
= 0,
11023 .config_init
= (config_init_t
)bnx2x_8706_config_init
,
11024 .read_status
= (read_status_t
)bnx2x_8706_read_status
,
11025 .link_reset
= (link_reset_t
)bnx2x_common_ext_link_reset
,
11026 .config_loopback
= (config_loopback_t
)NULL
,
11027 .format_fw_ver
= (format_fw_ver_t
)bnx2x_format_ver
,
11028 .hw_reset
= (hw_reset_t
)NULL
,
11029 .set_link_led
= (set_link_led_t
)NULL
,
11030 .phy_specific_func
= (phy_specific_func_t
)NULL
11033 static struct bnx2x_phy phy_8726
= {
11034 .type
= PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726
,
11037 .flags
= (FLAGS_HW_LOCK_REQUIRED
|
11038 FLAGS_INIT_XGXS_FIRST
),
11039 .rx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
11040 .tx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
11042 .supported
= (SUPPORTED_10000baseT_Full
|
11043 SUPPORTED_1000baseT_Full
|
11044 SUPPORTED_Autoneg
|
11047 SUPPORTED_Asym_Pause
),
11048 .media_type
= ETH_PHY_NOT_PRESENT
,
11050 .req_flow_ctrl
= 0,
11051 .req_line_speed
= 0,
11052 .speed_cap_mask
= 0,
11055 .config_init
= (config_init_t
)bnx2x_8726_config_init
,
11056 .read_status
= (read_status_t
)bnx2x_8726_read_status
,
11057 .link_reset
= (link_reset_t
)bnx2x_8726_link_reset
,
11058 .config_loopback
= (config_loopback_t
)bnx2x_8726_config_loopback
,
11059 .format_fw_ver
= (format_fw_ver_t
)bnx2x_format_ver
,
11060 .hw_reset
= (hw_reset_t
)NULL
,
11061 .set_link_led
= (set_link_led_t
)NULL
,
11062 .phy_specific_func
= (phy_specific_func_t
)NULL
11065 static struct bnx2x_phy phy_8727
= {
11066 .type
= PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727
,
11069 .flags
= FLAGS_FAN_FAILURE_DET_REQ
,
11070 .rx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
11071 .tx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
11073 .supported
= (SUPPORTED_10000baseT_Full
|
11074 SUPPORTED_1000baseT_Full
|
11077 SUPPORTED_Asym_Pause
),
11078 .media_type
= ETH_PHY_NOT_PRESENT
,
11080 .req_flow_ctrl
= 0,
11081 .req_line_speed
= 0,
11082 .speed_cap_mask
= 0,
11085 .config_init
= (config_init_t
)bnx2x_8727_config_init
,
11086 .read_status
= (read_status_t
)bnx2x_8727_read_status
,
11087 .link_reset
= (link_reset_t
)bnx2x_8727_link_reset
,
11088 .config_loopback
= (config_loopback_t
)NULL
,
11089 .format_fw_ver
= (format_fw_ver_t
)bnx2x_format_ver
,
11090 .hw_reset
= (hw_reset_t
)bnx2x_8727_hw_reset
,
11091 .set_link_led
= (set_link_led_t
)bnx2x_8727_set_link_led
,
11092 .phy_specific_func
= (phy_specific_func_t
)bnx2x_8727_specific_func
11094 static struct bnx2x_phy phy_8481
= {
11095 .type
= PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8481
,
11098 .flags
= FLAGS_FAN_FAILURE_DET_REQ
|
11099 FLAGS_REARM_LATCH_SIGNAL
,
11100 .rx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
11101 .tx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
11103 .supported
= (SUPPORTED_10baseT_Half
|
11104 SUPPORTED_10baseT_Full
|
11105 SUPPORTED_100baseT_Half
|
11106 SUPPORTED_100baseT_Full
|
11107 SUPPORTED_1000baseT_Full
|
11108 SUPPORTED_10000baseT_Full
|
11110 SUPPORTED_Autoneg
|
11112 SUPPORTED_Asym_Pause
),
11113 .media_type
= ETH_PHY_BASE_T
,
11115 .req_flow_ctrl
= 0,
11116 .req_line_speed
= 0,
11117 .speed_cap_mask
= 0,
11120 .config_init
= (config_init_t
)bnx2x_8481_config_init
,
11121 .read_status
= (read_status_t
)bnx2x_848xx_read_status
,
11122 .link_reset
= (link_reset_t
)bnx2x_8481_link_reset
,
11123 .config_loopback
= (config_loopback_t
)NULL
,
11124 .format_fw_ver
= (format_fw_ver_t
)bnx2x_848xx_format_ver
,
11125 .hw_reset
= (hw_reset_t
)bnx2x_8481_hw_reset
,
11126 .set_link_led
= (set_link_led_t
)bnx2x_848xx_set_link_led
,
11127 .phy_specific_func
= (phy_specific_func_t
)NULL
11130 static struct bnx2x_phy phy_84823
= {
11131 .type
= PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84823
,
11134 .flags
= FLAGS_FAN_FAILURE_DET_REQ
|
11135 FLAGS_REARM_LATCH_SIGNAL
,
11136 .rx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
11137 .tx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
11139 .supported
= (SUPPORTED_10baseT_Half
|
11140 SUPPORTED_10baseT_Full
|
11141 SUPPORTED_100baseT_Half
|
11142 SUPPORTED_100baseT_Full
|
11143 SUPPORTED_1000baseT_Full
|
11144 SUPPORTED_10000baseT_Full
|
11146 SUPPORTED_Autoneg
|
11148 SUPPORTED_Asym_Pause
),
11149 .media_type
= ETH_PHY_BASE_T
,
11151 .req_flow_ctrl
= 0,
11152 .req_line_speed
= 0,
11153 .speed_cap_mask
= 0,
11156 .config_init
= (config_init_t
)bnx2x_848x3_config_init
,
11157 .read_status
= (read_status_t
)bnx2x_848xx_read_status
,
11158 .link_reset
= (link_reset_t
)bnx2x_848x3_link_reset
,
11159 .config_loopback
= (config_loopback_t
)NULL
,
11160 .format_fw_ver
= (format_fw_ver_t
)bnx2x_848xx_format_ver
,
11161 .hw_reset
= (hw_reset_t
)NULL
,
11162 .set_link_led
= (set_link_led_t
)bnx2x_848xx_set_link_led
,
11163 .phy_specific_func
= (phy_specific_func_t
)NULL
11166 static struct bnx2x_phy phy_84833
= {
11167 .type
= PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833
,
11170 .flags
= FLAGS_FAN_FAILURE_DET_REQ
|
11171 FLAGS_REARM_LATCH_SIGNAL
,
11172 .rx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
11173 .tx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
11175 .supported
= (SUPPORTED_100baseT_Half
|
11176 SUPPORTED_100baseT_Full
|
11177 SUPPORTED_1000baseT_Full
|
11178 SUPPORTED_10000baseT_Full
|
11180 SUPPORTED_Autoneg
|
11182 SUPPORTED_Asym_Pause
),
11183 .media_type
= ETH_PHY_BASE_T
,
11185 .req_flow_ctrl
= 0,
11186 .req_line_speed
= 0,
11187 .speed_cap_mask
= 0,
11190 .config_init
= (config_init_t
)bnx2x_848x3_config_init
,
11191 .read_status
= (read_status_t
)bnx2x_848xx_read_status
,
11192 .link_reset
= (link_reset_t
)bnx2x_848x3_link_reset
,
11193 .config_loopback
= (config_loopback_t
)NULL
,
11194 .format_fw_ver
= (format_fw_ver_t
)bnx2x_848xx_format_ver
,
11195 .hw_reset
= (hw_reset_t
)bnx2x_84833_hw_reset_phy
,
11196 .set_link_led
= (set_link_led_t
)bnx2x_848xx_set_link_led
,
11197 .phy_specific_func
= (phy_specific_func_t
)NULL
11200 static struct bnx2x_phy phy_54618se
= {
11201 .type
= PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54618SE
,
11204 .flags
= FLAGS_INIT_XGXS_FIRST
,
11205 .rx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
11206 .tx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
11208 .supported
= (SUPPORTED_10baseT_Half
|
11209 SUPPORTED_10baseT_Full
|
11210 SUPPORTED_100baseT_Half
|
11211 SUPPORTED_100baseT_Full
|
11212 SUPPORTED_1000baseT_Full
|
11214 SUPPORTED_Autoneg
|
11216 SUPPORTED_Asym_Pause
),
11217 .media_type
= ETH_PHY_BASE_T
,
11219 .req_flow_ctrl
= 0,
11220 .req_line_speed
= 0,
11221 .speed_cap_mask
= 0,
11222 /* req_duplex = */0,
11224 .config_init
= (config_init_t
)bnx2x_54618se_config_init
,
11225 .read_status
= (read_status_t
)bnx2x_54618se_read_status
,
11226 .link_reset
= (link_reset_t
)bnx2x_54618se_link_reset
,
11227 .config_loopback
= (config_loopback_t
)bnx2x_54618se_config_loopback
,
11228 .format_fw_ver
= (format_fw_ver_t
)NULL
,
11229 .hw_reset
= (hw_reset_t
)NULL
,
11230 .set_link_led
= (set_link_led_t
)bnx2x_5461x_set_link_led
,
11231 .phy_specific_func
= (phy_specific_func_t
)NULL
11233 /*****************************************************************/
11235 /* Populate the phy according. Main function: bnx2x_populate_phy */
11237 /*****************************************************************/
11239 static void bnx2x_populate_preemphasis(struct bnx2x
*bp
, u32 shmem_base
,
11240 struct bnx2x_phy
*phy
, u8 port
,
11243 /* Get the 4 lanes xgxs config rx and tx */
11244 u32 rx
= 0, tx
= 0, i
;
11245 for (i
= 0; i
< 2; i
++) {
11247 * INT_PHY and EXT_PHY1 share the same value location in the
11248 * shmem. When num_phys is greater than 1, than this value
11249 * applies only to EXT_PHY1
11251 if (phy_index
== INT_PHY
|| phy_index
== EXT_PHY1
) {
11252 rx
= REG_RD(bp
, shmem_base
+
11253 offsetof(struct shmem_region
,
11254 dev_info
.port_hw_config
[port
].xgxs_config_rx
[i
<<1]));
11256 tx
= REG_RD(bp
, shmem_base
+
11257 offsetof(struct shmem_region
,
11258 dev_info
.port_hw_config
[port
].xgxs_config_tx
[i
<<1]));
11260 rx
= REG_RD(bp
, shmem_base
+
11261 offsetof(struct shmem_region
,
11262 dev_info
.port_hw_config
[port
].xgxs_config2_rx
[i
<<1]));
11264 tx
= REG_RD(bp
, shmem_base
+
11265 offsetof(struct shmem_region
,
11266 dev_info
.port_hw_config
[port
].xgxs_config2_rx
[i
<<1]));
11269 phy
->rx_preemphasis
[i
<< 1] = ((rx
>>16) & 0xffff);
11270 phy
->rx_preemphasis
[(i
<< 1) + 1] = (rx
& 0xffff);
11272 phy
->tx_preemphasis
[i
<< 1] = ((tx
>>16) & 0xffff);
11273 phy
->tx_preemphasis
[(i
<< 1) + 1] = (tx
& 0xffff);
11277 static u32
bnx2x_get_ext_phy_config(struct bnx2x
*bp
, u32 shmem_base
,
11278 u8 phy_index
, u8 port
)
11280 u32 ext_phy_config
= 0;
11281 switch (phy_index
) {
11283 ext_phy_config
= REG_RD(bp
, shmem_base
+
11284 offsetof(struct shmem_region
,
11285 dev_info
.port_hw_config
[port
].external_phy_config
));
11288 ext_phy_config
= REG_RD(bp
, shmem_base
+
11289 offsetof(struct shmem_region
,
11290 dev_info
.port_hw_config
[port
].external_phy_config2
));
11293 DP(NETIF_MSG_LINK
, "Invalid phy_index %d\n", phy_index
);
11297 return ext_phy_config
;
11299 static int bnx2x_populate_int_phy(struct bnx2x
*bp
, u32 shmem_base
, u8 port
,
11300 struct bnx2x_phy
*phy
)
11304 u32 switch_cfg
= (REG_RD(bp
, shmem_base
+
11305 offsetof(struct shmem_region
,
11306 dev_info
.port_feature_config
[port
].link_config
)) &
11307 PORT_FEATURE_CONNECTED_SWITCH_MASK
);
11308 chip_id
= (REG_RD(bp
, MISC_REG_CHIP_NUM
) << 16) |
11309 ((REG_RD(bp
, MISC_REG_CHIP_REV
) & 0xf) << 12);
11311 DP(NETIF_MSG_LINK
, ":chip_id = 0x%x\n", chip_id
);
11312 if (USES_WARPCORE(bp
)) {
11314 phy_addr
= REG_RD(bp
,
11315 MISC_REG_WC0_CTRL_PHY_ADDR
);
11316 *phy
= phy_warpcore
;
11317 if (REG_RD(bp
, MISC_REG_PORT4MODE_EN_OVWR
) == 0x3)
11318 phy
->flags
|= FLAGS_4_PORT_MODE
;
11320 phy
->flags
&= ~FLAGS_4_PORT_MODE
;
11321 /* Check Dual mode */
11322 serdes_net_if
= (REG_RD(bp
, shmem_base
+
11323 offsetof(struct shmem_region
, dev_info
.
11324 port_hw_config
[port
].default_cfg
)) &
11325 PORT_HW_CFG_NET_SERDES_IF_MASK
);
11327 * Set the appropriate supported and flags indications per
11328 * interface type of the chip
11330 switch (serdes_net_if
) {
11331 case PORT_HW_CFG_NET_SERDES_IF_SGMII
:
11332 phy
->supported
&= (SUPPORTED_10baseT_Half
|
11333 SUPPORTED_10baseT_Full
|
11334 SUPPORTED_100baseT_Half
|
11335 SUPPORTED_100baseT_Full
|
11336 SUPPORTED_1000baseT_Full
|
11338 SUPPORTED_Autoneg
|
11340 SUPPORTED_Asym_Pause
);
11341 phy
->media_type
= ETH_PHY_BASE_T
;
11343 case PORT_HW_CFG_NET_SERDES_IF_XFI
:
11344 phy
->media_type
= ETH_PHY_XFP_FIBER
;
11346 case PORT_HW_CFG_NET_SERDES_IF_SFI
:
11347 phy
->supported
&= (SUPPORTED_1000baseT_Full
|
11348 SUPPORTED_10000baseT_Full
|
11351 SUPPORTED_Asym_Pause
);
11352 phy
->media_type
= ETH_PHY_SFP_FIBER
;
11354 case PORT_HW_CFG_NET_SERDES_IF_KR
:
11355 phy
->media_type
= ETH_PHY_KR
;
11356 phy
->supported
&= (SUPPORTED_1000baseT_Full
|
11357 SUPPORTED_10000baseT_Full
|
11359 SUPPORTED_Autoneg
|
11361 SUPPORTED_Asym_Pause
);
11363 case PORT_HW_CFG_NET_SERDES_IF_DXGXS
:
11364 phy
->media_type
= ETH_PHY_KR
;
11365 phy
->flags
|= FLAGS_WC_DUAL_MODE
;
11366 phy
->supported
&= (SUPPORTED_20000baseMLD2_Full
|
11369 SUPPORTED_Asym_Pause
);
11371 case PORT_HW_CFG_NET_SERDES_IF_KR2
:
11372 phy
->media_type
= ETH_PHY_KR
;
11373 phy
->flags
|= FLAGS_WC_DUAL_MODE
;
11374 phy
->supported
&= (SUPPORTED_20000baseKR2_Full
|
11377 SUPPORTED_Asym_Pause
);
11380 DP(NETIF_MSG_LINK
, "Unknown WC interface type 0x%x\n",
11386 * Enable MDC/MDIO work-around for E3 A0 since free running MDC
11387 * was not set as expected. For B0, ECO will be enabled so there
11388 * won't be an issue there
11390 if (CHIP_REV(bp
) == CHIP_REV_Ax
)
11391 phy
->flags
|= FLAGS_MDC_MDIO_WA
;
11393 phy
->flags
|= FLAGS_MDC_MDIO_WA_B0
;
11395 switch (switch_cfg
) {
11396 case SWITCH_CFG_1G
:
11397 phy_addr
= REG_RD(bp
,
11398 NIG_REG_SERDES0_CTRL_PHY_ADDR
+
11402 case SWITCH_CFG_10G
:
11403 phy_addr
= REG_RD(bp
,
11404 NIG_REG_XGXS0_CTRL_PHY_ADDR
+
11409 DP(NETIF_MSG_LINK
, "Invalid switch_cfg\n");
11413 phy
->addr
= (u8
)phy_addr
;
11414 phy
->mdio_ctrl
= bnx2x_get_emac_base(bp
,
11415 SHARED_HW_CFG_MDC_MDIO_ACCESS1_BOTH
,
11417 if (CHIP_IS_E2(bp
))
11418 phy
->def_md_devad
= E2_DEFAULT_PHY_DEV_ADDR
;
11420 phy
->def_md_devad
= DEFAULT_PHY_DEV_ADDR
;
11422 DP(NETIF_MSG_LINK
, "Internal phy port=%d, addr=0x%x, mdio_ctl=0x%x\n",
11423 port
, phy
->addr
, phy
->mdio_ctrl
);
11425 bnx2x_populate_preemphasis(bp
, shmem_base
, phy
, port
, INT_PHY
);
11429 static int bnx2x_populate_ext_phy(struct bnx2x
*bp
,
11434 struct bnx2x_phy
*phy
)
11436 u32 ext_phy_config
, phy_type
, config2
;
11437 u32 mdc_mdio_access
= SHARED_HW_CFG_MDC_MDIO_ACCESS1_BOTH
;
11438 ext_phy_config
= bnx2x_get_ext_phy_config(bp
, shmem_base
,
11440 phy_type
= XGXS_EXT_PHY_TYPE(ext_phy_config
);
11441 /* Select the phy type */
11442 switch (phy_type
) {
11443 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073
:
11444 mdc_mdio_access
= SHARED_HW_CFG_MDC_MDIO_ACCESS1_SWAPPED
;
11447 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8705
:
11450 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8706
:
11453 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726
:
11454 mdc_mdio_access
= SHARED_HW_CFG_MDC_MDIO_ACCESS1_EMAC1
;
11457 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727_NOC
:
11458 /* BCM8727_NOC => BCM8727 no over current */
11459 mdc_mdio_access
= SHARED_HW_CFG_MDC_MDIO_ACCESS1_EMAC1
;
11461 phy
->flags
|= FLAGS_NOC
;
11463 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8722
:
11464 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727
:
11465 mdc_mdio_access
= SHARED_HW_CFG_MDC_MDIO_ACCESS1_EMAC1
;
11468 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8481
:
11471 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84823
:
11474 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833
:
11477 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54616
:
11478 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54618SE
:
11479 *phy
= phy_54618se
;
11481 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_SFX7101
:
11484 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_FAILURE
:
11489 /* In case external PHY wasn't found */
11490 if ((phy_type
!= PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT
) &&
11491 (phy_type
!= PORT_HW_CFG_XGXS_EXT_PHY_TYPE_NOT_CONN
))
11496 phy
->addr
= XGXS_EXT_PHY_ADDR(ext_phy_config
);
11497 bnx2x_populate_preemphasis(bp
, shmem_base
, phy
, port
, phy_index
);
11500 * The shmem address of the phy version is located on different
11501 * structures. In case this structure is too old, do not set
11504 config2
= REG_RD(bp
, shmem_base
+ offsetof(struct shmem_region
,
11505 dev_info
.shared_hw_config
.config2
));
11506 if (phy_index
== EXT_PHY1
) {
11507 phy
->ver_addr
= shmem_base
+ offsetof(struct shmem_region
,
11508 port_mb
[port
].ext_phy_fw_version
);
11510 /* Check specific mdc mdio settings */
11511 if (config2
& SHARED_HW_CFG_MDC_MDIO_ACCESS1_MASK
)
11512 mdc_mdio_access
= config2
&
11513 SHARED_HW_CFG_MDC_MDIO_ACCESS1_MASK
;
11515 u32 size
= REG_RD(bp
, shmem2_base
);
11518 offsetof(struct shmem2_region
, ext_phy_fw_version2
)) {
11519 phy
->ver_addr
= shmem2_base
+
11520 offsetof(struct shmem2_region
,
11521 ext_phy_fw_version2
[port
]);
11523 /* Check specific mdc mdio settings */
11524 if (config2
& SHARED_HW_CFG_MDC_MDIO_ACCESS2_MASK
)
11525 mdc_mdio_access
= (config2
&
11526 SHARED_HW_CFG_MDC_MDIO_ACCESS2_MASK
) >>
11527 (SHARED_HW_CFG_MDC_MDIO_ACCESS2_SHIFT
-
11528 SHARED_HW_CFG_MDC_MDIO_ACCESS1_SHIFT
);
11530 phy
->mdio_ctrl
= bnx2x_get_emac_base(bp
, mdc_mdio_access
, port
);
11532 if ((phy
->type
== PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833
) &&
11535 * Remove 100Mb link supported for BCM84833 when phy fw
11536 * version lower than or equal to 1.39
11538 u32 raw_ver
= REG_RD(bp
, phy
->ver_addr
);
11539 if (((raw_ver
& 0x7F) <= 39) &&
11540 (((raw_ver
& 0xF80) >> 7) <= 1))
11541 phy
->supported
&= ~(SUPPORTED_100baseT_Half
|
11542 SUPPORTED_100baseT_Full
);
11546 * In case mdc/mdio_access of the external phy is different than the
11547 * mdc/mdio access of the XGXS, a HW lock must be taken in each access
11548 * to prevent one port interfere with another port's CL45 operations.
11550 if (mdc_mdio_access
!= SHARED_HW_CFG_MDC_MDIO_ACCESS1_BOTH
)
11551 phy
->flags
|= FLAGS_HW_LOCK_REQUIRED
;
11552 DP(NETIF_MSG_LINK
, "phy_type 0x%x port %d found in index %d\n",
11553 phy_type
, port
, phy_index
);
11554 DP(NETIF_MSG_LINK
, " addr=0x%x, mdio_ctl=0x%x\n",
11555 phy
->addr
, phy
->mdio_ctrl
);
11559 static int bnx2x_populate_phy(struct bnx2x
*bp
, u8 phy_index
, u32 shmem_base
,
11560 u32 shmem2_base
, u8 port
, struct bnx2x_phy
*phy
)
11563 phy
->type
= PORT_HW_CFG_XGXS_EXT_PHY_TYPE_NOT_CONN
;
11564 if (phy_index
== INT_PHY
)
11565 return bnx2x_populate_int_phy(bp
, shmem_base
, port
, phy
);
11566 status
= bnx2x_populate_ext_phy(bp
, phy_index
, shmem_base
, shmem2_base
,
11571 static void bnx2x_phy_def_cfg(struct link_params
*params
,
11572 struct bnx2x_phy
*phy
,
11575 struct bnx2x
*bp
= params
->bp
;
11577 /* Populate the default phy configuration for MF mode */
11578 if (phy_index
== EXT_PHY2
) {
11579 link_config
= REG_RD(bp
, params
->shmem_base
+
11580 offsetof(struct shmem_region
, dev_info
.
11581 port_feature_config
[params
->port
].link_config2
));
11582 phy
->speed_cap_mask
= REG_RD(bp
, params
->shmem_base
+
11583 offsetof(struct shmem_region
,
11585 port_hw_config
[params
->port
].speed_capability_mask2
));
11587 link_config
= REG_RD(bp
, params
->shmem_base
+
11588 offsetof(struct shmem_region
, dev_info
.
11589 port_feature_config
[params
->port
].link_config
));
11590 phy
->speed_cap_mask
= REG_RD(bp
, params
->shmem_base
+
11591 offsetof(struct shmem_region
,
11593 port_hw_config
[params
->port
].speed_capability_mask
));
11596 "Default config phy idx %x cfg 0x%x speed_cap_mask 0x%x\n",
11597 phy_index
, link_config
, phy
->speed_cap_mask
);
11599 phy
->req_duplex
= DUPLEX_FULL
;
11600 switch (link_config
& PORT_FEATURE_LINK_SPEED_MASK
) {
11601 case PORT_FEATURE_LINK_SPEED_10M_HALF
:
11602 phy
->req_duplex
= DUPLEX_HALF
;
11603 case PORT_FEATURE_LINK_SPEED_10M_FULL
:
11604 phy
->req_line_speed
= SPEED_10
;
11606 case PORT_FEATURE_LINK_SPEED_100M_HALF
:
11607 phy
->req_duplex
= DUPLEX_HALF
;
11608 case PORT_FEATURE_LINK_SPEED_100M_FULL
:
11609 phy
->req_line_speed
= SPEED_100
;
11611 case PORT_FEATURE_LINK_SPEED_1G
:
11612 phy
->req_line_speed
= SPEED_1000
;
11614 case PORT_FEATURE_LINK_SPEED_2_5G
:
11615 phy
->req_line_speed
= SPEED_2500
;
11617 case PORT_FEATURE_LINK_SPEED_10G_CX4
:
11618 phy
->req_line_speed
= SPEED_10000
;
11621 phy
->req_line_speed
= SPEED_AUTO_NEG
;
11625 switch (link_config
& PORT_FEATURE_FLOW_CONTROL_MASK
) {
11626 case PORT_FEATURE_FLOW_CONTROL_AUTO
:
11627 phy
->req_flow_ctrl
= BNX2X_FLOW_CTRL_AUTO
;
11629 case PORT_FEATURE_FLOW_CONTROL_TX
:
11630 phy
->req_flow_ctrl
= BNX2X_FLOW_CTRL_TX
;
11632 case PORT_FEATURE_FLOW_CONTROL_RX
:
11633 phy
->req_flow_ctrl
= BNX2X_FLOW_CTRL_RX
;
11635 case PORT_FEATURE_FLOW_CONTROL_BOTH
:
11636 phy
->req_flow_ctrl
= BNX2X_FLOW_CTRL_BOTH
;
11639 phy
->req_flow_ctrl
= BNX2X_FLOW_CTRL_NONE
;
11644 u32
bnx2x_phy_selection(struct link_params
*params
)
11646 u32 phy_config_swapped
, prio_cfg
;
11647 u32 return_cfg
= PORT_HW_CFG_PHY_SELECTION_HARDWARE_DEFAULT
;
11649 phy_config_swapped
= params
->multi_phy_config
&
11650 PORT_HW_CFG_PHY_SWAPPED_ENABLED
;
11652 prio_cfg
= params
->multi_phy_config
&
11653 PORT_HW_CFG_PHY_SELECTION_MASK
;
11655 if (phy_config_swapped
) {
11656 switch (prio_cfg
) {
11657 case PORT_HW_CFG_PHY_SELECTION_FIRST_PHY_PRIORITY
:
11658 return_cfg
= PORT_HW_CFG_PHY_SELECTION_SECOND_PHY_PRIORITY
;
11660 case PORT_HW_CFG_PHY_SELECTION_SECOND_PHY_PRIORITY
:
11661 return_cfg
= PORT_HW_CFG_PHY_SELECTION_FIRST_PHY_PRIORITY
;
11663 case PORT_HW_CFG_PHY_SELECTION_SECOND_PHY
:
11664 return_cfg
= PORT_HW_CFG_PHY_SELECTION_FIRST_PHY
;
11666 case PORT_HW_CFG_PHY_SELECTION_FIRST_PHY
:
11667 return_cfg
= PORT_HW_CFG_PHY_SELECTION_SECOND_PHY
;
11671 return_cfg
= prio_cfg
;
11677 int bnx2x_phy_probe(struct link_params
*params
)
11679 u8 phy_index
, actual_phy_idx
;
11680 u32 phy_config_swapped
, sync_offset
, media_types
;
11681 struct bnx2x
*bp
= params
->bp
;
11682 struct bnx2x_phy
*phy
;
11683 params
->num_phys
= 0;
11684 DP(NETIF_MSG_LINK
, "Begin phy probe\n");
11685 phy_config_swapped
= params
->multi_phy_config
&
11686 PORT_HW_CFG_PHY_SWAPPED_ENABLED
;
11688 for (phy_index
= INT_PHY
; phy_index
< MAX_PHYS
;
11690 actual_phy_idx
= phy_index
;
11691 if (phy_config_swapped
) {
11692 if (phy_index
== EXT_PHY1
)
11693 actual_phy_idx
= EXT_PHY2
;
11694 else if (phy_index
== EXT_PHY2
)
11695 actual_phy_idx
= EXT_PHY1
;
11697 DP(NETIF_MSG_LINK
, "phy_config_swapped %x, phy_index %x,"
11698 " actual_phy_idx %x\n", phy_config_swapped
,
11699 phy_index
, actual_phy_idx
);
11700 phy
= ¶ms
->phy
[actual_phy_idx
];
11701 if (bnx2x_populate_phy(bp
, phy_index
, params
->shmem_base
,
11702 params
->shmem2_base
, params
->port
,
11704 params
->num_phys
= 0;
11705 DP(NETIF_MSG_LINK
, "phy probe failed in phy index %d\n",
11707 for (phy_index
= INT_PHY
;
11708 phy_index
< MAX_PHYS
;
11713 if (phy
->type
== PORT_HW_CFG_XGXS_EXT_PHY_TYPE_NOT_CONN
)
11716 sync_offset
= params
->shmem_base
+
11717 offsetof(struct shmem_region
,
11718 dev_info
.port_hw_config
[params
->port
].media_type
);
11719 media_types
= REG_RD(bp
, sync_offset
);
11722 * Update media type for non-PMF sync only for the first time
11723 * In case the media type changes afterwards, it will be updated
11724 * using the update_status function
11726 if ((media_types
& (PORT_HW_CFG_MEDIA_TYPE_PHY0_MASK
<<
11727 (PORT_HW_CFG_MEDIA_TYPE_PHY1_SHIFT
*
11728 actual_phy_idx
))) == 0) {
11729 media_types
|= ((phy
->media_type
&
11730 PORT_HW_CFG_MEDIA_TYPE_PHY0_MASK
) <<
11731 (PORT_HW_CFG_MEDIA_TYPE_PHY1_SHIFT
*
11734 REG_WR(bp
, sync_offset
, media_types
);
11736 bnx2x_phy_def_cfg(params
, phy
, phy_index
);
11737 params
->num_phys
++;
11740 DP(NETIF_MSG_LINK
, "End phy probe. #phys found %x\n", params
->num_phys
);
11744 void bnx2x_init_bmac_loopback(struct link_params
*params
,
11745 struct link_vars
*vars
)
11747 struct bnx2x
*bp
= params
->bp
;
11749 vars
->line_speed
= SPEED_10000
;
11750 vars
->duplex
= DUPLEX_FULL
;
11751 vars
->flow_ctrl
= BNX2X_FLOW_CTRL_NONE
;
11752 vars
->mac_type
= MAC_TYPE_BMAC
;
11754 vars
->phy_flags
= PHY_XGXS_FLAG
;
11756 bnx2x_xgxs_deassert(params
);
11758 /* set bmac loopback */
11759 bnx2x_bmac_enable(params
, vars
, 1);
11761 REG_WR(bp
, NIG_REG_EGRESS_DRAIN0_MODE
+ params
->port
*4, 0);
11764 void bnx2x_init_emac_loopback(struct link_params
*params
,
11765 struct link_vars
*vars
)
11767 struct bnx2x
*bp
= params
->bp
;
11769 vars
->line_speed
= SPEED_1000
;
11770 vars
->duplex
= DUPLEX_FULL
;
11771 vars
->flow_ctrl
= BNX2X_FLOW_CTRL_NONE
;
11772 vars
->mac_type
= MAC_TYPE_EMAC
;
11774 vars
->phy_flags
= PHY_XGXS_FLAG
;
11776 bnx2x_xgxs_deassert(params
);
11777 /* set bmac loopback */
11778 bnx2x_emac_enable(params
, vars
, 1);
11779 bnx2x_emac_program(params
, vars
);
11780 REG_WR(bp
, NIG_REG_EGRESS_DRAIN0_MODE
+ params
->port
*4, 0);
11783 void bnx2x_init_xmac_loopback(struct link_params
*params
,
11784 struct link_vars
*vars
)
11786 struct bnx2x
*bp
= params
->bp
;
11788 if (!params
->req_line_speed
[0])
11789 vars
->line_speed
= SPEED_10000
;
11791 vars
->line_speed
= params
->req_line_speed
[0];
11792 vars
->duplex
= DUPLEX_FULL
;
11793 vars
->flow_ctrl
= BNX2X_FLOW_CTRL_NONE
;
11794 vars
->mac_type
= MAC_TYPE_XMAC
;
11795 vars
->phy_flags
= PHY_XGXS_FLAG
;
11797 * Set WC to loopback mode since link is required to provide clock
11798 * to the XMAC in 20G mode
11800 bnx2x_set_aer_mmd(params
, ¶ms
->phy
[0]);
11801 bnx2x_warpcore_reset_lane(bp
, ¶ms
->phy
[0], 0);
11802 params
->phy
[INT_PHY
].config_loopback(
11803 ¶ms
->phy
[INT_PHY
],
11806 bnx2x_xmac_enable(params
, vars
, 1);
11807 REG_WR(bp
, NIG_REG_EGRESS_DRAIN0_MODE
+ params
->port
*4, 0);
11810 void bnx2x_init_umac_loopback(struct link_params
*params
,
11811 struct link_vars
*vars
)
11813 struct bnx2x
*bp
= params
->bp
;
11815 vars
->line_speed
= SPEED_1000
;
11816 vars
->duplex
= DUPLEX_FULL
;
11817 vars
->flow_ctrl
= BNX2X_FLOW_CTRL_NONE
;
11818 vars
->mac_type
= MAC_TYPE_UMAC
;
11819 vars
->phy_flags
= PHY_XGXS_FLAG
;
11820 bnx2x_umac_enable(params
, vars
, 1);
11822 REG_WR(bp
, NIG_REG_EGRESS_DRAIN0_MODE
+ params
->port
*4, 0);
11825 void bnx2x_init_xgxs_loopback(struct link_params
*params
,
11826 struct link_vars
*vars
)
11828 struct bnx2x
*bp
= params
->bp
;
11830 vars
->flow_ctrl
= BNX2X_FLOW_CTRL_NONE
;
11831 vars
->duplex
= DUPLEX_FULL
;
11832 if (params
->req_line_speed
[0] == SPEED_1000
)
11833 vars
->line_speed
= SPEED_1000
;
11835 vars
->line_speed
= SPEED_10000
;
11837 if (!USES_WARPCORE(bp
))
11838 bnx2x_xgxs_deassert(params
);
11839 bnx2x_link_initialize(params
, vars
);
11841 if (params
->req_line_speed
[0] == SPEED_1000
) {
11842 if (USES_WARPCORE(bp
))
11843 bnx2x_umac_enable(params
, vars
, 0);
11845 bnx2x_emac_program(params
, vars
);
11846 bnx2x_emac_enable(params
, vars
, 0);
11849 if (USES_WARPCORE(bp
))
11850 bnx2x_xmac_enable(params
, vars
, 0);
11852 bnx2x_bmac_enable(params
, vars
, 0);
11855 if (params
->loopback_mode
== LOOPBACK_XGXS
) {
11856 /* set 10G XGXS loopback */
11857 params
->phy
[INT_PHY
].config_loopback(
11858 ¶ms
->phy
[INT_PHY
],
11862 /* set external phy loopback */
11864 for (phy_index
= EXT_PHY1
;
11865 phy_index
< params
->num_phys
; phy_index
++) {
11866 if (params
->phy
[phy_index
].config_loopback
)
11867 params
->phy
[phy_index
].config_loopback(
11868 ¶ms
->phy
[phy_index
],
11872 REG_WR(bp
, NIG_REG_EGRESS_DRAIN0_MODE
+ params
->port
*4, 0);
11874 bnx2x_set_led(params
, vars
, LED_MODE_OPER
, vars
->line_speed
);
11877 int bnx2x_phy_init(struct link_params
*params
, struct link_vars
*vars
)
11879 struct bnx2x
*bp
= params
->bp
;
11880 DP(NETIF_MSG_LINK
, "Phy Initialization started\n");
11881 DP(NETIF_MSG_LINK
, "(1) req_speed %d, req_flowctrl %d\n",
11882 params
->req_line_speed
[0], params
->req_flow_ctrl
[0]);
11883 DP(NETIF_MSG_LINK
, "(2) req_speed %d, req_flowctrl %d\n",
11884 params
->req_line_speed
[1], params
->req_flow_ctrl
[1]);
11885 vars
->link_status
= 0;
11886 vars
->phy_link_up
= 0;
11888 vars
->line_speed
= 0;
11889 vars
->duplex
= DUPLEX_FULL
;
11890 vars
->flow_ctrl
= BNX2X_FLOW_CTRL_NONE
;
11891 vars
->mac_type
= MAC_TYPE_NONE
;
11892 vars
->phy_flags
= 0;
11894 /* disable attentions */
11895 bnx2x_bits_dis(bp
, NIG_REG_MASK_INTERRUPT_PORT0
+ params
->port
*4,
11896 (NIG_MASK_XGXS0_LINK_STATUS
|
11897 NIG_MASK_XGXS0_LINK10G
|
11898 NIG_MASK_SERDES0_LINK_STATUS
|
11901 bnx2x_emac_init(params
, vars
);
11903 if (params
->num_phys
== 0) {
11904 DP(NETIF_MSG_LINK
, "No phy found for initialization !!\n");
11907 set_phy_vars(params
, vars
);
11909 DP(NETIF_MSG_LINK
, "Num of phys on board: %d\n", params
->num_phys
);
11910 switch (params
->loopback_mode
) {
11911 case LOOPBACK_BMAC
:
11912 bnx2x_init_bmac_loopback(params
, vars
);
11914 case LOOPBACK_EMAC
:
11915 bnx2x_init_emac_loopback(params
, vars
);
11917 case LOOPBACK_XMAC
:
11918 bnx2x_init_xmac_loopback(params
, vars
);
11920 case LOOPBACK_UMAC
:
11921 bnx2x_init_umac_loopback(params
, vars
);
11923 case LOOPBACK_XGXS
:
11924 case LOOPBACK_EXT_PHY
:
11925 bnx2x_init_xgxs_loopback(params
, vars
);
11928 if (!CHIP_IS_E3(bp
)) {
11929 if (params
->switch_cfg
== SWITCH_CFG_10G
)
11930 bnx2x_xgxs_deassert(params
);
11932 bnx2x_serdes_deassert(bp
, params
->port
);
11934 bnx2x_link_initialize(params
, vars
);
11936 bnx2x_link_int_enable(params
);
11942 int bnx2x_link_reset(struct link_params
*params
, struct link_vars
*vars
,
11945 struct bnx2x
*bp
= params
->bp
;
11946 u8 phy_index
, port
= params
->port
, clear_latch_ind
= 0;
11947 DP(NETIF_MSG_LINK
, "Resetting the link of port %d\n", port
);
11948 /* disable attentions */
11949 vars
->link_status
= 0;
11950 bnx2x_update_mng(params
, vars
->link_status
);
11951 bnx2x_bits_dis(bp
, NIG_REG_MASK_INTERRUPT_PORT0
+ port
*4,
11952 (NIG_MASK_XGXS0_LINK_STATUS
|
11953 NIG_MASK_XGXS0_LINK10G
|
11954 NIG_MASK_SERDES0_LINK_STATUS
|
11957 /* activate nig drain */
11958 REG_WR(bp
, NIG_REG_EGRESS_DRAIN0_MODE
+ port
*4, 1);
11960 /* disable nig egress interface */
11961 if (!CHIP_IS_E3(bp
)) {
11962 REG_WR(bp
, NIG_REG_BMAC0_OUT_EN
+ port
*4, 0);
11963 REG_WR(bp
, NIG_REG_EGRESS_EMAC0_OUT_EN
+ port
*4, 0);
11966 /* Stop BigMac rx */
11967 if (!CHIP_IS_E3(bp
))
11968 bnx2x_bmac_rx_disable(bp
, port
);
11970 bnx2x_xmac_disable(params
);
11971 bnx2x_umac_disable(params
);
11974 if (!CHIP_IS_E3(bp
))
11975 REG_WR(bp
, NIG_REG_NIG_EMAC0_EN
+ port
*4, 0);
11978 /* The PHY reset is controlled by GPIO 1
11979 * Hold it as vars low
11981 /* clear link led */
11982 bnx2x_set_led(params
, vars
, LED_MODE_OFF
, 0);
11984 if (reset_ext_phy
) {
11985 bnx2x_set_mdio_clk(bp
, params
->chip_id
, port
);
11986 for (phy_index
= EXT_PHY1
; phy_index
< params
->num_phys
;
11988 if (params
->phy
[phy_index
].link_reset
) {
11989 bnx2x_set_aer_mmd(params
,
11990 ¶ms
->phy
[phy_index
]);
11991 params
->phy
[phy_index
].link_reset(
11992 ¶ms
->phy
[phy_index
],
11995 if (params
->phy
[phy_index
].flags
&
11996 FLAGS_REARM_LATCH_SIGNAL
)
11997 clear_latch_ind
= 1;
12001 if (clear_latch_ind
) {
12002 /* Clear latching indication */
12003 bnx2x_rearm_latch_signal(bp
, port
, 0);
12004 bnx2x_bits_dis(bp
, NIG_REG_LATCH_BC_0
+ port
*4,
12005 1 << NIG_LATCH_BC_ENABLE_MI_INT
);
12007 if (params
->phy
[INT_PHY
].link_reset
)
12008 params
->phy
[INT_PHY
].link_reset(
12009 ¶ms
->phy
[INT_PHY
], params
);
12011 /* disable nig ingress interface */
12012 if (!CHIP_IS_E3(bp
)) {
12014 REG_WR(bp
, GRCBASE_MISC
+ MISC_REGISTERS_RESET_REG_2_CLEAR
,
12015 (MISC_REGISTERS_RESET_REG_2_RST_BMAC0
<< port
));
12016 REG_WR(bp
, NIG_REG_BMAC0_IN_EN
+ port
*4, 0);
12017 REG_WR(bp
, NIG_REG_EMAC0_IN_EN
+ port
*4, 0);
12019 u32 xmac_base
= (params
->port
) ? GRCBASE_XMAC1
: GRCBASE_XMAC0
;
12020 bnx2x_set_xumac_nig(params
, 0, 0);
12021 if (REG_RD(bp
, MISC_REG_RESET_REG_2
) &
12022 MISC_REGISTERS_RESET_REG_2_XMAC
)
12023 REG_WR(bp
, xmac_base
+ XMAC_REG_CTRL
,
12024 XMAC_CTRL_REG_SOFT_RESET
);
12027 vars
->phy_flags
= 0;
12031 /****************************************************************************/
12032 /* Common function */
12033 /****************************************************************************/
12034 static int bnx2x_8073_common_init_phy(struct bnx2x
*bp
,
12035 u32 shmem_base_path
[],
12036 u32 shmem2_base_path
[], u8 phy_index
,
12039 struct bnx2x_phy phy
[PORT_MAX
];
12040 struct bnx2x_phy
*phy_blk
[PORT_MAX
];
12043 s8 port_of_path
= 0;
12044 u32 swap_val
, swap_override
;
12045 swap_val
= REG_RD(bp
, NIG_REG_PORT_SWAP
);
12046 swap_override
= REG_RD(bp
, NIG_REG_STRAP_OVERRIDE
);
12047 port
^= (swap_val
&& swap_override
);
12048 bnx2x_ext_phy_hw_reset(bp
, port
);
12049 /* PART1 - Reset both phys */
12050 for (port
= PORT_MAX
- 1; port
>= PORT_0
; port
--) {
12051 u32 shmem_base
, shmem2_base
;
12052 /* In E2, same phy is using for port0 of the two paths */
12053 if (CHIP_IS_E1x(bp
)) {
12054 shmem_base
= shmem_base_path
[0];
12055 shmem2_base
= shmem2_base_path
[0];
12056 port_of_path
= port
;
12058 shmem_base
= shmem_base_path
[port
];
12059 shmem2_base
= shmem2_base_path
[port
];
12063 /* Extract the ext phy address for the port */
12064 if (bnx2x_populate_phy(bp
, phy_index
, shmem_base
, shmem2_base
,
12065 port_of_path
, &phy
[port
]) !=
12067 DP(NETIF_MSG_LINK
, "populate_phy failed\n");
12070 /* disable attentions */
12071 bnx2x_bits_dis(bp
, NIG_REG_MASK_INTERRUPT_PORT0
+
12073 (NIG_MASK_XGXS0_LINK_STATUS
|
12074 NIG_MASK_XGXS0_LINK10G
|
12075 NIG_MASK_SERDES0_LINK_STATUS
|
12078 /* Need to take the phy out of low power mode in order
12079 to write to access its registers */
12080 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_2
,
12081 MISC_REGISTERS_GPIO_OUTPUT_HIGH
,
12084 /* Reset the phy */
12085 bnx2x_cl45_write(bp
, &phy
[port
],
12091 /* Add delay of 150ms after reset */
12094 if (phy
[PORT_0
].addr
& 0x1) {
12095 phy_blk
[PORT_0
] = &(phy
[PORT_1
]);
12096 phy_blk
[PORT_1
] = &(phy
[PORT_0
]);
12098 phy_blk
[PORT_0
] = &(phy
[PORT_0
]);
12099 phy_blk
[PORT_1
] = &(phy
[PORT_1
]);
12102 /* PART2 - Download firmware to both phys */
12103 for (port
= PORT_MAX
- 1; port
>= PORT_0
; port
--) {
12104 if (CHIP_IS_E1x(bp
))
12105 port_of_path
= port
;
12109 DP(NETIF_MSG_LINK
, "Loading spirom for phy address 0x%x\n",
12110 phy_blk
[port
]->addr
);
12111 if (bnx2x_8073_8727_external_rom_boot(bp
, phy_blk
[port
],
12115 /* Only set bit 10 = 1 (Tx power down) */
12116 bnx2x_cl45_read(bp
, phy_blk
[port
],
12118 MDIO_PMA_REG_TX_POWER_DOWN
, &val
);
12120 /* Phase1 of TX_POWER_DOWN reset */
12121 bnx2x_cl45_write(bp
, phy_blk
[port
],
12123 MDIO_PMA_REG_TX_POWER_DOWN
,
12128 * Toggle Transmitter: Power down and then up with 600ms delay
12133 /* PART3 - complete TX_POWER_DOWN process, and set GPIO2 back to low */
12134 for (port
= PORT_MAX
- 1; port
>= PORT_0
; port
--) {
12135 /* Phase2 of POWER_DOWN_RESET */
12136 /* Release bit 10 (Release Tx power down) */
12137 bnx2x_cl45_read(bp
, phy_blk
[port
],
12139 MDIO_PMA_REG_TX_POWER_DOWN
, &val
);
12141 bnx2x_cl45_write(bp
, phy_blk
[port
],
12143 MDIO_PMA_REG_TX_POWER_DOWN
, (val
& (~(1<<10))));
12146 /* Read modify write the SPI-ROM version select register */
12147 bnx2x_cl45_read(bp
, phy_blk
[port
],
12149 MDIO_PMA_REG_EDC_FFE_MAIN
, &val
);
12150 bnx2x_cl45_write(bp
, phy_blk
[port
],
12152 MDIO_PMA_REG_EDC_FFE_MAIN
, (val
| (1<<12)));
12154 /* set GPIO2 back to LOW */
12155 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_2
,
12156 MISC_REGISTERS_GPIO_OUTPUT_LOW
, port
);
12160 static int bnx2x_8726_common_init_phy(struct bnx2x
*bp
,
12161 u32 shmem_base_path
[],
12162 u32 shmem2_base_path
[], u8 phy_index
,
12167 struct bnx2x_phy phy
;
12168 /* Use port1 because of the static port-swap */
12169 /* Enable the module detection interrupt */
12170 val
= REG_RD(bp
, MISC_REG_GPIO_EVENT_EN
);
12171 val
|= ((1<<MISC_REGISTERS_GPIO_3
)|
12172 (1<<(MISC_REGISTERS_GPIO_3
+ MISC_REGISTERS_GPIO_PORT_SHIFT
)));
12173 REG_WR(bp
, MISC_REG_GPIO_EVENT_EN
, val
);
12175 bnx2x_ext_phy_hw_reset(bp
, 0);
12177 for (port
= 0; port
< PORT_MAX
; port
++) {
12178 u32 shmem_base
, shmem2_base
;
12180 /* In E2, same phy is using for port0 of the two paths */
12181 if (CHIP_IS_E1x(bp
)) {
12182 shmem_base
= shmem_base_path
[0];
12183 shmem2_base
= shmem2_base_path
[0];
12185 shmem_base
= shmem_base_path
[port
];
12186 shmem2_base
= shmem2_base_path
[port
];
12188 /* Extract the ext phy address for the port */
12189 if (bnx2x_populate_phy(bp
, phy_index
, shmem_base
, shmem2_base
,
12192 DP(NETIF_MSG_LINK
, "populate phy failed\n");
12197 bnx2x_cl45_write(bp
, &phy
,
12198 MDIO_PMA_DEVAD
, MDIO_PMA_REG_GEN_CTRL
, 0x0001);
12201 /* Set fault module detected LED on */
12202 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_0
,
12203 MISC_REGISTERS_GPIO_HIGH
,
12209 static void bnx2x_get_ext_phy_reset_gpio(struct bnx2x
*bp
, u32 shmem_base
,
12210 u8
*io_gpio
, u8
*io_port
)
12213 u32 phy_gpio_reset
= REG_RD(bp
, shmem_base
+
12214 offsetof(struct shmem_region
,
12215 dev_info
.port_hw_config
[PORT_0
].default_cfg
));
12216 switch (phy_gpio_reset
) {
12217 case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO0_P0
:
12221 case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO1_P0
:
12225 case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO2_P0
:
12229 case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO3_P0
:
12233 case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO0_P1
:
12237 case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO1_P1
:
12241 case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO2_P1
:
12245 case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO3_P1
:
12250 /* Don't override the io_gpio and io_port */
12255 static int bnx2x_8727_common_init_phy(struct bnx2x
*bp
,
12256 u32 shmem_base_path
[],
12257 u32 shmem2_base_path
[], u8 phy_index
,
12260 s8 port
, reset_gpio
;
12261 u32 swap_val
, swap_override
;
12262 struct bnx2x_phy phy
[PORT_MAX
];
12263 struct bnx2x_phy
*phy_blk
[PORT_MAX
];
12265 swap_val
= REG_RD(bp
, NIG_REG_PORT_SWAP
);
12266 swap_override
= REG_RD(bp
, NIG_REG_STRAP_OVERRIDE
);
12268 reset_gpio
= MISC_REGISTERS_GPIO_1
;
12272 * Retrieve the reset gpio/port which control the reset.
12273 * Default is GPIO1, PORT1
12275 bnx2x_get_ext_phy_reset_gpio(bp
, shmem_base_path
[0],
12276 (u8
*)&reset_gpio
, (u8
*)&port
);
12278 /* Calculate the port based on port swap */
12279 port
^= (swap_val
&& swap_override
);
12281 /* Initiate PHY reset*/
12282 bnx2x_set_gpio(bp
, reset_gpio
, MISC_REGISTERS_GPIO_OUTPUT_LOW
,
12285 bnx2x_set_gpio(bp
, reset_gpio
, MISC_REGISTERS_GPIO_OUTPUT_HIGH
,
12290 /* PART1 - Reset both phys */
12291 for (port
= PORT_MAX
- 1; port
>= PORT_0
; port
--) {
12292 u32 shmem_base
, shmem2_base
;
12294 /* In E2, same phy is using for port0 of the two paths */
12295 if (CHIP_IS_E1x(bp
)) {
12296 shmem_base
= shmem_base_path
[0];
12297 shmem2_base
= shmem2_base_path
[0];
12298 port_of_path
= port
;
12300 shmem_base
= shmem_base_path
[port
];
12301 shmem2_base
= shmem2_base_path
[port
];
12305 /* Extract the ext phy address for the port */
12306 if (bnx2x_populate_phy(bp
, phy_index
, shmem_base
, shmem2_base
,
12307 port_of_path
, &phy
[port
]) !=
12309 DP(NETIF_MSG_LINK
, "populate phy failed\n");
12312 /* disable attentions */
12313 bnx2x_bits_dis(bp
, NIG_REG_MASK_INTERRUPT_PORT0
+
12315 (NIG_MASK_XGXS0_LINK_STATUS
|
12316 NIG_MASK_XGXS0_LINK10G
|
12317 NIG_MASK_SERDES0_LINK_STATUS
|
12321 /* Reset the phy */
12322 bnx2x_cl45_write(bp
, &phy
[port
],
12323 MDIO_PMA_DEVAD
, MDIO_PMA_REG_CTRL
, 1<<15);
12326 /* Add delay of 150ms after reset */
12328 if (phy
[PORT_0
].addr
& 0x1) {
12329 phy_blk
[PORT_0
] = &(phy
[PORT_1
]);
12330 phy_blk
[PORT_1
] = &(phy
[PORT_0
]);
12332 phy_blk
[PORT_0
] = &(phy
[PORT_0
]);
12333 phy_blk
[PORT_1
] = &(phy
[PORT_1
]);
12335 /* PART2 - Download firmware to both phys */
12336 for (port
= PORT_MAX
- 1; port
>= PORT_0
; port
--) {
12337 if (CHIP_IS_E1x(bp
))
12338 port_of_path
= port
;
12341 DP(NETIF_MSG_LINK
, "Loading spirom for phy address 0x%x\n",
12342 phy_blk
[port
]->addr
);
12343 if (bnx2x_8073_8727_external_rom_boot(bp
, phy_blk
[port
],
12346 /* Disable PHY transmitter output */
12347 bnx2x_cl45_write(bp
, phy_blk
[port
],
12349 MDIO_PMA_REG_TX_DISABLE
, 1);
12355 static int bnx2x_84833_common_init_phy(struct bnx2x
*bp
,
12356 u32 shmem_base_path
[],
12357 u32 shmem2_base_path
[],
12362 reset_gpios
= bnx2x_84833_get_reset_gpios(bp
, shmem_base_path
, chip_id
);
12363 bnx2x_set_mult_gpio(bp
, reset_gpios
, MISC_REGISTERS_GPIO_OUTPUT_LOW
);
12365 bnx2x_set_mult_gpio(bp
, reset_gpios
, MISC_REGISTERS_GPIO_OUTPUT_HIGH
);
12366 DP(NETIF_MSG_LINK
, "84833 reset pulse on pin values 0x%x\n",
12371 static int bnx2x_84833_pre_init_phy(struct bnx2x
*bp
,
12372 struct bnx2x_phy
*phy
)
12375 /* Wait for FW completing its initialization. */
12376 for (cnt
= 0; cnt
< 1500; cnt
++) {
12377 bnx2x_cl45_read(bp
, phy
,
12379 MDIO_PMA_REG_CTRL
, &val
);
12380 if (!(val
& (1<<15)))
12385 DP(NETIF_MSG_LINK
, "84833 reset timeout\n");
12389 /* Put the port in super isolate mode. */
12390 bnx2x_cl45_read(bp
, phy
,
12392 MDIO_84833_TOP_CFG_XGPHY_STRAP1
, &val
);
12393 val
|= MDIO_84833_SUPER_ISOLATE
;
12394 bnx2x_cl45_write(bp
, phy
,
12396 MDIO_84833_TOP_CFG_XGPHY_STRAP1
, val
);
12398 /* Save spirom version */
12399 bnx2x_save_848xx_spirom_version(phy
, bp
, PORT_0
);
12403 int bnx2x_pre_init_phy(struct bnx2x
*bp
,
12409 struct bnx2x_phy phy
;
12410 bnx2x_set_mdio_clk(bp
, chip_id
, PORT_0
);
12411 if (bnx2x_populate_phy(bp
, EXT_PHY1
, shmem_base
, shmem2_base
,
12413 DP(NETIF_MSG_LINK
, "populate_phy failed\n");
12416 switch (phy
.type
) {
12417 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833
:
12418 rc
= bnx2x_84833_pre_init_phy(bp
, &phy
);
12426 static int bnx2x_ext_phy_common_init(struct bnx2x
*bp
, u32 shmem_base_path
[],
12427 u32 shmem2_base_path
[], u8 phy_index
,
12428 u32 ext_phy_type
, u32 chip_id
)
12432 switch (ext_phy_type
) {
12433 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073
:
12434 rc
= bnx2x_8073_common_init_phy(bp
, shmem_base_path
,
12436 phy_index
, chip_id
);
12438 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8722
:
12439 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727
:
12440 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727_NOC
:
12441 rc
= bnx2x_8727_common_init_phy(bp
, shmem_base_path
,
12443 phy_index
, chip_id
);
12446 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726
:
12448 * GPIO1 affects both ports, so there's need to pull
12449 * it for single port alone
12451 rc
= bnx2x_8726_common_init_phy(bp
, shmem_base_path
,
12453 phy_index
, chip_id
);
12455 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833
:
12457 * GPIO3's are linked, and so both need to be toggled
12458 * to obtain required 2us pulse.
12460 rc
= bnx2x_84833_common_init_phy(bp
, shmem_base_path
,
12462 phy_index
, chip_id
);
12464 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_FAILURE
:
12469 "ext_phy 0x%x common init not required\n",
12475 netdev_err(bp
->dev
, "Warning: PHY was not initialized,"
12481 int bnx2x_common_init_phy(struct bnx2x
*bp
, u32 shmem_base_path
[],
12482 u32 shmem2_base_path
[], u32 chip_id
)
12487 u32 ext_phy_type
, ext_phy_config
;
12488 bnx2x_set_mdio_clk(bp
, chip_id
, PORT_0
);
12489 bnx2x_set_mdio_clk(bp
, chip_id
, PORT_1
);
12490 DP(NETIF_MSG_LINK
, "Begin common phy init\n");
12491 if (CHIP_IS_E3(bp
)) {
12493 val
= REG_RD(bp
, MISC_REG_GEN_PURP_HWG
);
12494 REG_WR(bp
, MISC_REG_GEN_PURP_HWG
, val
| 1);
12496 /* Check if common init was already done */
12497 phy_ver
= REG_RD(bp
, shmem_base_path
[0] +
12498 offsetof(struct shmem_region
,
12499 port_mb
[PORT_0
].ext_phy_fw_version
));
12501 DP(NETIF_MSG_LINK
, "Not doing common init; phy ver is 0x%x\n",
12506 /* Read the ext_phy_type for arbitrary port(0) */
12507 for (phy_index
= EXT_PHY1
; phy_index
< MAX_PHYS
;
12509 ext_phy_config
= bnx2x_get_ext_phy_config(bp
,
12510 shmem_base_path
[0],
12512 ext_phy_type
= XGXS_EXT_PHY_TYPE(ext_phy_config
);
12513 rc
|= bnx2x_ext_phy_common_init(bp
, shmem_base_path
,
12515 phy_index
, ext_phy_type
,
12521 static void bnx2x_check_over_curr(struct link_params
*params
,
12522 struct link_vars
*vars
)
12524 struct bnx2x
*bp
= params
->bp
;
12526 u8 port
= params
->port
;
12529 cfg_pin
= (REG_RD(bp
, params
->shmem_base
+
12530 offsetof(struct shmem_region
,
12531 dev_info
.port_hw_config
[port
].e3_cmn_pin_cfg1
)) &
12532 PORT_HW_CFG_E3_OVER_CURRENT_MASK
) >>
12533 PORT_HW_CFG_E3_OVER_CURRENT_SHIFT
;
12535 /* Ignore check if no external input PIN available */
12536 if (bnx2x_get_cfg_pin(bp
, cfg_pin
, &pin_val
) != 0)
12540 if ((vars
->phy_flags
& PHY_OVER_CURRENT_FLAG
) == 0) {
12541 netdev_err(bp
->dev
, "Error: Power fault on Port %d has"
12542 " been detected and the power to "
12543 "that SFP+ module has been removed"
12544 " to prevent failure of the card."
12545 " Please remove the SFP+ module and"
12546 " restart the system to clear this"
12549 vars
->phy_flags
|= PHY_OVER_CURRENT_FLAG
;
12552 vars
->phy_flags
&= ~PHY_OVER_CURRENT_FLAG
;
12555 static void bnx2x_analyze_link_error(struct link_params
*params
,
12556 struct link_vars
*vars
, u32 lss_status
)
12558 struct bnx2x
*bp
= params
->bp
;
12559 /* Compare new value with previous value */
12561 u32 half_open_conn
= (vars
->phy_flags
& PHY_HALF_OPEN_CONN_FLAG
) > 0;
12563 if ((lss_status
^ half_open_conn
) == 0)
12566 /* If values differ */
12567 DP(NETIF_MSG_LINK
, "Link changed:%x %x->%x\n", vars
->link_up
,
12568 half_open_conn
, lss_status
);
12571 * a. Update shmem->link_status accordingly
12572 * b. Update link_vars->link_up
12575 DP(NETIF_MSG_LINK
, "Remote Fault detected !!!\n");
12576 vars
->link_status
&= ~LINK_STATUS_LINK_UP
;
12578 vars
->phy_flags
|= PHY_HALF_OPEN_CONN_FLAG
;
12580 * Set LED mode to off since the PHY doesn't know about these
12583 led_mode
= LED_MODE_OFF
;
12585 DP(NETIF_MSG_LINK
, "Remote Fault cleared\n");
12586 vars
->link_status
|= LINK_STATUS_LINK_UP
;
12588 vars
->phy_flags
&= ~PHY_HALF_OPEN_CONN_FLAG
;
12589 led_mode
= LED_MODE_OPER
;
12591 /* Update the LED according to the link state */
12592 bnx2x_set_led(params
, vars
, led_mode
, SPEED_10000
);
12594 /* Update link status in the shared memory */
12595 bnx2x_update_mng(params
, vars
->link_status
);
12597 /* C. Trigger General Attention */
12598 vars
->periodic_flags
|= PERIODIC_FLAGS_LINK_EVENT
;
12599 bnx2x_notify_link_changed(bp
);
12602 /******************************************************************************
12604 * This function checks for half opened connection change indication.
12605 * When such change occurs, it calls the bnx2x_analyze_link_error
12606 * to check if Remote Fault is set or cleared. Reception of remote fault
12607 * status message in the MAC indicates that the peer's MAC has detected
12608 * a fault, for example, due to break in the TX side of fiber.
12610 ******************************************************************************/
12611 static void bnx2x_check_half_open_conn(struct link_params
*params
,
12612 struct link_vars
*vars
)
12614 struct bnx2x
*bp
= params
->bp
;
12615 u32 lss_status
= 0;
12617 /* In case link status is physically up @ 10G do */
12618 if ((vars
->phy_flags
& PHY_PHYSICAL_LINK_FLAG
) == 0)
12621 if (CHIP_IS_E3(bp
) &&
12622 (REG_RD(bp
, MISC_REG_RESET_REG_2
) &
12623 (MISC_REGISTERS_RESET_REG_2_XMAC
))) {
12624 /* Check E3 XMAC */
12626 * Note that link speed cannot be queried here, since it may be
12627 * zero while link is down. In case UMAC is active, LSS will
12628 * simply not be set
12630 mac_base
= (params
->port
) ? GRCBASE_XMAC1
: GRCBASE_XMAC0
;
12632 /* Clear stick bits (Requires rising edge) */
12633 REG_WR(bp
, mac_base
+ XMAC_REG_CLEAR_RX_LSS_STATUS
, 0);
12634 REG_WR(bp
, mac_base
+ XMAC_REG_CLEAR_RX_LSS_STATUS
,
12635 XMAC_CLEAR_RX_LSS_STATUS_REG_CLEAR_LOCAL_FAULT_STATUS
|
12636 XMAC_CLEAR_RX_LSS_STATUS_REG_CLEAR_REMOTE_FAULT_STATUS
);
12637 if (REG_RD(bp
, mac_base
+ XMAC_REG_RX_LSS_STATUS
))
12640 bnx2x_analyze_link_error(params
, vars
, lss_status
);
12641 } else if (REG_RD(bp
, MISC_REG_RESET_REG_2
) &
12642 (MISC_REGISTERS_RESET_REG_2_RST_BMAC0
<< params
->port
)) {
12643 /* Check E1X / E2 BMAC */
12644 u32 lss_status_reg
;
12646 mac_base
= params
->port
? NIG_REG_INGRESS_BMAC1_MEM
:
12647 NIG_REG_INGRESS_BMAC0_MEM
;
12648 /* Read BIGMAC_REGISTER_RX_LSS_STATUS */
12649 if (CHIP_IS_E2(bp
))
12650 lss_status_reg
= BIGMAC2_REGISTER_RX_LSS_STAT
;
12652 lss_status_reg
= BIGMAC_REGISTER_RX_LSS_STATUS
;
12654 REG_RD_DMAE(bp
, mac_base
+ lss_status_reg
, wb_data
, 2);
12655 lss_status
= (wb_data
[0] > 0);
12657 bnx2x_analyze_link_error(params
, vars
, lss_status
);
12661 void bnx2x_period_func(struct link_params
*params
, struct link_vars
*vars
)
12663 struct bnx2x
*bp
= params
->bp
;
12665 for (phy_idx
= INT_PHY
; phy_idx
< MAX_PHYS
; phy_idx
++) {
12666 if (params
->phy
[phy_idx
].flags
& FLAGS_TX_ERROR_CHECK
) {
12667 bnx2x_set_aer_mmd(params
, ¶ms
->phy
[phy_idx
]);
12668 bnx2x_check_half_open_conn(params
, vars
);
12673 if (CHIP_IS_E3(bp
)) {
12674 struct bnx2x_phy
*phy
= ¶ms
->phy
[INT_PHY
];
12675 bnx2x_set_aer_mmd(params
, phy
);
12676 bnx2x_check_over_curr(params
, vars
);
12677 bnx2x_warpcore_config_runtime(phy
, params
, vars
);
12682 u8
bnx2x_hw_lock_required(struct bnx2x
*bp
, u32 shmem_base
, u32 shmem2_base
)
12685 struct bnx2x_phy phy
;
12686 for (phy_index
= INT_PHY
; phy_index
< MAX_PHYS
;
12688 if (bnx2x_populate_phy(bp
, phy_index
, shmem_base
, shmem2_base
,
12690 DP(NETIF_MSG_LINK
, "populate phy failed\n");
12694 if (phy
.flags
& FLAGS_HW_LOCK_REQUIRED
)
12700 u8
bnx2x_fan_failure_det_req(struct bnx2x
*bp
,
12705 u8 phy_index
, fan_failure_det_req
= 0;
12706 struct bnx2x_phy phy
;
12707 for (phy_index
= EXT_PHY1
; phy_index
< MAX_PHYS
;
12709 if (bnx2x_populate_phy(bp
, phy_index
, shmem_base
, shmem2_base
,
12712 DP(NETIF_MSG_LINK
, "populate phy failed\n");
12715 fan_failure_det_req
|= (phy
.flags
&
12716 FLAGS_FAN_FAILURE_DET_REQ
);
12718 return fan_failure_det_req
;
12721 void bnx2x_hw_reset_phy(struct link_params
*params
)
12724 struct bnx2x
*bp
= params
->bp
;
12725 bnx2x_update_mng(params
, 0);
12726 bnx2x_bits_dis(bp
, NIG_REG_MASK_INTERRUPT_PORT0
+ params
->port
*4,
12727 (NIG_MASK_XGXS0_LINK_STATUS
|
12728 NIG_MASK_XGXS0_LINK10G
|
12729 NIG_MASK_SERDES0_LINK_STATUS
|
12732 for (phy_index
= INT_PHY
; phy_index
< MAX_PHYS
;
12734 if (params
->phy
[phy_index
].hw_reset
) {
12735 params
->phy
[phy_index
].hw_reset(
12736 ¶ms
->phy
[phy_index
],
12738 params
->phy
[phy_index
] = phy_null
;
12743 void bnx2x_init_mod_abs_int(struct bnx2x
*bp
, struct link_vars
*vars
,
12744 u32 chip_id
, u32 shmem_base
, u32 shmem2_base
,
12747 u8 gpio_num
= 0xff, gpio_port
= 0xff, phy_index
;
12749 u32 offset
, aeu_mask
, swap_val
, swap_override
, sync_offset
;
12750 if (CHIP_IS_E3(bp
)) {
12751 if (bnx2x_get_mod_abs_int_cfg(bp
, chip_id
,
12758 struct bnx2x_phy phy
;
12759 for (phy_index
= EXT_PHY1
; phy_index
< MAX_PHYS
;
12761 if (bnx2x_populate_phy(bp
, phy_index
, shmem_base
,
12762 shmem2_base
, port
, &phy
)
12764 DP(NETIF_MSG_LINK
, "populate phy failed\n");
12767 if (phy
.type
== PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726
) {
12768 gpio_num
= MISC_REGISTERS_GPIO_3
;
12775 if (gpio_num
== 0xff)
12778 /* Set GPIO3 to trigger SFP+ module insertion/removal */
12779 bnx2x_set_gpio(bp
, gpio_num
, MISC_REGISTERS_GPIO_INPUT_HI_Z
, gpio_port
);
12781 swap_val
= REG_RD(bp
, NIG_REG_PORT_SWAP
);
12782 swap_override
= REG_RD(bp
, NIG_REG_STRAP_OVERRIDE
);
12783 gpio_port
^= (swap_val
&& swap_override
);
12785 vars
->aeu_int_mask
= AEU_INPUTS_ATTN_BITS_GPIO0_FUNCTION_0
<<
12786 (gpio_num
+ (gpio_port
<< 2));
12788 sync_offset
= shmem_base
+
12789 offsetof(struct shmem_region
,
12790 dev_info
.port_hw_config
[port
].aeu_int_mask
);
12791 REG_WR(bp
, sync_offset
, vars
->aeu_int_mask
);
12793 DP(NETIF_MSG_LINK
, "Setting MOD_ABS (GPIO%d_P%d) AEU to 0x%x\n",
12794 gpio_num
, gpio_port
, vars
->aeu_int_mask
);
12797 offset
= MISC_REG_AEU_ENABLE1_FUNC_0_OUT_0
;
12799 offset
= MISC_REG_AEU_ENABLE1_FUNC_1_OUT_0
;
12801 /* Open appropriate AEU for interrupts */
12802 aeu_mask
= REG_RD(bp
, offset
);
12803 aeu_mask
|= vars
->aeu_int_mask
;
12804 REG_WR(bp
, offset
, aeu_mask
);
12806 /* Enable the GPIO to trigger interrupt */
12807 val
= REG_RD(bp
, MISC_REG_GPIO_EVENT_EN
);
12808 val
|= 1 << (gpio_num
+ (gpio_port
<< 2));
12809 REG_WR(bp
, MISC_REG_GPIO_EVENT_EN
, val
);