Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1 | /* Copyright 2008-2011 Broadcom Corporation |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2 | * |
| 3 | * Unless you and Broadcom execute a separate written software license |
| 4 | * agreement governing use of this software, this software is licensed to you |
| 5 | * under the terms of the GNU General Public License version 2, available |
| 6 | * at http://www.gnu.org/licenses/old-licenses/gpl-2.0.html (the "GPL"). |
| 7 | * |
| 8 | * Notwithstanding the above, under no circumstances may you combine this |
| 9 | * software in any way with any other Broadcom software provided under a |
| 10 | * license other than the GPL, without Broadcom's express prior written |
| 11 | * consent. |
| 12 | * |
| 13 | * Written by Yaniv Rosner |
| 14 | * |
| 15 | */ |
| 16 | |
Joe Perches | 7995c64 | 2010-02-17 15:01:52 +0000 | [diff] [blame] | 17 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 18 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 19 | #include <linux/kernel.h> |
| 20 | #include <linux/errno.h> |
| 21 | #include <linux/pci.h> |
| 22 | #include <linux/netdevice.h> |
| 23 | #include <linux/delay.h> |
| 24 | #include <linux/ethtool.h> |
| 25 | #include <linux/mutex.h> |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 26 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 27 | #include "bnx2x.h" |
Vlad Zolotarov | 619c5cb | 2011-06-14 14:33:44 +0300 | [diff] [blame] | 28 | #include "bnx2x_cmn.h" |
| 29 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 30 | |
| 31 | /********************************************************/ |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 32 | #define ETH_HLEN 14 |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 33 | /* L2 header size + 2*VLANs (8 bytes) + LLC SNAP (8 bytes) */ |
| 34 | #define ETH_OVREHEAD (ETH_HLEN + 8 + 8) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 35 | #define ETH_MIN_PACKET_SIZE 60 |
| 36 | #define ETH_MAX_PACKET_SIZE 1500 |
| 37 | #define ETH_MAX_JUMBO_PACKET_SIZE 9600 |
| 38 | #define MDIO_ACCESS_TIMEOUT 1000 |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 39 | #define BMAC_CONTROL_RX_ENABLE 2 |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 40 | #define WC_LANE_MAX 4 |
| 41 | #define I2C_SWITCH_WIDTH 2 |
| 42 | #define I2C_BSC0 0 |
| 43 | #define I2C_BSC1 1 |
| 44 | #define I2C_WA_RETRY_CNT 3 |
| 45 | #define MCPR_IMC_COMMAND_READ_OP 1 |
| 46 | #define MCPR_IMC_COMMAND_WRITE_OP 2 |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 47 | |
| 48 | /***********************************************************/ |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 49 | /* Shortcut definitions */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 50 | /***********************************************************/ |
| 51 | |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 52 | #define NIG_LATCH_BC_ENABLE_MI_INT 0 |
| 53 | |
| 54 | #define NIG_STATUS_EMAC0_MI_INT \ |
| 55 | NIG_STATUS_INTERRUPT_PORT0_REG_STATUS_EMAC0_MISC_MI_INT |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 56 | #define NIG_STATUS_XGXS0_LINK10G \ |
| 57 | NIG_STATUS_INTERRUPT_PORT0_REG_STATUS_XGXS0_LINK10G |
| 58 | #define NIG_STATUS_XGXS0_LINK_STATUS \ |
| 59 | NIG_STATUS_INTERRUPT_PORT0_REG_STATUS_XGXS0_LINK_STATUS |
| 60 | #define NIG_STATUS_XGXS0_LINK_STATUS_SIZE \ |
| 61 | NIG_STATUS_INTERRUPT_PORT0_REG_STATUS_XGXS0_LINK_STATUS_SIZE |
| 62 | #define NIG_STATUS_SERDES0_LINK_STATUS \ |
| 63 | NIG_STATUS_INTERRUPT_PORT0_REG_STATUS_SERDES0_LINK_STATUS |
| 64 | #define NIG_MASK_MI_INT \ |
| 65 | NIG_MASK_INTERRUPT_PORT0_REG_MASK_EMAC0_MISC_MI_INT |
| 66 | #define NIG_MASK_XGXS0_LINK10G \ |
| 67 | NIG_MASK_INTERRUPT_PORT0_REG_MASK_XGXS0_LINK10G |
| 68 | #define NIG_MASK_XGXS0_LINK_STATUS \ |
| 69 | NIG_MASK_INTERRUPT_PORT0_REG_MASK_XGXS0_LINK_STATUS |
| 70 | #define NIG_MASK_SERDES0_LINK_STATUS \ |
| 71 | NIG_MASK_INTERRUPT_PORT0_REG_MASK_SERDES0_LINK_STATUS |
| 72 | |
| 73 | #define MDIO_AN_CL73_OR_37_COMPLETE \ |
| 74 | (MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_AUTONEG_COMPLETE | \ |
| 75 | MDIO_GP_STATUS_TOP_AN_STATUS1_CL37_AUTONEG_COMPLETE) |
| 76 | |
| 77 | #define XGXS_RESET_BITS \ |
| 78 | (MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_XGXS0_RSTB_HW | \ |
| 79 | MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_XGXS0_IDDQ | \ |
| 80 | MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_XGXS0_PWRDWN | \ |
| 81 | MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_XGXS0_PWRDWN_SD | \ |
| 82 | MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_XGXS0_TXD_FIFO_RSTB) |
| 83 | |
| 84 | #define SERDES_RESET_BITS \ |
| 85 | (MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_SERDES0_RSTB_HW | \ |
| 86 | MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_SERDES0_IDDQ | \ |
| 87 | MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_SERDES0_PWRDWN | \ |
| 88 | MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_SERDES0_PWRDWN_SD) |
| 89 | |
| 90 | #define AUTONEG_CL37 SHARED_HW_CFG_AN_ENABLE_CL37 |
| 91 | #define AUTONEG_CL73 SHARED_HW_CFG_AN_ENABLE_CL73 |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 92 | #define AUTONEG_BAM SHARED_HW_CFG_AN_ENABLE_BAM |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 93 | #define AUTONEG_PARALLEL \ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 94 | SHARED_HW_CFG_AN_ENABLE_PARALLEL_DETECTION |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 95 | #define AUTONEG_SGMII_FIBER_AUTODET \ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 96 | SHARED_HW_CFG_AN_EN_SGMII_FIBER_AUTO_DETECT |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 97 | #define AUTONEG_REMOTE_PHY SHARED_HW_CFG_AN_ENABLE_REMOTE_PHY |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 98 | |
| 99 | #define GP_STATUS_PAUSE_RSOLUTION_TXSIDE \ |
| 100 | MDIO_GP_STATUS_TOP_AN_STATUS1_PAUSE_RSOLUTION_TXSIDE |
| 101 | #define GP_STATUS_PAUSE_RSOLUTION_RXSIDE \ |
| 102 | MDIO_GP_STATUS_TOP_AN_STATUS1_PAUSE_RSOLUTION_RXSIDE |
| 103 | #define GP_STATUS_SPEED_MASK \ |
| 104 | MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_MASK |
| 105 | #define GP_STATUS_10M MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_10M |
| 106 | #define GP_STATUS_100M MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_100M |
| 107 | #define GP_STATUS_1G MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_1G |
| 108 | #define GP_STATUS_2_5G MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_2_5G |
| 109 | #define GP_STATUS_5G MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_5G |
| 110 | #define GP_STATUS_6G MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_6G |
| 111 | #define GP_STATUS_10G_HIG \ |
| 112 | MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_10G_HIG |
| 113 | #define GP_STATUS_10G_CX4 \ |
| 114 | MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_10G_CX4 |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 115 | #define GP_STATUS_1G_KX MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_1G_KX |
| 116 | #define GP_STATUS_10G_KX4 \ |
| 117 | MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_10G_KX4 |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 118 | #define GP_STATUS_10G_KR MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_10G_KR |
| 119 | #define GP_STATUS_10G_XFI MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_10G_XFI |
| 120 | #define GP_STATUS_20G_DXGXS MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_20G_DXGXS |
| 121 | #define GP_STATUS_10G_SFI MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_10G_SFI |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 122 | #define LINK_10THD LINK_STATUS_SPEED_AND_DUPLEX_10THD |
| 123 | #define LINK_10TFD LINK_STATUS_SPEED_AND_DUPLEX_10TFD |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 124 | #define LINK_100TXHD LINK_STATUS_SPEED_AND_DUPLEX_100TXHD |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 125 | #define LINK_100T4 LINK_STATUS_SPEED_AND_DUPLEX_100T4 |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 126 | #define LINK_100TXFD LINK_STATUS_SPEED_AND_DUPLEX_100TXFD |
| 127 | #define LINK_1000THD LINK_STATUS_SPEED_AND_DUPLEX_1000THD |
| 128 | #define LINK_1000TFD LINK_STATUS_SPEED_AND_DUPLEX_1000TFD |
| 129 | #define LINK_1000XFD LINK_STATUS_SPEED_AND_DUPLEX_1000XFD |
| 130 | #define LINK_2500THD LINK_STATUS_SPEED_AND_DUPLEX_2500THD |
| 131 | #define LINK_2500TFD LINK_STATUS_SPEED_AND_DUPLEX_2500TFD |
| 132 | #define LINK_2500XFD LINK_STATUS_SPEED_AND_DUPLEX_2500XFD |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 133 | #define LINK_10GTFD LINK_STATUS_SPEED_AND_DUPLEX_10GTFD |
| 134 | #define LINK_10GXFD LINK_STATUS_SPEED_AND_DUPLEX_10GXFD |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 135 | #define LINK_20GTFD LINK_STATUS_SPEED_AND_DUPLEX_20GTFD |
| 136 | #define LINK_20GXFD LINK_STATUS_SPEED_AND_DUPLEX_20GXFD |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 137 | |
| 138 | |
| 139 | |
Eilon Greenstein | 589abe3 | 2009-02-12 08:36:55 +0000 | [diff] [blame] | 140 | /* */ |
| 141 | #define SFP_EEPROM_CON_TYPE_ADDR 0x2 |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 142 | #define SFP_EEPROM_CON_TYPE_VAL_LC 0x7 |
Eilon Greenstein | 589abe3 | 2009-02-12 08:36:55 +0000 | [diff] [blame] | 143 | #define SFP_EEPROM_CON_TYPE_VAL_COPPER 0x21 |
| 144 | |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 145 | |
| 146 | #define SFP_EEPROM_COMP_CODE_ADDR 0x3 |
| 147 | #define SFP_EEPROM_COMP_CODE_SR_MASK (1<<4) |
| 148 | #define SFP_EEPROM_COMP_CODE_LR_MASK (1<<5) |
| 149 | #define SFP_EEPROM_COMP_CODE_LRM_MASK (1<<6) |
| 150 | |
Eilon Greenstein | 589abe3 | 2009-02-12 08:36:55 +0000 | [diff] [blame] | 151 | #define SFP_EEPROM_FC_TX_TECH_ADDR 0x8 |
| 152 | #define SFP_EEPROM_FC_TX_TECH_BITMASK_COPPER_PASSIVE 0x4 |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 153 | #define SFP_EEPROM_FC_TX_TECH_BITMASK_COPPER_ACTIVE 0x8 |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 154 | |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 155 | #define SFP_EEPROM_OPTIONS_ADDR 0x40 |
Eilon Greenstein | 589abe3 | 2009-02-12 08:36:55 +0000 | [diff] [blame] | 156 | #define SFP_EEPROM_OPTIONS_LINEAR_RX_OUT_MASK 0x1 |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 157 | #define SFP_EEPROM_OPTIONS_SIZE 2 |
Eilon Greenstein | 589abe3 | 2009-02-12 08:36:55 +0000 | [diff] [blame] | 158 | |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 159 | #define EDC_MODE_LINEAR 0x0022 |
| 160 | #define EDC_MODE_LIMITING 0x0044 |
| 161 | #define EDC_MODE_PASSIVE_DAC 0x0055 |
Eilon Greenstein | 589abe3 | 2009-02-12 08:36:55 +0000 | [diff] [blame] | 162 | |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 163 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 164 | /* BRB thresholds for E2*/ |
| 165 | #define PFC_E2_BRB_MAC_PAUSE_XOFF_THR_PAUSE 170 |
| 166 | #define PFC_E2_BRB_MAC_PAUSE_XOFF_THR_NON_PAUSE 0 |
| 167 | |
| 168 | #define PFC_E2_BRB_MAC_PAUSE_XON_THR_PAUSE 250 |
| 169 | #define PFC_E2_BRB_MAC_PAUSE_XON_THR_NON_PAUSE 0 |
| 170 | |
| 171 | #define PFC_E2_BRB_MAC_FULL_XOFF_THR_PAUSE 10 |
| 172 | #define PFC_E2_BRB_MAC_FULL_XOFF_THR_NON_PAUSE 90 |
| 173 | |
| 174 | #define PFC_E2_BRB_MAC_FULL_XON_THR_PAUSE 50 |
| 175 | #define PFC_E2_BRB_MAC_FULL_XON_THR_NON_PAUSE 250 |
| 176 | |
| 177 | /* BRB thresholds for E3A0 */ |
| 178 | #define PFC_E3A0_BRB_MAC_PAUSE_XOFF_THR_PAUSE 290 |
| 179 | #define PFC_E3A0_BRB_MAC_PAUSE_XOFF_THR_NON_PAUSE 0 |
| 180 | |
| 181 | #define PFC_E3A0_BRB_MAC_PAUSE_XON_THR_PAUSE 410 |
| 182 | #define PFC_E3A0_BRB_MAC_PAUSE_XON_THR_NON_PAUSE 0 |
| 183 | |
| 184 | #define PFC_E3A0_BRB_MAC_FULL_XOFF_THR_PAUSE 10 |
| 185 | #define PFC_E3A0_BRB_MAC_FULL_XOFF_THR_NON_PAUSE 170 |
| 186 | |
| 187 | #define PFC_E3A0_BRB_MAC_FULL_XON_THR_PAUSE 50 |
| 188 | #define PFC_E3A0_BRB_MAC_FULL_XON_THR_NON_PAUSE 410 |
| 189 | |
| 190 | |
| 191 | /* BRB thresholds for E3B0 2 port mode*/ |
| 192 | #define PFC_E3B0_2P_BRB_MAC_PAUSE_XOFF_THR_PAUSE 1025 |
| 193 | #define PFC_E3B0_2P_BRB_MAC_PAUSE_XOFF_THR_NON_PAUSE 0 |
| 194 | |
| 195 | #define PFC_E3B0_2P_BRB_MAC_PAUSE_XON_THR_PAUSE 1025 |
| 196 | #define PFC_E3B0_2P_BRB_MAC_PAUSE_XON_THR_NON_PAUSE 0 |
| 197 | |
| 198 | #define PFC_E3B0_2P_BRB_MAC_FULL_XOFF_THR_PAUSE 10 |
| 199 | #define PFC_E3B0_2P_BRB_MAC_FULL_XOFF_THR_NON_PAUSE 1025 |
| 200 | |
| 201 | #define PFC_E3B0_2P_BRB_MAC_FULL_XON_THR_PAUSE 50 |
| 202 | #define PFC_E3B0_2P_BRB_MAC_FULL_XON_THR_NON_PAUSE 1025 |
| 203 | |
| 204 | /* only for E3B0*/ |
| 205 | #define PFC_E3B0_2P_BRB_FULL_LB_XOFF_THR 1025 |
| 206 | #define PFC_E3B0_2P_BRB_FULL_LB_XON_THR 1025 |
| 207 | |
| 208 | /* Lossy +Lossless GUARANTIED == GUART */ |
| 209 | #define PFC_E3B0_2P_MIX_PAUSE_LB_GUART 284 |
| 210 | /* Lossless +Lossless*/ |
| 211 | #define PFC_E3B0_2P_PAUSE_LB_GUART 236 |
| 212 | /* Lossy +Lossy*/ |
| 213 | #define PFC_E3B0_2P_NON_PAUSE_LB_GUART 342 |
| 214 | |
| 215 | /* Lossy +Lossless*/ |
| 216 | #define PFC_E3B0_2P_MIX_PAUSE_MAC_0_CLASS_T_GUART 284 |
| 217 | /* Lossless +Lossless*/ |
| 218 | #define PFC_E3B0_2P_PAUSE_MAC_0_CLASS_T_GUART 236 |
| 219 | /* Lossy +Lossy*/ |
| 220 | #define PFC_E3B0_2P_NON_PAUSE_MAC_0_CLASS_T_GUART 336 |
| 221 | #define PFC_E3B0_2P_BRB_MAC_0_CLASS_T_GUART_HYST 80 |
| 222 | |
| 223 | #define PFC_E3B0_2P_BRB_MAC_1_CLASS_T_GUART 0 |
| 224 | #define PFC_E3B0_2P_BRB_MAC_1_CLASS_T_GUART_HYST 0 |
| 225 | |
| 226 | /* BRB thresholds for E3B0 4 port mode */ |
| 227 | #define PFC_E3B0_4P_BRB_MAC_PAUSE_XOFF_THR_PAUSE 304 |
| 228 | #define PFC_E3B0_4P_BRB_MAC_PAUSE_XOFF_THR_NON_PAUSE 0 |
| 229 | |
| 230 | #define PFC_E3B0_4P_BRB_MAC_PAUSE_XON_THR_PAUSE 384 |
| 231 | #define PFC_E3B0_4P_BRB_MAC_PAUSE_XON_THR_NON_PAUSE 0 |
| 232 | |
| 233 | #define PFC_E3B0_4P_BRB_MAC_FULL_XOFF_THR_PAUSE 10 |
| 234 | #define PFC_E3B0_4P_BRB_MAC_FULL_XOFF_THR_NON_PAUSE 304 |
| 235 | |
| 236 | #define PFC_E3B0_4P_BRB_MAC_FULL_XON_THR_PAUSE 50 |
| 237 | #define PFC_E3B0_4P_BRB_MAC_FULL_XON_THR_NON_PAUSE 384 |
| 238 | |
| 239 | |
| 240 | /* only for E3B0*/ |
| 241 | #define PFC_E3B0_4P_BRB_FULL_LB_XOFF_THR 304 |
| 242 | #define PFC_E3B0_4P_BRB_FULL_LB_XON_THR 384 |
| 243 | #define PFC_E3B0_4P_LB_GUART 120 |
| 244 | |
| 245 | #define PFC_E3B0_4P_BRB_MAC_0_CLASS_T_GUART 120 |
| 246 | #define PFC_E3B0_4P_BRB_MAC_0_CLASS_T_GUART_HYST 80 |
| 247 | |
| 248 | #define PFC_E3B0_4P_BRB_MAC_1_CLASS_T_GUART 80 |
| 249 | #define PFC_E3B0_4P_BRB_MAC_1_CLASS_T_GUART_HYST 120 |
| 250 | |
| 251 | #define DCBX_INVALID_COS (0xFF) |
| 252 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 253 | #define ETS_BW_LIMIT_CREDIT_UPPER_BOUND (0x5000) |
| 254 | #define ETS_BW_LIMIT_CREDIT_WEIGHT (0x5000) |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 255 | #define ETS_E3B0_NIG_MIN_W_VAL_UP_TO_10GBPS (1360) |
| 256 | #define ETS_E3B0_NIG_MIN_W_VAL_20GBPS (2720) |
| 257 | #define ETS_E3B0_PBF_MIN_W_VAL (10000) |
| 258 | |
| 259 | #define MAX_PACKET_SIZE (9700) |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 260 | #define WC_UC_TIMEOUT 100 |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 261 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 262 | /**********************************************************/ |
| 263 | /* INTERFACE */ |
| 264 | /**********************************************************/ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 265 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 266 | #define CL22_WR_OVER_CL45(_bp, _phy, _bank, _addr, _val) \ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 267 | bnx2x_cl45_write(_bp, _phy, \ |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 268 | (_phy)->def_md_devad, \ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 269 | (_bank + (_addr & 0xf)), \ |
| 270 | _val) |
| 271 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 272 | #define CL22_RD_OVER_CL45(_bp, _phy, _bank, _addr, _val) \ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 273 | bnx2x_cl45_read(_bp, _phy, \ |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 274 | (_phy)->def_md_devad, \ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 275 | (_bank + (_addr & 0xf)), \ |
| 276 | _val) |
| 277 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 278 | static u32 bnx2x_bits_en(struct bnx2x *bp, u32 reg, u32 bits) |
| 279 | { |
| 280 | u32 val = REG_RD(bp, reg); |
| 281 | |
| 282 | val |= bits; |
| 283 | REG_WR(bp, reg, val); |
| 284 | return val; |
| 285 | } |
| 286 | |
| 287 | static u32 bnx2x_bits_dis(struct bnx2x *bp, u32 reg, u32 bits) |
| 288 | { |
| 289 | u32 val = REG_RD(bp, reg); |
| 290 | |
| 291 | val &= ~bits; |
| 292 | REG_WR(bp, reg, val); |
| 293 | return val; |
| 294 | } |
| 295 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 296 | /******************************************************************/ |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 297 | /* EPIO/GPIO section */ |
| 298 | /******************************************************************/ |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 299 | static void bnx2x_get_epio(struct bnx2x *bp, u32 epio_pin, u32 *en) |
| 300 | { |
| 301 | u32 epio_mask, gp_oenable; |
| 302 | *en = 0; |
| 303 | /* Sanity check */ |
| 304 | if (epio_pin > 31) { |
| 305 | DP(NETIF_MSG_LINK, "Invalid EPIO pin %d to get\n", epio_pin); |
| 306 | return; |
| 307 | } |
| 308 | |
| 309 | epio_mask = 1 << epio_pin; |
| 310 | /* Set this EPIO to output */ |
| 311 | gp_oenable = REG_RD(bp, MCP_REG_MCPR_GP_OENABLE); |
| 312 | REG_WR(bp, MCP_REG_MCPR_GP_OENABLE, gp_oenable & ~epio_mask); |
| 313 | |
| 314 | *en = (REG_RD(bp, MCP_REG_MCPR_GP_INPUTS) & epio_mask) >> epio_pin; |
| 315 | } |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 316 | static void bnx2x_set_epio(struct bnx2x *bp, u32 epio_pin, u32 en) |
| 317 | { |
| 318 | u32 epio_mask, gp_output, gp_oenable; |
| 319 | |
| 320 | /* Sanity check */ |
| 321 | if (epio_pin > 31) { |
| 322 | DP(NETIF_MSG_LINK, "Invalid EPIO pin %d to set\n", epio_pin); |
| 323 | return; |
| 324 | } |
| 325 | DP(NETIF_MSG_LINK, "Setting EPIO pin %d to %d\n", epio_pin, en); |
| 326 | epio_mask = 1 << epio_pin; |
| 327 | /* Set this EPIO to output */ |
| 328 | gp_output = REG_RD(bp, MCP_REG_MCPR_GP_OUTPUTS); |
| 329 | if (en) |
| 330 | gp_output |= epio_mask; |
| 331 | else |
| 332 | gp_output &= ~epio_mask; |
| 333 | |
| 334 | REG_WR(bp, MCP_REG_MCPR_GP_OUTPUTS, gp_output); |
| 335 | |
| 336 | /* Set the value for this EPIO */ |
| 337 | gp_oenable = REG_RD(bp, MCP_REG_MCPR_GP_OENABLE); |
| 338 | REG_WR(bp, MCP_REG_MCPR_GP_OENABLE, gp_oenable | epio_mask); |
| 339 | } |
| 340 | |
| 341 | static void bnx2x_set_cfg_pin(struct bnx2x *bp, u32 pin_cfg, u32 val) |
| 342 | { |
| 343 | if (pin_cfg == PIN_CFG_NA) |
| 344 | return; |
| 345 | if (pin_cfg >= PIN_CFG_EPIO0) { |
| 346 | bnx2x_set_epio(bp, pin_cfg - PIN_CFG_EPIO0, val); |
| 347 | } else { |
| 348 | u8 gpio_num = (pin_cfg - PIN_CFG_GPIO0_P0) & 0x3; |
| 349 | u8 gpio_port = (pin_cfg - PIN_CFG_GPIO0_P0) >> 2; |
| 350 | bnx2x_set_gpio(bp, gpio_num, (u8)val, gpio_port); |
| 351 | } |
| 352 | } |
| 353 | |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 354 | static u32 bnx2x_get_cfg_pin(struct bnx2x *bp, u32 pin_cfg, u32 *val) |
| 355 | { |
| 356 | if (pin_cfg == PIN_CFG_NA) |
| 357 | return -EINVAL; |
| 358 | if (pin_cfg >= PIN_CFG_EPIO0) { |
| 359 | bnx2x_get_epio(bp, pin_cfg - PIN_CFG_EPIO0, val); |
| 360 | } else { |
| 361 | u8 gpio_num = (pin_cfg - PIN_CFG_GPIO0_P0) & 0x3; |
| 362 | u8 gpio_port = (pin_cfg - PIN_CFG_GPIO0_P0) >> 2; |
| 363 | *val = bnx2x_get_gpio(bp, gpio_num, gpio_port); |
| 364 | } |
| 365 | return 0; |
| 366 | |
| 367 | } |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 368 | /******************************************************************/ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 369 | /* ETS section */ |
| 370 | /******************************************************************/ |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 371 | static void bnx2x_ets_e2e3a0_disabled(struct link_params *params) |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 372 | { |
| 373 | /* ETS disabled configuration*/ |
| 374 | struct bnx2x *bp = params->bp; |
| 375 | |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 376 | DP(NETIF_MSG_LINK, "ETS E2E3 disabled configuration\n"); |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 377 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 378 | /* |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 379 | * mapping between entry priority to client number (0,1,2 -debug and |
| 380 | * management clients, 3 - COS0 client, 4 - COS client)(HIGHEST) |
| 381 | * 3bits client num. |
| 382 | * PRI4 | PRI3 | PRI2 | PRI1 | PRI0 |
| 383 | * cos1-100 cos0-011 dbg1-010 dbg0-001 MCP-000 |
| 384 | */ |
| 385 | |
| 386 | REG_WR(bp, NIG_REG_P0_TX_ARB_PRIORITY_CLIENT, 0x4688); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 387 | /* |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 388 | * Bitmap of 5bits length. Each bit specifies whether the entry behaves |
| 389 | * as strict. Bits 0,1,2 - debug and management entries, 3 - |
| 390 | * COS0 entry, 4 - COS1 entry. |
| 391 | * COS1 | COS0 | DEBUG1 | DEBUG0 | MGMT |
| 392 | * bit4 bit3 bit2 bit1 bit0 |
| 393 | * MCP and debug are strict |
| 394 | */ |
| 395 | |
| 396 | REG_WR(bp, NIG_REG_P0_TX_ARB_CLIENT_IS_STRICT, 0x7); |
| 397 | /* defines which entries (clients) are subjected to WFQ arbitration */ |
| 398 | REG_WR(bp, NIG_REG_P0_TX_ARB_CLIENT_IS_SUBJECT2WFQ, 0); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 399 | /* |
| 400 | * For strict priority entries defines the number of consecutive |
| 401 | * slots for the highest priority. |
| 402 | */ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 403 | REG_WR(bp, NIG_REG_P0_TX_ARB_NUM_STRICT_ARB_SLOTS, 0x100); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 404 | /* |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 405 | * mapping between the CREDIT_WEIGHT registers and actual client |
| 406 | * numbers |
| 407 | */ |
| 408 | REG_WR(bp, NIG_REG_P0_TX_ARB_CLIENT_CREDIT_MAP, 0); |
| 409 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_0, 0); |
| 410 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_1, 0); |
| 411 | |
| 412 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_0, 0); |
| 413 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_1, 0); |
| 414 | REG_WR(bp, PBF_REG_HIGH_PRIORITY_COS_NUM, 0); |
| 415 | /* ETS mode disable */ |
| 416 | REG_WR(bp, PBF_REG_ETS_ENABLED, 0); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 417 | /* |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 418 | * If ETS mode is enabled (there is no strict priority) defines a WFQ |
| 419 | * weight for COS0/COS1. |
| 420 | */ |
| 421 | REG_WR(bp, PBF_REG_COS0_WEIGHT, 0x2710); |
| 422 | REG_WR(bp, PBF_REG_COS1_WEIGHT, 0x2710); |
| 423 | /* Upper bound that COS0_WEIGHT can reach in the WFQ arbiter */ |
| 424 | REG_WR(bp, PBF_REG_COS0_UPPER_BOUND, 0x989680); |
| 425 | REG_WR(bp, PBF_REG_COS1_UPPER_BOUND, 0x989680); |
| 426 | /* Defines the number of consecutive slots for the strict priority */ |
| 427 | REG_WR(bp, PBF_REG_NUM_STRICT_ARB_SLOTS, 0); |
| 428 | } |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 429 | /****************************************************************************** |
| 430 | * Description: |
| 431 | * Getting min_w_val will be set according to line speed . |
| 432 | *. |
| 433 | ******************************************************************************/ |
| 434 | static u32 bnx2x_ets_get_min_w_val_nig(const struct link_vars *vars) |
| 435 | { |
| 436 | u32 min_w_val = 0; |
| 437 | /* Calculate min_w_val.*/ |
| 438 | if (vars->link_up) { |
| 439 | if (SPEED_20000 == vars->line_speed) |
| 440 | min_w_val = ETS_E3B0_NIG_MIN_W_VAL_20GBPS; |
| 441 | else |
| 442 | min_w_val = ETS_E3B0_NIG_MIN_W_VAL_UP_TO_10GBPS; |
| 443 | } else |
| 444 | min_w_val = ETS_E3B0_NIG_MIN_W_VAL_20GBPS; |
| 445 | /** |
| 446 | * If the link isn't up (static configuration for example ) The |
| 447 | * link will be according to 20GBPS. |
| 448 | */ |
| 449 | return min_w_val; |
| 450 | } |
| 451 | /****************************************************************************** |
| 452 | * Description: |
| 453 | * Getting credit upper bound form min_w_val. |
| 454 | *. |
| 455 | ******************************************************************************/ |
| 456 | static u32 bnx2x_ets_get_credit_upper_bound(const u32 min_w_val) |
| 457 | { |
| 458 | const u32 credit_upper_bound = (u32)MAXVAL((150 * min_w_val), |
| 459 | MAX_PACKET_SIZE); |
| 460 | return credit_upper_bound; |
| 461 | } |
| 462 | /****************************************************************************** |
| 463 | * Description: |
| 464 | * Set credit upper bound for NIG. |
| 465 | *. |
| 466 | ******************************************************************************/ |
| 467 | static void bnx2x_ets_e3b0_set_credit_upper_bound_nig( |
| 468 | const struct link_params *params, |
| 469 | const u32 min_w_val) |
| 470 | { |
| 471 | struct bnx2x *bp = params->bp; |
| 472 | const u8 port = params->port; |
| 473 | const u32 credit_upper_bound = |
| 474 | bnx2x_ets_get_credit_upper_bound(min_w_val); |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 475 | |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 476 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CREDIT_UPPER_BOUND_0 : |
| 477 | NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_0, credit_upper_bound); |
| 478 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CREDIT_UPPER_BOUND_1 : |
| 479 | NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_1, credit_upper_bound); |
| 480 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CREDIT_UPPER_BOUND_2 : |
| 481 | NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_2, credit_upper_bound); |
| 482 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CREDIT_UPPER_BOUND_3 : |
| 483 | NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_3, credit_upper_bound); |
| 484 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CREDIT_UPPER_BOUND_4 : |
| 485 | NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_4, credit_upper_bound); |
| 486 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CREDIT_UPPER_BOUND_5 : |
| 487 | NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_5, credit_upper_bound); |
| 488 | |
| 489 | if (0 == port) { |
| 490 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_6, |
| 491 | credit_upper_bound); |
| 492 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_7, |
| 493 | credit_upper_bound); |
| 494 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_8, |
| 495 | credit_upper_bound); |
| 496 | } |
| 497 | } |
| 498 | /****************************************************************************** |
| 499 | * Description: |
| 500 | * Will return the NIG ETS registers to init values.Except |
| 501 | * credit_upper_bound. |
| 502 | * That isn't used in this configuration (No WFQ is enabled) and will be |
| 503 | * configured acording to spec |
| 504 | *. |
| 505 | ******************************************************************************/ |
| 506 | static void bnx2x_ets_e3b0_nig_disabled(const struct link_params *params, |
| 507 | const struct link_vars *vars) |
| 508 | { |
| 509 | struct bnx2x *bp = params->bp; |
| 510 | const u8 port = params->port; |
| 511 | const u32 min_w_val = bnx2x_ets_get_min_w_val_nig(vars); |
| 512 | /** |
| 513 | * mapping between entry priority to client number (0,1,2 -debug and |
| 514 | * management clients, 3 - COS0 client, 4 - COS1, ... 8 - |
| 515 | * COS5)(HIGHEST) 4bits client num.TODO_ETS - Should be done by |
| 516 | * reset value or init tool |
| 517 | */ |
| 518 | if (port) { |
| 519 | REG_WR(bp, NIG_REG_P1_TX_ARB_PRIORITY_CLIENT2_LSB, 0x543210); |
| 520 | REG_WR(bp, NIG_REG_P1_TX_ARB_PRIORITY_CLIENT2_MSB, 0x0); |
| 521 | } else { |
| 522 | REG_WR(bp, NIG_REG_P0_TX_ARB_PRIORITY_CLIENT2_LSB, 0x76543210); |
| 523 | REG_WR(bp, NIG_REG_P0_TX_ARB_PRIORITY_CLIENT2_MSB, 0x8); |
| 524 | } |
| 525 | /** |
| 526 | * For strict priority entries defines the number of consecutive |
| 527 | * slots for the highest priority. |
| 528 | */ |
| 529 | /* TODO_ETS - Should be done by reset value or init tool */ |
| 530 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_NUM_STRICT_ARB_SLOTS : |
| 531 | NIG_REG_P1_TX_ARB_NUM_STRICT_ARB_SLOTS, 0x100); |
| 532 | /** |
| 533 | * mapping between the CREDIT_WEIGHT registers and actual client |
| 534 | * numbers |
| 535 | */ |
| 536 | /* TODO_ETS - Should be done by reset value or init tool */ |
| 537 | if (port) { |
| 538 | /*Port 1 has 6 COS*/ |
| 539 | REG_WR(bp, NIG_REG_P1_TX_ARB_CLIENT_CREDIT_MAP2_LSB, 0x210543); |
| 540 | REG_WR(bp, NIG_REG_P1_TX_ARB_CLIENT_CREDIT_MAP2_MSB, 0x0); |
| 541 | } else { |
| 542 | /*Port 0 has 9 COS*/ |
| 543 | REG_WR(bp, NIG_REG_P0_TX_ARB_CLIENT_CREDIT_MAP2_LSB, |
| 544 | 0x43210876); |
| 545 | REG_WR(bp, NIG_REG_P0_TX_ARB_CLIENT_CREDIT_MAP2_MSB, 0x5); |
| 546 | } |
| 547 | |
| 548 | /** |
| 549 | * Bitmap of 5bits length. Each bit specifies whether the entry behaves |
| 550 | * as strict. Bits 0,1,2 - debug and management entries, 3 - |
| 551 | * COS0 entry, 4 - COS1 entry. |
| 552 | * COS1 | COS0 | DEBUG1 | DEBUG0 | MGMT |
| 553 | * bit4 bit3 bit2 bit1 bit0 |
| 554 | * MCP and debug are strict |
| 555 | */ |
| 556 | if (port) |
| 557 | REG_WR(bp, NIG_REG_P1_TX_ARB_CLIENT_IS_STRICT, 0x3f); |
| 558 | else |
| 559 | REG_WR(bp, NIG_REG_P0_TX_ARB_CLIENT_IS_STRICT, 0x1ff); |
| 560 | /* defines which entries (clients) are subjected to WFQ arbitration */ |
| 561 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CLIENT_IS_SUBJECT2WFQ : |
| 562 | NIG_REG_P0_TX_ARB_CLIENT_IS_SUBJECT2WFQ, 0); |
| 563 | |
| 564 | /** |
| 565 | * Please notice the register address are note continuous and a |
| 566 | * for here is note appropriate.In 2 port mode port0 only COS0-5 |
| 567 | * can be used. DEBUG1,DEBUG1,MGMT are never used for WFQ* In 4 |
| 568 | * port mode port1 only COS0-2 can be used. DEBUG1,DEBUG1,MGMT |
| 569 | * are never used for WFQ |
| 570 | */ |
| 571 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CREDIT_WEIGHT_0 : |
| 572 | NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_0, 0x0); |
| 573 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CREDIT_WEIGHT_1 : |
| 574 | NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_1, 0x0); |
| 575 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CREDIT_WEIGHT_2 : |
| 576 | NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_2, 0x0); |
| 577 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CREDIT_WEIGHT_3 : |
| 578 | NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_3, 0x0); |
| 579 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CREDIT_WEIGHT_4 : |
| 580 | NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_4, 0x0); |
| 581 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CREDIT_WEIGHT_5 : |
| 582 | NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_5, 0x0); |
| 583 | if (0 == port) { |
| 584 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_6, 0x0); |
| 585 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_7, 0x0); |
| 586 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_8, 0x0); |
| 587 | } |
| 588 | |
| 589 | bnx2x_ets_e3b0_set_credit_upper_bound_nig(params, min_w_val); |
| 590 | } |
| 591 | /****************************************************************************** |
| 592 | * Description: |
| 593 | * Set credit upper bound for PBF. |
| 594 | *. |
| 595 | ******************************************************************************/ |
| 596 | static void bnx2x_ets_e3b0_set_credit_upper_bound_pbf( |
| 597 | const struct link_params *params, |
| 598 | const u32 min_w_val) |
| 599 | { |
| 600 | struct bnx2x *bp = params->bp; |
| 601 | const u32 credit_upper_bound = |
| 602 | bnx2x_ets_get_credit_upper_bound(min_w_val); |
| 603 | const u8 port = params->port; |
| 604 | u32 base_upper_bound = 0; |
| 605 | u8 max_cos = 0; |
| 606 | u8 i = 0; |
| 607 | /** |
| 608 | * In 2 port mode port0 has COS0-5 that can be used for WFQ.In 4 |
| 609 | * port mode port1 has COS0-2 that can be used for WFQ. |
| 610 | */ |
| 611 | if (0 == port) { |
| 612 | base_upper_bound = PBF_REG_COS0_UPPER_BOUND_P0; |
| 613 | max_cos = DCBX_E3B0_MAX_NUM_COS_PORT0; |
| 614 | } else { |
| 615 | base_upper_bound = PBF_REG_COS0_UPPER_BOUND_P1; |
| 616 | max_cos = DCBX_E3B0_MAX_NUM_COS_PORT1; |
| 617 | } |
| 618 | |
| 619 | for (i = 0; i < max_cos; i++) |
| 620 | REG_WR(bp, base_upper_bound + (i << 2), credit_upper_bound); |
| 621 | } |
| 622 | |
| 623 | /****************************************************************************** |
| 624 | * Description: |
| 625 | * Will return the PBF ETS registers to init values.Except |
| 626 | * credit_upper_bound. |
| 627 | * That isn't used in this configuration (No WFQ is enabled) and will be |
| 628 | * configured acording to spec |
| 629 | *. |
| 630 | ******************************************************************************/ |
| 631 | static void bnx2x_ets_e3b0_pbf_disabled(const struct link_params *params) |
| 632 | { |
| 633 | struct bnx2x *bp = params->bp; |
| 634 | const u8 port = params->port; |
| 635 | const u32 min_w_val_pbf = ETS_E3B0_PBF_MIN_W_VAL; |
| 636 | u8 i = 0; |
| 637 | u32 base_weight = 0; |
| 638 | u8 max_cos = 0; |
| 639 | |
| 640 | /** |
| 641 | * mapping between entry priority to client number 0 - COS0 |
| 642 | * client, 2 - COS1, ... 5 - COS5)(HIGHEST) 4bits client num. |
| 643 | * TODO_ETS - Should be done by reset value or init tool |
| 644 | */ |
| 645 | if (port) |
| 646 | /* 0x688 (|011|0 10|00 1|000) */ |
| 647 | REG_WR(bp, PBF_REG_ETS_ARB_PRIORITY_CLIENT_P1 , 0x688); |
| 648 | else |
| 649 | /* (10 1|100 |011|0 10|00 1|000) */ |
| 650 | REG_WR(bp, PBF_REG_ETS_ARB_PRIORITY_CLIENT_P0 , 0x2C688); |
| 651 | |
| 652 | /* TODO_ETS - Should be done by reset value or init tool */ |
| 653 | if (port) |
| 654 | /* 0x688 (|011|0 10|00 1|000)*/ |
| 655 | REG_WR(bp, PBF_REG_ETS_ARB_CLIENT_CREDIT_MAP_P1, 0x688); |
| 656 | else |
| 657 | /* 0x2C688 (10 1|100 |011|0 10|00 1|000) */ |
| 658 | REG_WR(bp, PBF_REG_ETS_ARB_CLIENT_CREDIT_MAP_P0, 0x2C688); |
| 659 | |
| 660 | REG_WR(bp, (port) ? PBF_REG_ETS_ARB_NUM_STRICT_ARB_SLOTS_P1 : |
| 661 | PBF_REG_ETS_ARB_NUM_STRICT_ARB_SLOTS_P0 , 0x100); |
| 662 | |
| 663 | |
| 664 | REG_WR(bp, (port) ? PBF_REG_ETS_ARB_CLIENT_IS_STRICT_P1 : |
| 665 | PBF_REG_ETS_ARB_CLIENT_IS_STRICT_P0 , 0); |
| 666 | |
| 667 | REG_WR(bp, (port) ? PBF_REG_ETS_ARB_CLIENT_IS_SUBJECT2WFQ_P1 : |
| 668 | PBF_REG_ETS_ARB_CLIENT_IS_SUBJECT2WFQ_P0 , 0); |
| 669 | /** |
| 670 | * In 2 port mode port0 has COS0-5 that can be used for WFQ. |
| 671 | * In 4 port mode port1 has COS0-2 that can be used for WFQ. |
| 672 | */ |
| 673 | if (0 == port) { |
| 674 | base_weight = PBF_REG_COS0_WEIGHT_P0; |
| 675 | max_cos = DCBX_E3B0_MAX_NUM_COS_PORT0; |
| 676 | } else { |
| 677 | base_weight = PBF_REG_COS0_WEIGHT_P1; |
| 678 | max_cos = DCBX_E3B0_MAX_NUM_COS_PORT1; |
| 679 | } |
| 680 | |
| 681 | for (i = 0; i < max_cos; i++) |
| 682 | REG_WR(bp, base_weight + (0x4 * i), 0); |
| 683 | |
| 684 | bnx2x_ets_e3b0_set_credit_upper_bound_pbf(params, min_w_val_pbf); |
| 685 | } |
| 686 | /****************************************************************************** |
| 687 | * Description: |
| 688 | * E3B0 disable will return basicly the values to init values. |
| 689 | *. |
| 690 | ******************************************************************************/ |
| 691 | static int bnx2x_ets_e3b0_disabled(const struct link_params *params, |
| 692 | const struct link_vars *vars) |
| 693 | { |
| 694 | struct bnx2x *bp = params->bp; |
| 695 | |
| 696 | if (!CHIP_IS_E3B0(bp)) { |
| 697 | DP(NETIF_MSG_LINK, "bnx2x_ets_e3b0_disabled the chip isn't E3B0" |
| 698 | "\n"); |
| 699 | return -EINVAL; |
| 700 | } |
| 701 | |
| 702 | bnx2x_ets_e3b0_nig_disabled(params, vars); |
| 703 | |
| 704 | bnx2x_ets_e3b0_pbf_disabled(params); |
| 705 | |
| 706 | return 0; |
| 707 | } |
| 708 | |
| 709 | /****************************************************************************** |
| 710 | * Description: |
| 711 | * Disable will return basicly the values to init values. |
| 712 | *. |
| 713 | ******************************************************************************/ |
| 714 | int bnx2x_ets_disabled(struct link_params *params, |
| 715 | struct link_vars *vars) |
| 716 | { |
| 717 | struct bnx2x *bp = params->bp; |
| 718 | int bnx2x_status = 0; |
| 719 | |
| 720 | if ((CHIP_IS_E2(bp)) || (CHIP_IS_E3A0(bp))) |
| 721 | bnx2x_ets_e2e3a0_disabled(params); |
| 722 | else if (CHIP_IS_E3B0(bp)) |
| 723 | bnx2x_status = bnx2x_ets_e3b0_disabled(params, vars); |
| 724 | else { |
| 725 | DP(NETIF_MSG_LINK, "bnx2x_ets_disabled - chip not supported\n"); |
| 726 | return -EINVAL; |
| 727 | } |
| 728 | |
| 729 | return bnx2x_status; |
| 730 | } |
| 731 | |
| 732 | /****************************************************************************** |
| 733 | * Description |
| 734 | * Set the COS mappimg to SP and BW until this point all the COS are not |
| 735 | * set as SP or BW. |
| 736 | ******************************************************************************/ |
| 737 | static int bnx2x_ets_e3b0_cli_map(const struct link_params *params, |
| 738 | const struct bnx2x_ets_params *ets_params, |
| 739 | const u8 cos_sp_bitmap, |
| 740 | const u8 cos_bw_bitmap) |
| 741 | { |
| 742 | struct bnx2x *bp = params->bp; |
| 743 | const u8 port = params->port; |
| 744 | const u8 nig_cli_sp_bitmap = 0x7 | (cos_sp_bitmap << 3); |
| 745 | const u8 pbf_cli_sp_bitmap = cos_sp_bitmap; |
| 746 | const u8 nig_cli_subject2wfq_bitmap = cos_bw_bitmap << 3; |
| 747 | const u8 pbf_cli_subject2wfq_bitmap = cos_bw_bitmap; |
| 748 | |
| 749 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CLIENT_IS_STRICT : |
| 750 | NIG_REG_P0_TX_ARB_CLIENT_IS_STRICT, nig_cli_sp_bitmap); |
| 751 | |
| 752 | REG_WR(bp, (port) ? PBF_REG_ETS_ARB_CLIENT_IS_STRICT_P1 : |
| 753 | PBF_REG_ETS_ARB_CLIENT_IS_STRICT_P0 , pbf_cli_sp_bitmap); |
| 754 | |
| 755 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CLIENT_IS_SUBJECT2WFQ : |
| 756 | NIG_REG_P0_TX_ARB_CLIENT_IS_SUBJECT2WFQ, |
| 757 | nig_cli_subject2wfq_bitmap); |
| 758 | |
| 759 | REG_WR(bp, (port) ? PBF_REG_ETS_ARB_CLIENT_IS_SUBJECT2WFQ_P1 : |
| 760 | PBF_REG_ETS_ARB_CLIENT_IS_SUBJECT2WFQ_P0, |
| 761 | pbf_cli_subject2wfq_bitmap); |
| 762 | |
| 763 | return 0; |
| 764 | } |
| 765 | |
| 766 | /****************************************************************************** |
| 767 | * Description: |
| 768 | * This function is needed because NIG ARB_CREDIT_WEIGHT_X are |
| 769 | * not continues and ARB_CREDIT_WEIGHT_0 + offset is suitable. |
| 770 | ******************************************************************************/ |
| 771 | static int bnx2x_ets_e3b0_set_cos_bw(struct bnx2x *bp, |
| 772 | const u8 cos_entry, |
| 773 | const u32 min_w_val_nig, |
| 774 | const u32 min_w_val_pbf, |
| 775 | const u16 total_bw, |
| 776 | const u8 bw, |
| 777 | const u8 port) |
| 778 | { |
| 779 | u32 nig_reg_adress_crd_weight = 0; |
| 780 | u32 pbf_reg_adress_crd_weight = 0; |
| 781 | /* Calculate and set BW for this COS*/ |
| 782 | const u32 cos_bw_nig = (bw * min_w_val_nig) / total_bw; |
| 783 | const u32 cos_bw_pbf = (bw * min_w_val_pbf) / total_bw; |
| 784 | |
| 785 | switch (cos_entry) { |
| 786 | case 0: |
| 787 | nig_reg_adress_crd_weight = |
| 788 | (port) ? NIG_REG_P1_TX_ARB_CREDIT_WEIGHT_0 : |
| 789 | NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_0; |
| 790 | pbf_reg_adress_crd_weight = (port) ? |
| 791 | PBF_REG_COS0_WEIGHT_P1 : PBF_REG_COS0_WEIGHT_P0; |
| 792 | break; |
| 793 | case 1: |
| 794 | nig_reg_adress_crd_weight = (port) ? |
| 795 | NIG_REG_P1_TX_ARB_CREDIT_WEIGHT_1 : |
| 796 | NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_1; |
| 797 | pbf_reg_adress_crd_weight = (port) ? |
| 798 | PBF_REG_COS1_WEIGHT_P1 : PBF_REG_COS1_WEIGHT_P0; |
| 799 | break; |
| 800 | case 2: |
| 801 | nig_reg_adress_crd_weight = (port) ? |
| 802 | NIG_REG_P1_TX_ARB_CREDIT_WEIGHT_2 : |
| 803 | NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_2; |
| 804 | |
| 805 | pbf_reg_adress_crd_weight = (port) ? |
| 806 | PBF_REG_COS2_WEIGHT_P1 : PBF_REG_COS2_WEIGHT_P0; |
| 807 | break; |
| 808 | case 3: |
| 809 | if (port) |
| 810 | return -EINVAL; |
| 811 | nig_reg_adress_crd_weight = |
| 812 | NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_3; |
| 813 | pbf_reg_adress_crd_weight = |
| 814 | PBF_REG_COS3_WEIGHT_P0; |
| 815 | break; |
| 816 | case 4: |
| 817 | if (port) |
| 818 | return -EINVAL; |
| 819 | nig_reg_adress_crd_weight = |
| 820 | NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_4; |
| 821 | pbf_reg_adress_crd_weight = PBF_REG_COS4_WEIGHT_P0; |
| 822 | break; |
| 823 | case 5: |
| 824 | if (port) |
| 825 | return -EINVAL; |
| 826 | nig_reg_adress_crd_weight = |
| 827 | NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_5; |
| 828 | pbf_reg_adress_crd_weight = PBF_REG_COS5_WEIGHT_P0; |
| 829 | break; |
| 830 | } |
| 831 | |
| 832 | REG_WR(bp, nig_reg_adress_crd_weight, cos_bw_nig); |
| 833 | |
| 834 | REG_WR(bp, pbf_reg_adress_crd_weight, cos_bw_pbf); |
| 835 | |
| 836 | return 0; |
| 837 | } |
| 838 | /****************************************************************************** |
| 839 | * Description: |
| 840 | * Calculate the total BW.A value of 0 isn't legal. |
| 841 | *. |
| 842 | ******************************************************************************/ |
| 843 | static int bnx2x_ets_e3b0_get_total_bw( |
| 844 | const struct link_params *params, |
| 845 | const struct bnx2x_ets_params *ets_params, |
| 846 | u16 *total_bw) |
| 847 | { |
| 848 | struct bnx2x *bp = params->bp; |
| 849 | u8 cos_idx = 0; |
| 850 | |
| 851 | *total_bw = 0 ; |
| 852 | /* Calculate total BW requested */ |
| 853 | for (cos_idx = 0; cos_idx < ets_params->num_of_cos; cos_idx++) { |
| 854 | if (bnx2x_cos_state_bw == ets_params->cos[cos_idx].state) { |
| 855 | |
| 856 | if (0 == ets_params->cos[cos_idx].params.bw_params.bw) { |
| 857 | DP(NETIF_MSG_LINK, "bnx2x_ets_E3B0_config BW" |
| 858 | "was set to 0\n"); |
| 859 | return -EINVAL; |
| 860 | } |
| 861 | *total_bw += |
| 862 | ets_params->cos[cos_idx].params.bw_params.bw; |
| 863 | } |
| 864 | } |
| 865 | |
| 866 | /*Check taotl BW is valid */ |
| 867 | if ((100 != *total_bw) || (0 == *total_bw)) { |
| 868 | if (0 == *total_bw) { |
| 869 | DP(NETIF_MSG_LINK, "bnx2x_ets_E3B0_config toatl BW" |
| 870 | "shouldn't be 0\n"); |
| 871 | return -EINVAL; |
| 872 | } |
| 873 | DP(NETIF_MSG_LINK, "bnx2x_ets_E3B0_config toatl BW should be" |
| 874 | "100\n"); |
| 875 | /** |
| 876 | * We can handle a case whre the BW isn't 100 this can happen |
| 877 | * if the TC are joined. |
| 878 | */ |
| 879 | } |
| 880 | return 0; |
| 881 | } |
| 882 | |
| 883 | /****************************************************************************** |
| 884 | * Description: |
| 885 | * Invalidate all the sp_pri_to_cos. |
| 886 | *. |
| 887 | ******************************************************************************/ |
| 888 | static void bnx2x_ets_e3b0_sp_pri_to_cos_init(u8 *sp_pri_to_cos) |
| 889 | { |
| 890 | u8 pri = 0; |
| 891 | for (pri = 0; pri < DCBX_MAX_NUM_COS; pri++) |
| 892 | sp_pri_to_cos[pri] = DCBX_INVALID_COS; |
| 893 | } |
| 894 | /****************************************************************************** |
| 895 | * Description: |
| 896 | * Calculate and set the SP (ARB_PRIORITY_CLIENT) NIG and PBF registers |
| 897 | * according to sp_pri_to_cos. |
| 898 | *. |
| 899 | ******************************************************************************/ |
| 900 | static int bnx2x_ets_e3b0_sp_pri_to_cos_set(const struct link_params *params, |
| 901 | u8 *sp_pri_to_cos, const u8 pri, |
| 902 | const u8 cos_entry) |
| 903 | { |
| 904 | struct bnx2x *bp = params->bp; |
| 905 | const u8 port = params->port; |
| 906 | const u8 max_num_of_cos = (port) ? DCBX_E3B0_MAX_NUM_COS_PORT1 : |
| 907 | DCBX_E3B0_MAX_NUM_COS_PORT0; |
| 908 | |
| 909 | if (DCBX_INVALID_COS != sp_pri_to_cos[pri]) { |
| 910 | DP(NETIF_MSG_LINK, "bnx2x_ets_e3b0_sp_pri_to_cos_set invalid " |
| 911 | "parameter There can't be two COS's with" |
| 912 | "the same strict pri\n"); |
| 913 | return -EINVAL; |
| 914 | } |
| 915 | |
| 916 | if (pri > max_num_of_cos) { |
| 917 | DP(NETIF_MSG_LINK, "bnx2x_ets_e3b0_sp_pri_to_cos_set invalid" |
| 918 | "parameter Illegal strict priority\n"); |
| 919 | return -EINVAL; |
| 920 | } |
| 921 | |
| 922 | sp_pri_to_cos[pri] = cos_entry; |
| 923 | return 0; |
| 924 | |
| 925 | } |
| 926 | |
| 927 | /****************************************************************************** |
| 928 | * Description: |
| 929 | * Returns the correct value according to COS and priority in |
| 930 | * the sp_pri_cli register. |
| 931 | *. |
| 932 | ******************************************************************************/ |
| 933 | static u64 bnx2x_e3b0_sp_get_pri_cli_reg(const u8 cos, const u8 cos_offset, |
| 934 | const u8 pri_set, |
| 935 | const u8 pri_offset, |
| 936 | const u8 entry_size) |
| 937 | { |
| 938 | u64 pri_cli_nig = 0; |
| 939 | pri_cli_nig = ((u64)(cos + cos_offset)) << (entry_size * |
| 940 | (pri_set + pri_offset)); |
| 941 | |
| 942 | return pri_cli_nig; |
| 943 | } |
| 944 | /****************************************************************************** |
| 945 | * Description: |
| 946 | * Returns the correct value according to COS and priority in the |
| 947 | * sp_pri_cli register for NIG. |
| 948 | *. |
| 949 | ******************************************************************************/ |
| 950 | static u64 bnx2x_e3b0_sp_get_pri_cli_reg_nig(const u8 cos, const u8 pri_set) |
| 951 | { |
| 952 | /* MCP Dbg0 and dbg1 are always with higher strict pri*/ |
| 953 | const u8 nig_cos_offset = 3; |
| 954 | const u8 nig_pri_offset = 3; |
| 955 | |
| 956 | return bnx2x_e3b0_sp_get_pri_cli_reg(cos, nig_cos_offset, pri_set, |
| 957 | nig_pri_offset, 4); |
| 958 | |
| 959 | } |
| 960 | /****************************************************************************** |
| 961 | * Description: |
| 962 | * Returns the correct value according to COS and priority in the |
| 963 | * sp_pri_cli register for PBF. |
| 964 | *. |
| 965 | ******************************************************************************/ |
| 966 | static u64 bnx2x_e3b0_sp_get_pri_cli_reg_pbf(const u8 cos, const u8 pri_set) |
| 967 | { |
| 968 | const u8 pbf_cos_offset = 0; |
| 969 | const u8 pbf_pri_offset = 0; |
| 970 | |
| 971 | return bnx2x_e3b0_sp_get_pri_cli_reg(cos, pbf_cos_offset, pri_set, |
| 972 | pbf_pri_offset, 3); |
| 973 | |
| 974 | } |
| 975 | |
| 976 | /****************************************************************************** |
| 977 | * Description: |
| 978 | * Calculate and set the SP (ARB_PRIORITY_CLIENT) NIG and PBF registers |
| 979 | * according to sp_pri_to_cos.(which COS has higher priority) |
| 980 | *. |
| 981 | ******************************************************************************/ |
| 982 | static int bnx2x_ets_e3b0_sp_set_pri_cli_reg(const struct link_params *params, |
| 983 | u8 *sp_pri_to_cos) |
| 984 | { |
| 985 | struct bnx2x *bp = params->bp; |
| 986 | u8 i = 0; |
| 987 | const u8 port = params->port; |
| 988 | /* MCP Dbg0 and dbg1 are always with higher strict pri*/ |
| 989 | u64 pri_cli_nig = 0x210; |
| 990 | u32 pri_cli_pbf = 0x0; |
| 991 | u8 pri_set = 0; |
| 992 | u8 pri_bitmask = 0; |
| 993 | const u8 max_num_of_cos = (port) ? DCBX_E3B0_MAX_NUM_COS_PORT1 : |
| 994 | DCBX_E3B0_MAX_NUM_COS_PORT0; |
| 995 | |
| 996 | u8 cos_bit_to_set = (1 << max_num_of_cos) - 1; |
| 997 | |
| 998 | /* Set all the strict priority first */ |
| 999 | for (i = 0; i < max_num_of_cos; i++) { |
| 1000 | if (DCBX_INVALID_COS != sp_pri_to_cos[i]) { |
| 1001 | if (DCBX_MAX_NUM_COS <= sp_pri_to_cos[i]) { |
| 1002 | DP(NETIF_MSG_LINK, |
| 1003 | "bnx2x_ets_e3b0_sp_set_pri_cli_reg " |
| 1004 | "invalid cos entry\n"); |
| 1005 | return -EINVAL; |
| 1006 | } |
| 1007 | |
| 1008 | pri_cli_nig |= bnx2x_e3b0_sp_get_pri_cli_reg_nig( |
| 1009 | sp_pri_to_cos[i], pri_set); |
| 1010 | |
| 1011 | pri_cli_pbf |= bnx2x_e3b0_sp_get_pri_cli_reg_pbf( |
| 1012 | sp_pri_to_cos[i], pri_set); |
| 1013 | pri_bitmask = 1 << sp_pri_to_cos[i]; |
| 1014 | /* COS is used remove it from bitmap.*/ |
| 1015 | if (0 == (pri_bitmask & cos_bit_to_set)) { |
| 1016 | DP(NETIF_MSG_LINK, |
| 1017 | "bnx2x_ets_e3b0_sp_set_pri_cli_reg " |
| 1018 | "invalid There can't be two COS's with" |
| 1019 | " the same strict pri\n"); |
| 1020 | return -EINVAL; |
| 1021 | } |
| 1022 | cos_bit_to_set &= ~pri_bitmask; |
| 1023 | pri_set++; |
| 1024 | } |
| 1025 | } |
| 1026 | |
| 1027 | /* Set all the Non strict priority i= COS*/ |
| 1028 | for (i = 0; i < max_num_of_cos; i++) { |
| 1029 | pri_bitmask = 1 << i; |
| 1030 | /* Check if COS was already used for SP */ |
| 1031 | if (pri_bitmask & cos_bit_to_set) { |
| 1032 | /* COS wasn't used for SP */ |
| 1033 | pri_cli_nig |= bnx2x_e3b0_sp_get_pri_cli_reg_nig( |
| 1034 | i, pri_set); |
| 1035 | |
| 1036 | pri_cli_pbf |= bnx2x_e3b0_sp_get_pri_cli_reg_pbf( |
| 1037 | i, pri_set); |
| 1038 | /* COS is used remove it from bitmap.*/ |
| 1039 | cos_bit_to_set &= ~pri_bitmask; |
| 1040 | pri_set++; |
| 1041 | } |
| 1042 | } |
| 1043 | |
| 1044 | if (pri_set != max_num_of_cos) { |
| 1045 | DP(NETIF_MSG_LINK, "bnx2x_ets_e3b0_sp_set_pri_cli_reg not all " |
| 1046 | "entries were set\n"); |
| 1047 | return -EINVAL; |
| 1048 | } |
| 1049 | |
| 1050 | if (port) { |
| 1051 | /* Only 6 usable clients*/ |
| 1052 | REG_WR(bp, NIG_REG_P1_TX_ARB_PRIORITY_CLIENT2_LSB, |
| 1053 | (u32)pri_cli_nig); |
| 1054 | |
| 1055 | REG_WR(bp, PBF_REG_ETS_ARB_PRIORITY_CLIENT_P1 , pri_cli_pbf); |
| 1056 | } else { |
| 1057 | /* Only 9 usable clients*/ |
| 1058 | const u32 pri_cli_nig_lsb = (u32) (pri_cli_nig); |
| 1059 | const u32 pri_cli_nig_msb = (u32) ((pri_cli_nig >> 32) & 0xF); |
| 1060 | |
| 1061 | REG_WR(bp, NIG_REG_P0_TX_ARB_PRIORITY_CLIENT2_LSB, |
| 1062 | pri_cli_nig_lsb); |
| 1063 | REG_WR(bp, NIG_REG_P0_TX_ARB_PRIORITY_CLIENT2_MSB, |
| 1064 | pri_cli_nig_msb); |
| 1065 | |
| 1066 | REG_WR(bp, PBF_REG_ETS_ARB_PRIORITY_CLIENT_P0 , pri_cli_pbf); |
| 1067 | } |
| 1068 | return 0; |
| 1069 | } |
| 1070 | |
| 1071 | /****************************************************************************** |
| 1072 | * Description: |
| 1073 | * Configure the COS to ETS according to BW and SP settings. |
| 1074 | ******************************************************************************/ |
| 1075 | int bnx2x_ets_e3b0_config(const struct link_params *params, |
| 1076 | const struct link_vars *vars, |
| 1077 | const struct bnx2x_ets_params *ets_params) |
| 1078 | { |
| 1079 | struct bnx2x *bp = params->bp; |
| 1080 | int bnx2x_status = 0; |
| 1081 | const u8 port = params->port; |
| 1082 | u16 total_bw = 0; |
| 1083 | const u32 min_w_val_nig = bnx2x_ets_get_min_w_val_nig(vars); |
| 1084 | const u32 min_w_val_pbf = ETS_E3B0_PBF_MIN_W_VAL; |
| 1085 | u8 cos_bw_bitmap = 0; |
| 1086 | u8 cos_sp_bitmap = 0; |
| 1087 | u8 sp_pri_to_cos[DCBX_MAX_NUM_COS] = {0}; |
| 1088 | const u8 max_num_of_cos = (port) ? DCBX_E3B0_MAX_NUM_COS_PORT1 : |
| 1089 | DCBX_E3B0_MAX_NUM_COS_PORT0; |
| 1090 | u8 cos_entry = 0; |
| 1091 | |
| 1092 | if (!CHIP_IS_E3B0(bp)) { |
| 1093 | DP(NETIF_MSG_LINK, "bnx2x_ets_e3b0_disabled the chip isn't E3B0" |
| 1094 | "\n"); |
| 1095 | return -EINVAL; |
| 1096 | } |
| 1097 | |
| 1098 | if ((ets_params->num_of_cos > max_num_of_cos)) { |
| 1099 | DP(NETIF_MSG_LINK, "bnx2x_ets_E3B0_config the number of COS " |
| 1100 | "isn't supported\n"); |
| 1101 | return -EINVAL; |
| 1102 | } |
| 1103 | |
| 1104 | /* Prepare sp strict priority parameters*/ |
| 1105 | bnx2x_ets_e3b0_sp_pri_to_cos_init(sp_pri_to_cos); |
| 1106 | |
| 1107 | /* Prepare BW parameters*/ |
| 1108 | bnx2x_status = bnx2x_ets_e3b0_get_total_bw(params, ets_params, |
| 1109 | &total_bw); |
| 1110 | if (0 != bnx2x_status) { |
| 1111 | DP(NETIF_MSG_LINK, "bnx2x_ets_E3B0_config get_total_bw failed " |
| 1112 | "\n"); |
| 1113 | return -EINVAL; |
| 1114 | } |
| 1115 | |
| 1116 | /** |
| 1117 | * Upper bound is set according to current link speed (min_w_val |
| 1118 | * should be the same for upper bound and COS credit val). |
| 1119 | */ |
| 1120 | bnx2x_ets_e3b0_set_credit_upper_bound_nig(params, min_w_val_nig); |
| 1121 | bnx2x_ets_e3b0_set_credit_upper_bound_pbf(params, min_w_val_pbf); |
| 1122 | |
| 1123 | |
| 1124 | for (cos_entry = 0; cos_entry < ets_params->num_of_cos; cos_entry++) { |
| 1125 | if (bnx2x_cos_state_bw == ets_params->cos[cos_entry].state) { |
| 1126 | cos_bw_bitmap |= (1 << cos_entry); |
| 1127 | /** |
| 1128 | * The function also sets the BW in HW(not the mappin |
| 1129 | * yet) |
| 1130 | */ |
| 1131 | bnx2x_status = bnx2x_ets_e3b0_set_cos_bw( |
| 1132 | bp, cos_entry, min_w_val_nig, min_w_val_pbf, |
| 1133 | total_bw, |
| 1134 | ets_params->cos[cos_entry].params.bw_params.bw, |
| 1135 | port); |
| 1136 | } else if (bnx2x_cos_state_strict == |
| 1137 | ets_params->cos[cos_entry].state){ |
| 1138 | cos_sp_bitmap |= (1 << cos_entry); |
| 1139 | |
| 1140 | bnx2x_status = bnx2x_ets_e3b0_sp_pri_to_cos_set( |
| 1141 | params, |
| 1142 | sp_pri_to_cos, |
| 1143 | ets_params->cos[cos_entry].params.sp_params.pri, |
| 1144 | cos_entry); |
| 1145 | |
| 1146 | } else { |
| 1147 | DP(NETIF_MSG_LINK, "bnx2x_ets_e3b0_config cos state not" |
| 1148 | " valid\n"); |
| 1149 | return -EINVAL; |
| 1150 | } |
| 1151 | if (0 != bnx2x_status) { |
| 1152 | DP(NETIF_MSG_LINK, "bnx2x_ets_e3b0_config set cos bw " |
| 1153 | "failed\n"); |
| 1154 | return bnx2x_status; |
| 1155 | } |
| 1156 | } |
| 1157 | |
| 1158 | /* Set SP register (which COS has higher priority) */ |
| 1159 | bnx2x_status = bnx2x_ets_e3b0_sp_set_pri_cli_reg(params, |
| 1160 | sp_pri_to_cos); |
| 1161 | |
| 1162 | if (0 != bnx2x_status) { |
| 1163 | DP(NETIF_MSG_LINK, "bnx2x_ets_E3B0_config set_pri_cli_reg " |
| 1164 | "failed\n"); |
| 1165 | return bnx2x_status; |
| 1166 | } |
| 1167 | |
| 1168 | /* Set client mapping of BW and strict */ |
| 1169 | bnx2x_status = bnx2x_ets_e3b0_cli_map(params, ets_params, |
| 1170 | cos_sp_bitmap, |
| 1171 | cos_bw_bitmap); |
| 1172 | |
| 1173 | if (0 != bnx2x_status) { |
| 1174 | DP(NETIF_MSG_LINK, "bnx2x_ets_E3B0_config SP failed\n"); |
| 1175 | return bnx2x_status; |
| 1176 | } |
| 1177 | return 0; |
| 1178 | } |
Yaniv Rosner | 65a001b | 2011-01-31 04:22:03 +0000 | [diff] [blame] | 1179 | static void bnx2x_ets_bw_limit_common(const struct link_params *params) |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1180 | { |
| 1181 | /* ETS disabled configuration */ |
| 1182 | struct bnx2x *bp = params->bp; |
| 1183 | DP(NETIF_MSG_LINK, "ETS enabled BW limit configuration\n"); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 1184 | /* |
| 1185 | * defines which entries (clients) are subjected to WFQ arbitration |
| 1186 | * COS0 0x8 |
| 1187 | * COS1 0x10 |
| 1188 | */ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1189 | REG_WR(bp, NIG_REG_P0_TX_ARB_CLIENT_IS_SUBJECT2WFQ, 0x18); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 1190 | /* |
| 1191 | * mapping between the ARB_CREDIT_WEIGHT registers and actual |
| 1192 | * client numbers (WEIGHT_0 does not actually have to represent |
| 1193 | * client 0) |
| 1194 | * PRI4 | PRI3 | PRI2 | PRI1 | PRI0 |
| 1195 | * cos1-001 cos0-000 dbg1-100 dbg0-011 MCP-010 |
| 1196 | */ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1197 | REG_WR(bp, NIG_REG_P0_TX_ARB_CLIENT_CREDIT_MAP, 0x111A); |
| 1198 | |
| 1199 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_0, |
| 1200 | ETS_BW_LIMIT_CREDIT_UPPER_BOUND); |
| 1201 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_1, |
| 1202 | ETS_BW_LIMIT_CREDIT_UPPER_BOUND); |
| 1203 | |
| 1204 | /* ETS mode enabled*/ |
| 1205 | REG_WR(bp, PBF_REG_ETS_ENABLED, 1); |
| 1206 | |
| 1207 | /* Defines the number of consecutive slots for the strict priority */ |
| 1208 | REG_WR(bp, PBF_REG_NUM_STRICT_ARB_SLOTS, 0); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 1209 | /* |
| 1210 | * Bitmap of 5bits length. Each bit specifies whether the entry behaves |
| 1211 | * as strict. Bits 0,1,2 - debug and management entries, 3 - COS0 |
| 1212 | * entry, 4 - COS1 entry. |
| 1213 | * COS1 | COS0 | DEBUG21 | DEBUG0 | MGMT |
| 1214 | * bit4 bit3 bit2 bit1 bit0 |
| 1215 | * MCP and debug are strict |
| 1216 | */ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1217 | REG_WR(bp, NIG_REG_P0_TX_ARB_CLIENT_IS_STRICT, 0x7); |
| 1218 | |
| 1219 | /* Upper bound that COS0_WEIGHT can reach in the WFQ arbiter.*/ |
| 1220 | REG_WR(bp, PBF_REG_COS0_UPPER_BOUND, |
| 1221 | ETS_BW_LIMIT_CREDIT_UPPER_BOUND); |
| 1222 | REG_WR(bp, PBF_REG_COS1_UPPER_BOUND, |
| 1223 | ETS_BW_LIMIT_CREDIT_UPPER_BOUND); |
| 1224 | } |
| 1225 | |
| 1226 | void bnx2x_ets_bw_limit(const struct link_params *params, const u32 cos0_bw, |
| 1227 | const u32 cos1_bw) |
| 1228 | { |
| 1229 | /* ETS disabled configuration*/ |
| 1230 | struct bnx2x *bp = params->bp; |
| 1231 | const u32 total_bw = cos0_bw + cos1_bw; |
| 1232 | u32 cos0_credit_weight = 0; |
| 1233 | u32 cos1_credit_weight = 0; |
| 1234 | |
| 1235 | DP(NETIF_MSG_LINK, "ETS enabled BW limit configuration\n"); |
| 1236 | |
| 1237 | if ((0 == total_bw) || |
| 1238 | (0 == cos0_bw) || |
| 1239 | (0 == cos1_bw)) { |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1240 | DP(NETIF_MSG_LINK, "Total BW can't be zero\n"); |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1241 | return; |
| 1242 | } |
| 1243 | |
| 1244 | cos0_credit_weight = (cos0_bw * ETS_BW_LIMIT_CREDIT_WEIGHT)/ |
| 1245 | total_bw; |
| 1246 | cos1_credit_weight = (cos1_bw * ETS_BW_LIMIT_CREDIT_WEIGHT)/ |
| 1247 | total_bw; |
| 1248 | |
| 1249 | bnx2x_ets_bw_limit_common(params); |
| 1250 | |
| 1251 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_0, cos0_credit_weight); |
| 1252 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_1, cos1_credit_weight); |
| 1253 | |
| 1254 | REG_WR(bp, PBF_REG_COS0_WEIGHT, cos0_credit_weight); |
| 1255 | REG_WR(bp, PBF_REG_COS1_WEIGHT, cos1_credit_weight); |
| 1256 | } |
| 1257 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 1258 | int bnx2x_ets_strict(const struct link_params *params, const u8 strict_cos) |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1259 | { |
| 1260 | /* ETS disabled configuration*/ |
| 1261 | struct bnx2x *bp = params->bp; |
| 1262 | u32 val = 0; |
| 1263 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1264 | DP(NETIF_MSG_LINK, "ETS enabled strict configuration\n"); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 1265 | /* |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1266 | * Bitmap of 5bits length. Each bit specifies whether the entry behaves |
| 1267 | * as strict. Bits 0,1,2 - debug and management entries, |
| 1268 | * 3 - COS0 entry, 4 - COS1 entry. |
| 1269 | * COS1 | COS0 | DEBUG21 | DEBUG0 | MGMT |
| 1270 | * bit4 bit3 bit2 bit1 bit0 |
| 1271 | * MCP and debug are strict |
| 1272 | */ |
| 1273 | REG_WR(bp, NIG_REG_P0_TX_ARB_CLIENT_IS_STRICT, 0x1F); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 1274 | /* |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1275 | * For strict priority entries defines the number of consecutive slots |
| 1276 | * for the highest priority. |
| 1277 | */ |
| 1278 | REG_WR(bp, NIG_REG_P0_TX_ARB_NUM_STRICT_ARB_SLOTS, 0x100); |
| 1279 | /* ETS mode disable */ |
| 1280 | REG_WR(bp, PBF_REG_ETS_ENABLED, 0); |
| 1281 | /* Defines the number of consecutive slots for the strict priority */ |
| 1282 | REG_WR(bp, PBF_REG_NUM_STRICT_ARB_SLOTS, 0x100); |
| 1283 | |
| 1284 | /* Defines the number of consecutive slots for the strict priority */ |
| 1285 | REG_WR(bp, PBF_REG_HIGH_PRIORITY_COS_NUM, strict_cos); |
| 1286 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 1287 | /* |
| 1288 | * mapping between entry priority to client number (0,1,2 -debug and |
| 1289 | * management clients, 3 - COS0 client, 4 - COS client)(HIGHEST) |
| 1290 | * 3bits client num. |
| 1291 | * PRI4 | PRI3 | PRI2 | PRI1 | PRI0 |
| 1292 | * dbg0-010 dbg1-001 cos1-100 cos0-011 MCP-000 |
| 1293 | * dbg0-010 dbg1-001 cos0-011 cos1-100 MCP-000 |
| 1294 | */ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1295 | val = (0 == strict_cos) ? 0x2318 : 0x22E0; |
| 1296 | REG_WR(bp, NIG_REG_P0_TX_ARB_PRIORITY_CLIENT, val); |
| 1297 | |
| 1298 | return 0; |
| 1299 | } |
| 1300 | /******************************************************************/ |
Dmitry Kravkov | e892067 | 2011-05-04 23:52:40 +0000 | [diff] [blame] | 1301 | /* PFC section */ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1302 | /******************************************************************/ |
| 1303 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1304 | static void bnx2x_update_pfc_xmac(struct link_params *params, |
| 1305 | struct link_vars *vars, |
| 1306 | u8 is_lb) |
| 1307 | { |
| 1308 | struct bnx2x *bp = params->bp; |
| 1309 | u32 xmac_base; |
| 1310 | u32 pause_val, pfc0_val, pfc1_val; |
| 1311 | |
| 1312 | /* XMAC base adrr */ |
| 1313 | xmac_base = (params->port) ? GRCBASE_XMAC1 : GRCBASE_XMAC0; |
| 1314 | |
| 1315 | /* Initialize pause and pfc registers */ |
| 1316 | pause_val = 0x18000; |
| 1317 | pfc0_val = 0xFFFF8000; |
| 1318 | pfc1_val = 0x2; |
| 1319 | |
| 1320 | /* No PFC support */ |
| 1321 | if (!(params->feature_config_flags & |
| 1322 | FEATURE_CONFIG_PFC_ENABLED)) { |
| 1323 | |
| 1324 | /* |
| 1325 | * RX flow control - Process pause frame in receive direction |
| 1326 | */ |
| 1327 | if (vars->flow_ctrl & BNX2X_FLOW_CTRL_RX) |
| 1328 | pause_val |= XMAC_PAUSE_CTRL_REG_RX_PAUSE_EN; |
| 1329 | |
| 1330 | /* |
| 1331 | * TX flow control - Send pause packet when buffer is full |
| 1332 | */ |
| 1333 | if (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX) |
| 1334 | pause_val |= XMAC_PAUSE_CTRL_REG_TX_PAUSE_EN; |
| 1335 | } else {/* PFC support */ |
| 1336 | pfc1_val |= XMAC_PFC_CTRL_HI_REG_PFC_REFRESH_EN | |
| 1337 | XMAC_PFC_CTRL_HI_REG_PFC_STATS_EN | |
| 1338 | XMAC_PFC_CTRL_HI_REG_RX_PFC_EN | |
| 1339 | XMAC_PFC_CTRL_HI_REG_TX_PFC_EN; |
| 1340 | } |
| 1341 | |
| 1342 | /* Write pause and PFC registers */ |
| 1343 | REG_WR(bp, xmac_base + XMAC_REG_PAUSE_CTRL, pause_val); |
| 1344 | REG_WR(bp, xmac_base + XMAC_REG_PFC_CTRL, pfc0_val); |
| 1345 | REG_WR(bp, xmac_base + XMAC_REG_PFC_CTRL_HI, pfc1_val); |
| 1346 | |
Yaniv Rosner | b8d6d08 | 2011-07-05 01:06:27 +0000 | [diff] [blame] | 1347 | |
| 1348 | /* Set MAC address for source TX Pause/PFC frames */ |
| 1349 | REG_WR(bp, xmac_base + XMAC_REG_CTRL_SA_LO, |
| 1350 | ((params->mac_addr[2] << 24) | |
| 1351 | (params->mac_addr[3] << 16) | |
| 1352 | (params->mac_addr[4] << 8) | |
| 1353 | (params->mac_addr[5]))); |
| 1354 | REG_WR(bp, xmac_base + XMAC_REG_CTRL_SA_HI, |
| 1355 | ((params->mac_addr[0] << 8) | |
| 1356 | (params->mac_addr[1]))); |
| 1357 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1358 | udelay(30); |
| 1359 | } |
| 1360 | |
| 1361 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1362 | static void bnx2x_emac_get_pfc_stat(struct link_params *params, |
| 1363 | u32 pfc_frames_sent[2], |
| 1364 | u32 pfc_frames_received[2]) |
| 1365 | { |
| 1366 | /* Read pfc statistic */ |
| 1367 | struct bnx2x *bp = params->bp; |
| 1368 | u32 emac_base = params->port ? GRCBASE_EMAC1 : GRCBASE_EMAC0; |
| 1369 | u32 val_xon = 0; |
| 1370 | u32 val_xoff = 0; |
| 1371 | |
| 1372 | DP(NETIF_MSG_LINK, "pfc statistic read from EMAC\n"); |
| 1373 | |
| 1374 | /* PFC received frames */ |
| 1375 | val_xoff = REG_RD(bp, emac_base + |
| 1376 | EMAC_REG_RX_PFC_STATS_XOFF_RCVD); |
| 1377 | val_xoff &= EMAC_REG_RX_PFC_STATS_XOFF_RCVD_COUNT; |
| 1378 | val_xon = REG_RD(bp, emac_base + EMAC_REG_RX_PFC_STATS_XON_RCVD); |
| 1379 | val_xon &= EMAC_REG_RX_PFC_STATS_XON_RCVD_COUNT; |
| 1380 | |
| 1381 | pfc_frames_received[0] = val_xon + val_xoff; |
| 1382 | |
| 1383 | /* PFC received sent */ |
| 1384 | val_xoff = REG_RD(bp, emac_base + |
| 1385 | EMAC_REG_RX_PFC_STATS_XOFF_SENT); |
| 1386 | val_xoff &= EMAC_REG_RX_PFC_STATS_XOFF_SENT_COUNT; |
| 1387 | val_xon = REG_RD(bp, emac_base + EMAC_REG_RX_PFC_STATS_XON_SENT); |
| 1388 | val_xon &= EMAC_REG_RX_PFC_STATS_XON_SENT_COUNT; |
| 1389 | |
| 1390 | pfc_frames_sent[0] = val_xon + val_xoff; |
| 1391 | } |
| 1392 | |
Yaniv Rosner | b8d6d08 | 2011-07-05 01:06:27 +0000 | [diff] [blame] | 1393 | /* Read pfc statistic*/ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1394 | void bnx2x_pfc_statistic(struct link_params *params, struct link_vars *vars, |
| 1395 | u32 pfc_frames_sent[2], |
| 1396 | u32 pfc_frames_received[2]) |
| 1397 | { |
| 1398 | /* Read pfc statistic */ |
| 1399 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | b8d6d08 | 2011-07-05 01:06:27 +0000 | [diff] [blame] | 1400 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1401 | DP(NETIF_MSG_LINK, "pfc statistic\n"); |
| 1402 | |
| 1403 | if (!vars->link_up) |
| 1404 | return; |
| 1405 | |
Yaniv Rosner | b8d6d08 | 2011-07-05 01:06:27 +0000 | [diff] [blame] | 1406 | if (MAC_TYPE_EMAC == vars->mac_type) { |
| 1407 | DP(NETIF_MSG_LINK, "About to read PFC stats from EMAC\n"); |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1408 | bnx2x_emac_get_pfc_stat(params, pfc_frames_sent, |
| 1409 | pfc_frames_received); |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1410 | } |
| 1411 | } |
| 1412 | /******************************************************************/ |
| 1413 | /* MAC/PBF section */ |
| 1414 | /******************************************************************/ |
Yaniv Rosner | a198c14 | 2011-05-31 21:29:42 +0000 | [diff] [blame] | 1415 | static void bnx2x_set_mdio_clk(struct bnx2x *bp, u32 chip_id, u8 port) |
| 1416 | { |
| 1417 | u32 mode, emac_base; |
| 1418 | /** |
| 1419 | * Set clause 45 mode, slow down the MDIO clock to 2.5MHz |
| 1420 | * (a value of 49==0x31) and make sure that the AUTO poll is off |
| 1421 | */ |
| 1422 | |
| 1423 | if (CHIP_IS_E2(bp)) |
| 1424 | emac_base = GRCBASE_EMAC0; |
| 1425 | else |
| 1426 | emac_base = (port) ? GRCBASE_EMAC1 : GRCBASE_EMAC0; |
| 1427 | mode = REG_RD(bp, emac_base + EMAC_REG_EMAC_MDIO_MODE); |
| 1428 | mode &= ~(EMAC_MDIO_MODE_AUTO_POLL | |
| 1429 | EMAC_MDIO_MODE_CLOCK_CNT); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 1430 | if (USES_WARPCORE(bp)) |
| 1431 | mode |= (74L << EMAC_MDIO_MODE_CLOCK_CNT_BITSHIFT); |
| 1432 | else |
| 1433 | mode |= (49L << EMAC_MDIO_MODE_CLOCK_CNT_BITSHIFT); |
Yaniv Rosner | a198c14 | 2011-05-31 21:29:42 +0000 | [diff] [blame] | 1434 | |
| 1435 | mode |= (EMAC_MDIO_MODE_CLAUSE_45); |
| 1436 | REG_WR(bp, emac_base + EMAC_REG_EMAC_MDIO_MODE, mode); |
| 1437 | |
| 1438 | udelay(40); |
| 1439 | } |
| 1440 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1441 | static void bnx2x_emac_init(struct link_params *params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1442 | struct link_vars *vars) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1443 | { |
| 1444 | /* reset and unreset the emac core */ |
| 1445 | struct bnx2x *bp = params->bp; |
| 1446 | u8 port = params->port; |
| 1447 | u32 emac_base = port ? GRCBASE_EMAC1 : GRCBASE_EMAC0; |
| 1448 | u32 val; |
| 1449 | u16 timeout; |
| 1450 | |
| 1451 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_CLEAR, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1452 | (MISC_REGISTERS_RESET_REG_2_RST_EMAC0_HARD_CORE << port)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1453 | udelay(5); |
| 1454 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_SET, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1455 | (MISC_REGISTERS_RESET_REG_2_RST_EMAC0_HARD_CORE << port)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1456 | |
| 1457 | /* init emac - use read-modify-write */ |
| 1458 | /* self clear reset */ |
| 1459 | val = REG_RD(bp, emac_base + EMAC_REG_EMAC_MODE); |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 1460 | EMAC_WR(bp, EMAC_REG_EMAC_MODE, (val | EMAC_MODE_RESET)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1461 | |
| 1462 | timeout = 200; |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 1463 | do { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1464 | val = REG_RD(bp, emac_base + EMAC_REG_EMAC_MODE); |
| 1465 | DP(NETIF_MSG_LINK, "EMAC reset reg is %u\n", val); |
| 1466 | if (!timeout) { |
| 1467 | DP(NETIF_MSG_LINK, "EMAC timeout!\n"); |
| 1468 | return; |
| 1469 | } |
| 1470 | timeout--; |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 1471 | } while (val & EMAC_MODE_RESET); |
Yaniv Rosner | a198c14 | 2011-05-31 21:29:42 +0000 | [diff] [blame] | 1472 | bnx2x_set_mdio_clk(bp, params->chip_id, port); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1473 | /* Set mac address */ |
| 1474 | val = ((params->mac_addr[0] << 8) | |
| 1475 | params->mac_addr[1]); |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 1476 | EMAC_WR(bp, EMAC_REG_EMAC_MAC_MATCH, val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1477 | |
| 1478 | val = ((params->mac_addr[2] << 24) | |
| 1479 | (params->mac_addr[3] << 16) | |
| 1480 | (params->mac_addr[4] << 8) | |
| 1481 | params->mac_addr[5]); |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 1482 | EMAC_WR(bp, EMAC_REG_EMAC_MAC_MATCH + 4, val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1483 | } |
| 1484 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1485 | static void bnx2x_set_xumac_nig(struct link_params *params, |
| 1486 | u16 tx_pause_en, |
| 1487 | u8 enable) |
| 1488 | { |
| 1489 | struct bnx2x *bp = params->bp; |
| 1490 | |
| 1491 | REG_WR(bp, params->port ? NIG_REG_P1_MAC_IN_EN : NIG_REG_P0_MAC_IN_EN, |
| 1492 | enable); |
| 1493 | REG_WR(bp, params->port ? NIG_REG_P1_MAC_OUT_EN : NIG_REG_P0_MAC_OUT_EN, |
| 1494 | enable); |
| 1495 | REG_WR(bp, params->port ? NIG_REG_P1_MAC_PAUSE_OUT_EN : |
| 1496 | NIG_REG_P0_MAC_PAUSE_OUT_EN, tx_pause_en); |
| 1497 | } |
| 1498 | |
| 1499 | static void bnx2x_umac_enable(struct link_params *params, |
| 1500 | struct link_vars *vars, u8 lb) |
| 1501 | { |
| 1502 | u32 val; |
| 1503 | u32 umac_base = params->port ? GRCBASE_UMAC1 : GRCBASE_UMAC0; |
| 1504 | struct bnx2x *bp = params->bp; |
| 1505 | /* Reset UMAC */ |
| 1506 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_CLEAR, |
| 1507 | (MISC_REGISTERS_RESET_REG_2_UMAC0 << params->port)); |
| 1508 | usleep_range(1000, 1000); |
| 1509 | |
| 1510 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_SET, |
| 1511 | (MISC_REGISTERS_RESET_REG_2_UMAC0 << params->port)); |
| 1512 | |
| 1513 | DP(NETIF_MSG_LINK, "enabling UMAC\n"); |
| 1514 | |
| 1515 | /** |
| 1516 | * This register determines on which events the MAC will assert |
| 1517 | * error on the i/f to the NIG along w/ EOP. |
| 1518 | */ |
| 1519 | |
| 1520 | /** |
| 1521 | * BD REG_WR(bp, NIG_REG_P0_MAC_RSV_ERR_MASK + |
| 1522 | * params->port*0x14, 0xfffff. |
| 1523 | */ |
| 1524 | /* This register opens the gate for the UMAC despite its name */ |
| 1525 | REG_WR(bp, NIG_REG_EGRESS_EMAC0_PORT + params->port*4, 1); |
| 1526 | |
| 1527 | val = UMAC_COMMAND_CONFIG_REG_PROMIS_EN | |
| 1528 | UMAC_COMMAND_CONFIG_REG_PAD_EN | |
| 1529 | UMAC_COMMAND_CONFIG_REG_SW_RESET | |
| 1530 | UMAC_COMMAND_CONFIG_REG_NO_LGTH_CHECK; |
| 1531 | switch (vars->line_speed) { |
| 1532 | case SPEED_10: |
| 1533 | val |= (0<<2); |
| 1534 | break; |
| 1535 | case SPEED_100: |
| 1536 | val |= (1<<2); |
| 1537 | break; |
| 1538 | case SPEED_1000: |
| 1539 | val |= (2<<2); |
| 1540 | break; |
| 1541 | case SPEED_2500: |
| 1542 | val |= (3<<2); |
| 1543 | break; |
| 1544 | default: |
| 1545 | DP(NETIF_MSG_LINK, "Invalid speed for UMAC %d\n", |
| 1546 | vars->line_speed); |
| 1547 | break; |
| 1548 | } |
| 1549 | REG_WR(bp, umac_base + UMAC_REG_COMMAND_CONFIG, val); |
| 1550 | udelay(50); |
| 1551 | |
Yaniv Rosner | b8d6d08 | 2011-07-05 01:06:27 +0000 | [diff] [blame] | 1552 | /* Set MAC address for source TX Pause/PFC frames (under SW reset) */ |
| 1553 | REG_WR(bp, umac_base + UMAC_REG_MAC_ADDR0, |
| 1554 | ((params->mac_addr[2] << 24) | |
| 1555 | (params->mac_addr[3] << 16) | |
| 1556 | (params->mac_addr[4] << 8) | |
| 1557 | (params->mac_addr[5]))); |
| 1558 | REG_WR(bp, umac_base + UMAC_REG_MAC_ADDR1, |
| 1559 | ((params->mac_addr[0] << 8) | |
| 1560 | (params->mac_addr[1]))); |
| 1561 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1562 | /* Enable RX and TX */ |
| 1563 | val &= ~UMAC_COMMAND_CONFIG_REG_PAD_EN; |
| 1564 | val |= UMAC_COMMAND_CONFIG_REG_TX_ENA | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 1565 | UMAC_COMMAND_CONFIG_REG_RX_ENA; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1566 | REG_WR(bp, umac_base + UMAC_REG_COMMAND_CONFIG, val); |
| 1567 | udelay(50); |
| 1568 | |
| 1569 | /* Remove SW Reset */ |
| 1570 | val &= ~UMAC_COMMAND_CONFIG_REG_SW_RESET; |
| 1571 | |
| 1572 | /* Check loopback mode */ |
| 1573 | if (lb) |
| 1574 | val |= UMAC_COMMAND_CONFIG_REG_LOOP_ENA; |
| 1575 | REG_WR(bp, umac_base + UMAC_REG_COMMAND_CONFIG, val); |
| 1576 | |
| 1577 | /* |
| 1578 | * Maximum Frame Length (RW). Defines a 14-Bit maximum frame |
| 1579 | * length used by the MAC receive logic to check frames. |
| 1580 | */ |
| 1581 | REG_WR(bp, umac_base + UMAC_REG_MAXFR, 0x2710); |
| 1582 | bnx2x_set_xumac_nig(params, |
| 1583 | ((vars->flow_ctrl & BNX2X_FLOW_CTRL_TX) != 0), 1); |
| 1584 | vars->mac_type = MAC_TYPE_UMAC; |
| 1585 | |
| 1586 | } |
| 1587 | |
| 1588 | static u8 bnx2x_is_4_port_mode(struct bnx2x *bp) |
| 1589 | { |
| 1590 | u32 port4mode_ovwr_val; |
| 1591 | /* Check 4-port override enabled */ |
| 1592 | port4mode_ovwr_val = REG_RD(bp, MISC_REG_PORT4MODE_EN_OVWR); |
| 1593 | if (port4mode_ovwr_val & (1<<0)) { |
| 1594 | /* Return 4-port mode override value */ |
| 1595 | return ((port4mode_ovwr_val & (1<<1)) == (1<<1)); |
| 1596 | } |
| 1597 | /* Return 4-port mode from input pin */ |
| 1598 | return (u8)REG_RD(bp, MISC_REG_PORT4MODE_EN); |
| 1599 | } |
| 1600 | |
| 1601 | /* Define the XMAC mode */ |
| 1602 | static void bnx2x_xmac_init(struct bnx2x *bp, u32 max_speed) |
| 1603 | { |
| 1604 | u32 is_port4mode = bnx2x_is_4_port_mode(bp); |
| 1605 | |
| 1606 | /** |
| 1607 | * In 4-port mode, need to set the mode only once, so if XMAC is |
| 1608 | * already out of reset, it means the mode has already been set, |
| 1609 | * and it must not* reset the XMAC again, since it controls both |
| 1610 | * ports of the path |
| 1611 | **/ |
| 1612 | |
| 1613 | if (is_port4mode && (REG_RD(bp, MISC_REG_RESET_REG_2) & |
| 1614 | MISC_REGISTERS_RESET_REG_2_XMAC)) { |
| 1615 | DP(NETIF_MSG_LINK, "XMAC already out of reset" |
| 1616 | " in 4-port mode\n"); |
| 1617 | return; |
| 1618 | } |
| 1619 | |
| 1620 | /* Hard reset */ |
| 1621 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_CLEAR, |
| 1622 | MISC_REGISTERS_RESET_REG_2_XMAC); |
| 1623 | usleep_range(1000, 1000); |
| 1624 | |
| 1625 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_SET, |
| 1626 | MISC_REGISTERS_RESET_REG_2_XMAC); |
| 1627 | if (is_port4mode) { |
| 1628 | DP(NETIF_MSG_LINK, "Init XMAC to 2 ports x 10G per path\n"); |
| 1629 | |
| 1630 | /* Set the number of ports on the system side to up to 2 */ |
| 1631 | REG_WR(bp, MISC_REG_XMAC_CORE_PORT_MODE, 1); |
| 1632 | |
| 1633 | /* Set the number of ports on the Warp Core to 10G */ |
| 1634 | REG_WR(bp, MISC_REG_XMAC_PHY_PORT_MODE, 3); |
| 1635 | } else { |
| 1636 | /* Set the number of ports on the system side to 1 */ |
| 1637 | REG_WR(bp, MISC_REG_XMAC_CORE_PORT_MODE, 0); |
| 1638 | if (max_speed == SPEED_10000) { |
| 1639 | DP(NETIF_MSG_LINK, "Init XMAC to 10G x 1" |
| 1640 | " port per path\n"); |
| 1641 | /* Set the number of ports on the Warp Core to 10G */ |
| 1642 | REG_WR(bp, MISC_REG_XMAC_PHY_PORT_MODE, 3); |
| 1643 | } else { |
| 1644 | DP(NETIF_MSG_LINK, "Init XMAC to 20G x 2 ports" |
| 1645 | " per path\n"); |
| 1646 | /* Set the number of ports on the Warp Core to 20G */ |
| 1647 | REG_WR(bp, MISC_REG_XMAC_PHY_PORT_MODE, 1); |
| 1648 | } |
| 1649 | } |
| 1650 | /* Soft reset */ |
| 1651 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_CLEAR, |
| 1652 | MISC_REGISTERS_RESET_REG_2_XMAC_SOFT); |
| 1653 | usleep_range(1000, 1000); |
| 1654 | |
| 1655 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_SET, |
| 1656 | MISC_REGISTERS_RESET_REG_2_XMAC_SOFT); |
| 1657 | |
| 1658 | } |
| 1659 | |
| 1660 | static void bnx2x_xmac_disable(struct link_params *params) |
| 1661 | { |
| 1662 | u8 port = params->port; |
| 1663 | struct bnx2x *bp = params->bp; |
| 1664 | u32 xmac_base = (port) ? GRCBASE_XMAC1 : GRCBASE_XMAC0; |
| 1665 | |
| 1666 | if (REG_RD(bp, MISC_REG_RESET_REG_2) & |
| 1667 | MISC_REGISTERS_RESET_REG_2_XMAC) { |
| 1668 | DP(NETIF_MSG_LINK, "Disable XMAC on port %x\n", port); |
| 1669 | REG_WR(bp, xmac_base + XMAC_REG_CTRL, 0); |
| 1670 | usleep_range(1000, 1000); |
| 1671 | bnx2x_set_xumac_nig(params, 0, 0); |
| 1672 | REG_WR(bp, xmac_base + XMAC_REG_CTRL, |
| 1673 | XMAC_CTRL_REG_SOFT_RESET); |
| 1674 | } |
| 1675 | } |
| 1676 | |
| 1677 | static int bnx2x_xmac_enable(struct link_params *params, |
| 1678 | struct link_vars *vars, u8 lb) |
| 1679 | { |
| 1680 | u32 val, xmac_base; |
| 1681 | struct bnx2x *bp = params->bp; |
| 1682 | DP(NETIF_MSG_LINK, "enabling XMAC\n"); |
| 1683 | |
| 1684 | xmac_base = (params->port) ? GRCBASE_XMAC1 : GRCBASE_XMAC0; |
| 1685 | |
| 1686 | bnx2x_xmac_init(bp, vars->line_speed); |
| 1687 | |
| 1688 | /* |
| 1689 | * This register determines on which events the MAC will assert |
| 1690 | * error on the i/f to the NIG along w/ EOP. |
| 1691 | */ |
| 1692 | |
| 1693 | /* |
| 1694 | * This register tells the NIG whether to send traffic to UMAC |
| 1695 | * or XMAC |
| 1696 | */ |
| 1697 | REG_WR(bp, NIG_REG_EGRESS_EMAC0_PORT + params->port*4, 0); |
| 1698 | |
| 1699 | /* Set Max packet size */ |
| 1700 | REG_WR(bp, xmac_base + XMAC_REG_RX_MAX_SIZE, 0x2710); |
| 1701 | |
| 1702 | /* CRC append for Tx packets */ |
| 1703 | REG_WR(bp, xmac_base + XMAC_REG_TX_CTRL, 0xC800); |
| 1704 | |
| 1705 | /* update PFC */ |
| 1706 | bnx2x_update_pfc_xmac(params, vars, 0); |
| 1707 | |
| 1708 | /* Enable TX and RX */ |
| 1709 | val = XMAC_CTRL_REG_TX_EN | XMAC_CTRL_REG_RX_EN; |
| 1710 | |
| 1711 | /* Check loopback mode */ |
| 1712 | if (lb) |
| 1713 | val |= XMAC_CTRL_REG_CORE_LOCAL_LPBK; |
| 1714 | REG_WR(bp, xmac_base + XMAC_REG_CTRL, val); |
| 1715 | bnx2x_set_xumac_nig(params, |
| 1716 | ((vars->flow_ctrl & BNX2X_FLOW_CTRL_TX) != 0), 1); |
| 1717 | |
| 1718 | vars->mac_type = MAC_TYPE_XMAC; |
| 1719 | |
| 1720 | return 0; |
| 1721 | } |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 1722 | static int bnx2x_emac_enable(struct link_params *params, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 1723 | struct link_vars *vars, u8 lb) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1724 | { |
| 1725 | struct bnx2x *bp = params->bp; |
| 1726 | u8 port = params->port; |
| 1727 | u32 emac_base = port ? GRCBASE_EMAC1 : GRCBASE_EMAC0; |
| 1728 | u32 val; |
| 1729 | |
| 1730 | DP(NETIF_MSG_LINK, "enabling EMAC\n"); |
| 1731 | |
| 1732 | /* enable emac and not bmac */ |
| 1733 | REG_WR(bp, NIG_REG_EGRESS_EMAC0_PORT + port*4, 1); |
| 1734 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1735 | /* ASIC */ |
| 1736 | if (vars->phy_flags & PHY_XGXS_FLAG) { |
| 1737 | u32 ser_lane = ((params->lane_config & |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1738 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_MASK) >> |
| 1739 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_SHIFT); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1740 | |
| 1741 | DP(NETIF_MSG_LINK, "XGXS\n"); |
| 1742 | /* select the master lanes (out of 0-3) */ |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1743 | REG_WR(bp, NIG_REG_XGXS_LANE_SEL_P0 + port*4, ser_lane); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1744 | /* select XGXS */ |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1745 | REG_WR(bp, NIG_REG_XGXS_SERDES0_MODE_SEL + port*4, 1); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1746 | |
| 1747 | } else { /* SerDes */ |
| 1748 | DP(NETIF_MSG_LINK, "SerDes\n"); |
| 1749 | /* select SerDes */ |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1750 | REG_WR(bp, NIG_REG_XGXS_SERDES0_MODE_SEL + port*4, 0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1751 | } |
| 1752 | |
Eilon Greenstein | 811a2f2 | 2009-02-12 08:37:04 +0000 | [diff] [blame] | 1753 | bnx2x_bits_en(bp, emac_base + EMAC_REG_EMAC_RX_MODE, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1754 | EMAC_RX_MODE_RESET); |
Eilon Greenstein | 811a2f2 | 2009-02-12 08:37:04 +0000 | [diff] [blame] | 1755 | bnx2x_bits_en(bp, emac_base + EMAC_REG_EMAC_TX_MODE, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1756 | EMAC_TX_MODE_RESET); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1757 | |
| 1758 | if (CHIP_REV_IS_SLOW(bp)) { |
| 1759 | /* config GMII mode */ |
| 1760 | val = REG_RD(bp, emac_base + EMAC_REG_EMAC_MODE); |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1761 | EMAC_WR(bp, EMAC_REG_EMAC_MODE, (val | EMAC_MODE_PORT_GMII)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1762 | } else { /* ASIC */ |
| 1763 | /* pause enable/disable */ |
| 1764 | bnx2x_bits_dis(bp, emac_base + EMAC_REG_EMAC_RX_MODE, |
| 1765 | EMAC_RX_MODE_FLOW_EN); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1766 | |
| 1767 | bnx2x_bits_dis(bp, emac_base + EMAC_REG_EMAC_TX_MODE, |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1768 | (EMAC_TX_MODE_EXT_PAUSE_EN | |
| 1769 | EMAC_TX_MODE_FLOW_EN)); |
| 1770 | if (!(params->feature_config_flags & |
| 1771 | FEATURE_CONFIG_PFC_ENABLED)) { |
| 1772 | if (vars->flow_ctrl & BNX2X_FLOW_CTRL_RX) |
| 1773 | bnx2x_bits_en(bp, emac_base + |
| 1774 | EMAC_REG_EMAC_RX_MODE, |
| 1775 | EMAC_RX_MODE_FLOW_EN); |
| 1776 | |
| 1777 | if (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX) |
| 1778 | bnx2x_bits_en(bp, emac_base + |
| 1779 | EMAC_REG_EMAC_TX_MODE, |
| 1780 | (EMAC_TX_MODE_EXT_PAUSE_EN | |
| 1781 | EMAC_TX_MODE_FLOW_EN)); |
| 1782 | } else |
| 1783 | bnx2x_bits_en(bp, emac_base + EMAC_REG_EMAC_TX_MODE, |
| 1784 | EMAC_TX_MODE_FLOW_EN); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1785 | } |
| 1786 | |
| 1787 | /* KEEP_VLAN_TAG, promiscuous */ |
| 1788 | val = REG_RD(bp, emac_base + EMAC_REG_EMAC_RX_MODE); |
| 1789 | val |= EMAC_RX_MODE_KEEP_VLAN_TAG | EMAC_RX_MODE_PROMISCUOUS; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1790 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 1791 | /* |
| 1792 | * Setting this bit causes MAC control frames (except for pause |
| 1793 | * frames) to be passed on for processing. This setting has no |
| 1794 | * affect on the operation of the pause frames. This bit effects |
| 1795 | * all packets regardless of RX Parser packet sorting logic. |
| 1796 | * Turn the PFC off to make sure we are in Xon state before |
| 1797 | * enabling it. |
| 1798 | */ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1799 | EMAC_WR(bp, EMAC_REG_RX_PFC_MODE, 0); |
| 1800 | if (params->feature_config_flags & FEATURE_CONFIG_PFC_ENABLED) { |
| 1801 | DP(NETIF_MSG_LINK, "PFC is enabled\n"); |
| 1802 | /* Enable PFC again */ |
| 1803 | EMAC_WR(bp, EMAC_REG_RX_PFC_MODE, |
| 1804 | EMAC_REG_RX_PFC_MODE_RX_EN | |
| 1805 | EMAC_REG_RX_PFC_MODE_TX_EN | |
| 1806 | EMAC_REG_RX_PFC_MODE_PRIORITIES); |
| 1807 | |
| 1808 | EMAC_WR(bp, EMAC_REG_RX_PFC_PARAM, |
| 1809 | ((0x0101 << |
| 1810 | EMAC_REG_RX_PFC_PARAM_OPCODE_BITSHIFT) | |
| 1811 | (0x00ff << |
| 1812 | EMAC_REG_RX_PFC_PARAM_PRIORITY_EN_BITSHIFT))); |
| 1813 | val |= EMAC_RX_MODE_KEEP_MAC_CONTROL; |
| 1814 | } |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 1815 | EMAC_WR(bp, EMAC_REG_EMAC_RX_MODE, val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1816 | |
| 1817 | /* Set Loopback */ |
| 1818 | val = REG_RD(bp, emac_base + EMAC_REG_EMAC_MODE); |
| 1819 | if (lb) |
| 1820 | val |= 0x810; |
| 1821 | else |
| 1822 | val &= ~0x810; |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 1823 | EMAC_WR(bp, EMAC_REG_EMAC_MODE, val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1824 | |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 1825 | /* enable emac */ |
| 1826 | REG_WR(bp, NIG_REG_NIG_EMAC0_EN + port*4, 1); |
| 1827 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1828 | /* enable emac for jumbo packets */ |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 1829 | EMAC_WR(bp, EMAC_REG_EMAC_RX_MTU_SIZE, |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1830 | (EMAC_RX_MTU_SIZE_JUMBO_ENA | |
| 1831 | (ETH_MAX_JUMBO_PACKET_SIZE + ETH_OVREHEAD))); |
| 1832 | |
| 1833 | /* strip CRC */ |
| 1834 | REG_WR(bp, NIG_REG_NIG_INGRESS_EMAC0_NO_CRC + port*4, 0x1); |
| 1835 | |
| 1836 | /* disable the NIG in/out to the bmac */ |
| 1837 | REG_WR(bp, NIG_REG_BMAC0_IN_EN + port*4, 0x0); |
| 1838 | REG_WR(bp, NIG_REG_BMAC0_PAUSE_OUT_EN + port*4, 0x0); |
| 1839 | REG_WR(bp, NIG_REG_BMAC0_OUT_EN + port*4, 0x0); |
| 1840 | |
| 1841 | /* enable the NIG in/out to the emac */ |
| 1842 | REG_WR(bp, NIG_REG_EMAC0_IN_EN + port*4, 0x1); |
| 1843 | val = 0; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1844 | if ((params->feature_config_flags & |
| 1845 | FEATURE_CONFIG_PFC_ENABLED) || |
| 1846 | (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX)) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1847 | val = 1; |
| 1848 | |
| 1849 | REG_WR(bp, NIG_REG_EMAC0_PAUSE_OUT_EN + port*4, val); |
| 1850 | REG_WR(bp, NIG_REG_EGRESS_EMAC0_OUT_EN + port*4, 0x1); |
| 1851 | |
Yaniv Rosner | 02a2316 | 2011-01-31 04:22:53 +0000 | [diff] [blame] | 1852 | REG_WR(bp, NIG_REG_BMAC0_REGS_OUT_EN + port*4, 0x0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1853 | |
| 1854 | vars->mac_type = MAC_TYPE_EMAC; |
| 1855 | return 0; |
| 1856 | } |
| 1857 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1858 | static void bnx2x_update_pfc_bmac1(struct link_params *params, |
| 1859 | struct link_vars *vars) |
| 1860 | { |
| 1861 | u32 wb_data[2]; |
| 1862 | struct bnx2x *bp = params->bp; |
| 1863 | u32 bmac_addr = params->port ? NIG_REG_INGRESS_BMAC1_MEM : |
| 1864 | NIG_REG_INGRESS_BMAC0_MEM; |
| 1865 | |
| 1866 | u32 val = 0x14; |
| 1867 | if ((!(params->feature_config_flags & |
| 1868 | FEATURE_CONFIG_PFC_ENABLED)) && |
| 1869 | (vars->flow_ctrl & BNX2X_FLOW_CTRL_RX)) |
| 1870 | /* Enable BigMAC to react on received Pause packets */ |
| 1871 | val |= (1<<5); |
| 1872 | wb_data[0] = val; |
| 1873 | wb_data[1] = 0; |
| 1874 | REG_WR_DMAE(bp, bmac_addr + BIGMAC_REGISTER_RX_CONTROL, wb_data, 2); |
| 1875 | |
| 1876 | /* tx control */ |
| 1877 | val = 0xc0; |
| 1878 | if (!(params->feature_config_flags & |
| 1879 | FEATURE_CONFIG_PFC_ENABLED) && |
| 1880 | (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX)) |
| 1881 | val |= 0x800000; |
| 1882 | wb_data[0] = val; |
| 1883 | wb_data[1] = 0; |
| 1884 | REG_WR_DMAE(bp, bmac_addr + BIGMAC_REGISTER_TX_CONTROL, wb_data, 2); |
| 1885 | } |
| 1886 | |
| 1887 | static void bnx2x_update_pfc_bmac2(struct link_params *params, |
| 1888 | struct link_vars *vars, |
| 1889 | u8 is_lb) |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1890 | { |
| 1891 | /* |
| 1892 | * Set rx control: Strip CRC and enable BigMAC to relay |
| 1893 | * control packets to the system as well |
| 1894 | */ |
| 1895 | u32 wb_data[2]; |
| 1896 | struct bnx2x *bp = params->bp; |
| 1897 | u32 bmac_addr = params->port ? NIG_REG_INGRESS_BMAC1_MEM : |
| 1898 | NIG_REG_INGRESS_BMAC0_MEM; |
| 1899 | u32 val = 0x14; |
| 1900 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1901 | if ((!(params->feature_config_flags & |
| 1902 | FEATURE_CONFIG_PFC_ENABLED)) && |
| 1903 | (vars->flow_ctrl & BNX2X_FLOW_CTRL_RX)) |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1904 | /* Enable BigMAC to react on received Pause packets */ |
| 1905 | val |= (1<<5); |
| 1906 | wb_data[0] = val; |
| 1907 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1908 | REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_RX_CONTROL, wb_data, 2); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1909 | udelay(30); |
| 1910 | |
| 1911 | /* Tx control */ |
| 1912 | val = 0xc0; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1913 | if (!(params->feature_config_flags & |
| 1914 | FEATURE_CONFIG_PFC_ENABLED) && |
| 1915 | (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX)) |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1916 | val |= 0x800000; |
| 1917 | wb_data[0] = val; |
| 1918 | wb_data[1] = 0; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1919 | REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_TX_CONTROL, wb_data, 2); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1920 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1921 | if (params->feature_config_flags & FEATURE_CONFIG_PFC_ENABLED) { |
| 1922 | DP(NETIF_MSG_LINK, "PFC is enabled\n"); |
| 1923 | /* Enable PFC RX & TX & STATS and set 8 COS */ |
| 1924 | wb_data[0] = 0x0; |
| 1925 | wb_data[0] |= (1<<0); /* RX */ |
| 1926 | wb_data[0] |= (1<<1); /* TX */ |
| 1927 | wb_data[0] |= (1<<2); /* Force initial Xon */ |
| 1928 | wb_data[0] |= (1<<3); /* 8 cos */ |
| 1929 | wb_data[0] |= (1<<5); /* STATS */ |
| 1930 | wb_data[1] = 0; |
| 1931 | REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_PFC_CONTROL, |
| 1932 | wb_data, 2); |
| 1933 | /* Clear the force Xon */ |
| 1934 | wb_data[0] &= ~(1<<2); |
| 1935 | } else { |
| 1936 | DP(NETIF_MSG_LINK, "PFC is disabled\n"); |
| 1937 | /* disable PFC RX & TX & STATS and set 8 COS */ |
| 1938 | wb_data[0] = 0x8; |
| 1939 | wb_data[1] = 0; |
| 1940 | } |
| 1941 | |
| 1942 | REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_PFC_CONTROL, wb_data, 2); |
| 1943 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 1944 | /* |
| 1945 | * Set Time (based unit is 512 bit time) between automatic |
| 1946 | * re-sending of PP packets amd enable automatic re-send of |
| 1947 | * Per-Priroity Packet as long as pp_gen is asserted and |
| 1948 | * pp_disable is low. |
| 1949 | */ |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1950 | val = 0x8000; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1951 | if (params->feature_config_flags & FEATURE_CONFIG_PFC_ENABLED) |
| 1952 | val |= (1<<16); /* enable automatic re-send */ |
| 1953 | |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1954 | wb_data[0] = val; |
| 1955 | wb_data[1] = 0; |
| 1956 | REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_TX_PAUSE_CONTROL, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1957 | wb_data, 2); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1958 | |
| 1959 | /* mac control */ |
| 1960 | val = 0x3; /* Enable RX and TX */ |
| 1961 | if (is_lb) { |
| 1962 | val |= 0x4; /* Local loopback */ |
| 1963 | DP(NETIF_MSG_LINK, "enable bmac loopback\n"); |
| 1964 | } |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1965 | /* When PFC enabled, Pass pause frames towards the NIG. */ |
| 1966 | if (params->feature_config_flags & FEATURE_CONFIG_PFC_ENABLED) |
| 1967 | val |= ((1<<6)|(1<<5)); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1968 | |
| 1969 | wb_data[0] = val; |
| 1970 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1971 | REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_BMAC_CONTROL, wb_data, 2); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1972 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1973 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1974 | |
| 1975 | /* PFC BRB internal port configuration params */ |
| 1976 | struct bnx2x_pfc_brb_threshold_val { |
| 1977 | u32 pause_xoff; |
| 1978 | u32 pause_xon; |
| 1979 | u32 full_xoff; |
| 1980 | u32 full_xon; |
| 1981 | }; |
| 1982 | |
| 1983 | struct bnx2x_pfc_brb_e3b0_val { |
| 1984 | u32 full_lb_xoff_th; |
| 1985 | u32 full_lb_xon_threshold; |
| 1986 | u32 lb_guarantied; |
| 1987 | u32 mac_0_class_t_guarantied; |
| 1988 | u32 mac_0_class_t_guarantied_hyst; |
| 1989 | u32 mac_1_class_t_guarantied; |
| 1990 | u32 mac_1_class_t_guarantied_hyst; |
| 1991 | }; |
| 1992 | |
| 1993 | struct bnx2x_pfc_brb_th_val { |
| 1994 | struct bnx2x_pfc_brb_threshold_val pauseable_th; |
| 1995 | struct bnx2x_pfc_brb_threshold_val non_pauseable_th; |
| 1996 | }; |
| 1997 | static int bnx2x_pfc_brb_get_config_params( |
| 1998 | struct link_params *params, |
| 1999 | struct bnx2x_pfc_brb_th_val *config_val) |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2000 | { |
| 2001 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2002 | DP(NETIF_MSG_LINK, "Setting PFC BRB configuration\n"); |
| 2003 | if (CHIP_IS_E2(bp)) { |
| 2004 | config_val->pauseable_th.pause_xoff = |
| 2005 | PFC_E2_BRB_MAC_PAUSE_XOFF_THR_PAUSE; |
| 2006 | config_val->pauseable_th.pause_xon = |
| 2007 | PFC_E2_BRB_MAC_PAUSE_XON_THR_PAUSE; |
| 2008 | config_val->pauseable_th.full_xoff = |
| 2009 | PFC_E2_BRB_MAC_FULL_XOFF_THR_PAUSE; |
| 2010 | config_val->pauseable_th.full_xon = |
| 2011 | PFC_E2_BRB_MAC_FULL_XON_THR_PAUSE; |
| 2012 | /* non pause able*/ |
| 2013 | config_val->non_pauseable_th.pause_xoff = |
| 2014 | PFC_E2_BRB_MAC_PAUSE_XOFF_THR_NON_PAUSE; |
| 2015 | config_val->non_pauseable_th.pause_xon = |
| 2016 | PFC_E2_BRB_MAC_PAUSE_XON_THR_NON_PAUSE; |
| 2017 | config_val->non_pauseable_th.full_xoff = |
| 2018 | PFC_E2_BRB_MAC_FULL_XOFF_THR_NON_PAUSE; |
| 2019 | config_val->non_pauseable_th.full_xon = |
| 2020 | PFC_E2_BRB_MAC_FULL_XON_THR_NON_PAUSE; |
| 2021 | } else if (CHIP_IS_E3A0(bp)) { |
| 2022 | config_val->pauseable_th.pause_xoff = |
| 2023 | PFC_E3A0_BRB_MAC_PAUSE_XOFF_THR_PAUSE; |
| 2024 | config_val->pauseable_th.pause_xon = |
| 2025 | PFC_E3A0_BRB_MAC_PAUSE_XON_THR_PAUSE; |
| 2026 | config_val->pauseable_th.full_xoff = |
| 2027 | PFC_E3A0_BRB_MAC_FULL_XOFF_THR_PAUSE; |
| 2028 | config_val->pauseable_th.full_xon = |
| 2029 | PFC_E3A0_BRB_MAC_FULL_XON_THR_PAUSE; |
| 2030 | /* non pause able*/ |
| 2031 | config_val->non_pauseable_th.pause_xoff = |
| 2032 | PFC_E3A0_BRB_MAC_PAUSE_XOFF_THR_NON_PAUSE; |
| 2033 | config_val->non_pauseable_th.pause_xon = |
| 2034 | PFC_E3A0_BRB_MAC_PAUSE_XON_THR_NON_PAUSE; |
| 2035 | config_val->non_pauseable_th.full_xoff = |
| 2036 | PFC_E3A0_BRB_MAC_FULL_XOFF_THR_NON_PAUSE; |
| 2037 | config_val->non_pauseable_th.full_xon = |
| 2038 | PFC_E3A0_BRB_MAC_FULL_XON_THR_NON_PAUSE; |
| 2039 | } else if (CHIP_IS_E3B0(bp)) { |
| 2040 | if (params->phy[INT_PHY].flags & |
| 2041 | FLAGS_4_PORT_MODE) { |
| 2042 | config_val->pauseable_th.pause_xoff = |
| 2043 | PFC_E3B0_4P_BRB_MAC_PAUSE_XOFF_THR_PAUSE; |
| 2044 | config_val->pauseable_th.pause_xon = |
| 2045 | PFC_E3B0_4P_BRB_MAC_PAUSE_XON_THR_PAUSE; |
| 2046 | config_val->pauseable_th.full_xoff = |
| 2047 | PFC_E3B0_4P_BRB_MAC_FULL_XOFF_THR_PAUSE; |
| 2048 | config_val->pauseable_th.full_xon = |
| 2049 | PFC_E3B0_4P_BRB_MAC_FULL_XON_THR_PAUSE; |
| 2050 | /* non pause able*/ |
| 2051 | config_val->non_pauseable_th.pause_xoff = |
| 2052 | PFC_E3B0_4P_BRB_MAC_PAUSE_XOFF_THR_NON_PAUSE; |
| 2053 | config_val->non_pauseable_th.pause_xon = |
| 2054 | PFC_E3B0_4P_BRB_MAC_PAUSE_XON_THR_NON_PAUSE; |
| 2055 | config_val->non_pauseable_th.full_xoff = |
| 2056 | PFC_E3B0_4P_BRB_MAC_FULL_XOFF_THR_NON_PAUSE; |
| 2057 | config_val->non_pauseable_th.full_xon = |
| 2058 | PFC_E3B0_4P_BRB_MAC_FULL_XON_THR_NON_PAUSE; |
| 2059 | } else { |
| 2060 | config_val->pauseable_th.pause_xoff = |
| 2061 | PFC_E3B0_2P_BRB_MAC_PAUSE_XOFF_THR_PAUSE; |
| 2062 | config_val->pauseable_th.pause_xon = |
| 2063 | PFC_E3B0_2P_BRB_MAC_PAUSE_XON_THR_PAUSE; |
| 2064 | config_val->pauseable_th.full_xoff = |
| 2065 | PFC_E3B0_2P_BRB_MAC_FULL_XOFF_THR_PAUSE; |
| 2066 | config_val->pauseable_th.full_xon = |
| 2067 | PFC_E3B0_2P_BRB_MAC_FULL_XON_THR_PAUSE; |
| 2068 | /* non pause able*/ |
| 2069 | config_val->non_pauseable_th.pause_xoff = |
| 2070 | PFC_E3B0_2P_BRB_MAC_PAUSE_XOFF_THR_NON_PAUSE; |
| 2071 | config_val->non_pauseable_th.pause_xon = |
| 2072 | PFC_E3B0_2P_BRB_MAC_PAUSE_XON_THR_NON_PAUSE; |
| 2073 | config_val->non_pauseable_th.full_xoff = |
| 2074 | PFC_E3B0_2P_BRB_MAC_FULL_XOFF_THR_NON_PAUSE; |
| 2075 | config_val->non_pauseable_th.full_xon = |
| 2076 | PFC_E3B0_2P_BRB_MAC_FULL_XON_THR_NON_PAUSE; |
| 2077 | } |
| 2078 | } else |
| 2079 | return -EINVAL; |
| 2080 | |
| 2081 | return 0; |
| 2082 | } |
| 2083 | |
| 2084 | |
| 2085 | static void bnx2x_pfc_brb_get_e3b0_config_params(struct link_params *params, |
| 2086 | struct bnx2x_pfc_brb_e3b0_val |
| 2087 | *e3b0_val, |
| 2088 | u32 cos0_pauseable, |
| 2089 | u32 cos1_pauseable) |
| 2090 | { |
| 2091 | if (params->phy[INT_PHY].flags & FLAGS_4_PORT_MODE) { |
| 2092 | e3b0_val->full_lb_xoff_th = |
| 2093 | PFC_E3B0_4P_BRB_FULL_LB_XOFF_THR; |
| 2094 | e3b0_val->full_lb_xon_threshold = |
| 2095 | PFC_E3B0_4P_BRB_FULL_LB_XON_THR; |
| 2096 | e3b0_val->lb_guarantied = |
| 2097 | PFC_E3B0_4P_LB_GUART; |
| 2098 | e3b0_val->mac_0_class_t_guarantied = |
| 2099 | PFC_E3B0_4P_BRB_MAC_0_CLASS_T_GUART; |
| 2100 | e3b0_val->mac_0_class_t_guarantied_hyst = |
| 2101 | PFC_E3B0_4P_BRB_MAC_0_CLASS_T_GUART_HYST; |
| 2102 | e3b0_val->mac_1_class_t_guarantied = |
| 2103 | PFC_E3B0_4P_BRB_MAC_1_CLASS_T_GUART; |
| 2104 | e3b0_val->mac_1_class_t_guarantied_hyst = |
| 2105 | PFC_E3B0_4P_BRB_MAC_1_CLASS_T_GUART_HYST; |
| 2106 | } else { |
| 2107 | e3b0_val->full_lb_xoff_th = |
| 2108 | PFC_E3B0_2P_BRB_FULL_LB_XOFF_THR; |
| 2109 | e3b0_val->full_lb_xon_threshold = |
| 2110 | PFC_E3B0_2P_BRB_FULL_LB_XON_THR; |
| 2111 | e3b0_val->mac_0_class_t_guarantied_hyst = |
| 2112 | PFC_E3B0_2P_BRB_MAC_0_CLASS_T_GUART_HYST; |
| 2113 | e3b0_val->mac_1_class_t_guarantied = |
| 2114 | PFC_E3B0_2P_BRB_MAC_1_CLASS_T_GUART; |
| 2115 | e3b0_val->mac_1_class_t_guarantied_hyst = |
| 2116 | PFC_E3B0_2P_BRB_MAC_1_CLASS_T_GUART_HYST; |
| 2117 | |
| 2118 | if (cos0_pauseable != cos1_pauseable) { |
| 2119 | /* nonpauseable= Lossy + pauseable = Lossless*/ |
| 2120 | e3b0_val->lb_guarantied = |
| 2121 | PFC_E3B0_2P_MIX_PAUSE_LB_GUART; |
| 2122 | e3b0_val->mac_0_class_t_guarantied = |
| 2123 | PFC_E3B0_2P_MIX_PAUSE_MAC_0_CLASS_T_GUART; |
| 2124 | } else if (cos0_pauseable) { |
| 2125 | /* Lossless +Lossless*/ |
| 2126 | e3b0_val->lb_guarantied = |
| 2127 | PFC_E3B0_2P_PAUSE_LB_GUART; |
| 2128 | e3b0_val->mac_0_class_t_guarantied = |
| 2129 | PFC_E3B0_2P_PAUSE_MAC_0_CLASS_T_GUART; |
| 2130 | } else { |
| 2131 | /* Lossy +Lossy*/ |
| 2132 | e3b0_val->lb_guarantied = |
| 2133 | PFC_E3B0_2P_NON_PAUSE_LB_GUART; |
| 2134 | e3b0_val->mac_0_class_t_guarantied = |
| 2135 | PFC_E3B0_2P_NON_PAUSE_MAC_0_CLASS_T_GUART; |
| 2136 | } |
| 2137 | } |
| 2138 | } |
| 2139 | static int bnx2x_update_pfc_brb(struct link_params *params, |
| 2140 | struct link_vars *vars, |
| 2141 | struct bnx2x_nig_brb_pfc_port_params |
| 2142 | *pfc_params) |
| 2143 | { |
| 2144 | struct bnx2x *bp = params->bp; |
| 2145 | struct bnx2x_pfc_brb_th_val config_val = { {0} }; |
| 2146 | struct bnx2x_pfc_brb_threshold_val *reg_th_config = |
| 2147 | &config_val.pauseable_th; |
| 2148 | struct bnx2x_pfc_brb_e3b0_val e3b0_val = {0}; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2149 | int set_pfc = params->feature_config_flags & |
| 2150 | FEATURE_CONFIG_PFC_ENABLED; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2151 | int bnx2x_status = 0; |
| 2152 | u8 port = params->port; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2153 | |
| 2154 | /* default - pause configuration */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2155 | reg_th_config = &config_val.pauseable_th; |
| 2156 | bnx2x_status = bnx2x_pfc_brb_get_config_params(params, &config_val); |
| 2157 | if (0 != bnx2x_status) |
| 2158 | return bnx2x_status; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2159 | |
| 2160 | if (set_pfc && pfc_params) |
| 2161 | /* First COS */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2162 | if (!pfc_params->cos0_pauseable) |
| 2163 | reg_th_config = &config_val.non_pauseable_th; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2164 | /* |
| 2165 | * The number of free blocks below which the pause signal to class 0 |
| 2166 | * of MAC #n is asserted. n=0,1 |
| 2167 | */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2168 | REG_WR(bp, (port) ? BRB1_REG_PAUSE_0_XOFF_THRESHOLD_1 : |
| 2169 | BRB1_REG_PAUSE_0_XOFF_THRESHOLD_0 , |
| 2170 | reg_th_config->pause_xoff); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2171 | /* |
| 2172 | * The number of free blocks above which the pause signal to class 0 |
| 2173 | * of MAC #n is de-asserted. n=0,1 |
| 2174 | */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2175 | REG_WR(bp, (port) ? BRB1_REG_PAUSE_0_XON_THRESHOLD_1 : |
| 2176 | BRB1_REG_PAUSE_0_XON_THRESHOLD_0 , reg_th_config->pause_xon); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2177 | /* |
| 2178 | * The number of free blocks below which the full signal to class 0 |
| 2179 | * of MAC #n is asserted. n=0,1 |
| 2180 | */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2181 | REG_WR(bp, (port) ? BRB1_REG_FULL_0_XOFF_THRESHOLD_1 : |
| 2182 | BRB1_REG_FULL_0_XOFF_THRESHOLD_0 , reg_th_config->full_xoff); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2183 | /* |
| 2184 | * The number of free blocks above which the full signal to class 0 |
| 2185 | * of MAC #n is de-asserted. n=0,1 |
| 2186 | */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2187 | REG_WR(bp, (port) ? BRB1_REG_FULL_0_XON_THRESHOLD_1 : |
| 2188 | BRB1_REG_FULL_0_XON_THRESHOLD_0 , reg_th_config->full_xon); |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2189 | |
| 2190 | if (set_pfc && pfc_params) { |
| 2191 | /* Second COS */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2192 | if (pfc_params->cos1_pauseable) |
| 2193 | reg_th_config = &config_val.pauseable_th; |
| 2194 | else |
| 2195 | reg_th_config = &config_val.non_pauseable_th; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2196 | /* |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2197 | * The number of free blocks below which the pause signal to |
| 2198 | * class 1 of MAC #n is asserted. n=0,1 |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2199 | **/ |
| 2200 | REG_WR(bp, (port) ? BRB1_REG_PAUSE_1_XOFF_THRESHOLD_1 : |
| 2201 | BRB1_REG_PAUSE_1_XOFF_THRESHOLD_0, |
| 2202 | reg_th_config->pause_xoff); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2203 | /* |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2204 | * The number of free blocks above which the pause signal to |
| 2205 | * class 1 of MAC #n is de-asserted. n=0,1 |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2206 | */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2207 | REG_WR(bp, (port) ? BRB1_REG_PAUSE_1_XON_THRESHOLD_1 : |
| 2208 | BRB1_REG_PAUSE_1_XON_THRESHOLD_0, |
| 2209 | reg_th_config->pause_xon); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2210 | /* |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2211 | * The number of free blocks below which the full signal to |
| 2212 | * class 1 of MAC #n is asserted. n=0,1 |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2213 | */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2214 | REG_WR(bp, (port) ? BRB1_REG_FULL_1_XOFF_THRESHOLD_1 : |
| 2215 | BRB1_REG_FULL_1_XOFF_THRESHOLD_0, |
| 2216 | reg_th_config->full_xoff); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2217 | /* |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2218 | * The number of free blocks above which the full signal to |
| 2219 | * class 1 of MAC #n is de-asserted. n=0,1 |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2220 | */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2221 | REG_WR(bp, (port) ? BRB1_REG_FULL_1_XON_THRESHOLD_1 : |
| 2222 | BRB1_REG_FULL_1_XON_THRESHOLD_0, |
| 2223 | reg_th_config->full_xon); |
| 2224 | |
| 2225 | |
| 2226 | if (CHIP_IS_E3B0(bp)) { |
| 2227 | /*Should be done by init tool */ |
| 2228 | /* |
| 2229 | * BRB_empty_for_dup = BRB1_REG_BRB_EMPTY_THRESHOLD |
| 2230 | * reset value |
| 2231 | * 944 |
| 2232 | */ |
| 2233 | |
| 2234 | /** |
| 2235 | * The hysteresis on the guarantied buffer space for the Lb port |
| 2236 | * before signaling XON. |
| 2237 | **/ |
| 2238 | REG_WR(bp, BRB1_REG_LB_GUARANTIED_HYST, 80); |
| 2239 | |
| 2240 | bnx2x_pfc_brb_get_e3b0_config_params( |
| 2241 | params, |
| 2242 | &e3b0_val, |
| 2243 | pfc_params->cos0_pauseable, |
| 2244 | pfc_params->cos1_pauseable); |
| 2245 | /** |
| 2246 | * The number of free blocks below which the full signal to the |
| 2247 | * LB port is asserted. |
| 2248 | */ |
| 2249 | REG_WR(bp, BRB1_REG_FULL_LB_XOFF_THRESHOLD, |
| 2250 | e3b0_val.full_lb_xoff_th); |
| 2251 | /** |
| 2252 | * The number of free blocks above which the full signal to the |
| 2253 | * LB port is de-asserted. |
| 2254 | */ |
| 2255 | REG_WR(bp, BRB1_REG_FULL_LB_XON_THRESHOLD, |
| 2256 | e3b0_val.full_lb_xon_threshold); |
| 2257 | /** |
| 2258 | * The number of blocks guarantied for the MAC #n port. n=0,1 |
| 2259 | */ |
| 2260 | |
| 2261 | /*The number of blocks guarantied for the LB port.*/ |
| 2262 | REG_WR(bp, BRB1_REG_LB_GUARANTIED, |
| 2263 | e3b0_val.lb_guarantied); |
| 2264 | |
| 2265 | /** |
| 2266 | * The number of blocks guarantied for the MAC #n port. |
| 2267 | */ |
| 2268 | REG_WR(bp, BRB1_REG_MAC_GUARANTIED_0, |
| 2269 | 2 * e3b0_val.mac_0_class_t_guarantied); |
| 2270 | REG_WR(bp, BRB1_REG_MAC_GUARANTIED_1, |
| 2271 | 2 * e3b0_val.mac_1_class_t_guarantied); |
| 2272 | /** |
| 2273 | * The number of blocks guarantied for class #t in MAC0. t=0,1 |
| 2274 | */ |
| 2275 | REG_WR(bp, BRB1_REG_MAC_0_CLASS_0_GUARANTIED, |
| 2276 | e3b0_val.mac_0_class_t_guarantied); |
| 2277 | REG_WR(bp, BRB1_REG_MAC_0_CLASS_1_GUARANTIED, |
| 2278 | e3b0_val.mac_0_class_t_guarantied); |
| 2279 | /** |
| 2280 | * The hysteresis on the guarantied buffer space for class in |
| 2281 | * MAC0. t=0,1 |
| 2282 | */ |
| 2283 | REG_WR(bp, BRB1_REG_MAC_0_CLASS_0_GUARANTIED_HYST, |
| 2284 | e3b0_val.mac_0_class_t_guarantied_hyst); |
| 2285 | REG_WR(bp, BRB1_REG_MAC_0_CLASS_1_GUARANTIED_HYST, |
| 2286 | e3b0_val.mac_0_class_t_guarantied_hyst); |
| 2287 | |
| 2288 | /** |
| 2289 | * The number of blocks guarantied for class #t in MAC1.t=0,1 |
| 2290 | */ |
| 2291 | REG_WR(bp, BRB1_REG_MAC_1_CLASS_0_GUARANTIED, |
| 2292 | e3b0_val.mac_1_class_t_guarantied); |
| 2293 | REG_WR(bp, BRB1_REG_MAC_1_CLASS_1_GUARANTIED, |
| 2294 | e3b0_val.mac_1_class_t_guarantied); |
| 2295 | /** |
| 2296 | * The hysteresis on the guarantied buffer space for class #t |
| 2297 | * in MAC1. t=0,1 |
| 2298 | */ |
| 2299 | REG_WR(bp, BRB1_REG_MAC_1_CLASS_0_GUARANTIED_HYST, |
| 2300 | e3b0_val.mac_1_class_t_guarantied_hyst); |
| 2301 | REG_WR(bp, BRB1_REG_MAC_1_CLASS_1_GUARANTIED_HYST, |
| 2302 | e3b0_val.mac_1_class_t_guarantied_hyst); |
| 2303 | |
| 2304 | } |
| 2305 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2306 | } |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2307 | |
| 2308 | return bnx2x_status; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2309 | } |
| 2310 | |
Vlad Zolotarov | 619c5cb | 2011-06-14 14:33:44 +0300 | [diff] [blame] | 2311 | /****************************************************************************** |
| 2312 | * Description: |
| 2313 | * This function is needed because NIG ARB_CREDIT_WEIGHT_X are |
| 2314 | * not continues and ARB_CREDIT_WEIGHT_0 + offset is suitable. |
| 2315 | ******************************************************************************/ |
| 2316 | int bnx2x_pfc_nig_rx_priority_mask(struct bnx2x *bp, |
| 2317 | u8 cos_entry, |
| 2318 | u32 priority_mask, u8 port) |
| 2319 | { |
| 2320 | u32 nig_reg_rx_priority_mask_add = 0; |
| 2321 | |
| 2322 | switch (cos_entry) { |
| 2323 | case 0: |
| 2324 | nig_reg_rx_priority_mask_add = (port) ? |
| 2325 | NIG_REG_P1_RX_COS0_PRIORITY_MASK : |
| 2326 | NIG_REG_P0_RX_COS0_PRIORITY_MASK; |
| 2327 | break; |
| 2328 | case 1: |
| 2329 | nig_reg_rx_priority_mask_add = (port) ? |
| 2330 | NIG_REG_P1_RX_COS1_PRIORITY_MASK : |
| 2331 | NIG_REG_P0_RX_COS1_PRIORITY_MASK; |
| 2332 | break; |
| 2333 | case 2: |
| 2334 | nig_reg_rx_priority_mask_add = (port) ? |
| 2335 | NIG_REG_P1_RX_COS2_PRIORITY_MASK : |
| 2336 | NIG_REG_P0_RX_COS2_PRIORITY_MASK; |
| 2337 | break; |
| 2338 | case 3: |
| 2339 | if (port) |
| 2340 | return -EINVAL; |
| 2341 | nig_reg_rx_priority_mask_add = NIG_REG_P0_RX_COS3_PRIORITY_MASK; |
| 2342 | break; |
| 2343 | case 4: |
| 2344 | if (port) |
| 2345 | return -EINVAL; |
| 2346 | nig_reg_rx_priority_mask_add = NIG_REG_P0_RX_COS4_PRIORITY_MASK; |
| 2347 | break; |
| 2348 | case 5: |
| 2349 | if (port) |
| 2350 | return -EINVAL; |
| 2351 | nig_reg_rx_priority_mask_add = NIG_REG_P0_RX_COS5_PRIORITY_MASK; |
| 2352 | break; |
| 2353 | } |
| 2354 | |
| 2355 | REG_WR(bp, nig_reg_rx_priority_mask_add, priority_mask); |
| 2356 | |
| 2357 | return 0; |
| 2358 | } |
Yaniv Rosner | b8d6d08 | 2011-07-05 01:06:27 +0000 | [diff] [blame] | 2359 | static void bnx2x_update_mng(struct link_params *params, u32 link_status) |
| 2360 | { |
| 2361 | struct bnx2x *bp = params->bp; |
| 2362 | |
| 2363 | REG_WR(bp, params->shmem_base + |
| 2364 | offsetof(struct shmem_region, |
| 2365 | port_mb[params->port].link_status), link_status); |
| 2366 | } |
| 2367 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2368 | static void bnx2x_update_pfc_nig(struct link_params *params, |
| 2369 | struct link_vars *vars, |
| 2370 | struct bnx2x_nig_brb_pfc_port_params *nig_params) |
| 2371 | { |
| 2372 | u32 xcm_mask = 0, ppp_enable = 0, pause_enable = 0, llfc_out_en = 0; |
| 2373 | u32 llfc_enable = 0, xcm0_out_en = 0, p0_hwpfc_enable = 0; |
| 2374 | u32 pkt_priority_to_cos = 0; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2375 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2376 | u8 port = params->port; |
| 2377 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2378 | int set_pfc = params->feature_config_flags & |
| 2379 | FEATURE_CONFIG_PFC_ENABLED; |
| 2380 | DP(NETIF_MSG_LINK, "updating pfc nig parameters\n"); |
| 2381 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2382 | /* |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2383 | * When NIG_LLH0_XCM_MASK_REG_LLHX_XCM_MASK_BCN bit is set |
| 2384 | * MAC control frames (that are not pause packets) |
| 2385 | * will be forwarded to the XCM. |
| 2386 | */ |
| 2387 | xcm_mask = REG_RD(bp, |
| 2388 | port ? NIG_REG_LLH1_XCM_MASK : |
| 2389 | NIG_REG_LLH0_XCM_MASK); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2390 | /* |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2391 | * nig params will override non PFC params, since it's possible to |
| 2392 | * do transition from PFC to SAFC |
| 2393 | */ |
| 2394 | if (set_pfc) { |
| 2395 | pause_enable = 0; |
| 2396 | llfc_out_en = 0; |
| 2397 | llfc_enable = 0; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2398 | if (CHIP_IS_E3(bp)) |
| 2399 | ppp_enable = 0; |
| 2400 | else |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2401 | ppp_enable = 1; |
| 2402 | xcm_mask &= ~(port ? NIG_LLH1_XCM_MASK_REG_LLH1_XCM_MASK_BCN : |
| 2403 | NIG_LLH0_XCM_MASK_REG_LLH0_XCM_MASK_BCN); |
| 2404 | xcm0_out_en = 0; |
| 2405 | p0_hwpfc_enable = 1; |
| 2406 | } else { |
| 2407 | if (nig_params) { |
| 2408 | llfc_out_en = nig_params->llfc_out_en; |
| 2409 | llfc_enable = nig_params->llfc_enable; |
| 2410 | pause_enable = nig_params->pause_enable; |
| 2411 | } else /*defaul non PFC mode - PAUSE */ |
| 2412 | pause_enable = 1; |
| 2413 | |
| 2414 | xcm_mask |= (port ? NIG_LLH1_XCM_MASK_REG_LLH1_XCM_MASK_BCN : |
| 2415 | NIG_LLH0_XCM_MASK_REG_LLH0_XCM_MASK_BCN); |
| 2416 | xcm0_out_en = 1; |
| 2417 | } |
| 2418 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2419 | if (CHIP_IS_E3(bp)) |
| 2420 | REG_WR(bp, port ? NIG_REG_BRB1_PAUSE_IN_EN : |
| 2421 | NIG_REG_BRB0_PAUSE_IN_EN, pause_enable); |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2422 | REG_WR(bp, port ? NIG_REG_LLFC_OUT_EN_1 : |
| 2423 | NIG_REG_LLFC_OUT_EN_0, llfc_out_en); |
| 2424 | REG_WR(bp, port ? NIG_REG_LLFC_ENABLE_1 : |
| 2425 | NIG_REG_LLFC_ENABLE_0, llfc_enable); |
| 2426 | REG_WR(bp, port ? NIG_REG_PAUSE_ENABLE_1 : |
| 2427 | NIG_REG_PAUSE_ENABLE_0, pause_enable); |
| 2428 | |
| 2429 | REG_WR(bp, port ? NIG_REG_PPP_ENABLE_1 : |
| 2430 | NIG_REG_PPP_ENABLE_0, ppp_enable); |
| 2431 | |
| 2432 | REG_WR(bp, port ? NIG_REG_LLH1_XCM_MASK : |
| 2433 | NIG_REG_LLH0_XCM_MASK, xcm_mask); |
| 2434 | |
| 2435 | REG_WR(bp, NIG_REG_LLFC_EGRESS_SRC_ENABLE_0, 0x7); |
| 2436 | |
| 2437 | /* output enable for RX_XCM # IF */ |
| 2438 | REG_WR(bp, NIG_REG_XCM0_OUT_EN, xcm0_out_en); |
| 2439 | |
| 2440 | /* HW PFC TX enable */ |
| 2441 | REG_WR(bp, NIG_REG_P0_HWPFC_ENABLE, p0_hwpfc_enable); |
| 2442 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2443 | if (nig_params) { |
Vlad Zolotarov | 619c5cb | 2011-06-14 14:33:44 +0300 | [diff] [blame] | 2444 | u8 i = 0; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2445 | pkt_priority_to_cos = nig_params->pkt_priority_to_cos; |
| 2446 | |
Vlad Zolotarov | 619c5cb | 2011-06-14 14:33:44 +0300 | [diff] [blame] | 2447 | for (i = 0; i < nig_params->num_of_rx_cos_priority_mask; i++) |
| 2448 | bnx2x_pfc_nig_rx_priority_mask(bp, i, |
| 2449 | nig_params->rx_cos_priority_mask[i], port); |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2450 | |
| 2451 | REG_WR(bp, port ? NIG_REG_LLFC_HIGH_PRIORITY_CLASSES_1 : |
| 2452 | NIG_REG_LLFC_HIGH_PRIORITY_CLASSES_0, |
| 2453 | nig_params->llfc_high_priority_classes); |
| 2454 | |
| 2455 | REG_WR(bp, port ? NIG_REG_LLFC_LOW_PRIORITY_CLASSES_1 : |
| 2456 | NIG_REG_LLFC_LOW_PRIORITY_CLASSES_0, |
| 2457 | nig_params->llfc_low_priority_classes); |
| 2458 | } |
| 2459 | REG_WR(bp, port ? NIG_REG_P1_PKT_PRIORITY_TO_COS : |
| 2460 | NIG_REG_P0_PKT_PRIORITY_TO_COS, |
| 2461 | pkt_priority_to_cos); |
| 2462 | } |
| 2463 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2464 | int bnx2x_update_pfc(struct link_params *params, |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2465 | struct link_vars *vars, |
| 2466 | struct bnx2x_nig_brb_pfc_port_params *pfc_params) |
| 2467 | { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2468 | /* |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2469 | * The PFC and pause are orthogonal to one another, meaning when |
| 2470 | * PFC is enabled, the pause are disabled, and when PFC is |
| 2471 | * disabled, pause are set according to the pause result. |
| 2472 | */ |
| 2473 | u32 val; |
| 2474 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2475 | int bnx2x_status = 0; |
| 2476 | u8 bmac_loopback = (params->loopback_mode == LOOPBACK_BMAC); |
Yaniv Rosner | b8d6d08 | 2011-07-05 01:06:27 +0000 | [diff] [blame] | 2477 | |
| 2478 | if (params->feature_config_flags & FEATURE_CONFIG_PFC_ENABLED) |
| 2479 | vars->link_status |= LINK_STATUS_PFC_ENABLED; |
| 2480 | else |
| 2481 | vars->link_status &= ~LINK_STATUS_PFC_ENABLED; |
| 2482 | |
| 2483 | bnx2x_update_mng(params, vars->link_status); |
| 2484 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2485 | /* update NIG params */ |
| 2486 | bnx2x_update_pfc_nig(params, vars, pfc_params); |
| 2487 | |
| 2488 | /* update BRB params */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2489 | bnx2x_status = bnx2x_update_pfc_brb(params, vars, pfc_params); |
| 2490 | if (0 != bnx2x_status) |
| 2491 | return bnx2x_status; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2492 | |
| 2493 | if (!vars->link_up) |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2494 | return bnx2x_status; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2495 | |
| 2496 | DP(NETIF_MSG_LINK, "About to update PFC in BMAC\n"); |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2497 | if (CHIP_IS_E3(bp)) |
| 2498 | bnx2x_update_pfc_xmac(params, vars, 0); |
| 2499 | else { |
| 2500 | val = REG_RD(bp, MISC_REG_RESET_REG_2); |
| 2501 | if ((val & |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 2502 | (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << params->port)) |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2503 | == 0) { |
| 2504 | DP(NETIF_MSG_LINK, "About to update PFC in EMAC\n"); |
| 2505 | bnx2x_emac_enable(params, vars, 0); |
| 2506 | return bnx2x_status; |
| 2507 | } |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2508 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2509 | if (CHIP_IS_E2(bp)) |
| 2510 | bnx2x_update_pfc_bmac2(params, vars, bmac_loopback); |
| 2511 | else |
| 2512 | bnx2x_update_pfc_bmac1(params, vars); |
| 2513 | |
| 2514 | val = 0; |
| 2515 | if ((params->feature_config_flags & |
| 2516 | FEATURE_CONFIG_PFC_ENABLED) || |
| 2517 | (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX)) |
| 2518 | val = 1; |
| 2519 | REG_WR(bp, NIG_REG_BMAC0_PAUSE_OUT_EN + params->port*4, val); |
| 2520 | } |
| 2521 | return bnx2x_status; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2522 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2523 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2524 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 2525 | static int bnx2x_bmac1_enable(struct link_params *params, |
| 2526 | struct link_vars *vars, |
| 2527 | u8 is_lb) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2528 | { |
| 2529 | struct bnx2x *bp = params->bp; |
| 2530 | u8 port = params->port; |
| 2531 | u32 bmac_addr = port ? NIG_REG_INGRESS_BMAC1_MEM : |
| 2532 | NIG_REG_INGRESS_BMAC0_MEM; |
| 2533 | u32 wb_data[2]; |
| 2534 | u32 val; |
| 2535 | |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2536 | DP(NETIF_MSG_LINK, "Enabling BigMAC1\n"); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2537 | |
| 2538 | /* XGXS control */ |
| 2539 | wb_data[0] = 0x3c; |
| 2540 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2541 | REG_WR_DMAE(bp, bmac_addr + BIGMAC_REGISTER_BMAC_XGXS_CONTROL, |
| 2542 | wb_data, 2); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2543 | |
| 2544 | /* tx MAC SA */ |
| 2545 | wb_data[0] = ((params->mac_addr[2] << 24) | |
| 2546 | (params->mac_addr[3] << 16) | |
| 2547 | (params->mac_addr[4] << 8) | |
| 2548 | params->mac_addr[5]); |
| 2549 | wb_data[1] = ((params->mac_addr[0] << 8) | |
| 2550 | params->mac_addr[1]); |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2551 | REG_WR_DMAE(bp, bmac_addr + BIGMAC_REGISTER_TX_SOURCE_ADDR, wb_data, 2); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2552 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2553 | /* mac control */ |
| 2554 | val = 0x3; |
| 2555 | if (is_lb) { |
| 2556 | val |= 0x4; |
| 2557 | DP(NETIF_MSG_LINK, "enable bmac loopback\n"); |
| 2558 | } |
| 2559 | wb_data[0] = val; |
| 2560 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2561 | REG_WR_DMAE(bp, bmac_addr + BIGMAC_REGISTER_BMAC_CONTROL, wb_data, 2); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2562 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2563 | /* set rx mtu */ |
| 2564 | wb_data[0] = ETH_MAX_JUMBO_PACKET_SIZE + ETH_OVREHEAD; |
| 2565 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2566 | REG_WR_DMAE(bp, bmac_addr + BIGMAC_REGISTER_RX_MAX_SIZE, wb_data, 2); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2567 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2568 | bnx2x_update_pfc_bmac1(params, vars); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2569 | |
| 2570 | /* set tx mtu */ |
| 2571 | wb_data[0] = ETH_MAX_JUMBO_PACKET_SIZE + ETH_OVREHEAD; |
| 2572 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2573 | REG_WR_DMAE(bp, bmac_addr + BIGMAC_REGISTER_TX_MAX_SIZE, wb_data, 2); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2574 | |
| 2575 | /* set cnt max size */ |
| 2576 | wb_data[0] = ETH_MAX_JUMBO_PACKET_SIZE + ETH_OVREHEAD; |
| 2577 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2578 | REG_WR_DMAE(bp, bmac_addr + BIGMAC_REGISTER_CNT_MAX_SIZE, wb_data, 2); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2579 | |
| 2580 | /* configure safc */ |
| 2581 | wb_data[0] = 0x1000200; |
| 2582 | wb_data[1] = 0; |
| 2583 | REG_WR_DMAE(bp, bmac_addr + BIGMAC_REGISTER_RX_LLFC_MSG_FLDS, |
| 2584 | wb_data, 2); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2585 | |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 2586 | if (vars->phy_flags & PHY_TX_ERROR_CHECK_FLAG) { |
| 2587 | REG_RD_DMAE(bp, bmac_addr + BIGMAC_REGISTER_RX_LSS_STATUS, |
| 2588 | wb_data, 2); |
| 2589 | if (wb_data[0] > 0) |
| 2590 | return -ESRCH; |
| 2591 | } |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2592 | return 0; |
| 2593 | } |
| 2594 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 2595 | static int bnx2x_bmac2_enable(struct link_params *params, |
| 2596 | struct link_vars *vars, |
| 2597 | u8 is_lb) |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2598 | { |
| 2599 | struct bnx2x *bp = params->bp; |
| 2600 | u8 port = params->port; |
| 2601 | u32 bmac_addr = port ? NIG_REG_INGRESS_BMAC1_MEM : |
| 2602 | NIG_REG_INGRESS_BMAC0_MEM; |
| 2603 | u32 wb_data[2]; |
| 2604 | |
| 2605 | DP(NETIF_MSG_LINK, "Enabling BigMAC2\n"); |
| 2606 | |
| 2607 | wb_data[0] = 0; |
| 2608 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2609 | REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_BMAC_CONTROL, wb_data, 2); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2610 | udelay(30); |
| 2611 | |
| 2612 | /* XGXS control: Reset phy HW, MDIO registers, PHY PLL and BMAC */ |
| 2613 | wb_data[0] = 0x3c; |
| 2614 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2615 | REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_BMAC_XGXS_CONTROL, |
| 2616 | wb_data, 2); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2617 | |
| 2618 | udelay(30); |
| 2619 | |
| 2620 | /* tx MAC SA */ |
| 2621 | wb_data[0] = ((params->mac_addr[2] << 24) | |
| 2622 | (params->mac_addr[3] << 16) | |
| 2623 | (params->mac_addr[4] << 8) | |
| 2624 | params->mac_addr[5]); |
| 2625 | wb_data[1] = ((params->mac_addr[0] << 8) | |
| 2626 | params->mac_addr[1]); |
| 2627 | REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_TX_SOURCE_ADDR, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2628 | wb_data, 2); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2629 | |
| 2630 | udelay(30); |
| 2631 | |
| 2632 | /* Configure SAFC */ |
| 2633 | wb_data[0] = 0x1000200; |
| 2634 | wb_data[1] = 0; |
| 2635 | REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_RX_LLFC_MSG_FLDS, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2636 | wb_data, 2); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2637 | udelay(30); |
| 2638 | |
| 2639 | /* set rx mtu */ |
| 2640 | wb_data[0] = ETH_MAX_JUMBO_PACKET_SIZE + ETH_OVREHEAD; |
| 2641 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2642 | REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_RX_MAX_SIZE, wb_data, 2); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2643 | udelay(30); |
| 2644 | |
| 2645 | /* set tx mtu */ |
| 2646 | wb_data[0] = ETH_MAX_JUMBO_PACKET_SIZE + ETH_OVREHEAD; |
| 2647 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2648 | REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_TX_MAX_SIZE, wb_data, 2); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2649 | udelay(30); |
| 2650 | /* set cnt max size */ |
| 2651 | wb_data[0] = ETH_MAX_JUMBO_PACKET_SIZE + ETH_OVREHEAD - 2; |
| 2652 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2653 | REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_CNT_MAX_SIZE, wb_data, 2); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2654 | udelay(30); |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2655 | bnx2x_update_pfc_bmac2(params, vars, is_lb); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2656 | |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 2657 | if (vars->phy_flags & PHY_TX_ERROR_CHECK_FLAG) { |
| 2658 | REG_RD_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_RX_LSS_STAT, |
| 2659 | wb_data, 2); |
| 2660 | if (wb_data[0] > 0) { |
| 2661 | DP(NETIF_MSG_LINK, "Got bad LSS status 0x%x\n", |
| 2662 | wb_data[0]); |
| 2663 | return -ESRCH; |
| 2664 | } |
| 2665 | } |
| 2666 | |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2667 | return 0; |
| 2668 | } |
| 2669 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 2670 | static int bnx2x_bmac_enable(struct link_params *params, |
| 2671 | struct link_vars *vars, |
| 2672 | u8 is_lb) |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2673 | { |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 2674 | int rc = 0; |
| 2675 | u8 port = params->port; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2676 | struct bnx2x *bp = params->bp; |
| 2677 | u32 val; |
| 2678 | /* reset and unreset the BigMac */ |
| 2679 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_CLEAR, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2680 | (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << port)); |
Yaniv Rosner | 1d9c05d | 2010-11-01 05:32:25 +0000 | [diff] [blame] | 2681 | msleep(1); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2682 | |
| 2683 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_SET, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2684 | (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << port)); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2685 | |
| 2686 | /* enable access for bmac registers */ |
| 2687 | REG_WR(bp, NIG_REG_BMAC0_REGS_OUT_EN + port*4, 0x1); |
| 2688 | |
| 2689 | /* Enable BMAC according to BMAC type*/ |
| 2690 | if (CHIP_IS_E2(bp)) |
| 2691 | rc = bnx2x_bmac2_enable(params, vars, is_lb); |
| 2692 | else |
| 2693 | rc = bnx2x_bmac1_enable(params, vars, is_lb); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2694 | REG_WR(bp, NIG_REG_XGXS_SERDES0_MODE_SEL + port*4, 0x1); |
| 2695 | REG_WR(bp, NIG_REG_XGXS_LANE_SEL_P0 + port*4, 0x0); |
| 2696 | REG_WR(bp, NIG_REG_EGRESS_EMAC0_PORT + port*4, 0x0); |
| 2697 | val = 0; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2698 | if ((params->feature_config_flags & |
| 2699 | FEATURE_CONFIG_PFC_ENABLED) || |
| 2700 | (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX)) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2701 | val = 1; |
| 2702 | REG_WR(bp, NIG_REG_BMAC0_PAUSE_OUT_EN + port*4, val); |
| 2703 | REG_WR(bp, NIG_REG_EGRESS_EMAC0_OUT_EN + port*4, 0x0); |
| 2704 | REG_WR(bp, NIG_REG_EMAC0_IN_EN + port*4, 0x0); |
| 2705 | REG_WR(bp, NIG_REG_EMAC0_PAUSE_OUT_EN + port*4, 0x0); |
| 2706 | REG_WR(bp, NIG_REG_BMAC0_IN_EN + port*4, 0x1); |
| 2707 | REG_WR(bp, NIG_REG_BMAC0_OUT_EN + port*4, 0x1); |
| 2708 | |
| 2709 | vars->mac_type = MAC_TYPE_BMAC; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2710 | return rc; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2711 | } |
| 2712 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2713 | static void bnx2x_bmac_rx_disable(struct bnx2x *bp, u8 port) |
| 2714 | { |
| 2715 | u32 bmac_addr = port ? NIG_REG_INGRESS_BMAC1_MEM : |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2716 | NIG_REG_INGRESS_BMAC0_MEM; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2717 | u32 wb_data[2]; |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 2718 | u32 nig_bmac_enable = REG_RD(bp, NIG_REG_BMAC0_REGS_OUT_EN + port*4); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2719 | |
| 2720 | /* Only if the bmac is out of reset */ |
| 2721 | if (REG_RD(bp, MISC_REG_RESET_REG_2) & |
| 2722 | (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << port) && |
| 2723 | nig_bmac_enable) { |
| 2724 | |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2725 | if (CHIP_IS_E2(bp)) { |
| 2726 | /* Clear Rx Enable bit in BMAC_CONTROL register */ |
| 2727 | REG_RD_DMAE(bp, bmac_addr + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2728 | BIGMAC2_REGISTER_BMAC_CONTROL, |
| 2729 | wb_data, 2); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2730 | wb_data[0] &= ~BMAC_CONTROL_RX_ENABLE; |
| 2731 | REG_WR_DMAE(bp, bmac_addr + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2732 | BIGMAC2_REGISTER_BMAC_CONTROL, |
| 2733 | wb_data, 2); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2734 | } else { |
| 2735 | /* Clear Rx Enable bit in BMAC_CONTROL register */ |
| 2736 | REG_RD_DMAE(bp, bmac_addr + |
| 2737 | BIGMAC_REGISTER_BMAC_CONTROL, |
| 2738 | wb_data, 2); |
| 2739 | wb_data[0] &= ~BMAC_CONTROL_RX_ENABLE; |
| 2740 | REG_WR_DMAE(bp, bmac_addr + |
| 2741 | BIGMAC_REGISTER_BMAC_CONTROL, |
| 2742 | wb_data, 2); |
| 2743 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2744 | msleep(1); |
| 2745 | } |
| 2746 | } |
| 2747 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 2748 | static int bnx2x_pbf_update(struct link_params *params, u32 flow_ctrl, |
| 2749 | u32 line_speed) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2750 | { |
| 2751 | struct bnx2x *bp = params->bp; |
| 2752 | u8 port = params->port; |
| 2753 | u32 init_crd, crd; |
| 2754 | u32 count = 1000; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2755 | |
| 2756 | /* disable port */ |
| 2757 | REG_WR(bp, PBF_REG_DISABLE_NEW_TASK_PROC_P0 + port*4, 0x1); |
| 2758 | |
| 2759 | /* wait for init credit */ |
| 2760 | init_crd = REG_RD(bp, PBF_REG_P0_INIT_CRD + port*4); |
| 2761 | crd = REG_RD(bp, PBF_REG_P0_CREDIT + port*8); |
| 2762 | DP(NETIF_MSG_LINK, "init_crd 0x%x crd 0x%x\n", init_crd, crd); |
| 2763 | |
| 2764 | while ((init_crd != crd) && count) { |
| 2765 | msleep(5); |
| 2766 | |
| 2767 | crd = REG_RD(bp, PBF_REG_P0_CREDIT + port*8); |
| 2768 | count--; |
| 2769 | } |
| 2770 | crd = REG_RD(bp, PBF_REG_P0_CREDIT + port*8); |
| 2771 | if (init_crd != crd) { |
| 2772 | DP(NETIF_MSG_LINK, "BUG! init_crd 0x%x != crd 0x%x\n", |
| 2773 | init_crd, crd); |
| 2774 | return -EINVAL; |
| 2775 | } |
| 2776 | |
David S. Miller | c0700f9 | 2008-12-16 23:53:20 -0800 | [diff] [blame] | 2777 | if (flow_ctrl & BNX2X_FLOW_CTRL_RX || |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 2778 | line_speed == SPEED_10 || |
| 2779 | line_speed == SPEED_100 || |
| 2780 | line_speed == SPEED_1000 || |
| 2781 | line_speed == SPEED_2500) { |
| 2782 | REG_WR(bp, PBF_REG_P0_PAUSE_ENABLE + port*4, 1); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2783 | /* update threshold */ |
| 2784 | REG_WR(bp, PBF_REG_P0_ARB_THRSH + port*4, 0); |
| 2785 | /* update init credit */ |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2786 | init_crd = 778; /* (800-18-4) */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2787 | |
| 2788 | } else { |
| 2789 | u32 thresh = (ETH_MAX_JUMBO_PACKET_SIZE + |
| 2790 | ETH_OVREHEAD)/16; |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 2791 | REG_WR(bp, PBF_REG_P0_PAUSE_ENABLE + port*4, 0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2792 | /* update threshold */ |
| 2793 | REG_WR(bp, PBF_REG_P0_ARB_THRSH + port*4, thresh); |
| 2794 | /* update init credit */ |
| 2795 | switch (line_speed) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2796 | case SPEED_10000: |
| 2797 | init_crd = thresh + 553 - 22; |
| 2798 | break; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2799 | default: |
| 2800 | DP(NETIF_MSG_LINK, "Invalid line_speed 0x%x\n", |
| 2801 | line_speed); |
| 2802 | return -EINVAL; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2803 | } |
| 2804 | } |
| 2805 | REG_WR(bp, PBF_REG_P0_INIT_CRD + port*4, init_crd); |
| 2806 | DP(NETIF_MSG_LINK, "PBF updated to speed %d credit %d\n", |
| 2807 | line_speed, init_crd); |
| 2808 | |
| 2809 | /* probe the credit changes */ |
| 2810 | REG_WR(bp, PBF_REG_INIT_P0 + port*4, 0x1); |
| 2811 | msleep(5); |
| 2812 | REG_WR(bp, PBF_REG_INIT_P0 + port*4, 0x0); |
| 2813 | |
| 2814 | /* enable port */ |
| 2815 | REG_WR(bp, PBF_REG_DISABLE_NEW_TASK_PROC_P0 + port*4, 0x0); |
| 2816 | return 0; |
| 2817 | } |
| 2818 | |
Dmitry Kravkov | e892067 | 2011-05-04 23:52:40 +0000 | [diff] [blame] | 2819 | /** |
| 2820 | * bnx2x_get_emac_base - retrive emac base address |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2821 | * |
Dmitry Kravkov | e892067 | 2011-05-04 23:52:40 +0000 | [diff] [blame] | 2822 | * @bp: driver handle |
| 2823 | * @mdc_mdio_access: access type |
| 2824 | * @port: port id |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2825 | * |
| 2826 | * This function selects the MDC/MDIO access (through emac0 or |
| 2827 | * emac1) depend on the mdc_mdio_access, port, port swapped. Each |
| 2828 | * phy has a default access mode, which could also be overridden |
| 2829 | * by nvram configuration. This parameter, whether this is the |
| 2830 | * default phy configuration, or the nvram overrun |
| 2831 | * configuration, is passed here as mdc_mdio_access and selects |
| 2832 | * the emac_base for the CL45 read/writes operations |
| 2833 | */ |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 2834 | static u32 bnx2x_get_emac_base(struct bnx2x *bp, |
| 2835 | u32 mdc_mdio_access, u8 port) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2836 | { |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 2837 | u32 emac_base = 0; |
| 2838 | switch (mdc_mdio_access) { |
| 2839 | case SHARED_HW_CFG_MDC_MDIO_ACCESS1_PHY_TYPE: |
| 2840 | break; |
| 2841 | case SHARED_HW_CFG_MDC_MDIO_ACCESS1_EMAC0: |
| 2842 | if (REG_RD(bp, NIG_REG_PORT_SWAP)) |
| 2843 | emac_base = GRCBASE_EMAC1; |
| 2844 | else |
| 2845 | emac_base = GRCBASE_EMAC0; |
| 2846 | break; |
| 2847 | case SHARED_HW_CFG_MDC_MDIO_ACCESS1_EMAC1: |
Eilon Greenstein | 589abe3 | 2009-02-12 08:36:55 +0000 | [diff] [blame] | 2848 | if (REG_RD(bp, NIG_REG_PORT_SWAP)) |
| 2849 | emac_base = GRCBASE_EMAC0; |
| 2850 | else |
| 2851 | emac_base = GRCBASE_EMAC1; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2852 | break; |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 2853 | case SHARED_HW_CFG_MDC_MDIO_ACCESS1_BOTH: |
| 2854 | emac_base = (port) ? GRCBASE_EMAC1 : GRCBASE_EMAC0; |
| 2855 | break; |
| 2856 | case SHARED_HW_CFG_MDC_MDIO_ACCESS1_SWAPPED: |
Eilon Greenstein | 6378c02 | 2008-08-13 15:59:25 -0700 | [diff] [blame] | 2857 | emac_base = (port) ? GRCBASE_EMAC0 : GRCBASE_EMAC1; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2858 | break; |
| 2859 | default: |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2860 | break; |
| 2861 | } |
| 2862 | return emac_base; |
| 2863 | |
| 2864 | } |
| 2865 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2866 | /******************************************************************/ |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 2867 | /* CL22 access functions */ |
| 2868 | /******************************************************************/ |
| 2869 | static int bnx2x_cl22_write(struct bnx2x *bp, |
| 2870 | struct bnx2x_phy *phy, |
| 2871 | u16 reg, u16 val) |
| 2872 | { |
| 2873 | u32 tmp, mode; |
| 2874 | u8 i; |
| 2875 | int rc = 0; |
| 2876 | /* Switch to CL22 */ |
| 2877 | mode = REG_RD(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_MODE); |
| 2878 | REG_WR(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_MODE, |
| 2879 | mode & ~EMAC_MDIO_MODE_CLAUSE_45); |
| 2880 | |
| 2881 | /* address */ |
| 2882 | tmp = ((phy->addr << 21) | (reg << 16) | val | |
| 2883 | EMAC_MDIO_COMM_COMMAND_WRITE_22 | |
| 2884 | EMAC_MDIO_COMM_START_BUSY); |
| 2885 | REG_WR(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM, tmp); |
| 2886 | |
| 2887 | for (i = 0; i < 50; i++) { |
| 2888 | udelay(10); |
| 2889 | |
| 2890 | tmp = REG_RD(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM); |
| 2891 | if (!(tmp & EMAC_MDIO_COMM_START_BUSY)) { |
| 2892 | udelay(5); |
| 2893 | break; |
| 2894 | } |
| 2895 | } |
| 2896 | if (tmp & EMAC_MDIO_COMM_START_BUSY) { |
| 2897 | DP(NETIF_MSG_LINK, "write phy register failed\n"); |
| 2898 | rc = -EFAULT; |
| 2899 | } |
| 2900 | REG_WR(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_MODE, mode); |
| 2901 | return rc; |
| 2902 | } |
| 2903 | |
| 2904 | static int bnx2x_cl22_read(struct bnx2x *bp, |
| 2905 | struct bnx2x_phy *phy, |
| 2906 | u16 reg, u16 *ret_val) |
| 2907 | { |
| 2908 | u32 val, mode; |
| 2909 | u16 i; |
| 2910 | int rc = 0; |
| 2911 | |
| 2912 | /* Switch to CL22 */ |
| 2913 | mode = REG_RD(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_MODE); |
| 2914 | REG_WR(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_MODE, |
| 2915 | mode & ~EMAC_MDIO_MODE_CLAUSE_45); |
| 2916 | |
| 2917 | /* address */ |
| 2918 | val = ((phy->addr << 21) | (reg << 16) | |
| 2919 | EMAC_MDIO_COMM_COMMAND_READ_22 | |
| 2920 | EMAC_MDIO_COMM_START_BUSY); |
| 2921 | REG_WR(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM, val); |
| 2922 | |
| 2923 | for (i = 0; i < 50; i++) { |
| 2924 | udelay(10); |
| 2925 | |
| 2926 | val = REG_RD(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM); |
| 2927 | if (!(val & EMAC_MDIO_COMM_START_BUSY)) { |
| 2928 | *ret_val = (u16)(val & EMAC_MDIO_COMM_DATA); |
| 2929 | udelay(5); |
| 2930 | break; |
| 2931 | } |
| 2932 | } |
| 2933 | if (val & EMAC_MDIO_COMM_START_BUSY) { |
| 2934 | DP(NETIF_MSG_LINK, "read phy register failed\n"); |
| 2935 | |
| 2936 | *ret_val = 0; |
| 2937 | rc = -EFAULT; |
| 2938 | } |
| 2939 | REG_WR(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_MODE, mode); |
| 2940 | return rc; |
| 2941 | } |
| 2942 | |
| 2943 | /******************************************************************/ |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2944 | /* CL45 access functions */ |
| 2945 | /******************************************************************/ |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 2946 | static int bnx2x_cl45_read(struct bnx2x *bp, struct bnx2x_phy *phy, |
| 2947 | u8 devad, u16 reg, u16 *ret_val) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2948 | { |
Yaniv Rosner | a198c14 | 2011-05-31 21:29:42 +0000 | [diff] [blame] | 2949 | u32 val; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2950 | u16 i; |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 2951 | int rc = 0; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2952 | |
| 2953 | /* address */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2954 | val = ((phy->addr << 21) | (devad << 16) | reg | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2955 | EMAC_MDIO_COMM_COMMAND_ADDRESS | |
| 2956 | EMAC_MDIO_COMM_START_BUSY); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2957 | REG_WR(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM, val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2958 | |
| 2959 | for (i = 0; i < 50; i++) { |
| 2960 | udelay(10); |
| 2961 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2962 | val = REG_RD(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2963 | if (!(val & EMAC_MDIO_COMM_START_BUSY)) { |
| 2964 | udelay(5); |
| 2965 | break; |
| 2966 | } |
| 2967 | } |
| 2968 | if (val & EMAC_MDIO_COMM_START_BUSY) { |
| 2969 | DP(NETIF_MSG_LINK, "read phy register failed\n"); |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 2970 | netdev_err(bp->dev, "MDC/MDIO access timeout\n"); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2971 | *ret_val = 0; |
| 2972 | rc = -EFAULT; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2973 | } else { |
| 2974 | /* data */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2975 | val = ((phy->addr << 21) | (devad << 16) | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2976 | EMAC_MDIO_COMM_COMMAND_READ_45 | |
| 2977 | EMAC_MDIO_COMM_START_BUSY); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2978 | REG_WR(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM, val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2979 | |
| 2980 | for (i = 0; i < 50; i++) { |
| 2981 | udelay(10); |
| 2982 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2983 | val = REG_RD(bp, phy->mdio_ctrl + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2984 | EMAC_REG_EMAC_MDIO_COMM); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2985 | if (!(val & EMAC_MDIO_COMM_START_BUSY)) { |
| 2986 | *ret_val = (u16)(val & EMAC_MDIO_COMM_DATA); |
| 2987 | break; |
| 2988 | } |
| 2989 | } |
| 2990 | if (val & EMAC_MDIO_COMM_START_BUSY) { |
| 2991 | DP(NETIF_MSG_LINK, "read phy register failed\n"); |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 2992 | netdev_err(bp->dev, "MDC/MDIO access timeout\n"); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2993 | *ret_val = 0; |
| 2994 | rc = -EFAULT; |
| 2995 | } |
| 2996 | } |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 2997 | /* Work around for E3 A0 */ |
| 2998 | if (phy->flags & FLAGS_MDC_MDIO_WA) { |
| 2999 | phy->flags ^= FLAGS_DUMMY_READ; |
| 3000 | if (phy->flags & FLAGS_DUMMY_READ) { |
| 3001 | u16 temp_val; |
| 3002 | bnx2x_cl45_read(bp, phy, devad, 0xf, &temp_val); |
| 3003 | } |
| 3004 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3005 | |
Yaniv Rosner | a198c14 | 2011-05-31 21:29:42 +0000 | [diff] [blame] | 3006 | return rc; |
| 3007 | } |
| 3008 | |
| 3009 | static int bnx2x_cl45_write(struct bnx2x *bp, struct bnx2x_phy *phy, |
| 3010 | u8 devad, u16 reg, u16 val) |
| 3011 | { |
| 3012 | u32 tmp; |
| 3013 | u8 i; |
| 3014 | int rc = 0; |
| 3015 | |
| 3016 | /* address */ |
| 3017 | |
| 3018 | tmp = ((phy->addr << 21) | (devad << 16) | reg | |
| 3019 | EMAC_MDIO_COMM_COMMAND_ADDRESS | |
| 3020 | EMAC_MDIO_COMM_START_BUSY); |
| 3021 | REG_WR(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM, tmp); |
| 3022 | |
| 3023 | for (i = 0; i < 50; i++) { |
| 3024 | udelay(10); |
| 3025 | |
| 3026 | tmp = REG_RD(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM); |
| 3027 | if (!(tmp & EMAC_MDIO_COMM_START_BUSY)) { |
| 3028 | udelay(5); |
| 3029 | break; |
| 3030 | } |
| 3031 | } |
| 3032 | if (tmp & EMAC_MDIO_COMM_START_BUSY) { |
| 3033 | DP(NETIF_MSG_LINK, "write phy register failed\n"); |
| 3034 | netdev_err(bp->dev, "MDC/MDIO access timeout\n"); |
| 3035 | rc = -EFAULT; |
| 3036 | |
| 3037 | } else { |
| 3038 | /* data */ |
| 3039 | tmp = ((phy->addr << 21) | (devad << 16) | val | |
| 3040 | EMAC_MDIO_COMM_COMMAND_WRITE_45 | |
| 3041 | EMAC_MDIO_COMM_START_BUSY); |
| 3042 | REG_WR(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM, tmp); |
| 3043 | |
| 3044 | for (i = 0; i < 50; i++) { |
| 3045 | udelay(10); |
| 3046 | |
| 3047 | tmp = REG_RD(bp, phy->mdio_ctrl + |
| 3048 | EMAC_REG_EMAC_MDIO_COMM); |
| 3049 | if (!(tmp & EMAC_MDIO_COMM_START_BUSY)) { |
| 3050 | udelay(5); |
| 3051 | break; |
| 3052 | } |
| 3053 | } |
| 3054 | if (tmp & EMAC_MDIO_COMM_START_BUSY) { |
| 3055 | DP(NETIF_MSG_LINK, "write phy register failed\n"); |
| 3056 | netdev_err(bp->dev, "MDC/MDIO access timeout\n"); |
| 3057 | rc = -EFAULT; |
| 3058 | } |
| 3059 | } |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 3060 | /* Work around for E3 A0 */ |
| 3061 | if (phy->flags & FLAGS_MDC_MDIO_WA) { |
| 3062 | phy->flags ^= FLAGS_DUMMY_READ; |
| 3063 | if (phy->flags & FLAGS_DUMMY_READ) { |
| 3064 | u16 temp_val; |
| 3065 | bnx2x_cl45_read(bp, phy, devad, 0xf, &temp_val); |
| 3066 | } |
| 3067 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3068 | |
| 3069 | return rc; |
| 3070 | } |
| 3071 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 3072 | |
| 3073 | /******************************************************************/ |
| 3074 | /* BSC access functions from E3 */ |
| 3075 | /******************************************************************/ |
| 3076 | static void bnx2x_bsc_module_sel(struct link_params *params) |
| 3077 | { |
| 3078 | int idx; |
| 3079 | u32 board_cfg, sfp_ctrl; |
| 3080 | u32 i2c_pins[I2C_SWITCH_WIDTH], i2c_val[I2C_SWITCH_WIDTH]; |
| 3081 | struct bnx2x *bp = params->bp; |
| 3082 | u8 port = params->port; |
| 3083 | /* Read I2C output PINs */ |
| 3084 | board_cfg = REG_RD(bp, params->shmem_base + |
| 3085 | offsetof(struct shmem_region, |
| 3086 | dev_info.shared_hw_config.board)); |
| 3087 | i2c_pins[I2C_BSC0] = board_cfg & SHARED_HW_CFG_E3_I2C_MUX0_MASK; |
| 3088 | i2c_pins[I2C_BSC1] = (board_cfg & SHARED_HW_CFG_E3_I2C_MUX1_MASK) >> |
| 3089 | SHARED_HW_CFG_E3_I2C_MUX1_SHIFT; |
| 3090 | |
| 3091 | /* Read I2C output value */ |
| 3092 | sfp_ctrl = REG_RD(bp, params->shmem_base + |
| 3093 | offsetof(struct shmem_region, |
| 3094 | dev_info.port_hw_config[port].e3_cmn_pin_cfg)); |
| 3095 | i2c_val[I2C_BSC0] = (sfp_ctrl & PORT_HW_CFG_E3_I2C_MUX0_MASK) > 0; |
| 3096 | i2c_val[I2C_BSC1] = (sfp_ctrl & PORT_HW_CFG_E3_I2C_MUX1_MASK) > 0; |
| 3097 | DP(NETIF_MSG_LINK, "Setting BSC switch\n"); |
| 3098 | for (idx = 0; idx < I2C_SWITCH_WIDTH; idx++) |
| 3099 | bnx2x_set_cfg_pin(bp, i2c_pins[idx], i2c_val[idx]); |
| 3100 | } |
| 3101 | |
| 3102 | static int bnx2x_bsc_read(struct link_params *params, |
| 3103 | struct bnx2x_phy *phy, |
| 3104 | u8 sl_devid, |
| 3105 | u16 sl_addr, |
| 3106 | u8 lc_addr, |
| 3107 | u8 xfer_cnt, |
| 3108 | u32 *data_array) |
| 3109 | { |
| 3110 | u32 val, i; |
| 3111 | int rc = 0; |
| 3112 | struct bnx2x *bp = params->bp; |
| 3113 | |
| 3114 | if ((sl_devid != 0xa0) && (sl_devid != 0xa2)) { |
| 3115 | DP(NETIF_MSG_LINK, "invalid sl_devid 0x%x\n", sl_devid); |
| 3116 | return -EINVAL; |
| 3117 | } |
| 3118 | |
| 3119 | if (xfer_cnt > 16) { |
| 3120 | DP(NETIF_MSG_LINK, "invalid xfer_cnt %d. Max is 16 bytes\n", |
| 3121 | xfer_cnt); |
| 3122 | return -EINVAL; |
| 3123 | } |
| 3124 | bnx2x_bsc_module_sel(params); |
| 3125 | |
| 3126 | xfer_cnt = 16 - lc_addr; |
| 3127 | |
| 3128 | /* enable the engine */ |
| 3129 | val = REG_RD(bp, MCP_REG_MCPR_IMC_COMMAND); |
| 3130 | val |= MCPR_IMC_COMMAND_ENABLE; |
| 3131 | REG_WR(bp, MCP_REG_MCPR_IMC_COMMAND, val); |
| 3132 | |
| 3133 | /* program slave device ID */ |
| 3134 | val = (sl_devid << 16) | sl_addr; |
| 3135 | REG_WR(bp, MCP_REG_MCPR_IMC_SLAVE_CONTROL, val); |
| 3136 | |
| 3137 | /* start xfer with 0 byte to update the address pointer ???*/ |
| 3138 | val = (MCPR_IMC_COMMAND_ENABLE) | |
| 3139 | (MCPR_IMC_COMMAND_WRITE_OP << |
| 3140 | MCPR_IMC_COMMAND_OPERATION_BITSHIFT) | |
| 3141 | (lc_addr << MCPR_IMC_COMMAND_TRANSFER_ADDRESS_BITSHIFT) | (0); |
| 3142 | REG_WR(bp, MCP_REG_MCPR_IMC_COMMAND, val); |
| 3143 | |
| 3144 | /* poll for completion */ |
| 3145 | i = 0; |
| 3146 | val = REG_RD(bp, MCP_REG_MCPR_IMC_COMMAND); |
| 3147 | while (((val >> MCPR_IMC_COMMAND_IMC_STATUS_BITSHIFT) & 0x3) != 1) { |
| 3148 | udelay(10); |
| 3149 | val = REG_RD(bp, MCP_REG_MCPR_IMC_COMMAND); |
| 3150 | if (i++ > 1000) { |
| 3151 | DP(NETIF_MSG_LINK, "wr 0 byte timed out after %d try\n", |
| 3152 | i); |
| 3153 | rc = -EFAULT; |
| 3154 | break; |
| 3155 | } |
| 3156 | } |
| 3157 | if (rc == -EFAULT) |
| 3158 | return rc; |
| 3159 | |
| 3160 | /* start xfer with read op */ |
| 3161 | val = (MCPR_IMC_COMMAND_ENABLE) | |
| 3162 | (MCPR_IMC_COMMAND_READ_OP << |
| 3163 | MCPR_IMC_COMMAND_OPERATION_BITSHIFT) | |
| 3164 | (lc_addr << MCPR_IMC_COMMAND_TRANSFER_ADDRESS_BITSHIFT) | |
| 3165 | (xfer_cnt); |
| 3166 | REG_WR(bp, MCP_REG_MCPR_IMC_COMMAND, val); |
| 3167 | |
| 3168 | /* poll for completion */ |
| 3169 | i = 0; |
| 3170 | val = REG_RD(bp, MCP_REG_MCPR_IMC_COMMAND); |
| 3171 | while (((val >> MCPR_IMC_COMMAND_IMC_STATUS_BITSHIFT) & 0x3) != 1) { |
| 3172 | udelay(10); |
| 3173 | val = REG_RD(bp, MCP_REG_MCPR_IMC_COMMAND); |
| 3174 | if (i++ > 1000) { |
| 3175 | DP(NETIF_MSG_LINK, "rd op timed out after %d try\n", i); |
| 3176 | rc = -EFAULT; |
| 3177 | break; |
| 3178 | } |
| 3179 | } |
| 3180 | if (rc == -EFAULT) |
| 3181 | return rc; |
| 3182 | |
| 3183 | for (i = (lc_addr >> 2); i < 4; i++) { |
| 3184 | data_array[i] = REG_RD(bp, (MCP_REG_MCPR_IMC_DATAREG0 + i*4)); |
| 3185 | #ifdef __BIG_ENDIAN |
| 3186 | data_array[i] = ((data_array[i] & 0x000000ff) << 24) | |
| 3187 | ((data_array[i] & 0x0000ff00) << 8) | |
| 3188 | ((data_array[i] & 0x00ff0000) >> 8) | |
| 3189 | ((data_array[i] & 0xff000000) >> 24); |
| 3190 | #endif |
| 3191 | } |
| 3192 | return rc; |
| 3193 | } |
| 3194 | |
| 3195 | static void bnx2x_cl45_read_or_write(struct bnx2x *bp, struct bnx2x_phy *phy, |
| 3196 | u8 devad, u16 reg, u16 or_val) |
| 3197 | { |
| 3198 | u16 val; |
| 3199 | bnx2x_cl45_read(bp, phy, devad, reg, &val); |
| 3200 | bnx2x_cl45_write(bp, phy, devad, reg, val | or_val); |
| 3201 | } |
| 3202 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 3203 | int bnx2x_phy_read(struct link_params *params, u8 phy_addr, |
| 3204 | u8 devad, u16 reg, u16 *ret_val) |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3205 | { |
| 3206 | u8 phy_index; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3207 | /* |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3208 | * Probe for the phy according to the given phy_addr, and execute |
| 3209 | * the read request on it |
| 3210 | */ |
| 3211 | for (phy_index = 0; phy_index < params->num_phys; phy_index++) { |
| 3212 | if (params->phy[phy_index].addr == phy_addr) { |
| 3213 | return bnx2x_cl45_read(params->bp, |
| 3214 | ¶ms->phy[phy_index], devad, |
| 3215 | reg, ret_val); |
| 3216 | } |
| 3217 | } |
| 3218 | return -EINVAL; |
| 3219 | } |
| 3220 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 3221 | int bnx2x_phy_write(struct link_params *params, u8 phy_addr, |
| 3222 | u8 devad, u16 reg, u16 val) |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3223 | { |
| 3224 | u8 phy_index; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3225 | /* |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3226 | * Probe for the phy according to the given phy_addr, and execute |
| 3227 | * the write request on it |
| 3228 | */ |
| 3229 | for (phy_index = 0; phy_index < params->num_phys; phy_index++) { |
| 3230 | if (params->phy[phy_index].addr == phy_addr) { |
| 3231 | return bnx2x_cl45_write(params->bp, |
| 3232 | ¶ms->phy[phy_index], devad, |
| 3233 | reg, val); |
| 3234 | } |
| 3235 | } |
| 3236 | return -EINVAL; |
| 3237 | } |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 3238 | static u8 bnx2x_get_warpcore_lane(struct bnx2x_phy *phy, |
| 3239 | struct link_params *params) |
| 3240 | { |
| 3241 | u8 lane = 0; |
| 3242 | struct bnx2x *bp = params->bp; |
| 3243 | u32 path_swap, path_swap_ovr; |
| 3244 | u8 path, port; |
| 3245 | |
| 3246 | path = BP_PATH(bp); |
| 3247 | port = params->port; |
| 3248 | |
| 3249 | if (bnx2x_is_4_port_mode(bp)) { |
| 3250 | u32 port_swap, port_swap_ovr; |
| 3251 | |
| 3252 | /*figure out path swap value */ |
| 3253 | path_swap_ovr = REG_RD(bp, MISC_REG_FOUR_PORT_PATH_SWAP_OVWR); |
| 3254 | if (path_swap_ovr & 0x1) |
| 3255 | path_swap = (path_swap_ovr & 0x2); |
| 3256 | else |
| 3257 | path_swap = REG_RD(bp, MISC_REG_FOUR_PORT_PATH_SWAP); |
| 3258 | |
| 3259 | if (path_swap) |
| 3260 | path = path ^ 1; |
| 3261 | |
| 3262 | /*figure out port swap value */ |
| 3263 | port_swap_ovr = REG_RD(bp, MISC_REG_FOUR_PORT_PORT_SWAP_OVWR); |
| 3264 | if (port_swap_ovr & 0x1) |
| 3265 | port_swap = (port_swap_ovr & 0x2); |
| 3266 | else |
| 3267 | port_swap = REG_RD(bp, MISC_REG_FOUR_PORT_PORT_SWAP); |
| 3268 | |
| 3269 | if (port_swap) |
| 3270 | port = port ^ 1; |
| 3271 | |
| 3272 | lane = (port<<1) + path; |
| 3273 | } else { /* two port mode - no port swap */ |
| 3274 | |
| 3275 | /*figure out path swap value */ |
| 3276 | path_swap_ovr = |
| 3277 | REG_RD(bp, MISC_REG_TWO_PORT_PATH_SWAP_OVWR); |
| 3278 | if (path_swap_ovr & 0x1) { |
| 3279 | path_swap = (path_swap_ovr & 0x2); |
| 3280 | } else { |
| 3281 | path_swap = |
| 3282 | REG_RD(bp, MISC_REG_TWO_PORT_PATH_SWAP); |
| 3283 | } |
| 3284 | if (path_swap) |
| 3285 | path = path ^ 1; |
| 3286 | |
| 3287 | lane = path << 1 ; |
| 3288 | } |
| 3289 | return lane; |
| 3290 | } |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3291 | |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 3292 | static void bnx2x_set_aer_mmd(struct link_params *params, |
| 3293 | struct bnx2x_phy *phy) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3294 | { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3295 | u32 ser_lane; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 3296 | u16 offset, aer_val; |
| 3297 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3298 | ser_lane = ((params->lane_config & |
| 3299 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_MASK) >> |
| 3300 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_SHIFT); |
| 3301 | |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 3302 | offset = (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT) ? |
| 3303 | (phy->addr + ser_lane) : 0; |
| 3304 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 3305 | if (USES_WARPCORE(bp)) { |
| 3306 | aer_val = bnx2x_get_warpcore_lane(phy, params); |
| 3307 | /* |
| 3308 | * In Dual-lane mode, two lanes are joined together, |
| 3309 | * so in order to configure them, the AER broadcast method is |
| 3310 | * used here. |
| 3311 | * 0x200 is the broadcast address for lanes 0,1 |
| 3312 | * 0x201 is the broadcast address for lanes 2,3 |
| 3313 | */ |
| 3314 | if (phy->flags & FLAGS_WC_DUAL_MODE) |
| 3315 | aer_val = (aer_val >> 1) | 0x200; |
| 3316 | } else if (CHIP_IS_E2(bp)) |
Yaniv Rosner | 82a0d47 | 2011-01-18 04:33:52 +0000 | [diff] [blame] | 3317 | aer_val = 0x3800 + offset - 1; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 3318 | else |
| 3319 | aer_val = 0x3800 + offset; |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 3320 | DP(NETIF_MSG_LINK, "Set AER to 0x%x\n", aer_val); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 3321 | CL22_WR_OVER_CL45(bp, phy, MDIO_REG_BANK_AER_BLOCK, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3322 | MDIO_AER_BLOCK_AER_REG, aer_val); |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 3323 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3324 | } |
| 3325 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3326 | /******************************************************************/ |
| 3327 | /* Internal phy section */ |
| 3328 | /******************************************************************/ |
| 3329 | |
| 3330 | static void bnx2x_set_serdes_access(struct bnx2x *bp, u8 port) |
| 3331 | { |
| 3332 | u32 emac_base = (port) ? GRCBASE_EMAC1 : GRCBASE_EMAC0; |
| 3333 | |
| 3334 | /* Set Clause 22 */ |
| 3335 | REG_WR(bp, NIG_REG_SERDES0_CTRL_MD_ST + port*0x10, 1); |
| 3336 | REG_WR(bp, emac_base + EMAC_REG_EMAC_MDIO_COMM, 0x245f8000); |
| 3337 | udelay(500); |
| 3338 | REG_WR(bp, emac_base + EMAC_REG_EMAC_MDIO_COMM, 0x245d000f); |
| 3339 | udelay(500); |
| 3340 | /* Set Clause 45 */ |
| 3341 | REG_WR(bp, NIG_REG_SERDES0_CTRL_MD_ST + port*0x10, 0); |
| 3342 | } |
| 3343 | |
| 3344 | static void bnx2x_serdes_deassert(struct bnx2x *bp, u8 port) |
| 3345 | { |
| 3346 | u32 val; |
| 3347 | |
| 3348 | DP(NETIF_MSG_LINK, "bnx2x_serdes_deassert\n"); |
| 3349 | |
| 3350 | val = SERDES_RESET_BITS << (port*16); |
| 3351 | |
| 3352 | /* reset and unreset the SerDes/XGXS */ |
| 3353 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_3_CLEAR, val); |
| 3354 | udelay(500); |
| 3355 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_3_SET, val); |
| 3356 | |
| 3357 | bnx2x_set_serdes_access(bp, port); |
| 3358 | |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3359 | REG_WR(bp, NIG_REG_SERDES0_CTRL_MD_DEVAD + port*0x10, |
| 3360 | DEFAULT_PHY_DEV_ADDR); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3361 | } |
| 3362 | |
| 3363 | static void bnx2x_xgxs_deassert(struct link_params *params) |
| 3364 | { |
| 3365 | struct bnx2x *bp = params->bp; |
| 3366 | u8 port; |
| 3367 | u32 val; |
| 3368 | DP(NETIF_MSG_LINK, "bnx2x_xgxs_deassert\n"); |
| 3369 | port = params->port; |
| 3370 | |
| 3371 | val = XGXS_RESET_BITS << (port*16); |
| 3372 | |
| 3373 | /* reset and unreset the SerDes/XGXS */ |
| 3374 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_3_CLEAR, val); |
| 3375 | udelay(500); |
| 3376 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_3_SET, val); |
| 3377 | |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3378 | REG_WR(bp, NIG_REG_XGXS0_CTRL_MD_ST + port*0x18, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3379 | REG_WR(bp, NIG_REG_XGXS0_CTRL_MD_DEVAD + port*0x18, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3380 | params->phy[INT_PHY].def_md_devad); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3381 | } |
| 3382 | |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 3383 | static void bnx2x_calc_ieee_aneg_adv(struct bnx2x_phy *phy, |
| 3384 | struct link_params *params, u16 *ieee_fc) |
| 3385 | { |
| 3386 | struct bnx2x *bp = params->bp; |
| 3387 | *ieee_fc = MDIO_COMBO_IEEE0_AUTO_NEG_ADV_FULL_DUPLEX; |
| 3388 | /** |
| 3389 | * resolve pause mode and advertisement Please refer to Table |
| 3390 | * 28B-3 of the 802.3ab-1999 spec |
| 3391 | */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3392 | |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 3393 | switch (phy->req_flow_ctrl) { |
| 3394 | case BNX2X_FLOW_CTRL_AUTO: |
| 3395 | if (params->req_fc_auto_adv == BNX2X_FLOW_CTRL_BOTH) |
| 3396 | *ieee_fc |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH; |
| 3397 | else |
| 3398 | *ieee_fc |= |
| 3399 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC; |
| 3400 | break; |
| 3401 | |
| 3402 | case BNX2X_FLOW_CTRL_TX: |
| 3403 | *ieee_fc |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC; |
| 3404 | break; |
| 3405 | |
| 3406 | case BNX2X_FLOW_CTRL_RX: |
| 3407 | case BNX2X_FLOW_CTRL_BOTH: |
| 3408 | *ieee_fc |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH; |
| 3409 | break; |
| 3410 | |
| 3411 | case BNX2X_FLOW_CTRL_NONE: |
| 3412 | default: |
| 3413 | *ieee_fc |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_NONE; |
| 3414 | break; |
| 3415 | } |
| 3416 | DP(NETIF_MSG_LINK, "ieee_fc = 0x%x\n", *ieee_fc); |
| 3417 | } |
| 3418 | |
| 3419 | static void set_phy_vars(struct link_params *params, |
| 3420 | struct link_vars *vars) |
| 3421 | { |
| 3422 | struct bnx2x *bp = params->bp; |
| 3423 | u8 actual_phy_idx, phy_index, link_cfg_idx; |
| 3424 | u8 phy_config_swapped = params->multi_phy_config & |
| 3425 | PORT_HW_CFG_PHY_SWAPPED_ENABLED; |
| 3426 | for (phy_index = INT_PHY; phy_index < params->num_phys; |
| 3427 | phy_index++) { |
| 3428 | link_cfg_idx = LINK_CONFIG_IDX(phy_index); |
| 3429 | actual_phy_idx = phy_index; |
| 3430 | if (phy_config_swapped) { |
| 3431 | if (phy_index == EXT_PHY1) |
| 3432 | actual_phy_idx = EXT_PHY2; |
| 3433 | else if (phy_index == EXT_PHY2) |
| 3434 | actual_phy_idx = EXT_PHY1; |
| 3435 | } |
| 3436 | params->phy[actual_phy_idx].req_flow_ctrl = |
| 3437 | params->req_flow_ctrl[link_cfg_idx]; |
| 3438 | |
| 3439 | params->phy[actual_phy_idx].req_line_speed = |
| 3440 | params->req_line_speed[link_cfg_idx]; |
| 3441 | |
| 3442 | params->phy[actual_phy_idx].speed_cap_mask = |
| 3443 | params->speed_cap_mask[link_cfg_idx]; |
| 3444 | |
| 3445 | params->phy[actual_phy_idx].req_duplex = |
| 3446 | params->req_duplex[link_cfg_idx]; |
| 3447 | |
| 3448 | if (params->req_line_speed[link_cfg_idx] == |
| 3449 | SPEED_AUTO_NEG) |
| 3450 | vars->link_status |= LINK_STATUS_AUTO_NEGOTIATE_ENABLED; |
| 3451 | |
| 3452 | DP(NETIF_MSG_LINK, "req_flow_ctrl %x, req_line_speed %x," |
| 3453 | " speed_cap_mask %x\n", |
| 3454 | params->phy[actual_phy_idx].req_flow_ctrl, |
| 3455 | params->phy[actual_phy_idx].req_line_speed, |
| 3456 | params->phy[actual_phy_idx].speed_cap_mask); |
| 3457 | } |
| 3458 | } |
| 3459 | |
| 3460 | static void bnx2x_ext_phy_set_pause(struct link_params *params, |
| 3461 | struct bnx2x_phy *phy, |
| 3462 | struct link_vars *vars) |
| 3463 | { |
| 3464 | u16 val; |
| 3465 | struct bnx2x *bp = params->bp; |
| 3466 | /* read modify write pause advertizing */ |
| 3467 | bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_ADV_PAUSE, &val); |
| 3468 | |
| 3469 | val &= ~MDIO_AN_REG_ADV_PAUSE_BOTH; |
| 3470 | |
| 3471 | /* Please refer to Table 28B-3 of 802.3ab-1999 spec. */ |
| 3472 | bnx2x_calc_ieee_aneg_adv(phy, params, &vars->ieee_fc); |
| 3473 | if ((vars->ieee_fc & |
| 3474 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC) == |
| 3475 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC) { |
| 3476 | val |= MDIO_AN_REG_ADV_PAUSE_ASYMMETRIC; |
| 3477 | } |
| 3478 | if ((vars->ieee_fc & |
| 3479 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) == |
| 3480 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) { |
| 3481 | val |= MDIO_AN_REG_ADV_PAUSE_PAUSE; |
| 3482 | } |
| 3483 | DP(NETIF_MSG_LINK, "Ext phy AN advertize 0x%x\n", val); |
| 3484 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_ADV_PAUSE, val); |
| 3485 | } |
| 3486 | |
| 3487 | static void bnx2x_pause_resolve(struct link_vars *vars, u32 pause_result) |
| 3488 | { /* LD LP */ |
| 3489 | switch (pause_result) { /* ASYM P ASYM P */ |
| 3490 | case 0xb: /* 1 0 1 1 */ |
| 3491 | vars->flow_ctrl = BNX2X_FLOW_CTRL_TX; |
| 3492 | break; |
| 3493 | |
| 3494 | case 0xe: /* 1 1 1 0 */ |
| 3495 | vars->flow_ctrl = BNX2X_FLOW_CTRL_RX; |
| 3496 | break; |
| 3497 | |
| 3498 | case 0x5: /* 0 1 0 1 */ |
| 3499 | case 0x7: /* 0 1 1 1 */ |
| 3500 | case 0xd: /* 1 1 0 1 */ |
| 3501 | case 0xf: /* 1 1 1 1 */ |
| 3502 | vars->flow_ctrl = BNX2X_FLOW_CTRL_BOTH; |
| 3503 | break; |
| 3504 | |
| 3505 | default: |
| 3506 | break; |
| 3507 | } |
| 3508 | if (pause_result & (1<<0)) |
| 3509 | vars->link_status |= LINK_STATUS_LINK_PARTNER_SYMMETRIC_PAUSE; |
| 3510 | if (pause_result & (1<<1)) |
| 3511 | vars->link_status |= LINK_STATUS_LINK_PARTNER_ASYMMETRIC_PAUSE; |
| 3512 | } |
| 3513 | |
| 3514 | static u8 bnx2x_ext_phy_resolve_fc(struct bnx2x_phy *phy, |
| 3515 | struct link_params *params, |
| 3516 | struct link_vars *vars) |
| 3517 | { |
| 3518 | struct bnx2x *bp = params->bp; |
| 3519 | u16 ld_pause; /* local */ |
| 3520 | u16 lp_pause; /* link partner */ |
| 3521 | u16 pause_result; |
| 3522 | u8 ret = 0; |
| 3523 | /* read twice */ |
| 3524 | |
| 3525 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 3526 | |
| 3527 | if (phy->req_flow_ctrl != BNX2X_FLOW_CTRL_AUTO) |
| 3528 | vars->flow_ctrl = phy->req_flow_ctrl; |
| 3529 | else if (phy->req_line_speed != SPEED_AUTO_NEG) |
| 3530 | vars->flow_ctrl = params->req_fc_auto_adv; |
| 3531 | else if (vars->link_status & LINK_STATUS_AUTO_NEGOTIATE_COMPLETE) { |
| 3532 | ret = 1; |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 3533 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54618SE) { |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 3534 | bnx2x_cl22_read(bp, phy, |
| 3535 | 0x4, &ld_pause); |
| 3536 | bnx2x_cl22_read(bp, phy, |
| 3537 | 0x5, &lp_pause); |
| 3538 | } else { |
| 3539 | bnx2x_cl45_read(bp, phy, |
| 3540 | MDIO_AN_DEVAD, |
| 3541 | MDIO_AN_REG_ADV_PAUSE, &ld_pause); |
| 3542 | bnx2x_cl45_read(bp, phy, |
| 3543 | MDIO_AN_DEVAD, |
| 3544 | MDIO_AN_REG_LP_AUTO_NEG, &lp_pause); |
| 3545 | } |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 3546 | pause_result = (ld_pause & |
| 3547 | MDIO_AN_REG_ADV_PAUSE_MASK) >> 8; |
| 3548 | pause_result |= (lp_pause & |
| 3549 | MDIO_AN_REG_ADV_PAUSE_MASK) >> 10; |
| 3550 | DP(NETIF_MSG_LINK, "Ext PHY pause result 0x%x\n", |
| 3551 | pause_result); |
| 3552 | bnx2x_pause_resolve(vars, pause_result); |
| 3553 | } |
| 3554 | return ret; |
| 3555 | } |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 3556 | /******************************************************************/ |
| 3557 | /* Warpcore section */ |
| 3558 | /******************************************************************/ |
| 3559 | /* The init_internal_warpcore should mirror the xgxs, |
| 3560 | * i.e. reset the lane (if needed), set aer for the |
| 3561 | * init configuration, and set/clear SGMII flag. Internal |
| 3562 | * phy init is done purely in phy_init stage. |
| 3563 | */ |
| 3564 | static void bnx2x_warpcore_enable_AN_KR(struct bnx2x_phy *phy, |
| 3565 | struct link_params *params, |
| 3566 | struct link_vars *vars) { |
Yaniv Rosner | a34bc96 | 2011-07-05 01:06:41 +0000 | [diff] [blame] | 3567 | u16 val16 = 0, lane, bam37 = 0; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 3568 | struct bnx2x *bp = params->bp; |
| 3569 | DP(NETIF_MSG_LINK, "Enable Auto Negotiation for KR\n"); |
| 3570 | /* Check adding advertisement for 1G KX */ |
| 3571 | if (((vars->line_speed == SPEED_AUTO_NEG) && |
| 3572 | (phy->speed_cap_mask & PORT_HW_CFG_SPEED_CAPABILITY_D0_1G)) || |
| 3573 | (vars->line_speed == SPEED_1000)) { |
| 3574 | u16 sd_digital; |
| 3575 | val16 |= (1<<5); |
| 3576 | |
| 3577 | /* Enable CL37 1G Parallel Detect */ |
| 3578 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 3579 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2, &sd_digital); |
| 3580 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3581 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2, |
| 3582 | (sd_digital | 0x1)); |
| 3583 | |
| 3584 | DP(NETIF_MSG_LINK, "Advertize 1G\n"); |
| 3585 | } |
| 3586 | if (((vars->line_speed == SPEED_AUTO_NEG) && |
| 3587 | (phy->speed_cap_mask & PORT_HW_CFG_SPEED_CAPABILITY_D0_10G)) || |
| 3588 | (vars->line_speed == SPEED_10000)) { |
| 3589 | /* Check adding advertisement for 10G KR */ |
| 3590 | val16 |= (1<<7); |
| 3591 | /* Enable 10G Parallel Detect */ |
| 3592 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, |
| 3593 | MDIO_WC_REG_PAR_DET_10G_CTRL, 1); |
| 3594 | |
| 3595 | DP(NETIF_MSG_LINK, "Advertize 10G\n"); |
| 3596 | } |
| 3597 | |
| 3598 | /* Set Transmit PMD settings */ |
| 3599 | lane = bnx2x_get_warpcore_lane(phy, params); |
| 3600 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3601 | MDIO_WC_REG_TX0_TX_DRIVER + 0x10*lane, |
| 3602 | ((0x02 << MDIO_WC_REG_TX0_TX_DRIVER_POST2_COEFF_OFFSET) | |
| 3603 | (0x06 << MDIO_WC_REG_TX0_TX_DRIVER_IDRIVER_OFFSET) | |
| 3604 | (0x09 << MDIO_WC_REG_TX0_TX_DRIVER_IPRE_DRIVER_OFFSET))); |
| 3605 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3606 | MDIO_WC_REG_CL72_USERB0_CL72_OS_DEF_CTRL, |
| 3607 | 0x03f0); |
| 3608 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3609 | MDIO_WC_REG_CL72_USERB0_CL72_2P5_DEF_CTRL, |
| 3610 | 0x03f0); |
| 3611 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3612 | MDIO_WC_REG_CL72_USERB0_CL72_MISC1_CONTROL, |
| 3613 | 0x383f); |
| 3614 | |
| 3615 | /* Advertised speeds */ |
| 3616 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, |
| 3617 | MDIO_WC_REG_AN_IEEE1BLK_AN_ADVERTISEMENT1, val16); |
| 3618 | |
Yaniv Rosner | a34bc96 | 2011-07-05 01:06:41 +0000 | [diff] [blame] | 3619 | /* Enable CL37 BAM */ |
| 3620 | if (REG_RD(bp, params->shmem_base + |
| 3621 | offsetof(struct shmem_region, dev_info. |
| 3622 | port_hw_config[params->port].default_cfg)) & |
| 3623 | PORT_HW_CFG_ENABLE_BAM_ON_KR_ENABLED) { |
| 3624 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 3625 | MDIO_WC_REG_DIGITAL6_MP5_NEXTPAGECTRL, &bam37); |
| 3626 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3627 | MDIO_WC_REG_DIGITAL6_MP5_NEXTPAGECTRL, bam37 | 1); |
| 3628 | DP(NETIF_MSG_LINK, "Enable CL37 BAM on KR\n"); |
| 3629 | } |
| 3630 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 3631 | /* Advertise pause */ |
| 3632 | bnx2x_ext_phy_set_pause(params, phy, vars); |
| 3633 | |
| 3634 | /* Enable Autoneg */ |
| 3635 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, |
| 3636 | MDIO_WC_REG_IEEE0BLK_MIICNTL, 0x1000); |
| 3637 | |
| 3638 | /* Over 1G - AN local device user page 1 */ |
| 3639 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3640 | MDIO_WC_REG_DIGITAL3_UP1, 0x1f); |
| 3641 | |
| 3642 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 3643 | MDIO_WC_REG_DIGITAL5_MISC7, &val16); |
| 3644 | |
| 3645 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3646 | MDIO_WC_REG_DIGITAL5_MISC7, val16 | 0x100); |
| 3647 | } |
| 3648 | |
| 3649 | static void bnx2x_warpcore_set_10G_KR(struct bnx2x_phy *phy, |
| 3650 | struct link_params *params, |
| 3651 | struct link_vars *vars) |
| 3652 | { |
| 3653 | struct bnx2x *bp = params->bp; |
| 3654 | u16 val; |
| 3655 | |
| 3656 | /* Disable Autoneg */ |
| 3657 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3658 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2, 0x7); |
| 3659 | |
| 3660 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, |
| 3661 | MDIO_WC_REG_PAR_DET_10G_CTRL, 0); |
| 3662 | |
| 3663 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3664 | MDIO_WC_REG_CL72_USERB0_CL72_MISC1_CONTROL, 0x3f00); |
| 3665 | |
| 3666 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, |
| 3667 | MDIO_WC_REG_AN_IEEE1BLK_AN_ADVERTISEMENT1, 0); |
| 3668 | |
| 3669 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, |
| 3670 | MDIO_WC_REG_IEEE0BLK_MIICNTL, 0x0); |
| 3671 | |
| 3672 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3673 | MDIO_WC_REG_DIGITAL3_UP1, 0x1); |
| 3674 | |
| 3675 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3676 | MDIO_WC_REG_DIGITAL5_MISC7, 0xa); |
| 3677 | |
| 3678 | /* Disable CL36 PCS Tx */ |
| 3679 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3680 | MDIO_WC_REG_XGXSBLK1_LANECTRL0, 0x0); |
| 3681 | |
| 3682 | /* Double Wide Single Data Rate @ pll rate */ |
| 3683 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3684 | MDIO_WC_REG_XGXSBLK1_LANECTRL1, 0xFFFF); |
| 3685 | |
| 3686 | /* Leave cl72 training enable, needed for KR */ |
| 3687 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, |
| 3688 | MDIO_WC_REG_PMD_IEEE9BLK_TENGBASE_KR_PMD_CONTROL_REGISTER_150, |
| 3689 | 0x2); |
| 3690 | |
| 3691 | /* Leave CL72 enabled */ |
| 3692 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 3693 | MDIO_WC_REG_CL72_USERB0_CL72_MISC1_CONTROL, |
| 3694 | &val); |
| 3695 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3696 | MDIO_WC_REG_CL72_USERB0_CL72_MISC1_CONTROL, |
| 3697 | val | 0x3800); |
| 3698 | |
| 3699 | /* Set speed via PMA/PMD register */ |
| 3700 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, |
| 3701 | MDIO_WC_REG_IEEE0BLK_MIICNTL, 0x2040); |
| 3702 | |
| 3703 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, |
| 3704 | MDIO_WC_REG_IEEE0BLK_AUTONEGNP, 0xB); |
| 3705 | |
| 3706 | /*Enable encoded forced speed */ |
| 3707 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3708 | MDIO_WC_REG_SERDESDIGITAL_MISC2, 0x30); |
| 3709 | |
| 3710 | /* Turn TX scramble payload only the 64/66 scrambler */ |
| 3711 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3712 | MDIO_WC_REG_TX66_CONTROL, 0x9); |
| 3713 | |
| 3714 | /* Turn RX scramble payload only the 64/66 scrambler */ |
| 3715 | bnx2x_cl45_read_or_write(bp, phy, MDIO_WC_DEVAD, |
| 3716 | MDIO_WC_REG_RX66_CONTROL, 0xF9); |
| 3717 | |
| 3718 | /* set and clear loopback to cause a reset to 64/66 decoder */ |
| 3719 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3720 | MDIO_WC_REG_IEEE0BLK_MIICNTL, 0x4000); |
| 3721 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3722 | MDIO_WC_REG_IEEE0BLK_MIICNTL, 0x0); |
| 3723 | |
| 3724 | } |
| 3725 | |
| 3726 | static void bnx2x_warpcore_set_10G_XFI(struct bnx2x_phy *phy, |
| 3727 | struct link_params *params, |
| 3728 | u8 is_xfi) |
| 3729 | { |
| 3730 | struct bnx2x *bp = params->bp; |
| 3731 | u16 misc1_val, tap_val, tx_driver_val, lane, val; |
| 3732 | /* Hold rxSeqStart */ |
| 3733 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 3734 | MDIO_WC_REG_DSC2B0_DSC_MISC_CTRL0, &val); |
| 3735 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3736 | MDIO_WC_REG_DSC2B0_DSC_MISC_CTRL0, (val | 0x8000)); |
| 3737 | |
| 3738 | /* Hold tx_fifo_reset */ |
| 3739 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 3740 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X3, &val); |
| 3741 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3742 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X3, (val | 0x1)); |
| 3743 | |
| 3744 | /* Disable CL73 AN */ |
| 3745 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, 0); |
| 3746 | |
| 3747 | /* Disable 100FX Enable and Auto-Detect */ |
| 3748 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 3749 | MDIO_WC_REG_FX100_CTRL1, &val); |
| 3750 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3751 | MDIO_WC_REG_FX100_CTRL1, (val & 0xFFFA)); |
| 3752 | |
| 3753 | /* Disable 100FX Idle detect */ |
| 3754 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 3755 | MDIO_WC_REG_FX100_CTRL3, &val); |
| 3756 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3757 | MDIO_WC_REG_FX100_CTRL3, (val | 0x0080)); |
| 3758 | |
| 3759 | /* Set Block address to Remote PHY & Clear forced_speed[5] */ |
| 3760 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 3761 | MDIO_WC_REG_DIGITAL4_MISC3, &val); |
| 3762 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3763 | MDIO_WC_REG_DIGITAL4_MISC3, (val & 0xFF7F)); |
| 3764 | |
| 3765 | /* Turn off auto-detect & fiber mode */ |
| 3766 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 3767 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X1, &val); |
| 3768 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3769 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X1, |
| 3770 | (val & 0xFFEE)); |
| 3771 | |
| 3772 | /* Set filter_force_link, disable_false_link and parallel_detect */ |
| 3773 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 3774 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2, &val); |
| 3775 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3776 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2, |
| 3777 | ((val | 0x0006) & 0xFFFE)); |
| 3778 | |
| 3779 | /* Set XFI / SFI */ |
| 3780 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 3781 | MDIO_WC_REG_SERDESDIGITAL_MISC1, &misc1_val); |
| 3782 | |
| 3783 | misc1_val &= ~(0x1f); |
| 3784 | |
| 3785 | if (is_xfi) { |
| 3786 | misc1_val |= 0x5; |
| 3787 | tap_val = ((0x08 << MDIO_WC_REG_TX_FIR_TAP_POST_TAP_OFFSET) | |
| 3788 | (0x37 << MDIO_WC_REG_TX_FIR_TAP_MAIN_TAP_OFFSET) | |
| 3789 | (0x00 << MDIO_WC_REG_TX_FIR_TAP_PRE_TAP_OFFSET)); |
| 3790 | tx_driver_val = |
| 3791 | ((0x00 << MDIO_WC_REG_TX0_TX_DRIVER_POST2_COEFF_OFFSET) | |
| 3792 | (0x02 << MDIO_WC_REG_TX0_TX_DRIVER_IDRIVER_OFFSET) | |
| 3793 | (0x03 << MDIO_WC_REG_TX0_TX_DRIVER_IPRE_DRIVER_OFFSET)); |
| 3794 | |
| 3795 | } else { |
| 3796 | misc1_val |= 0x9; |
| 3797 | tap_val = ((0x12 << MDIO_WC_REG_TX_FIR_TAP_POST_TAP_OFFSET) | |
| 3798 | (0x2d << MDIO_WC_REG_TX_FIR_TAP_MAIN_TAP_OFFSET) | |
| 3799 | (0x00 << MDIO_WC_REG_TX_FIR_TAP_PRE_TAP_OFFSET)); |
| 3800 | tx_driver_val = |
| 3801 | ((0x02 << MDIO_WC_REG_TX0_TX_DRIVER_POST2_COEFF_OFFSET) | |
| 3802 | (0x02 << MDIO_WC_REG_TX0_TX_DRIVER_IDRIVER_OFFSET) | |
| 3803 | (0x02 << MDIO_WC_REG_TX0_TX_DRIVER_IPRE_DRIVER_OFFSET)); |
| 3804 | } |
| 3805 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3806 | MDIO_WC_REG_SERDESDIGITAL_MISC1, misc1_val); |
| 3807 | |
| 3808 | /* Set Transmit PMD settings */ |
| 3809 | lane = bnx2x_get_warpcore_lane(phy, params); |
| 3810 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3811 | MDIO_WC_REG_TX_FIR_TAP, |
| 3812 | tap_val | MDIO_WC_REG_TX_FIR_TAP_ENABLE); |
| 3813 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3814 | MDIO_WC_REG_TX0_TX_DRIVER + 0x10*lane, |
| 3815 | tx_driver_val); |
| 3816 | |
| 3817 | /* Enable fiber mode, enable and invert sig_det */ |
| 3818 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 3819 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X1, &val); |
| 3820 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3821 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X1, val | 0xd); |
| 3822 | |
| 3823 | /* Set Block address to Remote PHY & Set forced_speed[5], 40bit mode */ |
| 3824 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 3825 | MDIO_WC_REG_DIGITAL4_MISC3, &val); |
| 3826 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3827 | MDIO_WC_REG_DIGITAL4_MISC3, val | 0x8080); |
| 3828 | |
| 3829 | /* 10G XFI Full Duplex */ |
| 3830 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3831 | MDIO_WC_REG_IEEE0BLK_MIICNTL, 0x100); |
| 3832 | |
| 3833 | /* Release tx_fifo_reset */ |
| 3834 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 3835 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X3, &val); |
| 3836 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3837 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X3, val & 0xFFFE); |
| 3838 | |
| 3839 | /* Release rxSeqStart */ |
| 3840 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 3841 | MDIO_WC_REG_DSC2B0_DSC_MISC_CTRL0, &val); |
| 3842 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3843 | MDIO_WC_REG_DSC2B0_DSC_MISC_CTRL0, (val & 0x7FFF)); |
| 3844 | } |
| 3845 | |
| 3846 | static void bnx2x_warpcore_set_20G_KR2(struct bnx2x *bp, |
| 3847 | struct bnx2x_phy *phy) |
| 3848 | { |
| 3849 | DP(NETIF_MSG_LINK, "KR2 still not supported !!!\n"); |
| 3850 | } |
| 3851 | |
| 3852 | static void bnx2x_warpcore_set_20G_DXGXS(struct bnx2x *bp, |
| 3853 | struct bnx2x_phy *phy, |
| 3854 | u16 lane) |
| 3855 | { |
| 3856 | /* Rx0 anaRxControl1G */ |
| 3857 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3858 | MDIO_WC_REG_RX0_ANARXCONTROL1G, 0x90); |
| 3859 | |
| 3860 | /* Rx2 anaRxControl1G */ |
| 3861 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3862 | MDIO_WC_REG_RX2_ANARXCONTROL1G, 0x90); |
| 3863 | |
| 3864 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3865 | MDIO_WC_REG_RX66_SCW0, 0xE070); |
| 3866 | |
| 3867 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3868 | MDIO_WC_REG_RX66_SCW1, 0xC0D0); |
| 3869 | |
| 3870 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3871 | MDIO_WC_REG_RX66_SCW2, 0xA0B0); |
| 3872 | |
| 3873 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3874 | MDIO_WC_REG_RX66_SCW3, 0x8090); |
| 3875 | |
| 3876 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3877 | MDIO_WC_REG_RX66_SCW0_MASK, 0xF0F0); |
| 3878 | |
| 3879 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3880 | MDIO_WC_REG_RX66_SCW1_MASK, 0xF0F0); |
| 3881 | |
| 3882 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3883 | MDIO_WC_REG_RX66_SCW2_MASK, 0xF0F0); |
| 3884 | |
| 3885 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3886 | MDIO_WC_REG_RX66_SCW3_MASK, 0xF0F0); |
| 3887 | |
| 3888 | /* Serdes Digital Misc1 */ |
| 3889 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3890 | MDIO_WC_REG_SERDESDIGITAL_MISC1, 0x6008); |
| 3891 | |
| 3892 | /* Serdes Digital4 Misc3 */ |
| 3893 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3894 | MDIO_WC_REG_DIGITAL4_MISC3, 0x8088); |
| 3895 | |
| 3896 | /* Set Transmit PMD settings */ |
| 3897 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3898 | MDIO_WC_REG_TX_FIR_TAP, |
| 3899 | ((0x12 << MDIO_WC_REG_TX_FIR_TAP_POST_TAP_OFFSET) | |
| 3900 | (0x2d << MDIO_WC_REG_TX_FIR_TAP_MAIN_TAP_OFFSET) | |
| 3901 | (0x00 << MDIO_WC_REG_TX_FIR_TAP_PRE_TAP_OFFSET) | |
| 3902 | MDIO_WC_REG_TX_FIR_TAP_ENABLE)); |
| 3903 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3904 | MDIO_WC_REG_TX0_TX_DRIVER + 0x10*lane, |
| 3905 | ((0x02 << MDIO_WC_REG_TX0_TX_DRIVER_POST2_COEFF_OFFSET) | |
| 3906 | (0x02 << MDIO_WC_REG_TX0_TX_DRIVER_IDRIVER_OFFSET) | |
| 3907 | (0x02 << MDIO_WC_REG_TX0_TX_DRIVER_IPRE_DRIVER_OFFSET))); |
| 3908 | } |
| 3909 | |
| 3910 | static void bnx2x_warpcore_set_sgmii_speed(struct bnx2x_phy *phy, |
| 3911 | struct link_params *params, |
| 3912 | u8 fiber_mode) |
| 3913 | { |
| 3914 | struct bnx2x *bp = params->bp; |
| 3915 | u16 val16, digctrl_kx1, digctrl_kx2; |
| 3916 | u8 lane; |
| 3917 | |
| 3918 | lane = bnx2x_get_warpcore_lane(phy, params); |
| 3919 | |
| 3920 | /* Clear XFI clock comp in non-10G single lane mode. */ |
| 3921 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 3922 | MDIO_WC_REG_RX66_CONTROL, &val16); |
| 3923 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3924 | MDIO_WC_REG_RX66_CONTROL, val16 & ~(3<<13)); |
| 3925 | |
| 3926 | if (phy->req_line_speed == SPEED_AUTO_NEG) { |
| 3927 | /* SGMII Autoneg */ |
| 3928 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 3929 | MDIO_WC_REG_COMBO_IEEE0_MIICTRL, &val16); |
| 3930 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3931 | MDIO_WC_REG_COMBO_IEEE0_MIICTRL, |
| 3932 | val16 | 0x1000); |
| 3933 | DP(NETIF_MSG_LINK, "set SGMII AUTONEG\n"); |
| 3934 | } else { |
| 3935 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 3936 | MDIO_WC_REG_COMBO_IEEE0_MIICTRL, &val16); |
| 3937 | val16 &= 0xcfbf; |
| 3938 | switch (phy->req_line_speed) { |
| 3939 | case SPEED_10: |
| 3940 | break; |
| 3941 | case SPEED_100: |
| 3942 | val16 |= 0x2000; |
| 3943 | break; |
| 3944 | case SPEED_1000: |
| 3945 | val16 |= 0x0040; |
| 3946 | break; |
| 3947 | default: |
| 3948 | DP(NETIF_MSG_LINK, "Speed not supported: 0x%x" |
| 3949 | "\n", phy->req_line_speed); |
| 3950 | return; |
| 3951 | } |
| 3952 | |
| 3953 | if (phy->req_duplex == DUPLEX_FULL) |
| 3954 | val16 |= 0x0100; |
| 3955 | |
| 3956 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3957 | MDIO_WC_REG_COMBO_IEEE0_MIICTRL, val16); |
| 3958 | |
| 3959 | DP(NETIF_MSG_LINK, "set SGMII force speed %d\n", |
| 3960 | phy->req_line_speed); |
| 3961 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 3962 | MDIO_WC_REG_COMBO_IEEE0_MIICTRL, &val16); |
| 3963 | DP(NETIF_MSG_LINK, " (readback) %x\n", val16); |
| 3964 | } |
| 3965 | |
| 3966 | /* SGMII Slave mode and disable signal detect */ |
| 3967 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 3968 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X1, &digctrl_kx1); |
| 3969 | if (fiber_mode) |
| 3970 | digctrl_kx1 = 1; |
| 3971 | else |
| 3972 | digctrl_kx1 &= 0xff4a; |
| 3973 | |
| 3974 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3975 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X1, |
| 3976 | digctrl_kx1); |
| 3977 | |
| 3978 | /* Turn off parallel detect */ |
| 3979 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 3980 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2, &digctrl_kx2); |
| 3981 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3982 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2, |
| 3983 | (digctrl_kx2 & ~(1<<2))); |
| 3984 | |
| 3985 | /* Re-enable parallel detect */ |
| 3986 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3987 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2, |
| 3988 | (digctrl_kx2 | (1<<2))); |
| 3989 | |
| 3990 | /* Enable autodet */ |
| 3991 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3992 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X1, |
| 3993 | (digctrl_kx1 | 0x10)); |
| 3994 | } |
| 3995 | |
| 3996 | static void bnx2x_warpcore_reset_lane(struct bnx2x *bp, |
| 3997 | struct bnx2x_phy *phy, |
| 3998 | u8 reset) |
| 3999 | { |
| 4000 | u16 val; |
| 4001 | /* Take lane out of reset after configuration is finished */ |
| 4002 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4003 | MDIO_WC_REG_DIGITAL5_MISC6, &val); |
| 4004 | if (reset) |
| 4005 | val |= 0xC000; |
| 4006 | else |
| 4007 | val &= 0x3FFF; |
| 4008 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4009 | MDIO_WC_REG_DIGITAL5_MISC6, val); |
| 4010 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4011 | MDIO_WC_REG_DIGITAL5_MISC6, &val); |
| 4012 | } |
| 4013 | |
| 4014 | |
| 4015 | /* Clear SFI/XFI link settings registers */ |
| 4016 | static void bnx2x_warpcore_clear_regs(struct bnx2x_phy *phy, |
| 4017 | struct link_params *params, |
| 4018 | u16 lane) |
| 4019 | { |
| 4020 | struct bnx2x *bp = params->bp; |
| 4021 | u16 val16; |
| 4022 | |
| 4023 | /* Set XFI clock comp as default. */ |
| 4024 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4025 | MDIO_WC_REG_RX66_CONTROL, &val16); |
| 4026 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4027 | MDIO_WC_REG_RX66_CONTROL, val16 | (3<<13)); |
| 4028 | |
| 4029 | bnx2x_warpcore_reset_lane(bp, phy, 1); |
| 4030 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, 0); |
| 4031 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4032 | MDIO_WC_REG_FX100_CTRL1, 0x014a); |
| 4033 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4034 | MDIO_WC_REG_FX100_CTRL3, 0x0800); |
| 4035 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4036 | MDIO_WC_REG_DIGITAL4_MISC3, 0x8008); |
| 4037 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4038 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X1, 0x0195); |
| 4039 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4040 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2, 0x0007); |
| 4041 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4042 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X3, 0x0002); |
| 4043 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4044 | MDIO_WC_REG_SERDESDIGITAL_MISC1, 0x6000); |
| 4045 | lane = bnx2x_get_warpcore_lane(phy, params); |
| 4046 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4047 | MDIO_WC_REG_TX_FIR_TAP, 0x0000); |
| 4048 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4049 | MDIO_WC_REG_TX0_TX_DRIVER + 0x10*lane, 0x0990); |
| 4050 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4051 | MDIO_WC_REG_IEEE0BLK_MIICNTL, 0x2040); |
| 4052 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4053 | MDIO_WC_REG_COMBO_IEEE0_MIICTRL, 0x0140); |
| 4054 | bnx2x_warpcore_reset_lane(bp, phy, 0); |
| 4055 | } |
| 4056 | |
| 4057 | static int bnx2x_get_mod_abs_int_cfg(struct bnx2x *bp, |
| 4058 | u32 chip_id, |
| 4059 | u32 shmem_base, u8 port, |
| 4060 | u8 *gpio_num, u8 *gpio_port) |
| 4061 | { |
| 4062 | u32 cfg_pin; |
| 4063 | *gpio_num = 0; |
| 4064 | *gpio_port = 0; |
| 4065 | if (CHIP_IS_E3(bp)) { |
| 4066 | cfg_pin = (REG_RD(bp, shmem_base + |
| 4067 | offsetof(struct shmem_region, |
| 4068 | dev_info.port_hw_config[port].e3_sfp_ctrl)) & |
| 4069 | PORT_HW_CFG_E3_MOD_ABS_MASK) >> |
| 4070 | PORT_HW_CFG_E3_MOD_ABS_SHIFT; |
| 4071 | |
| 4072 | /* |
| 4073 | * Should not happen. This function called upon interrupt |
| 4074 | * triggered by GPIO ( since EPIO can only generate interrupts |
| 4075 | * to MCP). |
| 4076 | * So if this function was called and none of the GPIOs was set, |
| 4077 | * it means the shit hit the fan. |
| 4078 | */ |
| 4079 | if ((cfg_pin < PIN_CFG_GPIO0_P0) || |
| 4080 | (cfg_pin > PIN_CFG_GPIO3_P1)) { |
| 4081 | DP(NETIF_MSG_LINK, "ERROR: Invalid cfg pin %x for " |
| 4082 | "module detect indication\n", |
| 4083 | cfg_pin); |
| 4084 | return -EINVAL; |
| 4085 | } |
| 4086 | |
| 4087 | *gpio_num = (cfg_pin - PIN_CFG_GPIO0_P0) & 0x3; |
| 4088 | *gpio_port = (cfg_pin - PIN_CFG_GPIO0_P0) >> 2; |
| 4089 | } else { |
| 4090 | *gpio_num = MISC_REGISTERS_GPIO_3; |
| 4091 | *gpio_port = port; |
| 4092 | } |
| 4093 | DP(NETIF_MSG_LINK, "MOD_ABS int GPIO%d_P%d\n", *gpio_num, *gpio_port); |
| 4094 | return 0; |
| 4095 | } |
| 4096 | |
| 4097 | static int bnx2x_is_sfp_module_plugged(struct bnx2x_phy *phy, |
| 4098 | struct link_params *params) |
| 4099 | { |
| 4100 | struct bnx2x *bp = params->bp; |
| 4101 | u8 gpio_num, gpio_port; |
| 4102 | u32 gpio_val; |
| 4103 | if (bnx2x_get_mod_abs_int_cfg(bp, params->chip_id, |
| 4104 | params->shmem_base, params->port, |
| 4105 | &gpio_num, &gpio_port) != 0) |
| 4106 | return 0; |
| 4107 | gpio_val = bnx2x_get_gpio(bp, gpio_num, gpio_port); |
| 4108 | |
| 4109 | /* Call the handling function in case module is detected */ |
| 4110 | if (gpio_val == 0) |
| 4111 | return 1; |
| 4112 | else |
| 4113 | return 0; |
| 4114 | } |
| 4115 | |
| 4116 | static void bnx2x_warpcore_config_init(struct bnx2x_phy *phy, |
| 4117 | struct link_params *params, |
| 4118 | struct link_vars *vars) |
| 4119 | { |
| 4120 | struct bnx2x *bp = params->bp; |
| 4121 | u32 serdes_net_if; |
| 4122 | u8 fiber_mode; |
| 4123 | u16 lane = bnx2x_get_warpcore_lane(phy, params); |
| 4124 | serdes_net_if = (REG_RD(bp, params->shmem_base + |
| 4125 | offsetof(struct shmem_region, dev_info. |
| 4126 | port_hw_config[params->port].default_cfg)) & |
| 4127 | PORT_HW_CFG_NET_SERDES_IF_MASK); |
| 4128 | DP(NETIF_MSG_LINK, "Begin Warpcore init, link_speed %d, " |
| 4129 | "serdes_net_if = 0x%x\n", |
| 4130 | vars->line_speed, serdes_net_if); |
| 4131 | bnx2x_set_aer_mmd(params, phy); |
| 4132 | |
| 4133 | vars->phy_flags |= PHY_XGXS_FLAG; |
| 4134 | if ((serdes_net_if == PORT_HW_CFG_NET_SERDES_IF_SGMII) || |
| 4135 | (phy->req_line_speed && |
| 4136 | ((phy->req_line_speed == SPEED_100) || |
| 4137 | (phy->req_line_speed == SPEED_10)))) { |
| 4138 | vars->phy_flags |= PHY_SGMII_FLAG; |
| 4139 | DP(NETIF_MSG_LINK, "Setting SGMII mode\n"); |
| 4140 | bnx2x_warpcore_clear_regs(phy, params, lane); |
| 4141 | bnx2x_warpcore_set_sgmii_speed(phy, params, 0); |
| 4142 | } else { |
| 4143 | switch (serdes_net_if) { |
| 4144 | case PORT_HW_CFG_NET_SERDES_IF_KR: |
| 4145 | /* Enable KR Auto Neg */ |
| 4146 | if (params->loopback_mode == LOOPBACK_NONE) |
| 4147 | bnx2x_warpcore_enable_AN_KR(phy, params, vars); |
| 4148 | else { |
| 4149 | DP(NETIF_MSG_LINK, "Setting KR 10G-Force\n"); |
| 4150 | bnx2x_warpcore_set_10G_KR(phy, params, vars); |
| 4151 | } |
| 4152 | break; |
| 4153 | |
| 4154 | case PORT_HW_CFG_NET_SERDES_IF_XFI: |
| 4155 | bnx2x_warpcore_clear_regs(phy, params, lane); |
| 4156 | if (vars->line_speed == SPEED_10000) { |
| 4157 | DP(NETIF_MSG_LINK, "Setting 10G XFI\n"); |
| 4158 | bnx2x_warpcore_set_10G_XFI(phy, params, 1); |
| 4159 | } else { |
| 4160 | if (SINGLE_MEDIA_DIRECT(params)) { |
| 4161 | DP(NETIF_MSG_LINK, "1G Fiber\n"); |
| 4162 | fiber_mode = 1; |
| 4163 | } else { |
| 4164 | DP(NETIF_MSG_LINK, "10/100/1G SGMII\n"); |
| 4165 | fiber_mode = 0; |
| 4166 | } |
| 4167 | bnx2x_warpcore_set_sgmii_speed(phy, |
| 4168 | params, |
| 4169 | fiber_mode); |
| 4170 | } |
| 4171 | |
| 4172 | break; |
| 4173 | |
| 4174 | case PORT_HW_CFG_NET_SERDES_IF_SFI: |
| 4175 | |
| 4176 | bnx2x_warpcore_clear_regs(phy, params, lane); |
| 4177 | if (vars->line_speed == SPEED_10000) { |
| 4178 | DP(NETIF_MSG_LINK, "Setting 10G SFI\n"); |
| 4179 | bnx2x_warpcore_set_10G_XFI(phy, params, 0); |
| 4180 | } else if (vars->line_speed == SPEED_1000) { |
| 4181 | DP(NETIF_MSG_LINK, "Setting 1G Fiber\n"); |
| 4182 | bnx2x_warpcore_set_sgmii_speed(phy, params, 1); |
| 4183 | } |
| 4184 | /* Issue Module detection */ |
| 4185 | if (bnx2x_is_sfp_module_plugged(phy, params)) |
| 4186 | bnx2x_sfp_module_detection(phy, params); |
| 4187 | break; |
| 4188 | |
| 4189 | case PORT_HW_CFG_NET_SERDES_IF_DXGXS: |
| 4190 | if (vars->line_speed != SPEED_20000) { |
| 4191 | DP(NETIF_MSG_LINK, "Speed not supported yet\n"); |
| 4192 | return; |
| 4193 | } |
| 4194 | DP(NETIF_MSG_LINK, "Setting 20G DXGXS\n"); |
| 4195 | bnx2x_warpcore_set_20G_DXGXS(bp, phy, lane); |
| 4196 | /* Issue Module detection */ |
| 4197 | |
| 4198 | bnx2x_sfp_module_detection(phy, params); |
| 4199 | break; |
| 4200 | |
| 4201 | case PORT_HW_CFG_NET_SERDES_IF_KR2: |
| 4202 | if (vars->line_speed != SPEED_20000) { |
| 4203 | DP(NETIF_MSG_LINK, "Speed not supported yet\n"); |
| 4204 | return; |
| 4205 | } |
| 4206 | DP(NETIF_MSG_LINK, "Setting 20G KR2\n"); |
| 4207 | bnx2x_warpcore_set_20G_KR2(bp, phy); |
| 4208 | break; |
| 4209 | |
| 4210 | default: |
| 4211 | DP(NETIF_MSG_LINK, "Unsupported Serdes Net Interface " |
| 4212 | "0x%x\n", serdes_net_if); |
| 4213 | return; |
| 4214 | } |
| 4215 | } |
| 4216 | |
| 4217 | /* Take lane out of reset after configuration is finished */ |
| 4218 | bnx2x_warpcore_reset_lane(bp, phy, 0); |
| 4219 | DP(NETIF_MSG_LINK, "Exit config init\n"); |
| 4220 | } |
| 4221 | |
| 4222 | static void bnx2x_sfp_e3_set_transmitter(struct link_params *params, |
| 4223 | struct bnx2x_phy *phy, |
| 4224 | u8 tx_en) |
| 4225 | { |
| 4226 | struct bnx2x *bp = params->bp; |
| 4227 | u32 cfg_pin; |
| 4228 | u8 port = params->port; |
| 4229 | |
| 4230 | cfg_pin = REG_RD(bp, params->shmem_base + |
| 4231 | offsetof(struct shmem_region, |
| 4232 | dev_info.port_hw_config[port].e3_sfp_ctrl)) & |
| 4233 | PORT_HW_CFG_TX_LASER_MASK; |
| 4234 | /* Set the !tx_en since this pin is DISABLE_TX_LASER */ |
| 4235 | DP(NETIF_MSG_LINK, "Setting WC TX to %d\n", tx_en); |
| 4236 | /* For 20G, the expected pin to be used is 3 pins after the current */ |
| 4237 | |
| 4238 | bnx2x_set_cfg_pin(bp, cfg_pin, tx_en ^ 1); |
| 4239 | if (phy->speed_cap_mask & PORT_HW_CFG_SPEED_CAPABILITY_D0_20G) |
| 4240 | bnx2x_set_cfg_pin(bp, cfg_pin + 3, tx_en ^ 1); |
| 4241 | } |
| 4242 | |
| 4243 | static void bnx2x_warpcore_link_reset(struct bnx2x_phy *phy, |
| 4244 | struct link_params *params) |
| 4245 | { |
| 4246 | struct bnx2x *bp = params->bp; |
| 4247 | u16 val16; |
| 4248 | bnx2x_sfp_e3_set_transmitter(params, phy, 0); |
| 4249 | bnx2x_set_mdio_clk(bp, params->chip_id, params->port); |
| 4250 | bnx2x_set_aer_mmd(params, phy); |
| 4251 | /* Global register */ |
| 4252 | bnx2x_warpcore_reset_lane(bp, phy, 1); |
| 4253 | |
| 4254 | /* Clear loopback settings (if any) */ |
| 4255 | /* 10G & 20G */ |
| 4256 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4257 | MDIO_WC_REG_COMBO_IEEE0_MIICTRL, &val16); |
| 4258 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4259 | MDIO_WC_REG_COMBO_IEEE0_MIICTRL, val16 & |
| 4260 | 0xBFFF); |
| 4261 | |
| 4262 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4263 | MDIO_WC_REG_IEEE0BLK_MIICNTL, &val16); |
| 4264 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4265 | MDIO_WC_REG_IEEE0BLK_MIICNTL, val16 & 0xfffe); |
| 4266 | |
| 4267 | /* Update those 1-copy registers */ |
| 4268 | CL22_WR_OVER_CL45(bp, phy, MDIO_REG_BANK_AER_BLOCK, |
| 4269 | MDIO_AER_BLOCK_AER_REG, 0); |
| 4270 | /* Enable 1G MDIO (1-copy) */ |
| 4271 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4272 | MDIO_WC_REG_XGXSBLK0_XGXSCONTROL, |
| 4273 | &val16); |
| 4274 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4275 | MDIO_WC_REG_XGXSBLK0_XGXSCONTROL, |
| 4276 | val16 & ~0x10); |
| 4277 | |
| 4278 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4279 | MDIO_WC_REG_XGXSBLK1_LANECTRL2, &val16); |
| 4280 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4281 | MDIO_WC_REG_XGXSBLK1_LANECTRL2, |
| 4282 | val16 & 0xff00); |
| 4283 | |
| 4284 | } |
| 4285 | |
| 4286 | static void bnx2x_set_warpcore_loopback(struct bnx2x_phy *phy, |
| 4287 | struct link_params *params) |
| 4288 | { |
| 4289 | struct bnx2x *bp = params->bp; |
| 4290 | u16 val16; |
| 4291 | u32 lane; |
| 4292 | DP(NETIF_MSG_LINK, "Setting Warpcore loopback type %x, speed %d\n", |
| 4293 | params->loopback_mode, phy->req_line_speed); |
| 4294 | |
| 4295 | if (phy->req_line_speed < SPEED_10000) { |
| 4296 | /* 10/100/1000 */ |
| 4297 | |
| 4298 | /* Update those 1-copy registers */ |
| 4299 | CL22_WR_OVER_CL45(bp, phy, MDIO_REG_BANK_AER_BLOCK, |
| 4300 | MDIO_AER_BLOCK_AER_REG, 0); |
| 4301 | /* Enable 1G MDIO (1-copy) */ |
| 4302 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4303 | MDIO_WC_REG_XGXSBLK0_XGXSCONTROL, |
| 4304 | &val16); |
| 4305 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4306 | MDIO_WC_REG_XGXSBLK0_XGXSCONTROL, |
| 4307 | val16 | 0x10); |
| 4308 | /* Set 1G loopback based on lane (1-copy) */ |
| 4309 | lane = bnx2x_get_warpcore_lane(phy, params); |
| 4310 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4311 | MDIO_WC_REG_XGXSBLK1_LANECTRL2, &val16); |
| 4312 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4313 | MDIO_WC_REG_XGXSBLK1_LANECTRL2, |
| 4314 | val16 | (1<<lane)); |
| 4315 | |
| 4316 | /* Switch back to 4-copy registers */ |
| 4317 | bnx2x_set_aer_mmd(params, phy); |
| 4318 | /* Global loopback, not recommended. */ |
| 4319 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4320 | MDIO_WC_REG_COMBO_IEEE0_MIICTRL, &val16); |
| 4321 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4322 | MDIO_WC_REG_COMBO_IEEE0_MIICTRL, val16 | |
| 4323 | 0x4000); |
| 4324 | } else { |
| 4325 | /* 10G & 20G */ |
| 4326 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4327 | MDIO_WC_REG_COMBO_IEEE0_MIICTRL, &val16); |
| 4328 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4329 | MDIO_WC_REG_COMBO_IEEE0_MIICTRL, val16 | |
| 4330 | 0x4000); |
| 4331 | |
| 4332 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4333 | MDIO_WC_REG_IEEE0BLK_MIICNTL, &val16); |
| 4334 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4335 | MDIO_WC_REG_IEEE0BLK_MIICNTL, val16 | 0x1); |
| 4336 | } |
| 4337 | } |
| 4338 | |
| 4339 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4340 | void bnx2x_link_status_update(struct link_params *params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4341 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4342 | { |
| 4343 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 4344 | u8 link_10g_plus; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4345 | u8 port = params->port; |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 4346 | u32 sync_offset, media_types; |
Yaniv Rosner | fd36a2e | 2011-05-31 21:29:05 +0000 | [diff] [blame] | 4347 | /* Update PHY configuration */ |
| 4348 | set_phy_vars(params, vars); |
| 4349 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4350 | vars->link_status = REG_RD(bp, params->shmem_base + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4351 | offsetof(struct shmem_region, |
| 4352 | port_mb[port].link_status)); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4353 | |
| 4354 | vars->link_up = (vars->link_status & LINK_STATUS_LINK_UP); |
Yaniv Rosner | fd36a2e | 2011-05-31 21:29:05 +0000 | [diff] [blame] | 4355 | vars->phy_flags = PHY_XGXS_FLAG; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4356 | if (vars->link_up) { |
| 4357 | DP(NETIF_MSG_LINK, "phy link up\n"); |
| 4358 | |
| 4359 | vars->phy_link_up = 1; |
| 4360 | vars->duplex = DUPLEX_FULL; |
| 4361 | switch (vars->link_status & |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4362 | LINK_STATUS_SPEED_AND_DUPLEX_MASK) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4363 | case LINK_10THD: |
| 4364 | vars->duplex = DUPLEX_HALF; |
| 4365 | /* fall thru */ |
| 4366 | case LINK_10TFD: |
| 4367 | vars->line_speed = SPEED_10; |
| 4368 | break; |
| 4369 | |
| 4370 | case LINK_100TXHD: |
| 4371 | vars->duplex = DUPLEX_HALF; |
| 4372 | /* fall thru */ |
| 4373 | case LINK_100T4: |
| 4374 | case LINK_100TXFD: |
| 4375 | vars->line_speed = SPEED_100; |
| 4376 | break; |
| 4377 | |
| 4378 | case LINK_1000THD: |
| 4379 | vars->duplex = DUPLEX_HALF; |
| 4380 | /* fall thru */ |
| 4381 | case LINK_1000TFD: |
| 4382 | vars->line_speed = SPEED_1000; |
| 4383 | break; |
| 4384 | |
| 4385 | case LINK_2500THD: |
| 4386 | vars->duplex = DUPLEX_HALF; |
| 4387 | /* fall thru */ |
| 4388 | case LINK_2500TFD: |
| 4389 | vars->line_speed = SPEED_2500; |
| 4390 | break; |
| 4391 | |
| 4392 | case LINK_10GTFD: |
| 4393 | vars->line_speed = SPEED_10000; |
| 4394 | break; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4395 | case LINK_20GTFD: |
| 4396 | vars->line_speed = SPEED_20000; |
| 4397 | break; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4398 | default: |
| 4399 | break; |
| 4400 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4401 | vars->flow_ctrl = 0; |
| 4402 | if (vars->link_status & LINK_STATUS_TX_FLOW_CONTROL_ENABLED) |
| 4403 | vars->flow_ctrl |= BNX2X_FLOW_CTRL_TX; |
| 4404 | |
| 4405 | if (vars->link_status & LINK_STATUS_RX_FLOW_CONTROL_ENABLED) |
| 4406 | vars->flow_ctrl |= BNX2X_FLOW_CTRL_RX; |
| 4407 | |
| 4408 | if (!vars->flow_ctrl) |
| 4409 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 4410 | |
| 4411 | if (vars->line_speed && |
| 4412 | ((vars->line_speed == SPEED_10) || |
| 4413 | (vars->line_speed == SPEED_100))) { |
| 4414 | vars->phy_flags |= PHY_SGMII_FLAG; |
| 4415 | } else { |
| 4416 | vars->phy_flags &= ~PHY_SGMII_FLAG; |
| 4417 | } |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4418 | if (vars->line_speed && |
| 4419 | USES_WARPCORE(bp) && |
| 4420 | (vars->line_speed == SPEED_1000)) |
| 4421 | vars->phy_flags |= PHY_SGMII_FLAG; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4422 | /* anything 10 and over uses the bmac */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 4423 | link_10g_plus = (vars->line_speed >= SPEED_10000); |
| 4424 | |
| 4425 | if (link_10g_plus) { |
| 4426 | if (USES_WARPCORE(bp)) |
| 4427 | vars->mac_type = MAC_TYPE_XMAC; |
| 4428 | else |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4429 | vars->mac_type = MAC_TYPE_BMAC; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 4430 | } else { |
| 4431 | if (USES_WARPCORE(bp)) |
| 4432 | vars->mac_type = MAC_TYPE_UMAC; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4433 | else |
| 4434 | vars->mac_type = MAC_TYPE_EMAC; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 4435 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4436 | } else { /* link down */ |
| 4437 | DP(NETIF_MSG_LINK, "phy link down\n"); |
| 4438 | |
| 4439 | vars->phy_link_up = 0; |
| 4440 | |
| 4441 | vars->line_speed = 0; |
| 4442 | vars->duplex = DUPLEX_FULL; |
| 4443 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 4444 | |
| 4445 | /* indicate no mac active */ |
| 4446 | vars->mac_type = MAC_TYPE_NONE; |
| 4447 | } |
| 4448 | |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 4449 | /* Sync media type */ |
| 4450 | sync_offset = params->shmem_base + |
| 4451 | offsetof(struct shmem_region, |
| 4452 | dev_info.port_hw_config[port].media_type); |
| 4453 | media_types = REG_RD(bp, sync_offset); |
| 4454 | |
| 4455 | params->phy[INT_PHY].media_type = |
| 4456 | (media_types & PORT_HW_CFG_MEDIA_TYPE_PHY0_MASK) >> |
| 4457 | PORT_HW_CFG_MEDIA_TYPE_PHY0_SHIFT; |
| 4458 | params->phy[EXT_PHY1].media_type = |
| 4459 | (media_types & PORT_HW_CFG_MEDIA_TYPE_PHY1_MASK) >> |
| 4460 | PORT_HW_CFG_MEDIA_TYPE_PHY1_SHIFT; |
| 4461 | params->phy[EXT_PHY2].media_type = |
| 4462 | (media_types & PORT_HW_CFG_MEDIA_TYPE_PHY2_MASK) >> |
| 4463 | PORT_HW_CFG_MEDIA_TYPE_PHY2_SHIFT; |
| 4464 | DP(NETIF_MSG_LINK, "media_types = 0x%x\n", media_types); |
| 4465 | |
Yaniv Rosner | 020c7e3 | 2011-05-31 21:28:43 +0000 | [diff] [blame] | 4466 | /* Sync AEU offset */ |
| 4467 | sync_offset = params->shmem_base + |
| 4468 | offsetof(struct shmem_region, |
| 4469 | dev_info.port_hw_config[port].aeu_int_mask); |
| 4470 | |
| 4471 | vars->aeu_int_mask = REG_RD(bp, sync_offset); |
| 4472 | |
Yaniv Rosner | b8d6d08 | 2011-07-05 01:06:27 +0000 | [diff] [blame] | 4473 | /* Sync PFC status */ |
| 4474 | if (vars->link_status & LINK_STATUS_PFC_ENABLED) |
| 4475 | params->feature_config_flags |= |
| 4476 | FEATURE_CONFIG_PFC_ENABLED; |
| 4477 | else |
| 4478 | params->feature_config_flags &= |
| 4479 | ~FEATURE_CONFIG_PFC_ENABLED; |
| 4480 | |
Yaniv Rosner | 020c7e3 | 2011-05-31 21:28:43 +0000 | [diff] [blame] | 4481 | DP(NETIF_MSG_LINK, "link_status 0x%x phy_link_up %x int_mask 0x%x\n", |
| 4482 | vars->link_status, vars->phy_link_up, vars->aeu_int_mask); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4483 | DP(NETIF_MSG_LINK, "line_speed %x duplex %x flow_ctrl 0x%x\n", |
| 4484 | vars->line_speed, vars->duplex, vars->flow_ctrl); |
| 4485 | } |
| 4486 | |
| 4487 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 4488 | static void bnx2x_set_master_ln(struct link_params *params, |
| 4489 | struct bnx2x_phy *phy) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4490 | { |
| 4491 | struct bnx2x *bp = params->bp; |
| 4492 | u16 new_master_ln, ser_lane; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4493 | ser_lane = ((params->lane_config & |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4494 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_MASK) >> |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4495 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_SHIFT); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4496 | |
| 4497 | /* set the master_ln for AN */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4498 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4499 | MDIO_REG_BANK_XGXS_BLOCK2, |
| 4500 | MDIO_XGXS_BLOCK2_TEST_MODE_LANE, |
| 4501 | &new_master_ln); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4502 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4503 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4504 | MDIO_REG_BANK_XGXS_BLOCK2 , |
| 4505 | MDIO_XGXS_BLOCK2_TEST_MODE_LANE, |
| 4506 | (new_master_ln | ser_lane)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4507 | } |
| 4508 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 4509 | static int bnx2x_reset_unicore(struct link_params *params, |
| 4510 | struct bnx2x_phy *phy, |
| 4511 | u8 set_serdes) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4512 | { |
| 4513 | struct bnx2x *bp = params->bp; |
| 4514 | u16 mii_control; |
| 4515 | u16 i; |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4516 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4517 | MDIO_REG_BANK_COMBO_IEEE0, |
| 4518 | MDIO_COMBO_IEEE0_MII_CONTROL, &mii_control); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4519 | |
| 4520 | /* reset the unicore */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4521 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4522 | MDIO_REG_BANK_COMBO_IEEE0, |
| 4523 | MDIO_COMBO_IEEE0_MII_CONTROL, |
| 4524 | (mii_control | |
| 4525 | MDIO_COMBO_IEEO_MII_CONTROL_RESET)); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 4526 | if (set_serdes) |
| 4527 | bnx2x_set_serdes_access(bp, params->port); |
Eilon Greenstein | c1b7399 | 2009-02-12 08:37:07 +0000 | [diff] [blame] | 4528 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4529 | /* wait for the reset to self clear */ |
| 4530 | for (i = 0; i < MDIO_ACCESS_TIMEOUT; i++) { |
| 4531 | udelay(5); |
| 4532 | |
| 4533 | /* the reset erased the previous bank value */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4534 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4535 | MDIO_REG_BANK_COMBO_IEEE0, |
| 4536 | MDIO_COMBO_IEEE0_MII_CONTROL, |
| 4537 | &mii_control); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4538 | |
| 4539 | if (!(mii_control & MDIO_COMBO_IEEO_MII_CONTROL_RESET)) { |
| 4540 | udelay(5); |
| 4541 | return 0; |
| 4542 | } |
| 4543 | } |
| 4544 | |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 4545 | netdev_err(bp->dev, "Warning: PHY was not initialized," |
| 4546 | " Port %d\n", |
| 4547 | params->port); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4548 | DP(NETIF_MSG_LINK, "BUG! XGXS is still in reset!\n"); |
| 4549 | return -EINVAL; |
| 4550 | |
| 4551 | } |
| 4552 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 4553 | static void bnx2x_set_swap_lanes(struct link_params *params, |
| 4554 | struct bnx2x_phy *phy) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4555 | { |
| 4556 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 4557 | /* |
| 4558 | * Each two bits represents a lane number: |
| 4559 | * No swap is 0123 => 0x1b no need to enable the swap |
| 4560 | */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4561 | u16 ser_lane, rx_lane_swap, tx_lane_swap; |
| 4562 | |
| 4563 | ser_lane = ((params->lane_config & |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4564 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_MASK) >> |
| 4565 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_SHIFT); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4566 | rx_lane_swap = ((params->lane_config & |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4567 | PORT_HW_CFG_LANE_SWAP_CFG_RX_MASK) >> |
| 4568 | PORT_HW_CFG_LANE_SWAP_CFG_RX_SHIFT); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4569 | tx_lane_swap = ((params->lane_config & |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4570 | PORT_HW_CFG_LANE_SWAP_CFG_TX_MASK) >> |
| 4571 | PORT_HW_CFG_LANE_SWAP_CFG_TX_SHIFT); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4572 | |
| 4573 | if (rx_lane_swap != 0x1b) { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4574 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4575 | MDIO_REG_BANK_XGXS_BLOCK2, |
| 4576 | MDIO_XGXS_BLOCK2_RX_LN_SWAP, |
| 4577 | (rx_lane_swap | |
| 4578 | MDIO_XGXS_BLOCK2_RX_LN_SWAP_ENABLE | |
| 4579 | MDIO_XGXS_BLOCK2_RX_LN_SWAP_FORCE_ENABLE)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4580 | } else { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4581 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4582 | MDIO_REG_BANK_XGXS_BLOCK2, |
| 4583 | MDIO_XGXS_BLOCK2_RX_LN_SWAP, 0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4584 | } |
| 4585 | |
| 4586 | if (tx_lane_swap != 0x1b) { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4587 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4588 | MDIO_REG_BANK_XGXS_BLOCK2, |
| 4589 | MDIO_XGXS_BLOCK2_TX_LN_SWAP, |
| 4590 | (tx_lane_swap | |
| 4591 | MDIO_XGXS_BLOCK2_TX_LN_SWAP_ENABLE)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4592 | } else { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4593 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4594 | MDIO_REG_BANK_XGXS_BLOCK2, |
| 4595 | MDIO_XGXS_BLOCK2_TX_LN_SWAP, 0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4596 | } |
| 4597 | } |
| 4598 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 4599 | static void bnx2x_set_parallel_detection(struct bnx2x_phy *phy, |
| 4600 | struct link_params *params) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4601 | { |
| 4602 | struct bnx2x *bp = params->bp; |
| 4603 | u16 control2; |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4604 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4605 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 4606 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL2, |
| 4607 | &control2); |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 4608 | if (phy->speed_cap_mask & PORT_HW_CFG_SPEED_CAPABILITY_D0_1G) |
Yaniv Rosner | 18afb0a | 2009-11-05 19:18:04 +0200 | [diff] [blame] | 4609 | control2 |= MDIO_SERDES_DIGITAL_A_1000X_CONTROL2_PRL_DT_EN; |
| 4610 | else |
| 4611 | control2 &= ~MDIO_SERDES_DIGITAL_A_1000X_CONTROL2_PRL_DT_EN; |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 4612 | DP(NETIF_MSG_LINK, "phy->speed_cap_mask = 0x%x, control2 = 0x%x\n", |
| 4613 | phy->speed_cap_mask, control2); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4614 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4615 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 4616 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL2, |
| 4617 | control2); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4618 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 4619 | if ((phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT) && |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 4620 | (phy->speed_cap_mask & |
Yaniv Rosner | 18afb0a | 2009-11-05 19:18:04 +0200 | [diff] [blame] | 4621 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G)) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4622 | DP(NETIF_MSG_LINK, "XGXS\n"); |
| 4623 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4624 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4625 | MDIO_REG_BANK_10G_PARALLEL_DETECT, |
| 4626 | MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_LINK, |
| 4627 | MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_LINK_CNT); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4628 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4629 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4630 | MDIO_REG_BANK_10G_PARALLEL_DETECT, |
| 4631 | MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_CONTROL, |
| 4632 | &control2); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4633 | |
| 4634 | |
| 4635 | control2 |= |
| 4636 | MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_CONTROL_PARDET10G_EN; |
| 4637 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4638 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4639 | MDIO_REG_BANK_10G_PARALLEL_DETECT, |
| 4640 | MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_CONTROL, |
| 4641 | control2); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4642 | |
| 4643 | /* Disable parallel detection of HiG */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4644 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4645 | MDIO_REG_BANK_XGXS_BLOCK2, |
| 4646 | MDIO_XGXS_BLOCK2_UNICORE_MODE_10G, |
| 4647 | MDIO_XGXS_BLOCK2_UNICORE_MODE_10G_CX4_XGXS | |
| 4648 | MDIO_XGXS_BLOCK2_UNICORE_MODE_10G_HIGIG_XGXS); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4649 | } |
| 4650 | } |
| 4651 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 4652 | static void bnx2x_set_autoneg(struct bnx2x_phy *phy, |
| 4653 | struct link_params *params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4654 | struct link_vars *vars, |
| 4655 | u8 enable_cl73) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4656 | { |
| 4657 | struct bnx2x *bp = params->bp; |
| 4658 | u16 reg_val; |
| 4659 | |
| 4660 | /* CL37 Autoneg */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4661 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4662 | MDIO_REG_BANK_COMBO_IEEE0, |
| 4663 | MDIO_COMBO_IEEE0_MII_CONTROL, ®_val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4664 | |
| 4665 | /* CL37 Autoneg Enabled */ |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 4666 | if (vars->line_speed == SPEED_AUTO_NEG) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4667 | reg_val |= MDIO_COMBO_IEEO_MII_CONTROL_AN_EN; |
| 4668 | else /* CL37 Autoneg Disabled */ |
| 4669 | reg_val &= ~(MDIO_COMBO_IEEO_MII_CONTROL_AN_EN | |
| 4670 | MDIO_COMBO_IEEO_MII_CONTROL_RESTART_AN); |
| 4671 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4672 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4673 | MDIO_REG_BANK_COMBO_IEEE0, |
| 4674 | MDIO_COMBO_IEEE0_MII_CONTROL, reg_val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4675 | |
| 4676 | /* Enable/Disable Autodetection */ |
| 4677 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4678 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4679 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 4680 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL1, ®_val); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 4681 | reg_val &= ~(MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_SIGNAL_DETECT_EN | |
| 4682 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_INVERT_SIGNAL_DETECT); |
| 4683 | reg_val |= MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_FIBER_MODE; |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 4684 | if (vars->line_speed == SPEED_AUTO_NEG) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4685 | reg_val |= MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_AUTODET; |
| 4686 | else |
| 4687 | reg_val &= ~MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_AUTODET; |
| 4688 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4689 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4690 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 4691 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL1, reg_val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4692 | |
| 4693 | /* Enable TetonII and BAM autoneg */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4694 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4695 | MDIO_REG_BANK_BAM_NEXT_PAGE, |
| 4696 | MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL, |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4697 | ®_val); |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 4698 | if (vars->line_speed == SPEED_AUTO_NEG) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4699 | /* Enable BAM aneg Mode and TetonII aneg Mode */ |
| 4700 | reg_val |= (MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL_BAM_MODE | |
| 4701 | MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL_TETON_AN); |
| 4702 | } else { |
| 4703 | /* TetonII and BAM Autoneg Disabled */ |
| 4704 | reg_val &= ~(MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL_BAM_MODE | |
| 4705 | MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL_TETON_AN); |
| 4706 | } |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4707 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4708 | MDIO_REG_BANK_BAM_NEXT_PAGE, |
| 4709 | MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL, |
| 4710 | reg_val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4711 | |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 4712 | if (enable_cl73) { |
| 4713 | /* Enable Cl73 FSM status bits */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4714 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4715 | MDIO_REG_BANK_CL73_USERB0, |
| 4716 | MDIO_CL73_USERB0_CL73_UCTRL, |
| 4717 | 0xe); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 4718 | |
| 4719 | /* Enable BAM Station Manager*/ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4720 | CL22_WR_OVER_CL45(bp, phy, |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 4721 | MDIO_REG_BANK_CL73_USERB0, |
| 4722 | MDIO_CL73_USERB0_CL73_BAM_CTRL1, |
| 4723 | MDIO_CL73_USERB0_CL73_BAM_CTRL1_BAM_EN | |
| 4724 | MDIO_CL73_USERB0_CL73_BAM_CTRL1_BAM_STATION_MNGR_EN | |
| 4725 | MDIO_CL73_USERB0_CL73_BAM_CTRL1_BAM_NP_AFTER_BP_EN); |
| 4726 | |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 4727 | /* Advertise CL73 link speeds */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4728 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4729 | MDIO_REG_BANK_CL73_IEEEB1, |
| 4730 | MDIO_CL73_IEEEB1_AN_ADV2, |
| 4731 | ®_val); |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 4732 | if (phy->speed_cap_mask & |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 4733 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G) |
| 4734 | reg_val |= MDIO_CL73_IEEEB1_AN_ADV2_ADVR_10G_KX4; |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 4735 | if (phy->speed_cap_mask & |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 4736 | PORT_HW_CFG_SPEED_CAPABILITY_D0_1G) |
| 4737 | reg_val |= MDIO_CL73_IEEEB1_AN_ADV2_ADVR_1000M_KX; |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 4738 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4739 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4740 | MDIO_REG_BANK_CL73_IEEEB1, |
| 4741 | MDIO_CL73_IEEEB1_AN_ADV2, |
| 4742 | reg_val); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 4743 | |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 4744 | /* CL73 Autoneg Enabled */ |
| 4745 | reg_val = MDIO_CL73_IEEEB0_CL73_AN_CONTROL_AN_EN; |
| 4746 | |
| 4747 | } else /* CL73 Autoneg Disabled */ |
| 4748 | reg_val = 0; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4749 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4750 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4751 | MDIO_REG_BANK_CL73_IEEEB0, |
| 4752 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL, reg_val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4753 | } |
| 4754 | |
| 4755 | /* program SerDes, forced speed */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 4756 | static void bnx2x_program_serdes(struct bnx2x_phy *phy, |
| 4757 | struct link_params *params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4758 | struct link_vars *vars) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4759 | { |
| 4760 | struct bnx2x *bp = params->bp; |
| 4761 | u16 reg_val; |
| 4762 | |
Eilon Greenstein | 5793720 | 2009-08-12 08:23:53 +0000 | [diff] [blame] | 4763 | /* program duplex, disable autoneg and sgmii*/ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4764 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4765 | MDIO_REG_BANK_COMBO_IEEE0, |
| 4766 | MDIO_COMBO_IEEE0_MII_CONTROL, ®_val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4767 | reg_val &= ~(MDIO_COMBO_IEEO_MII_CONTROL_FULL_DUPLEX | |
Eilon Greenstein | 5793720 | 2009-08-12 08:23:53 +0000 | [diff] [blame] | 4768 | MDIO_COMBO_IEEO_MII_CONTROL_AN_EN | |
| 4769 | MDIO_COMBO_IEEO_MII_CONTROL_MAN_SGMII_SP_MASK); |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 4770 | if (phy->req_duplex == DUPLEX_FULL) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4771 | reg_val |= MDIO_COMBO_IEEO_MII_CONTROL_FULL_DUPLEX; |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4772 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4773 | MDIO_REG_BANK_COMBO_IEEE0, |
| 4774 | MDIO_COMBO_IEEE0_MII_CONTROL, reg_val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4775 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 4776 | /* |
| 4777 | * program speed |
| 4778 | * - needed only if the speed is greater than 1G (2.5G or 10G) |
| 4779 | */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4780 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4781 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 4782 | MDIO_SERDES_DIGITAL_MISC1, ®_val); |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 4783 | /* clearing the speed value before setting the right speed */ |
| 4784 | DP(NETIF_MSG_LINK, "MDIO_REG_BANK_SERDES_DIGITAL = 0x%x\n", reg_val); |
| 4785 | |
| 4786 | reg_val &= ~(MDIO_SERDES_DIGITAL_MISC1_FORCE_SPEED_MASK | |
| 4787 | MDIO_SERDES_DIGITAL_MISC1_FORCE_SPEED_SEL); |
| 4788 | |
| 4789 | if (!((vars->line_speed == SPEED_1000) || |
| 4790 | (vars->line_speed == SPEED_100) || |
| 4791 | (vars->line_speed == SPEED_10))) { |
| 4792 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4793 | reg_val |= (MDIO_SERDES_DIGITAL_MISC1_REFCLK_SEL_156_25M | |
| 4794 | MDIO_SERDES_DIGITAL_MISC1_FORCE_SPEED_SEL); |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 4795 | if (vars->line_speed == SPEED_10000) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4796 | reg_val |= |
| 4797 | MDIO_SERDES_DIGITAL_MISC1_FORCE_SPEED_10G_CX4; |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 4798 | } |
| 4799 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4800 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4801 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 4802 | MDIO_SERDES_DIGITAL_MISC1, reg_val); |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 4803 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4804 | } |
| 4805 | |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 4806 | static void bnx2x_set_brcm_cl37_advertisement(struct bnx2x_phy *phy, |
| 4807 | struct link_params *params) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4808 | { |
| 4809 | struct bnx2x *bp = params->bp; |
| 4810 | u16 val = 0; |
| 4811 | |
| 4812 | /* configure the 48 bits for BAM AN */ |
| 4813 | |
| 4814 | /* set extended capabilities */ |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 4815 | if (phy->speed_cap_mask & PORT_HW_CFG_SPEED_CAPABILITY_D0_2_5G) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4816 | val |= MDIO_OVER_1G_UP1_2_5G; |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 4817 | if (phy->speed_cap_mask & PORT_HW_CFG_SPEED_CAPABILITY_D0_10G) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4818 | val |= MDIO_OVER_1G_UP1_10G; |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4819 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4820 | MDIO_REG_BANK_OVER_1G, |
| 4821 | MDIO_OVER_1G_UP1, val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4822 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4823 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4824 | MDIO_REG_BANK_OVER_1G, |
| 4825 | MDIO_OVER_1G_UP3, 0x400); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4826 | } |
| 4827 | |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 4828 | static void bnx2x_set_ieee_aneg_advertisement(struct bnx2x_phy *phy, |
| 4829 | struct link_params *params, |
| 4830 | u16 ieee_fc) |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 4831 | { |
| 4832 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 4833 | u16 val; |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 4834 | /* for AN, we are always publishing full duplex */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4835 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4836 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4837 | MDIO_REG_BANK_COMBO_IEEE0, |
| 4838 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV, ieee_fc); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4839 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4840 | MDIO_REG_BANK_CL73_IEEEB1, |
| 4841 | MDIO_CL73_IEEEB1_AN_ADV1, &val); |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 4842 | val &= ~MDIO_CL73_IEEEB1_AN_ADV1_PAUSE_BOTH; |
| 4843 | val |= ((ieee_fc<<3) & MDIO_CL73_IEEEB1_AN_ADV1_PAUSE_MASK); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4844 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4845 | MDIO_REG_BANK_CL73_IEEEB1, |
| 4846 | MDIO_CL73_IEEEB1_AN_ADV1, val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4847 | } |
| 4848 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 4849 | static void bnx2x_restart_autoneg(struct bnx2x_phy *phy, |
| 4850 | struct link_params *params, |
| 4851 | u8 enable_cl73) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4852 | { |
| 4853 | struct bnx2x *bp = params->bp; |
Eilon Greenstein | 3a36f2e | 2009-02-12 08:37:09 +0000 | [diff] [blame] | 4854 | u16 mii_control; |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 4855 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4856 | DP(NETIF_MSG_LINK, "bnx2x_restart_autoneg\n"); |
Eilon Greenstein | 3a36f2e | 2009-02-12 08:37:09 +0000 | [diff] [blame] | 4857 | /* Enable and restart BAM/CL37 aneg */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4858 | |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 4859 | if (enable_cl73) { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4860 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4861 | MDIO_REG_BANK_CL73_IEEEB0, |
| 4862 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL, |
| 4863 | &mii_control); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 4864 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4865 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4866 | MDIO_REG_BANK_CL73_IEEEB0, |
| 4867 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL, |
| 4868 | (mii_control | |
| 4869 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL_AN_EN | |
| 4870 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL_RESTART_AN)); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 4871 | } else { |
| 4872 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4873 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4874 | MDIO_REG_BANK_COMBO_IEEE0, |
| 4875 | MDIO_COMBO_IEEE0_MII_CONTROL, |
| 4876 | &mii_control); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 4877 | DP(NETIF_MSG_LINK, |
| 4878 | "bnx2x_restart_autoneg mii_control before = 0x%x\n", |
| 4879 | mii_control); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4880 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4881 | MDIO_REG_BANK_COMBO_IEEE0, |
| 4882 | MDIO_COMBO_IEEE0_MII_CONTROL, |
| 4883 | (mii_control | |
| 4884 | MDIO_COMBO_IEEO_MII_CONTROL_AN_EN | |
| 4885 | MDIO_COMBO_IEEO_MII_CONTROL_RESTART_AN)); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 4886 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4887 | } |
| 4888 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 4889 | static void bnx2x_initialize_sgmii_process(struct bnx2x_phy *phy, |
| 4890 | struct link_params *params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4891 | struct link_vars *vars) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4892 | { |
| 4893 | struct bnx2x *bp = params->bp; |
| 4894 | u16 control1; |
| 4895 | |
| 4896 | /* in SGMII mode, the unicore is always slave */ |
| 4897 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4898 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4899 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 4900 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL1, |
| 4901 | &control1); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4902 | control1 |= MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_INVERT_SIGNAL_DETECT; |
| 4903 | /* set sgmii mode (and not fiber) */ |
| 4904 | control1 &= ~(MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_FIBER_MODE | |
| 4905 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_AUTODET | |
| 4906 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_MSTR_MODE); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4907 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4908 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 4909 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL1, |
| 4910 | control1); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4911 | |
| 4912 | /* if forced speed */ |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 4913 | if (!(vars->line_speed == SPEED_AUTO_NEG)) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4914 | /* set speed, disable autoneg */ |
| 4915 | u16 mii_control; |
| 4916 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4917 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4918 | MDIO_REG_BANK_COMBO_IEEE0, |
| 4919 | MDIO_COMBO_IEEE0_MII_CONTROL, |
| 4920 | &mii_control); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4921 | mii_control &= ~(MDIO_COMBO_IEEO_MII_CONTROL_AN_EN | |
| 4922 | MDIO_COMBO_IEEO_MII_CONTROL_MAN_SGMII_SP_MASK| |
| 4923 | MDIO_COMBO_IEEO_MII_CONTROL_FULL_DUPLEX); |
| 4924 | |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 4925 | switch (vars->line_speed) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4926 | case SPEED_100: |
| 4927 | mii_control |= |
| 4928 | MDIO_COMBO_IEEO_MII_CONTROL_MAN_SGMII_SP_100; |
| 4929 | break; |
| 4930 | case SPEED_1000: |
| 4931 | mii_control |= |
| 4932 | MDIO_COMBO_IEEO_MII_CONTROL_MAN_SGMII_SP_1000; |
| 4933 | break; |
| 4934 | case SPEED_10: |
| 4935 | /* there is nothing to set for 10M */ |
| 4936 | break; |
| 4937 | default: |
| 4938 | /* invalid speed for SGMII */ |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 4939 | DP(NETIF_MSG_LINK, "Invalid line_speed 0x%x\n", |
| 4940 | vars->line_speed); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4941 | break; |
| 4942 | } |
| 4943 | |
| 4944 | /* setting the full duplex */ |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 4945 | if (phy->req_duplex == DUPLEX_FULL) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4946 | mii_control |= |
| 4947 | MDIO_COMBO_IEEO_MII_CONTROL_FULL_DUPLEX; |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4948 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4949 | MDIO_REG_BANK_COMBO_IEEE0, |
| 4950 | MDIO_COMBO_IEEE0_MII_CONTROL, |
| 4951 | mii_control); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4952 | |
| 4953 | } else { /* AN mode */ |
| 4954 | /* enable and restart AN */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 4955 | bnx2x_restart_autoneg(phy, params, 0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4956 | } |
| 4957 | } |
| 4958 | |
| 4959 | |
| 4960 | /* |
| 4961 | * link management |
| 4962 | */ |
| 4963 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 4964 | static int bnx2x_direct_parallel_detect_used(struct bnx2x_phy *phy, |
| 4965 | struct link_params *params) |
Yaniv Rosner | 15ddd2d | 2009-11-05 19:18:12 +0200 | [diff] [blame] | 4966 | { |
| 4967 | struct bnx2x *bp = params->bp; |
| 4968 | u16 pd_10g, status2_1000x; |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 4969 | if (phy->req_line_speed != SPEED_AUTO_NEG) |
| 4970 | return 0; |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4971 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4972 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 4973 | MDIO_SERDES_DIGITAL_A_1000X_STATUS2, |
| 4974 | &status2_1000x); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4975 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4976 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 4977 | MDIO_SERDES_DIGITAL_A_1000X_STATUS2, |
| 4978 | &status2_1000x); |
Yaniv Rosner | 15ddd2d | 2009-11-05 19:18:12 +0200 | [diff] [blame] | 4979 | if (status2_1000x & MDIO_SERDES_DIGITAL_A_1000X_STATUS2_AN_DISABLED) { |
| 4980 | DP(NETIF_MSG_LINK, "1G parallel detect link on port %d\n", |
| 4981 | params->port); |
| 4982 | return 1; |
| 4983 | } |
| 4984 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4985 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4986 | MDIO_REG_BANK_10G_PARALLEL_DETECT, |
| 4987 | MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_STATUS, |
| 4988 | &pd_10g); |
Yaniv Rosner | 15ddd2d | 2009-11-05 19:18:12 +0200 | [diff] [blame] | 4989 | |
| 4990 | if (pd_10g & MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_STATUS_PD_LINK) { |
| 4991 | DP(NETIF_MSG_LINK, "10G parallel detect link on port %d\n", |
| 4992 | params->port); |
| 4993 | return 1; |
| 4994 | } |
| 4995 | return 0; |
| 4996 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4997 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 4998 | static void bnx2x_flow_ctrl_resolve(struct bnx2x_phy *phy, |
| 4999 | struct link_params *params, |
| 5000 | struct link_vars *vars, |
| 5001 | u32 gp_status) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5002 | { |
| 5003 | struct bnx2x *bp = params->bp; |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 5004 | u16 ld_pause; /* local driver */ |
| 5005 | u16 lp_pause; /* link partner */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5006 | u16 pause_result; |
| 5007 | |
David S. Miller | c0700f9 | 2008-12-16 23:53:20 -0800 | [diff] [blame] | 5008 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5009 | |
| 5010 | /* resolve from gp_status in case of AN complete and not sgmii */ |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 5011 | if (phy->req_flow_ctrl != BNX2X_FLOW_CTRL_AUTO) |
| 5012 | vars->flow_ctrl = phy->req_flow_ctrl; |
| 5013 | else if (phy->req_line_speed != SPEED_AUTO_NEG) |
| 5014 | vars->flow_ctrl = params->req_fc_auto_adv; |
| 5015 | else if ((gp_status & MDIO_AN_CL73_OR_37_COMPLETE) && |
| 5016 | (!(vars->phy_flags & PHY_SGMII_FLAG))) { |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 5017 | if (bnx2x_direct_parallel_detect_used(phy, params)) { |
Yaniv Rosner | 15ddd2d | 2009-11-05 19:18:12 +0200 | [diff] [blame] | 5018 | vars->flow_ctrl = params->req_fc_auto_adv; |
| 5019 | return; |
| 5020 | } |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 5021 | if ((gp_status & |
| 5022 | (MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_AUTONEG_COMPLETE | |
| 5023 | MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_MR_LP_NP_AN_ABLE)) == |
| 5024 | (MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_AUTONEG_COMPLETE | |
| 5025 | MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_MR_LP_NP_AN_ABLE)) { |
| 5026 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5027 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5028 | MDIO_REG_BANK_CL73_IEEEB1, |
| 5029 | MDIO_CL73_IEEEB1_AN_ADV1, |
| 5030 | &ld_pause); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5031 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5032 | MDIO_REG_BANK_CL73_IEEEB1, |
| 5033 | MDIO_CL73_IEEEB1_AN_LP_ADV1, |
| 5034 | &lp_pause); |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 5035 | pause_result = (ld_pause & |
| 5036 | MDIO_CL73_IEEEB1_AN_ADV1_PAUSE_MASK) |
| 5037 | >> 8; |
| 5038 | pause_result |= (lp_pause & |
| 5039 | MDIO_CL73_IEEEB1_AN_LP_ADV1_PAUSE_MASK) |
| 5040 | >> 10; |
| 5041 | DP(NETIF_MSG_LINK, "pause_result CL73 0x%x\n", |
| 5042 | pause_result); |
| 5043 | } else { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5044 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5045 | MDIO_REG_BANK_COMBO_IEEE0, |
| 5046 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV, |
| 5047 | &ld_pause); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5048 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5049 | MDIO_REG_BANK_COMBO_IEEE0, |
| 5050 | MDIO_COMBO_IEEE0_AUTO_NEG_LINK_PARTNER_ABILITY1, |
| 5051 | &lp_pause); |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 5052 | pause_result = (ld_pause & |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5053 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_MASK)>>5; |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 5054 | pause_result |= (lp_pause & |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5055 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_MASK)>>7; |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 5056 | DP(NETIF_MSG_LINK, "pause_result CL37 0x%x\n", |
| 5057 | pause_result); |
| 5058 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5059 | bnx2x_pause_resolve(vars, pause_result); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5060 | } |
| 5061 | DP(NETIF_MSG_LINK, "flow_ctrl 0x%x\n", vars->flow_ctrl); |
| 5062 | } |
| 5063 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 5064 | static void bnx2x_check_fallback_to_cl37(struct bnx2x_phy *phy, |
| 5065 | struct link_params *params) |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5066 | { |
| 5067 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 5068 | u16 rx_status, ustat_val, cl37_fsm_received; |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5069 | DP(NETIF_MSG_LINK, "bnx2x_check_fallback_to_cl37\n"); |
| 5070 | /* Step 1: Make sure signal is detected */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5071 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5072 | MDIO_REG_BANK_RX0, |
| 5073 | MDIO_RX0_RX_STATUS, |
| 5074 | &rx_status); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5075 | if ((rx_status & MDIO_RX0_RX_STATUS_SIGDET) != |
| 5076 | (MDIO_RX0_RX_STATUS_SIGDET)) { |
| 5077 | DP(NETIF_MSG_LINK, "Signal is not detected. Restoring CL73." |
| 5078 | "rx_status(0x80b0) = 0x%x\n", rx_status); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5079 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5080 | MDIO_REG_BANK_CL73_IEEEB0, |
| 5081 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL, |
| 5082 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL_AN_EN); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5083 | return; |
| 5084 | } |
| 5085 | /* Step 2: Check CL73 state machine */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5086 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5087 | MDIO_REG_BANK_CL73_USERB0, |
| 5088 | MDIO_CL73_USERB0_CL73_USTAT1, |
| 5089 | &ustat_val); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5090 | if ((ustat_val & |
| 5091 | (MDIO_CL73_USERB0_CL73_USTAT1_LINK_STATUS_CHECK | |
| 5092 | MDIO_CL73_USERB0_CL73_USTAT1_AN_GOOD_CHECK_BAM37)) != |
| 5093 | (MDIO_CL73_USERB0_CL73_USTAT1_LINK_STATUS_CHECK | |
| 5094 | MDIO_CL73_USERB0_CL73_USTAT1_AN_GOOD_CHECK_BAM37)) { |
| 5095 | DP(NETIF_MSG_LINK, "CL73 state-machine is not stable. " |
| 5096 | "ustat_val(0x8371) = 0x%x\n", ustat_val); |
| 5097 | return; |
| 5098 | } |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5099 | /* |
| 5100 | * Step 3: Check CL37 Message Pages received to indicate LP |
| 5101 | * supports only CL37 |
| 5102 | */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5103 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5104 | MDIO_REG_BANK_REMOTE_PHY, |
| 5105 | MDIO_REMOTE_PHY_MISC_RX_STATUS, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 5106 | &cl37_fsm_received); |
| 5107 | if ((cl37_fsm_received & |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5108 | (MDIO_REMOTE_PHY_MISC_RX_STATUS_CL37_FSM_RECEIVED_OVER1G_MSG | |
| 5109 | MDIO_REMOTE_PHY_MISC_RX_STATUS_CL37_FSM_RECEIVED_BRCM_OUI_MSG)) != |
| 5110 | (MDIO_REMOTE_PHY_MISC_RX_STATUS_CL37_FSM_RECEIVED_OVER1G_MSG | |
| 5111 | MDIO_REMOTE_PHY_MISC_RX_STATUS_CL37_FSM_RECEIVED_BRCM_OUI_MSG)) { |
| 5112 | DP(NETIF_MSG_LINK, "No CL37 FSM were received. " |
| 5113 | "misc_rx_status(0x8330) = 0x%x\n", |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 5114 | cl37_fsm_received); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5115 | return; |
| 5116 | } |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5117 | /* |
| 5118 | * The combined cl37/cl73 fsm state information indicating that |
| 5119 | * we are connected to a device which does not support cl73, but |
| 5120 | * does support cl37 BAM. In this case we disable cl73 and |
| 5121 | * restart cl37 auto-neg |
| 5122 | */ |
| 5123 | |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5124 | /* Disable CL73 */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5125 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5126 | MDIO_REG_BANK_CL73_IEEEB0, |
| 5127 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL, |
| 5128 | 0); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5129 | /* Restart CL37 autoneg */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 5130 | bnx2x_restart_autoneg(phy, params, 0); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5131 | DP(NETIF_MSG_LINK, "Disabling CL73, and restarting CL37 autoneg\n"); |
| 5132 | } |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 5133 | |
| 5134 | static void bnx2x_xgxs_an_resolve(struct bnx2x_phy *phy, |
| 5135 | struct link_params *params, |
| 5136 | struct link_vars *vars, |
| 5137 | u32 gp_status) |
| 5138 | { |
| 5139 | if (gp_status & MDIO_AN_CL73_OR_37_COMPLETE) |
| 5140 | vars->link_status |= |
| 5141 | LINK_STATUS_AUTO_NEGOTIATE_COMPLETE; |
| 5142 | |
| 5143 | if (bnx2x_direct_parallel_detect_used(phy, params)) |
| 5144 | vars->link_status |= |
| 5145 | LINK_STATUS_PARALLEL_DETECTION_USED; |
| 5146 | } |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5147 | static int bnx2x_get_link_speed_duplex(struct bnx2x_phy *phy, |
| 5148 | struct link_params *params, |
| 5149 | struct link_vars *vars, |
| 5150 | u16 is_link_up, |
| 5151 | u16 speed_mask, |
| 5152 | u16 is_duplex) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5153 | { |
| 5154 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 5155 | if (phy->req_line_speed == SPEED_AUTO_NEG) |
| 5156 | vars->link_status |= LINK_STATUS_AUTO_NEGOTIATE_ENABLED; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5157 | if (is_link_up) { |
| 5158 | DP(NETIF_MSG_LINK, "phy link up\n"); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5159 | |
| 5160 | vars->phy_link_up = 1; |
| 5161 | vars->link_status |= LINK_STATUS_LINK_UP; |
| 5162 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5163 | switch (speed_mask) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5164 | case GP_STATUS_10M: |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5165 | vars->line_speed = SPEED_10; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5166 | if (vars->duplex == DUPLEX_FULL) |
| 5167 | vars->link_status |= LINK_10TFD; |
| 5168 | else |
| 5169 | vars->link_status |= LINK_10THD; |
| 5170 | break; |
| 5171 | |
| 5172 | case GP_STATUS_100M: |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5173 | vars->line_speed = SPEED_100; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5174 | if (vars->duplex == DUPLEX_FULL) |
| 5175 | vars->link_status |= LINK_100TXFD; |
| 5176 | else |
| 5177 | vars->link_status |= LINK_100TXHD; |
| 5178 | break; |
| 5179 | |
| 5180 | case GP_STATUS_1G: |
| 5181 | case GP_STATUS_1G_KX: |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5182 | vars->line_speed = SPEED_1000; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5183 | if (vars->duplex == DUPLEX_FULL) |
| 5184 | vars->link_status |= LINK_1000TFD; |
| 5185 | else |
| 5186 | vars->link_status |= LINK_1000THD; |
| 5187 | break; |
| 5188 | |
| 5189 | case GP_STATUS_2_5G: |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5190 | vars->line_speed = SPEED_2500; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5191 | if (vars->duplex == DUPLEX_FULL) |
| 5192 | vars->link_status |= LINK_2500TFD; |
| 5193 | else |
| 5194 | vars->link_status |= LINK_2500THD; |
| 5195 | break; |
| 5196 | |
| 5197 | case GP_STATUS_5G: |
| 5198 | case GP_STATUS_6G: |
| 5199 | DP(NETIF_MSG_LINK, |
| 5200 | "link speed unsupported gp_status 0x%x\n", |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5201 | speed_mask); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5202 | return -EINVAL; |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 5203 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5204 | case GP_STATUS_10G_KX4: |
| 5205 | case GP_STATUS_10G_HIG: |
| 5206 | case GP_STATUS_10G_CX4: |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5207 | case GP_STATUS_10G_KR: |
| 5208 | case GP_STATUS_10G_SFI: |
| 5209 | case GP_STATUS_10G_XFI: |
| 5210 | vars->line_speed = SPEED_10000; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5211 | vars->link_status |= LINK_10GTFD; |
| 5212 | break; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5213 | case GP_STATUS_20G_DXGXS: |
| 5214 | vars->line_speed = SPEED_20000; |
| 5215 | vars->link_status |= LINK_20GTFD; |
| 5216 | break; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5217 | default: |
| 5218 | DP(NETIF_MSG_LINK, |
| 5219 | "link speed unsupported gp_status 0x%x\n", |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5220 | speed_mask); |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 5221 | return -EINVAL; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5222 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5223 | } else { /* link_down */ |
| 5224 | DP(NETIF_MSG_LINK, "phy link down\n"); |
| 5225 | |
| 5226 | vars->phy_link_up = 0; |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 5227 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5228 | vars->duplex = DUPLEX_FULL; |
David S. Miller | c0700f9 | 2008-12-16 23:53:20 -0800 | [diff] [blame] | 5229 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5230 | vars->mac_type = MAC_TYPE_NONE; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5231 | } |
| 5232 | DP(NETIF_MSG_LINK, " phy_link_up %x line_speed %d\n", |
| 5233 | vars->phy_link_up, vars->line_speed); |
| 5234 | return 0; |
| 5235 | } |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5236 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5237 | static int bnx2x_link_settings_status(struct bnx2x_phy *phy, |
| 5238 | struct link_params *params, |
| 5239 | struct link_vars *vars) |
| 5240 | { |
| 5241 | |
| 5242 | struct bnx2x *bp = params->bp; |
| 5243 | |
| 5244 | u16 gp_status, duplex = DUPLEX_HALF, link_up = 0, speed_mask; |
| 5245 | int rc = 0; |
| 5246 | |
| 5247 | /* Read gp_status */ |
| 5248 | CL22_RD_OVER_CL45(bp, phy, |
| 5249 | MDIO_REG_BANK_GP_STATUS, |
| 5250 | MDIO_GP_STATUS_TOP_AN_STATUS1, |
| 5251 | &gp_status); |
| 5252 | if (gp_status & MDIO_GP_STATUS_TOP_AN_STATUS1_DUPLEX_STATUS) |
| 5253 | duplex = DUPLEX_FULL; |
| 5254 | if (gp_status & MDIO_GP_STATUS_TOP_AN_STATUS1_LINK_STATUS) |
| 5255 | link_up = 1; |
| 5256 | speed_mask = gp_status & GP_STATUS_SPEED_MASK; |
| 5257 | DP(NETIF_MSG_LINK, "gp_status 0x%x, is_link_up %d, speed_mask 0x%x\n", |
| 5258 | gp_status, link_up, speed_mask); |
| 5259 | rc = bnx2x_get_link_speed_duplex(phy, params, vars, link_up, speed_mask, |
| 5260 | duplex); |
| 5261 | if (rc == -EINVAL) |
| 5262 | return rc; |
| 5263 | |
| 5264 | if (gp_status & MDIO_GP_STATUS_TOP_AN_STATUS1_LINK_STATUS) { |
| 5265 | if (SINGLE_MEDIA_DIRECT(params)) { |
| 5266 | bnx2x_flow_ctrl_resolve(phy, params, vars, gp_status); |
| 5267 | if (phy->req_line_speed == SPEED_AUTO_NEG) |
| 5268 | bnx2x_xgxs_an_resolve(phy, params, vars, |
| 5269 | gp_status); |
| 5270 | } |
| 5271 | } else { /* link_down */ |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 5272 | if ((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 5273 | SINGLE_MEDIA_DIRECT(params)) { |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5274 | /* Check signal is detected */ |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 5275 | bnx2x_check_fallback_to_cl37(phy, params); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5276 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5277 | } |
| 5278 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5279 | DP(NETIF_MSG_LINK, "duplex %x flow_ctrl 0x%x link_status 0x%x\n", |
| 5280 | vars->duplex, vars->flow_ctrl, vars->link_status); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5281 | return rc; |
| 5282 | } |
| 5283 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5284 | static int bnx2x_warpcore_read_status(struct bnx2x_phy *phy, |
| 5285 | struct link_params *params, |
| 5286 | struct link_vars *vars) |
| 5287 | { |
| 5288 | |
| 5289 | struct bnx2x *bp = params->bp; |
| 5290 | |
| 5291 | u8 lane; |
| 5292 | u16 gp_status1, gp_speed, link_up, duplex = DUPLEX_FULL; |
| 5293 | int rc = 0; |
| 5294 | lane = bnx2x_get_warpcore_lane(phy, params); |
| 5295 | /* Read gp_status */ |
| 5296 | if (phy->req_line_speed > SPEED_10000) { |
| 5297 | u16 temp_link_up; |
| 5298 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 5299 | 1, &temp_link_up); |
| 5300 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 5301 | 1, &link_up); |
| 5302 | DP(NETIF_MSG_LINK, "PCS RX link status = 0x%x-->0x%x\n", |
| 5303 | temp_link_up, link_up); |
| 5304 | link_up &= (1<<2); |
| 5305 | if (link_up) |
| 5306 | bnx2x_ext_phy_resolve_fc(phy, params, vars); |
| 5307 | } else { |
| 5308 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 5309 | MDIO_WC_REG_GP2_STATUS_GP_2_1, &gp_status1); |
| 5310 | DP(NETIF_MSG_LINK, "0x81d1 = 0x%x\n", gp_status1); |
| 5311 | /* Check for either KR or generic link up. */ |
| 5312 | gp_status1 = ((gp_status1 >> 8) & 0xf) | |
| 5313 | ((gp_status1 >> 12) & 0xf); |
| 5314 | link_up = gp_status1 & (1 << lane); |
| 5315 | if (link_up && SINGLE_MEDIA_DIRECT(params)) { |
| 5316 | u16 pd, gp_status4; |
| 5317 | if (phy->req_line_speed == SPEED_AUTO_NEG) { |
| 5318 | /* Check Autoneg complete */ |
| 5319 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 5320 | MDIO_WC_REG_GP2_STATUS_GP_2_4, |
| 5321 | &gp_status4); |
| 5322 | if (gp_status4 & ((1<<12)<<lane)) |
| 5323 | vars->link_status |= |
| 5324 | LINK_STATUS_AUTO_NEGOTIATE_COMPLETE; |
| 5325 | |
| 5326 | /* Check parallel detect used */ |
| 5327 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 5328 | MDIO_WC_REG_PAR_DET_10G_STATUS, |
| 5329 | &pd); |
| 5330 | if (pd & (1<<15)) |
| 5331 | vars->link_status |= |
| 5332 | LINK_STATUS_PARALLEL_DETECTION_USED; |
| 5333 | } |
| 5334 | bnx2x_ext_phy_resolve_fc(phy, params, vars); |
| 5335 | } |
| 5336 | } |
| 5337 | |
| 5338 | if (lane < 2) { |
| 5339 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 5340 | MDIO_WC_REG_GP2_STATUS_GP_2_2, &gp_speed); |
| 5341 | } else { |
| 5342 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 5343 | MDIO_WC_REG_GP2_STATUS_GP_2_3, &gp_speed); |
| 5344 | } |
| 5345 | DP(NETIF_MSG_LINK, "lane %d gp_speed 0x%x\n", lane, gp_speed); |
| 5346 | |
| 5347 | if ((lane & 1) == 0) |
| 5348 | gp_speed <<= 8; |
| 5349 | gp_speed &= 0x3f00; |
| 5350 | |
| 5351 | |
| 5352 | rc = bnx2x_get_link_speed_duplex(phy, params, vars, link_up, gp_speed, |
| 5353 | duplex); |
| 5354 | |
| 5355 | DP(NETIF_MSG_LINK, "duplex %x flow_ctrl 0x%x link_status 0x%x\n", |
| 5356 | vars->duplex, vars->flow_ctrl, vars->link_status); |
| 5357 | return rc; |
| 5358 | } |
Eilon Greenstein | ed8680a | 2009-02-12 08:37:12 +0000 | [diff] [blame] | 5359 | static void bnx2x_set_gmii_tx_driver(struct link_params *params) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5360 | { |
| 5361 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 5362 | struct bnx2x_phy *phy = ¶ms->phy[INT_PHY]; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5363 | u16 lp_up2; |
| 5364 | u16 tx_driver; |
Eilon Greenstein | c2c8b03 | 2009-02-12 08:37:14 +0000 | [diff] [blame] | 5365 | u16 bank; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5366 | |
| 5367 | /* read precomp */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5368 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5369 | MDIO_REG_BANK_OVER_1G, |
| 5370 | MDIO_OVER_1G_LP_UP2, &lp_up2); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5371 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5372 | /* bits [10:7] at lp_up2, positioned at [15:12] */ |
| 5373 | lp_up2 = (((lp_up2 & MDIO_OVER_1G_LP_UP2_PREEMPHASIS_MASK) >> |
| 5374 | MDIO_OVER_1G_LP_UP2_PREEMPHASIS_SHIFT) << |
| 5375 | MDIO_TX0_TX_DRIVER_PREEMPHASIS_SHIFT); |
| 5376 | |
Eilon Greenstein | c2c8b03 | 2009-02-12 08:37:14 +0000 | [diff] [blame] | 5377 | if (lp_up2 == 0) |
| 5378 | return; |
| 5379 | |
| 5380 | for (bank = MDIO_REG_BANK_TX0; bank <= MDIO_REG_BANK_TX3; |
| 5381 | bank += (MDIO_REG_BANK_TX1 - MDIO_REG_BANK_TX0)) { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5382 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5383 | bank, |
| 5384 | MDIO_TX0_TX_DRIVER, &tx_driver); |
Eilon Greenstein | c2c8b03 | 2009-02-12 08:37:14 +0000 | [diff] [blame] | 5385 | |
| 5386 | /* replace tx_driver bits [15:12] */ |
| 5387 | if (lp_up2 != |
| 5388 | (tx_driver & MDIO_TX0_TX_DRIVER_PREEMPHASIS_MASK)) { |
| 5389 | tx_driver &= ~MDIO_TX0_TX_DRIVER_PREEMPHASIS_MASK; |
| 5390 | tx_driver |= lp_up2; |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5391 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5392 | bank, |
| 5393 | MDIO_TX0_TX_DRIVER, tx_driver); |
Eilon Greenstein | c2c8b03 | 2009-02-12 08:37:14 +0000 | [diff] [blame] | 5394 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5395 | } |
| 5396 | } |
| 5397 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 5398 | static int bnx2x_emac_program(struct link_params *params, |
| 5399 | struct link_vars *vars) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5400 | { |
| 5401 | struct bnx2x *bp = params->bp; |
| 5402 | u8 port = params->port; |
| 5403 | u16 mode = 0; |
| 5404 | |
| 5405 | DP(NETIF_MSG_LINK, "setting link speed & duplex\n"); |
| 5406 | bnx2x_bits_dis(bp, GRCBASE_EMAC0 + port*0x400 + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5407 | EMAC_REG_EMAC_MODE, |
| 5408 | (EMAC_MODE_25G_MODE | |
| 5409 | EMAC_MODE_PORT_MII_10M | |
| 5410 | EMAC_MODE_HALF_DUPLEX)); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 5411 | switch (vars->line_speed) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5412 | case SPEED_10: |
| 5413 | mode |= EMAC_MODE_PORT_MII_10M; |
| 5414 | break; |
| 5415 | |
| 5416 | case SPEED_100: |
| 5417 | mode |= EMAC_MODE_PORT_MII; |
| 5418 | break; |
| 5419 | |
| 5420 | case SPEED_1000: |
| 5421 | mode |= EMAC_MODE_PORT_GMII; |
| 5422 | break; |
| 5423 | |
| 5424 | case SPEED_2500: |
| 5425 | mode |= (EMAC_MODE_25G_MODE | EMAC_MODE_PORT_GMII); |
| 5426 | break; |
| 5427 | |
| 5428 | default: |
| 5429 | /* 10G not valid for EMAC */ |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 5430 | DP(NETIF_MSG_LINK, "Invalid line_speed 0x%x\n", |
| 5431 | vars->line_speed); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5432 | return -EINVAL; |
| 5433 | } |
| 5434 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 5435 | if (vars->duplex == DUPLEX_HALF) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5436 | mode |= EMAC_MODE_HALF_DUPLEX; |
| 5437 | bnx2x_bits_en(bp, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5438 | GRCBASE_EMAC0 + port*0x400 + EMAC_REG_EMAC_MODE, |
| 5439 | mode); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5440 | |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 5441 | bnx2x_set_led(params, vars, LED_MODE_OPER, vars->line_speed); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5442 | return 0; |
| 5443 | } |
| 5444 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5445 | static void bnx2x_set_preemphasis(struct bnx2x_phy *phy, |
| 5446 | struct link_params *params) |
| 5447 | { |
| 5448 | |
| 5449 | u16 bank, i = 0; |
| 5450 | struct bnx2x *bp = params->bp; |
| 5451 | |
| 5452 | for (bank = MDIO_REG_BANK_RX0, i = 0; bank <= MDIO_REG_BANK_RX3; |
| 5453 | bank += (MDIO_REG_BANK_RX1-MDIO_REG_BANK_RX0), i++) { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5454 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5455 | bank, |
| 5456 | MDIO_RX0_RX_EQ_BOOST, |
| 5457 | phy->rx_preemphasis[i]); |
| 5458 | } |
| 5459 | |
| 5460 | for (bank = MDIO_REG_BANK_TX0, i = 0; bank <= MDIO_REG_BANK_TX3; |
| 5461 | bank += (MDIO_REG_BANK_TX1 - MDIO_REG_BANK_TX0), i++) { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5462 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5463 | bank, |
| 5464 | MDIO_TX0_TX_DRIVER, |
| 5465 | phy->tx_preemphasis[i]); |
| 5466 | } |
| 5467 | } |
| 5468 | |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 5469 | static void bnx2x_xgxs_config_init(struct bnx2x_phy *phy, |
| 5470 | struct link_params *params, |
| 5471 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5472 | { |
| 5473 | struct bnx2x *bp = params->bp; |
| 5474 | u8 enable_cl73 = (SINGLE_MEDIA_DIRECT(params) || |
| 5475 | (params->loopback_mode == LOOPBACK_XGXS)); |
| 5476 | if (!(vars->phy_flags & PHY_SGMII_FLAG)) { |
| 5477 | if (SINGLE_MEDIA_DIRECT(params) && |
| 5478 | (params->feature_config_flags & |
| 5479 | FEATURE_CONFIG_OVERRIDE_PREEMPHASIS_ENABLED)) |
| 5480 | bnx2x_set_preemphasis(phy, params); |
| 5481 | |
| 5482 | /* forced speed requested? */ |
| 5483 | if (vars->line_speed != SPEED_AUTO_NEG || |
| 5484 | (SINGLE_MEDIA_DIRECT(params) && |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5485 | params->loopback_mode == LOOPBACK_EXT)) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5486 | DP(NETIF_MSG_LINK, "not SGMII, no AN\n"); |
| 5487 | |
| 5488 | /* disable autoneg */ |
| 5489 | bnx2x_set_autoneg(phy, params, vars, 0); |
| 5490 | |
| 5491 | /* program speed and duplex */ |
| 5492 | bnx2x_program_serdes(phy, params, vars); |
| 5493 | |
| 5494 | } else { /* AN_mode */ |
| 5495 | DP(NETIF_MSG_LINK, "not SGMII, AN\n"); |
| 5496 | |
| 5497 | /* AN enabled */ |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 5498 | bnx2x_set_brcm_cl37_advertisement(phy, params); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5499 | |
| 5500 | /* program duplex & pause advertisement (for aneg) */ |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 5501 | bnx2x_set_ieee_aneg_advertisement(phy, params, |
| 5502 | vars->ieee_fc); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5503 | |
| 5504 | /* enable autoneg */ |
| 5505 | bnx2x_set_autoneg(phy, params, vars, enable_cl73); |
| 5506 | |
| 5507 | /* enable and restart AN */ |
| 5508 | bnx2x_restart_autoneg(phy, params, enable_cl73); |
| 5509 | } |
| 5510 | |
| 5511 | } else { /* SGMII mode */ |
| 5512 | DP(NETIF_MSG_LINK, "SGMII\n"); |
| 5513 | |
| 5514 | bnx2x_initialize_sgmii_process(phy, params, vars); |
| 5515 | } |
| 5516 | } |
| 5517 | |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 5518 | static int bnx2x_prepare_xgxs(struct bnx2x_phy *phy, |
| 5519 | struct link_params *params, |
| 5520 | struct link_vars *vars) |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 5521 | { |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 5522 | int rc; |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 5523 | vars->phy_flags |= PHY_XGXS_FLAG; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 5524 | if ((phy->req_line_speed && |
| 5525 | ((phy->req_line_speed == SPEED_100) || |
| 5526 | (phy->req_line_speed == SPEED_10))) || |
| 5527 | (!phy->req_line_speed && |
| 5528 | (phy->speed_cap_mask >= |
| 5529 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_FULL) && |
| 5530 | (phy->speed_cap_mask < |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 5531 | PORT_HW_CFG_SPEED_CAPABILITY_D0_1G)) || |
| 5532 | (phy->type == PORT_HW_CFG_SERDES_EXT_PHY_TYPE_DIRECT_SD)) |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 5533 | vars->phy_flags |= PHY_SGMII_FLAG; |
| 5534 | else |
| 5535 | vars->phy_flags &= ~PHY_SGMII_FLAG; |
| 5536 | |
| 5537 | bnx2x_calc_ieee_aneg_adv(phy, params, &vars->ieee_fc); |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 5538 | bnx2x_set_aer_mmd(params, phy); |
| 5539 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT) |
| 5540 | bnx2x_set_master_ln(params, phy); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 5541 | |
| 5542 | rc = bnx2x_reset_unicore(params, phy, 0); |
| 5543 | /* reset the SerDes and wait for reset bit return low */ |
| 5544 | if (rc != 0) |
| 5545 | return rc; |
| 5546 | |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 5547 | bnx2x_set_aer_mmd(params, phy); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 5548 | /* setting the masterLn_def again after the reset */ |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 5549 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT) { |
| 5550 | bnx2x_set_master_ln(params, phy); |
| 5551 | bnx2x_set_swap_lanes(params, phy); |
| 5552 | } |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 5553 | |
| 5554 | return rc; |
| 5555 | } |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 5556 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 5557 | static u16 bnx2x_wait_reset_complete(struct bnx2x *bp, |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 5558 | struct bnx2x_phy *phy, |
| 5559 | struct link_params *params) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5560 | { |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 5561 | u16 cnt, ctrl; |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 5562 | /* Wait for soft reset to get cleared up to 1 sec */ |
Yaniv Rosner | 62b29a5 | 2010-09-07 11:40:58 +0000 | [diff] [blame] | 5563 | for (cnt = 0; cnt < 1000; cnt++) { |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 5564 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54618SE) |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 5565 | bnx2x_cl22_read(bp, phy, |
| 5566 | MDIO_PMA_REG_CTRL, &ctrl); |
| 5567 | else |
| 5568 | bnx2x_cl45_read(bp, phy, |
| 5569 | MDIO_PMA_DEVAD, |
| 5570 | MDIO_PMA_REG_CTRL, &ctrl); |
Yaniv Rosner | 62b29a5 | 2010-09-07 11:40:58 +0000 | [diff] [blame] | 5571 | if (!(ctrl & (1<<15))) |
| 5572 | break; |
| 5573 | msleep(1); |
| 5574 | } |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 5575 | |
| 5576 | if (cnt == 1000) |
| 5577 | netdev_err(bp->dev, "Warning: PHY was not initialized," |
| 5578 | " Port %d\n", |
| 5579 | params->port); |
Yaniv Rosner | 62b29a5 | 2010-09-07 11:40:58 +0000 | [diff] [blame] | 5580 | DP(NETIF_MSG_LINK, "control reg 0x%x (after %d ms)\n", ctrl, cnt); |
| 5581 | return cnt; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 5582 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5583 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5584 | static void bnx2x_link_int_enable(struct link_params *params) |
| 5585 | { |
| 5586 | u8 port = params->port; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5587 | u32 mask; |
| 5588 | struct bnx2x *bp = params->bp; |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 5589 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5590 | /* Setting the status to report on link up for either XGXS or SerDes */ |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5591 | if (CHIP_IS_E3(bp)) { |
| 5592 | mask = NIG_MASK_XGXS0_LINK_STATUS; |
| 5593 | if (!(SINGLE_MEDIA_DIRECT(params))) |
| 5594 | mask |= NIG_MASK_MI_INT; |
| 5595 | } else if (params->switch_cfg == SWITCH_CFG_10G) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5596 | mask = (NIG_MASK_XGXS0_LINK10G | |
| 5597 | NIG_MASK_XGXS0_LINK_STATUS); |
| 5598 | DP(NETIF_MSG_LINK, "enabled XGXS interrupt\n"); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 5599 | if (!(SINGLE_MEDIA_DIRECT(params)) && |
| 5600 | params->phy[INT_PHY].type != |
| 5601 | PORT_HW_CFG_XGXS_EXT_PHY_TYPE_FAILURE) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5602 | mask |= NIG_MASK_MI_INT; |
| 5603 | DP(NETIF_MSG_LINK, "enabled external phy int\n"); |
| 5604 | } |
| 5605 | |
| 5606 | } else { /* SerDes */ |
| 5607 | mask = NIG_MASK_SERDES0_LINK_STATUS; |
| 5608 | DP(NETIF_MSG_LINK, "enabled SerDes interrupt\n"); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 5609 | if (!(SINGLE_MEDIA_DIRECT(params)) && |
| 5610 | params->phy[INT_PHY].type != |
| 5611 | PORT_HW_CFG_SERDES_EXT_PHY_TYPE_NOT_CONN) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5612 | mask |= NIG_MASK_MI_INT; |
| 5613 | DP(NETIF_MSG_LINK, "enabled external phy int\n"); |
| 5614 | } |
| 5615 | } |
| 5616 | bnx2x_bits_en(bp, |
| 5617 | NIG_REG_MASK_INTERRUPT_PORT0 + port*4, |
| 5618 | mask); |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 5619 | |
| 5620 | DP(NETIF_MSG_LINK, "port %x, is_xgxs %x, int_status 0x%x\n", port, |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5621 | (params->switch_cfg == SWITCH_CFG_10G), |
| 5622 | REG_RD(bp, NIG_REG_STATUS_INTERRUPT_PORT0 + port*4)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5623 | DP(NETIF_MSG_LINK, " int_mask 0x%x, MI_INT %x, SERDES_LINK %x\n", |
| 5624 | REG_RD(bp, NIG_REG_MASK_INTERRUPT_PORT0 + port*4), |
| 5625 | REG_RD(bp, NIG_REG_EMAC0_STATUS_MISC_MI_INT + port*0x18), |
| 5626 | REG_RD(bp, NIG_REG_SERDES0_STATUS_LINK_STATUS+port*0x3c)); |
| 5627 | DP(NETIF_MSG_LINK, " 10G %x, XGXS_LINK %x\n", |
| 5628 | REG_RD(bp, NIG_REG_XGXS0_STATUS_LINK10G + port*0x68), |
| 5629 | REG_RD(bp, NIG_REG_XGXS0_STATUS_LINK_STATUS + port*0x68)); |
| 5630 | } |
| 5631 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5632 | static void bnx2x_rearm_latch_signal(struct bnx2x *bp, u8 port, |
| 5633 | u8 exp_mi_int) |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 5634 | { |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5635 | u32 latch_status = 0; |
| 5636 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5637 | /* |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5638 | * Disable the MI INT ( external phy int ) by writing 1 to the |
| 5639 | * status register. Link down indication is high-active-signal, |
| 5640 | * so in this case we need to write the status to clear the XOR |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 5641 | */ |
| 5642 | /* Read Latched signals */ |
| 5643 | latch_status = REG_RD(bp, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5644 | NIG_REG_LATCH_STATUS_0 + port*8); |
| 5645 | DP(NETIF_MSG_LINK, "latch_status = 0x%x\n", latch_status); |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 5646 | /* Handle only those with latched-signal=up.*/ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5647 | if (exp_mi_int) |
| 5648 | bnx2x_bits_en(bp, |
| 5649 | NIG_REG_STATUS_INTERRUPT_PORT0 |
| 5650 | + port*4, |
| 5651 | NIG_STATUS_EMAC0_MI_INT); |
| 5652 | else |
| 5653 | bnx2x_bits_dis(bp, |
| 5654 | NIG_REG_STATUS_INTERRUPT_PORT0 |
| 5655 | + port*4, |
| 5656 | NIG_STATUS_EMAC0_MI_INT); |
| 5657 | |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 5658 | if (latch_status & 1) { |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5659 | |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 5660 | /* For all latched-signal=up : Re-Arm Latch signals */ |
| 5661 | REG_WR(bp, NIG_REG_LATCH_STATUS_0 + port*8, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5662 | (latch_status & 0xfffe) | (latch_status & 1)); |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 5663 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5664 | /* For all latched-signal=up,Write original_signal to status */ |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 5665 | } |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 5666 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5667 | static void bnx2x_link_int_ack(struct link_params *params, |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5668 | struct link_vars *vars, u8 is_10g_plus) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5669 | { |
| 5670 | struct bnx2x *bp = params->bp; |
| 5671 | u8 port = params->port; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5672 | u32 mask; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5673 | /* |
| 5674 | * First reset all status we assume only one line will be |
| 5675 | * change at a time |
| 5676 | */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5677 | bnx2x_bits_dis(bp, NIG_REG_STATUS_INTERRUPT_PORT0 + port*4, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5678 | (NIG_STATUS_XGXS0_LINK10G | |
| 5679 | NIG_STATUS_XGXS0_LINK_STATUS | |
| 5680 | NIG_STATUS_SERDES0_LINK_STATUS)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5681 | if (vars->phy_link_up) { |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5682 | if (USES_WARPCORE(bp)) |
| 5683 | mask = NIG_STATUS_XGXS0_LINK_STATUS; |
| 5684 | else { |
| 5685 | if (is_10g_plus) |
| 5686 | mask = NIG_STATUS_XGXS0_LINK10G; |
| 5687 | else if (params->switch_cfg == SWITCH_CFG_10G) { |
| 5688 | /* |
| 5689 | * Disable the link interrupt by writing 1 to |
| 5690 | * the relevant lane in the status register |
| 5691 | */ |
| 5692 | u32 ser_lane = |
| 5693 | ((params->lane_config & |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5694 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_MASK) >> |
| 5695 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_SHIFT); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5696 | mask = ((1 << ser_lane) << |
| 5697 | NIG_STATUS_XGXS0_LINK_STATUS_SIZE); |
| 5698 | } else |
| 5699 | mask = NIG_STATUS_SERDES0_LINK_STATUS; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5700 | } |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5701 | DP(NETIF_MSG_LINK, "Ack link up interrupt with mask 0x%x\n", |
| 5702 | mask); |
| 5703 | bnx2x_bits_en(bp, |
| 5704 | NIG_REG_STATUS_INTERRUPT_PORT0 + port*4, |
| 5705 | mask); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5706 | } |
| 5707 | } |
| 5708 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 5709 | static int bnx2x_format_ver(u32 num, u8 *str, u16 *len) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5710 | { |
| 5711 | u8 *str_ptr = str; |
| 5712 | u32 mask = 0xf0000000; |
| 5713 | u8 shift = 8*4; |
| 5714 | u8 digit; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5715 | u8 remove_leading_zeros = 1; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 5716 | if (*len < 10) { |
Frederik Schwarzer | 025dfda | 2008-10-16 19:02:37 +0200 | [diff] [blame] | 5717 | /* Need more than 10chars for this format */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5718 | *str_ptr = '\0'; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5719 | (*len)--; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5720 | return -EINVAL; |
| 5721 | } |
| 5722 | while (shift > 0) { |
| 5723 | |
| 5724 | shift -= 4; |
| 5725 | digit = ((num & mask) >> shift); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5726 | if (digit == 0 && remove_leading_zeros) { |
| 5727 | mask = mask >> 4; |
| 5728 | continue; |
| 5729 | } else if (digit < 0xa) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5730 | *str_ptr = digit + '0'; |
| 5731 | else |
| 5732 | *str_ptr = digit - 0xa + 'a'; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5733 | remove_leading_zeros = 0; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5734 | str_ptr++; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5735 | (*len)--; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5736 | mask = mask >> 4; |
| 5737 | if (shift == 4*4) { |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5738 | *str_ptr = '.'; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5739 | str_ptr++; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5740 | (*len)--; |
| 5741 | remove_leading_zeros = 1; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5742 | } |
| 5743 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5744 | return 0; |
| 5745 | } |
| 5746 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5747 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 5748 | static int bnx2x_null_format_ver(u32 spirom_ver, u8 *str, u16 *len) |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 5749 | { |
| 5750 | str[0] = '\0'; |
| 5751 | (*len)--; |
| 5752 | return 0; |
| 5753 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5754 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 5755 | int bnx2x_get_ext_phy_fw_version(struct link_params *params, u8 driver_loaded, |
| 5756 | u8 *version, u16 len) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5757 | { |
Julia Lawall | 0376d5b | 2009-07-19 05:26:35 +0000 | [diff] [blame] | 5758 | struct bnx2x *bp; |
Eilon Greenstein | a35da8d | 2009-02-12 08:37:02 +0000 | [diff] [blame] | 5759 | u32 spirom_ver = 0; |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 5760 | int status = 0; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 5761 | u8 *ver_p = version; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5762 | u16 remain_len = len; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5763 | if (version == NULL || params == NULL) |
| 5764 | return -EINVAL; |
Julia Lawall | 0376d5b | 2009-07-19 05:26:35 +0000 | [diff] [blame] | 5765 | bp = params->bp; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5766 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 5767 | /* Extract first external phy*/ |
| 5768 | version[0] = '\0'; |
| 5769 | spirom_ver = REG_RD(bp, params->phy[EXT_PHY1].ver_addr); |
Eilon Greenstein | a35da8d | 2009-02-12 08:37:02 +0000 | [diff] [blame] | 5770 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5771 | if (params->phy[EXT_PHY1].format_fw_ver) { |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 5772 | status |= params->phy[EXT_PHY1].format_fw_ver(spirom_ver, |
| 5773 | ver_p, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5774 | &remain_len); |
| 5775 | ver_p += (len - remain_len); |
| 5776 | } |
| 5777 | if ((params->num_phys == MAX_PHYS) && |
| 5778 | (params->phy[EXT_PHY2].ver_addr != 0)) { |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5779 | spirom_ver = REG_RD(bp, params->phy[EXT_PHY2].ver_addr); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5780 | if (params->phy[EXT_PHY2].format_fw_ver) { |
| 5781 | *ver_p = '/'; |
| 5782 | ver_p++; |
| 5783 | remain_len--; |
| 5784 | status |= params->phy[EXT_PHY2].format_fw_ver( |
| 5785 | spirom_ver, |
| 5786 | ver_p, |
| 5787 | &remain_len); |
| 5788 | ver_p = version + (len - remain_len); |
| 5789 | } |
| 5790 | } |
| 5791 | *ver_p = '\0'; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5792 | return status; |
| 5793 | } |
| 5794 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 5795 | static void bnx2x_set_xgxs_loopback(struct bnx2x_phy *phy, |
Yaniv Rosner | 62b29a5 | 2010-09-07 11:40:58 +0000 | [diff] [blame] | 5796 | struct link_params *params) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5797 | { |
| 5798 | u8 port = params->port; |
| 5799 | struct bnx2x *bp = params->bp; |
| 5800 | |
Yaniv Rosner | 62b29a5 | 2010-09-07 11:40:58 +0000 | [diff] [blame] | 5801 | if (phy->req_line_speed != SPEED_1000) { |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5802 | u32 md_devad = 0; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5803 | |
| 5804 | DP(NETIF_MSG_LINK, "XGXS 10G loopback enable\n"); |
| 5805 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5806 | if (!CHIP_IS_E3(bp)) { |
| 5807 | /* change the uni_phy_addr in the nig */ |
| 5808 | md_devad = REG_RD(bp, (NIG_REG_XGXS0_CTRL_MD_DEVAD + |
| 5809 | port*0x18)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5810 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5811 | REG_WR(bp, NIG_REG_XGXS0_CTRL_MD_DEVAD + port*0x18, |
| 5812 | 0x5); |
| 5813 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5814 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 5815 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5816 | 5, |
| 5817 | (MDIO_REG_BANK_AER_BLOCK + |
| 5818 | (MDIO_AER_BLOCK_AER_REG & 0xf)), |
| 5819 | 0x2800); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5820 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 5821 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5822 | 5, |
| 5823 | (MDIO_REG_BANK_CL73_IEEEB0 + |
| 5824 | (MDIO_CL73_IEEEB0_CL73_AN_CONTROL & 0xf)), |
| 5825 | 0x6041); |
Eilon Greenstein | 3858276 | 2009-01-14 06:44:16 +0000 | [diff] [blame] | 5826 | msleep(200); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5827 | /* set aer mmd back */ |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 5828 | bnx2x_set_aer_mmd(params, phy); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5829 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5830 | if (!CHIP_IS_E3(bp)) { |
| 5831 | /* and md_devad */ |
| 5832 | REG_WR(bp, NIG_REG_XGXS0_CTRL_MD_DEVAD + port*0x18, |
| 5833 | md_devad); |
| 5834 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5835 | } else { |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 5836 | u16 mii_ctrl; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5837 | DP(NETIF_MSG_LINK, "XGXS 1G loopback enable\n"); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 5838 | bnx2x_cl45_read(bp, phy, 5, |
| 5839 | (MDIO_REG_BANK_COMBO_IEEE0 + |
| 5840 | (MDIO_COMBO_IEEE0_MII_CONTROL & 0xf)), |
| 5841 | &mii_ctrl); |
| 5842 | bnx2x_cl45_write(bp, phy, 5, |
| 5843 | (MDIO_REG_BANK_COMBO_IEEE0 + |
| 5844 | (MDIO_COMBO_IEEE0_MII_CONTROL & 0xf)), |
| 5845 | mii_ctrl | |
| 5846 | MDIO_COMBO_IEEO_MII_CONTROL_LOOPBACK); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5847 | } |
| 5848 | } |
| 5849 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 5850 | int bnx2x_set_led(struct link_params *params, |
| 5851 | struct link_vars *vars, u8 mode, u32 speed) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5852 | { |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 5853 | u8 port = params->port; |
| 5854 | u16 hw_led_mode = params->hw_led_mode; |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 5855 | int rc = 0; |
| 5856 | u8 phy_idx; |
Eilon Greenstein | 345b5d5 | 2008-08-13 15:58:12 -0700 | [diff] [blame] | 5857 | u32 tmp; |
| 5858 | u32 emac_base = port ? GRCBASE_EMAC1 : GRCBASE_EMAC0; |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 5859 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5860 | DP(NETIF_MSG_LINK, "bnx2x_set_led: port %x, mode %d\n", port, mode); |
| 5861 | DP(NETIF_MSG_LINK, "speed 0x%x, hw_led_mode 0x%x\n", |
| 5862 | speed, hw_led_mode); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 5863 | /* In case */ |
| 5864 | for (phy_idx = EXT_PHY1; phy_idx < MAX_PHYS; phy_idx++) { |
| 5865 | if (params->phy[phy_idx].set_link_led) { |
| 5866 | params->phy[phy_idx].set_link_led( |
| 5867 | ¶ms->phy[phy_idx], params, mode); |
| 5868 | } |
| 5869 | } |
| 5870 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5871 | switch (mode) { |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 5872 | case LED_MODE_FRONT_PANEL_OFF: |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5873 | case LED_MODE_OFF: |
| 5874 | REG_WR(bp, NIG_REG_LED_10G_P0 + port*4, 0); |
| 5875 | REG_WR(bp, NIG_REG_LED_MODE_P0 + port*4, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5876 | SHARED_HW_CFG_LED_MAC1); |
Eilon Greenstein | 345b5d5 | 2008-08-13 15:58:12 -0700 | [diff] [blame] | 5877 | |
| 5878 | tmp = EMAC_RD(bp, EMAC_REG_EMAC_LED); |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 5879 | EMAC_WR(bp, EMAC_REG_EMAC_LED, (tmp | EMAC_LED_OVERRIDE)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5880 | break; |
| 5881 | |
| 5882 | case LED_MODE_OPER: |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5883 | /* |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 5884 | * For all other phys, OPER mode is same as ON, so in case |
| 5885 | * link is down, do nothing |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5886 | */ |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 5887 | if (!vars->link_up) |
| 5888 | break; |
| 5889 | case LED_MODE_ON: |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 5890 | if (((params->phy[EXT_PHY1].type == |
| 5891 | PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727) || |
| 5892 | (params->phy[EXT_PHY1].type == |
| 5893 | PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8722)) && |
Yaniv Rosner | 1f48353 | 2011-01-18 04:33:31 +0000 | [diff] [blame] | 5894 | CHIP_IS_E2(bp) && params->num_phys == 2) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5895 | /* |
| 5896 | * This is a work-around for E2+8727 Configurations |
| 5897 | */ |
Yaniv Rosner | 1f48353 | 2011-01-18 04:33:31 +0000 | [diff] [blame] | 5898 | if (mode == LED_MODE_ON || |
| 5899 | speed == SPEED_10000){ |
| 5900 | REG_WR(bp, NIG_REG_LED_MODE_P0 + port*4, 0); |
| 5901 | REG_WR(bp, NIG_REG_LED_10G_P0 + port*4, 1); |
| 5902 | |
| 5903 | tmp = EMAC_RD(bp, EMAC_REG_EMAC_LED); |
| 5904 | EMAC_WR(bp, EMAC_REG_EMAC_LED, |
| 5905 | (tmp | EMAC_LED_OVERRIDE)); |
| 5906 | return rc; |
| 5907 | } |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5908 | } else if (SINGLE_MEDIA_DIRECT(params) && |
| 5909 | (CHIP_IS_E1x(bp) || |
| 5910 | CHIP_IS_E2(bp))) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5911 | /* |
| 5912 | * This is a work-around for HW issue found when link |
| 5913 | * is up in CL73 |
| 5914 | */ |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 5915 | REG_WR(bp, NIG_REG_LED_MODE_P0 + port*4, 0); |
| 5916 | REG_WR(bp, NIG_REG_LED_10G_P0 + port*4, 1); |
| 5917 | } else { |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5918 | REG_WR(bp, NIG_REG_LED_MODE_P0 + port*4, hw_led_mode); |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 5919 | } |
| 5920 | |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5921 | REG_WR(bp, NIG_REG_LED_CONTROL_OVERRIDE_TRAFFIC_P0 + port*4, 0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5922 | /* Set blinking rate to ~15.9Hz */ |
| 5923 | REG_WR(bp, NIG_REG_LED_CONTROL_BLINK_RATE_P0 + port*4, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5924 | LED_BLINK_RATE_VAL); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5925 | REG_WR(bp, NIG_REG_LED_CONTROL_BLINK_RATE_ENA_P0 + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5926 | port*4, 1); |
Eilon Greenstein | 345b5d5 | 2008-08-13 15:58:12 -0700 | [diff] [blame] | 5927 | tmp = EMAC_RD(bp, EMAC_REG_EMAC_LED); |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5928 | EMAC_WR(bp, EMAC_REG_EMAC_LED, (tmp & (~EMAC_LED_OVERRIDE))); |
Eilon Greenstein | 345b5d5 | 2008-08-13 15:58:12 -0700 | [diff] [blame] | 5929 | |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 5930 | if (CHIP_IS_E1(bp) && |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 5931 | ((speed == SPEED_2500) || |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5932 | (speed == SPEED_1000) || |
| 5933 | (speed == SPEED_100) || |
| 5934 | (speed == SPEED_10))) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5935 | /* |
| 5936 | * On Everest 1 Ax chip versions for speeds less than |
| 5937 | * 10G LED scheme is different |
| 5938 | */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5939 | REG_WR(bp, NIG_REG_LED_CONTROL_OVERRIDE_TRAFFIC_P0 |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5940 | + port*4, 1); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5941 | REG_WR(bp, NIG_REG_LED_CONTROL_TRAFFIC_P0 + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5942 | port*4, 0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5943 | REG_WR(bp, NIG_REG_LED_CONTROL_BLINK_TRAFFIC_P0 + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5944 | port*4, 1); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5945 | } |
| 5946 | break; |
| 5947 | |
| 5948 | default: |
| 5949 | rc = -EINVAL; |
| 5950 | DP(NETIF_MSG_LINK, "bnx2x_set_led: Invalid led mode %d\n", |
| 5951 | mode); |
| 5952 | break; |
| 5953 | } |
| 5954 | return rc; |
| 5955 | |
| 5956 | } |
| 5957 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5958 | /* |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5959 | * This function comes to reflect the actual link state read DIRECTLY from the |
| 5960 | * HW |
| 5961 | */ |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 5962 | int bnx2x_test_link(struct link_params *params, struct link_vars *vars, |
| 5963 | u8 is_serdes) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5964 | { |
| 5965 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 5966 | u16 gp_status = 0, phy_index = 0; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5967 | u8 ext_phy_link_up = 0, serdes_phy_type; |
| 5968 | struct link_vars temp_vars; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5969 | struct bnx2x_phy *int_phy = ¶ms->phy[INT_PHY]; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5970 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5971 | if (CHIP_IS_E3(bp)) { |
| 5972 | u16 link_up; |
| 5973 | if (params->req_line_speed[LINK_CONFIG_IDX(INT_PHY)] |
| 5974 | > SPEED_10000) { |
| 5975 | /* Check 20G link */ |
| 5976 | bnx2x_cl45_read(bp, int_phy, MDIO_WC_DEVAD, |
| 5977 | 1, &link_up); |
| 5978 | bnx2x_cl45_read(bp, int_phy, MDIO_WC_DEVAD, |
| 5979 | 1, &link_up); |
| 5980 | link_up &= (1<<2); |
| 5981 | } else { |
| 5982 | /* Check 10G link and below*/ |
| 5983 | u8 lane = bnx2x_get_warpcore_lane(int_phy, params); |
| 5984 | bnx2x_cl45_read(bp, int_phy, MDIO_WC_DEVAD, |
| 5985 | MDIO_WC_REG_GP2_STATUS_GP_2_1, |
| 5986 | &gp_status); |
| 5987 | gp_status = ((gp_status >> 8) & 0xf) | |
| 5988 | ((gp_status >> 12) & 0xf); |
| 5989 | link_up = gp_status & (1 << lane); |
| 5990 | } |
| 5991 | if (!link_up) |
| 5992 | return -ESRCH; |
| 5993 | } else { |
| 5994 | CL22_RD_OVER_CL45(bp, int_phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5995 | MDIO_REG_BANK_GP_STATUS, |
| 5996 | MDIO_GP_STATUS_TOP_AN_STATUS1, |
| 5997 | &gp_status); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5998 | /* link is up only if both local phy and external phy are up */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5999 | if (!(gp_status & MDIO_GP_STATUS_TOP_AN_STATUS1_LINK_STATUS)) |
| 6000 | return -ESRCH; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6001 | } |
| 6002 | /* In XGXS loopback mode, do not check external PHY */ |
| 6003 | if (params->loopback_mode == LOOPBACK_XGXS) |
| 6004 | return 0; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6005 | |
| 6006 | switch (params->num_phys) { |
| 6007 | case 1: |
| 6008 | /* No external PHY */ |
| 6009 | return 0; |
| 6010 | case 2: |
| 6011 | ext_phy_link_up = params->phy[EXT_PHY1].read_status( |
| 6012 | ¶ms->phy[EXT_PHY1], |
| 6013 | params, &temp_vars); |
| 6014 | break; |
| 6015 | case 3: /* Dual Media */ |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 6016 | for (phy_index = EXT_PHY1; phy_index < params->num_phys; |
| 6017 | phy_index++) { |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6018 | serdes_phy_type = ((params->phy[phy_index].media_type == |
| 6019 | ETH_PHY_SFP_FIBER) || |
| 6020 | (params->phy[phy_index].media_type == |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 6021 | ETH_PHY_XFP_FIBER) || |
| 6022 | (params->phy[phy_index].media_type == |
| 6023 | ETH_PHY_DA_TWINAX)); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6024 | |
| 6025 | if (is_serdes != serdes_phy_type) |
| 6026 | continue; |
| 6027 | if (params->phy[phy_index].read_status) { |
| 6028 | ext_phy_link_up |= |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 6029 | params->phy[phy_index].read_status( |
| 6030 | ¶ms->phy[phy_index], |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6031 | params, &temp_vars); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6032 | } |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 6033 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6034 | break; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6035 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6036 | if (ext_phy_link_up) |
| 6037 | return 0; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6038 | return -ESRCH; |
| 6039 | } |
| 6040 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6041 | static int bnx2x_link_initialize(struct link_params *params, |
| 6042 | struct link_vars *vars) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6043 | { |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6044 | int rc = 0; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6045 | u8 phy_index, non_ext_phy; |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 6046 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6047 | /* |
| 6048 | * In case of external phy existence, the line speed would be the |
| 6049 | * line speed linked up by the external phy. In case it is direct |
| 6050 | * only, then the line_speed during initialization will be |
| 6051 | * equal to the req_line_speed |
| 6052 | */ |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 6053 | vars->line_speed = params->phy[INT_PHY].req_line_speed; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6054 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6055 | /* |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 6056 | * Initialize the internal phy in case this is a direct board |
| 6057 | * (no external phys), or this board has external phy which requires |
| 6058 | * to first. |
| 6059 | */ |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6060 | if (!USES_WARPCORE(bp)) |
| 6061 | bnx2x_prepare_xgxs(¶ms->phy[INT_PHY], params, vars); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6062 | /* init ext phy and enable link state int */ |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 6063 | non_ext_phy = (SINGLE_MEDIA_DIRECT(params) || |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6064 | (params->loopback_mode == LOOPBACK_XGXS)); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6065 | |
| 6066 | if (non_ext_phy || |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 6067 | (params->phy[EXT_PHY1].flags & FLAGS_INIT_XGXS_FIRST) || |
Eilon Greenstein | 8660d8c | 2009-03-02 08:01:02 +0000 | [diff] [blame] | 6068 | (params->loopback_mode == LOOPBACK_EXT_PHY)) { |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 6069 | struct bnx2x_phy *phy = ¶ms->phy[INT_PHY]; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6070 | if (vars->line_speed == SPEED_AUTO_NEG && |
| 6071 | (CHIP_IS_E1x(bp) || |
| 6072 | CHIP_IS_E2(bp))) |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 6073 | bnx2x_set_parallel_detection(phy, params); |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 6074 | if (params->phy[INT_PHY].config_init) |
| 6075 | params->phy[INT_PHY].config_init(phy, |
| 6076 | params, |
| 6077 | vars); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6078 | } |
| 6079 | |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 6080 | /* Init external phy*/ |
Yaniv Rosner | fd36a2e | 2011-05-31 21:29:05 +0000 | [diff] [blame] | 6081 | if (non_ext_phy) { |
| 6082 | if (params->phy[INT_PHY].supported & |
| 6083 | SUPPORTED_FIBRE) |
| 6084 | vars->link_status |= LINK_STATUS_SERDES_LINK; |
| 6085 | } else { |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6086 | for (phy_index = EXT_PHY1; phy_index < params->num_phys; |
| 6087 | phy_index++) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6088 | /* |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6089 | * No need to initialize second phy in case of first |
| 6090 | * phy only selection. In case of second phy, we do |
| 6091 | * need to initialize the first phy, since they are |
| 6092 | * connected. |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6093 | */ |
Yaniv Rosner | fd36a2e | 2011-05-31 21:29:05 +0000 | [diff] [blame] | 6094 | if (params->phy[phy_index].supported & |
| 6095 | SUPPORTED_FIBRE) |
| 6096 | vars->link_status |= LINK_STATUS_SERDES_LINK; |
| 6097 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6098 | if (phy_index == EXT_PHY2 && |
| 6099 | (bnx2x_phy_selection(params) == |
| 6100 | PORT_HW_CFG_PHY_SELECTION_FIRST_PHY)) { |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 6101 | DP(NETIF_MSG_LINK, "Not initializing" |
| 6102 | " second phy\n"); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6103 | continue; |
| 6104 | } |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6105 | params->phy[phy_index].config_init( |
| 6106 | ¶ms->phy[phy_index], |
| 6107 | params, vars); |
| 6108 | } |
Yaniv Rosner | fd36a2e | 2011-05-31 21:29:05 +0000 | [diff] [blame] | 6109 | } |
Yaniv Rosner | d90d96b | 2010-09-07 11:41:04 +0000 | [diff] [blame] | 6110 | /* Reset the interrupt indication after phy was initialized */ |
| 6111 | bnx2x_bits_dis(bp, NIG_REG_STATUS_INTERRUPT_PORT0 + |
| 6112 | params->port*4, |
| 6113 | (NIG_STATUS_XGXS0_LINK10G | |
| 6114 | NIG_STATUS_XGXS0_LINK_STATUS | |
| 6115 | NIG_STATUS_SERDES0_LINK_STATUS | |
| 6116 | NIG_MASK_MI_INT)); |
Yaniv Rosner | fd36a2e | 2011-05-31 21:29:05 +0000 | [diff] [blame] | 6117 | bnx2x_update_mng(params, vars->link_status); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6118 | return rc; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6119 | } |
| 6120 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6121 | static void bnx2x_int_link_reset(struct bnx2x_phy *phy, |
| 6122 | struct link_params *params) |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6123 | { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6124 | /* reset the SerDes/XGXS */ |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6125 | REG_WR(params->bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_3_CLEAR, |
| 6126 | (0x1ff << (params->port*16))); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6127 | } |
| 6128 | |
| 6129 | static void bnx2x_common_ext_link_reset(struct bnx2x_phy *phy, |
| 6130 | struct link_params *params) |
| 6131 | { |
| 6132 | struct bnx2x *bp = params->bp; |
| 6133 | u8 gpio_port; |
| 6134 | /* HW reset */ |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 6135 | if (CHIP_IS_E2(bp)) |
| 6136 | gpio_port = BP_PATH(bp); |
| 6137 | else |
| 6138 | gpio_port = params->port; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6139 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6140 | MISC_REGISTERS_GPIO_OUTPUT_LOW, |
| 6141 | gpio_port); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6142 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6143 | MISC_REGISTERS_GPIO_OUTPUT_LOW, |
| 6144 | gpio_port); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6145 | DP(NETIF_MSG_LINK, "reset external PHY\n"); |
| 6146 | } |
| 6147 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6148 | static int bnx2x_update_link_down(struct link_params *params, |
| 6149 | struct link_vars *vars) |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6150 | { |
| 6151 | struct bnx2x *bp = params->bp; |
| 6152 | u8 port = params->port; |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 6153 | |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6154 | DP(NETIF_MSG_LINK, "Port %x: Link is down\n", port); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6155 | bnx2x_set_led(params, vars, LED_MODE_OFF, 0); |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 6156 | vars->phy_flags &= ~PHY_PHYSICAL_LINK_FLAG; |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6157 | /* indicate no mac active */ |
| 6158 | vars->mac_type = MAC_TYPE_NONE; |
| 6159 | |
| 6160 | /* update shared memory */ |
Yaniv Rosner | fd36a2e | 2011-05-31 21:29:05 +0000 | [diff] [blame] | 6161 | vars->link_status &= ~(LINK_STATUS_SPEED_AND_DUPLEX_MASK | |
| 6162 | LINK_STATUS_LINK_UP | |
| 6163 | LINK_STATUS_AUTO_NEGOTIATE_COMPLETE | |
| 6164 | LINK_STATUS_RX_FLOW_CONTROL_FLAG_MASK | |
| 6165 | LINK_STATUS_TX_FLOW_CONTROL_FLAG_MASK | |
| 6166 | LINK_STATUS_PARALLEL_DETECTION_FLAG_MASK); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6167 | vars->line_speed = 0; |
| 6168 | bnx2x_update_mng(params, vars->link_status); |
| 6169 | |
| 6170 | /* activate nig drain */ |
| 6171 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + port*4, 1); |
| 6172 | |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 6173 | /* disable emac */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 6174 | if (!CHIP_IS_E3(bp)) |
| 6175 | REG_WR(bp, NIG_REG_NIG_EMAC0_EN + port*4, 0); |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 6176 | |
| 6177 | msleep(10); |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 6178 | /* reset BigMac/Xmac */ |
| 6179 | if (CHIP_IS_E1x(bp) || |
| 6180 | CHIP_IS_E2(bp)) { |
| 6181 | bnx2x_bmac_rx_disable(bp, params->port); |
| 6182 | REG_WR(bp, GRCBASE_MISC + |
| 6183 | MISC_REGISTERS_RESET_REG_2_CLEAR, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6184 | (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << port)); |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 6185 | } |
| 6186 | if (CHIP_IS_E3(bp)) |
| 6187 | bnx2x_xmac_disable(params); |
| 6188 | |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6189 | return 0; |
| 6190 | } |
| 6191 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6192 | static int bnx2x_update_link_up(struct link_params *params, |
| 6193 | struct link_vars *vars, |
| 6194 | u8 link_10g) |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6195 | { |
| 6196 | struct bnx2x *bp = params->bp; |
| 6197 | u8 port = params->port; |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6198 | int rc = 0; |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 6199 | |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6200 | vars->link_status |= LINK_STATUS_LINK_UP; |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 6201 | vars->phy_flags |= PHY_PHYSICAL_LINK_FLAG; |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6202 | |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 6203 | if (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX) |
| 6204 | vars->link_status |= |
| 6205 | LINK_STATUS_TX_FLOW_CONTROL_ENABLED; |
| 6206 | |
| 6207 | if (vars->flow_ctrl & BNX2X_FLOW_CTRL_RX) |
| 6208 | vars->link_status |= |
| 6209 | LINK_STATUS_RX_FLOW_CONTROL_ENABLED; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 6210 | if (USES_WARPCORE(bp)) { |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 6211 | if (link_10g) { |
| 6212 | if (bnx2x_xmac_enable(params, vars, 0) == |
| 6213 | -ESRCH) { |
| 6214 | DP(NETIF_MSG_LINK, "Found errors on XMAC\n"); |
| 6215 | vars->link_up = 0; |
| 6216 | vars->phy_flags |= PHY_HALF_OPEN_CONN_FLAG; |
| 6217 | vars->link_status &= ~LINK_STATUS_LINK_UP; |
| 6218 | } |
| 6219 | } else |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 6220 | bnx2x_umac_enable(params, vars, 0); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6221 | bnx2x_set_led(params, vars, |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 6222 | LED_MODE_OPER, vars->line_speed); |
| 6223 | } |
| 6224 | if ((CHIP_IS_E1x(bp) || |
| 6225 | CHIP_IS_E2(bp))) { |
| 6226 | if (link_10g) { |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 6227 | if (bnx2x_bmac_enable(params, vars, 0) == |
| 6228 | -ESRCH) { |
| 6229 | DP(NETIF_MSG_LINK, "Found errors on BMAC\n"); |
| 6230 | vars->link_up = 0; |
| 6231 | vars->phy_flags |= PHY_HALF_OPEN_CONN_FLAG; |
| 6232 | vars->link_status &= ~LINK_STATUS_LINK_UP; |
| 6233 | } |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6234 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 6235 | bnx2x_set_led(params, vars, |
| 6236 | LED_MODE_OPER, SPEED_10000); |
| 6237 | } else { |
| 6238 | rc = bnx2x_emac_program(params, vars); |
| 6239 | bnx2x_emac_enable(params, vars, 0); |
Yaniv Rosner | 0c786f0 | 2009-11-05 19:18:32 +0200 | [diff] [blame] | 6240 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 6241 | /* AN complete? */ |
| 6242 | if ((vars->link_status & |
| 6243 | LINK_STATUS_AUTO_NEGOTIATE_COMPLETE) |
| 6244 | && (!(vars->phy_flags & PHY_SGMII_FLAG)) && |
| 6245 | SINGLE_MEDIA_DIRECT(params)) |
| 6246 | bnx2x_set_gmii_tx_driver(params); |
| 6247 | } |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6248 | } |
| 6249 | |
| 6250 | /* PBF - link up */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 6251 | if (CHIP_IS_E1x(bp)) |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 6252 | rc |= bnx2x_pbf_update(params, vars->flow_ctrl, |
| 6253 | vars->line_speed); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6254 | |
| 6255 | /* disable drain */ |
| 6256 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + port*4, 0); |
| 6257 | |
| 6258 | /* update shared memory */ |
| 6259 | bnx2x_update_mng(params, vars->link_status); |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 6260 | msleep(20); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6261 | return rc; |
| 6262 | } |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6263 | /* |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6264 | * The bnx2x_link_update function should be called upon link |
| 6265 | * interrupt. |
| 6266 | * Link is considered up as follows: |
| 6267 | * - DIRECT_SINGLE_MEDIA - Only XGXS link (internal link) needs |
| 6268 | * to be up |
| 6269 | * - SINGLE_MEDIA - The link between the 577xx and the external |
| 6270 | * phy (XGXS) need to up as well as the external link of the |
| 6271 | * phy (PHY_EXT1) |
| 6272 | * - DUAL_MEDIA - The link between the 577xx and the first |
| 6273 | * external phy needs to be up, and at least one of the 2 |
| 6274 | * external phy link must be up. |
Yaniv Rosner | 62b29a5 | 2010-09-07 11:40:58 +0000 | [diff] [blame] | 6275 | */ |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6276 | int bnx2x_link_update(struct link_params *params, struct link_vars *vars) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6277 | { |
| 6278 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6279 | struct link_vars phy_vars[MAX_PHYS]; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6280 | u8 port = params->port; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6281 | u8 link_10g_plus, phy_index; |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6282 | u8 ext_phy_link_up = 0, cur_link_up; |
| 6283 | int rc = 0; |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 6284 | u8 is_mi_int = 0; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6285 | u16 ext_phy_line_speed = 0, prev_line_speed = vars->line_speed; |
| 6286 | u8 active_external_phy = INT_PHY; |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 6287 | vars->phy_flags &= ~PHY_HALF_OPEN_CONN_FLAG; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6288 | for (phy_index = INT_PHY; phy_index < params->num_phys; |
| 6289 | phy_index++) { |
| 6290 | phy_vars[phy_index].flow_ctrl = 0; |
| 6291 | phy_vars[phy_index].link_status = 0; |
| 6292 | phy_vars[phy_index].line_speed = 0; |
| 6293 | phy_vars[phy_index].duplex = DUPLEX_FULL; |
| 6294 | phy_vars[phy_index].phy_link_up = 0; |
| 6295 | phy_vars[phy_index].link_up = 0; |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 6296 | phy_vars[phy_index].fault_detected = 0; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6297 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6298 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6299 | if (USES_WARPCORE(bp)) |
| 6300 | bnx2x_set_aer_mmd(params, ¶ms->phy[INT_PHY]); |
| 6301 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6302 | DP(NETIF_MSG_LINK, "port %x, XGXS?%x, int_status 0x%x\n", |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 6303 | port, (vars->phy_flags & PHY_XGXS_FLAG), |
| 6304 | REG_RD(bp, NIG_REG_STATUS_INTERRUPT_PORT0 + port*4)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6305 | |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 6306 | is_mi_int = (u8)(REG_RD(bp, NIG_REG_EMAC0_STATUS_MISC_MI_INT + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6307 | port*0x18) > 0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6308 | DP(NETIF_MSG_LINK, "int_mask 0x%x MI_INT %x, SERDES_LINK %x\n", |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 6309 | REG_RD(bp, NIG_REG_MASK_INTERRUPT_PORT0 + port*4), |
| 6310 | is_mi_int, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6311 | REG_RD(bp, NIG_REG_SERDES0_STATUS_LINK_STATUS + port*0x3c)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6312 | |
| 6313 | DP(NETIF_MSG_LINK, " 10G %x, XGXS_LINK %x\n", |
| 6314 | REG_RD(bp, NIG_REG_XGXS0_STATUS_LINK10G + port*0x68), |
| 6315 | REG_RD(bp, NIG_REG_XGXS0_STATUS_LINK_STATUS + port*0x68)); |
| 6316 | |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 6317 | /* disable emac */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 6318 | if (!CHIP_IS_E3(bp)) |
| 6319 | REG_WR(bp, NIG_REG_NIG_EMAC0_EN + port*4, 0); |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 6320 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6321 | /* |
| 6322 | * Step 1: |
| 6323 | * Check external link change only for external phys, and apply |
| 6324 | * priority selection between them in case the link on both phys |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 6325 | * is up. Note that instead of the common vars, a temporary |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6326 | * vars argument is used since each phy may have different link/ |
| 6327 | * speed/duplex result |
| 6328 | */ |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6329 | for (phy_index = EXT_PHY1; phy_index < params->num_phys; |
| 6330 | phy_index++) { |
| 6331 | struct bnx2x_phy *phy = ¶ms->phy[phy_index]; |
| 6332 | if (!phy->read_status) |
| 6333 | continue; |
| 6334 | /* Read link status and params of this ext phy */ |
| 6335 | cur_link_up = phy->read_status(phy, params, |
| 6336 | &phy_vars[phy_index]); |
| 6337 | if (cur_link_up) { |
| 6338 | DP(NETIF_MSG_LINK, "phy in index %d link is up\n", |
| 6339 | phy_index); |
| 6340 | } else { |
| 6341 | DP(NETIF_MSG_LINK, "phy in index %d link is down\n", |
| 6342 | phy_index); |
| 6343 | continue; |
| 6344 | } |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6345 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6346 | if (!ext_phy_link_up) { |
| 6347 | ext_phy_link_up = 1; |
| 6348 | active_external_phy = phy_index; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6349 | } else { |
| 6350 | switch (bnx2x_phy_selection(params)) { |
| 6351 | case PORT_HW_CFG_PHY_SELECTION_HARDWARE_DEFAULT: |
| 6352 | case PORT_HW_CFG_PHY_SELECTION_FIRST_PHY_PRIORITY: |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6353 | /* |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6354 | * In this option, the first PHY makes sure to pass the |
| 6355 | * traffic through itself only. |
| 6356 | * Its not clear how to reset the link on the second phy |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6357 | */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6358 | active_external_phy = EXT_PHY1; |
| 6359 | break; |
| 6360 | case PORT_HW_CFG_PHY_SELECTION_SECOND_PHY_PRIORITY: |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6361 | /* |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6362 | * In this option, the first PHY makes sure to pass the |
| 6363 | * traffic through the second PHY. |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6364 | */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6365 | active_external_phy = EXT_PHY2; |
| 6366 | break; |
| 6367 | default: |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6368 | /* |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6369 | * Link indication on both PHYs with the following cases |
| 6370 | * is invalid: |
| 6371 | * - FIRST_PHY means that second phy wasn't initialized, |
| 6372 | * hence its link is expected to be down |
| 6373 | * - SECOND_PHY means that first phy should not be able |
| 6374 | * to link up by itself (using configuration) |
| 6375 | * - DEFAULT should be overriden during initialiazation |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6376 | */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6377 | DP(NETIF_MSG_LINK, "Invalid link indication" |
| 6378 | "mpc=0x%x. DISABLING LINK !!!\n", |
| 6379 | params->multi_phy_config); |
| 6380 | ext_phy_link_up = 0; |
| 6381 | break; |
| 6382 | } |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6383 | } |
| 6384 | } |
| 6385 | prev_line_speed = vars->line_speed; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6386 | /* |
| 6387 | * Step 2: |
| 6388 | * Read the status of the internal phy. In case of |
| 6389 | * DIRECT_SINGLE_MEDIA board, this link is the external link, |
| 6390 | * otherwise this is the link between the 577xx and the first |
| 6391 | * external phy |
| 6392 | */ |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6393 | if (params->phy[INT_PHY].read_status) |
| 6394 | params->phy[INT_PHY].read_status( |
| 6395 | ¶ms->phy[INT_PHY], |
| 6396 | params, vars); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6397 | /* |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6398 | * The INT_PHY flow control reside in the vars. This include the |
| 6399 | * case where the speed or flow control are not set to AUTO. |
| 6400 | * Otherwise, the active external phy flow control result is set |
| 6401 | * to the vars. The ext_phy_line_speed is needed to check if the |
| 6402 | * speed is different between the internal phy and external phy. |
| 6403 | * This case may be result of intermediate link speed change. |
| 6404 | */ |
| 6405 | if (active_external_phy > INT_PHY) { |
| 6406 | vars->flow_ctrl = phy_vars[active_external_phy].flow_ctrl; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6407 | /* |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6408 | * Link speed is taken from the XGXS. AN and FC result from |
| 6409 | * the external phy. |
| 6410 | */ |
| 6411 | vars->link_status |= phy_vars[active_external_phy].link_status; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6412 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6413 | /* |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6414 | * if active_external_phy is first PHY and link is up - disable |
| 6415 | * disable TX on second external PHY |
| 6416 | */ |
| 6417 | if (active_external_phy == EXT_PHY1) { |
| 6418 | if (params->phy[EXT_PHY2].phy_specific_func) { |
| 6419 | DP(NETIF_MSG_LINK, "Disabling TX on" |
| 6420 | " EXT_PHY2\n"); |
| 6421 | params->phy[EXT_PHY2].phy_specific_func( |
| 6422 | ¶ms->phy[EXT_PHY2], |
| 6423 | params, DISABLE_TX); |
| 6424 | } |
| 6425 | } |
| 6426 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6427 | ext_phy_line_speed = phy_vars[active_external_phy].line_speed; |
| 6428 | vars->duplex = phy_vars[active_external_phy].duplex; |
| 6429 | if (params->phy[active_external_phy].supported & |
| 6430 | SUPPORTED_FIBRE) |
| 6431 | vars->link_status |= LINK_STATUS_SERDES_LINK; |
Yaniv Rosner | fd36a2e | 2011-05-31 21:29:05 +0000 | [diff] [blame] | 6432 | else |
| 6433 | vars->link_status &= ~LINK_STATUS_SERDES_LINK; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6434 | DP(NETIF_MSG_LINK, "Active external phy selected: %x\n", |
| 6435 | active_external_phy); |
| 6436 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6437 | |
| 6438 | for (phy_index = EXT_PHY1; phy_index < params->num_phys; |
| 6439 | phy_index++) { |
| 6440 | if (params->phy[phy_index].flags & |
| 6441 | FLAGS_REARM_LATCH_SIGNAL) { |
| 6442 | bnx2x_rearm_latch_signal(bp, port, |
| 6443 | phy_index == |
| 6444 | active_external_phy); |
| 6445 | break; |
| 6446 | } |
| 6447 | } |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6448 | DP(NETIF_MSG_LINK, "vars->flow_ctrl = 0x%x, vars->link_status = 0x%x," |
| 6449 | " ext_phy_line_speed = %d\n", vars->flow_ctrl, |
| 6450 | vars->link_status, ext_phy_line_speed); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6451 | /* |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6452 | * Upon link speed change set the NIG into drain mode. Comes to |
| 6453 | * deals with possible FIFO glitch due to clk change when speed |
| 6454 | * is decreased without link down indicator |
| 6455 | */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6456 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6457 | if (vars->phy_link_up) { |
| 6458 | if (!(SINGLE_MEDIA_DIRECT(params)) && ext_phy_link_up && |
| 6459 | (ext_phy_line_speed != vars->line_speed)) { |
| 6460 | DP(NETIF_MSG_LINK, "Internal link speed %d is" |
| 6461 | " different than the external" |
| 6462 | " link speed %d\n", vars->line_speed, |
| 6463 | ext_phy_line_speed); |
| 6464 | vars->phy_link_up = 0; |
| 6465 | } else if (prev_line_speed != vars->line_speed) { |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6466 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + params->port*4, |
| 6467 | 0); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6468 | msleep(1); |
| 6469 | } |
| 6470 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6471 | |
| 6472 | /* anything 10 and over uses the bmac */ |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6473 | link_10g_plus = (vars->line_speed >= SPEED_10000); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6474 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6475 | bnx2x_link_int_ack(params, vars, link_10g_plus); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6476 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6477 | /* |
| 6478 | * In case external phy link is up, and internal link is down |
| 6479 | * (not initialized yet probably after link initialization, it |
| 6480 | * needs to be initialized. |
| 6481 | * Note that after link down-up as result of cable plug, the xgxs |
| 6482 | * link would probably become up again without the need |
| 6483 | * initialize it |
| 6484 | */ |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6485 | if (!(SINGLE_MEDIA_DIRECT(params))) { |
| 6486 | DP(NETIF_MSG_LINK, "ext_phy_link_up = %d, int_link_up = %d," |
| 6487 | " init_preceding = %d\n", ext_phy_link_up, |
| 6488 | vars->phy_link_up, |
| 6489 | params->phy[EXT_PHY1].flags & |
| 6490 | FLAGS_INIT_XGXS_FIRST); |
| 6491 | if (!(params->phy[EXT_PHY1].flags & |
| 6492 | FLAGS_INIT_XGXS_FIRST) |
| 6493 | && ext_phy_link_up && !vars->phy_link_up) { |
| 6494 | vars->line_speed = ext_phy_line_speed; |
| 6495 | if (vars->line_speed < SPEED_1000) |
| 6496 | vars->phy_flags |= PHY_SGMII_FLAG; |
| 6497 | else |
| 6498 | vars->phy_flags &= ~PHY_SGMII_FLAG; |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 6499 | |
| 6500 | if (params->phy[INT_PHY].config_init) |
| 6501 | params->phy[INT_PHY].config_init( |
| 6502 | ¶ms->phy[INT_PHY], params, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6503 | vars); |
| 6504 | } |
| 6505 | } |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6506 | /* |
| 6507 | * Link is up only if both local phy and external phy (in case of |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 6508 | * non-direct board) are up and no fault detected on active PHY. |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6509 | */ |
| 6510 | vars->link_up = (vars->phy_link_up && |
| 6511 | (ext_phy_link_up || |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 6512 | SINGLE_MEDIA_DIRECT(params)) && |
| 6513 | (phy_vars[active_external_phy].fault_detected == 0)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6514 | |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6515 | if (vars->link_up) |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6516 | rc = bnx2x_update_link_up(params, vars, link_10g_plus); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6517 | else |
| 6518 | rc = bnx2x_update_link_down(params, vars); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6519 | |
| 6520 | return rc; |
| 6521 | } |
| 6522 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6523 | |
| 6524 | /*****************************************************************************/ |
| 6525 | /* External Phy section */ |
| 6526 | /*****************************************************************************/ |
| 6527 | void bnx2x_ext_phy_hw_reset(struct bnx2x *bp, u8 port) |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6528 | { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6529 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6530 | MISC_REGISTERS_GPIO_OUTPUT_LOW, port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6531 | msleep(1); |
| 6532 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6533 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, port); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6534 | } |
| 6535 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6536 | static void bnx2x_save_spirom_version(struct bnx2x *bp, u8 port, |
| 6537 | u32 spirom_ver, u32 ver_addr) |
| 6538 | { |
| 6539 | DP(NETIF_MSG_LINK, "FW version 0x%x:0x%x for port %d\n", |
| 6540 | (u16)(spirom_ver>>16), (u16)spirom_ver, port); |
| 6541 | |
| 6542 | if (ver_addr) |
| 6543 | REG_WR(bp, ver_addr, spirom_ver); |
| 6544 | } |
| 6545 | |
| 6546 | static void bnx2x_save_bcm_spirom_ver(struct bnx2x *bp, |
| 6547 | struct bnx2x_phy *phy, |
| 6548 | u8 port) |
| 6549 | { |
| 6550 | u16 fw_ver1, fw_ver2; |
| 6551 | |
| 6552 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6553 | MDIO_PMA_REG_ROM_VER1, &fw_ver1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6554 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6555 | MDIO_PMA_REG_ROM_VER2, &fw_ver2); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6556 | bnx2x_save_spirom_version(bp, port, (u32)(fw_ver1<<16 | fw_ver2), |
| 6557 | phy->ver_addr); |
| 6558 | } |
| 6559 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6560 | static void bnx2x_ext_phy_10G_an_resolve(struct bnx2x *bp, |
| 6561 | struct bnx2x_phy *phy, |
| 6562 | struct link_vars *vars) |
| 6563 | { |
| 6564 | u16 val; |
| 6565 | bnx2x_cl45_read(bp, phy, |
| 6566 | MDIO_AN_DEVAD, |
| 6567 | MDIO_AN_REG_STATUS, &val); |
| 6568 | bnx2x_cl45_read(bp, phy, |
| 6569 | MDIO_AN_DEVAD, |
| 6570 | MDIO_AN_REG_STATUS, &val); |
| 6571 | if (val & (1<<5)) |
| 6572 | vars->link_status |= LINK_STATUS_AUTO_NEGOTIATE_COMPLETE; |
| 6573 | if ((val & (1<<0)) == 0) |
| 6574 | vars->link_status |= LINK_STATUS_PARALLEL_DETECTION_USED; |
| 6575 | } |
| 6576 | |
| 6577 | /******************************************************************/ |
| 6578 | /* common BCM8073/BCM8727 PHY SECTION */ |
| 6579 | /******************************************************************/ |
| 6580 | static void bnx2x_8073_resolve_fc(struct bnx2x_phy *phy, |
| 6581 | struct link_params *params, |
| 6582 | struct link_vars *vars) |
| 6583 | { |
| 6584 | struct bnx2x *bp = params->bp; |
| 6585 | if (phy->req_line_speed == SPEED_10 || |
| 6586 | phy->req_line_speed == SPEED_100) { |
| 6587 | vars->flow_ctrl = phy->req_flow_ctrl; |
| 6588 | return; |
| 6589 | } |
| 6590 | |
| 6591 | if (bnx2x_ext_phy_resolve_fc(phy, params, vars) && |
| 6592 | (vars->flow_ctrl == BNX2X_FLOW_CTRL_NONE)) { |
| 6593 | u16 pause_result; |
| 6594 | u16 ld_pause; /* local */ |
| 6595 | u16 lp_pause; /* link partner */ |
| 6596 | bnx2x_cl45_read(bp, phy, |
| 6597 | MDIO_AN_DEVAD, |
| 6598 | MDIO_AN_REG_CL37_FC_LD, &ld_pause); |
| 6599 | |
| 6600 | bnx2x_cl45_read(bp, phy, |
| 6601 | MDIO_AN_DEVAD, |
| 6602 | MDIO_AN_REG_CL37_FC_LP, &lp_pause); |
| 6603 | pause_result = (ld_pause & |
| 6604 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) >> 5; |
| 6605 | pause_result |= (lp_pause & |
| 6606 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) >> 7; |
| 6607 | |
| 6608 | bnx2x_pause_resolve(vars, pause_result); |
| 6609 | DP(NETIF_MSG_LINK, "Ext PHY CL37 pause result 0x%x\n", |
| 6610 | pause_result); |
| 6611 | } |
| 6612 | } |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6613 | static int bnx2x_8073_8727_external_rom_boot(struct bnx2x *bp, |
| 6614 | struct bnx2x_phy *phy, |
| 6615 | u8 port) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6616 | { |
Yaniv Rosner | 5c99274b | 2011-01-18 04:33:36 +0000 | [diff] [blame] | 6617 | u32 count = 0; |
| 6618 | u16 fw_ver1, fw_msgout; |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6619 | int rc = 0; |
Yaniv Rosner | 5c99274b | 2011-01-18 04:33:36 +0000 | [diff] [blame] | 6620 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6621 | /* Boot port from external ROM */ |
| 6622 | /* EDC grst */ |
| 6623 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6624 | MDIO_PMA_DEVAD, |
| 6625 | MDIO_PMA_REG_GEN_CTRL, |
| 6626 | 0x0001); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6627 | |
| 6628 | /* ucode reboot and rst */ |
| 6629 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6630 | MDIO_PMA_DEVAD, |
| 6631 | MDIO_PMA_REG_GEN_CTRL, |
| 6632 | 0x008c); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6633 | |
| 6634 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6635 | MDIO_PMA_DEVAD, |
| 6636 | MDIO_PMA_REG_MISC_CTRL1, 0x0001); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6637 | |
| 6638 | /* Reset internal microprocessor */ |
| 6639 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6640 | MDIO_PMA_DEVAD, |
| 6641 | MDIO_PMA_REG_GEN_CTRL, |
| 6642 | MDIO_PMA_REG_GEN_CTRL_ROM_MICRO_RESET); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6643 | |
| 6644 | /* Release srst bit */ |
| 6645 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6646 | MDIO_PMA_DEVAD, |
| 6647 | MDIO_PMA_REG_GEN_CTRL, |
| 6648 | MDIO_PMA_REG_GEN_CTRL_ROM_RESET_INTERNAL_MP); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6649 | |
Yaniv Rosner | 5c99274b | 2011-01-18 04:33:36 +0000 | [diff] [blame] | 6650 | /* Delay 100ms per the PHY specifications */ |
| 6651 | msleep(100); |
| 6652 | |
| 6653 | /* 8073 sometimes taking longer to download */ |
| 6654 | do { |
| 6655 | count++; |
| 6656 | if (count > 300) { |
| 6657 | DP(NETIF_MSG_LINK, |
| 6658 | "bnx2x_8073_8727_external_rom_boot port %x:" |
| 6659 | "Download failed. fw version = 0x%x\n", |
| 6660 | port, fw_ver1); |
| 6661 | rc = -EINVAL; |
| 6662 | break; |
| 6663 | } |
| 6664 | |
| 6665 | bnx2x_cl45_read(bp, phy, |
| 6666 | MDIO_PMA_DEVAD, |
| 6667 | MDIO_PMA_REG_ROM_VER1, &fw_ver1); |
| 6668 | bnx2x_cl45_read(bp, phy, |
| 6669 | MDIO_PMA_DEVAD, |
| 6670 | MDIO_PMA_REG_M8051_MSGOUT_REG, &fw_msgout); |
| 6671 | |
| 6672 | msleep(1); |
| 6673 | } while (fw_ver1 == 0 || fw_ver1 == 0x4321 || |
| 6674 | ((fw_msgout & 0xff) != 0x03 && (phy->type == |
| 6675 | PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073))); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6676 | |
| 6677 | /* Clear ser_boot_ctl bit */ |
| 6678 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6679 | MDIO_PMA_DEVAD, |
| 6680 | MDIO_PMA_REG_MISC_CTRL1, 0x0000); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6681 | bnx2x_save_bcm_spirom_ver(bp, phy, port); |
Yaniv Rosner | 5c99274b | 2011-01-18 04:33:36 +0000 | [diff] [blame] | 6682 | |
| 6683 | DP(NETIF_MSG_LINK, |
| 6684 | "bnx2x_8073_8727_external_rom_boot port %x:" |
| 6685 | "Download complete. fw version = 0x%x\n", |
| 6686 | port, fw_ver1); |
| 6687 | |
| 6688 | return rc; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6689 | } |
| 6690 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6691 | /******************************************************************/ |
| 6692 | /* BCM8073 PHY SECTION */ |
| 6693 | /******************************************************************/ |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6694 | static int bnx2x_8073_is_snr_needed(struct bnx2x *bp, struct bnx2x_phy *phy) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6695 | { |
| 6696 | /* This is only required for 8073A1, version 102 only */ |
| 6697 | u16 val; |
| 6698 | |
| 6699 | /* Read 8073 HW revision*/ |
| 6700 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6701 | MDIO_PMA_DEVAD, |
| 6702 | MDIO_PMA_REG_8073_CHIP_REV, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6703 | |
| 6704 | if (val != 1) { |
| 6705 | /* No need to workaround in 8073 A1 */ |
| 6706 | return 0; |
| 6707 | } |
| 6708 | |
| 6709 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6710 | MDIO_PMA_DEVAD, |
| 6711 | MDIO_PMA_REG_ROM_VER2, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6712 | |
| 6713 | /* SNR should be applied only for version 0x102 */ |
| 6714 | if (val != 0x102) |
| 6715 | return 0; |
| 6716 | |
| 6717 | return 1; |
| 6718 | } |
| 6719 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6720 | static int bnx2x_8073_xaui_wa(struct bnx2x *bp, struct bnx2x_phy *phy) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6721 | { |
| 6722 | u16 val, cnt, cnt1 ; |
| 6723 | |
| 6724 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6725 | MDIO_PMA_DEVAD, |
| 6726 | MDIO_PMA_REG_8073_CHIP_REV, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6727 | |
| 6728 | if (val > 0) { |
| 6729 | /* No need to workaround in 8073 A1 */ |
| 6730 | return 0; |
| 6731 | } |
| 6732 | /* XAUI workaround in 8073 A0: */ |
| 6733 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6734 | /* |
| 6735 | * After loading the boot ROM and restarting Autoneg, poll |
| 6736 | * Dev1, Reg $C820: |
| 6737 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6738 | |
| 6739 | for (cnt = 0; cnt < 1000; cnt++) { |
| 6740 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6741 | MDIO_PMA_DEVAD, |
| 6742 | MDIO_PMA_REG_8073_SPEED_LINK_STATUS, |
| 6743 | &val); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6744 | /* |
| 6745 | * If bit [14] = 0 or bit [13] = 0, continue on with |
| 6746 | * system initialization (XAUI work-around not required, as |
| 6747 | * these bits indicate 2.5G or 1G link up). |
| 6748 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6749 | if (!(val & (1<<14)) || !(val & (1<<13))) { |
| 6750 | DP(NETIF_MSG_LINK, "XAUI work-around not required\n"); |
| 6751 | return 0; |
| 6752 | } else if (!(val & (1<<15))) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6753 | DP(NETIF_MSG_LINK, "bit 15 went off\n"); |
| 6754 | /* |
| 6755 | * If bit 15 is 0, then poll Dev1, Reg $C841 until it's |
| 6756 | * MSB (bit15) goes to 1 (indicating that the XAUI |
| 6757 | * workaround has completed), then continue on with |
| 6758 | * system initialization. |
| 6759 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6760 | for (cnt1 = 0; cnt1 < 1000; cnt1++) { |
| 6761 | bnx2x_cl45_read(bp, phy, |
| 6762 | MDIO_PMA_DEVAD, |
| 6763 | MDIO_PMA_REG_8073_XAUI_WA, &val); |
| 6764 | if (val & (1<<15)) { |
| 6765 | DP(NETIF_MSG_LINK, |
| 6766 | "XAUI workaround has completed\n"); |
| 6767 | return 0; |
| 6768 | } |
| 6769 | msleep(3); |
| 6770 | } |
| 6771 | break; |
| 6772 | } |
| 6773 | msleep(3); |
| 6774 | } |
| 6775 | DP(NETIF_MSG_LINK, "Warning: XAUI work-around timeout !!!\n"); |
| 6776 | return -EINVAL; |
| 6777 | } |
| 6778 | |
| 6779 | static void bnx2x_807x_force_10G(struct bnx2x *bp, struct bnx2x_phy *phy) |
| 6780 | { |
| 6781 | /* Force KR or KX */ |
| 6782 | bnx2x_cl45_write(bp, phy, |
| 6783 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 0x2040); |
| 6784 | bnx2x_cl45_write(bp, phy, |
| 6785 | MDIO_PMA_DEVAD, MDIO_PMA_REG_10G_CTRL2, 0x000b); |
| 6786 | bnx2x_cl45_write(bp, phy, |
| 6787 | MDIO_PMA_DEVAD, MDIO_PMA_REG_BCM_CTRL, 0x0000); |
| 6788 | bnx2x_cl45_write(bp, phy, |
| 6789 | MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, 0x0000); |
| 6790 | } |
| 6791 | |
| 6792 | static void bnx2x_8073_set_pause_cl37(struct link_params *params, |
| 6793 | struct bnx2x_phy *phy, |
| 6794 | struct link_vars *vars) |
| 6795 | { |
| 6796 | u16 cl37_val; |
| 6797 | struct bnx2x *bp = params->bp; |
| 6798 | bnx2x_cl45_read(bp, phy, |
| 6799 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_FC_LD, &cl37_val); |
| 6800 | |
| 6801 | cl37_val &= ~MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH; |
| 6802 | /* Please refer to Table 28B-3 of 802.3ab-1999 spec. */ |
| 6803 | bnx2x_calc_ieee_aneg_adv(phy, params, &vars->ieee_fc); |
| 6804 | if ((vars->ieee_fc & |
| 6805 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_SYMMETRIC) == |
| 6806 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_SYMMETRIC) { |
| 6807 | cl37_val |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_SYMMETRIC; |
| 6808 | } |
| 6809 | if ((vars->ieee_fc & |
| 6810 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC) == |
| 6811 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC) { |
| 6812 | cl37_val |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC; |
| 6813 | } |
| 6814 | if ((vars->ieee_fc & |
| 6815 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) == |
| 6816 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) { |
| 6817 | cl37_val |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH; |
| 6818 | } |
| 6819 | DP(NETIF_MSG_LINK, |
| 6820 | "Ext phy AN advertize cl37 0x%x\n", cl37_val); |
| 6821 | |
| 6822 | bnx2x_cl45_write(bp, phy, |
| 6823 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_FC_LD, cl37_val); |
| 6824 | msleep(500); |
| 6825 | } |
| 6826 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6827 | static int bnx2x_8073_config_init(struct bnx2x_phy *phy, |
| 6828 | struct link_params *params, |
| 6829 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6830 | { |
| 6831 | struct bnx2x *bp = params->bp; |
| 6832 | u16 val = 0, tmp1; |
| 6833 | u8 gpio_port; |
| 6834 | DP(NETIF_MSG_LINK, "Init 8073\n"); |
| 6835 | |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 6836 | if (CHIP_IS_E2(bp)) |
| 6837 | gpio_port = BP_PATH(bp); |
| 6838 | else |
| 6839 | gpio_port = params->port; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6840 | /* Restore normal power mode*/ |
| 6841 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6842 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, gpio_port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6843 | |
| 6844 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6845 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, gpio_port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6846 | |
| 6847 | /* enable LASI */ |
| 6848 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 6849 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_RXCTRL, (1<<2)); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6850 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 6851 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_CTRL, 0x0004); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6852 | |
| 6853 | bnx2x_8073_set_pause_cl37(params, phy, vars); |
| 6854 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6855 | bnx2x_cl45_read(bp, phy, |
| 6856 | MDIO_PMA_DEVAD, MDIO_PMA_REG_M8051_MSGOUT_REG, &tmp1); |
| 6857 | |
| 6858 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 6859 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_RXSTAT, &tmp1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6860 | |
| 6861 | DP(NETIF_MSG_LINK, "Before rom RX_ALARM(port1): 0x%x\n", tmp1); |
| 6862 | |
Yaniv Rosner | 74d7a11 | 2011-01-18 04:33:18 +0000 | [diff] [blame] | 6863 | /* Swap polarity if required - Must be done only in non-1G mode */ |
| 6864 | if (params->lane_config & PORT_HW_CFG_SWAP_PHY_POLARITY_ENABLED) { |
| 6865 | /* Configure the 8073 to swap _P and _N of the KR lines */ |
| 6866 | DP(NETIF_MSG_LINK, "Swapping polarity for the 8073\n"); |
| 6867 | /* 10G Rx/Tx and 1G Tx signal polarity swap */ |
| 6868 | bnx2x_cl45_read(bp, phy, |
| 6869 | MDIO_PMA_DEVAD, |
| 6870 | MDIO_PMA_REG_8073_OPT_DIGITAL_CTRL, &val); |
| 6871 | bnx2x_cl45_write(bp, phy, |
| 6872 | MDIO_PMA_DEVAD, |
| 6873 | MDIO_PMA_REG_8073_OPT_DIGITAL_CTRL, |
| 6874 | (val | (3<<9))); |
| 6875 | } |
| 6876 | |
| 6877 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6878 | /* Enable CL37 BAM */ |
Yaniv Rosner | 121839b | 2010-11-01 05:32:38 +0000 | [diff] [blame] | 6879 | if (REG_RD(bp, params->shmem_base + |
| 6880 | offsetof(struct shmem_region, dev_info. |
| 6881 | port_hw_config[params->port].default_cfg)) & |
| 6882 | PORT_HW_CFG_ENABLE_BAM_ON_KR_ENABLED) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6883 | |
Yaniv Rosner | 121839b | 2010-11-01 05:32:38 +0000 | [diff] [blame] | 6884 | bnx2x_cl45_read(bp, phy, |
| 6885 | MDIO_AN_DEVAD, |
| 6886 | MDIO_AN_REG_8073_BAM, &val); |
| 6887 | bnx2x_cl45_write(bp, phy, |
| 6888 | MDIO_AN_DEVAD, |
| 6889 | MDIO_AN_REG_8073_BAM, val | 1); |
| 6890 | DP(NETIF_MSG_LINK, "Enable CL37 BAM on KR\n"); |
| 6891 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6892 | if (params->loopback_mode == LOOPBACK_EXT) { |
| 6893 | bnx2x_807x_force_10G(bp, phy); |
| 6894 | DP(NETIF_MSG_LINK, "Forced speed 10G on 807X\n"); |
| 6895 | return 0; |
| 6896 | } else { |
| 6897 | bnx2x_cl45_write(bp, phy, |
| 6898 | MDIO_PMA_DEVAD, MDIO_PMA_REG_BCM_CTRL, 0x0002); |
| 6899 | } |
| 6900 | if (phy->req_line_speed != SPEED_AUTO_NEG) { |
| 6901 | if (phy->req_line_speed == SPEED_10000) { |
| 6902 | val = (1<<7); |
| 6903 | } else if (phy->req_line_speed == SPEED_2500) { |
| 6904 | val = (1<<5); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6905 | /* |
| 6906 | * Note that 2.5G works only when used with 1G |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 6907 | * advertisement |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6908 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6909 | } else |
| 6910 | val = (1<<5); |
| 6911 | } else { |
| 6912 | val = 0; |
| 6913 | if (phy->speed_cap_mask & |
| 6914 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G) |
| 6915 | val |= (1<<7); |
| 6916 | |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 6917 | /* Note that 2.5G works only when used with 1G advertisement */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6918 | if (phy->speed_cap_mask & |
| 6919 | (PORT_HW_CFG_SPEED_CAPABILITY_D0_1G | |
| 6920 | PORT_HW_CFG_SPEED_CAPABILITY_D0_2_5G)) |
| 6921 | val |= (1<<5); |
| 6922 | DP(NETIF_MSG_LINK, "807x autoneg val = 0x%x\n", val); |
| 6923 | } |
| 6924 | |
| 6925 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_ADV, val); |
| 6926 | bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_8073_2_5G, &tmp1); |
| 6927 | |
| 6928 | if (((phy->speed_cap_mask & PORT_HW_CFG_SPEED_CAPABILITY_D0_2_5G) && |
| 6929 | (phy->req_line_speed == SPEED_AUTO_NEG)) || |
| 6930 | (phy->req_line_speed == SPEED_2500)) { |
| 6931 | u16 phy_ver; |
| 6932 | /* Allow 2.5G for A1 and above */ |
| 6933 | bnx2x_cl45_read(bp, phy, |
| 6934 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8073_CHIP_REV, |
| 6935 | &phy_ver); |
| 6936 | DP(NETIF_MSG_LINK, "Add 2.5G\n"); |
| 6937 | if (phy_ver > 0) |
| 6938 | tmp1 |= 1; |
| 6939 | else |
| 6940 | tmp1 &= 0xfffe; |
| 6941 | } else { |
| 6942 | DP(NETIF_MSG_LINK, "Disable 2.5G\n"); |
| 6943 | tmp1 &= 0xfffe; |
| 6944 | } |
| 6945 | |
| 6946 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_8073_2_5G, tmp1); |
| 6947 | /* Add support for CL37 (passive mode) II */ |
| 6948 | |
| 6949 | bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_CL37_FC_LD, &tmp1); |
| 6950 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_CL37_FC_LD, |
| 6951 | (tmp1 | ((phy->req_duplex == DUPLEX_FULL) ? |
| 6952 | 0x20 : 0x40))); |
| 6953 | |
| 6954 | /* Add support for CL37 (passive mode) III */ |
| 6955 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_CL37_AN, 0x1000); |
| 6956 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6957 | /* |
| 6958 | * The SNR will improve about 2db by changing BW and FEE main |
| 6959 | * tap. Rest commands are executed after link is up |
| 6960 | * Change FFE main cursor to 5 in EDC register |
| 6961 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6962 | if (bnx2x_8073_is_snr_needed(bp, phy)) |
| 6963 | bnx2x_cl45_write(bp, phy, |
| 6964 | MDIO_PMA_DEVAD, MDIO_PMA_REG_EDC_FFE_MAIN, |
| 6965 | 0xFB0C); |
| 6966 | |
| 6967 | /* Enable FEC (Forware Error Correction) Request in the AN */ |
| 6968 | bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_ADV2, &tmp1); |
| 6969 | tmp1 |= (1<<15); |
| 6970 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_ADV2, tmp1); |
| 6971 | |
| 6972 | bnx2x_ext_phy_set_pause(params, phy, vars); |
| 6973 | |
| 6974 | /* Restart autoneg */ |
| 6975 | msleep(500); |
| 6976 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, 0x1200); |
| 6977 | DP(NETIF_MSG_LINK, "807x Autoneg Restart: Advertise 1G=%x, 10G=%x\n", |
| 6978 | ((val & (1<<5)) > 0), ((val & (1<<7)) > 0)); |
| 6979 | return 0; |
| 6980 | } |
| 6981 | |
| 6982 | static u8 bnx2x_8073_read_status(struct bnx2x_phy *phy, |
| 6983 | struct link_params *params, |
| 6984 | struct link_vars *vars) |
| 6985 | { |
| 6986 | struct bnx2x *bp = params->bp; |
| 6987 | u8 link_up = 0; |
| 6988 | u16 val1, val2; |
| 6989 | u16 link_status = 0; |
| 6990 | u16 an1000_status = 0; |
| 6991 | |
| 6992 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 6993 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_STAT, &val1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6994 | |
| 6995 | DP(NETIF_MSG_LINK, "8703 LASI status 0x%x\n", val1); |
| 6996 | |
| 6997 | /* clear the interrupt LASI status register */ |
| 6998 | bnx2x_cl45_read(bp, phy, |
| 6999 | MDIO_PCS_DEVAD, MDIO_PCS_REG_STATUS, &val2); |
| 7000 | bnx2x_cl45_read(bp, phy, |
| 7001 | MDIO_PCS_DEVAD, MDIO_PCS_REG_STATUS, &val1); |
| 7002 | DP(NETIF_MSG_LINK, "807x PCS status 0x%x->0x%x\n", val2, val1); |
| 7003 | /* Clear MSG-OUT */ |
| 7004 | bnx2x_cl45_read(bp, phy, |
| 7005 | MDIO_PMA_DEVAD, MDIO_PMA_REG_M8051_MSGOUT_REG, &val1); |
| 7006 | |
| 7007 | /* Check the LASI */ |
| 7008 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 7009 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_RXSTAT, &val2); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7010 | |
| 7011 | DP(NETIF_MSG_LINK, "KR 0x9003 0x%x\n", val2); |
| 7012 | |
| 7013 | /* Check the link status */ |
| 7014 | bnx2x_cl45_read(bp, phy, |
| 7015 | MDIO_PCS_DEVAD, MDIO_PCS_REG_STATUS, &val2); |
| 7016 | DP(NETIF_MSG_LINK, "KR PCS status 0x%x\n", val2); |
| 7017 | |
| 7018 | bnx2x_cl45_read(bp, phy, |
| 7019 | MDIO_PMA_DEVAD, MDIO_PMA_REG_STATUS, &val2); |
| 7020 | bnx2x_cl45_read(bp, phy, |
| 7021 | MDIO_PMA_DEVAD, MDIO_PMA_REG_STATUS, &val1); |
| 7022 | link_up = ((val1 & 4) == 4); |
| 7023 | DP(NETIF_MSG_LINK, "PMA_REG_STATUS=0x%x\n", val1); |
| 7024 | |
| 7025 | if (link_up && |
| 7026 | ((phy->req_line_speed != SPEED_10000))) { |
| 7027 | if (bnx2x_8073_xaui_wa(bp, phy) != 0) |
| 7028 | return 0; |
| 7029 | } |
| 7030 | bnx2x_cl45_read(bp, phy, |
| 7031 | MDIO_AN_DEVAD, MDIO_AN_REG_LINK_STATUS, &an1000_status); |
| 7032 | bnx2x_cl45_read(bp, phy, |
| 7033 | MDIO_AN_DEVAD, MDIO_AN_REG_LINK_STATUS, &an1000_status); |
| 7034 | |
| 7035 | /* Check the link status on 1.1.2 */ |
| 7036 | bnx2x_cl45_read(bp, phy, |
| 7037 | MDIO_PMA_DEVAD, MDIO_PMA_REG_STATUS, &val2); |
| 7038 | bnx2x_cl45_read(bp, phy, |
| 7039 | MDIO_PMA_DEVAD, MDIO_PMA_REG_STATUS, &val1); |
| 7040 | DP(NETIF_MSG_LINK, "KR PMA status 0x%x->0x%x," |
| 7041 | "an_link_status=0x%x\n", val2, val1, an1000_status); |
| 7042 | |
| 7043 | link_up = (((val1 & 4) == 4) || (an1000_status & (1<<1))); |
| 7044 | if (link_up && bnx2x_8073_is_snr_needed(bp, phy)) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7045 | /* |
| 7046 | * The SNR will improve about 2dbby changing the BW and FEE main |
| 7047 | * tap. The 1st write to change FFE main tap is set before |
| 7048 | * restart AN. Change PLL Bandwidth in EDC register |
| 7049 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7050 | bnx2x_cl45_write(bp, phy, |
| 7051 | MDIO_PMA_DEVAD, MDIO_PMA_REG_PLL_BANDWIDTH, |
| 7052 | 0x26BC); |
| 7053 | |
| 7054 | /* Change CDR Bandwidth in EDC register */ |
| 7055 | bnx2x_cl45_write(bp, phy, |
| 7056 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CDR_BANDWIDTH, |
| 7057 | 0x0333); |
| 7058 | } |
| 7059 | bnx2x_cl45_read(bp, phy, |
| 7060 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8073_SPEED_LINK_STATUS, |
| 7061 | &link_status); |
| 7062 | |
| 7063 | /* Bits 0..2 --> speed detected, bits 13..15--> link is down */ |
| 7064 | if ((link_status & (1<<2)) && (!(link_status & (1<<15)))) { |
| 7065 | link_up = 1; |
| 7066 | vars->line_speed = SPEED_10000; |
| 7067 | DP(NETIF_MSG_LINK, "port %x: External link up in 10G\n", |
| 7068 | params->port); |
| 7069 | } else if ((link_status & (1<<1)) && (!(link_status & (1<<14)))) { |
| 7070 | link_up = 1; |
| 7071 | vars->line_speed = SPEED_2500; |
| 7072 | DP(NETIF_MSG_LINK, "port %x: External link up in 2.5G\n", |
| 7073 | params->port); |
| 7074 | } else if ((link_status & (1<<0)) && (!(link_status & (1<<13)))) { |
| 7075 | link_up = 1; |
| 7076 | vars->line_speed = SPEED_1000; |
| 7077 | DP(NETIF_MSG_LINK, "port %x: External link up in 1G\n", |
| 7078 | params->port); |
| 7079 | } else { |
| 7080 | link_up = 0; |
| 7081 | DP(NETIF_MSG_LINK, "port %x: External link is down\n", |
| 7082 | params->port); |
| 7083 | } |
| 7084 | |
| 7085 | if (link_up) { |
Yaniv Rosner | 74d7a11 | 2011-01-18 04:33:18 +0000 | [diff] [blame] | 7086 | /* Swap polarity if required */ |
| 7087 | if (params->lane_config & |
| 7088 | PORT_HW_CFG_SWAP_PHY_POLARITY_ENABLED) { |
| 7089 | /* Configure the 8073 to swap P and N of the KR lines */ |
| 7090 | bnx2x_cl45_read(bp, phy, |
| 7091 | MDIO_XS_DEVAD, |
| 7092 | MDIO_XS_REG_8073_RX_CTRL_PCIE, &val1); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7093 | /* |
| 7094 | * Set bit 3 to invert Rx in 1G mode and clear this bit |
| 7095 | * when it`s in 10G mode. |
| 7096 | */ |
Yaniv Rosner | 74d7a11 | 2011-01-18 04:33:18 +0000 | [diff] [blame] | 7097 | if (vars->line_speed == SPEED_1000) { |
| 7098 | DP(NETIF_MSG_LINK, "Swapping 1G polarity for" |
| 7099 | "the 8073\n"); |
| 7100 | val1 |= (1<<3); |
| 7101 | } else |
| 7102 | val1 &= ~(1<<3); |
| 7103 | |
| 7104 | bnx2x_cl45_write(bp, phy, |
| 7105 | MDIO_XS_DEVAD, |
| 7106 | MDIO_XS_REG_8073_RX_CTRL_PCIE, |
| 7107 | val1); |
| 7108 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7109 | bnx2x_ext_phy_10G_an_resolve(bp, phy, vars); |
| 7110 | bnx2x_8073_resolve_fc(phy, params, vars); |
Yaniv Rosner | 791f18c | 2011-01-18 04:33:42 +0000 | [diff] [blame] | 7111 | vars->duplex = DUPLEX_FULL; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7112 | } |
| 7113 | return link_up; |
| 7114 | } |
| 7115 | |
| 7116 | static void bnx2x_8073_link_reset(struct bnx2x_phy *phy, |
| 7117 | struct link_params *params) |
| 7118 | { |
| 7119 | struct bnx2x *bp = params->bp; |
| 7120 | u8 gpio_port; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 7121 | if (CHIP_IS_E2(bp)) |
| 7122 | gpio_port = BP_PATH(bp); |
| 7123 | else |
| 7124 | gpio_port = params->port; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7125 | DP(NETIF_MSG_LINK, "Setting 8073 port %d into low power mode\n", |
| 7126 | gpio_port); |
| 7127 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7128 | MISC_REGISTERS_GPIO_OUTPUT_LOW, |
| 7129 | gpio_port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7130 | } |
| 7131 | |
| 7132 | /******************************************************************/ |
| 7133 | /* BCM8705 PHY SECTION */ |
| 7134 | /******************************************************************/ |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 7135 | static int bnx2x_8705_config_init(struct bnx2x_phy *phy, |
| 7136 | struct link_params *params, |
| 7137 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7138 | { |
| 7139 | struct bnx2x *bp = params->bp; |
| 7140 | DP(NETIF_MSG_LINK, "init 8705\n"); |
| 7141 | /* Restore normal power mode*/ |
| 7142 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7143 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, params->port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7144 | /* HW reset */ |
| 7145 | bnx2x_ext_phy_hw_reset(bp, params->port); |
| 7146 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 0xa040); |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 7147 | bnx2x_wait_reset_complete(bp, phy, params); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7148 | |
| 7149 | bnx2x_cl45_write(bp, phy, |
| 7150 | MDIO_PMA_DEVAD, MDIO_PMA_REG_MISC_CTRL, 0x8288); |
| 7151 | bnx2x_cl45_write(bp, phy, |
| 7152 | MDIO_PMA_DEVAD, MDIO_PMA_REG_PHY_IDENTIFIER, 0x7fbf); |
| 7153 | bnx2x_cl45_write(bp, phy, |
| 7154 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CMU_PLL_BYPASS, 0x0100); |
| 7155 | bnx2x_cl45_write(bp, phy, |
| 7156 | MDIO_WIS_DEVAD, MDIO_WIS_REG_LASI_CNTL, 0x1); |
| 7157 | /* BCM8705 doesn't have microcode, hence the 0 */ |
| 7158 | bnx2x_save_spirom_version(bp, params->port, params->shmem_base, 0); |
| 7159 | return 0; |
| 7160 | } |
| 7161 | |
| 7162 | static u8 bnx2x_8705_read_status(struct bnx2x_phy *phy, |
| 7163 | struct link_params *params, |
| 7164 | struct link_vars *vars) |
| 7165 | { |
| 7166 | u8 link_up = 0; |
| 7167 | u16 val1, rx_sd; |
| 7168 | struct bnx2x *bp = params->bp; |
| 7169 | DP(NETIF_MSG_LINK, "read status 8705\n"); |
| 7170 | bnx2x_cl45_read(bp, phy, |
| 7171 | MDIO_WIS_DEVAD, MDIO_WIS_REG_LASI_STATUS, &val1); |
| 7172 | DP(NETIF_MSG_LINK, "8705 LASI status 0x%x\n", val1); |
| 7173 | |
| 7174 | bnx2x_cl45_read(bp, phy, |
| 7175 | MDIO_WIS_DEVAD, MDIO_WIS_REG_LASI_STATUS, &val1); |
| 7176 | DP(NETIF_MSG_LINK, "8705 LASI status 0x%x\n", val1); |
| 7177 | |
| 7178 | bnx2x_cl45_read(bp, phy, |
| 7179 | MDIO_PMA_DEVAD, MDIO_PMA_REG_RX_SD, &rx_sd); |
| 7180 | |
| 7181 | bnx2x_cl45_read(bp, phy, |
| 7182 | MDIO_PMA_DEVAD, 0xc809, &val1); |
| 7183 | bnx2x_cl45_read(bp, phy, |
| 7184 | MDIO_PMA_DEVAD, 0xc809, &val1); |
| 7185 | |
| 7186 | DP(NETIF_MSG_LINK, "8705 1.c809 val=0x%x\n", val1); |
| 7187 | link_up = ((rx_sd & 0x1) && (val1 & (1<<9)) && ((val1 & (1<<8)) == 0)); |
| 7188 | if (link_up) { |
| 7189 | vars->line_speed = SPEED_10000; |
| 7190 | bnx2x_ext_phy_resolve_fc(phy, params, vars); |
| 7191 | } |
| 7192 | return link_up; |
| 7193 | } |
| 7194 | |
| 7195 | /******************************************************************/ |
| 7196 | /* SFP+ module Section */ |
| 7197 | /******************************************************************/ |
Yaniv Rosner | 85242ee | 2011-07-05 01:06:53 +0000 | [diff] [blame] | 7198 | static void bnx2x_set_disable_pmd_transmit(struct link_params *params, |
| 7199 | struct bnx2x_phy *phy, |
| 7200 | u8 pmd_dis) |
| 7201 | { |
| 7202 | struct bnx2x *bp = params->bp; |
| 7203 | /* |
| 7204 | * Disable transmitter only for bootcodes which can enable it afterwards |
| 7205 | * (for D3 link) |
| 7206 | */ |
| 7207 | if (pmd_dis) { |
| 7208 | if (params->feature_config_flags & |
| 7209 | FEATURE_CONFIG_BC_SUPPORTS_SFP_TX_DISABLED) |
| 7210 | DP(NETIF_MSG_LINK, "Disabling PMD transmitter\n"); |
| 7211 | else { |
| 7212 | DP(NETIF_MSG_LINK, "NOT disabling PMD transmitter\n"); |
| 7213 | return; |
| 7214 | } |
| 7215 | } else |
| 7216 | DP(NETIF_MSG_LINK, "Enabling PMD transmitter\n"); |
| 7217 | bnx2x_cl45_write(bp, phy, |
| 7218 | MDIO_PMA_DEVAD, |
| 7219 | MDIO_PMA_REG_TX_DISABLE, pmd_dis); |
| 7220 | } |
| 7221 | |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 7222 | static u8 bnx2x_get_gpio_port(struct link_params *params) |
| 7223 | { |
| 7224 | u8 gpio_port; |
| 7225 | u32 swap_val, swap_override; |
| 7226 | struct bnx2x *bp = params->bp; |
| 7227 | if (CHIP_IS_E2(bp)) |
| 7228 | gpio_port = BP_PATH(bp); |
| 7229 | else |
| 7230 | gpio_port = params->port; |
| 7231 | swap_val = REG_RD(bp, NIG_REG_PORT_SWAP); |
| 7232 | swap_override = REG_RD(bp, NIG_REG_STRAP_OVERRIDE); |
| 7233 | return gpio_port ^ (swap_val && swap_override); |
| 7234 | } |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 7235 | |
| 7236 | static void bnx2x_sfp_e1e2_set_transmitter(struct link_params *params, |
| 7237 | struct bnx2x_phy *phy, |
| 7238 | u8 tx_en) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7239 | { |
| 7240 | u16 val; |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 7241 | u8 port = params->port; |
| 7242 | struct bnx2x *bp = params->bp; |
| 7243 | u32 tx_en_mode; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7244 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7245 | /* Disable/Enable transmitter ( TX laser of the SFP+ module.)*/ |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 7246 | tx_en_mode = REG_RD(bp, params->shmem_base + |
| 7247 | offsetof(struct shmem_region, |
| 7248 | dev_info.port_hw_config[port].sfp_ctrl)) & |
| 7249 | PORT_HW_CFG_TX_LASER_MASK; |
| 7250 | DP(NETIF_MSG_LINK, "Setting transmitter tx_en=%x for port %x " |
| 7251 | "mode = %x\n", tx_en, port, tx_en_mode); |
| 7252 | switch (tx_en_mode) { |
| 7253 | case PORT_HW_CFG_TX_LASER_MDIO: |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7254 | |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 7255 | bnx2x_cl45_read(bp, phy, |
| 7256 | MDIO_PMA_DEVAD, |
| 7257 | MDIO_PMA_REG_PHY_IDENTIFIER, |
| 7258 | &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7259 | |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 7260 | if (tx_en) |
| 7261 | val &= ~(1<<15); |
| 7262 | else |
| 7263 | val |= (1<<15); |
| 7264 | |
| 7265 | bnx2x_cl45_write(bp, phy, |
| 7266 | MDIO_PMA_DEVAD, |
| 7267 | MDIO_PMA_REG_PHY_IDENTIFIER, |
| 7268 | val); |
| 7269 | break; |
| 7270 | case PORT_HW_CFG_TX_LASER_GPIO0: |
| 7271 | case PORT_HW_CFG_TX_LASER_GPIO1: |
| 7272 | case PORT_HW_CFG_TX_LASER_GPIO2: |
| 7273 | case PORT_HW_CFG_TX_LASER_GPIO3: |
| 7274 | { |
| 7275 | u16 gpio_pin; |
| 7276 | u8 gpio_port, gpio_mode; |
| 7277 | if (tx_en) |
| 7278 | gpio_mode = MISC_REGISTERS_GPIO_OUTPUT_HIGH; |
| 7279 | else |
| 7280 | gpio_mode = MISC_REGISTERS_GPIO_OUTPUT_LOW; |
| 7281 | |
| 7282 | gpio_pin = tx_en_mode - PORT_HW_CFG_TX_LASER_GPIO0; |
| 7283 | gpio_port = bnx2x_get_gpio_port(params); |
| 7284 | bnx2x_set_gpio(bp, gpio_pin, gpio_mode, gpio_port); |
| 7285 | break; |
| 7286 | } |
| 7287 | default: |
| 7288 | DP(NETIF_MSG_LINK, "Invalid TX_LASER_MDIO 0x%x\n", tx_en_mode); |
| 7289 | break; |
| 7290 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7291 | } |
| 7292 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 7293 | static void bnx2x_sfp_set_transmitter(struct link_params *params, |
| 7294 | struct bnx2x_phy *phy, |
| 7295 | u8 tx_en) |
| 7296 | { |
| 7297 | struct bnx2x *bp = params->bp; |
| 7298 | DP(NETIF_MSG_LINK, "Setting SFP+ transmitter to %d\n", tx_en); |
| 7299 | if (CHIP_IS_E3(bp)) |
| 7300 | bnx2x_sfp_e3_set_transmitter(params, phy, tx_en); |
| 7301 | else |
| 7302 | bnx2x_sfp_e1e2_set_transmitter(params, phy, tx_en); |
| 7303 | } |
| 7304 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 7305 | static int bnx2x_8726_read_sfp_module_eeprom(struct bnx2x_phy *phy, |
| 7306 | struct link_params *params, |
| 7307 | u16 addr, u8 byte_cnt, u8 *o_buf) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7308 | { |
| 7309 | struct bnx2x *bp = params->bp; |
| 7310 | u16 val = 0; |
| 7311 | u16 i; |
| 7312 | if (byte_cnt > 16) { |
| 7313 | DP(NETIF_MSG_LINK, "Reading from eeprom is" |
| 7314 | " is limited to 0xf\n"); |
| 7315 | return -EINVAL; |
| 7316 | } |
| 7317 | /* Set the read command byte count */ |
| 7318 | bnx2x_cl45_write(bp, phy, |
| 7319 | MDIO_PMA_DEVAD, MDIO_PMA_REG_SFP_TWO_WIRE_BYTE_CNT, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7320 | (byte_cnt | 0xa000)); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7321 | |
| 7322 | /* Set the read command address */ |
| 7323 | bnx2x_cl45_write(bp, phy, |
| 7324 | MDIO_PMA_DEVAD, MDIO_PMA_REG_SFP_TWO_WIRE_MEM_ADDR, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7325 | addr); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7326 | |
| 7327 | /* Activate read command */ |
| 7328 | bnx2x_cl45_write(bp, phy, |
| 7329 | MDIO_PMA_DEVAD, MDIO_PMA_REG_SFP_TWO_WIRE_CTRL, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7330 | 0x2c0f); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7331 | |
| 7332 | /* Wait up to 500us for command complete status */ |
| 7333 | for (i = 0; i < 100; i++) { |
| 7334 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7335 | MDIO_PMA_DEVAD, |
| 7336 | MDIO_PMA_REG_SFP_TWO_WIRE_CTRL, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7337 | if ((val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK) == |
| 7338 | MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_COMPLETE) |
| 7339 | break; |
| 7340 | udelay(5); |
| 7341 | } |
| 7342 | |
| 7343 | if ((val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK) != |
| 7344 | MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_COMPLETE) { |
| 7345 | DP(NETIF_MSG_LINK, |
| 7346 | "Got bad status 0x%x when reading from SFP+ EEPROM\n", |
| 7347 | (val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK)); |
| 7348 | return -EINVAL; |
| 7349 | } |
| 7350 | |
| 7351 | /* Read the buffer */ |
| 7352 | for (i = 0; i < byte_cnt; i++) { |
| 7353 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7354 | MDIO_PMA_DEVAD, |
| 7355 | MDIO_PMA_REG_8726_TWO_WIRE_DATA_BUF + i, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7356 | o_buf[i] = (u8)(val & MDIO_PMA_REG_8726_TWO_WIRE_DATA_MASK); |
| 7357 | } |
| 7358 | |
| 7359 | for (i = 0; i < 100; i++) { |
| 7360 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7361 | MDIO_PMA_DEVAD, |
| 7362 | MDIO_PMA_REG_SFP_TWO_WIRE_CTRL, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7363 | if ((val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK) == |
| 7364 | MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_IDLE) |
Joe Perches | 6f38ad9 | 2010-11-14 17:04:31 +0000 | [diff] [blame] | 7365 | return 0; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7366 | msleep(1); |
| 7367 | } |
| 7368 | return -EINVAL; |
| 7369 | } |
| 7370 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 7371 | static int bnx2x_warpcore_read_sfp_module_eeprom(struct bnx2x_phy *phy, |
| 7372 | struct link_params *params, |
| 7373 | u16 addr, u8 byte_cnt, |
| 7374 | u8 *o_buf) |
| 7375 | { |
| 7376 | int rc = 0; |
| 7377 | u8 i, j = 0, cnt = 0; |
| 7378 | u32 data_array[4]; |
| 7379 | u16 addr32; |
| 7380 | struct bnx2x *bp = params->bp; |
| 7381 | /*DP(NETIF_MSG_LINK, "bnx2x_direct_read_sfp_module_eeprom:" |
| 7382 | " addr %d, cnt %d\n", |
| 7383 | addr, byte_cnt);*/ |
| 7384 | if (byte_cnt > 16) { |
| 7385 | DP(NETIF_MSG_LINK, "Reading from eeprom is" |
| 7386 | " is limited to 16 bytes\n"); |
| 7387 | return -EINVAL; |
| 7388 | } |
| 7389 | |
| 7390 | /* 4 byte aligned address */ |
| 7391 | addr32 = addr & (~0x3); |
| 7392 | do { |
| 7393 | rc = bnx2x_bsc_read(params, phy, 0xa0, addr32, 0, byte_cnt, |
| 7394 | data_array); |
| 7395 | } while ((rc != 0) && (++cnt < I2C_WA_RETRY_CNT)); |
| 7396 | |
| 7397 | if (rc == 0) { |
| 7398 | for (i = (addr - addr32); i < byte_cnt + (addr - addr32); i++) { |
| 7399 | o_buf[j] = *((u8 *)data_array + i); |
| 7400 | j++; |
| 7401 | } |
| 7402 | } |
| 7403 | |
| 7404 | return rc; |
| 7405 | } |
| 7406 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 7407 | static int bnx2x_8727_read_sfp_module_eeprom(struct bnx2x_phy *phy, |
| 7408 | struct link_params *params, |
| 7409 | u16 addr, u8 byte_cnt, u8 *o_buf) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7410 | { |
| 7411 | struct bnx2x *bp = params->bp; |
| 7412 | u16 val, i; |
| 7413 | |
| 7414 | if (byte_cnt > 16) { |
| 7415 | DP(NETIF_MSG_LINK, "Reading from eeprom is" |
| 7416 | " is limited to 0xf\n"); |
| 7417 | return -EINVAL; |
| 7418 | } |
| 7419 | |
| 7420 | /* Need to read from 1.8000 to clear it */ |
| 7421 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7422 | MDIO_PMA_DEVAD, |
| 7423 | MDIO_PMA_REG_SFP_TWO_WIRE_CTRL, |
| 7424 | &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7425 | |
| 7426 | /* Set the read command byte count */ |
| 7427 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7428 | MDIO_PMA_DEVAD, |
| 7429 | MDIO_PMA_REG_SFP_TWO_WIRE_BYTE_CNT, |
| 7430 | ((byte_cnt < 2) ? 2 : byte_cnt)); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7431 | |
| 7432 | /* Set the read command address */ |
| 7433 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7434 | MDIO_PMA_DEVAD, |
| 7435 | MDIO_PMA_REG_SFP_TWO_WIRE_MEM_ADDR, |
| 7436 | addr); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7437 | /* Set the destination address */ |
| 7438 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7439 | MDIO_PMA_DEVAD, |
| 7440 | 0x8004, |
| 7441 | MDIO_PMA_REG_8727_TWO_WIRE_DATA_BUF); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7442 | |
| 7443 | /* Activate read command */ |
| 7444 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7445 | MDIO_PMA_DEVAD, |
| 7446 | MDIO_PMA_REG_SFP_TWO_WIRE_CTRL, |
| 7447 | 0x8002); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7448 | /* |
| 7449 | * Wait appropriate time for two-wire command to finish before |
| 7450 | * polling the status register |
| 7451 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7452 | msleep(1); |
| 7453 | |
| 7454 | /* Wait up to 500us for command complete status */ |
| 7455 | for (i = 0; i < 100; i++) { |
| 7456 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7457 | MDIO_PMA_DEVAD, |
| 7458 | MDIO_PMA_REG_SFP_TWO_WIRE_CTRL, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7459 | if ((val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK) == |
| 7460 | MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_COMPLETE) |
| 7461 | break; |
| 7462 | udelay(5); |
| 7463 | } |
| 7464 | |
| 7465 | if ((val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK) != |
| 7466 | MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_COMPLETE) { |
| 7467 | DP(NETIF_MSG_LINK, |
| 7468 | "Got bad status 0x%x when reading from SFP+ EEPROM\n", |
| 7469 | (val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK)); |
Yaniv Rosner | 65a001b | 2011-01-31 04:22:03 +0000 | [diff] [blame] | 7470 | return -EFAULT; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7471 | } |
| 7472 | |
| 7473 | /* Read the buffer */ |
| 7474 | for (i = 0; i < byte_cnt; i++) { |
| 7475 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7476 | MDIO_PMA_DEVAD, |
| 7477 | MDIO_PMA_REG_8727_TWO_WIRE_DATA_BUF + i, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7478 | o_buf[i] = (u8)(val & MDIO_PMA_REG_8727_TWO_WIRE_DATA_MASK); |
| 7479 | } |
| 7480 | |
| 7481 | for (i = 0; i < 100; i++) { |
| 7482 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7483 | MDIO_PMA_DEVAD, |
| 7484 | MDIO_PMA_REG_SFP_TWO_WIRE_CTRL, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7485 | if ((val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK) == |
| 7486 | MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_IDLE) |
Joe Perches | 6f38ad9 | 2010-11-14 17:04:31 +0000 | [diff] [blame] | 7487 | return 0; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7488 | msleep(1); |
| 7489 | } |
| 7490 | |
| 7491 | return -EINVAL; |
| 7492 | } |
| 7493 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 7494 | int bnx2x_read_sfp_module_eeprom(struct bnx2x_phy *phy, |
| 7495 | struct link_params *params, u16 addr, |
| 7496 | u8 byte_cnt, u8 *o_buf) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7497 | { |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 7498 | int rc = -EINVAL; |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 7499 | switch (phy->type) { |
| 7500 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726: |
| 7501 | rc = bnx2x_8726_read_sfp_module_eeprom(phy, params, addr, |
| 7502 | byte_cnt, o_buf); |
| 7503 | break; |
| 7504 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727: |
| 7505 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8722: |
| 7506 | rc = bnx2x_8727_read_sfp_module_eeprom(phy, params, addr, |
| 7507 | byte_cnt, o_buf); |
| 7508 | break; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 7509 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT: |
| 7510 | rc = bnx2x_warpcore_read_sfp_module_eeprom(phy, params, addr, |
| 7511 | byte_cnt, o_buf); |
| 7512 | break; |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 7513 | } |
| 7514 | return rc; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7515 | } |
| 7516 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 7517 | static int bnx2x_get_edc_mode(struct bnx2x_phy *phy, |
| 7518 | struct link_params *params, |
| 7519 | u16 *edc_mode) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7520 | { |
| 7521 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 7522 | u32 sync_offset = 0, phy_idx, media_types; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7523 | u8 val, check_limiting_mode = 0; |
| 7524 | *edc_mode = EDC_MODE_LIMITING; |
| 7525 | |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 7526 | phy->media_type = ETH_PHY_UNSPECIFIED; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7527 | /* First check for copper cable */ |
| 7528 | if (bnx2x_read_sfp_module_eeprom(phy, |
| 7529 | params, |
| 7530 | SFP_EEPROM_CON_TYPE_ADDR, |
| 7531 | 1, |
| 7532 | &val) != 0) { |
| 7533 | DP(NETIF_MSG_LINK, "Failed to read from SFP+ module EEPROM\n"); |
| 7534 | return -EINVAL; |
| 7535 | } |
| 7536 | |
| 7537 | switch (val) { |
| 7538 | case SFP_EEPROM_CON_TYPE_VAL_COPPER: |
| 7539 | { |
| 7540 | u8 copper_module_type; |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 7541 | phy->media_type = ETH_PHY_DA_TWINAX; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7542 | /* |
| 7543 | * Check if its active cable (includes SFP+ module) |
| 7544 | * of passive cable |
| 7545 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7546 | if (bnx2x_read_sfp_module_eeprom(phy, |
| 7547 | params, |
| 7548 | SFP_EEPROM_FC_TX_TECH_ADDR, |
| 7549 | 1, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 7550 | &copper_module_type) != 0) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7551 | DP(NETIF_MSG_LINK, |
| 7552 | "Failed to read copper-cable-type" |
| 7553 | " from SFP+ EEPROM\n"); |
| 7554 | return -EINVAL; |
| 7555 | } |
| 7556 | |
| 7557 | if (copper_module_type & |
| 7558 | SFP_EEPROM_FC_TX_TECH_BITMASK_COPPER_ACTIVE) { |
| 7559 | DP(NETIF_MSG_LINK, "Active Copper cable detected\n"); |
| 7560 | check_limiting_mode = 1; |
| 7561 | } else if (copper_module_type & |
| 7562 | SFP_EEPROM_FC_TX_TECH_BITMASK_COPPER_PASSIVE) { |
| 7563 | DP(NETIF_MSG_LINK, "Passive Copper" |
| 7564 | " cable detected\n"); |
| 7565 | *edc_mode = |
| 7566 | EDC_MODE_PASSIVE_DAC; |
| 7567 | } else { |
| 7568 | DP(NETIF_MSG_LINK, "Unknown copper-cable-" |
| 7569 | "type 0x%x !!!\n", copper_module_type); |
| 7570 | return -EINVAL; |
| 7571 | } |
| 7572 | break; |
| 7573 | } |
| 7574 | case SFP_EEPROM_CON_TYPE_VAL_LC: |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 7575 | phy->media_type = ETH_PHY_SFP_FIBER; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7576 | DP(NETIF_MSG_LINK, "Optic module detected\n"); |
| 7577 | check_limiting_mode = 1; |
| 7578 | break; |
| 7579 | default: |
| 7580 | DP(NETIF_MSG_LINK, "Unable to determine module type 0x%x !!!\n", |
| 7581 | val); |
| 7582 | return -EINVAL; |
| 7583 | } |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 7584 | sync_offset = params->shmem_base + |
| 7585 | offsetof(struct shmem_region, |
| 7586 | dev_info.port_hw_config[params->port].media_type); |
| 7587 | media_types = REG_RD(bp, sync_offset); |
| 7588 | /* Update media type for non-PMF sync */ |
| 7589 | for (phy_idx = INT_PHY; phy_idx < MAX_PHYS; phy_idx++) { |
| 7590 | if (&(params->phy[phy_idx]) == phy) { |
| 7591 | media_types &= ~(PORT_HW_CFG_MEDIA_TYPE_PHY0_MASK << |
| 7592 | (PORT_HW_CFG_MEDIA_TYPE_PHY1_SHIFT * phy_idx)); |
| 7593 | media_types |= ((phy->media_type & |
| 7594 | PORT_HW_CFG_MEDIA_TYPE_PHY0_MASK) << |
| 7595 | (PORT_HW_CFG_MEDIA_TYPE_PHY1_SHIFT * phy_idx)); |
| 7596 | break; |
| 7597 | } |
| 7598 | } |
| 7599 | REG_WR(bp, sync_offset, media_types); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7600 | if (check_limiting_mode) { |
| 7601 | u8 options[SFP_EEPROM_OPTIONS_SIZE]; |
| 7602 | if (bnx2x_read_sfp_module_eeprom(phy, |
| 7603 | params, |
| 7604 | SFP_EEPROM_OPTIONS_ADDR, |
| 7605 | SFP_EEPROM_OPTIONS_SIZE, |
| 7606 | options) != 0) { |
| 7607 | DP(NETIF_MSG_LINK, "Failed to read Option" |
| 7608 | " field from module EEPROM\n"); |
| 7609 | return -EINVAL; |
| 7610 | } |
| 7611 | if ((options[0] & SFP_EEPROM_OPTIONS_LINEAR_RX_OUT_MASK)) |
| 7612 | *edc_mode = EDC_MODE_LINEAR; |
| 7613 | else |
| 7614 | *edc_mode = EDC_MODE_LIMITING; |
| 7615 | } |
| 7616 | DP(NETIF_MSG_LINK, "EDC mode is set to 0x%x\n", *edc_mode); |
| 7617 | return 0; |
| 7618 | } |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7619 | /* |
| 7620 | * This function read the relevant field from the module (SFP+), and verify it |
| 7621 | * is compliant with this board |
| 7622 | */ |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 7623 | static int bnx2x_verify_sfp_module(struct bnx2x_phy *phy, |
| 7624 | struct link_params *params) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7625 | { |
| 7626 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7627 | u32 val, cmd; |
| 7628 | u32 fw_resp, fw_cmd_param; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7629 | char vendor_name[SFP_EEPROM_VENDOR_NAME_SIZE+1]; |
| 7630 | char vendor_pn[SFP_EEPROM_PART_NO_SIZE+1]; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7631 | phy->flags &= ~FLAGS_SFP_NOT_APPROVED; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7632 | val = REG_RD(bp, params->shmem_base + |
| 7633 | offsetof(struct shmem_region, dev_info. |
| 7634 | port_feature_config[params->port].config)); |
| 7635 | if ((val & PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK) == |
| 7636 | PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_NO_ENFORCEMENT) { |
| 7637 | DP(NETIF_MSG_LINK, "NOT enforcing module verification\n"); |
| 7638 | return 0; |
| 7639 | } |
| 7640 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7641 | if (params->feature_config_flags & |
| 7642 | FEATURE_CONFIG_BC_SUPPORTS_DUAL_PHY_OPT_MDL_VRFY) { |
| 7643 | /* Use specific phy request */ |
| 7644 | cmd = DRV_MSG_CODE_VRFY_SPECIFIC_PHY_OPT_MDL; |
| 7645 | } else if (params->feature_config_flags & |
| 7646 | FEATURE_CONFIG_BC_SUPPORTS_OPT_MDL_VRFY) { |
| 7647 | /* Use first phy request only in case of non-dual media*/ |
| 7648 | if (DUAL_MEDIA(params)) { |
| 7649 | DP(NETIF_MSG_LINK, "FW does not support OPT MDL " |
| 7650 | "verification\n"); |
| 7651 | return -EINVAL; |
| 7652 | } |
| 7653 | cmd = DRV_MSG_CODE_VRFY_FIRST_PHY_OPT_MDL; |
| 7654 | } else { |
| 7655 | /* No support in OPT MDL detection */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7656 | DP(NETIF_MSG_LINK, "FW does not support OPT MDL " |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7657 | "verification\n"); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7658 | return -EINVAL; |
| 7659 | } |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 7660 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7661 | fw_cmd_param = FW_PARAM_SET(phy->addr, phy->type, phy->mdio_ctrl); |
| 7662 | fw_resp = bnx2x_fw_command(bp, cmd, fw_cmd_param); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7663 | if (fw_resp == FW_MSG_CODE_VRFY_OPT_MDL_SUCCESS) { |
| 7664 | DP(NETIF_MSG_LINK, "Approved module\n"); |
| 7665 | return 0; |
| 7666 | } |
| 7667 | |
| 7668 | /* format the warning message */ |
| 7669 | if (bnx2x_read_sfp_module_eeprom(phy, |
| 7670 | params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7671 | SFP_EEPROM_VENDOR_NAME_ADDR, |
| 7672 | SFP_EEPROM_VENDOR_NAME_SIZE, |
| 7673 | (u8 *)vendor_name)) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7674 | vendor_name[0] = '\0'; |
| 7675 | else |
| 7676 | vendor_name[SFP_EEPROM_VENDOR_NAME_SIZE] = '\0'; |
| 7677 | if (bnx2x_read_sfp_module_eeprom(phy, |
| 7678 | params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7679 | SFP_EEPROM_PART_NO_ADDR, |
| 7680 | SFP_EEPROM_PART_NO_SIZE, |
| 7681 | (u8 *)vendor_pn)) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7682 | vendor_pn[0] = '\0'; |
| 7683 | else |
| 7684 | vendor_pn[SFP_EEPROM_PART_NO_SIZE] = '\0'; |
| 7685 | |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 7686 | netdev_err(bp->dev, "Warning: Unqualified SFP+ module detected," |
| 7687 | " Port %d from %s part number %s\n", |
| 7688 | params->port, vendor_name, vendor_pn); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7689 | phy->flags |= FLAGS_SFP_NOT_APPROVED; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7690 | return -EINVAL; |
| 7691 | } |
| 7692 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 7693 | static int bnx2x_wait_for_sfp_module_initialized(struct bnx2x_phy *phy, |
| 7694 | struct link_params *params) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7695 | |
| 7696 | { |
| 7697 | u8 val; |
| 7698 | struct bnx2x *bp = params->bp; |
| 7699 | u16 timeout; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7700 | /* |
| 7701 | * Initialization time after hot-plug may take up to 300ms for |
| 7702 | * some phys type ( e.g. JDSU ) |
| 7703 | */ |
| 7704 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7705 | for (timeout = 0; timeout < 60; timeout++) { |
| 7706 | if (bnx2x_read_sfp_module_eeprom(phy, params, 1, 1, &val) |
| 7707 | == 0) { |
| 7708 | DP(NETIF_MSG_LINK, "SFP+ module initialization " |
| 7709 | "took %d ms\n", timeout * 5); |
| 7710 | return 0; |
| 7711 | } |
| 7712 | msleep(5); |
| 7713 | } |
| 7714 | return -EINVAL; |
| 7715 | } |
| 7716 | |
| 7717 | static void bnx2x_8727_power_module(struct bnx2x *bp, |
| 7718 | struct bnx2x_phy *phy, |
| 7719 | u8 is_power_up) { |
| 7720 | /* Make sure GPIOs are not using for LED mode */ |
| 7721 | u16 val; |
| 7722 | /* |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7723 | * In the GPIO register, bit 4 is use to determine if the GPIOs are |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7724 | * operating as INPUT or as OUTPUT. Bit 1 is for input, and 0 for |
| 7725 | * output |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 7726 | * Bits 0-1 determine the GPIOs value for OUTPUT in case bit 4 val is 0 |
| 7727 | * Bits 8-9 determine the GPIOs value for INPUT in case bit 4 val is 1 |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7728 | * where the 1st bit is the over-current(only input), and 2nd bit is |
| 7729 | * for power( only output ) |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7730 | * |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7731 | * In case of NOC feature is disabled and power is up, set GPIO control |
| 7732 | * as input to enable listening of over-current indication |
| 7733 | */ |
| 7734 | if (phy->flags & FLAGS_NOC) |
| 7735 | return; |
Yaniv Rosner | 27d0243 | 2011-05-31 21:27:48 +0000 | [diff] [blame] | 7736 | if (is_power_up) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7737 | val = (1<<4); |
| 7738 | else |
| 7739 | /* |
| 7740 | * Set GPIO control to OUTPUT, and set the power bit |
| 7741 | * to according to the is_power_up |
| 7742 | */ |
Yaniv Rosner | 27d0243 | 2011-05-31 21:27:48 +0000 | [diff] [blame] | 7743 | val = (1<<1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7744 | |
| 7745 | bnx2x_cl45_write(bp, phy, |
| 7746 | MDIO_PMA_DEVAD, |
| 7747 | MDIO_PMA_REG_8727_GPIO_CTRL, |
| 7748 | val); |
| 7749 | } |
| 7750 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 7751 | static int bnx2x_8726_set_limiting_mode(struct bnx2x *bp, |
| 7752 | struct bnx2x_phy *phy, |
| 7753 | u16 edc_mode) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7754 | { |
| 7755 | u16 cur_limiting_mode; |
| 7756 | |
| 7757 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7758 | MDIO_PMA_DEVAD, |
| 7759 | MDIO_PMA_REG_ROM_VER2, |
| 7760 | &cur_limiting_mode); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7761 | DP(NETIF_MSG_LINK, "Current Limiting mode is 0x%x\n", |
| 7762 | cur_limiting_mode); |
| 7763 | |
| 7764 | if (edc_mode == EDC_MODE_LIMITING) { |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7765 | DP(NETIF_MSG_LINK, "Setting LIMITING MODE\n"); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7766 | bnx2x_cl45_write(bp, phy, |
| 7767 | MDIO_PMA_DEVAD, |
| 7768 | MDIO_PMA_REG_ROM_VER2, |
| 7769 | EDC_MODE_LIMITING); |
| 7770 | } else { /* LRM mode ( default )*/ |
| 7771 | |
| 7772 | DP(NETIF_MSG_LINK, "Setting LRM MODE\n"); |
| 7773 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7774 | /* |
| 7775 | * Changing to LRM mode takes quite few seconds. So do it only |
| 7776 | * if current mode is limiting (default is LRM) |
| 7777 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7778 | if (cur_limiting_mode != EDC_MODE_LIMITING) |
| 7779 | return 0; |
| 7780 | |
| 7781 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7782 | MDIO_PMA_DEVAD, |
| 7783 | MDIO_PMA_REG_LRM_MODE, |
| 7784 | 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7785 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7786 | MDIO_PMA_DEVAD, |
| 7787 | MDIO_PMA_REG_ROM_VER2, |
| 7788 | 0x128); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7789 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7790 | MDIO_PMA_DEVAD, |
| 7791 | MDIO_PMA_REG_MISC_CTRL0, |
| 7792 | 0x4008); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7793 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7794 | MDIO_PMA_DEVAD, |
| 7795 | MDIO_PMA_REG_LRM_MODE, |
| 7796 | 0xaaaa); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7797 | } |
| 7798 | return 0; |
| 7799 | } |
| 7800 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 7801 | static int bnx2x_8727_set_limiting_mode(struct bnx2x *bp, |
| 7802 | struct bnx2x_phy *phy, |
| 7803 | u16 edc_mode) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7804 | { |
| 7805 | u16 phy_identifier; |
| 7806 | u16 rom_ver2_val; |
| 7807 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7808 | MDIO_PMA_DEVAD, |
| 7809 | MDIO_PMA_REG_PHY_IDENTIFIER, |
| 7810 | &phy_identifier); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7811 | |
| 7812 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7813 | MDIO_PMA_DEVAD, |
| 7814 | MDIO_PMA_REG_PHY_IDENTIFIER, |
| 7815 | (phy_identifier & ~(1<<9))); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7816 | |
| 7817 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7818 | MDIO_PMA_DEVAD, |
| 7819 | MDIO_PMA_REG_ROM_VER2, |
| 7820 | &rom_ver2_val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7821 | /* Keep the MSB 8-bits, and set the LSB 8-bits with the edc_mode */ |
| 7822 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7823 | MDIO_PMA_DEVAD, |
| 7824 | MDIO_PMA_REG_ROM_VER2, |
| 7825 | (rom_ver2_val & 0xff00) | (edc_mode & 0x00ff)); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7826 | |
| 7827 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7828 | MDIO_PMA_DEVAD, |
| 7829 | MDIO_PMA_REG_PHY_IDENTIFIER, |
| 7830 | (phy_identifier | (1<<9))); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7831 | |
| 7832 | return 0; |
| 7833 | } |
| 7834 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7835 | static void bnx2x_8727_specific_func(struct bnx2x_phy *phy, |
| 7836 | struct link_params *params, |
| 7837 | u32 action) |
| 7838 | { |
| 7839 | struct bnx2x *bp = params->bp; |
| 7840 | |
| 7841 | switch (action) { |
| 7842 | case DISABLE_TX: |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 7843 | bnx2x_sfp_set_transmitter(params, phy, 0); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7844 | break; |
| 7845 | case ENABLE_TX: |
| 7846 | if (!(phy->flags & FLAGS_SFP_NOT_APPROVED)) |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 7847 | bnx2x_sfp_set_transmitter(params, phy, 1); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7848 | break; |
| 7849 | default: |
| 7850 | DP(NETIF_MSG_LINK, "Function 0x%x not supported by 8727\n", |
| 7851 | action); |
| 7852 | return; |
| 7853 | } |
| 7854 | } |
| 7855 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 7856 | static void bnx2x_set_e1e2_module_fault_led(struct link_params *params, |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 7857 | u8 gpio_mode) |
| 7858 | { |
| 7859 | struct bnx2x *bp = params->bp; |
| 7860 | |
| 7861 | u32 fault_led_gpio = REG_RD(bp, params->shmem_base + |
| 7862 | offsetof(struct shmem_region, |
| 7863 | dev_info.port_hw_config[params->port].sfp_ctrl)) & |
| 7864 | PORT_HW_CFG_FAULT_MODULE_LED_MASK; |
| 7865 | switch (fault_led_gpio) { |
| 7866 | case PORT_HW_CFG_FAULT_MODULE_LED_DISABLED: |
| 7867 | return; |
| 7868 | case PORT_HW_CFG_FAULT_MODULE_LED_GPIO0: |
| 7869 | case PORT_HW_CFG_FAULT_MODULE_LED_GPIO1: |
| 7870 | case PORT_HW_CFG_FAULT_MODULE_LED_GPIO2: |
| 7871 | case PORT_HW_CFG_FAULT_MODULE_LED_GPIO3: |
| 7872 | { |
| 7873 | u8 gpio_port = bnx2x_get_gpio_port(params); |
| 7874 | u16 gpio_pin = fault_led_gpio - |
| 7875 | PORT_HW_CFG_FAULT_MODULE_LED_GPIO0; |
| 7876 | DP(NETIF_MSG_LINK, "Set fault module-detected led " |
| 7877 | "pin %x port %x mode %x\n", |
| 7878 | gpio_pin, gpio_port, gpio_mode); |
| 7879 | bnx2x_set_gpio(bp, gpio_pin, gpio_mode, gpio_port); |
| 7880 | } |
| 7881 | break; |
| 7882 | default: |
| 7883 | DP(NETIF_MSG_LINK, "Error: Invalid fault led mode 0x%x\n", |
| 7884 | fault_led_gpio); |
| 7885 | } |
| 7886 | } |
| 7887 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 7888 | static void bnx2x_set_e3_module_fault_led(struct link_params *params, |
| 7889 | u8 gpio_mode) |
| 7890 | { |
| 7891 | u32 pin_cfg; |
| 7892 | u8 port = params->port; |
| 7893 | struct bnx2x *bp = params->bp; |
| 7894 | pin_cfg = (REG_RD(bp, params->shmem_base + |
| 7895 | offsetof(struct shmem_region, |
| 7896 | dev_info.port_hw_config[port].e3_sfp_ctrl)) & |
| 7897 | PORT_HW_CFG_E3_FAULT_MDL_LED_MASK) >> |
| 7898 | PORT_HW_CFG_E3_FAULT_MDL_LED_SHIFT; |
| 7899 | DP(NETIF_MSG_LINK, "Setting Fault LED to %d using pin cfg %d\n", |
| 7900 | gpio_mode, pin_cfg); |
| 7901 | bnx2x_set_cfg_pin(bp, pin_cfg, gpio_mode); |
| 7902 | } |
| 7903 | |
| 7904 | static void bnx2x_set_sfp_module_fault_led(struct link_params *params, |
| 7905 | u8 gpio_mode) |
| 7906 | { |
| 7907 | struct bnx2x *bp = params->bp; |
| 7908 | DP(NETIF_MSG_LINK, "Setting SFP+ module fault LED to %d\n", gpio_mode); |
| 7909 | if (CHIP_IS_E3(bp)) { |
| 7910 | /* |
| 7911 | * Low ==> if SFP+ module is supported otherwise |
| 7912 | * High ==> if SFP+ module is not on the approved vendor list |
| 7913 | */ |
| 7914 | bnx2x_set_e3_module_fault_led(params, gpio_mode); |
| 7915 | } else |
| 7916 | bnx2x_set_e1e2_module_fault_led(params, gpio_mode); |
| 7917 | } |
| 7918 | |
| 7919 | static void bnx2x_warpcore_power_module(struct link_params *params, |
| 7920 | struct bnx2x_phy *phy, |
| 7921 | u8 power) |
| 7922 | { |
| 7923 | u32 pin_cfg; |
| 7924 | struct bnx2x *bp = params->bp; |
| 7925 | |
| 7926 | pin_cfg = (REG_RD(bp, params->shmem_base + |
| 7927 | offsetof(struct shmem_region, |
| 7928 | dev_info.port_hw_config[params->port].e3_sfp_ctrl)) & |
| 7929 | PORT_HW_CFG_E3_PWR_DIS_MASK) >> |
| 7930 | PORT_HW_CFG_E3_PWR_DIS_SHIFT; |
Yaniv Rosner | 985848f | 2011-07-05 01:06:48 +0000 | [diff] [blame] | 7931 | |
| 7932 | if (pin_cfg == PIN_CFG_NA) |
| 7933 | return; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 7934 | DP(NETIF_MSG_LINK, "Setting SFP+ module power to %d using pin cfg %d\n", |
| 7935 | power, pin_cfg); |
| 7936 | /* |
| 7937 | * Low ==> corresponding SFP+ module is powered |
| 7938 | * high ==> the SFP+ module is powered down |
| 7939 | */ |
| 7940 | bnx2x_set_cfg_pin(bp, pin_cfg, power ^ 1); |
| 7941 | } |
| 7942 | |
Yaniv Rosner | 985848f | 2011-07-05 01:06:48 +0000 | [diff] [blame] | 7943 | static void bnx2x_warpcore_hw_reset(struct bnx2x_phy *phy, |
| 7944 | struct link_params *params) |
| 7945 | { |
| 7946 | bnx2x_warpcore_power_module(params, phy, 0); |
| 7947 | } |
| 7948 | |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 7949 | static void bnx2x_power_sfp_module(struct link_params *params, |
| 7950 | struct bnx2x_phy *phy, |
| 7951 | u8 power) |
| 7952 | { |
| 7953 | struct bnx2x *bp = params->bp; |
| 7954 | DP(NETIF_MSG_LINK, "Setting SFP+ power to %x\n", power); |
| 7955 | |
| 7956 | switch (phy->type) { |
| 7957 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727: |
| 7958 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8722: |
| 7959 | bnx2x_8727_power_module(params->bp, phy, power); |
| 7960 | break; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 7961 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT: |
| 7962 | bnx2x_warpcore_power_module(params, phy, power); |
| 7963 | break; |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 7964 | default: |
| 7965 | break; |
| 7966 | } |
| 7967 | } |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 7968 | static void bnx2x_warpcore_set_limiting_mode(struct link_params *params, |
| 7969 | struct bnx2x_phy *phy, |
| 7970 | u16 edc_mode) |
| 7971 | { |
| 7972 | u16 val = 0; |
| 7973 | u16 mode = MDIO_WC_REG_UC_INFO_B1_FIRMWARE_MODE_DEFAULT; |
| 7974 | struct bnx2x *bp = params->bp; |
| 7975 | |
| 7976 | u8 lane = bnx2x_get_warpcore_lane(phy, params); |
| 7977 | /* This is a global register which controls all lanes */ |
| 7978 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 7979 | MDIO_WC_REG_UC_INFO_B1_FIRMWARE_MODE, &val); |
| 7980 | val &= ~(0xf << (lane << 2)); |
| 7981 | |
| 7982 | switch (edc_mode) { |
| 7983 | case EDC_MODE_LINEAR: |
| 7984 | case EDC_MODE_LIMITING: |
| 7985 | mode = MDIO_WC_REG_UC_INFO_B1_FIRMWARE_MODE_DEFAULT; |
| 7986 | break; |
| 7987 | case EDC_MODE_PASSIVE_DAC: |
| 7988 | mode = MDIO_WC_REG_UC_INFO_B1_FIRMWARE_MODE_SFP_DAC; |
| 7989 | break; |
| 7990 | default: |
| 7991 | break; |
| 7992 | } |
| 7993 | |
| 7994 | val |= (mode << (lane << 2)); |
| 7995 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 7996 | MDIO_WC_REG_UC_INFO_B1_FIRMWARE_MODE, val); |
| 7997 | /* A must read */ |
| 7998 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 7999 | MDIO_WC_REG_UC_INFO_B1_FIRMWARE_MODE, &val); |
| 8000 | |
| 8001 | |
| 8002 | } |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 8003 | |
| 8004 | static void bnx2x_set_limiting_mode(struct link_params *params, |
| 8005 | struct bnx2x_phy *phy, |
| 8006 | u16 edc_mode) |
| 8007 | { |
| 8008 | switch (phy->type) { |
| 8009 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726: |
| 8010 | bnx2x_8726_set_limiting_mode(params->bp, phy, edc_mode); |
| 8011 | break; |
| 8012 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727: |
| 8013 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8722: |
| 8014 | bnx2x_8727_set_limiting_mode(params->bp, phy, edc_mode); |
| 8015 | break; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8016 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT: |
| 8017 | bnx2x_warpcore_set_limiting_mode(params, phy, edc_mode); |
| 8018 | break; |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 8019 | } |
| 8020 | } |
| 8021 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 8022 | int bnx2x_sfp_module_detection(struct bnx2x_phy *phy, |
| 8023 | struct link_params *params) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8024 | { |
| 8025 | struct bnx2x *bp = params->bp; |
| 8026 | u16 edc_mode; |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 8027 | int rc = 0; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8028 | |
| 8029 | u32 val = REG_RD(bp, params->shmem_base + |
| 8030 | offsetof(struct shmem_region, dev_info. |
| 8031 | port_feature_config[params->port].config)); |
| 8032 | |
| 8033 | DP(NETIF_MSG_LINK, "SFP+ module plugged in/out detected on port %d\n", |
| 8034 | params->port); |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 8035 | /* Power up module */ |
| 8036 | bnx2x_power_sfp_module(params, phy, 1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8037 | if (bnx2x_get_edc_mode(phy, params, &edc_mode) != 0) { |
| 8038 | DP(NETIF_MSG_LINK, "Failed to get valid module type\n"); |
| 8039 | return -EINVAL; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8040 | } else if (bnx2x_verify_sfp_module(phy, params) != 0) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8041 | /* check SFP+ module compatibility */ |
| 8042 | DP(NETIF_MSG_LINK, "Module verification failed!!\n"); |
| 8043 | rc = -EINVAL; |
| 8044 | /* Turn on fault module-detected led */ |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8045 | bnx2x_set_sfp_module_fault_led(params, |
| 8046 | MISC_REGISTERS_GPIO_HIGH); |
| 8047 | |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 8048 | /* Check if need to power down the SFP+ module */ |
| 8049 | if ((val & PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK) == |
| 8050 | PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_POWER_DOWN) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8051 | DP(NETIF_MSG_LINK, "Shutdown SFP+ module!!\n"); |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 8052 | bnx2x_power_sfp_module(params, phy, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8053 | return rc; |
| 8054 | } |
| 8055 | } else { |
| 8056 | /* Turn off fault module-detected led */ |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8057 | bnx2x_set_sfp_module_fault_led(params, MISC_REGISTERS_GPIO_LOW); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8058 | } |
| 8059 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8060 | /* |
| 8061 | * Check and set limiting mode / LRM mode on 8726. On 8727 it |
| 8062 | * is done automatically |
| 8063 | */ |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 8064 | bnx2x_set_limiting_mode(params, phy, edc_mode); |
| 8065 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8066 | /* |
| 8067 | * Enable transmit for this module if the module is approved, or |
| 8068 | * if unapproved modules should also enable the Tx laser |
| 8069 | */ |
| 8070 | if (rc == 0 || |
| 8071 | (val & PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK) != |
| 8072 | PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_DISABLE_TX_LASER) |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8073 | bnx2x_sfp_set_transmitter(params, phy, 1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8074 | else |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8075 | bnx2x_sfp_set_transmitter(params, phy, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8076 | |
| 8077 | return rc; |
| 8078 | } |
| 8079 | |
| 8080 | void bnx2x_handle_module_detect_int(struct link_params *params) |
| 8081 | { |
| 8082 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8083 | struct bnx2x_phy *phy; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8084 | u32 gpio_val; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8085 | u8 gpio_num, gpio_port; |
| 8086 | if (CHIP_IS_E3(bp)) |
| 8087 | phy = ¶ms->phy[INT_PHY]; |
| 8088 | else |
| 8089 | phy = ¶ms->phy[EXT_PHY1]; |
| 8090 | |
| 8091 | if (bnx2x_get_mod_abs_int_cfg(bp, params->chip_id, params->shmem_base, |
| 8092 | params->port, &gpio_num, &gpio_port) == |
| 8093 | -EINVAL) { |
| 8094 | DP(NETIF_MSG_LINK, "Failed to get MOD_ABS interrupt config\n"); |
| 8095 | return; |
| 8096 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8097 | |
| 8098 | /* Set valid module led off */ |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8099 | bnx2x_set_sfp_module_fault_led(params, MISC_REGISTERS_GPIO_HIGH); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8100 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8101 | /* Get current gpio val reflecting module plugged in / out*/ |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8102 | gpio_val = bnx2x_get_gpio(bp, gpio_num, gpio_port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8103 | |
| 8104 | /* Call the handling function in case module is detected */ |
| 8105 | if (gpio_val == 0) { |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 8106 | bnx2x_power_sfp_module(params, phy, 1); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8107 | bnx2x_set_gpio_int(bp, gpio_num, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8108 | MISC_REGISTERS_GPIO_INT_OUTPUT_CLR, |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8109 | gpio_port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8110 | if (bnx2x_wait_for_sfp_module_initialized(phy, params) == 0) |
| 8111 | bnx2x_sfp_module_detection(phy, params); |
| 8112 | else |
| 8113 | DP(NETIF_MSG_LINK, "SFP+ module is not initialized\n"); |
| 8114 | } else { |
| 8115 | u32 val = REG_RD(bp, params->shmem_base + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8116 | offsetof(struct shmem_region, dev_info. |
| 8117 | port_feature_config[params->port]. |
| 8118 | config)); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8119 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8120 | bnx2x_set_gpio_int(bp, gpio_num, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8121 | MISC_REGISTERS_GPIO_INT_OUTPUT_SET, |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8122 | gpio_port); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8123 | /* |
| 8124 | * Module was plugged out. |
| 8125 | * Disable transmit for this module |
| 8126 | */ |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 8127 | phy->media_type = ETH_PHY_NOT_PRESENT; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8128 | if ((val & PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK) == |
| 8129 | PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_DISABLE_TX_LASER) |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8130 | bnx2x_sfp_set_transmitter(params, phy, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8131 | } |
| 8132 | } |
| 8133 | |
| 8134 | /******************************************************************/ |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 8135 | /* Used by 8706 and 8727 */ |
| 8136 | /******************************************************************/ |
| 8137 | static void bnx2x_sfp_mask_fault(struct bnx2x *bp, |
| 8138 | struct bnx2x_phy *phy, |
| 8139 | u16 alarm_status_offset, |
| 8140 | u16 alarm_ctrl_offset) |
| 8141 | { |
| 8142 | u16 alarm_status, val; |
| 8143 | bnx2x_cl45_read(bp, phy, |
| 8144 | MDIO_PMA_DEVAD, alarm_status_offset, |
| 8145 | &alarm_status); |
| 8146 | bnx2x_cl45_read(bp, phy, |
| 8147 | MDIO_PMA_DEVAD, alarm_status_offset, |
| 8148 | &alarm_status); |
| 8149 | /* Mask or enable the fault event. */ |
| 8150 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, alarm_ctrl_offset, &val); |
| 8151 | if (alarm_status & (1<<0)) |
| 8152 | val &= ~(1<<0); |
| 8153 | else |
| 8154 | val |= (1<<0); |
| 8155 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, alarm_ctrl_offset, val); |
| 8156 | } |
| 8157 | /******************************************************************/ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8158 | /* common BCM8706/BCM8726 PHY SECTION */ |
| 8159 | /******************************************************************/ |
| 8160 | static u8 bnx2x_8706_8726_read_status(struct bnx2x_phy *phy, |
| 8161 | struct link_params *params, |
| 8162 | struct link_vars *vars) |
| 8163 | { |
| 8164 | u8 link_up = 0; |
| 8165 | u16 val1, val2, rx_sd, pcs_status; |
| 8166 | struct bnx2x *bp = params->bp; |
| 8167 | DP(NETIF_MSG_LINK, "XGXS 8706/8726\n"); |
| 8168 | /* Clear RX Alarm*/ |
| 8169 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8170 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_RXSTAT, &val2); |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 8171 | |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8172 | bnx2x_sfp_mask_fault(bp, phy, MDIO_PMA_LASI_TXSTAT, |
| 8173 | MDIO_PMA_LASI_TXCTRL); |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 8174 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8175 | /* clear LASI indication*/ |
| 8176 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8177 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_STAT, &val1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8178 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8179 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_STAT, &val2); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8180 | DP(NETIF_MSG_LINK, "8706/8726 LASI status 0x%x--> 0x%x\n", val1, val2); |
| 8181 | |
| 8182 | bnx2x_cl45_read(bp, phy, |
| 8183 | MDIO_PMA_DEVAD, MDIO_PMA_REG_RX_SD, &rx_sd); |
| 8184 | bnx2x_cl45_read(bp, phy, |
| 8185 | MDIO_PCS_DEVAD, MDIO_PCS_REG_STATUS, &pcs_status); |
| 8186 | bnx2x_cl45_read(bp, phy, |
| 8187 | MDIO_AN_DEVAD, MDIO_AN_REG_LINK_STATUS, &val2); |
| 8188 | bnx2x_cl45_read(bp, phy, |
| 8189 | MDIO_AN_DEVAD, MDIO_AN_REG_LINK_STATUS, &val2); |
| 8190 | |
| 8191 | DP(NETIF_MSG_LINK, "8706/8726 rx_sd 0x%x pcs_status 0x%x 1Gbps" |
| 8192 | " link_status 0x%x\n", rx_sd, pcs_status, val2); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8193 | /* |
| 8194 | * link is up if both bit 0 of pmd_rx_sd and bit 0 of pcs_status |
| 8195 | * are set, or if the autoneg bit 1 is set |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8196 | */ |
| 8197 | link_up = ((rx_sd & pcs_status & 0x1) || (val2 & (1<<1))); |
| 8198 | if (link_up) { |
| 8199 | if (val2 & (1<<1)) |
| 8200 | vars->line_speed = SPEED_1000; |
| 8201 | else |
| 8202 | vars->line_speed = SPEED_10000; |
| 8203 | bnx2x_ext_phy_resolve_fc(phy, params, vars); |
Yaniv Rosner | 791f18c | 2011-01-18 04:33:42 +0000 | [diff] [blame] | 8204 | vars->duplex = DUPLEX_FULL; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8205 | } |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 8206 | |
| 8207 | /* Capture 10G link fault. Read twice to clear stale value. */ |
| 8208 | if (vars->line_speed == SPEED_10000) { |
| 8209 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8210 | MDIO_PMA_LASI_TXSTAT, &val1); |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 8211 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8212 | MDIO_PMA_LASI_TXSTAT, &val1); |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 8213 | if (val1 & (1<<0)) |
| 8214 | vars->fault_detected = 1; |
| 8215 | } |
| 8216 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8217 | return link_up; |
| 8218 | } |
| 8219 | |
| 8220 | /******************************************************************/ |
| 8221 | /* BCM8706 PHY SECTION */ |
| 8222 | /******************************************************************/ |
| 8223 | static u8 bnx2x_8706_config_init(struct bnx2x_phy *phy, |
| 8224 | struct link_params *params, |
| 8225 | struct link_vars *vars) |
| 8226 | { |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8227 | u32 tx_en_mode; |
| 8228 | u16 cnt, val, tmp1; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8229 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 8230 | |
| 8231 | /* SPF+ PHY: Set flag to check for Tx error */ |
| 8232 | vars->phy_flags = PHY_TX_ERROR_CHECK_FLAG; |
| 8233 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8234 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8235 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, params->port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8236 | /* HW reset */ |
| 8237 | bnx2x_ext_phy_hw_reset(bp, params->port); |
| 8238 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 0xa040); |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 8239 | bnx2x_wait_reset_complete(bp, phy, params); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8240 | |
| 8241 | /* Wait until fw is loaded */ |
| 8242 | for (cnt = 0; cnt < 100; cnt++) { |
| 8243 | bnx2x_cl45_read(bp, phy, |
| 8244 | MDIO_PMA_DEVAD, MDIO_PMA_REG_ROM_VER1, &val); |
| 8245 | if (val) |
| 8246 | break; |
| 8247 | msleep(10); |
| 8248 | } |
| 8249 | DP(NETIF_MSG_LINK, "XGXS 8706 is initialized after %d ms\n", cnt); |
| 8250 | if ((params->feature_config_flags & |
| 8251 | FEATURE_CONFIG_OVERRIDE_PREEMPHASIS_ENABLED)) { |
| 8252 | u8 i; |
| 8253 | u16 reg; |
| 8254 | for (i = 0; i < 4; i++) { |
| 8255 | reg = MDIO_XS_8706_REG_BANK_RX0 + |
| 8256 | i*(MDIO_XS_8706_REG_BANK_RX1 - |
| 8257 | MDIO_XS_8706_REG_BANK_RX0); |
| 8258 | bnx2x_cl45_read(bp, phy, MDIO_XS_DEVAD, reg, &val); |
| 8259 | /* Clear first 3 bits of the control */ |
| 8260 | val &= ~0x7; |
| 8261 | /* Set control bits according to configuration */ |
| 8262 | val |= (phy->rx_preemphasis[i] & 0x7); |
| 8263 | DP(NETIF_MSG_LINK, "Setting RX Equalizer to BCM8706" |
| 8264 | " reg 0x%x <-- val 0x%x\n", reg, val); |
| 8265 | bnx2x_cl45_write(bp, phy, MDIO_XS_DEVAD, reg, val); |
| 8266 | } |
| 8267 | } |
| 8268 | /* Force speed */ |
| 8269 | if (phy->req_line_speed == SPEED_10000) { |
| 8270 | DP(NETIF_MSG_LINK, "XGXS 8706 force 10Gbps\n"); |
| 8271 | |
| 8272 | bnx2x_cl45_write(bp, phy, |
| 8273 | MDIO_PMA_DEVAD, |
| 8274 | MDIO_PMA_REG_DIGITAL_CTRL, 0x400); |
| 8275 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8276 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_TXCTRL, |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 8277 | 0); |
| 8278 | /* Arm LASI for link and Tx fault. */ |
| 8279 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8280 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_CTRL, 3); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8281 | } else { |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 8282 | /* Force 1Gbps using autoneg with 1G advertisement */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8283 | |
| 8284 | /* Allow CL37 through CL73 */ |
| 8285 | DP(NETIF_MSG_LINK, "XGXS 8706 AutoNeg\n"); |
| 8286 | bnx2x_cl45_write(bp, phy, |
| 8287 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_CL73, 0x040c); |
| 8288 | |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 8289 | /* Enable Full-Duplex advertisement on CL37 */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8290 | bnx2x_cl45_write(bp, phy, |
| 8291 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_FC_LP, 0x0020); |
| 8292 | /* Enable CL37 AN */ |
| 8293 | bnx2x_cl45_write(bp, phy, |
| 8294 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_AN, 0x1000); |
| 8295 | /* 1G support */ |
| 8296 | bnx2x_cl45_write(bp, phy, |
| 8297 | MDIO_AN_DEVAD, MDIO_AN_REG_ADV, (1<<5)); |
| 8298 | |
| 8299 | /* Enable clause 73 AN */ |
| 8300 | bnx2x_cl45_write(bp, phy, |
| 8301 | MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, 0x1200); |
| 8302 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8303 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_RXCTRL, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8304 | 0x0400); |
| 8305 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8306 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_CTRL, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8307 | 0x0004); |
| 8308 | } |
| 8309 | bnx2x_save_bcm_spirom_ver(bp, phy, params->port); |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8310 | |
| 8311 | /* |
| 8312 | * If TX Laser is controlled by GPIO_0, do not let PHY go into low |
| 8313 | * power mode, if TX Laser is disabled |
| 8314 | */ |
| 8315 | |
| 8316 | tx_en_mode = REG_RD(bp, params->shmem_base + |
| 8317 | offsetof(struct shmem_region, |
| 8318 | dev_info.port_hw_config[params->port].sfp_ctrl)) |
| 8319 | & PORT_HW_CFG_TX_LASER_MASK; |
| 8320 | |
| 8321 | if (tx_en_mode == PORT_HW_CFG_TX_LASER_GPIO0) { |
| 8322 | DP(NETIF_MSG_LINK, "Enabling TXONOFF_PWRDN_DIS\n"); |
| 8323 | bnx2x_cl45_read(bp, phy, |
| 8324 | MDIO_PMA_DEVAD, MDIO_PMA_REG_DIGITAL_CTRL, &tmp1); |
| 8325 | tmp1 |= 0x1; |
| 8326 | bnx2x_cl45_write(bp, phy, |
| 8327 | MDIO_PMA_DEVAD, MDIO_PMA_REG_DIGITAL_CTRL, tmp1); |
| 8328 | } |
| 8329 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8330 | return 0; |
| 8331 | } |
| 8332 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 8333 | static int bnx2x_8706_read_status(struct bnx2x_phy *phy, |
| 8334 | struct link_params *params, |
| 8335 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8336 | { |
| 8337 | return bnx2x_8706_8726_read_status(phy, params, vars); |
| 8338 | } |
| 8339 | |
| 8340 | /******************************************************************/ |
| 8341 | /* BCM8726 PHY SECTION */ |
| 8342 | /******************************************************************/ |
| 8343 | static void bnx2x_8726_config_loopback(struct bnx2x_phy *phy, |
| 8344 | struct link_params *params) |
| 8345 | { |
| 8346 | struct bnx2x *bp = params->bp; |
| 8347 | DP(NETIF_MSG_LINK, "PMA/PMD ext_phy_loopback: 8726\n"); |
| 8348 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 0x0001); |
| 8349 | } |
| 8350 | |
| 8351 | static void bnx2x_8726_external_rom_boot(struct bnx2x_phy *phy, |
| 8352 | struct link_params *params) |
| 8353 | { |
| 8354 | struct bnx2x *bp = params->bp; |
| 8355 | /* Need to wait 100ms after reset */ |
| 8356 | msleep(100); |
| 8357 | |
| 8358 | /* Micro controller re-boot */ |
| 8359 | bnx2x_cl45_write(bp, phy, |
| 8360 | MDIO_PMA_DEVAD, MDIO_PMA_REG_GEN_CTRL, 0x018B); |
| 8361 | |
| 8362 | /* Set soft reset */ |
| 8363 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8364 | MDIO_PMA_DEVAD, |
| 8365 | MDIO_PMA_REG_GEN_CTRL, |
| 8366 | MDIO_PMA_REG_GEN_CTRL_ROM_MICRO_RESET); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8367 | |
| 8368 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8369 | MDIO_PMA_DEVAD, |
| 8370 | MDIO_PMA_REG_MISC_CTRL1, 0x0001); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8371 | |
| 8372 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8373 | MDIO_PMA_DEVAD, |
| 8374 | MDIO_PMA_REG_GEN_CTRL, |
| 8375 | MDIO_PMA_REG_GEN_CTRL_ROM_RESET_INTERNAL_MP); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8376 | |
| 8377 | /* wait for 150ms for microcode load */ |
| 8378 | msleep(150); |
| 8379 | |
| 8380 | /* Disable serial boot control, tristates pins SS_N, SCK, MOSI, MISO */ |
| 8381 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8382 | MDIO_PMA_DEVAD, |
| 8383 | MDIO_PMA_REG_MISC_CTRL1, 0x0000); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8384 | |
| 8385 | msleep(200); |
| 8386 | bnx2x_save_bcm_spirom_ver(bp, phy, params->port); |
| 8387 | } |
| 8388 | |
| 8389 | static u8 bnx2x_8726_read_status(struct bnx2x_phy *phy, |
| 8390 | struct link_params *params, |
| 8391 | struct link_vars *vars) |
| 8392 | { |
| 8393 | struct bnx2x *bp = params->bp; |
| 8394 | u16 val1; |
| 8395 | u8 link_up = bnx2x_8706_8726_read_status(phy, params, vars); |
| 8396 | if (link_up) { |
| 8397 | bnx2x_cl45_read(bp, phy, |
| 8398 | MDIO_PMA_DEVAD, MDIO_PMA_REG_PHY_IDENTIFIER, |
| 8399 | &val1); |
| 8400 | if (val1 & (1<<15)) { |
| 8401 | DP(NETIF_MSG_LINK, "Tx is disabled\n"); |
| 8402 | link_up = 0; |
| 8403 | vars->line_speed = 0; |
| 8404 | } |
| 8405 | } |
| 8406 | return link_up; |
| 8407 | } |
| 8408 | |
| 8409 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 8410 | static int bnx2x_8726_config_init(struct bnx2x_phy *phy, |
| 8411 | struct link_params *params, |
| 8412 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8413 | { |
| 8414 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8415 | DP(NETIF_MSG_LINK, "Initializing BCM8726\n"); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8416 | |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 8417 | /* SPF+ PHY: Set flag to check for Tx error */ |
| 8418 | vars->phy_flags = PHY_TX_ERROR_CHECK_FLAG; |
| 8419 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8420 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 1<<15); |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 8421 | bnx2x_wait_reset_complete(bp, phy, params); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8422 | |
| 8423 | bnx2x_8726_external_rom_boot(phy, params); |
| 8424 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8425 | /* |
| 8426 | * Need to call module detected on initialization since the module |
| 8427 | * detection triggered by actual module insertion might occur before |
| 8428 | * driver is loaded, and when driver is loaded, it reset all |
| 8429 | * registers, including the transmitter |
| 8430 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8431 | bnx2x_sfp_module_detection(phy, params); |
| 8432 | |
| 8433 | if (phy->req_line_speed == SPEED_1000) { |
| 8434 | DP(NETIF_MSG_LINK, "Setting 1G force\n"); |
| 8435 | bnx2x_cl45_write(bp, phy, |
| 8436 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 0x40); |
| 8437 | bnx2x_cl45_write(bp, phy, |
| 8438 | MDIO_PMA_DEVAD, MDIO_PMA_REG_10G_CTRL2, 0xD); |
| 8439 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8440 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_CTRL, 0x5); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8441 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8442 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_RXCTRL, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8443 | 0x400); |
| 8444 | } else if ((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 8445 | (phy->speed_cap_mask & |
| 8446 | PORT_HW_CFG_SPEED_CAPABILITY_D0_1G) && |
| 8447 | ((phy->speed_cap_mask & |
| 8448 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G) != |
| 8449 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G)) { |
| 8450 | DP(NETIF_MSG_LINK, "Setting 1G clause37\n"); |
| 8451 | /* Set Flow control */ |
| 8452 | bnx2x_ext_phy_set_pause(params, phy, vars); |
| 8453 | bnx2x_cl45_write(bp, phy, |
| 8454 | MDIO_AN_DEVAD, MDIO_AN_REG_ADV, 0x20); |
| 8455 | bnx2x_cl45_write(bp, phy, |
| 8456 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_CL73, 0x040c); |
| 8457 | bnx2x_cl45_write(bp, phy, |
| 8458 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_FC_LD, 0x0020); |
| 8459 | bnx2x_cl45_write(bp, phy, |
| 8460 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_AN, 0x1000); |
| 8461 | bnx2x_cl45_write(bp, phy, |
| 8462 | MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, 0x1200); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8463 | /* |
| 8464 | * Enable RX-ALARM control to receive interrupt for 1G speed |
| 8465 | * change |
| 8466 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8467 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8468 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_CTRL, 0x4); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8469 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8470 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_RXCTRL, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8471 | 0x400); |
| 8472 | |
| 8473 | } else { /* Default 10G. Set only LASI control */ |
| 8474 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8475 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_CTRL, 1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8476 | } |
| 8477 | |
| 8478 | /* Set TX PreEmphasis if needed */ |
| 8479 | if ((params->feature_config_flags & |
| 8480 | FEATURE_CONFIG_OVERRIDE_PREEMPHASIS_ENABLED)) { |
| 8481 | DP(NETIF_MSG_LINK, "Setting TX_CTRL1 0x%x," |
| 8482 | "TX_CTRL2 0x%x\n", |
| 8483 | phy->tx_preemphasis[0], |
| 8484 | phy->tx_preemphasis[1]); |
| 8485 | bnx2x_cl45_write(bp, phy, |
| 8486 | MDIO_PMA_DEVAD, |
| 8487 | MDIO_PMA_REG_8726_TX_CTRL1, |
| 8488 | phy->tx_preemphasis[0]); |
| 8489 | |
| 8490 | bnx2x_cl45_write(bp, phy, |
| 8491 | MDIO_PMA_DEVAD, |
| 8492 | MDIO_PMA_REG_8726_TX_CTRL2, |
| 8493 | phy->tx_preemphasis[1]); |
| 8494 | } |
| 8495 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8496 | return 0; |
| 8497 | |
| 8498 | } |
| 8499 | |
| 8500 | static void bnx2x_8726_link_reset(struct bnx2x_phy *phy, |
| 8501 | struct link_params *params) |
| 8502 | { |
| 8503 | struct bnx2x *bp = params->bp; |
| 8504 | DP(NETIF_MSG_LINK, "bnx2x_8726_link_reset port %d\n", params->port); |
| 8505 | /* Set serial boot control for external load */ |
| 8506 | bnx2x_cl45_write(bp, phy, |
| 8507 | MDIO_PMA_DEVAD, |
| 8508 | MDIO_PMA_REG_GEN_CTRL, 0x0001); |
| 8509 | } |
| 8510 | |
| 8511 | /******************************************************************/ |
| 8512 | /* BCM8727 PHY SECTION */ |
| 8513 | /******************************************************************/ |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 8514 | |
| 8515 | static void bnx2x_8727_set_link_led(struct bnx2x_phy *phy, |
| 8516 | struct link_params *params, u8 mode) |
| 8517 | { |
| 8518 | struct bnx2x *bp = params->bp; |
| 8519 | u16 led_mode_bitmask = 0; |
| 8520 | u16 gpio_pins_bitmask = 0; |
| 8521 | u16 val; |
| 8522 | /* Only NOC flavor requires to set the LED specifically */ |
| 8523 | if (!(phy->flags & FLAGS_NOC)) |
| 8524 | return; |
| 8525 | switch (mode) { |
| 8526 | case LED_MODE_FRONT_PANEL_OFF: |
| 8527 | case LED_MODE_OFF: |
| 8528 | led_mode_bitmask = 0; |
| 8529 | gpio_pins_bitmask = 0x03; |
| 8530 | break; |
| 8531 | case LED_MODE_ON: |
| 8532 | led_mode_bitmask = 0; |
| 8533 | gpio_pins_bitmask = 0x02; |
| 8534 | break; |
| 8535 | case LED_MODE_OPER: |
| 8536 | led_mode_bitmask = 0x60; |
| 8537 | gpio_pins_bitmask = 0x11; |
| 8538 | break; |
| 8539 | } |
| 8540 | bnx2x_cl45_read(bp, phy, |
| 8541 | MDIO_PMA_DEVAD, |
| 8542 | MDIO_PMA_REG_8727_PCS_OPT_CTRL, |
| 8543 | &val); |
| 8544 | val &= 0xff8f; |
| 8545 | val |= led_mode_bitmask; |
| 8546 | bnx2x_cl45_write(bp, phy, |
| 8547 | MDIO_PMA_DEVAD, |
| 8548 | MDIO_PMA_REG_8727_PCS_OPT_CTRL, |
| 8549 | val); |
| 8550 | bnx2x_cl45_read(bp, phy, |
| 8551 | MDIO_PMA_DEVAD, |
| 8552 | MDIO_PMA_REG_8727_GPIO_CTRL, |
| 8553 | &val); |
| 8554 | val &= 0xffe0; |
| 8555 | val |= gpio_pins_bitmask; |
| 8556 | bnx2x_cl45_write(bp, phy, |
| 8557 | MDIO_PMA_DEVAD, |
| 8558 | MDIO_PMA_REG_8727_GPIO_CTRL, |
| 8559 | val); |
| 8560 | } |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 8561 | static void bnx2x_8727_hw_reset(struct bnx2x_phy *phy, |
| 8562 | struct link_params *params) { |
| 8563 | u32 swap_val, swap_override; |
| 8564 | u8 port; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8565 | /* |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 8566 | * The PHY reset is controlled by GPIO 1. Fake the port number |
| 8567 | * to cancel the swap done in set_gpio() |
| 8568 | */ |
| 8569 | struct bnx2x *bp = params->bp; |
| 8570 | swap_val = REG_RD(bp, NIG_REG_PORT_SWAP); |
| 8571 | swap_override = REG_RD(bp, NIG_REG_STRAP_OVERRIDE); |
| 8572 | port = (swap_val && swap_override) ^ 1; |
| 8573 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8574 | MISC_REGISTERS_GPIO_OUTPUT_LOW, port); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 8575 | } |
| 8576 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 8577 | static int bnx2x_8727_config_init(struct bnx2x_phy *phy, |
| 8578 | struct link_params *params, |
| 8579 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8580 | { |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8581 | u32 tx_en_mode; |
| 8582 | u16 tmp1, val, mod_abs, tmp2; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8583 | u16 rx_alarm_ctrl_val; |
| 8584 | u16 lasi_ctrl_val; |
| 8585 | struct bnx2x *bp = params->bp; |
| 8586 | /* Enable PMD link, MOD_ABS_FLT, and 1G link alarm */ |
| 8587 | |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 8588 | /* SPF+ PHY: Set flag to check for Tx error */ |
| 8589 | vars->phy_flags = PHY_TX_ERROR_CHECK_FLAG; |
| 8590 | |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 8591 | bnx2x_wait_reset_complete(bp, phy, params); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8592 | rx_alarm_ctrl_val = (1<<2) | (1<<5) ; |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 8593 | /* Should be 0x6 to enable XS on Tx side. */ |
| 8594 | lasi_ctrl_val = 0x0006; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8595 | |
| 8596 | DP(NETIF_MSG_LINK, "Initializing BCM8727\n"); |
| 8597 | /* enable LASI */ |
| 8598 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8599 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_RXCTRL, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8600 | rx_alarm_ctrl_val); |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 8601 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8602 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_TXCTRL, |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 8603 | 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8604 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8605 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_CTRL, lasi_ctrl_val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8606 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8607 | /* |
| 8608 | * Initially configure MOD_ABS to interrupt when module is |
| 8609 | * presence( bit 8) |
| 8610 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8611 | bnx2x_cl45_read(bp, phy, |
| 8612 | MDIO_PMA_DEVAD, MDIO_PMA_REG_PHY_IDENTIFIER, &mod_abs); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8613 | /* |
| 8614 | * Set EDC off by setting OPTXLOS signal input to low (bit 9). |
| 8615 | * When the EDC is off it locks onto a reference clock and avoids |
| 8616 | * becoming 'lost' |
| 8617 | */ |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 8618 | mod_abs &= ~(1<<8); |
| 8619 | if (!(phy->flags & FLAGS_NOC)) |
| 8620 | mod_abs &= ~(1<<9); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8621 | bnx2x_cl45_write(bp, phy, |
| 8622 | MDIO_PMA_DEVAD, MDIO_PMA_REG_PHY_IDENTIFIER, mod_abs); |
| 8623 | |
| 8624 | |
Yaniv Rosner | 85242ee | 2011-07-05 01:06:53 +0000 | [diff] [blame] | 8625 | /* Enable/Disable PHY transmitter output */ |
| 8626 | bnx2x_set_disable_pmd_transmit(params, phy, 0); |
| 8627 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8628 | /* Make MOD_ABS give interrupt on change */ |
| 8629 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_PCS_OPT_CTRL, |
| 8630 | &val); |
| 8631 | val |= (1<<12); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 8632 | if (phy->flags & FLAGS_NOC) |
| 8633 | val |= (3<<5); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8634 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8635 | /* |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 8636 | * Set 8727 GPIOs to input to allow reading from the 8727 GPIO0 |
| 8637 | * status which reflect SFP+ module over-current |
| 8638 | */ |
| 8639 | if (!(phy->flags & FLAGS_NOC)) |
| 8640 | val &= 0xff8f; /* Reset bits 4-6 */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8641 | bnx2x_cl45_write(bp, phy, |
| 8642 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_PCS_OPT_CTRL, val); |
| 8643 | |
| 8644 | bnx2x_8727_power_module(bp, phy, 1); |
| 8645 | |
| 8646 | bnx2x_cl45_read(bp, phy, |
| 8647 | MDIO_PMA_DEVAD, MDIO_PMA_REG_M8051_MSGOUT_REG, &tmp1); |
| 8648 | |
| 8649 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8650 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_RXSTAT, &tmp1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8651 | |
| 8652 | /* Set option 1G speed */ |
| 8653 | if (phy->req_line_speed == SPEED_1000) { |
| 8654 | DP(NETIF_MSG_LINK, "Setting 1G force\n"); |
| 8655 | bnx2x_cl45_write(bp, phy, |
| 8656 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 0x40); |
| 8657 | bnx2x_cl45_write(bp, phy, |
| 8658 | MDIO_PMA_DEVAD, MDIO_PMA_REG_10G_CTRL2, 0xD); |
| 8659 | bnx2x_cl45_read(bp, phy, |
| 8660 | MDIO_PMA_DEVAD, MDIO_PMA_REG_10G_CTRL2, &tmp1); |
| 8661 | DP(NETIF_MSG_LINK, "1.7 = 0x%x\n", tmp1); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8662 | /* |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8663 | * Power down the XAUI until link is up in case of dual-media |
| 8664 | * and 1G |
| 8665 | */ |
| 8666 | if (DUAL_MEDIA(params)) { |
| 8667 | bnx2x_cl45_read(bp, phy, |
| 8668 | MDIO_PMA_DEVAD, |
| 8669 | MDIO_PMA_REG_8727_PCS_GP, &val); |
| 8670 | val |= (3<<10); |
| 8671 | bnx2x_cl45_write(bp, phy, |
| 8672 | MDIO_PMA_DEVAD, |
| 8673 | MDIO_PMA_REG_8727_PCS_GP, val); |
| 8674 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8675 | } else if ((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 8676 | ((phy->speed_cap_mask & |
| 8677 | PORT_HW_CFG_SPEED_CAPABILITY_D0_1G)) && |
| 8678 | ((phy->speed_cap_mask & |
| 8679 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G) != |
| 8680 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G)) { |
| 8681 | |
| 8682 | DP(NETIF_MSG_LINK, "Setting 1G clause37\n"); |
| 8683 | bnx2x_cl45_write(bp, phy, |
| 8684 | MDIO_AN_DEVAD, MDIO_AN_REG_8727_MISC_CTRL, 0); |
| 8685 | bnx2x_cl45_write(bp, phy, |
| 8686 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_AN, 0x1300); |
| 8687 | } else { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8688 | /* |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8689 | * Since the 8727 has only single reset pin, need to set the 10G |
| 8690 | * registers although it is default |
| 8691 | */ |
| 8692 | bnx2x_cl45_write(bp, phy, |
| 8693 | MDIO_AN_DEVAD, MDIO_AN_REG_8727_MISC_CTRL, |
| 8694 | 0x0020); |
| 8695 | bnx2x_cl45_write(bp, phy, |
| 8696 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_AN, 0x0100); |
| 8697 | bnx2x_cl45_write(bp, phy, |
| 8698 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 0x2040); |
| 8699 | bnx2x_cl45_write(bp, phy, |
| 8700 | MDIO_PMA_DEVAD, MDIO_PMA_REG_10G_CTRL2, |
| 8701 | 0x0008); |
| 8702 | } |
| 8703 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8704 | /* |
| 8705 | * Set 2-wire transfer rate of SFP+ module EEPROM |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8706 | * to 100Khz since some DACs(direct attached cables) do |
| 8707 | * not work at 400Khz. |
| 8708 | */ |
| 8709 | bnx2x_cl45_write(bp, phy, |
| 8710 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_TWO_WIRE_SLAVE_ADDR, |
| 8711 | 0xa001); |
| 8712 | |
| 8713 | /* Set TX PreEmphasis if needed */ |
| 8714 | if ((params->feature_config_flags & |
| 8715 | FEATURE_CONFIG_OVERRIDE_PREEMPHASIS_ENABLED)) { |
| 8716 | DP(NETIF_MSG_LINK, "Setting TX_CTRL1 0x%x, TX_CTRL2 0x%x\n", |
| 8717 | phy->tx_preemphasis[0], |
| 8718 | phy->tx_preemphasis[1]); |
| 8719 | bnx2x_cl45_write(bp, phy, |
| 8720 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_TX_CTRL1, |
| 8721 | phy->tx_preemphasis[0]); |
| 8722 | |
| 8723 | bnx2x_cl45_write(bp, phy, |
| 8724 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_TX_CTRL2, |
| 8725 | phy->tx_preemphasis[1]); |
| 8726 | } |
| 8727 | |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8728 | /* |
| 8729 | * If TX Laser is controlled by GPIO_0, do not let PHY go into low |
| 8730 | * power mode, if TX Laser is disabled |
| 8731 | */ |
| 8732 | tx_en_mode = REG_RD(bp, params->shmem_base + |
| 8733 | offsetof(struct shmem_region, |
| 8734 | dev_info.port_hw_config[params->port].sfp_ctrl)) |
| 8735 | & PORT_HW_CFG_TX_LASER_MASK; |
| 8736 | |
| 8737 | if (tx_en_mode == PORT_HW_CFG_TX_LASER_GPIO0) { |
| 8738 | |
| 8739 | DP(NETIF_MSG_LINK, "Enabling TXONOFF_PWRDN_DIS\n"); |
| 8740 | bnx2x_cl45_read(bp, phy, |
| 8741 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_OPT_CFG_REG, &tmp2); |
| 8742 | tmp2 |= 0x1000; |
| 8743 | tmp2 &= 0xFFEF; |
| 8744 | bnx2x_cl45_write(bp, phy, |
| 8745 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_OPT_CFG_REG, tmp2); |
| 8746 | } |
| 8747 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8748 | return 0; |
| 8749 | } |
| 8750 | |
| 8751 | static void bnx2x_8727_handle_mod_abs(struct bnx2x_phy *phy, |
| 8752 | struct link_params *params) |
| 8753 | { |
| 8754 | struct bnx2x *bp = params->bp; |
| 8755 | u16 mod_abs, rx_alarm_status; |
| 8756 | u32 val = REG_RD(bp, params->shmem_base + |
| 8757 | offsetof(struct shmem_region, dev_info. |
| 8758 | port_feature_config[params->port]. |
| 8759 | config)); |
| 8760 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8761 | MDIO_PMA_DEVAD, |
| 8762 | MDIO_PMA_REG_PHY_IDENTIFIER, &mod_abs); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8763 | if (mod_abs & (1<<8)) { |
| 8764 | |
| 8765 | /* Module is absent */ |
| 8766 | DP(NETIF_MSG_LINK, "MOD_ABS indication " |
| 8767 | "show module is absent\n"); |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 8768 | phy->media_type = ETH_PHY_NOT_PRESENT; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8769 | /* |
| 8770 | * 1. Set mod_abs to detect next module |
| 8771 | * presence event |
| 8772 | * 2. Set EDC off by setting OPTXLOS signal input to low |
| 8773 | * (bit 9). |
| 8774 | * When the EDC is off it locks onto a reference clock and |
| 8775 | * avoids becoming 'lost'. |
| 8776 | */ |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 8777 | mod_abs &= ~(1<<8); |
| 8778 | if (!(phy->flags & FLAGS_NOC)) |
| 8779 | mod_abs &= ~(1<<9); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8780 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8781 | MDIO_PMA_DEVAD, |
| 8782 | MDIO_PMA_REG_PHY_IDENTIFIER, mod_abs); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8783 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8784 | /* |
| 8785 | * Clear RX alarm since it stays up as long as |
| 8786 | * the mod_abs wasn't changed |
| 8787 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8788 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8789 | MDIO_PMA_DEVAD, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8790 | MDIO_PMA_LASI_RXSTAT, &rx_alarm_status); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8791 | |
| 8792 | } else { |
| 8793 | /* Module is present */ |
| 8794 | DP(NETIF_MSG_LINK, "MOD_ABS indication " |
| 8795 | "show module is present\n"); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8796 | /* |
| 8797 | * First disable transmitter, and if the module is ok, the |
| 8798 | * module_detection will enable it |
| 8799 | * 1. Set mod_abs to detect next module absent event ( bit 8) |
| 8800 | * 2. Restore the default polarity of the OPRXLOS signal and |
| 8801 | * this signal will then correctly indicate the presence or |
| 8802 | * absence of the Rx signal. (bit 9) |
| 8803 | */ |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 8804 | mod_abs |= (1<<8); |
| 8805 | if (!(phy->flags & FLAGS_NOC)) |
| 8806 | mod_abs |= (1<<9); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8807 | bnx2x_cl45_write(bp, phy, |
| 8808 | MDIO_PMA_DEVAD, |
| 8809 | MDIO_PMA_REG_PHY_IDENTIFIER, mod_abs); |
| 8810 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8811 | /* |
| 8812 | * Clear RX alarm since it stays up as long as the mod_abs |
| 8813 | * wasn't changed. This is need to be done before calling the |
| 8814 | * module detection, otherwise it will clear* the link update |
| 8815 | * alarm |
| 8816 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8817 | bnx2x_cl45_read(bp, phy, |
| 8818 | MDIO_PMA_DEVAD, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8819 | MDIO_PMA_LASI_RXSTAT, &rx_alarm_status); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8820 | |
| 8821 | |
| 8822 | if ((val & PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK) == |
| 8823 | PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_DISABLE_TX_LASER) |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8824 | bnx2x_sfp_set_transmitter(params, phy, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8825 | |
| 8826 | if (bnx2x_wait_for_sfp_module_initialized(phy, params) == 0) |
| 8827 | bnx2x_sfp_module_detection(phy, params); |
| 8828 | else |
| 8829 | DP(NETIF_MSG_LINK, "SFP+ module is not initialized\n"); |
| 8830 | } |
| 8831 | |
| 8832 | DP(NETIF_MSG_LINK, "8727 RX_ALARM_STATUS 0x%x\n", |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8833 | rx_alarm_status); |
| 8834 | /* No need to check link status in case of module plugged in/out */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8835 | } |
| 8836 | |
| 8837 | static u8 bnx2x_8727_read_status(struct bnx2x_phy *phy, |
| 8838 | struct link_params *params, |
| 8839 | struct link_vars *vars) |
| 8840 | |
| 8841 | { |
| 8842 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 27d0243 | 2011-05-31 21:27:48 +0000 | [diff] [blame] | 8843 | u8 link_up = 0, oc_port = params->port; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8844 | u16 link_status = 0; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8845 | u16 rx_alarm_status, lasi_ctrl, val1; |
| 8846 | |
| 8847 | /* If PHY is not initialized, do not check link status */ |
| 8848 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8849 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_CTRL, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8850 | &lasi_ctrl); |
| 8851 | if (!lasi_ctrl) |
| 8852 | return 0; |
| 8853 | |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 8854 | /* Check the LASI on Rx */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8855 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8856 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_RXSTAT, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8857 | &rx_alarm_status); |
| 8858 | vars->line_speed = 0; |
| 8859 | DP(NETIF_MSG_LINK, "8727 RX_ALARM_STATUS 0x%x\n", rx_alarm_status); |
| 8860 | |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8861 | bnx2x_sfp_mask_fault(bp, phy, MDIO_PMA_LASI_TXSTAT, |
| 8862 | MDIO_PMA_LASI_TXCTRL); |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 8863 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8864 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8865 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_STAT, &val1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8866 | |
| 8867 | DP(NETIF_MSG_LINK, "8727 LASI status 0x%x\n", val1); |
| 8868 | |
| 8869 | /* Clear MSG-OUT */ |
| 8870 | bnx2x_cl45_read(bp, phy, |
| 8871 | MDIO_PMA_DEVAD, MDIO_PMA_REG_M8051_MSGOUT_REG, &val1); |
| 8872 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8873 | /* |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8874 | * If a module is present and there is need to check |
| 8875 | * for over current |
| 8876 | */ |
| 8877 | if (!(phy->flags & FLAGS_NOC) && !(rx_alarm_status & (1<<5))) { |
| 8878 | /* Check over-current using 8727 GPIO0 input*/ |
| 8879 | bnx2x_cl45_read(bp, phy, |
| 8880 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_GPIO_CTRL, |
| 8881 | &val1); |
| 8882 | |
| 8883 | if ((val1 & (1<<8)) == 0) { |
Yaniv Rosner | 27d0243 | 2011-05-31 21:27:48 +0000 | [diff] [blame] | 8884 | if (!CHIP_IS_E1x(bp)) |
| 8885 | oc_port = BP_PATH(bp) + (params->port << 1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8886 | DP(NETIF_MSG_LINK, "8727 Power fault has been detected" |
Yaniv Rosner | 27d0243 | 2011-05-31 21:27:48 +0000 | [diff] [blame] | 8887 | " on port %d\n", oc_port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8888 | netdev_err(bp->dev, "Error: Power fault on Port %d has" |
| 8889 | " been detected and the power to " |
| 8890 | "that SFP+ module has been removed" |
| 8891 | " to prevent failure of the card." |
| 8892 | " Please remove the SFP+ module and" |
| 8893 | " restart the system to clear this" |
| 8894 | " error.\n", |
Yaniv Rosner | 27d0243 | 2011-05-31 21:27:48 +0000 | [diff] [blame] | 8895 | oc_port); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8896 | /* Disable all RX_ALARMs except for mod_abs */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8897 | bnx2x_cl45_write(bp, phy, |
| 8898 | MDIO_PMA_DEVAD, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8899 | MDIO_PMA_LASI_RXCTRL, (1<<5)); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8900 | |
| 8901 | bnx2x_cl45_read(bp, phy, |
| 8902 | MDIO_PMA_DEVAD, |
| 8903 | MDIO_PMA_REG_PHY_IDENTIFIER, &val1); |
| 8904 | /* Wait for module_absent_event */ |
| 8905 | val1 |= (1<<8); |
| 8906 | bnx2x_cl45_write(bp, phy, |
| 8907 | MDIO_PMA_DEVAD, |
| 8908 | MDIO_PMA_REG_PHY_IDENTIFIER, val1); |
| 8909 | /* Clear RX alarm */ |
| 8910 | bnx2x_cl45_read(bp, phy, |
| 8911 | MDIO_PMA_DEVAD, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8912 | MDIO_PMA_LASI_RXSTAT, &rx_alarm_status); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8913 | return 0; |
| 8914 | } |
| 8915 | } /* Over current check */ |
| 8916 | |
| 8917 | /* When module absent bit is set, check module */ |
| 8918 | if (rx_alarm_status & (1<<5)) { |
| 8919 | bnx2x_8727_handle_mod_abs(phy, params); |
| 8920 | /* Enable all mod_abs and link detection bits */ |
| 8921 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8922 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_RXCTRL, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8923 | ((1<<5) | (1<<2))); |
| 8924 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8925 | DP(NETIF_MSG_LINK, "Enabling 8727 TX laser if SFP is approved\n"); |
| 8926 | bnx2x_8727_specific_func(phy, params, ENABLE_TX); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8927 | /* If transmitter is disabled, ignore false link up indication */ |
| 8928 | bnx2x_cl45_read(bp, phy, |
| 8929 | MDIO_PMA_DEVAD, MDIO_PMA_REG_PHY_IDENTIFIER, &val1); |
| 8930 | if (val1 & (1<<15)) { |
| 8931 | DP(NETIF_MSG_LINK, "Tx is disabled\n"); |
| 8932 | return 0; |
| 8933 | } |
| 8934 | |
| 8935 | bnx2x_cl45_read(bp, phy, |
| 8936 | MDIO_PMA_DEVAD, |
| 8937 | MDIO_PMA_REG_8073_SPEED_LINK_STATUS, &link_status); |
| 8938 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8939 | /* |
| 8940 | * Bits 0..2 --> speed detected, |
| 8941 | * Bits 13..15--> link is down |
| 8942 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8943 | if ((link_status & (1<<2)) && (!(link_status & (1<<15)))) { |
| 8944 | link_up = 1; |
| 8945 | vars->line_speed = SPEED_10000; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8946 | DP(NETIF_MSG_LINK, "port %x: External link up in 10G\n", |
| 8947 | params->port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8948 | } else if ((link_status & (1<<0)) && (!(link_status & (1<<13)))) { |
| 8949 | link_up = 1; |
| 8950 | vars->line_speed = SPEED_1000; |
| 8951 | DP(NETIF_MSG_LINK, "port %x: External link up in 1G\n", |
| 8952 | params->port); |
| 8953 | } else { |
| 8954 | link_up = 0; |
| 8955 | DP(NETIF_MSG_LINK, "port %x: External link is down\n", |
| 8956 | params->port); |
| 8957 | } |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 8958 | |
| 8959 | /* Capture 10G link fault. */ |
| 8960 | if (vars->line_speed == SPEED_10000) { |
| 8961 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8962 | MDIO_PMA_LASI_TXSTAT, &val1); |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 8963 | |
| 8964 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8965 | MDIO_PMA_LASI_TXSTAT, &val1); |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 8966 | |
| 8967 | if (val1 & (1<<0)) { |
| 8968 | vars->fault_detected = 1; |
| 8969 | } |
| 8970 | } |
| 8971 | |
Yaniv Rosner | 791f18c | 2011-01-18 04:33:42 +0000 | [diff] [blame] | 8972 | if (link_up) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8973 | bnx2x_ext_phy_resolve_fc(phy, params, vars); |
Yaniv Rosner | 791f18c | 2011-01-18 04:33:42 +0000 | [diff] [blame] | 8974 | vars->duplex = DUPLEX_FULL; |
| 8975 | DP(NETIF_MSG_LINK, "duplex = 0x%x\n", vars->duplex); |
| 8976 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8977 | |
| 8978 | if ((DUAL_MEDIA(params)) && |
| 8979 | (phy->req_line_speed == SPEED_1000)) { |
| 8980 | bnx2x_cl45_read(bp, phy, |
| 8981 | MDIO_PMA_DEVAD, |
| 8982 | MDIO_PMA_REG_8727_PCS_GP, &val1); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8983 | /* |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8984 | * In case of dual-media board and 1G, power up the XAUI side, |
| 8985 | * otherwise power it down. For 10G it is done automatically |
| 8986 | */ |
| 8987 | if (link_up) |
| 8988 | val1 &= ~(3<<10); |
| 8989 | else |
| 8990 | val1 |= (3<<10); |
| 8991 | bnx2x_cl45_write(bp, phy, |
| 8992 | MDIO_PMA_DEVAD, |
| 8993 | MDIO_PMA_REG_8727_PCS_GP, val1); |
| 8994 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8995 | return link_up; |
| 8996 | } |
| 8997 | |
| 8998 | static void bnx2x_8727_link_reset(struct bnx2x_phy *phy, |
| 8999 | struct link_params *params) |
| 9000 | { |
| 9001 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 85242ee | 2011-07-05 01:06:53 +0000 | [diff] [blame] | 9002 | |
| 9003 | /* Enable/Disable PHY transmitter output */ |
| 9004 | bnx2x_set_disable_pmd_transmit(params, phy, 1); |
| 9005 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9006 | /* Disable Transmitter */ |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 9007 | bnx2x_sfp_set_transmitter(params, phy, 0); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 9008 | /* Clear LASI */ |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 9009 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, MDIO_PMA_LASI_CTRL, 0); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 9010 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9011 | } |
| 9012 | |
| 9013 | /******************************************************************/ |
| 9014 | /* BCM8481/BCM84823/BCM84833 PHY SECTION */ |
| 9015 | /******************************************************************/ |
| 9016 | static void bnx2x_save_848xx_spirom_version(struct bnx2x_phy *phy, |
| 9017 | struct link_params *params) |
| 9018 | { |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9019 | u16 val, fw_ver1, fw_ver2, cnt; |
| 9020 | u8 port; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9021 | struct bnx2x *bp = params->bp; |
| 9022 | |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9023 | port = params->port; |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 9024 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9025 | /* For the 32 bits registers in 848xx, access via MDIO2ARM interface.*/ |
| 9026 | /* (1) set register 0xc200_0014(SPI_BRIDGE_CTRL_2) to 0x03000000 */ |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9027 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA819, 0x0014); |
| 9028 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA81A, 0xc200); |
| 9029 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA81B, 0x0000); |
| 9030 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA81C, 0x0300); |
| 9031 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA817, 0x0009); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9032 | |
| 9033 | for (cnt = 0; cnt < 100; cnt++) { |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9034 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, 0xA818, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9035 | if (val & 1) |
| 9036 | break; |
| 9037 | udelay(5); |
| 9038 | } |
| 9039 | if (cnt == 100) { |
| 9040 | DP(NETIF_MSG_LINK, "Unable to read 848xx phy fw version(1)\n"); |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9041 | bnx2x_save_spirom_version(bp, port, 0, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9042 | phy->ver_addr); |
| 9043 | return; |
| 9044 | } |
| 9045 | |
| 9046 | |
| 9047 | /* 2) read register 0xc200_0000 (SPI_FW_STATUS) */ |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9048 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA819, 0x0000); |
| 9049 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA81A, 0xc200); |
| 9050 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA817, 0x000A); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9051 | for (cnt = 0; cnt < 100; cnt++) { |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9052 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, 0xA818, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9053 | if (val & 1) |
| 9054 | break; |
| 9055 | udelay(5); |
| 9056 | } |
| 9057 | if (cnt == 100) { |
| 9058 | DP(NETIF_MSG_LINK, "Unable to read 848xx phy fw version(2)\n"); |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9059 | bnx2x_save_spirom_version(bp, port, 0, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9060 | phy->ver_addr); |
| 9061 | return; |
| 9062 | } |
| 9063 | |
| 9064 | /* lower 16 bits of the register SPI_FW_STATUS */ |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9065 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, 0xA81B, &fw_ver1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9066 | /* upper 16 bits of register SPI_FW_STATUS */ |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9067 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, 0xA81C, &fw_ver2); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9068 | |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9069 | bnx2x_save_spirom_version(bp, port, (fw_ver2<<16) | fw_ver1, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9070 | phy->ver_addr); |
| 9071 | } |
| 9072 | |
| 9073 | static void bnx2x_848xx_set_led(struct bnx2x *bp, |
| 9074 | struct bnx2x_phy *phy) |
| 9075 | { |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9076 | u16 val; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9077 | |
| 9078 | /* PHYC_CTL_LED_CTL */ |
| 9079 | bnx2x_cl45_read(bp, phy, |
| 9080 | MDIO_PMA_DEVAD, |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9081 | MDIO_PMA_REG_8481_LINK_SIGNAL, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9082 | val &= 0xFE00; |
| 9083 | val |= 0x0092; |
| 9084 | |
| 9085 | bnx2x_cl45_write(bp, phy, |
| 9086 | MDIO_PMA_DEVAD, |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9087 | MDIO_PMA_REG_8481_LINK_SIGNAL, val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9088 | |
| 9089 | bnx2x_cl45_write(bp, phy, |
| 9090 | MDIO_PMA_DEVAD, |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9091 | MDIO_PMA_REG_8481_LED1_MASK, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9092 | 0x80); |
| 9093 | |
| 9094 | bnx2x_cl45_write(bp, phy, |
| 9095 | MDIO_PMA_DEVAD, |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9096 | MDIO_PMA_REG_8481_LED2_MASK, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9097 | 0x18); |
| 9098 | |
Yaniv Rosner | f25b3c8 | 2011-01-18 04:33:47 +0000 | [diff] [blame] | 9099 | /* Select activity source by Tx and Rx, as suggested by PHY AE */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9100 | bnx2x_cl45_write(bp, phy, |
| 9101 | MDIO_PMA_DEVAD, |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9102 | MDIO_PMA_REG_8481_LED3_MASK, |
Yaniv Rosner | f25b3c8 | 2011-01-18 04:33:47 +0000 | [diff] [blame] | 9103 | 0x0006); |
| 9104 | |
| 9105 | /* Select the closest activity blink rate to that in 10/100/1000 */ |
| 9106 | bnx2x_cl45_write(bp, phy, |
| 9107 | MDIO_PMA_DEVAD, |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9108 | MDIO_PMA_REG_8481_LED3_BLINK, |
Yaniv Rosner | f25b3c8 | 2011-01-18 04:33:47 +0000 | [diff] [blame] | 9109 | 0); |
| 9110 | |
| 9111 | bnx2x_cl45_read(bp, phy, |
| 9112 | MDIO_PMA_DEVAD, |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9113 | MDIO_PMA_REG_84823_CTL_LED_CTL_1, &val); |
Yaniv Rosner | f25b3c8 | 2011-01-18 04:33:47 +0000 | [diff] [blame] | 9114 | val |= MDIO_PMA_REG_84823_LED3_STRETCH_EN; /* stretch_en for LED3*/ |
| 9115 | |
| 9116 | bnx2x_cl45_write(bp, phy, |
| 9117 | MDIO_PMA_DEVAD, |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9118 | MDIO_PMA_REG_84823_CTL_LED_CTL_1, val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9119 | |
| 9120 | /* 'Interrupt Mask' */ |
| 9121 | bnx2x_cl45_write(bp, phy, |
| 9122 | MDIO_AN_DEVAD, |
| 9123 | 0xFFFB, 0xFFFD); |
| 9124 | } |
| 9125 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 9126 | static int bnx2x_848xx_cmn_config_init(struct bnx2x_phy *phy, |
| 9127 | struct link_params *params, |
| 9128 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9129 | { |
| 9130 | struct bnx2x *bp = params->bp; |
| 9131 | u16 autoneg_val, an_1000_val, an_10_100_val; |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9132 | u16 tmp_req_line_speed; |
| 9133 | |
| 9134 | tmp_req_line_speed = phy->req_line_speed; |
| 9135 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833) |
| 9136 | if (phy->req_line_speed == SPEED_10000) |
| 9137 | phy->req_line_speed = SPEED_AUTO_NEG; |
| 9138 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 9139 | /* |
| 9140 | * This phy uses the NIG latch mechanism since link indication |
| 9141 | * arrives through its LED4 and not via its LASI signal, so we |
| 9142 | * get steady signal instead of clear on read |
| 9143 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9144 | bnx2x_bits_en(bp, NIG_REG_LATCH_BC_0 + params->port*4, |
| 9145 | 1 << NIG_LATCH_BC_ENABLE_MI_INT); |
| 9146 | |
| 9147 | bnx2x_cl45_write(bp, phy, |
| 9148 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 0x0000); |
| 9149 | |
| 9150 | bnx2x_848xx_set_led(bp, phy); |
| 9151 | |
| 9152 | /* set 1000 speed advertisement */ |
| 9153 | bnx2x_cl45_read(bp, phy, |
| 9154 | MDIO_AN_DEVAD, MDIO_AN_REG_8481_1000T_CTRL, |
| 9155 | &an_1000_val); |
| 9156 | |
| 9157 | bnx2x_ext_phy_set_pause(params, phy, vars); |
| 9158 | bnx2x_cl45_read(bp, phy, |
| 9159 | MDIO_AN_DEVAD, |
| 9160 | MDIO_AN_REG_8481_LEGACY_AN_ADV, |
| 9161 | &an_10_100_val); |
| 9162 | bnx2x_cl45_read(bp, phy, |
| 9163 | MDIO_AN_DEVAD, MDIO_AN_REG_8481_LEGACY_MII_CTRL, |
| 9164 | &autoneg_val); |
| 9165 | /* Disable forced speed */ |
| 9166 | autoneg_val &= ~((1<<6) | (1<<8) | (1<<9) | (1<<12) | (1<<13)); |
| 9167 | an_10_100_val &= ~((1<<5) | (1<<6) | (1<<7) | (1<<8)); |
| 9168 | |
| 9169 | if (((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 9170 | (phy->speed_cap_mask & |
| 9171 | PORT_HW_CFG_SPEED_CAPABILITY_D0_1G)) || |
| 9172 | (phy->req_line_speed == SPEED_1000)) { |
| 9173 | an_1000_val |= (1<<8); |
| 9174 | autoneg_val |= (1<<9 | 1<<12); |
| 9175 | if (phy->req_duplex == DUPLEX_FULL) |
| 9176 | an_1000_val |= (1<<9); |
| 9177 | DP(NETIF_MSG_LINK, "Advertising 1G\n"); |
| 9178 | } else |
| 9179 | an_1000_val &= ~((1<<8) | (1<<9)); |
| 9180 | |
| 9181 | bnx2x_cl45_write(bp, phy, |
| 9182 | MDIO_AN_DEVAD, MDIO_AN_REG_8481_1000T_CTRL, |
| 9183 | an_1000_val); |
| 9184 | |
Yaniv Rosner | 0520e63 | 2011-07-05 01:06:59 +0000 | [diff] [blame^] | 9185 | /* set 100 speed advertisement */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9186 | if (((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 9187 | (phy->speed_cap_mask & |
Yaniv Rosner | 0520e63 | 2011-07-05 01:06:59 +0000 | [diff] [blame^] | 9188 | (PORT_HW_CFG_SPEED_CAPABILITY_D0_100M_FULL | |
| 9189 | PORT_HW_CFG_SPEED_CAPABILITY_D0_100M_HALF)) && |
| 9190 | (phy->supported & |
| 9191 | (SUPPORTED_100baseT_Half | |
| 9192 | SUPPORTED_100baseT_Full)))) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9193 | an_10_100_val |= (1<<7); |
| 9194 | /* Enable autoneg and restart autoneg for legacy speeds */ |
| 9195 | autoneg_val |= (1<<9 | 1<<12); |
| 9196 | |
| 9197 | if (phy->req_duplex == DUPLEX_FULL) |
| 9198 | an_10_100_val |= (1<<8); |
| 9199 | DP(NETIF_MSG_LINK, "Advertising 100M\n"); |
| 9200 | } |
| 9201 | /* set 10 speed advertisement */ |
| 9202 | if (((phy->req_line_speed == SPEED_AUTO_NEG) && |
Yaniv Rosner | 0520e63 | 2011-07-05 01:06:59 +0000 | [diff] [blame^] | 9203 | (phy->speed_cap_mask & |
| 9204 | (PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_FULL | |
| 9205 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_HALF)) && |
| 9206 | (phy->supported & |
| 9207 | (SUPPORTED_10baseT_Half | |
| 9208 | SUPPORTED_10baseT_Full)))) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9209 | an_10_100_val |= (1<<5); |
| 9210 | autoneg_val |= (1<<9 | 1<<12); |
| 9211 | if (phy->req_duplex == DUPLEX_FULL) |
| 9212 | an_10_100_val |= (1<<6); |
| 9213 | DP(NETIF_MSG_LINK, "Advertising 10M\n"); |
| 9214 | } |
| 9215 | |
| 9216 | /* Only 10/100 are allowed to work in FORCE mode */ |
Yaniv Rosner | 0520e63 | 2011-07-05 01:06:59 +0000 | [diff] [blame^] | 9217 | if ((phy->req_line_speed == SPEED_100) && |
| 9218 | (phy->supported & |
| 9219 | (SUPPORTED_100baseT_Half | |
| 9220 | SUPPORTED_100baseT_Full))) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9221 | autoneg_val |= (1<<13); |
| 9222 | /* Enabled AUTO-MDIX when autoneg is disabled */ |
| 9223 | bnx2x_cl45_write(bp, phy, |
| 9224 | MDIO_AN_DEVAD, MDIO_AN_REG_8481_AUX_CTRL, |
| 9225 | (1<<15 | 1<<9 | 7<<0)); |
| 9226 | DP(NETIF_MSG_LINK, "Setting 100M force\n"); |
| 9227 | } |
Yaniv Rosner | 0520e63 | 2011-07-05 01:06:59 +0000 | [diff] [blame^] | 9228 | if ((phy->req_line_speed == SPEED_10) && |
| 9229 | (phy->supported & |
| 9230 | (SUPPORTED_10baseT_Half | |
| 9231 | SUPPORTED_10baseT_Full))) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9232 | /* Enabled AUTO-MDIX when autoneg is disabled */ |
| 9233 | bnx2x_cl45_write(bp, phy, |
| 9234 | MDIO_AN_DEVAD, MDIO_AN_REG_8481_AUX_CTRL, |
| 9235 | (1<<15 | 1<<9 | 7<<0)); |
| 9236 | DP(NETIF_MSG_LINK, "Setting 10M force\n"); |
| 9237 | } |
| 9238 | |
| 9239 | bnx2x_cl45_write(bp, phy, |
| 9240 | MDIO_AN_DEVAD, MDIO_AN_REG_8481_LEGACY_AN_ADV, |
| 9241 | an_10_100_val); |
| 9242 | |
| 9243 | if (phy->req_duplex == DUPLEX_FULL) |
| 9244 | autoneg_val |= (1<<8); |
| 9245 | |
| 9246 | bnx2x_cl45_write(bp, phy, |
| 9247 | MDIO_AN_DEVAD, |
| 9248 | MDIO_AN_REG_8481_LEGACY_MII_CTRL, autoneg_val); |
| 9249 | |
| 9250 | if (((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 9251 | (phy->speed_cap_mask & |
| 9252 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G)) || |
| 9253 | (phy->req_line_speed == SPEED_10000)) { |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 9254 | DP(NETIF_MSG_LINK, "Advertising 10G\n"); |
| 9255 | /* Restart autoneg for 10G*/ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9256 | |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 9257 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9258 | MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, |
| 9259 | 0x3200); |
| 9260 | } else if (phy->req_line_speed != SPEED_10 && |
| 9261 | phy->req_line_speed != SPEED_100) { |
| 9262 | bnx2x_cl45_write(bp, phy, |
| 9263 | MDIO_AN_DEVAD, |
| 9264 | MDIO_AN_REG_8481_10GBASE_T_AN_CTRL, |
| 9265 | 1); |
| 9266 | } |
| 9267 | /* Save spirom version */ |
| 9268 | bnx2x_save_848xx_spirom_version(phy, params); |
| 9269 | |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9270 | phy->req_line_speed = tmp_req_line_speed; |
| 9271 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9272 | return 0; |
| 9273 | } |
| 9274 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 9275 | static int bnx2x_8481_config_init(struct bnx2x_phy *phy, |
| 9276 | struct link_params *params, |
| 9277 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9278 | { |
| 9279 | struct bnx2x *bp = params->bp; |
| 9280 | /* Restore normal power mode*/ |
| 9281 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 9282 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, params->port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9283 | |
| 9284 | /* HW reset */ |
| 9285 | bnx2x_ext_phy_hw_reset(bp, params->port); |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 9286 | bnx2x_wait_reset_complete(bp, phy, params); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9287 | |
| 9288 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 1<<15); |
| 9289 | return bnx2x_848xx_cmn_config_init(phy, params, vars); |
| 9290 | } |
| 9291 | |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9292 | |
| 9293 | #define PHY84833_HDSHK_WAIT 300 |
| 9294 | static int bnx2x_84833_pair_swap_cfg(struct bnx2x_phy *phy, |
| 9295 | struct link_params *params, |
| 9296 | struct link_vars *vars) |
| 9297 | { |
| 9298 | u32 idx; |
Yaniv Rosner | 0520e63 | 2011-07-05 01:06:59 +0000 | [diff] [blame^] | 9299 | u32 pair_swap; |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9300 | u16 val; |
Yaniv Rosner | 0520e63 | 2011-07-05 01:06:59 +0000 | [diff] [blame^] | 9301 | u16 data; |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9302 | struct bnx2x *bp = params->bp; |
| 9303 | /* Do pair swap */ |
| 9304 | |
Yaniv Rosner | 0520e63 | 2011-07-05 01:06:59 +0000 | [diff] [blame^] | 9305 | /* Check for configuration. */ |
| 9306 | pair_swap = REG_RD(bp, params->shmem_base + |
| 9307 | offsetof(struct shmem_region, |
| 9308 | dev_info.port_hw_config[params->port].xgbt_phy_cfg)) & |
| 9309 | PORT_HW_CFG_RJ45_PAIR_SWAP_MASK; |
| 9310 | |
| 9311 | if (pair_swap == 0) |
| 9312 | return 0; |
| 9313 | |
| 9314 | data = (u16)pair_swap; |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9315 | |
| 9316 | /* Write CMD_OPEN_OVERRIDE to STATUS reg */ |
| 9317 | bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD, |
| 9318 | MDIO_84833_TOP_CFG_SCRATCH_REG2, |
| 9319 | PHY84833_CMD_OPEN_OVERRIDE); |
| 9320 | for (idx = 0; idx < PHY84833_HDSHK_WAIT; idx++) { |
| 9321 | bnx2x_cl45_read(bp, phy, MDIO_CTL_DEVAD, |
| 9322 | MDIO_84833_TOP_CFG_SCRATCH_REG2, &val); |
| 9323 | if (val == PHY84833_CMD_OPEN_FOR_CMDS) |
| 9324 | break; |
| 9325 | msleep(1); |
| 9326 | } |
| 9327 | if (idx >= PHY84833_HDSHK_WAIT) { |
| 9328 | DP(NETIF_MSG_LINK, "Pairswap: FW not ready.\n"); |
| 9329 | return -EINVAL; |
| 9330 | } |
| 9331 | |
| 9332 | bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD, |
| 9333 | MDIO_84833_TOP_CFG_SCRATCH_REG4, |
| 9334 | data); |
| 9335 | /* Issue pair swap command */ |
| 9336 | bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD, |
| 9337 | MDIO_84833_TOP_CFG_SCRATCH_REG0, |
| 9338 | PHY84833_DIAG_CMD_PAIR_SWAP_CHANGE); |
| 9339 | for (idx = 0; idx < PHY84833_HDSHK_WAIT; idx++) { |
| 9340 | bnx2x_cl45_read(bp, phy, MDIO_CTL_DEVAD, |
| 9341 | MDIO_84833_TOP_CFG_SCRATCH_REG2, &val); |
| 9342 | if ((val == PHY84833_CMD_COMPLETE_PASS) || |
| 9343 | (val == PHY84833_CMD_COMPLETE_ERROR)) |
| 9344 | break; |
| 9345 | msleep(1); |
| 9346 | } |
| 9347 | if ((idx >= PHY84833_HDSHK_WAIT) || |
| 9348 | (val == PHY84833_CMD_COMPLETE_ERROR)) { |
| 9349 | DP(NETIF_MSG_LINK, "Pairswap: override failed.\n"); |
| 9350 | return -EINVAL; |
| 9351 | } |
| 9352 | bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD, |
| 9353 | MDIO_84833_TOP_CFG_SCRATCH_REG2, |
| 9354 | PHY84833_CMD_CLEAR_COMPLETE); |
| 9355 | DP(NETIF_MSG_LINK, "Pairswap OK, val=0x%x\n", data); |
| 9356 | return 0; |
| 9357 | } |
| 9358 | |
Yaniv Rosner | 0d40f0d | 2011-06-14 01:34:27 +0000 | [diff] [blame] | 9359 | |
Yaniv Rosner | 985848f | 2011-07-05 01:06:48 +0000 | [diff] [blame] | 9360 | static u8 bnx2x_84833_get_reset_gpios(struct bnx2x *bp, |
| 9361 | u32 shmem_base_path[], |
| 9362 | u32 chip_id) |
Yaniv Rosner | 0d40f0d | 2011-06-14 01:34:27 +0000 | [diff] [blame] | 9363 | { |
| 9364 | u32 reset_pin[2]; |
| 9365 | u32 idx; |
| 9366 | u8 reset_gpios; |
| 9367 | if (CHIP_IS_E3(bp)) { |
| 9368 | /* Assume that these will be GPIOs, not EPIOs. */ |
| 9369 | for (idx = 0; idx < 2; idx++) { |
| 9370 | /* Map config param to register bit. */ |
| 9371 | reset_pin[idx] = REG_RD(bp, shmem_base_path[idx] + |
| 9372 | offsetof(struct shmem_region, |
| 9373 | dev_info.port_hw_config[0].e3_cmn_pin_cfg)); |
| 9374 | reset_pin[idx] = (reset_pin[idx] & |
| 9375 | PORT_HW_CFG_E3_PHY_RESET_MASK) >> |
| 9376 | PORT_HW_CFG_E3_PHY_RESET_SHIFT; |
| 9377 | reset_pin[idx] -= PIN_CFG_GPIO0_P0; |
| 9378 | reset_pin[idx] = (1 << reset_pin[idx]); |
| 9379 | } |
| 9380 | reset_gpios = (u8)(reset_pin[0] | reset_pin[1]); |
| 9381 | } else { |
| 9382 | /* E2, look from diff place of shmem. */ |
| 9383 | for (idx = 0; idx < 2; idx++) { |
| 9384 | reset_pin[idx] = REG_RD(bp, shmem_base_path[idx] + |
| 9385 | offsetof(struct shmem_region, |
| 9386 | dev_info.port_hw_config[0].default_cfg)); |
| 9387 | reset_pin[idx] &= PORT_HW_CFG_EXT_PHY_GPIO_RST_MASK; |
| 9388 | reset_pin[idx] -= PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO0_P0; |
| 9389 | reset_pin[idx] >>= PORT_HW_CFG_EXT_PHY_GPIO_RST_SHIFT; |
| 9390 | reset_pin[idx] = (1 << reset_pin[idx]); |
| 9391 | } |
| 9392 | reset_gpios = (u8)(reset_pin[0] | reset_pin[1]); |
| 9393 | } |
| 9394 | |
Yaniv Rosner | 985848f | 2011-07-05 01:06:48 +0000 | [diff] [blame] | 9395 | return reset_gpios; |
| 9396 | } |
| 9397 | |
| 9398 | static int bnx2x_84833_hw_reset_phy(struct bnx2x_phy *phy, |
| 9399 | struct link_params *params) |
| 9400 | { |
| 9401 | struct bnx2x *bp = params->bp; |
| 9402 | u8 reset_gpios; |
| 9403 | u32 other_shmem_base_addr = REG_RD(bp, params->shmem2_base + |
| 9404 | offsetof(struct shmem2_region, |
| 9405 | other_shmem_base_addr)); |
| 9406 | |
| 9407 | u32 shmem_base_path[2]; |
| 9408 | shmem_base_path[0] = params->shmem_base; |
| 9409 | shmem_base_path[1] = other_shmem_base_addr; |
| 9410 | |
| 9411 | reset_gpios = bnx2x_84833_get_reset_gpios(bp, shmem_base_path, |
| 9412 | params->chip_id); |
| 9413 | |
| 9414 | bnx2x_set_mult_gpio(bp, reset_gpios, MISC_REGISTERS_GPIO_OUTPUT_LOW); |
| 9415 | udelay(10); |
| 9416 | DP(NETIF_MSG_LINK, "84833 hw reset on pin values 0x%x\n", |
| 9417 | reset_gpios); |
| 9418 | |
| 9419 | return 0; |
| 9420 | } |
| 9421 | |
| 9422 | static int bnx2x_84833_common_init_phy(struct bnx2x *bp, |
| 9423 | u32 shmem_base_path[], |
| 9424 | u32 chip_id) |
| 9425 | { |
| 9426 | u8 reset_gpios; |
| 9427 | |
| 9428 | reset_gpios = bnx2x_84833_get_reset_gpios(bp, shmem_base_path, chip_id); |
| 9429 | |
Yaniv Rosner | 0d40f0d | 2011-06-14 01:34:27 +0000 | [diff] [blame] | 9430 | bnx2x_set_mult_gpio(bp, reset_gpios, MISC_REGISTERS_GPIO_OUTPUT_LOW); |
| 9431 | udelay(10); |
| 9432 | bnx2x_set_mult_gpio(bp, reset_gpios, MISC_REGISTERS_GPIO_OUTPUT_HIGH); |
| 9433 | msleep(800); |
| 9434 | DP(NETIF_MSG_LINK, "84833 reset pulse on pin values 0x%x\n", |
| 9435 | reset_gpios); |
| 9436 | |
| 9437 | return 0; |
| 9438 | } |
| 9439 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 9440 | static int bnx2x_848x3_config_init(struct bnx2x_phy *phy, |
| 9441 | struct link_params *params, |
| 9442 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9443 | { |
| 9444 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 6a71bbe | 2010-11-01 05:32:31 +0000 | [diff] [blame] | 9445 | u8 port, initialize = 1; |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9446 | u16 val; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9447 | u16 temp; |
Yaniv Rosner | 1bef68e | 2011-01-31 04:22:46 +0000 | [diff] [blame] | 9448 | u32 actual_phy_selection, cms_enable; |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 9449 | int rc = 0; |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 9450 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9451 | msleep(1); |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9452 | |
| 9453 | if (!(CHIP_IS_E1(bp))) |
Yaniv Rosner | 6a71bbe | 2010-11-01 05:32:31 +0000 | [diff] [blame] | 9454 | port = BP_PATH(bp); |
| 9455 | else |
| 9456 | port = params->port; |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9457 | |
| 9458 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84823) { |
| 9459 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_3, |
| 9460 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, |
| 9461 | port); |
| 9462 | } else { |
Yaniv Rosner | 985848f | 2011-07-05 01:06:48 +0000 | [diff] [blame] | 9463 | /* MDIO reset */ |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9464 | bnx2x_cl45_write(bp, phy, |
| 9465 | MDIO_PMA_DEVAD, |
| 9466 | MDIO_PMA_REG_CTRL, 0x8000); |
Yaniv Rosner | 985848f | 2011-07-05 01:06:48 +0000 | [diff] [blame] | 9467 | /* Bring PHY out of super isolate mode */ |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9468 | bnx2x_cl45_read(bp, phy, |
| 9469 | MDIO_CTL_DEVAD, |
| 9470 | MDIO_84833_TOP_CFG_XGPHY_STRAP1, &val); |
| 9471 | val &= ~MDIO_84833_SUPER_ISOLATE; |
| 9472 | bnx2x_cl45_write(bp, phy, |
| 9473 | MDIO_CTL_DEVAD, |
| 9474 | MDIO_84833_TOP_CFG_XGPHY_STRAP1, val); |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9475 | } |
| 9476 | |
Yaniv Rosner | 985848f | 2011-07-05 01:06:48 +0000 | [diff] [blame] | 9477 | bnx2x_wait_reset_complete(bp, phy, params); |
| 9478 | |
| 9479 | /* Wait for GPHY to come out of reset */ |
| 9480 | msleep(50); |
| 9481 | |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9482 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833) |
| 9483 | bnx2x_84833_pair_swap_cfg(phy, params, vars); |
| 9484 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 9485 | /* |
| 9486 | * BCM84823 requires that XGXS links up first @ 10G for normal behavior |
| 9487 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9488 | temp = vars->line_speed; |
| 9489 | vars->line_speed = SPEED_10000; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 9490 | bnx2x_set_autoneg(¶ms->phy[INT_PHY], params, vars, 0); |
| 9491 | bnx2x_program_serdes(¶ms->phy[INT_PHY], params, vars); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9492 | vars->line_speed = temp; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 9493 | |
| 9494 | /* Set dual-media configuration according to configuration */ |
| 9495 | |
| 9496 | bnx2x_cl45_read(bp, phy, MDIO_CTL_DEVAD, |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9497 | MDIO_CTL_REG_84823_MEDIA, &val); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 9498 | val &= ~(MDIO_CTL_REG_84823_MEDIA_MAC_MASK | |
| 9499 | MDIO_CTL_REG_84823_MEDIA_LINE_MASK | |
| 9500 | MDIO_CTL_REG_84823_MEDIA_COPPER_CORE_DOWN | |
| 9501 | MDIO_CTL_REG_84823_MEDIA_PRIORITY_MASK | |
| 9502 | MDIO_CTL_REG_84823_MEDIA_FIBER_1G); |
Yaniv Rosner | 0d40f0d | 2011-06-14 01:34:27 +0000 | [diff] [blame] | 9503 | |
| 9504 | if (CHIP_IS_E3(bp)) { |
| 9505 | val &= ~(MDIO_CTL_REG_84823_MEDIA_MAC_MASK | |
| 9506 | MDIO_CTL_REG_84823_MEDIA_LINE_MASK); |
| 9507 | } else { |
| 9508 | val |= (MDIO_CTL_REG_84823_CTRL_MAC_XFI | |
| 9509 | MDIO_CTL_REG_84823_MEDIA_LINE_XAUI_L); |
| 9510 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 9511 | |
| 9512 | actual_phy_selection = bnx2x_phy_selection(params); |
| 9513 | |
| 9514 | switch (actual_phy_selection) { |
| 9515 | case PORT_HW_CFG_PHY_SELECTION_HARDWARE_DEFAULT: |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 9516 | /* Do nothing. Essentially this is like the priority copper */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 9517 | break; |
| 9518 | case PORT_HW_CFG_PHY_SELECTION_FIRST_PHY_PRIORITY: |
| 9519 | val |= MDIO_CTL_REG_84823_MEDIA_PRIORITY_COPPER; |
| 9520 | break; |
| 9521 | case PORT_HW_CFG_PHY_SELECTION_SECOND_PHY_PRIORITY: |
| 9522 | val |= MDIO_CTL_REG_84823_MEDIA_PRIORITY_FIBER; |
| 9523 | break; |
| 9524 | case PORT_HW_CFG_PHY_SELECTION_FIRST_PHY: |
| 9525 | /* Do nothing here. The first PHY won't be initialized at all */ |
| 9526 | break; |
| 9527 | case PORT_HW_CFG_PHY_SELECTION_SECOND_PHY: |
| 9528 | val |= MDIO_CTL_REG_84823_MEDIA_COPPER_CORE_DOWN; |
| 9529 | initialize = 0; |
| 9530 | break; |
| 9531 | } |
| 9532 | if (params->phy[EXT_PHY2].req_line_speed == SPEED_1000) |
| 9533 | val |= MDIO_CTL_REG_84823_MEDIA_FIBER_1G; |
| 9534 | |
| 9535 | bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD, |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9536 | MDIO_CTL_REG_84823_MEDIA, val); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 9537 | DP(NETIF_MSG_LINK, "Multi_phy config = 0x%x, Media control = 0x%x\n", |
| 9538 | params->multi_phy_config, val); |
| 9539 | |
| 9540 | if (initialize) |
| 9541 | rc = bnx2x_848xx_cmn_config_init(phy, params, vars); |
| 9542 | else |
| 9543 | bnx2x_save_848xx_spirom_version(phy, params); |
Yaniv Rosner | 1bef68e | 2011-01-31 04:22:46 +0000 | [diff] [blame] | 9544 | cms_enable = REG_RD(bp, params->shmem_base + |
| 9545 | offsetof(struct shmem_region, |
| 9546 | dev_info.port_hw_config[params->port].default_cfg)) & |
| 9547 | PORT_HW_CFG_ENABLE_CMS_MASK; |
| 9548 | |
| 9549 | bnx2x_cl45_read(bp, phy, MDIO_CTL_DEVAD, |
| 9550 | MDIO_CTL_REG_84823_USER_CTRL_REG, &val); |
| 9551 | if (cms_enable) |
| 9552 | val |= MDIO_CTL_REG_84823_USER_CTRL_CMS; |
| 9553 | else |
| 9554 | val &= ~MDIO_CTL_REG_84823_USER_CTRL_CMS; |
| 9555 | bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD, |
| 9556 | MDIO_CTL_REG_84823_USER_CTRL_REG, val); |
| 9557 | |
| 9558 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 9559 | return rc; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9560 | } |
| 9561 | |
| 9562 | static u8 bnx2x_848xx_read_status(struct bnx2x_phy *phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 9563 | struct link_params *params, |
| 9564 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9565 | { |
| 9566 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9567 | u16 val, val1, val2; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9568 | u8 link_up = 0; |
| 9569 | |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 9570 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9571 | /* Check 10G-BaseT link status */ |
| 9572 | /* Check PMD signal ok */ |
| 9573 | bnx2x_cl45_read(bp, phy, |
| 9574 | MDIO_AN_DEVAD, 0xFFFA, &val1); |
| 9575 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9576 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8481_PMD_SIGNAL, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9577 | &val2); |
| 9578 | DP(NETIF_MSG_LINK, "BCM848xx: PMD_SIGNAL 1.a811 = 0x%x\n", val2); |
| 9579 | |
| 9580 | /* Check link 10G */ |
| 9581 | if (val2 & (1<<11)) { |
| 9582 | vars->line_speed = SPEED_10000; |
Yaniv Rosner | 791f18c | 2011-01-18 04:33:42 +0000 | [diff] [blame] | 9583 | vars->duplex = DUPLEX_FULL; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9584 | link_up = 1; |
| 9585 | bnx2x_ext_phy_10G_an_resolve(bp, phy, vars); |
| 9586 | } else { /* Check Legacy speed link */ |
| 9587 | u16 legacy_status, legacy_speed; |
| 9588 | |
| 9589 | /* Enable expansion register 0x42 (Operation mode status) */ |
| 9590 | bnx2x_cl45_write(bp, phy, |
| 9591 | MDIO_AN_DEVAD, |
| 9592 | MDIO_AN_REG_8481_EXPANSION_REG_ACCESS, 0xf42); |
| 9593 | |
| 9594 | /* Get legacy speed operation status */ |
| 9595 | bnx2x_cl45_read(bp, phy, |
| 9596 | MDIO_AN_DEVAD, |
| 9597 | MDIO_AN_REG_8481_EXPANSION_REG_RD_RW, |
| 9598 | &legacy_status); |
| 9599 | |
| 9600 | DP(NETIF_MSG_LINK, "Legacy speed status" |
| 9601 | " = 0x%x\n", legacy_status); |
| 9602 | link_up = ((legacy_status & (1<<11)) == (1<<11)); |
| 9603 | if (link_up) { |
| 9604 | legacy_speed = (legacy_status & (3<<9)); |
| 9605 | if (legacy_speed == (0<<9)) |
| 9606 | vars->line_speed = SPEED_10; |
| 9607 | else if (legacy_speed == (1<<9)) |
| 9608 | vars->line_speed = SPEED_100; |
| 9609 | else if (legacy_speed == (2<<9)) |
| 9610 | vars->line_speed = SPEED_1000; |
| 9611 | else /* Should not happen */ |
| 9612 | vars->line_speed = 0; |
| 9613 | |
| 9614 | if (legacy_status & (1<<8)) |
| 9615 | vars->duplex = DUPLEX_FULL; |
| 9616 | else |
| 9617 | vars->duplex = DUPLEX_HALF; |
| 9618 | |
| 9619 | DP(NETIF_MSG_LINK, "Link is up in %dMbps," |
| 9620 | " is_duplex_full= %d\n", vars->line_speed, |
| 9621 | (vars->duplex == DUPLEX_FULL)); |
| 9622 | /* Check legacy speed AN resolution */ |
| 9623 | bnx2x_cl45_read(bp, phy, |
| 9624 | MDIO_AN_DEVAD, |
| 9625 | MDIO_AN_REG_8481_LEGACY_MII_STATUS, |
| 9626 | &val); |
| 9627 | if (val & (1<<5)) |
| 9628 | vars->link_status |= |
| 9629 | LINK_STATUS_AUTO_NEGOTIATE_COMPLETE; |
| 9630 | bnx2x_cl45_read(bp, phy, |
| 9631 | MDIO_AN_DEVAD, |
| 9632 | MDIO_AN_REG_8481_LEGACY_AN_EXPANSION, |
| 9633 | &val); |
| 9634 | if ((val & (1<<0)) == 0) |
| 9635 | vars->link_status |= |
| 9636 | LINK_STATUS_PARALLEL_DETECTION_USED; |
| 9637 | } |
| 9638 | } |
| 9639 | if (link_up) { |
| 9640 | DP(NETIF_MSG_LINK, "BCM84823: link speed is %d\n", |
| 9641 | vars->line_speed); |
| 9642 | bnx2x_ext_phy_resolve_fc(phy, params, vars); |
| 9643 | } |
| 9644 | |
| 9645 | return link_up; |
| 9646 | } |
| 9647 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 9648 | |
| 9649 | static int bnx2x_848xx_format_ver(u32 raw_ver, u8 *str, u16 *len) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9650 | { |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 9651 | int status = 0; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9652 | u32 spirom_ver; |
| 9653 | spirom_ver = ((raw_ver & 0xF80) >> 7) << 16 | (raw_ver & 0x7F); |
| 9654 | status = bnx2x_format_ver(spirom_ver, str, len); |
| 9655 | return status; |
| 9656 | } |
| 9657 | |
| 9658 | static void bnx2x_8481_hw_reset(struct bnx2x_phy *phy, |
| 9659 | struct link_params *params) |
| 9660 | { |
| 9661 | bnx2x_set_gpio(params->bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 9662 | MISC_REGISTERS_GPIO_OUTPUT_LOW, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9663 | bnx2x_set_gpio(params->bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 9664 | MISC_REGISTERS_GPIO_OUTPUT_LOW, 1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9665 | } |
| 9666 | |
| 9667 | static void bnx2x_8481_link_reset(struct bnx2x_phy *phy, |
| 9668 | struct link_params *params) |
| 9669 | { |
| 9670 | bnx2x_cl45_write(params->bp, phy, |
| 9671 | MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, 0x0000); |
| 9672 | bnx2x_cl45_write(params->bp, phy, |
| 9673 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 1); |
| 9674 | } |
| 9675 | |
| 9676 | static void bnx2x_848x3_link_reset(struct bnx2x_phy *phy, |
| 9677 | struct link_params *params) |
| 9678 | { |
| 9679 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 6a71bbe | 2010-11-01 05:32:31 +0000 | [diff] [blame] | 9680 | u8 port; |
Yaniv Rosner | 0d40f0d | 2011-06-14 01:34:27 +0000 | [diff] [blame] | 9681 | u16 val16; |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9682 | |
| 9683 | if (!(CHIP_IS_E1(bp))) |
Yaniv Rosner | 6a71bbe | 2010-11-01 05:32:31 +0000 | [diff] [blame] | 9684 | port = BP_PATH(bp); |
| 9685 | else |
| 9686 | port = params->port; |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9687 | |
| 9688 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84823) { |
| 9689 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_3, |
| 9690 | MISC_REGISTERS_GPIO_OUTPUT_LOW, |
| 9691 | port); |
| 9692 | } else { |
Yaniv Rosner | 0d40f0d | 2011-06-14 01:34:27 +0000 | [diff] [blame] | 9693 | bnx2x_cl45_read(bp, phy, |
| 9694 | MDIO_CTL_DEVAD, |
| 9695 | 0x400f, &val16); |
| 9696 | /* Put to low power mode on newer FW */ |
| 9697 | if ((val16 & 0x303f) > 0x1009) |
| 9698 | bnx2x_cl45_write(bp, phy, |
| 9699 | MDIO_PMA_DEVAD, |
| 9700 | MDIO_PMA_REG_CTRL, 0x800); |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9701 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9702 | } |
| 9703 | |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 9704 | static void bnx2x_848xx_set_link_led(struct bnx2x_phy *phy, |
| 9705 | struct link_params *params, u8 mode) |
| 9706 | { |
| 9707 | struct bnx2x *bp = params->bp; |
| 9708 | u16 val; |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9709 | u8 port; |
| 9710 | |
| 9711 | if (!(CHIP_IS_E1(bp))) |
| 9712 | port = BP_PATH(bp); |
| 9713 | else |
| 9714 | port = params->port; |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 9715 | |
| 9716 | switch (mode) { |
| 9717 | case LED_MODE_OFF: |
| 9718 | |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9719 | DP(NETIF_MSG_LINK, "Port 0x%x: LED MODE OFF\n", port); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 9720 | |
| 9721 | if ((params->hw_led_mode << SHARED_HW_CFG_LED_MODE_SHIFT) == |
| 9722 | SHARED_HW_CFG_LED_EXTPHY1) { |
| 9723 | |
| 9724 | /* Set LED masks */ |
| 9725 | bnx2x_cl45_write(bp, phy, |
| 9726 | MDIO_PMA_DEVAD, |
| 9727 | MDIO_PMA_REG_8481_LED1_MASK, |
| 9728 | 0x0); |
| 9729 | |
| 9730 | bnx2x_cl45_write(bp, phy, |
| 9731 | MDIO_PMA_DEVAD, |
| 9732 | MDIO_PMA_REG_8481_LED2_MASK, |
| 9733 | 0x0); |
| 9734 | |
| 9735 | bnx2x_cl45_write(bp, phy, |
| 9736 | MDIO_PMA_DEVAD, |
| 9737 | MDIO_PMA_REG_8481_LED3_MASK, |
| 9738 | 0x0); |
| 9739 | |
| 9740 | bnx2x_cl45_write(bp, phy, |
| 9741 | MDIO_PMA_DEVAD, |
| 9742 | MDIO_PMA_REG_8481_LED5_MASK, |
| 9743 | 0x0); |
| 9744 | |
| 9745 | } else { |
| 9746 | bnx2x_cl45_write(bp, phy, |
| 9747 | MDIO_PMA_DEVAD, |
| 9748 | MDIO_PMA_REG_8481_LED1_MASK, |
| 9749 | 0x0); |
| 9750 | } |
| 9751 | break; |
| 9752 | case LED_MODE_FRONT_PANEL_OFF: |
| 9753 | |
| 9754 | DP(NETIF_MSG_LINK, "Port 0x%x: LED MODE FRONT PANEL OFF\n", |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9755 | port); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 9756 | |
| 9757 | if ((params->hw_led_mode << SHARED_HW_CFG_LED_MODE_SHIFT) == |
| 9758 | SHARED_HW_CFG_LED_EXTPHY1) { |
| 9759 | |
| 9760 | /* Set LED masks */ |
| 9761 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 9762 | MDIO_PMA_DEVAD, |
| 9763 | MDIO_PMA_REG_8481_LED1_MASK, |
| 9764 | 0x0); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 9765 | |
| 9766 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 9767 | MDIO_PMA_DEVAD, |
| 9768 | MDIO_PMA_REG_8481_LED2_MASK, |
| 9769 | 0x0); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 9770 | |
| 9771 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 9772 | MDIO_PMA_DEVAD, |
| 9773 | MDIO_PMA_REG_8481_LED3_MASK, |
| 9774 | 0x0); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 9775 | |
| 9776 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 9777 | MDIO_PMA_DEVAD, |
| 9778 | MDIO_PMA_REG_8481_LED5_MASK, |
| 9779 | 0x20); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 9780 | |
| 9781 | } else { |
| 9782 | bnx2x_cl45_write(bp, phy, |
| 9783 | MDIO_PMA_DEVAD, |
| 9784 | MDIO_PMA_REG_8481_LED1_MASK, |
| 9785 | 0x0); |
| 9786 | } |
| 9787 | break; |
| 9788 | case LED_MODE_ON: |
| 9789 | |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9790 | DP(NETIF_MSG_LINK, "Port 0x%x: LED MODE ON\n", port); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 9791 | |
| 9792 | if ((params->hw_led_mode << SHARED_HW_CFG_LED_MODE_SHIFT) == |
| 9793 | SHARED_HW_CFG_LED_EXTPHY1) { |
| 9794 | /* Set control reg */ |
| 9795 | bnx2x_cl45_read(bp, phy, |
| 9796 | MDIO_PMA_DEVAD, |
| 9797 | MDIO_PMA_REG_8481_LINK_SIGNAL, |
| 9798 | &val); |
| 9799 | val &= 0x8000; |
| 9800 | val |= 0x2492; |
| 9801 | |
| 9802 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 9803 | MDIO_PMA_DEVAD, |
| 9804 | MDIO_PMA_REG_8481_LINK_SIGNAL, |
| 9805 | val); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 9806 | |
| 9807 | /* Set LED masks */ |
| 9808 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 9809 | MDIO_PMA_DEVAD, |
| 9810 | MDIO_PMA_REG_8481_LED1_MASK, |
| 9811 | 0x0); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 9812 | |
| 9813 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 9814 | MDIO_PMA_DEVAD, |
| 9815 | MDIO_PMA_REG_8481_LED2_MASK, |
| 9816 | 0x20); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 9817 | |
| 9818 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 9819 | MDIO_PMA_DEVAD, |
| 9820 | MDIO_PMA_REG_8481_LED3_MASK, |
| 9821 | 0x20); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 9822 | |
| 9823 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 9824 | MDIO_PMA_DEVAD, |
| 9825 | MDIO_PMA_REG_8481_LED5_MASK, |
| 9826 | 0x0); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 9827 | } else { |
| 9828 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 9829 | MDIO_PMA_DEVAD, |
| 9830 | MDIO_PMA_REG_8481_LED1_MASK, |
| 9831 | 0x20); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 9832 | } |
| 9833 | break; |
| 9834 | |
| 9835 | case LED_MODE_OPER: |
| 9836 | |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9837 | DP(NETIF_MSG_LINK, "Port 0x%x: LED MODE OPER\n", port); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 9838 | |
| 9839 | if ((params->hw_led_mode << SHARED_HW_CFG_LED_MODE_SHIFT) == |
| 9840 | SHARED_HW_CFG_LED_EXTPHY1) { |
| 9841 | |
| 9842 | /* Set control reg */ |
| 9843 | bnx2x_cl45_read(bp, phy, |
| 9844 | MDIO_PMA_DEVAD, |
| 9845 | MDIO_PMA_REG_8481_LINK_SIGNAL, |
| 9846 | &val); |
| 9847 | |
| 9848 | if (!((val & |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 9849 | MDIO_PMA_REG_8481_LINK_SIGNAL_LED4_ENABLE_MASK) |
| 9850 | >> MDIO_PMA_REG_8481_LINK_SIGNAL_LED4_ENABLE_SHIFT)) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 9851 | DP(NETIF_MSG_LINK, "Setting LINK_SIGNAL\n"); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 9852 | bnx2x_cl45_write(bp, phy, |
| 9853 | MDIO_PMA_DEVAD, |
| 9854 | MDIO_PMA_REG_8481_LINK_SIGNAL, |
| 9855 | 0xa492); |
| 9856 | } |
| 9857 | |
| 9858 | /* Set LED masks */ |
| 9859 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 9860 | MDIO_PMA_DEVAD, |
| 9861 | MDIO_PMA_REG_8481_LED1_MASK, |
| 9862 | 0x10); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 9863 | |
| 9864 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 9865 | MDIO_PMA_DEVAD, |
| 9866 | MDIO_PMA_REG_8481_LED2_MASK, |
| 9867 | 0x80); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 9868 | |
| 9869 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 9870 | MDIO_PMA_DEVAD, |
| 9871 | MDIO_PMA_REG_8481_LED3_MASK, |
| 9872 | 0x98); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 9873 | |
| 9874 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 9875 | MDIO_PMA_DEVAD, |
| 9876 | MDIO_PMA_REG_8481_LED5_MASK, |
| 9877 | 0x40); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 9878 | |
| 9879 | } else { |
| 9880 | bnx2x_cl45_write(bp, phy, |
| 9881 | MDIO_PMA_DEVAD, |
| 9882 | MDIO_PMA_REG_8481_LED1_MASK, |
| 9883 | 0x80); |
Yaniv Rosner | 53eda06 | 2011-01-30 04:14:55 +0000 | [diff] [blame] | 9884 | |
| 9885 | /* Tell LED3 to blink on source */ |
| 9886 | bnx2x_cl45_read(bp, phy, |
| 9887 | MDIO_PMA_DEVAD, |
| 9888 | MDIO_PMA_REG_8481_LINK_SIGNAL, |
| 9889 | &val); |
| 9890 | val &= ~(7<<6); |
| 9891 | val |= (1<<6); /* A83B[8:6]= 1 */ |
| 9892 | bnx2x_cl45_write(bp, phy, |
| 9893 | MDIO_PMA_DEVAD, |
| 9894 | MDIO_PMA_REG_8481_LINK_SIGNAL, |
| 9895 | val); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 9896 | } |
| 9897 | break; |
| 9898 | } |
Yaniv Rosner | 0d40f0d | 2011-06-14 01:34:27 +0000 | [diff] [blame] | 9899 | |
| 9900 | /* |
| 9901 | * This is a workaround for E3+84833 until autoneg |
| 9902 | * restart is fixed in f/w |
| 9903 | */ |
| 9904 | if (CHIP_IS_E3(bp)) { |
| 9905 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 9906 | MDIO_WC_REG_GP2_STATUS_GP_2_1, &val); |
| 9907 | } |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 9908 | } |
Yaniv Rosner | 0d40f0d | 2011-06-14 01:34:27 +0000 | [diff] [blame] | 9909 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9910 | /******************************************************************/ |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 9911 | /* 54618SE PHY SECTION */ |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 9912 | /******************************************************************/ |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 9913 | static int bnx2x_54618se_config_init(struct bnx2x_phy *phy, |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 9914 | struct link_params *params, |
| 9915 | struct link_vars *vars) |
| 9916 | { |
| 9917 | struct bnx2x *bp = params->bp; |
| 9918 | u8 port; |
| 9919 | u16 autoneg_val, an_1000_val, an_10_100_val, fc_val, temp; |
| 9920 | u32 cfg_pin; |
| 9921 | |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 9922 | DP(NETIF_MSG_LINK, "54618SE cfg init\n"); |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 9923 | usleep_range(1000, 1000); |
| 9924 | |
| 9925 | /* This works with E3 only, no need to check the chip |
| 9926 | before determining the port. */ |
| 9927 | port = params->port; |
| 9928 | |
| 9929 | cfg_pin = (REG_RD(bp, params->shmem_base + |
| 9930 | offsetof(struct shmem_region, |
| 9931 | dev_info.port_hw_config[port].e3_cmn_pin_cfg)) & |
| 9932 | PORT_HW_CFG_E3_PHY_RESET_MASK) >> |
| 9933 | PORT_HW_CFG_E3_PHY_RESET_SHIFT; |
| 9934 | |
| 9935 | /* Drive pin high to bring the GPHY out of reset. */ |
| 9936 | bnx2x_set_cfg_pin(bp, cfg_pin, 1); |
| 9937 | |
| 9938 | /* wait for GPHY to reset */ |
| 9939 | msleep(50); |
| 9940 | |
| 9941 | /* reset phy */ |
| 9942 | bnx2x_cl22_write(bp, phy, |
| 9943 | MDIO_PMA_REG_CTRL, 0x8000); |
| 9944 | bnx2x_wait_reset_complete(bp, phy, params); |
| 9945 | |
| 9946 | /*wait for GPHY to reset */ |
| 9947 | msleep(50); |
| 9948 | |
| 9949 | /* Configure LED4: set to INTR (0x6). */ |
| 9950 | /* Accessing shadow register 0xe. */ |
| 9951 | bnx2x_cl22_write(bp, phy, |
| 9952 | MDIO_REG_GPHY_SHADOW, |
| 9953 | MDIO_REG_GPHY_SHADOW_LED_SEL2); |
| 9954 | bnx2x_cl22_read(bp, phy, |
| 9955 | MDIO_REG_GPHY_SHADOW, |
| 9956 | &temp); |
| 9957 | temp &= ~(0xf << 4); |
| 9958 | temp |= (0x6 << 4); |
| 9959 | bnx2x_cl22_write(bp, phy, |
| 9960 | MDIO_REG_GPHY_SHADOW, |
| 9961 | MDIO_REG_GPHY_SHADOW_WR_ENA | temp); |
| 9962 | /* Configure INTR based on link status change. */ |
| 9963 | bnx2x_cl22_write(bp, phy, |
| 9964 | MDIO_REG_INTR_MASK, |
| 9965 | ~MDIO_REG_INTR_MASK_LINK_STATUS); |
| 9966 | |
| 9967 | /* Flip the signal detect polarity (set 0x1c.0x1e[8]). */ |
| 9968 | bnx2x_cl22_write(bp, phy, |
| 9969 | MDIO_REG_GPHY_SHADOW, |
| 9970 | MDIO_REG_GPHY_SHADOW_AUTO_DET_MED); |
| 9971 | bnx2x_cl22_read(bp, phy, |
| 9972 | MDIO_REG_GPHY_SHADOW, |
| 9973 | &temp); |
| 9974 | temp |= MDIO_REG_GPHY_SHADOW_INVERT_FIB_SD; |
| 9975 | bnx2x_cl22_write(bp, phy, |
| 9976 | MDIO_REG_GPHY_SHADOW, |
| 9977 | MDIO_REG_GPHY_SHADOW_WR_ENA | temp); |
| 9978 | |
| 9979 | /* Set up fc */ |
| 9980 | /* Please refer to Table 28B-3 of 802.3ab-1999 spec. */ |
| 9981 | bnx2x_calc_ieee_aneg_adv(phy, params, &vars->ieee_fc); |
| 9982 | fc_val = 0; |
| 9983 | if ((vars->ieee_fc & MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC) == |
| 9984 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC) |
| 9985 | fc_val |= MDIO_AN_REG_ADV_PAUSE_ASYMMETRIC; |
| 9986 | |
| 9987 | if ((vars->ieee_fc & MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) == |
| 9988 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) |
| 9989 | fc_val |= MDIO_AN_REG_ADV_PAUSE_PAUSE; |
| 9990 | |
| 9991 | /* read all advertisement */ |
| 9992 | bnx2x_cl22_read(bp, phy, |
| 9993 | 0x09, |
| 9994 | &an_1000_val); |
| 9995 | |
| 9996 | bnx2x_cl22_read(bp, phy, |
| 9997 | 0x04, |
| 9998 | &an_10_100_val); |
| 9999 | |
| 10000 | bnx2x_cl22_read(bp, phy, |
| 10001 | MDIO_PMA_REG_CTRL, |
| 10002 | &autoneg_val); |
| 10003 | |
| 10004 | /* Disable forced speed */ |
| 10005 | autoneg_val &= ~((1<<6) | (1<<8) | (1<<9) | (1<<12) | (1<<13)); |
| 10006 | an_10_100_val &= ~((1<<5) | (1<<6) | (1<<7) | (1<<8) | (1<<10) | |
| 10007 | (1<<11)); |
| 10008 | |
| 10009 | if (((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 10010 | (phy->speed_cap_mask & |
| 10011 | PORT_HW_CFG_SPEED_CAPABILITY_D0_1G)) || |
| 10012 | (phy->req_line_speed == SPEED_1000)) { |
| 10013 | an_1000_val |= (1<<8); |
| 10014 | autoneg_val |= (1<<9 | 1<<12); |
| 10015 | if (phy->req_duplex == DUPLEX_FULL) |
| 10016 | an_1000_val |= (1<<9); |
| 10017 | DP(NETIF_MSG_LINK, "Advertising 1G\n"); |
| 10018 | } else |
| 10019 | an_1000_val &= ~((1<<8) | (1<<9)); |
| 10020 | |
| 10021 | bnx2x_cl22_write(bp, phy, |
| 10022 | 0x09, |
| 10023 | an_1000_val); |
| 10024 | bnx2x_cl22_read(bp, phy, |
| 10025 | 0x09, |
| 10026 | &an_1000_val); |
| 10027 | |
| 10028 | /* set 100 speed advertisement */ |
| 10029 | if (((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 10030 | (phy->speed_cap_mask & |
| 10031 | (PORT_HW_CFG_SPEED_CAPABILITY_D0_100M_FULL | |
| 10032 | PORT_HW_CFG_SPEED_CAPABILITY_D0_100M_HALF)))) { |
| 10033 | an_10_100_val |= (1<<7); |
| 10034 | /* Enable autoneg and restart autoneg for legacy speeds */ |
| 10035 | autoneg_val |= (1<<9 | 1<<12); |
| 10036 | |
| 10037 | if (phy->req_duplex == DUPLEX_FULL) |
| 10038 | an_10_100_val |= (1<<8); |
| 10039 | DP(NETIF_MSG_LINK, "Advertising 100M\n"); |
| 10040 | } |
| 10041 | |
| 10042 | /* set 10 speed advertisement */ |
| 10043 | if (((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 10044 | (phy->speed_cap_mask & |
| 10045 | (PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_FULL | |
| 10046 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_HALF)))) { |
| 10047 | an_10_100_val |= (1<<5); |
| 10048 | autoneg_val |= (1<<9 | 1<<12); |
| 10049 | if (phy->req_duplex == DUPLEX_FULL) |
| 10050 | an_10_100_val |= (1<<6); |
| 10051 | DP(NETIF_MSG_LINK, "Advertising 10M\n"); |
| 10052 | } |
| 10053 | |
| 10054 | /* Only 10/100 are allowed to work in FORCE mode */ |
| 10055 | if (phy->req_line_speed == SPEED_100) { |
| 10056 | autoneg_val |= (1<<13); |
| 10057 | /* Enabled AUTO-MDIX when autoneg is disabled */ |
| 10058 | bnx2x_cl22_write(bp, phy, |
| 10059 | 0x18, |
| 10060 | (1<<15 | 1<<9 | 7<<0)); |
| 10061 | DP(NETIF_MSG_LINK, "Setting 100M force\n"); |
| 10062 | } |
| 10063 | if (phy->req_line_speed == SPEED_10) { |
| 10064 | /* Enabled AUTO-MDIX when autoneg is disabled */ |
| 10065 | bnx2x_cl22_write(bp, phy, |
| 10066 | 0x18, |
| 10067 | (1<<15 | 1<<9 | 7<<0)); |
| 10068 | DP(NETIF_MSG_LINK, "Setting 10M force\n"); |
| 10069 | } |
| 10070 | |
| 10071 | bnx2x_cl22_write(bp, phy, |
| 10072 | 0x04, |
| 10073 | an_10_100_val | fc_val); |
| 10074 | |
| 10075 | if (phy->req_duplex == DUPLEX_FULL) |
| 10076 | autoneg_val |= (1<<8); |
| 10077 | |
| 10078 | bnx2x_cl22_write(bp, phy, |
| 10079 | MDIO_PMA_REG_CTRL, autoneg_val); |
| 10080 | |
| 10081 | return 0; |
| 10082 | } |
| 10083 | |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 10084 | static void bnx2x_54618se_set_link_led(struct bnx2x_phy *phy, |
| 10085 | struct link_params *params, u8 mode) |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 10086 | { |
| 10087 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 10088 | DP(NETIF_MSG_LINK, "54618SE set link led (mode=%x)\n", mode); |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 10089 | switch (mode) { |
| 10090 | case LED_MODE_FRONT_PANEL_OFF: |
| 10091 | case LED_MODE_OFF: |
| 10092 | case LED_MODE_OPER: |
| 10093 | case LED_MODE_ON: |
| 10094 | default: |
| 10095 | break; |
| 10096 | } |
| 10097 | return; |
| 10098 | } |
| 10099 | |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 10100 | static void bnx2x_54618se_link_reset(struct bnx2x_phy *phy, |
| 10101 | struct link_params *params) |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 10102 | { |
| 10103 | struct bnx2x *bp = params->bp; |
| 10104 | u32 cfg_pin; |
| 10105 | u8 port; |
| 10106 | |
| 10107 | /* This works with E3 only, no need to check the chip |
| 10108 | before determining the port. */ |
| 10109 | port = params->port; |
| 10110 | cfg_pin = (REG_RD(bp, params->shmem_base + |
| 10111 | offsetof(struct shmem_region, |
| 10112 | dev_info.port_hw_config[port].e3_cmn_pin_cfg)) & |
| 10113 | PORT_HW_CFG_E3_PHY_RESET_MASK) >> |
| 10114 | PORT_HW_CFG_E3_PHY_RESET_SHIFT; |
| 10115 | |
| 10116 | /* Drive pin low to put GPHY in reset. */ |
| 10117 | bnx2x_set_cfg_pin(bp, cfg_pin, 0); |
| 10118 | } |
| 10119 | |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 10120 | static u8 bnx2x_54618se_read_status(struct bnx2x_phy *phy, |
| 10121 | struct link_params *params, |
| 10122 | struct link_vars *vars) |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 10123 | { |
| 10124 | struct bnx2x *bp = params->bp; |
| 10125 | u16 val; |
| 10126 | u8 link_up = 0; |
| 10127 | u16 legacy_status, legacy_speed; |
| 10128 | |
| 10129 | /* Get speed operation status */ |
| 10130 | bnx2x_cl22_read(bp, phy, |
| 10131 | 0x19, |
| 10132 | &legacy_status); |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 10133 | DP(NETIF_MSG_LINK, "54618SE read_status: 0x%x\n", legacy_status); |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 10134 | |
| 10135 | /* Read status to clear the PHY interrupt. */ |
| 10136 | bnx2x_cl22_read(bp, phy, |
| 10137 | MDIO_REG_INTR_STATUS, |
| 10138 | &val); |
| 10139 | |
| 10140 | link_up = ((legacy_status & (1<<2)) == (1<<2)); |
| 10141 | |
| 10142 | if (link_up) { |
| 10143 | legacy_speed = (legacy_status & (7<<8)); |
| 10144 | if (legacy_speed == (7<<8)) { |
| 10145 | vars->line_speed = SPEED_1000; |
| 10146 | vars->duplex = DUPLEX_FULL; |
| 10147 | } else if (legacy_speed == (6<<8)) { |
| 10148 | vars->line_speed = SPEED_1000; |
| 10149 | vars->duplex = DUPLEX_HALF; |
| 10150 | } else if (legacy_speed == (5<<8)) { |
| 10151 | vars->line_speed = SPEED_100; |
| 10152 | vars->duplex = DUPLEX_FULL; |
| 10153 | } |
| 10154 | /* Omitting 100Base-T4 for now */ |
| 10155 | else if (legacy_speed == (3<<8)) { |
| 10156 | vars->line_speed = SPEED_100; |
| 10157 | vars->duplex = DUPLEX_HALF; |
| 10158 | } else if (legacy_speed == (2<<8)) { |
| 10159 | vars->line_speed = SPEED_10; |
| 10160 | vars->duplex = DUPLEX_FULL; |
| 10161 | } else if (legacy_speed == (1<<8)) { |
| 10162 | vars->line_speed = SPEED_10; |
| 10163 | vars->duplex = DUPLEX_HALF; |
| 10164 | } else /* Should not happen */ |
| 10165 | vars->line_speed = 0; |
| 10166 | |
| 10167 | DP(NETIF_MSG_LINK, "Link is up in %dMbps," |
| 10168 | " is_duplex_full= %d\n", vars->line_speed, |
| 10169 | (vars->duplex == DUPLEX_FULL)); |
| 10170 | |
| 10171 | /* Check legacy speed AN resolution */ |
| 10172 | bnx2x_cl22_read(bp, phy, |
| 10173 | 0x01, |
| 10174 | &val); |
| 10175 | if (val & (1<<5)) |
| 10176 | vars->link_status |= |
| 10177 | LINK_STATUS_AUTO_NEGOTIATE_COMPLETE; |
| 10178 | bnx2x_cl22_read(bp, phy, |
| 10179 | 0x06, |
| 10180 | &val); |
| 10181 | if ((val & (1<<0)) == 0) |
| 10182 | vars->link_status |= |
| 10183 | LINK_STATUS_PARALLEL_DETECTION_USED; |
| 10184 | |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 10185 | DP(NETIF_MSG_LINK, "BCM54618SE: link speed is %d\n", |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 10186 | vars->line_speed); |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 10187 | |
| 10188 | /* Report whether EEE is resolved. */ |
| 10189 | bnx2x_cl22_read(bp, phy, MDIO_REG_GPHY_PHYID_LSB, &val); |
| 10190 | if (val == MDIO_REG_GPHY_ID_54618SE) { |
| 10191 | if (vars->link_status & |
| 10192 | LINK_STATUS_AUTO_NEGOTIATE_COMPLETE) |
| 10193 | val = 0; |
| 10194 | else { |
| 10195 | bnx2x_cl22_write(bp, phy, |
| 10196 | MDIO_REG_GPHY_CL45_ADDR_REG, |
| 10197 | MDIO_AN_DEVAD); |
| 10198 | bnx2x_cl22_write(bp, phy, |
| 10199 | MDIO_REG_GPHY_CL45_DATA_REG, |
| 10200 | MDIO_REG_GPHY_EEE_RESOLVED); |
| 10201 | bnx2x_cl22_write(bp, phy, |
| 10202 | MDIO_REG_GPHY_CL45_ADDR_REG, |
| 10203 | (0x1 << 14) | MDIO_AN_DEVAD); |
| 10204 | bnx2x_cl22_read(bp, phy, |
| 10205 | MDIO_REG_GPHY_CL45_DATA_REG, |
| 10206 | &val); |
| 10207 | } |
| 10208 | DP(NETIF_MSG_LINK, "EEE resolution: 0x%x\n", val); |
| 10209 | } |
| 10210 | |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 10211 | bnx2x_ext_phy_resolve_fc(phy, params, vars); |
| 10212 | } |
| 10213 | return link_up; |
| 10214 | } |
| 10215 | |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 10216 | static void bnx2x_54618se_config_loopback(struct bnx2x_phy *phy, |
| 10217 | struct link_params *params) |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 10218 | { |
| 10219 | struct bnx2x *bp = params->bp; |
| 10220 | u16 val; |
| 10221 | u32 umac_base = params->port ? GRCBASE_UMAC1 : GRCBASE_UMAC0; |
| 10222 | |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 10223 | DP(NETIF_MSG_LINK, "2PMA/PMD ext_phy_loopback: 54618se\n"); |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 10224 | |
| 10225 | /* Enable master/slave manual mmode and set to master */ |
| 10226 | /* mii write 9 [bits set 11 12] */ |
| 10227 | bnx2x_cl22_write(bp, phy, 0x09, 3<<11); |
| 10228 | |
| 10229 | /* forced 1G and disable autoneg */ |
| 10230 | /* set val [mii read 0] */ |
| 10231 | /* set val [expr $val & [bits clear 6 12 13]] */ |
| 10232 | /* set val [expr $val | [bits set 6 8]] */ |
| 10233 | /* mii write 0 $val */ |
| 10234 | bnx2x_cl22_read(bp, phy, 0x00, &val); |
| 10235 | val &= ~((1<<6) | (1<<12) | (1<<13)); |
| 10236 | val |= (1<<6) | (1<<8); |
| 10237 | bnx2x_cl22_write(bp, phy, 0x00, val); |
| 10238 | |
| 10239 | /* Set external loopback and Tx using 6dB coding */ |
| 10240 | /* mii write 0x18 7 */ |
| 10241 | /* set val [mii read 0x18] */ |
| 10242 | /* mii write 0x18 [expr $val | [bits set 10 15]] */ |
| 10243 | bnx2x_cl22_write(bp, phy, 0x18, 7); |
| 10244 | bnx2x_cl22_read(bp, phy, 0x18, &val); |
| 10245 | bnx2x_cl22_write(bp, phy, 0x18, val | (1<<10) | (1<<15)); |
| 10246 | |
| 10247 | /* This register opens the gate for the UMAC despite its name */ |
| 10248 | REG_WR(bp, NIG_REG_EGRESS_EMAC0_PORT + params->port*4, 1); |
| 10249 | |
| 10250 | /* |
| 10251 | * Maximum Frame Length (RW). Defines a 14-Bit maximum frame |
| 10252 | * length used by the MAC receive logic to check frames. |
| 10253 | */ |
| 10254 | REG_WR(bp, umac_base + UMAC_REG_MAXFR, 0x2710); |
| 10255 | } |
| 10256 | |
| 10257 | /******************************************************************/ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10258 | /* SFX7101 PHY SECTION */ |
| 10259 | /******************************************************************/ |
| 10260 | static void bnx2x_7101_config_loopback(struct bnx2x_phy *phy, |
| 10261 | struct link_params *params) |
| 10262 | { |
| 10263 | struct bnx2x *bp = params->bp; |
| 10264 | /* SFX7101_XGXS_TEST1 */ |
| 10265 | bnx2x_cl45_write(bp, phy, |
| 10266 | MDIO_XS_DEVAD, MDIO_XS_SFX7101_XGXS_TEST1, 0x100); |
| 10267 | } |
| 10268 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 10269 | static int bnx2x_7101_config_init(struct bnx2x_phy *phy, |
| 10270 | struct link_params *params, |
| 10271 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10272 | { |
| 10273 | u16 fw_ver1, fw_ver2, val; |
| 10274 | struct bnx2x *bp = params->bp; |
| 10275 | DP(NETIF_MSG_LINK, "Setting the SFX7101 LASI indication\n"); |
| 10276 | |
| 10277 | /* Restore normal power mode*/ |
| 10278 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10279 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, params->port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10280 | /* HW reset */ |
| 10281 | bnx2x_ext_phy_hw_reset(bp, params->port); |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 10282 | bnx2x_wait_reset_complete(bp, phy, params); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10283 | |
| 10284 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 10285 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_CTRL, 0x1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10286 | DP(NETIF_MSG_LINK, "Setting the SFX7101 LED to blink on traffic\n"); |
| 10287 | bnx2x_cl45_write(bp, phy, |
| 10288 | MDIO_PMA_DEVAD, MDIO_PMA_REG_7107_LED_CNTL, (1<<3)); |
| 10289 | |
| 10290 | bnx2x_ext_phy_set_pause(params, phy, vars); |
| 10291 | /* Restart autoneg */ |
| 10292 | bnx2x_cl45_read(bp, phy, |
| 10293 | MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, &val); |
| 10294 | val |= 0x200; |
| 10295 | bnx2x_cl45_write(bp, phy, |
| 10296 | MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, val); |
| 10297 | |
| 10298 | /* Save spirom version */ |
| 10299 | bnx2x_cl45_read(bp, phy, |
| 10300 | MDIO_PMA_DEVAD, MDIO_PMA_REG_7101_VER1, &fw_ver1); |
| 10301 | |
| 10302 | bnx2x_cl45_read(bp, phy, |
| 10303 | MDIO_PMA_DEVAD, MDIO_PMA_REG_7101_VER2, &fw_ver2); |
| 10304 | bnx2x_save_spirom_version(bp, params->port, |
| 10305 | (u32)(fw_ver1<<16 | fw_ver2), phy->ver_addr); |
| 10306 | return 0; |
| 10307 | } |
| 10308 | |
| 10309 | static u8 bnx2x_7101_read_status(struct bnx2x_phy *phy, |
| 10310 | struct link_params *params, |
| 10311 | struct link_vars *vars) |
| 10312 | { |
| 10313 | struct bnx2x *bp = params->bp; |
| 10314 | u8 link_up; |
| 10315 | u16 val1, val2; |
| 10316 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 10317 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_STAT, &val2); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10318 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 10319 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_STAT, &val1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10320 | DP(NETIF_MSG_LINK, "10G-base-T LASI status 0x%x->0x%x\n", |
| 10321 | val2, val1); |
| 10322 | bnx2x_cl45_read(bp, phy, |
| 10323 | MDIO_PMA_DEVAD, MDIO_PMA_REG_STATUS, &val2); |
| 10324 | bnx2x_cl45_read(bp, phy, |
| 10325 | MDIO_PMA_DEVAD, MDIO_PMA_REG_STATUS, &val1); |
| 10326 | DP(NETIF_MSG_LINK, "10G-base-T PMA status 0x%x->0x%x\n", |
| 10327 | val2, val1); |
| 10328 | link_up = ((val1 & 4) == 4); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 10329 | /* if link is up print the AN outcome of the SFX7101 PHY */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10330 | if (link_up) { |
| 10331 | bnx2x_cl45_read(bp, phy, |
| 10332 | MDIO_AN_DEVAD, MDIO_AN_REG_MASTER_STATUS, |
| 10333 | &val2); |
| 10334 | vars->line_speed = SPEED_10000; |
Yaniv Rosner | 791f18c | 2011-01-18 04:33:42 +0000 | [diff] [blame] | 10335 | vars->duplex = DUPLEX_FULL; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10336 | DP(NETIF_MSG_LINK, "SFX7101 AN status 0x%x->Master=%x\n", |
| 10337 | val2, (val2 & (1<<14))); |
| 10338 | bnx2x_ext_phy_10G_an_resolve(bp, phy, vars); |
| 10339 | bnx2x_ext_phy_resolve_fc(phy, params, vars); |
| 10340 | } |
| 10341 | return link_up; |
| 10342 | } |
| 10343 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 10344 | static int bnx2x_7101_format_ver(u32 spirom_ver, u8 *str, u16 *len) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10345 | { |
| 10346 | if (*len < 5) |
| 10347 | return -EINVAL; |
| 10348 | str[0] = (spirom_ver & 0xFF); |
| 10349 | str[1] = (spirom_ver & 0xFF00) >> 8; |
| 10350 | str[2] = (spirom_ver & 0xFF0000) >> 16; |
| 10351 | str[3] = (spirom_ver & 0xFF000000) >> 24; |
| 10352 | str[4] = '\0'; |
| 10353 | *len -= 5; |
| 10354 | return 0; |
| 10355 | } |
| 10356 | |
| 10357 | void bnx2x_sfx7101_sp_sw_reset(struct bnx2x *bp, struct bnx2x_phy *phy) |
| 10358 | { |
| 10359 | u16 val, cnt; |
| 10360 | |
| 10361 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10362 | MDIO_PMA_DEVAD, |
| 10363 | MDIO_PMA_REG_7101_RESET, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10364 | |
| 10365 | for (cnt = 0; cnt < 10; cnt++) { |
| 10366 | msleep(50); |
| 10367 | /* Writes a self-clearing reset */ |
| 10368 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10369 | MDIO_PMA_DEVAD, |
| 10370 | MDIO_PMA_REG_7101_RESET, |
| 10371 | (val | (1<<15))); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10372 | /* Wait for clear */ |
| 10373 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10374 | MDIO_PMA_DEVAD, |
| 10375 | MDIO_PMA_REG_7101_RESET, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10376 | |
| 10377 | if ((val & (1<<15)) == 0) |
| 10378 | break; |
| 10379 | } |
| 10380 | } |
| 10381 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10382 | static void bnx2x_7101_hw_reset(struct bnx2x_phy *phy, |
| 10383 | struct link_params *params) { |
| 10384 | /* Low power mode is controlled by GPIO 2 */ |
| 10385 | bnx2x_set_gpio(params->bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10386 | MISC_REGISTERS_GPIO_OUTPUT_LOW, params->port); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10387 | /* The PHY reset is controlled by GPIO 1 */ |
| 10388 | bnx2x_set_gpio(params->bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10389 | MISC_REGISTERS_GPIO_OUTPUT_LOW, params->port); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10390 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10391 | |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10392 | static void bnx2x_7101_set_link_led(struct bnx2x_phy *phy, |
| 10393 | struct link_params *params, u8 mode) |
| 10394 | { |
| 10395 | u16 val = 0; |
| 10396 | struct bnx2x *bp = params->bp; |
| 10397 | switch (mode) { |
| 10398 | case LED_MODE_FRONT_PANEL_OFF: |
| 10399 | case LED_MODE_OFF: |
| 10400 | val = 2; |
| 10401 | break; |
| 10402 | case LED_MODE_ON: |
| 10403 | val = 1; |
| 10404 | break; |
| 10405 | case LED_MODE_OPER: |
| 10406 | val = 0; |
| 10407 | break; |
| 10408 | } |
| 10409 | bnx2x_cl45_write(bp, phy, |
| 10410 | MDIO_PMA_DEVAD, |
| 10411 | MDIO_PMA_REG_7107_LINK_LED_CNTL, |
| 10412 | val); |
| 10413 | } |
| 10414 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10415 | /******************************************************************/ |
| 10416 | /* STATIC PHY DECLARATION */ |
| 10417 | /******************************************************************/ |
| 10418 | |
| 10419 | static struct bnx2x_phy phy_null = { |
| 10420 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_NOT_CONN, |
| 10421 | .addr = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10422 | .def_md_devad = 0, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 10423 | .flags = FLAGS_INIT_XGXS_FIRST, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10424 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 10425 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 10426 | .mdio_ctrl = 0, |
| 10427 | .supported = 0, |
| 10428 | .media_type = ETH_PHY_NOT_PRESENT, |
| 10429 | .ver_addr = 0, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10430 | .req_flow_ctrl = 0, |
| 10431 | .req_line_speed = 0, |
| 10432 | .speed_cap_mask = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10433 | .req_duplex = 0, |
| 10434 | .rsrv = 0, |
| 10435 | .config_init = (config_init_t)NULL, |
| 10436 | .read_status = (read_status_t)NULL, |
| 10437 | .link_reset = (link_reset_t)NULL, |
| 10438 | .config_loopback = (config_loopback_t)NULL, |
| 10439 | .format_fw_ver = (format_fw_ver_t)NULL, |
| 10440 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 10441 | .set_link_led = (set_link_led_t)NULL, |
| 10442 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10443 | }; |
| 10444 | |
| 10445 | static struct bnx2x_phy phy_serdes = { |
| 10446 | .type = PORT_HW_CFG_SERDES_EXT_PHY_TYPE_DIRECT, |
| 10447 | .addr = 0xff, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10448 | .def_md_devad = 0, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 10449 | .flags = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10450 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 10451 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 10452 | .mdio_ctrl = 0, |
| 10453 | .supported = (SUPPORTED_10baseT_Half | |
| 10454 | SUPPORTED_10baseT_Full | |
| 10455 | SUPPORTED_100baseT_Half | |
| 10456 | SUPPORTED_100baseT_Full | |
| 10457 | SUPPORTED_1000baseT_Full | |
| 10458 | SUPPORTED_2500baseX_Full | |
| 10459 | SUPPORTED_TP | |
| 10460 | SUPPORTED_Autoneg | |
| 10461 | SUPPORTED_Pause | |
| 10462 | SUPPORTED_Asym_Pause), |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 10463 | .media_type = ETH_PHY_BASE_T, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10464 | .ver_addr = 0, |
| 10465 | .req_flow_ctrl = 0, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10466 | .req_line_speed = 0, |
| 10467 | .speed_cap_mask = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10468 | .req_duplex = 0, |
| 10469 | .rsrv = 0, |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 10470 | .config_init = (config_init_t)bnx2x_xgxs_config_init, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10471 | .read_status = (read_status_t)bnx2x_link_settings_status, |
| 10472 | .link_reset = (link_reset_t)bnx2x_int_link_reset, |
| 10473 | .config_loopback = (config_loopback_t)NULL, |
| 10474 | .format_fw_ver = (format_fw_ver_t)NULL, |
| 10475 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 10476 | .set_link_led = (set_link_led_t)NULL, |
| 10477 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10478 | }; |
| 10479 | |
| 10480 | static struct bnx2x_phy phy_xgxs = { |
| 10481 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT, |
| 10482 | .addr = 0xff, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10483 | .def_md_devad = 0, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 10484 | .flags = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10485 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 10486 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 10487 | .mdio_ctrl = 0, |
| 10488 | .supported = (SUPPORTED_10baseT_Half | |
| 10489 | SUPPORTED_10baseT_Full | |
| 10490 | SUPPORTED_100baseT_Half | |
| 10491 | SUPPORTED_100baseT_Full | |
| 10492 | SUPPORTED_1000baseT_Full | |
| 10493 | SUPPORTED_2500baseX_Full | |
| 10494 | SUPPORTED_10000baseT_Full | |
| 10495 | SUPPORTED_FIBRE | |
| 10496 | SUPPORTED_Autoneg | |
| 10497 | SUPPORTED_Pause | |
| 10498 | SUPPORTED_Asym_Pause), |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 10499 | .media_type = ETH_PHY_CX4, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10500 | .ver_addr = 0, |
| 10501 | .req_flow_ctrl = 0, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10502 | .req_line_speed = 0, |
| 10503 | .speed_cap_mask = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10504 | .req_duplex = 0, |
| 10505 | .rsrv = 0, |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 10506 | .config_init = (config_init_t)bnx2x_xgxs_config_init, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10507 | .read_status = (read_status_t)bnx2x_link_settings_status, |
| 10508 | .link_reset = (link_reset_t)bnx2x_int_link_reset, |
| 10509 | .config_loopback = (config_loopback_t)bnx2x_set_xgxs_loopback, |
| 10510 | .format_fw_ver = (format_fw_ver_t)NULL, |
| 10511 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 10512 | .set_link_led = (set_link_led_t)NULL, |
| 10513 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10514 | }; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 10515 | static struct bnx2x_phy phy_warpcore = { |
| 10516 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT, |
| 10517 | .addr = 0xff, |
| 10518 | .def_md_devad = 0, |
| 10519 | .flags = FLAGS_HW_LOCK_REQUIRED, |
| 10520 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 10521 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 10522 | .mdio_ctrl = 0, |
| 10523 | .supported = (SUPPORTED_10baseT_Half | |
| 10524 | SUPPORTED_10baseT_Full | |
| 10525 | SUPPORTED_100baseT_Half | |
| 10526 | SUPPORTED_100baseT_Full | |
| 10527 | SUPPORTED_1000baseT_Full | |
| 10528 | SUPPORTED_10000baseT_Full | |
| 10529 | SUPPORTED_20000baseKR2_Full | |
| 10530 | SUPPORTED_20000baseMLD2_Full | |
| 10531 | SUPPORTED_FIBRE | |
| 10532 | SUPPORTED_Autoneg | |
| 10533 | SUPPORTED_Pause | |
| 10534 | SUPPORTED_Asym_Pause), |
| 10535 | .media_type = ETH_PHY_UNSPECIFIED, |
| 10536 | .ver_addr = 0, |
| 10537 | .req_flow_ctrl = 0, |
| 10538 | .req_line_speed = 0, |
| 10539 | .speed_cap_mask = 0, |
| 10540 | /* req_duplex = */0, |
| 10541 | /* rsrv = */0, |
| 10542 | .config_init = (config_init_t)bnx2x_warpcore_config_init, |
| 10543 | .read_status = (read_status_t)bnx2x_warpcore_read_status, |
| 10544 | .link_reset = (link_reset_t)bnx2x_warpcore_link_reset, |
| 10545 | .config_loopback = (config_loopback_t)bnx2x_set_warpcore_loopback, |
| 10546 | .format_fw_ver = (format_fw_ver_t)NULL, |
Yaniv Rosner | 985848f | 2011-07-05 01:06:48 +0000 | [diff] [blame] | 10547 | .hw_reset = (hw_reset_t)bnx2x_warpcore_hw_reset, |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 10548 | .set_link_led = (set_link_led_t)NULL, |
| 10549 | .phy_specific_func = (phy_specific_func_t)NULL |
| 10550 | }; |
| 10551 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10552 | |
| 10553 | static struct bnx2x_phy phy_7101 = { |
| 10554 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_SFX7101, |
| 10555 | .addr = 0xff, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10556 | .def_md_devad = 0, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 10557 | .flags = FLAGS_FAN_FAILURE_DET_REQ, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10558 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 10559 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 10560 | .mdio_ctrl = 0, |
| 10561 | .supported = (SUPPORTED_10000baseT_Full | |
| 10562 | SUPPORTED_TP | |
| 10563 | SUPPORTED_Autoneg | |
| 10564 | SUPPORTED_Pause | |
| 10565 | SUPPORTED_Asym_Pause), |
| 10566 | .media_type = ETH_PHY_BASE_T, |
| 10567 | .ver_addr = 0, |
| 10568 | .req_flow_ctrl = 0, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10569 | .req_line_speed = 0, |
| 10570 | .speed_cap_mask = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10571 | .req_duplex = 0, |
| 10572 | .rsrv = 0, |
| 10573 | .config_init = (config_init_t)bnx2x_7101_config_init, |
| 10574 | .read_status = (read_status_t)bnx2x_7101_read_status, |
| 10575 | .link_reset = (link_reset_t)bnx2x_common_ext_link_reset, |
| 10576 | .config_loopback = (config_loopback_t)bnx2x_7101_config_loopback, |
| 10577 | .format_fw_ver = (format_fw_ver_t)bnx2x_7101_format_ver, |
| 10578 | .hw_reset = (hw_reset_t)bnx2x_7101_hw_reset, |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10579 | .set_link_led = (set_link_led_t)bnx2x_7101_set_link_led, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 10580 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10581 | }; |
| 10582 | static struct bnx2x_phy phy_8073 = { |
| 10583 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073, |
| 10584 | .addr = 0xff, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10585 | .def_md_devad = 0, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 10586 | .flags = FLAGS_HW_LOCK_REQUIRED, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10587 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 10588 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 10589 | .mdio_ctrl = 0, |
| 10590 | .supported = (SUPPORTED_10000baseT_Full | |
| 10591 | SUPPORTED_2500baseX_Full | |
| 10592 | SUPPORTED_1000baseT_Full | |
| 10593 | SUPPORTED_FIBRE | |
| 10594 | SUPPORTED_Autoneg | |
| 10595 | SUPPORTED_Pause | |
| 10596 | SUPPORTED_Asym_Pause), |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 10597 | .media_type = ETH_PHY_KR, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10598 | .ver_addr = 0, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10599 | .req_flow_ctrl = 0, |
| 10600 | .req_line_speed = 0, |
| 10601 | .speed_cap_mask = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10602 | .req_duplex = 0, |
| 10603 | .rsrv = 0, |
Yaniv Rosner | 62b29a5 | 2010-09-07 11:40:58 +0000 | [diff] [blame] | 10604 | .config_init = (config_init_t)bnx2x_8073_config_init, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10605 | .read_status = (read_status_t)bnx2x_8073_read_status, |
| 10606 | .link_reset = (link_reset_t)bnx2x_8073_link_reset, |
| 10607 | .config_loopback = (config_loopback_t)NULL, |
| 10608 | .format_fw_ver = (format_fw_ver_t)bnx2x_format_ver, |
| 10609 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 10610 | .set_link_led = (set_link_led_t)NULL, |
| 10611 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10612 | }; |
| 10613 | static struct bnx2x_phy phy_8705 = { |
| 10614 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8705, |
| 10615 | .addr = 0xff, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10616 | .def_md_devad = 0, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 10617 | .flags = FLAGS_INIT_XGXS_FIRST, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10618 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 10619 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 10620 | .mdio_ctrl = 0, |
| 10621 | .supported = (SUPPORTED_10000baseT_Full | |
| 10622 | SUPPORTED_FIBRE | |
| 10623 | SUPPORTED_Pause | |
| 10624 | SUPPORTED_Asym_Pause), |
| 10625 | .media_type = ETH_PHY_XFP_FIBER, |
| 10626 | .ver_addr = 0, |
| 10627 | .req_flow_ctrl = 0, |
| 10628 | .req_line_speed = 0, |
| 10629 | .speed_cap_mask = 0, |
| 10630 | .req_duplex = 0, |
| 10631 | .rsrv = 0, |
| 10632 | .config_init = (config_init_t)bnx2x_8705_config_init, |
| 10633 | .read_status = (read_status_t)bnx2x_8705_read_status, |
| 10634 | .link_reset = (link_reset_t)bnx2x_common_ext_link_reset, |
| 10635 | .config_loopback = (config_loopback_t)NULL, |
| 10636 | .format_fw_ver = (format_fw_ver_t)bnx2x_null_format_ver, |
| 10637 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 10638 | .set_link_led = (set_link_led_t)NULL, |
| 10639 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10640 | }; |
| 10641 | static struct bnx2x_phy phy_8706 = { |
| 10642 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8706, |
| 10643 | .addr = 0xff, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10644 | .def_md_devad = 0, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 10645 | .flags = FLAGS_INIT_XGXS_FIRST, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10646 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 10647 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 10648 | .mdio_ctrl = 0, |
| 10649 | .supported = (SUPPORTED_10000baseT_Full | |
| 10650 | SUPPORTED_1000baseT_Full | |
| 10651 | SUPPORTED_FIBRE | |
| 10652 | SUPPORTED_Pause | |
| 10653 | SUPPORTED_Asym_Pause), |
| 10654 | .media_type = ETH_PHY_SFP_FIBER, |
| 10655 | .ver_addr = 0, |
| 10656 | .req_flow_ctrl = 0, |
| 10657 | .req_line_speed = 0, |
| 10658 | .speed_cap_mask = 0, |
| 10659 | .req_duplex = 0, |
| 10660 | .rsrv = 0, |
| 10661 | .config_init = (config_init_t)bnx2x_8706_config_init, |
| 10662 | .read_status = (read_status_t)bnx2x_8706_read_status, |
| 10663 | .link_reset = (link_reset_t)bnx2x_common_ext_link_reset, |
| 10664 | .config_loopback = (config_loopback_t)NULL, |
| 10665 | .format_fw_ver = (format_fw_ver_t)bnx2x_format_ver, |
| 10666 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 10667 | .set_link_led = (set_link_led_t)NULL, |
| 10668 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10669 | }; |
| 10670 | |
| 10671 | static struct bnx2x_phy phy_8726 = { |
| 10672 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726, |
| 10673 | .addr = 0xff, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 10674 | .def_md_devad = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10675 | .flags = (FLAGS_HW_LOCK_REQUIRED | |
| 10676 | FLAGS_INIT_XGXS_FIRST), |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10677 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 10678 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 10679 | .mdio_ctrl = 0, |
| 10680 | .supported = (SUPPORTED_10000baseT_Full | |
| 10681 | SUPPORTED_1000baseT_Full | |
| 10682 | SUPPORTED_Autoneg | |
| 10683 | SUPPORTED_FIBRE | |
| 10684 | SUPPORTED_Pause | |
| 10685 | SUPPORTED_Asym_Pause), |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 10686 | .media_type = ETH_PHY_NOT_PRESENT, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10687 | .ver_addr = 0, |
| 10688 | .req_flow_ctrl = 0, |
| 10689 | .req_line_speed = 0, |
| 10690 | .speed_cap_mask = 0, |
| 10691 | .req_duplex = 0, |
| 10692 | .rsrv = 0, |
| 10693 | .config_init = (config_init_t)bnx2x_8726_config_init, |
| 10694 | .read_status = (read_status_t)bnx2x_8726_read_status, |
| 10695 | .link_reset = (link_reset_t)bnx2x_8726_link_reset, |
| 10696 | .config_loopback = (config_loopback_t)bnx2x_8726_config_loopback, |
| 10697 | .format_fw_ver = (format_fw_ver_t)bnx2x_format_ver, |
| 10698 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 10699 | .set_link_led = (set_link_led_t)NULL, |
| 10700 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10701 | }; |
| 10702 | |
| 10703 | static struct bnx2x_phy phy_8727 = { |
| 10704 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727, |
| 10705 | .addr = 0xff, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10706 | .def_md_devad = 0, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 10707 | .flags = FLAGS_FAN_FAILURE_DET_REQ, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10708 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 10709 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 10710 | .mdio_ctrl = 0, |
| 10711 | .supported = (SUPPORTED_10000baseT_Full | |
| 10712 | SUPPORTED_1000baseT_Full | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10713 | SUPPORTED_FIBRE | |
| 10714 | SUPPORTED_Pause | |
| 10715 | SUPPORTED_Asym_Pause), |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 10716 | .media_type = ETH_PHY_NOT_PRESENT, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10717 | .ver_addr = 0, |
| 10718 | .req_flow_ctrl = 0, |
| 10719 | .req_line_speed = 0, |
| 10720 | .speed_cap_mask = 0, |
| 10721 | .req_duplex = 0, |
| 10722 | .rsrv = 0, |
| 10723 | .config_init = (config_init_t)bnx2x_8727_config_init, |
| 10724 | .read_status = (read_status_t)bnx2x_8727_read_status, |
| 10725 | .link_reset = (link_reset_t)bnx2x_8727_link_reset, |
| 10726 | .config_loopback = (config_loopback_t)NULL, |
| 10727 | .format_fw_ver = (format_fw_ver_t)bnx2x_format_ver, |
| 10728 | .hw_reset = (hw_reset_t)bnx2x_8727_hw_reset, |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10729 | .set_link_led = (set_link_led_t)bnx2x_8727_set_link_led, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 10730 | .phy_specific_func = (phy_specific_func_t)bnx2x_8727_specific_func |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10731 | }; |
| 10732 | static struct bnx2x_phy phy_8481 = { |
| 10733 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8481, |
| 10734 | .addr = 0xff, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 10735 | .def_md_devad = 0, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 10736 | .flags = FLAGS_FAN_FAILURE_DET_REQ | |
| 10737 | FLAGS_REARM_LATCH_SIGNAL, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10738 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 10739 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 10740 | .mdio_ctrl = 0, |
| 10741 | .supported = (SUPPORTED_10baseT_Half | |
| 10742 | SUPPORTED_10baseT_Full | |
| 10743 | SUPPORTED_100baseT_Half | |
| 10744 | SUPPORTED_100baseT_Full | |
| 10745 | SUPPORTED_1000baseT_Full | |
| 10746 | SUPPORTED_10000baseT_Full | |
| 10747 | SUPPORTED_TP | |
| 10748 | SUPPORTED_Autoneg | |
| 10749 | SUPPORTED_Pause | |
| 10750 | SUPPORTED_Asym_Pause), |
| 10751 | .media_type = ETH_PHY_BASE_T, |
| 10752 | .ver_addr = 0, |
| 10753 | .req_flow_ctrl = 0, |
| 10754 | .req_line_speed = 0, |
| 10755 | .speed_cap_mask = 0, |
| 10756 | .req_duplex = 0, |
| 10757 | .rsrv = 0, |
| 10758 | .config_init = (config_init_t)bnx2x_8481_config_init, |
| 10759 | .read_status = (read_status_t)bnx2x_848xx_read_status, |
| 10760 | .link_reset = (link_reset_t)bnx2x_8481_link_reset, |
| 10761 | .config_loopback = (config_loopback_t)NULL, |
| 10762 | .format_fw_ver = (format_fw_ver_t)bnx2x_848xx_format_ver, |
| 10763 | .hw_reset = (hw_reset_t)bnx2x_8481_hw_reset, |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10764 | .set_link_led = (set_link_led_t)bnx2x_848xx_set_link_led, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 10765 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10766 | }; |
| 10767 | |
| 10768 | static struct bnx2x_phy phy_84823 = { |
| 10769 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84823, |
| 10770 | .addr = 0xff, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 10771 | .def_md_devad = 0, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 10772 | .flags = FLAGS_FAN_FAILURE_DET_REQ | |
| 10773 | FLAGS_REARM_LATCH_SIGNAL, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10774 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 10775 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 10776 | .mdio_ctrl = 0, |
| 10777 | .supported = (SUPPORTED_10baseT_Half | |
| 10778 | SUPPORTED_10baseT_Full | |
| 10779 | SUPPORTED_100baseT_Half | |
| 10780 | SUPPORTED_100baseT_Full | |
| 10781 | SUPPORTED_1000baseT_Full | |
| 10782 | SUPPORTED_10000baseT_Full | |
| 10783 | SUPPORTED_TP | |
| 10784 | SUPPORTED_Autoneg | |
| 10785 | SUPPORTED_Pause | |
| 10786 | SUPPORTED_Asym_Pause), |
| 10787 | .media_type = ETH_PHY_BASE_T, |
| 10788 | .ver_addr = 0, |
| 10789 | .req_flow_ctrl = 0, |
| 10790 | .req_line_speed = 0, |
| 10791 | .speed_cap_mask = 0, |
| 10792 | .req_duplex = 0, |
| 10793 | .rsrv = 0, |
| 10794 | .config_init = (config_init_t)bnx2x_848x3_config_init, |
| 10795 | .read_status = (read_status_t)bnx2x_848xx_read_status, |
| 10796 | .link_reset = (link_reset_t)bnx2x_848x3_link_reset, |
| 10797 | .config_loopback = (config_loopback_t)NULL, |
| 10798 | .format_fw_ver = (format_fw_ver_t)bnx2x_848xx_format_ver, |
| 10799 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10800 | .set_link_led = (set_link_led_t)bnx2x_848xx_set_link_led, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 10801 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10802 | }; |
| 10803 | |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 10804 | static struct bnx2x_phy phy_84833 = { |
| 10805 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833, |
| 10806 | .addr = 0xff, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 10807 | .def_md_devad = 0, |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 10808 | .flags = FLAGS_FAN_FAILURE_DET_REQ | |
| 10809 | FLAGS_REARM_LATCH_SIGNAL, |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 10810 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 10811 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 10812 | .mdio_ctrl = 0, |
Yaniv Rosner | 0520e63 | 2011-07-05 01:06:59 +0000 | [diff] [blame^] | 10813 | .supported = (SUPPORTED_100baseT_Half | |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 10814 | SUPPORTED_100baseT_Full | |
| 10815 | SUPPORTED_1000baseT_Full | |
| 10816 | SUPPORTED_10000baseT_Full | |
| 10817 | SUPPORTED_TP | |
| 10818 | SUPPORTED_Autoneg | |
| 10819 | SUPPORTED_Pause | |
| 10820 | SUPPORTED_Asym_Pause), |
| 10821 | .media_type = ETH_PHY_BASE_T, |
| 10822 | .ver_addr = 0, |
| 10823 | .req_flow_ctrl = 0, |
| 10824 | .req_line_speed = 0, |
| 10825 | .speed_cap_mask = 0, |
| 10826 | .req_duplex = 0, |
| 10827 | .rsrv = 0, |
| 10828 | .config_init = (config_init_t)bnx2x_848x3_config_init, |
| 10829 | .read_status = (read_status_t)bnx2x_848xx_read_status, |
| 10830 | .link_reset = (link_reset_t)bnx2x_848x3_link_reset, |
| 10831 | .config_loopback = (config_loopback_t)NULL, |
| 10832 | .format_fw_ver = (format_fw_ver_t)bnx2x_848xx_format_ver, |
Yaniv Rosner | 985848f | 2011-07-05 01:06:48 +0000 | [diff] [blame] | 10833 | .hw_reset = (hw_reset_t)bnx2x_84833_hw_reset_phy, |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 10834 | .set_link_led = (set_link_led_t)bnx2x_848xx_set_link_led, |
| 10835 | .phy_specific_func = (phy_specific_func_t)NULL |
| 10836 | }; |
| 10837 | |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 10838 | static struct bnx2x_phy phy_54618se = { |
| 10839 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54618SE, |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 10840 | .addr = 0xff, |
| 10841 | .def_md_devad = 0, |
| 10842 | .flags = FLAGS_INIT_XGXS_FIRST, |
| 10843 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 10844 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 10845 | .mdio_ctrl = 0, |
| 10846 | .supported = (SUPPORTED_10baseT_Half | |
| 10847 | SUPPORTED_10baseT_Full | |
| 10848 | SUPPORTED_100baseT_Half | |
| 10849 | SUPPORTED_100baseT_Full | |
| 10850 | SUPPORTED_1000baseT_Full | |
| 10851 | SUPPORTED_TP | |
| 10852 | SUPPORTED_Autoneg | |
| 10853 | SUPPORTED_Pause | |
| 10854 | SUPPORTED_Asym_Pause), |
| 10855 | .media_type = ETH_PHY_BASE_T, |
| 10856 | .ver_addr = 0, |
| 10857 | .req_flow_ctrl = 0, |
| 10858 | .req_line_speed = 0, |
| 10859 | .speed_cap_mask = 0, |
| 10860 | /* req_duplex = */0, |
| 10861 | /* rsrv = */0, |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 10862 | .config_init = (config_init_t)bnx2x_54618se_config_init, |
| 10863 | .read_status = (read_status_t)bnx2x_54618se_read_status, |
| 10864 | .link_reset = (link_reset_t)bnx2x_54618se_link_reset, |
| 10865 | .config_loopback = (config_loopback_t)bnx2x_54618se_config_loopback, |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 10866 | .format_fw_ver = (format_fw_ver_t)NULL, |
| 10867 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 10868 | .set_link_led = (set_link_led_t)bnx2x_54618se_set_link_led, |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 10869 | .phy_specific_func = (phy_specific_func_t)NULL |
| 10870 | }; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10871 | /*****************************************************************/ |
| 10872 | /* */ |
| 10873 | /* Populate the phy according. Main function: bnx2x_populate_phy */ |
| 10874 | /* */ |
| 10875 | /*****************************************************************/ |
| 10876 | |
| 10877 | static void bnx2x_populate_preemphasis(struct bnx2x *bp, u32 shmem_base, |
| 10878 | struct bnx2x_phy *phy, u8 port, |
| 10879 | u8 phy_index) |
| 10880 | { |
| 10881 | /* Get the 4 lanes xgxs config rx and tx */ |
| 10882 | u32 rx = 0, tx = 0, i; |
| 10883 | for (i = 0; i < 2; i++) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 10884 | /* |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10885 | * INT_PHY and EXT_PHY1 share the same value location in the |
| 10886 | * shmem. When num_phys is greater than 1, than this value |
| 10887 | * applies only to EXT_PHY1 |
| 10888 | */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 10889 | if (phy_index == INT_PHY || phy_index == EXT_PHY1) { |
| 10890 | rx = REG_RD(bp, shmem_base + |
| 10891 | offsetof(struct shmem_region, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10892 | dev_info.port_hw_config[port].xgxs_config_rx[i<<1])); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10893 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 10894 | tx = REG_RD(bp, shmem_base + |
| 10895 | offsetof(struct shmem_region, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10896 | dev_info.port_hw_config[port].xgxs_config_tx[i<<1])); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 10897 | } else { |
| 10898 | rx = REG_RD(bp, shmem_base + |
| 10899 | offsetof(struct shmem_region, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10900 | dev_info.port_hw_config[port].xgxs_config2_rx[i<<1])); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10901 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 10902 | tx = REG_RD(bp, shmem_base + |
| 10903 | offsetof(struct shmem_region, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10904 | dev_info.port_hw_config[port].xgxs_config2_rx[i<<1])); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 10905 | } |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10906 | |
| 10907 | phy->rx_preemphasis[i << 1] = ((rx>>16) & 0xffff); |
| 10908 | phy->rx_preemphasis[(i << 1) + 1] = (rx & 0xffff); |
| 10909 | |
| 10910 | phy->tx_preemphasis[i << 1] = ((tx>>16) & 0xffff); |
| 10911 | phy->tx_preemphasis[(i << 1) + 1] = (tx & 0xffff); |
| 10912 | } |
| 10913 | } |
| 10914 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 10915 | static u32 bnx2x_get_ext_phy_config(struct bnx2x *bp, u32 shmem_base, |
| 10916 | u8 phy_index, u8 port) |
| 10917 | { |
| 10918 | u32 ext_phy_config = 0; |
| 10919 | switch (phy_index) { |
| 10920 | case EXT_PHY1: |
| 10921 | ext_phy_config = REG_RD(bp, shmem_base + |
| 10922 | offsetof(struct shmem_region, |
| 10923 | dev_info.port_hw_config[port].external_phy_config)); |
| 10924 | break; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 10925 | case EXT_PHY2: |
| 10926 | ext_phy_config = REG_RD(bp, shmem_base + |
| 10927 | offsetof(struct shmem_region, |
| 10928 | dev_info.port_hw_config[port].external_phy_config2)); |
| 10929 | break; |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 10930 | default: |
| 10931 | DP(NETIF_MSG_LINK, "Invalid phy_index %d\n", phy_index); |
| 10932 | return -EINVAL; |
| 10933 | } |
| 10934 | |
| 10935 | return ext_phy_config; |
| 10936 | } |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 10937 | static int bnx2x_populate_int_phy(struct bnx2x *bp, u32 shmem_base, u8 port, |
| 10938 | struct bnx2x_phy *phy) |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10939 | { |
| 10940 | u32 phy_addr; |
| 10941 | u32 chip_id; |
| 10942 | u32 switch_cfg = (REG_RD(bp, shmem_base + |
| 10943 | offsetof(struct shmem_region, |
| 10944 | dev_info.port_feature_config[port].link_config)) & |
| 10945 | PORT_FEATURE_CONNECTED_SWITCH_MASK); |
| 10946 | chip_id = REG_RD(bp, MISC_REG_CHIP_NUM) << 16; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 10947 | DP(NETIF_MSG_LINK, ":chip_id = 0x%x\n", chip_id); |
| 10948 | if (USES_WARPCORE(bp)) { |
| 10949 | u32 serdes_net_if; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10950 | phy_addr = REG_RD(bp, |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 10951 | MISC_REG_WC0_CTRL_PHY_ADDR); |
| 10952 | *phy = phy_warpcore; |
| 10953 | if (REG_RD(bp, MISC_REG_PORT4MODE_EN_OVWR) == 0x3) |
| 10954 | phy->flags |= FLAGS_4_PORT_MODE; |
| 10955 | else |
| 10956 | phy->flags &= ~FLAGS_4_PORT_MODE; |
| 10957 | /* Check Dual mode */ |
| 10958 | serdes_net_if = (REG_RD(bp, shmem_base + |
| 10959 | offsetof(struct shmem_region, dev_info. |
| 10960 | port_hw_config[port].default_cfg)) & |
| 10961 | PORT_HW_CFG_NET_SERDES_IF_MASK); |
| 10962 | /* |
| 10963 | * Set the appropriate supported and flags indications per |
| 10964 | * interface type of the chip |
| 10965 | */ |
| 10966 | switch (serdes_net_if) { |
| 10967 | case PORT_HW_CFG_NET_SERDES_IF_SGMII: |
| 10968 | phy->supported &= (SUPPORTED_10baseT_Half | |
| 10969 | SUPPORTED_10baseT_Full | |
| 10970 | SUPPORTED_100baseT_Half | |
| 10971 | SUPPORTED_100baseT_Full | |
| 10972 | SUPPORTED_1000baseT_Full | |
| 10973 | SUPPORTED_FIBRE | |
| 10974 | SUPPORTED_Autoneg | |
| 10975 | SUPPORTED_Pause | |
| 10976 | SUPPORTED_Asym_Pause); |
| 10977 | phy->media_type = ETH_PHY_BASE_T; |
| 10978 | break; |
| 10979 | case PORT_HW_CFG_NET_SERDES_IF_XFI: |
| 10980 | phy->media_type = ETH_PHY_XFP_FIBER; |
| 10981 | break; |
| 10982 | case PORT_HW_CFG_NET_SERDES_IF_SFI: |
| 10983 | phy->supported &= (SUPPORTED_1000baseT_Full | |
| 10984 | SUPPORTED_10000baseT_Full | |
| 10985 | SUPPORTED_FIBRE | |
| 10986 | SUPPORTED_Pause | |
| 10987 | SUPPORTED_Asym_Pause); |
| 10988 | phy->media_type = ETH_PHY_SFP_FIBER; |
| 10989 | break; |
| 10990 | case PORT_HW_CFG_NET_SERDES_IF_KR: |
| 10991 | phy->media_type = ETH_PHY_KR; |
| 10992 | phy->supported &= (SUPPORTED_1000baseT_Full | |
| 10993 | SUPPORTED_10000baseT_Full | |
| 10994 | SUPPORTED_FIBRE | |
| 10995 | SUPPORTED_Autoneg | |
| 10996 | SUPPORTED_Pause | |
| 10997 | SUPPORTED_Asym_Pause); |
| 10998 | break; |
| 10999 | case PORT_HW_CFG_NET_SERDES_IF_DXGXS: |
| 11000 | phy->media_type = ETH_PHY_KR; |
| 11001 | phy->flags |= FLAGS_WC_DUAL_MODE; |
| 11002 | phy->supported &= (SUPPORTED_20000baseMLD2_Full | |
| 11003 | SUPPORTED_FIBRE | |
| 11004 | SUPPORTED_Pause | |
| 11005 | SUPPORTED_Asym_Pause); |
| 11006 | break; |
| 11007 | case PORT_HW_CFG_NET_SERDES_IF_KR2: |
| 11008 | phy->media_type = ETH_PHY_KR; |
| 11009 | phy->flags |= FLAGS_WC_DUAL_MODE; |
| 11010 | phy->supported &= (SUPPORTED_20000baseKR2_Full | |
| 11011 | SUPPORTED_FIBRE | |
| 11012 | SUPPORTED_Pause | |
| 11013 | SUPPORTED_Asym_Pause); |
| 11014 | break; |
| 11015 | default: |
| 11016 | DP(NETIF_MSG_LINK, "Unknown WC interface type 0x%x\n", |
| 11017 | serdes_net_if); |
| 11018 | break; |
| 11019 | } |
| 11020 | |
| 11021 | /* |
| 11022 | * Enable MDC/MDIO work-around for E3 A0 since free running MDC |
| 11023 | * was not set as expected. For B0, ECO will be enabled so there |
| 11024 | * won't be an issue there |
| 11025 | */ |
| 11026 | if (CHIP_REV(bp) == CHIP_REV_Ax) |
| 11027 | phy->flags |= FLAGS_MDC_MDIO_WA; |
| 11028 | } else { |
| 11029 | switch (switch_cfg) { |
| 11030 | case SWITCH_CFG_1G: |
| 11031 | phy_addr = REG_RD(bp, |
| 11032 | NIG_REG_SERDES0_CTRL_PHY_ADDR + |
| 11033 | port * 0x10); |
| 11034 | *phy = phy_serdes; |
| 11035 | break; |
| 11036 | case SWITCH_CFG_10G: |
| 11037 | phy_addr = REG_RD(bp, |
| 11038 | NIG_REG_XGXS0_CTRL_PHY_ADDR + |
| 11039 | port * 0x18); |
| 11040 | *phy = phy_xgxs; |
| 11041 | break; |
| 11042 | default: |
| 11043 | DP(NETIF_MSG_LINK, "Invalid switch_cfg\n"); |
| 11044 | return -EINVAL; |
| 11045 | } |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11046 | } |
| 11047 | phy->addr = (u8)phy_addr; |
| 11048 | phy->mdio_ctrl = bnx2x_get_emac_base(bp, |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 11049 | SHARED_HW_CFG_MDC_MDIO_ACCESS1_BOTH, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11050 | port); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 11051 | if (CHIP_IS_E2(bp)) |
| 11052 | phy->def_md_devad = E2_DEFAULT_PHY_DEV_ADDR; |
| 11053 | else |
| 11054 | phy->def_md_devad = DEFAULT_PHY_DEV_ADDR; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11055 | |
| 11056 | DP(NETIF_MSG_LINK, "Internal phy port=%d, addr=0x%x, mdio_ctl=0x%x\n", |
| 11057 | port, phy->addr, phy->mdio_ctrl); |
| 11058 | |
| 11059 | bnx2x_populate_preemphasis(bp, shmem_base, phy, port, INT_PHY); |
| 11060 | return 0; |
| 11061 | } |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 11062 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 11063 | static int bnx2x_populate_ext_phy(struct bnx2x *bp, |
| 11064 | u8 phy_index, |
| 11065 | u32 shmem_base, |
| 11066 | u32 shmem2_base, |
| 11067 | u8 port, |
| 11068 | struct bnx2x_phy *phy) |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 11069 | { |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 11070 | u32 ext_phy_config, phy_type, config2; |
| 11071 | u32 mdc_mdio_access = SHARED_HW_CFG_MDC_MDIO_ACCESS1_BOTH; |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 11072 | ext_phy_config = bnx2x_get_ext_phy_config(bp, shmem_base, |
| 11073 | phy_index, port); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11074 | phy_type = XGXS_EXT_PHY_TYPE(ext_phy_config); |
| 11075 | /* Select the phy type */ |
| 11076 | switch (phy_type) { |
| 11077 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073: |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 11078 | mdc_mdio_access = SHARED_HW_CFG_MDC_MDIO_ACCESS1_SWAPPED; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11079 | *phy = phy_8073; |
| 11080 | break; |
| 11081 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8705: |
| 11082 | *phy = phy_8705; |
| 11083 | break; |
| 11084 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8706: |
| 11085 | *phy = phy_8706; |
| 11086 | break; |
| 11087 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726: |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 11088 | mdc_mdio_access = SHARED_HW_CFG_MDC_MDIO_ACCESS1_EMAC1; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11089 | *phy = phy_8726; |
| 11090 | break; |
| 11091 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727_NOC: |
| 11092 | /* BCM8727_NOC => BCM8727 no over current */ |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 11093 | mdc_mdio_access = SHARED_HW_CFG_MDC_MDIO_ACCESS1_EMAC1; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11094 | *phy = phy_8727; |
| 11095 | phy->flags |= FLAGS_NOC; |
| 11096 | break; |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 11097 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8722: |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11098 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727: |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 11099 | mdc_mdio_access = SHARED_HW_CFG_MDC_MDIO_ACCESS1_EMAC1; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11100 | *phy = phy_8727; |
| 11101 | break; |
| 11102 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8481: |
| 11103 | *phy = phy_8481; |
| 11104 | break; |
| 11105 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84823: |
| 11106 | *phy = phy_84823; |
| 11107 | break; |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 11108 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833: |
| 11109 | *phy = phy_84833; |
| 11110 | break; |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 11111 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54618SE: |
| 11112 | *phy = phy_54618se; |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 11113 | break; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11114 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_SFX7101: |
| 11115 | *phy = phy_7101; |
| 11116 | break; |
| 11117 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_FAILURE: |
| 11118 | *phy = phy_null; |
| 11119 | return -EINVAL; |
| 11120 | default: |
| 11121 | *phy = phy_null; |
| 11122 | return 0; |
| 11123 | } |
| 11124 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 11125 | phy->addr = XGXS_EXT_PHY_ADDR(ext_phy_config); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11126 | bnx2x_populate_preemphasis(bp, shmem_base, phy, port, phy_index); |
Yaniv Rosner | 62b29a5 | 2010-09-07 11:40:58 +0000 | [diff] [blame] | 11127 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 11128 | /* |
| 11129 | * The shmem address of the phy version is located on different |
| 11130 | * structures. In case this structure is too old, do not set |
| 11131 | * the address |
| 11132 | */ |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 11133 | config2 = REG_RD(bp, shmem_base + offsetof(struct shmem_region, |
| 11134 | dev_info.shared_hw_config.config2)); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11135 | if (phy_index == EXT_PHY1) { |
| 11136 | phy->ver_addr = shmem_base + offsetof(struct shmem_region, |
| 11137 | port_mb[port].ext_phy_fw_version); |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 11138 | |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11139 | /* Check specific mdc mdio settings */ |
| 11140 | if (config2 & SHARED_HW_CFG_MDC_MDIO_ACCESS1_MASK) |
| 11141 | mdc_mdio_access = config2 & |
| 11142 | SHARED_HW_CFG_MDC_MDIO_ACCESS1_MASK; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11143 | } else { |
| 11144 | u32 size = REG_RD(bp, shmem2_base); |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 11145 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11146 | if (size > |
| 11147 | offsetof(struct shmem2_region, ext_phy_fw_version2)) { |
| 11148 | phy->ver_addr = shmem2_base + |
| 11149 | offsetof(struct shmem2_region, |
| 11150 | ext_phy_fw_version2[port]); |
| 11151 | } |
| 11152 | /* Check specific mdc mdio settings */ |
| 11153 | if (config2 & SHARED_HW_CFG_MDC_MDIO_ACCESS2_MASK) |
| 11154 | mdc_mdio_access = (config2 & |
| 11155 | SHARED_HW_CFG_MDC_MDIO_ACCESS2_MASK) >> |
| 11156 | (SHARED_HW_CFG_MDC_MDIO_ACCESS2_SHIFT - |
| 11157 | SHARED_HW_CFG_MDC_MDIO_ACCESS1_SHIFT); |
| 11158 | } |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 11159 | phy->mdio_ctrl = bnx2x_get_emac_base(bp, mdc_mdio_access, port); |
| 11160 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 11161 | /* |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 11162 | * In case mdc/mdio_access of the external phy is different than the |
| 11163 | * mdc/mdio access of the XGXS, a HW lock must be taken in each access |
| 11164 | * to prevent one port interfere with another port's CL45 operations. |
| 11165 | */ |
| 11166 | if (mdc_mdio_access != SHARED_HW_CFG_MDC_MDIO_ACCESS1_BOTH) |
| 11167 | phy->flags |= FLAGS_HW_LOCK_REQUIRED; |
| 11168 | DP(NETIF_MSG_LINK, "phy_type 0x%x port %d found in index %d\n", |
| 11169 | phy_type, port, phy_index); |
| 11170 | DP(NETIF_MSG_LINK, " addr=0x%x, mdio_ctl=0x%x\n", |
| 11171 | phy->addr, phy->mdio_ctrl); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 11172 | return 0; |
| 11173 | } |
| 11174 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 11175 | static int bnx2x_populate_phy(struct bnx2x *bp, u8 phy_index, u32 shmem_base, |
| 11176 | u32 shmem2_base, u8 port, struct bnx2x_phy *phy) |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 11177 | { |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 11178 | int status = 0; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11179 | phy->type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_NOT_CONN; |
| 11180 | if (phy_index == INT_PHY) |
| 11181 | return bnx2x_populate_int_phy(bp, shmem_base, port, phy); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11182 | status = bnx2x_populate_ext_phy(bp, phy_index, shmem_base, shmem2_base, |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 11183 | port, phy); |
| 11184 | return status; |
| 11185 | } |
| 11186 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11187 | static void bnx2x_phy_def_cfg(struct link_params *params, |
| 11188 | struct bnx2x_phy *phy, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11189 | u8 phy_index) |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11190 | { |
| 11191 | struct bnx2x *bp = params->bp; |
| 11192 | u32 link_config; |
| 11193 | /* Populate the default phy configuration for MF mode */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11194 | if (phy_index == EXT_PHY2) { |
| 11195 | link_config = REG_RD(bp, params->shmem_base + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11196 | offsetof(struct shmem_region, dev_info. |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11197 | port_feature_config[params->port].link_config2)); |
| 11198 | phy->speed_cap_mask = REG_RD(bp, params->shmem_base + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11199 | offsetof(struct shmem_region, |
| 11200 | dev_info. |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11201 | port_hw_config[params->port].speed_capability_mask2)); |
| 11202 | } else { |
| 11203 | link_config = REG_RD(bp, params->shmem_base + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11204 | offsetof(struct shmem_region, dev_info. |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11205 | port_feature_config[params->port].link_config)); |
| 11206 | phy->speed_cap_mask = REG_RD(bp, params->shmem_base + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11207 | offsetof(struct shmem_region, |
| 11208 | dev_info. |
| 11209 | port_hw_config[params->port].speed_capability_mask)); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11210 | } |
| 11211 | DP(NETIF_MSG_LINK, "Default config phy idx %x cfg 0x%x speed_cap_mask" |
| 11212 | " 0x%x\n", phy_index, link_config, phy->speed_cap_mask); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11213 | |
| 11214 | phy->req_duplex = DUPLEX_FULL; |
| 11215 | switch (link_config & PORT_FEATURE_LINK_SPEED_MASK) { |
| 11216 | case PORT_FEATURE_LINK_SPEED_10M_HALF: |
| 11217 | phy->req_duplex = DUPLEX_HALF; |
| 11218 | case PORT_FEATURE_LINK_SPEED_10M_FULL: |
| 11219 | phy->req_line_speed = SPEED_10; |
| 11220 | break; |
| 11221 | case PORT_FEATURE_LINK_SPEED_100M_HALF: |
| 11222 | phy->req_duplex = DUPLEX_HALF; |
| 11223 | case PORT_FEATURE_LINK_SPEED_100M_FULL: |
| 11224 | phy->req_line_speed = SPEED_100; |
| 11225 | break; |
| 11226 | case PORT_FEATURE_LINK_SPEED_1G: |
| 11227 | phy->req_line_speed = SPEED_1000; |
| 11228 | break; |
| 11229 | case PORT_FEATURE_LINK_SPEED_2_5G: |
| 11230 | phy->req_line_speed = SPEED_2500; |
| 11231 | break; |
| 11232 | case PORT_FEATURE_LINK_SPEED_10G_CX4: |
| 11233 | phy->req_line_speed = SPEED_10000; |
| 11234 | break; |
| 11235 | default: |
| 11236 | phy->req_line_speed = SPEED_AUTO_NEG; |
| 11237 | break; |
| 11238 | } |
| 11239 | |
| 11240 | switch (link_config & PORT_FEATURE_FLOW_CONTROL_MASK) { |
| 11241 | case PORT_FEATURE_FLOW_CONTROL_AUTO: |
| 11242 | phy->req_flow_ctrl = BNX2X_FLOW_CTRL_AUTO; |
| 11243 | break; |
| 11244 | case PORT_FEATURE_FLOW_CONTROL_TX: |
| 11245 | phy->req_flow_ctrl = BNX2X_FLOW_CTRL_TX; |
| 11246 | break; |
| 11247 | case PORT_FEATURE_FLOW_CONTROL_RX: |
| 11248 | phy->req_flow_ctrl = BNX2X_FLOW_CTRL_RX; |
| 11249 | break; |
| 11250 | case PORT_FEATURE_FLOW_CONTROL_BOTH: |
| 11251 | phy->req_flow_ctrl = BNX2X_FLOW_CTRL_BOTH; |
| 11252 | break; |
| 11253 | default: |
| 11254 | phy->req_flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 11255 | break; |
| 11256 | } |
| 11257 | } |
| 11258 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11259 | u32 bnx2x_phy_selection(struct link_params *params) |
| 11260 | { |
| 11261 | u32 phy_config_swapped, prio_cfg; |
| 11262 | u32 return_cfg = PORT_HW_CFG_PHY_SELECTION_HARDWARE_DEFAULT; |
| 11263 | |
| 11264 | phy_config_swapped = params->multi_phy_config & |
| 11265 | PORT_HW_CFG_PHY_SWAPPED_ENABLED; |
| 11266 | |
| 11267 | prio_cfg = params->multi_phy_config & |
| 11268 | PORT_HW_CFG_PHY_SELECTION_MASK; |
| 11269 | |
| 11270 | if (phy_config_swapped) { |
| 11271 | switch (prio_cfg) { |
| 11272 | case PORT_HW_CFG_PHY_SELECTION_FIRST_PHY_PRIORITY: |
| 11273 | return_cfg = PORT_HW_CFG_PHY_SELECTION_SECOND_PHY_PRIORITY; |
| 11274 | break; |
| 11275 | case PORT_HW_CFG_PHY_SELECTION_SECOND_PHY_PRIORITY: |
| 11276 | return_cfg = PORT_HW_CFG_PHY_SELECTION_FIRST_PHY_PRIORITY; |
| 11277 | break; |
| 11278 | case PORT_HW_CFG_PHY_SELECTION_SECOND_PHY: |
| 11279 | return_cfg = PORT_HW_CFG_PHY_SELECTION_FIRST_PHY; |
| 11280 | break; |
| 11281 | case PORT_HW_CFG_PHY_SELECTION_FIRST_PHY: |
| 11282 | return_cfg = PORT_HW_CFG_PHY_SELECTION_SECOND_PHY; |
| 11283 | break; |
| 11284 | } |
| 11285 | } else |
| 11286 | return_cfg = prio_cfg; |
| 11287 | |
| 11288 | return return_cfg; |
| 11289 | } |
| 11290 | |
| 11291 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 11292 | int bnx2x_phy_probe(struct link_params *params) |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11293 | { |
| 11294 | u8 phy_index, actual_phy_idx, link_cfg_idx; |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 11295 | u32 phy_config_swapped, sync_offset, media_types; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11296 | struct bnx2x *bp = params->bp; |
| 11297 | struct bnx2x_phy *phy; |
| 11298 | params->num_phys = 0; |
| 11299 | DP(NETIF_MSG_LINK, "Begin phy probe\n"); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11300 | phy_config_swapped = params->multi_phy_config & |
| 11301 | PORT_HW_CFG_PHY_SWAPPED_ENABLED; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11302 | |
| 11303 | for (phy_index = INT_PHY; phy_index < MAX_PHYS; |
| 11304 | phy_index++) { |
| 11305 | link_cfg_idx = LINK_CONFIG_IDX(phy_index); |
| 11306 | actual_phy_idx = phy_index; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11307 | if (phy_config_swapped) { |
| 11308 | if (phy_index == EXT_PHY1) |
| 11309 | actual_phy_idx = EXT_PHY2; |
| 11310 | else if (phy_index == EXT_PHY2) |
| 11311 | actual_phy_idx = EXT_PHY1; |
| 11312 | } |
| 11313 | DP(NETIF_MSG_LINK, "phy_config_swapped %x, phy_index %x," |
| 11314 | " actual_phy_idx %x\n", phy_config_swapped, |
| 11315 | phy_index, actual_phy_idx); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11316 | phy = ¶ms->phy[actual_phy_idx]; |
| 11317 | if (bnx2x_populate_phy(bp, phy_index, params->shmem_base, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11318 | params->shmem2_base, params->port, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11319 | phy) != 0) { |
| 11320 | params->num_phys = 0; |
| 11321 | DP(NETIF_MSG_LINK, "phy probe failed in phy index %d\n", |
| 11322 | phy_index); |
| 11323 | for (phy_index = INT_PHY; |
| 11324 | phy_index < MAX_PHYS; |
| 11325 | phy_index++) |
| 11326 | *phy = phy_null; |
| 11327 | return -EINVAL; |
| 11328 | } |
| 11329 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_NOT_CONN) |
| 11330 | break; |
| 11331 | |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 11332 | sync_offset = params->shmem_base + |
| 11333 | offsetof(struct shmem_region, |
| 11334 | dev_info.port_hw_config[params->port].media_type); |
| 11335 | media_types = REG_RD(bp, sync_offset); |
| 11336 | |
| 11337 | /* |
| 11338 | * Update media type for non-PMF sync only for the first time |
| 11339 | * In case the media type changes afterwards, it will be updated |
| 11340 | * using the update_status function |
| 11341 | */ |
| 11342 | if ((media_types & (PORT_HW_CFG_MEDIA_TYPE_PHY0_MASK << |
| 11343 | (PORT_HW_CFG_MEDIA_TYPE_PHY1_SHIFT * |
| 11344 | actual_phy_idx))) == 0) { |
| 11345 | media_types |= ((phy->media_type & |
| 11346 | PORT_HW_CFG_MEDIA_TYPE_PHY0_MASK) << |
| 11347 | (PORT_HW_CFG_MEDIA_TYPE_PHY1_SHIFT * |
| 11348 | actual_phy_idx)); |
| 11349 | } |
| 11350 | REG_WR(bp, sync_offset, media_types); |
| 11351 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11352 | bnx2x_phy_def_cfg(params, phy, phy_index); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11353 | params->num_phys++; |
| 11354 | } |
| 11355 | |
| 11356 | DP(NETIF_MSG_LINK, "End phy probe. #phys found %x\n", params->num_phys); |
| 11357 | return 0; |
| 11358 | } |
| 11359 | |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 11360 | void bnx2x_init_bmac_loopback(struct link_params *params, |
| 11361 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11362 | { |
| 11363 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 11364 | vars->link_up = 1; |
| 11365 | vars->line_speed = SPEED_10000; |
| 11366 | vars->duplex = DUPLEX_FULL; |
| 11367 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 11368 | vars->mac_type = MAC_TYPE_BMAC; |
| 11369 | |
| 11370 | vars->phy_flags = PHY_XGXS_FLAG; |
| 11371 | |
| 11372 | bnx2x_xgxs_deassert(params); |
| 11373 | |
| 11374 | /* set bmac loopback */ |
| 11375 | bnx2x_bmac_enable(params, vars, 1); |
| 11376 | |
| 11377 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + params->port*4, 0); |
| 11378 | } |
| 11379 | |
| 11380 | void bnx2x_init_emac_loopback(struct link_params *params, |
| 11381 | struct link_vars *vars) |
| 11382 | { |
| 11383 | struct bnx2x *bp = params->bp; |
| 11384 | vars->link_up = 1; |
| 11385 | vars->line_speed = SPEED_1000; |
| 11386 | vars->duplex = DUPLEX_FULL; |
| 11387 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 11388 | vars->mac_type = MAC_TYPE_EMAC; |
| 11389 | |
| 11390 | vars->phy_flags = PHY_XGXS_FLAG; |
| 11391 | |
| 11392 | bnx2x_xgxs_deassert(params); |
| 11393 | /* set bmac loopback */ |
| 11394 | bnx2x_emac_enable(params, vars, 1); |
| 11395 | bnx2x_emac_program(params, vars); |
| 11396 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + params->port*4, 0); |
| 11397 | } |
| 11398 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 11399 | void bnx2x_init_xmac_loopback(struct link_params *params, |
| 11400 | struct link_vars *vars) |
| 11401 | { |
| 11402 | struct bnx2x *bp = params->bp; |
| 11403 | vars->link_up = 1; |
| 11404 | if (!params->req_line_speed[0]) |
| 11405 | vars->line_speed = SPEED_10000; |
| 11406 | else |
| 11407 | vars->line_speed = params->req_line_speed[0]; |
| 11408 | vars->duplex = DUPLEX_FULL; |
| 11409 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 11410 | vars->mac_type = MAC_TYPE_XMAC; |
| 11411 | vars->phy_flags = PHY_XGXS_FLAG; |
| 11412 | /* |
| 11413 | * Set WC to loopback mode since link is required to provide clock |
| 11414 | * to the XMAC in 20G mode |
| 11415 | */ |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 11416 | if (vars->line_speed == SPEED_20000) { |
| 11417 | bnx2x_set_aer_mmd(params, ¶ms->phy[0]); |
| 11418 | bnx2x_warpcore_reset_lane(bp, ¶ms->phy[0], 0); |
| 11419 | params->phy[INT_PHY].config_loopback( |
| 11420 | ¶ms->phy[INT_PHY], |
| 11421 | params); |
| 11422 | } |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 11423 | bnx2x_xmac_enable(params, vars, 1); |
| 11424 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + params->port*4, 0); |
| 11425 | } |
| 11426 | |
| 11427 | void bnx2x_init_umac_loopback(struct link_params *params, |
| 11428 | struct link_vars *vars) |
| 11429 | { |
| 11430 | struct bnx2x *bp = params->bp; |
| 11431 | vars->link_up = 1; |
| 11432 | vars->line_speed = SPEED_1000; |
| 11433 | vars->duplex = DUPLEX_FULL; |
| 11434 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 11435 | vars->mac_type = MAC_TYPE_UMAC; |
| 11436 | vars->phy_flags = PHY_XGXS_FLAG; |
| 11437 | bnx2x_umac_enable(params, vars, 1); |
| 11438 | |
| 11439 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + params->port*4, 0); |
| 11440 | } |
| 11441 | |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 11442 | void bnx2x_init_xgxs_loopback(struct link_params *params, |
| 11443 | struct link_vars *vars) |
| 11444 | { |
| 11445 | struct bnx2x *bp = params->bp; |
| 11446 | vars->link_up = 1; |
| 11447 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 11448 | vars->duplex = DUPLEX_FULL; |
| 11449 | if (params->req_line_speed[0] == SPEED_1000) |
| 11450 | vars->line_speed = SPEED_1000; |
| 11451 | else |
| 11452 | vars->line_speed = SPEED_10000; |
| 11453 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 11454 | if (!USES_WARPCORE(bp)) |
| 11455 | bnx2x_xgxs_deassert(params); |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 11456 | bnx2x_link_initialize(params, vars); |
| 11457 | |
| 11458 | if (params->req_line_speed[0] == SPEED_1000) { |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 11459 | if (USES_WARPCORE(bp)) |
| 11460 | bnx2x_umac_enable(params, vars, 0); |
| 11461 | else { |
| 11462 | bnx2x_emac_program(params, vars); |
| 11463 | bnx2x_emac_enable(params, vars, 0); |
| 11464 | } |
| 11465 | } else { |
| 11466 | if (USES_WARPCORE(bp)) |
| 11467 | bnx2x_xmac_enable(params, vars, 0); |
| 11468 | else |
| 11469 | bnx2x_bmac_enable(params, vars, 0); |
| 11470 | } |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 11471 | |
| 11472 | if (params->loopback_mode == LOOPBACK_XGXS) { |
| 11473 | /* set 10G XGXS loopback */ |
| 11474 | params->phy[INT_PHY].config_loopback( |
| 11475 | ¶ms->phy[INT_PHY], |
| 11476 | params); |
| 11477 | |
| 11478 | } else { |
| 11479 | /* set external phy loopback */ |
| 11480 | u8 phy_index; |
| 11481 | for (phy_index = EXT_PHY1; |
| 11482 | phy_index < params->num_phys; phy_index++) { |
| 11483 | if (params->phy[phy_index].config_loopback) |
| 11484 | params->phy[phy_index].config_loopback( |
| 11485 | ¶ms->phy[phy_index], |
| 11486 | params); |
| 11487 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11488 | } |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 11489 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + params->port*4, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11490 | |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 11491 | bnx2x_set_led(params, vars, LED_MODE_OPER, vars->line_speed); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11492 | } |
| 11493 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 11494 | int bnx2x_phy_init(struct link_params *params, struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11495 | { |
| 11496 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11497 | DP(NETIF_MSG_LINK, "Phy Initialization started\n"); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11498 | DP(NETIF_MSG_LINK, "(1) req_speed %d, req_flowctrl %d\n", |
| 11499 | params->req_line_speed[0], params->req_flow_ctrl[0]); |
| 11500 | DP(NETIF_MSG_LINK, "(2) req_speed %d, req_flowctrl %d\n", |
| 11501 | params->req_line_speed[1], params->req_flow_ctrl[1]); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11502 | vars->link_status = 0; |
| 11503 | vars->phy_link_up = 0; |
| 11504 | vars->link_up = 0; |
| 11505 | vars->line_speed = 0; |
| 11506 | vars->duplex = DUPLEX_FULL; |
| 11507 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 11508 | vars->mac_type = MAC_TYPE_NONE; |
| 11509 | vars->phy_flags = 0; |
| 11510 | |
| 11511 | /* disable attentions */ |
| 11512 | bnx2x_bits_dis(bp, NIG_REG_MASK_INTERRUPT_PORT0 + params->port*4, |
| 11513 | (NIG_MASK_XGXS0_LINK_STATUS | |
| 11514 | NIG_MASK_XGXS0_LINK10G | |
| 11515 | NIG_MASK_SERDES0_LINK_STATUS | |
| 11516 | NIG_MASK_MI_INT)); |
| 11517 | |
| 11518 | bnx2x_emac_init(params, vars); |
| 11519 | |
| 11520 | if (params->num_phys == 0) { |
| 11521 | DP(NETIF_MSG_LINK, "No phy found for initialization !!\n"); |
| 11522 | return -EINVAL; |
| 11523 | } |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 11524 | set_phy_vars(params, vars); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11525 | |
| 11526 | DP(NETIF_MSG_LINK, "Num of phys on board: %d\n", params->num_phys); |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 11527 | switch (params->loopback_mode) { |
| 11528 | case LOOPBACK_BMAC: |
| 11529 | bnx2x_init_bmac_loopback(params, vars); |
| 11530 | break; |
| 11531 | case LOOPBACK_EMAC: |
| 11532 | bnx2x_init_emac_loopback(params, vars); |
| 11533 | break; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 11534 | case LOOPBACK_XMAC: |
| 11535 | bnx2x_init_xmac_loopback(params, vars); |
| 11536 | break; |
| 11537 | case LOOPBACK_UMAC: |
| 11538 | bnx2x_init_umac_loopback(params, vars); |
| 11539 | break; |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 11540 | case LOOPBACK_XGXS: |
| 11541 | case LOOPBACK_EXT_PHY: |
| 11542 | bnx2x_init_xgxs_loopback(params, vars); |
| 11543 | break; |
| 11544 | default: |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 11545 | if (!CHIP_IS_E3(bp)) { |
| 11546 | if (params->switch_cfg == SWITCH_CFG_10G) |
| 11547 | bnx2x_xgxs_deassert(params); |
| 11548 | else |
| 11549 | bnx2x_serdes_deassert(bp, params->port); |
| 11550 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11551 | bnx2x_link_initialize(params, vars); |
| 11552 | msleep(30); |
| 11553 | bnx2x_link_int_enable(params); |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 11554 | break; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11555 | } |
| 11556 | return 0; |
| 11557 | } |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 11558 | |
| 11559 | int bnx2x_link_reset(struct link_params *params, struct link_vars *vars, |
| 11560 | u8 reset_ext_phy) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11561 | { |
| 11562 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | cf1d972 | 2010-11-01 05:32:34 +0000 | [diff] [blame] | 11563 | u8 phy_index, port = params->port, clear_latch_ind = 0; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11564 | DP(NETIF_MSG_LINK, "Resetting the link of port %d\n", port); |
| 11565 | /* disable attentions */ |
| 11566 | vars->link_status = 0; |
| 11567 | bnx2x_update_mng(params, vars->link_status); |
| 11568 | bnx2x_bits_dis(bp, NIG_REG_MASK_INTERRUPT_PORT0 + port*4, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11569 | (NIG_MASK_XGXS0_LINK_STATUS | |
| 11570 | NIG_MASK_XGXS0_LINK10G | |
| 11571 | NIG_MASK_SERDES0_LINK_STATUS | |
| 11572 | NIG_MASK_MI_INT)); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11573 | |
| 11574 | /* activate nig drain */ |
| 11575 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + port*4, 1); |
| 11576 | |
| 11577 | /* disable nig egress interface */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 11578 | if (!CHIP_IS_E3(bp)) { |
| 11579 | REG_WR(bp, NIG_REG_BMAC0_OUT_EN + port*4, 0); |
| 11580 | REG_WR(bp, NIG_REG_EGRESS_EMAC0_OUT_EN + port*4, 0); |
| 11581 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11582 | |
| 11583 | /* Stop BigMac rx */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 11584 | if (!CHIP_IS_E3(bp)) |
| 11585 | bnx2x_bmac_rx_disable(bp, port); |
| 11586 | else |
| 11587 | bnx2x_xmac_disable(params); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11588 | /* disable emac */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 11589 | if (!CHIP_IS_E3(bp)) |
| 11590 | REG_WR(bp, NIG_REG_NIG_EMAC0_EN + port*4, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11591 | |
| 11592 | msleep(10); |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 11593 | /* The PHY reset is controlled by GPIO 1 |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11594 | * Hold it as vars low |
| 11595 | */ |
| 11596 | /* clear link led */ |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 11597 | bnx2x_set_led(params, vars, LED_MODE_OFF, 0); |
| 11598 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11599 | if (reset_ext_phy) { |
| 11600 | for (phy_index = EXT_PHY1; phy_index < params->num_phys; |
| 11601 | phy_index++) { |
| 11602 | if (params->phy[phy_index].link_reset) |
| 11603 | params->phy[phy_index].link_reset( |
| 11604 | ¶ms->phy[phy_index], |
| 11605 | params); |
Yaniv Rosner | cf1d972 | 2010-11-01 05:32:34 +0000 | [diff] [blame] | 11606 | if (params->phy[phy_index].flags & |
| 11607 | FLAGS_REARM_LATCH_SIGNAL) |
| 11608 | clear_latch_ind = 1; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11609 | } |
| 11610 | } |
| 11611 | |
Yaniv Rosner | cf1d972 | 2010-11-01 05:32:34 +0000 | [diff] [blame] | 11612 | if (clear_latch_ind) { |
| 11613 | /* Clear latching indication */ |
| 11614 | bnx2x_rearm_latch_signal(bp, port, 0); |
| 11615 | bnx2x_bits_dis(bp, NIG_REG_LATCH_BC_0 + port*4, |
| 11616 | 1 << NIG_LATCH_BC_ENABLE_MI_INT); |
| 11617 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11618 | if (params->phy[INT_PHY].link_reset) |
| 11619 | params->phy[INT_PHY].link_reset( |
| 11620 | ¶ms->phy[INT_PHY], params); |
| 11621 | /* reset BigMac */ |
| 11622 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_CLEAR, |
| 11623 | (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << port)); |
| 11624 | |
| 11625 | /* disable nig ingress interface */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 11626 | if (!CHIP_IS_E3(bp)) { |
| 11627 | REG_WR(bp, NIG_REG_BMAC0_IN_EN + port*4, 0); |
| 11628 | REG_WR(bp, NIG_REG_EMAC0_IN_EN + port*4, 0); |
| 11629 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11630 | vars->link_up = 0; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 11631 | vars->phy_flags = 0; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11632 | return 0; |
| 11633 | } |
| 11634 | |
| 11635 | /****************************************************************************/ |
| 11636 | /* Common function */ |
| 11637 | /****************************************************************************/ |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 11638 | static int bnx2x_8073_common_init_phy(struct bnx2x *bp, |
| 11639 | u32 shmem_base_path[], |
| 11640 | u32 shmem2_base_path[], u8 phy_index, |
| 11641 | u32 chip_id) |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 11642 | { |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 11643 | struct bnx2x_phy phy[PORT_MAX]; |
| 11644 | struct bnx2x_phy *phy_blk[PORT_MAX]; |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 11645 | u16 val; |
Yaniv Rosner | c8e64df | 2011-01-30 04:15:00 +0000 | [diff] [blame] | 11646 | s8 port = 0; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 11647 | s8 port_of_path = 0; |
Yaniv Rosner | c8e64df | 2011-01-30 04:15:00 +0000 | [diff] [blame] | 11648 | u32 swap_val, swap_override; |
| 11649 | swap_val = REG_RD(bp, NIG_REG_PORT_SWAP); |
| 11650 | swap_override = REG_RD(bp, NIG_REG_STRAP_OVERRIDE); |
| 11651 | port ^= (swap_val && swap_override); |
| 11652 | bnx2x_ext_phy_hw_reset(bp, port); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 11653 | /* PART1 - Reset both phys */ |
| 11654 | for (port = PORT_MAX - 1; port >= PORT_0; port--) { |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 11655 | u32 shmem_base, shmem2_base; |
| 11656 | /* In E2, same phy is using for port0 of the two paths */ |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 11657 | if (CHIP_IS_E1x(bp)) { |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 11658 | shmem_base = shmem_base_path[0]; |
| 11659 | shmem2_base = shmem2_base_path[0]; |
| 11660 | port_of_path = port; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 11661 | } else { |
| 11662 | shmem_base = shmem_base_path[port]; |
| 11663 | shmem2_base = shmem2_base_path[port]; |
| 11664 | port_of_path = 0; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 11665 | } |
| 11666 | |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 11667 | /* Extract the ext phy address for the port */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11668 | if (bnx2x_populate_phy(bp, phy_index, shmem_base, shmem2_base, |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 11669 | port_of_path, &phy[port]) != |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 11670 | 0) { |
| 11671 | DP(NETIF_MSG_LINK, "populate_phy failed\n"); |
| 11672 | return -EINVAL; |
| 11673 | } |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 11674 | /* disable attentions */ |
Yaniv Rosner | 6a71bbe | 2010-11-01 05:32:31 +0000 | [diff] [blame] | 11675 | bnx2x_bits_dis(bp, NIG_REG_MASK_INTERRUPT_PORT0 + |
| 11676 | port_of_path*4, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11677 | (NIG_MASK_XGXS0_LINK_STATUS | |
| 11678 | NIG_MASK_XGXS0_LINK10G | |
| 11679 | NIG_MASK_SERDES0_LINK_STATUS | |
| 11680 | NIG_MASK_MI_INT)); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 11681 | |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 11682 | /* Need to take the phy out of low power mode in order |
| 11683 | to write to access its registers */ |
| 11684 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11685 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, |
| 11686 | port); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 11687 | |
| 11688 | /* Reset the phy */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 11689 | bnx2x_cl45_write(bp, &phy[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11690 | MDIO_PMA_DEVAD, |
| 11691 | MDIO_PMA_REG_CTRL, |
| 11692 | 1<<15); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 11693 | } |
| 11694 | |
| 11695 | /* Add delay of 150ms after reset */ |
| 11696 | msleep(150); |
| 11697 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 11698 | if (phy[PORT_0].addr & 0x1) { |
| 11699 | phy_blk[PORT_0] = &(phy[PORT_1]); |
| 11700 | phy_blk[PORT_1] = &(phy[PORT_0]); |
| 11701 | } else { |
| 11702 | phy_blk[PORT_0] = &(phy[PORT_0]); |
| 11703 | phy_blk[PORT_1] = &(phy[PORT_1]); |
| 11704 | } |
| 11705 | |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 11706 | /* PART2 - Download firmware to both phys */ |
| 11707 | for (port = PORT_MAX - 1; port >= PORT_0; port--) { |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 11708 | if (CHIP_IS_E1x(bp)) |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 11709 | port_of_path = port; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 11710 | else |
| 11711 | port_of_path = 0; |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 11712 | |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 11713 | DP(NETIF_MSG_LINK, "Loading spirom for phy address 0x%x\n", |
| 11714 | phy_blk[port]->addr); |
Yaniv Rosner | 5c99274b | 2011-01-18 04:33:36 +0000 | [diff] [blame] | 11715 | if (bnx2x_8073_8727_external_rom_boot(bp, phy_blk[port], |
| 11716 | port_of_path)) |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 11717 | return -EINVAL; |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 11718 | |
| 11719 | /* Only set bit 10 = 1 (Tx power down) */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 11720 | bnx2x_cl45_read(bp, phy_blk[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11721 | MDIO_PMA_DEVAD, |
| 11722 | MDIO_PMA_REG_TX_POWER_DOWN, &val); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 11723 | |
| 11724 | /* Phase1 of TX_POWER_DOWN reset */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 11725 | bnx2x_cl45_write(bp, phy_blk[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11726 | MDIO_PMA_DEVAD, |
| 11727 | MDIO_PMA_REG_TX_POWER_DOWN, |
| 11728 | (val | 1<<10)); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 11729 | } |
| 11730 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 11731 | /* |
| 11732 | * Toggle Transmitter: Power down and then up with 600ms delay |
| 11733 | * between |
| 11734 | */ |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 11735 | msleep(600); |
| 11736 | |
| 11737 | /* PART3 - complete TX_POWER_DOWN process, and set GPIO2 back to low */ |
| 11738 | for (port = PORT_MAX - 1; port >= PORT_0; port--) { |
Eilon Greenstein | f537225 | 2009-02-12 08:38:30 +0000 | [diff] [blame] | 11739 | /* Phase2 of POWER_DOWN_RESET */ |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 11740 | /* Release bit 10 (Release Tx power down) */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 11741 | bnx2x_cl45_read(bp, phy_blk[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11742 | MDIO_PMA_DEVAD, |
| 11743 | MDIO_PMA_REG_TX_POWER_DOWN, &val); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 11744 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 11745 | bnx2x_cl45_write(bp, phy_blk[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11746 | MDIO_PMA_DEVAD, |
| 11747 | MDIO_PMA_REG_TX_POWER_DOWN, (val & (~(1<<10)))); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 11748 | msleep(15); |
| 11749 | |
| 11750 | /* Read modify write the SPI-ROM version select register */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 11751 | bnx2x_cl45_read(bp, phy_blk[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11752 | MDIO_PMA_DEVAD, |
| 11753 | MDIO_PMA_REG_EDC_FFE_MAIN, &val); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 11754 | bnx2x_cl45_write(bp, phy_blk[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11755 | MDIO_PMA_DEVAD, |
| 11756 | MDIO_PMA_REG_EDC_FFE_MAIN, (val | (1<<12))); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 11757 | |
| 11758 | /* set GPIO2 back to LOW */ |
| 11759 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11760 | MISC_REGISTERS_GPIO_OUTPUT_LOW, port); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 11761 | } |
| 11762 | return 0; |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 11763 | } |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 11764 | static int bnx2x_8726_common_init_phy(struct bnx2x *bp, |
| 11765 | u32 shmem_base_path[], |
| 11766 | u32 shmem2_base_path[], u8 phy_index, |
| 11767 | u32 chip_id) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11768 | { |
| 11769 | u32 val; |
| 11770 | s8 port; |
| 11771 | struct bnx2x_phy phy; |
| 11772 | /* Use port1 because of the static port-swap */ |
| 11773 | /* Enable the module detection interrupt */ |
| 11774 | val = REG_RD(bp, MISC_REG_GPIO_EVENT_EN); |
| 11775 | val |= ((1<<MISC_REGISTERS_GPIO_3)| |
| 11776 | (1<<(MISC_REGISTERS_GPIO_3 + MISC_REGISTERS_GPIO_PORT_SHIFT))); |
| 11777 | REG_WR(bp, MISC_REG_GPIO_EVENT_EN, val); |
| 11778 | |
Yaniv Rosner | 650154b | 2010-11-01 05:32:36 +0000 | [diff] [blame] | 11779 | bnx2x_ext_phy_hw_reset(bp, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11780 | msleep(5); |
| 11781 | for (port = 0; port < PORT_MAX; port++) { |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 11782 | u32 shmem_base, shmem2_base; |
| 11783 | |
| 11784 | /* In E2, same phy is using for port0 of the two paths */ |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 11785 | if (CHIP_IS_E1x(bp)) { |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 11786 | shmem_base = shmem_base_path[0]; |
| 11787 | shmem2_base = shmem2_base_path[0]; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 11788 | } else { |
| 11789 | shmem_base = shmem_base_path[port]; |
| 11790 | shmem2_base = shmem2_base_path[port]; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 11791 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11792 | /* Extract the ext phy address for the port */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11793 | if (bnx2x_populate_phy(bp, phy_index, shmem_base, shmem2_base, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11794 | port, &phy) != |
| 11795 | 0) { |
| 11796 | DP(NETIF_MSG_LINK, "populate phy failed\n"); |
| 11797 | return -EINVAL; |
| 11798 | } |
| 11799 | |
| 11800 | /* Reset phy*/ |
| 11801 | bnx2x_cl45_write(bp, &phy, |
| 11802 | MDIO_PMA_DEVAD, MDIO_PMA_REG_GEN_CTRL, 0x0001); |
| 11803 | |
| 11804 | |
| 11805 | /* Set fault module detected LED on */ |
| 11806 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_0, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11807 | MISC_REGISTERS_GPIO_HIGH, |
| 11808 | port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11809 | } |
| 11810 | |
| 11811 | return 0; |
| 11812 | } |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 11813 | static void bnx2x_get_ext_phy_reset_gpio(struct bnx2x *bp, u32 shmem_base, |
| 11814 | u8 *io_gpio, u8 *io_port) |
| 11815 | { |
| 11816 | |
| 11817 | u32 phy_gpio_reset = REG_RD(bp, shmem_base + |
| 11818 | offsetof(struct shmem_region, |
| 11819 | dev_info.port_hw_config[PORT_0].default_cfg)); |
| 11820 | switch (phy_gpio_reset) { |
| 11821 | case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO0_P0: |
| 11822 | *io_gpio = 0; |
| 11823 | *io_port = 0; |
| 11824 | break; |
| 11825 | case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO1_P0: |
| 11826 | *io_gpio = 1; |
| 11827 | *io_port = 0; |
| 11828 | break; |
| 11829 | case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO2_P0: |
| 11830 | *io_gpio = 2; |
| 11831 | *io_port = 0; |
| 11832 | break; |
| 11833 | case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO3_P0: |
| 11834 | *io_gpio = 3; |
| 11835 | *io_port = 0; |
| 11836 | break; |
| 11837 | case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO0_P1: |
| 11838 | *io_gpio = 0; |
| 11839 | *io_port = 1; |
| 11840 | break; |
| 11841 | case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO1_P1: |
| 11842 | *io_gpio = 1; |
| 11843 | *io_port = 1; |
| 11844 | break; |
| 11845 | case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO2_P1: |
| 11846 | *io_gpio = 2; |
| 11847 | *io_port = 1; |
| 11848 | break; |
| 11849 | case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO3_P1: |
| 11850 | *io_gpio = 3; |
| 11851 | *io_port = 1; |
| 11852 | break; |
| 11853 | default: |
| 11854 | /* Don't override the io_gpio and io_port */ |
| 11855 | break; |
| 11856 | } |
| 11857 | } |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 11858 | |
| 11859 | static int bnx2x_8727_common_init_phy(struct bnx2x *bp, |
| 11860 | u32 shmem_base_path[], |
| 11861 | u32 shmem2_base_path[], u8 phy_index, |
| 11862 | u32 chip_id) |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 11863 | { |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 11864 | s8 port, reset_gpio; |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 11865 | u32 swap_val, swap_override; |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 11866 | struct bnx2x_phy phy[PORT_MAX]; |
| 11867 | struct bnx2x_phy *phy_blk[PORT_MAX]; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 11868 | s8 port_of_path; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11869 | swap_val = REG_RD(bp, NIG_REG_PORT_SWAP); |
| 11870 | swap_override = REG_RD(bp, NIG_REG_STRAP_OVERRIDE); |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 11871 | |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 11872 | reset_gpio = MISC_REGISTERS_GPIO_1; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11873 | port = 1; |
| 11874 | |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 11875 | /* |
| 11876 | * Retrieve the reset gpio/port which control the reset. |
| 11877 | * Default is GPIO1, PORT1 |
| 11878 | */ |
| 11879 | bnx2x_get_ext_phy_reset_gpio(bp, shmem_base_path[0], |
| 11880 | (u8 *)&reset_gpio, (u8 *)&port); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11881 | |
| 11882 | /* Calculate the port based on port swap */ |
| 11883 | port ^= (swap_val && swap_override); |
| 11884 | |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 11885 | /* Initiate PHY reset*/ |
| 11886 | bnx2x_set_gpio(bp, reset_gpio, MISC_REGISTERS_GPIO_OUTPUT_LOW, |
| 11887 | port); |
| 11888 | msleep(1); |
| 11889 | bnx2x_set_gpio(bp, reset_gpio, MISC_REGISTERS_GPIO_OUTPUT_HIGH, |
| 11890 | port); |
| 11891 | |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 11892 | msleep(5); |
| 11893 | |
| 11894 | /* PART1 - Reset both phys */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11895 | for (port = PORT_MAX - 1; port >= PORT_0; port--) { |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 11896 | u32 shmem_base, shmem2_base; |
| 11897 | |
| 11898 | /* In E2, same phy is using for port0 of the two paths */ |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 11899 | if (CHIP_IS_E1x(bp)) { |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 11900 | shmem_base = shmem_base_path[0]; |
| 11901 | shmem2_base = shmem2_base_path[0]; |
| 11902 | port_of_path = port; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 11903 | } else { |
| 11904 | shmem_base = shmem_base_path[port]; |
| 11905 | shmem2_base = shmem2_base_path[port]; |
| 11906 | port_of_path = 0; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 11907 | } |
| 11908 | |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 11909 | /* Extract the ext phy address for the port */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11910 | if (bnx2x_populate_phy(bp, phy_index, shmem_base, shmem2_base, |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 11911 | port_of_path, &phy[port]) != |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 11912 | 0) { |
| 11913 | DP(NETIF_MSG_LINK, "populate phy failed\n"); |
| 11914 | return -EINVAL; |
| 11915 | } |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 11916 | /* disable attentions */ |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 11917 | bnx2x_bits_dis(bp, NIG_REG_MASK_INTERRUPT_PORT0 + |
| 11918 | port_of_path*4, |
| 11919 | (NIG_MASK_XGXS0_LINK_STATUS | |
| 11920 | NIG_MASK_XGXS0_LINK10G | |
| 11921 | NIG_MASK_SERDES0_LINK_STATUS | |
| 11922 | NIG_MASK_MI_INT)); |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 11923 | |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 11924 | |
| 11925 | /* Reset the phy */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 11926 | bnx2x_cl45_write(bp, &phy[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11927 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 1<<15); |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 11928 | } |
| 11929 | |
| 11930 | /* Add delay of 150ms after reset */ |
| 11931 | msleep(150); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 11932 | if (phy[PORT_0].addr & 0x1) { |
| 11933 | phy_blk[PORT_0] = &(phy[PORT_1]); |
| 11934 | phy_blk[PORT_1] = &(phy[PORT_0]); |
| 11935 | } else { |
| 11936 | phy_blk[PORT_0] = &(phy[PORT_0]); |
| 11937 | phy_blk[PORT_1] = &(phy[PORT_1]); |
| 11938 | } |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 11939 | /* PART2 - Download firmware to both phys */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 11940 | for (port = PORT_MAX - 1; port >= PORT_0; port--) { |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 11941 | if (CHIP_IS_E1x(bp)) |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 11942 | port_of_path = port; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 11943 | else |
| 11944 | port_of_path = 0; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 11945 | DP(NETIF_MSG_LINK, "Loading spirom for phy address 0x%x\n", |
| 11946 | phy_blk[port]->addr); |
Yaniv Rosner | 5c99274b | 2011-01-18 04:33:36 +0000 | [diff] [blame] | 11947 | if (bnx2x_8073_8727_external_rom_boot(bp, phy_blk[port], |
| 11948 | port_of_path)) |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 11949 | return -EINVAL; |
Yaniv Rosner | 85242ee | 2011-07-05 01:06:53 +0000 | [diff] [blame] | 11950 | /* Disable PHY transmitter output */ |
| 11951 | bnx2x_cl45_write(bp, phy_blk[port], |
| 11952 | MDIO_PMA_DEVAD, |
| 11953 | MDIO_PMA_REG_TX_DISABLE, 1); |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 11954 | |
Yaniv Rosner | 5c99274b | 2011-01-18 04:33:36 +0000 | [diff] [blame] | 11955 | } |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 11956 | return 0; |
| 11957 | } |
| 11958 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 11959 | static int bnx2x_ext_phy_common_init(struct bnx2x *bp, u32 shmem_base_path[], |
| 11960 | u32 shmem2_base_path[], u8 phy_index, |
| 11961 | u32 ext_phy_type, u32 chip_id) |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 11962 | { |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 11963 | int rc = 0; |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 11964 | |
| 11965 | switch (ext_phy_type) { |
| 11966 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073: |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 11967 | rc = bnx2x_8073_common_init_phy(bp, shmem_base_path, |
| 11968 | shmem2_base_path, |
| 11969 | phy_index, chip_id); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 11970 | break; |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 11971 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8722: |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 11972 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727: |
| 11973 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727_NOC: |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 11974 | rc = bnx2x_8727_common_init_phy(bp, shmem_base_path, |
| 11975 | shmem2_base_path, |
| 11976 | phy_index, chip_id); |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 11977 | break; |
| 11978 | |
Eilon Greenstein | 589abe3 | 2009-02-12 08:36:55 +0000 | [diff] [blame] | 11979 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726: |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 11980 | /* |
| 11981 | * GPIO1 affects both ports, so there's need to pull |
| 11982 | * it for single port alone |
| 11983 | */ |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 11984 | rc = bnx2x_8726_common_init_phy(bp, shmem_base_path, |
| 11985 | shmem2_base_path, |
| 11986 | phy_index, chip_id); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11987 | break; |
Yaniv Rosner | 0d40f0d | 2011-06-14 01:34:27 +0000 | [diff] [blame] | 11988 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833: |
| 11989 | /* |
| 11990 | * GPIO3's are linked, and so both need to be toggled |
| 11991 | * to obtain required 2us pulse. |
| 11992 | */ |
| 11993 | rc = bnx2x_84833_common_init_phy(bp, shmem_base_path, chip_id); |
| 11994 | break; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11995 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_FAILURE: |
| 11996 | rc = -EINVAL; |
Yaniv Rosner | 4f60dab | 2009-11-05 19:18:23 +0200 | [diff] [blame] | 11997 | break; |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 11998 | default: |
| 11999 | DP(NETIF_MSG_LINK, |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 12000 | "ext_phy 0x%x common init not required\n", |
| 12001 | ext_phy_type); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12002 | break; |
| 12003 | } |
| 12004 | |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 12005 | if (rc != 0) |
| 12006 | netdev_err(bp->dev, "Warning: PHY was not initialized," |
| 12007 | " Port %d\n", |
| 12008 | 0); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12009 | return rc; |
| 12010 | } |
| 12011 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 12012 | int bnx2x_common_init_phy(struct bnx2x *bp, u32 shmem_base_path[], |
| 12013 | u32 shmem2_base_path[], u32 chip_id) |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12014 | { |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 12015 | int rc = 0; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 12016 | u32 phy_ver, val; |
| 12017 | u8 phy_index = 0; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12018 | u32 ext_phy_type, ext_phy_config; |
Yaniv Rosner | a198c14 | 2011-05-31 21:29:42 +0000 | [diff] [blame] | 12019 | bnx2x_set_mdio_clk(bp, chip_id, PORT_0); |
| 12020 | bnx2x_set_mdio_clk(bp, chip_id, PORT_1); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12021 | DP(NETIF_MSG_LINK, "Begin common phy init\n"); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 12022 | if (CHIP_IS_E3(bp)) { |
| 12023 | /* Enable EPIO */ |
| 12024 | val = REG_RD(bp, MISC_REG_GEN_PURP_HWG); |
| 12025 | REG_WR(bp, MISC_REG_GEN_PURP_HWG, val | 1); |
| 12026 | } |
Yaniv Rosner | b21a342 | 2011-01-18 04:33:24 +0000 | [diff] [blame] | 12027 | /* Check if common init was already done */ |
| 12028 | phy_ver = REG_RD(bp, shmem_base_path[0] + |
| 12029 | offsetof(struct shmem_region, |
| 12030 | port_mb[PORT_0].ext_phy_fw_version)); |
| 12031 | if (phy_ver) { |
| 12032 | DP(NETIF_MSG_LINK, "Not doing common init; phy ver is 0x%x\n", |
| 12033 | phy_ver); |
| 12034 | return 0; |
| 12035 | } |
| 12036 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12037 | /* Read the ext_phy_type for arbitrary port(0) */ |
| 12038 | for (phy_index = EXT_PHY1; phy_index < MAX_PHYS; |
| 12039 | phy_index++) { |
| 12040 | ext_phy_config = bnx2x_get_ext_phy_config(bp, |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12041 | shmem_base_path[0], |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12042 | phy_index, 0); |
| 12043 | ext_phy_type = XGXS_EXT_PHY_TYPE(ext_phy_config); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12044 | rc |= bnx2x_ext_phy_common_init(bp, shmem_base_path, |
| 12045 | shmem2_base_path, |
| 12046 | phy_index, ext_phy_type, |
| 12047 | chip_id); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12048 | } |
| 12049 | return rc; |
| 12050 | } |
| 12051 | |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 12052 | static void bnx2x_check_over_curr(struct link_params *params, |
| 12053 | struct link_vars *vars) |
| 12054 | { |
| 12055 | struct bnx2x *bp = params->bp; |
| 12056 | u32 cfg_pin; |
| 12057 | u8 port = params->port; |
| 12058 | u32 pin_val; |
| 12059 | |
| 12060 | cfg_pin = (REG_RD(bp, params->shmem_base + |
| 12061 | offsetof(struct shmem_region, |
| 12062 | dev_info.port_hw_config[port].e3_cmn_pin_cfg1)) & |
| 12063 | PORT_HW_CFG_E3_OVER_CURRENT_MASK) >> |
| 12064 | PORT_HW_CFG_E3_OVER_CURRENT_SHIFT; |
| 12065 | |
| 12066 | /* Ignore check if no external input PIN available */ |
| 12067 | if (bnx2x_get_cfg_pin(bp, cfg_pin, &pin_val) != 0) |
| 12068 | return; |
| 12069 | |
| 12070 | if (!pin_val) { |
| 12071 | if ((vars->phy_flags & PHY_OVER_CURRENT_FLAG) == 0) { |
| 12072 | netdev_err(bp->dev, "Error: Power fault on Port %d has" |
| 12073 | " been detected and the power to " |
| 12074 | "that SFP+ module has been removed" |
| 12075 | " to prevent failure of the card." |
| 12076 | " Please remove the SFP+ module and" |
| 12077 | " restart the system to clear this" |
| 12078 | " error.\n", |
| 12079 | params->port); |
| 12080 | vars->phy_flags |= PHY_OVER_CURRENT_FLAG; |
| 12081 | } |
| 12082 | } else |
| 12083 | vars->phy_flags &= ~PHY_OVER_CURRENT_FLAG; |
| 12084 | } |
| 12085 | |
| 12086 | static void bnx2x_analyze_link_error(struct link_params *params, |
| 12087 | struct link_vars *vars, u32 lss_status) |
| 12088 | { |
| 12089 | struct bnx2x *bp = params->bp; |
| 12090 | /* Compare new value with previous value */ |
| 12091 | u8 led_mode; |
| 12092 | u32 half_open_conn = (vars->phy_flags & PHY_HALF_OPEN_CONN_FLAG) > 0; |
| 12093 | |
| 12094 | /*DP(NETIF_MSG_LINK, "CHECK LINK: %x half_open:%x-> lss:%x\n", |
| 12095 | vars->link_up, |
| 12096 | half_open_conn, lss_status);*/ |
| 12097 | |
| 12098 | if ((lss_status ^ half_open_conn) == 0) |
| 12099 | return; |
| 12100 | |
| 12101 | /* If values differ */ |
| 12102 | DP(NETIF_MSG_LINK, "Link changed:%x %x->%x\n", vars->link_up, |
| 12103 | half_open_conn, lss_status); |
| 12104 | |
| 12105 | /* |
| 12106 | * a. Update shmem->link_status accordingly |
| 12107 | * b. Update link_vars->link_up |
| 12108 | */ |
| 12109 | if (lss_status) { |
| 12110 | vars->link_status &= ~LINK_STATUS_LINK_UP; |
| 12111 | vars->link_up = 0; |
| 12112 | vars->phy_flags |= PHY_HALF_OPEN_CONN_FLAG; |
| 12113 | /* |
| 12114 | * Set LED mode to off since the PHY doesn't know about these |
| 12115 | * errors |
| 12116 | */ |
| 12117 | led_mode = LED_MODE_OFF; |
| 12118 | } else { |
| 12119 | vars->link_status |= LINK_STATUS_LINK_UP; |
| 12120 | vars->link_up = 1; |
| 12121 | vars->phy_flags &= ~PHY_HALF_OPEN_CONN_FLAG; |
| 12122 | led_mode = LED_MODE_OPER; |
| 12123 | } |
| 12124 | /* Update the LED according to the link state */ |
| 12125 | bnx2x_set_led(params, vars, led_mode, SPEED_10000); |
| 12126 | |
| 12127 | /* Update link status in the shared memory */ |
| 12128 | bnx2x_update_mng(params, vars->link_status); |
| 12129 | |
| 12130 | /* C. Trigger General Attention */ |
| 12131 | vars->periodic_flags |= PERIODIC_FLAGS_LINK_EVENT; |
| 12132 | bnx2x_notify_link_changed(bp); |
| 12133 | } |
| 12134 | |
| 12135 | static void bnx2x_check_half_open_conn(struct link_params *params, |
| 12136 | struct link_vars *vars) |
| 12137 | { |
| 12138 | struct bnx2x *bp = params->bp; |
| 12139 | u32 lss_status = 0; |
| 12140 | u32 mac_base; |
| 12141 | /* In case link status is physically up @ 10G do */ |
| 12142 | if ((vars->phy_flags & PHY_PHYSICAL_LINK_FLAG) == 0) |
| 12143 | return; |
| 12144 | |
| 12145 | if (!CHIP_IS_E3(bp) && |
| 12146 | (REG_RD(bp, MISC_REG_RESET_REG_2) & |
| 12147 | (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << params->port))) { |
| 12148 | /* Check E1X / E2 BMAC */ |
| 12149 | u32 lss_status_reg; |
| 12150 | u32 wb_data[2]; |
| 12151 | mac_base = params->port ? NIG_REG_INGRESS_BMAC1_MEM : |
| 12152 | NIG_REG_INGRESS_BMAC0_MEM; |
| 12153 | /* Read BIGMAC_REGISTER_RX_LSS_STATUS */ |
| 12154 | if (CHIP_IS_E2(bp)) |
| 12155 | lss_status_reg = BIGMAC2_REGISTER_RX_LSS_STAT; |
| 12156 | else |
| 12157 | lss_status_reg = BIGMAC_REGISTER_RX_LSS_STATUS; |
| 12158 | |
| 12159 | REG_RD_DMAE(bp, mac_base + lss_status_reg, wb_data, 2); |
| 12160 | lss_status = (wb_data[0] > 0); |
| 12161 | |
| 12162 | bnx2x_analyze_link_error(params, vars, lss_status); |
| 12163 | } |
| 12164 | } |
| 12165 | |
| 12166 | void bnx2x_period_func(struct link_params *params, struct link_vars *vars) |
| 12167 | { |
| 12168 | struct bnx2x *bp = params->bp; |
| 12169 | if (!params) { |
| 12170 | DP(NETIF_MSG_LINK, "Ininitliazed params !\n"); |
| 12171 | return; |
| 12172 | } |
| 12173 | /* DP(NETIF_MSG_LINK, "Periodic called vars->phy_flags 0x%x speed 0x%x |
| 12174 | RESET_REG_2 0x%x\n", vars->phy_flags, vars->line_speed, |
| 12175 | REG_RD(bp, MISC_REG_RESET_REG_2)); */ |
| 12176 | bnx2x_check_half_open_conn(params, vars); |
| 12177 | if (CHIP_IS_E3(bp)) |
| 12178 | bnx2x_check_over_curr(params, vars); |
| 12179 | } |
| 12180 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12181 | u8 bnx2x_hw_lock_required(struct bnx2x *bp, u32 shmem_base, u32 shmem2_base) |
Yaniv Rosner | d90d96b | 2010-09-07 11:41:04 +0000 | [diff] [blame] | 12182 | { |
| 12183 | u8 phy_index; |
| 12184 | struct bnx2x_phy phy; |
| 12185 | for (phy_index = INT_PHY; phy_index < MAX_PHYS; |
| 12186 | phy_index++) { |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12187 | if (bnx2x_populate_phy(bp, phy_index, shmem_base, shmem2_base, |
Yaniv Rosner | d90d96b | 2010-09-07 11:41:04 +0000 | [diff] [blame] | 12188 | 0, &phy) != 0) { |
| 12189 | DP(NETIF_MSG_LINK, "populate phy failed\n"); |
| 12190 | return 0; |
| 12191 | } |
| 12192 | |
| 12193 | if (phy.flags & FLAGS_HW_LOCK_REQUIRED) |
| 12194 | return 1; |
| 12195 | } |
| 12196 | return 0; |
| 12197 | } |
| 12198 | |
| 12199 | u8 bnx2x_fan_failure_det_req(struct bnx2x *bp, |
| 12200 | u32 shmem_base, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12201 | u32 shmem2_base, |
Yaniv Rosner | d90d96b | 2010-09-07 11:41:04 +0000 | [diff] [blame] | 12202 | u8 port) |
| 12203 | { |
| 12204 | u8 phy_index, fan_failure_det_req = 0; |
| 12205 | struct bnx2x_phy phy; |
| 12206 | for (phy_index = EXT_PHY1; phy_index < MAX_PHYS; |
| 12207 | phy_index++) { |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12208 | if (bnx2x_populate_phy(bp, phy_index, shmem_base, shmem2_base, |
Yaniv Rosner | d90d96b | 2010-09-07 11:41:04 +0000 | [diff] [blame] | 12209 | port, &phy) |
| 12210 | != 0) { |
| 12211 | DP(NETIF_MSG_LINK, "populate phy failed\n"); |
| 12212 | return 0; |
| 12213 | } |
| 12214 | fan_failure_det_req |= (phy.flags & |
| 12215 | FLAGS_FAN_FAILURE_DET_REQ); |
| 12216 | } |
| 12217 | return fan_failure_det_req; |
| 12218 | } |
| 12219 | |
| 12220 | void bnx2x_hw_reset_phy(struct link_params *params) |
| 12221 | { |
| 12222 | u8 phy_index; |
Yaniv Rosner | 985848f | 2011-07-05 01:06:48 +0000 | [diff] [blame] | 12223 | struct bnx2x *bp = params->bp; |
| 12224 | bnx2x_update_mng(params, 0); |
| 12225 | bnx2x_bits_dis(bp, NIG_REG_MASK_INTERRUPT_PORT0 + params->port*4, |
| 12226 | (NIG_MASK_XGXS0_LINK_STATUS | |
| 12227 | NIG_MASK_XGXS0_LINK10G | |
| 12228 | NIG_MASK_SERDES0_LINK_STATUS | |
| 12229 | NIG_MASK_MI_INT)); |
| 12230 | |
| 12231 | for (phy_index = INT_PHY; phy_index < MAX_PHYS; |
Yaniv Rosner | d90d96b | 2010-09-07 11:41:04 +0000 | [diff] [blame] | 12232 | phy_index++) { |
| 12233 | if (params->phy[phy_index].hw_reset) { |
| 12234 | params->phy[phy_index].hw_reset( |
| 12235 | ¶ms->phy[phy_index], |
| 12236 | params); |
| 12237 | params->phy[phy_index] = phy_null; |
| 12238 | } |
| 12239 | } |
| 12240 | } |
Yaniv Rosner | 020c7e3 | 2011-05-31 21:28:43 +0000 | [diff] [blame] | 12241 | |
| 12242 | void bnx2x_init_mod_abs_int(struct bnx2x *bp, struct link_vars *vars, |
| 12243 | u32 chip_id, u32 shmem_base, u32 shmem2_base, |
| 12244 | u8 port) |
| 12245 | { |
| 12246 | u8 gpio_num = 0xff, gpio_port = 0xff, phy_index; |
| 12247 | u32 val; |
| 12248 | u32 offset, aeu_mask, swap_val, swap_override, sync_offset; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 12249 | if (CHIP_IS_E3(bp)) { |
| 12250 | if (bnx2x_get_mod_abs_int_cfg(bp, chip_id, |
| 12251 | shmem_base, |
| 12252 | port, |
| 12253 | &gpio_num, |
| 12254 | &gpio_port) != 0) |
| 12255 | return; |
| 12256 | } else { |
Yaniv Rosner | 020c7e3 | 2011-05-31 21:28:43 +0000 | [diff] [blame] | 12257 | struct bnx2x_phy phy; |
| 12258 | for (phy_index = EXT_PHY1; phy_index < MAX_PHYS; |
| 12259 | phy_index++) { |
| 12260 | if (bnx2x_populate_phy(bp, phy_index, shmem_base, |
| 12261 | shmem2_base, port, &phy) |
| 12262 | != 0) { |
| 12263 | DP(NETIF_MSG_LINK, "populate phy failed\n"); |
| 12264 | return; |
| 12265 | } |
| 12266 | if (phy.type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726) { |
| 12267 | gpio_num = MISC_REGISTERS_GPIO_3; |
| 12268 | gpio_port = port; |
| 12269 | break; |
| 12270 | } |
| 12271 | } |
| 12272 | } |
| 12273 | |
| 12274 | if (gpio_num == 0xff) |
| 12275 | return; |
| 12276 | |
| 12277 | /* Set GPIO3 to trigger SFP+ module insertion/removal */ |
| 12278 | bnx2x_set_gpio(bp, gpio_num, MISC_REGISTERS_GPIO_INPUT_HI_Z, gpio_port); |
| 12279 | |
| 12280 | swap_val = REG_RD(bp, NIG_REG_PORT_SWAP); |
| 12281 | swap_override = REG_RD(bp, NIG_REG_STRAP_OVERRIDE); |
| 12282 | gpio_port ^= (swap_val && swap_override); |
| 12283 | |
| 12284 | vars->aeu_int_mask = AEU_INPUTS_ATTN_BITS_GPIO0_FUNCTION_0 << |
| 12285 | (gpio_num + (gpio_port << 2)); |
| 12286 | |
| 12287 | sync_offset = shmem_base + |
| 12288 | offsetof(struct shmem_region, |
| 12289 | dev_info.port_hw_config[port].aeu_int_mask); |
| 12290 | REG_WR(bp, sync_offset, vars->aeu_int_mask); |
| 12291 | |
| 12292 | DP(NETIF_MSG_LINK, "Setting MOD_ABS (GPIO%d_P%d) AEU to 0x%x\n", |
| 12293 | gpio_num, gpio_port, vars->aeu_int_mask); |
| 12294 | |
| 12295 | if (port == 0) |
| 12296 | offset = MISC_REG_AEU_ENABLE1_FUNC_0_OUT_0; |
| 12297 | else |
| 12298 | offset = MISC_REG_AEU_ENABLE1_FUNC_1_OUT_0; |
| 12299 | |
| 12300 | /* Open appropriate AEU for interrupts */ |
| 12301 | aeu_mask = REG_RD(bp, offset); |
| 12302 | aeu_mask |= vars->aeu_int_mask; |
| 12303 | REG_WR(bp, offset, aeu_mask); |
| 12304 | |
| 12305 | /* Enable the GPIO to trigger interrupt */ |
| 12306 | val = REG_RD(bp, MISC_REG_GPIO_EVENT_EN); |
| 12307 | val |= 1 << (gpio_num + (gpio_port << 2)); |
| 12308 | REG_WR(bp, MISC_REG_GPIO_EVENT_EN, val); |
| 12309 | } |