1 /* Copyright 2008-2009 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>
29 /********************************************************/
31 #define ETH_OVREHEAD (ETH_HLEN + 8 + 8)/* 16 for CRC + VLAN + LLC */
32 #define ETH_MIN_PACKET_SIZE 60
33 #define ETH_MAX_PACKET_SIZE 1500
34 #define ETH_MAX_JUMBO_PACKET_SIZE 9600
35 #define MDIO_ACCESS_TIMEOUT 1000
36 #define BMAC_CONTROL_RX_ENABLE 2
38 /***********************************************************/
39 /* Shortcut definitions */
40 /***********************************************************/
42 #define NIG_LATCH_BC_ENABLE_MI_INT 0
44 #define NIG_STATUS_EMAC0_MI_INT \
45 NIG_STATUS_INTERRUPT_PORT0_REG_STATUS_EMAC0_MISC_MI_INT
46 #define NIG_STATUS_XGXS0_LINK10G \
47 NIG_STATUS_INTERRUPT_PORT0_REG_STATUS_XGXS0_LINK10G
48 #define NIG_STATUS_XGXS0_LINK_STATUS \
49 NIG_STATUS_INTERRUPT_PORT0_REG_STATUS_XGXS0_LINK_STATUS
50 #define NIG_STATUS_XGXS0_LINK_STATUS_SIZE \
51 NIG_STATUS_INTERRUPT_PORT0_REG_STATUS_XGXS0_LINK_STATUS_SIZE
52 #define NIG_STATUS_SERDES0_LINK_STATUS \
53 NIG_STATUS_INTERRUPT_PORT0_REG_STATUS_SERDES0_LINK_STATUS
54 #define NIG_MASK_MI_INT \
55 NIG_MASK_INTERRUPT_PORT0_REG_MASK_EMAC0_MISC_MI_INT
56 #define NIG_MASK_XGXS0_LINK10G \
57 NIG_MASK_INTERRUPT_PORT0_REG_MASK_XGXS0_LINK10G
58 #define NIG_MASK_XGXS0_LINK_STATUS \
59 NIG_MASK_INTERRUPT_PORT0_REG_MASK_XGXS0_LINK_STATUS
60 #define NIG_MASK_SERDES0_LINK_STATUS \
61 NIG_MASK_INTERRUPT_PORT0_REG_MASK_SERDES0_LINK_STATUS
63 #define MDIO_AN_CL73_OR_37_COMPLETE \
64 (MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_AUTONEG_COMPLETE | \
65 MDIO_GP_STATUS_TOP_AN_STATUS1_CL37_AUTONEG_COMPLETE)
67 #define XGXS_RESET_BITS \
68 (MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_XGXS0_RSTB_HW | \
69 MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_XGXS0_IDDQ | \
70 MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_XGXS0_PWRDWN | \
71 MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_XGXS0_PWRDWN_SD | \
72 MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_XGXS0_TXD_FIFO_RSTB)
74 #define SERDES_RESET_BITS \
75 (MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_SERDES0_RSTB_HW | \
76 MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_SERDES0_IDDQ | \
77 MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_SERDES0_PWRDWN | \
78 MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_SERDES0_PWRDWN_SD)
80 #define AUTONEG_CL37 SHARED_HW_CFG_AN_ENABLE_CL37
81 #define AUTONEG_CL73 SHARED_HW_CFG_AN_ENABLE_CL73
82 #define AUTONEG_BAM SHARED_HW_CFG_AN_ENABLE_BAM
83 #define AUTONEG_PARALLEL \
84 SHARED_HW_CFG_AN_ENABLE_PARALLEL_DETECTION
85 #define AUTONEG_SGMII_FIBER_AUTODET \
86 SHARED_HW_CFG_AN_EN_SGMII_FIBER_AUTO_DETECT
87 #define AUTONEG_REMOTE_PHY SHARED_HW_CFG_AN_ENABLE_REMOTE_PHY
89 #define GP_STATUS_PAUSE_RSOLUTION_TXSIDE \
90 MDIO_GP_STATUS_TOP_AN_STATUS1_PAUSE_RSOLUTION_TXSIDE
91 #define GP_STATUS_PAUSE_RSOLUTION_RXSIDE \
92 MDIO_GP_STATUS_TOP_AN_STATUS1_PAUSE_RSOLUTION_RXSIDE
93 #define GP_STATUS_SPEED_MASK \
94 MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_MASK
95 #define GP_STATUS_10M MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_10M
96 #define GP_STATUS_100M MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_100M
97 #define GP_STATUS_1G MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_1G
98 #define GP_STATUS_2_5G MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_2_5G
99 #define GP_STATUS_5G MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_5G
100 #define GP_STATUS_6G MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_6G
101 #define GP_STATUS_10G_HIG \
102 MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_10G_HIG
103 #define GP_STATUS_10G_CX4 \
104 MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_10G_CX4
105 #define GP_STATUS_12G_HIG \
106 MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_12G_HIG
107 #define GP_STATUS_12_5G MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_12_5G
108 #define GP_STATUS_13G MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_13G
109 #define GP_STATUS_15G MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_15G
110 #define GP_STATUS_16G MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_16G
111 #define GP_STATUS_1G_KX MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_1G_KX
112 #define GP_STATUS_10G_KX4 \
113 MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_10G_KX4
115 #define LINK_10THD LINK_STATUS_SPEED_AND_DUPLEX_10THD
116 #define LINK_10TFD LINK_STATUS_SPEED_AND_DUPLEX_10TFD
117 #define LINK_100TXHD LINK_STATUS_SPEED_AND_DUPLEX_100TXHD
118 #define LINK_100T4 LINK_STATUS_SPEED_AND_DUPLEX_100T4
119 #define LINK_100TXFD LINK_STATUS_SPEED_AND_DUPLEX_100TXFD
120 #define LINK_1000THD LINK_STATUS_SPEED_AND_DUPLEX_1000THD
121 #define LINK_1000TFD LINK_STATUS_SPEED_AND_DUPLEX_1000TFD
122 #define LINK_1000XFD LINK_STATUS_SPEED_AND_DUPLEX_1000XFD
123 #define LINK_2500THD LINK_STATUS_SPEED_AND_DUPLEX_2500THD
124 #define LINK_2500TFD LINK_STATUS_SPEED_AND_DUPLEX_2500TFD
125 #define LINK_2500XFD LINK_STATUS_SPEED_AND_DUPLEX_2500XFD
126 #define LINK_10GTFD LINK_STATUS_SPEED_AND_DUPLEX_10GTFD
127 #define LINK_10GXFD LINK_STATUS_SPEED_AND_DUPLEX_10GXFD
128 #define LINK_12GTFD LINK_STATUS_SPEED_AND_DUPLEX_12GTFD
129 #define LINK_12GXFD LINK_STATUS_SPEED_AND_DUPLEX_12GXFD
130 #define LINK_12_5GTFD LINK_STATUS_SPEED_AND_DUPLEX_12_5GTFD
131 #define LINK_12_5GXFD LINK_STATUS_SPEED_AND_DUPLEX_12_5GXFD
132 #define LINK_13GTFD LINK_STATUS_SPEED_AND_DUPLEX_13GTFD
133 #define LINK_13GXFD LINK_STATUS_SPEED_AND_DUPLEX_13GXFD
134 #define LINK_15GTFD LINK_STATUS_SPEED_AND_DUPLEX_15GTFD
135 #define LINK_15GXFD LINK_STATUS_SPEED_AND_DUPLEX_15GXFD
136 #define LINK_16GTFD LINK_STATUS_SPEED_AND_DUPLEX_16GTFD
137 #define LINK_16GXFD LINK_STATUS_SPEED_AND_DUPLEX_16GXFD
139 #define PHY_XGXS_FLAG 0x1
140 #define PHY_SGMII_FLAG 0x2
141 #define PHY_SERDES_FLAG 0x4
144 #define SFP_EEPROM_CON_TYPE_ADDR 0x2
145 #define SFP_EEPROM_CON_TYPE_VAL_LC 0x7
146 #define SFP_EEPROM_CON_TYPE_VAL_COPPER 0x21
149 #define SFP_EEPROM_COMP_CODE_ADDR 0x3
150 #define SFP_EEPROM_COMP_CODE_SR_MASK (1<<4)
151 #define SFP_EEPROM_COMP_CODE_LR_MASK (1<<5)
152 #define SFP_EEPROM_COMP_CODE_LRM_MASK (1<<6)
154 #define SFP_EEPROM_FC_TX_TECH_ADDR 0x8
155 #define SFP_EEPROM_FC_TX_TECH_BITMASK_COPPER_PASSIVE 0x4
156 #define SFP_EEPROM_FC_TX_TECH_BITMASK_COPPER_ACTIVE 0x8
158 #define SFP_EEPROM_OPTIONS_ADDR 0x40
159 #define SFP_EEPROM_OPTIONS_LINEAR_RX_OUT_MASK 0x1
160 #define SFP_EEPROM_OPTIONS_SIZE 2
162 #define EDC_MODE_LINEAR 0x0022
163 #define EDC_MODE_LIMITING 0x0044
164 #define EDC_MODE_PASSIVE_DAC 0x0055
167 #define ETS_BW_LIMIT_CREDIT_UPPER_BOUND (0x5000)
168 #define ETS_BW_LIMIT_CREDIT_WEIGHT (0x5000)
169 /**********************************************************/
171 /**********************************************************/
173 #define CL45_WR_OVER_CL22(_bp, _phy, _bank, _addr, _val) \
174 bnx2x_cl45_write(_bp, _phy, \
175 (_phy)->def_md_devad, \
176 (_bank + (_addr & 0xf)), \
179 #define CL45_RD_OVER_CL22(_bp, _phy, _bank, _addr, _val) \
180 bnx2x_cl45_read(_bp, _phy, \
181 (_phy)->def_md_devad, \
182 (_bank + (_addr & 0xf)), \
185 static u8
bnx2x_cl45_read(struct bnx2x
*bp
, struct bnx2x_phy
*phy
,
186 u8 devad
, u16 reg
, u16
*ret_val
);
188 static u8
bnx2x_cl45_write(struct bnx2x
*bp
, struct bnx2x_phy
*phy
,
189 u8 devad
, u16 reg
, u16 val
);
191 static u32
bnx2x_bits_en(struct bnx2x
*bp
, u32 reg
, u32 bits
)
193 u32 val
= REG_RD(bp
, reg
);
196 REG_WR(bp
, reg
, val
);
200 static u32
bnx2x_bits_dis(struct bnx2x
*bp
, u32 reg
, u32 bits
)
202 u32 val
= REG_RD(bp
, reg
);
205 REG_WR(bp
, reg
, val
);
209 /******************************************************************/
211 /******************************************************************/
212 void bnx2x_ets_disabled(struct link_params
*params
)
214 /* ETS disabled configuration*/
215 struct bnx2x
*bp
= params
->bp
;
217 DP(NETIF_MSG_LINK
, "ETS disabled configuration\n");
220 * mapping between entry priority to client number (0,1,2 -debug and
221 * management clients, 3 - COS0 client, 4 - COS client)(HIGHEST)
223 * PRI4 | PRI3 | PRI2 | PRI1 | PRI0
224 * cos1-100 cos0-011 dbg1-010 dbg0-001 MCP-000
227 REG_WR(bp
, NIG_REG_P0_TX_ARB_PRIORITY_CLIENT
, 0x4688);
229 * Bitmap of 5bits length. Each bit specifies whether the entry behaves
230 * as strict. Bits 0,1,2 - debug and management entries, 3 -
231 * COS0 entry, 4 - COS1 entry.
232 * COS1 | COS0 | DEBUG1 | DEBUG0 | MGMT
233 * bit4 bit3 bit2 bit1 bit0
234 * MCP and debug are strict
237 REG_WR(bp
, NIG_REG_P0_TX_ARB_CLIENT_IS_STRICT
, 0x7);
238 /* defines which entries (clients) are subjected to WFQ arbitration */
239 REG_WR(bp
, NIG_REG_P0_TX_ARB_CLIENT_IS_SUBJECT2WFQ
, 0);
241 * For strict priority entries defines the number of consecutive
242 * slots for the highest priority.
244 REG_WR(bp
, NIG_REG_P0_TX_ARB_NUM_STRICT_ARB_SLOTS
, 0x100);
246 * mapping between the CREDIT_WEIGHT registers and actual client
249 REG_WR(bp
, NIG_REG_P0_TX_ARB_CLIENT_CREDIT_MAP
, 0);
250 REG_WR(bp
, NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_0
, 0);
251 REG_WR(bp
, NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_1
, 0);
253 REG_WR(bp
, NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_0
, 0);
254 REG_WR(bp
, NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_1
, 0);
255 REG_WR(bp
, PBF_REG_HIGH_PRIORITY_COS_NUM
, 0);
256 /* ETS mode disable */
257 REG_WR(bp
, PBF_REG_ETS_ENABLED
, 0);
259 * If ETS mode is enabled (there is no strict priority) defines a WFQ
260 * weight for COS0/COS1.
262 REG_WR(bp
, PBF_REG_COS0_WEIGHT
, 0x2710);
263 REG_WR(bp
, PBF_REG_COS1_WEIGHT
, 0x2710);
264 /* Upper bound that COS0_WEIGHT can reach in the WFQ arbiter */
265 REG_WR(bp
, PBF_REG_COS0_UPPER_BOUND
, 0x989680);
266 REG_WR(bp
, PBF_REG_COS1_UPPER_BOUND
, 0x989680);
267 /* Defines the number of consecutive slots for the strict priority */
268 REG_WR(bp
, PBF_REG_NUM_STRICT_ARB_SLOTS
, 0);
271 void bnx2x_ets_bw_limit_common(const struct link_params
*params
)
273 /* ETS disabled configuration */
274 struct bnx2x
*bp
= params
->bp
;
275 DP(NETIF_MSG_LINK
, "ETS enabled BW limit configuration\n");
277 * defines which entries (clients) are subjected to WFQ arbitration
281 REG_WR(bp
, NIG_REG_P0_TX_ARB_CLIENT_IS_SUBJECT2WFQ
, 0x18);
283 * mapping between the ARB_CREDIT_WEIGHT registers and actual
284 * client numbers (WEIGHT_0 does not actually have to represent
286 * PRI4 | PRI3 | PRI2 | PRI1 | PRI0
287 * cos1-001 cos0-000 dbg1-100 dbg0-011 MCP-010
289 REG_WR(bp
, NIG_REG_P0_TX_ARB_CLIENT_CREDIT_MAP
, 0x111A);
291 REG_WR(bp
, NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_0
,
292 ETS_BW_LIMIT_CREDIT_UPPER_BOUND
);
293 REG_WR(bp
, NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_1
,
294 ETS_BW_LIMIT_CREDIT_UPPER_BOUND
);
296 /* ETS mode enabled*/
297 REG_WR(bp
, PBF_REG_ETS_ENABLED
, 1);
299 /* Defines the number of consecutive slots for the strict priority */
300 REG_WR(bp
, PBF_REG_NUM_STRICT_ARB_SLOTS
, 0);
302 * Bitmap of 5bits length. Each bit specifies whether the entry behaves
303 * as strict. Bits 0,1,2 - debug and management entries, 3 - COS0
304 * entry, 4 - COS1 entry.
305 * COS1 | COS0 | DEBUG21 | DEBUG0 | MGMT
306 * bit4 bit3 bit2 bit1 bit0
307 * MCP and debug are strict
309 REG_WR(bp
, NIG_REG_P0_TX_ARB_CLIENT_IS_STRICT
, 0x7);
311 /* Upper bound that COS0_WEIGHT can reach in the WFQ arbiter.*/
312 REG_WR(bp
, PBF_REG_COS0_UPPER_BOUND
,
313 ETS_BW_LIMIT_CREDIT_UPPER_BOUND
);
314 REG_WR(bp
, PBF_REG_COS1_UPPER_BOUND
,
315 ETS_BW_LIMIT_CREDIT_UPPER_BOUND
);
318 void bnx2x_ets_bw_limit(const struct link_params
*params
, const u32 cos0_bw
,
321 /* ETS disabled configuration*/
322 struct bnx2x
*bp
= params
->bp
;
323 const u32 total_bw
= cos0_bw
+ cos1_bw
;
324 u32 cos0_credit_weight
= 0;
325 u32 cos1_credit_weight
= 0;
327 DP(NETIF_MSG_LINK
, "ETS enabled BW limit configuration\n");
329 if ((0 == total_bw
) ||
333 "bnx2x_ets_bw_limit: Total BW can't be zero\n");
337 cos0_credit_weight
= (cos0_bw
* ETS_BW_LIMIT_CREDIT_WEIGHT
)/
339 cos1_credit_weight
= (cos1_bw
* ETS_BW_LIMIT_CREDIT_WEIGHT
)/
342 bnx2x_ets_bw_limit_common(params
);
344 REG_WR(bp
, NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_0
, cos0_credit_weight
);
345 REG_WR(bp
, NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_1
, cos1_credit_weight
);
347 REG_WR(bp
, PBF_REG_COS0_WEIGHT
, cos0_credit_weight
);
348 REG_WR(bp
, PBF_REG_COS1_WEIGHT
, cos1_credit_weight
);
351 u8
bnx2x_ets_strict(const struct link_params
*params
, const u8 strict_cos
)
353 /* ETS disabled configuration*/
354 struct bnx2x
*bp
= params
->bp
;
357 DP(NETIF_MSG_LINK
, "ETS enabled strict configuration\n");
359 * Bitmap of 5bits length. Each bit specifies whether the entry behaves
360 * as strict. Bits 0,1,2 - debug and management entries,
361 * 3 - COS0 entry, 4 - COS1 entry.
362 * COS1 | COS0 | DEBUG21 | DEBUG0 | MGMT
363 * bit4 bit3 bit2 bit1 bit0
364 * MCP and debug are strict
366 REG_WR(bp
, NIG_REG_P0_TX_ARB_CLIENT_IS_STRICT
, 0x1F);
368 * For strict priority entries defines the number of consecutive slots
369 * for the highest priority.
371 REG_WR(bp
, NIG_REG_P0_TX_ARB_NUM_STRICT_ARB_SLOTS
, 0x100);
372 /* ETS mode disable */
373 REG_WR(bp
, PBF_REG_ETS_ENABLED
, 0);
374 /* Defines the number of consecutive slots for the strict priority */
375 REG_WR(bp
, PBF_REG_NUM_STRICT_ARB_SLOTS
, 0x100);
377 /* Defines the number of consecutive slots for the strict priority */
378 REG_WR(bp
, PBF_REG_HIGH_PRIORITY_COS_NUM
, strict_cos
);
381 * mapping between entry priority to client number (0,1,2 -debug and
382 * management clients, 3 - COS0 client, 4 - COS client)(HIGHEST)
384 * PRI4 | PRI3 | PRI2 | PRI1 | PRI0
385 * dbg0-010 dbg1-001 cos1-100 cos0-011 MCP-000
386 * dbg0-010 dbg1-001 cos0-011 cos1-100 MCP-000
388 val
= (0 == strict_cos
) ? 0x2318 : 0x22E0;
389 REG_WR(bp
, NIG_REG_P0_TX_ARB_PRIORITY_CLIENT
, val
);
393 /******************************************************************/
395 /******************************************************************/
397 static void bnx2x_bmac2_get_pfc_stat(struct link_params
*params
,
398 u32 pfc_frames_sent
[2],
399 u32 pfc_frames_received
[2])
401 /* Read pfc statistic */
402 struct bnx2x
*bp
= params
->bp
;
403 u32 bmac_addr
= params
->port
? NIG_REG_INGRESS_BMAC1_MEM
:
404 NIG_REG_INGRESS_BMAC0_MEM
;
406 DP(NETIF_MSG_LINK
, "pfc statistic read from BMAC\n");
408 REG_RD_DMAE(bp
, bmac_addr
+ BIGMAC2_REGISTER_TX_STAT_GTPP
,
411 REG_RD_DMAE(bp
, bmac_addr
+ BIGMAC2_REGISTER_RX_STAT_GRPP
,
412 pfc_frames_received
, 2);
415 static void bnx2x_emac_get_pfc_stat(struct link_params
*params
,
416 u32 pfc_frames_sent
[2],
417 u32 pfc_frames_received
[2])
419 /* Read pfc statistic */
420 struct bnx2x
*bp
= params
->bp
;
421 u32 emac_base
= params
->port
? GRCBASE_EMAC1
: GRCBASE_EMAC0
;
425 DP(NETIF_MSG_LINK
, "pfc statistic read from EMAC\n");
427 /* PFC received frames */
428 val_xoff
= REG_RD(bp
, emac_base
+
429 EMAC_REG_RX_PFC_STATS_XOFF_RCVD
);
430 val_xoff
&= EMAC_REG_RX_PFC_STATS_XOFF_RCVD_COUNT
;
431 val_xon
= REG_RD(bp
, emac_base
+ EMAC_REG_RX_PFC_STATS_XON_RCVD
);
432 val_xon
&= EMAC_REG_RX_PFC_STATS_XON_RCVD_COUNT
;
434 pfc_frames_received
[0] = val_xon
+ val_xoff
;
436 /* PFC received sent */
437 val_xoff
= REG_RD(bp
, emac_base
+
438 EMAC_REG_RX_PFC_STATS_XOFF_SENT
);
439 val_xoff
&= EMAC_REG_RX_PFC_STATS_XOFF_SENT_COUNT
;
440 val_xon
= REG_RD(bp
, emac_base
+ EMAC_REG_RX_PFC_STATS_XON_SENT
);
441 val_xon
&= EMAC_REG_RX_PFC_STATS_XON_SENT_COUNT
;
443 pfc_frames_sent
[0] = val_xon
+ val_xoff
;
446 void bnx2x_pfc_statistic(struct link_params
*params
, struct link_vars
*vars
,
447 u32 pfc_frames_sent
[2],
448 u32 pfc_frames_received
[2])
450 /* Read pfc statistic */
451 struct bnx2x
*bp
= params
->bp
;
453 DP(NETIF_MSG_LINK
, "pfc statistic\n");
458 val
= REG_RD(bp
, MISC_REG_RESET_REG_2
);
459 if ((val
& (MISC_REGISTERS_RESET_REG_2_RST_BMAC0
<< params
->port
))
461 DP(NETIF_MSG_LINK
, "About to read stats from EMAC\n");
462 bnx2x_emac_get_pfc_stat(params
, pfc_frames_sent
,
463 pfc_frames_received
);
465 DP(NETIF_MSG_LINK
, "About to read stats from BMAC\n");
466 bnx2x_bmac2_get_pfc_stat(params
, pfc_frames_sent
,
467 pfc_frames_received
);
470 /******************************************************************/
471 /* MAC/PBF section */
472 /******************************************************************/
473 static void bnx2x_emac_init(struct link_params
*params
,
474 struct link_vars
*vars
)
476 /* reset and unreset the emac core */
477 struct bnx2x
*bp
= params
->bp
;
478 u8 port
= params
->port
;
479 u32 emac_base
= port
? GRCBASE_EMAC1
: GRCBASE_EMAC0
;
483 REG_WR(bp
, GRCBASE_MISC
+ MISC_REGISTERS_RESET_REG_2_CLEAR
,
484 (MISC_REGISTERS_RESET_REG_2_RST_EMAC0_HARD_CORE
<< port
));
486 REG_WR(bp
, GRCBASE_MISC
+ MISC_REGISTERS_RESET_REG_2_SET
,
487 (MISC_REGISTERS_RESET_REG_2_RST_EMAC0_HARD_CORE
<< port
));
489 /* init emac - use read-modify-write */
490 /* self clear reset */
491 val
= REG_RD(bp
, emac_base
+ EMAC_REG_EMAC_MODE
);
492 EMAC_WR(bp
, EMAC_REG_EMAC_MODE
, (val
| EMAC_MODE_RESET
));
496 val
= REG_RD(bp
, emac_base
+ EMAC_REG_EMAC_MODE
);
497 DP(NETIF_MSG_LINK
, "EMAC reset reg is %u\n", val
);
499 DP(NETIF_MSG_LINK
, "EMAC timeout!\n");
503 } while (val
& EMAC_MODE_RESET
);
505 /* Set mac address */
506 val
= ((params
->mac_addr
[0] << 8) |
507 params
->mac_addr
[1]);
508 EMAC_WR(bp
, EMAC_REG_EMAC_MAC_MATCH
, val
);
510 val
= ((params
->mac_addr
[2] << 24) |
511 (params
->mac_addr
[3] << 16) |
512 (params
->mac_addr
[4] << 8) |
513 params
->mac_addr
[5]);
514 EMAC_WR(bp
, EMAC_REG_EMAC_MAC_MATCH
+ 4, val
);
517 static u8
bnx2x_emac_enable(struct link_params
*params
,
518 struct link_vars
*vars
, u8 lb
)
520 struct bnx2x
*bp
= params
->bp
;
521 u8 port
= params
->port
;
522 u32 emac_base
= port
? GRCBASE_EMAC1
: GRCBASE_EMAC0
;
525 DP(NETIF_MSG_LINK
, "enabling EMAC\n");
527 /* enable emac and not bmac */
528 REG_WR(bp
, NIG_REG_EGRESS_EMAC0_PORT
+ port
*4, 1);
531 if (CHIP_REV_IS_EMUL(bp
)) {
532 /* Use lane 1 (of lanes 0-3) */
533 REG_WR(bp
, NIG_REG_XGXS_LANE_SEL_P0
+ port
*4, 1);
534 REG_WR(bp
, NIG_REG_XGXS_SERDES0_MODE_SEL
+
540 if (CHIP_REV_IS_FPGA(bp
)) {
541 /* Use lane 1 (of lanes 0-3) */
542 DP(NETIF_MSG_LINK
, "bnx2x_emac_enable: Setting FPGA\n");
544 REG_WR(bp
, NIG_REG_XGXS_LANE_SEL_P0
+ port
*4, 1);
545 REG_WR(bp
, NIG_REG_XGXS_SERDES0_MODE_SEL
+ port
*4,
549 if (vars
->phy_flags
& PHY_XGXS_FLAG
) {
550 u32 ser_lane
= ((params
->lane_config
&
551 PORT_HW_CFG_LANE_SWAP_CFG_MASTER_MASK
) >>
552 PORT_HW_CFG_LANE_SWAP_CFG_MASTER_SHIFT
);
554 DP(NETIF_MSG_LINK
, "XGXS\n");
555 /* select the master lanes (out of 0-3) */
556 REG_WR(bp
, NIG_REG_XGXS_LANE_SEL_P0
+
559 REG_WR(bp
, NIG_REG_XGXS_SERDES0_MODE_SEL
+
562 } else { /* SerDes */
563 DP(NETIF_MSG_LINK
, "SerDes\n");
565 REG_WR(bp
, NIG_REG_XGXS_SERDES0_MODE_SEL
+
569 bnx2x_bits_en(bp
, emac_base
+ EMAC_REG_EMAC_RX_MODE
,
571 bnx2x_bits_en(bp
, emac_base
+ EMAC_REG_EMAC_TX_MODE
,
574 if (CHIP_REV_IS_SLOW(bp
)) {
575 /* config GMII mode */
576 val
= REG_RD(bp
, emac_base
+ EMAC_REG_EMAC_MODE
);
577 EMAC_WR(bp
, EMAC_REG_EMAC_MODE
,
578 (val
| EMAC_MODE_PORT_GMII
));
580 /* pause enable/disable */
581 bnx2x_bits_dis(bp
, emac_base
+ EMAC_REG_EMAC_RX_MODE
,
582 EMAC_RX_MODE_FLOW_EN
);
584 bnx2x_bits_dis(bp
, emac_base
+ EMAC_REG_EMAC_TX_MODE
,
585 (EMAC_TX_MODE_EXT_PAUSE_EN
|
586 EMAC_TX_MODE_FLOW_EN
));
587 if (!(params
->feature_config_flags
&
588 FEATURE_CONFIG_PFC_ENABLED
)) {
589 if (vars
->flow_ctrl
& BNX2X_FLOW_CTRL_RX
)
590 bnx2x_bits_en(bp
, emac_base
+
591 EMAC_REG_EMAC_RX_MODE
,
592 EMAC_RX_MODE_FLOW_EN
);
594 if (vars
->flow_ctrl
& BNX2X_FLOW_CTRL_TX
)
595 bnx2x_bits_en(bp
, emac_base
+
596 EMAC_REG_EMAC_TX_MODE
,
597 (EMAC_TX_MODE_EXT_PAUSE_EN
|
598 EMAC_TX_MODE_FLOW_EN
));
600 bnx2x_bits_en(bp
, emac_base
+ EMAC_REG_EMAC_TX_MODE
,
601 EMAC_TX_MODE_FLOW_EN
);
604 /* KEEP_VLAN_TAG, promiscuous */
605 val
= REG_RD(bp
, emac_base
+ EMAC_REG_EMAC_RX_MODE
);
606 val
|= EMAC_RX_MODE_KEEP_VLAN_TAG
| EMAC_RX_MODE_PROMISCUOUS
;
609 * Setting this bit causes MAC control frames (except for pause
610 * frames) to be passed on for processing. This setting has no
611 * affect on the operation of the pause frames. This bit effects
612 * all packets regardless of RX Parser packet sorting logic.
613 * Turn the PFC off to make sure we are in Xon state before
616 EMAC_WR(bp
, EMAC_REG_RX_PFC_MODE
, 0);
617 if (params
->feature_config_flags
& FEATURE_CONFIG_PFC_ENABLED
) {
618 DP(NETIF_MSG_LINK
, "PFC is enabled\n");
619 /* Enable PFC again */
620 EMAC_WR(bp
, EMAC_REG_RX_PFC_MODE
,
621 EMAC_REG_RX_PFC_MODE_RX_EN
|
622 EMAC_REG_RX_PFC_MODE_TX_EN
|
623 EMAC_REG_RX_PFC_MODE_PRIORITIES
);
625 EMAC_WR(bp
, EMAC_REG_RX_PFC_PARAM
,
627 EMAC_REG_RX_PFC_PARAM_OPCODE_BITSHIFT
) |
629 EMAC_REG_RX_PFC_PARAM_PRIORITY_EN_BITSHIFT
)));
630 val
|= EMAC_RX_MODE_KEEP_MAC_CONTROL
;
632 EMAC_WR(bp
, EMAC_REG_EMAC_RX_MODE
, val
);
635 val
= REG_RD(bp
, emac_base
+ EMAC_REG_EMAC_MODE
);
640 EMAC_WR(bp
, EMAC_REG_EMAC_MODE
, val
);
643 REG_WR(bp
, NIG_REG_NIG_EMAC0_EN
+ port
*4, 1);
645 /* enable emac for jumbo packets */
646 EMAC_WR(bp
, EMAC_REG_EMAC_RX_MTU_SIZE
,
647 (EMAC_RX_MTU_SIZE_JUMBO_ENA
|
648 (ETH_MAX_JUMBO_PACKET_SIZE
+ ETH_OVREHEAD
)));
651 REG_WR(bp
, NIG_REG_NIG_INGRESS_EMAC0_NO_CRC
+ port
*4, 0x1);
653 /* disable the NIG in/out to the bmac */
654 REG_WR(bp
, NIG_REG_BMAC0_IN_EN
+ port
*4, 0x0);
655 REG_WR(bp
, NIG_REG_BMAC0_PAUSE_OUT_EN
+ port
*4, 0x0);
656 REG_WR(bp
, NIG_REG_BMAC0_OUT_EN
+ port
*4, 0x0);
658 /* enable the NIG in/out to the emac */
659 REG_WR(bp
, NIG_REG_EMAC0_IN_EN
+ port
*4, 0x1);
661 if ((params
->feature_config_flags
&
662 FEATURE_CONFIG_PFC_ENABLED
) ||
663 (vars
->flow_ctrl
& BNX2X_FLOW_CTRL_TX
))
666 REG_WR(bp
, NIG_REG_EMAC0_PAUSE_OUT_EN
+ port
*4, val
);
667 REG_WR(bp
, NIG_REG_EGRESS_EMAC0_OUT_EN
+ port
*4, 0x1);
669 if (CHIP_REV_IS_EMUL(bp
)) {
670 /* take the BigMac out of reset */
672 GRCBASE_MISC
+ MISC_REGISTERS_RESET_REG_2_SET
,
673 (MISC_REGISTERS_RESET_REG_2_RST_BMAC0
<< port
));
675 /* enable access for bmac registers */
676 REG_WR(bp
, NIG_REG_BMAC0_REGS_OUT_EN
+ port
*4, 0x1);
678 REG_WR(bp
, NIG_REG_BMAC0_REGS_OUT_EN
+ port
*4, 0x0);
680 vars
->mac_type
= MAC_TYPE_EMAC
;
684 static void bnx2x_update_pfc_bmac1(struct link_params
*params
,
685 struct link_vars
*vars
)
688 struct bnx2x
*bp
= params
->bp
;
689 u32 bmac_addr
= params
->port
? NIG_REG_INGRESS_BMAC1_MEM
:
690 NIG_REG_INGRESS_BMAC0_MEM
;
693 if ((!(params
->feature_config_flags
&
694 FEATURE_CONFIG_PFC_ENABLED
)) &&
695 (vars
->flow_ctrl
& BNX2X_FLOW_CTRL_RX
))
696 /* Enable BigMAC to react on received Pause packets */
700 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC_REGISTER_RX_CONTROL
, wb_data
, 2);
704 if (!(params
->feature_config_flags
&
705 FEATURE_CONFIG_PFC_ENABLED
) &&
706 (vars
->flow_ctrl
& BNX2X_FLOW_CTRL_TX
))
710 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC_REGISTER_TX_CONTROL
, wb_data
, 2);
713 static void bnx2x_update_pfc_bmac2(struct link_params
*params
,
714 struct link_vars
*vars
,
718 * Set rx control: Strip CRC and enable BigMAC to relay
719 * control packets to the system as well
722 struct bnx2x
*bp
= params
->bp
;
723 u32 bmac_addr
= params
->port
? NIG_REG_INGRESS_BMAC1_MEM
:
724 NIG_REG_INGRESS_BMAC0_MEM
;
727 if ((!(params
->feature_config_flags
&
728 FEATURE_CONFIG_PFC_ENABLED
)) &&
729 (vars
->flow_ctrl
& BNX2X_FLOW_CTRL_RX
))
730 /* Enable BigMAC to react on received Pause packets */
734 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC2_REGISTER_RX_CONTROL
,
740 if (!(params
->feature_config_flags
&
741 FEATURE_CONFIG_PFC_ENABLED
) &&
742 (vars
->flow_ctrl
& BNX2X_FLOW_CTRL_TX
))
746 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC2_REGISTER_TX_CONTROL
, wb_data
, 2);
748 if (params
->feature_config_flags
& FEATURE_CONFIG_PFC_ENABLED
) {
749 DP(NETIF_MSG_LINK
, "PFC is enabled\n");
750 /* Enable PFC RX & TX & STATS and set 8 COS */
752 wb_data
[0] |= (1<<0); /* RX */
753 wb_data
[0] |= (1<<1); /* TX */
754 wb_data
[0] |= (1<<2); /* Force initial Xon */
755 wb_data
[0] |= (1<<3); /* 8 cos */
756 wb_data
[0] |= (1<<5); /* STATS */
758 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC2_REGISTER_PFC_CONTROL
,
760 /* Clear the force Xon */
761 wb_data
[0] &= ~(1<<2);
763 DP(NETIF_MSG_LINK
, "PFC is disabled\n");
764 /* disable PFC RX & TX & STATS and set 8 COS */
769 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC2_REGISTER_PFC_CONTROL
, wb_data
, 2);
772 * Set Time (based unit is 512 bit time) between automatic
773 * re-sending of PP packets amd enable automatic re-send of
774 * Per-Priroity Packet as long as pp_gen is asserted and
778 if (params
->feature_config_flags
& FEATURE_CONFIG_PFC_ENABLED
)
779 val
|= (1<<16); /* enable automatic re-send */
783 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC2_REGISTER_TX_PAUSE_CONTROL
,
787 val
= 0x3; /* Enable RX and TX */
789 val
|= 0x4; /* Local loopback */
790 DP(NETIF_MSG_LINK
, "enable bmac loopback\n");
792 /* When PFC enabled, Pass pause frames towards the NIG. */
793 if (params
->feature_config_flags
& FEATURE_CONFIG_PFC_ENABLED
)
794 val
|= ((1<<6)|(1<<5));
798 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC2_REGISTER_BMAC_CONTROL
,
802 static void bnx2x_update_pfc_brb(struct link_params
*params
,
803 struct link_vars
*vars
,
804 struct bnx2x_nig_brb_pfc_port_params
*pfc_params
)
806 struct bnx2x
*bp
= params
->bp
;
807 int set_pfc
= params
->feature_config_flags
&
808 FEATURE_CONFIG_PFC_ENABLED
;
810 /* default - pause configuration */
811 u32 pause_xoff_th
= PFC_BRB_MAC_PAUSE_XOFF_THRESHOLD_PAUSEABLE
;
812 u32 pause_xon_th
= PFC_BRB_MAC_PAUSE_XON_THRESHOLD_PAUSEABLE
;
813 u32 full_xoff_th
= PFC_BRB_MAC_FULL_XOFF_THRESHOLD_PAUSEABLE
;
814 u32 full_xon_th
= PFC_BRB_MAC_FULL_XON_THRESHOLD_PAUSEABLE
;
816 if (set_pfc
&& pfc_params
)
818 if (!pfc_params
->cos0_pauseable
) {
820 PFC_BRB_MAC_PAUSE_XOFF_THRESHOLD_NON_PAUSEABLE
;
822 PFC_BRB_MAC_PAUSE_XON_THRESHOLD_NON_PAUSEABLE
;
824 PFC_BRB_MAC_FULL_XOFF_THRESHOLD_NON_PAUSEABLE
;
826 PFC_BRB_MAC_FULL_XON_THRESHOLD_NON_PAUSEABLE
;
828 /* The number of free blocks below which the pause signal to class 0
829 of MAC #n is asserted. n=0,1 */
830 REG_WR(bp
, BRB1_REG_PAUSE_0_XOFF_THRESHOLD_0
, pause_xoff_th
);
831 /* The number of free blocks above which the pause signal to class 0
832 of MAC #n is de-asserted. n=0,1 */
833 REG_WR(bp
, BRB1_REG_PAUSE_0_XON_THRESHOLD_0
, pause_xon_th
);
834 /* The number of free blocks below which the full signal to class 0
835 of MAC #n is asserted. n=0,1 */
836 REG_WR(bp
, BRB1_REG_FULL_0_XOFF_THRESHOLD_0
, full_xoff_th
);
837 /* The number of free blocks above which the full signal to class 0
838 of MAC #n is de-asserted. n=0,1 */
839 REG_WR(bp
, BRB1_REG_FULL_0_XON_THRESHOLD_0
, full_xon_th
);
841 if (set_pfc
&& pfc_params
) {
843 if (pfc_params
->cos1_pauseable
) {
845 PFC_BRB_MAC_PAUSE_XOFF_THRESHOLD_PAUSEABLE
;
847 PFC_BRB_MAC_PAUSE_XON_THRESHOLD_PAUSEABLE
;
849 PFC_BRB_MAC_FULL_XOFF_THRESHOLD_PAUSEABLE
;
851 PFC_BRB_MAC_FULL_XON_THRESHOLD_PAUSEABLE
;
854 PFC_BRB_MAC_PAUSE_XOFF_THRESHOLD_NON_PAUSEABLE
;
856 PFC_BRB_MAC_PAUSE_XON_THRESHOLD_NON_PAUSEABLE
;
858 PFC_BRB_MAC_FULL_XOFF_THRESHOLD_NON_PAUSEABLE
;
860 PFC_BRB_MAC_FULL_XON_THRESHOLD_NON_PAUSEABLE
;
863 * The number of free blocks below which the pause signal to
864 * class 1 of MAC #n is asserted. n=0,1
866 REG_WR(bp
, BRB1_REG_PAUSE_1_XOFF_THRESHOLD_0
, pause_xoff_th
);
868 * The number of free blocks above which the pause signal to
869 * class 1 of MAC #n is de-asserted. n=0,1
871 REG_WR(bp
, BRB1_REG_PAUSE_1_XON_THRESHOLD_0
, pause_xon_th
);
873 * The number of free blocks below which the full signal to
874 * class 1 of MAC #n is asserted. n=0,1
876 REG_WR(bp
, BRB1_REG_FULL_1_XOFF_THRESHOLD_0
, full_xoff_th
);
878 * The number of free blocks above which the full signal to
879 * class 1 of MAC #n is de-asserted. n=0,1
881 REG_WR(bp
, BRB1_REG_FULL_1_XON_THRESHOLD_0
, full_xon_th
);
885 static void bnx2x_update_pfc_nig(struct link_params
*params
,
886 struct link_vars
*vars
,
887 struct bnx2x_nig_brb_pfc_port_params
*nig_params
)
889 u32 xcm_mask
= 0, ppp_enable
= 0, pause_enable
= 0, llfc_out_en
= 0;
890 u32 llfc_enable
= 0, xcm0_out_en
= 0, p0_hwpfc_enable
= 0;
891 u32 pkt_priority_to_cos
= 0;
893 struct bnx2x
*bp
= params
->bp
;
894 int port
= params
->port
;
895 int set_pfc
= params
->feature_config_flags
&
896 FEATURE_CONFIG_PFC_ENABLED
;
897 DP(NETIF_MSG_LINK
, "updating pfc nig parameters\n");
900 * When NIG_LLH0_XCM_MASK_REG_LLHX_XCM_MASK_BCN bit is set
901 * MAC control frames (that are not pause packets)
902 * will be forwarded to the XCM.
904 xcm_mask
= REG_RD(bp
,
905 port
? NIG_REG_LLH1_XCM_MASK
:
906 NIG_REG_LLH0_XCM_MASK
);
908 * nig params will override non PFC params, since it's possible to
909 * do transition from PFC to SAFC
916 xcm_mask
&= ~(port
? NIG_LLH1_XCM_MASK_REG_LLH1_XCM_MASK_BCN
:
917 NIG_LLH0_XCM_MASK_REG_LLH0_XCM_MASK_BCN
);
922 llfc_out_en
= nig_params
->llfc_out_en
;
923 llfc_enable
= nig_params
->llfc_enable
;
924 pause_enable
= nig_params
->pause_enable
;
925 } else /*defaul non PFC mode - PAUSE */
928 xcm_mask
|= (port
? NIG_LLH1_XCM_MASK_REG_LLH1_XCM_MASK_BCN
:
929 NIG_LLH0_XCM_MASK_REG_LLH0_XCM_MASK_BCN
);
933 REG_WR(bp
, port
? NIG_REG_LLFC_OUT_EN_1
:
934 NIG_REG_LLFC_OUT_EN_0
, llfc_out_en
);
935 REG_WR(bp
, port
? NIG_REG_LLFC_ENABLE_1
:
936 NIG_REG_LLFC_ENABLE_0
, llfc_enable
);
937 REG_WR(bp
, port
? NIG_REG_PAUSE_ENABLE_1
:
938 NIG_REG_PAUSE_ENABLE_0
, pause_enable
);
940 REG_WR(bp
, port
? NIG_REG_PPP_ENABLE_1
:
941 NIG_REG_PPP_ENABLE_0
, ppp_enable
);
943 REG_WR(bp
, port
? NIG_REG_LLH1_XCM_MASK
:
944 NIG_REG_LLH0_XCM_MASK
, xcm_mask
);
946 REG_WR(bp
, NIG_REG_LLFC_EGRESS_SRC_ENABLE_0
, 0x7);
948 /* output enable for RX_XCM # IF */
949 REG_WR(bp
, NIG_REG_XCM0_OUT_EN
, xcm0_out_en
);
951 /* HW PFC TX enable */
952 REG_WR(bp
, NIG_REG_P0_HWPFC_ENABLE
, p0_hwpfc_enable
);
954 /* 0x2 = BMAC, 0x1= EMAC */
955 switch (vars
->mac_type
) {
966 REG_WR(bp
, NIG_REG_EGRESS_EMAC0_PORT
, val
);
969 pkt_priority_to_cos
= nig_params
->pkt_priority_to_cos
;
971 REG_WR(bp
, port
? NIG_REG_P1_RX_COS0_PRIORITY_MASK
:
972 NIG_REG_P0_RX_COS0_PRIORITY_MASK
,
973 nig_params
->rx_cos0_priority_mask
);
975 REG_WR(bp
, port
? NIG_REG_P1_RX_COS1_PRIORITY_MASK
:
976 NIG_REG_P0_RX_COS1_PRIORITY_MASK
,
977 nig_params
->rx_cos1_priority_mask
);
979 REG_WR(bp
, port
? NIG_REG_LLFC_HIGH_PRIORITY_CLASSES_1
:
980 NIG_REG_LLFC_HIGH_PRIORITY_CLASSES_0
,
981 nig_params
->llfc_high_priority_classes
);
983 REG_WR(bp
, port
? NIG_REG_LLFC_LOW_PRIORITY_CLASSES_1
:
984 NIG_REG_LLFC_LOW_PRIORITY_CLASSES_0
,
985 nig_params
->llfc_low_priority_classes
);
987 REG_WR(bp
, port
? NIG_REG_P1_PKT_PRIORITY_TO_COS
:
988 NIG_REG_P0_PKT_PRIORITY_TO_COS
,
989 pkt_priority_to_cos
);
993 void bnx2x_update_pfc(struct link_params
*params
,
994 struct link_vars
*vars
,
995 struct bnx2x_nig_brb_pfc_port_params
*pfc_params
)
998 * The PFC and pause are orthogonal to one another, meaning when
999 * PFC is enabled, the pause are disabled, and when PFC is
1000 * disabled, pause are set according to the pause result.
1003 struct bnx2x
*bp
= params
->bp
;
1005 /* update NIG params */
1006 bnx2x_update_pfc_nig(params
, vars
, pfc_params
);
1008 /* update BRB params */
1009 bnx2x_update_pfc_brb(params
, vars
, pfc_params
);
1014 val
= REG_RD(bp
, MISC_REG_RESET_REG_2
);
1015 if ((val
& (MISC_REGISTERS_RESET_REG_2_RST_BMAC0
<< params
->port
))
1017 DP(NETIF_MSG_LINK
, "About to update PFC in EMAC\n");
1018 bnx2x_emac_enable(params
, vars
, 0);
1022 DP(NETIF_MSG_LINK
, "About to update PFC in BMAC\n");
1024 bnx2x_update_pfc_bmac2(params
, vars
, 0);
1026 bnx2x_update_pfc_bmac1(params
, vars
);
1029 if ((params
->feature_config_flags
&
1030 FEATURE_CONFIG_PFC_ENABLED
) ||
1031 (vars
->flow_ctrl
& BNX2X_FLOW_CTRL_TX
))
1033 REG_WR(bp
, NIG_REG_BMAC0_PAUSE_OUT_EN
+ params
->port
*4, val
);
1036 static u8
bnx2x_bmac1_enable(struct link_params
*params
,
1037 struct link_vars
*vars
,
1040 struct bnx2x
*bp
= params
->bp
;
1041 u8 port
= params
->port
;
1042 u32 bmac_addr
= port
? NIG_REG_INGRESS_BMAC1_MEM
:
1043 NIG_REG_INGRESS_BMAC0_MEM
;
1047 DP(NETIF_MSG_LINK
, "Enabling BigMAC1\n");
1052 REG_WR_DMAE(bp
, bmac_addr
+
1053 BIGMAC_REGISTER_BMAC_XGXS_CONTROL
,
1057 wb_data
[0] = ((params
->mac_addr
[2] << 24) |
1058 (params
->mac_addr
[3] << 16) |
1059 (params
->mac_addr
[4] << 8) |
1060 params
->mac_addr
[5]);
1061 wb_data
[1] = ((params
->mac_addr
[0] << 8) |
1062 params
->mac_addr
[1]);
1063 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC_REGISTER_TX_SOURCE_ADDR
,
1070 DP(NETIF_MSG_LINK
, "enable bmac loopback\n");
1074 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC_REGISTER_BMAC_CONTROL
,
1078 wb_data
[0] = ETH_MAX_JUMBO_PACKET_SIZE
+ ETH_OVREHEAD
;
1080 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC_REGISTER_RX_MAX_SIZE
,
1083 bnx2x_update_pfc_bmac1(params
, vars
);
1086 wb_data
[0] = ETH_MAX_JUMBO_PACKET_SIZE
+ ETH_OVREHEAD
;
1088 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC_REGISTER_TX_MAX_SIZE
,
1091 /* set cnt max size */
1092 wb_data
[0] = ETH_MAX_JUMBO_PACKET_SIZE
+ ETH_OVREHEAD
;
1094 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC_REGISTER_CNT_MAX_SIZE
,
1097 /* configure safc */
1098 wb_data
[0] = 0x1000200;
1100 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC_REGISTER_RX_LLFC_MSG_FLDS
,
1102 /* fix for emulation */
1103 if (CHIP_REV_IS_EMUL(bp
)) {
1104 wb_data
[0] = 0xf000;
1107 bmac_addr
+ BIGMAC_REGISTER_TX_PAUSE_THRESHOLD
,
1115 static u8
bnx2x_bmac2_enable(struct link_params
*params
,
1116 struct link_vars
*vars
,
1119 struct bnx2x
*bp
= params
->bp
;
1120 u8 port
= params
->port
;
1121 u32 bmac_addr
= port
? NIG_REG_INGRESS_BMAC1_MEM
:
1122 NIG_REG_INGRESS_BMAC0_MEM
;
1125 DP(NETIF_MSG_LINK
, "Enabling BigMAC2\n");
1129 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC2_REGISTER_BMAC_CONTROL
,
1133 /* XGXS control: Reset phy HW, MDIO registers, PHY PLL and BMAC */
1136 REG_WR_DMAE(bp
, bmac_addr
+
1137 BIGMAC2_REGISTER_BMAC_XGXS_CONTROL
,
1143 wb_data
[0] = ((params
->mac_addr
[2] << 24) |
1144 (params
->mac_addr
[3] << 16) |
1145 (params
->mac_addr
[4] << 8) |
1146 params
->mac_addr
[5]);
1147 wb_data
[1] = ((params
->mac_addr
[0] << 8) |
1148 params
->mac_addr
[1]);
1149 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC2_REGISTER_TX_SOURCE_ADDR
,
1154 /* Configure SAFC */
1155 wb_data
[0] = 0x1000200;
1157 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC2_REGISTER_RX_LLFC_MSG_FLDS
,
1162 wb_data
[0] = ETH_MAX_JUMBO_PACKET_SIZE
+ ETH_OVREHEAD
;
1164 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC2_REGISTER_RX_MAX_SIZE
,
1169 wb_data
[0] = ETH_MAX_JUMBO_PACKET_SIZE
+ ETH_OVREHEAD
;
1171 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC2_REGISTER_TX_MAX_SIZE
,
1174 /* set cnt max size */
1175 wb_data
[0] = ETH_MAX_JUMBO_PACKET_SIZE
+ ETH_OVREHEAD
- 2;
1177 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC2_REGISTER_CNT_MAX_SIZE
,
1180 bnx2x_update_pfc_bmac2(params
, vars
, is_lb
);
1185 static u8
bnx2x_bmac_enable(struct link_params
*params
,
1186 struct link_vars
*vars
,
1189 u8 rc
, port
= params
->port
;
1190 struct bnx2x
*bp
= params
->bp
;
1192 /* reset and unreset the BigMac */
1193 REG_WR(bp
, GRCBASE_MISC
+ MISC_REGISTERS_RESET_REG_2_CLEAR
,
1194 (MISC_REGISTERS_RESET_REG_2_RST_BMAC0
<< port
));
1197 REG_WR(bp
, GRCBASE_MISC
+ MISC_REGISTERS_RESET_REG_2_SET
,
1198 (MISC_REGISTERS_RESET_REG_2_RST_BMAC0
<< port
));
1200 /* enable access for bmac registers */
1201 REG_WR(bp
, NIG_REG_BMAC0_REGS_OUT_EN
+ port
*4, 0x1);
1203 /* Enable BMAC according to BMAC type*/
1205 rc
= bnx2x_bmac2_enable(params
, vars
, is_lb
);
1207 rc
= bnx2x_bmac1_enable(params
, vars
, is_lb
);
1208 REG_WR(bp
, NIG_REG_XGXS_SERDES0_MODE_SEL
+ port
*4, 0x1);
1209 REG_WR(bp
, NIG_REG_XGXS_LANE_SEL_P0
+ port
*4, 0x0);
1210 REG_WR(bp
, NIG_REG_EGRESS_EMAC0_PORT
+ port
*4, 0x0);
1212 if ((params
->feature_config_flags
&
1213 FEATURE_CONFIG_PFC_ENABLED
) ||
1214 (vars
->flow_ctrl
& BNX2X_FLOW_CTRL_TX
))
1216 REG_WR(bp
, NIG_REG_BMAC0_PAUSE_OUT_EN
+ port
*4, val
);
1217 REG_WR(bp
, NIG_REG_EGRESS_EMAC0_OUT_EN
+ port
*4, 0x0);
1218 REG_WR(bp
, NIG_REG_EMAC0_IN_EN
+ port
*4, 0x0);
1219 REG_WR(bp
, NIG_REG_EMAC0_PAUSE_OUT_EN
+ port
*4, 0x0);
1220 REG_WR(bp
, NIG_REG_BMAC0_IN_EN
+ port
*4, 0x1);
1221 REG_WR(bp
, NIG_REG_BMAC0_OUT_EN
+ port
*4, 0x1);
1223 vars
->mac_type
= MAC_TYPE_BMAC
;
1228 static void bnx2x_update_mng(struct link_params
*params
, u32 link_status
)
1230 struct bnx2x
*bp
= params
->bp
;
1232 REG_WR(bp
, params
->shmem_base
+
1233 offsetof(struct shmem_region
,
1234 port_mb
[params
->port
].link_status
),
1238 static void bnx2x_bmac_rx_disable(struct bnx2x
*bp
, u8 port
)
1240 u32 bmac_addr
= port
? NIG_REG_INGRESS_BMAC1_MEM
:
1241 NIG_REG_INGRESS_BMAC0_MEM
;
1243 u32 nig_bmac_enable
= REG_RD(bp
, NIG_REG_BMAC0_REGS_OUT_EN
+ port
*4);
1245 /* Only if the bmac is out of reset */
1246 if (REG_RD(bp
, MISC_REG_RESET_REG_2
) &
1247 (MISC_REGISTERS_RESET_REG_2_RST_BMAC0
<< port
) &&
1250 if (CHIP_IS_E2(bp
)) {
1251 /* Clear Rx Enable bit in BMAC_CONTROL register */
1252 REG_RD_DMAE(bp
, bmac_addr
+
1253 BIGMAC2_REGISTER_BMAC_CONTROL
,
1255 wb_data
[0] &= ~BMAC_CONTROL_RX_ENABLE
;
1256 REG_WR_DMAE(bp
, bmac_addr
+
1257 BIGMAC2_REGISTER_BMAC_CONTROL
,
1260 /* Clear Rx Enable bit in BMAC_CONTROL register */
1261 REG_RD_DMAE(bp
, bmac_addr
+
1262 BIGMAC_REGISTER_BMAC_CONTROL
,
1264 wb_data
[0] &= ~BMAC_CONTROL_RX_ENABLE
;
1265 REG_WR_DMAE(bp
, bmac_addr
+
1266 BIGMAC_REGISTER_BMAC_CONTROL
,
1273 static u8
bnx2x_pbf_update(struct link_params
*params
, u32 flow_ctrl
,
1276 struct bnx2x
*bp
= params
->bp
;
1277 u8 port
= params
->port
;
1282 REG_WR(bp
, PBF_REG_DISABLE_NEW_TASK_PROC_P0
+ port
*4, 0x1);
1284 /* wait for init credit */
1285 init_crd
= REG_RD(bp
, PBF_REG_P0_INIT_CRD
+ port
*4);
1286 crd
= REG_RD(bp
, PBF_REG_P0_CREDIT
+ port
*8);
1287 DP(NETIF_MSG_LINK
, "init_crd 0x%x crd 0x%x\n", init_crd
, crd
);
1289 while ((init_crd
!= crd
) && count
) {
1292 crd
= REG_RD(bp
, PBF_REG_P0_CREDIT
+ port
*8);
1295 crd
= REG_RD(bp
, PBF_REG_P0_CREDIT
+ port
*8);
1296 if (init_crd
!= crd
) {
1297 DP(NETIF_MSG_LINK
, "BUG! init_crd 0x%x != crd 0x%x\n",
1302 if (flow_ctrl
& BNX2X_FLOW_CTRL_RX
||
1303 line_speed
== SPEED_10
||
1304 line_speed
== SPEED_100
||
1305 line_speed
== SPEED_1000
||
1306 line_speed
== SPEED_2500
) {
1307 REG_WR(bp
, PBF_REG_P0_PAUSE_ENABLE
+ port
*4, 1);
1308 /* update threshold */
1309 REG_WR(bp
, PBF_REG_P0_ARB_THRSH
+ port
*4, 0);
1310 /* update init credit */
1311 init_crd
= 778; /* (800-18-4) */
1314 u32 thresh
= (ETH_MAX_JUMBO_PACKET_SIZE
+
1316 REG_WR(bp
, PBF_REG_P0_PAUSE_ENABLE
+ port
*4, 0);
1317 /* update threshold */
1318 REG_WR(bp
, PBF_REG_P0_ARB_THRSH
+ port
*4, thresh
);
1319 /* update init credit */
1320 switch (line_speed
) {
1322 init_crd
= thresh
+ 553 - 22;
1326 init_crd
= thresh
+ 664 - 22;
1330 init_crd
= thresh
+ 742 - 22;
1334 init_crd
= thresh
+ 778 - 22;
1337 DP(NETIF_MSG_LINK
, "Invalid line_speed 0x%x\n",
1342 REG_WR(bp
, PBF_REG_P0_INIT_CRD
+ port
*4, init_crd
);
1343 DP(NETIF_MSG_LINK
, "PBF updated to speed %d credit %d\n",
1344 line_speed
, init_crd
);
1346 /* probe the credit changes */
1347 REG_WR(bp
, PBF_REG_INIT_P0
+ port
*4, 0x1);
1349 REG_WR(bp
, PBF_REG_INIT_P0
+ port
*4, 0x0);
1352 REG_WR(bp
, PBF_REG_DISABLE_NEW_TASK_PROC_P0
+ port
*4, 0x0);
1356 static u32
bnx2x_get_emac_base(struct bnx2x
*bp
,
1357 u32 mdc_mdio_access
, u8 port
)
1360 switch (mdc_mdio_access
) {
1361 case SHARED_HW_CFG_MDC_MDIO_ACCESS1_PHY_TYPE
:
1363 case SHARED_HW_CFG_MDC_MDIO_ACCESS1_EMAC0
:
1364 if (REG_RD(bp
, NIG_REG_PORT_SWAP
))
1365 emac_base
= GRCBASE_EMAC1
;
1367 emac_base
= GRCBASE_EMAC0
;
1369 case SHARED_HW_CFG_MDC_MDIO_ACCESS1_EMAC1
:
1370 if (REG_RD(bp
, NIG_REG_PORT_SWAP
))
1371 emac_base
= GRCBASE_EMAC0
;
1373 emac_base
= GRCBASE_EMAC1
;
1375 case SHARED_HW_CFG_MDC_MDIO_ACCESS1_BOTH
:
1376 emac_base
= (port
) ? GRCBASE_EMAC1
: GRCBASE_EMAC0
;
1378 case SHARED_HW_CFG_MDC_MDIO_ACCESS1_SWAPPED
:
1379 emac_base
= (port
) ? GRCBASE_EMAC0
: GRCBASE_EMAC1
;
1388 u8
bnx2x_cl45_write(struct bnx2x
*bp
, struct bnx2x_phy
*phy
,
1389 u8 devad
, u16 reg
, u16 val
)
1391 u32 tmp
, saved_mode
;
1394 /* set clause 45 mode, slow down the MDIO clock to 2.5MHz
1395 * (a value of 49==0x31) and make sure that the AUTO poll is off
1398 saved_mode
= REG_RD(bp
, phy
->mdio_ctrl
+ EMAC_REG_EMAC_MDIO_MODE
);
1399 tmp
= saved_mode
& ~(EMAC_MDIO_MODE_AUTO_POLL
|
1400 EMAC_MDIO_MODE_CLOCK_CNT
);
1401 tmp
|= (EMAC_MDIO_MODE_CLAUSE_45
|
1402 (49 << EMAC_MDIO_MODE_CLOCK_CNT_BITSHIFT
));
1403 REG_WR(bp
, phy
->mdio_ctrl
+ EMAC_REG_EMAC_MDIO_MODE
, tmp
);
1404 REG_RD(bp
, phy
->mdio_ctrl
+ EMAC_REG_EMAC_MDIO_MODE
);
1409 tmp
= ((phy
->addr
<< 21) | (devad
<< 16) | reg
|
1410 EMAC_MDIO_COMM_COMMAND_ADDRESS
|
1411 EMAC_MDIO_COMM_START_BUSY
);
1412 REG_WR(bp
, phy
->mdio_ctrl
+ EMAC_REG_EMAC_MDIO_COMM
, tmp
);
1414 for (i
= 0; i
< 50; i
++) {
1417 tmp
= REG_RD(bp
, phy
->mdio_ctrl
+
1418 EMAC_REG_EMAC_MDIO_COMM
);
1419 if (!(tmp
& EMAC_MDIO_COMM_START_BUSY
)) {
1424 if (tmp
& EMAC_MDIO_COMM_START_BUSY
) {
1425 DP(NETIF_MSG_LINK
, "write phy register failed\n");
1429 tmp
= ((phy
->addr
<< 21) | (devad
<< 16) | val
|
1430 EMAC_MDIO_COMM_COMMAND_WRITE_45
|
1431 EMAC_MDIO_COMM_START_BUSY
);
1432 REG_WR(bp
, phy
->mdio_ctrl
+ EMAC_REG_EMAC_MDIO_COMM
, tmp
);
1434 for (i
= 0; i
< 50; i
++) {
1437 tmp
= REG_RD(bp
, phy
->mdio_ctrl
+
1438 EMAC_REG_EMAC_MDIO_COMM
);
1439 if (!(tmp
& EMAC_MDIO_COMM_START_BUSY
)) {
1444 if (tmp
& EMAC_MDIO_COMM_START_BUSY
) {
1445 DP(NETIF_MSG_LINK
, "write phy register failed\n");
1450 /* Restore the saved mode */
1451 REG_WR(bp
, phy
->mdio_ctrl
+ EMAC_REG_EMAC_MDIO_MODE
, saved_mode
);
1456 u8
bnx2x_cl45_read(struct bnx2x
*bp
, struct bnx2x_phy
*phy
,
1457 u8 devad
, u16 reg
, u16
*ret_val
)
1459 u32 val
, saved_mode
;
1463 /* set clause 45 mode, slow down the MDIO clock to 2.5MHz
1464 * (a value of 49==0x31) and make sure that the AUTO poll is off
1467 saved_mode
= REG_RD(bp
, phy
->mdio_ctrl
+ EMAC_REG_EMAC_MDIO_MODE
);
1468 val
= saved_mode
& ~((EMAC_MDIO_MODE_AUTO_POLL
|
1469 EMAC_MDIO_MODE_CLOCK_CNT
));
1470 val
|= (EMAC_MDIO_MODE_CLAUSE_45
|
1471 (49L << EMAC_MDIO_MODE_CLOCK_CNT_BITSHIFT
));
1472 REG_WR(bp
, phy
->mdio_ctrl
+ EMAC_REG_EMAC_MDIO_MODE
, val
);
1473 REG_RD(bp
, phy
->mdio_ctrl
+ EMAC_REG_EMAC_MDIO_MODE
);
1477 val
= ((phy
->addr
<< 21) | (devad
<< 16) | reg
|
1478 EMAC_MDIO_COMM_COMMAND_ADDRESS
|
1479 EMAC_MDIO_COMM_START_BUSY
);
1480 REG_WR(bp
, phy
->mdio_ctrl
+ EMAC_REG_EMAC_MDIO_COMM
, val
);
1482 for (i
= 0; i
< 50; i
++) {
1485 val
= REG_RD(bp
, phy
->mdio_ctrl
+ EMAC_REG_EMAC_MDIO_COMM
);
1486 if (!(val
& EMAC_MDIO_COMM_START_BUSY
)) {
1491 if (val
& EMAC_MDIO_COMM_START_BUSY
) {
1492 DP(NETIF_MSG_LINK
, "read phy register failed\n");
1499 val
= ((phy
->addr
<< 21) | (devad
<< 16) |
1500 EMAC_MDIO_COMM_COMMAND_READ_45
|
1501 EMAC_MDIO_COMM_START_BUSY
);
1502 REG_WR(bp
, phy
->mdio_ctrl
+ EMAC_REG_EMAC_MDIO_COMM
, val
);
1504 for (i
= 0; i
< 50; i
++) {
1507 val
= REG_RD(bp
, phy
->mdio_ctrl
+
1508 EMAC_REG_EMAC_MDIO_COMM
);
1509 if (!(val
& EMAC_MDIO_COMM_START_BUSY
)) {
1510 *ret_val
= (u16
)(val
& EMAC_MDIO_COMM_DATA
);
1514 if (val
& EMAC_MDIO_COMM_START_BUSY
) {
1515 DP(NETIF_MSG_LINK
, "read phy register failed\n");
1522 /* Restore the saved mode */
1523 REG_WR(bp
, phy
->mdio_ctrl
+ EMAC_REG_EMAC_MDIO_MODE
, saved_mode
);
1528 u8
bnx2x_phy_read(struct link_params
*params
, u8 phy_addr
,
1529 u8 devad
, u16 reg
, u16
*ret_val
)
1533 * Probe for the phy according to the given phy_addr, and execute
1534 * the read request on it
1536 for (phy_index
= 0; phy_index
< params
->num_phys
; phy_index
++) {
1537 if (params
->phy
[phy_index
].addr
== phy_addr
) {
1538 return bnx2x_cl45_read(params
->bp
,
1539 ¶ms
->phy
[phy_index
], devad
,
1546 u8
bnx2x_phy_write(struct link_params
*params
, u8 phy_addr
,
1547 u8 devad
, u16 reg
, u16 val
)
1551 * Probe for the phy according to the given phy_addr, and execute
1552 * the write request on it
1554 for (phy_index
= 0; phy_index
< params
->num_phys
; phy_index
++) {
1555 if (params
->phy
[phy_index
].addr
== phy_addr
) {
1556 return bnx2x_cl45_write(params
->bp
,
1557 ¶ms
->phy
[phy_index
], devad
,
1564 static void bnx2x_set_aer_mmd_xgxs(struct link_params
*params
,
1565 struct bnx2x_phy
*phy
)
1568 u16 offset
, aer_val
;
1569 struct bnx2x
*bp
= params
->bp
;
1570 ser_lane
= ((params
->lane_config
&
1571 PORT_HW_CFG_LANE_SWAP_CFG_MASTER_MASK
) >>
1572 PORT_HW_CFG_LANE_SWAP_CFG_MASTER_SHIFT
);
1574 offset
= phy
->addr
+ ser_lane
;
1576 aer_val
= 0x2800 + offset
- 1;
1578 aer_val
= 0x3800 + offset
;
1579 CL45_WR_OVER_CL22(bp
, phy
,
1580 MDIO_REG_BANK_AER_BLOCK
,
1581 MDIO_AER_BLOCK_AER_REG
, aer_val
);
1583 static void bnx2x_set_aer_mmd_serdes(struct bnx2x
*bp
,
1584 struct bnx2x_phy
*phy
)
1586 CL45_WR_OVER_CL22(bp
, phy
,
1587 MDIO_REG_BANK_AER_BLOCK
,
1588 MDIO_AER_BLOCK_AER_REG
, 0x3800);
1591 /******************************************************************/
1592 /* Internal phy section */
1593 /******************************************************************/
1595 static void bnx2x_set_serdes_access(struct bnx2x
*bp
, u8 port
)
1597 u32 emac_base
= (port
) ? GRCBASE_EMAC1
: GRCBASE_EMAC0
;
1600 REG_WR(bp
, NIG_REG_SERDES0_CTRL_MD_ST
+ port
*0x10, 1);
1601 REG_WR(bp
, emac_base
+ EMAC_REG_EMAC_MDIO_COMM
, 0x245f8000);
1603 REG_WR(bp
, emac_base
+ EMAC_REG_EMAC_MDIO_COMM
, 0x245d000f);
1606 REG_WR(bp
, NIG_REG_SERDES0_CTRL_MD_ST
+ port
*0x10, 0);
1609 static void bnx2x_serdes_deassert(struct bnx2x
*bp
, u8 port
)
1613 DP(NETIF_MSG_LINK
, "bnx2x_serdes_deassert\n");
1615 val
= SERDES_RESET_BITS
<< (port
*16);
1617 /* reset and unreset the SerDes/XGXS */
1618 REG_WR(bp
, GRCBASE_MISC
+ MISC_REGISTERS_RESET_REG_3_CLEAR
, val
);
1620 REG_WR(bp
, GRCBASE_MISC
+ MISC_REGISTERS_RESET_REG_3_SET
, val
);
1622 bnx2x_set_serdes_access(bp
, port
);
1624 REG_WR(bp
, NIG_REG_SERDES0_CTRL_MD_DEVAD
+
1626 DEFAULT_PHY_DEV_ADDR
);
1629 static void bnx2x_xgxs_deassert(struct link_params
*params
)
1631 struct bnx2x
*bp
= params
->bp
;
1634 DP(NETIF_MSG_LINK
, "bnx2x_xgxs_deassert\n");
1635 port
= params
->port
;
1637 val
= XGXS_RESET_BITS
<< (port
*16);
1639 /* reset and unreset the SerDes/XGXS */
1640 REG_WR(bp
, GRCBASE_MISC
+ MISC_REGISTERS_RESET_REG_3_CLEAR
, val
);
1642 REG_WR(bp
, GRCBASE_MISC
+ MISC_REGISTERS_RESET_REG_3_SET
, val
);
1644 REG_WR(bp
, NIG_REG_XGXS0_CTRL_MD_ST
+
1646 REG_WR(bp
, NIG_REG_XGXS0_CTRL_MD_DEVAD
+ port
*0x18,
1647 params
->phy
[INT_PHY
].def_md_devad
);
1651 void bnx2x_link_status_update(struct link_params
*params
,
1652 struct link_vars
*vars
)
1654 struct bnx2x
*bp
= params
->bp
;
1656 u8 port
= params
->port
;
1658 vars
->link_status
= REG_RD(bp
, params
->shmem_base
+
1659 offsetof(struct shmem_region
,
1660 port_mb
[port
].link_status
));
1662 vars
->link_up
= (vars
->link_status
& LINK_STATUS_LINK_UP
);
1664 if (vars
->link_up
) {
1665 DP(NETIF_MSG_LINK
, "phy link up\n");
1667 vars
->phy_link_up
= 1;
1668 vars
->duplex
= DUPLEX_FULL
;
1669 switch (vars
->link_status
&
1670 LINK_STATUS_SPEED_AND_DUPLEX_MASK
) {
1672 vars
->duplex
= DUPLEX_HALF
;
1675 vars
->line_speed
= SPEED_10
;
1679 vars
->duplex
= DUPLEX_HALF
;
1683 vars
->line_speed
= SPEED_100
;
1687 vars
->duplex
= DUPLEX_HALF
;
1690 vars
->line_speed
= SPEED_1000
;
1694 vars
->duplex
= DUPLEX_HALF
;
1697 vars
->line_speed
= SPEED_2500
;
1701 vars
->line_speed
= SPEED_10000
;
1705 vars
->line_speed
= SPEED_12000
;
1709 vars
->line_speed
= SPEED_12500
;
1713 vars
->line_speed
= SPEED_13000
;
1717 vars
->line_speed
= SPEED_15000
;
1721 vars
->line_speed
= SPEED_16000
;
1727 vars
->flow_ctrl
= 0;
1728 if (vars
->link_status
& LINK_STATUS_TX_FLOW_CONTROL_ENABLED
)
1729 vars
->flow_ctrl
|= BNX2X_FLOW_CTRL_TX
;
1731 if (vars
->link_status
& LINK_STATUS_RX_FLOW_CONTROL_ENABLED
)
1732 vars
->flow_ctrl
|= BNX2X_FLOW_CTRL_RX
;
1734 if (!vars
->flow_ctrl
)
1735 vars
->flow_ctrl
= BNX2X_FLOW_CTRL_NONE
;
1737 if (vars
->line_speed
&&
1738 ((vars
->line_speed
== SPEED_10
) ||
1739 (vars
->line_speed
== SPEED_100
))) {
1740 vars
->phy_flags
|= PHY_SGMII_FLAG
;
1742 vars
->phy_flags
&= ~PHY_SGMII_FLAG
;
1745 /* anything 10 and over uses the bmac */
1746 link_10g
= ((vars
->line_speed
== SPEED_10000
) ||
1747 (vars
->line_speed
== SPEED_12000
) ||
1748 (vars
->line_speed
== SPEED_12500
) ||
1749 (vars
->line_speed
== SPEED_13000
) ||
1750 (vars
->line_speed
== SPEED_15000
) ||
1751 (vars
->line_speed
== SPEED_16000
));
1753 vars
->mac_type
= MAC_TYPE_BMAC
;
1755 vars
->mac_type
= MAC_TYPE_EMAC
;
1757 } else { /* link down */
1758 DP(NETIF_MSG_LINK
, "phy link down\n");
1760 vars
->phy_link_up
= 0;
1762 vars
->line_speed
= 0;
1763 vars
->duplex
= DUPLEX_FULL
;
1764 vars
->flow_ctrl
= BNX2X_FLOW_CTRL_NONE
;
1766 /* indicate no mac active */
1767 vars
->mac_type
= MAC_TYPE_NONE
;
1770 DP(NETIF_MSG_LINK
, "link_status 0x%x phy_link_up %x\n",
1771 vars
->link_status
, vars
->phy_link_up
);
1772 DP(NETIF_MSG_LINK
, "line_speed %x duplex %x flow_ctrl 0x%x\n",
1773 vars
->line_speed
, vars
->duplex
, vars
->flow_ctrl
);
1777 static void bnx2x_set_master_ln(struct link_params
*params
,
1778 struct bnx2x_phy
*phy
)
1780 struct bnx2x
*bp
= params
->bp
;
1781 u16 new_master_ln
, ser_lane
;
1782 ser_lane
= ((params
->lane_config
&
1783 PORT_HW_CFG_LANE_SWAP_CFG_MASTER_MASK
) >>
1784 PORT_HW_CFG_LANE_SWAP_CFG_MASTER_SHIFT
);
1786 /* set the master_ln for AN */
1787 CL45_RD_OVER_CL22(bp
, phy
,
1788 MDIO_REG_BANK_XGXS_BLOCK2
,
1789 MDIO_XGXS_BLOCK2_TEST_MODE_LANE
,
1792 CL45_WR_OVER_CL22(bp
, phy
,
1793 MDIO_REG_BANK_XGXS_BLOCK2
,
1794 MDIO_XGXS_BLOCK2_TEST_MODE_LANE
,
1795 (new_master_ln
| ser_lane
));
1798 static u8
bnx2x_reset_unicore(struct link_params
*params
,
1799 struct bnx2x_phy
*phy
,
1802 struct bnx2x
*bp
= params
->bp
;
1806 CL45_RD_OVER_CL22(bp
, phy
,
1807 MDIO_REG_BANK_COMBO_IEEE0
,
1808 MDIO_COMBO_IEEE0_MII_CONTROL
, &mii_control
);
1810 /* reset the unicore */
1811 CL45_WR_OVER_CL22(bp
, phy
,
1812 MDIO_REG_BANK_COMBO_IEEE0
,
1813 MDIO_COMBO_IEEE0_MII_CONTROL
,
1815 MDIO_COMBO_IEEO_MII_CONTROL_RESET
));
1817 bnx2x_set_serdes_access(bp
, params
->port
);
1819 /* wait for the reset to self clear */
1820 for (i
= 0; i
< MDIO_ACCESS_TIMEOUT
; i
++) {
1823 /* the reset erased the previous bank value */
1824 CL45_RD_OVER_CL22(bp
, phy
,
1825 MDIO_REG_BANK_COMBO_IEEE0
,
1826 MDIO_COMBO_IEEE0_MII_CONTROL
,
1829 if (!(mii_control
& MDIO_COMBO_IEEO_MII_CONTROL_RESET
)) {
1835 DP(NETIF_MSG_LINK
, "BUG! XGXS is still in reset!\n");
1840 static void bnx2x_set_swap_lanes(struct link_params
*params
,
1841 struct bnx2x_phy
*phy
)
1843 struct bnx2x
*bp
= params
->bp
;
1844 /* Each two bits represents a lane number:
1845 No swap is 0123 => 0x1b no need to enable the swap */
1846 u16 ser_lane
, rx_lane_swap
, tx_lane_swap
;
1848 ser_lane
= ((params
->lane_config
&
1849 PORT_HW_CFG_LANE_SWAP_CFG_MASTER_MASK
) >>
1850 PORT_HW_CFG_LANE_SWAP_CFG_MASTER_SHIFT
);
1851 rx_lane_swap
= ((params
->lane_config
&
1852 PORT_HW_CFG_LANE_SWAP_CFG_RX_MASK
) >>
1853 PORT_HW_CFG_LANE_SWAP_CFG_RX_SHIFT
);
1854 tx_lane_swap
= ((params
->lane_config
&
1855 PORT_HW_CFG_LANE_SWAP_CFG_TX_MASK
) >>
1856 PORT_HW_CFG_LANE_SWAP_CFG_TX_SHIFT
);
1858 if (rx_lane_swap
!= 0x1b) {
1859 CL45_WR_OVER_CL22(bp
, phy
,
1860 MDIO_REG_BANK_XGXS_BLOCK2
,
1861 MDIO_XGXS_BLOCK2_RX_LN_SWAP
,
1863 MDIO_XGXS_BLOCK2_RX_LN_SWAP_ENABLE
|
1864 MDIO_XGXS_BLOCK2_RX_LN_SWAP_FORCE_ENABLE
));
1866 CL45_WR_OVER_CL22(bp
, phy
,
1867 MDIO_REG_BANK_XGXS_BLOCK2
,
1868 MDIO_XGXS_BLOCK2_RX_LN_SWAP
, 0);
1871 if (tx_lane_swap
!= 0x1b) {
1872 CL45_WR_OVER_CL22(bp
, phy
,
1873 MDIO_REG_BANK_XGXS_BLOCK2
,
1874 MDIO_XGXS_BLOCK2_TX_LN_SWAP
,
1876 MDIO_XGXS_BLOCK2_TX_LN_SWAP_ENABLE
));
1878 CL45_WR_OVER_CL22(bp
, phy
,
1879 MDIO_REG_BANK_XGXS_BLOCK2
,
1880 MDIO_XGXS_BLOCK2_TX_LN_SWAP
, 0);
1884 static void bnx2x_set_parallel_detection(struct bnx2x_phy
*phy
,
1885 struct link_params
*params
)
1887 struct bnx2x
*bp
= params
->bp
;
1889 CL45_RD_OVER_CL22(bp
, phy
,
1890 MDIO_REG_BANK_SERDES_DIGITAL
,
1891 MDIO_SERDES_DIGITAL_A_1000X_CONTROL2
,
1893 if (phy
->speed_cap_mask
& PORT_HW_CFG_SPEED_CAPABILITY_D0_1G
)
1894 control2
|= MDIO_SERDES_DIGITAL_A_1000X_CONTROL2_PRL_DT_EN
;
1896 control2
&= ~MDIO_SERDES_DIGITAL_A_1000X_CONTROL2_PRL_DT_EN
;
1897 DP(NETIF_MSG_LINK
, "phy->speed_cap_mask = 0x%x, control2 = 0x%x\n",
1898 phy
->speed_cap_mask
, control2
);
1899 CL45_WR_OVER_CL22(bp
, phy
,
1900 MDIO_REG_BANK_SERDES_DIGITAL
,
1901 MDIO_SERDES_DIGITAL_A_1000X_CONTROL2
,
1904 if ((phy
->type
== PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT
) &&
1905 (phy
->speed_cap_mask
&
1906 PORT_HW_CFG_SPEED_CAPABILITY_D0_10G
)) {
1907 DP(NETIF_MSG_LINK
, "XGXS\n");
1909 CL45_WR_OVER_CL22(bp
, phy
,
1910 MDIO_REG_BANK_10G_PARALLEL_DETECT
,
1911 MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_LINK
,
1912 MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_LINK_CNT
);
1914 CL45_RD_OVER_CL22(bp
, phy
,
1915 MDIO_REG_BANK_10G_PARALLEL_DETECT
,
1916 MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_CONTROL
,
1921 MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_CONTROL_PARDET10G_EN
;
1923 CL45_WR_OVER_CL22(bp
, phy
,
1924 MDIO_REG_BANK_10G_PARALLEL_DETECT
,
1925 MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_CONTROL
,
1928 /* Disable parallel detection of HiG */
1929 CL45_WR_OVER_CL22(bp
, phy
,
1930 MDIO_REG_BANK_XGXS_BLOCK2
,
1931 MDIO_XGXS_BLOCK2_UNICORE_MODE_10G
,
1932 MDIO_XGXS_BLOCK2_UNICORE_MODE_10G_CX4_XGXS
|
1933 MDIO_XGXS_BLOCK2_UNICORE_MODE_10G_HIGIG_XGXS
);
1937 static void bnx2x_set_autoneg(struct bnx2x_phy
*phy
,
1938 struct link_params
*params
,
1939 struct link_vars
*vars
,
1942 struct bnx2x
*bp
= params
->bp
;
1946 CL45_RD_OVER_CL22(bp
, phy
,
1947 MDIO_REG_BANK_COMBO_IEEE0
,
1948 MDIO_COMBO_IEEE0_MII_CONTROL
, ®_val
);
1950 /* CL37 Autoneg Enabled */
1951 if (vars
->line_speed
== SPEED_AUTO_NEG
)
1952 reg_val
|= MDIO_COMBO_IEEO_MII_CONTROL_AN_EN
;
1953 else /* CL37 Autoneg Disabled */
1954 reg_val
&= ~(MDIO_COMBO_IEEO_MII_CONTROL_AN_EN
|
1955 MDIO_COMBO_IEEO_MII_CONTROL_RESTART_AN
);
1957 CL45_WR_OVER_CL22(bp
, phy
,
1958 MDIO_REG_BANK_COMBO_IEEE0
,
1959 MDIO_COMBO_IEEE0_MII_CONTROL
, reg_val
);
1961 /* Enable/Disable Autodetection */
1963 CL45_RD_OVER_CL22(bp
, phy
,
1964 MDIO_REG_BANK_SERDES_DIGITAL
,
1965 MDIO_SERDES_DIGITAL_A_1000X_CONTROL1
, ®_val
);
1966 reg_val
&= ~(MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_SIGNAL_DETECT_EN
|
1967 MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_INVERT_SIGNAL_DETECT
);
1968 reg_val
|= MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_FIBER_MODE
;
1969 if (vars
->line_speed
== SPEED_AUTO_NEG
)
1970 reg_val
|= MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_AUTODET
;
1972 reg_val
&= ~MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_AUTODET
;
1974 CL45_WR_OVER_CL22(bp
, phy
,
1975 MDIO_REG_BANK_SERDES_DIGITAL
,
1976 MDIO_SERDES_DIGITAL_A_1000X_CONTROL1
, reg_val
);
1978 /* Enable TetonII and BAM autoneg */
1979 CL45_RD_OVER_CL22(bp
, phy
,
1980 MDIO_REG_BANK_BAM_NEXT_PAGE
,
1981 MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL
,
1983 if (vars
->line_speed
== SPEED_AUTO_NEG
) {
1984 /* Enable BAM aneg Mode and TetonII aneg Mode */
1985 reg_val
|= (MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL_BAM_MODE
|
1986 MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL_TETON_AN
);
1988 /* TetonII and BAM Autoneg Disabled */
1989 reg_val
&= ~(MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL_BAM_MODE
|
1990 MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL_TETON_AN
);
1992 CL45_WR_OVER_CL22(bp
, phy
,
1993 MDIO_REG_BANK_BAM_NEXT_PAGE
,
1994 MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL
,
1998 /* Enable Cl73 FSM status bits */
1999 CL45_WR_OVER_CL22(bp
, phy
,
2000 MDIO_REG_BANK_CL73_USERB0
,
2001 MDIO_CL73_USERB0_CL73_UCTRL
,
2004 /* Enable BAM Station Manager*/
2005 CL45_WR_OVER_CL22(bp
, phy
,
2006 MDIO_REG_BANK_CL73_USERB0
,
2007 MDIO_CL73_USERB0_CL73_BAM_CTRL1
,
2008 MDIO_CL73_USERB0_CL73_BAM_CTRL1_BAM_EN
|
2009 MDIO_CL73_USERB0_CL73_BAM_CTRL1_BAM_STATION_MNGR_EN
|
2010 MDIO_CL73_USERB0_CL73_BAM_CTRL1_BAM_NP_AFTER_BP_EN
);
2012 /* Advertise CL73 link speeds */
2013 CL45_RD_OVER_CL22(bp
, phy
,
2014 MDIO_REG_BANK_CL73_IEEEB1
,
2015 MDIO_CL73_IEEEB1_AN_ADV2
,
2017 if (phy
->speed_cap_mask
&
2018 PORT_HW_CFG_SPEED_CAPABILITY_D0_10G
)
2019 reg_val
|= MDIO_CL73_IEEEB1_AN_ADV2_ADVR_10G_KX4
;
2020 if (phy
->speed_cap_mask
&
2021 PORT_HW_CFG_SPEED_CAPABILITY_D0_1G
)
2022 reg_val
|= MDIO_CL73_IEEEB1_AN_ADV2_ADVR_1000M_KX
;
2024 CL45_WR_OVER_CL22(bp
, phy
,
2025 MDIO_REG_BANK_CL73_IEEEB1
,
2026 MDIO_CL73_IEEEB1_AN_ADV2
,
2029 /* CL73 Autoneg Enabled */
2030 reg_val
= MDIO_CL73_IEEEB0_CL73_AN_CONTROL_AN_EN
;
2032 } else /* CL73 Autoneg Disabled */
2035 CL45_WR_OVER_CL22(bp
, phy
,
2036 MDIO_REG_BANK_CL73_IEEEB0
,
2037 MDIO_CL73_IEEEB0_CL73_AN_CONTROL
, reg_val
);
2040 /* program SerDes, forced speed */
2041 static void bnx2x_program_serdes(struct bnx2x_phy
*phy
,
2042 struct link_params
*params
,
2043 struct link_vars
*vars
)
2045 struct bnx2x
*bp
= params
->bp
;
2048 /* program duplex, disable autoneg and sgmii*/
2049 CL45_RD_OVER_CL22(bp
, phy
,
2050 MDIO_REG_BANK_COMBO_IEEE0
,
2051 MDIO_COMBO_IEEE0_MII_CONTROL
, ®_val
);
2052 reg_val
&= ~(MDIO_COMBO_IEEO_MII_CONTROL_FULL_DUPLEX
|
2053 MDIO_COMBO_IEEO_MII_CONTROL_AN_EN
|
2054 MDIO_COMBO_IEEO_MII_CONTROL_MAN_SGMII_SP_MASK
);
2055 if (phy
->req_duplex
== DUPLEX_FULL
)
2056 reg_val
|= MDIO_COMBO_IEEO_MII_CONTROL_FULL_DUPLEX
;
2057 CL45_WR_OVER_CL22(bp
, phy
,
2058 MDIO_REG_BANK_COMBO_IEEE0
,
2059 MDIO_COMBO_IEEE0_MII_CONTROL
, reg_val
);
2062 - needed only if the speed is greater than 1G (2.5G or 10G) */
2063 CL45_RD_OVER_CL22(bp
, phy
,
2064 MDIO_REG_BANK_SERDES_DIGITAL
,
2065 MDIO_SERDES_DIGITAL_MISC1
, ®_val
);
2066 /* clearing the speed value before setting the right speed */
2067 DP(NETIF_MSG_LINK
, "MDIO_REG_BANK_SERDES_DIGITAL = 0x%x\n", reg_val
);
2069 reg_val
&= ~(MDIO_SERDES_DIGITAL_MISC1_FORCE_SPEED_MASK
|
2070 MDIO_SERDES_DIGITAL_MISC1_FORCE_SPEED_SEL
);
2072 if (!((vars
->line_speed
== SPEED_1000
) ||
2073 (vars
->line_speed
== SPEED_100
) ||
2074 (vars
->line_speed
== SPEED_10
))) {
2076 reg_val
|= (MDIO_SERDES_DIGITAL_MISC1_REFCLK_SEL_156_25M
|
2077 MDIO_SERDES_DIGITAL_MISC1_FORCE_SPEED_SEL
);
2078 if (vars
->line_speed
== SPEED_10000
)
2080 MDIO_SERDES_DIGITAL_MISC1_FORCE_SPEED_10G_CX4
;
2081 if (vars
->line_speed
== SPEED_13000
)
2083 MDIO_SERDES_DIGITAL_MISC1_FORCE_SPEED_13G
;
2086 CL45_WR_OVER_CL22(bp
, phy
,
2087 MDIO_REG_BANK_SERDES_DIGITAL
,
2088 MDIO_SERDES_DIGITAL_MISC1
, reg_val
);
2092 static void bnx2x_set_brcm_cl37_advertisment(struct bnx2x_phy
*phy
,
2093 struct link_params
*params
)
2095 struct bnx2x
*bp
= params
->bp
;
2098 /* configure the 48 bits for BAM AN */
2100 /* set extended capabilities */
2101 if (phy
->speed_cap_mask
& PORT_HW_CFG_SPEED_CAPABILITY_D0_2_5G
)
2102 val
|= MDIO_OVER_1G_UP1_2_5G
;
2103 if (phy
->speed_cap_mask
& PORT_HW_CFG_SPEED_CAPABILITY_D0_10G
)
2104 val
|= MDIO_OVER_1G_UP1_10G
;
2105 CL45_WR_OVER_CL22(bp
, phy
,
2106 MDIO_REG_BANK_OVER_1G
,
2107 MDIO_OVER_1G_UP1
, val
);
2109 CL45_WR_OVER_CL22(bp
, phy
,
2110 MDIO_REG_BANK_OVER_1G
,
2111 MDIO_OVER_1G_UP3
, 0x400);
2114 static void bnx2x_calc_ieee_aneg_adv(struct bnx2x_phy
*phy
,
2115 struct link_params
*params
, u16
*ieee_fc
)
2117 struct bnx2x
*bp
= params
->bp
;
2118 *ieee_fc
= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_FULL_DUPLEX
;
2119 /* resolve pause mode and advertisement
2120 * Please refer to Table 28B-3 of the 802.3ab-1999 spec */
2122 switch (phy
->req_flow_ctrl
) {
2123 case BNX2X_FLOW_CTRL_AUTO
:
2124 if (params
->req_fc_auto_adv
== BNX2X_FLOW_CTRL_BOTH
) {
2126 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH
;
2129 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC
;
2132 case BNX2X_FLOW_CTRL_TX
:
2134 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC
;
2137 case BNX2X_FLOW_CTRL_RX
:
2138 case BNX2X_FLOW_CTRL_BOTH
:
2139 *ieee_fc
|= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH
;
2142 case BNX2X_FLOW_CTRL_NONE
:
2144 *ieee_fc
|= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_NONE
;
2147 DP(NETIF_MSG_LINK
, "ieee_fc = 0x%x\n", *ieee_fc
);
2150 static void bnx2x_set_ieee_aneg_advertisment(struct bnx2x_phy
*phy
,
2151 struct link_params
*params
,
2154 struct bnx2x
*bp
= params
->bp
;
2156 /* for AN, we are always publishing full duplex */
2158 CL45_WR_OVER_CL22(bp
, phy
,
2159 MDIO_REG_BANK_COMBO_IEEE0
,
2160 MDIO_COMBO_IEEE0_AUTO_NEG_ADV
, ieee_fc
);
2161 CL45_RD_OVER_CL22(bp
, phy
,
2162 MDIO_REG_BANK_CL73_IEEEB1
,
2163 MDIO_CL73_IEEEB1_AN_ADV1
, &val
);
2164 val
&= ~MDIO_CL73_IEEEB1_AN_ADV1_PAUSE_BOTH
;
2165 val
|= ((ieee_fc
<<3) & MDIO_CL73_IEEEB1_AN_ADV1_PAUSE_MASK
);
2166 CL45_WR_OVER_CL22(bp
, phy
,
2167 MDIO_REG_BANK_CL73_IEEEB1
,
2168 MDIO_CL73_IEEEB1_AN_ADV1
, val
);
2171 static void bnx2x_restart_autoneg(struct bnx2x_phy
*phy
,
2172 struct link_params
*params
,
2175 struct bnx2x
*bp
= params
->bp
;
2178 DP(NETIF_MSG_LINK
, "bnx2x_restart_autoneg\n");
2179 /* Enable and restart BAM/CL37 aneg */
2182 CL45_RD_OVER_CL22(bp
, phy
,
2183 MDIO_REG_BANK_CL73_IEEEB0
,
2184 MDIO_CL73_IEEEB0_CL73_AN_CONTROL
,
2187 CL45_WR_OVER_CL22(bp
, phy
,
2188 MDIO_REG_BANK_CL73_IEEEB0
,
2189 MDIO_CL73_IEEEB0_CL73_AN_CONTROL
,
2191 MDIO_CL73_IEEEB0_CL73_AN_CONTROL_AN_EN
|
2192 MDIO_CL73_IEEEB0_CL73_AN_CONTROL_RESTART_AN
));
2195 CL45_RD_OVER_CL22(bp
, phy
,
2196 MDIO_REG_BANK_COMBO_IEEE0
,
2197 MDIO_COMBO_IEEE0_MII_CONTROL
,
2200 "bnx2x_restart_autoneg mii_control before = 0x%x\n",
2202 CL45_WR_OVER_CL22(bp
, phy
,
2203 MDIO_REG_BANK_COMBO_IEEE0
,
2204 MDIO_COMBO_IEEE0_MII_CONTROL
,
2206 MDIO_COMBO_IEEO_MII_CONTROL_AN_EN
|
2207 MDIO_COMBO_IEEO_MII_CONTROL_RESTART_AN
));
2211 static void bnx2x_initialize_sgmii_process(struct bnx2x_phy
*phy
,
2212 struct link_params
*params
,
2213 struct link_vars
*vars
)
2215 struct bnx2x
*bp
= params
->bp
;
2218 /* in SGMII mode, the unicore is always slave */
2220 CL45_RD_OVER_CL22(bp
, phy
,
2221 MDIO_REG_BANK_SERDES_DIGITAL
,
2222 MDIO_SERDES_DIGITAL_A_1000X_CONTROL1
,
2224 control1
|= MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_INVERT_SIGNAL_DETECT
;
2225 /* set sgmii mode (and not fiber) */
2226 control1
&= ~(MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_FIBER_MODE
|
2227 MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_AUTODET
|
2228 MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_MSTR_MODE
);
2229 CL45_WR_OVER_CL22(bp
, phy
,
2230 MDIO_REG_BANK_SERDES_DIGITAL
,
2231 MDIO_SERDES_DIGITAL_A_1000X_CONTROL1
,
2234 /* if forced speed */
2235 if (!(vars
->line_speed
== SPEED_AUTO_NEG
)) {
2236 /* set speed, disable autoneg */
2239 CL45_RD_OVER_CL22(bp
, phy
,
2240 MDIO_REG_BANK_COMBO_IEEE0
,
2241 MDIO_COMBO_IEEE0_MII_CONTROL
,
2243 mii_control
&= ~(MDIO_COMBO_IEEO_MII_CONTROL_AN_EN
|
2244 MDIO_COMBO_IEEO_MII_CONTROL_MAN_SGMII_SP_MASK
|
2245 MDIO_COMBO_IEEO_MII_CONTROL_FULL_DUPLEX
);
2247 switch (vars
->line_speed
) {
2250 MDIO_COMBO_IEEO_MII_CONTROL_MAN_SGMII_SP_100
;
2254 MDIO_COMBO_IEEO_MII_CONTROL_MAN_SGMII_SP_1000
;
2257 /* there is nothing to set for 10M */
2260 /* invalid speed for SGMII */
2261 DP(NETIF_MSG_LINK
, "Invalid line_speed 0x%x\n",
2266 /* setting the full duplex */
2267 if (phy
->req_duplex
== DUPLEX_FULL
)
2269 MDIO_COMBO_IEEO_MII_CONTROL_FULL_DUPLEX
;
2270 CL45_WR_OVER_CL22(bp
, phy
,
2271 MDIO_REG_BANK_COMBO_IEEE0
,
2272 MDIO_COMBO_IEEE0_MII_CONTROL
,
2275 } else { /* AN mode */
2276 /* enable and restart AN */
2277 bnx2x_restart_autoneg(phy
, params
, 0);
2286 static void bnx2x_pause_resolve(struct link_vars
*vars
, u32 pause_result
)
2288 switch (pause_result
) { /* ASYM P ASYM P */
2289 case 0xb: /* 1 0 1 1 */
2290 vars
->flow_ctrl
= BNX2X_FLOW_CTRL_TX
;
2293 case 0xe: /* 1 1 1 0 */
2294 vars
->flow_ctrl
= BNX2X_FLOW_CTRL_RX
;
2297 case 0x5: /* 0 1 0 1 */
2298 case 0x7: /* 0 1 1 1 */
2299 case 0xd: /* 1 1 0 1 */
2300 case 0xf: /* 1 1 1 1 */
2301 vars
->flow_ctrl
= BNX2X_FLOW_CTRL_BOTH
;
2307 if (pause_result
& (1<<0))
2308 vars
->link_status
|= LINK_STATUS_LINK_PARTNER_SYMMETRIC_PAUSE
;
2309 if (pause_result
& (1<<1))
2310 vars
->link_status
|= LINK_STATUS_LINK_PARTNER_ASYMMETRIC_PAUSE
;
2313 static u8
bnx2x_direct_parallel_detect_used(struct bnx2x_phy
*phy
,
2314 struct link_params
*params
)
2316 struct bnx2x
*bp
= params
->bp
;
2317 u16 pd_10g
, status2_1000x
;
2318 if (phy
->req_line_speed
!= SPEED_AUTO_NEG
)
2320 CL45_RD_OVER_CL22(bp
, phy
,
2321 MDIO_REG_BANK_SERDES_DIGITAL
,
2322 MDIO_SERDES_DIGITAL_A_1000X_STATUS2
,
2324 CL45_RD_OVER_CL22(bp
, phy
,
2325 MDIO_REG_BANK_SERDES_DIGITAL
,
2326 MDIO_SERDES_DIGITAL_A_1000X_STATUS2
,
2328 if (status2_1000x
& MDIO_SERDES_DIGITAL_A_1000X_STATUS2_AN_DISABLED
) {
2329 DP(NETIF_MSG_LINK
, "1G parallel detect link on port %d\n",
2334 CL45_RD_OVER_CL22(bp
, phy
,
2335 MDIO_REG_BANK_10G_PARALLEL_DETECT
,
2336 MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_STATUS
,
2339 if (pd_10g
& MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_STATUS_PD_LINK
) {
2340 DP(NETIF_MSG_LINK
, "10G parallel detect link on port %d\n",
2347 static void bnx2x_flow_ctrl_resolve(struct bnx2x_phy
*phy
,
2348 struct link_params
*params
,
2349 struct link_vars
*vars
,
2352 struct bnx2x
*bp
= params
->bp
;
2353 u16 ld_pause
; /* local driver */
2354 u16 lp_pause
; /* link partner */
2357 vars
->flow_ctrl
= BNX2X_FLOW_CTRL_NONE
;
2359 /* resolve from gp_status in case of AN complete and not sgmii */
2360 if (phy
->req_flow_ctrl
!= BNX2X_FLOW_CTRL_AUTO
)
2361 vars
->flow_ctrl
= phy
->req_flow_ctrl
;
2362 else if (phy
->req_line_speed
!= SPEED_AUTO_NEG
)
2363 vars
->flow_ctrl
= params
->req_fc_auto_adv
;
2364 else if ((gp_status
& MDIO_AN_CL73_OR_37_COMPLETE
) &&
2365 (!(vars
->phy_flags
& PHY_SGMII_FLAG
))) {
2366 if (bnx2x_direct_parallel_detect_used(phy
, params
)) {
2367 vars
->flow_ctrl
= params
->req_fc_auto_adv
;
2371 (MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_AUTONEG_COMPLETE
|
2372 MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_MR_LP_NP_AN_ABLE
)) ==
2373 (MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_AUTONEG_COMPLETE
|
2374 MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_MR_LP_NP_AN_ABLE
)) {
2376 CL45_RD_OVER_CL22(bp
, phy
,
2377 MDIO_REG_BANK_CL73_IEEEB1
,
2378 MDIO_CL73_IEEEB1_AN_ADV1
,
2380 CL45_RD_OVER_CL22(bp
, phy
,
2381 MDIO_REG_BANK_CL73_IEEEB1
,
2382 MDIO_CL73_IEEEB1_AN_LP_ADV1
,
2384 pause_result
= (ld_pause
&
2385 MDIO_CL73_IEEEB1_AN_ADV1_PAUSE_MASK
)
2387 pause_result
|= (lp_pause
&
2388 MDIO_CL73_IEEEB1_AN_LP_ADV1_PAUSE_MASK
)
2390 DP(NETIF_MSG_LINK
, "pause_result CL73 0x%x\n",
2393 CL45_RD_OVER_CL22(bp
, phy
,
2394 MDIO_REG_BANK_COMBO_IEEE0
,
2395 MDIO_COMBO_IEEE0_AUTO_NEG_ADV
,
2397 CL45_RD_OVER_CL22(bp
, phy
,
2398 MDIO_REG_BANK_COMBO_IEEE0
,
2399 MDIO_COMBO_IEEE0_AUTO_NEG_LINK_PARTNER_ABILITY1
,
2401 pause_result
= (ld_pause
&
2402 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_MASK
)>>5;
2403 pause_result
|= (lp_pause
&
2404 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_MASK
)>>7;
2405 DP(NETIF_MSG_LINK
, "pause_result CL37 0x%x\n",
2408 bnx2x_pause_resolve(vars
, pause_result
);
2410 DP(NETIF_MSG_LINK
, "flow_ctrl 0x%x\n", vars
->flow_ctrl
);
2413 static void bnx2x_check_fallback_to_cl37(struct bnx2x_phy
*phy
,
2414 struct link_params
*params
)
2416 struct bnx2x
*bp
= params
->bp
;
2417 u16 rx_status
, ustat_val
, cl37_fsm_recieved
;
2418 DP(NETIF_MSG_LINK
, "bnx2x_check_fallback_to_cl37\n");
2419 /* Step 1: Make sure signal is detected */
2420 CL45_RD_OVER_CL22(bp
, phy
,
2424 if ((rx_status
& MDIO_RX0_RX_STATUS_SIGDET
) !=
2425 (MDIO_RX0_RX_STATUS_SIGDET
)) {
2426 DP(NETIF_MSG_LINK
, "Signal is not detected. Restoring CL73."
2427 "rx_status(0x80b0) = 0x%x\n", rx_status
);
2428 CL45_WR_OVER_CL22(bp
, phy
,
2429 MDIO_REG_BANK_CL73_IEEEB0
,
2430 MDIO_CL73_IEEEB0_CL73_AN_CONTROL
,
2431 MDIO_CL73_IEEEB0_CL73_AN_CONTROL_AN_EN
);
2434 /* Step 2: Check CL73 state machine */
2435 CL45_RD_OVER_CL22(bp
, phy
,
2436 MDIO_REG_BANK_CL73_USERB0
,
2437 MDIO_CL73_USERB0_CL73_USTAT1
,
2440 (MDIO_CL73_USERB0_CL73_USTAT1_LINK_STATUS_CHECK
|
2441 MDIO_CL73_USERB0_CL73_USTAT1_AN_GOOD_CHECK_BAM37
)) !=
2442 (MDIO_CL73_USERB0_CL73_USTAT1_LINK_STATUS_CHECK
|
2443 MDIO_CL73_USERB0_CL73_USTAT1_AN_GOOD_CHECK_BAM37
)) {
2444 DP(NETIF_MSG_LINK
, "CL73 state-machine is not stable. "
2445 "ustat_val(0x8371) = 0x%x\n", ustat_val
);
2448 /* Step 3: Check CL37 Message Pages received to indicate LP
2449 supports only CL37 */
2450 CL45_RD_OVER_CL22(bp
, phy
,
2451 MDIO_REG_BANK_REMOTE_PHY
,
2452 MDIO_REMOTE_PHY_MISC_RX_STATUS
,
2453 &cl37_fsm_recieved
);
2454 if ((cl37_fsm_recieved
&
2455 (MDIO_REMOTE_PHY_MISC_RX_STATUS_CL37_FSM_RECEIVED_OVER1G_MSG
|
2456 MDIO_REMOTE_PHY_MISC_RX_STATUS_CL37_FSM_RECEIVED_BRCM_OUI_MSG
)) !=
2457 (MDIO_REMOTE_PHY_MISC_RX_STATUS_CL37_FSM_RECEIVED_OVER1G_MSG
|
2458 MDIO_REMOTE_PHY_MISC_RX_STATUS_CL37_FSM_RECEIVED_BRCM_OUI_MSG
)) {
2459 DP(NETIF_MSG_LINK
, "No CL37 FSM were received. "
2460 "misc_rx_status(0x8330) = 0x%x\n",
2464 /* The combined cl37/cl73 fsm state information indicating that we are
2465 connected to a device which does not support cl73, but does support
2466 cl37 BAM. In this case we disable cl73 and restart cl37 auto-neg */
2468 CL45_WR_OVER_CL22(bp
, phy
,
2469 MDIO_REG_BANK_CL73_IEEEB0
,
2470 MDIO_CL73_IEEEB0_CL73_AN_CONTROL
,
2472 /* Restart CL37 autoneg */
2473 bnx2x_restart_autoneg(phy
, params
, 0);
2474 DP(NETIF_MSG_LINK
, "Disabling CL73, and restarting CL37 autoneg\n");
2477 static void bnx2x_xgxs_an_resolve(struct bnx2x_phy
*phy
,
2478 struct link_params
*params
,
2479 struct link_vars
*vars
,
2482 if (gp_status
& MDIO_AN_CL73_OR_37_COMPLETE
)
2483 vars
->link_status
|=
2484 LINK_STATUS_AUTO_NEGOTIATE_COMPLETE
;
2486 if (bnx2x_direct_parallel_detect_used(phy
, params
))
2487 vars
->link_status
|=
2488 LINK_STATUS_PARALLEL_DETECTION_USED
;
2491 static u8
bnx2x_link_settings_status(struct bnx2x_phy
*phy
,
2492 struct link_params
*params
,
2493 struct link_vars
*vars
)
2495 struct bnx2x
*bp
= params
->bp
;
2496 u16 new_line_speed
, gp_status
;
2499 /* Read gp_status */
2500 CL45_RD_OVER_CL22(bp
, phy
,
2501 MDIO_REG_BANK_GP_STATUS
,
2502 MDIO_GP_STATUS_TOP_AN_STATUS1
,
2505 if (phy
->req_line_speed
== SPEED_AUTO_NEG
)
2506 vars
->link_status
|= LINK_STATUS_AUTO_NEGOTIATE_ENABLED
;
2507 if (gp_status
& MDIO_GP_STATUS_TOP_AN_STATUS1_LINK_STATUS
) {
2508 DP(NETIF_MSG_LINK
, "phy link up gp_status=0x%x\n",
2511 vars
->phy_link_up
= 1;
2512 vars
->link_status
|= LINK_STATUS_LINK_UP
;
2514 if (gp_status
& MDIO_GP_STATUS_TOP_AN_STATUS1_DUPLEX_STATUS
)
2515 vars
->duplex
= DUPLEX_FULL
;
2517 vars
->duplex
= DUPLEX_HALF
;
2519 if (SINGLE_MEDIA_DIRECT(params
)) {
2520 bnx2x_flow_ctrl_resolve(phy
, params
, vars
, gp_status
);
2521 if (phy
->req_line_speed
== SPEED_AUTO_NEG
)
2522 bnx2x_xgxs_an_resolve(phy
, params
, vars
,
2526 switch (gp_status
& GP_STATUS_SPEED_MASK
) {
2528 new_line_speed
= SPEED_10
;
2529 if (vars
->duplex
== DUPLEX_FULL
)
2530 vars
->link_status
|= LINK_10TFD
;
2532 vars
->link_status
|= LINK_10THD
;
2535 case GP_STATUS_100M
:
2536 new_line_speed
= SPEED_100
;
2537 if (vars
->duplex
== DUPLEX_FULL
)
2538 vars
->link_status
|= LINK_100TXFD
;
2540 vars
->link_status
|= LINK_100TXHD
;
2544 case GP_STATUS_1G_KX
:
2545 new_line_speed
= SPEED_1000
;
2546 if (vars
->duplex
== DUPLEX_FULL
)
2547 vars
->link_status
|= LINK_1000TFD
;
2549 vars
->link_status
|= LINK_1000THD
;
2552 case GP_STATUS_2_5G
:
2553 new_line_speed
= SPEED_2500
;
2554 if (vars
->duplex
== DUPLEX_FULL
)
2555 vars
->link_status
|= LINK_2500TFD
;
2557 vars
->link_status
|= LINK_2500THD
;
2563 "link speed unsupported gp_status 0x%x\n",
2567 case GP_STATUS_10G_KX4
:
2568 case GP_STATUS_10G_HIG
:
2569 case GP_STATUS_10G_CX4
:
2570 new_line_speed
= SPEED_10000
;
2571 vars
->link_status
|= LINK_10GTFD
;
2574 case GP_STATUS_12G_HIG
:
2575 new_line_speed
= SPEED_12000
;
2576 vars
->link_status
|= LINK_12GTFD
;
2579 case GP_STATUS_12_5G
:
2580 new_line_speed
= SPEED_12500
;
2581 vars
->link_status
|= LINK_12_5GTFD
;
2585 new_line_speed
= SPEED_13000
;
2586 vars
->link_status
|= LINK_13GTFD
;
2590 new_line_speed
= SPEED_15000
;
2591 vars
->link_status
|= LINK_15GTFD
;
2595 new_line_speed
= SPEED_16000
;
2596 vars
->link_status
|= LINK_16GTFD
;
2601 "link speed unsupported gp_status 0x%x\n",
2606 vars
->line_speed
= new_line_speed
;
2608 } else { /* link_down */
2609 DP(NETIF_MSG_LINK
, "phy link down\n");
2611 vars
->phy_link_up
= 0;
2613 vars
->duplex
= DUPLEX_FULL
;
2614 vars
->flow_ctrl
= BNX2X_FLOW_CTRL_NONE
;
2615 vars
->mac_type
= MAC_TYPE_NONE
;
2617 if ((phy
->req_line_speed
== SPEED_AUTO_NEG
) &&
2618 SINGLE_MEDIA_DIRECT(params
)) {
2619 /* Check signal is detected */
2620 bnx2x_check_fallback_to_cl37(phy
, params
);
2624 DP(NETIF_MSG_LINK
, "gp_status 0x%x phy_link_up %x line_speed %x\n",
2625 gp_status
, vars
->phy_link_up
, vars
->line_speed
);
2626 DP(NETIF_MSG_LINK
, "duplex %x flow_ctrl 0x%x link_status 0x%x\n",
2627 vars
->duplex
, vars
->flow_ctrl
, vars
->link_status
);
2631 static void bnx2x_set_gmii_tx_driver(struct link_params
*params
)
2633 struct bnx2x
*bp
= params
->bp
;
2634 struct bnx2x_phy
*phy
= ¶ms
->phy
[INT_PHY
];
2640 CL45_RD_OVER_CL22(bp
, phy
,
2641 MDIO_REG_BANK_OVER_1G
,
2642 MDIO_OVER_1G_LP_UP2
, &lp_up2
);
2644 /* bits [10:7] at lp_up2, positioned at [15:12] */
2645 lp_up2
= (((lp_up2
& MDIO_OVER_1G_LP_UP2_PREEMPHASIS_MASK
) >>
2646 MDIO_OVER_1G_LP_UP2_PREEMPHASIS_SHIFT
) <<
2647 MDIO_TX0_TX_DRIVER_PREEMPHASIS_SHIFT
);
2652 for (bank
= MDIO_REG_BANK_TX0
; bank
<= MDIO_REG_BANK_TX3
;
2653 bank
+= (MDIO_REG_BANK_TX1
- MDIO_REG_BANK_TX0
)) {
2654 CL45_RD_OVER_CL22(bp
, phy
,
2656 MDIO_TX0_TX_DRIVER
, &tx_driver
);
2658 /* replace tx_driver bits [15:12] */
2660 (tx_driver
& MDIO_TX0_TX_DRIVER_PREEMPHASIS_MASK
)) {
2661 tx_driver
&= ~MDIO_TX0_TX_DRIVER_PREEMPHASIS_MASK
;
2662 tx_driver
|= lp_up2
;
2663 CL45_WR_OVER_CL22(bp
, phy
,
2665 MDIO_TX0_TX_DRIVER
, tx_driver
);
2670 static u8
bnx2x_emac_program(struct link_params
*params
,
2671 struct link_vars
*vars
)
2673 struct bnx2x
*bp
= params
->bp
;
2674 u8 port
= params
->port
;
2677 DP(NETIF_MSG_LINK
, "setting link speed & duplex\n");
2678 bnx2x_bits_dis(bp
, GRCBASE_EMAC0
+ port
*0x400 +
2680 (EMAC_MODE_25G_MODE
|
2681 EMAC_MODE_PORT_MII_10M
|
2682 EMAC_MODE_HALF_DUPLEX
));
2683 switch (vars
->line_speed
) {
2685 mode
|= EMAC_MODE_PORT_MII_10M
;
2689 mode
|= EMAC_MODE_PORT_MII
;
2693 mode
|= EMAC_MODE_PORT_GMII
;
2697 mode
|= (EMAC_MODE_25G_MODE
| EMAC_MODE_PORT_GMII
);
2701 /* 10G not valid for EMAC */
2702 DP(NETIF_MSG_LINK
, "Invalid line_speed 0x%x\n",
2707 if (vars
->duplex
== DUPLEX_HALF
)
2708 mode
|= EMAC_MODE_HALF_DUPLEX
;
2710 GRCBASE_EMAC0
+ port
*0x400 + EMAC_REG_EMAC_MODE
,
2713 bnx2x_set_led(params
, vars
, LED_MODE_OPER
, vars
->line_speed
);
2717 static void bnx2x_set_preemphasis(struct bnx2x_phy
*phy
,
2718 struct link_params
*params
)
2722 struct bnx2x
*bp
= params
->bp
;
2724 for (bank
= MDIO_REG_BANK_RX0
, i
= 0; bank
<= MDIO_REG_BANK_RX3
;
2725 bank
+= (MDIO_REG_BANK_RX1
-MDIO_REG_BANK_RX0
), i
++) {
2726 CL45_WR_OVER_CL22(bp
, phy
,
2728 MDIO_RX0_RX_EQ_BOOST
,
2729 phy
->rx_preemphasis
[i
]);
2732 for (bank
= MDIO_REG_BANK_TX0
, i
= 0; bank
<= MDIO_REG_BANK_TX3
;
2733 bank
+= (MDIO_REG_BANK_TX1
- MDIO_REG_BANK_TX0
), i
++) {
2734 CL45_WR_OVER_CL22(bp
, phy
,
2737 phy
->tx_preemphasis
[i
]);
2741 static void bnx2x_init_internal_phy(struct bnx2x_phy
*phy
,
2742 struct link_params
*params
,
2743 struct link_vars
*vars
)
2745 struct bnx2x
*bp
= params
->bp
;
2746 u8 enable_cl73
= (SINGLE_MEDIA_DIRECT(params
) ||
2747 (params
->loopback_mode
== LOOPBACK_XGXS
));
2748 if (!(vars
->phy_flags
& PHY_SGMII_FLAG
)) {
2749 if (SINGLE_MEDIA_DIRECT(params
) &&
2750 (params
->feature_config_flags
&
2751 FEATURE_CONFIG_OVERRIDE_PREEMPHASIS_ENABLED
))
2752 bnx2x_set_preemphasis(phy
, params
);
2754 /* forced speed requested? */
2755 if (vars
->line_speed
!= SPEED_AUTO_NEG
||
2756 (SINGLE_MEDIA_DIRECT(params
) &&
2757 params
->loopback_mode
== LOOPBACK_EXT
)) {
2758 DP(NETIF_MSG_LINK
, "not SGMII, no AN\n");
2760 /* disable autoneg */
2761 bnx2x_set_autoneg(phy
, params
, vars
, 0);
2763 /* program speed and duplex */
2764 bnx2x_program_serdes(phy
, params
, vars
);
2766 } else { /* AN_mode */
2767 DP(NETIF_MSG_LINK
, "not SGMII, AN\n");
2770 bnx2x_set_brcm_cl37_advertisment(phy
, params
);
2772 /* program duplex & pause advertisement (for aneg) */
2773 bnx2x_set_ieee_aneg_advertisment(phy
, params
,
2776 /* enable autoneg */
2777 bnx2x_set_autoneg(phy
, params
, vars
, enable_cl73
);
2779 /* enable and restart AN */
2780 bnx2x_restart_autoneg(phy
, params
, enable_cl73
);
2783 } else { /* SGMII mode */
2784 DP(NETIF_MSG_LINK
, "SGMII\n");
2786 bnx2x_initialize_sgmii_process(phy
, params
, vars
);
2790 static u8
bnx2x_init_serdes(struct bnx2x_phy
*phy
,
2791 struct link_params
*params
,
2792 struct link_vars
*vars
)
2795 vars
->phy_flags
|= PHY_SGMII_FLAG
;
2796 bnx2x_calc_ieee_aneg_adv(phy
, params
, &vars
->ieee_fc
);
2797 bnx2x_set_aer_mmd_serdes(params
->bp
, phy
);
2798 rc
= bnx2x_reset_unicore(params
, phy
, 1);
2799 /* reset the SerDes and wait for reset bit return low */
2802 bnx2x_set_aer_mmd_serdes(params
->bp
, phy
);
2807 static u8
bnx2x_init_xgxs(struct bnx2x_phy
*phy
,
2808 struct link_params
*params
,
2809 struct link_vars
*vars
)
2812 vars
->phy_flags
= PHY_XGXS_FLAG
;
2813 if ((phy
->req_line_speed
&&
2814 ((phy
->req_line_speed
== SPEED_100
) ||
2815 (phy
->req_line_speed
== SPEED_10
))) ||
2816 (!phy
->req_line_speed
&&
2817 (phy
->speed_cap_mask
>=
2818 PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_FULL
) &&
2819 (phy
->speed_cap_mask
<
2820 PORT_HW_CFG_SPEED_CAPABILITY_D0_1G
)
2822 vars
->phy_flags
|= PHY_SGMII_FLAG
;
2824 vars
->phy_flags
&= ~PHY_SGMII_FLAG
;
2826 bnx2x_calc_ieee_aneg_adv(phy
, params
, &vars
->ieee_fc
);
2827 bnx2x_set_aer_mmd_xgxs(params
, phy
);
2828 bnx2x_set_master_ln(params
, phy
);
2830 rc
= bnx2x_reset_unicore(params
, phy
, 0);
2831 /* reset the SerDes and wait for reset bit return low */
2835 bnx2x_set_aer_mmd_xgxs(params
, phy
);
2837 /* setting the masterLn_def again after the reset */
2838 bnx2x_set_master_ln(params
, phy
);
2839 bnx2x_set_swap_lanes(params
, phy
);
2844 static u16
bnx2x_wait_reset_complete(struct bnx2x
*bp
,
2845 struct bnx2x_phy
*phy
)
2848 /* Wait for soft reset to get cleared upto 1 sec */
2849 for (cnt
= 0; cnt
< 1000; cnt
++) {
2850 bnx2x_cl45_read(bp
, phy
,
2851 MDIO_PMA_DEVAD
, MDIO_PMA_REG_CTRL
, &ctrl
);
2852 if (!(ctrl
& (1<<15)))
2856 DP(NETIF_MSG_LINK
, "control reg 0x%x (after %d ms)\n", ctrl
, cnt
);
2860 static void bnx2x_link_int_enable(struct link_params
*params
)
2862 u8 port
= params
->port
;
2864 struct bnx2x
*bp
= params
->bp
;
2866 /* setting the status to report on link up
2867 for either XGXS or SerDes */
2869 if (params
->switch_cfg
== SWITCH_CFG_10G
) {
2870 mask
= (NIG_MASK_XGXS0_LINK10G
|
2871 NIG_MASK_XGXS0_LINK_STATUS
);
2872 DP(NETIF_MSG_LINK
, "enabled XGXS interrupt\n");
2873 if (!(SINGLE_MEDIA_DIRECT(params
)) &&
2874 params
->phy
[INT_PHY
].type
!=
2875 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_FAILURE
) {
2876 mask
|= NIG_MASK_MI_INT
;
2877 DP(NETIF_MSG_LINK
, "enabled external phy int\n");
2880 } else { /* SerDes */
2881 mask
= NIG_MASK_SERDES0_LINK_STATUS
;
2882 DP(NETIF_MSG_LINK
, "enabled SerDes interrupt\n");
2883 if (!(SINGLE_MEDIA_DIRECT(params
)) &&
2884 params
->phy
[INT_PHY
].type
!=
2885 PORT_HW_CFG_SERDES_EXT_PHY_TYPE_NOT_CONN
) {
2886 mask
|= NIG_MASK_MI_INT
;
2887 DP(NETIF_MSG_LINK
, "enabled external phy int\n");
2891 NIG_REG_MASK_INTERRUPT_PORT0
+ port
*4,
2894 DP(NETIF_MSG_LINK
, "port %x, is_xgxs %x, int_status 0x%x\n", port
,
2895 (params
->switch_cfg
== SWITCH_CFG_10G
),
2896 REG_RD(bp
, NIG_REG_STATUS_INTERRUPT_PORT0
+ port
*4));
2897 DP(NETIF_MSG_LINK
, " int_mask 0x%x, MI_INT %x, SERDES_LINK %x\n",
2898 REG_RD(bp
, NIG_REG_MASK_INTERRUPT_PORT0
+ port
*4),
2899 REG_RD(bp
, NIG_REG_EMAC0_STATUS_MISC_MI_INT
+ port
*0x18),
2900 REG_RD(bp
, NIG_REG_SERDES0_STATUS_LINK_STATUS
+port
*0x3c));
2901 DP(NETIF_MSG_LINK
, " 10G %x, XGXS_LINK %x\n",
2902 REG_RD(bp
, NIG_REG_XGXS0_STATUS_LINK10G
+ port
*0x68),
2903 REG_RD(bp
, NIG_REG_XGXS0_STATUS_LINK_STATUS
+ port
*0x68));
2906 static void bnx2x_rearm_latch_signal(struct bnx2x
*bp
, u8 port
,
2909 u32 latch_status
= 0;
2912 * Disable the MI INT ( external phy int ) by writing 1 to the
2913 * status register. Link down indication is high-active-signal,
2914 * so in this case we need to write the status to clear the XOR
2916 /* Read Latched signals */
2917 latch_status
= REG_RD(bp
,
2918 NIG_REG_LATCH_STATUS_0
+ port
*8);
2919 DP(NETIF_MSG_LINK
, "latch_status = 0x%x\n", latch_status
);
2920 /* Handle only those with latched-signal=up.*/
2923 NIG_REG_STATUS_INTERRUPT_PORT0
2925 NIG_STATUS_EMAC0_MI_INT
);
2928 NIG_REG_STATUS_INTERRUPT_PORT0
2930 NIG_STATUS_EMAC0_MI_INT
);
2932 if (latch_status
& 1) {
2934 /* For all latched-signal=up : Re-Arm Latch signals */
2935 REG_WR(bp
, NIG_REG_LATCH_STATUS_0
+ port
*8,
2936 (latch_status
& 0xfffe) | (latch_status
& 1));
2938 /* For all latched-signal=up,Write original_signal to status */
2941 static void bnx2x_link_int_ack(struct link_params
*params
,
2942 struct link_vars
*vars
, u8 is_10g
)
2944 struct bnx2x
*bp
= params
->bp
;
2945 u8 port
= params
->port
;
2947 /* first reset all status
2948 * we assume only one line will be change at a time */
2949 bnx2x_bits_dis(bp
, NIG_REG_STATUS_INTERRUPT_PORT0
+ port
*4,
2950 (NIG_STATUS_XGXS0_LINK10G
|
2951 NIG_STATUS_XGXS0_LINK_STATUS
|
2952 NIG_STATUS_SERDES0_LINK_STATUS
));
2953 if (vars
->phy_link_up
) {
2955 /* Disable the 10G link interrupt
2956 * by writing 1 to the status register
2958 DP(NETIF_MSG_LINK
, "10G XGXS phy link up\n");
2960 NIG_REG_STATUS_INTERRUPT_PORT0
+ port
*4,
2961 NIG_STATUS_XGXS0_LINK10G
);
2963 } else if (params
->switch_cfg
== SWITCH_CFG_10G
) {
2964 /* Disable the link interrupt
2965 * by writing 1 to the relevant lane
2966 * in the status register
2968 u32 ser_lane
= ((params
->lane_config
&
2969 PORT_HW_CFG_LANE_SWAP_CFG_MASTER_MASK
) >>
2970 PORT_HW_CFG_LANE_SWAP_CFG_MASTER_SHIFT
);
2972 DP(NETIF_MSG_LINK
, "%d speed XGXS phy link up\n",
2975 NIG_REG_STATUS_INTERRUPT_PORT0
+ port
*4,
2977 NIG_STATUS_XGXS0_LINK_STATUS_SIZE
));
2979 } else { /* SerDes */
2980 DP(NETIF_MSG_LINK
, "SerDes phy link up\n");
2981 /* Disable the link interrupt
2982 * by writing 1 to the status register
2985 NIG_REG_STATUS_INTERRUPT_PORT0
+ port
*4,
2986 NIG_STATUS_SERDES0_LINK_STATUS
);
2992 static u8
bnx2x_format_ver(u32 num
, u8
*str
, u16
*len
)
2995 u32 mask
= 0xf0000000;
2998 u8 remove_leading_zeros
= 1;
3000 /* Need more than 10chars for this format */
3008 digit
= ((num
& mask
) >> shift
);
3009 if (digit
== 0 && remove_leading_zeros
) {
3012 } else if (digit
< 0xa)
3013 *str_ptr
= digit
+ '0';
3015 *str_ptr
= digit
- 0xa + 'a';
3016 remove_leading_zeros
= 0;
3024 remove_leading_zeros
= 1;
3031 static u8
bnx2x_null_format_ver(u32 spirom_ver
, u8
*str
, u16
*len
)
3038 u8
bnx2x_get_ext_phy_fw_version(struct link_params
*params
, u8 driver_loaded
,
3039 u8
*version
, u16 len
)
3044 u8
*ver_p
= version
;
3045 u16 remain_len
= len
;
3046 if (version
== NULL
|| params
== NULL
)
3050 /* Extract first external phy*/
3052 spirom_ver
= REG_RD(bp
, params
->phy
[EXT_PHY1
].ver_addr
);
3054 if (params
->phy
[EXT_PHY1
].format_fw_ver
) {
3055 status
|= params
->phy
[EXT_PHY1
].format_fw_ver(spirom_ver
,
3058 ver_p
+= (len
- remain_len
);
3060 if ((params
->num_phys
== MAX_PHYS
) &&
3061 (params
->phy
[EXT_PHY2
].ver_addr
!= 0)) {
3062 spirom_ver
= REG_RD(bp
,
3063 params
->phy
[EXT_PHY2
].ver_addr
);
3064 if (params
->phy
[EXT_PHY2
].format_fw_ver
) {
3068 status
|= params
->phy
[EXT_PHY2
].format_fw_ver(
3072 ver_p
= version
+ (len
- remain_len
);
3079 static void bnx2x_set_xgxs_loopback(struct bnx2x_phy
*phy
,
3080 struct link_params
*params
)
3082 u8 port
= params
->port
;
3083 struct bnx2x
*bp
= params
->bp
;
3085 if (phy
->req_line_speed
!= SPEED_1000
) {
3088 DP(NETIF_MSG_LINK
, "XGXS 10G loopback enable\n");
3090 /* change the uni_phy_addr in the nig */
3091 md_devad
= REG_RD(bp
, (NIG_REG_XGXS0_CTRL_MD_DEVAD
+
3094 REG_WR(bp
, NIG_REG_XGXS0_CTRL_MD_DEVAD
+ port
*0x18, 0x5);
3096 bnx2x_cl45_write(bp
, phy
,
3098 (MDIO_REG_BANK_AER_BLOCK
+
3099 (MDIO_AER_BLOCK_AER_REG
& 0xf)),
3102 bnx2x_cl45_write(bp
, phy
,
3104 (MDIO_REG_BANK_CL73_IEEEB0
+
3105 (MDIO_CL73_IEEEB0_CL73_AN_CONTROL
& 0xf)),
3108 /* set aer mmd back */
3109 bnx2x_set_aer_mmd_xgxs(params
, phy
);
3112 REG_WR(bp
, NIG_REG_XGXS0_CTRL_MD_DEVAD
+ port
*0x18,
3117 DP(NETIF_MSG_LINK
, "XGXS 1G loopback enable\n");
3118 bnx2x_cl45_read(bp
, phy
, 5,
3119 (MDIO_REG_BANK_COMBO_IEEE0
+
3120 (MDIO_COMBO_IEEE0_MII_CONTROL
& 0xf)),
3122 bnx2x_cl45_write(bp
, phy
, 5,
3123 (MDIO_REG_BANK_COMBO_IEEE0
+
3124 (MDIO_COMBO_IEEE0_MII_CONTROL
& 0xf)),
3126 MDIO_COMBO_IEEO_MII_CONTROL_LOOPBACK
);
3130 u8
bnx2x_set_led(struct link_params
*params
,
3131 struct link_vars
*vars
, u8 mode
, u32 speed
)
3133 u8 port
= params
->port
;
3134 u16 hw_led_mode
= params
->hw_led_mode
;
3137 u32 emac_base
= port
? GRCBASE_EMAC1
: GRCBASE_EMAC0
;
3138 struct bnx2x
*bp
= params
->bp
;
3139 DP(NETIF_MSG_LINK
, "bnx2x_set_led: port %x, mode %d\n", port
, mode
);
3140 DP(NETIF_MSG_LINK
, "speed 0x%x, hw_led_mode 0x%x\n",
3141 speed
, hw_led_mode
);
3143 for (phy_idx
= EXT_PHY1
; phy_idx
< MAX_PHYS
; phy_idx
++) {
3144 if (params
->phy
[phy_idx
].set_link_led
) {
3145 params
->phy
[phy_idx
].set_link_led(
3146 ¶ms
->phy
[phy_idx
], params
, mode
);
3151 case LED_MODE_FRONT_PANEL_OFF
:
3153 REG_WR(bp
, NIG_REG_LED_10G_P0
+ port
*4, 0);
3154 REG_WR(bp
, NIG_REG_LED_MODE_P0
+ port
*4,
3155 SHARED_HW_CFG_LED_MAC1
);
3157 tmp
= EMAC_RD(bp
, EMAC_REG_EMAC_LED
);
3158 EMAC_WR(bp
, EMAC_REG_EMAC_LED
, (tmp
| EMAC_LED_OVERRIDE
));
3163 * For all other phys, OPER mode is same as ON, so in case
3164 * link is down, do nothing
3169 if (SINGLE_MEDIA_DIRECT(params
)) {
3171 * This is a work-around for HW issue found when link
3174 REG_WR(bp
, NIG_REG_LED_MODE_P0
+ port
*4, 0);
3175 REG_WR(bp
, NIG_REG_LED_10G_P0
+ port
*4, 1);
3177 REG_WR(bp
, NIG_REG_LED_MODE_P0
+ port
*4,
3181 REG_WR(bp
, NIG_REG_LED_CONTROL_OVERRIDE_TRAFFIC_P0
+
3183 /* Set blinking rate to ~15.9Hz */
3184 REG_WR(bp
, NIG_REG_LED_CONTROL_BLINK_RATE_P0
+ port
*4,
3185 LED_BLINK_RATE_VAL
);
3186 REG_WR(bp
, NIG_REG_LED_CONTROL_BLINK_RATE_ENA_P0
+
3188 tmp
= EMAC_RD(bp
, EMAC_REG_EMAC_LED
);
3189 EMAC_WR(bp
, EMAC_REG_EMAC_LED
,
3190 (tmp
& (~EMAC_LED_OVERRIDE
)));
3192 if (CHIP_IS_E1(bp
) &&
3193 ((speed
== SPEED_2500
) ||
3194 (speed
== SPEED_1000
) ||
3195 (speed
== SPEED_100
) ||
3196 (speed
== SPEED_10
))) {
3197 /* On Everest 1 Ax chip versions for speeds less than
3198 10G LED scheme is different */
3199 REG_WR(bp
, NIG_REG_LED_CONTROL_OVERRIDE_TRAFFIC_P0
3201 REG_WR(bp
, NIG_REG_LED_CONTROL_TRAFFIC_P0
+
3203 REG_WR(bp
, NIG_REG_LED_CONTROL_BLINK_TRAFFIC_P0
+
3210 DP(NETIF_MSG_LINK
, "bnx2x_set_led: Invalid led mode %d\n",
3219 * This function comes to reflect the actual link state read DIRECTLY from the
3222 u8
bnx2x_test_link(struct link_params
*params
, struct link_vars
*vars
,
3225 struct bnx2x
*bp
= params
->bp
;
3226 u16 gp_status
= 0, phy_index
= 0;
3227 u8 ext_phy_link_up
= 0, serdes_phy_type
;
3228 struct link_vars temp_vars
;
3230 CL45_RD_OVER_CL22(bp
, ¶ms
->phy
[INT_PHY
],
3231 MDIO_REG_BANK_GP_STATUS
,
3232 MDIO_GP_STATUS_TOP_AN_STATUS1
,
3234 /* link is up only if both local phy and external phy are up */
3235 if (!(gp_status
& MDIO_GP_STATUS_TOP_AN_STATUS1_LINK_STATUS
))
3238 switch (params
->num_phys
) {
3240 /* No external PHY */
3243 ext_phy_link_up
= params
->phy
[EXT_PHY1
].read_status(
3244 ¶ms
->phy
[EXT_PHY1
],
3245 params
, &temp_vars
);
3247 case 3: /* Dual Media */
3248 for (phy_index
= EXT_PHY1
; phy_index
< params
->num_phys
;
3250 serdes_phy_type
= ((params
->phy
[phy_index
].media_type
==
3251 ETH_PHY_SFP_FIBER
) ||
3252 (params
->phy
[phy_index
].media_type
==
3253 ETH_PHY_XFP_FIBER
));
3255 if (is_serdes
!= serdes_phy_type
)
3257 if (params
->phy
[phy_index
].read_status
) {
3259 params
->phy
[phy_index
].read_status(
3260 ¶ms
->phy
[phy_index
],
3261 params
, &temp_vars
);
3266 if (ext_phy_link_up
)
3271 static u8
bnx2x_link_initialize(struct link_params
*params
,
3272 struct link_vars
*vars
)
3275 u8 phy_index
, non_ext_phy
;
3276 struct bnx2x
*bp
= params
->bp
;
3278 * In case of external phy existence, the line speed would be the
3279 * line speed linked up by the external phy. In case it is direct
3280 * only, then the line_speed during initialization will be
3281 * equal to the req_line_speed
3283 vars
->line_speed
= params
->phy
[INT_PHY
].req_line_speed
;
3286 * Initialize the internal phy in case this is a direct board
3287 * (no external phys), or this board has external phy which requires
3291 if (params
->phy
[INT_PHY
].config_init
)
3292 params
->phy
[INT_PHY
].config_init(
3293 ¶ms
->phy
[INT_PHY
],
3296 /* init ext phy and enable link state int */
3297 non_ext_phy
= (SINGLE_MEDIA_DIRECT(params
) ||
3298 (params
->loopback_mode
== LOOPBACK_XGXS
));
3301 (params
->phy
[EXT_PHY1
].flags
& FLAGS_INIT_XGXS_FIRST
) ||
3302 (params
->loopback_mode
== LOOPBACK_EXT_PHY
)) {
3303 struct bnx2x_phy
*phy
= ¶ms
->phy
[INT_PHY
];
3304 if (vars
->line_speed
== SPEED_AUTO_NEG
)
3305 bnx2x_set_parallel_detection(phy
, params
);
3306 bnx2x_init_internal_phy(phy
, params
, vars
);
3309 /* Init external phy*/
3311 for (phy_index
= EXT_PHY1
; phy_index
< params
->num_phys
;
3314 * No need to initialize second phy in case of first
3315 * phy only selection. In case of second phy, we do
3316 * need to initialize the first phy, since they are
3319 if (phy_index
== EXT_PHY2
&&
3320 (bnx2x_phy_selection(params
) ==
3321 PORT_HW_CFG_PHY_SELECTION_FIRST_PHY
)) {
3322 DP(NETIF_MSG_LINK
, "Not initializing"
3326 params
->phy
[phy_index
].config_init(
3327 ¶ms
->phy
[phy_index
],
3331 /* Reset the interrupt indication after phy was initialized */
3332 bnx2x_bits_dis(bp
, NIG_REG_STATUS_INTERRUPT_PORT0
+
3334 (NIG_STATUS_XGXS0_LINK10G
|
3335 NIG_STATUS_XGXS0_LINK_STATUS
|
3336 NIG_STATUS_SERDES0_LINK_STATUS
|
3341 static void bnx2x_int_link_reset(struct bnx2x_phy
*phy
,
3342 struct link_params
*params
)
3344 /* reset the SerDes/XGXS */
3345 REG_WR(params
->bp
, GRCBASE_MISC
+
3346 MISC_REGISTERS_RESET_REG_3_CLEAR
,
3347 (0x1ff << (params
->port
*16)));
3350 static void bnx2x_common_ext_link_reset(struct bnx2x_phy
*phy
,
3351 struct link_params
*params
)
3353 struct bnx2x
*bp
= params
->bp
;
3357 gpio_port
= BP_PATH(bp
);
3359 gpio_port
= params
->port
;
3360 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_1
,
3361 MISC_REGISTERS_GPIO_OUTPUT_LOW
,
3363 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_2
,
3364 MISC_REGISTERS_GPIO_OUTPUT_LOW
,
3366 DP(NETIF_MSG_LINK
, "reset external PHY\n");
3369 static u8
bnx2x_update_link_down(struct link_params
*params
,
3370 struct link_vars
*vars
)
3372 struct bnx2x
*bp
= params
->bp
;
3373 u8 port
= params
->port
;
3375 DP(NETIF_MSG_LINK
, "Port %x: Link is down\n", port
);
3376 bnx2x_set_led(params
, vars
, LED_MODE_OFF
, 0);
3378 /* indicate no mac active */
3379 vars
->mac_type
= MAC_TYPE_NONE
;
3381 /* update shared memory */
3382 vars
->link_status
= 0;
3383 vars
->line_speed
= 0;
3384 bnx2x_update_mng(params
, vars
->link_status
);
3386 /* activate nig drain */
3387 REG_WR(bp
, NIG_REG_EGRESS_DRAIN0_MODE
+ port
*4, 1);
3390 REG_WR(bp
, NIG_REG_NIG_EMAC0_EN
+ port
*4, 0);
3395 bnx2x_bmac_rx_disable(bp
, params
->port
);
3396 REG_WR(bp
, GRCBASE_MISC
+
3397 MISC_REGISTERS_RESET_REG_2_CLEAR
,
3398 (MISC_REGISTERS_RESET_REG_2_RST_BMAC0
<< port
));
3402 static u8
bnx2x_update_link_up(struct link_params
*params
,
3403 struct link_vars
*vars
,
3406 struct bnx2x
*bp
= params
->bp
;
3407 u8 port
= params
->port
;
3410 vars
->link_status
|= LINK_STATUS_LINK_UP
;
3412 if (vars
->flow_ctrl
& BNX2X_FLOW_CTRL_TX
)
3413 vars
->link_status
|=
3414 LINK_STATUS_TX_FLOW_CONTROL_ENABLED
;
3416 if (vars
->flow_ctrl
& BNX2X_FLOW_CTRL_RX
)
3417 vars
->link_status
|=
3418 LINK_STATUS_RX_FLOW_CONTROL_ENABLED
;
3421 bnx2x_bmac_enable(params
, vars
, 0);
3422 bnx2x_set_led(params
, vars
,
3423 LED_MODE_OPER
, SPEED_10000
);
3425 rc
= bnx2x_emac_program(params
, vars
);
3427 bnx2x_emac_enable(params
, vars
, 0);
3430 if ((vars
->link_status
& LINK_STATUS_AUTO_NEGOTIATE_COMPLETE
)
3431 && (!(vars
->phy_flags
& PHY_SGMII_FLAG
)) &&
3432 SINGLE_MEDIA_DIRECT(params
))
3433 bnx2x_set_gmii_tx_driver(params
);
3437 if (!(CHIP_IS_E2(bp
)))
3438 rc
|= bnx2x_pbf_update(params
, vars
->flow_ctrl
,
3442 REG_WR(bp
, NIG_REG_EGRESS_DRAIN0_MODE
+ port
*4, 0);
3444 /* update shared memory */
3445 bnx2x_update_mng(params
, vars
->link_status
);
3450 * The bnx2x_link_update function should be called upon link
3452 * Link is considered up as follows:
3453 * - DIRECT_SINGLE_MEDIA - Only XGXS link (internal link) needs
3455 * - SINGLE_MEDIA - The link between the 577xx and the external
3456 * phy (XGXS) need to up as well as the external link of the
3458 * - DUAL_MEDIA - The link between the 577xx and the first
3459 * external phy needs to be up, and at least one of the 2
3460 * external phy link must be up.
3462 u8
bnx2x_link_update(struct link_params
*params
, struct link_vars
*vars
)
3464 struct bnx2x
*bp
= params
->bp
;
3465 struct link_vars phy_vars
[MAX_PHYS
];
3466 u8 port
= params
->port
;
3467 u8 link_10g
, phy_index
;
3468 u8 ext_phy_link_up
= 0, cur_link_up
, rc
= 0;
3470 u16 ext_phy_line_speed
= 0, prev_line_speed
= vars
->line_speed
;
3471 u8 active_external_phy
= INT_PHY
;
3472 vars
->link_status
= 0;
3473 for (phy_index
= INT_PHY
; phy_index
< params
->num_phys
;
3475 phy_vars
[phy_index
].flow_ctrl
= 0;
3476 phy_vars
[phy_index
].link_status
= 0;
3477 phy_vars
[phy_index
].line_speed
= 0;
3478 phy_vars
[phy_index
].duplex
= DUPLEX_FULL
;
3479 phy_vars
[phy_index
].phy_link_up
= 0;
3480 phy_vars
[phy_index
].link_up
= 0;
3483 DP(NETIF_MSG_LINK
, "port %x, XGXS?%x, int_status 0x%x\n",
3484 port
, (vars
->phy_flags
& PHY_XGXS_FLAG
),
3485 REG_RD(bp
, NIG_REG_STATUS_INTERRUPT_PORT0
+ port
*4));
3487 is_mi_int
= (u8
)(REG_RD(bp
, NIG_REG_EMAC0_STATUS_MISC_MI_INT
+
3489 DP(NETIF_MSG_LINK
, "int_mask 0x%x MI_INT %x, SERDES_LINK %x\n",
3490 REG_RD(bp
, NIG_REG_MASK_INTERRUPT_PORT0
+ port
*4),
3493 NIG_REG_SERDES0_STATUS_LINK_STATUS
+ port
*0x3c));
3495 DP(NETIF_MSG_LINK
, " 10G %x, XGXS_LINK %x\n",
3496 REG_RD(bp
, NIG_REG_XGXS0_STATUS_LINK10G
+ port
*0x68),
3497 REG_RD(bp
, NIG_REG_XGXS0_STATUS_LINK_STATUS
+ port
*0x68));
3500 REG_WR(bp
, NIG_REG_NIG_EMAC0_EN
+ port
*4, 0);
3504 * Check external link change only for external phys, and apply
3505 * priority selection between them in case the link on both phys
3506 * is up. Note that the instead of the common vars, a temporary
3507 * vars argument is used since each phy may have different link/
3508 * speed/duplex result
3510 for (phy_index
= EXT_PHY1
; phy_index
< params
->num_phys
;
3512 struct bnx2x_phy
*phy
= ¶ms
->phy
[phy_index
];
3513 if (!phy
->read_status
)
3515 /* Read link status and params of this ext phy */
3516 cur_link_up
= phy
->read_status(phy
, params
,
3517 &phy_vars
[phy_index
]);
3519 DP(NETIF_MSG_LINK
, "phy in index %d link is up\n",
3522 DP(NETIF_MSG_LINK
, "phy in index %d link is down\n",
3527 if (!ext_phy_link_up
) {
3528 ext_phy_link_up
= 1;
3529 active_external_phy
= phy_index
;
3531 switch (bnx2x_phy_selection(params
)) {
3532 case PORT_HW_CFG_PHY_SELECTION_HARDWARE_DEFAULT
:
3533 case PORT_HW_CFG_PHY_SELECTION_FIRST_PHY_PRIORITY
:
3535 * In this option, the first PHY makes sure to pass the
3536 * traffic through itself only.
3537 * Its not clear how to reset the link on the second phy
3539 active_external_phy
= EXT_PHY1
;
3541 case PORT_HW_CFG_PHY_SELECTION_SECOND_PHY_PRIORITY
:
3543 * In this option, the first PHY makes sure to pass the
3544 * traffic through the second PHY.
3546 active_external_phy
= EXT_PHY2
;
3550 * Link indication on both PHYs with the following cases
3552 * - FIRST_PHY means that second phy wasn't initialized,
3553 * hence its link is expected to be down
3554 * - SECOND_PHY means that first phy should not be able
3555 * to link up by itself (using configuration)
3556 * - DEFAULT should be overriden during initialiazation
3558 DP(NETIF_MSG_LINK
, "Invalid link indication"
3559 "mpc=0x%x. DISABLING LINK !!!\n",
3560 params
->multi_phy_config
);
3561 ext_phy_link_up
= 0;
3566 prev_line_speed
= vars
->line_speed
;
3569 * Read the status of the internal phy. In case of
3570 * DIRECT_SINGLE_MEDIA board, this link is the external link,
3571 * otherwise this is the link between the 577xx and the first
3574 if (params
->phy
[INT_PHY
].read_status
)
3575 params
->phy
[INT_PHY
].read_status(
3576 ¶ms
->phy
[INT_PHY
],
3579 * The INT_PHY flow control reside in the vars. This include the
3580 * case where the speed or flow control are not set to AUTO.
3581 * Otherwise, the active external phy flow control result is set
3582 * to the vars. The ext_phy_line_speed is needed to check if the
3583 * speed is different between the internal phy and external phy.
3584 * This case may be result of intermediate link speed change.
3586 if (active_external_phy
> INT_PHY
) {
3587 vars
->flow_ctrl
= phy_vars
[active_external_phy
].flow_ctrl
;
3589 * Link speed is taken from the XGXS. AN and FC result from
3592 vars
->link_status
|= phy_vars
[active_external_phy
].link_status
;
3595 * if active_external_phy is first PHY and link is up - disable
3596 * disable TX on second external PHY
3598 if (active_external_phy
== EXT_PHY1
) {
3599 if (params
->phy
[EXT_PHY2
].phy_specific_func
) {
3600 DP(NETIF_MSG_LINK
, "Disabling TX on"
3602 params
->phy
[EXT_PHY2
].phy_specific_func(
3603 ¶ms
->phy
[EXT_PHY2
],
3604 params
, DISABLE_TX
);
3608 ext_phy_line_speed
= phy_vars
[active_external_phy
].line_speed
;
3609 vars
->duplex
= phy_vars
[active_external_phy
].duplex
;
3610 if (params
->phy
[active_external_phy
].supported
&
3612 vars
->link_status
|= LINK_STATUS_SERDES_LINK
;
3613 DP(NETIF_MSG_LINK
, "Active external phy selected: %x\n",
3614 active_external_phy
);
3617 for (phy_index
= EXT_PHY1
; phy_index
< params
->num_phys
;
3619 if (params
->phy
[phy_index
].flags
&
3620 FLAGS_REARM_LATCH_SIGNAL
) {
3621 bnx2x_rearm_latch_signal(bp
, port
,
3623 active_external_phy
);
3627 DP(NETIF_MSG_LINK
, "vars->flow_ctrl = 0x%x, vars->link_status = 0x%x,"
3628 " ext_phy_line_speed = %d\n", vars
->flow_ctrl
,
3629 vars
->link_status
, ext_phy_line_speed
);
3631 * Upon link speed change set the NIG into drain mode. Comes to
3632 * deals with possible FIFO glitch due to clk change when speed
3633 * is decreased without link down indicator
3636 if (vars
->phy_link_up
) {
3637 if (!(SINGLE_MEDIA_DIRECT(params
)) && ext_phy_link_up
&&
3638 (ext_phy_line_speed
!= vars
->line_speed
)) {
3639 DP(NETIF_MSG_LINK
, "Internal link speed %d is"
3640 " different than the external"
3641 " link speed %d\n", vars
->line_speed
,
3642 ext_phy_line_speed
);
3643 vars
->phy_link_up
= 0;
3644 } else if (prev_line_speed
!= vars
->line_speed
) {
3645 REG_WR(bp
, NIG_REG_EGRESS_DRAIN0_MODE
3646 + params
->port
*4, 0);
3651 /* anything 10 and over uses the bmac */
3652 link_10g
= ((vars
->line_speed
== SPEED_10000
) ||
3653 (vars
->line_speed
== SPEED_12000
) ||
3654 (vars
->line_speed
== SPEED_12500
) ||
3655 (vars
->line_speed
== SPEED_13000
) ||
3656 (vars
->line_speed
== SPEED_15000
) ||
3657 (vars
->line_speed
== SPEED_16000
));
3659 bnx2x_link_int_ack(params
, vars
, link_10g
);
3662 * In case external phy link is up, and internal link is down
3663 * (not initialized yet probably after link initialization, it
3664 * needs to be initialized.
3665 * Note that after link down-up as result of cable plug, the xgxs
3666 * link would probably become up again without the need
3669 if (!(SINGLE_MEDIA_DIRECT(params
))) {
3670 DP(NETIF_MSG_LINK
, "ext_phy_link_up = %d, int_link_up = %d,"
3671 " init_preceding = %d\n", ext_phy_link_up
,
3673 params
->phy
[EXT_PHY1
].flags
&
3674 FLAGS_INIT_XGXS_FIRST
);
3675 if (!(params
->phy
[EXT_PHY1
].flags
&
3676 FLAGS_INIT_XGXS_FIRST
)
3677 && ext_phy_link_up
&& !vars
->phy_link_up
) {
3678 vars
->line_speed
= ext_phy_line_speed
;
3679 if (vars
->line_speed
< SPEED_1000
)
3680 vars
->phy_flags
|= PHY_SGMII_FLAG
;
3682 vars
->phy_flags
&= ~PHY_SGMII_FLAG
;
3683 bnx2x_init_internal_phy(¶ms
->phy
[INT_PHY
],
3689 * Link is up only if both local phy and external phy (in case of
3690 * non-direct board) are up
3692 vars
->link_up
= (vars
->phy_link_up
&&
3694 SINGLE_MEDIA_DIRECT(params
)));
3697 rc
= bnx2x_update_link_up(params
, vars
, link_10g
);
3699 rc
= bnx2x_update_link_down(params
, vars
);
3705 /*****************************************************************************/
3706 /* External Phy section */
3707 /*****************************************************************************/
3708 void bnx2x_ext_phy_hw_reset(struct bnx2x
*bp
, u8 port
)
3710 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_1
,
3711 MISC_REGISTERS_GPIO_OUTPUT_LOW
, port
);
3713 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_1
,
3714 MISC_REGISTERS_GPIO_OUTPUT_HIGH
, port
);
3717 static void bnx2x_save_spirom_version(struct bnx2x
*bp
, u8 port
,
3718 u32 spirom_ver
, u32 ver_addr
)
3720 DP(NETIF_MSG_LINK
, "FW version 0x%x:0x%x for port %d\n",
3721 (u16
)(spirom_ver
>>16), (u16
)spirom_ver
, port
);
3724 REG_WR(bp
, ver_addr
, spirom_ver
);
3727 static void bnx2x_save_bcm_spirom_ver(struct bnx2x
*bp
,
3728 struct bnx2x_phy
*phy
,
3731 u16 fw_ver1
, fw_ver2
;
3733 bnx2x_cl45_read(bp
, phy
, MDIO_PMA_DEVAD
,
3734 MDIO_PMA_REG_ROM_VER1
, &fw_ver1
);
3735 bnx2x_cl45_read(bp
, phy
, MDIO_PMA_DEVAD
,
3736 MDIO_PMA_REG_ROM_VER2
, &fw_ver2
);
3737 bnx2x_save_spirom_version(bp
, port
, (u32
)(fw_ver1
<<16 | fw_ver2
),
3741 static void bnx2x_ext_phy_set_pause(struct link_params
*params
,
3742 struct bnx2x_phy
*phy
,
3743 struct link_vars
*vars
)
3746 struct bnx2x
*bp
= params
->bp
;
3747 /* read modify write pause advertizing */
3748 bnx2x_cl45_read(bp
, phy
, MDIO_AN_DEVAD
, MDIO_AN_REG_ADV_PAUSE
, &val
);
3750 val
&= ~MDIO_AN_REG_ADV_PAUSE_BOTH
;
3752 /* Please refer to Table 28B-3 of 802.3ab-1999 spec. */
3753 bnx2x_calc_ieee_aneg_adv(phy
, params
, &vars
->ieee_fc
);
3754 if ((vars
->ieee_fc
&
3755 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC
) ==
3756 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC
) {
3757 val
|= MDIO_AN_REG_ADV_PAUSE_ASYMMETRIC
;
3759 if ((vars
->ieee_fc
&
3760 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH
) ==
3761 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH
) {
3762 val
|= MDIO_AN_REG_ADV_PAUSE_PAUSE
;
3764 DP(NETIF_MSG_LINK
, "Ext phy AN advertize 0x%x\n", val
);
3765 bnx2x_cl45_write(bp
, phy
, MDIO_AN_DEVAD
, MDIO_AN_REG_ADV_PAUSE
, val
);
3768 static u8
bnx2x_ext_phy_resolve_fc(struct bnx2x_phy
*phy
,
3769 struct link_params
*params
,
3770 struct link_vars
*vars
)
3772 struct bnx2x
*bp
= params
->bp
;
3773 u16 ld_pause
; /* local */
3774 u16 lp_pause
; /* link partner */
3779 vars
->flow_ctrl
= BNX2X_FLOW_CTRL_NONE
;
3781 if (phy
->req_flow_ctrl
!= BNX2X_FLOW_CTRL_AUTO
)
3782 vars
->flow_ctrl
= phy
->req_flow_ctrl
;
3783 else if (phy
->req_line_speed
!= SPEED_AUTO_NEG
)
3784 vars
->flow_ctrl
= params
->req_fc_auto_adv
;
3785 else if (vars
->link_status
& LINK_STATUS_AUTO_NEGOTIATE_COMPLETE
) {
3787 bnx2x_cl45_read(bp
, phy
,
3789 MDIO_AN_REG_ADV_PAUSE
, &ld_pause
);
3790 bnx2x_cl45_read(bp
, phy
,
3792 MDIO_AN_REG_LP_AUTO_NEG
, &lp_pause
);
3793 pause_result
= (ld_pause
&
3794 MDIO_AN_REG_ADV_PAUSE_MASK
) >> 8;
3795 pause_result
|= (lp_pause
&
3796 MDIO_AN_REG_ADV_PAUSE_MASK
) >> 10;
3797 DP(NETIF_MSG_LINK
, "Ext PHY pause result 0x%x\n",
3799 bnx2x_pause_resolve(vars
, pause_result
);
3804 static void bnx2x_ext_phy_10G_an_resolve(struct bnx2x
*bp
,
3805 struct bnx2x_phy
*phy
,
3806 struct link_vars
*vars
)
3809 bnx2x_cl45_read(bp
, phy
,
3811 MDIO_AN_REG_STATUS
, &val
);
3812 bnx2x_cl45_read(bp
, phy
,
3814 MDIO_AN_REG_STATUS
, &val
);
3816 vars
->link_status
|= LINK_STATUS_AUTO_NEGOTIATE_COMPLETE
;
3817 if ((val
& (1<<0)) == 0)
3818 vars
->link_status
|= LINK_STATUS_PARALLEL_DETECTION_USED
;
3821 /******************************************************************/
3822 /* common BCM8073/BCM8727 PHY SECTION */
3823 /******************************************************************/
3824 static void bnx2x_8073_resolve_fc(struct bnx2x_phy
*phy
,
3825 struct link_params
*params
,
3826 struct link_vars
*vars
)
3828 struct bnx2x
*bp
= params
->bp
;
3829 if (phy
->req_line_speed
== SPEED_10
||
3830 phy
->req_line_speed
== SPEED_100
) {
3831 vars
->flow_ctrl
= phy
->req_flow_ctrl
;
3835 if (bnx2x_ext_phy_resolve_fc(phy
, params
, vars
) &&
3836 (vars
->flow_ctrl
== BNX2X_FLOW_CTRL_NONE
)) {
3838 u16 ld_pause
; /* local */
3839 u16 lp_pause
; /* link partner */
3840 bnx2x_cl45_read(bp
, phy
,
3842 MDIO_AN_REG_CL37_FC_LD
, &ld_pause
);
3844 bnx2x_cl45_read(bp
, phy
,
3846 MDIO_AN_REG_CL37_FC_LP
, &lp_pause
);
3847 pause_result
= (ld_pause
&
3848 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH
) >> 5;
3849 pause_result
|= (lp_pause
&
3850 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH
) >> 7;
3852 bnx2x_pause_resolve(vars
, pause_result
);
3853 DP(NETIF_MSG_LINK
, "Ext PHY CL37 pause result 0x%x\n",
3858 static void bnx2x_8073_8727_external_rom_boot(struct bnx2x
*bp
,
3859 struct bnx2x_phy
*phy
,
3862 /* Boot port from external ROM */
3864 bnx2x_cl45_write(bp
, phy
,
3866 MDIO_PMA_REG_GEN_CTRL
,
3869 /* ucode reboot and rst */
3870 bnx2x_cl45_write(bp
, phy
,
3872 MDIO_PMA_REG_GEN_CTRL
,
3875 bnx2x_cl45_write(bp
, phy
,
3877 MDIO_PMA_REG_MISC_CTRL1
, 0x0001);
3879 /* Reset internal microprocessor */
3880 bnx2x_cl45_write(bp
, phy
,
3882 MDIO_PMA_REG_GEN_CTRL
,
3883 MDIO_PMA_REG_GEN_CTRL_ROM_MICRO_RESET
);
3885 /* Release srst bit */
3886 bnx2x_cl45_write(bp
, phy
,
3888 MDIO_PMA_REG_GEN_CTRL
,
3889 MDIO_PMA_REG_GEN_CTRL_ROM_RESET_INTERNAL_MP
);
3891 /* wait for 120ms for code download via SPI port */
3894 /* Clear ser_boot_ctl bit */
3895 bnx2x_cl45_write(bp
, phy
,
3897 MDIO_PMA_REG_MISC_CTRL1
, 0x0000);
3898 bnx2x_save_bcm_spirom_ver(bp
, phy
, port
);
3901 static void bnx2x_8073_set_xaui_low_power_mode(struct bnx2x
*bp
,
3902 struct bnx2x_phy
*phy
)
3905 bnx2x_cl45_read(bp
, phy
,
3906 MDIO_PMA_DEVAD
, MDIO_PMA_REG_8073_CHIP_REV
, &val
);
3909 /* Mustn't set low power mode in 8073 A0 */
3913 /* Disable PLL sequencer (use read-modify-write to clear bit 13) */
3914 bnx2x_cl45_read(bp
, phy
,
3915 MDIO_XS_DEVAD
, MDIO_XS_PLL_SEQUENCER
, &val
);
3917 bnx2x_cl45_write(bp
, phy
,
3918 MDIO_XS_DEVAD
, MDIO_XS_PLL_SEQUENCER
, val
);
3921 bnx2x_cl45_write(bp
, phy
, MDIO_XS_DEVAD
, 0x805E, 0x1077);
3922 bnx2x_cl45_write(bp
, phy
, MDIO_XS_DEVAD
, 0x805D, 0x0000);
3923 bnx2x_cl45_write(bp
, phy
, MDIO_XS_DEVAD
, 0x805C, 0x030B);
3924 bnx2x_cl45_write(bp
, phy
, MDIO_XS_DEVAD
, 0x805B, 0x1240);
3925 bnx2x_cl45_write(bp
, phy
, MDIO_XS_DEVAD
, 0x805A, 0x2490);
3928 bnx2x_cl45_write(bp
, phy
, MDIO_XS_DEVAD
, 0x80A7, 0x0C74);
3929 bnx2x_cl45_write(bp
, phy
, MDIO_XS_DEVAD
, 0x80A6, 0x9041);
3930 bnx2x_cl45_write(bp
, phy
, MDIO_XS_DEVAD
, 0x80A5, 0x4640);
3933 bnx2x_cl45_write(bp
, phy
, MDIO_XS_DEVAD
, 0x80FE, 0x01C4);
3934 bnx2x_cl45_write(bp
, phy
, MDIO_XS_DEVAD
, 0x80FD, 0x9249);
3935 bnx2x_cl45_write(bp
, phy
, MDIO_XS_DEVAD
, 0x80FC, 0x2015);
3937 /* Enable PLL sequencer (use read-modify-write to set bit 13) */
3938 bnx2x_cl45_read(bp
, phy
, MDIO_XS_DEVAD
, MDIO_XS_PLL_SEQUENCER
, &val
);
3940 bnx2x_cl45_write(bp
, phy
, MDIO_XS_DEVAD
, MDIO_XS_PLL_SEQUENCER
, val
);
3943 /******************************************************************/
3944 /* BCM8073 PHY SECTION */
3945 /******************************************************************/
3946 static u8
bnx2x_8073_is_snr_needed(struct bnx2x
*bp
, struct bnx2x_phy
*phy
)
3948 /* This is only required for 8073A1, version 102 only */
3951 /* Read 8073 HW revision*/
3952 bnx2x_cl45_read(bp
, phy
,
3954 MDIO_PMA_REG_8073_CHIP_REV
, &val
);
3957 /* No need to workaround in 8073 A1 */
3961 bnx2x_cl45_read(bp
, phy
,
3963 MDIO_PMA_REG_ROM_VER2
, &val
);
3965 /* SNR should be applied only for version 0x102 */
3972 static u8
bnx2x_8073_xaui_wa(struct bnx2x
*bp
, struct bnx2x_phy
*phy
)
3974 u16 val
, cnt
, cnt1
;
3976 bnx2x_cl45_read(bp
, phy
,
3978 MDIO_PMA_REG_8073_CHIP_REV
, &val
);
3981 /* No need to workaround in 8073 A1 */
3984 /* XAUI workaround in 8073 A0: */
3986 /* After loading the boot ROM and restarting Autoneg,
3987 poll Dev1, Reg $C820: */
3989 for (cnt
= 0; cnt
< 1000; cnt
++) {
3990 bnx2x_cl45_read(bp
, phy
,
3992 MDIO_PMA_REG_8073_SPEED_LINK_STATUS
,
3994 /* If bit [14] = 0 or bit [13] = 0, continue on with
3995 system initialization (XAUI work-around not required,
3996 as these bits indicate 2.5G or 1G link up). */
3997 if (!(val
& (1<<14)) || !(val
& (1<<13))) {
3998 DP(NETIF_MSG_LINK
, "XAUI work-around not required\n");
4000 } else if (!(val
& (1<<15))) {
4001 DP(NETIF_MSG_LINK
, "clc bit 15 went off\n");
4002 /* If bit 15 is 0, then poll Dev1, Reg $C841 until
4003 it's MSB (bit 15) goes to 1 (indicating that the
4004 XAUI workaround has completed),
4005 then continue on with system initialization.*/
4006 for (cnt1
= 0; cnt1
< 1000; cnt1
++) {
4007 bnx2x_cl45_read(bp
, phy
,
4009 MDIO_PMA_REG_8073_XAUI_WA
, &val
);
4010 if (val
& (1<<15)) {
4012 "XAUI workaround has completed\n");
4021 DP(NETIF_MSG_LINK
, "Warning: XAUI work-around timeout !!!\n");
4025 static void bnx2x_807x_force_10G(struct bnx2x
*bp
, struct bnx2x_phy
*phy
)
4027 /* Force KR or KX */
4028 bnx2x_cl45_write(bp
, phy
,
4029 MDIO_PMA_DEVAD
, MDIO_PMA_REG_CTRL
, 0x2040);
4030 bnx2x_cl45_write(bp
, phy
,
4031 MDIO_PMA_DEVAD
, MDIO_PMA_REG_10G_CTRL2
, 0x000b);
4032 bnx2x_cl45_write(bp
, phy
,
4033 MDIO_PMA_DEVAD
, MDIO_PMA_REG_BCM_CTRL
, 0x0000);
4034 bnx2x_cl45_write(bp
, phy
,
4035 MDIO_AN_DEVAD
, MDIO_AN_REG_CTRL
, 0x0000);
4038 static void bnx2x_8073_set_pause_cl37(struct link_params
*params
,
4039 struct bnx2x_phy
*phy
,
4040 struct link_vars
*vars
)
4043 struct bnx2x
*bp
= params
->bp
;
4044 bnx2x_cl45_read(bp
, phy
,
4045 MDIO_AN_DEVAD
, MDIO_AN_REG_CL37_FC_LD
, &cl37_val
);
4047 cl37_val
&= ~MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH
;
4048 /* Please refer to Table 28B-3 of 802.3ab-1999 spec. */
4049 bnx2x_calc_ieee_aneg_adv(phy
, params
, &vars
->ieee_fc
);
4050 if ((vars
->ieee_fc
&
4051 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_SYMMETRIC
) ==
4052 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_SYMMETRIC
) {
4053 cl37_val
|= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_SYMMETRIC
;
4055 if ((vars
->ieee_fc
&
4056 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC
) ==
4057 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC
) {
4058 cl37_val
|= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC
;
4060 if ((vars
->ieee_fc
&
4061 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH
) ==
4062 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH
) {
4063 cl37_val
|= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH
;
4066 "Ext phy AN advertize cl37 0x%x\n", cl37_val
);
4068 bnx2x_cl45_write(bp
, phy
,
4069 MDIO_AN_DEVAD
, MDIO_AN_REG_CL37_FC_LD
, cl37_val
);
4073 static u8
bnx2x_8073_config_init(struct bnx2x_phy
*phy
,
4074 struct link_params
*params
,
4075 struct link_vars
*vars
)
4077 struct bnx2x
*bp
= params
->bp
;
4080 DP(NETIF_MSG_LINK
, "Init 8073\n");
4083 gpio_port
= BP_PATH(bp
);
4085 gpio_port
= params
->port
;
4086 /* Restore normal power mode*/
4087 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_2
,
4088 MISC_REGISTERS_GPIO_OUTPUT_HIGH
, gpio_port
);
4090 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_1
,
4091 MISC_REGISTERS_GPIO_OUTPUT_HIGH
, gpio_port
);
4094 bnx2x_cl45_write(bp
, phy
,
4095 MDIO_PMA_DEVAD
, MDIO_PMA_REG_RX_ALARM_CTRL
, (1<<2));
4096 bnx2x_cl45_write(bp
, phy
,
4097 MDIO_PMA_DEVAD
, MDIO_PMA_REG_LASI_CTRL
, 0x0004);
4099 bnx2x_8073_set_pause_cl37(params
, phy
, vars
);
4101 bnx2x_8073_set_xaui_low_power_mode(bp
, phy
);
4103 bnx2x_cl45_read(bp
, phy
,
4104 MDIO_PMA_DEVAD
, MDIO_PMA_REG_M8051_MSGOUT_REG
, &tmp1
);
4106 bnx2x_cl45_read(bp
, phy
,
4107 MDIO_PMA_DEVAD
, MDIO_PMA_REG_RX_ALARM
, &tmp1
);
4109 DP(NETIF_MSG_LINK
, "Before rom RX_ALARM(port1): 0x%x\n", tmp1
);
4111 /* Enable CL37 BAM */
4112 if (REG_RD(bp
, params
->shmem_base
+
4113 offsetof(struct shmem_region
, dev_info
.
4114 port_hw_config
[params
->port
].default_cfg
)) &
4115 PORT_HW_CFG_ENABLE_BAM_ON_KR_ENABLED
) {
4117 bnx2x_cl45_read(bp
, phy
,
4119 MDIO_AN_REG_8073_BAM
, &val
);
4120 bnx2x_cl45_write(bp
, phy
,
4122 MDIO_AN_REG_8073_BAM
, val
| 1);
4123 DP(NETIF_MSG_LINK
, "Enable CL37 BAM on KR\n");
4125 if (params
->loopback_mode
== LOOPBACK_EXT
) {
4126 bnx2x_807x_force_10G(bp
, phy
);
4127 DP(NETIF_MSG_LINK
, "Forced speed 10G on 807X\n");
4130 bnx2x_cl45_write(bp
, phy
,
4131 MDIO_PMA_DEVAD
, MDIO_PMA_REG_BCM_CTRL
, 0x0002);
4133 if (phy
->req_line_speed
!= SPEED_AUTO_NEG
) {
4134 if (phy
->req_line_speed
== SPEED_10000
) {
4136 } else if (phy
->req_line_speed
== SPEED_2500
) {
4138 /* Note that 2.5G works only
4139 when used with 1G advertisment */
4144 if (phy
->speed_cap_mask
&
4145 PORT_HW_CFG_SPEED_CAPABILITY_D0_10G
)
4148 /* Note that 2.5G works only when
4149 used with 1G advertisment */
4150 if (phy
->speed_cap_mask
&
4151 (PORT_HW_CFG_SPEED_CAPABILITY_D0_1G
|
4152 PORT_HW_CFG_SPEED_CAPABILITY_D0_2_5G
))
4154 DP(NETIF_MSG_LINK
, "807x autoneg val = 0x%x\n", val
);
4157 bnx2x_cl45_write(bp
, phy
, MDIO_AN_DEVAD
, MDIO_AN_REG_ADV
, val
);
4158 bnx2x_cl45_read(bp
, phy
, MDIO_AN_DEVAD
, MDIO_AN_REG_8073_2_5G
, &tmp1
);
4160 if (((phy
->speed_cap_mask
& PORT_HW_CFG_SPEED_CAPABILITY_D0_2_5G
) &&
4161 (phy
->req_line_speed
== SPEED_AUTO_NEG
)) ||
4162 (phy
->req_line_speed
== SPEED_2500
)) {
4164 /* Allow 2.5G for A1 and above */
4165 bnx2x_cl45_read(bp
, phy
,
4166 MDIO_PMA_DEVAD
, MDIO_PMA_REG_8073_CHIP_REV
,
4168 DP(NETIF_MSG_LINK
, "Add 2.5G\n");
4174 DP(NETIF_MSG_LINK
, "Disable 2.5G\n");
4178 bnx2x_cl45_write(bp
, phy
, MDIO_AN_DEVAD
, MDIO_AN_REG_8073_2_5G
, tmp1
);
4179 /* Add support for CL37 (passive mode) II */
4181 bnx2x_cl45_read(bp
, phy
, MDIO_AN_DEVAD
, MDIO_AN_REG_CL37_FC_LD
, &tmp1
);
4182 bnx2x_cl45_write(bp
, phy
, MDIO_AN_DEVAD
, MDIO_AN_REG_CL37_FC_LD
,
4183 (tmp1
| ((phy
->req_duplex
== DUPLEX_FULL
) ?
4186 /* Add support for CL37 (passive mode) III */
4187 bnx2x_cl45_write(bp
, phy
, MDIO_AN_DEVAD
, MDIO_AN_REG_CL37_AN
, 0x1000);
4189 /* The SNR will improve about 2db by changing
4190 BW and FEE main tap. Rest commands are executed
4192 if (bnx2x_8073_is_snr_needed(bp
, phy
))
4193 bnx2x_cl45_write(bp
, phy
,
4194 MDIO_PMA_DEVAD
, MDIO_PMA_REG_EDC_FFE_MAIN
,
4197 /* Enable FEC (Forware Error Correction) Request in the AN */
4198 bnx2x_cl45_read(bp
, phy
, MDIO_AN_DEVAD
, MDIO_AN_REG_ADV2
, &tmp1
);
4200 bnx2x_cl45_write(bp
, phy
, MDIO_AN_DEVAD
, MDIO_AN_REG_ADV2
, tmp1
);
4202 bnx2x_ext_phy_set_pause(params
, phy
, vars
);
4204 /* Restart autoneg */
4206 bnx2x_cl45_write(bp
, phy
, MDIO_AN_DEVAD
, MDIO_AN_REG_CTRL
, 0x1200);
4207 DP(NETIF_MSG_LINK
, "807x Autoneg Restart: Advertise 1G=%x, 10G=%x\n",
4208 ((val
& (1<<5)) > 0), ((val
& (1<<7)) > 0));
4212 static u8
bnx2x_8073_read_status(struct bnx2x_phy
*phy
,
4213 struct link_params
*params
,
4214 struct link_vars
*vars
)
4216 struct bnx2x
*bp
= params
->bp
;
4219 u16 link_status
= 0;
4220 u16 an1000_status
= 0;
4222 bnx2x_cl45_read(bp
, phy
,
4223 MDIO_PMA_DEVAD
, MDIO_PMA_REG_LASI_STATUS
, &val1
);
4225 DP(NETIF_MSG_LINK
, "8703 LASI status 0x%x\n", val1
);
4227 /* clear the interrupt LASI status register */
4228 bnx2x_cl45_read(bp
, phy
,
4229 MDIO_PCS_DEVAD
, MDIO_PCS_REG_STATUS
, &val2
);
4230 bnx2x_cl45_read(bp
, phy
,
4231 MDIO_PCS_DEVAD
, MDIO_PCS_REG_STATUS
, &val1
);
4232 DP(NETIF_MSG_LINK
, "807x PCS status 0x%x->0x%x\n", val2
, val1
);
4234 bnx2x_cl45_read(bp
, phy
,
4235 MDIO_PMA_DEVAD
, MDIO_PMA_REG_M8051_MSGOUT_REG
, &val1
);
4237 /* Check the LASI */
4238 bnx2x_cl45_read(bp
, phy
,
4239 MDIO_PMA_DEVAD
, MDIO_PMA_REG_RX_ALARM
, &val2
);
4241 DP(NETIF_MSG_LINK
, "KR 0x9003 0x%x\n", val2
);
4243 /* Check the link status */
4244 bnx2x_cl45_read(bp
, phy
,
4245 MDIO_PCS_DEVAD
, MDIO_PCS_REG_STATUS
, &val2
);
4246 DP(NETIF_MSG_LINK
, "KR PCS status 0x%x\n", val2
);
4248 bnx2x_cl45_read(bp
, phy
,
4249 MDIO_PMA_DEVAD
, MDIO_PMA_REG_STATUS
, &val2
);
4250 bnx2x_cl45_read(bp
, phy
,
4251 MDIO_PMA_DEVAD
, MDIO_PMA_REG_STATUS
, &val1
);
4252 link_up
= ((val1
& 4) == 4);
4253 DP(NETIF_MSG_LINK
, "PMA_REG_STATUS=0x%x\n", val1
);
4256 ((phy
->req_line_speed
!= SPEED_10000
))) {
4257 if (bnx2x_8073_xaui_wa(bp
, phy
) != 0)
4260 bnx2x_cl45_read(bp
, phy
,
4261 MDIO_AN_DEVAD
, MDIO_AN_REG_LINK_STATUS
, &an1000_status
);
4262 bnx2x_cl45_read(bp
, phy
,
4263 MDIO_AN_DEVAD
, MDIO_AN_REG_LINK_STATUS
, &an1000_status
);
4265 /* Check the link status on 1.1.2 */
4266 bnx2x_cl45_read(bp
, phy
,
4267 MDIO_PMA_DEVAD
, MDIO_PMA_REG_STATUS
, &val2
);
4268 bnx2x_cl45_read(bp
, phy
,
4269 MDIO_PMA_DEVAD
, MDIO_PMA_REG_STATUS
, &val1
);
4270 DP(NETIF_MSG_LINK
, "KR PMA status 0x%x->0x%x,"
4271 "an_link_status=0x%x\n", val2
, val1
, an1000_status
);
4273 link_up
= (((val1
& 4) == 4) || (an1000_status
& (1<<1)));
4274 if (link_up
&& bnx2x_8073_is_snr_needed(bp
, phy
)) {
4275 /* The SNR will improve about 2dbby
4276 changing the BW and FEE main tap.*/
4277 /* The 1st write to change FFE main
4278 tap is set before restart AN */
4279 /* Change PLL Bandwidth in EDC
4281 bnx2x_cl45_write(bp
, phy
,
4282 MDIO_PMA_DEVAD
, MDIO_PMA_REG_PLL_BANDWIDTH
,
4285 /* Change CDR Bandwidth in EDC register */
4286 bnx2x_cl45_write(bp
, phy
,
4287 MDIO_PMA_DEVAD
, MDIO_PMA_REG_CDR_BANDWIDTH
,
4290 bnx2x_cl45_read(bp
, phy
,
4291 MDIO_PMA_DEVAD
, MDIO_PMA_REG_8073_SPEED_LINK_STATUS
,
4294 /* Bits 0..2 --> speed detected, bits 13..15--> link is down */
4295 if ((link_status
& (1<<2)) && (!(link_status
& (1<<15)))) {
4297 vars
->line_speed
= SPEED_10000
;
4298 DP(NETIF_MSG_LINK
, "port %x: External link up in 10G\n",
4300 } else if ((link_status
& (1<<1)) && (!(link_status
& (1<<14)))) {
4302 vars
->line_speed
= SPEED_2500
;
4303 DP(NETIF_MSG_LINK
, "port %x: External link up in 2.5G\n",
4305 } else if ((link_status
& (1<<0)) && (!(link_status
& (1<<13)))) {
4307 vars
->line_speed
= SPEED_1000
;
4308 DP(NETIF_MSG_LINK
, "port %x: External link up in 1G\n",
4312 DP(NETIF_MSG_LINK
, "port %x: External link is down\n",
4317 bnx2x_ext_phy_10G_an_resolve(bp
, phy
, vars
);
4318 bnx2x_8073_resolve_fc(phy
, params
, vars
);
4323 static void bnx2x_8073_link_reset(struct bnx2x_phy
*phy
,
4324 struct link_params
*params
)
4326 struct bnx2x
*bp
= params
->bp
;
4329 gpio_port
= BP_PATH(bp
);
4331 gpio_port
= params
->port
;
4332 DP(NETIF_MSG_LINK
, "Setting 8073 port %d into low power mode\n",
4334 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_2
,
4335 MISC_REGISTERS_GPIO_OUTPUT_LOW
,
4339 /******************************************************************/
4340 /* BCM8705 PHY SECTION */
4341 /******************************************************************/
4342 static u8
bnx2x_8705_config_init(struct bnx2x_phy
*phy
,
4343 struct link_params
*params
,
4344 struct link_vars
*vars
)
4346 struct bnx2x
*bp
= params
->bp
;
4347 DP(NETIF_MSG_LINK
, "init 8705\n");
4348 /* Restore normal power mode*/
4349 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_2
,
4350 MISC_REGISTERS_GPIO_OUTPUT_HIGH
, params
->port
);
4352 bnx2x_ext_phy_hw_reset(bp
, params
->port
);
4353 bnx2x_cl45_write(bp
, phy
, MDIO_PMA_DEVAD
, MDIO_PMA_REG_CTRL
, 0xa040);
4354 bnx2x_wait_reset_complete(bp
, phy
);
4356 bnx2x_cl45_write(bp
, phy
,
4357 MDIO_PMA_DEVAD
, MDIO_PMA_REG_MISC_CTRL
, 0x8288);
4358 bnx2x_cl45_write(bp
, phy
,
4359 MDIO_PMA_DEVAD
, MDIO_PMA_REG_PHY_IDENTIFIER
, 0x7fbf);
4360 bnx2x_cl45_write(bp
, phy
,
4361 MDIO_PMA_DEVAD
, MDIO_PMA_REG_CMU_PLL_BYPASS
, 0x0100);
4362 bnx2x_cl45_write(bp
, phy
,
4363 MDIO_WIS_DEVAD
, MDIO_WIS_REG_LASI_CNTL
, 0x1);
4364 /* BCM8705 doesn't have microcode, hence the 0 */
4365 bnx2x_save_spirom_version(bp
, params
->port
, params
->shmem_base
, 0);
4369 static u8
bnx2x_8705_read_status(struct bnx2x_phy
*phy
,
4370 struct link_params
*params
,
4371 struct link_vars
*vars
)
4375 struct bnx2x
*bp
= params
->bp
;
4376 DP(NETIF_MSG_LINK
, "read status 8705\n");
4377 bnx2x_cl45_read(bp
, phy
,
4378 MDIO_WIS_DEVAD
, MDIO_WIS_REG_LASI_STATUS
, &val1
);
4379 DP(NETIF_MSG_LINK
, "8705 LASI status 0x%x\n", val1
);
4381 bnx2x_cl45_read(bp
, phy
,
4382 MDIO_WIS_DEVAD
, MDIO_WIS_REG_LASI_STATUS
, &val1
);
4383 DP(NETIF_MSG_LINK
, "8705 LASI status 0x%x\n", val1
);
4385 bnx2x_cl45_read(bp
, phy
,
4386 MDIO_PMA_DEVAD
, MDIO_PMA_REG_RX_SD
, &rx_sd
);
4388 bnx2x_cl45_read(bp
, phy
,
4389 MDIO_PMA_DEVAD
, 0xc809, &val1
);
4390 bnx2x_cl45_read(bp
, phy
,
4391 MDIO_PMA_DEVAD
, 0xc809, &val1
);
4393 DP(NETIF_MSG_LINK
, "8705 1.c809 val=0x%x\n", val1
);
4394 link_up
= ((rx_sd
& 0x1) && (val1
& (1<<9)) && ((val1
& (1<<8)) == 0));
4396 vars
->line_speed
= SPEED_10000
;
4397 bnx2x_ext_phy_resolve_fc(phy
, params
, vars
);
4402 /******************************************************************/
4403 /* SFP+ module Section */
4404 /******************************************************************/
4405 static void bnx2x_sfp_set_transmitter(struct bnx2x
*bp
,
4406 struct bnx2x_phy
*phy
,
4412 DP(NETIF_MSG_LINK
, "Setting transmitter tx_en=%x for port %x\n",
4414 /* Disable/Enable transmitter ( TX laser of the SFP+ module.)*/
4415 bnx2x_cl45_read(bp
, phy
,
4417 MDIO_PMA_REG_PHY_IDENTIFIER
,
4425 bnx2x_cl45_write(bp
, phy
,
4427 MDIO_PMA_REG_PHY_IDENTIFIER
,
4431 static u8
bnx2x_8726_read_sfp_module_eeprom(struct bnx2x_phy
*phy
,
4432 struct link_params
*params
,
4433 u16 addr
, u8 byte_cnt
, u8
*o_buf
)
4435 struct bnx2x
*bp
= params
->bp
;
4438 if (byte_cnt
> 16) {
4439 DP(NETIF_MSG_LINK
, "Reading from eeprom is"
4440 " is limited to 0xf\n");
4443 /* Set the read command byte count */
4444 bnx2x_cl45_write(bp
, phy
,
4445 MDIO_PMA_DEVAD
, MDIO_PMA_REG_SFP_TWO_WIRE_BYTE_CNT
,
4446 (byte_cnt
| 0xa000));
4448 /* Set the read command address */
4449 bnx2x_cl45_write(bp
, phy
,
4450 MDIO_PMA_DEVAD
, MDIO_PMA_REG_SFP_TWO_WIRE_MEM_ADDR
,
4453 /* Activate read command */
4454 bnx2x_cl45_write(bp
, phy
,
4455 MDIO_PMA_DEVAD
, MDIO_PMA_REG_SFP_TWO_WIRE_CTRL
,
4458 /* Wait up to 500us for command complete status */
4459 for (i
= 0; i
< 100; i
++) {
4460 bnx2x_cl45_read(bp
, phy
,
4462 MDIO_PMA_REG_SFP_TWO_WIRE_CTRL
, &val
);
4463 if ((val
& MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK
) ==
4464 MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_COMPLETE
)
4469 if ((val
& MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK
) !=
4470 MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_COMPLETE
) {
4472 "Got bad status 0x%x when reading from SFP+ EEPROM\n",
4473 (val
& MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK
));
4477 /* Read the buffer */
4478 for (i
= 0; i
< byte_cnt
; i
++) {
4479 bnx2x_cl45_read(bp
, phy
,
4481 MDIO_PMA_REG_8726_TWO_WIRE_DATA_BUF
+ i
, &val
);
4482 o_buf
[i
] = (u8
)(val
& MDIO_PMA_REG_8726_TWO_WIRE_DATA_MASK
);
4485 for (i
= 0; i
< 100; i
++) {
4486 bnx2x_cl45_read(bp
, phy
,
4488 MDIO_PMA_REG_SFP_TWO_WIRE_CTRL
, &val
);
4489 if ((val
& MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK
) ==
4490 MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_IDLE
)
4497 static u8
bnx2x_8727_read_sfp_module_eeprom(struct bnx2x_phy
*phy
,
4498 struct link_params
*params
,
4499 u16 addr
, u8 byte_cnt
, u8
*o_buf
)
4501 struct bnx2x
*bp
= params
->bp
;
4504 if (byte_cnt
> 16) {
4505 DP(NETIF_MSG_LINK
, "Reading from eeprom is"
4506 " is limited to 0xf\n");
4510 /* Need to read from 1.8000 to clear it */
4511 bnx2x_cl45_read(bp
, phy
,
4513 MDIO_PMA_REG_SFP_TWO_WIRE_CTRL
,
4516 /* Set the read command byte count */
4517 bnx2x_cl45_write(bp
, phy
,
4519 MDIO_PMA_REG_SFP_TWO_WIRE_BYTE_CNT
,
4520 ((byte_cnt
< 2) ? 2 : byte_cnt
));
4522 /* Set the read command address */
4523 bnx2x_cl45_write(bp
, phy
,
4525 MDIO_PMA_REG_SFP_TWO_WIRE_MEM_ADDR
,
4527 /* Set the destination address */
4528 bnx2x_cl45_write(bp
, phy
,
4531 MDIO_PMA_REG_8727_TWO_WIRE_DATA_BUF
);
4533 /* Activate read command */
4534 bnx2x_cl45_write(bp
, phy
,
4536 MDIO_PMA_REG_SFP_TWO_WIRE_CTRL
,
4538 /* Wait appropriate time for two-wire command to finish before
4539 polling the status register */
4542 /* Wait up to 500us for command complete status */
4543 for (i
= 0; i
< 100; i
++) {
4544 bnx2x_cl45_read(bp
, phy
,
4546 MDIO_PMA_REG_SFP_TWO_WIRE_CTRL
, &val
);
4547 if ((val
& MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK
) ==
4548 MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_COMPLETE
)
4553 if ((val
& MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK
) !=
4554 MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_COMPLETE
) {
4556 "Got bad status 0x%x when reading from SFP+ EEPROM\n",
4557 (val
& MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK
));
4561 /* Read the buffer */
4562 for (i
= 0; i
< byte_cnt
; i
++) {
4563 bnx2x_cl45_read(bp
, phy
,
4565 MDIO_PMA_REG_8727_TWO_WIRE_DATA_BUF
+ i
, &val
);
4566 o_buf
[i
] = (u8
)(val
& MDIO_PMA_REG_8727_TWO_WIRE_DATA_MASK
);
4569 for (i
= 0; i
< 100; i
++) {
4570 bnx2x_cl45_read(bp
, phy
,
4572 MDIO_PMA_REG_SFP_TWO_WIRE_CTRL
, &val
);
4573 if ((val
& MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK
) ==
4574 MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_IDLE
)
4582 static u8
bnx2x_read_sfp_module_eeprom(struct bnx2x_phy
*phy
,
4583 struct link_params
*params
, u16 addr
,
4584 u8 byte_cnt
, u8
*o_buf
)
4586 if (phy
->type
== PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726
)
4587 return bnx2x_8726_read_sfp_module_eeprom(phy
, params
, addr
,
4589 else if (phy
->type
== PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727
)
4590 return bnx2x_8727_read_sfp_module_eeprom(phy
, params
, addr
,
4595 static u8
bnx2x_get_edc_mode(struct bnx2x_phy
*phy
,
4596 struct link_params
*params
,
4599 struct bnx2x
*bp
= params
->bp
;
4600 u8 val
, check_limiting_mode
= 0;
4601 *edc_mode
= EDC_MODE_LIMITING
;
4603 /* First check for copper cable */
4604 if (bnx2x_read_sfp_module_eeprom(phy
,
4606 SFP_EEPROM_CON_TYPE_ADDR
,
4609 DP(NETIF_MSG_LINK
, "Failed to read from SFP+ module EEPROM\n");
4614 case SFP_EEPROM_CON_TYPE_VAL_COPPER
:
4616 u8 copper_module_type
;
4618 /* Check if its active cable( includes SFP+ module)
4620 if (bnx2x_read_sfp_module_eeprom(phy
,
4622 SFP_EEPROM_FC_TX_TECH_ADDR
,
4624 &copper_module_type
) !=
4627 "Failed to read copper-cable-type"
4628 " from SFP+ EEPROM\n");
4632 if (copper_module_type
&
4633 SFP_EEPROM_FC_TX_TECH_BITMASK_COPPER_ACTIVE
) {
4634 DP(NETIF_MSG_LINK
, "Active Copper cable detected\n");
4635 check_limiting_mode
= 1;
4636 } else if (copper_module_type
&
4637 SFP_EEPROM_FC_TX_TECH_BITMASK_COPPER_PASSIVE
) {
4638 DP(NETIF_MSG_LINK
, "Passive Copper"
4639 " cable detected\n");
4641 EDC_MODE_PASSIVE_DAC
;
4643 DP(NETIF_MSG_LINK
, "Unknown copper-cable-"
4644 "type 0x%x !!!\n", copper_module_type
);
4649 case SFP_EEPROM_CON_TYPE_VAL_LC
:
4650 DP(NETIF_MSG_LINK
, "Optic module detected\n");
4651 check_limiting_mode
= 1;
4654 DP(NETIF_MSG_LINK
, "Unable to determine module type 0x%x !!!\n",
4659 if (check_limiting_mode
) {
4660 u8 options
[SFP_EEPROM_OPTIONS_SIZE
];
4661 if (bnx2x_read_sfp_module_eeprom(phy
,
4663 SFP_EEPROM_OPTIONS_ADDR
,
4664 SFP_EEPROM_OPTIONS_SIZE
,
4666 DP(NETIF_MSG_LINK
, "Failed to read Option"
4667 " field from module EEPROM\n");
4670 if ((options
[0] & SFP_EEPROM_OPTIONS_LINEAR_RX_OUT_MASK
))
4671 *edc_mode
= EDC_MODE_LINEAR
;
4673 *edc_mode
= EDC_MODE_LIMITING
;
4675 DP(NETIF_MSG_LINK
, "EDC mode is set to 0x%x\n", *edc_mode
);
4678 /* This function read the relevant field from the module ( SFP+ ),
4679 and verify it is compliant with this board */
4680 static u8
bnx2x_verify_sfp_module(struct bnx2x_phy
*phy
,
4681 struct link_params
*params
)
4683 struct bnx2x
*bp
= params
->bp
;
4685 u32 fw_resp
, fw_cmd_param
;
4686 char vendor_name
[SFP_EEPROM_VENDOR_NAME_SIZE
+1];
4687 char vendor_pn
[SFP_EEPROM_PART_NO_SIZE
+1];
4688 phy
->flags
&= ~FLAGS_SFP_NOT_APPROVED
;
4689 val
= REG_RD(bp
, params
->shmem_base
+
4690 offsetof(struct shmem_region
, dev_info
.
4691 port_feature_config
[params
->port
].config
));
4692 if ((val
& PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK
) ==
4693 PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_NO_ENFORCEMENT
) {
4694 DP(NETIF_MSG_LINK
, "NOT enforcing module verification\n");
4698 if (params
->feature_config_flags
&
4699 FEATURE_CONFIG_BC_SUPPORTS_DUAL_PHY_OPT_MDL_VRFY
) {
4700 /* Use specific phy request */
4701 cmd
= DRV_MSG_CODE_VRFY_SPECIFIC_PHY_OPT_MDL
;
4702 } else if (params
->feature_config_flags
&
4703 FEATURE_CONFIG_BC_SUPPORTS_OPT_MDL_VRFY
) {
4704 /* Use first phy request only in case of non-dual media*/
4705 if (DUAL_MEDIA(params
)) {
4706 DP(NETIF_MSG_LINK
, "FW does not support OPT MDL "
4710 cmd
= DRV_MSG_CODE_VRFY_FIRST_PHY_OPT_MDL
;
4712 /* No support in OPT MDL detection */
4713 DP(NETIF_MSG_LINK
, "FW does not support OPT MDL "
4718 fw_cmd_param
= FW_PARAM_SET(phy
->addr
, phy
->type
, phy
->mdio_ctrl
);
4719 fw_resp
= bnx2x_fw_command(bp
, cmd
, fw_cmd_param
);
4720 if (fw_resp
== FW_MSG_CODE_VRFY_OPT_MDL_SUCCESS
) {
4721 DP(NETIF_MSG_LINK
, "Approved module\n");
4725 /* format the warning message */
4726 if (bnx2x_read_sfp_module_eeprom(phy
,
4728 SFP_EEPROM_VENDOR_NAME_ADDR
,
4729 SFP_EEPROM_VENDOR_NAME_SIZE
,
4731 vendor_name
[0] = '\0';
4733 vendor_name
[SFP_EEPROM_VENDOR_NAME_SIZE
] = '\0';
4734 if (bnx2x_read_sfp_module_eeprom(phy
,
4736 SFP_EEPROM_PART_NO_ADDR
,
4737 SFP_EEPROM_PART_NO_SIZE
,
4739 vendor_pn
[0] = '\0';
4741 vendor_pn
[SFP_EEPROM_PART_NO_SIZE
] = '\0';
4743 netdev_info(bp
->dev
, "Warning: Unqualified SFP+ module detected,"
4744 " Port %d from %s part number %s\n",
4745 params
->port
, vendor_name
, vendor_pn
);
4746 phy
->flags
|= FLAGS_SFP_NOT_APPROVED
;
4750 static u8
bnx2x_wait_for_sfp_module_initialized(struct bnx2x_phy
*phy
,
4751 struct link_params
*params
)
4755 struct bnx2x
*bp
= params
->bp
;
4757 /* Initialization time after hot-plug may take up to 300ms for some
4758 phys type ( e.g. JDSU ) */
4759 for (timeout
= 0; timeout
< 60; timeout
++) {
4760 if (bnx2x_read_sfp_module_eeprom(phy
, params
, 1, 1, &val
)
4762 DP(NETIF_MSG_LINK
, "SFP+ module initialization "
4763 "took %d ms\n", timeout
* 5);
4771 static void bnx2x_8727_power_module(struct bnx2x
*bp
,
4772 struct bnx2x_phy
*phy
,
4774 /* Make sure GPIOs are not using for LED mode */
4777 * In the GPIO register, bit 4 is use to detemine if the GPIOs are
4778 * operating as INPUT or as OUTPUT. Bit 1 is for input, and 0 for
4780 * Bits 0-1 determine the gpios value for OUTPUT in case bit 4 val is 0
4781 * Bits 8-9 determine the gpios value for INPUT in case bit 4 val is 1
4782 * where the 1st bit is the over-current(only input), and 2nd bit is
4783 * for power( only output )
4787 * In case of NOC feature is disabled and power is up, set GPIO control
4788 * as input to enable listening of over-current indication
4790 if (phy
->flags
& FLAGS_NOC
)
4793 FLAGS_NOC
) && is_power_up
)
4797 * Set GPIO control to OUTPUT, and set the power bit
4798 * to according to the is_power_up
4800 val
= ((!(is_power_up
)) << 1);
4802 bnx2x_cl45_write(bp
, phy
,
4804 MDIO_PMA_REG_8727_GPIO_CTRL
,
4808 static u8
bnx2x_8726_set_limiting_mode(struct bnx2x
*bp
,
4809 struct bnx2x_phy
*phy
,
4812 u16 cur_limiting_mode
;
4814 bnx2x_cl45_read(bp
, phy
,
4816 MDIO_PMA_REG_ROM_VER2
,
4817 &cur_limiting_mode
);
4818 DP(NETIF_MSG_LINK
, "Current Limiting mode is 0x%x\n",
4821 if (edc_mode
== EDC_MODE_LIMITING
) {
4823 "Setting LIMITING MODE\n");
4824 bnx2x_cl45_write(bp
, phy
,
4826 MDIO_PMA_REG_ROM_VER2
,
4828 } else { /* LRM mode ( default )*/
4830 DP(NETIF_MSG_LINK
, "Setting LRM MODE\n");
4832 /* Changing to LRM mode takes quite few seconds.
4833 So do it only if current mode is limiting
4834 ( default is LRM )*/
4835 if (cur_limiting_mode
!= EDC_MODE_LIMITING
)
4838 bnx2x_cl45_write(bp
, phy
,
4840 MDIO_PMA_REG_LRM_MODE
,
4842 bnx2x_cl45_write(bp
, phy
,
4844 MDIO_PMA_REG_ROM_VER2
,
4846 bnx2x_cl45_write(bp
, phy
,
4848 MDIO_PMA_REG_MISC_CTRL0
,
4850 bnx2x_cl45_write(bp
, phy
,
4852 MDIO_PMA_REG_LRM_MODE
,
4858 static u8
bnx2x_8727_set_limiting_mode(struct bnx2x
*bp
,
4859 struct bnx2x_phy
*phy
,
4864 bnx2x_cl45_read(bp
, phy
,
4866 MDIO_PMA_REG_PHY_IDENTIFIER
,
4869 bnx2x_cl45_write(bp
, phy
,
4871 MDIO_PMA_REG_PHY_IDENTIFIER
,
4872 (phy_identifier
& ~(1<<9)));
4874 bnx2x_cl45_read(bp
, phy
,
4876 MDIO_PMA_REG_ROM_VER2
,
4878 /* Keep the MSB 8-bits, and set the LSB 8-bits with the edc_mode */
4879 bnx2x_cl45_write(bp
, phy
,
4881 MDIO_PMA_REG_ROM_VER2
,
4882 (rom_ver2_val
& 0xff00) | (edc_mode
& 0x00ff));
4884 bnx2x_cl45_write(bp
, phy
,
4886 MDIO_PMA_REG_PHY_IDENTIFIER
,
4887 (phy_identifier
| (1<<9)));
4892 static void bnx2x_8727_specific_func(struct bnx2x_phy
*phy
,
4893 struct link_params
*params
,
4896 struct bnx2x
*bp
= params
->bp
;
4900 bnx2x_sfp_set_transmitter(bp
, phy
, params
->port
, 0);
4903 if (!(phy
->flags
& FLAGS_SFP_NOT_APPROVED
))
4904 bnx2x_sfp_set_transmitter(bp
, phy
, params
->port
, 1);
4907 DP(NETIF_MSG_LINK
, "Function 0x%x not supported by 8727\n",
4913 static u8
bnx2x_sfp_module_detection(struct bnx2x_phy
*phy
,
4914 struct link_params
*params
)
4916 struct bnx2x
*bp
= params
->bp
;
4920 u32 val
= REG_RD(bp
, params
->shmem_base
+
4921 offsetof(struct shmem_region
, dev_info
.
4922 port_feature_config
[params
->port
].config
));
4924 DP(NETIF_MSG_LINK
, "SFP+ module plugged in/out detected on port %d\n",
4927 if (bnx2x_get_edc_mode(phy
, params
, &edc_mode
) != 0) {
4928 DP(NETIF_MSG_LINK
, "Failed to get valid module type\n");
4930 } else if (bnx2x_verify_sfp_module(phy
, params
) !=
4932 /* check SFP+ module compatibility */
4933 DP(NETIF_MSG_LINK
, "Module verification failed!!\n");
4935 /* Turn on fault module-detected led */
4936 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_0
,
4937 MISC_REGISTERS_GPIO_HIGH
,
4939 if ((phy
->type
== PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727
) &&
4940 ((val
& PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK
) ==
4941 PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_POWER_DOWN
)) {
4942 /* Shutdown SFP+ module */
4943 DP(NETIF_MSG_LINK
, "Shutdown SFP+ module!!\n");
4944 bnx2x_8727_power_module(bp
, phy
, 0);
4948 /* Turn off fault module-detected led */
4949 DP(NETIF_MSG_LINK
, "Turn off fault module-detected led\n");
4950 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_0
,
4951 MISC_REGISTERS_GPIO_LOW
,
4955 /* power up the SFP module */
4956 if (phy
->type
== PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727
)
4957 bnx2x_8727_power_module(bp
, phy
, 1);
4959 /* Check and set limiting mode / LRM mode on 8726.
4960 On 8727 it is done automatically */
4961 if (phy
->type
== PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726
)
4962 bnx2x_8726_set_limiting_mode(bp
, phy
, edc_mode
);
4964 bnx2x_8727_set_limiting_mode(bp
, phy
, edc_mode
);
4966 * Enable transmit for this module if the module is approved, or
4967 * if unapproved modules should also enable the Tx laser
4970 (val
& PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK
) !=
4971 PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_DISABLE_TX_LASER
)
4972 bnx2x_sfp_set_transmitter(bp
, phy
, params
->port
, 1);
4974 bnx2x_sfp_set_transmitter(bp
, phy
, params
->port
, 0);
4979 void bnx2x_handle_module_detect_int(struct link_params
*params
)
4981 struct bnx2x
*bp
= params
->bp
;
4982 struct bnx2x_phy
*phy
= ¶ms
->phy
[EXT_PHY1
];
4984 u8 port
= params
->port
;
4986 /* Set valid module led off */
4987 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_0
,
4988 MISC_REGISTERS_GPIO_HIGH
,
4991 /* Get current gpio val refelecting module plugged in / out*/
4992 gpio_val
= bnx2x_get_gpio(bp
, MISC_REGISTERS_GPIO_3
, port
);
4994 /* Call the handling function in case module is detected */
4995 if (gpio_val
== 0) {
4997 bnx2x_set_gpio_int(bp
, MISC_REGISTERS_GPIO_3
,
4998 MISC_REGISTERS_GPIO_INT_OUTPUT_CLR
,
5001 if (bnx2x_wait_for_sfp_module_initialized(phy
, params
) == 0)
5002 bnx2x_sfp_module_detection(phy
, params
);
5004 DP(NETIF_MSG_LINK
, "SFP+ module is not initialized\n");
5006 u32 val
= REG_RD(bp
, params
->shmem_base
+
5007 offsetof(struct shmem_region
, dev_info
.
5008 port_feature_config
[params
->port
].
5011 bnx2x_set_gpio_int(bp
, MISC_REGISTERS_GPIO_3
,
5012 MISC_REGISTERS_GPIO_INT_OUTPUT_SET
,
5014 /* Module was plugged out. */
5015 /* Disable transmit for this module */
5016 if ((val
& PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK
) ==
5017 PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_DISABLE_TX_LASER
)
5018 bnx2x_sfp_set_transmitter(bp
, phy
, params
->port
, 0);
5022 /******************************************************************/
5023 /* common BCM8706/BCM8726 PHY SECTION */
5024 /******************************************************************/
5025 static u8
bnx2x_8706_8726_read_status(struct bnx2x_phy
*phy
,
5026 struct link_params
*params
,
5027 struct link_vars
*vars
)
5030 u16 val1
, val2
, rx_sd
, pcs_status
;
5031 struct bnx2x
*bp
= params
->bp
;
5032 DP(NETIF_MSG_LINK
, "XGXS 8706/8726\n");
5034 bnx2x_cl45_read(bp
, phy
,
5035 MDIO_PMA_DEVAD
, MDIO_PMA_REG_RX_ALARM
, &val2
);
5036 /* clear LASI indication*/
5037 bnx2x_cl45_read(bp
, phy
,
5038 MDIO_PMA_DEVAD
, MDIO_PMA_REG_LASI_STATUS
, &val1
);
5039 bnx2x_cl45_read(bp
, phy
,
5040 MDIO_PMA_DEVAD
, MDIO_PMA_REG_LASI_STATUS
, &val2
);
5041 DP(NETIF_MSG_LINK
, "8706/8726 LASI status 0x%x--> 0x%x\n", val1
, val2
);
5043 bnx2x_cl45_read(bp
, phy
,
5044 MDIO_PMA_DEVAD
, MDIO_PMA_REG_RX_SD
, &rx_sd
);
5045 bnx2x_cl45_read(bp
, phy
,
5046 MDIO_PCS_DEVAD
, MDIO_PCS_REG_STATUS
, &pcs_status
);
5047 bnx2x_cl45_read(bp
, phy
,
5048 MDIO_AN_DEVAD
, MDIO_AN_REG_LINK_STATUS
, &val2
);
5049 bnx2x_cl45_read(bp
, phy
,
5050 MDIO_AN_DEVAD
, MDIO_AN_REG_LINK_STATUS
, &val2
);
5052 DP(NETIF_MSG_LINK
, "8706/8726 rx_sd 0x%x pcs_status 0x%x 1Gbps"
5053 " link_status 0x%x\n", rx_sd
, pcs_status
, val2
);
5054 /* link is up if both bit 0 of pmd_rx_sd and
5055 * bit 0 of pcs_status are set, or if the autoneg bit
5058 link_up
= ((rx_sd
& pcs_status
& 0x1) || (val2
& (1<<1)));
5061 vars
->line_speed
= SPEED_1000
;
5063 vars
->line_speed
= SPEED_10000
;
5064 bnx2x_ext_phy_resolve_fc(phy
, params
, vars
);
5069 /******************************************************************/
5070 /* BCM8706 PHY SECTION */
5071 /******************************************************************/
5072 static u8
bnx2x_8706_config_init(struct bnx2x_phy
*phy
,
5073 struct link_params
*params
,
5074 struct link_vars
*vars
)
5077 struct bnx2x
*bp
= params
->bp
;
5078 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_2
,
5079 MISC_REGISTERS_GPIO_OUTPUT_HIGH
, params
->port
);
5081 bnx2x_ext_phy_hw_reset(bp
, params
->port
);
5082 bnx2x_cl45_write(bp
, phy
, MDIO_PMA_DEVAD
, MDIO_PMA_REG_CTRL
, 0xa040);
5083 bnx2x_wait_reset_complete(bp
, phy
);
5085 /* Wait until fw is loaded */
5086 for (cnt
= 0; cnt
< 100; cnt
++) {
5087 bnx2x_cl45_read(bp
, phy
,
5088 MDIO_PMA_DEVAD
, MDIO_PMA_REG_ROM_VER1
, &val
);
5093 DP(NETIF_MSG_LINK
, "XGXS 8706 is initialized after %d ms\n", cnt
);
5094 if ((params
->feature_config_flags
&
5095 FEATURE_CONFIG_OVERRIDE_PREEMPHASIS_ENABLED
)) {
5098 for (i
= 0; i
< 4; i
++) {
5099 reg
= MDIO_XS_8706_REG_BANK_RX0
+
5100 i
*(MDIO_XS_8706_REG_BANK_RX1
-
5101 MDIO_XS_8706_REG_BANK_RX0
);
5102 bnx2x_cl45_read(bp
, phy
, MDIO_XS_DEVAD
, reg
, &val
);
5103 /* Clear first 3 bits of the control */
5105 /* Set control bits according to configuration */
5106 val
|= (phy
->rx_preemphasis
[i
] & 0x7);
5107 DP(NETIF_MSG_LINK
, "Setting RX Equalizer to BCM8706"
5108 " reg 0x%x <-- val 0x%x\n", reg
, val
);
5109 bnx2x_cl45_write(bp
, phy
, MDIO_XS_DEVAD
, reg
, val
);
5113 if (phy
->req_line_speed
== SPEED_10000
) {
5114 DP(NETIF_MSG_LINK
, "XGXS 8706 force 10Gbps\n");
5116 bnx2x_cl45_write(bp
, phy
,
5118 MDIO_PMA_REG_DIGITAL_CTRL
, 0x400);
5119 bnx2x_cl45_write(bp
, phy
,
5120 MDIO_PMA_DEVAD
, MDIO_PMA_REG_LASI_CTRL
, 1);
5122 /* Force 1Gbps using autoneg with 1G advertisment */
5124 /* Allow CL37 through CL73 */
5125 DP(NETIF_MSG_LINK
, "XGXS 8706 AutoNeg\n");
5126 bnx2x_cl45_write(bp
, phy
,
5127 MDIO_AN_DEVAD
, MDIO_AN_REG_CL37_CL73
, 0x040c);
5129 /* Enable Full-Duplex advertisment on CL37 */
5130 bnx2x_cl45_write(bp
, phy
,
5131 MDIO_AN_DEVAD
, MDIO_AN_REG_CL37_FC_LP
, 0x0020);
5132 /* Enable CL37 AN */
5133 bnx2x_cl45_write(bp
, phy
,
5134 MDIO_AN_DEVAD
, MDIO_AN_REG_CL37_AN
, 0x1000);
5136 bnx2x_cl45_write(bp
, phy
,
5137 MDIO_AN_DEVAD
, MDIO_AN_REG_ADV
, (1<<5));
5139 /* Enable clause 73 AN */
5140 bnx2x_cl45_write(bp
, phy
,
5141 MDIO_AN_DEVAD
, MDIO_AN_REG_CTRL
, 0x1200);
5142 bnx2x_cl45_write(bp
, phy
,
5143 MDIO_PMA_DEVAD
, MDIO_PMA_REG_RX_ALARM_CTRL
,
5145 bnx2x_cl45_write(bp
, phy
,
5146 MDIO_PMA_DEVAD
, MDIO_PMA_REG_LASI_CTRL
,
5149 bnx2x_save_bcm_spirom_ver(bp
, phy
, params
->port
);
5153 static u8
bnx2x_8706_read_status(struct bnx2x_phy
*phy
,
5154 struct link_params
*params
,
5155 struct link_vars
*vars
)
5157 return bnx2x_8706_8726_read_status(phy
, params
, vars
);
5160 /******************************************************************/
5161 /* BCM8726 PHY SECTION */
5162 /******************************************************************/
5163 static void bnx2x_8726_config_loopback(struct bnx2x_phy
*phy
,
5164 struct link_params
*params
)
5166 struct bnx2x
*bp
= params
->bp
;
5167 DP(NETIF_MSG_LINK
, "PMA/PMD ext_phy_loopback: 8726\n");
5168 bnx2x_cl45_write(bp
, phy
, MDIO_PMA_DEVAD
, MDIO_PMA_REG_CTRL
, 0x0001);
5171 static void bnx2x_8726_external_rom_boot(struct bnx2x_phy
*phy
,
5172 struct link_params
*params
)
5174 struct bnx2x
*bp
= params
->bp
;
5175 /* Need to wait 100ms after reset */
5178 /* Micro controller re-boot */
5179 bnx2x_cl45_write(bp
, phy
,
5180 MDIO_PMA_DEVAD
, MDIO_PMA_REG_GEN_CTRL
, 0x018B);
5182 /* Set soft reset */
5183 bnx2x_cl45_write(bp
, phy
,
5185 MDIO_PMA_REG_GEN_CTRL
,
5186 MDIO_PMA_REG_GEN_CTRL_ROM_MICRO_RESET
);
5188 bnx2x_cl45_write(bp
, phy
,
5190 MDIO_PMA_REG_MISC_CTRL1
, 0x0001);
5192 bnx2x_cl45_write(bp
, phy
,
5194 MDIO_PMA_REG_GEN_CTRL
,
5195 MDIO_PMA_REG_GEN_CTRL_ROM_RESET_INTERNAL_MP
);
5197 /* wait for 150ms for microcode load */
5200 /* Disable serial boot control, tristates pins SS_N, SCK, MOSI, MISO */
5201 bnx2x_cl45_write(bp
, phy
,
5203 MDIO_PMA_REG_MISC_CTRL1
, 0x0000);
5206 bnx2x_save_bcm_spirom_ver(bp
, phy
, params
->port
);
5209 static u8
bnx2x_8726_read_status(struct bnx2x_phy
*phy
,
5210 struct link_params
*params
,
5211 struct link_vars
*vars
)
5213 struct bnx2x
*bp
= params
->bp
;
5215 u8 link_up
= bnx2x_8706_8726_read_status(phy
, params
, vars
);
5217 bnx2x_cl45_read(bp
, phy
,
5218 MDIO_PMA_DEVAD
, MDIO_PMA_REG_PHY_IDENTIFIER
,
5220 if (val1
& (1<<15)) {
5221 DP(NETIF_MSG_LINK
, "Tx is disabled\n");
5223 vars
->line_speed
= 0;
5230 static u8
bnx2x_8726_config_init(struct bnx2x_phy
*phy
,
5231 struct link_params
*params
,
5232 struct link_vars
*vars
)
5234 struct bnx2x
*bp
= params
->bp
;
5236 u32 swap_val
, swap_override
, aeu_gpio_mask
, offset
;
5237 DP(NETIF_MSG_LINK
, "Initializing BCM8726\n");
5238 /* Restore normal power mode*/
5239 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_2
,
5240 MISC_REGISTERS_GPIO_OUTPUT_HIGH
, params
->port
);
5242 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_1
,
5243 MISC_REGISTERS_GPIO_OUTPUT_HIGH
, params
->port
);
5245 bnx2x_cl45_write(bp
, phy
, MDIO_PMA_DEVAD
, MDIO_PMA_REG_CTRL
, 1<<15);
5246 bnx2x_wait_reset_complete(bp
, phy
);
5248 bnx2x_8726_external_rom_boot(phy
, params
);
5250 /* Need to call module detected on initialization since
5251 the module detection triggered by actual module
5252 insertion might occur before driver is loaded, and when
5253 driver is loaded, it reset all registers, including the
5255 bnx2x_sfp_module_detection(phy
, params
);
5257 if (phy
->req_line_speed
== SPEED_1000
) {
5258 DP(NETIF_MSG_LINK
, "Setting 1G force\n");
5259 bnx2x_cl45_write(bp
, phy
,
5260 MDIO_PMA_DEVAD
, MDIO_PMA_REG_CTRL
, 0x40);
5261 bnx2x_cl45_write(bp
, phy
,
5262 MDIO_PMA_DEVAD
, MDIO_PMA_REG_10G_CTRL2
, 0xD);
5263 bnx2x_cl45_write(bp
, phy
,
5264 MDIO_PMA_DEVAD
, MDIO_PMA_REG_LASI_CTRL
, 0x5);
5265 bnx2x_cl45_write(bp
, phy
,
5266 MDIO_PMA_DEVAD
, MDIO_PMA_REG_RX_ALARM_CTRL
,
5268 } else if ((phy
->req_line_speed
== SPEED_AUTO_NEG
) &&
5269 (phy
->speed_cap_mask
&
5270 PORT_HW_CFG_SPEED_CAPABILITY_D0_1G
) &&
5271 ((phy
->speed_cap_mask
&
5272 PORT_HW_CFG_SPEED_CAPABILITY_D0_10G
) !=
5273 PORT_HW_CFG_SPEED_CAPABILITY_D0_10G
)) {
5274 DP(NETIF_MSG_LINK
, "Setting 1G clause37\n");
5275 /* Set Flow control */
5276 bnx2x_ext_phy_set_pause(params
, phy
, vars
);
5277 bnx2x_cl45_write(bp
, phy
,
5278 MDIO_AN_DEVAD
, MDIO_AN_REG_ADV
, 0x20);
5279 bnx2x_cl45_write(bp
, phy
,
5280 MDIO_AN_DEVAD
, MDIO_AN_REG_CL37_CL73
, 0x040c);
5281 bnx2x_cl45_write(bp
, phy
,
5282 MDIO_AN_DEVAD
, MDIO_AN_REG_CL37_FC_LD
, 0x0020);
5283 bnx2x_cl45_write(bp
, phy
,
5284 MDIO_AN_DEVAD
, MDIO_AN_REG_CL37_AN
, 0x1000);
5285 bnx2x_cl45_write(bp
, phy
,
5286 MDIO_AN_DEVAD
, MDIO_AN_REG_CTRL
, 0x1200);
5287 /* Enable RX-ALARM control to receive
5288 interrupt for 1G speed change */
5289 bnx2x_cl45_write(bp
, phy
,
5290 MDIO_PMA_DEVAD
, MDIO_PMA_REG_LASI_CTRL
, 0x4);
5291 bnx2x_cl45_write(bp
, phy
,
5292 MDIO_PMA_DEVAD
, MDIO_PMA_REG_RX_ALARM_CTRL
,
5295 } else { /* Default 10G. Set only LASI control */
5296 bnx2x_cl45_write(bp
, phy
,
5297 MDIO_PMA_DEVAD
, MDIO_PMA_REG_LASI_CTRL
, 1);
5300 /* Set TX PreEmphasis if needed */
5301 if ((params
->feature_config_flags
&
5302 FEATURE_CONFIG_OVERRIDE_PREEMPHASIS_ENABLED
)) {
5303 DP(NETIF_MSG_LINK
, "Setting TX_CTRL1 0x%x,"
5305 phy
->tx_preemphasis
[0],
5306 phy
->tx_preemphasis
[1]);
5307 bnx2x_cl45_write(bp
, phy
,
5309 MDIO_PMA_REG_8726_TX_CTRL1
,
5310 phy
->tx_preemphasis
[0]);
5312 bnx2x_cl45_write(bp
, phy
,
5314 MDIO_PMA_REG_8726_TX_CTRL2
,
5315 phy
->tx_preemphasis
[1]);
5318 /* Set GPIO3 to trigger SFP+ module insertion/removal */
5319 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_3
,
5320 MISC_REGISTERS_GPIO_INPUT_HI_Z
, params
->port
);
5322 /* The GPIO should be swapped if the swap register is set and active */
5323 swap_val
= REG_RD(bp
, NIG_REG_PORT_SWAP
);
5324 swap_override
= REG_RD(bp
, NIG_REG_STRAP_OVERRIDE
);
5326 /* Select function upon port-swap configuration */
5327 if (params
->port
== 0) {
5328 offset
= MISC_REG_AEU_ENABLE1_FUNC_0_OUT_0
;
5329 aeu_gpio_mask
= (swap_val
&& swap_override
) ?
5330 AEU_INPUTS_ATTN_BITS_GPIO3_FUNCTION_1
:
5331 AEU_INPUTS_ATTN_BITS_GPIO3_FUNCTION_0
;
5333 offset
= MISC_REG_AEU_ENABLE1_FUNC_1_OUT_0
;
5334 aeu_gpio_mask
= (swap_val
&& swap_override
) ?
5335 AEU_INPUTS_ATTN_BITS_GPIO3_FUNCTION_0
:
5336 AEU_INPUTS_ATTN_BITS_GPIO3_FUNCTION_1
;
5338 val
= REG_RD(bp
, offset
);
5339 /* add GPIO3 to group */
5340 val
|= aeu_gpio_mask
;
5341 REG_WR(bp
, offset
, val
);
5346 static void bnx2x_8726_link_reset(struct bnx2x_phy
*phy
,
5347 struct link_params
*params
)
5349 struct bnx2x
*bp
= params
->bp
;
5350 DP(NETIF_MSG_LINK
, "bnx2x_8726_link_reset port %d\n", params
->port
);
5351 /* Set serial boot control for external load */
5352 bnx2x_cl45_write(bp
, phy
,
5354 MDIO_PMA_REG_GEN_CTRL
, 0x0001);
5357 /******************************************************************/
5358 /* BCM8727 PHY SECTION */
5359 /******************************************************************/
5361 static void bnx2x_8727_set_link_led(struct bnx2x_phy
*phy
,
5362 struct link_params
*params
, u8 mode
)
5364 struct bnx2x
*bp
= params
->bp
;
5365 u16 led_mode_bitmask
= 0;
5366 u16 gpio_pins_bitmask
= 0;
5368 /* Only NOC flavor requires to set the LED specifically */
5369 if (!(phy
->flags
& FLAGS_NOC
))
5372 case LED_MODE_FRONT_PANEL_OFF
:
5374 led_mode_bitmask
= 0;
5375 gpio_pins_bitmask
= 0x03;
5378 led_mode_bitmask
= 0;
5379 gpio_pins_bitmask
= 0x02;
5382 led_mode_bitmask
= 0x60;
5383 gpio_pins_bitmask
= 0x11;
5386 bnx2x_cl45_read(bp
, phy
,
5388 MDIO_PMA_REG_8727_PCS_OPT_CTRL
,
5391 val
|= led_mode_bitmask
;
5392 bnx2x_cl45_write(bp
, phy
,
5394 MDIO_PMA_REG_8727_PCS_OPT_CTRL
,
5396 bnx2x_cl45_read(bp
, phy
,
5398 MDIO_PMA_REG_8727_GPIO_CTRL
,
5401 val
|= gpio_pins_bitmask
;
5402 bnx2x_cl45_write(bp
, phy
,
5404 MDIO_PMA_REG_8727_GPIO_CTRL
,
5407 static void bnx2x_8727_hw_reset(struct bnx2x_phy
*phy
,
5408 struct link_params
*params
) {
5409 u32 swap_val
, swap_override
;
5412 * The PHY reset is controlled by GPIO 1. Fake the port number
5413 * to cancel the swap done in set_gpio()
5415 struct bnx2x
*bp
= params
->bp
;
5416 swap_val
= REG_RD(bp
, NIG_REG_PORT_SWAP
);
5417 swap_override
= REG_RD(bp
, NIG_REG_STRAP_OVERRIDE
);
5418 port
= (swap_val
&& swap_override
) ^ 1;
5419 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_1
,
5420 MISC_REGISTERS_GPIO_OUTPUT_LOW
, port
);
5423 static u8
bnx2x_8727_config_init(struct bnx2x_phy
*phy
,
5424 struct link_params
*params
,
5425 struct link_vars
*vars
)
5427 u16 tmp1
, val
, mod_abs
;
5428 u16 rx_alarm_ctrl_val
;
5430 struct bnx2x
*bp
= params
->bp
;
5431 /* Enable PMD link, MOD_ABS_FLT, and 1G link alarm */
5433 bnx2x_wait_reset_complete(bp
, phy
);
5434 rx_alarm_ctrl_val
= (1<<2) | (1<<5) ;
5435 lasi_ctrl_val
= 0x0004;
5437 DP(NETIF_MSG_LINK
, "Initializing BCM8727\n");
5439 bnx2x_cl45_write(bp
, phy
,
5440 MDIO_PMA_DEVAD
, MDIO_PMA_REG_RX_ALARM_CTRL
,
5443 bnx2x_cl45_write(bp
, phy
,
5444 MDIO_PMA_DEVAD
, MDIO_PMA_REG_LASI_CTRL
, lasi_ctrl_val
);
5446 /* Initially configure MOD_ABS to interrupt when
5447 module is presence( bit 8) */
5448 bnx2x_cl45_read(bp
, phy
,
5449 MDIO_PMA_DEVAD
, MDIO_PMA_REG_PHY_IDENTIFIER
, &mod_abs
);
5450 /* Set EDC off by setting OPTXLOS signal input to low
5452 When the EDC is off it locks onto a reference clock and
5453 avoids becoming 'lost'.*/
5455 if (!(phy
->flags
& FLAGS_NOC
))
5457 bnx2x_cl45_write(bp
, phy
,
5458 MDIO_PMA_DEVAD
, MDIO_PMA_REG_PHY_IDENTIFIER
, mod_abs
);
5461 /* Make MOD_ABS give interrupt on change */
5462 bnx2x_cl45_read(bp
, phy
, MDIO_PMA_DEVAD
, MDIO_PMA_REG_8727_PCS_OPT_CTRL
,
5465 if (phy
->flags
& FLAGS_NOC
)
5469 * Set 8727 GPIOs to input to allow reading from the 8727 GPIO0
5470 * status which reflect SFP+ module over-current
5472 if (!(phy
->flags
& FLAGS_NOC
))
5473 val
&= 0xff8f; /* Reset bits 4-6 */
5474 bnx2x_cl45_write(bp
, phy
,
5475 MDIO_PMA_DEVAD
, MDIO_PMA_REG_8727_PCS_OPT_CTRL
, val
);
5477 bnx2x_8727_power_module(bp
, phy
, 1);
5479 bnx2x_cl45_read(bp
, phy
,
5480 MDIO_PMA_DEVAD
, MDIO_PMA_REG_M8051_MSGOUT_REG
, &tmp1
);
5482 bnx2x_cl45_read(bp
, phy
,
5483 MDIO_PMA_DEVAD
, MDIO_PMA_REG_RX_ALARM
, &tmp1
);
5485 /* Set option 1G speed */
5486 if (phy
->req_line_speed
== SPEED_1000
) {
5487 DP(NETIF_MSG_LINK
, "Setting 1G force\n");
5488 bnx2x_cl45_write(bp
, phy
,
5489 MDIO_PMA_DEVAD
, MDIO_PMA_REG_CTRL
, 0x40);
5490 bnx2x_cl45_write(bp
, phy
,
5491 MDIO_PMA_DEVAD
, MDIO_PMA_REG_10G_CTRL2
, 0xD);
5492 bnx2x_cl45_read(bp
, phy
,
5493 MDIO_PMA_DEVAD
, MDIO_PMA_REG_10G_CTRL2
, &tmp1
);
5494 DP(NETIF_MSG_LINK
, "1.7 = 0x%x\n", tmp1
);
5496 * Power down the XAUI until link is up in case of dual-media
5499 if (DUAL_MEDIA(params
)) {
5500 bnx2x_cl45_read(bp
, phy
,
5502 MDIO_PMA_REG_8727_PCS_GP
, &val
);
5504 bnx2x_cl45_write(bp
, phy
,
5506 MDIO_PMA_REG_8727_PCS_GP
, val
);
5508 } else if ((phy
->req_line_speed
== SPEED_AUTO_NEG
) &&
5509 ((phy
->speed_cap_mask
&
5510 PORT_HW_CFG_SPEED_CAPABILITY_D0_1G
)) &&
5511 ((phy
->speed_cap_mask
&
5512 PORT_HW_CFG_SPEED_CAPABILITY_D0_10G
) !=
5513 PORT_HW_CFG_SPEED_CAPABILITY_D0_10G
)) {
5515 DP(NETIF_MSG_LINK
, "Setting 1G clause37\n");
5516 bnx2x_cl45_write(bp
, phy
,
5517 MDIO_AN_DEVAD
, MDIO_AN_REG_8727_MISC_CTRL
, 0);
5518 bnx2x_cl45_write(bp
, phy
,
5519 MDIO_AN_DEVAD
, MDIO_AN_REG_CL37_AN
, 0x1300);
5522 * Since the 8727 has only single reset pin, need to set the 10G
5523 * registers although it is default
5525 bnx2x_cl45_write(bp
, phy
,
5526 MDIO_AN_DEVAD
, MDIO_AN_REG_8727_MISC_CTRL
,
5528 bnx2x_cl45_write(bp
, phy
,
5529 MDIO_AN_DEVAD
, MDIO_AN_REG_CL37_AN
, 0x0100);
5530 bnx2x_cl45_write(bp
, phy
,
5531 MDIO_PMA_DEVAD
, MDIO_PMA_REG_CTRL
, 0x2040);
5532 bnx2x_cl45_write(bp
, phy
,
5533 MDIO_PMA_DEVAD
, MDIO_PMA_REG_10G_CTRL2
,
5537 /* Set 2-wire transfer rate of SFP+ module EEPROM
5538 * to 100Khz since some DACs(direct attached cables) do
5539 * not work at 400Khz.
5541 bnx2x_cl45_write(bp
, phy
,
5542 MDIO_PMA_DEVAD
, MDIO_PMA_REG_8727_TWO_WIRE_SLAVE_ADDR
,
5545 /* Set TX PreEmphasis if needed */
5546 if ((params
->feature_config_flags
&
5547 FEATURE_CONFIG_OVERRIDE_PREEMPHASIS_ENABLED
)) {
5548 DP(NETIF_MSG_LINK
, "Setting TX_CTRL1 0x%x, TX_CTRL2 0x%x\n",
5549 phy
->tx_preemphasis
[0],
5550 phy
->tx_preemphasis
[1]);
5551 bnx2x_cl45_write(bp
, phy
,
5552 MDIO_PMA_DEVAD
, MDIO_PMA_REG_8727_TX_CTRL1
,
5553 phy
->tx_preemphasis
[0]);
5555 bnx2x_cl45_write(bp
, phy
,
5556 MDIO_PMA_DEVAD
, MDIO_PMA_REG_8727_TX_CTRL2
,
5557 phy
->tx_preemphasis
[1]);
5563 static void bnx2x_8727_handle_mod_abs(struct bnx2x_phy
*phy
,
5564 struct link_params
*params
)
5566 struct bnx2x
*bp
= params
->bp
;
5567 u16 mod_abs
, rx_alarm_status
;
5568 u32 val
= REG_RD(bp
, params
->shmem_base
+
5569 offsetof(struct shmem_region
, dev_info
.
5570 port_feature_config
[params
->port
].
5572 bnx2x_cl45_read(bp
, phy
,
5574 MDIO_PMA_REG_PHY_IDENTIFIER
, &mod_abs
);
5575 if (mod_abs
& (1<<8)) {
5577 /* Module is absent */
5578 DP(NETIF_MSG_LINK
, "MOD_ABS indication "
5579 "show module is absent\n");
5581 /* 1. Set mod_abs to detect next module
5583 2. Set EDC off by setting OPTXLOS signal input to low
5585 When the EDC is off it locks onto a reference clock and
5586 avoids becoming 'lost'.*/
5588 if (!(phy
->flags
& FLAGS_NOC
))
5590 bnx2x_cl45_write(bp
, phy
,
5592 MDIO_PMA_REG_PHY_IDENTIFIER
, mod_abs
);
5594 /* Clear RX alarm since it stays up as long as
5595 the mod_abs wasn't changed */
5596 bnx2x_cl45_read(bp
, phy
,
5598 MDIO_PMA_REG_RX_ALARM
, &rx_alarm_status
);
5601 /* Module is present */
5602 DP(NETIF_MSG_LINK
, "MOD_ABS indication "
5603 "show module is present\n");
5604 /* First thing, disable transmitter,
5605 and if the module is ok, the
5606 module_detection will enable it*/
5608 /* 1. Set mod_abs to detect next module
5609 absent event ( bit 8)
5610 2. Restore the default polarity of the OPRXLOS signal and
5611 this signal will then correctly indicate the presence or
5612 absence of the Rx signal. (bit 9) */
5614 if (!(phy
->flags
& FLAGS_NOC
))
5616 bnx2x_cl45_write(bp
, phy
,
5618 MDIO_PMA_REG_PHY_IDENTIFIER
, mod_abs
);
5620 /* Clear RX alarm since it stays up as long as
5621 the mod_abs wasn't changed. This is need to be done
5622 before calling the module detection, otherwise it will clear
5623 the link update alarm */
5624 bnx2x_cl45_read(bp
, phy
,
5626 MDIO_PMA_REG_RX_ALARM
, &rx_alarm_status
);
5629 if ((val
& PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK
) ==
5630 PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_DISABLE_TX_LASER
)
5631 bnx2x_sfp_set_transmitter(bp
, phy
, params
->port
, 0);
5633 if (bnx2x_wait_for_sfp_module_initialized(phy
, params
) == 0)
5634 bnx2x_sfp_module_detection(phy
, params
);
5636 DP(NETIF_MSG_LINK
, "SFP+ module is not initialized\n");
5639 DP(NETIF_MSG_LINK
, "8727 RX_ALARM_STATUS 0x%x\n",
5641 /* No need to check link status in case of
5642 module plugged in/out */
5645 static u8
bnx2x_8727_read_status(struct bnx2x_phy
*phy
,
5646 struct link_params
*params
,
5647 struct link_vars
*vars
)
5650 struct bnx2x
*bp
= params
->bp
;
5652 u16 link_status
= 0;
5653 u16 rx_alarm_status
, lasi_ctrl
, val1
;
5655 /* If PHY is not initialized, do not check link status */
5656 bnx2x_cl45_read(bp
, phy
,
5657 MDIO_PMA_DEVAD
, MDIO_PMA_REG_LASI_CTRL
,
5662 /* Check the LASI */
5663 bnx2x_cl45_read(bp
, phy
,
5664 MDIO_PMA_DEVAD
, MDIO_PMA_REG_RX_ALARM
,
5666 vars
->line_speed
= 0;
5667 DP(NETIF_MSG_LINK
, "8727 RX_ALARM_STATUS 0x%x\n", rx_alarm_status
);
5669 bnx2x_cl45_read(bp
, phy
,
5670 MDIO_PMA_DEVAD
, MDIO_PMA_REG_LASI_STATUS
, &val1
);
5672 DP(NETIF_MSG_LINK
, "8727 LASI status 0x%x\n", val1
);
5675 bnx2x_cl45_read(bp
, phy
,
5676 MDIO_PMA_DEVAD
, MDIO_PMA_REG_M8051_MSGOUT_REG
, &val1
);
5679 * If a module is present and there is need to check
5682 if (!(phy
->flags
& FLAGS_NOC
) && !(rx_alarm_status
& (1<<5))) {
5683 /* Check over-current using 8727 GPIO0 input*/
5684 bnx2x_cl45_read(bp
, phy
,
5685 MDIO_PMA_DEVAD
, MDIO_PMA_REG_8727_GPIO_CTRL
,
5688 if ((val1
& (1<<8)) == 0) {
5689 DP(NETIF_MSG_LINK
, "8727 Power fault has been detected"
5690 " on port %d\n", params
->port
);
5691 netdev_err(bp
->dev
, "Error: Power fault on Port %d has"
5692 " been detected and the power to "
5693 "that SFP+ module has been removed"
5694 " to prevent failure of the card."
5695 " Please remove the SFP+ module and"
5696 " restart the system to clear this"
5701 * Disable all RX_ALARMs except for
5704 bnx2x_cl45_write(bp
, phy
,
5706 MDIO_PMA_REG_RX_ALARM_CTRL
, (1<<5));
5708 bnx2x_cl45_read(bp
, phy
,
5710 MDIO_PMA_REG_PHY_IDENTIFIER
, &val1
);
5711 /* Wait for module_absent_event */
5713 bnx2x_cl45_write(bp
, phy
,
5715 MDIO_PMA_REG_PHY_IDENTIFIER
, val1
);
5716 /* Clear RX alarm */
5717 bnx2x_cl45_read(bp
, phy
,
5719 MDIO_PMA_REG_RX_ALARM
, &rx_alarm_status
);
5722 } /* Over current check */
5724 /* When module absent bit is set, check module */
5725 if (rx_alarm_status
& (1<<5)) {
5726 bnx2x_8727_handle_mod_abs(phy
, params
);
5727 /* Enable all mod_abs and link detection bits */
5728 bnx2x_cl45_write(bp
, phy
,
5729 MDIO_PMA_DEVAD
, MDIO_PMA_REG_RX_ALARM_CTRL
,
5732 DP(NETIF_MSG_LINK
, "Enabling 8727 TX laser if SFP is approved\n");
5733 bnx2x_8727_specific_func(phy
, params
, ENABLE_TX
);
5734 /* If transmitter is disabled, ignore false link up indication */
5735 bnx2x_cl45_read(bp
, phy
,
5736 MDIO_PMA_DEVAD
, MDIO_PMA_REG_PHY_IDENTIFIER
, &val1
);
5737 if (val1
& (1<<15)) {
5738 DP(NETIF_MSG_LINK
, "Tx is disabled\n");
5742 bnx2x_cl45_read(bp
, phy
,
5744 MDIO_PMA_REG_8073_SPEED_LINK_STATUS
, &link_status
);
5746 /* Bits 0..2 --> speed detected,
5747 bits 13..15--> link is down */
5748 if ((link_status
& (1<<2)) && (!(link_status
& (1<<15)))) {
5750 vars
->line_speed
= SPEED_10000
;
5751 } else if ((link_status
& (1<<0)) && (!(link_status
& (1<<13)))) {
5753 vars
->line_speed
= SPEED_1000
;
5754 DP(NETIF_MSG_LINK
, "port %x: External link up in 1G\n",
5758 DP(NETIF_MSG_LINK
, "port %x: External link is down\n",
5762 bnx2x_ext_phy_resolve_fc(phy
, params
, vars
);
5764 if ((DUAL_MEDIA(params
)) &&
5765 (phy
->req_line_speed
== SPEED_1000
)) {
5766 bnx2x_cl45_read(bp
, phy
,
5768 MDIO_PMA_REG_8727_PCS_GP
, &val1
);
5770 * In case of dual-media board and 1G, power up the XAUI side,
5771 * otherwise power it down. For 10G it is done automatically
5777 bnx2x_cl45_write(bp
, phy
,
5779 MDIO_PMA_REG_8727_PCS_GP
, val1
);
5784 static void bnx2x_8727_link_reset(struct bnx2x_phy
*phy
,
5785 struct link_params
*params
)
5787 struct bnx2x
*bp
= params
->bp
;
5788 /* Disable Transmitter */
5789 bnx2x_sfp_set_transmitter(bp
, phy
, params
->port
, 0);
5791 bnx2x_cl45_write(bp
, phy
, MDIO_PMA_DEVAD
, MDIO_PMA_REG_LASI_CTRL
, 0);
5795 /******************************************************************/
5796 /* BCM8481/BCM84823/BCM84833 PHY SECTION */
5797 /******************************************************************/
5798 static void bnx2x_save_848xx_spirom_version(struct bnx2x_phy
*phy
,
5799 struct link_params
*params
)
5801 u16 val
, fw_ver1
, fw_ver2
, cnt
;
5802 struct bnx2x
*bp
= params
->bp
;
5804 /* For the 32 bits registers in 848xx, access via MDIO2ARM interface.*/
5805 /* (1) set register 0xc200_0014(SPI_BRIDGE_CTRL_2) to 0x03000000 */
5806 bnx2x_cl45_write(bp
, phy
, MDIO_PMA_DEVAD
, 0xA819, 0x0014);
5807 bnx2x_cl45_write(bp
, phy
, MDIO_PMA_DEVAD
, 0xA81A, 0xc200);
5808 bnx2x_cl45_write(bp
, phy
, MDIO_PMA_DEVAD
, 0xA81B, 0x0000);
5809 bnx2x_cl45_write(bp
, phy
, MDIO_PMA_DEVAD
, 0xA81C, 0x0300);
5810 bnx2x_cl45_write(bp
, phy
, MDIO_PMA_DEVAD
, 0xA817, 0x0009);
5812 for (cnt
= 0; cnt
< 100; cnt
++) {
5813 bnx2x_cl45_read(bp
, phy
, MDIO_PMA_DEVAD
, 0xA818, &val
);
5819 DP(NETIF_MSG_LINK
, "Unable to read 848xx phy fw version(1)\n");
5820 bnx2x_save_spirom_version(bp
, params
->port
, 0,
5826 /* 2) read register 0xc200_0000 (SPI_FW_STATUS) */
5827 bnx2x_cl45_write(bp
, phy
, MDIO_PMA_DEVAD
, 0xA819, 0x0000);
5828 bnx2x_cl45_write(bp
, phy
, MDIO_PMA_DEVAD
, 0xA81A, 0xc200);
5829 bnx2x_cl45_write(bp
, phy
, MDIO_PMA_DEVAD
, 0xA817, 0x000A);
5830 for (cnt
= 0; cnt
< 100; cnt
++) {
5831 bnx2x_cl45_read(bp
, phy
, MDIO_PMA_DEVAD
, 0xA818, &val
);
5837 DP(NETIF_MSG_LINK
, "Unable to read 848xx phy fw version(2)\n");
5838 bnx2x_save_spirom_version(bp
, params
->port
, 0,
5843 /* lower 16 bits of the register SPI_FW_STATUS */
5844 bnx2x_cl45_read(bp
, phy
, MDIO_PMA_DEVAD
, 0xA81B, &fw_ver1
);
5845 /* upper 16 bits of register SPI_FW_STATUS */
5846 bnx2x_cl45_read(bp
, phy
, MDIO_PMA_DEVAD
, 0xA81C, &fw_ver2
);
5848 bnx2x_save_spirom_version(bp
, params
->port
, (fw_ver2
<<16) | fw_ver1
,
5852 static void bnx2x_848xx_set_led(struct bnx2x
*bp
,
5853 struct bnx2x_phy
*phy
)
5857 /* PHYC_CTL_LED_CTL */
5858 bnx2x_cl45_read(bp
, phy
,
5860 MDIO_PMA_REG_8481_LINK_SIGNAL
, &val
);
5864 bnx2x_cl45_write(bp
, phy
,
5866 MDIO_PMA_REG_8481_LINK_SIGNAL
, val
);
5868 bnx2x_cl45_write(bp
, phy
,
5870 MDIO_PMA_REG_8481_LED1_MASK
,
5873 bnx2x_cl45_write(bp
, phy
,
5875 MDIO_PMA_REG_8481_LED2_MASK
,
5878 bnx2x_cl45_write(bp
, phy
,
5880 MDIO_PMA_REG_8481_LED3_MASK
,
5883 /* 'Interrupt Mask' */
5884 bnx2x_cl45_write(bp
, phy
,
5889 static u8
bnx2x_848xx_cmn_config_init(struct bnx2x_phy
*phy
,
5890 struct link_params
*params
,
5891 struct link_vars
*vars
)
5893 struct bnx2x
*bp
= params
->bp
;
5894 u16 autoneg_val
, an_1000_val
, an_10_100_val
;
5896 bnx2x_bits_en(bp
, NIG_REG_LATCH_BC_0
+ params
->port
*4,
5897 1 << NIG_LATCH_BC_ENABLE_MI_INT
);
5899 bnx2x_cl45_write(bp
, phy
,
5900 MDIO_PMA_DEVAD
, MDIO_PMA_REG_CTRL
, 0x0000);
5902 bnx2x_848xx_set_led(bp
, phy
);
5904 /* set 1000 speed advertisement */
5905 bnx2x_cl45_read(bp
, phy
,
5906 MDIO_AN_DEVAD
, MDIO_AN_REG_8481_1000T_CTRL
,
5909 bnx2x_ext_phy_set_pause(params
, phy
, vars
);
5910 bnx2x_cl45_read(bp
, phy
,
5912 MDIO_AN_REG_8481_LEGACY_AN_ADV
,
5914 bnx2x_cl45_read(bp
, phy
,
5915 MDIO_AN_DEVAD
, MDIO_AN_REG_8481_LEGACY_MII_CTRL
,
5917 /* Disable forced speed */
5918 autoneg_val
&= ~((1<<6) | (1<<8) | (1<<9) | (1<<12) | (1<<13));
5919 an_10_100_val
&= ~((1<<5) | (1<<6) | (1<<7) | (1<<8));
5921 if (((phy
->req_line_speed
== SPEED_AUTO_NEG
) &&
5922 (phy
->speed_cap_mask
&
5923 PORT_HW_CFG_SPEED_CAPABILITY_D0_1G
)) ||
5924 (phy
->req_line_speed
== SPEED_1000
)) {
5925 an_1000_val
|= (1<<8);
5926 autoneg_val
|= (1<<9 | 1<<12);
5927 if (phy
->req_duplex
== DUPLEX_FULL
)
5928 an_1000_val
|= (1<<9);
5929 DP(NETIF_MSG_LINK
, "Advertising 1G\n");
5931 an_1000_val
&= ~((1<<8) | (1<<9));
5933 bnx2x_cl45_write(bp
, phy
,
5934 MDIO_AN_DEVAD
, MDIO_AN_REG_8481_1000T_CTRL
,
5937 /* set 10 speed advertisement */
5938 if (((phy
->req_line_speed
== SPEED_AUTO_NEG
) &&
5939 (phy
->speed_cap_mask
&
5940 (PORT_HW_CFG_SPEED_CAPABILITY_D0_100M_FULL
|
5941 PORT_HW_CFG_SPEED_CAPABILITY_D0_100M_HALF
)))) {
5942 an_10_100_val
|= (1<<7);
5943 /* Enable autoneg and restart autoneg for legacy speeds */
5944 autoneg_val
|= (1<<9 | 1<<12);
5946 if (phy
->req_duplex
== DUPLEX_FULL
)
5947 an_10_100_val
|= (1<<8);
5948 DP(NETIF_MSG_LINK
, "Advertising 100M\n");
5950 /* set 10 speed advertisement */
5951 if (((phy
->req_line_speed
== SPEED_AUTO_NEG
) &&
5952 (phy
->speed_cap_mask
&
5953 (PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_FULL
|
5954 PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_HALF
)))) {
5955 an_10_100_val
|= (1<<5);
5956 autoneg_val
|= (1<<9 | 1<<12);
5957 if (phy
->req_duplex
== DUPLEX_FULL
)
5958 an_10_100_val
|= (1<<6);
5959 DP(NETIF_MSG_LINK
, "Advertising 10M\n");
5962 /* Only 10/100 are allowed to work in FORCE mode */
5963 if (phy
->req_line_speed
== SPEED_100
) {
5964 autoneg_val
|= (1<<13);
5965 /* Enabled AUTO-MDIX when autoneg is disabled */
5966 bnx2x_cl45_write(bp
, phy
,
5967 MDIO_AN_DEVAD
, MDIO_AN_REG_8481_AUX_CTRL
,
5968 (1<<15 | 1<<9 | 7<<0));
5969 DP(NETIF_MSG_LINK
, "Setting 100M force\n");
5971 if (phy
->req_line_speed
== SPEED_10
) {
5972 /* Enabled AUTO-MDIX when autoneg is disabled */
5973 bnx2x_cl45_write(bp
, phy
,
5974 MDIO_AN_DEVAD
, MDIO_AN_REG_8481_AUX_CTRL
,
5975 (1<<15 | 1<<9 | 7<<0));
5976 DP(NETIF_MSG_LINK
, "Setting 10M force\n");
5979 bnx2x_cl45_write(bp
, phy
,
5980 MDIO_AN_DEVAD
, MDIO_AN_REG_8481_LEGACY_AN_ADV
,
5983 if (phy
->req_duplex
== DUPLEX_FULL
)
5984 autoneg_val
|= (1<<8);
5986 bnx2x_cl45_write(bp
, phy
,
5988 MDIO_AN_REG_8481_LEGACY_MII_CTRL
, autoneg_val
);
5990 if (((phy
->req_line_speed
== SPEED_AUTO_NEG
) &&
5991 (phy
->speed_cap_mask
&
5992 PORT_HW_CFG_SPEED_CAPABILITY_D0_10G
)) ||
5993 (phy
->req_line_speed
== SPEED_10000
)) {
5994 DP(NETIF_MSG_LINK
, "Advertising 10G\n");
5995 /* Restart autoneg for 10G*/
5997 bnx2x_cl45_write(bp
, phy
,
5998 MDIO_AN_DEVAD
, MDIO_AN_REG_CTRL
,
6000 } else if (phy
->req_line_speed
!= SPEED_10
&&
6001 phy
->req_line_speed
!= SPEED_100
) {
6002 bnx2x_cl45_write(bp
, phy
,
6004 MDIO_AN_REG_8481_10GBASE_T_AN_CTRL
,
6007 /* Save spirom version */
6008 bnx2x_save_848xx_spirom_version(phy
, params
);
6013 static u8
bnx2x_8481_config_init(struct bnx2x_phy
*phy
,
6014 struct link_params
*params
,
6015 struct link_vars
*vars
)
6017 struct bnx2x
*bp
= params
->bp
;
6018 /* Restore normal power mode*/
6019 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_2
,
6020 MISC_REGISTERS_GPIO_OUTPUT_HIGH
, params
->port
);
6023 bnx2x_ext_phy_hw_reset(bp
, params
->port
);
6024 bnx2x_wait_reset_complete(bp
, phy
);
6026 bnx2x_cl45_write(bp
, phy
, MDIO_PMA_DEVAD
, MDIO_PMA_REG_CTRL
, 1<<15);
6027 return bnx2x_848xx_cmn_config_init(phy
, params
, vars
);
6030 static u8
bnx2x_848x3_config_init(struct bnx2x_phy
*phy
,
6031 struct link_params
*params
,
6032 struct link_vars
*vars
)
6034 struct bnx2x
*bp
= params
->bp
;
6035 u8 port
, initialize
= 1;
6038 u32 actual_phy_selection
;
6041 /* This is just for MDIO_CTL_REG_84823_MEDIA register. */
6047 port
= params
->port
;
6048 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_3
,
6049 MISC_REGISTERS_GPIO_OUTPUT_HIGH
,
6051 bnx2x_wait_reset_complete(bp
, phy
);
6052 /* Wait for GPHY to come out of reset */
6054 /* BCM84823 requires that XGXS links up first @ 10G for normal
6056 temp
= vars
->line_speed
;
6057 vars
->line_speed
= SPEED_10000
;
6058 bnx2x_set_autoneg(¶ms
->phy
[INT_PHY
], params
, vars
, 0);
6059 bnx2x_program_serdes(¶ms
->phy
[INT_PHY
], params
, vars
);
6060 vars
->line_speed
= temp
;
6062 /* Set dual-media configuration according to configuration */
6064 bnx2x_cl45_read(bp
, phy
, MDIO_CTL_DEVAD
,
6065 MDIO_CTL_REG_84823_MEDIA
, &val
);
6066 val
&= ~(MDIO_CTL_REG_84823_MEDIA_MAC_MASK
|
6067 MDIO_CTL_REG_84823_MEDIA_LINE_MASK
|
6068 MDIO_CTL_REG_84823_MEDIA_COPPER_CORE_DOWN
|
6069 MDIO_CTL_REG_84823_MEDIA_PRIORITY_MASK
|
6070 MDIO_CTL_REG_84823_MEDIA_FIBER_1G
);
6071 val
|= MDIO_CTL_REG_84823_CTRL_MAC_XFI
|
6072 MDIO_CTL_REG_84823_MEDIA_LINE_XAUI_L
;
6074 actual_phy_selection
= bnx2x_phy_selection(params
);
6076 switch (actual_phy_selection
) {
6077 case PORT_HW_CFG_PHY_SELECTION_HARDWARE_DEFAULT
:
6078 /* Do nothing. Essentialy this is like the priority copper */
6080 case PORT_HW_CFG_PHY_SELECTION_FIRST_PHY_PRIORITY
:
6081 val
|= MDIO_CTL_REG_84823_MEDIA_PRIORITY_COPPER
;
6083 case PORT_HW_CFG_PHY_SELECTION_SECOND_PHY_PRIORITY
:
6084 val
|= MDIO_CTL_REG_84823_MEDIA_PRIORITY_FIBER
;
6086 case PORT_HW_CFG_PHY_SELECTION_FIRST_PHY
:
6087 /* Do nothing here. The first PHY won't be initialized at all */
6089 case PORT_HW_CFG_PHY_SELECTION_SECOND_PHY
:
6090 val
|= MDIO_CTL_REG_84823_MEDIA_COPPER_CORE_DOWN
;
6094 if (params
->phy
[EXT_PHY2
].req_line_speed
== SPEED_1000
)
6095 val
|= MDIO_CTL_REG_84823_MEDIA_FIBER_1G
;
6097 bnx2x_cl45_write(bp
, phy
, MDIO_CTL_DEVAD
,
6098 MDIO_CTL_REG_84823_MEDIA
, val
);
6099 DP(NETIF_MSG_LINK
, "Multi_phy config = 0x%x, Media control = 0x%x\n",
6100 params
->multi_phy_config
, val
);
6103 rc
= bnx2x_848xx_cmn_config_init(phy
, params
, vars
);
6105 bnx2x_save_848xx_spirom_version(phy
, params
);
6109 static u8
bnx2x_848xx_read_status(struct bnx2x_phy
*phy
,
6110 struct link_params
*params
,
6111 struct link_vars
*vars
)
6113 struct bnx2x
*bp
= params
->bp
;
6114 u16 val
, val1
, val2
;
6117 /* Check 10G-BaseT link status */
6118 /* Check PMD signal ok */
6119 bnx2x_cl45_read(bp
, phy
,
6120 MDIO_AN_DEVAD
, 0xFFFA, &val1
);
6121 bnx2x_cl45_read(bp
, phy
,
6122 MDIO_PMA_DEVAD
, MDIO_PMA_REG_8481_PMD_SIGNAL
,
6124 DP(NETIF_MSG_LINK
, "BCM848xx: PMD_SIGNAL 1.a811 = 0x%x\n", val2
);
6126 /* Check link 10G */
6127 if (val2
& (1<<11)) {
6128 vars
->line_speed
= SPEED_10000
;
6130 bnx2x_ext_phy_10G_an_resolve(bp
, phy
, vars
);
6131 } else { /* Check Legacy speed link */
6132 u16 legacy_status
, legacy_speed
;
6134 /* Enable expansion register 0x42 (Operation mode status) */
6135 bnx2x_cl45_write(bp
, phy
,
6137 MDIO_AN_REG_8481_EXPANSION_REG_ACCESS
, 0xf42);
6139 /* Get legacy speed operation status */
6140 bnx2x_cl45_read(bp
, phy
,
6142 MDIO_AN_REG_8481_EXPANSION_REG_RD_RW
,
6145 DP(NETIF_MSG_LINK
, "Legacy speed status"
6146 " = 0x%x\n", legacy_status
);
6147 link_up
= ((legacy_status
& (1<<11)) == (1<<11));
6149 legacy_speed
= (legacy_status
& (3<<9));
6150 if (legacy_speed
== (0<<9))
6151 vars
->line_speed
= SPEED_10
;
6152 else if (legacy_speed
== (1<<9))
6153 vars
->line_speed
= SPEED_100
;
6154 else if (legacy_speed
== (2<<9))
6155 vars
->line_speed
= SPEED_1000
;
6156 else /* Should not happen */
6157 vars
->line_speed
= 0;
6159 if (legacy_status
& (1<<8))
6160 vars
->duplex
= DUPLEX_FULL
;
6162 vars
->duplex
= DUPLEX_HALF
;
6164 DP(NETIF_MSG_LINK
, "Link is up in %dMbps,"
6165 " is_duplex_full= %d\n", vars
->line_speed
,
6166 (vars
->duplex
== DUPLEX_FULL
));
6167 /* Check legacy speed AN resolution */
6168 bnx2x_cl45_read(bp
, phy
,
6170 MDIO_AN_REG_8481_LEGACY_MII_STATUS
,
6173 vars
->link_status
|=
6174 LINK_STATUS_AUTO_NEGOTIATE_COMPLETE
;
6175 bnx2x_cl45_read(bp
, phy
,
6177 MDIO_AN_REG_8481_LEGACY_AN_EXPANSION
,
6179 if ((val
& (1<<0)) == 0)
6180 vars
->link_status
|=
6181 LINK_STATUS_PARALLEL_DETECTION_USED
;
6185 DP(NETIF_MSG_LINK
, "BCM84823: link speed is %d\n",
6187 bnx2x_ext_phy_resolve_fc(phy
, params
, vars
);
6193 static u8
bnx2x_848xx_format_ver(u32 raw_ver
, u8
*str
, u16
*len
)
6197 spirom_ver
= ((raw_ver
& 0xF80) >> 7) << 16 | (raw_ver
& 0x7F);
6198 status
= bnx2x_format_ver(spirom_ver
, str
, len
);
6202 static void bnx2x_8481_hw_reset(struct bnx2x_phy
*phy
,
6203 struct link_params
*params
)
6205 bnx2x_set_gpio(params
->bp
, MISC_REGISTERS_GPIO_1
,
6206 MISC_REGISTERS_GPIO_OUTPUT_LOW
, 0);
6207 bnx2x_set_gpio(params
->bp
, MISC_REGISTERS_GPIO_1
,
6208 MISC_REGISTERS_GPIO_OUTPUT_LOW
, 1);
6211 static void bnx2x_8481_link_reset(struct bnx2x_phy
*phy
,
6212 struct link_params
*params
)
6214 bnx2x_cl45_write(params
->bp
, phy
,
6215 MDIO_AN_DEVAD
, MDIO_AN_REG_CTRL
, 0x0000);
6216 bnx2x_cl45_write(params
->bp
, phy
,
6217 MDIO_PMA_DEVAD
, MDIO_PMA_REG_CTRL
, 1);
6220 static void bnx2x_848x3_link_reset(struct bnx2x_phy
*phy
,
6221 struct link_params
*params
)
6223 struct bnx2x
*bp
= params
->bp
;
6228 port
= params
->port
;
6229 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_3
,
6230 MISC_REGISTERS_GPIO_OUTPUT_LOW
,
6234 static void bnx2x_848xx_set_link_led(struct bnx2x_phy
*phy
,
6235 struct link_params
*params
, u8 mode
)
6237 struct bnx2x
*bp
= params
->bp
;
6243 DP(NETIF_MSG_LINK
, "Port 0x%x: LED MODE OFF\n", params
->port
);
6245 if ((params
->hw_led_mode
<< SHARED_HW_CFG_LED_MODE_SHIFT
) ==
6246 SHARED_HW_CFG_LED_EXTPHY1
) {
6249 bnx2x_cl45_write(bp
, phy
,
6251 MDIO_PMA_REG_8481_LED1_MASK
,
6254 bnx2x_cl45_write(bp
, phy
,
6256 MDIO_PMA_REG_8481_LED2_MASK
,
6259 bnx2x_cl45_write(bp
, phy
,
6261 MDIO_PMA_REG_8481_LED3_MASK
,
6264 bnx2x_cl45_write(bp
, phy
,
6266 MDIO_PMA_REG_8481_LED5_MASK
,
6270 bnx2x_cl45_write(bp
, phy
,
6272 MDIO_PMA_REG_8481_LED1_MASK
,
6276 case LED_MODE_FRONT_PANEL_OFF
:
6278 DP(NETIF_MSG_LINK
, "Port 0x%x: LED MODE FRONT PANEL OFF\n",
6281 if ((params
->hw_led_mode
<< SHARED_HW_CFG_LED_MODE_SHIFT
) ==
6282 SHARED_HW_CFG_LED_EXTPHY1
) {
6285 bnx2x_cl45_write(bp
, phy
,
6287 MDIO_PMA_REG_8481_LED1_MASK
,
6290 bnx2x_cl45_write(bp
, phy
,
6292 MDIO_PMA_REG_8481_LED2_MASK
,
6295 bnx2x_cl45_write(bp
, phy
,
6297 MDIO_PMA_REG_8481_LED3_MASK
,
6300 bnx2x_cl45_write(bp
, phy
,
6302 MDIO_PMA_REG_8481_LED5_MASK
,
6306 bnx2x_cl45_write(bp
, phy
,
6308 MDIO_PMA_REG_8481_LED1_MASK
,
6314 DP(NETIF_MSG_LINK
, "Port 0x%x: LED MODE ON\n", params
->port
);
6316 if ((params
->hw_led_mode
<< SHARED_HW_CFG_LED_MODE_SHIFT
) ==
6317 SHARED_HW_CFG_LED_EXTPHY1
) {
6318 /* Set control reg */
6319 bnx2x_cl45_read(bp
, phy
,
6321 MDIO_PMA_REG_8481_LINK_SIGNAL
,
6326 bnx2x_cl45_write(bp
, phy
,
6328 MDIO_PMA_REG_8481_LINK_SIGNAL
,
6332 bnx2x_cl45_write(bp
, phy
,
6334 MDIO_PMA_REG_8481_LED1_MASK
,
6337 bnx2x_cl45_write(bp
, phy
,
6339 MDIO_PMA_REG_8481_LED2_MASK
,
6342 bnx2x_cl45_write(bp
, phy
,
6344 MDIO_PMA_REG_8481_LED3_MASK
,
6347 bnx2x_cl45_write(bp
, phy
,
6349 MDIO_PMA_REG_8481_LED5_MASK
,
6352 bnx2x_cl45_write(bp
, phy
,
6354 MDIO_PMA_REG_8481_LED1_MASK
,
6361 DP(NETIF_MSG_LINK
, "Port 0x%x: LED MODE OPER\n", params
->port
);
6363 if ((params
->hw_led_mode
<< SHARED_HW_CFG_LED_MODE_SHIFT
) ==
6364 SHARED_HW_CFG_LED_EXTPHY1
) {
6366 /* Set control reg */
6367 bnx2x_cl45_read(bp
, phy
,
6369 MDIO_PMA_REG_8481_LINK_SIGNAL
,
6373 MDIO_PMA_REG_8481_LINK_SIGNAL_LED4_ENABLE_MASK
)
6374 >> MDIO_PMA_REG_8481_LINK_SIGNAL_LED4_ENABLE_SHIFT
)){
6375 DP(NETIF_MSG_LINK
, "Seting LINK_SIGNAL\n");
6376 bnx2x_cl45_write(bp
, phy
,
6378 MDIO_PMA_REG_8481_LINK_SIGNAL
,
6383 bnx2x_cl45_write(bp
, phy
,
6385 MDIO_PMA_REG_8481_LED1_MASK
,
6388 bnx2x_cl45_write(bp
, phy
,
6390 MDIO_PMA_REG_8481_LED2_MASK
,
6393 bnx2x_cl45_write(bp
, phy
,
6395 MDIO_PMA_REG_8481_LED3_MASK
,
6398 bnx2x_cl45_write(bp
, phy
,
6400 MDIO_PMA_REG_8481_LED5_MASK
,
6404 bnx2x_cl45_write(bp
, phy
,
6406 MDIO_PMA_REG_8481_LED1_MASK
,
6412 /******************************************************************/
6413 /* SFX7101 PHY SECTION */
6414 /******************************************************************/
6415 static void bnx2x_7101_config_loopback(struct bnx2x_phy
*phy
,
6416 struct link_params
*params
)
6418 struct bnx2x
*bp
= params
->bp
;
6419 /* SFX7101_XGXS_TEST1 */
6420 bnx2x_cl45_write(bp
, phy
,
6421 MDIO_XS_DEVAD
, MDIO_XS_SFX7101_XGXS_TEST1
, 0x100);
6424 static u8
bnx2x_7101_config_init(struct bnx2x_phy
*phy
,
6425 struct link_params
*params
,
6426 struct link_vars
*vars
)
6428 u16 fw_ver1
, fw_ver2
, val
;
6429 struct bnx2x
*bp
= params
->bp
;
6430 DP(NETIF_MSG_LINK
, "Setting the SFX7101 LASI indication\n");
6432 /* Restore normal power mode*/
6433 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_2
,
6434 MISC_REGISTERS_GPIO_OUTPUT_HIGH
, params
->port
);
6436 bnx2x_ext_phy_hw_reset(bp
, params
->port
);
6437 bnx2x_wait_reset_complete(bp
, phy
);
6439 bnx2x_cl45_write(bp
, phy
,
6440 MDIO_PMA_DEVAD
, MDIO_PMA_REG_LASI_CTRL
, 0x1);
6441 DP(NETIF_MSG_LINK
, "Setting the SFX7101 LED to blink on traffic\n");
6442 bnx2x_cl45_write(bp
, phy
,
6443 MDIO_PMA_DEVAD
, MDIO_PMA_REG_7107_LED_CNTL
, (1<<3));
6445 bnx2x_ext_phy_set_pause(params
, phy
, vars
);
6446 /* Restart autoneg */
6447 bnx2x_cl45_read(bp
, phy
,
6448 MDIO_AN_DEVAD
, MDIO_AN_REG_CTRL
, &val
);
6450 bnx2x_cl45_write(bp
, phy
,
6451 MDIO_AN_DEVAD
, MDIO_AN_REG_CTRL
, val
);
6453 /* Save spirom version */
6454 bnx2x_cl45_read(bp
, phy
,
6455 MDIO_PMA_DEVAD
, MDIO_PMA_REG_7101_VER1
, &fw_ver1
);
6457 bnx2x_cl45_read(bp
, phy
,
6458 MDIO_PMA_DEVAD
, MDIO_PMA_REG_7101_VER2
, &fw_ver2
);
6459 bnx2x_save_spirom_version(bp
, params
->port
,
6460 (u32
)(fw_ver1
<<16 | fw_ver2
), phy
->ver_addr
);
6464 static u8
bnx2x_7101_read_status(struct bnx2x_phy
*phy
,
6465 struct link_params
*params
,
6466 struct link_vars
*vars
)
6468 struct bnx2x
*bp
= params
->bp
;
6471 bnx2x_cl45_read(bp
, phy
,
6472 MDIO_PMA_DEVAD
, MDIO_PMA_REG_LASI_STATUS
, &val2
);
6473 bnx2x_cl45_read(bp
, phy
,
6474 MDIO_PMA_DEVAD
, MDIO_PMA_REG_LASI_STATUS
, &val1
);
6475 DP(NETIF_MSG_LINK
, "10G-base-T LASI status 0x%x->0x%x\n",
6477 bnx2x_cl45_read(bp
, phy
,
6478 MDIO_PMA_DEVAD
, MDIO_PMA_REG_STATUS
, &val2
);
6479 bnx2x_cl45_read(bp
, phy
,
6480 MDIO_PMA_DEVAD
, MDIO_PMA_REG_STATUS
, &val1
);
6481 DP(NETIF_MSG_LINK
, "10G-base-T PMA status 0x%x->0x%x\n",
6483 link_up
= ((val1
& 4) == 4);
6485 * print the AN outcome of the SFX7101 PHY
6488 bnx2x_cl45_read(bp
, phy
,
6489 MDIO_AN_DEVAD
, MDIO_AN_REG_MASTER_STATUS
,
6491 vars
->line_speed
= SPEED_10000
;
6492 DP(NETIF_MSG_LINK
, "SFX7101 AN status 0x%x->Master=%x\n",
6493 val2
, (val2
& (1<<14)));
6494 bnx2x_ext_phy_10G_an_resolve(bp
, phy
, vars
);
6495 bnx2x_ext_phy_resolve_fc(phy
, params
, vars
);
6501 static u8
bnx2x_7101_format_ver(u32 spirom_ver
, u8
*str
, u16
*len
)
6505 str
[0] = (spirom_ver
& 0xFF);
6506 str
[1] = (spirom_ver
& 0xFF00) >> 8;
6507 str
[2] = (spirom_ver
& 0xFF0000) >> 16;
6508 str
[3] = (spirom_ver
& 0xFF000000) >> 24;
6514 void bnx2x_sfx7101_sp_sw_reset(struct bnx2x
*bp
, struct bnx2x_phy
*phy
)
6518 bnx2x_cl45_read(bp
, phy
,
6520 MDIO_PMA_REG_7101_RESET
, &val
);
6522 for (cnt
= 0; cnt
< 10; cnt
++) {
6524 /* Writes a self-clearing reset */
6525 bnx2x_cl45_write(bp
, phy
,
6527 MDIO_PMA_REG_7101_RESET
,
6529 /* Wait for clear */
6530 bnx2x_cl45_read(bp
, phy
,
6532 MDIO_PMA_REG_7101_RESET
, &val
);
6534 if ((val
& (1<<15)) == 0)
6539 static void bnx2x_7101_hw_reset(struct bnx2x_phy
*phy
,
6540 struct link_params
*params
) {
6541 /* Low power mode is controlled by GPIO 2 */
6542 bnx2x_set_gpio(params
->bp
, MISC_REGISTERS_GPIO_2
,
6543 MISC_REGISTERS_GPIO_OUTPUT_LOW
, params
->port
);
6544 /* The PHY reset is controlled by GPIO 1 */
6545 bnx2x_set_gpio(params
->bp
, MISC_REGISTERS_GPIO_1
,
6546 MISC_REGISTERS_GPIO_OUTPUT_LOW
, params
->port
);
6549 static void bnx2x_7101_set_link_led(struct bnx2x_phy
*phy
,
6550 struct link_params
*params
, u8 mode
)
6553 struct bnx2x
*bp
= params
->bp
;
6555 case LED_MODE_FRONT_PANEL_OFF
:
6566 bnx2x_cl45_write(bp
, phy
,
6568 MDIO_PMA_REG_7107_LINK_LED_CNTL
,
6572 /******************************************************************/
6573 /* STATIC PHY DECLARATION */
6574 /******************************************************************/
6576 static struct bnx2x_phy phy_null
= {
6577 .type
= PORT_HW_CFG_XGXS_EXT_PHY_TYPE_NOT_CONN
,
6579 .flags
= FLAGS_INIT_XGXS_FIRST
,
6582 .rx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
6583 .tx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
6586 .media_type
= ETH_PHY_NOT_PRESENT
,
6589 .req_line_speed
= 0,
6590 .speed_cap_mask
= 0,
6593 .config_init
= (config_init_t
)NULL
,
6594 .read_status
= (read_status_t
)NULL
,
6595 .link_reset
= (link_reset_t
)NULL
,
6596 .config_loopback
= (config_loopback_t
)NULL
,
6597 .format_fw_ver
= (format_fw_ver_t
)NULL
,
6598 .hw_reset
= (hw_reset_t
)NULL
,
6599 .set_link_led
= (set_link_led_t
)NULL
,
6600 .phy_specific_func
= (phy_specific_func_t
)NULL
6603 static struct bnx2x_phy phy_serdes
= {
6604 .type
= PORT_HW_CFG_SERDES_EXT_PHY_TYPE_DIRECT
,
6609 .rx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
6610 .tx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
6612 .supported
= (SUPPORTED_10baseT_Half
|
6613 SUPPORTED_10baseT_Full
|
6614 SUPPORTED_100baseT_Half
|
6615 SUPPORTED_100baseT_Full
|
6616 SUPPORTED_1000baseT_Full
|
6617 SUPPORTED_2500baseX_Full
|
6621 SUPPORTED_Asym_Pause
),
6622 .media_type
= ETH_PHY_UNSPECIFIED
,
6625 .req_line_speed
= 0,
6626 .speed_cap_mask
= 0,
6629 .config_init
= (config_init_t
)bnx2x_init_serdes
,
6630 .read_status
= (read_status_t
)bnx2x_link_settings_status
,
6631 .link_reset
= (link_reset_t
)bnx2x_int_link_reset
,
6632 .config_loopback
= (config_loopback_t
)NULL
,
6633 .format_fw_ver
= (format_fw_ver_t
)NULL
,
6634 .hw_reset
= (hw_reset_t
)NULL
,
6635 .set_link_led
= (set_link_led_t
)NULL
,
6636 .phy_specific_func
= (phy_specific_func_t
)NULL
6639 static struct bnx2x_phy phy_xgxs
= {
6640 .type
= PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT
,
6645 .rx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
6646 .tx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
6648 .supported
= (SUPPORTED_10baseT_Half
|
6649 SUPPORTED_10baseT_Full
|
6650 SUPPORTED_100baseT_Half
|
6651 SUPPORTED_100baseT_Full
|
6652 SUPPORTED_1000baseT_Full
|
6653 SUPPORTED_2500baseX_Full
|
6654 SUPPORTED_10000baseT_Full
|
6658 SUPPORTED_Asym_Pause
),
6659 .media_type
= ETH_PHY_UNSPECIFIED
,
6662 .req_line_speed
= 0,
6663 .speed_cap_mask
= 0,
6666 .config_init
= (config_init_t
)bnx2x_init_xgxs
,
6667 .read_status
= (read_status_t
)bnx2x_link_settings_status
,
6668 .link_reset
= (link_reset_t
)bnx2x_int_link_reset
,
6669 .config_loopback
= (config_loopback_t
)bnx2x_set_xgxs_loopback
,
6670 .format_fw_ver
= (format_fw_ver_t
)NULL
,
6671 .hw_reset
= (hw_reset_t
)NULL
,
6672 .set_link_led
= (set_link_led_t
)NULL
,
6673 .phy_specific_func
= (phy_specific_func_t
)NULL
6676 static struct bnx2x_phy phy_7101
= {
6677 .type
= PORT_HW_CFG_XGXS_EXT_PHY_TYPE_SFX7101
,
6679 .flags
= FLAGS_FAN_FAILURE_DET_REQ
,
6682 .rx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
6683 .tx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
6685 .supported
= (SUPPORTED_10000baseT_Full
|
6689 SUPPORTED_Asym_Pause
),
6690 .media_type
= ETH_PHY_BASE_T
,
6693 .req_line_speed
= 0,
6694 .speed_cap_mask
= 0,
6697 .config_init
= (config_init_t
)bnx2x_7101_config_init
,
6698 .read_status
= (read_status_t
)bnx2x_7101_read_status
,
6699 .link_reset
= (link_reset_t
)bnx2x_common_ext_link_reset
,
6700 .config_loopback
= (config_loopback_t
)bnx2x_7101_config_loopback
,
6701 .format_fw_ver
= (format_fw_ver_t
)bnx2x_7101_format_ver
,
6702 .hw_reset
= (hw_reset_t
)bnx2x_7101_hw_reset
,
6703 .set_link_led
= (set_link_led_t
)bnx2x_7101_set_link_led
,
6704 .phy_specific_func
= (phy_specific_func_t
)NULL
6706 static struct bnx2x_phy phy_8073
= {
6707 .type
= PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073
,
6709 .flags
= FLAGS_HW_LOCK_REQUIRED
,
6712 .rx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
6713 .tx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
6715 .supported
= (SUPPORTED_10000baseT_Full
|
6716 SUPPORTED_2500baseX_Full
|
6717 SUPPORTED_1000baseT_Full
|
6721 SUPPORTED_Asym_Pause
),
6722 .media_type
= ETH_PHY_UNSPECIFIED
,
6725 .req_line_speed
= 0,
6726 .speed_cap_mask
= 0,
6729 .config_init
= (config_init_t
)bnx2x_8073_config_init
,
6730 .read_status
= (read_status_t
)bnx2x_8073_read_status
,
6731 .link_reset
= (link_reset_t
)bnx2x_8073_link_reset
,
6732 .config_loopback
= (config_loopback_t
)NULL
,
6733 .format_fw_ver
= (format_fw_ver_t
)bnx2x_format_ver
,
6734 .hw_reset
= (hw_reset_t
)NULL
,
6735 .set_link_led
= (set_link_led_t
)NULL
,
6736 .phy_specific_func
= (phy_specific_func_t
)NULL
6738 static struct bnx2x_phy phy_8705
= {
6739 .type
= PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8705
,
6741 .flags
= FLAGS_INIT_XGXS_FIRST
,
6744 .rx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
6745 .tx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
6747 .supported
= (SUPPORTED_10000baseT_Full
|
6750 SUPPORTED_Asym_Pause
),
6751 .media_type
= ETH_PHY_XFP_FIBER
,
6754 .req_line_speed
= 0,
6755 .speed_cap_mask
= 0,
6758 .config_init
= (config_init_t
)bnx2x_8705_config_init
,
6759 .read_status
= (read_status_t
)bnx2x_8705_read_status
,
6760 .link_reset
= (link_reset_t
)bnx2x_common_ext_link_reset
,
6761 .config_loopback
= (config_loopback_t
)NULL
,
6762 .format_fw_ver
= (format_fw_ver_t
)bnx2x_null_format_ver
,
6763 .hw_reset
= (hw_reset_t
)NULL
,
6764 .set_link_led
= (set_link_led_t
)NULL
,
6765 .phy_specific_func
= (phy_specific_func_t
)NULL
6767 static struct bnx2x_phy phy_8706
= {
6768 .type
= PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8706
,
6770 .flags
= FLAGS_INIT_XGXS_FIRST
,
6773 .rx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
6774 .tx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
6776 .supported
= (SUPPORTED_10000baseT_Full
|
6777 SUPPORTED_1000baseT_Full
|
6780 SUPPORTED_Asym_Pause
),
6781 .media_type
= ETH_PHY_SFP_FIBER
,
6784 .req_line_speed
= 0,
6785 .speed_cap_mask
= 0,
6788 .config_init
= (config_init_t
)bnx2x_8706_config_init
,
6789 .read_status
= (read_status_t
)bnx2x_8706_read_status
,
6790 .link_reset
= (link_reset_t
)bnx2x_common_ext_link_reset
,
6791 .config_loopback
= (config_loopback_t
)NULL
,
6792 .format_fw_ver
= (format_fw_ver_t
)bnx2x_format_ver
,
6793 .hw_reset
= (hw_reset_t
)NULL
,
6794 .set_link_led
= (set_link_led_t
)NULL
,
6795 .phy_specific_func
= (phy_specific_func_t
)NULL
6798 static struct bnx2x_phy phy_8726
= {
6799 .type
= PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726
,
6801 .flags
= (FLAGS_HW_LOCK_REQUIRED
|
6802 FLAGS_INIT_XGXS_FIRST
),
6805 .rx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
6806 .tx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
6808 .supported
= (SUPPORTED_10000baseT_Full
|
6809 SUPPORTED_1000baseT_Full
|
6813 SUPPORTED_Asym_Pause
),
6814 .media_type
= ETH_PHY_SFP_FIBER
,
6817 .req_line_speed
= 0,
6818 .speed_cap_mask
= 0,
6821 .config_init
= (config_init_t
)bnx2x_8726_config_init
,
6822 .read_status
= (read_status_t
)bnx2x_8726_read_status
,
6823 .link_reset
= (link_reset_t
)bnx2x_8726_link_reset
,
6824 .config_loopback
= (config_loopback_t
)bnx2x_8726_config_loopback
,
6825 .format_fw_ver
= (format_fw_ver_t
)bnx2x_format_ver
,
6826 .hw_reset
= (hw_reset_t
)NULL
,
6827 .set_link_led
= (set_link_led_t
)NULL
,
6828 .phy_specific_func
= (phy_specific_func_t
)NULL
6831 static struct bnx2x_phy phy_8727
= {
6832 .type
= PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727
,
6834 .flags
= FLAGS_FAN_FAILURE_DET_REQ
,
6837 .rx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
6838 .tx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
6840 .supported
= (SUPPORTED_10000baseT_Full
|
6841 SUPPORTED_1000baseT_Full
|
6844 SUPPORTED_Asym_Pause
),
6845 .media_type
= ETH_PHY_SFP_FIBER
,
6848 .req_line_speed
= 0,
6849 .speed_cap_mask
= 0,
6852 .config_init
= (config_init_t
)bnx2x_8727_config_init
,
6853 .read_status
= (read_status_t
)bnx2x_8727_read_status
,
6854 .link_reset
= (link_reset_t
)bnx2x_8727_link_reset
,
6855 .config_loopback
= (config_loopback_t
)NULL
,
6856 .format_fw_ver
= (format_fw_ver_t
)bnx2x_format_ver
,
6857 .hw_reset
= (hw_reset_t
)bnx2x_8727_hw_reset
,
6858 .set_link_led
= (set_link_led_t
)bnx2x_8727_set_link_led
,
6859 .phy_specific_func
= (phy_specific_func_t
)bnx2x_8727_specific_func
6861 static struct bnx2x_phy phy_8481
= {
6862 .type
= PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8481
,
6864 .flags
= FLAGS_FAN_FAILURE_DET_REQ
|
6865 FLAGS_REARM_LATCH_SIGNAL
,
6868 .rx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
6869 .tx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
6871 .supported
= (SUPPORTED_10baseT_Half
|
6872 SUPPORTED_10baseT_Full
|
6873 SUPPORTED_100baseT_Half
|
6874 SUPPORTED_100baseT_Full
|
6875 SUPPORTED_1000baseT_Full
|
6876 SUPPORTED_10000baseT_Full
|
6880 SUPPORTED_Asym_Pause
),
6881 .media_type
= ETH_PHY_BASE_T
,
6884 .req_line_speed
= 0,
6885 .speed_cap_mask
= 0,
6888 .config_init
= (config_init_t
)bnx2x_8481_config_init
,
6889 .read_status
= (read_status_t
)bnx2x_848xx_read_status
,
6890 .link_reset
= (link_reset_t
)bnx2x_8481_link_reset
,
6891 .config_loopback
= (config_loopback_t
)NULL
,
6892 .format_fw_ver
= (format_fw_ver_t
)bnx2x_848xx_format_ver
,
6893 .hw_reset
= (hw_reset_t
)bnx2x_8481_hw_reset
,
6894 .set_link_led
= (set_link_led_t
)bnx2x_848xx_set_link_led
,
6895 .phy_specific_func
= (phy_specific_func_t
)NULL
6898 static struct bnx2x_phy phy_84823
= {
6899 .type
= PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84823
,
6901 .flags
= FLAGS_FAN_FAILURE_DET_REQ
|
6902 FLAGS_REARM_LATCH_SIGNAL
,
6905 .rx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
6906 .tx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
6908 .supported
= (SUPPORTED_10baseT_Half
|
6909 SUPPORTED_10baseT_Full
|
6910 SUPPORTED_100baseT_Half
|
6911 SUPPORTED_100baseT_Full
|
6912 SUPPORTED_1000baseT_Full
|
6913 SUPPORTED_10000baseT_Full
|
6917 SUPPORTED_Asym_Pause
),
6918 .media_type
= ETH_PHY_BASE_T
,
6921 .req_line_speed
= 0,
6922 .speed_cap_mask
= 0,
6925 .config_init
= (config_init_t
)bnx2x_848x3_config_init
,
6926 .read_status
= (read_status_t
)bnx2x_848xx_read_status
,
6927 .link_reset
= (link_reset_t
)bnx2x_848x3_link_reset
,
6928 .config_loopback
= (config_loopback_t
)NULL
,
6929 .format_fw_ver
= (format_fw_ver_t
)bnx2x_848xx_format_ver
,
6930 .hw_reset
= (hw_reset_t
)NULL
,
6931 .set_link_led
= (set_link_led_t
)bnx2x_848xx_set_link_led
,
6932 .phy_specific_func
= (phy_specific_func_t
)NULL
6935 /*****************************************************************/
6937 /* Populate the phy according. Main function: bnx2x_populate_phy */
6939 /*****************************************************************/
6941 static void bnx2x_populate_preemphasis(struct bnx2x
*bp
, u32 shmem_base
,
6942 struct bnx2x_phy
*phy
, u8 port
,
6945 /* Get the 4 lanes xgxs config rx and tx */
6946 u32 rx
= 0, tx
= 0, i
;
6947 for (i
= 0; i
< 2; i
++) {
6949 * INT_PHY and EXT_PHY1 share the same value location in the
6950 * shmem. When num_phys is greater than 1, than this value
6951 * applies only to EXT_PHY1
6953 if (phy_index
== INT_PHY
|| phy_index
== EXT_PHY1
) {
6954 rx
= REG_RD(bp
, shmem_base
+
6955 offsetof(struct shmem_region
,
6956 dev_info
.port_hw_config
[port
].xgxs_config_rx
[i
<<1]));
6958 tx
= REG_RD(bp
, shmem_base
+
6959 offsetof(struct shmem_region
,
6960 dev_info
.port_hw_config
[port
].xgxs_config_tx
[i
<<1]));
6962 rx
= REG_RD(bp
, shmem_base
+
6963 offsetof(struct shmem_region
,
6964 dev_info
.port_hw_config
[port
].xgxs_config2_rx
[i
<<1]));
6966 tx
= REG_RD(bp
, shmem_base
+
6967 offsetof(struct shmem_region
,
6968 dev_info
.port_hw_config
[port
].xgxs_config2_rx
[i
<<1]));
6971 phy
->rx_preemphasis
[i
<< 1] = ((rx
>>16) & 0xffff);
6972 phy
->rx_preemphasis
[(i
<< 1) + 1] = (rx
& 0xffff);
6974 phy
->tx_preemphasis
[i
<< 1] = ((tx
>>16) & 0xffff);
6975 phy
->tx_preemphasis
[(i
<< 1) + 1] = (tx
& 0xffff);
6979 static u32
bnx2x_get_ext_phy_config(struct bnx2x
*bp
, u32 shmem_base
,
6980 u8 phy_index
, u8 port
)
6982 u32 ext_phy_config
= 0;
6983 switch (phy_index
) {
6985 ext_phy_config
= REG_RD(bp
, shmem_base
+
6986 offsetof(struct shmem_region
,
6987 dev_info
.port_hw_config
[port
].external_phy_config
));
6990 ext_phy_config
= REG_RD(bp
, shmem_base
+
6991 offsetof(struct shmem_region
,
6992 dev_info
.port_hw_config
[port
].external_phy_config2
));
6995 DP(NETIF_MSG_LINK
, "Invalid phy_index %d\n", phy_index
);
6999 return ext_phy_config
;
7001 static u8
bnx2x_populate_int_phy(struct bnx2x
*bp
, u32 shmem_base
, u8 port
,
7002 struct bnx2x_phy
*phy
)
7006 u32 switch_cfg
= (REG_RD(bp
, shmem_base
+
7007 offsetof(struct shmem_region
,
7008 dev_info
.port_feature_config
[port
].link_config
)) &
7009 PORT_FEATURE_CONNECTED_SWITCH_MASK
);
7010 chip_id
= REG_RD(bp
, MISC_REG_CHIP_NUM
) << 16;
7011 switch (switch_cfg
) {
7013 phy_addr
= REG_RD(bp
,
7014 NIG_REG_SERDES0_CTRL_PHY_ADDR
+
7018 case SWITCH_CFG_10G
:
7019 phy_addr
= REG_RD(bp
,
7020 NIG_REG_XGXS0_CTRL_PHY_ADDR
+
7025 DP(NETIF_MSG_LINK
, "Invalid switch_cfg\n");
7028 phy
->addr
= (u8
)phy_addr
;
7029 phy
->mdio_ctrl
= bnx2x_get_emac_base(bp
,
7030 SHARED_HW_CFG_MDC_MDIO_ACCESS1_BOTH
,
7033 phy
->def_md_devad
= E2_DEFAULT_PHY_DEV_ADDR
;
7035 phy
->def_md_devad
= DEFAULT_PHY_DEV_ADDR
;
7037 DP(NETIF_MSG_LINK
, "Internal phy port=%d, addr=0x%x, mdio_ctl=0x%x\n",
7038 port
, phy
->addr
, phy
->mdio_ctrl
);
7040 bnx2x_populate_preemphasis(bp
, shmem_base
, phy
, port
, INT_PHY
);
7044 static u8
bnx2x_populate_ext_phy(struct bnx2x
*bp
,
7049 struct bnx2x_phy
*phy
)
7051 u32 ext_phy_config
, phy_type
, config2
;
7052 u32 mdc_mdio_access
= SHARED_HW_CFG_MDC_MDIO_ACCESS1_BOTH
;
7053 ext_phy_config
= bnx2x_get_ext_phy_config(bp
, shmem_base
,
7055 phy_type
= XGXS_EXT_PHY_TYPE(ext_phy_config
);
7056 /* Select the phy type */
7058 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073
:
7059 mdc_mdio_access
= SHARED_HW_CFG_MDC_MDIO_ACCESS1_SWAPPED
;
7062 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8705
:
7065 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8706
:
7068 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726
:
7069 mdc_mdio_access
= SHARED_HW_CFG_MDC_MDIO_ACCESS1_EMAC1
;
7072 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727_NOC
:
7073 /* BCM8727_NOC => BCM8727 no over current */
7074 mdc_mdio_access
= SHARED_HW_CFG_MDC_MDIO_ACCESS1_EMAC1
;
7076 phy
->flags
|= FLAGS_NOC
;
7078 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727
:
7079 mdc_mdio_access
= SHARED_HW_CFG_MDC_MDIO_ACCESS1_EMAC1
;
7082 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8481
:
7085 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84823
:
7088 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_SFX7101
:
7091 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_FAILURE
:
7099 phy
->addr
= XGXS_EXT_PHY_ADDR(ext_phy_config
);
7100 bnx2x_populate_preemphasis(bp
, shmem_base
, phy
, port
, phy_index
);
7103 * The shmem address of the phy version is located on different
7104 * structures. In case this structure is too old, do not set
7107 config2
= REG_RD(bp
, shmem_base
+ offsetof(struct shmem_region
,
7108 dev_info
.shared_hw_config
.config2
));
7109 if (phy_index
== EXT_PHY1
) {
7110 phy
->ver_addr
= shmem_base
+ offsetof(struct shmem_region
,
7111 port_mb
[port
].ext_phy_fw_version
);
7113 /* Check specific mdc mdio settings */
7114 if (config2
& SHARED_HW_CFG_MDC_MDIO_ACCESS1_MASK
)
7115 mdc_mdio_access
= config2
&
7116 SHARED_HW_CFG_MDC_MDIO_ACCESS1_MASK
;
7118 u32 size
= REG_RD(bp
, shmem2_base
);
7121 offsetof(struct shmem2_region
, ext_phy_fw_version2
)) {
7122 phy
->ver_addr
= shmem2_base
+
7123 offsetof(struct shmem2_region
,
7124 ext_phy_fw_version2
[port
]);
7126 /* Check specific mdc mdio settings */
7127 if (config2
& SHARED_HW_CFG_MDC_MDIO_ACCESS2_MASK
)
7128 mdc_mdio_access
= (config2
&
7129 SHARED_HW_CFG_MDC_MDIO_ACCESS2_MASK
) >>
7130 (SHARED_HW_CFG_MDC_MDIO_ACCESS2_SHIFT
-
7131 SHARED_HW_CFG_MDC_MDIO_ACCESS1_SHIFT
);
7133 phy
->mdio_ctrl
= bnx2x_get_emac_base(bp
, mdc_mdio_access
, port
);
7136 * In case mdc/mdio_access of the external phy is different than the
7137 * mdc/mdio access of the XGXS, a HW lock must be taken in each access
7138 * to prevent one port interfere with another port's CL45 operations.
7140 if (mdc_mdio_access
!= SHARED_HW_CFG_MDC_MDIO_ACCESS1_BOTH
)
7141 phy
->flags
|= FLAGS_HW_LOCK_REQUIRED
;
7142 DP(NETIF_MSG_LINK
, "phy_type 0x%x port %d found in index %d\n",
7143 phy_type
, port
, phy_index
);
7144 DP(NETIF_MSG_LINK
, " addr=0x%x, mdio_ctl=0x%x\n",
7145 phy
->addr
, phy
->mdio_ctrl
);
7149 static u8
bnx2x_populate_phy(struct bnx2x
*bp
, u8 phy_index
, u32 shmem_base
,
7150 u32 shmem2_base
, u8 port
, struct bnx2x_phy
*phy
)
7153 phy
->type
= PORT_HW_CFG_XGXS_EXT_PHY_TYPE_NOT_CONN
;
7154 if (phy_index
== INT_PHY
)
7155 return bnx2x_populate_int_phy(bp
, shmem_base
, port
, phy
);
7156 status
= bnx2x_populate_ext_phy(bp
, phy_index
, shmem_base
, shmem2_base
,
7161 static void bnx2x_phy_def_cfg(struct link_params
*params
,
7162 struct bnx2x_phy
*phy
,
7165 struct bnx2x
*bp
= params
->bp
;
7167 /* Populate the default phy configuration for MF mode */
7168 if (phy_index
== EXT_PHY2
) {
7169 link_config
= REG_RD(bp
, params
->shmem_base
+
7170 offsetof(struct shmem_region
, dev_info
.
7171 port_feature_config
[params
->port
].link_config2
));
7172 phy
->speed_cap_mask
= REG_RD(bp
, params
->shmem_base
+
7173 offsetof(struct shmem_region
, dev_info
.
7174 port_hw_config
[params
->port
].speed_capability_mask2
));
7176 link_config
= REG_RD(bp
, params
->shmem_base
+
7177 offsetof(struct shmem_region
, dev_info
.
7178 port_feature_config
[params
->port
].link_config
));
7179 phy
->speed_cap_mask
= REG_RD(bp
, params
->shmem_base
+
7180 offsetof(struct shmem_region
, dev_info
.
7181 port_hw_config
[params
->port
].speed_capability_mask
));
7183 DP(NETIF_MSG_LINK
, "Default config phy idx %x cfg 0x%x speed_cap_mask"
7184 " 0x%x\n", phy_index
, link_config
, phy
->speed_cap_mask
);
7186 phy
->req_duplex
= DUPLEX_FULL
;
7187 switch (link_config
& PORT_FEATURE_LINK_SPEED_MASK
) {
7188 case PORT_FEATURE_LINK_SPEED_10M_HALF
:
7189 phy
->req_duplex
= DUPLEX_HALF
;
7190 case PORT_FEATURE_LINK_SPEED_10M_FULL
:
7191 phy
->req_line_speed
= SPEED_10
;
7193 case PORT_FEATURE_LINK_SPEED_100M_HALF
:
7194 phy
->req_duplex
= DUPLEX_HALF
;
7195 case PORT_FEATURE_LINK_SPEED_100M_FULL
:
7196 phy
->req_line_speed
= SPEED_100
;
7198 case PORT_FEATURE_LINK_SPEED_1G
:
7199 phy
->req_line_speed
= SPEED_1000
;
7201 case PORT_FEATURE_LINK_SPEED_2_5G
:
7202 phy
->req_line_speed
= SPEED_2500
;
7204 case PORT_FEATURE_LINK_SPEED_10G_CX4
:
7205 phy
->req_line_speed
= SPEED_10000
;
7208 phy
->req_line_speed
= SPEED_AUTO_NEG
;
7212 switch (link_config
& PORT_FEATURE_FLOW_CONTROL_MASK
) {
7213 case PORT_FEATURE_FLOW_CONTROL_AUTO
:
7214 phy
->req_flow_ctrl
= BNX2X_FLOW_CTRL_AUTO
;
7216 case PORT_FEATURE_FLOW_CONTROL_TX
:
7217 phy
->req_flow_ctrl
= BNX2X_FLOW_CTRL_TX
;
7219 case PORT_FEATURE_FLOW_CONTROL_RX
:
7220 phy
->req_flow_ctrl
= BNX2X_FLOW_CTRL_RX
;
7222 case PORT_FEATURE_FLOW_CONTROL_BOTH
:
7223 phy
->req_flow_ctrl
= BNX2X_FLOW_CTRL_BOTH
;
7226 phy
->req_flow_ctrl
= BNX2X_FLOW_CTRL_NONE
;
7231 u32
bnx2x_phy_selection(struct link_params
*params
)
7233 u32 phy_config_swapped
, prio_cfg
;
7234 u32 return_cfg
= PORT_HW_CFG_PHY_SELECTION_HARDWARE_DEFAULT
;
7236 phy_config_swapped
= params
->multi_phy_config
&
7237 PORT_HW_CFG_PHY_SWAPPED_ENABLED
;
7239 prio_cfg
= params
->multi_phy_config
&
7240 PORT_HW_CFG_PHY_SELECTION_MASK
;
7242 if (phy_config_swapped
) {
7244 case PORT_HW_CFG_PHY_SELECTION_FIRST_PHY_PRIORITY
:
7245 return_cfg
= PORT_HW_CFG_PHY_SELECTION_SECOND_PHY_PRIORITY
;
7247 case PORT_HW_CFG_PHY_SELECTION_SECOND_PHY_PRIORITY
:
7248 return_cfg
= PORT_HW_CFG_PHY_SELECTION_FIRST_PHY_PRIORITY
;
7250 case PORT_HW_CFG_PHY_SELECTION_SECOND_PHY
:
7251 return_cfg
= PORT_HW_CFG_PHY_SELECTION_FIRST_PHY
;
7253 case PORT_HW_CFG_PHY_SELECTION_FIRST_PHY
:
7254 return_cfg
= PORT_HW_CFG_PHY_SELECTION_SECOND_PHY
;
7258 return_cfg
= prio_cfg
;
7264 u8
bnx2x_phy_probe(struct link_params
*params
)
7266 u8 phy_index
, actual_phy_idx
, link_cfg_idx
;
7267 u32 phy_config_swapped
;
7268 struct bnx2x
*bp
= params
->bp
;
7269 struct bnx2x_phy
*phy
;
7270 params
->num_phys
= 0;
7271 DP(NETIF_MSG_LINK
, "Begin phy probe\n");
7272 phy_config_swapped
= params
->multi_phy_config
&
7273 PORT_HW_CFG_PHY_SWAPPED_ENABLED
;
7275 for (phy_index
= INT_PHY
; phy_index
< MAX_PHYS
;
7277 link_cfg_idx
= LINK_CONFIG_IDX(phy_index
);
7278 actual_phy_idx
= phy_index
;
7279 if (phy_config_swapped
) {
7280 if (phy_index
== EXT_PHY1
)
7281 actual_phy_idx
= EXT_PHY2
;
7282 else if (phy_index
== EXT_PHY2
)
7283 actual_phy_idx
= EXT_PHY1
;
7285 DP(NETIF_MSG_LINK
, "phy_config_swapped %x, phy_index %x,"
7286 " actual_phy_idx %x\n", phy_config_swapped
,
7287 phy_index
, actual_phy_idx
);
7288 phy
= ¶ms
->phy
[actual_phy_idx
];
7289 if (bnx2x_populate_phy(bp
, phy_index
, params
->shmem_base
,
7290 params
->shmem2_base
, params
->port
,
7292 params
->num_phys
= 0;
7293 DP(NETIF_MSG_LINK
, "phy probe failed in phy index %d\n",
7295 for (phy_index
= INT_PHY
;
7296 phy_index
< MAX_PHYS
;
7301 if (phy
->type
== PORT_HW_CFG_XGXS_EXT_PHY_TYPE_NOT_CONN
)
7304 bnx2x_phy_def_cfg(params
, phy
, phy_index
);
7308 DP(NETIF_MSG_LINK
, "End phy probe. #phys found %x\n", params
->num_phys
);
7312 static void set_phy_vars(struct link_params
*params
)
7314 struct bnx2x
*bp
= params
->bp
;
7315 u8 actual_phy_idx
, phy_index
, link_cfg_idx
;
7316 u8 phy_config_swapped
= params
->multi_phy_config
&
7317 PORT_HW_CFG_PHY_SWAPPED_ENABLED
;
7318 for (phy_index
= INT_PHY
; phy_index
< params
->num_phys
;
7320 link_cfg_idx
= LINK_CONFIG_IDX(phy_index
);
7321 actual_phy_idx
= phy_index
;
7322 if (phy_config_swapped
) {
7323 if (phy_index
== EXT_PHY1
)
7324 actual_phy_idx
= EXT_PHY2
;
7325 else if (phy_index
== EXT_PHY2
)
7326 actual_phy_idx
= EXT_PHY1
;
7328 params
->phy
[actual_phy_idx
].req_flow_ctrl
=
7329 params
->req_flow_ctrl
[link_cfg_idx
];
7331 params
->phy
[actual_phy_idx
].req_line_speed
=
7332 params
->req_line_speed
[link_cfg_idx
];
7334 params
->phy
[actual_phy_idx
].speed_cap_mask
=
7335 params
->speed_cap_mask
[link_cfg_idx
];
7337 params
->phy
[actual_phy_idx
].req_duplex
=
7338 params
->req_duplex
[link_cfg_idx
];
7340 DP(NETIF_MSG_LINK
, "req_flow_ctrl %x, req_line_speed %x,"
7341 " speed_cap_mask %x\n",
7342 params
->phy
[actual_phy_idx
].req_flow_ctrl
,
7343 params
->phy
[actual_phy_idx
].req_line_speed
,
7344 params
->phy
[actual_phy_idx
].speed_cap_mask
);
7348 u8
bnx2x_phy_init(struct link_params
*params
, struct link_vars
*vars
)
7350 struct bnx2x
*bp
= params
->bp
;
7351 DP(NETIF_MSG_LINK
, "Phy Initialization started\n");
7352 DP(NETIF_MSG_LINK
, "(1) req_speed %d, req_flowctrl %d\n",
7353 params
->req_line_speed
[0], params
->req_flow_ctrl
[0]);
7354 DP(NETIF_MSG_LINK
, "(2) req_speed %d, req_flowctrl %d\n",
7355 params
->req_line_speed
[1], params
->req_flow_ctrl
[1]);
7356 vars
->link_status
= 0;
7357 vars
->phy_link_up
= 0;
7359 vars
->line_speed
= 0;
7360 vars
->duplex
= DUPLEX_FULL
;
7361 vars
->flow_ctrl
= BNX2X_FLOW_CTRL_NONE
;
7362 vars
->mac_type
= MAC_TYPE_NONE
;
7363 vars
->phy_flags
= 0;
7365 /* disable attentions */
7366 bnx2x_bits_dis(bp
, NIG_REG_MASK_INTERRUPT_PORT0
+ params
->port
*4,
7367 (NIG_MASK_XGXS0_LINK_STATUS
|
7368 NIG_MASK_XGXS0_LINK10G
|
7369 NIG_MASK_SERDES0_LINK_STATUS
|
7372 bnx2x_emac_init(params
, vars
);
7374 if (params
->num_phys
== 0) {
7375 DP(NETIF_MSG_LINK
, "No phy found for initialization !!\n");
7378 set_phy_vars(params
);
7380 DP(NETIF_MSG_LINK
, "Num of phys on board: %d\n", params
->num_phys
);
7381 if (CHIP_REV_IS_FPGA(bp
)) {
7384 vars
->line_speed
= SPEED_10000
;
7385 vars
->duplex
= DUPLEX_FULL
;
7386 vars
->flow_ctrl
= BNX2X_FLOW_CTRL_NONE
;
7387 vars
->link_status
= (LINK_STATUS_LINK_UP
| LINK_10GTFD
);
7388 /* enable on E1.5 FPGA */
7389 if (CHIP_IS_E1H(bp
)) {
7391 (BNX2X_FLOW_CTRL_TX
|
7392 BNX2X_FLOW_CTRL_RX
);
7393 vars
->link_status
|=
7394 (LINK_STATUS_TX_FLOW_CONTROL_ENABLED
|
7395 LINK_STATUS_RX_FLOW_CONTROL_ENABLED
);
7398 bnx2x_emac_enable(params
, vars
, 0);
7399 if (!(CHIP_IS_E2(bp
)))
7400 bnx2x_pbf_update(params
, vars
->flow_ctrl
,
7403 REG_WR(bp
, NIG_REG_EGRESS_DRAIN0_MODE
+ params
->port
*4, 0);
7405 /* update shared memory */
7406 bnx2x_update_mng(params
, vars
->link_status
);
7411 if (CHIP_REV_IS_EMUL(bp
)) {
7414 vars
->line_speed
= SPEED_10000
;
7415 vars
->duplex
= DUPLEX_FULL
;
7416 vars
->flow_ctrl
= BNX2X_FLOW_CTRL_NONE
;
7417 vars
->link_status
= (LINK_STATUS_LINK_UP
| LINK_10GTFD
);
7419 bnx2x_bmac_enable(params
, vars
, 0);
7421 bnx2x_pbf_update(params
, vars
->flow_ctrl
, vars
->line_speed
);
7423 REG_WR(bp
, NIG_REG_EGRESS_DRAIN0_MODE
7424 + params
->port
*4, 0);
7426 /* update shared memory */
7427 bnx2x_update_mng(params
, vars
->link_status
);
7432 if (params
->loopback_mode
== LOOPBACK_BMAC
) {
7435 vars
->line_speed
= SPEED_10000
;
7436 vars
->duplex
= DUPLEX_FULL
;
7437 vars
->flow_ctrl
= BNX2X_FLOW_CTRL_NONE
;
7438 vars
->mac_type
= MAC_TYPE_BMAC
;
7440 vars
->phy_flags
= PHY_XGXS_FLAG
;
7442 bnx2x_xgxs_deassert(params
);
7444 /* set bmac loopback */
7445 bnx2x_bmac_enable(params
, vars
, 1);
7447 REG_WR(bp
, NIG_REG_EGRESS_DRAIN0_MODE
+
7450 } else if (params
->loopback_mode
== LOOPBACK_EMAC
) {
7453 vars
->line_speed
= SPEED_1000
;
7454 vars
->duplex
= DUPLEX_FULL
;
7455 vars
->flow_ctrl
= BNX2X_FLOW_CTRL_NONE
;
7456 vars
->mac_type
= MAC_TYPE_EMAC
;
7458 vars
->phy_flags
= PHY_XGXS_FLAG
;
7460 bnx2x_xgxs_deassert(params
);
7461 /* set bmac loopback */
7462 bnx2x_emac_enable(params
, vars
, 1);
7463 bnx2x_emac_program(params
, vars
);
7464 REG_WR(bp
, NIG_REG_EGRESS_DRAIN0_MODE
+
7467 } else if ((params
->loopback_mode
== LOOPBACK_XGXS
) ||
7468 (params
->loopback_mode
== LOOPBACK_EXT_PHY
)) {
7471 vars
->flow_ctrl
= BNX2X_FLOW_CTRL_NONE
;
7472 vars
->duplex
= DUPLEX_FULL
;
7473 if (params
->req_line_speed
[0] == SPEED_1000
) {
7474 vars
->line_speed
= SPEED_1000
;
7475 vars
->mac_type
= MAC_TYPE_EMAC
;
7477 vars
->line_speed
= SPEED_10000
;
7478 vars
->mac_type
= MAC_TYPE_BMAC
;
7481 bnx2x_xgxs_deassert(params
);
7482 bnx2x_link_initialize(params
, vars
);
7484 if (params
->req_line_speed
[0] == SPEED_1000
) {
7485 bnx2x_emac_program(params
, vars
);
7486 bnx2x_emac_enable(params
, vars
, 0);
7488 bnx2x_bmac_enable(params
, vars
, 0);
7490 if (params
->loopback_mode
== LOOPBACK_XGXS
) {
7491 /* set 10G XGXS loopback */
7492 params
->phy
[INT_PHY
].config_loopback(
7493 ¶ms
->phy
[INT_PHY
],
7497 /* set external phy loopback */
7499 for (phy_index
= EXT_PHY1
;
7500 phy_index
< params
->num_phys
; phy_index
++) {
7501 if (params
->phy
[phy_index
].config_loopback
)
7502 params
->phy
[phy_index
].config_loopback(
7503 ¶ms
->phy
[phy_index
],
7508 REG_WR(bp
, NIG_REG_EGRESS_DRAIN0_MODE
+
7511 bnx2x_set_led(params
, vars
,
7512 LED_MODE_OPER
, vars
->line_speed
);
7516 if (params
->switch_cfg
== SWITCH_CFG_10G
)
7517 bnx2x_xgxs_deassert(params
);
7519 bnx2x_serdes_deassert(bp
, params
->port
);
7521 bnx2x_link_initialize(params
, vars
);
7523 bnx2x_link_int_enable(params
);
7527 u8
bnx2x_link_reset(struct link_params
*params
, struct link_vars
*vars
,
7530 struct bnx2x
*bp
= params
->bp
;
7531 u8 phy_index
, port
= params
->port
, clear_latch_ind
= 0;
7532 DP(NETIF_MSG_LINK
, "Resetting the link of port %d\n", port
);
7533 /* disable attentions */
7534 vars
->link_status
= 0;
7535 bnx2x_update_mng(params
, vars
->link_status
);
7536 bnx2x_bits_dis(bp
, NIG_REG_MASK_INTERRUPT_PORT0
+ port
*4,
7537 (NIG_MASK_XGXS0_LINK_STATUS
|
7538 NIG_MASK_XGXS0_LINK10G
|
7539 NIG_MASK_SERDES0_LINK_STATUS
|
7542 /* activate nig drain */
7543 REG_WR(bp
, NIG_REG_EGRESS_DRAIN0_MODE
+ port
*4, 1);
7545 /* disable nig egress interface */
7546 REG_WR(bp
, NIG_REG_BMAC0_OUT_EN
+ port
*4, 0);
7547 REG_WR(bp
, NIG_REG_EGRESS_EMAC0_OUT_EN
+ port
*4, 0);
7549 /* Stop BigMac rx */
7550 bnx2x_bmac_rx_disable(bp
, port
);
7553 REG_WR(bp
, NIG_REG_NIG_EMAC0_EN
+ port
*4, 0);
7556 /* The PHY reset is controled by GPIO 1
7557 * Hold it as vars low
7559 /* clear link led */
7560 bnx2x_set_led(params
, vars
, LED_MODE_OFF
, 0);
7562 if (reset_ext_phy
) {
7563 for (phy_index
= EXT_PHY1
; phy_index
< params
->num_phys
;
7565 if (params
->phy
[phy_index
].link_reset
)
7566 params
->phy
[phy_index
].link_reset(
7567 ¶ms
->phy
[phy_index
],
7569 if (params
->phy
[phy_index
].flags
&
7570 FLAGS_REARM_LATCH_SIGNAL
)
7571 clear_latch_ind
= 1;
7575 if (clear_latch_ind
) {
7576 /* Clear latching indication */
7577 bnx2x_rearm_latch_signal(bp
, port
, 0);
7578 bnx2x_bits_dis(bp
, NIG_REG_LATCH_BC_0
+ port
*4,
7579 1 << NIG_LATCH_BC_ENABLE_MI_INT
);
7581 if (params
->phy
[INT_PHY
].link_reset
)
7582 params
->phy
[INT_PHY
].link_reset(
7583 ¶ms
->phy
[INT_PHY
], params
);
7585 REG_WR(bp
, GRCBASE_MISC
+ MISC_REGISTERS_RESET_REG_2_CLEAR
,
7586 (MISC_REGISTERS_RESET_REG_2_RST_BMAC0
<< port
));
7588 /* disable nig ingress interface */
7589 REG_WR(bp
, NIG_REG_BMAC0_IN_EN
+ port
*4, 0);
7590 REG_WR(bp
, NIG_REG_EMAC0_IN_EN
+ port
*4, 0);
7591 REG_WR(bp
, NIG_REG_BMAC0_OUT_EN
+ port
*4, 0);
7592 REG_WR(bp
, NIG_REG_EGRESS_EMAC0_OUT_EN
+ port
*4, 0);
7597 /****************************************************************************/
7598 /* Common function */
7599 /****************************************************************************/
7600 static u8
bnx2x_8073_common_init_phy(struct bnx2x
*bp
,
7601 u32 shmem_base_path
[],
7602 u32 shmem2_base_path
[], u8 phy_index
,
7605 struct bnx2x_phy phy
[PORT_MAX
];
7606 struct bnx2x_phy
*phy_blk
[PORT_MAX
];
7609 s8 port_of_path
= 0;
7611 bnx2x_ext_phy_hw_reset(bp
, 0);
7612 /* PART1 - Reset both phys */
7613 for (port
= PORT_MAX
- 1; port
>= PORT_0
; port
--) {
7614 u32 shmem_base
, shmem2_base
;
7615 /* In E2, same phy is using for port0 of the two paths */
7616 if (CHIP_IS_E2(bp
)) {
7617 shmem_base
= shmem_base_path
[port
];
7618 shmem2_base
= shmem2_base_path
[port
];
7621 shmem_base
= shmem_base_path
[0];
7622 shmem2_base
= shmem2_base_path
[0];
7623 port_of_path
= port
;
7626 /* Extract the ext phy address for the port */
7627 if (bnx2x_populate_phy(bp
, phy_index
, shmem_base
, shmem2_base
,
7628 port_of_path
, &phy
[port
]) !=
7630 DP(NETIF_MSG_LINK
, "populate_phy failed\n");
7633 /* disable attentions */
7634 bnx2x_bits_dis(bp
, NIG_REG_MASK_INTERRUPT_PORT0
+
7636 (NIG_MASK_XGXS0_LINK_STATUS
|
7637 NIG_MASK_XGXS0_LINK10G
|
7638 NIG_MASK_SERDES0_LINK_STATUS
|
7641 /* Need to take the phy out of low power mode in order
7642 to write to access its registers */
7643 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_2
,
7644 MISC_REGISTERS_GPIO_OUTPUT_HIGH
, port
);
7647 bnx2x_cl45_write(bp
, &phy
[port
],
7653 /* Add delay of 150ms after reset */
7656 if (phy
[PORT_0
].addr
& 0x1) {
7657 phy_blk
[PORT_0
] = &(phy
[PORT_1
]);
7658 phy_blk
[PORT_1
] = &(phy
[PORT_0
]);
7660 phy_blk
[PORT_0
] = &(phy
[PORT_0
]);
7661 phy_blk
[PORT_1
] = &(phy
[PORT_1
]);
7664 /* PART2 - Download firmware to both phys */
7665 for (port
= PORT_MAX
- 1; port
>= PORT_0
; port
--) {
7670 port_of_path
= port
;
7672 DP(NETIF_MSG_LINK
, "Loading spirom for phy address 0x%x\n",
7673 phy_blk
[port
]->addr
);
7674 bnx2x_8073_8727_external_rom_boot(bp
, phy_blk
[port
],
7677 bnx2x_cl45_read(bp
, phy_blk
[port
],
7679 MDIO_PMA_REG_ROM_VER1
, &fw_ver1
);
7680 if (fw_ver1
== 0 || fw_ver1
== 0x4321) {
7682 "bnx2x_8073_common_init_phy port %x:"
7683 "Download failed. fw version = 0x%x\n",
7688 /* Only set bit 10 = 1 (Tx power down) */
7689 bnx2x_cl45_read(bp
, phy_blk
[port
],
7691 MDIO_PMA_REG_TX_POWER_DOWN
, &val
);
7693 /* Phase1 of TX_POWER_DOWN reset */
7694 bnx2x_cl45_write(bp
, phy_blk
[port
],
7696 MDIO_PMA_REG_TX_POWER_DOWN
,
7700 /* Toggle Transmitter: Power down and then up with 600ms
7704 /* PART3 - complete TX_POWER_DOWN process, and set GPIO2 back to low */
7705 for (port
= PORT_MAX
- 1; port
>= PORT_0
; port
--) {
7706 /* Phase2 of POWER_DOWN_RESET */
7707 /* Release bit 10 (Release Tx power down) */
7708 bnx2x_cl45_read(bp
, phy_blk
[port
],
7710 MDIO_PMA_REG_TX_POWER_DOWN
, &val
);
7712 bnx2x_cl45_write(bp
, phy_blk
[port
],
7714 MDIO_PMA_REG_TX_POWER_DOWN
, (val
& (~(1<<10))));
7717 /* Read modify write the SPI-ROM version select register */
7718 bnx2x_cl45_read(bp
, phy_blk
[port
],
7720 MDIO_PMA_REG_EDC_FFE_MAIN
, &val
);
7721 bnx2x_cl45_write(bp
, phy_blk
[port
],
7723 MDIO_PMA_REG_EDC_FFE_MAIN
, (val
| (1<<12)));
7725 /* set GPIO2 back to LOW */
7726 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_2
,
7727 MISC_REGISTERS_GPIO_OUTPUT_LOW
, port
);
7731 static u8
bnx2x_8726_common_init_phy(struct bnx2x
*bp
,
7732 u32 shmem_base_path
[],
7733 u32 shmem2_base_path
[], u8 phy_index
,
7738 struct bnx2x_phy phy
;
7739 /* Use port1 because of the static port-swap */
7740 /* Enable the module detection interrupt */
7741 val
= REG_RD(bp
, MISC_REG_GPIO_EVENT_EN
);
7742 val
|= ((1<<MISC_REGISTERS_GPIO_3
)|
7743 (1<<(MISC_REGISTERS_GPIO_3
+ MISC_REGISTERS_GPIO_PORT_SHIFT
)));
7744 REG_WR(bp
, MISC_REG_GPIO_EVENT_EN
, val
);
7746 bnx2x_ext_phy_hw_reset(bp
, 0);
7748 for (port
= 0; port
< PORT_MAX
; port
++) {
7749 u32 shmem_base
, shmem2_base
;
7751 /* In E2, same phy is using for port0 of the two paths */
7752 if (CHIP_IS_E2(bp
)) {
7753 shmem_base
= shmem_base_path
[port
];
7754 shmem2_base
= shmem2_base_path
[port
];
7756 shmem_base
= shmem_base_path
[0];
7757 shmem2_base
= shmem2_base_path
[0];
7759 /* Extract the ext phy address for the port */
7760 if (bnx2x_populate_phy(bp
, phy_index
, shmem_base
, shmem2_base
,
7763 DP(NETIF_MSG_LINK
, "populate phy failed\n");
7768 bnx2x_cl45_write(bp
, &phy
,
7769 MDIO_PMA_DEVAD
, MDIO_PMA_REG_GEN_CTRL
, 0x0001);
7772 /* Set fault module detected LED on */
7773 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_0
,
7774 MISC_REGISTERS_GPIO_HIGH
,
7780 static u8
bnx2x_8727_common_init_phy(struct bnx2x
*bp
,
7781 u32 shmem_base_path
[],
7782 u32 shmem2_base_path
[], u8 phy_index
,
7786 u32 swap_val
, swap_override
;
7787 struct bnx2x_phy phy
[PORT_MAX
];
7788 struct bnx2x_phy
*phy_blk
[PORT_MAX
];
7790 swap_val
= REG_RD(bp
, NIG_REG_PORT_SWAP
);
7791 swap_override
= REG_RD(bp
, NIG_REG_STRAP_OVERRIDE
);
7795 bnx2x_ext_phy_hw_reset(bp
, port
^ (swap_val
&& swap_override
));
7797 /* Calculate the port based on port swap */
7798 port
^= (swap_val
&& swap_override
);
7802 /* PART1 - Reset both phys */
7803 for (port
= PORT_MAX
- 1; port
>= PORT_0
; port
--) {
7804 u32 shmem_base
, shmem2_base
;
7806 /* In E2, same phy is using for port0 of the two paths */
7807 if (CHIP_IS_E2(bp
)) {
7808 shmem_base
= shmem_base_path
[port
];
7809 shmem2_base
= shmem2_base_path
[port
];
7812 shmem_base
= shmem_base_path
[0];
7813 shmem2_base
= shmem2_base_path
[0];
7814 port_of_path
= port
;
7817 /* Extract the ext phy address for the port */
7818 if (bnx2x_populate_phy(bp
, phy_index
, shmem_base
, shmem2_base
,
7819 port_of_path
, &phy
[port
]) !=
7821 DP(NETIF_MSG_LINK
, "populate phy failed\n");
7824 /* disable attentions */
7825 bnx2x_bits_dis(bp
, NIG_REG_MASK_INTERRUPT_PORT0
+
7827 (NIG_MASK_XGXS0_LINK_STATUS
|
7828 NIG_MASK_XGXS0_LINK10G
|
7829 NIG_MASK_SERDES0_LINK_STATUS
|
7834 bnx2x_cl45_write(bp
, &phy
[port
],
7840 /* Add delay of 150ms after reset */
7842 if (phy
[PORT_0
].addr
& 0x1) {
7843 phy_blk
[PORT_0
] = &(phy
[PORT_1
]);
7844 phy_blk
[PORT_1
] = &(phy
[PORT_0
]);
7846 phy_blk
[PORT_0
] = &(phy
[PORT_0
]);
7847 phy_blk
[PORT_1
] = &(phy
[PORT_1
]);
7849 /* PART2 - Download firmware to both phys */
7850 for (port
= PORT_MAX
- 1; port
>= PORT_0
; port
--) {
7855 port_of_path
= port
;
7856 DP(NETIF_MSG_LINK
, "Loading spirom for phy address 0x%x\n",
7857 phy_blk
[port
]->addr
);
7858 bnx2x_8073_8727_external_rom_boot(bp
, phy_blk
[port
],
7860 bnx2x_cl45_read(bp
, phy_blk
[port
],
7862 MDIO_PMA_REG_ROM_VER1
, &fw_ver1
);
7863 if (fw_ver1
== 0 || fw_ver1
== 0x4321) {
7865 "bnx2x_8727_common_init_phy port %x:"
7866 "Download failed. fw version = 0x%x\n",
7875 static u8
bnx2x_ext_phy_common_init(struct bnx2x
*bp
, u32 shmem_base_path
[],
7876 u32 shmem2_base_path
[], u8 phy_index
,
7877 u32 ext_phy_type
, u32 chip_id
)
7881 switch (ext_phy_type
) {
7882 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073
:
7883 rc
= bnx2x_8073_common_init_phy(bp
, shmem_base_path
,
7885 phy_index
, chip_id
);
7888 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727
:
7889 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727_NOC
:
7890 rc
= bnx2x_8727_common_init_phy(bp
, shmem_base_path
,
7892 phy_index
, chip_id
);
7895 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726
:
7896 /* GPIO1 affects both ports, so there's need to pull
7897 it for single port alone */
7898 rc
= bnx2x_8726_common_init_phy(bp
, shmem_base_path
,
7900 phy_index
, chip_id
);
7902 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_FAILURE
:
7907 "bnx2x_common_init_phy: ext_phy 0x%x not required\n",
7915 u8
bnx2x_common_init_phy(struct bnx2x
*bp
, u32 shmem_base_path
[],
7916 u32 shmem2_base_path
[], u32 chip_id
)
7920 u32 ext_phy_type
, ext_phy_config
;
7921 DP(NETIF_MSG_LINK
, "Begin common phy init\n");
7923 if (CHIP_REV_IS_EMUL(bp
))
7926 /* Read the ext_phy_type for arbitrary port(0) */
7927 for (phy_index
= EXT_PHY1
; phy_index
< MAX_PHYS
;
7929 ext_phy_config
= bnx2x_get_ext_phy_config(bp
,
7932 ext_phy_type
= XGXS_EXT_PHY_TYPE(ext_phy_config
);
7933 rc
|= bnx2x_ext_phy_common_init(bp
, shmem_base_path
,
7935 phy_index
, ext_phy_type
,
7941 u8
bnx2x_hw_lock_required(struct bnx2x
*bp
, u32 shmem_base
, u32 shmem2_base
)
7944 struct bnx2x_phy phy
;
7945 for (phy_index
= INT_PHY
; phy_index
< MAX_PHYS
;
7947 if (bnx2x_populate_phy(bp
, phy_index
, shmem_base
, shmem2_base
,
7949 DP(NETIF_MSG_LINK
, "populate phy failed\n");
7953 if (phy
.flags
& FLAGS_HW_LOCK_REQUIRED
)
7959 u8
bnx2x_fan_failure_det_req(struct bnx2x
*bp
,
7964 u8 phy_index
, fan_failure_det_req
= 0;
7965 struct bnx2x_phy phy
;
7966 for (phy_index
= EXT_PHY1
; phy_index
< MAX_PHYS
;
7968 if (bnx2x_populate_phy(bp
, phy_index
, shmem_base
, shmem2_base
,
7971 DP(NETIF_MSG_LINK
, "populate phy failed\n");
7974 fan_failure_det_req
|= (phy
.flags
&
7975 FLAGS_FAN_FAILURE_DET_REQ
);
7977 return fan_failure_det_req
;
7980 void bnx2x_hw_reset_phy(struct link_params
*params
)
7983 for (phy_index
= EXT_PHY1
; phy_index
< MAX_PHYS
;
7985 if (params
->phy
[phy_index
].hw_reset
) {
7986 params
->phy
[phy_index
].hw_reset(
7987 ¶ms
->phy
[phy_index
],
7989 params
->phy
[phy_index
] = phy_null
;