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 #include <linux/kernel.h>
18 #include <linux/errno.h>
19 #include <linux/pci.h>
20 #include <linux/netdevice.h>
21 #include <linux/delay.h>
22 #include <linux/ethtool.h>
23 #include <linux/mutex.h>
27 /********************************************************/
29 #define ETH_OVREHEAD (ETH_HLEN + 8)/* 8 for CRC + VLAN*/
30 #define ETH_MIN_PACKET_SIZE 60
31 #define ETH_MAX_PACKET_SIZE 1500
32 #define ETH_MAX_JUMBO_PACKET_SIZE 9600
33 #define MDIO_ACCESS_TIMEOUT 1000
34 #define BMAC_CONTROL_RX_ENABLE 2
36 /***********************************************************/
37 /* Shortcut definitions */
38 /***********************************************************/
40 #define NIG_LATCH_BC_ENABLE_MI_INT 0
42 #define NIG_STATUS_EMAC0_MI_INT \
43 NIG_STATUS_INTERRUPT_PORT0_REG_STATUS_EMAC0_MISC_MI_INT
44 #define NIG_STATUS_XGXS0_LINK10G \
45 NIG_STATUS_INTERRUPT_PORT0_REG_STATUS_XGXS0_LINK10G
46 #define NIG_STATUS_XGXS0_LINK_STATUS \
47 NIG_STATUS_INTERRUPT_PORT0_REG_STATUS_XGXS0_LINK_STATUS
48 #define NIG_STATUS_XGXS0_LINK_STATUS_SIZE \
49 NIG_STATUS_INTERRUPT_PORT0_REG_STATUS_XGXS0_LINK_STATUS_SIZE
50 #define NIG_STATUS_SERDES0_LINK_STATUS \
51 NIG_STATUS_INTERRUPT_PORT0_REG_STATUS_SERDES0_LINK_STATUS
52 #define NIG_MASK_MI_INT \
53 NIG_MASK_INTERRUPT_PORT0_REG_MASK_EMAC0_MISC_MI_INT
54 #define NIG_MASK_XGXS0_LINK10G \
55 NIG_MASK_INTERRUPT_PORT0_REG_MASK_XGXS0_LINK10G
56 #define NIG_MASK_XGXS0_LINK_STATUS \
57 NIG_MASK_INTERRUPT_PORT0_REG_MASK_XGXS0_LINK_STATUS
58 #define NIG_MASK_SERDES0_LINK_STATUS \
59 NIG_MASK_INTERRUPT_PORT0_REG_MASK_SERDES0_LINK_STATUS
61 #define MDIO_AN_CL73_OR_37_COMPLETE \
62 (MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_AUTONEG_COMPLETE | \
63 MDIO_GP_STATUS_TOP_AN_STATUS1_CL37_AUTONEG_COMPLETE)
65 #define XGXS_RESET_BITS \
66 (MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_XGXS0_RSTB_HW | \
67 MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_XGXS0_IDDQ | \
68 MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_XGXS0_PWRDWN | \
69 MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_XGXS0_PWRDWN_SD | \
70 MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_XGXS0_TXD_FIFO_RSTB)
72 #define SERDES_RESET_BITS \
73 (MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_SERDES0_RSTB_HW | \
74 MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_SERDES0_IDDQ | \
75 MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_SERDES0_PWRDWN | \
76 MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_SERDES0_PWRDWN_SD)
78 #define AUTONEG_CL37 SHARED_HW_CFG_AN_ENABLE_CL37
79 #define AUTONEG_CL73 SHARED_HW_CFG_AN_ENABLE_CL73
80 #define AUTONEG_BAM SHARED_HW_CFG_AN_ENABLE_BAM
81 #define AUTONEG_PARALLEL \
82 SHARED_HW_CFG_AN_ENABLE_PARALLEL_DETECTION
83 #define AUTONEG_SGMII_FIBER_AUTODET \
84 SHARED_HW_CFG_AN_EN_SGMII_FIBER_AUTO_DETECT
85 #define AUTONEG_REMOTE_PHY SHARED_HW_CFG_AN_ENABLE_REMOTE_PHY
87 #define GP_STATUS_PAUSE_RSOLUTION_TXSIDE \
88 MDIO_GP_STATUS_TOP_AN_STATUS1_PAUSE_RSOLUTION_TXSIDE
89 #define GP_STATUS_PAUSE_RSOLUTION_RXSIDE \
90 MDIO_GP_STATUS_TOP_AN_STATUS1_PAUSE_RSOLUTION_RXSIDE
91 #define GP_STATUS_SPEED_MASK \
92 MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_MASK
93 #define GP_STATUS_10M MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_10M
94 #define GP_STATUS_100M MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_100M
95 #define GP_STATUS_1G MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_1G
96 #define GP_STATUS_2_5G MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_2_5G
97 #define GP_STATUS_5G MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_5G
98 #define GP_STATUS_6G MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_6G
99 #define GP_STATUS_10G_HIG \
100 MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_10G_HIG
101 #define GP_STATUS_10G_CX4 \
102 MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_10G_CX4
103 #define GP_STATUS_12G_HIG \
104 MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_12G_HIG
105 #define GP_STATUS_12_5G MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_12_5G
106 #define GP_STATUS_13G MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_13G
107 #define GP_STATUS_15G MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_15G
108 #define GP_STATUS_16G MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_16G
109 #define GP_STATUS_1G_KX MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_1G_KX
110 #define GP_STATUS_10G_KX4 \
111 MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_10G_KX4
113 #define LINK_10THD LINK_STATUS_SPEED_AND_DUPLEX_10THD
114 #define LINK_10TFD LINK_STATUS_SPEED_AND_DUPLEX_10TFD
115 #define LINK_100TXHD LINK_STATUS_SPEED_AND_DUPLEX_100TXHD
116 #define LINK_100T4 LINK_STATUS_SPEED_AND_DUPLEX_100T4
117 #define LINK_100TXFD LINK_STATUS_SPEED_AND_DUPLEX_100TXFD
118 #define LINK_1000THD LINK_STATUS_SPEED_AND_DUPLEX_1000THD
119 #define LINK_1000TFD LINK_STATUS_SPEED_AND_DUPLEX_1000TFD
120 #define LINK_1000XFD LINK_STATUS_SPEED_AND_DUPLEX_1000XFD
121 #define LINK_2500THD LINK_STATUS_SPEED_AND_DUPLEX_2500THD
122 #define LINK_2500TFD LINK_STATUS_SPEED_AND_DUPLEX_2500TFD
123 #define LINK_2500XFD LINK_STATUS_SPEED_AND_DUPLEX_2500XFD
124 #define LINK_10GTFD LINK_STATUS_SPEED_AND_DUPLEX_10GTFD
125 #define LINK_10GXFD LINK_STATUS_SPEED_AND_DUPLEX_10GXFD
126 #define LINK_12GTFD LINK_STATUS_SPEED_AND_DUPLEX_12GTFD
127 #define LINK_12GXFD LINK_STATUS_SPEED_AND_DUPLEX_12GXFD
128 #define LINK_12_5GTFD LINK_STATUS_SPEED_AND_DUPLEX_12_5GTFD
129 #define LINK_12_5GXFD LINK_STATUS_SPEED_AND_DUPLEX_12_5GXFD
130 #define LINK_13GTFD LINK_STATUS_SPEED_AND_DUPLEX_13GTFD
131 #define LINK_13GXFD LINK_STATUS_SPEED_AND_DUPLEX_13GXFD
132 #define LINK_15GTFD LINK_STATUS_SPEED_AND_DUPLEX_15GTFD
133 #define LINK_15GXFD LINK_STATUS_SPEED_AND_DUPLEX_15GXFD
134 #define LINK_16GTFD LINK_STATUS_SPEED_AND_DUPLEX_16GTFD
135 #define LINK_16GXFD LINK_STATUS_SPEED_AND_DUPLEX_16GXFD
137 #define PHY_XGXS_FLAG 0x1
138 #define PHY_SGMII_FLAG 0x2
139 #define PHY_SERDES_FLAG 0x4
142 #define SFP_EEPROM_CON_TYPE_ADDR 0x2
143 #define SFP_EEPROM_CON_TYPE_VAL_LC 0x7
144 #define SFP_EEPROM_CON_TYPE_VAL_COPPER 0x21
147 #define SFP_EEPROM_COMP_CODE_ADDR 0x3
148 #define SFP_EEPROM_COMP_CODE_SR_MASK (1<<4)
149 #define SFP_EEPROM_COMP_CODE_LR_MASK (1<<5)
150 #define SFP_EEPROM_COMP_CODE_LRM_MASK (1<<6)
152 #define SFP_EEPROM_FC_TX_TECH_ADDR 0x8
153 #define SFP_EEPROM_FC_TX_TECH_BITMASK_COPPER_PASSIVE 0x4
154 #define SFP_EEPROM_FC_TX_TECH_BITMASK_COPPER_ACTIVE 0x8
156 #define SFP_EEPROM_OPTIONS_ADDR 0x40
157 #define SFP_EEPROM_OPTIONS_LINEAR_RX_OUT_MASK 0x1
158 #define SFP_EEPROM_OPTIONS_SIZE 2
160 #define EDC_MODE_LINEAR 0x0022
161 #define EDC_MODE_LIMITING 0x0044
162 #define EDC_MODE_PASSIVE_DAC 0x0055
166 /**********************************************************/
168 /**********************************************************/
169 #define CL45_WR_OVER_CL22(_bp, _port, _phy_addr, _bank, _addr, _val) \
170 bnx2x_cl45_write(_bp, _port, 0, _phy_addr, \
171 DEFAULT_PHY_DEV_ADDR, \
172 (_bank + (_addr & 0xf)), \
175 #define CL45_RD_OVER_CL22(_bp, _port, _phy_addr, _bank, _addr, _val) \
176 bnx2x_cl45_read(_bp, _port, 0, _phy_addr, \
177 DEFAULT_PHY_DEV_ADDR, \
178 (_bank + (_addr & 0xf)), \
181 static void bnx2x_set_serdes_access(struct link_params
*params
)
183 struct bnx2x
*bp
= params
->bp
;
184 u32 emac_base
= (params
->port
) ? GRCBASE_EMAC1
: GRCBASE_EMAC0
;
187 REG_WR(bp
, NIG_REG_SERDES0_CTRL_MD_ST
+ params
->port
*0x10, 1);
188 REG_WR(bp
, emac_base
+ EMAC_REG_EMAC_MDIO_COMM
, 0x245f8000);
190 REG_WR(bp
, emac_base
+ EMAC_REG_EMAC_MDIO_COMM
, 0x245d000f);
193 REG_WR(bp
, NIG_REG_SERDES0_CTRL_MD_ST
+ params
->port
*0x10, 0);
195 static void bnx2x_set_phy_mdio(struct link_params
*params
, u8 phy_flags
)
197 struct bnx2x
*bp
= params
->bp
;
199 if (phy_flags
& PHY_XGXS_FLAG
) {
200 REG_WR(bp
, NIG_REG_XGXS0_CTRL_MD_ST
+
201 params
->port
*0x18, 0);
202 REG_WR(bp
, NIG_REG_XGXS0_CTRL_MD_DEVAD
+ params
->port
*0x18,
203 DEFAULT_PHY_DEV_ADDR
);
205 bnx2x_set_serdes_access(params
);
207 REG_WR(bp
, NIG_REG_SERDES0_CTRL_MD_DEVAD
+
209 DEFAULT_PHY_DEV_ADDR
);
213 static u32
bnx2x_bits_en(struct bnx2x
*bp
, u32 reg
, u32 bits
)
215 u32 val
= REG_RD(bp
, reg
);
218 REG_WR(bp
, reg
, val
);
222 static u32
bnx2x_bits_dis(struct bnx2x
*bp
, u32 reg
, u32 bits
)
224 u32 val
= REG_RD(bp
, reg
);
227 REG_WR(bp
, reg
, val
);
231 static void bnx2x_emac_init(struct link_params
*params
,
232 struct link_vars
*vars
)
234 /* reset and unreset the emac core */
235 struct bnx2x
*bp
= params
->bp
;
236 u8 port
= params
->port
;
237 u32 emac_base
= port
? GRCBASE_EMAC1
: GRCBASE_EMAC0
;
241 REG_WR(bp
, GRCBASE_MISC
+ MISC_REGISTERS_RESET_REG_2_CLEAR
,
242 (MISC_REGISTERS_RESET_REG_2_RST_EMAC0_HARD_CORE
<< port
));
244 REG_WR(bp
, GRCBASE_MISC
+ MISC_REGISTERS_RESET_REG_2_SET
,
245 (MISC_REGISTERS_RESET_REG_2_RST_EMAC0_HARD_CORE
<< port
));
247 /* init emac - use read-modify-write */
248 /* self clear reset */
249 val
= REG_RD(bp
, emac_base
+ EMAC_REG_EMAC_MODE
);
250 EMAC_WR(bp
, EMAC_REG_EMAC_MODE
, (val
| EMAC_MODE_RESET
));
254 val
= REG_RD(bp
, emac_base
+ EMAC_REG_EMAC_MODE
);
255 DP(NETIF_MSG_LINK
, "EMAC reset reg is %u\n", val
);
257 DP(NETIF_MSG_LINK
, "EMAC timeout!\n");
261 } while (val
& EMAC_MODE_RESET
);
263 /* Set mac address */
264 val
= ((params
->mac_addr
[0] << 8) |
265 params
->mac_addr
[1]);
266 EMAC_WR(bp
, EMAC_REG_EMAC_MAC_MATCH
, val
);
268 val
= ((params
->mac_addr
[2] << 24) |
269 (params
->mac_addr
[3] << 16) |
270 (params
->mac_addr
[4] << 8) |
271 params
->mac_addr
[5]);
272 EMAC_WR(bp
, EMAC_REG_EMAC_MAC_MATCH
+ 4, val
);
275 static u8
bnx2x_emac_enable(struct link_params
*params
,
276 struct link_vars
*vars
, u8 lb
)
278 struct bnx2x
*bp
= params
->bp
;
279 u8 port
= params
->port
;
280 u32 emac_base
= port
? GRCBASE_EMAC1
: GRCBASE_EMAC0
;
283 DP(NETIF_MSG_LINK
, "enabling EMAC\n");
285 /* enable emac and not bmac */
286 REG_WR(bp
, NIG_REG_EGRESS_EMAC0_PORT
+ port
*4, 1);
289 if (CHIP_REV_IS_EMUL(bp
)) {
290 /* Use lane 1 (of lanes 0-3) */
291 REG_WR(bp
, NIG_REG_XGXS_LANE_SEL_P0
+ port
*4, 1);
292 REG_WR(bp
, NIG_REG_XGXS_SERDES0_MODE_SEL
+
298 if (CHIP_REV_IS_FPGA(bp
)) {
299 /* Use lane 1 (of lanes 0-3) */
300 DP(NETIF_MSG_LINK
, "bnx2x_emac_enable: Setting FPGA\n");
302 REG_WR(bp
, NIG_REG_XGXS_LANE_SEL_P0
+ port
*4, 1);
303 REG_WR(bp
, NIG_REG_XGXS_SERDES0_MODE_SEL
+ port
*4,
307 if (vars
->phy_flags
& PHY_XGXS_FLAG
) {
308 u32 ser_lane
= ((params
->lane_config
&
309 PORT_HW_CFG_LANE_SWAP_CFG_MASTER_MASK
) >>
310 PORT_HW_CFG_LANE_SWAP_CFG_MASTER_SHIFT
);
312 DP(NETIF_MSG_LINK
, "XGXS\n");
313 /* select the master lanes (out of 0-3) */
314 REG_WR(bp
, NIG_REG_XGXS_LANE_SEL_P0
+
317 REG_WR(bp
, NIG_REG_XGXS_SERDES0_MODE_SEL
+
320 } else { /* SerDes */
321 DP(NETIF_MSG_LINK
, "SerDes\n");
323 REG_WR(bp
, NIG_REG_XGXS_SERDES0_MODE_SEL
+
327 bnx2x_bits_en(bp
, emac_base
+ EMAC_REG_EMAC_RX_MODE
,
329 bnx2x_bits_en(bp
, emac_base
+ EMAC_REG_EMAC_TX_MODE
,
332 if (CHIP_REV_IS_SLOW(bp
)) {
333 /* config GMII mode */
334 val
= REG_RD(bp
, emac_base
+ EMAC_REG_EMAC_MODE
);
335 EMAC_WR(bp
, EMAC_REG_EMAC_MODE
,
336 (val
| EMAC_MODE_PORT_GMII
));
338 /* pause enable/disable */
339 bnx2x_bits_dis(bp
, emac_base
+ EMAC_REG_EMAC_RX_MODE
,
340 EMAC_RX_MODE_FLOW_EN
);
341 if (vars
->flow_ctrl
& BNX2X_FLOW_CTRL_RX
)
342 bnx2x_bits_en(bp
, emac_base
+
343 EMAC_REG_EMAC_RX_MODE
,
344 EMAC_RX_MODE_FLOW_EN
);
346 bnx2x_bits_dis(bp
, emac_base
+ EMAC_REG_EMAC_TX_MODE
,
347 (EMAC_TX_MODE_EXT_PAUSE_EN
|
348 EMAC_TX_MODE_FLOW_EN
));
349 if (vars
->flow_ctrl
& BNX2X_FLOW_CTRL_TX
)
350 bnx2x_bits_en(bp
, emac_base
+
351 EMAC_REG_EMAC_TX_MODE
,
352 (EMAC_TX_MODE_EXT_PAUSE_EN
|
353 EMAC_TX_MODE_FLOW_EN
));
356 /* KEEP_VLAN_TAG, promiscuous */
357 val
= REG_RD(bp
, emac_base
+ EMAC_REG_EMAC_RX_MODE
);
358 val
|= EMAC_RX_MODE_KEEP_VLAN_TAG
| EMAC_RX_MODE_PROMISCUOUS
;
359 EMAC_WR(bp
, EMAC_REG_EMAC_RX_MODE
, val
);
362 val
= REG_RD(bp
, emac_base
+ EMAC_REG_EMAC_MODE
);
367 EMAC_WR(bp
, EMAC_REG_EMAC_MODE
, val
);
370 REG_WR(bp
, NIG_REG_NIG_EMAC0_EN
+ port
*4, 1);
372 /* enable emac for jumbo packets */
373 EMAC_WR(bp
, EMAC_REG_EMAC_RX_MTU_SIZE
,
374 (EMAC_RX_MTU_SIZE_JUMBO_ENA
|
375 (ETH_MAX_JUMBO_PACKET_SIZE
+ ETH_OVREHEAD
)));
378 REG_WR(bp
, NIG_REG_NIG_INGRESS_EMAC0_NO_CRC
+ port
*4, 0x1);
380 /* disable the NIG in/out to the bmac */
381 REG_WR(bp
, NIG_REG_BMAC0_IN_EN
+ port
*4, 0x0);
382 REG_WR(bp
, NIG_REG_BMAC0_PAUSE_OUT_EN
+ port
*4, 0x0);
383 REG_WR(bp
, NIG_REG_BMAC0_OUT_EN
+ port
*4, 0x0);
385 /* enable the NIG in/out to the emac */
386 REG_WR(bp
, NIG_REG_EMAC0_IN_EN
+ port
*4, 0x1);
388 if (vars
->flow_ctrl
& BNX2X_FLOW_CTRL_TX
)
391 REG_WR(bp
, NIG_REG_EMAC0_PAUSE_OUT_EN
+ port
*4, val
);
392 REG_WR(bp
, NIG_REG_EGRESS_EMAC0_OUT_EN
+ port
*4, 0x1);
394 if (CHIP_REV_IS_EMUL(bp
)) {
395 /* take the BigMac out of reset */
397 GRCBASE_MISC
+ MISC_REGISTERS_RESET_REG_2_SET
,
398 (MISC_REGISTERS_RESET_REG_2_RST_BMAC0
<< port
));
400 /* enable access for bmac registers */
401 REG_WR(bp
, NIG_REG_BMAC0_REGS_OUT_EN
+ port
*4, 0x1);
403 REG_WR(bp
, NIG_REG_BMAC0_REGS_OUT_EN
+ port
*4, 0x0);
405 vars
->mac_type
= MAC_TYPE_EMAC
;
411 static u8
bnx2x_bmac_enable(struct link_params
*params
, struct link_vars
*vars
,
414 struct bnx2x
*bp
= params
->bp
;
415 u8 port
= params
->port
;
416 u32 bmac_addr
= port
? NIG_REG_INGRESS_BMAC1_MEM
:
417 NIG_REG_INGRESS_BMAC0_MEM
;
421 DP(NETIF_MSG_LINK
, "Enabling BigMAC\n");
422 /* reset and unreset the BigMac */
423 REG_WR(bp
, GRCBASE_MISC
+ MISC_REGISTERS_RESET_REG_2_CLEAR
,
424 (MISC_REGISTERS_RESET_REG_2_RST_BMAC0
<< port
));
427 REG_WR(bp
, GRCBASE_MISC
+ MISC_REGISTERS_RESET_REG_2_SET
,
428 (MISC_REGISTERS_RESET_REG_2_RST_BMAC0
<< port
));
430 /* enable access for bmac registers */
431 REG_WR(bp
, NIG_REG_BMAC0_REGS_OUT_EN
+ port
*4, 0x1);
436 REG_WR_DMAE(bp
, bmac_addr
+
437 BIGMAC_REGISTER_BMAC_XGXS_CONTROL
,
441 wb_data
[0] = ((params
->mac_addr
[2] << 24) |
442 (params
->mac_addr
[3] << 16) |
443 (params
->mac_addr
[4] << 8) |
444 params
->mac_addr
[5]);
445 wb_data
[1] = ((params
->mac_addr
[0] << 8) |
446 params
->mac_addr
[1]);
447 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC_REGISTER_TX_SOURCE_ADDR
,
452 if (vars
->flow_ctrl
& BNX2X_FLOW_CTRL_TX
)
456 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC_REGISTER_TX_CONTROL
,
463 DP(NETIF_MSG_LINK
, "enable bmac loopback\n");
467 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC_REGISTER_BMAC_CONTROL
,
471 wb_data
[0] = ETH_MAX_JUMBO_PACKET_SIZE
+ ETH_OVREHEAD
;
473 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC_REGISTER_RX_MAX_SIZE
,
476 /* rx control set to don't strip crc */
478 if (vars
->flow_ctrl
& BNX2X_FLOW_CTRL_RX
)
482 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC_REGISTER_RX_CONTROL
,
486 wb_data
[0] = ETH_MAX_JUMBO_PACKET_SIZE
+ ETH_OVREHEAD
;
488 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC_REGISTER_TX_MAX_SIZE
,
491 /* set cnt max size */
492 wb_data
[0] = ETH_MAX_JUMBO_PACKET_SIZE
+ ETH_OVREHEAD
;
494 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC_REGISTER_CNT_MAX_SIZE
,
498 wb_data
[0] = 0x1000200;
500 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC_REGISTER_RX_LLFC_MSG_FLDS
,
502 /* fix for emulation */
503 if (CHIP_REV_IS_EMUL(bp
)) {
507 bmac_addr
+ BIGMAC_REGISTER_TX_PAUSE_THRESHOLD
,
511 REG_WR(bp
, NIG_REG_XGXS_SERDES0_MODE_SEL
+ port
*4, 0x1);
512 REG_WR(bp
, NIG_REG_XGXS_LANE_SEL_P0
+ port
*4, 0x0);
513 REG_WR(bp
, NIG_REG_EGRESS_EMAC0_PORT
+ port
*4, 0x0);
515 if (vars
->flow_ctrl
& BNX2X_FLOW_CTRL_TX
)
517 REG_WR(bp
, NIG_REG_BMAC0_PAUSE_OUT_EN
+ port
*4, val
);
518 REG_WR(bp
, NIG_REG_EGRESS_EMAC0_OUT_EN
+ port
*4, 0x0);
519 REG_WR(bp
, NIG_REG_EMAC0_IN_EN
+ port
*4, 0x0);
520 REG_WR(bp
, NIG_REG_EMAC0_PAUSE_OUT_EN
+ port
*4, 0x0);
521 REG_WR(bp
, NIG_REG_BMAC0_IN_EN
+ port
*4, 0x1);
522 REG_WR(bp
, NIG_REG_BMAC0_OUT_EN
+ port
*4, 0x1);
524 vars
->mac_type
= MAC_TYPE_BMAC
;
528 static void bnx2x_phy_deassert(struct link_params
*params
, u8 phy_flags
)
530 struct bnx2x
*bp
= params
->bp
;
533 if (phy_flags
& PHY_XGXS_FLAG
) {
534 DP(NETIF_MSG_LINK
, "bnx2x_phy_deassert:XGXS\n");
535 val
= XGXS_RESET_BITS
;
537 } else { /* SerDes */
538 DP(NETIF_MSG_LINK
, "bnx2x_phy_deassert:SerDes\n");
539 val
= SERDES_RESET_BITS
;
542 val
= val
<< (params
->port
*16);
544 /* reset and unreset the SerDes/XGXS */
545 REG_WR(bp
, GRCBASE_MISC
+ MISC_REGISTERS_RESET_REG_3_CLEAR
,
548 REG_WR(bp
, GRCBASE_MISC
+ MISC_REGISTERS_RESET_REG_3_SET
,
550 bnx2x_set_phy_mdio(params
, phy_flags
);
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
;
634 if (vars
->link_status
& LINK_STATUS_TX_FLOW_CONTROL_ENABLED
)
635 vars
->flow_ctrl
|= BNX2X_FLOW_CTRL_TX
;
637 vars
->flow_ctrl
&= ~BNX2X_FLOW_CTRL_TX
;
639 if (vars
->link_status
& LINK_STATUS_RX_FLOW_CONTROL_ENABLED
)
640 vars
->flow_ctrl
|= BNX2X_FLOW_CTRL_RX
;
642 vars
->flow_ctrl
&= ~BNX2X_FLOW_CTRL_RX
;
644 if (vars
->phy_flags
& PHY_XGXS_FLAG
) {
645 if (vars
->line_speed
&&
646 ((vars
->line_speed
== SPEED_10
) ||
647 (vars
->line_speed
== SPEED_100
))) {
648 vars
->phy_flags
|= PHY_SGMII_FLAG
;
650 vars
->phy_flags
&= ~PHY_SGMII_FLAG
;
654 /* anything 10 and over uses the bmac */
655 link_10g
= ((vars
->line_speed
== SPEED_10000
) ||
656 (vars
->line_speed
== SPEED_12000
) ||
657 (vars
->line_speed
== SPEED_12500
) ||
658 (vars
->line_speed
== SPEED_13000
) ||
659 (vars
->line_speed
== SPEED_15000
) ||
660 (vars
->line_speed
== SPEED_16000
));
662 vars
->mac_type
= MAC_TYPE_BMAC
;
664 vars
->mac_type
= MAC_TYPE_EMAC
;
666 } else { /* link down */
667 DP(NETIF_MSG_LINK
, "phy link down\n");
669 vars
->phy_link_up
= 0;
671 vars
->line_speed
= 0;
672 vars
->duplex
= DUPLEX_FULL
;
673 vars
->flow_ctrl
= BNX2X_FLOW_CTRL_NONE
;
675 /* indicate no mac active */
676 vars
->mac_type
= MAC_TYPE_NONE
;
679 DP(NETIF_MSG_LINK
, "link_status 0x%x phy_link_up %x\n",
680 vars
->link_status
, vars
->phy_link_up
);
681 DP(NETIF_MSG_LINK
, "line_speed %x duplex %x flow_ctrl 0x%x\n",
682 vars
->line_speed
, vars
->duplex
, vars
->flow_ctrl
);
685 static void bnx2x_update_mng(struct link_params
*params
, u32 link_status
)
687 struct bnx2x
*bp
= params
->bp
;
689 REG_WR(bp
, params
->shmem_base
+
690 offsetof(struct shmem_region
,
691 port_mb
[params
->port
].link_status
),
695 static void bnx2x_bmac_rx_disable(struct bnx2x
*bp
, u8 port
)
697 u32 bmac_addr
= port
? NIG_REG_INGRESS_BMAC1_MEM
:
698 NIG_REG_INGRESS_BMAC0_MEM
;
700 u32 nig_bmac_enable
= REG_RD(bp
, NIG_REG_BMAC0_REGS_OUT_EN
+ port
*4);
702 /* Only if the bmac is out of reset */
703 if (REG_RD(bp
, MISC_REG_RESET_REG_2
) &
704 (MISC_REGISTERS_RESET_REG_2_RST_BMAC0
<< port
) &&
707 /* Clear Rx Enable bit in BMAC_CONTROL register */
708 REG_RD_DMAE(bp
, bmac_addr
+ BIGMAC_REGISTER_BMAC_CONTROL
,
710 wb_data
[0] &= ~BMAC_CONTROL_RX_ENABLE
;
711 REG_WR_DMAE(bp
, bmac_addr
+ BIGMAC_REGISTER_BMAC_CONTROL
,
718 static u8
bnx2x_pbf_update(struct link_params
*params
, u32 flow_ctrl
,
721 struct bnx2x
*bp
= params
->bp
;
722 u8 port
= params
->port
;
727 REG_WR(bp
, PBF_REG_DISABLE_NEW_TASK_PROC_P0
+ port
*4, 0x1);
729 /* wait for init credit */
730 init_crd
= REG_RD(bp
, PBF_REG_P0_INIT_CRD
+ port
*4);
731 crd
= REG_RD(bp
, PBF_REG_P0_CREDIT
+ port
*8);
732 DP(NETIF_MSG_LINK
, "init_crd 0x%x crd 0x%x\n", init_crd
, crd
);
734 while ((init_crd
!= crd
) && count
) {
737 crd
= REG_RD(bp
, PBF_REG_P0_CREDIT
+ port
*8);
740 crd
= REG_RD(bp
, PBF_REG_P0_CREDIT
+ port
*8);
741 if (init_crd
!= crd
) {
742 DP(NETIF_MSG_LINK
, "BUG! init_crd 0x%x != crd 0x%x\n",
747 if (flow_ctrl
& BNX2X_FLOW_CTRL_RX
||
748 line_speed
== SPEED_10
||
749 line_speed
== SPEED_100
||
750 line_speed
== SPEED_1000
||
751 line_speed
== SPEED_2500
) {
752 REG_WR(bp
, PBF_REG_P0_PAUSE_ENABLE
+ port
*4, 1);
753 /* update threshold */
754 REG_WR(bp
, PBF_REG_P0_ARB_THRSH
+ port
*4, 0);
755 /* update init credit */
756 init_crd
= 778; /* (800-18-4) */
759 u32 thresh
= (ETH_MAX_JUMBO_PACKET_SIZE
+
761 REG_WR(bp
, PBF_REG_P0_PAUSE_ENABLE
+ port
*4, 0);
762 /* update threshold */
763 REG_WR(bp
, PBF_REG_P0_ARB_THRSH
+ port
*4, thresh
);
764 /* update init credit */
765 switch (line_speed
) {
767 init_crd
= thresh
+ 553 - 22;
771 init_crd
= thresh
+ 664 - 22;
775 init_crd
= thresh
+ 742 - 22;
779 init_crd
= thresh
+ 778 - 22;
782 DP(NETIF_MSG_LINK
, "Invalid line_speed 0x%x\n",
787 REG_WR(bp
, PBF_REG_P0_INIT_CRD
+ port
*4, init_crd
);
788 DP(NETIF_MSG_LINK
, "PBF updated to speed %d credit %d\n",
789 line_speed
, init_crd
);
791 /* probe the credit changes */
792 REG_WR(bp
, PBF_REG_INIT_P0
+ port
*4, 0x1);
794 REG_WR(bp
, PBF_REG_INIT_P0
+ port
*4, 0x0);
797 REG_WR(bp
, PBF_REG_DISABLE_NEW_TASK_PROC_P0
+ port
*4, 0x0);
801 static u32
bnx2x_get_emac_base(struct bnx2x
*bp
, u32 ext_phy_type
, u8 port
)
805 switch (ext_phy_type
) {
806 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8072
:
807 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726
:
808 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727
:
809 /* All MDC/MDIO is directed through single EMAC */
810 if (REG_RD(bp
, NIG_REG_PORT_SWAP
))
811 emac_base
= GRCBASE_EMAC0
;
813 emac_base
= GRCBASE_EMAC1
;
815 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073
:
816 emac_base
= (port
) ? GRCBASE_EMAC0
: GRCBASE_EMAC1
;
819 emac_base
= (port
) ? GRCBASE_EMAC1
: GRCBASE_EMAC0
;
826 u8
bnx2x_cl45_write(struct bnx2x
*bp
, u8 port
, u32 ext_phy_type
,
827 u8 phy_addr
, u8 devad
, u16 reg
, u16 val
)
831 u32 mdio_ctrl
= bnx2x_get_emac_base(bp
, ext_phy_type
, port
);
833 /* set clause 45 mode, slow down the MDIO clock to 2.5MHz
834 * (a value of 49==0x31) and make sure that the AUTO poll is off
837 saved_mode
= REG_RD(bp
, mdio_ctrl
+ EMAC_REG_EMAC_MDIO_MODE
);
838 tmp
= saved_mode
& ~(EMAC_MDIO_MODE_AUTO_POLL
|
839 EMAC_MDIO_MODE_CLOCK_CNT
);
840 tmp
|= (EMAC_MDIO_MODE_CLAUSE_45
|
841 (49 << EMAC_MDIO_MODE_CLOCK_CNT_BITSHIFT
));
842 REG_WR(bp
, mdio_ctrl
+ EMAC_REG_EMAC_MDIO_MODE
, tmp
);
843 REG_RD(bp
, mdio_ctrl
+ EMAC_REG_EMAC_MDIO_MODE
);
848 tmp
= ((phy_addr
<< 21) | (devad
<< 16) | reg
|
849 EMAC_MDIO_COMM_COMMAND_ADDRESS
|
850 EMAC_MDIO_COMM_START_BUSY
);
851 REG_WR(bp
, mdio_ctrl
+ EMAC_REG_EMAC_MDIO_COMM
, tmp
);
853 for (i
= 0; i
< 50; i
++) {
856 tmp
= REG_RD(bp
, mdio_ctrl
+ EMAC_REG_EMAC_MDIO_COMM
);
857 if (!(tmp
& EMAC_MDIO_COMM_START_BUSY
)) {
862 if (tmp
& EMAC_MDIO_COMM_START_BUSY
) {
863 DP(NETIF_MSG_LINK
, "write phy register failed\n");
867 tmp
= ((phy_addr
<< 21) | (devad
<< 16) | val
|
868 EMAC_MDIO_COMM_COMMAND_WRITE_45
|
869 EMAC_MDIO_COMM_START_BUSY
);
870 REG_WR(bp
, mdio_ctrl
+ EMAC_REG_EMAC_MDIO_COMM
, tmp
);
872 for (i
= 0; i
< 50; i
++) {
875 tmp
= REG_RD(bp
, mdio_ctrl
+
876 EMAC_REG_EMAC_MDIO_COMM
);
877 if (!(tmp
& EMAC_MDIO_COMM_START_BUSY
)) {
882 if (tmp
& EMAC_MDIO_COMM_START_BUSY
) {
883 DP(NETIF_MSG_LINK
, "write phy register failed\n");
888 /* Restore the saved mode */
889 REG_WR(bp
, mdio_ctrl
+ EMAC_REG_EMAC_MDIO_MODE
, saved_mode
);
894 u8
bnx2x_cl45_read(struct bnx2x
*bp
, u8 port
, u32 ext_phy_type
,
895 u8 phy_addr
, u8 devad
, u16 reg
, u16
*ret_val
)
901 u32 mdio_ctrl
= bnx2x_get_emac_base(bp
, ext_phy_type
, port
);
902 /* set clause 45 mode, slow down the MDIO clock to 2.5MHz
903 * (a value of 49==0x31) and make sure that the AUTO poll is off
906 saved_mode
= REG_RD(bp
, mdio_ctrl
+ EMAC_REG_EMAC_MDIO_MODE
);
907 val
= saved_mode
& ((EMAC_MDIO_MODE_AUTO_POLL
|
908 EMAC_MDIO_MODE_CLOCK_CNT
));
909 val
|= (EMAC_MDIO_MODE_CLAUSE_45
|
910 (49L << EMAC_MDIO_MODE_CLOCK_CNT_BITSHIFT
));
911 REG_WR(bp
, mdio_ctrl
+ EMAC_REG_EMAC_MDIO_MODE
, val
);
912 REG_RD(bp
, mdio_ctrl
+ EMAC_REG_EMAC_MDIO_MODE
);
916 val
= ((phy_addr
<< 21) | (devad
<< 16) | reg
|
917 EMAC_MDIO_COMM_COMMAND_ADDRESS
|
918 EMAC_MDIO_COMM_START_BUSY
);
919 REG_WR(bp
, mdio_ctrl
+ EMAC_REG_EMAC_MDIO_COMM
, val
);
921 for (i
= 0; i
< 50; i
++) {
924 val
= REG_RD(bp
, mdio_ctrl
+ EMAC_REG_EMAC_MDIO_COMM
);
925 if (!(val
& EMAC_MDIO_COMM_START_BUSY
)) {
930 if (val
& EMAC_MDIO_COMM_START_BUSY
) {
931 DP(NETIF_MSG_LINK
, "read phy register failed\n");
938 val
= ((phy_addr
<< 21) | (devad
<< 16) |
939 EMAC_MDIO_COMM_COMMAND_READ_45
|
940 EMAC_MDIO_COMM_START_BUSY
);
941 REG_WR(bp
, mdio_ctrl
+ EMAC_REG_EMAC_MDIO_COMM
, val
);
943 for (i
= 0; i
< 50; i
++) {
946 val
= REG_RD(bp
, mdio_ctrl
+
947 EMAC_REG_EMAC_MDIO_COMM
);
948 if (!(val
& EMAC_MDIO_COMM_START_BUSY
)) {
949 *ret_val
= (u16
)(val
& EMAC_MDIO_COMM_DATA
);
953 if (val
& EMAC_MDIO_COMM_START_BUSY
) {
954 DP(NETIF_MSG_LINK
, "read phy register failed\n");
961 /* Restore the saved mode */
962 REG_WR(bp
, mdio_ctrl
+ EMAC_REG_EMAC_MDIO_MODE
, saved_mode
);
967 static void bnx2x_set_aer_mmd(struct link_params
*params
,
968 struct link_vars
*vars
)
970 struct bnx2x
*bp
= params
->bp
;
974 ser_lane
= ((params
->lane_config
&
975 PORT_HW_CFG_LANE_SWAP_CFG_MASTER_MASK
) >>
976 PORT_HW_CFG_LANE_SWAP_CFG_MASTER_SHIFT
);
978 offset
= (vars
->phy_flags
& PHY_XGXS_FLAG
) ?
979 (params
->phy_addr
+ ser_lane
) : 0;
981 CL45_WR_OVER_CL22(bp
, params
->port
,
983 MDIO_REG_BANK_AER_BLOCK
,
984 MDIO_AER_BLOCK_AER_REG
, 0x3800 + offset
);
987 static void bnx2x_set_master_ln(struct link_params
*params
)
989 struct bnx2x
*bp
= params
->bp
;
990 u16 new_master_ln
, ser_lane
;
991 ser_lane
= ((params
->lane_config
&
992 PORT_HW_CFG_LANE_SWAP_CFG_MASTER_MASK
) >>
993 PORT_HW_CFG_LANE_SWAP_CFG_MASTER_SHIFT
);
995 /* set the master_ln for AN */
996 CL45_RD_OVER_CL22(bp
, params
->port
,
998 MDIO_REG_BANK_XGXS_BLOCK2
,
999 MDIO_XGXS_BLOCK2_TEST_MODE_LANE
,
1002 CL45_WR_OVER_CL22(bp
, params
->port
,
1004 MDIO_REG_BANK_XGXS_BLOCK2
,
1005 MDIO_XGXS_BLOCK2_TEST_MODE_LANE
,
1006 (new_master_ln
| ser_lane
));
1009 static u8
bnx2x_reset_unicore(struct link_params
*params
)
1011 struct bnx2x
*bp
= params
->bp
;
1015 CL45_RD_OVER_CL22(bp
, params
->port
,
1017 MDIO_REG_BANK_COMBO_IEEE0
,
1018 MDIO_COMBO_IEEE0_MII_CONTROL
, &mii_control
);
1020 /* reset the unicore */
1021 CL45_WR_OVER_CL22(bp
, params
->port
,
1023 MDIO_REG_BANK_COMBO_IEEE0
,
1024 MDIO_COMBO_IEEE0_MII_CONTROL
,
1026 MDIO_COMBO_IEEO_MII_CONTROL_RESET
));
1027 if (params
->switch_cfg
== SWITCH_CFG_1G
)
1028 bnx2x_set_serdes_access(params
);
1030 /* wait for the reset to self clear */
1031 for (i
= 0; i
< MDIO_ACCESS_TIMEOUT
; i
++) {
1034 /* the reset erased the previous bank value */
1035 CL45_RD_OVER_CL22(bp
, params
->port
,
1037 MDIO_REG_BANK_COMBO_IEEE0
,
1038 MDIO_COMBO_IEEE0_MII_CONTROL
,
1041 if (!(mii_control
& MDIO_COMBO_IEEO_MII_CONTROL_RESET
)) {
1047 DP(NETIF_MSG_LINK
, "BUG! XGXS is still in reset!\n");
1052 static void bnx2x_set_swap_lanes(struct link_params
*params
)
1054 struct bnx2x
*bp
= params
->bp
;
1055 /* Each two bits represents a lane number:
1056 No swap is 0123 => 0x1b no need to enable the swap */
1057 u16 ser_lane
, rx_lane_swap
, tx_lane_swap
;
1059 ser_lane
= ((params
->lane_config
&
1060 PORT_HW_CFG_LANE_SWAP_CFG_MASTER_MASK
) >>
1061 PORT_HW_CFG_LANE_SWAP_CFG_MASTER_SHIFT
);
1062 rx_lane_swap
= ((params
->lane_config
&
1063 PORT_HW_CFG_LANE_SWAP_CFG_RX_MASK
) >>
1064 PORT_HW_CFG_LANE_SWAP_CFG_RX_SHIFT
);
1065 tx_lane_swap
= ((params
->lane_config
&
1066 PORT_HW_CFG_LANE_SWAP_CFG_TX_MASK
) >>
1067 PORT_HW_CFG_LANE_SWAP_CFG_TX_SHIFT
);
1069 if (rx_lane_swap
!= 0x1b) {
1070 CL45_WR_OVER_CL22(bp
, params
->port
,
1072 MDIO_REG_BANK_XGXS_BLOCK2
,
1073 MDIO_XGXS_BLOCK2_RX_LN_SWAP
,
1075 MDIO_XGXS_BLOCK2_RX_LN_SWAP_ENABLE
|
1076 MDIO_XGXS_BLOCK2_RX_LN_SWAP_FORCE_ENABLE
));
1078 CL45_WR_OVER_CL22(bp
, params
->port
,
1080 MDIO_REG_BANK_XGXS_BLOCK2
,
1081 MDIO_XGXS_BLOCK2_RX_LN_SWAP
, 0);
1084 if (tx_lane_swap
!= 0x1b) {
1085 CL45_WR_OVER_CL22(bp
, params
->port
,
1087 MDIO_REG_BANK_XGXS_BLOCK2
,
1088 MDIO_XGXS_BLOCK2_TX_LN_SWAP
,
1090 MDIO_XGXS_BLOCK2_TX_LN_SWAP_ENABLE
));
1092 CL45_WR_OVER_CL22(bp
, params
->port
,
1094 MDIO_REG_BANK_XGXS_BLOCK2
,
1095 MDIO_XGXS_BLOCK2_TX_LN_SWAP
, 0);
1099 static void bnx2x_set_parallel_detection(struct link_params
*params
,
1102 struct bnx2x
*bp
= params
->bp
;
1105 CL45_RD_OVER_CL22(bp
, params
->port
,
1107 MDIO_REG_BANK_SERDES_DIGITAL
,
1108 MDIO_SERDES_DIGITAL_A_1000X_CONTROL2
,
1112 control2
|= MDIO_SERDES_DIGITAL_A_1000X_CONTROL2_PRL_DT_EN
;
1115 CL45_WR_OVER_CL22(bp
, params
->port
,
1117 MDIO_REG_BANK_SERDES_DIGITAL
,
1118 MDIO_SERDES_DIGITAL_A_1000X_CONTROL2
,
1121 if (phy_flags
& PHY_XGXS_FLAG
) {
1122 DP(NETIF_MSG_LINK
, "XGXS\n");
1124 CL45_WR_OVER_CL22(bp
, params
->port
,
1126 MDIO_REG_BANK_10G_PARALLEL_DETECT
,
1127 MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_LINK
,
1128 MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_LINK_CNT
);
1130 CL45_RD_OVER_CL22(bp
, params
->port
,
1132 MDIO_REG_BANK_10G_PARALLEL_DETECT
,
1133 MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_CONTROL
,
1138 MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_CONTROL_PARDET10G_EN
;
1140 CL45_WR_OVER_CL22(bp
, params
->port
,
1142 MDIO_REG_BANK_10G_PARALLEL_DETECT
,
1143 MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_CONTROL
,
1146 /* Disable parallel detection of HiG */
1147 CL45_WR_OVER_CL22(bp
, params
->port
,
1149 MDIO_REG_BANK_XGXS_BLOCK2
,
1150 MDIO_XGXS_BLOCK2_UNICORE_MODE_10G
,
1151 MDIO_XGXS_BLOCK2_UNICORE_MODE_10G_CX4_XGXS
|
1152 MDIO_XGXS_BLOCK2_UNICORE_MODE_10G_HIGIG_XGXS
);
1156 static void bnx2x_set_autoneg(struct link_params
*params
,
1157 struct link_vars
*vars
,
1160 struct bnx2x
*bp
= params
->bp
;
1165 CL45_RD_OVER_CL22(bp
, params
->port
,
1167 MDIO_REG_BANK_COMBO_IEEE0
,
1168 MDIO_COMBO_IEEE0_MII_CONTROL
, ®_val
);
1170 /* CL37 Autoneg Enabled */
1171 if (vars
->line_speed
== SPEED_AUTO_NEG
)
1172 reg_val
|= MDIO_COMBO_IEEO_MII_CONTROL_AN_EN
;
1173 else /* CL37 Autoneg Disabled */
1174 reg_val
&= ~(MDIO_COMBO_IEEO_MII_CONTROL_AN_EN
|
1175 MDIO_COMBO_IEEO_MII_CONTROL_RESTART_AN
);
1177 CL45_WR_OVER_CL22(bp
, params
->port
,
1179 MDIO_REG_BANK_COMBO_IEEE0
,
1180 MDIO_COMBO_IEEE0_MII_CONTROL
, reg_val
);
1182 /* Enable/Disable Autodetection */
1184 CL45_RD_OVER_CL22(bp
, params
->port
,
1186 MDIO_REG_BANK_SERDES_DIGITAL
,
1187 MDIO_SERDES_DIGITAL_A_1000X_CONTROL1
, ®_val
);
1188 reg_val
&= ~(MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_SIGNAL_DETECT_EN
|
1189 MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_INVERT_SIGNAL_DETECT
);
1190 reg_val
|= MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_FIBER_MODE
;
1191 if (vars
->line_speed
== SPEED_AUTO_NEG
)
1192 reg_val
|= MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_AUTODET
;
1194 reg_val
&= ~MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_AUTODET
;
1196 CL45_WR_OVER_CL22(bp
, params
->port
,
1198 MDIO_REG_BANK_SERDES_DIGITAL
,
1199 MDIO_SERDES_DIGITAL_A_1000X_CONTROL1
, reg_val
);
1201 /* Enable TetonII and BAM autoneg */
1202 CL45_RD_OVER_CL22(bp
, params
->port
,
1204 MDIO_REG_BANK_BAM_NEXT_PAGE
,
1205 MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL
,
1207 if (vars
->line_speed
== SPEED_AUTO_NEG
) {
1208 /* Enable BAM aneg Mode and TetonII aneg Mode */
1209 reg_val
|= (MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL_BAM_MODE
|
1210 MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL_TETON_AN
);
1212 /* TetonII and BAM Autoneg Disabled */
1213 reg_val
&= ~(MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL_BAM_MODE
|
1214 MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL_TETON_AN
);
1216 CL45_WR_OVER_CL22(bp
, params
->port
,
1218 MDIO_REG_BANK_BAM_NEXT_PAGE
,
1219 MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL
,
1223 /* Enable Cl73 FSM status bits */
1224 CL45_WR_OVER_CL22(bp
, params
->port
,
1226 MDIO_REG_BANK_CL73_USERB0
,
1227 MDIO_CL73_USERB0_CL73_UCTRL
,
1228 MDIO_CL73_USERB0_CL73_UCTRL_USTAT1_MUXSEL
);
1230 /* Enable BAM Station Manager*/
1231 CL45_WR_OVER_CL22(bp
, params
->port
,
1233 MDIO_REG_BANK_CL73_USERB0
,
1234 MDIO_CL73_USERB0_CL73_BAM_CTRL1
,
1235 MDIO_CL73_USERB0_CL73_BAM_CTRL1_BAM_EN
|
1236 MDIO_CL73_USERB0_CL73_BAM_CTRL1_BAM_STATION_MNGR_EN
|
1237 MDIO_CL73_USERB0_CL73_BAM_CTRL1_BAM_NP_AFTER_BP_EN
);
1239 /* Merge CL73 and CL37 aneg resolution */
1240 CL45_RD_OVER_CL22(bp
, params
->port
,
1242 MDIO_REG_BANK_CL73_USERB0
,
1243 MDIO_CL73_USERB0_CL73_BAM_CTRL3
,
1246 if (params
->speed_cap_mask
&
1247 PORT_HW_CFG_SPEED_CAPABILITY_D0_10G
) {
1248 /* Set the CL73 AN speed */
1249 CL45_RD_OVER_CL22(bp
, params
->port
,
1251 MDIO_REG_BANK_CL73_IEEEB1
,
1252 MDIO_CL73_IEEEB1_AN_ADV2
,
1255 CL45_WR_OVER_CL22(bp
, params
->port
,
1257 MDIO_REG_BANK_CL73_IEEEB1
,
1258 MDIO_CL73_IEEEB1_AN_ADV2
,
1259 reg_val
| MDIO_CL73_IEEEB1_AN_ADV2_ADVR_10G_KX4
);
1262 /* CL73 Autoneg Enabled */
1263 reg_val
= MDIO_CL73_IEEEB0_CL73_AN_CONTROL_AN_EN
;
1265 } else /* CL73 Autoneg Disabled */
1268 CL45_WR_OVER_CL22(bp
, params
->port
,
1270 MDIO_REG_BANK_CL73_IEEEB0
,
1271 MDIO_CL73_IEEEB0_CL73_AN_CONTROL
, reg_val
);
1274 /* program SerDes, forced speed */
1275 static void bnx2x_program_serdes(struct link_params
*params
,
1276 struct link_vars
*vars
)
1278 struct bnx2x
*bp
= params
->bp
;
1281 /* program duplex, disable autoneg and sgmii*/
1282 CL45_RD_OVER_CL22(bp
, params
->port
,
1284 MDIO_REG_BANK_COMBO_IEEE0
,
1285 MDIO_COMBO_IEEE0_MII_CONTROL
, ®_val
);
1286 reg_val
&= ~(MDIO_COMBO_IEEO_MII_CONTROL_FULL_DUPLEX
|
1287 MDIO_COMBO_IEEO_MII_CONTROL_AN_EN
|
1288 MDIO_COMBO_IEEO_MII_CONTROL_MAN_SGMII_SP_MASK
);
1289 if (params
->req_duplex
== DUPLEX_FULL
)
1290 reg_val
|= MDIO_COMBO_IEEO_MII_CONTROL_FULL_DUPLEX
;
1291 CL45_WR_OVER_CL22(bp
, params
->port
,
1293 MDIO_REG_BANK_COMBO_IEEE0
,
1294 MDIO_COMBO_IEEE0_MII_CONTROL
, reg_val
);
1297 - needed only if the speed is greater than 1G (2.5G or 10G) */
1298 CL45_RD_OVER_CL22(bp
, params
->port
,
1300 MDIO_REG_BANK_SERDES_DIGITAL
,
1301 MDIO_SERDES_DIGITAL_MISC1
, ®_val
);
1302 /* clearing the speed value before setting the right speed */
1303 DP(NETIF_MSG_LINK
, "MDIO_REG_BANK_SERDES_DIGITAL = 0x%x\n", reg_val
);
1305 reg_val
&= ~(MDIO_SERDES_DIGITAL_MISC1_FORCE_SPEED_MASK
|
1306 MDIO_SERDES_DIGITAL_MISC1_FORCE_SPEED_SEL
);
1308 if (!((vars
->line_speed
== SPEED_1000
) ||
1309 (vars
->line_speed
== SPEED_100
) ||
1310 (vars
->line_speed
== SPEED_10
))) {
1312 reg_val
|= (MDIO_SERDES_DIGITAL_MISC1_REFCLK_SEL_156_25M
|
1313 MDIO_SERDES_DIGITAL_MISC1_FORCE_SPEED_SEL
);
1314 if (vars
->line_speed
== SPEED_10000
)
1316 MDIO_SERDES_DIGITAL_MISC1_FORCE_SPEED_10G_CX4
;
1317 if (vars
->line_speed
== SPEED_13000
)
1319 MDIO_SERDES_DIGITAL_MISC1_FORCE_SPEED_13G
;
1322 CL45_WR_OVER_CL22(bp
, params
->port
,
1324 MDIO_REG_BANK_SERDES_DIGITAL
,
1325 MDIO_SERDES_DIGITAL_MISC1
, reg_val
);
1329 static void bnx2x_set_brcm_cl37_advertisment(struct link_params
*params
)
1331 struct bnx2x
*bp
= params
->bp
;
1334 /* configure the 48 bits for BAM AN */
1336 /* set extended capabilities */
1337 if (params
->speed_cap_mask
& PORT_HW_CFG_SPEED_CAPABILITY_D0_2_5G
)
1338 val
|= MDIO_OVER_1G_UP1_2_5G
;
1339 if (params
->speed_cap_mask
& PORT_HW_CFG_SPEED_CAPABILITY_D0_10G
)
1340 val
|= MDIO_OVER_1G_UP1_10G
;
1341 CL45_WR_OVER_CL22(bp
, params
->port
,
1343 MDIO_REG_BANK_OVER_1G
,
1344 MDIO_OVER_1G_UP1
, val
);
1346 CL45_WR_OVER_CL22(bp
, params
->port
,
1348 MDIO_REG_BANK_OVER_1G
,
1349 MDIO_OVER_1G_UP3
, 0x400);
1352 static void bnx2x_calc_ieee_aneg_adv(struct link_params
*params
, u16
*ieee_fc
)
1354 *ieee_fc
= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_FULL_DUPLEX
;
1355 /* resolve pause mode and advertisement
1356 * Please refer to Table 28B-3 of the 802.3ab-1999 spec */
1358 switch (params
->req_flow_ctrl
) {
1359 case BNX2X_FLOW_CTRL_AUTO
:
1360 if (params
->req_fc_auto_adv
== BNX2X_FLOW_CTRL_BOTH
) {
1362 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH
;
1365 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC
;
1368 case BNX2X_FLOW_CTRL_TX
:
1370 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC
;
1373 case BNX2X_FLOW_CTRL_RX
:
1374 case BNX2X_FLOW_CTRL_BOTH
:
1375 *ieee_fc
|= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH
;
1378 case BNX2X_FLOW_CTRL_NONE
:
1380 *ieee_fc
|= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_NONE
;
1385 static void bnx2x_set_ieee_aneg_advertisment(struct link_params
*params
,
1388 struct bnx2x
*bp
= params
->bp
;
1389 /* for AN, we are always publishing full duplex */
1391 CL45_WR_OVER_CL22(bp
, params
->port
,
1393 MDIO_REG_BANK_COMBO_IEEE0
,
1394 MDIO_COMBO_IEEE0_AUTO_NEG_ADV
, ieee_fc
);
1397 static void bnx2x_restart_autoneg(struct link_params
*params
, u8 enable_cl73
)
1399 struct bnx2x
*bp
= params
->bp
;
1402 DP(NETIF_MSG_LINK
, "bnx2x_restart_autoneg\n");
1403 /* Enable and restart BAM/CL37 aneg */
1406 CL45_RD_OVER_CL22(bp
, params
->port
,
1408 MDIO_REG_BANK_CL73_IEEEB0
,
1409 MDIO_CL73_IEEEB0_CL73_AN_CONTROL
,
1412 CL45_WR_OVER_CL22(bp
, params
->port
,
1414 MDIO_REG_BANK_CL73_IEEEB0
,
1415 MDIO_CL73_IEEEB0_CL73_AN_CONTROL
,
1417 MDIO_CL73_IEEEB0_CL73_AN_CONTROL_AN_EN
|
1418 MDIO_CL73_IEEEB0_CL73_AN_CONTROL_RESTART_AN
));
1421 CL45_RD_OVER_CL22(bp
, params
->port
,
1423 MDIO_REG_BANK_COMBO_IEEE0
,
1424 MDIO_COMBO_IEEE0_MII_CONTROL
,
1427 "bnx2x_restart_autoneg mii_control before = 0x%x\n",
1429 CL45_WR_OVER_CL22(bp
, params
->port
,
1431 MDIO_REG_BANK_COMBO_IEEE0
,
1432 MDIO_COMBO_IEEE0_MII_CONTROL
,
1434 MDIO_COMBO_IEEO_MII_CONTROL_AN_EN
|
1435 MDIO_COMBO_IEEO_MII_CONTROL_RESTART_AN
));
1439 static void bnx2x_initialize_sgmii_process(struct link_params
*params
,
1440 struct link_vars
*vars
)
1442 struct bnx2x
*bp
= params
->bp
;
1445 /* in SGMII mode, the unicore is always slave */
1447 CL45_RD_OVER_CL22(bp
, params
->port
,
1449 MDIO_REG_BANK_SERDES_DIGITAL
,
1450 MDIO_SERDES_DIGITAL_A_1000X_CONTROL1
,
1452 control1
|= MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_INVERT_SIGNAL_DETECT
;
1453 /* set sgmii mode (and not fiber) */
1454 control1
&= ~(MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_FIBER_MODE
|
1455 MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_AUTODET
|
1456 MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_MSTR_MODE
);
1457 CL45_WR_OVER_CL22(bp
, params
->port
,
1459 MDIO_REG_BANK_SERDES_DIGITAL
,
1460 MDIO_SERDES_DIGITAL_A_1000X_CONTROL1
,
1463 /* if forced speed */
1464 if (!(vars
->line_speed
== SPEED_AUTO_NEG
)) {
1465 /* set speed, disable autoneg */
1468 CL45_RD_OVER_CL22(bp
, params
->port
,
1470 MDIO_REG_BANK_COMBO_IEEE0
,
1471 MDIO_COMBO_IEEE0_MII_CONTROL
,
1473 mii_control
&= ~(MDIO_COMBO_IEEO_MII_CONTROL_AN_EN
|
1474 MDIO_COMBO_IEEO_MII_CONTROL_MAN_SGMII_SP_MASK
|
1475 MDIO_COMBO_IEEO_MII_CONTROL_FULL_DUPLEX
);
1477 switch (vars
->line_speed
) {
1480 MDIO_COMBO_IEEO_MII_CONTROL_MAN_SGMII_SP_100
;
1484 MDIO_COMBO_IEEO_MII_CONTROL_MAN_SGMII_SP_1000
;
1487 /* there is nothing to set for 10M */
1490 /* invalid speed for SGMII */
1491 DP(NETIF_MSG_LINK
, "Invalid line_speed 0x%x\n",
1496 /* setting the full duplex */
1497 if (params
->req_duplex
== DUPLEX_FULL
)
1499 MDIO_COMBO_IEEO_MII_CONTROL_FULL_DUPLEX
;
1500 CL45_WR_OVER_CL22(bp
, params
->port
,
1502 MDIO_REG_BANK_COMBO_IEEE0
,
1503 MDIO_COMBO_IEEE0_MII_CONTROL
,
1506 } else { /* AN mode */
1507 /* enable and restart AN */
1508 bnx2x_restart_autoneg(params
, 0);
1517 static void bnx2x_pause_resolve(struct link_vars
*vars
, u32 pause_result
)
1519 switch (pause_result
) { /* ASYM P ASYM P */
1520 case 0xb: /* 1 0 1 1 */
1521 vars
->flow_ctrl
= BNX2X_FLOW_CTRL_TX
;
1524 case 0xe: /* 1 1 1 0 */
1525 vars
->flow_ctrl
= BNX2X_FLOW_CTRL_RX
;
1528 case 0x5: /* 0 1 0 1 */
1529 case 0x7: /* 0 1 1 1 */
1530 case 0xd: /* 1 1 0 1 */
1531 case 0xf: /* 1 1 1 1 */
1532 vars
->flow_ctrl
= BNX2X_FLOW_CTRL_BOTH
;
1540 static u8
bnx2x_ext_phy_resolve_fc(struct link_params
*params
,
1541 struct link_vars
*vars
)
1543 struct bnx2x
*bp
= params
->bp
;
1545 u16 ld_pause
; /* local */
1546 u16 lp_pause
; /* link partner */
1547 u16 an_complete
; /* AN complete */
1551 u8 port
= params
->port
;
1552 ext_phy_addr
= XGXS_EXT_PHY_ADDR(params
->ext_phy_config
);
1553 ext_phy_type
= XGXS_EXT_PHY_TYPE(params
->ext_phy_config
);
1556 bnx2x_cl45_read(bp
, port
,
1560 MDIO_AN_REG_STATUS
, &an_complete
);
1561 bnx2x_cl45_read(bp
, port
,
1565 MDIO_AN_REG_STATUS
, &an_complete
);
1567 if (an_complete
& MDIO_AN_REG_STATUS_AN_COMPLETE
) {
1569 bnx2x_cl45_read(bp
, port
,
1573 MDIO_AN_REG_ADV_PAUSE
, &ld_pause
);
1574 bnx2x_cl45_read(bp
, port
,
1578 MDIO_AN_REG_LP_AUTO_NEG
, &lp_pause
);
1579 pause_result
= (ld_pause
&
1580 MDIO_AN_REG_ADV_PAUSE_MASK
) >> 8;
1581 pause_result
|= (lp_pause
&
1582 MDIO_AN_REG_ADV_PAUSE_MASK
) >> 10;
1583 DP(NETIF_MSG_LINK
, "Ext PHY pause result 0x%x \n",
1585 bnx2x_pause_resolve(vars
, pause_result
);
1586 if (vars
->flow_ctrl
== BNX2X_FLOW_CTRL_NONE
&&
1587 ext_phy_type
== PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073
) {
1588 bnx2x_cl45_read(bp
, port
,
1592 MDIO_AN_REG_CL37_FC_LD
, &ld_pause
);
1594 bnx2x_cl45_read(bp
, port
,
1598 MDIO_AN_REG_CL37_FC_LP
, &lp_pause
);
1599 pause_result
= (ld_pause
&
1600 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH
) >> 5;
1601 pause_result
|= (lp_pause
&
1602 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH
) >> 7;
1604 bnx2x_pause_resolve(vars
, pause_result
);
1605 DP(NETIF_MSG_LINK
, "Ext PHY CL37 pause result 0x%x \n",
1613 static void bnx2x_flow_ctrl_resolve(struct link_params
*params
,
1614 struct link_vars
*vars
,
1617 struct bnx2x
*bp
= params
->bp
;
1618 u16 ld_pause
; /* local driver */
1619 u16 lp_pause
; /* link partner */
1622 vars
->flow_ctrl
= BNX2X_FLOW_CTRL_NONE
;
1624 /* resolve from gp_status in case of AN complete and not sgmii */
1625 if ((params
->req_flow_ctrl
== BNX2X_FLOW_CTRL_AUTO
) &&
1626 (gp_status
& MDIO_AN_CL73_OR_37_COMPLETE
) &&
1627 (!(vars
->phy_flags
& PHY_SGMII_FLAG
)) &&
1628 (XGXS_EXT_PHY_TYPE(params
->ext_phy_config
) ==
1629 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT
)) {
1630 CL45_RD_OVER_CL22(bp
, params
->port
,
1632 MDIO_REG_BANK_COMBO_IEEE0
,
1633 MDIO_COMBO_IEEE0_AUTO_NEG_ADV
,
1635 CL45_RD_OVER_CL22(bp
, params
->port
,
1637 MDIO_REG_BANK_COMBO_IEEE0
,
1638 MDIO_COMBO_IEEE0_AUTO_NEG_LINK_PARTNER_ABILITY1
,
1640 pause_result
= (ld_pause
&
1641 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_MASK
)>>5;
1642 pause_result
|= (lp_pause
&
1643 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_MASK
)>>7;
1644 DP(NETIF_MSG_LINK
, "pause_result 0x%x\n", pause_result
);
1645 bnx2x_pause_resolve(vars
, pause_result
);
1646 } else if ((params
->req_flow_ctrl
== BNX2X_FLOW_CTRL_AUTO
) &&
1647 (bnx2x_ext_phy_resolve_fc(params
, vars
))) {
1650 if (params
->req_flow_ctrl
== BNX2X_FLOW_CTRL_AUTO
)
1651 vars
->flow_ctrl
= params
->req_fc_auto_adv
;
1653 vars
->flow_ctrl
= params
->req_flow_ctrl
;
1655 DP(NETIF_MSG_LINK
, "flow_ctrl 0x%x\n", vars
->flow_ctrl
);
1658 static void bnx2x_check_fallback_to_cl37(struct link_params
*params
)
1660 struct bnx2x
*bp
= params
->bp
;
1661 u16 rx_status
, ustat_val
, cl37_fsm_recieved
;
1662 DP(NETIF_MSG_LINK
, "bnx2x_check_fallback_to_cl37\n");
1663 /* Step 1: Make sure signal is detected */
1664 CL45_RD_OVER_CL22(bp
, params
->port
,
1669 if ((rx_status
& MDIO_RX0_RX_STATUS_SIGDET
) !=
1670 (MDIO_RX0_RX_STATUS_SIGDET
)) {
1671 DP(NETIF_MSG_LINK
, "Signal is not detected. Restoring CL73."
1672 "rx_status(0x80b0) = 0x%x\n", rx_status
);
1673 CL45_WR_OVER_CL22(bp
, params
->port
,
1675 MDIO_REG_BANK_CL73_IEEEB0
,
1676 MDIO_CL73_IEEEB0_CL73_AN_CONTROL
,
1677 MDIO_CL73_IEEEB0_CL73_AN_CONTROL_AN_EN
);
1680 /* Step 2: Check CL73 state machine */
1681 CL45_RD_OVER_CL22(bp
, params
->port
,
1683 MDIO_REG_BANK_CL73_USERB0
,
1684 MDIO_CL73_USERB0_CL73_USTAT1
,
1687 (MDIO_CL73_USERB0_CL73_USTAT1_LINK_STATUS_CHECK
|
1688 MDIO_CL73_USERB0_CL73_USTAT1_AN_GOOD_CHECK_BAM37
)) !=
1689 (MDIO_CL73_USERB0_CL73_USTAT1_LINK_STATUS_CHECK
|
1690 MDIO_CL73_USERB0_CL73_USTAT1_AN_GOOD_CHECK_BAM37
)) {
1691 DP(NETIF_MSG_LINK
, "CL73 state-machine is not stable. "
1692 "ustat_val(0x8371) = 0x%x\n", ustat_val
);
1695 /* Step 3: Check CL37 Message Pages received to indicate LP
1696 supports only CL37 */
1697 CL45_RD_OVER_CL22(bp
, params
->port
,
1699 MDIO_REG_BANK_REMOTE_PHY
,
1700 MDIO_REMOTE_PHY_MISC_RX_STATUS
,
1701 &cl37_fsm_recieved
);
1702 if ((cl37_fsm_recieved
&
1703 (MDIO_REMOTE_PHY_MISC_RX_STATUS_CL37_FSM_RECEIVED_OVER1G_MSG
|
1704 MDIO_REMOTE_PHY_MISC_RX_STATUS_CL37_FSM_RECEIVED_BRCM_OUI_MSG
)) !=
1705 (MDIO_REMOTE_PHY_MISC_RX_STATUS_CL37_FSM_RECEIVED_OVER1G_MSG
|
1706 MDIO_REMOTE_PHY_MISC_RX_STATUS_CL37_FSM_RECEIVED_BRCM_OUI_MSG
)) {
1707 DP(NETIF_MSG_LINK
, "No CL37 FSM were received. "
1708 "misc_rx_status(0x8330) = 0x%x\n",
1712 /* The combined cl37/cl73 fsm state information indicating that we are
1713 connected to a device which does not support cl73, but does support
1714 cl37 BAM. In this case we disable cl73 and restart cl37 auto-neg */
1716 CL45_WR_OVER_CL22(bp
, params
->port
,
1718 MDIO_REG_BANK_CL73_IEEEB0
,
1719 MDIO_CL73_IEEEB0_CL73_AN_CONTROL
,
1721 /* Restart CL37 autoneg */
1722 bnx2x_restart_autoneg(params
, 0);
1723 DP(NETIF_MSG_LINK
, "Disabling CL73, and restarting CL37 autoneg\n");
1725 static u8
bnx2x_link_settings_status(struct link_params
*params
,
1726 struct link_vars
*vars
,
1730 struct bnx2x
*bp
= params
->bp
;
1733 vars
->link_status
= 0;
1735 if (gp_status
& MDIO_GP_STATUS_TOP_AN_STATUS1_LINK_STATUS
) {
1736 DP(NETIF_MSG_LINK
, "phy link up gp_status=0x%x\n",
1739 vars
->phy_link_up
= 1;
1740 vars
->link_status
|= LINK_STATUS_LINK_UP
;
1742 if (gp_status
& MDIO_GP_STATUS_TOP_AN_STATUS1_DUPLEX_STATUS
)
1743 vars
->duplex
= DUPLEX_FULL
;
1745 vars
->duplex
= DUPLEX_HALF
;
1747 bnx2x_flow_ctrl_resolve(params
, vars
, gp_status
);
1749 switch (gp_status
& GP_STATUS_SPEED_MASK
) {
1751 new_line_speed
= SPEED_10
;
1752 if (vars
->duplex
== DUPLEX_FULL
)
1753 vars
->link_status
|= LINK_10TFD
;
1755 vars
->link_status
|= LINK_10THD
;
1758 case GP_STATUS_100M
:
1759 new_line_speed
= SPEED_100
;
1760 if (vars
->duplex
== DUPLEX_FULL
)
1761 vars
->link_status
|= LINK_100TXFD
;
1763 vars
->link_status
|= LINK_100TXHD
;
1767 case GP_STATUS_1G_KX
:
1768 new_line_speed
= SPEED_1000
;
1769 if (vars
->duplex
== DUPLEX_FULL
)
1770 vars
->link_status
|= LINK_1000TFD
;
1772 vars
->link_status
|= LINK_1000THD
;
1775 case GP_STATUS_2_5G
:
1776 new_line_speed
= SPEED_2500
;
1777 if (vars
->duplex
== DUPLEX_FULL
)
1778 vars
->link_status
|= LINK_2500TFD
;
1780 vars
->link_status
|= LINK_2500THD
;
1786 "link speed unsupported gp_status 0x%x\n",
1790 case GP_STATUS_10G_KX4
:
1791 case GP_STATUS_10G_HIG
:
1792 case GP_STATUS_10G_CX4
:
1793 new_line_speed
= SPEED_10000
;
1794 vars
->link_status
|= LINK_10GTFD
;
1797 case GP_STATUS_12G_HIG
:
1798 new_line_speed
= SPEED_12000
;
1799 vars
->link_status
|= LINK_12GTFD
;
1802 case GP_STATUS_12_5G
:
1803 new_line_speed
= SPEED_12500
;
1804 vars
->link_status
|= LINK_12_5GTFD
;
1808 new_line_speed
= SPEED_13000
;
1809 vars
->link_status
|= LINK_13GTFD
;
1813 new_line_speed
= SPEED_15000
;
1814 vars
->link_status
|= LINK_15GTFD
;
1818 new_line_speed
= SPEED_16000
;
1819 vars
->link_status
|= LINK_16GTFD
;
1824 "link speed unsupported gp_status 0x%x\n",
1829 /* Upon link speed change set the NIG into drain mode.
1830 Comes to deals with possible FIFO glitch due to clk change
1831 when speed is decreased without link down indicator */
1832 if (new_line_speed
!= vars
->line_speed
) {
1833 if (XGXS_EXT_PHY_TYPE(params
->ext_phy_config
) !=
1834 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT
&&
1836 DP(NETIF_MSG_LINK
, "Internal link speed %d is"
1837 " different than the external"
1838 " link speed %d\n", new_line_speed
,
1840 vars
->phy_link_up
= 0;
1843 REG_WR(bp
, NIG_REG_EGRESS_DRAIN0_MODE
1844 + params
->port
*4, 0);
1847 vars
->line_speed
= new_line_speed
;
1848 vars
->link_status
|= LINK_STATUS_SERDES_LINK
;
1850 if ((params
->req_line_speed
== SPEED_AUTO_NEG
) &&
1851 ((XGXS_EXT_PHY_TYPE(params
->ext_phy_config
) ==
1852 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT
) ||
1853 (XGXS_EXT_PHY_TYPE(params
->ext_phy_config
) ==
1854 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8705
) ||
1855 (XGXS_EXT_PHY_TYPE(params
->ext_phy_config
) ==
1856 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726
))) {
1857 vars
->autoneg
= AUTO_NEG_ENABLED
;
1859 if (gp_status
& MDIO_AN_CL73_OR_37_COMPLETE
) {
1860 vars
->autoneg
|= AUTO_NEG_COMPLETE
;
1861 vars
->link_status
|=
1862 LINK_STATUS_AUTO_NEGOTIATE_COMPLETE
;
1865 vars
->autoneg
|= AUTO_NEG_PARALLEL_DETECTION_USED
;
1866 vars
->link_status
|=
1867 LINK_STATUS_PARALLEL_DETECTION_USED
;
1870 if (vars
->flow_ctrl
& BNX2X_FLOW_CTRL_TX
)
1871 vars
->link_status
|=
1872 LINK_STATUS_TX_FLOW_CONTROL_ENABLED
;
1874 if (vars
->flow_ctrl
& BNX2X_FLOW_CTRL_RX
)
1875 vars
->link_status
|=
1876 LINK_STATUS_RX_FLOW_CONTROL_ENABLED
;
1878 } else { /* link_down */
1879 DP(NETIF_MSG_LINK
, "phy link down\n");
1881 vars
->phy_link_up
= 0;
1883 vars
->duplex
= DUPLEX_FULL
;
1884 vars
->flow_ctrl
= BNX2X_FLOW_CTRL_NONE
;
1885 vars
->autoneg
= AUTO_NEG_DISABLED
;
1886 vars
->mac_type
= MAC_TYPE_NONE
;
1888 if ((params
->req_line_speed
== SPEED_AUTO_NEG
) &&
1889 ((XGXS_EXT_PHY_TYPE(params
->ext_phy_config
) ==
1890 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT
))) {
1891 /* Check signal is detected */
1892 bnx2x_check_fallback_to_cl37(params
);
1896 DP(NETIF_MSG_LINK
, "gp_status 0x%x phy_link_up %x line_speed %x \n",
1897 gp_status
, vars
->phy_link_up
, vars
->line_speed
);
1898 DP(NETIF_MSG_LINK
, "duplex %x flow_ctrl 0x%x"
1901 vars
->flow_ctrl
, vars
->autoneg
);
1902 DP(NETIF_MSG_LINK
, "link_status 0x%x\n", vars
->link_status
);
1907 static void bnx2x_set_gmii_tx_driver(struct link_params
*params
)
1909 struct bnx2x
*bp
= params
->bp
;
1915 CL45_RD_OVER_CL22(bp
, params
->port
,
1917 MDIO_REG_BANK_OVER_1G
,
1918 MDIO_OVER_1G_LP_UP2
, &lp_up2
);
1920 /* bits [10:7] at lp_up2, positioned at [15:12] */
1921 lp_up2
= (((lp_up2
& MDIO_OVER_1G_LP_UP2_PREEMPHASIS_MASK
) >>
1922 MDIO_OVER_1G_LP_UP2_PREEMPHASIS_SHIFT
) <<
1923 MDIO_TX0_TX_DRIVER_PREEMPHASIS_SHIFT
);
1928 for (bank
= MDIO_REG_BANK_TX0
; bank
<= MDIO_REG_BANK_TX3
;
1929 bank
+= (MDIO_REG_BANK_TX1
- MDIO_REG_BANK_TX0
)) {
1930 CL45_RD_OVER_CL22(bp
, params
->port
,
1933 MDIO_TX0_TX_DRIVER
, &tx_driver
);
1935 /* replace tx_driver bits [15:12] */
1937 (tx_driver
& MDIO_TX0_TX_DRIVER_PREEMPHASIS_MASK
)) {
1938 tx_driver
&= ~MDIO_TX0_TX_DRIVER_PREEMPHASIS_MASK
;
1939 tx_driver
|= lp_up2
;
1940 CL45_WR_OVER_CL22(bp
, params
->port
,
1943 MDIO_TX0_TX_DRIVER
, tx_driver
);
1948 static u8
bnx2x_emac_program(struct link_params
*params
,
1949 u32 line_speed
, u32 duplex
)
1951 struct bnx2x
*bp
= params
->bp
;
1952 u8 port
= params
->port
;
1955 DP(NETIF_MSG_LINK
, "setting link speed & duplex\n");
1956 bnx2x_bits_dis(bp
, GRCBASE_EMAC0
+ port
*0x400 +
1958 (EMAC_MODE_25G_MODE
|
1959 EMAC_MODE_PORT_MII_10M
|
1960 EMAC_MODE_HALF_DUPLEX
));
1961 switch (line_speed
) {
1963 mode
|= EMAC_MODE_PORT_MII_10M
;
1967 mode
|= EMAC_MODE_PORT_MII
;
1971 mode
|= EMAC_MODE_PORT_GMII
;
1975 mode
|= (EMAC_MODE_25G_MODE
| EMAC_MODE_PORT_GMII
);
1979 /* 10G not valid for EMAC */
1980 DP(NETIF_MSG_LINK
, "Invalid line_speed 0x%x\n", line_speed
);
1984 if (duplex
== DUPLEX_HALF
)
1985 mode
|= EMAC_MODE_HALF_DUPLEX
;
1987 GRCBASE_EMAC0
+ port
*0x400 + EMAC_REG_EMAC_MODE
,
1990 bnx2x_set_led(bp
, params
->port
, LED_MODE_OPER
,
1991 line_speed
, params
->hw_led_mode
, params
->chip_id
);
1995 /*****************************************************************************/
1996 /* External Phy section */
1997 /*****************************************************************************/
1998 void bnx2x_ext_phy_hw_reset(struct bnx2x
*bp
, u8 port
)
2000 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_1
,
2001 MISC_REGISTERS_GPIO_OUTPUT_LOW
, port
);
2003 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_1
,
2004 MISC_REGISTERS_GPIO_OUTPUT_HIGH
, port
);
2007 static void bnx2x_ext_phy_reset(struct link_params
*params
,
2008 struct link_vars
*vars
)
2010 struct bnx2x
*bp
= params
->bp
;
2012 u8 ext_phy_addr
= XGXS_EXT_PHY_ADDR(params
->ext_phy_config
);
2014 DP(NETIF_MSG_LINK
, "Port %x: bnx2x_ext_phy_reset\n", params
->port
);
2015 ext_phy_type
= XGXS_EXT_PHY_TYPE(params
->ext_phy_config
);
2016 /* The PHY reset is controled by GPIO 1
2017 * Give it 1ms of reset pulse
2019 if (vars
->phy_flags
& PHY_XGXS_FLAG
) {
2021 switch (ext_phy_type
) {
2022 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT
:
2023 DP(NETIF_MSG_LINK
, "XGXS Direct\n");
2026 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8705
:
2027 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8706
:
2028 DP(NETIF_MSG_LINK
, "XGXS 8705/8706\n");
2030 /* Restore normal power mode*/
2031 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_2
,
2032 MISC_REGISTERS_GPIO_OUTPUT_HIGH
,
2036 bnx2x_ext_phy_hw_reset(bp
, params
->port
);
2038 bnx2x_cl45_write(bp
, params
->port
,
2042 MDIO_PMA_REG_CTRL
, 0xa040);
2045 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727
:
2048 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726
:
2050 /* Restore normal power mode*/
2051 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_2
,
2052 MISC_REGISTERS_GPIO_OUTPUT_HIGH
,
2055 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_1
,
2056 MISC_REGISTERS_GPIO_OUTPUT_HIGH
,
2059 bnx2x_cl45_write(bp
, params
->port
,
2067 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8072
:
2068 DP(NETIF_MSG_LINK
, "XGXS 8072\n");
2070 /* Unset Low Power Mode and SW reset */
2071 /* Restore normal power mode*/
2072 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_2
,
2073 MISC_REGISTERS_GPIO_OUTPUT_HIGH
,
2076 bnx2x_cl45_write(bp
, params
->port
,
2084 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073
:
2085 DP(NETIF_MSG_LINK
, "XGXS 8073\n");
2087 /* Restore normal power mode*/
2088 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_2
,
2089 MISC_REGISTERS_GPIO_OUTPUT_HIGH
,
2092 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_1
,
2093 MISC_REGISTERS_GPIO_OUTPUT_HIGH
,
2097 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_SFX7101
:
2098 DP(NETIF_MSG_LINK
, "XGXS SFX7101\n");
2100 /* Restore normal power mode*/
2101 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_2
,
2102 MISC_REGISTERS_GPIO_OUTPUT_HIGH
,
2106 bnx2x_ext_phy_hw_reset(bp
, params
->port
);
2109 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8481
:
2110 /* Restore normal power mode*/
2111 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_2
,
2112 MISC_REGISTERS_GPIO_OUTPUT_HIGH
,
2116 bnx2x_ext_phy_hw_reset(bp
, params
->port
);
2118 bnx2x_cl45_write(bp
, params
->port
,
2125 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_FAILURE
:
2126 DP(NETIF_MSG_LINK
, "XGXS PHY Failure detected\n");
2130 DP(NETIF_MSG_LINK
, "BAD XGXS ext_phy_config 0x%x\n",
2131 params
->ext_phy_config
);
2135 } else { /* SerDes */
2136 ext_phy_type
= SERDES_EXT_PHY_TYPE(params
->ext_phy_config
);
2137 switch (ext_phy_type
) {
2138 case PORT_HW_CFG_SERDES_EXT_PHY_TYPE_DIRECT
:
2139 DP(NETIF_MSG_LINK
, "SerDes Direct\n");
2142 case PORT_HW_CFG_SERDES_EXT_PHY_TYPE_BCM5482
:
2143 DP(NETIF_MSG_LINK
, "SerDes 5482\n");
2144 bnx2x_ext_phy_hw_reset(bp
, params
->port
);
2148 DP(NETIF_MSG_LINK
, "BAD SerDes ext_phy_config 0x%x\n",
2149 params
->ext_phy_config
);
2155 static void bnx2x_save_spirom_version(struct bnx2x
*bp
, u8 port
,
2156 u32 shmem_base
, u32 spirom_ver
)
2158 DP(NETIF_MSG_LINK
, "FW version 0x%x:0x%x for port %d\n",
2159 (u16
)(spirom_ver
>>16), (u16
)spirom_ver
, port
);
2160 REG_WR(bp
, shmem_base
+
2161 offsetof(struct shmem_region
,
2162 port_mb
[port
].ext_phy_fw_version
),
2166 static void bnx2x_save_bcm_spirom_ver(struct bnx2x
*bp
, u8 port
,
2167 u32 ext_phy_type
, u8 ext_phy_addr
,
2170 u16 fw_ver1
, fw_ver2
;
2172 bnx2x_cl45_read(bp
, port
, ext_phy_type
, ext_phy_addr
, MDIO_PMA_DEVAD
,
2173 MDIO_PMA_REG_ROM_VER1
, &fw_ver1
);
2174 bnx2x_cl45_read(bp
, port
, ext_phy_type
, ext_phy_addr
, MDIO_PMA_DEVAD
,
2175 MDIO_PMA_REG_ROM_VER2
, &fw_ver2
);
2176 bnx2x_save_spirom_version(bp
, port
, shmem_base
,
2177 (u32
)(fw_ver1
<<16 | fw_ver2
));
2181 static void bnx2x_save_8481_spirom_version(struct bnx2x
*bp
, u8 port
,
2182 u8 ext_phy_addr
, u32 shmem_base
)
2184 u16 val
, fw_ver1
, fw_ver2
, cnt
;
2185 /* For the 32 bits registers in 8481, access via MDIO2ARM interface.*/
2186 /* (1) set register 0xc200_0014(SPI_BRIDGE_CTRL_2) to 0x03000000 */
2187 bnx2x_cl45_write(bp
, port
,
2188 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8481
,
2189 ext_phy_addr
, MDIO_PMA_DEVAD
,
2191 bnx2x_cl45_write(bp
, port
,
2192 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8481
,
2197 bnx2x_cl45_write(bp
, port
,
2198 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8481
,
2203 bnx2x_cl45_write(bp
, port
,
2204 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8481
,
2209 bnx2x_cl45_write(bp
, port
,
2210 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8481
,
2216 for (cnt
= 0; cnt
< 100; cnt
++) {
2217 bnx2x_cl45_read(bp
, port
,
2218 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8481
,
2228 DP(NETIF_MSG_LINK
, "Unable to read 8481 phy fw version(1)\n");
2229 bnx2x_save_spirom_version(bp
, port
,
2235 /* 2) read register 0xc200_0000 (SPI_FW_STATUS) */
2236 bnx2x_cl45_write(bp
, port
,
2237 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8481
,
2238 ext_phy_addr
, MDIO_PMA_DEVAD
,
2240 bnx2x_cl45_write(bp
, port
,
2241 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8481
,
2242 ext_phy_addr
, MDIO_PMA_DEVAD
,
2244 bnx2x_cl45_write(bp
, port
,
2245 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8481
,
2246 ext_phy_addr
, MDIO_PMA_DEVAD
,
2248 for (cnt
= 0; cnt
< 100; cnt
++) {
2249 bnx2x_cl45_read(bp
, port
,
2250 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8481
,
2260 DP(NETIF_MSG_LINK
, "Unable to read 8481 phy fw version(2)\n");
2261 bnx2x_save_spirom_version(bp
, port
,
2266 /* lower 16 bits of the register SPI_FW_STATUS */
2267 bnx2x_cl45_read(bp
, port
,
2268 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8481
,
2273 /* upper 16 bits of register SPI_FW_STATUS */
2274 bnx2x_cl45_read(bp
, port
,
2275 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8481
,
2281 bnx2x_save_spirom_version(bp
, port
,
2282 shmem_base
, (fw_ver2
<<16) | fw_ver1
);
2285 static void bnx2x_bcm8072_external_rom_boot(struct link_params
*params
)
2287 struct bnx2x
*bp
= params
->bp
;
2288 u8 port
= params
->port
;
2289 u8 ext_phy_addr
= XGXS_EXT_PHY_ADDR(params
->ext_phy_config
);
2290 u32 ext_phy_type
= XGXS_EXT_PHY_TYPE(params
->ext_phy_config
);
2292 /* Need to wait 200ms after reset */
2294 /* Boot port from external ROM
2295 * Set ser_boot_ctl bit in the MISC_CTRL1 register
2297 bnx2x_cl45_write(bp
, port
, ext_phy_type
, ext_phy_addr
,
2299 MDIO_PMA_REG_MISC_CTRL1
, 0x0001);
2301 /* Reset internal microprocessor */
2302 bnx2x_cl45_write(bp
, port
, ext_phy_type
, ext_phy_addr
,
2304 MDIO_PMA_REG_GEN_CTRL
,
2305 MDIO_PMA_REG_GEN_CTRL_ROM_RESET_INTERNAL_MP
);
2306 /* set micro reset = 0 */
2307 bnx2x_cl45_write(bp
, port
, ext_phy_type
, ext_phy_addr
,
2309 MDIO_PMA_REG_GEN_CTRL
,
2310 MDIO_PMA_REG_GEN_CTRL_ROM_MICRO_RESET
);
2311 /* Reset internal microprocessor */
2312 bnx2x_cl45_write(bp
, port
, ext_phy_type
, ext_phy_addr
,
2314 MDIO_PMA_REG_GEN_CTRL
,
2315 MDIO_PMA_REG_GEN_CTRL_ROM_RESET_INTERNAL_MP
);
2316 /* wait for 100ms for code download via SPI port */
2319 /* Clear ser_boot_ctl bit */
2320 bnx2x_cl45_write(bp
, port
, ext_phy_type
, ext_phy_addr
,
2322 MDIO_PMA_REG_MISC_CTRL1
, 0x0000);
2326 bnx2x_save_bcm_spirom_ver(bp
, port
,
2329 params
->shmem_base
);
2332 static u8
bnx2x_8073_is_snr_needed(struct link_params
*params
)
2334 /* This is only required for 8073A1, version 102 only */
2336 struct bnx2x
*bp
= params
->bp
;
2337 u8 ext_phy_addr
= XGXS_EXT_PHY_ADDR(params
->ext_phy_config
);
2340 /* Read 8073 HW revision*/
2341 bnx2x_cl45_read(bp
, params
->port
,
2342 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073
,
2345 MDIO_PMA_REG_8073_CHIP_REV
, &val
);
2348 /* No need to workaround in 8073 A1 */
2352 bnx2x_cl45_read(bp
, params
->port
,
2353 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073
,
2356 MDIO_PMA_REG_ROM_VER2
, &val
);
2358 /* SNR should be applied only for version 0x102 */
2365 static u8
bnx2x_bcm8073_xaui_wa(struct link_params
*params
)
2367 struct bnx2x
*bp
= params
->bp
;
2368 u8 ext_phy_addr
= XGXS_EXT_PHY_ADDR(params
->ext_phy_config
);
2369 u16 val
, cnt
, cnt1
;
2371 bnx2x_cl45_read(bp
, params
->port
,
2372 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073
,
2375 MDIO_PMA_REG_8073_CHIP_REV
, &val
);
2378 /* No need to workaround in 8073 A1 */
2381 /* XAUI workaround in 8073 A0: */
2383 /* After loading the boot ROM and restarting Autoneg,
2384 poll Dev1, Reg $C820: */
2386 for (cnt
= 0; cnt
< 1000; cnt
++) {
2387 bnx2x_cl45_read(bp
, params
->port
,
2388 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073
,
2391 MDIO_PMA_REG_8073_SPEED_LINK_STATUS
,
2393 /* If bit [14] = 0 or bit [13] = 0, continue on with
2394 system initialization (XAUI work-around not required,
2395 as these bits indicate 2.5G or 1G link up). */
2396 if (!(val
& (1<<14)) || !(val
& (1<<13))) {
2397 DP(NETIF_MSG_LINK
, "XAUI work-around not required\n");
2399 } else if (!(val
& (1<<15))) {
2400 DP(NETIF_MSG_LINK
, "clc bit 15 went off\n");
2401 /* If bit 15 is 0, then poll Dev1, Reg $C841 until
2402 it's MSB (bit 15) goes to 1 (indicating that the
2403 XAUI workaround has completed),
2404 then continue on with system initialization.*/
2405 for (cnt1
= 0; cnt1
< 1000; cnt1
++) {
2406 bnx2x_cl45_read(bp
, params
->port
,
2407 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073
,
2410 MDIO_PMA_REG_8073_XAUI_WA
, &val
);
2411 if (val
& (1<<15)) {
2413 "XAUI workaround has completed\n");
2422 DP(NETIF_MSG_LINK
, "Warning: XAUI work-around timeout !!!\n");
2426 static void bnx2x_bcm8073_bcm8727_external_rom_boot(struct bnx2x
*bp
, u8 port
,
2431 /* Boot port from external ROM */
2433 bnx2x_cl45_write(bp
, port
,
2437 MDIO_PMA_REG_GEN_CTRL
,
2440 /* ucode reboot and rst */
2441 bnx2x_cl45_write(bp
, port
,
2445 MDIO_PMA_REG_GEN_CTRL
,
2448 bnx2x_cl45_write(bp
, port
,
2452 MDIO_PMA_REG_MISC_CTRL1
, 0x0001);
2454 /* Reset internal microprocessor */
2455 bnx2x_cl45_write(bp
, port
,
2459 MDIO_PMA_REG_GEN_CTRL
,
2460 MDIO_PMA_REG_GEN_CTRL_ROM_MICRO_RESET
);
2462 /* Release srst bit */
2463 bnx2x_cl45_write(bp
, port
,
2467 MDIO_PMA_REG_GEN_CTRL
,
2468 MDIO_PMA_REG_GEN_CTRL_ROM_RESET_INTERNAL_MP
);
2470 /* wait for 100ms for code download via SPI port */
2473 /* Clear ser_boot_ctl bit */
2474 bnx2x_cl45_write(bp
, port
,
2478 MDIO_PMA_REG_MISC_CTRL1
, 0x0000);
2480 bnx2x_save_bcm_spirom_ver(bp
, port
,
2486 static void bnx2x_bcm8073_external_rom_boot(struct bnx2x
*bp
, u8 port
,
2490 bnx2x_bcm8073_bcm8727_external_rom_boot(bp
, port
, ext_phy_addr
,
2491 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073
,
2495 static void bnx2x_bcm8727_external_rom_boot(struct bnx2x
*bp
, u8 port
,
2499 bnx2x_bcm8073_bcm8727_external_rom_boot(bp
, port
, ext_phy_addr
,
2500 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727
,
2505 static void bnx2x_bcm8726_external_rom_boot(struct link_params
*params
)
2507 struct bnx2x
*bp
= params
->bp
;
2508 u8 port
= params
->port
;
2509 u8 ext_phy_addr
= XGXS_EXT_PHY_ADDR(params
->ext_phy_config
);
2510 u32 ext_phy_type
= XGXS_EXT_PHY_TYPE(params
->ext_phy_config
);
2512 /* Need to wait 100ms after reset */
2515 /* Set serial boot control for external load */
2516 bnx2x_cl45_write(bp
, port
, ext_phy_type
, ext_phy_addr
,
2518 MDIO_PMA_REG_MISC_CTRL1
, 0x0001);
2520 /* Micro controller re-boot */
2521 bnx2x_cl45_write(bp
, port
, ext_phy_type
, ext_phy_addr
,
2523 MDIO_PMA_REG_GEN_CTRL
,
2524 MDIO_PMA_REG_GEN_CTRL_ROM_RESET_INTERNAL_MP
);
2526 /* Set soft reset */
2527 bnx2x_cl45_write(bp
, port
, ext_phy_type
, ext_phy_addr
,
2529 MDIO_PMA_REG_GEN_CTRL
,
2530 MDIO_PMA_REG_GEN_CTRL_ROM_MICRO_RESET
);
2532 /* Set PLL register value to be same like in P13 ver */
2533 bnx2x_cl45_write(bp
, port
, ext_phy_type
, ext_phy_addr
,
2535 MDIO_PMA_REG_PLL_CTRL
,
2538 /* Clear soft reset.
2539 Will automatically reset micro-controller re-boot */
2540 bnx2x_cl45_write(bp
, port
, ext_phy_type
, ext_phy_addr
,
2542 MDIO_PMA_REG_GEN_CTRL
,
2543 MDIO_PMA_REG_GEN_CTRL_ROM_RESET_INTERNAL_MP
);
2545 /* wait for 150ms for microcode load */
2548 /* Disable serial boot control, tristates pins SS_N, SCK, MOSI, MISO */
2549 bnx2x_cl45_write(bp
, port
, ext_phy_type
, ext_phy_addr
,
2551 MDIO_PMA_REG_MISC_CTRL1
, 0x0000);
2554 bnx2x_save_bcm_spirom_ver(bp
, port
,
2557 params
->shmem_base
);
2560 static void bnx2x_sfp_set_transmitter(struct bnx2x
*bp
, u8 port
,
2561 u32 ext_phy_type
, u8 ext_phy_addr
,
2566 DP(NETIF_MSG_LINK
, "Setting transmitter tx_en=%x for port %x\n",
2568 /* Disable/Enable transmitter ( TX laser of the SFP+ module.)*/
2569 bnx2x_cl45_read(bp
, port
,
2573 MDIO_PMA_REG_PHY_IDENTIFIER
,
2581 bnx2x_cl45_write(bp
, port
,
2585 MDIO_PMA_REG_PHY_IDENTIFIER
,
2589 static u8
bnx2x_8726_read_sfp_module_eeprom(struct link_params
*params
,
2590 u16 addr
, u8 byte_cnt
, u8
*o_buf
)
2592 struct bnx2x
*bp
= params
->bp
;
2595 u8 port
= params
->port
;
2596 u8 ext_phy_addr
= XGXS_EXT_PHY_ADDR(params
->ext_phy_config
);
2597 u32 ext_phy_type
= XGXS_EXT_PHY_TYPE(params
->ext_phy_config
);
2599 if (byte_cnt
> 16) {
2600 DP(NETIF_MSG_LINK
, "Reading from eeprom is"
2601 " is limited to 0xf\n");
2604 /* Set the read command byte count */
2605 bnx2x_cl45_write(bp
, port
,
2609 MDIO_PMA_REG_SFP_TWO_WIRE_BYTE_CNT
,
2610 (byte_cnt
| 0xa000));
2612 /* Set the read command address */
2613 bnx2x_cl45_write(bp
, port
,
2617 MDIO_PMA_REG_SFP_TWO_WIRE_MEM_ADDR
,
2620 /* Activate read command */
2621 bnx2x_cl45_write(bp
, port
,
2625 MDIO_PMA_REG_SFP_TWO_WIRE_CTRL
,
2628 /* Wait up to 500us for command complete status */
2629 for (i
= 0; i
< 100; i
++) {
2630 bnx2x_cl45_read(bp
, port
,
2634 MDIO_PMA_REG_SFP_TWO_WIRE_CTRL
, &val
);
2635 if ((val
& MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK
) ==
2636 MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_COMPLETE
)
2641 if ((val
& MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK
) !=
2642 MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_COMPLETE
) {
2644 "Got bad status 0x%x when reading from SFP+ EEPROM\n",
2645 (val
& MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK
));
2649 /* Read the buffer */
2650 for (i
= 0; i
< byte_cnt
; i
++) {
2651 bnx2x_cl45_read(bp
, port
,
2655 MDIO_PMA_REG_8726_TWO_WIRE_DATA_BUF
+ i
, &val
);
2656 o_buf
[i
] = (u8
)(val
& MDIO_PMA_REG_8726_TWO_WIRE_DATA_MASK
);
2659 for (i
= 0; i
< 100; i
++) {
2660 bnx2x_cl45_read(bp
, port
,
2664 MDIO_PMA_REG_SFP_TWO_WIRE_CTRL
, &val
);
2665 if ((val
& MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK
) ==
2666 MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_IDLE
)
2673 static u8
bnx2x_8727_read_sfp_module_eeprom(struct link_params
*params
,
2674 u16 addr
, u8 byte_cnt
, u8
*o_buf
)
2676 struct bnx2x
*bp
= params
->bp
;
2678 u8 port
= params
->port
;
2679 u8 ext_phy_addr
= XGXS_EXT_PHY_ADDR(params
->ext_phy_config
);
2680 u32 ext_phy_type
= XGXS_EXT_PHY_TYPE(params
->ext_phy_config
);
2682 if (byte_cnt
> 16) {
2683 DP(NETIF_MSG_LINK
, "Reading from eeprom is"
2684 " is limited to 0xf\n");
2688 /* Need to read from 1.8000 to clear it */
2689 bnx2x_cl45_read(bp
, port
,
2690 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727
,
2693 MDIO_PMA_REG_SFP_TWO_WIRE_CTRL
,
2696 /* Set the read command byte count */
2697 bnx2x_cl45_write(bp
, port
,
2701 MDIO_PMA_REG_SFP_TWO_WIRE_BYTE_CNT
,
2702 ((byte_cnt
< 2) ? 2 : byte_cnt
));
2704 /* Set the read command address */
2705 bnx2x_cl45_write(bp
, port
,
2709 MDIO_PMA_REG_SFP_TWO_WIRE_MEM_ADDR
,
2711 /* Set the destination address */
2712 bnx2x_cl45_write(bp
, port
,
2717 MDIO_PMA_REG_8727_TWO_WIRE_DATA_BUF
);
2719 /* Activate read command */
2720 bnx2x_cl45_write(bp
, port
,
2724 MDIO_PMA_REG_SFP_TWO_WIRE_CTRL
,
2726 /* Wait appropriate time for two-wire command to finish before
2727 polling the status register */
2730 /* Wait up to 500us for command complete status */
2731 for (i
= 0; i
< 100; i
++) {
2732 bnx2x_cl45_read(bp
, port
,
2736 MDIO_PMA_REG_SFP_TWO_WIRE_CTRL
, &val
);
2737 if ((val
& MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK
) ==
2738 MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_COMPLETE
)
2743 if ((val
& MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK
) !=
2744 MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_COMPLETE
) {
2746 "Got bad status 0x%x when reading from SFP+ EEPROM\n",
2747 (val
& MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK
));
2751 /* Read the buffer */
2752 for (i
= 0; i
< byte_cnt
; i
++) {
2753 bnx2x_cl45_read(bp
, port
,
2757 MDIO_PMA_REG_8727_TWO_WIRE_DATA_BUF
+ i
, &val
);
2758 o_buf
[i
] = (u8
)(val
& MDIO_PMA_REG_8727_TWO_WIRE_DATA_MASK
);
2761 for (i
= 0; i
< 100; i
++) {
2762 bnx2x_cl45_read(bp
, port
,
2766 MDIO_PMA_REG_SFP_TWO_WIRE_CTRL
, &val
);
2767 if ((val
& MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK
) ==
2768 MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_IDLE
)
2776 u8
bnx2x_read_sfp_module_eeprom(struct link_params
*params
, u16 addr
,
2777 u8 byte_cnt
, u8
*o_buf
)
2779 u32 ext_phy_type
= XGXS_EXT_PHY_TYPE(params
->ext_phy_config
);
2781 if (ext_phy_type
== PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726
)
2782 return bnx2x_8726_read_sfp_module_eeprom(params
, addr
,
2784 else if (ext_phy_type
== PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727
)
2785 return bnx2x_8727_read_sfp_module_eeprom(params
, addr
,
2790 static u8
bnx2x_get_edc_mode(struct link_params
*params
,
2793 struct bnx2x
*bp
= params
->bp
;
2794 u8 val
, check_limiting_mode
= 0;
2795 *edc_mode
= EDC_MODE_LIMITING
;
2797 /* First check for copper cable */
2798 if (bnx2x_read_sfp_module_eeprom(params
,
2799 SFP_EEPROM_CON_TYPE_ADDR
,
2802 DP(NETIF_MSG_LINK
, "Failed to read from SFP+ module EEPROM\n");
2807 case SFP_EEPROM_CON_TYPE_VAL_COPPER
:
2809 u8 copper_module_type
;
2811 /* Check if its active cable( includes SFP+ module)
2813 if (bnx2x_read_sfp_module_eeprom(params
,
2814 SFP_EEPROM_FC_TX_TECH_ADDR
,
2816 &copper_module_type
) !=
2819 "Failed to read copper-cable-type"
2820 " from SFP+ EEPROM\n");
2824 if (copper_module_type
&
2825 SFP_EEPROM_FC_TX_TECH_BITMASK_COPPER_ACTIVE
) {
2826 DP(NETIF_MSG_LINK
, "Active Copper cable detected\n");
2827 check_limiting_mode
= 1;
2828 } else if (copper_module_type
&
2829 SFP_EEPROM_FC_TX_TECH_BITMASK_COPPER_PASSIVE
) {
2830 DP(NETIF_MSG_LINK
, "Passive Copper"
2831 " cable detected\n");
2833 EDC_MODE_PASSIVE_DAC
;
2835 DP(NETIF_MSG_LINK
, "Unknown copper-cable-"
2836 "type 0x%x !!!\n", copper_module_type
);
2841 case SFP_EEPROM_CON_TYPE_VAL_LC
:
2842 DP(NETIF_MSG_LINK
, "Optic module detected\n");
2843 check_limiting_mode
= 1;
2846 DP(NETIF_MSG_LINK
, "Unable to determine module type 0x%x !!!\n",
2851 if (check_limiting_mode
) {
2852 u8 options
[SFP_EEPROM_OPTIONS_SIZE
];
2853 if (bnx2x_read_sfp_module_eeprom(params
,
2854 SFP_EEPROM_OPTIONS_ADDR
,
2855 SFP_EEPROM_OPTIONS_SIZE
,
2857 DP(NETIF_MSG_LINK
, "Failed to read Option"
2858 " field from module EEPROM\n");
2861 if ((options
[0] & SFP_EEPROM_OPTIONS_LINEAR_RX_OUT_MASK
))
2862 *edc_mode
= EDC_MODE_LINEAR
;
2864 *edc_mode
= EDC_MODE_LIMITING
;
2866 DP(NETIF_MSG_LINK
, "EDC mode is set to 0x%x\n", *edc_mode
);
2870 /* This function read the relevant field from the module ( SFP+ ),
2871 and verify it is compliant with this board */
2872 static u8
bnx2x_verify_sfp_module(struct link_params
*params
)
2874 struct bnx2x
*bp
= params
->bp
;
2877 char vendor_name
[SFP_EEPROM_VENDOR_NAME_SIZE
+1];
2878 char vendor_pn
[SFP_EEPROM_PART_NO_SIZE
+1];
2880 val
= REG_RD(bp
, params
->shmem_base
+
2881 offsetof(struct shmem_region
, dev_info
.
2882 port_feature_config
[params
->port
].config
));
2883 if ((val
& PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK
) ==
2884 PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_NO_ENFORCEMENT
) {
2885 DP(NETIF_MSG_LINK
, "NOT enforcing module verification\n");
2889 /* Ask the FW to validate the module */
2890 if (!(params
->feature_config_flags
&
2891 FEATURE_CONFIG_BC_SUPPORTS_OPT_MDL_VRFY
)) {
2892 DP(NETIF_MSG_LINK
, "FW does not support OPT MDL "
2897 fw_resp
= bnx2x_fw_command(bp
, DRV_MSG_CODE_VRFY_OPT_MDL
);
2898 if (fw_resp
== FW_MSG_CODE_VRFY_OPT_MDL_SUCCESS
) {
2899 DP(NETIF_MSG_LINK
, "Approved module\n");
2903 /* format the warning message */
2904 if (bnx2x_read_sfp_module_eeprom(params
,
2905 SFP_EEPROM_VENDOR_NAME_ADDR
,
2906 SFP_EEPROM_VENDOR_NAME_SIZE
,
2908 vendor_name
[0] = '\0';
2910 vendor_name
[SFP_EEPROM_VENDOR_NAME_SIZE
] = '\0';
2911 if (bnx2x_read_sfp_module_eeprom(params
,
2912 SFP_EEPROM_PART_NO_ADDR
,
2913 SFP_EEPROM_PART_NO_SIZE
,
2915 vendor_pn
[0] = '\0';
2917 vendor_pn
[SFP_EEPROM_PART_NO_SIZE
] = '\0';
2919 printk(KERN_INFO PFX
"Warning: "
2920 "Unqualified SFP+ module "
2921 "detected on %s, Port %d from %s part number %s\n"
2922 , bp
->dev
->name
, params
->port
,
2923 vendor_name
, vendor_pn
);
2927 static u8
bnx2x_bcm8726_set_limiting_mode(struct link_params
*params
,
2930 struct bnx2x
*bp
= params
->bp
;
2931 u8 port
= params
->port
;
2932 u8 ext_phy_addr
= XGXS_EXT_PHY_ADDR(params
->ext_phy_config
);
2933 u16 cur_limiting_mode
;
2935 bnx2x_cl45_read(bp
, port
,
2936 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726
,
2939 MDIO_PMA_REG_ROM_VER2
,
2940 &cur_limiting_mode
);
2941 DP(NETIF_MSG_LINK
, "Current Limiting mode is 0x%x\n",
2944 if (edc_mode
== EDC_MODE_LIMITING
) {
2946 "Setting LIMITING MODE\n");
2947 bnx2x_cl45_write(bp
, port
,
2948 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726
,
2951 MDIO_PMA_REG_ROM_VER2
,
2953 } else { /* LRM mode ( default )*/
2955 DP(NETIF_MSG_LINK
, "Setting LRM MODE\n");
2957 /* Changing to LRM mode takes quite few seconds.
2958 So do it only if current mode is limiting
2959 ( default is LRM )*/
2960 if (cur_limiting_mode
!= EDC_MODE_LIMITING
)
2963 bnx2x_cl45_write(bp
, port
,
2964 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726
,
2967 MDIO_PMA_REG_LRM_MODE
,
2969 bnx2x_cl45_write(bp
, port
,
2970 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726
,
2973 MDIO_PMA_REG_ROM_VER2
,
2975 bnx2x_cl45_write(bp
, port
,
2976 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726
,
2979 MDIO_PMA_REG_MISC_CTRL0
,
2981 bnx2x_cl45_write(bp
, port
,
2982 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726
,
2985 MDIO_PMA_REG_LRM_MODE
,
2991 static u8
bnx2x_bcm8727_set_limiting_mode(struct link_params
*params
,
2994 struct bnx2x
*bp
= params
->bp
;
2995 u8 port
= params
->port
;
2998 u8 ext_phy_addr
= XGXS_EXT_PHY_ADDR(params
->ext_phy_config
);
3000 bnx2x_cl45_read(bp
, port
,
3001 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727
,
3004 MDIO_PMA_REG_PHY_IDENTIFIER
,
3007 bnx2x_cl45_write(bp
, port
,
3008 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727
,
3011 MDIO_PMA_REG_PHY_IDENTIFIER
,
3012 (phy_identifier
& ~(1<<9)));
3014 bnx2x_cl45_read(bp
, port
,
3015 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727
,
3018 MDIO_PMA_REG_ROM_VER2
,
3020 /* Keep the MSB 8-bits, and set the LSB 8-bits with the edc_mode */
3021 bnx2x_cl45_write(bp
, port
,
3022 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727
,
3025 MDIO_PMA_REG_ROM_VER2
,
3026 (rom_ver2_val
& 0xff00) | (edc_mode
& 0x00ff));
3028 bnx2x_cl45_write(bp
, port
,
3029 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727
,
3032 MDIO_PMA_REG_PHY_IDENTIFIER
,
3033 (phy_identifier
| (1<<9)));
3039 static u8
bnx2x_wait_for_sfp_module_initialized(struct link_params
*params
)
3042 struct bnx2x
*bp
= params
->bp
;
3044 /* Initialization time after hot-plug may take up to 300ms for some
3045 phys type ( e.g. JDSU ) */
3046 for (timeout
= 0; timeout
< 60; timeout
++) {
3047 if (bnx2x_read_sfp_module_eeprom(params
, 1, 1, &val
)
3049 DP(NETIF_MSG_LINK
, "SFP+ module initialization "
3050 "took %d ms\n", timeout
* 5);
3058 static void bnx2x_8727_power_module(struct bnx2x
*bp
,
3059 struct link_params
*params
,
3060 u8 ext_phy_addr
, u8 is_power_up
) {
3061 /* Make sure GPIOs are not using for LED mode */
3063 u8 port
= params
->port
;
3065 * In the GPIO register, bit 4 is use to detemine if the GPIOs are
3066 * operating as INPUT or as OUTPUT. Bit 1 is for input, and 0 for
3068 * Bits 0-1 determine the gpios value for OUTPUT in case bit 4 val is 0
3069 * Bits 8-9 determine the gpios value for INPUT in case bit 4 val is 1
3070 * where the 1st bit is the over-current(only input), and 2nd bit is
3071 * for power( only output )
3075 * In case of NOC feature is disabled and power is up, set GPIO control
3076 * as input to enable listening of over-current indication
3079 if (!(params
->feature_config_flags
&
3080 FEATURE_CONFIG_BCM8727_NOC
) && is_power_up
)
3084 * Set GPIO control to OUTPUT, and set the power bit
3085 * to according to the is_power_up
3087 val
= ((!(is_power_up
)) << 1);
3089 bnx2x_cl45_write(bp
, port
,
3090 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727
,
3093 MDIO_PMA_REG_8727_GPIO_CTRL
,
3097 static u8
bnx2x_sfp_module_detection(struct link_params
*params
)
3099 struct bnx2x
*bp
= params
->bp
;
3102 u8 ext_phy_addr
= XGXS_EXT_PHY_ADDR(params
->ext_phy_config
);
3103 u32 ext_phy_type
= XGXS_EXT_PHY_TYPE(params
->ext_phy_config
);
3104 u32 val
= REG_RD(bp
, params
->shmem_base
+
3105 offsetof(struct shmem_region
, dev_info
.
3106 port_feature_config
[params
->port
].config
));
3108 DP(NETIF_MSG_LINK
, "SFP+ module plugged in/out detected on port %d\n",
3111 if (bnx2x_get_edc_mode(params
, &edc_mode
) != 0) {
3112 DP(NETIF_MSG_LINK
, "Failed to get valid module type\n");
3114 } else if (bnx2x_verify_sfp_module(params
) !=
3116 /* check SFP+ module compatibility */
3117 DP(NETIF_MSG_LINK
, "Module verification failed!!\n");
3119 /* Turn on fault module-detected led */
3120 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_0
,
3121 MISC_REGISTERS_GPIO_HIGH
,
3123 if ((ext_phy_type
== PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727
) &&
3124 ((val
& PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK
) ==
3125 PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_POWER_DOWN
)) {
3126 /* Shutdown SFP+ module */
3127 DP(NETIF_MSG_LINK
, "Shutdown SFP+ module!!\n");
3128 bnx2x_8727_power_module(bp
, params
,
3133 /* Turn off fault module-detected led */
3134 DP(NETIF_MSG_LINK
, "Turn off fault module-detected led\n");
3135 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_0
,
3136 MISC_REGISTERS_GPIO_LOW
,
3140 /* power up the SFP module */
3141 if (ext_phy_type
== PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727
)
3142 bnx2x_8727_power_module(bp
, params
, ext_phy_addr
, 1);
3144 /* Check and set limiting mode / LRM mode on 8726.
3145 On 8727 it is done automatically */
3146 if (ext_phy_type
== PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726
)
3147 bnx2x_bcm8726_set_limiting_mode(params
, edc_mode
);
3149 bnx2x_bcm8727_set_limiting_mode(params
, edc_mode
);
3151 * Enable transmit for this module if the module is approved, or
3152 * if unapproved modules should also enable the Tx laser
3155 (val
& PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK
) !=
3156 PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_DISABLE_TX_LASER
)
3157 bnx2x_sfp_set_transmitter(bp
, params
->port
,
3158 ext_phy_type
, ext_phy_addr
, 1);
3160 bnx2x_sfp_set_transmitter(bp
, params
->port
,
3161 ext_phy_type
, ext_phy_addr
, 0);
3166 void bnx2x_handle_module_detect_int(struct link_params
*params
)
3168 struct bnx2x
*bp
= params
->bp
;
3170 u8 port
= params
->port
;
3172 /* Set valid module led off */
3173 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_0
,
3174 MISC_REGISTERS_GPIO_HIGH
,
3177 /* Get current gpio val refelecting module plugged in / out*/
3178 gpio_val
= bnx2x_get_gpio(bp
, MISC_REGISTERS_GPIO_3
, port
);
3180 /* Call the handling function in case module is detected */
3181 if (gpio_val
== 0) {
3183 bnx2x_set_gpio_int(bp
, MISC_REGISTERS_GPIO_3
,
3184 MISC_REGISTERS_GPIO_INT_OUTPUT_CLR
,
3187 if (bnx2x_wait_for_sfp_module_initialized(params
) ==
3189 bnx2x_sfp_module_detection(params
);
3191 DP(NETIF_MSG_LINK
, "SFP+ module is not initialized\n");
3193 u8 ext_phy_addr
= XGXS_EXT_PHY_ADDR(params
->ext_phy_config
);
3196 XGXS_EXT_PHY_TYPE(params
->ext_phy_config
);
3197 u32 val
= REG_RD(bp
, params
->shmem_base
+
3198 offsetof(struct shmem_region
, dev_info
.
3199 port_feature_config
[params
->port
].
3202 bnx2x_set_gpio_int(bp
, MISC_REGISTERS_GPIO_3
,
3203 MISC_REGISTERS_GPIO_INT_OUTPUT_SET
,
3205 /* Module was plugged out. */
3206 /* Disable transmit for this module */
3207 if ((val
& PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK
) ==
3208 PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_DISABLE_TX_LASER
)
3209 bnx2x_sfp_set_transmitter(bp
, params
->port
,
3210 ext_phy_type
, ext_phy_addr
, 0);
3214 static void bnx2x_bcm807x_force_10G(struct link_params
*params
)
3216 struct bnx2x
*bp
= params
->bp
;
3217 u8 port
= params
->port
;
3218 u8 ext_phy_addr
= XGXS_EXT_PHY_ADDR(params
->ext_phy_config
);
3219 u32 ext_phy_type
= XGXS_EXT_PHY_TYPE(params
->ext_phy_config
);
3221 /* Force KR or KX */
3222 bnx2x_cl45_write(bp
, port
, ext_phy_type
, ext_phy_addr
,
3226 bnx2x_cl45_write(bp
, port
, ext_phy_type
, ext_phy_addr
,
3228 MDIO_PMA_REG_10G_CTRL2
,
3230 bnx2x_cl45_write(bp
, port
, ext_phy_type
, ext_phy_addr
,
3232 MDIO_PMA_REG_BCM_CTRL
,
3234 bnx2x_cl45_write(bp
, port
, ext_phy_type
, ext_phy_addr
,
3240 static void bnx2x_bcm8073_set_xaui_low_power_mode(struct link_params
*params
)
3242 struct bnx2x
*bp
= params
->bp
;
3243 u8 port
= params
->port
;
3245 u8 ext_phy_addr
= XGXS_EXT_PHY_ADDR(params
->ext_phy_config
);
3246 u32 ext_phy_type
= XGXS_EXT_PHY_TYPE(params
->ext_phy_config
);
3248 bnx2x_cl45_read(bp
, params
->port
,
3249 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073
,
3252 MDIO_PMA_REG_8073_CHIP_REV
, &val
);
3255 /* Mustn't set low power mode in 8073 A0 */
3259 /* Disable PLL sequencer (use read-modify-write to clear bit 13) */
3260 bnx2x_cl45_read(bp
, port
, ext_phy_type
, ext_phy_addr
,
3262 MDIO_XS_PLL_SEQUENCER
, &val
);
3264 bnx2x_cl45_write(bp
, port
, ext_phy_type
, ext_phy_addr
,
3265 MDIO_XS_DEVAD
, MDIO_XS_PLL_SEQUENCER
, val
);
3268 bnx2x_cl45_write(bp
, port
, ext_phy_type
, ext_phy_addr
,
3269 MDIO_XS_DEVAD
, 0x805E, 0x1077);
3270 bnx2x_cl45_write(bp
, port
, ext_phy_type
, ext_phy_addr
,
3271 MDIO_XS_DEVAD
, 0x805D, 0x0000);
3272 bnx2x_cl45_write(bp
, port
, ext_phy_type
, ext_phy_addr
,
3273 MDIO_XS_DEVAD
, 0x805C, 0x030B);
3274 bnx2x_cl45_write(bp
, port
, ext_phy_type
, ext_phy_addr
,
3275 MDIO_XS_DEVAD
, 0x805B, 0x1240);
3276 bnx2x_cl45_write(bp
, port
, ext_phy_type
, ext_phy_addr
,
3277 MDIO_XS_DEVAD
, 0x805A, 0x2490);
3280 bnx2x_cl45_write(bp
, port
, ext_phy_type
, ext_phy_addr
,
3281 MDIO_XS_DEVAD
, 0x80A7, 0x0C74);
3282 bnx2x_cl45_write(bp
, port
, ext_phy_type
, ext_phy_addr
,
3283 MDIO_XS_DEVAD
, 0x80A6, 0x9041);
3284 bnx2x_cl45_write(bp
, port
, ext_phy_type
, ext_phy_addr
,
3285 MDIO_XS_DEVAD
, 0x80A5, 0x4640);
3288 bnx2x_cl45_write(bp
, port
, ext_phy_type
, ext_phy_addr
,
3289 MDIO_XS_DEVAD
, 0x80FE, 0x01C4);
3290 bnx2x_cl45_write(bp
, port
, ext_phy_type
, ext_phy_addr
,
3291 MDIO_XS_DEVAD
, 0x80FD, 0x9249);
3292 bnx2x_cl45_write(bp
, port
, ext_phy_type
, ext_phy_addr
,
3293 MDIO_XS_DEVAD
, 0x80FC, 0x2015);
3295 /* Enable PLL sequencer (use read-modify-write to set bit 13) */
3296 bnx2x_cl45_read(bp
, port
, ext_phy_type
, ext_phy_addr
,
3298 MDIO_XS_PLL_SEQUENCER
, &val
);
3300 bnx2x_cl45_write(bp
, port
, ext_phy_type
, ext_phy_addr
,
3301 MDIO_XS_DEVAD
, MDIO_XS_PLL_SEQUENCER
, val
);
3304 static void bnx2x_8073_set_pause_cl37(struct link_params
*params
,
3305 struct link_vars
*vars
)
3307 struct bnx2x
*bp
= params
->bp
;
3309 u8 ext_phy_addr
= XGXS_EXT_PHY_ADDR(params
->ext_phy_config
);
3310 u32 ext_phy_type
= XGXS_EXT_PHY_TYPE(params
->ext_phy_config
);
3312 bnx2x_cl45_read(bp
, params
->port
,
3316 MDIO_AN_REG_CL37_FC_LD
, &cl37_val
);
3318 cl37_val
&= ~MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH
;
3319 /* Please refer to Table 28B-3 of 802.3ab-1999 spec. */
3321 if ((vars
->ieee_fc
&
3322 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_SYMMETRIC
) ==
3323 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_SYMMETRIC
) {
3324 cl37_val
|= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_SYMMETRIC
;
3326 if ((vars
->ieee_fc
&
3327 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC
) ==
3328 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC
) {
3329 cl37_val
|= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC
;
3331 if ((vars
->ieee_fc
&
3332 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH
) ==
3333 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH
) {
3334 cl37_val
|= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH
;
3337 "Ext phy AN advertize cl37 0x%x\n", cl37_val
);
3339 bnx2x_cl45_write(bp
, params
->port
,
3343 MDIO_AN_REG_CL37_FC_LD
, cl37_val
);
3347 static void bnx2x_ext_phy_set_pause(struct link_params
*params
,
3348 struct link_vars
*vars
)
3350 struct bnx2x
*bp
= params
->bp
;
3352 u8 ext_phy_addr
= XGXS_EXT_PHY_ADDR(params
->ext_phy_config
);
3353 u32 ext_phy_type
= XGXS_EXT_PHY_TYPE(params
->ext_phy_config
);
3355 /* read modify write pause advertizing */
3356 bnx2x_cl45_read(bp
, params
->port
,
3360 MDIO_AN_REG_ADV_PAUSE
, &val
);
3362 val
&= ~MDIO_AN_REG_ADV_PAUSE_BOTH
;
3364 /* Please refer to Table 28B-3 of 802.3ab-1999 spec. */
3366 if ((vars
->ieee_fc
&
3367 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC
) ==
3368 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC
) {
3369 val
|= MDIO_AN_REG_ADV_PAUSE_ASYMMETRIC
;
3371 if ((vars
->ieee_fc
&
3372 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH
) ==
3373 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH
) {
3375 MDIO_AN_REG_ADV_PAUSE_PAUSE
;
3378 "Ext phy AN advertize 0x%x\n", val
);
3379 bnx2x_cl45_write(bp
, params
->port
,
3383 MDIO_AN_REG_ADV_PAUSE
, val
);
3385 static void bnx2x_set_preemphasis(struct link_params
*params
)
3388 struct bnx2x
*bp
= params
->bp
;
3390 for (bank
= MDIO_REG_BANK_RX0
, i
= 0; bank
<= MDIO_REG_BANK_RX3
;
3391 bank
+= (MDIO_REG_BANK_RX1
-MDIO_REG_BANK_RX0
), i
++) {
3392 CL45_WR_OVER_CL22(bp
, params
->port
,
3395 MDIO_RX0_RX_EQ_BOOST
,
3396 params
->xgxs_config_rx
[i
]);
3399 for (bank
= MDIO_REG_BANK_TX0
, i
= 0; bank
<= MDIO_REG_BANK_TX3
;
3400 bank
+= (MDIO_REG_BANK_TX1
- MDIO_REG_BANK_TX0
), i
++) {
3401 CL45_WR_OVER_CL22(bp
, params
->port
,
3405 params
->xgxs_config_tx
[i
]);
3410 static void bnx2x_8481_set_led4(struct link_params
*params
,
3411 u32 ext_phy_type
, u8 ext_phy_addr
)
3413 struct bnx2x
*bp
= params
->bp
;
3415 /* PHYC_CTL_LED_CTL */
3416 bnx2x_cl45_write(bp
, params
->port
,
3420 MDIO_PMA_REG_8481_LINK_SIGNAL
, 0xa482);
3422 /* Unmask LED4 for 10G link */
3423 bnx2x_cl45_write(bp
, params
->port
,
3427 MDIO_PMA_REG_8481_SIGNAL_MASK
, (1<<6));
3428 /* 'Interrupt Mask' */
3429 bnx2x_cl45_write(bp
, params
->port
,
3435 static void bnx2x_8481_set_legacy_led_mode(struct link_params
*params
,
3436 u32 ext_phy_type
, u8 ext_phy_addr
)
3438 struct bnx2x
*bp
= params
->bp
;
3440 /* LED1 (10G Link): Disable LED1 when 10/100/1000 link */
3441 /* LED2 (1G/100/10 Link): Enable LED2 when 10/100/1000 link) */
3442 bnx2x_cl45_write(bp
, params
->port
,
3446 MDIO_AN_REG_8481_LEGACY_SHADOW
,
3447 (1<<15) | (0xd << 10) | (0xc<<4) | 0xe);
3450 static void bnx2x_8481_set_10G_led_mode(struct link_params
*params
,
3451 u32 ext_phy_type
, u8 ext_phy_addr
)
3453 struct bnx2x
*bp
= params
->bp
;
3456 /* LED1 (10G Link) */
3457 /* Enable continuse based on source 7(10G-link) */
3458 bnx2x_cl45_read(bp
, params
->port
,
3462 MDIO_PMA_REG_8481_LINK_SIGNAL
,
3464 /* Set bit 2 to 0, and bits [1:0] to 10 */
3465 val1
&= ~((1<<0) | (1<<2)); /* Clear bits 0,2*/
3466 val1
|= (1<<1); /* Set bit 1 */
3468 bnx2x_cl45_write(bp
, params
->port
,
3472 MDIO_PMA_REG_8481_LINK_SIGNAL
,
3475 /* Unmask LED1 for 10G link */
3476 bnx2x_cl45_read(bp
, params
->port
,
3480 MDIO_PMA_REG_8481_LED1_MASK
,
3482 /* Set bit 2 to 0, and bits [1:0] to 10 */
3484 bnx2x_cl45_write(bp
, params
->port
,
3488 MDIO_PMA_REG_8481_LED1_MASK
,
3491 /* LED2 (1G/100/10G Link) */
3492 /* Mask LED2 for 10G link */
3493 bnx2x_cl45_write(bp
, params
->port
,
3497 MDIO_PMA_REG_8481_LED2_MASK
,
3500 /* LED3 (10G/1G/100/10G Activity) */
3501 bnx2x_cl45_read(bp
, params
->port
,
3505 MDIO_PMA_REG_8481_LINK_SIGNAL
,
3507 /* Enable blink based on source 4(Activity) */
3508 val1
&= ~((1<<7) | (1<<8)); /* Clear bits 7,8 */
3509 val1
|= (1<<6); /* Set only bit 6 */
3510 bnx2x_cl45_write(bp
, params
->port
,
3514 MDIO_PMA_REG_8481_LINK_SIGNAL
,
3517 bnx2x_cl45_read(bp
, params
->port
,
3521 MDIO_PMA_REG_8481_LED3_MASK
,
3523 val1
|= (1<<4); /* Unmask LED3 for 10G link */
3524 bnx2x_cl45_write(bp
, params
->port
,
3528 MDIO_PMA_REG_8481_LED3_MASK
,
3533 static void bnx2x_init_internal_phy(struct link_params
*params
,
3534 struct link_vars
*vars
,
3537 struct bnx2x
*bp
= params
->bp
;
3539 if (!(vars
->phy_flags
& PHY_SGMII_FLAG
)) {
3540 if ((XGXS_EXT_PHY_TYPE(params
->ext_phy_config
) ==
3541 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT
) &&
3542 (params
->feature_config_flags
&
3543 FEATURE_CONFIG_OVERRIDE_PREEMPHASIS_ENABLED
))
3544 bnx2x_set_preemphasis(params
);
3546 /* forced speed requested? */
3547 if (vars
->line_speed
!= SPEED_AUTO_NEG
) {
3548 DP(NETIF_MSG_LINK
, "not SGMII, no AN\n");
3550 /* disable autoneg */
3551 bnx2x_set_autoneg(params
, vars
, 0);
3553 /* program speed and duplex */
3554 bnx2x_program_serdes(params
, vars
);
3556 } else { /* AN_mode */
3557 DP(NETIF_MSG_LINK
, "not SGMII, AN\n");
3560 bnx2x_set_brcm_cl37_advertisment(params
);
3562 /* program duplex & pause advertisement (for aneg) */
3563 bnx2x_set_ieee_aneg_advertisment(params
,
3566 /* enable autoneg */
3567 bnx2x_set_autoneg(params
, vars
, enable_cl73
);
3569 /* enable and restart AN */
3570 bnx2x_restart_autoneg(params
, enable_cl73
);
3573 } else { /* SGMII mode */
3574 DP(NETIF_MSG_LINK
, "SGMII\n");
3576 bnx2x_initialize_sgmii_process(params
, vars
);
3580 static u8
bnx2x_ext_phy_init(struct link_params
*params
, struct link_vars
*vars
)
3582 struct bnx2x
*bp
= params
->bp
;
3590 if (vars
->phy_flags
& PHY_XGXS_FLAG
) {
3591 ext_phy_addr
= XGXS_EXT_PHY_ADDR(params
->ext_phy_config
);
3593 ext_phy_type
= XGXS_EXT_PHY_TYPE(params
->ext_phy_config
);
3594 /* Make sure that the soft reset is off (expect for the 8072:
3595 * due to the lock, it will be done inside the specific
3598 if ((ext_phy_type
!= PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT
) &&
3599 (ext_phy_type
!= PORT_HW_CFG_XGXS_EXT_PHY_TYPE_FAILURE
) &&
3600 (ext_phy_type
!= PORT_HW_CFG_XGXS_EXT_PHY_TYPE_NOT_CONN
) &&
3601 (ext_phy_type
!= PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8072
) &&
3602 (ext_phy_type
!= PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073
)) {
3603 /* Wait for soft reset to get cleared upto 1 sec */
3604 for (cnt
= 0; cnt
< 1000; cnt
++) {
3605 bnx2x_cl45_read(bp
, params
->port
,
3609 MDIO_PMA_REG_CTRL
, &ctrl
);
3610 if (!(ctrl
& (1<<15)))
3614 DP(NETIF_MSG_LINK
, "control reg 0x%x (after %d ms)\n",
3618 switch (ext_phy_type
) {
3619 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT
:
3622 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8705
:
3623 DP(NETIF_MSG_LINK
, "XGXS 8705\n");
3625 bnx2x_cl45_write(bp
, params
->port
,
3629 MDIO_PMA_REG_MISC_CTRL
,
3631 bnx2x_cl45_write(bp
, params
->port
,
3635 MDIO_PMA_REG_PHY_IDENTIFIER
,
3637 bnx2x_cl45_write(bp
, params
->port
,
3641 MDIO_PMA_REG_CMU_PLL_BYPASS
,
3643 bnx2x_cl45_write(bp
, params
->port
,
3647 MDIO_WIS_REG_LASI_CNTL
, 0x1);
3649 /* BCM8705 doesn't have microcode, hence the 0 */
3650 bnx2x_save_spirom_version(bp
, params
->port
,
3651 params
->shmem_base
, 0);
3654 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8706
:
3655 /* Wait until fw is loaded */
3656 for (cnt
= 0; cnt
< 100; cnt
++) {
3657 bnx2x_cl45_read(bp
, params
->port
, ext_phy_type
,
3658 ext_phy_addr
, MDIO_PMA_DEVAD
,
3659 MDIO_PMA_REG_ROM_VER1
, &val
);
3664 DP(NETIF_MSG_LINK
, "XGXS 8706 is initialized "
3665 "after %d ms\n", cnt
);
3666 if ((params
->feature_config_flags
&
3667 FEATURE_CONFIG_OVERRIDE_PREEMPHASIS_ENABLED
)) {
3670 for (i
= 0; i
< 4; i
++) {
3671 reg
= MDIO_XS_8706_REG_BANK_RX0
+
3672 i
*(MDIO_XS_8706_REG_BANK_RX1
-
3673 MDIO_XS_8706_REG_BANK_RX0
);
3674 bnx2x_cl45_read(bp
, params
->port
,
3679 /* Clear first 3 bits of the control */
3681 /* Set control bits according to
3683 val
|= (params
->xgxs_config_rx
[i
] &
3685 DP(NETIF_MSG_LINK
, "Setting RX"
3686 "Equalizer to BCM8706 reg 0x%x"
3687 " <-- val 0x%x\n", reg
, val
);
3688 bnx2x_cl45_write(bp
, params
->port
,
3696 /* First enable LASI */
3697 bnx2x_cl45_write(bp
, params
->port
,
3701 MDIO_PMA_REG_RX_ALARM_CTRL
,
3703 bnx2x_cl45_write(bp
, params
->port
,
3707 MDIO_PMA_REG_LASI_CTRL
, 0x0004);
3709 if (params
->req_line_speed
== SPEED_10000
) {
3710 DP(NETIF_MSG_LINK
, "XGXS 8706 force 10Gbps\n");
3712 bnx2x_cl45_write(bp
, params
->port
,
3716 MDIO_PMA_REG_DIGITAL_CTRL
,
3719 /* Force 1Gbps using autoneg with 1G
3722 /* Allow CL37 through CL73 */
3723 DP(NETIF_MSG_LINK
, "XGXS 8706 AutoNeg\n");
3724 bnx2x_cl45_write(bp
, params
->port
,
3728 MDIO_AN_REG_CL37_CL73
,
3731 /* Enable Full-Duplex advertisment on CL37 */
3732 bnx2x_cl45_write(bp
, params
->port
,
3736 MDIO_AN_REG_CL37_FC_LP
,
3738 /* Enable CL37 AN */
3739 bnx2x_cl45_write(bp
, params
->port
,
3743 MDIO_AN_REG_CL37_AN
,
3746 bnx2x_cl45_write(bp
, params
->port
,
3750 MDIO_AN_REG_ADV
, (1<<5));
3752 /* Enable clause 73 AN */
3753 bnx2x_cl45_write(bp
, params
->port
,
3761 bnx2x_save_bcm_spirom_ver(bp
, params
->port
,
3764 params
->shmem_base
);
3766 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726
:
3767 DP(NETIF_MSG_LINK
, "Initializing BCM8726\n");
3768 bnx2x_bcm8726_external_rom_boot(params
);
3770 /* Need to call module detected on initialization since
3771 the module detection triggered by actual module
3772 insertion might occur before driver is loaded, and when
3773 driver is loaded, it reset all registers, including the
3775 bnx2x_sfp_module_detection(params
);
3777 /* Set Flow control */
3778 bnx2x_ext_phy_set_pause(params
, vars
);
3779 if (params
->req_line_speed
== SPEED_1000
) {
3780 DP(NETIF_MSG_LINK
, "Setting 1G force\n");
3781 bnx2x_cl45_write(bp
, params
->port
, ext_phy_type
,
3782 ext_phy_addr
, MDIO_PMA_DEVAD
,
3783 MDIO_PMA_REG_CTRL
, 0x40);
3784 bnx2x_cl45_write(bp
, params
->port
, ext_phy_type
,
3785 ext_phy_addr
, MDIO_PMA_DEVAD
,
3786 MDIO_PMA_REG_10G_CTRL2
, 0xD);
3787 bnx2x_cl45_write(bp
, params
->port
, ext_phy_type
,
3788 ext_phy_addr
, MDIO_PMA_DEVAD
,
3789 MDIO_PMA_REG_LASI_CTRL
, 0x5);
3790 bnx2x_cl45_write(bp
, params
->port
, ext_phy_type
,
3791 ext_phy_addr
, MDIO_PMA_DEVAD
,
3792 MDIO_PMA_REG_RX_ALARM_CTRL
,
3794 } else if ((params
->req_line_speed
==
3796 ((params
->speed_cap_mask
&
3797 PORT_HW_CFG_SPEED_CAPABILITY_D0_1G
))) {
3798 DP(NETIF_MSG_LINK
, "Setting 1G clause37 \n");
3799 bnx2x_cl45_write(bp
, params
->port
, ext_phy_type
,
3800 ext_phy_addr
, MDIO_AN_DEVAD
,
3801 MDIO_AN_REG_ADV
, 0x20);
3802 bnx2x_cl45_write(bp
, params
->port
, ext_phy_type
,
3803 ext_phy_addr
, MDIO_AN_DEVAD
,
3804 MDIO_AN_REG_CL37_CL73
, 0x040c);
3805 bnx2x_cl45_write(bp
, params
->port
, ext_phy_type
,
3806 ext_phy_addr
, MDIO_AN_DEVAD
,
3807 MDIO_AN_REG_CL37_FC_LD
, 0x0020);
3808 bnx2x_cl45_write(bp
, params
->port
, ext_phy_type
,
3809 ext_phy_addr
, MDIO_AN_DEVAD
,
3810 MDIO_AN_REG_CL37_AN
, 0x1000);
3811 bnx2x_cl45_write(bp
, params
->port
, ext_phy_type
,
3812 ext_phy_addr
, MDIO_AN_DEVAD
,
3813 MDIO_AN_REG_CTRL
, 0x1200);
3815 /* Enable RX-ALARM control to receive
3816 interrupt for 1G speed change */
3817 bnx2x_cl45_write(bp
, params
->port
, ext_phy_type
,
3818 ext_phy_addr
, MDIO_PMA_DEVAD
,
3819 MDIO_PMA_REG_LASI_CTRL
, 0x4);
3820 bnx2x_cl45_write(bp
, params
->port
, ext_phy_type
,
3821 ext_phy_addr
, MDIO_PMA_DEVAD
,
3822 MDIO_PMA_REG_RX_ALARM_CTRL
,
3825 } else { /* Default 10G. Set only LASI control */
3826 bnx2x_cl45_write(bp
, params
->port
, ext_phy_type
,
3827 ext_phy_addr
, MDIO_PMA_DEVAD
,
3828 MDIO_PMA_REG_LASI_CTRL
, 1);
3831 /* Set TX PreEmphasis if needed */
3832 if ((params
->feature_config_flags
&
3833 FEATURE_CONFIG_OVERRIDE_PREEMPHASIS_ENABLED
)) {
3834 DP(NETIF_MSG_LINK
, "Setting TX_CTRL1 0x%x,"
3836 params
->xgxs_config_tx
[0],
3837 params
->xgxs_config_tx
[1]);
3838 bnx2x_cl45_write(bp
, params
->port
,
3842 MDIO_PMA_REG_8726_TX_CTRL1
,
3843 params
->xgxs_config_tx
[0]);
3845 bnx2x_cl45_write(bp
, params
->port
,
3849 MDIO_PMA_REG_8726_TX_CTRL2
,
3850 params
->xgxs_config_tx
[1]);
3853 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8072
:
3854 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073
:
3857 u16 rx_alarm_ctrl_val
;
3860 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8072
) {
3861 rx_alarm_ctrl_val
= 0x400;
3862 lasi_ctrl_val
= 0x0004;
3864 rx_alarm_ctrl_val
= (1<<2);
3865 lasi_ctrl_val
= 0x0004;
3869 bnx2x_cl45_write(bp
, params
->port
,
3873 MDIO_PMA_REG_RX_ALARM_CTRL
,
3876 bnx2x_cl45_write(bp
, params
->port
,
3880 MDIO_PMA_REG_LASI_CTRL
,
3883 bnx2x_8073_set_pause_cl37(params
, vars
);
3886 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8072
)
3887 bnx2x_bcm8072_external_rom_boot(params
);
3889 /* In case of 8073 with long xaui lines,
3890 don't set the 8073 xaui low power*/
3891 bnx2x_bcm8073_set_xaui_low_power_mode(params
);
3893 bnx2x_cl45_read(bp
, params
->port
,
3897 MDIO_PMA_REG_M8051_MSGOUT_REG
,
3900 bnx2x_cl45_read(bp
, params
->port
,
3904 MDIO_PMA_REG_RX_ALARM
, &tmp1
);
3906 DP(NETIF_MSG_LINK
, "Before rom RX_ALARM(port1):"
3909 /* If this is forced speed, set to KR or KX
3910 * (all other are not supported)
3912 if (params
->loopback_mode
== LOOPBACK_EXT
) {
3913 bnx2x_bcm807x_force_10G(params
);
3915 "Forced speed 10G on 807X\n");
3918 bnx2x_cl45_write(bp
, params
->port
,
3919 ext_phy_type
, ext_phy_addr
,
3921 MDIO_PMA_REG_BCM_CTRL
,
3924 if (params
->req_line_speed
!= SPEED_AUTO_NEG
) {
3925 if (params
->req_line_speed
== SPEED_10000
) {
3927 } else if (params
->req_line_speed
==
3930 /* Note that 2.5G works only
3931 when used with 1G advertisment */
3937 if (params
->speed_cap_mask
&
3938 PORT_HW_CFG_SPEED_CAPABILITY_D0_10G
)
3941 /* Note that 2.5G works only when
3942 used with 1G advertisment */
3943 if (params
->speed_cap_mask
&
3944 (PORT_HW_CFG_SPEED_CAPABILITY_D0_1G
|
3945 PORT_HW_CFG_SPEED_CAPABILITY_D0_2_5G
))
3948 "807x autoneg val = 0x%x\n", val
);
3951 bnx2x_cl45_write(bp
, params
->port
,
3955 MDIO_AN_REG_ADV
, val
);
3957 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073
) {
3958 bnx2x_cl45_read(bp
, params
->port
,
3962 MDIO_AN_REG_8073_2_5G
, &tmp1
);
3964 if (((params
->speed_cap_mask
&
3965 PORT_HW_CFG_SPEED_CAPABILITY_D0_2_5G
) &&
3966 (params
->req_line_speed
==
3968 (params
->req_line_speed
==
3971 /* Allow 2.5G for A1 and above */
3972 bnx2x_cl45_read(bp
, params
->port
,
3973 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073
,
3976 MDIO_PMA_REG_8073_CHIP_REV
, &phy_ver
);
3977 DP(NETIF_MSG_LINK
, "Add 2.5G\n");
3983 DP(NETIF_MSG_LINK
, "Disable 2.5G\n");
3987 bnx2x_cl45_write(bp
, params
->port
,
3991 MDIO_AN_REG_8073_2_5G
, tmp1
);
3994 /* Add support for CL37 (passive mode) II */
3996 bnx2x_cl45_read(bp
, params
->port
,
4000 MDIO_AN_REG_CL37_FC_LD
,
4003 bnx2x_cl45_write(bp
, params
->port
,
4007 MDIO_AN_REG_CL37_FC_LD
, (tmp1
|
4008 ((params
->req_duplex
== DUPLEX_FULL
) ?
4011 /* Add support for CL37 (passive mode) III */
4012 bnx2x_cl45_write(bp
, params
->port
,
4016 MDIO_AN_REG_CL37_AN
, 0x1000);
4019 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073
) {
4020 /* The SNR will improve about 2db by changing
4021 BW and FEE main tap. Rest commands are executed
4023 /*Change FFE main cursor to 5 in EDC register*/
4024 if (bnx2x_8073_is_snr_needed(params
))
4025 bnx2x_cl45_write(bp
, params
->port
,
4029 MDIO_PMA_REG_EDC_FFE_MAIN
,
4032 /* Enable FEC (Forware Error Correction)
4033 Request in the AN */
4034 bnx2x_cl45_read(bp
, params
->port
,
4038 MDIO_AN_REG_ADV2
, &tmp1
);
4042 bnx2x_cl45_write(bp
, params
->port
,
4046 MDIO_AN_REG_ADV2
, tmp1
);
4050 bnx2x_ext_phy_set_pause(params
, vars
);
4052 /* Restart autoneg */
4054 bnx2x_cl45_write(bp
, params
->port
,
4058 MDIO_AN_REG_CTRL
, 0x1200);
4059 DP(NETIF_MSG_LINK
, "807x Autoneg Restart: "
4060 "Advertise 1G=%x, 10G=%x\n",
4061 ((val
& (1<<5)) > 0),
4062 ((val
& (1<<7)) > 0));
4066 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727
:
4069 u16 rx_alarm_ctrl_val
;
4072 /* Enable PMD link, MOD_ABS_FLT, and 1G link alarm */
4075 rx_alarm_ctrl_val
= (1<<2) | (1<<5) ;
4076 lasi_ctrl_val
= 0x0004;
4078 DP(NETIF_MSG_LINK
, "Initializing BCM8727\n");
4080 bnx2x_cl45_write(bp
, params
->port
,
4084 MDIO_PMA_REG_RX_ALARM_CTRL
,
4087 bnx2x_cl45_write(bp
, params
->port
,
4091 MDIO_PMA_REG_LASI_CTRL
,
4094 /* Initially configure MOD_ABS to interrupt when
4095 module is presence( bit 8) */
4096 bnx2x_cl45_read(bp
, params
->port
,
4100 MDIO_PMA_REG_PHY_IDENTIFIER
, &mod_abs
);
4101 /* Set EDC off by setting OPTXLOS signal input to low
4103 When the EDC is off it locks onto a reference clock and
4104 avoids becoming 'lost'.*/
4105 mod_abs
&= ~((1<<8) | (1<<9));
4106 bnx2x_cl45_write(bp
, params
->port
,
4110 MDIO_PMA_REG_PHY_IDENTIFIER
, mod_abs
);
4112 /* Make MOD_ABS give interrupt on change */
4113 bnx2x_cl45_read(bp
, params
->port
,
4117 MDIO_PMA_REG_8727_PCS_OPT_CTRL
,
4120 bnx2x_cl45_write(bp
, params
->port
,
4124 MDIO_PMA_REG_8727_PCS_OPT_CTRL
,
4127 /* Set 8727 GPIOs to input to allow reading from the
4128 8727 GPIO0 status which reflect SFP+ module
4131 bnx2x_cl45_read(bp
, params
->port
,
4132 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727
,
4135 MDIO_PMA_REG_8727_PCS_OPT_CTRL
,
4137 val
&= 0xff8f; /* Reset bits 4-6 */
4138 bnx2x_cl45_write(bp
, params
->port
,
4139 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727
,
4142 MDIO_PMA_REG_8727_PCS_OPT_CTRL
,
4145 bnx2x_8727_power_module(bp
, params
, ext_phy_addr
, 1);
4146 bnx2x_bcm8073_set_xaui_low_power_mode(params
);
4148 bnx2x_cl45_read(bp
, params
->port
,
4152 MDIO_PMA_REG_M8051_MSGOUT_REG
,
4155 bnx2x_cl45_read(bp
, params
->port
,
4159 MDIO_PMA_REG_RX_ALARM
, &tmp1
);
4161 /* Set option 1G speed */
4162 if (params
->req_line_speed
== SPEED_1000
) {
4164 DP(NETIF_MSG_LINK
, "Setting 1G force\n");
4165 bnx2x_cl45_write(bp
, params
->port
,
4169 MDIO_PMA_REG_CTRL
, 0x40);
4170 bnx2x_cl45_write(bp
, params
->port
,
4174 MDIO_PMA_REG_10G_CTRL2
, 0xD);
4175 bnx2x_cl45_read(bp
, params
->port
,
4179 MDIO_PMA_REG_10G_CTRL2
, &tmp1
);
4180 DP(NETIF_MSG_LINK
, "1.7 = 0x%x \n", tmp1
);
4182 } else if ((params
->req_line_speed
==
4184 ((params
->speed_cap_mask
&
4185 PORT_HW_CFG_SPEED_CAPABILITY_D0_1G
))) {
4187 DP(NETIF_MSG_LINK
, "Setting 1G clause37 \n");
4188 bnx2x_cl45_write(bp
, params
->port
, ext_phy_type
,
4189 ext_phy_addr
, MDIO_AN_DEVAD
,
4190 MDIO_PMA_REG_8727_MISC_CTRL
, 0);
4191 bnx2x_cl45_write(bp
, params
->port
, ext_phy_type
,
4192 ext_phy_addr
, MDIO_AN_DEVAD
,
4193 MDIO_AN_REG_CL37_AN
, 0x1300);
4195 /* Since the 8727 has only single reset pin,
4196 need to set the 10G registers although it is
4198 bnx2x_cl45_write(bp
, params
->port
, ext_phy_type
,
4199 ext_phy_addr
, MDIO_AN_DEVAD
,
4200 MDIO_AN_REG_CTRL
, 0x0020);
4201 bnx2x_cl45_write(bp
, params
->port
, ext_phy_type
,
4202 ext_phy_addr
, MDIO_AN_DEVAD
,
4204 bnx2x_cl45_write(bp
, params
->port
, ext_phy_type
,
4205 ext_phy_addr
, MDIO_PMA_DEVAD
,
4206 MDIO_PMA_REG_CTRL
, 0x2040);
4207 bnx2x_cl45_write(bp
, params
->port
, ext_phy_type
,
4208 ext_phy_addr
, MDIO_PMA_DEVAD
,
4209 MDIO_PMA_REG_10G_CTRL2
, 0x0008);
4212 /* Set 2-wire transfer rate to 400Khz since 100Khz
4213 is not operational */
4214 bnx2x_cl45_write(bp
, params
->port
,
4218 MDIO_PMA_REG_8727_TWO_WIRE_SLAVE_ADDR
,
4221 /* Set TX PreEmphasis if needed */
4222 if ((params
->feature_config_flags
&
4223 FEATURE_CONFIG_OVERRIDE_PREEMPHASIS_ENABLED
)) {
4224 DP(NETIF_MSG_LINK
, "Setting TX_CTRL1 0x%x,"
4226 params
->xgxs_config_tx
[0],
4227 params
->xgxs_config_tx
[1]);
4228 bnx2x_cl45_write(bp
, params
->port
,
4232 MDIO_PMA_REG_8727_TX_CTRL1
,
4233 params
->xgxs_config_tx
[0]);
4235 bnx2x_cl45_write(bp
, params
->port
,
4239 MDIO_PMA_REG_8727_TX_CTRL2
,
4240 params
->xgxs_config_tx
[1]);
4246 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_SFX7101
:
4248 u16 fw_ver1
, fw_ver2
;
4250 "Setting the SFX7101 LASI indication\n");
4252 bnx2x_cl45_write(bp
, params
->port
,
4256 MDIO_PMA_REG_LASI_CTRL
, 0x1);
4258 "Setting the SFX7101 LED to blink on traffic\n");
4259 bnx2x_cl45_write(bp
, params
->port
,
4263 MDIO_PMA_REG_7107_LED_CNTL
, (1<<3));
4265 bnx2x_ext_phy_set_pause(params
, vars
);
4266 /* Restart autoneg */
4267 bnx2x_cl45_read(bp
, params
->port
,
4271 MDIO_AN_REG_CTRL
, &val
);
4273 bnx2x_cl45_write(bp
, params
->port
,
4277 MDIO_AN_REG_CTRL
, val
);
4279 /* Save spirom version */
4280 bnx2x_cl45_read(bp
, params
->port
, ext_phy_type
,
4281 ext_phy_addr
, MDIO_PMA_DEVAD
,
4282 MDIO_PMA_REG_7101_VER1
, &fw_ver1
);
4284 bnx2x_cl45_read(bp
, params
->port
, ext_phy_type
,
4285 ext_phy_addr
, MDIO_PMA_DEVAD
,
4286 MDIO_PMA_REG_7101_VER2
, &fw_ver2
);
4288 bnx2x_save_spirom_version(params
->bp
, params
->port
,
4290 (u32
)(fw_ver1
<<16 | fw_ver2
));
4293 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8481
:
4294 /* This phy uses the NIG latch mechanism since link
4295 indication arrives through its LED4 and not via
4296 its LASI signal, so we get steady signal
4297 instead of clear on read */
4298 bnx2x_bits_en(bp
, NIG_REG_LATCH_BC_0
+ params
->port
*4,
4299 1 << NIG_LATCH_BC_ENABLE_MI_INT
);
4301 bnx2x_8481_set_led4(params
, ext_phy_type
, ext_phy_addr
);
4302 if (params
->req_line_speed
== SPEED_AUTO_NEG
) {
4304 u16 autoneg_val
, an_1000_val
, an_10_100_val
;
4305 /* set 1000 speed advertisement */
4306 bnx2x_cl45_read(bp
, params
->port
,
4310 MDIO_AN_REG_8481_1000T_CTRL
,
4313 if (params
->speed_cap_mask
&
4314 PORT_HW_CFG_SPEED_CAPABILITY_D0_1G
) {
4315 an_1000_val
|= (1<<8);
4316 if (params
->req_duplex
== DUPLEX_FULL
)
4317 an_1000_val
|= (1<<9);
4318 DP(NETIF_MSG_LINK
, "Advertising 1G\n");
4320 an_1000_val
&= ~((1<<8) | (1<<9));
4322 bnx2x_cl45_write(bp
, params
->port
,
4326 MDIO_AN_REG_8481_1000T_CTRL
,
4329 /* set 100 speed advertisement */
4330 bnx2x_cl45_read(bp
, params
->port
,
4334 MDIO_AN_REG_8481_LEGACY_AN_ADV
,
4337 if (params
->speed_cap_mask
&
4338 (PORT_HW_CFG_SPEED_CAPABILITY_D0_100M_FULL
|
4339 PORT_HW_CFG_SPEED_CAPABILITY_D0_100M_HALF
)) {
4340 an_10_100_val
|= (1<<7);
4341 if (params
->req_duplex
== DUPLEX_FULL
)
4342 an_10_100_val
|= (1<<8);
4344 "Advertising 100M\n");
4346 an_10_100_val
&= ~((1<<7) | (1<<8));
4348 /* set 10 speed advertisement */
4349 if (params
->speed_cap_mask
&
4350 (PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_FULL
|
4351 PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_HALF
)) {
4352 an_10_100_val
|= (1<<5);
4353 if (params
->req_duplex
== DUPLEX_FULL
)
4354 an_10_100_val
|= (1<<6);
4355 DP(NETIF_MSG_LINK
, "Advertising 10M\n");
4358 an_10_100_val
&= ~((1<<5) | (1<<6));
4360 bnx2x_cl45_write(bp
, params
->port
,
4364 MDIO_AN_REG_8481_LEGACY_AN_ADV
,
4367 bnx2x_cl45_read(bp
, params
->port
,
4371 MDIO_AN_REG_8481_LEGACY_MII_CTRL
,
4374 /* Disable forced speed */
4375 autoneg_val
&= ~(1<<6|1<<13);
4377 /* Enable autoneg and restart autoneg
4378 for legacy speeds */
4379 autoneg_val
|= (1<<9|1<<12);
4381 if (params
->req_duplex
== DUPLEX_FULL
)
4382 autoneg_val
|= (1<<8);
4384 autoneg_val
&= ~(1<<8);
4386 bnx2x_cl45_write(bp
, params
->port
,
4390 MDIO_AN_REG_8481_LEGACY_MII_CTRL
,
4393 if (params
->speed_cap_mask
&
4394 PORT_HW_CFG_SPEED_CAPABILITY_D0_10G
) {
4395 DP(NETIF_MSG_LINK
, "Advertising 10G\n");
4396 /* Restart autoneg for 10G*/
4397 bnx2x_cl45_read(bp
, params
->port
,
4401 MDIO_AN_REG_CTRL
, &val
);
4403 bnx2x_cl45_write(bp
, params
->port
,
4407 MDIO_AN_REG_CTRL
, val
);
4411 u16 autoneg_ctrl
, pma_ctrl
;
4412 bnx2x_cl45_read(bp
, params
->port
,
4416 MDIO_AN_REG_8481_LEGACY_MII_CTRL
,
4419 /* Disable autoneg */
4420 autoneg_ctrl
&= ~(1<<12);
4422 /* Set 1000 force */
4423 switch (params
->req_line_speed
) {
4426 "Unable to set 10G force !\n");
4429 bnx2x_cl45_read(bp
, params
->port
,
4435 autoneg_ctrl
&= ~(1<<13);
4436 autoneg_ctrl
|= (1<<6);
4437 pma_ctrl
&= ~(1<<13);
4440 "Setting 1000M force\n");
4441 bnx2x_cl45_write(bp
, params
->port
,
4449 autoneg_ctrl
|= (1<<13);
4450 autoneg_ctrl
&= ~(1<<6);
4452 "Setting 100M force\n");
4455 autoneg_ctrl
&= ~(1<<13);
4456 autoneg_ctrl
&= ~(1<<6);
4458 "Setting 10M force\n");
4463 if (params
->req_duplex
== DUPLEX_FULL
) {
4464 autoneg_ctrl
|= (1<<8);
4466 "Setting full duplex\n");
4468 autoneg_ctrl
&= ~(1<<8);
4470 /* Update autoneg ctrl and pma ctrl */
4471 bnx2x_cl45_write(bp
, params
->port
,
4475 MDIO_AN_REG_8481_LEGACY_MII_CTRL
,
4479 /* Save spirom version */
4480 bnx2x_save_8481_spirom_version(bp
, params
->port
,
4482 params
->shmem_base
);
4484 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_FAILURE
:
4486 "XGXS PHY Failure detected 0x%x\n",
4487 params
->ext_phy_config
);
4491 DP(NETIF_MSG_LINK
, "BAD XGXS ext_phy_config 0x%x\n",
4492 params
->ext_phy_config
);
4497 } else { /* SerDes */
4499 ext_phy_type
= SERDES_EXT_PHY_TYPE(params
->ext_phy_config
);
4500 switch (ext_phy_type
) {
4501 case PORT_HW_CFG_SERDES_EXT_PHY_TYPE_DIRECT
:
4502 DP(NETIF_MSG_LINK
, "SerDes Direct\n");
4505 case PORT_HW_CFG_SERDES_EXT_PHY_TYPE_BCM5482
:
4506 DP(NETIF_MSG_LINK
, "SerDes 5482\n");
4510 DP(NETIF_MSG_LINK
, "BAD SerDes ext_phy_config 0x%x\n",
4511 params
->ext_phy_config
);
4518 static void bnx2x_8727_handle_mod_abs(struct link_params
*params
)
4520 struct bnx2x
*bp
= params
->bp
;
4521 u16 mod_abs
, rx_alarm_status
;
4522 u8 ext_phy_addr
= XGXS_EXT_PHY_ADDR(params
->ext_phy_config
);
4523 u32 val
= REG_RD(bp
, params
->shmem_base
+
4524 offsetof(struct shmem_region
, dev_info
.
4525 port_feature_config
[params
->port
].
4527 bnx2x_cl45_read(bp
, params
->port
,
4528 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727
,
4531 MDIO_PMA_REG_PHY_IDENTIFIER
, &mod_abs
);
4532 if (mod_abs
& (1<<8)) {
4534 /* Module is absent */
4535 DP(NETIF_MSG_LINK
, "MOD_ABS indication "
4536 "show module is absent\n");
4538 /* 1. Set mod_abs to detect next module
4540 2. Set EDC off by setting OPTXLOS signal input to low
4542 When the EDC is off it locks onto a reference clock and
4543 avoids becoming 'lost'.*/
4544 mod_abs
&= ~((1<<8)|(1<<9));
4545 bnx2x_cl45_write(bp
, params
->port
,
4546 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727
,
4549 MDIO_PMA_REG_PHY_IDENTIFIER
, mod_abs
);
4551 /* Clear RX alarm since it stays up as long as
4552 the mod_abs wasn't changed */
4553 bnx2x_cl45_read(bp
, params
->port
,
4554 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727
,
4557 MDIO_PMA_REG_RX_ALARM
, &rx_alarm_status
);
4560 /* Module is present */
4561 DP(NETIF_MSG_LINK
, "MOD_ABS indication "
4562 "show module is present\n");
4563 /* First thing, disable transmitter,
4564 and if the module is ok, the
4565 module_detection will enable it*/
4567 /* 1. Set mod_abs to detect next module
4568 absent event ( bit 8)
4569 2. Restore the default polarity of the OPRXLOS signal and
4570 this signal will then correctly indicate the presence or
4571 absence of the Rx signal. (bit 9) */
4572 mod_abs
|= ((1<<8)|(1<<9));
4573 bnx2x_cl45_write(bp
, params
->port
,
4574 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727
,
4577 MDIO_PMA_REG_PHY_IDENTIFIER
, mod_abs
);
4579 /* Clear RX alarm since it stays up as long as
4580 the mod_abs wasn't changed. This is need to be done
4581 before calling the module detection, otherwise it will clear
4582 the link update alarm */
4583 bnx2x_cl45_read(bp
, params
->port
,
4584 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727
,
4587 MDIO_PMA_REG_RX_ALARM
, &rx_alarm_status
);
4590 if ((val
& PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK
) ==
4591 PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_DISABLE_TX_LASER
)
4592 bnx2x_sfp_set_transmitter(bp
, params
->port
,
4593 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727
,
4596 if (bnx2x_wait_for_sfp_module_initialized(params
)
4598 bnx2x_sfp_module_detection(params
);
4600 DP(NETIF_MSG_LINK
, "SFP+ module is not initialized\n");
4603 DP(NETIF_MSG_LINK
, "8727 RX_ALARM_STATUS 0x%x\n",
4605 /* No need to check link status in case of
4606 module plugged in/out */
4610 static u8
bnx2x_ext_phy_is_link_up(struct link_params
*params
,
4611 struct link_vars
*vars
,
4614 struct bnx2x
*bp
= params
->bp
;
4618 u16 rx_sd
, pcs_status
;
4619 u8 ext_phy_link_up
= 0;
4620 u8 port
= params
->port
;
4622 if (vars
->phy_flags
& PHY_XGXS_FLAG
) {
4623 ext_phy_addr
= XGXS_EXT_PHY_ADDR(params
->ext_phy_config
);
4624 ext_phy_type
= XGXS_EXT_PHY_TYPE(params
->ext_phy_config
);
4625 switch (ext_phy_type
) {
4626 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT
:
4627 DP(NETIF_MSG_LINK
, "XGXS Direct\n");
4628 ext_phy_link_up
= 1;
4631 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8705
:
4632 DP(NETIF_MSG_LINK
, "XGXS 8705\n");
4633 bnx2x_cl45_read(bp
, params
->port
, ext_phy_type
,
4636 MDIO_WIS_REG_LASI_STATUS
, &val1
);
4637 DP(NETIF_MSG_LINK
, "8705 LASI status 0x%x\n", val1
);
4639 bnx2x_cl45_read(bp
, params
->port
, ext_phy_type
,
4642 MDIO_WIS_REG_LASI_STATUS
, &val1
);
4643 DP(NETIF_MSG_LINK
, "8705 LASI status 0x%x\n", val1
);
4645 bnx2x_cl45_read(bp
, params
->port
, ext_phy_type
,
4648 MDIO_PMA_REG_RX_SD
, &rx_sd
);
4650 bnx2x_cl45_read(bp
, params
->port
, ext_phy_type
,
4654 bnx2x_cl45_read(bp
, params
->port
, ext_phy_type
,
4659 DP(NETIF_MSG_LINK
, "8705 1.c809 val=0x%x\n", val1
);
4660 ext_phy_link_up
= ((rx_sd
& 0x1) && (val1
& (1<<9))
4661 && ((val1
& (1<<8)) == 0));
4662 if (ext_phy_link_up
)
4663 vars
->line_speed
= SPEED_10000
;
4666 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8706
:
4667 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726
:
4668 DP(NETIF_MSG_LINK
, "XGXS 8706/8726\n");
4670 bnx2x_cl45_read(bp
, params
->port
, ext_phy_type
,
4672 MDIO_PMA_DEVAD
, MDIO_PMA_REG_RX_ALARM
,
4674 /* clear LASI indication*/
4675 bnx2x_cl45_read(bp
, params
->port
, ext_phy_type
,
4677 MDIO_PMA_DEVAD
, MDIO_PMA_REG_LASI_STATUS
,
4679 bnx2x_cl45_read(bp
, params
->port
, ext_phy_type
,
4681 MDIO_PMA_DEVAD
, MDIO_PMA_REG_LASI_STATUS
,
4683 DP(NETIF_MSG_LINK
, "8706/8726 LASI status 0x%x-->"
4684 "0x%x\n", val1
, val2
);
4686 bnx2x_cl45_read(bp
, params
->port
, ext_phy_type
,
4688 MDIO_PMA_DEVAD
, MDIO_PMA_REG_RX_SD
,
4690 bnx2x_cl45_read(bp
, params
->port
, ext_phy_type
,
4692 MDIO_PCS_DEVAD
, MDIO_PCS_REG_STATUS
,
4694 bnx2x_cl45_read(bp
, params
->port
, ext_phy_type
,
4696 MDIO_AN_DEVAD
, MDIO_AN_REG_LINK_STATUS
,
4698 bnx2x_cl45_read(bp
, params
->port
, ext_phy_type
,
4700 MDIO_AN_DEVAD
, MDIO_AN_REG_LINK_STATUS
,
4703 DP(NETIF_MSG_LINK
, "8706/8726 rx_sd 0x%x"
4704 " pcs_status 0x%x 1Gbps link_status 0x%x\n",
4705 rx_sd
, pcs_status
, val2
);
4706 /* link is up if both bit 0 of pmd_rx_sd and
4707 * bit 0 of pcs_status are set, or if the autoneg bit
4710 ext_phy_link_up
= ((rx_sd
& pcs_status
& 0x1) ||
4712 if (ext_phy_link_up
) {
4714 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726
) {
4715 /* If transmitter is disabled,
4716 ignore false link up indication */
4717 bnx2x_cl45_read(bp
, params
->port
,
4721 MDIO_PMA_REG_PHY_IDENTIFIER
,
4723 if (val1
& (1<<15)) {
4724 DP(NETIF_MSG_LINK
, "Tx is "
4726 ext_phy_link_up
= 0;
4731 vars
->line_speed
= SPEED_1000
;
4733 vars
->line_speed
= SPEED_10000
;
4737 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727
:
4739 u16 link_status
= 0;
4740 u16 rx_alarm_status
;
4741 /* Check the LASI */
4742 bnx2x_cl45_read(bp
, params
->port
,
4746 MDIO_PMA_REG_RX_ALARM
, &rx_alarm_status
);
4748 DP(NETIF_MSG_LINK
, "8727 RX_ALARM_STATUS 0x%x\n",
4751 bnx2x_cl45_read(bp
, params
->port
,
4755 MDIO_PMA_REG_LASI_STATUS
, &val1
);
4758 "8727 LASI status 0x%x\n",
4762 bnx2x_cl45_read(bp
, params
->port
,
4766 MDIO_PMA_REG_M8051_MSGOUT_REG
,
4770 * If a module is present and there is need to check
4773 if (!(params
->feature_config_flags
&
4774 FEATURE_CONFIG_BCM8727_NOC
) &&
4775 !(rx_alarm_status
& (1<<5))) {
4776 /* Check over-current using 8727 GPIO0 input*/
4777 bnx2x_cl45_read(bp
, params
->port
,
4781 MDIO_PMA_REG_8727_GPIO_CTRL
,
4784 if ((val1
& (1<<8)) == 0) {
4785 DP(NETIF_MSG_LINK
, "8727 Power fault"
4786 " has been detected on "
4789 printk(KERN_ERR PFX
"Error: Power"
4790 " fault on %s Port %d has"
4791 " been detected and the"
4792 " power to that SFP+ module"
4793 " has been removed to prevent"
4794 " failure of the card. Please"
4795 " remove the SFP+ module and"
4796 " restart the system to clear"
4798 , bp
->dev
->name
, params
->port
);
4800 * Disable all RX_ALARMs except for
4803 bnx2x_cl45_write(bp
, params
->port
,
4807 MDIO_PMA_REG_RX_ALARM_CTRL
,
4810 bnx2x_cl45_read(bp
, params
->port
,
4814 MDIO_PMA_REG_PHY_IDENTIFIER
,
4816 /* Wait for module_absent_event */
4818 bnx2x_cl45_write(bp
, params
->port
,
4822 MDIO_PMA_REG_PHY_IDENTIFIER
,
4824 /* Clear RX alarm */
4825 bnx2x_cl45_read(bp
, params
->port
,
4829 MDIO_PMA_REG_RX_ALARM
,
4833 } /* Over current check */
4835 /* When module absent bit is set, check module */
4836 if (rx_alarm_status
& (1<<5)) {
4837 bnx2x_8727_handle_mod_abs(params
);
4838 /* Enable all mod_abs and link detection bits */
4839 bnx2x_cl45_write(bp
, params
->port
,
4843 MDIO_PMA_REG_RX_ALARM_CTRL
,
4847 /* If transmitter is disabled,
4848 ignore false link up indication */
4849 bnx2x_cl45_read(bp
, params
->port
,
4853 MDIO_PMA_REG_PHY_IDENTIFIER
,
4855 if (val1
& (1<<15)) {
4856 DP(NETIF_MSG_LINK
, "Tx is disabled\n");
4857 ext_phy_link_up
= 0;
4861 bnx2x_cl45_read(bp
, params
->port
,
4865 MDIO_PMA_REG_8073_SPEED_LINK_STATUS
,
4868 /* Bits 0..2 --> speed detected,
4869 bits 13..15--> link is down */
4870 if ((link_status
& (1<<2)) &&
4871 (!(link_status
& (1<<15)))) {
4872 ext_phy_link_up
= 1;
4873 vars
->line_speed
= SPEED_10000
;
4874 } else if ((link_status
& (1<<0)) &&
4875 (!(link_status
& (1<<13)))) {
4876 ext_phy_link_up
= 1;
4877 vars
->line_speed
= SPEED_1000
;
4879 "port %x: External link"
4880 " up in 1G\n", params
->port
);
4882 ext_phy_link_up
= 0;
4884 "port %x: External link"
4885 " is down\n", params
->port
);
4890 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8072
:
4891 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073
:
4893 u16 link_status
= 0;
4894 u16 an1000_status
= 0;
4897 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8072
) {
4898 bnx2x_cl45_read(bp
, params
->port
,
4902 MDIO_PCS_REG_LASI_STATUS
, &val1
);
4903 bnx2x_cl45_read(bp
, params
->port
,
4907 MDIO_PCS_REG_LASI_STATUS
, &val2
);
4909 "870x LASI status 0x%x->0x%x\n",
4912 /* In 8073, port1 is directed through emac0 and
4913 * port0 is directed through emac1
4915 bnx2x_cl45_read(bp
, params
->port
,
4919 MDIO_PMA_REG_LASI_STATUS
, &val1
);
4922 "8703 LASI status 0x%x\n",
4926 /* clear the interrupt LASI status register */
4927 bnx2x_cl45_read(bp
, params
->port
,
4931 MDIO_PCS_REG_STATUS
, &val2
);
4932 bnx2x_cl45_read(bp
, params
->port
,
4936 MDIO_PCS_REG_STATUS
, &val1
);
4937 DP(NETIF_MSG_LINK
, "807x PCS status 0x%x->0x%x\n",
4940 bnx2x_cl45_read(bp
, params
->port
,
4944 MDIO_PMA_REG_M8051_MSGOUT_REG
,
4947 /* Check the LASI */
4948 bnx2x_cl45_read(bp
, params
->port
,
4952 MDIO_PMA_REG_RX_ALARM
, &val2
);
4954 DP(NETIF_MSG_LINK
, "KR 0x9003 0x%x\n", val2
);
4956 /* Check the link status */
4957 bnx2x_cl45_read(bp
, params
->port
,
4961 MDIO_PCS_REG_STATUS
, &val2
);
4962 DP(NETIF_MSG_LINK
, "KR PCS status 0x%x\n", val2
);
4964 bnx2x_cl45_read(bp
, params
->port
,
4968 MDIO_PMA_REG_STATUS
, &val2
);
4969 bnx2x_cl45_read(bp
, params
->port
,
4973 MDIO_PMA_REG_STATUS
, &val1
);
4974 ext_phy_link_up
= ((val1
& 4) == 4);
4975 DP(NETIF_MSG_LINK
, "PMA_REG_STATUS=0x%x\n", val1
);
4977 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073
) {
4979 if (ext_phy_link_up
&&
4980 ((params
->req_line_speed
!=
4982 if (bnx2x_bcm8073_xaui_wa(params
)
4984 ext_phy_link_up
= 0;
4988 bnx2x_cl45_read(bp
, params
->port
,
4992 MDIO_AN_REG_LINK_STATUS
,
4994 bnx2x_cl45_read(bp
, params
->port
,
4998 MDIO_AN_REG_LINK_STATUS
,
5001 /* Check the link status on 1.1.2 */
5002 bnx2x_cl45_read(bp
, params
->port
,
5006 MDIO_PMA_REG_STATUS
, &val2
);
5007 bnx2x_cl45_read(bp
, params
->port
,
5011 MDIO_PMA_REG_STATUS
, &val1
);
5012 DP(NETIF_MSG_LINK
, "KR PMA status 0x%x->0x%x,"
5013 "an_link_status=0x%x\n",
5014 val2
, val1
, an1000_status
);
5016 ext_phy_link_up
= (((val1
& 4) == 4) ||
5017 (an1000_status
& (1<<1)));
5018 if (ext_phy_link_up
&&
5019 bnx2x_8073_is_snr_needed(params
)) {
5020 /* The SNR will improve about 2dbby
5021 changing the BW and FEE main tap.*/
5023 /* The 1st write to change FFE main
5024 tap is set before restart AN */
5025 /* Change PLL Bandwidth in EDC
5027 bnx2x_cl45_write(bp
, port
, ext_phy_type
,
5030 MDIO_PMA_REG_PLL_BANDWIDTH
,
5033 /* Change CDR Bandwidth in EDC
5035 bnx2x_cl45_write(bp
, port
, ext_phy_type
,
5038 MDIO_PMA_REG_CDR_BANDWIDTH
,
5041 bnx2x_cl45_read(bp
, params
->port
,
5045 MDIO_PMA_REG_8073_SPEED_LINK_STATUS
,
5048 /* Bits 0..2 --> speed detected,
5049 bits 13..15--> link is down */
5050 if ((link_status
& (1<<2)) &&
5051 (!(link_status
& (1<<15)))) {
5052 ext_phy_link_up
= 1;
5053 vars
->line_speed
= SPEED_10000
;
5055 "port %x: External link"
5056 " up in 10G\n", params
->port
);
5057 } else if ((link_status
& (1<<1)) &&
5058 (!(link_status
& (1<<14)))) {
5059 ext_phy_link_up
= 1;
5060 vars
->line_speed
= SPEED_2500
;
5062 "port %x: External link"
5063 " up in 2.5G\n", params
->port
);
5064 } else if ((link_status
& (1<<0)) &&
5065 (!(link_status
& (1<<13)))) {
5066 ext_phy_link_up
= 1;
5067 vars
->line_speed
= SPEED_1000
;
5069 "port %x: External link"
5070 " up in 1G\n", params
->port
);
5072 ext_phy_link_up
= 0;
5074 "port %x: External link"
5075 " is down\n", params
->port
);
5078 /* See if 1G link is up for the 8072 */
5079 bnx2x_cl45_read(bp
, params
->port
,
5083 MDIO_AN_REG_LINK_STATUS
,
5085 bnx2x_cl45_read(bp
, params
->port
,
5089 MDIO_AN_REG_LINK_STATUS
,
5091 if (an1000_status
& (1<<1)) {
5092 ext_phy_link_up
= 1;
5093 vars
->line_speed
= SPEED_1000
;
5095 "port %x: External link"
5096 " up in 1G\n", params
->port
);
5097 } else if (ext_phy_link_up
) {
5098 ext_phy_link_up
= 1;
5099 vars
->line_speed
= SPEED_10000
;
5101 "port %x: External link"
5102 " up in 10G\n", params
->port
);
5109 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_SFX7101
:
5110 bnx2x_cl45_read(bp
, params
->port
, ext_phy_type
,
5113 MDIO_PMA_REG_LASI_STATUS
, &val2
);
5114 bnx2x_cl45_read(bp
, params
->port
, ext_phy_type
,
5117 MDIO_PMA_REG_LASI_STATUS
, &val1
);
5119 "10G-base-T LASI status 0x%x->0x%x\n",
5121 bnx2x_cl45_read(bp
, params
->port
, ext_phy_type
,
5124 MDIO_PMA_REG_STATUS
, &val2
);
5125 bnx2x_cl45_read(bp
, params
->port
, ext_phy_type
,
5128 MDIO_PMA_REG_STATUS
, &val1
);
5130 "10G-base-T PMA status 0x%x->0x%x\n",
5132 ext_phy_link_up
= ((val1
& 4) == 4);
5134 * print the AN outcome of the SFX7101 PHY
5136 if (ext_phy_link_up
) {
5137 bnx2x_cl45_read(bp
, params
->port
,
5141 MDIO_AN_REG_MASTER_STATUS
,
5143 vars
->line_speed
= SPEED_10000
;
5145 "SFX7101 AN status 0x%x->Master=%x\n",
5150 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8481
:
5151 /* Check 10G-BaseT link status */
5152 /* Check PMD signal ok */
5153 bnx2x_cl45_read(bp
, params
->port
, ext_phy_type
,
5158 bnx2x_cl45_read(bp
, params
->port
, ext_phy_type
,
5161 MDIO_PMA_REG_8481_PMD_SIGNAL
,
5163 DP(NETIF_MSG_LINK
, "PMD_SIGNAL 1.a811 = 0x%x\n", val2
);
5165 /* Check link 10G */
5166 if (val2
& (1<<11)) {
5167 vars
->line_speed
= SPEED_10000
;
5168 ext_phy_link_up
= 1;
5169 bnx2x_8481_set_10G_led_mode(params
,
5172 } else { /* Check Legacy speed link */
5173 u16 legacy_status
, legacy_speed
;
5175 /* Enable expansion register 0x42
5176 (Operation mode status) */
5177 bnx2x_cl45_write(bp
, params
->port
,
5181 MDIO_AN_REG_8481_EXPANSION_REG_ACCESS
,
5184 /* Get legacy speed operation status */
5185 bnx2x_cl45_read(bp
, params
->port
,
5189 MDIO_AN_REG_8481_EXPANSION_REG_RD_RW
,
5192 DP(NETIF_MSG_LINK
, "Legacy speed status"
5193 " = 0x%x\n", legacy_status
);
5194 ext_phy_link_up
= ((legacy_status
& (1<<11))
5196 if (ext_phy_link_up
) {
5197 legacy_speed
= (legacy_status
& (3<<9));
5198 if (legacy_speed
== (0<<9))
5199 vars
->line_speed
= SPEED_10
;
5200 else if (legacy_speed
== (1<<9))
5203 else if (legacy_speed
== (2<<9))
5206 else /* Should not happen */
5207 vars
->line_speed
= 0;
5209 if (legacy_status
& (1<<8))
5210 vars
->duplex
= DUPLEX_FULL
;
5212 vars
->duplex
= DUPLEX_HALF
;
5214 DP(NETIF_MSG_LINK
, "Link is up "
5215 "in %dMbps, is_duplex_full"
5218 (vars
->duplex
== DUPLEX_FULL
));
5219 bnx2x_8481_set_legacy_led_mode(params
,
5226 DP(NETIF_MSG_LINK
, "BAD XGXS ext_phy_config 0x%x\n",
5227 params
->ext_phy_config
);
5228 ext_phy_link_up
= 0;
5231 /* Set SGMII mode for external phy */
5232 if (ext_phy_type
!= PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT
) {
5233 if (vars
->line_speed
< SPEED_1000
)
5234 vars
->phy_flags
|= PHY_SGMII_FLAG
;
5236 vars
->phy_flags
&= ~PHY_SGMII_FLAG
;
5239 } else { /* SerDes */
5240 ext_phy_type
= SERDES_EXT_PHY_TYPE(params
->ext_phy_config
);
5241 switch (ext_phy_type
) {
5242 case PORT_HW_CFG_SERDES_EXT_PHY_TYPE_DIRECT
:
5243 DP(NETIF_MSG_LINK
, "SerDes Direct\n");
5244 ext_phy_link_up
= 1;
5247 case PORT_HW_CFG_SERDES_EXT_PHY_TYPE_BCM5482
:
5248 DP(NETIF_MSG_LINK
, "SerDes 5482\n");
5249 ext_phy_link_up
= 1;
5254 "BAD SerDes ext_phy_config 0x%x\n",
5255 params
->ext_phy_config
);
5256 ext_phy_link_up
= 0;
5261 return ext_phy_link_up
;
5264 static void bnx2x_link_int_enable(struct link_params
*params
)
5266 u8 port
= params
->port
;
5269 struct bnx2x
*bp
= params
->bp
;
5271 /* setting the status to report on link up
5272 for either XGXS or SerDes */
5274 if (params
->switch_cfg
== SWITCH_CFG_10G
) {
5275 mask
= (NIG_MASK_XGXS0_LINK10G
|
5276 NIG_MASK_XGXS0_LINK_STATUS
);
5277 DP(NETIF_MSG_LINK
, "enabled XGXS interrupt\n");
5278 ext_phy_type
= XGXS_EXT_PHY_TYPE(params
->ext_phy_config
);
5279 if ((ext_phy_type
!= PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT
) &&
5280 (ext_phy_type
!= PORT_HW_CFG_XGXS_EXT_PHY_TYPE_FAILURE
) &&
5282 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_NOT_CONN
)) {
5283 mask
|= NIG_MASK_MI_INT
;
5284 DP(NETIF_MSG_LINK
, "enabled external phy int\n");
5287 } else { /* SerDes */
5288 mask
= NIG_MASK_SERDES0_LINK_STATUS
;
5289 DP(NETIF_MSG_LINK
, "enabled SerDes interrupt\n");
5290 ext_phy_type
= SERDES_EXT_PHY_TYPE(params
->ext_phy_config
);
5291 if ((ext_phy_type
!=
5292 PORT_HW_CFG_SERDES_EXT_PHY_TYPE_DIRECT
) &&
5294 PORT_HW_CFG_SERDES_EXT_PHY_TYPE_NOT_CONN
)) {
5295 mask
|= NIG_MASK_MI_INT
;
5296 DP(NETIF_MSG_LINK
, "enabled external phy int\n");
5300 NIG_REG_MASK_INTERRUPT_PORT0
+ port
*4,
5303 DP(NETIF_MSG_LINK
, "port %x, is_xgxs %x, int_status 0x%x\n", port
,
5304 (params
->switch_cfg
== SWITCH_CFG_10G
),
5305 REG_RD(bp
, NIG_REG_STATUS_INTERRUPT_PORT0
+ port
*4));
5306 DP(NETIF_MSG_LINK
, " int_mask 0x%x, MI_INT %x, SERDES_LINK %x\n",
5307 REG_RD(bp
, NIG_REG_MASK_INTERRUPT_PORT0
+ port
*4),
5308 REG_RD(bp
, NIG_REG_EMAC0_STATUS_MISC_MI_INT
+ port
*0x18),
5309 REG_RD(bp
, NIG_REG_SERDES0_STATUS_LINK_STATUS
+port
*0x3c));
5310 DP(NETIF_MSG_LINK
, " 10G %x, XGXS_LINK %x\n",
5311 REG_RD(bp
, NIG_REG_XGXS0_STATUS_LINK10G
+ port
*0x68),
5312 REG_RD(bp
, NIG_REG_XGXS0_STATUS_LINK_STATUS
+ port
*0x68));
5315 static void bnx2x_8481_rearm_latch_signal(struct bnx2x
*bp
, u8 port
,
5318 u32 latch_status
= 0, is_mi_int_status
;
5319 /* Disable the MI INT ( external phy int )
5320 * by writing 1 to the status register. Link down indication
5321 * is high-active-signal, so in this case we need to write the
5322 * status to clear the XOR
5324 /* Read Latched signals */
5325 latch_status
= REG_RD(bp
,
5326 NIG_REG_LATCH_STATUS_0
+ port
*8);
5327 is_mi_int_status
= REG_RD(bp
,
5328 NIG_REG_STATUS_INTERRUPT_PORT0
+ port
*4);
5329 DP(NETIF_MSG_LINK
, "original_signal = 0x%x, nig_status = 0x%x,"
5330 "latch_status = 0x%x\n",
5331 is_mi_int
, is_mi_int_status
, latch_status
);
5332 /* Handle only those with latched-signal=up.*/
5333 if (latch_status
& 1) {
5334 /* For all latched-signal=up,Write original_signal to status */
5337 NIG_REG_STATUS_INTERRUPT_PORT0
5339 NIG_STATUS_EMAC0_MI_INT
);
5342 NIG_REG_STATUS_INTERRUPT_PORT0
5344 NIG_STATUS_EMAC0_MI_INT
);
5345 /* For all latched-signal=up : Re-Arm Latch signals */
5346 REG_WR(bp
, NIG_REG_LATCH_STATUS_0
+ port
*8,
5347 (latch_status
& 0xfffe) | (latch_status
& 1));
5353 static void bnx2x_link_int_ack(struct link_params
*params
,
5354 struct link_vars
*vars
, u8 is_10g
,
5357 struct bnx2x
*bp
= params
->bp
;
5358 u8 port
= params
->port
;
5360 /* first reset all status
5361 * we assume only one line will be change at a time */
5362 bnx2x_bits_dis(bp
, NIG_REG_STATUS_INTERRUPT_PORT0
+ port
*4,
5363 (NIG_STATUS_XGXS0_LINK10G
|
5364 NIG_STATUS_XGXS0_LINK_STATUS
|
5365 NIG_STATUS_SERDES0_LINK_STATUS
));
5366 if (XGXS_EXT_PHY_TYPE(params
->ext_phy_config
)
5367 == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8481
) {
5368 bnx2x_8481_rearm_latch_signal(bp
, port
, is_mi_int
);
5370 if (vars
->phy_link_up
) {
5372 /* Disable the 10G link interrupt
5373 * by writing 1 to the status register
5375 DP(NETIF_MSG_LINK
, "10G XGXS phy link up\n");
5377 NIG_REG_STATUS_INTERRUPT_PORT0
+ port
*4,
5378 NIG_STATUS_XGXS0_LINK10G
);
5380 } else if (params
->switch_cfg
== SWITCH_CFG_10G
) {
5381 /* Disable the link interrupt
5382 * by writing 1 to the relevant lane
5383 * in the status register
5385 u32 ser_lane
= ((params
->lane_config
&
5386 PORT_HW_CFG_LANE_SWAP_CFG_MASTER_MASK
) >>
5387 PORT_HW_CFG_LANE_SWAP_CFG_MASTER_SHIFT
);
5389 DP(NETIF_MSG_LINK
, "%d speed XGXS phy link up\n",
5392 NIG_REG_STATUS_INTERRUPT_PORT0
+ port
*4,
5394 NIG_STATUS_XGXS0_LINK_STATUS_SIZE
));
5396 } else { /* SerDes */
5397 DP(NETIF_MSG_LINK
, "SerDes phy link up\n");
5398 /* Disable the link interrupt
5399 * by writing 1 to the status register
5402 NIG_REG_STATUS_INTERRUPT_PORT0
+ port
*4,
5403 NIG_STATUS_SERDES0_LINK_STATUS
);
5406 } else { /* link_down */
5410 static u8
bnx2x_format_ver(u32 num
, u8
*str
, u16 len
)
5413 u32 mask
= 0xf0000000;
5417 /* Need more than 10chars for this format */
5424 digit
= ((num
& mask
) >> shift
);
5426 *str_ptr
= digit
+ '0';
5428 *str_ptr
= digit
- 0xa + 'a';
5440 u8
bnx2x_get_ext_phy_fw_version(struct link_params
*params
, u8 driver_loaded
,
5441 u8
*version
, u16 len
)
5444 u32 ext_phy_type
= 0;
5448 if (version
== NULL
|| params
== NULL
)
5452 spirom_ver
= REG_RD(bp
, params
->shmem_base
+
5453 offsetof(struct shmem_region
,
5454 port_mb
[params
->port
].ext_phy_fw_version
));
5457 /* reset the returned value to zero */
5458 ext_phy_type
= XGXS_EXT_PHY_TYPE(params
->ext_phy_config
);
5459 switch (ext_phy_type
) {
5460 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_SFX7101
:
5465 version
[0] = (spirom_ver
& 0xFF);
5466 version
[1] = (spirom_ver
& 0xFF00) >> 8;
5467 version
[2] = (spirom_ver
& 0xFF0000) >> 16;
5468 version
[3] = (spirom_ver
& 0xFF000000) >> 24;
5472 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8072
:
5473 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073
:
5474 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727
:
5475 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8706
:
5476 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726
:
5477 status
= bnx2x_format_ver(spirom_ver
, version
, len
);
5479 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8481
:
5480 spirom_ver
= ((spirom_ver
& 0xF80) >> 7) << 16 |
5481 (spirom_ver
& 0x7F);
5482 status
= bnx2x_format_ver(spirom_ver
, version
, len
);
5484 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT
:
5485 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8705
:
5489 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_FAILURE
:
5490 DP(NETIF_MSG_LINK
, "bnx2x_get_ext_phy_fw_version:"
5491 " type is FAILURE!\n");
5501 static void bnx2x_set_xgxs_loopback(struct link_params
*params
,
5502 struct link_vars
*vars
,
5505 u8 port
= params
->port
;
5506 struct bnx2x
*bp
= params
->bp
;
5511 DP(NETIF_MSG_LINK
, "XGXS 10G loopback enable\n");
5513 /* change the uni_phy_addr in the nig */
5514 md_devad
= REG_RD(bp
, (NIG_REG_XGXS0_CTRL_MD_DEVAD
+
5517 REG_WR(bp
, NIG_REG_XGXS0_CTRL_MD_DEVAD
+ port
*0x18, 0x5);
5519 bnx2x_cl45_write(bp
, port
, 0,
5522 (MDIO_REG_BANK_AER_BLOCK
+
5523 (MDIO_AER_BLOCK_AER_REG
& 0xf)),
5526 bnx2x_cl45_write(bp
, port
, 0,
5529 (MDIO_REG_BANK_CL73_IEEEB0
+
5530 (MDIO_CL73_IEEEB0_CL73_AN_CONTROL
& 0xf)),
5533 /* set aer mmd back */
5534 bnx2x_set_aer_mmd(params
, vars
);
5537 REG_WR(bp
, NIG_REG_XGXS0_CTRL_MD_DEVAD
+ port
*0x18,
5543 DP(NETIF_MSG_LINK
, "XGXS 1G loopback enable\n");
5545 CL45_RD_OVER_CL22(bp
, port
,
5547 MDIO_REG_BANK_COMBO_IEEE0
,
5548 MDIO_COMBO_IEEE0_MII_CONTROL
,
5551 CL45_WR_OVER_CL22(bp
, port
,
5553 MDIO_REG_BANK_COMBO_IEEE0
,
5554 MDIO_COMBO_IEEE0_MII_CONTROL
,
5556 MDIO_COMBO_IEEO_MII_CONTROL_LOOPBACK
));
5561 static void bnx2x_ext_phy_loopback(struct link_params
*params
)
5563 struct bnx2x
*bp
= params
->bp
;
5567 if (params
->switch_cfg
== SWITCH_CFG_10G
) {
5568 ext_phy_type
= XGXS_EXT_PHY_TYPE(params
->ext_phy_config
);
5569 ext_phy_addr
= XGXS_EXT_PHY_ADDR(params
->ext_phy_config
);
5570 /* CL37 Autoneg Enabled */
5571 switch (ext_phy_type
) {
5572 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT
:
5573 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_NOT_CONN
:
5575 "ext_phy_loopback: We should not get here\n");
5577 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8705
:
5578 DP(NETIF_MSG_LINK
, "ext_phy_loopback: 8705\n");
5580 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8706
:
5581 DP(NETIF_MSG_LINK
, "ext_phy_loopback: 8706\n");
5583 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726
:
5584 DP(NETIF_MSG_LINK
, "PMA/PMD ext_phy_loopback: 8726\n");
5585 bnx2x_cl45_write(bp
, params
->port
, ext_phy_type
,
5591 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_SFX7101
:
5592 /* SFX7101_XGXS_TEST1 */
5593 bnx2x_cl45_write(bp
, params
->port
, ext_phy_type
,
5596 MDIO_XS_SFX7101_XGXS_TEST1
,
5599 "ext_phy_loopback: set ext phy loopback\n");
5601 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8072
:
5604 } /* switch external PHY type */
5607 ext_phy_type
= SERDES_EXT_PHY_TYPE(params
->ext_phy_config
);
5608 ext_phy_addr
= (params
->ext_phy_config
&
5609 PORT_HW_CFG_SERDES_EXT_PHY_ADDR_MASK
)
5610 >> PORT_HW_CFG_SERDES_EXT_PHY_ADDR_SHIFT
;
5616 *------------------------------------------------------------------------
5617 * bnx2x_override_led_value -
5619 * Override the led value of the requsted led
5621 *------------------------------------------------------------------------
5623 u8
bnx2x_override_led_value(struct bnx2x
*bp
, u8 port
,
5624 u32 led_idx
, u32 value
)
5628 /* If port 0 then use EMAC0, else use EMAC1*/
5629 u32 emac_base
= (port
) ? GRCBASE_EMAC1
: GRCBASE_EMAC0
;
5632 "bnx2x_override_led_value() port %x led_idx %d value %d\n",
5633 port
, led_idx
, value
);
5636 case 0: /* 10MB led */
5637 /* Read the current value of the LED register in
5639 reg_val
= REG_RD(bp
, emac_base
+ EMAC_REG_EMAC_LED
);
5640 /* Set the OVERRIDE bit to 1 */
5641 reg_val
|= EMAC_LED_OVERRIDE
;
5642 /* If value is 1, set the 10M_OVERRIDE bit,
5643 otherwise reset it.*/
5644 reg_val
= (value
== 1) ? (reg_val
| EMAC_LED_10MB_OVERRIDE
) :
5645 (reg_val
& ~EMAC_LED_10MB_OVERRIDE
);
5646 REG_WR(bp
, emac_base
+ EMAC_REG_EMAC_LED
, reg_val
);
5648 case 1: /*100MB led */
5649 /*Read the current value of the LED register in
5651 reg_val
= REG_RD(bp
, emac_base
+ EMAC_REG_EMAC_LED
);
5652 /* Set the OVERRIDE bit to 1 */
5653 reg_val
|= EMAC_LED_OVERRIDE
;
5654 /* If value is 1, set the 100M_OVERRIDE bit,
5655 otherwise reset it.*/
5656 reg_val
= (value
== 1) ? (reg_val
| EMAC_LED_100MB_OVERRIDE
) :
5657 (reg_val
& ~EMAC_LED_100MB_OVERRIDE
);
5658 REG_WR(bp
, emac_base
+ EMAC_REG_EMAC_LED
, reg_val
);
5660 case 2: /* 1000MB led */
5661 /* Read the current value of the LED register in the
5663 reg_val
= REG_RD(bp
, emac_base
+ EMAC_REG_EMAC_LED
);
5664 /* Set the OVERRIDE bit to 1 */
5665 reg_val
|= EMAC_LED_OVERRIDE
;
5666 /* If value is 1, set the 1000M_OVERRIDE bit, otherwise
5668 reg_val
= (value
== 1) ? (reg_val
| EMAC_LED_1000MB_OVERRIDE
) :
5669 (reg_val
& ~EMAC_LED_1000MB_OVERRIDE
);
5670 REG_WR(bp
, emac_base
+ EMAC_REG_EMAC_LED
, reg_val
);
5672 case 3: /* 2500MB led */
5673 /* Read the current value of the LED register in the
5675 reg_val
= REG_RD(bp
, emac_base
+ EMAC_REG_EMAC_LED
);
5676 /* Set the OVERRIDE bit to 1 */
5677 reg_val
|= EMAC_LED_OVERRIDE
;
5678 /* If value is 1, set the 2500M_OVERRIDE bit, otherwise
5680 reg_val
= (value
== 1) ? (reg_val
| EMAC_LED_2500MB_OVERRIDE
) :
5681 (reg_val
& ~EMAC_LED_2500MB_OVERRIDE
);
5682 REG_WR(bp
, emac_base
+ EMAC_REG_EMAC_LED
, reg_val
);
5684 case 4: /*10G led */
5686 REG_WR(bp
, NIG_REG_LED_10G_P0
,
5689 REG_WR(bp
, NIG_REG_LED_10G_P1
,
5693 case 5: /* TRAFFIC led */
5694 /* Find if the traffic control is via BMAC or EMAC */
5696 reg_val
= REG_RD(bp
, NIG_REG_NIG_EMAC0_EN
);
5698 reg_val
= REG_RD(bp
, NIG_REG_NIG_EMAC1_EN
);
5700 /* Override the traffic led in the EMAC:*/
5702 /* Read the current value of the LED register in
5704 reg_val
= REG_RD(bp
, emac_base
+
5706 /* Set the TRAFFIC_OVERRIDE bit to 1 */
5707 reg_val
|= EMAC_LED_OVERRIDE
;
5708 /* If value is 1, set the TRAFFIC bit, otherwise
5710 reg_val
= (value
== 1) ? (reg_val
| EMAC_LED_TRAFFIC
) :
5711 (reg_val
& ~EMAC_LED_TRAFFIC
);
5712 REG_WR(bp
, emac_base
+ EMAC_REG_EMAC_LED
, reg_val
);
5713 } else { /* Override the traffic led in the BMAC: */
5714 REG_WR(bp
, NIG_REG_LED_CONTROL_OVERRIDE_TRAFFIC_P0
5716 REG_WR(bp
, NIG_REG_LED_CONTROL_TRAFFIC_P0
+ port
*4,
5722 "bnx2x_override_led_value() unknown led index %d "
5723 "(should be 0-5)\n", led_idx
);
5731 u8
bnx2x_set_led(struct bnx2x
*bp
, u8 port
, u8 mode
, u32 speed
,
5732 u16 hw_led_mode
, u32 chip_id
)
5736 u32 emac_base
= port
? GRCBASE_EMAC1
: GRCBASE_EMAC0
;
5738 DP(NETIF_MSG_LINK
, "bnx2x_set_led: port %x, mode %d\n", port
, mode
);
5739 DP(NETIF_MSG_LINK
, "speed 0x%x, hw_led_mode 0x%x\n",
5740 speed
, hw_led_mode
);
5743 REG_WR(bp
, NIG_REG_LED_10G_P0
+ port
*4, 0);
5744 REG_WR(bp
, NIG_REG_LED_MODE_P0
+ port
*4,
5745 SHARED_HW_CFG_LED_MAC1
);
5747 tmp
= EMAC_RD(bp
, EMAC_REG_EMAC_LED
);
5748 EMAC_WR(bp
, EMAC_REG_EMAC_LED
, (tmp
| EMAC_LED_OVERRIDE
));
5752 REG_WR(bp
, NIG_REG_LED_MODE_P0
+ port
*4, hw_led_mode
);
5753 REG_WR(bp
, NIG_REG_LED_CONTROL_OVERRIDE_TRAFFIC_P0
+
5755 /* Set blinking rate to ~15.9Hz */
5756 REG_WR(bp
, NIG_REG_LED_CONTROL_BLINK_RATE_P0
+ port
*4,
5757 LED_BLINK_RATE_VAL
);
5758 REG_WR(bp
, NIG_REG_LED_CONTROL_BLINK_RATE_ENA_P0
+
5760 tmp
= EMAC_RD(bp
, EMAC_REG_EMAC_LED
);
5761 EMAC_WR(bp
, EMAC_REG_EMAC_LED
,
5762 (tmp
& (~EMAC_LED_OVERRIDE
)));
5764 if (!CHIP_IS_E1H(bp
) &&
5765 ((speed
== SPEED_2500
) ||
5766 (speed
== SPEED_1000
) ||
5767 (speed
== SPEED_100
) ||
5768 (speed
== SPEED_10
))) {
5769 /* On Everest 1 Ax chip versions for speeds less than
5770 10G LED scheme is different */
5771 REG_WR(bp
, NIG_REG_LED_CONTROL_OVERRIDE_TRAFFIC_P0
5773 REG_WR(bp
, NIG_REG_LED_CONTROL_TRAFFIC_P0
+
5775 REG_WR(bp
, NIG_REG_LED_CONTROL_BLINK_TRAFFIC_P0
+
5782 DP(NETIF_MSG_LINK
, "bnx2x_set_led: Invalid led mode %d\n",
5790 u8
bnx2x_test_link(struct link_params
*params
, struct link_vars
*vars
)
5792 struct bnx2x
*bp
= params
->bp
;
5795 CL45_RD_OVER_CL22(bp
, params
->port
,
5797 MDIO_REG_BANK_GP_STATUS
,
5798 MDIO_GP_STATUS_TOP_AN_STATUS1
,
5800 /* link is up only if both local phy and external phy are up */
5801 if ((gp_status
& MDIO_GP_STATUS_TOP_AN_STATUS1_LINK_STATUS
) &&
5802 bnx2x_ext_phy_is_link_up(params
, vars
, 1))
5808 static u8
bnx2x_link_initialize(struct link_params
*params
,
5809 struct link_vars
*vars
)
5811 struct bnx2x
*bp
= params
->bp
;
5812 u8 port
= params
->port
;
5815 u32 ext_phy_type
= XGXS_EXT_PHY_TYPE(params
->ext_phy_config
);
5817 /* Activate the external PHY */
5818 bnx2x_ext_phy_reset(params
, vars
);
5820 bnx2x_set_aer_mmd(params
, vars
);
5822 if (vars
->phy_flags
& PHY_XGXS_FLAG
)
5823 bnx2x_set_master_ln(params
);
5825 rc
= bnx2x_reset_unicore(params
);
5826 /* reset the SerDes and wait for reset bit return low */
5830 bnx2x_set_aer_mmd(params
, vars
);
5832 /* setting the masterLn_def again after the reset */
5833 if (vars
->phy_flags
& PHY_XGXS_FLAG
) {
5834 bnx2x_set_master_ln(params
);
5835 bnx2x_set_swap_lanes(params
);
5838 if (vars
->phy_flags
& PHY_XGXS_FLAG
) {
5839 if ((params
->req_line_speed
&&
5840 ((params
->req_line_speed
== SPEED_100
) ||
5841 (params
->req_line_speed
== SPEED_10
))) ||
5842 (!params
->req_line_speed
&&
5843 (params
->speed_cap_mask
>=
5844 PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_FULL
) &&
5845 (params
->speed_cap_mask
<
5846 PORT_HW_CFG_SPEED_CAPABILITY_D0_1G
)
5848 vars
->phy_flags
|= PHY_SGMII_FLAG
;
5850 vars
->phy_flags
&= ~PHY_SGMII_FLAG
;
5853 /* In case of external phy existance, the line speed would be the
5854 line speed linked up by the external phy. In case it is direct only,
5855 then the line_speed during initialization will be equal to the
5857 vars
->line_speed
= params
->req_line_speed
;
5859 bnx2x_calc_ieee_aneg_adv(params
, &vars
->ieee_fc
);
5861 /* init ext phy and enable link state int */
5862 non_ext_phy
= ((ext_phy_type
== PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT
) ||
5863 (params
->loopback_mode
== LOOPBACK_XGXS_10
));
5866 (ext_phy_type
== PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8705
) ||
5867 (ext_phy_type
== PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726
) ||
5868 (params
->loopback_mode
== LOOPBACK_EXT_PHY
)) {
5869 if (params
->req_line_speed
== SPEED_AUTO_NEG
)
5870 bnx2x_set_parallel_detection(params
, vars
->phy_flags
);
5871 bnx2x_init_internal_phy(params
, vars
, non_ext_phy
);
5875 rc
|= bnx2x_ext_phy_init(params
, vars
);
5877 bnx2x_bits_dis(bp
, NIG_REG_STATUS_INTERRUPT_PORT0
+ port
*4,
5878 (NIG_STATUS_XGXS0_LINK10G
|
5879 NIG_STATUS_XGXS0_LINK_STATUS
|
5880 NIG_STATUS_SERDES0_LINK_STATUS
));
5887 u8
bnx2x_phy_init(struct link_params
*params
, struct link_vars
*vars
)
5889 struct bnx2x
*bp
= params
->bp
;
5892 DP(NETIF_MSG_LINK
, "Phy Initialization started\n");
5893 DP(NETIF_MSG_LINK
, "req_speed %d, req_flowctrl %d\n",
5894 params
->req_line_speed
, params
->req_flow_ctrl
);
5895 vars
->link_status
= 0;
5896 vars
->phy_link_up
= 0;
5898 vars
->line_speed
= 0;
5899 vars
->duplex
= DUPLEX_FULL
;
5900 vars
->flow_ctrl
= BNX2X_FLOW_CTRL_NONE
;
5901 vars
->mac_type
= MAC_TYPE_NONE
;
5903 if (params
->switch_cfg
== SWITCH_CFG_1G
)
5904 vars
->phy_flags
= PHY_SERDES_FLAG
;
5906 vars
->phy_flags
= PHY_XGXS_FLAG
;
5908 /* disable attentions */
5909 bnx2x_bits_dis(bp
, NIG_REG_MASK_INTERRUPT_PORT0
+ params
->port
*4,
5910 (NIG_MASK_XGXS0_LINK_STATUS
|
5911 NIG_MASK_XGXS0_LINK10G
|
5912 NIG_MASK_SERDES0_LINK_STATUS
|
5915 bnx2x_emac_init(params
, vars
);
5917 if (CHIP_REV_IS_FPGA(bp
)) {
5920 vars
->line_speed
= SPEED_10000
;
5921 vars
->duplex
= DUPLEX_FULL
;
5922 vars
->flow_ctrl
= BNX2X_FLOW_CTRL_NONE
;
5923 vars
->link_status
= (LINK_STATUS_LINK_UP
| LINK_10GTFD
);
5924 /* enable on E1.5 FPGA */
5925 if (CHIP_IS_E1H(bp
)) {
5927 (BNX2X_FLOW_CTRL_TX
|
5928 BNX2X_FLOW_CTRL_RX
);
5929 vars
->link_status
|=
5930 (LINK_STATUS_TX_FLOW_CONTROL_ENABLED
|
5931 LINK_STATUS_RX_FLOW_CONTROL_ENABLED
);
5934 bnx2x_emac_enable(params
, vars
, 0);
5935 bnx2x_pbf_update(params
, vars
->flow_ctrl
, vars
->line_speed
);
5937 REG_WR(bp
, NIG_REG_EGRESS_DRAIN0_MODE
+ params
->port
*4, 0);
5939 /* update shared memory */
5940 bnx2x_update_mng(params
, vars
->link_status
);
5945 if (CHIP_REV_IS_EMUL(bp
)) {
5948 vars
->line_speed
= SPEED_10000
;
5949 vars
->duplex
= DUPLEX_FULL
;
5950 vars
->flow_ctrl
= BNX2X_FLOW_CTRL_NONE
;
5951 vars
->link_status
= (LINK_STATUS_LINK_UP
| LINK_10GTFD
);
5953 bnx2x_bmac_enable(params
, vars
, 0);
5955 bnx2x_pbf_update(params
, vars
->flow_ctrl
, vars
->line_speed
);
5957 REG_WR(bp
, NIG_REG_EGRESS_DRAIN0_MODE
5958 + params
->port
*4, 0);
5960 /* update shared memory */
5961 bnx2x_update_mng(params
, vars
->link_status
);
5966 if (params
->loopback_mode
== LOOPBACK_BMAC
) {
5969 vars
->line_speed
= SPEED_10000
;
5970 vars
->duplex
= DUPLEX_FULL
;
5971 vars
->flow_ctrl
= BNX2X_FLOW_CTRL_NONE
;
5972 vars
->mac_type
= MAC_TYPE_BMAC
;
5974 vars
->phy_flags
= PHY_XGXS_FLAG
;
5976 bnx2x_phy_deassert(params
, vars
->phy_flags
);
5977 /* set bmac loopback */
5978 bnx2x_bmac_enable(params
, vars
, 1);
5980 REG_WR(bp
, NIG_REG_EGRESS_DRAIN0_MODE
+
5983 } else if (params
->loopback_mode
== LOOPBACK_EMAC
) {
5986 vars
->line_speed
= SPEED_1000
;
5987 vars
->duplex
= DUPLEX_FULL
;
5988 vars
->flow_ctrl
= BNX2X_FLOW_CTRL_NONE
;
5989 vars
->mac_type
= MAC_TYPE_EMAC
;
5991 vars
->phy_flags
= PHY_XGXS_FLAG
;
5993 bnx2x_phy_deassert(params
, vars
->phy_flags
);
5994 /* set bmac loopback */
5995 bnx2x_emac_enable(params
, vars
, 1);
5996 bnx2x_emac_program(params
, vars
->line_speed
,
5998 REG_WR(bp
, NIG_REG_EGRESS_DRAIN0_MODE
+
6001 } else if ((params
->loopback_mode
== LOOPBACK_XGXS_10
) ||
6002 (params
->loopback_mode
== LOOPBACK_EXT_PHY
)) {
6005 vars
->line_speed
= SPEED_10000
;
6006 vars
->duplex
= DUPLEX_FULL
;
6007 vars
->flow_ctrl
= BNX2X_FLOW_CTRL_NONE
;
6009 vars
->phy_flags
= PHY_XGXS_FLAG
;
6012 NIG_REG_XGXS0_CTRL_PHY_ADDR
+
6014 params
->phy_addr
= (u8
)val
;
6016 bnx2x_phy_deassert(params
, vars
->phy_flags
);
6017 bnx2x_link_initialize(params
, vars
);
6019 vars
->mac_type
= MAC_TYPE_BMAC
;
6021 bnx2x_bmac_enable(params
, vars
, 0);
6023 if (params
->loopback_mode
== LOOPBACK_XGXS_10
) {
6024 /* set 10G XGXS loopback */
6025 bnx2x_set_xgxs_loopback(params
, vars
, 1);
6027 /* set external phy loopback */
6028 bnx2x_ext_phy_loopback(params
);
6030 REG_WR(bp
, NIG_REG_EGRESS_DRAIN0_MODE
+
6033 bnx2x_set_led(bp
, params
->port
, LED_MODE_OPER
,
6034 vars
->line_speed
, params
->hw_led_mode
,
6040 bnx2x_phy_deassert(params
, vars
->phy_flags
);
6041 switch (params
->switch_cfg
) {
6043 vars
->phy_flags
|= PHY_SERDES_FLAG
;
6044 if ((params
->ext_phy_config
&
6045 PORT_HW_CFG_SERDES_EXT_PHY_TYPE_MASK
) ==
6046 PORT_HW_CFG_SERDES_EXT_PHY_TYPE_BCM5482
) {
6047 vars
->phy_flags
|= PHY_SGMII_FLAG
;
6051 NIG_REG_SERDES0_CTRL_PHY_ADDR
+
6054 params
->phy_addr
= (u8
)val
;
6057 case SWITCH_CFG_10G
:
6058 vars
->phy_flags
|= PHY_XGXS_FLAG
;
6060 NIG_REG_XGXS0_CTRL_PHY_ADDR
+
6062 params
->phy_addr
= (u8
)val
;
6066 DP(NETIF_MSG_LINK
, "Invalid switch_cfg\n");
6069 DP(NETIF_MSG_LINK
, "Phy address = 0x%x\n", params
->phy_addr
);
6071 bnx2x_link_initialize(params
, vars
);
6073 bnx2x_link_int_enable(params
);
6078 static void bnx2x_8726_reset_phy(struct bnx2x
*bp
, u8 port
, u8 ext_phy_addr
)
6080 DP(NETIF_MSG_LINK
, "bnx2x_8726_reset_phy port %d\n", port
);
6082 /* Set serial boot control for external load */
6083 bnx2x_cl45_write(bp
, port
,
6084 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726
, ext_phy_addr
,
6086 MDIO_PMA_REG_GEN_CTRL
, 0x0001);
6089 u8
bnx2x_link_reset(struct link_params
*params
, struct link_vars
*vars
,
6092 struct bnx2x
*bp
= params
->bp
;
6093 u32 ext_phy_config
= params
->ext_phy_config
;
6094 u16 hw_led_mode
= params
->hw_led_mode
;
6095 u32 chip_id
= params
->chip_id
;
6096 u8 port
= params
->port
;
6097 u32 ext_phy_type
= XGXS_EXT_PHY_TYPE(ext_phy_config
);
6098 u32 val
= REG_RD(bp
, params
->shmem_base
+
6099 offsetof(struct shmem_region
, dev_info
.
6100 port_feature_config
[params
->port
].
6103 /* disable attentions */
6104 vars
->link_status
= 0;
6105 bnx2x_update_mng(params
, vars
->link_status
);
6106 bnx2x_bits_dis(bp
, NIG_REG_MASK_INTERRUPT_PORT0
+ port
*4,
6107 (NIG_MASK_XGXS0_LINK_STATUS
|
6108 NIG_MASK_XGXS0_LINK10G
|
6109 NIG_MASK_SERDES0_LINK_STATUS
|
6112 /* activate nig drain */
6113 REG_WR(bp
, NIG_REG_EGRESS_DRAIN0_MODE
+ port
*4, 1);
6115 /* disable nig egress interface */
6116 REG_WR(bp
, NIG_REG_BMAC0_OUT_EN
+ port
*4, 0);
6117 REG_WR(bp
, NIG_REG_EGRESS_EMAC0_OUT_EN
+ port
*4, 0);
6119 /* Stop BigMac rx */
6120 bnx2x_bmac_rx_disable(bp
, port
);
6123 REG_WR(bp
, NIG_REG_NIG_EMAC0_EN
+ port
*4, 0);
6126 /* The PHY reset is controled by GPIO 1
6127 * Hold it as vars low
6129 /* clear link led */
6130 bnx2x_set_led(bp
, port
, LED_MODE_OFF
, 0, hw_led_mode
, chip_id
);
6131 if (reset_ext_phy
) {
6132 switch (ext_phy_type
) {
6133 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT
:
6134 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8072
:
6137 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727
:
6140 /* Disable Transmitter */
6142 XGXS_EXT_PHY_ADDR(params
->ext_phy_config
);
6143 if ((val
& PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK
) ==
6144 PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_DISABLE_TX_LASER
)
6145 bnx2x_sfp_set_transmitter(bp
, port
,
6146 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727
,
6150 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073
:
6151 DP(NETIF_MSG_LINK
, "Setting 8073 port %d into "
6154 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_2
,
6155 MISC_REGISTERS_GPIO_OUTPUT_LOW
,
6158 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726
:
6161 XGXS_EXT_PHY_ADDR(params
->ext_phy_config
);
6162 /* Set soft reset */
6163 bnx2x_8726_reset_phy(bp
, params
->port
, ext_phy_addr
);
6168 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_1
,
6169 MISC_REGISTERS_GPIO_OUTPUT_LOW
,
6171 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_2
,
6172 MISC_REGISTERS_GPIO_OUTPUT_LOW
,
6174 DP(NETIF_MSG_LINK
, "reset external PHY\n");
6177 /* reset the SerDes/XGXS */
6178 REG_WR(bp
, GRCBASE_MISC
+ MISC_REGISTERS_RESET_REG_3_CLEAR
,
6179 (0x1ff << (port
*16)));
6182 REG_WR(bp
, GRCBASE_MISC
+ MISC_REGISTERS_RESET_REG_2_CLEAR
,
6183 (MISC_REGISTERS_RESET_REG_2_RST_BMAC0
<< port
));
6185 /* disable nig ingress interface */
6186 REG_WR(bp
, NIG_REG_BMAC0_IN_EN
+ port
*4, 0);
6187 REG_WR(bp
, NIG_REG_EMAC0_IN_EN
+ port
*4, 0);
6188 REG_WR(bp
, NIG_REG_BMAC0_OUT_EN
+ port
*4, 0);
6189 REG_WR(bp
, NIG_REG_EGRESS_EMAC0_OUT_EN
+ port
*4, 0);
6194 static u8
bnx2x_update_link_down(struct link_params
*params
,
6195 struct link_vars
*vars
)
6197 struct bnx2x
*bp
= params
->bp
;
6198 u8 port
= params
->port
;
6200 DP(NETIF_MSG_LINK
, "Port %x: Link is down\n", port
);
6201 bnx2x_set_led(bp
, port
, LED_MODE_OFF
,
6202 0, params
->hw_led_mode
,
6205 /* indicate no mac active */
6206 vars
->mac_type
= MAC_TYPE_NONE
;
6208 /* update shared memory */
6209 vars
->link_status
= 0;
6210 vars
->line_speed
= 0;
6211 bnx2x_update_mng(params
, vars
->link_status
);
6213 /* activate nig drain */
6214 REG_WR(bp
, NIG_REG_EGRESS_DRAIN0_MODE
+ port
*4, 1);
6217 REG_WR(bp
, NIG_REG_NIG_EMAC0_EN
+ port
*4, 0);
6222 bnx2x_bmac_rx_disable(bp
, params
->port
);
6223 REG_WR(bp
, GRCBASE_MISC
+
6224 MISC_REGISTERS_RESET_REG_2_CLEAR
,
6225 (MISC_REGISTERS_RESET_REG_2_RST_BMAC0
<< port
));
6229 static u8
bnx2x_update_link_up(struct link_params
*params
,
6230 struct link_vars
*vars
,
6231 u8 link_10g
, u32 gp_status
)
6233 struct bnx2x
*bp
= params
->bp
;
6234 u8 port
= params
->port
;
6237 vars
->link_status
|= LINK_STATUS_LINK_UP
;
6239 bnx2x_bmac_enable(params
, vars
, 0);
6240 bnx2x_set_led(bp
, port
, LED_MODE_OPER
,
6241 SPEED_10000
, params
->hw_led_mode
,
6245 bnx2x_emac_enable(params
, vars
, 0);
6246 rc
= bnx2x_emac_program(params
, vars
->line_speed
,
6250 if (gp_status
& MDIO_AN_CL73_OR_37_COMPLETE
) {
6251 if (!(vars
->phy_flags
&
6253 bnx2x_set_gmii_tx_driver(params
);
6258 rc
|= bnx2x_pbf_update(params
, vars
->flow_ctrl
,
6262 REG_WR(bp
, NIG_REG_EGRESS_DRAIN0_MODE
+ port
*4, 0);
6264 /* update shared memory */
6265 bnx2x_update_mng(params
, vars
->link_status
);
6269 /* This function should called upon link interrupt */
6270 /* In case vars->link_up, driver needs to
6273 3. Update the shared memory
6277 1. Update shared memory
6282 u8
bnx2x_link_update(struct link_params
*params
, struct link_vars
*vars
)
6284 struct bnx2x
*bp
= params
->bp
;
6285 u8 port
= params
->port
;
6288 u8 ext_phy_link_up
, rc
= 0;
6292 DP(NETIF_MSG_LINK
, "port %x, XGXS?%x, int_status 0x%x\n",
6293 port
, (vars
->phy_flags
& PHY_XGXS_FLAG
),
6294 REG_RD(bp
, NIG_REG_STATUS_INTERRUPT_PORT0
+ port
*4));
6296 is_mi_int
= (u8
)(REG_RD(bp
, NIG_REG_EMAC0_STATUS_MISC_MI_INT
+
6298 DP(NETIF_MSG_LINK
, "int_mask 0x%x MI_INT %x, SERDES_LINK %x\n",
6299 REG_RD(bp
, NIG_REG_MASK_INTERRUPT_PORT0
+ port
*4),
6302 NIG_REG_SERDES0_STATUS_LINK_STATUS
+ port
*0x3c));
6304 DP(NETIF_MSG_LINK
, " 10G %x, XGXS_LINK %x\n",
6305 REG_RD(bp
, NIG_REG_XGXS0_STATUS_LINK10G
+ port
*0x68),
6306 REG_RD(bp
, NIG_REG_XGXS0_STATUS_LINK_STATUS
+ port
*0x68));
6309 REG_WR(bp
, NIG_REG_NIG_EMAC0_EN
+ port
*4, 0);
6311 ext_phy_type
= XGXS_EXT_PHY_TYPE(params
->ext_phy_config
);
6313 /* Check external link change only for non-direct */
6314 ext_phy_link_up
= bnx2x_ext_phy_is_link_up(params
, vars
, is_mi_int
);
6316 /* Read gp_status */
6317 CL45_RD_OVER_CL22(bp
, port
, params
->phy_addr
,
6318 MDIO_REG_BANK_GP_STATUS
,
6319 MDIO_GP_STATUS_TOP_AN_STATUS1
,
6322 rc
= bnx2x_link_settings_status(params
, vars
, gp_status
,
6327 /* anything 10 and over uses the bmac */
6328 link_10g
= ((vars
->line_speed
== SPEED_10000
) ||
6329 (vars
->line_speed
== SPEED_12000
) ||
6330 (vars
->line_speed
== SPEED_12500
) ||
6331 (vars
->line_speed
== SPEED_13000
) ||
6332 (vars
->line_speed
== SPEED_15000
) ||
6333 (vars
->line_speed
== SPEED_16000
));
6335 bnx2x_link_int_ack(params
, vars
, link_10g
, is_mi_int
);
6337 /* In case external phy link is up, and internal link is down
6338 ( not initialized yet probably after link initialization, it needs
6340 Note that after link down-up as result of cable plug,
6341 the xgxs link would probably become up again without the need to
6344 if ((ext_phy_type
!= PORT_HW_CFG_SERDES_EXT_PHY_TYPE_DIRECT
) &&
6345 (ext_phy_type
!= PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8705
) &&
6346 (ext_phy_type
!= PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726
) &&
6347 (ext_phy_link_up
&& !vars
->phy_link_up
))
6348 bnx2x_init_internal_phy(params
, vars
, 0);
6350 /* link is up only if both local phy and external phy are up */
6351 vars
->link_up
= (ext_phy_link_up
&& vars
->phy_link_up
);
6354 rc
= bnx2x_update_link_up(params
, vars
, link_10g
, gp_status
);
6356 rc
= bnx2x_update_link_down(params
, vars
);
6361 static u8
bnx2x_8073_common_init_phy(struct bnx2x
*bp
, u32 shmem_base
)
6363 u8 ext_phy_addr
[PORT_MAX
];
6367 /* PART1 - Reset both phys */
6368 for (port
= PORT_MAX
- 1; port
>= PORT_0
; port
--) {
6369 /* Extract the ext phy address for the port */
6370 u32 ext_phy_config
= REG_RD(bp
, shmem_base
+
6371 offsetof(struct shmem_region
,
6372 dev_info
.port_hw_config
[port
].external_phy_config
));
6374 /* disable attentions */
6375 bnx2x_bits_dis(bp
, NIG_REG_MASK_INTERRUPT_PORT0
+ port
*4,
6376 (NIG_MASK_XGXS0_LINK_STATUS
|
6377 NIG_MASK_XGXS0_LINK10G
|
6378 NIG_MASK_SERDES0_LINK_STATUS
|
6381 ext_phy_addr
[port
] = XGXS_EXT_PHY_ADDR(ext_phy_config
);
6383 /* Need to take the phy out of low power mode in order
6384 to write to access its registers */
6385 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_2
,
6386 MISC_REGISTERS_GPIO_OUTPUT_HIGH
, port
);
6389 bnx2x_cl45_write(bp
, port
,
6390 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073
,
6397 /* Add delay of 150ms after reset */
6400 /* PART2 - Download firmware to both phys */
6401 for (port
= PORT_MAX
- 1; port
>= PORT_0
; port
--) {
6404 bnx2x_bcm8073_external_rom_boot(bp
, port
,
6405 ext_phy_addr
[port
], shmem_base
);
6407 bnx2x_cl45_read(bp
, port
, PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073
,
6410 MDIO_PMA_REG_ROM_VER1
, &fw_ver1
);
6411 if (fw_ver1
== 0 || fw_ver1
== 0x4321) {
6413 "bnx2x_8073_common_init_phy port %x:"
6414 "Download failed. fw version = 0x%x\n",
6419 /* Only set bit 10 = 1 (Tx power down) */
6420 bnx2x_cl45_read(bp
, port
,
6421 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073
,
6424 MDIO_PMA_REG_TX_POWER_DOWN
, &val
);
6426 /* Phase1 of TX_POWER_DOWN reset */
6427 bnx2x_cl45_write(bp
, port
,
6428 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073
,
6431 MDIO_PMA_REG_TX_POWER_DOWN
,
6435 /* Toggle Transmitter: Power down and then up with 600ms
6439 /* PART3 - complete TX_POWER_DOWN process, and set GPIO2 back to low */
6440 for (port
= PORT_MAX
- 1; port
>= PORT_0
; port
--) {
6441 /* Phase2 of POWER_DOWN_RESET */
6442 /* Release bit 10 (Release Tx power down) */
6443 bnx2x_cl45_read(bp
, port
,
6444 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073
,
6447 MDIO_PMA_REG_TX_POWER_DOWN
, &val
);
6449 bnx2x_cl45_write(bp
, port
,
6450 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073
,
6453 MDIO_PMA_REG_TX_POWER_DOWN
, (val
& (~(1<<10))));
6456 /* Read modify write the SPI-ROM version select register */
6457 bnx2x_cl45_read(bp
, port
,
6458 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073
,
6461 MDIO_PMA_REG_EDC_FFE_MAIN
, &val
);
6462 bnx2x_cl45_write(bp
, port
,
6463 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073
,
6466 MDIO_PMA_REG_EDC_FFE_MAIN
, (val
| (1<<12)));
6468 /* set GPIO2 back to LOW */
6469 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_2
,
6470 MISC_REGISTERS_GPIO_OUTPUT_LOW
, port
);
6476 static u8
bnx2x_8727_common_init_phy(struct bnx2x
*bp
, u32 shmem_base
)
6478 u8 ext_phy_addr
[PORT_MAX
];
6479 s8 port
, first_port
, i
;
6480 u32 swap_val
, swap_override
;
6481 DP(NETIF_MSG_LINK
, "Executing BCM8727 common init\n");
6482 swap_val
= REG_RD(bp
, NIG_REG_PORT_SWAP
);
6483 swap_override
= REG_RD(bp
, NIG_REG_STRAP_OVERRIDE
);
6485 bnx2x_ext_phy_hw_reset(bp
, 1 ^ (swap_val
&& swap_override
));
6488 if (swap_val
&& swap_override
)
6489 first_port
= PORT_0
;
6491 first_port
= PORT_1
;
6493 /* PART1 - Reset both phys */
6494 for (i
= 0, port
= first_port
; i
< PORT_MAX
; i
++, port
= !port
) {
6495 /* Extract the ext phy address for the port */
6496 u32 ext_phy_config
= REG_RD(bp
, shmem_base
+
6497 offsetof(struct shmem_region
,
6498 dev_info
.port_hw_config
[port
].external_phy_config
));
6500 /* disable attentions */
6501 bnx2x_bits_dis(bp
, NIG_REG_MASK_INTERRUPT_PORT0
+ port
*4,
6502 (NIG_MASK_XGXS0_LINK_STATUS
|
6503 NIG_MASK_XGXS0_LINK10G
|
6504 NIG_MASK_SERDES0_LINK_STATUS
|
6507 ext_phy_addr
[port
] = XGXS_EXT_PHY_ADDR(ext_phy_config
);
6510 bnx2x_cl45_write(bp
, port
,
6511 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727
,
6518 /* Add delay of 150ms after reset */
6521 /* PART2 - Download firmware to both phys */
6522 for (i
= 0, port
= first_port
; i
< PORT_MAX
; i
++, port
= !port
) {
6525 bnx2x_bcm8727_external_rom_boot(bp
, port
,
6526 ext_phy_addr
[port
], shmem_base
);
6528 bnx2x_cl45_read(bp
, port
, PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727
,
6531 MDIO_PMA_REG_ROM_VER1
, &fw_ver1
);
6532 if (fw_ver1
== 0 || fw_ver1
== 0x4321) {
6534 "bnx2x_8727_common_init_phy port %x:"
6535 "Download failed. fw version = 0x%x\n",
6545 static u8
bnx2x_8726_common_init_phy(struct bnx2x
*bp
, u32 shmem_base
)
6551 /* Use port1 because of the static port-swap */
6552 /* Enable the module detection interrupt */
6553 val
= REG_RD(bp
, MISC_REG_GPIO_EVENT_EN
);
6554 val
|= ((1<<MISC_REGISTERS_GPIO_3
)|
6555 (1<<(MISC_REGISTERS_GPIO_3
+ MISC_REGISTERS_GPIO_PORT_SHIFT
)));
6556 REG_WR(bp
, MISC_REG_GPIO_EVENT_EN
, val
);
6558 bnx2x_ext_phy_hw_reset(bp
, 1);
6560 for (port
= 0; port
< PORT_MAX
; port
++) {
6561 /* Extract the ext phy address for the port */
6562 u32 ext_phy_config
= REG_RD(bp
, shmem_base
+
6563 offsetof(struct shmem_region
,
6564 dev_info
.port_hw_config
[port
].external_phy_config
));
6566 ext_phy_addr
= XGXS_EXT_PHY_ADDR(ext_phy_config
);
6567 DP(NETIF_MSG_LINK
, "8726_common_init : ext_phy_addr = 0x%x\n",
6570 bnx2x_8726_reset_phy(bp
, port
, ext_phy_addr
);
6572 /* Set fault module detected LED on */
6573 bnx2x_set_gpio(bp
, MISC_REGISTERS_GPIO_0
,
6574 MISC_REGISTERS_GPIO_HIGH
,
6581 u8
bnx2x_common_init_phy(struct bnx2x
*bp
, u32 shmem_base
)
6586 DP(NETIF_MSG_LINK
, "Begin common phy init\n");
6588 /* Read the ext_phy_type for arbitrary port(0) */
6589 ext_phy_type
= XGXS_EXT_PHY_TYPE(
6590 REG_RD(bp
, shmem_base
+
6591 offsetof(struct shmem_region
,
6592 dev_info
.port_hw_config
[0].external_phy_config
)));
6594 switch (ext_phy_type
) {
6595 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073
:
6597 rc
= bnx2x_8073_common_init_phy(bp
, shmem_base
);
6601 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727
:
6602 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727_NOC
:
6603 rc
= bnx2x_8727_common_init_phy(bp
, shmem_base
);
6606 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726
:
6607 /* GPIO1 affects both ports, so there's need to pull
6608 it for single port alone */
6609 rc
= bnx2x_8726_common_init_phy(bp
, shmem_base
);
6614 "bnx2x_common_init_phy: ext_phy 0x%x not required\n",
6622 void bnx2x_sfx7101_sp_sw_reset(struct bnx2x
*bp
, u8 port
, u8 phy_addr
)
6626 bnx2x_cl45_read(bp
, port
,
6627 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_SFX7101
,
6630 MDIO_PMA_REG_7101_RESET
, &val
);
6632 for (cnt
= 0; cnt
< 10; cnt
++) {
6634 /* Writes a self-clearing reset */
6635 bnx2x_cl45_write(bp
, port
,
6636 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_SFX7101
,
6639 MDIO_PMA_REG_7101_RESET
,
6641 /* Wait for clear */
6642 bnx2x_cl45_read(bp
, port
,
6643 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_SFX7101
,
6646 MDIO_PMA_REG_7101_RESET
, &val
);
6648 if ((val
& (1<<15)) == 0)