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 | |
Yaniv Rosner | 26ffaf3 | 2011-10-27 05:09:45 +0000 | [diff] [blame] | 48 | /* LED Blink rate that will achieve ~15.9Hz */ |
| 49 | #define LED_BLINK_RATE_VAL_E3 354 |
| 50 | #define LED_BLINK_RATE_VAL_E1X_E2 480 |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 51 | /***********************************************************/ |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 52 | /* Shortcut definitions */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 53 | /***********************************************************/ |
| 54 | |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 55 | #define NIG_LATCH_BC_ENABLE_MI_INT 0 |
| 56 | |
| 57 | #define NIG_STATUS_EMAC0_MI_INT \ |
| 58 | NIG_STATUS_INTERRUPT_PORT0_REG_STATUS_EMAC0_MISC_MI_INT |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 59 | #define NIG_STATUS_XGXS0_LINK10G \ |
| 60 | NIG_STATUS_INTERRUPT_PORT0_REG_STATUS_XGXS0_LINK10G |
| 61 | #define NIG_STATUS_XGXS0_LINK_STATUS \ |
| 62 | NIG_STATUS_INTERRUPT_PORT0_REG_STATUS_XGXS0_LINK_STATUS |
| 63 | #define NIG_STATUS_XGXS0_LINK_STATUS_SIZE \ |
| 64 | NIG_STATUS_INTERRUPT_PORT0_REG_STATUS_XGXS0_LINK_STATUS_SIZE |
| 65 | #define NIG_STATUS_SERDES0_LINK_STATUS \ |
| 66 | NIG_STATUS_INTERRUPT_PORT0_REG_STATUS_SERDES0_LINK_STATUS |
| 67 | #define NIG_MASK_MI_INT \ |
| 68 | NIG_MASK_INTERRUPT_PORT0_REG_MASK_EMAC0_MISC_MI_INT |
| 69 | #define NIG_MASK_XGXS0_LINK10G \ |
| 70 | NIG_MASK_INTERRUPT_PORT0_REG_MASK_XGXS0_LINK10G |
| 71 | #define NIG_MASK_XGXS0_LINK_STATUS \ |
| 72 | NIG_MASK_INTERRUPT_PORT0_REG_MASK_XGXS0_LINK_STATUS |
| 73 | #define NIG_MASK_SERDES0_LINK_STATUS \ |
| 74 | NIG_MASK_INTERRUPT_PORT0_REG_MASK_SERDES0_LINK_STATUS |
| 75 | |
| 76 | #define MDIO_AN_CL73_OR_37_COMPLETE \ |
| 77 | (MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_AUTONEG_COMPLETE | \ |
| 78 | MDIO_GP_STATUS_TOP_AN_STATUS1_CL37_AUTONEG_COMPLETE) |
| 79 | |
| 80 | #define XGXS_RESET_BITS \ |
| 81 | (MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_XGXS0_RSTB_HW | \ |
| 82 | MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_XGXS0_IDDQ | \ |
| 83 | MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_XGXS0_PWRDWN | \ |
| 84 | MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_XGXS0_PWRDWN_SD | \ |
| 85 | MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_XGXS0_TXD_FIFO_RSTB) |
| 86 | |
| 87 | #define SERDES_RESET_BITS \ |
| 88 | (MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_SERDES0_RSTB_HW | \ |
| 89 | MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_SERDES0_IDDQ | \ |
| 90 | MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_SERDES0_PWRDWN | \ |
| 91 | MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_SERDES0_PWRDWN_SD) |
| 92 | |
| 93 | #define AUTONEG_CL37 SHARED_HW_CFG_AN_ENABLE_CL37 |
| 94 | #define AUTONEG_CL73 SHARED_HW_CFG_AN_ENABLE_CL73 |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 95 | #define AUTONEG_BAM SHARED_HW_CFG_AN_ENABLE_BAM |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 96 | #define AUTONEG_PARALLEL \ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 97 | SHARED_HW_CFG_AN_ENABLE_PARALLEL_DETECTION |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 98 | #define AUTONEG_SGMII_FIBER_AUTODET \ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 99 | SHARED_HW_CFG_AN_EN_SGMII_FIBER_AUTO_DETECT |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 100 | #define AUTONEG_REMOTE_PHY SHARED_HW_CFG_AN_ENABLE_REMOTE_PHY |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 101 | |
| 102 | #define GP_STATUS_PAUSE_RSOLUTION_TXSIDE \ |
| 103 | MDIO_GP_STATUS_TOP_AN_STATUS1_PAUSE_RSOLUTION_TXSIDE |
| 104 | #define GP_STATUS_PAUSE_RSOLUTION_RXSIDE \ |
| 105 | MDIO_GP_STATUS_TOP_AN_STATUS1_PAUSE_RSOLUTION_RXSIDE |
| 106 | #define GP_STATUS_SPEED_MASK \ |
| 107 | MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_MASK |
| 108 | #define GP_STATUS_10M MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_10M |
| 109 | #define GP_STATUS_100M MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_100M |
| 110 | #define GP_STATUS_1G MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_1G |
| 111 | #define GP_STATUS_2_5G MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_2_5G |
| 112 | #define GP_STATUS_5G MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_5G |
| 113 | #define GP_STATUS_6G MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_6G |
| 114 | #define GP_STATUS_10G_HIG \ |
| 115 | MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_10G_HIG |
| 116 | #define GP_STATUS_10G_CX4 \ |
| 117 | MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_10G_CX4 |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 118 | #define GP_STATUS_1G_KX MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_1G_KX |
| 119 | #define GP_STATUS_10G_KX4 \ |
| 120 | MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_10G_KX4 |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 121 | #define GP_STATUS_10G_KR MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_10G_KR |
| 122 | #define GP_STATUS_10G_XFI MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_10G_XFI |
| 123 | #define GP_STATUS_20G_DXGXS MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_20G_DXGXS |
| 124 | #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] | 125 | #define LINK_10THD LINK_STATUS_SPEED_AND_DUPLEX_10THD |
| 126 | #define LINK_10TFD LINK_STATUS_SPEED_AND_DUPLEX_10TFD |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 127 | #define LINK_100TXHD LINK_STATUS_SPEED_AND_DUPLEX_100TXHD |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 128 | #define LINK_100T4 LINK_STATUS_SPEED_AND_DUPLEX_100T4 |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 129 | #define LINK_100TXFD LINK_STATUS_SPEED_AND_DUPLEX_100TXFD |
| 130 | #define LINK_1000THD LINK_STATUS_SPEED_AND_DUPLEX_1000THD |
| 131 | #define LINK_1000TFD LINK_STATUS_SPEED_AND_DUPLEX_1000TFD |
| 132 | #define LINK_1000XFD LINK_STATUS_SPEED_AND_DUPLEX_1000XFD |
| 133 | #define LINK_2500THD LINK_STATUS_SPEED_AND_DUPLEX_2500THD |
| 134 | #define LINK_2500TFD LINK_STATUS_SPEED_AND_DUPLEX_2500TFD |
| 135 | #define LINK_2500XFD LINK_STATUS_SPEED_AND_DUPLEX_2500XFD |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 136 | #define LINK_10GTFD LINK_STATUS_SPEED_AND_DUPLEX_10GTFD |
| 137 | #define LINK_10GXFD LINK_STATUS_SPEED_AND_DUPLEX_10GXFD |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 138 | #define LINK_20GTFD LINK_STATUS_SPEED_AND_DUPLEX_20GTFD |
| 139 | #define LINK_20GXFD LINK_STATUS_SPEED_AND_DUPLEX_20GXFD |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 140 | |
| 141 | |
| 142 | |
Eilon Greenstein | 589abe3 | 2009-02-12 08:36:55 +0000 | [diff] [blame] | 143 | /* */ |
| 144 | #define SFP_EEPROM_CON_TYPE_ADDR 0x2 |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 145 | #define SFP_EEPROM_CON_TYPE_VAL_LC 0x7 |
Eilon Greenstein | 589abe3 | 2009-02-12 08:36:55 +0000 | [diff] [blame] | 146 | #define SFP_EEPROM_CON_TYPE_VAL_COPPER 0x21 |
| 147 | |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 148 | |
| 149 | #define SFP_EEPROM_COMP_CODE_ADDR 0x3 |
| 150 | #define SFP_EEPROM_COMP_CODE_SR_MASK (1<<4) |
| 151 | #define SFP_EEPROM_COMP_CODE_LR_MASK (1<<5) |
| 152 | #define SFP_EEPROM_COMP_CODE_LRM_MASK (1<<6) |
| 153 | |
Eilon Greenstein | 589abe3 | 2009-02-12 08:36:55 +0000 | [diff] [blame] | 154 | #define SFP_EEPROM_FC_TX_TECH_ADDR 0x8 |
| 155 | #define SFP_EEPROM_FC_TX_TECH_BITMASK_COPPER_PASSIVE 0x4 |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 156 | #define SFP_EEPROM_FC_TX_TECH_BITMASK_COPPER_ACTIVE 0x8 |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 157 | |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 158 | #define SFP_EEPROM_OPTIONS_ADDR 0x40 |
Eilon Greenstein | 589abe3 | 2009-02-12 08:36:55 +0000 | [diff] [blame] | 159 | #define SFP_EEPROM_OPTIONS_LINEAR_RX_OUT_MASK 0x1 |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 160 | #define SFP_EEPROM_OPTIONS_SIZE 2 |
Eilon Greenstein | 589abe3 | 2009-02-12 08:36:55 +0000 | [diff] [blame] | 161 | |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 162 | #define EDC_MODE_LINEAR 0x0022 |
| 163 | #define EDC_MODE_LIMITING 0x0044 |
| 164 | #define EDC_MODE_PASSIVE_DAC 0x0055 |
Eilon Greenstein | 589abe3 | 2009-02-12 08:36:55 +0000 | [diff] [blame] | 165 | |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame^] | 166 | /* BRB default for class 0 E2 */ |
| 167 | #define DEFAULT0_E2_BRB_MAC_PAUSE_XOFF_THR 170 |
| 168 | #define DEFAULT0_E2_BRB_MAC_PAUSE_XON_THR 250 |
| 169 | #define DEFAULT0_E2_BRB_MAC_FULL_XOFF_THR 10 |
| 170 | #define DEFAULT0_E2_BRB_MAC_FULL_XON_THR 50 |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 171 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 172 | /* BRB thresholds for E2*/ |
| 173 | #define PFC_E2_BRB_MAC_PAUSE_XOFF_THR_PAUSE 170 |
| 174 | #define PFC_E2_BRB_MAC_PAUSE_XOFF_THR_NON_PAUSE 0 |
| 175 | |
| 176 | #define PFC_E2_BRB_MAC_PAUSE_XON_THR_PAUSE 250 |
| 177 | #define PFC_E2_BRB_MAC_PAUSE_XON_THR_NON_PAUSE 0 |
| 178 | |
| 179 | #define PFC_E2_BRB_MAC_FULL_XOFF_THR_PAUSE 10 |
| 180 | #define PFC_E2_BRB_MAC_FULL_XOFF_THR_NON_PAUSE 90 |
| 181 | |
| 182 | #define PFC_E2_BRB_MAC_FULL_XON_THR_PAUSE 50 |
| 183 | #define PFC_E2_BRB_MAC_FULL_XON_THR_NON_PAUSE 250 |
| 184 | |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame^] | 185 | /* BRB default for class 0 E3A0 */ |
| 186 | #define DEFAULT0_E3A0_BRB_MAC_PAUSE_XOFF_THR 290 |
| 187 | #define DEFAULT0_E3A0_BRB_MAC_PAUSE_XON_THR 410 |
| 188 | #define DEFAULT0_E3A0_BRB_MAC_FULL_XOFF_THR 10 |
| 189 | #define DEFAULT0_E3A0_BRB_MAC_FULL_XON_THR 50 |
| 190 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 191 | /* BRB thresholds for E3A0 */ |
| 192 | #define PFC_E3A0_BRB_MAC_PAUSE_XOFF_THR_PAUSE 290 |
| 193 | #define PFC_E3A0_BRB_MAC_PAUSE_XOFF_THR_NON_PAUSE 0 |
| 194 | |
| 195 | #define PFC_E3A0_BRB_MAC_PAUSE_XON_THR_PAUSE 410 |
| 196 | #define PFC_E3A0_BRB_MAC_PAUSE_XON_THR_NON_PAUSE 0 |
| 197 | |
| 198 | #define PFC_E3A0_BRB_MAC_FULL_XOFF_THR_PAUSE 10 |
| 199 | #define PFC_E3A0_BRB_MAC_FULL_XOFF_THR_NON_PAUSE 170 |
| 200 | |
| 201 | #define PFC_E3A0_BRB_MAC_FULL_XON_THR_PAUSE 50 |
| 202 | #define PFC_E3A0_BRB_MAC_FULL_XON_THR_NON_PAUSE 410 |
| 203 | |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame^] | 204 | /* BRB default for E3B0 */ |
| 205 | #define DEFAULT0_E3B0_BRB_MAC_PAUSE_XOFF_THR 330 |
| 206 | #define DEFAULT0_E3B0_BRB_MAC_PAUSE_XON_THR 490 |
| 207 | #define DEFAULT0_E3B0_BRB_MAC_FULL_XOFF_THR 15 |
| 208 | #define DEFAULT0_E3B0_BRB_MAC_FULL_XON_THR 55 |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 209 | |
| 210 | /* BRB thresholds for E3B0 2 port mode*/ |
| 211 | #define PFC_E3B0_2P_BRB_MAC_PAUSE_XOFF_THR_PAUSE 1025 |
| 212 | #define PFC_E3B0_2P_BRB_MAC_PAUSE_XOFF_THR_NON_PAUSE 0 |
| 213 | |
| 214 | #define PFC_E3B0_2P_BRB_MAC_PAUSE_XON_THR_PAUSE 1025 |
| 215 | #define PFC_E3B0_2P_BRB_MAC_PAUSE_XON_THR_NON_PAUSE 0 |
| 216 | |
| 217 | #define PFC_E3B0_2P_BRB_MAC_FULL_XOFF_THR_PAUSE 10 |
| 218 | #define PFC_E3B0_2P_BRB_MAC_FULL_XOFF_THR_NON_PAUSE 1025 |
| 219 | |
| 220 | #define PFC_E3B0_2P_BRB_MAC_FULL_XON_THR_PAUSE 50 |
| 221 | #define PFC_E3B0_2P_BRB_MAC_FULL_XON_THR_NON_PAUSE 1025 |
| 222 | |
| 223 | /* only for E3B0*/ |
| 224 | #define PFC_E3B0_2P_BRB_FULL_LB_XOFF_THR 1025 |
| 225 | #define PFC_E3B0_2P_BRB_FULL_LB_XON_THR 1025 |
| 226 | |
| 227 | /* Lossy +Lossless GUARANTIED == GUART */ |
| 228 | #define PFC_E3B0_2P_MIX_PAUSE_LB_GUART 284 |
| 229 | /* Lossless +Lossless*/ |
| 230 | #define PFC_E3B0_2P_PAUSE_LB_GUART 236 |
| 231 | /* Lossy +Lossy*/ |
| 232 | #define PFC_E3B0_2P_NON_PAUSE_LB_GUART 342 |
| 233 | |
| 234 | /* Lossy +Lossless*/ |
| 235 | #define PFC_E3B0_2P_MIX_PAUSE_MAC_0_CLASS_T_GUART 284 |
| 236 | /* Lossless +Lossless*/ |
| 237 | #define PFC_E3B0_2P_PAUSE_MAC_0_CLASS_T_GUART 236 |
| 238 | /* Lossy +Lossy*/ |
| 239 | #define PFC_E3B0_2P_NON_PAUSE_MAC_0_CLASS_T_GUART 336 |
| 240 | #define PFC_E3B0_2P_BRB_MAC_0_CLASS_T_GUART_HYST 80 |
| 241 | |
| 242 | #define PFC_E3B0_2P_BRB_MAC_1_CLASS_T_GUART 0 |
| 243 | #define PFC_E3B0_2P_BRB_MAC_1_CLASS_T_GUART_HYST 0 |
| 244 | |
| 245 | /* BRB thresholds for E3B0 4 port mode */ |
| 246 | #define PFC_E3B0_4P_BRB_MAC_PAUSE_XOFF_THR_PAUSE 304 |
| 247 | #define PFC_E3B0_4P_BRB_MAC_PAUSE_XOFF_THR_NON_PAUSE 0 |
| 248 | |
| 249 | #define PFC_E3B0_4P_BRB_MAC_PAUSE_XON_THR_PAUSE 384 |
| 250 | #define PFC_E3B0_4P_BRB_MAC_PAUSE_XON_THR_NON_PAUSE 0 |
| 251 | |
| 252 | #define PFC_E3B0_4P_BRB_MAC_FULL_XOFF_THR_PAUSE 10 |
| 253 | #define PFC_E3B0_4P_BRB_MAC_FULL_XOFF_THR_NON_PAUSE 304 |
| 254 | |
| 255 | #define PFC_E3B0_4P_BRB_MAC_FULL_XON_THR_PAUSE 50 |
| 256 | #define PFC_E3B0_4P_BRB_MAC_FULL_XON_THR_NON_PAUSE 384 |
| 257 | |
| 258 | |
| 259 | /* only for E3B0*/ |
| 260 | #define PFC_E3B0_4P_BRB_FULL_LB_XOFF_THR 304 |
| 261 | #define PFC_E3B0_4P_BRB_FULL_LB_XON_THR 384 |
| 262 | #define PFC_E3B0_4P_LB_GUART 120 |
| 263 | |
| 264 | #define PFC_E3B0_4P_BRB_MAC_0_CLASS_T_GUART 120 |
| 265 | #define PFC_E3B0_4P_BRB_MAC_0_CLASS_T_GUART_HYST 80 |
| 266 | |
| 267 | #define PFC_E3B0_4P_BRB_MAC_1_CLASS_T_GUART 80 |
| 268 | #define PFC_E3B0_4P_BRB_MAC_1_CLASS_T_GUART_HYST 120 |
| 269 | |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame^] | 270 | /* Pause defines*/ |
| 271 | #define DEFAULT_E3B0_BRB_FULL_LB_XOFF_THR 330 |
| 272 | #define DEFAULT_E3B0_BRB_FULL_LB_XON_THR 490 |
| 273 | #define DEFAULT_E3B0_LB_GUART 40 |
| 274 | |
| 275 | #define DEFAULT_E3B0_BRB_MAC_0_CLASS_T_GUART 40 |
| 276 | #define DEFAULT_E3B0_BRB_MAC_0_CLASS_T_GUART_HYST 0 |
| 277 | |
| 278 | #define DEFAULT_E3B0_BRB_MAC_1_CLASS_T_GUART 40 |
| 279 | #define DEFAULT_E3B0_BRB_MAC_1_CLASS_T_GUART_HYST 0 |
| 280 | |
| 281 | /* ETS defines*/ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 282 | #define DCBX_INVALID_COS (0xFF) |
| 283 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 284 | #define ETS_BW_LIMIT_CREDIT_UPPER_BOUND (0x5000) |
| 285 | #define ETS_BW_LIMIT_CREDIT_WEIGHT (0x5000) |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 286 | #define ETS_E3B0_NIG_MIN_W_VAL_UP_TO_10GBPS (1360) |
| 287 | #define ETS_E3B0_NIG_MIN_W_VAL_20GBPS (2720) |
| 288 | #define ETS_E3B0_PBF_MIN_W_VAL (10000) |
| 289 | |
| 290 | #define MAX_PACKET_SIZE (9700) |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 291 | #define WC_UC_TIMEOUT 100 |
Yaniv Rosner | a9077bf | 2011-10-27 05:09:46 +0000 | [diff] [blame] | 292 | #define MAX_KR_LINK_RETRY 4 |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 293 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 294 | /**********************************************************/ |
| 295 | /* INTERFACE */ |
| 296 | /**********************************************************/ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 297 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 298 | #define CL22_WR_OVER_CL45(_bp, _phy, _bank, _addr, _val) \ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 299 | bnx2x_cl45_write(_bp, _phy, \ |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 300 | (_phy)->def_md_devad, \ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 301 | (_bank + (_addr & 0xf)), \ |
| 302 | _val) |
| 303 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 304 | #define CL22_RD_OVER_CL45(_bp, _phy, _bank, _addr, _val) \ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 305 | bnx2x_cl45_read(_bp, _phy, \ |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 306 | (_phy)->def_md_devad, \ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 307 | (_bank + (_addr & 0xf)), \ |
| 308 | _val) |
| 309 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 310 | static u32 bnx2x_bits_en(struct bnx2x *bp, u32 reg, u32 bits) |
| 311 | { |
| 312 | u32 val = REG_RD(bp, reg); |
| 313 | |
| 314 | val |= bits; |
| 315 | REG_WR(bp, reg, val); |
| 316 | return val; |
| 317 | } |
| 318 | |
| 319 | static u32 bnx2x_bits_dis(struct bnx2x *bp, u32 reg, u32 bits) |
| 320 | { |
| 321 | u32 val = REG_RD(bp, reg); |
| 322 | |
| 323 | val &= ~bits; |
| 324 | REG_WR(bp, reg, val); |
| 325 | return val; |
| 326 | } |
| 327 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 328 | /******************************************************************/ |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 329 | /* EPIO/GPIO section */ |
| 330 | /******************************************************************/ |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 331 | static void bnx2x_get_epio(struct bnx2x *bp, u32 epio_pin, u32 *en) |
| 332 | { |
| 333 | u32 epio_mask, gp_oenable; |
| 334 | *en = 0; |
| 335 | /* Sanity check */ |
| 336 | if (epio_pin > 31) { |
| 337 | DP(NETIF_MSG_LINK, "Invalid EPIO pin %d to get\n", epio_pin); |
| 338 | return; |
| 339 | } |
| 340 | |
| 341 | epio_mask = 1 << epio_pin; |
| 342 | /* Set this EPIO to output */ |
| 343 | gp_oenable = REG_RD(bp, MCP_REG_MCPR_GP_OENABLE); |
| 344 | REG_WR(bp, MCP_REG_MCPR_GP_OENABLE, gp_oenable & ~epio_mask); |
| 345 | |
| 346 | *en = (REG_RD(bp, MCP_REG_MCPR_GP_INPUTS) & epio_mask) >> epio_pin; |
| 347 | } |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 348 | static void bnx2x_set_epio(struct bnx2x *bp, u32 epio_pin, u32 en) |
| 349 | { |
| 350 | u32 epio_mask, gp_output, gp_oenable; |
| 351 | |
| 352 | /* Sanity check */ |
| 353 | if (epio_pin > 31) { |
| 354 | DP(NETIF_MSG_LINK, "Invalid EPIO pin %d to set\n", epio_pin); |
| 355 | return; |
| 356 | } |
| 357 | DP(NETIF_MSG_LINK, "Setting EPIO pin %d to %d\n", epio_pin, en); |
| 358 | epio_mask = 1 << epio_pin; |
| 359 | /* Set this EPIO to output */ |
| 360 | gp_output = REG_RD(bp, MCP_REG_MCPR_GP_OUTPUTS); |
| 361 | if (en) |
| 362 | gp_output |= epio_mask; |
| 363 | else |
| 364 | gp_output &= ~epio_mask; |
| 365 | |
| 366 | REG_WR(bp, MCP_REG_MCPR_GP_OUTPUTS, gp_output); |
| 367 | |
| 368 | /* Set the value for this EPIO */ |
| 369 | gp_oenable = REG_RD(bp, MCP_REG_MCPR_GP_OENABLE); |
| 370 | REG_WR(bp, MCP_REG_MCPR_GP_OENABLE, gp_oenable | epio_mask); |
| 371 | } |
| 372 | |
| 373 | static void bnx2x_set_cfg_pin(struct bnx2x *bp, u32 pin_cfg, u32 val) |
| 374 | { |
| 375 | if (pin_cfg == PIN_CFG_NA) |
| 376 | return; |
| 377 | if (pin_cfg >= PIN_CFG_EPIO0) { |
| 378 | bnx2x_set_epio(bp, pin_cfg - PIN_CFG_EPIO0, val); |
| 379 | } else { |
| 380 | u8 gpio_num = (pin_cfg - PIN_CFG_GPIO0_P0) & 0x3; |
| 381 | u8 gpio_port = (pin_cfg - PIN_CFG_GPIO0_P0) >> 2; |
| 382 | bnx2x_set_gpio(bp, gpio_num, (u8)val, gpio_port); |
| 383 | } |
| 384 | } |
| 385 | |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 386 | static u32 bnx2x_get_cfg_pin(struct bnx2x *bp, u32 pin_cfg, u32 *val) |
| 387 | { |
| 388 | if (pin_cfg == PIN_CFG_NA) |
| 389 | return -EINVAL; |
| 390 | if (pin_cfg >= PIN_CFG_EPIO0) { |
| 391 | bnx2x_get_epio(bp, pin_cfg - PIN_CFG_EPIO0, val); |
| 392 | } else { |
| 393 | u8 gpio_num = (pin_cfg - PIN_CFG_GPIO0_P0) & 0x3; |
| 394 | u8 gpio_port = (pin_cfg - PIN_CFG_GPIO0_P0) >> 2; |
| 395 | *val = bnx2x_get_gpio(bp, gpio_num, gpio_port); |
| 396 | } |
| 397 | return 0; |
| 398 | |
| 399 | } |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 400 | /******************************************************************/ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 401 | /* ETS section */ |
| 402 | /******************************************************************/ |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 403 | static void bnx2x_ets_e2e3a0_disabled(struct link_params *params) |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 404 | { |
| 405 | /* ETS disabled configuration*/ |
| 406 | struct bnx2x *bp = params->bp; |
| 407 | |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 408 | DP(NETIF_MSG_LINK, "ETS E2E3 disabled configuration\n"); |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 409 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 410 | /* |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 411 | * mapping between entry priority to client number (0,1,2 -debug and |
| 412 | * management clients, 3 - COS0 client, 4 - COS client)(HIGHEST) |
| 413 | * 3bits client num. |
| 414 | * PRI4 | PRI3 | PRI2 | PRI1 | PRI0 |
| 415 | * cos1-100 cos0-011 dbg1-010 dbg0-001 MCP-000 |
| 416 | */ |
| 417 | |
| 418 | REG_WR(bp, NIG_REG_P0_TX_ARB_PRIORITY_CLIENT, 0x4688); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 419 | /* |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 420 | * Bitmap of 5bits length. Each bit specifies whether the entry behaves |
| 421 | * as strict. Bits 0,1,2 - debug and management entries, 3 - |
| 422 | * COS0 entry, 4 - COS1 entry. |
| 423 | * COS1 | COS0 | DEBUG1 | DEBUG0 | MGMT |
| 424 | * bit4 bit3 bit2 bit1 bit0 |
| 425 | * MCP and debug are strict |
| 426 | */ |
| 427 | |
| 428 | REG_WR(bp, NIG_REG_P0_TX_ARB_CLIENT_IS_STRICT, 0x7); |
| 429 | /* defines which entries (clients) are subjected to WFQ arbitration */ |
| 430 | REG_WR(bp, NIG_REG_P0_TX_ARB_CLIENT_IS_SUBJECT2WFQ, 0); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 431 | /* |
| 432 | * For strict priority entries defines the number of consecutive |
| 433 | * slots for the highest priority. |
| 434 | */ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 435 | 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] | 436 | /* |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 437 | * mapping between the CREDIT_WEIGHT registers and actual client |
| 438 | * numbers |
| 439 | */ |
| 440 | REG_WR(bp, NIG_REG_P0_TX_ARB_CLIENT_CREDIT_MAP, 0); |
| 441 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_0, 0); |
| 442 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_1, 0); |
| 443 | |
| 444 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_0, 0); |
| 445 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_1, 0); |
| 446 | REG_WR(bp, PBF_REG_HIGH_PRIORITY_COS_NUM, 0); |
| 447 | /* ETS mode disable */ |
| 448 | REG_WR(bp, PBF_REG_ETS_ENABLED, 0); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 449 | /* |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 450 | * If ETS mode is enabled (there is no strict priority) defines a WFQ |
| 451 | * weight for COS0/COS1. |
| 452 | */ |
| 453 | REG_WR(bp, PBF_REG_COS0_WEIGHT, 0x2710); |
| 454 | REG_WR(bp, PBF_REG_COS1_WEIGHT, 0x2710); |
| 455 | /* Upper bound that COS0_WEIGHT can reach in the WFQ arbiter */ |
| 456 | REG_WR(bp, PBF_REG_COS0_UPPER_BOUND, 0x989680); |
| 457 | REG_WR(bp, PBF_REG_COS1_UPPER_BOUND, 0x989680); |
| 458 | /* Defines the number of consecutive slots for the strict priority */ |
| 459 | REG_WR(bp, PBF_REG_NUM_STRICT_ARB_SLOTS, 0); |
| 460 | } |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 461 | /****************************************************************************** |
| 462 | * Description: |
| 463 | * Getting min_w_val will be set according to line speed . |
| 464 | *. |
| 465 | ******************************************************************************/ |
| 466 | static u32 bnx2x_ets_get_min_w_val_nig(const struct link_vars *vars) |
| 467 | { |
| 468 | u32 min_w_val = 0; |
| 469 | /* Calculate min_w_val.*/ |
| 470 | if (vars->link_up) { |
| 471 | if (SPEED_20000 == vars->line_speed) |
| 472 | min_w_val = ETS_E3B0_NIG_MIN_W_VAL_20GBPS; |
| 473 | else |
| 474 | min_w_val = ETS_E3B0_NIG_MIN_W_VAL_UP_TO_10GBPS; |
| 475 | } else |
| 476 | min_w_val = ETS_E3B0_NIG_MIN_W_VAL_20GBPS; |
| 477 | /** |
| 478 | * If the link isn't up (static configuration for example ) The |
| 479 | * link will be according to 20GBPS. |
| 480 | */ |
| 481 | return min_w_val; |
| 482 | } |
| 483 | /****************************************************************************** |
| 484 | * Description: |
| 485 | * Getting credit upper bound form min_w_val. |
| 486 | *. |
| 487 | ******************************************************************************/ |
| 488 | static u32 bnx2x_ets_get_credit_upper_bound(const u32 min_w_val) |
| 489 | { |
| 490 | const u32 credit_upper_bound = (u32)MAXVAL((150 * min_w_val), |
| 491 | MAX_PACKET_SIZE); |
| 492 | return credit_upper_bound; |
| 493 | } |
| 494 | /****************************************************************************** |
| 495 | * Description: |
| 496 | * Set credit upper bound for NIG. |
| 497 | *. |
| 498 | ******************************************************************************/ |
| 499 | static void bnx2x_ets_e3b0_set_credit_upper_bound_nig( |
| 500 | const struct link_params *params, |
| 501 | const u32 min_w_val) |
| 502 | { |
| 503 | struct bnx2x *bp = params->bp; |
| 504 | const u8 port = params->port; |
| 505 | const u32 credit_upper_bound = |
| 506 | bnx2x_ets_get_credit_upper_bound(min_w_val); |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 507 | |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 508 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CREDIT_UPPER_BOUND_0 : |
| 509 | NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_0, credit_upper_bound); |
| 510 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CREDIT_UPPER_BOUND_1 : |
| 511 | NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_1, credit_upper_bound); |
| 512 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CREDIT_UPPER_BOUND_2 : |
| 513 | NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_2, credit_upper_bound); |
| 514 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CREDIT_UPPER_BOUND_3 : |
| 515 | NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_3, credit_upper_bound); |
| 516 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CREDIT_UPPER_BOUND_4 : |
| 517 | NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_4, credit_upper_bound); |
| 518 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CREDIT_UPPER_BOUND_5 : |
| 519 | NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_5, credit_upper_bound); |
| 520 | |
| 521 | if (0 == port) { |
| 522 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_6, |
| 523 | credit_upper_bound); |
| 524 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_7, |
| 525 | credit_upper_bound); |
| 526 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_8, |
| 527 | credit_upper_bound); |
| 528 | } |
| 529 | } |
| 530 | /****************************************************************************** |
| 531 | * Description: |
| 532 | * Will return the NIG ETS registers to init values.Except |
| 533 | * credit_upper_bound. |
| 534 | * That isn't used in this configuration (No WFQ is enabled) and will be |
| 535 | * configured acording to spec |
| 536 | *. |
| 537 | ******************************************************************************/ |
| 538 | static void bnx2x_ets_e3b0_nig_disabled(const struct link_params *params, |
| 539 | const struct link_vars *vars) |
| 540 | { |
| 541 | struct bnx2x *bp = params->bp; |
| 542 | const u8 port = params->port; |
| 543 | const u32 min_w_val = bnx2x_ets_get_min_w_val_nig(vars); |
| 544 | /** |
| 545 | * mapping between entry priority to client number (0,1,2 -debug and |
| 546 | * management clients, 3 - COS0 client, 4 - COS1, ... 8 - |
| 547 | * COS5)(HIGHEST) 4bits client num.TODO_ETS - Should be done by |
| 548 | * reset value or init tool |
| 549 | */ |
| 550 | if (port) { |
| 551 | REG_WR(bp, NIG_REG_P1_TX_ARB_PRIORITY_CLIENT2_LSB, 0x543210); |
| 552 | REG_WR(bp, NIG_REG_P1_TX_ARB_PRIORITY_CLIENT2_MSB, 0x0); |
| 553 | } else { |
| 554 | REG_WR(bp, NIG_REG_P0_TX_ARB_PRIORITY_CLIENT2_LSB, 0x76543210); |
| 555 | REG_WR(bp, NIG_REG_P0_TX_ARB_PRIORITY_CLIENT2_MSB, 0x8); |
| 556 | } |
| 557 | /** |
| 558 | * For strict priority entries defines the number of consecutive |
| 559 | * slots for the highest priority. |
| 560 | */ |
| 561 | /* TODO_ETS - Should be done by reset value or init tool */ |
| 562 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_NUM_STRICT_ARB_SLOTS : |
| 563 | NIG_REG_P1_TX_ARB_NUM_STRICT_ARB_SLOTS, 0x100); |
| 564 | /** |
| 565 | * mapping between the CREDIT_WEIGHT registers and actual client |
| 566 | * numbers |
| 567 | */ |
| 568 | /* TODO_ETS - Should be done by reset value or init tool */ |
| 569 | if (port) { |
| 570 | /*Port 1 has 6 COS*/ |
| 571 | REG_WR(bp, NIG_REG_P1_TX_ARB_CLIENT_CREDIT_MAP2_LSB, 0x210543); |
| 572 | REG_WR(bp, NIG_REG_P1_TX_ARB_CLIENT_CREDIT_MAP2_MSB, 0x0); |
| 573 | } else { |
| 574 | /*Port 0 has 9 COS*/ |
| 575 | REG_WR(bp, NIG_REG_P0_TX_ARB_CLIENT_CREDIT_MAP2_LSB, |
| 576 | 0x43210876); |
| 577 | REG_WR(bp, NIG_REG_P0_TX_ARB_CLIENT_CREDIT_MAP2_MSB, 0x5); |
| 578 | } |
| 579 | |
| 580 | /** |
| 581 | * Bitmap of 5bits length. Each bit specifies whether the entry behaves |
| 582 | * as strict. Bits 0,1,2 - debug and management entries, 3 - |
| 583 | * COS0 entry, 4 - COS1 entry. |
| 584 | * COS1 | COS0 | DEBUG1 | DEBUG0 | MGMT |
| 585 | * bit4 bit3 bit2 bit1 bit0 |
| 586 | * MCP and debug are strict |
| 587 | */ |
| 588 | if (port) |
| 589 | REG_WR(bp, NIG_REG_P1_TX_ARB_CLIENT_IS_STRICT, 0x3f); |
| 590 | else |
| 591 | REG_WR(bp, NIG_REG_P0_TX_ARB_CLIENT_IS_STRICT, 0x1ff); |
| 592 | /* defines which entries (clients) are subjected to WFQ arbitration */ |
| 593 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CLIENT_IS_SUBJECT2WFQ : |
| 594 | NIG_REG_P0_TX_ARB_CLIENT_IS_SUBJECT2WFQ, 0); |
| 595 | |
| 596 | /** |
| 597 | * Please notice the register address are note continuous and a |
| 598 | * for here is note appropriate.In 2 port mode port0 only COS0-5 |
| 599 | * can be used. DEBUG1,DEBUG1,MGMT are never used for WFQ* In 4 |
| 600 | * port mode port1 only COS0-2 can be used. DEBUG1,DEBUG1,MGMT |
| 601 | * are never used for WFQ |
| 602 | */ |
| 603 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CREDIT_WEIGHT_0 : |
| 604 | NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_0, 0x0); |
| 605 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CREDIT_WEIGHT_1 : |
| 606 | NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_1, 0x0); |
| 607 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CREDIT_WEIGHT_2 : |
| 608 | NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_2, 0x0); |
| 609 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CREDIT_WEIGHT_3 : |
| 610 | NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_3, 0x0); |
| 611 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CREDIT_WEIGHT_4 : |
| 612 | NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_4, 0x0); |
| 613 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CREDIT_WEIGHT_5 : |
| 614 | NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_5, 0x0); |
| 615 | if (0 == port) { |
| 616 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_6, 0x0); |
| 617 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_7, 0x0); |
| 618 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_8, 0x0); |
| 619 | } |
| 620 | |
| 621 | bnx2x_ets_e3b0_set_credit_upper_bound_nig(params, min_w_val); |
| 622 | } |
| 623 | /****************************************************************************** |
| 624 | * Description: |
| 625 | * Set credit upper bound for PBF. |
| 626 | *. |
| 627 | ******************************************************************************/ |
| 628 | static void bnx2x_ets_e3b0_set_credit_upper_bound_pbf( |
| 629 | const struct link_params *params, |
| 630 | const u32 min_w_val) |
| 631 | { |
| 632 | struct bnx2x *bp = params->bp; |
| 633 | const u32 credit_upper_bound = |
| 634 | bnx2x_ets_get_credit_upper_bound(min_w_val); |
| 635 | const u8 port = params->port; |
| 636 | u32 base_upper_bound = 0; |
| 637 | u8 max_cos = 0; |
| 638 | u8 i = 0; |
| 639 | /** |
| 640 | * In 2 port mode port0 has COS0-5 that can be used for WFQ.In 4 |
| 641 | * port mode port1 has COS0-2 that can be used for WFQ. |
| 642 | */ |
| 643 | if (0 == port) { |
| 644 | base_upper_bound = PBF_REG_COS0_UPPER_BOUND_P0; |
| 645 | max_cos = DCBX_E3B0_MAX_NUM_COS_PORT0; |
| 646 | } else { |
| 647 | base_upper_bound = PBF_REG_COS0_UPPER_BOUND_P1; |
| 648 | max_cos = DCBX_E3B0_MAX_NUM_COS_PORT1; |
| 649 | } |
| 650 | |
| 651 | for (i = 0; i < max_cos; i++) |
| 652 | REG_WR(bp, base_upper_bound + (i << 2), credit_upper_bound); |
| 653 | } |
| 654 | |
| 655 | /****************************************************************************** |
| 656 | * Description: |
| 657 | * Will return the PBF ETS registers to init values.Except |
| 658 | * credit_upper_bound. |
| 659 | * That isn't used in this configuration (No WFQ is enabled) and will be |
| 660 | * configured acording to spec |
| 661 | *. |
| 662 | ******************************************************************************/ |
| 663 | static void bnx2x_ets_e3b0_pbf_disabled(const struct link_params *params) |
| 664 | { |
| 665 | struct bnx2x *bp = params->bp; |
| 666 | const u8 port = params->port; |
| 667 | const u32 min_w_val_pbf = ETS_E3B0_PBF_MIN_W_VAL; |
| 668 | u8 i = 0; |
| 669 | u32 base_weight = 0; |
| 670 | u8 max_cos = 0; |
| 671 | |
| 672 | /** |
| 673 | * mapping between entry priority to client number 0 - COS0 |
| 674 | * client, 2 - COS1, ... 5 - COS5)(HIGHEST) 4bits client num. |
| 675 | * TODO_ETS - Should be done by reset value or init tool |
| 676 | */ |
| 677 | if (port) |
| 678 | /* 0x688 (|011|0 10|00 1|000) */ |
| 679 | REG_WR(bp, PBF_REG_ETS_ARB_PRIORITY_CLIENT_P1 , 0x688); |
| 680 | else |
| 681 | /* (10 1|100 |011|0 10|00 1|000) */ |
| 682 | REG_WR(bp, PBF_REG_ETS_ARB_PRIORITY_CLIENT_P0 , 0x2C688); |
| 683 | |
| 684 | /* TODO_ETS - Should be done by reset value or init tool */ |
| 685 | if (port) |
| 686 | /* 0x688 (|011|0 10|00 1|000)*/ |
| 687 | REG_WR(bp, PBF_REG_ETS_ARB_CLIENT_CREDIT_MAP_P1, 0x688); |
| 688 | else |
| 689 | /* 0x2C688 (10 1|100 |011|0 10|00 1|000) */ |
| 690 | REG_WR(bp, PBF_REG_ETS_ARB_CLIENT_CREDIT_MAP_P0, 0x2C688); |
| 691 | |
| 692 | REG_WR(bp, (port) ? PBF_REG_ETS_ARB_NUM_STRICT_ARB_SLOTS_P1 : |
| 693 | PBF_REG_ETS_ARB_NUM_STRICT_ARB_SLOTS_P0 , 0x100); |
| 694 | |
| 695 | |
| 696 | REG_WR(bp, (port) ? PBF_REG_ETS_ARB_CLIENT_IS_STRICT_P1 : |
| 697 | PBF_REG_ETS_ARB_CLIENT_IS_STRICT_P0 , 0); |
| 698 | |
| 699 | REG_WR(bp, (port) ? PBF_REG_ETS_ARB_CLIENT_IS_SUBJECT2WFQ_P1 : |
| 700 | PBF_REG_ETS_ARB_CLIENT_IS_SUBJECT2WFQ_P0 , 0); |
| 701 | /** |
| 702 | * In 2 port mode port0 has COS0-5 that can be used for WFQ. |
| 703 | * In 4 port mode port1 has COS0-2 that can be used for WFQ. |
| 704 | */ |
| 705 | if (0 == port) { |
| 706 | base_weight = PBF_REG_COS0_WEIGHT_P0; |
| 707 | max_cos = DCBX_E3B0_MAX_NUM_COS_PORT0; |
| 708 | } else { |
| 709 | base_weight = PBF_REG_COS0_WEIGHT_P1; |
| 710 | max_cos = DCBX_E3B0_MAX_NUM_COS_PORT1; |
| 711 | } |
| 712 | |
| 713 | for (i = 0; i < max_cos; i++) |
| 714 | REG_WR(bp, base_weight + (0x4 * i), 0); |
| 715 | |
| 716 | bnx2x_ets_e3b0_set_credit_upper_bound_pbf(params, min_w_val_pbf); |
| 717 | } |
| 718 | /****************************************************************************** |
| 719 | * Description: |
| 720 | * E3B0 disable will return basicly the values to init values. |
| 721 | *. |
| 722 | ******************************************************************************/ |
| 723 | static int bnx2x_ets_e3b0_disabled(const struct link_params *params, |
| 724 | const struct link_vars *vars) |
| 725 | { |
| 726 | struct bnx2x *bp = params->bp; |
| 727 | |
| 728 | if (!CHIP_IS_E3B0(bp)) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 729 | DP(NETIF_MSG_LINK, |
| 730 | "bnx2x_ets_e3b0_disabled the chip isn't E3B0\n"); |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 731 | return -EINVAL; |
| 732 | } |
| 733 | |
| 734 | bnx2x_ets_e3b0_nig_disabled(params, vars); |
| 735 | |
| 736 | bnx2x_ets_e3b0_pbf_disabled(params); |
| 737 | |
| 738 | return 0; |
| 739 | } |
| 740 | |
| 741 | /****************************************************************************** |
| 742 | * Description: |
| 743 | * Disable will return basicly the values to init values. |
| 744 | *. |
| 745 | ******************************************************************************/ |
| 746 | int bnx2x_ets_disabled(struct link_params *params, |
| 747 | struct link_vars *vars) |
| 748 | { |
| 749 | struct bnx2x *bp = params->bp; |
| 750 | int bnx2x_status = 0; |
| 751 | |
| 752 | if ((CHIP_IS_E2(bp)) || (CHIP_IS_E3A0(bp))) |
| 753 | bnx2x_ets_e2e3a0_disabled(params); |
| 754 | else if (CHIP_IS_E3B0(bp)) |
| 755 | bnx2x_status = bnx2x_ets_e3b0_disabled(params, vars); |
| 756 | else { |
| 757 | DP(NETIF_MSG_LINK, "bnx2x_ets_disabled - chip not supported\n"); |
| 758 | return -EINVAL; |
| 759 | } |
| 760 | |
| 761 | return bnx2x_status; |
| 762 | } |
| 763 | |
| 764 | /****************************************************************************** |
| 765 | * Description |
| 766 | * Set the COS mappimg to SP and BW until this point all the COS are not |
| 767 | * set as SP or BW. |
| 768 | ******************************************************************************/ |
| 769 | static int bnx2x_ets_e3b0_cli_map(const struct link_params *params, |
| 770 | const struct bnx2x_ets_params *ets_params, |
| 771 | const u8 cos_sp_bitmap, |
| 772 | const u8 cos_bw_bitmap) |
| 773 | { |
| 774 | struct bnx2x *bp = params->bp; |
| 775 | const u8 port = params->port; |
| 776 | const u8 nig_cli_sp_bitmap = 0x7 | (cos_sp_bitmap << 3); |
| 777 | const u8 pbf_cli_sp_bitmap = cos_sp_bitmap; |
| 778 | const u8 nig_cli_subject2wfq_bitmap = cos_bw_bitmap << 3; |
| 779 | const u8 pbf_cli_subject2wfq_bitmap = cos_bw_bitmap; |
| 780 | |
| 781 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CLIENT_IS_STRICT : |
| 782 | NIG_REG_P0_TX_ARB_CLIENT_IS_STRICT, nig_cli_sp_bitmap); |
| 783 | |
| 784 | REG_WR(bp, (port) ? PBF_REG_ETS_ARB_CLIENT_IS_STRICT_P1 : |
| 785 | PBF_REG_ETS_ARB_CLIENT_IS_STRICT_P0 , pbf_cli_sp_bitmap); |
| 786 | |
| 787 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CLIENT_IS_SUBJECT2WFQ : |
| 788 | NIG_REG_P0_TX_ARB_CLIENT_IS_SUBJECT2WFQ, |
| 789 | nig_cli_subject2wfq_bitmap); |
| 790 | |
| 791 | REG_WR(bp, (port) ? PBF_REG_ETS_ARB_CLIENT_IS_SUBJECT2WFQ_P1 : |
| 792 | PBF_REG_ETS_ARB_CLIENT_IS_SUBJECT2WFQ_P0, |
| 793 | pbf_cli_subject2wfq_bitmap); |
| 794 | |
| 795 | return 0; |
| 796 | } |
| 797 | |
| 798 | /****************************************************************************** |
| 799 | * Description: |
| 800 | * This function is needed because NIG ARB_CREDIT_WEIGHT_X are |
| 801 | * not continues and ARB_CREDIT_WEIGHT_0 + offset is suitable. |
| 802 | ******************************************************************************/ |
| 803 | static int bnx2x_ets_e3b0_set_cos_bw(struct bnx2x *bp, |
| 804 | const u8 cos_entry, |
| 805 | const u32 min_w_val_nig, |
| 806 | const u32 min_w_val_pbf, |
| 807 | const u16 total_bw, |
| 808 | const u8 bw, |
| 809 | const u8 port) |
| 810 | { |
| 811 | u32 nig_reg_adress_crd_weight = 0; |
| 812 | u32 pbf_reg_adress_crd_weight = 0; |
David S. Miller | 8decf86 | 2011-09-22 03:23:13 -0400 | [diff] [blame] | 813 | /* Calculate and set BW for this COS - use 1 instead of 0 for BW */ |
| 814 | const u32 cos_bw_nig = ((bw ? bw : 1) * min_w_val_nig) / total_bw; |
| 815 | const u32 cos_bw_pbf = ((bw ? bw : 1) * min_w_val_pbf) / total_bw; |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 816 | |
| 817 | switch (cos_entry) { |
| 818 | case 0: |
| 819 | nig_reg_adress_crd_weight = |
| 820 | (port) ? NIG_REG_P1_TX_ARB_CREDIT_WEIGHT_0 : |
| 821 | NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_0; |
| 822 | pbf_reg_adress_crd_weight = (port) ? |
| 823 | PBF_REG_COS0_WEIGHT_P1 : PBF_REG_COS0_WEIGHT_P0; |
| 824 | break; |
| 825 | case 1: |
| 826 | nig_reg_adress_crd_weight = (port) ? |
| 827 | NIG_REG_P1_TX_ARB_CREDIT_WEIGHT_1 : |
| 828 | NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_1; |
| 829 | pbf_reg_adress_crd_weight = (port) ? |
| 830 | PBF_REG_COS1_WEIGHT_P1 : PBF_REG_COS1_WEIGHT_P0; |
| 831 | break; |
| 832 | case 2: |
| 833 | nig_reg_adress_crd_weight = (port) ? |
| 834 | NIG_REG_P1_TX_ARB_CREDIT_WEIGHT_2 : |
| 835 | NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_2; |
| 836 | |
| 837 | pbf_reg_adress_crd_weight = (port) ? |
| 838 | PBF_REG_COS2_WEIGHT_P1 : PBF_REG_COS2_WEIGHT_P0; |
| 839 | break; |
| 840 | case 3: |
| 841 | if (port) |
| 842 | return -EINVAL; |
| 843 | nig_reg_adress_crd_weight = |
| 844 | NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_3; |
| 845 | pbf_reg_adress_crd_weight = |
| 846 | PBF_REG_COS3_WEIGHT_P0; |
| 847 | break; |
| 848 | case 4: |
| 849 | if (port) |
| 850 | return -EINVAL; |
| 851 | nig_reg_adress_crd_weight = |
| 852 | NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_4; |
| 853 | pbf_reg_adress_crd_weight = PBF_REG_COS4_WEIGHT_P0; |
| 854 | break; |
| 855 | case 5: |
| 856 | if (port) |
| 857 | return -EINVAL; |
| 858 | nig_reg_adress_crd_weight = |
| 859 | NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_5; |
| 860 | pbf_reg_adress_crd_weight = PBF_REG_COS5_WEIGHT_P0; |
| 861 | break; |
| 862 | } |
| 863 | |
| 864 | REG_WR(bp, nig_reg_adress_crd_weight, cos_bw_nig); |
| 865 | |
| 866 | REG_WR(bp, pbf_reg_adress_crd_weight, cos_bw_pbf); |
| 867 | |
| 868 | return 0; |
| 869 | } |
| 870 | /****************************************************************************** |
| 871 | * Description: |
| 872 | * Calculate the total BW.A value of 0 isn't legal. |
| 873 | *. |
| 874 | ******************************************************************************/ |
| 875 | static int bnx2x_ets_e3b0_get_total_bw( |
| 876 | const struct link_params *params, |
| 877 | const struct bnx2x_ets_params *ets_params, |
| 878 | u16 *total_bw) |
| 879 | { |
| 880 | struct bnx2x *bp = params->bp; |
| 881 | u8 cos_idx = 0; |
| 882 | |
| 883 | *total_bw = 0 ; |
| 884 | /* Calculate total BW requested */ |
| 885 | for (cos_idx = 0; cos_idx < ets_params->num_of_cos; cos_idx++) { |
| 886 | if (bnx2x_cos_state_bw == ets_params->cos[cos_idx].state) { |
David S. Miller | 8decf86 | 2011-09-22 03:23:13 -0400 | [diff] [blame] | 887 | *total_bw += |
| 888 | ets_params->cos[cos_idx].params.bw_params.bw; |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 889 | } |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 890 | } |
| 891 | |
David S. Miller | 8decf86 | 2011-09-22 03:23:13 -0400 | [diff] [blame] | 892 | /* Check total BW is valid */ |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 893 | if ((100 != *total_bw) || (0 == *total_bw)) { |
| 894 | if (0 == *total_bw) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 895 | DP(NETIF_MSG_LINK, |
| 896 | "bnx2x_ets_E3B0_config toatl BW shouldn't be 0\n"); |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 897 | return -EINVAL; |
| 898 | } |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 899 | DP(NETIF_MSG_LINK, |
| 900 | "bnx2x_ets_E3B0_config toatl BW should be 100\n"); |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 901 | /** |
| 902 | * We can handle a case whre the BW isn't 100 this can happen |
| 903 | * if the TC are joined. |
| 904 | */ |
| 905 | } |
| 906 | return 0; |
| 907 | } |
| 908 | |
| 909 | /****************************************************************************** |
| 910 | * Description: |
| 911 | * Invalidate all the sp_pri_to_cos. |
| 912 | *. |
| 913 | ******************************************************************************/ |
| 914 | static void bnx2x_ets_e3b0_sp_pri_to_cos_init(u8 *sp_pri_to_cos) |
| 915 | { |
| 916 | u8 pri = 0; |
| 917 | for (pri = 0; pri < DCBX_MAX_NUM_COS; pri++) |
| 918 | sp_pri_to_cos[pri] = DCBX_INVALID_COS; |
| 919 | } |
| 920 | /****************************************************************************** |
| 921 | * Description: |
| 922 | * Calculate and set the SP (ARB_PRIORITY_CLIENT) NIG and PBF registers |
| 923 | * according to sp_pri_to_cos. |
| 924 | *. |
| 925 | ******************************************************************************/ |
| 926 | static int bnx2x_ets_e3b0_sp_pri_to_cos_set(const struct link_params *params, |
| 927 | u8 *sp_pri_to_cos, const u8 pri, |
| 928 | const u8 cos_entry) |
| 929 | { |
| 930 | struct bnx2x *bp = params->bp; |
| 931 | const u8 port = params->port; |
| 932 | const u8 max_num_of_cos = (port) ? DCBX_E3B0_MAX_NUM_COS_PORT1 : |
| 933 | DCBX_E3B0_MAX_NUM_COS_PORT0; |
| 934 | |
| 935 | if (DCBX_INVALID_COS != sp_pri_to_cos[pri]) { |
| 936 | DP(NETIF_MSG_LINK, "bnx2x_ets_e3b0_sp_pri_to_cos_set invalid " |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 937 | "parameter There can't be two COS's with " |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 938 | "the same strict pri\n"); |
| 939 | return -EINVAL; |
| 940 | } |
| 941 | |
| 942 | if (pri > max_num_of_cos) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 943 | DP(NETIF_MSG_LINK, "bnx2x_ets_e3b0_sp_pri_to_cos_set invalid " |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 944 | "parameter Illegal strict priority\n"); |
| 945 | return -EINVAL; |
| 946 | } |
| 947 | |
| 948 | sp_pri_to_cos[pri] = cos_entry; |
| 949 | return 0; |
| 950 | |
| 951 | } |
| 952 | |
| 953 | /****************************************************************************** |
| 954 | * Description: |
| 955 | * Returns the correct value according to COS and priority in |
| 956 | * the sp_pri_cli register. |
| 957 | *. |
| 958 | ******************************************************************************/ |
| 959 | static u64 bnx2x_e3b0_sp_get_pri_cli_reg(const u8 cos, const u8 cos_offset, |
| 960 | const u8 pri_set, |
| 961 | const u8 pri_offset, |
| 962 | const u8 entry_size) |
| 963 | { |
| 964 | u64 pri_cli_nig = 0; |
| 965 | pri_cli_nig = ((u64)(cos + cos_offset)) << (entry_size * |
| 966 | (pri_set + pri_offset)); |
| 967 | |
| 968 | return pri_cli_nig; |
| 969 | } |
| 970 | /****************************************************************************** |
| 971 | * Description: |
| 972 | * Returns the correct value according to COS and priority in the |
| 973 | * sp_pri_cli register for NIG. |
| 974 | *. |
| 975 | ******************************************************************************/ |
| 976 | static u64 bnx2x_e3b0_sp_get_pri_cli_reg_nig(const u8 cos, const u8 pri_set) |
| 977 | { |
| 978 | /* MCP Dbg0 and dbg1 are always with higher strict pri*/ |
| 979 | const u8 nig_cos_offset = 3; |
| 980 | const u8 nig_pri_offset = 3; |
| 981 | |
| 982 | return bnx2x_e3b0_sp_get_pri_cli_reg(cos, nig_cos_offset, pri_set, |
| 983 | nig_pri_offset, 4); |
| 984 | |
| 985 | } |
| 986 | /****************************************************************************** |
| 987 | * Description: |
| 988 | * Returns the correct value according to COS and priority in the |
| 989 | * sp_pri_cli register for PBF. |
| 990 | *. |
| 991 | ******************************************************************************/ |
| 992 | static u64 bnx2x_e3b0_sp_get_pri_cli_reg_pbf(const u8 cos, const u8 pri_set) |
| 993 | { |
| 994 | const u8 pbf_cos_offset = 0; |
| 995 | const u8 pbf_pri_offset = 0; |
| 996 | |
| 997 | return bnx2x_e3b0_sp_get_pri_cli_reg(cos, pbf_cos_offset, pri_set, |
| 998 | pbf_pri_offset, 3); |
| 999 | |
| 1000 | } |
| 1001 | |
| 1002 | /****************************************************************************** |
| 1003 | * Description: |
| 1004 | * Calculate and set the SP (ARB_PRIORITY_CLIENT) NIG and PBF registers |
| 1005 | * according to sp_pri_to_cos.(which COS has higher priority) |
| 1006 | *. |
| 1007 | ******************************************************************************/ |
| 1008 | static int bnx2x_ets_e3b0_sp_set_pri_cli_reg(const struct link_params *params, |
| 1009 | u8 *sp_pri_to_cos) |
| 1010 | { |
| 1011 | struct bnx2x *bp = params->bp; |
| 1012 | u8 i = 0; |
| 1013 | const u8 port = params->port; |
| 1014 | /* MCP Dbg0 and dbg1 are always with higher strict pri*/ |
| 1015 | u64 pri_cli_nig = 0x210; |
| 1016 | u32 pri_cli_pbf = 0x0; |
| 1017 | u8 pri_set = 0; |
| 1018 | u8 pri_bitmask = 0; |
| 1019 | const u8 max_num_of_cos = (port) ? DCBX_E3B0_MAX_NUM_COS_PORT1 : |
| 1020 | DCBX_E3B0_MAX_NUM_COS_PORT0; |
| 1021 | |
| 1022 | u8 cos_bit_to_set = (1 << max_num_of_cos) - 1; |
| 1023 | |
| 1024 | /* Set all the strict priority first */ |
| 1025 | for (i = 0; i < max_num_of_cos; i++) { |
| 1026 | if (DCBX_INVALID_COS != sp_pri_to_cos[i]) { |
| 1027 | if (DCBX_MAX_NUM_COS <= sp_pri_to_cos[i]) { |
| 1028 | DP(NETIF_MSG_LINK, |
| 1029 | "bnx2x_ets_e3b0_sp_set_pri_cli_reg " |
| 1030 | "invalid cos entry\n"); |
| 1031 | return -EINVAL; |
| 1032 | } |
| 1033 | |
| 1034 | pri_cli_nig |= bnx2x_e3b0_sp_get_pri_cli_reg_nig( |
| 1035 | sp_pri_to_cos[i], pri_set); |
| 1036 | |
| 1037 | pri_cli_pbf |= bnx2x_e3b0_sp_get_pri_cli_reg_pbf( |
| 1038 | sp_pri_to_cos[i], pri_set); |
| 1039 | pri_bitmask = 1 << sp_pri_to_cos[i]; |
| 1040 | /* COS is used remove it from bitmap.*/ |
| 1041 | if (0 == (pri_bitmask & cos_bit_to_set)) { |
| 1042 | DP(NETIF_MSG_LINK, |
| 1043 | "bnx2x_ets_e3b0_sp_set_pri_cli_reg " |
| 1044 | "invalid There can't be two COS's with" |
| 1045 | " the same strict pri\n"); |
| 1046 | return -EINVAL; |
| 1047 | } |
| 1048 | cos_bit_to_set &= ~pri_bitmask; |
| 1049 | pri_set++; |
| 1050 | } |
| 1051 | } |
| 1052 | |
| 1053 | /* Set all the Non strict priority i= COS*/ |
| 1054 | for (i = 0; i < max_num_of_cos; i++) { |
| 1055 | pri_bitmask = 1 << i; |
| 1056 | /* Check if COS was already used for SP */ |
| 1057 | if (pri_bitmask & cos_bit_to_set) { |
| 1058 | /* COS wasn't used for SP */ |
| 1059 | pri_cli_nig |= bnx2x_e3b0_sp_get_pri_cli_reg_nig( |
| 1060 | i, pri_set); |
| 1061 | |
| 1062 | pri_cli_pbf |= bnx2x_e3b0_sp_get_pri_cli_reg_pbf( |
| 1063 | i, pri_set); |
| 1064 | /* COS is used remove it from bitmap.*/ |
| 1065 | cos_bit_to_set &= ~pri_bitmask; |
| 1066 | pri_set++; |
| 1067 | } |
| 1068 | } |
| 1069 | |
| 1070 | if (pri_set != max_num_of_cos) { |
| 1071 | DP(NETIF_MSG_LINK, "bnx2x_ets_e3b0_sp_set_pri_cli_reg not all " |
| 1072 | "entries were set\n"); |
| 1073 | return -EINVAL; |
| 1074 | } |
| 1075 | |
| 1076 | if (port) { |
| 1077 | /* Only 6 usable clients*/ |
| 1078 | REG_WR(bp, NIG_REG_P1_TX_ARB_PRIORITY_CLIENT2_LSB, |
| 1079 | (u32)pri_cli_nig); |
| 1080 | |
| 1081 | REG_WR(bp, PBF_REG_ETS_ARB_PRIORITY_CLIENT_P1 , pri_cli_pbf); |
| 1082 | } else { |
| 1083 | /* Only 9 usable clients*/ |
| 1084 | const u32 pri_cli_nig_lsb = (u32) (pri_cli_nig); |
| 1085 | const u32 pri_cli_nig_msb = (u32) ((pri_cli_nig >> 32) & 0xF); |
| 1086 | |
| 1087 | REG_WR(bp, NIG_REG_P0_TX_ARB_PRIORITY_CLIENT2_LSB, |
| 1088 | pri_cli_nig_lsb); |
| 1089 | REG_WR(bp, NIG_REG_P0_TX_ARB_PRIORITY_CLIENT2_MSB, |
| 1090 | pri_cli_nig_msb); |
| 1091 | |
| 1092 | REG_WR(bp, PBF_REG_ETS_ARB_PRIORITY_CLIENT_P0 , pri_cli_pbf); |
| 1093 | } |
| 1094 | return 0; |
| 1095 | } |
| 1096 | |
| 1097 | /****************************************************************************** |
| 1098 | * Description: |
| 1099 | * Configure the COS to ETS according to BW and SP settings. |
| 1100 | ******************************************************************************/ |
| 1101 | int bnx2x_ets_e3b0_config(const struct link_params *params, |
| 1102 | const struct link_vars *vars, |
| 1103 | const struct bnx2x_ets_params *ets_params) |
| 1104 | { |
| 1105 | struct bnx2x *bp = params->bp; |
| 1106 | int bnx2x_status = 0; |
| 1107 | const u8 port = params->port; |
| 1108 | u16 total_bw = 0; |
| 1109 | const u32 min_w_val_nig = bnx2x_ets_get_min_w_val_nig(vars); |
| 1110 | const u32 min_w_val_pbf = ETS_E3B0_PBF_MIN_W_VAL; |
| 1111 | u8 cos_bw_bitmap = 0; |
| 1112 | u8 cos_sp_bitmap = 0; |
| 1113 | u8 sp_pri_to_cos[DCBX_MAX_NUM_COS] = {0}; |
| 1114 | const u8 max_num_of_cos = (port) ? DCBX_E3B0_MAX_NUM_COS_PORT1 : |
| 1115 | DCBX_E3B0_MAX_NUM_COS_PORT0; |
| 1116 | u8 cos_entry = 0; |
| 1117 | |
| 1118 | if (!CHIP_IS_E3B0(bp)) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 1119 | DP(NETIF_MSG_LINK, |
| 1120 | "bnx2x_ets_e3b0_disabled the chip isn't E3B0\n"); |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 1121 | return -EINVAL; |
| 1122 | } |
| 1123 | |
| 1124 | if ((ets_params->num_of_cos > max_num_of_cos)) { |
| 1125 | DP(NETIF_MSG_LINK, "bnx2x_ets_E3B0_config the number of COS " |
| 1126 | "isn't supported\n"); |
| 1127 | return -EINVAL; |
| 1128 | } |
| 1129 | |
| 1130 | /* Prepare sp strict priority parameters*/ |
| 1131 | bnx2x_ets_e3b0_sp_pri_to_cos_init(sp_pri_to_cos); |
| 1132 | |
| 1133 | /* Prepare BW parameters*/ |
| 1134 | bnx2x_status = bnx2x_ets_e3b0_get_total_bw(params, ets_params, |
| 1135 | &total_bw); |
| 1136 | if (0 != bnx2x_status) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 1137 | DP(NETIF_MSG_LINK, |
| 1138 | "bnx2x_ets_E3B0_config get_total_bw failed\n"); |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 1139 | return -EINVAL; |
| 1140 | } |
| 1141 | |
| 1142 | /** |
| 1143 | * Upper bound is set according to current link speed (min_w_val |
| 1144 | * should be the same for upper bound and COS credit val). |
| 1145 | */ |
| 1146 | bnx2x_ets_e3b0_set_credit_upper_bound_nig(params, min_w_val_nig); |
| 1147 | bnx2x_ets_e3b0_set_credit_upper_bound_pbf(params, min_w_val_pbf); |
| 1148 | |
| 1149 | |
| 1150 | for (cos_entry = 0; cos_entry < ets_params->num_of_cos; cos_entry++) { |
| 1151 | if (bnx2x_cos_state_bw == ets_params->cos[cos_entry].state) { |
| 1152 | cos_bw_bitmap |= (1 << cos_entry); |
| 1153 | /** |
| 1154 | * The function also sets the BW in HW(not the mappin |
| 1155 | * yet) |
| 1156 | */ |
| 1157 | bnx2x_status = bnx2x_ets_e3b0_set_cos_bw( |
| 1158 | bp, cos_entry, min_w_val_nig, min_w_val_pbf, |
| 1159 | total_bw, |
| 1160 | ets_params->cos[cos_entry].params.bw_params.bw, |
| 1161 | port); |
| 1162 | } else if (bnx2x_cos_state_strict == |
| 1163 | ets_params->cos[cos_entry].state){ |
| 1164 | cos_sp_bitmap |= (1 << cos_entry); |
| 1165 | |
| 1166 | bnx2x_status = bnx2x_ets_e3b0_sp_pri_to_cos_set( |
| 1167 | params, |
| 1168 | sp_pri_to_cos, |
| 1169 | ets_params->cos[cos_entry].params.sp_params.pri, |
| 1170 | cos_entry); |
| 1171 | |
| 1172 | } else { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 1173 | DP(NETIF_MSG_LINK, |
| 1174 | "bnx2x_ets_e3b0_config cos state not valid\n"); |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 1175 | return -EINVAL; |
| 1176 | } |
| 1177 | if (0 != bnx2x_status) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 1178 | DP(NETIF_MSG_LINK, |
| 1179 | "bnx2x_ets_e3b0_config set cos bw failed\n"); |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 1180 | return bnx2x_status; |
| 1181 | } |
| 1182 | } |
| 1183 | |
| 1184 | /* Set SP register (which COS has higher priority) */ |
| 1185 | bnx2x_status = bnx2x_ets_e3b0_sp_set_pri_cli_reg(params, |
| 1186 | sp_pri_to_cos); |
| 1187 | |
| 1188 | if (0 != bnx2x_status) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 1189 | DP(NETIF_MSG_LINK, |
| 1190 | "bnx2x_ets_E3B0_config set_pri_cli_reg failed\n"); |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 1191 | return bnx2x_status; |
| 1192 | } |
| 1193 | |
| 1194 | /* Set client mapping of BW and strict */ |
| 1195 | bnx2x_status = bnx2x_ets_e3b0_cli_map(params, ets_params, |
| 1196 | cos_sp_bitmap, |
| 1197 | cos_bw_bitmap); |
| 1198 | |
| 1199 | if (0 != bnx2x_status) { |
| 1200 | DP(NETIF_MSG_LINK, "bnx2x_ets_E3B0_config SP failed\n"); |
| 1201 | return bnx2x_status; |
| 1202 | } |
| 1203 | return 0; |
| 1204 | } |
Yaniv Rosner | 65a001b | 2011-01-31 04:22:03 +0000 | [diff] [blame] | 1205 | static void bnx2x_ets_bw_limit_common(const struct link_params *params) |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1206 | { |
| 1207 | /* ETS disabled configuration */ |
| 1208 | struct bnx2x *bp = params->bp; |
| 1209 | DP(NETIF_MSG_LINK, "ETS enabled BW limit configuration\n"); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 1210 | /* |
| 1211 | * defines which entries (clients) are subjected to WFQ arbitration |
| 1212 | * COS0 0x8 |
| 1213 | * COS1 0x10 |
| 1214 | */ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1215 | REG_WR(bp, NIG_REG_P0_TX_ARB_CLIENT_IS_SUBJECT2WFQ, 0x18); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 1216 | /* |
| 1217 | * mapping between the ARB_CREDIT_WEIGHT registers and actual |
| 1218 | * client numbers (WEIGHT_0 does not actually have to represent |
| 1219 | * client 0) |
| 1220 | * PRI4 | PRI3 | PRI2 | PRI1 | PRI0 |
| 1221 | * cos1-001 cos0-000 dbg1-100 dbg0-011 MCP-010 |
| 1222 | */ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1223 | REG_WR(bp, NIG_REG_P0_TX_ARB_CLIENT_CREDIT_MAP, 0x111A); |
| 1224 | |
| 1225 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_0, |
| 1226 | ETS_BW_LIMIT_CREDIT_UPPER_BOUND); |
| 1227 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_1, |
| 1228 | ETS_BW_LIMIT_CREDIT_UPPER_BOUND); |
| 1229 | |
| 1230 | /* ETS mode enabled*/ |
| 1231 | REG_WR(bp, PBF_REG_ETS_ENABLED, 1); |
| 1232 | |
| 1233 | /* Defines the number of consecutive slots for the strict priority */ |
| 1234 | REG_WR(bp, PBF_REG_NUM_STRICT_ARB_SLOTS, 0); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 1235 | /* |
| 1236 | * Bitmap of 5bits length. Each bit specifies whether the entry behaves |
| 1237 | * as strict. Bits 0,1,2 - debug and management entries, 3 - COS0 |
| 1238 | * entry, 4 - COS1 entry. |
| 1239 | * COS1 | COS0 | DEBUG21 | DEBUG0 | MGMT |
| 1240 | * bit4 bit3 bit2 bit1 bit0 |
| 1241 | * MCP and debug are strict |
| 1242 | */ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1243 | REG_WR(bp, NIG_REG_P0_TX_ARB_CLIENT_IS_STRICT, 0x7); |
| 1244 | |
| 1245 | /* Upper bound that COS0_WEIGHT can reach in the WFQ arbiter.*/ |
| 1246 | REG_WR(bp, PBF_REG_COS0_UPPER_BOUND, |
| 1247 | ETS_BW_LIMIT_CREDIT_UPPER_BOUND); |
| 1248 | REG_WR(bp, PBF_REG_COS1_UPPER_BOUND, |
| 1249 | ETS_BW_LIMIT_CREDIT_UPPER_BOUND); |
| 1250 | } |
| 1251 | |
| 1252 | void bnx2x_ets_bw_limit(const struct link_params *params, const u32 cos0_bw, |
| 1253 | const u32 cos1_bw) |
| 1254 | { |
| 1255 | /* ETS disabled configuration*/ |
| 1256 | struct bnx2x *bp = params->bp; |
| 1257 | const u32 total_bw = cos0_bw + cos1_bw; |
| 1258 | u32 cos0_credit_weight = 0; |
| 1259 | u32 cos1_credit_weight = 0; |
| 1260 | |
| 1261 | DP(NETIF_MSG_LINK, "ETS enabled BW limit configuration\n"); |
| 1262 | |
| 1263 | if ((0 == total_bw) || |
| 1264 | (0 == cos0_bw) || |
| 1265 | (0 == cos1_bw)) { |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1266 | DP(NETIF_MSG_LINK, "Total BW can't be zero\n"); |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1267 | return; |
| 1268 | } |
| 1269 | |
| 1270 | cos0_credit_weight = (cos0_bw * ETS_BW_LIMIT_CREDIT_WEIGHT)/ |
| 1271 | total_bw; |
| 1272 | cos1_credit_weight = (cos1_bw * ETS_BW_LIMIT_CREDIT_WEIGHT)/ |
| 1273 | total_bw; |
| 1274 | |
| 1275 | bnx2x_ets_bw_limit_common(params); |
| 1276 | |
| 1277 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_0, cos0_credit_weight); |
| 1278 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_1, cos1_credit_weight); |
| 1279 | |
| 1280 | REG_WR(bp, PBF_REG_COS0_WEIGHT, cos0_credit_weight); |
| 1281 | REG_WR(bp, PBF_REG_COS1_WEIGHT, cos1_credit_weight); |
| 1282 | } |
| 1283 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 1284 | 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] | 1285 | { |
| 1286 | /* ETS disabled configuration*/ |
| 1287 | struct bnx2x *bp = params->bp; |
| 1288 | u32 val = 0; |
| 1289 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1290 | DP(NETIF_MSG_LINK, "ETS enabled strict configuration\n"); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 1291 | /* |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1292 | * Bitmap of 5bits length. Each bit specifies whether the entry behaves |
| 1293 | * as strict. Bits 0,1,2 - debug and management entries, |
| 1294 | * 3 - COS0 entry, 4 - COS1 entry. |
| 1295 | * COS1 | COS0 | DEBUG21 | DEBUG0 | MGMT |
| 1296 | * bit4 bit3 bit2 bit1 bit0 |
| 1297 | * MCP and debug are strict |
| 1298 | */ |
| 1299 | REG_WR(bp, NIG_REG_P0_TX_ARB_CLIENT_IS_STRICT, 0x1F); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 1300 | /* |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1301 | * For strict priority entries defines the number of consecutive slots |
| 1302 | * for the highest priority. |
| 1303 | */ |
| 1304 | REG_WR(bp, NIG_REG_P0_TX_ARB_NUM_STRICT_ARB_SLOTS, 0x100); |
| 1305 | /* ETS mode disable */ |
| 1306 | REG_WR(bp, PBF_REG_ETS_ENABLED, 0); |
| 1307 | /* Defines the number of consecutive slots for the strict priority */ |
| 1308 | REG_WR(bp, PBF_REG_NUM_STRICT_ARB_SLOTS, 0x100); |
| 1309 | |
| 1310 | /* Defines the number of consecutive slots for the strict priority */ |
| 1311 | REG_WR(bp, PBF_REG_HIGH_PRIORITY_COS_NUM, strict_cos); |
| 1312 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 1313 | /* |
| 1314 | * mapping between entry priority to client number (0,1,2 -debug and |
| 1315 | * management clients, 3 - COS0 client, 4 - COS client)(HIGHEST) |
| 1316 | * 3bits client num. |
| 1317 | * PRI4 | PRI3 | PRI2 | PRI1 | PRI0 |
| 1318 | * dbg0-010 dbg1-001 cos1-100 cos0-011 MCP-000 |
| 1319 | * dbg0-010 dbg1-001 cos0-011 cos1-100 MCP-000 |
| 1320 | */ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1321 | val = (0 == strict_cos) ? 0x2318 : 0x22E0; |
| 1322 | REG_WR(bp, NIG_REG_P0_TX_ARB_PRIORITY_CLIENT, val); |
| 1323 | |
| 1324 | return 0; |
| 1325 | } |
| 1326 | /******************************************************************/ |
Dmitry Kravkov | e892067 | 2011-05-04 23:52:40 +0000 | [diff] [blame] | 1327 | /* PFC section */ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1328 | /******************************************************************/ |
| 1329 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1330 | static void bnx2x_update_pfc_xmac(struct link_params *params, |
| 1331 | struct link_vars *vars, |
| 1332 | u8 is_lb) |
| 1333 | { |
| 1334 | struct bnx2x *bp = params->bp; |
| 1335 | u32 xmac_base; |
| 1336 | u32 pause_val, pfc0_val, pfc1_val; |
| 1337 | |
| 1338 | /* XMAC base adrr */ |
| 1339 | xmac_base = (params->port) ? GRCBASE_XMAC1 : GRCBASE_XMAC0; |
| 1340 | |
| 1341 | /* Initialize pause and pfc registers */ |
| 1342 | pause_val = 0x18000; |
| 1343 | pfc0_val = 0xFFFF8000; |
| 1344 | pfc1_val = 0x2; |
| 1345 | |
| 1346 | /* No PFC support */ |
| 1347 | if (!(params->feature_config_flags & |
| 1348 | FEATURE_CONFIG_PFC_ENABLED)) { |
| 1349 | |
| 1350 | /* |
| 1351 | * RX flow control - Process pause frame in receive direction |
| 1352 | */ |
| 1353 | if (vars->flow_ctrl & BNX2X_FLOW_CTRL_RX) |
| 1354 | pause_val |= XMAC_PAUSE_CTRL_REG_RX_PAUSE_EN; |
| 1355 | |
| 1356 | /* |
| 1357 | * TX flow control - Send pause packet when buffer is full |
| 1358 | */ |
| 1359 | if (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX) |
| 1360 | pause_val |= XMAC_PAUSE_CTRL_REG_TX_PAUSE_EN; |
| 1361 | } else {/* PFC support */ |
| 1362 | pfc1_val |= XMAC_PFC_CTRL_HI_REG_PFC_REFRESH_EN | |
| 1363 | XMAC_PFC_CTRL_HI_REG_PFC_STATS_EN | |
| 1364 | XMAC_PFC_CTRL_HI_REG_RX_PFC_EN | |
| 1365 | XMAC_PFC_CTRL_HI_REG_TX_PFC_EN; |
| 1366 | } |
| 1367 | |
| 1368 | /* Write pause and PFC registers */ |
| 1369 | REG_WR(bp, xmac_base + XMAC_REG_PAUSE_CTRL, pause_val); |
| 1370 | REG_WR(bp, xmac_base + XMAC_REG_PFC_CTRL, pfc0_val); |
| 1371 | REG_WR(bp, xmac_base + XMAC_REG_PFC_CTRL_HI, pfc1_val); |
| 1372 | |
Yaniv Rosner | b8d6d08 | 2011-07-05 01:06:27 +0000 | [diff] [blame] | 1373 | |
| 1374 | /* Set MAC address for source TX Pause/PFC frames */ |
| 1375 | REG_WR(bp, xmac_base + XMAC_REG_CTRL_SA_LO, |
| 1376 | ((params->mac_addr[2] << 24) | |
| 1377 | (params->mac_addr[3] << 16) | |
| 1378 | (params->mac_addr[4] << 8) | |
| 1379 | (params->mac_addr[5]))); |
| 1380 | REG_WR(bp, xmac_base + XMAC_REG_CTRL_SA_HI, |
| 1381 | ((params->mac_addr[0] << 8) | |
| 1382 | (params->mac_addr[1]))); |
| 1383 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1384 | udelay(30); |
| 1385 | } |
| 1386 | |
| 1387 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1388 | static void bnx2x_emac_get_pfc_stat(struct link_params *params, |
| 1389 | u32 pfc_frames_sent[2], |
| 1390 | u32 pfc_frames_received[2]) |
| 1391 | { |
| 1392 | /* Read pfc statistic */ |
| 1393 | struct bnx2x *bp = params->bp; |
| 1394 | u32 emac_base = params->port ? GRCBASE_EMAC1 : GRCBASE_EMAC0; |
| 1395 | u32 val_xon = 0; |
| 1396 | u32 val_xoff = 0; |
| 1397 | |
| 1398 | DP(NETIF_MSG_LINK, "pfc statistic read from EMAC\n"); |
| 1399 | |
| 1400 | /* PFC received frames */ |
| 1401 | val_xoff = REG_RD(bp, emac_base + |
| 1402 | EMAC_REG_RX_PFC_STATS_XOFF_RCVD); |
| 1403 | val_xoff &= EMAC_REG_RX_PFC_STATS_XOFF_RCVD_COUNT; |
| 1404 | val_xon = REG_RD(bp, emac_base + EMAC_REG_RX_PFC_STATS_XON_RCVD); |
| 1405 | val_xon &= EMAC_REG_RX_PFC_STATS_XON_RCVD_COUNT; |
| 1406 | |
| 1407 | pfc_frames_received[0] = val_xon + val_xoff; |
| 1408 | |
| 1409 | /* PFC received sent */ |
| 1410 | val_xoff = REG_RD(bp, emac_base + |
| 1411 | EMAC_REG_RX_PFC_STATS_XOFF_SENT); |
| 1412 | val_xoff &= EMAC_REG_RX_PFC_STATS_XOFF_SENT_COUNT; |
| 1413 | val_xon = REG_RD(bp, emac_base + EMAC_REG_RX_PFC_STATS_XON_SENT); |
| 1414 | val_xon &= EMAC_REG_RX_PFC_STATS_XON_SENT_COUNT; |
| 1415 | |
| 1416 | pfc_frames_sent[0] = val_xon + val_xoff; |
| 1417 | } |
| 1418 | |
Yaniv Rosner | b8d6d08 | 2011-07-05 01:06:27 +0000 | [diff] [blame] | 1419 | /* Read pfc statistic*/ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1420 | void bnx2x_pfc_statistic(struct link_params *params, struct link_vars *vars, |
| 1421 | u32 pfc_frames_sent[2], |
| 1422 | u32 pfc_frames_received[2]) |
| 1423 | { |
| 1424 | /* Read pfc statistic */ |
| 1425 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | b8d6d08 | 2011-07-05 01:06:27 +0000 | [diff] [blame] | 1426 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1427 | DP(NETIF_MSG_LINK, "pfc statistic\n"); |
| 1428 | |
| 1429 | if (!vars->link_up) |
| 1430 | return; |
| 1431 | |
Yaniv Rosner | b8d6d08 | 2011-07-05 01:06:27 +0000 | [diff] [blame] | 1432 | if (MAC_TYPE_EMAC == vars->mac_type) { |
| 1433 | DP(NETIF_MSG_LINK, "About to read PFC stats from EMAC\n"); |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1434 | bnx2x_emac_get_pfc_stat(params, pfc_frames_sent, |
| 1435 | pfc_frames_received); |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1436 | } |
| 1437 | } |
| 1438 | /******************************************************************/ |
| 1439 | /* MAC/PBF section */ |
| 1440 | /******************************************************************/ |
Yaniv Rosner | a198c14 | 2011-05-31 21:29:42 +0000 | [diff] [blame] | 1441 | static void bnx2x_set_mdio_clk(struct bnx2x *bp, u32 chip_id, u8 port) |
| 1442 | { |
| 1443 | u32 mode, emac_base; |
| 1444 | /** |
| 1445 | * Set clause 45 mode, slow down the MDIO clock to 2.5MHz |
| 1446 | * (a value of 49==0x31) and make sure that the AUTO poll is off |
| 1447 | */ |
| 1448 | |
| 1449 | if (CHIP_IS_E2(bp)) |
| 1450 | emac_base = GRCBASE_EMAC0; |
| 1451 | else |
| 1452 | emac_base = (port) ? GRCBASE_EMAC1 : GRCBASE_EMAC0; |
| 1453 | mode = REG_RD(bp, emac_base + EMAC_REG_EMAC_MDIO_MODE); |
| 1454 | mode &= ~(EMAC_MDIO_MODE_AUTO_POLL | |
| 1455 | EMAC_MDIO_MODE_CLOCK_CNT); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 1456 | if (USES_WARPCORE(bp)) |
| 1457 | mode |= (74L << EMAC_MDIO_MODE_CLOCK_CNT_BITSHIFT); |
| 1458 | else |
| 1459 | mode |= (49L << EMAC_MDIO_MODE_CLOCK_CNT_BITSHIFT); |
Yaniv Rosner | a198c14 | 2011-05-31 21:29:42 +0000 | [diff] [blame] | 1460 | |
| 1461 | mode |= (EMAC_MDIO_MODE_CLAUSE_45); |
| 1462 | REG_WR(bp, emac_base + EMAC_REG_EMAC_MDIO_MODE, mode); |
| 1463 | |
| 1464 | udelay(40); |
| 1465 | } |
| 1466 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1467 | static void bnx2x_emac_init(struct link_params *params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1468 | struct link_vars *vars) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1469 | { |
| 1470 | /* reset and unreset the emac core */ |
| 1471 | struct bnx2x *bp = params->bp; |
| 1472 | u8 port = params->port; |
| 1473 | u32 emac_base = port ? GRCBASE_EMAC1 : GRCBASE_EMAC0; |
| 1474 | u32 val; |
| 1475 | u16 timeout; |
| 1476 | |
| 1477 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_CLEAR, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1478 | (MISC_REGISTERS_RESET_REG_2_RST_EMAC0_HARD_CORE << port)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1479 | udelay(5); |
| 1480 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_SET, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1481 | (MISC_REGISTERS_RESET_REG_2_RST_EMAC0_HARD_CORE << port)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1482 | |
| 1483 | /* init emac - use read-modify-write */ |
| 1484 | /* self clear reset */ |
| 1485 | val = REG_RD(bp, emac_base + EMAC_REG_EMAC_MODE); |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 1486 | EMAC_WR(bp, EMAC_REG_EMAC_MODE, (val | EMAC_MODE_RESET)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1487 | |
| 1488 | timeout = 200; |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 1489 | do { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1490 | val = REG_RD(bp, emac_base + EMAC_REG_EMAC_MODE); |
| 1491 | DP(NETIF_MSG_LINK, "EMAC reset reg is %u\n", val); |
| 1492 | if (!timeout) { |
| 1493 | DP(NETIF_MSG_LINK, "EMAC timeout!\n"); |
| 1494 | return; |
| 1495 | } |
| 1496 | timeout--; |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 1497 | } while (val & EMAC_MODE_RESET); |
Yaniv Rosner | a198c14 | 2011-05-31 21:29:42 +0000 | [diff] [blame] | 1498 | bnx2x_set_mdio_clk(bp, params->chip_id, port); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1499 | /* Set mac address */ |
| 1500 | val = ((params->mac_addr[0] << 8) | |
| 1501 | params->mac_addr[1]); |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 1502 | EMAC_WR(bp, EMAC_REG_EMAC_MAC_MATCH, val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1503 | |
| 1504 | val = ((params->mac_addr[2] << 24) | |
| 1505 | (params->mac_addr[3] << 16) | |
| 1506 | (params->mac_addr[4] << 8) | |
| 1507 | params->mac_addr[5]); |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 1508 | EMAC_WR(bp, EMAC_REG_EMAC_MAC_MATCH + 4, val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1509 | } |
| 1510 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1511 | static void bnx2x_set_xumac_nig(struct link_params *params, |
| 1512 | u16 tx_pause_en, |
| 1513 | u8 enable) |
| 1514 | { |
| 1515 | struct bnx2x *bp = params->bp; |
| 1516 | |
| 1517 | REG_WR(bp, params->port ? NIG_REG_P1_MAC_IN_EN : NIG_REG_P0_MAC_IN_EN, |
| 1518 | enable); |
| 1519 | REG_WR(bp, params->port ? NIG_REG_P1_MAC_OUT_EN : NIG_REG_P0_MAC_OUT_EN, |
| 1520 | enable); |
| 1521 | REG_WR(bp, params->port ? NIG_REG_P1_MAC_PAUSE_OUT_EN : |
| 1522 | NIG_REG_P0_MAC_PAUSE_OUT_EN, tx_pause_en); |
| 1523 | } |
| 1524 | |
Yaniv Rosner | ce7c048 | 2011-10-27 05:09:47 +0000 | [diff] [blame] | 1525 | static void bnx2x_umac_disable(struct link_params *params) |
| 1526 | { |
| 1527 | u32 umac_base = params->port ? GRCBASE_UMAC1 : GRCBASE_UMAC0; |
| 1528 | struct bnx2x *bp = params->bp; |
| 1529 | if (!(REG_RD(bp, MISC_REG_RESET_REG_2) & |
| 1530 | (MISC_REGISTERS_RESET_REG_2_UMAC0 << params->port))) |
| 1531 | return; |
| 1532 | |
| 1533 | /* Disable RX and TX */ |
| 1534 | REG_WR(bp, umac_base + UMAC_REG_COMMAND_CONFIG, 0); |
| 1535 | } |
| 1536 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1537 | static void bnx2x_umac_enable(struct link_params *params, |
| 1538 | struct link_vars *vars, u8 lb) |
| 1539 | { |
| 1540 | u32 val; |
| 1541 | u32 umac_base = params->port ? GRCBASE_UMAC1 : GRCBASE_UMAC0; |
| 1542 | struct bnx2x *bp = params->bp; |
| 1543 | /* Reset UMAC */ |
| 1544 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_CLEAR, |
| 1545 | (MISC_REGISTERS_RESET_REG_2_UMAC0 << params->port)); |
| 1546 | usleep_range(1000, 1000); |
| 1547 | |
| 1548 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_SET, |
| 1549 | (MISC_REGISTERS_RESET_REG_2_UMAC0 << params->port)); |
| 1550 | |
| 1551 | DP(NETIF_MSG_LINK, "enabling UMAC\n"); |
| 1552 | |
| 1553 | /** |
| 1554 | * This register determines on which events the MAC will assert |
| 1555 | * error on the i/f to the NIG along w/ EOP. |
| 1556 | */ |
| 1557 | |
| 1558 | /** |
| 1559 | * BD REG_WR(bp, NIG_REG_P0_MAC_RSV_ERR_MASK + |
| 1560 | * params->port*0x14, 0xfffff. |
| 1561 | */ |
| 1562 | /* This register opens the gate for the UMAC despite its name */ |
| 1563 | REG_WR(bp, NIG_REG_EGRESS_EMAC0_PORT + params->port*4, 1); |
| 1564 | |
| 1565 | val = UMAC_COMMAND_CONFIG_REG_PROMIS_EN | |
| 1566 | UMAC_COMMAND_CONFIG_REG_PAD_EN | |
| 1567 | UMAC_COMMAND_CONFIG_REG_SW_RESET | |
| 1568 | UMAC_COMMAND_CONFIG_REG_NO_LGTH_CHECK; |
| 1569 | switch (vars->line_speed) { |
| 1570 | case SPEED_10: |
| 1571 | val |= (0<<2); |
| 1572 | break; |
| 1573 | case SPEED_100: |
| 1574 | val |= (1<<2); |
| 1575 | break; |
| 1576 | case SPEED_1000: |
| 1577 | val |= (2<<2); |
| 1578 | break; |
| 1579 | case SPEED_2500: |
| 1580 | val |= (3<<2); |
| 1581 | break; |
| 1582 | default: |
| 1583 | DP(NETIF_MSG_LINK, "Invalid speed for UMAC %d\n", |
| 1584 | vars->line_speed); |
| 1585 | break; |
| 1586 | } |
Yaniv Rosner | 9d5b36b | 2011-08-02 22:59:10 +0000 | [diff] [blame] | 1587 | if (!(vars->flow_ctrl & BNX2X_FLOW_CTRL_TX)) |
| 1588 | val |= UMAC_COMMAND_CONFIG_REG_IGNORE_TX_PAUSE; |
| 1589 | |
| 1590 | if (!(vars->flow_ctrl & BNX2X_FLOW_CTRL_RX)) |
| 1591 | val |= UMAC_COMMAND_CONFIG_REG_PAUSE_IGNORE; |
| 1592 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1593 | REG_WR(bp, umac_base + UMAC_REG_COMMAND_CONFIG, val); |
| 1594 | udelay(50); |
| 1595 | |
Yaniv Rosner | b8d6d08 | 2011-07-05 01:06:27 +0000 | [diff] [blame] | 1596 | /* Set MAC address for source TX Pause/PFC frames (under SW reset) */ |
| 1597 | REG_WR(bp, umac_base + UMAC_REG_MAC_ADDR0, |
| 1598 | ((params->mac_addr[2] << 24) | |
| 1599 | (params->mac_addr[3] << 16) | |
| 1600 | (params->mac_addr[4] << 8) | |
| 1601 | (params->mac_addr[5]))); |
| 1602 | REG_WR(bp, umac_base + UMAC_REG_MAC_ADDR1, |
| 1603 | ((params->mac_addr[0] << 8) | |
| 1604 | (params->mac_addr[1]))); |
| 1605 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1606 | /* Enable RX and TX */ |
| 1607 | val &= ~UMAC_COMMAND_CONFIG_REG_PAD_EN; |
| 1608 | val |= UMAC_COMMAND_CONFIG_REG_TX_ENA | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 1609 | UMAC_COMMAND_CONFIG_REG_RX_ENA; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1610 | REG_WR(bp, umac_base + UMAC_REG_COMMAND_CONFIG, val); |
| 1611 | udelay(50); |
| 1612 | |
| 1613 | /* Remove SW Reset */ |
| 1614 | val &= ~UMAC_COMMAND_CONFIG_REG_SW_RESET; |
| 1615 | |
| 1616 | /* Check loopback mode */ |
| 1617 | if (lb) |
| 1618 | val |= UMAC_COMMAND_CONFIG_REG_LOOP_ENA; |
| 1619 | REG_WR(bp, umac_base + UMAC_REG_COMMAND_CONFIG, val); |
| 1620 | |
| 1621 | /* |
| 1622 | * Maximum Frame Length (RW). Defines a 14-Bit maximum frame |
| 1623 | * length used by the MAC receive logic to check frames. |
| 1624 | */ |
| 1625 | REG_WR(bp, umac_base + UMAC_REG_MAXFR, 0x2710); |
| 1626 | bnx2x_set_xumac_nig(params, |
| 1627 | ((vars->flow_ctrl & BNX2X_FLOW_CTRL_TX) != 0), 1); |
| 1628 | vars->mac_type = MAC_TYPE_UMAC; |
| 1629 | |
| 1630 | } |
| 1631 | |
| 1632 | static u8 bnx2x_is_4_port_mode(struct bnx2x *bp) |
| 1633 | { |
| 1634 | u32 port4mode_ovwr_val; |
| 1635 | /* Check 4-port override enabled */ |
| 1636 | port4mode_ovwr_val = REG_RD(bp, MISC_REG_PORT4MODE_EN_OVWR); |
| 1637 | if (port4mode_ovwr_val & (1<<0)) { |
| 1638 | /* Return 4-port mode override value */ |
| 1639 | return ((port4mode_ovwr_val & (1<<1)) == (1<<1)); |
| 1640 | } |
| 1641 | /* Return 4-port mode from input pin */ |
| 1642 | return (u8)REG_RD(bp, MISC_REG_PORT4MODE_EN); |
| 1643 | } |
| 1644 | |
| 1645 | /* Define the XMAC mode */ |
Yaniv Rosner | ce7c048 | 2011-10-27 05:09:47 +0000 | [diff] [blame] | 1646 | static void bnx2x_xmac_init(struct link_params *params, u32 max_speed) |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1647 | { |
Yaniv Rosner | ce7c048 | 2011-10-27 05:09:47 +0000 | [diff] [blame] | 1648 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1649 | u32 is_port4mode = bnx2x_is_4_port_mode(bp); |
| 1650 | |
| 1651 | /** |
| 1652 | * In 4-port mode, need to set the mode only once, so if XMAC is |
| 1653 | * already out of reset, it means the mode has already been set, |
| 1654 | * and it must not* reset the XMAC again, since it controls both |
| 1655 | * ports of the path |
| 1656 | **/ |
| 1657 | |
Yaniv Rosner | ce7c048 | 2011-10-27 05:09:47 +0000 | [diff] [blame] | 1658 | if ((CHIP_NUM(bp) == CHIP_NUM_57840) && |
| 1659 | (REG_RD(bp, MISC_REG_RESET_REG_2) & |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1660 | MISC_REGISTERS_RESET_REG_2_XMAC)) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 1661 | DP(NETIF_MSG_LINK, |
| 1662 | "XMAC already out of reset in 4-port mode\n"); |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1663 | return; |
| 1664 | } |
| 1665 | |
| 1666 | /* Hard reset */ |
| 1667 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_CLEAR, |
| 1668 | MISC_REGISTERS_RESET_REG_2_XMAC); |
| 1669 | usleep_range(1000, 1000); |
| 1670 | |
| 1671 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_SET, |
| 1672 | MISC_REGISTERS_RESET_REG_2_XMAC); |
| 1673 | if (is_port4mode) { |
| 1674 | DP(NETIF_MSG_LINK, "Init XMAC to 2 ports x 10G per path\n"); |
| 1675 | |
| 1676 | /* Set the number of ports on the system side to up to 2 */ |
| 1677 | REG_WR(bp, MISC_REG_XMAC_CORE_PORT_MODE, 1); |
| 1678 | |
| 1679 | /* Set the number of ports on the Warp Core to 10G */ |
| 1680 | REG_WR(bp, MISC_REG_XMAC_PHY_PORT_MODE, 3); |
| 1681 | } else { |
| 1682 | /* Set the number of ports on the system side to 1 */ |
| 1683 | REG_WR(bp, MISC_REG_XMAC_CORE_PORT_MODE, 0); |
| 1684 | if (max_speed == SPEED_10000) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 1685 | DP(NETIF_MSG_LINK, |
| 1686 | "Init XMAC to 10G x 1 port per path\n"); |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1687 | /* Set the number of ports on the Warp Core to 10G */ |
| 1688 | REG_WR(bp, MISC_REG_XMAC_PHY_PORT_MODE, 3); |
| 1689 | } else { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 1690 | DP(NETIF_MSG_LINK, |
| 1691 | "Init XMAC to 20G x 2 ports per path\n"); |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1692 | /* Set the number of ports on the Warp Core to 20G */ |
| 1693 | REG_WR(bp, MISC_REG_XMAC_PHY_PORT_MODE, 1); |
| 1694 | } |
| 1695 | } |
| 1696 | /* Soft reset */ |
| 1697 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_CLEAR, |
| 1698 | MISC_REGISTERS_RESET_REG_2_XMAC_SOFT); |
| 1699 | usleep_range(1000, 1000); |
| 1700 | |
| 1701 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_SET, |
| 1702 | MISC_REGISTERS_RESET_REG_2_XMAC_SOFT); |
| 1703 | |
| 1704 | } |
| 1705 | |
| 1706 | static void bnx2x_xmac_disable(struct link_params *params) |
| 1707 | { |
| 1708 | u8 port = params->port; |
| 1709 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | b507766 | 2011-08-02 22:59:18 +0000 | [diff] [blame] | 1710 | u32 pfc_ctrl, xmac_base = (port) ? GRCBASE_XMAC1 : GRCBASE_XMAC0; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1711 | |
| 1712 | if (REG_RD(bp, MISC_REG_RESET_REG_2) & |
| 1713 | MISC_REGISTERS_RESET_REG_2_XMAC) { |
Yaniv Rosner | b507766 | 2011-08-02 22:59:18 +0000 | [diff] [blame] | 1714 | /* |
| 1715 | * Send an indication to change the state in the NIG back to XON |
| 1716 | * Clearing this bit enables the next set of this bit to get |
| 1717 | * rising edge |
| 1718 | */ |
| 1719 | pfc_ctrl = REG_RD(bp, xmac_base + XMAC_REG_PFC_CTRL_HI); |
| 1720 | REG_WR(bp, xmac_base + XMAC_REG_PFC_CTRL_HI, |
| 1721 | (pfc_ctrl & ~(1<<1))); |
| 1722 | REG_WR(bp, xmac_base + XMAC_REG_PFC_CTRL_HI, |
| 1723 | (pfc_ctrl | (1<<1))); |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1724 | DP(NETIF_MSG_LINK, "Disable XMAC on port %x\n", port); |
| 1725 | REG_WR(bp, xmac_base + XMAC_REG_CTRL, 0); |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1726 | } |
| 1727 | } |
| 1728 | |
| 1729 | static int bnx2x_xmac_enable(struct link_params *params, |
| 1730 | struct link_vars *vars, u8 lb) |
| 1731 | { |
| 1732 | u32 val, xmac_base; |
| 1733 | struct bnx2x *bp = params->bp; |
| 1734 | DP(NETIF_MSG_LINK, "enabling XMAC\n"); |
| 1735 | |
| 1736 | xmac_base = (params->port) ? GRCBASE_XMAC1 : GRCBASE_XMAC0; |
| 1737 | |
Yaniv Rosner | ce7c048 | 2011-10-27 05:09:47 +0000 | [diff] [blame] | 1738 | bnx2x_xmac_init(params, vars->line_speed); |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1739 | |
| 1740 | /* |
| 1741 | * This register determines on which events the MAC will assert |
| 1742 | * error on the i/f to the NIG along w/ EOP. |
| 1743 | */ |
| 1744 | |
| 1745 | /* |
| 1746 | * This register tells the NIG whether to send traffic to UMAC |
| 1747 | * or XMAC |
| 1748 | */ |
| 1749 | REG_WR(bp, NIG_REG_EGRESS_EMAC0_PORT + params->port*4, 0); |
| 1750 | |
| 1751 | /* Set Max packet size */ |
| 1752 | REG_WR(bp, xmac_base + XMAC_REG_RX_MAX_SIZE, 0x2710); |
| 1753 | |
| 1754 | /* CRC append for Tx packets */ |
| 1755 | REG_WR(bp, xmac_base + XMAC_REG_TX_CTRL, 0xC800); |
| 1756 | |
| 1757 | /* update PFC */ |
| 1758 | bnx2x_update_pfc_xmac(params, vars, 0); |
| 1759 | |
| 1760 | /* Enable TX and RX */ |
| 1761 | val = XMAC_CTRL_REG_TX_EN | XMAC_CTRL_REG_RX_EN; |
| 1762 | |
| 1763 | /* Check loopback mode */ |
| 1764 | if (lb) |
David S. Miller | 8decf86 | 2011-09-22 03:23:13 -0400 | [diff] [blame] | 1765 | val |= XMAC_CTRL_REG_LINE_LOCAL_LPBK; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1766 | REG_WR(bp, xmac_base + XMAC_REG_CTRL, val); |
| 1767 | bnx2x_set_xumac_nig(params, |
| 1768 | ((vars->flow_ctrl & BNX2X_FLOW_CTRL_TX) != 0), 1); |
| 1769 | |
| 1770 | vars->mac_type = MAC_TYPE_XMAC; |
| 1771 | |
| 1772 | return 0; |
| 1773 | } |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 1774 | static int bnx2x_emac_enable(struct link_params *params, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 1775 | struct link_vars *vars, u8 lb) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1776 | { |
| 1777 | struct bnx2x *bp = params->bp; |
| 1778 | u8 port = params->port; |
| 1779 | u32 emac_base = port ? GRCBASE_EMAC1 : GRCBASE_EMAC0; |
| 1780 | u32 val; |
| 1781 | |
| 1782 | DP(NETIF_MSG_LINK, "enabling EMAC\n"); |
| 1783 | |
Yaniv Rosner | de6f337 | 2011-08-02 22:59:25 +0000 | [diff] [blame] | 1784 | /* Disable BMAC */ |
| 1785 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_CLEAR, |
| 1786 | (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << port)); |
| 1787 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1788 | /* enable emac and not bmac */ |
| 1789 | REG_WR(bp, NIG_REG_EGRESS_EMAC0_PORT + port*4, 1); |
| 1790 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1791 | /* ASIC */ |
| 1792 | if (vars->phy_flags & PHY_XGXS_FLAG) { |
| 1793 | u32 ser_lane = ((params->lane_config & |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1794 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_MASK) >> |
| 1795 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_SHIFT); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1796 | |
| 1797 | DP(NETIF_MSG_LINK, "XGXS\n"); |
| 1798 | /* select the master lanes (out of 0-3) */ |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1799 | 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] | 1800 | /* select XGXS */ |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1801 | REG_WR(bp, NIG_REG_XGXS_SERDES0_MODE_SEL + port*4, 1); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1802 | |
| 1803 | } else { /* SerDes */ |
| 1804 | DP(NETIF_MSG_LINK, "SerDes\n"); |
| 1805 | /* select SerDes */ |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1806 | REG_WR(bp, NIG_REG_XGXS_SERDES0_MODE_SEL + port*4, 0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1807 | } |
| 1808 | |
Eilon Greenstein | 811a2f2 | 2009-02-12 08:37:04 +0000 | [diff] [blame] | 1809 | bnx2x_bits_en(bp, emac_base + EMAC_REG_EMAC_RX_MODE, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1810 | EMAC_RX_MODE_RESET); |
Eilon Greenstein | 811a2f2 | 2009-02-12 08:37:04 +0000 | [diff] [blame] | 1811 | bnx2x_bits_en(bp, emac_base + EMAC_REG_EMAC_TX_MODE, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1812 | EMAC_TX_MODE_RESET); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1813 | |
| 1814 | if (CHIP_REV_IS_SLOW(bp)) { |
| 1815 | /* config GMII mode */ |
| 1816 | val = REG_RD(bp, emac_base + EMAC_REG_EMAC_MODE); |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1817 | EMAC_WR(bp, EMAC_REG_EMAC_MODE, (val | EMAC_MODE_PORT_GMII)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1818 | } else { /* ASIC */ |
| 1819 | /* pause enable/disable */ |
| 1820 | bnx2x_bits_dis(bp, emac_base + EMAC_REG_EMAC_RX_MODE, |
| 1821 | EMAC_RX_MODE_FLOW_EN); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1822 | |
| 1823 | bnx2x_bits_dis(bp, emac_base + EMAC_REG_EMAC_TX_MODE, |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1824 | (EMAC_TX_MODE_EXT_PAUSE_EN | |
| 1825 | EMAC_TX_MODE_FLOW_EN)); |
| 1826 | if (!(params->feature_config_flags & |
| 1827 | FEATURE_CONFIG_PFC_ENABLED)) { |
| 1828 | if (vars->flow_ctrl & BNX2X_FLOW_CTRL_RX) |
| 1829 | bnx2x_bits_en(bp, emac_base + |
| 1830 | EMAC_REG_EMAC_RX_MODE, |
| 1831 | EMAC_RX_MODE_FLOW_EN); |
| 1832 | |
| 1833 | if (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX) |
| 1834 | bnx2x_bits_en(bp, emac_base + |
| 1835 | EMAC_REG_EMAC_TX_MODE, |
| 1836 | (EMAC_TX_MODE_EXT_PAUSE_EN | |
| 1837 | EMAC_TX_MODE_FLOW_EN)); |
| 1838 | } else |
| 1839 | bnx2x_bits_en(bp, emac_base + EMAC_REG_EMAC_TX_MODE, |
| 1840 | EMAC_TX_MODE_FLOW_EN); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1841 | } |
| 1842 | |
| 1843 | /* KEEP_VLAN_TAG, promiscuous */ |
| 1844 | val = REG_RD(bp, emac_base + EMAC_REG_EMAC_RX_MODE); |
| 1845 | val |= EMAC_RX_MODE_KEEP_VLAN_TAG | EMAC_RX_MODE_PROMISCUOUS; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1846 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 1847 | /* |
| 1848 | * Setting this bit causes MAC control frames (except for pause |
| 1849 | * frames) to be passed on for processing. This setting has no |
| 1850 | * affect on the operation of the pause frames. This bit effects |
| 1851 | * all packets regardless of RX Parser packet sorting logic. |
| 1852 | * Turn the PFC off to make sure we are in Xon state before |
| 1853 | * enabling it. |
| 1854 | */ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1855 | EMAC_WR(bp, EMAC_REG_RX_PFC_MODE, 0); |
| 1856 | if (params->feature_config_flags & FEATURE_CONFIG_PFC_ENABLED) { |
| 1857 | DP(NETIF_MSG_LINK, "PFC is enabled\n"); |
| 1858 | /* Enable PFC again */ |
| 1859 | EMAC_WR(bp, EMAC_REG_RX_PFC_MODE, |
| 1860 | EMAC_REG_RX_PFC_MODE_RX_EN | |
| 1861 | EMAC_REG_RX_PFC_MODE_TX_EN | |
| 1862 | EMAC_REG_RX_PFC_MODE_PRIORITIES); |
| 1863 | |
| 1864 | EMAC_WR(bp, EMAC_REG_RX_PFC_PARAM, |
| 1865 | ((0x0101 << |
| 1866 | EMAC_REG_RX_PFC_PARAM_OPCODE_BITSHIFT) | |
| 1867 | (0x00ff << |
| 1868 | EMAC_REG_RX_PFC_PARAM_PRIORITY_EN_BITSHIFT))); |
| 1869 | val |= EMAC_RX_MODE_KEEP_MAC_CONTROL; |
| 1870 | } |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 1871 | EMAC_WR(bp, EMAC_REG_EMAC_RX_MODE, val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1872 | |
| 1873 | /* Set Loopback */ |
| 1874 | val = REG_RD(bp, emac_base + EMAC_REG_EMAC_MODE); |
| 1875 | if (lb) |
| 1876 | val |= 0x810; |
| 1877 | else |
| 1878 | val &= ~0x810; |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 1879 | EMAC_WR(bp, EMAC_REG_EMAC_MODE, val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1880 | |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 1881 | /* enable emac */ |
| 1882 | REG_WR(bp, NIG_REG_NIG_EMAC0_EN + port*4, 1); |
| 1883 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1884 | /* enable emac for jumbo packets */ |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 1885 | EMAC_WR(bp, EMAC_REG_EMAC_RX_MTU_SIZE, |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1886 | (EMAC_RX_MTU_SIZE_JUMBO_ENA | |
| 1887 | (ETH_MAX_JUMBO_PACKET_SIZE + ETH_OVREHEAD))); |
| 1888 | |
| 1889 | /* strip CRC */ |
| 1890 | REG_WR(bp, NIG_REG_NIG_INGRESS_EMAC0_NO_CRC + port*4, 0x1); |
| 1891 | |
| 1892 | /* disable the NIG in/out to the bmac */ |
| 1893 | REG_WR(bp, NIG_REG_BMAC0_IN_EN + port*4, 0x0); |
| 1894 | REG_WR(bp, NIG_REG_BMAC0_PAUSE_OUT_EN + port*4, 0x0); |
| 1895 | REG_WR(bp, NIG_REG_BMAC0_OUT_EN + port*4, 0x0); |
| 1896 | |
| 1897 | /* enable the NIG in/out to the emac */ |
| 1898 | REG_WR(bp, NIG_REG_EMAC0_IN_EN + port*4, 0x1); |
| 1899 | val = 0; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1900 | if ((params->feature_config_flags & |
| 1901 | FEATURE_CONFIG_PFC_ENABLED) || |
| 1902 | (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX)) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1903 | val = 1; |
| 1904 | |
| 1905 | REG_WR(bp, NIG_REG_EMAC0_PAUSE_OUT_EN + port*4, val); |
| 1906 | REG_WR(bp, NIG_REG_EGRESS_EMAC0_OUT_EN + port*4, 0x1); |
| 1907 | |
Yaniv Rosner | 02a2316 | 2011-01-31 04:22:53 +0000 | [diff] [blame] | 1908 | REG_WR(bp, NIG_REG_BMAC0_REGS_OUT_EN + port*4, 0x0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1909 | |
| 1910 | vars->mac_type = MAC_TYPE_EMAC; |
| 1911 | return 0; |
| 1912 | } |
| 1913 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1914 | static void bnx2x_update_pfc_bmac1(struct link_params *params, |
| 1915 | struct link_vars *vars) |
| 1916 | { |
| 1917 | u32 wb_data[2]; |
| 1918 | struct bnx2x *bp = params->bp; |
| 1919 | u32 bmac_addr = params->port ? NIG_REG_INGRESS_BMAC1_MEM : |
| 1920 | NIG_REG_INGRESS_BMAC0_MEM; |
| 1921 | |
| 1922 | u32 val = 0x14; |
| 1923 | if ((!(params->feature_config_flags & |
| 1924 | FEATURE_CONFIG_PFC_ENABLED)) && |
| 1925 | (vars->flow_ctrl & BNX2X_FLOW_CTRL_RX)) |
| 1926 | /* Enable BigMAC to react on received Pause packets */ |
| 1927 | val |= (1<<5); |
| 1928 | wb_data[0] = val; |
| 1929 | wb_data[1] = 0; |
| 1930 | REG_WR_DMAE(bp, bmac_addr + BIGMAC_REGISTER_RX_CONTROL, wb_data, 2); |
| 1931 | |
| 1932 | /* tx control */ |
| 1933 | val = 0xc0; |
| 1934 | if (!(params->feature_config_flags & |
| 1935 | FEATURE_CONFIG_PFC_ENABLED) && |
| 1936 | (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX)) |
| 1937 | val |= 0x800000; |
| 1938 | wb_data[0] = val; |
| 1939 | wb_data[1] = 0; |
| 1940 | REG_WR_DMAE(bp, bmac_addr + BIGMAC_REGISTER_TX_CONTROL, wb_data, 2); |
| 1941 | } |
| 1942 | |
| 1943 | static void bnx2x_update_pfc_bmac2(struct link_params *params, |
| 1944 | struct link_vars *vars, |
| 1945 | u8 is_lb) |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1946 | { |
| 1947 | /* |
| 1948 | * Set rx control: Strip CRC and enable BigMAC to relay |
| 1949 | * control packets to the system as well |
| 1950 | */ |
| 1951 | u32 wb_data[2]; |
| 1952 | struct bnx2x *bp = params->bp; |
| 1953 | u32 bmac_addr = params->port ? NIG_REG_INGRESS_BMAC1_MEM : |
| 1954 | NIG_REG_INGRESS_BMAC0_MEM; |
| 1955 | u32 val = 0x14; |
| 1956 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1957 | if ((!(params->feature_config_flags & |
| 1958 | FEATURE_CONFIG_PFC_ENABLED)) && |
| 1959 | (vars->flow_ctrl & BNX2X_FLOW_CTRL_RX)) |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1960 | /* Enable BigMAC to react on received Pause packets */ |
| 1961 | val |= (1<<5); |
| 1962 | wb_data[0] = val; |
| 1963 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1964 | 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] | 1965 | udelay(30); |
| 1966 | |
| 1967 | /* Tx control */ |
| 1968 | val = 0xc0; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1969 | if (!(params->feature_config_flags & |
| 1970 | FEATURE_CONFIG_PFC_ENABLED) && |
| 1971 | (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX)) |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1972 | val |= 0x800000; |
| 1973 | wb_data[0] = val; |
| 1974 | wb_data[1] = 0; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1975 | 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] | 1976 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1977 | if (params->feature_config_flags & FEATURE_CONFIG_PFC_ENABLED) { |
| 1978 | DP(NETIF_MSG_LINK, "PFC is enabled\n"); |
| 1979 | /* Enable PFC RX & TX & STATS and set 8 COS */ |
| 1980 | wb_data[0] = 0x0; |
| 1981 | wb_data[0] |= (1<<0); /* RX */ |
| 1982 | wb_data[0] |= (1<<1); /* TX */ |
| 1983 | wb_data[0] |= (1<<2); /* Force initial Xon */ |
| 1984 | wb_data[0] |= (1<<3); /* 8 cos */ |
| 1985 | wb_data[0] |= (1<<5); /* STATS */ |
| 1986 | wb_data[1] = 0; |
| 1987 | REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_PFC_CONTROL, |
| 1988 | wb_data, 2); |
| 1989 | /* Clear the force Xon */ |
| 1990 | wb_data[0] &= ~(1<<2); |
| 1991 | } else { |
| 1992 | DP(NETIF_MSG_LINK, "PFC is disabled\n"); |
| 1993 | /* disable PFC RX & TX & STATS and set 8 COS */ |
| 1994 | wb_data[0] = 0x8; |
| 1995 | wb_data[1] = 0; |
| 1996 | } |
| 1997 | |
| 1998 | REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_PFC_CONTROL, wb_data, 2); |
| 1999 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2000 | /* |
| 2001 | * Set Time (based unit is 512 bit time) between automatic |
| 2002 | * re-sending of PP packets amd enable automatic re-send of |
| 2003 | * Per-Priroity Packet as long as pp_gen is asserted and |
| 2004 | * pp_disable is low. |
| 2005 | */ |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2006 | val = 0x8000; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2007 | if (params->feature_config_flags & FEATURE_CONFIG_PFC_ENABLED) |
| 2008 | val |= (1<<16); /* enable automatic re-send */ |
| 2009 | |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2010 | wb_data[0] = val; |
| 2011 | wb_data[1] = 0; |
| 2012 | REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_TX_PAUSE_CONTROL, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2013 | wb_data, 2); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2014 | |
| 2015 | /* mac control */ |
| 2016 | val = 0x3; /* Enable RX and TX */ |
| 2017 | if (is_lb) { |
| 2018 | val |= 0x4; /* Local loopback */ |
| 2019 | DP(NETIF_MSG_LINK, "enable bmac loopback\n"); |
| 2020 | } |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2021 | /* When PFC enabled, Pass pause frames towards the NIG. */ |
| 2022 | if (params->feature_config_flags & FEATURE_CONFIG_PFC_ENABLED) |
| 2023 | val |= ((1<<6)|(1<<5)); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2024 | |
| 2025 | wb_data[0] = val; |
| 2026 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2027 | 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] | 2028 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2029 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2030 | |
| 2031 | /* PFC BRB internal port configuration params */ |
| 2032 | struct bnx2x_pfc_brb_threshold_val { |
| 2033 | u32 pause_xoff; |
| 2034 | u32 pause_xon; |
| 2035 | u32 full_xoff; |
| 2036 | u32 full_xon; |
| 2037 | }; |
| 2038 | |
| 2039 | struct bnx2x_pfc_brb_e3b0_val { |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame^] | 2040 | u32 per_class_guaranty_mode; |
| 2041 | u32 lb_guarantied_hyst; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2042 | u32 full_lb_xoff_th; |
| 2043 | u32 full_lb_xon_threshold; |
| 2044 | u32 lb_guarantied; |
| 2045 | u32 mac_0_class_t_guarantied; |
| 2046 | u32 mac_0_class_t_guarantied_hyst; |
| 2047 | u32 mac_1_class_t_guarantied; |
| 2048 | u32 mac_1_class_t_guarantied_hyst; |
| 2049 | }; |
| 2050 | |
| 2051 | struct bnx2x_pfc_brb_th_val { |
| 2052 | struct bnx2x_pfc_brb_threshold_val pauseable_th; |
| 2053 | struct bnx2x_pfc_brb_threshold_val non_pauseable_th; |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame^] | 2054 | struct bnx2x_pfc_brb_threshold_val default_class0; |
| 2055 | struct bnx2x_pfc_brb_threshold_val default_class1; |
| 2056 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2057 | }; |
| 2058 | static int bnx2x_pfc_brb_get_config_params( |
| 2059 | struct link_params *params, |
| 2060 | struct bnx2x_pfc_brb_th_val *config_val) |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2061 | { |
| 2062 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2063 | DP(NETIF_MSG_LINK, "Setting PFC BRB configuration\n"); |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame^] | 2064 | |
| 2065 | config_val->default_class1.pause_xoff = 0; |
| 2066 | config_val->default_class1.pause_xon = 0; |
| 2067 | config_val->default_class1.full_xoff = 0; |
| 2068 | config_val->default_class1.full_xon = 0; |
| 2069 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2070 | if (CHIP_IS_E2(bp)) { |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame^] | 2071 | /* class0 defaults */ |
| 2072 | config_val->default_class0.pause_xoff = |
| 2073 | DEFAULT0_E2_BRB_MAC_PAUSE_XOFF_THR; |
| 2074 | config_val->default_class0.pause_xon = |
| 2075 | DEFAULT0_E2_BRB_MAC_PAUSE_XON_THR; |
| 2076 | config_val->default_class0.full_xoff = |
| 2077 | DEFAULT0_E2_BRB_MAC_FULL_XOFF_THR; |
| 2078 | config_val->default_class0.full_xon = |
| 2079 | DEFAULT0_E2_BRB_MAC_FULL_XON_THR; |
| 2080 | /* pause able*/ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2081 | config_val->pauseable_th.pause_xoff = |
| 2082 | PFC_E2_BRB_MAC_PAUSE_XOFF_THR_PAUSE; |
| 2083 | config_val->pauseable_th.pause_xon = |
| 2084 | PFC_E2_BRB_MAC_PAUSE_XON_THR_PAUSE; |
| 2085 | config_val->pauseable_th.full_xoff = |
| 2086 | PFC_E2_BRB_MAC_FULL_XOFF_THR_PAUSE; |
| 2087 | config_val->pauseable_th.full_xon = |
| 2088 | PFC_E2_BRB_MAC_FULL_XON_THR_PAUSE; |
| 2089 | /* non pause able*/ |
| 2090 | config_val->non_pauseable_th.pause_xoff = |
| 2091 | PFC_E2_BRB_MAC_PAUSE_XOFF_THR_NON_PAUSE; |
| 2092 | config_val->non_pauseable_th.pause_xon = |
| 2093 | PFC_E2_BRB_MAC_PAUSE_XON_THR_NON_PAUSE; |
| 2094 | config_val->non_pauseable_th.full_xoff = |
| 2095 | PFC_E2_BRB_MAC_FULL_XOFF_THR_NON_PAUSE; |
| 2096 | config_val->non_pauseable_th.full_xon = |
| 2097 | PFC_E2_BRB_MAC_FULL_XON_THR_NON_PAUSE; |
| 2098 | } else if (CHIP_IS_E3A0(bp)) { |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame^] | 2099 | /* class0 defaults */ |
| 2100 | config_val->default_class0.pause_xoff = |
| 2101 | DEFAULT0_E3A0_BRB_MAC_PAUSE_XOFF_THR; |
| 2102 | config_val->default_class0.pause_xon = |
| 2103 | DEFAULT0_E3A0_BRB_MAC_PAUSE_XON_THR; |
| 2104 | config_val->default_class0.full_xoff = |
| 2105 | DEFAULT0_E3A0_BRB_MAC_FULL_XOFF_THR; |
| 2106 | config_val->default_class0.full_xon = |
| 2107 | DEFAULT0_E3A0_BRB_MAC_FULL_XON_THR; |
| 2108 | /* pause able */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2109 | config_val->pauseable_th.pause_xoff = |
| 2110 | PFC_E3A0_BRB_MAC_PAUSE_XOFF_THR_PAUSE; |
| 2111 | config_val->pauseable_th.pause_xon = |
| 2112 | PFC_E3A0_BRB_MAC_PAUSE_XON_THR_PAUSE; |
| 2113 | config_val->pauseable_th.full_xoff = |
| 2114 | PFC_E3A0_BRB_MAC_FULL_XOFF_THR_PAUSE; |
| 2115 | config_val->pauseable_th.full_xon = |
| 2116 | PFC_E3A0_BRB_MAC_FULL_XON_THR_PAUSE; |
| 2117 | /* non pause able*/ |
| 2118 | config_val->non_pauseable_th.pause_xoff = |
| 2119 | PFC_E3A0_BRB_MAC_PAUSE_XOFF_THR_NON_PAUSE; |
| 2120 | config_val->non_pauseable_th.pause_xon = |
| 2121 | PFC_E3A0_BRB_MAC_PAUSE_XON_THR_NON_PAUSE; |
| 2122 | config_val->non_pauseable_th.full_xoff = |
| 2123 | PFC_E3A0_BRB_MAC_FULL_XOFF_THR_NON_PAUSE; |
| 2124 | config_val->non_pauseable_th.full_xon = |
| 2125 | PFC_E3A0_BRB_MAC_FULL_XON_THR_NON_PAUSE; |
| 2126 | } else if (CHIP_IS_E3B0(bp)) { |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame^] | 2127 | /* class0 defaults */ |
| 2128 | config_val->default_class0.pause_xoff = |
| 2129 | DEFAULT0_E3B0_BRB_MAC_PAUSE_XOFF_THR; |
| 2130 | config_val->default_class0.pause_xon = |
| 2131 | DEFAULT0_E3B0_BRB_MAC_PAUSE_XON_THR; |
| 2132 | config_val->default_class0.full_xoff = |
| 2133 | DEFAULT0_E3B0_BRB_MAC_FULL_XOFF_THR; |
| 2134 | config_val->default_class0.full_xon = |
| 2135 | DEFAULT0_E3B0_BRB_MAC_FULL_XON_THR; |
| 2136 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2137 | if (params->phy[INT_PHY].flags & |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame^] | 2138 | FLAGS_4_PORT_MODE) { |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2139 | config_val->pauseable_th.pause_xoff = |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame^] | 2140 | PFC_E3B0_4P_BRB_MAC_PAUSE_XOFF_THR_PAUSE; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2141 | config_val->pauseable_th.pause_xon = |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame^] | 2142 | PFC_E3B0_4P_BRB_MAC_PAUSE_XON_THR_PAUSE; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2143 | config_val->pauseable_th.full_xoff = |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame^] | 2144 | PFC_E3B0_4P_BRB_MAC_FULL_XOFF_THR_PAUSE; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2145 | config_val->pauseable_th.full_xon = |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame^] | 2146 | PFC_E3B0_4P_BRB_MAC_FULL_XON_THR_PAUSE; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2147 | /* non pause able*/ |
| 2148 | config_val->non_pauseable_th.pause_xoff = |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame^] | 2149 | PFC_E3B0_4P_BRB_MAC_PAUSE_XOFF_THR_NON_PAUSE; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2150 | config_val->non_pauseable_th.pause_xon = |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame^] | 2151 | PFC_E3B0_4P_BRB_MAC_PAUSE_XON_THR_NON_PAUSE; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2152 | config_val->non_pauseable_th.full_xoff = |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame^] | 2153 | PFC_E3B0_4P_BRB_MAC_FULL_XOFF_THR_NON_PAUSE; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2154 | config_val->non_pauseable_th.full_xon = |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame^] | 2155 | PFC_E3B0_4P_BRB_MAC_FULL_XON_THR_NON_PAUSE; |
| 2156 | } else { |
| 2157 | config_val->pauseable_th.pause_xoff = |
| 2158 | PFC_E3B0_2P_BRB_MAC_PAUSE_XOFF_THR_PAUSE; |
| 2159 | config_val->pauseable_th.pause_xon = |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2160 | PFC_E3B0_2P_BRB_MAC_PAUSE_XON_THR_PAUSE; |
| 2161 | config_val->pauseable_th.full_xoff = |
| 2162 | PFC_E3B0_2P_BRB_MAC_FULL_XOFF_THR_PAUSE; |
| 2163 | config_val->pauseable_th.full_xon = |
| 2164 | PFC_E3B0_2P_BRB_MAC_FULL_XON_THR_PAUSE; |
| 2165 | /* non pause able*/ |
| 2166 | config_val->non_pauseable_th.pause_xoff = |
| 2167 | PFC_E3B0_2P_BRB_MAC_PAUSE_XOFF_THR_NON_PAUSE; |
| 2168 | config_val->non_pauseable_th.pause_xon = |
| 2169 | PFC_E3B0_2P_BRB_MAC_PAUSE_XON_THR_NON_PAUSE; |
| 2170 | config_val->non_pauseable_th.full_xoff = |
| 2171 | PFC_E3B0_2P_BRB_MAC_FULL_XOFF_THR_NON_PAUSE; |
| 2172 | config_val->non_pauseable_th.full_xon = |
| 2173 | PFC_E3B0_2P_BRB_MAC_FULL_XON_THR_NON_PAUSE; |
| 2174 | } |
| 2175 | } else |
| 2176 | return -EINVAL; |
| 2177 | |
| 2178 | return 0; |
| 2179 | } |
| 2180 | |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame^] | 2181 | static void bnx2x_pfc_brb_get_e3b0_config_params( |
| 2182 | struct link_params *params, |
| 2183 | struct bnx2x_pfc_brb_e3b0_val |
| 2184 | *e3b0_val, |
| 2185 | struct bnx2x_nig_brb_pfc_port_params *pfc_params, |
| 2186 | const u8 pfc_enabled) |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2187 | { |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame^] | 2188 | if (pfc_enabled && pfc_params) { |
| 2189 | e3b0_val->per_class_guaranty_mode = 1; |
| 2190 | e3b0_val->lb_guarantied_hyst = 80; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2191 | |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame^] | 2192 | if (params->phy[INT_PHY].flags & |
| 2193 | FLAGS_4_PORT_MODE) { |
| 2194 | e3b0_val->full_lb_xoff_th = |
| 2195 | PFC_E3B0_4P_BRB_FULL_LB_XOFF_THR; |
| 2196 | e3b0_val->full_lb_xon_threshold = |
| 2197 | PFC_E3B0_4P_BRB_FULL_LB_XON_THR; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2198 | e3b0_val->lb_guarantied = |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame^] | 2199 | PFC_E3B0_4P_LB_GUART; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2200 | e3b0_val->mac_0_class_t_guarantied = |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame^] | 2201 | PFC_E3B0_4P_BRB_MAC_0_CLASS_T_GUART; |
| 2202 | e3b0_val->mac_0_class_t_guarantied_hyst = |
| 2203 | PFC_E3B0_4P_BRB_MAC_0_CLASS_T_GUART_HYST; |
| 2204 | e3b0_val->mac_1_class_t_guarantied = |
| 2205 | PFC_E3B0_4P_BRB_MAC_1_CLASS_T_GUART; |
| 2206 | e3b0_val->mac_1_class_t_guarantied_hyst = |
| 2207 | PFC_E3B0_4P_BRB_MAC_1_CLASS_T_GUART_HYST; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2208 | } else { |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame^] | 2209 | e3b0_val->full_lb_xoff_th = |
| 2210 | PFC_E3B0_2P_BRB_FULL_LB_XOFF_THR; |
| 2211 | e3b0_val->full_lb_xon_threshold = |
| 2212 | PFC_E3B0_2P_BRB_FULL_LB_XON_THR; |
| 2213 | e3b0_val->mac_0_class_t_guarantied_hyst = |
| 2214 | PFC_E3B0_2P_BRB_MAC_0_CLASS_T_GUART_HYST; |
| 2215 | e3b0_val->mac_1_class_t_guarantied = |
| 2216 | PFC_E3B0_2P_BRB_MAC_1_CLASS_T_GUART; |
| 2217 | e3b0_val->mac_1_class_t_guarantied_hyst = |
| 2218 | PFC_E3B0_2P_BRB_MAC_1_CLASS_T_GUART_HYST; |
| 2219 | |
| 2220 | if (pfc_params->cos0_pauseable != |
| 2221 | pfc_params->cos1_pauseable) { |
| 2222 | /* nonpauseable= Lossy + pauseable = Lossless*/ |
| 2223 | e3b0_val->lb_guarantied = |
| 2224 | PFC_E3B0_2P_MIX_PAUSE_LB_GUART; |
| 2225 | e3b0_val->mac_0_class_t_guarantied = |
| 2226 | PFC_E3B0_2P_MIX_PAUSE_MAC_0_CLASS_T_GUART; |
| 2227 | } else if (pfc_params->cos0_pauseable) { |
| 2228 | /* Lossless +Lossless*/ |
| 2229 | e3b0_val->lb_guarantied = |
| 2230 | PFC_E3B0_2P_PAUSE_LB_GUART; |
| 2231 | e3b0_val->mac_0_class_t_guarantied = |
| 2232 | PFC_E3B0_2P_PAUSE_MAC_0_CLASS_T_GUART; |
| 2233 | } else { |
| 2234 | /* Lossy +Lossy*/ |
| 2235 | e3b0_val->lb_guarantied = |
| 2236 | PFC_E3B0_2P_NON_PAUSE_LB_GUART; |
| 2237 | e3b0_val->mac_0_class_t_guarantied = |
| 2238 | PFC_E3B0_2P_NON_PAUSE_MAC_0_CLASS_T_GUART; |
| 2239 | } |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2240 | } |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame^] | 2241 | } else { |
| 2242 | e3b0_val->per_class_guaranty_mode = 0; |
| 2243 | e3b0_val->lb_guarantied_hyst = 0; |
| 2244 | e3b0_val->full_lb_xoff_th = |
| 2245 | DEFAULT_E3B0_BRB_FULL_LB_XOFF_THR; |
| 2246 | e3b0_val->full_lb_xon_threshold = |
| 2247 | DEFAULT_E3B0_BRB_FULL_LB_XON_THR; |
| 2248 | e3b0_val->lb_guarantied = |
| 2249 | DEFAULT_E3B0_LB_GUART; |
| 2250 | e3b0_val->mac_0_class_t_guarantied = |
| 2251 | DEFAULT_E3B0_BRB_MAC_0_CLASS_T_GUART; |
| 2252 | e3b0_val->mac_0_class_t_guarantied_hyst = |
| 2253 | DEFAULT_E3B0_BRB_MAC_0_CLASS_T_GUART_HYST; |
| 2254 | e3b0_val->mac_1_class_t_guarantied = |
| 2255 | DEFAULT_E3B0_BRB_MAC_1_CLASS_T_GUART; |
| 2256 | e3b0_val->mac_1_class_t_guarantied_hyst = |
| 2257 | DEFAULT_E3B0_BRB_MAC_1_CLASS_T_GUART_HYST; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2258 | } |
| 2259 | } |
| 2260 | static int bnx2x_update_pfc_brb(struct link_params *params, |
| 2261 | struct link_vars *vars, |
| 2262 | struct bnx2x_nig_brb_pfc_port_params |
| 2263 | *pfc_params) |
| 2264 | { |
| 2265 | struct bnx2x *bp = params->bp; |
| 2266 | struct bnx2x_pfc_brb_th_val config_val = { {0} }; |
| 2267 | struct bnx2x_pfc_brb_threshold_val *reg_th_config = |
| 2268 | &config_val.pauseable_th; |
| 2269 | struct bnx2x_pfc_brb_e3b0_val e3b0_val = {0}; |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame^] | 2270 | const int set_pfc = params->feature_config_flags & |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2271 | FEATURE_CONFIG_PFC_ENABLED; |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame^] | 2272 | const u8 pfc_enabled = (set_pfc && pfc_params); |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2273 | int bnx2x_status = 0; |
| 2274 | u8 port = params->port; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2275 | |
| 2276 | /* default - pause configuration */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2277 | reg_th_config = &config_val.pauseable_th; |
| 2278 | bnx2x_status = bnx2x_pfc_brb_get_config_params(params, &config_val); |
| 2279 | if (0 != bnx2x_status) |
| 2280 | return bnx2x_status; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2281 | |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame^] | 2282 | if (pfc_enabled) { |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2283 | /* First COS */ |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame^] | 2284 | if (pfc_params->cos0_pauseable) |
| 2285 | reg_th_config = &config_val.pauseable_th; |
| 2286 | else |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2287 | reg_th_config = &config_val.non_pauseable_th; |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame^] | 2288 | } else |
| 2289 | reg_th_config = &config_val.default_class0; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2290 | /* |
| 2291 | * The number of free blocks below which the pause signal to class 0 |
| 2292 | * of MAC #n is asserted. n=0,1 |
| 2293 | */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2294 | REG_WR(bp, (port) ? BRB1_REG_PAUSE_0_XOFF_THRESHOLD_1 : |
| 2295 | BRB1_REG_PAUSE_0_XOFF_THRESHOLD_0 , |
| 2296 | reg_th_config->pause_xoff); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2297 | /* |
| 2298 | * The number of free blocks above which the pause signal to class 0 |
| 2299 | * of MAC #n is de-asserted. n=0,1 |
| 2300 | */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2301 | REG_WR(bp, (port) ? BRB1_REG_PAUSE_0_XON_THRESHOLD_1 : |
| 2302 | BRB1_REG_PAUSE_0_XON_THRESHOLD_0 , reg_th_config->pause_xon); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2303 | /* |
| 2304 | * The number of free blocks below which the full signal to class 0 |
| 2305 | * of MAC #n is asserted. n=0,1 |
| 2306 | */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2307 | REG_WR(bp, (port) ? BRB1_REG_FULL_0_XOFF_THRESHOLD_1 : |
| 2308 | BRB1_REG_FULL_0_XOFF_THRESHOLD_0 , reg_th_config->full_xoff); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2309 | /* |
| 2310 | * The number of free blocks above which the full signal to class 0 |
| 2311 | * of MAC #n is de-asserted. n=0,1 |
| 2312 | */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2313 | REG_WR(bp, (port) ? BRB1_REG_FULL_0_XON_THRESHOLD_1 : |
| 2314 | BRB1_REG_FULL_0_XON_THRESHOLD_0 , reg_th_config->full_xon); |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2315 | |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame^] | 2316 | if (pfc_enabled) { |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2317 | /* Second COS */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2318 | if (pfc_params->cos1_pauseable) |
| 2319 | reg_th_config = &config_val.pauseable_th; |
| 2320 | else |
| 2321 | reg_th_config = &config_val.non_pauseable_th; |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame^] | 2322 | } else |
| 2323 | reg_th_config = &config_val.default_class1; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2324 | /* |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2325 | * The number of free blocks below which the pause signal to |
| 2326 | * class 1 of MAC #n is asserted. n=0,1 |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2327 | **/ |
| 2328 | REG_WR(bp, (port) ? BRB1_REG_PAUSE_1_XOFF_THRESHOLD_1 : |
| 2329 | BRB1_REG_PAUSE_1_XOFF_THRESHOLD_0, |
| 2330 | reg_th_config->pause_xoff); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2331 | /* |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2332 | * The number of free blocks above which the pause signal to |
| 2333 | * class 1 of MAC #n is de-asserted. n=0,1 |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2334 | */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2335 | REG_WR(bp, (port) ? BRB1_REG_PAUSE_1_XON_THRESHOLD_1 : |
| 2336 | BRB1_REG_PAUSE_1_XON_THRESHOLD_0, |
| 2337 | reg_th_config->pause_xon); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2338 | /* |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2339 | * The number of free blocks below which the full signal to |
| 2340 | * class 1 of MAC #n is asserted. n=0,1 |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2341 | */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2342 | REG_WR(bp, (port) ? BRB1_REG_FULL_1_XOFF_THRESHOLD_1 : |
| 2343 | BRB1_REG_FULL_1_XOFF_THRESHOLD_0, |
| 2344 | reg_th_config->full_xoff); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2345 | /* |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2346 | * The number of free blocks above which the full signal to |
| 2347 | * class 1 of MAC #n is de-asserted. n=0,1 |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2348 | */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2349 | REG_WR(bp, (port) ? BRB1_REG_FULL_1_XON_THRESHOLD_1 : |
| 2350 | BRB1_REG_FULL_1_XON_THRESHOLD_0, |
| 2351 | reg_th_config->full_xon); |
| 2352 | |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame^] | 2353 | if (CHIP_IS_E3B0(bp)) { |
| 2354 | bnx2x_pfc_brb_get_e3b0_config_params( |
| 2355 | params, |
| 2356 | &e3b0_val, |
| 2357 | pfc_params, |
| 2358 | pfc_enabled); |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2359 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2360 | /*Should be done by init tool */ |
| 2361 | /* |
| 2362 | * BRB_empty_for_dup = BRB1_REG_BRB_EMPTY_THRESHOLD |
| 2363 | * reset value |
| 2364 | * 944 |
| 2365 | */ |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame^] | 2366 | REG_WR(bp, BRB1_REG_PER_CLASS_GUARANTY_MODE, |
| 2367 | e3b0_val.per_class_guaranty_mode); |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2368 | |
| 2369 | /** |
| 2370 | * The hysteresis on the guarantied buffer space for the Lb port |
| 2371 | * before signaling XON. |
| 2372 | **/ |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame^] | 2373 | REG_WR(bp, BRB1_REG_LB_GUARANTIED_HYST, |
| 2374 | e3b0_val.lb_guarantied_hyst); |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2375 | /** |
| 2376 | * The number of free blocks below which the full signal to the |
| 2377 | * LB port is asserted. |
| 2378 | */ |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame^] | 2379 | REG_WR(bp, BRB1_REG_FULL_LB_XOFF_THRESHOLD, |
| 2380 | e3b0_val.full_lb_xoff_th); |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2381 | /** |
| 2382 | * The number of free blocks above which the full signal to the |
| 2383 | * LB port is de-asserted. |
| 2384 | */ |
| 2385 | REG_WR(bp, BRB1_REG_FULL_LB_XON_THRESHOLD, |
| 2386 | e3b0_val.full_lb_xon_threshold); |
| 2387 | /** |
| 2388 | * The number of blocks guarantied for the MAC #n port. n=0,1 |
| 2389 | */ |
| 2390 | |
| 2391 | /*The number of blocks guarantied for the LB port.*/ |
| 2392 | REG_WR(bp, BRB1_REG_LB_GUARANTIED, |
| 2393 | e3b0_val.lb_guarantied); |
| 2394 | |
| 2395 | /** |
| 2396 | * The number of blocks guarantied for the MAC #n port. |
| 2397 | */ |
| 2398 | REG_WR(bp, BRB1_REG_MAC_GUARANTIED_0, |
| 2399 | 2 * e3b0_val.mac_0_class_t_guarantied); |
| 2400 | REG_WR(bp, BRB1_REG_MAC_GUARANTIED_1, |
| 2401 | 2 * e3b0_val.mac_1_class_t_guarantied); |
| 2402 | /** |
| 2403 | * The number of blocks guarantied for class #t in MAC0. t=0,1 |
| 2404 | */ |
| 2405 | REG_WR(bp, BRB1_REG_MAC_0_CLASS_0_GUARANTIED, |
| 2406 | e3b0_val.mac_0_class_t_guarantied); |
| 2407 | REG_WR(bp, BRB1_REG_MAC_0_CLASS_1_GUARANTIED, |
| 2408 | e3b0_val.mac_0_class_t_guarantied); |
| 2409 | /** |
| 2410 | * The hysteresis on the guarantied buffer space for class in |
| 2411 | * MAC0. t=0,1 |
| 2412 | */ |
| 2413 | REG_WR(bp, BRB1_REG_MAC_0_CLASS_0_GUARANTIED_HYST, |
| 2414 | e3b0_val.mac_0_class_t_guarantied_hyst); |
| 2415 | REG_WR(bp, BRB1_REG_MAC_0_CLASS_1_GUARANTIED_HYST, |
| 2416 | e3b0_val.mac_0_class_t_guarantied_hyst); |
| 2417 | |
| 2418 | /** |
| 2419 | * The number of blocks guarantied for class #t in MAC1.t=0,1 |
| 2420 | */ |
| 2421 | REG_WR(bp, BRB1_REG_MAC_1_CLASS_0_GUARANTIED, |
| 2422 | e3b0_val.mac_1_class_t_guarantied); |
| 2423 | REG_WR(bp, BRB1_REG_MAC_1_CLASS_1_GUARANTIED, |
| 2424 | e3b0_val.mac_1_class_t_guarantied); |
| 2425 | /** |
| 2426 | * The hysteresis on the guarantied buffer space for class #t |
| 2427 | * in MAC1. t=0,1 |
| 2428 | */ |
| 2429 | REG_WR(bp, BRB1_REG_MAC_1_CLASS_0_GUARANTIED_HYST, |
| 2430 | e3b0_val.mac_1_class_t_guarantied_hyst); |
| 2431 | REG_WR(bp, BRB1_REG_MAC_1_CLASS_1_GUARANTIED_HYST, |
| 2432 | e3b0_val.mac_1_class_t_guarantied_hyst); |
| 2433 | |
| 2434 | } |
| 2435 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2436 | return bnx2x_status; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2437 | } |
| 2438 | |
Vlad Zolotarov | 619c5cb | 2011-06-14 14:33:44 +0300 | [diff] [blame] | 2439 | /****************************************************************************** |
| 2440 | * Description: |
| 2441 | * This function is needed because NIG ARB_CREDIT_WEIGHT_X are |
| 2442 | * not continues and ARB_CREDIT_WEIGHT_0 + offset is suitable. |
| 2443 | ******************************************************************************/ |
| 2444 | int bnx2x_pfc_nig_rx_priority_mask(struct bnx2x *bp, |
| 2445 | u8 cos_entry, |
| 2446 | u32 priority_mask, u8 port) |
| 2447 | { |
| 2448 | u32 nig_reg_rx_priority_mask_add = 0; |
| 2449 | |
| 2450 | switch (cos_entry) { |
| 2451 | case 0: |
| 2452 | nig_reg_rx_priority_mask_add = (port) ? |
| 2453 | NIG_REG_P1_RX_COS0_PRIORITY_MASK : |
| 2454 | NIG_REG_P0_RX_COS0_PRIORITY_MASK; |
| 2455 | break; |
| 2456 | case 1: |
| 2457 | nig_reg_rx_priority_mask_add = (port) ? |
| 2458 | NIG_REG_P1_RX_COS1_PRIORITY_MASK : |
| 2459 | NIG_REG_P0_RX_COS1_PRIORITY_MASK; |
| 2460 | break; |
| 2461 | case 2: |
| 2462 | nig_reg_rx_priority_mask_add = (port) ? |
| 2463 | NIG_REG_P1_RX_COS2_PRIORITY_MASK : |
| 2464 | NIG_REG_P0_RX_COS2_PRIORITY_MASK; |
| 2465 | break; |
| 2466 | case 3: |
| 2467 | if (port) |
| 2468 | return -EINVAL; |
| 2469 | nig_reg_rx_priority_mask_add = NIG_REG_P0_RX_COS3_PRIORITY_MASK; |
| 2470 | break; |
| 2471 | case 4: |
| 2472 | if (port) |
| 2473 | return -EINVAL; |
| 2474 | nig_reg_rx_priority_mask_add = NIG_REG_P0_RX_COS4_PRIORITY_MASK; |
| 2475 | break; |
| 2476 | case 5: |
| 2477 | if (port) |
| 2478 | return -EINVAL; |
| 2479 | nig_reg_rx_priority_mask_add = NIG_REG_P0_RX_COS5_PRIORITY_MASK; |
| 2480 | break; |
| 2481 | } |
| 2482 | |
| 2483 | REG_WR(bp, nig_reg_rx_priority_mask_add, priority_mask); |
| 2484 | |
| 2485 | return 0; |
| 2486 | } |
Yaniv Rosner | b8d6d08 | 2011-07-05 01:06:27 +0000 | [diff] [blame] | 2487 | static void bnx2x_update_mng(struct link_params *params, u32 link_status) |
| 2488 | { |
| 2489 | struct bnx2x *bp = params->bp; |
| 2490 | |
| 2491 | REG_WR(bp, params->shmem_base + |
| 2492 | offsetof(struct shmem_region, |
| 2493 | port_mb[params->port].link_status), link_status); |
| 2494 | } |
| 2495 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2496 | static void bnx2x_update_pfc_nig(struct link_params *params, |
| 2497 | struct link_vars *vars, |
| 2498 | struct bnx2x_nig_brb_pfc_port_params *nig_params) |
| 2499 | { |
| 2500 | u32 xcm_mask = 0, ppp_enable = 0, pause_enable = 0, llfc_out_en = 0; |
| 2501 | u32 llfc_enable = 0, xcm0_out_en = 0, p0_hwpfc_enable = 0; |
| 2502 | u32 pkt_priority_to_cos = 0; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2503 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2504 | u8 port = params->port; |
| 2505 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2506 | int set_pfc = params->feature_config_flags & |
| 2507 | FEATURE_CONFIG_PFC_ENABLED; |
| 2508 | DP(NETIF_MSG_LINK, "updating pfc nig parameters\n"); |
| 2509 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2510 | /* |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2511 | * When NIG_LLH0_XCM_MASK_REG_LLHX_XCM_MASK_BCN bit is set |
| 2512 | * MAC control frames (that are not pause packets) |
| 2513 | * will be forwarded to the XCM. |
| 2514 | */ |
| 2515 | xcm_mask = REG_RD(bp, |
| 2516 | port ? NIG_REG_LLH1_XCM_MASK : |
| 2517 | NIG_REG_LLH0_XCM_MASK); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2518 | /* |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2519 | * nig params will override non PFC params, since it's possible to |
| 2520 | * do transition from PFC to SAFC |
| 2521 | */ |
| 2522 | if (set_pfc) { |
| 2523 | pause_enable = 0; |
| 2524 | llfc_out_en = 0; |
| 2525 | llfc_enable = 0; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2526 | if (CHIP_IS_E3(bp)) |
| 2527 | ppp_enable = 0; |
| 2528 | else |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2529 | ppp_enable = 1; |
| 2530 | xcm_mask &= ~(port ? NIG_LLH1_XCM_MASK_REG_LLH1_XCM_MASK_BCN : |
| 2531 | NIG_LLH0_XCM_MASK_REG_LLH0_XCM_MASK_BCN); |
| 2532 | xcm0_out_en = 0; |
| 2533 | p0_hwpfc_enable = 1; |
| 2534 | } else { |
| 2535 | if (nig_params) { |
| 2536 | llfc_out_en = nig_params->llfc_out_en; |
| 2537 | llfc_enable = nig_params->llfc_enable; |
| 2538 | pause_enable = nig_params->pause_enable; |
| 2539 | } else /*defaul non PFC mode - PAUSE */ |
| 2540 | pause_enable = 1; |
| 2541 | |
| 2542 | xcm_mask |= (port ? NIG_LLH1_XCM_MASK_REG_LLH1_XCM_MASK_BCN : |
| 2543 | NIG_LLH0_XCM_MASK_REG_LLH0_XCM_MASK_BCN); |
| 2544 | xcm0_out_en = 1; |
| 2545 | } |
| 2546 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2547 | if (CHIP_IS_E3(bp)) |
| 2548 | REG_WR(bp, port ? NIG_REG_BRB1_PAUSE_IN_EN : |
| 2549 | NIG_REG_BRB0_PAUSE_IN_EN, pause_enable); |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2550 | REG_WR(bp, port ? NIG_REG_LLFC_OUT_EN_1 : |
| 2551 | NIG_REG_LLFC_OUT_EN_0, llfc_out_en); |
| 2552 | REG_WR(bp, port ? NIG_REG_LLFC_ENABLE_1 : |
| 2553 | NIG_REG_LLFC_ENABLE_0, llfc_enable); |
| 2554 | REG_WR(bp, port ? NIG_REG_PAUSE_ENABLE_1 : |
| 2555 | NIG_REG_PAUSE_ENABLE_0, pause_enable); |
| 2556 | |
| 2557 | REG_WR(bp, port ? NIG_REG_PPP_ENABLE_1 : |
| 2558 | NIG_REG_PPP_ENABLE_0, ppp_enable); |
| 2559 | |
| 2560 | REG_WR(bp, port ? NIG_REG_LLH1_XCM_MASK : |
| 2561 | NIG_REG_LLH0_XCM_MASK, xcm_mask); |
| 2562 | |
| 2563 | REG_WR(bp, NIG_REG_LLFC_EGRESS_SRC_ENABLE_0, 0x7); |
| 2564 | |
| 2565 | /* output enable for RX_XCM # IF */ |
| 2566 | REG_WR(bp, NIG_REG_XCM0_OUT_EN, xcm0_out_en); |
| 2567 | |
| 2568 | /* HW PFC TX enable */ |
| 2569 | REG_WR(bp, NIG_REG_P0_HWPFC_ENABLE, p0_hwpfc_enable); |
| 2570 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2571 | if (nig_params) { |
Vlad Zolotarov | 619c5cb | 2011-06-14 14:33:44 +0300 | [diff] [blame] | 2572 | u8 i = 0; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2573 | pkt_priority_to_cos = nig_params->pkt_priority_to_cos; |
| 2574 | |
Vlad Zolotarov | 619c5cb | 2011-06-14 14:33:44 +0300 | [diff] [blame] | 2575 | for (i = 0; i < nig_params->num_of_rx_cos_priority_mask; i++) |
| 2576 | bnx2x_pfc_nig_rx_priority_mask(bp, i, |
| 2577 | nig_params->rx_cos_priority_mask[i], port); |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2578 | |
| 2579 | REG_WR(bp, port ? NIG_REG_LLFC_HIGH_PRIORITY_CLASSES_1 : |
| 2580 | NIG_REG_LLFC_HIGH_PRIORITY_CLASSES_0, |
| 2581 | nig_params->llfc_high_priority_classes); |
| 2582 | |
| 2583 | REG_WR(bp, port ? NIG_REG_LLFC_LOW_PRIORITY_CLASSES_1 : |
| 2584 | NIG_REG_LLFC_LOW_PRIORITY_CLASSES_0, |
| 2585 | nig_params->llfc_low_priority_classes); |
| 2586 | } |
| 2587 | REG_WR(bp, port ? NIG_REG_P1_PKT_PRIORITY_TO_COS : |
| 2588 | NIG_REG_P0_PKT_PRIORITY_TO_COS, |
| 2589 | pkt_priority_to_cos); |
| 2590 | } |
| 2591 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2592 | int bnx2x_update_pfc(struct link_params *params, |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2593 | struct link_vars *vars, |
| 2594 | struct bnx2x_nig_brb_pfc_port_params *pfc_params) |
| 2595 | { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2596 | /* |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2597 | * The PFC and pause are orthogonal to one another, meaning when |
| 2598 | * PFC is enabled, the pause are disabled, and when PFC is |
| 2599 | * disabled, pause are set according to the pause result. |
| 2600 | */ |
| 2601 | u32 val; |
| 2602 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2603 | int bnx2x_status = 0; |
| 2604 | u8 bmac_loopback = (params->loopback_mode == LOOPBACK_BMAC); |
Yaniv Rosner | b8d6d08 | 2011-07-05 01:06:27 +0000 | [diff] [blame] | 2605 | |
| 2606 | if (params->feature_config_flags & FEATURE_CONFIG_PFC_ENABLED) |
| 2607 | vars->link_status |= LINK_STATUS_PFC_ENABLED; |
| 2608 | else |
| 2609 | vars->link_status &= ~LINK_STATUS_PFC_ENABLED; |
| 2610 | |
| 2611 | bnx2x_update_mng(params, vars->link_status); |
| 2612 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2613 | /* update NIG params */ |
| 2614 | bnx2x_update_pfc_nig(params, vars, pfc_params); |
| 2615 | |
| 2616 | /* update BRB params */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2617 | bnx2x_status = bnx2x_update_pfc_brb(params, vars, pfc_params); |
| 2618 | if (0 != bnx2x_status) |
| 2619 | return bnx2x_status; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2620 | |
| 2621 | if (!vars->link_up) |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2622 | return bnx2x_status; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2623 | |
| 2624 | DP(NETIF_MSG_LINK, "About to update PFC in BMAC\n"); |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2625 | if (CHIP_IS_E3(bp)) |
| 2626 | bnx2x_update_pfc_xmac(params, vars, 0); |
| 2627 | else { |
| 2628 | val = REG_RD(bp, MISC_REG_RESET_REG_2); |
| 2629 | if ((val & |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 2630 | (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << params->port)) |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2631 | == 0) { |
| 2632 | DP(NETIF_MSG_LINK, "About to update PFC in EMAC\n"); |
| 2633 | bnx2x_emac_enable(params, vars, 0); |
| 2634 | return bnx2x_status; |
| 2635 | } |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2636 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2637 | if (CHIP_IS_E2(bp)) |
| 2638 | bnx2x_update_pfc_bmac2(params, vars, bmac_loopback); |
| 2639 | else |
| 2640 | bnx2x_update_pfc_bmac1(params, vars); |
| 2641 | |
| 2642 | val = 0; |
| 2643 | if ((params->feature_config_flags & |
| 2644 | FEATURE_CONFIG_PFC_ENABLED) || |
| 2645 | (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX)) |
| 2646 | val = 1; |
| 2647 | REG_WR(bp, NIG_REG_BMAC0_PAUSE_OUT_EN + params->port*4, val); |
| 2648 | } |
| 2649 | return bnx2x_status; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2650 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2651 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2652 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 2653 | static int bnx2x_bmac1_enable(struct link_params *params, |
| 2654 | struct link_vars *vars, |
| 2655 | u8 is_lb) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2656 | { |
| 2657 | struct bnx2x *bp = params->bp; |
| 2658 | u8 port = params->port; |
| 2659 | u32 bmac_addr = port ? NIG_REG_INGRESS_BMAC1_MEM : |
| 2660 | NIG_REG_INGRESS_BMAC0_MEM; |
| 2661 | u32 wb_data[2]; |
| 2662 | u32 val; |
| 2663 | |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2664 | DP(NETIF_MSG_LINK, "Enabling BigMAC1\n"); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2665 | |
| 2666 | /* XGXS control */ |
| 2667 | wb_data[0] = 0x3c; |
| 2668 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2669 | REG_WR_DMAE(bp, bmac_addr + BIGMAC_REGISTER_BMAC_XGXS_CONTROL, |
| 2670 | wb_data, 2); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2671 | |
| 2672 | /* tx MAC SA */ |
| 2673 | wb_data[0] = ((params->mac_addr[2] << 24) | |
| 2674 | (params->mac_addr[3] << 16) | |
| 2675 | (params->mac_addr[4] << 8) | |
| 2676 | params->mac_addr[5]); |
| 2677 | wb_data[1] = ((params->mac_addr[0] << 8) | |
| 2678 | params->mac_addr[1]); |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2679 | 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] | 2680 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2681 | /* mac control */ |
| 2682 | val = 0x3; |
| 2683 | if (is_lb) { |
| 2684 | val |= 0x4; |
| 2685 | DP(NETIF_MSG_LINK, "enable bmac loopback\n"); |
| 2686 | } |
| 2687 | wb_data[0] = val; |
| 2688 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2689 | 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] | 2690 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2691 | /* set rx mtu */ |
| 2692 | wb_data[0] = ETH_MAX_JUMBO_PACKET_SIZE + ETH_OVREHEAD; |
| 2693 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2694 | 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] | 2695 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2696 | bnx2x_update_pfc_bmac1(params, vars); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2697 | |
| 2698 | /* set tx mtu */ |
| 2699 | wb_data[0] = ETH_MAX_JUMBO_PACKET_SIZE + ETH_OVREHEAD; |
| 2700 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2701 | 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] | 2702 | |
| 2703 | /* set cnt max size */ |
| 2704 | wb_data[0] = ETH_MAX_JUMBO_PACKET_SIZE + ETH_OVREHEAD; |
| 2705 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2706 | 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] | 2707 | |
| 2708 | /* configure safc */ |
| 2709 | wb_data[0] = 0x1000200; |
| 2710 | wb_data[1] = 0; |
| 2711 | REG_WR_DMAE(bp, bmac_addr + BIGMAC_REGISTER_RX_LLFC_MSG_FLDS, |
| 2712 | wb_data, 2); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2713 | |
| 2714 | return 0; |
| 2715 | } |
| 2716 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 2717 | static int bnx2x_bmac2_enable(struct link_params *params, |
| 2718 | struct link_vars *vars, |
| 2719 | u8 is_lb) |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2720 | { |
| 2721 | struct bnx2x *bp = params->bp; |
| 2722 | u8 port = params->port; |
| 2723 | u32 bmac_addr = port ? NIG_REG_INGRESS_BMAC1_MEM : |
| 2724 | NIG_REG_INGRESS_BMAC0_MEM; |
| 2725 | u32 wb_data[2]; |
| 2726 | |
| 2727 | DP(NETIF_MSG_LINK, "Enabling BigMAC2\n"); |
| 2728 | |
| 2729 | wb_data[0] = 0; |
| 2730 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2731 | 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] | 2732 | udelay(30); |
| 2733 | |
| 2734 | /* XGXS control: Reset phy HW, MDIO registers, PHY PLL and BMAC */ |
| 2735 | wb_data[0] = 0x3c; |
| 2736 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2737 | REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_BMAC_XGXS_CONTROL, |
| 2738 | wb_data, 2); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2739 | |
| 2740 | udelay(30); |
| 2741 | |
| 2742 | /* tx MAC SA */ |
| 2743 | wb_data[0] = ((params->mac_addr[2] << 24) | |
| 2744 | (params->mac_addr[3] << 16) | |
| 2745 | (params->mac_addr[4] << 8) | |
| 2746 | params->mac_addr[5]); |
| 2747 | wb_data[1] = ((params->mac_addr[0] << 8) | |
| 2748 | params->mac_addr[1]); |
| 2749 | REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_TX_SOURCE_ADDR, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2750 | wb_data, 2); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2751 | |
| 2752 | udelay(30); |
| 2753 | |
| 2754 | /* Configure SAFC */ |
| 2755 | wb_data[0] = 0x1000200; |
| 2756 | wb_data[1] = 0; |
| 2757 | REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_RX_LLFC_MSG_FLDS, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2758 | wb_data, 2); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2759 | udelay(30); |
| 2760 | |
| 2761 | /* set rx mtu */ |
| 2762 | wb_data[0] = ETH_MAX_JUMBO_PACKET_SIZE + ETH_OVREHEAD; |
| 2763 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2764 | 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] | 2765 | udelay(30); |
| 2766 | |
| 2767 | /* set tx mtu */ |
| 2768 | wb_data[0] = ETH_MAX_JUMBO_PACKET_SIZE + ETH_OVREHEAD; |
| 2769 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2770 | 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] | 2771 | udelay(30); |
| 2772 | /* set cnt max size */ |
| 2773 | wb_data[0] = ETH_MAX_JUMBO_PACKET_SIZE + ETH_OVREHEAD - 2; |
| 2774 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2775 | 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] | 2776 | udelay(30); |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2777 | bnx2x_update_pfc_bmac2(params, vars, is_lb); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2778 | |
| 2779 | return 0; |
| 2780 | } |
| 2781 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 2782 | static int bnx2x_bmac_enable(struct link_params *params, |
| 2783 | struct link_vars *vars, |
| 2784 | u8 is_lb) |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2785 | { |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 2786 | int rc = 0; |
| 2787 | u8 port = params->port; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2788 | struct bnx2x *bp = params->bp; |
| 2789 | u32 val; |
| 2790 | /* reset and unreset the BigMac */ |
| 2791 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_CLEAR, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2792 | (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << port)); |
Yaniv Rosner | 1d9c05d | 2010-11-01 05:32:25 +0000 | [diff] [blame] | 2793 | msleep(1); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2794 | |
| 2795 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_SET, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2796 | (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << port)); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2797 | |
| 2798 | /* enable access for bmac registers */ |
| 2799 | REG_WR(bp, NIG_REG_BMAC0_REGS_OUT_EN + port*4, 0x1); |
| 2800 | |
| 2801 | /* Enable BMAC according to BMAC type*/ |
| 2802 | if (CHIP_IS_E2(bp)) |
| 2803 | rc = bnx2x_bmac2_enable(params, vars, is_lb); |
| 2804 | else |
| 2805 | rc = bnx2x_bmac1_enable(params, vars, is_lb); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2806 | REG_WR(bp, NIG_REG_XGXS_SERDES0_MODE_SEL + port*4, 0x1); |
| 2807 | REG_WR(bp, NIG_REG_XGXS_LANE_SEL_P0 + port*4, 0x0); |
| 2808 | REG_WR(bp, NIG_REG_EGRESS_EMAC0_PORT + port*4, 0x0); |
| 2809 | val = 0; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2810 | if ((params->feature_config_flags & |
| 2811 | FEATURE_CONFIG_PFC_ENABLED) || |
| 2812 | (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX)) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2813 | val = 1; |
| 2814 | REG_WR(bp, NIG_REG_BMAC0_PAUSE_OUT_EN + port*4, val); |
| 2815 | REG_WR(bp, NIG_REG_EGRESS_EMAC0_OUT_EN + port*4, 0x0); |
| 2816 | REG_WR(bp, NIG_REG_EMAC0_IN_EN + port*4, 0x0); |
| 2817 | REG_WR(bp, NIG_REG_EMAC0_PAUSE_OUT_EN + port*4, 0x0); |
| 2818 | REG_WR(bp, NIG_REG_BMAC0_IN_EN + port*4, 0x1); |
| 2819 | REG_WR(bp, NIG_REG_BMAC0_OUT_EN + port*4, 0x1); |
| 2820 | |
| 2821 | vars->mac_type = MAC_TYPE_BMAC; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2822 | return rc; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2823 | } |
| 2824 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2825 | static void bnx2x_bmac_rx_disable(struct bnx2x *bp, u8 port) |
| 2826 | { |
| 2827 | u32 bmac_addr = port ? NIG_REG_INGRESS_BMAC1_MEM : |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2828 | NIG_REG_INGRESS_BMAC0_MEM; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2829 | u32 wb_data[2]; |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 2830 | 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] | 2831 | |
| 2832 | /* Only if the bmac is out of reset */ |
| 2833 | if (REG_RD(bp, MISC_REG_RESET_REG_2) & |
| 2834 | (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << port) && |
| 2835 | nig_bmac_enable) { |
| 2836 | |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2837 | if (CHIP_IS_E2(bp)) { |
| 2838 | /* Clear Rx Enable bit in BMAC_CONTROL register */ |
| 2839 | REG_RD_DMAE(bp, bmac_addr + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2840 | BIGMAC2_REGISTER_BMAC_CONTROL, |
| 2841 | wb_data, 2); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2842 | wb_data[0] &= ~BMAC_CONTROL_RX_ENABLE; |
| 2843 | REG_WR_DMAE(bp, bmac_addr + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2844 | BIGMAC2_REGISTER_BMAC_CONTROL, |
| 2845 | wb_data, 2); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2846 | } else { |
| 2847 | /* Clear Rx Enable bit in BMAC_CONTROL register */ |
| 2848 | REG_RD_DMAE(bp, bmac_addr + |
| 2849 | BIGMAC_REGISTER_BMAC_CONTROL, |
| 2850 | wb_data, 2); |
| 2851 | wb_data[0] &= ~BMAC_CONTROL_RX_ENABLE; |
| 2852 | REG_WR_DMAE(bp, bmac_addr + |
| 2853 | BIGMAC_REGISTER_BMAC_CONTROL, |
| 2854 | wb_data, 2); |
| 2855 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2856 | msleep(1); |
| 2857 | } |
| 2858 | } |
| 2859 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 2860 | static int bnx2x_pbf_update(struct link_params *params, u32 flow_ctrl, |
| 2861 | u32 line_speed) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2862 | { |
| 2863 | struct bnx2x *bp = params->bp; |
| 2864 | u8 port = params->port; |
| 2865 | u32 init_crd, crd; |
| 2866 | u32 count = 1000; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2867 | |
| 2868 | /* disable port */ |
| 2869 | REG_WR(bp, PBF_REG_DISABLE_NEW_TASK_PROC_P0 + port*4, 0x1); |
| 2870 | |
| 2871 | /* wait for init credit */ |
| 2872 | init_crd = REG_RD(bp, PBF_REG_P0_INIT_CRD + port*4); |
| 2873 | crd = REG_RD(bp, PBF_REG_P0_CREDIT + port*8); |
| 2874 | DP(NETIF_MSG_LINK, "init_crd 0x%x crd 0x%x\n", init_crd, crd); |
| 2875 | |
| 2876 | while ((init_crd != crd) && count) { |
| 2877 | msleep(5); |
| 2878 | |
| 2879 | crd = REG_RD(bp, PBF_REG_P0_CREDIT + port*8); |
| 2880 | count--; |
| 2881 | } |
| 2882 | crd = REG_RD(bp, PBF_REG_P0_CREDIT + port*8); |
| 2883 | if (init_crd != crd) { |
| 2884 | DP(NETIF_MSG_LINK, "BUG! init_crd 0x%x != crd 0x%x\n", |
| 2885 | init_crd, crd); |
| 2886 | return -EINVAL; |
| 2887 | } |
| 2888 | |
David S. Miller | c0700f9 | 2008-12-16 23:53:20 -0800 | [diff] [blame] | 2889 | if (flow_ctrl & BNX2X_FLOW_CTRL_RX || |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 2890 | line_speed == SPEED_10 || |
| 2891 | line_speed == SPEED_100 || |
| 2892 | line_speed == SPEED_1000 || |
| 2893 | line_speed == SPEED_2500) { |
| 2894 | REG_WR(bp, PBF_REG_P0_PAUSE_ENABLE + port*4, 1); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2895 | /* update threshold */ |
| 2896 | REG_WR(bp, PBF_REG_P0_ARB_THRSH + port*4, 0); |
| 2897 | /* update init credit */ |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2898 | init_crd = 778; /* (800-18-4) */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2899 | |
| 2900 | } else { |
| 2901 | u32 thresh = (ETH_MAX_JUMBO_PACKET_SIZE + |
| 2902 | ETH_OVREHEAD)/16; |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 2903 | REG_WR(bp, PBF_REG_P0_PAUSE_ENABLE + port*4, 0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2904 | /* update threshold */ |
| 2905 | REG_WR(bp, PBF_REG_P0_ARB_THRSH + port*4, thresh); |
| 2906 | /* update init credit */ |
| 2907 | switch (line_speed) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2908 | case SPEED_10000: |
| 2909 | init_crd = thresh + 553 - 22; |
| 2910 | break; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2911 | default: |
| 2912 | DP(NETIF_MSG_LINK, "Invalid line_speed 0x%x\n", |
| 2913 | line_speed); |
| 2914 | return -EINVAL; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2915 | } |
| 2916 | } |
| 2917 | REG_WR(bp, PBF_REG_P0_INIT_CRD + port*4, init_crd); |
| 2918 | DP(NETIF_MSG_LINK, "PBF updated to speed %d credit %d\n", |
| 2919 | line_speed, init_crd); |
| 2920 | |
| 2921 | /* probe the credit changes */ |
| 2922 | REG_WR(bp, PBF_REG_INIT_P0 + port*4, 0x1); |
| 2923 | msleep(5); |
| 2924 | REG_WR(bp, PBF_REG_INIT_P0 + port*4, 0x0); |
| 2925 | |
| 2926 | /* enable port */ |
| 2927 | REG_WR(bp, PBF_REG_DISABLE_NEW_TASK_PROC_P0 + port*4, 0x0); |
| 2928 | return 0; |
| 2929 | } |
| 2930 | |
Dmitry Kravkov | e892067 | 2011-05-04 23:52:40 +0000 | [diff] [blame] | 2931 | /** |
| 2932 | * bnx2x_get_emac_base - retrive emac base address |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2933 | * |
Dmitry Kravkov | e892067 | 2011-05-04 23:52:40 +0000 | [diff] [blame] | 2934 | * @bp: driver handle |
| 2935 | * @mdc_mdio_access: access type |
| 2936 | * @port: port id |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2937 | * |
| 2938 | * This function selects the MDC/MDIO access (through emac0 or |
| 2939 | * emac1) depend on the mdc_mdio_access, port, port swapped. Each |
| 2940 | * phy has a default access mode, which could also be overridden |
| 2941 | * by nvram configuration. This parameter, whether this is the |
| 2942 | * default phy configuration, or the nvram overrun |
| 2943 | * configuration, is passed here as mdc_mdio_access and selects |
| 2944 | * the emac_base for the CL45 read/writes operations |
| 2945 | */ |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 2946 | static u32 bnx2x_get_emac_base(struct bnx2x *bp, |
| 2947 | u32 mdc_mdio_access, u8 port) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2948 | { |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 2949 | u32 emac_base = 0; |
| 2950 | switch (mdc_mdio_access) { |
| 2951 | case SHARED_HW_CFG_MDC_MDIO_ACCESS1_PHY_TYPE: |
| 2952 | break; |
| 2953 | case SHARED_HW_CFG_MDC_MDIO_ACCESS1_EMAC0: |
| 2954 | if (REG_RD(bp, NIG_REG_PORT_SWAP)) |
| 2955 | emac_base = GRCBASE_EMAC1; |
| 2956 | else |
| 2957 | emac_base = GRCBASE_EMAC0; |
| 2958 | break; |
| 2959 | case SHARED_HW_CFG_MDC_MDIO_ACCESS1_EMAC1: |
Eilon Greenstein | 589abe3 | 2009-02-12 08:36:55 +0000 | [diff] [blame] | 2960 | if (REG_RD(bp, NIG_REG_PORT_SWAP)) |
| 2961 | emac_base = GRCBASE_EMAC0; |
| 2962 | else |
| 2963 | emac_base = GRCBASE_EMAC1; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2964 | break; |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 2965 | case SHARED_HW_CFG_MDC_MDIO_ACCESS1_BOTH: |
| 2966 | emac_base = (port) ? GRCBASE_EMAC1 : GRCBASE_EMAC0; |
| 2967 | break; |
| 2968 | case SHARED_HW_CFG_MDC_MDIO_ACCESS1_SWAPPED: |
Eilon Greenstein | 6378c02 | 2008-08-13 15:59:25 -0700 | [diff] [blame] | 2969 | emac_base = (port) ? GRCBASE_EMAC0 : GRCBASE_EMAC1; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2970 | break; |
| 2971 | default: |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2972 | break; |
| 2973 | } |
| 2974 | return emac_base; |
| 2975 | |
| 2976 | } |
| 2977 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2978 | /******************************************************************/ |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 2979 | /* CL22 access functions */ |
| 2980 | /******************************************************************/ |
| 2981 | static int bnx2x_cl22_write(struct bnx2x *bp, |
| 2982 | struct bnx2x_phy *phy, |
| 2983 | u16 reg, u16 val) |
| 2984 | { |
| 2985 | u32 tmp, mode; |
| 2986 | u8 i; |
| 2987 | int rc = 0; |
| 2988 | /* Switch to CL22 */ |
| 2989 | mode = REG_RD(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_MODE); |
| 2990 | REG_WR(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_MODE, |
| 2991 | mode & ~EMAC_MDIO_MODE_CLAUSE_45); |
| 2992 | |
| 2993 | /* address */ |
| 2994 | tmp = ((phy->addr << 21) | (reg << 16) | val | |
| 2995 | EMAC_MDIO_COMM_COMMAND_WRITE_22 | |
| 2996 | EMAC_MDIO_COMM_START_BUSY); |
| 2997 | REG_WR(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM, tmp); |
| 2998 | |
| 2999 | for (i = 0; i < 50; i++) { |
| 3000 | udelay(10); |
| 3001 | |
| 3002 | tmp = REG_RD(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM); |
| 3003 | if (!(tmp & EMAC_MDIO_COMM_START_BUSY)) { |
| 3004 | udelay(5); |
| 3005 | break; |
| 3006 | } |
| 3007 | } |
| 3008 | if (tmp & EMAC_MDIO_COMM_START_BUSY) { |
| 3009 | DP(NETIF_MSG_LINK, "write phy register failed\n"); |
| 3010 | rc = -EFAULT; |
| 3011 | } |
| 3012 | REG_WR(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_MODE, mode); |
| 3013 | return rc; |
| 3014 | } |
| 3015 | |
| 3016 | static int bnx2x_cl22_read(struct bnx2x *bp, |
| 3017 | struct bnx2x_phy *phy, |
| 3018 | u16 reg, u16 *ret_val) |
| 3019 | { |
| 3020 | u32 val, mode; |
| 3021 | u16 i; |
| 3022 | int rc = 0; |
| 3023 | |
| 3024 | /* Switch to CL22 */ |
| 3025 | mode = REG_RD(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_MODE); |
| 3026 | REG_WR(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_MODE, |
| 3027 | mode & ~EMAC_MDIO_MODE_CLAUSE_45); |
| 3028 | |
| 3029 | /* address */ |
| 3030 | val = ((phy->addr << 21) | (reg << 16) | |
| 3031 | EMAC_MDIO_COMM_COMMAND_READ_22 | |
| 3032 | EMAC_MDIO_COMM_START_BUSY); |
| 3033 | REG_WR(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM, val); |
| 3034 | |
| 3035 | for (i = 0; i < 50; i++) { |
| 3036 | udelay(10); |
| 3037 | |
| 3038 | val = REG_RD(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM); |
| 3039 | if (!(val & EMAC_MDIO_COMM_START_BUSY)) { |
| 3040 | *ret_val = (u16)(val & EMAC_MDIO_COMM_DATA); |
| 3041 | udelay(5); |
| 3042 | break; |
| 3043 | } |
| 3044 | } |
| 3045 | if (val & EMAC_MDIO_COMM_START_BUSY) { |
| 3046 | DP(NETIF_MSG_LINK, "read phy register failed\n"); |
| 3047 | |
| 3048 | *ret_val = 0; |
| 3049 | rc = -EFAULT; |
| 3050 | } |
| 3051 | REG_WR(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_MODE, mode); |
| 3052 | return rc; |
| 3053 | } |
| 3054 | |
| 3055 | /******************************************************************/ |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3056 | /* CL45 access functions */ |
| 3057 | /******************************************************************/ |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 3058 | static int bnx2x_cl45_read(struct bnx2x *bp, struct bnx2x_phy *phy, |
| 3059 | u8 devad, u16 reg, u16 *ret_val) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3060 | { |
Yaniv Rosner | a198c14 | 2011-05-31 21:29:42 +0000 | [diff] [blame] | 3061 | u32 val; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3062 | u16 i; |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 3063 | int rc = 0; |
Yaniv Rosner | 157fa28 | 2011-08-02 22:59:32 +0000 | [diff] [blame] | 3064 | if (phy->flags & FLAGS_MDC_MDIO_WA_B0) |
| 3065 | bnx2x_bits_en(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_STATUS, |
| 3066 | EMAC_MDIO_STATUS_10MB); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3067 | /* address */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3068 | val = ((phy->addr << 21) | (devad << 16) | reg | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3069 | EMAC_MDIO_COMM_COMMAND_ADDRESS | |
| 3070 | EMAC_MDIO_COMM_START_BUSY); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3071 | REG_WR(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM, val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3072 | |
| 3073 | for (i = 0; i < 50; i++) { |
| 3074 | udelay(10); |
| 3075 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3076 | val = REG_RD(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3077 | if (!(val & EMAC_MDIO_COMM_START_BUSY)) { |
| 3078 | udelay(5); |
| 3079 | break; |
| 3080 | } |
| 3081 | } |
| 3082 | if (val & EMAC_MDIO_COMM_START_BUSY) { |
| 3083 | DP(NETIF_MSG_LINK, "read phy register failed\n"); |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 3084 | netdev_err(bp->dev, "MDC/MDIO access timeout\n"); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3085 | *ret_val = 0; |
| 3086 | rc = -EFAULT; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3087 | } else { |
| 3088 | /* data */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3089 | val = ((phy->addr << 21) | (devad << 16) | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3090 | EMAC_MDIO_COMM_COMMAND_READ_45 | |
| 3091 | EMAC_MDIO_COMM_START_BUSY); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3092 | REG_WR(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM, val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3093 | |
| 3094 | for (i = 0; i < 50; i++) { |
| 3095 | udelay(10); |
| 3096 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3097 | val = REG_RD(bp, phy->mdio_ctrl + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3098 | EMAC_REG_EMAC_MDIO_COMM); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3099 | if (!(val & EMAC_MDIO_COMM_START_BUSY)) { |
| 3100 | *ret_val = (u16)(val & EMAC_MDIO_COMM_DATA); |
| 3101 | break; |
| 3102 | } |
| 3103 | } |
| 3104 | if (val & EMAC_MDIO_COMM_START_BUSY) { |
| 3105 | DP(NETIF_MSG_LINK, "read phy register failed\n"); |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 3106 | netdev_err(bp->dev, "MDC/MDIO access timeout\n"); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3107 | *ret_val = 0; |
| 3108 | rc = -EFAULT; |
| 3109 | } |
| 3110 | } |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 3111 | /* Work around for E3 A0 */ |
| 3112 | if (phy->flags & FLAGS_MDC_MDIO_WA) { |
| 3113 | phy->flags ^= FLAGS_DUMMY_READ; |
| 3114 | if (phy->flags & FLAGS_DUMMY_READ) { |
| 3115 | u16 temp_val; |
| 3116 | bnx2x_cl45_read(bp, phy, devad, 0xf, &temp_val); |
| 3117 | } |
| 3118 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3119 | |
Yaniv Rosner | 157fa28 | 2011-08-02 22:59:32 +0000 | [diff] [blame] | 3120 | if (phy->flags & FLAGS_MDC_MDIO_WA_B0) |
| 3121 | bnx2x_bits_dis(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_STATUS, |
| 3122 | EMAC_MDIO_STATUS_10MB); |
Yaniv Rosner | a198c14 | 2011-05-31 21:29:42 +0000 | [diff] [blame] | 3123 | return rc; |
| 3124 | } |
| 3125 | |
| 3126 | static int bnx2x_cl45_write(struct bnx2x *bp, struct bnx2x_phy *phy, |
| 3127 | u8 devad, u16 reg, u16 val) |
| 3128 | { |
| 3129 | u32 tmp; |
| 3130 | u8 i; |
| 3131 | int rc = 0; |
Yaniv Rosner | 157fa28 | 2011-08-02 22:59:32 +0000 | [diff] [blame] | 3132 | if (phy->flags & FLAGS_MDC_MDIO_WA_B0) |
| 3133 | bnx2x_bits_en(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_STATUS, |
| 3134 | EMAC_MDIO_STATUS_10MB); |
Yaniv Rosner | a198c14 | 2011-05-31 21:29:42 +0000 | [diff] [blame] | 3135 | |
| 3136 | /* address */ |
| 3137 | |
| 3138 | tmp = ((phy->addr << 21) | (devad << 16) | reg | |
| 3139 | EMAC_MDIO_COMM_COMMAND_ADDRESS | |
| 3140 | EMAC_MDIO_COMM_START_BUSY); |
| 3141 | REG_WR(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM, tmp); |
| 3142 | |
| 3143 | for (i = 0; i < 50; i++) { |
| 3144 | udelay(10); |
| 3145 | |
| 3146 | tmp = REG_RD(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM); |
| 3147 | if (!(tmp & EMAC_MDIO_COMM_START_BUSY)) { |
| 3148 | udelay(5); |
| 3149 | break; |
| 3150 | } |
| 3151 | } |
| 3152 | if (tmp & EMAC_MDIO_COMM_START_BUSY) { |
| 3153 | DP(NETIF_MSG_LINK, "write phy register failed\n"); |
| 3154 | netdev_err(bp->dev, "MDC/MDIO access timeout\n"); |
| 3155 | rc = -EFAULT; |
| 3156 | |
| 3157 | } else { |
| 3158 | /* data */ |
| 3159 | tmp = ((phy->addr << 21) | (devad << 16) | val | |
| 3160 | EMAC_MDIO_COMM_COMMAND_WRITE_45 | |
| 3161 | EMAC_MDIO_COMM_START_BUSY); |
| 3162 | REG_WR(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM, tmp); |
| 3163 | |
| 3164 | for (i = 0; i < 50; i++) { |
| 3165 | udelay(10); |
| 3166 | |
| 3167 | tmp = REG_RD(bp, phy->mdio_ctrl + |
| 3168 | EMAC_REG_EMAC_MDIO_COMM); |
| 3169 | if (!(tmp & EMAC_MDIO_COMM_START_BUSY)) { |
| 3170 | udelay(5); |
| 3171 | break; |
| 3172 | } |
| 3173 | } |
| 3174 | if (tmp & EMAC_MDIO_COMM_START_BUSY) { |
| 3175 | DP(NETIF_MSG_LINK, "write phy register failed\n"); |
| 3176 | netdev_err(bp->dev, "MDC/MDIO access timeout\n"); |
| 3177 | rc = -EFAULT; |
| 3178 | } |
| 3179 | } |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 3180 | /* Work around for E3 A0 */ |
| 3181 | if (phy->flags & FLAGS_MDC_MDIO_WA) { |
| 3182 | phy->flags ^= FLAGS_DUMMY_READ; |
| 3183 | if (phy->flags & FLAGS_DUMMY_READ) { |
| 3184 | u16 temp_val; |
| 3185 | bnx2x_cl45_read(bp, phy, devad, 0xf, &temp_val); |
| 3186 | } |
| 3187 | } |
Yaniv Rosner | 157fa28 | 2011-08-02 22:59:32 +0000 | [diff] [blame] | 3188 | if (phy->flags & FLAGS_MDC_MDIO_WA_B0) |
| 3189 | bnx2x_bits_dis(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_STATUS, |
| 3190 | EMAC_MDIO_STATUS_10MB); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3191 | return rc; |
| 3192 | } |
| 3193 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 3194 | |
| 3195 | /******************************************************************/ |
| 3196 | /* BSC access functions from E3 */ |
| 3197 | /******************************************************************/ |
| 3198 | static void bnx2x_bsc_module_sel(struct link_params *params) |
| 3199 | { |
| 3200 | int idx; |
| 3201 | u32 board_cfg, sfp_ctrl; |
| 3202 | u32 i2c_pins[I2C_SWITCH_WIDTH], i2c_val[I2C_SWITCH_WIDTH]; |
| 3203 | struct bnx2x *bp = params->bp; |
| 3204 | u8 port = params->port; |
| 3205 | /* Read I2C output PINs */ |
| 3206 | board_cfg = REG_RD(bp, params->shmem_base + |
| 3207 | offsetof(struct shmem_region, |
| 3208 | dev_info.shared_hw_config.board)); |
| 3209 | i2c_pins[I2C_BSC0] = board_cfg & SHARED_HW_CFG_E3_I2C_MUX0_MASK; |
| 3210 | i2c_pins[I2C_BSC1] = (board_cfg & SHARED_HW_CFG_E3_I2C_MUX1_MASK) >> |
| 3211 | SHARED_HW_CFG_E3_I2C_MUX1_SHIFT; |
| 3212 | |
| 3213 | /* Read I2C output value */ |
| 3214 | sfp_ctrl = REG_RD(bp, params->shmem_base + |
| 3215 | offsetof(struct shmem_region, |
| 3216 | dev_info.port_hw_config[port].e3_cmn_pin_cfg)); |
| 3217 | i2c_val[I2C_BSC0] = (sfp_ctrl & PORT_HW_CFG_E3_I2C_MUX0_MASK) > 0; |
| 3218 | i2c_val[I2C_BSC1] = (sfp_ctrl & PORT_HW_CFG_E3_I2C_MUX1_MASK) > 0; |
| 3219 | DP(NETIF_MSG_LINK, "Setting BSC switch\n"); |
| 3220 | for (idx = 0; idx < I2C_SWITCH_WIDTH; idx++) |
| 3221 | bnx2x_set_cfg_pin(bp, i2c_pins[idx], i2c_val[idx]); |
| 3222 | } |
| 3223 | |
| 3224 | static int bnx2x_bsc_read(struct link_params *params, |
| 3225 | struct bnx2x_phy *phy, |
| 3226 | u8 sl_devid, |
| 3227 | u16 sl_addr, |
| 3228 | u8 lc_addr, |
| 3229 | u8 xfer_cnt, |
| 3230 | u32 *data_array) |
| 3231 | { |
| 3232 | u32 val, i; |
| 3233 | int rc = 0; |
| 3234 | struct bnx2x *bp = params->bp; |
| 3235 | |
| 3236 | if ((sl_devid != 0xa0) && (sl_devid != 0xa2)) { |
| 3237 | DP(NETIF_MSG_LINK, "invalid sl_devid 0x%x\n", sl_devid); |
| 3238 | return -EINVAL; |
| 3239 | } |
| 3240 | |
| 3241 | if (xfer_cnt > 16) { |
| 3242 | DP(NETIF_MSG_LINK, "invalid xfer_cnt %d. Max is 16 bytes\n", |
| 3243 | xfer_cnt); |
| 3244 | return -EINVAL; |
| 3245 | } |
| 3246 | bnx2x_bsc_module_sel(params); |
| 3247 | |
| 3248 | xfer_cnt = 16 - lc_addr; |
| 3249 | |
| 3250 | /* enable the engine */ |
| 3251 | val = REG_RD(bp, MCP_REG_MCPR_IMC_COMMAND); |
| 3252 | val |= MCPR_IMC_COMMAND_ENABLE; |
| 3253 | REG_WR(bp, MCP_REG_MCPR_IMC_COMMAND, val); |
| 3254 | |
| 3255 | /* program slave device ID */ |
| 3256 | val = (sl_devid << 16) | sl_addr; |
| 3257 | REG_WR(bp, MCP_REG_MCPR_IMC_SLAVE_CONTROL, val); |
| 3258 | |
| 3259 | /* start xfer with 0 byte to update the address pointer ???*/ |
| 3260 | val = (MCPR_IMC_COMMAND_ENABLE) | |
| 3261 | (MCPR_IMC_COMMAND_WRITE_OP << |
| 3262 | MCPR_IMC_COMMAND_OPERATION_BITSHIFT) | |
| 3263 | (lc_addr << MCPR_IMC_COMMAND_TRANSFER_ADDRESS_BITSHIFT) | (0); |
| 3264 | REG_WR(bp, MCP_REG_MCPR_IMC_COMMAND, val); |
| 3265 | |
| 3266 | /* poll for completion */ |
| 3267 | i = 0; |
| 3268 | val = REG_RD(bp, MCP_REG_MCPR_IMC_COMMAND); |
| 3269 | while (((val >> MCPR_IMC_COMMAND_IMC_STATUS_BITSHIFT) & 0x3) != 1) { |
| 3270 | udelay(10); |
| 3271 | val = REG_RD(bp, MCP_REG_MCPR_IMC_COMMAND); |
| 3272 | if (i++ > 1000) { |
| 3273 | DP(NETIF_MSG_LINK, "wr 0 byte timed out after %d try\n", |
| 3274 | i); |
| 3275 | rc = -EFAULT; |
| 3276 | break; |
| 3277 | } |
| 3278 | } |
| 3279 | if (rc == -EFAULT) |
| 3280 | return rc; |
| 3281 | |
| 3282 | /* start xfer with read op */ |
| 3283 | val = (MCPR_IMC_COMMAND_ENABLE) | |
| 3284 | (MCPR_IMC_COMMAND_READ_OP << |
| 3285 | MCPR_IMC_COMMAND_OPERATION_BITSHIFT) | |
| 3286 | (lc_addr << MCPR_IMC_COMMAND_TRANSFER_ADDRESS_BITSHIFT) | |
| 3287 | (xfer_cnt); |
| 3288 | REG_WR(bp, MCP_REG_MCPR_IMC_COMMAND, val); |
| 3289 | |
| 3290 | /* poll for completion */ |
| 3291 | i = 0; |
| 3292 | val = REG_RD(bp, MCP_REG_MCPR_IMC_COMMAND); |
| 3293 | while (((val >> MCPR_IMC_COMMAND_IMC_STATUS_BITSHIFT) & 0x3) != 1) { |
| 3294 | udelay(10); |
| 3295 | val = REG_RD(bp, MCP_REG_MCPR_IMC_COMMAND); |
| 3296 | if (i++ > 1000) { |
| 3297 | DP(NETIF_MSG_LINK, "rd op timed out after %d try\n", i); |
| 3298 | rc = -EFAULT; |
| 3299 | break; |
| 3300 | } |
| 3301 | } |
| 3302 | if (rc == -EFAULT) |
| 3303 | return rc; |
| 3304 | |
| 3305 | for (i = (lc_addr >> 2); i < 4; i++) { |
| 3306 | data_array[i] = REG_RD(bp, (MCP_REG_MCPR_IMC_DATAREG0 + i*4)); |
| 3307 | #ifdef __BIG_ENDIAN |
| 3308 | data_array[i] = ((data_array[i] & 0x000000ff) << 24) | |
| 3309 | ((data_array[i] & 0x0000ff00) << 8) | |
| 3310 | ((data_array[i] & 0x00ff0000) >> 8) | |
| 3311 | ((data_array[i] & 0xff000000) >> 24); |
| 3312 | #endif |
| 3313 | } |
| 3314 | return rc; |
| 3315 | } |
| 3316 | |
| 3317 | static void bnx2x_cl45_read_or_write(struct bnx2x *bp, struct bnx2x_phy *phy, |
| 3318 | u8 devad, u16 reg, u16 or_val) |
| 3319 | { |
| 3320 | u16 val; |
| 3321 | bnx2x_cl45_read(bp, phy, devad, reg, &val); |
| 3322 | bnx2x_cl45_write(bp, phy, devad, reg, val | or_val); |
| 3323 | } |
| 3324 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 3325 | int bnx2x_phy_read(struct link_params *params, u8 phy_addr, |
| 3326 | u8 devad, u16 reg, u16 *ret_val) |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3327 | { |
| 3328 | u8 phy_index; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3329 | /* |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3330 | * Probe for the phy according to the given phy_addr, and execute |
| 3331 | * the read request on it |
| 3332 | */ |
| 3333 | for (phy_index = 0; phy_index < params->num_phys; phy_index++) { |
| 3334 | if (params->phy[phy_index].addr == phy_addr) { |
| 3335 | return bnx2x_cl45_read(params->bp, |
| 3336 | ¶ms->phy[phy_index], devad, |
| 3337 | reg, ret_val); |
| 3338 | } |
| 3339 | } |
| 3340 | return -EINVAL; |
| 3341 | } |
| 3342 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 3343 | int bnx2x_phy_write(struct link_params *params, u8 phy_addr, |
| 3344 | u8 devad, u16 reg, u16 val) |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3345 | { |
| 3346 | u8 phy_index; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3347 | /* |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3348 | * Probe for the phy according to the given phy_addr, and execute |
| 3349 | * the write request on it |
| 3350 | */ |
| 3351 | for (phy_index = 0; phy_index < params->num_phys; phy_index++) { |
| 3352 | if (params->phy[phy_index].addr == phy_addr) { |
| 3353 | return bnx2x_cl45_write(params->bp, |
| 3354 | ¶ms->phy[phy_index], devad, |
| 3355 | reg, val); |
| 3356 | } |
| 3357 | } |
| 3358 | return -EINVAL; |
| 3359 | } |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 3360 | static u8 bnx2x_get_warpcore_lane(struct bnx2x_phy *phy, |
| 3361 | struct link_params *params) |
| 3362 | { |
| 3363 | u8 lane = 0; |
| 3364 | struct bnx2x *bp = params->bp; |
| 3365 | u32 path_swap, path_swap_ovr; |
| 3366 | u8 path, port; |
| 3367 | |
| 3368 | path = BP_PATH(bp); |
| 3369 | port = params->port; |
| 3370 | |
| 3371 | if (bnx2x_is_4_port_mode(bp)) { |
| 3372 | u32 port_swap, port_swap_ovr; |
| 3373 | |
| 3374 | /*figure out path swap value */ |
| 3375 | path_swap_ovr = REG_RD(bp, MISC_REG_FOUR_PORT_PATH_SWAP_OVWR); |
| 3376 | if (path_swap_ovr & 0x1) |
| 3377 | path_swap = (path_swap_ovr & 0x2); |
| 3378 | else |
| 3379 | path_swap = REG_RD(bp, MISC_REG_FOUR_PORT_PATH_SWAP); |
| 3380 | |
| 3381 | if (path_swap) |
| 3382 | path = path ^ 1; |
| 3383 | |
| 3384 | /*figure out port swap value */ |
| 3385 | port_swap_ovr = REG_RD(bp, MISC_REG_FOUR_PORT_PORT_SWAP_OVWR); |
| 3386 | if (port_swap_ovr & 0x1) |
| 3387 | port_swap = (port_swap_ovr & 0x2); |
| 3388 | else |
| 3389 | port_swap = REG_RD(bp, MISC_REG_FOUR_PORT_PORT_SWAP); |
| 3390 | |
| 3391 | if (port_swap) |
| 3392 | port = port ^ 1; |
| 3393 | |
| 3394 | lane = (port<<1) + path; |
| 3395 | } else { /* two port mode - no port swap */ |
| 3396 | |
| 3397 | /*figure out path swap value */ |
| 3398 | path_swap_ovr = |
| 3399 | REG_RD(bp, MISC_REG_TWO_PORT_PATH_SWAP_OVWR); |
| 3400 | if (path_swap_ovr & 0x1) { |
| 3401 | path_swap = (path_swap_ovr & 0x2); |
| 3402 | } else { |
| 3403 | path_swap = |
| 3404 | REG_RD(bp, MISC_REG_TWO_PORT_PATH_SWAP); |
| 3405 | } |
| 3406 | if (path_swap) |
| 3407 | path = path ^ 1; |
| 3408 | |
| 3409 | lane = path << 1 ; |
| 3410 | } |
| 3411 | return lane; |
| 3412 | } |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3413 | |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 3414 | static void bnx2x_set_aer_mmd(struct link_params *params, |
| 3415 | struct bnx2x_phy *phy) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3416 | { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3417 | u32 ser_lane; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 3418 | u16 offset, aer_val; |
| 3419 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3420 | ser_lane = ((params->lane_config & |
| 3421 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_MASK) >> |
| 3422 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_SHIFT); |
| 3423 | |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 3424 | offset = (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT) ? |
| 3425 | (phy->addr + ser_lane) : 0; |
| 3426 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 3427 | if (USES_WARPCORE(bp)) { |
| 3428 | aer_val = bnx2x_get_warpcore_lane(phy, params); |
| 3429 | /* |
| 3430 | * In Dual-lane mode, two lanes are joined together, |
| 3431 | * so in order to configure them, the AER broadcast method is |
| 3432 | * used here. |
| 3433 | * 0x200 is the broadcast address for lanes 0,1 |
| 3434 | * 0x201 is the broadcast address for lanes 2,3 |
| 3435 | */ |
| 3436 | if (phy->flags & FLAGS_WC_DUAL_MODE) |
| 3437 | aer_val = (aer_val >> 1) | 0x200; |
| 3438 | } else if (CHIP_IS_E2(bp)) |
Yaniv Rosner | 82a0d47 | 2011-01-18 04:33:52 +0000 | [diff] [blame] | 3439 | aer_val = 0x3800 + offset - 1; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 3440 | else |
| 3441 | aer_val = 0x3800 + offset; |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 3442 | DP(NETIF_MSG_LINK, "Set AER to 0x%x\n", aer_val); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 3443 | CL22_WR_OVER_CL45(bp, phy, MDIO_REG_BANK_AER_BLOCK, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3444 | MDIO_AER_BLOCK_AER_REG, aer_val); |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 3445 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3446 | } |
| 3447 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3448 | /******************************************************************/ |
| 3449 | /* Internal phy section */ |
| 3450 | /******************************************************************/ |
| 3451 | |
| 3452 | static void bnx2x_set_serdes_access(struct bnx2x *bp, u8 port) |
| 3453 | { |
| 3454 | u32 emac_base = (port) ? GRCBASE_EMAC1 : GRCBASE_EMAC0; |
| 3455 | |
| 3456 | /* Set Clause 22 */ |
| 3457 | REG_WR(bp, NIG_REG_SERDES0_CTRL_MD_ST + port*0x10, 1); |
| 3458 | REG_WR(bp, emac_base + EMAC_REG_EMAC_MDIO_COMM, 0x245f8000); |
| 3459 | udelay(500); |
| 3460 | REG_WR(bp, emac_base + EMAC_REG_EMAC_MDIO_COMM, 0x245d000f); |
| 3461 | udelay(500); |
| 3462 | /* Set Clause 45 */ |
| 3463 | REG_WR(bp, NIG_REG_SERDES0_CTRL_MD_ST + port*0x10, 0); |
| 3464 | } |
| 3465 | |
| 3466 | static void bnx2x_serdes_deassert(struct bnx2x *bp, u8 port) |
| 3467 | { |
| 3468 | u32 val; |
| 3469 | |
| 3470 | DP(NETIF_MSG_LINK, "bnx2x_serdes_deassert\n"); |
| 3471 | |
| 3472 | val = SERDES_RESET_BITS << (port*16); |
| 3473 | |
| 3474 | /* reset and unreset the SerDes/XGXS */ |
| 3475 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_3_CLEAR, val); |
| 3476 | udelay(500); |
| 3477 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_3_SET, val); |
| 3478 | |
| 3479 | bnx2x_set_serdes_access(bp, port); |
| 3480 | |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3481 | REG_WR(bp, NIG_REG_SERDES0_CTRL_MD_DEVAD + port*0x10, |
| 3482 | DEFAULT_PHY_DEV_ADDR); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3483 | } |
| 3484 | |
| 3485 | static void bnx2x_xgxs_deassert(struct link_params *params) |
| 3486 | { |
| 3487 | struct bnx2x *bp = params->bp; |
| 3488 | u8 port; |
| 3489 | u32 val; |
| 3490 | DP(NETIF_MSG_LINK, "bnx2x_xgxs_deassert\n"); |
| 3491 | port = params->port; |
| 3492 | |
| 3493 | val = XGXS_RESET_BITS << (port*16); |
| 3494 | |
| 3495 | /* reset and unreset the SerDes/XGXS */ |
| 3496 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_3_CLEAR, val); |
| 3497 | udelay(500); |
| 3498 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_3_SET, val); |
| 3499 | |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3500 | REG_WR(bp, NIG_REG_XGXS0_CTRL_MD_ST + port*0x18, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3501 | REG_WR(bp, NIG_REG_XGXS0_CTRL_MD_DEVAD + port*0x18, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3502 | params->phy[INT_PHY].def_md_devad); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3503 | } |
| 3504 | |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 3505 | static void bnx2x_calc_ieee_aneg_adv(struct bnx2x_phy *phy, |
| 3506 | struct link_params *params, u16 *ieee_fc) |
| 3507 | { |
| 3508 | struct bnx2x *bp = params->bp; |
| 3509 | *ieee_fc = MDIO_COMBO_IEEE0_AUTO_NEG_ADV_FULL_DUPLEX; |
| 3510 | /** |
| 3511 | * resolve pause mode and advertisement Please refer to Table |
| 3512 | * 28B-3 of the 802.3ab-1999 spec |
| 3513 | */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3514 | |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 3515 | switch (phy->req_flow_ctrl) { |
| 3516 | case BNX2X_FLOW_CTRL_AUTO: |
| 3517 | if (params->req_fc_auto_adv == BNX2X_FLOW_CTRL_BOTH) |
| 3518 | *ieee_fc |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH; |
| 3519 | else |
| 3520 | *ieee_fc |= |
| 3521 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC; |
| 3522 | break; |
| 3523 | |
| 3524 | case BNX2X_FLOW_CTRL_TX: |
| 3525 | *ieee_fc |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC; |
| 3526 | break; |
| 3527 | |
| 3528 | case BNX2X_FLOW_CTRL_RX: |
| 3529 | case BNX2X_FLOW_CTRL_BOTH: |
| 3530 | *ieee_fc |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH; |
| 3531 | break; |
| 3532 | |
| 3533 | case BNX2X_FLOW_CTRL_NONE: |
| 3534 | default: |
| 3535 | *ieee_fc |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_NONE; |
| 3536 | break; |
| 3537 | } |
| 3538 | DP(NETIF_MSG_LINK, "ieee_fc = 0x%x\n", *ieee_fc); |
| 3539 | } |
| 3540 | |
| 3541 | static void set_phy_vars(struct link_params *params, |
| 3542 | struct link_vars *vars) |
| 3543 | { |
| 3544 | struct bnx2x *bp = params->bp; |
| 3545 | u8 actual_phy_idx, phy_index, link_cfg_idx; |
| 3546 | u8 phy_config_swapped = params->multi_phy_config & |
| 3547 | PORT_HW_CFG_PHY_SWAPPED_ENABLED; |
| 3548 | for (phy_index = INT_PHY; phy_index < params->num_phys; |
| 3549 | phy_index++) { |
| 3550 | link_cfg_idx = LINK_CONFIG_IDX(phy_index); |
| 3551 | actual_phy_idx = phy_index; |
| 3552 | if (phy_config_swapped) { |
| 3553 | if (phy_index == EXT_PHY1) |
| 3554 | actual_phy_idx = EXT_PHY2; |
| 3555 | else if (phy_index == EXT_PHY2) |
| 3556 | actual_phy_idx = EXT_PHY1; |
| 3557 | } |
| 3558 | params->phy[actual_phy_idx].req_flow_ctrl = |
| 3559 | params->req_flow_ctrl[link_cfg_idx]; |
| 3560 | |
| 3561 | params->phy[actual_phy_idx].req_line_speed = |
| 3562 | params->req_line_speed[link_cfg_idx]; |
| 3563 | |
| 3564 | params->phy[actual_phy_idx].speed_cap_mask = |
| 3565 | params->speed_cap_mask[link_cfg_idx]; |
| 3566 | |
| 3567 | params->phy[actual_phy_idx].req_duplex = |
| 3568 | params->req_duplex[link_cfg_idx]; |
| 3569 | |
| 3570 | if (params->req_line_speed[link_cfg_idx] == |
| 3571 | SPEED_AUTO_NEG) |
| 3572 | vars->link_status |= LINK_STATUS_AUTO_NEGOTIATE_ENABLED; |
| 3573 | |
| 3574 | DP(NETIF_MSG_LINK, "req_flow_ctrl %x, req_line_speed %x," |
| 3575 | " speed_cap_mask %x\n", |
| 3576 | params->phy[actual_phy_idx].req_flow_ctrl, |
| 3577 | params->phy[actual_phy_idx].req_line_speed, |
| 3578 | params->phy[actual_phy_idx].speed_cap_mask); |
| 3579 | } |
| 3580 | } |
| 3581 | |
| 3582 | static void bnx2x_ext_phy_set_pause(struct link_params *params, |
| 3583 | struct bnx2x_phy *phy, |
| 3584 | struct link_vars *vars) |
| 3585 | { |
| 3586 | u16 val; |
| 3587 | struct bnx2x *bp = params->bp; |
| 3588 | /* read modify write pause advertizing */ |
| 3589 | bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_ADV_PAUSE, &val); |
| 3590 | |
| 3591 | val &= ~MDIO_AN_REG_ADV_PAUSE_BOTH; |
| 3592 | |
| 3593 | /* Please refer to Table 28B-3 of 802.3ab-1999 spec. */ |
| 3594 | bnx2x_calc_ieee_aneg_adv(phy, params, &vars->ieee_fc); |
| 3595 | if ((vars->ieee_fc & |
| 3596 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC) == |
| 3597 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC) { |
| 3598 | val |= MDIO_AN_REG_ADV_PAUSE_ASYMMETRIC; |
| 3599 | } |
| 3600 | if ((vars->ieee_fc & |
| 3601 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) == |
| 3602 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) { |
| 3603 | val |= MDIO_AN_REG_ADV_PAUSE_PAUSE; |
| 3604 | } |
| 3605 | DP(NETIF_MSG_LINK, "Ext phy AN advertize 0x%x\n", val); |
| 3606 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_ADV_PAUSE, val); |
| 3607 | } |
| 3608 | |
| 3609 | static void bnx2x_pause_resolve(struct link_vars *vars, u32 pause_result) |
| 3610 | { /* LD LP */ |
| 3611 | switch (pause_result) { /* ASYM P ASYM P */ |
| 3612 | case 0xb: /* 1 0 1 1 */ |
| 3613 | vars->flow_ctrl = BNX2X_FLOW_CTRL_TX; |
| 3614 | break; |
| 3615 | |
| 3616 | case 0xe: /* 1 1 1 0 */ |
| 3617 | vars->flow_ctrl = BNX2X_FLOW_CTRL_RX; |
| 3618 | break; |
| 3619 | |
| 3620 | case 0x5: /* 0 1 0 1 */ |
| 3621 | case 0x7: /* 0 1 1 1 */ |
| 3622 | case 0xd: /* 1 1 0 1 */ |
| 3623 | case 0xf: /* 1 1 1 1 */ |
| 3624 | vars->flow_ctrl = BNX2X_FLOW_CTRL_BOTH; |
| 3625 | break; |
| 3626 | |
| 3627 | default: |
| 3628 | break; |
| 3629 | } |
| 3630 | if (pause_result & (1<<0)) |
| 3631 | vars->link_status |= LINK_STATUS_LINK_PARTNER_SYMMETRIC_PAUSE; |
| 3632 | if (pause_result & (1<<1)) |
| 3633 | vars->link_status |= LINK_STATUS_LINK_PARTNER_ASYMMETRIC_PAUSE; |
| 3634 | } |
| 3635 | |
| 3636 | static u8 bnx2x_ext_phy_resolve_fc(struct bnx2x_phy *phy, |
| 3637 | struct link_params *params, |
| 3638 | struct link_vars *vars) |
| 3639 | { |
| 3640 | struct bnx2x *bp = params->bp; |
| 3641 | u16 ld_pause; /* local */ |
| 3642 | u16 lp_pause; /* link partner */ |
| 3643 | u16 pause_result; |
| 3644 | u8 ret = 0; |
| 3645 | /* read twice */ |
| 3646 | |
| 3647 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 3648 | |
| 3649 | if (phy->req_flow_ctrl != BNX2X_FLOW_CTRL_AUTO) |
| 3650 | vars->flow_ctrl = phy->req_flow_ctrl; |
| 3651 | else if (phy->req_line_speed != SPEED_AUTO_NEG) |
| 3652 | vars->flow_ctrl = params->req_fc_auto_adv; |
| 3653 | else if (vars->link_status & LINK_STATUS_AUTO_NEGOTIATE_COMPLETE) { |
| 3654 | ret = 1; |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 3655 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54618SE) { |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 3656 | bnx2x_cl22_read(bp, phy, |
| 3657 | 0x4, &ld_pause); |
| 3658 | bnx2x_cl22_read(bp, phy, |
| 3659 | 0x5, &lp_pause); |
| 3660 | } else { |
| 3661 | bnx2x_cl45_read(bp, phy, |
| 3662 | MDIO_AN_DEVAD, |
| 3663 | MDIO_AN_REG_ADV_PAUSE, &ld_pause); |
| 3664 | bnx2x_cl45_read(bp, phy, |
| 3665 | MDIO_AN_DEVAD, |
| 3666 | MDIO_AN_REG_LP_AUTO_NEG, &lp_pause); |
| 3667 | } |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 3668 | pause_result = (ld_pause & |
| 3669 | MDIO_AN_REG_ADV_PAUSE_MASK) >> 8; |
| 3670 | pause_result |= (lp_pause & |
| 3671 | MDIO_AN_REG_ADV_PAUSE_MASK) >> 10; |
| 3672 | DP(NETIF_MSG_LINK, "Ext PHY pause result 0x%x\n", |
| 3673 | pause_result); |
| 3674 | bnx2x_pause_resolve(vars, pause_result); |
| 3675 | } |
| 3676 | return ret; |
| 3677 | } |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 3678 | /******************************************************************/ |
| 3679 | /* Warpcore section */ |
| 3680 | /******************************************************************/ |
| 3681 | /* The init_internal_warpcore should mirror the xgxs, |
| 3682 | * i.e. reset the lane (if needed), set aer for the |
| 3683 | * init configuration, and set/clear SGMII flag. Internal |
| 3684 | * phy init is done purely in phy_init stage. |
| 3685 | */ |
| 3686 | static void bnx2x_warpcore_enable_AN_KR(struct bnx2x_phy *phy, |
| 3687 | struct link_params *params, |
| 3688 | struct link_vars *vars) { |
Yaniv Rosner | a34bc96 | 2011-07-05 01:06:41 +0000 | [diff] [blame] | 3689 | u16 val16 = 0, lane, bam37 = 0; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 3690 | struct bnx2x *bp = params->bp; |
| 3691 | DP(NETIF_MSG_LINK, "Enable Auto Negotiation for KR\n"); |
Yaniv Rosner | a9077bf | 2011-10-27 05:09:46 +0000 | [diff] [blame] | 3692 | |
| 3693 | /* Disable Autoneg: re-enable it after adv is done. */ |
| 3694 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, |
| 3695 | MDIO_WC_REG_IEEE0BLK_MIICNTL, 0); |
| 3696 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 3697 | /* Check adding advertisement for 1G KX */ |
| 3698 | if (((vars->line_speed == SPEED_AUTO_NEG) && |
| 3699 | (phy->speed_cap_mask & PORT_HW_CFG_SPEED_CAPABILITY_D0_1G)) || |
| 3700 | (vars->line_speed == SPEED_1000)) { |
| 3701 | u16 sd_digital; |
| 3702 | val16 |= (1<<5); |
| 3703 | |
| 3704 | /* Enable CL37 1G Parallel Detect */ |
| 3705 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 3706 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2, &sd_digital); |
| 3707 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3708 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2, |
| 3709 | (sd_digital | 0x1)); |
| 3710 | |
| 3711 | DP(NETIF_MSG_LINK, "Advertize 1G\n"); |
| 3712 | } |
| 3713 | if (((vars->line_speed == SPEED_AUTO_NEG) && |
| 3714 | (phy->speed_cap_mask & PORT_HW_CFG_SPEED_CAPABILITY_D0_10G)) || |
| 3715 | (vars->line_speed == SPEED_10000)) { |
| 3716 | /* Check adding advertisement for 10G KR */ |
| 3717 | val16 |= (1<<7); |
| 3718 | /* Enable 10G Parallel Detect */ |
| 3719 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, |
| 3720 | MDIO_WC_REG_PAR_DET_10G_CTRL, 1); |
| 3721 | |
| 3722 | DP(NETIF_MSG_LINK, "Advertize 10G\n"); |
| 3723 | } |
| 3724 | |
| 3725 | /* Set Transmit PMD settings */ |
| 3726 | lane = bnx2x_get_warpcore_lane(phy, params); |
| 3727 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3728 | MDIO_WC_REG_TX0_TX_DRIVER + 0x10*lane, |
| 3729 | ((0x02 << MDIO_WC_REG_TX0_TX_DRIVER_POST2_COEFF_OFFSET) | |
| 3730 | (0x06 << MDIO_WC_REG_TX0_TX_DRIVER_IDRIVER_OFFSET) | |
| 3731 | (0x09 << MDIO_WC_REG_TX0_TX_DRIVER_IPRE_DRIVER_OFFSET))); |
| 3732 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3733 | MDIO_WC_REG_CL72_USERB0_CL72_OS_DEF_CTRL, |
| 3734 | 0x03f0); |
| 3735 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3736 | MDIO_WC_REG_CL72_USERB0_CL72_2P5_DEF_CTRL, |
| 3737 | 0x03f0); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 3738 | |
| 3739 | /* Advertised speeds */ |
| 3740 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, |
| 3741 | MDIO_WC_REG_AN_IEEE1BLK_AN_ADVERTISEMENT1, val16); |
| 3742 | |
David S. Miller | 8decf86 | 2011-09-22 03:23:13 -0400 | [diff] [blame] | 3743 | /* Advertised and set FEC (Forward Error Correction) */ |
| 3744 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, |
| 3745 | MDIO_WC_REG_AN_IEEE1BLK_AN_ADVERTISEMENT2, |
| 3746 | (MDIO_WC_REG_AN_IEEE1BLK_AN_ADV2_FEC_ABILITY | |
| 3747 | MDIO_WC_REG_AN_IEEE1BLK_AN_ADV2_FEC_REQ)); |
| 3748 | |
Yaniv Rosner | a34bc96 | 2011-07-05 01:06:41 +0000 | [diff] [blame] | 3749 | /* Enable CL37 BAM */ |
| 3750 | if (REG_RD(bp, params->shmem_base + |
| 3751 | offsetof(struct shmem_region, dev_info. |
| 3752 | port_hw_config[params->port].default_cfg)) & |
| 3753 | PORT_HW_CFG_ENABLE_BAM_ON_KR_ENABLED) { |
| 3754 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 3755 | MDIO_WC_REG_DIGITAL6_MP5_NEXTPAGECTRL, &bam37); |
| 3756 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3757 | MDIO_WC_REG_DIGITAL6_MP5_NEXTPAGECTRL, bam37 | 1); |
| 3758 | DP(NETIF_MSG_LINK, "Enable CL37 BAM on KR\n"); |
| 3759 | } |
| 3760 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 3761 | /* Advertise pause */ |
| 3762 | bnx2x_ext_phy_set_pause(params, phy, vars); |
| 3763 | |
Yaniv Rosner | a9077bf | 2011-10-27 05:09:46 +0000 | [diff] [blame] | 3764 | vars->rx_tx_asic_rst = MAX_KR_LINK_RETRY; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 3765 | |
| 3766 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 3767 | MDIO_WC_REG_DIGITAL5_MISC7, &val16); |
| 3768 | |
| 3769 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3770 | MDIO_WC_REG_DIGITAL5_MISC7, val16 | 0x100); |
Yaniv Rosner | a9077bf | 2011-10-27 05:09:46 +0000 | [diff] [blame] | 3771 | |
| 3772 | /* Over 1G - AN local device user page 1 */ |
| 3773 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3774 | MDIO_WC_REG_DIGITAL3_UP1, 0x1f); |
| 3775 | |
| 3776 | /* Enable Autoneg */ |
| 3777 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, |
| 3778 | MDIO_WC_REG_IEEE0BLK_MIICNTL, 0x1000); |
| 3779 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 3780 | } |
| 3781 | |
| 3782 | static void bnx2x_warpcore_set_10G_KR(struct bnx2x_phy *phy, |
| 3783 | struct link_params *params, |
| 3784 | struct link_vars *vars) |
| 3785 | { |
| 3786 | struct bnx2x *bp = params->bp; |
| 3787 | u16 val; |
| 3788 | |
| 3789 | /* Disable Autoneg */ |
| 3790 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3791 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2, 0x7); |
| 3792 | |
| 3793 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, |
| 3794 | MDIO_WC_REG_PAR_DET_10G_CTRL, 0); |
| 3795 | |
| 3796 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3797 | MDIO_WC_REG_CL72_USERB0_CL72_MISC1_CONTROL, 0x3f00); |
| 3798 | |
| 3799 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, |
| 3800 | MDIO_WC_REG_AN_IEEE1BLK_AN_ADVERTISEMENT1, 0); |
| 3801 | |
| 3802 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, |
| 3803 | MDIO_WC_REG_IEEE0BLK_MIICNTL, 0x0); |
| 3804 | |
| 3805 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3806 | MDIO_WC_REG_DIGITAL3_UP1, 0x1); |
| 3807 | |
| 3808 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3809 | MDIO_WC_REG_DIGITAL5_MISC7, 0xa); |
| 3810 | |
| 3811 | /* Disable CL36 PCS Tx */ |
| 3812 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3813 | MDIO_WC_REG_XGXSBLK1_LANECTRL0, 0x0); |
| 3814 | |
| 3815 | /* Double Wide Single Data Rate @ pll rate */ |
| 3816 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3817 | MDIO_WC_REG_XGXSBLK1_LANECTRL1, 0xFFFF); |
| 3818 | |
| 3819 | /* Leave cl72 training enable, needed for KR */ |
| 3820 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, |
| 3821 | MDIO_WC_REG_PMD_IEEE9BLK_TENGBASE_KR_PMD_CONTROL_REGISTER_150, |
| 3822 | 0x2); |
| 3823 | |
| 3824 | /* Leave CL72 enabled */ |
| 3825 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 3826 | MDIO_WC_REG_CL72_USERB0_CL72_MISC1_CONTROL, |
| 3827 | &val); |
| 3828 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3829 | MDIO_WC_REG_CL72_USERB0_CL72_MISC1_CONTROL, |
| 3830 | val | 0x3800); |
| 3831 | |
| 3832 | /* Set speed via PMA/PMD register */ |
| 3833 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, |
| 3834 | MDIO_WC_REG_IEEE0BLK_MIICNTL, 0x2040); |
| 3835 | |
| 3836 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, |
| 3837 | MDIO_WC_REG_IEEE0BLK_AUTONEGNP, 0xB); |
| 3838 | |
| 3839 | /*Enable encoded forced speed */ |
| 3840 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3841 | MDIO_WC_REG_SERDESDIGITAL_MISC2, 0x30); |
| 3842 | |
| 3843 | /* Turn TX scramble payload only the 64/66 scrambler */ |
| 3844 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3845 | MDIO_WC_REG_TX66_CONTROL, 0x9); |
| 3846 | |
| 3847 | /* Turn RX scramble payload only the 64/66 scrambler */ |
| 3848 | bnx2x_cl45_read_or_write(bp, phy, MDIO_WC_DEVAD, |
| 3849 | MDIO_WC_REG_RX66_CONTROL, 0xF9); |
| 3850 | |
| 3851 | /* set and clear loopback to cause a reset to 64/66 decoder */ |
| 3852 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3853 | MDIO_WC_REG_IEEE0BLK_MIICNTL, 0x4000); |
| 3854 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3855 | MDIO_WC_REG_IEEE0BLK_MIICNTL, 0x0); |
| 3856 | |
| 3857 | } |
| 3858 | |
| 3859 | static void bnx2x_warpcore_set_10G_XFI(struct bnx2x_phy *phy, |
| 3860 | struct link_params *params, |
| 3861 | u8 is_xfi) |
| 3862 | { |
| 3863 | struct bnx2x *bp = params->bp; |
| 3864 | u16 misc1_val, tap_val, tx_driver_val, lane, val; |
| 3865 | /* Hold rxSeqStart */ |
| 3866 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 3867 | MDIO_WC_REG_DSC2B0_DSC_MISC_CTRL0, &val); |
| 3868 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3869 | MDIO_WC_REG_DSC2B0_DSC_MISC_CTRL0, (val | 0x8000)); |
| 3870 | |
| 3871 | /* Hold tx_fifo_reset */ |
| 3872 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 3873 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X3, &val); |
| 3874 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3875 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X3, (val | 0x1)); |
| 3876 | |
| 3877 | /* Disable CL73 AN */ |
| 3878 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, 0); |
| 3879 | |
| 3880 | /* Disable 100FX Enable and Auto-Detect */ |
| 3881 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 3882 | MDIO_WC_REG_FX100_CTRL1, &val); |
| 3883 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3884 | MDIO_WC_REG_FX100_CTRL1, (val & 0xFFFA)); |
| 3885 | |
| 3886 | /* Disable 100FX Idle detect */ |
| 3887 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 3888 | MDIO_WC_REG_FX100_CTRL3, &val); |
| 3889 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3890 | MDIO_WC_REG_FX100_CTRL3, (val | 0x0080)); |
| 3891 | |
| 3892 | /* Set Block address to Remote PHY & Clear forced_speed[5] */ |
| 3893 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 3894 | MDIO_WC_REG_DIGITAL4_MISC3, &val); |
| 3895 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3896 | MDIO_WC_REG_DIGITAL4_MISC3, (val & 0xFF7F)); |
| 3897 | |
| 3898 | /* Turn off auto-detect & fiber mode */ |
| 3899 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 3900 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X1, &val); |
| 3901 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3902 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X1, |
| 3903 | (val & 0xFFEE)); |
| 3904 | |
| 3905 | /* Set filter_force_link, disable_false_link and parallel_detect */ |
| 3906 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 3907 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2, &val); |
| 3908 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3909 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2, |
| 3910 | ((val | 0x0006) & 0xFFFE)); |
| 3911 | |
| 3912 | /* Set XFI / SFI */ |
| 3913 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 3914 | MDIO_WC_REG_SERDESDIGITAL_MISC1, &misc1_val); |
| 3915 | |
| 3916 | misc1_val &= ~(0x1f); |
| 3917 | |
| 3918 | if (is_xfi) { |
| 3919 | misc1_val |= 0x5; |
| 3920 | tap_val = ((0x08 << MDIO_WC_REG_TX_FIR_TAP_POST_TAP_OFFSET) | |
| 3921 | (0x37 << MDIO_WC_REG_TX_FIR_TAP_MAIN_TAP_OFFSET) | |
| 3922 | (0x00 << MDIO_WC_REG_TX_FIR_TAP_PRE_TAP_OFFSET)); |
| 3923 | tx_driver_val = |
| 3924 | ((0x00 << MDIO_WC_REG_TX0_TX_DRIVER_POST2_COEFF_OFFSET) | |
| 3925 | (0x02 << MDIO_WC_REG_TX0_TX_DRIVER_IDRIVER_OFFSET) | |
| 3926 | (0x03 << MDIO_WC_REG_TX0_TX_DRIVER_IPRE_DRIVER_OFFSET)); |
| 3927 | |
| 3928 | } else { |
| 3929 | misc1_val |= 0x9; |
| 3930 | tap_val = ((0x12 << MDIO_WC_REG_TX_FIR_TAP_POST_TAP_OFFSET) | |
| 3931 | (0x2d << MDIO_WC_REG_TX_FIR_TAP_MAIN_TAP_OFFSET) | |
| 3932 | (0x00 << MDIO_WC_REG_TX_FIR_TAP_PRE_TAP_OFFSET)); |
| 3933 | tx_driver_val = |
| 3934 | ((0x02 << MDIO_WC_REG_TX0_TX_DRIVER_POST2_COEFF_OFFSET) | |
| 3935 | (0x02 << MDIO_WC_REG_TX0_TX_DRIVER_IDRIVER_OFFSET) | |
| 3936 | (0x02 << MDIO_WC_REG_TX0_TX_DRIVER_IPRE_DRIVER_OFFSET)); |
| 3937 | } |
| 3938 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3939 | MDIO_WC_REG_SERDESDIGITAL_MISC1, misc1_val); |
| 3940 | |
| 3941 | /* Set Transmit PMD settings */ |
| 3942 | lane = bnx2x_get_warpcore_lane(phy, params); |
| 3943 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3944 | MDIO_WC_REG_TX_FIR_TAP, |
| 3945 | tap_val | MDIO_WC_REG_TX_FIR_TAP_ENABLE); |
| 3946 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3947 | MDIO_WC_REG_TX0_TX_DRIVER + 0x10*lane, |
| 3948 | tx_driver_val); |
| 3949 | |
| 3950 | /* Enable fiber mode, enable and invert sig_det */ |
| 3951 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 3952 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X1, &val); |
| 3953 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3954 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X1, val | 0xd); |
| 3955 | |
| 3956 | /* Set Block address to Remote PHY & Set forced_speed[5], 40bit mode */ |
| 3957 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 3958 | MDIO_WC_REG_DIGITAL4_MISC3, &val); |
| 3959 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3960 | MDIO_WC_REG_DIGITAL4_MISC3, val | 0x8080); |
| 3961 | |
| 3962 | /* 10G XFI Full Duplex */ |
| 3963 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3964 | MDIO_WC_REG_IEEE0BLK_MIICNTL, 0x100); |
| 3965 | |
| 3966 | /* Release tx_fifo_reset */ |
| 3967 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 3968 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X3, &val); |
| 3969 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3970 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X3, val & 0xFFFE); |
| 3971 | |
| 3972 | /* Release rxSeqStart */ |
| 3973 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 3974 | MDIO_WC_REG_DSC2B0_DSC_MISC_CTRL0, &val); |
| 3975 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3976 | MDIO_WC_REG_DSC2B0_DSC_MISC_CTRL0, (val & 0x7FFF)); |
| 3977 | } |
| 3978 | |
| 3979 | static void bnx2x_warpcore_set_20G_KR2(struct bnx2x *bp, |
| 3980 | struct bnx2x_phy *phy) |
| 3981 | { |
| 3982 | DP(NETIF_MSG_LINK, "KR2 still not supported !!!\n"); |
| 3983 | } |
| 3984 | |
| 3985 | static void bnx2x_warpcore_set_20G_DXGXS(struct bnx2x *bp, |
| 3986 | struct bnx2x_phy *phy, |
| 3987 | u16 lane) |
| 3988 | { |
| 3989 | /* Rx0 anaRxControl1G */ |
| 3990 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3991 | MDIO_WC_REG_RX0_ANARXCONTROL1G, 0x90); |
| 3992 | |
| 3993 | /* Rx2 anaRxControl1G */ |
| 3994 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3995 | MDIO_WC_REG_RX2_ANARXCONTROL1G, 0x90); |
| 3996 | |
| 3997 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3998 | MDIO_WC_REG_RX66_SCW0, 0xE070); |
| 3999 | |
| 4000 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4001 | MDIO_WC_REG_RX66_SCW1, 0xC0D0); |
| 4002 | |
| 4003 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4004 | MDIO_WC_REG_RX66_SCW2, 0xA0B0); |
| 4005 | |
| 4006 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4007 | MDIO_WC_REG_RX66_SCW3, 0x8090); |
| 4008 | |
| 4009 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4010 | MDIO_WC_REG_RX66_SCW0_MASK, 0xF0F0); |
| 4011 | |
| 4012 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4013 | MDIO_WC_REG_RX66_SCW1_MASK, 0xF0F0); |
| 4014 | |
| 4015 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4016 | MDIO_WC_REG_RX66_SCW2_MASK, 0xF0F0); |
| 4017 | |
| 4018 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4019 | MDIO_WC_REG_RX66_SCW3_MASK, 0xF0F0); |
| 4020 | |
| 4021 | /* Serdes Digital Misc1 */ |
| 4022 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4023 | MDIO_WC_REG_SERDESDIGITAL_MISC1, 0x6008); |
| 4024 | |
| 4025 | /* Serdes Digital4 Misc3 */ |
| 4026 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4027 | MDIO_WC_REG_DIGITAL4_MISC3, 0x8088); |
| 4028 | |
| 4029 | /* Set Transmit PMD settings */ |
| 4030 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4031 | MDIO_WC_REG_TX_FIR_TAP, |
| 4032 | ((0x12 << MDIO_WC_REG_TX_FIR_TAP_POST_TAP_OFFSET) | |
| 4033 | (0x2d << MDIO_WC_REG_TX_FIR_TAP_MAIN_TAP_OFFSET) | |
| 4034 | (0x00 << MDIO_WC_REG_TX_FIR_TAP_PRE_TAP_OFFSET) | |
| 4035 | MDIO_WC_REG_TX_FIR_TAP_ENABLE)); |
| 4036 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4037 | MDIO_WC_REG_TX0_TX_DRIVER + 0x10*lane, |
| 4038 | ((0x02 << MDIO_WC_REG_TX0_TX_DRIVER_POST2_COEFF_OFFSET) | |
| 4039 | (0x02 << MDIO_WC_REG_TX0_TX_DRIVER_IDRIVER_OFFSET) | |
| 4040 | (0x02 << MDIO_WC_REG_TX0_TX_DRIVER_IPRE_DRIVER_OFFSET))); |
| 4041 | } |
| 4042 | |
| 4043 | static void bnx2x_warpcore_set_sgmii_speed(struct bnx2x_phy *phy, |
| 4044 | struct link_params *params, |
| 4045 | u8 fiber_mode) |
| 4046 | { |
| 4047 | struct bnx2x *bp = params->bp; |
| 4048 | u16 val16, digctrl_kx1, digctrl_kx2; |
| 4049 | u8 lane; |
| 4050 | |
| 4051 | lane = bnx2x_get_warpcore_lane(phy, params); |
| 4052 | |
| 4053 | /* Clear XFI clock comp in non-10G single lane mode. */ |
| 4054 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4055 | MDIO_WC_REG_RX66_CONTROL, &val16); |
| 4056 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4057 | MDIO_WC_REG_RX66_CONTROL, val16 & ~(3<<13)); |
| 4058 | |
| 4059 | if (phy->req_line_speed == SPEED_AUTO_NEG) { |
| 4060 | /* SGMII Autoneg */ |
| 4061 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4062 | MDIO_WC_REG_COMBO_IEEE0_MIICTRL, &val16); |
| 4063 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4064 | MDIO_WC_REG_COMBO_IEEE0_MIICTRL, |
| 4065 | val16 | 0x1000); |
| 4066 | DP(NETIF_MSG_LINK, "set SGMII AUTONEG\n"); |
| 4067 | } else { |
| 4068 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4069 | MDIO_WC_REG_COMBO_IEEE0_MIICTRL, &val16); |
| 4070 | val16 &= 0xcfbf; |
| 4071 | switch (phy->req_line_speed) { |
| 4072 | case SPEED_10: |
| 4073 | break; |
| 4074 | case SPEED_100: |
| 4075 | val16 |= 0x2000; |
| 4076 | break; |
| 4077 | case SPEED_1000: |
| 4078 | val16 |= 0x0040; |
| 4079 | break; |
| 4080 | default: |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 4081 | DP(NETIF_MSG_LINK, |
| 4082 | "Speed not supported: 0x%x\n", phy->req_line_speed); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4083 | return; |
| 4084 | } |
| 4085 | |
| 4086 | if (phy->req_duplex == DUPLEX_FULL) |
| 4087 | val16 |= 0x0100; |
| 4088 | |
| 4089 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4090 | MDIO_WC_REG_COMBO_IEEE0_MIICTRL, val16); |
| 4091 | |
| 4092 | DP(NETIF_MSG_LINK, "set SGMII force speed %d\n", |
| 4093 | phy->req_line_speed); |
| 4094 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4095 | MDIO_WC_REG_COMBO_IEEE0_MIICTRL, &val16); |
| 4096 | DP(NETIF_MSG_LINK, " (readback) %x\n", val16); |
| 4097 | } |
| 4098 | |
| 4099 | /* SGMII Slave mode and disable signal detect */ |
| 4100 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4101 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X1, &digctrl_kx1); |
| 4102 | if (fiber_mode) |
| 4103 | digctrl_kx1 = 1; |
| 4104 | else |
| 4105 | digctrl_kx1 &= 0xff4a; |
| 4106 | |
| 4107 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4108 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X1, |
| 4109 | digctrl_kx1); |
| 4110 | |
| 4111 | /* Turn off parallel detect */ |
| 4112 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4113 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2, &digctrl_kx2); |
| 4114 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4115 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2, |
| 4116 | (digctrl_kx2 & ~(1<<2))); |
| 4117 | |
| 4118 | /* Re-enable parallel detect */ |
| 4119 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4120 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2, |
| 4121 | (digctrl_kx2 | (1<<2))); |
| 4122 | |
| 4123 | /* Enable autodet */ |
| 4124 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4125 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X1, |
| 4126 | (digctrl_kx1 | 0x10)); |
| 4127 | } |
| 4128 | |
| 4129 | static void bnx2x_warpcore_reset_lane(struct bnx2x *bp, |
| 4130 | struct bnx2x_phy *phy, |
| 4131 | u8 reset) |
| 4132 | { |
| 4133 | u16 val; |
| 4134 | /* Take lane out of reset after configuration is finished */ |
| 4135 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4136 | MDIO_WC_REG_DIGITAL5_MISC6, &val); |
| 4137 | if (reset) |
| 4138 | val |= 0xC000; |
| 4139 | else |
| 4140 | val &= 0x3FFF; |
| 4141 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4142 | MDIO_WC_REG_DIGITAL5_MISC6, val); |
| 4143 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4144 | MDIO_WC_REG_DIGITAL5_MISC6, &val); |
| 4145 | } |
| 4146 | |
| 4147 | |
| 4148 | /* Clear SFI/XFI link settings registers */ |
| 4149 | static void bnx2x_warpcore_clear_regs(struct bnx2x_phy *phy, |
| 4150 | struct link_params *params, |
| 4151 | u16 lane) |
| 4152 | { |
| 4153 | struct bnx2x *bp = params->bp; |
| 4154 | u16 val16; |
| 4155 | |
| 4156 | /* Set XFI clock comp as default. */ |
| 4157 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4158 | MDIO_WC_REG_RX66_CONTROL, &val16); |
| 4159 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4160 | MDIO_WC_REG_RX66_CONTROL, val16 | (3<<13)); |
| 4161 | |
| 4162 | bnx2x_warpcore_reset_lane(bp, phy, 1); |
| 4163 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, 0); |
| 4164 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4165 | MDIO_WC_REG_FX100_CTRL1, 0x014a); |
| 4166 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4167 | MDIO_WC_REG_FX100_CTRL3, 0x0800); |
| 4168 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4169 | MDIO_WC_REG_DIGITAL4_MISC3, 0x8008); |
| 4170 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4171 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X1, 0x0195); |
| 4172 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4173 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2, 0x0007); |
| 4174 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4175 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X3, 0x0002); |
| 4176 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4177 | MDIO_WC_REG_SERDESDIGITAL_MISC1, 0x6000); |
| 4178 | lane = bnx2x_get_warpcore_lane(phy, params); |
| 4179 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4180 | MDIO_WC_REG_TX_FIR_TAP, 0x0000); |
| 4181 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4182 | MDIO_WC_REG_TX0_TX_DRIVER + 0x10*lane, 0x0990); |
| 4183 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4184 | MDIO_WC_REG_IEEE0BLK_MIICNTL, 0x2040); |
| 4185 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4186 | MDIO_WC_REG_COMBO_IEEE0_MIICTRL, 0x0140); |
| 4187 | bnx2x_warpcore_reset_lane(bp, phy, 0); |
| 4188 | } |
| 4189 | |
| 4190 | static int bnx2x_get_mod_abs_int_cfg(struct bnx2x *bp, |
| 4191 | u32 chip_id, |
| 4192 | u32 shmem_base, u8 port, |
| 4193 | u8 *gpio_num, u8 *gpio_port) |
| 4194 | { |
| 4195 | u32 cfg_pin; |
| 4196 | *gpio_num = 0; |
| 4197 | *gpio_port = 0; |
| 4198 | if (CHIP_IS_E3(bp)) { |
| 4199 | cfg_pin = (REG_RD(bp, shmem_base + |
| 4200 | offsetof(struct shmem_region, |
| 4201 | dev_info.port_hw_config[port].e3_sfp_ctrl)) & |
| 4202 | PORT_HW_CFG_E3_MOD_ABS_MASK) >> |
| 4203 | PORT_HW_CFG_E3_MOD_ABS_SHIFT; |
| 4204 | |
| 4205 | /* |
| 4206 | * Should not happen. This function called upon interrupt |
| 4207 | * triggered by GPIO ( since EPIO can only generate interrupts |
| 4208 | * to MCP). |
| 4209 | * So if this function was called and none of the GPIOs was set, |
| 4210 | * it means the shit hit the fan. |
| 4211 | */ |
| 4212 | if ((cfg_pin < PIN_CFG_GPIO0_P0) || |
| 4213 | (cfg_pin > PIN_CFG_GPIO3_P1)) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 4214 | DP(NETIF_MSG_LINK, |
| 4215 | "ERROR: Invalid cfg pin %x for module detect indication\n", |
| 4216 | cfg_pin); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4217 | return -EINVAL; |
| 4218 | } |
| 4219 | |
| 4220 | *gpio_num = (cfg_pin - PIN_CFG_GPIO0_P0) & 0x3; |
| 4221 | *gpio_port = (cfg_pin - PIN_CFG_GPIO0_P0) >> 2; |
| 4222 | } else { |
| 4223 | *gpio_num = MISC_REGISTERS_GPIO_3; |
| 4224 | *gpio_port = port; |
| 4225 | } |
| 4226 | DP(NETIF_MSG_LINK, "MOD_ABS int GPIO%d_P%d\n", *gpio_num, *gpio_port); |
| 4227 | return 0; |
| 4228 | } |
| 4229 | |
| 4230 | static int bnx2x_is_sfp_module_plugged(struct bnx2x_phy *phy, |
| 4231 | struct link_params *params) |
| 4232 | { |
| 4233 | struct bnx2x *bp = params->bp; |
| 4234 | u8 gpio_num, gpio_port; |
| 4235 | u32 gpio_val; |
| 4236 | if (bnx2x_get_mod_abs_int_cfg(bp, params->chip_id, |
| 4237 | params->shmem_base, params->port, |
| 4238 | &gpio_num, &gpio_port) != 0) |
| 4239 | return 0; |
| 4240 | gpio_val = bnx2x_get_gpio(bp, gpio_num, gpio_port); |
| 4241 | |
| 4242 | /* Call the handling function in case module is detected */ |
| 4243 | if (gpio_val == 0) |
| 4244 | return 1; |
| 4245 | else |
| 4246 | return 0; |
| 4247 | } |
Yaniv Rosner | a9077bf | 2011-10-27 05:09:46 +0000 | [diff] [blame] | 4248 | static int bnx2x_warpcore_get_sigdet(struct bnx2x_phy *phy, |
| 4249 | struct link_params *params) |
| 4250 | { |
| 4251 | u16 gp2_status_reg0, lane; |
| 4252 | struct bnx2x *bp = params->bp; |
| 4253 | |
| 4254 | lane = bnx2x_get_warpcore_lane(phy, params); |
| 4255 | |
| 4256 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, MDIO_WC_REG_GP2_STATUS_GP_2_0, |
| 4257 | &gp2_status_reg0); |
| 4258 | |
| 4259 | return (gp2_status_reg0 >> (8+lane)) & 0x1; |
| 4260 | } |
| 4261 | |
| 4262 | static void bnx2x_warpcore_config_runtime(struct bnx2x_phy *phy, |
| 4263 | struct link_params *params, |
| 4264 | struct link_vars *vars) |
| 4265 | { |
| 4266 | struct bnx2x *bp = params->bp; |
| 4267 | u32 serdes_net_if; |
| 4268 | u16 gp_status1 = 0, lnkup = 0, lnkup_kr = 0; |
| 4269 | u16 lane = bnx2x_get_warpcore_lane(phy, params); |
| 4270 | |
| 4271 | vars->turn_to_run_wc_rt = vars->turn_to_run_wc_rt ? 0 : 1; |
| 4272 | |
| 4273 | if (!vars->turn_to_run_wc_rt) |
| 4274 | return; |
| 4275 | |
| 4276 | /* return if there is no link partner */ |
| 4277 | if (!(bnx2x_warpcore_get_sigdet(phy, params))) { |
| 4278 | DP(NETIF_MSG_LINK, "bnx2x_warpcore_get_sigdet false\n"); |
| 4279 | return; |
| 4280 | } |
| 4281 | |
| 4282 | if (vars->rx_tx_asic_rst) { |
| 4283 | serdes_net_if = (REG_RD(bp, params->shmem_base + |
| 4284 | offsetof(struct shmem_region, dev_info. |
| 4285 | port_hw_config[params->port].default_cfg)) & |
| 4286 | PORT_HW_CFG_NET_SERDES_IF_MASK); |
| 4287 | |
| 4288 | switch (serdes_net_if) { |
| 4289 | case PORT_HW_CFG_NET_SERDES_IF_KR: |
| 4290 | /* Do we get link yet? */ |
| 4291 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, 0x81d1, |
| 4292 | &gp_status1); |
| 4293 | lnkup = (gp_status1 >> (8+lane)) & 0x1;/* 1G */ |
| 4294 | /*10G KR*/ |
| 4295 | lnkup_kr = (gp_status1 >> (12+lane)) & 0x1; |
| 4296 | |
| 4297 | DP(NETIF_MSG_LINK, |
| 4298 | "gp_status1 0x%x\n", gp_status1); |
| 4299 | |
| 4300 | if (lnkup_kr || lnkup) { |
| 4301 | vars->rx_tx_asic_rst = 0; |
| 4302 | DP(NETIF_MSG_LINK, |
| 4303 | "link up, rx_tx_asic_rst 0x%x\n", |
| 4304 | vars->rx_tx_asic_rst); |
| 4305 | } else { |
| 4306 | /*reset the lane to see if link comes up.*/ |
| 4307 | bnx2x_warpcore_reset_lane(bp, phy, 1); |
| 4308 | bnx2x_warpcore_reset_lane(bp, phy, 0); |
| 4309 | |
| 4310 | /* restart Autoneg */ |
| 4311 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, |
| 4312 | MDIO_WC_REG_IEEE0BLK_MIICNTL, 0x1200); |
| 4313 | |
| 4314 | vars->rx_tx_asic_rst--; |
| 4315 | DP(NETIF_MSG_LINK, "0x%x retry left\n", |
| 4316 | vars->rx_tx_asic_rst); |
| 4317 | } |
| 4318 | break; |
| 4319 | |
| 4320 | default: |
| 4321 | break; |
| 4322 | } |
| 4323 | |
| 4324 | } /*params->rx_tx_asic_rst*/ |
| 4325 | |
| 4326 | } |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4327 | |
| 4328 | static void bnx2x_warpcore_config_init(struct bnx2x_phy *phy, |
| 4329 | struct link_params *params, |
| 4330 | struct link_vars *vars) |
| 4331 | { |
| 4332 | struct bnx2x *bp = params->bp; |
| 4333 | u32 serdes_net_if; |
| 4334 | u8 fiber_mode; |
| 4335 | u16 lane = bnx2x_get_warpcore_lane(phy, params); |
| 4336 | serdes_net_if = (REG_RD(bp, params->shmem_base + |
| 4337 | offsetof(struct shmem_region, dev_info. |
| 4338 | port_hw_config[params->port].default_cfg)) & |
| 4339 | PORT_HW_CFG_NET_SERDES_IF_MASK); |
| 4340 | DP(NETIF_MSG_LINK, "Begin Warpcore init, link_speed %d, " |
| 4341 | "serdes_net_if = 0x%x\n", |
| 4342 | vars->line_speed, serdes_net_if); |
| 4343 | bnx2x_set_aer_mmd(params, phy); |
| 4344 | |
| 4345 | vars->phy_flags |= PHY_XGXS_FLAG; |
| 4346 | if ((serdes_net_if == PORT_HW_CFG_NET_SERDES_IF_SGMII) || |
| 4347 | (phy->req_line_speed && |
| 4348 | ((phy->req_line_speed == SPEED_100) || |
| 4349 | (phy->req_line_speed == SPEED_10)))) { |
| 4350 | vars->phy_flags |= PHY_SGMII_FLAG; |
| 4351 | DP(NETIF_MSG_LINK, "Setting SGMII mode\n"); |
| 4352 | bnx2x_warpcore_clear_regs(phy, params, lane); |
| 4353 | bnx2x_warpcore_set_sgmii_speed(phy, params, 0); |
| 4354 | } else { |
| 4355 | switch (serdes_net_if) { |
| 4356 | case PORT_HW_CFG_NET_SERDES_IF_KR: |
| 4357 | /* Enable KR Auto Neg */ |
| 4358 | if (params->loopback_mode == LOOPBACK_NONE) |
| 4359 | bnx2x_warpcore_enable_AN_KR(phy, params, vars); |
| 4360 | else { |
| 4361 | DP(NETIF_MSG_LINK, "Setting KR 10G-Force\n"); |
| 4362 | bnx2x_warpcore_set_10G_KR(phy, params, vars); |
| 4363 | } |
| 4364 | break; |
| 4365 | |
| 4366 | case PORT_HW_CFG_NET_SERDES_IF_XFI: |
| 4367 | bnx2x_warpcore_clear_regs(phy, params, lane); |
| 4368 | if (vars->line_speed == SPEED_10000) { |
| 4369 | DP(NETIF_MSG_LINK, "Setting 10G XFI\n"); |
| 4370 | bnx2x_warpcore_set_10G_XFI(phy, params, 1); |
| 4371 | } else { |
| 4372 | if (SINGLE_MEDIA_DIRECT(params)) { |
| 4373 | DP(NETIF_MSG_LINK, "1G Fiber\n"); |
| 4374 | fiber_mode = 1; |
| 4375 | } else { |
| 4376 | DP(NETIF_MSG_LINK, "10/100/1G SGMII\n"); |
| 4377 | fiber_mode = 0; |
| 4378 | } |
| 4379 | bnx2x_warpcore_set_sgmii_speed(phy, |
| 4380 | params, |
| 4381 | fiber_mode); |
| 4382 | } |
| 4383 | |
| 4384 | break; |
| 4385 | |
| 4386 | case PORT_HW_CFG_NET_SERDES_IF_SFI: |
| 4387 | |
| 4388 | bnx2x_warpcore_clear_regs(phy, params, lane); |
| 4389 | if (vars->line_speed == SPEED_10000) { |
| 4390 | DP(NETIF_MSG_LINK, "Setting 10G SFI\n"); |
| 4391 | bnx2x_warpcore_set_10G_XFI(phy, params, 0); |
| 4392 | } else if (vars->line_speed == SPEED_1000) { |
| 4393 | DP(NETIF_MSG_LINK, "Setting 1G Fiber\n"); |
| 4394 | bnx2x_warpcore_set_sgmii_speed(phy, params, 1); |
| 4395 | } |
| 4396 | /* Issue Module detection */ |
| 4397 | if (bnx2x_is_sfp_module_plugged(phy, params)) |
| 4398 | bnx2x_sfp_module_detection(phy, params); |
| 4399 | break; |
| 4400 | |
| 4401 | case PORT_HW_CFG_NET_SERDES_IF_DXGXS: |
| 4402 | if (vars->line_speed != SPEED_20000) { |
| 4403 | DP(NETIF_MSG_LINK, "Speed not supported yet\n"); |
| 4404 | return; |
| 4405 | } |
| 4406 | DP(NETIF_MSG_LINK, "Setting 20G DXGXS\n"); |
| 4407 | bnx2x_warpcore_set_20G_DXGXS(bp, phy, lane); |
| 4408 | /* Issue Module detection */ |
| 4409 | |
| 4410 | bnx2x_sfp_module_detection(phy, params); |
| 4411 | break; |
| 4412 | |
| 4413 | case PORT_HW_CFG_NET_SERDES_IF_KR2: |
| 4414 | if (vars->line_speed != SPEED_20000) { |
| 4415 | DP(NETIF_MSG_LINK, "Speed not supported yet\n"); |
| 4416 | return; |
| 4417 | } |
| 4418 | DP(NETIF_MSG_LINK, "Setting 20G KR2\n"); |
| 4419 | bnx2x_warpcore_set_20G_KR2(bp, phy); |
| 4420 | break; |
| 4421 | |
| 4422 | default: |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 4423 | DP(NETIF_MSG_LINK, |
| 4424 | "Unsupported Serdes Net Interface 0x%x\n", |
| 4425 | serdes_net_if); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4426 | return; |
| 4427 | } |
| 4428 | } |
| 4429 | |
| 4430 | /* Take lane out of reset after configuration is finished */ |
| 4431 | bnx2x_warpcore_reset_lane(bp, phy, 0); |
| 4432 | DP(NETIF_MSG_LINK, "Exit config init\n"); |
| 4433 | } |
| 4434 | |
| 4435 | static void bnx2x_sfp_e3_set_transmitter(struct link_params *params, |
| 4436 | struct bnx2x_phy *phy, |
| 4437 | u8 tx_en) |
| 4438 | { |
| 4439 | struct bnx2x *bp = params->bp; |
| 4440 | u32 cfg_pin; |
| 4441 | u8 port = params->port; |
| 4442 | |
| 4443 | cfg_pin = REG_RD(bp, params->shmem_base + |
| 4444 | offsetof(struct shmem_region, |
| 4445 | dev_info.port_hw_config[port].e3_sfp_ctrl)) & |
| 4446 | PORT_HW_CFG_TX_LASER_MASK; |
| 4447 | /* Set the !tx_en since this pin is DISABLE_TX_LASER */ |
| 4448 | DP(NETIF_MSG_LINK, "Setting WC TX to %d\n", tx_en); |
| 4449 | /* For 20G, the expected pin to be used is 3 pins after the current */ |
| 4450 | |
| 4451 | bnx2x_set_cfg_pin(bp, cfg_pin, tx_en ^ 1); |
| 4452 | if (phy->speed_cap_mask & PORT_HW_CFG_SPEED_CAPABILITY_D0_20G) |
| 4453 | bnx2x_set_cfg_pin(bp, cfg_pin + 3, tx_en ^ 1); |
| 4454 | } |
| 4455 | |
| 4456 | static void bnx2x_warpcore_link_reset(struct bnx2x_phy *phy, |
| 4457 | struct link_params *params) |
| 4458 | { |
| 4459 | struct bnx2x *bp = params->bp; |
| 4460 | u16 val16; |
| 4461 | bnx2x_sfp_e3_set_transmitter(params, phy, 0); |
| 4462 | bnx2x_set_mdio_clk(bp, params->chip_id, params->port); |
| 4463 | bnx2x_set_aer_mmd(params, phy); |
| 4464 | /* Global register */ |
| 4465 | bnx2x_warpcore_reset_lane(bp, phy, 1); |
| 4466 | |
| 4467 | /* Clear loopback settings (if any) */ |
| 4468 | /* 10G & 20G */ |
| 4469 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4470 | MDIO_WC_REG_COMBO_IEEE0_MIICTRL, &val16); |
| 4471 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4472 | MDIO_WC_REG_COMBO_IEEE0_MIICTRL, val16 & |
| 4473 | 0xBFFF); |
| 4474 | |
| 4475 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4476 | MDIO_WC_REG_IEEE0BLK_MIICNTL, &val16); |
| 4477 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4478 | MDIO_WC_REG_IEEE0BLK_MIICNTL, val16 & 0xfffe); |
| 4479 | |
| 4480 | /* Update those 1-copy registers */ |
| 4481 | CL22_WR_OVER_CL45(bp, phy, MDIO_REG_BANK_AER_BLOCK, |
| 4482 | MDIO_AER_BLOCK_AER_REG, 0); |
| 4483 | /* Enable 1G MDIO (1-copy) */ |
| 4484 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4485 | MDIO_WC_REG_XGXSBLK0_XGXSCONTROL, |
| 4486 | &val16); |
| 4487 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4488 | MDIO_WC_REG_XGXSBLK0_XGXSCONTROL, |
| 4489 | val16 & ~0x10); |
| 4490 | |
| 4491 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4492 | MDIO_WC_REG_XGXSBLK1_LANECTRL2, &val16); |
| 4493 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4494 | MDIO_WC_REG_XGXSBLK1_LANECTRL2, |
| 4495 | val16 & 0xff00); |
| 4496 | |
| 4497 | } |
| 4498 | |
| 4499 | static void bnx2x_set_warpcore_loopback(struct bnx2x_phy *phy, |
| 4500 | struct link_params *params) |
| 4501 | { |
| 4502 | struct bnx2x *bp = params->bp; |
| 4503 | u16 val16; |
| 4504 | u32 lane; |
| 4505 | DP(NETIF_MSG_LINK, "Setting Warpcore loopback type %x, speed %d\n", |
| 4506 | params->loopback_mode, phy->req_line_speed); |
| 4507 | |
| 4508 | if (phy->req_line_speed < SPEED_10000) { |
| 4509 | /* 10/100/1000 */ |
| 4510 | |
| 4511 | /* Update those 1-copy registers */ |
| 4512 | CL22_WR_OVER_CL45(bp, phy, MDIO_REG_BANK_AER_BLOCK, |
| 4513 | MDIO_AER_BLOCK_AER_REG, 0); |
| 4514 | /* Enable 1G MDIO (1-copy) */ |
| 4515 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4516 | MDIO_WC_REG_XGXSBLK0_XGXSCONTROL, |
| 4517 | &val16); |
| 4518 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4519 | MDIO_WC_REG_XGXSBLK0_XGXSCONTROL, |
| 4520 | val16 | 0x10); |
| 4521 | /* Set 1G loopback based on lane (1-copy) */ |
| 4522 | lane = bnx2x_get_warpcore_lane(phy, params); |
| 4523 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4524 | MDIO_WC_REG_XGXSBLK1_LANECTRL2, &val16); |
| 4525 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4526 | MDIO_WC_REG_XGXSBLK1_LANECTRL2, |
| 4527 | val16 | (1<<lane)); |
| 4528 | |
| 4529 | /* Switch back to 4-copy registers */ |
| 4530 | bnx2x_set_aer_mmd(params, phy); |
| 4531 | /* Global loopback, not recommended. */ |
| 4532 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4533 | MDIO_WC_REG_COMBO_IEEE0_MIICTRL, &val16); |
| 4534 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4535 | MDIO_WC_REG_COMBO_IEEE0_MIICTRL, val16 | |
| 4536 | 0x4000); |
| 4537 | } else { |
| 4538 | /* 10G & 20G */ |
| 4539 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4540 | MDIO_WC_REG_COMBO_IEEE0_MIICTRL, &val16); |
| 4541 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4542 | MDIO_WC_REG_COMBO_IEEE0_MIICTRL, val16 | |
| 4543 | 0x4000); |
| 4544 | |
| 4545 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4546 | MDIO_WC_REG_IEEE0BLK_MIICNTL, &val16); |
| 4547 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4548 | MDIO_WC_REG_IEEE0BLK_MIICNTL, val16 | 0x1); |
| 4549 | } |
| 4550 | } |
| 4551 | |
| 4552 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4553 | void bnx2x_link_status_update(struct link_params *params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4554 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4555 | { |
| 4556 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 4557 | u8 link_10g_plus; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4558 | u8 port = params->port; |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 4559 | u32 sync_offset, media_types; |
Yaniv Rosner | fd36a2e | 2011-05-31 21:29:05 +0000 | [diff] [blame] | 4560 | /* Update PHY configuration */ |
| 4561 | set_phy_vars(params, vars); |
| 4562 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4563 | vars->link_status = REG_RD(bp, params->shmem_base + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4564 | offsetof(struct shmem_region, |
| 4565 | port_mb[port].link_status)); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4566 | |
| 4567 | vars->link_up = (vars->link_status & LINK_STATUS_LINK_UP); |
Yaniv Rosner | fd36a2e | 2011-05-31 21:29:05 +0000 | [diff] [blame] | 4568 | vars->phy_flags = PHY_XGXS_FLAG; |
Yaniv Rosner | de6f337 | 2011-08-02 22:59:25 +0000 | [diff] [blame] | 4569 | if (vars->link_status & LINK_STATUS_PHYSICAL_LINK_FLAG) |
| 4570 | vars->phy_flags |= PHY_PHYSICAL_LINK_FLAG; |
| 4571 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4572 | if (vars->link_up) { |
| 4573 | DP(NETIF_MSG_LINK, "phy link up\n"); |
| 4574 | |
| 4575 | vars->phy_link_up = 1; |
| 4576 | vars->duplex = DUPLEX_FULL; |
| 4577 | switch (vars->link_status & |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4578 | LINK_STATUS_SPEED_AND_DUPLEX_MASK) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4579 | case LINK_10THD: |
| 4580 | vars->duplex = DUPLEX_HALF; |
| 4581 | /* fall thru */ |
| 4582 | case LINK_10TFD: |
| 4583 | vars->line_speed = SPEED_10; |
| 4584 | break; |
| 4585 | |
| 4586 | case LINK_100TXHD: |
| 4587 | vars->duplex = DUPLEX_HALF; |
| 4588 | /* fall thru */ |
| 4589 | case LINK_100T4: |
| 4590 | case LINK_100TXFD: |
| 4591 | vars->line_speed = SPEED_100; |
| 4592 | break; |
| 4593 | |
| 4594 | case LINK_1000THD: |
| 4595 | vars->duplex = DUPLEX_HALF; |
| 4596 | /* fall thru */ |
| 4597 | case LINK_1000TFD: |
| 4598 | vars->line_speed = SPEED_1000; |
| 4599 | break; |
| 4600 | |
| 4601 | case LINK_2500THD: |
| 4602 | vars->duplex = DUPLEX_HALF; |
| 4603 | /* fall thru */ |
| 4604 | case LINK_2500TFD: |
| 4605 | vars->line_speed = SPEED_2500; |
| 4606 | break; |
| 4607 | |
| 4608 | case LINK_10GTFD: |
| 4609 | vars->line_speed = SPEED_10000; |
| 4610 | break; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4611 | case LINK_20GTFD: |
| 4612 | vars->line_speed = SPEED_20000; |
| 4613 | break; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4614 | default: |
| 4615 | break; |
| 4616 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4617 | vars->flow_ctrl = 0; |
| 4618 | if (vars->link_status & LINK_STATUS_TX_FLOW_CONTROL_ENABLED) |
| 4619 | vars->flow_ctrl |= BNX2X_FLOW_CTRL_TX; |
| 4620 | |
| 4621 | if (vars->link_status & LINK_STATUS_RX_FLOW_CONTROL_ENABLED) |
| 4622 | vars->flow_ctrl |= BNX2X_FLOW_CTRL_RX; |
| 4623 | |
| 4624 | if (!vars->flow_ctrl) |
| 4625 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 4626 | |
| 4627 | if (vars->line_speed && |
| 4628 | ((vars->line_speed == SPEED_10) || |
| 4629 | (vars->line_speed == SPEED_100))) { |
| 4630 | vars->phy_flags |= PHY_SGMII_FLAG; |
| 4631 | } else { |
| 4632 | vars->phy_flags &= ~PHY_SGMII_FLAG; |
| 4633 | } |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4634 | if (vars->line_speed && |
| 4635 | USES_WARPCORE(bp) && |
| 4636 | (vars->line_speed == SPEED_1000)) |
| 4637 | vars->phy_flags |= PHY_SGMII_FLAG; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4638 | /* anything 10 and over uses the bmac */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 4639 | link_10g_plus = (vars->line_speed >= SPEED_10000); |
| 4640 | |
| 4641 | if (link_10g_plus) { |
| 4642 | if (USES_WARPCORE(bp)) |
| 4643 | vars->mac_type = MAC_TYPE_XMAC; |
| 4644 | else |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4645 | vars->mac_type = MAC_TYPE_BMAC; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 4646 | } else { |
| 4647 | if (USES_WARPCORE(bp)) |
| 4648 | vars->mac_type = MAC_TYPE_UMAC; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4649 | else |
| 4650 | vars->mac_type = MAC_TYPE_EMAC; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 4651 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4652 | } else { /* link down */ |
| 4653 | DP(NETIF_MSG_LINK, "phy link down\n"); |
| 4654 | |
| 4655 | vars->phy_link_up = 0; |
| 4656 | |
| 4657 | vars->line_speed = 0; |
| 4658 | vars->duplex = DUPLEX_FULL; |
| 4659 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 4660 | |
| 4661 | /* indicate no mac active */ |
| 4662 | vars->mac_type = MAC_TYPE_NONE; |
Yaniv Rosner | de6f337 | 2011-08-02 22:59:25 +0000 | [diff] [blame] | 4663 | if (vars->link_status & LINK_STATUS_PHYSICAL_LINK_FLAG) |
| 4664 | vars->phy_flags |= PHY_HALF_OPEN_CONN_FLAG; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4665 | } |
| 4666 | |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 4667 | /* Sync media type */ |
| 4668 | sync_offset = params->shmem_base + |
| 4669 | offsetof(struct shmem_region, |
| 4670 | dev_info.port_hw_config[port].media_type); |
| 4671 | media_types = REG_RD(bp, sync_offset); |
| 4672 | |
| 4673 | params->phy[INT_PHY].media_type = |
| 4674 | (media_types & PORT_HW_CFG_MEDIA_TYPE_PHY0_MASK) >> |
| 4675 | PORT_HW_CFG_MEDIA_TYPE_PHY0_SHIFT; |
| 4676 | params->phy[EXT_PHY1].media_type = |
| 4677 | (media_types & PORT_HW_CFG_MEDIA_TYPE_PHY1_MASK) >> |
| 4678 | PORT_HW_CFG_MEDIA_TYPE_PHY1_SHIFT; |
| 4679 | params->phy[EXT_PHY2].media_type = |
| 4680 | (media_types & PORT_HW_CFG_MEDIA_TYPE_PHY2_MASK) >> |
| 4681 | PORT_HW_CFG_MEDIA_TYPE_PHY2_SHIFT; |
| 4682 | DP(NETIF_MSG_LINK, "media_types = 0x%x\n", media_types); |
| 4683 | |
Yaniv Rosner | 020c7e3 | 2011-05-31 21:28:43 +0000 | [diff] [blame] | 4684 | /* Sync AEU offset */ |
| 4685 | sync_offset = params->shmem_base + |
| 4686 | offsetof(struct shmem_region, |
| 4687 | dev_info.port_hw_config[port].aeu_int_mask); |
| 4688 | |
| 4689 | vars->aeu_int_mask = REG_RD(bp, sync_offset); |
| 4690 | |
Yaniv Rosner | b8d6d08 | 2011-07-05 01:06:27 +0000 | [diff] [blame] | 4691 | /* Sync PFC status */ |
| 4692 | if (vars->link_status & LINK_STATUS_PFC_ENABLED) |
| 4693 | params->feature_config_flags |= |
| 4694 | FEATURE_CONFIG_PFC_ENABLED; |
| 4695 | else |
| 4696 | params->feature_config_flags &= |
| 4697 | ~FEATURE_CONFIG_PFC_ENABLED; |
| 4698 | |
Yaniv Rosner | 020c7e3 | 2011-05-31 21:28:43 +0000 | [diff] [blame] | 4699 | DP(NETIF_MSG_LINK, "link_status 0x%x phy_link_up %x int_mask 0x%x\n", |
| 4700 | vars->link_status, vars->phy_link_up, vars->aeu_int_mask); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4701 | DP(NETIF_MSG_LINK, "line_speed %x duplex %x flow_ctrl 0x%x\n", |
| 4702 | vars->line_speed, vars->duplex, vars->flow_ctrl); |
| 4703 | } |
| 4704 | |
| 4705 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 4706 | static void bnx2x_set_master_ln(struct link_params *params, |
| 4707 | struct bnx2x_phy *phy) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4708 | { |
| 4709 | struct bnx2x *bp = params->bp; |
| 4710 | u16 new_master_ln, ser_lane; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4711 | ser_lane = ((params->lane_config & |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4712 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_MASK) >> |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4713 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_SHIFT); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4714 | |
| 4715 | /* set the master_ln for AN */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4716 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4717 | MDIO_REG_BANK_XGXS_BLOCK2, |
| 4718 | MDIO_XGXS_BLOCK2_TEST_MODE_LANE, |
| 4719 | &new_master_ln); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4720 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4721 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4722 | MDIO_REG_BANK_XGXS_BLOCK2 , |
| 4723 | MDIO_XGXS_BLOCK2_TEST_MODE_LANE, |
| 4724 | (new_master_ln | ser_lane)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4725 | } |
| 4726 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 4727 | static int bnx2x_reset_unicore(struct link_params *params, |
| 4728 | struct bnx2x_phy *phy, |
| 4729 | u8 set_serdes) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4730 | { |
| 4731 | struct bnx2x *bp = params->bp; |
| 4732 | u16 mii_control; |
| 4733 | u16 i; |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4734 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4735 | MDIO_REG_BANK_COMBO_IEEE0, |
| 4736 | MDIO_COMBO_IEEE0_MII_CONTROL, &mii_control); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4737 | |
| 4738 | /* reset the unicore */ |
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_COMBO_IEEE0, |
| 4741 | MDIO_COMBO_IEEE0_MII_CONTROL, |
| 4742 | (mii_control | |
| 4743 | MDIO_COMBO_IEEO_MII_CONTROL_RESET)); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 4744 | if (set_serdes) |
| 4745 | bnx2x_set_serdes_access(bp, params->port); |
Eilon Greenstein | c1b7399 | 2009-02-12 08:37:07 +0000 | [diff] [blame] | 4746 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4747 | /* wait for the reset to self clear */ |
| 4748 | for (i = 0; i < MDIO_ACCESS_TIMEOUT; i++) { |
| 4749 | udelay(5); |
| 4750 | |
| 4751 | /* the reset erased the previous bank value */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4752 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4753 | MDIO_REG_BANK_COMBO_IEEE0, |
| 4754 | MDIO_COMBO_IEEE0_MII_CONTROL, |
| 4755 | &mii_control); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4756 | |
| 4757 | if (!(mii_control & MDIO_COMBO_IEEO_MII_CONTROL_RESET)) { |
| 4758 | udelay(5); |
| 4759 | return 0; |
| 4760 | } |
| 4761 | } |
| 4762 | |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 4763 | netdev_err(bp->dev, "Warning: PHY was not initialized," |
| 4764 | " Port %d\n", |
| 4765 | params->port); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4766 | DP(NETIF_MSG_LINK, "BUG! XGXS is still in reset!\n"); |
| 4767 | return -EINVAL; |
| 4768 | |
| 4769 | } |
| 4770 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 4771 | static void bnx2x_set_swap_lanes(struct link_params *params, |
| 4772 | struct bnx2x_phy *phy) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4773 | { |
| 4774 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 4775 | /* |
| 4776 | * Each two bits represents a lane number: |
| 4777 | * No swap is 0123 => 0x1b no need to enable the swap |
| 4778 | */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4779 | u16 ser_lane, rx_lane_swap, tx_lane_swap; |
| 4780 | |
| 4781 | ser_lane = ((params->lane_config & |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4782 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_MASK) >> |
| 4783 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_SHIFT); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4784 | rx_lane_swap = ((params->lane_config & |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4785 | PORT_HW_CFG_LANE_SWAP_CFG_RX_MASK) >> |
| 4786 | PORT_HW_CFG_LANE_SWAP_CFG_RX_SHIFT); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4787 | tx_lane_swap = ((params->lane_config & |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4788 | PORT_HW_CFG_LANE_SWAP_CFG_TX_MASK) >> |
| 4789 | PORT_HW_CFG_LANE_SWAP_CFG_TX_SHIFT); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4790 | |
| 4791 | if (rx_lane_swap != 0x1b) { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4792 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4793 | MDIO_REG_BANK_XGXS_BLOCK2, |
| 4794 | MDIO_XGXS_BLOCK2_RX_LN_SWAP, |
| 4795 | (rx_lane_swap | |
| 4796 | MDIO_XGXS_BLOCK2_RX_LN_SWAP_ENABLE | |
| 4797 | MDIO_XGXS_BLOCK2_RX_LN_SWAP_FORCE_ENABLE)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4798 | } else { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4799 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4800 | MDIO_REG_BANK_XGXS_BLOCK2, |
| 4801 | MDIO_XGXS_BLOCK2_RX_LN_SWAP, 0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4802 | } |
| 4803 | |
| 4804 | if (tx_lane_swap != 0x1b) { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4805 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4806 | MDIO_REG_BANK_XGXS_BLOCK2, |
| 4807 | MDIO_XGXS_BLOCK2_TX_LN_SWAP, |
| 4808 | (tx_lane_swap | |
| 4809 | MDIO_XGXS_BLOCK2_TX_LN_SWAP_ENABLE)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4810 | } else { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4811 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4812 | MDIO_REG_BANK_XGXS_BLOCK2, |
| 4813 | MDIO_XGXS_BLOCK2_TX_LN_SWAP, 0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4814 | } |
| 4815 | } |
| 4816 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 4817 | static void bnx2x_set_parallel_detection(struct bnx2x_phy *phy, |
| 4818 | struct link_params *params) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4819 | { |
| 4820 | struct bnx2x *bp = params->bp; |
| 4821 | u16 control2; |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4822 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4823 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 4824 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL2, |
| 4825 | &control2); |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 4826 | if (phy->speed_cap_mask & PORT_HW_CFG_SPEED_CAPABILITY_D0_1G) |
Yaniv Rosner | 18afb0a | 2009-11-05 19:18:04 +0200 | [diff] [blame] | 4827 | control2 |= MDIO_SERDES_DIGITAL_A_1000X_CONTROL2_PRL_DT_EN; |
| 4828 | else |
| 4829 | control2 &= ~MDIO_SERDES_DIGITAL_A_1000X_CONTROL2_PRL_DT_EN; |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 4830 | DP(NETIF_MSG_LINK, "phy->speed_cap_mask = 0x%x, control2 = 0x%x\n", |
| 4831 | phy->speed_cap_mask, control2); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4832 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4833 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 4834 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL2, |
| 4835 | control2); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4836 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 4837 | if ((phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT) && |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 4838 | (phy->speed_cap_mask & |
Yaniv Rosner | 18afb0a | 2009-11-05 19:18:04 +0200 | [diff] [blame] | 4839 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G)) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4840 | DP(NETIF_MSG_LINK, "XGXS\n"); |
| 4841 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4842 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4843 | MDIO_REG_BANK_10G_PARALLEL_DETECT, |
| 4844 | MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_LINK, |
| 4845 | MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_LINK_CNT); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4846 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4847 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4848 | MDIO_REG_BANK_10G_PARALLEL_DETECT, |
| 4849 | MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_CONTROL, |
| 4850 | &control2); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4851 | |
| 4852 | |
| 4853 | control2 |= |
| 4854 | MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_CONTROL_PARDET10G_EN; |
| 4855 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4856 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4857 | MDIO_REG_BANK_10G_PARALLEL_DETECT, |
| 4858 | MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_CONTROL, |
| 4859 | control2); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4860 | |
| 4861 | /* Disable parallel detection of HiG */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4862 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4863 | MDIO_REG_BANK_XGXS_BLOCK2, |
| 4864 | MDIO_XGXS_BLOCK2_UNICORE_MODE_10G, |
| 4865 | MDIO_XGXS_BLOCK2_UNICORE_MODE_10G_CX4_XGXS | |
| 4866 | MDIO_XGXS_BLOCK2_UNICORE_MODE_10G_HIGIG_XGXS); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4867 | } |
| 4868 | } |
| 4869 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 4870 | static void bnx2x_set_autoneg(struct bnx2x_phy *phy, |
| 4871 | struct link_params *params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4872 | struct link_vars *vars, |
| 4873 | u8 enable_cl73) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4874 | { |
| 4875 | struct bnx2x *bp = params->bp; |
| 4876 | u16 reg_val; |
| 4877 | |
| 4878 | /* CL37 Autoneg */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4879 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4880 | MDIO_REG_BANK_COMBO_IEEE0, |
| 4881 | MDIO_COMBO_IEEE0_MII_CONTROL, ®_val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4882 | |
| 4883 | /* CL37 Autoneg Enabled */ |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 4884 | if (vars->line_speed == SPEED_AUTO_NEG) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4885 | reg_val |= MDIO_COMBO_IEEO_MII_CONTROL_AN_EN; |
| 4886 | else /* CL37 Autoneg Disabled */ |
| 4887 | reg_val &= ~(MDIO_COMBO_IEEO_MII_CONTROL_AN_EN | |
| 4888 | MDIO_COMBO_IEEO_MII_CONTROL_RESTART_AN); |
| 4889 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4890 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4891 | MDIO_REG_BANK_COMBO_IEEE0, |
| 4892 | MDIO_COMBO_IEEE0_MII_CONTROL, reg_val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4893 | |
| 4894 | /* Enable/Disable Autodetection */ |
| 4895 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4896 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4897 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 4898 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL1, ®_val); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 4899 | reg_val &= ~(MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_SIGNAL_DETECT_EN | |
| 4900 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_INVERT_SIGNAL_DETECT); |
| 4901 | reg_val |= MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_FIBER_MODE; |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 4902 | if (vars->line_speed == SPEED_AUTO_NEG) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4903 | reg_val |= MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_AUTODET; |
| 4904 | else |
| 4905 | reg_val &= ~MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_AUTODET; |
| 4906 | |
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, reg_val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4910 | |
| 4911 | /* Enable TetonII and BAM autoneg */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4912 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4913 | MDIO_REG_BANK_BAM_NEXT_PAGE, |
| 4914 | MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL, |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4915 | ®_val); |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 4916 | if (vars->line_speed == SPEED_AUTO_NEG) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4917 | /* Enable BAM aneg Mode and TetonII aneg Mode */ |
| 4918 | reg_val |= (MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL_BAM_MODE | |
| 4919 | MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL_TETON_AN); |
| 4920 | } else { |
| 4921 | /* TetonII and BAM Autoneg Disabled */ |
| 4922 | reg_val &= ~(MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL_BAM_MODE | |
| 4923 | MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL_TETON_AN); |
| 4924 | } |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4925 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4926 | MDIO_REG_BANK_BAM_NEXT_PAGE, |
| 4927 | MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL, |
| 4928 | reg_val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4929 | |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 4930 | if (enable_cl73) { |
| 4931 | /* Enable Cl73 FSM status bits */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4932 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4933 | MDIO_REG_BANK_CL73_USERB0, |
| 4934 | MDIO_CL73_USERB0_CL73_UCTRL, |
| 4935 | 0xe); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 4936 | |
| 4937 | /* Enable BAM Station Manager*/ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4938 | CL22_WR_OVER_CL45(bp, phy, |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 4939 | MDIO_REG_BANK_CL73_USERB0, |
| 4940 | MDIO_CL73_USERB0_CL73_BAM_CTRL1, |
| 4941 | MDIO_CL73_USERB0_CL73_BAM_CTRL1_BAM_EN | |
| 4942 | MDIO_CL73_USERB0_CL73_BAM_CTRL1_BAM_STATION_MNGR_EN | |
| 4943 | MDIO_CL73_USERB0_CL73_BAM_CTRL1_BAM_NP_AFTER_BP_EN); |
| 4944 | |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 4945 | /* Advertise CL73 link speeds */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4946 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4947 | MDIO_REG_BANK_CL73_IEEEB1, |
| 4948 | MDIO_CL73_IEEEB1_AN_ADV2, |
| 4949 | ®_val); |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 4950 | if (phy->speed_cap_mask & |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 4951 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G) |
| 4952 | reg_val |= MDIO_CL73_IEEEB1_AN_ADV2_ADVR_10G_KX4; |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 4953 | if (phy->speed_cap_mask & |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 4954 | PORT_HW_CFG_SPEED_CAPABILITY_D0_1G) |
| 4955 | reg_val |= MDIO_CL73_IEEEB1_AN_ADV2_ADVR_1000M_KX; |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 4956 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4957 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4958 | MDIO_REG_BANK_CL73_IEEEB1, |
| 4959 | MDIO_CL73_IEEEB1_AN_ADV2, |
| 4960 | reg_val); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 4961 | |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 4962 | /* CL73 Autoneg Enabled */ |
| 4963 | reg_val = MDIO_CL73_IEEEB0_CL73_AN_CONTROL_AN_EN; |
| 4964 | |
| 4965 | } else /* CL73 Autoneg Disabled */ |
| 4966 | reg_val = 0; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4967 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4968 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4969 | MDIO_REG_BANK_CL73_IEEEB0, |
| 4970 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL, reg_val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4971 | } |
| 4972 | |
| 4973 | /* program SerDes, forced speed */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 4974 | static void bnx2x_program_serdes(struct bnx2x_phy *phy, |
| 4975 | struct link_params *params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4976 | struct link_vars *vars) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4977 | { |
| 4978 | struct bnx2x *bp = params->bp; |
| 4979 | u16 reg_val; |
| 4980 | |
Eilon Greenstein | 5793720 | 2009-08-12 08:23:53 +0000 | [diff] [blame] | 4981 | /* program duplex, disable autoneg and sgmii*/ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4982 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4983 | MDIO_REG_BANK_COMBO_IEEE0, |
| 4984 | MDIO_COMBO_IEEE0_MII_CONTROL, ®_val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4985 | reg_val &= ~(MDIO_COMBO_IEEO_MII_CONTROL_FULL_DUPLEX | |
Eilon Greenstein | 5793720 | 2009-08-12 08:23:53 +0000 | [diff] [blame] | 4986 | MDIO_COMBO_IEEO_MII_CONTROL_AN_EN | |
| 4987 | MDIO_COMBO_IEEO_MII_CONTROL_MAN_SGMII_SP_MASK); |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 4988 | if (phy->req_duplex == DUPLEX_FULL) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4989 | reg_val |= MDIO_COMBO_IEEO_MII_CONTROL_FULL_DUPLEX; |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4990 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4991 | MDIO_REG_BANK_COMBO_IEEE0, |
| 4992 | MDIO_COMBO_IEEE0_MII_CONTROL, reg_val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4993 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 4994 | /* |
| 4995 | * program speed |
| 4996 | * - needed only if the speed is greater than 1G (2.5G or 10G) |
| 4997 | */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4998 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4999 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 5000 | MDIO_SERDES_DIGITAL_MISC1, ®_val); |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 5001 | /* clearing the speed value before setting the right speed */ |
| 5002 | DP(NETIF_MSG_LINK, "MDIO_REG_BANK_SERDES_DIGITAL = 0x%x\n", reg_val); |
| 5003 | |
| 5004 | reg_val &= ~(MDIO_SERDES_DIGITAL_MISC1_FORCE_SPEED_MASK | |
| 5005 | MDIO_SERDES_DIGITAL_MISC1_FORCE_SPEED_SEL); |
| 5006 | |
| 5007 | if (!((vars->line_speed == SPEED_1000) || |
| 5008 | (vars->line_speed == SPEED_100) || |
| 5009 | (vars->line_speed == SPEED_10))) { |
| 5010 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5011 | reg_val |= (MDIO_SERDES_DIGITAL_MISC1_REFCLK_SEL_156_25M | |
| 5012 | MDIO_SERDES_DIGITAL_MISC1_FORCE_SPEED_SEL); |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 5013 | if (vars->line_speed == SPEED_10000) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5014 | reg_val |= |
| 5015 | MDIO_SERDES_DIGITAL_MISC1_FORCE_SPEED_10G_CX4; |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 5016 | } |
| 5017 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5018 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5019 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 5020 | MDIO_SERDES_DIGITAL_MISC1, reg_val); |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 5021 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5022 | } |
| 5023 | |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 5024 | static void bnx2x_set_brcm_cl37_advertisement(struct bnx2x_phy *phy, |
| 5025 | struct link_params *params) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5026 | { |
| 5027 | struct bnx2x *bp = params->bp; |
| 5028 | u16 val = 0; |
| 5029 | |
| 5030 | /* configure the 48 bits for BAM AN */ |
| 5031 | |
| 5032 | /* set extended capabilities */ |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 5033 | 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] | 5034 | val |= MDIO_OVER_1G_UP1_2_5G; |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 5035 | if (phy->speed_cap_mask & PORT_HW_CFG_SPEED_CAPABILITY_D0_10G) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5036 | val |= MDIO_OVER_1G_UP1_10G; |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5037 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5038 | MDIO_REG_BANK_OVER_1G, |
| 5039 | MDIO_OVER_1G_UP1, val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5040 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5041 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5042 | MDIO_REG_BANK_OVER_1G, |
| 5043 | MDIO_OVER_1G_UP3, 0x400); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5044 | } |
| 5045 | |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 5046 | static void bnx2x_set_ieee_aneg_advertisement(struct bnx2x_phy *phy, |
| 5047 | struct link_params *params, |
| 5048 | u16 ieee_fc) |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 5049 | { |
| 5050 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 5051 | u16 val; |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 5052 | /* for AN, we are always publishing full duplex */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5053 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5054 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5055 | MDIO_REG_BANK_COMBO_IEEE0, |
| 5056 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV, ieee_fc); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5057 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5058 | MDIO_REG_BANK_CL73_IEEEB1, |
| 5059 | MDIO_CL73_IEEEB1_AN_ADV1, &val); |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 5060 | val &= ~MDIO_CL73_IEEEB1_AN_ADV1_PAUSE_BOTH; |
| 5061 | val |= ((ieee_fc<<3) & MDIO_CL73_IEEEB1_AN_ADV1_PAUSE_MASK); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5062 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5063 | MDIO_REG_BANK_CL73_IEEEB1, |
| 5064 | MDIO_CL73_IEEEB1_AN_ADV1, val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5065 | } |
| 5066 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 5067 | static void bnx2x_restart_autoneg(struct bnx2x_phy *phy, |
| 5068 | struct link_params *params, |
| 5069 | u8 enable_cl73) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5070 | { |
| 5071 | struct bnx2x *bp = params->bp; |
Eilon Greenstein | 3a36f2e | 2009-02-12 08:37:09 +0000 | [diff] [blame] | 5072 | u16 mii_control; |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5073 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5074 | DP(NETIF_MSG_LINK, "bnx2x_restart_autoneg\n"); |
Eilon Greenstein | 3a36f2e | 2009-02-12 08:37:09 +0000 | [diff] [blame] | 5075 | /* Enable and restart BAM/CL37 aneg */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5076 | |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5077 | if (enable_cl73) { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5078 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5079 | MDIO_REG_BANK_CL73_IEEEB0, |
| 5080 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL, |
| 5081 | &mii_control); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5082 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5083 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5084 | MDIO_REG_BANK_CL73_IEEEB0, |
| 5085 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL, |
| 5086 | (mii_control | |
| 5087 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL_AN_EN | |
| 5088 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL_RESTART_AN)); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5089 | } else { |
| 5090 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5091 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5092 | MDIO_REG_BANK_COMBO_IEEE0, |
| 5093 | MDIO_COMBO_IEEE0_MII_CONTROL, |
| 5094 | &mii_control); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5095 | DP(NETIF_MSG_LINK, |
| 5096 | "bnx2x_restart_autoneg mii_control before = 0x%x\n", |
| 5097 | mii_control); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5098 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5099 | MDIO_REG_BANK_COMBO_IEEE0, |
| 5100 | MDIO_COMBO_IEEE0_MII_CONTROL, |
| 5101 | (mii_control | |
| 5102 | MDIO_COMBO_IEEO_MII_CONTROL_AN_EN | |
| 5103 | MDIO_COMBO_IEEO_MII_CONTROL_RESTART_AN)); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5104 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5105 | } |
| 5106 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 5107 | static void bnx2x_initialize_sgmii_process(struct bnx2x_phy *phy, |
| 5108 | struct link_params *params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5109 | struct link_vars *vars) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5110 | { |
| 5111 | struct bnx2x *bp = params->bp; |
| 5112 | u16 control1; |
| 5113 | |
| 5114 | /* in SGMII mode, the unicore is always slave */ |
| 5115 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5116 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5117 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 5118 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL1, |
| 5119 | &control1); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5120 | control1 |= MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_INVERT_SIGNAL_DETECT; |
| 5121 | /* set sgmii mode (and not fiber) */ |
| 5122 | control1 &= ~(MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_FIBER_MODE | |
| 5123 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_AUTODET | |
| 5124 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_MSTR_MODE); |
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_SERDES_DIGITAL, |
| 5127 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL1, |
| 5128 | control1); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5129 | |
| 5130 | /* if forced speed */ |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 5131 | if (!(vars->line_speed == SPEED_AUTO_NEG)) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5132 | /* set speed, disable autoneg */ |
| 5133 | u16 mii_control; |
| 5134 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5135 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5136 | MDIO_REG_BANK_COMBO_IEEE0, |
| 5137 | MDIO_COMBO_IEEE0_MII_CONTROL, |
| 5138 | &mii_control); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5139 | mii_control &= ~(MDIO_COMBO_IEEO_MII_CONTROL_AN_EN | |
| 5140 | MDIO_COMBO_IEEO_MII_CONTROL_MAN_SGMII_SP_MASK| |
| 5141 | MDIO_COMBO_IEEO_MII_CONTROL_FULL_DUPLEX); |
| 5142 | |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 5143 | switch (vars->line_speed) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5144 | case SPEED_100: |
| 5145 | mii_control |= |
| 5146 | MDIO_COMBO_IEEO_MII_CONTROL_MAN_SGMII_SP_100; |
| 5147 | break; |
| 5148 | case SPEED_1000: |
| 5149 | mii_control |= |
| 5150 | MDIO_COMBO_IEEO_MII_CONTROL_MAN_SGMII_SP_1000; |
| 5151 | break; |
| 5152 | case SPEED_10: |
| 5153 | /* there is nothing to set for 10M */ |
| 5154 | break; |
| 5155 | default: |
| 5156 | /* invalid speed for SGMII */ |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 5157 | DP(NETIF_MSG_LINK, "Invalid line_speed 0x%x\n", |
| 5158 | vars->line_speed); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5159 | break; |
| 5160 | } |
| 5161 | |
| 5162 | /* setting the full duplex */ |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 5163 | if (phy->req_duplex == DUPLEX_FULL) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5164 | mii_control |= |
| 5165 | MDIO_COMBO_IEEO_MII_CONTROL_FULL_DUPLEX; |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5166 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5167 | MDIO_REG_BANK_COMBO_IEEE0, |
| 5168 | MDIO_COMBO_IEEE0_MII_CONTROL, |
| 5169 | mii_control); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5170 | |
| 5171 | } else { /* AN mode */ |
| 5172 | /* enable and restart AN */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 5173 | bnx2x_restart_autoneg(phy, params, 0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5174 | } |
| 5175 | } |
| 5176 | |
| 5177 | |
| 5178 | /* |
| 5179 | * link management |
| 5180 | */ |
| 5181 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 5182 | static int bnx2x_direct_parallel_detect_used(struct bnx2x_phy *phy, |
| 5183 | struct link_params *params) |
Yaniv Rosner | 15ddd2d | 2009-11-05 19:18:12 +0200 | [diff] [blame] | 5184 | { |
| 5185 | struct bnx2x *bp = params->bp; |
| 5186 | u16 pd_10g, status2_1000x; |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 5187 | if (phy->req_line_speed != SPEED_AUTO_NEG) |
| 5188 | return 0; |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5189 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5190 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 5191 | MDIO_SERDES_DIGITAL_A_1000X_STATUS2, |
| 5192 | &status2_1000x); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5193 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5194 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 5195 | MDIO_SERDES_DIGITAL_A_1000X_STATUS2, |
| 5196 | &status2_1000x); |
Yaniv Rosner | 15ddd2d | 2009-11-05 19:18:12 +0200 | [diff] [blame] | 5197 | if (status2_1000x & MDIO_SERDES_DIGITAL_A_1000X_STATUS2_AN_DISABLED) { |
| 5198 | DP(NETIF_MSG_LINK, "1G parallel detect link on port %d\n", |
| 5199 | params->port); |
| 5200 | return 1; |
| 5201 | } |
| 5202 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5203 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5204 | MDIO_REG_BANK_10G_PARALLEL_DETECT, |
| 5205 | MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_STATUS, |
| 5206 | &pd_10g); |
Yaniv Rosner | 15ddd2d | 2009-11-05 19:18:12 +0200 | [diff] [blame] | 5207 | |
| 5208 | if (pd_10g & MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_STATUS_PD_LINK) { |
| 5209 | DP(NETIF_MSG_LINK, "10G parallel detect link on port %d\n", |
| 5210 | params->port); |
| 5211 | return 1; |
| 5212 | } |
| 5213 | return 0; |
| 5214 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5215 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 5216 | static void bnx2x_flow_ctrl_resolve(struct bnx2x_phy *phy, |
| 5217 | struct link_params *params, |
| 5218 | struct link_vars *vars, |
| 5219 | u32 gp_status) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5220 | { |
| 5221 | struct bnx2x *bp = params->bp; |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 5222 | u16 ld_pause; /* local driver */ |
| 5223 | u16 lp_pause; /* link partner */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5224 | u16 pause_result; |
| 5225 | |
David S. Miller | c0700f9 | 2008-12-16 23:53:20 -0800 | [diff] [blame] | 5226 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5227 | |
| 5228 | /* resolve from gp_status in case of AN complete and not sgmii */ |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 5229 | if (phy->req_flow_ctrl != BNX2X_FLOW_CTRL_AUTO) |
| 5230 | vars->flow_ctrl = phy->req_flow_ctrl; |
| 5231 | else if (phy->req_line_speed != SPEED_AUTO_NEG) |
| 5232 | vars->flow_ctrl = params->req_fc_auto_adv; |
| 5233 | else if ((gp_status & MDIO_AN_CL73_OR_37_COMPLETE) && |
| 5234 | (!(vars->phy_flags & PHY_SGMII_FLAG))) { |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 5235 | if (bnx2x_direct_parallel_detect_used(phy, params)) { |
Yaniv Rosner | 15ddd2d | 2009-11-05 19:18:12 +0200 | [diff] [blame] | 5236 | vars->flow_ctrl = params->req_fc_auto_adv; |
| 5237 | return; |
| 5238 | } |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 5239 | if ((gp_status & |
| 5240 | (MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_AUTONEG_COMPLETE | |
| 5241 | MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_MR_LP_NP_AN_ABLE)) == |
| 5242 | (MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_AUTONEG_COMPLETE | |
| 5243 | MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_MR_LP_NP_AN_ABLE)) { |
| 5244 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5245 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5246 | MDIO_REG_BANK_CL73_IEEEB1, |
| 5247 | MDIO_CL73_IEEEB1_AN_ADV1, |
| 5248 | &ld_pause); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5249 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5250 | MDIO_REG_BANK_CL73_IEEEB1, |
| 5251 | MDIO_CL73_IEEEB1_AN_LP_ADV1, |
| 5252 | &lp_pause); |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 5253 | pause_result = (ld_pause & |
| 5254 | MDIO_CL73_IEEEB1_AN_ADV1_PAUSE_MASK) |
| 5255 | >> 8; |
| 5256 | pause_result |= (lp_pause & |
| 5257 | MDIO_CL73_IEEEB1_AN_LP_ADV1_PAUSE_MASK) |
| 5258 | >> 10; |
| 5259 | DP(NETIF_MSG_LINK, "pause_result CL73 0x%x\n", |
| 5260 | pause_result); |
| 5261 | } else { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5262 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5263 | MDIO_REG_BANK_COMBO_IEEE0, |
| 5264 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV, |
| 5265 | &ld_pause); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5266 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5267 | MDIO_REG_BANK_COMBO_IEEE0, |
| 5268 | MDIO_COMBO_IEEE0_AUTO_NEG_LINK_PARTNER_ABILITY1, |
| 5269 | &lp_pause); |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 5270 | pause_result = (ld_pause & |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5271 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_MASK)>>5; |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 5272 | pause_result |= (lp_pause & |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5273 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_MASK)>>7; |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 5274 | DP(NETIF_MSG_LINK, "pause_result CL37 0x%x\n", |
| 5275 | pause_result); |
| 5276 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5277 | bnx2x_pause_resolve(vars, pause_result); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5278 | } |
| 5279 | DP(NETIF_MSG_LINK, "flow_ctrl 0x%x\n", vars->flow_ctrl); |
| 5280 | } |
| 5281 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 5282 | static void bnx2x_check_fallback_to_cl37(struct bnx2x_phy *phy, |
| 5283 | struct link_params *params) |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5284 | { |
| 5285 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 5286 | u16 rx_status, ustat_val, cl37_fsm_received; |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5287 | DP(NETIF_MSG_LINK, "bnx2x_check_fallback_to_cl37\n"); |
| 5288 | /* Step 1: Make sure signal is detected */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5289 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5290 | MDIO_REG_BANK_RX0, |
| 5291 | MDIO_RX0_RX_STATUS, |
| 5292 | &rx_status); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5293 | if ((rx_status & MDIO_RX0_RX_STATUS_SIGDET) != |
| 5294 | (MDIO_RX0_RX_STATUS_SIGDET)) { |
| 5295 | DP(NETIF_MSG_LINK, "Signal is not detected. Restoring CL73." |
| 5296 | "rx_status(0x80b0) = 0x%x\n", rx_status); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5297 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5298 | MDIO_REG_BANK_CL73_IEEEB0, |
| 5299 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL, |
| 5300 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL_AN_EN); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5301 | return; |
| 5302 | } |
| 5303 | /* Step 2: Check CL73 state machine */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5304 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5305 | MDIO_REG_BANK_CL73_USERB0, |
| 5306 | MDIO_CL73_USERB0_CL73_USTAT1, |
| 5307 | &ustat_val); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5308 | if ((ustat_val & |
| 5309 | (MDIO_CL73_USERB0_CL73_USTAT1_LINK_STATUS_CHECK | |
| 5310 | MDIO_CL73_USERB0_CL73_USTAT1_AN_GOOD_CHECK_BAM37)) != |
| 5311 | (MDIO_CL73_USERB0_CL73_USTAT1_LINK_STATUS_CHECK | |
| 5312 | MDIO_CL73_USERB0_CL73_USTAT1_AN_GOOD_CHECK_BAM37)) { |
| 5313 | DP(NETIF_MSG_LINK, "CL73 state-machine is not stable. " |
| 5314 | "ustat_val(0x8371) = 0x%x\n", ustat_val); |
| 5315 | return; |
| 5316 | } |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5317 | /* |
| 5318 | * Step 3: Check CL37 Message Pages received to indicate LP |
| 5319 | * supports only CL37 |
| 5320 | */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5321 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5322 | MDIO_REG_BANK_REMOTE_PHY, |
| 5323 | MDIO_REMOTE_PHY_MISC_RX_STATUS, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 5324 | &cl37_fsm_received); |
| 5325 | if ((cl37_fsm_received & |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5326 | (MDIO_REMOTE_PHY_MISC_RX_STATUS_CL37_FSM_RECEIVED_OVER1G_MSG | |
| 5327 | MDIO_REMOTE_PHY_MISC_RX_STATUS_CL37_FSM_RECEIVED_BRCM_OUI_MSG)) != |
| 5328 | (MDIO_REMOTE_PHY_MISC_RX_STATUS_CL37_FSM_RECEIVED_OVER1G_MSG | |
| 5329 | MDIO_REMOTE_PHY_MISC_RX_STATUS_CL37_FSM_RECEIVED_BRCM_OUI_MSG)) { |
| 5330 | DP(NETIF_MSG_LINK, "No CL37 FSM were received. " |
| 5331 | "misc_rx_status(0x8330) = 0x%x\n", |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 5332 | cl37_fsm_received); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5333 | return; |
| 5334 | } |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5335 | /* |
| 5336 | * The combined cl37/cl73 fsm state information indicating that |
| 5337 | * we are connected to a device which does not support cl73, but |
| 5338 | * does support cl37 BAM. In this case we disable cl73 and |
| 5339 | * restart cl37 auto-neg |
| 5340 | */ |
| 5341 | |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5342 | /* Disable CL73 */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5343 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5344 | MDIO_REG_BANK_CL73_IEEEB0, |
| 5345 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL, |
| 5346 | 0); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5347 | /* Restart CL37 autoneg */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 5348 | bnx2x_restart_autoneg(phy, params, 0); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5349 | DP(NETIF_MSG_LINK, "Disabling CL73, and restarting CL37 autoneg\n"); |
| 5350 | } |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 5351 | |
| 5352 | static void bnx2x_xgxs_an_resolve(struct bnx2x_phy *phy, |
| 5353 | struct link_params *params, |
| 5354 | struct link_vars *vars, |
| 5355 | u32 gp_status) |
| 5356 | { |
| 5357 | if (gp_status & MDIO_AN_CL73_OR_37_COMPLETE) |
| 5358 | vars->link_status |= |
| 5359 | LINK_STATUS_AUTO_NEGOTIATE_COMPLETE; |
| 5360 | |
| 5361 | if (bnx2x_direct_parallel_detect_used(phy, params)) |
| 5362 | vars->link_status |= |
| 5363 | LINK_STATUS_PARALLEL_DETECTION_USED; |
| 5364 | } |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5365 | static int bnx2x_get_link_speed_duplex(struct bnx2x_phy *phy, |
| 5366 | struct link_params *params, |
| 5367 | struct link_vars *vars, |
| 5368 | u16 is_link_up, |
| 5369 | u16 speed_mask, |
| 5370 | u16 is_duplex) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5371 | { |
| 5372 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 5373 | if (phy->req_line_speed == SPEED_AUTO_NEG) |
| 5374 | vars->link_status |= LINK_STATUS_AUTO_NEGOTIATE_ENABLED; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5375 | if (is_link_up) { |
| 5376 | DP(NETIF_MSG_LINK, "phy link up\n"); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5377 | |
| 5378 | vars->phy_link_up = 1; |
| 5379 | vars->link_status |= LINK_STATUS_LINK_UP; |
| 5380 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5381 | switch (speed_mask) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5382 | case GP_STATUS_10M: |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5383 | vars->line_speed = SPEED_10; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5384 | if (vars->duplex == DUPLEX_FULL) |
| 5385 | vars->link_status |= LINK_10TFD; |
| 5386 | else |
| 5387 | vars->link_status |= LINK_10THD; |
| 5388 | break; |
| 5389 | |
| 5390 | case GP_STATUS_100M: |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5391 | vars->line_speed = SPEED_100; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5392 | if (vars->duplex == DUPLEX_FULL) |
| 5393 | vars->link_status |= LINK_100TXFD; |
| 5394 | else |
| 5395 | vars->link_status |= LINK_100TXHD; |
| 5396 | break; |
| 5397 | |
| 5398 | case GP_STATUS_1G: |
| 5399 | case GP_STATUS_1G_KX: |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5400 | vars->line_speed = SPEED_1000; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5401 | if (vars->duplex == DUPLEX_FULL) |
| 5402 | vars->link_status |= LINK_1000TFD; |
| 5403 | else |
| 5404 | vars->link_status |= LINK_1000THD; |
| 5405 | break; |
| 5406 | |
| 5407 | case GP_STATUS_2_5G: |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5408 | vars->line_speed = SPEED_2500; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5409 | if (vars->duplex == DUPLEX_FULL) |
| 5410 | vars->link_status |= LINK_2500TFD; |
| 5411 | else |
| 5412 | vars->link_status |= LINK_2500THD; |
| 5413 | break; |
| 5414 | |
| 5415 | case GP_STATUS_5G: |
| 5416 | case GP_STATUS_6G: |
| 5417 | DP(NETIF_MSG_LINK, |
| 5418 | "link speed unsupported gp_status 0x%x\n", |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5419 | speed_mask); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5420 | return -EINVAL; |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 5421 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5422 | case GP_STATUS_10G_KX4: |
| 5423 | case GP_STATUS_10G_HIG: |
| 5424 | case GP_STATUS_10G_CX4: |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5425 | case GP_STATUS_10G_KR: |
| 5426 | case GP_STATUS_10G_SFI: |
| 5427 | case GP_STATUS_10G_XFI: |
| 5428 | vars->line_speed = SPEED_10000; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5429 | vars->link_status |= LINK_10GTFD; |
| 5430 | break; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5431 | case GP_STATUS_20G_DXGXS: |
| 5432 | vars->line_speed = SPEED_20000; |
| 5433 | vars->link_status |= LINK_20GTFD; |
| 5434 | break; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5435 | default: |
| 5436 | DP(NETIF_MSG_LINK, |
| 5437 | "link speed unsupported gp_status 0x%x\n", |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5438 | speed_mask); |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 5439 | return -EINVAL; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5440 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5441 | } else { /* link_down */ |
| 5442 | DP(NETIF_MSG_LINK, "phy link down\n"); |
| 5443 | |
| 5444 | vars->phy_link_up = 0; |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 5445 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5446 | vars->duplex = DUPLEX_FULL; |
David S. Miller | c0700f9 | 2008-12-16 23:53:20 -0800 | [diff] [blame] | 5447 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5448 | vars->mac_type = MAC_TYPE_NONE; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5449 | } |
| 5450 | DP(NETIF_MSG_LINK, " phy_link_up %x line_speed %d\n", |
| 5451 | vars->phy_link_up, vars->line_speed); |
| 5452 | return 0; |
| 5453 | } |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5454 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5455 | static int bnx2x_link_settings_status(struct bnx2x_phy *phy, |
| 5456 | struct link_params *params, |
| 5457 | struct link_vars *vars) |
| 5458 | { |
| 5459 | |
| 5460 | struct bnx2x *bp = params->bp; |
| 5461 | |
| 5462 | u16 gp_status, duplex = DUPLEX_HALF, link_up = 0, speed_mask; |
| 5463 | int rc = 0; |
| 5464 | |
| 5465 | /* Read gp_status */ |
| 5466 | CL22_RD_OVER_CL45(bp, phy, |
| 5467 | MDIO_REG_BANK_GP_STATUS, |
| 5468 | MDIO_GP_STATUS_TOP_AN_STATUS1, |
| 5469 | &gp_status); |
| 5470 | if (gp_status & MDIO_GP_STATUS_TOP_AN_STATUS1_DUPLEX_STATUS) |
| 5471 | duplex = DUPLEX_FULL; |
| 5472 | if (gp_status & MDIO_GP_STATUS_TOP_AN_STATUS1_LINK_STATUS) |
| 5473 | link_up = 1; |
| 5474 | speed_mask = gp_status & GP_STATUS_SPEED_MASK; |
| 5475 | DP(NETIF_MSG_LINK, "gp_status 0x%x, is_link_up %d, speed_mask 0x%x\n", |
| 5476 | gp_status, link_up, speed_mask); |
| 5477 | rc = bnx2x_get_link_speed_duplex(phy, params, vars, link_up, speed_mask, |
| 5478 | duplex); |
| 5479 | if (rc == -EINVAL) |
| 5480 | return rc; |
| 5481 | |
| 5482 | if (gp_status & MDIO_GP_STATUS_TOP_AN_STATUS1_LINK_STATUS) { |
| 5483 | if (SINGLE_MEDIA_DIRECT(params)) { |
| 5484 | bnx2x_flow_ctrl_resolve(phy, params, vars, gp_status); |
| 5485 | if (phy->req_line_speed == SPEED_AUTO_NEG) |
| 5486 | bnx2x_xgxs_an_resolve(phy, params, vars, |
| 5487 | gp_status); |
| 5488 | } |
| 5489 | } else { /* link_down */ |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 5490 | if ((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 5491 | SINGLE_MEDIA_DIRECT(params)) { |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5492 | /* Check signal is detected */ |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 5493 | bnx2x_check_fallback_to_cl37(phy, params); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5494 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5495 | } |
| 5496 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5497 | DP(NETIF_MSG_LINK, "duplex %x flow_ctrl 0x%x link_status 0x%x\n", |
| 5498 | vars->duplex, vars->flow_ctrl, vars->link_status); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5499 | return rc; |
| 5500 | } |
| 5501 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5502 | static int bnx2x_warpcore_read_status(struct bnx2x_phy *phy, |
| 5503 | struct link_params *params, |
| 5504 | struct link_vars *vars) |
| 5505 | { |
| 5506 | |
| 5507 | struct bnx2x *bp = params->bp; |
| 5508 | |
| 5509 | u8 lane; |
| 5510 | u16 gp_status1, gp_speed, link_up, duplex = DUPLEX_FULL; |
| 5511 | int rc = 0; |
| 5512 | lane = bnx2x_get_warpcore_lane(phy, params); |
| 5513 | /* Read gp_status */ |
| 5514 | if (phy->req_line_speed > SPEED_10000) { |
| 5515 | u16 temp_link_up; |
| 5516 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 5517 | 1, &temp_link_up); |
| 5518 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 5519 | 1, &link_up); |
| 5520 | DP(NETIF_MSG_LINK, "PCS RX link status = 0x%x-->0x%x\n", |
| 5521 | temp_link_up, link_up); |
| 5522 | link_up &= (1<<2); |
| 5523 | if (link_up) |
| 5524 | bnx2x_ext_phy_resolve_fc(phy, params, vars); |
| 5525 | } else { |
| 5526 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 5527 | MDIO_WC_REG_GP2_STATUS_GP_2_1, &gp_status1); |
| 5528 | DP(NETIF_MSG_LINK, "0x81d1 = 0x%x\n", gp_status1); |
| 5529 | /* Check for either KR or generic link up. */ |
| 5530 | gp_status1 = ((gp_status1 >> 8) & 0xf) | |
| 5531 | ((gp_status1 >> 12) & 0xf); |
| 5532 | link_up = gp_status1 & (1 << lane); |
| 5533 | if (link_up && SINGLE_MEDIA_DIRECT(params)) { |
| 5534 | u16 pd, gp_status4; |
| 5535 | if (phy->req_line_speed == SPEED_AUTO_NEG) { |
| 5536 | /* Check Autoneg complete */ |
| 5537 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 5538 | MDIO_WC_REG_GP2_STATUS_GP_2_4, |
| 5539 | &gp_status4); |
| 5540 | if (gp_status4 & ((1<<12)<<lane)) |
| 5541 | vars->link_status |= |
| 5542 | LINK_STATUS_AUTO_NEGOTIATE_COMPLETE; |
| 5543 | |
| 5544 | /* Check parallel detect used */ |
| 5545 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 5546 | MDIO_WC_REG_PAR_DET_10G_STATUS, |
| 5547 | &pd); |
| 5548 | if (pd & (1<<15)) |
| 5549 | vars->link_status |= |
| 5550 | LINK_STATUS_PARALLEL_DETECTION_USED; |
| 5551 | } |
| 5552 | bnx2x_ext_phy_resolve_fc(phy, params, vars); |
| 5553 | } |
| 5554 | } |
| 5555 | |
| 5556 | if (lane < 2) { |
| 5557 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 5558 | MDIO_WC_REG_GP2_STATUS_GP_2_2, &gp_speed); |
| 5559 | } else { |
| 5560 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 5561 | MDIO_WC_REG_GP2_STATUS_GP_2_3, &gp_speed); |
| 5562 | } |
| 5563 | DP(NETIF_MSG_LINK, "lane %d gp_speed 0x%x\n", lane, gp_speed); |
| 5564 | |
| 5565 | if ((lane & 1) == 0) |
| 5566 | gp_speed <<= 8; |
| 5567 | gp_speed &= 0x3f00; |
| 5568 | |
| 5569 | |
| 5570 | rc = bnx2x_get_link_speed_duplex(phy, params, vars, link_up, gp_speed, |
| 5571 | duplex); |
| 5572 | |
| 5573 | DP(NETIF_MSG_LINK, "duplex %x flow_ctrl 0x%x link_status 0x%x\n", |
| 5574 | vars->duplex, vars->flow_ctrl, vars->link_status); |
| 5575 | return rc; |
| 5576 | } |
Eilon Greenstein | ed8680a | 2009-02-12 08:37:12 +0000 | [diff] [blame] | 5577 | static void bnx2x_set_gmii_tx_driver(struct link_params *params) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5578 | { |
| 5579 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 5580 | struct bnx2x_phy *phy = ¶ms->phy[INT_PHY]; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5581 | u16 lp_up2; |
| 5582 | u16 tx_driver; |
Eilon Greenstein | c2c8b03 | 2009-02-12 08:37:14 +0000 | [diff] [blame] | 5583 | u16 bank; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5584 | |
| 5585 | /* read precomp */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5586 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5587 | MDIO_REG_BANK_OVER_1G, |
| 5588 | MDIO_OVER_1G_LP_UP2, &lp_up2); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5589 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5590 | /* bits [10:7] at lp_up2, positioned at [15:12] */ |
| 5591 | lp_up2 = (((lp_up2 & MDIO_OVER_1G_LP_UP2_PREEMPHASIS_MASK) >> |
| 5592 | MDIO_OVER_1G_LP_UP2_PREEMPHASIS_SHIFT) << |
| 5593 | MDIO_TX0_TX_DRIVER_PREEMPHASIS_SHIFT); |
| 5594 | |
Eilon Greenstein | c2c8b03 | 2009-02-12 08:37:14 +0000 | [diff] [blame] | 5595 | if (lp_up2 == 0) |
| 5596 | return; |
| 5597 | |
| 5598 | for (bank = MDIO_REG_BANK_TX0; bank <= MDIO_REG_BANK_TX3; |
| 5599 | bank += (MDIO_REG_BANK_TX1 - MDIO_REG_BANK_TX0)) { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5600 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5601 | bank, |
| 5602 | MDIO_TX0_TX_DRIVER, &tx_driver); |
Eilon Greenstein | c2c8b03 | 2009-02-12 08:37:14 +0000 | [diff] [blame] | 5603 | |
| 5604 | /* replace tx_driver bits [15:12] */ |
| 5605 | if (lp_up2 != |
| 5606 | (tx_driver & MDIO_TX0_TX_DRIVER_PREEMPHASIS_MASK)) { |
| 5607 | tx_driver &= ~MDIO_TX0_TX_DRIVER_PREEMPHASIS_MASK; |
| 5608 | tx_driver |= lp_up2; |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5609 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5610 | bank, |
| 5611 | MDIO_TX0_TX_DRIVER, tx_driver); |
Eilon Greenstein | c2c8b03 | 2009-02-12 08:37:14 +0000 | [diff] [blame] | 5612 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5613 | } |
| 5614 | } |
| 5615 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 5616 | static int bnx2x_emac_program(struct link_params *params, |
| 5617 | struct link_vars *vars) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5618 | { |
| 5619 | struct bnx2x *bp = params->bp; |
| 5620 | u8 port = params->port; |
| 5621 | u16 mode = 0; |
| 5622 | |
| 5623 | DP(NETIF_MSG_LINK, "setting link speed & duplex\n"); |
| 5624 | bnx2x_bits_dis(bp, GRCBASE_EMAC0 + port*0x400 + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5625 | EMAC_REG_EMAC_MODE, |
| 5626 | (EMAC_MODE_25G_MODE | |
| 5627 | EMAC_MODE_PORT_MII_10M | |
| 5628 | EMAC_MODE_HALF_DUPLEX)); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 5629 | switch (vars->line_speed) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5630 | case SPEED_10: |
| 5631 | mode |= EMAC_MODE_PORT_MII_10M; |
| 5632 | break; |
| 5633 | |
| 5634 | case SPEED_100: |
| 5635 | mode |= EMAC_MODE_PORT_MII; |
| 5636 | break; |
| 5637 | |
| 5638 | case SPEED_1000: |
| 5639 | mode |= EMAC_MODE_PORT_GMII; |
| 5640 | break; |
| 5641 | |
| 5642 | case SPEED_2500: |
| 5643 | mode |= (EMAC_MODE_25G_MODE | EMAC_MODE_PORT_GMII); |
| 5644 | break; |
| 5645 | |
| 5646 | default: |
| 5647 | /* 10G not valid for EMAC */ |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 5648 | DP(NETIF_MSG_LINK, "Invalid line_speed 0x%x\n", |
| 5649 | vars->line_speed); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5650 | return -EINVAL; |
| 5651 | } |
| 5652 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 5653 | if (vars->duplex == DUPLEX_HALF) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5654 | mode |= EMAC_MODE_HALF_DUPLEX; |
| 5655 | bnx2x_bits_en(bp, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5656 | GRCBASE_EMAC0 + port*0x400 + EMAC_REG_EMAC_MODE, |
| 5657 | mode); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5658 | |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 5659 | bnx2x_set_led(params, vars, LED_MODE_OPER, vars->line_speed); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5660 | return 0; |
| 5661 | } |
| 5662 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5663 | static void bnx2x_set_preemphasis(struct bnx2x_phy *phy, |
| 5664 | struct link_params *params) |
| 5665 | { |
| 5666 | |
| 5667 | u16 bank, i = 0; |
| 5668 | struct bnx2x *bp = params->bp; |
| 5669 | |
| 5670 | for (bank = MDIO_REG_BANK_RX0, i = 0; bank <= MDIO_REG_BANK_RX3; |
| 5671 | bank += (MDIO_REG_BANK_RX1-MDIO_REG_BANK_RX0), i++) { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5672 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5673 | bank, |
| 5674 | MDIO_RX0_RX_EQ_BOOST, |
| 5675 | phy->rx_preemphasis[i]); |
| 5676 | } |
| 5677 | |
| 5678 | for (bank = MDIO_REG_BANK_TX0, i = 0; bank <= MDIO_REG_BANK_TX3; |
| 5679 | bank += (MDIO_REG_BANK_TX1 - MDIO_REG_BANK_TX0), i++) { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5680 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5681 | bank, |
| 5682 | MDIO_TX0_TX_DRIVER, |
| 5683 | phy->tx_preemphasis[i]); |
| 5684 | } |
| 5685 | } |
| 5686 | |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 5687 | static void bnx2x_xgxs_config_init(struct bnx2x_phy *phy, |
| 5688 | struct link_params *params, |
| 5689 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5690 | { |
| 5691 | struct bnx2x *bp = params->bp; |
| 5692 | u8 enable_cl73 = (SINGLE_MEDIA_DIRECT(params) || |
| 5693 | (params->loopback_mode == LOOPBACK_XGXS)); |
| 5694 | if (!(vars->phy_flags & PHY_SGMII_FLAG)) { |
| 5695 | if (SINGLE_MEDIA_DIRECT(params) && |
| 5696 | (params->feature_config_flags & |
| 5697 | FEATURE_CONFIG_OVERRIDE_PREEMPHASIS_ENABLED)) |
| 5698 | bnx2x_set_preemphasis(phy, params); |
| 5699 | |
| 5700 | /* forced speed requested? */ |
| 5701 | if (vars->line_speed != SPEED_AUTO_NEG || |
| 5702 | (SINGLE_MEDIA_DIRECT(params) && |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5703 | params->loopback_mode == LOOPBACK_EXT)) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5704 | DP(NETIF_MSG_LINK, "not SGMII, no AN\n"); |
| 5705 | |
| 5706 | /* disable autoneg */ |
| 5707 | bnx2x_set_autoneg(phy, params, vars, 0); |
| 5708 | |
| 5709 | /* program speed and duplex */ |
| 5710 | bnx2x_program_serdes(phy, params, vars); |
| 5711 | |
| 5712 | } else { /* AN_mode */ |
| 5713 | DP(NETIF_MSG_LINK, "not SGMII, AN\n"); |
| 5714 | |
| 5715 | /* AN enabled */ |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 5716 | bnx2x_set_brcm_cl37_advertisement(phy, params); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5717 | |
| 5718 | /* program duplex & pause advertisement (for aneg) */ |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 5719 | bnx2x_set_ieee_aneg_advertisement(phy, params, |
| 5720 | vars->ieee_fc); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5721 | |
| 5722 | /* enable autoneg */ |
| 5723 | bnx2x_set_autoneg(phy, params, vars, enable_cl73); |
| 5724 | |
| 5725 | /* enable and restart AN */ |
| 5726 | bnx2x_restart_autoneg(phy, params, enable_cl73); |
| 5727 | } |
| 5728 | |
| 5729 | } else { /* SGMII mode */ |
| 5730 | DP(NETIF_MSG_LINK, "SGMII\n"); |
| 5731 | |
| 5732 | bnx2x_initialize_sgmii_process(phy, params, vars); |
| 5733 | } |
| 5734 | } |
| 5735 | |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 5736 | static int bnx2x_prepare_xgxs(struct bnx2x_phy *phy, |
| 5737 | struct link_params *params, |
| 5738 | struct link_vars *vars) |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 5739 | { |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 5740 | int rc; |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 5741 | vars->phy_flags |= PHY_XGXS_FLAG; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 5742 | if ((phy->req_line_speed && |
| 5743 | ((phy->req_line_speed == SPEED_100) || |
| 5744 | (phy->req_line_speed == SPEED_10))) || |
| 5745 | (!phy->req_line_speed && |
| 5746 | (phy->speed_cap_mask >= |
| 5747 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_FULL) && |
| 5748 | (phy->speed_cap_mask < |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 5749 | PORT_HW_CFG_SPEED_CAPABILITY_D0_1G)) || |
| 5750 | (phy->type == PORT_HW_CFG_SERDES_EXT_PHY_TYPE_DIRECT_SD)) |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 5751 | vars->phy_flags |= PHY_SGMII_FLAG; |
| 5752 | else |
| 5753 | vars->phy_flags &= ~PHY_SGMII_FLAG; |
| 5754 | |
| 5755 | bnx2x_calc_ieee_aneg_adv(phy, params, &vars->ieee_fc); |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 5756 | bnx2x_set_aer_mmd(params, phy); |
| 5757 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT) |
| 5758 | bnx2x_set_master_ln(params, phy); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 5759 | |
| 5760 | rc = bnx2x_reset_unicore(params, phy, 0); |
| 5761 | /* reset the SerDes and wait for reset bit return low */ |
| 5762 | if (rc != 0) |
| 5763 | return rc; |
| 5764 | |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 5765 | bnx2x_set_aer_mmd(params, phy); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 5766 | /* setting the masterLn_def again after the reset */ |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 5767 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT) { |
| 5768 | bnx2x_set_master_ln(params, phy); |
| 5769 | bnx2x_set_swap_lanes(params, phy); |
| 5770 | } |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 5771 | |
| 5772 | return rc; |
| 5773 | } |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 5774 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 5775 | static u16 bnx2x_wait_reset_complete(struct bnx2x *bp, |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 5776 | struct bnx2x_phy *phy, |
| 5777 | struct link_params *params) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5778 | { |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 5779 | u16 cnt, ctrl; |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 5780 | /* Wait for soft reset to get cleared up to 1 sec */ |
Yaniv Rosner | 62b29a5 | 2010-09-07 11:40:58 +0000 | [diff] [blame] | 5781 | for (cnt = 0; cnt < 1000; cnt++) { |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 5782 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54618SE) |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 5783 | bnx2x_cl22_read(bp, phy, |
| 5784 | MDIO_PMA_REG_CTRL, &ctrl); |
| 5785 | else |
| 5786 | bnx2x_cl45_read(bp, phy, |
| 5787 | MDIO_PMA_DEVAD, |
| 5788 | MDIO_PMA_REG_CTRL, &ctrl); |
Yaniv Rosner | 62b29a5 | 2010-09-07 11:40:58 +0000 | [diff] [blame] | 5789 | if (!(ctrl & (1<<15))) |
| 5790 | break; |
| 5791 | msleep(1); |
| 5792 | } |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 5793 | |
| 5794 | if (cnt == 1000) |
| 5795 | netdev_err(bp->dev, "Warning: PHY was not initialized," |
| 5796 | " Port %d\n", |
| 5797 | params->port); |
Yaniv Rosner | 62b29a5 | 2010-09-07 11:40:58 +0000 | [diff] [blame] | 5798 | DP(NETIF_MSG_LINK, "control reg 0x%x (after %d ms)\n", ctrl, cnt); |
| 5799 | return cnt; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 5800 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5801 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5802 | static void bnx2x_link_int_enable(struct link_params *params) |
| 5803 | { |
| 5804 | u8 port = params->port; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5805 | u32 mask; |
| 5806 | struct bnx2x *bp = params->bp; |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 5807 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5808 | /* 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] | 5809 | if (CHIP_IS_E3(bp)) { |
| 5810 | mask = NIG_MASK_XGXS0_LINK_STATUS; |
| 5811 | if (!(SINGLE_MEDIA_DIRECT(params))) |
| 5812 | mask |= NIG_MASK_MI_INT; |
| 5813 | } else if (params->switch_cfg == SWITCH_CFG_10G) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5814 | mask = (NIG_MASK_XGXS0_LINK10G | |
| 5815 | NIG_MASK_XGXS0_LINK_STATUS); |
| 5816 | DP(NETIF_MSG_LINK, "enabled XGXS interrupt\n"); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 5817 | if (!(SINGLE_MEDIA_DIRECT(params)) && |
| 5818 | params->phy[INT_PHY].type != |
| 5819 | PORT_HW_CFG_XGXS_EXT_PHY_TYPE_FAILURE) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5820 | mask |= NIG_MASK_MI_INT; |
| 5821 | DP(NETIF_MSG_LINK, "enabled external phy int\n"); |
| 5822 | } |
| 5823 | |
| 5824 | } else { /* SerDes */ |
| 5825 | mask = NIG_MASK_SERDES0_LINK_STATUS; |
| 5826 | DP(NETIF_MSG_LINK, "enabled SerDes interrupt\n"); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 5827 | if (!(SINGLE_MEDIA_DIRECT(params)) && |
| 5828 | params->phy[INT_PHY].type != |
| 5829 | PORT_HW_CFG_SERDES_EXT_PHY_TYPE_NOT_CONN) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5830 | mask |= NIG_MASK_MI_INT; |
| 5831 | DP(NETIF_MSG_LINK, "enabled external phy int\n"); |
| 5832 | } |
| 5833 | } |
| 5834 | bnx2x_bits_en(bp, |
| 5835 | NIG_REG_MASK_INTERRUPT_PORT0 + port*4, |
| 5836 | mask); |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 5837 | |
| 5838 | 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] | 5839 | (params->switch_cfg == SWITCH_CFG_10G), |
| 5840 | REG_RD(bp, NIG_REG_STATUS_INTERRUPT_PORT0 + port*4)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5841 | DP(NETIF_MSG_LINK, " int_mask 0x%x, MI_INT %x, SERDES_LINK %x\n", |
| 5842 | REG_RD(bp, NIG_REG_MASK_INTERRUPT_PORT0 + port*4), |
| 5843 | REG_RD(bp, NIG_REG_EMAC0_STATUS_MISC_MI_INT + port*0x18), |
| 5844 | REG_RD(bp, NIG_REG_SERDES0_STATUS_LINK_STATUS+port*0x3c)); |
| 5845 | DP(NETIF_MSG_LINK, " 10G %x, XGXS_LINK %x\n", |
| 5846 | REG_RD(bp, NIG_REG_XGXS0_STATUS_LINK10G + port*0x68), |
| 5847 | REG_RD(bp, NIG_REG_XGXS0_STATUS_LINK_STATUS + port*0x68)); |
| 5848 | } |
| 5849 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5850 | static void bnx2x_rearm_latch_signal(struct bnx2x *bp, u8 port, |
| 5851 | u8 exp_mi_int) |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 5852 | { |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5853 | u32 latch_status = 0; |
| 5854 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5855 | /* |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5856 | * Disable the MI INT ( external phy int ) by writing 1 to the |
| 5857 | * status register. Link down indication is high-active-signal, |
| 5858 | * so in this case we need to write the status to clear the XOR |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 5859 | */ |
| 5860 | /* Read Latched signals */ |
| 5861 | latch_status = REG_RD(bp, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5862 | NIG_REG_LATCH_STATUS_0 + port*8); |
| 5863 | DP(NETIF_MSG_LINK, "latch_status = 0x%x\n", latch_status); |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 5864 | /* Handle only those with latched-signal=up.*/ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5865 | if (exp_mi_int) |
| 5866 | bnx2x_bits_en(bp, |
| 5867 | NIG_REG_STATUS_INTERRUPT_PORT0 |
| 5868 | + port*4, |
| 5869 | NIG_STATUS_EMAC0_MI_INT); |
| 5870 | else |
| 5871 | bnx2x_bits_dis(bp, |
| 5872 | NIG_REG_STATUS_INTERRUPT_PORT0 |
| 5873 | + port*4, |
| 5874 | NIG_STATUS_EMAC0_MI_INT); |
| 5875 | |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 5876 | if (latch_status & 1) { |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5877 | |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 5878 | /* For all latched-signal=up : Re-Arm Latch signals */ |
| 5879 | REG_WR(bp, NIG_REG_LATCH_STATUS_0 + port*8, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5880 | (latch_status & 0xfffe) | (latch_status & 1)); |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 5881 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5882 | /* For all latched-signal=up,Write original_signal to status */ |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 5883 | } |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 5884 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5885 | static void bnx2x_link_int_ack(struct link_params *params, |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5886 | struct link_vars *vars, u8 is_10g_plus) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5887 | { |
| 5888 | struct bnx2x *bp = params->bp; |
| 5889 | u8 port = params->port; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5890 | u32 mask; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5891 | /* |
| 5892 | * First reset all status we assume only one line will be |
| 5893 | * change at a time |
| 5894 | */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5895 | bnx2x_bits_dis(bp, NIG_REG_STATUS_INTERRUPT_PORT0 + port*4, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5896 | (NIG_STATUS_XGXS0_LINK10G | |
| 5897 | NIG_STATUS_XGXS0_LINK_STATUS | |
| 5898 | NIG_STATUS_SERDES0_LINK_STATUS)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5899 | if (vars->phy_link_up) { |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5900 | if (USES_WARPCORE(bp)) |
| 5901 | mask = NIG_STATUS_XGXS0_LINK_STATUS; |
| 5902 | else { |
| 5903 | if (is_10g_plus) |
| 5904 | mask = NIG_STATUS_XGXS0_LINK10G; |
| 5905 | else if (params->switch_cfg == SWITCH_CFG_10G) { |
| 5906 | /* |
| 5907 | * Disable the link interrupt by writing 1 to |
| 5908 | * the relevant lane in the status register |
| 5909 | */ |
| 5910 | u32 ser_lane = |
| 5911 | ((params->lane_config & |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5912 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_MASK) >> |
| 5913 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_SHIFT); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5914 | mask = ((1 << ser_lane) << |
| 5915 | NIG_STATUS_XGXS0_LINK_STATUS_SIZE); |
| 5916 | } else |
| 5917 | mask = NIG_STATUS_SERDES0_LINK_STATUS; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5918 | } |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5919 | DP(NETIF_MSG_LINK, "Ack link up interrupt with mask 0x%x\n", |
| 5920 | mask); |
| 5921 | bnx2x_bits_en(bp, |
| 5922 | NIG_REG_STATUS_INTERRUPT_PORT0 + port*4, |
| 5923 | mask); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5924 | } |
| 5925 | } |
| 5926 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 5927 | static int bnx2x_format_ver(u32 num, u8 *str, u16 *len) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5928 | { |
| 5929 | u8 *str_ptr = str; |
| 5930 | u32 mask = 0xf0000000; |
| 5931 | u8 shift = 8*4; |
| 5932 | u8 digit; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5933 | u8 remove_leading_zeros = 1; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 5934 | if (*len < 10) { |
Frederik Schwarzer | 025dfda | 2008-10-16 19:02:37 +0200 | [diff] [blame] | 5935 | /* Need more than 10chars for this format */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5936 | *str_ptr = '\0'; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5937 | (*len)--; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5938 | return -EINVAL; |
| 5939 | } |
| 5940 | while (shift > 0) { |
| 5941 | |
| 5942 | shift -= 4; |
| 5943 | digit = ((num & mask) >> shift); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5944 | if (digit == 0 && remove_leading_zeros) { |
| 5945 | mask = mask >> 4; |
| 5946 | continue; |
| 5947 | } else if (digit < 0xa) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5948 | *str_ptr = digit + '0'; |
| 5949 | else |
| 5950 | *str_ptr = digit - 0xa + 'a'; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5951 | remove_leading_zeros = 0; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5952 | str_ptr++; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5953 | (*len)--; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5954 | mask = mask >> 4; |
| 5955 | if (shift == 4*4) { |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5956 | *str_ptr = '.'; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5957 | str_ptr++; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5958 | (*len)--; |
| 5959 | remove_leading_zeros = 1; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5960 | } |
| 5961 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5962 | return 0; |
| 5963 | } |
| 5964 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5965 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 5966 | 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] | 5967 | { |
| 5968 | str[0] = '\0'; |
| 5969 | (*len)--; |
| 5970 | return 0; |
| 5971 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5972 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 5973 | int bnx2x_get_ext_phy_fw_version(struct link_params *params, u8 driver_loaded, |
| 5974 | u8 *version, u16 len) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5975 | { |
Julia Lawall | 0376d5b | 2009-07-19 05:26:35 +0000 | [diff] [blame] | 5976 | struct bnx2x *bp; |
Eilon Greenstein | a35da8d | 2009-02-12 08:37:02 +0000 | [diff] [blame] | 5977 | u32 spirom_ver = 0; |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 5978 | int status = 0; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 5979 | u8 *ver_p = version; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5980 | u16 remain_len = len; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5981 | if (version == NULL || params == NULL) |
| 5982 | return -EINVAL; |
Julia Lawall | 0376d5b | 2009-07-19 05:26:35 +0000 | [diff] [blame] | 5983 | bp = params->bp; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5984 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 5985 | /* Extract first external phy*/ |
| 5986 | version[0] = '\0'; |
| 5987 | spirom_ver = REG_RD(bp, params->phy[EXT_PHY1].ver_addr); |
Eilon Greenstein | a35da8d | 2009-02-12 08:37:02 +0000 | [diff] [blame] | 5988 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5989 | if (params->phy[EXT_PHY1].format_fw_ver) { |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 5990 | status |= params->phy[EXT_PHY1].format_fw_ver(spirom_ver, |
| 5991 | ver_p, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5992 | &remain_len); |
| 5993 | ver_p += (len - remain_len); |
| 5994 | } |
| 5995 | if ((params->num_phys == MAX_PHYS) && |
| 5996 | (params->phy[EXT_PHY2].ver_addr != 0)) { |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5997 | spirom_ver = REG_RD(bp, params->phy[EXT_PHY2].ver_addr); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5998 | if (params->phy[EXT_PHY2].format_fw_ver) { |
| 5999 | *ver_p = '/'; |
| 6000 | ver_p++; |
| 6001 | remain_len--; |
| 6002 | status |= params->phy[EXT_PHY2].format_fw_ver( |
| 6003 | spirom_ver, |
| 6004 | ver_p, |
| 6005 | &remain_len); |
| 6006 | ver_p = version + (len - remain_len); |
| 6007 | } |
| 6008 | } |
| 6009 | *ver_p = '\0'; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6010 | return status; |
| 6011 | } |
| 6012 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 6013 | static void bnx2x_set_xgxs_loopback(struct bnx2x_phy *phy, |
Yaniv Rosner | 62b29a5 | 2010-09-07 11:40:58 +0000 | [diff] [blame] | 6014 | struct link_params *params) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6015 | { |
| 6016 | u8 port = params->port; |
| 6017 | struct bnx2x *bp = params->bp; |
| 6018 | |
Yaniv Rosner | 62b29a5 | 2010-09-07 11:40:58 +0000 | [diff] [blame] | 6019 | if (phy->req_line_speed != SPEED_1000) { |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6020 | u32 md_devad = 0; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6021 | |
| 6022 | DP(NETIF_MSG_LINK, "XGXS 10G loopback enable\n"); |
| 6023 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6024 | if (!CHIP_IS_E3(bp)) { |
| 6025 | /* change the uni_phy_addr in the nig */ |
| 6026 | md_devad = REG_RD(bp, (NIG_REG_XGXS0_CTRL_MD_DEVAD + |
| 6027 | port*0x18)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6028 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6029 | REG_WR(bp, NIG_REG_XGXS0_CTRL_MD_DEVAD + port*0x18, |
| 6030 | 0x5); |
| 6031 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6032 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 6033 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6034 | 5, |
| 6035 | (MDIO_REG_BANK_AER_BLOCK + |
| 6036 | (MDIO_AER_BLOCK_AER_REG & 0xf)), |
| 6037 | 0x2800); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6038 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 6039 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6040 | 5, |
| 6041 | (MDIO_REG_BANK_CL73_IEEEB0 + |
| 6042 | (MDIO_CL73_IEEEB0_CL73_AN_CONTROL & 0xf)), |
| 6043 | 0x6041); |
Eilon Greenstein | 3858276 | 2009-01-14 06:44:16 +0000 | [diff] [blame] | 6044 | msleep(200); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6045 | /* set aer mmd back */ |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 6046 | bnx2x_set_aer_mmd(params, phy); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6047 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6048 | if (!CHIP_IS_E3(bp)) { |
| 6049 | /* and md_devad */ |
| 6050 | REG_WR(bp, NIG_REG_XGXS0_CTRL_MD_DEVAD + port*0x18, |
| 6051 | md_devad); |
| 6052 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6053 | } else { |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 6054 | u16 mii_ctrl; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6055 | DP(NETIF_MSG_LINK, "XGXS 1G loopback enable\n"); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 6056 | bnx2x_cl45_read(bp, phy, 5, |
| 6057 | (MDIO_REG_BANK_COMBO_IEEE0 + |
| 6058 | (MDIO_COMBO_IEEE0_MII_CONTROL & 0xf)), |
| 6059 | &mii_ctrl); |
| 6060 | bnx2x_cl45_write(bp, phy, 5, |
| 6061 | (MDIO_REG_BANK_COMBO_IEEE0 + |
| 6062 | (MDIO_COMBO_IEEE0_MII_CONTROL & 0xf)), |
| 6063 | mii_ctrl | |
| 6064 | MDIO_COMBO_IEEO_MII_CONTROL_LOOPBACK); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6065 | } |
| 6066 | } |
| 6067 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6068 | int bnx2x_set_led(struct link_params *params, |
| 6069 | struct link_vars *vars, u8 mode, u32 speed) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6070 | { |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 6071 | u8 port = params->port; |
| 6072 | u16 hw_led_mode = params->hw_led_mode; |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6073 | int rc = 0; |
| 6074 | u8 phy_idx; |
Eilon Greenstein | 345b5d5 | 2008-08-13 15:58:12 -0700 | [diff] [blame] | 6075 | u32 tmp; |
| 6076 | u32 emac_base = port ? GRCBASE_EMAC1 : GRCBASE_EMAC0; |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 6077 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6078 | DP(NETIF_MSG_LINK, "bnx2x_set_led: port %x, mode %d\n", port, mode); |
| 6079 | DP(NETIF_MSG_LINK, "speed 0x%x, hw_led_mode 0x%x\n", |
| 6080 | speed, hw_led_mode); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6081 | /* In case */ |
| 6082 | for (phy_idx = EXT_PHY1; phy_idx < MAX_PHYS; phy_idx++) { |
| 6083 | if (params->phy[phy_idx].set_link_led) { |
| 6084 | params->phy[phy_idx].set_link_led( |
| 6085 | ¶ms->phy[phy_idx], params, mode); |
| 6086 | } |
| 6087 | } |
| 6088 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6089 | switch (mode) { |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6090 | case LED_MODE_FRONT_PANEL_OFF: |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6091 | case LED_MODE_OFF: |
| 6092 | REG_WR(bp, NIG_REG_LED_10G_P0 + port*4, 0); |
| 6093 | REG_WR(bp, NIG_REG_LED_MODE_P0 + port*4, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6094 | SHARED_HW_CFG_LED_MAC1); |
Eilon Greenstein | 345b5d5 | 2008-08-13 15:58:12 -0700 | [diff] [blame] | 6095 | |
| 6096 | tmp = EMAC_RD(bp, EMAC_REG_EMAC_LED); |
Yaniv Rosner | 001cea7 | 2011-10-27 05:09:48 +0000 | [diff] [blame] | 6097 | if (params->phy[EXT_PHY1].type == |
| 6098 | PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54618SE) |
| 6099 | EMAC_WR(bp, EMAC_REG_EMAC_LED, tmp & 0xfff1); |
| 6100 | else { |
| 6101 | EMAC_WR(bp, EMAC_REG_EMAC_LED, |
| 6102 | (tmp | EMAC_LED_OVERRIDE)); |
| 6103 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6104 | break; |
| 6105 | |
| 6106 | case LED_MODE_OPER: |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6107 | /* |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6108 | * For all other phys, OPER mode is same as ON, so in case |
| 6109 | * link is down, do nothing |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6110 | */ |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6111 | if (!vars->link_up) |
| 6112 | break; |
| 6113 | case LED_MODE_ON: |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 6114 | if (((params->phy[EXT_PHY1].type == |
| 6115 | PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727) || |
| 6116 | (params->phy[EXT_PHY1].type == |
| 6117 | PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8722)) && |
Yaniv Rosner | 1f48353 | 2011-01-18 04:33:31 +0000 | [diff] [blame] | 6118 | CHIP_IS_E2(bp) && params->num_phys == 2) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6119 | /* |
| 6120 | * This is a work-around for E2+8727 Configurations |
| 6121 | */ |
Yaniv Rosner | 1f48353 | 2011-01-18 04:33:31 +0000 | [diff] [blame] | 6122 | if (mode == LED_MODE_ON || |
| 6123 | speed == SPEED_10000){ |
| 6124 | REG_WR(bp, NIG_REG_LED_MODE_P0 + port*4, 0); |
| 6125 | REG_WR(bp, NIG_REG_LED_10G_P0 + port*4, 1); |
| 6126 | |
| 6127 | tmp = EMAC_RD(bp, EMAC_REG_EMAC_LED); |
| 6128 | EMAC_WR(bp, EMAC_REG_EMAC_LED, |
| 6129 | (tmp | EMAC_LED_OVERRIDE)); |
Yaniv Rosner | 793bd45 | 2011-08-02 22:59:40 +0000 | [diff] [blame] | 6130 | /* |
| 6131 | * return here without enabling traffic |
David S. Miller | 8decf86 | 2011-09-22 03:23:13 -0400 | [diff] [blame] | 6132 | * LED blink and setting rate in ON mode. |
Yaniv Rosner | 793bd45 | 2011-08-02 22:59:40 +0000 | [diff] [blame] | 6133 | * In oper mode, enabling LED blink |
| 6134 | * and setting rate is needed. |
| 6135 | */ |
| 6136 | if (mode == LED_MODE_ON) |
| 6137 | return rc; |
Yaniv Rosner | 1f48353 | 2011-01-18 04:33:31 +0000 | [diff] [blame] | 6138 | } |
Yaniv Rosner | 793bd45 | 2011-08-02 22:59:40 +0000 | [diff] [blame] | 6139 | } else if (SINGLE_MEDIA_DIRECT(params)) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6140 | /* |
| 6141 | * This is a work-around for HW issue found when link |
| 6142 | * is up in CL73 |
| 6143 | */ |
David S. Miller | 8decf86 | 2011-09-22 03:23:13 -0400 | [diff] [blame] | 6144 | if ((!CHIP_IS_E3(bp)) || |
| 6145 | (CHIP_IS_E3(bp) && |
| 6146 | mode == LED_MODE_ON)) |
| 6147 | REG_WR(bp, NIG_REG_LED_10G_P0 + port*4, 1); |
| 6148 | |
Yaniv Rosner | 793bd45 | 2011-08-02 22:59:40 +0000 | [diff] [blame] | 6149 | if (CHIP_IS_E1x(bp) || |
| 6150 | CHIP_IS_E2(bp) || |
| 6151 | (mode == LED_MODE_ON)) |
| 6152 | REG_WR(bp, NIG_REG_LED_MODE_P0 + port*4, 0); |
| 6153 | else |
| 6154 | REG_WR(bp, NIG_REG_LED_MODE_P0 + port*4, |
| 6155 | hw_led_mode); |
Yaniv Rosner | 001cea7 | 2011-10-27 05:09:48 +0000 | [diff] [blame] | 6156 | } else if ((params->phy[EXT_PHY1].type == |
| 6157 | PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54618SE) && |
| 6158 | (mode != LED_MODE_OPER)) { |
| 6159 | REG_WR(bp, NIG_REG_LED_MODE_P0 + port*4, 0); |
| 6160 | tmp = EMAC_RD(bp, EMAC_REG_EMAC_LED); |
| 6161 | EMAC_WR(bp, EMAC_REG_EMAC_LED, tmp | 0x3); |
Yaniv Rosner | 793bd45 | 2011-08-02 22:59:40 +0000 | [diff] [blame] | 6162 | } else |
Yaniv Rosner | 001cea7 | 2011-10-27 05:09:48 +0000 | [diff] [blame] | 6163 | REG_WR(bp, NIG_REG_LED_MODE_P0 + port*4, |
| 6164 | hw_led_mode); |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 6165 | |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6166 | 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] | 6167 | /* Set blinking rate to ~15.9Hz */ |
Yaniv Rosner | 26ffaf3 | 2011-10-27 05:09:45 +0000 | [diff] [blame] | 6168 | if (CHIP_IS_E3(bp)) |
| 6169 | REG_WR(bp, NIG_REG_LED_CONTROL_BLINK_RATE_P0 + port*4, |
| 6170 | LED_BLINK_RATE_VAL_E3); |
| 6171 | else |
| 6172 | REG_WR(bp, NIG_REG_LED_CONTROL_BLINK_RATE_P0 + port*4, |
| 6173 | LED_BLINK_RATE_VAL_E1X_E2); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6174 | REG_WR(bp, NIG_REG_LED_CONTROL_BLINK_RATE_ENA_P0 + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6175 | port*4, 1); |
Yaniv Rosner | 001cea7 | 2011-10-27 05:09:48 +0000 | [diff] [blame] | 6176 | if ((params->phy[EXT_PHY1].type != |
| 6177 | PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54618SE) && |
| 6178 | (mode != LED_MODE_OPER)) { |
| 6179 | tmp = EMAC_RD(bp, EMAC_REG_EMAC_LED); |
| 6180 | EMAC_WR(bp, EMAC_REG_EMAC_LED, |
| 6181 | (tmp & (~EMAC_LED_OVERRIDE))); |
| 6182 | } |
Eilon Greenstein | 345b5d5 | 2008-08-13 15:58:12 -0700 | [diff] [blame] | 6183 | |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 6184 | if (CHIP_IS_E1(bp) && |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 6185 | ((speed == SPEED_2500) || |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6186 | (speed == SPEED_1000) || |
| 6187 | (speed == SPEED_100) || |
| 6188 | (speed == SPEED_10))) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6189 | /* |
| 6190 | * On Everest 1 Ax chip versions for speeds less than |
| 6191 | * 10G LED scheme is different |
| 6192 | */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6193 | REG_WR(bp, NIG_REG_LED_CONTROL_OVERRIDE_TRAFFIC_P0 |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6194 | + port*4, 1); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6195 | REG_WR(bp, NIG_REG_LED_CONTROL_TRAFFIC_P0 + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6196 | port*4, 0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6197 | REG_WR(bp, NIG_REG_LED_CONTROL_BLINK_TRAFFIC_P0 + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6198 | port*4, 1); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6199 | } |
| 6200 | break; |
| 6201 | |
| 6202 | default: |
| 6203 | rc = -EINVAL; |
| 6204 | DP(NETIF_MSG_LINK, "bnx2x_set_led: Invalid led mode %d\n", |
| 6205 | mode); |
| 6206 | break; |
| 6207 | } |
| 6208 | return rc; |
| 6209 | |
| 6210 | } |
| 6211 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6212 | /* |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6213 | * This function comes to reflect the actual link state read DIRECTLY from the |
| 6214 | * HW |
| 6215 | */ |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6216 | int bnx2x_test_link(struct link_params *params, struct link_vars *vars, |
| 6217 | u8 is_serdes) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6218 | { |
| 6219 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 6220 | u16 gp_status = 0, phy_index = 0; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6221 | u8 ext_phy_link_up = 0, serdes_phy_type; |
| 6222 | struct link_vars temp_vars; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6223 | struct bnx2x_phy *int_phy = ¶ms->phy[INT_PHY]; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6224 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6225 | if (CHIP_IS_E3(bp)) { |
| 6226 | u16 link_up; |
| 6227 | if (params->req_line_speed[LINK_CONFIG_IDX(INT_PHY)] |
| 6228 | > SPEED_10000) { |
| 6229 | /* Check 20G link */ |
| 6230 | bnx2x_cl45_read(bp, int_phy, MDIO_WC_DEVAD, |
| 6231 | 1, &link_up); |
| 6232 | bnx2x_cl45_read(bp, int_phy, MDIO_WC_DEVAD, |
| 6233 | 1, &link_up); |
| 6234 | link_up &= (1<<2); |
| 6235 | } else { |
| 6236 | /* Check 10G link and below*/ |
| 6237 | u8 lane = bnx2x_get_warpcore_lane(int_phy, params); |
| 6238 | bnx2x_cl45_read(bp, int_phy, MDIO_WC_DEVAD, |
| 6239 | MDIO_WC_REG_GP2_STATUS_GP_2_1, |
| 6240 | &gp_status); |
| 6241 | gp_status = ((gp_status >> 8) & 0xf) | |
| 6242 | ((gp_status >> 12) & 0xf); |
| 6243 | link_up = gp_status & (1 << lane); |
| 6244 | } |
| 6245 | if (!link_up) |
| 6246 | return -ESRCH; |
| 6247 | } else { |
| 6248 | CL22_RD_OVER_CL45(bp, int_phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6249 | MDIO_REG_BANK_GP_STATUS, |
| 6250 | MDIO_GP_STATUS_TOP_AN_STATUS1, |
| 6251 | &gp_status); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6252 | /* 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] | 6253 | if (!(gp_status & MDIO_GP_STATUS_TOP_AN_STATUS1_LINK_STATUS)) |
| 6254 | return -ESRCH; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6255 | } |
| 6256 | /* In XGXS loopback mode, do not check external PHY */ |
| 6257 | if (params->loopback_mode == LOOPBACK_XGXS) |
| 6258 | return 0; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6259 | |
| 6260 | switch (params->num_phys) { |
| 6261 | case 1: |
| 6262 | /* No external PHY */ |
| 6263 | return 0; |
| 6264 | case 2: |
| 6265 | ext_phy_link_up = params->phy[EXT_PHY1].read_status( |
| 6266 | ¶ms->phy[EXT_PHY1], |
| 6267 | params, &temp_vars); |
| 6268 | break; |
| 6269 | case 3: /* Dual Media */ |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 6270 | for (phy_index = EXT_PHY1; phy_index < params->num_phys; |
| 6271 | phy_index++) { |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6272 | serdes_phy_type = ((params->phy[phy_index].media_type == |
| 6273 | ETH_PHY_SFP_FIBER) || |
| 6274 | (params->phy[phy_index].media_type == |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 6275 | ETH_PHY_XFP_FIBER) || |
| 6276 | (params->phy[phy_index].media_type == |
| 6277 | ETH_PHY_DA_TWINAX)); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6278 | |
| 6279 | if (is_serdes != serdes_phy_type) |
| 6280 | continue; |
| 6281 | if (params->phy[phy_index].read_status) { |
| 6282 | ext_phy_link_up |= |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 6283 | params->phy[phy_index].read_status( |
| 6284 | ¶ms->phy[phy_index], |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6285 | params, &temp_vars); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6286 | } |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 6287 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6288 | break; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6289 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6290 | if (ext_phy_link_up) |
| 6291 | return 0; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6292 | return -ESRCH; |
| 6293 | } |
| 6294 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6295 | static int bnx2x_link_initialize(struct link_params *params, |
| 6296 | struct link_vars *vars) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6297 | { |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6298 | int rc = 0; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6299 | u8 phy_index, non_ext_phy; |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 6300 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6301 | /* |
| 6302 | * In case of external phy existence, the line speed would be the |
| 6303 | * line speed linked up by the external phy. In case it is direct |
| 6304 | * only, then the line_speed during initialization will be |
| 6305 | * equal to the req_line_speed |
| 6306 | */ |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 6307 | vars->line_speed = params->phy[INT_PHY].req_line_speed; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6308 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6309 | /* |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 6310 | * Initialize the internal phy in case this is a direct board |
| 6311 | * (no external phys), or this board has external phy which requires |
| 6312 | * to first. |
| 6313 | */ |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6314 | if (!USES_WARPCORE(bp)) |
| 6315 | bnx2x_prepare_xgxs(¶ms->phy[INT_PHY], params, vars); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6316 | /* init ext phy and enable link state int */ |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 6317 | non_ext_phy = (SINGLE_MEDIA_DIRECT(params) || |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6318 | (params->loopback_mode == LOOPBACK_XGXS)); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6319 | |
| 6320 | if (non_ext_phy || |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 6321 | (params->phy[EXT_PHY1].flags & FLAGS_INIT_XGXS_FIRST) || |
Eilon Greenstein | 8660d8c | 2009-03-02 08:01:02 +0000 | [diff] [blame] | 6322 | (params->loopback_mode == LOOPBACK_EXT_PHY)) { |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 6323 | struct bnx2x_phy *phy = ¶ms->phy[INT_PHY]; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6324 | if (vars->line_speed == SPEED_AUTO_NEG && |
| 6325 | (CHIP_IS_E1x(bp) || |
| 6326 | CHIP_IS_E2(bp))) |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 6327 | bnx2x_set_parallel_detection(phy, params); |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 6328 | if (params->phy[INT_PHY].config_init) |
| 6329 | params->phy[INT_PHY].config_init(phy, |
| 6330 | params, |
| 6331 | vars); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6332 | } |
| 6333 | |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 6334 | /* Init external phy*/ |
Yaniv Rosner | fd36a2e | 2011-05-31 21:29:05 +0000 | [diff] [blame] | 6335 | if (non_ext_phy) { |
| 6336 | if (params->phy[INT_PHY].supported & |
| 6337 | SUPPORTED_FIBRE) |
| 6338 | vars->link_status |= LINK_STATUS_SERDES_LINK; |
| 6339 | } else { |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6340 | for (phy_index = EXT_PHY1; phy_index < params->num_phys; |
| 6341 | phy_index++) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6342 | /* |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6343 | * No need to initialize second phy in case of first |
| 6344 | * phy only selection. In case of second phy, we do |
| 6345 | * need to initialize the first phy, since they are |
| 6346 | * connected. |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6347 | */ |
Yaniv Rosner | fd36a2e | 2011-05-31 21:29:05 +0000 | [diff] [blame] | 6348 | if (params->phy[phy_index].supported & |
| 6349 | SUPPORTED_FIBRE) |
| 6350 | vars->link_status |= LINK_STATUS_SERDES_LINK; |
| 6351 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6352 | if (phy_index == EXT_PHY2 && |
| 6353 | (bnx2x_phy_selection(params) == |
| 6354 | PORT_HW_CFG_PHY_SELECTION_FIRST_PHY)) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 6355 | DP(NETIF_MSG_LINK, |
| 6356 | "Not initializing second phy\n"); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6357 | continue; |
| 6358 | } |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6359 | params->phy[phy_index].config_init( |
| 6360 | ¶ms->phy[phy_index], |
| 6361 | params, vars); |
| 6362 | } |
Yaniv Rosner | fd36a2e | 2011-05-31 21:29:05 +0000 | [diff] [blame] | 6363 | } |
Yaniv Rosner | d90d96b | 2010-09-07 11:41:04 +0000 | [diff] [blame] | 6364 | /* Reset the interrupt indication after phy was initialized */ |
| 6365 | bnx2x_bits_dis(bp, NIG_REG_STATUS_INTERRUPT_PORT0 + |
| 6366 | params->port*4, |
| 6367 | (NIG_STATUS_XGXS0_LINK10G | |
| 6368 | NIG_STATUS_XGXS0_LINK_STATUS | |
| 6369 | NIG_STATUS_SERDES0_LINK_STATUS | |
| 6370 | NIG_MASK_MI_INT)); |
Yaniv Rosner | fd36a2e | 2011-05-31 21:29:05 +0000 | [diff] [blame] | 6371 | bnx2x_update_mng(params, vars->link_status); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6372 | return rc; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6373 | } |
| 6374 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6375 | static void bnx2x_int_link_reset(struct bnx2x_phy *phy, |
| 6376 | struct link_params *params) |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6377 | { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6378 | /* reset the SerDes/XGXS */ |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6379 | REG_WR(params->bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_3_CLEAR, |
| 6380 | (0x1ff << (params->port*16))); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6381 | } |
| 6382 | |
| 6383 | static void bnx2x_common_ext_link_reset(struct bnx2x_phy *phy, |
| 6384 | struct link_params *params) |
| 6385 | { |
| 6386 | struct bnx2x *bp = params->bp; |
| 6387 | u8 gpio_port; |
| 6388 | /* HW reset */ |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 6389 | if (CHIP_IS_E2(bp)) |
| 6390 | gpio_port = BP_PATH(bp); |
| 6391 | else |
| 6392 | gpio_port = params->port; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6393 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6394 | MISC_REGISTERS_GPIO_OUTPUT_LOW, |
| 6395 | gpio_port); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6396 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6397 | MISC_REGISTERS_GPIO_OUTPUT_LOW, |
| 6398 | gpio_port); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6399 | DP(NETIF_MSG_LINK, "reset external PHY\n"); |
| 6400 | } |
| 6401 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6402 | static int bnx2x_update_link_down(struct link_params *params, |
| 6403 | struct link_vars *vars) |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6404 | { |
| 6405 | struct bnx2x *bp = params->bp; |
| 6406 | u8 port = params->port; |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 6407 | |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6408 | DP(NETIF_MSG_LINK, "Port %x: Link is down\n", port); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6409 | bnx2x_set_led(params, vars, LED_MODE_OFF, 0); |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 6410 | vars->phy_flags &= ~PHY_PHYSICAL_LINK_FLAG; |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6411 | /* indicate no mac active */ |
| 6412 | vars->mac_type = MAC_TYPE_NONE; |
| 6413 | |
| 6414 | /* update shared memory */ |
Yaniv Rosner | fd36a2e | 2011-05-31 21:29:05 +0000 | [diff] [blame] | 6415 | vars->link_status &= ~(LINK_STATUS_SPEED_AND_DUPLEX_MASK | |
| 6416 | LINK_STATUS_LINK_UP | |
Yaniv Rosner | de6f337 | 2011-08-02 22:59:25 +0000 | [diff] [blame] | 6417 | LINK_STATUS_PHYSICAL_LINK_FLAG | |
Yaniv Rosner | fd36a2e | 2011-05-31 21:29:05 +0000 | [diff] [blame] | 6418 | LINK_STATUS_AUTO_NEGOTIATE_COMPLETE | |
| 6419 | LINK_STATUS_RX_FLOW_CONTROL_FLAG_MASK | |
| 6420 | LINK_STATUS_TX_FLOW_CONTROL_FLAG_MASK | |
| 6421 | LINK_STATUS_PARALLEL_DETECTION_FLAG_MASK); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6422 | vars->line_speed = 0; |
| 6423 | bnx2x_update_mng(params, vars->link_status); |
| 6424 | |
| 6425 | /* activate nig drain */ |
| 6426 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + port*4, 1); |
| 6427 | |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 6428 | /* disable emac */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 6429 | if (!CHIP_IS_E3(bp)) |
| 6430 | REG_WR(bp, NIG_REG_NIG_EMAC0_EN + port*4, 0); |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 6431 | |
| 6432 | msleep(10); |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 6433 | /* reset BigMac/Xmac */ |
| 6434 | if (CHIP_IS_E1x(bp) || |
| 6435 | CHIP_IS_E2(bp)) { |
| 6436 | bnx2x_bmac_rx_disable(bp, params->port); |
| 6437 | REG_WR(bp, GRCBASE_MISC + |
| 6438 | MISC_REGISTERS_RESET_REG_2_CLEAR, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6439 | (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << port)); |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 6440 | } |
Yaniv Rosner | ce7c048 | 2011-10-27 05:09:47 +0000 | [diff] [blame] | 6441 | if (CHIP_IS_E3(bp)) { |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 6442 | bnx2x_xmac_disable(params); |
Yaniv Rosner | ce7c048 | 2011-10-27 05:09:47 +0000 | [diff] [blame] | 6443 | bnx2x_umac_disable(params); |
| 6444 | } |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 6445 | |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6446 | return 0; |
| 6447 | } |
| 6448 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6449 | static int bnx2x_update_link_up(struct link_params *params, |
| 6450 | struct link_vars *vars, |
| 6451 | u8 link_10g) |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6452 | { |
| 6453 | struct bnx2x *bp = params->bp; |
| 6454 | u8 port = params->port; |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6455 | int rc = 0; |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 6456 | |
Yaniv Rosner | de6f337 | 2011-08-02 22:59:25 +0000 | [diff] [blame] | 6457 | vars->link_status |= (LINK_STATUS_LINK_UP | |
| 6458 | LINK_STATUS_PHYSICAL_LINK_FLAG); |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 6459 | vars->phy_flags |= PHY_PHYSICAL_LINK_FLAG; |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6460 | |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 6461 | if (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX) |
| 6462 | vars->link_status |= |
| 6463 | LINK_STATUS_TX_FLOW_CONTROL_ENABLED; |
| 6464 | |
| 6465 | if (vars->flow_ctrl & BNX2X_FLOW_CTRL_RX) |
| 6466 | vars->link_status |= |
| 6467 | LINK_STATUS_RX_FLOW_CONTROL_ENABLED; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 6468 | if (USES_WARPCORE(bp)) { |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 6469 | if (link_10g) { |
| 6470 | if (bnx2x_xmac_enable(params, vars, 0) == |
| 6471 | -ESRCH) { |
| 6472 | DP(NETIF_MSG_LINK, "Found errors on XMAC\n"); |
| 6473 | vars->link_up = 0; |
| 6474 | vars->phy_flags |= PHY_HALF_OPEN_CONN_FLAG; |
| 6475 | vars->link_status &= ~LINK_STATUS_LINK_UP; |
| 6476 | } |
| 6477 | } else |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 6478 | bnx2x_umac_enable(params, vars, 0); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6479 | bnx2x_set_led(params, vars, |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 6480 | LED_MODE_OPER, vars->line_speed); |
| 6481 | } |
| 6482 | if ((CHIP_IS_E1x(bp) || |
| 6483 | CHIP_IS_E2(bp))) { |
| 6484 | if (link_10g) { |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 6485 | if (bnx2x_bmac_enable(params, vars, 0) == |
| 6486 | -ESRCH) { |
| 6487 | DP(NETIF_MSG_LINK, "Found errors on BMAC\n"); |
| 6488 | vars->link_up = 0; |
| 6489 | vars->phy_flags |= PHY_HALF_OPEN_CONN_FLAG; |
| 6490 | vars->link_status &= ~LINK_STATUS_LINK_UP; |
| 6491 | } |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6492 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 6493 | bnx2x_set_led(params, vars, |
| 6494 | LED_MODE_OPER, SPEED_10000); |
| 6495 | } else { |
| 6496 | rc = bnx2x_emac_program(params, vars); |
| 6497 | bnx2x_emac_enable(params, vars, 0); |
Yaniv Rosner | 0c786f0 | 2009-11-05 19:18:32 +0200 | [diff] [blame] | 6498 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 6499 | /* AN complete? */ |
| 6500 | if ((vars->link_status & |
| 6501 | LINK_STATUS_AUTO_NEGOTIATE_COMPLETE) |
| 6502 | && (!(vars->phy_flags & PHY_SGMII_FLAG)) && |
| 6503 | SINGLE_MEDIA_DIRECT(params)) |
| 6504 | bnx2x_set_gmii_tx_driver(params); |
| 6505 | } |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6506 | } |
| 6507 | |
| 6508 | /* PBF - link up */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 6509 | if (CHIP_IS_E1x(bp)) |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 6510 | rc |= bnx2x_pbf_update(params, vars->flow_ctrl, |
| 6511 | vars->line_speed); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6512 | |
| 6513 | /* disable drain */ |
| 6514 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + port*4, 0); |
| 6515 | |
| 6516 | /* update shared memory */ |
| 6517 | bnx2x_update_mng(params, vars->link_status); |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 6518 | msleep(20); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6519 | return rc; |
| 6520 | } |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6521 | /* |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6522 | * The bnx2x_link_update function should be called upon link |
| 6523 | * interrupt. |
| 6524 | * Link is considered up as follows: |
| 6525 | * - DIRECT_SINGLE_MEDIA - Only XGXS link (internal link) needs |
| 6526 | * to be up |
| 6527 | * - SINGLE_MEDIA - The link between the 577xx and the external |
| 6528 | * phy (XGXS) need to up as well as the external link of the |
| 6529 | * phy (PHY_EXT1) |
| 6530 | * - DUAL_MEDIA - The link between the 577xx and the first |
| 6531 | * external phy needs to be up, and at least one of the 2 |
| 6532 | * external phy link must be up. |
Yaniv Rosner | 62b29a5 | 2010-09-07 11:40:58 +0000 | [diff] [blame] | 6533 | */ |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6534 | int bnx2x_link_update(struct link_params *params, struct link_vars *vars) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6535 | { |
| 6536 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6537 | struct link_vars phy_vars[MAX_PHYS]; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6538 | u8 port = params->port; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6539 | u8 link_10g_plus, phy_index; |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6540 | u8 ext_phy_link_up = 0, cur_link_up; |
| 6541 | int rc = 0; |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 6542 | u8 is_mi_int = 0; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6543 | u16 ext_phy_line_speed = 0, prev_line_speed = vars->line_speed; |
| 6544 | u8 active_external_phy = INT_PHY; |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 6545 | vars->phy_flags &= ~PHY_HALF_OPEN_CONN_FLAG; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6546 | for (phy_index = INT_PHY; phy_index < params->num_phys; |
| 6547 | phy_index++) { |
| 6548 | phy_vars[phy_index].flow_ctrl = 0; |
| 6549 | phy_vars[phy_index].link_status = 0; |
| 6550 | phy_vars[phy_index].line_speed = 0; |
| 6551 | phy_vars[phy_index].duplex = DUPLEX_FULL; |
| 6552 | phy_vars[phy_index].phy_link_up = 0; |
| 6553 | phy_vars[phy_index].link_up = 0; |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 6554 | phy_vars[phy_index].fault_detected = 0; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6555 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6556 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6557 | if (USES_WARPCORE(bp)) |
| 6558 | bnx2x_set_aer_mmd(params, ¶ms->phy[INT_PHY]); |
| 6559 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6560 | 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] | 6561 | port, (vars->phy_flags & PHY_XGXS_FLAG), |
| 6562 | REG_RD(bp, NIG_REG_STATUS_INTERRUPT_PORT0 + port*4)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6563 | |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 6564 | 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] | 6565 | port*0x18) > 0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6566 | 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] | 6567 | REG_RD(bp, NIG_REG_MASK_INTERRUPT_PORT0 + port*4), |
| 6568 | is_mi_int, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6569 | REG_RD(bp, NIG_REG_SERDES0_STATUS_LINK_STATUS + port*0x3c)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6570 | |
| 6571 | DP(NETIF_MSG_LINK, " 10G %x, XGXS_LINK %x\n", |
| 6572 | REG_RD(bp, NIG_REG_XGXS0_STATUS_LINK10G + port*0x68), |
| 6573 | REG_RD(bp, NIG_REG_XGXS0_STATUS_LINK_STATUS + port*0x68)); |
| 6574 | |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 6575 | /* disable emac */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 6576 | if (!CHIP_IS_E3(bp)) |
| 6577 | REG_WR(bp, NIG_REG_NIG_EMAC0_EN + port*4, 0); |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 6578 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6579 | /* |
| 6580 | * Step 1: |
| 6581 | * Check external link change only for external phys, and apply |
| 6582 | * priority selection between them in case the link on both phys |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 6583 | * is up. Note that instead of the common vars, a temporary |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6584 | * vars argument is used since each phy may have different link/ |
| 6585 | * speed/duplex result |
| 6586 | */ |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6587 | for (phy_index = EXT_PHY1; phy_index < params->num_phys; |
| 6588 | phy_index++) { |
| 6589 | struct bnx2x_phy *phy = ¶ms->phy[phy_index]; |
| 6590 | if (!phy->read_status) |
| 6591 | continue; |
| 6592 | /* Read link status and params of this ext phy */ |
| 6593 | cur_link_up = phy->read_status(phy, params, |
| 6594 | &phy_vars[phy_index]); |
| 6595 | if (cur_link_up) { |
| 6596 | DP(NETIF_MSG_LINK, "phy in index %d link is up\n", |
| 6597 | phy_index); |
| 6598 | } else { |
| 6599 | DP(NETIF_MSG_LINK, "phy in index %d link is down\n", |
| 6600 | phy_index); |
| 6601 | continue; |
| 6602 | } |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6603 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6604 | if (!ext_phy_link_up) { |
| 6605 | ext_phy_link_up = 1; |
| 6606 | active_external_phy = phy_index; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6607 | } else { |
| 6608 | switch (bnx2x_phy_selection(params)) { |
| 6609 | case PORT_HW_CFG_PHY_SELECTION_HARDWARE_DEFAULT: |
| 6610 | case PORT_HW_CFG_PHY_SELECTION_FIRST_PHY_PRIORITY: |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6611 | /* |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6612 | * In this option, the first PHY makes sure to pass the |
| 6613 | * traffic through itself only. |
| 6614 | * Its not clear how to reset the link on the second phy |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6615 | */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6616 | active_external_phy = EXT_PHY1; |
| 6617 | break; |
| 6618 | case PORT_HW_CFG_PHY_SELECTION_SECOND_PHY_PRIORITY: |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6619 | /* |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6620 | * In this option, the first PHY makes sure to pass the |
| 6621 | * traffic through the second PHY. |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6622 | */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6623 | active_external_phy = EXT_PHY2; |
| 6624 | break; |
| 6625 | default: |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6626 | /* |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6627 | * Link indication on both PHYs with the following cases |
| 6628 | * is invalid: |
| 6629 | * - FIRST_PHY means that second phy wasn't initialized, |
| 6630 | * hence its link is expected to be down |
| 6631 | * - SECOND_PHY means that first phy should not be able |
| 6632 | * to link up by itself (using configuration) |
| 6633 | * - DEFAULT should be overriden during initialiazation |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6634 | */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6635 | DP(NETIF_MSG_LINK, "Invalid link indication" |
| 6636 | "mpc=0x%x. DISABLING LINK !!!\n", |
| 6637 | params->multi_phy_config); |
| 6638 | ext_phy_link_up = 0; |
| 6639 | break; |
| 6640 | } |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6641 | } |
| 6642 | } |
| 6643 | prev_line_speed = vars->line_speed; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6644 | /* |
| 6645 | * Step 2: |
| 6646 | * Read the status of the internal phy. In case of |
| 6647 | * DIRECT_SINGLE_MEDIA board, this link is the external link, |
| 6648 | * otherwise this is the link between the 577xx and the first |
| 6649 | * external phy |
| 6650 | */ |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6651 | if (params->phy[INT_PHY].read_status) |
| 6652 | params->phy[INT_PHY].read_status( |
| 6653 | ¶ms->phy[INT_PHY], |
| 6654 | params, vars); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6655 | /* |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6656 | * The INT_PHY flow control reside in the vars. This include the |
| 6657 | * case where the speed or flow control are not set to AUTO. |
| 6658 | * Otherwise, the active external phy flow control result is set |
| 6659 | * to the vars. The ext_phy_line_speed is needed to check if the |
| 6660 | * speed is different between the internal phy and external phy. |
| 6661 | * This case may be result of intermediate link speed change. |
| 6662 | */ |
| 6663 | if (active_external_phy > INT_PHY) { |
| 6664 | vars->flow_ctrl = phy_vars[active_external_phy].flow_ctrl; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6665 | /* |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6666 | * Link speed is taken from the XGXS. AN and FC result from |
| 6667 | * the external phy. |
| 6668 | */ |
| 6669 | vars->link_status |= phy_vars[active_external_phy].link_status; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6670 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6671 | /* |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6672 | * if active_external_phy is first PHY and link is up - disable |
| 6673 | * disable TX on second external PHY |
| 6674 | */ |
| 6675 | if (active_external_phy == EXT_PHY1) { |
| 6676 | if (params->phy[EXT_PHY2].phy_specific_func) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 6677 | DP(NETIF_MSG_LINK, |
| 6678 | "Disabling TX on EXT_PHY2\n"); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6679 | params->phy[EXT_PHY2].phy_specific_func( |
| 6680 | ¶ms->phy[EXT_PHY2], |
| 6681 | params, DISABLE_TX); |
| 6682 | } |
| 6683 | } |
| 6684 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6685 | ext_phy_line_speed = phy_vars[active_external_phy].line_speed; |
| 6686 | vars->duplex = phy_vars[active_external_phy].duplex; |
| 6687 | if (params->phy[active_external_phy].supported & |
| 6688 | SUPPORTED_FIBRE) |
| 6689 | vars->link_status |= LINK_STATUS_SERDES_LINK; |
Yaniv Rosner | fd36a2e | 2011-05-31 21:29:05 +0000 | [diff] [blame] | 6690 | else |
| 6691 | vars->link_status &= ~LINK_STATUS_SERDES_LINK; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6692 | DP(NETIF_MSG_LINK, "Active external phy selected: %x\n", |
| 6693 | active_external_phy); |
| 6694 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6695 | |
| 6696 | for (phy_index = EXT_PHY1; phy_index < params->num_phys; |
| 6697 | phy_index++) { |
| 6698 | if (params->phy[phy_index].flags & |
| 6699 | FLAGS_REARM_LATCH_SIGNAL) { |
| 6700 | bnx2x_rearm_latch_signal(bp, port, |
| 6701 | phy_index == |
| 6702 | active_external_phy); |
| 6703 | break; |
| 6704 | } |
| 6705 | } |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6706 | DP(NETIF_MSG_LINK, "vars->flow_ctrl = 0x%x, vars->link_status = 0x%x," |
| 6707 | " ext_phy_line_speed = %d\n", vars->flow_ctrl, |
| 6708 | vars->link_status, ext_phy_line_speed); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6709 | /* |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6710 | * Upon link speed change set the NIG into drain mode. Comes to |
| 6711 | * deals with possible FIFO glitch due to clk change when speed |
| 6712 | * is decreased without link down indicator |
| 6713 | */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6714 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6715 | if (vars->phy_link_up) { |
| 6716 | if (!(SINGLE_MEDIA_DIRECT(params)) && ext_phy_link_up && |
| 6717 | (ext_phy_line_speed != vars->line_speed)) { |
| 6718 | DP(NETIF_MSG_LINK, "Internal link speed %d is" |
| 6719 | " different than the external" |
| 6720 | " link speed %d\n", vars->line_speed, |
| 6721 | ext_phy_line_speed); |
| 6722 | vars->phy_link_up = 0; |
| 6723 | } else if (prev_line_speed != vars->line_speed) { |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6724 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + params->port*4, |
| 6725 | 0); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6726 | msleep(1); |
| 6727 | } |
| 6728 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6729 | |
| 6730 | /* anything 10 and over uses the bmac */ |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6731 | link_10g_plus = (vars->line_speed >= SPEED_10000); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6732 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6733 | bnx2x_link_int_ack(params, vars, link_10g_plus); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6734 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6735 | /* |
| 6736 | * In case external phy link is up, and internal link is down |
| 6737 | * (not initialized yet probably after link initialization, it |
| 6738 | * needs to be initialized. |
| 6739 | * Note that after link down-up as result of cable plug, the xgxs |
| 6740 | * link would probably become up again without the need |
| 6741 | * initialize it |
| 6742 | */ |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6743 | if (!(SINGLE_MEDIA_DIRECT(params))) { |
| 6744 | DP(NETIF_MSG_LINK, "ext_phy_link_up = %d, int_link_up = %d," |
| 6745 | " init_preceding = %d\n", ext_phy_link_up, |
| 6746 | vars->phy_link_up, |
| 6747 | params->phy[EXT_PHY1].flags & |
| 6748 | FLAGS_INIT_XGXS_FIRST); |
| 6749 | if (!(params->phy[EXT_PHY1].flags & |
| 6750 | FLAGS_INIT_XGXS_FIRST) |
| 6751 | && ext_phy_link_up && !vars->phy_link_up) { |
| 6752 | vars->line_speed = ext_phy_line_speed; |
| 6753 | if (vars->line_speed < SPEED_1000) |
| 6754 | vars->phy_flags |= PHY_SGMII_FLAG; |
| 6755 | else |
| 6756 | vars->phy_flags &= ~PHY_SGMII_FLAG; |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 6757 | |
| 6758 | if (params->phy[INT_PHY].config_init) |
| 6759 | params->phy[INT_PHY].config_init( |
| 6760 | ¶ms->phy[INT_PHY], params, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6761 | vars); |
| 6762 | } |
| 6763 | } |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6764 | /* |
| 6765 | * 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] | 6766 | * non-direct board) are up and no fault detected on active PHY. |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6767 | */ |
| 6768 | vars->link_up = (vars->phy_link_up && |
| 6769 | (ext_phy_link_up || |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 6770 | SINGLE_MEDIA_DIRECT(params)) && |
| 6771 | (phy_vars[active_external_phy].fault_detected == 0)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6772 | |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6773 | if (vars->link_up) |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6774 | rc = bnx2x_update_link_up(params, vars, link_10g_plus); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6775 | else |
| 6776 | rc = bnx2x_update_link_down(params, vars); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6777 | |
| 6778 | return rc; |
| 6779 | } |
| 6780 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6781 | |
| 6782 | /*****************************************************************************/ |
| 6783 | /* External Phy section */ |
| 6784 | /*****************************************************************************/ |
| 6785 | void bnx2x_ext_phy_hw_reset(struct bnx2x *bp, u8 port) |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6786 | { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6787 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6788 | MISC_REGISTERS_GPIO_OUTPUT_LOW, port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6789 | msleep(1); |
| 6790 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6791 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, port); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6792 | } |
| 6793 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6794 | static void bnx2x_save_spirom_version(struct bnx2x *bp, u8 port, |
| 6795 | u32 spirom_ver, u32 ver_addr) |
| 6796 | { |
| 6797 | DP(NETIF_MSG_LINK, "FW version 0x%x:0x%x for port %d\n", |
| 6798 | (u16)(spirom_ver>>16), (u16)spirom_ver, port); |
| 6799 | |
| 6800 | if (ver_addr) |
| 6801 | REG_WR(bp, ver_addr, spirom_ver); |
| 6802 | } |
| 6803 | |
| 6804 | static void bnx2x_save_bcm_spirom_ver(struct bnx2x *bp, |
| 6805 | struct bnx2x_phy *phy, |
| 6806 | u8 port) |
| 6807 | { |
| 6808 | u16 fw_ver1, fw_ver2; |
| 6809 | |
| 6810 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6811 | MDIO_PMA_REG_ROM_VER1, &fw_ver1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6812 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6813 | MDIO_PMA_REG_ROM_VER2, &fw_ver2); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6814 | bnx2x_save_spirom_version(bp, port, (u32)(fw_ver1<<16 | fw_ver2), |
| 6815 | phy->ver_addr); |
| 6816 | } |
| 6817 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6818 | static void bnx2x_ext_phy_10G_an_resolve(struct bnx2x *bp, |
| 6819 | struct bnx2x_phy *phy, |
| 6820 | struct link_vars *vars) |
| 6821 | { |
| 6822 | u16 val; |
| 6823 | bnx2x_cl45_read(bp, phy, |
| 6824 | MDIO_AN_DEVAD, |
| 6825 | MDIO_AN_REG_STATUS, &val); |
| 6826 | bnx2x_cl45_read(bp, phy, |
| 6827 | MDIO_AN_DEVAD, |
| 6828 | MDIO_AN_REG_STATUS, &val); |
| 6829 | if (val & (1<<5)) |
| 6830 | vars->link_status |= LINK_STATUS_AUTO_NEGOTIATE_COMPLETE; |
| 6831 | if ((val & (1<<0)) == 0) |
| 6832 | vars->link_status |= LINK_STATUS_PARALLEL_DETECTION_USED; |
| 6833 | } |
| 6834 | |
| 6835 | /******************************************************************/ |
| 6836 | /* common BCM8073/BCM8727 PHY SECTION */ |
| 6837 | /******************************************************************/ |
| 6838 | static void bnx2x_8073_resolve_fc(struct bnx2x_phy *phy, |
| 6839 | struct link_params *params, |
| 6840 | struct link_vars *vars) |
| 6841 | { |
| 6842 | struct bnx2x *bp = params->bp; |
| 6843 | if (phy->req_line_speed == SPEED_10 || |
| 6844 | phy->req_line_speed == SPEED_100) { |
| 6845 | vars->flow_ctrl = phy->req_flow_ctrl; |
| 6846 | return; |
| 6847 | } |
| 6848 | |
| 6849 | if (bnx2x_ext_phy_resolve_fc(phy, params, vars) && |
| 6850 | (vars->flow_ctrl == BNX2X_FLOW_CTRL_NONE)) { |
| 6851 | u16 pause_result; |
| 6852 | u16 ld_pause; /* local */ |
| 6853 | u16 lp_pause; /* link partner */ |
| 6854 | bnx2x_cl45_read(bp, phy, |
| 6855 | MDIO_AN_DEVAD, |
| 6856 | MDIO_AN_REG_CL37_FC_LD, &ld_pause); |
| 6857 | |
| 6858 | bnx2x_cl45_read(bp, phy, |
| 6859 | MDIO_AN_DEVAD, |
| 6860 | MDIO_AN_REG_CL37_FC_LP, &lp_pause); |
| 6861 | pause_result = (ld_pause & |
| 6862 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) >> 5; |
| 6863 | pause_result |= (lp_pause & |
| 6864 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) >> 7; |
| 6865 | |
| 6866 | bnx2x_pause_resolve(vars, pause_result); |
| 6867 | DP(NETIF_MSG_LINK, "Ext PHY CL37 pause result 0x%x\n", |
| 6868 | pause_result); |
| 6869 | } |
| 6870 | } |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6871 | static int bnx2x_8073_8727_external_rom_boot(struct bnx2x *bp, |
| 6872 | struct bnx2x_phy *phy, |
| 6873 | u8 port) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6874 | { |
Yaniv Rosner | 5c99274b | 2011-01-18 04:33:36 +0000 | [diff] [blame] | 6875 | u32 count = 0; |
| 6876 | u16 fw_ver1, fw_msgout; |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6877 | int rc = 0; |
Yaniv Rosner | 5c99274b | 2011-01-18 04:33:36 +0000 | [diff] [blame] | 6878 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6879 | /* Boot port from external ROM */ |
| 6880 | /* EDC grst */ |
| 6881 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6882 | MDIO_PMA_DEVAD, |
| 6883 | MDIO_PMA_REG_GEN_CTRL, |
| 6884 | 0x0001); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6885 | |
| 6886 | /* ucode reboot and rst */ |
| 6887 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6888 | MDIO_PMA_DEVAD, |
| 6889 | MDIO_PMA_REG_GEN_CTRL, |
| 6890 | 0x008c); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6891 | |
| 6892 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6893 | MDIO_PMA_DEVAD, |
| 6894 | MDIO_PMA_REG_MISC_CTRL1, 0x0001); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6895 | |
| 6896 | /* Reset internal microprocessor */ |
| 6897 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6898 | MDIO_PMA_DEVAD, |
| 6899 | MDIO_PMA_REG_GEN_CTRL, |
| 6900 | MDIO_PMA_REG_GEN_CTRL_ROM_MICRO_RESET); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6901 | |
| 6902 | /* Release srst bit */ |
| 6903 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6904 | MDIO_PMA_DEVAD, |
| 6905 | MDIO_PMA_REG_GEN_CTRL, |
| 6906 | MDIO_PMA_REG_GEN_CTRL_ROM_RESET_INTERNAL_MP); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6907 | |
Yaniv Rosner | 5c99274b | 2011-01-18 04:33:36 +0000 | [diff] [blame] | 6908 | /* Delay 100ms per the PHY specifications */ |
| 6909 | msleep(100); |
| 6910 | |
| 6911 | /* 8073 sometimes taking longer to download */ |
| 6912 | do { |
| 6913 | count++; |
| 6914 | if (count > 300) { |
| 6915 | DP(NETIF_MSG_LINK, |
| 6916 | "bnx2x_8073_8727_external_rom_boot port %x:" |
| 6917 | "Download failed. fw version = 0x%x\n", |
| 6918 | port, fw_ver1); |
| 6919 | rc = -EINVAL; |
| 6920 | break; |
| 6921 | } |
| 6922 | |
| 6923 | bnx2x_cl45_read(bp, phy, |
| 6924 | MDIO_PMA_DEVAD, |
| 6925 | MDIO_PMA_REG_ROM_VER1, &fw_ver1); |
| 6926 | bnx2x_cl45_read(bp, phy, |
| 6927 | MDIO_PMA_DEVAD, |
| 6928 | MDIO_PMA_REG_M8051_MSGOUT_REG, &fw_msgout); |
| 6929 | |
| 6930 | msleep(1); |
| 6931 | } while (fw_ver1 == 0 || fw_ver1 == 0x4321 || |
| 6932 | ((fw_msgout & 0xff) != 0x03 && (phy->type == |
| 6933 | PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073))); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6934 | |
| 6935 | /* Clear ser_boot_ctl bit */ |
| 6936 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6937 | MDIO_PMA_DEVAD, |
| 6938 | MDIO_PMA_REG_MISC_CTRL1, 0x0000); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6939 | bnx2x_save_bcm_spirom_ver(bp, phy, port); |
Yaniv Rosner | 5c99274b | 2011-01-18 04:33:36 +0000 | [diff] [blame] | 6940 | |
| 6941 | DP(NETIF_MSG_LINK, |
| 6942 | "bnx2x_8073_8727_external_rom_boot port %x:" |
| 6943 | "Download complete. fw version = 0x%x\n", |
| 6944 | port, fw_ver1); |
| 6945 | |
| 6946 | return rc; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6947 | } |
| 6948 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6949 | /******************************************************************/ |
| 6950 | /* BCM8073 PHY SECTION */ |
| 6951 | /******************************************************************/ |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6952 | 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] | 6953 | { |
| 6954 | /* This is only required for 8073A1, version 102 only */ |
| 6955 | u16 val; |
| 6956 | |
| 6957 | /* Read 8073 HW revision*/ |
| 6958 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6959 | MDIO_PMA_DEVAD, |
| 6960 | MDIO_PMA_REG_8073_CHIP_REV, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6961 | |
| 6962 | if (val != 1) { |
| 6963 | /* No need to workaround in 8073 A1 */ |
| 6964 | return 0; |
| 6965 | } |
| 6966 | |
| 6967 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6968 | MDIO_PMA_DEVAD, |
| 6969 | MDIO_PMA_REG_ROM_VER2, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6970 | |
| 6971 | /* SNR should be applied only for version 0x102 */ |
| 6972 | if (val != 0x102) |
| 6973 | return 0; |
| 6974 | |
| 6975 | return 1; |
| 6976 | } |
| 6977 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6978 | 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] | 6979 | { |
| 6980 | u16 val, cnt, cnt1 ; |
| 6981 | |
| 6982 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6983 | MDIO_PMA_DEVAD, |
| 6984 | MDIO_PMA_REG_8073_CHIP_REV, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6985 | |
| 6986 | if (val > 0) { |
| 6987 | /* No need to workaround in 8073 A1 */ |
| 6988 | return 0; |
| 6989 | } |
| 6990 | /* XAUI workaround in 8073 A0: */ |
| 6991 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6992 | /* |
| 6993 | * After loading the boot ROM and restarting Autoneg, poll |
| 6994 | * Dev1, Reg $C820: |
| 6995 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6996 | |
| 6997 | for (cnt = 0; cnt < 1000; cnt++) { |
| 6998 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6999 | MDIO_PMA_DEVAD, |
| 7000 | MDIO_PMA_REG_8073_SPEED_LINK_STATUS, |
| 7001 | &val); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7002 | /* |
| 7003 | * If bit [14] = 0 or bit [13] = 0, continue on with |
| 7004 | * system initialization (XAUI work-around not required, as |
| 7005 | * these bits indicate 2.5G or 1G link up). |
| 7006 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7007 | if (!(val & (1<<14)) || !(val & (1<<13))) { |
| 7008 | DP(NETIF_MSG_LINK, "XAUI work-around not required\n"); |
| 7009 | return 0; |
| 7010 | } else if (!(val & (1<<15))) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7011 | DP(NETIF_MSG_LINK, "bit 15 went off\n"); |
| 7012 | /* |
| 7013 | * If bit 15 is 0, then poll Dev1, Reg $C841 until it's |
| 7014 | * MSB (bit15) goes to 1 (indicating that the XAUI |
| 7015 | * workaround has completed), then continue on with |
| 7016 | * system initialization. |
| 7017 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7018 | for (cnt1 = 0; cnt1 < 1000; cnt1++) { |
| 7019 | bnx2x_cl45_read(bp, phy, |
| 7020 | MDIO_PMA_DEVAD, |
| 7021 | MDIO_PMA_REG_8073_XAUI_WA, &val); |
| 7022 | if (val & (1<<15)) { |
| 7023 | DP(NETIF_MSG_LINK, |
| 7024 | "XAUI workaround has completed\n"); |
| 7025 | return 0; |
| 7026 | } |
| 7027 | msleep(3); |
| 7028 | } |
| 7029 | break; |
| 7030 | } |
| 7031 | msleep(3); |
| 7032 | } |
| 7033 | DP(NETIF_MSG_LINK, "Warning: XAUI work-around timeout !!!\n"); |
| 7034 | return -EINVAL; |
| 7035 | } |
| 7036 | |
| 7037 | static void bnx2x_807x_force_10G(struct bnx2x *bp, struct bnx2x_phy *phy) |
| 7038 | { |
| 7039 | /* Force KR or KX */ |
| 7040 | bnx2x_cl45_write(bp, phy, |
| 7041 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 0x2040); |
| 7042 | bnx2x_cl45_write(bp, phy, |
| 7043 | MDIO_PMA_DEVAD, MDIO_PMA_REG_10G_CTRL2, 0x000b); |
| 7044 | bnx2x_cl45_write(bp, phy, |
| 7045 | MDIO_PMA_DEVAD, MDIO_PMA_REG_BCM_CTRL, 0x0000); |
| 7046 | bnx2x_cl45_write(bp, phy, |
| 7047 | MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, 0x0000); |
| 7048 | } |
| 7049 | |
| 7050 | static void bnx2x_8073_set_pause_cl37(struct link_params *params, |
| 7051 | struct bnx2x_phy *phy, |
| 7052 | struct link_vars *vars) |
| 7053 | { |
| 7054 | u16 cl37_val; |
| 7055 | struct bnx2x *bp = params->bp; |
| 7056 | bnx2x_cl45_read(bp, phy, |
| 7057 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_FC_LD, &cl37_val); |
| 7058 | |
| 7059 | cl37_val &= ~MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH; |
| 7060 | /* Please refer to Table 28B-3 of 802.3ab-1999 spec. */ |
| 7061 | bnx2x_calc_ieee_aneg_adv(phy, params, &vars->ieee_fc); |
| 7062 | if ((vars->ieee_fc & |
| 7063 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_SYMMETRIC) == |
| 7064 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_SYMMETRIC) { |
| 7065 | cl37_val |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_SYMMETRIC; |
| 7066 | } |
| 7067 | if ((vars->ieee_fc & |
| 7068 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC) == |
| 7069 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC) { |
| 7070 | cl37_val |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC; |
| 7071 | } |
| 7072 | if ((vars->ieee_fc & |
| 7073 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) == |
| 7074 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) { |
| 7075 | cl37_val |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH; |
| 7076 | } |
| 7077 | DP(NETIF_MSG_LINK, |
| 7078 | "Ext phy AN advertize cl37 0x%x\n", cl37_val); |
| 7079 | |
| 7080 | bnx2x_cl45_write(bp, phy, |
| 7081 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_FC_LD, cl37_val); |
| 7082 | msleep(500); |
| 7083 | } |
| 7084 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 7085 | static int bnx2x_8073_config_init(struct bnx2x_phy *phy, |
| 7086 | struct link_params *params, |
| 7087 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7088 | { |
| 7089 | struct bnx2x *bp = params->bp; |
| 7090 | u16 val = 0, tmp1; |
| 7091 | u8 gpio_port; |
| 7092 | DP(NETIF_MSG_LINK, "Init 8073\n"); |
| 7093 | |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 7094 | if (CHIP_IS_E2(bp)) |
| 7095 | gpio_port = BP_PATH(bp); |
| 7096 | else |
| 7097 | gpio_port = params->port; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7098 | /* Restore normal power mode*/ |
| 7099 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7100 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, gpio_port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7101 | |
| 7102 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7103 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, gpio_port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7104 | |
| 7105 | /* enable LASI */ |
| 7106 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 7107 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_RXCTRL, (1<<2)); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7108 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 7109 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_CTRL, 0x0004); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7110 | |
| 7111 | bnx2x_8073_set_pause_cl37(params, phy, vars); |
| 7112 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7113 | bnx2x_cl45_read(bp, phy, |
| 7114 | MDIO_PMA_DEVAD, MDIO_PMA_REG_M8051_MSGOUT_REG, &tmp1); |
| 7115 | |
| 7116 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 7117 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_RXSTAT, &tmp1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7118 | |
| 7119 | DP(NETIF_MSG_LINK, "Before rom RX_ALARM(port1): 0x%x\n", tmp1); |
| 7120 | |
Yaniv Rosner | 74d7a11 | 2011-01-18 04:33:18 +0000 | [diff] [blame] | 7121 | /* Swap polarity if required - Must be done only in non-1G mode */ |
| 7122 | if (params->lane_config & PORT_HW_CFG_SWAP_PHY_POLARITY_ENABLED) { |
| 7123 | /* Configure the 8073 to swap _P and _N of the KR lines */ |
| 7124 | DP(NETIF_MSG_LINK, "Swapping polarity for the 8073\n"); |
| 7125 | /* 10G Rx/Tx and 1G Tx signal polarity swap */ |
| 7126 | bnx2x_cl45_read(bp, phy, |
| 7127 | MDIO_PMA_DEVAD, |
| 7128 | MDIO_PMA_REG_8073_OPT_DIGITAL_CTRL, &val); |
| 7129 | bnx2x_cl45_write(bp, phy, |
| 7130 | MDIO_PMA_DEVAD, |
| 7131 | MDIO_PMA_REG_8073_OPT_DIGITAL_CTRL, |
| 7132 | (val | (3<<9))); |
| 7133 | } |
| 7134 | |
| 7135 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7136 | /* Enable CL37 BAM */ |
Yaniv Rosner | 121839b | 2010-11-01 05:32:38 +0000 | [diff] [blame] | 7137 | if (REG_RD(bp, params->shmem_base + |
| 7138 | offsetof(struct shmem_region, dev_info. |
| 7139 | port_hw_config[params->port].default_cfg)) & |
| 7140 | PORT_HW_CFG_ENABLE_BAM_ON_KR_ENABLED) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7141 | |
Yaniv Rosner | 121839b | 2010-11-01 05:32:38 +0000 | [diff] [blame] | 7142 | bnx2x_cl45_read(bp, phy, |
| 7143 | MDIO_AN_DEVAD, |
| 7144 | MDIO_AN_REG_8073_BAM, &val); |
| 7145 | bnx2x_cl45_write(bp, phy, |
| 7146 | MDIO_AN_DEVAD, |
| 7147 | MDIO_AN_REG_8073_BAM, val | 1); |
| 7148 | DP(NETIF_MSG_LINK, "Enable CL37 BAM on KR\n"); |
| 7149 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7150 | if (params->loopback_mode == LOOPBACK_EXT) { |
| 7151 | bnx2x_807x_force_10G(bp, phy); |
| 7152 | DP(NETIF_MSG_LINK, "Forced speed 10G on 807X\n"); |
| 7153 | return 0; |
| 7154 | } else { |
| 7155 | bnx2x_cl45_write(bp, phy, |
| 7156 | MDIO_PMA_DEVAD, MDIO_PMA_REG_BCM_CTRL, 0x0002); |
| 7157 | } |
| 7158 | if (phy->req_line_speed != SPEED_AUTO_NEG) { |
| 7159 | if (phy->req_line_speed == SPEED_10000) { |
| 7160 | val = (1<<7); |
| 7161 | } else if (phy->req_line_speed == SPEED_2500) { |
| 7162 | val = (1<<5); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7163 | /* |
| 7164 | * Note that 2.5G works only when used with 1G |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 7165 | * advertisement |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7166 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7167 | } else |
| 7168 | val = (1<<5); |
| 7169 | } else { |
| 7170 | val = 0; |
| 7171 | if (phy->speed_cap_mask & |
| 7172 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G) |
| 7173 | val |= (1<<7); |
| 7174 | |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 7175 | /* Note that 2.5G works only when used with 1G advertisement */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7176 | if (phy->speed_cap_mask & |
| 7177 | (PORT_HW_CFG_SPEED_CAPABILITY_D0_1G | |
| 7178 | PORT_HW_CFG_SPEED_CAPABILITY_D0_2_5G)) |
| 7179 | val |= (1<<5); |
| 7180 | DP(NETIF_MSG_LINK, "807x autoneg val = 0x%x\n", val); |
| 7181 | } |
| 7182 | |
| 7183 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_ADV, val); |
| 7184 | bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_8073_2_5G, &tmp1); |
| 7185 | |
| 7186 | if (((phy->speed_cap_mask & PORT_HW_CFG_SPEED_CAPABILITY_D0_2_5G) && |
| 7187 | (phy->req_line_speed == SPEED_AUTO_NEG)) || |
| 7188 | (phy->req_line_speed == SPEED_2500)) { |
| 7189 | u16 phy_ver; |
| 7190 | /* Allow 2.5G for A1 and above */ |
| 7191 | bnx2x_cl45_read(bp, phy, |
| 7192 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8073_CHIP_REV, |
| 7193 | &phy_ver); |
| 7194 | DP(NETIF_MSG_LINK, "Add 2.5G\n"); |
| 7195 | if (phy_ver > 0) |
| 7196 | tmp1 |= 1; |
| 7197 | else |
| 7198 | tmp1 &= 0xfffe; |
| 7199 | } else { |
| 7200 | DP(NETIF_MSG_LINK, "Disable 2.5G\n"); |
| 7201 | tmp1 &= 0xfffe; |
| 7202 | } |
| 7203 | |
| 7204 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_8073_2_5G, tmp1); |
| 7205 | /* Add support for CL37 (passive mode) II */ |
| 7206 | |
| 7207 | bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_CL37_FC_LD, &tmp1); |
| 7208 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_CL37_FC_LD, |
| 7209 | (tmp1 | ((phy->req_duplex == DUPLEX_FULL) ? |
| 7210 | 0x20 : 0x40))); |
| 7211 | |
| 7212 | /* Add support for CL37 (passive mode) III */ |
| 7213 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_CL37_AN, 0x1000); |
| 7214 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7215 | /* |
| 7216 | * The SNR will improve about 2db by changing BW and FEE main |
| 7217 | * tap. Rest commands are executed after link is up |
| 7218 | * Change FFE main cursor to 5 in EDC register |
| 7219 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7220 | if (bnx2x_8073_is_snr_needed(bp, phy)) |
| 7221 | bnx2x_cl45_write(bp, phy, |
| 7222 | MDIO_PMA_DEVAD, MDIO_PMA_REG_EDC_FFE_MAIN, |
| 7223 | 0xFB0C); |
| 7224 | |
| 7225 | /* Enable FEC (Forware Error Correction) Request in the AN */ |
| 7226 | bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_ADV2, &tmp1); |
| 7227 | tmp1 |= (1<<15); |
| 7228 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_ADV2, tmp1); |
| 7229 | |
| 7230 | bnx2x_ext_phy_set_pause(params, phy, vars); |
| 7231 | |
| 7232 | /* Restart autoneg */ |
| 7233 | msleep(500); |
| 7234 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, 0x1200); |
| 7235 | DP(NETIF_MSG_LINK, "807x Autoneg Restart: Advertise 1G=%x, 10G=%x\n", |
| 7236 | ((val & (1<<5)) > 0), ((val & (1<<7)) > 0)); |
| 7237 | return 0; |
| 7238 | } |
| 7239 | |
| 7240 | static u8 bnx2x_8073_read_status(struct bnx2x_phy *phy, |
| 7241 | struct link_params *params, |
| 7242 | struct link_vars *vars) |
| 7243 | { |
| 7244 | struct bnx2x *bp = params->bp; |
| 7245 | u8 link_up = 0; |
| 7246 | u16 val1, val2; |
| 7247 | u16 link_status = 0; |
| 7248 | u16 an1000_status = 0; |
| 7249 | |
| 7250 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 7251 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_STAT, &val1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7252 | |
| 7253 | DP(NETIF_MSG_LINK, "8703 LASI status 0x%x\n", val1); |
| 7254 | |
| 7255 | /* clear the interrupt LASI status register */ |
| 7256 | bnx2x_cl45_read(bp, phy, |
| 7257 | MDIO_PCS_DEVAD, MDIO_PCS_REG_STATUS, &val2); |
| 7258 | bnx2x_cl45_read(bp, phy, |
| 7259 | MDIO_PCS_DEVAD, MDIO_PCS_REG_STATUS, &val1); |
| 7260 | DP(NETIF_MSG_LINK, "807x PCS status 0x%x->0x%x\n", val2, val1); |
| 7261 | /* Clear MSG-OUT */ |
| 7262 | bnx2x_cl45_read(bp, phy, |
| 7263 | MDIO_PMA_DEVAD, MDIO_PMA_REG_M8051_MSGOUT_REG, &val1); |
| 7264 | |
| 7265 | /* Check the LASI */ |
| 7266 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 7267 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_RXSTAT, &val2); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7268 | |
| 7269 | DP(NETIF_MSG_LINK, "KR 0x9003 0x%x\n", val2); |
| 7270 | |
| 7271 | /* Check the link status */ |
| 7272 | bnx2x_cl45_read(bp, phy, |
| 7273 | MDIO_PCS_DEVAD, MDIO_PCS_REG_STATUS, &val2); |
| 7274 | DP(NETIF_MSG_LINK, "KR PCS status 0x%x\n", val2); |
| 7275 | |
| 7276 | bnx2x_cl45_read(bp, phy, |
| 7277 | MDIO_PMA_DEVAD, MDIO_PMA_REG_STATUS, &val2); |
| 7278 | bnx2x_cl45_read(bp, phy, |
| 7279 | MDIO_PMA_DEVAD, MDIO_PMA_REG_STATUS, &val1); |
| 7280 | link_up = ((val1 & 4) == 4); |
| 7281 | DP(NETIF_MSG_LINK, "PMA_REG_STATUS=0x%x\n", val1); |
| 7282 | |
| 7283 | if (link_up && |
| 7284 | ((phy->req_line_speed != SPEED_10000))) { |
| 7285 | if (bnx2x_8073_xaui_wa(bp, phy) != 0) |
| 7286 | return 0; |
| 7287 | } |
| 7288 | bnx2x_cl45_read(bp, phy, |
| 7289 | MDIO_AN_DEVAD, MDIO_AN_REG_LINK_STATUS, &an1000_status); |
| 7290 | bnx2x_cl45_read(bp, phy, |
| 7291 | MDIO_AN_DEVAD, MDIO_AN_REG_LINK_STATUS, &an1000_status); |
| 7292 | |
| 7293 | /* Check the link status on 1.1.2 */ |
| 7294 | bnx2x_cl45_read(bp, phy, |
| 7295 | MDIO_PMA_DEVAD, MDIO_PMA_REG_STATUS, &val2); |
| 7296 | bnx2x_cl45_read(bp, phy, |
| 7297 | MDIO_PMA_DEVAD, MDIO_PMA_REG_STATUS, &val1); |
| 7298 | DP(NETIF_MSG_LINK, "KR PMA status 0x%x->0x%x," |
| 7299 | "an_link_status=0x%x\n", val2, val1, an1000_status); |
| 7300 | |
| 7301 | link_up = (((val1 & 4) == 4) || (an1000_status & (1<<1))); |
| 7302 | if (link_up && bnx2x_8073_is_snr_needed(bp, phy)) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7303 | /* |
| 7304 | * The SNR will improve about 2dbby changing the BW and FEE main |
| 7305 | * tap. The 1st write to change FFE main tap is set before |
| 7306 | * restart AN. Change PLL Bandwidth in EDC register |
| 7307 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7308 | bnx2x_cl45_write(bp, phy, |
| 7309 | MDIO_PMA_DEVAD, MDIO_PMA_REG_PLL_BANDWIDTH, |
| 7310 | 0x26BC); |
| 7311 | |
| 7312 | /* Change CDR Bandwidth in EDC register */ |
| 7313 | bnx2x_cl45_write(bp, phy, |
| 7314 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CDR_BANDWIDTH, |
| 7315 | 0x0333); |
| 7316 | } |
| 7317 | bnx2x_cl45_read(bp, phy, |
| 7318 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8073_SPEED_LINK_STATUS, |
| 7319 | &link_status); |
| 7320 | |
| 7321 | /* Bits 0..2 --> speed detected, bits 13..15--> link is down */ |
| 7322 | if ((link_status & (1<<2)) && (!(link_status & (1<<15)))) { |
| 7323 | link_up = 1; |
| 7324 | vars->line_speed = SPEED_10000; |
| 7325 | DP(NETIF_MSG_LINK, "port %x: External link up in 10G\n", |
| 7326 | params->port); |
| 7327 | } else if ((link_status & (1<<1)) && (!(link_status & (1<<14)))) { |
| 7328 | link_up = 1; |
| 7329 | vars->line_speed = SPEED_2500; |
| 7330 | DP(NETIF_MSG_LINK, "port %x: External link up in 2.5G\n", |
| 7331 | params->port); |
| 7332 | } else if ((link_status & (1<<0)) && (!(link_status & (1<<13)))) { |
| 7333 | link_up = 1; |
| 7334 | vars->line_speed = SPEED_1000; |
| 7335 | DP(NETIF_MSG_LINK, "port %x: External link up in 1G\n", |
| 7336 | params->port); |
| 7337 | } else { |
| 7338 | link_up = 0; |
| 7339 | DP(NETIF_MSG_LINK, "port %x: External link is down\n", |
| 7340 | params->port); |
| 7341 | } |
| 7342 | |
| 7343 | if (link_up) { |
Yaniv Rosner | 74d7a11 | 2011-01-18 04:33:18 +0000 | [diff] [blame] | 7344 | /* Swap polarity if required */ |
| 7345 | if (params->lane_config & |
| 7346 | PORT_HW_CFG_SWAP_PHY_POLARITY_ENABLED) { |
| 7347 | /* Configure the 8073 to swap P and N of the KR lines */ |
| 7348 | bnx2x_cl45_read(bp, phy, |
| 7349 | MDIO_XS_DEVAD, |
| 7350 | MDIO_XS_REG_8073_RX_CTRL_PCIE, &val1); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7351 | /* |
| 7352 | * Set bit 3 to invert Rx in 1G mode and clear this bit |
| 7353 | * when it`s in 10G mode. |
| 7354 | */ |
Yaniv Rosner | 74d7a11 | 2011-01-18 04:33:18 +0000 | [diff] [blame] | 7355 | if (vars->line_speed == SPEED_1000) { |
| 7356 | DP(NETIF_MSG_LINK, "Swapping 1G polarity for" |
| 7357 | "the 8073\n"); |
| 7358 | val1 |= (1<<3); |
| 7359 | } else |
| 7360 | val1 &= ~(1<<3); |
| 7361 | |
| 7362 | bnx2x_cl45_write(bp, phy, |
| 7363 | MDIO_XS_DEVAD, |
| 7364 | MDIO_XS_REG_8073_RX_CTRL_PCIE, |
| 7365 | val1); |
| 7366 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7367 | bnx2x_ext_phy_10G_an_resolve(bp, phy, vars); |
| 7368 | bnx2x_8073_resolve_fc(phy, params, vars); |
Yaniv Rosner | 791f18c | 2011-01-18 04:33:42 +0000 | [diff] [blame] | 7369 | vars->duplex = DUPLEX_FULL; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7370 | } |
| 7371 | return link_up; |
| 7372 | } |
| 7373 | |
| 7374 | static void bnx2x_8073_link_reset(struct bnx2x_phy *phy, |
| 7375 | struct link_params *params) |
| 7376 | { |
| 7377 | struct bnx2x *bp = params->bp; |
| 7378 | u8 gpio_port; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 7379 | if (CHIP_IS_E2(bp)) |
| 7380 | gpio_port = BP_PATH(bp); |
| 7381 | else |
| 7382 | gpio_port = params->port; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7383 | DP(NETIF_MSG_LINK, "Setting 8073 port %d into low power mode\n", |
| 7384 | gpio_port); |
| 7385 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7386 | MISC_REGISTERS_GPIO_OUTPUT_LOW, |
| 7387 | gpio_port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7388 | } |
| 7389 | |
| 7390 | /******************************************************************/ |
| 7391 | /* BCM8705 PHY SECTION */ |
| 7392 | /******************************************************************/ |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 7393 | static int bnx2x_8705_config_init(struct bnx2x_phy *phy, |
| 7394 | struct link_params *params, |
| 7395 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7396 | { |
| 7397 | struct bnx2x *bp = params->bp; |
| 7398 | DP(NETIF_MSG_LINK, "init 8705\n"); |
| 7399 | /* Restore normal power mode*/ |
| 7400 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7401 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, params->port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7402 | /* HW reset */ |
| 7403 | bnx2x_ext_phy_hw_reset(bp, params->port); |
| 7404 | 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] | 7405 | bnx2x_wait_reset_complete(bp, phy, params); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7406 | |
| 7407 | bnx2x_cl45_write(bp, phy, |
| 7408 | MDIO_PMA_DEVAD, MDIO_PMA_REG_MISC_CTRL, 0x8288); |
| 7409 | bnx2x_cl45_write(bp, phy, |
| 7410 | MDIO_PMA_DEVAD, MDIO_PMA_REG_PHY_IDENTIFIER, 0x7fbf); |
| 7411 | bnx2x_cl45_write(bp, phy, |
| 7412 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CMU_PLL_BYPASS, 0x0100); |
| 7413 | bnx2x_cl45_write(bp, phy, |
| 7414 | MDIO_WIS_DEVAD, MDIO_WIS_REG_LASI_CNTL, 0x1); |
| 7415 | /* BCM8705 doesn't have microcode, hence the 0 */ |
| 7416 | bnx2x_save_spirom_version(bp, params->port, params->shmem_base, 0); |
| 7417 | return 0; |
| 7418 | } |
| 7419 | |
| 7420 | static u8 bnx2x_8705_read_status(struct bnx2x_phy *phy, |
| 7421 | struct link_params *params, |
| 7422 | struct link_vars *vars) |
| 7423 | { |
| 7424 | u8 link_up = 0; |
| 7425 | u16 val1, rx_sd; |
| 7426 | struct bnx2x *bp = params->bp; |
| 7427 | DP(NETIF_MSG_LINK, "read status 8705\n"); |
| 7428 | bnx2x_cl45_read(bp, phy, |
| 7429 | MDIO_WIS_DEVAD, MDIO_WIS_REG_LASI_STATUS, &val1); |
| 7430 | DP(NETIF_MSG_LINK, "8705 LASI status 0x%x\n", val1); |
| 7431 | |
| 7432 | bnx2x_cl45_read(bp, phy, |
| 7433 | MDIO_WIS_DEVAD, MDIO_WIS_REG_LASI_STATUS, &val1); |
| 7434 | DP(NETIF_MSG_LINK, "8705 LASI status 0x%x\n", val1); |
| 7435 | |
| 7436 | bnx2x_cl45_read(bp, phy, |
| 7437 | MDIO_PMA_DEVAD, MDIO_PMA_REG_RX_SD, &rx_sd); |
| 7438 | |
| 7439 | bnx2x_cl45_read(bp, phy, |
| 7440 | MDIO_PMA_DEVAD, 0xc809, &val1); |
| 7441 | bnx2x_cl45_read(bp, phy, |
| 7442 | MDIO_PMA_DEVAD, 0xc809, &val1); |
| 7443 | |
| 7444 | DP(NETIF_MSG_LINK, "8705 1.c809 val=0x%x\n", val1); |
| 7445 | link_up = ((rx_sd & 0x1) && (val1 & (1<<9)) && ((val1 & (1<<8)) == 0)); |
| 7446 | if (link_up) { |
| 7447 | vars->line_speed = SPEED_10000; |
| 7448 | bnx2x_ext_phy_resolve_fc(phy, params, vars); |
| 7449 | } |
| 7450 | return link_up; |
| 7451 | } |
| 7452 | |
| 7453 | /******************************************************************/ |
| 7454 | /* SFP+ module Section */ |
| 7455 | /******************************************************************/ |
Yaniv Rosner | 85242ee | 2011-07-05 01:06:53 +0000 | [diff] [blame] | 7456 | static void bnx2x_set_disable_pmd_transmit(struct link_params *params, |
| 7457 | struct bnx2x_phy *phy, |
| 7458 | u8 pmd_dis) |
| 7459 | { |
| 7460 | struct bnx2x *bp = params->bp; |
| 7461 | /* |
| 7462 | * Disable transmitter only for bootcodes which can enable it afterwards |
| 7463 | * (for D3 link) |
| 7464 | */ |
| 7465 | if (pmd_dis) { |
| 7466 | if (params->feature_config_flags & |
| 7467 | FEATURE_CONFIG_BC_SUPPORTS_SFP_TX_DISABLED) |
| 7468 | DP(NETIF_MSG_LINK, "Disabling PMD transmitter\n"); |
| 7469 | else { |
| 7470 | DP(NETIF_MSG_LINK, "NOT disabling PMD transmitter\n"); |
| 7471 | return; |
| 7472 | } |
| 7473 | } else |
| 7474 | DP(NETIF_MSG_LINK, "Enabling PMD transmitter\n"); |
| 7475 | bnx2x_cl45_write(bp, phy, |
| 7476 | MDIO_PMA_DEVAD, |
| 7477 | MDIO_PMA_REG_TX_DISABLE, pmd_dis); |
| 7478 | } |
| 7479 | |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 7480 | static u8 bnx2x_get_gpio_port(struct link_params *params) |
| 7481 | { |
| 7482 | u8 gpio_port; |
| 7483 | u32 swap_val, swap_override; |
| 7484 | struct bnx2x *bp = params->bp; |
| 7485 | if (CHIP_IS_E2(bp)) |
| 7486 | gpio_port = BP_PATH(bp); |
| 7487 | else |
| 7488 | gpio_port = params->port; |
| 7489 | swap_val = REG_RD(bp, NIG_REG_PORT_SWAP); |
| 7490 | swap_override = REG_RD(bp, NIG_REG_STRAP_OVERRIDE); |
| 7491 | return gpio_port ^ (swap_val && swap_override); |
| 7492 | } |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 7493 | |
| 7494 | static void bnx2x_sfp_e1e2_set_transmitter(struct link_params *params, |
| 7495 | struct bnx2x_phy *phy, |
| 7496 | u8 tx_en) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7497 | { |
| 7498 | u16 val; |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 7499 | u8 port = params->port; |
| 7500 | struct bnx2x *bp = params->bp; |
| 7501 | u32 tx_en_mode; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7502 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7503 | /* Disable/Enable transmitter ( TX laser of the SFP+ module.)*/ |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 7504 | tx_en_mode = REG_RD(bp, params->shmem_base + |
| 7505 | offsetof(struct shmem_region, |
| 7506 | dev_info.port_hw_config[port].sfp_ctrl)) & |
| 7507 | PORT_HW_CFG_TX_LASER_MASK; |
| 7508 | DP(NETIF_MSG_LINK, "Setting transmitter tx_en=%x for port %x " |
| 7509 | "mode = %x\n", tx_en, port, tx_en_mode); |
| 7510 | switch (tx_en_mode) { |
| 7511 | case PORT_HW_CFG_TX_LASER_MDIO: |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7512 | |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 7513 | bnx2x_cl45_read(bp, phy, |
| 7514 | MDIO_PMA_DEVAD, |
| 7515 | MDIO_PMA_REG_PHY_IDENTIFIER, |
| 7516 | &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7517 | |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 7518 | if (tx_en) |
| 7519 | val &= ~(1<<15); |
| 7520 | else |
| 7521 | val |= (1<<15); |
| 7522 | |
| 7523 | bnx2x_cl45_write(bp, phy, |
| 7524 | MDIO_PMA_DEVAD, |
| 7525 | MDIO_PMA_REG_PHY_IDENTIFIER, |
| 7526 | val); |
| 7527 | break; |
| 7528 | case PORT_HW_CFG_TX_LASER_GPIO0: |
| 7529 | case PORT_HW_CFG_TX_LASER_GPIO1: |
| 7530 | case PORT_HW_CFG_TX_LASER_GPIO2: |
| 7531 | case PORT_HW_CFG_TX_LASER_GPIO3: |
| 7532 | { |
| 7533 | u16 gpio_pin; |
| 7534 | u8 gpio_port, gpio_mode; |
| 7535 | if (tx_en) |
| 7536 | gpio_mode = MISC_REGISTERS_GPIO_OUTPUT_HIGH; |
| 7537 | else |
| 7538 | gpio_mode = MISC_REGISTERS_GPIO_OUTPUT_LOW; |
| 7539 | |
| 7540 | gpio_pin = tx_en_mode - PORT_HW_CFG_TX_LASER_GPIO0; |
| 7541 | gpio_port = bnx2x_get_gpio_port(params); |
| 7542 | bnx2x_set_gpio(bp, gpio_pin, gpio_mode, gpio_port); |
| 7543 | break; |
| 7544 | } |
| 7545 | default: |
| 7546 | DP(NETIF_MSG_LINK, "Invalid TX_LASER_MDIO 0x%x\n", tx_en_mode); |
| 7547 | break; |
| 7548 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7549 | } |
| 7550 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 7551 | static void bnx2x_sfp_set_transmitter(struct link_params *params, |
| 7552 | struct bnx2x_phy *phy, |
| 7553 | u8 tx_en) |
| 7554 | { |
| 7555 | struct bnx2x *bp = params->bp; |
| 7556 | DP(NETIF_MSG_LINK, "Setting SFP+ transmitter to %d\n", tx_en); |
| 7557 | if (CHIP_IS_E3(bp)) |
| 7558 | bnx2x_sfp_e3_set_transmitter(params, phy, tx_en); |
| 7559 | else |
| 7560 | bnx2x_sfp_e1e2_set_transmitter(params, phy, tx_en); |
| 7561 | } |
| 7562 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 7563 | static int bnx2x_8726_read_sfp_module_eeprom(struct bnx2x_phy *phy, |
| 7564 | struct link_params *params, |
| 7565 | u16 addr, u8 byte_cnt, u8 *o_buf) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7566 | { |
| 7567 | struct bnx2x *bp = params->bp; |
| 7568 | u16 val = 0; |
| 7569 | u16 i; |
| 7570 | if (byte_cnt > 16) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 7571 | DP(NETIF_MSG_LINK, |
| 7572 | "Reading from eeprom is limited to 0xf\n"); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7573 | return -EINVAL; |
| 7574 | } |
| 7575 | /* Set the read command byte count */ |
| 7576 | bnx2x_cl45_write(bp, phy, |
| 7577 | MDIO_PMA_DEVAD, MDIO_PMA_REG_SFP_TWO_WIRE_BYTE_CNT, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7578 | (byte_cnt | 0xa000)); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7579 | |
| 7580 | /* Set the read command address */ |
| 7581 | bnx2x_cl45_write(bp, phy, |
| 7582 | MDIO_PMA_DEVAD, MDIO_PMA_REG_SFP_TWO_WIRE_MEM_ADDR, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7583 | addr); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7584 | |
| 7585 | /* Activate read command */ |
| 7586 | bnx2x_cl45_write(bp, phy, |
| 7587 | MDIO_PMA_DEVAD, MDIO_PMA_REG_SFP_TWO_WIRE_CTRL, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7588 | 0x2c0f); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7589 | |
| 7590 | /* Wait up to 500us for command complete status */ |
| 7591 | for (i = 0; i < 100; i++) { |
| 7592 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7593 | MDIO_PMA_DEVAD, |
| 7594 | MDIO_PMA_REG_SFP_TWO_WIRE_CTRL, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7595 | if ((val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK) == |
| 7596 | MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_COMPLETE) |
| 7597 | break; |
| 7598 | udelay(5); |
| 7599 | } |
| 7600 | |
| 7601 | if ((val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK) != |
| 7602 | MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_COMPLETE) { |
| 7603 | DP(NETIF_MSG_LINK, |
| 7604 | "Got bad status 0x%x when reading from SFP+ EEPROM\n", |
| 7605 | (val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK)); |
| 7606 | return -EINVAL; |
| 7607 | } |
| 7608 | |
| 7609 | /* Read the buffer */ |
| 7610 | for (i = 0; i < byte_cnt; i++) { |
| 7611 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7612 | MDIO_PMA_DEVAD, |
| 7613 | MDIO_PMA_REG_8726_TWO_WIRE_DATA_BUF + i, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7614 | o_buf[i] = (u8)(val & MDIO_PMA_REG_8726_TWO_WIRE_DATA_MASK); |
| 7615 | } |
| 7616 | |
| 7617 | for (i = 0; i < 100; i++) { |
| 7618 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7619 | MDIO_PMA_DEVAD, |
| 7620 | MDIO_PMA_REG_SFP_TWO_WIRE_CTRL, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7621 | if ((val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK) == |
| 7622 | MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_IDLE) |
Joe Perches | 6f38ad9 | 2010-11-14 17:04:31 +0000 | [diff] [blame] | 7623 | return 0; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7624 | msleep(1); |
| 7625 | } |
| 7626 | return -EINVAL; |
| 7627 | } |
| 7628 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 7629 | static int bnx2x_warpcore_read_sfp_module_eeprom(struct bnx2x_phy *phy, |
| 7630 | struct link_params *params, |
| 7631 | u16 addr, u8 byte_cnt, |
| 7632 | u8 *o_buf) |
| 7633 | { |
| 7634 | int rc = 0; |
| 7635 | u8 i, j = 0, cnt = 0; |
| 7636 | u32 data_array[4]; |
| 7637 | u16 addr32; |
| 7638 | struct bnx2x *bp = params->bp; |
| 7639 | /*DP(NETIF_MSG_LINK, "bnx2x_direct_read_sfp_module_eeprom:" |
| 7640 | " addr %d, cnt %d\n", |
| 7641 | addr, byte_cnt);*/ |
| 7642 | if (byte_cnt > 16) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 7643 | DP(NETIF_MSG_LINK, |
| 7644 | "Reading from eeprom is limited to 16 bytes\n"); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 7645 | return -EINVAL; |
| 7646 | } |
| 7647 | |
| 7648 | /* 4 byte aligned address */ |
| 7649 | addr32 = addr & (~0x3); |
| 7650 | do { |
| 7651 | rc = bnx2x_bsc_read(params, phy, 0xa0, addr32, 0, byte_cnt, |
| 7652 | data_array); |
| 7653 | } while ((rc != 0) && (++cnt < I2C_WA_RETRY_CNT)); |
| 7654 | |
| 7655 | if (rc == 0) { |
| 7656 | for (i = (addr - addr32); i < byte_cnt + (addr - addr32); i++) { |
| 7657 | o_buf[j] = *((u8 *)data_array + i); |
| 7658 | j++; |
| 7659 | } |
| 7660 | } |
| 7661 | |
| 7662 | return rc; |
| 7663 | } |
| 7664 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 7665 | static int bnx2x_8727_read_sfp_module_eeprom(struct bnx2x_phy *phy, |
| 7666 | struct link_params *params, |
| 7667 | u16 addr, u8 byte_cnt, u8 *o_buf) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7668 | { |
| 7669 | struct bnx2x *bp = params->bp; |
| 7670 | u16 val, i; |
| 7671 | |
| 7672 | if (byte_cnt > 16) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 7673 | DP(NETIF_MSG_LINK, |
| 7674 | "Reading from eeprom is limited to 0xf\n"); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7675 | return -EINVAL; |
| 7676 | } |
| 7677 | |
| 7678 | /* Need to read from 1.8000 to clear it */ |
| 7679 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7680 | MDIO_PMA_DEVAD, |
| 7681 | MDIO_PMA_REG_SFP_TWO_WIRE_CTRL, |
| 7682 | &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7683 | |
| 7684 | /* Set the read command byte count */ |
| 7685 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7686 | MDIO_PMA_DEVAD, |
| 7687 | MDIO_PMA_REG_SFP_TWO_WIRE_BYTE_CNT, |
| 7688 | ((byte_cnt < 2) ? 2 : byte_cnt)); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7689 | |
| 7690 | /* Set the read command address */ |
| 7691 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7692 | MDIO_PMA_DEVAD, |
| 7693 | MDIO_PMA_REG_SFP_TWO_WIRE_MEM_ADDR, |
| 7694 | addr); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7695 | /* Set the destination address */ |
| 7696 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7697 | MDIO_PMA_DEVAD, |
| 7698 | 0x8004, |
| 7699 | MDIO_PMA_REG_8727_TWO_WIRE_DATA_BUF); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7700 | |
| 7701 | /* Activate read command */ |
| 7702 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7703 | MDIO_PMA_DEVAD, |
| 7704 | MDIO_PMA_REG_SFP_TWO_WIRE_CTRL, |
| 7705 | 0x8002); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7706 | /* |
| 7707 | * Wait appropriate time for two-wire command to finish before |
| 7708 | * polling the status register |
| 7709 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7710 | msleep(1); |
| 7711 | |
| 7712 | /* Wait up to 500us for command complete status */ |
| 7713 | for (i = 0; i < 100; i++) { |
| 7714 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7715 | MDIO_PMA_DEVAD, |
| 7716 | MDIO_PMA_REG_SFP_TWO_WIRE_CTRL, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7717 | if ((val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK) == |
| 7718 | MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_COMPLETE) |
| 7719 | break; |
| 7720 | udelay(5); |
| 7721 | } |
| 7722 | |
| 7723 | if ((val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK) != |
| 7724 | MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_COMPLETE) { |
| 7725 | DP(NETIF_MSG_LINK, |
| 7726 | "Got bad status 0x%x when reading from SFP+ EEPROM\n", |
| 7727 | (val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK)); |
Yaniv Rosner | 65a001b | 2011-01-31 04:22:03 +0000 | [diff] [blame] | 7728 | return -EFAULT; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7729 | } |
| 7730 | |
| 7731 | /* Read the buffer */ |
| 7732 | for (i = 0; i < byte_cnt; i++) { |
| 7733 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7734 | MDIO_PMA_DEVAD, |
| 7735 | MDIO_PMA_REG_8727_TWO_WIRE_DATA_BUF + i, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7736 | o_buf[i] = (u8)(val & MDIO_PMA_REG_8727_TWO_WIRE_DATA_MASK); |
| 7737 | } |
| 7738 | |
| 7739 | for (i = 0; i < 100; i++) { |
| 7740 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7741 | MDIO_PMA_DEVAD, |
| 7742 | MDIO_PMA_REG_SFP_TWO_WIRE_CTRL, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7743 | if ((val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK) == |
| 7744 | MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_IDLE) |
Joe Perches | 6f38ad9 | 2010-11-14 17:04:31 +0000 | [diff] [blame] | 7745 | return 0; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7746 | msleep(1); |
| 7747 | } |
| 7748 | |
| 7749 | return -EINVAL; |
| 7750 | } |
| 7751 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 7752 | int bnx2x_read_sfp_module_eeprom(struct bnx2x_phy *phy, |
| 7753 | struct link_params *params, u16 addr, |
| 7754 | u8 byte_cnt, u8 *o_buf) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7755 | { |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 7756 | int rc = -EINVAL; |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 7757 | switch (phy->type) { |
| 7758 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726: |
| 7759 | rc = bnx2x_8726_read_sfp_module_eeprom(phy, params, addr, |
| 7760 | byte_cnt, o_buf); |
| 7761 | break; |
| 7762 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727: |
| 7763 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8722: |
| 7764 | rc = bnx2x_8727_read_sfp_module_eeprom(phy, params, addr, |
| 7765 | byte_cnt, o_buf); |
| 7766 | break; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 7767 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT: |
| 7768 | rc = bnx2x_warpcore_read_sfp_module_eeprom(phy, params, addr, |
| 7769 | byte_cnt, o_buf); |
| 7770 | break; |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 7771 | } |
| 7772 | return rc; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7773 | } |
| 7774 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 7775 | static int bnx2x_get_edc_mode(struct bnx2x_phy *phy, |
| 7776 | struct link_params *params, |
| 7777 | u16 *edc_mode) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7778 | { |
| 7779 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 7780 | u32 sync_offset = 0, phy_idx, media_types; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7781 | u8 val, check_limiting_mode = 0; |
| 7782 | *edc_mode = EDC_MODE_LIMITING; |
| 7783 | |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 7784 | phy->media_type = ETH_PHY_UNSPECIFIED; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7785 | /* First check for copper cable */ |
| 7786 | if (bnx2x_read_sfp_module_eeprom(phy, |
| 7787 | params, |
| 7788 | SFP_EEPROM_CON_TYPE_ADDR, |
| 7789 | 1, |
| 7790 | &val) != 0) { |
| 7791 | DP(NETIF_MSG_LINK, "Failed to read from SFP+ module EEPROM\n"); |
| 7792 | return -EINVAL; |
| 7793 | } |
| 7794 | |
| 7795 | switch (val) { |
| 7796 | case SFP_EEPROM_CON_TYPE_VAL_COPPER: |
| 7797 | { |
| 7798 | u8 copper_module_type; |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 7799 | phy->media_type = ETH_PHY_DA_TWINAX; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7800 | /* |
| 7801 | * Check if its active cable (includes SFP+ module) |
| 7802 | * of passive cable |
| 7803 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7804 | if (bnx2x_read_sfp_module_eeprom(phy, |
| 7805 | params, |
| 7806 | SFP_EEPROM_FC_TX_TECH_ADDR, |
| 7807 | 1, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 7808 | &copper_module_type) != 0) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7809 | DP(NETIF_MSG_LINK, |
| 7810 | "Failed to read copper-cable-type" |
| 7811 | " from SFP+ EEPROM\n"); |
| 7812 | return -EINVAL; |
| 7813 | } |
| 7814 | |
| 7815 | if (copper_module_type & |
| 7816 | SFP_EEPROM_FC_TX_TECH_BITMASK_COPPER_ACTIVE) { |
| 7817 | DP(NETIF_MSG_LINK, "Active Copper cable detected\n"); |
| 7818 | check_limiting_mode = 1; |
| 7819 | } else if (copper_module_type & |
| 7820 | SFP_EEPROM_FC_TX_TECH_BITMASK_COPPER_PASSIVE) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 7821 | DP(NETIF_MSG_LINK, |
| 7822 | "Passive Copper cable detected\n"); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7823 | *edc_mode = |
| 7824 | EDC_MODE_PASSIVE_DAC; |
| 7825 | } else { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 7826 | DP(NETIF_MSG_LINK, |
| 7827 | "Unknown copper-cable-type 0x%x !!!\n", |
| 7828 | copper_module_type); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7829 | return -EINVAL; |
| 7830 | } |
| 7831 | break; |
| 7832 | } |
| 7833 | case SFP_EEPROM_CON_TYPE_VAL_LC: |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 7834 | phy->media_type = ETH_PHY_SFP_FIBER; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7835 | DP(NETIF_MSG_LINK, "Optic module detected\n"); |
| 7836 | check_limiting_mode = 1; |
| 7837 | break; |
| 7838 | default: |
| 7839 | DP(NETIF_MSG_LINK, "Unable to determine module type 0x%x !!!\n", |
| 7840 | val); |
| 7841 | return -EINVAL; |
| 7842 | } |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 7843 | sync_offset = params->shmem_base + |
| 7844 | offsetof(struct shmem_region, |
| 7845 | dev_info.port_hw_config[params->port].media_type); |
| 7846 | media_types = REG_RD(bp, sync_offset); |
| 7847 | /* Update media type for non-PMF sync */ |
| 7848 | for (phy_idx = INT_PHY; phy_idx < MAX_PHYS; phy_idx++) { |
| 7849 | if (&(params->phy[phy_idx]) == phy) { |
| 7850 | media_types &= ~(PORT_HW_CFG_MEDIA_TYPE_PHY0_MASK << |
| 7851 | (PORT_HW_CFG_MEDIA_TYPE_PHY1_SHIFT * phy_idx)); |
| 7852 | media_types |= ((phy->media_type & |
| 7853 | PORT_HW_CFG_MEDIA_TYPE_PHY0_MASK) << |
| 7854 | (PORT_HW_CFG_MEDIA_TYPE_PHY1_SHIFT * phy_idx)); |
| 7855 | break; |
| 7856 | } |
| 7857 | } |
| 7858 | REG_WR(bp, sync_offset, media_types); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7859 | if (check_limiting_mode) { |
| 7860 | u8 options[SFP_EEPROM_OPTIONS_SIZE]; |
| 7861 | if (bnx2x_read_sfp_module_eeprom(phy, |
| 7862 | params, |
| 7863 | SFP_EEPROM_OPTIONS_ADDR, |
| 7864 | SFP_EEPROM_OPTIONS_SIZE, |
| 7865 | options) != 0) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 7866 | DP(NETIF_MSG_LINK, |
| 7867 | "Failed to read Option field from module EEPROM\n"); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7868 | return -EINVAL; |
| 7869 | } |
| 7870 | if ((options[0] & SFP_EEPROM_OPTIONS_LINEAR_RX_OUT_MASK)) |
| 7871 | *edc_mode = EDC_MODE_LINEAR; |
| 7872 | else |
| 7873 | *edc_mode = EDC_MODE_LIMITING; |
| 7874 | } |
| 7875 | DP(NETIF_MSG_LINK, "EDC mode is set to 0x%x\n", *edc_mode); |
| 7876 | return 0; |
| 7877 | } |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7878 | /* |
| 7879 | * This function read the relevant field from the module (SFP+), and verify it |
| 7880 | * is compliant with this board |
| 7881 | */ |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 7882 | static int bnx2x_verify_sfp_module(struct bnx2x_phy *phy, |
| 7883 | struct link_params *params) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7884 | { |
| 7885 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7886 | u32 val, cmd; |
| 7887 | u32 fw_resp, fw_cmd_param; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7888 | char vendor_name[SFP_EEPROM_VENDOR_NAME_SIZE+1]; |
| 7889 | char vendor_pn[SFP_EEPROM_PART_NO_SIZE+1]; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7890 | phy->flags &= ~FLAGS_SFP_NOT_APPROVED; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7891 | val = REG_RD(bp, params->shmem_base + |
| 7892 | offsetof(struct shmem_region, dev_info. |
| 7893 | port_feature_config[params->port].config)); |
| 7894 | if ((val & PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK) == |
| 7895 | PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_NO_ENFORCEMENT) { |
| 7896 | DP(NETIF_MSG_LINK, "NOT enforcing module verification\n"); |
| 7897 | return 0; |
| 7898 | } |
| 7899 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7900 | if (params->feature_config_flags & |
| 7901 | FEATURE_CONFIG_BC_SUPPORTS_DUAL_PHY_OPT_MDL_VRFY) { |
| 7902 | /* Use specific phy request */ |
| 7903 | cmd = DRV_MSG_CODE_VRFY_SPECIFIC_PHY_OPT_MDL; |
| 7904 | } else if (params->feature_config_flags & |
| 7905 | FEATURE_CONFIG_BC_SUPPORTS_OPT_MDL_VRFY) { |
| 7906 | /* Use first phy request only in case of non-dual media*/ |
| 7907 | if (DUAL_MEDIA(params)) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 7908 | DP(NETIF_MSG_LINK, |
| 7909 | "FW does not support OPT MDL verification\n"); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7910 | return -EINVAL; |
| 7911 | } |
| 7912 | cmd = DRV_MSG_CODE_VRFY_FIRST_PHY_OPT_MDL; |
| 7913 | } else { |
| 7914 | /* No support in OPT MDL detection */ |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 7915 | DP(NETIF_MSG_LINK, |
| 7916 | "FW does not support OPT MDL verification\n"); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7917 | return -EINVAL; |
| 7918 | } |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 7919 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7920 | fw_cmd_param = FW_PARAM_SET(phy->addr, phy->type, phy->mdio_ctrl); |
| 7921 | fw_resp = bnx2x_fw_command(bp, cmd, fw_cmd_param); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7922 | if (fw_resp == FW_MSG_CODE_VRFY_OPT_MDL_SUCCESS) { |
| 7923 | DP(NETIF_MSG_LINK, "Approved module\n"); |
| 7924 | return 0; |
| 7925 | } |
| 7926 | |
| 7927 | /* format the warning message */ |
| 7928 | if (bnx2x_read_sfp_module_eeprom(phy, |
| 7929 | params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7930 | SFP_EEPROM_VENDOR_NAME_ADDR, |
| 7931 | SFP_EEPROM_VENDOR_NAME_SIZE, |
| 7932 | (u8 *)vendor_name)) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7933 | vendor_name[0] = '\0'; |
| 7934 | else |
| 7935 | vendor_name[SFP_EEPROM_VENDOR_NAME_SIZE] = '\0'; |
| 7936 | if (bnx2x_read_sfp_module_eeprom(phy, |
| 7937 | params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7938 | SFP_EEPROM_PART_NO_ADDR, |
| 7939 | SFP_EEPROM_PART_NO_SIZE, |
| 7940 | (u8 *)vendor_pn)) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7941 | vendor_pn[0] = '\0'; |
| 7942 | else |
| 7943 | vendor_pn[SFP_EEPROM_PART_NO_SIZE] = '\0'; |
| 7944 | |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 7945 | netdev_err(bp->dev, "Warning: Unqualified SFP+ module detected," |
| 7946 | " Port %d from %s part number %s\n", |
| 7947 | params->port, vendor_name, vendor_pn); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7948 | phy->flags |= FLAGS_SFP_NOT_APPROVED; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7949 | return -EINVAL; |
| 7950 | } |
| 7951 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 7952 | static int bnx2x_wait_for_sfp_module_initialized(struct bnx2x_phy *phy, |
| 7953 | struct link_params *params) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7954 | |
| 7955 | { |
| 7956 | u8 val; |
| 7957 | struct bnx2x *bp = params->bp; |
| 7958 | u16 timeout; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7959 | /* |
| 7960 | * Initialization time after hot-plug may take up to 300ms for |
| 7961 | * some phys type ( e.g. JDSU ) |
| 7962 | */ |
| 7963 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7964 | for (timeout = 0; timeout < 60; timeout++) { |
| 7965 | if (bnx2x_read_sfp_module_eeprom(phy, params, 1, 1, &val) |
| 7966 | == 0) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 7967 | DP(NETIF_MSG_LINK, |
| 7968 | "SFP+ module initialization took %d ms\n", |
| 7969 | timeout * 5); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7970 | return 0; |
| 7971 | } |
| 7972 | msleep(5); |
| 7973 | } |
| 7974 | return -EINVAL; |
| 7975 | } |
| 7976 | |
| 7977 | static void bnx2x_8727_power_module(struct bnx2x *bp, |
| 7978 | struct bnx2x_phy *phy, |
| 7979 | u8 is_power_up) { |
| 7980 | /* Make sure GPIOs are not using for LED mode */ |
| 7981 | u16 val; |
| 7982 | /* |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7983 | * 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] | 7984 | * operating as INPUT or as OUTPUT. Bit 1 is for input, and 0 for |
| 7985 | * output |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 7986 | * Bits 0-1 determine the GPIOs value for OUTPUT in case bit 4 val is 0 |
| 7987 | * 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] | 7988 | * where the 1st bit is the over-current(only input), and 2nd bit is |
| 7989 | * for power( only output ) |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7990 | * |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7991 | * In case of NOC feature is disabled and power is up, set GPIO control |
| 7992 | * as input to enable listening of over-current indication |
| 7993 | */ |
| 7994 | if (phy->flags & FLAGS_NOC) |
| 7995 | return; |
Yaniv Rosner | 27d0243 | 2011-05-31 21:27:48 +0000 | [diff] [blame] | 7996 | if (is_power_up) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7997 | val = (1<<4); |
| 7998 | else |
| 7999 | /* |
| 8000 | * Set GPIO control to OUTPUT, and set the power bit |
| 8001 | * to according to the is_power_up |
| 8002 | */ |
Yaniv Rosner | 27d0243 | 2011-05-31 21:27:48 +0000 | [diff] [blame] | 8003 | val = (1<<1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8004 | |
| 8005 | bnx2x_cl45_write(bp, phy, |
| 8006 | MDIO_PMA_DEVAD, |
| 8007 | MDIO_PMA_REG_8727_GPIO_CTRL, |
| 8008 | val); |
| 8009 | } |
| 8010 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 8011 | static int bnx2x_8726_set_limiting_mode(struct bnx2x *bp, |
| 8012 | struct bnx2x_phy *phy, |
| 8013 | u16 edc_mode) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8014 | { |
| 8015 | u16 cur_limiting_mode; |
| 8016 | |
| 8017 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8018 | MDIO_PMA_DEVAD, |
| 8019 | MDIO_PMA_REG_ROM_VER2, |
| 8020 | &cur_limiting_mode); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8021 | DP(NETIF_MSG_LINK, "Current Limiting mode is 0x%x\n", |
| 8022 | cur_limiting_mode); |
| 8023 | |
| 8024 | if (edc_mode == EDC_MODE_LIMITING) { |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8025 | DP(NETIF_MSG_LINK, "Setting LIMITING MODE\n"); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8026 | bnx2x_cl45_write(bp, phy, |
| 8027 | MDIO_PMA_DEVAD, |
| 8028 | MDIO_PMA_REG_ROM_VER2, |
| 8029 | EDC_MODE_LIMITING); |
| 8030 | } else { /* LRM mode ( default )*/ |
| 8031 | |
| 8032 | DP(NETIF_MSG_LINK, "Setting LRM MODE\n"); |
| 8033 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8034 | /* |
| 8035 | * Changing to LRM mode takes quite few seconds. So do it only |
| 8036 | * if current mode is limiting (default is LRM) |
| 8037 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8038 | if (cur_limiting_mode != EDC_MODE_LIMITING) |
| 8039 | return 0; |
| 8040 | |
| 8041 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8042 | MDIO_PMA_DEVAD, |
| 8043 | MDIO_PMA_REG_LRM_MODE, |
| 8044 | 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8045 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8046 | MDIO_PMA_DEVAD, |
| 8047 | MDIO_PMA_REG_ROM_VER2, |
| 8048 | 0x128); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8049 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8050 | MDIO_PMA_DEVAD, |
| 8051 | MDIO_PMA_REG_MISC_CTRL0, |
| 8052 | 0x4008); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8053 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8054 | MDIO_PMA_DEVAD, |
| 8055 | MDIO_PMA_REG_LRM_MODE, |
| 8056 | 0xaaaa); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8057 | } |
| 8058 | return 0; |
| 8059 | } |
| 8060 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 8061 | static int bnx2x_8727_set_limiting_mode(struct bnx2x *bp, |
| 8062 | struct bnx2x_phy *phy, |
| 8063 | u16 edc_mode) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8064 | { |
| 8065 | u16 phy_identifier; |
| 8066 | u16 rom_ver2_val; |
| 8067 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8068 | MDIO_PMA_DEVAD, |
| 8069 | MDIO_PMA_REG_PHY_IDENTIFIER, |
| 8070 | &phy_identifier); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8071 | |
| 8072 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8073 | MDIO_PMA_DEVAD, |
| 8074 | MDIO_PMA_REG_PHY_IDENTIFIER, |
| 8075 | (phy_identifier & ~(1<<9))); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8076 | |
| 8077 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8078 | MDIO_PMA_DEVAD, |
| 8079 | MDIO_PMA_REG_ROM_VER2, |
| 8080 | &rom_ver2_val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8081 | /* Keep the MSB 8-bits, and set the LSB 8-bits with the edc_mode */ |
| 8082 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8083 | MDIO_PMA_DEVAD, |
| 8084 | MDIO_PMA_REG_ROM_VER2, |
| 8085 | (rom_ver2_val & 0xff00) | (edc_mode & 0x00ff)); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8086 | |
| 8087 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8088 | MDIO_PMA_DEVAD, |
| 8089 | MDIO_PMA_REG_PHY_IDENTIFIER, |
| 8090 | (phy_identifier | (1<<9))); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8091 | |
| 8092 | return 0; |
| 8093 | } |
| 8094 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8095 | static void bnx2x_8727_specific_func(struct bnx2x_phy *phy, |
| 8096 | struct link_params *params, |
| 8097 | u32 action) |
| 8098 | { |
| 8099 | struct bnx2x *bp = params->bp; |
| 8100 | |
| 8101 | switch (action) { |
| 8102 | case DISABLE_TX: |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8103 | bnx2x_sfp_set_transmitter(params, phy, 0); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8104 | break; |
| 8105 | case ENABLE_TX: |
| 8106 | if (!(phy->flags & FLAGS_SFP_NOT_APPROVED)) |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8107 | bnx2x_sfp_set_transmitter(params, phy, 1); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8108 | break; |
| 8109 | default: |
| 8110 | DP(NETIF_MSG_LINK, "Function 0x%x not supported by 8727\n", |
| 8111 | action); |
| 8112 | return; |
| 8113 | } |
| 8114 | } |
| 8115 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8116 | static void bnx2x_set_e1e2_module_fault_led(struct link_params *params, |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8117 | u8 gpio_mode) |
| 8118 | { |
| 8119 | struct bnx2x *bp = params->bp; |
| 8120 | |
| 8121 | u32 fault_led_gpio = REG_RD(bp, params->shmem_base + |
| 8122 | offsetof(struct shmem_region, |
| 8123 | dev_info.port_hw_config[params->port].sfp_ctrl)) & |
| 8124 | PORT_HW_CFG_FAULT_MODULE_LED_MASK; |
| 8125 | switch (fault_led_gpio) { |
| 8126 | case PORT_HW_CFG_FAULT_MODULE_LED_DISABLED: |
| 8127 | return; |
| 8128 | case PORT_HW_CFG_FAULT_MODULE_LED_GPIO0: |
| 8129 | case PORT_HW_CFG_FAULT_MODULE_LED_GPIO1: |
| 8130 | case PORT_HW_CFG_FAULT_MODULE_LED_GPIO2: |
| 8131 | case PORT_HW_CFG_FAULT_MODULE_LED_GPIO3: |
| 8132 | { |
| 8133 | u8 gpio_port = bnx2x_get_gpio_port(params); |
| 8134 | u16 gpio_pin = fault_led_gpio - |
| 8135 | PORT_HW_CFG_FAULT_MODULE_LED_GPIO0; |
| 8136 | DP(NETIF_MSG_LINK, "Set fault module-detected led " |
| 8137 | "pin %x port %x mode %x\n", |
| 8138 | gpio_pin, gpio_port, gpio_mode); |
| 8139 | bnx2x_set_gpio(bp, gpio_pin, gpio_mode, gpio_port); |
| 8140 | } |
| 8141 | break; |
| 8142 | default: |
| 8143 | DP(NETIF_MSG_LINK, "Error: Invalid fault led mode 0x%x\n", |
| 8144 | fault_led_gpio); |
| 8145 | } |
| 8146 | } |
| 8147 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8148 | static void bnx2x_set_e3_module_fault_led(struct link_params *params, |
| 8149 | u8 gpio_mode) |
| 8150 | { |
| 8151 | u32 pin_cfg; |
| 8152 | u8 port = params->port; |
| 8153 | struct bnx2x *bp = params->bp; |
| 8154 | pin_cfg = (REG_RD(bp, params->shmem_base + |
| 8155 | offsetof(struct shmem_region, |
| 8156 | dev_info.port_hw_config[port].e3_sfp_ctrl)) & |
| 8157 | PORT_HW_CFG_E3_FAULT_MDL_LED_MASK) >> |
| 8158 | PORT_HW_CFG_E3_FAULT_MDL_LED_SHIFT; |
| 8159 | DP(NETIF_MSG_LINK, "Setting Fault LED to %d using pin cfg %d\n", |
| 8160 | gpio_mode, pin_cfg); |
| 8161 | bnx2x_set_cfg_pin(bp, pin_cfg, gpio_mode); |
| 8162 | } |
| 8163 | |
| 8164 | static void bnx2x_set_sfp_module_fault_led(struct link_params *params, |
| 8165 | u8 gpio_mode) |
| 8166 | { |
| 8167 | struct bnx2x *bp = params->bp; |
| 8168 | DP(NETIF_MSG_LINK, "Setting SFP+ module fault LED to %d\n", gpio_mode); |
| 8169 | if (CHIP_IS_E3(bp)) { |
| 8170 | /* |
| 8171 | * Low ==> if SFP+ module is supported otherwise |
| 8172 | * High ==> if SFP+ module is not on the approved vendor list |
| 8173 | */ |
| 8174 | bnx2x_set_e3_module_fault_led(params, gpio_mode); |
| 8175 | } else |
| 8176 | bnx2x_set_e1e2_module_fault_led(params, gpio_mode); |
| 8177 | } |
| 8178 | |
| 8179 | static void bnx2x_warpcore_power_module(struct link_params *params, |
| 8180 | struct bnx2x_phy *phy, |
| 8181 | u8 power) |
| 8182 | { |
| 8183 | u32 pin_cfg; |
| 8184 | struct bnx2x *bp = params->bp; |
| 8185 | |
| 8186 | pin_cfg = (REG_RD(bp, params->shmem_base + |
| 8187 | offsetof(struct shmem_region, |
| 8188 | dev_info.port_hw_config[params->port].e3_sfp_ctrl)) & |
| 8189 | PORT_HW_CFG_E3_PWR_DIS_MASK) >> |
| 8190 | PORT_HW_CFG_E3_PWR_DIS_SHIFT; |
Yaniv Rosner | 985848f | 2011-07-05 01:06:48 +0000 | [diff] [blame] | 8191 | |
| 8192 | if (pin_cfg == PIN_CFG_NA) |
| 8193 | return; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8194 | DP(NETIF_MSG_LINK, "Setting SFP+ module power to %d using pin cfg %d\n", |
| 8195 | power, pin_cfg); |
| 8196 | /* |
| 8197 | * Low ==> corresponding SFP+ module is powered |
| 8198 | * high ==> the SFP+ module is powered down |
| 8199 | */ |
| 8200 | bnx2x_set_cfg_pin(bp, pin_cfg, power ^ 1); |
| 8201 | } |
| 8202 | |
Yaniv Rosner | 985848f | 2011-07-05 01:06:48 +0000 | [diff] [blame] | 8203 | static void bnx2x_warpcore_hw_reset(struct bnx2x_phy *phy, |
| 8204 | struct link_params *params) |
| 8205 | { |
| 8206 | bnx2x_warpcore_power_module(params, phy, 0); |
| 8207 | } |
| 8208 | |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 8209 | static void bnx2x_power_sfp_module(struct link_params *params, |
| 8210 | struct bnx2x_phy *phy, |
| 8211 | u8 power) |
| 8212 | { |
| 8213 | struct bnx2x *bp = params->bp; |
| 8214 | DP(NETIF_MSG_LINK, "Setting SFP+ power to %x\n", power); |
| 8215 | |
| 8216 | switch (phy->type) { |
| 8217 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727: |
| 8218 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8722: |
| 8219 | bnx2x_8727_power_module(params->bp, phy, power); |
| 8220 | break; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8221 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT: |
| 8222 | bnx2x_warpcore_power_module(params, phy, power); |
| 8223 | break; |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 8224 | default: |
| 8225 | break; |
| 8226 | } |
| 8227 | } |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8228 | static void bnx2x_warpcore_set_limiting_mode(struct link_params *params, |
| 8229 | struct bnx2x_phy *phy, |
| 8230 | u16 edc_mode) |
| 8231 | { |
| 8232 | u16 val = 0; |
| 8233 | u16 mode = MDIO_WC_REG_UC_INFO_B1_FIRMWARE_MODE_DEFAULT; |
| 8234 | struct bnx2x *bp = params->bp; |
| 8235 | |
| 8236 | u8 lane = bnx2x_get_warpcore_lane(phy, params); |
| 8237 | /* This is a global register which controls all lanes */ |
| 8238 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 8239 | MDIO_WC_REG_UC_INFO_B1_FIRMWARE_MODE, &val); |
| 8240 | val &= ~(0xf << (lane << 2)); |
| 8241 | |
| 8242 | switch (edc_mode) { |
| 8243 | case EDC_MODE_LINEAR: |
| 8244 | case EDC_MODE_LIMITING: |
| 8245 | mode = MDIO_WC_REG_UC_INFO_B1_FIRMWARE_MODE_DEFAULT; |
| 8246 | break; |
| 8247 | case EDC_MODE_PASSIVE_DAC: |
| 8248 | mode = MDIO_WC_REG_UC_INFO_B1_FIRMWARE_MODE_SFP_DAC; |
| 8249 | break; |
| 8250 | default: |
| 8251 | break; |
| 8252 | } |
| 8253 | |
| 8254 | val |= (mode << (lane << 2)); |
| 8255 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 8256 | MDIO_WC_REG_UC_INFO_B1_FIRMWARE_MODE, val); |
| 8257 | /* A must read */ |
| 8258 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 8259 | MDIO_WC_REG_UC_INFO_B1_FIRMWARE_MODE, &val); |
| 8260 | |
Yaniv Rosner | 19af03a | 2011-08-02 22:59:47 +0000 | [diff] [blame] | 8261 | /* Restart microcode to re-read the new mode */ |
| 8262 | bnx2x_warpcore_reset_lane(bp, phy, 1); |
| 8263 | bnx2x_warpcore_reset_lane(bp, phy, 0); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8264 | |
| 8265 | } |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 8266 | |
| 8267 | static void bnx2x_set_limiting_mode(struct link_params *params, |
| 8268 | struct bnx2x_phy *phy, |
| 8269 | u16 edc_mode) |
| 8270 | { |
| 8271 | switch (phy->type) { |
| 8272 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726: |
| 8273 | bnx2x_8726_set_limiting_mode(params->bp, phy, edc_mode); |
| 8274 | break; |
| 8275 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727: |
| 8276 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8722: |
| 8277 | bnx2x_8727_set_limiting_mode(params->bp, phy, edc_mode); |
| 8278 | break; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8279 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT: |
| 8280 | bnx2x_warpcore_set_limiting_mode(params, phy, edc_mode); |
| 8281 | break; |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 8282 | } |
| 8283 | } |
| 8284 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 8285 | int bnx2x_sfp_module_detection(struct bnx2x_phy *phy, |
| 8286 | struct link_params *params) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8287 | { |
| 8288 | struct bnx2x *bp = params->bp; |
| 8289 | u16 edc_mode; |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 8290 | int rc = 0; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8291 | |
| 8292 | u32 val = REG_RD(bp, params->shmem_base + |
| 8293 | offsetof(struct shmem_region, dev_info. |
| 8294 | port_feature_config[params->port].config)); |
| 8295 | |
| 8296 | DP(NETIF_MSG_LINK, "SFP+ module plugged in/out detected on port %d\n", |
| 8297 | params->port); |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 8298 | /* Power up module */ |
| 8299 | bnx2x_power_sfp_module(params, phy, 1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8300 | if (bnx2x_get_edc_mode(phy, params, &edc_mode) != 0) { |
| 8301 | DP(NETIF_MSG_LINK, "Failed to get valid module type\n"); |
| 8302 | return -EINVAL; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8303 | } else if (bnx2x_verify_sfp_module(phy, params) != 0) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8304 | /* check SFP+ module compatibility */ |
| 8305 | DP(NETIF_MSG_LINK, "Module verification failed!!\n"); |
| 8306 | rc = -EINVAL; |
| 8307 | /* Turn on fault module-detected led */ |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8308 | bnx2x_set_sfp_module_fault_led(params, |
| 8309 | MISC_REGISTERS_GPIO_HIGH); |
| 8310 | |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 8311 | /* Check if need to power down the SFP+ module */ |
| 8312 | if ((val & PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK) == |
| 8313 | PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_POWER_DOWN) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8314 | DP(NETIF_MSG_LINK, "Shutdown SFP+ module!!\n"); |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 8315 | bnx2x_power_sfp_module(params, phy, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8316 | return rc; |
| 8317 | } |
| 8318 | } else { |
| 8319 | /* Turn off fault module-detected led */ |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8320 | bnx2x_set_sfp_module_fault_led(params, MISC_REGISTERS_GPIO_LOW); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8321 | } |
| 8322 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8323 | /* |
| 8324 | * Check and set limiting mode / LRM mode on 8726. On 8727 it |
| 8325 | * is done automatically |
| 8326 | */ |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 8327 | bnx2x_set_limiting_mode(params, phy, edc_mode); |
| 8328 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8329 | /* |
| 8330 | * Enable transmit for this module if the module is approved, or |
| 8331 | * if unapproved modules should also enable the Tx laser |
| 8332 | */ |
| 8333 | if (rc == 0 || |
| 8334 | (val & PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK) != |
| 8335 | PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_DISABLE_TX_LASER) |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8336 | bnx2x_sfp_set_transmitter(params, phy, 1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8337 | else |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8338 | bnx2x_sfp_set_transmitter(params, phy, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8339 | |
| 8340 | return rc; |
| 8341 | } |
| 8342 | |
| 8343 | void bnx2x_handle_module_detect_int(struct link_params *params) |
| 8344 | { |
| 8345 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8346 | struct bnx2x_phy *phy; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8347 | u32 gpio_val; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8348 | u8 gpio_num, gpio_port; |
| 8349 | if (CHIP_IS_E3(bp)) |
| 8350 | phy = ¶ms->phy[INT_PHY]; |
| 8351 | else |
| 8352 | phy = ¶ms->phy[EXT_PHY1]; |
| 8353 | |
| 8354 | if (bnx2x_get_mod_abs_int_cfg(bp, params->chip_id, params->shmem_base, |
| 8355 | params->port, &gpio_num, &gpio_port) == |
| 8356 | -EINVAL) { |
| 8357 | DP(NETIF_MSG_LINK, "Failed to get MOD_ABS interrupt config\n"); |
| 8358 | return; |
| 8359 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8360 | |
| 8361 | /* Set valid module led off */ |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8362 | bnx2x_set_sfp_module_fault_led(params, MISC_REGISTERS_GPIO_HIGH); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8363 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8364 | /* Get current gpio val reflecting module plugged in / out*/ |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8365 | gpio_val = bnx2x_get_gpio(bp, gpio_num, gpio_port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8366 | |
| 8367 | /* Call the handling function in case module is detected */ |
| 8368 | if (gpio_val == 0) { |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 8369 | bnx2x_power_sfp_module(params, phy, 1); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8370 | bnx2x_set_gpio_int(bp, gpio_num, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8371 | MISC_REGISTERS_GPIO_INT_OUTPUT_CLR, |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8372 | gpio_port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8373 | if (bnx2x_wait_for_sfp_module_initialized(phy, params) == 0) |
| 8374 | bnx2x_sfp_module_detection(phy, params); |
| 8375 | else |
| 8376 | DP(NETIF_MSG_LINK, "SFP+ module is not initialized\n"); |
| 8377 | } else { |
| 8378 | u32 val = REG_RD(bp, params->shmem_base + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8379 | offsetof(struct shmem_region, dev_info. |
| 8380 | port_feature_config[params->port]. |
| 8381 | config)); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8382 | bnx2x_set_gpio_int(bp, gpio_num, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8383 | MISC_REGISTERS_GPIO_INT_OUTPUT_SET, |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8384 | gpio_port); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8385 | /* |
| 8386 | * Module was plugged out. |
| 8387 | * Disable transmit for this module |
| 8388 | */ |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 8389 | phy->media_type = ETH_PHY_NOT_PRESENT; |
Yaniv Rosner | de6f337 | 2011-08-02 22:59:25 +0000 | [diff] [blame] | 8390 | if (((val & PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK) == |
| 8391 | PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_DISABLE_TX_LASER) || |
| 8392 | CHIP_IS_E3(bp)) |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8393 | bnx2x_sfp_set_transmitter(params, phy, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8394 | } |
| 8395 | } |
| 8396 | |
| 8397 | /******************************************************************/ |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 8398 | /* Used by 8706 and 8727 */ |
| 8399 | /******************************************************************/ |
| 8400 | static void bnx2x_sfp_mask_fault(struct bnx2x *bp, |
| 8401 | struct bnx2x_phy *phy, |
| 8402 | u16 alarm_status_offset, |
| 8403 | u16 alarm_ctrl_offset) |
| 8404 | { |
| 8405 | u16 alarm_status, val; |
| 8406 | bnx2x_cl45_read(bp, phy, |
| 8407 | MDIO_PMA_DEVAD, alarm_status_offset, |
| 8408 | &alarm_status); |
| 8409 | bnx2x_cl45_read(bp, phy, |
| 8410 | MDIO_PMA_DEVAD, alarm_status_offset, |
| 8411 | &alarm_status); |
| 8412 | /* Mask or enable the fault event. */ |
| 8413 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, alarm_ctrl_offset, &val); |
| 8414 | if (alarm_status & (1<<0)) |
| 8415 | val &= ~(1<<0); |
| 8416 | else |
| 8417 | val |= (1<<0); |
| 8418 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, alarm_ctrl_offset, val); |
| 8419 | } |
| 8420 | /******************************************************************/ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8421 | /* common BCM8706/BCM8726 PHY SECTION */ |
| 8422 | /******************************************************************/ |
| 8423 | static u8 bnx2x_8706_8726_read_status(struct bnx2x_phy *phy, |
| 8424 | struct link_params *params, |
| 8425 | struct link_vars *vars) |
| 8426 | { |
| 8427 | u8 link_up = 0; |
| 8428 | u16 val1, val2, rx_sd, pcs_status; |
| 8429 | struct bnx2x *bp = params->bp; |
| 8430 | DP(NETIF_MSG_LINK, "XGXS 8706/8726\n"); |
| 8431 | /* Clear RX Alarm*/ |
| 8432 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8433 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_RXSTAT, &val2); |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 8434 | |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8435 | bnx2x_sfp_mask_fault(bp, phy, MDIO_PMA_LASI_TXSTAT, |
| 8436 | MDIO_PMA_LASI_TXCTRL); |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 8437 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8438 | /* clear LASI indication*/ |
| 8439 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8440 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_STAT, &val1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8441 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8442 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_STAT, &val2); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8443 | DP(NETIF_MSG_LINK, "8706/8726 LASI status 0x%x--> 0x%x\n", val1, val2); |
| 8444 | |
| 8445 | bnx2x_cl45_read(bp, phy, |
| 8446 | MDIO_PMA_DEVAD, MDIO_PMA_REG_RX_SD, &rx_sd); |
| 8447 | bnx2x_cl45_read(bp, phy, |
| 8448 | MDIO_PCS_DEVAD, MDIO_PCS_REG_STATUS, &pcs_status); |
| 8449 | bnx2x_cl45_read(bp, phy, |
| 8450 | MDIO_AN_DEVAD, MDIO_AN_REG_LINK_STATUS, &val2); |
| 8451 | bnx2x_cl45_read(bp, phy, |
| 8452 | MDIO_AN_DEVAD, MDIO_AN_REG_LINK_STATUS, &val2); |
| 8453 | |
| 8454 | DP(NETIF_MSG_LINK, "8706/8726 rx_sd 0x%x pcs_status 0x%x 1Gbps" |
| 8455 | " link_status 0x%x\n", rx_sd, pcs_status, val2); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8456 | /* |
| 8457 | * link is up if both bit 0 of pmd_rx_sd and bit 0 of pcs_status |
| 8458 | * are set, or if the autoneg bit 1 is set |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8459 | */ |
| 8460 | link_up = ((rx_sd & pcs_status & 0x1) || (val2 & (1<<1))); |
| 8461 | if (link_up) { |
| 8462 | if (val2 & (1<<1)) |
| 8463 | vars->line_speed = SPEED_1000; |
| 8464 | else |
| 8465 | vars->line_speed = SPEED_10000; |
| 8466 | bnx2x_ext_phy_resolve_fc(phy, params, vars); |
Yaniv Rosner | 791f18c | 2011-01-18 04:33:42 +0000 | [diff] [blame] | 8467 | vars->duplex = DUPLEX_FULL; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8468 | } |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 8469 | |
| 8470 | /* Capture 10G link fault. Read twice to clear stale value. */ |
| 8471 | if (vars->line_speed == SPEED_10000) { |
| 8472 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8473 | MDIO_PMA_LASI_TXSTAT, &val1); |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 8474 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8475 | MDIO_PMA_LASI_TXSTAT, &val1); |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 8476 | if (val1 & (1<<0)) |
| 8477 | vars->fault_detected = 1; |
| 8478 | } |
| 8479 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8480 | return link_up; |
| 8481 | } |
| 8482 | |
| 8483 | /******************************************************************/ |
| 8484 | /* BCM8706 PHY SECTION */ |
| 8485 | /******************************************************************/ |
| 8486 | static u8 bnx2x_8706_config_init(struct bnx2x_phy *phy, |
| 8487 | struct link_params *params, |
| 8488 | struct link_vars *vars) |
| 8489 | { |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8490 | u32 tx_en_mode; |
| 8491 | u16 cnt, val, tmp1; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8492 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 8493 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8494 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8495 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, params->port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8496 | /* HW reset */ |
| 8497 | bnx2x_ext_phy_hw_reset(bp, params->port); |
| 8498 | 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] | 8499 | bnx2x_wait_reset_complete(bp, phy, params); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8500 | |
| 8501 | /* Wait until fw is loaded */ |
| 8502 | for (cnt = 0; cnt < 100; cnt++) { |
| 8503 | bnx2x_cl45_read(bp, phy, |
| 8504 | MDIO_PMA_DEVAD, MDIO_PMA_REG_ROM_VER1, &val); |
| 8505 | if (val) |
| 8506 | break; |
| 8507 | msleep(10); |
| 8508 | } |
| 8509 | DP(NETIF_MSG_LINK, "XGXS 8706 is initialized after %d ms\n", cnt); |
| 8510 | if ((params->feature_config_flags & |
| 8511 | FEATURE_CONFIG_OVERRIDE_PREEMPHASIS_ENABLED)) { |
| 8512 | u8 i; |
| 8513 | u16 reg; |
| 8514 | for (i = 0; i < 4; i++) { |
| 8515 | reg = MDIO_XS_8706_REG_BANK_RX0 + |
| 8516 | i*(MDIO_XS_8706_REG_BANK_RX1 - |
| 8517 | MDIO_XS_8706_REG_BANK_RX0); |
| 8518 | bnx2x_cl45_read(bp, phy, MDIO_XS_DEVAD, reg, &val); |
| 8519 | /* Clear first 3 bits of the control */ |
| 8520 | val &= ~0x7; |
| 8521 | /* Set control bits according to configuration */ |
| 8522 | val |= (phy->rx_preemphasis[i] & 0x7); |
| 8523 | DP(NETIF_MSG_LINK, "Setting RX Equalizer to BCM8706" |
| 8524 | " reg 0x%x <-- val 0x%x\n", reg, val); |
| 8525 | bnx2x_cl45_write(bp, phy, MDIO_XS_DEVAD, reg, val); |
| 8526 | } |
| 8527 | } |
| 8528 | /* Force speed */ |
| 8529 | if (phy->req_line_speed == SPEED_10000) { |
| 8530 | DP(NETIF_MSG_LINK, "XGXS 8706 force 10Gbps\n"); |
| 8531 | |
| 8532 | bnx2x_cl45_write(bp, phy, |
| 8533 | MDIO_PMA_DEVAD, |
| 8534 | MDIO_PMA_REG_DIGITAL_CTRL, 0x400); |
| 8535 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8536 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_TXCTRL, |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 8537 | 0); |
| 8538 | /* Arm LASI for link and Tx fault. */ |
| 8539 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8540 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_CTRL, 3); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8541 | } else { |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 8542 | /* Force 1Gbps using autoneg with 1G advertisement */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8543 | |
| 8544 | /* Allow CL37 through CL73 */ |
| 8545 | DP(NETIF_MSG_LINK, "XGXS 8706 AutoNeg\n"); |
| 8546 | bnx2x_cl45_write(bp, phy, |
| 8547 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_CL73, 0x040c); |
| 8548 | |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 8549 | /* Enable Full-Duplex advertisement on CL37 */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8550 | bnx2x_cl45_write(bp, phy, |
| 8551 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_FC_LP, 0x0020); |
| 8552 | /* Enable CL37 AN */ |
| 8553 | bnx2x_cl45_write(bp, phy, |
| 8554 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_AN, 0x1000); |
| 8555 | /* 1G support */ |
| 8556 | bnx2x_cl45_write(bp, phy, |
| 8557 | MDIO_AN_DEVAD, MDIO_AN_REG_ADV, (1<<5)); |
| 8558 | |
| 8559 | /* Enable clause 73 AN */ |
| 8560 | bnx2x_cl45_write(bp, phy, |
| 8561 | MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, 0x1200); |
| 8562 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8563 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_RXCTRL, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8564 | 0x0400); |
| 8565 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8566 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_CTRL, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8567 | 0x0004); |
| 8568 | } |
| 8569 | bnx2x_save_bcm_spirom_ver(bp, phy, params->port); |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8570 | |
| 8571 | /* |
| 8572 | * If TX Laser is controlled by GPIO_0, do not let PHY go into low |
| 8573 | * power mode, if TX Laser is disabled |
| 8574 | */ |
| 8575 | |
| 8576 | tx_en_mode = REG_RD(bp, params->shmem_base + |
| 8577 | offsetof(struct shmem_region, |
| 8578 | dev_info.port_hw_config[params->port].sfp_ctrl)) |
| 8579 | & PORT_HW_CFG_TX_LASER_MASK; |
| 8580 | |
| 8581 | if (tx_en_mode == PORT_HW_CFG_TX_LASER_GPIO0) { |
| 8582 | DP(NETIF_MSG_LINK, "Enabling TXONOFF_PWRDN_DIS\n"); |
| 8583 | bnx2x_cl45_read(bp, phy, |
| 8584 | MDIO_PMA_DEVAD, MDIO_PMA_REG_DIGITAL_CTRL, &tmp1); |
| 8585 | tmp1 |= 0x1; |
| 8586 | bnx2x_cl45_write(bp, phy, |
| 8587 | MDIO_PMA_DEVAD, MDIO_PMA_REG_DIGITAL_CTRL, tmp1); |
| 8588 | } |
| 8589 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8590 | return 0; |
| 8591 | } |
| 8592 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 8593 | static int bnx2x_8706_read_status(struct bnx2x_phy *phy, |
| 8594 | struct link_params *params, |
| 8595 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8596 | { |
| 8597 | return bnx2x_8706_8726_read_status(phy, params, vars); |
| 8598 | } |
| 8599 | |
| 8600 | /******************************************************************/ |
| 8601 | /* BCM8726 PHY SECTION */ |
| 8602 | /******************************************************************/ |
| 8603 | static void bnx2x_8726_config_loopback(struct bnx2x_phy *phy, |
| 8604 | struct link_params *params) |
| 8605 | { |
| 8606 | struct bnx2x *bp = params->bp; |
| 8607 | DP(NETIF_MSG_LINK, "PMA/PMD ext_phy_loopback: 8726\n"); |
| 8608 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 0x0001); |
| 8609 | } |
| 8610 | |
| 8611 | static void bnx2x_8726_external_rom_boot(struct bnx2x_phy *phy, |
| 8612 | struct link_params *params) |
| 8613 | { |
| 8614 | struct bnx2x *bp = params->bp; |
| 8615 | /* Need to wait 100ms after reset */ |
| 8616 | msleep(100); |
| 8617 | |
| 8618 | /* Micro controller re-boot */ |
| 8619 | bnx2x_cl45_write(bp, phy, |
| 8620 | MDIO_PMA_DEVAD, MDIO_PMA_REG_GEN_CTRL, 0x018B); |
| 8621 | |
| 8622 | /* Set soft reset */ |
| 8623 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8624 | MDIO_PMA_DEVAD, |
| 8625 | MDIO_PMA_REG_GEN_CTRL, |
| 8626 | MDIO_PMA_REG_GEN_CTRL_ROM_MICRO_RESET); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8627 | |
| 8628 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8629 | MDIO_PMA_DEVAD, |
| 8630 | MDIO_PMA_REG_MISC_CTRL1, 0x0001); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8631 | |
| 8632 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8633 | MDIO_PMA_DEVAD, |
| 8634 | MDIO_PMA_REG_GEN_CTRL, |
| 8635 | MDIO_PMA_REG_GEN_CTRL_ROM_RESET_INTERNAL_MP); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8636 | |
| 8637 | /* wait for 150ms for microcode load */ |
| 8638 | msleep(150); |
| 8639 | |
| 8640 | /* Disable serial boot control, tristates pins SS_N, SCK, MOSI, MISO */ |
| 8641 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8642 | MDIO_PMA_DEVAD, |
| 8643 | MDIO_PMA_REG_MISC_CTRL1, 0x0000); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8644 | |
| 8645 | msleep(200); |
| 8646 | bnx2x_save_bcm_spirom_ver(bp, phy, params->port); |
| 8647 | } |
| 8648 | |
| 8649 | static u8 bnx2x_8726_read_status(struct bnx2x_phy *phy, |
| 8650 | struct link_params *params, |
| 8651 | struct link_vars *vars) |
| 8652 | { |
| 8653 | struct bnx2x *bp = params->bp; |
| 8654 | u16 val1; |
| 8655 | u8 link_up = bnx2x_8706_8726_read_status(phy, params, vars); |
| 8656 | if (link_up) { |
| 8657 | bnx2x_cl45_read(bp, phy, |
| 8658 | MDIO_PMA_DEVAD, MDIO_PMA_REG_PHY_IDENTIFIER, |
| 8659 | &val1); |
| 8660 | if (val1 & (1<<15)) { |
| 8661 | DP(NETIF_MSG_LINK, "Tx is disabled\n"); |
| 8662 | link_up = 0; |
| 8663 | vars->line_speed = 0; |
| 8664 | } |
| 8665 | } |
| 8666 | return link_up; |
| 8667 | } |
| 8668 | |
| 8669 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 8670 | static int bnx2x_8726_config_init(struct bnx2x_phy *phy, |
| 8671 | struct link_params *params, |
| 8672 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8673 | { |
| 8674 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8675 | DP(NETIF_MSG_LINK, "Initializing BCM8726\n"); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8676 | |
| 8677 | 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] | 8678 | bnx2x_wait_reset_complete(bp, phy, params); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8679 | |
| 8680 | bnx2x_8726_external_rom_boot(phy, params); |
| 8681 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8682 | /* |
| 8683 | * Need to call module detected on initialization since the module |
| 8684 | * detection triggered by actual module insertion might occur before |
| 8685 | * driver is loaded, and when driver is loaded, it reset all |
| 8686 | * registers, including the transmitter |
| 8687 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8688 | bnx2x_sfp_module_detection(phy, params); |
| 8689 | |
| 8690 | if (phy->req_line_speed == SPEED_1000) { |
| 8691 | DP(NETIF_MSG_LINK, "Setting 1G force\n"); |
| 8692 | bnx2x_cl45_write(bp, phy, |
| 8693 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 0x40); |
| 8694 | bnx2x_cl45_write(bp, phy, |
| 8695 | MDIO_PMA_DEVAD, MDIO_PMA_REG_10G_CTRL2, 0xD); |
| 8696 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8697 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_CTRL, 0x5); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8698 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8699 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_RXCTRL, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8700 | 0x400); |
| 8701 | } else if ((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 8702 | (phy->speed_cap_mask & |
| 8703 | PORT_HW_CFG_SPEED_CAPABILITY_D0_1G) && |
| 8704 | ((phy->speed_cap_mask & |
| 8705 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G) != |
| 8706 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G)) { |
| 8707 | DP(NETIF_MSG_LINK, "Setting 1G clause37\n"); |
| 8708 | /* Set Flow control */ |
| 8709 | bnx2x_ext_phy_set_pause(params, phy, vars); |
| 8710 | bnx2x_cl45_write(bp, phy, |
| 8711 | MDIO_AN_DEVAD, MDIO_AN_REG_ADV, 0x20); |
| 8712 | bnx2x_cl45_write(bp, phy, |
| 8713 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_CL73, 0x040c); |
| 8714 | bnx2x_cl45_write(bp, phy, |
| 8715 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_FC_LD, 0x0020); |
| 8716 | bnx2x_cl45_write(bp, phy, |
| 8717 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_AN, 0x1000); |
| 8718 | bnx2x_cl45_write(bp, phy, |
| 8719 | MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, 0x1200); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8720 | /* |
| 8721 | * Enable RX-ALARM control to receive interrupt for 1G speed |
| 8722 | * change |
| 8723 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8724 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8725 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_CTRL, 0x4); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8726 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8727 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_RXCTRL, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8728 | 0x400); |
| 8729 | |
| 8730 | } else { /* Default 10G. Set only LASI control */ |
| 8731 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8732 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_CTRL, 1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8733 | } |
| 8734 | |
| 8735 | /* Set TX PreEmphasis if needed */ |
| 8736 | if ((params->feature_config_flags & |
| 8737 | FEATURE_CONFIG_OVERRIDE_PREEMPHASIS_ENABLED)) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 8738 | DP(NETIF_MSG_LINK, |
| 8739 | "Setting TX_CTRL1 0x%x, TX_CTRL2 0x%x\n", |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8740 | phy->tx_preemphasis[0], |
| 8741 | phy->tx_preemphasis[1]); |
| 8742 | bnx2x_cl45_write(bp, phy, |
| 8743 | MDIO_PMA_DEVAD, |
| 8744 | MDIO_PMA_REG_8726_TX_CTRL1, |
| 8745 | phy->tx_preemphasis[0]); |
| 8746 | |
| 8747 | bnx2x_cl45_write(bp, phy, |
| 8748 | MDIO_PMA_DEVAD, |
| 8749 | MDIO_PMA_REG_8726_TX_CTRL2, |
| 8750 | phy->tx_preemphasis[1]); |
| 8751 | } |
| 8752 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8753 | return 0; |
| 8754 | |
| 8755 | } |
| 8756 | |
| 8757 | static void bnx2x_8726_link_reset(struct bnx2x_phy *phy, |
| 8758 | struct link_params *params) |
| 8759 | { |
| 8760 | struct bnx2x *bp = params->bp; |
| 8761 | DP(NETIF_MSG_LINK, "bnx2x_8726_link_reset port %d\n", params->port); |
| 8762 | /* Set serial boot control for external load */ |
| 8763 | bnx2x_cl45_write(bp, phy, |
| 8764 | MDIO_PMA_DEVAD, |
| 8765 | MDIO_PMA_REG_GEN_CTRL, 0x0001); |
| 8766 | } |
| 8767 | |
| 8768 | /******************************************************************/ |
| 8769 | /* BCM8727 PHY SECTION */ |
| 8770 | /******************************************************************/ |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 8771 | |
| 8772 | static void bnx2x_8727_set_link_led(struct bnx2x_phy *phy, |
| 8773 | struct link_params *params, u8 mode) |
| 8774 | { |
| 8775 | struct bnx2x *bp = params->bp; |
| 8776 | u16 led_mode_bitmask = 0; |
| 8777 | u16 gpio_pins_bitmask = 0; |
| 8778 | u16 val; |
| 8779 | /* Only NOC flavor requires to set the LED specifically */ |
| 8780 | if (!(phy->flags & FLAGS_NOC)) |
| 8781 | return; |
| 8782 | switch (mode) { |
| 8783 | case LED_MODE_FRONT_PANEL_OFF: |
| 8784 | case LED_MODE_OFF: |
| 8785 | led_mode_bitmask = 0; |
| 8786 | gpio_pins_bitmask = 0x03; |
| 8787 | break; |
| 8788 | case LED_MODE_ON: |
| 8789 | led_mode_bitmask = 0; |
| 8790 | gpio_pins_bitmask = 0x02; |
| 8791 | break; |
| 8792 | case LED_MODE_OPER: |
| 8793 | led_mode_bitmask = 0x60; |
| 8794 | gpio_pins_bitmask = 0x11; |
| 8795 | break; |
| 8796 | } |
| 8797 | bnx2x_cl45_read(bp, phy, |
| 8798 | MDIO_PMA_DEVAD, |
| 8799 | MDIO_PMA_REG_8727_PCS_OPT_CTRL, |
| 8800 | &val); |
| 8801 | val &= 0xff8f; |
| 8802 | val |= led_mode_bitmask; |
| 8803 | bnx2x_cl45_write(bp, phy, |
| 8804 | MDIO_PMA_DEVAD, |
| 8805 | MDIO_PMA_REG_8727_PCS_OPT_CTRL, |
| 8806 | val); |
| 8807 | bnx2x_cl45_read(bp, phy, |
| 8808 | MDIO_PMA_DEVAD, |
| 8809 | MDIO_PMA_REG_8727_GPIO_CTRL, |
| 8810 | &val); |
| 8811 | val &= 0xffe0; |
| 8812 | val |= gpio_pins_bitmask; |
| 8813 | bnx2x_cl45_write(bp, phy, |
| 8814 | MDIO_PMA_DEVAD, |
| 8815 | MDIO_PMA_REG_8727_GPIO_CTRL, |
| 8816 | val); |
| 8817 | } |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 8818 | static void bnx2x_8727_hw_reset(struct bnx2x_phy *phy, |
| 8819 | struct link_params *params) { |
| 8820 | u32 swap_val, swap_override; |
| 8821 | u8 port; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8822 | /* |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 8823 | * The PHY reset is controlled by GPIO 1. Fake the port number |
| 8824 | * to cancel the swap done in set_gpio() |
| 8825 | */ |
| 8826 | struct bnx2x *bp = params->bp; |
| 8827 | swap_val = REG_RD(bp, NIG_REG_PORT_SWAP); |
| 8828 | swap_override = REG_RD(bp, NIG_REG_STRAP_OVERRIDE); |
| 8829 | port = (swap_val && swap_override) ^ 1; |
| 8830 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8831 | MISC_REGISTERS_GPIO_OUTPUT_LOW, port); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 8832 | } |
| 8833 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 8834 | static int bnx2x_8727_config_init(struct bnx2x_phy *phy, |
| 8835 | struct link_params *params, |
| 8836 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8837 | { |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8838 | u32 tx_en_mode; |
| 8839 | u16 tmp1, val, mod_abs, tmp2; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8840 | u16 rx_alarm_ctrl_val; |
| 8841 | u16 lasi_ctrl_val; |
| 8842 | struct bnx2x *bp = params->bp; |
| 8843 | /* Enable PMD link, MOD_ABS_FLT, and 1G link alarm */ |
| 8844 | |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 8845 | bnx2x_wait_reset_complete(bp, phy, params); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8846 | rx_alarm_ctrl_val = (1<<2) | (1<<5) ; |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 8847 | /* Should be 0x6 to enable XS on Tx side. */ |
| 8848 | lasi_ctrl_val = 0x0006; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8849 | |
| 8850 | DP(NETIF_MSG_LINK, "Initializing BCM8727\n"); |
| 8851 | /* enable LASI */ |
| 8852 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8853 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_RXCTRL, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8854 | rx_alarm_ctrl_val); |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 8855 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8856 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_TXCTRL, |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 8857 | 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8858 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8859 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_CTRL, lasi_ctrl_val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8860 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8861 | /* |
| 8862 | * Initially configure MOD_ABS to interrupt when module is |
| 8863 | * presence( bit 8) |
| 8864 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8865 | bnx2x_cl45_read(bp, phy, |
| 8866 | MDIO_PMA_DEVAD, MDIO_PMA_REG_PHY_IDENTIFIER, &mod_abs); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8867 | /* |
| 8868 | * Set EDC off by setting OPTXLOS signal input to low (bit 9). |
| 8869 | * When the EDC is off it locks onto a reference clock and avoids |
| 8870 | * becoming 'lost' |
| 8871 | */ |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 8872 | mod_abs &= ~(1<<8); |
| 8873 | if (!(phy->flags & FLAGS_NOC)) |
| 8874 | mod_abs &= ~(1<<9); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8875 | bnx2x_cl45_write(bp, phy, |
| 8876 | MDIO_PMA_DEVAD, MDIO_PMA_REG_PHY_IDENTIFIER, mod_abs); |
| 8877 | |
| 8878 | |
Yaniv Rosner | 85242ee | 2011-07-05 01:06:53 +0000 | [diff] [blame] | 8879 | /* Enable/Disable PHY transmitter output */ |
| 8880 | bnx2x_set_disable_pmd_transmit(params, phy, 0); |
| 8881 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8882 | /* Make MOD_ABS give interrupt on change */ |
| 8883 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_PCS_OPT_CTRL, |
| 8884 | &val); |
| 8885 | val |= (1<<12); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 8886 | if (phy->flags & FLAGS_NOC) |
| 8887 | val |= (3<<5); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8888 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8889 | /* |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 8890 | * Set 8727 GPIOs to input to allow reading from the 8727 GPIO0 |
| 8891 | * status which reflect SFP+ module over-current |
| 8892 | */ |
| 8893 | if (!(phy->flags & FLAGS_NOC)) |
| 8894 | val &= 0xff8f; /* Reset bits 4-6 */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8895 | bnx2x_cl45_write(bp, phy, |
| 8896 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_PCS_OPT_CTRL, val); |
| 8897 | |
| 8898 | bnx2x_8727_power_module(bp, phy, 1); |
| 8899 | |
| 8900 | bnx2x_cl45_read(bp, phy, |
| 8901 | MDIO_PMA_DEVAD, MDIO_PMA_REG_M8051_MSGOUT_REG, &tmp1); |
| 8902 | |
| 8903 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8904 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_RXSTAT, &tmp1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8905 | |
| 8906 | /* Set option 1G speed */ |
| 8907 | if (phy->req_line_speed == SPEED_1000) { |
| 8908 | DP(NETIF_MSG_LINK, "Setting 1G force\n"); |
| 8909 | bnx2x_cl45_write(bp, phy, |
| 8910 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 0x40); |
| 8911 | bnx2x_cl45_write(bp, phy, |
| 8912 | MDIO_PMA_DEVAD, MDIO_PMA_REG_10G_CTRL2, 0xD); |
| 8913 | bnx2x_cl45_read(bp, phy, |
| 8914 | MDIO_PMA_DEVAD, MDIO_PMA_REG_10G_CTRL2, &tmp1); |
| 8915 | DP(NETIF_MSG_LINK, "1.7 = 0x%x\n", tmp1); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8916 | /* |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8917 | * Power down the XAUI until link is up in case of dual-media |
| 8918 | * and 1G |
| 8919 | */ |
| 8920 | if (DUAL_MEDIA(params)) { |
| 8921 | bnx2x_cl45_read(bp, phy, |
| 8922 | MDIO_PMA_DEVAD, |
| 8923 | MDIO_PMA_REG_8727_PCS_GP, &val); |
| 8924 | val |= (3<<10); |
| 8925 | bnx2x_cl45_write(bp, phy, |
| 8926 | MDIO_PMA_DEVAD, |
| 8927 | MDIO_PMA_REG_8727_PCS_GP, val); |
| 8928 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8929 | } else if ((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 8930 | ((phy->speed_cap_mask & |
| 8931 | PORT_HW_CFG_SPEED_CAPABILITY_D0_1G)) && |
| 8932 | ((phy->speed_cap_mask & |
| 8933 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G) != |
| 8934 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G)) { |
| 8935 | |
| 8936 | DP(NETIF_MSG_LINK, "Setting 1G clause37\n"); |
| 8937 | bnx2x_cl45_write(bp, phy, |
| 8938 | MDIO_AN_DEVAD, MDIO_AN_REG_8727_MISC_CTRL, 0); |
| 8939 | bnx2x_cl45_write(bp, phy, |
| 8940 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_AN, 0x1300); |
| 8941 | } else { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8942 | /* |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8943 | * Since the 8727 has only single reset pin, need to set the 10G |
| 8944 | * registers although it is default |
| 8945 | */ |
| 8946 | bnx2x_cl45_write(bp, phy, |
| 8947 | MDIO_AN_DEVAD, MDIO_AN_REG_8727_MISC_CTRL, |
| 8948 | 0x0020); |
| 8949 | bnx2x_cl45_write(bp, phy, |
| 8950 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_AN, 0x0100); |
| 8951 | bnx2x_cl45_write(bp, phy, |
| 8952 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 0x2040); |
| 8953 | bnx2x_cl45_write(bp, phy, |
| 8954 | MDIO_PMA_DEVAD, MDIO_PMA_REG_10G_CTRL2, |
| 8955 | 0x0008); |
| 8956 | } |
| 8957 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8958 | /* |
| 8959 | * Set 2-wire transfer rate of SFP+ module EEPROM |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8960 | * to 100Khz since some DACs(direct attached cables) do |
| 8961 | * not work at 400Khz. |
| 8962 | */ |
| 8963 | bnx2x_cl45_write(bp, phy, |
| 8964 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_TWO_WIRE_SLAVE_ADDR, |
| 8965 | 0xa001); |
| 8966 | |
| 8967 | /* Set TX PreEmphasis if needed */ |
| 8968 | if ((params->feature_config_flags & |
| 8969 | FEATURE_CONFIG_OVERRIDE_PREEMPHASIS_ENABLED)) { |
| 8970 | DP(NETIF_MSG_LINK, "Setting TX_CTRL1 0x%x, TX_CTRL2 0x%x\n", |
| 8971 | phy->tx_preemphasis[0], |
| 8972 | phy->tx_preemphasis[1]); |
| 8973 | bnx2x_cl45_write(bp, phy, |
| 8974 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_TX_CTRL1, |
| 8975 | phy->tx_preemphasis[0]); |
| 8976 | |
| 8977 | bnx2x_cl45_write(bp, phy, |
| 8978 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_TX_CTRL2, |
| 8979 | phy->tx_preemphasis[1]); |
| 8980 | } |
| 8981 | |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8982 | /* |
| 8983 | * If TX Laser is controlled by GPIO_0, do not let PHY go into low |
| 8984 | * power mode, if TX Laser is disabled |
| 8985 | */ |
| 8986 | tx_en_mode = REG_RD(bp, params->shmem_base + |
| 8987 | offsetof(struct shmem_region, |
| 8988 | dev_info.port_hw_config[params->port].sfp_ctrl)) |
| 8989 | & PORT_HW_CFG_TX_LASER_MASK; |
| 8990 | |
| 8991 | if (tx_en_mode == PORT_HW_CFG_TX_LASER_GPIO0) { |
| 8992 | |
| 8993 | DP(NETIF_MSG_LINK, "Enabling TXONOFF_PWRDN_DIS\n"); |
| 8994 | bnx2x_cl45_read(bp, phy, |
| 8995 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_OPT_CFG_REG, &tmp2); |
| 8996 | tmp2 |= 0x1000; |
| 8997 | tmp2 &= 0xFFEF; |
| 8998 | bnx2x_cl45_write(bp, phy, |
| 8999 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_OPT_CFG_REG, tmp2); |
| 9000 | } |
| 9001 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9002 | return 0; |
| 9003 | } |
| 9004 | |
| 9005 | static void bnx2x_8727_handle_mod_abs(struct bnx2x_phy *phy, |
| 9006 | struct link_params *params) |
| 9007 | { |
| 9008 | struct bnx2x *bp = params->bp; |
| 9009 | u16 mod_abs, rx_alarm_status; |
| 9010 | u32 val = REG_RD(bp, params->shmem_base + |
| 9011 | offsetof(struct shmem_region, dev_info. |
| 9012 | port_feature_config[params->port]. |
| 9013 | config)); |
| 9014 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 9015 | MDIO_PMA_DEVAD, |
| 9016 | MDIO_PMA_REG_PHY_IDENTIFIER, &mod_abs); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9017 | if (mod_abs & (1<<8)) { |
| 9018 | |
| 9019 | /* Module is absent */ |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 9020 | DP(NETIF_MSG_LINK, |
| 9021 | "MOD_ABS indication show module is absent\n"); |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 9022 | phy->media_type = ETH_PHY_NOT_PRESENT; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 9023 | /* |
| 9024 | * 1. Set mod_abs to detect next module |
| 9025 | * presence event |
| 9026 | * 2. Set EDC off by setting OPTXLOS signal input to low |
| 9027 | * (bit 9). |
| 9028 | * When the EDC is off it locks onto a reference clock and |
| 9029 | * avoids becoming 'lost'. |
| 9030 | */ |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 9031 | mod_abs &= ~(1<<8); |
| 9032 | if (!(phy->flags & FLAGS_NOC)) |
| 9033 | mod_abs &= ~(1<<9); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9034 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 9035 | MDIO_PMA_DEVAD, |
| 9036 | MDIO_PMA_REG_PHY_IDENTIFIER, mod_abs); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9037 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 9038 | /* |
| 9039 | * Clear RX alarm since it stays up as long as |
| 9040 | * the mod_abs wasn't changed |
| 9041 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9042 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 9043 | MDIO_PMA_DEVAD, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 9044 | MDIO_PMA_LASI_RXSTAT, &rx_alarm_status); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9045 | |
| 9046 | } else { |
| 9047 | /* Module is present */ |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 9048 | DP(NETIF_MSG_LINK, |
| 9049 | "MOD_ABS indication show module is present\n"); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 9050 | /* |
| 9051 | * First disable transmitter, and if the module is ok, the |
| 9052 | * module_detection will enable it |
| 9053 | * 1. Set mod_abs to detect next module absent event ( bit 8) |
| 9054 | * 2. Restore the default polarity of the OPRXLOS signal and |
| 9055 | * this signal will then correctly indicate the presence or |
| 9056 | * absence of the Rx signal. (bit 9) |
| 9057 | */ |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 9058 | mod_abs |= (1<<8); |
| 9059 | if (!(phy->flags & FLAGS_NOC)) |
| 9060 | mod_abs |= (1<<9); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9061 | bnx2x_cl45_write(bp, phy, |
| 9062 | MDIO_PMA_DEVAD, |
| 9063 | MDIO_PMA_REG_PHY_IDENTIFIER, mod_abs); |
| 9064 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 9065 | /* |
| 9066 | * Clear RX alarm since it stays up as long as the mod_abs |
| 9067 | * wasn't changed. This is need to be done before calling the |
| 9068 | * module detection, otherwise it will clear* the link update |
| 9069 | * alarm |
| 9070 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9071 | bnx2x_cl45_read(bp, phy, |
| 9072 | MDIO_PMA_DEVAD, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 9073 | MDIO_PMA_LASI_RXSTAT, &rx_alarm_status); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9074 | |
| 9075 | |
| 9076 | if ((val & PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK) == |
| 9077 | PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_DISABLE_TX_LASER) |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 9078 | bnx2x_sfp_set_transmitter(params, phy, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9079 | |
| 9080 | if (bnx2x_wait_for_sfp_module_initialized(phy, params) == 0) |
| 9081 | bnx2x_sfp_module_detection(phy, params); |
| 9082 | else |
| 9083 | DP(NETIF_MSG_LINK, "SFP+ module is not initialized\n"); |
| 9084 | } |
| 9085 | |
| 9086 | DP(NETIF_MSG_LINK, "8727 RX_ALARM_STATUS 0x%x\n", |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 9087 | rx_alarm_status); |
| 9088 | /* 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] | 9089 | } |
| 9090 | |
| 9091 | static u8 bnx2x_8727_read_status(struct bnx2x_phy *phy, |
| 9092 | struct link_params *params, |
| 9093 | struct link_vars *vars) |
| 9094 | |
| 9095 | { |
| 9096 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 27d0243 | 2011-05-31 21:27:48 +0000 | [diff] [blame] | 9097 | u8 link_up = 0, oc_port = params->port; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9098 | u16 link_status = 0; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 9099 | u16 rx_alarm_status, lasi_ctrl, val1; |
| 9100 | |
| 9101 | /* If PHY is not initialized, do not check link status */ |
| 9102 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 9103 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_CTRL, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 9104 | &lasi_ctrl); |
| 9105 | if (!lasi_ctrl) |
| 9106 | return 0; |
| 9107 | |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 9108 | /* Check the LASI on Rx */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9109 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 9110 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_RXSTAT, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9111 | &rx_alarm_status); |
| 9112 | vars->line_speed = 0; |
| 9113 | DP(NETIF_MSG_LINK, "8727 RX_ALARM_STATUS 0x%x\n", rx_alarm_status); |
| 9114 | |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 9115 | bnx2x_sfp_mask_fault(bp, phy, MDIO_PMA_LASI_TXSTAT, |
| 9116 | MDIO_PMA_LASI_TXCTRL); |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 9117 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9118 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 9119 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_STAT, &val1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9120 | |
| 9121 | DP(NETIF_MSG_LINK, "8727 LASI status 0x%x\n", val1); |
| 9122 | |
| 9123 | /* Clear MSG-OUT */ |
| 9124 | bnx2x_cl45_read(bp, phy, |
| 9125 | MDIO_PMA_DEVAD, MDIO_PMA_REG_M8051_MSGOUT_REG, &val1); |
| 9126 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 9127 | /* |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9128 | * If a module is present and there is need to check |
| 9129 | * for over current |
| 9130 | */ |
| 9131 | if (!(phy->flags & FLAGS_NOC) && !(rx_alarm_status & (1<<5))) { |
| 9132 | /* Check over-current using 8727 GPIO0 input*/ |
| 9133 | bnx2x_cl45_read(bp, phy, |
| 9134 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_GPIO_CTRL, |
| 9135 | &val1); |
| 9136 | |
| 9137 | if ((val1 & (1<<8)) == 0) { |
Yaniv Rosner | 27d0243 | 2011-05-31 21:27:48 +0000 | [diff] [blame] | 9138 | if (!CHIP_IS_E1x(bp)) |
| 9139 | oc_port = BP_PATH(bp) + (params->port << 1); |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 9140 | DP(NETIF_MSG_LINK, |
| 9141 | "8727 Power fault has been detected on port %d\n", |
| 9142 | oc_port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9143 | netdev_err(bp->dev, "Error: Power fault on Port %d has" |
| 9144 | " been detected and the power to " |
| 9145 | "that SFP+ module has been removed" |
| 9146 | " to prevent failure of the card." |
| 9147 | " Please remove the SFP+ module and" |
| 9148 | " restart the system to clear this" |
| 9149 | " error.\n", |
Yaniv Rosner | 27d0243 | 2011-05-31 21:27:48 +0000 | [diff] [blame] | 9150 | oc_port); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 9151 | /* Disable all RX_ALARMs except for mod_abs */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9152 | bnx2x_cl45_write(bp, phy, |
| 9153 | MDIO_PMA_DEVAD, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 9154 | MDIO_PMA_LASI_RXCTRL, (1<<5)); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9155 | |
| 9156 | bnx2x_cl45_read(bp, phy, |
| 9157 | MDIO_PMA_DEVAD, |
| 9158 | MDIO_PMA_REG_PHY_IDENTIFIER, &val1); |
| 9159 | /* Wait for module_absent_event */ |
| 9160 | val1 |= (1<<8); |
| 9161 | bnx2x_cl45_write(bp, phy, |
| 9162 | MDIO_PMA_DEVAD, |
| 9163 | MDIO_PMA_REG_PHY_IDENTIFIER, val1); |
| 9164 | /* Clear RX alarm */ |
| 9165 | bnx2x_cl45_read(bp, phy, |
| 9166 | MDIO_PMA_DEVAD, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 9167 | MDIO_PMA_LASI_RXSTAT, &rx_alarm_status); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9168 | return 0; |
| 9169 | } |
| 9170 | } /* Over current check */ |
| 9171 | |
| 9172 | /* When module absent bit is set, check module */ |
| 9173 | if (rx_alarm_status & (1<<5)) { |
| 9174 | bnx2x_8727_handle_mod_abs(phy, params); |
| 9175 | /* Enable all mod_abs and link detection bits */ |
| 9176 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 9177 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_RXCTRL, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9178 | ((1<<5) | (1<<2))); |
| 9179 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 9180 | DP(NETIF_MSG_LINK, "Enabling 8727 TX laser if SFP is approved\n"); |
| 9181 | bnx2x_8727_specific_func(phy, params, ENABLE_TX); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9182 | /* If transmitter is disabled, ignore false link up indication */ |
| 9183 | bnx2x_cl45_read(bp, phy, |
| 9184 | MDIO_PMA_DEVAD, MDIO_PMA_REG_PHY_IDENTIFIER, &val1); |
| 9185 | if (val1 & (1<<15)) { |
| 9186 | DP(NETIF_MSG_LINK, "Tx is disabled\n"); |
| 9187 | return 0; |
| 9188 | } |
| 9189 | |
| 9190 | bnx2x_cl45_read(bp, phy, |
| 9191 | MDIO_PMA_DEVAD, |
| 9192 | MDIO_PMA_REG_8073_SPEED_LINK_STATUS, &link_status); |
| 9193 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 9194 | /* |
| 9195 | * Bits 0..2 --> speed detected, |
| 9196 | * Bits 13..15--> link is down |
| 9197 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9198 | if ((link_status & (1<<2)) && (!(link_status & (1<<15)))) { |
| 9199 | link_up = 1; |
| 9200 | vars->line_speed = SPEED_10000; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 9201 | DP(NETIF_MSG_LINK, "port %x: External link up in 10G\n", |
| 9202 | params->port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9203 | } else if ((link_status & (1<<0)) && (!(link_status & (1<<13)))) { |
| 9204 | link_up = 1; |
| 9205 | vars->line_speed = SPEED_1000; |
| 9206 | DP(NETIF_MSG_LINK, "port %x: External link up in 1G\n", |
| 9207 | params->port); |
| 9208 | } else { |
| 9209 | link_up = 0; |
| 9210 | DP(NETIF_MSG_LINK, "port %x: External link is down\n", |
| 9211 | params->port); |
| 9212 | } |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 9213 | |
| 9214 | /* Capture 10G link fault. */ |
| 9215 | if (vars->line_speed == SPEED_10000) { |
| 9216 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 9217 | MDIO_PMA_LASI_TXSTAT, &val1); |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 9218 | |
| 9219 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 9220 | MDIO_PMA_LASI_TXSTAT, &val1); |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 9221 | |
| 9222 | if (val1 & (1<<0)) { |
| 9223 | vars->fault_detected = 1; |
| 9224 | } |
| 9225 | } |
| 9226 | |
Yaniv Rosner | 791f18c | 2011-01-18 04:33:42 +0000 | [diff] [blame] | 9227 | if (link_up) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9228 | bnx2x_ext_phy_resolve_fc(phy, params, vars); |
Yaniv Rosner | 791f18c | 2011-01-18 04:33:42 +0000 | [diff] [blame] | 9229 | vars->duplex = DUPLEX_FULL; |
| 9230 | DP(NETIF_MSG_LINK, "duplex = 0x%x\n", vars->duplex); |
| 9231 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 9232 | |
| 9233 | if ((DUAL_MEDIA(params)) && |
| 9234 | (phy->req_line_speed == SPEED_1000)) { |
| 9235 | bnx2x_cl45_read(bp, phy, |
| 9236 | MDIO_PMA_DEVAD, |
| 9237 | MDIO_PMA_REG_8727_PCS_GP, &val1); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 9238 | /* |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 9239 | * In case of dual-media board and 1G, power up the XAUI side, |
| 9240 | * otherwise power it down. For 10G it is done automatically |
| 9241 | */ |
| 9242 | if (link_up) |
| 9243 | val1 &= ~(3<<10); |
| 9244 | else |
| 9245 | val1 |= (3<<10); |
| 9246 | bnx2x_cl45_write(bp, phy, |
| 9247 | MDIO_PMA_DEVAD, |
| 9248 | MDIO_PMA_REG_8727_PCS_GP, val1); |
| 9249 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9250 | return link_up; |
| 9251 | } |
| 9252 | |
| 9253 | static void bnx2x_8727_link_reset(struct bnx2x_phy *phy, |
| 9254 | struct link_params *params) |
| 9255 | { |
| 9256 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 85242ee | 2011-07-05 01:06:53 +0000 | [diff] [blame] | 9257 | |
| 9258 | /* Enable/Disable PHY transmitter output */ |
| 9259 | bnx2x_set_disable_pmd_transmit(params, phy, 1); |
| 9260 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9261 | /* Disable Transmitter */ |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 9262 | bnx2x_sfp_set_transmitter(params, phy, 0); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 9263 | /* Clear LASI */ |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 9264 | 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] | 9265 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9266 | } |
| 9267 | |
| 9268 | /******************************************************************/ |
| 9269 | /* BCM8481/BCM84823/BCM84833 PHY SECTION */ |
| 9270 | /******************************************************************/ |
| 9271 | static void bnx2x_save_848xx_spirom_version(struct bnx2x_phy *phy, |
| 9272 | struct link_params *params) |
| 9273 | { |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9274 | u16 val, fw_ver1, fw_ver2, cnt; |
| 9275 | u8 port; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9276 | struct bnx2x *bp = params->bp; |
| 9277 | |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9278 | port = params->port; |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 9279 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9280 | /* For the 32 bits registers in 848xx, access via MDIO2ARM interface.*/ |
| 9281 | /* (1) set register 0xc200_0014(SPI_BRIDGE_CTRL_2) to 0x03000000 */ |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9282 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA819, 0x0014); |
| 9283 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA81A, 0xc200); |
| 9284 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA81B, 0x0000); |
| 9285 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA81C, 0x0300); |
| 9286 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA817, 0x0009); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9287 | |
| 9288 | for (cnt = 0; cnt < 100; cnt++) { |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9289 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, 0xA818, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9290 | if (val & 1) |
| 9291 | break; |
| 9292 | udelay(5); |
| 9293 | } |
| 9294 | if (cnt == 100) { |
| 9295 | 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] | 9296 | bnx2x_save_spirom_version(bp, port, 0, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9297 | phy->ver_addr); |
| 9298 | return; |
| 9299 | } |
| 9300 | |
| 9301 | |
| 9302 | /* 2) read register 0xc200_0000 (SPI_FW_STATUS) */ |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9303 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA819, 0x0000); |
| 9304 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA81A, 0xc200); |
| 9305 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA817, 0x000A); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9306 | for (cnt = 0; cnt < 100; cnt++) { |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9307 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, 0xA818, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9308 | if (val & 1) |
| 9309 | break; |
| 9310 | udelay(5); |
| 9311 | } |
| 9312 | if (cnt == 100) { |
| 9313 | 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] | 9314 | bnx2x_save_spirom_version(bp, port, 0, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9315 | phy->ver_addr); |
| 9316 | return; |
| 9317 | } |
| 9318 | |
| 9319 | /* lower 16 bits of the register SPI_FW_STATUS */ |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9320 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, 0xA81B, &fw_ver1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9321 | /* upper 16 bits of register SPI_FW_STATUS */ |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9322 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, 0xA81C, &fw_ver2); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9323 | |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9324 | bnx2x_save_spirom_version(bp, port, (fw_ver2<<16) | fw_ver1, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9325 | phy->ver_addr); |
| 9326 | } |
| 9327 | |
| 9328 | static void bnx2x_848xx_set_led(struct bnx2x *bp, |
| 9329 | struct bnx2x_phy *phy) |
| 9330 | { |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9331 | u16 val; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9332 | |
| 9333 | /* PHYC_CTL_LED_CTL */ |
| 9334 | bnx2x_cl45_read(bp, phy, |
| 9335 | MDIO_PMA_DEVAD, |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9336 | MDIO_PMA_REG_8481_LINK_SIGNAL, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9337 | val &= 0xFE00; |
| 9338 | val |= 0x0092; |
| 9339 | |
| 9340 | bnx2x_cl45_write(bp, phy, |
| 9341 | MDIO_PMA_DEVAD, |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9342 | MDIO_PMA_REG_8481_LINK_SIGNAL, val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9343 | |
| 9344 | bnx2x_cl45_write(bp, phy, |
| 9345 | MDIO_PMA_DEVAD, |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9346 | MDIO_PMA_REG_8481_LED1_MASK, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9347 | 0x80); |
| 9348 | |
| 9349 | bnx2x_cl45_write(bp, phy, |
| 9350 | MDIO_PMA_DEVAD, |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9351 | MDIO_PMA_REG_8481_LED2_MASK, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9352 | 0x18); |
| 9353 | |
Yaniv Rosner | f25b3c8 | 2011-01-18 04:33:47 +0000 | [diff] [blame] | 9354 | /* Select activity source by Tx and Rx, as suggested by PHY AE */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9355 | bnx2x_cl45_write(bp, phy, |
| 9356 | MDIO_PMA_DEVAD, |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9357 | MDIO_PMA_REG_8481_LED3_MASK, |
Yaniv Rosner | f25b3c8 | 2011-01-18 04:33:47 +0000 | [diff] [blame] | 9358 | 0x0006); |
| 9359 | |
| 9360 | /* Select the closest activity blink rate to that in 10/100/1000 */ |
| 9361 | bnx2x_cl45_write(bp, phy, |
| 9362 | MDIO_PMA_DEVAD, |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9363 | MDIO_PMA_REG_8481_LED3_BLINK, |
Yaniv Rosner | f25b3c8 | 2011-01-18 04:33:47 +0000 | [diff] [blame] | 9364 | 0); |
| 9365 | |
| 9366 | bnx2x_cl45_read(bp, phy, |
| 9367 | MDIO_PMA_DEVAD, |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9368 | MDIO_PMA_REG_84823_CTL_LED_CTL_1, &val); |
Yaniv Rosner | f25b3c8 | 2011-01-18 04:33:47 +0000 | [diff] [blame] | 9369 | val |= MDIO_PMA_REG_84823_LED3_STRETCH_EN; /* stretch_en for LED3*/ |
| 9370 | |
| 9371 | bnx2x_cl45_write(bp, phy, |
| 9372 | MDIO_PMA_DEVAD, |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9373 | MDIO_PMA_REG_84823_CTL_LED_CTL_1, val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9374 | |
| 9375 | /* 'Interrupt Mask' */ |
| 9376 | bnx2x_cl45_write(bp, phy, |
| 9377 | MDIO_AN_DEVAD, |
| 9378 | 0xFFFB, 0xFFFD); |
| 9379 | } |
| 9380 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 9381 | static int bnx2x_848xx_cmn_config_init(struct bnx2x_phy *phy, |
| 9382 | struct link_params *params, |
| 9383 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9384 | { |
| 9385 | struct bnx2x *bp = params->bp; |
| 9386 | u16 autoneg_val, an_1000_val, an_10_100_val; |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9387 | u16 tmp_req_line_speed; |
| 9388 | |
| 9389 | tmp_req_line_speed = phy->req_line_speed; |
| 9390 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833) |
| 9391 | if (phy->req_line_speed == SPEED_10000) |
| 9392 | phy->req_line_speed = SPEED_AUTO_NEG; |
| 9393 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 9394 | /* |
| 9395 | * This phy uses the NIG latch mechanism since link indication |
| 9396 | * arrives through its LED4 and not via its LASI signal, so we |
| 9397 | * get steady signal instead of clear on read |
| 9398 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9399 | bnx2x_bits_en(bp, NIG_REG_LATCH_BC_0 + params->port*4, |
| 9400 | 1 << NIG_LATCH_BC_ENABLE_MI_INT); |
| 9401 | |
| 9402 | bnx2x_cl45_write(bp, phy, |
| 9403 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 0x0000); |
| 9404 | |
| 9405 | bnx2x_848xx_set_led(bp, phy); |
| 9406 | |
| 9407 | /* set 1000 speed advertisement */ |
| 9408 | bnx2x_cl45_read(bp, phy, |
| 9409 | MDIO_AN_DEVAD, MDIO_AN_REG_8481_1000T_CTRL, |
| 9410 | &an_1000_val); |
| 9411 | |
| 9412 | bnx2x_ext_phy_set_pause(params, phy, vars); |
| 9413 | bnx2x_cl45_read(bp, phy, |
| 9414 | MDIO_AN_DEVAD, |
| 9415 | MDIO_AN_REG_8481_LEGACY_AN_ADV, |
| 9416 | &an_10_100_val); |
| 9417 | bnx2x_cl45_read(bp, phy, |
| 9418 | MDIO_AN_DEVAD, MDIO_AN_REG_8481_LEGACY_MII_CTRL, |
| 9419 | &autoneg_val); |
| 9420 | /* Disable forced speed */ |
| 9421 | autoneg_val &= ~((1<<6) | (1<<8) | (1<<9) | (1<<12) | (1<<13)); |
| 9422 | an_10_100_val &= ~((1<<5) | (1<<6) | (1<<7) | (1<<8)); |
| 9423 | |
| 9424 | if (((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 9425 | (phy->speed_cap_mask & |
| 9426 | PORT_HW_CFG_SPEED_CAPABILITY_D0_1G)) || |
| 9427 | (phy->req_line_speed == SPEED_1000)) { |
| 9428 | an_1000_val |= (1<<8); |
| 9429 | autoneg_val |= (1<<9 | 1<<12); |
| 9430 | if (phy->req_duplex == DUPLEX_FULL) |
| 9431 | an_1000_val |= (1<<9); |
| 9432 | DP(NETIF_MSG_LINK, "Advertising 1G\n"); |
| 9433 | } else |
| 9434 | an_1000_val &= ~((1<<8) | (1<<9)); |
| 9435 | |
| 9436 | bnx2x_cl45_write(bp, phy, |
| 9437 | MDIO_AN_DEVAD, MDIO_AN_REG_8481_1000T_CTRL, |
| 9438 | an_1000_val); |
| 9439 | |
Yaniv Rosner | 0520e63 | 2011-07-05 01:06:59 +0000 | [diff] [blame] | 9440 | /* set 100 speed advertisement */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9441 | if (((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 9442 | (phy->speed_cap_mask & |
Yaniv Rosner | 0520e63 | 2011-07-05 01:06:59 +0000 | [diff] [blame] | 9443 | (PORT_HW_CFG_SPEED_CAPABILITY_D0_100M_FULL | |
| 9444 | PORT_HW_CFG_SPEED_CAPABILITY_D0_100M_HALF)) && |
| 9445 | (phy->supported & |
| 9446 | (SUPPORTED_100baseT_Half | |
| 9447 | SUPPORTED_100baseT_Full)))) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9448 | an_10_100_val |= (1<<7); |
| 9449 | /* Enable autoneg and restart autoneg for legacy speeds */ |
| 9450 | autoneg_val |= (1<<9 | 1<<12); |
| 9451 | |
| 9452 | if (phy->req_duplex == DUPLEX_FULL) |
| 9453 | an_10_100_val |= (1<<8); |
| 9454 | DP(NETIF_MSG_LINK, "Advertising 100M\n"); |
| 9455 | } |
| 9456 | /* set 10 speed advertisement */ |
| 9457 | if (((phy->req_line_speed == SPEED_AUTO_NEG) && |
Yaniv Rosner | 0520e63 | 2011-07-05 01:06:59 +0000 | [diff] [blame] | 9458 | (phy->speed_cap_mask & |
| 9459 | (PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_FULL | |
| 9460 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_HALF)) && |
| 9461 | (phy->supported & |
| 9462 | (SUPPORTED_10baseT_Half | |
| 9463 | SUPPORTED_10baseT_Full)))) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9464 | an_10_100_val |= (1<<5); |
| 9465 | autoneg_val |= (1<<9 | 1<<12); |
| 9466 | if (phy->req_duplex == DUPLEX_FULL) |
| 9467 | an_10_100_val |= (1<<6); |
| 9468 | DP(NETIF_MSG_LINK, "Advertising 10M\n"); |
| 9469 | } |
| 9470 | |
| 9471 | /* Only 10/100 are allowed to work in FORCE mode */ |
Yaniv Rosner | 0520e63 | 2011-07-05 01:06:59 +0000 | [diff] [blame] | 9472 | if ((phy->req_line_speed == SPEED_100) && |
| 9473 | (phy->supported & |
| 9474 | (SUPPORTED_100baseT_Half | |
| 9475 | SUPPORTED_100baseT_Full))) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9476 | autoneg_val |= (1<<13); |
| 9477 | /* Enabled AUTO-MDIX when autoneg is disabled */ |
| 9478 | bnx2x_cl45_write(bp, phy, |
| 9479 | MDIO_AN_DEVAD, MDIO_AN_REG_8481_AUX_CTRL, |
| 9480 | (1<<15 | 1<<9 | 7<<0)); |
| 9481 | DP(NETIF_MSG_LINK, "Setting 100M force\n"); |
| 9482 | } |
Yaniv Rosner | 0520e63 | 2011-07-05 01:06:59 +0000 | [diff] [blame] | 9483 | if ((phy->req_line_speed == SPEED_10) && |
| 9484 | (phy->supported & |
| 9485 | (SUPPORTED_10baseT_Half | |
| 9486 | SUPPORTED_10baseT_Full))) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9487 | /* Enabled AUTO-MDIX when autoneg is disabled */ |
| 9488 | bnx2x_cl45_write(bp, phy, |
| 9489 | MDIO_AN_DEVAD, MDIO_AN_REG_8481_AUX_CTRL, |
| 9490 | (1<<15 | 1<<9 | 7<<0)); |
| 9491 | DP(NETIF_MSG_LINK, "Setting 10M force\n"); |
| 9492 | } |
| 9493 | |
| 9494 | bnx2x_cl45_write(bp, phy, |
| 9495 | MDIO_AN_DEVAD, MDIO_AN_REG_8481_LEGACY_AN_ADV, |
| 9496 | an_10_100_val); |
| 9497 | |
| 9498 | if (phy->req_duplex == DUPLEX_FULL) |
| 9499 | autoneg_val |= (1<<8); |
| 9500 | |
Yaniv Rosner | fd38f73e | 2011-08-02 22:59:53 +0000 | [diff] [blame] | 9501 | /* |
| 9502 | * Always write this if this is not 84833. |
| 9503 | * For 84833, write it only when it's a forced speed. |
| 9504 | */ |
| 9505 | if ((phy->type != PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833) || |
| 9506 | ((autoneg_val & (1<<12)) == 0)) |
| 9507 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9508 | MDIO_AN_DEVAD, |
| 9509 | MDIO_AN_REG_8481_LEGACY_MII_CTRL, autoneg_val); |
| 9510 | |
| 9511 | if (((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 9512 | (phy->speed_cap_mask & |
| 9513 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G)) || |
| 9514 | (phy->req_line_speed == SPEED_10000)) { |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 9515 | DP(NETIF_MSG_LINK, "Advertising 10G\n"); |
| 9516 | /* Restart autoneg for 10G*/ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9517 | |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 9518 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9519 | MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, |
| 9520 | 0x3200); |
Yaniv Rosner | fd38f73e | 2011-08-02 22:59:53 +0000 | [diff] [blame] | 9521 | } else |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9522 | bnx2x_cl45_write(bp, phy, |
| 9523 | MDIO_AN_DEVAD, |
| 9524 | MDIO_AN_REG_8481_10GBASE_T_AN_CTRL, |
| 9525 | 1); |
Yaniv Rosner | fd38f73e | 2011-08-02 22:59:53 +0000 | [diff] [blame] | 9526 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9527 | /* Save spirom version */ |
| 9528 | bnx2x_save_848xx_spirom_version(phy, params); |
| 9529 | |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9530 | phy->req_line_speed = tmp_req_line_speed; |
| 9531 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9532 | return 0; |
| 9533 | } |
| 9534 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 9535 | static int bnx2x_8481_config_init(struct bnx2x_phy *phy, |
| 9536 | struct link_params *params, |
| 9537 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9538 | { |
| 9539 | struct bnx2x *bp = params->bp; |
| 9540 | /* Restore normal power mode*/ |
| 9541 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 9542 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, params->port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9543 | |
| 9544 | /* HW reset */ |
| 9545 | bnx2x_ext_phy_hw_reset(bp, params->port); |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 9546 | bnx2x_wait_reset_complete(bp, phy, params); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9547 | |
| 9548 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 1<<15); |
| 9549 | return bnx2x_848xx_cmn_config_init(phy, params, vars); |
| 9550 | } |
| 9551 | |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9552 | |
| 9553 | #define PHY84833_HDSHK_WAIT 300 |
| 9554 | static int bnx2x_84833_pair_swap_cfg(struct bnx2x_phy *phy, |
| 9555 | struct link_params *params, |
| 9556 | struct link_vars *vars) |
| 9557 | { |
| 9558 | u32 idx; |
Yaniv Rosner | 0520e63 | 2011-07-05 01:06:59 +0000 | [diff] [blame] | 9559 | u32 pair_swap; |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9560 | u16 val; |
Yaniv Rosner | 0520e63 | 2011-07-05 01:06:59 +0000 | [diff] [blame] | 9561 | u16 data; |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9562 | struct bnx2x *bp = params->bp; |
| 9563 | /* Do pair swap */ |
| 9564 | |
Yaniv Rosner | 0520e63 | 2011-07-05 01:06:59 +0000 | [diff] [blame] | 9565 | /* Check for configuration. */ |
| 9566 | pair_swap = REG_RD(bp, params->shmem_base + |
| 9567 | offsetof(struct shmem_region, |
| 9568 | dev_info.port_hw_config[params->port].xgbt_phy_cfg)) & |
| 9569 | PORT_HW_CFG_RJ45_PAIR_SWAP_MASK; |
| 9570 | |
| 9571 | if (pair_swap == 0) |
| 9572 | return 0; |
| 9573 | |
| 9574 | data = (u16)pair_swap; |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9575 | |
| 9576 | /* Write CMD_OPEN_OVERRIDE to STATUS reg */ |
| 9577 | bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD, |
| 9578 | MDIO_84833_TOP_CFG_SCRATCH_REG2, |
| 9579 | PHY84833_CMD_OPEN_OVERRIDE); |
| 9580 | for (idx = 0; idx < PHY84833_HDSHK_WAIT; idx++) { |
| 9581 | bnx2x_cl45_read(bp, phy, MDIO_CTL_DEVAD, |
| 9582 | MDIO_84833_TOP_CFG_SCRATCH_REG2, &val); |
| 9583 | if (val == PHY84833_CMD_OPEN_FOR_CMDS) |
| 9584 | break; |
| 9585 | msleep(1); |
| 9586 | } |
| 9587 | if (idx >= PHY84833_HDSHK_WAIT) { |
| 9588 | DP(NETIF_MSG_LINK, "Pairswap: FW not ready.\n"); |
| 9589 | return -EINVAL; |
| 9590 | } |
| 9591 | |
| 9592 | bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD, |
| 9593 | MDIO_84833_TOP_CFG_SCRATCH_REG4, |
| 9594 | data); |
| 9595 | /* Issue pair swap command */ |
| 9596 | bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD, |
| 9597 | MDIO_84833_TOP_CFG_SCRATCH_REG0, |
| 9598 | PHY84833_DIAG_CMD_PAIR_SWAP_CHANGE); |
| 9599 | for (idx = 0; idx < PHY84833_HDSHK_WAIT; idx++) { |
| 9600 | bnx2x_cl45_read(bp, phy, MDIO_CTL_DEVAD, |
| 9601 | MDIO_84833_TOP_CFG_SCRATCH_REG2, &val); |
| 9602 | if ((val == PHY84833_CMD_COMPLETE_PASS) || |
| 9603 | (val == PHY84833_CMD_COMPLETE_ERROR)) |
| 9604 | break; |
| 9605 | msleep(1); |
| 9606 | } |
| 9607 | if ((idx >= PHY84833_HDSHK_WAIT) || |
| 9608 | (val == PHY84833_CMD_COMPLETE_ERROR)) { |
| 9609 | DP(NETIF_MSG_LINK, "Pairswap: override failed.\n"); |
| 9610 | return -EINVAL; |
| 9611 | } |
| 9612 | bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD, |
| 9613 | MDIO_84833_TOP_CFG_SCRATCH_REG2, |
| 9614 | PHY84833_CMD_CLEAR_COMPLETE); |
| 9615 | DP(NETIF_MSG_LINK, "Pairswap OK, val=0x%x\n", data); |
| 9616 | return 0; |
| 9617 | } |
| 9618 | |
Yaniv Rosner | 0d40f0d | 2011-06-14 01:34:27 +0000 | [diff] [blame] | 9619 | |
Yaniv Rosner | 985848f | 2011-07-05 01:06:48 +0000 | [diff] [blame] | 9620 | static u8 bnx2x_84833_get_reset_gpios(struct bnx2x *bp, |
| 9621 | u32 shmem_base_path[], |
| 9622 | u32 chip_id) |
Yaniv Rosner | 0d40f0d | 2011-06-14 01:34:27 +0000 | [diff] [blame] | 9623 | { |
| 9624 | u32 reset_pin[2]; |
| 9625 | u32 idx; |
| 9626 | u8 reset_gpios; |
| 9627 | if (CHIP_IS_E3(bp)) { |
| 9628 | /* Assume that these will be GPIOs, not EPIOs. */ |
| 9629 | for (idx = 0; idx < 2; idx++) { |
| 9630 | /* Map config param to register bit. */ |
| 9631 | reset_pin[idx] = REG_RD(bp, shmem_base_path[idx] + |
| 9632 | offsetof(struct shmem_region, |
| 9633 | dev_info.port_hw_config[0].e3_cmn_pin_cfg)); |
| 9634 | reset_pin[idx] = (reset_pin[idx] & |
| 9635 | PORT_HW_CFG_E3_PHY_RESET_MASK) >> |
| 9636 | PORT_HW_CFG_E3_PHY_RESET_SHIFT; |
| 9637 | reset_pin[idx] -= PIN_CFG_GPIO0_P0; |
| 9638 | reset_pin[idx] = (1 << reset_pin[idx]); |
| 9639 | } |
| 9640 | reset_gpios = (u8)(reset_pin[0] | reset_pin[1]); |
| 9641 | } else { |
| 9642 | /* E2, look from diff place of shmem. */ |
| 9643 | for (idx = 0; idx < 2; idx++) { |
| 9644 | reset_pin[idx] = REG_RD(bp, shmem_base_path[idx] + |
| 9645 | offsetof(struct shmem_region, |
| 9646 | dev_info.port_hw_config[0].default_cfg)); |
| 9647 | reset_pin[idx] &= PORT_HW_CFG_EXT_PHY_GPIO_RST_MASK; |
| 9648 | reset_pin[idx] -= PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO0_P0; |
| 9649 | reset_pin[idx] >>= PORT_HW_CFG_EXT_PHY_GPIO_RST_SHIFT; |
| 9650 | reset_pin[idx] = (1 << reset_pin[idx]); |
| 9651 | } |
| 9652 | reset_gpios = (u8)(reset_pin[0] | reset_pin[1]); |
| 9653 | } |
| 9654 | |
Yaniv Rosner | 985848f | 2011-07-05 01:06:48 +0000 | [diff] [blame] | 9655 | return reset_gpios; |
| 9656 | } |
| 9657 | |
| 9658 | static int bnx2x_84833_hw_reset_phy(struct bnx2x_phy *phy, |
| 9659 | struct link_params *params) |
| 9660 | { |
| 9661 | struct bnx2x *bp = params->bp; |
| 9662 | u8 reset_gpios; |
| 9663 | u32 other_shmem_base_addr = REG_RD(bp, params->shmem2_base + |
| 9664 | offsetof(struct shmem2_region, |
| 9665 | other_shmem_base_addr)); |
| 9666 | |
| 9667 | u32 shmem_base_path[2]; |
| 9668 | shmem_base_path[0] = params->shmem_base; |
| 9669 | shmem_base_path[1] = other_shmem_base_addr; |
| 9670 | |
| 9671 | reset_gpios = bnx2x_84833_get_reset_gpios(bp, shmem_base_path, |
| 9672 | params->chip_id); |
| 9673 | |
| 9674 | bnx2x_set_mult_gpio(bp, reset_gpios, MISC_REGISTERS_GPIO_OUTPUT_LOW); |
| 9675 | udelay(10); |
| 9676 | DP(NETIF_MSG_LINK, "84833 hw reset on pin values 0x%x\n", |
| 9677 | reset_gpios); |
| 9678 | |
| 9679 | return 0; |
| 9680 | } |
| 9681 | |
| 9682 | static int bnx2x_84833_common_init_phy(struct bnx2x *bp, |
| 9683 | u32 shmem_base_path[], |
| 9684 | u32 chip_id) |
| 9685 | { |
| 9686 | u8 reset_gpios; |
| 9687 | |
| 9688 | reset_gpios = bnx2x_84833_get_reset_gpios(bp, shmem_base_path, chip_id); |
| 9689 | |
Yaniv Rosner | 0d40f0d | 2011-06-14 01:34:27 +0000 | [diff] [blame] | 9690 | bnx2x_set_mult_gpio(bp, reset_gpios, MISC_REGISTERS_GPIO_OUTPUT_LOW); |
| 9691 | udelay(10); |
| 9692 | bnx2x_set_mult_gpio(bp, reset_gpios, MISC_REGISTERS_GPIO_OUTPUT_HIGH); |
| 9693 | msleep(800); |
| 9694 | DP(NETIF_MSG_LINK, "84833 reset pulse on pin values 0x%x\n", |
| 9695 | reset_gpios); |
| 9696 | |
| 9697 | return 0; |
| 9698 | } |
| 9699 | |
Yaniv Rosner | a89a1d4 | 2011-07-05 01:07:05 +0000 | [diff] [blame] | 9700 | #define PHY84833_CONSTANT_LATENCY 1193 |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 9701 | static int bnx2x_848x3_config_init(struct bnx2x_phy *phy, |
| 9702 | struct link_params *params, |
| 9703 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9704 | { |
| 9705 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 6a71bbe | 2010-11-01 05:32:31 +0000 | [diff] [blame] | 9706 | u8 port, initialize = 1; |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9707 | u16 val; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9708 | u16 temp; |
Yaniv Rosner | a89a1d4 | 2011-07-05 01:07:05 +0000 | [diff] [blame] | 9709 | u32 actual_phy_selection, cms_enable, idx; |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 9710 | int rc = 0; |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 9711 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9712 | msleep(1); |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9713 | |
| 9714 | if (!(CHIP_IS_E1(bp))) |
Yaniv Rosner | 6a71bbe | 2010-11-01 05:32:31 +0000 | [diff] [blame] | 9715 | port = BP_PATH(bp); |
| 9716 | else |
| 9717 | port = params->port; |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9718 | |
| 9719 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84823) { |
| 9720 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_3, |
| 9721 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, |
| 9722 | port); |
| 9723 | } else { |
Yaniv Rosner | 985848f | 2011-07-05 01:06:48 +0000 | [diff] [blame] | 9724 | /* MDIO reset */ |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9725 | bnx2x_cl45_write(bp, phy, |
| 9726 | MDIO_PMA_DEVAD, |
| 9727 | MDIO_PMA_REG_CTRL, 0x8000); |
Yaniv Rosner | 985848f | 2011-07-05 01:06:48 +0000 | [diff] [blame] | 9728 | /* Bring PHY out of super isolate mode */ |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9729 | bnx2x_cl45_read(bp, phy, |
| 9730 | MDIO_CTL_DEVAD, |
| 9731 | MDIO_84833_TOP_CFG_XGPHY_STRAP1, &val); |
| 9732 | val &= ~MDIO_84833_SUPER_ISOLATE; |
| 9733 | bnx2x_cl45_write(bp, phy, |
| 9734 | MDIO_CTL_DEVAD, |
| 9735 | MDIO_84833_TOP_CFG_XGPHY_STRAP1, val); |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9736 | } |
| 9737 | |
Yaniv Rosner | 985848f | 2011-07-05 01:06:48 +0000 | [diff] [blame] | 9738 | bnx2x_wait_reset_complete(bp, phy, params); |
| 9739 | |
| 9740 | /* Wait for GPHY to come out of reset */ |
| 9741 | msleep(50); |
| 9742 | |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9743 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833) |
| 9744 | bnx2x_84833_pair_swap_cfg(phy, params, vars); |
| 9745 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 9746 | /* |
| 9747 | * BCM84823 requires that XGXS links up first @ 10G for normal behavior |
| 9748 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9749 | temp = vars->line_speed; |
| 9750 | vars->line_speed = SPEED_10000; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 9751 | bnx2x_set_autoneg(¶ms->phy[INT_PHY], params, vars, 0); |
| 9752 | bnx2x_program_serdes(¶ms->phy[INT_PHY], params, vars); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9753 | vars->line_speed = temp; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 9754 | |
| 9755 | /* Set dual-media configuration according to configuration */ |
| 9756 | |
| 9757 | bnx2x_cl45_read(bp, phy, MDIO_CTL_DEVAD, |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9758 | MDIO_CTL_REG_84823_MEDIA, &val); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 9759 | val &= ~(MDIO_CTL_REG_84823_MEDIA_MAC_MASK | |
| 9760 | MDIO_CTL_REG_84823_MEDIA_LINE_MASK | |
| 9761 | MDIO_CTL_REG_84823_MEDIA_COPPER_CORE_DOWN | |
| 9762 | MDIO_CTL_REG_84823_MEDIA_PRIORITY_MASK | |
| 9763 | MDIO_CTL_REG_84823_MEDIA_FIBER_1G); |
Yaniv Rosner | 0d40f0d | 2011-06-14 01:34:27 +0000 | [diff] [blame] | 9764 | |
| 9765 | if (CHIP_IS_E3(bp)) { |
| 9766 | val &= ~(MDIO_CTL_REG_84823_MEDIA_MAC_MASK | |
| 9767 | MDIO_CTL_REG_84823_MEDIA_LINE_MASK); |
| 9768 | } else { |
| 9769 | val |= (MDIO_CTL_REG_84823_CTRL_MAC_XFI | |
| 9770 | MDIO_CTL_REG_84823_MEDIA_LINE_XAUI_L); |
| 9771 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 9772 | |
| 9773 | actual_phy_selection = bnx2x_phy_selection(params); |
| 9774 | |
| 9775 | switch (actual_phy_selection) { |
| 9776 | case PORT_HW_CFG_PHY_SELECTION_HARDWARE_DEFAULT: |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 9777 | /* Do nothing. Essentially this is like the priority copper */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 9778 | break; |
| 9779 | case PORT_HW_CFG_PHY_SELECTION_FIRST_PHY_PRIORITY: |
| 9780 | val |= MDIO_CTL_REG_84823_MEDIA_PRIORITY_COPPER; |
| 9781 | break; |
| 9782 | case PORT_HW_CFG_PHY_SELECTION_SECOND_PHY_PRIORITY: |
| 9783 | val |= MDIO_CTL_REG_84823_MEDIA_PRIORITY_FIBER; |
| 9784 | break; |
| 9785 | case PORT_HW_CFG_PHY_SELECTION_FIRST_PHY: |
| 9786 | /* Do nothing here. The first PHY won't be initialized at all */ |
| 9787 | break; |
| 9788 | case PORT_HW_CFG_PHY_SELECTION_SECOND_PHY: |
| 9789 | val |= MDIO_CTL_REG_84823_MEDIA_COPPER_CORE_DOWN; |
| 9790 | initialize = 0; |
| 9791 | break; |
| 9792 | } |
| 9793 | if (params->phy[EXT_PHY2].req_line_speed == SPEED_1000) |
| 9794 | val |= MDIO_CTL_REG_84823_MEDIA_FIBER_1G; |
| 9795 | |
| 9796 | bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD, |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9797 | MDIO_CTL_REG_84823_MEDIA, val); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 9798 | DP(NETIF_MSG_LINK, "Multi_phy config = 0x%x, Media control = 0x%x\n", |
| 9799 | params->multi_phy_config, val); |
| 9800 | |
Yaniv Rosner | a89a1d4 | 2011-07-05 01:07:05 +0000 | [diff] [blame] | 9801 | /* AutogrEEEn */ |
| 9802 | if (params->feature_config_flags & |
| 9803 | FEATURE_CONFIG_AUTOGREEEN_ENABLED) { |
| 9804 | /* Ensure that f/w is ready */ |
| 9805 | for (idx = 0; idx < PHY84833_HDSHK_WAIT; idx++) { |
| 9806 | bnx2x_cl45_read(bp, phy, MDIO_CTL_DEVAD, |
| 9807 | MDIO_84833_TOP_CFG_SCRATCH_REG2, &val); |
| 9808 | if (val == PHY84833_CMD_OPEN_FOR_CMDS) |
| 9809 | break; |
| 9810 | usleep_range(1000, 1000); |
| 9811 | } |
| 9812 | if (idx >= PHY84833_HDSHK_WAIT) { |
| 9813 | DP(NETIF_MSG_LINK, "AutogrEEEn: FW not ready.\n"); |
| 9814 | return -EINVAL; |
| 9815 | } |
| 9816 | |
| 9817 | /* Select EEE mode */ |
| 9818 | bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD, |
| 9819 | MDIO_84833_TOP_CFG_SCRATCH_REG3, |
| 9820 | 0x2); |
| 9821 | |
| 9822 | /* Set Idle and Latency */ |
| 9823 | bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD, |
| 9824 | MDIO_84833_TOP_CFG_SCRATCH_REG4, |
| 9825 | PHY84833_CONSTANT_LATENCY + 1); |
| 9826 | |
| 9827 | bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD, |
| 9828 | MDIO_84833_TOP_CFG_DATA3_REG, |
| 9829 | PHY84833_CONSTANT_LATENCY + 1); |
| 9830 | |
| 9831 | bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD, |
| 9832 | MDIO_84833_TOP_CFG_DATA4_REG, |
| 9833 | PHY84833_CONSTANT_LATENCY); |
| 9834 | |
| 9835 | /* Send EEE instruction to command register */ |
| 9836 | bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD, |
| 9837 | MDIO_84833_TOP_CFG_SCRATCH_REG0, |
| 9838 | PHY84833_DIAG_CMD_SET_EEE_MODE); |
| 9839 | |
| 9840 | /* Ensure that the command has completed */ |
| 9841 | for (idx = 0; idx < PHY84833_HDSHK_WAIT; idx++) { |
| 9842 | bnx2x_cl45_read(bp, phy, MDIO_CTL_DEVAD, |
| 9843 | MDIO_84833_TOP_CFG_SCRATCH_REG2, &val); |
| 9844 | if ((val == PHY84833_CMD_COMPLETE_PASS) || |
| 9845 | (val == PHY84833_CMD_COMPLETE_ERROR)) |
| 9846 | break; |
| 9847 | usleep_range(1000, 1000); |
| 9848 | } |
| 9849 | if ((idx >= PHY84833_HDSHK_WAIT) || |
| 9850 | (val == PHY84833_CMD_COMPLETE_ERROR)) { |
| 9851 | DP(NETIF_MSG_LINK, "AutogrEEEn: command failed.\n"); |
| 9852 | return -EINVAL; |
| 9853 | } |
| 9854 | |
| 9855 | /* Reset command handler */ |
| 9856 | bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD, |
| 9857 | MDIO_84833_TOP_CFG_SCRATCH_REG2, |
| 9858 | PHY84833_CMD_CLEAR_COMPLETE); |
| 9859 | } |
| 9860 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 9861 | if (initialize) |
| 9862 | rc = bnx2x_848xx_cmn_config_init(phy, params, vars); |
| 9863 | else |
| 9864 | bnx2x_save_848xx_spirom_version(phy, params); |
Yaniv Rosner | a89a1d4 | 2011-07-05 01:07:05 +0000 | [diff] [blame] | 9865 | /* 84833 PHY has a better feature and doesn't need to support this. */ |
| 9866 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84823) { |
| 9867 | cms_enable = REG_RD(bp, params->shmem_base + |
Yaniv Rosner | 1bef68e | 2011-01-31 04:22:46 +0000 | [diff] [blame] | 9868 | offsetof(struct shmem_region, |
| 9869 | dev_info.port_hw_config[params->port].default_cfg)) & |
| 9870 | PORT_HW_CFG_ENABLE_CMS_MASK; |
| 9871 | |
Yaniv Rosner | a89a1d4 | 2011-07-05 01:07:05 +0000 | [diff] [blame] | 9872 | bnx2x_cl45_read(bp, phy, MDIO_CTL_DEVAD, |
| 9873 | MDIO_CTL_REG_84823_USER_CTRL_REG, &val); |
| 9874 | if (cms_enable) |
| 9875 | val |= MDIO_CTL_REG_84823_USER_CTRL_CMS; |
| 9876 | else |
| 9877 | val &= ~MDIO_CTL_REG_84823_USER_CTRL_CMS; |
| 9878 | bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD, |
| 9879 | MDIO_CTL_REG_84823_USER_CTRL_REG, val); |
| 9880 | } |
Yaniv Rosner | 1bef68e | 2011-01-31 04:22:46 +0000 | [diff] [blame] | 9881 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 9882 | return rc; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9883 | } |
| 9884 | |
| 9885 | static u8 bnx2x_848xx_read_status(struct bnx2x_phy *phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 9886 | struct link_params *params, |
| 9887 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9888 | { |
| 9889 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9890 | u16 val, val1, val2; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9891 | u8 link_up = 0; |
| 9892 | |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 9893 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9894 | /* Check 10G-BaseT link status */ |
| 9895 | /* Check PMD signal ok */ |
| 9896 | bnx2x_cl45_read(bp, phy, |
| 9897 | MDIO_AN_DEVAD, 0xFFFA, &val1); |
| 9898 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9899 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8481_PMD_SIGNAL, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9900 | &val2); |
| 9901 | DP(NETIF_MSG_LINK, "BCM848xx: PMD_SIGNAL 1.a811 = 0x%x\n", val2); |
| 9902 | |
| 9903 | /* Check link 10G */ |
| 9904 | if (val2 & (1<<11)) { |
| 9905 | vars->line_speed = SPEED_10000; |
Yaniv Rosner | 791f18c | 2011-01-18 04:33:42 +0000 | [diff] [blame] | 9906 | vars->duplex = DUPLEX_FULL; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9907 | link_up = 1; |
| 9908 | bnx2x_ext_phy_10G_an_resolve(bp, phy, vars); |
| 9909 | } else { /* Check Legacy speed link */ |
| 9910 | u16 legacy_status, legacy_speed; |
| 9911 | |
| 9912 | /* Enable expansion register 0x42 (Operation mode status) */ |
| 9913 | bnx2x_cl45_write(bp, phy, |
| 9914 | MDIO_AN_DEVAD, |
| 9915 | MDIO_AN_REG_8481_EXPANSION_REG_ACCESS, 0xf42); |
| 9916 | |
| 9917 | /* Get legacy speed operation status */ |
| 9918 | bnx2x_cl45_read(bp, phy, |
| 9919 | MDIO_AN_DEVAD, |
| 9920 | MDIO_AN_REG_8481_EXPANSION_REG_RD_RW, |
| 9921 | &legacy_status); |
| 9922 | |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 9923 | DP(NETIF_MSG_LINK, "Legacy speed status = 0x%x\n", |
| 9924 | legacy_status); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9925 | link_up = ((legacy_status & (1<<11)) == (1<<11)); |
| 9926 | if (link_up) { |
| 9927 | legacy_speed = (legacy_status & (3<<9)); |
| 9928 | if (legacy_speed == (0<<9)) |
| 9929 | vars->line_speed = SPEED_10; |
| 9930 | else if (legacy_speed == (1<<9)) |
| 9931 | vars->line_speed = SPEED_100; |
| 9932 | else if (legacy_speed == (2<<9)) |
| 9933 | vars->line_speed = SPEED_1000; |
| 9934 | else /* Should not happen */ |
| 9935 | vars->line_speed = 0; |
| 9936 | |
| 9937 | if (legacy_status & (1<<8)) |
| 9938 | vars->duplex = DUPLEX_FULL; |
| 9939 | else |
| 9940 | vars->duplex = DUPLEX_HALF; |
| 9941 | |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 9942 | DP(NETIF_MSG_LINK, |
| 9943 | "Link is up in %dMbps, is_duplex_full= %d\n", |
| 9944 | vars->line_speed, |
| 9945 | (vars->duplex == DUPLEX_FULL)); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9946 | /* Check legacy speed AN resolution */ |
| 9947 | bnx2x_cl45_read(bp, phy, |
| 9948 | MDIO_AN_DEVAD, |
| 9949 | MDIO_AN_REG_8481_LEGACY_MII_STATUS, |
| 9950 | &val); |
| 9951 | if (val & (1<<5)) |
| 9952 | vars->link_status |= |
| 9953 | LINK_STATUS_AUTO_NEGOTIATE_COMPLETE; |
| 9954 | bnx2x_cl45_read(bp, phy, |
| 9955 | MDIO_AN_DEVAD, |
| 9956 | MDIO_AN_REG_8481_LEGACY_AN_EXPANSION, |
| 9957 | &val); |
| 9958 | if ((val & (1<<0)) == 0) |
| 9959 | vars->link_status |= |
| 9960 | LINK_STATUS_PARALLEL_DETECTION_USED; |
| 9961 | } |
| 9962 | } |
| 9963 | if (link_up) { |
| 9964 | DP(NETIF_MSG_LINK, "BCM84823: link speed is %d\n", |
| 9965 | vars->line_speed); |
| 9966 | bnx2x_ext_phy_resolve_fc(phy, params, vars); |
| 9967 | } |
| 9968 | |
| 9969 | return link_up; |
| 9970 | } |
| 9971 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 9972 | |
| 9973 | 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] | 9974 | { |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 9975 | int status = 0; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9976 | u32 spirom_ver; |
| 9977 | spirom_ver = ((raw_ver & 0xF80) >> 7) << 16 | (raw_ver & 0x7F); |
| 9978 | status = bnx2x_format_ver(spirom_ver, str, len); |
| 9979 | return status; |
| 9980 | } |
| 9981 | |
| 9982 | static void bnx2x_8481_hw_reset(struct bnx2x_phy *phy, |
| 9983 | struct link_params *params) |
| 9984 | { |
| 9985 | bnx2x_set_gpio(params->bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 9986 | MISC_REGISTERS_GPIO_OUTPUT_LOW, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9987 | bnx2x_set_gpio(params->bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 9988 | MISC_REGISTERS_GPIO_OUTPUT_LOW, 1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9989 | } |
| 9990 | |
| 9991 | static void bnx2x_8481_link_reset(struct bnx2x_phy *phy, |
| 9992 | struct link_params *params) |
| 9993 | { |
| 9994 | bnx2x_cl45_write(params->bp, phy, |
| 9995 | MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, 0x0000); |
| 9996 | bnx2x_cl45_write(params->bp, phy, |
| 9997 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 1); |
| 9998 | } |
| 9999 | |
| 10000 | static void bnx2x_848x3_link_reset(struct bnx2x_phy *phy, |
| 10001 | struct link_params *params) |
| 10002 | { |
| 10003 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 6a71bbe | 2010-11-01 05:32:31 +0000 | [diff] [blame] | 10004 | u8 port; |
Yaniv Rosner | 0d40f0d | 2011-06-14 01:34:27 +0000 | [diff] [blame] | 10005 | u16 val16; |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 10006 | |
| 10007 | if (!(CHIP_IS_E1(bp))) |
Yaniv Rosner | 6a71bbe | 2010-11-01 05:32:31 +0000 | [diff] [blame] | 10008 | port = BP_PATH(bp); |
| 10009 | else |
| 10010 | port = params->port; |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 10011 | |
| 10012 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84823) { |
| 10013 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_3, |
| 10014 | MISC_REGISTERS_GPIO_OUTPUT_LOW, |
| 10015 | port); |
| 10016 | } else { |
Yaniv Rosner | 0d40f0d | 2011-06-14 01:34:27 +0000 | [diff] [blame] | 10017 | bnx2x_cl45_read(bp, phy, |
| 10018 | MDIO_CTL_DEVAD, |
| 10019 | 0x400f, &val16); |
Yaniv Rosner | fd38f73e | 2011-08-02 22:59:53 +0000 | [diff] [blame] | 10020 | bnx2x_cl45_write(bp, phy, |
| 10021 | MDIO_PMA_DEVAD, |
| 10022 | MDIO_PMA_REG_CTRL, 0x800); |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 10023 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10024 | } |
| 10025 | |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10026 | static void bnx2x_848xx_set_link_led(struct bnx2x_phy *phy, |
| 10027 | struct link_params *params, u8 mode) |
| 10028 | { |
| 10029 | struct bnx2x *bp = params->bp; |
| 10030 | u16 val; |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 10031 | u8 port; |
| 10032 | |
| 10033 | if (!(CHIP_IS_E1(bp))) |
| 10034 | port = BP_PATH(bp); |
| 10035 | else |
| 10036 | port = params->port; |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10037 | |
| 10038 | switch (mode) { |
| 10039 | case LED_MODE_OFF: |
| 10040 | |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 10041 | DP(NETIF_MSG_LINK, "Port 0x%x: LED MODE OFF\n", port); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10042 | |
| 10043 | if ((params->hw_led_mode << SHARED_HW_CFG_LED_MODE_SHIFT) == |
| 10044 | SHARED_HW_CFG_LED_EXTPHY1) { |
| 10045 | |
| 10046 | /* Set LED masks */ |
| 10047 | bnx2x_cl45_write(bp, phy, |
| 10048 | MDIO_PMA_DEVAD, |
| 10049 | MDIO_PMA_REG_8481_LED1_MASK, |
| 10050 | 0x0); |
| 10051 | |
| 10052 | bnx2x_cl45_write(bp, phy, |
| 10053 | MDIO_PMA_DEVAD, |
| 10054 | MDIO_PMA_REG_8481_LED2_MASK, |
| 10055 | 0x0); |
| 10056 | |
| 10057 | bnx2x_cl45_write(bp, phy, |
| 10058 | MDIO_PMA_DEVAD, |
| 10059 | MDIO_PMA_REG_8481_LED3_MASK, |
| 10060 | 0x0); |
| 10061 | |
| 10062 | bnx2x_cl45_write(bp, phy, |
| 10063 | MDIO_PMA_DEVAD, |
| 10064 | MDIO_PMA_REG_8481_LED5_MASK, |
| 10065 | 0x0); |
| 10066 | |
| 10067 | } else { |
| 10068 | bnx2x_cl45_write(bp, phy, |
| 10069 | MDIO_PMA_DEVAD, |
| 10070 | MDIO_PMA_REG_8481_LED1_MASK, |
| 10071 | 0x0); |
| 10072 | } |
| 10073 | break; |
| 10074 | case LED_MODE_FRONT_PANEL_OFF: |
| 10075 | |
| 10076 | 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] | 10077 | port); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10078 | |
| 10079 | if ((params->hw_led_mode << SHARED_HW_CFG_LED_MODE_SHIFT) == |
| 10080 | SHARED_HW_CFG_LED_EXTPHY1) { |
| 10081 | |
| 10082 | /* Set LED masks */ |
| 10083 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10084 | MDIO_PMA_DEVAD, |
| 10085 | MDIO_PMA_REG_8481_LED1_MASK, |
| 10086 | 0x0); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10087 | |
| 10088 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10089 | MDIO_PMA_DEVAD, |
| 10090 | MDIO_PMA_REG_8481_LED2_MASK, |
| 10091 | 0x0); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10092 | |
| 10093 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10094 | MDIO_PMA_DEVAD, |
| 10095 | MDIO_PMA_REG_8481_LED3_MASK, |
| 10096 | 0x0); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10097 | |
| 10098 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10099 | MDIO_PMA_DEVAD, |
| 10100 | MDIO_PMA_REG_8481_LED5_MASK, |
| 10101 | 0x20); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10102 | |
| 10103 | } else { |
| 10104 | bnx2x_cl45_write(bp, phy, |
| 10105 | MDIO_PMA_DEVAD, |
| 10106 | MDIO_PMA_REG_8481_LED1_MASK, |
| 10107 | 0x0); |
| 10108 | } |
| 10109 | break; |
| 10110 | case LED_MODE_ON: |
| 10111 | |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 10112 | DP(NETIF_MSG_LINK, "Port 0x%x: LED MODE ON\n", port); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10113 | |
| 10114 | if ((params->hw_led_mode << SHARED_HW_CFG_LED_MODE_SHIFT) == |
| 10115 | SHARED_HW_CFG_LED_EXTPHY1) { |
| 10116 | /* Set control reg */ |
| 10117 | bnx2x_cl45_read(bp, phy, |
| 10118 | MDIO_PMA_DEVAD, |
| 10119 | MDIO_PMA_REG_8481_LINK_SIGNAL, |
| 10120 | &val); |
| 10121 | val &= 0x8000; |
| 10122 | val |= 0x2492; |
| 10123 | |
| 10124 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10125 | MDIO_PMA_DEVAD, |
| 10126 | MDIO_PMA_REG_8481_LINK_SIGNAL, |
| 10127 | val); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10128 | |
| 10129 | /* Set LED masks */ |
| 10130 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10131 | MDIO_PMA_DEVAD, |
| 10132 | MDIO_PMA_REG_8481_LED1_MASK, |
| 10133 | 0x0); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10134 | |
| 10135 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10136 | MDIO_PMA_DEVAD, |
| 10137 | MDIO_PMA_REG_8481_LED2_MASK, |
| 10138 | 0x20); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10139 | |
| 10140 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10141 | MDIO_PMA_DEVAD, |
| 10142 | MDIO_PMA_REG_8481_LED3_MASK, |
| 10143 | 0x20); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10144 | |
| 10145 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10146 | MDIO_PMA_DEVAD, |
| 10147 | MDIO_PMA_REG_8481_LED5_MASK, |
| 10148 | 0x0); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10149 | } else { |
| 10150 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10151 | MDIO_PMA_DEVAD, |
| 10152 | MDIO_PMA_REG_8481_LED1_MASK, |
| 10153 | 0x20); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10154 | } |
| 10155 | break; |
| 10156 | |
| 10157 | case LED_MODE_OPER: |
| 10158 | |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 10159 | DP(NETIF_MSG_LINK, "Port 0x%x: LED MODE OPER\n", port); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10160 | |
| 10161 | if ((params->hw_led_mode << SHARED_HW_CFG_LED_MODE_SHIFT) == |
| 10162 | SHARED_HW_CFG_LED_EXTPHY1) { |
| 10163 | |
| 10164 | /* Set control reg */ |
| 10165 | bnx2x_cl45_read(bp, phy, |
| 10166 | MDIO_PMA_DEVAD, |
| 10167 | MDIO_PMA_REG_8481_LINK_SIGNAL, |
| 10168 | &val); |
| 10169 | |
| 10170 | if (!((val & |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10171 | MDIO_PMA_REG_8481_LINK_SIGNAL_LED4_ENABLE_MASK) |
| 10172 | >> MDIO_PMA_REG_8481_LINK_SIGNAL_LED4_ENABLE_SHIFT)) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 10173 | DP(NETIF_MSG_LINK, "Setting LINK_SIGNAL\n"); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10174 | bnx2x_cl45_write(bp, phy, |
| 10175 | MDIO_PMA_DEVAD, |
| 10176 | MDIO_PMA_REG_8481_LINK_SIGNAL, |
| 10177 | 0xa492); |
| 10178 | } |
| 10179 | |
| 10180 | /* Set LED masks */ |
| 10181 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10182 | MDIO_PMA_DEVAD, |
| 10183 | MDIO_PMA_REG_8481_LED1_MASK, |
| 10184 | 0x10); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10185 | |
| 10186 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10187 | MDIO_PMA_DEVAD, |
| 10188 | MDIO_PMA_REG_8481_LED2_MASK, |
| 10189 | 0x80); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10190 | |
| 10191 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10192 | MDIO_PMA_DEVAD, |
| 10193 | MDIO_PMA_REG_8481_LED3_MASK, |
| 10194 | 0x98); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10195 | |
| 10196 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10197 | MDIO_PMA_DEVAD, |
| 10198 | MDIO_PMA_REG_8481_LED5_MASK, |
| 10199 | 0x40); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10200 | |
| 10201 | } else { |
| 10202 | bnx2x_cl45_write(bp, phy, |
| 10203 | MDIO_PMA_DEVAD, |
| 10204 | MDIO_PMA_REG_8481_LED1_MASK, |
| 10205 | 0x80); |
Yaniv Rosner | 53eda06 | 2011-01-30 04:14:55 +0000 | [diff] [blame] | 10206 | |
| 10207 | /* Tell LED3 to blink on source */ |
| 10208 | bnx2x_cl45_read(bp, phy, |
| 10209 | MDIO_PMA_DEVAD, |
| 10210 | MDIO_PMA_REG_8481_LINK_SIGNAL, |
| 10211 | &val); |
| 10212 | val &= ~(7<<6); |
| 10213 | val |= (1<<6); /* A83B[8:6]= 1 */ |
| 10214 | bnx2x_cl45_write(bp, phy, |
| 10215 | MDIO_PMA_DEVAD, |
| 10216 | MDIO_PMA_REG_8481_LINK_SIGNAL, |
| 10217 | val); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10218 | } |
| 10219 | break; |
| 10220 | } |
Yaniv Rosner | 0d40f0d | 2011-06-14 01:34:27 +0000 | [diff] [blame] | 10221 | |
| 10222 | /* |
| 10223 | * This is a workaround for E3+84833 until autoneg |
| 10224 | * restart is fixed in f/w |
| 10225 | */ |
| 10226 | if (CHIP_IS_E3(bp)) { |
| 10227 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 10228 | MDIO_WC_REG_GP2_STATUS_GP_2_1, &val); |
| 10229 | } |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10230 | } |
Yaniv Rosner | 0d40f0d | 2011-06-14 01:34:27 +0000 | [diff] [blame] | 10231 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10232 | /******************************************************************/ |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 10233 | /* 54618SE PHY SECTION */ |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 10234 | /******************************************************************/ |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 10235 | static int bnx2x_54618se_config_init(struct bnx2x_phy *phy, |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 10236 | struct link_params *params, |
| 10237 | struct link_vars *vars) |
| 10238 | { |
| 10239 | struct bnx2x *bp = params->bp; |
| 10240 | u8 port; |
| 10241 | u16 autoneg_val, an_1000_val, an_10_100_val, fc_val, temp; |
| 10242 | u32 cfg_pin; |
| 10243 | |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 10244 | DP(NETIF_MSG_LINK, "54618SE cfg init\n"); |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 10245 | usleep_range(1000, 1000); |
| 10246 | |
| 10247 | /* This works with E3 only, no need to check the chip |
| 10248 | before determining the port. */ |
| 10249 | port = params->port; |
| 10250 | |
| 10251 | cfg_pin = (REG_RD(bp, params->shmem_base + |
| 10252 | offsetof(struct shmem_region, |
| 10253 | dev_info.port_hw_config[port].e3_cmn_pin_cfg)) & |
| 10254 | PORT_HW_CFG_E3_PHY_RESET_MASK) >> |
| 10255 | PORT_HW_CFG_E3_PHY_RESET_SHIFT; |
| 10256 | |
| 10257 | /* Drive pin high to bring the GPHY out of reset. */ |
| 10258 | bnx2x_set_cfg_pin(bp, cfg_pin, 1); |
| 10259 | |
| 10260 | /* wait for GPHY to reset */ |
| 10261 | msleep(50); |
| 10262 | |
| 10263 | /* reset phy */ |
| 10264 | bnx2x_cl22_write(bp, phy, |
| 10265 | MDIO_PMA_REG_CTRL, 0x8000); |
| 10266 | bnx2x_wait_reset_complete(bp, phy, params); |
| 10267 | |
| 10268 | /*wait for GPHY to reset */ |
| 10269 | msleep(50); |
| 10270 | |
| 10271 | /* Configure LED4: set to INTR (0x6). */ |
| 10272 | /* Accessing shadow register 0xe. */ |
| 10273 | bnx2x_cl22_write(bp, phy, |
| 10274 | MDIO_REG_GPHY_SHADOW, |
| 10275 | MDIO_REG_GPHY_SHADOW_LED_SEL2); |
| 10276 | bnx2x_cl22_read(bp, phy, |
| 10277 | MDIO_REG_GPHY_SHADOW, |
| 10278 | &temp); |
| 10279 | temp &= ~(0xf << 4); |
| 10280 | temp |= (0x6 << 4); |
| 10281 | bnx2x_cl22_write(bp, phy, |
| 10282 | MDIO_REG_GPHY_SHADOW, |
| 10283 | MDIO_REG_GPHY_SHADOW_WR_ENA | temp); |
| 10284 | /* Configure INTR based on link status change. */ |
| 10285 | bnx2x_cl22_write(bp, phy, |
| 10286 | MDIO_REG_INTR_MASK, |
| 10287 | ~MDIO_REG_INTR_MASK_LINK_STATUS); |
| 10288 | |
| 10289 | /* Flip the signal detect polarity (set 0x1c.0x1e[8]). */ |
| 10290 | bnx2x_cl22_write(bp, phy, |
| 10291 | MDIO_REG_GPHY_SHADOW, |
| 10292 | MDIO_REG_GPHY_SHADOW_AUTO_DET_MED); |
| 10293 | bnx2x_cl22_read(bp, phy, |
| 10294 | MDIO_REG_GPHY_SHADOW, |
| 10295 | &temp); |
| 10296 | temp |= MDIO_REG_GPHY_SHADOW_INVERT_FIB_SD; |
| 10297 | bnx2x_cl22_write(bp, phy, |
| 10298 | MDIO_REG_GPHY_SHADOW, |
| 10299 | MDIO_REG_GPHY_SHADOW_WR_ENA | temp); |
| 10300 | |
| 10301 | /* Set up fc */ |
| 10302 | /* Please refer to Table 28B-3 of 802.3ab-1999 spec. */ |
| 10303 | bnx2x_calc_ieee_aneg_adv(phy, params, &vars->ieee_fc); |
| 10304 | fc_val = 0; |
| 10305 | if ((vars->ieee_fc & MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC) == |
| 10306 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC) |
| 10307 | fc_val |= MDIO_AN_REG_ADV_PAUSE_ASYMMETRIC; |
| 10308 | |
| 10309 | if ((vars->ieee_fc & MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) == |
| 10310 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) |
| 10311 | fc_val |= MDIO_AN_REG_ADV_PAUSE_PAUSE; |
| 10312 | |
| 10313 | /* read all advertisement */ |
| 10314 | bnx2x_cl22_read(bp, phy, |
| 10315 | 0x09, |
| 10316 | &an_1000_val); |
| 10317 | |
| 10318 | bnx2x_cl22_read(bp, phy, |
| 10319 | 0x04, |
| 10320 | &an_10_100_val); |
| 10321 | |
| 10322 | bnx2x_cl22_read(bp, phy, |
| 10323 | MDIO_PMA_REG_CTRL, |
| 10324 | &autoneg_val); |
| 10325 | |
| 10326 | /* Disable forced speed */ |
| 10327 | autoneg_val &= ~((1<<6) | (1<<8) | (1<<9) | (1<<12) | (1<<13)); |
| 10328 | an_10_100_val &= ~((1<<5) | (1<<6) | (1<<7) | (1<<8) | (1<<10) | |
| 10329 | (1<<11)); |
| 10330 | |
| 10331 | if (((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 10332 | (phy->speed_cap_mask & |
| 10333 | PORT_HW_CFG_SPEED_CAPABILITY_D0_1G)) || |
| 10334 | (phy->req_line_speed == SPEED_1000)) { |
| 10335 | an_1000_val |= (1<<8); |
| 10336 | autoneg_val |= (1<<9 | 1<<12); |
| 10337 | if (phy->req_duplex == DUPLEX_FULL) |
| 10338 | an_1000_val |= (1<<9); |
| 10339 | DP(NETIF_MSG_LINK, "Advertising 1G\n"); |
| 10340 | } else |
| 10341 | an_1000_val &= ~((1<<8) | (1<<9)); |
| 10342 | |
| 10343 | bnx2x_cl22_write(bp, phy, |
| 10344 | 0x09, |
| 10345 | an_1000_val); |
| 10346 | bnx2x_cl22_read(bp, phy, |
| 10347 | 0x09, |
| 10348 | &an_1000_val); |
| 10349 | |
| 10350 | /* set 100 speed advertisement */ |
| 10351 | if (((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 10352 | (phy->speed_cap_mask & |
| 10353 | (PORT_HW_CFG_SPEED_CAPABILITY_D0_100M_FULL | |
| 10354 | PORT_HW_CFG_SPEED_CAPABILITY_D0_100M_HALF)))) { |
| 10355 | an_10_100_val |= (1<<7); |
| 10356 | /* Enable autoneg and restart autoneg for legacy speeds */ |
| 10357 | autoneg_val |= (1<<9 | 1<<12); |
| 10358 | |
| 10359 | if (phy->req_duplex == DUPLEX_FULL) |
| 10360 | an_10_100_val |= (1<<8); |
| 10361 | DP(NETIF_MSG_LINK, "Advertising 100M\n"); |
| 10362 | } |
| 10363 | |
| 10364 | /* set 10 speed advertisement */ |
| 10365 | if (((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 10366 | (phy->speed_cap_mask & |
| 10367 | (PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_FULL | |
| 10368 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_HALF)))) { |
| 10369 | an_10_100_val |= (1<<5); |
| 10370 | autoneg_val |= (1<<9 | 1<<12); |
| 10371 | if (phy->req_duplex == DUPLEX_FULL) |
| 10372 | an_10_100_val |= (1<<6); |
| 10373 | DP(NETIF_MSG_LINK, "Advertising 10M\n"); |
| 10374 | } |
| 10375 | |
| 10376 | /* Only 10/100 are allowed to work in FORCE mode */ |
| 10377 | if (phy->req_line_speed == SPEED_100) { |
| 10378 | autoneg_val |= (1<<13); |
| 10379 | /* Enabled AUTO-MDIX when autoneg is disabled */ |
| 10380 | bnx2x_cl22_write(bp, phy, |
| 10381 | 0x18, |
| 10382 | (1<<15 | 1<<9 | 7<<0)); |
| 10383 | DP(NETIF_MSG_LINK, "Setting 100M force\n"); |
| 10384 | } |
| 10385 | if (phy->req_line_speed == SPEED_10) { |
| 10386 | /* Enabled AUTO-MDIX when autoneg is disabled */ |
| 10387 | bnx2x_cl22_write(bp, phy, |
| 10388 | 0x18, |
| 10389 | (1<<15 | 1<<9 | 7<<0)); |
| 10390 | DP(NETIF_MSG_LINK, "Setting 10M force\n"); |
| 10391 | } |
| 10392 | |
Yaniv Rosner | a89a1d4 | 2011-07-05 01:07:05 +0000 | [diff] [blame] | 10393 | /* Check if we should turn on Auto-GrEEEn */ |
| 10394 | bnx2x_cl22_read(bp, phy, MDIO_REG_GPHY_PHYID_LSB, &temp); |
| 10395 | if (temp == MDIO_REG_GPHY_ID_54618SE) { |
| 10396 | if (params->feature_config_flags & |
| 10397 | FEATURE_CONFIG_AUTOGREEEN_ENABLED) { |
| 10398 | temp = 6; |
| 10399 | DP(NETIF_MSG_LINK, "Enabling Auto-GrEEEn\n"); |
| 10400 | } else { |
| 10401 | temp = 0; |
| 10402 | DP(NETIF_MSG_LINK, "Disabling Auto-GrEEEn\n"); |
| 10403 | } |
| 10404 | bnx2x_cl22_write(bp, phy, |
| 10405 | MDIO_REG_GPHY_CL45_ADDR_REG, MDIO_AN_DEVAD); |
| 10406 | bnx2x_cl22_write(bp, phy, |
| 10407 | MDIO_REG_GPHY_CL45_DATA_REG, |
| 10408 | MDIO_REG_GPHY_EEE_ADV); |
| 10409 | bnx2x_cl22_write(bp, phy, |
| 10410 | MDIO_REG_GPHY_CL45_ADDR_REG, |
| 10411 | (0x1 << 14) | MDIO_AN_DEVAD); |
| 10412 | bnx2x_cl22_write(bp, phy, |
| 10413 | MDIO_REG_GPHY_CL45_DATA_REG, |
| 10414 | temp); |
| 10415 | } |
| 10416 | |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 10417 | bnx2x_cl22_write(bp, phy, |
| 10418 | 0x04, |
| 10419 | an_10_100_val | fc_val); |
| 10420 | |
| 10421 | if (phy->req_duplex == DUPLEX_FULL) |
| 10422 | autoneg_val |= (1<<8); |
| 10423 | |
| 10424 | bnx2x_cl22_write(bp, phy, |
| 10425 | MDIO_PMA_REG_CTRL, autoneg_val); |
| 10426 | |
| 10427 | return 0; |
| 10428 | } |
| 10429 | |
Yaniv Rosner | 1d125bd | 2011-11-23 03:54:08 +0000 | [diff] [blame] | 10430 | |
| 10431 | static void bnx2x_5461x_set_link_led(struct bnx2x_phy *phy, |
| 10432 | struct link_params *params, u8 mode) |
| 10433 | { |
| 10434 | struct bnx2x *bp = params->bp; |
| 10435 | u16 temp; |
| 10436 | |
| 10437 | bnx2x_cl22_write(bp, phy, |
| 10438 | MDIO_REG_GPHY_SHADOW, |
| 10439 | MDIO_REG_GPHY_SHADOW_LED_SEL1); |
| 10440 | bnx2x_cl22_read(bp, phy, |
| 10441 | MDIO_REG_GPHY_SHADOW, |
| 10442 | &temp); |
| 10443 | temp &= 0xff00; |
| 10444 | |
| 10445 | DP(NETIF_MSG_LINK, "54618x set link led (mode=%x)\n", mode); |
| 10446 | switch (mode) { |
| 10447 | case LED_MODE_FRONT_PANEL_OFF: |
| 10448 | case LED_MODE_OFF: |
| 10449 | temp |= 0x00ee; |
| 10450 | break; |
| 10451 | case LED_MODE_OPER: |
| 10452 | temp |= 0x0001; |
| 10453 | break; |
| 10454 | case LED_MODE_ON: |
| 10455 | temp |= 0x00ff; |
| 10456 | break; |
| 10457 | default: |
| 10458 | break; |
| 10459 | } |
| 10460 | bnx2x_cl22_write(bp, phy, |
| 10461 | MDIO_REG_GPHY_SHADOW, |
| 10462 | MDIO_REG_GPHY_SHADOW_WR_ENA | temp); |
| 10463 | return; |
| 10464 | } |
| 10465 | |
| 10466 | |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 10467 | static void bnx2x_54618se_link_reset(struct bnx2x_phy *phy, |
| 10468 | struct link_params *params) |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 10469 | { |
| 10470 | struct bnx2x *bp = params->bp; |
| 10471 | u32 cfg_pin; |
| 10472 | u8 port; |
| 10473 | |
Yaniv Rosner | d2059a0 | 2011-08-02 23:00:00 +0000 | [diff] [blame] | 10474 | /* |
| 10475 | * In case of no EPIO routed to reset the GPHY, put it |
| 10476 | * in low power mode. |
| 10477 | */ |
| 10478 | bnx2x_cl22_write(bp, phy, MDIO_PMA_REG_CTRL, 0x800); |
| 10479 | /* |
| 10480 | * This works with E3 only, no need to check the chip |
| 10481 | * before determining the port. |
| 10482 | */ |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 10483 | port = params->port; |
| 10484 | cfg_pin = (REG_RD(bp, params->shmem_base + |
| 10485 | offsetof(struct shmem_region, |
| 10486 | dev_info.port_hw_config[port].e3_cmn_pin_cfg)) & |
| 10487 | PORT_HW_CFG_E3_PHY_RESET_MASK) >> |
| 10488 | PORT_HW_CFG_E3_PHY_RESET_SHIFT; |
| 10489 | |
| 10490 | /* Drive pin low to put GPHY in reset. */ |
| 10491 | bnx2x_set_cfg_pin(bp, cfg_pin, 0); |
| 10492 | } |
| 10493 | |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 10494 | static u8 bnx2x_54618se_read_status(struct bnx2x_phy *phy, |
| 10495 | struct link_params *params, |
| 10496 | struct link_vars *vars) |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 10497 | { |
| 10498 | struct bnx2x *bp = params->bp; |
| 10499 | u16 val; |
| 10500 | u8 link_up = 0; |
| 10501 | u16 legacy_status, legacy_speed; |
| 10502 | |
| 10503 | /* Get speed operation status */ |
| 10504 | bnx2x_cl22_read(bp, phy, |
| 10505 | 0x19, |
| 10506 | &legacy_status); |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 10507 | DP(NETIF_MSG_LINK, "54618SE read_status: 0x%x\n", legacy_status); |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 10508 | |
| 10509 | /* Read status to clear the PHY interrupt. */ |
| 10510 | bnx2x_cl22_read(bp, phy, |
| 10511 | MDIO_REG_INTR_STATUS, |
| 10512 | &val); |
| 10513 | |
| 10514 | link_up = ((legacy_status & (1<<2)) == (1<<2)); |
| 10515 | |
| 10516 | if (link_up) { |
| 10517 | legacy_speed = (legacy_status & (7<<8)); |
| 10518 | if (legacy_speed == (7<<8)) { |
| 10519 | vars->line_speed = SPEED_1000; |
| 10520 | vars->duplex = DUPLEX_FULL; |
| 10521 | } else if (legacy_speed == (6<<8)) { |
| 10522 | vars->line_speed = SPEED_1000; |
| 10523 | vars->duplex = DUPLEX_HALF; |
| 10524 | } else if (legacy_speed == (5<<8)) { |
| 10525 | vars->line_speed = SPEED_100; |
| 10526 | vars->duplex = DUPLEX_FULL; |
| 10527 | } |
| 10528 | /* Omitting 100Base-T4 for now */ |
| 10529 | else if (legacy_speed == (3<<8)) { |
| 10530 | vars->line_speed = SPEED_100; |
| 10531 | vars->duplex = DUPLEX_HALF; |
| 10532 | } else if (legacy_speed == (2<<8)) { |
| 10533 | vars->line_speed = SPEED_10; |
| 10534 | vars->duplex = DUPLEX_FULL; |
| 10535 | } else if (legacy_speed == (1<<8)) { |
| 10536 | vars->line_speed = SPEED_10; |
| 10537 | vars->duplex = DUPLEX_HALF; |
| 10538 | } else /* Should not happen */ |
| 10539 | vars->line_speed = 0; |
| 10540 | |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 10541 | DP(NETIF_MSG_LINK, |
| 10542 | "Link is up in %dMbps, is_duplex_full= %d\n", |
| 10543 | vars->line_speed, |
| 10544 | (vars->duplex == DUPLEX_FULL)); |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 10545 | |
| 10546 | /* Check legacy speed AN resolution */ |
| 10547 | bnx2x_cl22_read(bp, phy, |
| 10548 | 0x01, |
| 10549 | &val); |
| 10550 | if (val & (1<<5)) |
| 10551 | vars->link_status |= |
| 10552 | LINK_STATUS_AUTO_NEGOTIATE_COMPLETE; |
| 10553 | bnx2x_cl22_read(bp, phy, |
| 10554 | 0x06, |
| 10555 | &val); |
| 10556 | if ((val & (1<<0)) == 0) |
| 10557 | vars->link_status |= |
| 10558 | LINK_STATUS_PARALLEL_DETECTION_USED; |
| 10559 | |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 10560 | DP(NETIF_MSG_LINK, "BCM54618SE: link speed is %d\n", |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 10561 | vars->line_speed); |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 10562 | |
| 10563 | /* Report whether EEE is resolved. */ |
| 10564 | bnx2x_cl22_read(bp, phy, MDIO_REG_GPHY_PHYID_LSB, &val); |
| 10565 | if (val == MDIO_REG_GPHY_ID_54618SE) { |
| 10566 | if (vars->link_status & |
| 10567 | LINK_STATUS_AUTO_NEGOTIATE_COMPLETE) |
| 10568 | val = 0; |
| 10569 | else { |
| 10570 | bnx2x_cl22_write(bp, phy, |
| 10571 | MDIO_REG_GPHY_CL45_ADDR_REG, |
| 10572 | MDIO_AN_DEVAD); |
| 10573 | bnx2x_cl22_write(bp, phy, |
| 10574 | MDIO_REG_GPHY_CL45_DATA_REG, |
| 10575 | MDIO_REG_GPHY_EEE_RESOLVED); |
| 10576 | bnx2x_cl22_write(bp, phy, |
| 10577 | MDIO_REG_GPHY_CL45_ADDR_REG, |
| 10578 | (0x1 << 14) | MDIO_AN_DEVAD); |
| 10579 | bnx2x_cl22_read(bp, phy, |
| 10580 | MDIO_REG_GPHY_CL45_DATA_REG, |
| 10581 | &val); |
| 10582 | } |
| 10583 | DP(NETIF_MSG_LINK, "EEE resolution: 0x%x\n", val); |
| 10584 | } |
| 10585 | |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 10586 | bnx2x_ext_phy_resolve_fc(phy, params, vars); |
| 10587 | } |
| 10588 | return link_up; |
| 10589 | } |
| 10590 | |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 10591 | static void bnx2x_54618se_config_loopback(struct bnx2x_phy *phy, |
| 10592 | struct link_params *params) |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 10593 | { |
| 10594 | struct bnx2x *bp = params->bp; |
| 10595 | u16 val; |
| 10596 | u32 umac_base = params->port ? GRCBASE_UMAC1 : GRCBASE_UMAC0; |
| 10597 | |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 10598 | DP(NETIF_MSG_LINK, "2PMA/PMD ext_phy_loopback: 54618se\n"); |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 10599 | |
| 10600 | /* Enable master/slave manual mmode and set to master */ |
| 10601 | /* mii write 9 [bits set 11 12] */ |
| 10602 | bnx2x_cl22_write(bp, phy, 0x09, 3<<11); |
| 10603 | |
| 10604 | /* forced 1G and disable autoneg */ |
| 10605 | /* set val [mii read 0] */ |
| 10606 | /* set val [expr $val & [bits clear 6 12 13]] */ |
| 10607 | /* set val [expr $val | [bits set 6 8]] */ |
| 10608 | /* mii write 0 $val */ |
| 10609 | bnx2x_cl22_read(bp, phy, 0x00, &val); |
| 10610 | val &= ~((1<<6) | (1<<12) | (1<<13)); |
| 10611 | val |= (1<<6) | (1<<8); |
| 10612 | bnx2x_cl22_write(bp, phy, 0x00, val); |
| 10613 | |
| 10614 | /* Set external loopback and Tx using 6dB coding */ |
| 10615 | /* mii write 0x18 7 */ |
| 10616 | /* set val [mii read 0x18] */ |
| 10617 | /* mii write 0x18 [expr $val | [bits set 10 15]] */ |
| 10618 | bnx2x_cl22_write(bp, phy, 0x18, 7); |
| 10619 | bnx2x_cl22_read(bp, phy, 0x18, &val); |
| 10620 | bnx2x_cl22_write(bp, phy, 0x18, val | (1<<10) | (1<<15)); |
| 10621 | |
| 10622 | /* This register opens the gate for the UMAC despite its name */ |
| 10623 | REG_WR(bp, NIG_REG_EGRESS_EMAC0_PORT + params->port*4, 1); |
| 10624 | |
| 10625 | /* |
| 10626 | * Maximum Frame Length (RW). Defines a 14-Bit maximum frame |
| 10627 | * length used by the MAC receive logic to check frames. |
| 10628 | */ |
| 10629 | REG_WR(bp, umac_base + UMAC_REG_MAXFR, 0x2710); |
| 10630 | } |
| 10631 | |
| 10632 | /******************************************************************/ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10633 | /* SFX7101 PHY SECTION */ |
| 10634 | /******************************************************************/ |
| 10635 | static void bnx2x_7101_config_loopback(struct bnx2x_phy *phy, |
| 10636 | struct link_params *params) |
| 10637 | { |
| 10638 | struct bnx2x *bp = params->bp; |
| 10639 | /* SFX7101_XGXS_TEST1 */ |
| 10640 | bnx2x_cl45_write(bp, phy, |
| 10641 | MDIO_XS_DEVAD, MDIO_XS_SFX7101_XGXS_TEST1, 0x100); |
| 10642 | } |
| 10643 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 10644 | static int bnx2x_7101_config_init(struct bnx2x_phy *phy, |
| 10645 | struct link_params *params, |
| 10646 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10647 | { |
| 10648 | u16 fw_ver1, fw_ver2, val; |
| 10649 | struct bnx2x *bp = params->bp; |
| 10650 | DP(NETIF_MSG_LINK, "Setting the SFX7101 LASI indication\n"); |
| 10651 | |
| 10652 | /* Restore normal power mode*/ |
| 10653 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10654 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, params->port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10655 | /* HW reset */ |
| 10656 | bnx2x_ext_phy_hw_reset(bp, params->port); |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 10657 | bnx2x_wait_reset_complete(bp, phy, params); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10658 | |
| 10659 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 10660 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_CTRL, 0x1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10661 | DP(NETIF_MSG_LINK, "Setting the SFX7101 LED to blink on traffic\n"); |
| 10662 | bnx2x_cl45_write(bp, phy, |
| 10663 | MDIO_PMA_DEVAD, MDIO_PMA_REG_7107_LED_CNTL, (1<<3)); |
| 10664 | |
| 10665 | bnx2x_ext_phy_set_pause(params, phy, vars); |
| 10666 | /* Restart autoneg */ |
| 10667 | bnx2x_cl45_read(bp, phy, |
| 10668 | MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, &val); |
| 10669 | val |= 0x200; |
| 10670 | bnx2x_cl45_write(bp, phy, |
| 10671 | MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, val); |
| 10672 | |
| 10673 | /* Save spirom version */ |
| 10674 | bnx2x_cl45_read(bp, phy, |
| 10675 | MDIO_PMA_DEVAD, MDIO_PMA_REG_7101_VER1, &fw_ver1); |
| 10676 | |
| 10677 | bnx2x_cl45_read(bp, phy, |
| 10678 | MDIO_PMA_DEVAD, MDIO_PMA_REG_7101_VER2, &fw_ver2); |
| 10679 | bnx2x_save_spirom_version(bp, params->port, |
| 10680 | (u32)(fw_ver1<<16 | fw_ver2), phy->ver_addr); |
| 10681 | return 0; |
| 10682 | } |
| 10683 | |
| 10684 | static u8 bnx2x_7101_read_status(struct bnx2x_phy *phy, |
| 10685 | struct link_params *params, |
| 10686 | struct link_vars *vars) |
| 10687 | { |
| 10688 | struct bnx2x *bp = params->bp; |
| 10689 | u8 link_up; |
| 10690 | u16 val1, val2; |
| 10691 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 10692 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_STAT, &val2); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10693 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 10694 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_STAT, &val1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10695 | DP(NETIF_MSG_LINK, "10G-base-T LASI status 0x%x->0x%x\n", |
| 10696 | val2, val1); |
| 10697 | bnx2x_cl45_read(bp, phy, |
| 10698 | MDIO_PMA_DEVAD, MDIO_PMA_REG_STATUS, &val2); |
| 10699 | bnx2x_cl45_read(bp, phy, |
| 10700 | MDIO_PMA_DEVAD, MDIO_PMA_REG_STATUS, &val1); |
| 10701 | DP(NETIF_MSG_LINK, "10G-base-T PMA status 0x%x->0x%x\n", |
| 10702 | val2, val1); |
| 10703 | link_up = ((val1 & 4) == 4); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 10704 | /* if link is up print the AN outcome of the SFX7101 PHY */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10705 | if (link_up) { |
| 10706 | bnx2x_cl45_read(bp, phy, |
| 10707 | MDIO_AN_DEVAD, MDIO_AN_REG_MASTER_STATUS, |
| 10708 | &val2); |
| 10709 | vars->line_speed = SPEED_10000; |
Yaniv Rosner | 791f18c | 2011-01-18 04:33:42 +0000 | [diff] [blame] | 10710 | vars->duplex = DUPLEX_FULL; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10711 | DP(NETIF_MSG_LINK, "SFX7101 AN status 0x%x->Master=%x\n", |
| 10712 | val2, (val2 & (1<<14))); |
| 10713 | bnx2x_ext_phy_10G_an_resolve(bp, phy, vars); |
| 10714 | bnx2x_ext_phy_resolve_fc(phy, params, vars); |
| 10715 | } |
| 10716 | return link_up; |
| 10717 | } |
| 10718 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 10719 | 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] | 10720 | { |
| 10721 | if (*len < 5) |
| 10722 | return -EINVAL; |
| 10723 | str[0] = (spirom_ver & 0xFF); |
| 10724 | str[1] = (spirom_ver & 0xFF00) >> 8; |
| 10725 | str[2] = (spirom_ver & 0xFF0000) >> 16; |
| 10726 | str[3] = (spirom_ver & 0xFF000000) >> 24; |
| 10727 | str[4] = '\0'; |
| 10728 | *len -= 5; |
| 10729 | return 0; |
| 10730 | } |
| 10731 | |
| 10732 | void bnx2x_sfx7101_sp_sw_reset(struct bnx2x *bp, struct bnx2x_phy *phy) |
| 10733 | { |
| 10734 | u16 val, cnt; |
| 10735 | |
| 10736 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10737 | MDIO_PMA_DEVAD, |
| 10738 | MDIO_PMA_REG_7101_RESET, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10739 | |
| 10740 | for (cnt = 0; cnt < 10; cnt++) { |
| 10741 | msleep(50); |
| 10742 | /* Writes a self-clearing reset */ |
| 10743 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10744 | MDIO_PMA_DEVAD, |
| 10745 | MDIO_PMA_REG_7101_RESET, |
| 10746 | (val | (1<<15))); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10747 | /* Wait for clear */ |
| 10748 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10749 | MDIO_PMA_DEVAD, |
| 10750 | MDIO_PMA_REG_7101_RESET, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10751 | |
| 10752 | if ((val & (1<<15)) == 0) |
| 10753 | break; |
| 10754 | } |
| 10755 | } |
| 10756 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10757 | static void bnx2x_7101_hw_reset(struct bnx2x_phy *phy, |
| 10758 | struct link_params *params) { |
| 10759 | /* Low power mode is controlled by GPIO 2 */ |
| 10760 | bnx2x_set_gpio(params->bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10761 | MISC_REGISTERS_GPIO_OUTPUT_LOW, params->port); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10762 | /* The PHY reset is controlled by GPIO 1 */ |
| 10763 | bnx2x_set_gpio(params->bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10764 | MISC_REGISTERS_GPIO_OUTPUT_LOW, params->port); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10765 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10766 | |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10767 | static void bnx2x_7101_set_link_led(struct bnx2x_phy *phy, |
| 10768 | struct link_params *params, u8 mode) |
| 10769 | { |
| 10770 | u16 val = 0; |
| 10771 | struct bnx2x *bp = params->bp; |
| 10772 | switch (mode) { |
| 10773 | case LED_MODE_FRONT_PANEL_OFF: |
| 10774 | case LED_MODE_OFF: |
| 10775 | val = 2; |
| 10776 | break; |
| 10777 | case LED_MODE_ON: |
| 10778 | val = 1; |
| 10779 | break; |
| 10780 | case LED_MODE_OPER: |
| 10781 | val = 0; |
| 10782 | break; |
| 10783 | } |
| 10784 | bnx2x_cl45_write(bp, phy, |
| 10785 | MDIO_PMA_DEVAD, |
| 10786 | MDIO_PMA_REG_7107_LINK_LED_CNTL, |
| 10787 | val); |
| 10788 | } |
| 10789 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10790 | /******************************************************************/ |
| 10791 | /* STATIC PHY DECLARATION */ |
| 10792 | /******************************************************************/ |
| 10793 | |
| 10794 | static struct bnx2x_phy phy_null = { |
| 10795 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_NOT_CONN, |
| 10796 | .addr = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10797 | .def_md_devad = 0, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 10798 | .flags = FLAGS_INIT_XGXS_FIRST, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10799 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 10800 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 10801 | .mdio_ctrl = 0, |
| 10802 | .supported = 0, |
| 10803 | .media_type = ETH_PHY_NOT_PRESENT, |
| 10804 | .ver_addr = 0, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10805 | .req_flow_ctrl = 0, |
| 10806 | .req_line_speed = 0, |
| 10807 | .speed_cap_mask = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10808 | .req_duplex = 0, |
| 10809 | .rsrv = 0, |
| 10810 | .config_init = (config_init_t)NULL, |
| 10811 | .read_status = (read_status_t)NULL, |
| 10812 | .link_reset = (link_reset_t)NULL, |
| 10813 | .config_loopback = (config_loopback_t)NULL, |
| 10814 | .format_fw_ver = (format_fw_ver_t)NULL, |
| 10815 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 10816 | .set_link_led = (set_link_led_t)NULL, |
| 10817 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10818 | }; |
| 10819 | |
| 10820 | static struct bnx2x_phy phy_serdes = { |
| 10821 | .type = PORT_HW_CFG_SERDES_EXT_PHY_TYPE_DIRECT, |
| 10822 | .addr = 0xff, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10823 | .def_md_devad = 0, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 10824 | .flags = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10825 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 10826 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 10827 | .mdio_ctrl = 0, |
| 10828 | .supported = (SUPPORTED_10baseT_Half | |
| 10829 | SUPPORTED_10baseT_Full | |
| 10830 | SUPPORTED_100baseT_Half | |
| 10831 | SUPPORTED_100baseT_Full | |
| 10832 | SUPPORTED_1000baseT_Full | |
| 10833 | SUPPORTED_2500baseX_Full | |
| 10834 | SUPPORTED_TP | |
| 10835 | SUPPORTED_Autoneg | |
| 10836 | SUPPORTED_Pause | |
| 10837 | SUPPORTED_Asym_Pause), |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 10838 | .media_type = ETH_PHY_BASE_T, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10839 | .ver_addr = 0, |
| 10840 | .req_flow_ctrl = 0, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10841 | .req_line_speed = 0, |
| 10842 | .speed_cap_mask = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10843 | .req_duplex = 0, |
| 10844 | .rsrv = 0, |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 10845 | .config_init = (config_init_t)bnx2x_xgxs_config_init, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10846 | .read_status = (read_status_t)bnx2x_link_settings_status, |
| 10847 | .link_reset = (link_reset_t)bnx2x_int_link_reset, |
| 10848 | .config_loopback = (config_loopback_t)NULL, |
| 10849 | .format_fw_ver = (format_fw_ver_t)NULL, |
| 10850 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 10851 | .set_link_led = (set_link_led_t)NULL, |
| 10852 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10853 | }; |
| 10854 | |
| 10855 | static struct bnx2x_phy phy_xgxs = { |
| 10856 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT, |
| 10857 | .addr = 0xff, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10858 | .def_md_devad = 0, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 10859 | .flags = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10860 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 10861 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 10862 | .mdio_ctrl = 0, |
| 10863 | .supported = (SUPPORTED_10baseT_Half | |
| 10864 | SUPPORTED_10baseT_Full | |
| 10865 | SUPPORTED_100baseT_Half | |
| 10866 | SUPPORTED_100baseT_Full | |
| 10867 | SUPPORTED_1000baseT_Full | |
| 10868 | SUPPORTED_2500baseX_Full | |
| 10869 | SUPPORTED_10000baseT_Full | |
| 10870 | SUPPORTED_FIBRE | |
| 10871 | SUPPORTED_Autoneg | |
| 10872 | SUPPORTED_Pause | |
| 10873 | SUPPORTED_Asym_Pause), |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 10874 | .media_type = ETH_PHY_CX4, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10875 | .ver_addr = 0, |
| 10876 | .req_flow_ctrl = 0, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10877 | .req_line_speed = 0, |
| 10878 | .speed_cap_mask = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10879 | .req_duplex = 0, |
| 10880 | .rsrv = 0, |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 10881 | .config_init = (config_init_t)bnx2x_xgxs_config_init, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10882 | .read_status = (read_status_t)bnx2x_link_settings_status, |
| 10883 | .link_reset = (link_reset_t)bnx2x_int_link_reset, |
| 10884 | .config_loopback = (config_loopback_t)bnx2x_set_xgxs_loopback, |
| 10885 | .format_fw_ver = (format_fw_ver_t)NULL, |
| 10886 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 10887 | .set_link_led = (set_link_led_t)NULL, |
| 10888 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10889 | }; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 10890 | static struct bnx2x_phy phy_warpcore = { |
| 10891 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT, |
| 10892 | .addr = 0xff, |
| 10893 | .def_md_devad = 0, |
David S. Miller | 8decf86 | 2011-09-22 03:23:13 -0400 | [diff] [blame] | 10894 | .flags = FLAGS_HW_LOCK_REQUIRED, |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 10895 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 10896 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 10897 | .mdio_ctrl = 0, |
| 10898 | .supported = (SUPPORTED_10baseT_Half | |
| 10899 | SUPPORTED_10baseT_Full | |
| 10900 | SUPPORTED_100baseT_Half | |
| 10901 | SUPPORTED_100baseT_Full | |
| 10902 | SUPPORTED_1000baseT_Full | |
| 10903 | SUPPORTED_10000baseT_Full | |
| 10904 | SUPPORTED_20000baseKR2_Full | |
| 10905 | SUPPORTED_20000baseMLD2_Full | |
| 10906 | SUPPORTED_FIBRE | |
| 10907 | SUPPORTED_Autoneg | |
| 10908 | SUPPORTED_Pause | |
| 10909 | SUPPORTED_Asym_Pause), |
| 10910 | .media_type = ETH_PHY_UNSPECIFIED, |
| 10911 | .ver_addr = 0, |
| 10912 | .req_flow_ctrl = 0, |
| 10913 | .req_line_speed = 0, |
| 10914 | .speed_cap_mask = 0, |
| 10915 | /* req_duplex = */0, |
| 10916 | /* rsrv = */0, |
| 10917 | .config_init = (config_init_t)bnx2x_warpcore_config_init, |
| 10918 | .read_status = (read_status_t)bnx2x_warpcore_read_status, |
| 10919 | .link_reset = (link_reset_t)bnx2x_warpcore_link_reset, |
| 10920 | .config_loopback = (config_loopback_t)bnx2x_set_warpcore_loopback, |
| 10921 | .format_fw_ver = (format_fw_ver_t)NULL, |
Yaniv Rosner | 985848f | 2011-07-05 01:06:48 +0000 | [diff] [blame] | 10922 | .hw_reset = (hw_reset_t)bnx2x_warpcore_hw_reset, |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 10923 | .set_link_led = (set_link_led_t)NULL, |
| 10924 | .phy_specific_func = (phy_specific_func_t)NULL |
| 10925 | }; |
| 10926 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10927 | |
| 10928 | static struct bnx2x_phy phy_7101 = { |
| 10929 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_SFX7101, |
| 10930 | .addr = 0xff, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10931 | .def_md_devad = 0, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 10932 | .flags = FLAGS_FAN_FAILURE_DET_REQ, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10933 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 10934 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 10935 | .mdio_ctrl = 0, |
| 10936 | .supported = (SUPPORTED_10000baseT_Full | |
| 10937 | SUPPORTED_TP | |
| 10938 | SUPPORTED_Autoneg | |
| 10939 | SUPPORTED_Pause | |
| 10940 | SUPPORTED_Asym_Pause), |
| 10941 | .media_type = ETH_PHY_BASE_T, |
| 10942 | .ver_addr = 0, |
| 10943 | .req_flow_ctrl = 0, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10944 | .req_line_speed = 0, |
| 10945 | .speed_cap_mask = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10946 | .req_duplex = 0, |
| 10947 | .rsrv = 0, |
| 10948 | .config_init = (config_init_t)bnx2x_7101_config_init, |
| 10949 | .read_status = (read_status_t)bnx2x_7101_read_status, |
| 10950 | .link_reset = (link_reset_t)bnx2x_common_ext_link_reset, |
| 10951 | .config_loopback = (config_loopback_t)bnx2x_7101_config_loopback, |
| 10952 | .format_fw_ver = (format_fw_ver_t)bnx2x_7101_format_ver, |
| 10953 | .hw_reset = (hw_reset_t)bnx2x_7101_hw_reset, |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10954 | .set_link_led = (set_link_led_t)bnx2x_7101_set_link_led, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 10955 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10956 | }; |
| 10957 | static struct bnx2x_phy phy_8073 = { |
| 10958 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073, |
| 10959 | .addr = 0xff, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10960 | .def_md_devad = 0, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 10961 | .flags = FLAGS_HW_LOCK_REQUIRED, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10962 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 10963 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 10964 | .mdio_ctrl = 0, |
| 10965 | .supported = (SUPPORTED_10000baseT_Full | |
| 10966 | SUPPORTED_2500baseX_Full | |
| 10967 | SUPPORTED_1000baseT_Full | |
| 10968 | SUPPORTED_FIBRE | |
| 10969 | SUPPORTED_Autoneg | |
| 10970 | SUPPORTED_Pause | |
| 10971 | SUPPORTED_Asym_Pause), |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 10972 | .media_type = ETH_PHY_KR, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10973 | .ver_addr = 0, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10974 | .req_flow_ctrl = 0, |
| 10975 | .req_line_speed = 0, |
| 10976 | .speed_cap_mask = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10977 | .req_duplex = 0, |
| 10978 | .rsrv = 0, |
Yaniv Rosner | 62b29a5 | 2010-09-07 11:40:58 +0000 | [diff] [blame] | 10979 | .config_init = (config_init_t)bnx2x_8073_config_init, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10980 | .read_status = (read_status_t)bnx2x_8073_read_status, |
| 10981 | .link_reset = (link_reset_t)bnx2x_8073_link_reset, |
| 10982 | .config_loopback = (config_loopback_t)NULL, |
| 10983 | .format_fw_ver = (format_fw_ver_t)bnx2x_format_ver, |
| 10984 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 10985 | .set_link_led = (set_link_led_t)NULL, |
| 10986 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10987 | }; |
| 10988 | static struct bnx2x_phy phy_8705 = { |
| 10989 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8705, |
| 10990 | .addr = 0xff, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10991 | .def_md_devad = 0, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 10992 | .flags = FLAGS_INIT_XGXS_FIRST, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10993 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 10994 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 10995 | .mdio_ctrl = 0, |
| 10996 | .supported = (SUPPORTED_10000baseT_Full | |
| 10997 | SUPPORTED_FIBRE | |
| 10998 | SUPPORTED_Pause | |
| 10999 | SUPPORTED_Asym_Pause), |
| 11000 | .media_type = ETH_PHY_XFP_FIBER, |
| 11001 | .ver_addr = 0, |
| 11002 | .req_flow_ctrl = 0, |
| 11003 | .req_line_speed = 0, |
| 11004 | .speed_cap_mask = 0, |
| 11005 | .req_duplex = 0, |
| 11006 | .rsrv = 0, |
| 11007 | .config_init = (config_init_t)bnx2x_8705_config_init, |
| 11008 | .read_status = (read_status_t)bnx2x_8705_read_status, |
| 11009 | .link_reset = (link_reset_t)bnx2x_common_ext_link_reset, |
| 11010 | .config_loopback = (config_loopback_t)NULL, |
| 11011 | .format_fw_ver = (format_fw_ver_t)bnx2x_null_format_ver, |
| 11012 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11013 | .set_link_led = (set_link_led_t)NULL, |
| 11014 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11015 | }; |
| 11016 | static struct bnx2x_phy phy_8706 = { |
| 11017 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8706, |
| 11018 | .addr = 0xff, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11019 | .def_md_devad = 0, |
David S. Miller | 8decf86 | 2011-09-22 03:23:13 -0400 | [diff] [blame] | 11020 | .flags = FLAGS_INIT_XGXS_FIRST, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11021 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11022 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11023 | .mdio_ctrl = 0, |
| 11024 | .supported = (SUPPORTED_10000baseT_Full | |
| 11025 | SUPPORTED_1000baseT_Full | |
| 11026 | SUPPORTED_FIBRE | |
| 11027 | SUPPORTED_Pause | |
| 11028 | SUPPORTED_Asym_Pause), |
| 11029 | .media_type = ETH_PHY_SFP_FIBER, |
| 11030 | .ver_addr = 0, |
| 11031 | .req_flow_ctrl = 0, |
| 11032 | .req_line_speed = 0, |
| 11033 | .speed_cap_mask = 0, |
| 11034 | .req_duplex = 0, |
| 11035 | .rsrv = 0, |
| 11036 | .config_init = (config_init_t)bnx2x_8706_config_init, |
| 11037 | .read_status = (read_status_t)bnx2x_8706_read_status, |
| 11038 | .link_reset = (link_reset_t)bnx2x_common_ext_link_reset, |
| 11039 | .config_loopback = (config_loopback_t)NULL, |
| 11040 | .format_fw_ver = (format_fw_ver_t)bnx2x_format_ver, |
| 11041 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11042 | .set_link_led = (set_link_led_t)NULL, |
| 11043 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11044 | }; |
| 11045 | |
| 11046 | static struct bnx2x_phy phy_8726 = { |
| 11047 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726, |
| 11048 | .addr = 0xff, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 11049 | .def_md_devad = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11050 | .flags = (FLAGS_HW_LOCK_REQUIRED | |
David S. Miller | 8decf86 | 2011-09-22 03:23:13 -0400 | [diff] [blame] | 11051 | FLAGS_INIT_XGXS_FIRST), |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11052 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11053 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11054 | .mdio_ctrl = 0, |
| 11055 | .supported = (SUPPORTED_10000baseT_Full | |
| 11056 | SUPPORTED_1000baseT_Full | |
| 11057 | SUPPORTED_Autoneg | |
| 11058 | SUPPORTED_FIBRE | |
| 11059 | SUPPORTED_Pause | |
| 11060 | SUPPORTED_Asym_Pause), |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 11061 | .media_type = ETH_PHY_NOT_PRESENT, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11062 | .ver_addr = 0, |
| 11063 | .req_flow_ctrl = 0, |
| 11064 | .req_line_speed = 0, |
| 11065 | .speed_cap_mask = 0, |
| 11066 | .req_duplex = 0, |
| 11067 | .rsrv = 0, |
| 11068 | .config_init = (config_init_t)bnx2x_8726_config_init, |
| 11069 | .read_status = (read_status_t)bnx2x_8726_read_status, |
| 11070 | .link_reset = (link_reset_t)bnx2x_8726_link_reset, |
| 11071 | .config_loopback = (config_loopback_t)bnx2x_8726_config_loopback, |
| 11072 | .format_fw_ver = (format_fw_ver_t)bnx2x_format_ver, |
| 11073 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11074 | .set_link_led = (set_link_led_t)NULL, |
| 11075 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11076 | }; |
| 11077 | |
| 11078 | static struct bnx2x_phy phy_8727 = { |
| 11079 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727, |
| 11080 | .addr = 0xff, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11081 | .def_md_devad = 0, |
David S. Miller | 8decf86 | 2011-09-22 03:23:13 -0400 | [diff] [blame] | 11082 | .flags = FLAGS_FAN_FAILURE_DET_REQ, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11083 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11084 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11085 | .mdio_ctrl = 0, |
| 11086 | .supported = (SUPPORTED_10000baseT_Full | |
| 11087 | SUPPORTED_1000baseT_Full | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11088 | SUPPORTED_FIBRE | |
| 11089 | SUPPORTED_Pause | |
| 11090 | SUPPORTED_Asym_Pause), |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 11091 | .media_type = ETH_PHY_NOT_PRESENT, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11092 | .ver_addr = 0, |
| 11093 | .req_flow_ctrl = 0, |
| 11094 | .req_line_speed = 0, |
| 11095 | .speed_cap_mask = 0, |
| 11096 | .req_duplex = 0, |
| 11097 | .rsrv = 0, |
| 11098 | .config_init = (config_init_t)bnx2x_8727_config_init, |
| 11099 | .read_status = (read_status_t)bnx2x_8727_read_status, |
| 11100 | .link_reset = (link_reset_t)bnx2x_8727_link_reset, |
| 11101 | .config_loopback = (config_loopback_t)NULL, |
| 11102 | .format_fw_ver = (format_fw_ver_t)bnx2x_format_ver, |
| 11103 | .hw_reset = (hw_reset_t)bnx2x_8727_hw_reset, |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 11104 | .set_link_led = (set_link_led_t)bnx2x_8727_set_link_led, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11105 | .phy_specific_func = (phy_specific_func_t)bnx2x_8727_specific_func |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11106 | }; |
| 11107 | static struct bnx2x_phy phy_8481 = { |
| 11108 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8481, |
| 11109 | .addr = 0xff, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 11110 | .def_md_devad = 0, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11111 | .flags = FLAGS_FAN_FAILURE_DET_REQ | |
| 11112 | FLAGS_REARM_LATCH_SIGNAL, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11113 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11114 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11115 | .mdio_ctrl = 0, |
| 11116 | .supported = (SUPPORTED_10baseT_Half | |
| 11117 | SUPPORTED_10baseT_Full | |
| 11118 | SUPPORTED_100baseT_Half | |
| 11119 | SUPPORTED_100baseT_Full | |
| 11120 | SUPPORTED_1000baseT_Full | |
| 11121 | SUPPORTED_10000baseT_Full | |
| 11122 | SUPPORTED_TP | |
| 11123 | SUPPORTED_Autoneg | |
| 11124 | SUPPORTED_Pause | |
| 11125 | SUPPORTED_Asym_Pause), |
| 11126 | .media_type = ETH_PHY_BASE_T, |
| 11127 | .ver_addr = 0, |
| 11128 | .req_flow_ctrl = 0, |
| 11129 | .req_line_speed = 0, |
| 11130 | .speed_cap_mask = 0, |
| 11131 | .req_duplex = 0, |
| 11132 | .rsrv = 0, |
| 11133 | .config_init = (config_init_t)bnx2x_8481_config_init, |
| 11134 | .read_status = (read_status_t)bnx2x_848xx_read_status, |
| 11135 | .link_reset = (link_reset_t)bnx2x_8481_link_reset, |
| 11136 | .config_loopback = (config_loopback_t)NULL, |
| 11137 | .format_fw_ver = (format_fw_ver_t)bnx2x_848xx_format_ver, |
| 11138 | .hw_reset = (hw_reset_t)bnx2x_8481_hw_reset, |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 11139 | .set_link_led = (set_link_led_t)bnx2x_848xx_set_link_led, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11140 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11141 | }; |
| 11142 | |
| 11143 | static struct bnx2x_phy phy_84823 = { |
| 11144 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84823, |
| 11145 | .addr = 0xff, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 11146 | .def_md_devad = 0, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11147 | .flags = FLAGS_FAN_FAILURE_DET_REQ | |
| 11148 | FLAGS_REARM_LATCH_SIGNAL, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11149 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11150 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11151 | .mdio_ctrl = 0, |
| 11152 | .supported = (SUPPORTED_10baseT_Half | |
| 11153 | SUPPORTED_10baseT_Full | |
| 11154 | SUPPORTED_100baseT_Half | |
| 11155 | SUPPORTED_100baseT_Full | |
| 11156 | SUPPORTED_1000baseT_Full | |
| 11157 | SUPPORTED_10000baseT_Full | |
| 11158 | SUPPORTED_TP | |
| 11159 | SUPPORTED_Autoneg | |
| 11160 | SUPPORTED_Pause | |
| 11161 | SUPPORTED_Asym_Pause), |
| 11162 | .media_type = ETH_PHY_BASE_T, |
| 11163 | .ver_addr = 0, |
| 11164 | .req_flow_ctrl = 0, |
| 11165 | .req_line_speed = 0, |
| 11166 | .speed_cap_mask = 0, |
| 11167 | .req_duplex = 0, |
| 11168 | .rsrv = 0, |
| 11169 | .config_init = (config_init_t)bnx2x_848x3_config_init, |
| 11170 | .read_status = (read_status_t)bnx2x_848xx_read_status, |
| 11171 | .link_reset = (link_reset_t)bnx2x_848x3_link_reset, |
| 11172 | .config_loopback = (config_loopback_t)NULL, |
| 11173 | .format_fw_ver = (format_fw_ver_t)bnx2x_848xx_format_ver, |
| 11174 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 11175 | .set_link_led = (set_link_led_t)bnx2x_848xx_set_link_led, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11176 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11177 | }; |
| 11178 | |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 11179 | static struct bnx2x_phy phy_84833 = { |
| 11180 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833, |
| 11181 | .addr = 0xff, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 11182 | .def_md_devad = 0, |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 11183 | .flags = FLAGS_FAN_FAILURE_DET_REQ | |
| 11184 | FLAGS_REARM_LATCH_SIGNAL, |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 11185 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11186 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11187 | .mdio_ctrl = 0, |
Yaniv Rosner | 0520e63 | 2011-07-05 01:06:59 +0000 | [diff] [blame] | 11188 | .supported = (SUPPORTED_100baseT_Half | |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 11189 | SUPPORTED_100baseT_Full | |
| 11190 | SUPPORTED_1000baseT_Full | |
| 11191 | SUPPORTED_10000baseT_Full | |
| 11192 | SUPPORTED_TP | |
| 11193 | SUPPORTED_Autoneg | |
| 11194 | SUPPORTED_Pause | |
| 11195 | SUPPORTED_Asym_Pause), |
| 11196 | .media_type = ETH_PHY_BASE_T, |
| 11197 | .ver_addr = 0, |
| 11198 | .req_flow_ctrl = 0, |
| 11199 | .req_line_speed = 0, |
| 11200 | .speed_cap_mask = 0, |
| 11201 | .req_duplex = 0, |
| 11202 | .rsrv = 0, |
| 11203 | .config_init = (config_init_t)bnx2x_848x3_config_init, |
| 11204 | .read_status = (read_status_t)bnx2x_848xx_read_status, |
| 11205 | .link_reset = (link_reset_t)bnx2x_848x3_link_reset, |
| 11206 | .config_loopback = (config_loopback_t)NULL, |
| 11207 | .format_fw_ver = (format_fw_ver_t)bnx2x_848xx_format_ver, |
Yaniv Rosner | 985848f | 2011-07-05 01:06:48 +0000 | [diff] [blame] | 11208 | .hw_reset = (hw_reset_t)bnx2x_84833_hw_reset_phy, |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 11209 | .set_link_led = (set_link_led_t)bnx2x_848xx_set_link_led, |
| 11210 | .phy_specific_func = (phy_specific_func_t)NULL |
| 11211 | }; |
| 11212 | |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 11213 | static struct bnx2x_phy phy_54618se = { |
| 11214 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54618SE, |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 11215 | .addr = 0xff, |
| 11216 | .def_md_devad = 0, |
| 11217 | .flags = FLAGS_INIT_XGXS_FIRST, |
| 11218 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11219 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11220 | .mdio_ctrl = 0, |
| 11221 | .supported = (SUPPORTED_10baseT_Half | |
| 11222 | SUPPORTED_10baseT_Full | |
| 11223 | SUPPORTED_100baseT_Half | |
| 11224 | SUPPORTED_100baseT_Full | |
| 11225 | SUPPORTED_1000baseT_Full | |
| 11226 | SUPPORTED_TP | |
| 11227 | SUPPORTED_Autoneg | |
| 11228 | SUPPORTED_Pause | |
| 11229 | SUPPORTED_Asym_Pause), |
| 11230 | .media_type = ETH_PHY_BASE_T, |
| 11231 | .ver_addr = 0, |
| 11232 | .req_flow_ctrl = 0, |
| 11233 | .req_line_speed = 0, |
| 11234 | .speed_cap_mask = 0, |
| 11235 | /* req_duplex = */0, |
| 11236 | /* rsrv = */0, |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 11237 | .config_init = (config_init_t)bnx2x_54618se_config_init, |
| 11238 | .read_status = (read_status_t)bnx2x_54618se_read_status, |
| 11239 | .link_reset = (link_reset_t)bnx2x_54618se_link_reset, |
| 11240 | .config_loopback = (config_loopback_t)bnx2x_54618se_config_loopback, |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 11241 | .format_fw_ver = (format_fw_ver_t)NULL, |
| 11242 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | 1d125bd | 2011-11-23 03:54:08 +0000 | [diff] [blame] | 11243 | .set_link_led = (set_link_led_t)bnx2x_5461x_set_link_led, |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 11244 | .phy_specific_func = (phy_specific_func_t)NULL |
| 11245 | }; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11246 | /*****************************************************************/ |
| 11247 | /* */ |
| 11248 | /* Populate the phy according. Main function: bnx2x_populate_phy */ |
| 11249 | /* */ |
| 11250 | /*****************************************************************/ |
| 11251 | |
| 11252 | static void bnx2x_populate_preemphasis(struct bnx2x *bp, u32 shmem_base, |
| 11253 | struct bnx2x_phy *phy, u8 port, |
| 11254 | u8 phy_index) |
| 11255 | { |
| 11256 | /* Get the 4 lanes xgxs config rx and tx */ |
| 11257 | u32 rx = 0, tx = 0, i; |
| 11258 | for (i = 0; i < 2; i++) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 11259 | /* |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11260 | * INT_PHY and EXT_PHY1 share the same value location in the |
| 11261 | * shmem. When num_phys is greater than 1, than this value |
| 11262 | * applies only to EXT_PHY1 |
| 11263 | */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11264 | if (phy_index == INT_PHY || phy_index == EXT_PHY1) { |
| 11265 | rx = REG_RD(bp, shmem_base + |
| 11266 | offsetof(struct shmem_region, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11267 | dev_info.port_hw_config[port].xgxs_config_rx[i<<1])); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11268 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11269 | tx = REG_RD(bp, shmem_base + |
| 11270 | offsetof(struct shmem_region, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11271 | dev_info.port_hw_config[port].xgxs_config_tx[i<<1])); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11272 | } else { |
| 11273 | rx = REG_RD(bp, shmem_base + |
| 11274 | offsetof(struct shmem_region, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11275 | dev_info.port_hw_config[port].xgxs_config2_rx[i<<1])); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11276 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11277 | tx = REG_RD(bp, shmem_base + |
| 11278 | offsetof(struct shmem_region, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11279 | dev_info.port_hw_config[port].xgxs_config2_rx[i<<1])); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11280 | } |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11281 | |
| 11282 | phy->rx_preemphasis[i << 1] = ((rx>>16) & 0xffff); |
| 11283 | phy->rx_preemphasis[(i << 1) + 1] = (rx & 0xffff); |
| 11284 | |
| 11285 | phy->tx_preemphasis[i << 1] = ((tx>>16) & 0xffff); |
| 11286 | phy->tx_preemphasis[(i << 1) + 1] = (tx & 0xffff); |
| 11287 | } |
| 11288 | } |
| 11289 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 11290 | static u32 bnx2x_get_ext_phy_config(struct bnx2x *bp, u32 shmem_base, |
| 11291 | u8 phy_index, u8 port) |
| 11292 | { |
| 11293 | u32 ext_phy_config = 0; |
| 11294 | switch (phy_index) { |
| 11295 | case EXT_PHY1: |
| 11296 | ext_phy_config = REG_RD(bp, shmem_base + |
| 11297 | offsetof(struct shmem_region, |
| 11298 | dev_info.port_hw_config[port].external_phy_config)); |
| 11299 | break; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11300 | case EXT_PHY2: |
| 11301 | ext_phy_config = REG_RD(bp, shmem_base + |
| 11302 | offsetof(struct shmem_region, |
| 11303 | dev_info.port_hw_config[port].external_phy_config2)); |
| 11304 | break; |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 11305 | default: |
| 11306 | DP(NETIF_MSG_LINK, "Invalid phy_index %d\n", phy_index); |
| 11307 | return -EINVAL; |
| 11308 | } |
| 11309 | |
| 11310 | return ext_phy_config; |
| 11311 | } |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 11312 | static int bnx2x_populate_int_phy(struct bnx2x *bp, u32 shmem_base, u8 port, |
| 11313 | struct bnx2x_phy *phy) |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11314 | { |
| 11315 | u32 phy_addr; |
| 11316 | u32 chip_id; |
| 11317 | u32 switch_cfg = (REG_RD(bp, shmem_base + |
| 11318 | offsetof(struct shmem_region, |
| 11319 | dev_info.port_feature_config[port].link_config)) & |
| 11320 | PORT_FEATURE_CONNECTED_SWITCH_MASK); |
| 11321 | chip_id = REG_RD(bp, MISC_REG_CHIP_NUM) << 16; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 11322 | DP(NETIF_MSG_LINK, ":chip_id = 0x%x\n", chip_id); |
| 11323 | if (USES_WARPCORE(bp)) { |
| 11324 | u32 serdes_net_if; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11325 | phy_addr = REG_RD(bp, |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 11326 | MISC_REG_WC0_CTRL_PHY_ADDR); |
| 11327 | *phy = phy_warpcore; |
| 11328 | if (REG_RD(bp, MISC_REG_PORT4MODE_EN_OVWR) == 0x3) |
| 11329 | phy->flags |= FLAGS_4_PORT_MODE; |
| 11330 | else |
| 11331 | phy->flags &= ~FLAGS_4_PORT_MODE; |
| 11332 | /* Check Dual mode */ |
| 11333 | serdes_net_if = (REG_RD(bp, shmem_base + |
| 11334 | offsetof(struct shmem_region, dev_info. |
| 11335 | port_hw_config[port].default_cfg)) & |
| 11336 | PORT_HW_CFG_NET_SERDES_IF_MASK); |
| 11337 | /* |
| 11338 | * Set the appropriate supported and flags indications per |
| 11339 | * interface type of the chip |
| 11340 | */ |
| 11341 | switch (serdes_net_if) { |
| 11342 | case PORT_HW_CFG_NET_SERDES_IF_SGMII: |
| 11343 | phy->supported &= (SUPPORTED_10baseT_Half | |
| 11344 | SUPPORTED_10baseT_Full | |
| 11345 | SUPPORTED_100baseT_Half | |
| 11346 | SUPPORTED_100baseT_Full | |
| 11347 | SUPPORTED_1000baseT_Full | |
| 11348 | SUPPORTED_FIBRE | |
| 11349 | SUPPORTED_Autoneg | |
| 11350 | SUPPORTED_Pause | |
| 11351 | SUPPORTED_Asym_Pause); |
| 11352 | phy->media_type = ETH_PHY_BASE_T; |
| 11353 | break; |
| 11354 | case PORT_HW_CFG_NET_SERDES_IF_XFI: |
| 11355 | phy->media_type = ETH_PHY_XFP_FIBER; |
| 11356 | break; |
| 11357 | case PORT_HW_CFG_NET_SERDES_IF_SFI: |
| 11358 | phy->supported &= (SUPPORTED_1000baseT_Full | |
| 11359 | SUPPORTED_10000baseT_Full | |
| 11360 | SUPPORTED_FIBRE | |
| 11361 | SUPPORTED_Pause | |
| 11362 | SUPPORTED_Asym_Pause); |
| 11363 | phy->media_type = ETH_PHY_SFP_FIBER; |
| 11364 | break; |
| 11365 | case PORT_HW_CFG_NET_SERDES_IF_KR: |
| 11366 | phy->media_type = ETH_PHY_KR; |
| 11367 | phy->supported &= (SUPPORTED_1000baseT_Full | |
| 11368 | SUPPORTED_10000baseT_Full | |
| 11369 | SUPPORTED_FIBRE | |
| 11370 | SUPPORTED_Autoneg | |
| 11371 | SUPPORTED_Pause | |
| 11372 | SUPPORTED_Asym_Pause); |
| 11373 | break; |
| 11374 | case PORT_HW_CFG_NET_SERDES_IF_DXGXS: |
| 11375 | phy->media_type = ETH_PHY_KR; |
| 11376 | phy->flags |= FLAGS_WC_DUAL_MODE; |
| 11377 | phy->supported &= (SUPPORTED_20000baseMLD2_Full | |
| 11378 | SUPPORTED_FIBRE | |
| 11379 | SUPPORTED_Pause | |
| 11380 | SUPPORTED_Asym_Pause); |
| 11381 | break; |
| 11382 | case PORT_HW_CFG_NET_SERDES_IF_KR2: |
| 11383 | phy->media_type = ETH_PHY_KR; |
| 11384 | phy->flags |= FLAGS_WC_DUAL_MODE; |
| 11385 | phy->supported &= (SUPPORTED_20000baseKR2_Full | |
| 11386 | SUPPORTED_FIBRE | |
| 11387 | SUPPORTED_Pause | |
| 11388 | SUPPORTED_Asym_Pause); |
| 11389 | break; |
| 11390 | default: |
| 11391 | DP(NETIF_MSG_LINK, "Unknown WC interface type 0x%x\n", |
| 11392 | serdes_net_if); |
| 11393 | break; |
| 11394 | } |
| 11395 | |
| 11396 | /* |
| 11397 | * Enable MDC/MDIO work-around for E3 A0 since free running MDC |
| 11398 | * was not set as expected. For B0, ECO will be enabled so there |
| 11399 | * won't be an issue there |
| 11400 | */ |
| 11401 | if (CHIP_REV(bp) == CHIP_REV_Ax) |
| 11402 | phy->flags |= FLAGS_MDC_MDIO_WA; |
Yaniv Rosner | 157fa28 | 2011-08-02 22:59:32 +0000 | [diff] [blame] | 11403 | else |
| 11404 | phy->flags |= FLAGS_MDC_MDIO_WA_B0; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 11405 | } else { |
| 11406 | switch (switch_cfg) { |
| 11407 | case SWITCH_CFG_1G: |
| 11408 | phy_addr = REG_RD(bp, |
| 11409 | NIG_REG_SERDES0_CTRL_PHY_ADDR + |
| 11410 | port * 0x10); |
| 11411 | *phy = phy_serdes; |
| 11412 | break; |
| 11413 | case SWITCH_CFG_10G: |
| 11414 | phy_addr = REG_RD(bp, |
| 11415 | NIG_REG_XGXS0_CTRL_PHY_ADDR + |
| 11416 | port * 0x18); |
| 11417 | *phy = phy_xgxs; |
| 11418 | break; |
| 11419 | default: |
| 11420 | DP(NETIF_MSG_LINK, "Invalid switch_cfg\n"); |
| 11421 | return -EINVAL; |
| 11422 | } |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11423 | } |
| 11424 | phy->addr = (u8)phy_addr; |
| 11425 | phy->mdio_ctrl = bnx2x_get_emac_base(bp, |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 11426 | SHARED_HW_CFG_MDC_MDIO_ACCESS1_BOTH, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11427 | port); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 11428 | if (CHIP_IS_E2(bp)) |
| 11429 | phy->def_md_devad = E2_DEFAULT_PHY_DEV_ADDR; |
| 11430 | else |
| 11431 | phy->def_md_devad = DEFAULT_PHY_DEV_ADDR; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11432 | |
| 11433 | DP(NETIF_MSG_LINK, "Internal phy port=%d, addr=0x%x, mdio_ctl=0x%x\n", |
| 11434 | port, phy->addr, phy->mdio_ctrl); |
| 11435 | |
| 11436 | bnx2x_populate_preemphasis(bp, shmem_base, phy, port, INT_PHY); |
| 11437 | return 0; |
| 11438 | } |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 11439 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 11440 | static int bnx2x_populate_ext_phy(struct bnx2x *bp, |
| 11441 | u8 phy_index, |
| 11442 | u32 shmem_base, |
| 11443 | u32 shmem2_base, |
| 11444 | u8 port, |
| 11445 | struct bnx2x_phy *phy) |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 11446 | { |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 11447 | u32 ext_phy_config, phy_type, config2; |
| 11448 | u32 mdc_mdio_access = SHARED_HW_CFG_MDC_MDIO_ACCESS1_BOTH; |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 11449 | ext_phy_config = bnx2x_get_ext_phy_config(bp, shmem_base, |
| 11450 | phy_index, port); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11451 | phy_type = XGXS_EXT_PHY_TYPE(ext_phy_config); |
| 11452 | /* Select the phy type */ |
| 11453 | switch (phy_type) { |
| 11454 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073: |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 11455 | mdc_mdio_access = SHARED_HW_CFG_MDC_MDIO_ACCESS1_SWAPPED; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11456 | *phy = phy_8073; |
| 11457 | break; |
| 11458 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8705: |
| 11459 | *phy = phy_8705; |
| 11460 | break; |
| 11461 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8706: |
| 11462 | *phy = phy_8706; |
| 11463 | break; |
| 11464 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726: |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 11465 | mdc_mdio_access = SHARED_HW_CFG_MDC_MDIO_ACCESS1_EMAC1; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11466 | *phy = phy_8726; |
| 11467 | break; |
| 11468 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727_NOC: |
| 11469 | /* BCM8727_NOC => BCM8727 no over current */ |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 11470 | mdc_mdio_access = SHARED_HW_CFG_MDC_MDIO_ACCESS1_EMAC1; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11471 | *phy = phy_8727; |
| 11472 | phy->flags |= FLAGS_NOC; |
| 11473 | break; |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 11474 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8722: |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11475 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727: |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 11476 | mdc_mdio_access = SHARED_HW_CFG_MDC_MDIO_ACCESS1_EMAC1; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11477 | *phy = phy_8727; |
| 11478 | break; |
| 11479 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8481: |
| 11480 | *phy = phy_8481; |
| 11481 | break; |
| 11482 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84823: |
| 11483 | *phy = phy_84823; |
| 11484 | break; |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 11485 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833: |
| 11486 | *phy = phy_84833; |
| 11487 | break; |
Yaniv Rosner | 3756a89 | 2011-08-23 06:33:24 +0000 | [diff] [blame] | 11488 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54616: |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 11489 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54618SE: |
| 11490 | *phy = phy_54618se; |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 11491 | break; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11492 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_SFX7101: |
| 11493 | *phy = phy_7101; |
| 11494 | break; |
| 11495 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_FAILURE: |
| 11496 | *phy = phy_null; |
| 11497 | return -EINVAL; |
| 11498 | default: |
| 11499 | *phy = phy_null; |
| 11500 | return 0; |
| 11501 | } |
| 11502 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 11503 | phy->addr = XGXS_EXT_PHY_ADDR(ext_phy_config); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11504 | bnx2x_populate_preemphasis(bp, shmem_base, phy, port, phy_index); |
Yaniv Rosner | 62b29a5 | 2010-09-07 11:40:58 +0000 | [diff] [blame] | 11505 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 11506 | /* |
| 11507 | * The shmem address of the phy version is located on different |
| 11508 | * structures. In case this structure is too old, do not set |
| 11509 | * the address |
| 11510 | */ |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 11511 | config2 = REG_RD(bp, shmem_base + offsetof(struct shmem_region, |
| 11512 | dev_info.shared_hw_config.config2)); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11513 | if (phy_index == EXT_PHY1) { |
| 11514 | phy->ver_addr = shmem_base + offsetof(struct shmem_region, |
| 11515 | port_mb[port].ext_phy_fw_version); |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 11516 | |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11517 | /* Check specific mdc mdio settings */ |
| 11518 | if (config2 & SHARED_HW_CFG_MDC_MDIO_ACCESS1_MASK) |
| 11519 | mdc_mdio_access = config2 & |
| 11520 | SHARED_HW_CFG_MDC_MDIO_ACCESS1_MASK; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11521 | } else { |
| 11522 | u32 size = REG_RD(bp, shmem2_base); |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 11523 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11524 | if (size > |
| 11525 | offsetof(struct shmem2_region, ext_phy_fw_version2)) { |
| 11526 | phy->ver_addr = shmem2_base + |
| 11527 | offsetof(struct shmem2_region, |
| 11528 | ext_phy_fw_version2[port]); |
| 11529 | } |
| 11530 | /* Check specific mdc mdio settings */ |
| 11531 | if (config2 & SHARED_HW_CFG_MDC_MDIO_ACCESS2_MASK) |
| 11532 | mdc_mdio_access = (config2 & |
| 11533 | SHARED_HW_CFG_MDC_MDIO_ACCESS2_MASK) >> |
| 11534 | (SHARED_HW_CFG_MDC_MDIO_ACCESS2_SHIFT - |
| 11535 | SHARED_HW_CFG_MDC_MDIO_ACCESS1_SHIFT); |
| 11536 | } |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 11537 | phy->mdio_ctrl = bnx2x_get_emac_base(bp, mdc_mdio_access, port); |
| 11538 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 11539 | /* |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 11540 | * In case mdc/mdio_access of the external phy is different than the |
| 11541 | * mdc/mdio access of the XGXS, a HW lock must be taken in each access |
| 11542 | * to prevent one port interfere with another port's CL45 operations. |
| 11543 | */ |
| 11544 | if (mdc_mdio_access != SHARED_HW_CFG_MDC_MDIO_ACCESS1_BOTH) |
| 11545 | phy->flags |= FLAGS_HW_LOCK_REQUIRED; |
| 11546 | DP(NETIF_MSG_LINK, "phy_type 0x%x port %d found in index %d\n", |
| 11547 | phy_type, port, phy_index); |
| 11548 | DP(NETIF_MSG_LINK, " addr=0x%x, mdio_ctl=0x%x\n", |
| 11549 | phy->addr, phy->mdio_ctrl); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 11550 | return 0; |
| 11551 | } |
| 11552 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 11553 | static int bnx2x_populate_phy(struct bnx2x *bp, u8 phy_index, u32 shmem_base, |
| 11554 | u32 shmem2_base, u8 port, struct bnx2x_phy *phy) |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 11555 | { |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 11556 | int status = 0; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11557 | phy->type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_NOT_CONN; |
| 11558 | if (phy_index == INT_PHY) |
| 11559 | return bnx2x_populate_int_phy(bp, shmem_base, port, phy); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11560 | status = bnx2x_populate_ext_phy(bp, phy_index, shmem_base, shmem2_base, |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 11561 | port, phy); |
| 11562 | return status; |
| 11563 | } |
| 11564 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11565 | static void bnx2x_phy_def_cfg(struct link_params *params, |
| 11566 | struct bnx2x_phy *phy, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11567 | u8 phy_index) |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11568 | { |
| 11569 | struct bnx2x *bp = params->bp; |
| 11570 | u32 link_config; |
| 11571 | /* Populate the default phy configuration for MF mode */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11572 | if (phy_index == EXT_PHY2) { |
| 11573 | link_config = REG_RD(bp, params->shmem_base + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11574 | offsetof(struct shmem_region, dev_info. |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11575 | port_feature_config[params->port].link_config2)); |
| 11576 | phy->speed_cap_mask = REG_RD(bp, params->shmem_base + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11577 | offsetof(struct shmem_region, |
| 11578 | dev_info. |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11579 | port_hw_config[params->port].speed_capability_mask2)); |
| 11580 | } else { |
| 11581 | link_config = REG_RD(bp, params->shmem_base + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11582 | offsetof(struct shmem_region, dev_info. |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11583 | port_feature_config[params->port].link_config)); |
| 11584 | phy->speed_cap_mask = REG_RD(bp, params->shmem_base + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11585 | offsetof(struct shmem_region, |
| 11586 | dev_info. |
| 11587 | port_hw_config[params->port].speed_capability_mask)); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11588 | } |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 11589 | DP(NETIF_MSG_LINK, |
| 11590 | "Default config phy idx %x cfg 0x%x speed_cap_mask 0x%x\n", |
| 11591 | phy_index, link_config, phy->speed_cap_mask); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11592 | |
| 11593 | phy->req_duplex = DUPLEX_FULL; |
| 11594 | switch (link_config & PORT_FEATURE_LINK_SPEED_MASK) { |
| 11595 | case PORT_FEATURE_LINK_SPEED_10M_HALF: |
| 11596 | phy->req_duplex = DUPLEX_HALF; |
| 11597 | case PORT_FEATURE_LINK_SPEED_10M_FULL: |
| 11598 | phy->req_line_speed = SPEED_10; |
| 11599 | break; |
| 11600 | case PORT_FEATURE_LINK_SPEED_100M_HALF: |
| 11601 | phy->req_duplex = DUPLEX_HALF; |
| 11602 | case PORT_FEATURE_LINK_SPEED_100M_FULL: |
| 11603 | phy->req_line_speed = SPEED_100; |
| 11604 | break; |
| 11605 | case PORT_FEATURE_LINK_SPEED_1G: |
| 11606 | phy->req_line_speed = SPEED_1000; |
| 11607 | break; |
| 11608 | case PORT_FEATURE_LINK_SPEED_2_5G: |
| 11609 | phy->req_line_speed = SPEED_2500; |
| 11610 | break; |
| 11611 | case PORT_FEATURE_LINK_SPEED_10G_CX4: |
| 11612 | phy->req_line_speed = SPEED_10000; |
| 11613 | break; |
| 11614 | default: |
| 11615 | phy->req_line_speed = SPEED_AUTO_NEG; |
| 11616 | break; |
| 11617 | } |
| 11618 | |
| 11619 | switch (link_config & PORT_FEATURE_FLOW_CONTROL_MASK) { |
| 11620 | case PORT_FEATURE_FLOW_CONTROL_AUTO: |
| 11621 | phy->req_flow_ctrl = BNX2X_FLOW_CTRL_AUTO; |
| 11622 | break; |
| 11623 | case PORT_FEATURE_FLOW_CONTROL_TX: |
| 11624 | phy->req_flow_ctrl = BNX2X_FLOW_CTRL_TX; |
| 11625 | break; |
| 11626 | case PORT_FEATURE_FLOW_CONTROL_RX: |
| 11627 | phy->req_flow_ctrl = BNX2X_FLOW_CTRL_RX; |
| 11628 | break; |
| 11629 | case PORT_FEATURE_FLOW_CONTROL_BOTH: |
| 11630 | phy->req_flow_ctrl = BNX2X_FLOW_CTRL_BOTH; |
| 11631 | break; |
| 11632 | default: |
| 11633 | phy->req_flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 11634 | break; |
| 11635 | } |
| 11636 | } |
| 11637 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11638 | u32 bnx2x_phy_selection(struct link_params *params) |
| 11639 | { |
| 11640 | u32 phy_config_swapped, prio_cfg; |
| 11641 | u32 return_cfg = PORT_HW_CFG_PHY_SELECTION_HARDWARE_DEFAULT; |
| 11642 | |
| 11643 | phy_config_swapped = params->multi_phy_config & |
| 11644 | PORT_HW_CFG_PHY_SWAPPED_ENABLED; |
| 11645 | |
| 11646 | prio_cfg = params->multi_phy_config & |
| 11647 | PORT_HW_CFG_PHY_SELECTION_MASK; |
| 11648 | |
| 11649 | if (phy_config_swapped) { |
| 11650 | switch (prio_cfg) { |
| 11651 | case PORT_HW_CFG_PHY_SELECTION_FIRST_PHY_PRIORITY: |
| 11652 | return_cfg = PORT_HW_CFG_PHY_SELECTION_SECOND_PHY_PRIORITY; |
| 11653 | break; |
| 11654 | case PORT_HW_CFG_PHY_SELECTION_SECOND_PHY_PRIORITY: |
| 11655 | return_cfg = PORT_HW_CFG_PHY_SELECTION_FIRST_PHY_PRIORITY; |
| 11656 | break; |
| 11657 | case PORT_HW_CFG_PHY_SELECTION_SECOND_PHY: |
| 11658 | return_cfg = PORT_HW_CFG_PHY_SELECTION_FIRST_PHY; |
| 11659 | break; |
| 11660 | case PORT_HW_CFG_PHY_SELECTION_FIRST_PHY: |
| 11661 | return_cfg = PORT_HW_CFG_PHY_SELECTION_SECOND_PHY; |
| 11662 | break; |
| 11663 | } |
| 11664 | } else |
| 11665 | return_cfg = prio_cfg; |
| 11666 | |
| 11667 | return return_cfg; |
| 11668 | } |
| 11669 | |
| 11670 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 11671 | int bnx2x_phy_probe(struct link_params *params) |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11672 | { |
| 11673 | u8 phy_index, actual_phy_idx, link_cfg_idx; |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 11674 | u32 phy_config_swapped, sync_offset, media_types; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11675 | struct bnx2x *bp = params->bp; |
| 11676 | struct bnx2x_phy *phy; |
| 11677 | params->num_phys = 0; |
| 11678 | DP(NETIF_MSG_LINK, "Begin phy probe\n"); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11679 | phy_config_swapped = params->multi_phy_config & |
| 11680 | PORT_HW_CFG_PHY_SWAPPED_ENABLED; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11681 | |
| 11682 | for (phy_index = INT_PHY; phy_index < MAX_PHYS; |
| 11683 | phy_index++) { |
| 11684 | link_cfg_idx = LINK_CONFIG_IDX(phy_index); |
| 11685 | actual_phy_idx = phy_index; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11686 | if (phy_config_swapped) { |
| 11687 | if (phy_index == EXT_PHY1) |
| 11688 | actual_phy_idx = EXT_PHY2; |
| 11689 | else if (phy_index == EXT_PHY2) |
| 11690 | actual_phy_idx = EXT_PHY1; |
| 11691 | } |
| 11692 | DP(NETIF_MSG_LINK, "phy_config_swapped %x, phy_index %x," |
| 11693 | " actual_phy_idx %x\n", phy_config_swapped, |
| 11694 | phy_index, actual_phy_idx); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11695 | phy = ¶ms->phy[actual_phy_idx]; |
| 11696 | if (bnx2x_populate_phy(bp, phy_index, params->shmem_base, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11697 | params->shmem2_base, params->port, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11698 | phy) != 0) { |
| 11699 | params->num_phys = 0; |
| 11700 | DP(NETIF_MSG_LINK, "phy probe failed in phy index %d\n", |
| 11701 | phy_index); |
| 11702 | for (phy_index = INT_PHY; |
| 11703 | phy_index < MAX_PHYS; |
| 11704 | phy_index++) |
| 11705 | *phy = phy_null; |
| 11706 | return -EINVAL; |
| 11707 | } |
| 11708 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_NOT_CONN) |
| 11709 | break; |
| 11710 | |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 11711 | sync_offset = params->shmem_base + |
| 11712 | offsetof(struct shmem_region, |
| 11713 | dev_info.port_hw_config[params->port].media_type); |
| 11714 | media_types = REG_RD(bp, sync_offset); |
| 11715 | |
| 11716 | /* |
| 11717 | * Update media type for non-PMF sync only for the first time |
| 11718 | * In case the media type changes afterwards, it will be updated |
| 11719 | * using the update_status function |
| 11720 | */ |
| 11721 | if ((media_types & (PORT_HW_CFG_MEDIA_TYPE_PHY0_MASK << |
| 11722 | (PORT_HW_CFG_MEDIA_TYPE_PHY1_SHIFT * |
| 11723 | actual_phy_idx))) == 0) { |
| 11724 | media_types |= ((phy->media_type & |
| 11725 | PORT_HW_CFG_MEDIA_TYPE_PHY0_MASK) << |
| 11726 | (PORT_HW_CFG_MEDIA_TYPE_PHY1_SHIFT * |
| 11727 | actual_phy_idx)); |
| 11728 | } |
| 11729 | REG_WR(bp, sync_offset, media_types); |
| 11730 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11731 | bnx2x_phy_def_cfg(params, phy, phy_index); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11732 | params->num_phys++; |
| 11733 | } |
| 11734 | |
| 11735 | DP(NETIF_MSG_LINK, "End phy probe. #phys found %x\n", params->num_phys); |
| 11736 | return 0; |
| 11737 | } |
| 11738 | |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 11739 | void bnx2x_init_bmac_loopback(struct link_params *params, |
| 11740 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11741 | { |
| 11742 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 11743 | vars->link_up = 1; |
| 11744 | vars->line_speed = SPEED_10000; |
| 11745 | vars->duplex = DUPLEX_FULL; |
| 11746 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 11747 | vars->mac_type = MAC_TYPE_BMAC; |
| 11748 | |
| 11749 | vars->phy_flags = PHY_XGXS_FLAG; |
| 11750 | |
| 11751 | bnx2x_xgxs_deassert(params); |
| 11752 | |
| 11753 | /* set bmac loopback */ |
| 11754 | bnx2x_bmac_enable(params, vars, 1); |
| 11755 | |
| 11756 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + params->port*4, 0); |
| 11757 | } |
| 11758 | |
| 11759 | void bnx2x_init_emac_loopback(struct link_params *params, |
| 11760 | struct link_vars *vars) |
| 11761 | { |
| 11762 | struct bnx2x *bp = params->bp; |
| 11763 | vars->link_up = 1; |
| 11764 | vars->line_speed = SPEED_1000; |
| 11765 | vars->duplex = DUPLEX_FULL; |
| 11766 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 11767 | vars->mac_type = MAC_TYPE_EMAC; |
| 11768 | |
| 11769 | vars->phy_flags = PHY_XGXS_FLAG; |
| 11770 | |
| 11771 | bnx2x_xgxs_deassert(params); |
| 11772 | /* set bmac loopback */ |
| 11773 | bnx2x_emac_enable(params, vars, 1); |
| 11774 | bnx2x_emac_program(params, vars); |
| 11775 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + params->port*4, 0); |
| 11776 | } |
| 11777 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 11778 | void bnx2x_init_xmac_loopback(struct link_params *params, |
| 11779 | struct link_vars *vars) |
| 11780 | { |
| 11781 | struct bnx2x *bp = params->bp; |
| 11782 | vars->link_up = 1; |
| 11783 | if (!params->req_line_speed[0]) |
| 11784 | vars->line_speed = SPEED_10000; |
| 11785 | else |
| 11786 | vars->line_speed = params->req_line_speed[0]; |
| 11787 | vars->duplex = DUPLEX_FULL; |
| 11788 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 11789 | vars->mac_type = MAC_TYPE_XMAC; |
| 11790 | vars->phy_flags = PHY_XGXS_FLAG; |
| 11791 | /* |
| 11792 | * Set WC to loopback mode since link is required to provide clock |
| 11793 | * to the XMAC in 20G mode |
| 11794 | */ |
Yaniv Rosner | afad009 | 2011-08-02 23:00:06 +0000 | [diff] [blame] | 11795 | bnx2x_set_aer_mmd(params, ¶ms->phy[0]); |
| 11796 | bnx2x_warpcore_reset_lane(bp, ¶ms->phy[0], 0); |
| 11797 | params->phy[INT_PHY].config_loopback( |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 11798 | ¶ms->phy[INT_PHY], |
| 11799 | params); |
Yaniv Rosner | afad009 | 2011-08-02 23:00:06 +0000 | [diff] [blame] | 11800 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 11801 | bnx2x_xmac_enable(params, vars, 1); |
| 11802 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + params->port*4, 0); |
| 11803 | } |
| 11804 | |
| 11805 | void bnx2x_init_umac_loopback(struct link_params *params, |
| 11806 | struct link_vars *vars) |
| 11807 | { |
| 11808 | struct bnx2x *bp = params->bp; |
| 11809 | vars->link_up = 1; |
| 11810 | vars->line_speed = SPEED_1000; |
| 11811 | vars->duplex = DUPLEX_FULL; |
| 11812 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 11813 | vars->mac_type = MAC_TYPE_UMAC; |
| 11814 | vars->phy_flags = PHY_XGXS_FLAG; |
| 11815 | bnx2x_umac_enable(params, vars, 1); |
| 11816 | |
| 11817 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + params->port*4, 0); |
| 11818 | } |
| 11819 | |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 11820 | void bnx2x_init_xgxs_loopback(struct link_params *params, |
| 11821 | struct link_vars *vars) |
| 11822 | { |
| 11823 | struct bnx2x *bp = params->bp; |
| 11824 | vars->link_up = 1; |
| 11825 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 11826 | vars->duplex = DUPLEX_FULL; |
| 11827 | if (params->req_line_speed[0] == SPEED_1000) |
| 11828 | vars->line_speed = SPEED_1000; |
| 11829 | else |
| 11830 | vars->line_speed = SPEED_10000; |
| 11831 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 11832 | if (!USES_WARPCORE(bp)) |
| 11833 | bnx2x_xgxs_deassert(params); |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 11834 | bnx2x_link_initialize(params, vars); |
| 11835 | |
| 11836 | if (params->req_line_speed[0] == SPEED_1000) { |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 11837 | if (USES_WARPCORE(bp)) |
| 11838 | bnx2x_umac_enable(params, vars, 0); |
| 11839 | else { |
| 11840 | bnx2x_emac_program(params, vars); |
| 11841 | bnx2x_emac_enable(params, vars, 0); |
| 11842 | } |
| 11843 | } else { |
| 11844 | if (USES_WARPCORE(bp)) |
| 11845 | bnx2x_xmac_enable(params, vars, 0); |
| 11846 | else |
| 11847 | bnx2x_bmac_enable(params, vars, 0); |
| 11848 | } |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 11849 | |
| 11850 | if (params->loopback_mode == LOOPBACK_XGXS) { |
| 11851 | /* set 10G XGXS loopback */ |
| 11852 | params->phy[INT_PHY].config_loopback( |
| 11853 | ¶ms->phy[INT_PHY], |
| 11854 | params); |
| 11855 | |
| 11856 | } else { |
| 11857 | /* set external phy loopback */ |
| 11858 | u8 phy_index; |
| 11859 | for (phy_index = EXT_PHY1; |
| 11860 | phy_index < params->num_phys; phy_index++) { |
| 11861 | if (params->phy[phy_index].config_loopback) |
| 11862 | params->phy[phy_index].config_loopback( |
| 11863 | ¶ms->phy[phy_index], |
| 11864 | params); |
| 11865 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11866 | } |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 11867 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + params->port*4, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11868 | |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 11869 | bnx2x_set_led(params, vars, LED_MODE_OPER, vars->line_speed); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11870 | } |
| 11871 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 11872 | int bnx2x_phy_init(struct link_params *params, struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11873 | { |
| 11874 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11875 | DP(NETIF_MSG_LINK, "Phy Initialization started\n"); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11876 | DP(NETIF_MSG_LINK, "(1) req_speed %d, req_flowctrl %d\n", |
| 11877 | params->req_line_speed[0], params->req_flow_ctrl[0]); |
| 11878 | DP(NETIF_MSG_LINK, "(2) req_speed %d, req_flowctrl %d\n", |
| 11879 | params->req_line_speed[1], params->req_flow_ctrl[1]); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11880 | vars->link_status = 0; |
| 11881 | vars->phy_link_up = 0; |
| 11882 | vars->link_up = 0; |
| 11883 | vars->line_speed = 0; |
| 11884 | vars->duplex = DUPLEX_FULL; |
| 11885 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 11886 | vars->mac_type = MAC_TYPE_NONE; |
| 11887 | vars->phy_flags = 0; |
| 11888 | |
| 11889 | /* disable attentions */ |
| 11890 | bnx2x_bits_dis(bp, NIG_REG_MASK_INTERRUPT_PORT0 + params->port*4, |
| 11891 | (NIG_MASK_XGXS0_LINK_STATUS | |
| 11892 | NIG_MASK_XGXS0_LINK10G | |
| 11893 | NIG_MASK_SERDES0_LINK_STATUS | |
| 11894 | NIG_MASK_MI_INT)); |
| 11895 | |
| 11896 | bnx2x_emac_init(params, vars); |
| 11897 | |
| 11898 | if (params->num_phys == 0) { |
| 11899 | DP(NETIF_MSG_LINK, "No phy found for initialization !!\n"); |
| 11900 | return -EINVAL; |
| 11901 | } |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 11902 | set_phy_vars(params, vars); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11903 | |
| 11904 | 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] | 11905 | switch (params->loopback_mode) { |
| 11906 | case LOOPBACK_BMAC: |
| 11907 | bnx2x_init_bmac_loopback(params, vars); |
| 11908 | break; |
| 11909 | case LOOPBACK_EMAC: |
| 11910 | bnx2x_init_emac_loopback(params, vars); |
| 11911 | break; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 11912 | case LOOPBACK_XMAC: |
| 11913 | bnx2x_init_xmac_loopback(params, vars); |
| 11914 | break; |
| 11915 | case LOOPBACK_UMAC: |
| 11916 | bnx2x_init_umac_loopback(params, vars); |
| 11917 | break; |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 11918 | case LOOPBACK_XGXS: |
| 11919 | case LOOPBACK_EXT_PHY: |
| 11920 | bnx2x_init_xgxs_loopback(params, vars); |
| 11921 | break; |
| 11922 | default: |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 11923 | if (!CHIP_IS_E3(bp)) { |
| 11924 | if (params->switch_cfg == SWITCH_CFG_10G) |
| 11925 | bnx2x_xgxs_deassert(params); |
| 11926 | else |
| 11927 | bnx2x_serdes_deassert(bp, params->port); |
| 11928 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11929 | bnx2x_link_initialize(params, vars); |
| 11930 | msleep(30); |
| 11931 | bnx2x_link_int_enable(params); |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 11932 | break; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11933 | } |
| 11934 | return 0; |
| 11935 | } |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 11936 | |
| 11937 | int bnx2x_link_reset(struct link_params *params, struct link_vars *vars, |
| 11938 | u8 reset_ext_phy) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11939 | { |
| 11940 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | cf1d972 | 2010-11-01 05:32:34 +0000 | [diff] [blame] | 11941 | u8 phy_index, port = params->port, clear_latch_ind = 0; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11942 | DP(NETIF_MSG_LINK, "Resetting the link of port %d\n", port); |
| 11943 | /* disable attentions */ |
| 11944 | vars->link_status = 0; |
| 11945 | bnx2x_update_mng(params, vars->link_status); |
| 11946 | bnx2x_bits_dis(bp, NIG_REG_MASK_INTERRUPT_PORT0 + port*4, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11947 | (NIG_MASK_XGXS0_LINK_STATUS | |
| 11948 | NIG_MASK_XGXS0_LINK10G | |
| 11949 | NIG_MASK_SERDES0_LINK_STATUS | |
| 11950 | NIG_MASK_MI_INT)); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11951 | |
| 11952 | /* activate nig drain */ |
| 11953 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + port*4, 1); |
| 11954 | |
| 11955 | /* disable nig egress interface */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 11956 | if (!CHIP_IS_E3(bp)) { |
| 11957 | REG_WR(bp, NIG_REG_BMAC0_OUT_EN + port*4, 0); |
| 11958 | REG_WR(bp, NIG_REG_EGRESS_EMAC0_OUT_EN + port*4, 0); |
| 11959 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11960 | |
| 11961 | /* Stop BigMac rx */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 11962 | if (!CHIP_IS_E3(bp)) |
| 11963 | bnx2x_bmac_rx_disable(bp, port); |
Yaniv Rosner | ce7c048 | 2011-10-27 05:09:47 +0000 | [diff] [blame] | 11964 | else { |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 11965 | bnx2x_xmac_disable(params); |
Yaniv Rosner | ce7c048 | 2011-10-27 05:09:47 +0000 | [diff] [blame] | 11966 | bnx2x_umac_disable(params); |
| 11967 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11968 | /* disable emac */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 11969 | if (!CHIP_IS_E3(bp)) |
| 11970 | REG_WR(bp, NIG_REG_NIG_EMAC0_EN + port*4, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11971 | |
| 11972 | msleep(10); |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 11973 | /* The PHY reset is controlled by GPIO 1 |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11974 | * Hold it as vars low |
| 11975 | */ |
| 11976 | /* clear link led */ |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 11977 | bnx2x_set_led(params, vars, LED_MODE_OFF, 0); |
| 11978 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11979 | if (reset_ext_phy) { |
Yaniv Rosner | 28f4881 | 2011-08-02 23:00:12 +0000 | [diff] [blame] | 11980 | bnx2x_set_mdio_clk(bp, params->chip_id, port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11981 | for (phy_index = EXT_PHY1; phy_index < params->num_phys; |
| 11982 | phy_index++) { |
Yaniv Rosner | 28f4881 | 2011-08-02 23:00:12 +0000 | [diff] [blame] | 11983 | if (params->phy[phy_index].link_reset) { |
| 11984 | bnx2x_set_aer_mmd(params, |
| 11985 | ¶ms->phy[phy_index]); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11986 | params->phy[phy_index].link_reset( |
| 11987 | ¶ms->phy[phy_index], |
| 11988 | params); |
Yaniv Rosner | 28f4881 | 2011-08-02 23:00:12 +0000 | [diff] [blame] | 11989 | } |
Yaniv Rosner | cf1d972 | 2010-11-01 05:32:34 +0000 | [diff] [blame] | 11990 | if (params->phy[phy_index].flags & |
| 11991 | FLAGS_REARM_LATCH_SIGNAL) |
| 11992 | clear_latch_ind = 1; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11993 | } |
| 11994 | } |
| 11995 | |
Yaniv Rosner | cf1d972 | 2010-11-01 05:32:34 +0000 | [diff] [blame] | 11996 | if (clear_latch_ind) { |
| 11997 | /* Clear latching indication */ |
| 11998 | bnx2x_rearm_latch_signal(bp, port, 0); |
| 11999 | bnx2x_bits_dis(bp, NIG_REG_LATCH_BC_0 + port*4, |
| 12000 | 1 << NIG_LATCH_BC_ENABLE_MI_INT); |
| 12001 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12002 | if (params->phy[INT_PHY].link_reset) |
| 12003 | params->phy[INT_PHY].link_reset( |
| 12004 | ¶ms->phy[INT_PHY], params); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12005 | |
| 12006 | /* disable nig ingress interface */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 12007 | if (!CHIP_IS_E3(bp)) { |
Yaniv Rosner | ce7c048 | 2011-10-27 05:09:47 +0000 | [diff] [blame] | 12008 | /* reset BigMac */ |
| 12009 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_CLEAR, |
| 12010 | (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << port)); |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 12011 | REG_WR(bp, NIG_REG_BMAC0_IN_EN + port*4, 0); |
| 12012 | REG_WR(bp, NIG_REG_EMAC0_IN_EN + port*4, 0); |
Yaniv Rosner | ce7c048 | 2011-10-27 05:09:47 +0000 | [diff] [blame] | 12013 | } else { |
| 12014 | u32 xmac_base = (params->port) ? GRCBASE_XMAC1 : GRCBASE_XMAC0; |
| 12015 | bnx2x_set_xumac_nig(params, 0, 0); |
| 12016 | if (REG_RD(bp, MISC_REG_RESET_REG_2) & |
| 12017 | MISC_REGISTERS_RESET_REG_2_XMAC) |
| 12018 | REG_WR(bp, xmac_base + XMAC_REG_CTRL, |
| 12019 | XMAC_CTRL_REG_SOFT_RESET); |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 12020 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12021 | vars->link_up = 0; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 12022 | vars->phy_flags = 0; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12023 | return 0; |
| 12024 | } |
| 12025 | |
| 12026 | /****************************************************************************/ |
| 12027 | /* Common function */ |
| 12028 | /****************************************************************************/ |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 12029 | static int bnx2x_8073_common_init_phy(struct bnx2x *bp, |
| 12030 | u32 shmem_base_path[], |
| 12031 | u32 shmem2_base_path[], u8 phy_index, |
| 12032 | u32 chip_id) |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12033 | { |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 12034 | struct bnx2x_phy phy[PORT_MAX]; |
| 12035 | struct bnx2x_phy *phy_blk[PORT_MAX]; |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12036 | u16 val; |
Yaniv Rosner | c8e64df | 2011-01-30 04:15:00 +0000 | [diff] [blame] | 12037 | s8 port = 0; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12038 | s8 port_of_path = 0; |
Yaniv Rosner | c8e64df | 2011-01-30 04:15:00 +0000 | [diff] [blame] | 12039 | u32 swap_val, swap_override; |
| 12040 | swap_val = REG_RD(bp, NIG_REG_PORT_SWAP); |
| 12041 | swap_override = REG_RD(bp, NIG_REG_STRAP_OVERRIDE); |
| 12042 | port ^= (swap_val && swap_override); |
| 12043 | bnx2x_ext_phy_hw_reset(bp, port); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12044 | /* PART1 - Reset both phys */ |
| 12045 | for (port = PORT_MAX - 1; port >= PORT_0; port--) { |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12046 | u32 shmem_base, shmem2_base; |
| 12047 | /* In E2, same phy is using for port0 of the two paths */ |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 12048 | if (CHIP_IS_E1x(bp)) { |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12049 | shmem_base = shmem_base_path[0]; |
| 12050 | shmem2_base = shmem2_base_path[0]; |
| 12051 | port_of_path = port; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 12052 | } else { |
| 12053 | shmem_base = shmem_base_path[port]; |
| 12054 | shmem2_base = shmem2_base_path[port]; |
| 12055 | port_of_path = 0; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12056 | } |
| 12057 | |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12058 | /* Extract the ext phy address for the port */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12059 | if (bnx2x_populate_phy(bp, phy_index, shmem_base, shmem2_base, |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12060 | port_of_path, &phy[port]) != |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 12061 | 0) { |
| 12062 | DP(NETIF_MSG_LINK, "populate_phy failed\n"); |
| 12063 | return -EINVAL; |
| 12064 | } |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12065 | /* disable attentions */ |
Yaniv Rosner | 6a71bbe | 2010-11-01 05:32:31 +0000 | [diff] [blame] | 12066 | bnx2x_bits_dis(bp, NIG_REG_MASK_INTERRUPT_PORT0 + |
| 12067 | port_of_path*4, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 12068 | (NIG_MASK_XGXS0_LINK_STATUS | |
| 12069 | NIG_MASK_XGXS0_LINK10G | |
| 12070 | NIG_MASK_SERDES0_LINK_STATUS | |
| 12071 | NIG_MASK_MI_INT)); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12072 | |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12073 | /* Need to take the phy out of low power mode in order |
| 12074 | to write to access its registers */ |
| 12075 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 12076 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, |
| 12077 | port); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12078 | |
| 12079 | /* Reset the phy */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 12080 | bnx2x_cl45_write(bp, &phy[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 12081 | MDIO_PMA_DEVAD, |
| 12082 | MDIO_PMA_REG_CTRL, |
| 12083 | 1<<15); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12084 | } |
| 12085 | |
| 12086 | /* Add delay of 150ms after reset */ |
| 12087 | msleep(150); |
| 12088 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 12089 | if (phy[PORT_0].addr & 0x1) { |
| 12090 | phy_blk[PORT_0] = &(phy[PORT_1]); |
| 12091 | phy_blk[PORT_1] = &(phy[PORT_0]); |
| 12092 | } else { |
| 12093 | phy_blk[PORT_0] = &(phy[PORT_0]); |
| 12094 | phy_blk[PORT_1] = &(phy[PORT_1]); |
| 12095 | } |
| 12096 | |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12097 | /* PART2 - Download firmware to both phys */ |
| 12098 | for (port = PORT_MAX - 1; port >= PORT_0; port--) { |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 12099 | if (CHIP_IS_E1x(bp)) |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12100 | port_of_path = port; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 12101 | else |
| 12102 | port_of_path = 0; |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12103 | |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12104 | DP(NETIF_MSG_LINK, "Loading spirom for phy address 0x%x\n", |
| 12105 | phy_blk[port]->addr); |
Yaniv Rosner | 5c99274b | 2011-01-18 04:33:36 +0000 | [diff] [blame] | 12106 | if (bnx2x_8073_8727_external_rom_boot(bp, phy_blk[port], |
| 12107 | port_of_path)) |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12108 | return -EINVAL; |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12109 | |
| 12110 | /* Only set bit 10 = 1 (Tx power down) */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 12111 | bnx2x_cl45_read(bp, phy_blk[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 12112 | MDIO_PMA_DEVAD, |
| 12113 | MDIO_PMA_REG_TX_POWER_DOWN, &val); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12114 | |
| 12115 | /* Phase1 of TX_POWER_DOWN reset */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 12116 | bnx2x_cl45_write(bp, phy_blk[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 12117 | MDIO_PMA_DEVAD, |
| 12118 | MDIO_PMA_REG_TX_POWER_DOWN, |
| 12119 | (val | 1<<10)); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12120 | } |
| 12121 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 12122 | /* |
| 12123 | * Toggle Transmitter: Power down and then up with 600ms delay |
| 12124 | * between |
| 12125 | */ |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12126 | msleep(600); |
| 12127 | |
| 12128 | /* PART3 - complete TX_POWER_DOWN process, and set GPIO2 back to low */ |
| 12129 | for (port = PORT_MAX - 1; port >= PORT_0; port--) { |
Eilon Greenstein | f537225 | 2009-02-12 08:38:30 +0000 | [diff] [blame] | 12130 | /* Phase2 of POWER_DOWN_RESET */ |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12131 | /* Release bit 10 (Release Tx power down) */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 12132 | bnx2x_cl45_read(bp, phy_blk[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 12133 | MDIO_PMA_DEVAD, |
| 12134 | MDIO_PMA_REG_TX_POWER_DOWN, &val); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12135 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 12136 | bnx2x_cl45_write(bp, phy_blk[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 12137 | MDIO_PMA_DEVAD, |
| 12138 | MDIO_PMA_REG_TX_POWER_DOWN, (val & (~(1<<10)))); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12139 | msleep(15); |
| 12140 | |
| 12141 | /* Read modify write the SPI-ROM version select register */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 12142 | bnx2x_cl45_read(bp, phy_blk[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 12143 | MDIO_PMA_DEVAD, |
| 12144 | MDIO_PMA_REG_EDC_FFE_MAIN, &val); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 12145 | bnx2x_cl45_write(bp, phy_blk[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 12146 | MDIO_PMA_DEVAD, |
| 12147 | MDIO_PMA_REG_EDC_FFE_MAIN, (val | (1<<12))); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12148 | |
| 12149 | /* set GPIO2 back to LOW */ |
| 12150 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 12151 | MISC_REGISTERS_GPIO_OUTPUT_LOW, port); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12152 | } |
| 12153 | return 0; |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12154 | } |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 12155 | static int bnx2x_8726_common_init_phy(struct bnx2x *bp, |
| 12156 | u32 shmem_base_path[], |
| 12157 | u32 shmem2_base_path[], u8 phy_index, |
| 12158 | u32 chip_id) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12159 | { |
| 12160 | u32 val; |
| 12161 | s8 port; |
| 12162 | struct bnx2x_phy phy; |
| 12163 | /* Use port1 because of the static port-swap */ |
| 12164 | /* Enable the module detection interrupt */ |
| 12165 | val = REG_RD(bp, MISC_REG_GPIO_EVENT_EN); |
| 12166 | val |= ((1<<MISC_REGISTERS_GPIO_3)| |
| 12167 | (1<<(MISC_REGISTERS_GPIO_3 + MISC_REGISTERS_GPIO_PORT_SHIFT))); |
| 12168 | REG_WR(bp, MISC_REG_GPIO_EVENT_EN, val); |
| 12169 | |
Yaniv Rosner | 650154b | 2010-11-01 05:32:36 +0000 | [diff] [blame] | 12170 | bnx2x_ext_phy_hw_reset(bp, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12171 | msleep(5); |
| 12172 | for (port = 0; port < PORT_MAX; port++) { |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12173 | u32 shmem_base, shmem2_base; |
| 12174 | |
| 12175 | /* In E2, same phy is using for port0 of the two paths */ |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 12176 | if (CHIP_IS_E1x(bp)) { |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12177 | shmem_base = shmem_base_path[0]; |
| 12178 | shmem2_base = shmem2_base_path[0]; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 12179 | } else { |
| 12180 | shmem_base = shmem_base_path[port]; |
| 12181 | shmem2_base = shmem2_base_path[port]; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12182 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12183 | /* Extract the ext phy address for the port */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12184 | if (bnx2x_populate_phy(bp, phy_index, shmem_base, shmem2_base, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12185 | port, &phy) != |
| 12186 | 0) { |
| 12187 | DP(NETIF_MSG_LINK, "populate phy failed\n"); |
| 12188 | return -EINVAL; |
| 12189 | } |
| 12190 | |
| 12191 | /* Reset phy*/ |
| 12192 | bnx2x_cl45_write(bp, &phy, |
| 12193 | MDIO_PMA_DEVAD, MDIO_PMA_REG_GEN_CTRL, 0x0001); |
| 12194 | |
| 12195 | |
| 12196 | /* Set fault module detected LED on */ |
| 12197 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_0, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 12198 | MISC_REGISTERS_GPIO_HIGH, |
| 12199 | port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12200 | } |
| 12201 | |
| 12202 | return 0; |
| 12203 | } |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 12204 | static void bnx2x_get_ext_phy_reset_gpio(struct bnx2x *bp, u32 shmem_base, |
| 12205 | u8 *io_gpio, u8 *io_port) |
| 12206 | { |
| 12207 | |
| 12208 | u32 phy_gpio_reset = REG_RD(bp, shmem_base + |
| 12209 | offsetof(struct shmem_region, |
| 12210 | dev_info.port_hw_config[PORT_0].default_cfg)); |
| 12211 | switch (phy_gpio_reset) { |
| 12212 | case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO0_P0: |
| 12213 | *io_gpio = 0; |
| 12214 | *io_port = 0; |
| 12215 | break; |
| 12216 | case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO1_P0: |
| 12217 | *io_gpio = 1; |
| 12218 | *io_port = 0; |
| 12219 | break; |
| 12220 | case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO2_P0: |
| 12221 | *io_gpio = 2; |
| 12222 | *io_port = 0; |
| 12223 | break; |
| 12224 | case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO3_P0: |
| 12225 | *io_gpio = 3; |
| 12226 | *io_port = 0; |
| 12227 | break; |
| 12228 | case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO0_P1: |
| 12229 | *io_gpio = 0; |
| 12230 | *io_port = 1; |
| 12231 | break; |
| 12232 | case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO1_P1: |
| 12233 | *io_gpio = 1; |
| 12234 | *io_port = 1; |
| 12235 | break; |
| 12236 | case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO2_P1: |
| 12237 | *io_gpio = 2; |
| 12238 | *io_port = 1; |
| 12239 | break; |
| 12240 | case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO3_P1: |
| 12241 | *io_gpio = 3; |
| 12242 | *io_port = 1; |
| 12243 | break; |
| 12244 | default: |
| 12245 | /* Don't override the io_gpio and io_port */ |
| 12246 | break; |
| 12247 | } |
| 12248 | } |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 12249 | |
| 12250 | static int bnx2x_8727_common_init_phy(struct bnx2x *bp, |
| 12251 | u32 shmem_base_path[], |
| 12252 | u32 shmem2_base_path[], u8 phy_index, |
| 12253 | u32 chip_id) |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 12254 | { |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 12255 | s8 port, reset_gpio; |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 12256 | u32 swap_val, swap_override; |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 12257 | struct bnx2x_phy phy[PORT_MAX]; |
| 12258 | struct bnx2x_phy *phy_blk[PORT_MAX]; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12259 | s8 port_of_path; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 12260 | swap_val = REG_RD(bp, NIG_REG_PORT_SWAP); |
| 12261 | swap_override = REG_RD(bp, NIG_REG_STRAP_OVERRIDE); |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 12262 | |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 12263 | reset_gpio = MISC_REGISTERS_GPIO_1; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12264 | port = 1; |
| 12265 | |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 12266 | /* |
| 12267 | * Retrieve the reset gpio/port which control the reset. |
| 12268 | * Default is GPIO1, PORT1 |
| 12269 | */ |
| 12270 | bnx2x_get_ext_phy_reset_gpio(bp, shmem_base_path[0], |
| 12271 | (u8 *)&reset_gpio, (u8 *)&port); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12272 | |
| 12273 | /* Calculate the port based on port swap */ |
| 12274 | port ^= (swap_val && swap_override); |
| 12275 | |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 12276 | /* Initiate PHY reset*/ |
| 12277 | bnx2x_set_gpio(bp, reset_gpio, MISC_REGISTERS_GPIO_OUTPUT_LOW, |
| 12278 | port); |
| 12279 | msleep(1); |
| 12280 | bnx2x_set_gpio(bp, reset_gpio, MISC_REGISTERS_GPIO_OUTPUT_HIGH, |
| 12281 | port); |
| 12282 | |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 12283 | msleep(5); |
| 12284 | |
| 12285 | /* PART1 - Reset both phys */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12286 | for (port = PORT_MAX - 1; port >= PORT_0; port--) { |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12287 | u32 shmem_base, shmem2_base; |
| 12288 | |
| 12289 | /* In E2, same phy is using for port0 of the two paths */ |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 12290 | if (CHIP_IS_E1x(bp)) { |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12291 | shmem_base = shmem_base_path[0]; |
| 12292 | shmem2_base = shmem2_base_path[0]; |
| 12293 | port_of_path = port; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 12294 | } else { |
| 12295 | shmem_base = shmem_base_path[port]; |
| 12296 | shmem2_base = shmem2_base_path[port]; |
| 12297 | port_of_path = 0; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12298 | } |
| 12299 | |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 12300 | /* Extract the ext phy address for the port */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12301 | if (bnx2x_populate_phy(bp, phy_index, shmem_base, shmem2_base, |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12302 | port_of_path, &phy[port]) != |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 12303 | 0) { |
| 12304 | DP(NETIF_MSG_LINK, "populate phy failed\n"); |
| 12305 | return -EINVAL; |
| 12306 | } |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 12307 | /* disable attentions */ |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12308 | bnx2x_bits_dis(bp, NIG_REG_MASK_INTERRUPT_PORT0 + |
| 12309 | port_of_path*4, |
| 12310 | (NIG_MASK_XGXS0_LINK_STATUS | |
| 12311 | NIG_MASK_XGXS0_LINK10G | |
| 12312 | NIG_MASK_SERDES0_LINK_STATUS | |
| 12313 | NIG_MASK_MI_INT)); |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 12314 | |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 12315 | |
| 12316 | /* Reset the phy */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 12317 | bnx2x_cl45_write(bp, &phy[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 12318 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 1<<15); |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 12319 | } |
| 12320 | |
| 12321 | /* Add delay of 150ms after reset */ |
| 12322 | msleep(150); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 12323 | if (phy[PORT_0].addr & 0x1) { |
| 12324 | phy_blk[PORT_0] = &(phy[PORT_1]); |
| 12325 | phy_blk[PORT_1] = &(phy[PORT_0]); |
| 12326 | } else { |
| 12327 | phy_blk[PORT_0] = &(phy[PORT_0]); |
| 12328 | phy_blk[PORT_1] = &(phy[PORT_1]); |
| 12329 | } |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 12330 | /* PART2 - Download firmware to both phys */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 12331 | for (port = PORT_MAX - 1; port >= PORT_0; port--) { |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 12332 | if (CHIP_IS_E1x(bp)) |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12333 | port_of_path = port; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 12334 | else |
| 12335 | port_of_path = 0; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12336 | DP(NETIF_MSG_LINK, "Loading spirom for phy address 0x%x\n", |
| 12337 | phy_blk[port]->addr); |
Yaniv Rosner | 5c99274b | 2011-01-18 04:33:36 +0000 | [diff] [blame] | 12338 | if (bnx2x_8073_8727_external_rom_boot(bp, phy_blk[port], |
| 12339 | port_of_path)) |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 12340 | return -EINVAL; |
Yaniv Rosner | 85242ee | 2011-07-05 01:06:53 +0000 | [diff] [blame] | 12341 | /* Disable PHY transmitter output */ |
| 12342 | bnx2x_cl45_write(bp, phy_blk[port], |
| 12343 | MDIO_PMA_DEVAD, |
| 12344 | MDIO_PMA_REG_TX_DISABLE, 1); |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 12345 | |
Yaniv Rosner | 5c99274b | 2011-01-18 04:33:36 +0000 | [diff] [blame] | 12346 | } |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 12347 | return 0; |
| 12348 | } |
| 12349 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 12350 | static int bnx2x_ext_phy_common_init(struct bnx2x *bp, u32 shmem_base_path[], |
| 12351 | u32 shmem2_base_path[], u8 phy_index, |
| 12352 | u32 ext_phy_type, u32 chip_id) |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12353 | { |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 12354 | int rc = 0; |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12355 | |
| 12356 | switch (ext_phy_type) { |
| 12357 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073: |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12358 | rc = bnx2x_8073_common_init_phy(bp, shmem_base_path, |
| 12359 | shmem2_base_path, |
| 12360 | phy_index, chip_id); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12361 | break; |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 12362 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8722: |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 12363 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727: |
| 12364 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727_NOC: |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12365 | rc = bnx2x_8727_common_init_phy(bp, shmem_base_path, |
| 12366 | shmem2_base_path, |
| 12367 | phy_index, chip_id); |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 12368 | break; |
| 12369 | |
Eilon Greenstein | 589abe3 | 2009-02-12 08:36:55 +0000 | [diff] [blame] | 12370 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726: |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 12371 | /* |
| 12372 | * GPIO1 affects both ports, so there's need to pull |
| 12373 | * it for single port alone |
| 12374 | */ |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12375 | rc = bnx2x_8726_common_init_phy(bp, shmem_base_path, |
| 12376 | shmem2_base_path, |
| 12377 | phy_index, chip_id); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12378 | break; |
Yaniv Rosner | 0d40f0d | 2011-06-14 01:34:27 +0000 | [diff] [blame] | 12379 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833: |
| 12380 | /* |
| 12381 | * GPIO3's are linked, and so both need to be toggled |
| 12382 | * to obtain required 2us pulse. |
| 12383 | */ |
| 12384 | rc = bnx2x_84833_common_init_phy(bp, shmem_base_path, chip_id); |
| 12385 | break; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12386 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_FAILURE: |
| 12387 | rc = -EINVAL; |
Yaniv Rosner | 4f60dab | 2009-11-05 19:18:23 +0200 | [diff] [blame] | 12388 | break; |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12389 | default: |
| 12390 | DP(NETIF_MSG_LINK, |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 12391 | "ext_phy 0x%x common init not required\n", |
| 12392 | ext_phy_type); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12393 | break; |
| 12394 | } |
| 12395 | |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 12396 | if (rc != 0) |
| 12397 | netdev_err(bp->dev, "Warning: PHY was not initialized," |
| 12398 | " Port %d\n", |
| 12399 | 0); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12400 | return rc; |
| 12401 | } |
| 12402 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 12403 | int bnx2x_common_init_phy(struct bnx2x *bp, u32 shmem_base_path[], |
| 12404 | u32 shmem2_base_path[], u32 chip_id) |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12405 | { |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 12406 | int rc = 0; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 12407 | u32 phy_ver, val; |
| 12408 | u8 phy_index = 0; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12409 | u32 ext_phy_type, ext_phy_config; |
Yaniv Rosner | a198c14 | 2011-05-31 21:29:42 +0000 | [diff] [blame] | 12410 | bnx2x_set_mdio_clk(bp, chip_id, PORT_0); |
| 12411 | bnx2x_set_mdio_clk(bp, chip_id, PORT_1); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12412 | DP(NETIF_MSG_LINK, "Begin common phy init\n"); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 12413 | if (CHIP_IS_E3(bp)) { |
| 12414 | /* Enable EPIO */ |
| 12415 | val = REG_RD(bp, MISC_REG_GEN_PURP_HWG); |
| 12416 | REG_WR(bp, MISC_REG_GEN_PURP_HWG, val | 1); |
| 12417 | } |
Yaniv Rosner | b21a342 | 2011-01-18 04:33:24 +0000 | [diff] [blame] | 12418 | /* Check if common init was already done */ |
| 12419 | phy_ver = REG_RD(bp, shmem_base_path[0] + |
| 12420 | offsetof(struct shmem_region, |
| 12421 | port_mb[PORT_0].ext_phy_fw_version)); |
| 12422 | if (phy_ver) { |
| 12423 | DP(NETIF_MSG_LINK, "Not doing common init; phy ver is 0x%x\n", |
| 12424 | phy_ver); |
| 12425 | return 0; |
| 12426 | } |
| 12427 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12428 | /* Read the ext_phy_type for arbitrary port(0) */ |
| 12429 | for (phy_index = EXT_PHY1; phy_index < MAX_PHYS; |
| 12430 | phy_index++) { |
| 12431 | ext_phy_config = bnx2x_get_ext_phy_config(bp, |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12432 | shmem_base_path[0], |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12433 | phy_index, 0); |
| 12434 | ext_phy_type = XGXS_EXT_PHY_TYPE(ext_phy_config); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12435 | rc |= bnx2x_ext_phy_common_init(bp, shmem_base_path, |
| 12436 | shmem2_base_path, |
| 12437 | phy_index, ext_phy_type, |
| 12438 | chip_id); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12439 | } |
| 12440 | return rc; |
| 12441 | } |
| 12442 | |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 12443 | static void bnx2x_check_over_curr(struct link_params *params, |
| 12444 | struct link_vars *vars) |
| 12445 | { |
| 12446 | struct bnx2x *bp = params->bp; |
| 12447 | u32 cfg_pin; |
| 12448 | u8 port = params->port; |
| 12449 | u32 pin_val; |
| 12450 | |
| 12451 | cfg_pin = (REG_RD(bp, params->shmem_base + |
| 12452 | offsetof(struct shmem_region, |
| 12453 | dev_info.port_hw_config[port].e3_cmn_pin_cfg1)) & |
| 12454 | PORT_HW_CFG_E3_OVER_CURRENT_MASK) >> |
| 12455 | PORT_HW_CFG_E3_OVER_CURRENT_SHIFT; |
| 12456 | |
| 12457 | /* Ignore check if no external input PIN available */ |
| 12458 | if (bnx2x_get_cfg_pin(bp, cfg_pin, &pin_val) != 0) |
| 12459 | return; |
| 12460 | |
| 12461 | if (!pin_val) { |
| 12462 | if ((vars->phy_flags & PHY_OVER_CURRENT_FLAG) == 0) { |
| 12463 | netdev_err(bp->dev, "Error: Power fault on Port %d has" |
| 12464 | " been detected and the power to " |
| 12465 | "that SFP+ module has been removed" |
| 12466 | " to prevent failure of the card." |
| 12467 | " Please remove the SFP+ module and" |
| 12468 | " restart the system to clear this" |
| 12469 | " error.\n", |
| 12470 | params->port); |
| 12471 | vars->phy_flags |= PHY_OVER_CURRENT_FLAG; |
| 12472 | } |
| 12473 | } else |
| 12474 | vars->phy_flags &= ~PHY_OVER_CURRENT_FLAG; |
| 12475 | } |
| 12476 | |
| 12477 | static void bnx2x_analyze_link_error(struct link_params *params, |
| 12478 | struct link_vars *vars, u32 lss_status) |
| 12479 | { |
| 12480 | struct bnx2x *bp = params->bp; |
| 12481 | /* Compare new value with previous value */ |
| 12482 | u8 led_mode; |
| 12483 | u32 half_open_conn = (vars->phy_flags & PHY_HALF_OPEN_CONN_FLAG) > 0; |
| 12484 | |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 12485 | if ((lss_status ^ half_open_conn) == 0) |
| 12486 | return; |
| 12487 | |
| 12488 | /* If values differ */ |
| 12489 | DP(NETIF_MSG_LINK, "Link changed:%x %x->%x\n", vars->link_up, |
| 12490 | half_open_conn, lss_status); |
| 12491 | |
| 12492 | /* |
| 12493 | * a. Update shmem->link_status accordingly |
| 12494 | * b. Update link_vars->link_up |
| 12495 | */ |
| 12496 | if (lss_status) { |
Yaniv Rosner | de6f337 | 2011-08-02 22:59:25 +0000 | [diff] [blame] | 12497 | DP(NETIF_MSG_LINK, "Remote Fault detected !!!\n"); |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 12498 | vars->link_status &= ~LINK_STATUS_LINK_UP; |
| 12499 | vars->link_up = 0; |
| 12500 | vars->phy_flags |= PHY_HALF_OPEN_CONN_FLAG; |
| 12501 | /* |
| 12502 | * Set LED mode to off since the PHY doesn't know about these |
| 12503 | * errors |
| 12504 | */ |
| 12505 | led_mode = LED_MODE_OFF; |
| 12506 | } else { |
Yaniv Rosner | de6f337 | 2011-08-02 22:59:25 +0000 | [diff] [blame] | 12507 | DP(NETIF_MSG_LINK, "Remote Fault cleared\n"); |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 12508 | vars->link_status |= LINK_STATUS_LINK_UP; |
| 12509 | vars->link_up = 1; |
| 12510 | vars->phy_flags &= ~PHY_HALF_OPEN_CONN_FLAG; |
| 12511 | led_mode = LED_MODE_OPER; |
| 12512 | } |
| 12513 | /* Update the LED according to the link state */ |
| 12514 | bnx2x_set_led(params, vars, led_mode, SPEED_10000); |
| 12515 | |
| 12516 | /* Update link status in the shared memory */ |
| 12517 | bnx2x_update_mng(params, vars->link_status); |
| 12518 | |
| 12519 | /* C. Trigger General Attention */ |
| 12520 | vars->periodic_flags |= PERIODIC_FLAGS_LINK_EVENT; |
| 12521 | bnx2x_notify_link_changed(bp); |
| 12522 | } |
| 12523 | |
Yaniv Rosner | de6f337 | 2011-08-02 22:59:25 +0000 | [diff] [blame] | 12524 | /****************************************************************************** |
| 12525 | * Description: |
| 12526 | * This function checks for half opened connection change indication. |
| 12527 | * When such change occurs, it calls the bnx2x_analyze_link_error |
| 12528 | * to check if Remote Fault is set or cleared. Reception of remote fault |
| 12529 | * status message in the MAC indicates that the peer's MAC has detected |
| 12530 | * a fault, for example, due to break in the TX side of fiber. |
| 12531 | * |
| 12532 | ******************************************************************************/ |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 12533 | static void bnx2x_check_half_open_conn(struct link_params *params, |
| 12534 | struct link_vars *vars) |
| 12535 | { |
| 12536 | struct bnx2x *bp = params->bp; |
| 12537 | u32 lss_status = 0; |
| 12538 | u32 mac_base; |
| 12539 | /* In case link status is physically up @ 10G do */ |
| 12540 | if ((vars->phy_flags & PHY_PHYSICAL_LINK_FLAG) == 0) |
| 12541 | return; |
| 12542 | |
Yaniv Rosner | de6f337 | 2011-08-02 22:59:25 +0000 | [diff] [blame] | 12543 | if (CHIP_IS_E3(bp) && |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 12544 | (REG_RD(bp, MISC_REG_RESET_REG_2) & |
Yaniv Rosner | de6f337 | 2011-08-02 22:59:25 +0000 | [diff] [blame] | 12545 | (MISC_REGISTERS_RESET_REG_2_XMAC))) { |
| 12546 | /* Check E3 XMAC */ |
| 12547 | /* |
| 12548 | * Note that link speed cannot be queried here, since it may be |
| 12549 | * zero while link is down. In case UMAC is active, LSS will |
| 12550 | * simply not be set |
| 12551 | */ |
| 12552 | mac_base = (params->port) ? GRCBASE_XMAC1 : GRCBASE_XMAC0; |
| 12553 | |
| 12554 | /* Clear stick bits (Requires rising edge) */ |
| 12555 | REG_WR(bp, mac_base + XMAC_REG_CLEAR_RX_LSS_STATUS, 0); |
| 12556 | REG_WR(bp, mac_base + XMAC_REG_CLEAR_RX_LSS_STATUS, |
| 12557 | XMAC_CLEAR_RX_LSS_STATUS_REG_CLEAR_LOCAL_FAULT_STATUS | |
| 12558 | XMAC_CLEAR_RX_LSS_STATUS_REG_CLEAR_REMOTE_FAULT_STATUS); |
| 12559 | if (REG_RD(bp, mac_base + XMAC_REG_RX_LSS_STATUS)) |
| 12560 | lss_status = 1; |
| 12561 | |
| 12562 | bnx2x_analyze_link_error(params, vars, lss_status); |
| 12563 | } else if (REG_RD(bp, MISC_REG_RESET_REG_2) & |
| 12564 | (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << params->port)) { |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 12565 | /* Check E1X / E2 BMAC */ |
| 12566 | u32 lss_status_reg; |
| 12567 | u32 wb_data[2]; |
| 12568 | mac_base = params->port ? NIG_REG_INGRESS_BMAC1_MEM : |
| 12569 | NIG_REG_INGRESS_BMAC0_MEM; |
| 12570 | /* Read BIGMAC_REGISTER_RX_LSS_STATUS */ |
| 12571 | if (CHIP_IS_E2(bp)) |
| 12572 | lss_status_reg = BIGMAC2_REGISTER_RX_LSS_STAT; |
| 12573 | else |
| 12574 | lss_status_reg = BIGMAC_REGISTER_RX_LSS_STATUS; |
| 12575 | |
| 12576 | REG_RD_DMAE(bp, mac_base + lss_status_reg, wb_data, 2); |
| 12577 | lss_status = (wb_data[0] > 0); |
| 12578 | |
| 12579 | bnx2x_analyze_link_error(params, vars, lss_status); |
| 12580 | } |
| 12581 | } |
| 12582 | |
| 12583 | void bnx2x_period_func(struct link_params *params, struct link_vars *vars) |
| 12584 | { |
| 12585 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | de6f337 | 2011-08-02 22:59:25 +0000 | [diff] [blame] | 12586 | u16 phy_idx; |
Yaniv Rosner | de6f337 | 2011-08-02 22:59:25 +0000 | [diff] [blame] | 12587 | for (phy_idx = INT_PHY; phy_idx < MAX_PHYS; phy_idx++) { |
| 12588 | if (params->phy[phy_idx].flags & FLAGS_TX_ERROR_CHECK) { |
| 12589 | bnx2x_set_aer_mmd(params, ¶ms->phy[phy_idx]); |
| 12590 | bnx2x_check_half_open_conn(params, vars); |
| 12591 | break; |
| 12592 | } |
| 12593 | } |
| 12594 | |
Yaniv Rosner | a9077bf | 2011-10-27 05:09:46 +0000 | [diff] [blame] | 12595 | if (CHIP_IS_E3(bp)) { |
| 12596 | struct bnx2x_phy *phy = ¶ms->phy[INT_PHY]; |
| 12597 | bnx2x_set_aer_mmd(params, phy); |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 12598 | bnx2x_check_over_curr(params, vars); |
Yaniv Rosner | a9077bf | 2011-10-27 05:09:46 +0000 | [diff] [blame] | 12599 | bnx2x_warpcore_config_runtime(phy, params, vars); |
| 12600 | } |
| 12601 | |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 12602 | } |
| 12603 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12604 | 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] | 12605 | { |
| 12606 | u8 phy_index; |
| 12607 | struct bnx2x_phy phy; |
| 12608 | for (phy_index = INT_PHY; phy_index < MAX_PHYS; |
| 12609 | phy_index++) { |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12610 | if (bnx2x_populate_phy(bp, phy_index, shmem_base, shmem2_base, |
Yaniv Rosner | d90d96b | 2010-09-07 11:41:04 +0000 | [diff] [blame] | 12611 | 0, &phy) != 0) { |
| 12612 | DP(NETIF_MSG_LINK, "populate phy failed\n"); |
| 12613 | return 0; |
| 12614 | } |
| 12615 | |
| 12616 | if (phy.flags & FLAGS_HW_LOCK_REQUIRED) |
| 12617 | return 1; |
| 12618 | } |
| 12619 | return 0; |
| 12620 | } |
| 12621 | |
| 12622 | u8 bnx2x_fan_failure_det_req(struct bnx2x *bp, |
| 12623 | u32 shmem_base, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12624 | u32 shmem2_base, |
Yaniv Rosner | d90d96b | 2010-09-07 11:41:04 +0000 | [diff] [blame] | 12625 | u8 port) |
| 12626 | { |
| 12627 | u8 phy_index, fan_failure_det_req = 0; |
| 12628 | struct bnx2x_phy phy; |
| 12629 | for (phy_index = EXT_PHY1; phy_index < MAX_PHYS; |
| 12630 | phy_index++) { |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12631 | if (bnx2x_populate_phy(bp, phy_index, shmem_base, shmem2_base, |
Yaniv Rosner | d90d96b | 2010-09-07 11:41:04 +0000 | [diff] [blame] | 12632 | port, &phy) |
| 12633 | != 0) { |
| 12634 | DP(NETIF_MSG_LINK, "populate phy failed\n"); |
| 12635 | return 0; |
| 12636 | } |
| 12637 | fan_failure_det_req |= (phy.flags & |
| 12638 | FLAGS_FAN_FAILURE_DET_REQ); |
| 12639 | } |
| 12640 | return fan_failure_det_req; |
| 12641 | } |
| 12642 | |
| 12643 | void bnx2x_hw_reset_phy(struct link_params *params) |
| 12644 | { |
| 12645 | u8 phy_index; |
Yaniv Rosner | 985848f | 2011-07-05 01:06:48 +0000 | [diff] [blame] | 12646 | struct bnx2x *bp = params->bp; |
| 12647 | bnx2x_update_mng(params, 0); |
| 12648 | bnx2x_bits_dis(bp, NIG_REG_MASK_INTERRUPT_PORT0 + params->port*4, |
| 12649 | (NIG_MASK_XGXS0_LINK_STATUS | |
| 12650 | NIG_MASK_XGXS0_LINK10G | |
| 12651 | NIG_MASK_SERDES0_LINK_STATUS | |
| 12652 | NIG_MASK_MI_INT)); |
| 12653 | |
| 12654 | for (phy_index = INT_PHY; phy_index < MAX_PHYS; |
Yaniv Rosner | d90d96b | 2010-09-07 11:41:04 +0000 | [diff] [blame] | 12655 | phy_index++) { |
| 12656 | if (params->phy[phy_index].hw_reset) { |
| 12657 | params->phy[phy_index].hw_reset( |
| 12658 | ¶ms->phy[phy_index], |
| 12659 | params); |
| 12660 | params->phy[phy_index] = phy_null; |
| 12661 | } |
| 12662 | } |
| 12663 | } |
Yaniv Rosner | 020c7e3 | 2011-05-31 21:28:43 +0000 | [diff] [blame] | 12664 | |
| 12665 | void bnx2x_init_mod_abs_int(struct bnx2x *bp, struct link_vars *vars, |
| 12666 | u32 chip_id, u32 shmem_base, u32 shmem2_base, |
| 12667 | u8 port) |
| 12668 | { |
| 12669 | u8 gpio_num = 0xff, gpio_port = 0xff, phy_index; |
| 12670 | u32 val; |
| 12671 | u32 offset, aeu_mask, swap_val, swap_override, sync_offset; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 12672 | if (CHIP_IS_E3(bp)) { |
| 12673 | if (bnx2x_get_mod_abs_int_cfg(bp, chip_id, |
| 12674 | shmem_base, |
| 12675 | port, |
| 12676 | &gpio_num, |
| 12677 | &gpio_port) != 0) |
| 12678 | return; |
| 12679 | } else { |
Yaniv Rosner | 020c7e3 | 2011-05-31 21:28:43 +0000 | [diff] [blame] | 12680 | struct bnx2x_phy phy; |
| 12681 | for (phy_index = EXT_PHY1; phy_index < MAX_PHYS; |
| 12682 | phy_index++) { |
| 12683 | if (bnx2x_populate_phy(bp, phy_index, shmem_base, |
| 12684 | shmem2_base, port, &phy) |
| 12685 | != 0) { |
| 12686 | DP(NETIF_MSG_LINK, "populate phy failed\n"); |
| 12687 | return; |
| 12688 | } |
| 12689 | if (phy.type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726) { |
| 12690 | gpio_num = MISC_REGISTERS_GPIO_3; |
| 12691 | gpio_port = port; |
| 12692 | break; |
| 12693 | } |
| 12694 | } |
| 12695 | } |
| 12696 | |
| 12697 | if (gpio_num == 0xff) |
| 12698 | return; |
| 12699 | |
| 12700 | /* Set GPIO3 to trigger SFP+ module insertion/removal */ |
| 12701 | bnx2x_set_gpio(bp, gpio_num, MISC_REGISTERS_GPIO_INPUT_HI_Z, gpio_port); |
| 12702 | |
| 12703 | swap_val = REG_RD(bp, NIG_REG_PORT_SWAP); |
| 12704 | swap_override = REG_RD(bp, NIG_REG_STRAP_OVERRIDE); |
| 12705 | gpio_port ^= (swap_val && swap_override); |
| 12706 | |
| 12707 | vars->aeu_int_mask = AEU_INPUTS_ATTN_BITS_GPIO0_FUNCTION_0 << |
| 12708 | (gpio_num + (gpio_port << 2)); |
| 12709 | |
| 12710 | sync_offset = shmem_base + |
| 12711 | offsetof(struct shmem_region, |
| 12712 | dev_info.port_hw_config[port].aeu_int_mask); |
| 12713 | REG_WR(bp, sync_offset, vars->aeu_int_mask); |
| 12714 | |
| 12715 | DP(NETIF_MSG_LINK, "Setting MOD_ABS (GPIO%d_P%d) AEU to 0x%x\n", |
| 12716 | gpio_num, gpio_port, vars->aeu_int_mask); |
| 12717 | |
| 12718 | if (port == 0) |
| 12719 | offset = MISC_REG_AEU_ENABLE1_FUNC_0_OUT_0; |
| 12720 | else |
| 12721 | offset = MISC_REG_AEU_ENABLE1_FUNC_1_OUT_0; |
| 12722 | |
| 12723 | /* Open appropriate AEU for interrupts */ |
| 12724 | aeu_mask = REG_RD(bp, offset); |
| 12725 | aeu_mask |= vars->aeu_int_mask; |
| 12726 | REG_WR(bp, offset, aeu_mask); |
| 12727 | |
| 12728 | /* Enable the GPIO to trigger interrupt */ |
| 12729 | val = REG_RD(bp, MISC_REG_GPIO_EVENT_EN); |
| 12730 | val |= 1 << (gpio_num + (gpio_port << 2)); |
| 12731 | REG_WR(bp, MISC_REG_GPIO_EVENT_EN, val); |
| 12732 | } |