Ariel Elior | 85b26ea | 2012-01-26 06:01:54 +0000 | [diff] [blame] | 1 | /* Copyright 2008-2012 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 | /********************************************************/ |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 31 | #define ETH_HLEN 14 |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 32 | /* L2 header size + 2*VLANs (8 bytes) + LLC SNAP (8 bytes) */ |
| 33 | #define ETH_OVREHEAD (ETH_HLEN + 8 + 8) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 34 | #define ETH_MIN_PACKET_SIZE 60 |
| 35 | #define ETH_MAX_PACKET_SIZE 1500 |
| 36 | #define ETH_MAX_JUMBO_PACKET_SIZE 9600 |
| 37 | #define MDIO_ACCESS_TIMEOUT 1000 |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 38 | #define WC_LANE_MAX 4 |
| 39 | #define I2C_SWITCH_WIDTH 2 |
| 40 | #define I2C_BSC0 0 |
| 41 | #define I2C_BSC1 1 |
| 42 | #define I2C_WA_RETRY_CNT 3 |
| 43 | #define MCPR_IMC_COMMAND_READ_OP 1 |
| 44 | #define MCPR_IMC_COMMAND_WRITE_OP 2 |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 45 | |
Yaniv Rosner | 26ffaf3 | 2011-10-27 05:09:45 +0000 | [diff] [blame] | 46 | /* LED Blink rate that will achieve ~15.9Hz */ |
| 47 | #define LED_BLINK_RATE_VAL_E3 354 |
| 48 | #define LED_BLINK_RATE_VAL_E1X_E2 480 |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 49 | /***********************************************************/ |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 50 | /* Shortcut definitions */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 51 | /***********************************************************/ |
| 52 | |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 53 | #define NIG_LATCH_BC_ENABLE_MI_INT 0 |
| 54 | |
| 55 | #define NIG_STATUS_EMAC0_MI_INT \ |
| 56 | NIG_STATUS_INTERRUPT_PORT0_REG_STATUS_EMAC0_MISC_MI_INT |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 57 | #define NIG_STATUS_XGXS0_LINK10G \ |
| 58 | NIG_STATUS_INTERRUPT_PORT0_REG_STATUS_XGXS0_LINK10G |
| 59 | #define NIG_STATUS_XGXS0_LINK_STATUS \ |
| 60 | NIG_STATUS_INTERRUPT_PORT0_REG_STATUS_XGXS0_LINK_STATUS |
| 61 | #define NIG_STATUS_XGXS0_LINK_STATUS_SIZE \ |
| 62 | NIG_STATUS_INTERRUPT_PORT0_REG_STATUS_XGXS0_LINK_STATUS_SIZE |
| 63 | #define NIG_STATUS_SERDES0_LINK_STATUS \ |
| 64 | NIG_STATUS_INTERRUPT_PORT0_REG_STATUS_SERDES0_LINK_STATUS |
| 65 | #define NIG_MASK_MI_INT \ |
| 66 | NIG_MASK_INTERRUPT_PORT0_REG_MASK_EMAC0_MISC_MI_INT |
| 67 | #define NIG_MASK_XGXS0_LINK10G \ |
| 68 | NIG_MASK_INTERRUPT_PORT0_REG_MASK_XGXS0_LINK10G |
| 69 | #define NIG_MASK_XGXS0_LINK_STATUS \ |
| 70 | NIG_MASK_INTERRUPT_PORT0_REG_MASK_XGXS0_LINK_STATUS |
| 71 | #define NIG_MASK_SERDES0_LINK_STATUS \ |
| 72 | NIG_MASK_INTERRUPT_PORT0_REG_MASK_SERDES0_LINK_STATUS |
| 73 | |
| 74 | #define MDIO_AN_CL73_OR_37_COMPLETE \ |
| 75 | (MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_AUTONEG_COMPLETE | \ |
| 76 | MDIO_GP_STATUS_TOP_AN_STATUS1_CL37_AUTONEG_COMPLETE) |
| 77 | |
| 78 | #define XGXS_RESET_BITS \ |
| 79 | (MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_XGXS0_RSTB_HW | \ |
| 80 | MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_XGXS0_IDDQ | \ |
| 81 | MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_XGXS0_PWRDWN | \ |
| 82 | MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_XGXS0_PWRDWN_SD | \ |
| 83 | MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_XGXS0_TXD_FIFO_RSTB) |
| 84 | |
| 85 | #define SERDES_RESET_BITS \ |
| 86 | (MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_SERDES0_RSTB_HW | \ |
| 87 | MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_SERDES0_IDDQ | \ |
| 88 | MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_SERDES0_PWRDWN | \ |
| 89 | MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_SERDES0_PWRDWN_SD) |
| 90 | |
| 91 | #define AUTONEG_CL37 SHARED_HW_CFG_AN_ENABLE_CL37 |
| 92 | #define AUTONEG_CL73 SHARED_HW_CFG_AN_ENABLE_CL73 |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 93 | #define AUTONEG_BAM SHARED_HW_CFG_AN_ENABLE_BAM |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 94 | #define AUTONEG_PARALLEL \ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 95 | SHARED_HW_CFG_AN_ENABLE_PARALLEL_DETECTION |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 96 | #define AUTONEG_SGMII_FIBER_AUTODET \ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 97 | SHARED_HW_CFG_AN_EN_SGMII_FIBER_AUTO_DETECT |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 98 | #define AUTONEG_REMOTE_PHY SHARED_HW_CFG_AN_ENABLE_REMOTE_PHY |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 99 | |
| 100 | #define GP_STATUS_PAUSE_RSOLUTION_TXSIDE \ |
| 101 | MDIO_GP_STATUS_TOP_AN_STATUS1_PAUSE_RSOLUTION_TXSIDE |
| 102 | #define GP_STATUS_PAUSE_RSOLUTION_RXSIDE \ |
| 103 | MDIO_GP_STATUS_TOP_AN_STATUS1_PAUSE_RSOLUTION_RXSIDE |
| 104 | #define GP_STATUS_SPEED_MASK \ |
| 105 | MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_MASK |
| 106 | #define GP_STATUS_10M MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_10M |
| 107 | #define GP_STATUS_100M MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_100M |
| 108 | #define GP_STATUS_1G MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_1G |
| 109 | #define GP_STATUS_2_5G MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_2_5G |
| 110 | #define GP_STATUS_5G MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_5G |
| 111 | #define GP_STATUS_6G MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_6G |
| 112 | #define GP_STATUS_10G_HIG \ |
| 113 | MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_10G_HIG |
| 114 | #define GP_STATUS_10G_CX4 \ |
| 115 | MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_10G_CX4 |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 116 | #define GP_STATUS_1G_KX MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_1G_KX |
| 117 | #define GP_STATUS_10G_KX4 \ |
| 118 | MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_10G_KX4 |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 119 | #define GP_STATUS_10G_KR MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_10G_KR |
| 120 | #define GP_STATUS_10G_XFI MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_10G_XFI |
| 121 | #define GP_STATUS_20G_DXGXS MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_20G_DXGXS |
| 122 | #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] | 123 | #define LINK_10THD LINK_STATUS_SPEED_AND_DUPLEX_10THD |
| 124 | #define LINK_10TFD LINK_STATUS_SPEED_AND_DUPLEX_10TFD |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 125 | #define LINK_100TXHD LINK_STATUS_SPEED_AND_DUPLEX_100TXHD |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 126 | #define LINK_100T4 LINK_STATUS_SPEED_AND_DUPLEX_100T4 |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 127 | #define LINK_100TXFD LINK_STATUS_SPEED_AND_DUPLEX_100TXFD |
| 128 | #define LINK_1000THD LINK_STATUS_SPEED_AND_DUPLEX_1000THD |
| 129 | #define LINK_1000TFD LINK_STATUS_SPEED_AND_DUPLEX_1000TFD |
| 130 | #define LINK_1000XFD LINK_STATUS_SPEED_AND_DUPLEX_1000XFD |
| 131 | #define LINK_2500THD LINK_STATUS_SPEED_AND_DUPLEX_2500THD |
| 132 | #define LINK_2500TFD LINK_STATUS_SPEED_AND_DUPLEX_2500TFD |
| 133 | #define LINK_2500XFD LINK_STATUS_SPEED_AND_DUPLEX_2500XFD |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 134 | #define LINK_10GTFD LINK_STATUS_SPEED_AND_DUPLEX_10GTFD |
| 135 | #define LINK_10GXFD LINK_STATUS_SPEED_AND_DUPLEX_10GXFD |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 136 | #define LINK_20GTFD LINK_STATUS_SPEED_AND_DUPLEX_20GTFD |
| 137 | #define LINK_20GXFD LINK_STATUS_SPEED_AND_DUPLEX_20GXFD |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 138 | |
| 139 | |
| 140 | |
Eilon Greenstein | 589abe3 | 2009-02-12 08:36:55 +0000 | [diff] [blame] | 141 | /* */ |
| 142 | #define SFP_EEPROM_CON_TYPE_ADDR 0x2 |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 143 | #define SFP_EEPROM_CON_TYPE_VAL_LC 0x7 |
Eilon Greenstein | 589abe3 | 2009-02-12 08:36:55 +0000 | [diff] [blame] | 144 | #define SFP_EEPROM_CON_TYPE_VAL_COPPER 0x21 |
| 145 | |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 146 | |
| 147 | #define SFP_EEPROM_COMP_CODE_ADDR 0x3 |
| 148 | #define SFP_EEPROM_COMP_CODE_SR_MASK (1<<4) |
| 149 | #define SFP_EEPROM_COMP_CODE_LR_MASK (1<<5) |
| 150 | #define SFP_EEPROM_COMP_CODE_LRM_MASK (1<<6) |
| 151 | |
Eilon Greenstein | 589abe3 | 2009-02-12 08:36:55 +0000 | [diff] [blame] | 152 | #define SFP_EEPROM_FC_TX_TECH_ADDR 0x8 |
| 153 | #define SFP_EEPROM_FC_TX_TECH_BITMASK_COPPER_PASSIVE 0x4 |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 154 | #define SFP_EEPROM_FC_TX_TECH_BITMASK_COPPER_ACTIVE 0x8 |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 155 | |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 156 | #define SFP_EEPROM_OPTIONS_ADDR 0x40 |
Eilon Greenstein | 589abe3 | 2009-02-12 08:36:55 +0000 | [diff] [blame] | 157 | #define SFP_EEPROM_OPTIONS_LINEAR_RX_OUT_MASK 0x1 |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 158 | #define SFP_EEPROM_OPTIONS_SIZE 2 |
Eilon Greenstein | 589abe3 | 2009-02-12 08:36:55 +0000 | [diff] [blame] | 159 | |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 160 | #define EDC_MODE_LINEAR 0x0022 |
| 161 | #define EDC_MODE_LIMITING 0x0044 |
| 162 | #define EDC_MODE_PASSIVE_DAC 0x0055 |
Eilon Greenstein | 589abe3 | 2009-02-12 08:36:55 +0000 | [diff] [blame] | 163 | |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 164 | /* BRB default for class 0 E2 */ |
| 165 | #define DEFAULT0_E2_BRB_MAC_PAUSE_XOFF_THR 170 |
| 166 | #define DEFAULT0_E2_BRB_MAC_PAUSE_XON_THR 250 |
| 167 | #define DEFAULT0_E2_BRB_MAC_FULL_XOFF_THR 10 |
| 168 | #define DEFAULT0_E2_BRB_MAC_FULL_XON_THR 50 |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 169 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 170 | /* BRB thresholds for E2*/ |
| 171 | #define PFC_E2_BRB_MAC_PAUSE_XOFF_THR_PAUSE 170 |
| 172 | #define PFC_E2_BRB_MAC_PAUSE_XOFF_THR_NON_PAUSE 0 |
| 173 | |
| 174 | #define PFC_E2_BRB_MAC_PAUSE_XON_THR_PAUSE 250 |
| 175 | #define PFC_E2_BRB_MAC_PAUSE_XON_THR_NON_PAUSE 0 |
| 176 | |
| 177 | #define PFC_E2_BRB_MAC_FULL_XOFF_THR_PAUSE 10 |
| 178 | #define PFC_E2_BRB_MAC_FULL_XOFF_THR_NON_PAUSE 90 |
| 179 | |
| 180 | #define PFC_E2_BRB_MAC_FULL_XON_THR_PAUSE 50 |
| 181 | #define PFC_E2_BRB_MAC_FULL_XON_THR_NON_PAUSE 250 |
| 182 | |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 183 | /* BRB default for class 0 E3A0 */ |
| 184 | #define DEFAULT0_E3A0_BRB_MAC_PAUSE_XOFF_THR 290 |
| 185 | #define DEFAULT0_E3A0_BRB_MAC_PAUSE_XON_THR 410 |
| 186 | #define DEFAULT0_E3A0_BRB_MAC_FULL_XOFF_THR 10 |
| 187 | #define DEFAULT0_E3A0_BRB_MAC_FULL_XON_THR 50 |
| 188 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 189 | /* BRB thresholds for E3A0 */ |
| 190 | #define PFC_E3A0_BRB_MAC_PAUSE_XOFF_THR_PAUSE 290 |
| 191 | #define PFC_E3A0_BRB_MAC_PAUSE_XOFF_THR_NON_PAUSE 0 |
| 192 | |
| 193 | #define PFC_E3A0_BRB_MAC_PAUSE_XON_THR_PAUSE 410 |
| 194 | #define PFC_E3A0_BRB_MAC_PAUSE_XON_THR_NON_PAUSE 0 |
| 195 | |
| 196 | #define PFC_E3A0_BRB_MAC_FULL_XOFF_THR_PAUSE 10 |
| 197 | #define PFC_E3A0_BRB_MAC_FULL_XOFF_THR_NON_PAUSE 170 |
| 198 | |
| 199 | #define PFC_E3A0_BRB_MAC_FULL_XON_THR_PAUSE 50 |
| 200 | #define PFC_E3A0_BRB_MAC_FULL_XON_THR_NON_PAUSE 410 |
| 201 | |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 202 | /* BRB default for E3B0 */ |
| 203 | #define DEFAULT0_E3B0_BRB_MAC_PAUSE_XOFF_THR 330 |
| 204 | #define DEFAULT0_E3B0_BRB_MAC_PAUSE_XON_THR 490 |
| 205 | #define DEFAULT0_E3B0_BRB_MAC_FULL_XOFF_THR 15 |
| 206 | #define DEFAULT0_E3B0_BRB_MAC_FULL_XON_THR 55 |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 207 | |
| 208 | /* BRB thresholds for E3B0 2 port mode*/ |
| 209 | #define PFC_E3B0_2P_BRB_MAC_PAUSE_XOFF_THR_PAUSE 1025 |
| 210 | #define PFC_E3B0_2P_BRB_MAC_PAUSE_XOFF_THR_NON_PAUSE 0 |
| 211 | |
| 212 | #define PFC_E3B0_2P_BRB_MAC_PAUSE_XON_THR_PAUSE 1025 |
| 213 | #define PFC_E3B0_2P_BRB_MAC_PAUSE_XON_THR_NON_PAUSE 0 |
| 214 | |
| 215 | #define PFC_E3B0_2P_BRB_MAC_FULL_XOFF_THR_PAUSE 10 |
| 216 | #define PFC_E3B0_2P_BRB_MAC_FULL_XOFF_THR_NON_PAUSE 1025 |
| 217 | |
| 218 | #define PFC_E3B0_2P_BRB_MAC_FULL_XON_THR_PAUSE 50 |
| 219 | #define PFC_E3B0_2P_BRB_MAC_FULL_XON_THR_NON_PAUSE 1025 |
| 220 | |
| 221 | /* only for E3B0*/ |
| 222 | #define PFC_E3B0_2P_BRB_FULL_LB_XOFF_THR 1025 |
| 223 | #define PFC_E3B0_2P_BRB_FULL_LB_XON_THR 1025 |
| 224 | |
| 225 | /* Lossy +Lossless GUARANTIED == GUART */ |
| 226 | #define PFC_E3B0_2P_MIX_PAUSE_LB_GUART 284 |
| 227 | /* Lossless +Lossless*/ |
| 228 | #define PFC_E3B0_2P_PAUSE_LB_GUART 236 |
| 229 | /* Lossy +Lossy*/ |
| 230 | #define PFC_E3B0_2P_NON_PAUSE_LB_GUART 342 |
| 231 | |
| 232 | /* Lossy +Lossless*/ |
| 233 | #define PFC_E3B0_2P_MIX_PAUSE_MAC_0_CLASS_T_GUART 284 |
| 234 | /* Lossless +Lossless*/ |
| 235 | #define PFC_E3B0_2P_PAUSE_MAC_0_CLASS_T_GUART 236 |
| 236 | /* Lossy +Lossy*/ |
| 237 | #define PFC_E3B0_2P_NON_PAUSE_MAC_0_CLASS_T_GUART 336 |
| 238 | #define PFC_E3B0_2P_BRB_MAC_0_CLASS_T_GUART_HYST 80 |
| 239 | |
| 240 | #define PFC_E3B0_2P_BRB_MAC_1_CLASS_T_GUART 0 |
| 241 | #define PFC_E3B0_2P_BRB_MAC_1_CLASS_T_GUART_HYST 0 |
| 242 | |
| 243 | /* BRB thresholds for E3B0 4 port mode */ |
| 244 | #define PFC_E3B0_4P_BRB_MAC_PAUSE_XOFF_THR_PAUSE 304 |
| 245 | #define PFC_E3B0_4P_BRB_MAC_PAUSE_XOFF_THR_NON_PAUSE 0 |
| 246 | |
| 247 | #define PFC_E3B0_4P_BRB_MAC_PAUSE_XON_THR_PAUSE 384 |
| 248 | #define PFC_E3B0_4P_BRB_MAC_PAUSE_XON_THR_NON_PAUSE 0 |
| 249 | |
| 250 | #define PFC_E3B0_4P_BRB_MAC_FULL_XOFF_THR_PAUSE 10 |
| 251 | #define PFC_E3B0_4P_BRB_MAC_FULL_XOFF_THR_NON_PAUSE 304 |
| 252 | |
| 253 | #define PFC_E3B0_4P_BRB_MAC_FULL_XON_THR_PAUSE 50 |
| 254 | #define PFC_E3B0_4P_BRB_MAC_FULL_XON_THR_NON_PAUSE 384 |
| 255 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 256 | /* only for E3B0*/ |
| 257 | #define PFC_E3B0_4P_BRB_FULL_LB_XOFF_THR 304 |
| 258 | #define PFC_E3B0_4P_BRB_FULL_LB_XON_THR 384 |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 259 | #define PFC_E3B0_4P_LB_GUART 120 |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 260 | |
| 261 | #define PFC_E3B0_4P_BRB_MAC_0_CLASS_T_GUART 120 |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 262 | #define PFC_E3B0_4P_BRB_MAC_0_CLASS_T_GUART_HYST 80 |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 263 | |
| 264 | #define PFC_E3B0_4P_BRB_MAC_1_CLASS_T_GUART 80 |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 265 | #define PFC_E3B0_4P_BRB_MAC_1_CLASS_T_GUART_HYST 120 |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 266 | |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 267 | /* Pause defines*/ |
| 268 | #define DEFAULT_E3B0_BRB_FULL_LB_XOFF_THR 330 |
| 269 | #define DEFAULT_E3B0_BRB_FULL_LB_XON_THR 490 |
| 270 | #define DEFAULT_E3B0_LB_GUART 40 |
| 271 | |
| 272 | #define DEFAULT_E3B0_BRB_MAC_0_CLASS_T_GUART 40 |
| 273 | #define DEFAULT_E3B0_BRB_MAC_0_CLASS_T_GUART_HYST 0 |
| 274 | |
| 275 | #define DEFAULT_E3B0_BRB_MAC_1_CLASS_T_GUART 40 |
| 276 | #define DEFAULT_E3B0_BRB_MAC_1_CLASS_T_GUART_HYST 0 |
| 277 | |
| 278 | /* ETS defines*/ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 279 | #define DCBX_INVALID_COS (0xFF) |
| 280 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 281 | #define ETS_BW_LIMIT_CREDIT_UPPER_BOUND (0x5000) |
| 282 | #define ETS_BW_LIMIT_CREDIT_WEIGHT (0x5000) |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 283 | #define ETS_E3B0_NIG_MIN_W_VAL_UP_TO_10GBPS (1360) |
| 284 | #define ETS_E3B0_NIG_MIN_W_VAL_20GBPS (2720) |
| 285 | #define ETS_E3B0_PBF_MIN_W_VAL (10000) |
| 286 | |
| 287 | #define MAX_PACKET_SIZE (9700) |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 288 | #define WC_UC_TIMEOUT 100 |
Yaniv Rosner | a9077bf | 2011-10-27 05:09:46 +0000 | [diff] [blame] | 289 | #define MAX_KR_LINK_RETRY 4 |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 290 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 291 | /**********************************************************/ |
| 292 | /* INTERFACE */ |
| 293 | /**********************************************************/ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 294 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 295 | #define CL22_WR_OVER_CL45(_bp, _phy, _bank, _addr, _val) \ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 296 | bnx2x_cl45_write(_bp, _phy, \ |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 297 | (_phy)->def_md_devad, \ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 298 | (_bank + (_addr & 0xf)), \ |
| 299 | _val) |
| 300 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 301 | #define CL22_RD_OVER_CL45(_bp, _phy, _bank, _addr, _val) \ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 302 | bnx2x_cl45_read(_bp, _phy, \ |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 303 | (_phy)->def_md_devad, \ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 304 | (_bank + (_addr & 0xf)), \ |
| 305 | _val) |
| 306 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 307 | static u32 bnx2x_bits_en(struct bnx2x *bp, u32 reg, u32 bits) |
| 308 | { |
| 309 | u32 val = REG_RD(bp, reg); |
| 310 | |
| 311 | val |= bits; |
| 312 | REG_WR(bp, reg, val); |
| 313 | return val; |
| 314 | } |
| 315 | |
| 316 | static u32 bnx2x_bits_dis(struct bnx2x *bp, u32 reg, u32 bits) |
| 317 | { |
| 318 | u32 val = REG_RD(bp, reg); |
| 319 | |
| 320 | val &= ~bits; |
| 321 | REG_WR(bp, reg, val); |
| 322 | return val; |
| 323 | } |
| 324 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 325 | /******************************************************************/ |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 326 | /* EPIO/GPIO section */ |
| 327 | /******************************************************************/ |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 328 | static void bnx2x_get_epio(struct bnx2x *bp, u32 epio_pin, u32 *en) |
| 329 | { |
| 330 | u32 epio_mask, gp_oenable; |
| 331 | *en = 0; |
| 332 | /* Sanity check */ |
| 333 | if (epio_pin > 31) { |
| 334 | DP(NETIF_MSG_LINK, "Invalid EPIO pin %d to get\n", epio_pin); |
| 335 | return; |
| 336 | } |
| 337 | |
| 338 | epio_mask = 1 << epio_pin; |
| 339 | /* Set this EPIO to output */ |
| 340 | gp_oenable = REG_RD(bp, MCP_REG_MCPR_GP_OENABLE); |
| 341 | REG_WR(bp, MCP_REG_MCPR_GP_OENABLE, gp_oenable & ~epio_mask); |
| 342 | |
| 343 | *en = (REG_RD(bp, MCP_REG_MCPR_GP_INPUTS) & epio_mask) >> epio_pin; |
| 344 | } |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 345 | static void bnx2x_set_epio(struct bnx2x *bp, u32 epio_pin, u32 en) |
| 346 | { |
| 347 | u32 epio_mask, gp_output, gp_oenable; |
| 348 | |
| 349 | /* Sanity check */ |
| 350 | if (epio_pin > 31) { |
| 351 | DP(NETIF_MSG_LINK, "Invalid EPIO pin %d to set\n", epio_pin); |
| 352 | return; |
| 353 | } |
| 354 | DP(NETIF_MSG_LINK, "Setting EPIO pin %d to %d\n", epio_pin, en); |
| 355 | epio_mask = 1 << epio_pin; |
| 356 | /* Set this EPIO to output */ |
| 357 | gp_output = REG_RD(bp, MCP_REG_MCPR_GP_OUTPUTS); |
| 358 | if (en) |
| 359 | gp_output |= epio_mask; |
| 360 | else |
| 361 | gp_output &= ~epio_mask; |
| 362 | |
| 363 | REG_WR(bp, MCP_REG_MCPR_GP_OUTPUTS, gp_output); |
| 364 | |
| 365 | /* Set the value for this EPIO */ |
| 366 | gp_oenable = REG_RD(bp, MCP_REG_MCPR_GP_OENABLE); |
| 367 | REG_WR(bp, MCP_REG_MCPR_GP_OENABLE, gp_oenable | epio_mask); |
| 368 | } |
| 369 | |
| 370 | static void bnx2x_set_cfg_pin(struct bnx2x *bp, u32 pin_cfg, u32 val) |
| 371 | { |
| 372 | if (pin_cfg == PIN_CFG_NA) |
| 373 | return; |
| 374 | if (pin_cfg >= PIN_CFG_EPIO0) { |
| 375 | bnx2x_set_epio(bp, pin_cfg - PIN_CFG_EPIO0, val); |
| 376 | } else { |
| 377 | u8 gpio_num = (pin_cfg - PIN_CFG_GPIO0_P0) & 0x3; |
| 378 | u8 gpio_port = (pin_cfg - PIN_CFG_GPIO0_P0) >> 2; |
| 379 | bnx2x_set_gpio(bp, gpio_num, (u8)val, gpio_port); |
| 380 | } |
| 381 | } |
| 382 | |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 383 | static u32 bnx2x_get_cfg_pin(struct bnx2x *bp, u32 pin_cfg, u32 *val) |
| 384 | { |
| 385 | if (pin_cfg == PIN_CFG_NA) |
| 386 | return -EINVAL; |
| 387 | if (pin_cfg >= PIN_CFG_EPIO0) { |
| 388 | bnx2x_get_epio(bp, pin_cfg - PIN_CFG_EPIO0, val); |
| 389 | } else { |
| 390 | u8 gpio_num = (pin_cfg - PIN_CFG_GPIO0_P0) & 0x3; |
| 391 | u8 gpio_port = (pin_cfg - PIN_CFG_GPIO0_P0) >> 2; |
| 392 | *val = bnx2x_get_gpio(bp, gpio_num, gpio_port); |
| 393 | } |
| 394 | return 0; |
| 395 | |
| 396 | } |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 397 | /******************************************************************/ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 398 | /* ETS section */ |
| 399 | /******************************************************************/ |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 400 | static void bnx2x_ets_e2e3a0_disabled(struct link_params *params) |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 401 | { |
| 402 | /* ETS disabled configuration*/ |
| 403 | struct bnx2x *bp = params->bp; |
| 404 | |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 405 | DP(NETIF_MSG_LINK, "ETS E2E3 disabled configuration\n"); |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 406 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 407 | /* |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 408 | * mapping between entry priority to client number (0,1,2 -debug and |
| 409 | * management clients, 3 - COS0 client, 4 - COS client)(HIGHEST) |
| 410 | * 3bits client num. |
| 411 | * PRI4 | PRI3 | PRI2 | PRI1 | PRI0 |
| 412 | * cos1-100 cos0-011 dbg1-010 dbg0-001 MCP-000 |
| 413 | */ |
| 414 | |
| 415 | REG_WR(bp, NIG_REG_P0_TX_ARB_PRIORITY_CLIENT, 0x4688); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 416 | /* |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 417 | * Bitmap of 5bits length. Each bit specifies whether the entry behaves |
| 418 | * as strict. Bits 0,1,2 - debug and management entries, 3 - |
| 419 | * COS0 entry, 4 - COS1 entry. |
| 420 | * COS1 | COS0 | DEBUG1 | DEBUG0 | MGMT |
| 421 | * bit4 bit3 bit2 bit1 bit0 |
| 422 | * MCP and debug are strict |
| 423 | */ |
| 424 | |
| 425 | REG_WR(bp, NIG_REG_P0_TX_ARB_CLIENT_IS_STRICT, 0x7); |
| 426 | /* defines which entries (clients) are subjected to WFQ arbitration */ |
| 427 | REG_WR(bp, NIG_REG_P0_TX_ARB_CLIENT_IS_SUBJECT2WFQ, 0); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 428 | /* |
| 429 | * For strict priority entries defines the number of consecutive |
| 430 | * slots for the highest priority. |
| 431 | */ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 432 | 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] | 433 | /* |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 434 | * mapping between the CREDIT_WEIGHT registers and actual client |
| 435 | * numbers |
| 436 | */ |
| 437 | REG_WR(bp, NIG_REG_P0_TX_ARB_CLIENT_CREDIT_MAP, 0); |
| 438 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_0, 0); |
| 439 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_1, 0); |
| 440 | |
| 441 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_0, 0); |
| 442 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_1, 0); |
| 443 | REG_WR(bp, PBF_REG_HIGH_PRIORITY_COS_NUM, 0); |
| 444 | /* ETS mode disable */ |
| 445 | REG_WR(bp, PBF_REG_ETS_ENABLED, 0); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 446 | /* |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 447 | * If ETS mode is enabled (there is no strict priority) defines a WFQ |
| 448 | * weight for COS0/COS1. |
| 449 | */ |
| 450 | REG_WR(bp, PBF_REG_COS0_WEIGHT, 0x2710); |
| 451 | REG_WR(bp, PBF_REG_COS1_WEIGHT, 0x2710); |
| 452 | /* Upper bound that COS0_WEIGHT can reach in the WFQ arbiter */ |
| 453 | REG_WR(bp, PBF_REG_COS0_UPPER_BOUND, 0x989680); |
| 454 | REG_WR(bp, PBF_REG_COS1_UPPER_BOUND, 0x989680); |
| 455 | /* Defines the number of consecutive slots for the strict priority */ |
| 456 | REG_WR(bp, PBF_REG_NUM_STRICT_ARB_SLOTS, 0); |
| 457 | } |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 458 | /****************************************************************************** |
| 459 | * Description: |
| 460 | * Getting min_w_val will be set according to line speed . |
| 461 | *. |
| 462 | ******************************************************************************/ |
| 463 | static u32 bnx2x_ets_get_min_w_val_nig(const struct link_vars *vars) |
| 464 | { |
| 465 | u32 min_w_val = 0; |
| 466 | /* Calculate min_w_val.*/ |
| 467 | if (vars->link_up) { |
Yaniv Rosner | de0396f | 2011-11-28 00:49:53 +0000 | [diff] [blame] | 468 | if (vars->line_speed == SPEED_20000) |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 469 | min_w_val = ETS_E3B0_NIG_MIN_W_VAL_20GBPS; |
| 470 | else |
| 471 | min_w_val = ETS_E3B0_NIG_MIN_W_VAL_UP_TO_10GBPS; |
| 472 | } else |
| 473 | min_w_val = ETS_E3B0_NIG_MIN_W_VAL_20GBPS; |
| 474 | /** |
| 475 | * If the link isn't up (static configuration for example ) The |
| 476 | * link will be according to 20GBPS. |
| 477 | */ |
| 478 | return min_w_val; |
| 479 | } |
| 480 | /****************************************************************************** |
| 481 | * Description: |
| 482 | * Getting credit upper bound form min_w_val. |
| 483 | *. |
| 484 | ******************************************************************************/ |
| 485 | static u32 bnx2x_ets_get_credit_upper_bound(const u32 min_w_val) |
| 486 | { |
| 487 | const u32 credit_upper_bound = (u32)MAXVAL((150 * min_w_val), |
| 488 | MAX_PACKET_SIZE); |
| 489 | return credit_upper_bound; |
| 490 | } |
| 491 | /****************************************************************************** |
| 492 | * Description: |
| 493 | * Set credit upper bound for NIG. |
| 494 | *. |
| 495 | ******************************************************************************/ |
| 496 | static void bnx2x_ets_e3b0_set_credit_upper_bound_nig( |
| 497 | const struct link_params *params, |
| 498 | const u32 min_w_val) |
| 499 | { |
| 500 | struct bnx2x *bp = params->bp; |
| 501 | const u8 port = params->port; |
| 502 | const u32 credit_upper_bound = |
| 503 | bnx2x_ets_get_credit_upper_bound(min_w_val); |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 504 | |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 505 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CREDIT_UPPER_BOUND_0 : |
| 506 | NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_0, credit_upper_bound); |
| 507 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CREDIT_UPPER_BOUND_1 : |
| 508 | NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_1, credit_upper_bound); |
| 509 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CREDIT_UPPER_BOUND_2 : |
| 510 | NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_2, credit_upper_bound); |
| 511 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CREDIT_UPPER_BOUND_3 : |
| 512 | NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_3, credit_upper_bound); |
| 513 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CREDIT_UPPER_BOUND_4 : |
| 514 | NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_4, credit_upper_bound); |
| 515 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CREDIT_UPPER_BOUND_5 : |
| 516 | NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_5, credit_upper_bound); |
| 517 | |
Yaniv Rosner | de0396f | 2011-11-28 00:49:53 +0000 | [diff] [blame] | 518 | if (!port) { |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 519 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_6, |
| 520 | credit_upper_bound); |
| 521 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_7, |
| 522 | credit_upper_bound); |
| 523 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_8, |
| 524 | credit_upper_bound); |
| 525 | } |
| 526 | } |
| 527 | /****************************************************************************** |
| 528 | * Description: |
| 529 | * Will return the NIG ETS registers to init values.Except |
| 530 | * credit_upper_bound. |
| 531 | * That isn't used in this configuration (No WFQ is enabled) and will be |
| 532 | * configured acording to spec |
| 533 | *. |
| 534 | ******************************************************************************/ |
| 535 | static void bnx2x_ets_e3b0_nig_disabled(const struct link_params *params, |
| 536 | const struct link_vars *vars) |
| 537 | { |
| 538 | struct bnx2x *bp = params->bp; |
| 539 | const u8 port = params->port; |
| 540 | const u32 min_w_val = bnx2x_ets_get_min_w_val_nig(vars); |
| 541 | /** |
| 542 | * mapping between entry priority to client number (0,1,2 -debug and |
| 543 | * management clients, 3 - COS0 client, 4 - COS1, ... 8 - |
| 544 | * COS5)(HIGHEST) 4bits client num.TODO_ETS - Should be done by |
| 545 | * reset value or init tool |
| 546 | */ |
| 547 | if (port) { |
| 548 | REG_WR(bp, NIG_REG_P1_TX_ARB_PRIORITY_CLIENT2_LSB, 0x543210); |
| 549 | REG_WR(bp, NIG_REG_P1_TX_ARB_PRIORITY_CLIENT2_MSB, 0x0); |
| 550 | } else { |
| 551 | REG_WR(bp, NIG_REG_P0_TX_ARB_PRIORITY_CLIENT2_LSB, 0x76543210); |
| 552 | REG_WR(bp, NIG_REG_P0_TX_ARB_PRIORITY_CLIENT2_MSB, 0x8); |
| 553 | } |
| 554 | /** |
| 555 | * For strict priority entries defines the number of consecutive |
| 556 | * slots for the highest priority. |
| 557 | */ |
| 558 | /* TODO_ETS - Should be done by reset value or init tool */ |
| 559 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_NUM_STRICT_ARB_SLOTS : |
| 560 | NIG_REG_P1_TX_ARB_NUM_STRICT_ARB_SLOTS, 0x100); |
| 561 | /** |
| 562 | * mapping between the CREDIT_WEIGHT registers and actual client |
| 563 | * numbers |
| 564 | */ |
| 565 | /* TODO_ETS - Should be done by reset value or init tool */ |
| 566 | if (port) { |
| 567 | /*Port 1 has 6 COS*/ |
| 568 | REG_WR(bp, NIG_REG_P1_TX_ARB_CLIENT_CREDIT_MAP2_LSB, 0x210543); |
| 569 | REG_WR(bp, NIG_REG_P1_TX_ARB_CLIENT_CREDIT_MAP2_MSB, 0x0); |
| 570 | } else { |
| 571 | /*Port 0 has 9 COS*/ |
| 572 | REG_WR(bp, NIG_REG_P0_TX_ARB_CLIENT_CREDIT_MAP2_LSB, |
| 573 | 0x43210876); |
| 574 | REG_WR(bp, NIG_REG_P0_TX_ARB_CLIENT_CREDIT_MAP2_MSB, 0x5); |
| 575 | } |
| 576 | |
| 577 | /** |
| 578 | * Bitmap of 5bits length. Each bit specifies whether the entry behaves |
| 579 | * as strict. Bits 0,1,2 - debug and management entries, 3 - |
| 580 | * COS0 entry, 4 - COS1 entry. |
| 581 | * COS1 | COS0 | DEBUG1 | DEBUG0 | MGMT |
| 582 | * bit4 bit3 bit2 bit1 bit0 |
| 583 | * MCP and debug are strict |
| 584 | */ |
| 585 | if (port) |
| 586 | REG_WR(bp, NIG_REG_P1_TX_ARB_CLIENT_IS_STRICT, 0x3f); |
| 587 | else |
| 588 | REG_WR(bp, NIG_REG_P0_TX_ARB_CLIENT_IS_STRICT, 0x1ff); |
| 589 | /* defines which entries (clients) are subjected to WFQ arbitration */ |
| 590 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CLIENT_IS_SUBJECT2WFQ : |
| 591 | NIG_REG_P0_TX_ARB_CLIENT_IS_SUBJECT2WFQ, 0); |
| 592 | |
| 593 | /** |
| 594 | * Please notice the register address are note continuous and a |
| 595 | * for here is note appropriate.In 2 port mode port0 only COS0-5 |
| 596 | * can be used. DEBUG1,DEBUG1,MGMT are never used for WFQ* In 4 |
| 597 | * port mode port1 only COS0-2 can be used. DEBUG1,DEBUG1,MGMT |
| 598 | * are never used for WFQ |
| 599 | */ |
| 600 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CREDIT_WEIGHT_0 : |
| 601 | NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_0, 0x0); |
| 602 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CREDIT_WEIGHT_1 : |
| 603 | NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_1, 0x0); |
| 604 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CREDIT_WEIGHT_2 : |
| 605 | NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_2, 0x0); |
| 606 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CREDIT_WEIGHT_3 : |
| 607 | NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_3, 0x0); |
| 608 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CREDIT_WEIGHT_4 : |
| 609 | NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_4, 0x0); |
| 610 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CREDIT_WEIGHT_5 : |
| 611 | NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_5, 0x0); |
Yaniv Rosner | de0396f | 2011-11-28 00:49:53 +0000 | [diff] [blame] | 612 | if (!port) { |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 613 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_6, 0x0); |
| 614 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_7, 0x0); |
| 615 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_8, 0x0); |
| 616 | } |
| 617 | |
| 618 | bnx2x_ets_e3b0_set_credit_upper_bound_nig(params, min_w_val); |
| 619 | } |
| 620 | /****************************************************************************** |
| 621 | * Description: |
| 622 | * Set credit upper bound for PBF. |
| 623 | *. |
| 624 | ******************************************************************************/ |
| 625 | static void bnx2x_ets_e3b0_set_credit_upper_bound_pbf( |
| 626 | const struct link_params *params, |
| 627 | const u32 min_w_val) |
| 628 | { |
| 629 | struct bnx2x *bp = params->bp; |
| 630 | const u32 credit_upper_bound = |
| 631 | bnx2x_ets_get_credit_upper_bound(min_w_val); |
| 632 | const u8 port = params->port; |
| 633 | u32 base_upper_bound = 0; |
| 634 | u8 max_cos = 0; |
| 635 | u8 i = 0; |
| 636 | /** |
| 637 | * In 2 port mode port0 has COS0-5 that can be used for WFQ.In 4 |
| 638 | * port mode port1 has COS0-2 that can be used for WFQ. |
| 639 | */ |
Yaniv Rosner | de0396f | 2011-11-28 00:49:53 +0000 | [diff] [blame] | 640 | if (!port) { |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 641 | base_upper_bound = PBF_REG_COS0_UPPER_BOUND_P0; |
| 642 | max_cos = DCBX_E3B0_MAX_NUM_COS_PORT0; |
| 643 | } else { |
| 644 | base_upper_bound = PBF_REG_COS0_UPPER_BOUND_P1; |
| 645 | max_cos = DCBX_E3B0_MAX_NUM_COS_PORT1; |
| 646 | } |
| 647 | |
| 648 | for (i = 0; i < max_cos; i++) |
| 649 | REG_WR(bp, base_upper_bound + (i << 2), credit_upper_bound); |
| 650 | } |
| 651 | |
| 652 | /****************************************************************************** |
| 653 | * Description: |
| 654 | * Will return the PBF ETS registers to init values.Except |
| 655 | * credit_upper_bound. |
| 656 | * That isn't used in this configuration (No WFQ is enabled) and will be |
| 657 | * configured acording to spec |
| 658 | *. |
| 659 | ******************************************************************************/ |
| 660 | static void bnx2x_ets_e3b0_pbf_disabled(const struct link_params *params) |
| 661 | { |
| 662 | struct bnx2x *bp = params->bp; |
| 663 | const u8 port = params->port; |
| 664 | const u32 min_w_val_pbf = ETS_E3B0_PBF_MIN_W_VAL; |
| 665 | u8 i = 0; |
| 666 | u32 base_weight = 0; |
| 667 | u8 max_cos = 0; |
| 668 | |
| 669 | /** |
| 670 | * mapping between entry priority to client number 0 - COS0 |
| 671 | * client, 2 - COS1, ... 5 - COS5)(HIGHEST) 4bits client num. |
| 672 | * TODO_ETS - Should be done by reset value or init tool |
| 673 | */ |
| 674 | if (port) |
| 675 | /* 0x688 (|011|0 10|00 1|000) */ |
| 676 | REG_WR(bp, PBF_REG_ETS_ARB_PRIORITY_CLIENT_P1 , 0x688); |
| 677 | else |
| 678 | /* (10 1|100 |011|0 10|00 1|000) */ |
| 679 | REG_WR(bp, PBF_REG_ETS_ARB_PRIORITY_CLIENT_P0 , 0x2C688); |
| 680 | |
| 681 | /* TODO_ETS - Should be done by reset value or init tool */ |
| 682 | if (port) |
| 683 | /* 0x688 (|011|0 10|00 1|000)*/ |
| 684 | REG_WR(bp, PBF_REG_ETS_ARB_CLIENT_CREDIT_MAP_P1, 0x688); |
| 685 | else |
| 686 | /* 0x2C688 (10 1|100 |011|0 10|00 1|000) */ |
| 687 | REG_WR(bp, PBF_REG_ETS_ARB_CLIENT_CREDIT_MAP_P0, 0x2C688); |
| 688 | |
| 689 | REG_WR(bp, (port) ? PBF_REG_ETS_ARB_NUM_STRICT_ARB_SLOTS_P1 : |
| 690 | PBF_REG_ETS_ARB_NUM_STRICT_ARB_SLOTS_P0 , 0x100); |
| 691 | |
| 692 | |
| 693 | REG_WR(bp, (port) ? PBF_REG_ETS_ARB_CLIENT_IS_STRICT_P1 : |
| 694 | PBF_REG_ETS_ARB_CLIENT_IS_STRICT_P0 , 0); |
| 695 | |
| 696 | REG_WR(bp, (port) ? PBF_REG_ETS_ARB_CLIENT_IS_SUBJECT2WFQ_P1 : |
| 697 | PBF_REG_ETS_ARB_CLIENT_IS_SUBJECT2WFQ_P0 , 0); |
| 698 | /** |
| 699 | * In 2 port mode port0 has COS0-5 that can be used for WFQ. |
| 700 | * In 4 port mode port1 has COS0-2 that can be used for WFQ. |
| 701 | */ |
Yaniv Rosner | de0396f | 2011-11-28 00:49:53 +0000 | [diff] [blame] | 702 | if (!port) { |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 703 | base_weight = PBF_REG_COS0_WEIGHT_P0; |
| 704 | max_cos = DCBX_E3B0_MAX_NUM_COS_PORT0; |
| 705 | } else { |
| 706 | base_weight = PBF_REG_COS0_WEIGHT_P1; |
| 707 | max_cos = DCBX_E3B0_MAX_NUM_COS_PORT1; |
| 708 | } |
| 709 | |
| 710 | for (i = 0; i < max_cos; i++) |
| 711 | REG_WR(bp, base_weight + (0x4 * i), 0); |
| 712 | |
| 713 | bnx2x_ets_e3b0_set_credit_upper_bound_pbf(params, min_w_val_pbf); |
| 714 | } |
| 715 | /****************************************************************************** |
| 716 | * Description: |
| 717 | * E3B0 disable will return basicly the values to init values. |
| 718 | *. |
| 719 | ******************************************************************************/ |
| 720 | static int bnx2x_ets_e3b0_disabled(const struct link_params *params, |
| 721 | const struct link_vars *vars) |
| 722 | { |
| 723 | struct bnx2x *bp = params->bp; |
| 724 | |
| 725 | if (!CHIP_IS_E3B0(bp)) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 726 | DP(NETIF_MSG_LINK, |
| 727 | "bnx2x_ets_e3b0_disabled the chip isn't E3B0\n"); |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 728 | return -EINVAL; |
| 729 | } |
| 730 | |
| 731 | bnx2x_ets_e3b0_nig_disabled(params, vars); |
| 732 | |
| 733 | bnx2x_ets_e3b0_pbf_disabled(params); |
| 734 | |
| 735 | return 0; |
| 736 | } |
| 737 | |
| 738 | /****************************************************************************** |
| 739 | * Description: |
| 740 | * Disable will return basicly the values to init values. |
| 741 | *. |
| 742 | ******************************************************************************/ |
| 743 | int bnx2x_ets_disabled(struct link_params *params, |
| 744 | struct link_vars *vars) |
| 745 | { |
| 746 | struct bnx2x *bp = params->bp; |
| 747 | int bnx2x_status = 0; |
| 748 | |
| 749 | if ((CHIP_IS_E2(bp)) || (CHIP_IS_E3A0(bp))) |
| 750 | bnx2x_ets_e2e3a0_disabled(params); |
| 751 | else if (CHIP_IS_E3B0(bp)) |
| 752 | bnx2x_status = bnx2x_ets_e3b0_disabled(params, vars); |
| 753 | else { |
| 754 | DP(NETIF_MSG_LINK, "bnx2x_ets_disabled - chip not supported\n"); |
| 755 | return -EINVAL; |
| 756 | } |
| 757 | |
| 758 | return bnx2x_status; |
| 759 | } |
| 760 | |
| 761 | /****************************************************************************** |
| 762 | * Description |
| 763 | * Set the COS mappimg to SP and BW until this point all the COS are not |
| 764 | * set as SP or BW. |
| 765 | ******************************************************************************/ |
| 766 | static int bnx2x_ets_e3b0_cli_map(const struct link_params *params, |
| 767 | const struct bnx2x_ets_params *ets_params, |
| 768 | const u8 cos_sp_bitmap, |
| 769 | const u8 cos_bw_bitmap) |
| 770 | { |
| 771 | struct bnx2x *bp = params->bp; |
| 772 | const u8 port = params->port; |
| 773 | const u8 nig_cli_sp_bitmap = 0x7 | (cos_sp_bitmap << 3); |
| 774 | const u8 pbf_cli_sp_bitmap = cos_sp_bitmap; |
| 775 | const u8 nig_cli_subject2wfq_bitmap = cos_bw_bitmap << 3; |
| 776 | const u8 pbf_cli_subject2wfq_bitmap = cos_bw_bitmap; |
| 777 | |
| 778 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CLIENT_IS_STRICT : |
| 779 | NIG_REG_P0_TX_ARB_CLIENT_IS_STRICT, nig_cli_sp_bitmap); |
| 780 | |
| 781 | REG_WR(bp, (port) ? PBF_REG_ETS_ARB_CLIENT_IS_STRICT_P1 : |
| 782 | PBF_REG_ETS_ARB_CLIENT_IS_STRICT_P0 , pbf_cli_sp_bitmap); |
| 783 | |
| 784 | REG_WR(bp, (port) ? NIG_REG_P1_TX_ARB_CLIENT_IS_SUBJECT2WFQ : |
| 785 | NIG_REG_P0_TX_ARB_CLIENT_IS_SUBJECT2WFQ, |
| 786 | nig_cli_subject2wfq_bitmap); |
| 787 | |
| 788 | REG_WR(bp, (port) ? PBF_REG_ETS_ARB_CLIENT_IS_SUBJECT2WFQ_P1 : |
| 789 | PBF_REG_ETS_ARB_CLIENT_IS_SUBJECT2WFQ_P0, |
| 790 | pbf_cli_subject2wfq_bitmap); |
| 791 | |
| 792 | return 0; |
| 793 | } |
| 794 | |
| 795 | /****************************************************************************** |
| 796 | * Description: |
| 797 | * This function is needed because NIG ARB_CREDIT_WEIGHT_X are |
| 798 | * not continues and ARB_CREDIT_WEIGHT_0 + offset is suitable. |
| 799 | ******************************************************************************/ |
| 800 | static int bnx2x_ets_e3b0_set_cos_bw(struct bnx2x *bp, |
| 801 | const u8 cos_entry, |
| 802 | const u32 min_w_val_nig, |
| 803 | const u32 min_w_val_pbf, |
| 804 | const u16 total_bw, |
| 805 | const u8 bw, |
| 806 | const u8 port) |
| 807 | { |
| 808 | u32 nig_reg_adress_crd_weight = 0; |
| 809 | u32 pbf_reg_adress_crd_weight = 0; |
David S. Miller | 8decf86 | 2011-09-22 03:23:13 -0400 | [diff] [blame] | 810 | /* Calculate and set BW for this COS - use 1 instead of 0 for BW */ |
| 811 | const u32 cos_bw_nig = ((bw ? bw : 1) * min_w_val_nig) / total_bw; |
| 812 | 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] | 813 | |
| 814 | switch (cos_entry) { |
| 815 | case 0: |
| 816 | nig_reg_adress_crd_weight = |
| 817 | (port) ? NIG_REG_P1_TX_ARB_CREDIT_WEIGHT_0 : |
| 818 | NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_0; |
| 819 | pbf_reg_adress_crd_weight = (port) ? |
| 820 | PBF_REG_COS0_WEIGHT_P1 : PBF_REG_COS0_WEIGHT_P0; |
| 821 | break; |
| 822 | case 1: |
| 823 | nig_reg_adress_crd_weight = (port) ? |
| 824 | NIG_REG_P1_TX_ARB_CREDIT_WEIGHT_1 : |
| 825 | NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_1; |
| 826 | pbf_reg_adress_crd_weight = (port) ? |
| 827 | PBF_REG_COS1_WEIGHT_P1 : PBF_REG_COS1_WEIGHT_P0; |
| 828 | break; |
| 829 | case 2: |
| 830 | nig_reg_adress_crd_weight = (port) ? |
| 831 | NIG_REG_P1_TX_ARB_CREDIT_WEIGHT_2 : |
| 832 | NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_2; |
| 833 | |
| 834 | pbf_reg_adress_crd_weight = (port) ? |
| 835 | PBF_REG_COS2_WEIGHT_P1 : PBF_REG_COS2_WEIGHT_P0; |
| 836 | break; |
| 837 | case 3: |
| 838 | if (port) |
| 839 | return -EINVAL; |
| 840 | nig_reg_adress_crd_weight = |
| 841 | NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_3; |
| 842 | pbf_reg_adress_crd_weight = |
| 843 | PBF_REG_COS3_WEIGHT_P0; |
| 844 | break; |
| 845 | case 4: |
| 846 | if (port) |
| 847 | return -EINVAL; |
| 848 | nig_reg_adress_crd_weight = |
| 849 | NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_4; |
| 850 | pbf_reg_adress_crd_weight = PBF_REG_COS4_WEIGHT_P0; |
| 851 | break; |
| 852 | case 5: |
| 853 | if (port) |
| 854 | return -EINVAL; |
| 855 | nig_reg_adress_crd_weight = |
| 856 | NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_5; |
| 857 | pbf_reg_adress_crd_weight = PBF_REG_COS5_WEIGHT_P0; |
| 858 | break; |
| 859 | } |
| 860 | |
| 861 | REG_WR(bp, nig_reg_adress_crd_weight, cos_bw_nig); |
| 862 | |
| 863 | REG_WR(bp, pbf_reg_adress_crd_weight, cos_bw_pbf); |
| 864 | |
| 865 | return 0; |
| 866 | } |
| 867 | /****************************************************************************** |
| 868 | * Description: |
| 869 | * Calculate the total BW.A value of 0 isn't legal. |
| 870 | *. |
| 871 | ******************************************************************************/ |
| 872 | static int bnx2x_ets_e3b0_get_total_bw( |
| 873 | const struct link_params *params, |
Yaniv Rosner | 870516e1 | 2011-11-28 00:49:46 +0000 | [diff] [blame] | 874 | struct bnx2x_ets_params *ets_params, |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 875 | u16 *total_bw) |
| 876 | { |
| 877 | struct bnx2x *bp = params->bp; |
| 878 | u8 cos_idx = 0; |
Yaniv Rosner | 870516e1 | 2011-11-28 00:49:46 +0000 | [diff] [blame] | 879 | u8 is_bw_cos_exist = 0; |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 880 | |
| 881 | *total_bw = 0 ; |
Yaniv Rosner | 870516e1 | 2011-11-28 00:49:46 +0000 | [diff] [blame] | 882 | |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 883 | /* Calculate total BW requested */ |
| 884 | for (cos_idx = 0; cos_idx < ets_params->num_of_cos; cos_idx++) { |
Yaniv Rosner | de0396f | 2011-11-28 00:49:53 +0000 | [diff] [blame] | 885 | if (ets_params->cos[cos_idx].state == bnx2x_cos_state_bw) { |
Yaniv Rosner | 870516e1 | 2011-11-28 00:49:46 +0000 | [diff] [blame] | 886 | is_bw_cos_exist = 1; |
| 887 | if (!ets_params->cos[cos_idx].params.bw_params.bw) { |
| 888 | DP(NETIF_MSG_LINK, "bnx2x_ets_E3B0_config BW" |
| 889 | "was set to 0\n"); |
| 890 | /* |
| 891 | * This is to prevent a state when ramrods |
| 892 | * can't be sent |
| 893 | */ |
| 894 | ets_params->cos[cos_idx].params.bw_params.bw |
| 895 | = 1; |
| 896 | } |
David S. Miller | 8decf86 | 2011-09-22 03:23:13 -0400 | [diff] [blame] | 897 | *total_bw += |
| 898 | ets_params->cos[cos_idx].params.bw_params.bw; |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 899 | } |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 900 | } |
| 901 | |
David S. Miller | 8decf86 | 2011-09-22 03:23:13 -0400 | [diff] [blame] | 902 | /* Check total BW is valid */ |
Yaniv Rosner | de0396f | 2011-11-28 00:49:53 +0000 | [diff] [blame] | 903 | if ((is_bw_cos_exist == 1) && (*total_bw != 100)) { |
| 904 | if (*total_bw == 0) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 905 | DP(NETIF_MSG_LINK, |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 906 | "bnx2x_ets_E3B0_config total BW shouldn't be 0\n"); |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 907 | return -EINVAL; |
| 908 | } |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 909 | DP(NETIF_MSG_LINK, |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 910 | "bnx2x_ets_E3B0_config total BW should be 100\n"); |
| 911 | /* |
| 912 | * We can handle a case whre the BW isn't 100 this can happen |
| 913 | * if the TC are joined. |
| 914 | */ |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 915 | } |
| 916 | return 0; |
| 917 | } |
| 918 | |
| 919 | /****************************************************************************** |
| 920 | * Description: |
| 921 | * Invalidate all the sp_pri_to_cos. |
| 922 | *. |
| 923 | ******************************************************************************/ |
| 924 | static void bnx2x_ets_e3b0_sp_pri_to_cos_init(u8 *sp_pri_to_cos) |
| 925 | { |
| 926 | u8 pri = 0; |
| 927 | for (pri = 0; pri < DCBX_MAX_NUM_COS; pri++) |
| 928 | sp_pri_to_cos[pri] = DCBX_INVALID_COS; |
| 929 | } |
| 930 | /****************************************************************************** |
| 931 | * Description: |
| 932 | * Calculate and set the SP (ARB_PRIORITY_CLIENT) NIG and PBF registers |
| 933 | * according to sp_pri_to_cos. |
| 934 | *. |
| 935 | ******************************************************************************/ |
| 936 | static int bnx2x_ets_e3b0_sp_pri_to_cos_set(const struct link_params *params, |
| 937 | u8 *sp_pri_to_cos, const u8 pri, |
| 938 | const u8 cos_entry) |
| 939 | { |
| 940 | struct bnx2x *bp = params->bp; |
| 941 | const u8 port = params->port; |
| 942 | const u8 max_num_of_cos = (port) ? DCBX_E3B0_MAX_NUM_COS_PORT1 : |
| 943 | DCBX_E3B0_MAX_NUM_COS_PORT0; |
| 944 | |
Yaniv Rosner | de0396f | 2011-11-28 00:49:53 +0000 | [diff] [blame] | 945 | if (sp_pri_to_cos[pri] != DCBX_INVALID_COS) { |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 946 | 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] | 947 | "parameter There can't be two COS's with " |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 948 | "the same strict pri\n"); |
| 949 | return -EINVAL; |
| 950 | } |
| 951 | |
| 952 | if (pri > max_num_of_cos) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 953 | DP(NETIF_MSG_LINK, "bnx2x_ets_e3b0_sp_pri_to_cos_set invalid " |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 954 | "parameter Illegal strict priority\n"); |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 955 | return -EINVAL; |
| 956 | } |
| 957 | |
| 958 | sp_pri_to_cos[pri] = cos_entry; |
| 959 | return 0; |
| 960 | |
| 961 | } |
| 962 | |
| 963 | /****************************************************************************** |
| 964 | * Description: |
| 965 | * Returns the correct value according to COS and priority in |
| 966 | * the sp_pri_cli register. |
| 967 | *. |
| 968 | ******************************************************************************/ |
| 969 | static u64 bnx2x_e3b0_sp_get_pri_cli_reg(const u8 cos, const u8 cos_offset, |
| 970 | const u8 pri_set, |
| 971 | const u8 pri_offset, |
| 972 | const u8 entry_size) |
| 973 | { |
| 974 | u64 pri_cli_nig = 0; |
| 975 | pri_cli_nig = ((u64)(cos + cos_offset)) << (entry_size * |
| 976 | (pri_set + pri_offset)); |
| 977 | |
| 978 | return pri_cli_nig; |
| 979 | } |
| 980 | /****************************************************************************** |
| 981 | * Description: |
| 982 | * Returns the correct value according to COS and priority in the |
| 983 | * sp_pri_cli register for NIG. |
| 984 | *. |
| 985 | ******************************************************************************/ |
| 986 | static u64 bnx2x_e3b0_sp_get_pri_cli_reg_nig(const u8 cos, const u8 pri_set) |
| 987 | { |
| 988 | /* MCP Dbg0 and dbg1 are always with higher strict pri*/ |
| 989 | const u8 nig_cos_offset = 3; |
| 990 | const u8 nig_pri_offset = 3; |
| 991 | |
| 992 | return bnx2x_e3b0_sp_get_pri_cli_reg(cos, nig_cos_offset, pri_set, |
| 993 | nig_pri_offset, 4); |
| 994 | |
| 995 | } |
| 996 | /****************************************************************************** |
| 997 | * Description: |
| 998 | * Returns the correct value according to COS and priority in the |
| 999 | * sp_pri_cli register for PBF. |
| 1000 | *. |
| 1001 | ******************************************************************************/ |
| 1002 | static u64 bnx2x_e3b0_sp_get_pri_cli_reg_pbf(const u8 cos, const u8 pri_set) |
| 1003 | { |
| 1004 | const u8 pbf_cos_offset = 0; |
| 1005 | const u8 pbf_pri_offset = 0; |
| 1006 | |
| 1007 | return bnx2x_e3b0_sp_get_pri_cli_reg(cos, pbf_cos_offset, pri_set, |
| 1008 | pbf_pri_offset, 3); |
| 1009 | |
| 1010 | } |
| 1011 | |
| 1012 | /****************************************************************************** |
| 1013 | * Description: |
| 1014 | * Calculate and set the SP (ARB_PRIORITY_CLIENT) NIG and PBF registers |
| 1015 | * according to sp_pri_to_cos.(which COS has higher priority) |
| 1016 | *. |
| 1017 | ******************************************************************************/ |
| 1018 | static int bnx2x_ets_e3b0_sp_set_pri_cli_reg(const struct link_params *params, |
| 1019 | u8 *sp_pri_to_cos) |
| 1020 | { |
| 1021 | struct bnx2x *bp = params->bp; |
| 1022 | u8 i = 0; |
| 1023 | const u8 port = params->port; |
| 1024 | /* MCP Dbg0 and dbg1 are always with higher strict pri*/ |
| 1025 | u64 pri_cli_nig = 0x210; |
| 1026 | u32 pri_cli_pbf = 0x0; |
| 1027 | u8 pri_set = 0; |
| 1028 | u8 pri_bitmask = 0; |
| 1029 | const u8 max_num_of_cos = (port) ? DCBX_E3B0_MAX_NUM_COS_PORT1 : |
| 1030 | DCBX_E3B0_MAX_NUM_COS_PORT0; |
| 1031 | |
| 1032 | u8 cos_bit_to_set = (1 << max_num_of_cos) - 1; |
| 1033 | |
| 1034 | /* Set all the strict priority first */ |
| 1035 | for (i = 0; i < max_num_of_cos; i++) { |
Yaniv Rosner | de0396f | 2011-11-28 00:49:53 +0000 | [diff] [blame] | 1036 | if (sp_pri_to_cos[i] != DCBX_INVALID_COS) { |
| 1037 | if (sp_pri_to_cos[i] >= DCBX_MAX_NUM_COS) { |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 1038 | DP(NETIF_MSG_LINK, |
| 1039 | "bnx2x_ets_e3b0_sp_set_pri_cli_reg " |
| 1040 | "invalid cos entry\n"); |
| 1041 | return -EINVAL; |
| 1042 | } |
| 1043 | |
| 1044 | pri_cli_nig |= bnx2x_e3b0_sp_get_pri_cli_reg_nig( |
| 1045 | sp_pri_to_cos[i], pri_set); |
| 1046 | |
| 1047 | pri_cli_pbf |= bnx2x_e3b0_sp_get_pri_cli_reg_pbf( |
| 1048 | sp_pri_to_cos[i], pri_set); |
| 1049 | pri_bitmask = 1 << sp_pri_to_cos[i]; |
| 1050 | /* COS is used remove it from bitmap.*/ |
Yaniv Rosner | de0396f | 2011-11-28 00:49:53 +0000 | [diff] [blame] | 1051 | if (!(pri_bitmask & cos_bit_to_set)) { |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 1052 | DP(NETIF_MSG_LINK, |
| 1053 | "bnx2x_ets_e3b0_sp_set_pri_cli_reg " |
| 1054 | "invalid There can't be two COS's with" |
| 1055 | " the same strict pri\n"); |
| 1056 | return -EINVAL; |
| 1057 | } |
| 1058 | cos_bit_to_set &= ~pri_bitmask; |
| 1059 | pri_set++; |
| 1060 | } |
| 1061 | } |
| 1062 | |
| 1063 | /* Set all the Non strict priority i= COS*/ |
| 1064 | for (i = 0; i < max_num_of_cos; i++) { |
| 1065 | pri_bitmask = 1 << i; |
| 1066 | /* Check if COS was already used for SP */ |
| 1067 | if (pri_bitmask & cos_bit_to_set) { |
| 1068 | /* COS wasn't used for SP */ |
| 1069 | pri_cli_nig |= bnx2x_e3b0_sp_get_pri_cli_reg_nig( |
| 1070 | i, pri_set); |
| 1071 | |
| 1072 | pri_cli_pbf |= bnx2x_e3b0_sp_get_pri_cli_reg_pbf( |
| 1073 | i, pri_set); |
| 1074 | /* COS is used remove it from bitmap.*/ |
| 1075 | cos_bit_to_set &= ~pri_bitmask; |
| 1076 | pri_set++; |
| 1077 | } |
| 1078 | } |
| 1079 | |
| 1080 | if (pri_set != max_num_of_cos) { |
| 1081 | DP(NETIF_MSG_LINK, "bnx2x_ets_e3b0_sp_set_pri_cli_reg not all " |
| 1082 | "entries were set\n"); |
| 1083 | return -EINVAL; |
| 1084 | } |
| 1085 | |
| 1086 | if (port) { |
| 1087 | /* Only 6 usable clients*/ |
| 1088 | REG_WR(bp, NIG_REG_P1_TX_ARB_PRIORITY_CLIENT2_LSB, |
| 1089 | (u32)pri_cli_nig); |
| 1090 | |
| 1091 | REG_WR(bp, PBF_REG_ETS_ARB_PRIORITY_CLIENT_P1 , pri_cli_pbf); |
| 1092 | } else { |
| 1093 | /* Only 9 usable clients*/ |
| 1094 | const u32 pri_cli_nig_lsb = (u32) (pri_cli_nig); |
| 1095 | const u32 pri_cli_nig_msb = (u32) ((pri_cli_nig >> 32) & 0xF); |
| 1096 | |
| 1097 | REG_WR(bp, NIG_REG_P0_TX_ARB_PRIORITY_CLIENT2_LSB, |
| 1098 | pri_cli_nig_lsb); |
| 1099 | REG_WR(bp, NIG_REG_P0_TX_ARB_PRIORITY_CLIENT2_MSB, |
| 1100 | pri_cli_nig_msb); |
| 1101 | |
| 1102 | REG_WR(bp, PBF_REG_ETS_ARB_PRIORITY_CLIENT_P0 , pri_cli_pbf); |
| 1103 | } |
| 1104 | return 0; |
| 1105 | } |
| 1106 | |
| 1107 | /****************************************************************************** |
| 1108 | * Description: |
| 1109 | * Configure the COS to ETS according to BW and SP settings. |
| 1110 | ******************************************************************************/ |
| 1111 | int bnx2x_ets_e3b0_config(const struct link_params *params, |
| 1112 | const struct link_vars *vars, |
Yaniv Rosner | 870516e1 | 2011-11-28 00:49:46 +0000 | [diff] [blame] | 1113 | struct bnx2x_ets_params *ets_params) |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 1114 | { |
| 1115 | struct bnx2x *bp = params->bp; |
| 1116 | int bnx2x_status = 0; |
| 1117 | const u8 port = params->port; |
| 1118 | u16 total_bw = 0; |
| 1119 | const u32 min_w_val_nig = bnx2x_ets_get_min_w_val_nig(vars); |
| 1120 | const u32 min_w_val_pbf = ETS_E3B0_PBF_MIN_W_VAL; |
| 1121 | u8 cos_bw_bitmap = 0; |
| 1122 | u8 cos_sp_bitmap = 0; |
| 1123 | u8 sp_pri_to_cos[DCBX_MAX_NUM_COS] = {0}; |
| 1124 | const u8 max_num_of_cos = (port) ? DCBX_E3B0_MAX_NUM_COS_PORT1 : |
| 1125 | DCBX_E3B0_MAX_NUM_COS_PORT0; |
| 1126 | u8 cos_entry = 0; |
| 1127 | |
| 1128 | if (!CHIP_IS_E3B0(bp)) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 1129 | DP(NETIF_MSG_LINK, |
| 1130 | "bnx2x_ets_e3b0_disabled the chip isn't E3B0\n"); |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 1131 | return -EINVAL; |
| 1132 | } |
| 1133 | |
| 1134 | if ((ets_params->num_of_cos > max_num_of_cos)) { |
| 1135 | DP(NETIF_MSG_LINK, "bnx2x_ets_E3B0_config the number of COS " |
| 1136 | "isn't supported\n"); |
| 1137 | return -EINVAL; |
| 1138 | } |
| 1139 | |
| 1140 | /* Prepare sp strict priority parameters*/ |
| 1141 | bnx2x_ets_e3b0_sp_pri_to_cos_init(sp_pri_to_cos); |
| 1142 | |
| 1143 | /* Prepare BW parameters*/ |
| 1144 | bnx2x_status = bnx2x_ets_e3b0_get_total_bw(params, ets_params, |
| 1145 | &total_bw); |
Yaniv Rosner | de0396f | 2011-11-28 00:49:53 +0000 | [diff] [blame] | 1146 | if (bnx2x_status) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 1147 | DP(NETIF_MSG_LINK, |
| 1148 | "bnx2x_ets_E3B0_config get_total_bw failed\n"); |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 1149 | return -EINVAL; |
| 1150 | } |
| 1151 | |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 1152 | /* |
| 1153 | * Upper bound is set according to current link speed (min_w_val |
| 1154 | * should be the same for upper bound and COS credit val). |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 1155 | */ |
| 1156 | bnx2x_ets_e3b0_set_credit_upper_bound_nig(params, min_w_val_nig); |
| 1157 | bnx2x_ets_e3b0_set_credit_upper_bound_pbf(params, min_w_val_pbf); |
| 1158 | |
| 1159 | |
| 1160 | for (cos_entry = 0; cos_entry < ets_params->num_of_cos; cos_entry++) { |
| 1161 | if (bnx2x_cos_state_bw == ets_params->cos[cos_entry].state) { |
| 1162 | cos_bw_bitmap |= (1 << cos_entry); |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 1163 | /* |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 1164 | * The function also sets the BW in HW(not the mappin |
| 1165 | * yet) |
| 1166 | */ |
| 1167 | bnx2x_status = bnx2x_ets_e3b0_set_cos_bw( |
| 1168 | bp, cos_entry, min_w_val_nig, min_w_val_pbf, |
| 1169 | total_bw, |
| 1170 | ets_params->cos[cos_entry].params.bw_params.bw, |
| 1171 | port); |
| 1172 | } else if (bnx2x_cos_state_strict == |
| 1173 | ets_params->cos[cos_entry].state){ |
| 1174 | cos_sp_bitmap |= (1 << cos_entry); |
| 1175 | |
| 1176 | bnx2x_status = bnx2x_ets_e3b0_sp_pri_to_cos_set( |
| 1177 | params, |
| 1178 | sp_pri_to_cos, |
| 1179 | ets_params->cos[cos_entry].params.sp_params.pri, |
| 1180 | cos_entry); |
| 1181 | |
| 1182 | } else { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 1183 | DP(NETIF_MSG_LINK, |
| 1184 | "bnx2x_ets_e3b0_config cos state not valid\n"); |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 1185 | return -EINVAL; |
| 1186 | } |
Yaniv Rosner | de0396f | 2011-11-28 00:49:53 +0000 | [diff] [blame] | 1187 | if (bnx2x_status) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 1188 | DP(NETIF_MSG_LINK, |
| 1189 | "bnx2x_ets_e3b0_config set cos bw failed\n"); |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 1190 | return bnx2x_status; |
| 1191 | } |
| 1192 | } |
| 1193 | |
| 1194 | /* Set SP register (which COS has higher priority) */ |
| 1195 | bnx2x_status = bnx2x_ets_e3b0_sp_set_pri_cli_reg(params, |
| 1196 | sp_pri_to_cos); |
| 1197 | |
Yaniv Rosner | de0396f | 2011-11-28 00:49:53 +0000 | [diff] [blame] | 1198 | if (bnx2x_status) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 1199 | DP(NETIF_MSG_LINK, |
| 1200 | "bnx2x_ets_E3B0_config set_pri_cli_reg failed\n"); |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 1201 | return bnx2x_status; |
| 1202 | } |
| 1203 | |
| 1204 | /* Set client mapping of BW and strict */ |
| 1205 | bnx2x_status = bnx2x_ets_e3b0_cli_map(params, ets_params, |
| 1206 | cos_sp_bitmap, |
| 1207 | cos_bw_bitmap); |
| 1208 | |
Yaniv Rosner | de0396f | 2011-11-28 00:49:53 +0000 | [diff] [blame] | 1209 | if (bnx2x_status) { |
Yaniv Rosner | 6c3218c | 2011-06-14 01:34:23 +0000 | [diff] [blame] | 1210 | DP(NETIF_MSG_LINK, "bnx2x_ets_E3B0_config SP failed\n"); |
| 1211 | return bnx2x_status; |
| 1212 | } |
| 1213 | return 0; |
| 1214 | } |
Yaniv Rosner | 65a001b | 2011-01-31 04:22:03 +0000 | [diff] [blame] | 1215 | static void bnx2x_ets_bw_limit_common(const struct link_params *params) |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1216 | { |
| 1217 | /* ETS disabled configuration */ |
| 1218 | struct bnx2x *bp = params->bp; |
| 1219 | DP(NETIF_MSG_LINK, "ETS enabled BW limit configuration\n"); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 1220 | /* |
| 1221 | * defines which entries (clients) are subjected to WFQ arbitration |
| 1222 | * COS0 0x8 |
| 1223 | * COS1 0x10 |
| 1224 | */ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1225 | REG_WR(bp, NIG_REG_P0_TX_ARB_CLIENT_IS_SUBJECT2WFQ, 0x18); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 1226 | /* |
| 1227 | * mapping between the ARB_CREDIT_WEIGHT registers and actual |
| 1228 | * client numbers (WEIGHT_0 does not actually have to represent |
| 1229 | * client 0) |
| 1230 | * PRI4 | PRI3 | PRI2 | PRI1 | PRI0 |
| 1231 | * cos1-001 cos0-000 dbg1-100 dbg0-011 MCP-010 |
| 1232 | */ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1233 | REG_WR(bp, NIG_REG_P0_TX_ARB_CLIENT_CREDIT_MAP, 0x111A); |
| 1234 | |
| 1235 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_0, |
| 1236 | ETS_BW_LIMIT_CREDIT_UPPER_BOUND); |
| 1237 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_1, |
| 1238 | ETS_BW_LIMIT_CREDIT_UPPER_BOUND); |
| 1239 | |
| 1240 | /* ETS mode enabled*/ |
| 1241 | REG_WR(bp, PBF_REG_ETS_ENABLED, 1); |
| 1242 | |
| 1243 | /* Defines the number of consecutive slots for the strict priority */ |
| 1244 | REG_WR(bp, PBF_REG_NUM_STRICT_ARB_SLOTS, 0); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 1245 | /* |
| 1246 | * Bitmap of 5bits length. Each bit specifies whether the entry behaves |
| 1247 | * as strict. Bits 0,1,2 - debug and management entries, 3 - COS0 |
| 1248 | * entry, 4 - COS1 entry. |
| 1249 | * COS1 | COS0 | DEBUG21 | DEBUG0 | MGMT |
| 1250 | * bit4 bit3 bit2 bit1 bit0 |
| 1251 | * MCP and debug are strict |
| 1252 | */ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1253 | REG_WR(bp, NIG_REG_P0_TX_ARB_CLIENT_IS_STRICT, 0x7); |
| 1254 | |
| 1255 | /* Upper bound that COS0_WEIGHT can reach in the WFQ arbiter.*/ |
| 1256 | REG_WR(bp, PBF_REG_COS0_UPPER_BOUND, |
| 1257 | ETS_BW_LIMIT_CREDIT_UPPER_BOUND); |
| 1258 | REG_WR(bp, PBF_REG_COS1_UPPER_BOUND, |
| 1259 | ETS_BW_LIMIT_CREDIT_UPPER_BOUND); |
| 1260 | } |
| 1261 | |
| 1262 | void bnx2x_ets_bw_limit(const struct link_params *params, const u32 cos0_bw, |
| 1263 | const u32 cos1_bw) |
| 1264 | { |
| 1265 | /* ETS disabled configuration*/ |
| 1266 | struct bnx2x *bp = params->bp; |
| 1267 | const u32 total_bw = cos0_bw + cos1_bw; |
| 1268 | u32 cos0_credit_weight = 0; |
| 1269 | u32 cos1_credit_weight = 0; |
| 1270 | |
| 1271 | DP(NETIF_MSG_LINK, "ETS enabled BW limit configuration\n"); |
| 1272 | |
Yaniv Rosner | de0396f | 2011-11-28 00:49:53 +0000 | [diff] [blame] | 1273 | if ((!total_bw) || |
| 1274 | (!cos0_bw) || |
| 1275 | (!cos1_bw)) { |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1276 | DP(NETIF_MSG_LINK, "Total BW can't be zero\n"); |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1277 | return; |
| 1278 | } |
| 1279 | |
| 1280 | cos0_credit_weight = (cos0_bw * ETS_BW_LIMIT_CREDIT_WEIGHT)/ |
| 1281 | total_bw; |
| 1282 | cos1_credit_weight = (cos1_bw * ETS_BW_LIMIT_CREDIT_WEIGHT)/ |
| 1283 | total_bw; |
| 1284 | |
| 1285 | bnx2x_ets_bw_limit_common(params); |
| 1286 | |
| 1287 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_0, cos0_credit_weight); |
| 1288 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_1, cos1_credit_weight); |
| 1289 | |
| 1290 | REG_WR(bp, PBF_REG_COS0_WEIGHT, cos0_credit_weight); |
| 1291 | REG_WR(bp, PBF_REG_COS1_WEIGHT, cos1_credit_weight); |
| 1292 | } |
| 1293 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 1294 | 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] | 1295 | { |
| 1296 | /* ETS disabled configuration*/ |
| 1297 | struct bnx2x *bp = params->bp; |
| 1298 | u32 val = 0; |
| 1299 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1300 | DP(NETIF_MSG_LINK, "ETS enabled strict configuration\n"); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 1301 | /* |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1302 | * Bitmap of 5bits length. Each bit specifies whether the entry behaves |
| 1303 | * as strict. Bits 0,1,2 - debug and management entries, |
| 1304 | * 3 - COS0 entry, 4 - COS1 entry. |
| 1305 | * COS1 | COS0 | DEBUG21 | DEBUG0 | MGMT |
| 1306 | * bit4 bit3 bit2 bit1 bit0 |
| 1307 | * MCP and debug are strict |
| 1308 | */ |
| 1309 | REG_WR(bp, NIG_REG_P0_TX_ARB_CLIENT_IS_STRICT, 0x1F); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 1310 | /* |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1311 | * For strict priority entries defines the number of consecutive slots |
| 1312 | * for the highest priority. |
| 1313 | */ |
| 1314 | REG_WR(bp, NIG_REG_P0_TX_ARB_NUM_STRICT_ARB_SLOTS, 0x100); |
| 1315 | /* ETS mode disable */ |
| 1316 | REG_WR(bp, PBF_REG_ETS_ENABLED, 0); |
| 1317 | /* Defines the number of consecutive slots for the strict priority */ |
| 1318 | REG_WR(bp, PBF_REG_NUM_STRICT_ARB_SLOTS, 0x100); |
| 1319 | |
| 1320 | /* Defines the number of consecutive slots for the strict priority */ |
| 1321 | REG_WR(bp, PBF_REG_HIGH_PRIORITY_COS_NUM, strict_cos); |
| 1322 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 1323 | /* |
| 1324 | * mapping between entry priority to client number (0,1,2 -debug and |
| 1325 | * management clients, 3 - COS0 client, 4 - COS client)(HIGHEST) |
| 1326 | * 3bits client num. |
| 1327 | * PRI4 | PRI3 | PRI2 | PRI1 | PRI0 |
| 1328 | * dbg0-010 dbg1-001 cos1-100 cos0-011 MCP-000 |
| 1329 | * dbg0-010 dbg1-001 cos0-011 cos1-100 MCP-000 |
| 1330 | */ |
Yaniv Rosner | de0396f | 2011-11-28 00:49:53 +0000 | [diff] [blame] | 1331 | val = (!strict_cos) ? 0x2318 : 0x22E0; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1332 | REG_WR(bp, NIG_REG_P0_TX_ARB_PRIORITY_CLIENT, val); |
| 1333 | |
| 1334 | return 0; |
| 1335 | } |
| 1336 | /******************************************************************/ |
Dmitry Kravkov | e892067 | 2011-05-04 23:52:40 +0000 | [diff] [blame] | 1337 | /* PFC section */ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1338 | /******************************************************************/ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1339 | static void bnx2x_update_pfc_xmac(struct link_params *params, |
| 1340 | struct link_vars *vars, |
| 1341 | u8 is_lb) |
| 1342 | { |
| 1343 | struct bnx2x *bp = params->bp; |
| 1344 | u32 xmac_base; |
| 1345 | u32 pause_val, pfc0_val, pfc1_val; |
| 1346 | |
| 1347 | /* XMAC base adrr */ |
| 1348 | xmac_base = (params->port) ? GRCBASE_XMAC1 : GRCBASE_XMAC0; |
| 1349 | |
| 1350 | /* Initialize pause and pfc registers */ |
| 1351 | pause_val = 0x18000; |
| 1352 | pfc0_val = 0xFFFF8000; |
| 1353 | pfc1_val = 0x2; |
| 1354 | |
| 1355 | /* No PFC support */ |
| 1356 | if (!(params->feature_config_flags & |
| 1357 | FEATURE_CONFIG_PFC_ENABLED)) { |
| 1358 | |
| 1359 | /* |
| 1360 | * RX flow control - Process pause frame in receive direction |
| 1361 | */ |
| 1362 | if (vars->flow_ctrl & BNX2X_FLOW_CTRL_RX) |
| 1363 | pause_val |= XMAC_PAUSE_CTRL_REG_RX_PAUSE_EN; |
| 1364 | |
| 1365 | /* |
| 1366 | * TX flow control - Send pause packet when buffer is full |
| 1367 | */ |
| 1368 | if (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX) |
| 1369 | pause_val |= XMAC_PAUSE_CTRL_REG_TX_PAUSE_EN; |
| 1370 | } else {/* PFC support */ |
| 1371 | pfc1_val |= XMAC_PFC_CTRL_HI_REG_PFC_REFRESH_EN | |
| 1372 | XMAC_PFC_CTRL_HI_REG_PFC_STATS_EN | |
| 1373 | XMAC_PFC_CTRL_HI_REG_RX_PFC_EN | |
Yaniv Rosner | 27d9129 | 2012-04-04 01:28:54 +0000 | [diff] [blame] | 1374 | XMAC_PFC_CTRL_HI_REG_TX_PFC_EN | |
| 1375 | XMAC_PFC_CTRL_HI_REG_FORCE_PFC_XON; |
| 1376 | /* Write pause and PFC registers */ |
| 1377 | REG_WR(bp, xmac_base + XMAC_REG_PAUSE_CTRL, pause_val); |
| 1378 | REG_WR(bp, xmac_base + XMAC_REG_PFC_CTRL, pfc0_val); |
| 1379 | REG_WR(bp, xmac_base + XMAC_REG_PFC_CTRL_HI, pfc1_val); |
| 1380 | pfc1_val &= ~XMAC_PFC_CTRL_HI_REG_FORCE_PFC_XON; |
| 1381 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1382 | } |
| 1383 | |
| 1384 | /* Write pause and PFC registers */ |
| 1385 | REG_WR(bp, xmac_base + XMAC_REG_PAUSE_CTRL, pause_val); |
| 1386 | REG_WR(bp, xmac_base + XMAC_REG_PFC_CTRL, pfc0_val); |
| 1387 | REG_WR(bp, xmac_base + XMAC_REG_PFC_CTRL_HI, pfc1_val); |
| 1388 | |
Yaniv Rosner | b8d6d08 | 2011-07-05 01:06:27 +0000 | [diff] [blame] | 1389 | |
| 1390 | /* Set MAC address for source TX Pause/PFC frames */ |
| 1391 | REG_WR(bp, xmac_base + XMAC_REG_CTRL_SA_LO, |
| 1392 | ((params->mac_addr[2] << 24) | |
| 1393 | (params->mac_addr[3] << 16) | |
| 1394 | (params->mac_addr[4] << 8) | |
| 1395 | (params->mac_addr[5]))); |
| 1396 | REG_WR(bp, xmac_base + XMAC_REG_CTRL_SA_HI, |
| 1397 | ((params->mac_addr[0] << 8) | |
| 1398 | (params->mac_addr[1]))); |
| 1399 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1400 | udelay(30); |
| 1401 | } |
| 1402 | |
| 1403 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1404 | static void bnx2x_emac_get_pfc_stat(struct link_params *params, |
| 1405 | u32 pfc_frames_sent[2], |
| 1406 | u32 pfc_frames_received[2]) |
| 1407 | { |
| 1408 | /* Read pfc statistic */ |
| 1409 | struct bnx2x *bp = params->bp; |
| 1410 | u32 emac_base = params->port ? GRCBASE_EMAC1 : GRCBASE_EMAC0; |
| 1411 | u32 val_xon = 0; |
| 1412 | u32 val_xoff = 0; |
| 1413 | |
| 1414 | DP(NETIF_MSG_LINK, "pfc statistic read from EMAC\n"); |
| 1415 | |
| 1416 | /* PFC received frames */ |
| 1417 | val_xoff = REG_RD(bp, emac_base + |
| 1418 | EMAC_REG_RX_PFC_STATS_XOFF_RCVD); |
| 1419 | val_xoff &= EMAC_REG_RX_PFC_STATS_XOFF_RCVD_COUNT; |
| 1420 | val_xon = REG_RD(bp, emac_base + EMAC_REG_RX_PFC_STATS_XON_RCVD); |
| 1421 | val_xon &= EMAC_REG_RX_PFC_STATS_XON_RCVD_COUNT; |
| 1422 | |
| 1423 | pfc_frames_received[0] = val_xon + val_xoff; |
| 1424 | |
| 1425 | /* PFC received sent */ |
| 1426 | val_xoff = REG_RD(bp, emac_base + |
| 1427 | EMAC_REG_RX_PFC_STATS_XOFF_SENT); |
| 1428 | val_xoff &= EMAC_REG_RX_PFC_STATS_XOFF_SENT_COUNT; |
| 1429 | val_xon = REG_RD(bp, emac_base + EMAC_REG_RX_PFC_STATS_XON_SENT); |
| 1430 | val_xon &= EMAC_REG_RX_PFC_STATS_XON_SENT_COUNT; |
| 1431 | |
| 1432 | pfc_frames_sent[0] = val_xon + val_xoff; |
| 1433 | } |
| 1434 | |
Yaniv Rosner | b8d6d08 | 2011-07-05 01:06:27 +0000 | [diff] [blame] | 1435 | /* Read pfc statistic*/ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1436 | void bnx2x_pfc_statistic(struct link_params *params, struct link_vars *vars, |
| 1437 | u32 pfc_frames_sent[2], |
| 1438 | u32 pfc_frames_received[2]) |
| 1439 | { |
| 1440 | /* Read pfc statistic */ |
| 1441 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | b8d6d08 | 2011-07-05 01:06:27 +0000 | [diff] [blame] | 1442 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1443 | DP(NETIF_MSG_LINK, "pfc statistic\n"); |
| 1444 | |
| 1445 | if (!vars->link_up) |
| 1446 | return; |
| 1447 | |
Yaniv Rosner | de0396f | 2011-11-28 00:49:53 +0000 | [diff] [blame] | 1448 | if (vars->mac_type == MAC_TYPE_EMAC) { |
Yaniv Rosner | b8d6d08 | 2011-07-05 01:06:27 +0000 | [diff] [blame] | 1449 | DP(NETIF_MSG_LINK, "About to read PFC stats from EMAC\n"); |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1450 | bnx2x_emac_get_pfc_stat(params, pfc_frames_sent, |
| 1451 | pfc_frames_received); |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1452 | } |
| 1453 | } |
| 1454 | /******************************************************************/ |
| 1455 | /* MAC/PBF section */ |
| 1456 | /******************************************************************/ |
Yaniv Rosner | a198c14 | 2011-05-31 21:29:42 +0000 | [diff] [blame] | 1457 | static void bnx2x_set_mdio_clk(struct bnx2x *bp, u32 chip_id, u8 port) |
| 1458 | { |
| 1459 | u32 mode, emac_base; |
| 1460 | /** |
| 1461 | * Set clause 45 mode, slow down the MDIO clock to 2.5MHz |
| 1462 | * (a value of 49==0x31) and make sure that the AUTO poll is off |
| 1463 | */ |
| 1464 | |
| 1465 | if (CHIP_IS_E2(bp)) |
| 1466 | emac_base = GRCBASE_EMAC0; |
| 1467 | else |
| 1468 | emac_base = (port) ? GRCBASE_EMAC1 : GRCBASE_EMAC0; |
| 1469 | mode = REG_RD(bp, emac_base + EMAC_REG_EMAC_MDIO_MODE); |
| 1470 | mode &= ~(EMAC_MDIO_MODE_AUTO_POLL | |
| 1471 | EMAC_MDIO_MODE_CLOCK_CNT); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 1472 | if (USES_WARPCORE(bp)) |
| 1473 | mode |= (74L << EMAC_MDIO_MODE_CLOCK_CNT_BITSHIFT); |
| 1474 | else |
| 1475 | mode |= (49L << EMAC_MDIO_MODE_CLOCK_CNT_BITSHIFT); |
Yaniv Rosner | a198c14 | 2011-05-31 21:29:42 +0000 | [diff] [blame] | 1476 | |
| 1477 | mode |= (EMAC_MDIO_MODE_CLAUSE_45); |
| 1478 | REG_WR(bp, emac_base + EMAC_REG_EMAC_MDIO_MODE, mode); |
| 1479 | |
| 1480 | udelay(40); |
| 1481 | } |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 1482 | static u8 bnx2x_is_4_port_mode(struct bnx2x *bp) |
| 1483 | { |
| 1484 | u32 port4mode_ovwr_val; |
| 1485 | /* Check 4-port override enabled */ |
| 1486 | port4mode_ovwr_val = REG_RD(bp, MISC_REG_PORT4MODE_EN_OVWR); |
| 1487 | if (port4mode_ovwr_val & (1<<0)) { |
| 1488 | /* Return 4-port mode override value */ |
| 1489 | return ((port4mode_ovwr_val & (1<<1)) == (1<<1)); |
| 1490 | } |
| 1491 | /* Return 4-port mode from input pin */ |
| 1492 | return (u8)REG_RD(bp, MISC_REG_PORT4MODE_EN); |
| 1493 | } |
Yaniv Rosner | a198c14 | 2011-05-31 21:29:42 +0000 | [diff] [blame] | 1494 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1495 | static void bnx2x_emac_init(struct link_params *params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1496 | struct link_vars *vars) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1497 | { |
| 1498 | /* reset and unreset the emac core */ |
| 1499 | struct bnx2x *bp = params->bp; |
| 1500 | u8 port = params->port; |
| 1501 | u32 emac_base = port ? GRCBASE_EMAC1 : GRCBASE_EMAC0; |
| 1502 | u32 val; |
| 1503 | u16 timeout; |
| 1504 | |
| 1505 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_CLEAR, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1506 | (MISC_REGISTERS_RESET_REG_2_RST_EMAC0_HARD_CORE << port)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1507 | udelay(5); |
| 1508 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_SET, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1509 | (MISC_REGISTERS_RESET_REG_2_RST_EMAC0_HARD_CORE << port)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1510 | |
| 1511 | /* init emac - use read-modify-write */ |
| 1512 | /* self clear reset */ |
| 1513 | val = REG_RD(bp, emac_base + EMAC_REG_EMAC_MODE); |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 1514 | EMAC_WR(bp, EMAC_REG_EMAC_MODE, (val | EMAC_MODE_RESET)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1515 | |
| 1516 | timeout = 200; |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 1517 | do { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1518 | val = REG_RD(bp, emac_base + EMAC_REG_EMAC_MODE); |
| 1519 | DP(NETIF_MSG_LINK, "EMAC reset reg is %u\n", val); |
| 1520 | if (!timeout) { |
| 1521 | DP(NETIF_MSG_LINK, "EMAC timeout!\n"); |
| 1522 | return; |
| 1523 | } |
| 1524 | timeout--; |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 1525 | } while (val & EMAC_MODE_RESET); |
Yaniv Rosner | a198c14 | 2011-05-31 21:29:42 +0000 | [diff] [blame] | 1526 | bnx2x_set_mdio_clk(bp, params->chip_id, port); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1527 | /* Set mac address */ |
| 1528 | val = ((params->mac_addr[0] << 8) | |
| 1529 | params->mac_addr[1]); |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 1530 | EMAC_WR(bp, EMAC_REG_EMAC_MAC_MATCH, val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1531 | |
| 1532 | val = ((params->mac_addr[2] << 24) | |
| 1533 | (params->mac_addr[3] << 16) | |
| 1534 | (params->mac_addr[4] << 8) | |
| 1535 | params->mac_addr[5]); |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 1536 | EMAC_WR(bp, EMAC_REG_EMAC_MAC_MATCH + 4, val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1537 | } |
| 1538 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1539 | static void bnx2x_set_xumac_nig(struct link_params *params, |
| 1540 | u16 tx_pause_en, |
| 1541 | u8 enable) |
| 1542 | { |
| 1543 | struct bnx2x *bp = params->bp; |
| 1544 | |
| 1545 | REG_WR(bp, params->port ? NIG_REG_P1_MAC_IN_EN : NIG_REG_P0_MAC_IN_EN, |
| 1546 | enable); |
| 1547 | REG_WR(bp, params->port ? NIG_REG_P1_MAC_OUT_EN : NIG_REG_P0_MAC_OUT_EN, |
| 1548 | enable); |
| 1549 | REG_WR(bp, params->port ? NIG_REG_P1_MAC_PAUSE_OUT_EN : |
| 1550 | NIG_REG_P0_MAC_PAUSE_OUT_EN, tx_pause_en); |
| 1551 | } |
| 1552 | |
Yaniv Rosner | ce7c048 | 2011-10-27 05:09:47 +0000 | [diff] [blame] | 1553 | static void bnx2x_umac_disable(struct link_params *params) |
| 1554 | { |
| 1555 | u32 umac_base = params->port ? GRCBASE_UMAC1 : GRCBASE_UMAC0; |
| 1556 | struct bnx2x *bp = params->bp; |
| 1557 | if (!(REG_RD(bp, MISC_REG_RESET_REG_2) & |
| 1558 | (MISC_REGISTERS_RESET_REG_2_UMAC0 << params->port))) |
| 1559 | return; |
| 1560 | |
| 1561 | /* Disable RX and TX */ |
| 1562 | REG_WR(bp, umac_base + UMAC_REG_COMMAND_CONFIG, 0); |
| 1563 | } |
| 1564 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1565 | static void bnx2x_umac_enable(struct link_params *params, |
| 1566 | struct link_vars *vars, u8 lb) |
| 1567 | { |
| 1568 | u32 val; |
| 1569 | u32 umac_base = params->port ? GRCBASE_UMAC1 : GRCBASE_UMAC0; |
| 1570 | struct bnx2x *bp = params->bp; |
| 1571 | /* Reset UMAC */ |
| 1572 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_CLEAR, |
| 1573 | (MISC_REGISTERS_RESET_REG_2_UMAC0 << params->port)); |
| 1574 | usleep_range(1000, 1000); |
| 1575 | |
| 1576 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_SET, |
| 1577 | (MISC_REGISTERS_RESET_REG_2_UMAC0 << params->port)); |
| 1578 | |
| 1579 | DP(NETIF_MSG_LINK, "enabling UMAC\n"); |
| 1580 | |
| 1581 | /** |
| 1582 | * This register determines on which events the MAC will assert |
| 1583 | * error on the i/f to the NIG along w/ EOP. |
| 1584 | */ |
| 1585 | |
| 1586 | /** |
| 1587 | * BD REG_WR(bp, NIG_REG_P0_MAC_RSV_ERR_MASK + |
| 1588 | * params->port*0x14, 0xfffff. |
| 1589 | */ |
| 1590 | /* This register opens the gate for the UMAC despite its name */ |
| 1591 | REG_WR(bp, NIG_REG_EGRESS_EMAC0_PORT + params->port*4, 1); |
| 1592 | |
| 1593 | val = UMAC_COMMAND_CONFIG_REG_PROMIS_EN | |
| 1594 | UMAC_COMMAND_CONFIG_REG_PAD_EN | |
| 1595 | UMAC_COMMAND_CONFIG_REG_SW_RESET | |
| 1596 | UMAC_COMMAND_CONFIG_REG_NO_LGTH_CHECK; |
| 1597 | switch (vars->line_speed) { |
| 1598 | case SPEED_10: |
| 1599 | val |= (0<<2); |
| 1600 | break; |
| 1601 | case SPEED_100: |
| 1602 | val |= (1<<2); |
| 1603 | break; |
| 1604 | case SPEED_1000: |
| 1605 | val |= (2<<2); |
| 1606 | break; |
| 1607 | case SPEED_2500: |
| 1608 | val |= (3<<2); |
| 1609 | break; |
| 1610 | default: |
| 1611 | DP(NETIF_MSG_LINK, "Invalid speed for UMAC %d\n", |
| 1612 | vars->line_speed); |
| 1613 | break; |
| 1614 | } |
Yaniv Rosner | 9d5b36b | 2011-08-02 22:59:10 +0000 | [diff] [blame] | 1615 | if (!(vars->flow_ctrl & BNX2X_FLOW_CTRL_TX)) |
| 1616 | val |= UMAC_COMMAND_CONFIG_REG_IGNORE_TX_PAUSE; |
| 1617 | |
| 1618 | if (!(vars->flow_ctrl & BNX2X_FLOW_CTRL_RX)) |
| 1619 | val |= UMAC_COMMAND_CONFIG_REG_PAUSE_IGNORE; |
| 1620 | |
Mintz Yuval | e18c56b | 2012-02-15 02:10:23 +0000 | [diff] [blame] | 1621 | if (vars->duplex == DUPLEX_HALF) |
| 1622 | val |= UMAC_COMMAND_CONFIG_REG_HD_ENA; |
| 1623 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1624 | REG_WR(bp, umac_base + UMAC_REG_COMMAND_CONFIG, val); |
| 1625 | udelay(50); |
| 1626 | |
Yaniv Rosner | b8d6d08 | 2011-07-05 01:06:27 +0000 | [diff] [blame] | 1627 | /* Set MAC address for source TX Pause/PFC frames (under SW reset) */ |
| 1628 | REG_WR(bp, umac_base + UMAC_REG_MAC_ADDR0, |
| 1629 | ((params->mac_addr[2] << 24) | |
| 1630 | (params->mac_addr[3] << 16) | |
| 1631 | (params->mac_addr[4] << 8) | |
| 1632 | (params->mac_addr[5]))); |
| 1633 | REG_WR(bp, umac_base + UMAC_REG_MAC_ADDR1, |
| 1634 | ((params->mac_addr[0] << 8) | |
| 1635 | (params->mac_addr[1]))); |
| 1636 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1637 | /* Enable RX and TX */ |
| 1638 | val &= ~UMAC_COMMAND_CONFIG_REG_PAD_EN; |
| 1639 | val |= UMAC_COMMAND_CONFIG_REG_TX_ENA | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 1640 | UMAC_COMMAND_CONFIG_REG_RX_ENA; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1641 | REG_WR(bp, umac_base + UMAC_REG_COMMAND_CONFIG, val); |
| 1642 | udelay(50); |
| 1643 | |
| 1644 | /* Remove SW Reset */ |
| 1645 | val &= ~UMAC_COMMAND_CONFIG_REG_SW_RESET; |
| 1646 | |
| 1647 | /* Check loopback mode */ |
| 1648 | if (lb) |
| 1649 | val |= UMAC_COMMAND_CONFIG_REG_LOOP_ENA; |
| 1650 | REG_WR(bp, umac_base + UMAC_REG_COMMAND_CONFIG, val); |
| 1651 | |
| 1652 | /* |
| 1653 | * Maximum Frame Length (RW). Defines a 14-Bit maximum frame |
| 1654 | * length used by the MAC receive logic to check frames. |
| 1655 | */ |
| 1656 | REG_WR(bp, umac_base + UMAC_REG_MAXFR, 0x2710); |
| 1657 | bnx2x_set_xumac_nig(params, |
| 1658 | ((vars->flow_ctrl & BNX2X_FLOW_CTRL_TX) != 0), 1); |
| 1659 | vars->mac_type = MAC_TYPE_UMAC; |
| 1660 | |
| 1661 | } |
| 1662 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1663 | /* Define the XMAC mode */ |
Yaniv Rosner | ce7c048 | 2011-10-27 05:09:47 +0000 | [diff] [blame] | 1664 | static void bnx2x_xmac_init(struct link_params *params, u32 max_speed) |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1665 | { |
Yaniv Rosner | ce7c048 | 2011-10-27 05:09:47 +0000 | [diff] [blame] | 1666 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1667 | u32 is_port4mode = bnx2x_is_4_port_mode(bp); |
| 1668 | |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 1669 | /* |
| 1670 | * In 4-port mode, need to set the mode only once, so if XMAC is |
| 1671 | * already out of reset, it means the mode has already been set, |
| 1672 | * and it must not* reset the XMAC again, since it controls both |
| 1673 | * ports of the path |
| 1674 | */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1675 | |
Yaniv Rosner | ce7c048 | 2011-10-27 05:09:47 +0000 | [diff] [blame] | 1676 | if ((CHIP_NUM(bp) == CHIP_NUM_57840) && |
| 1677 | (REG_RD(bp, MISC_REG_RESET_REG_2) & |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1678 | MISC_REGISTERS_RESET_REG_2_XMAC)) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 1679 | DP(NETIF_MSG_LINK, |
| 1680 | "XMAC already out of reset in 4-port mode\n"); |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1681 | return; |
| 1682 | } |
| 1683 | |
| 1684 | /* Hard reset */ |
| 1685 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_CLEAR, |
| 1686 | MISC_REGISTERS_RESET_REG_2_XMAC); |
| 1687 | usleep_range(1000, 1000); |
| 1688 | |
| 1689 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_SET, |
| 1690 | MISC_REGISTERS_RESET_REG_2_XMAC); |
| 1691 | if (is_port4mode) { |
| 1692 | DP(NETIF_MSG_LINK, "Init XMAC to 2 ports x 10G per path\n"); |
| 1693 | |
| 1694 | /* Set the number of ports on the system side to up to 2 */ |
| 1695 | REG_WR(bp, MISC_REG_XMAC_CORE_PORT_MODE, 1); |
| 1696 | |
| 1697 | /* Set the number of ports on the Warp Core to 10G */ |
| 1698 | REG_WR(bp, MISC_REG_XMAC_PHY_PORT_MODE, 3); |
| 1699 | } else { |
| 1700 | /* Set the number of ports on the system side to 1 */ |
| 1701 | REG_WR(bp, MISC_REG_XMAC_CORE_PORT_MODE, 0); |
| 1702 | if (max_speed == SPEED_10000) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 1703 | DP(NETIF_MSG_LINK, |
| 1704 | "Init XMAC to 10G x 1 port per path\n"); |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1705 | /* Set the number of ports on the Warp Core to 10G */ |
| 1706 | REG_WR(bp, MISC_REG_XMAC_PHY_PORT_MODE, 3); |
| 1707 | } else { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 1708 | DP(NETIF_MSG_LINK, |
| 1709 | "Init XMAC to 20G x 2 ports per path\n"); |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1710 | /* Set the number of ports on the Warp Core to 20G */ |
| 1711 | REG_WR(bp, MISC_REG_XMAC_PHY_PORT_MODE, 1); |
| 1712 | } |
| 1713 | } |
| 1714 | /* Soft reset */ |
| 1715 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_CLEAR, |
| 1716 | MISC_REGISTERS_RESET_REG_2_XMAC_SOFT); |
| 1717 | usleep_range(1000, 1000); |
| 1718 | |
| 1719 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_SET, |
| 1720 | MISC_REGISTERS_RESET_REG_2_XMAC_SOFT); |
| 1721 | |
| 1722 | } |
| 1723 | |
| 1724 | static void bnx2x_xmac_disable(struct link_params *params) |
| 1725 | { |
| 1726 | u8 port = params->port; |
| 1727 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | b507766 | 2011-08-02 22:59:18 +0000 | [diff] [blame] | 1728 | u32 pfc_ctrl, xmac_base = (port) ? GRCBASE_XMAC1 : GRCBASE_XMAC0; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1729 | |
| 1730 | if (REG_RD(bp, MISC_REG_RESET_REG_2) & |
| 1731 | MISC_REGISTERS_RESET_REG_2_XMAC) { |
Yaniv Rosner | b507766 | 2011-08-02 22:59:18 +0000 | [diff] [blame] | 1732 | /* |
| 1733 | * Send an indication to change the state in the NIG back to XON |
| 1734 | * Clearing this bit enables the next set of this bit to get |
| 1735 | * rising edge |
| 1736 | */ |
| 1737 | pfc_ctrl = REG_RD(bp, xmac_base + XMAC_REG_PFC_CTRL_HI); |
| 1738 | REG_WR(bp, xmac_base + XMAC_REG_PFC_CTRL_HI, |
| 1739 | (pfc_ctrl & ~(1<<1))); |
| 1740 | REG_WR(bp, xmac_base + XMAC_REG_PFC_CTRL_HI, |
| 1741 | (pfc_ctrl | (1<<1))); |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1742 | DP(NETIF_MSG_LINK, "Disable XMAC on port %x\n", port); |
| 1743 | REG_WR(bp, xmac_base + XMAC_REG_CTRL, 0); |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1744 | } |
| 1745 | } |
| 1746 | |
| 1747 | static int bnx2x_xmac_enable(struct link_params *params, |
| 1748 | struct link_vars *vars, u8 lb) |
| 1749 | { |
| 1750 | u32 val, xmac_base; |
| 1751 | struct bnx2x *bp = params->bp; |
| 1752 | DP(NETIF_MSG_LINK, "enabling XMAC\n"); |
| 1753 | |
| 1754 | xmac_base = (params->port) ? GRCBASE_XMAC1 : GRCBASE_XMAC0; |
| 1755 | |
Yaniv Rosner | ce7c048 | 2011-10-27 05:09:47 +0000 | [diff] [blame] | 1756 | bnx2x_xmac_init(params, vars->line_speed); |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1757 | |
| 1758 | /* |
| 1759 | * This register determines on which events the MAC will assert |
| 1760 | * error on the i/f to the NIG along w/ EOP. |
| 1761 | */ |
| 1762 | |
| 1763 | /* |
| 1764 | * This register tells the NIG whether to send traffic to UMAC |
| 1765 | * or XMAC |
| 1766 | */ |
| 1767 | REG_WR(bp, NIG_REG_EGRESS_EMAC0_PORT + params->port*4, 0); |
| 1768 | |
| 1769 | /* Set Max packet size */ |
| 1770 | REG_WR(bp, xmac_base + XMAC_REG_RX_MAX_SIZE, 0x2710); |
| 1771 | |
| 1772 | /* CRC append for Tx packets */ |
| 1773 | REG_WR(bp, xmac_base + XMAC_REG_TX_CTRL, 0xC800); |
| 1774 | |
| 1775 | /* update PFC */ |
| 1776 | bnx2x_update_pfc_xmac(params, vars, 0); |
| 1777 | |
| 1778 | /* Enable TX and RX */ |
| 1779 | val = XMAC_CTRL_REG_TX_EN | XMAC_CTRL_REG_RX_EN; |
| 1780 | |
| 1781 | /* Check loopback mode */ |
| 1782 | if (lb) |
David S. Miller | 8decf86 | 2011-09-22 03:23:13 -0400 | [diff] [blame] | 1783 | val |= XMAC_CTRL_REG_LINE_LOCAL_LPBK; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 1784 | REG_WR(bp, xmac_base + XMAC_REG_CTRL, val); |
| 1785 | bnx2x_set_xumac_nig(params, |
| 1786 | ((vars->flow_ctrl & BNX2X_FLOW_CTRL_TX) != 0), 1); |
| 1787 | |
| 1788 | vars->mac_type = MAC_TYPE_XMAC; |
| 1789 | |
| 1790 | return 0; |
| 1791 | } |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 1792 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 1793 | static int bnx2x_emac_enable(struct link_params *params, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 1794 | struct link_vars *vars, u8 lb) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1795 | { |
| 1796 | struct bnx2x *bp = params->bp; |
| 1797 | u8 port = params->port; |
| 1798 | u32 emac_base = port ? GRCBASE_EMAC1 : GRCBASE_EMAC0; |
| 1799 | u32 val; |
| 1800 | |
| 1801 | DP(NETIF_MSG_LINK, "enabling EMAC\n"); |
| 1802 | |
Yaniv Rosner | de6f337 | 2011-08-02 22:59:25 +0000 | [diff] [blame] | 1803 | /* Disable BMAC */ |
| 1804 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_CLEAR, |
| 1805 | (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << port)); |
| 1806 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1807 | /* enable emac and not bmac */ |
| 1808 | REG_WR(bp, NIG_REG_EGRESS_EMAC0_PORT + port*4, 1); |
| 1809 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1810 | /* ASIC */ |
| 1811 | if (vars->phy_flags & PHY_XGXS_FLAG) { |
| 1812 | u32 ser_lane = ((params->lane_config & |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1813 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_MASK) >> |
| 1814 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_SHIFT); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1815 | |
| 1816 | DP(NETIF_MSG_LINK, "XGXS\n"); |
| 1817 | /* select the master lanes (out of 0-3) */ |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1818 | 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] | 1819 | /* select XGXS */ |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1820 | REG_WR(bp, NIG_REG_XGXS_SERDES0_MODE_SEL + port*4, 1); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1821 | |
| 1822 | } else { /* SerDes */ |
| 1823 | DP(NETIF_MSG_LINK, "SerDes\n"); |
| 1824 | /* select SerDes */ |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1825 | REG_WR(bp, NIG_REG_XGXS_SERDES0_MODE_SEL + port*4, 0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1826 | } |
| 1827 | |
Eilon Greenstein | 811a2f2 | 2009-02-12 08:37:04 +0000 | [diff] [blame] | 1828 | bnx2x_bits_en(bp, emac_base + EMAC_REG_EMAC_RX_MODE, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1829 | EMAC_RX_MODE_RESET); |
Eilon Greenstein | 811a2f2 | 2009-02-12 08:37:04 +0000 | [diff] [blame] | 1830 | bnx2x_bits_en(bp, emac_base + EMAC_REG_EMAC_TX_MODE, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1831 | EMAC_TX_MODE_RESET); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1832 | |
| 1833 | if (CHIP_REV_IS_SLOW(bp)) { |
| 1834 | /* config GMII mode */ |
| 1835 | val = REG_RD(bp, emac_base + EMAC_REG_EMAC_MODE); |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1836 | EMAC_WR(bp, EMAC_REG_EMAC_MODE, (val | EMAC_MODE_PORT_GMII)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1837 | } else { /* ASIC */ |
| 1838 | /* pause enable/disable */ |
| 1839 | bnx2x_bits_dis(bp, emac_base + EMAC_REG_EMAC_RX_MODE, |
| 1840 | EMAC_RX_MODE_FLOW_EN); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1841 | |
| 1842 | bnx2x_bits_dis(bp, emac_base + EMAC_REG_EMAC_TX_MODE, |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1843 | (EMAC_TX_MODE_EXT_PAUSE_EN | |
| 1844 | EMAC_TX_MODE_FLOW_EN)); |
| 1845 | if (!(params->feature_config_flags & |
| 1846 | FEATURE_CONFIG_PFC_ENABLED)) { |
| 1847 | if (vars->flow_ctrl & BNX2X_FLOW_CTRL_RX) |
| 1848 | bnx2x_bits_en(bp, emac_base + |
| 1849 | EMAC_REG_EMAC_RX_MODE, |
| 1850 | EMAC_RX_MODE_FLOW_EN); |
| 1851 | |
| 1852 | if (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX) |
| 1853 | bnx2x_bits_en(bp, emac_base + |
| 1854 | EMAC_REG_EMAC_TX_MODE, |
| 1855 | (EMAC_TX_MODE_EXT_PAUSE_EN | |
| 1856 | EMAC_TX_MODE_FLOW_EN)); |
| 1857 | } else |
| 1858 | bnx2x_bits_en(bp, emac_base + EMAC_REG_EMAC_TX_MODE, |
| 1859 | EMAC_TX_MODE_FLOW_EN); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1860 | } |
| 1861 | |
| 1862 | /* KEEP_VLAN_TAG, promiscuous */ |
| 1863 | val = REG_RD(bp, emac_base + EMAC_REG_EMAC_RX_MODE); |
| 1864 | val |= EMAC_RX_MODE_KEEP_VLAN_TAG | EMAC_RX_MODE_PROMISCUOUS; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1865 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 1866 | /* |
| 1867 | * Setting this bit causes MAC control frames (except for pause |
| 1868 | * frames) to be passed on for processing. This setting has no |
| 1869 | * affect on the operation of the pause frames. This bit effects |
| 1870 | * all packets regardless of RX Parser packet sorting logic. |
| 1871 | * Turn the PFC off to make sure we are in Xon state before |
| 1872 | * enabling it. |
| 1873 | */ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1874 | EMAC_WR(bp, EMAC_REG_RX_PFC_MODE, 0); |
| 1875 | if (params->feature_config_flags & FEATURE_CONFIG_PFC_ENABLED) { |
| 1876 | DP(NETIF_MSG_LINK, "PFC is enabled\n"); |
| 1877 | /* Enable PFC again */ |
| 1878 | EMAC_WR(bp, EMAC_REG_RX_PFC_MODE, |
| 1879 | EMAC_REG_RX_PFC_MODE_RX_EN | |
| 1880 | EMAC_REG_RX_PFC_MODE_TX_EN | |
| 1881 | EMAC_REG_RX_PFC_MODE_PRIORITIES); |
| 1882 | |
| 1883 | EMAC_WR(bp, EMAC_REG_RX_PFC_PARAM, |
| 1884 | ((0x0101 << |
| 1885 | EMAC_REG_RX_PFC_PARAM_OPCODE_BITSHIFT) | |
| 1886 | (0x00ff << |
| 1887 | EMAC_REG_RX_PFC_PARAM_PRIORITY_EN_BITSHIFT))); |
| 1888 | val |= EMAC_RX_MODE_KEEP_MAC_CONTROL; |
| 1889 | } |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 1890 | EMAC_WR(bp, EMAC_REG_EMAC_RX_MODE, val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1891 | |
| 1892 | /* Set Loopback */ |
| 1893 | val = REG_RD(bp, emac_base + EMAC_REG_EMAC_MODE); |
| 1894 | if (lb) |
| 1895 | val |= 0x810; |
| 1896 | else |
| 1897 | val &= ~0x810; |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 1898 | EMAC_WR(bp, EMAC_REG_EMAC_MODE, val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1899 | |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 1900 | /* enable emac */ |
| 1901 | REG_WR(bp, NIG_REG_NIG_EMAC0_EN + port*4, 1); |
| 1902 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1903 | /* enable emac for jumbo packets */ |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 1904 | EMAC_WR(bp, EMAC_REG_EMAC_RX_MTU_SIZE, |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1905 | (EMAC_RX_MTU_SIZE_JUMBO_ENA | |
| 1906 | (ETH_MAX_JUMBO_PACKET_SIZE + ETH_OVREHEAD))); |
| 1907 | |
| 1908 | /* strip CRC */ |
| 1909 | REG_WR(bp, NIG_REG_NIG_INGRESS_EMAC0_NO_CRC + port*4, 0x1); |
| 1910 | |
| 1911 | /* disable the NIG in/out to the bmac */ |
| 1912 | REG_WR(bp, NIG_REG_BMAC0_IN_EN + port*4, 0x0); |
| 1913 | REG_WR(bp, NIG_REG_BMAC0_PAUSE_OUT_EN + port*4, 0x0); |
| 1914 | REG_WR(bp, NIG_REG_BMAC0_OUT_EN + port*4, 0x0); |
| 1915 | |
| 1916 | /* enable the NIG in/out to the emac */ |
| 1917 | REG_WR(bp, NIG_REG_EMAC0_IN_EN + port*4, 0x1); |
| 1918 | val = 0; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1919 | if ((params->feature_config_flags & |
| 1920 | FEATURE_CONFIG_PFC_ENABLED) || |
| 1921 | (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX)) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1922 | val = 1; |
| 1923 | |
| 1924 | REG_WR(bp, NIG_REG_EMAC0_PAUSE_OUT_EN + port*4, val); |
| 1925 | REG_WR(bp, NIG_REG_EGRESS_EMAC0_OUT_EN + port*4, 0x1); |
| 1926 | |
Yaniv Rosner | 02a2316 | 2011-01-31 04:22:53 +0000 | [diff] [blame] | 1927 | REG_WR(bp, NIG_REG_BMAC0_REGS_OUT_EN + port*4, 0x0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1928 | |
| 1929 | vars->mac_type = MAC_TYPE_EMAC; |
| 1930 | return 0; |
| 1931 | } |
| 1932 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1933 | static void bnx2x_update_pfc_bmac1(struct link_params *params, |
| 1934 | struct link_vars *vars) |
| 1935 | { |
| 1936 | u32 wb_data[2]; |
| 1937 | struct bnx2x *bp = params->bp; |
| 1938 | u32 bmac_addr = params->port ? NIG_REG_INGRESS_BMAC1_MEM : |
| 1939 | NIG_REG_INGRESS_BMAC0_MEM; |
| 1940 | |
| 1941 | u32 val = 0x14; |
| 1942 | if ((!(params->feature_config_flags & |
| 1943 | FEATURE_CONFIG_PFC_ENABLED)) && |
| 1944 | (vars->flow_ctrl & BNX2X_FLOW_CTRL_RX)) |
| 1945 | /* Enable BigMAC to react on received Pause packets */ |
| 1946 | val |= (1<<5); |
| 1947 | wb_data[0] = val; |
| 1948 | wb_data[1] = 0; |
| 1949 | REG_WR_DMAE(bp, bmac_addr + BIGMAC_REGISTER_RX_CONTROL, wb_data, 2); |
| 1950 | |
| 1951 | /* tx control */ |
| 1952 | val = 0xc0; |
| 1953 | if (!(params->feature_config_flags & |
| 1954 | FEATURE_CONFIG_PFC_ENABLED) && |
| 1955 | (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX)) |
| 1956 | val |= 0x800000; |
| 1957 | wb_data[0] = val; |
| 1958 | wb_data[1] = 0; |
| 1959 | REG_WR_DMAE(bp, bmac_addr + BIGMAC_REGISTER_TX_CONTROL, wb_data, 2); |
| 1960 | } |
| 1961 | |
| 1962 | static void bnx2x_update_pfc_bmac2(struct link_params *params, |
| 1963 | struct link_vars *vars, |
| 1964 | u8 is_lb) |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1965 | { |
| 1966 | /* |
| 1967 | * Set rx control: Strip CRC and enable BigMAC to relay |
| 1968 | * control packets to the system as well |
| 1969 | */ |
| 1970 | u32 wb_data[2]; |
| 1971 | struct bnx2x *bp = params->bp; |
| 1972 | u32 bmac_addr = params->port ? NIG_REG_INGRESS_BMAC1_MEM : |
| 1973 | NIG_REG_INGRESS_BMAC0_MEM; |
| 1974 | u32 val = 0x14; |
| 1975 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1976 | if ((!(params->feature_config_flags & |
| 1977 | FEATURE_CONFIG_PFC_ENABLED)) && |
| 1978 | (vars->flow_ctrl & BNX2X_FLOW_CTRL_RX)) |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1979 | /* Enable BigMAC to react on received Pause packets */ |
| 1980 | val |= (1<<5); |
| 1981 | wb_data[0] = val; |
| 1982 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1983 | 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] | 1984 | udelay(30); |
| 1985 | |
| 1986 | /* Tx control */ |
| 1987 | val = 0xc0; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1988 | if (!(params->feature_config_flags & |
| 1989 | FEATURE_CONFIG_PFC_ENABLED) && |
| 1990 | (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX)) |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1991 | val |= 0x800000; |
| 1992 | wb_data[0] = val; |
| 1993 | wb_data[1] = 0; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1994 | 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] | 1995 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1996 | if (params->feature_config_flags & FEATURE_CONFIG_PFC_ENABLED) { |
| 1997 | DP(NETIF_MSG_LINK, "PFC is enabled\n"); |
| 1998 | /* Enable PFC RX & TX & STATS and set 8 COS */ |
| 1999 | wb_data[0] = 0x0; |
| 2000 | wb_data[0] |= (1<<0); /* RX */ |
| 2001 | wb_data[0] |= (1<<1); /* TX */ |
| 2002 | wb_data[0] |= (1<<2); /* Force initial Xon */ |
| 2003 | wb_data[0] |= (1<<3); /* 8 cos */ |
| 2004 | wb_data[0] |= (1<<5); /* STATS */ |
| 2005 | wb_data[1] = 0; |
| 2006 | REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_PFC_CONTROL, |
| 2007 | wb_data, 2); |
| 2008 | /* Clear the force Xon */ |
| 2009 | wb_data[0] &= ~(1<<2); |
| 2010 | } else { |
| 2011 | DP(NETIF_MSG_LINK, "PFC is disabled\n"); |
| 2012 | /* disable PFC RX & TX & STATS and set 8 COS */ |
| 2013 | wb_data[0] = 0x8; |
| 2014 | wb_data[1] = 0; |
| 2015 | } |
| 2016 | |
| 2017 | REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_PFC_CONTROL, wb_data, 2); |
| 2018 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2019 | /* |
| 2020 | * Set Time (based unit is 512 bit time) between automatic |
| 2021 | * re-sending of PP packets amd enable automatic re-send of |
| 2022 | * Per-Priroity Packet as long as pp_gen is asserted and |
| 2023 | * pp_disable is low. |
| 2024 | */ |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2025 | val = 0x8000; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2026 | if (params->feature_config_flags & FEATURE_CONFIG_PFC_ENABLED) |
| 2027 | val |= (1<<16); /* enable automatic re-send */ |
| 2028 | |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2029 | wb_data[0] = val; |
| 2030 | wb_data[1] = 0; |
| 2031 | REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_TX_PAUSE_CONTROL, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2032 | wb_data, 2); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2033 | |
| 2034 | /* mac control */ |
| 2035 | val = 0x3; /* Enable RX and TX */ |
| 2036 | if (is_lb) { |
| 2037 | val |= 0x4; /* Local loopback */ |
| 2038 | DP(NETIF_MSG_LINK, "enable bmac loopback\n"); |
| 2039 | } |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2040 | /* When PFC enabled, Pass pause frames towards the NIG. */ |
| 2041 | if (params->feature_config_flags & FEATURE_CONFIG_PFC_ENABLED) |
| 2042 | val |= ((1<<6)|(1<<5)); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2043 | |
| 2044 | wb_data[0] = val; |
| 2045 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2046 | 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] | 2047 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2048 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2049 | /* PFC BRB internal port configuration params */ |
| 2050 | struct bnx2x_pfc_brb_threshold_val { |
| 2051 | u32 pause_xoff; |
| 2052 | u32 pause_xon; |
| 2053 | u32 full_xoff; |
| 2054 | u32 full_xon; |
| 2055 | }; |
| 2056 | |
| 2057 | struct bnx2x_pfc_brb_e3b0_val { |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2058 | u32 per_class_guaranty_mode; |
| 2059 | u32 lb_guarantied_hyst; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2060 | u32 full_lb_xoff_th; |
| 2061 | u32 full_lb_xon_threshold; |
| 2062 | u32 lb_guarantied; |
| 2063 | u32 mac_0_class_t_guarantied; |
| 2064 | u32 mac_0_class_t_guarantied_hyst; |
| 2065 | u32 mac_1_class_t_guarantied; |
| 2066 | u32 mac_1_class_t_guarantied_hyst; |
| 2067 | }; |
| 2068 | |
| 2069 | struct bnx2x_pfc_brb_th_val { |
| 2070 | struct bnx2x_pfc_brb_threshold_val pauseable_th; |
| 2071 | struct bnx2x_pfc_brb_threshold_val non_pauseable_th; |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2072 | struct bnx2x_pfc_brb_threshold_val default_class0; |
| 2073 | struct bnx2x_pfc_brb_threshold_val default_class1; |
| 2074 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2075 | }; |
| 2076 | static int bnx2x_pfc_brb_get_config_params( |
| 2077 | struct link_params *params, |
| 2078 | struct bnx2x_pfc_brb_th_val *config_val) |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2079 | { |
| 2080 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2081 | DP(NETIF_MSG_LINK, "Setting PFC BRB configuration\n"); |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2082 | |
| 2083 | config_val->default_class1.pause_xoff = 0; |
| 2084 | config_val->default_class1.pause_xon = 0; |
| 2085 | config_val->default_class1.full_xoff = 0; |
| 2086 | config_val->default_class1.full_xon = 0; |
| 2087 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2088 | if (CHIP_IS_E2(bp)) { |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2089 | /* class0 defaults */ |
| 2090 | config_val->default_class0.pause_xoff = |
| 2091 | DEFAULT0_E2_BRB_MAC_PAUSE_XOFF_THR; |
| 2092 | config_val->default_class0.pause_xon = |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2093 | DEFAULT0_E2_BRB_MAC_PAUSE_XON_THR; |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2094 | config_val->default_class0.full_xoff = |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2095 | DEFAULT0_E2_BRB_MAC_FULL_XOFF_THR; |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2096 | config_val->default_class0.full_xon = |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2097 | DEFAULT0_E2_BRB_MAC_FULL_XON_THR; |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2098 | /* pause able*/ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2099 | config_val->pauseable_th.pause_xoff = |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2100 | PFC_E2_BRB_MAC_PAUSE_XOFF_THR_PAUSE; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2101 | config_val->pauseable_th.pause_xon = |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2102 | PFC_E2_BRB_MAC_PAUSE_XON_THR_PAUSE; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2103 | config_val->pauseable_th.full_xoff = |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2104 | PFC_E2_BRB_MAC_FULL_XOFF_THR_PAUSE; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2105 | config_val->pauseable_th.full_xon = |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2106 | PFC_E2_BRB_MAC_FULL_XON_THR_PAUSE; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2107 | /* non pause able*/ |
| 2108 | config_val->non_pauseable_th.pause_xoff = |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2109 | PFC_E2_BRB_MAC_PAUSE_XOFF_THR_NON_PAUSE; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2110 | config_val->non_pauseable_th.pause_xon = |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2111 | PFC_E2_BRB_MAC_PAUSE_XON_THR_NON_PAUSE; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2112 | config_val->non_pauseable_th.full_xoff = |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2113 | PFC_E2_BRB_MAC_FULL_XOFF_THR_NON_PAUSE; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2114 | config_val->non_pauseable_th.full_xon = |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2115 | PFC_E2_BRB_MAC_FULL_XON_THR_NON_PAUSE; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2116 | } else if (CHIP_IS_E3A0(bp)) { |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2117 | /* class0 defaults */ |
| 2118 | config_val->default_class0.pause_xoff = |
| 2119 | DEFAULT0_E3A0_BRB_MAC_PAUSE_XOFF_THR; |
| 2120 | config_val->default_class0.pause_xon = |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2121 | DEFAULT0_E3A0_BRB_MAC_PAUSE_XON_THR; |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2122 | config_val->default_class0.full_xoff = |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2123 | DEFAULT0_E3A0_BRB_MAC_FULL_XOFF_THR; |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2124 | config_val->default_class0.full_xon = |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2125 | DEFAULT0_E3A0_BRB_MAC_FULL_XON_THR; |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2126 | /* pause able */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2127 | config_val->pauseable_th.pause_xoff = |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2128 | PFC_E3A0_BRB_MAC_PAUSE_XOFF_THR_PAUSE; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2129 | config_val->pauseable_th.pause_xon = |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2130 | PFC_E3A0_BRB_MAC_PAUSE_XON_THR_PAUSE; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2131 | config_val->pauseable_th.full_xoff = |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2132 | PFC_E3A0_BRB_MAC_FULL_XOFF_THR_PAUSE; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2133 | config_val->pauseable_th.full_xon = |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2134 | PFC_E3A0_BRB_MAC_FULL_XON_THR_PAUSE; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2135 | /* non pause able*/ |
| 2136 | config_val->non_pauseable_th.pause_xoff = |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2137 | PFC_E3A0_BRB_MAC_PAUSE_XOFF_THR_NON_PAUSE; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2138 | config_val->non_pauseable_th.pause_xon = |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2139 | PFC_E3A0_BRB_MAC_PAUSE_XON_THR_NON_PAUSE; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2140 | config_val->non_pauseable_th.full_xoff = |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2141 | PFC_E3A0_BRB_MAC_FULL_XOFF_THR_NON_PAUSE; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2142 | config_val->non_pauseable_th.full_xon = |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2143 | PFC_E3A0_BRB_MAC_FULL_XON_THR_NON_PAUSE; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2144 | } else if (CHIP_IS_E3B0(bp)) { |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2145 | /* class0 defaults */ |
| 2146 | config_val->default_class0.pause_xoff = |
| 2147 | DEFAULT0_E3B0_BRB_MAC_PAUSE_XOFF_THR; |
| 2148 | config_val->default_class0.pause_xon = |
| 2149 | DEFAULT0_E3B0_BRB_MAC_PAUSE_XON_THR; |
| 2150 | config_val->default_class0.full_xoff = |
| 2151 | DEFAULT0_E3B0_BRB_MAC_FULL_XOFF_THR; |
| 2152 | config_val->default_class0.full_xon = |
| 2153 | DEFAULT0_E3B0_BRB_MAC_FULL_XON_THR; |
| 2154 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2155 | if (params->phy[INT_PHY].flags & |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2156 | FLAGS_4_PORT_MODE) { |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2157 | config_val->pauseable_th.pause_xoff = |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2158 | PFC_E3B0_4P_BRB_MAC_PAUSE_XOFF_THR_PAUSE; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2159 | config_val->pauseable_th.pause_xon = |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2160 | PFC_E3B0_4P_BRB_MAC_PAUSE_XON_THR_PAUSE; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2161 | config_val->pauseable_th.full_xoff = |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2162 | PFC_E3B0_4P_BRB_MAC_FULL_XOFF_THR_PAUSE; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2163 | config_val->pauseable_th.full_xon = |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2164 | PFC_E3B0_4P_BRB_MAC_FULL_XON_THR_PAUSE; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2165 | /* non pause able*/ |
| 2166 | config_val->non_pauseable_th.pause_xoff = |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2167 | PFC_E3B0_4P_BRB_MAC_PAUSE_XOFF_THR_NON_PAUSE; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2168 | config_val->non_pauseable_th.pause_xon = |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2169 | PFC_E3B0_4P_BRB_MAC_PAUSE_XON_THR_NON_PAUSE; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2170 | config_val->non_pauseable_th.full_xoff = |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2171 | PFC_E3B0_4P_BRB_MAC_FULL_XOFF_THR_NON_PAUSE; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2172 | config_val->non_pauseable_th.full_xon = |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2173 | PFC_E3B0_4P_BRB_MAC_FULL_XON_THR_NON_PAUSE; |
| 2174 | } else { |
| 2175 | config_val->pauseable_th.pause_xoff = |
| 2176 | PFC_E3B0_2P_BRB_MAC_PAUSE_XOFF_THR_PAUSE; |
| 2177 | config_val->pauseable_th.pause_xon = |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2178 | PFC_E3B0_2P_BRB_MAC_PAUSE_XON_THR_PAUSE; |
| 2179 | config_val->pauseable_th.full_xoff = |
| 2180 | PFC_E3B0_2P_BRB_MAC_FULL_XOFF_THR_PAUSE; |
| 2181 | config_val->pauseable_th.full_xon = |
| 2182 | PFC_E3B0_2P_BRB_MAC_FULL_XON_THR_PAUSE; |
| 2183 | /* non pause able*/ |
| 2184 | config_val->non_pauseable_th.pause_xoff = |
| 2185 | PFC_E3B0_2P_BRB_MAC_PAUSE_XOFF_THR_NON_PAUSE; |
| 2186 | config_val->non_pauseable_th.pause_xon = |
| 2187 | PFC_E3B0_2P_BRB_MAC_PAUSE_XON_THR_NON_PAUSE; |
| 2188 | config_val->non_pauseable_th.full_xoff = |
| 2189 | PFC_E3B0_2P_BRB_MAC_FULL_XOFF_THR_NON_PAUSE; |
| 2190 | config_val->non_pauseable_th.full_xon = |
| 2191 | PFC_E3B0_2P_BRB_MAC_FULL_XON_THR_NON_PAUSE; |
| 2192 | } |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2193 | } else |
| 2194 | return -EINVAL; |
| 2195 | |
| 2196 | return 0; |
| 2197 | } |
| 2198 | |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2199 | static void bnx2x_pfc_brb_get_e3b0_config_params( |
| 2200 | struct link_params *params, |
| 2201 | struct bnx2x_pfc_brb_e3b0_val |
| 2202 | *e3b0_val, |
| 2203 | struct bnx2x_nig_brb_pfc_port_params *pfc_params, |
| 2204 | const u8 pfc_enabled) |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2205 | { |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2206 | if (pfc_enabled && pfc_params) { |
| 2207 | e3b0_val->per_class_guaranty_mode = 1; |
| 2208 | e3b0_val->lb_guarantied_hyst = 80; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2209 | |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2210 | if (params->phy[INT_PHY].flags & |
| 2211 | FLAGS_4_PORT_MODE) { |
| 2212 | e3b0_val->full_lb_xoff_th = |
| 2213 | PFC_E3B0_4P_BRB_FULL_LB_XOFF_THR; |
| 2214 | e3b0_val->full_lb_xon_threshold = |
| 2215 | PFC_E3B0_4P_BRB_FULL_LB_XON_THR; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2216 | e3b0_val->lb_guarantied = |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2217 | PFC_E3B0_4P_LB_GUART; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2218 | e3b0_val->mac_0_class_t_guarantied = |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2219 | PFC_E3B0_4P_BRB_MAC_0_CLASS_T_GUART; |
| 2220 | e3b0_val->mac_0_class_t_guarantied_hyst = |
| 2221 | PFC_E3B0_4P_BRB_MAC_0_CLASS_T_GUART_HYST; |
| 2222 | e3b0_val->mac_1_class_t_guarantied = |
| 2223 | PFC_E3B0_4P_BRB_MAC_1_CLASS_T_GUART; |
| 2224 | e3b0_val->mac_1_class_t_guarantied_hyst = |
| 2225 | PFC_E3B0_4P_BRB_MAC_1_CLASS_T_GUART_HYST; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2226 | } else { |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2227 | e3b0_val->full_lb_xoff_th = |
| 2228 | PFC_E3B0_2P_BRB_FULL_LB_XOFF_THR; |
| 2229 | e3b0_val->full_lb_xon_threshold = |
| 2230 | PFC_E3B0_2P_BRB_FULL_LB_XON_THR; |
| 2231 | e3b0_val->mac_0_class_t_guarantied_hyst = |
| 2232 | PFC_E3B0_2P_BRB_MAC_0_CLASS_T_GUART_HYST; |
| 2233 | e3b0_val->mac_1_class_t_guarantied = |
| 2234 | PFC_E3B0_2P_BRB_MAC_1_CLASS_T_GUART; |
| 2235 | e3b0_val->mac_1_class_t_guarantied_hyst = |
| 2236 | PFC_E3B0_2P_BRB_MAC_1_CLASS_T_GUART_HYST; |
| 2237 | |
| 2238 | if (pfc_params->cos0_pauseable != |
| 2239 | pfc_params->cos1_pauseable) { |
| 2240 | /* nonpauseable= Lossy + pauseable = Lossless*/ |
| 2241 | e3b0_val->lb_guarantied = |
| 2242 | PFC_E3B0_2P_MIX_PAUSE_LB_GUART; |
| 2243 | e3b0_val->mac_0_class_t_guarantied = |
| 2244 | PFC_E3B0_2P_MIX_PAUSE_MAC_0_CLASS_T_GUART; |
| 2245 | } else if (pfc_params->cos0_pauseable) { |
| 2246 | /* Lossless +Lossless*/ |
| 2247 | e3b0_val->lb_guarantied = |
| 2248 | PFC_E3B0_2P_PAUSE_LB_GUART; |
| 2249 | e3b0_val->mac_0_class_t_guarantied = |
| 2250 | PFC_E3B0_2P_PAUSE_MAC_0_CLASS_T_GUART; |
| 2251 | } else { |
| 2252 | /* Lossy +Lossy*/ |
| 2253 | e3b0_val->lb_guarantied = |
| 2254 | PFC_E3B0_2P_NON_PAUSE_LB_GUART; |
| 2255 | e3b0_val->mac_0_class_t_guarantied = |
| 2256 | PFC_E3B0_2P_NON_PAUSE_MAC_0_CLASS_T_GUART; |
| 2257 | } |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2258 | } |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2259 | } else { |
| 2260 | e3b0_val->per_class_guaranty_mode = 0; |
| 2261 | e3b0_val->lb_guarantied_hyst = 0; |
| 2262 | e3b0_val->full_lb_xoff_th = |
| 2263 | DEFAULT_E3B0_BRB_FULL_LB_XOFF_THR; |
| 2264 | e3b0_val->full_lb_xon_threshold = |
| 2265 | DEFAULT_E3B0_BRB_FULL_LB_XON_THR; |
| 2266 | e3b0_val->lb_guarantied = |
| 2267 | DEFAULT_E3B0_LB_GUART; |
| 2268 | e3b0_val->mac_0_class_t_guarantied = |
| 2269 | DEFAULT_E3B0_BRB_MAC_0_CLASS_T_GUART; |
| 2270 | e3b0_val->mac_0_class_t_guarantied_hyst = |
| 2271 | DEFAULT_E3B0_BRB_MAC_0_CLASS_T_GUART_HYST; |
| 2272 | e3b0_val->mac_1_class_t_guarantied = |
| 2273 | DEFAULT_E3B0_BRB_MAC_1_CLASS_T_GUART; |
| 2274 | e3b0_val->mac_1_class_t_guarantied_hyst = |
| 2275 | DEFAULT_E3B0_BRB_MAC_1_CLASS_T_GUART_HYST; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2276 | } |
| 2277 | } |
| 2278 | static int bnx2x_update_pfc_brb(struct link_params *params, |
| 2279 | struct link_vars *vars, |
| 2280 | struct bnx2x_nig_brb_pfc_port_params |
| 2281 | *pfc_params) |
| 2282 | { |
| 2283 | struct bnx2x *bp = params->bp; |
| 2284 | struct bnx2x_pfc_brb_th_val config_val = { {0} }; |
| 2285 | struct bnx2x_pfc_brb_threshold_val *reg_th_config = |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2286 | &config_val.pauseable_th; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2287 | struct bnx2x_pfc_brb_e3b0_val e3b0_val = {0}; |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2288 | const int set_pfc = params->feature_config_flags & |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2289 | FEATURE_CONFIG_PFC_ENABLED; |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2290 | const u8 pfc_enabled = (set_pfc && pfc_params); |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2291 | int bnx2x_status = 0; |
| 2292 | u8 port = params->port; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2293 | |
| 2294 | /* default - pause configuration */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2295 | reg_th_config = &config_val.pauseable_th; |
| 2296 | bnx2x_status = bnx2x_pfc_brb_get_config_params(params, &config_val); |
Yaniv Rosner | de0396f | 2011-11-28 00:49:53 +0000 | [diff] [blame] | 2297 | if (bnx2x_status) |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2298 | return bnx2x_status; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2299 | |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2300 | if (pfc_enabled) { |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2301 | /* First COS */ |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2302 | if (pfc_params->cos0_pauseable) |
| 2303 | reg_th_config = &config_val.pauseable_th; |
| 2304 | else |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2305 | reg_th_config = &config_val.non_pauseable_th; |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2306 | } else |
| 2307 | reg_th_config = &config_val.default_class0; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2308 | /* |
| 2309 | * The number of free blocks below which the pause signal to class 0 |
| 2310 | * of MAC #n is asserted. n=0,1 |
| 2311 | */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2312 | REG_WR(bp, (port) ? BRB1_REG_PAUSE_0_XOFF_THRESHOLD_1 : |
| 2313 | BRB1_REG_PAUSE_0_XOFF_THRESHOLD_0 , |
| 2314 | reg_th_config->pause_xoff); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2315 | /* |
| 2316 | * The number of free blocks above which the pause signal to class 0 |
| 2317 | * of MAC #n is de-asserted. n=0,1 |
| 2318 | */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2319 | REG_WR(bp, (port) ? BRB1_REG_PAUSE_0_XON_THRESHOLD_1 : |
| 2320 | BRB1_REG_PAUSE_0_XON_THRESHOLD_0 , reg_th_config->pause_xon); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2321 | /* |
| 2322 | * The number of free blocks below which the full signal to class 0 |
| 2323 | * of MAC #n is asserted. n=0,1 |
| 2324 | */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2325 | REG_WR(bp, (port) ? BRB1_REG_FULL_0_XOFF_THRESHOLD_1 : |
| 2326 | BRB1_REG_FULL_0_XOFF_THRESHOLD_0 , reg_th_config->full_xoff); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2327 | /* |
| 2328 | * The number of free blocks above which the full signal to class 0 |
| 2329 | * of MAC #n is de-asserted. n=0,1 |
| 2330 | */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2331 | REG_WR(bp, (port) ? BRB1_REG_FULL_0_XON_THRESHOLD_1 : |
| 2332 | BRB1_REG_FULL_0_XON_THRESHOLD_0 , reg_th_config->full_xon); |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2333 | |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2334 | if (pfc_enabled) { |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2335 | /* Second COS */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2336 | if (pfc_params->cos1_pauseable) |
| 2337 | reg_th_config = &config_val.pauseable_th; |
| 2338 | else |
| 2339 | reg_th_config = &config_val.non_pauseable_th; |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2340 | } else |
| 2341 | reg_th_config = &config_val.default_class1; |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2342 | /* |
| 2343 | * The number of free blocks below which the pause signal to |
| 2344 | * class 1 of MAC #n is asserted. n=0,1 |
| 2345 | */ |
| 2346 | REG_WR(bp, (port) ? BRB1_REG_PAUSE_1_XOFF_THRESHOLD_1 : |
| 2347 | BRB1_REG_PAUSE_1_XOFF_THRESHOLD_0, |
| 2348 | reg_th_config->pause_xoff); |
| 2349 | |
| 2350 | /* |
| 2351 | * The number of free blocks above which the pause signal to |
| 2352 | * class 1 of MAC #n is de-asserted. n=0,1 |
| 2353 | */ |
| 2354 | REG_WR(bp, (port) ? BRB1_REG_PAUSE_1_XON_THRESHOLD_1 : |
| 2355 | BRB1_REG_PAUSE_1_XON_THRESHOLD_0, |
| 2356 | reg_th_config->pause_xon); |
| 2357 | /* |
| 2358 | * The number of free blocks below which the full signal to |
| 2359 | * class 1 of MAC #n is asserted. n=0,1 |
| 2360 | */ |
| 2361 | REG_WR(bp, (port) ? BRB1_REG_FULL_1_XOFF_THRESHOLD_1 : |
| 2362 | BRB1_REG_FULL_1_XOFF_THRESHOLD_0, |
| 2363 | reg_th_config->full_xoff); |
| 2364 | /* |
| 2365 | * The number of free blocks above which the full signal to |
| 2366 | * class 1 of MAC #n is de-asserted. n=0,1 |
| 2367 | */ |
| 2368 | REG_WR(bp, (port) ? BRB1_REG_FULL_1_XON_THRESHOLD_1 : |
| 2369 | BRB1_REG_FULL_1_XON_THRESHOLD_0, |
| 2370 | reg_th_config->full_xon); |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2371 | |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2372 | if (CHIP_IS_E3B0(bp)) { |
| 2373 | bnx2x_pfc_brb_get_e3b0_config_params( |
| 2374 | params, |
| 2375 | &e3b0_val, |
| 2376 | pfc_params, |
| 2377 | pfc_enabled); |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2378 | |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2379 | REG_WR(bp, BRB1_REG_PER_CLASS_GUARANTY_MODE, |
| 2380 | e3b0_val.per_class_guaranty_mode); |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2381 | |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2382 | /* |
| 2383 | * The hysteresis on the guarantied buffer space for the Lb |
| 2384 | * port before signaling XON. |
| 2385 | */ |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2386 | REG_WR(bp, BRB1_REG_LB_GUARANTIED_HYST, |
| 2387 | e3b0_val.lb_guarantied_hyst); |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2388 | |
| 2389 | /* |
| 2390 | * The number of free blocks below which the full signal to the |
| 2391 | * LB port is asserted. |
| 2392 | */ |
Yaniv Rosner | 866ceda | 2011-11-28 00:49:45 +0000 | [diff] [blame] | 2393 | REG_WR(bp, BRB1_REG_FULL_LB_XOFF_THRESHOLD, |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2394 | e3b0_val.full_lb_xoff_th); |
| 2395 | /* |
| 2396 | * The number of free blocks above which the full signal to the |
| 2397 | * LB port is de-asserted. |
| 2398 | */ |
| 2399 | REG_WR(bp, BRB1_REG_FULL_LB_XON_THRESHOLD, |
| 2400 | e3b0_val.full_lb_xon_threshold); |
| 2401 | /* |
| 2402 | * The number of blocks guarantied for the MAC #n port. n=0,1 |
| 2403 | */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2404 | |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2405 | /* The number of blocks guarantied for the LB port.*/ |
| 2406 | REG_WR(bp, BRB1_REG_LB_GUARANTIED, |
| 2407 | e3b0_val.lb_guarantied); |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2408 | |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2409 | /* |
| 2410 | * The number of blocks guarantied for the MAC #n port. |
| 2411 | */ |
| 2412 | REG_WR(bp, BRB1_REG_MAC_GUARANTIED_0, |
| 2413 | 2 * e3b0_val.mac_0_class_t_guarantied); |
| 2414 | REG_WR(bp, BRB1_REG_MAC_GUARANTIED_1, |
| 2415 | 2 * e3b0_val.mac_1_class_t_guarantied); |
| 2416 | /* |
| 2417 | * The number of blocks guarantied for class #t in MAC0. t=0,1 |
| 2418 | */ |
| 2419 | REG_WR(bp, BRB1_REG_MAC_0_CLASS_0_GUARANTIED, |
| 2420 | e3b0_val.mac_0_class_t_guarantied); |
| 2421 | REG_WR(bp, BRB1_REG_MAC_0_CLASS_1_GUARANTIED, |
| 2422 | e3b0_val.mac_0_class_t_guarantied); |
| 2423 | /* |
| 2424 | * The hysteresis on the guarantied buffer space for class in |
| 2425 | * MAC0. t=0,1 |
| 2426 | */ |
| 2427 | REG_WR(bp, BRB1_REG_MAC_0_CLASS_0_GUARANTIED_HYST, |
| 2428 | e3b0_val.mac_0_class_t_guarantied_hyst); |
| 2429 | REG_WR(bp, BRB1_REG_MAC_0_CLASS_1_GUARANTIED_HYST, |
| 2430 | e3b0_val.mac_0_class_t_guarantied_hyst); |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2431 | |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 2432 | /* |
| 2433 | * The number of blocks guarantied for class #t in MAC1.t=0,1 |
| 2434 | */ |
| 2435 | REG_WR(bp, BRB1_REG_MAC_1_CLASS_0_GUARANTIED, |
| 2436 | e3b0_val.mac_1_class_t_guarantied); |
| 2437 | REG_WR(bp, BRB1_REG_MAC_1_CLASS_1_GUARANTIED, |
| 2438 | e3b0_val.mac_1_class_t_guarantied); |
| 2439 | /* |
| 2440 | * The hysteresis on the guarantied buffer space for class #t |
| 2441 | * in MAC1. t=0,1 |
| 2442 | */ |
| 2443 | REG_WR(bp, BRB1_REG_MAC_1_CLASS_0_GUARANTIED_HYST, |
| 2444 | e3b0_val.mac_1_class_t_guarantied_hyst); |
| 2445 | REG_WR(bp, BRB1_REG_MAC_1_CLASS_1_GUARANTIED_HYST, |
| 2446 | e3b0_val.mac_1_class_t_guarantied_hyst); |
| 2447 | } |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2448 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2449 | return bnx2x_status; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2450 | } |
| 2451 | |
Vlad Zolotarov | 619c5cb | 2011-06-14 14:33:44 +0300 | [diff] [blame] | 2452 | /****************************************************************************** |
| 2453 | * Description: |
| 2454 | * This function is needed because NIG ARB_CREDIT_WEIGHT_X are |
| 2455 | * not continues and ARB_CREDIT_WEIGHT_0 + offset is suitable. |
| 2456 | ******************************************************************************/ |
| 2457 | int bnx2x_pfc_nig_rx_priority_mask(struct bnx2x *bp, |
| 2458 | u8 cos_entry, |
| 2459 | u32 priority_mask, u8 port) |
| 2460 | { |
| 2461 | u32 nig_reg_rx_priority_mask_add = 0; |
| 2462 | |
| 2463 | switch (cos_entry) { |
| 2464 | case 0: |
| 2465 | nig_reg_rx_priority_mask_add = (port) ? |
| 2466 | NIG_REG_P1_RX_COS0_PRIORITY_MASK : |
| 2467 | NIG_REG_P0_RX_COS0_PRIORITY_MASK; |
| 2468 | break; |
| 2469 | case 1: |
| 2470 | nig_reg_rx_priority_mask_add = (port) ? |
| 2471 | NIG_REG_P1_RX_COS1_PRIORITY_MASK : |
| 2472 | NIG_REG_P0_RX_COS1_PRIORITY_MASK; |
| 2473 | break; |
| 2474 | case 2: |
| 2475 | nig_reg_rx_priority_mask_add = (port) ? |
| 2476 | NIG_REG_P1_RX_COS2_PRIORITY_MASK : |
| 2477 | NIG_REG_P0_RX_COS2_PRIORITY_MASK; |
| 2478 | break; |
| 2479 | case 3: |
| 2480 | if (port) |
| 2481 | return -EINVAL; |
| 2482 | nig_reg_rx_priority_mask_add = NIG_REG_P0_RX_COS3_PRIORITY_MASK; |
| 2483 | break; |
| 2484 | case 4: |
| 2485 | if (port) |
| 2486 | return -EINVAL; |
| 2487 | nig_reg_rx_priority_mask_add = NIG_REG_P0_RX_COS4_PRIORITY_MASK; |
| 2488 | break; |
| 2489 | case 5: |
| 2490 | if (port) |
| 2491 | return -EINVAL; |
| 2492 | nig_reg_rx_priority_mask_add = NIG_REG_P0_RX_COS5_PRIORITY_MASK; |
| 2493 | break; |
| 2494 | } |
| 2495 | |
| 2496 | REG_WR(bp, nig_reg_rx_priority_mask_add, priority_mask); |
| 2497 | |
| 2498 | return 0; |
| 2499 | } |
Yaniv Rosner | b8d6d08 | 2011-07-05 01:06:27 +0000 | [diff] [blame] | 2500 | static void bnx2x_update_mng(struct link_params *params, u32 link_status) |
| 2501 | { |
| 2502 | struct bnx2x *bp = params->bp; |
| 2503 | |
| 2504 | REG_WR(bp, params->shmem_base + |
| 2505 | offsetof(struct shmem_region, |
| 2506 | port_mb[params->port].link_status), link_status); |
| 2507 | } |
| 2508 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2509 | static void bnx2x_update_pfc_nig(struct link_params *params, |
| 2510 | struct link_vars *vars, |
| 2511 | struct bnx2x_nig_brb_pfc_port_params *nig_params) |
| 2512 | { |
| 2513 | u32 xcm_mask = 0, ppp_enable = 0, pause_enable = 0, llfc_out_en = 0; |
Yaniv Rosner | 127302b | 2012-01-17 02:33:26 +0000 | [diff] [blame] | 2514 | u32 llfc_enable = 0, xcm_out_en = 0, hwpfc_enable = 0; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2515 | u32 pkt_priority_to_cos = 0; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2516 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2517 | u8 port = params->port; |
| 2518 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2519 | int set_pfc = params->feature_config_flags & |
| 2520 | FEATURE_CONFIG_PFC_ENABLED; |
| 2521 | DP(NETIF_MSG_LINK, "updating pfc nig parameters\n"); |
| 2522 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2523 | /* |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2524 | * When NIG_LLH0_XCM_MASK_REG_LLHX_XCM_MASK_BCN bit is set |
| 2525 | * MAC control frames (that are not pause packets) |
| 2526 | * will be forwarded to the XCM. |
| 2527 | */ |
Yaniv Rosner | 127302b | 2012-01-17 02:33:26 +0000 | [diff] [blame] | 2528 | xcm_mask = REG_RD(bp, port ? NIG_REG_LLH1_XCM_MASK : |
| 2529 | NIG_REG_LLH0_XCM_MASK); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2530 | /* |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2531 | * nig params will override non PFC params, since it's possible to |
| 2532 | * do transition from PFC to SAFC |
| 2533 | */ |
| 2534 | if (set_pfc) { |
| 2535 | pause_enable = 0; |
| 2536 | llfc_out_en = 0; |
| 2537 | llfc_enable = 0; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2538 | if (CHIP_IS_E3(bp)) |
| 2539 | ppp_enable = 0; |
| 2540 | else |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2541 | ppp_enable = 1; |
| 2542 | xcm_mask &= ~(port ? NIG_LLH1_XCM_MASK_REG_LLH1_XCM_MASK_BCN : |
| 2543 | NIG_LLH0_XCM_MASK_REG_LLH0_XCM_MASK_BCN); |
Yaniv Rosner | 127302b | 2012-01-17 02:33:26 +0000 | [diff] [blame] | 2544 | xcm_out_en = 0; |
| 2545 | hwpfc_enable = 1; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2546 | } else { |
| 2547 | if (nig_params) { |
| 2548 | llfc_out_en = nig_params->llfc_out_en; |
| 2549 | llfc_enable = nig_params->llfc_enable; |
| 2550 | pause_enable = nig_params->pause_enable; |
| 2551 | } else /*defaul non PFC mode - PAUSE */ |
| 2552 | pause_enable = 1; |
| 2553 | |
| 2554 | xcm_mask |= (port ? NIG_LLH1_XCM_MASK_REG_LLH1_XCM_MASK_BCN : |
| 2555 | NIG_LLH0_XCM_MASK_REG_LLH0_XCM_MASK_BCN); |
Yaniv Rosner | 127302b | 2012-01-17 02:33:26 +0000 | [diff] [blame] | 2556 | xcm_out_en = 1; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2557 | } |
| 2558 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2559 | if (CHIP_IS_E3(bp)) |
| 2560 | REG_WR(bp, port ? NIG_REG_BRB1_PAUSE_IN_EN : |
| 2561 | NIG_REG_BRB0_PAUSE_IN_EN, pause_enable); |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2562 | REG_WR(bp, port ? NIG_REG_LLFC_OUT_EN_1 : |
| 2563 | NIG_REG_LLFC_OUT_EN_0, llfc_out_en); |
| 2564 | REG_WR(bp, port ? NIG_REG_LLFC_ENABLE_1 : |
| 2565 | NIG_REG_LLFC_ENABLE_0, llfc_enable); |
| 2566 | REG_WR(bp, port ? NIG_REG_PAUSE_ENABLE_1 : |
| 2567 | NIG_REG_PAUSE_ENABLE_0, pause_enable); |
| 2568 | |
| 2569 | REG_WR(bp, port ? NIG_REG_PPP_ENABLE_1 : |
| 2570 | NIG_REG_PPP_ENABLE_0, ppp_enable); |
| 2571 | |
| 2572 | REG_WR(bp, port ? NIG_REG_LLH1_XCM_MASK : |
| 2573 | NIG_REG_LLH0_XCM_MASK, xcm_mask); |
| 2574 | |
Yaniv Rosner | 127302b | 2012-01-17 02:33:26 +0000 | [diff] [blame] | 2575 | REG_WR(bp, port ? NIG_REG_LLFC_EGRESS_SRC_ENABLE_1 : |
| 2576 | NIG_REG_LLFC_EGRESS_SRC_ENABLE_0, 0x7); |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2577 | |
| 2578 | /* output enable for RX_XCM # IF */ |
Yaniv Rosner | 127302b | 2012-01-17 02:33:26 +0000 | [diff] [blame] | 2579 | REG_WR(bp, port ? NIG_REG_XCM1_OUT_EN : |
| 2580 | NIG_REG_XCM0_OUT_EN, xcm_out_en); |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2581 | |
| 2582 | /* HW PFC TX enable */ |
Yaniv Rosner | 127302b | 2012-01-17 02:33:26 +0000 | [diff] [blame] | 2583 | REG_WR(bp, port ? NIG_REG_P1_HWPFC_ENABLE : |
| 2584 | NIG_REG_P0_HWPFC_ENABLE, hwpfc_enable); |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2585 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2586 | if (nig_params) { |
Vlad Zolotarov | 619c5cb | 2011-06-14 14:33:44 +0300 | [diff] [blame] | 2587 | u8 i = 0; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2588 | pkt_priority_to_cos = nig_params->pkt_priority_to_cos; |
| 2589 | |
Vlad Zolotarov | 619c5cb | 2011-06-14 14:33:44 +0300 | [diff] [blame] | 2590 | for (i = 0; i < nig_params->num_of_rx_cos_priority_mask; i++) |
| 2591 | bnx2x_pfc_nig_rx_priority_mask(bp, i, |
| 2592 | nig_params->rx_cos_priority_mask[i], port); |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2593 | |
| 2594 | REG_WR(bp, port ? NIG_REG_LLFC_HIGH_PRIORITY_CLASSES_1 : |
| 2595 | NIG_REG_LLFC_HIGH_PRIORITY_CLASSES_0, |
| 2596 | nig_params->llfc_high_priority_classes); |
| 2597 | |
| 2598 | REG_WR(bp, port ? NIG_REG_LLFC_LOW_PRIORITY_CLASSES_1 : |
| 2599 | NIG_REG_LLFC_LOW_PRIORITY_CLASSES_0, |
| 2600 | nig_params->llfc_low_priority_classes); |
| 2601 | } |
| 2602 | REG_WR(bp, port ? NIG_REG_P1_PKT_PRIORITY_TO_COS : |
| 2603 | NIG_REG_P0_PKT_PRIORITY_TO_COS, |
| 2604 | pkt_priority_to_cos); |
| 2605 | } |
| 2606 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2607 | int bnx2x_update_pfc(struct link_params *params, |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2608 | struct link_vars *vars, |
| 2609 | struct bnx2x_nig_brb_pfc_port_params *pfc_params) |
| 2610 | { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2611 | /* |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2612 | * The PFC and pause are orthogonal to one another, meaning when |
| 2613 | * PFC is enabled, the pause are disabled, and when PFC is |
| 2614 | * disabled, pause are set according to the pause result. |
| 2615 | */ |
| 2616 | u32 val; |
| 2617 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2618 | int bnx2x_status = 0; |
| 2619 | u8 bmac_loopback = (params->loopback_mode == LOOPBACK_BMAC); |
Yaniv Rosner | b8d6d08 | 2011-07-05 01:06:27 +0000 | [diff] [blame] | 2620 | |
| 2621 | if (params->feature_config_flags & FEATURE_CONFIG_PFC_ENABLED) |
| 2622 | vars->link_status |= LINK_STATUS_PFC_ENABLED; |
| 2623 | else |
| 2624 | vars->link_status &= ~LINK_STATUS_PFC_ENABLED; |
| 2625 | |
| 2626 | bnx2x_update_mng(params, vars->link_status); |
| 2627 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2628 | /* update NIG params */ |
| 2629 | bnx2x_update_pfc_nig(params, vars, pfc_params); |
| 2630 | |
| 2631 | /* update BRB params */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2632 | bnx2x_status = bnx2x_update_pfc_brb(params, vars, pfc_params); |
Yaniv Rosner | de0396f | 2011-11-28 00:49:53 +0000 | [diff] [blame] | 2633 | if (bnx2x_status) |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2634 | return bnx2x_status; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2635 | |
| 2636 | if (!vars->link_up) |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2637 | return bnx2x_status; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2638 | |
| 2639 | DP(NETIF_MSG_LINK, "About to update PFC in BMAC\n"); |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2640 | if (CHIP_IS_E3(bp)) |
| 2641 | bnx2x_update_pfc_xmac(params, vars, 0); |
| 2642 | else { |
| 2643 | val = REG_RD(bp, MISC_REG_RESET_REG_2); |
| 2644 | if ((val & |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 2645 | (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << params->port)) |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2646 | == 0) { |
| 2647 | DP(NETIF_MSG_LINK, "About to update PFC in EMAC\n"); |
| 2648 | bnx2x_emac_enable(params, vars, 0); |
| 2649 | return bnx2x_status; |
| 2650 | } |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2651 | if (CHIP_IS_E2(bp)) |
| 2652 | bnx2x_update_pfc_bmac2(params, vars, bmac_loopback); |
| 2653 | else |
| 2654 | bnx2x_update_pfc_bmac1(params, vars); |
| 2655 | |
| 2656 | val = 0; |
| 2657 | if ((params->feature_config_flags & |
| 2658 | FEATURE_CONFIG_PFC_ENABLED) || |
| 2659 | (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX)) |
| 2660 | val = 1; |
| 2661 | REG_WR(bp, NIG_REG_BMAC0_PAUSE_OUT_EN + params->port*4, val); |
| 2662 | } |
| 2663 | return bnx2x_status; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2664 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2665 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 2666 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 2667 | static int bnx2x_bmac1_enable(struct link_params *params, |
| 2668 | struct link_vars *vars, |
| 2669 | u8 is_lb) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2670 | { |
| 2671 | struct bnx2x *bp = params->bp; |
| 2672 | u8 port = params->port; |
| 2673 | u32 bmac_addr = port ? NIG_REG_INGRESS_BMAC1_MEM : |
| 2674 | NIG_REG_INGRESS_BMAC0_MEM; |
| 2675 | u32 wb_data[2]; |
| 2676 | u32 val; |
| 2677 | |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2678 | DP(NETIF_MSG_LINK, "Enabling BigMAC1\n"); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2679 | |
| 2680 | /* XGXS control */ |
| 2681 | wb_data[0] = 0x3c; |
| 2682 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2683 | REG_WR_DMAE(bp, bmac_addr + BIGMAC_REGISTER_BMAC_XGXS_CONTROL, |
| 2684 | wb_data, 2); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2685 | |
| 2686 | /* tx MAC SA */ |
| 2687 | wb_data[0] = ((params->mac_addr[2] << 24) | |
| 2688 | (params->mac_addr[3] << 16) | |
| 2689 | (params->mac_addr[4] << 8) | |
| 2690 | params->mac_addr[5]); |
| 2691 | wb_data[1] = ((params->mac_addr[0] << 8) | |
| 2692 | params->mac_addr[1]); |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2693 | 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] | 2694 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2695 | /* mac control */ |
| 2696 | val = 0x3; |
| 2697 | if (is_lb) { |
| 2698 | val |= 0x4; |
| 2699 | DP(NETIF_MSG_LINK, "enable bmac loopback\n"); |
| 2700 | } |
| 2701 | wb_data[0] = val; |
| 2702 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2703 | 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] | 2704 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2705 | /* set rx mtu */ |
| 2706 | wb_data[0] = ETH_MAX_JUMBO_PACKET_SIZE + ETH_OVREHEAD; |
| 2707 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2708 | 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] | 2709 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2710 | bnx2x_update_pfc_bmac1(params, vars); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2711 | |
| 2712 | /* set tx mtu */ |
| 2713 | wb_data[0] = ETH_MAX_JUMBO_PACKET_SIZE + ETH_OVREHEAD; |
| 2714 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2715 | 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] | 2716 | |
| 2717 | /* set cnt max size */ |
| 2718 | wb_data[0] = ETH_MAX_JUMBO_PACKET_SIZE + ETH_OVREHEAD; |
| 2719 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2720 | 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] | 2721 | |
| 2722 | /* configure safc */ |
| 2723 | wb_data[0] = 0x1000200; |
| 2724 | wb_data[1] = 0; |
| 2725 | REG_WR_DMAE(bp, bmac_addr + BIGMAC_REGISTER_RX_LLFC_MSG_FLDS, |
| 2726 | wb_data, 2); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2727 | |
| 2728 | return 0; |
| 2729 | } |
| 2730 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 2731 | static int bnx2x_bmac2_enable(struct link_params *params, |
| 2732 | struct link_vars *vars, |
| 2733 | u8 is_lb) |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2734 | { |
| 2735 | struct bnx2x *bp = params->bp; |
| 2736 | u8 port = params->port; |
| 2737 | u32 bmac_addr = port ? NIG_REG_INGRESS_BMAC1_MEM : |
| 2738 | NIG_REG_INGRESS_BMAC0_MEM; |
| 2739 | u32 wb_data[2]; |
| 2740 | |
| 2741 | DP(NETIF_MSG_LINK, "Enabling BigMAC2\n"); |
| 2742 | |
| 2743 | wb_data[0] = 0; |
| 2744 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2745 | 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] | 2746 | udelay(30); |
| 2747 | |
| 2748 | /* XGXS control: Reset phy HW, MDIO registers, PHY PLL and BMAC */ |
| 2749 | wb_data[0] = 0x3c; |
| 2750 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2751 | REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_BMAC_XGXS_CONTROL, |
| 2752 | wb_data, 2); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2753 | |
| 2754 | udelay(30); |
| 2755 | |
| 2756 | /* tx MAC SA */ |
| 2757 | wb_data[0] = ((params->mac_addr[2] << 24) | |
| 2758 | (params->mac_addr[3] << 16) | |
| 2759 | (params->mac_addr[4] << 8) | |
| 2760 | params->mac_addr[5]); |
| 2761 | wb_data[1] = ((params->mac_addr[0] << 8) | |
| 2762 | params->mac_addr[1]); |
| 2763 | REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_TX_SOURCE_ADDR, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2764 | wb_data, 2); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2765 | |
| 2766 | udelay(30); |
| 2767 | |
| 2768 | /* Configure SAFC */ |
| 2769 | wb_data[0] = 0x1000200; |
| 2770 | wb_data[1] = 0; |
| 2771 | REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_RX_LLFC_MSG_FLDS, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2772 | wb_data, 2); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2773 | udelay(30); |
| 2774 | |
| 2775 | /* set rx mtu */ |
| 2776 | wb_data[0] = ETH_MAX_JUMBO_PACKET_SIZE + ETH_OVREHEAD; |
| 2777 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2778 | 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] | 2779 | udelay(30); |
| 2780 | |
| 2781 | /* set tx mtu */ |
| 2782 | wb_data[0] = ETH_MAX_JUMBO_PACKET_SIZE + ETH_OVREHEAD; |
| 2783 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2784 | 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] | 2785 | udelay(30); |
| 2786 | /* set cnt max size */ |
| 2787 | wb_data[0] = ETH_MAX_JUMBO_PACKET_SIZE + ETH_OVREHEAD - 2; |
| 2788 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2789 | 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] | 2790 | udelay(30); |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2791 | bnx2x_update_pfc_bmac2(params, vars, is_lb); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2792 | |
| 2793 | return 0; |
| 2794 | } |
| 2795 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 2796 | static int bnx2x_bmac_enable(struct link_params *params, |
| 2797 | struct link_vars *vars, |
| 2798 | u8 is_lb) |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2799 | { |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 2800 | int rc = 0; |
| 2801 | u8 port = params->port; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2802 | struct bnx2x *bp = params->bp; |
| 2803 | u32 val; |
| 2804 | /* reset and unreset the BigMac */ |
| 2805 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_CLEAR, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2806 | (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << port)); |
Yaniv Rosner | 1d9c05d | 2010-11-01 05:32:25 +0000 | [diff] [blame] | 2807 | msleep(1); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2808 | |
| 2809 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_SET, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2810 | (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << port)); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2811 | |
| 2812 | /* enable access for bmac registers */ |
| 2813 | REG_WR(bp, NIG_REG_BMAC0_REGS_OUT_EN + port*4, 0x1); |
| 2814 | |
| 2815 | /* Enable BMAC according to BMAC type*/ |
| 2816 | if (CHIP_IS_E2(bp)) |
| 2817 | rc = bnx2x_bmac2_enable(params, vars, is_lb); |
| 2818 | else |
| 2819 | rc = bnx2x_bmac1_enable(params, vars, is_lb); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2820 | REG_WR(bp, NIG_REG_XGXS_SERDES0_MODE_SEL + port*4, 0x1); |
| 2821 | REG_WR(bp, NIG_REG_XGXS_LANE_SEL_P0 + port*4, 0x0); |
| 2822 | REG_WR(bp, NIG_REG_EGRESS_EMAC0_PORT + port*4, 0x0); |
| 2823 | val = 0; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 2824 | if ((params->feature_config_flags & |
| 2825 | FEATURE_CONFIG_PFC_ENABLED) || |
| 2826 | (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX)) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2827 | val = 1; |
| 2828 | REG_WR(bp, NIG_REG_BMAC0_PAUSE_OUT_EN + port*4, val); |
| 2829 | REG_WR(bp, NIG_REG_EGRESS_EMAC0_OUT_EN + port*4, 0x0); |
| 2830 | REG_WR(bp, NIG_REG_EMAC0_IN_EN + port*4, 0x0); |
| 2831 | REG_WR(bp, NIG_REG_EMAC0_PAUSE_OUT_EN + port*4, 0x0); |
| 2832 | REG_WR(bp, NIG_REG_BMAC0_IN_EN + port*4, 0x1); |
| 2833 | REG_WR(bp, NIG_REG_BMAC0_OUT_EN + port*4, 0x1); |
| 2834 | |
| 2835 | vars->mac_type = MAC_TYPE_BMAC; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2836 | return rc; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2837 | } |
| 2838 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2839 | static void bnx2x_bmac_rx_disable(struct bnx2x *bp, u8 port) |
| 2840 | { |
| 2841 | u32 bmac_addr = port ? NIG_REG_INGRESS_BMAC1_MEM : |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2842 | NIG_REG_INGRESS_BMAC0_MEM; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2843 | u32 wb_data[2]; |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 2844 | 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] | 2845 | |
| 2846 | /* Only if the bmac is out of reset */ |
| 2847 | if (REG_RD(bp, MISC_REG_RESET_REG_2) & |
| 2848 | (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << port) && |
| 2849 | nig_bmac_enable) { |
| 2850 | |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2851 | if (CHIP_IS_E2(bp)) { |
| 2852 | /* Clear Rx Enable bit in BMAC_CONTROL register */ |
| 2853 | REG_RD_DMAE(bp, bmac_addr + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2854 | BIGMAC2_REGISTER_BMAC_CONTROL, |
| 2855 | wb_data, 2); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2856 | wb_data[0] &= ~BMAC_CONTROL_RX_ENABLE; |
| 2857 | REG_WR_DMAE(bp, bmac_addr + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2858 | BIGMAC2_REGISTER_BMAC_CONTROL, |
| 2859 | wb_data, 2); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2860 | } else { |
| 2861 | /* Clear Rx Enable bit in BMAC_CONTROL register */ |
| 2862 | REG_RD_DMAE(bp, bmac_addr + |
| 2863 | BIGMAC_REGISTER_BMAC_CONTROL, |
| 2864 | wb_data, 2); |
| 2865 | wb_data[0] &= ~BMAC_CONTROL_RX_ENABLE; |
| 2866 | REG_WR_DMAE(bp, bmac_addr + |
| 2867 | BIGMAC_REGISTER_BMAC_CONTROL, |
| 2868 | wb_data, 2); |
| 2869 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2870 | msleep(1); |
| 2871 | } |
| 2872 | } |
| 2873 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 2874 | static int bnx2x_pbf_update(struct link_params *params, u32 flow_ctrl, |
| 2875 | u32 line_speed) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2876 | { |
| 2877 | struct bnx2x *bp = params->bp; |
| 2878 | u8 port = params->port; |
| 2879 | u32 init_crd, crd; |
| 2880 | u32 count = 1000; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2881 | |
| 2882 | /* disable port */ |
| 2883 | REG_WR(bp, PBF_REG_DISABLE_NEW_TASK_PROC_P0 + port*4, 0x1); |
| 2884 | |
| 2885 | /* wait for init credit */ |
| 2886 | init_crd = REG_RD(bp, PBF_REG_P0_INIT_CRD + port*4); |
| 2887 | crd = REG_RD(bp, PBF_REG_P0_CREDIT + port*8); |
| 2888 | DP(NETIF_MSG_LINK, "init_crd 0x%x crd 0x%x\n", init_crd, crd); |
| 2889 | |
| 2890 | while ((init_crd != crd) && count) { |
| 2891 | msleep(5); |
| 2892 | |
| 2893 | crd = REG_RD(bp, PBF_REG_P0_CREDIT + port*8); |
| 2894 | count--; |
| 2895 | } |
| 2896 | crd = REG_RD(bp, PBF_REG_P0_CREDIT + port*8); |
| 2897 | if (init_crd != crd) { |
| 2898 | DP(NETIF_MSG_LINK, "BUG! init_crd 0x%x != crd 0x%x\n", |
| 2899 | init_crd, crd); |
| 2900 | return -EINVAL; |
| 2901 | } |
| 2902 | |
David S. Miller | c0700f9 | 2008-12-16 23:53:20 -0800 | [diff] [blame] | 2903 | if (flow_ctrl & BNX2X_FLOW_CTRL_RX || |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 2904 | line_speed == SPEED_10 || |
| 2905 | line_speed == SPEED_100 || |
| 2906 | line_speed == SPEED_1000 || |
| 2907 | line_speed == SPEED_2500) { |
| 2908 | REG_WR(bp, PBF_REG_P0_PAUSE_ENABLE + port*4, 1); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2909 | /* update threshold */ |
| 2910 | REG_WR(bp, PBF_REG_P0_ARB_THRSH + port*4, 0); |
| 2911 | /* update init credit */ |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2912 | init_crd = 778; /* (800-18-4) */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2913 | |
| 2914 | } else { |
| 2915 | u32 thresh = (ETH_MAX_JUMBO_PACKET_SIZE + |
| 2916 | ETH_OVREHEAD)/16; |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 2917 | REG_WR(bp, PBF_REG_P0_PAUSE_ENABLE + port*4, 0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2918 | /* update threshold */ |
| 2919 | REG_WR(bp, PBF_REG_P0_ARB_THRSH + port*4, thresh); |
| 2920 | /* update init credit */ |
| 2921 | switch (line_speed) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2922 | case SPEED_10000: |
| 2923 | init_crd = thresh + 553 - 22; |
| 2924 | break; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2925 | default: |
| 2926 | DP(NETIF_MSG_LINK, "Invalid line_speed 0x%x\n", |
| 2927 | line_speed); |
| 2928 | return -EINVAL; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2929 | } |
| 2930 | } |
| 2931 | REG_WR(bp, PBF_REG_P0_INIT_CRD + port*4, init_crd); |
| 2932 | DP(NETIF_MSG_LINK, "PBF updated to speed %d credit %d\n", |
| 2933 | line_speed, init_crd); |
| 2934 | |
| 2935 | /* probe the credit changes */ |
| 2936 | REG_WR(bp, PBF_REG_INIT_P0 + port*4, 0x1); |
| 2937 | msleep(5); |
| 2938 | REG_WR(bp, PBF_REG_INIT_P0 + port*4, 0x0); |
| 2939 | |
| 2940 | /* enable port */ |
| 2941 | REG_WR(bp, PBF_REG_DISABLE_NEW_TASK_PROC_P0 + port*4, 0x0); |
| 2942 | return 0; |
| 2943 | } |
| 2944 | |
Dmitry Kravkov | e892067 | 2011-05-04 23:52:40 +0000 | [diff] [blame] | 2945 | /** |
| 2946 | * bnx2x_get_emac_base - retrive emac base address |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2947 | * |
Dmitry Kravkov | e892067 | 2011-05-04 23:52:40 +0000 | [diff] [blame] | 2948 | * @bp: driver handle |
| 2949 | * @mdc_mdio_access: access type |
| 2950 | * @port: port id |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2951 | * |
| 2952 | * This function selects the MDC/MDIO access (through emac0 or |
| 2953 | * emac1) depend on the mdc_mdio_access, port, port swapped. Each |
| 2954 | * phy has a default access mode, which could also be overridden |
| 2955 | * by nvram configuration. This parameter, whether this is the |
| 2956 | * default phy configuration, or the nvram overrun |
| 2957 | * configuration, is passed here as mdc_mdio_access and selects |
| 2958 | * the emac_base for the CL45 read/writes operations |
| 2959 | */ |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 2960 | static u32 bnx2x_get_emac_base(struct bnx2x *bp, |
| 2961 | u32 mdc_mdio_access, u8 port) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2962 | { |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 2963 | u32 emac_base = 0; |
| 2964 | switch (mdc_mdio_access) { |
| 2965 | case SHARED_HW_CFG_MDC_MDIO_ACCESS1_PHY_TYPE: |
| 2966 | break; |
| 2967 | case SHARED_HW_CFG_MDC_MDIO_ACCESS1_EMAC0: |
| 2968 | if (REG_RD(bp, NIG_REG_PORT_SWAP)) |
| 2969 | emac_base = GRCBASE_EMAC1; |
| 2970 | else |
| 2971 | emac_base = GRCBASE_EMAC0; |
| 2972 | break; |
| 2973 | case SHARED_HW_CFG_MDC_MDIO_ACCESS1_EMAC1: |
Eilon Greenstein | 589abe3 | 2009-02-12 08:36:55 +0000 | [diff] [blame] | 2974 | if (REG_RD(bp, NIG_REG_PORT_SWAP)) |
| 2975 | emac_base = GRCBASE_EMAC0; |
| 2976 | else |
| 2977 | emac_base = GRCBASE_EMAC1; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2978 | break; |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 2979 | case SHARED_HW_CFG_MDC_MDIO_ACCESS1_BOTH: |
| 2980 | emac_base = (port) ? GRCBASE_EMAC1 : GRCBASE_EMAC0; |
| 2981 | break; |
| 2982 | case SHARED_HW_CFG_MDC_MDIO_ACCESS1_SWAPPED: |
Eilon Greenstein | 6378c02 | 2008-08-13 15:59:25 -0700 | [diff] [blame] | 2983 | emac_base = (port) ? GRCBASE_EMAC0 : GRCBASE_EMAC1; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2984 | break; |
| 2985 | default: |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2986 | break; |
| 2987 | } |
| 2988 | return emac_base; |
| 2989 | |
| 2990 | } |
| 2991 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2992 | /******************************************************************/ |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 2993 | /* CL22 access functions */ |
| 2994 | /******************************************************************/ |
| 2995 | static int bnx2x_cl22_write(struct bnx2x *bp, |
| 2996 | struct bnx2x_phy *phy, |
| 2997 | u16 reg, u16 val) |
| 2998 | { |
| 2999 | u32 tmp, mode; |
| 3000 | u8 i; |
| 3001 | int rc = 0; |
| 3002 | /* Switch to CL22 */ |
| 3003 | mode = REG_RD(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_MODE); |
| 3004 | REG_WR(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_MODE, |
| 3005 | mode & ~EMAC_MDIO_MODE_CLAUSE_45); |
| 3006 | |
| 3007 | /* address */ |
| 3008 | tmp = ((phy->addr << 21) | (reg << 16) | val | |
| 3009 | EMAC_MDIO_COMM_COMMAND_WRITE_22 | |
| 3010 | EMAC_MDIO_COMM_START_BUSY); |
| 3011 | REG_WR(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM, tmp); |
| 3012 | |
| 3013 | for (i = 0; i < 50; i++) { |
| 3014 | udelay(10); |
| 3015 | |
| 3016 | tmp = REG_RD(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM); |
| 3017 | if (!(tmp & EMAC_MDIO_COMM_START_BUSY)) { |
| 3018 | udelay(5); |
| 3019 | break; |
| 3020 | } |
| 3021 | } |
| 3022 | if (tmp & EMAC_MDIO_COMM_START_BUSY) { |
| 3023 | DP(NETIF_MSG_LINK, "write phy register failed\n"); |
| 3024 | rc = -EFAULT; |
| 3025 | } |
| 3026 | REG_WR(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_MODE, mode); |
| 3027 | return rc; |
| 3028 | } |
| 3029 | |
| 3030 | static int bnx2x_cl22_read(struct bnx2x *bp, |
| 3031 | struct bnx2x_phy *phy, |
| 3032 | u16 reg, u16 *ret_val) |
| 3033 | { |
| 3034 | u32 val, mode; |
| 3035 | u16 i; |
| 3036 | int rc = 0; |
| 3037 | |
| 3038 | /* Switch to CL22 */ |
| 3039 | mode = REG_RD(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_MODE); |
| 3040 | REG_WR(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_MODE, |
| 3041 | mode & ~EMAC_MDIO_MODE_CLAUSE_45); |
| 3042 | |
| 3043 | /* address */ |
| 3044 | val = ((phy->addr << 21) | (reg << 16) | |
| 3045 | EMAC_MDIO_COMM_COMMAND_READ_22 | |
| 3046 | EMAC_MDIO_COMM_START_BUSY); |
| 3047 | REG_WR(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM, val); |
| 3048 | |
| 3049 | for (i = 0; i < 50; i++) { |
| 3050 | udelay(10); |
| 3051 | |
| 3052 | val = REG_RD(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM); |
| 3053 | if (!(val & EMAC_MDIO_COMM_START_BUSY)) { |
| 3054 | *ret_val = (u16)(val & EMAC_MDIO_COMM_DATA); |
| 3055 | udelay(5); |
| 3056 | break; |
| 3057 | } |
| 3058 | } |
| 3059 | if (val & EMAC_MDIO_COMM_START_BUSY) { |
| 3060 | DP(NETIF_MSG_LINK, "read phy register failed\n"); |
| 3061 | |
| 3062 | *ret_val = 0; |
| 3063 | rc = -EFAULT; |
| 3064 | } |
| 3065 | REG_WR(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_MODE, mode); |
| 3066 | return rc; |
| 3067 | } |
| 3068 | |
| 3069 | /******************************************************************/ |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3070 | /* CL45 access functions */ |
| 3071 | /******************************************************************/ |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 3072 | static int bnx2x_cl45_read(struct bnx2x *bp, struct bnx2x_phy *phy, |
| 3073 | u8 devad, u16 reg, u16 *ret_val) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3074 | { |
Yaniv Rosner | a198c14 | 2011-05-31 21:29:42 +0000 | [diff] [blame] | 3075 | u32 val; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3076 | u16 i; |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 3077 | int rc = 0; |
Yaniv Rosner | 157fa28 | 2011-08-02 22:59:32 +0000 | [diff] [blame] | 3078 | if (phy->flags & FLAGS_MDC_MDIO_WA_B0) |
| 3079 | bnx2x_bits_en(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_STATUS, |
| 3080 | EMAC_MDIO_STATUS_10MB); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3081 | /* address */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3082 | val = ((phy->addr << 21) | (devad << 16) | reg | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3083 | EMAC_MDIO_COMM_COMMAND_ADDRESS | |
| 3084 | EMAC_MDIO_COMM_START_BUSY); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3085 | REG_WR(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM, val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3086 | |
| 3087 | for (i = 0; i < 50; i++) { |
| 3088 | udelay(10); |
| 3089 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3090 | val = REG_RD(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3091 | if (!(val & EMAC_MDIO_COMM_START_BUSY)) { |
| 3092 | udelay(5); |
| 3093 | break; |
| 3094 | } |
| 3095 | } |
| 3096 | if (val & EMAC_MDIO_COMM_START_BUSY) { |
| 3097 | DP(NETIF_MSG_LINK, "read phy register failed\n"); |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 3098 | netdev_err(bp->dev, "MDC/MDIO access timeout\n"); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3099 | *ret_val = 0; |
| 3100 | rc = -EFAULT; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3101 | } else { |
| 3102 | /* data */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3103 | val = ((phy->addr << 21) | (devad << 16) | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3104 | EMAC_MDIO_COMM_COMMAND_READ_45 | |
| 3105 | EMAC_MDIO_COMM_START_BUSY); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3106 | REG_WR(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM, val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3107 | |
| 3108 | for (i = 0; i < 50; i++) { |
| 3109 | udelay(10); |
| 3110 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3111 | val = REG_RD(bp, phy->mdio_ctrl + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3112 | EMAC_REG_EMAC_MDIO_COMM); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3113 | if (!(val & EMAC_MDIO_COMM_START_BUSY)) { |
| 3114 | *ret_val = (u16)(val & EMAC_MDIO_COMM_DATA); |
| 3115 | break; |
| 3116 | } |
| 3117 | } |
| 3118 | if (val & EMAC_MDIO_COMM_START_BUSY) { |
| 3119 | DP(NETIF_MSG_LINK, "read phy register failed\n"); |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 3120 | netdev_err(bp->dev, "MDC/MDIO access timeout\n"); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3121 | *ret_val = 0; |
| 3122 | rc = -EFAULT; |
| 3123 | } |
| 3124 | } |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 3125 | /* Work around for E3 A0 */ |
| 3126 | if (phy->flags & FLAGS_MDC_MDIO_WA) { |
| 3127 | phy->flags ^= FLAGS_DUMMY_READ; |
| 3128 | if (phy->flags & FLAGS_DUMMY_READ) { |
| 3129 | u16 temp_val; |
| 3130 | bnx2x_cl45_read(bp, phy, devad, 0xf, &temp_val); |
| 3131 | } |
| 3132 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3133 | |
Yaniv Rosner | 157fa28 | 2011-08-02 22:59:32 +0000 | [diff] [blame] | 3134 | if (phy->flags & FLAGS_MDC_MDIO_WA_B0) |
| 3135 | bnx2x_bits_dis(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_STATUS, |
| 3136 | EMAC_MDIO_STATUS_10MB); |
Yaniv Rosner | a198c14 | 2011-05-31 21:29:42 +0000 | [diff] [blame] | 3137 | return rc; |
| 3138 | } |
| 3139 | |
| 3140 | static int bnx2x_cl45_write(struct bnx2x *bp, struct bnx2x_phy *phy, |
| 3141 | u8 devad, u16 reg, u16 val) |
| 3142 | { |
| 3143 | u32 tmp; |
| 3144 | u8 i; |
| 3145 | int rc = 0; |
Yaniv Rosner | 157fa28 | 2011-08-02 22:59:32 +0000 | [diff] [blame] | 3146 | if (phy->flags & FLAGS_MDC_MDIO_WA_B0) |
| 3147 | bnx2x_bits_en(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_STATUS, |
| 3148 | EMAC_MDIO_STATUS_10MB); |
Yaniv Rosner | a198c14 | 2011-05-31 21:29:42 +0000 | [diff] [blame] | 3149 | |
| 3150 | /* address */ |
| 3151 | |
| 3152 | tmp = ((phy->addr << 21) | (devad << 16) | reg | |
| 3153 | EMAC_MDIO_COMM_COMMAND_ADDRESS | |
| 3154 | EMAC_MDIO_COMM_START_BUSY); |
| 3155 | REG_WR(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM, tmp); |
| 3156 | |
| 3157 | for (i = 0; i < 50; i++) { |
| 3158 | udelay(10); |
| 3159 | |
| 3160 | tmp = REG_RD(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM); |
| 3161 | if (!(tmp & EMAC_MDIO_COMM_START_BUSY)) { |
| 3162 | udelay(5); |
| 3163 | break; |
| 3164 | } |
| 3165 | } |
| 3166 | if (tmp & EMAC_MDIO_COMM_START_BUSY) { |
| 3167 | DP(NETIF_MSG_LINK, "write phy register failed\n"); |
| 3168 | netdev_err(bp->dev, "MDC/MDIO access timeout\n"); |
| 3169 | rc = -EFAULT; |
Yaniv Rosner | a198c14 | 2011-05-31 21:29:42 +0000 | [diff] [blame] | 3170 | } else { |
| 3171 | /* data */ |
| 3172 | tmp = ((phy->addr << 21) | (devad << 16) | val | |
| 3173 | EMAC_MDIO_COMM_COMMAND_WRITE_45 | |
| 3174 | EMAC_MDIO_COMM_START_BUSY); |
| 3175 | REG_WR(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM, tmp); |
| 3176 | |
| 3177 | for (i = 0; i < 50; i++) { |
| 3178 | udelay(10); |
| 3179 | |
| 3180 | tmp = REG_RD(bp, phy->mdio_ctrl + |
| 3181 | EMAC_REG_EMAC_MDIO_COMM); |
| 3182 | if (!(tmp & EMAC_MDIO_COMM_START_BUSY)) { |
| 3183 | udelay(5); |
| 3184 | break; |
| 3185 | } |
| 3186 | } |
| 3187 | if (tmp & EMAC_MDIO_COMM_START_BUSY) { |
| 3188 | DP(NETIF_MSG_LINK, "write phy register failed\n"); |
| 3189 | netdev_err(bp->dev, "MDC/MDIO access timeout\n"); |
| 3190 | rc = -EFAULT; |
| 3191 | } |
| 3192 | } |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 3193 | /* Work around for E3 A0 */ |
| 3194 | if (phy->flags & FLAGS_MDC_MDIO_WA) { |
| 3195 | phy->flags ^= FLAGS_DUMMY_READ; |
| 3196 | if (phy->flags & FLAGS_DUMMY_READ) { |
| 3197 | u16 temp_val; |
| 3198 | bnx2x_cl45_read(bp, phy, devad, 0xf, &temp_val); |
| 3199 | } |
| 3200 | } |
Yaniv Rosner | 157fa28 | 2011-08-02 22:59:32 +0000 | [diff] [blame] | 3201 | if (phy->flags & FLAGS_MDC_MDIO_WA_B0) |
| 3202 | bnx2x_bits_dis(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_STATUS, |
| 3203 | EMAC_MDIO_STATUS_10MB); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3204 | return rc; |
| 3205 | } |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 3206 | /******************************************************************/ |
| 3207 | /* BSC access functions from E3 */ |
| 3208 | /******************************************************************/ |
| 3209 | static void bnx2x_bsc_module_sel(struct link_params *params) |
| 3210 | { |
| 3211 | int idx; |
| 3212 | u32 board_cfg, sfp_ctrl; |
| 3213 | u32 i2c_pins[I2C_SWITCH_WIDTH], i2c_val[I2C_SWITCH_WIDTH]; |
| 3214 | struct bnx2x *bp = params->bp; |
| 3215 | u8 port = params->port; |
| 3216 | /* Read I2C output PINs */ |
| 3217 | board_cfg = REG_RD(bp, params->shmem_base + |
| 3218 | offsetof(struct shmem_region, |
| 3219 | dev_info.shared_hw_config.board)); |
| 3220 | i2c_pins[I2C_BSC0] = board_cfg & SHARED_HW_CFG_E3_I2C_MUX0_MASK; |
| 3221 | i2c_pins[I2C_BSC1] = (board_cfg & SHARED_HW_CFG_E3_I2C_MUX1_MASK) >> |
| 3222 | SHARED_HW_CFG_E3_I2C_MUX1_SHIFT; |
| 3223 | |
| 3224 | /* Read I2C output value */ |
| 3225 | sfp_ctrl = REG_RD(bp, params->shmem_base + |
| 3226 | offsetof(struct shmem_region, |
| 3227 | dev_info.port_hw_config[port].e3_cmn_pin_cfg)); |
| 3228 | i2c_val[I2C_BSC0] = (sfp_ctrl & PORT_HW_CFG_E3_I2C_MUX0_MASK) > 0; |
| 3229 | i2c_val[I2C_BSC1] = (sfp_ctrl & PORT_HW_CFG_E3_I2C_MUX1_MASK) > 0; |
| 3230 | DP(NETIF_MSG_LINK, "Setting BSC switch\n"); |
| 3231 | for (idx = 0; idx < I2C_SWITCH_WIDTH; idx++) |
| 3232 | bnx2x_set_cfg_pin(bp, i2c_pins[idx], i2c_val[idx]); |
| 3233 | } |
| 3234 | |
| 3235 | static int bnx2x_bsc_read(struct link_params *params, |
| 3236 | struct bnx2x_phy *phy, |
| 3237 | u8 sl_devid, |
| 3238 | u16 sl_addr, |
| 3239 | u8 lc_addr, |
| 3240 | u8 xfer_cnt, |
| 3241 | u32 *data_array) |
| 3242 | { |
| 3243 | u32 val, i; |
| 3244 | int rc = 0; |
| 3245 | struct bnx2x *bp = params->bp; |
| 3246 | |
| 3247 | if ((sl_devid != 0xa0) && (sl_devid != 0xa2)) { |
| 3248 | DP(NETIF_MSG_LINK, "invalid sl_devid 0x%x\n", sl_devid); |
| 3249 | return -EINVAL; |
| 3250 | } |
| 3251 | |
| 3252 | if (xfer_cnt > 16) { |
| 3253 | DP(NETIF_MSG_LINK, "invalid xfer_cnt %d. Max is 16 bytes\n", |
| 3254 | xfer_cnt); |
| 3255 | return -EINVAL; |
| 3256 | } |
| 3257 | bnx2x_bsc_module_sel(params); |
| 3258 | |
| 3259 | xfer_cnt = 16 - lc_addr; |
| 3260 | |
| 3261 | /* enable the engine */ |
| 3262 | val = REG_RD(bp, MCP_REG_MCPR_IMC_COMMAND); |
| 3263 | val |= MCPR_IMC_COMMAND_ENABLE; |
| 3264 | REG_WR(bp, MCP_REG_MCPR_IMC_COMMAND, val); |
| 3265 | |
| 3266 | /* program slave device ID */ |
| 3267 | val = (sl_devid << 16) | sl_addr; |
| 3268 | REG_WR(bp, MCP_REG_MCPR_IMC_SLAVE_CONTROL, val); |
| 3269 | |
| 3270 | /* start xfer with 0 byte to update the address pointer ???*/ |
| 3271 | val = (MCPR_IMC_COMMAND_ENABLE) | |
| 3272 | (MCPR_IMC_COMMAND_WRITE_OP << |
| 3273 | MCPR_IMC_COMMAND_OPERATION_BITSHIFT) | |
| 3274 | (lc_addr << MCPR_IMC_COMMAND_TRANSFER_ADDRESS_BITSHIFT) | (0); |
| 3275 | REG_WR(bp, MCP_REG_MCPR_IMC_COMMAND, val); |
| 3276 | |
| 3277 | /* poll for completion */ |
| 3278 | i = 0; |
| 3279 | val = REG_RD(bp, MCP_REG_MCPR_IMC_COMMAND); |
| 3280 | while (((val >> MCPR_IMC_COMMAND_IMC_STATUS_BITSHIFT) & 0x3) != 1) { |
| 3281 | udelay(10); |
| 3282 | val = REG_RD(bp, MCP_REG_MCPR_IMC_COMMAND); |
| 3283 | if (i++ > 1000) { |
| 3284 | DP(NETIF_MSG_LINK, "wr 0 byte timed out after %d try\n", |
| 3285 | i); |
| 3286 | rc = -EFAULT; |
| 3287 | break; |
| 3288 | } |
| 3289 | } |
| 3290 | if (rc == -EFAULT) |
| 3291 | return rc; |
| 3292 | |
| 3293 | /* start xfer with read op */ |
| 3294 | val = (MCPR_IMC_COMMAND_ENABLE) | |
| 3295 | (MCPR_IMC_COMMAND_READ_OP << |
| 3296 | MCPR_IMC_COMMAND_OPERATION_BITSHIFT) | |
| 3297 | (lc_addr << MCPR_IMC_COMMAND_TRANSFER_ADDRESS_BITSHIFT) | |
| 3298 | (xfer_cnt); |
| 3299 | REG_WR(bp, MCP_REG_MCPR_IMC_COMMAND, val); |
| 3300 | |
| 3301 | /* poll for completion */ |
| 3302 | i = 0; |
| 3303 | val = REG_RD(bp, MCP_REG_MCPR_IMC_COMMAND); |
| 3304 | while (((val >> MCPR_IMC_COMMAND_IMC_STATUS_BITSHIFT) & 0x3) != 1) { |
| 3305 | udelay(10); |
| 3306 | val = REG_RD(bp, MCP_REG_MCPR_IMC_COMMAND); |
| 3307 | if (i++ > 1000) { |
| 3308 | DP(NETIF_MSG_LINK, "rd op timed out after %d try\n", i); |
| 3309 | rc = -EFAULT; |
| 3310 | break; |
| 3311 | } |
| 3312 | } |
| 3313 | if (rc == -EFAULT) |
| 3314 | return rc; |
| 3315 | |
| 3316 | for (i = (lc_addr >> 2); i < 4; i++) { |
| 3317 | data_array[i] = REG_RD(bp, (MCP_REG_MCPR_IMC_DATAREG0 + i*4)); |
| 3318 | #ifdef __BIG_ENDIAN |
| 3319 | data_array[i] = ((data_array[i] & 0x000000ff) << 24) | |
| 3320 | ((data_array[i] & 0x0000ff00) << 8) | |
| 3321 | ((data_array[i] & 0x00ff0000) >> 8) | |
| 3322 | ((data_array[i] & 0xff000000) >> 24); |
| 3323 | #endif |
| 3324 | } |
| 3325 | return rc; |
| 3326 | } |
| 3327 | |
| 3328 | static void bnx2x_cl45_read_or_write(struct bnx2x *bp, struct bnx2x_phy *phy, |
| 3329 | u8 devad, u16 reg, u16 or_val) |
| 3330 | { |
| 3331 | u16 val; |
| 3332 | bnx2x_cl45_read(bp, phy, devad, reg, &val); |
| 3333 | bnx2x_cl45_write(bp, phy, devad, reg, val | or_val); |
| 3334 | } |
| 3335 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 3336 | int bnx2x_phy_read(struct link_params *params, u8 phy_addr, |
| 3337 | u8 devad, u16 reg, u16 *ret_val) |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3338 | { |
| 3339 | u8 phy_index; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3340 | /* |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3341 | * Probe for the phy according to the given phy_addr, and execute |
| 3342 | * the read request on it |
| 3343 | */ |
| 3344 | for (phy_index = 0; phy_index < params->num_phys; phy_index++) { |
| 3345 | if (params->phy[phy_index].addr == phy_addr) { |
| 3346 | return bnx2x_cl45_read(params->bp, |
| 3347 | ¶ms->phy[phy_index], devad, |
| 3348 | reg, ret_val); |
| 3349 | } |
| 3350 | } |
| 3351 | return -EINVAL; |
| 3352 | } |
| 3353 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 3354 | int bnx2x_phy_write(struct link_params *params, u8 phy_addr, |
| 3355 | u8 devad, u16 reg, u16 val) |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3356 | { |
| 3357 | u8 phy_index; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3358 | /* |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3359 | * Probe for the phy according to the given phy_addr, and execute |
| 3360 | * the write request on it |
| 3361 | */ |
| 3362 | for (phy_index = 0; phy_index < params->num_phys; phy_index++) { |
| 3363 | if (params->phy[phy_index].addr == phy_addr) { |
| 3364 | return bnx2x_cl45_write(params->bp, |
| 3365 | ¶ms->phy[phy_index], devad, |
| 3366 | reg, val); |
| 3367 | } |
| 3368 | } |
| 3369 | return -EINVAL; |
| 3370 | } |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 3371 | static u8 bnx2x_get_warpcore_lane(struct bnx2x_phy *phy, |
| 3372 | struct link_params *params) |
| 3373 | { |
| 3374 | u8 lane = 0; |
| 3375 | struct bnx2x *bp = params->bp; |
| 3376 | u32 path_swap, path_swap_ovr; |
| 3377 | u8 path, port; |
| 3378 | |
| 3379 | path = BP_PATH(bp); |
| 3380 | port = params->port; |
| 3381 | |
| 3382 | if (bnx2x_is_4_port_mode(bp)) { |
| 3383 | u32 port_swap, port_swap_ovr; |
| 3384 | |
| 3385 | /*figure out path swap value */ |
| 3386 | path_swap_ovr = REG_RD(bp, MISC_REG_FOUR_PORT_PATH_SWAP_OVWR); |
| 3387 | if (path_swap_ovr & 0x1) |
| 3388 | path_swap = (path_swap_ovr & 0x2); |
| 3389 | else |
| 3390 | path_swap = REG_RD(bp, MISC_REG_FOUR_PORT_PATH_SWAP); |
| 3391 | |
| 3392 | if (path_swap) |
| 3393 | path = path ^ 1; |
| 3394 | |
| 3395 | /*figure out port swap value */ |
| 3396 | port_swap_ovr = REG_RD(bp, MISC_REG_FOUR_PORT_PORT_SWAP_OVWR); |
| 3397 | if (port_swap_ovr & 0x1) |
| 3398 | port_swap = (port_swap_ovr & 0x2); |
| 3399 | else |
| 3400 | port_swap = REG_RD(bp, MISC_REG_FOUR_PORT_PORT_SWAP); |
| 3401 | |
| 3402 | if (port_swap) |
| 3403 | port = port ^ 1; |
| 3404 | |
| 3405 | lane = (port<<1) + path; |
| 3406 | } else { /* two port mode - no port swap */ |
| 3407 | |
| 3408 | /*figure out path swap value */ |
| 3409 | path_swap_ovr = |
| 3410 | REG_RD(bp, MISC_REG_TWO_PORT_PATH_SWAP_OVWR); |
| 3411 | if (path_swap_ovr & 0x1) { |
| 3412 | path_swap = (path_swap_ovr & 0x2); |
| 3413 | } else { |
| 3414 | path_swap = |
| 3415 | REG_RD(bp, MISC_REG_TWO_PORT_PATH_SWAP); |
| 3416 | } |
| 3417 | if (path_swap) |
| 3418 | path = path ^ 1; |
| 3419 | |
| 3420 | lane = path << 1 ; |
| 3421 | } |
| 3422 | return lane; |
| 3423 | } |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3424 | |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 3425 | static void bnx2x_set_aer_mmd(struct link_params *params, |
| 3426 | struct bnx2x_phy *phy) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3427 | { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3428 | u32 ser_lane; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 3429 | u16 offset, aer_val; |
| 3430 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3431 | ser_lane = ((params->lane_config & |
| 3432 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_MASK) >> |
| 3433 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_SHIFT); |
| 3434 | |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 3435 | offset = (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT) ? |
| 3436 | (phy->addr + ser_lane) : 0; |
| 3437 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 3438 | if (USES_WARPCORE(bp)) { |
| 3439 | aer_val = bnx2x_get_warpcore_lane(phy, params); |
| 3440 | /* |
| 3441 | * In Dual-lane mode, two lanes are joined together, |
| 3442 | * so in order to configure them, the AER broadcast method is |
| 3443 | * used here. |
| 3444 | * 0x200 is the broadcast address for lanes 0,1 |
| 3445 | * 0x201 is the broadcast address for lanes 2,3 |
| 3446 | */ |
| 3447 | if (phy->flags & FLAGS_WC_DUAL_MODE) |
| 3448 | aer_val = (aer_val >> 1) | 0x200; |
| 3449 | } else if (CHIP_IS_E2(bp)) |
Yaniv Rosner | 82a0d47 | 2011-01-18 04:33:52 +0000 | [diff] [blame] | 3450 | aer_val = 0x3800 + offset - 1; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 3451 | else |
| 3452 | aer_val = 0x3800 + offset; |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 3453 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 3454 | CL22_WR_OVER_CL45(bp, phy, MDIO_REG_BANK_AER_BLOCK, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3455 | MDIO_AER_BLOCK_AER_REG, aer_val); |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 3456 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3457 | } |
| 3458 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3459 | /******************************************************************/ |
| 3460 | /* Internal phy section */ |
| 3461 | /******************************************************************/ |
| 3462 | |
| 3463 | static void bnx2x_set_serdes_access(struct bnx2x *bp, u8 port) |
| 3464 | { |
| 3465 | u32 emac_base = (port) ? GRCBASE_EMAC1 : GRCBASE_EMAC0; |
| 3466 | |
| 3467 | /* Set Clause 22 */ |
| 3468 | REG_WR(bp, NIG_REG_SERDES0_CTRL_MD_ST + port*0x10, 1); |
| 3469 | REG_WR(bp, emac_base + EMAC_REG_EMAC_MDIO_COMM, 0x245f8000); |
| 3470 | udelay(500); |
| 3471 | REG_WR(bp, emac_base + EMAC_REG_EMAC_MDIO_COMM, 0x245d000f); |
| 3472 | udelay(500); |
| 3473 | /* Set Clause 45 */ |
| 3474 | REG_WR(bp, NIG_REG_SERDES0_CTRL_MD_ST + port*0x10, 0); |
| 3475 | } |
| 3476 | |
| 3477 | static void bnx2x_serdes_deassert(struct bnx2x *bp, u8 port) |
| 3478 | { |
| 3479 | u32 val; |
| 3480 | |
| 3481 | DP(NETIF_MSG_LINK, "bnx2x_serdes_deassert\n"); |
| 3482 | |
| 3483 | val = SERDES_RESET_BITS << (port*16); |
| 3484 | |
| 3485 | /* reset and unreset the SerDes/XGXS */ |
| 3486 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_3_CLEAR, val); |
| 3487 | udelay(500); |
| 3488 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_3_SET, val); |
| 3489 | |
| 3490 | bnx2x_set_serdes_access(bp, port); |
| 3491 | |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3492 | REG_WR(bp, NIG_REG_SERDES0_CTRL_MD_DEVAD + port*0x10, |
| 3493 | DEFAULT_PHY_DEV_ADDR); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3494 | } |
| 3495 | |
| 3496 | static void bnx2x_xgxs_deassert(struct link_params *params) |
| 3497 | { |
| 3498 | struct bnx2x *bp = params->bp; |
| 3499 | u8 port; |
| 3500 | u32 val; |
| 3501 | DP(NETIF_MSG_LINK, "bnx2x_xgxs_deassert\n"); |
| 3502 | port = params->port; |
| 3503 | |
| 3504 | val = XGXS_RESET_BITS << (port*16); |
| 3505 | |
| 3506 | /* reset and unreset the SerDes/XGXS */ |
| 3507 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_3_CLEAR, val); |
| 3508 | udelay(500); |
| 3509 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_3_SET, val); |
| 3510 | |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3511 | REG_WR(bp, NIG_REG_XGXS0_CTRL_MD_ST + port*0x18, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3512 | REG_WR(bp, NIG_REG_XGXS0_CTRL_MD_DEVAD + port*0x18, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3513 | params->phy[INT_PHY].def_md_devad); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3514 | } |
| 3515 | |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 3516 | static void bnx2x_calc_ieee_aneg_adv(struct bnx2x_phy *phy, |
| 3517 | struct link_params *params, u16 *ieee_fc) |
| 3518 | { |
| 3519 | struct bnx2x *bp = params->bp; |
| 3520 | *ieee_fc = MDIO_COMBO_IEEE0_AUTO_NEG_ADV_FULL_DUPLEX; |
| 3521 | /** |
| 3522 | * resolve pause mode and advertisement Please refer to Table |
| 3523 | * 28B-3 of the 802.3ab-1999 spec |
| 3524 | */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3525 | |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 3526 | switch (phy->req_flow_ctrl) { |
| 3527 | case BNX2X_FLOW_CTRL_AUTO: |
| 3528 | if (params->req_fc_auto_adv == BNX2X_FLOW_CTRL_BOTH) |
| 3529 | *ieee_fc |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH; |
| 3530 | else |
| 3531 | *ieee_fc |= |
| 3532 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC; |
| 3533 | break; |
| 3534 | |
| 3535 | case BNX2X_FLOW_CTRL_TX: |
| 3536 | *ieee_fc |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC; |
| 3537 | break; |
| 3538 | |
| 3539 | case BNX2X_FLOW_CTRL_RX: |
| 3540 | case BNX2X_FLOW_CTRL_BOTH: |
| 3541 | *ieee_fc |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH; |
| 3542 | break; |
| 3543 | |
| 3544 | case BNX2X_FLOW_CTRL_NONE: |
| 3545 | default: |
| 3546 | *ieee_fc |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_NONE; |
| 3547 | break; |
| 3548 | } |
| 3549 | DP(NETIF_MSG_LINK, "ieee_fc = 0x%x\n", *ieee_fc); |
| 3550 | } |
| 3551 | |
| 3552 | static void set_phy_vars(struct link_params *params, |
| 3553 | struct link_vars *vars) |
| 3554 | { |
| 3555 | struct bnx2x *bp = params->bp; |
| 3556 | u8 actual_phy_idx, phy_index, link_cfg_idx; |
| 3557 | u8 phy_config_swapped = params->multi_phy_config & |
| 3558 | PORT_HW_CFG_PHY_SWAPPED_ENABLED; |
| 3559 | for (phy_index = INT_PHY; phy_index < params->num_phys; |
| 3560 | phy_index++) { |
| 3561 | link_cfg_idx = LINK_CONFIG_IDX(phy_index); |
| 3562 | actual_phy_idx = phy_index; |
| 3563 | if (phy_config_swapped) { |
| 3564 | if (phy_index == EXT_PHY1) |
| 3565 | actual_phy_idx = EXT_PHY2; |
| 3566 | else if (phy_index == EXT_PHY2) |
| 3567 | actual_phy_idx = EXT_PHY1; |
| 3568 | } |
| 3569 | params->phy[actual_phy_idx].req_flow_ctrl = |
| 3570 | params->req_flow_ctrl[link_cfg_idx]; |
| 3571 | |
| 3572 | params->phy[actual_phy_idx].req_line_speed = |
| 3573 | params->req_line_speed[link_cfg_idx]; |
| 3574 | |
| 3575 | params->phy[actual_phy_idx].speed_cap_mask = |
| 3576 | params->speed_cap_mask[link_cfg_idx]; |
| 3577 | |
| 3578 | params->phy[actual_phy_idx].req_duplex = |
| 3579 | params->req_duplex[link_cfg_idx]; |
| 3580 | |
| 3581 | if (params->req_line_speed[link_cfg_idx] == |
| 3582 | SPEED_AUTO_NEG) |
| 3583 | vars->link_status |= LINK_STATUS_AUTO_NEGOTIATE_ENABLED; |
| 3584 | |
| 3585 | DP(NETIF_MSG_LINK, "req_flow_ctrl %x, req_line_speed %x," |
| 3586 | " speed_cap_mask %x\n", |
| 3587 | params->phy[actual_phy_idx].req_flow_ctrl, |
| 3588 | params->phy[actual_phy_idx].req_line_speed, |
| 3589 | params->phy[actual_phy_idx].speed_cap_mask); |
| 3590 | } |
| 3591 | } |
| 3592 | |
| 3593 | static void bnx2x_ext_phy_set_pause(struct link_params *params, |
| 3594 | struct bnx2x_phy *phy, |
| 3595 | struct link_vars *vars) |
| 3596 | { |
| 3597 | u16 val; |
| 3598 | struct bnx2x *bp = params->bp; |
| 3599 | /* read modify write pause advertizing */ |
| 3600 | bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_ADV_PAUSE, &val); |
| 3601 | |
| 3602 | val &= ~MDIO_AN_REG_ADV_PAUSE_BOTH; |
| 3603 | |
| 3604 | /* Please refer to Table 28B-3 of 802.3ab-1999 spec. */ |
| 3605 | bnx2x_calc_ieee_aneg_adv(phy, params, &vars->ieee_fc); |
| 3606 | if ((vars->ieee_fc & |
| 3607 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC) == |
| 3608 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC) { |
| 3609 | val |= MDIO_AN_REG_ADV_PAUSE_ASYMMETRIC; |
| 3610 | } |
| 3611 | if ((vars->ieee_fc & |
| 3612 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) == |
| 3613 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) { |
| 3614 | val |= MDIO_AN_REG_ADV_PAUSE_PAUSE; |
| 3615 | } |
| 3616 | DP(NETIF_MSG_LINK, "Ext phy AN advertize 0x%x\n", val); |
| 3617 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_ADV_PAUSE, val); |
| 3618 | } |
| 3619 | |
| 3620 | static void bnx2x_pause_resolve(struct link_vars *vars, u32 pause_result) |
| 3621 | { /* LD LP */ |
| 3622 | switch (pause_result) { /* ASYM P ASYM P */ |
| 3623 | case 0xb: /* 1 0 1 1 */ |
| 3624 | vars->flow_ctrl = BNX2X_FLOW_CTRL_TX; |
| 3625 | break; |
| 3626 | |
| 3627 | case 0xe: /* 1 1 1 0 */ |
| 3628 | vars->flow_ctrl = BNX2X_FLOW_CTRL_RX; |
| 3629 | break; |
| 3630 | |
| 3631 | case 0x5: /* 0 1 0 1 */ |
| 3632 | case 0x7: /* 0 1 1 1 */ |
| 3633 | case 0xd: /* 1 1 0 1 */ |
| 3634 | case 0xf: /* 1 1 1 1 */ |
| 3635 | vars->flow_ctrl = BNX2X_FLOW_CTRL_BOTH; |
| 3636 | break; |
| 3637 | |
| 3638 | default: |
| 3639 | break; |
| 3640 | } |
| 3641 | if (pause_result & (1<<0)) |
| 3642 | vars->link_status |= LINK_STATUS_LINK_PARTNER_SYMMETRIC_PAUSE; |
| 3643 | if (pause_result & (1<<1)) |
| 3644 | vars->link_status |= LINK_STATUS_LINK_PARTNER_ASYMMETRIC_PAUSE; |
| 3645 | } |
| 3646 | |
Mintz Yuval | 9e7e839 | 2012-02-15 02:10:24 +0000 | [diff] [blame] | 3647 | static void bnx2x_ext_phy_update_adv_fc(struct bnx2x_phy *phy, |
| 3648 | struct link_params *params, |
| 3649 | struct link_vars *vars) |
| 3650 | { |
| 3651 | u16 ld_pause; /* local */ |
| 3652 | u16 lp_pause; /* link partner */ |
| 3653 | u16 pause_result; |
| 3654 | struct bnx2x *bp = params->bp; |
| 3655 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54618SE) { |
| 3656 | bnx2x_cl22_read(bp, phy, 0x4, &ld_pause); |
| 3657 | bnx2x_cl22_read(bp, phy, 0x5, &lp_pause); |
Yaniv Rosner | ca05f29 | 2012-04-04 01:28:55 +0000 | [diff] [blame] | 3658 | } else if (CHIP_IS_E3(bp) && |
| 3659 | SINGLE_MEDIA_DIRECT(params)) { |
| 3660 | u8 lane = bnx2x_get_warpcore_lane(phy, params); |
| 3661 | u16 gp_status, gp_mask; |
| 3662 | bnx2x_cl45_read(bp, phy, |
| 3663 | MDIO_AN_DEVAD, MDIO_WC_REG_GP2_STATUS_GP_2_4, |
| 3664 | &gp_status); |
| 3665 | gp_mask = (MDIO_WC_REG_GP2_STATUS_GP_2_4_CL73_AN_CMPL | |
| 3666 | MDIO_WC_REG_GP2_STATUS_GP_2_4_CL37_LP_AN_CAP) << |
| 3667 | lane; |
| 3668 | if ((gp_status & gp_mask) == gp_mask) { |
| 3669 | bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD, |
| 3670 | MDIO_AN_REG_ADV_PAUSE, &ld_pause); |
| 3671 | bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD, |
| 3672 | MDIO_AN_REG_LP_AUTO_NEG, &lp_pause); |
| 3673 | } else { |
| 3674 | bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD, |
| 3675 | MDIO_AN_REG_CL37_FC_LD, &ld_pause); |
| 3676 | bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD, |
| 3677 | MDIO_AN_REG_CL37_FC_LP, &lp_pause); |
| 3678 | ld_pause = ((ld_pause & |
| 3679 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) |
| 3680 | << 3); |
| 3681 | lp_pause = ((lp_pause & |
| 3682 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) |
| 3683 | << 3); |
| 3684 | } |
Mintz Yuval | 9e7e839 | 2012-02-15 02:10:24 +0000 | [diff] [blame] | 3685 | } else { |
| 3686 | bnx2x_cl45_read(bp, phy, |
| 3687 | MDIO_AN_DEVAD, |
| 3688 | MDIO_AN_REG_ADV_PAUSE, &ld_pause); |
| 3689 | bnx2x_cl45_read(bp, phy, |
| 3690 | MDIO_AN_DEVAD, |
| 3691 | MDIO_AN_REG_LP_AUTO_NEG, &lp_pause); |
| 3692 | } |
| 3693 | pause_result = (ld_pause & |
| 3694 | MDIO_AN_REG_ADV_PAUSE_MASK) >> 8; |
| 3695 | pause_result |= (lp_pause & |
| 3696 | MDIO_AN_REG_ADV_PAUSE_MASK) >> 10; |
| 3697 | DP(NETIF_MSG_LINK, "Ext PHY pause result 0x%x\n", pause_result); |
| 3698 | bnx2x_pause_resolve(vars, pause_result); |
| 3699 | |
| 3700 | } |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 3701 | static u8 bnx2x_ext_phy_resolve_fc(struct bnx2x_phy *phy, |
| 3702 | struct link_params *params, |
| 3703 | struct link_vars *vars) |
| 3704 | { |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 3705 | u8 ret = 0; |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 3706 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
Mintz Yuval | 9e7e839 | 2012-02-15 02:10:24 +0000 | [diff] [blame] | 3707 | if (phy->req_flow_ctrl != BNX2X_FLOW_CTRL_AUTO) { |
| 3708 | /* Update the advertised flow-controled of LD/LP in AN */ |
| 3709 | if (phy->req_line_speed == SPEED_AUTO_NEG) |
| 3710 | bnx2x_ext_phy_update_adv_fc(phy, params, vars); |
| 3711 | /* But set the flow-control result as the requested one */ |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 3712 | vars->flow_ctrl = phy->req_flow_ctrl; |
Mintz Yuval | 9e7e839 | 2012-02-15 02:10:24 +0000 | [diff] [blame] | 3713 | } else if (phy->req_line_speed != SPEED_AUTO_NEG) |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 3714 | vars->flow_ctrl = params->req_fc_auto_adv; |
| 3715 | else if (vars->link_status & LINK_STATUS_AUTO_NEGOTIATE_COMPLETE) { |
| 3716 | ret = 1; |
Mintz Yuval | 9e7e839 | 2012-02-15 02:10:24 +0000 | [diff] [blame] | 3717 | bnx2x_ext_phy_update_adv_fc(phy, params, vars); |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 3718 | } |
| 3719 | return ret; |
| 3720 | } |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 3721 | /******************************************************************/ |
| 3722 | /* Warpcore section */ |
| 3723 | /******************************************************************/ |
| 3724 | /* The init_internal_warpcore should mirror the xgxs, |
| 3725 | * i.e. reset the lane (if needed), set aer for the |
| 3726 | * init configuration, and set/clear SGMII flag. Internal |
| 3727 | * phy init is done purely in phy_init stage. |
| 3728 | */ |
| 3729 | static void bnx2x_warpcore_enable_AN_KR(struct bnx2x_phy *phy, |
| 3730 | struct link_params *params, |
| 3731 | struct link_vars *vars) { |
Yaniv Rosner | a34bc96 | 2011-07-05 01:06:41 +0000 | [diff] [blame] | 3732 | u16 val16 = 0, lane, bam37 = 0; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 3733 | struct bnx2x *bp = params->bp; |
| 3734 | DP(NETIF_MSG_LINK, "Enable Auto Negotiation for KR\n"); |
Yaniv Rosner | 6a51c0d | 2012-04-04 01:28:56 +0000 | [diff] [blame] | 3735 | /* Set to default registers that may be overriden by 10G force */ |
| 3736 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3737 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2, 0x7); |
| 3738 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, |
| 3739 | MDIO_WC_REG_PAR_DET_10G_CTRL, 0); |
| 3740 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3741 | MDIO_WC_REG_CL72_USERB0_CL72_MISC1_CONTROL, 0); |
| 3742 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3743 | MDIO_WC_REG_XGXSBLK1_LANECTRL0, 0xff); |
| 3744 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3745 | MDIO_WC_REG_XGXSBLK1_LANECTRL1, 0x5555); |
| 3746 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, |
| 3747 | MDIO_WC_REG_IEEE0BLK_AUTONEGNP, 0x0); |
| 3748 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3749 | MDIO_WC_REG_RX66_CONTROL, 0x7415); |
| 3750 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3751 | MDIO_WC_REG_SERDESDIGITAL_MISC2, 0x6190); |
Yaniv Rosner | a9077bf | 2011-10-27 05:09:46 +0000 | [diff] [blame] | 3752 | /* Disable Autoneg: re-enable it after adv is done. */ |
| 3753 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, |
| 3754 | MDIO_WC_REG_IEEE0BLK_MIICNTL, 0); |
| 3755 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 3756 | /* Check adding advertisement for 1G KX */ |
| 3757 | if (((vars->line_speed == SPEED_AUTO_NEG) && |
| 3758 | (phy->speed_cap_mask & PORT_HW_CFG_SPEED_CAPABILITY_D0_1G)) || |
| 3759 | (vars->line_speed == SPEED_1000)) { |
| 3760 | u16 sd_digital; |
| 3761 | val16 |= (1<<5); |
| 3762 | |
| 3763 | /* Enable CL37 1G Parallel Detect */ |
| 3764 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 3765 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2, &sd_digital); |
| 3766 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3767 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2, |
| 3768 | (sd_digital | 0x1)); |
| 3769 | |
| 3770 | DP(NETIF_MSG_LINK, "Advertize 1G\n"); |
| 3771 | } |
| 3772 | if (((vars->line_speed == SPEED_AUTO_NEG) && |
| 3773 | (phy->speed_cap_mask & PORT_HW_CFG_SPEED_CAPABILITY_D0_10G)) || |
| 3774 | (vars->line_speed == SPEED_10000)) { |
| 3775 | /* Check adding advertisement for 10G KR */ |
| 3776 | val16 |= (1<<7); |
| 3777 | /* Enable 10G Parallel Detect */ |
| 3778 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, |
| 3779 | MDIO_WC_REG_PAR_DET_10G_CTRL, 1); |
| 3780 | |
| 3781 | DP(NETIF_MSG_LINK, "Advertize 10G\n"); |
| 3782 | } |
| 3783 | |
| 3784 | /* Set Transmit PMD settings */ |
| 3785 | lane = bnx2x_get_warpcore_lane(phy, params); |
| 3786 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3787 | MDIO_WC_REG_TX0_TX_DRIVER + 0x10*lane, |
| 3788 | ((0x02 << MDIO_WC_REG_TX0_TX_DRIVER_POST2_COEFF_OFFSET) | |
| 3789 | (0x06 << MDIO_WC_REG_TX0_TX_DRIVER_IDRIVER_OFFSET) | |
| 3790 | (0x09 << MDIO_WC_REG_TX0_TX_DRIVER_IPRE_DRIVER_OFFSET))); |
| 3791 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3792 | MDIO_WC_REG_CL72_USERB0_CL72_OS_DEF_CTRL, |
| 3793 | 0x03f0); |
| 3794 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3795 | MDIO_WC_REG_CL72_USERB0_CL72_2P5_DEF_CTRL, |
| 3796 | 0x03f0); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 3797 | |
| 3798 | /* Advertised speeds */ |
| 3799 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, |
| 3800 | MDIO_WC_REG_AN_IEEE1BLK_AN_ADVERTISEMENT1, val16); |
| 3801 | |
David S. Miller | 8decf86 | 2011-09-22 03:23:13 -0400 | [diff] [blame] | 3802 | /* Advertised and set FEC (Forward Error Correction) */ |
| 3803 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, |
| 3804 | MDIO_WC_REG_AN_IEEE1BLK_AN_ADVERTISEMENT2, |
| 3805 | (MDIO_WC_REG_AN_IEEE1BLK_AN_ADV2_FEC_ABILITY | |
| 3806 | MDIO_WC_REG_AN_IEEE1BLK_AN_ADV2_FEC_REQ)); |
| 3807 | |
Yaniv Rosner | a34bc96 | 2011-07-05 01:06:41 +0000 | [diff] [blame] | 3808 | /* Enable CL37 BAM */ |
| 3809 | if (REG_RD(bp, params->shmem_base + |
| 3810 | offsetof(struct shmem_region, dev_info. |
| 3811 | port_hw_config[params->port].default_cfg)) & |
| 3812 | PORT_HW_CFG_ENABLE_BAM_ON_KR_ENABLED) { |
| 3813 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 3814 | MDIO_WC_REG_DIGITAL6_MP5_NEXTPAGECTRL, &bam37); |
| 3815 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3816 | MDIO_WC_REG_DIGITAL6_MP5_NEXTPAGECTRL, bam37 | 1); |
| 3817 | DP(NETIF_MSG_LINK, "Enable CL37 BAM on KR\n"); |
| 3818 | } |
| 3819 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 3820 | /* Advertise pause */ |
| 3821 | bnx2x_ext_phy_set_pause(params, phy, vars); |
| 3822 | |
Yaniv Rosner | 6ab48a5 | 2012-01-17 02:33:29 +0000 | [diff] [blame] | 3823 | /* |
| 3824 | * Set KR Autoneg Work-Around flag for Warpcore version older than D108 |
| 3825 | */ |
| 3826 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 3827 | MDIO_WC_REG_UC_INFO_B1_VERSION, &val16); |
| 3828 | if (val16 < 0xd108) { |
| 3829 | DP(NETIF_MSG_LINK, "Enable AN KR work-around\n"); |
| 3830 | vars->rx_tx_asic_rst = MAX_KR_LINK_RETRY; |
| 3831 | } |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 3832 | |
| 3833 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 3834 | MDIO_WC_REG_DIGITAL5_MISC7, &val16); |
| 3835 | |
| 3836 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3837 | MDIO_WC_REG_DIGITAL5_MISC7, val16 | 0x100); |
Yaniv Rosner | a9077bf | 2011-10-27 05:09:46 +0000 | [diff] [blame] | 3838 | |
| 3839 | /* Over 1G - AN local device user page 1 */ |
| 3840 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3841 | MDIO_WC_REG_DIGITAL3_UP1, 0x1f); |
| 3842 | |
| 3843 | /* Enable Autoneg */ |
| 3844 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, |
Mintz Yuval | 1b85ae5 | 2012-02-15 02:10:25 +0000 | [diff] [blame] | 3845 | MDIO_WC_REG_IEEE0BLK_MIICNTL, 0x1200); |
Yaniv Rosner | a9077bf | 2011-10-27 05:09:46 +0000 | [diff] [blame] | 3846 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 3847 | } |
| 3848 | |
| 3849 | static void bnx2x_warpcore_set_10G_KR(struct bnx2x_phy *phy, |
| 3850 | struct link_params *params, |
| 3851 | struct link_vars *vars) |
| 3852 | { |
| 3853 | struct bnx2x *bp = params->bp; |
| 3854 | u16 val; |
| 3855 | |
| 3856 | /* Disable Autoneg */ |
| 3857 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3858 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2, 0x7); |
| 3859 | |
| 3860 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, |
| 3861 | MDIO_WC_REG_PAR_DET_10G_CTRL, 0); |
| 3862 | |
| 3863 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3864 | MDIO_WC_REG_CL72_USERB0_CL72_MISC1_CONTROL, 0x3f00); |
| 3865 | |
| 3866 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, |
| 3867 | MDIO_WC_REG_AN_IEEE1BLK_AN_ADVERTISEMENT1, 0); |
| 3868 | |
| 3869 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, |
| 3870 | MDIO_WC_REG_IEEE0BLK_MIICNTL, 0x0); |
| 3871 | |
| 3872 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3873 | MDIO_WC_REG_DIGITAL3_UP1, 0x1); |
| 3874 | |
| 3875 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3876 | MDIO_WC_REG_DIGITAL5_MISC7, 0xa); |
| 3877 | |
| 3878 | /* Disable CL36 PCS Tx */ |
| 3879 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3880 | MDIO_WC_REG_XGXSBLK1_LANECTRL0, 0x0); |
| 3881 | |
| 3882 | /* Double Wide Single Data Rate @ pll rate */ |
| 3883 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3884 | MDIO_WC_REG_XGXSBLK1_LANECTRL1, 0xFFFF); |
| 3885 | |
| 3886 | /* Leave cl72 training enable, needed for KR */ |
| 3887 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, |
| 3888 | MDIO_WC_REG_PMD_IEEE9BLK_TENGBASE_KR_PMD_CONTROL_REGISTER_150, |
| 3889 | 0x2); |
| 3890 | |
| 3891 | /* Leave CL72 enabled */ |
| 3892 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 3893 | MDIO_WC_REG_CL72_USERB0_CL72_MISC1_CONTROL, |
| 3894 | &val); |
| 3895 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3896 | MDIO_WC_REG_CL72_USERB0_CL72_MISC1_CONTROL, |
| 3897 | val | 0x3800); |
| 3898 | |
| 3899 | /* Set speed via PMA/PMD register */ |
| 3900 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, |
| 3901 | MDIO_WC_REG_IEEE0BLK_MIICNTL, 0x2040); |
| 3902 | |
| 3903 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, |
| 3904 | MDIO_WC_REG_IEEE0BLK_AUTONEGNP, 0xB); |
| 3905 | |
| 3906 | /*Enable encoded forced speed */ |
| 3907 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3908 | MDIO_WC_REG_SERDESDIGITAL_MISC2, 0x30); |
| 3909 | |
| 3910 | /* Turn TX scramble payload only the 64/66 scrambler */ |
| 3911 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3912 | MDIO_WC_REG_TX66_CONTROL, 0x9); |
| 3913 | |
| 3914 | /* Turn RX scramble payload only the 64/66 scrambler */ |
| 3915 | bnx2x_cl45_read_or_write(bp, phy, MDIO_WC_DEVAD, |
| 3916 | MDIO_WC_REG_RX66_CONTROL, 0xF9); |
| 3917 | |
| 3918 | /* set and clear loopback to cause a reset to 64/66 decoder */ |
| 3919 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3920 | MDIO_WC_REG_IEEE0BLK_MIICNTL, 0x4000); |
| 3921 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3922 | MDIO_WC_REG_IEEE0BLK_MIICNTL, 0x0); |
| 3923 | |
| 3924 | } |
| 3925 | |
| 3926 | static void bnx2x_warpcore_set_10G_XFI(struct bnx2x_phy *phy, |
| 3927 | struct link_params *params, |
| 3928 | u8 is_xfi) |
| 3929 | { |
| 3930 | struct bnx2x *bp = params->bp; |
| 3931 | u16 misc1_val, tap_val, tx_driver_val, lane, val; |
| 3932 | /* Hold rxSeqStart */ |
| 3933 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 3934 | MDIO_WC_REG_DSC2B0_DSC_MISC_CTRL0, &val); |
| 3935 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3936 | MDIO_WC_REG_DSC2B0_DSC_MISC_CTRL0, (val | 0x8000)); |
| 3937 | |
| 3938 | /* Hold tx_fifo_reset */ |
| 3939 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 3940 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X3, &val); |
| 3941 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3942 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X3, (val | 0x1)); |
| 3943 | |
| 3944 | /* Disable CL73 AN */ |
| 3945 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, 0); |
| 3946 | |
| 3947 | /* Disable 100FX Enable and Auto-Detect */ |
| 3948 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 3949 | MDIO_WC_REG_FX100_CTRL1, &val); |
| 3950 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3951 | MDIO_WC_REG_FX100_CTRL1, (val & 0xFFFA)); |
| 3952 | |
| 3953 | /* Disable 100FX Idle detect */ |
| 3954 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 3955 | MDIO_WC_REG_FX100_CTRL3, &val); |
| 3956 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3957 | MDIO_WC_REG_FX100_CTRL3, (val | 0x0080)); |
| 3958 | |
| 3959 | /* Set Block address to Remote PHY & Clear forced_speed[5] */ |
| 3960 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 3961 | MDIO_WC_REG_DIGITAL4_MISC3, &val); |
| 3962 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3963 | MDIO_WC_REG_DIGITAL4_MISC3, (val & 0xFF7F)); |
| 3964 | |
| 3965 | /* Turn off auto-detect & fiber mode */ |
| 3966 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 3967 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X1, &val); |
| 3968 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3969 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X1, |
| 3970 | (val & 0xFFEE)); |
| 3971 | |
| 3972 | /* Set filter_force_link, disable_false_link and parallel_detect */ |
| 3973 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 3974 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2, &val); |
| 3975 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 3976 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2, |
| 3977 | ((val | 0x0006) & 0xFFFE)); |
| 3978 | |
| 3979 | /* Set XFI / SFI */ |
| 3980 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 3981 | MDIO_WC_REG_SERDESDIGITAL_MISC1, &misc1_val); |
| 3982 | |
| 3983 | misc1_val &= ~(0x1f); |
| 3984 | |
| 3985 | if (is_xfi) { |
| 3986 | misc1_val |= 0x5; |
| 3987 | tap_val = ((0x08 << MDIO_WC_REG_TX_FIR_TAP_POST_TAP_OFFSET) | |
| 3988 | (0x37 << MDIO_WC_REG_TX_FIR_TAP_MAIN_TAP_OFFSET) | |
| 3989 | (0x00 << MDIO_WC_REG_TX_FIR_TAP_PRE_TAP_OFFSET)); |
| 3990 | tx_driver_val = |
| 3991 | ((0x00 << MDIO_WC_REG_TX0_TX_DRIVER_POST2_COEFF_OFFSET) | |
| 3992 | (0x02 << MDIO_WC_REG_TX0_TX_DRIVER_IDRIVER_OFFSET) | |
| 3993 | (0x03 << MDIO_WC_REG_TX0_TX_DRIVER_IPRE_DRIVER_OFFSET)); |
| 3994 | |
| 3995 | } else { |
| 3996 | misc1_val |= 0x9; |
Yaniv Rosner | 25182fc | 2012-04-04 01:28:57 +0000 | [diff] [blame] | 3997 | tap_val = ((0x0f << MDIO_WC_REG_TX_FIR_TAP_POST_TAP_OFFSET) | |
| 3998 | (0x2b << MDIO_WC_REG_TX_FIR_TAP_MAIN_TAP_OFFSET) | |
| 3999 | (0x02 << MDIO_WC_REG_TX_FIR_TAP_PRE_TAP_OFFSET)); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4000 | tx_driver_val = |
Yaniv Rosner | 25182fc | 2012-04-04 01:28:57 +0000 | [diff] [blame] | 4001 | ((0x03 << MDIO_WC_REG_TX0_TX_DRIVER_POST2_COEFF_OFFSET) | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4002 | (0x02 << MDIO_WC_REG_TX0_TX_DRIVER_IDRIVER_OFFSET) | |
Yaniv Rosner | 25182fc | 2012-04-04 01:28:57 +0000 | [diff] [blame] | 4003 | (0x06 << MDIO_WC_REG_TX0_TX_DRIVER_IPRE_DRIVER_OFFSET)); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4004 | } |
| 4005 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4006 | MDIO_WC_REG_SERDESDIGITAL_MISC1, misc1_val); |
| 4007 | |
| 4008 | /* Set Transmit PMD settings */ |
| 4009 | lane = bnx2x_get_warpcore_lane(phy, params); |
| 4010 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4011 | MDIO_WC_REG_TX_FIR_TAP, |
| 4012 | tap_val | MDIO_WC_REG_TX_FIR_TAP_ENABLE); |
| 4013 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4014 | MDIO_WC_REG_TX0_TX_DRIVER + 0x10*lane, |
| 4015 | tx_driver_val); |
| 4016 | |
| 4017 | /* Enable fiber mode, enable and invert sig_det */ |
| 4018 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4019 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X1, &val); |
| 4020 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4021 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X1, val | 0xd); |
| 4022 | |
| 4023 | /* Set Block address to Remote PHY & Set forced_speed[5], 40bit mode */ |
| 4024 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4025 | MDIO_WC_REG_DIGITAL4_MISC3, &val); |
| 4026 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4027 | MDIO_WC_REG_DIGITAL4_MISC3, val | 0x8080); |
| 4028 | |
| 4029 | /* 10G XFI Full Duplex */ |
| 4030 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4031 | MDIO_WC_REG_IEEE0BLK_MIICNTL, 0x100); |
| 4032 | |
| 4033 | /* Release tx_fifo_reset */ |
| 4034 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4035 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X3, &val); |
| 4036 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4037 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X3, val & 0xFFFE); |
| 4038 | |
| 4039 | /* Release rxSeqStart */ |
| 4040 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4041 | MDIO_WC_REG_DSC2B0_DSC_MISC_CTRL0, &val); |
| 4042 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4043 | MDIO_WC_REG_DSC2B0_DSC_MISC_CTRL0, (val & 0x7FFF)); |
| 4044 | } |
| 4045 | |
| 4046 | static void bnx2x_warpcore_set_20G_KR2(struct bnx2x *bp, |
| 4047 | struct bnx2x_phy *phy) |
| 4048 | { |
| 4049 | DP(NETIF_MSG_LINK, "KR2 still not supported !!!\n"); |
| 4050 | } |
| 4051 | |
| 4052 | static void bnx2x_warpcore_set_20G_DXGXS(struct bnx2x *bp, |
| 4053 | struct bnx2x_phy *phy, |
| 4054 | u16 lane) |
| 4055 | { |
| 4056 | /* Rx0 anaRxControl1G */ |
| 4057 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4058 | MDIO_WC_REG_RX0_ANARXCONTROL1G, 0x90); |
| 4059 | |
| 4060 | /* Rx2 anaRxControl1G */ |
| 4061 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4062 | MDIO_WC_REG_RX2_ANARXCONTROL1G, 0x90); |
| 4063 | |
| 4064 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4065 | MDIO_WC_REG_RX66_SCW0, 0xE070); |
| 4066 | |
| 4067 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4068 | MDIO_WC_REG_RX66_SCW1, 0xC0D0); |
| 4069 | |
| 4070 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4071 | MDIO_WC_REG_RX66_SCW2, 0xA0B0); |
| 4072 | |
| 4073 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4074 | MDIO_WC_REG_RX66_SCW3, 0x8090); |
| 4075 | |
| 4076 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4077 | MDIO_WC_REG_RX66_SCW0_MASK, 0xF0F0); |
| 4078 | |
| 4079 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4080 | MDIO_WC_REG_RX66_SCW1_MASK, 0xF0F0); |
| 4081 | |
| 4082 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4083 | MDIO_WC_REG_RX66_SCW2_MASK, 0xF0F0); |
| 4084 | |
| 4085 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4086 | MDIO_WC_REG_RX66_SCW3_MASK, 0xF0F0); |
| 4087 | |
| 4088 | /* Serdes Digital Misc1 */ |
| 4089 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4090 | MDIO_WC_REG_SERDESDIGITAL_MISC1, 0x6008); |
| 4091 | |
| 4092 | /* Serdes Digital4 Misc3 */ |
| 4093 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4094 | MDIO_WC_REG_DIGITAL4_MISC3, 0x8088); |
| 4095 | |
| 4096 | /* Set Transmit PMD settings */ |
| 4097 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4098 | MDIO_WC_REG_TX_FIR_TAP, |
| 4099 | ((0x12 << MDIO_WC_REG_TX_FIR_TAP_POST_TAP_OFFSET) | |
| 4100 | (0x2d << MDIO_WC_REG_TX_FIR_TAP_MAIN_TAP_OFFSET) | |
| 4101 | (0x00 << MDIO_WC_REG_TX_FIR_TAP_PRE_TAP_OFFSET) | |
| 4102 | MDIO_WC_REG_TX_FIR_TAP_ENABLE)); |
| 4103 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4104 | MDIO_WC_REG_TX0_TX_DRIVER + 0x10*lane, |
| 4105 | ((0x02 << MDIO_WC_REG_TX0_TX_DRIVER_POST2_COEFF_OFFSET) | |
| 4106 | (0x02 << MDIO_WC_REG_TX0_TX_DRIVER_IDRIVER_OFFSET) | |
| 4107 | (0x02 << MDIO_WC_REG_TX0_TX_DRIVER_IPRE_DRIVER_OFFSET))); |
| 4108 | } |
| 4109 | |
| 4110 | static void bnx2x_warpcore_set_sgmii_speed(struct bnx2x_phy *phy, |
| 4111 | struct link_params *params, |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 4112 | u8 fiber_mode, |
| 4113 | u8 always_autoneg) |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4114 | { |
| 4115 | struct bnx2x *bp = params->bp; |
| 4116 | u16 val16, digctrl_kx1, digctrl_kx2; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4117 | |
| 4118 | /* Clear XFI clock comp in non-10G single lane mode. */ |
| 4119 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4120 | MDIO_WC_REG_RX66_CONTROL, &val16); |
| 4121 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4122 | MDIO_WC_REG_RX66_CONTROL, val16 & ~(3<<13)); |
| 4123 | |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 4124 | if (always_autoneg || phy->req_line_speed == SPEED_AUTO_NEG) { |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4125 | /* SGMII Autoneg */ |
| 4126 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4127 | MDIO_WC_REG_COMBO_IEEE0_MIICTRL, &val16); |
| 4128 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4129 | MDIO_WC_REG_COMBO_IEEE0_MIICTRL, |
| 4130 | val16 | 0x1000); |
| 4131 | DP(NETIF_MSG_LINK, "set SGMII AUTONEG\n"); |
| 4132 | } else { |
| 4133 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4134 | MDIO_WC_REG_COMBO_IEEE0_MIICTRL, &val16); |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 4135 | val16 &= 0xcebf; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4136 | switch (phy->req_line_speed) { |
| 4137 | case SPEED_10: |
| 4138 | break; |
| 4139 | case SPEED_100: |
| 4140 | val16 |= 0x2000; |
| 4141 | break; |
| 4142 | case SPEED_1000: |
| 4143 | val16 |= 0x0040; |
| 4144 | break; |
| 4145 | default: |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 4146 | DP(NETIF_MSG_LINK, |
| 4147 | "Speed not supported: 0x%x\n", phy->req_line_speed); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4148 | return; |
| 4149 | } |
| 4150 | |
| 4151 | if (phy->req_duplex == DUPLEX_FULL) |
| 4152 | val16 |= 0x0100; |
| 4153 | |
| 4154 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4155 | MDIO_WC_REG_COMBO_IEEE0_MIICTRL, val16); |
| 4156 | |
| 4157 | DP(NETIF_MSG_LINK, "set SGMII force speed %d\n", |
| 4158 | phy->req_line_speed); |
| 4159 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4160 | MDIO_WC_REG_COMBO_IEEE0_MIICTRL, &val16); |
| 4161 | DP(NETIF_MSG_LINK, " (readback) %x\n", val16); |
| 4162 | } |
| 4163 | |
| 4164 | /* SGMII Slave mode and disable signal detect */ |
| 4165 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4166 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X1, &digctrl_kx1); |
| 4167 | if (fiber_mode) |
| 4168 | digctrl_kx1 = 1; |
| 4169 | else |
| 4170 | digctrl_kx1 &= 0xff4a; |
| 4171 | |
| 4172 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4173 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X1, |
| 4174 | digctrl_kx1); |
| 4175 | |
| 4176 | /* Turn off parallel detect */ |
| 4177 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4178 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2, &digctrl_kx2); |
| 4179 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4180 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2, |
| 4181 | (digctrl_kx2 & ~(1<<2))); |
| 4182 | |
| 4183 | /* Re-enable parallel detect */ |
| 4184 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4185 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2, |
| 4186 | (digctrl_kx2 | (1<<2))); |
| 4187 | |
| 4188 | /* Enable autodet */ |
| 4189 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4190 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X1, |
| 4191 | (digctrl_kx1 | 0x10)); |
| 4192 | } |
| 4193 | |
| 4194 | static void bnx2x_warpcore_reset_lane(struct bnx2x *bp, |
| 4195 | struct bnx2x_phy *phy, |
| 4196 | u8 reset) |
| 4197 | { |
| 4198 | u16 val; |
| 4199 | /* Take lane out of reset after configuration is finished */ |
| 4200 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4201 | MDIO_WC_REG_DIGITAL5_MISC6, &val); |
| 4202 | if (reset) |
| 4203 | val |= 0xC000; |
| 4204 | else |
| 4205 | val &= 0x3FFF; |
| 4206 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4207 | MDIO_WC_REG_DIGITAL5_MISC6, val); |
| 4208 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4209 | MDIO_WC_REG_DIGITAL5_MISC6, &val); |
| 4210 | } |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 4211 | /* Clear SFI/XFI link settings registers */ |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4212 | static void bnx2x_warpcore_clear_regs(struct bnx2x_phy *phy, |
| 4213 | struct link_params *params, |
| 4214 | u16 lane) |
| 4215 | { |
| 4216 | struct bnx2x *bp = params->bp; |
| 4217 | u16 val16; |
| 4218 | |
| 4219 | /* Set XFI clock comp as default. */ |
| 4220 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4221 | MDIO_WC_REG_RX66_CONTROL, &val16); |
| 4222 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4223 | MDIO_WC_REG_RX66_CONTROL, val16 | (3<<13)); |
| 4224 | |
| 4225 | bnx2x_warpcore_reset_lane(bp, phy, 1); |
| 4226 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, 0); |
| 4227 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4228 | MDIO_WC_REG_FX100_CTRL1, 0x014a); |
| 4229 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4230 | MDIO_WC_REG_FX100_CTRL3, 0x0800); |
| 4231 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4232 | MDIO_WC_REG_DIGITAL4_MISC3, 0x8008); |
| 4233 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4234 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X1, 0x0195); |
| 4235 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4236 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2, 0x0007); |
| 4237 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4238 | MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X3, 0x0002); |
| 4239 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4240 | MDIO_WC_REG_SERDESDIGITAL_MISC1, 0x6000); |
| 4241 | lane = bnx2x_get_warpcore_lane(phy, params); |
| 4242 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4243 | MDIO_WC_REG_TX_FIR_TAP, 0x0000); |
| 4244 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4245 | MDIO_WC_REG_TX0_TX_DRIVER + 0x10*lane, 0x0990); |
| 4246 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4247 | MDIO_WC_REG_IEEE0BLK_MIICNTL, 0x2040); |
| 4248 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4249 | MDIO_WC_REG_COMBO_IEEE0_MIICTRL, 0x0140); |
| 4250 | bnx2x_warpcore_reset_lane(bp, phy, 0); |
| 4251 | } |
| 4252 | |
| 4253 | static int bnx2x_get_mod_abs_int_cfg(struct bnx2x *bp, |
| 4254 | u32 chip_id, |
| 4255 | u32 shmem_base, u8 port, |
| 4256 | u8 *gpio_num, u8 *gpio_port) |
| 4257 | { |
| 4258 | u32 cfg_pin; |
| 4259 | *gpio_num = 0; |
| 4260 | *gpio_port = 0; |
| 4261 | if (CHIP_IS_E3(bp)) { |
| 4262 | cfg_pin = (REG_RD(bp, shmem_base + |
| 4263 | offsetof(struct shmem_region, |
| 4264 | dev_info.port_hw_config[port].e3_sfp_ctrl)) & |
| 4265 | PORT_HW_CFG_E3_MOD_ABS_MASK) >> |
| 4266 | PORT_HW_CFG_E3_MOD_ABS_SHIFT; |
| 4267 | |
| 4268 | /* |
| 4269 | * Should not happen. This function called upon interrupt |
| 4270 | * triggered by GPIO ( since EPIO can only generate interrupts |
| 4271 | * to MCP). |
| 4272 | * So if this function was called and none of the GPIOs was set, |
| 4273 | * it means the shit hit the fan. |
| 4274 | */ |
| 4275 | if ((cfg_pin < PIN_CFG_GPIO0_P0) || |
| 4276 | (cfg_pin > PIN_CFG_GPIO3_P1)) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 4277 | DP(NETIF_MSG_LINK, |
| 4278 | "ERROR: Invalid cfg pin %x for module detect indication\n", |
| 4279 | cfg_pin); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4280 | return -EINVAL; |
| 4281 | } |
| 4282 | |
| 4283 | *gpio_num = (cfg_pin - PIN_CFG_GPIO0_P0) & 0x3; |
| 4284 | *gpio_port = (cfg_pin - PIN_CFG_GPIO0_P0) >> 2; |
| 4285 | } else { |
| 4286 | *gpio_num = MISC_REGISTERS_GPIO_3; |
| 4287 | *gpio_port = port; |
| 4288 | } |
| 4289 | DP(NETIF_MSG_LINK, "MOD_ABS int GPIO%d_P%d\n", *gpio_num, *gpio_port); |
| 4290 | return 0; |
| 4291 | } |
| 4292 | |
| 4293 | static int bnx2x_is_sfp_module_plugged(struct bnx2x_phy *phy, |
| 4294 | struct link_params *params) |
| 4295 | { |
| 4296 | struct bnx2x *bp = params->bp; |
| 4297 | u8 gpio_num, gpio_port; |
| 4298 | u32 gpio_val; |
| 4299 | if (bnx2x_get_mod_abs_int_cfg(bp, params->chip_id, |
| 4300 | params->shmem_base, params->port, |
| 4301 | &gpio_num, &gpio_port) != 0) |
| 4302 | return 0; |
| 4303 | gpio_val = bnx2x_get_gpio(bp, gpio_num, gpio_port); |
| 4304 | |
| 4305 | /* Call the handling function in case module is detected */ |
| 4306 | if (gpio_val == 0) |
| 4307 | return 1; |
| 4308 | else |
| 4309 | return 0; |
| 4310 | } |
Yaniv Rosner | a9077bf | 2011-10-27 05:09:46 +0000 | [diff] [blame] | 4311 | static int bnx2x_warpcore_get_sigdet(struct bnx2x_phy *phy, |
| 4312 | struct link_params *params) |
| 4313 | { |
| 4314 | u16 gp2_status_reg0, lane; |
| 4315 | struct bnx2x *bp = params->bp; |
| 4316 | |
| 4317 | lane = bnx2x_get_warpcore_lane(phy, params); |
| 4318 | |
| 4319 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, MDIO_WC_REG_GP2_STATUS_GP_2_0, |
| 4320 | &gp2_status_reg0); |
| 4321 | |
| 4322 | return (gp2_status_reg0 >> (8+lane)) & 0x1; |
| 4323 | } |
| 4324 | |
| 4325 | static void bnx2x_warpcore_config_runtime(struct bnx2x_phy *phy, |
| 4326 | struct link_params *params, |
| 4327 | struct link_vars *vars) |
| 4328 | { |
| 4329 | struct bnx2x *bp = params->bp; |
| 4330 | u32 serdes_net_if; |
| 4331 | u16 gp_status1 = 0, lnkup = 0, lnkup_kr = 0; |
| 4332 | u16 lane = bnx2x_get_warpcore_lane(phy, params); |
| 4333 | |
| 4334 | vars->turn_to_run_wc_rt = vars->turn_to_run_wc_rt ? 0 : 1; |
| 4335 | |
| 4336 | if (!vars->turn_to_run_wc_rt) |
| 4337 | return; |
| 4338 | |
| 4339 | /* return if there is no link partner */ |
| 4340 | if (!(bnx2x_warpcore_get_sigdet(phy, params))) { |
| 4341 | DP(NETIF_MSG_LINK, "bnx2x_warpcore_get_sigdet false\n"); |
| 4342 | return; |
| 4343 | } |
| 4344 | |
| 4345 | if (vars->rx_tx_asic_rst) { |
| 4346 | serdes_net_if = (REG_RD(bp, params->shmem_base + |
| 4347 | offsetof(struct shmem_region, dev_info. |
| 4348 | port_hw_config[params->port].default_cfg)) & |
| 4349 | PORT_HW_CFG_NET_SERDES_IF_MASK); |
| 4350 | |
| 4351 | switch (serdes_net_if) { |
| 4352 | case PORT_HW_CFG_NET_SERDES_IF_KR: |
| 4353 | /* Do we get link yet? */ |
| 4354 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, 0x81d1, |
| 4355 | &gp_status1); |
| 4356 | lnkup = (gp_status1 >> (8+lane)) & 0x1;/* 1G */ |
| 4357 | /*10G KR*/ |
| 4358 | lnkup_kr = (gp_status1 >> (12+lane)) & 0x1; |
| 4359 | |
| 4360 | DP(NETIF_MSG_LINK, |
| 4361 | "gp_status1 0x%x\n", gp_status1); |
| 4362 | |
| 4363 | if (lnkup_kr || lnkup) { |
| 4364 | vars->rx_tx_asic_rst = 0; |
| 4365 | DP(NETIF_MSG_LINK, |
| 4366 | "link up, rx_tx_asic_rst 0x%x\n", |
| 4367 | vars->rx_tx_asic_rst); |
| 4368 | } else { |
| 4369 | /*reset the lane to see if link comes up.*/ |
| 4370 | bnx2x_warpcore_reset_lane(bp, phy, 1); |
| 4371 | bnx2x_warpcore_reset_lane(bp, phy, 0); |
| 4372 | |
| 4373 | /* restart Autoneg */ |
| 4374 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, |
| 4375 | MDIO_WC_REG_IEEE0BLK_MIICNTL, 0x1200); |
| 4376 | |
| 4377 | vars->rx_tx_asic_rst--; |
| 4378 | DP(NETIF_MSG_LINK, "0x%x retry left\n", |
| 4379 | vars->rx_tx_asic_rst); |
| 4380 | } |
| 4381 | break; |
| 4382 | |
| 4383 | default: |
| 4384 | break; |
| 4385 | } |
| 4386 | |
| 4387 | } /*params->rx_tx_asic_rst*/ |
| 4388 | |
| 4389 | } |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4390 | |
| 4391 | static void bnx2x_warpcore_config_init(struct bnx2x_phy *phy, |
| 4392 | struct link_params *params, |
| 4393 | struct link_vars *vars) |
| 4394 | { |
| 4395 | struct bnx2x *bp = params->bp; |
| 4396 | u32 serdes_net_if; |
| 4397 | u8 fiber_mode; |
| 4398 | u16 lane = bnx2x_get_warpcore_lane(phy, params); |
| 4399 | serdes_net_if = (REG_RD(bp, params->shmem_base + |
| 4400 | offsetof(struct shmem_region, dev_info. |
| 4401 | port_hw_config[params->port].default_cfg)) & |
| 4402 | PORT_HW_CFG_NET_SERDES_IF_MASK); |
| 4403 | DP(NETIF_MSG_LINK, "Begin Warpcore init, link_speed %d, " |
| 4404 | "serdes_net_if = 0x%x\n", |
| 4405 | vars->line_speed, serdes_net_if); |
| 4406 | bnx2x_set_aer_mmd(params, phy); |
| 4407 | |
| 4408 | vars->phy_flags |= PHY_XGXS_FLAG; |
| 4409 | if ((serdes_net_if == PORT_HW_CFG_NET_SERDES_IF_SGMII) || |
| 4410 | (phy->req_line_speed && |
| 4411 | ((phy->req_line_speed == SPEED_100) || |
| 4412 | (phy->req_line_speed == SPEED_10)))) { |
| 4413 | vars->phy_flags |= PHY_SGMII_FLAG; |
| 4414 | DP(NETIF_MSG_LINK, "Setting SGMII mode\n"); |
| 4415 | bnx2x_warpcore_clear_regs(phy, params, lane); |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 4416 | bnx2x_warpcore_set_sgmii_speed(phy, params, 0, 1); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4417 | } else { |
| 4418 | switch (serdes_net_if) { |
| 4419 | case PORT_HW_CFG_NET_SERDES_IF_KR: |
| 4420 | /* Enable KR Auto Neg */ |
Yaniv Rosner | 6a51c0d | 2012-04-04 01:28:56 +0000 | [diff] [blame] | 4421 | if (params->loopback_mode != LOOPBACK_EXT) |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4422 | bnx2x_warpcore_enable_AN_KR(phy, params, vars); |
| 4423 | else { |
| 4424 | DP(NETIF_MSG_LINK, "Setting KR 10G-Force\n"); |
| 4425 | bnx2x_warpcore_set_10G_KR(phy, params, vars); |
| 4426 | } |
| 4427 | break; |
| 4428 | |
| 4429 | case PORT_HW_CFG_NET_SERDES_IF_XFI: |
| 4430 | bnx2x_warpcore_clear_regs(phy, params, lane); |
| 4431 | if (vars->line_speed == SPEED_10000) { |
| 4432 | DP(NETIF_MSG_LINK, "Setting 10G XFI\n"); |
| 4433 | bnx2x_warpcore_set_10G_XFI(phy, params, 1); |
| 4434 | } else { |
| 4435 | if (SINGLE_MEDIA_DIRECT(params)) { |
| 4436 | DP(NETIF_MSG_LINK, "1G Fiber\n"); |
| 4437 | fiber_mode = 1; |
| 4438 | } else { |
| 4439 | DP(NETIF_MSG_LINK, "10/100/1G SGMII\n"); |
| 4440 | fiber_mode = 0; |
| 4441 | } |
| 4442 | bnx2x_warpcore_set_sgmii_speed(phy, |
| 4443 | params, |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 4444 | fiber_mode, |
| 4445 | 0); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4446 | } |
| 4447 | |
| 4448 | break; |
| 4449 | |
| 4450 | case PORT_HW_CFG_NET_SERDES_IF_SFI: |
| 4451 | |
| 4452 | bnx2x_warpcore_clear_regs(phy, params, lane); |
| 4453 | if (vars->line_speed == SPEED_10000) { |
| 4454 | DP(NETIF_MSG_LINK, "Setting 10G SFI\n"); |
| 4455 | bnx2x_warpcore_set_10G_XFI(phy, params, 0); |
| 4456 | } else if (vars->line_speed == SPEED_1000) { |
| 4457 | DP(NETIF_MSG_LINK, "Setting 1G Fiber\n"); |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 4458 | bnx2x_warpcore_set_sgmii_speed( |
| 4459 | phy, params, 1, 0); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4460 | } |
| 4461 | /* Issue Module detection */ |
| 4462 | if (bnx2x_is_sfp_module_plugged(phy, params)) |
| 4463 | bnx2x_sfp_module_detection(phy, params); |
| 4464 | break; |
| 4465 | |
| 4466 | case PORT_HW_CFG_NET_SERDES_IF_DXGXS: |
| 4467 | if (vars->line_speed != SPEED_20000) { |
| 4468 | DP(NETIF_MSG_LINK, "Speed not supported yet\n"); |
| 4469 | return; |
| 4470 | } |
| 4471 | DP(NETIF_MSG_LINK, "Setting 20G DXGXS\n"); |
| 4472 | bnx2x_warpcore_set_20G_DXGXS(bp, phy, lane); |
| 4473 | /* Issue Module detection */ |
| 4474 | |
| 4475 | bnx2x_sfp_module_detection(phy, params); |
| 4476 | break; |
| 4477 | |
| 4478 | case PORT_HW_CFG_NET_SERDES_IF_KR2: |
| 4479 | if (vars->line_speed != SPEED_20000) { |
| 4480 | DP(NETIF_MSG_LINK, "Speed not supported yet\n"); |
| 4481 | return; |
| 4482 | } |
| 4483 | DP(NETIF_MSG_LINK, "Setting 20G KR2\n"); |
| 4484 | bnx2x_warpcore_set_20G_KR2(bp, phy); |
| 4485 | break; |
| 4486 | |
| 4487 | default: |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 4488 | DP(NETIF_MSG_LINK, |
| 4489 | "Unsupported Serdes Net Interface 0x%x\n", |
| 4490 | serdes_net_if); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4491 | return; |
| 4492 | } |
| 4493 | } |
| 4494 | |
| 4495 | /* Take lane out of reset after configuration is finished */ |
| 4496 | bnx2x_warpcore_reset_lane(bp, phy, 0); |
| 4497 | DP(NETIF_MSG_LINK, "Exit config init\n"); |
| 4498 | } |
| 4499 | |
| 4500 | static void bnx2x_sfp_e3_set_transmitter(struct link_params *params, |
| 4501 | struct bnx2x_phy *phy, |
| 4502 | u8 tx_en) |
| 4503 | { |
| 4504 | struct bnx2x *bp = params->bp; |
| 4505 | u32 cfg_pin; |
| 4506 | u8 port = params->port; |
| 4507 | |
| 4508 | cfg_pin = REG_RD(bp, params->shmem_base + |
| 4509 | offsetof(struct shmem_region, |
| 4510 | dev_info.port_hw_config[port].e3_sfp_ctrl)) & |
| 4511 | PORT_HW_CFG_TX_LASER_MASK; |
| 4512 | /* Set the !tx_en since this pin is DISABLE_TX_LASER */ |
| 4513 | DP(NETIF_MSG_LINK, "Setting WC TX to %d\n", tx_en); |
| 4514 | /* For 20G, the expected pin to be used is 3 pins after the current */ |
| 4515 | |
| 4516 | bnx2x_set_cfg_pin(bp, cfg_pin, tx_en ^ 1); |
| 4517 | if (phy->speed_cap_mask & PORT_HW_CFG_SPEED_CAPABILITY_D0_20G) |
| 4518 | bnx2x_set_cfg_pin(bp, cfg_pin + 3, tx_en ^ 1); |
| 4519 | } |
| 4520 | |
| 4521 | static void bnx2x_warpcore_link_reset(struct bnx2x_phy *phy, |
| 4522 | struct link_params *params) |
| 4523 | { |
| 4524 | struct bnx2x *bp = params->bp; |
| 4525 | u16 val16; |
| 4526 | bnx2x_sfp_e3_set_transmitter(params, phy, 0); |
| 4527 | bnx2x_set_mdio_clk(bp, params->chip_id, params->port); |
| 4528 | bnx2x_set_aer_mmd(params, phy); |
| 4529 | /* Global register */ |
| 4530 | bnx2x_warpcore_reset_lane(bp, phy, 1); |
| 4531 | |
| 4532 | /* Clear loopback settings (if any) */ |
| 4533 | /* 10G & 20G */ |
| 4534 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4535 | MDIO_WC_REG_COMBO_IEEE0_MIICTRL, &val16); |
| 4536 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4537 | MDIO_WC_REG_COMBO_IEEE0_MIICTRL, val16 & |
| 4538 | 0xBFFF); |
| 4539 | |
| 4540 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4541 | MDIO_WC_REG_IEEE0BLK_MIICNTL, &val16); |
| 4542 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4543 | MDIO_WC_REG_IEEE0BLK_MIICNTL, val16 & 0xfffe); |
| 4544 | |
| 4545 | /* Update those 1-copy registers */ |
| 4546 | CL22_WR_OVER_CL45(bp, phy, MDIO_REG_BANK_AER_BLOCK, |
| 4547 | MDIO_AER_BLOCK_AER_REG, 0); |
| 4548 | /* Enable 1G MDIO (1-copy) */ |
| 4549 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4550 | MDIO_WC_REG_XGXSBLK0_XGXSCONTROL, |
| 4551 | &val16); |
| 4552 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4553 | MDIO_WC_REG_XGXSBLK0_XGXSCONTROL, |
| 4554 | val16 & ~0x10); |
| 4555 | |
| 4556 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4557 | MDIO_WC_REG_XGXSBLK1_LANECTRL2, &val16); |
| 4558 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4559 | MDIO_WC_REG_XGXSBLK1_LANECTRL2, |
| 4560 | val16 & 0xff00); |
| 4561 | |
| 4562 | } |
| 4563 | |
| 4564 | static void bnx2x_set_warpcore_loopback(struct bnx2x_phy *phy, |
| 4565 | struct link_params *params) |
| 4566 | { |
| 4567 | struct bnx2x *bp = params->bp; |
| 4568 | u16 val16; |
| 4569 | u32 lane; |
| 4570 | DP(NETIF_MSG_LINK, "Setting Warpcore loopback type %x, speed %d\n", |
| 4571 | params->loopback_mode, phy->req_line_speed); |
| 4572 | |
| 4573 | if (phy->req_line_speed < SPEED_10000) { |
| 4574 | /* 10/100/1000 */ |
| 4575 | |
| 4576 | /* Update those 1-copy registers */ |
| 4577 | CL22_WR_OVER_CL45(bp, phy, MDIO_REG_BANK_AER_BLOCK, |
| 4578 | MDIO_AER_BLOCK_AER_REG, 0); |
| 4579 | /* Enable 1G MDIO (1-copy) */ |
| 4580 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4581 | MDIO_WC_REG_XGXSBLK0_XGXSCONTROL, |
| 4582 | &val16); |
| 4583 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4584 | MDIO_WC_REG_XGXSBLK0_XGXSCONTROL, |
| 4585 | val16 | 0x10); |
| 4586 | /* Set 1G loopback based on lane (1-copy) */ |
| 4587 | lane = bnx2x_get_warpcore_lane(phy, params); |
| 4588 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4589 | MDIO_WC_REG_XGXSBLK1_LANECTRL2, &val16); |
| 4590 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4591 | MDIO_WC_REG_XGXSBLK1_LANECTRL2, |
| 4592 | val16 | (1<<lane)); |
| 4593 | |
| 4594 | /* Switch back to 4-copy registers */ |
| 4595 | bnx2x_set_aer_mmd(params, phy); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4596 | } else { |
| 4597 | /* 10G & 20G */ |
| 4598 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4599 | MDIO_WC_REG_COMBO_IEEE0_MIICTRL, &val16); |
| 4600 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4601 | MDIO_WC_REG_COMBO_IEEE0_MIICTRL, val16 | |
| 4602 | 0x4000); |
| 4603 | |
| 4604 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 4605 | MDIO_WC_REG_IEEE0BLK_MIICNTL, &val16); |
| 4606 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 4607 | MDIO_WC_REG_IEEE0BLK_MIICNTL, val16 | 0x1); |
| 4608 | } |
| 4609 | } |
| 4610 | |
| 4611 | |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 4612 | void bnx2x_sync_link(struct link_params *params, |
| 4613 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4614 | { |
| 4615 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 4616 | u8 link_10g_plus; |
Yaniv Rosner | de6f337 | 2011-08-02 22:59:25 +0000 | [diff] [blame] | 4617 | if (vars->link_status & LINK_STATUS_PHYSICAL_LINK_FLAG) |
| 4618 | vars->phy_flags |= PHY_PHYSICAL_LINK_FLAG; |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 4619 | vars->link_up = (vars->link_status & LINK_STATUS_LINK_UP); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4620 | if (vars->link_up) { |
| 4621 | DP(NETIF_MSG_LINK, "phy link up\n"); |
| 4622 | |
| 4623 | vars->phy_link_up = 1; |
| 4624 | vars->duplex = DUPLEX_FULL; |
| 4625 | switch (vars->link_status & |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4626 | LINK_STATUS_SPEED_AND_DUPLEX_MASK) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4627 | case LINK_10THD: |
| 4628 | vars->duplex = DUPLEX_HALF; |
| 4629 | /* fall thru */ |
| 4630 | case LINK_10TFD: |
| 4631 | vars->line_speed = SPEED_10; |
| 4632 | break; |
| 4633 | |
| 4634 | case LINK_100TXHD: |
| 4635 | vars->duplex = DUPLEX_HALF; |
| 4636 | /* fall thru */ |
| 4637 | case LINK_100T4: |
| 4638 | case LINK_100TXFD: |
| 4639 | vars->line_speed = SPEED_100; |
| 4640 | break; |
| 4641 | |
| 4642 | case LINK_1000THD: |
| 4643 | vars->duplex = DUPLEX_HALF; |
| 4644 | /* fall thru */ |
| 4645 | case LINK_1000TFD: |
| 4646 | vars->line_speed = SPEED_1000; |
| 4647 | break; |
| 4648 | |
| 4649 | case LINK_2500THD: |
| 4650 | vars->duplex = DUPLEX_HALF; |
| 4651 | /* fall thru */ |
| 4652 | case LINK_2500TFD: |
| 4653 | vars->line_speed = SPEED_2500; |
| 4654 | break; |
| 4655 | |
| 4656 | case LINK_10GTFD: |
| 4657 | vars->line_speed = SPEED_10000; |
| 4658 | break; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4659 | case LINK_20GTFD: |
| 4660 | vars->line_speed = SPEED_20000; |
| 4661 | break; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4662 | default: |
| 4663 | break; |
| 4664 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4665 | vars->flow_ctrl = 0; |
| 4666 | if (vars->link_status & LINK_STATUS_TX_FLOW_CONTROL_ENABLED) |
| 4667 | vars->flow_ctrl |= BNX2X_FLOW_CTRL_TX; |
| 4668 | |
| 4669 | if (vars->link_status & LINK_STATUS_RX_FLOW_CONTROL_ENABLED) |
| 4670 | vars->flow_ctrl |= BNX2X_FLOW_CTRL_RX; |
| 4671 | |
| 4672 | if (!vars->flow_ctrl) |
| 4673 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 4674 | |
| 4675 | if (vars->line_speed && |
| 4676 | ((vars->line_speed == SPEED_10) || |
| 4677 | (vars->line_speed == SPEED_100))) { |
| 4678 | vars->phy_flags |= PHY_SGMII_FLAG; |
| 4679 | } else { |
| 4680 | vars->phy_flags &= ~PHY_SGMII_FLAG; |
| 4681 | } |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4682 | if (vars->line_speed && |
| 4683 | USES_WARPCORE(bp) && |
| 4684 | (vars->line_speed == SPEED_1000)) |
| 4685 | vars->phy_flags |= PHY_SGMII_FLAG; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4686 | /* anything 10 and over uses the bmac */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 4687 | link_10g_plus = (vars->line_speed >= SPEED_10000); |
| 4688 | |
| 4689 | if (link_10g_plus) { |
| 4690 | if (USES_WARPCORE(bp)) |
| 4691 | vars->mac_type = MAC_TYPE_XMAC; |
| 4692 | else |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4693 | vars->mac_type = MAC_TYPE_BMAC; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 4694 | } else { |
| 4695 | if (USES_WARPCORE(bp)) |
| 4696 | vars->mac_type = MAC_TYPE_UMAC; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 4697 | else |
| 4698 | vars->mac_type = MAC_TYPE_EMAC; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 4699 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4700 | } else { /* link down */ |
| 4701 | DP(NETIF_MSG_LINK, "phy link down\n"); |
| 4702 | |
| 4703 | vars->phy_link_up = 0; |
| 4704 | |
| 4705 | vars->line_speed = 0; |
| 4706 | vars->duplex = DUPLEX_FULL; |
| 4707 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 4708 | |
| 4709 | /* indicate no mac active */ |
| 4710 | vars->mac_type = MAC_TYPE_NONE; |
Yaniv Rosner | de6f337 | 2011-08-02 22:59:25 +0000 | [diff] [blame] | 4711 | if (vars->link_status & LINK_STATUS_PHYSICAL_LINK_FLAG) |
| 4712 | vars->phy_flags |= PHY_HALF_OPEN_CONN_FLAG; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4713 | } |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 4714 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4715 | |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 4716 | void bnx2x_link_status_update(struct link_params *params, |
| 4717 | struct link_vars *vars) |
| 4718 | { |
| 4719 | struct bnx2x *bp = params->bp; |
| 4720 | u8 port = params->port; |
| 4721 | u32 sync_offset, media_types; |
| 4722 | /* Update PHY configuration */ |
| 4723 | set_phy_vars(params, vars); |
| 4724 | |
| 4725 | vars->link_status = REG_RD(bp, params->shmem_base + |
| 4726 | offsetof(struct shmem_region, |
| 4727 | port_mb[port].link_status)); |
| 4728 | |
| 4729 | vars->phy_flags = PHY_XGXS_FLAG; |
| 4730 | bnx2x_sync_link(params, vars); |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 4731 | /* Sync media type */ |
| 4732 | sync_offset = params->shmem_base + |
| 4733 | offsetof(struct shmem_region, |
| 4734 | dev_info.port_hw_config[port].media_type); |
| 4735 | media_types = REG_RD(bp, sync_offset); |
| 4736 | |
| 4737 | params->phy[INT_PHY].media_type = |
| 4738 | (media_types & PORT_HW_CFG_MEDIA_TYPE_PHY0_MASK) >> |
| 4739 | PORT_HW_CFG_MEDIA_TYPE_PHY0_SHIFT; |
| 4740 | params->phy[EXT_PHY1].media_type = |
| 4741 | (media_types & PORT_HW_CFG_MEDIA_TYPE_PHY1_MASK) >> |
| 4742 | PORT_HW_CFG_MEDIA_TYPE_PHY1_SHIFT; |
| 4743 | params->phy[EXT_PHY2].media_type = |
| 4744 | (media_types & PORT_HW_CFG_MEDIA_TYPE_PHY2_MASK) >> |
| 4745 | PORT_HW_CFG_MEDIA_TYPE_PHY2_SHIFT; |
| 4746 | DP(NETIF_MSG_LINK, "media_types = 0x%x\n", media_types); |
| 4747 | |
Yaniv Rosner | 020c7e3 | 2011-05-31 21:28:43 +0000 | [diff] [blame] | 4748 | /* Sync AEU offset */ |
| 4749 | sync_offset = params->shmem_base + |
| 4750 | offsetof(struct shmem_region, |
| 4751 | dev_info.port_hw_config[port].aeu_int_mask); |
| 4752 | |
| 4753 | vars->aeu_int_mask = REG_RD(bp, sync_offset); |
| 4754 | |
Yaniv Rosner | b8d6d08 | 2011-07-05 01:06:27 +0000 | [diff] [blame] | 4755 | /* Sync PFC status */ |
| 4756 | if (vars->link_status & LINK_STATUS_PFC_ENABLED) |
| 4757 | params->feature_config_flags |= |
| 4758 | FEATURE_CONFIG_PFC_ENABLED; |
| 4759 | else |
| 4760 | params->feature_config_flags &= |
| 4761 | ~FEATURE_CONFIG_PFC_ENABLED; |
| 4762 | |
Yaniv Rosner | 020c7e3 | 2011-05-31 21:28:43 +0000 | [diff] [blame] | 4763 | DP(NETIF_MSG_LINK, "link_status 0x%x phy_link_up %x int_mask 0x%x\n", |
| 4764 | vars->link_status, vars->phy_link_up, vars->aeu_int_mask); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4765 | DP(NETIF_MSG_LINK, "line_speed %x duplex %x flow_ctrl 0x%x\n", |
| 4766 | vars->line_speed, vars->duplex, vars->flow_ctrl); |
| 4767 | } |
| 4768 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 4769 | static void bnx2x_set_master_ln(struct link_params *params, |
| 4770 | struct bnx2x_phy *phy) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4771 | { |
| 4772 | struct bnx2x *bp = params->bp; |
| 4773 | u16 new_master_ln, ser_lane; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4774 | ser_lane = ((params->lane_config & |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4775 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_MASK) >> |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4776 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_SHIFT); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4777 | |
| 4778 | /* set the master_ln for AN */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4779 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4780 | MDIO_REG_BANK_XGXS_BLOCK2, |
| 4781 | MDIO_XGXS_BLOCK2_TEST_MODE_LANE, |
| 4782 | &new_master_ln); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4783 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4784 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4785 | MDIO_REG_BANK_XGXS_BLOCK2 , |
| 4786 | MDIO_XGXS_BLOCK2_TEST_MODE_LANE, |
| 4787 | (new_master_ln | ser_lane)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4788 | } |
| 4789 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 4790 | static int bnx2x_reset_unicore(struct link_params *params, |
| 4791 | struct bnx2x_phy *phy, |
| 4792 | u8 set_serdes) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4793 | { |
| 4794 | struct bnx2x *bp = params->bp; |
| 4795 | u16 mii_control; |
| 4796 | u16 i; |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4797 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4798 | MDIO_REG_BANK_COMBO_IEEE0, |
| 4799 | MDIO_COMBO_IEEE0_MII_CONTROL, &mii_control); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4800 | |
| 4801 | /* reset the unicore */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4802 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4803 | MDIO_REG_BANK_COMBO_IEEE0, |
| 4804 | MDIO_COMBO_IEEE0_MII_CONTROL, |
| 4805 | (mii_control | |
| 4806 | MDIO_COMBO_IEEO_MII_CONTROL_RESET)); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 4807 | if (set_serdes) |
| 4808 | bnx2x_set_serdes_access(bp, params->port); |
Eilon Greenstein | c1b7399 | 2009-02-12 08:37:07 +0000 | [diff] [blame] | 4809 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4810 | /* wait for the reset to self clear */ |
| 4811 | for (i = 0; i < MDIO_ACCESS_TIMEOUT; i++) { |
| 4812 | udelay(5); |
| 4813 | |
| 4814 | /* the reset erased the previous bank value */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4815 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4816 | MDIO_REG_BANK_COMBO_IEEE0, |
| 4817 | MDIO_COMBO_IEEE0_MII_CONTROL, |
| 4818 | &mii_control); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4819 | |
| 4820 | if (!(mii_control & MDIO_COMBO_IEEO_MII_CONTROL_RESET)) { |
| 4821 | udelay(5); |
| 4822 | return 0; |
| 4823 | } |
| 4824 | } |
| 4825 | |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 4826 | netdev_err(bp->dev, "Warning: PHY was not initialized," |
| 4827 | " Port %d\n", |
| 4828 | params->port); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4829 | DP(NETIF_MSG_LINK, "BUG! XGXS is still in reset!\n"); |
| 4830 | return -EINVAL; |
| 4831 | |
| 4832 | } |
| 4833 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 4834 | static void bnx2x_set_swap_lanes(struct link_params *params, |
| 4835 | struct bnx2x_phy *phy) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4836 | { |
| 4837 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 4838 | /* |
| 4839 | * Each two bits represents a lane number: |
| 4840 | * No swap is 0123 => 0x1b no need to enable the swap |
| 4841 | */ |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 4842 | u16 rx_lane_swap, tx_lane_swap; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4843 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4844 | rx_lane_swap = ((params->lane_config & |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4845 | PORT_HW_CFG_LANE_SWAP_CFG_RX_MASK) >> |
| 4846 | PORT_HW_CFG_LANE_SWAP_CFG_RX_SHIFT); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4847 | tx_lane_swap = ((params->lane_config & |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4848 | PORT_HW_CFG_LANE_SWAP_CFG_TX_MASK) >> |
| 4849 | PORT_HW_CFG_LANE_SWAP_CFG_TX_SHIFT); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4850 | |
| 4851 | if (rx_lane_swap != 0x1b) { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4852 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4853 | MDIO_REG_BANK_XGXS_BLOCK2, |
| 4854 | MDIO_XGXS_BLOCK2_RX_LN_SWAP, |
| 4855 | (rx_lane_swap | |
| 4856 | MDIO_XGXS_BLOCK2_RX_LN_SWAP_ENABLE | |
| 4857 | MDIO_XGXS_BLOCK2_RX_LN_SWAP_FORCE_ENABLE)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4858 | } else { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4859 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4860 | MDIO_REG_BANK_XGXS_BLOCK2, |
| 4861 | MDIO_XGXS_BLOCK2_RX_LN_SWAP, 0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4862 | } |
| 4863 | |
| 4864 | if (tx_lane_swap != 0x1b) { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4865 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4866 | MDIO_REG_BANK_XGXS_BLOCK2, |
| 4867 | MDIO_XGXS_BLOCK2_TX_LN_SWAP, |
| 4868 | (tx_lane_swap | |
| 4869 | MDIO_XGXS_BLOCK2_TX_LN_SWAP_ENABLE)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4870 | } else { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4871 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4872 | MDIO_REG_BANK_XGXS_BLOCK2, |
| 4873 | MDIO_XGXS_BLOCK2_TX_LN_SWAP, 0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4874 | } |
| 4875 | } |
| 4876 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 4877 | static void bnx2x_set_parallel_detection(struct bnx2x_phy *phy, |
| 4878 | struct link_params *params) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4879 | { |
| 4880 | struct bnx2x *bp = params->bp; |
| 4881 | u16 control2; |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4882 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4883 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 4884 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL2, |
| 4885 | &control2); |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 4886 | if (phy->speed_cap_mask & PORT_HW_CFG_SPEED_CAPABILITY_D0_1G) |
Yaniv Rosner | 18afb0a | 2009-11-05 19:18:04 +0200 | [diff] [blame] | 4887 | control2 |= MDIO_SERDES_DIGITAL_A_1000X_CONTROL2_PRL_DT_EN; |
| 4888 | else |
| 4889 | control2 &= ~MDIO_SERDES_DIGITAL_A_1000X_CONTROL2_PRL_DT_EN; |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 4890 | DP(NETIF_MSG_LINK, "phy->speed_cap_mask = 0x%x, control2 = 0x%x\n", |
| 4891 | phy->speed_cap_mask, control2); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4892 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4893 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 4894 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL2, |
| 4895 | control2); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4896 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 4897 | if ((phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT) && |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 4898 | (phy->speed_cap_mask & |
Yaniv Rosner | 18afb0a | 2009-11-05 19:18:04 +0200 | [diff] [blame] | 4899 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G)) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4900 | DP(NETIF_MSG_LINK, "XGXS\n"); |
| 4901 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4902 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4903 | MDIO_REG_BANK_10G_PARALLEL_DETECT, |
| 4904 | MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_LINK, |
| 4905 | MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_LINK_CNT); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4906 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4907 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4908 | MDIO_REG_BANK_10G_PARALLEL_DETECT, |
| 4909 | MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_CONTROL, |
| 4910 | &control2); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4911 | |
| 4912 | |
| 4913 | control2 |= |
| 4914 | MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_CONTROL_PARDET10G_EN; |
| 4915 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4916 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4917 | MDIO_REG_BANK_10G_PARALLEL_DETECT, |
| 4918 | MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_CONTROL, |
| 4919 | control2); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4920 | |
| 4921 | /* Disable parallel detection of HiG */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4922 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4923 | MDIO_REG_BANK_XGXS_BLOCK2, |
| 4924 | MDIO_XGXS_BLOCK2_UNICORE_MODE_10G, |
| 4925 | MDIO_XGXS_BLOCK2_UNICORE_MODE_10G_CX4_XGXS | |
| 4926 | MDIO_XGXS_BLOCK2_UNICORE_MODE_10G_HIGIG_XGXS); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4927 | } |
| 4928 | } |
| 4929 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 4930 | static void bnx2x_set_autoneg(struct bnx2x_phy *phy, |
| 4931 | struct link_params *params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4932 | struct link_vars *vars, |
| 4933 | u8 enable_cl73) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4934 | { |
| 4935 | struct bnx2x *bp = params->bp; |
| 4936 | u16 reg_val; |
| 4937 | |
| 4938 | /* CL37 Autoneg */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4939 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4940 | MDIO_REG_BANK_COMBO_IEEE0, |
| 4941 | MDIO_COMBO_IEEE0_MII_CONTROL, ®_val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4942 | |
| 4943 | /* CL37 Autoneg Enabled */ |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 4944 | if (vars->line_speed == SPEED_AUTO_NEG) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4945 | reg_val |= MDIO_COMBO_IEEO_MII_CONTROL_AN_EN; |
| 4946 | else /* CL37 Autoneg Disabled */ |
| 4947 | reg_val &= ~(MDIO_COMBO_IEEO_MII_CONTROL_AN_EN | |
| 4948 | MDIO_COMBO_IEEO_MII_CONTROL_RESTART_AN); |
| 4949 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4950 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4951 | MDIO_REG_BANK_COMBO_IEEE0, |
| 4952 | MDIO_COMBO_IEEE0_MII_CONTROL, reg_val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4953 | |
| 4954 | /* Enable/Disable Autodetection */ |
| 4955 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4956 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4957 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 4958 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL1, ®_val); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 4959 | reg_val &= ~(MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_SIGNAL_DETECT_EN | |
| 4960 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_INVERT_SIGNAL_DETECT); |
| 4961 | reg_val |= MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_FIBER_MODE; |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 4962 | if (vars->line_speed == SPEED_AUTO_NEG) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4963 | reg_val |= MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_AUTODET; |
| 4964 | else |
| 4965 | reg_val &= ~MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_AUTODET; |
| 4966 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4967 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4968 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 4969 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL1, reg_val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4970 | |
| 4971 | /* Enable TetonII and BAM autoneg */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4972 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4973 | MDIO_REG_BANK_BAM_NEXT_PAGE, |
| 4974 | MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL, |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4975 | ®_val); |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 4976 | if (vars->line_speed == SPEED_AUTO_NEG) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4977 | /* Enable BAM aneg Mode and TetonII aneg Mode */ |
| 4978 | reg_val |= (MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL_BAM_MODE | |
| 4979 | MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL_TETON_AN); |
| 4980 | } else { |
| 4981 | /* TetonII and BAM Autoneg Disabled */ |
| 4982 | reg_val &= ~(MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL_BAM_MODE | |
| 4983 | MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL_TETON_AN); |
| 4984 | } |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4985 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4986 | MDIO_REG_BANK_BAM_NEXT_PAGE, |
| 4987 | MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL, |
| 4988 | reg_val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 4989 | |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 4990 | if (enable_cl73) { |
| 4991 | /* Enable Cl73 FSM status bits */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4992 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4993 | MDIO_REG_BANK_CL73_USERB0, |
| 4994 | MDIO_CL73_USERB0_CL73_UCTRL, |
| 4995 | 0xe); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 4996 | |
| 4997 | /* Enable BAM Station Manager*/ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 4998 | CL22_WR_OVER_CL45(bp, phy, |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 4999 | MDIO_REG_BANK_CL73_USERB0, |
| 5000 | MDIO_CL73_USERB0_CL73_BAM_CTRL1, |
| 5001 | MDIO_CL73_USERB0_CL73_BAM_CTRL1_BAM_EN | |
| 5002 | MDIO_CL73_USERB0_CL73_BAM_CTRL1_BAM_STATION_MNGR_EN | |
| 5003 | MDIO_CL73_USERB0_CL73_BAM_CTRL1_BAM_NP_AFTER_BP_EN); |
| 5004 | |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 5005 | /* Advertise CL73 link speeds */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5006 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5007 | MDIO_REG_BANK_CL73_IEEEB1, |
| 5008 | MDIO_CL73_IEEEB1_AN_ADV2, |
| 5009 | ®_val); |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 5010 | if (phy->speed_cap_mask & |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 5011 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G) |
| 5012 | reg_val |= MDIO_CL73_IEEEB1_AN_ADV2_ADVR_10G_KX4; |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 5013 | if (phy->speed_cap_mask & |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 5014 | PORT_HW_CFG_SPEED_CAPABILITY_D0_1G) |
| 5015 | reg_val |= MDIO_CL73_IEEEB1_AN_ADV2_ADVR_1000M_KX; |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5016 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5017 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5018 | MDIO_REG_BANK_CL73_IEEEB1, |
| 5019 | MDIO_CL73_IEEEB1_AN_ADV2, |
| 5020 | reg_val); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5021 | |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5022 | /* CL73 Autoneg Enabled */ |
| 5023 | reg_val = MDIO_CL73_IEEEB0_CL73_AN_CONTROL_AN_EN; |
| 5024 | |
| 5025 | } else /* CL73 Autoneg Disabled */ |
| 5026 | reg_val = 0; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5027 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5028 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5029 | MDIO_REG_BANK_CL73_IEEEB0, |
| 5030 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL, reg_val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5031 | } |
| 5032 | |
| 5033 | /* program SerDes, forced speed */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 5034 | static void bnx2x_program_serdes(struct bnx2x_phy *phy, |
| 5035 | struct link_params *params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5036 | struct link_vars *vars) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5037 | { |
| 5038 | struct bnx2x *bp = params->bp; |
| 5039 | u16 reg_val; |
| 5040 | |
Eilon Greenstein | 5793720 | 2009-08-12 08:23:53 +0000 | [diff] [blame] | 5041 | /* program duplex, disable autoneg and sgmii*/ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5042 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5043 | MDIO_REG_BANK_COMBO_IEEE0, |
| 5044 | MDIO_COMBO_IEEE0_MII_CONTROL, ®_val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5045 | reg_val &= ~(MDIO_COMBO_IEEO_MII_CONTROL_FULL_DUPLEX | |
Eilon Greenstein | 5793720 | 2009-08-12 08:23:53 +0000 | [diff] [blame] | 5046 | MDIO_COMBO_IEEO_MII_CONTROL_AN_EN | |
| 5047 | MDIO_COMBO_IEEO_MII_CONTROL_MAN_SGMII_SP_MASK); |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 5048 | if (phy->req_duplex == DUPLEX_FULL) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5049 | reg_val |= MDIO_COMBO_IEEO_MII_CONTROL_FULL_DUPLEX; |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5050 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5051 | MDIO_REG_BANK_COMBO_IEEE0, |
| 5052 | MDIO_COMBO_IEEE0_MII_CONTROL, reg_val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5053 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5054 | /* |
| 5055 | * program speed |
| 5056 | * - needed only if the speed is greater than 1G (2.5G or 10G) |
| 5057 | */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5058 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5059 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 5060 | MDIO_SERDES_DIGITAL_MISC1, ®_val); |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 5061 | /* clearing the speed value before setting the right speed */ |
| 5062 | DP(NETIF_MSG_LINK, "MDIO_REG_BANK_SERDES_DIGITAL = 0x%x\n", reg_val); |
| 5063 | |
| 5064 | reg_val &= ~(MDIO_SERDES_DIGITAL_MISC1_FORCE_SPEED_MASK | |
| 5065 | MDIO_SERDES_DIGITAL_MISC1_FORCE_SPEED_SEL); |
| 5066 | |
| 5067 | if (!((vars->line_speed == SPEED_1000) || |
| 5068 | (vars->line_speed == SPEED_100) || |
| 5069 | (vars->line_speed == SPEED_10))) { |
| 5070 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5071 | reg_val |= (MDIO_SERDES_DIGITAL_MISC1_REFCLK_SEL_156_25M | |
| 5072 | MDIO_SERDES_DIGITAL_MISC1_FORCE_SPEED_SEL); |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 5073 | if (vars->line_speed == SPEED_10000) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5074 | reg_val |= |
| 5075 | MDIO_SERDES_DIGITAL_MISC1_FORCE_SPEED_10G_CX4; |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 5076 | } |
| 5077 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5078 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5079 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 5080 | MDIO_SERDES_DIGITAL_MISC1, reg_val); |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 5081 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5082 | } |
| 5083 | |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 5084 | static void bnx2x_set_brcm_cl37_advertisement(struct bnx2x_phy *phy, |
| 5085 | struct link_params *params) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5086 | { |
| 5087 | struct bnx2x *bp = params->bp; |
| 5088 | u16 val = 0; |
| 5089 | |
| 5090 | /* configure the 48 bits for BAM AN */ |
| 5091 | |
| 5092 | /* set extended capabilities */ |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 5093 | 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] | 5094 | val |= MDIO_OVER_1G_UP1_2_5G; |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 5095 | if (phy->speed_cap_mask & PORT_HW_CFG_SPEED_CAPABILITY_D0_10G) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5096 | val |= MDIO_OVER_1G_UP1_10G; |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5097 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5098 | MDIO_REG_BANK_OVER_1G, |
| 5099 | MDIO_OVER_1G_UP1, val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5100 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5101 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5102 | MDIO_REG_BANK_OVER_1G, |
| 5103 | MDIO_OVER_1G_UP3, 0x400); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5104 | } |
| 5105 | |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 5106 | static void bnx2x_set_ieee_aneg_advertisement(struct bnx2x_phy *phy, |
| 5107 | struct link_params *params, |
| 5108 | u16 ieee_fc) |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 5109 | { |
| 5110 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 5111 | u16 val; |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 5112 | /* for AN, we are always publishing full duplex */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5113 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5114 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5115 | MDIO_REG_BANK_COMBO_IEEE0, |
| 5116 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV, ieee_fc); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5117 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5118 | MDIO_REG_BANK_CL73_IEEEB1, |
| 5119 | MDIO_CL73_IEEEB1_AN_ADV1, &val); |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 5120 | val &= ~MDIO_CL73_IEEEB1_AN_ADV1_PAUSE_BOTH; |
| 5121 | val |= ((ieee_fc<<3) & MDIO_CL73_IEEEB1_AN_ADV1_PAUSE_MASK); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5122 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5123 | MDIO_REG_BANK_CL73_IEEEB1, |
| 5124 | MDIO_CL73_IEEEB1_AN_ADV1, val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5125 | } |
| 5126 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 5127 | static void bnx2x_restart_autoneg(struct bnx2x_phy *phy, |
| 5128 | struct link_params *params, |
| 5129 | u8 enable_cl73) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5130 | { |
| 5131 | struct bnx2x *bp = params->bp; |
Eilon Greenstein | 3a36f2e | 2009-02-12 08:37:09 +0000 | [diff] [blame] | 5132 | u16 mii_control; |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5133 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5134 | DP(NETIF_MSG_LINK, "bnx2x_restart_autoneg\n"); |
Eilon Greenstein | 3a36f2e | 2009-02-12 08:37:09 +0000 | [diff] [blame] | 5135 | /* Enable and restart BAM/CL37 aneg */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5136 | |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5137 | if (enable_cl73) { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5138 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5139 | MDIO_REG_BANK_CL73_IEEEB0, |
| 5140 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL, |
| 5141 | &mii_control); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5142 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5143 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5144 | MDIO_REG_BANK_CL73_IEEEB0, |
| 5145 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL, |
| 5146 | (mii_control | |
| 5147 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL_AN_EN | |
| 5148 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL_RESTART_AN)); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5149 | } else { |
| 5150 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5151 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5152 | MDIO_REG_BANK_COMBO_IEEE0, |
| 5153 | MDIO_COMBO_IEEE0_MII_CONTROL, |
| 5154 | &mii_control); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5155 | DP(NETIF_MSG_LINK, |
| 5156 | "bnx2x_restart_autoneg mii_control before = 0x%x\n", |
| 5157 | mii_control); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5158 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5159 | MDIO_REG_BANK_COMBO_IEEE0, |
| 5160 | MDIO_COMBO_IEEE0_MII_CONTROL, |
| 5161 | (mii_control | |
| 5162 | MDIO_COMBO_IEEO_MII_CONTROL_AN_EN | |
| 5163 | MDIO_COMBO_IEEO_MII_CONTROL_RESTART_AN)); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5164 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5165 | } |
| 5166 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 5167 | static void bnx2x_initialize_sgmii_process(struct bnx2x_phy *phy, |
| 5168 | struct link_params *params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5169 | struct link_vars *vars) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5170 | { |
| 5171 | struct bnx2x *bp = params->bp; |
| 5172 | u16 control1; |
| 5173 | |
| 5174 | /* in SGMII mode, the unicore is always slave */ |
| 5175 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5176 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5177 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 5178 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL1, |
| 5179 | &control1); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5180 | control1 |= MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_INVERT_SIGNAL_DETECT; |
| 5181 | /* set sgmii mode (and not fiber) */ |
| 5182 | control1 &= ~(MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_FIBER_MODE | |
| 5183 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_AUTODET | |
| 5184 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_MSTR_MODE); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5185 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5186 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 5187 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL1, |
| 5188 | control1); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5189 | |
| 5190 | /* if forced speed */ |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 5191 | if (!(vars->line_speed == SPEED_AUTO_NEG)) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5192 | /* set speed, disable autoneg */ |
| 5193 | u16 mii_control; |
| 5194 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5195 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5196 | MDIO_REG_BANK_COMBO_IEEE0, |
| 5197 | MDIO_COMBO_IEEE0_MII_CONTROL, |
| 5198 | &mii_control); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5199 | mii_control &= ~(MDIO_COMBO_IEEO_MII_CONTROL_AN_EN | |
| 5200 | MDIO_COMBO_IEEO_MII_CONTROL_MAN_SGMII_SP_MASK| |
| 5201 | MDIO_COMBO_IEEO_MII_CONTROL_FULL_DUPLEX); |
| 5202 | |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 5203 | switch (vars->line_speed) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5204 | case SPEED_100: |
| 5205 | mii_control |= |
| 5206 | MDIO_COMBO_IEEO_MII_CONTROL_MAN_SGMII_SP_100; |
| 5207 | break; |
| 5208 | case SPEED_1000: |
| 5209 | mii_control |= |
| 5210 | MDIO_COMBO_IEEO_MII_CONTROL_MAN_SGMII_SP_1000; |
| 5211 | break; |
| 5212 | case SPEED_10: |
| 5213 | /* there is nothing to set for 10M */ |
| 5214 | break; |
| 5215 | default: |
| 5216 | /* invalid speed for SGMII */ |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 5217 | DP(NETIF_MSG_LINK, "Invalid line_speed 0x%x\n", |
| 5218 | vars->line_speed); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5219 | break; |
| 5220 | } |
| 5221 | |
| 5222 | /* setting the full duplex */ |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 5223 | if (phy->req_duplex == DUPLEX_FULL) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5224 | mii_control |= |
| 5225 | MDIO_COMBO_IEEO_MII_CONTROL_FULL_DUPLEX; |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5226 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5227 | MDIO_REG_BANK_COMBO_IEEE0, |
| 5228 | MDIO_COMBO_IEEE0_MII_CONTROL, |
| 5229 | mii_control); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5230 | |
| 5231 | } else { /* AN mode */ |
| 5232 | /* enable and restart AN */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 5233 | bnx2x_restart_autoneg(phy, params, 0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5234 | } |
| 5235 | } |
| 5236 | |
| 5237 | |
| 5238 | /* |
| 5239 | * link management |
| 5240 | */ |
| 5241 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 5242 | static int bnx2x_direct_parallel_detect_used(struct bnx2x_phy *phy, |
| 5243 | struct link_params *params) |
Yaniv Rosner | 15ddd2d | 2009-11-05 19:18:12 +0200 | [diff] [blame] | 5244 | { |
| 5245 | struct bnx2x *bp = params->bp; |
| 5246 | u16 pd_10g, status2_1000x; |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 5247 | if (phy->req_line_speed != SPEED_AUTO_NEG) |
| 5248 | return 0; |
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_SERDES_DIGITAL, |
| 5251 | MDIO_SERDES_DIGITAL_A_1000X_STATUS2, |
| 5252 | &status2_1000x); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5253 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5254 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 5255 | MDIO_SERDES_DIGITAL_A_1000X_STATUS2, |
| 5256 | &status2_1000x); |
Yaniv Rosner | 15ddd2d | 2009-11-05 19:18:12 +0200 | [diff] [blame] | 5257 | if (status2_1000x & MDIO_SERDES_DIGITAL_A_1000X_STATUS2_AN_DISABLED) { |
| 5258 | DP(NETIF_MSG_LINK, "1G parallel detect link on port %d\n", |
| 5259 | params->port); |
| 5260 | return 1; |
| 5261 | } |
| 5262 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5263 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5264 | MDIO_REG_BANK_10G_PARALLEL_DETECT, |
| 5265 | MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_STATUS, |
| 5266 | &pd_10g); |
Yaniv Rosner | 15ddd2d | 2009-11-05 19:18:12 +0200 | [diff] [blame] | 5267 | |
| 5268 | if (pd_10g & MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_STATUS_PD_LINK) { |
| 5269 | DP(NETIF_MSG_LINK, "10G parallel detect link on port %d\n", |
| 5270 | params->port); |
| 5271 | return 1; |
| 5272 | } |
| 5273 | return 0; |
| 5274 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5275 | |
Mintz Yuval | 9e7e839 | 2012-02-15 02:10:24 +0000 | [diff] [blame] | 5276 | static void bnx2x_update_adv_fc(struct bnx2x_phy *phy, |
| 5277 | struct link_params *params, |
| 5278 | struct link_vars *vars, |
| 5279 | u32 gp_status) |
| 5280 | { |
| 5281 | u16 ld_pause; /* local driver */ |
| 5282 | u16 lp_pause; /* link partner */ |
| 5283 | u16 pause_result; |
| 5284 | struct bnx2x *bp = params->bp; |
| 5285 | if ((gp_status & |
| 5286 | (MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_AUTONEG_COMPLETE | |
| 5287 | MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_MR_LP_NP_AN_ABLE)) == |
| 5288 | (MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_AUTONEG_COMPLETE | |
| 5289 | MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_MR_LP_NP_AN_ABLE)) { |
| 5290 | |
| 5291 | CL22_RD_OVER_CL45(bp, phy, |
| 5292 | MDIO_REG_BANK_CL73_IEEEB1, |
| 5293 | MDIO_CL73_IEEEB1_AN_ADV1, |
| 5294 | &ld_pause); |
| 5295 | CL22_RD_OVER_CL45(bp, phy, |
| 5296 | MDIO_REG_BANK_CL73_IEEEB1, |
| 5297 | MDIO_CL73_IEEEB1_AN_LP_ADV1, |
| 5298 | &lp_pause); |
| 5299 | pause_result = (ld_pause & |
| 5300 | MDIO_CL73_IEEEB1_AN_ADV1_PAUSE_MASK) >> 8; |
| 5301 | pause_result |= (lp_pause & |
| 5302 | MDIO_CL73_IEEEB1_AN_LP_ADV1_PAUSE_MASK) >> 10; |
| 5303 | DP(NETIF_MSG_LINK, "pause_result CL73 0x%x\n", pause_result); |
| 5304 | } else { |
| 5305 | CL22_RD_OVER_CL45(bp, phy, |
| 5306 | MDIO_REG_BANK_COMBO_IEEE0, |
| 5307 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV, |
| 5308 | &ld_pause); |
| 5309 | CL22_RD_OVER_CL45(bp, phy, |
| 5310 | MDIO_REG_BANK_COMBO_IEEE0, |
| 5311 | MDIO_COMBO_IEEE0_AUTO_NEG_LINK_PARTNER_ABILITY1, |
| 5312 | &lp_pause); |
| 5313 | pause_result = (ld_pause & |
| 5314 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_MASK)>>5; |
| 5315 | pause_result |= (lp_pause & |
| 5316 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_MASK)>>7; |
| 5317 | DP(NETIF_MSG_LINK, "pause_result CL37 0x%x\n", pause_result); |
| 5318 | } |
| 5319 | bnx2x_pause_resolve(vars, pause_result); |
| 5320 | |
| 5321 | } |
| 5322 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 5323 | static void bnx2x_flow_ctrl_resolve(struct bnx2x_phy *phy, |
| 5324 | struct link_params *params, |
| 5325 | struct link_vars *vars, |
| 5326 | u32 gp_status) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5327 | { |
| 5328 | struct bnx2x *bp = params->bp; |
David S. Miller | c0700f9 | 2008-12-16 23:53:20 -0800 | [diff] [blame] | 5329 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5330 | |
| 5331 | /* resolve from gp_status in case of AN complete and not sgmii */ |
Mintz Yuval | 9e7e839 | 2012-02-15 02:10:24 +0000 | [diff] [blame] | 5332 | if (phy->req_flow_ctrl != BNX2X_FLOW_CTRL_AUTO) { |
| 5333 | /* Update the advertised flow-controled of LD/LP in AN */ |
| 5334 | if (phy->req_line_speed == SPEED_AUTO_NEG) |
| 5335 | bnx2x_update_adv_fc(phy, params, vars, gp_status); |
| 5336 | /* But set the flow-control result as the requested one */ |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 5337 | vars->flow_ctrl = phy->req_flow_ctrl; |
Mintz Yuval | 9e7e839 | 2012-02-15 02:10:24 +0000 | [diff] [blame] | 5338 | } else if (phy->req_line_speed != SPEED_AUTO_NEG) |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 5339 | vars->flow_ctrl = params->req_fc_auto_adv; |
| 5340 | else if ((gp_status & MDIO_AN_CL73_OR_37_COMPLETE) && |
| 5341 | (!(vars->phy_flags & PHY_SGMII_FLAG))) { |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 5342 | if (bnx2x_direct_parallel_detect_used(phy, params)) { |
Yaniv Rosner | 15ddd2d | 2009-11-05 19:18:12 +0200 | [diff] [blame] | 5343 | vars->flow_ctrl = params->req_fc_auto_adv; |
| 5344 | return; |
| 5345 | } |
Mintz Yuval | 9e7e839 | 2012-02-15 02:10:24 +0000 | [diff] [blame] | 5346 | bnx2x_update_adv_fc(phy, params, vars, gp_status); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5347 | } |
| 5348 | DP(NETIF_MSG_LINK, "flow_ctrl 0x%x\n", vars->flow_ctrl); |
| 5349 | } |
| 5350 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 5351 | static void bnx2x_check_fallback_to_cl37(struct bnx2x_phy *phy, |
| 5352 | struct link_params *params) |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5353 | { |
| 5354 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 5355 | u16 rx_status, ustat_val, cl37_fsm_received; |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5356 | DP(NETIF_MSG_LINK, "bnx2x_check_fallback_to_cl37\n"); |
| 5357 | /* Step 1: Make sure signal is detected */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5358 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5359 | MDIO_REG_BANK_RX0, |
| 5360 | MDIO_RX0_RX_STATUS, |
| 5361 | &rx_status); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5362 | if ((rx_status & MDIO_RX0_RX_STATUS_SIGDET) != |
| 5363 | (MDIO_RX0_RX_STATUS_SIGDET)) { |
| 5364 | DP(NETIF_MSG_LINK, "Signal is not detected. Restoring CL73." |
| 5365 | "rx_status(0x80b0) = 0x%x\n", rx_status); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5366 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5367 | MDIO_REG_BANK_CL73_IEEEB0, |
| 5368 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL, |
| 5369 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL_AN_EN); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5370 | return; |
| 5371 | } |
| 5372 | /* Step 2: Check CL73 state machine */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5373 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5374 | MDIO_REG_BANK_CL73_USERB0, |
| 5375 | MDIO_CL73_USERB0_CL73_USTAT1, |
| 5376 | &ustat_val); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5377 | if ((ustat_val & |
| 5378 | (MDIO_CL73_USERB0_CL73_USTAT1_LINK_STATUS_CHECK | |
| 5379 | MDIO_CL73_USERB0_CL73_USTAT1_AN_GOOD_CHECK_BAM37)) != |
| 5380 | (MDIO_CL73_USERB0_CL73_USTAT1_LINK_STATUS_CHECK | |
| 5381 | MDIO_CL73_USERB0_CL73_USTAT1_AN_GOOD_CHECK_BAM37)) { |
| 5382 | DP(NETIF_MSG_LINK, "CL73 state-machine is not stable. " |
| 5383 | "ustat_val(0x8371) = 0x%x\n", ustat_val); |
| 5384 | return; |
| 5385 | } |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5386 | /* |
| 5387 | * Step 3: Check CL37 Message Pages received to indicate LP |
| 5388 | * supports only CL37 |
| 5389 | */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5390 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5391 | MDIO_REG_BANK_REMOTE_PHY, |
| 5392 | MDIO_REMOTE_PHY_MISC_RX_STATUS, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 5393 | &cl37_fsm_received); |
| 5394 | if ((cl37_fsm_received & |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5395 | (MDIO_REMOTE_PHY_MISC_RX_STATUS_CL37_FSM_RECEIVED_OVER1G_MSG | |
| 5396 | MDIO_REMOTE_PHY_MISC_RX_STATUS_CL37_FSM_RECEIVED_BRCM_OUI_MSG)) != |
| 5397 | (MDIO_REMOTE_PHY_MISC_RX_STATUS_CL37_FSM_RECEIVED_OVER1G_MSG | |
| 5398 | MDIO_REMOTE_PHY_MISC_RX_STATUS_CL37_FSM_RECEIVED_BRCM_OUI_MSG)) { |
| 5399 | DP(NETIF_MSG_LINK, "No CL37 FSM were received. " |
| 5400 | "misc_rx_status(0x8330) = 0x%x\n", |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 5401 | cl37_fsm_received); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5402 | return; |
| 5403 | } |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5404 | /* |
| 5405 | * The combined cl37/cl73 fsm state information indicating that |
| 5406 | * we are connected to a device which does not support cl73, but |
| 5407 | * does support cl37 BAM. In this case we disable cl73 and |
| 5408 | * restart cl37 auto-neg |
| 5409 | */ |
| 5410 | |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5411 | /* Disable CL73 */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5412 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5413 | MDIO_REG_BANK_CL73_IEEEB0, |
| 5414 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL, |
| 5415 | 0); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5416 | /* Restart CL37 autoneg */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 5417 | bnx2x_restart_autoneg(phy, params, 0); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5418 | DP(NETIF_MSG_LINK, "Disabling CL73, and restarting CL37 autoneg\n"); |
| 5419 | } |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 5420 | |
| 5421 | static void bnx2x_xgxs_an_resolve(struct bnx2x_phy *phy, |
| 5422 | struct link_params *params, |
| 5423 | struct link_vars *vars, |
| 5424 | u32 gp_status) |
| 5425 | { |
| 5426 | if (gp_status & MDIO_AN_CL73_OR_37_COMPLETE) |
| 5427 | vars->link_status |= |
| 5428 | LINK_STATUS_AUTO_NEGOTIATE_COMPLETE; |
| 5429 | |
| 5430 | if (bnx2x_direct_parallel_detect_used(phy, params)) |
| 5431 | vars->link_status |= |
| 5432 | LINK_STATUS_PARALLEL_DETECTION_USED; |
| 5433 | } |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5434 | static int bnx2x_get_link_speed_duplex(struct bnx2x_phy *phy, |
| 5435 | struct link_params *params, |
| 5436 | struct link_vars *vars, |
| 5437 | u16 is_link_up, |
| 5438 | u16 speed_mask, |
| 5439 | u16 is_duplex) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5440 | { |
| 5441 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 5442 | if (phy->req_line_speed == SPEED_AUTO_NEG) |
| 5443 | vars->link_status |= LINK_STATUS_AUTO_NEGOTIATE_ENABLED; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5444 | if (is_link_up) { |
| 5445 | DP(NETIF_MSG_LINK, "phy link up\n"); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5446 | |
| 5447 | vars->phy_link_up = 1; |
| 5448 | vars->link_status |= LINK_STATUS_LINK_UP; |
| 5449 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5450 | switch (speed_mask) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5451 | case GP_STATUS_10M: |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5452 | vars->line_speed = SPEED_10; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5453 | if (vars->duplex == DUPLEX_FULL) |
| 5454 | vars->link_status |= LINK_10TFD; |
| 5455 | else |
| 5456 | vars->link_status |= LINK_10THD; |
| 5457 | break; |
| 5458 | |
| 5459 | case GP_STATUS_100M: |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5460 | vars->line_speed = SPEED_100; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5461 | if (vars->duplex == DUPLEX_FULL) |
| 5462 | vars->link_status |= LINK_100TXFD; |
| 5463 | else |
| 5464 | vars->link_status |= LINK_100TXHD; |
| 5465 | break; |
| 5466 | |
| 5467 | case GP_STATUS_1G: |
| 5468 | case GP_STATUS_1G_KX: |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5469 | vars->line_speed = SPEED_1000; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5470 | if (vars->duplex == DUPLEX_FULL) |
| 5471 | vars->link_status |= LINK_1000TFD; |
| 5472 | else |
| 5473 | vars->link_status |= LINK_1000THD; |
| 5474 | break; |
| 5475 | |
| 5476 | case GP_STATUS_2_5G: |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5477 | vars->line_speed = SPEED_2500; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5478 | if (vars->duplex == DUPLEX_FULL) |
| 5479 | vars->link_status |= LINK_2500TFD; |
| 5480 | else |
| 5481 | vars->link_status |= LINK_2500THD; |
| 5482 | break; |
| 5483 | |
| 5484 | case GP_STATUS_5G: |
| 5485 | case GP_STATUS_6G: |
| 5486 | DP(NETIF_MSG_LINK, |
| 5487 | "link speed unsupported gp_status 0x%x\n", |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5488 | speed_mask); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5489 | return -EINVAL; |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 5490 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5491 | case GP_STATUS_10G_KX4: |
| 5492 | case GP_STATUS_10G_HIG: |
| 5493 | case GP_STATUS_10G_CX4: |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5494 | case GP_STATUS_10G_KR: |
| 5495 | case GP_STATUS_10G_SFI: |
| 5496 | case GP_STATUS_10G_XFI: |
| 5497 | vars->line_speed = SPEED_10000; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5498 | vars->link_status |= LINK_10GTFD; |
| 5499 | break; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5500 | case GP_STATUS_20G_DXGXS: |
| 5501 | vars->line_speed = SPEED_20000; |
| 5502 | vars->link_status |= LINK_20GTFD; |
| 5503 | break; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5504 | default: |
| 5505 | DP(NETIF_MSG_LINK, |
| 5506 | "link speed unsupported gp_status 0x%x\n", |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5507 | speed_mask); |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 5508 | return -EINVAL; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5509 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5510 | } else { /* link_down */ |
| 5511 | DP(NETIF_MSG_LINK, "phy link down\n"); |
| 5512 | |
| 5513 | vars->phy_link_up = 0; |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 5514 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5515 | vars->duplex = DUPLEX_FULL; |
David S. Miller | c0700f9 | 2008-12-16 23:53:20 -0800 | [diff] [blame] | 5516 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5517 | vars->mac_type = MAC_TYPE_NONE; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5518 | } |
| 5519 | DP(NETIF_MSG_LINK, " phy_link_up %x line_speed %d\n", |
| 5520 | vars->phy_link_up, vars->line_speed); |
| 5521 | return 0; |
| 5522 | } |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5523 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5524 | static int bnx2x_link_settings_status(struct bnx2x_phy *phy, |
| 5525 | struct link_params *params, |
| 5526 | struct link_vars *vars) |
| 5527 | { |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5528 | struct bnx2x *bp = params->bp; |
| 5529 | |
| 5530 | u16 gp_status, duplex = DUPLEX_HALF, link_up = 0, speed_mask; |
| 5531 | int rc = 0; |
| 5532 | |
| 5533 | /* Read gp_status */ |
| 5534 | CL22_RD_OVER_CL45(bp, phy, |
| 5535 | MDIO_REG_BANK_GP_STATUS, |
| 5536 | MDIO_GP_STATUS_TOP_AN_STATUS1, |
| 5537 | &gp_status); |
| 5538 | if (gp_status & MDIO_GP_STATUS_TOP_AN_STATUS1_DUPLEX_STATUS) |
| 5539 | duplex = DUPLEX_FULL; |
| 5540 | if (gp_status & MDIO_GP_STATUS_TOP_AN_STATUS1_LINK_STATUS) |
| 5541 | link_up = 1; |
| 5542 | speed_mask = gp_status & GP_STATUS_SPEED_MASK; |
| 5543 | DP(NETIF_MSG_LINK, "gp_status 0x%x, is_link_up %d, speed_mask 0x%x\n", |
| 5544 | gp_status, link_up, speed_mask); |
| 5545 | rc = bnx2x_get_link_speed_duplex(phy, params, vars, link_up, speed_mask, |
| 5546 | duplex); |
| 5547 | if (rc == -EINVAL) |
| 5548 | return rc; |
| 5549 | |
| 5550 | if (gp_status & MDIO_GP_STATUS_TOP_AN_STATUS1_LINK_STATUS) { |
| 5551 | if (SINGLE_MEDIA_DIRECT(params)) { |
| 5552 | bnx2x_flow_ctrl_resolve(phy, params, vars, gp_status); |
| 5553 | if (phy->req_line_speed == SPEED_AUTO_NEG) |
| 5554 | bnx2x_xgxs_an_resolve(phy, params, vars, |
| 5555 | gp_status); |
| 5556 | } |
| 5557 | } else { /* link_down */ |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 5558 | if ((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 5559 | SINGLE_MEDIA_DIRECT(params)) { |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5560 | /* Check signal is detected */ |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 5561 | bnx2x_check_fallback_to_cl37(phy, params); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 5562 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5563 | } |
| 5564 | |
Mintz Yuval | 9e7e839 | 2012-02-15 02:10:24 +0000 | [diff] [blame] | 5565 | /* Read LP advertised speeds*/ |
| 5566 | if (SINGLE_MEDIA_DIRECT(params) && |
| 5567 | (vars->link_status & LINK_STATUS_AUTO_NEGOTIATE_COMPLETE)) { |
| 5568 | u16 val; |
| 5569 | |
| 5570 | CL22_RD_OVER_CL45(bp, phy, MDIO_REG_BANK_CL73_IEEEB1, |
| 5571 | MDIO_CL73_IEEEB1_AN_LP_ADV2, &val); |
| 5572 | |
| 5573 | if (val & MDIO_CL73_IEEEB1_AN_ADV2_ADVR_1000M_KX) |
| 5574 | vars->link_status |= |
| 5575 | LINK_STATUS_LINK_PARTNER_1000TFD_CAPABLE; |
| 5576 | if (val & (MDIO_CL73_IEEEB1_AN_ADV2_ADVR_10G_KX4 | |
| 5577 | MDIO_CL73_IEEEB1_AN_ADV2_ADVR_10G_KR)) |
| 5578 | vars->link_status |= |
| 5579 | LINK_STATUS_LINK_PARTNER_10GXFD_CAPABLE; |
| 5580 | |
| 5581 | CL22_RD_OVER_CL45(bp, phy, MDIO_REG_BANK_OVER_1G, |
| 5582 | MDIO_OVER_1G_LP_UP1, &val); |
| 5583 | |
| 5584 | if (val & MDIO_OVER_1G_UP1_2_5G) |
| 5585 | vars->link_status |= |
| 5586 | LINK_STATUS_LINK_PARTNER_2500XFD_CAPABLE; |
| 5587 | if (val & (MDIO_OVER_1G_UP1_10G | MDIO_OVER_1G_UP1_10GH)) |
| 5588 | vars->link_status |= |
| 5589 | LINK_STATUS_LINK_PARTNER_10GXFD_CAPABLE; |
| 5590 | } |
| 5591 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5592 | DP(NETIF_MSG_LINK, "duplex %x flow_ctrl 0x%x link_status 0x%x\n", |
| 5593 | vars->duplex, vars->flow_ctrl, vars->link_status); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5594 | return rc; |
| 5595 | } |
| 5596 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5597 | static int bnx2x_warpcore_read_status(struct bnx2x_phy *phy, |
| 5598 | struct link_params *params, |
| 5599 | struct link_vars *vars) |
| 5600 | { |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5601 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5602 | u8 lane; |
| 5603 | u16 gp_status1, gp_speed, link_up, duplex = DUPLEX_FULL; |
| 5604 | int rc = 0; |
| 5605 | lane = bnx2x_get_warpcore_lane(phy, params); |
| 5606 | /* Read gp_status */ |
| 5607 | if (phy->req_line_speed > SPEED_10000) { |
| 5608 | u16 temp_link_up; |
| 5609 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 5610 | 1, &temp_link_up); |
| 5611 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 5612 | 1, &link_up); |
| 5613 | DP(NETIF_MSG_LINK, "PCS RX link status = 0x%x-->0x%x\n", |
| 5614 | temp_link_up, link_up); |
| 5615 | link_up &= (1<<2); |
| 5616 | if (link_up) |
| 5617 | bnx2x_ext_phy_resolve_fc(phy, params, vars); |
| 5618 | } else { |
| 5619 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 5620 | MDIO_WC_REG_GP2_STATUS_GP_2_1, &gp_status1); |
| 5621 | DP(NETIF_MSG_LINK, "0x81d1 = 0x%x\n", gp_status1); |
| 5622 | /* Check for either KR or generic link up. */ |
| 5623 | gp_status1 = ((gp_status1 >> 8) & 0xf) | |
| 5624 | ((gp_status1 >> 12) & 0xf); |
| 5625 | link_up = gp_status1 & (1 << lane); |
| 5626 | if (link_up && SINGLE_MEDIA_DIRECT(params)) { |
| 5627 | u16 pd, gp_status4; |
| 5628 | if (phy->req_line_speed == SPEED_AUTO_NEG) { |
| 5629 | /* Check Autoneg complete */ |
| 5630 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 5631 | MDIO_WC_REG_GP2_STATUS_GP_2_4, |
| 5632 | &gp_status4); |
| 5633 | if (gp_status4 & ((1<<12)<<lane)) |
| 5634 | vars->link_status |= |
| 5635 | LINK_STATUS_AUTO_NEGOTIATE_COMPLETE; |
| 5636 | |
| 5637 | /* Check parallel detect used */ |
| 5638 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 5639 | MDIO_WC_REG_PAR_DET_10G_STATUS, |
| 5640 | &pd); |
| 5641 | if (pd & (1<<15)) |
| 5642 | vars->link_status |= |
| 5643 | LINK_STATUS_PARALLEL_DETECTION_USED; |
| 5644 | } |
| 5645 | bnx2x_ext_phy_resolve_fc(phy, params, vars); |
| 5646 | } |
| 5647 | } |
| 5648 | |
Mintz Yuval | 9e7e839 | 2012-02-15 02:10:24 +0000 | [diff] [blame] | 5649 | if ((vars->link_status & LINK_STATUS_AUTO_NEGOTIATE_COMPLETE) && |
| 5650 | SINGLE_MEDIA_DIRECT(params)) { |
| 5651 | u16 val; |
| 5652 | |
| 5653 | bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD, |
| 5654 | MDIO_AN_REG_LP_AUTO_NEG2, &val); |
| 5655 | |
| 5656 | if (val & MDIO_CL73_IEEEB1_AN_ADV2_ADVR_1000M_KX) |
| 5657 | vars->link_status |= |
| 5658 | LINK_STATUS_LINK_PARTNER_1000TFD_CAPABLE; |
| 5659 | if (val & (MDIO_CL73_IEEEB1_AN_ADV2_ADVR_10G_KX4 | |
| 5660 | MDIO_CL73_IEEEB1_AN_ADV2_ADVR_10G_KR)) |
| 5661 | vars->link_status |= |
| 5662 | LINK_STATUS_LINK_PARTNER_10GXFD_CAPABLE; |
| 5663 | |
| 5664 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 5665 | MDIO_WC_REG_DIGITAL3_LP_UP1, &val); |
| 5666 | |
| 5667 | if (val & MDIO_OVER_1G_UP1_2_5G) |
| 5668 | vars->link_status |= |
| 5669 | LINK_STATUS_LINK_PARTNER_2500XFD_CAPABLE; |
| 5670 | if (val & (MDIO_OVER_1G_UP1_10G | MDIO_OVER_1G_UP1_10GH)) |
| 5671 | vars->link_status |= |
| 5672 | LINK_STATUS_LINK_PARTNER_10GXFD_CAPABLE; |
| 5673 | |
| 5674 | } |
| 5675 | |
| 5676 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 5677 | if (lane < 2) { |
| 5678 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 5679 | MDIO_WC_REG_GP2_STATUS_GP_2_2, &gp_speed); |
| 5680 | } else { |
| 5681 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 5682 | MDIO_WC_REG_GP2_STATUS_GP_2_3, &gp_speed); |
| 5683 | } |
| 5684 | DP(NETIF_MSG_LINK, "lane %d gp_speed 0x%x\n", lane, gp_speed); |
| 5685 | |
| 5686 | if ((lane & 1) == 0) |
| 5687 | gp_speed <<= 8; |
| 5688 | gp_speed &= 0x3f00; |
| 5689 | |
| 5690 | |
| 5691 | rc = bnx2x_get_link_speed_duplex(phy, params, vars, link_up, gp_speed, |
| 5692 | duplex); |
| 5693 | |
| 5694 | DP(NETIF_MSG_LINK, "duplex %x flow_ctrl 0x%x link_status 0x%x\n", |
| 5695 | vars->duplex, vars->flow_ctrl, vars->link_status); |
| 5696 | return rc; |
| 5697 | } |
Eilon Greenstein | ed8680a | 2009-02-12 08:37:12 +0000 | [diff] [blame] | 5698 | static void bnx2x_set_gmii_tx_driver(struct link_params *params) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5699 | { |
| 5700 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 5701 | struct bnx2x_phy *phy = ¶ms->phy[INT_PHY]; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5702 | u16 lp_up2; |
| 5703 | u16 tx_driver; |
Eilon Greenstein | c2c8b03 | 2009-02-12 08:37:14 +0000 | [diff] [blame] | 5704 | u16 bank; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5705 | |
| 5706 | /* read precomp */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5707 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5708 | MDIO_REG_BANK_OVER_1G, |
| 5709 | MDIO_OVER_1G_LP_UP2, &lp_up2); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5710 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5711 | /* bits [10:7] at lp_up2, positioned at [15:12] */ |
| 5712 | lp_up2 = (((lp_up2 & MDIO_OVER_1G_LP_UP2_PREEMPHASIS_MASK) >> |
| 5713 | MDIO_OVER_1G_LP_UP2_PREEMPHASIS_SHIFT) << |
| 5714 | MDIO_TX0_TX_DRIVER_PREEMPHASIS_SHIFT); |
| 5715 | |
Eilon Greenstein | c2c8b03 | 2009-02-12 08:37:14 +0000 | [diff] [blame] | 5716 | if (lp_up2 == 0) |
| 5717 | return; |
| 5718 | |
| 5719 | for (bank = MDIO_REG_BANK_TX0; bank <= MDIO_REG_BANK_TX3; |
| 5720 | bank += (MDIO_REG_BANK_TX1 - MDIO_REG_BANK_TX0)) { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5721 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5722 | bank, |
| 5723 | MDIO_TX0_TX_DRIVER, &tx_driver); |
Eilon Greenstein | c2c8b03 | 2009-02-12 08:37:14 +0000 | [diff] [blame] | 5724 | |
| 5725 | /* replace tx_driver bits [15:12] */ |
| 5726 | if (lp_up2 != |
| 5727 | (tx_driver & MDIO_TX0_TX_DRIVER_PREEMPHASIS_MASK)) { |
| 5728 | tx_driver &= ~MDIO_TX0_TX_DRIVER_PREEMPHASIS_MASK; |
| 5729 | tx_driver |= lp_up2; |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5730 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5731 | bank, |
| 5732 | MDIO_TX0_TX_DRIVER, tx_driver); |
Eilon Greenstein | c2c8b03 | 2009-02-12 08:37:14 +0000 | [diff] [blame] | 5733 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5734 | } |
| 5735 | } |
| 5736 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 5737 | static int bnx2x_emac_program(struct link_params *params, |
| 5738 | struct link_vars *vars) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5739 | { |
| 5740 | struct bnx2x *bp = params->bp; |
| 5741 | u8 port = params->port; |
| 5742 | u16 mode = 0; |
| 5743 | |
| 5744 | DP(NETIF_MSG_LINK, "setting link speed & duplex\n"); |
| 5745 | bnx2x_bits_dis(bp, GRCBASE_EMAC0 + port*0x400 + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5746 | EMAC_REG_EMAC_MODE, |
| 5747 | (EMAC_MODE_25G_MODE | |
| 5748 | EMAC_MODE_PORT_MII_10M | |
| 5749 | EMAC_MODE_HALF_DUPLEX)); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 5750 | switch (vars->line_speed) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5751 | case SPEED_10: |
| 5752 | mode |= EMAC_MODE_PORT_MII_10M; |
| 5753 | break; |
| 5754 | |
| 5755 | case SPEED_100: |
| 5756 | mode |= EMAC_MODE_PORT_MII; |
| 5757 | break; |
| 5758 | |
| 5759 | case SPEED_1000: |
| 5760 | mode |= EMAC_MODE_PORT_GMII; |
| 5761 | break; |
| 5762 | |
| 5763 | case SPEED_2500: |
| 5764 | mode |= (EMAC_MODE_25G_MODE | EMAC_MODE_PORT_GMII); |
| 5765 | break; |
| 5766 | |
| 5767 | default: |
| 5768 | /* 10G not valid for EMAC */ |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 5769 | DP(NETIF_MSG_LINK, "Invalid line_speed 0x%x\n", |
| 5770 | vars->line_speed); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5771 | return -EINVAL; |
| 5772 | } |
| 5773 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 5774 | if (vars->duplex == DUPLEX_HALF) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5775 | mode |= EMAC_MODE_HALF_DUPLEX; |
| 5776 | bnx2x_bits_en(bp, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5777 | GRCBASE_EMAC0 + port*0x400 + EMAC_REG_EMAC_MODE, |
| 5778 | mode); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5779 | |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 5780 | bnx2x_set_led(params, vars, LED_MODE_OPER, vars->line_speed); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5781 | return 0; |
| 5782 | } |
| 5783 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5784 | static void bnx2x_set_preemphasis(struct bnx2x_phy *phy, |
| 5785 | struct link_params *params) |
| 5786 | { |
| 5787 | |
| 5788 | u16 bank, i = 0; |
| 5789 | struct bnx2x *bp = params->bp; |
| 5790 | |
| 5791 | for (bank = MDIO_REG_BANK_RX0, i = 0; bank <= MDIO_REG_BANK_RX3; |
| 5792 | bank += (MDIO_REG_BANK_RX1-MDIO_REG_BANK_RX0), i++) { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5793 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5794 | bank, |
| 5795 | MDIO_RX0_RX_EQ_BOOST, |
| 5796 | phy->rx_preemphasis[i]); |
| 5797 | } |
| 5798 | |
| 5799 | for (bank = MDIO_REG_BANK_TX0, i = 0; bank <= MDIO_REG_BANK_TX3; |
| 5800 | bank += (MDIO_REG_BANK_TX1 - MDIO_REG_BANK_TX0), i++) { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 5801 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5802 | bank, |
| 5803 | MDIO_TX0_TX_DRIVER, |
| 5804 | phy->tx_preemphasis[i]); |
| 5805 | } |
| 5806 | } |
| 5807 | |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 5808 | static void bnx2x_xgxs_config_init(struct bnx2x_phy *phy, |
| 5809 | struct link_params *params, |
| 5810 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5811 | { |
| 5812 | struct bnx2x *bp = params->bp; |
| 5813 | u8 enable_cl73 = (SINGLE_MEDIA_DIRECT(params) || |
| 5814 | (params->loopback_mode == LOOPBACK_XGXS)); |
| 5815 | if (!(vars->phy_flags & PHY_SGMII_FLAG)) { |
| 5816 | if (SINGLE_MEDIA_DIRECT(params) && |
| 5817 | (params->feature_config_flags & |
| 5818 | FEATURE_CONFIG_OVERRIDE_PREEMPHASIS_ENABLED)) |
| 5819 | bnx2x_set_preemphasis(phy, params); |
| 5820 | |
| 5821 | /* forced speed requested? */ |
| 5822 | if (vars->line_speed != SPEED_AUTO_NEG || |
| 5823 | (SINGLE_MEDIA_DIRECT(params) && |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5824 | params->loopback_mode == LOOPBACK_EXT)) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5825 | DP(NETIF_MSG_LINK, "not SGMII, no AN\n"); |
| 5826 | |
| 5827 | /* disable autoneg */ |
| 5828 | bnx2x_set_autoneg(phy, params, vars, 0); |
| 5829 | |
| 5830 | /* program speed and duplex */ |
| 5831 | bnx2x_program_serdes(phy, params, vars); |
| 5832 | |
| 5833 | } else { /* AN_mode */ |
| 5834 | DP(NETIF_MSG_LINK, "not SGMII, AN\n"); |
| 5835 | |
| 5836 | /* AN enabled */ |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 5837 | bnx2x_set_brcm_cl37_advertisement(phy, params); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5838 | |
| 5839 | /* program duplex & pause advertisement (for aneg) */ |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 5840 | bnx2x_set_ieee_aneg_advertisement(phy, params, |
| 5841 | vars->ieee_fc); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5842 | |
| 5843 | /* enable autoneg */ |
| 5844 | bnx2x_set_autoneg(phy, params, vars, enable_cl73); |
| 5845 | |
| 5846 | /* enable and restart AN */ |
| 5847 | bnx2x_restart_autoneg(phy, params, enable_cl73); |
| 5848 | } |
| 5849 | |
| 5850 | } else { /* SGMII mode */ |
| 5851 | DP(NETIF_MSG_LINK, "SGMII\n"); |
| 5852 | |
| 5853 | bnx2x_initialize_sgmii_process(phy, params, vars); |
| 5854 | } |
| 5855 | } |
| 5856 | |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 5857 | static int bnx2x_prepare_xgxs(struct bnx2x_phy *phy, |
| 5858 | struct link_params *params, |
| 5859 | struct link_vars *vars) |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 5860 | { |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 5861 | int rc; |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 5862 | vars->phy_flags |= PHY_XGXS_FLAG; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 5863 | if ((phy->req_line_speed && |
| 5864 | ((phy->req_line_speed == SPEED_100) || |
| 5865 | (phy->req_line_speed == SPEED_10))) || |
| 5866 | (!phy->req_line_speed && |
| 5867 | (phy->speed_cap_mask >= |
| 5868 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_FULL) && |
| 5869 | (phy->speed_cap_mask < |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 5870 | PORT_HW_CFG_SPEED_CAPABILITY_D0_1G)) || |
| 5871 | (phy->type == PORT_HW_CFG_SERDES_EXT_PHY_TYPE_DIRECT_SD)) |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 5872 | vars->phy_flags |= PHY_SGMII_FLAG; |
| 5873 | else |
| 5874 | vars->phy_flags &= ~PHY_SGMII_FLAG; |
| 5875 | |
| 5876 | bnx2x_calc_ieee_aneg_adv(phy, params, &vars->ieee_fc); |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 5877 | bnx2x_set_aer_mmd(params, phy); |
| 5878 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT) |
| 5879 | bnx2x_set_master_ln(params, phy); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 5880 | |
| 5881 | rc = bnx2x_reset_unicore(params, phy, 0); |
| 5882 | /* reset the SerDes and wait for reset bit return low */ |
| 5883 | if (rc != 0) |
| 5884 | return rc; |
| 5885 | |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 5886 | bnx2x_set_aer_mmd(params, phy); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 5887 | /* setting the masterLn_def again after the reset */ |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 5888 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT) { |
| 5889 | bnx2x_set_master_ln(params, phy); |
| 5890 | bnx2x_set_swap_lanes(params, phy); |
| 5891 | } |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 5892 | |
| 5893 | return rc; |
| 5894 | } |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 5895 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 5896 | static u16 bnx2x_wait_reset_complete(struct bnx2x *bp, |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 5897 | struct bnx2x_phy *phy, |
| 5898 | struct link_params *params) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5899 | { |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 5900 | u16 cnt, ctrl; |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 5901 | /* Wait for soft reset to get cleared up to 1 sec */ |
Yaniv Rosner | 62b29a5 | 2010-09-07 11:40:58 +0000 | [diff] [blame] | 5902 | for (cnt = 0; cnt < 1000; cnt++) { |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 5903 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54618SE) |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 5904 | bnx2x_cl22_read(bp, phy, |
| 5905 | MDIO_PMA_REG_CTRL, &ctrl); |
| 5906 | else |
| 5907 | bnx2x_cl45_read(bp, phy, |
| 5908 | MDIO_PMA_DEVAD, |
| 5909 | MDIO_PMA_REG_CTRL, &ctrl); |
Yaniv Rosner | 62b29a5 | 2010-09-07 11:40:58 +0000 | [diff] [blame] | 5910 | if (!(ctrl & (1<<15))) |
| 5911 | break; |
| 5912 | msleep(1); |
| 5913 | } |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 5914 | |
| 5915 | if (cnt == 1000) |
| 5916 | netdev_err(bp->dev, "Warning: PHY was not initialized," |
| 5917 | " Port %d\n", |
| 5918 | params->port); |
Yaniv Rosner | 62b29a5 | 2010-09-07 11:40:58 +0000 | [diff] [blame] | 5919 | DP(NETIF_MSG_LINK, "control reg 0x%x (after %d ms)\n", ctrl, cnt); |
| 5920 | return cnt; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 5921 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5922 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5923 | static void bnx2x_link_int_enable(struct link_params *params) |
| 5924 | { |
| 5925 | u8 port = params->port; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5926 | u32 mask; |
| 5927 | struct bnx2x *bp = params->bp; |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 5928 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5929 | /* 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] | 5930 | if (CHIP_IS_E3(bp)) { |
| 5931 | mask = NIG_MASK_XGXS0_LINK_STATUS; |
| 5932 | if (!(SINGLE_MEDIA_DIRECT(params))) |
| 5933 | mask |= NIG_MASK_MI_INT; |
| 5934 | } else if (params->switch_cfg == SWITCH_CFG_10G) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5935 | mask = (NIG_MASK_XGXS0_LINK10G | |
| 5936 | NIG_MASK_XGXS0_LINK_STATUS); |
| 5937 | DP(NETIF_MSG_LINK, "enabled XGXS interrupt\n"); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 5938 | if (!(SINGLE_MEDIA_DIRECT(params)) && |
| 5939 | params->phy[INT_PHY].type != |
| 5940 | PORT_HW_CFG_XGXS_EXT_PHY_TYPE_FAILURE) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5941 | mask |= NIG_MASK_MI_INT; |
| 5942 | DP(NETIF_MSG_LINK, "enabled external phy int\n"); |
| 5943 | } |
| 5944 | |
| 5945 | } else { /* SerDes */ |
| 5946 | mask = NIG_MASK_SERDES0_LINK_STATUS; |
| 5947 | DP(NETIF_MSG_LINK, "enabled SerDes interrupt\n"); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 5948 | if (!(SINGLE_MEDIA_DIRECT(params)) && |
| 5949 | params->phy[INT_PHY].type != |
| 5950 | PORT_HW_CFG_SERDES_EXT_PHY_TYPE_NOT_CONN) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5951 | mask |= NIG_MASK_MI_INT; |
| 5952 | DP(NETIF_MSG_LINK, "enabled external phy int\n"); |
| 5953 | } |
| 5954 | } |
| 5955 | bnx2x_bits_en(bp, |
| 5956 | NIG_REG_MASK_INTERRUPT_PORT0 + port*4, |
| 5957 | mask); |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 5958 | |
| 5959 | 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] | 5960 | (params->switch_cfg == SWITCH_CFG_10G), |
| 5961 | REG_RD(bp, NIG_REG_STATUS_INTERRUPT_PORT0 + port*4)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 5962 | DP(NETIF_MSG_LINK, " int_mask 0x%x, MI_INT %x, SERDES_LINK %x\n", |
| 5963 | REG_RD(bp, NIG_REG_MASK_INTERRUPT_PORT0 + port*4), |
| 5964 | REG_RD(bp, NIG_REG_EMAC0_STATUS_MISC_MI_INT + port*0x18), |
| 5965 | REG_RD(bp, NIG_REG_SERDES0_STATUS_LINK_STATUS+port*0x3c)); |
| 5966 | DP(NETIF_MSG_LINK, " 10G %x, XGXS_LINK %x\n", |
| 5967 | REG_RD(bp, NIG_REG_XGXS0_STATUS_LINK10G + port*0x68), |
| 5968 | REG_RD(bp, NIG_REG_XGXS0_STATUS_LINK_STATUS + port*0x68)); |
| 5969 | } |
| 5970 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5971 | static void bnx2x_rearm_latch_signal(struct bnx2x *bp, u8 port, |
| 5972 | u8 exp_mi_int) |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 5973 | { |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5974 | u32 latch_status = 0; |
| 5975 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5976 | /* |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5977 | * Disable the MI INT ( external phy int ) by writing 1 to the |
| 5978 | * status register. Link down indication is high-active-signal, |
| 5979 | * 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] | 5980 | */ |
| 5981 | /* Read Latched signals */ |
| 5982 | latch_status = REG_RD(bp, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5983 | NIG_REG_LATCH_STATUS_0 + port*8); |
| 5984 | DP(NETIF_MSG_LINK, "latch_status = 0x%x\n", latch_status); |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 5985 | /* Handle only those with latched-signal=up.*/ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5986 | if (exp_mi_int) |
| 5987 | bnx2x_bits_en(bp, |
| 5988 | NIG_REG_STATUS_INTERRUPT_PORT0 |
| 5989 | + port*4, |
| 5990 | NIG_STATUS_EMAC0_MI_INT); |
| 5991 | else |
| 5992 | bnx2x_bits_dis(bp, |
| 5993 | NIG_REG_STATUS_INTERRUPT_PORT0 |
| 5994 | + port*4, |
| 5995 | NIG_STATUS_EMAC0_MI_INT); |
| 5996 | |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 5997 | if (latch_status & 1) { |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5998 | |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 5999 | /* For all latched-signal=up : Re-Arm Latch signals */ |
| 6000 | REG_WR(bp, NIG_REG_LATCH_STATUS_0 + port*8, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6001 | (latch_status & 0xfffe) | (latch_status & 1)); |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 6002 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6003 | /* For all latched-signal=up,Write original_signal to status */ |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 6004 | } |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 6005 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6006 | static void bnx2x_link_int_ack(struct link_params *params, |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6007 | struct link_vars *vars, u8 is_10g_plus) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6008 | { |
| 6009 | struct bnx2x *bp = params->bp; |
| 6010 | u8 port = params->port; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6011 | u32 mask; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6012 | /* |
| 6013 | * First reset all status we assume only one line will be |
| 6014 | * change at a time |
| 6015 | */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6016 | bnx2x_bits_dis(bp, NIG_REG_STATUS_INTERRUPT_PORT0 + port*4, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6017 | (NIG_STATUS_XGXS0_LINK10G | |
| 6018 | NIG_STATUS_XGXS0_LINK_STATUS | |
| 6019 | NIG_STATUS_SERDES0_LINK_STATUS)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6020 | if (vars->phy_link_up) { |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6021 | if (USES_WARPCORE(bp)) |
| 6022 | mask = NIG_STATUS_XGXS0_LINK_STATUS; |
| 6023 | else { |
| 6024 | if (is_10g_plus) |
| 6025 | mask = NIG_STATUS_XGXS0_LINK10G; |
| 6026 | else if (params->switch_cfg == SWITCH_CFG_10G) { |
| 6027 | /* |
| 6028 | * Disable the link interrupt by writing 1 to |
| 6029 | * the relevant lane in the status register |
| 6030 | */ |
| 6031 | u32 ser_lane = |
| 6032 | ((params->lane_config & |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6033 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_MASK) >> |
| 6034 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_SHIFT); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6035 | mask = ((1 << ser_lane) << |
| 6036 | NIG_STATUS_XGXS0_LINK_STATUS_SIZE); |
| 6037 | } else |
| 6038 | mask = NIG_STATUS_SERDES0_LINK_STATUS; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6039 | } |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6040 | DP(NETIF_MSG_LINK, "Ack link up interrupt with mask 0x%x\n", |
| 6041 | mask); |
| 6042 | bnx2x_bits_en(bp, |
| 6043 | NIG_REG_STATUS_INTERRUPT_PORT0 + port*4, |
| 6044 | mask); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6045 | } |
| 6046 | } |
| 6047 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6048 | static int bnx2x_format_ver(u32 num, u8 *str, u16 *len) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6049 | { |
| 6050 | u8 *str_ptr = str; |
| 6051 | u32 mask = 0xf0000000; |
| 6052 | u8 shift = 8*4; |
| 6053 | u8 digit; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6054 | u8 remove_leading_zeros = 1; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6055 | if (*len < 10) { |
Frederik Schwarzer | 025dfda | 2008-10-16 19:02:37 +0200 | [diff] [blame] | 6056 | /* Need more than 10chars for this format */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6057 | *str_ptr = '\0'; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6058 | (*len)--; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6059 | return -EINVAL; |
| 6060 | } |
| 6061 | while (shift > 0) { |
| 6062 | |
| 6063 | shift -= 4; |
| 6064 | digit = ((num & mask) >> shift); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6065 | if (digit == 0 && remove_leading_zeros) { |
| 6066 | mask = mask >> 4; |
| 6067 | continue; |
| 6068 | } else if (digit < 0xa) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6069 | *str_ptr = digit + '0'; |
| 6070 | else |
| 6071 | *str_ptr = digit - 0xa + 'a'; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6072 | remove_leading_zeros = 0; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6073 | str_ptr++; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6074 | (*len)--; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6075 | mask = mask >> 4; |
| 6076 | if (shift == 4*4) { |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6077 | *str_ptr = '.'; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6078 | str_ptr++; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6079 | (*len)--; |
| 6080 | remove_leading_zeros = 1; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6081 | } |
| 6082 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6083 | return 0; |
| 6084 | } |
| 6085 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6086 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6087 | 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] | 6088 | { |
| 6089 | str[0] = '\0'; |
| 6090 | (*len)--; |
| 6091 | return 0; |
| 6092 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6093 | |
Mintz Yuval | a1e785e | 2012-02-15 02:10:32 +0000 | [diff] [blame] | 6094 | int bnx2x_get_ext_phy_fw_version(struct link_params *params, u8 *version, |
| 6095 | u16 len) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6096 | { |
Julia Lawall | 0376d5b | 2009-07-19 05:26:35 +0000 | [diff] [blame] | 6097 | struct bnx2x *bp; |
Eilon Greenstein | a35da8d | 2009-02-12 08:37:02 +0000 | [diff] [blame] | 6098 | u32 spirom_ver = 0; |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6099 | int status = 0; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6100 | u8 *ver_p = version; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6101 | u16 remain_len = len; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6102 | if (version == NULL || params == NULL) |
| 6103 | return -EINVAL; |
Julia Lawall | 0376d5b | 2009-07-19 05:26:35 +0000 | [diff] [blame] | 6104 | bp = params->bp; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6105 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6106 | /* Extract first external phy*/ |
| 6107 | version[0] = '\0'; |
| 6108 | spirom_ver = REG_RD(bp, params->phy[EXT_PHY1].ver_addr); |
Eilon Greenstein | a35da8d | 2009-02-12 08:37:02 +0000 | [diff] [blame] | 6109 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6110 | if (params->phy[EXT_PHY1].format_fw_ver) { |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6111 | status |= params->phy[EXT_PHY1].format_fw_ver(spirom_ver, |
| 6112 | ver_p, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6113 | &remain_len); |
| 6114 | ver_p += (len - remain_len); |
| 6115 | } |
| 6116 | if ((params->num_phys == MAX_PHYS) && |
| 6117 | (params->phy[EXT_PHY2].ver_addr != 0)) { |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6118 | spirom_ver = REG_RD(bp, params->phy[EXT_PHY2].ver_addr); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6119 | if (params->phy[EXT_PHY2].format_fw_ver) { |
| 6120 | *ver_p = '/'; |
| 6121 | ver_p++; |
| 6122 | remain_len--; |
| 6123 | status |= params->phy[EXT_PHY2].format_fw_ver( |
| 6124 | spirom_ver, |
| 6125 | ver_p, |
| 6126 | &remain_len); |
| 6127 | ver_p = version + (len - remain_len); |
| 6128 | } |
| 6129 | } |
| 6130 | *ver_p = '\0'; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6131 | return status; |
| 6132 | } |
| 6133 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 6134 | static void bnx2x_set_xgxs_loopback(struct bnx2x_phy *phy, |
Yaniv Rosner | 62b29a5 | 2010-09-07 11:40:58 +0000 | [diff] [blame] | 6135 | struct link_params *params) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6136 | { |
| 6137 | u8 port = params->port; |
| 6138 | struct bnx2x *bp = params->bp; |
| 6139 | |
Yaniv Rosner | 62b29a5 | 2010-09-07 11:40:58 +0000 | [diff] [blame] | 6140 | if (phy->req_line_speed != SPEED_1000) { |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6141 | u32 md_devad = 0; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6142 | |
| 6143 | DP(NETIF_MSG_LINK, "XGXS 10G loopback enable\n"); |
| 6144 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6145 | if (!CHIP_IS_E3(bp)) { |
| 6146 | /* change the uni_phy_addr in the nig */ |
| 6147 | md_devad = REG_RD(bp, (NIG_REG_XGXS0_CTRL_MD_DEVAD + |
| 6148 | port*0x18)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6149 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6150 | REG_WR(bp, NIG_REG_XGXS0_CTRL_MD_DEVAD + port*0x18, |
| 6151 | 0x5); |
| 6152 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6153 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 6154 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6155 | 5, |
| 6156 | (MDIO_REG_BANK_AER_BLOCK + |
| 6157 | (MDIO_AER_BLOCK_AER_REG & 0xf)), |
| 6158 | 0x2800); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6159 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 6160 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6161 | 5, |
| 6162 | (MDIO_REG_BANK_CL73_IEEEB0 + |
| 6163 | (MDIO_CL73_IEEEB0_CL73_AN_CONTROL & 0xf)), |
| 6164 | 0x6041); |
Eilon Greenstein | 3858276 | 2009-01-14 06:44:16 +0000 | [diff] [blame] | 6165 | msleep(200); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6166 | /* set aer mmd back */ |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 6167 | bnx2x_set_aer_mmd(params, phy); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6168 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6169 | if (!CHIP_IS_E3(bp)) { |
| 6170 | /* and md_devad */ |
| 6171 | REG_WR(bp, NIG_REG_XGXS0_CTRL_MD_DEVAD + port*0x18, |
| 6172 | md_devad); |
| 6173 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6174 | } else { |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 6175 | u16 mii_ctrl; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6176 | DP(NETIF_MSG_LINK, "XGXS 1G loopback enable\n"); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 6177 | bnx2x_cl45_read(bp, phy, 5, |
| 6178 | (MDIO_REG_BANK_COMBO_IEEE0 + |
| 6179 | (MDIO_COMBO_IEEE0_MII_CONTROL & 0xf)), |
| 6180 | &mii_ctrl); |
| 6181 | bnx2x_cl45_write(bp, phy, 5, |
| 6182 | (MDIO_REG_BANK_COMBO_IEEE0 + |
| 6183 | (MDIO_COMBO_IEEE0_MII_CONTROL & 0xf)), |
| 6184 | mii_ctrl | |
| 6185 | MDIO_COMBO_IEEO_MII_CONTROL_LOOPBACK); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6186 | } |
| 6187 | } |
| 6188 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6189 | int bnx2x_set_led(struct link_params *params, |
| 6190 | struct link_vars *vars, u8 mode, u32 speed) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6191 | { |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 6192 | u8 port = params->port; |
| 6193 | u16 hw_led_mode = params->hw_led_mode; |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6194 | int rc = 0; |
| 6195 | u8 phy_idx; |
Eilon Greenstein | 345b5d5 | 2008-08-13 15:58:12 -0700 | [diff] [blame] | 6196 | u32 tmp; |
| 6197 | u32 emac_base = port ? GRCBASE_EMAC1 : GRCBASE_EMAC0; |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 6198 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6199 | DP(NETIF_MSG_LINK, "bnx2x_set_led: port %x, mode %d\n", port, mode); |
| 6200 | DP(NETIF_MSG_LINK, "speed 0x%x, hw_led_mode 0x%x\n", |
| 6201 | speed, hw_led_mode); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6202 | /* In case */ |
| 6203 | for (phy_idx = EXT_PHY1; phy_idx < MAX_PHYS; phy_idx++) { |
| 6204 | if (params->phy[phy_idx].set_link_led) { |
| 6205 | params->phy[phy_idx].set_link_led( |
| 6206 | ¶ms->phy[phy_idx], params, mode); |
| 6207 | } |
| 6208 | } |
| 6209 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6210 | switch (mode) { |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6211 | case LED_MODE_FRONT_PANEL_OFF: |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6212 | case LED_MODE_OFF: |
| 6213 | REG_WR(bp, NIG_REG_LED_10G_P0 + port*4, 0); |
| 6214 | REG_WR(bp, NIG_REG_LED_MODE_P0 + port*4, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6215 | SHARED_HW_CFG_LED_MAC1); |
Eilon Greenstein | 345b5d5 | 2008-08-13 15:58:12 -0700 | [diff] [blame] | 6216 | |
| 6217 | tmp = EMAC_RD(bp, EMAC_REG_EMAC_LED); |
Yaniv Rosner | 001cea7 | 2011-10-27 05:09:48 +0000 | [diff] [blame] | 6218 | if (params->phy[EXT_PHY1].type == |
Yaniv Rosner | 9379c9b | 2012-04-04 01:28:58 +0000 | [diff] [blame^] | 6219 | PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54618SE) |
| 6220 | tmp &= ~(EMAC_LED_1000MB_OVERRIDE | |
| 6221 | EMAC_LED_100MB_OVERRIDE | |
| 6222 | EMAC_LED_10MB_OVERRIDE); |
| 6223 | else |
| 6224 | tmp |= EMAC_LED_OVERRIDE; |
| 6225 | |
| 6226 | EMAC_WR(bp, EMAC_REG_EMAC_LED, tmp); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6227 | break; |
| 6228 | |
| 6229 | case LED_MODE_OPER: |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6230 | /* |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6231 | * For all other phys, OPER mode is same as ON, so in case |
| 6232 | * link is down, do nothing |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6233 | */ |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6234 | if (!vars->link_up) |
| 6235 | break; |
| 6236 | case LED_MODE_ON: |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 6237 | if (((params->phy[EXT_PHY1].type == |
| 6238 | PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727) || |
| 6239 | (params->phy[EXT_PHY1].type == |
| 6240 | PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8722)) && |
Yaniv Rosner | 1f48353 | 2011-01-18 04:33:31 +0000 | [diff] [blame] | 6241 | CHIP_IS_E2(bp) && params->num_phys == 2) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6242 | /* |
| 6243 | * This is a work-around for E2+8727 Configurations |
| 6244 | */ |
Yaniv Rosner | 1f48353 | 2011-01-18 04:33:31 +0000 | [diff] [blame] | 6245 | if (mode == LED_MODE_ON || |
| 6246 | speed == SPEED_10000){ |
| 6247 | REG_WR(bp, NIG_REG_LED_MODE_P0 + port*4, 0); |
| 6248 | REG_WR(bp, NIG_REG_LED_10G_P0 + port*4, 1); |
| 6249 | |
| 6250 | tmp = EMAC_RD(bp, EMAC_REG_EMAC_LED); |
| 6251 | EMAC_WR(bp, EMAC_REG_EMAC_LED, |
| 6252 | (tmp | EMAC_LED_OVERRIDE)); |
Yaniv Rosner | 793bd45 | 2011-08-02 22:59:40 +0000 | [diff] [blame] | 6253 | /* |
| 6254 | * return here without enabling traffic |
David S. Miller | 8decf86 | 2011-09-22 03:23:13 -0400 | [diff] [blame] | 6255 | * LED blink and setting rate in ON mode. |
Yaniv Rosner | 793bd45 | 2011-08-02 22:59:40 +0000 | [diff] [blame] | 6256 | * In oper mode, enabling LED blink |
| 6257 | * and setting rate is needed. |
| 6258 | */ |
| 6259 | if (mode == LED_MODE_ON) |
| 6260 | return rc; |
Yaniv Rosner | 1f48353 | 2011-01-18 04:33:31 +0000 | [diff] [blame] | 6261 | } |
Yaniv Rosner | 793bd45 | 2011-08-02 22:59:40 +0000 | [diff] [blame] | 6262 | } else if (SINGLE_MEDIA_DIRECT(params)) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6263 | /* |
| 6264 | * This is a work-around for HW issue found when link |
| 6265 | * is up in CL73 |
| 6266 | */ |
David S. Miller | 8decf86 | 2011-09-22 03:23:13 -0400 | [diff] [blame] | 6267 | if ((!CHIP_IS_E3(bp)) || |
| 6268 | (CHIP_IS_E3(bp) && |
| 6269 | mode == LED_MODE_ON)) |
| 6270 | REG_WR(bp, NIG_REG_LED_10G_P0 + port*4, 1); |
| 6271 | |
Yaniv Rosner | 793bd45 | 2011-08-02 22:59:40 +0000 | [diff] [blame] | 6272 | if (CHIP_IS_E1x(bp) || |
| 6273 | CHIP_IS_E2(bp) || |
| 6274 | (mode == LED_MODE_ON)) |
| 6275 | REG_WR(bp, NIG_REG_LED_MODE_P0 + port*4, 0); |
| 6276 | else |
| 6277 | REG_WR(bp, NIG_REG_LED_MODE_P0 + port*4, |
| 6278 | hw_led_mode); |
Yaniv Rosner | 001cea7 | 2011-10-27 05:09:48 +0000 | [diff] [blame] | 6279 | } else if ((params->phy[EXT_PHY1].type == |
| 6280 | PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54618SE) && |
Yaniv Rosner | 9379c9b | 2012-04-04 01:28:58 +0000 | [diff] [blame^] | 6281 | (mode == LED_MODE_ON)) { |
Yaniv Rosner | 001cea7 | 2011-10-27 05:09:48 +0000 | [diff] [blame] | 6282 | REG_WR(bp, NIG_REG_LED_MODE_P0 + port*4, 0); |
| 6283 | tmp = EMAC_RD(bp, EMAC_REG_EMAC_LED); |
Yaniv Rosner | 9379c9b | 2012-04-04 01:28:58 +0000 | [diff] [blame^] | 6284 | EMAC_WR(bp, EMAC_REG_EMAC_LED, tmp | |
| 6285 | EMAC_LED_OVERRIDE | EMAC_LED_1000MB_OVERRIDE); |
| 6286 | /* Break here; otherwise, it'll disable the |
| 6287 | * intended override. |
| 6288 | */ |
| 6289 | break; |
Yaniv Rosner | 793bd45 | 2011-08-02 22:59:40 +0000 | [diff] [blame] | 6290 | } else |
Yaniv Rosner | 001cea7 | 2011-10-27 05:09:48 +0000 | [diff] [blame] | 6291 | REG_WR(bp, NIG_REG_LED_MODE_P0 + port*4, |
| 6292 | hw_led_mode); |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 6293 | |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6294 | 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] | 6295 | /* Set blinking rate to ~15.9Hz */ |
Yaniv Rosner | 26ffaf3 | 2011-10-27 05:09:45 +0000 | [diff] [blame] | 6296 | if (CHIP_IS_E3(bp)) |
| 6297 | REG_WR(bp, NIG_REG_LED_CONTROL_BLINK_RATE_P0 + port*4, |
| 6298 | LED_BLINK_RATE_VAL_E3); |
| 6299 | else |
| 6300 | REG_WR(bp, NIG_REG_LED_CONTROL_BLINK_RATE_P0 + port*4, |
| 6301 | LED_BLINK_RATE_VAL_E1X_E2); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6302 | REG_WR(bp, NIG_REG_LED_CONTROL_BLINK_RATE_ENA_P0 + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6303 | port*4, 1); |
Yaniv Rosner | 9379c9b | 2012-04-04 01:28:58 +0000 | [diff] [blame^] | 6304 | tmp = EMAC_RD(bp, EMAC_REG_EMAC_LED); |
| 6305 | EMAC_WR(bp, EMAC_REG_EMAC_LED, |
| 6306 | (tmp & (~EMAC_LED_OVERRIDE))); |
Eilon Greenstein | 345b5d5 | 2008-08-13 15:58:12 -0700 | [diff] [blame] | 6307 | |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 6308 | if (CHIP_IS_E1(bp) && |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 6309 | ((speed == SPEED_2500) || |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6310 | (speed == SPEED_1000) || |
| 6311 | (speed == SPEED_100) || |
| 6312 | (speed == SPEED_10))) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6313 | /* |
| 6314 | * On Everest 1 Ax chip versions for speeds less than |
| 6315 | * 10G LED scheme is different |
| 6316 | */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6317 | REG_WR(bp, NIG_REG_LED_CONTROL_OVERRIDE_TRAFFIC_P0 |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6318 | + port*4, 1); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6319 | REG_WR(bp, NIG_REG_LED_CONTROL_TRAFFIC_P0 + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6320 | port*4, 0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6321 | REG_WR(bp, NIG_REG_LED_CONTROL_BLINK_TRAFFIC_P0 + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6322 | port*4, 1); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6323 | } |
| 6324 | break; |
| 6325 | |
| 6326 | default: |
| 6327 | rc = -EINVAL; |
| 6328 | DP(NETIF_MSG_LINK, "bnx2x_set_led: Invalid led mode %d\n", |
| 6329 | mode); |
| 6330 | break; |
| 6331 | } |
| 6332 | return rc; |
| 6333 | |
| 6334 | } |
| 6335 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6336 | /* |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6337 | * This function comes to reflect the actual link state read DIRECTLY from the |
| 6338 | * HW |
| 6339 | */ |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6340 | int bnx2x_test_link(struct link_params *params, struct link_vars *vars, |
| 6341 | u8 is_serdes) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6342 | { |
| 6343 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 6344 | u16 gp_status = 0, phy_index = 0; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6345 | u8 ext_phy_link_up = 0, serdes_phy_type; |
| 6346 | struct link_vars temp_vars; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6347 | struct bnx2x_phy *int_phy = ¶ms->phy[INT_PHY]; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6348 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6349 | if (CHIP_IS_E3(bp)) { |
| 6350 | u16 link_up; |
| 6351 | if (params->req_line_speed[LINK_CONFIG_IDX(INT_PHY)] |
| 6352 | > SPEED_10000) { |
| 6353 | /* Check 20G link */ |
| 6354 | bnx2x_cl45_read(bp, int_phy, MDIO_WC_DEVAD, |
| 6355 | 1, &link_up); |
| 6356 | bnx2x_cl45_read(bp, int_phy, MDIO_WC_DEVAD, |
| 6357 | 1, &link_up); |
| 6358 | link_up &= (1<<2); |
| 6359 | } else { |
| 6360 | /* Check 10G link and below*/ |
| 6361 | u8 lane = bnx2x_get_warpcore_lane(int_phy, params); |
| 6362 | bnx2x_cl45_read(bp, int_phy, MDIO_WC_DEVAD, |
| 6363 | MDIO_WC_REG_GP2_STATUS_GP_2_1, |
| 6364 | &gp_status); |
| 6365 | gp_status = ((gp_status >> 8) & 0xf) | |
| 6366 | ((gp_status >> 12) & 0xf); |
| 6367 | link_up = gp_status & (1 << lane); |
| 6368 | } |
| 6369 | if (!link_up) |
| 6370 | return -ESRCH; |
| 6371 | } else { |
| 6372 | CL22_RD_OVER_CL45(bp, int_phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6373 | MDIO_REG_BANK_GP_STATUS, |
| 6374 | MDIO_GP_STATUS_TOP_AN_STATUS1, |
| 6375 | &gp_status); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6376 | /* 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] | 6377 | if (!(gp_status & MDIO_GP_STATUS_TOP_AN_STATUS1_LINK_STATUS)) |
| 6378 | return -ESRCH; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6379 | } |
| 6380 | /* In XGXS loopback mode, do not check external PHY */ |
| 6381 | if (params->loopback_mode == LOOPBACK_XGXS) |
| 6382 | return 0; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6383 | |
| 6384 | switch (params->num_phys) { |
| 6385 | case 1: |
| 6386 | /* No external PHY */ |
| 6387 | return 0; |
| 6388 | case 2: |
| 6389 | ext_phy_link_up = params->phy[EXT_PHY1].read_status( |
| 6390 | ¶ms->phy[EXT_PHY1], |
| 6391 | params, &temp_vars); |
| 6392 | break; |
| 6393 | case 3: /* Dual Media */ |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 6394 | for (phy_index = EXT_PHY1; phy_index < params->num_phys; |
| 6395 | phy_index++) { |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6396 | serdes_phy_type = ((params->phy[phy_index].media_type == |
| 6397 | ETH_PHY_SFP_FIBER) || |
| 6398 | (params->phy[phy_index].media_type == |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 6399 | ETH_PHY_XFP_FIBER) || |
| 6400 | (params->phy[phy_index].media_type == |
| 6401 | ETH_PHY_DA_TWINAX)); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6402 | |
| 6403 | if (is_serdes != serdes_phy_type) |
| 6404 | continue; |
| 6405 | if (params->phy[phy_index].read_status) { |
| 6406 | ext_phy_link_up |= |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 6407 | params->phy[phy_index].read_status( |
| 6408 | ¶ms->phy[phy_index], |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6409 | params, &temp_vars); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6410 | } |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 6411 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6412 | break; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6413 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6414 | if (ext_phy_link_up) |
| 6415 | return 0; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6416 | return -ESRCH; |
| 6417 | } |
| 6418 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6419 | static int bnx2x_link_initialize(struct link_params *params, |
| 6420 | struct link_vars *vars) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6421 | { |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6422 | int rc = 0; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6423 | u8 phy_index, non_ext_phy; |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 6424 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6425 | /* |
| 6426 | * In case of external phy existence, the line speed would be the |
| 6427 | * line speed linked up by the external phy. In case it is direct |
| 6428 | * only, then the line_speed during initialization will be |
| 6429 | * equal to the req_line_speed |
| 6430 | */ |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 6431 | vars->line_speed = params->phy[INT_PHY].req_line_speed; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6432 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6433 | /* |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 6434 | * Initialize the internal phy in case this is a direct board |
| 6435 | * (no external phys), or this board has external phy which requires |
| 6436 | * to first. |
| 6437 | */ |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6438 | if (!USES_WARPCORE(bp)) |
| 6439 | bnx2x_prepare_xgxs(¶ms->phy[INT_PHY], params, vars); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6440 | /* init ext phy and enable link state int */ |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 6441 | non_ext_phy = (SINGLE_MEDIA_DIRECT(params) || |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6442 | (params->loopback_mode == LOOPBACK_XGXS)); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6443 | |
| 6444 | if (non_ext_phy || |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 6445 | (params->phy[EXT_PHY1].flags & FLAGS_INIT_XGXS_FIRST) || |
Eilon Greenstein | 8660d8c | 2009-03-02 08:01:02 +0000 | [diff] [blame] | 6446 | (params->loopback_mode == LOOPBACK_EXT_PHY)) { |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 6447 | struct bnx2x_phy *phy = ¶ms->phy[INT_PHY]; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6448 | if (vars->line_speed == SPEED_AUTO_NEG && |
| 6449 | (CHIP_IS_E1x(bp) || |
| 6450 | CHIP_IS_E2(bp))) |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 6451 | bnx2x_set_parallel_detection(phy, params); |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 6452 | if (params->phy[INT_PHY].config_init) |
| 6453 | params->phy[INT_PHY].config_init(phy, |
| 6454 | params, |
| 6455 | vars); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6456 | } |
| 6457 | |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 6458 | /* Init external phy*/ |
Yaniv Rosner | fd36a2e | 2011-05-31 21:29:05 +0000 | [diff] [blame] | 6459 | if (non_ext_phy) { |
| 6460 | if (params->phy[INT_PHY].supported & |
| 6461 | SUPPORTED_FIBRE) |
| 6462 | vars->link_status |= LINK_STATUS_SERDES_LINK; |
| 6463 | } else { |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6464 | for (phy_index = EXT_PHY1; phy_index < params->num_phys; |
| 6465 | phy_index++) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6466 | /* |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6467 | * No need to initialize second phy in case of first |
| 6468 | * phy only selection. In case of second phy, we do |
| 6469 | * need to initialize the first phy, since they are |
| 6470 | * connected. |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6471 | */ |
Yaniv Rosner | fd36a2e | 2011-05-31 21:29:05 +0000 | [diff] [blame] | 6472 | if (params->phy[phy_index].supported & |
| 6473 | SUPPORTED_FIBRE) |
| 6474 | vars->link_status |= LINK_STATUS_SERDES_LINK; |
| 6475 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6476 | if (phy_index == EXT_PHY2 && |
| 6477 | (bnx2x_phy_selection(params) == |
| 6478 | PORT_HW_CFG_PHY_SELECTION_FIRST_PHY)) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 6479 | DP(NETIF_MSG_LINK, |
| 6480 | "Not initializing second phy\n"); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6481 | continue; |
| 6482 | } |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6483 | params->phy[phy_index].config_init( |
| 6484 | ¶ms->phy[phy_index], |
| 6485 | params, vars); |
| 6486 | } |
Yaniv Rosner | fd36a2e | 2011-05-31 21:29:05 +0000 | [diff] [blame] | 6487 | } |
Yaniv Rosner | d90d96b | 2010-09-07 11:41:04 +0000 | [diff] [blame] | 6488 | /* Reset the interrupt indication after phy was initialized */ |
| 6489 | bnx2x_bits_dis(bp, NIG_REG_STATUS_INTERRUPT_PORT0 + |
| 6490 | params->port*4, |
| 6491 | (NIG_STATUS_XGXS0_LINK10G | |
| 6492 | NIG_STATUS_XGXS0_LINK_STATUS | |
| 6493 | NIG_STATUS_SERDES0_LINK_STATUS | |
| 6494 | NIG_MASK_MI_INT)); |
Yaniv Rosner | fd36a2e | 2011-05-31 21:29:05 +0000 | [diff] [blame] | 6495 | bnx2x_update_mng(params, vars->link_status); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6496 | return rc; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6497 | } |
| 6498 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6499 | static void bnx2x_int_link_reset(struct bnx2x_phy *phy, |
| 6500 | struct link_params *params) |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6501 | { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6502 | /* reset the SerDes/XGXS */ |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6503 | REG_WR(params->bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_3_CLEAR, |
| 6504 | (0x1ff << (params->port*16))); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6505 | } |
| 6506 | |
| 6507 | static void bnx2x_common_ext_link_reset(struct bnx2x_phy *phy, |
| 6508 | struct link_params *params) |
| 6509 | { |
| 6510 | struct bnx2x *bp = params->bp; |
| 6511 | u8 gpio_port; |
| 6512 | /* HW reset */ |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 6513 | if (CHIP_IS_E2(bp)) |
| 6514 | gpio_port = BP_PATH(bp); |
| 6515 | else |
| 6516 | gpio_port = params->port; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6517 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6518 | MISC_REGISTERS_GPIO_OUTPUT_LOW, |
| 6519 | gpio_port); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6520 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6521 | MISC_REGISTERS_GPIO_OUTPUT_LOW, |
| 6522 | gpio_port); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6523 | DP(NETIF_MSG_LINK, "reset external PHY\n"); |
| 6524 | } |
| 6525 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6526 | static int bnx2x_update_link_down(struct link_params *params, |
| 6527 | struct link_vars *vars) |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6528 | { |
| 6529 | struct bnx2x *bp = params->bp; |
| 6530 | u8 port = params->port; |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 6531 | |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6532 | DP(NETIF_MSG_LINK, "Port %x: Link is down\n", port); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6533 | bnx2x_set_led(params, vars, LED_MODE_OFF, 0); |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 6534 | vars->phy_flags &= ~PHY_PHYSICAL_LINK_FLAG; |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6535 | /* indicate no mac active */ |
| 6536 | vars->mac_type = MAC_TYPE_NONE; |
| 6537 | |
| 6538 | /* update shared memory */ |
Yaniv Rosner | fd36a2e | 2011-05-31 21:29:05 +0000 | [diff] [blame] | 6539 | vars->link_status &= ~(LINK_STATUS_SPEED_AND_DUPLEX_MASK | |
| 6540 | LINK_STATUS_LINK_UP | |
Yaniv Rosner | de6f337 | 2011-08-02 22:59:25 +0000 | [diff] [blame] | 6541 | LINK_STATUS_PHYSICAL_LINK_FLAG | |
Yaniv Rosner | fd36a2e | 2011-05-31 21:29:05 +0000 | [diff] [blame] | 6542 | LINK_STATUS_AUTO_NEGOTIATE_COMPLETE | |
| 6543 | LINK_STATUS_RX_FLOW_CONTROL_FLAG_MASK | |
| 6544 | LINK_STATUS_TX_FLOW_CONTROL_FLAG_MASK | |
Mintz Yuval | 9e7e839 | 2012-02-15 02:10:24 +0000 | [diff] [blame] | 6545 | LINK_STATUS_PARALLEL_DETECTION_FLAG_MASK | |
| 6546 | LINK_STATUS_LINK_PARTNER_SYMMETRIC_PAUSE | |
| 6547 | LINK_STATUS_LINK_PARTNER_ASYMMETRIC_PAUSE); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6548 | vars->line_speed = 0; |
| 6549 | bnx2x_update_mng(params, vars->link_status); |
| 6550 | |
| 6551 | /* activate nig drain */ |
| 6552 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + port*4, 1); |
| 6553 | |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 6554 | /* disable emac */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 6555 | if (!CHIP_IS_E3(bp)) |
| 6556 | REG_WR(bp, NIG_REG_NIG_EMAC0_EN + port*4, 0); |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 6557 | |
| 6558 | msleep(10); |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 6559 | /* reset BigMac/Xmac */ |
| 6560 | if (CHIP_IS_E1x(bp) || |
| 6561 | CHIP_IS_E2(bp)) { |
| 6562 | bnx2x_bmac_rx_disable(bp, params->port); |
| 6563 | REG_WR(bp, GRCBASE_MISC + |
| 6564 | MISC_REGISTERS_RESET_REG_2_CLEAR, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6565 | (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << port)); |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 6566 | } |
Yaniv Rosner | ce7c048 | 2011-10-27 05:09:47 +0000 | [diff] [blame] | 6567 | if (CHIP_IS_E3(bp)) { |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 6568 | bnx2x_xmac_disable(params); |
Yaniv Rosner | ce7c048 | 2011-10-27 05:09:47 +0000 | [diff] [blame] | 6569 | bnx2x_umac_disable(params); |
| 6570 | } |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 6571 | |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6572 | return 0; |
| 6573 | } |
| 6574 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6575 | static int bnx2x_update_link_up(struct link_params *params, |
| 6576 | struct link_vars *vars, |
| 6577 | u8 link_10g) |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6578 | { |
| 6579 | struct bnx2x *bp = params->bp; |
| 6580 | u8 port = params->port; |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6581 | int rc = 0; |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 6582 | |
Yaniv Rosner | de6f337 | 2011-08-02 22:59:25 +0000 | [diff] [blame] | 6583 | vars->link_status |= (LINK_STATUS_LINK_UP | |
| 6584 | LINK_STATUS_PHYSICAL_LINK_FLAG); |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 6585 | vars->phy_flags |= PHY_PHYSICAL_LINK_FLAG; |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6586 | |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 6587 | if (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX) |
| 6588 | vars->link_status |= |
| 6589 | LINK_STATUS_TX_FLOW_CONTROL_ENABLED; |
| 6590 | |
| 6591 | if (vars->flow_ctrl & BNX2X_FLOW_CTRL_RX) |
| 6592 | vars->link_status |= |
| 6593 | LINK_STATUS_RX_FLOW_CONTROL_ENABLED; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 6594 | if (USES_WARPCORE(bp)) { |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 6595 | if (link_10g) { |
| 6596 | if (bnx2x_xmac_enable(params, vars, 0) == |
| 6597 | -ESRCH) { |
| 6598 | DP(NETIF_MSG_LINK, "Found errors on XMAC\n"); |
| 6599 | vars->link_up = 0; |
| 6600 | vars->phy_flags |= PHY_HALF_OPEN_CONN_FLAG; |
| 6601 | vars->link_status &= ~LINK_STATUS_LINK_UP; |
| 6602 | } |
| 6603 | } else |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 6604 | bnx2x_umac_enable(params, vars, 0); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6605 | bnx2x_set_led(params, vars, |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 6606 | LED_MODE_OPER, vars->line_speed); |
| 6607 | } |
| 6608 | if ((CHIP_IS_E1x(bp) || |
| 6609 | CHIP_IS_E2(bp))) { |
| 6610 | if (link_10g) { |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 6611 | if (bnx2x_bmac_enable(params, vars, 0) == |
| 6612 | -ESRCH) { |
| 6613 | DP(NETIF_MSG_LINK, "Found errors on BMAC\n"); |
| 6614 | vars->link_up = 0; |
| 6615 | vars->phy_flags |= PHY_HALF_OPEN_CONN_FLAG; |
| 6616 | vars->link_status &= ~LINK_STATUS_LINK_UP; |
| 6617 | } |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6618 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 6619 | bnx2x_set_led(params, vars, |
| 6620 | LED_MODE_OPER, SPEED_10000); |
| 6621 | } else { |
| 6622 | rc = bnx2x_emac_program(params, vars); |
| 6623 | bnx2x_emac_enable(params, vars, 0); |
Yaniv Rosner | 0c786f0 | 2009-11-05 19:18:32 +0200 | [diff] [blame] | 6624 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 6625 | /* AN complete? */ |
| 6626 | if ((vars->link_status & |
| 6627 | LINK_STATUS_AUTO_NEGOTIATE_COMPLETE) |
| 6628 | && (!(vars->phy_flags & PHY_SGMII_FLAG)) && |
| 6629 | SINGLE_MEDIA_DIRECT(params)) |
| 6630 | bnx2x_set_gmii_tx_driver(params); |
| 6631 | } |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6632 | } |
| 6633 | |
| 6634 | /* PBF - link up */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 6635 | if (CHIP_IS_E1x(bp)) |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 6636 | rc |= bnx2x_pbf_update(params, vars->flow_ctrl, |
| 6637 | vars->line_speed); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6638 | |
| 6639 | /* disable drain */ |
| 6640 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + port*4, 0); |
| 6641 | |
| 6642 | /* update shared memory */ |
| 6643 | bnx2x_update_mng(params, vars->link_status); |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 6644 | msleep(20); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6645 | return rc; |
| 6646 | } |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6647 | /* |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6648 | * The bnx2x_link_update function should be called upon link |
| 6649 | * interrupt. |
| 6650 | * Link is considered up as follows: |
| 6651 | * - DIRECT_SINGLE_MEDIA - Only XGXS link (internal link) needs |
| 6652 | * to be up |
| 6653 | * - SINGLE_MEDIA - The link between the 577xx and the external |
| 6654 | * phy (XGXS) need to up as well as the external link of the |
| 6655 | * phy (PHY_EXT1) |
| 6656 | * - DUAL_MEDIA - The link between the 577xx and the first |
| 6657 | * external phy needs to be up, and at least one of the 2 |
| 6658 | * external phy link must be up. |
Yaniv Rosner | 62b29a5 | 2010-09-07 11:40:58 +0000 | [diff] [blame] | 6659 | */ |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6660 | int bnx2x_link_update(struct link_params *params, struct link_vars *vars) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6661 | { |
| 6662 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6663 | struct link_vars phy_vars[MAX_PHYS]; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6664 | u8 port = params->port; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6665 | u8 link_10g_plus, phy_index; |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6666 | u8 ext_phy_link_up = 0, cur_link_up; |
| 6667 | int rc = 0; |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 6668 | u8 is_mi_int = 0; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6669 | u16 ext_phy_line_speed = 0, prev_line_speed = vars->line_speed; |
| 6670 | u8 active_external_phy = INT_PHY; |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 6671 | vars->phy_flags &= ~PHY_HALF_OPEN_CONN_FLAG; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6672 | for (phy_index = INT_PHY; phy_index < params->num_phys; |
| 6673 | phy_index++) { |
| 6674 | phy_vars[phy_index].flow_ctrl = 0; |
| 6675 | phy_vars[phy_index].link_status = 0; |
| 6676 | phy_vars[phy_index].line_speed = 0; |
| 6677 | phy_vars[phy_index].duplex = DUPLEX_FULL; |
| 6678 | phy_vars[phy_index].phy_link_up = 0; |
| 6679 | phy_vars[phy_index].link_up = 0; |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 6680 | phy_vars[phy_index].fault_detected = 0; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6681 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6682 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6683 | if (USES_WARPCORE(bp)) |
| 6684 | bnx2x_set_aer_mmd(params, ¶ms->phy[INT_PHY]); |
| 6685 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6686 | 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] | 6687 | port, (vars->phy_flags & PHY_XGXS_FLAG), |
| 6688 | REG_RD(bp, NIG_REG_STATUS_INTERRUPT_PORT0 + port*4)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6689 | |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 6690 | 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] | 6691 | port*0x18) > 0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6692 | 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] | 6693 | REG_RD(bp, NIG_REG_MASK_INTERRUPT_PORT0 + port*4), |
| 6694 | is_mi_int, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6695 | REG_RD(bp, NIG_REG_SERDES0_STATUS_LINK_STATUS + port*0x3c)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6696 | |
| 6697 | DP(NETIF_MSG_LINK, " 10G %x, XGXS_LINK %x\n", |
| 6698 | REG_RD(bp, NIG_REG_XGXS0_STATUS_LINK10G + port*0x68), |
| 6699 | REG_RD(bp, NIG_REG_XGXS0_STATUS_LINK_STATUS + port*0x68)); |
| 6700 | |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 6701 | /* disable emac */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 6702 | if (!CHIP_IS_E3(bp)) |
| 6703 | REG_WR(bp, NIG_REG_NIG_EMAC0_EN + port*4, 0); |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 6704 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6705 | /* |
| 6706 | * Step 1: |
| 6707 | * Check external link change only for external phys, and apply |
| 6708 | * priority selection between them in case the link on both phys |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 6709 | * is up. Note that instead of the common vars, a temporary |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6710 | * vars argument is used since each phy may have different link/ |
| 6711 | * speed/duplex result |
| 6712 | */ |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6713 | for (phy_index = EXT_PHY1; phy_index < params->num_phys; |
| 6714 | phy_index++) { |
| 6715 | struct bnx2x_phy *phy = ¶ms->phy[phy_index]; |
| 6716 | if (!phy->read_status) |
| 6717 | continue; |
| 6718 | /* Read link status and params of this ext phy */ |
| 6719 | cur_link_up = phy->read_status(phy, params, |
| 6720 | &phy_vars[phy_index]); |
| 6721 | if (cur_link_up) { |
| 6722 | DP(NETIF_MSG_LINK, "phy in index %d link is up\n", |
| 6723 | phy_index); |
| 6724 | } else { |
| 6725 | DP(NETIF_MSG_LINK, "phy in index %d link is down\n", |
| 6726 | phy_index); |
| 6727 | continue; |
| 6728 | } |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6729 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6730 | if (!ext_phy_link_up) { |
| 6731 | ext_phy_link_up = 1; |
| 6732 | active_external_phy = phy_index; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6733 | } else { |
| 6734 | switch (bnx2x_phy_selection(params)) { |
| 6735 | case PORT_HW_CFG_PHY_SELECTION_HARDWARE_DEFAULT: |
| 6736 | case PORT_HW_CFG_PHY_SELECTION_FIRST_PHY_PRIORITY: |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6737 | /* |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6738 | * In this option, the first PHY makes sure to pass the |
| 6739 | * traffic through itself only. |
| 6740 | * Its not clear how to reset the link on the second phy |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6741 | */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6742 | active_external_phy = EXT_PHY1; |
| 6743 | break; |
| 6744 | case PORT_HW_CFG_PHY_SELECTION_SECOND_PHY_PRIORITY: |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6745 | /* |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6746 | * In this option, the first PHY makes sure to pass the |
| 6747 | * traffic through the second PHY. |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6748 | */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6749 | active_external_phy = EXT_PHY2; |
| 6750 | break; |
| 6751 | default: |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6752 | /* |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6753 | * Link indication on both PHYs with the following cases |
| 6754 | * is invalid: |
| 6755 | * - FIRST_PHY means that second phy wasn't initialized, |
| 6756 | * hence its link is expected to be down |
| 6757 | * - SECOND_PHY means that first phy should not be able |
| 6758 | * to link up by itself (using configuration) |
| 6759 | * - DEFAULT should be overriden during initialiazation |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6760 | */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6761 | DP(NETIF_MSG_LINK, "Invalid link indication" |
| 6762 | "mpc=0x%x. DISABLING LINK !!!\n", |
| 6763 | params->multi_phy_config); |
| 6764 | ext_phy_link_up = 0; |
| 6765 | break; |
| 6766 | } |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6767 | } |
| 6768 | } |
| 6769 | prev_line_speed = vars->line_speed; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6770 | /* |
| 6771 | * Step 2: |
| 6772 | * Read the status of the internal phy. In case of |
| 6773 | * DIRECT_SINGLE_MEDIA board, this link is the external link, |
| 6774 | * otherwise this is the link between the 577xx and the first |
| 6775 | * external phy |
| 6776 | */ |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6777 | if (params->phy[INT_PHY].read_status) |
| 6778 | params->phy[INT_PHY].read_status( |
| 6779 | ¶ms->phy[INT_PHY], |
| 6780 | params, vars); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6781 | /* |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6782 | * The INT_PHY flow control reside in the vars. This include the |
| 6783 | * case where the speed or flow control are not set to AUTO. |
| 6784 | * Otherwise, the active external phy flow control result is set |
| 6785 | * to the vars. The ext_phy_line_speed is needed to check if the |
| 6786 | * speed is different between the internal phy and external phy. |
| 6787 | * This case may be result of intermediate link speed change. |
| 6788 | */ |
| 6789 | if (active_external_phy > INT_PHY) { |
| 6790 | vars->flow_ctrl = phy_vars[active_external_phy].flow_ctrl; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6791 | /* |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6792 | * Link speed is taken from the XGXS. AN and FC result from |
| 6793 | * the external phy. |
| 6794 | */ |
| 6795 | vars->link_status |= phy_vars[active_external_phy].link_status; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6796 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6797 | /* |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6798 | * if active_external_phy is first PHY and link is up - disable |
| 6799 | * disable TX on second external PHY |
| 6800 | */ |
| 6801 | if (active_external_phy == EXT_PHY1) { |
| 6802 | if (params->phy[EXT_PHY2].phy_specific_func) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 6803 | DP(NETIF_MSG_LINK, |
| 6804 | "Disabling TX on EXT_PHY2\n"); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6805 | params->phy[EXT_PHY2].phy_specific_func( |
| 6806 | ¶ms->phy[EXT_PHY2], |
| 6807 | params, DISABLE_TX); |
| 6808 | } |
| 6809 | } |
| 6810 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6811 | ext_phy_line_speed = phy_vars[active_external_phy].line_speed; |
| 6812 | vars->duplex = phy_vars[active_external_phy].duplex; |
| 6813 | if (params->phy[active_external_phy].supported & |
| 6814 | SUPPORTED_FIBRE) |
| 6815 | vars->link_status |= LINK_STATUS_SERDES_LINK; |
Yaniv Rosner | fd36a2e | 2011-05-31 21:29:05 +0000 | [diff] [blame] | 6816 | else |
| 6817 | vars->link_status &= ~LINK_STATUS_SERDES_LINK; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6818 | DP(NETIF_MSG_LINK, "Active external phy selected: %x\n", |
| 6819 | active_external_phy); |
| 6820 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6821 | |
| 6822 | for (phy_index = EXT_PHY1; phy_index < params->num_phys; |
| 6823 | phy_index++) { |
| 6824 | if (params->phy[phy_index].flags & |
| 6825 | FLAGS_REARM_LATCH_SIGNAL) { |
| 6826 | bnx2x_rearm_latch_signal(bp, port, |
| 6827 | phy_index == |
| 6828 | active_external_phy); |
| 6829 | break; |
| 6830 | } |
| 6831 | } |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6832 | DP(NETIF_MSG_LINK, "vars->flow_ctrl = 0x%x, vars->link_status = 0x%x," |
| 6833 | " ext_phy_line_speed = %d\n", vars->flow_ctrl, |
| 6834 | vars->link_status, ext_phy_line_speed); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6835 | /* |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6836 | * Upon link speed change set the NIG into drain mode. Comes to |
| 6837 | * deals with possible FIFO glitch due to clk change when speed |
| 6838 | * is decreased without link down indicator |
| 6839 | */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6840 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6841 | if (vars->phy_link_up) { |
| 6842 | if (!(SINGLE_MEDIA_DIRECT(params)) && ext_phy_link_up && |
| 6843 | (ext_phy_line_speed != vars->line_speed)) { |
| 6844 | DP(NETIF_MSG_LINK, "Internal link speed %d is" |
| 6845 | " different than the external" |
| 6846 | " link speed %d\n", vars->line_speed, |
| 6847 | ext_phy_line_speed); |
| 6848 | vars->phy_link_up = 0; |
| 6849 | } else if (prev_line_speed != vars->line_speed) { |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6850 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + params->port*4, |
| 6851 | 0); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6852 | msleep(1); |
| 6853 | } |
| 6854 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6855 | |
| 6856 | /* anything 10 and over uses the bmac */ |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6857 | link_10g_plus = (vars->line_speed >= SPEED_10000); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6858 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6859 | bnx2x_link_int_ack(params, vars, link_10g_plus); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6860 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6861 | /* |
| 6862 | * In case external phy link is up, and internal link is down |
| 6863 | * (not initialized yet probably after link initialization, it |
| 6864 | * needs to be initialized. |
| 6865 | * Note that after link down-up as result of cable plug, the xgxs |
| 6866 | * link would probably become up again without the need |
| 6867 | * initialize it |
| 6868 | */ |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6869 | if (!(SINGLE_MEDIA_DIRECT(params))) { |
| 6870 | DP(NETIF_MSG_LINK, "ext_phy_link_up = %d, int_link_up = %d," |
| 6871 | " init_preceding = %d\n", ext_phy_link_up, |
| 6872 | vars->phy_link_up, |
| 6873 | params->phy[EXT_PHY1].flags & |
| 6874 | FLAGS_INIT_XGXS_FIRST); |
| 6875 | if (!(params->phy[EXT_PHY1].flags & |
| 6876 | FLAGS_INIT_XGXS_FIRST) |
| 6877 | && ext_phy_link_up && !vars->phy_link_up) { |
| 6878 | vars->line_speed = ext_phy_line_speed; |
| 6879 | if (vars->line_speed < SPEED_1000) |
| 6880 | vars->phy_flags |= PHY_SGMII_FLAG; |
| 6881 | else |
| 6882 | vars->phy_flags &= ~PHY_SGMII_FLAG; |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 6883 | |
| 6884 | if (params->phy[INT_PHY].config_init) |
| 6885 | params->phy[INT_PHY].config_init( |
| 6886 | ¶ms->phy[INT_PHY], params, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6887 | vars); |
| 6888 | } |
| 6889 | } |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6890 | /* |
| 6891 | * 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] | 6892 | * non-direct board) are up and no fault detected on active PHY. |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6893 | */ |
| 6894 | vars->link_up = (vars->phy_link_up && |
| 6895 | (ext_phy_link_up || |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 6896 | SINGLE_MEDIA_DIRECT(params)) && |
| 6897 | (phy_vars[active_external_phy].fault_detected == 0)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6898 | |
Yaniv Rosner | 27d9129 | 2012-04-04 01:28:54 +0000 | [diff] [blame] | 6899 | /* Update the PFC configuration in case it was changed */ |
| 6900 | if (params->feature_config_flags & FEATURE_CONFIG_PFC_ENABLED) |
| 6901 | vars->link_status |= LINK_STATUS_PFC_ENABLED; |
| 6902 | else |
| 6903 | vars->link_status &= ~LINK_STATUS_PFC_ENABLED; |
| 6904 | |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6905 | if (vars->link_up) |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 6906 | rc = bnx2x_update_link_up(params, vars, link_10g_plus); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 6907 | else |
| 6908 | rc = bnx2x_update_link_down(params, vars); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 6909 | |
| 6910 | return rc; |
| 6911 | } |
| 6912 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6913 | /*****************************************************************************/ |
| 6914 | /* External Phy section */ |
| 6915 | /*****************************************************************************/ |
| 6916 | void bnx2x_ext_phy_hw_reset(struct bnx2x *bp, u8 port) |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6917 | { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6918 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6919 | MISC_REGISTERS_GPIO_OUTPUT_LOW, port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6920 | msleep(1); |
| 6921 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6922 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, port); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6923 | } |
| 6924 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6925 | static void bnx2x_save_spirom_version(struct bnx2x *bp, u8 port, |
| 6926 | u32 spirom_ver, u32 ver_addr) |
| 6927 | { |
| 6928 | DP(NETIF_MSG_LINK, "FW version 0x%x:0x%x for port %d\n", |
| 6929 | (u16)(spirom_ver>>16), (u16)spirom_ver, port); |
| 6930 | |
| 6931 | if (ver_addr) |
| 6932 | REG_WR(bp, ver_addr, spirom_ver); |
| 6933 | } |
| 6934 | |
| 6935 | static void bnx2x_save_bcm_spirom_ver(struct bnx2x *bp, |
| 6936 | struct bnx2x_phy *phy, |
| 6937 | u8 port) |
| 6938 | { |
| 6939 | u16 fw_ver1, fw_ver2; |
| 6940 | |
| 6941 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6942 | MDIO_PMA_REG_ROM_VER1, &fw_ver1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6943 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6944 | MDIO_PMA_REG_ROM_VER2, &fw_ver2); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6945 | bnx2x_save_spirom_version(bp, port, (u32)(fw_ver1<<16 | fw_ver2), |
| 6946 | phy->ver_addr); |
| 6947 | } |
| 6948 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6949 | static void bnx2x_ext_phy_10G_an_resolve(struct bnx2x *bp, |
| 6950 | struct bnx2x_phy *phy, |
| 6951 | struct link_vars *vars) |
| 6952 | { |
| 6953 | u16 val; |
| 6954 | bnx2x_cl45_read(bp, phy, |
| 6955 | MDIO_AN_DEVAD, |
| 6956 | MDIO_AN_REG_STATUS, &val); |
| 6957 | bnx2x_cl45_read(bp, phy, |
| 6958 | MDIO_AN_DEVAD, |
| 6959 | MDIO_AN_REG_STATUS, &val); |
| 6960 | if (val & (1<<5)) |
| 6961 | vars->link_status |= LINK_STATUS_AUTO_NEGOTIATE_COMPLETE; |
| 6962 | if ((val & (1<<0)) == 0) |
| 6963 | vars->link_status |= LINK_STATUS_PARALLEL_DETECTION_USED; |
| 6964 | } |
| 6965 | |
| 6966 | /******************************************************************/ |
| 6967 | /* common BCM8073/BCM8727 PHY SECTION */ |
| 6968 | /******************************************************************/ |
| 6969 | static void bnx2x_8073_resolve_fc(struct bnx2x_phy *phy, |
| 6970 | struct link_params *params, |
| 6971 | struct link_vars *vars) |
| 6972 | { |
| 6973 | struct bnx2x *bp = params->bp; |
| 6974 | if (phy->req_line_speed == SPEED_10 || |
| 6975 | phy->req_line_speed == SPEED_100) { |
| 6976 | vars->flow_ctrl = phy->req_flow_ctrl; |
| 6977 | return; |
| 6978 | } |
| 6979 | |
| 6980 | if (bnx2x_ext_phy_resolve_fc(phy, params, vars) && |
| 6981 | (vars->flow_ctrl == BNX2X_FLOW_CTRL_NONE)) { |
| 6982 | u16 pause_result; |
| 6983 | u16 ld_pause; /* local */ |
| 6984 | u16 lp_pause; /* link partner */ |
| 6985 | bnx2x_cl45_read(bp, phy, |
| 6986 | MDIO_AN_DEVAD, |
| 6987 | MDIO_AN_REG_CL37_FC_LD, &ld_pause); |
| 6988 | |
| 6989 | bnx2x_cl45_read(bp, phy, |
| 6990 | MDIO_AN_DEVAD, |
| 6991 | MDIO_AN_REG_CL37_FC_LP, &lp_pause); |
| 6992 | pause_result = (ld_pause & |
| 6993 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) >> 5; |
| 6994 | pause_result |= (lp_pause & |
| 6995 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) >> 7; |
| 6996 | |
| 6997 | bnx2x_pause_resolve(vars, pause_result); |
| 6998 | DP(NETIF_MSG_LINK, "Ext PHY CL37 pause result 0x%x\n", |
| 6999 | pause_result); |
| 7000 | } |
| 7001 | } |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 7002 | static int bnx2x_8073_8727_external_rom_boot(struct bnx2x *bp, |
| 7003 | struct bnx2x_phy *phy, |
| 7004 | u8 port) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7005 | { |
Yaniv Rosner | 5c99274b | 2011-01-18 04:33:36 +0000 | [diff] [blame] | 7006 | u32 count = 0; |
| 7007 | u16 fw_ver1, fw_msgout; |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 7008 | int rc = 0; |
Yaniv Rosner | 5c99274b | 2011-01-18 04:33:36 +0000 | [diff] [blame] | 7009 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7010 | /* Boot port from external ROM */ |
| 7011 | /* EDC grst */ |
| 7012 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7013 | MDIO_PMA_DEVAD, |
| 7014 | MDIO_PMA_REG_GEN_CTRL, |
| 7015 | 0x0001); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7016 | |
| 7017 | /* ucode reboot and rst */ |
| 7018 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7019 | MDIO_PMA_DEVAD, |
| 7020 | MDIO_PMA_REG_GEN_CTRL, |
| 7021 | 0x008c); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7022 | |
| 7023 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7024 | MDIO_PMA_DEVAD, |
| 7025 | MDIO_PMA_REG_MISC_CTRL1, 0x0001); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7026 | |
| 7027 | /* Reset internal microprocessor */ |
| 7028 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7029 | MDIO_PMA_DEVAD, |
| 7030 | MDIO_PMA_REG_GEN_CTRL, |
| 7031 | MDIO_PMA_REG_GEN_CTRL_ROM_MICRO_RESET); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7032 | |
| 7033 | /* Release srst bit */ |
| 7034 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7035 | MDIO_PMA_DEVAD, |
| 7036 | MDIO_PMA_REG_GEN_CTRL, |
| 7037 | MDIO_PMA_REG_GEN_CTRL_ROM_RESET_INTERNAL_MP); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7038 | |
Yaniv Rosner | 5c99274b | 2011-01-18 04:33:36 +0000 | [diff] [blame] | 7039 | /* Delay 100ms per the PHY specifications */ |
| 7040 | msleep(100); |
| 7041 | |
| 7042 | /* 8073 sometimes taking longer to download */ |
| 7043 | do { |
| 7044 | count++; |
| 7045 | if (count > 300) { |
| 7046 | DP(NETIF_MSG_LINK, |
| 7047 | "bnx2x_8073_8727_external_rom_boot port %x:" |
| 7048 | "Download failed. fw version = 0x%x\n", |
| 7049 | port, fw_ver1); |
| 7050 | rc = -EINVAL; |
| 7051 | break; |
| 7052 | } |
| 7053 | |
| 7054 | bnx2x_cl45_read(bp, phy, |
| 7055 | MDIO_PMA_DEVAD, |
| 7056 | MDIO_PMA_REG_ROM_VER1, &fw_ver1); |
| 7057 | bnx2x_cl45_read(bp, phy, |
| 7058 | MDIO_PMA_DEVAD, |
| 7059 | MDIO_PMA_REG_M8051_MSGOUT_REG, &fw_msgout); |
| 7060 | |
| 7061 | msleep(1); |
| 7062 | } while (fw_ver1 == 0 || fw_ver1 == 0x4321 || |
| 7063 | ((fw_msgout & 0xff) != 0x03 && (phy->type == |
| 7064 | PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073))); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7065 | |
| 7066 | /* Clear ser_boot_ctl bit */ |
| 7067 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7068 | MDIO_PMA_DEVAD, |
| 7069 | MDIO_PMA_REG_MISC_CTRL1, 0x0000); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7070 | bnx2x_save_bcm_spirom_ver(bp, phy, port); |
Yaniv Rosner | 5c99274b | 2011-01-18 04:33:36 +0000 | [diff] [blame] | 7071 | |
| 7072 | DP(NETIF_MSG_LINK, |
| 7073 | "bnx2x_8073_8727_external_rom_boot port %x:" |
| 7074 | "Download complete. fw version = 0x%x\n", |
| 7075 | port, fw_ver1); |
| 7076 | |
| 7077 | return rc; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7078 | } |
| 7079 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7080 | /******************************************************************/ |
| 7081 | /* BCM8073 PHY SECTION */ |
| 7082 | /******************************************************************/ |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 7083 | 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] | 7084 | { |
| 7085 | /* This is only required for 8073A1, version 102 only */ |
| 7086 | u16 val; |
| 7087 | |
| 7088 | /* Read 8073 HW revision*/ |
| 7089 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7090 | MDIO_PMA_DEVAD, |
| 7091 | MDIO_PMA_REG_8073_CHIP_REV, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7092 | |
| 7093 | if (val != 1) { |
| 7094 | /* No need to workaround in 8073 A1 */ |
| 7095 | return 0; |
| 7096 | } |
| 7097 | |
| 7098 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7099 | MDIO_PMA_DEVAD, |
| 7100 | MDIO_PMA_REG_ROM_VER2, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7101 | |
| 7102 | /* SNR should be applied only for version 0x102 */ |
| 7103 | if (val != 0x102) |
| 7104 | return 0; |
| 7105 | |
| 7106 | return 1; |
| 7107 | } |
| 7108 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 7109 | 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] | 7110 | { |
| 7111 | u16 val, cnt, cnt1 ; |
| 7112 | |
| 7113 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7114 | MDIO_PMA_DEVAD, |
| 7115 | MDIO_PMA_REG_8073_CHIP_REV, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7116 | |
| 7117 | if (val > 0) { |
| 7118 | /* No need to workaround in 8073 A1 */ |
| 7119 | return 0; |
| 7120 | } |
| 7121 | /* XAUI workaround in 8073 A0: */ |
| 7122 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7123 | /* |
| 7124 | * After loading the boot ROM and restarting Autoneg, poll |
| 7125 | * Dev1, Reg $C820: |
| 7126 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7127 | |
| 7128 | for (cnt = 0; cnt < 1000; cnt++) { |
| 7129 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7130 | MDIO_PMA_DEVAD, |
| 7131 | MDIO_PMA_REG_8073_SPEED_LINK_STATUS, |
| 7132 | &val); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7133 | /* |
| 7134 | * If bit [14] = 0 or bit [13] = 0, continue on with |
| 7135 | * system initialization (XAUI work-around not required, as |
| 7136 | * these bits indicate 2.5G or 1G link up). |
| 7137 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7138 | if (!(val & (1<<14)) || !(val & (1<<13))) { |
| 7139 | DP(NETIF_MSG_LINK, "XAUI work-around not required\n"); |
| 7140 | return 0; |
| 7141 | } else if (!(val & (1<<15))) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7142 | DP(NETIF_MSG_LINK, "bit 15 went off\n"); |
| 7143 | /* |
| 7144 | * If bit 15 is 0, then poll Dev1, Reg $C841 until it's |
| 7145 | * MSB (bit15) goes to 1 (indicating that the XAUI |
| 7146 | * workaround has completed), then continue on with |
| 7147 | * system initialization. |
| 7148 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7149 | for (cnt1 = 0; cnt1 < 1000; cnt1++) { |
| 7150 | bnx2x_cl45_read(bp, phy, |
| 7151 | MDIO_PMA_DEVAD, |
| 7152 | MDIO_PMA_REG_8073_XAUI_WA, &val); |
| 7153 | if (val & (1<<15)) { |
| 7154 | DP(NETIF_MSG_LINK, |
| 7155 | "XAUI workaround has completed\n"); |
| 7156 | return 0; |
| 7157 | } |
| 7158 | msleep(3); |
| 7159 | } |
| 7160 | break; |
| 7161 | } |
| 7162 | msleep(3); |
| 7163 | } |
| 7164 | DP(NETIF_MSG_LINK, "Warning: XAUI work-around timeout !!!\n"); |
| 7165 | return -EINVAL; |
| 7166 | } |
| 7167 | |
| 7168 | static void bnx2x_807x_force_10G(struct bnx2x *bp, struct bnx2x_phy *phy) |
| 7169 | { |
| 7170 | /* Force KR or KX */ |
| 7171 | bnx2x_cl45_write(bp, phy, |
| 7172 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 0x2040); |
| 7173 | bnx2x_cl45_write(bp, phy, |
| 7174 | MDIO_PMA_DEVAD, MDIO_PMA_REG_10G_CTRL2, 0x000b); |
| 7175 | bnx2x_cl45_write(bp, phy, |
| 7176 | MDIO_PMA_DEVAD, MDIO_PMA_REG_BCM_CTRL, 0x0000); |
| 7177 | bnx2x_cl45_write(bp, phy, |
| 7178 | MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, 0x0000); |
| 7179 | } |
| 7180 | |
| 7181 | static void bnx2x_8073_set_pause_cl37(struct link_params *params, |
| 7182 | struct bnx2x_phy *phy, |
| 7183 | struct link_vars *vars) |
| 7184 | { |
| 7185 | u16 cl37_val; |
| 7186 | struct bnx2x *bp = params->bp; |
| 7187 | bnx2x_cl45_read(bp, phy, |
| 7188 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_FC_LD, &cl37_val); |
| 7189 | |
| 7190 | cl37_val &= ~MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH; |
| 7191 | /* Please refer to Table 28B-3 of 802.3ab-1999 spec. */ |
| 7192 | bnx2x_calc_ieee_aneg_adv(phy, params, &vars->ieee_fc); |
| 7193 | if ((vars->ieee_fc & |
| 7194 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_SYMMETRIC) == |
| 7195 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_SYMMETRIC) { |
| 7196 | cl37_val |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_SYMMETRIC; |
| 7197 | } |
| 7198 | if ((vars->ieee_fc & |
| 7199 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC) == |
| 7200 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC) { |
| 7201 | cl37_val |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC; |
| 7202 | } |
| 7203 | if ((vars->ieee_fc & |
| 7204 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) == |
| 7205 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) { |
| 7206 | cl37_val |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH; |
| 7207 | } |
| 7208 | DP(NETIF_MSG_LINK, |
| 7209 | "Ext phy AN advertize cl37 0x%x\n", cl37_val); |
| 7210 | |
| 7211 | bnx2x_cl45_write(bp, phy, |
| 7212 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_FC_LD, cl37_val); |
| 7213 | msleep(500); |
| 7214 | } |
| 7215 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 7216 | static int bnx2x_8073_config_init(struct bnx2x_phy *phy, |
| 7217 | struct link_params *params, |
| 7218 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7219 | { |
| 7220 | struct bnx2x *bp = params->bp; |
| 7221 | u16 val = 0, tmp1; |
| 7222 | u8 gpio_port; |
| 7223 | DP(NETIF_MSG_LINK, "Init 8073\n"); |
| 7224 | |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 7225 | if (CHIP_IS_E2(bp)) |
| 7226 | gpio_port = BP_PATH(bp); |
| 7227 | else |
| 7228 | gpio_port = params->port; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7229 | /* Restore normal power mode*/ |
| 7230 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7231 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, gpio_port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7232 | |
| 7233 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7234 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, gpio_port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7235 | |
| 7236 | /* enable LASI */ |
| 7237 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 7238 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_RXCTRL, (1<<2)); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7239 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 7240 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_CTRL, 0x0004); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7241 | |
| 7242 | bnx2x_8073_set_pause_cl37(params, phy, vars); |
| 7243 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7244 | bnx2x_cl45_read(bp, phy, |
| 7245 | MDIO_PMA_DEVAD, MDIO_PMA_REG_M8051_MSGOUT_REG, &tmp1); |
| 7246 | |
| 7247 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 7248 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_RXSTAT, &tmp1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7249 | |
| 7250 | DP(NETIF_MSG_LINK, "Before rom RX_ALARM(port1): 0x%x\n", tmp1); |
| 7251 | |
Yaniv Rosner | 74d7a11 | 2011-01-18 04:33:18 +0000 | [diff] [blame] | 7252 | /* Swap polarity if required - Must be done only in non-1G mode */ |
| 7253 | if (params->lane_config & PORT_HW_CFG_SWAP_PHY_POLARITY_ENABLED) { |
| 7254 | /* Configure the 8073 to swap _P and _N of the KR lines */ |
| 7255 | DP(NETIF_MSG_LINK, "Swapping polarity for the 8073\n"); |
| 7256 | /* 10G Rx/Tx and 1G Tx signal polarity swap */ |
| 7257 | bnx2x_cl45_read(bp, phy, |
| 7258 | MDIO_PMA_DEVAD, |
| 7259 | MDIO_PMA_REG_8073_OPT_DIGITAL_CTRL, &val); |
| 7260 | bnx2x_cl45_write(bp, phy, |
| 7261 | MDIO_PMA_DEVAD, |
| 7262 | MDIO_PMA_REG_8073_OPT_DIGITAL_CTRL, |
| 7263 | (val | (3<<9))); |
| 7264 | } |
| 7265 | |
| 7266 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7267 | /* Enable CL37 BAM */ |
Yaniv Rosner | 121839b | 2010-11-01 05:32:38 +0000 | [diff] [blame] | 7268 | if (REG_RD(bp, params->shmem_base + |
| 7269 | offsetof(struct shmem_region, dev_info. |
| 7270 | port_hw_config[params->port].default_cfg)) & |
| 7271 | PORT_HW_CFG_ENABLE_BAM_ON_KR_ENABLED) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7272 | |
Yaniv Rosner | 121839b | 2010-11-01 05:32:38 +0000 | [diff] [blame] | 7273 | bnx2x_cl45_read(bp, phy, |
| 7274 | MDIO_AN_DEVAD, |
| 7275 | MDIO_AN_REG_8073_BAM, &val); |
| 7276 | bnx2x_cl45_write(bp, phy, |
| 7277 | MDIO_AN_DEVAD, |
| 7278 | MDIO_AN_REG_8073_BAM, val | 1); |
| 7279 | DP(NETIF_MSG_LINK, "Enable CL37 BAM on KR\n"); |
| 7280 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7281 | if (params->loopback_mode == LOOPBACK_EXT) { |
| 7282 | bnx2x_807x_force_10G(bp, phy); |
| 7283 | DP(NETIF_MSG_LINK, "Forced speed 10G on 807X\n"); |
| 7284 | return 0; |
| 7285 | } else { |
| 7286 | bnx2x_cl45_write(bp, phy, |
| 7287 | MDIO_PMA_DEVAD, MDIO_PMA_REG_BCM_CTRL, 0x0002); |
| 7288 | } |
| 7289 | if (phy->req_line_speed != SPEED_AUTO_NEG) { |
| 7290 | if (phy->req_line_speed == SPEED_10000) { |
| 7291 | val = (1<<7); |
| 7292 | } else if (phy->req_line_speed == SPEED_2500) { |
| 7293 | val = (1<<5); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7294 | /* |
| 7295 | * Note that 2.5G works only when used with 1G |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 7296 | * advertisement |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7297 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7298 | } else |
| 7299 | val = (1<<5); |
| 7300 | } else { |
| 7301 | val = 0; |
| 7302 | if (phy->speed_cap_mask & |
| 7303 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G) |
| 7304 | val |= (1<<7); |
| 7305 | |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 7306 | /* Note that 2.5G works only when used with 1G advertisement */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7307 | if (phy->speed_cap_mask & |
| 7308 | (PORT_HW_CFG_SPEED_CAPABILITY_D0_1G | |
| 7309 | PORT_HW_CFG_SPEED_CAPABILITY_D0_2_5G)) |
| 7310 | val |= (1<<5); |
| 7311 | DP(NETIF_MSG_LINK, "807x autoneg val = 0x%x\n", val); |
| 7312 | } |
| 7313 | |
| 7314 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_ADV, val); |
| 7315 | bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_8073_2_5G, &tmp1); |
| 7316 | |
| 7317 | if (((phy->speed_cap_mask & PORT_HW_CFG_SPEED_CAPABILITY_D0_2_5G) && |
| 7318 | (phy->req_line_speed == SPEED_AUTO_NEG)) || |
| 7319 | (phy->req_line_speed == SPEED_2500)) { |
| 7320 | u16 phy_ver; |
| 7321 | /* Allow 2.5G for A1 and above */ |
| 7322 | bnx2x_cl45_read(bp, phy, |
| 7323 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8073_CHIP_REV, |
| 7324 | &phy_ver); |
| 7325 | DP(NETIF_MSG_LINK, "Add 2.5G\n"); |
| 7326 | if (phy_ver > 0) |
| 7327 | tmp1 |= 1; |
| 7328 | else |
| 7329 | tmp1 &= 0xfffe; |
| 7330 | } else { |
| 7331 | DP(NETIF_MSG_LINK, "Disable 2.5G\n"); |
| 7332 | tmp1 &= 0xfffe; |
| 7333 | } |
| 7334 | |
| 7335 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_8073_2_5G, tmp1); |
| 7336 | /* Add support for CL37 (passive mode) II */ |
| 7337 | |
| 7338 | bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_CL37_FC_LD, &tmp1); |
| 7339 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_CL37_FC_LD, |
| 7340 | (tmp1 | ((phy->req_duplex == DUPLEX_FULL) ? |
| 7341 | 0x20 : 0x40))); |
| 7342 | |
| 7343 | /* Add support for CL37 (passive mode) III */ |
| 7344 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_CL37_AN, 0x1000); |
| 7345 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7346 | /* |
| 7347 | * The SNR will improve about 2db by changing BW and FEE main |
| 7348 | * tap. Rest commands are executed after link is up |
| 7349 | * Change FFE main cursor to 5 in EDC register |
| 7350 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7351 | if (bnx2x_8073_is_snr_needed(bp, phy)) |
| 7352 | bnx2x_cl45_write(bp, phy, |
| 7353 | MDIO_PMA_DEVAD, MDIO_PMA_REG_EDC_FFE_MAIN, |
| 7354 | 0xFB0C); |
| 7355 | |
| 7356 | /* Enable FEC (Forware Error Correction) Request in the AN */ |
| 7357 | bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_ADV2, &tmp1); |
| 7358 | tmp1 |= (1<<15); |
| 7359 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_ADV2, tmp1); |
| 7360 | |
| 7361 | bnx2x_ext_phy_set_pause(params, phy, vars); |
| 7362 | |
| 7363 | /* Restart autoneg */ |
| 7364 | msleep(500); |
| 7365 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, 0x1200); |
| 7366 | DP(NETIF_MSG_LINK, "807x Autoneg Restart: Advertise 1G=%x, 10G=%x\n", |
| 7367 | ((val & (1<<5)) > 0), ((val & (1<<7)) > 0)); |
| 7368 | return 0; |
| 7369 | } |
| 7370 | |
| 7371 | static u8 bnx2x_8073_read_status(struct bnx2x_phy *phy, |
| 7372 | struct link_params *params, |
| 7373 | struct link_vars *vars) |
| 7374 | { |
| 7375 | struct bnx2x *bp = params->bp; |
| 7376 | u8 link_up = 0; |
| 7377 | u16 val1, val2; |
| 7378 | u16 link_status = 0; |
| 7379 | u16 an1000_status = 0; |
| 7380 | |
| 7381 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 7382 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_STAT, &val1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7383 | |
| 7384 | DP(NETIF_MSG_LINK, "8703 LASI status 0x%x\n", val1); |
| 7385 | |
| 7386 | /* clear the interrupt LASI status register */ |
| 7387 | bnx2x_cl45_read(bp, phy, |
| 7388 | MDIO_PCS_DEVAD, MDIO_PCS_REG_STATUS, &val2); |
| 7389 | bnx2x_cl45_read(bp, phy, |
| 7390 | MDIO_PCS_DEVAD, MDIO_PCS_REG_STATUS, &val1); |
| 7391 | DP(NETIF_MSG_LINK, "807x PCS status 0x%x->0x%x\n", val2, val1); |
| 7392 | /* Clear MSG-OUT */ |
| 7393 | bnx2x_cl45_read(bp, phy, |
| 7394 | MDIO_PMA_DEVAD, MDIO_PMA_REG_M8051_MSGOUT_REG, &val1); |
| 7395 | |
| 7396 | /* Check the LASI */ |
| 7397 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 7398 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_RXSTAT, &val2); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7399 | |
| 7400 | DP(NETIF_MSG_LINK, "KR 0x9003 0x%x\n", val2); |
| 7401 | |
| 7402 | /* Check the link status */ |
| 7403 | bnx2x_cl45_read(bp, phy, |
| 7404 | MDIO_PCS_DEVAD, MDIO_PCS_REG_STATUS, &val2); |
| 7405 | DP(NETIF_MSG_LINK, "KR PCS status 0x%x\n", val2); |
| 7406 | |
| 7407 | bnx2x_cl45_read(bp, phy, |
| 7408 | MDIO_PMA_DEVAD, MDIO_PMA_REG_STATUS, &val2); |
| 7409 | bnx2x_cl45_read(bp, phy, |
| 7410 | MDIO_PMA_DEVAD, MDIO_PMA_REG_STATUS, &val1); |
| 7411 | link_up = ((val1 & 4) == 4); |
| 7412 | DP(NETIF_MSG_LINK, "PMA_REG_STATUS=0x%x\n", val1); |
| 7413 | |
| 7414 | if (link_up && |
| 7415 | ((phy->req_line_speed != SPEED_10000))) { |
| 7416 | if (bnx2x_8073_xaui_wa(bp, phy) != 0) |
| 7417 | return 0; |
| 7418 | } |
| 7419 | bnx2x_cl45_read(bp, phy, |
| 7420 | MDIO_AN_DEVAD, MDIO_AN_REG_LINK_STATUS, &an1000_status); |
| 7421 | bnx2x_cl45_read(bp, phy, |
| 7422 | MDIO_AN_DEVAD, MDIO_AN_REG_LINK_STATUS, &an1000_status); |
| 7423 | |
| 7424 | /* Check the link status on 1.1.2 */ |
| 7425 | bnx2x_cl45_read(bp, phy, |
| 7426 | MDIO_PMA_DEVAD, MDIO_PMA_REG_STATUS, &val2); |
| 7427 | bnx2x_cl45_read(bp, phy, |
| 7428 | MDIO_PMA_DEVAD, MDIO_PMA_REG_STATUS, &val1); |
| 7429 | DP(NETIF_MSG_LINK, "KR PMA status 0x%x->0x%x," |
| 7430 | "an_link_status=0x%x\n", val2, val1, an1000_status); |
| 7431 | |
| 7432 | link_up = (((val1 & 4) == 4) || (an1000_status & (1<<1))); |
| 7433 | if (link_up && bnx2x_8073_is_snr_needed(bp, phy)) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7434 | /* |
| 7435 | * The SNR will improve about 2dbby changing the BW and FEE main |
| 7436 | * tap. The 1st write to change FFE main tap is set before |
| 7437 | * restart AN. Change PLL Bandwidth in EDC register |
| 7438 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7439 | bnx2x_cl45_write(bp, phy, |
| 7440 | MDIO_PMA_DEVAD, MDIO_PMA_REG_PLL_BANDWIDTH, |
| 7441 | 0x26BC); |
| 7442 | |
| 7443 | /* Change CDR Bandwidth in EDC register */ |
| 7444 | bnx2x_cl45_write(bp, phy, |
| 7445 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CDR_BANDWIDTH, |
| 7446 | 0x0333); |
| 7447 | } |
| 7448 | bnx2x_cl45_read(bp, phy, |
| 7449 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8073_SPEED_LINK_STATUS, |
| 7450 | &link_status); |
| 7451 | |
| 7452 | /* Bits 0..2 --> speed detected, bits 13..15--> link is down */ |
| 7453 | if ((link_status & (1<<2)) && (!(link_status & (1<<15)))) { |
| 7454 | link_up = 1; |
| 7455 | vars->line_speed = SPEED_10000; |
| 7456 | DP(NETIF_MSG_LINK, "port %x: External link up in 10G\n", |
| 7457 | params->port); |
| 7458 | } else if ((link_status & (1<<1)) && (!(link_status & (1<<14)))) { |
| 7459 | link_up = 1; |
| 7460 | vars->line_speed = SPEED_2500; |
| 7461 | DP(NETIF_MSG_LINK, "port %x: External link up in 2.5G\n", |
| 7462 | params->port); |
| 7463 | } else if ((link_status & (1<<0)) && (!(link_status & (1<<13)))) { |
| 7464 | link_up = 1; |
| 7465 | vars->line_speed = SPEED_1000; |
| 7466 | DP(NETIF_MSG_LINK, "port %x: External link up in 1G\n", |
| 7467 | params->port); |
| 7468 | } else { |
| 7469 | link_up = 0; |
| 7470 | DP(NETIF_MSG_LINK, "port %x: External link is down\n", |
| 7471 | params->port); |
| 7472 | } |
| 7473 | |
| 7474 | if (link_up) { |
Yaniv Rosner | 74d7a11 | 2011-01-18 04:33:18 +0000 | [diff] [blame] | 7475 | /* Swap polarity if required */ |
| 7476 | if (params->lane_config & |
| 7477 | PORT_HW_CFG_SWAP_PHY_POLARITY_ENABLED) { |
| 7478 | /* Configure the 8073 to swap P and N of the KR lines */ |
| 7479 | bnx2x_cl45_read(bp, phy, |
| 7480 | MDIO_XS_DEVAD, |
| 7481 | MDIO_XS_REG_8073_RX_CTRL_PCIE, &val1); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7482 | /* |
| 7483 | * Set bit 3 to invert Rx in 1G mode and clear this bit |
| 7484 | * when it`s in 10G mode. |
| 7485 | */ |
Yaniv Rosner | 74d7a11 | 2011-01-18 04:33:18 +0000 | [diff] [blame] | 7486 | if (vars->line_speed == SPEED_1000) { |
| 7487 | DP(NETIF_MSG_LINK, "Swapping 1G polarity for" |
| 7488 | "the 8073\n"); |
| 7489 | val1 |= (1<<3); |
| 7490 | } else |
| 7491 | val1 &= ~(1<<3); |
| 7492 | |
| 7493 | bnx2x_cl45_write(bp, phy, |
| 7494 | MDIO_XS_DEVAD, |
| 7495 | MDIO_XS_REG_8073_RX_CTRL_PCIE, |
| 7496 | val1); |
| 7497 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7498 | bnx2x_ext_phy_10G_an_resolve(bp, phy, vars); |
| 7499 | bnx2x_8073_resolve_fc(phy, params, vars); |
Yaniv Rosner | 791f18c | 2011-01-18 04:33:42 +0000 | [diff] [blame] | 7500 | vars->duplex = DUPLEX_FULL; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7501 | } |
Mintz Yuval | 9e7e839 | 2012-02-15 02:10:24 +0000 | [diff] [blame] | 7502 | |
| 7503 | if (vars->link_status & LINK_STATUS_AUTO_NEGOTIATE_COMPLETE) { |
| 7504 | bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD, |
| 7505 | MDIO_AN_REG_LP_AUTO_NEG2, &val1); |
| 7506 | |
| 7507 | if (val1 & (1<<5)) |
| 7508 | vars->link_status |= |
| 7509 | LINK_STATUS_LINK_PARTNER_1000TFD_CAPABLE; |
| 7510 | if (val1 & (1<<7)) |
| 7511 | vars->link_status |= |
| 7512 | LINK_STATUS_LINK_PARTNER_10GXFD_CAPABLE; |
| 7513 | } |
| 7514 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7515 | return link_up; |
| 7516 | } |
| 7517 | |
| 7518 | static void bnx2x_8073_link_reset(struct bnx2x_phy *phy, |
| 7519 | struct link_params *params) |
| 7520 | { |
| 7521 | struct bnx2x *bp = params->bp; |
| 7522 | u8 gpio_port; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 7523 | if (CHIP_IS_E2(bp)) |
| 7524 | gpio_port = BP_PATH(bp); |
| 7525 | else |
| 7526 | gpio_port = params->port; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7527 | DP(NETIF_MSG_LINK, "Setting 8073 port %d into low power mode\n", |
| 7528 | gpio_port); |
| 7529 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7530 | MISC_REGISTERS_GPIO_OUTPUT_LOW, |
| 7531 | gpio_port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7532 | } |
| 7533 | |
| 7534 | /******************************************************************/ |
| 7535 | /* BCM8705 PHY SECTION */ |
| 7536 | /******************************************************************/ |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 7537 | static int bnx2x_8705_config_init(struct bnx2x_phy *phy, |
| 7538 | struct link_params *params, |
| 7539 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7540 | { |
| 7541 | struct bnx2x *bp = params->bp; |
| 7542 | DP(NETIF_MSG_LINK, "init 8705\n"); |
| 7543 | /* Restore normal power mode*/ |
| 7544 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7545 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, params->port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7546 | /* HW reset */ |
| 7547 | bnx2x_ext_phy_hw_reset(bp, params->port); |
| 7548 | 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] | 7549 | bnx2x_wait_reset_complete(bp, phy, params); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7550 | |
| 7551 | bnx2x_cl45_write(bp, phy, |
| 7552 | MDIO_PMA_DEVAD, MDIO_PMA_REG_MISC_CTRL, 0x8288); |
| 7553 | bnx2x_cl45_write(bp, phy, |
| 7554 | MDIO_PMA_DEVAD, MDIO_PMA_REG_PHY_IDENTIFIER, 0x7fbf); |
| 7555 | bnx2x_cl45_write(bp, phy, |
| 7556 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CMU_PLL_BYPASS, 0x0100); |
| 7557 | bnx2x_cl45_write(bp, phy, |
| 7558 | MDIO_WIS_DEVAD, MDIO_WIS_REG_LASI_CNTL, 0x1); |
| 7559 | /* BCM8705 doesn't have microcode, hence the 0 */ |
| 7560 | bnx2x_save_spirom_version(bp, params->port, params->shmem_base, 0); |
| 7561 | return 0; |
| 7562 | } |
| 7563 | |
| 7564 | static u8 bnx2x_8705_read_status(struct bnx2x_phy *phy, |
| 7565 | struct link_params *params, |
| 7566 | struct link_vars *vars) |
| 7567 | { |
| 7568 | u8 link_up = 0; |
| 7569 | u16 val1, rx_sd; |
| 7570 | struct bnx2x *bp = params->bp; |
| 7571 | DP(NETIF_MSG_LINK, "read status 8705\n"); |
| 7572 | bnx2x_cl45_read(bp, phy, |
| 7573 | MDIO_WIS_DEVAD, MDIO_WIS_REG_LASI_STATUS, &val1); |
| 7574 | DP(NETIF_MSG_LINK, "8705 LASI status 0x%x\n", val1); |
| 7575 | |
| 7576 | bnx2x_cl45_read(bp, phy, |
| 7577 | MDIO_WIS_DEVAD, MDIO_WIS_REG_LASI_STATUS, &val1); |
| 7578 | DP(NETIF_MSG_LINK, "8705 LASI status 0x%x\n", val1); |
| 7579 | |
| 7580 | bnx2x_cl45_read(bp, phy, |
| 7581 | MDIO_PMA_DEVAD, MDIO_PMA_REG_RX_SD, &rx_sd); |
| 7582 | |
| 7583 | bnx2x_cl45_read(bp, phy, |
| 7584 | MDIO_PMA_DEVAD, 0xc809, &val1); |
| 7585 | bnx2x_cl45_read(bp, phy, |
| 7586 | MDIO_PMA_DEVAD, 0xc809, &val1); |
| 7587 | |
| 7588 | DP(NETIF_MSG_LINK, "8705 1.c809 val=0x%x\n", val1); |
| 7589 | link_up = ((rx_sd & 0x1) && (val1 & (1<<9)) && ((val1 & (1<<8)) == 0)); |
| 7590 | if (link_up) { |
| 7591 | vars->line_speed = SPEED_10000; |
| 7592 | bnx2x_ext_phy_resolve_fc(phy, params, vars); |
| 7593 | } |
| 7594 | return link_up; |
| 7595 | } |
| 7596 | |
| 7597 | /******************************************************************/ |
| 7598 | /* SFP+ module Section */ |
| 7599 | /******************************************************************/ |
Yaniv Rosner | 85242ee | 2011-07-05 01:06:53 +0000 | [diff] [blame] | 7600 | static void bnx2x_set_disable_pmd_transmit(struct link_params *params, |
| 7601 | struct bnx2x_phy *phy, |
| 7602 | u8 pmd_dis) |
| 7603 | { |
| 7604 | struct bnx2x *bp = params->bp; |
| 7605 | /* |
| 7606 | * Disable transmitter only for bootcodes which can enable it afterwards |
| 7607 | * (for D3 link) |
| 7608 | */ |
| 7609 | if (pmd_dis) { |
| 7610 | if (params->feature_config_flags & |
| 7611 | FEATURE_CONFIG_BC_SUPPORTS_SFP_TX_DISABLED) |
| 7612 | DP(NETIF_MSG_LINK, "Disabling PMD transmitter\n"); |
| 7613 | else { |
| 7614 | DP(NETIF_MSG_LINK, "NOT disabling PMD transmitter\n"); |
| 7615 | return; |
| 7616 | } |
| 7617 | } else |
| 7618 | DP(NETIF_MSG_LINK, "Enabling PMD transmitter\n"); |
| 7619 | bnx2x_cl45_write(bp, phy, |
| 7620 | MDIO_PMA_DEVAD, |
| 7621 | MDIO_PMA_REG_TX_DISABLE, pmd_dis); |
| 7622 | } |
| 7623 | |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 7624 | static u8 bnx2x_get_gpio_port(struct link_params *params) |
| 7625 | { |
| 7626 | u8 gpio_port; |
| 7627 | u32 swap_val, swap_override; |
| 7628 | struct bnx2x *bp = params->bp; |
| 7629 | if (CHIP_IS_E2(bp)) |
| 7630 | gpio_port = BP_PATH(bp); |
| 7631 | else |
| 7632 | gpio_port = params->port; |
| 7633 | swap_val = REG_RD(bp, NIG_REG_PORT_SWAP); |
| 7634 | swap_override = REG_RD(bp, NIG_REG_STRAP_OVERRIDE); |
| 7635 | return gpio_port ^ (swap_val && swap_override); |
| 7636 | } |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 7637 | |
| 7638 | static void bnx2x_sfp_e1e2_set_transmitter(struct link_params *params, |
| 7639 | struct bnx2x_phy *phy, |
| 7640 | u8 tx_en) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7641 | { |
| 7642 | u16 val; |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 7643 | u8 port = params->port; |
| 7644 | struct bnx2x *bp = params->bp; |
| 7645 | u32 tx_en_mode; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7646 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7647 | /* Disable/Enable transmitter ( TX laser of the SFP+ module.)*/ |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 7648 | tx_en_mode = REG_RD(bp, params->shmem_base + |
| 7649 | offsetof(struct shmem_region, |
| 7650 | dev_info.port_hw_config[port].sfp_ctrl)) & |
| 7651 | PORT_HW_CFG_TX_LASER_MASK; |
| 7652 | DP(NETIF_MSG_LINK, "Setting transmitter tx_en=%x for port %x " |
| 7653 | "mode = %x\n", tx_en, port, tx_en_mode); |
| 7654 | switch (tx_en_mode) { |
| 7655 | case PORT_HW_CFG_TX_LASER_MDIO: |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7656 | |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 7657 | bnx2x_cl45_read(bp, phy, |
| 7658 | MDIO_PMA_DEVAD, |
| 7659 | MDIO_PMA_REG_PHY_IDENTIFIER, |
| 7660 | &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7661 | |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 7662 | if (tx_en) |
| 7663 | val &= ~(1<<15); |
| 7664 | else |
| 7665 | val |= (1<<15); |
| 7666 | |
| 7667 | bnx2x_cl45_write(bp, phy, |
| 7668 | MDIO_PMA_DEVAD, |
| 7669 | MDIO_PMA_REG_PHY_IDENTIFIER, |
| 7670 | val); |
| 7671 | break; |
| 7672 | case PORT_HW_CFG_TX_LASER_GPIO0: |
| 7673 | case PORT_HW_CFG_TX_LASER_GPIO1: |
| 7674 | case PORT_HW_CFG_TX_LASER_GPIO2: |
| 7675 | case PORT_HW_CFG_TX_LASER_GPIO3: |
| 7676 | { |
| 7677 | u16 gpio_pin; |
| 7678 | u8 gpio_port, gpio_mode; |
| 7679 | if (tx_en) |
| 7680 | gpio_mode = MISC_REGISTERS_GPIO_OUTPUT_HIGH; |
| 7681 | else |
| 7682 | gpio_mode = MISC_REGISTERS_GPIO_OUTPUT_LOW; |
| 7683 | |
| 7684 | gpio_pin = tx_en_mode - PORT_HW_CFG_TX_LASER_GPIO0; |
| 7685 | gpio_port = bnx2x_get_gpio_port(params); |
| 7686 | bnx2x_set_gpio(bp, gpio_pin, gpio_mode, gpio_port); |
| 7687 | break; |
| 7688 | } |
| 7689 | default: |
| 7690 | DP(NETIF_MSG_LINK, "Invalid TX_LASER_MDIO 0x%x\n", tx_en_mode); |
| 7691 | break; |
| 7692 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7693 | } |
| 7694 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 7695 | static void bnx2x_sfp_set_transmitter(struct link_params *params, |
| 7696 | struct bnx2x_phy *phy, |
| 7697 | u8 tx_en) |
| 7698 | { |
| 7699 | struct bnx2x *bp = params->bp; |
| 7700 | DP(NETIF_MSG_LINK, "Setting SFP+ transmitter to %d\n", tx_en); |
| 7701 | if (CHIP_IS_E3(bp)) |
| 7702 | bnx2x_sfp_e3_set_transmitter(params, phy, tx_en); |
| 7703 | else |
| 7704 | bnx2x_sfp_e1e2_set_transmitter(params, phy, tx_en); |
| 7705 | } |
| 7706 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 7707 | static int bnx2x_8726_read_sfp_module_eeprom(struct bnx2x_phy *phy, |
| 7708 | struct link_params *params, |
| 7709 | u16 addr, u8 byte_cnt, u8 *o_buf) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7710 | { |
| 7711 | struct bnx2x *bp = params->bp; |
| 7712 | u16 val = 0; |
| 7713 | u16 i; |
| 7714 | if (byte_cnt > 16) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 7715 | DP(NETIF_MSG_LINK, |
| 7716 | "Reading from eeprom is limited to 0xf\n"); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7717 | return -EINVAL; |
| 7718 | } |
| 7719 | /* Set the read command byte count */ |
| 7720 | bnx2x_cl45_write(bp, phy, |
| 7721 | MDIO_PMA_DEVAD, MDIO_PMA_REG_SFP_TWO_WIRE_BYTE_CNT, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7722 | (byte_cnt | 0xa000)); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7723 | |
| 7724 | /* Set the read command address */ |
| 7725 | bnx2x_cl45_write(bp, phy, |
| 7726 | MDIO_PMA_DEVAD, MDIO_PMA_REG_SFP_TWO_WIRE_MEM_ADDR, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7727 | addr); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7728 | |
| 7729 | /* Activate read command */ |
| 7730 | bnx2x_cl45_write(bp, phy, |
| 7731 | MDIO_PMA_DEVAD, MDIO_PMA_REG_SFP_TWO_WIRE_CTRL, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7732 | 0x2c0f); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7733 | |
| 7734 | /* Wait up to 500us for command complete status */ |
| 7735 | for (i = 0; i < 100; i++) { |
| 7736 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7737 | MDIO_PMA_DEVAD, |
| 7738 | MDIO_PMA_REG_SFP_TWO_WIRE_CTRL, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7739 | if ((val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK) == |
| 7740 | MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_COMPLETE) |
| 7741 | break; |
| 7742 | udelay(5); |
| 7743 | } |
| 7744 | |
| 7745 | if ((val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK) != |
| 7746 | MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_COMPLETE) { |
| 7747 | DP(NETIF_MSG_LINK, |
| 7748 | "Got bad status 0x%x when reading from SFP+ EEPROM\n", |
| 7749 | (val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK)); |
| 7750 | return -EINVAL; |
| 7751 | } |
| 7752 | |
| 7753 | /* Read the buffer */ |
| 7754 | for (i = 0; i < byte_cnt; i++) { |
| 7755 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7756 | MDIO_PMA_DEVAD, |
| 7757 | MDIO_PMA_REG_8726_TWO_WIRE_DATA_BUF + i, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7758 | o_buf[i] = (u8)(val & MDIO_PMA_REG_8726_TWO_WIRE_DATA_MASK); |
| 7759 | } |
| 7760 | |
| 7761 | for (i = 0; i < 100; i++) { |
| 7762 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7763 | MDIO_PMA_DEVAD, |
| 7764 | MDIO_PMA_REG_SFP_TWO_WIRE_CTRL, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7765 | if ((val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK) == |
| 7766 | MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_IDLE) |
Joe Perches | 6f38ad9 | 2010-11-14 17:04:31 +0000 | [diff] [blame] | 7767 | return 0; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7768 | msleep(1); |
| 7769 | } |
| 7770 | return -EINVAL; |
| 7771 | } |
| 7772 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 7773 | static int bnx2x_warpcore_read_sfp_module_eeprom(struct bnx2x_phy *phy, |
| 7774 | struct link_params *params, |
| 7775 | u16 addr, u8 byte_cnt, |
| 7776 | u8 *o_buf) |
| 7777 | { |
| 7778 | int rc = 0; |
| 7779 | u8 i, j = 0, cnt = 0; |
| 7780 | u32 data_array[4]; |
| 7781 | u16 addr32; |
| 7782 | struct bnx2x *bp = params->bp; |
| 7783 | /*DP(NETIF_MSG_LINK, "bnx2x_direct_read_sfp_module_eeprom:" |
| 7784 | " addr %d, cnt %d\n", |
| 7785 | addr, byte_cnt);*/ |
| 7786 | if (byte_cnt > 16) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 7787 | DP(NETIF_MSG_LINK, |
| 7788 | "Reading from eeprom is limited to 16 bytes\n"); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 7789 | return -EINVAL; |
| 7790 | } |
| 7791 | |
| 7792 | /* 4 byte aligned address */ |
| 7793 | addr32 = addr & (~0x3); |
| 7794 | do { |
| 7795 | rc = bnx2x_bsc_read(params, phy, 0xa0, addr32, 0, byte_cnt, |
| 7796 | data_array); |
| 7797 | } while ((rc != 0) && (++cnt < I2C_WA_RETRY_CNT)); |
| 7798 | |
| 7799 | if (rc == 0) { |
| 7800 | for (i = (addr - addr32); i < byte_cnt + (addr - addr32); i++) { |
| 7801 | o_buf[j] = *((u8 *)data_array + i); |
| 7802 | j++; |
| 7803 | } |
| 7804 | } |
| 7805 | |
| 7806 | return rc; |
| 7807 | } |
| 7808 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 7809 | static int bnx2x_8727_read_sfp_module_eeprom(struct bnx2x_phy *phy, |
| 7810 | struct link_params *params, |
| 7811 | u16 addr, u8 byte_cnt, u8 *o_buf) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7812 | { |
| 7813 | struct bnx2x *bp = params->bp; |
| 7814 | u16 val, i; |
| 7815 | |
| 7816 | if (byte_cnt > 16) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 7817 | DP(NETIF_MSG_LINK, |
| 7818 | "Reading from eeprom is limited to 0xf\n"); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7819 | return -EINVAL; |
| 7820 | } |
| 7821 | |
| 7822 | /* Need to read from 1.8000 to clear it */ |
| 7823 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7824 | MDIO_PMA_DEVAD, |
| 7825 | MDIO_PMA_REG_SFP_TWO_WIRE_CTRL, |
| 7826 | &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7827 | |
| 7828 | /* Set the read command byte count */ |
| 7829 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7830 | MDIO_PMA_DEVAD, |
| 7831 | MDIO_PMA_REG_SFP_TWO_WIRE_BYTE_CNT, |
| 7832 | ((byte_cnt < 2) ? 2 : byte_cnt)); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7833 | |
| 7834 | /* Set the read command address */ |
| 7835 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7836 | MDIO_PMA_DEVAD, |
| 7837 | MDIO_PMA_REG_SFP_TWO_WIRE_MEM_ADDR, |
| 7838 | addr); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7839 | /* Set the destination address */ |
| 7840 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7841 | MDIO_PMA_DEVAD, |
| 7842 | 0x8004, |
| 7843 | MDIO_PMA_REG_8727_TWO_WIRE_DATA_BUF); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7844 | |
| 7845 | /* Activate read command */ |
| 7846 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7847 | MDIO_PMA_DEVAD, |
| 7848 | MDIO_PMA_REG_SFP_TWO_WIRE_CTRL, |
| 7849 | 0x8002); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7850 | /* |
| 7851 | * Wait appropriate time for two-wire command to finish before |
| 7852 | * polling the status register |
| 7853 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7854 | msleep(1); |
| 7855 | |
| 7856 | /* Wait up to 500us for command complete status */ |
| 7857 | for (i = 0; i < 100; i++) { |
| 7858 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7859 | MDIO_PMA_DEVAD, |
| 7860 | MDIO_PMA_REG_SFP_TWO_WIRE_CTRL, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7861 | if ((val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK) == |
| 7862 | MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_COMPLETE) |
| 7863 | break; |
| 7864 | udelay(5); |
| 7865 | } |
| 7866 | |
| 7867 | if ((val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK) != |
| 7868 | MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_COMPLETE) { |
| 7869 | DP(NETIF_MSG_LINK, |
| 7870 | "Got bad status 0x%x when reading from SFP+ EEPROM\n", |
| 7871 | (val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK)); |
Yaniv Rosner | 65a001b | 2011-01-31 04:22:03 +0000 | [diff] [blame] | 7872 | return -EFAULT; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7873 | } |
| 7874 | |
| 7875 | /* Read the buffer */ |
| 7876 | for (i = 0; i < byte_cnt; i++) { |
| 7877 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7878 | MDIO_PMA_DEVAD, |
| 7879 | MDIO_PMA_REG_8727_TWO_WIRE_DATA_BUF + i, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7880 | o_buf[i] = (u8)(val & MDIO_PMA_REG_8727_TWO_WIRE_DATA_MASK); |
| 7881 | } |
| 7882 | |
| 7883 | for (i = 0; i < 100; i++) { |
| 7884 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7885 | MDIO_PMA_DEVAD, |
| 7886 | MDIO_PMA_REG_SFP_TWO_WIRE_CTRL, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7887 | if ((val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK) == |
| 7888 | MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_IDLE) |
Joe Perches | 6f38ad9 | 2010-11-14 17:04:31 +0000 | [diff] [blame] | 7889 | return 0; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7890 | msleep(1); |
| 7891 | } |
| 7892 | |
| 7893 | return -EINVAL; |
| 7894 | } |
| 7895 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 7896 | int bnx2x_read_sfp_module_eeprom(struct bnx2x_phy *phy, |
| 7897 | struct link_params *params, u16 addr, |
| 7898 | u8 byte_cnt, u8 *o_buf) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7899 | { |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 7900 | int rc = -EINVAL; |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 7901 | switch (phy->type) { |
| 7902 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726: |
| 7903 | rc = bnx2x_8726_read_sfp_module_eeprom(phy, params, addr, |
| 7904 | byte_cnt, o_buf); |
| 7905 | break; |
| 7906 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727: |
| 7907 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8722: |
| 7908 | rc = bnx2x_8727_read_sfp_module_eeprom(phy, params, addr, |
| 7909 | byte_cnt, o_buf); |
| 7910 | break; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 7911 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT: |
| 7912 | rc = bnx2x_warpcore_read_sfp_module_eeprom(phy, params, addr, |
| 7913 | byte_cnt, o_buf); |
| 7914 | break; |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 7915 | } |
| 7916 | return rc; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7917 | } |
| 7918 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 7919 | static int bnx2x_get_edc_mode(struct bnx2x_phy *phy, |
| 7920 | struct link_params *params, |
| 7921 | u16 *edc_mode) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7922 | { |
| 7923 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 7924 | u32 sync_offset = 0, phy_idx, media_types; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7925 | u8 val, check_limiting_mode = 0; |
| 7926 | *edc_mode = EDC_MODE_LIMITING; |
| 7927 | |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 7928 | phy->media_type = ETH_PHY_UNSPECIFIED; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7929 | /* First check for copper cable */ |
| 7930 | if (bnx2x_read_sfp_module_eeprom(phy, |
| 7931 | params, |
| 7932 | SFP_EEPROM_CON_TYPE_ADDR, |
| 7933 | 1, |
| 7934 | &val) != 0) { |
| 7935 | DP(NETIF_MSG_LINK, "Failed to read from SFP+ module EEPROM\n"); |
| 7936 | return -EINVAL; |
| 7937 | } |
| 7938 | |
| 7939 | switch (val) { |
| 7940 | case SFP_EEPROM_CON_TYPE_VAL_COPPER: |
| 7941 | { |
| 7942 | u8 copper_module_type; |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 7943 | phy->media_type = ETH_PHY_DA_TWINAX; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7944 | /* |
| 7945 | * Check if its active cable (includes SFP+ module) |
| 7946 | * of passive cable |
| 7947 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7948 | if (bnx2x_read_sfp_module_eeprom(phy, |
| 7949 | params, |
| 7950 | SFP_EEPROM_FC_TX_TECH_ADDR, |
| 7951 | 1, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 7952 | &copper_module_type) != 0) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7953 | DP(NETIF_MSG_LINK, |
| 7954 | "Failed to read copper-cable-type" |
| 7955 | " from SFP+ EEPROM\n"); |
| 7956 | return -EINVAL; |
| 7957 | } |
| 7958 | |
| 7959 | if (copper_module_type & |
| 7960 | SFP_EEPROM_FC_TX_TECH_BITMASK_COPPER_ACTIVE) { |
| 7961 | DP(NETIF_MSG_LINK, "Active Copper cable detected\n"); |
| 7962 | check_limiting_mode = 1; |
| 7963 | } else if (copper_module_type & |
| 7964 | SFP_EEPROM_FC_TX_TECH_BITMASK_COPPER_PASSIVE) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 7965 | DP(NETIF_MSG_LINK, |
| 7966 | "Passive Copper cable detected\n"); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7967 | *edc_mode = |
| 7968 | EDC_MODE_PASSIVE_DAC; |
| 7969 | } else { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 7970 | DP(NETIF_MSG_LINK, |
| 7971 | "Unknown copper-cable-type 0x%x !!!\n", |
| 7972 | copper_module_type); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7973 | return -EINVAL; |
| 7974 | } |
| 7975 | break; |
| 7976 | } |
| 7977 | case SFP_EEPROM_CON_TYPE_VAL_LC: |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 7978 | phy->media_type = ETH_PHY_SFP_FIBER; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7979 | DP(NETIF_MSG_LINK, "Optic module detected\n"); |
| 7980 | check_limiting_mode = 1; |
| 7981 | break; |
| 7982 | default: |
| 7983 | DP(NETIF_MSG_LINK, "Unable to determine module type 0x%x !!!\n", |
| 7984 | val); |
| 7985 | return -EINVAL; |
| 7986 | } |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 7987 | sync_offset = params->shmem_base + |
| 7988 | offsetof(struct shmem_region, |
| 7989 | dev_info.port_hw_config[params->port].media_type); |
| 7990 | media_types = REG_RD(bp, sync_offset); |
| 7991 | /* Update media type for non-PMF sync */ |
| 7992 | for (phy_idx = INT_PHY; phy_idx < MAX_PHYS; phy_idx++) { |
| 7993 | if (&(params->phy[phy_idx]) == phy) { |
| 7994 | media_types &= ~(PORT_HW_CFG_MEDIA_TYPE_PHY0_MASK << |
| 7995 | (PORT_HW_CFG_MEDIA_TYPE_PHY1_SHIFT * phy_idx)); |
| 7996 | media_types |= ((phy->media_type & |
| 7997 | PORT_HW_CFG_MEDIA_TYPE_PHY0_MASK) << |
| 7998 | (PORT_HW_CFG_MEDIA_TYPE_PHY1_SHIFT * phy_idx)); |
| 7999 | break; |
| 8000 | } |
| 8001 | } |
| 8002 | REG_WR(bp, sync_offset, media_types); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8003 | if (check_limiting_mode) { |
| 8004 | u8 options[SFP_EEPROM_OPTIONS_SIZE]; |
| 8005 | if (bnx2x_read_sfp_module_eeprom(phy, |
| 8006 | params, |
| 8007 | SFP_EEPROM_OPTIONS_ADDR, |
| 8008 | SFP_EEPROM_OPTIONS_SIZE, |
| 8009 | options) != 0) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 8010 | DP(NETIF_MSG_LINK, |
| 8011 | "Failed to read Option field from module EEPROM\n"); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8012 | return -EINVAL; |
| 8013 | } |
| 8014 | if ((options[0] & SFP_EEPROM_OPTIONS_LINEAR_RX_OUT_MASK)) |
| 8015 | *edc_mode = EDC_MODE_LINEAR; |
| 8016 | else |
| 8017 | *edc_mode = EDC_MODE_LIMITING; |
| 8018 | } |
| 8019 | DP(NETIF_MSG_LINK, "EDC mode is set to 0x%x\n", *edc_mode); |
| 8020 | return 0; |
| 8021 | } |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8022 | /* |
| 8023 | * This function read the relevant field from the module (SFP+), and verify it |
| 8024 | * is compliant with this board |
| 8025 | */ |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 8026 | static int bnx2x_verify_sfp_module(struct bnx2x_phy *phy, |
| 8027 | struct link_params *params) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8028 | { |
| 8029 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8030 | u32 val, cmd; |
| 8031 | u32 fw_resp, fw_cmd_param; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8032 | char vendor_name[SFP_EEPROM_VENDOR_NAME_SIZE+1]; |
| 8033 | char vendor_pn[SFP_EEPROM_PART_NO_SIZE+1]; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8034 | phy->flags &= ~FLAGS_SFP_NOT_APPROVED; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8035 | val = REG_RD(bp, params->shmem_base + |
| 8036 | offsetof(struct shmem_region, dev_info. |
| 8037 | port_feature_config[params->port].config)); |
| 8038 | if ((val & PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK) == |
| 8039 | PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_NO_ENFORCEMENT) { |
| 8040 | DP(NETIF_MSG_LINK, "NOT enforcing module verification\n"); |
| 8041 | return 0; |
| 8042 | } |
| 8043 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8044 | if (params->feature_config_flags & |
| 8045 | FEATURE_CONFIG_BC_SUPPORTS_DUAL_PHY_OPT_MDL_VRFY) { |
| 8046 | /* Use specific phy request */ |
| 8047 | cmd = DRV_MSG_CODE_VRFY_SPECIFIC_PHY_OPT_MDL; |
| 8048 | } else if (params->feature_config_flags & |
| 8049 | FEATURE_CONFIG_BC_SUPPORTS_OPT_MDL_VRFY) { |
| 8050 | /* Use first phy request only in case of non-dual media*/ |
| 8051 | if (DUAL_MEDIA(params)) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 8052 | DP(NETIF_MSG_LINK, |
| 8053 | "FW does not support OPT MDL verification\n"); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8054 | return -EINVAL; |
| 8055 | } |
| 8056 | cmd = DRV_MSG_CODE_VRFY_FIRST_PHY_OPT_MDL; |
| 8057 | } else { |
| 8058 | /* No support in OPT MDL detection */ |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 8059 | DP(NETIF_MSG_LINK, |
| 8060 | "FW does not support OPT MDL verification\n"); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8061 | return -EINVAL; |
| 8062 | } |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 8063 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8064 | fw_cmd_param = FW_PARAM_SET(phy->addr, phy->type, phy->mdio_ctrl); |
| 8065 | fw_resp = bnx2x_fw_command(bp, cmd, fw_cmd_param); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8066 | if (fw_resp == FW_MSG_CODE_VRFY_OPT_MDL_SUCCESS) { |
| 8067 | DP(NETIF_MSG_LINK, "Approved module\n"); |
| 8068 | return 0; |
| 8069 | } |
| 8070 | |
| 8071 | /* format the warning message */ |
| 8072 | if (bnx2x_read_sfp_module_eeprom(phy, |
| 8073 | params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8074 | SFP_EEPROM_VENDOR_NAME_ADDR, |
| 8075 | SFP_EEPROM_VENDOR_NAME_SIZE, |
| 8076 | (u8 *)vendor_name)) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8077 | vendor_name[0] = '\0'; |
| 8078 | else |
| 8079 | vendor_name[SFP_EEPROM_VENDOR_NAME_SIZE] = '\0'; |
| 8080 | if (bnx2x_read_sfp_module_eeprom(phy, |
| 8081 | params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8082 | SFP_EEPROM_PART_NO_ADDR, |
| 8083 | SFP_EEPROM_PART_NO_SIZE, |
| 8084 | (u8 *)vendor_pn)) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8085 | vendor_pn[0] = '\0'; |
| 8086 | else |
| 8087 | vendor_pn[SFP_EEPROM_PART_NO_SIZE] = '\0'; |
| 8088 | |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 8089 | netdev_err(bp->dev, "Warning: Unqualified SFP+ module detected," |
| 8090 | " Port %d from %s part number %s\n", |
| 8091 | params->port, vendor_name, vendor_pn); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8092 | phy->flags |= FLAGS_SFP_NOT_APPROVED; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8093 | return -EINVAL; |
| 8094 | } |
| 8095 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 8096 | static int bnx2x_wait_for_sfp_module_initialized(struct bnx2x_phy *phy, |
| 8097 | struct link_params *params) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8098 | |
| 8099 | { |
| 8100 | u8 val; |
| 8101 | struct bnx2x *bp = params->bp; |
| 8102 | u16 timeout; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8103 | /* |
| 8104 | * Initialization time after hot-plug may take up to 300ms for |
| 8105 | * some phys type ( e.g. JDSU ) |
| 8106 | */ |
| 8107 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8108 | for (timeout = 0; timeout < 60; timeout++) { |
| 8109 | if (bnx2x_read_sfp_module_eeprom(phy, params, 1, 1, &val) |
| 8110 | == 0) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 8111 | DP(NETIF_MSG_LINK, |
| 8112 | "SFP+ module initialization took %d ms\n", |
| 8113 | timeout * 5); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8114 | return 0; |
| 8115 | } |
| 8116 | msleep(5); |
| 8117 | } |
| 8118 | return -EINVAL; |
| 8119 | } |
| 8120 | |
| 8121 | static void bnx2x_8727_power_module(struct bnx2x *bp, |
| 8122 | struct bnx2x_phy *phy, |
| 8123 | u8 is_power_up) { |
| 8124 | /* Make sure GPIOs are not using for LED mode */ |
| 8125 | u16 val; |
| 8126 | /* |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8127 | * 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] | 8128 | * operating as INPUT or as OUTPUT. Bit 1 is for input, and 0 for |
| 8129 | * output |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8130 | * Bits 0-1 determine the GPIOs value for OUTPUT in case bit 4 val is 0 |
| 8131 | * 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] | 8132 | * where the 1st bit is the over-current(only input), and 2nd bit is |
| 8133 | * for power( only output ) |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8134 | * |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8135 | * In case of NOC feature is disabled and power is up, set GPIO control |
| 8136 | * as input to enable listening of over-current indication |
| 8137 | */ |
| 8138 | if (phy->flags & FLAGS_NOC) |
| 8139 | return; |
Yaniv Rosner | 27d0243 | 2011-05-31 21:27:48 +0000 | [diff] [blame] | 8140 | if (is_power_up) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8141 | val = (1<<4); |
| 8142 | else |
| 8143 | /* |
| 8144 | * Set GPIO control to OUTPUT, and set the power bit |
| 8145 | * to according to the is_power_up |
| 8146 | */ |
Yaniv Rosner | 27d0243 | 2011-05-31 21:27:48 +0000 | [diff] [blame] | 8147 | val = (1<<1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8148 | |
| 8149 | bnx2x_cl45_write(bp, phy, |
| 8150 | MDIO_PMA_DEVAD, |
| 8151 | MDIO_PMA_REG_8727_GPIO_CTRL, |
| 8152 | val); |
| 8153 | } |
| 8154 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 8155 | static int bnx2x_8726_set_limiting_mode(struct bnx2x *bp, |
| 8156 | struct bnx2x_phy *phy, |
| 8157 | u16 edc_mode) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8158 | { |
| 8159 | u16 cur_limiting_mode; |
| 8160 | |
| 8161 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8162 | MDIO_PMA_DEVAD, |
| 8163 | MDIO_PMA_REG_ROM_VER2, |
| 8164 | &cur_limiting_mode); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8165 | DP(NETIF_MSG_LINK, "Current Limiting mode is 0x%x\n", |
| 8166 | cur_limiting_mode); |
| 8167 | |
| 8168 | if (edc_mode == EDC_MODE_LIMITING) { |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8169 | DP(NETIF_MSG_LINK, "Setting LIMITING MODE\n"); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8170 | bnx2x_cl45_write(bp, phy, |
| 8171 | MDIO_PMA_DEVAD, |
| 8172 | MDIO_PMA_REG_ROM_VER2, |
| 8173 | EDC_MODE_LIMITING); |
| 8174 | } else { /* LRM mode ( default )*/ |
| 8175 | |
| 8176 | DP(NETIF_MSG_LINK, "Setting LRM MODE\n"); |
| 8177 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8178 | /* |
| 8179 | * Changing to LRM mode takes quite few seconds. So do it only |
| 8180 | * if current mode is limiting (default is LRM) |
| 8181 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8182 | if (cur_limiting_mode != EDC_MODE_LIMITING) |
| 8183 | return 0; |
| 8184 | |
| 8185 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8186 | MDIO_PMA_DEVAD, |
| 8187 | MDIO_PMA_REG_LRM_MODE, |
| 8188 | 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8189 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8190 | MDIO_PMA_DEVAD, |
| 8191 | MDIO_PMA_REG_ROM_VER2, |
| 8192 | 0x128); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8193 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8194 | MDIO_PMA_DEVAD, |
| 8195 | MDIO_PMA_REG_MISC_CTRL0, |
| 8196 | 0x4008); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8197 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8198 | MDIO_PMA_DEVAD, |
| 8199 | MDIO_PMA_REG_LRM_MODE, |
| 8200 | 0xaaaa); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8201 | } |
| 8202 | return 0; |
| 8203 | } |
| 8204 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 8205 | static int bnx2x_8727_set_limiting_mode(struct bnx2x *bp, |
| 8206 | struct bnx2x_phy *phy, |
| 8207 | u16 edc_mode) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8208 | { |
| 8209 | u16 phy_identifier; |
| 8210 | u16 rom_ver2_val; |
| 8211 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8212 | MDIO_PMA_DEVAD, |
| 8213 | MDIO_PMA_REG_PHY_IDENTIFIER, |
| 8214 | &phy_identifier); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8215 | |
| 8216 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8217 | MDIO_PMA_DEVAD, |
| 8218 | MDIO_PMA_REG_PHY_IDENTIFIER, |
| 8219 | (phy_identifier & ~(1<<9))); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8220 | |
| 8221 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8222 | MDIO_PMA_DEVAD, |
| 8223 | MDIO_PMA_REG_ROM_VER2, |
| 8224 | &rom_ver2_val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8225 | /* Keep the MSB 8-bits, and set the LSB 8-bits with the edc_mode */ |
| 8226 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8227 | MDIO_PMA_DEVAD, |
| 8228 | MDIO_PMA_REG_ROM_VER2, |
| 8229 | (rom_ver2_val & 0xff00) | (edc_mode & 0x00ff)); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8230 | |
| 8231 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8232 | MDIO_PMA_DEVAD, |
| 8233 | MDIO_PMA_REG_PHY_IDENTIFIER, |
| 8234 | (phy_identifier | (1<<9))); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8235 | |
| 8236 | return 0; |
| 8237 | } |
| 8238 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8239 | static void bnx2x_8727_specific_func(struct bnx2x_phy *phy, |
| 8240 | struct link_params *params, |
| 8241 | u32 action) |
| 8242 | { |
| 8243 | struct bnx2x *bp = params->bp; |
| 8244 | |
| 8245 | switch (action) { |
| 8246 | case DISABLE_TX: |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8247 | bnx2x_sfp_set_transmitter(params, phy, 0); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8248 | break; |
| 8249 | case ENABLE_TX: |
| 8250 | if (!(phy->flags & FLAGS_SFP_NOT_APPROVED)) |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8251 | bnx2x_sfp_set_transmitter(params, phy, 1); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8252 | break; |
| 8253 | default: |
| 8254 | DP(NETIF_MSG_LINK, "Function 0x%x not supported by 8727\n", |
| 8255 | action); |
| 8256 | return; |
| 8257 | } |
| 8258 | } |
| 8259 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8260 | static void bnx2x_set_e1e2_module_fault_led(struct link_params *params, |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8261 | u8 gpio_mode) |
| 8262 | { |
| 8263 | struct bnx2x *bp = params->bp; |
| 8264 | |
| 8265 | u32 fault_led_gpio = REG_RD(bp, params->shmem_base + |
| 8266 | offsetof(struct shmem_region, |
| 8267 | dev_info.port_hw_config[params->port].sfp_ctrl)) & |
| 8268 | PORT_HW_CFG_FAULT_MODULE_LED_MASK; |
| 8269 | switch (fault_led_gpio) { |
| 8270 | case PORT_HW_CFG_FAULT_MODULE_LED_DISABLED: |
| 8271 | return; |
| 8272 | case PORT_HW_CFG_FAULT_MODULE_LED_GPIO0: |
| 8273 | case PORT_HW_CFG_FAULT_MODULE_LED_GPIO1: |
| 8274 | case PORT_HW_CFG_FAULT_MODULE_LED_GPIO2: |
| 8275 | case PORT_HW_CFG_FAULT_MODULE_LED_GPIO3: |
| 8276 | { |
| 8277 | u8 gpio_port = bnx2x_get_gpio_port(params); |
| 8278 | u16 gpio_pin = fault_led_gpio - |
| 8279 | PORT_HW_CFG_FAULT_MODULE_LED_GPIO0; |
| 8280 | DP(NETIF_MSG_LINK, "Set fault module-detected led " |
| 8281 | "pin %x port %x mode %x\n", |
| 8282 | gpio_pin, gpio_port, gpio_mode); |
| 8283 | bnx2x_set_gpio(bp, gpio_pin, gpio_mode, gpio_port); |
| 8284 | } |
| 8285 | break; |
| 8286 | default: |
| 8287 | DP(NETIF_MSG_LINK, "Error: Invalid fault led mode 0x%x\n", |
| 8288 | fault_led_gpio); |
| 8289 | } |
| 8290 | } |
| 8291 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8292 | static void bnx2x_set_e3_module_fault_led(struct link_params *params, |
| 8293 | u8 gpio_mode) |
| 8294 | { |
| 8295 | u32 pin_cfg; |
| 8296 | u8 port = params->port; |
| 8297 | struct bnx2x *bp = params->bp; |
| 8298 | pin_cfg = (REG_RD(bp, params->shmem_base + |
| 8299 | offsetof(struct shmem_region, |
| 8300 | dev_info.port_hw_config[port].e3_sfp_ctrl)) & |
| 8301 | PORT_HW_CFG_E3_FAULT_MDL_LED_MASK) >> |
| 8302 | PORT_HW_CFG_E3_FAULT_MDL_LED_SHIFT; |
| 8303 | DP(NETIF_MSG_LINK, "Setting Fault LED to %d using pin cfg %d\n", |
| 8304 | gpio_mode, pin_cfg); |
| 8305 | bnx2x_set_cfg_pin(bp, pin_cfg, gpio_mode); |
| 8306 | } |
| 8307 | |
| 8308 | static void bnx2x_set_sfp_module_fault_led(struct link_params *params, |
| 8309 | u8 gpio_mode) |
| 8310 | { |
| 8311 | struct bnx2x *bp = params->bp; |
| 8312 | DP(NETIF_MSG_LINK, "Setting SFP+ module fault LED to %d\n", gpio_mode); |
| 8313 | if (CHIP_IS_E3(bp)) { |
| 8314 | /* |
| 8315 | * Low ==> if SFP+ module is supported otherwise |
| 8316 | * High ==> if SFP+ module is not on the approved vendor list |
| 8317 | */ |
| 8318 | bnx2x_set_e3_module_fault_led(params, gpio_mode); |
| 8319 | } else |
| 8320 | bnx2x_set_e1e2_module_fault_led(params, gpio_mode); |
| 8321 | } |
| 8322 | |
| 8323 | static void bnx2x_warpcore_power_module(struct link_params *params, |
| 8324 | struct bnx2x_phy *phy, |
| 8325 | u8 power) |
| 8326 | { |
| 8327 | u32 pin_cfg; |
| 8328 | struct bnx2x *bp = params->bp; |
| 8329 | |
| 8330 | pin_cfg = (REG_RD(bp, params->shmem_base + |
| 8331 | offsetof(struct shmem_region, |
| 8332 | dev_info.port_hw_config[params->port].e3_sfp_ctrl)) & |
| 8333 | PORT_HW_CFG_E3_PWR_DIS_MASK) >> |
| 8334 | PORT_HW_CFG_E3_PWR_DIS_SHIFT; |
Yaniv Rosner | 985848f | 2011-07-05 01:06:48 +0000 | [diff] [blame] | 8335 | |
| 8336 | if (pin_cfg == PIN_CFG_NA) |
| 8337 | return; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8338 | DP(NETIF_MSG_LINK, "Setting SFP+ module power to %d using pin cfg %d\n", |
| 8339 | power, pin_cfg); |
| 8340 | /* |
| 8341 | * Low ==> corresponding SFP+ module is powered |
| 8342 | * high ==> the SFP+ module is powered down |
| 8343 | */ |
| 8344 | bnx2x_set_cfg_pin(bp, pin_cfg, power ^ 1); |
| 8345 | } |
| 8346 | |
Yaniv Rosner | 985848f | 2011-07-05 01:06:48 +0000 | [diff] [blame] | 8347 | static void bnx2x_warpcore_hw_reset(struct bnx2x_phy *phy, |
| 8348 | struct link_params *params) |
| 8349 | { |
Yaniv Rosner | b76070b | 2011-11-28 00:49:47 +0000 | [diff] [blame] | 8350 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 985848f | 2011-07-05 01:06:48 +0000 | [diff] [blame] | 8351 | bnx2x_warpcore_power_module(params, phy, 0); |
Yaniv Rosner | b76070b | 2011-11-28 00:49:47 +0000 | [diff] [blame] | 8352 | /* Put Warpcore in low power mode */ |
| 8353 | REG_WR(bp, MISC_REG_WC0_RESET, 0x0c0e); |
| 8354 | |
| 8355 | /* Put LCPLL in low power mode */ |
| 8356 | REG_WR(bp, MISC_REG_LCPLL_E40_PWRDWN, 1); |
| 8357 | REG_WR(bp, MISC_REG_LCPLL_E40_RESETB_ANA, 0); |
| 8358 | REG_WR(bp, MISC_REG_LCPLL_E40_RESETB_DIG, 0); |
Yaniv Rosner | 985848f | 2011-07-05 01:06:48 +0000 | [diff] [blame] | 8359 | } |
| 8360 | |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 8361 | static void bnx2x_power_sfp_module(struct link_params *params, |
| 8362 | struct bnx2x_phy *phy, |
| 8363 | u8 power) |
| 8364 | { |
| 8365 | struct bnx2x *bp = params->bp; |
| 8366 | DP(NETIF_MSG_LINK, "Setting SFP+ power to %x\n", power); |
| 8367 | |
| 8368 | switch (phy->type) { |
| 8369 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727: |
| 8370 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8722: |
| 8371 | bnx2x_8727_power_module(params->bp, phy, power); |
| 8372 | break; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8373 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT: |
| 8374 | bnx2x_warpcore_power_module(params, phy, power); |
| 8375 | break; |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 8376 | default: |
| 8377 | break; |
| 8378 | } |
| 8379 | } |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8380 | static void bnx2x_warpcore_set_limiting_mode(struct link_params *params, |
| 8381 | struct bnx2x_phy *phy, |
| 8382 | u16 edc_mode) |
| 8383 | { |
| 8384 | u16 val = 0; |
| 8385 | u16 mode = MDIO_WC_REG_UC_INFO_B1_FIRMWARE_MODE_DEFAULT; |
| 8386 | struct bnx2x *bp = params->bp; |
| 8387 | |
| 8388 | u8 lane = bnx2x_get_warpcore_lane(phy, params); |
| 8389 | /* This is a global register which controls all lanes */ |
| 8390 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 8391 | MDIO_WC_REG_UC_INFO_B1_FIRMWARE_MODE, &val); |
| 8392 | val &= ~(0xf << (lane << 2)); |
| 8393 | |
| 8394 | switch (edc_mode) { |
| 8395 | case EDC_MODE_LINEAR: |
| 8396 | case EDC_MODE_LIMITING: |
| 8397 | mode = MDIO_WC_REG_UC_INFO_B1_FIRMWARE_MODE_DEFAULT; |
| 8398 | break; |
| 8399 | case EDC_MODE_PASSIVE_DAC: |
| 8400 | mode = MDIO_WC_REG_UC_INFO_B1_FIRMWARE_MODE_SFP_DAC; |
| 8401 | break; |
| 8402 | default: |
| 8403 | break; |
| 8404 | } |
| 8405 | |
| 8406 | val |= (mode << (lane << 2)); |
| 8407 | bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, |
| 8408 | MDIO_WC_REG_UC_INFO_B1_FIRMWARE_MODE, val); |
| 8409 | /* A must read */ |
| 8410 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 8411 | MDIO_WC_REG_UC_INFO_B1_FIRMWARE_MODE, &val); |
| 8412 | |
Yaniv Rosner | 19af03a | 2011-08-02 22:59:47 +0000 | [diff] [blame] | 8413 | /* Restart microcode to re-read the new mode */ |
| 8414 | bnx2x_warpcore_reset_lane(bp, phy, 1); |
| 8415 | bnx2x_warpcore_reset_lane(bp, phy, 0); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8416 | |
| 8417 | } |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 8418 | |
| 8419 | static void bnx2x_set_limiting_mode(struct link_params *params, |
| 8420 | struct bnx2x_phy *phy, |
| 8421 | u16 edc_mode) |
| 8422 | { |
| 8423 | switch (phy->type) { |
| 8424 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726: |
| 8425 | bnx2x_8726_set_limiting_mode(params->bp, phy, edc_mode); |
| 8426 | break; |
| 8427 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727: |
| 8428 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8722: |
| 8429 | bnx2x_8727_set_limiting_mode(params->bp, phy, edc_mode); |
| 8430 | break; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8431 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT: |
| 8432 | bnx2x_warpcore_set_limiting_mode(params, phy, edc_mode); |
| 8433 | break; |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 8434 | } |
| 8435 | } |
| 8436 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 8437 | int bnx2x_sfp_module_detection(struct bnx2x_phy *phy, |
| 8438 | struct link_params *params) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8439 | { |
| 8440 | struct bnx2x *bp = params->bp; |
| 8441 | u16 edc_mode; |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 8442 | int rc = 0; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8443 | |
| 8444 | u32 val = REG_RD(bp, params->shmem_base + |
| 8445 | offsetof(struct shmem_region, dev_info. |
| 8446 | port_feature_config[params->port].config)); |
| 8447 | |
| 8448 | DP(NETIF_MSG_LINK, "SFP+ module plugged in/out detected on port %d\n", |
| 8449 | params->port); |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 8450 | /* Power up module */ |
| 8451 | bnx2x_power_sfp_module(params, phy, 1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8452 | if (bnx2x_get_edc_mode(phy, params, &edc_mode) != 0) { |
| 8453 | DP(NETIF_MSG_LINK, "Failed to get valid module type\n"); |
| 8454 | return -EINVAL; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8455 | } else if (bnx2x_verify_sfp_module(phy, params) != 0) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8456 | /* check SFP+ module compatibility */ |
| 8457 | DP(NETIF_MSG_LINK, "Module verification failed!!\n"); |
| 8458 | rc = -EINVAL; |
| 8459 | /* Turn on fault module-detected led */ |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8460 | bnx2x_set_sfp_module_fault_led(params, |
| 8461 | MISC_REGISTERS_GPIO_HIGH); |
| 8462 | |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 8463 | /* Check if need to power down the SFP+ module */ |
| 8464 | if ((val & PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK) == |
| 8465 | PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_POWER_DOWN) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8466 | DP(NETIF_MSG_LINK, "Shutdown SFP+ module!!\n"); |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 8467 | bnx2x_power_sfp_module(params, phy, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8468 | return rc; |
| 8469 | } |
| 8470 | } else { |
| 8471 | /* Turn off fault module-detected led */ |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8472 | bnx2x_set_sfp_module_fault_led(params, MISC_REGISTERS_GPIO_LOW); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8473 | } |
| 8474 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8475 | /* |
| 8476 | * Check and set limiting mode / LRM mode on 8726. On 8727 it |
| 8477 | * is done automatically |
| 8478 | */ |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 8479 | bnx2x_set_limiting_mode(params, phy, edc_mode); |
| 8480 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8481 | /* |
| 8482 | * Enable transmit for this module if the module is approved, or |
| 8483 | * if unapproved modules should also enable the Tx laser |
| 8484 | */ |
| 8485 | if (rc == 0 || |
| 8486 | (val & PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK) != |
| 8487 | PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_DISABLE_TX_LASER) |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8488 | bnx2x_sfp_set_transmitter(params, phy, 1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8489 | else |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8490 | bnx2x_sfp_set_transmitter(params, phy, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8491 | |
| 8492 | return rc; |
| 8493 | } |
| 8494 | |
| 8495 | void bnx2x_handle_module_detect_int(struct link_params *params) |
| 8496 | { |
| 8497 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8498 | struct bnx2x_phy *phy; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8499 | u32 gpio_val; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8500 | u8 gpio_num, gpio_port; |
| 8501 | if (CHIP_IS_E3(bp)) |
| 8502 | phy = ¶ms->phy[INT_PHY]; |
| 8503 | else |
| 8504 | phy = ¶ms->phy[EXT_PHY1]; |
| 8505 | |
| 8506 | if (bnx2x_get_mod_abs_int_cfg(bp, params->chip_id, params->shmem_base, |
| 8507 | params->port, &gpio_num, &gpio_port) == |
| 8508 | -EINVAL) { |
| 8509 | DP(NETIF_MSG_LINK, "Failed to get MOD_ABS interrupt config\n"); |
| 8510 | return; |
| 8511 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8512 | |
| 8513 | /* Set valid module led off */ |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8514 | bnx2x_set_sfp_module_fault_led(params, MISC_REGISTERS_GPIO_HIGH); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8515 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8516 | /* Get current gpio val reflecting module plugged in / out*/ |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8517 | gpio_val = bnx2x_get_gpio(bp, gpio_num, gpio_port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8518 | |
| 8519 | /* Call the handling function in case module is detected */ |
| 8520 | if (gpio_val == 0) { |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 8521 | bnx2x_power_sfp_module(params, phy, 1); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8522 | bnx2x_set_gpio_int(bp, gpio_num, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8523 | MISC_REGISTERS_GPIO_INT_OUTPUT_CLR, |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8524 | gpio_port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8525 | if (bnx2x_wait_for_sfp_module_initialized(phy, params) == 0) |
| 8526 | bnx2x_sfp_module_detection(phy, params); |
| 8527 | else |
| 8528 | DP(NETIF_MSG_LINK, "SFP+ module is not initialized\n"); |
| 8529 | } else { |
| 8530 | u32 val = REG_RD(bp, params->shmem_base + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8531 | offsetof(struct shmem_region, dev_info. |
| 8532 | port_feature_config[params->port]. |
| 8533 | config)); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8534 | bnx2x_set_gpio_int(bp, gpio_num, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8535 | MISC_REGISTERS_GPIO_INT_OUTPUT_SET, |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 8536 | gpio_port); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8537 | /* |
| 8538 | * Module was plugged out. |
| 8539 | * Disable transmit for this module |
| 8540 | */ |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 8541 | phy->media_type = ETH_PHY_NOT_PRESENT; |
Yaniv Rosner | de6f337 | 2011-08-02 22:59:25 +0000 | [diff] [blame] | 8542 | if (((val & PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK) == |
| 8543 | PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_DISABLE_TX_LASER) || |
| 8544 | CHIP_IS_E3(bp)) |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8545 | bnx2x_sfp_set_transmitter(params, phy, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8546 | } |
| 8547 | } |
| 8548 | |
| 8549 | /******************************************************************/ |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 8550 | /* Used by 8706 and 8727 */ |
| 8551 | /******************************************************************/ |
| 8552 | static void bnx2x_sfp_mask_fault(struct bnx2x *bp, |
| 8553 | struct bnx2x_phy *phy, |
| 8554 | u16 alarm_status_offset, |
| 8555 | u16 alarm_ctrl_offset) |
| 8556 | { |
| 8557 | u16 alarm_status, val; |
| 8558 | bnx2x_cl45_read(bp, phy, |
| 8559 | MDIO_PMA_DEVAD, alarm_status_offset, |
| 8560 | &alarm_status); |
| 8561 | bnx2x_cl45_read(bp, phy, |
| 8562 | MDIO_PMA_DEVAD, alarm_status_offset, |
| 8563 | &alarm_status); |
| 8564 | /* Mask or enable the fault event. */ |
| 8565 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, alarm_ctrl_offset, &val); |
| 8566 | if (alarm_status & (1<<0)) |
| 8567 | val &= ~(1<<0); |
| 8568 | else |
| 8569 | val |= (1<<0); |
| 8570 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, alarm_ctrl_offset, val); |
| 8571 | } |
| 8572 | /******************************************************************/ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8573 | /* common BCM8706/BCM8726 PHY SECTION */ |
| 8574 | /******************************************************************/ |
| 8575 | static u8 bnx2x_8706_8726_read_status(struct bnx2x_phy *phy, |
| 8576 | struct link_params *params, |
| 8577 | struct link_vars *vars) |
| 8578 | { |
| 8579 | u8 link_up = 0; |
| 8580 | u16 val1, val2, rx_sd, pcs_status; |
| 8581 | struct bnx2x *bp = params->bp; |
| 8582 | DP(NETIF_MSG_LINK, "XGXS 8706/8726\n"); |
| 8583 | /* Clear RX Alarm*/ |
| 8584 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8585 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_RXSTAT, &val2); |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 8586 | |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8587 | bnx2x_sfp_mask_fault(bp, phy, MDIO_PMA_LASI_TXSTAT, |
| 8588 | MDIO_PMA_LASI_TXCTRL); |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 8589 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8590 | /* clear LASI indication*/ |
| 8591 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8592 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_STAT, &val1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8593 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8594 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_STAT, &val2); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8595 | DP(NETIF_MSG_LINK, "8706/8726 LASI status 0x%x--> 0x%x\n", val1, val2); |
| 8596 | |
| 8597 | bnx2x_cl45_read(bp, phy, |
| 8598 | MDIO_PMA_DEVAD, MDIO_PMA_REG_RX_SD, &rx_sd); |
| 8599 | bnx2x_cl45_read(bp, phy, |
| 8600 | MDIO_PCS_DEVAD, MDIO_PCS_REG_STATUS, &pcs_status); |
| 8601 | bnx2x_cl45_read(bp, phy, |
| 8602 | MDIO_AN_DEVAD, MDIO_AN_REG_LINK_STATUS, &val2); |
| 8603 | bnx2x_cl45_read(bp, phy, |
| 8604 | MDIO_AN_DEVAD, MDIO_AN_REG_LINK_STATUS, &val2); |
| 8605 | |
| 8606 | DP(NETIF_MSG_LINK, "8706/8726 rx_sd 0x%x pcs_status 0x%x 1Gbps" |
| 8607 | " link_status 0x%x\n", rx_sd, pcs_status, val2); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8608 | /* |
| 8609 | * link is up if both bit 0 of pmd_rx_sd and bit 0 of pcs_status |
| 8610 | * are set, or if the autoneg bit 1 is set |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8611 | */ |
| 8612 | link_up = ((rx_sd & pcs_status & 0x1) || (val2 & (1<<1))); |
| 8613 | if (link_up) { |
| 8614 | if (val2 & (1<<1)) |
| 8615 | vars->line_speed = SPEED_1000; |
| 8616 | else |
| 8617 | vars->line_speed = SPEED_10000; |
| 8618 | bnx2x_ext_phy_resolve_fc(phy, params, vars); |
Yaniv Rosner | 791f18c | 2011-01-18 04:33:42 +0000 | [diff] [blame] | 8619 | vars->duplex = DUPLEX_FULL; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8620 | } |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 8621 | |
| 8622 | /* Capture 10G link fault. Read twice to clear stale value. */ |
| 8623 | if (vars->line_speed == SPEED_10000) { |
| 8624 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8625 | MDIO_PMA_LASI_TXSTAT, &val1); |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 8626 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8627 | MDIO_PMA_LASI_TXSTAT, &val1); |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 8628 | if (val1 & (1<<0)) |
| 8629 | vars->fault_detected = 1; |
| 8630 | } |
| 8631 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8632 | return link_up; |
| 8633 | } |
| 8634 | |
| 8635 | /******************************************************************/ |
| 8636 | /* BCM8706 PHY SECTION */ |
| 8637 | /******************************************************************/ |
| 8638 | static u8 bnx2x_8706_config_init(struct bnx2x_phy *phy, |
| 8639 | struct link_params *params, |
| 8640 | struct link_vars *vars) |
| 8641 | { |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8642 | u32 tx_en_mode; |
| 8643 | u16 cnt, val, tmp1; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8644 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 8645 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8646 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8647 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, params->port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8648 | /* HW reset */ |
| 8649 | bnx2x_ext_phy_hw_reset(bp, params->port); |
| 8650 | 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] | 8651 | bnx2x_wait_reset_complete(bp, phy, params); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8652 | |
| 8653 | /* Wait until fw is loaded */ |
| 8654 | for (cnt = 0; cnt < 100; cnt++) { |
| 8655 | bnx2x_cl45_read(bp, phy, |
| 8656 | MDIO_PMA_DEVAD, MDIO_PMA_REG_ROM_VER1, &val); |
| 8657 | if (val) |
| 8658 | break; |
| 8659 | msleep(10); |
| 8660 | } |
| 8661 | DP(NETIF_MSG_LINK, "XGXS 8706 is initialized after %d ms\n", cnt); |
| 8662 | if ((params->feature_config_flags & |
| 8663 | FEATURE_CONFIG_OVERRIDE_PREEMPHASIS_ENABLED)) { |
| 8664 | u8 i; |
| 8665 | u16 reg; |
| 8666 | for (i = 0; i < 4; i++) { |
| 8667 | reg = MDIO_XS_8706_REG_BANK_RX0 + |
| 8668 | i*(MDIO_XS_8706_REG_BANK_RX1 - |
| 8669 | MDIO_XS_8706_REG_BANK_RX0); |
| 8670 | bnx2x_cl45_read(bp, phy, MDIO_XS_DEVAD, reg, &val); |
| 8671 | /* Clear first 3 bits of the control */ |
| 8672 | val &= ~0x7; |
| 8673 | /* Set control bits according to configuration */ |
| 8674 | val |= (phy->rx_preemphasis[i] & 0x7); |
| 8675 | DP(NETIF_MSG_LINK, "Setting RX Equalizer to BCM8706" |
| 8676 | " reg 0x%x <-- val 0x%x\n", reg, val); |
| 8677 | bnx2x_cl45_write(bp, phy, MDIO_XS_DEVAD, reg, val); |
| 8678 | } |
| 8679 | } |
| 8680 | /* Force speed */ |
| 8681 | if (phy->req_line_speed == SPEED_10000) { |
| 8682 | DP(NETIF_MSG_LINK, "XGXS 8706 force 10Gbps\n"); |
| 8683 | |
| 8684 | bnx2x_cl45_write(bp, phy, |
| 8685 | MDIO_PMA_DEVAD, |
| 8686 | MDIO_PMA_REG_DIGITAL_CTRL, 0x400); |
| 8687 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8688 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_TXCTRL, |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 8689 | 0); |
| 8690 | /* Arm LASI for link and Tx fault. */ |
| 8691 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8692 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_CTRL, 3); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8693 | } else { |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 8694 | /* Force 1Gbps using autoneg with 1G advertisement */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8695 | |
| 8696 | /* Allow CL37 through CL73 */ |
| 8697 | DP(NETIF_MSG_LINK, "XGXS 8706 AutoNeg\n"); |
| 8698 | bnx2x_cl45_write(bp, phy, |
| 8699 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_CL73, 0x040c); |
| 8700 | |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 8701 | /* Enable Full-Duplex advertisement on CL37 */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8702 | bnx2x_cl45_write(bp, phy, |
| 8703 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_FC_LP, 0x0020); |
| 8704 | /* Enable CL37 AN */ |
| 8705 | bnx2x_cl45_write(bp, phy, |
| 8706 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_AN, 0x1000); |
| 8707 | /* 1G support */ |
| 8708 | bnx2x_cl45_write(bp, phy, |
| 8709 | MDIO_AN_DEVAD, MDIO_AN_REG_ADV, (1<<5)); |
| 8710 | |
| 8711 | /* Enable clause 73 AN */ |
| 8712 | bnx2x_cl45_write(bp, phy, |
| 8713 | MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, 0x1200); |
| 8714 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8715 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_RXCTRL, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8716 | 0x0400); |
| 8717 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8718 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_CTRL, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8719 | 0x0004); |
| 8720 | } |
| 8721 | bnx2x_save_bcm_spirom_ver(bp, phy, params->port); |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8722 | |
| 8723 | /* |
| 8724 | * If TX Laser is controlled by GPIO_0, do not let PHY go into low |
| 8725 | * power mode, if TX Laser is disabled |
| 8726 | */ |
| 8727 | |
| 8728 | tx_en_mode = REG_RD(bp, params->shmem_base + |
| 8729 | offsetof(struct shmem_region, |
| 8730 | dev_info.port_hw_config[params->port].sfp_ctrl)) |
| 8731 | & PORT_HW_CFG_TX_LASER_MASK; |
| 8732 | |
| 8733 | if (tx_en_mode == PORT_HW_CFG_TX_LASER_GPIO0) { |
| 8734 | DP(NETIF_MSG_LINK, "Enabling TXONOFF_PWRDN_DIS\n"); |
| 8735 | bnx2x_cl45_read(bp, phy, |
| 8736 | MDIO_PMA_DEVAD, MDIO_PMA_REG_DIGITAL_CTRL, &tmp1); |
| 8737 | tmp1 |= 0x1; |
| 8738 | bnx2x_cl45_write(bp, phy, |
| 8739 | MDIO_PMA_DEVAD, MDIO_PMA_REG_DIGITAL_CTRL, tmp1); |
| 8740 | } |
| 8741 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8742 | return 0; |
| 8743 | } |
| 8744 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 8745 | static int bnx2x_8706_read_status(struct bnx2x_phy *phy, |
| 8746 | struct link_params *params, |
| 8747 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8748 | { |
| 8749 | return bnx2x_8706_8726_read_status(phy, params, vars); |
| 8750 | } |
| 8751 | |
| 8752 | /******************************************************************/ |
| 8753 | /* BCM8726 PHY SECTION */ |
| 8754 | /******************************************************************/ |
| 8755 | static void bnx2x_8726_config_loopback(struct bnx2x_phy *phy, |
| 8756 | struct link_params *params) |
| 8757 | { |
| 8758 | struct bnx2x *bp = params->bp; |
| 8759 | DP(NETIF_MSG_LINK, "PMA/PMD ext_phy_loopback: 8726\n"); |
| 8760 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 0x0001); |
| 8761 | } |
| 8762 | |
| 8763 | static void bnx2x_8726_external_rom_boot(struct bnx2x_phy *phy, |
| 8764 | struct link_params *params) |
| 8765 | { |
| 8766 | struct bnx2x *bp = params->bp; |
| 8767 | /* Need to wait 100ms after reset */ |
| 8768 | msleep(100); |
| 8769 | |
| 8770 | /* Micro controller re-boot */ |
| 8771 | bnx2x_cl45_write(bp, phy, |
| 8772 | MDIO_PMA_DEVAD, MDIO_PMA_REG_GEN_CTRL, 0x018B); |
| 8773 | |
| 8774 | /* Set soft reset */ |
| 8775 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8776 | MDIO_PMA_DEVAD, |
| 8777 | MDIO_PMA_REG_GEN_CTRL, |
| 8778 | MDIO_PMA_REG_GEN_CTRL_ROM_MICRO_RESET); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8779 | |
| 8780 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8781 | MDIO_PMA_DEVAD, |
| 8782 | MDIO_PMA_REG_MISC_CTRL1, 0x0001); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8783 | |
| 8784 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8785 | MDIO_PMA_DEVAD, |
| 8786 | MDIO_PMA_REG_GEN_CTRL, |
| 8787 | MDIO_PMA_REG_GEN_CTRL_ROM_RESET_INTERNAL_MP); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8788 | |
| 8789 | /* wait for 150ms for microcode load */ |
| 8790 | msleep(150); |
| 8791 | |
| 8792 | /* Disable serial boot control, tristates pins SS_N, SCK, MOSI, MISO */ |
| 8793 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8794 | MDIO_PMA_DEVAD, |
| 8795 | MDIO_PMA_REG_MISC_CTRL1, 0x0000); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8796 | |
| 8797 | msleep(200); |
| 8798 | bnx2x_save_bcm_spirom_ver(bp, phy, params->port); |
| 8799 | } |
| 8800 | |
| 8801 | static u8 bnx2x_8726_read_status(struct bnx2x_phy *phy, |
| 8802 | struct link_params *params, |
| 8803 | struct link_vars *vars) |
| 8804 | { |
| 8805 | struct bnx2x *bp = params->bp; |
| 8806 | u16 val1; |
| 8807 | u8 link_up = bnx2x_8706_8726_read_status(phy, params, vars); |
| 8808 | if (link_up) { |
| 8809 | bnx2x_cl45_read(bp, phy, |
| 8810 | MDIO_PMA_DEVAD, MDIO_PMA_REG_PHY_IDENTIFIER, |
| 8811 | &val1); |
| 8812 | if (val1 & (1<<15)) { |
| 8813 | DP(NETIF_MSG_LINK, "Tx is disabled\n"); |
| 8814 | link_up = 0; |
| 8815 | vars->line_speed = 0; |
| 8816 | } |
| 8817 | } |
| 8818 | return link_up; |
| 8819 | } |
| 8820 | |
| 8821 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 8822 | static int bnx2x_8726_config_init(struct bnx2x_phy *phy, |
| 8823 | struct link_params *params, |
| 8824 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8825 | { |
| 8826 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8827 | DP(NETIF_MSG_LINK, "Initializing BCM8726\n"); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8828 | |
| 8829 | 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] | 8830 | bnx2x_wait_reset_complete(bp, phy, params); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8831 | |
| 8832 | bnx2x_8726_external_rom_boot(phy, params); |
| 8833 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8834 | /* |
| 8835 | * Need to call module detected on initialization since the module |
| 8836 | * detection triggered by actual module insertion might occur before |
| 8837 | * driver is loaded, and when driver is loaded, it reset all |
| 8838 | * registers, including the transmitter |
| 8839 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8840 | bnx2x_sfp_module_detection(phy, params); |
| 8841 | |
| 8842 | if (phy->req_line_speed == SPEED_1000) { |
| 8843 | DP(NETIF_MSG_LINK, "Setting 1G force\n"); |
| 8844 | bnx2x_cl45_write(bp, phy, |
| 8845 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 0x40); |
| 8846 | bnx2x_cl45_write(bp, phy, |
| 8847 | MDIO_PMA_DEVAD, MDIO_PMA_REG_10G_CTRL2, 0xD); |
| 8848 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8849 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_CTRL, 0x5); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8850 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8851 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_RXCTRL, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8852 | 0x400); |
| 8853 | } else if ((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 8854 | (phy->speed_cap_mask & |
| 8855 | PORT_HW_CFG_SPEED_CAPABILITY_D0_1G) && |
| 8856 | ((phy->speed_cap_mask & |
| 8857 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G) != |
| 8858 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G)) { |
| 8859 | DP(NETIF_MSG_LINK, "Setting 1G clause37\n"); |
| 8860 | /* Set Flow control */ |
| 8861 | bnx2x_ext_phy_set_pause(params, phy, vars); |
| 8862 | bnx2x_cl45_write(bp, phy, |
| 8863 | MDIO_AN_DEVAD, MDIO_AN_REG_ADV, 0x20); |
| 8864 | bnx2x_cl45_write(bp, phy, |
| 8865 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_CL73, 0x040c); |
| 8866 | bnx2x_cl45_write(bp, phy, |
| 8867 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_FC_LD, 0x0020); |
| 8868 | bnx2x_cl45_write(bp, phy, |
| 8869 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_AN, 0x1000); |
| 8870 | bnx2x_cl45_write(bp, phy, |
| 8871 | MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, 0x1200); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8872 | /* |
| 8873 | * Enable RX-ALARM control to receive interrupt for 1G speed |
| 8874 | * change |
| 8875 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8876 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8877 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_CTRL, 0x4); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8878 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8879 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_RXCTRL, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8880 | 0x400); |
| 8881 | |
| 8882 | } else { /* Default 10G. Set only LASI control */ |
| 8883 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 8884 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_CTRL, 1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8885 | } |
| 8886 | |
| 8887 | /* Set TX PreEmphasis if needed */ |
| 8888 | if ((params->feature_config_flags & |
| 8889 | FEATURE_CONFIG_OVERRIDE_PREEMPHASIS_ENABLED)) { |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 8890 | DP(NETIF_MSG_LINK, |
| 8891 | "Setting TX_CTRL1 0x%x, TX_CTRL2 0x%x\n", |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8892 | phy->tx_preemphasis[0], |
| 8893 | phy->tx_preemphasis[1]); |
| 8894 | bnx2x_cl45_write(bp, phy, |
| 8895 | MDIO_PMA_DEVAD, |
| 8896 | MDIO_PMA_REG_8726_TX_CTRL1, |
| 8897 | phy->tx_preemphasis[0]); |
| 8898 | |
| 8899 | bnx2x_cl45_write(bp, phy, |
| 8900 | MDIO_PMA_DEVAD, |
| 8901 | MDIO_PMA_REG_8726_TX_CTRL2, |
| 8902 | phy->tx_preemphasis[1]); |
| 8903 | } |
| 8904 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8905 | return 0; |
| 8906 | |
| 8907 | } |
| 8908 | |
| 8909 | static void bnx2x_8726_link_reset(struct bnx2x_phy *phy, |
| 8910 | struct link_params *params) |
| 8911 | { |
| 8912 | struct bnx2x *bp = params->bp; |
| 8913 | DP(NETIF_MSG_LINK, "bnx2x_8726_link_reset port %d\n", params->port); |
| 8914 | /* Set serial boot control for external load */ |
| 8915 | bnx2x_cl45_write(bp, phy, |
| 8916 | MDIO_PMA_DEVAD, |
| 8917 | MDIO_PMA_REG_GEN_CTRL, 0x0001); |
| 8918 | } |
| 8919 | |
| 8920 | /******************************************************************/ |
| 8921 | /* BCM8727 PHY SECTION */ |
| 8922 | /******************************************************************/ |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 8923 | |
| 8924 | static void bnx2x_8727_set_link_led(struct bnx2x_phy *phy, |
| 8925 | struct link_params *params, u8 mode) |
| 8926 | { |
| 8927 | struct bnx2x *bp = params->bp; |
| 8928 | u16 led_mode_bitmask = 0; |
| 8929 | u16 gpio_pins_bitmask = 0; |
| 8930 | u16 val; |
| 8931 | /* Only NOC flavor requires to set the LED specifically */ |
| 8932 | if (!(phy->flags & FLAGS_NOC)) |
| 8933 | return; |
| 8934 | switch (mode) { |
| 8935 | case LED_MODE_FRONT_PANEL_OFF: |
| 8936 | case LED_MODE_OFF: |
| 8937 | led_mode_bitmask = 0; |
| 8938 | gpio_pins_bitmask = 0x03; |
| 8939 | break; |
| 8940 | case LED_MODE_ON: |
| 8941 | led_mode_bitmask = 0; |
| 8942 | gpio_pins_bitmask = 0x02; |
| 8943 | break; |
| 8944 | case LED_MODE_OPER: |
| 8945 | led_mode_bitmask = 0x60; |
| 8946 | gpio_pins_bitmask = 0x11; |
| 8947 | break; |
| 8948 | } |
| 8949 | bnx2x_cl45_read(bp, phy, |
| 8950 | MDIO_PMA_DEVAD, |
| 8951 | MDIO_PMA_REG_8727_PCS_OPT_CTRL, |
| 8952 | &val); |
| 8953 | val &= 0xff8f; |
| 8954 | val |= led_mode_bitmask; |
| 8955 | bnx2x_cl45_write(bp, phy, |
| 8956 | MDIO_PMA_DEVAD, |
| 8957 | MDIO_PMA_REG_8727_PCS_OPT_CTRL, |
| 8958 | val); |
| 8959 | bnx2x_cl45_read(bp, phy, |
| 8960 | MDIO_PMA_DEVAD, |
| 8961 | MDIO_PMA_REG_8727_GPIO_CTRL, |
| 8962 | &val); |
| 8963 | val &= 0xffe0; |
| 8964 | val |= gpio_pins_bitmask; |
| 8965 | bnx2x_cl45_write(bp, phy, |
| 8966 | MDIO_PMA_DEVAD, |
| 8967 | MDIO_PMA_REG_8727_GPIO_CTRL, |
| 8968 | val); |
| 8969 | } |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 8970 | static void bnx2x_8727_hw_reset(struct bnx2x_phy *phy, |
| 8971 | struct link_params *params) { |
| 8972 | u32 swap_val, swap_override; |
| 8973 | u8 port; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8974 | /* |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 8975 | * The PHY reset is controlled by GPIO 1. Fake the port number |
| 8976 | * to cancel the swap done in set_gpio() |
| 8977 | */ |
| 8978 | struct bnx2x *bp = params->bp; |
| 8979 | swap_val = REG_RD(bp, NIG_REG_PORT_SWAP); |
| 8980 | swap_override = REG_RD(bp, NIG_REG_STRAP_OVERRIDE); |
| 8981 | port = (swap_val && swap_override) ^ 1; |
| 8982 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8983 | MISC_REGISTERS_GPIO_OUTPUT_LOW, port); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 8984 | } |
| 8985 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 8986 | static int bnx2x_8727_config_init(struct bnx2x_phy *phy, |
| 8987 | struct link_params *params, |
| 8988 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8989 | { |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8990 | u32 tx_en_mode; |
| 8991 | u16 tmp1, val, mod_abs, tmp2; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8992 | u16 rx_alarm_ctrl_val; |
| 8993 | u16 lasi_ctrl_val; |
| 8994 | struct bnx2x *bp = params->bp; |
| 8995 | /* Enable PMD link, MOD_ABS_FLT, and 1G link alarm */ |
| 8996 | |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 8997 | bnx2x_wait_reset_complete(bp, phy, params); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8998 | rx_alarm_ctrl_val = (1<<2) | (1<<5) ; |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 8999 | /* Should be 0x6 to enable XS on Tx side. */ |
| 9000 | lasi_ctrl_val = 0x0006; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9001 | |
| 9002 | DP(NETIF_MSG_LINK, "Initializing BCM8727\n"); |
| 9003 | /* enable LASI */ |
| 9004 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 9005 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_RXCTRL, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9006 | rx_alarm_ctrl_val); |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 9007 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 9008 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_TXCTRL, |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 9009 | 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9010 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 9011 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_CTRL, lasi_ctrl_val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9012 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 9013 | /* |
| 9014 | * Initially configure MOD_ABS to interrupt when module is |
| 9015 | * presence( bit 8) |
| 9016 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9017 | bnx2x_cl45_read(bp, phy, |
| 9018 | MDIO_PMA_DEVAD, MDIO_PMA_REG_PHY_IDENTIFIER, &mod_abs); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 9019 | /* |
| 9020 | * Set EDC off by setting OPTXLOS signal input to low (bit 9). |
| 9021 | * When the EDC is off it locks onto a reference clock and avoids |
| 9022 | * becoming 'lost' |
| 9023 | */ |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 9024 | mod_abs &= ~(1<<8); |
| 9025 | if (!(phy->flags & FLAGS_NOC)) |
| 9026 | mod_abs &= ~(1<<9); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9027 | bnx2x_cl45_write(bp, phy, |
| 9028 | MDIO_PMA_DEVAD, MDIO_PMA_REG_PHY_IDENTIFIER, mod_abs); |
| 9029 | |
| 9030 | |
Yaniv Rosner | 85242ee | 2011-07-05 01:06:53 +0000 | [diff] [blame] | 9031 | /* Enable/Disable PHY transmitter output */ |
| 9032 | bnx2x_set_disable_pmd_transmit(params, phy, 0); |
| 9033 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9034 | /* Make MOD_ABS give interrupt on change */ |
| 9035 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_PCS_OPT_CTRL, |
| 9036 | &val); |
| 9037 | val |= (1<<12); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 9038 | if (phy->flags & FLAGS_NOC) |
| 9039 | val |= (3<<5); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9040 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 9041 | /* |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 9042 | * Set 8727 GPIOs to input to allow reading from the 8727 GPIO0 |
| 9043 | * status which reflect SFP+ module over-current |
| 9044 | */ |
| 9045 | if (!(phy->flags & FLAGS_NOC)) |
| 9046 | val &= 0xff8f; /* Reset bits 4-6 */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9047 | bnx2x_cl45_write(bp, phy, |
| 9048 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_PCS_OPT_CTRL, val); |
| 9049 | |
| 9050 | bnx2x_8727_power_module(bp, phy, 1); |
| 9051 | |
| 9052 | bnx2x_cl45_read(bp, phy, |
| 9053 | MDIO_PMA_DEVAD, MDIO_PMA_REG_M8051_MSGOUT_REG, &tmp1); |
| 9054 | |
| 9055 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 9056 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_RXSTAT, &tmp1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9057 | |
| 9058 | /* Set option 1G speed */ |
| 9059 | if (phy->req_line_speed == SPEED_1000) { |
| 9060 | DP(NETIF_MSG_LINK, "Setting 1G force\n"); |
| 9061 | bnx2x_cl45_write(bp, phy, |
| 9062 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 0x40); |
| 9063 | bnx2x_cl45_write(bp, phy, |
| 9064 | MDIO_PMA_DEVAD, MDIO_PMA_REG_10G_CTRL2, 0xD); |
| 9065 | bnx2x_cl45_read(bp, phy, |
| 9066 | MDIO_PMA_DEVAD, MDIO_PMA_REG_10G_CTRL2, &tmp1); |
| 9067 | DP(NETIF_MSG_LINK, "1.7 = 0x%x\n", tmp1); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 9068 | /* |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 9069 | * Power down the XAUI until link is up in case of dual-media |
| 9070 | * and 1G |
| 9071 | */ |
| 9072 | if (DUAL_MEDIA(params)) { |
| 9073 | bnx2x_cl45_read(bp, phy, |
| 9074 | MDIO_PMA_DEVAD, |
| 9075 | MDIO_PMA_REG_8727_PCS_GP, &val); |
| 9076 | val |= (3<<10); |
| 9077 | bnx2x_cl45_write(bp, phy, |
| 9078 | MDIO_PMA_DEVAD, |
| 9079 | MDIO_PMA_REG_8727_PCS_GP, val); |
| 9080 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9081 | } else if ((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 9082 | ((phy->speed_cap_mask & |
| 9083 | PORT_HW_CFG_SPEED_CAPABILITY_D0_1G)) && |
| 9084 | ((phy->speed_cap_mask & |
| 9085 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G) != |
| 9086 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G)) { |
| 9087 | |
| 9088 | DP(NETIF_MSG_LINK, "Setting 1G clause37\n"); |
| 9089 | bnx2x_cl45_write(bp, phy, |
| 9090 | MDIO_AN_DEVAD, MDIO_AN_REG_8727_MISC_CTRL, 0); |
| 9091 | bnx2x_cl45_write(bp, phy, |
| 9092 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_AN, 0x1300); |
| 9093 | } else { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 9094 | /* |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9095 | * Since the 8727 has only single reset pin, need to set the 10G |
| 9096 | * registers although it is default |
| 9097 | */ |
| 9098 | bnx2x_cl45_write(bp, phy, |
| 9099 | MDIO_AN_DEVAD, MDIO_AN_REG_8727_MISC_CTRL, |
| 9100 | 0x0020); |
| 9101 | bnx2x_cl45_write(bp, phy, |
| 9102 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_AN, 0x0100); |
| 9103 | bnx2x_cl45_write(bp, phy, |
| 9104 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 0x2040); |
| 9105 | bnx2x_cl45_write(bp, phy, |
| 9106 | MDIO_PMA_DEVAD, MDIO_PMA_REG_10G_CTRL2, |
| 9107 | 0x0008); |
| 9108 | } |
| 9109 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 9110 | /* |
| 9111 | * Set 2-wire transfer rate of SFP+ module EEPROM |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9112 | * to 100Khz since some DACs(direct attached cables) do |
| 9113 | * not work at 400Khz. |
| 9114 | */ |
| 9115 | bnx2x_cl45_write(bp, phy, |
| 9116 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_TWO_WIRE_SLAVE_ADDR, |
| 9117 | 0xa001); |
| 9118 | |
| 9119 | /* Set TX PreEmphasis if needed */ |
| 9120 | if ((params->feature_config_flags & |
| 9121 | FEATURE_CONFIG_OVERRIDE_PREEMPHASIS_ENABLED)) { |
| 9122 | DP(NETIF_MSG_LINK, "Setting TX_CTRL1 0x%x, TX_CTRL2 0x%x\n", |
| 9123 | phy->tx_preemphasis[0], |
| 9124 | phy->tx_preemphasis[1]); |
| 9125 | bnx2x_cl45_write(bp, phy, |
| 9126 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_TX_CTRL1, |
| 9127 | phy->tx_preemphasis[0]); |
| 9128 | |
| 9129 | bnx2x_cl45_write(bp, phy, |
| 9130 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_TX_CTRL2, |
| 9131 | phy->tx_preemphasis[1]); |
| 9132 | } |
| 9133 | |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 9134 | /* |
| 9135 | * If TX Laser is controlled by GPIO_0, do not let PHY go into low |
| 9136 | * power mode, if TX Laser is disabled |
| 9137 | */ |
| 9138 | tx_en_mode = REG_RD(bp, params->shmem_base + |
| 9139 | offsetof(struct shmem_region, |
| 9140 | dev_info.port_hw_config[params->port].sfp_ctrl)) |
| 9141 | & PORT_HW_CFG_TX_LASER_MASK; |
| 9142 | |
| 9143 | if (tx_en_mode == PORT_HW_CFG_TX_LASER_GPIO0) { |
| 9144 | |
| 9145 | DP(NETIF_MSG_LINK, "Enabling TXONOFF_PWRDN_DIS\n"); |
| 9146 | bnx2x_cl45_read(bp, phy, |
| 9147 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_OPT_CFG_REG, &tmp2); |
| 9148 | tmp2 |= 0x1000; |
| 9149 | tmp2 &= 0xFFEF; |
| 9150 | bnx2x_cl45_write(bp, phy, |
| 9151 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_OPT_CFG_REG, tmp2); |
| 9152 | } |
| 9153 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9154 | return 0; |
| 9155 | } |
| 9156 | |
| 9157 | static void bnx2x_8727_handle_mod_abs(struct bnx2x_phy *phy, |
| 9158 | struct link_params *params) |
| 9159 | { |
| 9160 | struct bnx2x *bp = params->bp; |
| 9161 | u16 mod_abs, rx_alarm_status; |
| 9162 | u32 val = REG_RD(bp, params->shmem_base + |
| 9163 | offsetof(struct shmem_region, dev_info. |
| 9164 | port_feature_config[params->port]. |
| 9165 | config)); |
| 9166 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 9167 | MDIO_PMA_DEVAD, |
| 9168 | MDIO_PMA_REG_PHY_IDENTIFIER, &mod_abs); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9169 | if (mod_abs & (1<<8)) { |
| 9170 | |
| 9171 | /* Module is absent */ |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 9172 | DP(NETIF_MSG_LINK, |
| 9173 | "MOD_ABS indication show module is absent\n"); |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 9174 | phy->media_type = ETH_PHY_NOT_PRESENT; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 9175 | /* |
| 9176 | * 1. Set mod_abs to detect next module |
| 9177 | * presence event |
| 9178 | * 2. Set EDC off by setting OPTXLOS signal input to low |
| 9179 | * (bit 9). |
| 9180 | * When the EDC is off it locks onto a reference clock and |
| 9181 | * avoids becoming 'lost'. |
| 9182 | */ |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 9183 | mod_abs &= ~(1<<8); |
| 9184 | if (!(phy->flags & FLAGS_NOC)) |
| 9185 | mod_abs &= ~(1<<9); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9186 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 9187 | MDIO_PMA_DEVAD, |
| 9188 | MDIO_PMA_REG_PHY_IDENTIFIER, mod_abs); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9189 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 9190 | /* |
| 9191 | * Clear RX alarm since it stays up as long as |
| 9192 | * the mod_abs wasn't changed |
| 9193 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9194 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 9195 | MDIO_PMA_DEVAD, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 9196 | MDIO_PMA_LASI_RXSTAT, &rx_alarm_status); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9197 | |
| 9198 | } else { |
| 9199 | /* Module is present */ |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 9200 | DP(NETIF_MSG_LINK, |
| 9201 | "MOD_ABS indication show module is present\n"); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 9202 | /* |
| 9203 | * First disable transmitter, and if the module is ok, the |
| 9204 | * module_detection will enable it |
| 9205 | * 1. Set mod_abs to detect next module absent event ( bit 8) |
| 9206 | * 2. Restore the default polarity of the OPRXLOS signal and |
| 9207 | * this signal will then correctly indicate the presence or |
| 9208 | * absence of the Rx signal. (bit 9) |
| 9209 | */ |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 9210 | mod_abs |= (1<<8); |
| 9211 | if (!(phy->flags & FLAGS_NOC)) |
| 9212 | mod_abs |= (1<<9); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9213 | bnx2x_cl45_write(bp, phy, |
| 9214 | MDIO_PMA_DEVAD, |
| 9215 | MDIO_PMA_REG_PHY_IDENTIFIER, mod_abs); |
| 9216 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 9217 | /* |
| 9218 | * Clear RX alarm since it stays up as long as the mod_abs |
| 9219 | * wasn't changed. This is need to be done before calling the |
| 9220 | * module detection, otherwise it will clear* the link update |
| 9221 | * alarm |
| 9222 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9223 | bnx2x_cl45_read(bp, phy, |
| 9224 | MDIO_PMA_DEVAD, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 9225 | MDIO_PMA_LASI_RXSTAT, &rx_alarm_status); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9226 | |
| 9227 | |
| 9228 | if ((val & PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK) == |
| 9229 | PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_DISABLE_TX_LASER) |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 9230 | bnx2x_sfp_set_transmitter(params, phy, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9231 | |
| 9232 | if (bnx2x_wait_for_sfp_module_initialized(phy, params) == 0) |
| 9233 | bnx2x_sfp_module_detection(phy, params); |
| 9234 | else |
| 9235 | DP(NETIF_MSG_LINK, "SFP+ module is not initialized\n"); |
| 9236 | } |
| 9237 | |
| 9238 | DP(NETIF_MSG_LINK, "8727 RX_ALARM_STATUS 0x%x\n", |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 9239 | rx_alarm_status); |
| 9240 | /* 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] | 9241 | } |
| 9242 | |
| 9243 | static u8 bnx2x_8727_read_status(struct bnx2x_phy *phy, |
| 9244 | struct link_params *params, |
| 9245 | struct link_vars *vars) |
| 9246 | |
| 9247 | { |
| 9248 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 27d0243 | 2011-05-31 21:27:48 +0000 | [diff] [blame] | 9249 | u8 link_up = 0, oc_port = params->port; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9250 | u16 link_status = 0; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 9251 | u16 rx_alarm_status, lasi_ctrl, val1; |
| 9252 | |
| 9253 | /* If PHY is not initialized, do not check link status */ |
| 9254 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 9255 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_CTRL, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 9256 | &lasi_ctrl); |
| 9257 | if (!lasi_ctrl) |
| 9258 | return 0; |
| 9259 | |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 9260 | /* Check the LASI on Rx */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9261 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 9262 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_RXSTAT, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9263 | &rx_alarm_status); |
| 9264 | vars->line_speed = 0; |
| 9265 | DP(NETIF_MSG_LINK, "8727 RX_ALARM_STATUS 0x%x\n", rx_alarm_status); |
| 9266 | |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 9267 | bnx2x_sfp_mask_fault(bp, phy, MDIO_PMA_LASI_TXSTAT, |
| 9268 | MDIO_PMA_LASI_TXCTRL); |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 9269 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9270 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 9271 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_STAT, &val1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9272 | |
| 9273 | DP(NETIF_MSG_LINK, "8727 LASI status 0x%x\n", val1); |
| 9274 | |
| 9275 | /* Clear MSG-OUT */ |
| 9276 | bnx2x_cl45_read(bp, phy, |
| 9277 | MDIO_PMA_DEVAD, MDIO_PMA_REG_M8051_MSGOUT_REG, &val1); |
| 9278 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 9279 | /* |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9280 | * If a module is present and there is need to check |
| 9281 | * for over current |
| 9282 | */ |
| 9283 | if (!(phy->flags & FLAGS_NOC) && !(rx_alarm_status & (1<<5))) { |
| 9284 | /* Check over-current using 8727 GPIO0 input*/ |
| 9285 | bnx2x_cl45_read(bp, phy, |
| 9286 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_GPIO_CTRL, |
| 9287 | &val1); |
| 9288 | |
| 9289 | if ((val1 & (1<<8)) == 0) { |
Yaniv Rosner | 27d0243 | 2011-05-31 21:27:48 +0000 | [diff] [blame] | 9290 | if (!CHIP_IS_E1x(bp)) |
| 9291 | oc_port = BP_PATH(bp) + (params->port << 1); |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 9292 | DP(NETIF_MSG_LINK, |
| 9293 | "8727 Power fault has been detected on port %d\n", |
| 9294 | oc_port); |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 9295 | netdev_err(bp->dev, "Error: Power fault on Port %d has " |
| 9296 | "been detected and the power to " |
| 9297 | "that SFP+ module has been removed " |
| 9298 | "to prevent failure of the card. " |
| 9299 | "Please remove the SFP+ module and " |
| 9300 | "restart the system to clear this " |
| 9301 | "error.\n", |
Yaniv Rosner | 27d0243 | 2011-05-31 21:27:48 +0000 | [diff] [blame] | 9302 | oc_port); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 9303 | /* Disable all RX_ALARMs except for mod_abs */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9304 | bnx2x_cl45_write(bp, phy, |
| 9305 | MDIO_PMA_DEVAD, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 9306 | MDIO_PMA_LASI_RXCTRL, (1<<5)); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9307 | |
| 9308 | bnx2x_cl45_read(bp, phy, |
| 9309 | MDIO_PMA_DEVAD, |
| 9310 | MDIO_PMA_REG_PHY_IDENTIFIER, &val1); |
| 9311 | /* Wait for module_absent_event */ |
| 9312 | val1 |= (1<<8); |
| 9313 | bnx2x_cl45_write(bp, phy, |
| 9314 | MDIO_PMA_DEVAD, |
| 9315 | MDIO_PMA_REG_PHY_IDENTIFIER, val1); |
| 9316 | /* Clear RX alarm */ |
| 9317 | bnx2x_cl45_read(bp, phy, |
| 9318 | MDIO_PMA_DEVAD, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 9319 | MDIO_PMA_LASI_RXSTAT, &rx_alarm_status); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9320 | return 0; |
| 9321 | } |
| 9322 | } /* Over current check */ |
| 9323 | |
| 9324 | /* When module absent bit is set, check module */ |
| 9325 | if (rx_alarm_status & (1<<5)) { |
| 9326 | bnx2x_8727_handle_mod_abs(phy, params); |
| 9327 | /* Enable all mod_abs and link detection bits */ |
| 9328 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 9329 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_RXCTRL, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9330 | ((1<<5) | (1<<2))); |
| 9331 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 9332 | DP(NETIF_MSG_LINK, "Enabling 8727 TX laser if SFP is approved\n"); |
| 9333 | bnx2x_8727_specific_func(phy, params, ENABLE_TX); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9334 | /* If transmitter is disabled, ignore false link up indication */ |
| 9335 | bnx2x_cl45_read(bp, phy, |
| 9336 | MDIO_PMA_DEVAD, MDIO_PMA_REG_PHY_IDENTIFIER, &val1); |
| 9337 | if (val1 & (1<<15)) { |
| 9338 | DP(NETIF_MSG_LINK, "Tx is disabled\n"); |
| 9339 | return 0; |
| 9340 | } |
| 9341 | |
| 9342 | bnx2x_cl45_read(bp, phy, |
| 9343 | MDIO_PMA_DEVAD, |
| 9344 | MDIO_PMA_REG_8073_SPEED_LINK_STATUS, &link_status); |
| 9345 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 9346 | /* |
| 9347 | * Bits 0..2 --> speed detected, |
| 9348 | * Bits 13..15--> link is down |
| 9349 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9350 | if ((link_status & (1<<2)) && (!(link_status & (1<<15)))) { |
| 9351 | link_up = 1; |
| 9352 | vars->line_speed = SPEED_10000; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 9353 | DP(NETIF_MSG_LINK, "port %x: External link up in 10G\n", |
| 9354 | params->port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9355 | } else if ((link_status & (1<<0)) && (!(link_status & (1<<13)))) { |
| 9356 | link_up = 1; |
| 9357 | vars->line_speed = SPEED_1000; |
| 9358 | DP(NETIF_MSG_LINK, "port %x: External link up in 1G\n", |
| 9359 | params->port); |
| 9360 | } else { |
| 9361 | link_up = 0; |
| 9362 | DP(NETIF_MSG_LINK, "port %x: External link is down\n", |
| 9363 | params->port); |
| 9364 | } |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 9365 | |
| 9366 | /* Capture 10G link fault. */ |
| 9367 | if (vars->line_speed == SPEED_10000) { |
| 9368 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 9369 | MDIO_PMA_LASI_TXSTAT, &val1); |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 9370 | |
| 9371 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 9372 | MDIO_PMA_LASI_TXSTAT, &val1); |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 9373 | |
| 9374 | if (val1 & (1<<0)) { |
| 9375 | vars->fault_detected = 1; |
| 9376 | } |
| 9377 | } |
| 9378 | |
Yaniv Rosner | 791f18c | 2011-01-18 04:33:42 +0000 | [diff] [blame] | 9379 | if (link_up) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9380 | bnx2x_ext_phy_resolve_fc(phy, params, vars); |
Yaniv Rosner | 791f18c | 2011-01-18 04:33:42 +0000 | [diff] [blame] | 9381 | vars->duplex = DUPLEX_FULL; |
| 9382 | DP(NETIF_MSG_LINK, "duplex = 0x%x\n", vars->duplex); |
| 9383 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 9384 | |
| 9385 | if ((DUAL_MEDIA(params)) && |
| 9386 | (phy->req_line_speed == SPEED_1000)) { |
| 9387 | bnx2x_cl45_read(bp, phy, |
| 9388 | MDIO_PMA_DEVAD, |
| 9389 | MDIO_PMA_REG_8727_PCS_GP, &val1); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 9390 | /* |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 9391 | * In case of dual-media board and 1G, power up the XAUI side, |
| 9392 | * otherwise power it down. For 10G it is done automatically |
| 9393 | */ |
| 9394 | if (link_up) |
| 9395 | val1 &= ~(3<<10); |
| 9396 | else |
| 9397 | val1 |= (3<<10); |
| 9398 | bnx2x_cl45_write(bp, phy, |
| 9399 | MDIO_PMA_DEVAD, |
| 9400 | MDIO_PMA_REG_8727_PCS_GP, val1); |
| 9401 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9402 | return link_up; |
| 9403 | } |
| 9404 | |
| 9405 | static void bnx2x_8727_link_reset(struct bnx2x_phy *phy, |
| 9406 | struct link_params *params) |
| 9407 | { |
| 9408 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 85242ee | 2011-07-05 01:06:53 +0000 | [diff] [blame] | 9409 | |
| 9410 | /* Enable/Disable PHY transmitter output */ |
| 9411 | bnx2x_set_disable_pmd_transmit(params, phy, 1); |
| 9412 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9413 | /* Disable Transmitter */ |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 9414 | bnx2x_sfp_set_transmitter(params, phy, 0); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 9415 | /* Clear LASI */ |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 9416 | 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] | 9417 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9418 | } |
| 9419 | |
| 9420 | /******************************************************************/ |
| 9421 | /* BCM8481/BCM84823/BCM84833 PHY SECTION */ |
| 9422 | /******************************************************************/ |
| 9423 | static void bnx2x_save_848xx_spirom_version(struct bnx2x_phy *phy, |
Yaniv Rosner | 11b2ec6 | 2012-01-17 02:33:25 +0000 | [diff] [blame] | 9424 | struct bnx2x *bp, |
| 9425 | u8 port) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9426 | { |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9427 | u16 val, fw_ver1, fw_ver2, cnt; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9428 | |
Yaniv Rosner | 11b2ec6 | 2012-01-17 02:33:25 +0000 | [diff] [blame] | 9429 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833) { |
| 9430 | bnx2x_cl45_read(bp, phy, MDIO_CTL_DEVAD, 0x400f, &fw_ver1); |
| 9431 | bnx2x_save_spirom_version(bp, port, |
| 9432 | ((fw_ver1 & 0xf000)>>5) | (fw_ver1 & 0x7f), |
| 9433 | phy->ver_addr); |
| 9434 | } else { |
| 9435 | /* For 32-bit registers in 848xx, access via MDIO2ARM i/f. */ |
| 9436 | /* (1) set reg 0xc200_0014(SPI_BRIDGE_CTRL_2) to 0x03000000 */ |
| 9437 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA819, 0x0014); |
| 9438 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA81A, 0xc200); |
| 9439 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA81B, 0x0000); |
| 9440 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA81C, 0x0300); |
| 9441 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA817, 0x0009); |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 9442 | |
Yaniv Rosner | 11b2ec6 | 2012-01-17 02:33:25 +0000 | [diff] [blame] | 9443 | for (cnt = 0; cnt < 100; cnt++) { |
| 9444 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, 0xA818, &val); |
| 9445 | if (val & 1) |
| 9446 | break; |
| 9447 | udelay(5); |
| 9448 | } |
| 9449 | if (cnt == 100) { |
| 9450 | DP(NETIF_MSG_LINK, "Unable to read 848xx " |
| 9451 | "phy fw version(1)\n"); |
| 9452 | bnx2x_save_spirom_version(bp, port, 0, |
| 9453 | phy->ver_addr); |
| 9454 | return; |
| 9455 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9456 | |
Yaniv Rosner | 11b2ec6 | 2012-01-17 02:33:25 +0000 | [diff] [blame] | 9457 | |
| 9458 | /* 2) read register 0xc200_0000 (SPI_FW_STATUS) */ |
| 9459 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA819, 0x0000); |
| 9460 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA81A, 0xc200); |
| 9461 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA817, 0x000A); |
| 9462 | for (cnt = 0; cnt < 100; cnt++) { |
| 9463 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, 0xA818, &val); |
| 9464 | if (val & 1) |
| 9465 | break; |
| 9466 | udelay(5); |
| 9467 | } |
| 9468 | if (cnt == 100) { |
| 9469 | DP(NETIF_MSG_LINK, "Unable to read 848xx phy fw " |
| 9470 | "version(2)\n"); |
| 9471 | bnx2x_save_spirom_version(bp, port, 0, |
| 9472 | phy->ver_addr); |
| 9473 | return; |
| 9474 | } |
| 9475 | |
| 9476 | /* lower 16 bits of the register SPI_FW_STATUS */ |
| 9477 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, 0xA81B, &fw_ver1); |
| 9478 | /* upper 16 bits of register SPI_FW_STATUS */ |
| 9479 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, 0xA81C, &fw_ver2); |
| 9480 | |
| 9481 | bnx2x_save_spirom_version(bp, port, (fw_ver2<<16) | fw_ver1, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9482 | phy->ver_addr); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9483 | } |
| 9484 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9485 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9486 | static void bnx2x_848xx_set_led(struct bnx2x *bp, |
| 9487 | struct bnx2x_phy *phy) |
| 9488 | { |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 9489 | u16 val, offset; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9490 | |
| 9491 | /* PHYC_CTL_LED_CTL */ |
| 9492 | bnx2x_cl45_read(bp, phy, |
| 9493 | MDIO_PMA_DEVAD, |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9494 | MDIO_PMA_REG_8481_LINK_SIGNAL, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9495 | val &= 0xFE00; |
| 9496 | val |= 0x0092; |
| 9497 | |
| 9498 | bnx2x_cl45_write(bp, phy, |
| 9499 | MDIO_PMA_DEVAD, |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9500 | MDIO_PMA_REG_8481_LINK_SIGNAL, val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9501 | |
| 9502 | bnx2x_cl45_write(bp, phy, |
| 9503 | MDIO_PMA_DEVAD, |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9504 | MDIO_PMA_REG_8481_LED1_MASK, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9505 | 0x80); |
| 9506 | |
| 9507 | bnx2x_cl45_write(bp, phy, |
| 9508 | MDIO_PMA_DEVAD, |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9509 | MDIO_PMA_REG_8481_LED2_MASK, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9510 | 0x18); |
| 9511 | |
Yaniv Rosner | f25b3c8 | 2011-01-18 04:33:47 +0000 | [diff] [blame] | 9512 | /* Select activity source by Tx and Rx, as suggested by PHY AE */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9513 | bnx2x_cl45_write(bp, phy, |
| 9514 | MDIO_PMA_DEVAD, |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9515 | MDIO_PMA_REG_8481_LED3_MASK, |
Yaniv Rosner | f25b3c8 | 2011-01-18 04:33:47 +0000 | [diff] [blame] | 9516 | 0x0006); |
| 9517 | |
| 9518 | /* Select the closest activity blink rate to that in 10/100/1000 */ |
| 9519 | bnx2x_cl45_write(bp, phy, |
| 9520 | MDIO_PMA_DEVAD, |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9521 | MDIO_PMA_REG_8481_LED3_BLINK, |
Yaniv Rosner | f25b3c8 | 2011-01-18 04:33:47 +0000 | [diff] [blame] | 9522 | 0); |
| 9523 | |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 9524 | /* Configure the blink rate to ~15.9 Hz */ |
Yaniv Rosner | f25b3c8 | 2011-01-18 04:33:47 +0000 | [diff] [blame] | 9525 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 9526 | MDIO_PMA_DEVAD, |
| 9527 | MDIO_PMA_REG_84823_CTL_SLOW_CLK_CNT_HIGH, |
| 9528 | MDIO_PMA_REG_84823_BLINK_RATE_VAL_15P9HZ); |
| 9529 | |
| 9530 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833) |
| 9531 | offset = MDIO_PMA_REG_84833_CTL_LED_CTL_1; |
| 9532 | else |
| 9533 | offset = MDIO_PMA_REG_84823_CTL_LED_CTL_1; |
| 9534 | |
| 9535 | bnx2x_cl45_read(bp, phy, |
| 9536 | MDIO_PMA_DEVAD, offset, &val); |
| 9537 | val |= MDIO_PMA_REG_84823_LED3_STRETCH_EN; /* stretch_en for LED3*/ |
| 9538 | bnx2x_cl45_write(bp, phy, |
| 9539 | MDIO_PMA_DEVAD, offset, val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9540 | |
| 9541 | /* 'Interrupt Mask' */ |
| 9542 | bnx2x_cl45_write(bp, phy, |
| 9543 | MDIO_AN_DEVAD, |
| 9544 | 0xFFFB, 0xFFFD); |
| 9545 | } |
| 9546 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 9547 | static int bnx2x_848xx_cmn_config_init(struct bnx2x_phy *phy, |
| 9548 | struct link_params *params, |
| 9549 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9550 | { |
| 9551 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 9552 | u16 autoneg_val, an_1000_val, an_10_100_val, an_10g_val; |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9553 | |
Mintz Yuval | 817a8aa | 2012-02-15 02:10:26 +0000 | [diff] [blame] | 9554 | if (phy->type != PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833) { |
Yaniv Rosner | 11b2ec6 | 2012-01-17 02:33:25 +0000 | [diff] [blame] | 9555 | /* Save spirom version */ |
| 9556 | bnx2x_save_848xx_spirom_version(phy, bp, params->port); |
| 9557 | } |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 9558 | /* |
| 9559 | * This phy uses the NIG latch mechanism since link indication |
| 9560 | * arrives through its LED4 and not via its LASI signal, so we |
| 9561 | * get steady signal instead of clear on read |
| 9562 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9563 | bnx2x_bits_en(bp, NIG_REG_LATCH_BC_0 + params->port*4, |
| 9564 | 1 << NIG_LATCH_BC_ENABLE_MI_INT); |
| 9565 | |
| 9566 | bnx2x_cl45_write(bp, phy, |
| 9567 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 0x0000); |
| 9568 | |
| 9569 | bnx2x_848xx_set_led(bp, phy); |
| 9570 | |
| 9571 | /* set 1000 speed advertisement */ |
| 9572 | bnx2x_cl45_read(bp, phy, |
| 9573 | MDIO_AN_DEVAD, MDIO_AN_REG_8481_1000T_CTRL, |
| 9574 | &an_1000_val); |
| 9575 | |
| 9576 | bnx2x_ext_phy_set_pause(params, phy, vars); |
| 9577 | bnx2x_cl45_read(bp, phy, |
| 9578 | MDIO_AN_DEVAD, |
| 9579 | MDIO_AN_REG_8481_LEGACY_AN_ADV, |
| 9580 | &an_10_100_val); |
| 9581 | bnx2x_cl45_read(bp, phy, |
| 9582 | MDIO_AN_DEVAD, MDIO_AN_REG_8481_LEGACY_MII_CTRL, |
| 9583 | &autoneg_val); |
| 9584 | /* Disable forced speed */ |
| 9585 | autoneg_val &= ~((1<<6) | (1<<8) | (1<<9) | (1<<12) | (1<<13)); |
| 9586 | an_10_100_val &= ~((1<<5) | (1<<6) | (1<<7) | (1<<8)); |
| 9587 | |
| 9588 | if (((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 9589 | (phy->speed_cap_mask & |
| 9590 | PORT_HW_CFG_SPEED_CAPABILITY_D0_1G)) || |
| 9591 | (phy->req_line_speed == SPEED_1000)) { |
| 9592 | an_1000_val |= (1<<8); |
| 9593 | autoneg_val |= (1<<9 | 1<<12); |
| 9594 | if (phy->req_duplex == DUPLEX_FULL) |
| 9595 | an_1000_val |= (1<<9); |
| 9596 | DP(NETIF_MSG_LINK, "Advertising 1G\n"); |
| 9597 | } else |
| 9598 | an_1000_val &= ~((1<<8) | (1<<9)); |
| 9599 | |
| 9600 | bnx2x_cl45_write(bp, phy, |
| 9601 | MDIO_AN_DEVAD, MDIO_AN_REG_8481_1000T_CTRL, |
| 9602 | an_1000_val); |
| 9603 | |
Yaniv Rosner | 0520e63 | 2011-07-05 01:06:59 +0000 | [diff] [blame] | 9604 | /* set 100 speed advertisement */ |
Yaniv Rosner | 7531832 | 2012-01-17 02:33:27 +0000 | [diff] [blame] | 9605 | if ((phy->req_line_speed == SPEED_AUTO_NEG) && |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9606 | (phy->speed_cap_mask & |
Yaniv Rosner | 0520e63 | 2011-07-05 01:06:59 +0000 | [diff] [blame] | 9607 | (PORT_HW_CFG_SPEED_CAPABILITY_D0_100M_FULL | |
Yaniv Rosner | 7531832 | 2012-01-17 02:33:27 +0000 | [diff] [blame] | 9608 | PORT_HW_CFG_SPEED_CAPABILITY_D0_100M_HALF))) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9609 | an_10_100_val |= (1<<7); |
| 9610 | /* Enable autoneg and restart autoneg for legacy speeds */ |
| 9611 | autoneg_val |= (1<<9 | 1<<12); |
| 9612 | |
| 9613 | if (phy->req_duplex == DUPLEX_FULL) |
| 9614 | an_10_100_val |= (1<<8); |
| 9615 | DP(NETIF_MSG_LINK, "Advertising 100M\n"); |
| 9616 | } |
| 9617 | /* set 10 speed advertisement */ |
| 9618 | if (((phy->req_line_speed == SPEED_AUTO_NEG) && |
Yaniv Rosner | 0520e63 | 2011-07-05 01:06:59 +0000 | [diff] [blame] | 9619 | (phy->speed_cap_mask & |
| 9620 | (PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_FULL | |
| 9621 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_HALF)) && |
| 9622 | (phy->supported & |
| 9623 | (SUPPORTED_10baseT_Half | |
| 9624 | SUPPORTED_10baseT_Full)))) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9625 | an_10_100_val |= (1<<5); |
| 9626 | autoneg_val |= (1<<9 | 1<<12); |
| 9627 | if (phy->req_duplex == DUPLEX_FULL) |
| 9628 | an_10_100_val |= (1<<6); |
| 9629 | DP(NETIF_MSG_LINK, "Advertising 10M\n"); |
| 9630 | } |
| 9631 | |
| 9632 | /* Only 10/100 are allowed to work in FORCE mode */ |
Yaniv Rosner | 0520e63 | 2011-07-05 01:06:59 +0000 | [diff] [blame] | 9633 | if ((phy->req_line_speed == SPEED_100) && |
| 9634 | (phy->supported & |
| 9635 | (SUPPORTED_100baseT_Half | |
| 9636 | SUPPORTED_100baseT_Full))) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9637 | autoneg_val |= (1<<13); |
| 9638 | /* Enabled AUTO-MDIX when autoneg is disabled */ |
| 9639 | bnx2x_cl45_write(bp, phy, |
| 9640 | MDIO_AN_DEVAD, MDIO_AN_REG_8481_AUX_CTRL, |
| 9641 | (1<<15 | 1<<9 | 7<<0)); |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 9642 | /* The PHY needs this set even for forced link. */ |
| 9643 | an_10_100_val |= (1<<8) | (1<<7); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9644 | DP(NETIF_MSG_LINK, "Setting 100M force\n"); |
| 9645 | } |
Yaniv Rosner | 0520e63 | 2011-07-05 01:06:59 +0000 | [diff] [blame] | 9646 | if ((phy->req_line_speed == SPEED_10) && |
| 9647 | (phy->supported & |
| 9648 | (SUPPORTED_10baseT_Half | |
| 9649 | SUPPORTED_10baseT_Full))) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9650 | /* Enabled AUTO-MDIX when autoneg is disabled */ |
| 9651 | bnx2x_cl45_write(bp, phy, |
| 9652 | MDIO_AN_DEVAD, MDIO_AN_REG_8481_AUX_CTRL, |
| 9653 | (1<<15 | 1<<9 | 7<<0)); |
| 9654 | DP(NETIF_MSG_LINK, "Setting 10M force\n"); |
| 9655 | } |
| 9656 | |
| 9657 | bnx2x_cl45_write(bp, phy, |
| 9658 | MDIO_AN_DEVAD, MDIO_AN_REG_8481_LEGACY_AN_ADV, |
| 9659 | an_10_100_val); |
| 9660 | |
| 9661 | if (phy->req_duplex == DUPLEX_FULL) |
| 9662 | autoneg_val |= (1<<8); |
| 9663 | |
Yaniv Rosner | fd38f73e | 2011-08-02 22:59:53 +0000 | [diff] [blame] | 9664 | /* |
| 9665 | * Always write this if this is not 84833. |
| 9666 | * For 84833, write it only when it's a forced speed. |
| 9667 | */ |
| 9668 | if ((phy->type != PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833) || |
| 9669 | ((autoneg_val & (1<<12)) == 0)) |
| 9670 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9671 | MDIO_AN_DEVAD, |
| 9672 | MDIO_AN_REG_8481_LEGACY_MII_CTRL, autoneg_val); |
| 9673 | |
| 9674 | if (((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 9675 | (phy->speed_cap_mask & |
| 9676 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G)) || |
| 9677 | (phy->req_line_speed == SPEED_10000)) { |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 9678 | DP(NETIF_MSG_LINK, "Advertising 10G\n"); |
| 9679 | /* Restart autoneg for 10G*/ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9680 | |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 9681 | bnx2x_cl45_read(bp, phy, |
| 9682 | MDIO_AN_DEVAD, |
| 9683 | MDIO_AN_REG_8481_10GBASE_T_AN_CTRL, |
| 9684 | &an_10g_val); |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 9685 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 9686 | MDIO_AN_DEVAD, |
| 9687 | MDIO_AN_REG_8481_10GBASE_T_AN_CTRL, |
| 9688 | an_10g_val | 0x1000); |
| 9689 | bnx2x_cl45_write(bp, phy, |
| 9690 | MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, |
| 9691 | 0x3200); |
Yaniv Rosner | fd38f73e | 2011-08-02 22:59:53 +0000 | [diff] [blame] | 9692 | } else |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9693 | bnx2x_cl45_write(bp, phy, |
| 9694 | MDIO_AN_DEVAD, |
| 9695 | MDIO_AN_REG_8481_10GBASE_T_AN_CTRL, |
| 9696 | 1); |
Yaniv Rosner | fd38f73e | 2011-08-02 22:59:53 +0000 | [diff] [blame] | 9697 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9698 | return 0; |
| 9699 | } |
| 9700 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 9701 | static int bnx2x_8481_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; |
| 9706 | /* Restore normal power mode*/ |
| 9707 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 9708 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, params->port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9709 | |
| 9710 | /* HW reset */ |
| 9711 | bnx2x_ext_phy_hw_reset(bp, params->port); |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 9712 | bnx2x_wait_reset_complete(bp, phy, params); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9713 | |
| 9714 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 1<<15); |
| 9715 | return bnx2x_848xx_cmn_config_init(phy, params, vars); |
| 9716 | } |
| 9717 | |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 9718 | #define PHY84833_CMDHDLR_WAIT 300 |
| 9719 | #define PHY84833_CMDHDLR_MAX_ARGS 5 |
| 9720 | static int bnx2x_84833_cmd_hdlr(struct bnx2x_phy *phy, |
| 9721 | struct link_params *params, |
| 9722 | u16 fw_cmd, |
| 9723 | u16 cmd_args[]) |
| 9724 | { |
| 9725 | u32 idx; |
| 9726 | u16 val; |
| 9727 | struct bnx2x *bp = params->bp; |
| 9728 | /* Write CMD_OPEN_OVERRIDE to STATUS reg */ |
| 9729 | bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD, |
| 9730 | MDIO_84833_CMD_HDLR_STATUS, |
| 9731 | PHY84833_STATUS_CMD_OPEN_OVERRIDE); |
| 9732 | for (idx = 0; idx < PHY84833_CMDHDLR_WAIT; idx++) { |
| 9733 | bnx2x_cl45_read(bp, phy, MDIO_CTL_DEVAD, |
| 9734 | MDIO_84833_CMD_HDLR_STATUS, &val); |
| 9735 | if (val == PHY84833_STATUS_CMD_OPEN_FOR_CMDS) |
| 9736 | break; |
| 9737 | msleep(1); |
| 9738 | } |
| 9739 | if (idx >= PHY84833_CMDHDLR_WAIT) { |
| 9740 | DP(NETIF_MSG_LINK, "FW cmd: FW not ready.\n"); |
| 9741 | return -EINVAL; |
| 9742 | } |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9743 | |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 9744 | /* Prepare argument(s) and issue command */ |
| 9745 | for (idx = 0; idx < PHY84833_CMDHDLR_MAX_ARGS; idx++) { |
| 9746 | bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD, |
| 9747 | MDIO_84833_CMD_HDLR_DATA1 + idx, |
| 9748 | cmd_args[idx]); |
| 9749 | } |
| 9750 | bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD, |
| 9751 | MDIO_84833_CMD_HDLR_COMMAND, fw_cmd); |
| 9752 | for (idx = 0; idx < PHY84833_CMDHDLR_WAIT; idx++) { |
| 9753 | bnx2x_cl45_read(bp, phy, MDIO_CTL_DEVAD, |
| 9754 | MDIO_84833_CMD_HDLR_STATUS, &val); |
| 9755 | if ((val == PHY84833_STATUS_CMD_COMPLETE_PASS) || |
| 9756 | (val == PHY84833_STATUS_CMD_COMPLETE_ERROR)) |
| 9757 | break; |
| 9758 | msleep(1); |
| 9759 | } |
| 9760 | if ((idx >= PHY84833_CMDHDLR_WAIT) || |
| 9761 | (val == PHY84833_STATUS_CMD_COMPLETE_ERROR)) { |
| 9762 | DP(NETIF_MSG_LINK, "FW cmd failed.\n"); |
| 9763 | return -EINVAL; |
| 9764 | } |
| 9765 | /* Gather returning data */ |
| 9766 | for (idx = 0; idx < PHY84833_CMDHDLR_MAX_ARGS; idx++) { |
| 9767 | bnx2x_cl45_read(bp, phy, MDIO_CTL_DEVAD, |
| 9768 | MDIO_84833_CMD_HDLR_DATA1 + idx, |
| 9769 | &cmd_args[idx]); |
| 9770 | } |
| 9771 | bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD, |
| 9772 | MDIO_84833_CMD_HDLR_STATUS, |
| 9773 | PHY84833_STATUS_CMD_CLEAR_COMPLETE); |
| 9774 | return 0; |
| 9775 | } |
| 9776 | |
| 9777 | |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9778 | static int bnx2x_84833_pair_swap_cfg(struct bnx2x_phy *phy, |
| 9779 | struct link_params *params, |
| 9780 | struct link_vars *vars) |
| 9781 | { |
Yaniv Rosner | 0520e63 | 2011-07-05 01:06:59 +0000 | [diff] [blame] | 9782 | u32 pair_swap; |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 9783 | u16 data[PHY84833_CMDHDLR_MAX_ARGS]; |
| 9784 | int status; |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9785 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9786 | |
Yaniv Rosner | 0520e63 | 2011-07-05 01:06:59 +0000 | [diff] [blame] | 9787 | /* Check for configuration. */ |
| 9788 | pair_swap = REG_RD(bp, params->shmem_base + |
| 9789 | offsetof(struct shmem_region, |
| 9790 | dev_info.port_hw_config[params->port].xgbt_phy_cfg)) & |
| 9791 | PORT_HW_CFG_RJ45_PAIR_SWAP_MASK; |
| 9792 | |
| 9793 | if (pair_swap == 0) |
| 9794 | return 0; |
| 9795 | |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 9796 | /* Only the second argument is used for this command */ |
| 9797 | data[1] = (u16)pair_swap; |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9798 | |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 9799 | status = bnx2x_84833_cmd_hdlr(phy, params, |
| 9800 | PHY84833_CMD_SET_PAIR_SWAP, data); |
| 9801 | if (status == 0) |
| 9802 | DP(NETIF_MSG_LINK, "Pairswap OK, val=0x%x\n", data[1]); |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9803 | |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 9804 | return status; |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9805 | } |
| 9806 | |
Yaniv Rosner | 985848f | 2011-07-05 01:06:48 +0000 | [diff] [blame] | 9807 | static u8 bnx2x_84833_get_reset_gpios(struct bnx2x *bp, |
| 9808 | u32 shmem_base_path[], |
| 9809 | u32 chip_id) |
Yaniv Rosner | 0d40f0d | 2011-06-14 01:34:27 +0000 | [diff] [blame] | 9810 | { |
| 9811 | u32 reset_pin[2]; |
| 9812 | u32 idx; |
| 9813 | u8 reset_gpios; |
| 9814 | if (CHIP_IS_E3(bp)) { |
| 9815 | /* Assume that these will be GPIOs, not EPIOs. */ |
| 9816 | for (idx = 0; idx < 2; idx++) { |
| 9817 | /* Map config param to register bit. */ |
| 9818 | reset_pin[idx] = REG_RD(bp, shmem_base_path[idx] + |
| 9819 | offsetof(struct shmem_region, |
| 9820 | dev_info.port_hw_config[0].e3_cmn_pin_cfg)); |
| 9821 | reset_pin[idx] = (reset_pin[idx] & |
| 9822 | PORT_HW_CFG_E3_PHY_RESET_MASK) >> |
| 9823 | PORT_HW_CFG_E3_PHY_RESET_SHIFT; |
| 9824 | reset_pin[idx] -= PIN_CFG_GPIO0_P0; |
| 9825 | reset_pin[idx] = (1 << reset_pin[idx]); |
| 9826 | } |
| 9827 | reset_gpios = (u8)(reset_pin[0] | reset_pin[1]); |
| 9828 | } else { |
| 9829 | /* E2, look from diff place of shmem. */ |
| 9830 | for (idx = 0; idx < 2; idx++) { |
| 9831 | reset_pin[idx] = REG_RD(bp, shmem_base_path[idx] + |
| 9832 | offsetof(struct shmem_region, |
| 9833 | dev_info.port_hw_config[0].default_cfg)); |
| 9834 | reset_pin[idx] &= PORT_HW_CFG_EXT_PHY_GPIO_RST_MASK; |
| 9835 | reset_pin[idx] -= PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO0_P0; |
| 9836 | reset_pin[idx] >>= PORT_HW_CFG_EXT_PHY_GPIO_RST_SHIFT; |
| 9837 | reset_pin[idx] = (1 << reset_pin[idx]); |
| 9838 | } |
| 9839 | reset_gpios = (u8)(reset_pin[0] | reset_pin[1]); |
| 9840 | } |
| 9841 | |
Yaniv Rosner | 985848f | 2011-07-05 01:06:48 +0000 | [diff] [blame] | 9842 | return reset_gpios; |
| 9843 | } |
| 9844 | |
| 9845 | static int bnx2x_84833_hw_reset_phy(struct bnx2x_phy *phy, |
| 9846 | struct link_params *params) |
| 9847 | { |
| 9848 | struct bnx2x *bp = params->bp; |
| 9849 | u8 reset_gpios; |
| 9850 | u32 other_shmem_base_addr = REG_RD(bp, params->shmem2_base + |
| 9851 | offsetof(struct shmem2_region, |
| 9852 | other_shmem_base_addr)); |
| 9853 | |
| 9854 | u32 shmem_base_path[2]; |
| 9855 | shmem_base_path[0] = params->shmem_base; |
| 9856 | shmem_base_path[1] = other_shmem_base_addr; |
| 9857 | |
| 9858 | reset_gpios = bnx2x_84833_get_reset_gpios(bp, shmem_base_path, |
| 9859 | params->chip_id); |
| 9860 | |
| 9861 | bnx2x_set_mult_gpio(bp, reset_gpios, MISC_REGISTERS_GPIO_OUTPUT_LOW); |
| 9862 | udelay(10); |
| 9863 | DP(NETIF_MSG_LINK, "84833 hw reset on pin values 0x%x\n", |
| 9864 | reset_gpios); |
| 9865 | |
| 9866 | return 0; |
| 9867 | } |
| 9868 | |
Yaniv Rosner | a89a1d4 | 2011-07-05 01:07:05 +0000 | [diff] [blame] | 9869 | #define PHY84833_CONSTANT_LATENCY 1193 |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 9870 | static int bnx2x_848x3_config_init(struct bnx2x_phy *phy, |
| 9871 | struct link_params *params, |
| 9872 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9873 | { |
| 9874 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 6a71bbe | 2010-11-01 05:32:31 +0000 | [diff] [blame] | 9875 | u8 port, initialize = 1; |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9876 | u16 val; |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 9877 | u32 actual_phy_selection, cms_enable; |
| 9878 | u16 cmd_args[PHY84833_CMDHDLR_MAX_ARGS]; |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 9879 | int rc = 0; |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 9880 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 9881 | msleep(1); |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9882 | |
| 9883 | if (!(CHIP_IS_E1(bp))) |
Yaniv Rosner | 6a71bbe | 2010-11-01 05:32:31 +0000 | [diff] [blame] | 9884 | port = BP_PATH(bp); |
| 9885 | else |
| 9886 | port = params->port; |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9887 | |
| 9888 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84823) { |
| 9889 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_3, |
| 9890 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, |
| 9891 | port); |
| 9892 | } else { |
Yaniv Rosner | 985848f | 2011-07-05 01:06:48 +0000 | [diff] [blame] | 9893 | /* MDIO reset */ |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9894 | bnx2x_cl45_write(bp, phy, |
| 9895 | MDIO_PMA_DEVAD, |
| 9896 | MDIO_PMA_REG_CTRL, 0x8000); |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 9897 | } |
| 9898 | |
| 9899 | bnx2x_wait_reset_complete(bp, phy, params); |
| 9900 | |
| 9901 | /* Wait for GPHY to come out of reset */ |
| 9902 | msleep(50); |
Yaniv Rosner | 11b2ec6 | 2012-01-17 02:33:25 +0000 | [diff] [blame] | 9903 | if (phy->type != PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833) { |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 9904 | /* |
| 9905 | * BCM84823 requires that XGXS links up first @ 10G for normal |
| 9906 | * behavior. |
| 9907 | */ |
| 9908 | u16 temp; |
| 9909 | temp = vars->line_speed; |
| 9910 | vars->line_speed = SPEED_10000; |
| 9911 | bnx2x_set_autoneg(¶ms->phy[INT_PHY], params, vars, 0); |
| 9912 | bnx2x_program_serdes(¶ms->phy[INT_PHY], params, vars); |
| 9913 | vars->line_speed = temp; |
| 9914 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 9915 | |
| 9916 | bnx2x_cl45_read(bp, phy, MDIO_CTL_DEVAD, |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9917 | MDIO_CTL_REG_84823_MEDIA, &val); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 9918 | val &= ~(MDIO_CTL_REG_84823_MEDIA_MAC_MASK | |
| 9919 | MDIO_CTL_REG_84823_MEDIA_LINE_MASK | |
| 9920 | MDIO_CTL_REG_84823_MEDIA_COPPER_CORE_DOWN | |
| 9921 | MDIO_CTL_REG_84823_MEDIA_PRIORITY_MASK | |
| 9922 | MDIO_CTL_REG_84823_MEDIA_FIBER_1G); |
Yaniv Rosner | 0d40f0d | 2011-06-14 01:34:27 +0000 | [diff] [blame] | 9923 | |
| 9924 | if (CHIP_IS_E3(bp)) { |
| 9925 | val &= ~(MDIO_CTL_REG_84823_MEDIA_MAC_MASK | |
| 9926 | MDIO_CTL_REG_84823_MEDIA_LINE_MASK); |
| 9927 | } else { |
| 9928 | val |= (MDIO_CTL_REG_84823_CTRL_MAC_XFI | |
| 9929 | MDIO_CTL_REG_84823_MEDIA_LINE_XAUI_L); |
| 9930 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 9931 | |
| 9932 | actual_phy_selection = bnx2x_phy_selection(params); |
| 9933 | |
| 9934 | switch (actual_phy_selection) { |
| 9935 | case PORT_HW_CFG_PHY_SELECTION_HARDWARE_DEFAULT: |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 9936 | /* Do nothing. Essentially this is like the priority copper */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 9937 | break; |
| 9938 | case PORT_HW_CFG_PHY_SELECTION_FIRST_PHY_PRIORITY: |
| 9939 | val |= MDIO_CTL_REG_84823_MEDIA_PRIORITY_COPPER; |
| 9940 | break; |
| 9941 | case PORT_HW_CFG_PHY_SELECTION_SECOND_PHY_PRIORITY: |
| 9942 | val |= MDIO_CTL_REG_84823_MEDIA_PRIORITY_FIBER; |
| 9943 | break; |
| 9944 | case PORT_HW_CFG_PHY_SELECTION_FIRST_PHY: |
| 9945 | /* Do nothing here. The first PHY won't be initialized at all */ |
| 9946 | break; |
| 9947 | case PORT_HW_CFG_PHY_SELECTION_SECOND_PHY: |
| 9948 | val |= MDIO_CTL_REG_84823_MEDIA_COPPER_CORE_DOWN; |
| 9949 | initialize = 0; |
| 9950 | break; |
| 9951 | } |
| 9952 | if (params->phy[EXT_PHY2].req_line_speed == SPEED_1000) |
| 9953 | val |= MDIO_CTL_REG_84823_MEDIA_FIBER_1G; |
| 9954 | |
| 9955 | bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD, |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 9956 | MDIO_CTL_REG_84823_MEDIA, val); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 9957 | DP(NETIF_MSG_LINK, "Multi_phy config = 0x%x, Media control = 0x%x\n", |
| 9958 | params->multi_phy_config, val); |
| 9959 | |
Yaniv Rosner | 11b2ec6 | 2012-01-17 02:33:25 +0000 | [diff] [blame] | 9960 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833) { |
| 9961 | bnx2x_84833_pair_swap_cfg(phy, params, vars); |
Yaniv Rosner | a89a1d4 | 2011-07-05 01:07:05 +0000 | [diff] [blame] | 9962 | |
Yaniv Rosner | 096b952 | 2012-01-17 02:33:28 +0000 | [diff] [blame] | 9963 | /* Keep AutogrEEEn disabled. */ |
| 9964 | cmd_args[0] = 0x0; |
Yaniv Rosner | 11b2ec6 | 2012-01-17 02:33:25 +0000 | [diff] [blame] | 9965 | cmd_args[1] = 0x0; |
| 9966 | cmd_args[2] = PHY84833_CONSTANT_LATENCY + 1; |
| 9967 | cmd_args[3] = PHY84833_CONSTANT_LATENCY; |
| 9968 | rc = bnx2x_84833_cmd_hdlr(phy, params, |
| 9969 | PHY84833_CMD_SET_EEE_MODE, cmd_args); |
| 9970 | if (rc != 0) |
| 9971 | DP(NETIF_MSG_LINK, "Cfg AutogrEEEn failed.\n"); |
| 9972 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 9973 | if (initialize) |
| 9974 | rc = bnx2x_848xx_cmn_config_init(phy, params, vars); |
| 9975 | else |
Yaniv Rosner | 11b2ec6 | 2012-01-17 02:33:25 +0000 | [diff] [blame] | 9976 | bnx2x_save_848xx_spirom_version(phy, bp, params->port); |
Yaniv Rosner | a89a1d4 | 2011-07-05 01:07:05 +0000 | [diff] [blame] | 9977 | /* 84833 PHY has a better feature and doesn't need to support this. */ |
| 9978 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84823) { |
| 9979 | cms_enable = REG_RD(bp, params->shmem_base + |
Yaniv Rosner | 1bef68e | 2011-01-31 04:22:46 +0000 | [diff] [blame] | 9980 | offsetof(struct shmem_region, |
| 9981 | dev_info.port_hw_config[params->port].default_cfg)) & |
| 9982 | PORT_HW_CFG_ENABLE_CMS_MASK; |
| 9983 | |
Yaniv Rosner | a89a1d4 | 2011-07-05 01:07:05 +0000 | [diff] [blame] | 9984 | bnx2x_cl45_read(bp, phy, MDIO_CTL_DEVAD, |
| 9985 | MDIO_CTL_REG_84823_USER_CTRL_REG, &val); |
| 9986 | if (cms_enable) |
| 9987 | val |= MDIO_CTL_REG_84823_USER_CTRL_CMS; |
| 9988 | else |
| 9989 | val &= ~MDIO_CTL_REG_84823_USER_CTRL_CMS; |
| 9990 | bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD, |
| 9991 | MDIO_CTL_REG_84823_USER_CTRL_REG, val); |
| 9992 | } |
Yaniv Rosner | 1bef68e | 2011-01-31 04:22:46 +0000 | [diff] [blame] | 9993 | |
Yaniv Rosner | 11b2ec6 | 2012-01-17 02:33:25 +0000 | [diff] [blame] | 9994 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833) { |
| 9995 | /* Bring PHY out of super isolate mode as the final step. */ |
| 9996 | bnx2x_cl45_read(bp, phy, |
| 9997 | MDIO_CTL_DEVAD, |
| 9998 | MDIO_84833_TOP_CFG_XGPHY_STRAP1, &val); |
| 9999 | val &= ~MDIO_84833_SUPER_ISOLATE; |
| 10000 | bnx2x_cl45_write(bp, phy, |
| 10001 | MDIO_CTL_DEVAD, |
| 10002 | MDIO_84833_TOP_CFG_XGPHY_STRAP1, val); |
| 10003 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 10004 | return rc; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10005 | } |
| 10006 | |
| 10007 | static u8 bnx2x_848xx_read_status(struct bnx2x_phy *phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10008 | struct link_params *params, |
| 10009 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10010 | { |
| 10011 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 10012 | u16 val, val1, val2; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10013 | u8 link_up = 0; |
| 10014 | |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 10015 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10016 | /* Check 10G-BaseT link status */ |
| 10017 | /* Check PMD signal ok */ |
| 10018 | bnx2x_cl45_read(bp, phy, |
| 10019 | MDIO_AN_DEVAD, 0xFFFA, &val1); |
| 10020 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 10021 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8481_PMD_SIGNAL, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10022 | &val2); |
| 10023 | DP(NETIF_MSG_LINK, "BCM848xx: PMD_SIGNAL 1.a811 = 0x%x\n", val2); |
| 10024 | |
| 10025 | /* Check link 10G */ |
| 10026 | if (val2 & (1<<11)) { |
| 10027 | vars->line_speed = SPEED_10000; |
Yaniv Rosner | 791f18c | 2011-01-18 04:33:42 +0000 | [diff] [blame] | 10028 | vars->duplex = DUPLEX_FULL; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10029 | link_up = 1; |
| 10030 | bnx2x_ext_phy_10G_an_resolve(bp, phy, vars); |
| 10031 | } else { /* Check Legacy speed link */ |
| 10032 | u16 legacy_status, legacy_speed; |
| 10033 | |
| 10034 | /* Enable expansion register 0x42 (Operation mode status) */ |
| 10035 | bnx2x_cl45_write(bp, phy, |
| 10036 | MDIO_AN_DEVAD, |
| 10037 | MDIO_AN_REG_8481_EXPANSION_REG_ACCESS, 0xf42); |
| 10038 | |
| 10039 | /* Get legacy speed operation status */ |
| 10040 | bnx2x_cl45_read(bp, phy, |
| 10041 | MDIO_AN_DEVAD, |
| 10042 | MDIO_AN_REG_8481_EXPANSION_REG_RD_RW, |
| 10043 | &legacy_status); |
| 10044 | |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 10045 | DP(NETIF_MSG_LINK, "Legacy speed status = 0x%x\n", |
| 10046 | legacy_status); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10047 | link_up = ((legacy_status & (1<<11)) == (1<<11)); |
| 10048 | if (link_up) { |
| 10049 | legacy_speed = (legacy_status & (3<<9)); |
| 10050 | if (legacy_speed == (0<<9)) |
| 10051 | vars->line_speed = SPEED_10; |
| 10052 | else if (legacy_speed == (1<<9)) |
| 10053 | vars->line_speed = SPEED_100; |
| 10054 | else if (legacy_speed == (2<<9)) |
| 10055 | vars->line_speed = SPEED_1000; |
| 10056 | else /* Should not happen */ |
| 10057 | vars->line_speed = 0; |
| 10058 | |
| 10059 | if (legacy_status & (1<<8)) |
| 10060 | vars->duplex = DUPLEX_FULL; |
| 10061 | else |
| 10062 | vars->duplex = DUPLEX_HALF; |
| 10063 | |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 10064 | DP(NETIF_MSG_LINK, |
| 10065 | "Link is up in %dMbps, is_duplex_full= %d\n", |
| 10066 | vars->line_speed, |
| 10067 | (vars->duplex == DUPLEX_FULL)); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10068 | /* Check legacy speed AN resolution */ |
| 10069 | bnx2x_cl45_read(bp, phy, |
| 10070 | MDIO_AN_DEVAD, |
| 10071 | MDIO_AN_REG_8481_LEGACY_MII_STATUS, |
| 10072 | &val); |
| 10073 | if (val & (1<<5)) |
| 10074 | vars->link_status |= |
| 10075 | LINK_STATUS_AUTO_NEGOTIATE_COMPLETE; |
| 10076 | bnx2x_cl45_read(bp, phy, |
| 10077 | MDIO_AN_DEVAD, |
| 10078 | MDIO_AN_REG_8481_LEGACY_AN_EXPANSION, |
| 10079 | &val); |
| 10080 | if ((val & (1<<0)) == 0) |
| 10081 | vars->link_status |= |
| 10082 | LINK_STATUS_PARALLEL_DETECTION_USED; |
| 10083 | } |
| 10084 | } |
| 10085 | if (link_up) { |
| 10086 | DP(NETIF_MSG_LINK, "BCM84823: link speed is %d\n", |
| 10087 | vars->line_speed); |
| 10088 | bnx2x_ext_phy_resolve_fc(phy, params, vars); |
Mintz Yuval | 9e7e839 | 2012-02-15 02:10:24 +0000 | [diff] [blame] | 10089 | |
| 10090 | /* Read LP advertised speeds */ |
| 10091 | bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD, |
| 10092 | MDIO_AN_REG_CL37_FC_LP, &val); |
| 10093 | if (val & (1<<5)) |
| 10094 | vars->link_status |= |
| 10095 | LINK_STATUS_LINK_PARTNER_10THD_CAPABLE; |
| 10096 | if (val & (1<<6)) |
| 10097 | vars->link_status |= |
| 10098 | LINK_STATUS_LINK_PARTNER_10TFD_CAPABLE; |
| 10099 | if (val & (1<<7)) |
| 10100 | vars->link_status |= |
| 10101 | LINK_STATUS_LINK_PARTNER_100TXHD_CAPABLE; |
| 10102 | if (val & (1<<8)) |
| 10103 | vars->link_status |= |
| 10104 | LINK_STATUS_LINK_PARTNER_100TXFD_CAPABLE; |
| 10105 | if (val & (1<<9)) |
| 10106 | vars->link_status |= |
| 10107 | LINK_STATUS_LINK_PARTNER_100T4_CAPABLE; |
| 10108 | |
| 10109 | bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD, |
| 10110 | MDIO_AN_REG_1000T_STATUS, &val); |
| 10111 | |
| 10112 | if (val & (1<<10)) |
| 10113 | vars->link_status |= |
| 10114 | LINK_STATUS_LINK_PARTNER_1000THD_CAPABLE; |
| 10115 | if (val & (1<<11)) |
| 10116 | vars->link_status |= |
| 10117 | LINK_STATUS_LINK_PARTNER_1000TFD_CAPABLE; |
| 10118 | |
| 10119 | bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD, |
| 10120 | MDIO_AN_REG_MASTER_STATUS, &val); |
| 10121 | |
| 10122 | if (val & (1<<11)) |
| 10123 | vars->link_status |= |
| 10124 | LINK_STATUS_LINK_PARTNER_10GXFD_CAPABLE; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10125 | } |
| 10126 | |
| 10127 | return link_up; |
| 10128 | } |
| 10129 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 10130 | |
| 10131 | 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] | 10132 | { |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 10133 | int status = 0; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10134 | u32 spirom_ver; |
| 10135 | spirom_ver = ((raw_ver & 0xF80) >> 7) << 16 | (raw_ver & 0x7F); |
| 10136 | status = bnx2x_format_ver(spirom_ver, str, len); |
| 10137 | return status; |
| 10138 | } |
| 10139 | |
| 10140 | static void bnx2x_8481_hw_reset(struct bnx2x_phy *phy, |
| 10141 | struct link_params *params) |
| 10142 | { |
| 10143 | bnx2x_set_gpio(params->bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10144 | MISC_REGISTERS_GPIO_OUTPUT_LOW, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10145 | bnx2x_set_gpio(params->bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10146 | MISC_REGISTERS_GPIO_OUTPUT_LOW, 1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10147 | } |
| 10148 | |
| 10149 | static void bnx2x_8481_link_reset(struct bnx2x_phy *phy, |
| 10150 | struct link_params *params) |
| 10151 | { |
| 10152 | bnx2x_cl45_write(params->bp, phy, |
| 10153 | MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, 0x0000); |
| 10154 | bnx2x_cl45_write(params->bp, phy, |
| 10155 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 1); |
| 10156 | } |
| 10157 | |
| 10158 | static void bnx2x_848x3_link_reset(struct bnx2x_phy *phy, |
| 10159 | struct link_params *params) |
| 10160 | { |
| 10161 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 6a71bbe | 2010-11-01 05:32:31 +0000 | [diff] [blame] | 10162 | u8 port; |
Yaniv Rosner | 0d40f0d | 2011-06-14 01:34:27 +0000 | [diff] [blame] | 10163 | u16 val16; |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 10164 | |
| 10165 | if (!(CHIP_IS_E1(bp))) |
Yaniv Rosner | 6a71bbe | 2010-11-01 05:32:31 +0000 | [diff] [blame] | 10166 | port = BP_PATH(bp); |
| 10167 | else |
| 10168 | port = params->port; |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 10169 | |
| 10170 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84823) { |
| 10171 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_3, |
| 10172 | MISC_REGISTERS_GPIO_OUTPUT_LOW, |
| 10173 | port); |
| 10174 | } else { |
Yaniv Rosner | 0d40f0d | 2011-06-14 01:34:27 +0000 | [diff] [blame] | 10175 | bnx2x_cl45_read(bp, phy, |
| 10176 | MDIO_CTL_DEVAD, |
Yaniv Rosner | 11b2ec6 | 2012-01-17 02:33:25 +0000 | [diff] [blame] | 10177 | MDIO_84833_TOP_CFG_XGPHY_STRAP1, &val16); |
| 10178 | val16 |= MDIO_84833_SUPER_ISOLATE; |
Yaniv Rosner | fd38f73e | 2011-08-02 22:59:53 +0000 | [diff] [blame] | 10179 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 11b2ec6 | 2012-01-17 02:33:25 +0000 | [diff] [blame] | 10180 | MDIO_CTL_DEVAD, |
| 10181 | MDIO_84833_TOP_CFG_XGPHY_STRAP1, val16); |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 10182 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10183 | } |
| 10184 | |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10185 | static void bnx2x_848xx_set_link_led(struct bnx2x_phy *phy, |
| 10186 | struct link_params *params, u8 mode) |
| 10187 | { |
| 10188 | struct bnx2x *bp = params->bp; |
| 10189 | u16 val; |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 10190 | u8 port; |
| 10191 | |
| 10192 | if (!(CHIP_IS_E1(bp))) |
| 10193 | port = BP_PATH(bp); |
| 10194 | else |
| 10195 | port = params->port; |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10196 | |
| 10197 | switch (mode) { |
| 10198 | case LED_MODE_OFF: |
| 10199 | |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 10200 | DP(NETIF_MSG_LINK, "Port 0x%x: LED MODE OFF\n", port); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10201 | |
| 10202 | if ((params->hw_led_mode << SHARED_HW_CFG_LED_MODE_SHIFT) == |
| 10203 | SHARED_HW_CFG_LED_EXTPHY1) { |
| 10204 | |
| 10205 | /* Set LED masks */ |
| 10206 | bnx2x_cl45_write(bp, phy, |
| 10207 | MDIO_PMA_DEVAD, |
| 10208 | MDIO_PMA_REG_8481_LED1_MASK, |
| 10209 | 0x0); |
| 10210 | |
| 10211 | bnx2x_cl45_write(bp, phy, |
| 10212 | MDIO_PMA_DEVAD, |
| 10213 | MDIO_PMA_REG_8481_LED2_MASK, |
| 10214 | 0x0); |
| 10215 | |
| 10216 | bnx2x_cl45_write(bp, phy, |
| 10217 | MDIO_PMA_DEVAD, |
| 10218 | MDIO_PMA_REG_8481_LED3_MASK, |
| 10219 | 0x0); |
| 10220 | |
| 10221 | bnx2x_cl45_write(bp, phy, |
| 10222 | MDIO_PMA_DEVAD, |
| 10223 | MDIO_PMA_REG_8481_LED5_MASK, |
| 10224 | 0x0); |
| 10225 | |
| 10226 | } else { |
| 10227 | bnx2x_cl45_write(bp, phy, |
| 10228 | MDIO_PMA_DEVAD, |
| 10229 | MDIO_PMA_REG_8481_LED1_MASK, |
| 10230 | 0x0); |
| 10231 | } |
| 10232 | break; |
| 10233 | case LED_MODE_FRONT_PANEL_OFF: |
| 10234 | |
| 10235 | 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] | 10236 | port); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10237 | |
| 10238 | if ((params->hw_led_mode << SHARED_HW_CFG_LED_MODE_SHIFT) == |
| 10239 | SHARED_HW_CFG_LED_EXTPHY1) { |
| 10240 | |
| 10241 | /* Set LED masks */ |
| 10242 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10243 | MDIO_PMA_DEVAD, |
| 10244 | MDIO_PMA_REG_8481_LED1_MASK, |
| 10245 | 0x0); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10246 | |
| 10247 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10248 | MDIO_PMA_DEVAD, |
| 10249 | MDIO_PMA_REG_8481_LED2_MASK, |
| 10250 | 0x0); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10251 | |
| 10252 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10253 | MDIO_PMA_DEVAD, |
| 10254 | MDIO_PMA_REG_8481_LED3_MASK, |
| 10255 | 0x0); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10256 | |
| 10257 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10258 | MDIO_PMA_DEVAD, |
| 10259 | MDIO_PMA_REG_8481_LED5_MASK, |
| 10260 | 0x20); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10261 | |
| 10262 | } else { |
| 10263 | bnx2x_cl45_write(bp, phy, |
| 10264 | MDIO_PMA_DEVAD, |
| 10265 | MDIO_PMA_REG_8481_LED1_MASK, |
| 10266 | 0x0); |
| 10267 | } |
| 10268 | break; |
| 10269 | case LED_MODE_ON: |
| 10270 | |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 10271 | DP(NETIF_MSG_LINK, "Port 0x%x: LED MODE ON\n", port); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10272 | |
| 10273 | if ((params->hw_led_mode << SHARED_HW_CFG_LED_MODE_SHIFT) == |
| 10274 | SHARED_HW_CFG_LED_EXTPHY1) { |
| 10275 | /* Set control reg */ |
| 10276 | bnx2x_cl45_read(bp, phy, |
| 10277 | MDIO_PMA_DEVAD, |
| 10278 | MDIO_PMA_REG_8481_LINK_SIGNAL, |
| 10279 | &val); |
| 10280 | val &= 0x8000; |
| 10281 | val |= 0x2492; |
| 10282 | |
| 10283 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10284 | MDIO_PMA_DEVAD, |
| 10285 | MDIO_PMA_REG_8481_LINK_SIGNAL, |
| 10286 | val); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10287 | |
| 10288 | /* Set LED masks */ |
| 10289 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10290 | MDIO_PMA_DEVAD, |
| 10291 | MDIO_PMA_REG_8481_LED1_MASK, |
| 10292 | 0x0); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10293 | |
| 10294 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10295 | MDIO_PMA_DEVAD, |
| 10296 | MDIO_PMA_REG_8481_LED2_MASK, |
| 10297 | 0x20); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10298 | |
| 10299 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10300 | MDIO_PMA_DEVAD, |
| 10301 | MDIO_PMA_REG_8481_LED3_MASK, |
| 10302 | 0x20); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10303 | |
| 10304 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10305 | MDIO_PMA_DEVAD, |
| 10306 | MDIO_PMA_REG_8481_LED5_MASK, |
| 10307 | 0x0); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10308 | } else { |
| 10309 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10310 | MDIO_PMA_DEVAD, |
| 10311 | MDIO_PMA_REG_8481_LED1_MASK, |
| 10312 | 0x20); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10313 | } |
| 10314 | break; |
| 10315 | |
| 10316 | case LED_MODE_OPER: |
| 10317 | |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 10318 | DP(NETIF_MSG_LINK, "Port 0x%x: LED MODE OPER\n", port); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10319 | |
| 10320 | if ((params->hw_led_mode << SHARED_HW_CFG_LED_MODE_SHIFT) == |
| 10321 | SHARED_HW_CFG_LED_EXTPHY1) { |
| 10322 | |
| 10323 | /* Set control reg */ |
| 10324 | bnx2x_cl45_read(bp, phy, |
| 10325 | MDIO_PMA_DEVAD, |
| 10326 | MDIO_PMA_REG_8481_LINK_SIGNAL, |
| 10327 | &val); |
| 10328 | |
| 10329 | if (!((val & |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10330 | MDIO_PMA_REG_8481_LINK_SIGNAL_LED4_ENABLE_MASK) |
| 10331 | >> MDIO_PMA_REG_8481_LINK_SIGNAL_LED4_ENABLE_SHIFT)) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 10332 | DP(NETIF_MSG_LINK, "Setting LINK_SIGNAL\n"); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10333 | bnx2x_cl45_write(bp, phy, |
| 10334 | MDIO_PMA_DEVAD, |
| 10335 | MDIO_PMA_REG_8481_LINK_SIGNAL, |
| 10336 | 0xa492); |
| 10337 | } |
| 10338 | |
| 10339 | /* Set LED masks */ |
| 10340 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10341 | MDIO_PMA_DEVAD, |
| 10342 | MDIO_PMA_REG_8481_LED1_MASK, |
| 10343 | 0x10); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10344 | |
| 10345 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10346 | MDIO_PMA_DEVAD, |
| 10347 | MDIO_PMA_REG_8481_LED2_MASK, |
| 10348 | 0x80); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10349 | |
| 10350 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10351 | MDIO_PMA_DEVAD, |
| 10352 | MDIO_PMA_REG_8481_LED3_MASK, |
| 10353 | 0x98); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10354 | |
| 10355 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10356 | MDIO_PMA_DEVAD, |
| 10357 | MDIO_PMA_REG_8481_LED5_MASK, |
| 10358 | 0x40); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10359 | |
| 10360 | } else { |
| 10361 | bnx2x_cl45_write(bp, phy, |
| 10362 | MDIO_PMA_DEVAD, |
| 10363 | MDIO_PMA_REG_8481_LED1_MASK, |
| 10364 | 0x80); |
Yaniv Rosner | 53eda06 | 2011-01-30 04:14:55 +0000 | [diff] [blame] | 10365 | |
| 10366 | /* Tell LED3 to blink on source */ |
| 10367 | bnx2x_cl45_read(bp, phy, |
| 10368 | MDIO_PMA_DEVAD, |
| 10369 | MDIO_PMA_REG_8481_LINK_SIGNAL, |
| 10370 | &val); |
| 10371 | val &= ~(7<<6); |
| 10372 | val |= (1<<6); /* A83B[8:6]= 1 */ |
| 10373 | bnx2x_cl45_write(bp, phy, |
| 10374 | MDIO_PMA_DEVAD, |
| 10375 | MDIO_PMA_REG_8481_LINK_SIGNAL, |
| 10376 | val); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10377 | } |
| 10378 | break; |
| 10379 | } |
Yaniv Rosner | 0d40f0d | 2011-06-14 01:34:27 +0000 | [diff] [blame] | 10380 | |
| 10381 | /* |
| 10382 | * This is a workaround for E3+84833 until autoneg |
| 10383 | * restart is fixed in f/w |
| 10384 | */ |
| 10385 | if (CHIP_IS_E3(bp)) { |
| 10386 | bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, |
| 10387 | MDIO_WC_REG_GP2_STATUS_GP_2_1, &val); |
| 10388 | } |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10389 | } |
Yaniv Rosner | 0d40f0d | 2011-06-14 01:34:27 +0000 | [diff] [blame] | 10390 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10391 | /******************************************************************/ |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 10392 | /* 54618SE PHY SECTION */ |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 10393 | /******************************************************************/ |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 10394 | static int bnx2x_54618se_config_init(struct bnx2x_phy *phy, |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 10395 | struct link_params *params, |
| 10396 | struct link_vars *vars) |
| 10397 | { |
| 10398 | struct bnx2x *bp = params->bp; |
| 10399 | u8 port; |
| 10400 | u16 autoneg_val, an_1000_val, an_10_100_val, fc_val, temp; |
| 10401 | u32 cfg_pin; |
| 10402 | |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 10403 | DP(NETIF_MSG_LINK, "54618SE cfg init\n"); |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 10404 | usleep_range(1000, 1000); |
| 10405 | |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 10406 | /* |
| 10407 | * This works with E3 only, no need to check the chip |
| 10408 | * before determining the port. |
| 10409 | */ |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 10410 | port = params->port; |
| 10411 | |
| 10412 | cfg_pin = (REG_RD(bp, params->shmem_base + |
| 10413 | offsetof(struct shmem_region, |
| 10414 | dev_info.port_hw_config[port].e3_cmn_pin_cfg)) & |
| 10415 | PORT_HW_CFG_E3_PHY_RESET_MASK) >> |
| 10416 | PORT_HW_CFG_E3_PHY_RESET_SHIFT; |
| 10417 | |
| 10418 | /* Drive pin high to bring the GPHY out of reset. */ |
| 10419 | bnx2x_set_cfg_pin(bp, cfg_pin, 1); |
| 10420 | |
| 10421 | /* wait for GPHY to reset */ |
| 10422 | msleep(50); |
| 10423 | |
| 10424 | /* reset phy */ |
| 10425 | bnx2x_cl22_write(bp, phy, |
| 10426 | MDIO_PMA_REG_CTRL, 0x8000); |
| 10427 | bnx2x_wait_reset_complete(bp, phy, params); |
| 10428 | |
| 10429 | /*wait for GPHY to reset */ |
| 10430 | msleep(50); |
| 10431 | |
| 10432 | /* Configure LED4: set to INTR (0x6). */ |
| 10433 | /* Accessing shadow register 0xe. */ |
| 10434 | bnx2x_cl22_write(bp, phy, |
| 10435 | MDIO_REG_GPHY_SHADOW, |
| 10436 | MDIO_REG_GPHY_SHADOW_LED_SEL2); |
| 10437 | bnx2x_cl22_read(bp, phy, |
| 10438 | MDIO_REG_GPHY_SHADOW, |
| 10439 | &temp); |
| 10440 | temp &= ~(0xf << 4); |
| 10441 | temp |= (0x6 << 4); |
| 10442 | bnx2x_cl22_write(bp, phy, |
| 10443 | MDIO_REG_GPHY_SHADOW, |
| 10444 | MDIO_REG_GPHY_SHADOW_WR_ENA | temp); |
| 10445 | /* Configure INTR based on link status change. */ |
| 10446 | bnx2x_cl22_write(bp, phy, |
| 10447 | MDIO_REG_INTR_MASK, |
| 10448 | ~MDIO_REG_INTR_MASK_LINK_STATUS); |
| 10449 | |
| 10450 | /* Flip the signal detect polarity (set 0x1c.0x1e[8]). */ |
| 10451 | bnx2x_cl22_write(bp, phy, |
| 10452 | MDIO_REG_GPHY_SHADOW, |
| 10453 | MDIO_REG_GPHY_SHADOW_AUTO_DET_MED); |
| 10454 | bnx2x_cl22_read(bp, phy, |
| 10455 | MDIO_REG_GPHY_SHADOW, |
| 10456 | &temp); |
| 10457 | temp |= MDIO_REG_GPHY_SHADOW_INVERT_FIB_SD; |
| 10458 | bnx2x_cl22_write(bp, phy, |
| 10459 | MDIO_REG_GPHY_SHADOW, |
| 10460 | MDIO_REG_GPHY_SHADOW_WR_ENA | temp); |
| 10461 | |
| 10462 | /* Set up fc */ |
| 10463 | /* Please refer to Table 28B-3 of 802.3ab-1999 spec. */ |
| 10464 | bnx2x_calc_ieee_aneg_adv(phy, params, &vars->ieee_fc); |
| 10465 | fc_val = 0; |
| 10466 | if ((vars->ieee_fc & MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC) == |
| 10467 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC) |
| 10468 | fc_val |= MDIO_AN_REG_ADV_PAUSE_ASYMMETRIC; |
| 10469 | |
| 10470 | if ((vars->ieee_fc & MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) == |
| 10471 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) |
| 10472 | fc_val |= MDIO_AN_REG_ADV_PAUSE_PAUSE; |
| 10473 | |
| 10474 | /* read all advertisement */ |
| 10475 | bnx2x_cl22_read(bp, phy, |
| 10476 | 0x09, |
| 10477 | &an_1000_val); |
| 10478 | |
| 10479 | bnx2x_cl22_read(bp, phy, |
| 10480 | 0x04, |
| 10481 | &an_10_100_val); |
| 10482 | |
| 10483 | bnx2x_cl22_read(bp, phy, |
| 10484 | MDIO_PMA_REG_CTRL, |
| 10485 | &autoneg_val); |
| 10486 | |
| 10487 | /* Disable forced speed */ |
| 10488 | autoneg_val &= ~((1<<6) | (1<<8) | (1<<9) | (1<<12) | (1<<13)); |
| 10489 | an_10_100_val &= ~((1<<5) | (1<<6) | (1<<7) | (1<<8) | (1<<10) | |
| 10490 | (1<<11)); |
| 10491 | |
| 10492 | if (((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 10493 | (phy->speed_cap_mask & |
| 10494 | PORT_HW_CFG_SPEED_CAPABILITY_D0_1G)) || |
| 10495 | (phy->req_line_speed == SPEED_1000)) { |
| 10496 | an_1000_val |= (1<<8); |
| 10497 | autoneg_val |= (1<<9 | 1<<12); |
| 10498 | if (phy->req_duplex == DUPLEX_FULL) |
| 10499 | an_1000_val |= (1<<9); |
| 10500 | DP(NETIF_MSG_LINK, "Advertising 1G\n"); |
| 10501 | } else |
| 10502 | an_1000_val &= ~((1<<8) | (1<<9)); |
| 10503 | |
| 10504 | bnx2x_cl22_write(bp, phy, |
| 10505 | 0x09, |
| 10506 | an_1000_val); |
| 10507 | bnx2x_cl22_read(bp, phy, |
| 10508 | 0x09, |
| 10509 | &an_1000_val); |
| 10510 | |
| 10511 | /* set 100 speed advertisement */ |
| 10512 | if (((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 10513 | (phy->speed_cap_mask & |
| 10514 | (PORT_HW_CFG_SPEED_CAPABILITY_D0_100M_FULL | |
| 10515 | PORT_HW_CFG_SPEED_CAPABILITY_D0_100M_HALF)))) { |
| 10516 | an_10_100_val |= (1<<7); |
| 10517 | /* Enable autoneg and restart autoneg for legacy speeds */ |
| 10518 | autoneg_val |= (1<<9 | 1<<12); |
| 10519 | |
| 10520 | if (phy->req_duplex == DUPLEX_FULL) |
| 10521 | an_10_100_val |= (1<<8); |
| 10522 | DP(NETIF_MSG_LINK, "Advertising 100M\n"); |
| 10523 | } |
| 10524 | |
| 10525 | /* set 10 speed advertisement */ |
| 10526 | if (((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 10527 | (phy->speed_cap_mask & |
| 10528 | (PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_FULL | |
| 10529 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_HALF)))) { |
| 10530 | an_10_100_val |= (1<<5); |
| 10531 | autoneg_val |= (1<<9 | 1<<12); |
| 10532 | if (phy->req_duplex == DUPLEX_FULL) |
| 10533 | an_10_100_val |= (1<<6); |
| 10534 | DP(NETIF_MSG_LINK, "Advertising 10M\n"); |
| 10535 | } |
| 10536 | |
| 10537 | /* Only 10/100 are allowed to work in FORCE mode */ |
| 10538 | if (phy->req_line_speed == SPEED_100) { |
| 10539 | autoneg_val |= (1<<13); |
| 10540 | /* Enabled AUTO-MDIX when autoneg is disabled */ |
| 10541 | bnx2x_cl22_write(bp, phy, |
| 10542 | 0x18, |
| 10543 | (1<<15 | 1<<9 | 7<<0)); |
| 10544 | DP(NETIF_MSG_LINK, "Setting 100M force\n"); |
| 10545 | } |
| 10546 | if (phy->req_line_speed == SPEED_10) { |
| 10547 | /* Enabled AUTO-MDIX when autoneg is disabled */ |
| 10548 | bnx2x_cl22_write(bp, phy, |
| 10549 | 0x18, |
| 10550 | (1<<15 | 1<<9 | 7<<0)); |
| 10551 | DP(NETIF_MSG_LINK, "Setting 10M force\n"); |
| 10552 | } |
| 10553 | |
Yaniv Rosner | a89a1d4 | 2011-07-05 01:07:05 +0000 | [diff] [blame] | 10554 | /* Check if we should turn on Auto-GrEEEn */ |
| 10555 | bnx2x_cl22_read(bp, phy, MDIO_REG_GPHY_PHYID_LSB, &temp); |
| 10556 | if (temp == MDIO_REG_GPHY_ID_54618SE) { |
| 10557 | if (params->feature_config_flags & |
| 10558 | FEATURE_CONFIG_AUTOGREEEN_ENABLED) { |
| 10559 | temp = 6; |
| 10560 | DP(NETIF_MSG_LINK, "Enabling Auto-GrEEEn\n"); |
| 10561 | } else { |
| 10562 | temp = 0; |
| 10563 | DP(NETIF_MSG_LINK, "Disabling Auto-GrEEEn\n"); |
| 10564 | } |
| 10565 | bnx2x_cl22_write(bp, phy, |
| 10566 | MDIO_REG_GPHY_CL45_ADDR_REG, MDIO_AN_DEVAD); |
| 10567 | bnx2x_cl22_write(bp, phy, |
| 10568 | MDIO_REG_GPHY_CL45_DATA_REG, |
| 10569 | MDIO_REG_GPHY_EEE_ADV); |
| 10570 | bnx2x_cl22_write(bp, phy, |
| 10571 | MDIO_REG_GPHY_CL45_ADDR_REG, |
| 10572 | (0x1 << 14) | MDIO_AN_DEVAD); |
| 10573 | bnx2x_cl22_write(bp, phy, |
| 10574 | MDIO_REG_GPHY_CL45_DATA_REG, |
| 10575 | temp); |
| 10576 | } |
| 10577 | |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 10578 | bnx2x_cl22_write(bp, phy, |
| 10579 | 0x04, |
| 10580 | an_10_100_val | fc_val); |
| 10581 | |
| 10582 | if (phy->req_duplex == DUPLEX_FULL) |
| 10583 | autoneg_val |= (1<<8); |
| 10584 | |
| 10585 | bnx2x_cl22_write(bp, phy, |
| 10586 | MDIO_PMA_REG_CTRL, autoneg_val); |
| 10587 | |
| 10588 | return 0; |
| 10589 | } |
| 10590 | |
Yaniv Rosner | 1d125bd | 2011-11-23 03:54:08 +0000 | [diff] [blame] | 10591 | |
| 10592 | static void bnx2x_5461x_set_link_led(struct bnx2x_phy *phy, |
| 10593 | struct link_params *params, u8 mode) |
| 10594 | { |
| 10595 | struct bnx2x *bp = params->bp; |
| 10596 | u16 temp; |
| 10597 | |
| 10598 | bnx2x_cl22_write(bp, phy, |
| 10599 | MDIO_REG_GPHY_SHADOW, |
| 10600 | MDIO_REG_GPHY_SHADOW_LED_SEL1); |
| 10601 | bnx2x_cl22_read(bp, phy, |
| 10602 | MDIO_REG_GPHY_SHADOW, |
| 10603 | &temp); |
| 10604 | temp &= 0xff00; |
| 10605 | |
| 10606 | DP(NETIF_MSG_LINK, "54618x set link led (mode=%x)\n", mode); |
| 10607 | switch (mode) { |
| 10608 | case LED_MODE_FRONT_PANEL_OFF: |
| 10609 | case LED_MODE_OFF: |
| 10610 | temp |= 0x00ee; |
| 10611 | break; |
| 10612 | case LED_MODE_OPER: |
| 10613 | temp |= 0x0001; |
| 10614 | break; |
| 10615 | case LED_MODE_ON: |
| 10616 | temp |= 0x00ff; |
| 10617 | break; |
| 10618 | default: |
| 10619 | break; |
| 10620 | } |
| 10621 | bnx2x_cl22_write(bp, phy, |
| 10622 | MDIO_REG_GPHY_SHADOW, |
| 10623 | MDIO_REG_GPHY_SHADOW_WR_ENA | temp); |
| 10624 | return; |
| 10625 | } |
| 10626 | |
| 10627 | |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 10628 | static void bnx2x_54618se_link_reset(struct bnx2x_phy *phy, |
| 10629 | struct link_params *params) |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 10630 | { |
| 10631 | struct bnx2x *bp = params->bp; |
| 10632 | u32 cfg_pin; |
| 10633 | u8 port; |
| 10634 | |
Yaniv Rosner | d2059a0 | 2011-08-02 23:00:00 +0000 | [diff] [blame] | 10635 | /* |
| 10636 | * In case of no EPIO routed to reset the GPHY, put it |
| 10637 | * in low power mode. |
| 10638 | */ |
| 10639 | bnx2x_cl22_write(bp, phy, MDIO_PMA_REG_CTRL, 0x800); |
| 10640 | /* |
| 10641 | * This works with E3 only, no need to check the chip |
| 10642 | * before determining the port. |
| 10643 | */ |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 10644 | port = params->port; |
| 10645 | cfg_pin = (REG_RD(bp, params->shmem_base + |
| 10646 | offsetof(struct shmem_region, |
| 10647 | dev_info.port_hw_config[port].e3_cmn_pin_cfg)) & |
| 10648 | PORT_HW_CFG_E3_PHY_RESET_MASK) >> |
| 10649 | PORT_HW_CFG_E3_PHY_RESET_SHIFT; |
| 10650 | |
| 10651 | /* Drive pin low to put GPHY in reset. */ |
| 10652 | bnx2x_set_cfg_pin(bp, cfg_pin, 0); |
| 10653 | } |
| 10654 | |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 10655 | static u8 bnx2x_54618se_read_status(struct bnx2x_phy *phy, |
| 10656 | struct link_params *params, |
| 10657 | struct link_vars *vars) |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 10658 | { |
| 10659 | struct bnx2x *bp = params->bp; |
| 10660 | u16 val; |
| 10661 | u8 link_up = 0; |
| 10662 | u16 legacy_status, legacy_speed; |
| 10663 | |
| 10664 | /* Get speed operation status */ |
| 10665 | bnx2x_cl22_read(bp, phy, |
| 10666 | 0x19, |
| 10667 | &legacy_status); |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 10668 | DP(NETIF_MSG_LINK, "54618SE read_status: 0x%x\n", legacy_status); |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 10669 | |
| 10670 | /* Read status to clear the PHY interrupt. */ |
| 10671 | bnx2x_cl22_read(bp, phy, |
| 10672 | MDIO_REG_INTR_STATUS, |
| 10673 | &val); |
| 10674 | |
| 10675 | link_up = ((legacy_status & (1<<2)) == (1<<2)); |
| 10676 | |
| 10677 | if (link_up) { |
| 10678 | legacy_speed = (legacy_status & (7<<8)); |
| 10679 | if (legacy_speed == (7<<8)) { |
| 10680 | vars->line_speed = SPEED_1000; |
| 10681 | vars->duplex = DUPLEX_FULL; |
| 10682 | } else if (legacy_speed == (6<<8)) { |
| 10683 | vars->line_speed = SPEED_1000; |
| 10684 | vars->duplex = DUPLEX_HALF; |
| 10685 | } else if (legacy_speed == (5<<8)) { |
| 10686 | vars->line_speed = SPEED_100; |
| 10687 | vars->duplex = DUPLEX_FULL; |
| 10688 | } |
| 10689 | /* Omitting 100Base-T4 for now */ |
| 10690 | else if (legacy_speed == (3<<8)) { |
| 10691 | vars->line_speed = SPEED_100; |
| 10692 | vars->duplex = DUPLEX_HALF; |
| 10693 | } else if (legacy_speed == (2<<8)) { |
| 10694 | vars->line_speed = SPEED_10; |
| 10695 | vars->duplex = DUPLEX_FULL; |
| 10696 | } else if (legacy_speed == (1<<8)) { |
| 10697 | vars->line_speed = SPEED_10; |
| 10698 | vars->duplex = DUPLEX_HALF; |
| 10699 | } else /* Should not happen */ |
| 10700 | vars->line_speed = 0; |
| 10701 | |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 10702 | DP(NETIF_MSG_LINK, |
| 10703 | "Link is up in %dMbps, is_duplex_full= %d\n", |
| 10704 | vars->line_speed, |
| 10705 | (vars->duplex == DUPLEX_FULL)); |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 10706 | |
| 10707 | /* Check legacy speed AN resolution */ |
| 10708 | bnx2x_cl22_read(bp, phy, |
| 10709 | 0x01, |
| 10710 | &val); |
| 10711 | if (val & (1<<5)) |
| 10712 | vars->link_status |= |
| 10713 | LINK_STATUS_AUTO_NEGOTIATE_COMPLETE; |
| 10714 | bnx2x_cl22_read(bp, phy, |
| 10715 | 0x06, |
| 10716 | &val); |
| 10717 | if ((val & (1<<0)) == 0) |
| 10718 | vars->link_status |= |
| 10719 | LINK_STATUS_PARALLEL_DETECTION_USED; |
| 10720 | |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 10721 | DP(NETIF_MSG_LINK, "BCM54618SE: link speed is %d\n", |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 10722 | vars->line_speed); |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 10723 | |
| 10724 | /* Report whether EEE is resolved. */ |
| 10725 | bnx2x_cl22_read(bp, phy, MDIO_REG_GPHY_PHYID_LSB, &val); |
| 10726 | if (val == MDIO_REG_GPHY_ID_54618SE) { |
| 10727 | if (vars->link_status & |
| 10728 | LINK_STATUS_AUTO_NEGOTIATE_COMPLETE) |
| 10729 | val = 0; |
| 10730 | else { |
| 10731 | bnx2x_cl22_write(bp, phy, |
| 10732 | MDIO_REG_GPHY_CL45_ADDR_REG, |
| 10733 | MDIO_AN_DEVAD); |
| 10734 | bnx2x_cl22_write(bp, phy, |
| 10735 | MDIO_REG_GPHY_CL45_DATA_REG, |
| 10736 | MDIO_REG_GPHY_EEE_RESOLVED); |
| 10737 | bnx2x_cl22_write(bp, phy, |
| 10738 | MDIO_REG_GPHY_CL45_ADDR_REG, |
| 10739 | (0x1 << 14) | MDIO_AN_DEVAD); |
| 10740 | bnx2x_cl22_read(bp, phy, |
| 10741 | MDIO_REG_GPHY_CL45_DATA_REG, |
| 10742 | &val); |
| 10743 | } |
| 10744 | DP(NETIF_MSG_LINK, "EEE resolution: 0x%x\n", val); |
| 10745 | } |
| 10746 | |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 10747 | bnx2x_ext_phy_resolve_fc(phy, params, vars); |
Mintz Yuval | 9e7e839 | 2012-02-15 02:10:24 +0000 | [diff] [blame] | 10748 | |
| 10749 | if (vars->link_status & LINK_STATUS_AUTO_NEGOTIATE_COMPLETE) { |
| 10750 | /* report LP advertised speeds */ |
| 10751 | bnx2x_cl22_read(bp, phy, 0x5, &val); |
| 10752 | |
| 10753 | if (val & (1<<5)) |
| 10754 | vars->link_status |= |
| 10755 | LINK_STATUS_LINK_PARTNER_10THD_CAPABLE; |
| 10756 | if (val & (1<<6)) |
| 10757 | vars->link_status |= |
| 10758 | LINK_STATUS_LINK_PARTNER_10TFD_CAPABLE; |
| 10759 | if (val & (1<<7)) |
| 10760 | vars->link_status |= |
| 10761 | LINK_STATUS_LINK_PARTNER_100TXHD_CAPABLE; |
| 10762 | if (val & (1<<8)) |
| 10763 | vars->link_status |= |
| 10764 | LINK_STATUS_LINK_PARTNER_100TXFD_CAPABLE; |
| 10765 | if (val & (1<<9)) |
| 10766 | vars->link_status |= |
| 10767 | LINK_STATUS_LINK_PARTNER_100T4_CAPABLE; |
| 10768 | |
| 10769 | bnx2x_cl22_read(bp, phy, 0xa, &val); |
| 10770 | if (val & (1<<10)) |
| 10771 | vars->link_status |= |
| 10772 | LINK_STATUS_LINK_PARTNER_1000THD_CAPABLE; |
| 10773 | if (val & (1<<11)) |
| 10774 | vars->link_status |= |
| 10775 | LINK_STATUS_LINK_PARTNER_1000TFD_CAPABLE; |
| 10776 | } |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 10777 | } |
| 10778 | return link_up; |
| 10779 | } |
| 10780 | |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 10781 | static void bnx2x_54618se_config_loopback(struct bnx2x_phy *phy, |
| 10782 | struct link_params *params) |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 10783 | { |
| 10784 | struct bnx2x *bp = params->bp; |
| 10785 | u16 val; |
| 10786 | u32 umac_base = params->port ? GRCBASE_UMAC1 : GRCBASE_UMAC0; |
| 10787 | |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 10788 | DP(NETIF_MSG_LINK, "2PMA/PMD ext_phy_loopback: 54618se\n"); |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 10789 | |
| 10790 | /* Enable master/slave manual mmode and set to master */ |
| 10791 | /* mii write 9 [bits set 11 12] */ |
| 10792 | bnx2x_cl22_write(bp, phy, 0x09, 3<<11); |
| 10793 | |
| 10794 | /* forced 1G and disable autoneg */ |
| 10795 | /* set val [mii read 0] */ |
| 10796 | /* set val [expr $val & [bits clear 6 12 13]] */ |
| 10797 | /* set val [expr $val | [bits set 6 8]] */ |
| 10798 | /* mii write 0 $val */ |
| 10799 | bnx2x_cl22_read(bp, phy, 0x00, &val); |
| 10800 | val &= ~((1<<6) | (1<<12) | (1<<13)); |
| 10801 | val |= (1<<6) | (1<<8); |
| 10802 | bnx2x_cl22_write(bp, phy, 0x00, val); |
| 10803 | |
| 10804 | /* Set external loopback and Tx using 6dB coding */ |
| 10805 | /* mii write 0x18 7 */ |
| 10806 | /* set val [mii read 0x18] */ |
| 10807 | /* mii write 0x18 [expr $val | [bits set 10 15]] */ |
| 10808 | bnx2x_cl22_write(bp, phy, 0x18, 7); |
| 10809 | bnx2x_cl22_read(bp, phy, 0x18, &val); |
| 10810 | bnx2x_cl22_write(bp, phy, 0x18, val | (1<<10) | (1<<15)); |
| 10811 | |
| 10812 | /* This register opens the gate for the UMAC despite its name */ |
| 10813 | REG_WR(bp, NIG_REG_EGRESS_EMAC0_PORT + params->port*4, 1); |
| 10814 | |
| 10815 | /* |
| 10816 | * Maximum Frame Length (RW). Defines a 14-Bit maximum frame |
| 10817 | * length used by the MAC receive logic to check frames. |
| 10818 | */ |
| 10819 | REG_WR(bp, umac_base + UMAC_REG_MAXFR, 0x2710); |
| 10820 | } |
| 10821 | |
| 10822 | /******************************************************************/ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10823 | /* SFX7101 PHY SECTION */ |
| 10824 | /******************************************************************/ |
| 10825 | static void bnx2x_7101_config_loopback(struct bnx2x_phy *phy, |
| 10826 | struct link_params *params) |
| 10827 | { |
| 10828 | struct bnx2x *bp = params->bp; |
| 10829 | /* SFX7101_XGXS_TEST1 */ |
| 10830 | bnx2x_cl45_write(bp, phy, |
| 10831 | MDIO_XS_DEVAD, MDIO_XS_SFX7101_XGXS_TEST1, 0x100); |
| 10832 | } |
| 10833 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 10834 | static int bnx2x_7101_config_init(struct bnx2x_phy *phy, |
| 10835 | struct link_params *params, |
| 10836 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10837 | { |
| 10838 | u16 fw_ver1, fw_ver2, val; |
| 10839 | struct bnx2x *bp = params->bp; |
| 10840 | DP(NETIF_MSG_LINK, "Setting the SFX7101 LASI indication\n"); |
| 10841 | |
| 10842 | /* Restore normal power mode*/ |
| 10843 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10844 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, params->port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10845 | /* HW reset */ |
| 10846 | bnx2x_ext_phy_hw_reset(bp, params->port); |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 10847 | bnx2x_wait_reset_complete(bp, phy, params); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10848 | |
| 10849 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 10850 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_CTRL, 0x1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10851 | DP(NETIF_MSG_LINK, "Setting the SFX7101 LED to blink on traffic\n"); |
| 10852 | bnx2x_cl45_write(bp, phy, |
| 10853 | MDIO_PMA_DEVAD, MDIO_PMA_REG_7107_LED_CNTL, (1<<3)); |
| 10854 | |
| 10855 | bnx2x_ext_phy_set_pause(params, phy, vars); |
| 10856 | /* Restart autoneg */ |
| 10857 | bnx2x_cl45_read(bp, phy, |
| 10858 | MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, &val); |
| 10859 | val |= 0x200; |
| 10860 | bnx2x_cl45_write(bp, phy, |
| 10861 | MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, val); |
| 10862 | |
| 10863 | /* Save spirom version */ |
| 10864 | bnx2x_cl45_read(bp, phy, |
| 10865 | MDIO_PMA_DEVAD, MDIO_PMA_REG_7101_VER1, &fw_ver1); |
| 10866 | |
| 10867 | bnx2x_cl45_read(bp, phy, |
| 10868 | MDIO_PMA_DEVAD, MDIO_PMA_REG_7101_VER2, &fw_ver2); |
| 10869 | bnx2x_save_spirom_version(bp, params->port, |
| 10870 | (u32)(fw_ver1<<16 | fw_ver2), phy->ver_addr); |
| 10871 | return 0; |
| 10872 | } |
| 10873 | |
| 10874 | static u8 bnx2x_7101_read_status(struct bnx2x_phy *phy, |
| 10875 | struct link_params *params, |
| 10876 | struct link_vars *vars) |
| 10877 | { |
| 10878 | struct bnx2x *bp = params->bp; |
| 10879 | u8 link_up; |
| 10880 | u16 val1, val2; |
| 10881 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 10882 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_STAT, &val2); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10883 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | 60d2fe0 | 2011-06-14 01:34:38 +0000 | [diff] [blame] | 10884 | MDIO_PMA_DEVAD, MDIO_PMA_LASI_STAT, &val1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10885 | DP(NETIF_MSG_LINK, "10G-base-T LASI status 0x%x->0x%x\n", |
| 10886 | val2, val1); |
| 10887 | bnx2x_cl45_read(bp, phy, |
| 10888 | MDIO_PMA_DEVAD, MDIO_PMA_REG_STATUS, &val2); |
| 10889 | bnx2x_cl45_read(bp, phy, |
| 10890 | MDIO_PMA_DEVAD, MDIO_PMA_REG_STATUS, &val1); |
| 10891 | DP(NETIF_MSG_LINK, "10G-base-T PMA status 0x%x->0x%x\n", |
| 10892 | val2, val1); |
| 10893 | link_up = ((val1 & 4) == 4); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 10894 | /* if link is up print the AN outcome of the SFX7101 PHY */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10895 | if (link_up) { |
| 10896 | bnx2x_cl45_read(bp, phy, |
| 10897 | MDIO_AN_DEVAD, MDIO_AN_REG_MASTER_STATUS, |
| 10898 | &val2); |
| 10899 | vars->line_speed = SPEED_10000; |
Yaniv Rosner | 791f18c | 2011-01-18 04:33:42 +0000 | [diff] [blame] | 10900 | vars->duplex = DUPLEX_FULL; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10901 | DP(NETIF_MSG_LINK, "SFX7101 AN status 0x%x->Master=%x\n", |
| 10902 | val2, (val2 & (1<<14))); |
| 10903 | bnx2x_ext_phy_10G_an_resolve(bp, phy, vars); |
| 10904 | bnx2x_ext_phy_resolve_fc(phy, params, vars); |
Mintz Yuval | 9e7e839 | 2012-02-15 02:10:24 +0000 | [diff] [blame] | 10905 | |
| 10906 | /* read LP advertised speeds */ |
| 10907 | if (val2 & (1<<11)) |
| 10908 | vars->link_status |= |
| 10909 | LINK_STATUS_LINK_PARTNER_10GXFD_CAPABLE; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10910 | } |
| 10911 | return link_up; |
| 10912 | } |
| 10913 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 10914 | 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] | 10915 | { |
| 10916 | if (*len < 5) |
| 10917 | return -EINVAL; |
| 10918 | str[0] = (spirom_ver & 0xFF); |
| 10919 | str[1] = (spirom_ver & 0xFF00) >> 8; |
| 10920 | str[2] = (spirom_ver & 0xFF0000) >> 16; |
| 10921 | str[3] = (spirom_ver & 0xFF000000) >> 24; |
| 10922 | str[4] = '\0'; |
| 10923 | *len -= 5; |
| 10924 | return 0; |
| 10925 | } |
| 10926 | |
| 10927 | void bnx2x_sfx7101_sp_sw_reset(struct bnx2x *bp, struct bnx2x_phy *phy) |
| 10928 | { |
| 10929 | u16 val, cnt; |
| 10930 | |
| 10931 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10932 | MDIO_PMA_DEVAD, |
| 10933 | MDIO_PMA_REG_7101_RESET, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10934 | |
| 10935 | for (cnt = 0; cnt < 10; cnt++) { |
| 10936 | msleep(50); |
| 10937 | /* Writes a self-clearing reset */ |
| 10938 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10939 | MDIO_PMA_DEVAD, |
| 10940 | MDIO_PMA_REG_7101_RESET, |
| 10941 | (val | (1<<15))); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10942 | /* Wait for clear */ |
| 10943 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10944 | MDIO_PMA_DEVAD, |
| 10945 | MDIO_PMA_REG_7101_RESET, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10946 | |
| 10947 | if ((val & (1<<15)) == 0) |
| 10948 | break; |
| 10949 | } |
| 10950 | } |
| 10951 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10952 | static void bnx2x_7101_hw_reset(struct bnx2x_phy *phy, |
| 10953 | struct link_params *params) { |
| 10954 | /* Low power mode is controlled by GPIO 2 */ |
| 10955 | bnx2x_set_gpio(params->bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10956 | MISC_REGISTERS_GPIO_OUTPUT_LOW, params->port); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10957 | /* The PHY reset is controlled by GPIO 1 */ |
| 10958 | bnx2x_set_gpio(params->bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 10959 | MISC_REGISTERS_GPIO_OUTPUT_LOW, params->port); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10960 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 10961 | |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 10962 | static void bnx2x_7101_set_link_led(struct bnx2x_phy *phy, |
| 10963 | struct link_params *params, u8 mode) |
| 10964 | { |
| 10965 | u16 val = 0; |
| 10966 | struct bnx2x *bp = params->bp; |
| 10967 | switch (mode) { |
| 10968 | case LED_MODE_FRONT_PANEL_OFF: |
| 10969 | case LED_MODE_OFF: |
| 10970 | val = 2; |
| 10971 | break; |
| 10972 | case LED_MODE_ON: |
| 10973 | val = 1; |
| 10974 | break; |
| 10975 | case LED_MODE_OPER: |
| 10976 | val = 0; |
| 10977 | break; |
| 10978 | } |
| 10979 | bnx2x_cl45_write(bp, phy, |
| 10980 | MDIO_PMA_DEVAD, |
| 10981 | MDIO_PMA_REG_7107_LINK_LED_CNTL, |
| 10982 | val); |
| 10983 | } |
| 10984 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10985 | /******************************************************************/ |
| 10986 | /* STATIC PHY DECLARATION */ |
| 10987 | /******************************************************************/ |
| 10988 | |
| 10989 | static struct bnx2x_phy phy_null = { |
| 10990 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_NOT_CONN, |
| 10991 | .addr = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10992 | .def_md_devad = 0, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 10993 | .flags = FLAGS_INIT_XGXS_FIRST, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 10994 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 10995 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 10996 | .mdio_ctrl = 0, |
| 10997 | .supported = 0, |
| 10998 | .media_type = ETH_PHY_NOT_PRESENT, |
| 10999 | .ver_addr = 0, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11000 | .req_flow_ctrl = 0, |
| 11001 | .req_line_speed = 0, |
| 11002 | .speed_cap_mask = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11003 | .req_duplex = 0, |
| 11004 | .rsrv = 0, |
| 11005 | .config_init = (config_init_t)NULL, |
| 11006 | .read_status = (read_status_t)NULL, |
| 11007 | .link_reset = (link_reset_t)NULL, |
| 11008 | .config_loopback = (config_loopback_t)NULL, |
| 11009 | .format_fw_ver = (format_fw_ver_t)NULL, |
| 11010 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11011 | .set_link_led = (set_link_led_t)NULL, |
| 11012 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11013 | }; |
| 11014 | |
| 11015 | static struct bnx2x_phy phy_serdes = { |
| 11016 | .type = PORT_HW_CFG_SERDES_EXT_PHY_TYPE_DIRECT, |
| 11017 | .addr = 0xff, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11018 | .def_md_devad = 0, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 11019 | .flags = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11020 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11021 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11022 | .mdio_ctrl = 0, |
| 11023 | .supported = (SUPPORTED_10baseT_Half | |
| 11024 | SUPPORTED_10baseT_Full | |
| 11025 | SUPPORTED_100baseT_Half | |
| 11026 | SUPPORTED_100baseT_Full | |
| 11027 | SUPPORTED_1000baseT_Full | |
| 11028 | SUPPORTED_2500baseX_Full | |
| 11029 | SUPPORTED_TP | |
| 11030 | SUPPORTED_Autoneg | |
| 11031 | SUPPORTED_Pause | |
| 11032 | SUPPORTED_Asym_Pause), |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 11033 | .media_type = ETH_PHY_BASE_T, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11034 | .ver_addr = 0, |
| 11035 | .req_flow_ctrl = 0, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11036 | .req_line_speed = 0, |
| 11037 | .speed_cap_mask = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11038 | .req_duplex = 0, |
| 11039 | .rsrv = 0, |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 11040 | .config_init = (config_init_t)bnx2x_xgxs_config_init, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11041 | .read_status = (read_status_t)bnx2x_link_settings_status, |
| 11042 | .link_reset = (link_reset_t)bnx2x_int_link_reset, |
| 11043 | .config_loopback = (config_loopback_t)NULL, |
| 11044 | .format_fw_ver = (format_fw_ver_t)NULL, |
| 11045 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11046 | .set_link_led = (set_link_led_t)NULL, |
| 11047 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11048 | }; |
| 11049 | |
| 11050 | static struct bnx2x_phy phy_xgxs = { |
| 11051 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT, |
| 11052 | .addr = 0xff, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11053 | .def_md_devad = 0, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 11054 | .flags = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11055 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11056 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11057 | .mdio_ctrl = 0, |
| 11058 | .supported = (SUPPORTED_10baseT_Half | |
| 11059 | SUPPORTED_10baseT_Full | |
| 11060 | SUPPORTED_100baseT_Half | |
| 11061 | SUPPORTED_100baseT_Full | |
| 11062 | SUPPORTED_1000baseT_Full | |
| 11063 | SUPPORTED_2500baseX_Full | |
| 11064 | SUPPORTED_10000baseT_Full | |
| 11065 | SUPPORTED_FIBRE | |
| 11066 | SUPPORTED_Autoneg | |
| 11067 | SUPPORTED_Pause | |
| 11068 | SUPPORTED_Asym_Pause), |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 11069 | .media_type = ETH_PHY_CX4, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11070 | .ver_addr = 0, |
| 11071 | .req_flow_ctrl = 0, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11072 | .req_line_speed = 0, |
| 11073 | .speed_cap_mask = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11074 | .req_duplex = 0, |
| 11075 | .rsrv = 0, |
Yaniv Rosner | ec146a6 | 2011-05-31 21:29:27 +0000 | [diff] [blame] | 11076 | .config_init = (config_init_t)bnx2x_xgxs_config_init, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11077 | .read_status = (read_status_t)bnx2x_link_settings_status, |
| 11078 | .link_reset = (link_reset_t)bnx2x_int_link_reset, |
| 11079 | .config_loopback = (config_loopback_t)bnx2x_set_xgxs_loopback, |
| 11080 | .format_fw_ver = (format_fw_ver_t)NULL, |
| 11081 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11082 | .set_link_led = (set_link_led_t)NULL, |
| 11083 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11084 | }; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 11085 | static struct bnx2x_phy phy_warpcore = { |
| 11086 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT, |
| 11087 | .addr = 0xff, |
| 11088 | .def_md_devad = 0, |
David S. Miller | 8decf86 | 2011-09-22 03:23:13 -0400 | [diff] [blame] | 11089 | .flags = FLAGS_HW_LOCK_REQUIRED, |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 11090 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11091 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11092 | .mdio_ctrl = 0, |
| 11093 | .supported = (SUPPORTED_10baseT_Half | |
| 11094 | SUPPORTED_10baseT_Full | |
| 11095 | SUPPORTED_100baseT_Half | |
| 11096 | SUPPORTED_100baseT_Full | |
| 11097 | SUPPORTED_1000baseT_Full | |
| 11098 | SUPPORTED_10000baseT_Full | |
| 11099 | SUPPORTED_20000baseKR2_Full | |
| 11100 | SUPPORTED_20000baseMLD2_Full | |
| 11101 | SUPPORTED_FIBRE | |
| 11102 | SUPPORTED_Autoneg | |
| 11103 | SUPPORTED_Pause | |
| 11104 | SUPPORTED_Asym_Pause), |
| 11105 | .media_type = ETH_PHY_UNSPECIFIED, |
| 11106 | .ver_addr = 0, |
| 11107 | .req_flow_ctrl = 0, |
| 11108 | .req_line_speed = 0, |
| 11109 | .speed_cap_mask = 0, |
| 11110 | /* req_duplex = */0, |
| 11111 | /* rsrv = */0, |
| 11112 | .config_init = (config_init_t)bnx2x_warpcore_config_init, |
| 11113 | .read_status = (read_status_t)bnx2x_warpcore_read_status, |
| 11114 | .link_reset = (link_reset_t)bnx2x_warpcore_link_reset, |
| 11115 | .config_loopback = (config_loopback_t)bnx2x_set_warpcore_loopback, |
| 11116 | .format_fw_ver = (format_fw_ver_t)NULL, |
Yaniv Rosner | 985848f | 2011-07-05 01:06:48 +0000 | [diff] [blame] | 11117 | .hw_reset = (hw_reset_t)bnx2x_warpcore_hw_reset, |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 11118 | .set_link_led = (set_link_led_t)NULL, |
| 11119 | .phy_specific_func = (phy_specific_func_t)NULL |
| 11120 | }; |
| 11121 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11122 | |
| 11123 | static struct bnx2x_phy phy_7101 = { |
| 11124 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_SFX7101, |
| 11125 | .addr = 0xff, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11126 | .def_md_devad = 0, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 11127 | .flags = FLAGS_FAN_FAILURE_DET_REQ, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11128 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11129 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11130 | .mdio_ctrl = 0, |
| 11131 | .supported = (SUPPORTED_10000baseT_Full | |
| 11132 | SUPPORTED_TP | |
| 11133 | SUPPORTED_Autoneg | |
| 11134 | SUPPORTED_Pause | |
| 11135 | SUPPORTED_Asym_Pause), |
| 11136 | .media_type = ETH_PHY_BASE_T, |
| 11137 | .ver_addr = 0, |
| 11138 | .req_flow_ctrl = 0, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11139 | .req_line_speed = 0, |
| 11140 | .speed_cap_mask = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11141 | .req_duplex = 0, |
| 11142 | .rsrv = 0, |
| 11143 | .config_init = (config_init_t)bnx2x_7101_config_init, |
| 11144 | .read_status = (read_status_t)bnx2x_7101_read_status, |
| 11145 | .link_reset = (link_reset_t)bnx2x_common_ext_link_reset, |
| 11146 | .config_loopback = (config_loopback_t)bnx2x_7101_config_loopback, |
| 11147 | .format_fw_ver = (format_fw_ver_t)bnx2x_7101_format_ver, |
| 11148 | .hw_reset = (hw_reset_t)bnx2x_7101_hw_reset, |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 11149 | .set_link_led = (set_link_led_t)bnx2x_7101_set_link_led, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11150 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11151 | }; |
| 11152 | static struct bnx2x_phy phy_8073 = { |
| 11153 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073, |
| 11154 | .addr = 0xff, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11155 | .def_md_devad = 0, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 11156 | .flags = FLAGS_HW_LOCK_REQUIRED, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11157 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11158 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11159 | .mdio_ctrl = 0, |
| 11160 | .supported = (SUPPORTED_10000baseT_Full | |
| 11161 | SUPPORTED_2500baseX_Full | |
| 11162 | SUPPORTED_1000baseT_Full | |
| 11163 | SUPPORTED_FIBRE | |
| 11164 | SUPPORTED_Autoneg | |
| 11165 | SUPPORTED_Pause | |
| 11166 | SUPPORTED_Asym_Pause), |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 11167 | .media_type = ETH_PHY_KR, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11168 | .ver_addr = 0, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11169 | .req_flow_ctrl = 0, |
| 11170 | .req_line_speed = 0, |
| 11171 | .speed_cap_mask = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11172 | .req_duplex = 0, |
| 11173 | .rsrv = 0, |
Yaniv Rosner | 62b29a5 | 2010-09-07 11:40:58 +0000 | [diff] [blame] | 11174 | .config_init = (config_init_t)bnx2x_8073_config_init, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11175 | .read_status = (read_status_t)bnx2x_8073_read_status, |
| 11176 | .link_reset = (link_reset_t)bnx2x_8073_link_reset, |
| 11177 | .config_loopback = (config_loopback_t)NULL, |
| 11178 | .format_fw_ver = (format_fw_ver_t)bnx2x_format_ver, |
| 11179 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11180 | .set_link_led = (set_link_led_t)NULL, |
| 11181 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11182 | }; |
| 11183 | static struct bnx2x_phy phy_8705 = { |
| 11184 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8705, |
| 11185 | .addr = 0xff, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11186 | .def_md_devad = 0, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 11187 | .flags = FLAGS_INIT_XGXS_FIRST, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11188 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11189 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11190 | .mdio_ctrl = 0, |
| 11191 | .supported = (SUPPORTED_10000baseT_Full | |
| 11192 | SUPPORTED_FIBRE | |
| 11193 | SUPPORTED_Pause | |
| 11194 | SUPPORTED_Asym_Pause), |
| 11195 | .media_type = ETH_PHY_XFP_FIBER, |
| 11196 | .ver_addr = 0, |
| 11197 | .req_flow_ctrl = 0, |
| 11198 | .req_line_speed = 0, |
| 11199 | .speed_cap_mask = 0, |
| 11200 | .req_duplex = 0, |
| 11201 | .rsrv = 0, |
| 11202 | .config_init = (config_init_t)bnx2x_8705_config_init, |
| 11203 | .read_status = (read_status_t)bnx2x_8705_read_status, |
| 11204 | .link_reset = (link_reset_t)bnx2x_common_ext_link_reset, |
| 11205 | .config_loopback = (config_loopback_t)NULL, |
| 11206 | .format_fw_ver = (format_fw_ver_t)bnx2x_null_format_ver, |
| 11207 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11208 | .set_link_led = (set_link_led_t)NULL, |
| 11209 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11210 | }; |
| 11211 | static struct bnx2x_phy phy_8706 = { |
| 11212 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8706, |
| 11213 | .addr = 0xff, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11214 | .def_md_devad = 0, |
David S. Miller | 8decf86 | 2011-09-22 03:23:13 -0400 | [diff] [blame] | 11215 | .flags = FLAGS_INIT_XGXS_FIRST, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11216 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11217 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11218 | .mdio_ctrl = 0, |
| 11219 | .supported = (SUPPORTED_10000baseT_Full | |
| 11220 | SUPPORTED_1000baseT_Full | |
| 11221 | SUPPORTED_FIBRE | |
| 11222 | SUPPORTED_Pause | |
| 11223 | SUPPORTED_Asym_Pause), |
| 11224 | .media_type = ETH_PHY_SFP_FIBER, |
| 11225 | .ver_addr = 0, |
| 11226 | .req_flow_ctrl = 0, |
| 11227 | .req_line_speed = 0, |
| 11228 | .speed_cap_mask = 0, |
| 11229 | .req_duplex = 0, |
| 11230 | .rsrv = 0, |
| 11231 | .config_init = (config_init_t)bnx2x_8706_config_init, |
| 11232 | .read_status = (read_status_t)bnx2x_8706_read_status, |
| 11233 | .link_reset = (link_reset_t)bnx2x_common_ext_link_reset, |
| 11234 | .config_loopback = (config_loopback_t)NULL, |
| 11235 | .format_fw_ver = (format_fw_ver_t)bnx2x_format_ver, |
| 11236 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11237 | .set_link_led = (set_link_led_t)NULL, |
| 11238 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11239 | }; |
| 11240 | |
| 11241 | static struct bnx2x_phy phy_8726 = { |
| 11242 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726, |
| 11243 | .addr = 0xff, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 11244 | .def_md_devad = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11245 | .flags = (FLAGS_HW_LOCK_REQUIRED | |
David S. Miller | 8decf86 | 2011-09-22 03:23:13 -0400 | [diff] [blame] | 11246 | FLAGS_INIT_XGXS_FIRST), |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11247 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11248 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11249 | .mdio_ctrl = 0, |
| 11250 | .supported = (SUPPORTED_10000baseT_Full | |
| 11251 | SUPPORTED_1000baseT_Full | |
| 11252 | SUPPORTED_Autoneg | |
| 11253 | SUPPORTED_FIBRE | |
| 11254 | SUPPORTED_Pause | |
| 11255 | SUPPORTED_Asym_Pause), |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 11256 | .media_type = ETH_PHY_NOT_PRESENT, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11257 | .ver_addr = 0, |
| 11258 | .req_flow_ctrl = 0, |
| 11259 | .req_line_speed = 0, |
| 11260 | .speed_cap_mask = 0, |
| 11261 | .req_duplex = 0, |
| 11262 | .rsrv = 0, |
| 11263 | .config_init = (config_init_t)bnx2x_8726_config_init, |
| 11264 | .read_status = (read_status_t)bnx2x_8726_read_status, |
| 11265 | .link_reset = (link_reset_t)bnx2x_8726_link_reset, |
| 11266 | .config_loopback = (config_loopback_t)bnx2x_8726_config_loopback, |
| 11267 | .format_fw_ver = (format_fw_ver_t)bnx2x_format_ver, |
| 11268 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11269 | .set_link_led = (set_link_led_t)NULL, |
| 11270 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11271 | }; |
| 11272 | |
| 11273 | static struct bnx2x_phy phy_8727 = { |
| 11274 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727, |
| 11275 | .addr = 0xff, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11276 | .def_md_devad = 0, |
David S. Miller | 8decf86 | 2011-09-22 03:23:13 -0400 | [diff] [blame] | 11277 | .flags = FLAGS_FAN_FAILURE_DET_REQ, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11278 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11279 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11280 | .mdio_ctrl = 0, |
| 11281 | .supported = (SUPPORTED_10000baseT_Full | |
| 11282 | SUPPORTED_1000baseT_Full | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11283 | SUPPORTED_FIBRE | |
| 11284 | SUPPORTED_Pause | |
| 11285 | SUPPORTED_Asym_Pause), |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 11286 | .media_type = ETH_PHY_NOT_PRESENT, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11287 | .ver_addr = 0, |
| 11288 | .req_flow_ctrl = 0, |
| 11289 | .req_line_speed = 0, |
| 11290 | .speed_cap_mask = 0, |
| 11291 | .req_duplex = 0, |
| 11292 | .rsrv = 0, |
| 11293 | .config_init = (config_init_t)bnx2x_8727_config_init, |
| 11294 | .read_status = (read_status_t)bnx2x_8727_read_status, |
| 11295 | .link_reset = (link_reset_t)bnx2x_8727_link_reset, |
| 11296 | .config_loopback = (config_loopback_t)NULL, |
| 11297 | .format_fw_ver = (format_fw_ver_t)bnx2x_format_ver, |
| 11298 | .hw_reset = (hw_reset_t)bnx2x_8727_hw_reset, |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 11299 | .set_link_led = (set_link_led_t)bnx2x_8727_set_link_led, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11300 | .phy_specific_func = (phy_specific_func_t)bnx2x_8727_specific_func |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11301 | }; |
| 11302 | static struct bnx2x_phy phy_8481 = { |
| 11303 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8481, |
| 11304 | .addr = 0xff, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 11305 | .def_md_devad = 0, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11306 | .flags = FLAGS_FAN_FAILURE_DET_REQ | |
| 11307 | FLAGS_REARM_LATCH_SIGNAL, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11308 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11309 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11310 | .mdio_ctrl = 0, |
| 11311 | .supported = (SUPPORTED_10baseT_Half | |
| 11312 | SUPPORTED_10baseT_Full | |
| 11313 | SUPPORTED_100baseT_Half | |
| 11314 | SUPPORTED_100baseT_Full | |
| 11315 | SUPPORTED_1000baseT_Full | |
| 11316 | SUPPORTED_10000baseT_Full | |
| 11317 | SUPPORTED_TP | |
| 11318 | SUPPORTED_Autoneg | |
| 11319 | SUPPORTED_Pause | |
| 11320 | SUPPORTED_Asym_Pause), |
| 11321 | .media_type = ETH_PHY_BASE_T, |
| 11322 | .ver_addr = 0, |
| 11323 | .req_flow_ctrl = 0, |
| 11324 | .req_line_speed = 0, |
| 11325 | .speed_cap_mask = 0, |
| 11326 | .req_duplex = 0, |
| 11327 | .rsrv = 0, |
| 11328 | .config_init = (config_init_t)bnx2x_8481_config_init, |
| 11329 | .read_status = (read_status_t)bnx2x_848xx_read_status, |
| 11330 | .link_reset = (link_reset_t)bnx2x_8481_link_reset, |
| 11331 | .config_loopback = (config_loopback_t)NULL, |
| 11332 | .format_fw_ver = (format_fw_ver_t)bnx2x_848xx_format_ver, |
| 11333 | .hw_reset = (hw_reset_t)bnx2x_8481_hw_reset, |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 11334 | .set_link_led = (set_link_led_t)bnx2x_848xx_set_link_led, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11335 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11336 | }; |
| 11337 | |
| 11338 | static struct bnx2x_phy phy_84823 = { |
| 11339 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84823, |
| 11340 | .addr = 0xff, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 11341 | .def_md_devad = 0, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11342 | .flags = FLAGS_FAN_FAILURE_DET_REQ | |
| 11343 | FLAGS_REARM_LATCH_SIGNAL, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11344 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11345 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11346 | .mdio_ctrl = 0, |
| 11347 | .supported = (SUPPORTED_10baseT_Half | |
| 11348 | SUPPORTED_10baseT_Full | |
| 11349 | SUPPORTED_100baseT_Half | |
| 11350 | SUPPORTED_100baseT_Full | |
| 11351 | SUPPORTED_1000baseT_Full | |
| 11352 | SUPPORTED_10000baseT_Full | |
| 11353 | SUPPORTED_TP | |
| 11354 | SUPPORTED_Autoneg | |
| 11355 | SUPPORTED_Pause | |
| 11356 | SUPPORTED_Asym_Pause), |
| 11357 | .media_type = ETH_PHY_BASE_T, |
| 11358 | .ver_addr = 0, |
| 11359 | .req_flow_ctrl = 0, |
| 11360 | .req_line_speed = 0, |
| 11361 | .speed_cap_mask = 0, |
| 11362 | .req_duplex = 0, |
| 11363 | .rsrv = 0, |
| 11364 | .config_init = (config_init_t)bnx2x_848x3_config_init, |
| 11365 | .read_status = (read_status_t)bnx2x_848xx_read_status, |
| 11366 | .link_reset = (link_reset_t)bnx2x_848x3_link_reset, |
| 11367 | .config_loopback = (config_loopback_t)NULL, |
| 11368 | .format_fw_ver = (format_fw_ver_t)bnx2x_848xx_format_ver, |
| 11369 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 11370 | .set_link_led = (set_link_led_t)bnx2x_848xx_set_link_led, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11371 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11372 | }; |
| 11373 | |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 11374 | static struct bnx2x_phy phy_84833 = { |
| 11375 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833, |
| 11376 | .addr = 0xff, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 11377 | .def_md_devad = 0, |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 11378 | .flags = FLAGS_FAN_FAILURE_DET_REQ | |
| 11379 | FLAGS_REARM_LATCH_SIGNAL, |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 11380 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11381 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11382 | .mdio_ctrl = 0, |
Yaniv Rosner | 0520e63 | 2011-07-05 01:06:59 +0000 | [diff] [blame] | 11383 | .supported = (SUPPORTED_100baseT_Half | |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 11384 | SUPPORTED_100baseT_Full | |
| 11385 | SUPPORTED_1000baseT_Full | |
| 11386 | SUPPORTED_10000baseT_Full | |
| 11387 | SUPPORTED_TP | |
| 11388 | SUPPORTED_Autoneg | |
| 11389 | SUPPORTED_Pause | |
| 11390 | SUPPORTED_Asym_Pause), |
| 11391 | .media_type = ETH_PHY_BASE_T, |
| 11392 | .ver_addr = 0, |
| 11393 | .req_flow_ctrl = 0, |
| 11394 | .req_line_speed = 0, |
| 11395 | .speed_cap_mask = 0, |
| 11396 | .req_duplex = 0, |
| 11397 | .rsrv = 0, |
| 11398 | .config_init = (config_init_t)bnx2x_848x3_config_init, |
| 11399 | .read_status = (read_status_t)bnx2x_848xx_read_status, |
| 11400 | .link_reset = (link_reset_t)bnx2x_848x3_link_reset, |
| 11401 | .config_loopback = (config_loopback_t)NULL, |
| 11402 | .format_fw_ver = (format_fw_ver_t)bnx2x_848xx_format_ver, |
Yaniv Rosner | 985848f | 2011-07-05 01:06:48 +0000 | [diff] [blame] | 11403 | .hw_reset = (hw_reset_t)bnx2x_84833_hw_reset_phy, |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 11404 | .set_link_led = (set_link_led_t)bnx2x_848xx_set_link_led, |
| 11405 | .phy_specific_func = (phy_specific_func_t)NULL |
| 11406 | }; |
| 11407 | |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 11408 | static struct bnx2x_phy phy_54618se = { |
| 11409 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54618SE, |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 11410 | .addr = 0xff, |
| 11411 | .def_md_devad = 0, |
| 11412 | .flags = FLAGS_INIT_XGXS_FIRST, |
| 11413 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11414 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 11415 | .mdio_ctrl = 0, |
| 11416 | .supported = (SUPPORTED_10baseT_Half | |
| 11417 | SUPPORTED_10baseT_Full | |
| 11418 | SUPPORTED_100baseT_Half | |
| 11419 | SUPPORTED_100baseT_Full | |
| 11420 | SUPPORTED_1000baseT_Full | |
| 11421 | SUPPORTED_TP | |
| 11422 | SUPPORTED_Autoneg | |
| 11423 | SUPPORTED_Pause | |
| 11424 | SUPPORTED_Asym_Pause), |
| 11425 | .media_type = ETH_PHY_BASE_T, |
| 11426 | .ver_addr = 0, |
| 11427 | .req_flow_ctrl = 0, |
| 11428 | .req_line_speed = 0, |
| 11429 | .speed_cap_mask = 0, |
| 11430 | /* req_duplex = */0, |
| 11431 | /* rsrv = */0, |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 11432 | .config_init = (config_init_t)bnx2x_54618se_config_init, |
| 11433 | .read_status = (read_status_t)bnx2x_54618se_read_status, |
| 11434 | .link_reset = (link_reset_t)bnx2x_54618se_link_reset, |
| 11435 | .config_loopback = (config_loopback_t)bnx2x_54618se_config_loopback, |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 11436 | .format_fw_ver = (format_fw_ver_t)NULL, |
| 11437 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | 1d125bd | 2011-11-23 03:54:08 +0000 | [diff] [blame] | 11438 | .set_link_led = (set_link_led_t)bnx2x_5461x_set_link_led, |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 11439 | .phy_specific_func = (phy_specific_func_t)NULL |
| 11440 | }; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11441 | /*****************************************************************/ |
| 11442 | /* */ |
| 11443 | /* Populate the phy according. Main function: bnx2x_populate_phy */ |
| 11444 | /* */ |
| 11445 | /*****************************************************************/ |
| 11446 | |
| 11447 | static void bnx2x_populate_preemphasis(struct bnx2x *bp, u32 shmem_base, |
| 11448 | struct bnx2x_phy *phy, u8 port, |
| 11449 | u8 phy_index) |
| 11450 | { |
| 11451 | /* Get the 4 lanes xgxs config rx and tx */ |
| 11452 | u32 rx = 0, tx = 0, i; |
| 11453 | for (i = 0; i < 2; i++) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 11454 | /* |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11455 | * INT_PHY and EXT_PHY1 share the same value location in the |
| 11456 | * shmem. When num_phys is greater than 1, than this value |
| 11457 | * applies only to EXT_PHY1 |
| 11458 | */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11459 | if (phy_index == INT_PHY || phy_index == EXT_PHY1) { |
| 11460 | rx = REG_RD(bp, shmem_base + |
| 11461 | offsetof(struct shmem_region, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11462 | dev_info.port_hw_config[port].xgxs_config_rx[i<<1])); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11463 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11464 | tx = REG_RD(bp, shmem_base + |
| 11465 | offsetof(struct shmem_region, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11466 | dev_info.port_hw_config[port].xgxs_config_tx[i<<1])); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11467 | } else { |
| 11468 | rx = REG_RD(bp, shmem_base + |
| 11469 | offsetof(struct shmem_region, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11470 | dev_info.port_hw_config[port].xgxs_config2_rx[i<<1])); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11471 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11472 | tx = REG_RD(bp, shmem_base + |
| 11473 | offsetof(struct shmem_region, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11474 | dev_info.port_hw_config[port].xgxs_config2_rx[i<<1])); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11475 | } |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11476 | |
| 11477 | phy->rx_preemphasis[i << 1] = ((rx>>16) & 0xffff); |
| 11478 | phy->rx_preemphasis[(i << 1) + 1] = (rx & 0xffff); |
| 11479 | |
| 11480 | phy->tx_preemphasis[i << 1] = ((tx>>16) & 0xffff); |
| 11481 | phy->tx_preemphasis[(i << 1) + 1] = (tx & 0xffff); |
| 11482 | } |
| 11483 | } |
| 11484 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 11485 | static u32 bnx2x_get_ext_phy_config(struct bnx2x *bp, u32 shmem_base, |
| 11486 | u8 phy_index, u8 port) |
| 11487 | { |
| 11488 | u32 ext_phy_config = 0; |
| 11489 | switch (phy_index) { |
| 11490 | case EXT_PHY1: |
| 11491 | ext_phy_config = REG_RD(bp, shmem_base + |
| 11492 | offsetof(struct shmem_region, |
| 11493 | dev_info.port_hw_config[port].external_phy_config)); |
| 11494 | break; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11495 | case EXT_PHY2: |
| 11496 | ext_phy_config = REG_RD(bp, shmem_base + |
| 11497 | offsetof(struct shmem_region, |
| 11498 | dev_info.port_hw_config[port].external_phy_config2)); |
| 11499 | break; |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 11500 | default: |
| 11501 | DP(NETIF_MSG_LINK, "Invalid phy_index %d\n", phy_index); |
| 11502 | return -EINVAL; |
| 11503 | } |
| 11504 | |
| 11505 | return ext_phy_config; |
| 11506 | } |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 11507 | static int bnx2x_populate_int_phy(struct bnx2x *bp, u32 shmem_base, u8 port, |
| 11508 | struct bnx2x_phy *phy) |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11509 | { |
| 11510 | u32 phy_addr; |
| 11511 | u32 chip_id; |
| 11512 | u32 switch_cfg = (REG_RD(bp, shmem_base + |
| 11513 | offsetof(struct shmem_region, |
| 11514 | dev_info.port_feature_config[port].link_config)) & |
| 11515 | PORT_FEATURE_CONNECTED_SWITCH_MASK); |
Yaniv Rosner | ec15b89 | 2011-11-28 00:49:49 +0000 | [diff] [blame] | 11516 | chip_id = (REG_RD(bp, MISC_REG_CHIP_NUM) << 16) | |
| 11517 | ((REG_RD(bp, MISC_REG_CHIP_REV) & 0xf) << 12); |
| 11518 | |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 11519 | DP(NETIF_MSG_LINK, ":chip_id = 0x%x\n", chip_id); |
| 11520 | if (USES_WARPCORE(bp)) { |
| 11521 | u32 serdes_net_if; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11522 | phy_addr = REG_RD(bp, |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 11523 | MISC_REG_WC0_CTRL_PHY_ADDR); |
| 11524 | *phy = phy_warpcore; |
| 11525 | if (REG_RD(bp, MISC_REG_PORT4MODE_EN_OVWR) == 0x3) |
| 11526 | phy->flags |= FLAGS_4_PORT_MODE; |
| 11527 | else |
| 11528 | phy->flags &= ~FLAGS_4_PORT_MODE; |
| 11529 | /* Check Dual mode */ |
| 11530 | serdes_net_if = (REG_RD(bp, shmem_base + |
| 11531 | offsetof(struct shmem_region, dev_info. |
| 11532 | port_hw_config[port].default_cfg)) & |
| 11533 | PORT_HW_CFG_NET_SERDES_IF_MASK); |
| 11534 | /* |
| 11535 | * Set the appropriate supported and flags indications per |
| 11536 | * interface type of the chip |
| 11537 | */ |
| 11538 | switch (serdes_net_if) { |
| 11539 | case PORT_HW_CFG_NET_SERDES_IF_SGMII: |
| 11540 | phy->supported &= (SUPPORTED_10baseT_Half | |
| 11541 | SUPPORTED_10baseT_Full | |
| 11542 | SUPPORTED_100baseT_Half | |
| 11543 | SUPPORTED_100baseT_Full | |
| 11544 | SUPPORTED_1000baseT_Full | |
| 11545 | SUPPORTED_FIBRE | |
| 11546 | SUPPORTED_Autoneg | |
| 11547 | SUPPORTED_Pause | |
| 11548 | SUPPORTED_Asym_Pause); |
| 11549 | phy->media_type = ETH_PHY_BASE_T; |
| 11550 | break; |
| 11551 | case PORT_HW_CFG_NET_SERDES_IF_XFI: |
| 11552 | phy->media_type = ETH_PHY_XFP_FIBER; |
| 11553 | break; |
| 11554 | case PORT_HW_CFG_NET_SERDES_IF_SFI: |
| 11555 | phy->supported &= (SUPPORTED_1000baseT_Full | |
| 11556 | SUPPORTED_10000baseT_Full | |
| 11557 | SUPPORTED_FIBRE | |
| 11558 | SUPPORTED_Pause | |
| 11559 | SUPPORTED_Asym_Pause); |
| 11560 | phy->media_type = ETH_PHY_SFP_FIBER; |
| 11561 | break; |
| 11562 | case PORT_HW_CFG_NET_SERDES_IF_KR: |
| 11563 | phy->media_type = ETH_PHY_KR; |
| 11564 | phy->supported &= (SUPPORTED_1000baseT_Full | |
| 11565 | SUPPORTED_10000baseT_Full | |
| 11566 | SUPPORTED_FIBRE | |
| 11567 | SUPPORTED_Autoneg | |
| 11568 | SUPPORTED_Pause | |
| 11569 | SUPPORTED_Asym_Pause); |
| 11570 | break; |
| 11571 | case PORT_HW_CFG_NET_SERDES_IF_DXGXS: |
| 11572 | phy->media_type = ETH_PHY_KR; |
| 11573 | phy->flags |= FLAGS_WC_DUAL_MODE; |
| 11574 | phy->supported &= (SUPPORTED_20000baseMLD2_Full | |
| 11575 | SUPPORTED_FIBRE | |
| 11576 | SUPPORTED_Pause | |
| 11577 | SUPPORTED_Asym_Pause); |
| 11578 | break; |
| 11579 | case PORT_HW_CFG_NET_SERDES_IF_KR2: |
| 11580 | phy->media_type = ETH_PHY_KR; |
| 11581 | phy->flags |= FLAGS_WC_DUAL_MODE; |
| 11582 | phy->supported &= (SUPPORTED_20000baseKR2_Full | |
| 11583 | SUPPORTED_FIBRE | |
| 11584 | SUPPORTED_Pause | |
| 11585 | SUPPORTED_Asym_Pause); |
| 11586 | break; |
| 11587 | default: |
| 11588 | DP(NETIF_MSG_LINK, "Unknown WC interface type 0x%x\n", |
| 11589 | serdes_net_if); |
| 11590 | break; |
| 11591 | } |
| 11592 | |
| 11593 | /* |
| 11594 | * Enable MDC/MDIO work-around for E3 A0 since free running MDC |
| 11595 | * was not set as expected. For B0, ECO will be enabled so there |
| 11596 | * won't be an issue there |
| 11597 | */ |
| 11598 | if (CHIP_REV(bp) == CHIP_REV_Ax) |
| 11599 | phy->flags |= FLAGS_MDC_MDIO_WA; |
Yaniv Rosner | 157fa28 | 2011-08-02 22:59:32 +0000 | [diff] [blame] | 11600 | else |
| 11601 | phy->flags |= FLAGS_MDC_MDIO_WA_B0; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 11602 | } else { |
| 11603 | switch (switch_cfg) { |
| 11604 | case SWITCH_CFG_1G: |
| 11605 | phy_addr = REG_RD(bp, |
| 11606 | NIG_REG_SERDES0_CTRL_PHY_ADDR + |
| 11607 | port * 0x10); |
| 11608 | *phy = phy_serdes; |
| 11609 | break; |
| 11610 | case SWITCH_CFG_10G: |
| 11611 | phy_addr = REG_RD(bp, |
| 11612 | NIG_REG_XGXS0_CTRL_PHY_ADDR + |
| 11613 | port * 0x18); |
| 11614 | *phy = phy_xgxs; |
| 11615 | break; |
| 11616 | default: |
| 11617 | DP(NETIF_MSG_LINK, "Invalid switch_cfg\n"); |
| 11618 | return -EINVAL; |
| 11619 | } |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11620 | } |
| 11621 | phy->addr = (u8)phy_addr; |
| 11622 | phy->mdio_ctrl = bnx2x_get_emac_base(bp, |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 11623 | SHARED_HW_CFG_MDC_MDIO_ACCESS1_BOTH, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11624 | port); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 11625 | if (CHIP_IS_E2(bp)) |
| 11626 | phy->def_md_devad = E2_DEFAULT_PHY_DEV_ADDR; |
| 11627 | else |
| 11628 | phy->def_md_devad = DEFAULT_PHY_DEV_ADDR; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11629 | |
| 11630 | DP(NETIF_MSG_LINK, "Internal phy port=%d, addr=0x%x, mdio_ctl=0x%x\n", |
| 11631 | port, phy->addr, phy->mdio_ctrl); |
| 11632 | |
| 11633 | bnx2x_populate_preemphasis(bp, shmem_base, phy, port, INT_PHY); |
| 11634 | return 0; |
| 11635 | } |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 11636 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 11637 | static int bnx2x_populate_ext_phy(struct bnx2x *bp, |
| 11638 | u8 phy_index, |
| 11639 | u32 shmem_base, |
| 11640 | u32 shmem2_base, |
| 11641 | u8 port, |
| 11642 | struct bnx2x_phy *phy) |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 11643 | { |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 11644 | u32 ext_phy_config, phy_type, config2; |
| 11645 | u32 mdc_mdio_access = SHARED_HW_CFG_MDC_MDIO_ACCESS1_BOTH; |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 11646 | ext_phy_config = bnx2x_get_ext_phy_config(bp, shmem_base, |
| 11647 | phy_index, port); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11648 | phy_type = XGXS_EXT_PHY_TYPE(ext_phy_config); |
| 11649 | /* Select the phy type */ |
| 11650 | switch (phy_type) { |
| 11651 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073: |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 11652 | mdc_mdio_access = SHARED_HW_CFG_MDC_MDIO_ACCESS1_SWAPPED; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11653 | *phy = phy_8073; |
| 11654 | break; |
| 11655 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8705: |
| 11656 | *phy = phy_8705; |
| 11657 | break; |
| 11658 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8706: |
| 11659 | *phy = phy_8706; |
| 11660 | break; |
| 11661 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726: |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 11662 | mdc_mdio_access = SHARED_HW_CFG_MDC_MDIO_ACCESS1_EMAC1; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11663 | *phy = phy_8726; |
| 11664 | break; |
| 11665 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727_NOC: |
| 11666 | /* BCM8727_NOC => BCM8727 no over current */ |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 11667 | mdc_mdio_access = SHARED_HW_CFG_MDC_MDIO_ACCESS1_EMAC1; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11668 | *phy = phy_8727; |
| 11669 | phy->flags |= FLAGS_NOC; |
| 11670 | break; |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 11671 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8722: |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11672 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727: |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 11673 | mdc_mdio_access = SHARED_HW_CFG_MDC_MDIO_ACCESS1_EMAC1; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11674 | *phy = phy_8727; |
| 11675 | break; |
| 11676 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8481: |
| 11677 | *phy = phy_8481; |
| 11678 | break; |
| 11679 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84823: |
| 11680 | *phy = phy_84823; |
| 11681 | break; |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 11682 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833: |
| 11683 | *phy = phy_84833; |
| 11684 | break; |
Yaniv Rosner | 3756a89 | 2011-08-23 06:33:24 +0000 | [diff] [blame] | 11685 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54616: |
Yaniv Rosner | 52c4d6c | 2011-07-05 01:06:34 +0000 | [diff] [blame] | 11686 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54618SE: |
| 11687 | *phy = phy_54618se; |
Yaniv Rosner | 6583e33 | 2011-06-14 01:34:17 +0000 | [diff] [blame] | 11688 | break; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11689 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_SFX7101: |
| 11690 | *phy = phy_7101; |
| 11691 | break; |
| 11692 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_FAILURE: |
| 11693 | *phy = phy_null; |
| 11694 | return -EINVAL; |
| 11695 | default: |
| 11696 | *phy = phy_null; |
Yaniv Rosner | 6db5193 | 2011-11-28 00:49:50 +0000 | [diff] [blame] | 11697 | /* In case external PHY wasn't found */ |
| 11698 | if ((phy_type != PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT) && |
| 11699 | (phy_type != PORT_HW_CFG_XGXS_EXT_PHY_TYPE_NOT_CONN)) |
| 11700 | return -EINVAL; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11701 | return 0; |
| 11702 | } |
| 11703 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 11704 | phy->addr = XGXS_EXT_PHY_ADDR(ext_phy_config); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11705 | bnx2x_populate_preemphasis(bp, shmem_base, phy, port, phy_index); |
Yaniv Rosner | 62b29a5 | 2010-09-07 11:40:58 +0000 | [diff] [blame] | 11706 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 11707 | /* |
| 11708 | * The shmem address of the phy version is located on different |
| 11709 | * structures. In case this structure is too old, do not set |
| 11710 | * the address |
| 11711 | */ |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 11712 | config2 = REG_RD(bp, shmem_base + offsetof(struct shmem_region, |
| 11713 | dev_info.shared_hw_config.config2)); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11714 | if (phy_index == EXT_PHY1) { |
| 11715 | phy->ver_addr = shmem_base + offsetof(struct shmem_region, |
| 11716 | port_mb[port].ext_phy_fw_version); |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 11717 | |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11718 | /* Check specific mdc mdio settings */ |
| 11719 | if (config2 & SHARED_HW_CFG_MDC_MDIO_ACCESS1_MASK) |
| 11720 | mdc_mdio_access = config2 & |
| 11721 | SHARED_HW_CFG_MDC_MDIO_ACCESS1_MASK; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11722 | } else { |
| 11723 | u32 size = REG_RD(bp, shmem2_base); |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 11724 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11725 | if (size > |
| 11726 | offsetof(struct shmem2_region, ext_phy_fw_version2)) { |
| 11727 | phy->ver_addr = shmem2_base + |
| 11728 | offsetof(struct shmem2_region, |
| 11729 | ext_phy_fw_version2[port]); |
| 11730 | } |
| 11731 | /* Check specific mdc mdio settings */ |
| 11732 | if (config2 & SHARED_HW_CFG_MDC_MDIO_ACCESS2_MASK) |
| 11733 | mdc_mdio_access = (config2 & |
| 11734 | SHARED_HW_CFG_MDC_MDIO_ACCESS2_MASK) >> |
| 11735 | (SHARED_HW_CFG_MDC_MDIO_ACCESS2_SHIFT - |
| 11736 | SHARED_HW_CFG_MDC_MDIO_ACCESS1_SHIFT); |
| 11737 | } |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 11738 | phy->mdio_ctrl = bnx2x_get_emac_base(bp, mdc_mdio_access, port); |
| 11739 | |
Yaniv Rosner | 7531832 | 2012-01-17 02:33:27 +0000 | [diff] [blame] | 11740 | if ((phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833) && |
| 11741 | (phy->ver_addr)) { |
| 11742 | /* |
| 11743 | * Remove 100Mb link supported for BCM84833 when phy fw |
| 11744 | * version lower than or equal to 1.39 |
| 11745 | */ |
| 11746 | u32 raw_ver = REG_RD(bp, phy->ver_addr); |
| 11747 | if (((raw_ver & 0x7F) <= 39) && |
| 11748 | (((raw_ver & 0xF80) >> 7) <= 1)) |
| 11749 | phy->supported &= ~(SUPPORTED_100baseT_Half | |
| 11750 | SUPPORTED_100baseT_Full); |
| 11751 | } |
| 11752 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 11753 | /* |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 11754 | * In case mdc/mdio_access of the external phy is different than the |
| 11755 | * mdc/mdio access of the XGXS, a HW lock must be taken in each access |
| 11756 | * to prevent one port interfere with another port's CL45 operations. |
| 11757 | */ |
| 11758 | if (mdc_mdio_access != SHARED_HW_CFG_MDC_MDIO_ACCESS1_BOTH) |
| 11759 | phy->flags |= FLAGS_HW_LOCK_REQUIRED; |
| 11760 | DP(NETIF_MSG_LINK, "phy_type 0x%x port %d found in index %d\n", |
| 11761 | phy_type, port, phy_index); |
| 11762 | DP(NETIF_MSG_LINK, " addr=0x%x, mdio_ctl=0x%x\n", |
| 11763 | phy->addr, phy->mdio_ctrl); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 11764 | return 0; |
| 11765 | } |
| 11766 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 11767 | static int bnx2x_populate_phy(struct bnx2x *bp, u8 phy_index, u32 shmem_base, |
| 11768 | u32 shmem2_base, u8 port, struct bnx2x_phy *phy) |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 11769 | { |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 11770 | int status = 0; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11771 | phy->type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_NOT_CONN; |
| 11772 | if (phy_index == INT_PHY) |
| 11773 | return bnx2x_populate_int_phy(bp, shmem_base, port, phy); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11774 | status = bnx2x_populate_ext_phy(bp, phy_index, shmem_base, shmem2_base, |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 11775 | port, phy); |
| 11776 | return status; |
| 11777 | } |
| 11778 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11779 | static void bnx2x_phy_def_cfg(struct link_params *params, |
| 11780 | struct bnx2x_phy *phy, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11781 | u8 phy_index) |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11782 | { |
| 11783 | struct bnx2x *bp = params->bp; |
| 11784 | u32 link_config; |
| 11785 | /* Populate the default phy configuration for MF mode */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11786 | if (phy_index == EXT_PHY2) { |
| 11787 | link_config = REG_RD(bp, params->shmem_base + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11788 | offsetof(struct shmem_region, dev_info. |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11789 | port_feature_config[params->port].link_config2)); |
| 11790 | phy->speed_cap_mask = REG_RD(bp, params->shmem_base + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11791 | offsetof(struct shmem_region, |
| 11792 | dev_info. |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11793 | port_hw_config[params->port].speed_capability_mask2)); |
| 11794 | } else { |
| 11795 | link_config = REG_RD(bp, params->shmem_base + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11796 | offsetof(struct shmem_region, dev_info. |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11797 | port_feature_config[params->port].link_config)); |
| 11798 | phy->speed_cap_mask = REG_RD(bp, params->shmem_base + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 11799 | offsetof(struct shmem_region, |
| 11800 | dev_info. |
| 11801 | port_hw_config[params->port].speed_capability_mask)); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11802 | } |
Joe Perches | 94f05b0 | 2011-08-14 12:16:20 +0000 | [diff] [blame] | 11803 | DP(NETIF_MSG_LINK, |
| 11804 | "Default config phy idx %x cfg 0x%x speed_cap_mask 0x%x\n", |
| 11805 | phy_index, link_config, phy->speed_cap_mask); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11806 | |
| 11807 | phy->req_duplex = DUPLEX_FULL; |
| 11808 | switch (link_config & PORT_FEATURE_LINK_SPEED_MASK) { |
| 11809 | case PORT_FEATURE_LINK_SPEED_10M_HALF: |
| 11810 | phy->req_duplex = DUPLEX_HALF; |
| 11811 | case PORT_FEATURE_LINK_SPEED_10M_FULL: |
| 11812 | phy->req_line_speed = SPEED_10; |
| 11813 | break; |
| 11814 | case PORT_FEATURE_LINK_SPEED_100M_HALF: |
| 11815 | phy->req_duplex = DUPLEX_HALF; |
| 11816 | case PORT_FEATURE_LINK_SPEED_100M_FULL: |
| 11817 | phy->req_line_speed = SPEED_100; |
| 11818 | break; |
| 11819 | case PORT_FEATURE_LINK_SPEED_1G: |
| 11820 | phy->req_line_speed = SPEED_1000; |
| 11821 | break; |
| 11822 | case PORT_FEATURE_LINK_SPEED_2_5G: |
| 11823 | phy->req_line_speed = SPEED_2500; |
| 11824 | break; |
| 11825 | case PORT_FEATURE_LINK_SPEED_10G_CX4: |
| 11826 | phy->req_line_speed = SPEED_10000; |
| 11827 | break; |
| 11828 | default: |
| 11829 | phy->req_line_speed = SPEED_AUTO_NEG; |
| 11830 | break; |
| 11831 | } |
| 11832 | |
| 11833 | switch (link_config & PORT_FEATURE_FLOW_CONTROL_MASK) { |
| 11834 | case PORT_FEATURE_FLOW_CONTROL_AUTO: |
| 11835 | phy->req_flow_ctrl = BNX2X_FLOW_CTRL_AUTO; |
| 11836 | break; |
| 11837 | case PORT_FEATURE_FLOW_CONTROL_TX: |
| 11838 | phy->req_flow_ctrl = BNX2X_FLOW_CTRL_TX; |
| 11839 | break; |
| 11840 | case PORT_FEATURE_FLOW_CONTROL_RX: |
| 11841 | phy->req_flow_ctrl = BNX2X_FLOW_CTRL_RX; |
| 11842 | break; |
| 11843 | case PORT_FEATURE_FLOW_CONTROL_BOTH: |
| 11844 | phy->req_flow_ctrl = BNX2X_FLOW_CTRL_BOTH; |
| 11845 | break; |
| 11846 | default: |
| 11847 | phy->req_flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 11848 | break; |
| 11849 | } |
| 11850 | } |
| 11851 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11852 | u32 bnx2x_phy_selection(struct link_params *params) |
| 11853 | { |
| 11854 | u32 phy_config_swapped, prio_cfg; |
| 11855 | u32 return_cfg = PORT_HW_CFG_PHY_SELECTION_HARDWARE_DEFAULT; |
| 11856 | |
| 11857 | phy_config_swapped = params->multi_phy_config & |
| 11858 | PORT_HW_CFG_PHY_SWAPPED_ENABLED; |
| 11859 | |
| 11860 | prio_cfg = params->multi_phy_config & |
| 11861 | PORT_HW_CFG_PHY_SELECTION_MASK; |
| 11862 | |
| 11863 | if (phy_config_swapped) { |
| 11864 | switch (prio_cfg) { |
| 11865 | case PORT_HW_CFG_PHY_SELECTION_FIRST_PHY_PRIORITY: |
| 11866 | return_cfg = PORT_HW_CFG_PHY_SELECTION_SECOND_PHY_PRIORITY; |
| 11867 | break; |
| 11868 | case PORT_HW_CFG_PHY_SELECTION_SECOND_PHY_PRIORITY: |
| 11869 | return_cfg = PORT_HW_CFG_PHY_SELECTION_FIRST_PHY_PRIORITY; |
| 11870 | break; |
| 11871 | case PORT_HW_CFG_PHY_SELECTION_SECOND_PHY: |
| 11872 | return_cfg = PORT_HW_CFG_PHY_SELECTION_FIRST_PHY; |
| 11873 | break; |
| 11874 | case PORT_HW_CFG_PHY_SELECTION_FIRST_PHY: |
| 11875 | return_cfg = PORT_HW_CFG_PHY_SELECTION_SECOND_PHY; |
| 11876 | break; |
| 11877 | } |
| 11878 | } else |
| 11879 | return_cfg = prio_cfg; |
| 11880 | |
| 11881 | return return_cfg; |
| 11882 | } |
| 11883 | |
| 11884 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 11885 | int bnx2x_phy_probe(struct link_params *params) |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11886 | { |
Yaniv Rosner | 2f751a8 | 2011-11-28 00:49:52 +0000 | [diff] [blame] | 11887 | u8 phy_index, actual_phy_idx; |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 11888 | u32 phy_config_swapped, sync_offset, media_types; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11889 | struct bnx2x *bp = params->bp; |
| 11890 | struct bnx2x_phy *phy; |
| 11891 | params->num_phys = 0; |
| 11892 | DP(NETIF_MSG_LINK, "Begin phy probe\n"); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11893 | phy_config_swapped = params->multi_phy_config & |
| 11894 | PORT_HW_CFG_PHY_SWAPPED_ENABLED; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11895 | |
| 11896 | for (phy_index = INT_PHY; phy_index < MAX_PHYS; |
| 11897 | phy_index++) { |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11898 | actual_phy_idx = phy_index; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11899 | if (phy_config_swapped) { |
| 11900 | if (phy_index == EXT_PHY1) |
| 11901 | actual_phy_idx = EXT_PHY2; |
| 11902 | else if (phy_index == EXT_PHY2) |
| 11903 | actual_phy_idx = EXT_PHY1; |
| 11904 | } |
| 11905 | DP(NETIF_MSG_LINK, "phy_config_swapped %x, phy_index %x," |
| 11906 | " actual_phy_idx %x\n", phy_config_swapped, |
| 11907 | phy_index, actual_phy_idx); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11908 | phy = ¶ms->phy[actual_phy_idx]; |
| 11909 | if (bnx2x_populate_phy(bp, phy_index, params->shmem_base, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11910 | params->shmem2_base, params->port, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11911 | phy) != 0) { |
| 11912 | params->num_phys = 0; |
| 11913 | DP(NETIF_MSG_LINK, "phy probe failed in phy index %d\n", |
| 11914 | phy_index); |
| 11915 | for (phy_index = INT_PHY; |
| 11916 | phy_index < MAX_PHYS; |
| 11917 | phy_index++) |
| 11918 | *phy = phy_null; |
| 11919 | return -EINVAL; |
| 11920 | } |
| 11921 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_NOT_CONN) |
| 11922 | break; |
| 11923 | |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 11924 | sync_offset = params->shmem_base + |
| 11925 | offsetof(struct shmem_region, |
| 11926 | dev_info.port_hw_config[params->port].media_type); |
| 11927 | media_types = REG_RD(bp, sync_offset); |
| 11928 | |
| 11929 | /* |
| 11930 | * Update media type for non-PMF sync only for the first time |
| 11931 | * In case the media type changes afterwards, it will be updated |
| 11932 | * using the update_status function |
| 11933 | */ |
| 11934 | if ((media_types & (PORT_HW_CFG_MEDIA_TYPE_PHY0_MASK << |
| 11935 | (PORT_HW_CFG_MEDIA_TYPE_PHY1_SHIFT * |
| 11936 | actual_phy_idx))) == 0) { |
| 11937 | media_types |= ((phy->media_type & |
| 11938 | PORT_HW_CFG_MEDIA_TYPE_PHY0_MASK) << |
| 11939 | (PORT_HW_CFG_MEDIA_TYPE_PHY1_SHIFT * |
| 11940 | actual_phy_idx)); |
| 11941 | } |
| 11942 | REG_WR(bp, sync_offset, media_types); |
| 11943 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 11944 | bnx2x_phy_def_cfg(params, phy, phy_index); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 11945 | params->num_phys++; |
| 11946 | } |
| 11947 | |
| 11948 | DP(NETIF_MSG_LINK, "End phy probe. #phys found %x\n", params->num_phys); |
| 11949 | return 0; |
| 11950 | } |
| 11951 | |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 11952 | void bnx2x_init_bmac_loopback(struct link_params *params, |
| 11953 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 11954 | { |
| 11955 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 11956 | vars->link_up = 1; |
| 11957 | vars->line_speed = SPEED_10000; |
| 11958 | vars->duplex = DUPLEX_FULL; |
| 11959 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 11960 | vars->mac_type = MAC_TYPE_BMAC; |
| 11961 | |
| 11962 | vars->phy_flags = PHY_XGXS_FLAG; |
| 11963 | |
| 11964 | bnx2x_xgxs_deassert(params); |
| 11965 | |
| 11966 | /* set bmac loopback */ |
| 11967 | bnx2x_bmac_enable(params, vars, 1); |
| 11968 | |
| 11969 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + params->port*4, 0); |
| 11970 | } |
| 11971 | |
| 11972 | void bnx2x_init_emac_loopback(struct link_params *params, |
| 11973 | struct link_vars *vars) |
| 11974 | { |
| 11975 | struct bnx2x *bp = params->bp; |
| 11976 | vars->link_up = 1; |
| 11977 | vars->line_speed = SPEED_1000; |
| 11978 | vars->duplex = DUPLEX_FULL; |
| 11979 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 11980 | vars->mac_type = MAC_TYPE_EMAC; |
| 11981 | |
| 11982 | vars->phy_flags = PHY_XGXS_FLAG; |
| 11983 | |
| 11984 | bnx2x_xgxs_deassert(params); |
| 11985 | /* set bmac loopback */ |
| 11986 | bnx2x_emac_enable(params, vars, 1); |
| 11987 | bnx2x_emac_program(params, vars); |
| 11988 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + params->port*4, 0); |
| 11989 | } |
| 11990 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 11991 | void bnx2x_init_xmac_loopback(struct link_params *params, |
| 11992 | struct link_vars *vars) |
| 11993 | { |
| 11994 | struct bnx2x *bp = params->bp; |
| 11995 | vars->link_up = 1; |
| 11996 | if (!params->req_line_speed[0]) |
| 11997 | vars->line_speed = SPEED_10000; |
| 11998 | else |
| 11999 | vars->line_speed = params->req_line_speed[0]; |
| 12000 | vars->duplex = DUPLEX_FULL; |
| 12001 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 12002 | vars->mac_type = MAC_TYPE_XMAC; |
| 12003 | vars->phy_flags = PHY_XGXS_FLAG; |
| 12004 | /* |
| 12005 | * Set WC to loopback mode since link is required to provide clock |
| 12006 | * to the XMAC in 20G mode |
| 12007 | */ |
Yaniv Rosner | afad009 | 2011-08-02 23:00:06 +0000 | [diff] [blame] | 12008 | bnx2x_set_aer_mmd(params, ¶ms->phy[0]); |
| 12009 | bnx2x_warpcore_reset_lane(bp, ¶ms->phy[0], 0); |
| 12010 | params->phy[INT_PHY].config_loopback( |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 12011 | ¶ms->phy[INT_PHY], |
| 12012 | params); |
Yaniv Rosner | afad009 | 2011-08-02 23:00:06 +0000 | [diff] [blame] | 12013 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 12014 | bnx2x_xmac_enable(params, vars, 1); |
| 12015 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + params->port*4, 0); |
| 12016 | } |
| 12017 | |
| 12018 | void bnx2x_init_umac_loopback(struct link_params *params, |
| 12019 | struct link_vars *vars) |
| 12020 | { |
| 12021 | struct bnx2x *bp = params->bp; |
| 12022 | vars->link_up = 1; |
| 12023 | vars->line_speed = SPEED_1000; |
| 12024 | vars->duplex = DUPLEX_FULL; |
| 12025 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 12026 | vars->mac_type = MAC_TYPE_UMAC; |
| 12027 | vars->phy_flags = PHY_XGXS_FLAG; |
| 12028 | bnx2x_umac_enable(params, vars, 1); |
| 12029 | |
| 12030 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + params->port*4, 0); |
| 12031 | } |
| 12032 | |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 12033 | void bnx2x_init_xgxs_loopback(struct link_params *params, |
| 12034 | struct link_vars *vars) |
| 12035 | { |
| 12036 | struct bnx2x *bp = params->bp; |
| 12037 | vars->link_up = 1; |
| 12038 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 12039 | vars->duplex = DUPLEX_FULL; |
| 12040 | if (params->req_line_speed[0] == SPEED_1000) |
| 12041 | vars->line_speed = SPEED_1000; |
| 12042 | else |
| 12043 | vars->line_speed = SPEED_10000; |
| 12044 | |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 12045 | if (!USES_WARPCORE(bp)) |
| 12046 | bnx2x_xgxs_deassert(params); |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 12047 | bnx2x_link_initialize(params, vars); |
| 12048 | |
| 12049 | if (params->req_line_speed[0] == SPEED_1000) { |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 12050 | if (USES_WARPCORE(bp)) |
| 12051 | bnx2x_umac_enable(params, vars, 0); |
| 12052 | else { |
| 12053 | bnx2x_emac_program(params, vars); |
| 12054 | bnx2x_emac_enable(params, vars, 0); |
| 12055 | } |
| 12056 | } else { |
| 12057 | if (USES_WARPCORE(bp)) |
| 12058 | bnx2x_xmac_enable(params, vars, 0); |
| 12059 | else |
| 12060 | bnx2x_bmac_enable(params, vars, 0); |
| 12061 | } |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 12062 | |
| 12063 | if (params->loopback_mode == LOOPBACK_XGXS) { |
| 12064 | /* set 10G XGXS loopback */ |
| 12065 | params->phy[INT_PHY].config_loopback( |
| 12066 | ¶ms->phy[INT_PHY], |
| 12067 | params); |
| 12068 | |
| 12069 | } else { |
| 12070 | /* set external phy loopback */ |
| 12071 | u8 phy_index; |
| 12072 | for (phy_index = EXT_PHY1; |
| 12073 | phy_index < params->num_phys; phy_index++) { |
| 12074 | if (params->phy[phy_index].config_loopback) |
| 12075 | params->phy[phy_index].config_loopback( |
| 12076 | ¶ms->phy[phy_index], |
| 12077 | params); |
| 12078 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12079 | } |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 12080 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + params->port*4, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12081 | |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 12082 | bnx2x_set_led(params, vars, LED_MODE_OPER, vars->line_speed); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12083 | } |
| 12084 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 12085 | int bnx2x_phy_init(struct link_params *params, struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12086 | { |
| 12087 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12088 | DP(NETIF_MSG_LINK, "Phy Initialization started\n"); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12089 | DP(NETIF_MSG_LINK, "(1) req_speed %d, req_flowctrl %d\n", |
| 12090 | params->req_line_speed[0], params->req_flow_ctrl[0]); |
| 12091 | DP(NETIF_MSG_LINK, "(2) req_speed %d, req_flowctrl %d\n", |
| 12092 | params->req_line_speed[1], params->req_flow_ctrl[1]); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12093 | vars->link_status = 0; |
| 12094 | vars->phy_link_up = 0; |
| 12095 | vars->link_up = 0; |
| 12096 | vars->line_speed = 0; |
| 12097 | vars->duplex = DUPLEX_FULL; |
| 12098 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 12099 | vars->mac_type = MAC_TYPE_NONE; |
| 12100 | vars->phy_flags = 0; |
| 12101 | |
| 12102 | /* disable attentions */ |
| 12103 | bnx2x_bits_dis(bp, NIG_REG_MASK_INTERRUPT_PORT0 + params->port*4, |
| 12104 | (NIG_MASK_XGXS0_LINK_STATUS | |
| 12105 | NIG_MASK_XGXS0_LINK10G | |
| 12106 | NIG_MASK_SERDES0_LINK_STATUS | |
| 12107 | NIG_MASK_MI_INT)); |
| 12108 | |
| 12109 | bnx2x_emac_init(params, vars); |
| 12110 | |
Yaniv Rosner | 27d9129 | 2012-04-04 01:28:54 +0000 | [diff] [blame] | 12111 | if (params->feature_config_flags & FEATURE_CONFIG_PFC_ENABLED) |
| 12112 | vars->link_status |= LINK_STATUS_PFC_ENABLED; |
| 12113 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12114 | if (params->num_phys == 0) { |
| 12115 | DP(NETIF_MSG_LINK, "No phy found for initialization !!\n"); |
| 12116 | return -EINVAL; |
| 12117 | } |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 12118 | set_phy_vars(params, vars); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12119 | |
| 12120 | 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] | 12121 | switch (params->loopback_mode) { |
| 12122 | case LOOPBACK_BMAC: |
| 12123 | bnx2x_init_bmac_loopback(params, vars); |
| 12124 | break; |
| 12125 | case LOOPBACK_EMAC: |
| 12126 | bnx2x_init_emac_loopback(params, vars); |
| 12127 | break; |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 12128 | case LOOPBACK_XMAC: |
| 12129 | bnx2x_init_xmac_loopback(params, vars); |
| 12130 | break; |
| 12131 | case LOOPBACK_UMAC: |
| 12132 | bnx2x_init_umac_loopback(params, vars); |
| 12133 | break; |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 12134 | case LOOPBACK_XGXS: |
| 12135 | case LOOPBACK_EXT_PHY: |
| 12136 | bnx2x_init_xgxs_loopback(params, vars); |
| 12137 | break; |
| 12138 | default: |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 12139 | if (!CHIP_IS_E3(bp)) { |
| 12140 | if (params->switch_cfg == SWITCH_CFG_10G) |
| 12141 | bnx2x_xgxs_deassert(params); |
| 12142 | else |
| 12143 | bnx2x_serdes_deassert(bp, params->port); |
| 12144 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12145 | bnx2x_link_initialize(params, vars); |
| 12146 | msleep(30); |
| 12147 | bnx2x_link_int_enable(params); |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 12148 | break; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12149 | } |
| 12150 | return 0; |
| 12151 | } |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 12152 | |
| 12153 | int bnx2x_link_reset(struct link_params *params, struct link_vars *vars, |
| 12154 | u8 reset_ext_phy) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12155 | { |
| 12156 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | cf1d972 | 2010-11-01 05:32:34 +0000 | [diff] [blame] | 12157 | u8 phy_index, port = params->port, clear_latch_ind = 0; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12158 | DP(NETIF_MSG_LINK, "Resetting the link of port %d\n", port); |
| 12159 | /* disable attentions */ |
| 12160 | vars->link_status = 0; |
| 12161 | bnx2x_update_mng(params, vars->link_status); |
| 12162 | bnx2x_bits_dis(bp, NIG_REG_MASK_INTERRUPT_PORT0 + port*4, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 12163 | (NIG_MASK_XGXS0_LINK_STATUS | |
| 12164 | NIG_MASK_XGXS0_LINK10G | |
| 12165 | NIG_MASK_SERDES0_LINK_STATUS | |
| 12166 | NIG_MASK_MI_INT)); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12167 | |
| 12168 | /* activate nig drain */ |
| 12169 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + port*4, 1); |
| 12170 | |
| 12171 | /* disable nig egress interface */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 12172 | if (!CHIP_IS_E3(bp)) { |
| 12173 | REG_WR(bp, NIG_REG_BMAC0_OUT_EN + port*4, 0); |
| 12174 | REG_WR(bp, NIG_REG_EGRESS_EMAC0_OUT_EN + port*4, 0); |
| 12175 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12176 | |
| 12177 | /* Stop BigMac rx */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 12178 | if (!CHIP_IS_E3(bp)) |
| 12179 | bnx2x_bmac_rx_disable(bp, port); |
Yaniv Rosner | ce7c048 | 2011-10-27 05:09:47 +0000 | [diff] [blame] | 12180 | else { |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 12181 | bnx2x_xmac_disable(params); |
Yaniv Rosner | ce7c048 | 2011-10-27 05:09:47 +0000 | [diff] [blame] | 12182 | bnx2x_umac_disable(params); |
| 12183 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12184 | /* disable emac */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 12185 | if (!CHIP_IS_E3(bp)) |
| 12186 | REG_WR(bp, NIG_REG_NIG_EMAC0_EN + port*4, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12187 | |
| 12188 | msleep(10); |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 12189 | /* The PHY reset is controlled by GPIO 1 |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12190 | * Hold it as vars low |
| 12191 | */ |
| 12192 | /* clear link led */ |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 12193 | bnx2x_set_led(params, vars, LED_MODE_OFF, 0); |
| 12194 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12195 | if (reset_ext_phy) { |
Yaniv Rosner | 28f4881 | 2011-08-02 23:00:12 +0000 | [diff] [blame] | 12196 | bnx2x_set_mdio_clk(bp, params->chip_id, port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12197 | for (phy_index = EXT_PHY1; phy_index < params->num_phys; |
| 12198 | phy_index++) { |
Yaniv Rosner | 28f4881 | 2011-08-02 23:00:12 +0000 | [diff] [blame] | 12199 | if (params->phy[phy_index].link_reset) { |
| 12200 | bnx2x_set_aer_mmd(params, |
| 12201 | ¶ms->phy[phy_index]); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12202 | params->phy[phy_index].link_reset( |
| 12203 | ¶ms->phy[phy_index], |
| 12204 | params); |
Yaniv Rosner | 28f4881 | 2011-08-02 23:00:12 +0000 | [diff] [blame] | 12205 | } |
Yaniv Rosner | cf1d972 | 2010-11-01 05:32:34 +0000 | [diff] [blame] | 12206 | if (params->phy[phy_index].flags & |
| 12207 | FLAGS_REARM_LATCH_SIGNAL) |
| 12208 | clear_latch_ind = 1; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12209 | } |
| 12210 | } |
| 12211 | |
Yaniv Rosner | cf1d972 | 2010-11-01 05:32:34 +0000 | [diff] [blame] | 12212 | if (clear_latch_ind) { |
| 12213 | /* Clear latching indication */ |
| 12214 | bnx2x_rearm_latch_signal(bp, port, 0); |
| 12215 | bnx2x_bits_dis(bp, NIG_REG_LATCH_BC_0 + port*4, |
| 12216 | 1 << NIG_LATCH_BC_ENABLE_MI_INT); |
| 12217 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12218 | if (params->phy[INT_PHY].link_reset) |
| 12219 | params->phy[INT_PHY].link_reset( |
| 12220 | ¶ms->phy[INT_PHY], params); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12221 | |
| 12222 | /* disable nig ingress interface */ |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 12223 | if (!CHIP_IS_E3(bp)) { |
Yaniv Rosner | ce7c048 | 2011-10-27 05:09:47 +0000 | [diff] [blame] | 12224 | /* reset BigMac */ |
| 12225 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_CLEAR, |
| 12226 | (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << port)); |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 12227 | REG_WR(bp, NIG_REG_BMAC0_IN_EN + port*4, 0); |
| 12228 | REG_WR(bp, NIG_REG_EMAC0_IN_EN + port*4, 0); |
Yaniv Rosner | ce7c048 | 2011-10-27 05:09:47 +0000 | [diff] [blame] | 12229 | } else { |
| 12230 | u32 xmac_base = (params->port) ? GRCBASE_XMAC1 : GRCBASE_XMAC0; |
| 12231 | bnx2x_set_xumac_nig(params, 0, 0); |
| 12232 | if (REG_RD(bp, MISC_REG_RESET_REG_2) & |
| 12233 | MISC_REGISTERS_RESET_REG_2_XMAC) |
| 12234 | REG_WR(bp, xmac_base + XMAC_REG_CTRL, |
| 12235 | XMAC_CTRL_REG_SOFT_RESET); |
Yaniv Rosner | 9380bb9 | 2011-06-14 01:34:07 +0000 | [diff] [blame] | 12236 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12237 | vars->link_up = 0; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 12238 | vars->phy_flags = 0; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12239 | return 0; |
| 12240 | } |
| 12241 | |
| 12242 | /****************************************************************************/ |
| 12243 | /* Common function */ |
| 12244 | /****************************************************************************/ |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 12245 | static int bnx2x_8073_common_init_phy(struct bnx2x *bp, |
| 12246 | u32 shmem_base_path[], |
| 12247 | u32 shmem2_base_path[], u8 phy_index, |
| 12248 | u32 chip_id) |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12249 | { |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 12250 | struct bnx2x_phy phy[PORT_MAX]; |
| 12251 | struct bnx2x_phy *phy_blk[PORT_MAX]; |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12252 | u16 val; |
Yaniv Rosner | c8e64df | 2011-01-30 04:15:00 +0000 | [diff] [blame] | 12253 | s8 port = 0; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12254 | s8 port_of_path = 0; |
Yaniv Rosner | c8e64df | 2011-01-30 04:15:00 +0000 | [diff] [blame] | 12255 | u32 swap_val, swap_override; |
| 12256 | swap_val = REG_RD(bp, NIG_REG_PORT_SWAP); |
| 12257 | swap_override = REG_RD(bp, NIG_REG_STRAP_OVERRIDE); |
| 12258 | port ^= (swap_val && swap_override); |
| 12259 | bnx2x_ext_phy_hw_reset(bp, port); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12260 | /* PART1 - Reset both phys */ |
| 12261 | for (port = PORT_MAX - 1; port >= PORT_0; port--) { |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12262 | u32 shmem_base, shmem2_base; |
| 12263 | /* In E2, same phy is using for port0 of the two paths */ |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 12264 | if (CHIP_IS_E1x(bp)) { |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12265 | shmem_base = shmem_base_path[0]; |
| 12266 | shmem2_base = shmem2_base_path[0]; |
| 12267 | port_of_path = port; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 12268 | } else { |
| 12269 | shmem_base = shmem_base_path[port]; |
| 12270 | shmem2_base = shmem2_base_path[port]; |
| 12271 | port_of_path = 0; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12272 | } |
| 12273 | |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12274 | /* Extract the ext phy address for the port */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12275 | if (bnx2x_populate_phy(bp, phy_index, shmem_base, shmem2_base, |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12276 | port_of_path, &phy[port]) != |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 12277 | 0) { |
| 12278 | DP(NETIF_MSG_LINK, "populate_phy failed\n"); |
| 12279 | return -EINVAL; |
| 12280 | } |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12281 | /* disable attentions */ |
Yaniv Rosner | 6a71bbe | 2010-11-01 05:32:31 +0000 | [diff] [blame] | 12282 | bnx2x_bits_dis(bp, NIG_REG_MASK_INTERRUPT_PORT0 + |
| 12283 | port_of_path*4, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 12284 | (NIG_MASK_XGXS0_LINK_STATUS | |
| 12285 | NIG_MASK_XGXS0_LINK10G | |
| 12286 | NIG_MASK_SERDES0_LINK_STATUS | |
| 12287 | NIG_MASK_MI_INT)); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12288 | |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12289 | /* Need to take the phy out of low power mode in order |
| 12290 | to write to access its registers */ |
| 12291 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 12292 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, |
| 12293 | port); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12294 | |
| 12295 | /* Reset the phy */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 12296 | bnx2x_cl45_write(bp, &phy[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 12297 | MDIO_PMA_DEVAD, |
| 12298 | MDIO_PMA_REG_CTRL, |
| 12299 | 1<<15); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12300 | } |
| 12301 | |
| 12302 | /* Add delay of 150ms after reset */ |
| 12303 | msleep(150); |
| 12304 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 12305 | if (phy[PORT_0].addr & 0x1) { |
| 12306 | phy_blk[PORT_0] = &(phy[PORT_1]); |
| 12307 | phy_blk[PORT_1] = &(phy[PORT_0]); |
| 12308 | } else { |
| 12309 | phy_blk[PORT_0] = &(phy[PORT_0]); |
| 12310 | phy_blk[PORT_1] = &(phy[PORT_1]); |
| 12311 | } |
| 12312 | |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12313 | /* PART2 - Download firmware to both phys */ |
| 12314 | for (port = PORT_MAX - 1; port >= PORT_0; port--) { |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 12315 | if (CHIP_IS_E1x(bp)) |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12316 | port_of_path = port; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 12317 | else |
| 12318 | port_of_path = 0; |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12319 | |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12320 | DP(NETIF_MSG_LINK, "Loading spirom for phy address 0x%x\n", |
| 12321 | phy_blk[port]->addr); |
Yaniv Rosner | 5c99274b | 2011-01-18 04:33:36 +0000 | [diff] [blame] | 12322 | if (bnx2x_8073_8727_external_rom_boot(bp, phy_blk[port], |
| 12323 | port_of_path)) |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12324 | return -EINVAL; |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12325 | |
| 12326 | /* Only set bit 10 = 1 (Tx power down) */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 12327 | bnx2x_cl45_read(bp, phy_blk[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 12328 | MDIO_PMA_DEVAD, |
| 12329 | MDIO_PMA_REG_TX_POWER_DOWN, &val); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12330 | |
| 12331 | /* Phase1 of TX_POWER_DOWN reset */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 12332 | bnx2x_cl45_write(bp, phy_blk[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 12333 | MDIO_PMA_DEVAD, |
| 12334 | MDIO_PMA_REG_TX_POWER_DOWN, |
| 12335 | (val | 1<<10)); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12336 | } |
| 12337 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 12338 | /* |
| 12339 | * Toggle Transmitter: Power down and then up with 600ms delay |
| 12340 | * between |
| 12341 | */ |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12342 | msleep(600); |
| 12343 | |
| 12344 | /* PART3 - complete TX_POWER_DOWN process, and set GPIO2 back to low */ |
| 12345 | for (port = PORT_MAX - 1; port >= PORT_0; port--) { |
Eilon Greenstein | f537225 | 2009-02-12 08:38:30 +0000 | [diff] [blame] | 12346 | /* Phase2 of POWER_DOWN_RESET */ |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12347 | /* Release bit 10 (Release Tx power down) */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 12348 | bnx2x_cl45_read(bp, phy_blk[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 12349 | MDIO_PMA_DEVAD, |
| 12350 | MDIO_PMA_REG_TX_POWER_DOWN, &val); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12351 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 12352 | bnx2x_cl45_write(bp, phy_blk[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 12353 | MDIO_PMA_DEVAD, |
| 12354 | MDIO_PMA_REG_TX_POWER_DOWN, (val & (~(1<<10)))); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12355 | msleep(15); |
| 12356 | |
| 12357 | /* Read modify write the SPI-ROM version select register */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 12358 | bnx2x_cl45_read(bp, phy_blk[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 12359 | MDIO_PMA_DEVAD, |
| 12360 | MDIO_PMA_REG_EDC_FFE_MAIN, &val); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 12361 | bnx2x_cl45_write(bp, phy_blk[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 12362 | MDIO_PMA_DEVAD, |
| 12363 | MDIO_PMA_REG_EDC_FFE_MAIN, (val | (1<<12))); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12364 | |
| 12365 | /* set GPIO2 back to LOW */ |
| 12366 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 12367 | MISC_REGISTERS_GPIO_OUTPUT_LOW, port); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12368 | } |
| 12369 | return 0; |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12370 | } |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 12371 | static int bnx2x_8726_common_init_phy(struct bnx2x *bp, |
| 12372 | u32 shmem_base_path[], |
| 12373 | u32 shmem2_base_path[], u8 phy_index, |
| 12374 | u32 chip_id) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12375 | { |
| 12376 | u32 val; |
| 12377 | s8 port; |
| 12378 | struct bnx2x_phy phy; |
| 12379 | /* Use port1 because of the static port-swap */ |
| 12380 | /* Enable the module detection interrupt */ |
| 12381 | val = REG_RD(bp, MISC_REG_GPIO_EVENT_EN); |
| 12382 | val |= ((1<<MISC_REGISTERS_GPIO_3)| |
| 12383 | (1<<(MISC_REGISTERS_GPIO_3 + MISC_REGISTERS_GPIO_PORT_SHIFT))); |
| 12384 | REG_WR(bp, MISC_REG_GPIO_EVENT_EN, val); |
| 12385 | |
Yaniv Rosner | 650154b | 2010-11-01 05:32:36 +0000 | [diff] [blame] | 12386 | bnx2x_ext_phy_hw_reset(bp, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12387 | msleep(5); |
| 12388 | for (port = 0; port < PORT_MAX; port++) { |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12389 | u32 shmem_base, shmem2_base; |
| 12390 | |
| 12391 | /* In E2, same phy is using for port0 of the two paths */ |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 12392 | if (CHIP_IS_E1x(bp)) { |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12393 | shmem_base = shmem_base_path[0]; |
| 12394 | shmem2_base = shmem2_base_path[0]; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 12395 | } else { |
| 12396 | shmem_base = shmem_base_path[port]; |
| 12397 | shmem2_base = shmem2_base_path[port]; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12398 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12399 | /* Extract the ext phy address for the port */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12400 | if (bnx2x_populate_phy(bp, phy_index, shmem_base, shmem2_base, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12401 | port, &phy) != |
| 12402 | 0) { |
| 12403 | DP(NETIF_MSG_LINK, "populate phy failed\n"); |
| 12404 | return -EINVAL; |
| 12405 | } |
| 12406 | |
| 12407 | /* Reset phy*/ |
| 12408 | bnx2x_cl45_write(bp, &phy, |
| 12409 | MDIO_PMA_DEVAD, MDIO_PMA_REG_GEN_CTRL, 0x0001); |
| 12410 | |
| 12411 | |
| 12412 | /* Set fault module detected LED on */ |
| 12413 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_0, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 12414 | MISC_REGISTERS_GPIO_HIGH, |
| 12415 | port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 12416 | } |
| 12417 | |
| 12418 | return 0; |
| 12419 | } |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 12420 | static void bnx2x_get_ext_phy_reset_gpio(struct bnx2x *bp, u32 shmem_base, |
| 12421 | u8 *io_gpio, u8 *io_port) |
| 12422 | { |
| 12423 | |
| 12424 | u32 phy_gpio_reset = REG_RD(bp, shmem_base + |
| 12425 | offsetof(struct shmem_region, |
| 12426 | dev_info.port_hw_config[PORT_0].default_cfg)); |
| 12427 | switch (phy_gpio_reset) { |
| 12428 | case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO0_P0: |
| 12429 | *io_gpio = 0; |
| 12430 | *io_port = 0; |
| 12431 | break; |
| 12432 | case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO1_P0: |
| 12433 | *io_gpio = 1; |
| 12434 | *io_port = 0; |
| 12435 | break; |
| 12436 | case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO2_P0: |
| 12437 | *io_gpio = 2; |
| 12438 | *io_port = 0; |
| 12439 | break; |
| 12440 | case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO3_P0: |
| 12441 | *io_gpio = 3; |
| 12442 | *io_port = 0; |
| 12443 | break; |
| 12444 | case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO0_P1: |
| 12445 | *io_gpio = 0; |
| 12446 | *io_port = 1; |
| 12447 | break; |
| 12448 | case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO1_P1: |
| 12449 | *io_gpio = 1; |
| 12450 | *io_port = 1; |
| 12451 | break; |
| 12452 | case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO2_P1: |
| 12453 | *io_gpio = 2; |
| 12454 | *io_port = 1; |
| 12455 | break; |
| 12456 | case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO3_P1: |
| 12457 | *io_gpio = 3; |
| 12458 | *io_port = 1; |
| 12459 | break; |
| 12460 | default: |
| 12461 | /* Don't override the io_gpio and io_port */ |
| 12462 | break; |
| 12463 | } |
| 12464 | } |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 12465 | |
| 12466 | static int bnx2x_8727_common_init_phy(struct bnx2x *bp, |
| 12467 | u32 shmem_base_path[], |
| 12468 | u32 shmem2_base_path[], u8 phy_index, |
| 12469 | u32 chip_id) |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 12470 | { |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 12471 | s8 port, reset_gpio; |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 12472 | u32 swap_val, swap_override; |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 12473 | struct bnx2x_phy phy[PORT_MAX]; |
| 12474 | struct bnx2x_phy *phy_blk[PORT_MAX]; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12475 | s8 port_of_path; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 12476 | swap_val = REG_RD(bp, NIG_REG_PORT_SWAP); |
| 12477 | swap_override = REG_RD(bp, NIG_REG_STRAP_OVERRIDE); |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 12478 | |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 12479 | reset_gpio = MISC_REGISTERS_GPIO_1; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12480 | port = 1; |
| 12481 | |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 12482 | /* |
| 12483 | * Retrieve the reset gpio/port which control the reset. |
| 12484 | * Default is GPIO1, PORT1 |
| 12485 | */ |
| 12486 | bnx2x_get_ext_phy_reset_gpio(bp, shmem_base_path[0], |
| 12487 | (u8 *)&reset_gpio, (u8 *)&port); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12488 | |
| 12489 | /* Calculate the port based on port swap */ |
| 12490 | port ^= (swap_val && swap_override); |
| 12491 | |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 12492 | /* Initiate PHY reset*/ |
| 12493 | bnx2x_set_gpio(bp, reset_gpio, MISC_REGISTERS_GPIO_OUTPUT_LOW, |
| 12494 | port); |
| 12495 | msleep(1); |
| 12496 | bnx2x_set_gpio(bp, reset_gpio, MISC_REGISTERS_GPIO_OUTPUT_HIGH, |
| 12497 | port); |
| 12498 | |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 12499 | msleep(5); |
| 12500 | |
| 12501 | /* PART1 - Reset both phys */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12502 | for (port = PORT_MAX - 1; port >= PORT_0; port--) { |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12503 | u32 shmem_base, shmem2_base; |
| 12504 | |
| 12505 | /* In E2, same phy is using for port0 of the two paths */ |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 12506 | if (CHIP_IS_E1x(bp)) { |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12507 | shmem_base = shmem_base_path[0]; |
| 12508 | shmem2_base = shmem2_base_path[0]; |
| 12509 | port_of_path = port; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 12510 | } else { |
| 12511 | shmem_base = shmem_base_path[port]; |
| 12512 | shmem2_base = shmem2_base_path[port]; |
| 12513 | port_of_path = 0; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12514 | } |
| 12515 | |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 12516 | /* Extract the ext phy address for the port */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12517 | if (bnx2x_populate_phy(bp, phy_index, shmem_base, shmem2_base, |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12518 | port_of_path, &phy[port]) != |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 12519 | 0) { |
| 12520 | DP(NETIF_MSG_LINK, "populate phy failed\n"); |
| 12521 | return -EINVAL; |
| 12522 | } |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 12523 | /* disable attentions */ |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12524 | bnx2x_bits_dis(bp, NIG_REG_MASK_INTERRUPT_PORT0 + |
| 12525 | port_of_path*4, |
| 12526 | (NIG_MASK_XGXS0_LINK_STATUS | |
| 12527 | NIG_MASK_XGXS0_LINK10G | |
| 12528 | NIG_MASK_SERDES0_LINK_STATUS | |
| 12529 | NIG_MASK_MI_INT)); |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 12530 | |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 12531 | |
| 12532 | /* Reset the phy */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 12533 | bnx2x_cl45_write(bp, &phy[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 12534 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 1<<15); |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 12535 | } |
| 12536 | |
| 12537 | /* Add delay of 150ms after reset */ |
| 12538 | msleep(150); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 12539 | if (phy[PORT_0].addr & 0x1) { |
| 12540 | phy_blk[PORT_0] = &(phy[PORT_1]); |
| 12541 | phy_blk[PORT_1] = &(phy[PORT_0]); |
| 12542 | } else { |
| 12543 | phy_blk[PORT_0] = &(phy[PORT_0]); |
| 12544 | phy_blk[PORT_1] = &(phy[PORT_1]); |
| 12545 | } |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 12546 | /* PART2 - Download firmware to both phys */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 12547 | for (port = PORT_MAX - 1; port >= PORT_0; port--) { |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 12548 | if (CHIP_IS_E1x(bp)) |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12549 | port_of_path = port; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 12550 | else |
| 12551 | port_of_path = 0; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12552 | DP(NETIF_MSG_LINK, "Loading spirom for phy address 0x%x\n", |
| 12553 | phy_blk[port]->addr); |
Yaniv Rosner | 5c99274b | 2011-01-18 04:33:36 +0000 | [diff] [blame] | 12554 | if (bnx2x_8073_8727_external_rom_boot(bp, phy_blk[port], |
| 12555 | port_of_path)) |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 12556 | return -EINVAL; |
Yaniv Rosner | 85242ee | 2011-07-05 01:06:53 +0000 | [diff] [blame] | 12557 | /* Disable PHY transmitter output */ |
| 12558 | bnx2x_cl45_write(bp, phy_blk[port], |
| 12559 | MDIO_PMA_DEVAD, |
| 12560 | MDIO_PMA_REG_TX_DISABLE, 1); |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 12561 | |
Yaniv Rosner | 5c99274b | 2011-01-18 04:33:36 +0000 | [diff] [blame] | 12562 | } |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 12563 | return 0; |
| 12564 | } |
| 12565 | |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 12566 | static int bnx2x_84833_common_init_phy(struct bnx2x *bp, |
| 12567 | u32 shmem_base_path[], |
| 12568 | u32 shmem2_base_path[], |
| 12569 | u8 phy_index, |
| 12570 | u32 chip_id) |
| 12571 | { |
| 12572 | u8 reset_gpios; |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 12573 | reset_gpios = bnx2x_84833_get_reset_gpios(bp, shmem_base_path, chip_id); |
| 12574 | bnx2x_set_mult_gpio(bp, reset_gpios, MISC_REGISTERS_GPIO_OUTPUT_LOW); |
| 12575 | udelay(10); |
| 12576 | bnx2x_set_mult_gpio(bp, reset_gpios, MISC_REGISTERS_GPIO_OUTPUT_HIGH); |
| 12577 | DP(NETIF_MSG_LINK, "84833 reset pulse on pin values 0x%x\n", |
| 12578 | reset_gpios); |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 12579 | return 0; |
| 12580 | } |
| 12581 | |
Yaniv Rosner | 11b2ec6 | 2012-01-17 02:33:25 +0000 | [diff] [blame] | 12582 | static int bnx2x_84833_pre_init_phy(struct bnx2x *bp, |
| 12583 | struct bnx2x_phy *phy) |
| 12584 | { |
| 12585 | u16 val, cnt; |
| 12586 | /* Wait for FW completing its initialization. */ |
| 12587 | for (cnt = 0; cnt < 1500; cnt++) { |
| 12588 | bnx2x_cl45_read(bp, phy, |
| 12589 | MDIO_PMA_DEVAD, |
| 12590 | MDIO_PMA_REG_CTRL, &val); |
| 12591 | if (!(val & (1<<15))) |
| 12592 | break; |
| 12593 | msleep(1); |
| 12594 | } |
| 12595 | if (cnt >= 1500) { |
| 12596 | DP(NETIF_MSG_LINK, "84833 reset timeout\n"); |
| 12597 | return -EINVAL; |
| 12598 | } |
| 12599 | |
| 12600 | /* Put the port in super isolate mode. */ |
| 12601 | bnx2x_cl45_read(bp, phy, |
| 12602 | MDIO_CTL_DEVAD, |
| 12603 | MDIO_84833_TOP_CFG_XGPHY_STRAP1, &val); |
| 12604 | val |= MDIO_84833_SUPER_ISOLATE; |
| 12605 | bnx2x_cl45_write(bp, phy, |
| 12606 | MDIO_CTL_DEVAD, |
| 12607 | MDIO_84833_TOP_CFG_XGPHY_STRAP1, val); |
| 12608 | |
| 12609 | /* Save spirom version */ |
| 12610 | bnx2x_save_848xx_spirom_version(phy, bp, PORT_0); |
| 12611 | return 0; |
| 12612 | } |
| 12613 | |
| 12614 | int bnx2x_pre_init_phy(struct bnx2x *bp, |
| 12615 | u32 shmem_base, |
| 12616 | u32 shmem2_base, |
| 12617 | u32 chip_id) |
| 12618 | { |
| 12619 | int rc = 0; |
| 12620 | struct bnx2x_phy phy; |
| 12621 | bnx2x_set_mdio_clk(bp, chip_id, PORT_0); |
| 12622 | if (bnx2x_populate_phy(bp, EXT_PHY1, shmem_base, shmem2_base, |
| 12623 | PORT_0, &phy)) { |
| 12624 | DP(NETIF_MSG_LINK, "populate_phy failed\n"); |
| 12625 | return -EINVAL; |
| 12626 | } |
| 12627 | switch (phy.type) { |
| 12628 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833: |
| 12629 | rc = bnx2x_84833_pre_init_phy(bp, &phy); |
| 12630 | break; |
| 12631 | default: |
| 12632 | break; |
| 12633 | } |
| 12634 | return rc; |
| 12635 | } |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 12636 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 12637 | static int bnx2x_ext_phy_common_init(struct bnx2x *bp, u32 shmem_base_path[], |
| 12638 | u32 shmem2_base_path[], u8 phy_index, |
| 12639 | u32 ext_phy_type, u32 chip_id) |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12640 | { |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 12641 | int rc = 0; |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12642 | |
| 12643 | switch (ext_phy_type) { |
| 12644 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073: |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12645 | rc = bnx2x_8073_common_init_phy(bp, shmem_base_path, |
| 12646 | shmem2_base_path, |
| 12647 | phy_index, chip_id); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12648 | break; |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 12649 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8722: |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 12650 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727: |
| 12651 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727_NOC: |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12652 | rc = bnx2x_8727_common_init_phy(bp, shmem_base_path, |
| 12653 | shmem2_base_path, |
| 12654 | phy_index, chip_id); |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 12655 | break; |
| 12656 | |
Eilon Greenstein | 589abe3 | 2009-02-12 08:36:55 +0000 | [diff] [blame] | 12657 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726: |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 12658 | /* |
| 12659 | * GPIO1 affects both ports, so there's need to pull |
| 12660 | * it for single port alone |
| 12661 | */ |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12662 | rc = bnx2x_8726_common_init_phy(bp, shmem_base_path, |
| 12663 | shmem2_base_path, |
| 12664 | phy_index, chip_id); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12665 | break; |
Yaniv Rosner | 0d40f0d | 2011-06-14 01:34:27 +0000 | [diff] [blame] | 12666 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833: |
| 12667 | /* |
| 12668 | * GPIO3's are linked, and so both need to be toggled |
| 12669 | * to obtain required 2us pulse. |
| 12670 | */ |
Yaniv Rosner | 521683d | 2011-11-28 00:49:48 +0000 | [diff] [blame] | 12671 | rc = bnx2x_84833_common_init_phy(bp, shmem_base_path, |
| 12672 | shmem2_base_path, |
| 12673 | phy_index, chip_id); |
Yaniv Rosner | 0d40f0d | 2011-06-14 01:34:27 +0000 | [diff] [blame] | 12674 | break; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12675 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_FAILURE: |
| 12676 | rc = -EINVAL; |
Yaniv Rosner | 4f60dab | 2009-11-05 19:18:23 +0200 | [diff] [blame] | 12677 | break; |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12678 | default: |
| 12679 | DP(NETIF_MSG_LINK, |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 12680 | "ext_phy 0x%x common init not required\n", |
| 12681 | ext_phy_type); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12682 | break; |
| 12683 | } |
| 12684 | |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 12685 | if (rc != 0) |
| 12686 | netdev_err(bp->dev, "Warning: PHY was not initialized," |
| 12687 | " Port %d\n", |
| 12688 | 0); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 12689 | return rc; |
| 12690 | } |
| 12691 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 12692 | int bnx2x_common_init_phy(struct bnx2x *bp, u32 shmem_base_path[], |
| 12693 | u32 shmem2_base_path[], u32 chip_id) |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12694 | { |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 12695 | int rc = 0; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 12696 | u32 phy_ver, val; |
| 12697 | u8 phy_index = 0; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12698 | u32 ext_phy_type, ext_phy_config; |
Yaniv Rosner | a198c14 | 2011-05-31 21:29:42 +0000 | [diff] [blame] | 12699 | bnx2x_set_mdio_clk(bp, chip_id, PORT_0); |
| 12700 | bnx2x_set_mdio_clk(bp, chip_id, PORT_1); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12701 | DP(NETIF_MSG_LINK, "Begin common phy init\n"); |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 12702 | if (CHIP_IS_E3(bp)) { |
| 12703 | /* Enable EPIO */ |
| 12704 | val = REG_RD(bp, MISC_REG_GEN_PURP_HWG); |
| 12705 | REG_WR(bp, MISC_REG_GEN_PURP_HWG, val | 1); |
| 12706 | } |
Yaniv Rosner | b21a342 | 2011-01-18 04:33:24 +0000 | [diff] [blame] | 12707 | /* Check if common init was already done */ |
| 12708 | phy_ver = REG_RD(bp, shmem_base_path[0] + |
| 12709 | offsetof(struct shmem_region, |
| 12710 | port_mb[PORT_0].ext_phy_fw_version)); |
| 12711 | if (phy_ver) { |
| 12712 | DP(NETIF_MSG_LINK, "Not doing common init; phy ver is 0x%x\n", |
| 12713 | phy_ver); |
| 12714 | return 0; |
| 12715 | } |
| 12716 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12717 | /* Read the ext_phy_type for arbitrary port(0) */ |
| 12718 | for (phy_index = EXT_PHY1; phy_index < MAX_PHYS; |
| 12719 | phy_index++) { |
| 12720 | ext_phy_config = bnx2x_get_ext_phy_config(bp, |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12721 | shmem_base_path[0], |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12722 | phy_index, 0); |
| 12723 | ext_phy_type = XGXS_EXT_PHY_TYPE(ext_phy_config); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 12724 | rc |= bnx2x_ext_phy_common_init(bp, shmem_base_path, |
| 12725 | shmem2_base_path, |
| 12726 | phy_index, ext_phy_type, |
| 12727 | chip_id); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12728 | } |
| 12729 | return rc; |
| 12730 | } |
| 12731 | |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 12732 | static void bnx2x_check_over_curr(struct link_params *params, |
| 12733 | struct link_vars *vars) |
| 12734 | { |
| 12735 | struct bnx2x *bp = params->bp; |
| 12736 | u32 cfg_pin; |
| 12737 | u8 port = params->port; |
| 12738 | u32 pin_val; |
| 12739 | |
| 12740 | cfg_pin = (REG_RD(bp, params->shmem_base + |
| 12741 | offsetof(struct shmem_region, |
| 12742 | dev_info.port_hw_config[port].e3_cmn_pin_cfg1)) & |
| 12743 | PORT_HW_CFG_E3_OVER_CURRENT_MASK) >> |
| 12744 | PORT_HW_CFG_E3_OVER_CURRENT_SHIFT; |
| 12745 | |
| 12746 | /* Ignore check if no external input PIN available */ |
| 12747 | if (bnx2x_get_cfg_pin(bp, cfg_pin, &pin_val) != 0) |
| 12748 | return; |
| 12749 | |
| 12750 | if (!pin_val) { |
| 12751 | if ((vars->phy_flags & PHY_OVER_CURRENT_FLAG) == 0) { |
| 12752 | netdev_err(bp->dev, "Error: Power fault on Port %d has" |
| 12753 | " been detected and the power to " |
| 12754 | "that SFP+ module has been removed" |
| 12755 | " to prevent failure of the card." |
| 12756 | " Please remove the SFP+ module and" |
| 12757 | " restart the system to clear this" |
| 12758 | " error.\n", |
| 12759 | params->port); |
| 12760 | vars->phy_flags |= PHY_OVER_CURRENT_FLAG; |
| 12761 | } |
| 12762 | } else |
| 12763 | vars->phy_flags &= ~PHY_OVER_CURRENT_FLAG; |
| 12764 | } |
| 12765 | |
| 12766 | static void bnx2x_analyze_link_error(struct link_params *params, |
| 12767 | struct link_vars *vars, u32 lss_status) |
| 12768 | { |
| 12769 | struct bnx2x *bp = params->bp; |
| 12770 | /* Compare new value with previous value */ |
| 12771 | u8 led_mode; |
| 12772 | u32 half_open_conn = (vars->phy_flags & PHY_HALF_OPEN_CONN_FLAG) > 0; |
| 12773 | |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 12774 | if ((lss_status ^ half_open_conn) == 0) |
| 12775 | return; |
| 12776 | |
| 12777 | /* If values differ */ |
| 12778 | DP(NETIF_MSG_LINK, "Link changed:%x %x->%x\n", vars->link_up, |
| 12779 | half_open_conn, lss_status); |
| 12780 | |
| 12781 | /* |
| 12782 | * a. Update shmem->link_status accordingly |
| 12783 | * b. Update link_vars->link_up |
| 12784 | */ |
| 12785 | if (lss_status) { |
Yaniv Rosner | de6f337 | 2011-08-02 22:59:25 +0000 | [diff] [blame] | 12786 | DP(NETIF_MSG_LINK, "Remote Fault detected !!!\n"); |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 12787 | vars->link_status &= ~LINK_STATUS_LINK_UP; |
| 12788 | vars->link_up = 0; |
| 12789 | vars->phy_flags |= PHY_HALF_OPEN_CONN_FLAG; |
| 12790 | /* |
| 12791 | * Set LED mode to off since the PHY doesn't know about these |
| 12792 | * errors |
| 12793 | */ |
| 12794 | led_mode = LED_MODE_OFF; |
| 12795 | } else { |
Yaniv Rosner | de6f337 | 2011-08-02 22:59:25 +0000 | [diff] [blame] | 12796 | DP(NETIF_MSG_LINK, "Remote Fault cleared\n"); |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 12797 | vars->link_status |= LINK_STATUS_LINK_UP; |
| 12798 | vars->link_up = 1; |
| 12799 | vars->phy_flags &= ~PHY_HALF_OPEN_CONN_FLAG; |
| 12800 | led_mode = LED_MODE_OPER; |
| 12801 | } |
| 12802 | /* Update the LED according to the link state */ |
| 12803 | bnx2x_set_led(params, vars, led_mode, SPEED_10000); |
| 12804 | |
| 12805 | /* Update link status in the shared memory */ |
| 12806 | bnx2x_update_mng(params, vars->link_status); |
| 12807 | |
| 12808 | /* C. Trigger General Attention */ |
| 12809 | vars->periodic_flags |= PERIODIC_FLAGS_LINK_EVENT; |
| 12810 | bnx2x_notify_link_changed(bp); |
| 12811 | } |
| 12812 | |
Yaniv Rosner | de6f337 | 2011-08-02 22:59:25 +0000 | [diff] [blame] | 12813 | /****************************************************************************** |
| 12814 | * Description: |
| 12815 | * This function checks for half opened connection change indication. |
| 12816 | * When such change occurs, it calls the bnx2x_analyze_link_error |
| 12817 | * to check if Remote Fault is set or cleared. Reception of remote fault |
| 12818 | * status message in the MAC indicates that the peer's MAC has detected |
| 12819 | * a fault, for example, due to break in the TX side of fiber. |
| 12820 | * |
| 12821 | ******************************************************************************/ |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 12822 | static void bnx2x_check_half_open_conn(struct link_params *params, |
| 12823 | struct link_vars *vars) |
| 12824 | { |
| 12825 | struct bnx2x *bp = params->bp; |
| 12826 | u32 lss_status = 0; |
| 12827 | u32 mac_base; |
| 12828 | /* In case link status is physically up @ 10G do */ |
| 12829 | if ((vars->phy_flags & PHY_PHYSICAL_LINK_FLAG) == 0) |
| 12830 | return; |
| 12831 | |
Yaniv Rosner | de6f337 | 2011-08-02 22:59:25 +0000 | [diff] [blame] | 12832 | if (CHIP_IS_E3(bp) && |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 12833 | (REG_RD(bp, MISC_REG_RESET_REG_2) & |
Yaniv Rosner | de6f337 | 2011-08-02 22:59:25 +0000 | [diff] [blame] | 12834 | (MISC_REGISTERS_RESET_REG_2_XMAC))) { |
| 12835 | /* Check E3 XMAC */ |
| 12836 | /* |
| 12837 | * Note that link speed cannot be queried here, since it may be |
| 12838 | * zero while link is down. In case UMAC is active, LSS will |
| 12839 | * simply not be set |
| 12840 | */ |
| 12841 | mac_base = (params->port) ? GRCBASE_XMAC1 : GRCBASE_XMAC0; |
| 12842 | |
| 12843 | /* Clear stick bits (Requires rising edge) */ |
| 12844 | REG_WR(bp, mac_base + XMAC_REG_CLEAR_RX_LSS_STATUS, 0); |
| 12845 | REG_WR(bp, mac_base + XMAC_REG_CLEAR_RX_LSS_STATUS, |
| 12846 | XMAC_CLEAR_RX_LSS_STATUS_REG_CLEAR_LOCAL_FAULT_STATUS | |
| 12847 | XMAC_CLEAR_RX_LSS_STATUS_REG_CLEAR_REMOTE_FAULT_STATUS); |
| 12848 | if (REG_RD(bp, mac_base + XMAC_REG_RX_LSS_STATUS)) |
| 12849 | lss_status = 1; |
| 12850 | |
| 12851 | bnx2x_analyze_link_error(params, vars, lss_status); |
| 12852 | } else if (REG_RD(bp, MISC_REG_RESET_REG_2) & |
| 12853 | (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << params->port)) { |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 12854 | /* Check E1X / E2 BMAC */ |
| 12855 | u32 lss_status_reg; |
| 12856 | u32 wb_data[2]; |
| 12857 | mac_base = params->port ? NIG_REG_INGRESS_BMAC1_MEM : |
| 12858 | NIG_REG_INGRESS_BMAC0_MEM; |
| 12859 | /* Read BIGMAC_REGISTER_RX_LSS_STATUS */ |
| 12860 | if (CHIP_IS_E2(bp)) |
| 12861 | lss_status_reg = BIGMAC2_REGISTER_RX_LSS_STAT; |
| 12862 | else |
| 12863 | lss_status_reg = BIGMAC_REGISTER_RX_LSS_STATUS; |
| 12864 | |
| 12865 | REG_RD_DMAE(bp, mac_base + lss_status_reg, wb_data, 2); |
| 12866 | lss_status = (wb_data[0] > 0); |
| 12867 | |
| 12868 | bnx2x_analyze_link_error(params, vars, lss_status); |
| 12869 | } |
| 12870 | } |
| 12871 | |
| 12872 | void bnx2x_period_func(struct link_params *params, struct link_vars *vars) |
| 12873 | { |
| 12874 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | de6f337 | 2011-08-02 22:59:25 +0000 | [diff] [blame] | 12875 | u16 phy_idx; |
Yaniv Rosner | de6f337 | 2011-08-02 22:59:25 +0000 | [diff] [blame] | 12876 | for (phy_idx = INT_PHY; phy_idx < MAX_PHYS; phy_idx++) { |
| 12877 | if (params->phy[phy_idx].flags & FLAGS_TX_ERROR_CHECK) { |
| 12878 | bnx2x_set_aer_mmd(params, ¶ms->phy[phy_idx]); |
| 12879 | bnx2x_check_half_open_conn(params, vars); |
| 12880 | break; |
| 12881 | } |
| 12882 | } |
| 12883 | |
Yaniv Rosner | a9077bf | 2011-10-27 05:09:46 +0000 | [diff] [blame] | 12884 | if (CHIP_IS_E3(bp)) { |
| 12885 | struct bnx2x_phy *phy = ¶ms->phy[INT_PHY]; |
| 12886 | bnx2x_set_aer_mmd(params, phy); |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 12887 | bnx2x_check_over_curr(params, vars); |
Yaniv Rosner | a9077bf | 2011-10-27 05:09:46 +0000 | [diff] [blame] | 12888 | bnx2x_warpcore_config_runtime(phy, params, vars); |
| 12889 | } |
| 12890 | |
Yaniv Rosner | 3deb816 | 2011-06-14 01:34:33 +0000 | [diff] [blame] | 12891 | } |
| 12892 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12893 | 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] | 12894 | { |
| 12895 | u8 phy_index; |
| 12896 | struct bnx2x_phy phy; |
| 12897 | for (phy_index = INT_PHY; phy_index < MAX_PHYS; |
| 12898 | phy_index++) { |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12899 | if (bnx2x_populate_phy(bp, phy_index, shmem_base, shmem2_base, |
Yaniv Rosner | d90d96b | 2010-09-07 11:41:04 +0000 | [diff] [blame] | 12900 | 0, &phy) != 0) { |
| 12901 | DP(NETIF_MSG_LINK, "populate phy failed\n"); |
| 12902 | return 0; |
| 12903 | } |
| 12904 | |
| 12905 | if (phy.flags & FLAGS_HW_LOCK_REQUIRED) |
| 12906 | return 1; |
| 12907 | } |
| 12908 | return 0; |
| 12909 | } |
| 12910 | |
| 12911 | u8 bnx2x_fan_failure_det_req(struct bnx2x *bp, |
| 12912 | u32 shmem_base, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12913 | u32 shmem2_base, |
Yaniv Rosner | d90d96b | 2010-09-07 11:41:04 +0000 | [diff] [blame] | 12914 | u8 port) |
| 12915 | { |
| 12916 | u8 phy_index, fan_failure_det_req = 0; |
| 12917 | struct bnx2x_phy phy; |
| 12918 | for (phy_index = EXT_PHY1; phy_index < MAX_PHYS; |
| 12919 | phy_index++) { |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 12920 | if (bnx2x_populate_phy(bp, phy_index, shmem_base, shmem2_base, |
Yaniv Rosner | d90d96b | 2010-09-07 11:41:04 +0000 | [diff] [blame] | 12921 | port, &phy) |
| 12922 | != 0) { |
| 12923 | DP(NETIF_MSG_LINK, "populate phy failed\n"); |
| 12924 | return 0; |
| 12925 | } |
| 12926 | fan_failure_det_req |= (phy.flags & |
| 12927 | FLAGS_FAN_FAILURE_DET_REQ); |
| 12928 | } |
| 12929 | return fan_failure_det_req; |
| 12930 | } |
| 12931 | |
| 12932 | void bnx2x_hw_reset_phy(struct link_params *params) |
| 12933 | { |
| 12934 | u8 phy_index; |
Yaniv Rosner | 985848f | 2011-07-05 01:06:48 +0000 | [diff] [blame] | 12935 | struct bnx2x *bp = params->bp; |
| 12936 | bnx2x_update_mng(params, 0); |
| 12937 | bnx2x_bits_dis(bp, NIG_REG_MASK_INTERRUPT_PORT0 + params->port*4, |
| 12938 | (NIG_MASK_XGXS0_LINK_STATUS | |
| 12939 | NIG_MASK_XGXS0_LINK10G | |
| 12940 | NIG_MASK_SERDES0_LINK_STATUS | |
| 12941 | NIG_MASK_MI_INT)); |
| 12942 | |
| 12943 | for (phy_index = INT_PHY; phy_index < MAX_PHYS; |
Yaniv Rosner | d90d96b | 2010-09-07 11:41:04 +0000 | [diff] [blame] | 12944 | phy_index++) { |
| 12945 | if (params->phy[phy_index].hw_reset) { |
| 12946 | params->phy[phy_index].hw_reset( |
| 12947 | ¶ms->phy[phy_index], |
| 12948 | params); |
| 12949 | params->phy[phy_index] = phy_null; |
| 12950 | } |
| 12951 | } |
| 12952 | } |
Yaniv Rosner | 020c7e3 | 2011-05-31 21:28:43 +0000 | [diff] [blame] | 12953 | |
| 12954 | void bnx2x_init_mod_abs_int(struct bnx2x *bp, struct link_vars *vars, |
| 12955 | u32 chip_id, u32 shmem_base, u32 shmem2_base, |
| 12956 | u8 port) |
| 12957 | { |
| 12958 | u8 gpio_num = 0xff, gpio_port = 0xff, phy_index; |
| 12959 | u32 val; |
| 12960 | u32 offset, aeu_mask, swap_val, swap_override, sync_offset; |
Yaniv Rosner | 3c9ada2 | 2011-06-14 01:34:12 +0000 | [diff] [blame] | 12961 | if (CHIP_IS_E3(bp)) { |
| 12962 | if (bnx2x_get_mod_abs_int_cfg(bp, chip_id, |
| 12963 | shmem_base, |
| 12964 | port, |
| 12965 | &gpio_num, |
| 12966 | &gpio_port) != 0) |
| 12967 | return; |
| 12968 | } else { |
Yaniv Rosner | 020c7e3 | 2011-05-31 21:28:43 +0000 | [diff] [blame] | 12969 | struct bnx2x_phy phy; |
| 12970 | for (phy_index = EXT_PHY1; phy_index < MAX_PHYS; |
| 12971 | phy_index++) { |
| 12972 | if (bnx2x_populate_phy(bp, phy_index, shmem_base, |
| 12973 | shmem2_base, port, &phy) |
| 12974 | != 0) { |
| 12975 | DP(NETIF_MSG_LINK, "populate phy failed\n"); |
| 12976 | return; |
| 12977 | } |
| 12978 | if (phy.type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726) { |
| 12979 | gpio_num = MISC_REGISTERS_GPIO_3; |
| 12980 | gpio_port = port; |
| 12981 | break; |
| 12982 | } |
| 12983 | } |
| 12984 | } |
| 12985 | |
| 12986 | if (gpio_num == 0xff) |
| 12987 | return; |
| 12988 | |
| 12989 | /* Set GPIO3 to trigger SFP+ module insertion/removal */ |
| 12990 | bnx2x_set_gpio(bp, gpio_num, MISC_REGISTERS_GPIO_INPUT_HI_Z, gpio_port); |
| 12991 | |
| 12992 | swap_val = REG_RD(bp, NIG_REG_PORT_SWAP); |
| 12993 | swap_override = REG_RD(bp, NIG_REG_STRAP_OVERRIDE); |
| 12994 | gpio_port ^= (swap_val && swap_override); |
| 12995 | |
| 12996 | vars->aeu_int_mask = AEU_INPUTS_ATTN_BITS_GPIO0_FUNCTION_0 << |
| 12997 | (gpio_num + (gpio_port << 2)); |
| 12998 | |
| 12999 | sync_offset = shmem_base + |
| 13000 | offsetof(struct shmem_region, |
| 13001 | dev_info.port_hw_config[port].aeu_int_mask); |
| 13002 | REG_WR(bp, sync_offset, vars->aeu_int_mask); |
| 13003 | |
| 13004 | DP(NETIF_MSG_LINK, "Setting MOD_ABS (GPIO%d_P%d) AEU to 0x%x\n", |
| 13005 | gpio_num, gpio_port, vars->aeu_int_mask); |
| 13006 | |
| 13007 | if (port == 0) |
| 13008 | offset = MISC_REG_AEU_ENABLE1_FUNC_0_OUT_0; |
| 13009 | else |
| 13010 | offset = MISC_REG_AEU_ENABLE1_FUNC_1_OUT_0; |
| 13011 | |
| 13012 | /* Open appropriate AEU for interrupts */ |
| 13013 | aeu_mask = REG_RD(bp, offset); |
| 13014 | aeu_mask |= vars->aeu_int_mask; |
| 13015 | REG_WR(bp, offset, aeu_mask); |
| 13016 | |
| 13017 | /* Enable the GPIO to trigger interrupt */ |
| 13018 | val = REG_RD(bp, MISC_REG_GPIO_EVENT_EN); |
| 13019 | val |= 1 << (gpio_num + (gpio_port << 2)); |
| 13020 | REG_WR(bp, MISC_REG_GPIO_EVENT_EN, val); |
| 13021 | } |