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 for CRC + VLAN*/
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
168 /**********************************************************/
170 /**********************************************************/
172 #define CL45_WR_OVER_CL22(_bp, _phy, _bank, _addr, _val) \
173 bnx2x_cl45_write(_bp, _phy, \
174 (_phy)->def_md_devad, \
175 (_bank + (_addr & 0xf)), \
178 #define CL45_RD_OVER_CL22(_bp, _phy, _bank, _addr, _val) \
179 bnx2x_cl45_read(_bp, _phy, \
180 (_phy)->def_md_devad, \
181 (_bank + (_addr & 0xf)), \
184 static void bnx2x_set_serdes_access(struct bnx2x
*bp
, u8 port
)
186 u32 emac_base
= (port
) ? GRCBASE_EMAC1
: GRCBASE_EMAC0
;
189 REG_WR(bp
, NIG_REG_SERDES0_CTRL_MD_ST
+ port
*0x10, 1);
190 REG_WR(bp
, emac_base
+ EMAC_REG_EMAC_MDIO_COMM
, 0x245f8000);
192 REG_WR(bp
, emac_base
+ EMAC_REG_EMAC_MDIO_COMM
, 0x245d000f);
195 REG_WR(bp
, NIG_REG_SERDES0_CTRL_MD_ST
+ port
*0x10, 0);
198 static u32
bnx2x_bits_en(struct bnx2x
*bp
, u32 reg
, u32 bits
)
200 u32 val
= REG_RD(bp
, reg
);
203 REG_WR(bp
, reg
, val
);
207 static u32
bnx2x_bits_dis(struct bnx2x
*bp
, u32 reg
, u32 bits
)
209 u32 val
= REG_RD(bp
, reg
);
212 REG_WR(bp
, reg
, val
);
216 static void bnx2x_emac_init(struct link_params
*params
,
217 struct link_vars
*vars
)
219 /* reset and unreset the emac core */
220 struct bnx2x
*bp
= params
->bp
;
221 u8 port
= params
->port
;
222 u32 emac_base
= port
? GRCBASE_EMAC1
: GRCBASE_EMAC0
;
226 REG_WR(bp
, GRCBASE_MISC
+ MISC_REGISTERS_RESET_REG_2_CLEAR
,
227 (MISC_REGISTERS_RESET_REG_2_RST_EMAC0_HARD_CORE
<< port
));
229 REG_WR(bp
, GRCBASE_MISC
+ MISC_REGISTERS_RESET_REG_2_SET
,
230 (MISC_REGISTERS_RESET_REG_2_RST_EMAC0_HARD_CORE
<< port
));
232 /* init emac - use read-modify-write */
233 /* self clear reset */
234 val
= REG_RD(bp
, emac_base
+ EMAC_REG_EMAC_MODE
);
235 EMAC_WR(bp
, EMAC_REG_EMAC_MODE
, (val
| EMAC_MODE_RESET
));
239 val
= REG_RD(bp
, emac_base
+ EMAC_REG_EMAC_MODE
);
240 DP(NETIF_MSG_LINK
, "EMAC reset reg is %u\n", val
);
242 DP(NETIF_MSG_LINK
, "EMAC timeout!\n");
246 } while (val
& EMAC_MODE_RESET
);
248 /* Set mac address */
249 val
= ((params
->mac_addr
[0] << 8) |
250 params
->mac_addr
[1]);
251 EMAC_WR(bp
, EMAC_REG_EMAC_MAC_MATCH
, val
);
253 val
= ((params
->mac_addr
[2] << 24) |
254 (params
->mac_addr
[3] << 16) |
255 (params
->mac_addr
[4] << 8) |
256 params
->mac_addr
[5]);
257 EMAC_WR(bp
, EMAC_REG_EMAC_MAC_MATCH
+ 4, val
);
260 static u8
bnx2x_emac_enable(struct link_params
*params
,
261 struct link_vars
*vars
, u8 lb
)
263 struct bnx2x
*bp
= params
->bp
;
264 u8 port
= params
->port
;
265 u32 emac_base
= port
? GRCBASE_EMAC1
: GRCBASE_EMAC0
;
268 DP(NETIF_MSG_LINK
, "enabling EMAC\n");
270 /* enable emac and not bmac */
271 REG_WR(bp
, NIG_REG_EGRESS_EMAC0_PORT
+ port
*4, 1);
274 if (CHIP_REV_IS_EMUL(bp
)) {
275 /* Use lane 1 (of lanes 0-3) */
276 REG_WR(bp
, NIG_REG_XGXS_LANE_SEL_P0
+ port
*4, 1);
277 REG_WR(bp
, NIG_REG_XGXS_SERDES0_MODE_SEL
+
283 if (CHIP_REV_IS_FPGA(bp
)) {
284 /* Use lane 1 (of lanes 0-3) */
285 DP(NETIF_MSG_LINK
, "bnx2x_emac_enable: Setting FPGA\n");
287 REG_WR(bp
, NIG_REG_XGXS_LANE_SEL_P0
+ port
*4, 1);
288 REG_WR(bp
, NIG_REG_XGXS_SERDES0_MODE_SEL
+ port
*4,
292 if (vars
->phy_flags
& PHY_XGXS_FLAG
) {
293 u32 ser_lane
= ((params
->lane_config
&
294 PORT_HW_CFG_LANE_SWAP_CFG_MASTER_MASK
) >>
295 PORT_HW_CFG_LANE_SWAP_CFG_MASTER_SHIFT
);
297 DP(NETIF_MSG_LINK
, "XGXS\n");
298 /* select the master lanes (out of 0-3) */
299 REG_WR(bp
, NIG_REG_XGXS_LANE_SEL_P0
+
302 REG_WR(bp
, NIG_REG_XGXS_SERDES0_MODE_SEL
+
305 } else { /* SerDes */
306 DP(NETIF_MSG_LINK
, "SerDes\n");
308 REG_WR(bp
, NIG_REG_XGXS_SERDES0_MODE_SEL
+
312 bnx2x_bits_en(bp
, emac_base
+ EMAC_REG_EMAC_RX_MODE
,
314 bnx2x_bits_en(bp
, emac_base
+ EMAC_REG_EMAC_TX_MODE
,
317 if (CHIP_REV_IS_SLOW(bp
)) {
318 /* config GMII mode */
319 val
= REG_RD(bp
, emac_base
+ EMAC_REG_EMAC_MODE
);
320 EMAC_WR(bp
, EMAC_REG_EMAC_MODE
,
321 (val
| EMAC_MODE_PORT_GMII
));
323 /* pause enable/disable */
324 bnx2x_bits_dis(bp
, emac_base
+ EMAC_REG_EMAC_RX_MODE
,
325 EMAC_RX_MODE_FLOW_EN
);
326 if (vars
->flow_ctrl
& BNX2X_FLOW_CTRL_RX
)
327 bnx2x_bits_en(bp
, emac_base
+
328 EMAC_REG_EMAC_RX_MODE
,
329 EMAC_RX_MODE_FLOW_EN
);
331 bnx2x_bits_dis(bp
, emac_base
+ EMAC_REG_EMAC_TX_MODE
,
332 (EMAC_TX_MODE_EXT_PAUSE_EN
|
333 EMAC_TX_MODE_FLOW_EN
));
334 if (vars
->flow_ctrl
& BNX2X_FLOW_CTRL_TX
)
335 bnx2x_bits_en(bp
, emac_base
+
336 EMAC_REG_EMAC_TX_MODE
,
337 (EMAC_TX_MODE_EXT_PAUSE_EN
|
338 EMAC_TX_MODE_FLOW_EN
));
341 /* KEEP_VLAN_TAG, promiscuous */
342 val
= REG_RD(bp
, emac_base
+ EMAC_REG_EMAC_RX_MODE
);
343 val
|= EMAC_RX_MODE_KEEP_VLAN_TAG
| EMAC_RX_MODE_PROMISCUOUS
;
344 EMAC_WR(bp
, EMAC_REG_EMAC_RX_MODE
, val
);
347 val
= REG_RD(bp
, emac_base
+ EMAC_REG_EMAC_MODE
);
352 EMAC_WR(bp
, EMAC_REG_EMAC_MODE
, val
);
355 REG_WR(bp
, NIG_REG_NIG_EMAC0_EN
+ port
*4, 1);
357 /* enable emac for jumbo packets */
358 EMAC_WR(bp
, EMAC_REG_EMAC_RX_MTU_SIZE
,
359 (EMAC_RX_MTU_SIZE_JUMBO_ENA
|
360 (ETH_MAX_JUMBO_PACKET_SIZE
+ ETH_OVREHEAD
)));
363 REG_WR(bp
, NIG_REG_NIG_INGRESS_EMAC0_NO_CRC
+ port
*4, 0x1);
365 /* disable the NIG in/out to the bmac */
366 REG_WR(bp
, NIG_REG_BMAC0_IN_EN
+ port
*4, 0x0);
367 REG_WR(bp
, NIG_REG_BMAC0_PAUSE_OUT_EN
+ port
*4, 0x0);
368 REG_WR(bp
, NIG_REG_BMAC0_OUT_EN
+ port
*4, 0x0);
370 /* enable the NIG in/out to the emac */
371 REG_WR(bp
, NIG_REG_EMAC0_IN_EN
+ port
*4, 0x1);
373 if (vars
->flow_ctrl
& BNX2X_FLOW_CTRL_TX
)
376 REG_WR(bp
, NIG_REG_EMAC0_PAUSE_OUT_EN
+ port
*4, val
);
377 REG_WR(bp
, NIG_REG_EGRESS_EMAC0_OUT_EN
+ port
*4, 0x1);
379 if (CHIP_REV_IS_EMUL(bp
)) {
380 /* take the BigMac out of reset */
382 GRCBASE_MISC
+ MISC_REGISTERS_RESET_REG_2_SET
,
383 (MISC_REGISTERS_RESET_REG_2_RST_BMAC0
<< port
));
385 /* enable access for bmac registers */
386 REG_WR(bp
, NIG_REG_BMAC0_REGS_OUT_EN
+ port
*4, 0x1);
388 REG_WR(bp
, NIG_REG_BMAC0_REGS_OUT_EN
+ port
*4, 0x0);
390 vars
->mac_type
= MAC_TYPE_EMAC
;
396 static u8
bnx2x_bmac_enable(struct link_params
*params
, struct link_vars
*vars
,
399 struct bnx2x
*bp
= params
->bp
;
400 u8 port
= params
->port
;
401 u32 bmac_addr
= port
? NIG_REG_INGRESS_BMAC1_MEM
:
402 NIG_REG_INGRESS_BMAC0_MEM
;
406 DP(NETIF_MSG_LINK
, "Enabling BigMAC\n");
407 /* reset and unreset the BigMac */
408 REG_WR(bp
, GRCBASE_MISC
+ MISC_REGISTERS_RESET_REG_2_CLEAR
,
409 (MISC_REGISTERS_RESET_REG_2_RST_BMAC0
<< port
));
412 REG_WR(bp
, GRCBASE_MISC
+ MISC_REGISTERS_RESET_REG_2_SET
,
413 (MISC_REGISTERS_RESET_REG_2_RST_BMAC0
<< port
));
415 /* enable access for bmac registers */
416 REG_WR(bp
, NIG_REG_BMAC0_REGS_OUT_EN
+ port
*4, 0x1);
421 REG_WR_DMAE(bp
, bmac_addr
+
422 BIGMAC_REGISTER_BMAC_XGXS_CONTROL
,
426 wb_data
[0] = ((params
->mac_addr
[2] << 24) |
427 (params
->mac_addr
[3] << 16) |
428 (params
->mac_addr
[4] << 8) |
429 params
->mac_addr
[5]);
430 wb_data
[1] = ((params
->mac_addr
[0] << 8) |
431 params
->mac_addr
[1]);
432 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC_REGISTER_TX_SOURCE_ADDR
,
437 if (vars
->flow_ctrl
& BNX2X_FLOW_CTRL_TX
)
441 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC_REGISTER_TX_CONTROL
,
448 DP(NETIF_MSG_LINK
, "enable bmac loopback\n");
452 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC_REGISTER_BMAC_CONTROL
,
456 wb_data
[0] = ETH_MAX_JUMBO_PACKET_SIZE
+ ETH_OVREHEAD
;
458 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC_REGISTER_RX_MAX_SIZE
,
461 /* rx control set to don't strip crc */
463 if (vars
->flow_ctrl
& BNX2X_FLOW_CTRL_RX
)
467 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC_REGISTER_RX_CONTROL
,
471 wb_data
[0] = ETH_MAX_JUMBO_PACKET_SIZE
+ ETH_OVREHEAD
;
473 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC_REGISTER_TX_MAX_SIZE
,
476 /* set cnt max size */
477 wb_data
[0] = ETH_MAX_JUMBO_PACKET_SIZE
+ ETH_OVREHEAD
;
479 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC_REGISTER_CNT_MAX_SIZE
,
483 wb_data
[0] = 0x1000200;
485 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC_REGISTER_RX_LLFC_MSG_FLDS
,
487 /* fix for emulation */
488 if (CHIP_REV_IS_EMUL(bp
)) {
492 bmac_addr
+ BIGMAC_REGISTER_TX_PAUSE_THRESHOLD
,
496 REG_WR(bp
, NIG_REG_XGXS_SERDES0_MODE_SEL
+ port
*4, 0x1);
497 REG_WR(bp
, NIG_REG_XGXS_LANE_SEL_P0
+ port
*4, 0x0);
498 REG_WR(bp
, NIG_REG_EGRESS_EMAC0_PORT
+ port
*4, 0x0);
500 if (vars
->flow_ctrl
& BNX2X_FLOW_CTRL_TX
)
502 REG_WR(bp
, NIG_REG_BMAC0_PAUSE_OUT_EN
+ port
*4, val
);
503 REG_WR(bp
, NIG_REG_EGRESS_EMAC0_OUT_EN
+ port
*4, 0x0);
504 REG_WR(bp
, NIG_REG_EMAC0_IN_EN
+ port
*4, 0x0);
505 REG_WR(bp
, NIG_REG_EMAC0_PAUSE_OUT_EN
+ port
*4, 0x0);
506 REG_WR(bp
, NIG_REG_BMAC0_IN_EN
+ port
*4, 0x1);
507 REG_WR(bp
, NIG_REG_BMAC0_OUT_EN
+ port
*4, 0x1);
509 vars
->mac_type
= MAC_TYPE_BMAC
;
513 static void bnx2x_serdes_deassert(struct bnx2x
*bp
, u8 port
)
517 DP(NETIF_MSG_LINK
, "bnx2x_serdes_deassert\n");
519 val
= SERDES_RESET_BITS
<< (port
*16);
521 /* reset and unreset the SerDes/XGXS */
522 REG_WR(bp
, GRCBASE_MISC
+ MISC_REGISTERS_RESET_REG_3_CLEAR
, val
);
524 REG_WR(bp
, GRCBASE_MISC
+ MISC_REGISTERS_RESET_REG_3_SET
, val
);
526 bnx2x_set_serdes_access(bp
, port
);
528 REG_WR(bp
, NIG_REG_SERDES0_CTRL_MD_DEVAD
+
530 DEFAULT_PHY_DEV_ADDR
);
533 static void bnx2x_xgxs_deassert(struct link_params
*params
)
535 struct bnx2x
*bp
= params
->bp
;
538 DP(NETIF_MSG_LINK
, "bnx2x_xgxs_deassert\n");
541 val
= XGXS_RESET_BITS
<< (port
*16);
543 /* reset and unreset the SerDes/XGXS */
544 REG_WR(bp
, GRCBASE_MISC
+ MISC_REGISTERS_RESET_REG_3_CLEAR
, val
);
546 REG_WR(bp
, GRCBASE_MISC
+ MISC_REGISTERS_RESET_REG_3_SET
, val
);
548 REG_WR(bp
, NIG_REG_XGXS0_CTRL_MD_ST
+
550 REG_WR(bp
, NIG_REG_XGXS0_CTRL_MD_DEVAD
+ port
*0x18,
551 params
->phy
[INT_PHY
].def_md_devad
);
553 void bnx2x_link_status_update(struct link_params
*params
,
554 struct link_vars
*vars
)
556 struct bnx2x
*bp
= params
->bp
;
558 u8 port
= params
->port
;
560 if (params
->switch_cfg
== SWITCH_CFG_1G
)
561 vars
->phy_flags
= PHY_SERDES_FLAG
;
563 vars
->phy_flags
= PHY_XGXS_FLAG
;
564 vars
->link_status
= REG_RD(bp
, params
->shmem_base
+
565 offsetof(struct shmem_region
,
566 port_mb
[port
].link_status
));
568 vars
->link_up
= (vars
->link_status
& LINK_STATUS_LINK_UP
);
571 DP(NETIF_MSG_LINK
, "phy link up\n");
573 vars
->phy_link_up
= 1;
574 vars
->duplex
= DUPLEX_FULL
;
575 switch (vars
->link_status
&
576 LINK_STATUS_SPEED_AND_DUPLEX_MASK
) {
578 vars
->duplex
= DUPLEX_HALF
;
581 vars
->line_speed
= SPEED_10
;
585 vars
->duplex
= DUPLEX_HALF
;
589 vars
->line_speed
= SPEED_100
;
593 vars
->duplex
= DUPLEX_HALF
;
596 vars
->line_speed
= SPEED_1000
;
600 vars
->duplex
= DUPLEX_HALF
;
603 vars
->line_speed
= SPEED_2500
;
607 vars
->line_speed
= SPEED_10000
;
611 vars
->line_speed
= SPEED_12000
;
615 vars
->line_speed
= SPEED_12500
;
619 vars
->line_speed
= SPEED_13000
;
623 vars
->line_speed
= SPEED_15000
;
627 vars
->line_speed
= SPEED_16000
;
635 if (vars
->link_status
& LINK_STATUS_TX_FLOW_CONTROL_ENABLED
)
636 vars
->flow_ctrl
|= BNX2X_FLOW_CTRL_TX
;
638 if (vars
->link_status
& LINK_STATUS_RX_FLOW_CONTROL_ENABLED
)
639 vars
->flow_ctrl
|= BNX2X_FLOW_CTRL_RX
;
641 if (!vars
->flow_ctrl
)
642 vars
->flow_ctrl
= BNX2X_FLOW_CTRL_NONE
;
644 if (vars
->line_speed
&&
645 ((vars
->line_speed
== SPEED_10
) ||
646 (vars
->line_speed
== SPEED_100
))) {
647 vars
->phy_flags
|= PHY_SGMII_FLAG
;
649 vars
->phy_flags
&= ~PHY_SGMII_FLAG
;
652 /* anything 10 and over uses the bmac */
653 link_10g
= ((vars
->line_speed
== SPEED_10000
) ||
654 (vars
->line_speed
== SPEED_12000
) ||
655 (vars
->line_speed
== SPEED_12500
) ||
656 (vars
->line_speed
== SPEED_13000
) ||
657 (vars
->line_speed
== SPEED_15000
) ||
658 (vars
->line_speed
== SPEED_16000
));
660 vars
->mac_type
= MAC_TYPE_BMAC
;
662 vars
->mac_type
= MAC_TYPE_EMAC
;
664 } else { /* link down */
665 DP(NETIF_MSG_LINK
, "phy link down\n");
667 vars
->phy_link_up
= 0;
669 vars
->line_speed
= 0;
670 vars
->duplex
= DUPLEX_FULL
;
671 vars
->flow_ctrl
= BNX2X_FLOW_CTRL_NONE
;
673 /* indicate no mac active */
674 vars
->mac_type
= MAC_TYPE_NONE
;
677 DP(NETIF_MSG_LINK
, "link_status 0x%x phy_link_up %x\n",
678 vars
->link_status
, vars
->phy_link_up
);
679 DP(NETIF_MSG_LINK
, "line_speed %x duplex %x flow_ctrl 0x%x\n",
680 vars
->line_speed
, vars
->duplex
, vars
->flow_ctrl
);
683 static void bnx2x_update_mng(struct link_params
*params
, u32 link_status
)
685 struct bnx2x
*bp
= params
->bp
;
687 REG_WR(bp
, params
->shmem_base
+
688 offsetof(struct shmem_region
,
689 port_mb
[params
->port
].link_status
),
693 static void bnx2x_bmac_rx_disable(struct bnx2x
*bp
, u8 port
)
695 u32 bmac_addr
= port
? NIG_REG_INGRESS_BMAC1_MEM
:
696 NIG_REG_INGRESS_BMAC0_MEM
;
698 u32 nig_bmac_enable
= REG_RD(bp
, NIG_REG_BMAC0_REGS_OUT_EN
+ port
*4);
700 /* Only if the bmac is out of reset */
701 if (REG_RD(bp
, MISC_REG_RESET_REG_2
) &
702 (MISC_REGISTERS_RESET_REG_2_RST_BMAC0
<< port
) &&
705 /* Clear Rx Enable bit in BMAC_CONTROL register */
706 REG_RD_DMAE(bp
, bmac_addr
+ BIGMAC_REGISTER_BMAC_CONTROL
,
708 wb_data
[0] &= ~BMAC_CONTROL_RX_ENABLE
;
709 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC_REGISTER_BMAC_CONTROL
,
716 static u8
bnx2x_pbf_update(struct link_params
*params
, u32 flow_ctrl
,
719 struct bnx2x
*bp
= params
->bp
;
720 u8 port
= params
->port
;
725 REG_WR(bp
, PBF_REG_DISABLE_NEW_TASK_PROC_P0
+ port
*4, 0x1);
727 /* wait for init credit */
728 init_crd
= REG_RD(bp
, PBF_REG_P0_INIT_CRD
+ port
*4);
729 crd
= REG_RD(bp
, PBF_REG_P0_CREDIT
+ port
*8);
730 DP(NETIF_MSG_LINK
, "init_crd 0x%x crd 0x%x\n", init_crd
, crd
);
732 while ((init_crd
!= crd
) && count
) {
735 crd
= REG_RD(bp
, PBF_REG_P0_CREDIT
+ port
*8);
738 crd
= REG_RD(bp
, PBF_REG_P0_CREDIT
+ port
*8);
739 if (init_crd
!= crd
) {
740 DP(NETIF_MSG_LINK
, "BUG! init_crd 0x%x != crd 0x%x\n",
745 if (flow_ctrl
& BNX2X_FLOW_CTRL_RX
||
746 line_speed
== SPEED_10
||
747 line_speed
== SPEED_100
||
748 line_speed
== SPEED_1000
||
749 line_speed
== SPEED_2500
) {
750 REG_WR(bp
, PBF_REG_P0_PAUSE_ENABLE
+ port
*4, 1);
751 /* update threshold */
752 REG_WR(bp
, PBF_REG_P0_ARB_THRSH
+ port
*4, 0);
753 /* update init credit */
754 init_crd
= 778; /* (800-18-4) */
757 u32 thresh
= (ETH_MAX_JUMBO_PACKET_SIZE
+
759 REG_WR(bp
, PBF_REG_P0_PAUSE_ENABLE
+ port
*4, 0);
760 /* update threshold */
761 REG_WR(bp
, PBF_REG_P0_ARB_THRSH
+ port
*4, thresh
);
762 /* update init credit */
763 switch (line_speed
) {
765 init_crd
= thresh
+ 553 - 22;
769 init_crd
= thresh
+ 664 - 22;
773 init_crd
= thresh
+ 742 - 22;
777 init_crd
= thresh
+ 778 - 22;
780 DP(NETIF_MSG_LINK
, "Invalid line_speed 0x%x\n",
785 REG_WR(bp
, PBF_REG_P0_INIT_CRD
+ port
*4, init_crd
);
786 DP(NETIF_MSG_LINK
, "PBF updated to speed %d credit %d\n",
787 line_speed
, init_crd
);
789 /* probe the credit changes */
790 REG_WR(bp
, PBF_REG_INIT_P0
+ port
*4, 0x1);
792 REG_WR(bp
, PBF_REG_INIT_P0
+ port
*4, 0x0);
795 REG_WR(bp
, PBF_REG_DISABLE_NEW_TASK_PROC_P0
+ port
*4, 0x0);
799 static u32
bnx2x_get_emac_base(struct bnx2x
*bp
,
800 u32 mdc_mdio_access
, u8 port
)
803 switch (mdc_mdio_access
) {
804 case SHARED_HW_CFG_MDC_MDIO_ACCESS1_PHY_TYPE
:
806 case SHARED_HW_CFG_MDC_MDIO_ACCESS1_EMAC0
:
807 if (REG_RD(bp
, NIG_REG_PORT_SWAP
))
808 emac_base
= GRCBASE_EMAC1
;
810 emac_base
= GRCBASE_EMAC0
;
812 case SHARED_HW_CFG_MDC_MDIO_ACCESS1_EMAC1
:
813 if (REG_RD(bp
, NIG_REG_PORT_SWAP
))
814 emac_base
= GRCBASE_EMAC0
;
816 emac_base
= GRCBASE_EMAC1
;
818 case SHARED_HW_CFG_MDC_MDIO_ACCESS1_BOTH
:
819 emac_base
= (port
) ? GRCBASE_EMAC1
: GRCBASE_EMAC0
;
821 case SHARED_HW_CFG_MDC_MDIO_ACCESS1_SWAPPED
:
822 emac_base
= (port
) ? GRCBASE_EMAC0
: GRCBASE_EMAC1
;
831 u8
bnx2x_cl45_write(struct bnx2x
*bp
, struct bnx2x_phy
*phy
,
832 u8 devad
, u16 reg
, u16 val
)
837 /* set clause 45 mode, slow down the MDIO clock to 2.5MHz
838 * (a value of 49==0x31) and make sure that the AUTO poll is off
841 saved_mode
= REG_RD(bp
, phy
->mdio_ctrl
+ EMAC_REG_EMAC_MDIO_MODE
);
842 tmp
= saved_mode
& ~(EMAC_MDIO_MODE_AUTO_POLL
|
843 EMAC_MDIO_MODE_CLOCK_CNT
);
844 tmp
|= (EMAC_MDIO_MODE_CLAUSE_45
|
845 (49 << EMAC_MDIO_MODE_CLOCK_CNT_BITSHIFT
));
846 REG_WR(bp
, phy
->mdio_ctrl
+ EMAC_REG_EMAC_MDIO_MODE
, tmp
);
847 REG_RD(bp
, phy
->mdio_ctrl
+ EMAC_REG_EMAC_MDIO_MODE
);
852 tmp
= ((phy
->addr
<< 21) | (devad
<< 16) | reg
|
853 EMAC_MDIO_COMM_COMMAND_ADDRESS
|
854 EMAC_MDIO_COMM_START_BUSY
);
855 REG_WR(bp
, phy
->mdio_ctrl
+ EMAC_REG_EMAC_MDIO_COMM
, tmp
);
857 for (i
= 0; i
< 50; i
++) {
860 tmp
= REG_RD(bp
, phy
->mdio_ctrl
+
861 EMAC_REG_EMAC_MDIO_COMM
);
862 if (!(tmp
& EMAC_MDIO_COMM_START_BUSY
)) {
867 if (tmp
& EMAC_MDIO_COMM_START_BUSY
) {
868 DP(NETIF_MSG_LINK
, "write phy register failed\n");
872 tmp
= ((phy
->addr
<< 21) | (devad
<< 16) | val
|
873 EMAC_MDIO_COMM_COMMAND_WRITE_45
|
874 EMAC_MDIO_COMM_START_BUSY
);
875 REG_WR(bp
, phy
->mdio_ctrl
+ EMAC_REG_EMAC_MDIO_COMM
, tmp
);
877 for (i
= 0; i
< 50; i
++) {
880 tmp
= REG_RD(bp
, phy
->mdio_ctrl
+
881 EMAC_REG_EMAC_MDIO_COMM
);
882 if (!(tmp
& EMAC_MDIO_COMM_START_BUSY
)) {
887 if (tmp
& EMAC_MDIO_COMM_START_BUSY
) {
888 DP(NETIF_MSG_LINK
, "write phy register failed\n");
893 /* Restore the saved mode */
894 REG_WR(bp
, phy
->mdio_ctrl
+ EMAC_REG_EMAC_MDIO_MODE
, saved_mode
);
899 u8
bnx2x_cl45_read(struct bnx2x
*bp
, struct bnx2x_phy
*phy
,
900 u8 devad
, u16 reg
, u16
*ret_val
)
906 /* set clause 45 mode, slow down the MDIO clock to 2.5MHz
907 * (a value of 49==0x31) and make sure that the AUTO poll is off
910 saved_mode
= REG_RD(bp
, phy
->mdio_ctrl
+ EMAC_REG_EMAC_MDIO_MODE
);
911 val
= saved_mode
& ~((EMAC_MDIO_MODE_AUTO_POLL
|
912 EMAC_MDIO_MODE_CLOCK_CNT
));
913 val
|= (EMAC_MDIO_MODE_CLAUSE_45
|
914 (49L << EMAC_MDIO_MODE_CLOCK_CNT_BITSHIFT
));
915 REG_WR(bp
, phy
->mdio_ctrl
+ EMAC_REG_EMAC_MDIO_MODE
, val
);
916 REG_RD(bp
, phy
->mdio_ctrl
+ EMAC_REG_EMAC_MDIO_MODE
);
920 val
= ((phy
->addr
<< 21) | (devad
<< 16) | reg
|
921 EMAC_MDIO_COMM_COMMAND_ADDRESS
|
922 EMAC_MDIO_COMM_START_BUSY
);
923 REG_WR(bp
, phy
->mdio_ctrl
+ EMAC_REG_EMAC_MDIO_COMM
, val
);
925 for (i
= 0; i
< 50; i
++) {
928 val
= REG_RD(bp
, phy
->mdio_ctrl
+ EMAC_REG_EMAC_MDIO_COMM
);
929 if (!(val
& EMAC_MDIO_COMM_START_BUSY
)) {
934 if (val
& EMAC_MDIO_COMM_START_BUSY
) {
935 DP(NETIF_MSG_LINK
, "read phy register failed\n");
942 val
= ((phy
->addr
<< 21) | (devad
<< 16) |
943 EMAC_MDIO_COMM_COMMAND_READ_45
|
944 EMAC_MDIO_COMM_START_BUSY
);
945 REG_WR(bp
, phy
->mdio_ctrl
+ EMAC_REG_EMAC_MDIO_COMM
, val
);
947 for (i
= 0; i
< 50; i
++) {
950 val
= REG_RD(bp
, phy
->mdio_ctrl
+
951 EMAC_REG_EMAC_MDIO_COMM
);
952 if (!(val
& EMAC_MDIO_COMM_START_BUSY
)) {
953 *ret_val
= (u16
)(val
& EMAC_MDIO_COMM_DATA
);
957 if (val
& EMAC_MDIO_COMM_START_BUSY
) {
958 DP(NETIF_MSG_LINK
, "read phy register failed\n");
965 /* Restore the saved mode */
966 REG_WR(bp
, phy
->mdio_ctrl
+ EMAC_REG_EMAC_MDIO_MODE
, saved_mode
);
971 u8
bnx2x_phy_read(struct link_params
*params
, u8 phy_addr
,
972 u8 devad
, u16 reg
, u16
*ret_val
)
976 * Probe for the phy according to the given phy_addr, and execute
977 * the read request on it
979 for (phy_index
= 0; phy_index
< params
->num_phys
; phy_index
++) {
980 if (params
->phy
[phy_index
].addr
== phy_addr
) {
981 return bnx2x_cl45_read(params
->bp
,
982 ¶ms
->phy
[phy_index
], devad
,
989 u8
bnx2x_phy_write(struct link_params
*params
, u8 phy_addr
,
990 u8 devad
, u16 reg
, u16 val
)
994 * Probe for the phy according to the given phy_addr, and execute
995 * the write request on it
997 for (phy_index
= 0; phy_index
< params
->num_phys
; phy_index
++) {
998 if (params
->phy
[phy_index
].addr
== phy_addr
) {
999 return bnx2x_cl45_write(params
->bp
,
1000 ¶ms
->phy
[phy_index
], devad
,
1007 static void bnx2x_set_aer_mmd(struct link_params
*params
,
1008 struct bnx2x_phy
*phy
)
1010 struct bnx2x
*bp
= params
->bp
;
1014 ser_lane
= ((params
->lane_config
&
1015 PORT_HW_CFG_LANE_SWAP_CFG_MASTER_MASK
) >>
1016 PORT_HW_CFG_LANE_SWAP_CFG_MASTER_SHIFT
);
1018 offset
= (phy
->type
== PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT
) ?
1019 (phy
->addr
+ ser_lane
) : 0;
1021 CL45_WR_OVER_CL22(bp
, phy
,
1022 MDIO_REG_BANK_AER_BLOCK
,
1023 MDIO_AER_BLOCK_AER_REG
, 0x3800 + offset
);
1026 static void bnx2x_set_master_ln(struct link_params
*params
,
1027 struct bnx2x_phy
*phy
)
1029 struct bnx2x
*bp
= params
->bp
;
1030 u16 new_master_ln
, ser_lane
;
1031 ser_lane
= ((params
->lane_config
&
1032 PORT_HW_CFG_LANE_SWAP_CFG_MASTER_MASK
) >>
1033 PORT_HW_CFG_LANE_SWAP_CFG_MASTER_SHIFT
);
1035 /* set the master_ln for AN */
1036 CL45_RD_OVER_CL22(bp
, phy
,
1037 MDIO_REG_BANK_XGXS_BLOCK2
,
1038 MDIO_XGXS_BLOCK2_TEST_MODE_LANE
,
1041 CL45_WR_OVER_CL22(bp
, phy
,
1042 MDIO_REG_BANK_XGXS_BLOCK2
,
1043 MDIO_XGXS_BLOCK2_TEST_MODE_LANE
,
1044 (new_master_ln
| ser_lane
));
1047 static u8
bnx2x_reset_unicore(struct link_params
*params
,
1048 struct bnx2x_phy
*phy
,
1051 struct bnx2x
*bp
= params
->bp
;
1055 CL45_RD_OVER_CL22(bp
, phy
,
1056 MDIO_REG_BANK_COMBO_IEEE0
,
1057 MDIO_COMBO_IEEE0_MII_CONTROL
, &mii_control
);
1059 /* reset the unicore */
1060 CL45_WR_OVER_CL22(bp
, phy
,
1061 MDIO_REG_BANK_COMBO_IEEE0
,
1062 MDIO_COMBO_IEEE0_MII_CONTROL
,
1064 MDIO_COMBO_IEEO_MII_CONTROL_RESET
));
1066 bnx2x_set_serdes_access(bp
, params
->port
);
1068 /* wait for the reset to self clear */
1069 for (i
= 0; i
< MDIO_ACCESS_TIMEOUT
; i
++) {
1072 /* the reset erased the previous bank value */
1073 CL45_RD_OVER_CL22(bp
, phy
,
1074 MDIO_REG_BANK_COMBO_IEEE0
,
1075 MDIO_COMBO_IEEE0_MII_CONTROL
,
1078 if (!(mii_control
& MDIO_COMBO_IEEO_MII_CONTROL_RESET
)) {
1084 DP(NETIF_MSG_LINK
, "BUG! XGXS is still in reset!\n");
1089 static void bnx2x_set_swap_lanes(struct link_params
*params
,
1090 struct bnx2x_phy
*phy
)
1092 struct bnx2x
*bp
= params
->bp
;
1093 /* Each two bits represents a lane number:
1094 No swap is 0123 => 0x1b no need to enable the swap */
1095 u16 ser_lane
, rx_lane_swap
, tx_lane_swap
;
1097 ser_lane
= ((params
->lane_config
&
1098 PORT_HW_CFG_LANE_SWAP_CFG_MASTER_MASK
) >>
1099 PORT_HW_CFG_LANE_SWAP_CFG_MASTER_SHIFT
);
1100 rx_lane_swap
= ((params
->lane_config
&
1101 PORT_HW_CFG_LANE_SWAP_CFG_RX_MASK
) >>
1102 PORT_HW_CFG_LANE_SWAP_CFG_RX_SHIFT
);
1103 tx_lane_swap
= ((params
->lane_config
&
1104 PORT_HW_CFG_LANE_SWAP_CFG_TX_MASK
) >>
1105 PORT_HW_CFG_LANE_SWAP_CFG_TX_SHIFT
);
1107 if (rx_lane_swap
!= 0x1b) {
1108 CL45_WR_OVER_CL22(bp
, phy
,
1109 MDIO_REG_BANK_XGXS_BLOCK2
,
1110 MDIO_XGXS_BLOCK2_RX_LN_SWAP
,
1112 MDIO_XGXS_BLOCK2_RX_LN_SWAP_ENABLE
|
1113 MDIO_XGXS_BLOCK2_RX_LN_SWAP_FORCE_ENABLE
));
1115 CL45_WR_OVER_CL22(bp
, phy
,
1116 MDIO_REG_BANK_XGXS_BLOCK2
,
1117 MDIO_XGXS_BLOCK2_RX_LN_SWAP
, 0);
1120 if (tx_lane_swap
!= 0x1b) {
1121 CL45_WR_OVER_CL22(bp
, phy
,
1122 MDIO_REG_BANK_XGXS_BLOCK2
,
1123 MDIO_XGXS_BLOCK2_TX_LN_SWAP
,
1125 MDIO_XGXS_BLOCK2_TX_LN_SWAP_ENABLE
));
1127 CL45_WR_OVER_CL22(bp
, phy
,
1128 MDIO_REG_BANK_XGXS_BLOCK2
,
1129 MDIO_XGXS_BLOCK2_TX_LN_SWAP
, 0);
1133 static void bnx2x_set_parallel_detection(struct bnx2x_phy
*phy
,
1134 struct link_params
*params
)
1136 struct bnx2x
*bp
= params
->bp
;
1138 CL45_RD_OVER_CL22(bp
, phy
,
1139 MDIO_REG_BANK_SERDES_DIGITAL
,
1140 MDIO_SERDES_DIGITAL_A_1000X_CONTROL2
,
1142 if (phy
->speed_cap_mask
& PORT_HW_CFG_SPEED_CAPABILITY_D0_1G
)
1143 control2
|= MDIO_SERDES_DIGITAL_A_1000X_CONTROL2_PRL_DT_EN
;
1145 control2
&= ~MDIO_SERDES_DIGITAL_A_1000X_CONTROL2_PRL_DT_EN
;
1146 DP(NETIF_MSG_LINK
, "phy->speed_cap_mask = 0x%x, control2 = 0x%x\n",
1147 phy
->speed_cap_mask
, control2
);
1148 CL45_WR_OVER_CL22(bp
, phy
,
1149 MDIO_REG_BANK_SERDES_DIGITAL
,
1150 MDIO_SERDES_DIGITAL_A_1000X_CONTROL2
,
1153 if ((phy
->type
== PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT
) &&
1154 (phy
->speed_cap_mask
&
1155 PORT_HW_CFG_SPEED_CAPABILITY_D0_10G
)) {
1156 DP(NETIF_MSG_LINK
, "XGXS\n");
1158 CL45_WR_OVER_CL22(bp
, phy
,
1159 MDIO_REG_BANK_10G_PARALLEL_DETECT
,
1160 MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_LINK
,
1161 MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_LINK_CNT
);
1163 CL45_RD_OVER_CL22(bp
, phy
,
1164 MDIO_REG_BANK_10G_PARALLEL_DETECT
,
1165 MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_CONTROL
,
1170 MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_CONTROL_PARDET10G_EN
;
1172 CL45_WR_OVER_CL22(bp
, phy
,
1173 MDIO_REG_BANK_10G_PARALLEL_DETECT
,
1174 MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_CONTROL
,
1177 /* Disable parallel detection of HiG */
1178 CL45_WR_OVER_CL22(bp
, phy
,
1179 MDIO_REG_BANK_XGXS_BLOCK2
,
1180 MDIO_XGXS_BLOCK2_UNICORE_MODE_10G
,
1181 MDIO_XGXS_BLOCK2_UNICORE_MODE_10G_CX4_XGXS
|
1182 MDIO_XGXS_BLOCK2_UNICORE_MODE_10G_HIGIG_XGXS
);
1186 static void bnx2x_set_autoneg(struct bnx2x_phy
*phy
,
1187 struct link_params
*params
,
1188 struct link_vars
*vars
,
1191 struct bnx2x
*bp
= params
->bp
;
1195 CL45_RD_OVER_CL22(bp
, phy
,
1196 MDIO_REG_BANK_COMBO_IEEE0
,
1197 MDIO_COMBO_IEEE0_MII_CONTROL
, ®_val
);
1199 /* CL37 Autoneg Enabled */
1200 if (vars
->line_speed
== SPEED_AUTO_NEG
)
1201 reg_val
|= MDIO_COMBO_IEEO_MII_CONTROL_AN_EN
;
1202 else /* CL37 Autoneg Disabled */
1203 reg_val
&= ~(MDIO_COMBO_IEEO_MII_CONTROL_AN_EN
|
1204 MDIO_COMBO_IEEO_MII_CONTROL_RESTART_AN
);
1206 CL45_WR_OVER_CL22(bp
, phy
,
1207 MDIO_REG_BANK_COMBO_IEEE0
,
1208 MDIO_COMBO_IEEE0_MII_CONTROL
, reg_val
);
1210 /* Enable/Disable Autodetection */
1212 CL45_RD_OVER_CL22(bp
, phy
,
1213 MDIO_REG_BANK_SERDES_DIGITAL
,
1214 MDIO_SERDES_DIGITAL_A_1000X_CONTROL1
, ®_val
);
1215 reg_val
&= ~(MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_SIGNAL_DETECT_EN
|
1216 MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_INVERT_SIGNAL_DETECT
);
1217 reg_val
|= MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_FIBER_MODE
;
1218 if (vars
->line_speed
== SPEED_AUTO_NEG
)
1219 reg_val
|= MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_AUTODET
;
1221 reg_val
&= ~MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_AUTODET
;
1223 CL45_WR_OVER_CL22(bp
, phy
,
1224 MDIO_REG_BANK_SERDES_DIGITAL
,
1225 MDIO_SERDES_DIGITAL_A_1000X_CONTROL1
, reg_val
);
1227 /* Enable TetonII and BAM autoneg */
1228 CL45_RD_OVER_CL22(bp
, phy
,
1229 MDIO_REG_BANK_BAM_NEXT_PAGE
,
1230 MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL
,
1232 if (vars
->line_speed
== SPEED_AUTO_NEG
) {
1233 /* Enable BAM aneg Mode and TetonII aneg Mode */
1234 reg_val
|= (MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL_BAM_MODE
|
1235 MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL_TETON_AN
);
1237 /* TetonII and BAM Autoneg Disabled */
1238 reg_val
&= ~(MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL_BAM_MODE
|
1239 MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL_TETON_AN
);
1241 CL45_WR_OVER_CL22(bp
, phy
,
1242 MDIO_REG_BANK_BAM_NEXT_PAGE
,
1243 MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL
,
1247 /* Enable Cl73 FSM status bits */
1248 CL45_WR_OVER_CL22(bp
, phy
,
1249 MDIO_REG_BANK_CL73_USERB0
,
1250 MDIO_CL73_USERB0_CL73_UCTRL
,
1253 /* Enable BAM Station Manager*/
1254 CL45_WR_OVER_CL22(bp
, phy
,
1255 MDIO_REG_BANK_CL73_USERB0
,
1256 MDIO_CL73_USERB0_CL73_BAM_CTRL1
,
1257 MDIO_CL73_USERB0_CL73_BAM_CTRL1_BAM_EN
|
1258 MDIO_CL73_USERB0_CL73_BAM_CTRL1_BAM_STATION_MNGR_EN
|
1259 MDIO_CL73_USERB0_CL73_BAM_CTRL1_BAM_NP_AFTER_BP_EN
);
1261 /* Advertise CL73 link speeds */
1262 CL45_RD_OVER_CL22(bp
, phy
,
1263 MDIO_REG_BANK_CL73_IEEEB1
,
1264 MDIO_CL73_IEEEB1_AN_ADV2
,
1266 if (phy
->speed_cap_mask
&
1267 PORT_HW_CFG_SPEED_CAPABILITY_D0_10G
)
1268 reg_val
|= MDIO_CL73_IEEEB1_AN_ADV2_ADVR_10G_KX4
;
1269 if (phy
->speed_cap_mask
&
1270 PORT_HW_CFG_SPEED_CAPABILITY_D0_1G
)
1271 reg_val
|= MDIO_CL73_IEEEB1_AN_ADV2_ADVR_1000M_KX
;
1273 CL45_WR_OVER_CL22(bp
, phy
,
1274 MDIO_REG_BANK_CL73_IEEEB1
,
1275 MDIO_CL73_IEEEB1_AN_ADV2
,
1278 /* CL73 Autoneg Enabled */
1279 reg_val
= MDIO_CL73_IEEEB0_CL73_AN_CONTROL_AN_EN
;
1281 } else /* CL73 Autoneg Disabled */
1284 CL45_WR_OVER_CL22(bp
, phy
,
1285 MDIO_REG_BANK_CL73_IEEEB0
,
1286 MDIO_CL73_IEEEB0_CL73_AN_CONTROL
, reg_val
);
1289 /* program SerDes, forced speed */
1290 static void bnx2x_program_serdes(struct bnx2x_phy
*phy
,
1291 struct link_params
*params
,
1292 struct link_vars
*vars
)
1294 struct bnx2x
*bp
= params
->bp
;
1297 /* program duplex, disable autoneg and sgmii*/
1298 CL45_RD_OVER_CL22(bp
, phy
,
1299 MDIO_REG_BANK_COMBO_IEEE0
,
1300 MDIO_COMBO_IEEE0_MII_CONTROL
, ®_val
);
1301 reg_val
&= ~(MDIO_COMBO_IEEO_MII_CONTROL_FULL_DUPLEX
|
1302 MDIO_COMBO_IEEO_MII_CONTROL_AN_EN
|
1303 MDIO_COMBO_IEEO_MII_CONTROL_MAN_SGMII_SP_MASK
);
1304 if (phy
->req_duplex
== DUPLEX_FULL
)
1305 reg_val
|= MDIO_COMBO_IEEO_MII_CONTROL_FULL_DUPLEX
;
1306 CL45_WR_OVER_CL22(bp
, phy
,
1307 MDIO_REG_BANK_COMBO_IEEE0
,
1308 MDIO_COMBO_IEEE0_MII_CONTROL
, reg_val
);
1311 - needed only if the speed is greater than 1G (2.5G or 10G) */
1312 CL45_RD_OVER_CL22(bp
, phy
,
1313 MDIO_REG_BANK_SERDES_DIGITAL
,
1314 MDIO_SERDES_DIGITAL_MISC1
, ®_val
);
1315 /* clearing the speed value before setting the right speed */
1316 DP(NETIF_MSG_LINK
, "MDIO_REG_BANK_SERDES_DIGITAL = 0x%x\n", reg_val
);
1318 reg_val
&= ~(MDIO_SERDES_DIGITAL_MISC1_FORCE_SPEED_MASK
|
1319 MDIO_SERDES_DIGITAL_MISC1_FORCE_SPEED_SEL
);
1321 if (!((vars
->line_speed
== SPEED_1000
) ||
1322 (vars
->line_speed
== SPEED_100
) ||
1323 (vars
->line_speed
== SPEED_10
))) {
1325 reg_val
|= (MDIO_SERDES_DIGITAL_MISC1_REFCLK_SEL_156_25M
|
1326 MDIO_SERDES_DIGITAL_MISC1_FORCE_SPEED_SEL
);
1327 if (vars
->line_speed
== SPEED_10000
)
1329 MDIO_SERDES_DIGITAL_MISC1_FORCE_SPEED_10G_CX4
;
1330 if (vars
->line_speed
== SPEED_13000
)
1332 MDIO_SERDES_DIGITAL_MISC1_FORCE_SPEED_13G
;
1335 CL45_WR_OVER_CL22(bp
, phy
,
1336 MDIO_REG_BANK_SERDES_DIGITAL
,
1337 MDIO_SERDES_DIGITAL_MISC1
, reg_val
);
1341 static void bnx2x_set_brcm_cl37_advertisment(struct bnx2x_phy
*phy
,
1342 struct link_params
*params
)
1344 struct bnx2x
*bp
= params
->bp
;
1347 /* configure the 48 bits for BAM AN */
1349 /* set extended capabilities */
1350 if (phy
->speed_cap_mask
& PORT_HW_CFG_SPEED_CAPABILITY_D0_2_5G
)
1351 val
|= MDIO_OVER_1G_UP1_2_5G
;
1352 if (phy
->speed_cap_mask
& PORT_HW_CFG_SPEED_CAPABILITY_D0_10G
)
1353 val
|= MDIO_OVER_1G_UP1_10G
;
1354 CL45_WR_OVER_CL22(bp
, phy
,
1355 MDIO_REG_BANK_OVER_1G
,
1356 MDIO_OVER_1G_UP1
, val
);
1358 CL45_WR_OVER_CL22(bp
, phy
,
1359 MDIO_REG_BANK_OVER_1G
,
1360 MDIO_OVER_1G_UP3
, 0x400);
1363 static void bnx2x_calc_ieee_aneg_adv(struct bnx2x_phy
*phy
,
1364 struct link_params
*params
, u16
*ieee_fc
)
1366 struct bnx2x
*bp
= params
->bp
;
1367 *ieee_fc
= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_FULL_DUPLEX
;
1368 /* resolve pause mode and advertisement
1369 * Please refer to Table 28B-3 of the 802.3ab-1999 spec */
1371 switch (phy
->req_flow_ctrl
) {
1372 case BNX2X_FLOW_CTRL_AUTO
:
1373 if (params
->req_fc_auto_adv
== BNX2X_FLOW_CTRL_BOTH
) {
1375 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH
;
1378 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC
;
1381 case BNX2X_FLOW_CTRL_TX
:
1383 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC
;
1386 case BNX2X_FLOW_CTRL_RX
:
1387 case BNX2X_FLOW_CTRL_BOTH
:
1388 *ieee_fc
|= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH
;
1391 case BNX2X_FLOW_CTRL_NONE
:
1393 *ieee_fc
|= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_NONE
;
1396 DP(NETIF_MSG_LINK
, "ieee_fc = 0x%x\n", *ieee_fc
);
1399 static void bnx2x_set_ieee_aneg_advertisment(struct bnx2x_phy
*phy
,
1400 struct link_params
*params
,
1403 struct bnx2x
*bp
= params
->bp
;
1405 /* for AN, we are always publishing full duplex */
1407 CL45_WR_OVER_CL22(bp
, phy
,
1408 MDIO_REG_BANK_COMBO_IEEE0
,
1409 MDIO_COMBO_IEEE0_AUTO_NEG_ADV
, ieee_fc
);
1410 CL45_RD_OVER_CL22(bp
, phy
,
1411 MDIO_REG_BANK_CL73_IEEEB1
,
1412 MDIO_CL73_IEEEB1_AN_ADV1
, &val
);
1413 val
&= ~MDIO_CL73_IEEEB1_AN_ADV1_PAUSE_BOTH
;
1414 val
|= ((ieee_fc
<<3) & MDIO_CL73_IEEEB1_AN_ADV1_PAUSE_MASK
);
1415 CL45_WR_OVER_CL22(bp
, phy
,
1416 MDIO_REG_BANK_CL73_IEEEB1
,
1417 MDIO_CL73_IEEEB1_AN_ADV1
, val
);
1420 static void bnx2x_restart_autoneg(struct bnx2x_phy
*phy
,
1421 struct link_params
*params
,
1424 struct bnx2x
*bp
= params
->bp
;
1427 DP(NETIF_MSG_LINK
, "bnx2x_restart_autoneg\n");
1428 /* Enable and restart BAM/CL37 aneg */
1431 CL45_RD_OVER_CL22(bp
, phy
,
1432 MDIO_REG_BANK_CL73_IEEEB0
,
1433 MDIO_CL73_IEEEB0_CL73_AN_CONTROL
,
1436 CL45_WR_OVER_CL22(bp
, phy
,
1437 MDIO_REG_BANK_CL73_IEEEB0
,
1438 MDIO_CL73_IEEEB0_CL73_AN_CONTROL
,
1440 MDIO_CL73_IEEEB0_CL73_AN_CONTROL_AN_EN
|
1441 MDIO_CL73_IEEEB0_CL73_AN_CONTROL_RESTART_AN
));
1444 CL45_RD_OVER_CL22(bp
, phy
,
1445 MDIO_REG_BANK_COMBO_IEEE0
,
1446 MDIO_COMBO_IEEE0_MII_CONTROL
,
1449 "bnx2x_restart_autoneg mii_control before = 0x%x\n",
1451 CL45_WR_OVER_CL22(bp
, phy
,
1452 MDIO_REG_BANK_COMBO_IEEE0
,
1453 MDIO_COMBO_IEEE0_MII_CONTROL
,
1455 MDIO_COMBO_IEEO_MII_CONTROL_AN_EN
|
1456 MDIO_COMBO_IEEO_MII_CONTROL_RESTART_AN
));
1460 static void bnx2x_initialize_sgmii_process(struct bnx2x_phy
*phy
,
1461 struct link_params
*params
,
1462 struct link_vars
*vars
)
1464 struct bnx2x
*bp
= params
->bp
;
1467 /* in SGMII mode, the unicore is always slave */
1469 CL45_RD_OVER_CL22(bp
, phy
,
1470 MDIO_REG_BANK_SERDES_DIGITAL
,
1471 MDIO_SERDES_DIGITAL_A_1000X_CONTROL1
,
1473 control1
|= MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_INVERT_SIGNAL_DETECT
;
1474 /* set sgmii mode (and not fiber) */
1475 control1
&= ~(MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_FIBER_MODE
|
1476 MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_AUTODET
|
1477 MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_MSTR_MODE
);
1478 CL45_WR_OVER_CL22(bp
, phy
,
1479 MDIO_REG_BANK_SERDES_DIGITAL
,
1480 MDIO_SERDES_DIGITAL_A_1000X_CONTROL1
,
1483 /* if forced speed */
1484 if (!(vars
->line_speed
== SPEED_AUTO_NEG
)) {
1485 /* set speed, disable autoneg */
1488 CL45_RD_OVER_CL22(bp
, phy
,
1489 MDIO_REG_BANK_COMBO_IEEE0
,
1490 MDIO_COMBO_IEEE0_MII_CONTROL
,
1492 mii_control
&= ~(MDIO_COMBO_IEEO_MII_CONTROL_AN_EN
|
1493 MDIO_COMBO_IEEO_MII_CONTROL_MAN_SGMII_SP_MASK
|
1494 MDIO_COMBO_IEEO_MII_CONTROL_FULL_DUPLEX
);
1496 switch (vars
->line_speed
) {
1499 MDIO_COMBO_IEEO_MII_CONTROL_MAN_SGMII_SP_100
;
1503 MDIO_COMBO_IEEO_MII_CONTROL_MAN_SGMII_SP_1000
;
1506 /* there is nothing to set for 10M */
1509 /* invalid speed for SGMII */
1510 DP(NETIF_MSG_LINK
, "Invalid line_speed 0x%x\n",
1515 /* setting the full duplex */
1516 if (phy
->req_duplex
== DUPLEX_FULL
)
1518 MDIO_COMBO_IEEO_MII_CONTROL_FULL_DUPLEX
;
1519 CL45_WR_OVER_CL22(bp
, phy
,
1520 MDIO_REG_BANK_COMBO_IEEE0
,
1521 MDIO_COMBO_IEEE0_MII_CONTROL
,
1524 } else { /* AN mode */
1525 /* enable and restart AN */
1526 bnx2x_restart_autoneg(phy
, params
, 0);
1535 static void bnx2x_pause_resolve(struct link_vars
*vars
, u32 pause_result
)
1537 switch (pause_result
) { /* ASYM P ASYM P */
1538 case 0xb: /* 1 0 1 1 */
1539 vars
->flow_ctrl
= BNX2X_FLOW_CTRL_TX
;
1542 case 0xe: /* 1 1 1 0 */
1543 vars
->flow_ctrl
= BNX2X_FLOW_CTRL_RX
;
1546 case 0x5: /* 0 1 0 1 */
1547 case 0x7: /* 0 1 1 1 */
1548 case 0xd: /* 1 1 0 1 */
1549 case 0xf: /* 1 1 1 1 */
1550 vars
->flow_ctrl
= BNX2X_FLOW_CTRL_BOTH
;
1556 if (pause_result
& (1<<0))
1557 vars
->link_status
|= LINK_STATUS_LINK_PARTNER_SYMMETRIC_PAUSE
;
1558 if (pause_result
& (1<<1))
1559 vars
->link_status
|= LINK_STATUS_LINK_PARTNER_ASYMMETRIC_PAUSE
;
1563 static u8
bnx2x_ext_phy_resolve_fc(struct bnx2x_phy
*phy
,
1564 struct link_params
*params
,
1565 struct link_vars
*vars
)
1567 struct bnx2x
*bp
= params
->bp
;
1568 u16 ld_pause
; /* local */
1569 u16 lp_pause
; /* link partner */
1574 vars
->flow_ctrl
= BNX2X_FLOW_CTRL_NONE
;
1576 if (phy
->req_flow_ctrl
!= BNX2X_FLOW_CTRL_AUTO
)
1577 vars
->flow_ctrl
= phy
->req_flow_ctrl
;
1578 else if (phy
->req_line_speed
!= SPEED_AUTO_NEG
)
1579 vars
->flow_ctrl
= params
->req_fc_auto_adv
;
1580 else if (vars
->link_status
& LINK_STATUS_AUTO_NEGOTIATE_COMPLETE
) {
1582 bnx2x_cl45_read(bp
, phy
,
1584 MDIO_AN_REG_ADV_PAUSE
, &ld_pause
);
1585 bnx2x_cl45_read(bp
, phy
,
1587 MDIO_AN_REG_LP_AUTO_NEG
, &lp_pause
);
1588 pause_result
= (ld_pause
&
1589 MDIO_AN_REG_ADV_PAUSE_MASK
) >> 8;
1590 pause_result
|= (lp_pause
&
1591 MDIO_AN_REG_ADV_PAUSE_MASK
) >> 10;
1592 DP(NETIF_MSG_LINK
, "Ext PHY pause result 0x%x\n",
1594 bnx2x_pause_resolve(vars
, pause_result
);
1599 static u8
bnx2x_direct_parallel_detect_used(struct bnx2x_phy
*phy
,
1600 struct link_params
*params
)
1602 struct bnx2x
*bp
= params
->bp
;
1603 u16 pd_10g
, status2_1000x
;
1604 if (phy
->req_line_speed
!= SPEED_AUTO_NEG
)
1606 CL45_RD_OVER_CL22(bp
, phy
,
1607 MDIO_REG_BANK_SERDES_DIGITAL
,
1608 MDIO_SERDES_DIGITAL_A_1000X_STATUS2
,
1610 CL45_RD_OVER_CL22(bp
, phy
,
1611 MDIO_REG_BANK_SERDES_DIGITAL
,
1612 MDIO_SERDES_DIGITAL_A_1000X_STATUS2
,
1614 if (status2_1000x
& MDIO_SERDES_DIGITAL_A_1000X_STATUS2_AN_DISABLED
) {
1615 DP(NETIF_MSG_LINK
, "1G parallel detect link on port %d\n",
1620 CL45_RD_OVER_CL22(bp
, phy
,
1621 MDIO_REG_BANK_10G_PARALLEL_DETECT
,
1622 MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_STATUS
,
1625 if (pd_10g
& MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_STATUS_PD_LINK
) {
1626 DP(NETIF_MSG_LINK
, "10G parallel detect link on port %d\n",
1633 static void bnx2x_flow_ctrl_resolve(struct bnx2x_phy
*phy
,
1634 struct link_params
*params
,
1635 struct link_vars
*vars
,
1638 struct bnx2x
*bp
= params
->bp
;
1639 u16 ld_pause
; /* local driver */
1640 u16 lp_pause
; /* link partner */
1643 vars
->flow_ctrl
= BNX2X_FLOW_CTRL_NONE
;
1645 /* resolve from gp_status in case of AN complete and not sgmii */
1646 if (phy
->req_flow_ctrl
!= BNX2X_FLOW_CTRL_AUTO
)
1647 vars
->flow_ctrl
= phy
->req_flow_ctrl
;
1648 else if (phy
->req_line_speed
!= SPEED_AUTO_NEG
)
1649 vars
->flow_ctrl
= params
->req_fc_auto_adv
;
1650 else if ((gp_status
& MDIO_AN_CL73_OR_37_COMPLETE
) &&
1651 (!(vars
->phy_flags
& PHY_SGMII_FLAG
))) {
1652 if (bnx2x_direct_parallel_detect_used(phy
, params
)) {
1653 vars
->flow_ctrl
= params
->req_fc_auto_adv
;
1657 (MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_AUTONEG_COMPLETE
|
1658 MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_MR_LP_NP_AN_ABLE
)) ==
1659 (MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_AUTONEG_COMPLETE
|
1660 MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_MR_LP_NP_AN_ABLE
)) {
1662 CL45_RD_OVER_CL22(bp
, phy
,
1663 MDIO_REG_BANK_CL73_IEEEB1
,
1664 MDIO_CL73_IEEEB1_AN_ADV1
,
1666 CL45_RD_OVER_CL22(bp
, phy
,
1667 MDIO_REG_BANK_CL73_IEEEB1
,
1668 MDIO_CL73_IEEEB1_AN_LP_ADV1
,
1670 pause_result
= (ld_pause
&
1671 MDIO_CL73_IEEEB1_AN_ADV1_PAUSE_MASK
)
1673 pause_result
|= (lp_pause
&
1674 MDIO_CL73_IEEEB1_AN_LP_ADV1_PAUSE_MASK
)
1676 DP(NETIF_MSG_LINK
, "pause_result CL73 0x%x\n",
1679 CL45_RD_OVER_CL22(bp
, phy
,
1680 MDIO_REG_BANK_COMBO_IEEE0
,
1681 MDIO_COMBO_IEEE0_AUTO_NEG_ADV
,
1683 CL45_RD_OVER_CL22(bp
, phy
,
1684 MDIO_REG_BANK_COMBO_IEEE0
,
1685 MDIO_COMBO_IEEE0_AUTO_NEG_LINK_PARTNER_ABILITY1
,
1687 pause_result
= (ld_pause
&
1688 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_MASK
)>>5;
1689 pause_result
|= (lp_pause
&
1690 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_MASK
)>>7;
1691 DP(NETIF_MSG_LINK
, "pause_result CL37 0x%x\n",
1694 bnx2x_pause_resolve(vars
, pause_result
);
1696 DP(NETIF_MSG_LINK
, "flow_ctrl 0x%x\n", vars
->flow_ctrl
);
1699 static void bnx2x_check_fallback_to_cl37(struct bnx2x_phy
*phy
,
1700 struct link_params
*params
)
1702 struct bnx2x
*bp
= params
->bp
;
1703 u16 rx_status
, ustat_val
, cl37_fsm_recieved
;
1704 DP(NETIF_MSG_LINK
, "bnx2x_check_fallback_to_cl37\n");
1705 /* Step 1: Make sure signal is detected */
1706 CL45_RD_OVER_CL22(bp
, phy
,
1710 if ((rx_status
& MDIO_RX0_RX_STATUS_SIGDET
) !=
1711 (MDIO_RX0_RX_STATUS_SIGDET
)) {
1712 DP(NETIF_MSG_LINK
, "Signal is not detected. Restoring CL73."
1713 "rx_status(0x80b0) = 0x%x\n", rx_status
);
1714 CL45_WR_OVER_CL22(bp
, phy
,
1715 MDIO_REG_BANK_CL73_IEEEB0
,
1716 MDIO_CL73_IEEEB0_CL73_AN_CONTROL
,
1717 MDIO_CL73_IEEEB0_CL73_AN_CONTROL_AN_EN
);
1720 /* Step 2: Check CL73 state machine */
1721 CL45_RD_OVER_CL22(bp
, phy
,
1722 MDIO_REG_BANK_CL73_USERB0
,
1723 MDIO_CL73_USERB0_CL73_USTAT1
,
1726 (MDIO_CL73_USERB0_CL73_USTAT1_LINK_STATUS_CHECK
|
1727 MDIO_CL73_USERB0_CL73_USTAT1_AN_GOOD_CHECK_BAM37
)) !=
1728 (MDIO_CL73_USERB0_CL73_USTAT1_LINK_STATUS_CHECK
|
1729 MDIO_CL73_USERB0_CL73_USTAT1_AN_GOOD_CHECK_BAM37
)) {
1730 DP(NETIF_MSG_LINK
, "CL73 state-machine is not stable. "
1731 "ustat_val(0x8371) = 0x%x\n", ustat_val
);
1734 /* Step 3: Check CL37 Message Pages received to indicate LP
1735 supports only CL37 */
1736 CL45_RD_OVER_CL22(bp
, phy
,
1737 MDIO_REG_BANK_REMOTE_PHY
,
1738 MDIO_REMOTE_PHY_MISC_RX_STATUS
,
1739 &cl37_fsm_recieved
);
1740 if ((cl37_fsm_recieved
&
1741 (MDIO_REMOTE_PHY_MISC_RX_STATUS_CL37_FSM_RECEIVED_OVER1G_MSG
|
1742 MDIO_REMOTE_PHY_MISC_RX_STATUS_CL37_FSM_RECEIVED_BRCM_OUI_MSG
)) !=
1743 (MDIO_REMOTE_PHY_MISC_RX_STATUS_CL37_FSM_RECEIVED_OVER1G_MSG
|
1744 MDIO_REMOTE_PHY_MISC_RX_STATUS_CL37_FSM_RECEIVED_BRCM_OUI_MSG
)) {
1745 DP(NETIF_MSG_LINK
, "No CL37 FSM were received. "
1746 "misc_rx_status(0x8330) = 0x%x\n",
1750 /* The combined cl37/cl73 fsm state information indicating that we are
1751 connected to a device which does not support cl73, but does support
1752 cl37 BAM. In this case we disable cl73 and restart cl37 auto-neg */
1754 CL45_WR_OVER_CL22(bp
, phy
,
1755 MDIO_REG_BANK_CL73_IEEEB0
,
1756 MDIO_CL73_IEEEB0_CL73_AN_CONTROL
,
1758 /* Restart CL37 autoneg */
1759 bnx2x_restart_autoneg(phy
, params
, 0);
1760 DP(NETIF_MSG_LINK
, "Disabling CL73, and restarting CL37 autoneg\n");
1763 static void bnx2x_xgxs_an_resolve(struct bnx2x_phy
*phy
,
1764 struct link_params
*params
,
1765 struct link_vars
*vars
,
1768 if (gp_status
& MDIO_AN_CL73_OR_37_COMPLETE
)
1769 vars
->link_status
|=
1770 LINK_STATUS_AUTO_NEGOTIATE_COMPLETE
;
1772 if (bnx2x_direct_parallel_detect_used(phy
, params
))
1773 vars
->link_status
|=
1774 LINK_STATUS_PARALLEL_DETECTION_USED
;
1777 static u8
bnx2x_link_settings_status(struct bnx2x_phy
*phy
,
1778 struct link_params
*params
,
1779 struct link_vars
*vars
)
1781 struct bnx2x
*bp
= params
->bp
;
1782 u16 new_line_speed
, gp_status
;
1785 /* Read gp_status */
1786 CL45_RD_OVER_CL22(bp
, phy
,
1787 MDIO_REG_BANK_GP_STATUS
,
1788 MDIO_GP_STATUS_TOP_AN_STATUS1
,
1790 if (phy
->req_line_speed
== SPEED_AUTO_NEG
)
1791 vars
->link_status
|= LINK_STATUS_AUTO_NEGOTIATE_ENABLED
;
1792 if (gp_status
& MDIO_GP_STATUS_TOP_AN_STATUS1_LINK_STATUS
) {
1793 DP(NETIF_MSG_LINK
, "phy link up gp_status=0x%x\n",
1796 vars
->phy_link_up
= 1;
1797 vars
->link_status
|= LINK_STATUS_LINK_UP
;
1799 if (gp_status
& MDIO_GP_STATUS_TOP_AN_STATUS1_DUPLEX_STATUS
)
1800 vars
->duplex
= DUPLEX_FULL
;
1802 vars
->duplex
= DUPLEX_HALF
;
1804 if (SINGLE_MEDIA_DIRECT(params
)) {
1805 bnx2x_flow_ctrl_resolve(phy
, params
, vars
, gp_status
);
1806 if (phy
->req_line_speed
== SPEED_AUTO_NEG
)
1807 bnx2x_xgxs_an_resolve(phy
, params
, vars
,
1811 switch (gp_status
& GP_STATUS_SPEED_MASK
) {
1813 new_line_speed
= SPEED_10
;
1814 if (vars
->duplex
== DUPLEX_FULL
)
1815 vars
->link_status
|= LINK_10TFD
;
1817 vars
->link_status
|= LINK_10THD
;
1820 case GP_STATUS_100M
:
1821 new_line_speed
= SPEED_100
;
1822 if (vars
->duplex
== DUPLEX_FULL
)
1823 vars
->link_status
|= LINK_100TXFD
;
1825 vars
->link_status
|= LINK_100TXHD
;
1829 case GP_STATUS_1G_KX
:
1830 new_line_speed
= SPEED_1000
;
1831 if (vars
->duplex
== DUPLEX_FULL
)
1832 vars
->link_status
|= LINK_1000TFD
;
1834 vars
->link_status
|= LINK_1000THD
;
1837 case GP_STATUS_2_5G
:
1838 new_line_speed
= SPEED_2500
;
1839 if (vars
->duplex
== DUPLEX_FULL
)
1840 vars
->link_status
|= LINK_2500TFD
;
1842 vars
->link_status
|= LINK_2500THD
;
1848 "link speed unsupported gp_status 0x%x\n",
1852 case GP_STATUS_10G_KX4
:
1853 case GP_STATUS_10G_HIG
:
1854 case GP_STATUS_10G_CX4
:
1855 new_line_speed
= SPEED_10000
;
1856 vars
->link_status
|= LINK_10GTFD
;
1859 case GP_STATUS_12G_HIG
:
1860 new_line_speed
= SPEED_12000
;
1861 vars
->link_status
|= LINK_12GTFD
;
1864 case GP_STATUS_12_5G
:
1865 new_line_speed
= SPEED_12500
;
1866 vars
->link_status
|= LINK_12_5GTFD
;
1870 new_line_speed
= SPEED_13000
;
1871 vars
->link_status
|= LINK_13GTFD
;
1875 new_line_speed
= SPEED_15000
;
1876 vars
->link_status
|= LINK_15GTFD
;
1880 new_line_speed
= SPEED_16000
;
1881 vars
->link_status
|= LINK_16GTFD
;
1886 "link speed unsupported gp_status 0x%x\n",
1891 vars
->line_speed
= new_line_speed
;
1894 } else { /* link_down */
1895 DP(NETIF_MSG_LINK
, "phy link down\n");
1897 vars
->phy_link_up
= 0;
1899 vars
->duplex
= DUPLEX_FULL
;
1900 vars
->flow_ctrl
= BNX2X_FLOW_CTRL_NONE
;
1901 vars
->mac_type
= MAC_TYPE_NONE
;
1903 if ((phy
->req_line_speed
== SPEED_AUTO_NEG
) &&
1904 SINGLE_MEDIA_DIRECT(params
)) {
1905 /* Check signal is detected */
1906 bnx2x_check_fallback_to_cl37(phy
, params
);
1910 DP(NETIF_MSG_LINK
, "gp_status 0x%x phy_link_up %x line_speed %x\n",
1911 gp_status
, vars
->phy_link_up
, vars
->line_speed
);
1912 DP(NETIF_MSG_LINK
, "duplex %x flow_ctrl 0x%x"
1915 vars
->flow_ctrl
, vars
->autoneg
);
1916 DP(NETIF_MSG_LINK
, "link_status 0x%x\n", vars
->link_status
);
1921 static void bnx2x_set_gmii_tx_driver(struct link_params
*params
)
1923 struct bnx2x
*bp
= params
->bp
;
1924 struct bnx2x_phy
*phy
= ¶ms
->phy
[INT_PHY
];
1930 CL45_RD_OVER_CL22(bp
, phy
,
1931 MDIO_REG_BANK_OVER_1G
,
1932 MDIO_OVER_1G_LP_UP2
, &lp_up2
);
1934 /* bits [10:7] at lp_up2, positioned at [15:12] */
1935 lp_up2
= (((lp_up2
& MDIO_OVER_1G_LP_UP2_PREEMPHASIS_MASK
) >>
1936 MDIO_OVER_1G_LP_UP2_PREEMPHASIS_SHIFT
) <<
1937 MDIO_TX0_TX_DRIVER_PREEMPHASIS_SHIFT
);
1942 for (bank
= MDIO_REG_BANK_TX0
; bank
<= MDIO_REG_BANK_TX3
;
1943 bank
+= (MDIO_REG_BANK_TX1
- MDIO_REG_BANK_TX0
)) {
1944 CL45_RD_OVER_CL22(bp
, phy
,
1946 MDIO_TX0_TX_DRIVER
, &tx_driver
);
1948 /* replace tx_driver bits [15:12] */
1950 (tx_driver
& MDIO_TX0_TX_DRIVER_PREEMPHASIS_MASK
)) {
1951 tx_driver
&= ~MDIO_TX0_TX_DRIVER_PREEMPHASIS_MASK
;
1952 tx_driver
|= lp_up2
;
1953 CL45_WR_OVER_CL22(bp
, phy
,
1955 MDIO_TX0_TX_DRIVER
, tx_driver
);
1960 static u8
bnx2x_emac_program(struct link_params
*params
,
1961 struct link_vars
*vars
)
1963 struct bnx2x
*bp
= params
->bp
;
1964 u8 port
= params
->port
;
1967 DP(NETIF_MSG_LINK
, "setting link speed & duplex\n");
1968 bnx2x_bits_dis(bp
, GRCBASE_EMAC0
+ port
*0x400 +
1970 (EMAC_MODE_25G_MODE
|
1971 EMAC_MODE_PORT_MII_10M
|
1972 EMAC_MODE_HALF_DUPLEX
));
1973 switch (vars
->line_speed
) {
1975 mode
|= EMAC_MODE_PORT_MII_10M
;
1979 mode
|= EMAC_MODE_PORT_MII
;
1983 mode
|= EMAC_MODE_PORT_GMII
;
1987 mode
|= (EMAC_MODE_25G_MODE
| EMAC_MODE_PORT_GMII
);
1991 /* 10G not valid for EMAC */
1992 DP(NETIF_MSG_LINK
, "Invalid line_speed 0x%x\n",
1997 if (vars
->duplex
== DUPLEX_HALF
)
1998 mode
|= EMAC_MODE_HALF_DUPLEX
;
2000 GRCBASE_EMAC0
+ port
*0x400 + EMAC_REG_EMAC_MODE
,
2003 bnx2x_set_led(params
, LED_MODE_OPER
, vars
->line_speed
);
2007 static u8
bnx2x_init_serdes(struct bnx2x_phy
*phy
,
2008 struct link_params
*params
,
2009 struct link_vars
*vars
)
2012 vars
->phy_flags
|= PHY_SGMII_FLAG
;
2013 bnx2x_calc_ieee_aneg_adv(phy
, params
, &vars
->ieee_fc
);
2014 bnx2x_set_aer_mmd(params
, phy
);
2015 rc
= bnx2x_reset_unicore(params
, phy
, 1);
2016 /* reset the SerDes and wait for reset bit return low */
2019 bnx2x_set_aer_mmd(params
, phy
);
2024 static u8
bnx2x_init_xgxs(struct bnx2x_phy
*phy
,
2025 struct link_params
*params
,
2026 struct link_vars
*vars
)
2029 vars
->phy_flags
= PHY_XGXS_FLAG
;
2030 if ((phy
->req_line_speed
&&
2031 ((phy
->req_line_speed
== SPEED_100
) ||
2032 (phy
->req_line_speed
== SPEED_10
))) ||
2033 (!phy
->req_line_speed
&&
2034 (phy
->speed_cap_mask
>=
2035 PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_FULL
) &&
2036 (phy
->speed_cap_mask
<
2037 PORT_HW_CFG_SPEED_CAPABILITY_D0_1G
)
2039 vars
->phy_flags
|= PHY_SGMII_FLAG
;
2041 vars
->phy_flags
&= ~PHY_SGMII_FLAG
;
2043 bnx2x_calc_ieee_aneg_adv(phy
, params
, &vars
->ieee_fc
);
2044 bnx2x_set_aer_mmd(params
, phy
);
2045 bnx2x_set_master_ln(params
, phy
);
2047 rc
= bnx2x_reset_unicore(params
, phy
, 0);
2048 /* reset the SerDes and wait for reset bit return low */
2052 bnx2x_set_aer_mmd(params
, phy
);
2054 /* setting the masterLn_def again after the reset */
2055 bnx2x_set_master_ln(params
, phy
);
2056 bnx2x_set_swap_lanes(params
, phy
);
2061 /*****************************************************************************/
2062 /* External Phy section */
2063 /*****************************************************************************/
2064 void bnx2x_ext_phy_hw_reset(struct bnx2x
*bp
, u8 port
)
2066 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_1
,
2067 MISC_REGISTERS_GPIO_OUTPUT_LOW
, port
);
2069 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_1
,
2070 MISC_REGISTERS_GPIO_OUTPUT_HIGH
, port
);
2073 static void bnx2x_save_spirom_version(struct bnx2x
*bp
, u8 port
,
2074 u32 spirom_ver
, u32 ver_addr
)
2076 DP(NETIF_MSG_LINK
, "FW version 0x%x:0x%x for port %d\n",
2077 (u16
)(spirom_ver
>>16), (u16
)spirom_ver
, port
);
2080 REG_WR(bp
, ver_addr
, spirom_ver
);
2083 static void bnx2x_save_bcm_spirom_ver(struct bnx2x
*bp
,
2084 struct bnx2x_phy
*phy
,
2087 u16 fw_ver1
, fw_ver2
;
2089 bnx2x_cl45_read(bp
, phy
, MDIO_PMA_DEVAD
,
2090 MDIO_PMA_REG_ROM_VER1
, &fw_ver1
);
2091 bnx2x_cl45_read(bp
, phy
, MDIO_PMA_DEVAD
,
2092 MDIO_PMA_REG_ROM_VER2
, &fw_ver2
);
2093 bnx2x_save_spirom_version(bp
, port
, (u32
)(fw_ver1
<<16 | fw_ver2
),
2097 static void bnx2x_save_848xx_spirom_version(struct bnx2x_phy
*phy
,
2098 struct link_params
*params
)
2100 u16 val
, fw_ver1
, fw_ver2
, cnt
;
2101 struct bnx2x
*bp
= params
->bp
;
2103 /* For the 32 bits registers in 848xx, access via MDIO2ARM interface.*/
2104 /* (1) set register 0xc200_0014(SPI_BRIDGE_CTRL_2) to 0x03000000 */
2105 bnx2x_cl45_write(bp
, phy
, MDIO_PMA_DEVAD
, 0xA819, 0x0014);
2106 bnx2x_cl45_write(bp
, phy
, MDIO_PMA_DEVAD
, 0xA81A, 0xc200);
2107 bnx2x_cl45_write(bp
, phy
, MDIO_PMA_DEVAD
, 0xA81B, 0x0000);
2108 bnx2x_cl45_write(bp
, phy
, MDIO_PMA_DEVAD
, 0xA81C, 0x0300);
2109 bnx2x_cl45_write(bp
, phy
, MDIO_PMA_DEVAD
, 0xA817, 0x0009);
2111 for (cnt
= 0; cnt
< 100; cnt
++) {
2112 bnx2x_cl45_read(bp
, phy
, MDIO_PMA_DEVAD
, 0xA818, &val
);
2118 DP(NETIF_MSG_LINK
, "Unable to read 848xx phy fw version(1)\n");
2119 bnx2x_save_spirom_version(bp
, params
->port
, 0,
2125 /* 2) read register 0xc200_0000 (SPI_FW_STATUS) */
2126 bnx2x_cl45_write(bp
, phy
, MDIO_PMA_DEVAD
, 0xA819, 0x0000);
2127 bnx2x_cl45_write(bp
, phy
, MDIO_PMA_DEVAD
, 0xA81A, 0xc200);
2128 bnx2x_cl45_write(bp
, phy
, MDIO_PMA_DEVAD
, 0xA817, 0x000A);
2129 for (cnt
= 0; cnt
< 100; cnt
++) {
2130 bnx2x_cl45_read(bp
, phy
, MDIO_PMA_DEVAD
, 0xA818, &val
);
2136 DP(NETIF_MSG_LINK
, "Unable to read 848xx phy fw version(2)\n");
2137 bnx2x_save_spirom_version(bp
, params
->port
, 0,
2142 /* lower 16 bits of the register SPI_FW_STATUS */
2143 bnx2x_cl45_read(bp
, phy
, MDIO_PMA_DEVAD
, 0xA81B, &fw_ver1
);
2144 /* upper 16 bits of register SPI_FW_STATUS */
2145 bnx2x_cl45_read(bp
, phy
, MDIO_PMA_DEVAD
, 0xA81C, &fw_ver2
);
2147 bnx2x_save_spirom_version(bp
, params
->port
, (fw_ver2
<<16) | fw_ver1
,
2150 static u8
bnx2x_8073_is_snr_needed(struct bnx2x
*bp
, struct bnx2x_phy
*phy
)
2152 /* This is only required for 8073A1, version 102 only */
2155 /* Read 8073 HW revision*/
2156 bnx2x_cl45_read(bp
, phy
,
2158 MDIO_PMA_REG_8073_CHIP_REV
, &val
);
2161 /* No need to workaround in 8073 A1 */
2165 bnx2x_cl45_read(bp
, phy
,
2167 MDIO_PMA_REG_ROM_VER2
, &val
);
2169 /* SNR should be applied only for version 0x102 */
2175 static u8
bnx2x_8073_xaui_wa(struct bnx2x
*bp
, struct bnx2x_phy
*phy
)
2177 u16 val
, cnt
, cnt1
;
2179 bnx2x_cl45_read(bp
, phy
,
2181 MDIO_PMA_REG_8073_CHIP_REV
, &val
);
2184 /* No need to workaround in 8073 A1 */
2187 /* XAUI workaround in 8073 A0: */
2189 /* After loading the boot ROM and restarting Autoneg,
2190 poll Dev1, Reg $C820: */
2192 for (cnt
= 0; cnt
< 1000; cnt
++) {
2193 bnx2x_cl45_read(bp
, phy
,
2195 MDIO_PMA_REG_8073_SPEED_LINK_STATUS
,
2197 /* If bit [14] = 0 or bit [13] = 0, continue on with
2198 system initialization (XAUI work-around not required,
2199 as these bits indicate 2.5G or 1G link up). */
2200 if (!(val
& (1<<14)) || !(val
& (1<<13))) {
2201 DP(NETIF_MSG_LINK
, "XAUI work-around not required\n");
2203 } else if (!(val
& (1<<15))) {
2204 DP(NETIF_MSG_LINK
, "clc bit 15 went off\n");
2205 /* If bit 15 is 0, then poll Dev1, Reg $C841 until
2206 it's MSB (bit 15) goes to 1 (indicating that the
2207 XAUI workaround has completed),
2208 then continue on with system initialization.*/
2209 for (cnt1
= 0; cnt1
< 1000; cnt1
++) {
2210 bnx2x_cl45_read(bp
, phy
,
2212 MDIO_PMA_REG_8073_XAUI_WA
, &val
);
2213 if (val
& (1<<15)) {
2215 "XAUI workaround has completed\n");
2224 DP(NETIF_MSG_LINK
, "Warning: XAUI work-around timeout !!!\n");
2228 static void bnx2x_8073_8727_external_rom_boot(struct bnx2x
*bp
,
2229 struct bnx2x_phy
*phy
,
2232 /* Boot port from external ROM */
2234 bnx2x_cl45_write(bp
, phy
,
2236 MDIO_PMA_REG_GEN_CTRL
,
2239 /* ucode reboot and rst */
2240 bnx2x_cl45_write(bp
, phy
,
2242 MDIO_PMA_REG_GEN_CTRL
,
2245 bnx2x_cl45_write(bp
, phy
,
2247 MDIO_PMA_REG_MISC_CTRL1
, 0x0001);
2249 /* Reset internal microprocessor */
2250 bnx2x_cl45_write(bp
, phy
,
2252 MDIO_PMA_REG_GEN_CTRL
,
2253 MDIO_PMA_REG_GEN_CTRL_ROM_MICRO_RESET
);
2255 /* Release srst bit */
2256 bnx2x_cl45_write(bp
, phy
,
2258 MDIO_PMA_REG_GEN_CTRL
,
2259 MDIO_PMA_REG_GEN_CTRL_ROM_RESET_INTERNAL_MP
);
2261 /* wait for 120ms for code download via SPI port */
2264 /* Clear ser_boot_ctl bit */
2265 bnx2x_cl45_write(bp
, phy
,
2267 MDIO_PMA_REG_MISC_CTRL1
, 0x0000);
2268 bnx2x_save_bcm_spirom_ver(bp
, phy
, port
);
2271 static void bnx2x_8726_external_rom_boot(struct bnx2x_phy
*phy
,
2272 struct link_params
*params
)
2274 struct bnx2x
*bp
= params
->bp
;
2275 /* Need to wait 100ms after reset */
2278 /* Micro controller re-boot */
2279 bnx2x_cl45_write(bp
, phy
,
2280 MDIO_PMA_DEVAD
, MDIO_PMA_REG_GEN_CTRL
, 0x018B);
2282 /* Set soft reset */
2283 bnx2x_cl45_write(bp
, phy
,
2285 MDIO_PMA_REG_GEN_CTRL
,
2286 MDIO_PMA_REG_GEN_CTRL_ROM_MICRO_RESET
);
2288 bnx2x_cl45_write(bp
, phy
,
2290 MDIO_PMA_REG_MISC_CTRL1
, 0x0001);
2292 bnx2x_cl45_write(bp
, phy
,
2294 MDIO_PMA_REG_GEN_CTRL
,
2295 MDIO_PMA_REG_GEN_CTRL_ROM_RESET_INTERNAL_MP
);
2297 /* wait for 150ms for microcode load */
2300 /* Disable serial boot control, tristates pins SS_N, SCK, MOSI, MISO */
2301 bnx2x_cl45_write(bp
, phy
,
2303 MDIO_PMA_REG_MISC_CTRL1
, 0x0000);
2306 bnx2x_save_bcm_spirom_ver(bp
, phy
, params
->port
);
2309 static void bnx2x_sfp_set_transmitter(struct bnx2x
*bp
,
2310 struct bnx2x_phy
*phy
,
2316 DP(NETIF_MSG_LINK
, "Setting transmitter tx_en=%x for port %x\n",
2318 /* Disable/Enable transmitter ( TX laser of the SFP+ module.)*/
2319 bnx2x_cl45_read(bp
, phy
,
2321 MDIO_PMA_REG_PHY_IDENTIFIER
,
2329 bnx2x_cl45_write(bp
, phy
,
2331 MDIO_PMA_REG_PHY_IDENTIFIER
,
2335 static u8
bnx2x_8726_read_sfp_module_eeprom(struct bnx2x_phy
*phy
,
2336 struct link_params
*params
,
2337 u16 addr
, u8 byte_cnt
, u8
*o_buf
)
2339 struct bnx2x
*bp
= params
->bp
;
2342 if (byte_cnt
> 16) {
2343 DP(NETIF_MSG_LINK
, "Reading from eeprom is"
2344 " is limited to 0xf\n");
2347 /* Set the read command byte count */
2348 bnx2x_cl45_write(bp
, phy
,
2349 MDIO_PMA_DEVAD
, MDIO_PMA_REG_SFP_TWO_WIRE_BYTE_CNT
,
2350 (byte_cnt
| 0xa000));
2352 /* Set the read command address */
2353 bnx2x_cl45_write(bp
, phy
,
2354 MDIO_PMA_DEVAD
, MDIO_PMA_REG_SFP_TWO_WIRE_MEM_ADDR
,
2357 /* Activate read command */
2358 bnx2x_cl45_write(bp
, phy
,
2359 MDIO_PMA_DEVAD
, MDIO_PMA_REG_SFP_TWO_WIRE_CTRL
,
2362 /* Wait up to 500us for command complete status */
2363 for (i
= 0; i
< 100; i
++) {
2364 bnx2x_cl45_read(bp
, phy
,
2366 MDIO_PMA_REG_SFP_TWO_WIRE_CTRL
, &val
);
2367 if ((val
& MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK
) ==
2368 MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_COMPLETE
)
2373 if ((val
& MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK
) !=
2374 MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_COMPLETE
) {
2376 "Got bad status 0x%x when reading from SFP+ EEPROM\n",
2377 (val
& MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK
));
2381 /* Read the buffer */
2382 for (i
= 0; i
< byte_cnt
; i
++) {
2383 bnx2x_cl45_read(bp
, phy
,
2385 MDIO_PMA_REG_8726_TWO_WIRE_DATA_BUF
+ i
, &val
);
2386 o_buf
[i
] = (u8
)(val
& MDIO_PMA_REG_8726_TWO_WIRE_DATA_MASK
);
2389 for (i
= 0; i
< 100; i
++) {
2390 bnx2x_cl45_read(bp
, phy
,
2392 MDIO_PMA_REG_SFP_TWO_WIRE_CTRL
, &val
);
2393 if ((val
& MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK
) ==
2394 MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_IDLE
)
2401 static u8
bnx2x_8727_read_sfp_module_eeprom(struct bnx2x_phy
*phy
,
2402 struct link_params
*params
,
2403 u16 addr
, u8 byte_cnt
, u8
*o_buf
)
2405 struct bnx2x
*bp
= params
->bp
;
2408 if (byte_cnt
> 16) {
2409 DP(NETIF_MSG_LINK
, "Reading from eeprom is"
2410 " is limited to 0xf\n");
2414 /* Need to read from 1.8000 to clear it */
2415 bnx2x_cl45_read(bp
, phy
,
2417 MDIO_PMA_REG_SFP_TWO_WIRE_CTRL
,
2420 /* Set the read command byte count */
2421 bnx2x_cl45_write(bp
, phy
,
2423 MDIO_PMA_REG_SFP_TWO_WIRE_BYTE_CNT
,
2424 ((byte_cnt
< 2) ? 2 : byte_cnt
));
2426 /* Set the read command address */
2427 bnx2x_cl45_write(bp
, phy
,
2429 MDIO_PMA_REG_SFP_TWO_WIRE_MEM_ADDR
,
2431 /* Set the destination address */
2432 bnx2x_cl45_write(bp
, phy
,
2435 MDIO_PMA_REG_8727_TWO_WIRE_DATA_BUF
);
2437 /* Activate read command */
2438 bnx2x_cl45_write(bp
, phy
,
2440 MDIO_PMA_REG_SFP_TWO_WIRE_CTRL
,
2442 /* Wait appropriate time for two-wire command to finish before
2443 polling the status register */
2446 /* Wait up to 500us for command complete status */
2447 for (i
= 0; i
< 100; i
++) {
2448 bnx2x_cl45_read(bp
, phy
,
2450 MDIO_PMA_REG_SFP_TWO_WIRE_CTRL
, &val
);
2451 if ((val
& MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK
) ==
2452 MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_COMPLETE
)
2457 if ((val
& MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK
) !=
2458 MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_COMPLETE
) {
2460 "Got bad status 0x%x when reading from SFP+ EEPROM\n",
2461 (val
& MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK
));
2465 /* Read the buffer */
2466 for (i
= 0; i
< byte_cnt
; i
++) {
2467 bnx2x_cl45_read(bp
, phy
,
2469 MDIO_PMA_REG_8727_TWO_WIRE_DATA_BUF
+ i
, &val
);
2470 o_buf
[i
] = (u8
)(val
& MDIO_PMA_REG_8727_TWO_WIRE_DATA_MASK
);
2473 for (i
= 0; i
< 100; i
++) {
2474 bnx2x_cl45_read(bp
, phy
,
2476 MDIO_PMA_REG_SFP_TWO_WIRE_CTRL
, &val
);
2477 if ((val
& MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK
) ==
2478 MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_IDLE
)
2486 u8
bnx2x_read_sfp_module_eeprom(struct bnx2x_phy
*phy
,
2487 struct link_params
*params
, u16 addr
,
2488 u8 byte_cnt
, u8
*o_buf
)
2490 if (phy
->type
== PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726
)
2491 return bnx2x_8726_read_sfp_module_eeprom(phy
, params
, addr
,
2493 else if (phy
->type
== PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727
)
2494 return bnx2x_8727_read_sfp_module_eeprom(phy
, params
, addr
,
2499 static u8
bnx2x_get_edc_mode(struct bnx2x_phy
*phy
,
2500 struct link_params
*params
,
2503 struct bnx2x
*bp
= params
->bp
;
2504 u8 val
, check_limiting_mode
= 0;
2505 *edc_mode
= EDC_MODE_LIMITING
;
2507 /* First check for copper cable */
2508 if (bnx2x_read_sfp_module_eeprom(phy
,
2510 SFP_EEPROM_CON_TYPE_ADDR
,
2513 DP(NETIF_MSG_LINK
, "Failed to read from SFP+ module EEPROM\n");
2518 case SFP_EEPROM_CON_TYPE_VAL_COPPER
:
2520 u8 copper_module_type
;
2522 /* Check if its active cable( includes SFP+ module)
2524 if (bnx2x_read_sfp_module_eeprom(phy
,
2526 SFP_EEPROM_FC_TX_TECH_ADDR
,
2528 &copper_module_type
) !=
2531 "Failed to read copper-cable-type"
2532 " from SFP+ EEPROM\n");
2536 if (copper_module_type
&
2537 SFP_EEPROM_FC_TX_TECH_BITMASK_COPPER_ACTIVE
) {
2538 DP(NETIF_MSG_LINK
, "Active Copper cable detected\n");
2539 check_limiting_mode
= 1;
2540 } else if (copper_module_type
&
2541 SFP_EEPROM_FC_TX_TECH_BITMASK_COPPER_PASSIVE
) {
2542 DP(NETIF_MSG_LINK
, "Passive Copper"
2543 " cable detected\n");
2545 EDC_MODE_PASSIVE_DAC
;
2547 DP(NETIF_MSG_LINK
, "Unknown copper-cable-"
2548 "type 0x%x !!!\n", copper_module_type
);
2553 case SFP_EEPROM_CON_TYPE_VAL_LC
:
2554 DP(NETIF_MSG_LINK
, "Optic module detected\n");
2555 check_limiting_mode
= 1;
2558 DP(NETIF_MSG_LINK
, "Unable to determine module type 0x%x !!!\n",
2563 if (check_limiting_mode
) {
2564 u8 options
[SFP_EEPROM_OPTIONS_SIZE
];
2565 if (bnx2x_read_sfp_module_eeprom(phy
,
2567 SFP_EEPROM_OPTIONS_ADDR
,
2568 SFP_EEPROM_OPTIONS_SIZE
,
2570 DP(NETIF_MSG_LINK
, "Failed to read Option"
2571 " field from module EEPROM\n");
2574 if ((options
[0] & SFP_EEPROM_OPTIONS_LINEAR_RX_OUT_MASK
))
2575 *edc_mode
= EDC_MODE_LINEAR
;
2577 *edc_mode
= EDC_MODE_LIMITING
;
2579 DP(NETIF_MSG_LINK
, "EDC mode is set to 0x%x\n", *edc_mode
);
2582 /* This function read the relevant field from the module ( SFP+ ),
2583 and verify it is compliant with this board */
2584 static u8
bnx2x_verify_sfp_module(struct bnx2x_phy
*phy
,
2585 struct link_params
*params
)
2587 struct bnx2x
*bp
= params
->bp
;
2590 char vendor_name
[SFP_EEPROM_VENDOR_NAME_SIZE
+1];
2591 char vendor_pn
[SFP_EEPROM_PART_NO_SIZE
+1];
2593 val
= REG_RD(bp
, params
->shmem_base
+
2594 offsetof(struct shmem_region
, dev_info
.
2595 port_feature_config
[params
->port
].config
));
2596 if ((val
& PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK
) ==
2597 PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_NO_ENFORCEMENT
) {
2598 DP(NETIF_MSG_LINK
, "NOT enforcing module verification\n");
2602 /* Ask the FW to validate the module */
2603 if (!(params
->feature_config_flags
&
2604 FEATURE_CONFIG_BC_SUPPORTS_OPT_MDL_VRFY
)) {
2605 DP(NETIF_MSG_LINK
, "FW does not support OPT MDL "
2610 fw_resp
= bnx2x_fw_command(bp
, DRV_MSG_CODE_VRFY_OPT_MDL
);
2611 if (fw_resp
== FW_MSG_CODE_VRFY_OPT_MDL_SUCCESS
) {
2612 DP(NETIF_MSG_LINK
, "Approved module\n");
2616 /* format the warning message */
2617 if (bnx2x_read_sfp_module_eeprom(phy
,
2619 SFP_EEPROM_VENDOR_NAME_ADDR
,
2620 SFP_EEPROM_VENDOR_NAME_SIZE
,
2622 vendor_name
[0] = '\0';
2624 vendor_name
[SFP_EEPROM_VENDOR_NAME_SIZE
] = '\0';
2625 if (bnx2x_read_sfp_module_eeprom(phy
,
2627 SFP_EEPROM_PART_NO_ADDR
,
2628 SFP_EEPROM_PART_NO_SIZE
,
2630 vendor_pn
[0] = '\0';
2632 vendor_pn
[SFP_EEPROM_PART_NO_SIZE
] = '\0';
2634 netdev_info(bp
->dev
, "Warning: Unqualified SFP+ module detected,"
2635 " Port %d from %s part number %s\n",
2636 params
->port
, vendor_name
, vendor_pn
);
2640 static u8
bnx2x_8726_set_limiting_mode(struct bnx2x
*bp
,
2641 struct bnx2x_phy
*phy
,
2644 u16 cur_limiting_mode
;
2646 bnx2x_cl45_read(bp
, phy
,
2648 MDIO_PMA_REG_ROM_VER2
,
2649 &cur_limiting_mode
);
2650 DP(NETIF_MSG_LINK
, "Current Limiting mode is 0x%x\n",
2653 if (edc_mode
== EDC_MODE_LIMITING
) {
2655 "Setting LIMITING MODE\n");
2656 bnx2x_cl45_write(bp
, phy
,
2658 MDIO_PMA_REG_ROM_VER2
,
2660 } else { /* LRM mode ( default )*/
2662 DP(NETIF_MSG_LINK
, "Setting LRM MODE\n");
2664 /* Changing to LRM mode takes quite few seconds.
2665 So do it only if current mode is limiting
2666 ( default is LRM )*/
2667 if (cur_limiting_mode
!= EDC_MODE_LIMITING
)
2670 bnx2x_cl45_write(bp
, phy
,
2672 MDIO_PMA_REG_LRM_MODE
,
2674 bnx2x_cl45_write(bp
, phy
,
2676 MDIO_PMA_REG_ROM_VER2
,
2678 bnx2x_cl45_write(bp
, phy
,
2680 MDIO_PMA_REG_MISC_CTRL0
,
2682 bnx2x_cl45_write(bp
, phy
,
2684 MDIO_PMA_REG_LRM_MODE
,
2690 static u8
bnx2x_8727_set_limiting_mode(struct bnx2x
*bp
,
2691 struct bnx2x_phy
*phy
,
2696 bnx2x_cl45_read(bp
, phy
,
2698 MDIO_PMA_REG_PHY_IDENTIFIER
,
2701 bnx2x_cl45_write(bp
, phy
,
2703 MDIO_PMA_REG_PHY_IDENTIFIER
,
2704 (phy_identifier
& ~(1<<9)));
2706 bnx2x_cl45_read(bp
, phy
,
2708 MDIO_PMA_REG_ROM_VER2
,
2710 /* Keep the MSB 8-bits, and set the LSB 8-bits with the edc_mode */
2711 bnx2x_cl45_write(bp
, phy
,
2713 MDIO_PMA_REG_ROM_VER2
,
2714 (rom_ver2_val
& 0xff00) | (edc_mode
& 0x00ff));
2716 bnx2x_cl45_write(bp
, phy
,
2718 MDIO_PMA_REG_PHY_IDENTIFIER
,
2719 (phy_identifier
| (1<<9)));
2725 static u8
bnx2x_wait_for_sfp_module_initialized(struct bnx2x_phy
*phy
,
2726 struct link_params
*params
)
2730 struct bnx2x
*bp
= params
->bp
;
2732 /* Initialization time after hot-plug may take up to 300ms for some
2733 phys type ( e.g. JDSU ) */
2734 for (timeout
= 0; timeout
< 60; timeout
++) {
2735 if (bnx2x_read_sfp_module_eeprom(phy
, params
, 1, 1, &val
)
2737 DP(NETIF_MSG_LINK
, "SFP+ module initialization "
2738 "took %d ms\n", timeout
* 5);
2746 static void bnx2x_8727_power_module(struct bnx2x
*bp
,
2747 struct bnx2x_phy
*phy
,
2749 /* Make sure GPIOs are not using for LED mode */
2752 * In the GPIO register, bit 4 is use to detemine if the GPIOs are
2753 * operating as INPUT or as OUTPUT. Bit 1 is for input, and 0 for
2755 * Bits 0-1 determine the gpios value for OUTPUT in case bit 4 val is 0
2756 * Bits 8-9 determine the gpios value for INPUT in case bit 4 val is 1
2757 * where the 1st bit is the over-current(only input), and 2nd bit is
2758 * for power( only output )
2762 * In case of NOC feature is disabled and power is up, set GPIO control
2763 * as input to enable listening of over-current indication
2765 if (phy
->flags
& FLAGS_NOC
)
2768 FLAGS_NOC
) && is_power_up
)
2772 * Set GPIO control to OUTPUT, and set the power bit
2773 * to according to the is_power_up
2775 val
= ((!(is_power_up
)) << 1);
2777 bnx2x_cl45_write(bp
, phy
,
2779 MDIO_PMA_REG_8727_GPIO_CTRL
,
2783 static u8
bnx2x_sfp_module_detection(struct bnx2x_phy
*phy
,
2784 struct link_params
*params
)
2786 struct bnx2x
*bp
= params
->bp
;
2790 u32 val
= REG_RD(bp
, params
->shmem_base
+
2791 offsetof(struct shmem_region
, dev_info
.
2792 port_feature_config
[params
->port
].config
));
2794 DP(NETIF_MSG_LINK
, "SFP+ module plugged in/out detected on port %d\n",
2797 if (bnx2x_get_edc_mode(phy
, params
, &edc_mode
) != 0) {
2798 DP(NETIF_MSG_LINK
, "Failed to get valid module type\n");
2800 } else if (bnx2x_verify_sfp_module(phy
, params
) !=
2802 /* check SFP+ module compatibility */
2803 DP(NETIF_MSG_LINK
, "Module verification failed!!\n");
2805 /* Turn on fault module-detected led */
2806 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_0
,
2807 MISC_REGISTERS_GPIO_HIGH
,
2809 if ((phy
->type
== PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727
) &&
2810 ((val
& PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK
) ==
2811 PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_POWER_DOWN
)) {
2812 /* Shutdown SFP+ module */
2813 DP(NETIF_MSG_LINK
, "Shutdown SFP+ module!!\n");
2814 bnx2x_8727_power_module(bp
, phy
, 0);
2818 /* Turn off fault module-detected led */
2819 DP(NETIF_MSG_LINK
, "Turn off fault module-detected led\n");
2820 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_0
,
2821 MISC_REGISTERS_GPIO_LOW
,
2825 /* power up the SFP module */
2826 if (phy
->type
== PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727
)
2827 bnx2x_8727_power_module(bp
, phy
, 1);
2829 /* Check and set limiting mode / LRM mode on 8726.
2830 On 8727 it is done automatically */
2831 if (phy
->type
== PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726
)
2832 bnx2x_8726_set_limiting_mode(bp
, phy
, edc_mode
);
2834 bnx2x_8727_set_limiting_mode(bp
, phy
, edc_mode
);
2836 * Enable transmit for this module if the module is approved, or
2837 * if unapproved modules should also enable the Tx laser
2840 (val
& PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK
) !=
2841 PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_DISABLE_TX_LASER
)
2842 bnx2x_sfp_set_transmitter(bp
, phy
, params
->port
, 1);
2844 bnx2x_sfp_set_transmitter(bp
, phy
, params
->port
, 0);
2849 void bnx2x_handle_module_detect_int(struct link_params
*params
)
2851 struct bnx2x
*bp
= params
->bp
;
2852 struct bnx2x_phy
*phy
= ¶ms
->phy
[EXT_PHY1
];
2854 u8 port
= params
->port
;
2856 /* Set valid module led off */
2857 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_0
,
2858 MISC_REGISTERS_GPIO_HIGH
,
2861 /* Get current gpio val refelecting module plugged in / out*/
2862 gpio_val
= bnx2x_get_gpio(bp
, MISC_REGISTERS_GPIO_3
, port
);
2864 /* Call the handling function in case module is detected */
2865 if (gpio_val
== 0) {
2867 bnx2x_set_gpio_int(bp
, MISC_REGISTERS_GPIO_3
,
2868 MISC_REGISTERS_GPIO_INT_OUTPUT_CLR
,
2871 if (bnx2x_wait_for_sfp_module_initialized(phy
, params
) == 0)
2872 bnx2x_sfp_module_detection(phy
, params
);
2874 DP(NETIF_MSG_LINK
, "SFP+ module is not initialized\n");
2876 u32 val
= REG_RD(bp
, params
->shmem_base
+
2877 offsetof(struct shmem_region
, dev_info
.
2878 port_feature_config
[params
->port
].
2881 bnx2x_set_gpio_int(bp
, MISC_REGISTERS_GPIO_3
,
2882 MISC_REGISTERS_GPIO_INT_OUTPUT_SET
,
2884 /* Module was plugged out. */
2885 /* Disable transmit for this module */
2886 if ((val
& PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK
) ==
2887 PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_DISABLE_TX_LASER
)
2888 bnx2x_sfp_set_transmitter(bp
, phy
, params
->port
, 0);
2892 static void bnx2x_807x_force_10G(struct bnx2x
*bp
, struct bnx2x_phy
*phy
)
2894 /* Force KR or KX */
2895 bnx2x_cl45_write(bp
, phy
,
2896 MDIO_PMA_DEVAD
, MDIO_PMA_REG_CTRL
, 0x2040);
2897 bnx2x_cl45_write(bp
, phy
,
2898 MDIO_PMA_DEVAD
, MDIO_PMA_REG_10G_CTRL2
, 0x000b);
2899 bnx2x_cl45_write(bp
, phy
,
2900 MDIO_PMA_DEVAD
, MDIO_PMA_REG_BCM_CTRL
, 0x0000);
2901 bnx2x_cl45_write(bp
, phy
,
2902 MDIO_AN_DEVAD
, MDIO_AN_REG_CTRL
, 0x0000);
2905 static void bnx2x_8073_set_xaui_low_power_mode(struct bnx2x
*bp
,
2906 struct bnx2x_phy
*phy
)
2909 bnx2x_cl45_read(bp
, phy
,
2910 MDIO_PMA_DEVAD
, MDIO_PMA_REG_8073_CHIP_REV
, &val
);
2913 /* Mustn't set low power mode in 8073 A0 */
2917 /* Disable PLL sequencer (use read-modify-write to clear bit 13) */
2918 bnx2x_cl45_read(bp
, phy
,
2919 MDIO_XS_DEVAD
, MDIO_XS_PLL_SEQUENCER
, &val
);
2921 bnx2x_cl45_write(bp
, phy
,
2922 MDIO_XS_DEVAD
, MDIO_XS_PLL_SEQUENCER
, val
);
2925 bnx2x_cl45_write(bp
, phy
, MDIO_XS_DEVAD
, 0x805E, 0x1077);
2926 bnx2x_cl45_write(bp
, phy
, MDIO_XS_DEVAD
, 0x805D, 0x0000);
2927 bnx2x_cl45_write(bp
, phy
, MDIO_XS_DEVAD
, 0x805C, 0x030B);
2928 bnx2x_cl45_write(bp
, phy
, MDIO_XS_DEVAD
, 0x805B, 0x1240);
2929 bnx2x_cl45_write(bp
, phy
, MDIO_XS_DEVAD
, 0x805A, 0x2490);
2932 bnx2x_cl45_write(bp
, phy
, MDIO_XS_DEVAD
, 0x80A7, 0x0C74);
2933 bnx2x_cl45_write(bp
, phy
, MDIO_XS_DEVAD
, 0x80A6, 0x9041);
2934 bnx2x_cl45_write(bp
, phy
, MDIO_XS_DEVAD
, 0x80A5, 0x4640);
2937 bnx2x_cl45_write(bp
, phy
, MDIO_XS_DEVAD
, 0x80FE, 0x01C4);
2938 bnx2x_cl45_write(bp
, phy
, MDIO_XS_DEVAD
, 0x80FD, 0x9249);
2939 bnx2x_cl45_write(bp
, phy
, MDIO_XS_DEVAD
, 0x80FC, 0x2015);
2941 /* Enable PLL sequencer (use read-modify-write to set bit 13) */
2942 bnx2x_cl45_read(bp
, phy
, MDIO_XS_DEVAD
, MDIO_XS_PLL_SEQUENCER
, &val
);
2944 bnx2x_cl45_write(bp
, phy
, MDIO_XS_DEVAD
, MDIO_XS_PLL_SEQUENCER
, val
);
2947 static void bnx2x_8073_set_pause_cl37(struct link_params
*params
,
2948 struct bnx2x_phy
*phy
,
2949 struct link_vars
*vars
)
2952 struct bnx2x
*bp
= params
->bp
;
2953 bnx2x_cl45_read(bp
, phy
,
2954 MDIO_AN_DEVAD
, MDIO_AN_REG_CL37_FC_LD
, &cl37_val
);
2956 cl37_val
&= ~MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH
;
2957 /* Please refer to Table 28B-3 of 802.3ab-1999 spec. */
2958 bnx2x_calc_ieee_aneg_adv(phy
, params
, &vars
->ieee_fc
);
2959 if ((vars
->ieee_fc
&
2960 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_SYMMETRIC
) ==
2961 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_SYMMETRIC
) {
2962 cl37_val
|= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_SYMMETRIC
;
2964 if ((vars
->ieee_fc
&
2965 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC
) ==
2966 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC
) {
2967 cl37_val
|= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC
;
2969 if ((vars
->ieee_fc
&
2970 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH
) ==
2971 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH
) {
2972 cl37_val
|= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH
;
2975 "Ext phy AN advertize cl37 0x%x\n", cl37_val
);
2977 bnx2x_cl45_write(bp
, phy
,
2978 MDIO_AN_DEVAD
, MDIO_AN_REG_CL37_FC_LD
, cl37_val
);
2982 static void bnx2x_ext_phy_set_pause(struct link_params
*params
,
2983 struct bnx2x_phy
*phy
,
2984 struct link_vars
*vars
)
2987 struct bnx2x
*bp
= params
->bp
;
2988 /* read modify write pause advertizing */
2989 bnx2x_cl45_read(bp
, phy
, MDIO_AN_DEVAD
, MDIO_AN_REG_ADV_PAUSE
, &val
);
2991 val
&= ~MDIO_AN_REG_ADV_PAUSE_BOTH
;
2993 /* Please refer to Table 28B-3 of 802.3ab-1999 spec. */
2994 bnx2x_calc_ieee_aneg_adv(phy
, params
, &vars
->ieee_fc
);
2995 if ((vars
->ieee_fc
&
2996 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC
) ==
2997 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC
) {
2998 val
|= MDIO_AN_REG_ADV_PAUSE_ASYMMETRIC
;
3000 if ((vars
->ieee_fc
&
3001 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH
) ==
3002 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH
) {
3003 val
|= MDIO_AN_REG_ADV_PAUSE_PAUSE
;
3005 DP(NETIF_MSG_LINK
, "Ext phy AN advertize 0x%x\n", val
);
3006 bnx2x_cl45_write(bp
, phy
, MDIO_AN_DEVAD
, MDIO_AN_REG_ADV_PAUSE
, val
);
3009 static void bnx2x_set_preemphasis(struct bnx2x_phy
*phy
,
3010 struct link_params
*params
)
3014 struct bnx2x
*bp
= params
->bp
;
3016 for (bank
= MDIO_REG_BANK_RX0
, i
= 0; bank
<= MDIO_REG_BANK_RX3
;
3017 bank
+= (MDIO_REG_BANK_RX1
-MDIO_REG_BANK_RX0
), i
++) {
3018 CL45_WR_OVER_CL22(bp
, phy
,
3020 MDIO_RX0_RX_EQ_BOOST
,
3021 phy
->rx_preemphasis
[i
]);
3024 for (bank
= MDIO_REG_BANK_TX0
, i
= 0; bank
<= MDIO_REG_BANK_TX3
;
3025 bank
+= (MDIO_REG_BANK_TX1
- MDIO_REG_BANK_TX0
), i
++) {
3026 CL45_WR_OVER_CL22(bp
, phy
,
3029 phy
->tx_preemphasis
[i
]);
3033 static void bnx2x_848xx_set_led(struct bnx2x
*bp
,
3034 struct bnx2x_phy
*phy
)
3038 /* PHYC_CTL_LED_CTL */
3039 bnx2x_cl45_read(bp
, phy
,
3041 MDIO_PMA_REG_8481_LINK_SIGNAL
, &val
);
3045 bnx2x_cl45_write(bp
, phy
,
3047 MDIO_PMA_REG_8481_LINK_SIGNAL
, val
);
3049 bnx2x_cl45_write(bp
, phy
,
3051 MDIO_PMA_REG_8481_LED1_MASK
,
3054 bnx2x_cl45_write(bp
, phy
,
3056 MDIO_PMA_REG_8481_LED2_MASK
,
3059 bnx2x_cl45_write(bp
, phy
,
3061 MDIO_PMA_REG_8481_LED3_MASK
,
3064 /* 'Interrupt Mask' */
3065 bnx2x_cl45_write(bp
, phy
,
3070 static void bnx2x_init_internal_phy(struct bnx2x_phy
*phy
,
3071 struct link_params
*params
,
3072 struct link_vars
*vars
)
3074 struct bnx2x
*bp
= params
->bp
;
3075 u8 enable_cl73
= (SINGLE_MEDIA_DIRECT(params
) ||
3076 (params
->loopback_mode
== LOOPBACK_XGXS_10
));
3077 if (!(vars
->phy_flags
& PHY_SGMII_FLAG
)) {
3078 if (SINGLE_MEDIA_DIRECT(params
) &&
3079 (params
->feature_config_flags
&
3080 FEATURE_CONFIG_OVERRIDE_PREEMPHASIS_ENABLED
))
3081 bnx2x_set_preemphasis(phy
, params
);
3083 /* forced speed requested? */
3084 if (vars
->line_speed
!= SPEED_AUTO_NEG
||
3085 (SINGLE_MEDIA_DIRECT(params
) &&
3086 params
->loopback_mode
== LOOPBACK_EXT
)) {
3087 DP(NETIF_MSG_LINK
, "not SGMII, no AN\n");
3089 /* disable autoneg */
3090 bnx2x_set_autoneg(phy
, params
, vars
, 0);
3092 /* program speed and duplex */
3093 bnx2x_program_serdes(phy
, params
, vars
);
3095 } else { /* AN_mode */
3096 DP(NETIF_MSG_LINK
, "not SGMII, AN\n");
3099 bnx2x_set_brcm_cl37_advertisment(phy
, params
);
3101 /* program duplex & pause advertisement (for aneg) */
3102 bnx2x_set_ieee_aneg_advertisment(phy
, params
,
3105 /* enable autoneg */
3106 bnx2x_set_autoneg(phy
, params
, vars
, enable_cl73
);
3108 /* enable and restart AN */
3109 bnx2x_restart_autoneg(phy
, params
, enable_cl73
);
3112 } else { /* SGMII mode */
3113 DP(NETIF_MSG_LINK
, "SGMII\n");
3115 bnx2x_initialize_sgmii_process(phy
, params
, vars
);
3119 static u16
bnx2x_wait_reset_complete(struct bnx2x
*bp
,
3120 struct bnx2x_phy
*phy
)
3123 /* Wait for soft reset to get cleared upto 1 sec */
3124 for (cnt
= 0; cnt
< 1000; cnt
++) {
3125 bnx2x_cl45_read(bp
, phy
,
3126 MDIO_PMA_DEVAD
, MDIO_PMA_REG_CTRL
, &ctrl
);
3127 if (!(ctrl
& (1<<15)))
3131 DP(NETIF_MSG_LINK
, "control reg 0x%x (after %d ms)\n", ctrl
, cnt
);
3135 static u8
bnx2x_8705_config_init(struct bnx2x_phy
*phy
,
3136 struct link_params
*params
,
3137 struct link_vars
*vars
)
3139 struct bnx2x
*bp
= params
->bp
;
3140 DP(NETIF_MSG_LINK
, "init 8705\n");
3141 /* Restore normal power mode*/
3142 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_2
,
3143 MISC_REGISTERS_GPIO_OUTPUT_HIGH
, params
->port
);
3145 bnx2x_ext_phy_hw_reset(bp
, params
->port
);
3146 bnx2x_cl45_write(bp
, phy
, MDIO_PMA_DEVAD
, MDIO_PMA_REG_CTRL
, 0xa040);
3147 bnx2x_wait_reset_complete(bp
, phy
);
3149 bnx2x_cl45_write(bp
, phy
,
3150 MDIO_PMA_DEVAD
, MDIO_PMA_REG_MISC_CTRL
, 0x8288);
3151 bnx2x_cl45_write(bp
, phy
,
3152 MDIO_PMA_DEVAD
, MDIO_PMA_REG_PHY_IDENTIFIER
, 0x7fbf);
3153 bnx2x_cl45_write(bp
, phy
,
3154 MDIO_PMA_DEVAD
, MDIO_PMA_REG_CMU_PLL_BYPASS
, 0x0100);
3155 bnx2x_cl45_write(bp
, phy
,
3156 MDIO_WIS_DEVAD
, MDIO_WIS_REG_LASI_CNTL
, 0x1);
3157 /* BCM8705 doesn't have microcode, hence the 0 */
3158 bnx2x_save_spirom_version(bp
, params
->port
, params
->shmem_base
, 0);
3162 static u8
bnx2x_8706_config_init(struct bnx2x_phy
*phy
,
3163 struct link_params
*params
,
3164 struct link_vars
*vars
)
3167 struct bnx2x
*bp
= params
->bp
;
3168 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_2
,
3169 MISC_REGISTERS_GPIO_OUTPUT_HIGH
, params
->port
);
3171 bnx2x_ext_phy_hw_reset(bp
, params
->port
);
3172 bnx2x_cl45_write(bp
, phy
, MDIO_PMA_DEVAD
, MDIO_PMA_REG_CTRL
, 0xa040);
3173 bnx2x_wait_reset_complete(bp
, phy
);
3175 /* Wait until fw is loaded */
3176 for (cnt
= 0; cnt
< 100; cnt
++) {
3177 bnx2x_cl45_read(bp
, phy
,
3178 MDIO_PMA_DEVAD
, MDIO_PMA_REG_ROM_VER1
, &val
);
3183 DP(NETIF_MSG_LINK
, "XGXS 8706 is initialized after %d ms\n", cnt
);
3184 if ((params
->feature_config_flags
&
3185 FEATURE_CONFIG_OVERRIDE_PREEMPHASIS_ENABLED
)) {
3188 for (i
= 0; i
< 4; i
++) {
3189 reg
= MDIO_XS_8706_REG_BANK_RX0
+
3190 i
*(MDIO_XS_8706_REG_BANK_RX1
-
3191 MDIO_XS_8706_REG_BANK_RX0
);
3192 bnx2x_cl45_read(bp
, phy
, MDIO_XS_DEVAD
, reg
, &val
);
3193 /* Clear first 3 bits of the control */
3195 /* Set control bits according to configuration */
3196 val
|= (phy
->rx_preemphasis
[i
] & 0x7);
3197 DP(NETIF_MSG_LINK
, "Setting RX Equalizer to BCM8706"
3198 " reg 0x%x <-- val 0x%x\n", reg
, val
);
3199 bnx2x_cl45_write(bp
, phy
, MDIO_XS_DEVAD
, reg
, val
);
3203 if (phy
->req_line_speed
== SPEED_10000
) {
3204 DP(NETIF_MSG_LINK
, "XGXS 8706 force 10Gbps\n");
3206 bnx2x_cl45_write(bp
, phy
,
3208 MDIO_PMA_REG_DIGITAL_CTRL
, 0x400);
3209 bnx2x_cl45_write(bp
, phy
,
3210 MDIO_PMA_DEVAD
, MDIO_PMA_REG_LASI_CTRL
, 1);
3212 /* Force 1Gbps using autoneg with 1G advertisment */
3214 /* Allow CL37 through CL73 */
3215 DP(NETIF_MSG_LINK
, "XGXS 8706 AutoNeg\n");
3216 bnx2x_cl45_write(bp
, phy
,
3217 MDIO_AN_DEVAD
, MDIO_AN_REG_CL37_CL73
, 0x040c);
3219 /* Enable Full-Duplex advertisment on CL37 */
3220 bnx2x_cl45_write(bp
, phy
,
3221 MDIO_AN_DEVAD
, MDIO_AN_REG_CL37_FC_LP
, 0x0020);
3222 /* Enable CL37 AN */
3223 bnx2x_cl45_write(bp
, phy
,
3224 MDIO_AN_DEVAD
, MDIO_AN_REG_CL37_AN
, 0x1000);
3226 bnx2x_cl45_write(bp
, phy
,
3227 MDIO_AN_DEVAD
, MDIO_AN_REG_ADV
, (1<<5));
3229 /* Enable clause 73 AN */
3230 bnx2x_cl45_write(bp
, phy
,
3231 MDIO_AN_DEVAD
, MDIO_AN_REG_CTRL
, 0x1200);
3232 bnx2x_cl45_write(bp
, phy
,
3233 MDIO_PMA_DEVAD
, MDIO_PMA_REG_RX_ALARM_CTRL
,
3235 bnx2x_cl45_write(bp
, phy
,
3236 MDIO_PMA_DEVAD
, MDIO_PMA_REG_LASI_CTRL
,
3239 bnx2x_save_bcm_spirom_ver(bp
, phy
, params
->port
);
3243 static u8
bnx2x_8726_config_init(struct bnx2x_phy
*phy
,
3244 struct link_params
*params
,
3245 struct link_vars
*vars
)
3247 struct bnx2x
*bp
= params
->bp
;
3249 u32 swap_val
, swap_override
, aeu_gpio_mask
, offset
;
3250 DP(NETIF_MSG_LINK
, "Initializing BCM8726\n");
3251 /* Restore normal power mode*/
3252 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_2
,
3253 MISC_REGISTERS_GPIO_OUTPUT_HIGH
, params
->port
);
3255 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_1
,
3256 MISC_REGISTERS_GPIO_OUTPUT_HIGH
, params
->port
);
3258 bnx2x_cl45_write(bp
, phy
, MDIO_PMA_DEVAD
, MDIO_PMA_REG_CTRL
, 1<<15);
3259 bnx2x_wait_reset_complete(bp
, phy
);
3261 bnx2x_8726_external_rom_boot(phy
, params
);
3263 /* Need to call module detected on initialization since
3264 the module detection triggered by actual module
3265 insertion might occur before driver is loaded, and when
3266 driver is loaded, it reset all registers, including the
3268 bnx2x_sfp_module_detection(phy
, params
);
3270 if (phy
->req_line_speed
== SPEED_1000
) {
3271 DP(NETIF_MSG_LINK
, "Setting 1G force\n");
3272 bnx2x_cl45_write(bp
, phy
,
3273 MDIO_PMA_DEVAD
, MDIO_PMA_REG_CTRL
, 0x40);
3274 bnx2x_cl45_write(bp
, phy
,
3275 MDIO_PMA_DEVAD
, MDIO_PMA_REG_10G_CTRL2
, 0xD);
3276 bnx2x_cl45_write(bp
, phy
,
3277 MDIO_PMA_DEVAD
, MDIO_PMA_REG_LASI_CTRL
, 0x5);
3278 bnx2x_cl45_write(bp
, phy
,
3279 MDIO_PMA_DEVAD
, MDIO_PMA_REG_RX_ALARM_CTRL
,
3281 } else if ((phy
->req_line_speed
== SPEED_AUTO_NEG
) &&
3282 (phy
->speed_cap_mask
&
3283 PORT_HW_CFG_SPEED_CAPABILITY_D0_1G
) &&
3284 ((phy
->speed_cap_mask
&
3285 PORT_HW_CFG_SPEED_CAPABILITY_D0_10G
) !=
3286 PORT_HW_CFG_SPEED_CAPABILITY_D0_10G
)) {
3287 DP(NETIF_MSG_LINK
, "Setting 1G clause37\n");
3288 /* Set Flow control */
3289 bnx2x_ext_phy_set_pause(params
, phy
, vars
);
3290 bnx2x_cl45_write(bp
, phy
,
3291 MDIO_AN_DEVAD
, MDIO_AN_REG_ADV
, 0x20);
3292 bnx2x_cl45_write(bp
, phy
,
3293 MDIO_AN_DEVAD
, MDIO_AN_REG_CL37_CL73
, 0x040c);
3294 bnx2x_cl45_write(bp
, phy
,
3295 MDIO_AN_DEVAD
, MDIO_AN_REG_CL37_FC_LD
, 0x0020);
3296 bnx2x_cl45_write(bp
, phy
,
3297 MDIO_AN_DEVAD
, MDIO_AN_REG_CL37_AN
, 0x1000);
3298 bnx2x_cl45_write(bp
, phy
,
3299 MDIO_AN_DEVAD
, MDIO_AN_REG_CTRL
, 0x1200);
3300 /* Enable RX-ALARM control to receive
3301 interrupt for 1G speed change */
3302 bnx2x_cl45_write(bp
, phy
,
3303 MDIO_PMA_DEVAD
, MDIO_PMA_REG_LASI_CTRL
, 0x4);
3304 bnx2x_cl45_write(bp
, phy
,
3305 MDIO_PMA_DEVAD
, MDIO_PMA_REG_RX_ALARM_CTRL
,
3308 } else { /* Default 10G. Set only LASI control */
3309 bnx2x_cl45_write(bp
, phy
,
3310 MDIO_PMA_DEVAD
, MDIO_PMA_REG_LASI_CTRL
, 1);
3313 /* Set TX PreEmphasis if needed */
3314 if ((params
->feature_config_flags
&
3315 FEATURE_CONFIG_OVERRIDE_PREEMPHASIS_ENABLED
)) {
3316 DP(NETIF_MSG_LINK
, "Setting TX_CTRL1 0x%x,"
3318 phy
->tx_preemphasis
[0],
3319 phy
->tx_preemphasis
[1]);
3320 bnx2x_cl45_write(bp
, phy
,
3322 MDIO_PMA_REG_8726_TX_CTRL1
,
3323 phy
->tx_preemphasis
[0]);
3325 bnx2x_cl45_write(bp
, phy
,
3327 MDIO_PMA_REG_8726_TX_CTRL2
,
3328 phy
->tx_preemphasis
[1]);
3331 /* Set GPIO3 to trigger SFP+ module insertion/removal */
3332 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_3
,
3333 MISC_REGISTERS_GPIO_INPUT_HI_Z
, params
->port
);
3335 /* The GPIO should be swapped if the swap register is set and active */
3336 swap_val
= REG_RD(bp
, NIG_REG_PORT_SWAP
);
3337 swap_override
= REG_RD(bp
, NIG_REG_STRAP_OVERRIDE
);
3339 /* Select function upon port-swap configuration */
3340 if (params
->port
== 0) {
3341 offset
= MISC_REG_AEU_ENABLE1_FUNC_0_OUT_0
;
3342 aeu_gpio_mask
= (swap_val
&& swap_override
) ?
3343 AEU_INPUTS_ATTN_BITS_GPIO3_FUNCTION_1
:
3344 AEU_INPUTS_ATTN_BITS_GPIO3_FUNCTION_0
;
3346 offset
= MISC_REG_AEU_ENABLE1_FUNC_1_OUT_0
;
3347 aeu_gpio_mask
= (swap_val
&& swap_override
) ?
3348 AEU_INPUTS_ATTN_BITS_GPIO3_FUNCTION_0
:
3349 AEU_INPUTS_ATTN_BITS_GPIO3_FUNCTION_1
;
3351 val
= REG_RD(bp
, offset
);
3352 /* add GPIO3 to group */
3353 val
|= aeu_gpio_mask
;
3354 REG_WR(bp
, offset
, val
);
3359 static u8
bnx2x_8073_config_init(struct bnx2x_phy
*phy
,
3360 struct link_params
*params
,
3361 struct link_vars
*vars
)
3363 struct bnx2x
*bp
= params
->bp
;
3366 DP(NETIF_MSG_LINK
, "Init 8073\n");
3368 gpio_port
= params
->port
;
3369 /* Restore normal power mode*/
3370 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_2
,
3371 MISC_REGISTERS_GPIO_OUTPUT_HIGH
, gpio_port
);
3373 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_1
,
3374 MISC_REGISTERS_GPIO_OUTPUT_HIGH
, gpio_port
);
3377 bnx2x_cl45_write(bp
, phy
,
3378 MDIO_PMA_DEVAD
, MDIO_PMA_REG_RX_ALARM_CTRL
, (1<<2));
3379 bnx2x_cl45_write(bp
, phy
,
3380 MDIO_PMA_DEVAD
, MDIO_PMA_REG_LASI_CTRL
, 0x0004);
3382 bnx2x_8073_set_pause_cl37(params
, phy
, vars
);
3384 bnx2x_8073_set_xaui_low_power_mode(bp
, phy
);
3386 bnx2x_cl45_read(bp
, phy
,
3387 MDIO_PMA_DEVAD
, MDIO_PMA_REG_M8051_MSGOUT_REG
, &tmp1
);
3389 bnx2x_cl45_read(bp
, phy
,
3390 MDIO_PMA_DEVAD
, MDIO_PMA_REG_RX_ALARM
, &tmp1
);
3392 DP(NETIF_MSG_LINK
, "Before rom RX_ALARM(port1): 0x%x\n", tmp1
);
3394 /* Enable CL37 BAM */
3395 bnx2x_cl45_read(bp
, phy
,
3397 MDIO_AN_REG_8073_BAM
, &val
);
3398 bnx2x_cl45_write(bp
, phy
,
3400 MDIO_AN_REG_8073_BAM
, val
| 1);
3402 if (params
->loopback_mode
== LOOPBACK_EXT
) {
3403 bnx2x_807x_force_10G(bp
, phy
);
3404 DP(NETIF_MSG_LINK
, "Forced speed 10G on 807X\n");
3407 bnx2x_cl45_write(bp
, phy
,
3408 MDIO_PMA_DEVAD
, MDIO_PMA_REG_BCM_CTRL
, 0x0002);
3410 if (phy
->req_line_speed
!= SPEED_AUTO_NEG
) {
3411 if (phy
->req_line_speed
== SPEED_10000
) {
3413 } else if (phy
->req_line_speed
== SPEED_2500
) {
3415 /* Note that 2.5G works only
3416 when used with 1G advertisment */
3421 if (phy
->speed_cap_mask
&
3422 PORT_HW_CFG_SPEED_CAPABILITY_D0_10G
)
3425 /* Note that 2.5G works only when
3426 used with 1G advertisment */
3427 if (phy
->speed_cap_mask
&
3428 (PORT_HW_CFG_SPEED_CAPABILITY_D0_1G
|
3429 PORT_HW_CFG_SPEED_CAPABILITY_D0_2_5G
))
3431 DP(NETIF_MSG_LINK
, "807x autoneg val = 0x%x\n", val
);
3434 bnx2x_cl45_write(bp
, phy
, MDIO_AN_DEVAD
, MDIO_AN_REG_ADV
, val
);
3435 bnx2x_cl45_read(bp
, phy
, MDIO_AN_DEVAD
, MDIO_AN_REG_8073_2_5G
, &tmp1
);
3437 if (((phy
->speed_cap_mask
& PORT_HW_CFG_SPEED_CAPABILITY_D0_2_5G
) &&
3438 (phy
->req_line_speed
== SPEED_AUTO_NEG
)) ||
3439 (phy
->req_line_speed
== SPEED_2500
)) {
3441 /* Allow 2.5G for A1 and above */
3442 bnx2x_cl45_read(bp
, phy
,
3443 MDIO_PMA_DEVAD
, MDIO_PMA_REG_8073_CHIP_REV
,
3445 DP(NETIF_MSG_LINK
, "Add 2.5G\n");
3451 DP(NETIF_MSG_LINK
, "Disable 2.5G\n");
3455 bnx2x_cl45_write(bp
, phy
, MDIO_AN_DEVAD
, MDIO_AN_REG_8073_2_5G
, tmp1
);
3456 /* Add support for CL37 (passive mode) II */
3458 bnx2x_cl45_read(bp
, phy
, MDIO_AN_DEVAD
, MDIO_AN_REG_CL37_FC_LD
, &tmp1
);
3459 bnx2x_cl45_write(bp
, phy
, MDIO_AN_DEVAD
, MDIO_AN_REG_CL37_FC_LD
,
3460 (tmp1
| ((phy
->req_duplex
== DUPLEX_FULL
) ?
3463 /* Add support for CL37 (passive mode) III */
3464 bnx2x_cl45_write(bp
, phy
, MDIO_AN_DEVAD
, MDIO_AN_REG_CL37_AN
, 0x1000);
3466 /* The SNR will improve about 2db by changing
3467 BW and FEE main tap. Rest commands are executed
3469 if (bnx2x_8073_is_snr_needed(bp
, phy
))
3470 bnx2x_cl45_write(bp
, phy
,
3471 MDIO_PMA_DEVAD
, MDIO_PMA_REG_EDC_FFE_MAIN
,
3474 /* Enable FEC (Forware Error Correction) Request in the AN */
3475 bnx2x_cl45_read(bp
, phy
, MDIO_AN_DEVAD
, MDIO_AN_REG_ADV2
, &tmp1
);
3477 bnx2x_cl45_write(bp
, phy
, MDIO_AN_DEVAD
, MDIO_AN_REG_ADV2
, tmp1
);
3479 bnx2x_ext_phy_set_pause(params
, phy
, vars
);
3481 /* Restart autoneg */
3483 bnx2x_cl45_write(bp
, phy
, MDIO_AN_DEVAD
, MDIO_AN_REG_CTRL
, 0x1200);
3484 DP(NETIF_MSG_LINK
, "807x Autoneg Restart: Advertise 1G=%x, 10G=%x\n",
3485 ((val
& (1<<5)) > 0), ((val
& (1<<7)) > 0));
3490 static u8
bnx2x_8727_config_init(struct bnx2x_phy
*phy
,
3491 struct link_params
*params
,
3492 struct link_vars
*vars
)
3494 u16 tmp1
, val
, mod_abs
;
3495 u16 rx_alarm_ctrl_val
;
3497 struct bnx2x
*bp
= params
->bp
;
3498 /* Enable PMD link, MOD_ABS_FLT, and 1G link alarm */
3500 bnx2x_wait_reset_complete(bp
, phy
);
3501 rx_alarm_ctrl_val
= (1<<2) | (1<<5) ;
3502 lasi_ctrl_val
= 0x0004;
3504 DP(NETIF_MSG_LINK
, "Initializing BCM8727\n");
3506 bnx2x_cl45_write(bp
, phy
,
3507 MDIO_PMA_DEVAD
, MDIO_PMA_REG_RX_ALARM_CTRL
,
3510 bnx2x_cl45_write(bp
, phy
,
3511 MDIO_PMA_DEVAD
, MDIO_PMA_REG_LASI_CTRL
, lasi_ctrl_val
);
3513 /* Initially configure MOD_ABS to interrupt when
3514 module is presence( bit 8) */
3515 bnx2x_cl45_read(bp
, phy
,
3516 MDIO_PMA_DEVAD
, MDIO_PMA_REG_PHY_IDENTIFIER
, &mod_abs
);
3517 /* Set EDC off by setting OPTXLOS signal input to low
3519 When the EDC is off it locks onto a reference clock and
3520 avoids becoming 'lost'.*/
3521 mod_abs
&= ~((1<<8) | (1<<9));
3522 bnx2x_cl45_write(bp
, phy
,
3523 MDIO_PMA_DEVAD
, MDIO_PMA_REG_PHY_IDENTIFIER
, mod_abs
);
3526 /* Make MOD_ABS give interrupt on change */
3527 bnx2x_cl45_read(bp
, phy
, MDIO_PMA_DEVAD
, MDIO_PMA_REG_8727_PCS_OPT_CTRL
,
3530 bnx2x_cl45_write(bp
, phy
,
3531 MDIO_PMA_DEVAD
, MDIO_PMA_REG_8727_PCS_OPT_CTRL
, val
);
3532 /* Set 8727 GPIOs to input to allow reading from the
3533 8727 GPIO0 status which reflect SFP+ module
3536 bnx2x_cl45_read(bp
, phy
, MDIO_PMA_DEVAD
, MDIO_PMA_REG_8727_PCS_OPT_CTRL
,
3538 val
&= 0xff8f; /* Reset bits 4-6 */
3539 bnx2x_cl45_write(bp
, phy
,
3540 MDIO_PMA_DEVAD
, MDIO_PMA_REG_8727_PCS_OPT_CTRL
, val
);
3542 bnx2x_8727_power_module(bp
, phy
, 1);
3544 bnx2x_cl45_read(bp
, phy
,
3545 MDIO_PMA_DEVAD
, MDIO_PMA_REG_M8051_MSGOUT_REG
, &tmp1
);
3547 bnx2x_cl45_read(bp
, phy
,
3548 MDIO_PMA_DEVAD
, MDIO_PMA_REG_RX_ALARM
, &tmp1
);
3550 /* Set option 1G speed */
3551 if (phy
->req_line_speed
== SPEED_1000
) {
3552 DP(NETIF_MSG_LINK
, "Setting 1G force\n");
3553 bnx2x_cl45_write(bp
, phy
,
3554 MDIO_PMA_DEVAD
, MDIO_PMA_REG_CTRL
, 0x40);
3555 bnx2x_cl45_write(bp
, phy
,
3556 MDIO_PMA_DEVAD
, MDIO_PMA_REG_10G_CTRL2
, 0xD);
3557 bnx2x_cl45_read(bp
, phy
,
3558 MDIO_PMA_DEVAD
, MDIO_PMA_REG_10G_CTRL2
, &tmp1
);
3559 DP(NETIF_MSG_LINK
, "1.7 = 0x%x\n", tmp1
);
3560 } else if ((phy
->req_line_speed
== SPEED_AUTO_NEG
) &&
3561 ((phy
->speed_cap_mask
&
3562 PORT_HW_CFG_SPEED_CAPABILITY_D0_1G
)) &&
3563 ((phy
->speed_cap_mask
&
3564 PORT_HW_CFG_SPEED_CAPABILITY_D0_10G
) !=
3565 PORT_HW_CFG_SPEED_CAPABILITY_D0_10G
)) {
3567 DP(NETIF_MSG_LINK
, "Setting 1G clause37\n");
3568 bnx2x_cl45_write(bp
, phy
,
3569 MDIO_AN_DEVAD
, MDIO_AN_REG_8727_MISC_CTRL
, 0);
3570 bnx2x_cl45_write(bp
, phy
,
3571 MDIO_AN_DEVAD
, MDIO_AN_REG_CL37_AN
, 0x1300);
3574 * Since the 8727 has only single reset pin, need to set the 10G
3575 * registers although it is default
3577 bnx2x_cl45_write(bp
, phy
,
3578 MDIO_AN_DEVAD
, MDIO_AN_REG_8727_MISC_CTRL
,
3580 bnx2x_cl45_write(bp
, phy
,
3581 MDIO_AN_DEVAD
, MDIO_AN_REG_CL37_AN
, 0x0100);
3582 bnx2x_cl45_write(bp
, phy
,
3583 MDIO_PMA_DEVAD
, MDIO_PMA_REG_CTRL
, 0x2040);
3584 bnx2x_cl45_write(bp
, phy
,
3585 MDIO_PMA_DEVAD
, MDIO_PMA_REG_10G_CTRL2
,
3590 /* Set 2-wire transfer rate of SFP+ module EEPROM
3591 * to 100Khz since some DACs(direct attached cables) do
3592 * not work at 400Khz.
3594 bnx2x_cl45_write(bp
, phy
,
3595 MDIO_PMA_DEVAD
, MDIO_PMA_REG_8727_TWO_WIRE_SLAVE_ADDR
,
3598 /* Set TX PreEmphasis if needed */
3599 if ((params
->feature_config_flags
&
3600 FEATURE_CONFIG_OVERRIDE_PREEMPHASIS_ENABLED
)) {
3601 DP(NETIF_MSG_LINK
, "Setting TX_CTRL1 0x%x, TX_CTRL2 0x%x\n",
3602 phy
->tx_preemphasis
[0],
3603 phy
->tx_preemphasis
[1]);
3604 bnx2x_cl45_write(bp
, phy
,
3605 MDIO_PMA_DEVAD
, MDIO_PMA_REG_8727_TX_CTRL1
,
3606 phy
->tx_preemphasis
[0]);
3608 bnx2x_cl45_write(bp
, phy
,
3609 MDIO_PMA_DEVAD
, MDIO_PMA_REG_8727_TX_CTRL2
,
3610 phy
->tx_preemphasis
[1]);
3616 static u8
bnx2x_7101_config_init(struct bnx2x_phy
*phy
,
3617 struct link_params
*params
,
3618 struct link_vars
*vars
)
3620 u16 fw_ver1
, fw_ver2
, val
;
3621 struct bnx2x
*bp
= params
->bp
;
3622 DP(NETIF_MSG_LINK
, "Setting the SFX7101 LASI indication\n");
3624 /* Restore normal power mode*/
3625 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_2
,
3626 MISC_REGISTERS_GPIO_OUTPUT_HIGH
, params
->port
);
3628 bnx2x_ext_phy_hw_reset(bp
, params
->port
);
3629 bnx2x_wait_reset_complete(bp
, phy
);
3631 bnx2x_cl45_write(bp
, phy
,
3632 MDIO_PMA_DEVAD
, MDIO_PMA_REG_LASI_CTRL
, 0x1);
3633 DP(NETIF_MSG_LINK
, "Setting the SFX7101 LED to blink on traffic\n");
3634 bnx2x_cl45_write(bp
, phy
,
3635 MDIO_PMA_DEVAD
, MDIO_PMA_REG_7107_LED_CNTL
, (1<<3));
3637 bnx2x_ext_phy_set_pause(params
, phy
, vars
);
3638 /* Restart autoneg */
3639 bnx2x_cl45_read(bp
, phy
,
3640 MDIO_AN_DEVAD
, MDIO_AN_REG_CTRL
, &val
);
3642 bnx2x_cl45_write(bp
, phy
,
3643 MDIO_AN_DEVAD
, MDIO_AN_REG_CTRL
, val
);
3645 /* Save spirom version */
3646 bnx2x_cl45_read(bp
, phy
,
3647 MDIO_PMA_DEVAD
, MDIO_PMA_REG_7101_VER1
, &fw_ver1
);
3649 bnx2x_cl45_read(bp
, phy
,
3650 MDIO_PMA_DEVAD
, MDIO_PMA_REG_7101_VER2
, &fw_ver2
);
3651 bnx2x_save_spirom_version(bp
, params
->port
,
3652 (u32
)(fw_ver1
<<16 | fw_ver2
), phy
->ver_addr
);
3656 static u8
bnx2x_848xx_cmn_config_init(struct bnx2x_phy
*phy
,
3657 struct link_params
*params
,
3658 struct link_vars
*vars
)
3660 struct bnx2x
*bp
= params
->bp
;
3661 u16 autoneg_val
, an_1000_val
, an_10_100_val
;
3662 bnx2x_wait_reset_complete(bp
, phy
);
3663 bnx2x_bits_en(bp
, NIG_REG_LATCH_BC_0
+ params
->port
*4,
3664 1 << NIG_LATCH_BC_ENABLE_MI_INT
);
3666 bnx2x_cl45_write(bp
, phy
,
3667 MDIO_PMA_DEVAD
, MDIO_PMA_REG_CTRL
, 0x0000);
3668 bnx2x_848xx_set_led(bp
, phy
);
3669 /* set 1000 speed advertisement */
3670 bnx2x_cl45_read(bp
, phy
,
3671 MDIO_AN_DEVAD
, MDIO_AN_REG_8481_1000T_CTRL
,
3674 bnx2x_ext_phy_set_pause(params
, phy
, vars
);
3675 bnx2x_cl45_read(bp
, phy
,
3677 MDIO_AN_REG_8481_LEGACY_AN_ADV
,
3679 bnx2x_cl45_read(bp
, phy
,
3680 MDIO_AN_DEVAD
, MDIO_AN_REG_8481_LEGACY_MII_CTRL
,
3682 /* Disable forced speed */
3683 autoneg_val
&= ~((1<<6) | (1<<8) | (1<<9) | (1<<12) | (1<<13));
3684 an_10_100_val
&= ~((1<<5) | (1<<6) | (1<<7) | (1<<8));
3686 if (((phy
->req_line_speed
== SPEED_AUTO_NEG
) &&
3687 (phy
->speed_cap_mask
&
3688 PORT_HW_CFG_SPEED_CAPABILITY_D0_1G
)) ||
3689 (phy
->req_line_speed
== SPEED_1000
)) {
3690 an_1000_val
|= (1<<8);
3691 autoneg_val
|= (1<<9 | 1<<12);
3692 if (phy
->req_duplex
== DUPLEX_FULL
)
3693 an_1000_val
|= (1<<9);
3694 DP(NETIF_MSG_LINK
, "Advertising 1G\n");
3696 an_1000_val
&= ~((1<<8) | (1<<9));
3698 bnx2x_cl45_write(bp
, phy
,
3699 MDIO_AN_DEVAD
, MDIO_AN_REG_8481_1000T_CTRL
,
3702 /* set 10 speed advertisement */
3703 if (((phy
->req_line_speed
== SPEED_AUTO_NEG
) &&
3704 (phy
->speed_cap_mask
&
3705 (PORT_HW_CFG_SPEED_CAPABILITY_D0_100M_FULL
|
3706 PORT_HW_CFG_SPEED_CAPABILITY_D0_100M_HALF
)))) {
3707 an_10_100_val
|= (1<<7);
3708 /* Enable autoneg and restart autoneg for legacy speeds */
3709 autoneg_val
|= (1<<9 | 1<<12);
3711 if (phy
->req_duplex
== DUPLEX_FULL
)
3712 an_10_100_val
|= (1<<8);
3713 DP(NETIF_MSG_LINK
, "Advertising 100M\n");
3715 /* set 10 speed advertisement */
3716 if (((phy
->req_line_speed
== SPEED_AUTO_NEG
) &&
3717 (phy
->speed_cap_mask
&
3718 (PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_FULL
|
3719 PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_HALF
)))) {
3720 an_10_100_val
|= (1<<5);
3721 autoneg_val
|= (1<<9 | 1<<12);
3722 if (phy
->req_duplex
== DUPLEX_FULL
)
3723 an_10_100_val
|= (1<<6);
3724 DP(NETIF_MSG_LINK
, "Advertising 10M\n");
3727 /* Only 10/100 are allowed to work in FORCE mode */
3728 if (phy
->req_line_speed
== SPEED_100
) {
3729 autoneg_val
|= (1<<13);
3730 /* Enabled AUTO-MDIX when autoneg is disabled */
3731 bnx2x_cl45_write(bp
, phy
,
3732 MDIO_AN_DEVAD
, MDIO_AN_REG_8481_AUX_CTRL
,
3733 (1<<15 | 1<<9 | 7<<0));
3734 DP(NETIF_MSG_LINK
, "Setting 100M force\n");
3736 if (phy
->req_line_speed
== SPEED_10
) {
3737 /* Enabled AUTO-MDIX when autoneg is disabled */
3738 bnx2x_cl45_write(bp
, phy
,
3739 MDIO_AN_DEVAD
, MDIO_AN_REG_8481_AUX_CTRL
,
3740 (1<<15 | 1<<9 | 7<<0));
3741 DP(NETIF_MSG_LINK
, "Setting 10M force\n");
3744 bnx2x_cl45_write(bp
, phy
,
3745 MDIO_AN_DEVAD
, MDIO_AN_REG_8481_LEGACY_AN_ADV
,
3748 if (phy
->req_duplex
== DUPLEX_FULL
)
3749 autoneg_val
|= (1<<8);
3751 bnx2x_cl45_write(bp
, phy
,
3753 MDIO_AN_REG_8481_LEGACY_MII_CTRL
, autoneg_val
);
3755 if (((phy
->req_line_speed
== SPEED_AUTO_NEG
) &&
3756 (phy
->speed_cap_mask
&
3757 PORT_HW_CFG_SPEED_CAPABILITY_D0_10G
)) ||
3758 (phy
->req_line_speed
== SPEED_10000
)) {
3759 DP(NETIF_MSG_LINK
, "Advertising 10G\n");
3760 /* Restart autoneg for 10G*/
3762 bnx2x_cl45_write(bp
, phy
,
3763 MDIO_AN_DEVAD
, MDIO_AN_REG_CTRL
,
3765 } else if (phy
->req_line_speed
!= SPEED_10
&&
3766 phy
->req_line_speed
!= SPEED_100
) {
3767 bnx2x_cl45_write(bp
, phy
,
3769 MDIO_AN_REG_8481_10GBASE_T_AN_CTRL
,
3772 /* Save spirom version */
3773 bnx2x_save_848xx_spirom_version(phy
, params
);
3778 static u8
bnx2x_848x3_config_init(struct bnx2x_phy
*phy
,
3779 struct link_params
*params
,
3780 struct link_vars
*vars
)
3782 struct bnx2x
*bp
= params
->bp
;
3785 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_3
,
3786 MISC_REGISTERS_GPIO_OUTPUT_HIGH
,
3788 msleep(200); /* 100 is not enough */
3791 * BCM84823 requires that XGXS links up first @ 10G for normal
3794 temp
= vars
->line_speed
;
3795 vars
->line_speed
= SPEED_10000
;
3796 bnx2x_set_autoneg(phy
, params
, vars
, 0);
3797 bnx2x_program_serdes(phy
, params
, vars
);
3798 vars
->line_speed
= temp
;
3799 return bnx2x_848xx_cmn_config_init(phy
, params
, vars
);
3802 static u8
bnx2x_8481_config_init(struct bnx2x_phy
*phy
,
3803 struct link_params
*params
,
3804 struct link_vars
*vars
)
3806 struct bnx2x
*bp
= params
->bp
;
3807 /* Restore normal power mode*/
3808 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_2
,
3809 MISC_REGISTERS_GPIO_OUTPUT_HIGH
, params
->port
);
3812 bnx2x_ext_phy_hw_reset(bp
, params
->port
);
3814 bnx2x_cl45_write(bp
, phy
, MDIO_PMA_DEVAD
, MDIO_PMA_REG_CTRL
, 1<<15);
3815 return bnx2x_848xx_cmn_config_init(phy
, params
, vars
);
3819 static void bnx2x_ext_phy_10G_an_resolve(struct bnx2x
*bp
,
3820 struct bnx2x_phy
*phy
,
3821 struct link_vars
*vars
)
3824 bnx2x_cl45_read(bp
, phy
,
3826 MDIO_AN_REG_STATUS
, &val
);
3827 bnx2x_cl45_read(bp
, phy
,
3829 MDIO_AN_REG_STATUS
, &val
);
3831 vars
->link_status
|= LINK_STATUS_AUTO_NEGOTIATE_COMPLETE
;
3832 if ((val
& (1<<0)) == 0)
3833 vars
->link_status
|= LINK_STATUS_PARALLEL_DETECTION_USED
;
3835 static void bnx2x_8727_handle_mod_abs(struct bnx2x_phy
*phy
,
3836 struct link_params
*params
)
3838 struct bnx2x
*bp
= params
->bp
;
3839 u16 mod_abs
, rx_alarm_status
;
3840 u32 val
= REG_RD(bp
, params
->shmem_base
+
3841 offsetof(struct shmem_region
, dev_info
.
3842 port_feature_config
[params
->port
].
3844 bnx2x_cl45_read(bp
, phy
,
3846 MDIO_PMA_REG_PHY_IDENTIFIER
, &mod_abs
);
3847 if (mod_abs
& (1<<8)) {
3849 /* Module is absent */
3850 DP(NETIF_MSG_LINK
, "MOD_ABS indication "
3851 "show module is absent\n");
3853 /* 1. Set mod_abs to detect next module
3855 2. Set EDC off by setting OPTXLOS signal input to low
3857 When the EDC is off it locks onto a reference clock and
3858 avoids becoming 'lost'.*/
3859 mod_abs
&= ~((1<<8)|(1<<9));
3860 bnx2x_cl45_write(bp
, phy
,
3862 MDIO_PMA_REG_PHY_IDENTIFIER
, mod_abs
);
3864 /* Clear RX alarm since it stays up as long as
3865 the mod_abs wasn't changed */
3866 bnx2x_cl45_read(bp
, phy
,
3868 MDIO_PMA_REG_RX_ALARM
, &rx_alarm_status
);
3871 /* Module is present */
3872 DP(NETIF_MSG_LINK
, "MOD_ABS indication "
3873 "show module is present\n");
3874 /* First thing, disable transmitter,
3875 and if the module is ok, the
3876 module_detection will enable it*/
3878 /* 1. Set mod_abs to detect next module
3879 absent event ( bit 8)
3880 2. Restore the default polarity of the OPRXLOS signal and
3881 this signal will then correctly indicate the presence or
3882 absence of the Rx signal. (bit 9) */
3883 mod_abs
|= ((1<<8)|(1<<9));
3884 bnx2x_cl45_write(bp
, phy
,
3886 MDIO_PMA_REG_PHY_IDENTIFIER
, mod_abs
);
3888 /* Clear RX alarm since it stays up as long as
3889 the mod_abs wasn't changed. This is need to be done
3890 before calling the module detection, otherwise it will clear
3891 the link update alarm */
3892 bnx2x_cl45_read(bp
, phy
,
3894 MDIO_PMA_REG_RX_ALARM
, &rx_alarm_status
);
3897 if ((val
& PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK
) ==
3898 PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_DISABLE_TX_LASER
)
3899 bnx2x_sfp_set_transmitter(bp
, phy
, params
->port
, 0);
3901 if (bnx2x_wait_for_sfp_module_initialized(phy
, params
) == 0)
3902 bnx2x_sfp_module_detection(phy
, params
);
3904 DP(NETIF_MSG_LINK
, "SFP+ module is not initialized\n");
3907 DP(NETIF_MSG_LINK
, "8727 RX_ALARM_STATUS 0x%x\n",
3909 /* No need to check link status in case of
3910 module plugged in/out */
3914 static u8
bnx2x_8705_read_status(struct bnx2x_phy
*phy
,
3915 struct link_params
*params
,
3916 struct link_vars
*vars
)
3920 struct bnx2x
*bp
= params
->bp
;
3921 DP(NETIF_MSG_LINK
, "read status 8705\n");
3922 bnx2x_cl45_read(bp
, phy
,
3923 MDIO_WIS_DEVAD
, MDIO_WIS_REG_LASI_STATUS
, &val1
);
3924 DP(NETIF_MSG_LINK
, "8705 LASI status 0x%x\n", val1
);
3926 bnx2x_cl45_read(bp
, phy
,
3927 MDIO_WIS_DEVAD
, MDIO_WIS_REG_LASI_STATUS
, &val1
);
3928 DP(NETIF_MSG_LINK
, "8705 LASI status 0x%x\n", val1
);
3930 bnx2x_cl45_read(bp
, phy
,
3931 MDIO_PMA_DEVAD
, MDIO_PMA_REG_RX_SD
, &rx_sd
);
3933 bnx2x_cl45_read(bp
, phy
,
3934 MDIO_PMA_DEVAD
, 0xc809, &val1
);
3935 bnx2x_cl45_read(bp
, phy
,
3936 MDIO_PMA_DEVAD
, 0xc809, &val1
);
3938 DP(NETIF_MSG_LINK
, "8705 1.c809 val=0x%x\n", val1
);
3939 link_up
= ((rx_sd
& 0x1) && (val1
& (1<<9)) && ((val1
& (1<<8)) == 0));
3941 vars
->line_speed
= SPEED_10000
;
3942 bnx2x_ext_phy_resolve_fc(phy
, params
, vars
);
3947 static u8
bnx2x_8706_8726_read_status(struct bnx2x_phy
*phy
,
3948 struct link_params
*params
,
3949 struct link_vars
*vars
)
3952 u16 val1
, val2
, rx_sd
, pcs_status
;
3953 struct bnx2x
*bp
= params
->bp
;
3954 DP(NETIF_MSG_LINK
, "XGXS 8706/8726\n");
3956 bnx2x_cl45_read(bp
, phy
,
3957 MDIO_PMA_DEVAD
, MDIO_PMA_REG_RX_ALARM
, &val2
);
3958 /* clear LASI indication*/
3959 bnx2x_cl45_read(bp
, phy
,
3960 MDIO_PMA_DEVAD
, MDIO_PMA_REG_LASI_STATUS
, &val1
);
3961 bnx2x_cl45_read(bp
, phy
,
3962 MDIO_PMA_DEVAD
, MDIO_PMA_REG_LASI_STATUS
, &val2
);
3963 DP(NETIF_MSG_LINK
, "8706/8726 LASI status 0x%x--> 0x%x\n", val1
, val2
);
3965 bnx2x_cl45_read(bp
, phy
,
3966 MDIO_PMA_DEVAD
, MDIO_PMA_REG_RX_SD
, &rx_sd
);
3967 bnx2x_cl45_read(bp
, phy
,
3968 MDIO_PCS_DEVAD
, MDIO_PCS_REG_STATUS
, &pcs_status
);
3969 bnx2x_cl45_read(bp
, phy
,
3970 MDIO_AN_DEVAD
, MDIO_AN_REG_LINK_STATUS
, &val2
);
3971 bnx2x_cl45_read(bp
, phy
,
3972 MDIO_AN_DEVAD
, MDIO_AN_REG_LINK_STATUS
, &val2
);
3974 DP(NETIF_MSG_LINK
, "8706/8726 rx_sd 0x%x pcs_status 0x%x 1Gbps"
3975 " link_status 0x%x\n", rx_sd
, pcs_status
, val2
);
3976 /* link is up if both bit 0 of pmd_rx_sd and
3977 * bit 0 of pcs_status are set, or if the autoneg bit
3980 link_up
= ((rx_sd
& pcs_status
& 0x1) || (val2
& (1<<1)));
3983 vars
->line_speed
= SPEED_1000
;
3985 vars
->line_speed
= SPEED_10000
;
3986 bnx2x_ext_phy_resolve_fc(phy
, params
, vars
);
3990 static u8
bnx2x_8706_read_status(struct bnx2x_phy
*phy
,
3991 struct link_params
*params
,
3992 struct link_vars
*vars
)
3994 return bnx2x_8706_8726_read_status(phy
, params
, vars
);
3997 static u8
bnx2x_8726_read_status(struct bnx2x_phy
*phy
,
3998 struct link_params
*params
,
3999 struct link_vars
*vars
)
4001 struct bnx2x
*bp
= params
->bp
;
4003 u8 link_up
= bnx2x_8706_8726_read_status(phy
, params
, vars
);
4005 bnx2x_cl45_read(bp
, phy
,
4006 MDIO_PMA_DEVAD
, MDIO_PMA_REG_PHY_IDENTIFIER
,
4008 if (val1
& (1<<15)) {
4009 DP(NETIF_MSG_LINK
, "Tx is disabled\n");
4011 vars
->line_speed
= 0;
4017 static u8
bnx2x_8727_read_status(struct bnx2x_phy
*phy
,
4018 struct link_params
*params
,
4019 struct link_vars
*vars
)
4022 struct bnx2x
*bp
= params
->bp
;
4024 u16 link_status
= 0;
4025 u16 rx_alarm_status
, val1
;
4026 /* Check the LASI */
4027 bnx2x_cl45_read(bp
, phy
,
4028 MDIO_PMA_DEVAD
, MDIO_PMA_REG_RX_ALARM
,
4030 vars
->line_speed
= 0;
4031 DP(NETIF_MSG_LINK
, "8727 RX_ALARM_STATUS 0x%x\n", rx_alarm_status
);
4033 bnx2x_cl45_read(bp
, phy
,
4034 MDIO_PMA_DEVAD
, MDIO_PMA_REG_LASI_STATUS
, &val1
);
4036 DP(NETIF_MSG_LINK
, "8727 LASI status 0x%x\n", val1
);
4039 bnx2x_cl45_read(bp
, phy
,
4040 MDIO_PMA_DEVAD
, MDIO_PMA_REG_M8051_MSGOUT_REG
, &val1
);
4043 * If a module is present and there is need to check
4046 if (!(phy
->flags
& FLAGS_NOC
) && !(rx_alarm_status
& (1<<5))) {
4047 /* Check over-current using 8727 GPIO0 input*/
4048 bnx2x_cl45_read(bp
, phy
,
4049 MDIO_PMA_DEVAD
, MDIO_PMA_REG_8727_GPIO_CTRL
,
4052 if ((val1
& (1<<8)) == 0) {
4053 DP(NETIF_MSG_LINK
, "8727 Power fault has been detected"
4054 " on port %d\n", params
->port
);
4055 netdev_err(bp
->dev
, "Error: Power fault on Port %d has"
4056 " been detected and the power to "
4057 "that SFP+ module has been removed"
4058 " to prevent failure of the card."
4059 " Please remove the SFP+ module and"
4060 " restart the system to clear this"
4065 * Disable all RX_ALARMs except for
4068 bnx2x_cl45_write(bp
, phy
,
4070 MDIO_PMA_REG_RX_ALARM_CTRL
, (1<<5));
4072 bnx2x_cl45_read(bp
, phy
,
4074 MDIO_PMA_REG_PHY_IDENTIFIER
, &val1
);
4075 /* Wait for module_absent_event */
4077 bnx2x_cl45_write(bp
, phy
,
4079 MDIO_PMA_REG_PHY_IDENTIFIER
, val1
);
4080 /* Clear RX alarm */
4081 bnx2x_cl45_read(bp
, phy
,
4083 MDIO_PMA_REG_RX_ALARM
, &rx_alarm_status
);
4086 } /* Over current check */
4088 /* When module absent bit is set, check module */
4089 if (rx_alarm_status
& (1<<5)) {
4090 bnx2x_8727_handle_mod_abs(phy
, params
);
4091 /* Enable all mod_abs and link detection bits */
4092 bnx2x_cl45_write(bp
, phy
,
4093 MDIO_PMA_DEVAD
, MDIO_PMA_REG_RX_ALARM_CTRL
,
4097 /* If transmitter is disabled, ignore false link up indication */
4098 bnx2x_cl45_read(bp
, phy
,
4099 MDIO_PMA_DEVAD
, MDIO_PMA_REG_PHY_IDENTIFIER
, &val1
);
4100 if (val1
& (1<<15)) {
4101 DP(NETIF_MSG_LINK
, "Tx is disabled\n");
4105 bnx2x_cl45_read(bp
, phy
,
4107 MDIO_PMA_REG_8073_SPEED_LINK_STATUS
, &link_status
);
4109 /* Bits 0..2 --> speed detected,
4110 bits 13..15--> link is down */
4111 if ((link_status
& (1<<2)) && (!(link_status
& (1<<15)))) {
4113 vars
->line_speed
= SPEED_10000
;
4114 } else if ((link_status
& (1<<0)) && (!(link_status
& (1<<13)))) {
4116 vars
->line_speed
= SPEED_1000
;
4117 DP(NETIF_MSG_LINK
, "port %x: External link up in 1G\n",
4121 DP(NETIF_MSG_LINK
, "port %x: External link is down\n",
4125 bnx2x_ext_phy_resolve_fc(phy
, params
, vars
);
4129 static void bnx2x_8073_resolve_fc(struct bnx2x_phy
*phy
,
4130 struct link_params
*params
,
4131 struct link_vars
*vars
)
4133 struct bnx2x
*bp
= params
->bp
;
4134 if (phy
->req_line_speed
== SPEED_10
||
4135 phy
->req_line_speed
== SPEED_100
) {
4136 vars
->flow_ctrl
= phy
->req_flow_ctrl
;
4140 if (bnx2x_ext_phy_resolve_fc(phy
, params
, vars
) &&
4141 (vars
->flow_ctrl
== BNX2X_FLOW_CTRL_NONE
)) {
4143 u16 ld_pause
; /* local */
4144 u16 lp_pause
; /* link partner */
4145 bnx2x_cl45_read(bp
, phy
,
4147 MDIO_AN_REG_CL37_FC_LD
, &ld_pause
);
4149 bnx2x_cl45_read(bp
, phy
,
4151 MDIO_AN_REG_CL37_FC_LP
, &lp_pause
);
4152 pause_result
= (ld_pause
&
4153 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH
) >> 5;
4154 pause_result
|= (lp_pause
&
4155 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH
) >> 7;
4157 bnx2x_pause_resolve(vars
, pause_result
);
4158 DP(NETIF_MSG_LINK
, "Ext PHY CL37 pause result 0x%x\n",
4162 static u8
bnx2x_8073_read_status(struct bnx2x_phy
*phy
,
4163 struct link_params
*params
,
4164 struct link_vars
*vars
)
4166 struct bnx2x
*bp
= params
->bp
;
4169 u16 link_status
= 0;
4170 u16 an1000_status
= 0;
4172 bnx2x_cl45_read(bp
, phy
,
4173 MDIO_PMA_DEVAD
, MDIO_PMA_REG_LASI_STATUS
, &val1
);
4175 DP(NETIF_MSG_LINK
, "8703 LASI status 0x%x\n", val1
);
4177 /* clear the interrupt LASI status register */
4178 bnx2x_cl45_read(bp
, phy
,
4179 MDIO_PCS_DEVAD
, MDIO_PCS_REG_STATUS
, &val2
);
4180 bnx2x_cl45_read(bp
, phy
,
4181 MDIO_PCS_DEVAD
, MDIO_PCS_REG_STATUS
, &val1
);
4182 DP(NETIF_MSG_LINK
, "807x PCS status 0x%x->0x%x\n", val2
, val1
);
4184 bnx2x_cl45_read(bp
, phy
,
4185 MDIO_PMA_DEVAD
, MDIO_PMA_REG_M8051_MSGOUT_REG
, &val1
);
4187 /* Check the LASI */
4188 bnx2x_cl45_read(bp
, phy
,
4189 MDIO_PMA_DEVAD
, MDIO_PMA_REG_RX_ALARM
, &val2
);
4191 DP(NETIF_MSG_LINK
, "KR 0x9003 0x%x\n", val2
);
4193 /* Check the link status */
4194 bnx2x_cl45_read(bp
, phy
,
4195 MDIO_PCS_DEVAD
, MDIO_PCS_REG_STATUS
, &val2
);
4196 DP(NETIF_MSG_LINK
, "KR PCS status 0x%x\n", val2
);
4198 bnx2x_cl45_read(bp
, phy
,
4199 MDIO_PMA_DEVAD
, MDIO_PMA_REG_STATUS
, &val2
);
4200 bnx2x_cl45_read(bp
, phy
,
4201 MDIO_PMA_DEVAD
, MDIO_PMA_REG_STATUS
, &val1
);
4202 link_up
= ((val1
& 4) == 4);
4203 DP(NETIF_MSG_LINK
, "PMA_REG_STATUS=0x%x\n", val1
);
4206 ((phy
->req_line_speed
!= SPEED_10000
))) {
4207 if (bnx2x_8073_xaui_wa(bp
, phy
) != 0)
4210 bnx2x_cl45_read(bp
, phy
,
4211 MDIO_AN_DEVAD
, MDIO_AN_REG_LINK_STATUS
, &an1000_status
);
4212 bnx2x_cl45_read(bp
, phy
,
4213 MDIO_AN_DEVAD
, MDIO_AN_REG_LINK_STATUS
, &an1000_status
);
4215 /* Check the link status on 1.1.2 */
4216 bnx2x_cl45_read(bp
, phy
,
4217 MDIO_PMA_DEVAD
, MDIO_PMA_REG_STATUS
, &val2
);
4218 bnx2x_cl45_read(bp
, phy
,
4219 MDIO_PMA_DEVAD
, MDIO_PMA_REG_STATUS
, &val1
);
4220 DP(NETIF_MSG_LINK
, "KR PMA status 0x%x->0x%x,"
4221 "an_link_status=0x%x\n", val2
, val1
, an1000_status
);
4223 link_up
= (((val1
& 4) == 4) || (an1000_status
& (1<<1)));
4224 if (link_up
&& bnx2x_8073_is_snr_needed(bp
, phy
)) {
4225 /* The SNR will improve about 2dbby
4226 changing the BW and FEE main tap.*/
4227 /* The 1st write to change FFE main
4228 tap is set before restart AN */
4229 /* Change PLL Bandwidth in EDC
4231 bnx2x_cl45_write(bp
, phy
,
4232 MDIO_PMA_DEVAD
, MDIO_PMA_REG_PLL_BANDWIDTH
,
4235 /* Change CDR Bandwidth in EDC register */
4236 bnx2x_cl45_write(bp
, phy
,
4237 MDIO_PMA_DEVAD
, MDIO_PMA_REG_CDR_BANDWIDTH
,
4240 bnx2x_cl45_read(bp
, phy
,
4241 MDIO_PMA_DEVAD
, MDIO_PMA_REG_8073_SPEED_LINK_STATUS
,
4244 /* Bits 0..2 --> speed detected, bits 13..15--> link is down */
4245 if ((link_status
& (1<<2)) && (!(link_status
& (1<<15)))) {
4247 vars
->line_speed
= SPEED_10000
;
4248 DP(NETIF_MSG_LINK
, "port %x: External link up in 10G\n",
4250 } else if ((link_status
& (1<<1)) && (!(link_status
& (1<<14)))) {
4252 vars
->line_speed
= SPEED_2500
;
4253 DP(NETIF_MSG_LINK
, "port %x: External link up in 2.5G\n",
4255 } else if ((link_status
& (1<<0)) && (!(link_status
& (1<<13)))) {
4257 vars
->line_speed
= SPEED_1000
;
4258 DP(NETIF_MSG_LINK
, "port %x: External link up in 1G\n",
4262 DP(NETIF_MSG_LINK
, "port %x: External link is down\n",
4267 bnx2x_ext_phy_10G_an_resolve(bp
, phy
, vars
);
4268 bnx2x_8073_resolve_fc(phy
, params
, vars
);
4273 static u8
bnx2x_7101_read_status(struct bnx2x_phy
*phy
,
4274 struct link_params
*params
,
4275 struct link_vars
*vars
)
4277 struct bnx2x
*bp
= params
->bp
;
4280 bnx2x_cl45_read(bp
, phy
,
4281 MDIO_PMA_DEVAD
, MDIO_PMA_REG_LASI_STATUS
, &val2
);
4282 bnx2x_cl45_read(bp
, phy
,
4283 MDIO_PMA_DEVAD
, MDIO_PMA_REG_LASI_STATUS
, &val1
);
4284 DP(NETIF_MSG_LINK
, "10G-base-T LASI status 0x%x->0x%x\n",
4286 bnx2x_cl45_read(bp
, phy
,
4287 MDIO_PMA_DEVAD
, MDIO_PMA_REG_STATUS
, &val2
);
4288 bnx2x_cl45_read(bp
, phy
,
4289 MDIO_PMA_DEVAD
, MDIO_PMA_REG_STATUS
, &val1
);
4290 DP(NETIF_MSG_LINK
, "10G-base-T PMA status 0x%x->0x%x\n",
4292 link_up
= ((val1
& 4) == 4);
4294 * print the AN outcome of the SFX7101 PHY
4297 bnx2x_cl45_read(bp
, phy
,
4298 MDIO_AN_DEVAD
, MDIO_AN_REG_MASTER_STATUS
,
4300 vars
->line_speed
= SPEED_10000
;
4301 DP(NETIF_MSG_LINK
, "SFX7101 AN status 0x%x->Master=%x\n",
4302 val2
, (val2
& (1<<14)));
4303 bnx2x_ext_phy_10G_an_resolve(bp
, phy
, vars
);
4304 bnx2x_ext_phy_resolve_fc(phy
, params
, vars
);
4309 static u8
bnx2x_848xx_read_status(struct bnx2x_phy
*phy
,
4310 struct link_params
*params
,
4311 struct link_vars
*vars
)
4313 struct bnx2x
*bp
= params
->bp
;
4314 u16 val
, val1
, val2
;
4317 /* Check 10G-BaseT link status */
4318 /* Check PMD signal ok */
4319 bnx2x_cl45_read(bp
, phy
,
4320 MDIO_AN_DEVAD
, 0xFFFA, &val1
);
4321 bnx2x_cl45_read(bp
, phy
,
4322 MDIO_PMA_DEVAD
, MDIO_PMA_REG_8481_PMD_SIGNAL
,
4324 DP(NETIF_MSG_LINK
, "BCM848xx: PMD_SIGNAL 1.a811 = 0x%x\n", val2
);
4326 /* Check link 10G */
4327 if (val2
& (1<<11)) {
4328 vars
->line_speed
= SPEED_10000
;
4330 bnx2x_ext_phy_10G_an_resolve(bp
, phy
, vars
);
4331 } else { /* Check Legacy speed link */
4332 u16 legacy_status
, legacy_speed
;
4334 /* Enable expansion register 0x42 (Operation mode status) */
4335 bnx2x_cl45_write(bp
, phy
,
4337 MDIO_AN_REG_8481_EXPANSION_REG_ACCESS
, 0xf42);
4339 /* Get legacy speed operation status */
4340 bnx2x_cl45_read(bp
, phy
,
4342 MDIO_AN_REG_8481_EXPANSION_REG_RD_RW
,
4345 DP(NETIF_MSG_LINK
, "Legacy speed status"
4346 " = 0x%x\n", legacy_status
);
4347 link_up
= ((legacy_status
& (1<<11)) == (1<<11));
4349 legacy_speed
= (legacy_status
& (3<<9));
4350 if (legacy_speed
== (0<<9))
4351 vars
->line_speed
= SPEED_10
;
4352 else if (legacy_speed
== (1<<9))
4353 vars
->line_speed
= SPEED_100
;
4354 else if (legacy_speed
== (2<<9))
4355 vars
->line_speed
= SPEED_1000
;
4356 else /* Should not happen */
4357 vars
->line_speed
= 0;
4359 if (legacy_status
& (1<<8))
4360 vars
->duplex
= DUPLEX_FULL
;
4362 vars
->duplex
= DUPLEX_HALF
;
4364 DP(NETIF_MSG_LINK
, "Link is up in %dMbps,"
4365 " is_duplex_full= %d\n", vars
->line_speed
,
4366 (vars
->duplex
== DUPLEX_FULL
));
4368 /* Check legacy speed AN resolution */
4369 bnx2x_cl45_read(bp
, phy
,
4371 MDIO_AN_REG_8481_LEGACY_MII_STATUS
,
4374 vars
->link_status
|=
4375 LINK_STATUS_AUTO_NEGOTIATE_COMPLETE
;
4376 bnx2x_cl45_read(bp
, phy
,
4378 MDIO_AN_REG_8481_LEGACY_AN_EXPANSION
,
4380 if ((val
& (1<<0)) == 0)
4381 vars
->link_status
|=
4382 LINK_STATUS_PARALLEL_DETECTION_USED
;
4386 DP(NETIF_MSG_LINK
, "BCM84823: link speed is %d\n",
4388 bnx2x_ext_phy_resolve_fc(phy
, params
, vars
);
4394 static void bnx2x_link_int_enable(struct link_params
*params
)
4396 u8 port
= params
->port
;
4398 struct bnx2x
*bp
= params
->bp
;
4400 /* setting the status to report on link up
4401 for either XGXS or SerDes */
4403 if (params
->switch_cfg
== SWITCH_CFG_10G
) {
4404 mask
= (NIG_MASK_XGXS0_LINK10G
|
4405 NIG_MASK_XGXS0_LINK_STATUS
);
4406 DP(NETIF_MSG_LINK
, "enabled XGXS interrupt\n");
4407 if (!(SINGLE_MEDIA_DIRECT(params
)) &&
4408 params
->phy
[INT_PHY
].type
!=
4409 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_FAILURE
) {
4410 mask
|= NIG_MASK_MI_INT
;
4411 DP(NETIF_MSG_LINK
, "enabled external phy int\n");
4414 } else { /* SerDes */
4415 mask
= NIG_MASK_SERDES0_LINK_STATUS
;
4416 DP(NETIF_MSG_LINK
, "enabled SerDes interrupt\n");
4417 if (!(SINGLE_MEDIA_DIRECT(params
)) &&
4418 params
->phy
[INT_PHY
].type
!=
4419 PORT_HW_CFG_SERDES_EXT_PHY_TYPE_NOT_CONN
) {
4420 mask
|= NIG_MASK_MI_INT
;
4421 DP(NETIF_MSG_LINK
, "enabled external phy int\n");
4425 NIG_REG_MASK_INTERRUPT_PORT0
+ port
*4,
4428 DP(NETIF_MSG_LINK
, "port %x, is_xgxs %x, int_status 0x%x\n", port
,
4429 (params
->switch_cfg
== SWITCH_CFG_10G
),
4430 REG_RD(bp
, NIG_REG_STATUS_INTERRUPT_PORT0
+ port
*4));
4431 DP(NETIF_MSG_LINK
, " int_mask 0x%x, MI_INT %x, SERDES_LINK %x\n",
4432 REG_RD(bp
, NIG_REG_MASK_INTERRUPT_PORT0
+ port
*4),
4433 REG_RD(bp
, NIG_REG_EMAC0_STATUS_MISC_MI_INT
+ port
*0x18),
4434 REG_RD(bp
, NIG_REG_SERDES0_STATUS_LINK_STATUS
+port
*0x3c));
4435 DP(NETIF_MSG_LINK
, " 10G %x, XGXS_LINK %x\n",
4436 REG_RD(bp
, NIG_REG_XGXS0_STATUS_LINK10G
+ port
*0x68),
4437 REG_RD(bp
, NIG_REG_XGXS0_STATUS_LINK_STATUS
+ port
*0x68));
4440 static void bnx2x_8481_rearm_latch_signal(struct bnx2x
*bp
, u8 port
,
4443 u32 latch_status
= 0, is_mi_int_status
;
4444 /* Disable the MI INT ( external phy int )
4445 * by writing 1 to the status register. Link down indication
4446 * is high-active-signal, so in this case we need to write the
4447 * status to clear the XOR
4449 /* Read Latched signals */
4450 latch_status
= REG_RD(bp
,
4451 NIG_REG_LATCH_STATUS_0
+ port
*8);
4452 is_mi_int_status
= REG_RD(bp
,
4453 NIG_REG_STATUS_INTERRUPT_PORT0
+ port
*4);
4454 DP(NETIF_MSG_LINK
, "original_signal = 0x%x, nig_status = 0x%x,"
4455 "latch_status = 0x%x\n",
4456 is_mi_int
, is_mi_int_status
, latch_status
);
4457 /* Handle only those with latched-signal=up.*/
4458 if (latch_status
& 1) {
4459 /* For all latched-signal=up,Write original_signal to status */
4462 NIG_REG_STATUS_INTERRUPT_PORT0
4464 NIG_STATUS_EMAC0_MI_INT
);
4467 NIG_REG_STATUS_INTERRUPT_PORT0
4469 NIG_STATUS_EMAC0_MI_INT
);
4470 /* For all latched-signal=up : Re-Arm Latch signals */
4471 REG_WR(bp
, NIG_REG_LATCH_STATUS_0
+ port
*8,
4472 (latch_status
& 0xfffe) | (latch_status
& 1));
4479 static void bnx2x_link_int_ack(struct link_params
*params
,
4480 struct link_vars
*vars
, u8 is_10g
,
4483 struct bnx2x
*bp
= params
->bp
;
4484 u8 port
= params
->port
;
4486 /* first reset all status
4487 * we assume only one line will be change at a time */
4488 bnx2x_bits_dis(bp
, NIG_REG_STATUS_INTERRUPT_PORT0
+ port
*4,
4489 (NIG_STATUS_XGXS0_LINK10G
|
4490 NIG_STATUS_XGXS0_LINK_STATUS
|
4491 NIG_STATUS_SERDES0_LINK_STATUS
));
4492 if ((params
->phy
[EXT_PHY1
].type
4493 == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8481
) ||
4494 (params
->phy
[EXT_PHY1
].type
4495 == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84823
)) {
4496 bnx2x_8481_rearm_latch_signal(bp
, port
, is_mi_int
);
4498 if (vars
->phy_link_up
) {
4500 /* Disable the 10G link interrupt
4501 * by writing 1 to the status register
4503 DP(NETIF_MSG_LINK
, "10G XGXS phy link up\n");
4505 NIG_REG_STATUS_INTERRUPT_PORT0
+ port
*4,
4506 NIG_STATUS_XGXS0_LINK10G
);
4508 } else if (params
->switch_cfg
== SWITCH_CFG_10G
) {
4509 /* Disable the link interrupt
4510 * by writing 1 to the relevant lane
4511 * in the status register
4513 u32 ser_lane
= ((params
->lane_config
&
4514 PORT_HW_CFG_LANE_SWAP_CFG_MASTER_MASK
) >>
4515 PORT_HW_CFG_LANE_SWAP_CFG_MASTER_SHIFT
);
4517 DP(NETIF_MSG_LINK
, "%d speed XGXS phy link up\n",
4520 NIG_REG_STATUS_INTERRUPT_PORT0
+ port
*4,
4522 NIG_STATUS_XGXS0_LINK_STATUS_SIZE
));
4524 } else { /* SerDes */
4525 DP(NETIF_MSG_LINK
, "SerDes phy link up\n");
4526 /* Disable the link interrupt
4527 * by writing 1 to the status register
4530 NIG_REG_STATUS_INTERRUPT_PORT0
+ port
*4,
4531 NIG_STATUS_SERDES0_LINK_STATUS
);
4537 static u8
bnx2x_7101_format_ver(u32 spirom_ver
, u8
*str
, u16
*len
)
4541 str
[0] = (spirom_ver
& 0xFF);
4542 str
[1] = (spirom_ver
& 0xFF00) >> 8;
4543 str
[2] = (spirom_ver
& 0xFF0000) >> 16;
4544 str
[3] = (spirom_ver
& 0xFF000000) >> 24;
4550 static u8
bnx2x_format_ver(u32 num
, u8
*str
, u16
*len
)
4553 u32 mask
= 0xf0000000;
4557 /* Need more than 10chars for this format */
4564 digit
= ((num
& mask
) >> shift
);
4566 *str_ptr
= digit
+ '0';
4568 *str_ptr
= digit
- 0xa + 'a';
4580 static u8
bnx2x_848xx_format_ver(u32 raw_ver
, u8
*str
, u16
*len
)
4584 spirom_ver
= ((raw_ver
& 0xF80) >> 7) << 16 | (raw_ver
& 0x7F);
4585 status
= bnx2x_format_ver(spirom_ver
, str
, len
);
4589 static u8
bnx2x_null_format_ver(u32 spirom_ver
, u8
*str
, u16
*len
)
4595 u8
bnx2x_get_ext_phy_fw_version(struct link_params
*params
, u8 driver_loaded
,
4596 u8
*version
, u16 len
)
4601 u8
*ver_p
= version
;
4602 if (version
== NULL
|| params
== NULL
)
4606 /* Extract first external phy*/
4608 spirom_ver
= REG_RD(bp
, params
->phy
[EXT_PHY1
].ver_addr
);
4610 if (params
->phy
[EXT_PHY1
].format_fw_ver
)
4611 status
|= params
->phy
[EXT_PHY1
].format_fw_ver(spirom_ver
,
4617 static void bnx2x_set_xgxs_loopback(struct bnx2x_phy
*phy
,
4618 struct link_params
*params
)
4620 u8 port
= params
->port
;
4621 struct bnx2x
*bp
= params
->bp
;
4623 if (phy
->req_line_speed
!= SPEED_1000
) {
4626 DP(NETIF_MSG_LINK
, "XGXS 10G loopback enable\n");
4628 /* change the uni_phy_addr in the nig */
4629 md_devad
= REG_RD(bp
, (NIG_REG_XGXS0_CTRL_MD_DEVAD
+
4632 REG_WR(bp
, NIG_REG_XGXS0_CTRL_MD_DEVAD
+ port
*0x18, 0x5);
4634 bnx2x_cl45_write(bp
, phy
,
4636 (MDIO_REG_BANK_AER_BLOCK
+
4637 (MDIO_AER_BLOCK_AER_REG
& 0xf)),
4640 bnx2x_cl45_write(bp
, phy
,
4642 (MDIO_REG_BANK_CL73_IEEEB0
+
4643 (MDIO_CL73_IEEEB0_CL73_AN_CONTROL
& 0xf)),
4646 /* set aer mmd back */
4647 bnx2x_set_aer_mmd(params
, phy
);
4650 REG_WR(bp
, NIG_REG_XGXS0_CTRL_MD_DEVAD
+ port
*0x18,
4655 DP(NETIF_MSG_LINK
, "XGXS 1G loopback enable\n");
4656 bnx2x_cl45_read(bp
, phy
, 5,
4657 (MDIO_REG_BANK_COMBO_IEEE0
+
4658 (MDIO_COMBO_IEEE0_MII_CONTROL
& 0xf)),
4660 bnx2x_cl45_write(bp
, phy
, 5,
4661 (MDIO_REG_BANK_COMBO_IEEE0
+
4662 (MDIO_COMBO_IEEE0_MII_CONTROL
& 0xf)),
4664 MDIO_COMBO_IEEO_MII_CONTROL_LOOPBACK
);
4668 static void bnx2x_8726_config_loopback(struct bnx2x_phy
*phy
,
4669 struct link_params
*params
)
4671 struct bnx2x
*bp
= params
->bp
;
4672 DP(NETIF_MSG_LINK
, "PMA/PMD ext_phy_loopback: 8726\n");
4673 bnx2x_cl45_write(bp
, phy
, MDIO_PMA_DEVAD
, MDIO_PMA_REG_CTRL
, 0x0001);
4676 static void bnx2x_7101_config_loopback(struct bnx2x_phy
*phy
,
4677 struct link_params
*params
)
4679 struct bnx2x
*bp
= params
->bp
;
4680 /* SFX7101_XGXS_TEST1 */
4681 bnx2x_cl45_write(bp
, phy
,
4682 MDIO_XS_DEVAD
, MDIO_XS_SFX7101_XGXS_TEST1
, 0x100);
4686 *------------------------------------------------------------------------
4687 * bnx2x_override_led_value -
4689 * Override the led value of the requested led
4691 *------------------------------------------------------------------------
4693 u8
bnx2x_override_led_value(struct bnx2x
*bp
, u8 port
,
4694 u32 led_idx
, u32 value
)
4698 /* If port 0 then use EMAC0, else use EMAC1*/
4699 u32 emac_base
= (port
) ? GRCBASE_EMAC1
: GRCBASE_EMAC0
;
4702 "bnx2x_override_led_value() port %x led_idx %d value %d\n",
4703 port
, led_idx
, value
);
4706 case 0: /* 10MB led */
4707 /* Read the current value of the LED register in
4709 reg_val
= REG_RD(bp
, emac_base
+ EMAC_REG_EMAC_LED
);
4710 /* Set the OVERRIDE bit to 1 */
4711 reg_val
|= EMAC_LED_OVERRIDE
;
4712 /* If value is 1, set the 10M_OVERRIDE bit,
4713 otherwise reset it.*/
4714 reg_val
= (value
== 1) ? (reg_val
| EMAC_LED_10MB_OVERRIDE
) :
4715 (reg_val
& ~EMAC_LED_10MB_OVERRIDE
);
4716 REG_WR(bp
, emac_base
+ EMAC_REG_EMAC_LED
, reg_val
);
4718 case 1: /*100MB led */
4719 /*Read the current value of the LED register in
4721 reg_val
= REG_RD(bp
, emac_base
+ EMAC_REG_EMAC_LED
);
4722 /* Set the OVERRIDE bit to 1 */
4723 reg_val
|= EMAC_LED_OVERRIDE
;
4724 /* If value is 1, set the 100M_OVERRIDE bit,
4725 otherwise reset it.*/
4726 reg_val
= (value
== 1) ? (reg_val
| EMAC_LED_100MB_OVERRIDE
) :
4727 (reg_val
& ~EMAC_LED_100MB_OVERRIDE
);
4728 REG_WR(bp
, emac_base
+ EMAC_REG_EMAC_LED
, reg_val
);
4730 case 2: /* 1000MB led */
4731 /* Read the current value of the LED register in the
4733 reg_val
= REG_RD(bp
, emac_base
+ EMAC_REG_EMAC_LED
);
4734 /* Set the OVERRIDE bit to 1 */
4735 reg_val
|= EMAC_LED_OVERRIDE
;
4736 /* If value is 1, set the 1000M_OVERRIDE bit, otherwise
4738 reg_val
= (value
== 1) ? (reg_val
| EMAC_LED_1000MB_OVERRIDE
) :
4739 (reg_val
& ~EMAC_LED_1000MB_OVERRIDE
);
4740 REG_WR(bp
, emac_base
+ EMAC_REG_EMAC_LED
, reg_val
);
4742 case 3: /* 2500MB led */
4743 /* Read the current value of the LED register in the
4745 reg_val
= REG_RD(bp
, emac_base
+ EMAC_REG_EMAC_LED
);
4746 /* Set the OVERRIDE bit to 1 */
4747 reg_val
|= EMAC_LED_OVERRIDE
;
4748 /* If value is 1, set the 2500M_OVERRIDE bit, otherwise
4750 reg_val
= (value
== 1) ? (reg_val
| EMAC_LED_2500MB_OVERRIDE
) :
4751 (reg_val
& ~EMAC_LED_2500MB_OVERRIDE
);
4752 REG_WR(bp
, emac_base
+ EMAC_REG_EMAC_LED
, reg_val
);
4754 case 4: /*10G led */
4756 REG_WR(bp
, NIG_REG_LED_10G_P0
,
4759 REG_WR(bp
, NIG_REG_LED_10G_P1
,
4763 case 5: /* TRAFFIC led */
4764 /* Find if the traffic control is via BMAC or EMAC */
4766 reg_val
= REG_RD(bp
, NIG_REG_NIG_EMAC0_EN
);
4768 reg_val
= REG_RD(bp
, NIG_REG_NIG_EMAC1_EN
);
4770 /* Override the traffic led in the EMAC:*/
4772 /* Read the current value of the LED register in
4774 reg_val
= REG_RD(bp
, emac_base
+
4776 /* Set the TRAFFIC_OVERRIDE bit to 1 */
4777 reg_val
|= EMAC_LED_OVERRIDE
;
4778 /* If value is 1, set the TRAFFIC bit, otherwise
4780 reg_val
= (value
== 1) ? (reg_val
| EMAC_LED_TRAFFIC
) :
4781 (reg_val
& ~EMAC_LED_TRAFFIC
);
4782 REG_WR(bp
, emac_base
+ EMAC_REG_EMAC_LED
, reg_val
);
4783 } else { /* Override the traffic led in the BMAC: */
4784 REG_WR(bp
, NIG_REG_LED_CONTROL_OVERRIDE_TRAFFIC_P0
4786 REG_WR(bp
, NIG_REG_LED_CONTROL_TRAFFIC_P0
+ port
*4,
4792 "bnx2x_override_led_value() unknown led index %d "
4793 "(should be 0-5)\n", led_idx
);
4801 u8
bnx2x_set_led(struct link_params
*params
, u8 mode
, u32 speed
)
4803 u8 port
= params
->port
;
4804 u16 hw_led_mode
= params
->hw_led_mode
;
4807 u32 emac_base
= port
? GRCBASE_EMAC1
: GRCBASE_EMAC0
;
4808 struct bnx2x
*bp
= params
->bp
;
4809 DP(NETIF_MSG_LINK
, "bnx2x_set_led: port %x, mode %d\n", port
, mode
);
4810 DP(NETIF_MSG_LINK
, "speed 0x%x, hw_led_mode 0x%x\n",
4811 speed
, hw_led_mode
);
4814 REG_WR(bp
, NIG_REG_LED_10G_P0
+ port
*4, 0);
4815 REG_WR(bp
, NIG_REG_LED_MODE_P0
+ port
*4,
4816 SHARED_HW_CFG_LED_MAC1
);
4818 tmp
= EMAC_RD(bp
, EMAC_REG_EMAC_LED
);
4819 EMAC_WR(bp
, EMAC_REG_EMAC_LED
, (tmp
| EMAC_LED_OVERRIDE
));
4823 if (SINGLE_MEDIA_DIRECT(params
)) {
4824 REG_WR(bp
, NIG_REG_LED_MODE_P0
+ port
*4, 0);
4825 REG_WR(bp
, NIG_REG_LED_10G_P0
+ port
*4, 1);
4827 REG_WR(bp
, NIG_REG_LED_MODE_P0
+ port
*4,
4831 REG_WR(bp
, NIG_REG_LED_CONTROL_OVERRIDE_TRAFFIC_P0
+
4833 /* Set blinking rate to ~15.9Hz */
4834 REG_WR(bp
, NIG_REG_LED_CONTROL_BLINK_RATE_P0
+ port
*4,
4835 LED_BLINK_RATE_VAL
);
4836 REG_WR(bp
, NIG_REG_LED_CONTROL_BLINK_RATE_ENA_P0
+
4838 tmp
= EMAC_RD(bp
, EMAC_REG_EMAC_LED
);
4839 EMAC_WR(bp
, EMAC_REG_EMAC_LED
,
4840 (tmp
& (~EMAC_LED_OVERRIDE
)));
4842 if (CHIP_IS_E1(bp
) &&
4843 ((speed
== SPEED_2500
) ||
4844 (speed
== SPEED_1000
) ||
4845 (speed
== SPEED_100
) ||
4846 (speed
== SPEED_10
))) {
4847 /* On Everest 1 Ax chip versions for speeds less than
4848 10G LED scheme is different */
4849 REG_WR(bp
, NIG_REG_LED_CONTROL_OVERRIDE_TRAFFIC_P0
4851 REG_WR(bp
, NIG_REG_LED_CONTROL_TRAFFIC_P0
+
4853 REG_WR(bp
, NIG_REG_LED_CONTROL_BLINK_TRAFFIC_P0
+
4860 DP(NETIF_MSG_LINK
, "bnx2x_set_led: Invalid led mode %d\n",
4868 u8
bnx2x_test_link(struct link_params
*params
, struct link_vars
*vars
)
4870 struct bnx2x
*bp
= params
->bp
;
4871 u16 gp_status
= 0, phy_index
= 0;
4873 CL45_RD_OVER_CL22(bp
, ¶ms
->phy
[INT_PHY
],
4874 MDIO_REG_BANK_GP_STATUS
,
4875 MDIO_GP_STATUS_TOP_AN_STATUS1
,
4877 /* link is up only if both local phy and external phy are up */
4878 if (gp_status
& MDIO_GP_STATUS_TOP_AN_STATUS1_LINK_STATUS
) {
4879 u8 ext_phy_link_up
= 1;
4880 struct link_vars temp_vars
;
4881 for (phy_index
= EXT_PHY1
; phy_index
< params
->num_phys
;
4883 if (params
->phy
[phy_index
].read_status
)
4885 params
->phy
[phy_index
].read_status(
4886 ¶ms
->phy
[phy_index
],
4887 params
, &temp_vars
);
4889 if (ext_phy_link_up
)
4895 static u8
bnx2x_link_initialize(struct link_params
*params
,
4896 struct link_vars
*vars
)
4899 u8 phy_index
, non_ext_phy
;
4900 struct bnx2x
*bp
= params
->bp
;
4902 * In case of external phy existence, the line speed would be the
4903 * line speed linked up by the external phy. In case it is direct
4904 * only, then the line_speed during initialization will be
4905 * equal to the req_line_speed
4907 vars
->line_speed
= params
->phy
[INT_PHY
].req_line_speed
;
4910 * Initialize the internal phy in case this is a direct board
4911 * (no external phys), or this board has external phy which requires
4915 if (params
->phy
[INT_PHY
].config_init
)
4916 params
->phy
[INT_PHY
].config_init(
4917 ¶ms
->phy
[INT_PHY
],
4920 /* init ext phy and enable link state int */
4921 non_ext_phy
= (SINGLE_MEDIA_DIRECT(params
) ||
4922 (params
->loopback_mode
== LOOPBACK_XGXS_10
));
4925 (params
->phy
[EXT_PHY1
].flags
& FLAGS_INIT_XGXS_FIRST
) ||
4926 (params
->loopback_mode
== LOOPBACK_EXT_PHY
)) {
4927 struct bnx2x_phy
*phy
= ¶ms
->phy
[INT_PHY
];
4928 if (vars
->line_speed
== SPEED_AUTO_NEG
)
4929 bnx2x_set_parallel_detection(phy
, params
);
4930 bnx2x_init_internal_phy(phy
, params
, vars
);
4933 /* Init external phy*/
4935 for (phy_index
= EXT_PHY1
; phy_index
< params
->num_phys
;
4937 params
->phy
[phy_index
].config_init(
4938 ¶ms
->phy
[phy_index
],
4942 /* Reset the interrupt indication after phy was initialized */
4943 bnx2x_bits_dis(bp
, NIG_REG_STATUS_INTERRUPT_PORT0
+
4945 (NIG_STATUS_XGXS0_LINK10G
|
4946 NIG_STATUS_XGXS0_LINK_STATUS
|
4947 NIG_STATUS_SERDES0_LINK_STATUS
|
4952 static void set_phy_vars(struct link_params
*params
)
4954 struct bnx2x
*bp
= params
->bp
;
4955 u8 actual_phy_idx
, phy_index
;
4957 for (phy_index
= INT_PHY
; phy_index
< params
->num_phys
;
4960 actual_phy_idx
= phy_index
;
4961 params
->phy
[actual_phy_idx
].req_flow_ctrl
=
4962 params
->req_flow_ctrl
;
4964 params
->phy
[actual_phy_idx
].req_line_speed
=
4965 params
->req_line_speed
;
4967 params
->phy
[actual_phy_idx
].speed_cap_mask
=
4968 params
->speed_cap_mask
;
4970 params
->phy
[actual_phy_idx
].req_duplex
=
4973 DP(NETIF_MSG_LINK
, "req_flow_ctrl %x, req_line_speed %x,"
4974 " speed_cap_mask %x\n",
4975 params
->phy
[actual_phy_idx
].req_flow_ctrl
,
4976 params
->phy
[actual_phy_idx
].req_line_speed
,
4977 params
->phy
[actual_phy_idx
].speed_cap_mask
);
4981 u8
bnx2x_phy_init(struct link_params
*params
, struct link_vars
*vars
)
4983 struct bnx2x
*bp
= params
->bp
;
4986 DP(NETIF_MSG_LINK
, "Phy Initialization started\n");
4987 DP(NETIF_MSG_LINK
, "req_speed %d, req_flowctrl %d\n",
4988 params
->req_line_speed
, params
->req_flow_ctrl
);
4989 vars
->link_status
= 0;
4990 vars
->phy_link_up
= 0;
4992 vars
->line_speed
= 0;
4993 vars
->duplex
= DUPLEX_FULL
;
4994 vars
->flow_ctrl
= BNX2X_FLOW_CTRL_NONE
;
4995 vars
->mac_type
= MAC_TYPE_NONE
;
4996 vars
->phy_flags
= 0;
4998 /* disable attentions */
4999 bnx2x_bits_dis(bp
, NIG_REG_MASK_INTERRUPT_PORT0
+ params
->port
*4,
5000 (NIG_MASK_XGXS0_LINK_STATUS
|
5001 NIG_MASK_XGXS0_LINK10G
|
5002 NIG_MASK_SERDES0_LINK_STATUS
|
5005 bnx2x_emac_init(params
, vars
);
5007 if (params
->num_phys
== 0) {
5008 DP(NETIF_MSG_LINK
, "No phy found for initialization !!\n");
5011 set_phy_vars(params
);
5013 DP(NETIF_MSG_LINK
, "Num of phys on board: %d\n", params
->num_phys
);
5014 if (CHIP_REV_IS_FPGA(bp
)) {
5017 vars
->line_speed
= SPEED_10000
;
5018 vars
->duplex
= DUPLEX_FULL
;
5019 vars
->flow_ctrl
= BNX2X_FLOW_CTRL_NONE
;
5020 vars
->link_status
= (LINK_STATUS_LINK_UP
| LINK_10GTFD
);
5021 /* enable on E1.5 FPGA */
5022 if (CHIP_IS_E1H(bp
)) {
5024 (BNX2X_FLOW_CTRL_TX
|
5025 BNX2X_FLOW_CTRL_RX
);
5026 vars
->link_status
|=
5027 (LINK_STATUS_TX_FLOW_CONTROL_ENABLED
|
5028 LINK_STATUS_RX_FLOW_CONTROL_ENABLED
);
5031 bnx2x_emac_enable(params
, vars
, 0);
5032 bnx2x_pbf_update(params
, vars
->flow_ctrl
, vars
->line_speed
);
5034 REG_WR(bp
, NIG_REG_EGRESS_DRAIN0_MODE
+ params
->port
*4, 0);
5036 /* update shared memory */
5037 bnx2x_update_mng(params
, vars
->link_status
);
5042 if (CHIP_REV_IS_EMUL(bp
)) {
5045 vars
->line_speed
= SPEED_10000
;
5046 vars
->duplex
= DUPLEX_FULL
;
5047 vars
->flow_ctrl
= BNX2X_FLOW_CTRL_NONE
;
5048 vars
->link_status
= (LINK_STATUS_LINK_UP
| LINK_10GTFD
);
5050 bnx2x_bmac_enable(params
, vars
, 0);
5052 bnx2x_pbf_update(params
, vars
->flow_ctrl
, vars
->line_speed
);
5054 REG_WR(bp
, NIG_REG_EGRESS_DRAIN0_MODE
5055 + params
->port
*4, 0);
5057 /* update shared memory */
5058 bnx2x_update_mng(params
, vars
->link_status
);
5063 if (params
->loopback_mode
== LOOPBACK_BMAC
) {
5066 vars
->line_speed
= SPEED_10000
;
5067 vars
->duplex
= DUPLEX_FULL
;
5068 vars
->flow_ctrl
= BNX2X_FLOW_CTRL_NONE
;
5069 vars
->mac_type
= MAC_TYPE_BMAC
;
5071 vars
->phy_flags
= PHY_XGXS_FLAG
;
5073 bnx2x_xgxs_deassert(params
);
5075 /* set bmac loopback */
5076 bnx2x_bmac_enable(params
, vars
, 1);
5078 REG_WR(bp
, NIG_REG_EGRESS_DRAIN0_MODE
+
5081 } else if (params
->loopback_mode
== LOOPBACK_EMAC
) {
5084 vars
->line_speed
= SPEED_1000
;
5085 vars
->duplex
= DUPLEX_FULL
;
5086 vars
->flow_ctrl
= BNX2X_FLOW_CTRL_NONE
;
5087 vars
->mac_type
= MAC_TYPE_EMAC
;
5089 vars
->phy_flags
= PHY_XGXS_FLAG
;
5091 bnx2x_xgxs_deassert(params
);
5092 /* set bmac loopback */
5093 bnx2x_emac_enable(params
, vars
, 1);
5094 bnx2x_emac_program(params
, vars
);
5095 REG_WR(bp
, NIG_REG_EGRESS_DRAIN0_MODE
+
5098 } else if ((params
->loopback_mode
== LOOPBACK_XGXS_10
) ||
5099 (params
->loopback_mode
== LOOPBACK_EXT_PHY
)) {
5102 vars
->line_speed
= SPEED_10000
;
5103 vars
->duplex
= DUPLEX_FULL
;
5104 vars
->flow_ctrl
= BNX2X_FLOW_CTRL_NONE
;
5106 vars
->phy_flags
= PHY_XGXS_FLAG
;
5109 NIG_REG_XGXS0_CTRL_PHY_ADDR
+
5112 bnx2x_xgxs_deassert(params
);
5113 bnx2x_link_initialize(params
, vars
);
5115 vars
->mac_type
= MAC_TYPE_BMAC
;
5117 bnx2x_bmac_enable(params
, vars
, 0);
5119 if (params
->loopback_mode
== LOOPBACK_XGXS_10
) {
5120 /* set 10G XGXS loopback */
5121 params
->phy
[INT_PHY
].config_loopback(
5122 ¶ms
->phy
[INT_PHY
],
5126 /* set external phy loopback */
5128 for (phy_index
= EXT_PHY1
;
5129 phy_index
< params
->num_phys
; phy_index
++) {
5130 if (params
->phy
[phy_index
].config_loopback
)
5131 params
->phy
[phy_index
].config_loopback(
5132 ¶ms
->phy
[phy_index
],
5137 REG_WR(bp
, NIG_REG_EGRESS_DRAIN0_MODE
+
5140 bnx2x_set_led(params
, LED_MODE_OPER
, vars
->line_speed
);
5144 if (params
->switch_cfg
== SWITCH_CFG_10G
)
5145 bnx2x_xgxs_deassert(params
);
5147 bnx2x_serdes_deassert(bp
, params
->port
);
5148 bnx2x_link_initialize(params
, vars
);
5150 bnx2x_link_int_enable(params
);
5156 static void bnx2x_8726_link_reset(struct bnx2x_phy
*phy
,
5157 struct link_params
*params
)
5159 struct bnx2x
*bp
= params
->bp
;
5160 DP(NETIF_MSG_LINK
, "bnx2x_8726_link_reset port %d\n", params
->port
);
5161 /* Set serial boot control for external load */
5162 bnx2x_cl45_write(bp
, phy
,
5164 MDIO_PMA_REG_GEN_CTRL
, 0x0001);
5167 static void bnx2x_8727_link_reset(struct bnx2x_phy
*phy
,
5168 struct link_params
*params
)
5170 struct bnx2x
*bp
= params
->bp
;
5171 /* Disable Transmitter */
5172 bnx2x_sfp_set_transmitter(bp
, phy
, params
->port
, 0);
5174 static void bnx2x_8073_link_reset(struct bnx2x_phy
*phy
,
5175 struct link_params
*params
)
5177 struct bnx2x
*bp
= params
->bp
;
5179 gpio_port
= params
->port
;
5180 DP(NETIF_MSG_LINK
, "Setting 8073 port %d into low power mode\n",
5182 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_2
,
5183 MISC_REGISTERS_GPIO_OUTPUT_LOW
,
5186 static void bnx2x_8481_link_reset(struct bnx2x_phy
*phy
,
5187 struct link_params
*params
)
5189 bnx2x_cl45_write(params
->bp
, phy
,
5190 MDIO_AN_DEVAD
, MDIO_AN_REG_CTRL
, 0x0000);
5191 bnx2x_cl45_write(params
->bp
, phy
,
5192 MDIO_PMA_DEVAD
, MDIO_PMA_REG_CTRL
, 1);
5195 static void bnx2x_848x3_link_reset(struct bnx2x_phy
*phy
,
5196 struct link_params
*params
)
5198 struct bnx2x
*bp
= params
->bp
;
5199 u8 port
= params
->port
;
5200 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_3
,
5201 MISC_REGISTERS_GPIO_OUTPUT_LOW
,
5205 static void bnx2x_common_ext_link_reset(struct bnx2x_phy
*phy
,
5206 struct link_params
*params
)
5208 struct bnx2x
*bp
= params
->bp
;
5211 gpio_port
= params
->port
;
5212 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_1
,
5213 MISC_REGISTERS_GPIO_OUTPUT_LOW
,
5215 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_2
,
5216 MISC_REGISTERS_GPIO_OUTPUT_LOW
,
5218 DP(NETIF_MSG_LINK
, "reset external PHY\n");
5221 static void bnx2x_int_link_reset(struct bnx2x_phy
*phy
,
5222 struct link_params
*params
)
5224 /* reset the SerDes/XGXS */
5225 REG_WR(params
->bp
, GRCBASE_MISC
+
5226 MISC_REGISTERS_RESET_REG_3_CLEAR
,
5227 (0x1ff << (params
->port
*16)));
5230 u8
bnx2x_link_reset(struct link_params
*params
, struct link_vars
*vars
,
5233 struct bnx2x
*bp
= params
->bp
;
5234 u8 phy_index
, port
= params
->port
;
5235 DP(NETIF_MSG_LINK
, "Resetting the link of port %d\n", port
);
5236 /* disable attentions */
5237 vars
->link_status
= 0;
5238 bnx2x_update_mng(params
, vars
->link_status
);
5239 bnx2x_bits_dis(bp
, NIG_REG_MASK_INTERRUPT_PORT0
+ port
*4,
5240 (NIG_MASK_XGXS0_LINK_STATUS
|
5241 NIG_MASK_XGXS0_LINK10G
|
5242 NIG_MASK_SERDES0_LINK_STATUS
|
5245 /* activate nig drain */
5246 REG_WR(bp
, NIG_REG_EGRESS_DRAIN0_MODE
+ port
*4, 1);
5248 /* disable nig egress interface */
5249 REG_WR(bp
, NIG_REG_BMAC0_OUT_EN
+ port
*4, 0);
5250 REG_WR(bp
, NIG_REG_EGRESS_EMAC0_OUT_EN
+ port
*4, 0);
5252 /* Stop BigMac rx */
5253 bnx2x_bmac_rx_disable(bp
, port
);
5256 REG_WR(bp
, NIG_REG_NIG_EMAC0_EN
+ port
*4, 0);
5259 /* The PHY reset is controled by GPIO 1
5260 * Hold it as vars low
5262 /* clear link led */
5263 bnx2x_set_led(params
, LED_MODE_OFF
, 0);
5264 if (reset_ext_phy
) {
5265 for (phy_index
= EXT_PHY1
; phy_index
< params
->num_phys
;
5267 if (params
->phy
[phy_index
].link_reset
)
5268 params
->phy
[phy_index
].link_reset(
5269 ¶ms
->phy
[phy_index
],
5274 if (params
->phy
[INT_PHY
].link_reset
)
5275 params
->phy
[INT_PHY
].link_reset(
5276 ¶ms
->phy
[INT_PHY
], params
);
5278 REG_WR(bp
, GRCBASE_MISC
+ MISC_REGISTERS_RESET_REG_2_CLEAR
,
5279 (MISC_REGISTERS_RESET_REG_2_RST_BMAC0
<< port
));
5281 /* disable nig ingress interface */
5282 REG_WR(bp
, NIG_REG_BMAC0_IN_EN
+ port
*4, 0);
5283 REG_WR(bp
, NIG_REG_EMAC0_IN_EN
+ port
*4, 0);
5284 REG_WR(bp
, NIG_REG_BMAC0_OUT_EN
+ port
*4, 0);
5285 REG_WR(bp
, NIG_REG_EGRESS_EMAC0_OUT_EN
+ port
*4, 0);
5290 static u8
bnx2x_update_link_down(struct link_params
*params
,
5291 struct link_vars
*vars
)
5293 struct bnx2x
*bp
= params
->bp
;
5294 u8 port
= params
->port
;
5296 DP(NETIF_MSG_LINK
, "Port %x: Link is down\n", port
);
5297 bnx2x_set_led(params
, LED_MODE_OFF
, 0);
5299 /* indicate no mac active */
5300 vars
->mac_type
= MAC_TYPE_NONE
;
5302 /* update shared memory */
5303 vars
->link_status
= 0;
5304 vars
->line_speed
= 0;
5305 bnx2x_update_mng(params
, vars
->link_status
);
5307 /* activate nig drain */
5308 REG_WR(bp
, NIG_REG_EGRESS_DRAIN0_MODE
+ port
*4, 1);
5311 REG_WR(bp
, NIG_REG_NIG_EMAC0_EN
+ port
*4, 0);
5316 bnx2x_bmac_rx_disable(bp
, params
->port
);
5317 REG_WR(bp
, GRCBASE_MISC
+
5318 MISC_REGISTERS_RESET_REG_2_CLEAR
,
5319 (MISC_REGISTERS_RESET_REG_2_RST_BMAC0
<< port
));
5323 static u8
bnx2x_update_link_up(struct link_params
*params
,
5324 struct link_vars
*vars
,
5327 struct bnx2x
*bp
= params
->bp
;
5328 u8 port
= params
->port
;
5331 vars
->link_status
|= LINK_STATUS_LINK_UP
;
5332 if (vars
->flow_ctrl
& BNX2X_FLOW_CTRL_TX
)
5333 vars
->link_status
|=
5334 LINK_STATUS_TX_FLOW_CONTROL_ENABLED
;
5336 if (vars
->flow_ctrl
& BNX2X_FLOW_CTRL_RX
)
5337 vars
->link_status
|=
5338 LINK_STATUS_RX_FLOW_CONTROL_ENABLED
;
5340 bnx2x_bmac_enable(params
, vars
, 0);
5341 bnx2x_set_led(params
, LED_MODE_OPER
, SPEED_10000
);
5343 rc
= bnx2x_emac_program(params
, vars
);
5345 bnx2x_emac_enable(params
, vars
, 0);
5348 if ((vars
->link_status
& LINK_STATUS_AUTO_NEGOTIATE_COMPLETE
)
5349 && (!(vars
->phy_flags
& PHY_SGMII_FLAG
)) &&
5350 SINGLE_MEDIA_DIRECT(params
))
5351 bnx2x_set_gmii_tx_driver(params
);
5355 rc
|= bnx2x_pbf_update(params
, vars
->flow_ctrl
,
5359 REG_WR(bp
, NIG_REG_EGRESS_DRAIN0_MODE
+ port
*4, 0);
5361 /* update shared memory */
5362 bnx2x_update_mng(params
, vars
->link_status
);
5367 * The bnx2x_link_update function should be called upon link
5369 * Link is considered up as follows:
5370 * - DIRECT_SINGLE_MEDIA - Only XGXS link (internal link) needs
5372 * - SINGLE_MEDIA - The link between the 577xx and the external
5373 * phy (XGXS) need to up as well as the external link of the
5375 * - DUAL_MEDIA - The link between the 577xx and the first
5376 * external phy needs to be up, and at least one of the 2
5377 * external phy link must be up.
5379 u8
bnx2x_link_update(struct link_params
*params
, struct link_vars
*vars
)
5381 struct bnx2x
*bp
= params
->bp
;
5382 struct link_vars phy_vars
[MAX_PHYS
];
5383 u8 port
= params
->port
;
5384 u8 link_10g
, phy_index
;
5385 u8 ext_phy_link_up
= 0, cur_link_up
, rc
= 0;
5387 u16 ext_phy_line_speed
= 0, prev_line_speed
= vars
->line_speed
;
5388 u8 active_external_phy
= INT_PHY
;
5389 vars
->link_status
= 0;
5390 for (phy_index
= INT_PHY
; phy_index
< params
->num_phys
;
5392 phy_vars
[phy_index
].flow_ctrl
= 0;
5393 phy_vars
[phy_index
].link_status
= 0;
5394 phy_vars
[phy_index
].line_speed
= 0;
5395 phy_vars
[phy_index
].duplex
= DUPLEX_FULL
;
5396 phy_vars
[phy_index
].phy_link_up
= 0;
5397 phy_vars
[phy_index
].link_up
= 0;
5400 DP(NETIF_MSG_LINK
, "port %x, XGXS?%x, int_status 0x%x\n",
5401 port
, (vars
->phy_flags
& PHY_XGXS_FLAG
),
5402 REG_RD(bp
, NIG_REG_STATUS_INTERRUPT_PORT0
+ port
*4));
5404 is_mi_int
= (u8
)(REG_RD(bp
, NIG_REG_EMAC0_STATUS_MISC_MI_INT
+
5406 DP(NETIF_MSG_LINK
, "int_mask 0x%x MI_INT %x, SERDES_LINK %x\n",
5407 REG_RD(bp
, NIG_REG_MASK_INTERRUPT_PORT0
+ port
*4),
5410 NIG_REG_SERDES0_STATUS_LINK_STATUS
+ port
*0x3c));
5412 DP(NETIF_MSG_LINK
, " 10G %x, XGXS_LINK %x\n",
5413 REG_RD(bp
, NIG_REG_XGXS0_STATUS_LINK10G
+ port
*0x68),
5414 REG_RD(bp
, NIG_REG_XGXS0_STATUS_LINK_STATUS
+ port
*0x68));
5417 REG_WR(bp
, NIG_REG_NIG_EMAC0_EN
+ port
*4, 0);
5421 * Check external link change only for external phys, and apply
5422 * priority selection between them in case the link on both phys
5423 * is up. Note that the instead of the common vars, a temporary
5424 * vars argument is used since each phy may have different link/
5425 * speed/duplex result
5427 for (phy_index
= EXT_PHY1
; phy_index
< params
->num_phys
;
5429 struct bnx2x_phy
*phy
= ¶ms
->phy
[phy_index
];
5430 if (!phy
->read_status
)
5432 /* Read link status and params of this ext phy */
5433 cur_link_up
= phy
->read_status(phy
, params
,
5434 &phy_vars
[phy_index
]);
5436 DP(NETIF_MSG_LINK
, "phy in index %d link is up\n",
5439 DP(NETIF_MSG_LINK
, "phy in index %d link is down\n",
5444 if (!ext_phy_link_up
) {
5445 ext_phy_link_up
= 1;
5446 active_external_phy
= phy_index
;
5449 prev_line_speed
= vars
->line_speed
;
5452 * Read the status of the internal phy. In case of
5453 * DIRECT_SINGLE_MEDIA board, this link is the external link,
5454 * otherwise this is the link between the 577xx and the first
5457 if (params
->phy
[INT_PHY
].read_status
)
5458 params
->phy
[INT_PHY
].read_status(
5459 ¶ms
->phy
[INT_PHY
],
5462 * The INT_PHY flow control reside in the vars. This include the
5463 * case where the speed or flow control are not set to AUTO.
5464 * Otherwise, the active external phy flow control result is set
5465 * to the vars. The ext_phy_line_speed is needed to check if the
5466 * speed is different between the internal phy and external phy.
5467 * This case may be result of intermediate link speed change.
5469 if (active_external_phy
> INT_PHY
) {
5470 vars
->flow_ctrl
= phy_vars
[active_external_phy
].flow_ctrl
;
5472 * Link speed is taken from the XGXS. AN and FC result from
5475 vars
->link_status
|= phy_vars
[active_external_phy
].link_status
;
5476 ext_phy_line_speed
= phy_vars
[active_external_phy
].line_speed
;
5477 vars
->duplex
= phy_vars
[active_external_phy
].duplex
;
5478 if (params
->phy
[active_external_phy
].supported
&
5480 vars
->link_status
|= LINK_STATUS_SERDES_LINK
;
5481 DP(NETIF_MSG_LINK
, "Active external phy selected: %x\n",
5482 active_external_phy
);
5484 DP(NETIF_MSG_LINK
, "vars->flow_ctrl = 0x%x, vars->link_status = 0x%x,"
5485 " ext_phy_line_speed = %d\n", vars
->flow_ctrl
,
5486 vars
->link_status
, ext_phy_line_speed
);
5488 * Upon link speed change set the NIG into drain mode. Comes to
5489 * deals with possible FIFO glitch due to clk change when speed
5490 * is decreased without link down indicator
5493 if (vars
->phy_link_up
) {
5494 if (!(SINGLE_MEDIA_DIRECT(params
)) && ext_phy_link_up
&&
5495 (ext_phy_line_speed
!= vars
->line_speed
)) {
5496 DP(NETIF_MSG_LINK
, "Internal link speed %d is"
5497 " different than the external"
5498 " link speed %d\n", vars
->line_speed
,
5499 ext_phy_line_speed
);
5500 vars
->phy_link_up
= 0;
5501 } else if (prev_line_speed
!= vars
->line_speed
) {
5502 REG_WR(bp
, NIG_REG_EGRESS_DRAIN0_MODE
5503 + params
->port
*4, 0);
5508 /* anything 10 and over uses the bmac */
5509 link_10g
= ((vars
->line_speed
== SPEED_10000
) ||
5510 (vars
->line_speed
== SPEED_12000
) ||
5511 (vars
->line_speed
== SPEED_12500
) ||
5512 (vars
->line_speed
== SPEED_13000
) ||
5513 (vars
->line_speed
== SPEED_15000
) ||
5514 (vars
->line_speed
== SPEED_16000
));
5516 bnx2x_link_int_ack(params
, vars
, link_10g
, is_mi_int
);
5519 * In case external phy link is up, and internal link is down
5520 * (not initialized yet probably after link initialization, it
5521 * needs to be initialized.
5522 * Note that after link down-up as result of cable plug, the xgxs
5523 * link would probably become up again without the need
5526 if (!(SINGLE_MEDIA_DIRECT(params
))) {
5527 DP(NETIF_MSG_LINK
, "ext_phy_link_up = %d, int_link_up = %d,"
5528 " init_preceding = %d\n", ext_phy_link_up
,
5530 params
->phy
[EXT_PHY1
].flags
&
5531 FLAGS_INIT_XGXS_FIRST
);
5532 if (!(params
->phy
[EXT_PHY1
].flags
&
5533 FLAGS_INIT_XGXS_FIRST
)
5534 && ext_phy_link_up
&& !vars
->phy_link_up
) {
5535 vars
->line_speed
= ext_phy_line_speed
;
5536 if (vars
->line_speed
< SPEED_1000
)
5537 vars
->phy_flags
|= PHY_SGMII_FLAG
;
5539 vars
->phy_flags
&= ~PHY_SGMII_FLAG
;
5540 bnx2x_init_internal_phy(¶ms
->phy
[INT_PHY
],
5546 * Link is up only if both local phy and external phy (in case of
5547 * non-direct board) are up
5549 vars
->link_up
= (vars
->phy_link_up
&&
5551 SINGLE_MEDIA_DIRECT(params
)));
5554 rc
= bnx2x_update_link_up(params
, vars
, link_10g
);
5556 rc
= bnx2x_update_link_down(params
, vars
);
5561 static void bnx2x_8481_hw_reset(struct bnx2x_phy
*phy
,
5562 struct link_params
*params
)
5564 bnx2x_set_gpio(params
->bp
, MISC_REGISTERS_GPIO_1
,
5565 MISC_REGISTERS_GPIO_OUTPUT_LOW
, 0);
5566 bnx2x_set_gpio(params
->bp
, MISC_REGISTERS_GPIO_1
,
5567 MISC_REGISTERS_GPIO_OUTPUT_LOW
, 1);
5570 static void bnx2x_8727_hw_reset(struct bnx2x_phy
*phy
,
5571 struct link_params
*params
) {
5572 u32 swap_val
, swap_override
;
5575 * The PHY reset is controlled by GPIO 1. Fake the port number
5576 * to cancel the swap done in set_gpio()
5578 struct bnx2x
*bp
= params
->bp
;
5579 swap_val
= REG_RD(bp
, NIG_REG_PORT_SWAP
);
5580 swap_override
= REG_RD(bp
, NIG_REG_STRAP_OVERRIDE
);
5581 port
= (swap_val
&& swap_override
) ^ 1;
5582 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_1
,
5583 MISC_REGISTERS_GPIO_OUTPUT_LOW
, port
);
5586 static void bnx2x_7101_hw_reset(struct bnx2x_phy
*phy
,
5587 struct link_params
*params
) {
5588 /* Low power mode is controlled by GPIO 2 */
5589 bnx2x_set_gpio(params
->bp
, MISC_REGISTERS_GPIO_2
,
5590 MISC_REGISTERS_GPIO_OUTPUT_LOW
, params
->port
);
5591 /* The PHY reset is controlled by GPIO 1 */
5592 bnx2x_set_gpio(params
->bp
, MISC_REGISTERS_GPIO_1
,
5593 MISC_REGISTERS_GPIO_OUTPUT_LOW
, params
->port
);
5595 /******************************************************************/
5596 /* STATIC PHY DECLARATION */
5597 /******************************************************************/
5599 static struct bnx2x_phy phy_null
= {
5600 .type
= PORT_HW_CFG_XGXS_EXT_PHY_TYPE_NOT_CONN
,
5602 .flags
= FLAGS_INIT_XGXS_FIRST
,
5605 .rx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
5606 .tx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
5609 .media_type
= ETH_PHY_NOT_PRESENT
,
5612 .req_line_speed
= 0,
5613 .speed_cap_mask
= 0,
5616 .config_init
= (config_init_t
)NULL
,
5617 .read_status
= (read_status_t
)NULL
,
5618 .link_reset
= (link_reset_t
)NULL
,
5619 .config_loopback
= (config_loopback_t
)NULL
,
5620 .format_fw_ver
= (format_fw_ver_t
)NULL
,
5621 .hw_reset
= (hw_reset_t
)NULL
,
5622 .set_link_led
= (set_link_led_t
)NULL
5625 static struct bnx2x_phy phy_serdes
= {
5626 .type
= PORT_HW_CFG_SERDES_EXT_PHY_TYPE_DIRECT
,
5631 .rx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
5632 .tx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
5634 .supported
= (SUPPORTED_10baseT_Half
|
5635 SUPPORTED_10baseT_Full
|
5636 SUPPORTED_100baseT_Half
|
5637 SUPPORTED_100baseT_Full
|
5638 SUPPORTED_1000baseT_Full
|
5639 SUPPORTED_2500baseX_Full
|
5643 SUPPORTED_Asym_Pause
),
5644 .media_type
= ETH_PHY_UNSPECIFIED
,
5647 .req_line_speed
= 0,
5648 .speed_cap_mask
= 0,
5651 .config_init
= (config_init_t
)bnx2x_init_serdes
,
5652 .read_status
= (read_status_t
)bnx2x_link_settings_status
,
5653 .link_reset
= (link_reset_t
)bnx2x_int_link_reset
,
5654 .config_loopback
= (config_loopback_t
)NULL
,
5655 .format_fw_ver
= (format_fw_ver_t
)NULL
,
5656 .hw_reset
= (hw_reset_t
)NULL
,
5657 .set_link_led
= (set_link_led_t
)NULL
5660 static struct bnx2x_phy phy_xgxs
= {
5661 .type
= PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT
,
5666 .rx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
5667 .tx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
5669 .supported
= (SUPPORTED_10baseT_Half
|
5670 SUPPORTED_10baseT_Full
|
5671 SUPPORTED_100baseT_Half
|
5672 SUPPORTED_100baseT_Full
|
5673 SUPPORTED_1000baseT_Full
|
5674 SUPPORTED_2500baseX_Full
|
5675 SUPPORTED_10000baseT_Full
|
5679 SUPPORTED_Asym_Pause
),
5680 .media_type
= ETH_PHY_UNSPECIFIED
,
5683 .req_line_speed
= 0,
5684 .speed_cap_mask
= 0,
5687 .config_init
= (config_init_t
)bnx2x_init_xgxs
,
5688 .read_status
= (read_status_t
)bnx2x_link_settings_status
,
5689 .link_reset
= (link_reset_t
)bnx2x_int_link_reset
,
5690 .config_loopback
= (config_loopback_t
)bnx2x_set_xgxs_loopback
,
5691 .format_fw_ver
= (format_fw_ver_t
)NULL
,
5692 .hw_reset
= (hw_reset_t
)NULL
,
5693 .set_link_led
= (set_link_led_t
)NULL
5696 static struct bnx2x_phy phy_7101
= {
5697 .type
= PORT_HW_CFG_XGXS_EXT_PHY_TYPE_SFX7101
,
5699 .flags
= FLAGS_FAN_FAILURE_DET_REQ
,
5702 .rx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
5703 .tx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
5705 .supported
= (SUPPORTED_10000baseT_Full
|
5709 SUPPORTED_Asym_Pause
),
5710 .media_type
= ETH_PHY_BASE_T
,
5713 .req_line_speed
= 0,
5714 .speed_cap_mask
= 0,
5717 .config_init
= (config_init_t
)bnx2x_7101_config_init
,
5718 .read_status
= (read_status_t
)bnx2x_7101_read_status
,
5719 .link_reset
= (link_reset_t
)bnx2x_common_ext_link_reset
,
5720 .config_loopback
= (config_loopback_t
)bnx2x_7101_config_loopback
,
5721 .format_fw_ver
= (format_fw_ver_t
)bnx2x_7101_format_ver
,
5722 .hw_reset
= (hw_reset_t
)bnx2x_7101_hw_reset
,
5723 .set_link_led
= (set_link_led_t
)NULL
5725 static struct bnx2x_phy phy_8073
= {
5726 .type
= PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073
,
5728 .flags
= FLAGS_HW_LOCK_REQUIRED
,
5731 .rx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
5732 .tx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
5734 .supported
= (SUPPORTED_10000baseT_Full
|
5735 SUPPORTED_2500baseX_Full
|
5736 SUPPORTED_1000baseT_Full
|
5740 SUPPORTED_Asym_Pause
),
5741 .media_type
= ETH_PHY_UNSPECIFIED
,
5744 .req_line_speed
= 0,
5745 .speed_cap_mask
= 0,
5748 .config_init
= (config_init_t
)bnx2x_8073_config_init
,
5749 .read_status
= (read_status_t
)bnx2x_8073_read_status
,
5750 .link_reset
= (link_reset_t
)bnx2x_8073_link_reset
,
5751 .config_loopback
= (config_loopback_t
)NULL
,
5752 .format_fw_ver
= (format_fw_ver_t
)bnx2x_format_ver
,
5753 .hw_reset
= (hw_reset_t
)NULL
,
5754 .set_link_led
= (set_link_led_t
)NULL
5756 static struct bnx2x_phy phy_8705
= {
5757 .type
= PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8705
,
5759 .flags
= FLAGS_INIT_XGXS_FIRST
,
5762 .rx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
5763 .tx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
5765 .supported
= (SUPPORTED_10000baseT_Full
|
5768 SUPPORTED_Asym_Pause
),
5769 .media_type
= ETH_PHY_XFP_FIBER
,
5772 .req_line_speed
= 0,
5773 .speed_cap_mask
= 0,
5776 .config_init
= (config_init_t
)bnx2x_8705_config_init
,
5777 .read_status
= (read_status_t
)bnx2x_8705_read_status
,
5778 .link_reset
= (link_reset_t
)bnx2x_common_ext_link_reset
,
5779 .config_loopback
= (config_loopback_t
)NULL
,
5780 .format_fw_ver
= (format_fw_ver_t
)bnx2x_null_format_ver
,
5781 .hw_reset
= (hw_reset_t
)NULL
,
5782 .set_link_led
= (set_link_led_t
)NULL
5784 static struct bnx2x_phy phy_8706
= {
5785 .type
= PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8706
,
5787 .flags
= FLAGS_INIT_XGXS_FIRST
,
5790 .rx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
5791 .tx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
5793 .supported
= (SUPPORTED_10000baseT_Full
|
5794 SUPPORTED_1000baseT_Full
|
5797 SUPPORTED_Asym_Pause
),
5798 .media_type
= ETH_PHY_SFP_FIBER
,
5801 .req_line_speed
= 0,
5802 .speed_cap_mask
= 0,
5805 .config_init
= (config_init_t
)bnx2x_8706_config_init
,
5806 .read_status
= (read_status_t
)bnx2x_8706_read_status
,
5807 .link_reset
= (link_reset_t
)bnx2x_common_ext_link_reset
,
5808 .config_loopback
= (config_loopback_t
)NULL
,
5809 .format_fw_ver
= (format_fw_ver_t
)bnx2x_format_ver
,
5810 .hw_reset
= (hw_reset_t
)NULL
,
5811 .set_link_led
= (set_link_led_t
)NULL
5814 static struct bnx2x_phy phy_8726
= {
5815 .type
= PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726
,
5817 .flags
= (FLAGS_HW_LOCK_REQUIRED
|
5818 FLAGS_INIT_XGXS_FIRST
),
5821 .rx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
5822 .tx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
5824 .supported
= (SUPPORTED_10000baseT_Full
|
5825 SUPPORTED_1000baseT_Full
|
5829 SUPPORTED_Asym_Pause
),
5830 .media_type
= ETH_PHY_SFP_FIBER
,
5833 .req_line_speed
= 0,
5834 .speed_cap_mask
= 0,
5837 .config_init
= (config_init_t
)bnx2x_8726_config_init
,
5838 .read_status
= (read_status_t
)bnx2x_8726_read_status
,
5839 .link_reset
= (link_reset_t
)bnx2x_8726_link_reset
,
5840 .config_loopback
= (config_loopback_t
)bnx2x_8726_config_loopback
,
5841 .format_fw_ver
= (format_fw_ver_t
)bnx2x_format_ver
,
5842 .hw_reset
= (hw_reset_t
)NULL
,
5843 .set_link_led
= (set_link_led_t
)NULL
5846 static struct bnx2x_phy phy_8727
= {
5847 .type
= PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727
,
5849 .flags
= FLAGS_FAN_FAILURE_DET_REQ
,
5852 .rx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
5853 .tx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
5855 .supported
= (SUPPORTED_10000baseT_Full
|
5856 SUPPORTED_1000baseT_Full
|
5860 SUPPORTED_Asym_Pause
),
5861 .media_type
= ETH_PHY_SFP_FIBER
,
5864 .req_line_speed
= 0,
5865 .speed_cap_mask
= 0,
5868 .config_init
= (config_init_t
)bnx2x_8727_config_init
,
5869 .read_status
= (read_status_t
)bnx2x_8727_read_status
,
5870 .link_reset
= (link_reset_t
)bnx2x_8727_link_reset
,
5871 .config_loopback
= (config_loopback_t
)NULL
,
5872 .format_fw_ver
= (format_fw_ver_t
)bnx2x_format_ver
,
5873 .hw_reset
= (hw_reset_t
)bnx2x_8727_hw_reset
,
5874 .set_link_led
= (set_link_led_t
)NULL
5876 static struct bnx2x_phy phy_8481
= {
5877 .type
= PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8481
,
5879 .flags
= FLAGS_FAN_FAILURE_DET_REQ
,
5882 .rx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
5883 .tx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
5885 .supported
= (SUPPORTED_10baseT_Half
|
5886 SUPPORTED_10baseT_Full
|
5887 SUPPORTED_100baseT_Half
|
5888 SUPPORTED_100baseT_Full
|
5889 SUPPORTED_1000baseT_Full
|
5890 SUPPORTED_10000baseT_Full
|
5894 SUPPORTED_Asym_Pause
),
5895 .media_type
= ETH_PHY_BASE_T
,
5898 .req_line_speed
= 0,
5899 .speed_cap_mask
= 0,
5902 .config_init
= (config_init_t
)bnx2x_8481_config_init
,
5903 .read_status
= (read_status_t
)bnx2x_848xx_read_status
,
5904 .link_reset
= (link_reset_t
)bnx2x_8481_link_reset
,
5905 .config_loopback
= (config_loopback_t
)NULL
,
5906 .format_fw_ver
= (format_fw_ver_t
)bnx2x_848xx_format_ver
,
5907 .hw_reset
= (hw_reset_t
)bnx2x_8481_hw_reset
,
5908 .set_link_led
= (set_link_led_t
)NULL
5911 static struct bnx2x_phy phy_84823
= {
5912 .type
= PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84823
,
5914 .flags
= FLAGS_FAN_FAILURE_DET_REQ
,
5917 .rx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
5918 .tx_preemphasis
= {0xffff, 0xffff, 0xffff, 0xffff},
5920 .supported
= (SUPPORTED_10baseT_Half
|
5921 SUPPORTED_10baseT_Full
|
5922 SUPPORTED_100baseT_Half
|
5923 SUPPORTED_100baseT_Full
|
5924 SUPPORTED_1000baseT_Full
|
5925 SUPPORTED_10000baseT_Full
|
5929 SUPPORTED_Asym_Pause
),
5930 .media_type
= ETH_PHY_BASE_T
,
5933 .req_line_speed
= 0,
5934 .speed_cap_mask
= 0,
5937 .config_init
= (config_init_t
)bnx2x_848x3_config_init
,
5938 .read_status
= (read_status_t
)bnx2x_848xx_read_status
,
5939 .link_reset
= (link_reset_t
)bnx2x_848x3_link_reset
,
5940 .config_loopback
= (config_loopback_t
)NULL
,
5941 .format_fw_ver
= (format_fw_ver_t
)bnx2x_848xx_format_ver
,
5942 .hw_reset
= (hw_reset_t
)NULL
,
5943 .set_link_led
= (set_link_led_t
)NULL
5946 /*****************************************************************/
5948 /* Populate the phy according. Main function: bnx2x_populate_phy */
5950 /*****************************************************************/
5952 static void bnx2x_populate_preemphasis(struct bnx2x
*bp
, u32 shmem_base
,
5953 struct bnx2x_phy
*phy
, u8 port
,
5956 /* Get the 4 lanes xgxs config rx and tx */
5957 u32 rx
= 0, tx
= 0, i
;
5958 for (i
= 0; i
< 2; i
++) {
5960 * INT_PHY and EXT_PHY1 share the same value location in the
5961 * shmem. When num_phys is greater than 1, than this value
5962 * applies only to EXT_PHY1
5965 rx
= REG_RD(bp
, shmem_base
+
5966 offsetof(struct shmem_region
,
5967 dev_info
.port_hw_config
[port
].xgxs_config_rx
[i
<<1]));
5969 tx
= REG_RD(bp
, shmem_base
+
5970 offsetof(struct shmem_region
,
5971 dev_info
.port_hw_config
[port
].xgxs_config_tx
[i
<<1]));
5973 phy
->rx_preemphasis
[i
<< 1] = ((rx
>>16) & 0xffff);
5974 phy
->rx_preemphasis
[(i
<< 1) + 1] = (rx
& 0xffff);
5976 phy
->tx_preemphasis
[i
<< 1] = ((tx
>>16) & 0xffff);
5977 phy
->tx_preemphasis
[(i
<< 1) + 1] = (tx
& 0xffff);
5981 static u32
bnx2x_get_ext_phy_config(struct bnx2x
*bp
, u32 shmem_base
,
5982 u8 phy_index
, u8 port
)
5984 u32 ext_phy_config
= 0;
5985 switch (phy_index
) {
5987 ext_phy_config
= REG_RD(bp
, shmem_base
+
5988 offsetof(struct shmem_region
,
5989 dev_info
.port_hw_config
[port
].external_phy_config
));
5992 DP(NETIF_MSG_LINK
, "Invalid phy_index %d\n", phy_index
);
5996 return ext_phy_config
;
5998 static u8
bnx2x_populate_int_phy(struct bnx2x
*bp
, u32 shmem_base
, u8 port
,
5999 struct bnx2x_phy
*phy
)
6003 u32 switch_cfg
= (REG_RD(bp
, shmem_base
+
6004 offsetof(struct shmem_region
,
6005 dev_info
.port_feature_config
[port
].link_config
)) &
6006 PORT_FEATURE_CONNECTED_SWITCH_MASK
);
6007 chip_id
= REG_RD(bp
, MISC_REG_CHIP_NUM
) << 16;
6008 switch (switch_cfg
) {
6010 phy_addr
= REG_RD(bp
,
6011 NIG_REG_SERDES0_CTRL_PHY_ADDR
+
6015 case SWITCH_CFG_10G
:
6016 phy_addr
= REG_RD(bp
,
6017 NIG_REG_XGXS0_CTRL_PHY_ADDR
+
6022 DP(NETIF_MSG_LINK
, "Invalid switch_cfg\n");
6025 phy
->addr
= (u8
)phy_addr
;
6026 phy
->mdio_ctrl
= bnx2x_get_emac_base(bp
,
6027 SHARED_HW_CFG_MDC_MDIO_ACCESS1_BOTH
,
6029 phy
->def_md_devad
= DEFAULT_PHY_DEV_ADDR
;
6031 DP(NETIF_MSG_LINK
, "Internal phy port=%d, addr=0x%x, mdio_ctl=0x%x\n",
6032 port
, phy
->addr
, phy
->mdio_ctrl
);
6034 bnx2x_populate_preemphasis(bp
, shmem_base
, phy
, port
, INT_PHY
);
6038 static u8
bnx2x_populate_ext_phy(struct bnx2x
*bp
,
6042 struct bnx2x_phy
*phy
)
6044 u32 ext_phy_config
, phy_type
, config2
;
6045 u32 mdc_mdio_access
= SHARED_HW_CFG_MDC_MDIO_ACCESS1_BOTH
;
6046 ext_phy_config
= bnx2x_get_ext_phy_config(bp
, shmem_base
,
6048 phy_type
= XGXS_EXT_PHY_TYPE(ext_phy_config
);
6049 /* Select the phy type */
6051 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073
:
6052 mdc_mdio_access
= SHARED_HW_CFG_MDC_MDIO_ACCESS1_SWAPPED
;
6055 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8705
:
6058 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8706
:
6061 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726
:
6062 mdc_mdio_access
= SHARED_HW_CFG_MDC_MDIO_ACCESS1_EMAC1
;
6065 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727_NOC
:
6066 /* BCM8727_NOC => BCM8727 no over current */
6067 mdc_mdio_access
= SHARED_HW_CFG_MDC_MDIO_ACCESS1_EMAC1
;
6069 phy
->flags
|= FLAGS_NOC
;
6071 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727
:
6072 mdc_mdio_access
= SHARED_HW_CFG_MDC_MDIO_ACCESS1_EMAC1
;
6075 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8481
:
6078 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84823
:
6081 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_SFX7101
:
6084 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_FAILURE
:
6092 phy
->addr
= XGXS_EXT_PHY_ADDR(ext_phy_config
);
6093 bnx2x_populate_preemphasis(bp
, shmem_base
, phy
, port
, phy_index
);
6096 * The shmem address of the phy version is located on different
6097 * structures. In case this structure is too old, do not set
6100 config2
= REG_RD(bp
, shmem_base
+ offsetof(struct shmem_region
,
6101 dev_info
.shared_hw_config
.config2
));
6103 phy
->ver_addr
= shmem_base
+ offsetof(struct shmem_region
,
6104 port_mb
[port
].ext_phy_fw_version
);
6106 /* Check specific mdc mdio settings */
6107 if (config2
& SHARED_HW_CFG_MDC_MDIO_ACCESS1_MASK
)
6108 mdc_mdio_access
= config2
&
6109 SHARED_HW_CFG_MDC_MDIO_ACCESS1_MASK
;
6111 phy
->mdio_ctrl
= bnx2x_get_emac_base(bp
, mdc_mdio_access
, port
);
6114 * In case mdc/mdio_access of the external phy is different than the
6115 * mdc/mdio access of the XGXS, a HW lock must be taken in each access
6116 * to prevent one port interfere with another port's CL45 operations.
6118 if (mdc_mdio_access
!= SHARED_HW_CFG_MDC_MDIO_ACCESS1_BOTH
)
6119 phy
->flags
|= FLAGS_HW_LOCK_REQUIRED
;
6120 DP(NETIF_MSG_LINK
, "phy_type 0x%x port %d found in index %d\n",
6121 phy_type
, port
, phy_index
);
6122 DP(NETIF_MSG_LINK
, " addr=0x%x, mdio_ctl=0x%x\n",
6123 phy
->addr
, phy
->mdio_ctrl
);
6127 static u8
bnx2x_populate_phy(struct bnx2x
*bp
, u8 phy_index
, u32 shmem_base
,
6128 u8 port
, struct bnx2x_phy
*phy
)
6131 phy
->type
= PORT_HW_CFG_XGXS_EXT_PHY_TYPE_NOT_CONN
;
6132 if (phy_index
== INT_PHY
)
6133 return bnx2x_populate_int_phy(bp
, shmem_base
, port
, phy
);
6134 status
= bnx2x_populate_ext_phy(bp
, phy_index
, shmem_base
,
6139 static void bnx2x_phy_def_cfg(struct link_params
*params
,
6140 struct bnx2x_phy
*phy
,
6143 struct bnx2x
*bp
= params
->bp
;
6145 /* Populate the default phy configuration for MF mode */
6146 link_config
= REG_RD(bp
, params
->shmem_base
+
6147 offsetof(struct shmem_region
, dev_info
.
6148 port_feature_config
[params
->port
].link_config
));
6149 phy
->speed_cap_mask
= REG_RD(bp
, params
->shmem_base
+
6150 offsetof(struct shmem_region
, dev_info
.
6151 port_hw_config
[params
->port
].speed_capability_mask
));
6153 phy
->req_duplex
= DUPLEX_FULL
;
6154 switch (link_config
& PORT_FEATURE_LINK_SPEED_MASK
) {
6155 case PORT_FEATURE_LINK_SPEED_10M_HALF
:
6156 phy
->req_duplex
= DUPLEX_HALF
;
6157 case PORT_FEATURE_LINK_SPEED_10M_FULL
:
6158 phy
->req_line_speed
= SPEED_10
;
6160 case PORT_FEATURE_LINK_SPEED_100M_HALF
:
6161 phy
->req_duplex
= DUPLEX_HALF
;
6162 case PORT_FEATURE_LINK_SPEED_100M_FULL
:
6163 phy
->req_line_speed
= SPEED_100
;
6165 case PORT_FEATURE_LINK_SPEED_1G
:
6166 phy
->req_line_speed
= SPEED_1000
;
6168 case PORT_FEATURE_LINK_SPEED_2_5G
:
6169 phy
->req_line_speed
= SPEED_2500
;
6171 case PORT_FEATURE_LINK_SPEED_10G_CX4
:
6172 phy
->req_line_speed
= SPEED_10000
;
6175 phy
->req_line_speed
= SPEED_AUTO_NEG
;
6179 switch (link_config
& PORT_FEATURE_FLOW_CONTROL_MASK
) {
6180 case PORT_FEATURE_FLOW_CONTROL_AUTO
:
6181 phy
->req_flow_ctrl
= BNX2X_FLOW_CTRL_AUTO
;
6183 case PORT_FEATURE_FLOW_CONTROL_TX
:
6184 phy
->req_flow_ctrl
= BNX2X_FLOW_CTRL_TX
;
6186 case PORT_FEATURE_FLOW_CONTROL_RX
:
6187 phy
->req_flow_ctrl
= BNX2X_FLOW_CTRL_RX
;
6189 case PORT_FEATURE_FLOW_CONTROL_BOTH
:
6190 phy
->req_flow_ctrl
= BNX2X_FLOW_CTRL_BOTH
;
6193 phy
->req_flow_ctrl
= BNX2X_FLOW_CTRL_NONE
;
6198 u8
bnx2x_phy_probe(struct link_params
*params
)
6200 u8 phy_index
, actual_phy_idx
, link_cfg_idx
;
6202 struct bnx2x
*bp
= params
->bp
;
6203 struct bnx2x_phy
*phy
;
6204 params
->num_phys
= 0;
6205 DP(NETIF_MSG_LINK
, "Begin phy probe\n");
6207 for (phy_index
= INT_PHY
; phy_index
< MAX_PHYS
;
6209 link_cfg_idx
= LINK_CONFIG_IDX(phy_index
);
6210 actual_phy_idx
= phy_index
;
6212 phy
= ¶ms
->phy
[actual_phy_idx
];
6213 if (bnx2x_populate_phy(bp
, phy_index
, params
->shmem_base
,
6216 params
->num_phys
= 0;
6217 DP(NETIF_MSG_LINK
, "phy probe failed in phy index %d\n",
6219 for (phy_index
= INT_PHY
;
6220 phy_index
< MAX_PHYS
;
6225 if (phy
->type
== PORT_HW_CFG_XGXS_EXT_PHY_TYPE_NOT_CONN
)
6228 bnx2x_phy_def_cfg(params
, phy
, actual_phy_idx
);
6232 DP(NETIF_MSG_LINK
, "End phy probe. #phys found %x\n", params
->num_phys
);
6236 u32
bnx2x_supported_attr(struct link_params
*params
, u8 phy_idx
)
6238 if (phy_idx
< params
->num_phys
)
6239 return params
->phy
[phy_idx
].supported
;
6243 static u8
bnx2x_8073_common_init_phy(struct bnx2x
*bp
, u32 shmem_base
)
6245 struct bnx2x_phy phy
[PORT_MAX
];
6246 struct bnx2x_phy
*phy_blk
[PORT_MAX
];
6250 /* PART1 - Reset both phys */
6251 for (port
= PORT_MAX
- 1; port
>= PORT_0
; port
--) {
6252 /* Extract the ext phy address for the port */
6253 if (bnx2x_populate_phy(bp
, EXT_PHY1
, shmem_base
,
6254 port
, &phy
[port
]) !=
6256 DP(NETIF_MSG_LINK
, "populate_phy failed\n");
6259 /* disable attentions */
6260 bnx2x_bits_dis(bp
, NIG_REG_MASK_INTERRUPT_PORT0
+ port
*4,
6261 (NIG_MASK_XGXS0_LINK_STATUS
|
6262 NIG_MASK_XGXS0_LINK10G
|
6263 NIG_MASK_SERDES0_LINK_STATUS
|
6266 /* Need to take the phy out of low power mode in order
6267 to write to access its registers */
6268 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_2
,
6269 MISC_REGISTERS_GPIO_OUTPUT_HIGH
, port
);
6272 bnx2x_cl45_write(bp
, &phy
[port
],
6278 /* Add delay of 150ms after reset */
6281 if (phy
[PORT_0
].addr
& 0x1) {
6282 phy_blk
[PORT_0
] = &(phy
[PORT_1
]);
6283 phy_blk
[PORT_1
] = &(phy
[PORT_0
]);
6285 phy_blk
[PORT_0
] = &(phy
[PORT_0
]);
6286 phy_blk
[PORT_1
] = &(phy
[PORT_1
]);
6289 /* PART2 - Download firmware to both phys */
6290 for (port
= PORT_MAX
- 1; port
>= PORT_0
; port
--) {
6293 bnx2x_8073_8727_external_rom_boot(bp
, phy_blk
[port
],
6296 bnx2x_cl45_read(bp
, phy_blk
[port
],
6298 MDIO_PMA_REG_ROM_VER1
, &fw_ver1
);
6299 if (fw_ver1
== 0 || fw_ver1
== 0x4321) {
6301 "bnx2x_8073_common_init_phy port %x:"
6302 "Download failed. fw version = 0x%x\n",
6307 /* Only set bit 10 = 1 (Tx power down) */
6308 bnx2x_cl45_read(bp
, phy_blk
[port
],
6310 MDIO_PMA_REG_TX_POWER_DOWN
, &val
);
6312 /* Phase1 of TX_POWER_DOWN reset */
6313 bnx2x_cl45_write(bp
, phy_blk
[port
],
6315 MDIO_PMA_REG_TX_POWER_DOWN
,
6319 /* Toggle Transmitter: Power down and then up with 600ms
6323 /* PART3 - complete TX_POWER_DOWN process, and set GPIO2 back to low */
6324 for (port
= PORT_MAX
- 1; port
>= PORT_0
; port
--) {
6325 /* Phase2 of POWER_DOWN_RESET */
6326 /* Release bit 10 (Release Tx power down) */
6327 bnx2x_cl45_read(bp
, phy_blk
[port
],
6329 MDIO_PMA_REG_TX_POWER_DOWN
, &val
);
6331 bnx2x_cl45_write(bp
, phy_blk
[port
],
6333 MDIO_PMA_REG_TX_POWER_DOWN
, (val
& (~(1<<10))));
6336 /* Read modify write the SPI-ROM version select register */
6337 bnx2x_cl45_read(bp
, phy_blk
[port
],
6339 MDIO_PMA_REG_EDC_FFE_MAIN
, &val
);
6340 bnx2x_cl45_write(bp
, phy_blk
[port
],
6342 MDIO_PMA_REG_EDC_FFE_MAIN
, (val
| (1<<12)));
6344 /* set GPIO2 back to LOW */
6345 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_2
,
6346 MISC_REGISTERS_GPIO_OUTPUT_LOW
, port
);
6351 static u8
bnx2x_8727_common_init_phy(struct bnx2x
*bp
, u32 shmem_base
)
6353 s8 port
, first_port
, i
;
6354 u32 swap_val
, swap_override
;
6355 struct bnx2x_phy phy
[PORT_MAX
];
6356 struct bnx2x_phy
*phy_blk
[PORT_MAX
];
6357 DP(NETIF_MSG_LINK
, "Executing BCM8727 common init\n");
6358 swap_val
= REG_RD(bp
, NIG_REG_PORT_SWAP
);
6359 swap_override
= REG_RD(bp
, NIG_REG_STRAP_OVERRIDE
);
6361 bnx2x_ext_phy_hw_reset(bp
, 1 ^ (swap_val
&& swap_override
));
6364 if (swap_val
&& swap_override
)
6365 first_port
= PORT_0
;
6367 first_port
= PORT_1
;
6369 /* PART1 - Reset both phys */
6370 for (i
= 0, port
= first_port
; i
< PORT_MAX
; i
++, port
= !port
) {
6371 /* Extract the ext phy address for the port */
6372 if (bnx2x_populate_phy(bp
, EXT_PHY1
, shmem_base
,
6373 port
, &phy
[port
]) !=
6375 DP(NETIF_MSG_LINK
, "populate phy failed\n");
6378 /* disable attentions */
6379 bnx2x_bits_dis(bp
, NIG_REG_MASK_INTERRUPT_PORT0
+ port
*4,
6380 (NIG_MASK_XGXS0_LINK_STATUS
|
6381 NIG_MASK_XGXS0_LINK10G
|
6382 NIG_MASK_SERDES0_LINK_STATUS
|
6387 bnx2x_cl45_write(bp
, &phy
[port
],
6393 /* Add delay of 150ms after reset */
6395 if (phy
[PORT_0
].addr
& 0x1) {
6396 phy_blk
[PORT_0
] = &(phy
[PORT_1
]);
6397 phy_blk
[PORT_1
] = &(phy
[PORT_0
]);
6399 phy_blk
[PORT_0
] = &(phy
[PORT_0
]);
6400 phy_blk
[PORT_1
] = &(phy
[PORT_1
]);
6402 /* PART2 - Download firmware to both phys */
6403 for (port
= PORT_MAX
- 1; port
>= PORT_0
; port
--) {
6406 bnx2x_8073_8727_external_rom_boot(bp
, phy_blk
[port
],
6408 bnx2x_cl45_read(bp
, phy_blk
[port
],
6410 MDIO_PMA_REG_ROM_VER1
, &fw_ver1
);
6411 if (fw_ver1
== 0 || fw_ver1
== 0x4321) {
6413 "bnx2x_8727_common_init_phy port %x:"
6414 "Download failed. fw version = 0x%x\n",
6423 static u8
bnx2x_8726_common_init_phy(struct bnx2x
*bp
, u32 shmem_base
)
6427 struct bnx2x_phy phy
;
6428 /* Use port1 because of the static port-swap */
6429 /* Enable the module detection interrupt */
6430 val
= REG_RD(bp
, MISC_REG_GPIO_EVENT_EN
);
6431 val
|= ((1<<MISC_REGISTERS_GPIO_3
)|
6432 (1<<(MISC_REGISTERS_GPIO_3
+ MISC_REGISTERS_GPIO_PORT_SHIFT
)));
6433 REG_WR(bp
, MISC_REG_GPIO_EVENT_EN
, val
);
6435 bnx2x_ext_phy_hw_reset(bp
, 1);
6437 for (port
= 0; port
< PORT_MAX
; port
++) {
6438 /* Extract the ext phy address for the port */
6439 if (bnx2x_populate_phy(bp
, EXT_PHY1
, shmem_base
,
6442 DP(NETIF_MSG_LINK
, "populate phy failed\n");
6447 bnx2x_cl45_write(bp
, &phy
,
6448 MDIO_PMA_DEVAD
, MDIO_PMA_REG_GEN_CTRL
, 0x0001);
6451 /* Set fault module detected LED on */
6452 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_0
,
6453 MISC_REGISTERS_GPIO_HIGH
,
6460 u8
bnx2x_common_init_phy(struct bnx2x
*bp
, u32 shmem_base
)
6465 DP(NETIF_MSG_LINK
, "Begin common phy init\n");
6467 /* Read the ext_phy_type for arbitrary port(0) */
6468 ext_phy_type
= XGXS_EXT_PHY_TYPE(
6469 REG_RD(bp
, shmem_base
+
6470 offsetof(struct shmem_region
,
6471 dev_info
.port_hw_config
[0].external_phy_config
)));
6473 switch (ext_phy_type
) {
6474 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073
:
6476 rc
= bnx2x_8073_common_init_phy(bp
, shmem_base
);
6480 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727
:
6481 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727_NOC
:
6482 rc
= bnx2x_8727_common_init_phy(bp
, shmem_base
);
6485 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726
:
6486 /* GPIO1 affects both ports, so there's need to pull
6487 it for single port alone */
6488 rc
= bnx2x_8726_common_init_phy(bp
, shmem_base
);
6492 "bnx2x_common_init_phy: ext_phy 0x%x not required\n",
6500 void bnx2x_sfx7101_sp_sw_reset(struct bnx2x
*bp
, struct bnx2x_phy
*phy
)
6504 bnx2x_cl45_read(bp
, phy
,
6506 MDIO_PMA_REG_7101_RESET
, &val
);
6508 for (cnt
= 0; cnt
< 10; cnt
++) {
6510 /* Writes a self-clearing reset */
6511 bnx2x_cl45_write(bp
, phy
,
6513 MDIO_PMA_REG_7101_RESET
,
6515 /* Wait for clear */
6516 bnx2x_cl45_read(bp
, phy
,
6518 MDIO_PMA_REG_7101_RESET
, &val
);
6520 if ((val
& (1<<15)) == 0)
6525 u8
bnx2x_hw_lock_required(struct bnx2x
*bp
, u32 shmem_base
)
6528 struct bnx2x_phy phy
;
6529 for (phy_index
= INT_PHY
; phy_index
< MAX_PHYS
;
6531 if (bnx2x_populate_phy(bp
, phy_index
, shmem_base
,
6533 DP(NETIF_MSG_LINK
, "populate phy failed\n");
6537 if (phy
.flags
& FLAGS_HW_LOCK_REQUIRED
)
6543 u8
bnx2x_fan_failure_det_req(struct bnx2x
*bp
,
6547 u8 phy_index
, fan_failure_det_req
= 0;
6548 struct bnx2x_phy phy
;
6549 for (phy_index
= EXT_PHY1
; phy_index
< MAX_PHYS
;
6551 if (bnx2x_populate_phy(bp
, phy_index
, shmem_base
,
6554 DP(NETIF_MSG_LINK
, "populate phy failed\n");
6557 fan_failure_det_req
|= (phy
.flags
&
6558 FLAGS_FAN_FAILURE_DET_REQ
);
6560 return fan_failure_det_req
;
6563 void bnx2x_hw_reset_phy(struct link_params
*params
)
6566 for (phy_index
= EXT_PHY1
; phy_index
< MAX_PHYS
;
6568 if (params
->phy
[phy_index
].hw_reset
) {
6569 params
->phy
[phy_index
].hw_reset(
6570 ¶ms
->phy
[phy_index
],
6572 params
->phy
[phy_index
] = phy_null
;