Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1 | /* Copyright 2008-2011 Broadcom Corporation |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2 | * |
| 3 | * Unless you and Broadcom execute a separate written software license |
| 4 | * agreement governing use of this software, this software is licensed to you |
| 5 | * under the terms of the GNU General Public License version 2, available |
| 6 | * at http://www.gnu.org/licenses/old-licenses/gpl-2.0.html (the "GPL"). |
| 7 | * |
| 8 | * Notwithstanding the above, under no circumstances may you combine this |
| 9 | * software in any way with any other Broadcom software provided under a |
| 10 | * license other than the GPL, without Broadcom's express prior written |
| 11 | * consent. |
| 12 | * |
| 13 | * Written by Yaniv Rosner |
| 14 | * |
| 15 | */ |
| 16 | |
Joe Perches | 7995c64 | 2010-02-17 15:01:52 +0000 | [diff] [blame] | 17 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 18 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 19 | #include <linux/kernel.h> |
| 20 | #include <linux/errno.h> |
| 21 | #include <linux/pci.h> |
| 22 | #include <linux/netdevice.h> |
| 23 | #include <linux/delay.h> |
| 24 | #include <linux/ethtool.h> |
| 25 | #include <linux/mutex.h> |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 26 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 27 | #include "bnx2x.h" |
| 28 | |
| 29 | /********************************************************/ |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 30 | #define ETH_HLEN 14 |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 31 | /* L2 header size + 2*VLANs (8 bytes) + LLC SNAP (8 bytes) */ |
| 32 | #define ETH_OVREHEAD (ETH_HLEN + 8 + 8) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 33 | #define ETH_MIN_PACKET_SIZE 60 |
| 34 | #define ETH_MAX_PACKET_SIZE 1500 |
| 35 | #define ETH_MAX_JUMBO_PACKET_SIZE 9600 |
| 36 | #define MDIO_ACCESS_TIMEOUT 1000 |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 37 | #define BMAC_CONTROL_RX_ENABLE 2 |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 38 | |
| 39 | /***********************************************************/ |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 40 | /* Shortcut definitions */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 41 | /***********************************************************/ |
| 42 | |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 43 | #define NIG_LATCH_BC_ENABLE_MI_INT 0 |
| 44 | |
| 45 | #define NIG_STATUS_EMAC0_MI_INT \ |
| 46 | NIG_STATUS_INTERRUPT_PORT0_REG_STATUS_EMAC0_MISC_MI_INT |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 47 | #define NIG_STATUS_XGXS0_LINK10G \ |
| 48 | NIG_STATUS_INTERRUPT_PORT0_REG_STATUS_XGXS0_LINK10G |
| 49 | #define NIG_STATUS_XGXS0_LINK_STATUS \ |
| 50 | NIG_STATUS_INTERRUPT_PORT0_REG_STATUS_XGXS0_LINK_STATUS |
| 51 | #define NIG_STATUS_XGXS0_LINK_STATUS_SIZE \ |
| 52 | NIG_STATUS_INTERRUPT_PORT0_REG_STATUS_XGXS0_LINK_STATUS_SIZE |
| 53 | #define NIG_STATUS_SERDES0_LINK_STATUS \ |
| 54 | NIG_STATUS_INTERRUPT_PORT0_REG_STATUS_SERDES0_LINK_STATUS |
| 55 | #define NIG_MASK_MI_INT \ |
| 56 | NIG_MASK_INTERRUPT_PORT0_REG_MASK_EMAC0_MISC_MI_INT |
| 57 | #define NIG_MASK_XGXS0_LINK10G \ |
| 58 | NIG_MASK_INTERRUPT_PORT0_REG_MASK_XGXS0_LINK10G |
| 59 | #define NIG_MASK_XGXS0_LINK_STATUS \ |
| 60 | NIG_MASK_INTERRUPT_PORT0_REG_MASK_XGXS0_LINK_STATUS |
| 61 | #define NIG_MASK_SERDES0_LINK_STATUS \ |
| 62 | NIG_MASK_INTERRUPT_PORT0_REG_MASK_SERDES0_LINK_STATUS |
| 63 | |
| 64 | #define MDIO_AN_CL73_OR_37_COMPLETE \ |
| 65 | (MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_AUTONEG_COMPLETE | \ |
| 66 | MDIO_GP_STATUS_TOP_AN_STATUS1_CL37_AUTONEG_COMPLETE) |
| 67 | |
| 68 | #define XGXS_RESET_BITS \ |
| 69 | (MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_XGXS0_RSTB_HW | \ |
| 70 | MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_XGXS0_IDDQ | \ |
| 71 | MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_XGXS0_PWRDWN | \ |
| 72 | MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_XGXS0_PWRDWN_SD | \ |
| 73 | MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_XGXS0_TXD_FIFO_RSTB) |
| 74 | |
| 75 | #define SERDES_RESET_BITS \ |
| 76 | (MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_SERDES0_RSTB_HW | \ |
| 77 | MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_SERDES0_IDDQ | \ |
| 78 | MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_SERDES0_PWRDWN | \ |
| 79 | MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_SERDES0_PWRDWN_SD) |
| 80 | |
| 81 | #define AUTONEG_CL37 SHARED_HW_CFG_AN_ENABLE_CL37 |
| 82 | #define AUTONEG_CL73 SHARED_HW_CFG_AN_ENABLE_CL73 |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 83 | #define AUTONEG_BAM SHARED_HW_CFG_AN_ENABLE_BAM |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 84 | #define AUTONEG_PARALLEL \ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 85 | SHARED_HW_CFG_AN_ENABLE_PARALLEL_DETECTION |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 86 | #define AUTONEG_SGMII_FIBER_AUTODET \ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 87 | SHARED_HW_CFG_AN_EN_SGMII_FIBER_AUTO_DETECT |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 88 | #define AUTONEG_REMOTE_PHY SHARED_HW_CFG_AN_ENABLE_REMOTE_PHY |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 89 | |
| 90 | #define GP_STATUS_PAUSE_RSOLUTION_TXSIDE \ |
| 91 | MDIO_GP_STATUS_TOP_AN_STATUS1_PAUSE_RSOLUTION_TXSIDE |
| 92 | #define GP_STATUS_PAUSE_RSOLUTION_RXSIDE \ |
| 93 | MDIO_GP_STATUS_TOP_AN_STATUS1_PAUSE_RSOLUTION_RXSIDE |
| 94 | #define GP_STATUS_SPEED_MASK \ |
| 95 | MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_MASK |
| 96 | #define GP_STATUS_10M MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_10M |
| 97 | #define GP_STATUS_100M MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_100M |
| 98 | #define GP_STATUS_1G MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_1G |
| 99 | #define GP_STATUS_2_5G MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_2_5G |
| 100 | #define GP_STATUS_5G MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_5G |
| 101 | #define GP_STATUS_6G MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_6G |
| 102 | #define GP_STATUS_10G_HIG \ |
| 103 | MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_10G_HIG |
| 104 | #define GP_STATUS_10G_CX4 \ |
| 105 | MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_10G_CX4 |
| 106 | #define GP_STATUS_12G_HIG \ |
| 107 | MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_12G_HIG |
| 108 | #define GP_STATUS_12_5G MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_12_5G |
| 109 | #define GP_STATUS_13G MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_13G |
| 110 | #define GP_STATUS_15G MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_15G |
| 111 | #define GP_STATUS_16G MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_16G |
| 112 | #define GP_STATUS_1G_KX MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_1G_KX |
| 113 | #define GP_STATUS_10G_KX4 \ |
| 114 | MDIO_GP_STATUS_TOP_AN_STATUS1_ACTUAL_SPEED_10G_KX4 |
| 115 | |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 116 | #define LINK_10THD LINK_STATUS_SPEED_AND_DUPLEX_10THD |
| 117 | #define LINK_10TFD LINK_STATUS_SPEED_AND_DUPLEX_10TFD |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 118 | #define LINK_100TXHD LINK_STATUS_SPEED_AND_DUPLEX_100TXHD |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 119 | #define LINK_100T4 LINK_STATUS_SPEED_AND_DUPLEX_100T4 |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 120 | #define LINK_100TXFD LINK_STATUS_SPEED_AND_DUPLEX_100TXFD |
| 121 | #define LINK_1000THD LINK_STATUS_SPEED_AND_DUPLEX_1000THD |
| 122 | #define LINK_1000TFD LINK_STATUS_SPEED_AND_DUPLEX_1000TFD |
| 123 | #define LINK_1000XFD LINK_STATUS_SPEED_AND_DUPLEX_1000XFD |
| 124 | #define LINK_2500THD LINK_STATUS_SPEED_AND_DUPLEX_2500THD |
| 125 | #define LINK_2500TFD LINK_STATUS_SPEED_AND_DUPLEX_2500TFD |
| 126 | #define LINK_2500XFD LINK_STATUS_SPEED_AND_DUPLEX_2500XFD |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 127 | #define LINK_10GTFD LINK_STATUS_SPEED_AND_DUPLEX_10GTFD |
| 128 | #define LINK_10GXFD LINK_STATUS_SPEED_AND_DUPLEX_10GXFD |
| 129 | #define LINK_12GTFD LINK_STATUS_SPEED_AND_DUPLEX_12GTFD |
| 130 | #define LINK_12GXFD LINK_STATUS_SPEED_AND_DUPLEX_12GXFD |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 131 | #define LINK_12_5GTFD LINK_STATUS_SPEED_AND_DUPLEX_12_5GTFD |
| 132 | #define LINK_12_5GXFD LINK_STATUS_SPEED_AND_DUPLEX_12_5GXFD |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 133 | #define LINK_13GTFD LINK_STATUS_SPEED_AND_DUPLEX_13GTFD |
| 134 | #define LINK_13GXFD LINK_STATUS_SPEED_AND_DUPLEX_13GXFD |
| 135 | #define LINK_15GTFD LINK_STATUS_SPEED_AND_DUPLEX_15GTFD |
| 136 | #define LINK_15GXFD LINK_STATUS_SPEED_AND_DUPLEX_15GXFD |
| 137 | #define LINK_16GTFD LINK_STATUS_SPEED_AND_DUPLEX_16GTFD |
| 138 | #define LINK_16GXFD LINK_STATUS_SPEED_AND_DUPLEX_16GXFD |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 139 | |
| 140 | #define PHY_XGXS_FLAG 0x1 |
| 141 | #define PHY_SGMII_FLAG 0x2 |
| 142 | #define PHY_SERDES_FLAG 0x4 |
| 143 | |
Eilon Greenstein | 589abe3 | 2009-02-12 08:36:55 +0000 | [diff] [blame] | 144 | /* */ |
| 145 | #define SFP_EEPROM_CON_TYPE_ADDR 0x2 |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 146 | #define SFP_EEPROM_CON_TYPE_VAL_LC 0x7 |
Eilon Greenstein | 589abe3 | 2009-02-12 08:36:55 +0000 | [diff] [blame] | 147 | #define SFP_EEPROM_CON_TYPE_VAL_COPPER 0x21 |
| 148 | |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 149 | |
| 150 | #define SFP_EEPROM_COMP_CODE_ADDR 0x3 |
| 151 | #define SFP_EEPROM_COMP_CODE_SR_MASK (1<<4) |
| 152 | #define SFP_EEPROM_COMP_CODE_LR_MASK (1<<5) |
| 153 | #define SFP_EEPROM_COMP_CODE_LRM_MASK (1<<6) |
| 154 | |
Eilon Greenstein | 589abe3 | 2009-02-12 08:36:55 +0000 | [diff] [blame] | 155 | #define SFP_EEPROM_FC_TX_TECH_ADDR 0x8 |
| 156 | #define SFP_EEPROM_FC_TX_TECH_BITMASK_COPPER_PASSIVE 0x4 |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 157 | #define SFP_EEPROM_FC_TX_TECH_BITMASK_COPPER_ACTIVE 0x8 |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 158 | |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 159 | #define SFP_EEPROM_OPTIONS_ADDR 0x40 |
Eilon Greenstein | 589abe3 | 2009-02-12 08:36:55 +0000 | [diff] [blame] | 160 | #define SFP_EEPROM_OPTIONS_LINEAR_RX_OUT_MASK 0x1 |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 161 | #define SFP_EEPROM_OPTIONS_SIZE 2 |
Eilon Greenstein | 589abe3 | 2009-02-12 08:36:55 +0000 | [diff] [blame] | 162 | |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 163 | #define EDC_MODE_LINEAR 0x0022 |
| 164 | #define EDC_MODE_LIMITING 0x0044 |
| 165 | #define EDC_MODE_PASSIVE_DAC 0x0055 |
Eilon Greenstein | 589abe3 | 2009-02-12 08:36:55 +0000 | [diff] [blame] | 166 | |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 167 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 168 | #define ETS_BW_LIMIT_CREDIT_UPPER_BOUND (0x5000) |
| 169 | #define ETS_BW_LIMIT_CREDIT_WEIGHT (0x5000) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 170 | /**********************************************************/ |
| 171 | /* INTERFACE */ |
| 172 | /**********************************************************/ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 173 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 174 | #define CL22_WR_OVER_CL45(_bp, _phy, _bank, _addr, _val) \ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 175 | bnx2x_cl45_write(_bp, _phy, \ |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 176 | (_phy)->def_md_devad, \ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 177 | (_bank + (_addr & 0xf)), \ |
| 178 | _val) |
| 179 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 180 | #define CL22_RD_OVER_CL45(_bp, _phy, _bank, _addr, _val) \ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 181 | bnx2x_cl45_read(_bp, _phy, \ |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 182 | (_phy)->def_md_devad, \ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 183 | (_bank + (_addr & 0xf)), \ |
| 184 | _val) |
| 185 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 186 | static u32 bnx2x_bits_en(struct bnx2x *bp, u32 reg, u32 bits) |
| 187 | { |
| 188 | u32 val = REG_RD(bp, reg); |
| 189 | |
| 190 | val |= bits; |
| 191 | REG_WR(bp, reg, val); |
| 192 | return val; |
| 193 | } |
| 194 | |
| 195 | static u32 bnx2x_bits_dis(struct bnx2x *bp, u32 reg, u32 bits) |
| 196 | { |
| 197 | u32 val = REG_RD(bp, reg); |
| 198 | |
| 199 | val &= ~bits; |
| 200 | REG_WR(bp, reg, val); |
| 201 | return val; |
| 202 | } |
| 203 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 204 | /******************************************************************/ |
| 205 | /* ETS section */ |
| 206 | /******************************************************************/ |
| 207 | void bnx2x_ets_disabled(struct link_params *params) |
| 208 | { |
| 209 | /* ETS disabled configuration*/ |
| 210 | struct bnx2x *bp = params->bp; |
| 211 | |
| 212 | DP(NETIF_MSG_LINK, "ETS disabled configuration\n"); |
| 213 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 214 | /* |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 215 | * mapping between entry priority to client number (0,1,2 -debug and |
| 216 | * management clients, 3 - COS0 client, 4 - COS client)(HIGHEST) |
| 217 | * 3bits client num. |
| 218 | * PRI4 | PRI3 | PRI2 | PRI1 | PRI0 |
| 219 | * cos1-100 cos0-011 dbg1-010 dbg0-001 MCP-000 |
| 220 | */ |
| 221 | |
| 222 | REG_WR(bp, NIG_REG_P0_TX_ARB_PRIORITY_CLIENT, 0x4688); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 223 | /* |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 224 | * Bitmap of 5bits length. Each bit specifies whether the entry behaves |
| 225 | * as strict. Bits 0,1,2 - debug and management entries, 3 - |
| 226 | * COS0 entry, 4 - COS1 entry. |
| 227 | * COS1 | COS0 | DEBUG1 | DEBUG0 | MGMT |
| 228 | * bit4 bit3 bit2 bit1 bit0 |
| 229 | * MCP and debug are strict |
| 230 | */ |
| 231 | |
| 232 | REG_WR(bp, NIG_REG_P0_TX_ARB_CLIENT_IS_STRICT, 0x7); |
| 233 | /* defines which entries (clients) are subjected to WFQ arbitration */ |
| 234 | REG_WR(bp, NIG_REG_P0_TX_ARB_CLIENT_IS_SUBJECT2WFQ, 0); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 235 | /* |
| 236 | * For strict priority entries defines the number of consecutive |
| 237 | * slots for the highest priority. |
| 238 | */ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 239 | 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] | 240 | /* |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 241 | * mapping between the CREDIT_WEIGHT registers and actual client |
| 242 | * numbers |
| 243 | */ |
| 244 | REG_WR(bp, NIG_REG_P0_TX_ARB_CLIENT_CREDIT_MAP, 0); |
| 245 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_0, 0); |
| 246 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_1, 0); |
| 247 | |
| 248 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_0, 0); |
| 249 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_1, 0); |
| 250 | REG_WR(bp, PBF_REG_HIGH_PRIORITY_COS_NUM, 0); |
| 251 | /* ETS mode disable */ |
| 252 | REG_WR(bp, PBF_REG_ETS_ENABLED, 0); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 253 | /* |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 254 | * If ETS mode is enabled (there is no strict priority) defines a WFQ |
| 255 | * weight for COS0/COS1. |
| 256 | */ |
| 257 | REG_WR(bp, PBF_REG_COS0_WEIGHT, 0x2710); |
| 258 | REG_WR(bp, PBF_REG_COS1_WEIGHT, 0x2710); |
| 259 | /* Upper bound that COS0_WEIGHT can reach in the WFQ arbiter */ |
| 260 | REG_WR(bp, PBF_REG_COS0_UPPER_BOUND, 0x989680); |
| 261 | REG_WR(bp, PBF_REG_COS1_UPPER_BOUND, 0x989680); |
| 262 | /* Defines the number of consecutive slots for the strict priority */ |
| 263 | REG_WR(bp, PBF_REG_NUM_STRICT_ARB_SLOTS, 0); |
| 264 | } |
| 265 | |
Yaniv Rosner | 65a001b | 2011-01-31 04:22:03 +0000 | [diff] [blame^] | 266 | static void bnx2x_ets_bw_limit_common(const struct link_params *params) |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 267 | { |
| 268 | /* ETS disabled configuration */ |
| 269 | struct bnx2x *bp = params->bp; |
| 270 | DP(NETIF_MSG_LINK, "ETS enabled BW limit configuration\n"); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 271 | /* |
| 272 | * defines which entries (clients) are subjected to WFQ arbitration |
| 273 | * COS0 0x8 |
| 274 | * COS1 0x10 |
| 275 | */ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 276 | REG_WR(bp, NIG_REG_P0_TX_ARB_CLIENT_IS_SUBJECT2WFQ, 0x18); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 277 | /* |
| 278 | * mapping between the ARB_CREDIT_WEIGHT registers and actual |
| 279 | * client numbers (WEIGHT_0 does not actually have to represent |
| 280 | * client 0) |
| 281 | * PRI4 | PRI3 | PRI2 | PRI1 | PRI0 |
| 282 | * cos1-001 cos0-000 dbg1-100 dbg0-011 MCP-010 |
| 283 | */ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 284 | REG_WR(bp, NIG_REG_P0_TX_ARB_CLIENT_CREDIT_MAP, 0x111A); |
| 285 | |
| 286 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_0, |
| 287 | ETS_BW_LIMIT_CREDIT_UPPER_BOUND); |
| 288 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_1, |
| 289 | ETS_BW_LIMIT_CREDIT_UPPER_BOUND); |
| 290 | |
| 291 | /* ETS mode enabled*/ |
| 292 | REG_WR(bp, PBF_REG_ETS_ENABLED, 1); |
| 293 | |
| 294 | /* Defines the number of consecutive slots for the strict priority */ |
| 295 | REG_WR(bp, PBF_REG_NUM_STRICT_ARB_SLOTS, 0); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 296 | /* |
| 297 | * Bitmap of 5bits length. Each bit specifies whether the entry behaves |
| 298 | * as strict. Bits 0,1,2 - debug and management entries, 3 - COS0 |
| 299 | * entry, 4 - COS1 entry. |
| 300 | * COS1 | COS0 | DEBUG21 | DEBUG0 | MGMT |
| 301 | * bit4 bit3 bit2 bit1 bit0 |
| 302 | * MCP and debug are strict |
| 303 | */ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 304 | REG_WR(bp, NIG_REG_P0_TX_ARB_CLIENT_IS_STRICT, 0x7); |
| 305 | |
| 306 | /* Upper bound that COS0_WEIGHT can reach in the WFQ arbiter.*/ |
| 307 | REG_WR(bp, PBF_REG_COS0_UPPER_BOUND, |
| 308 | ETS_BW_LIMIT_CREDIT_UPPER_BOUND); |
| 309 | REG_WR(bp, PBF_REG_COS1_UPPER_BOUND, |
| 310 | ETS_BW_LIMIT_CREDIT_UPPER_BOUND); |
| 311 | } |
| 312 | |
| 313 | void bnx2x_ets_bw_limit(const struct link_params *params, const u32 cos0_bw, |
| 314 | const u32 cos1_bw) |
| 315 | { |
| 316 | /* ETS disabled configuration*/ |
| 317 | struct bnx2x *bp = params->bp; |
| 318 | const u32 total_bw = cos0_bw + cos1_bw; |
| 319 | u32 cos0_credit_weight = 0; |
| 320 | u32 cos1_credit_weight = 0; |
| 321 | |
| 322 | DP(NETIF_MSG_LINK, "ETS enabled BW limit configuration\n"); |
| 323 | |
| 324 | if ((0 == total_bw) || |
| 325 | (0 == cos0_bw) || |
| 326 | (0 == cos1_bw)) { |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 327 | DP(NETIF_MSG_LINK, "Total BW can't be zero\n"); |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 328 | return; |
| 329 | } |
| 330 | |
| 331 | cos0_credit_weight = (cos0_bw * ETS_BW_LIMIT_CREDIT_WEIGHT)/ |
| 332 | total_bw; |
| 333 | cos1_credit_weight = (cos1_bw * ETS_BW_LIMIT_CREDIT_WEIGHT)/ |
| 334 | total_bw; |
| 335 | |
| 336 | bnx2x_ets_bw_limit_common(params); |
| 337 | |
| 338 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_0, cos0_credit_weight); |
| 339 | REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_1, cos1_credit_weight); |
| 340 | |
| 341 | REG_WR(bp, PBF_REG_COS0_WEIGHT, cos0_credit_weight); |
| 342 | REG_WR(bp, PBF_REG_COS1_WEIGHT, cos1_credit_weight); |
| 343 | } |
| 344 | |
| 345 | u8 bnx2x_ets_strict(const struct link_params *params, const u8 strict_cos) |
| 346 | { |
| 347 | /* ETS disabled configuration*/ |
| 348 | struct bnx2x *bp = params->bp; |
| 349 | u32 val = 0; |
| 350 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 351 | DP(NETIF_MSG_LINK, "ETS enabled strict configuration\n"); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 352 | /* |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 353 | * Bitmap of 5bits length. Each bit specifies whether the entry behaves |
| 354 | * as strict. Bits 0,1,2 - debug and management entries, |
| 355 | * 3 - COS0 entry, 4 - COS1 entry. |
| 356 | * COS1 | COS0 | DEBUG21 | DEBUG0 | MGMT |
| 357 | * bit4 bit3 bit2 bit1 bit0 |
| 358 | * MCP and debug are strict |
| 359 | */ |
| 360 | REG_WR(bp, NIG_REG_P0_TX_ARB_CLIENT_IS_STRICT, 0x1F); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 361 | /* |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 362 | * For strict priority entries defines the number of consecutive slots |
| 363 | * for the highest priority. |
| 364 | */ |
| 365 | REG_WR(bp, NIG_REG_P0_TX_ARB_NUM_STRICT_ARB_SLOTS, 0x100); |
| 366 | /* ETS mode disable */ |
| 367 | REG_WR(bp, PBF_REG_ETS_ENABLED, 0); |
| 368 | /* Defines the number of consecutive slots for the strict priority */ |
| 369 | REG_WR(bp, PBF_REG_NUM_STRICT_ARB_SLOTS, 0x100); |
| 370 | |
| 371 | /* Defines the number of consecutive slots for the strict priority */ |
| 372 | REG_WR(bp, PBF_REG_HIGH_PRIORITY_COS_NUM, strict_cos); |
| 373 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 374 | /* |
| 375 | * mapping between entry priority to client number (0,1,2 -debug and |
| 376 | * management clients, 3 - COS0 client, 4 - COS client)(HIGHEST) |
| 377 | * 3bits client num. |
| 378 | * PRI4 | PRI3 | PRI2 | PRI1 | PRI0 |
| 379 | * dbg0-010 dbg1-001 cos1-100 cos0-011 MCP-000 |
| 380 | * dbg0-010 dbg1-001 cos0-011 cos1-100 MCP-000 |
| 381 | */ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 382 | val = (0 == strict_cos) ? 0x2318 : 0x22E0; |
| 383 | REG_WR(bp, NIG_REG_P0_TX_ARB_PRIORITY_CLIENT, val); |
| 384 | |
| 385 | return 0; |
| 386 | } |
| 387 | /******************************************************************/ |
| 388 | /* ETS section */ |
| 389 | /******************************************************************/ |
| 390 | |
| 391 | static void bnx2x_bmac2_get_pfc_stat(struct link_params *params, |
| 392 | u32 pfc_frames_sent[2], |
| 393 | u32 pfc_frames_received[2]) |
| 394 | { |
| 395 | /* Read pfc statistic */ |
| 396 | struct bnx2x *bp = params->bp; |
| 397 | u32 bmac_addr = params->port ? NIG_REG_INGRESS_BMAC1_MEM : |
| 398 | NIG_REG_INGRESS_BMAC0_MEM; |
| 399 | |
| 400 | DP(NETIF_MSG_LINK, "pfc statistic read from BMAC\n"); |
| 401 | |
| 402 | REG_RD_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_TX_STAT_GTPP, |
| 403 | pfc_frames_sent, 2); |
| 404 | |
| 405 | REG_RD_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_RX_STAT_GRPP, |
| 406 | pfc_frames_received, 2); |
| 407 | |
| 408 | } |
| 409 | static void bnx2x_emac_get_pfc_stat(struct link_params *params, |
| 410 | u32 pfc_frames_sent[2], |
| 411 | u32 pfc_frames_received[2]) |
| 412 | { |
| 413 | /* Read pfc statistic */ |
| 414 | struct bnx2x *bp = params->bp; |
| 415 | u32 emac_base = params->port ? GRCBASE_EMAC1 : GRCBASE_EMAC0; |
| 416 | u32 val_xon = 0; |
| 417 | u32 val_xoff = 0; |
| 418 | |
| 419 | DP(NETIF_MSG_LINK, "pfc statistic read from EMAC\n"); |
| 420 | |
| 421 | /* PFC received frames */ |
| 422 | val_xoff = REG_RD(bp, emac_base + |
| 423 | EMAC_REG_RX_PFC_STATS_XOFF_RCVD); |
| 424 | val_xoff &= EMAC_REG_RX_PFC_STATS_XOFF_RCVD_COUNT; |
| 425 | val_xon = REG_RD(bp, emac_base + EMAC_REG_RX_PFC_STATS_XON_RCVD); |
| 426 | val_xon &= EMAC_REG_RX_PFC_STATS_XON_RCVD_COUNT; |
| 427 | |
| 428 | pfc_frames_received[0] = val_xon + val_xoff; |
| 429 | |
| 430 | /* PFC received sent */ |
| 431 | val_xoff = REG_RD(bp, emac_base + |
| 432 | EMAC_REG_RX_PFC_STATS_XOFF_SENT); |
| 433 | val_xoff &= EMAC_REG_RX_PFC_STATS_XOFF_SENT_COUNT; |
| 434 | val_xon = REG_RD(bp, emac_base + EMAC_REG_RX_PFC_STATS_XON_SENT); |
| 435 | val_xon &= EMAC_REG_RX_PFC_STATS_XON_SENT_COUNT; |
| 436 | |
| 437 | pfc_frames_sent[0] = val_xon + val_xoff; |
| 438 | } |
| 439 | |
| 440 | void bnx2x_pfc_statistic(struct link_params *params, struct link_vars *vars, |
| 441 | u32 pfc_frames_sent[2], |
| 442 | u32 pfc_frames_received[2]) |
| 443 | { |
| 444 | /* Read pfc statistic */ |
| 445 | struct bnx2x *bp = params->bp; |
| 446 | u32 val = 0; |
| 447 | DP(NETIF_MSG_LINK, "pfc statistic\n"); |
| 448 | |
| 449 | if (!vars->link_up) |
| 450 | return; |
| 451 | |
| 452 | val = REG_RD(bp, MISC_REG_RESET_REG_2); |
| 453 | if ((val & (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << params->port)) |
| 454 | == 0) { |
| 455 | DP(NETIF_MSG_LINK, "About to read stats from EMAC\n"); |
| 456 | bnx2x_emac_get_pfc_stat(params, pfc_frames_sent, |
| 457 | pfc_frames_received); |
| 458 | } else { |
| 459 | DP(NETIF_MSG_LINK, "About to read stats from BMAC\n"); |
| 460 | bnx2x_bmac2_get_pfc_stat(params, pfc_frames_sent, |
| 461 | pfc_frames_received); |
| 462 | } |
| 463 | } |
| 464 | /******************************************************************/ |
| 465 | /* MAC/PBF section */ |
| 466 | /******************************************************************/ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 467 | static void bnx2x_emac_init(struct link_params *params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 468 | struct link_vars *vars) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 469 | { |
| 470 | /* reset and unreset the emac core */ |
| 471 | struct bnx2x *bp = params->bp; |
| 472 | u8 port = params->port; |
| 473 | u32 emac_base = port ? GRCBASE_EMAC1 : GRCBASE_EMAC0; |
| 474 | u32 val; |
| 475 | u16 timeout; |
| 476 | |
| 477 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_CLEAR, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 478 | (MISC_REGISTERS_RESET_REG_2_RST_EMAC0_HARD_CORE << port)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 479 | udelay(5); |
| 480 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_SET, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 481 | (MISC_REGISTERS_RESET_REG_2_RST_EMAC0_HARD_CORE << port)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 482 | |
| 483 | /* init emac - use read-modify-write */ |
| 484 | /* self clear reset */ |
| 485 | val = REG_RD(bp, emac_base + EMAC_REG_EMAC_MODE); |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 486 | EMAC_WR(bp, EMAC_REG_EMAC_MODE, (val | EMAC_MODE_RESET)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 487 | |
| 488 | timeout = 200; |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 489 | do { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 490 | val = REG_RD(bp, emac_base + EMAC_REG_EMAC_MODE); |
| 491 | DP(NETIF_MSG_LINK, "EMAC reset reg is %u\n", val); |
| 492 | if (!timeout) { |
| 493 | DP(NETIF_MSG_LINK, "EMAC timeout!\n"); |
| 494 | return; |
| 495 | } |
| 496 | timeout--; |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 497 | } while (val & EMAC_MODE_RESET); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 498 | |
| 499 | /* Set mac address */ |
| 500 | val = ((params->mac_addr[0] << 8) | |
| 501 | params->mac_addr[1]); |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 502 | EMAC_WR(bp, EMAC_REG_EMAC_MAC_MATCH, val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 503 | |
| 504 | val = ((params->mac_addr[2] << 24) | |
| 505 | (params->mac_addr[3] << 16) | |
| 506 | (params->mac_addr[4] << 8) | |
| 507 | params->mac_addr[5]); |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 508 | EMAC_WR(bp, EMAC_REG_EMAC_MAC_MATCH + 4, val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 509 | } |
| 510 | |
| 511 | static u8 bnx2x_emac_enable(struct link_params *params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 512 | struct link_vars *vars, u8 lb) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 513 | { |
| 514 | struct bnx2x *bp = params->bp; |
| 515 | u8 port = params->port; |
| 516 | u32 emac_base = port ? GRCBASE_EMAC1 : GRCBASE_EMAC0; |
| 517 | u32 val; |
| 518 | |
| 519 | DP(NETIF_MSG_LINK, "enabling EMAC\n"); |
| 520 | |
| 521 | /* enable emac and not bmac */ |
| 522 | REG_WR(bp, NIG_REG_EGRESS_EMAC0_PORT + port*4, 1); |
| 523 | |
| 524 | /* for paladium */ |
| 525 | if (CHIP_REV_IS_EMUL(bp)) { |
| 526 | /* Use lane 1 (of lanes 0-3) */ |
| 527 | REG_WR(bp, NIG_REG_XGXS_LANE_SEL_P0 + port*4, 1); |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 528 | REG_WR(bp, NIG_REG_XGXS_SERDES0_MODE_SEL + port*4, 1); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 529 | } |
| 530 | /* for fpga */ |
| 531 | else |
| 532 | |
| 533 | if (CHIP_REV_IS_FPGA(bp)) { |
| 534 | /* Use lane 1 (of lanes 0-3) */ |
| 535 | DP(NETIF_MSG_LINK, "bnx2x_emac_enable: Setting FPGA\n"); |
| 536 | |
| 537 | REG_WR(bp, NIG_REG_XGXS_LANE_SEL_P0 + port*4, 1); |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 538 | REG_WR(bp, NIG_REG_XGXS_SERDES0_MODE_SEL + port*4, 0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 539 | } else |
| 540 | /* ASIC */ |
| 541 | if (vars->phy_flags & PHY_XGXS_FLAG) { |
| 542 | u32 ser_lane = ((params->lane_config & |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 543 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_MASK) >> |
| 544 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_SHIFT); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 545 | |
| 546 | DP(NETIF_MSG_LINK, "XGXS\n"); |
| 547 | /* select the master lanes (out of 0-3) */ |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 548 | 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] | 549 | /* select XGXS */ |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 550 | REG_WR(bp, NIG_REG_XGXS_SERDES0_MODE_SEL + port*4, 1); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 551 | |
| 552 | } else { /* SerDes */ |
| 553 | DP(NETIF_MSG_LINK, "SerDes\n"); |
| 554 | /* select SerDes */ |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 555 | REG_WR(bp, NIG_REG_XGXS_SERDES0_MODE_SEL + port*4, 0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 556 | } |
| 557 | |
Eilon Greenstein | 811a2f2 | 2009-02-12 08:37:04 +0000 | [diff] [blame] | 558 | bnx2x_bits_en(bp, emac_base + EMAC_REG_EMAC_RX_MODE, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 559 | EMAC_RX_MODE_RESET); |
Eilon Greenstein | 811a2f2 | 2009-02-12 08:37:04 +0000 | [diff] [blame] | 560 | bnx2x_bits_en(bp, emac_base + EMAC_REG_EMAC_TX_MODE, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 561 | EMAC_TX_MODE_RESET); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 562 | |
| 563 | if (CHIP_REV_IS_SLOW(bp)) { |
| 564 | /* config GMII mode */ |
| 565 | val = REG_RD(bp, emac_base + EMAC_REG_EMAC_MODE); |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 566 | EMAC_WR(bp, EMAC_REG_EMAC_MODE, (val | EMAC_MODE_PORT_GMII)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 567 | } else { /* ASIC */ |
| 568 | /* pause enable/disable */ |
| 569 | bnx2x_bits_dis(bp, emac_base + EMAC_REG_EMAC_RX_MODE, |
| 570 | EMAC_RX_MODE_FLOW_EN); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 571 | |
| 572 | bnx2x_bits_dis(bp, emac_base + EMAC_REG_EMAC_TX_MODE, |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 573 | (EMAC_TX_MODE_EXT_PAUSE_EN | |
| 574 | EMAC_TX_MODE_FLOW_EN)); |
| 575 | if (!(params->feature_config_flags & |
| 576 | FEATURE_CONFIG_PFC_ENABLED)) { |
| 577 | if (vars->flow_ctrl & BNX2X_FLOW_CTRL_RX) |
| 578 | bnx2x_bits_en(bp, emac_base + |
| 579 | EMAC_REG_EMAC_RX_MODE, |
| 580 | EMAC_RX_MODE_FLOW_EN); |
| 581 | |
| 582 | if (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX) |
| 583 | bnx2x_bits_en(bp, emac_base + |
| 584 | EMAC_REG_EMAC_TX_MODE, |
| 585 | (EMAC_TX_MODE_EXT_PAUSE_EN | |
| 586 | EMAC_TX_MODE_FLOW_EN)); |
| 587 | } else |
| 588 | bnx2x_bits_en(bp, emac_base + EMAC_REG_EMAC_TX_MODE, |
| 589 | EMAC_TX_MODE_FLOW_EN); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 590 | } |
| 591 | |
| 592 | /* KEEP_VLAN_TAG, promiscuous */ |
| 593 | val = REG_RD(bp, emac_base + EMAC_REG_EMAC_RX_MODE); |
| 594 | val |= EMAC_RX_MODE_KEEP_VLAN_TAG | EMAC_RX_MODE_PROMISCUOUS; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 595 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 596 | /* |
| 597 | * Setting this bit causes MAC control frames (except for pause |
| 598 | * frames) to be passed on for processing. This setting has no |
| 599 | * affect on the operation of the pause frames. This bit effects |
| 600 | * all packets regardless of RX Parser packet sorting logic. |
| 601 | * Turn the PFC off to make sure we are in Xon state before |
| 602 | * enabling it. |
| 603 | */ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 604 | EMAC_WR(bp, EMAC_REG_RX_PFC_MODE, 0); |
| 605 | if (params->feature_config_flags & FEATURE_CONFIG_PFC_ENABLED) { |
| 606 | DP(NETIF_MSG_LINK, "PFC is enabled\n"); |
| 607 | /* Enable PFC again */ |
| 608 | EMAC_WR(bp, EMAC_REG_RX_PFC_MODE, |
| 609 | EMAC_REG_RX_PFC_MODE_RX_EN | |
| 610 | EMAC_REG_RX_PFC_MODE_TX_EN | |
| 611 | EMAC_REG_RX_PFC_MODE_PRIORITIES); |
| 612 | |
| 613 | EMAC_WR(bp, EMAC_REG_RX_PFC_PARAM, |
| 614 | ((0x0101 << |
| 615 | EMAC_REG_RX_PFC_PARAM_OPCODE_BITSHIFT) | |
| 616 | (0x00ff << |
| 617 | EMAC_REG_RX_PFC_PARAM_PRIORITY_EN_BITSHIFT))); |
| 618 | val |= EMAC_RX_MODE_KEEP_MAC_CONTROL; |
| 619 | } |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 620 | EMAC_WR(bp, EMAC_REG_EMAC_RX_MODE, val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 621 | |
| 622 | /* Set Loopback */ |
| 623 | val = REG_RD(bp, emac_base + EMAC_REG_EMAC_MODE); |
| 624 | if (lb) |
| 625 | val |= 0x810; |
| 626 | else |
| 627 | val &= ~0x810; |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 628 | EMAC_WR(bp, EMAC_REG_EMAC_MODE, val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 629 | |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 630 | /* enable emac */ |
| 631 | REG_WR(bp, NIG_REG_NIG_EMAC0_EN + port*4, 1); |
| 632 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 633 | /* enable emac for jumbo packets */ |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 634 | EMAC_WR(bp, EMAC_REG_EMAC_RX_MTU_SIZE, |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 635 | (EMAC_RX_MTU_SIZE_JUMBO_ENA | |
| 636 | (ETH_MAX_JUMBO_PACKET_SIZE + ETH_OVREHEAD))); |
| 637 | |
| 638 | /* strip CRC */ |
| 639 | REG_WR(bp, NIG_REG_NIG_INGRESS_EMAC0_NO_CRC + port*4, 0x1); |
| 640 | |
| 641 | /* disable the NIG in/out to the bmac */ |
| 642 | REG_WR(bp, NIG_REG_BMAC0_IN_EN + port*4, 0x0); |
| 643 | REG_WR(bp, NIG_REG_BMAC0_PAUSE_OUT_EN + port*4, 0x0); |
| 644 | REG_WR(bp, NIG_REG_BMAC0_OUT_EN + port*4, 0x0); |
| 645 | |
| 646 | /* enable the NIG in/out to the emac */ |
| 647 | REG_WR(bp, NIG_REG_EMAC0_IN_EN + port*4, 0x1); |
| 648 | val = 0; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 649 | if ((params->feature_config_flags & |
| 650 | FEATURE_CONFIG_PFC_ENABLED) || |
| 651 | (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX)) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 652 | val = 1; |
| 653 | |
| 654 | REG_WR(bp, NIG_REG_EMAC0_PAUSE_OUT_EN + port*4, val); |
| 655 | REG_WR(bp, NIG_REG_EGRESS_EMAC0_OUT_EN + port*4, 0x1); |
| 656 | |
| 657 | if (CHIP_REV_IS_EMUL(bp)) { |
| 658 | /* take the BigMac out of reset */ |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 659 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_SET, |
| 660 | (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << port)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 661 | |
| 662 | /* enable access for bmac registers */ |
| 663 | REG_WR(bp, NIG_REG_BMAC0_REGS_OUT_EN + port*4, 0x1); |
Eilon Greenstein | 6f65497 | 2009-08-12 08:23:51 +0000 | [diff] [blame] | 664 | } else |
| 665 | REG_WR(bp, NIG_REG_BMAC0_REGS_OUT_EN + port*4, 0x0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 666 | |
| 667 | vars->mac_type = MAC_TYPE_EMAC; |
| 668 | return 0; |
| 669 | } |
| 670 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 671 | static void bnx2x_update_pfc_bmac1(struct link_params *params, |
| 672 | struct link_vars *vars) |
| 673 | { |
| 674 | u32 wb_data[2]; |
| 675 | struct bnx2x *bp = params->bp; |
| 676 | u32 bmac_addr = params->port ? NIG_REG_INGRESS_BMAC1_MEM : |
| 677 | NIG_REG_INGRESS_BMAC0_MEM; |
| 678 | |
| 679 | u32 val = 0x14; |
| 680 | if ((!(params->feature_config_flags & |
| 681 | FEATURE_CONFIG_PFC_ENABLED)) && |
| 682 | (vars->flow_ctrl & BNX2X_FLOW_CTRL_RX)) |
| 683 | /* Enable BigMAC to react on received Pause packets */ |
| 684 | val |= (1<<5); |
| 685 | wb_data[0] = val; |
| 686 | wb_data[1] = 0; |
| 687 | REG_WR_DMAE(bp, bmac_addr + BIGMAC_REGISTER_RX_CONTROL, wb_data, 2); |
| 688 | |
| 689 | /* tx control */ |
| 690 | val = 0xc0; |
| 691 | if (!(params->feature_config_flags & |
| 692 | FEATURE_CONFIG_PFC_ENABLED) && |
| 693 | (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX)) |
| 694 | val |= 0x800000; |
| 695 | wb_data[0] = val; |
| 696 | wb_data[1] = 0; |
| 697 | REG_WR_DMAE(bp, bmac_addr + BIGMAC_REGISTER_TX_CONTROL, wb_data, 2); |
| 698 | } |
| 699 | |
| 700 | static void bnx2x_update_pfc_bmac2(struct link_params *params, |
| 701 | struct link_vars *vars, |
| 702 | u8 is_lb) |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 703 | { |
| 704 | /* |
| 705 | * Set rx control: Strip CRC and enable BigMAC to relay |
| 706 | * control packets to the system as well |
| 707 | */ |
| 708 | u32 wb_data[2]; |
| 709 | struct bnx2x *bp = params->bp; |
| 710 | u32 bmac_addr = params->port ? NIG_REG_INGRESS_BMAC1_MEM : |
| 711 | NIG_REG_INGRESS_BMAC0_MEM; |
| 712 | u32 val = 0x14; |
| 713 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 714 | if ((!(params->feature_config_flags & |
| 715 | FEATURE_CONFIG_PFC_ENABLED)) && |
| 716 | (vars->flow_ctrl & BNX2X_FLOW_CTRL_RX)) |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 717 | /* Enable BigMAC to react on received Pause packets */ |
| 718 | val |= (1<<5); |
| 719 | wb_data[0] = val; |
| 720 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 721 | 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] | 722 | udelay(30); |
| 723 | |
| 724 | /* Tx control */ |
| 725 | val = 0xc0; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 726 | if (!(params->feature_config_flags & |
| 727 | FEATURE_CONFIG_PFC_ENABLED) && |
| 728 | (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX)) |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 729 | val |= 0x800000; |
| 730 | wb_data[0] = val; |
| 731 | wb_data[1] = 0; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 732 | 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] | 733 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 734 | if (params->feature_config_flags & FEATURE_CONFIG_PFC_ENABLED) { |
| 735 | DP(NETIF_MSG_LINK, "PFC is enabled\n"); |
| 736 | /* Enable PFC RX & TX & STATS and set 8 COS */ |
| 737 | wb_data[0] = 0x0; |
| 738 | wb_data[0] |= (1<<0); /* RX */ |
| 739 | wb_data[0] |= (1<<1); /* TX */ |
| 740 | wb_data[0] |= (1<<2); /* Force initial Xon */ |
| 741 | wb_data[0] |= (1<<3); /* 8 cos */ |
| 742 | wb_data[0] |= (1<<5); /* STATS */ |
| 743 | wb_data[1] = 0; |
| 744 | REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_PFC_CONTROL, |
| 745 | wb_data, 2); |
| 746 | /* Clear the force Xon */ |
| 747 | wb_data[0] &= ~(1<<2); |
| 748 | } else { |
| 749 | DP(NETIF_MSG_LINK, "PFC is disabled\n"); |
| 750 | /* disable PFC RX & TX & STATS and set 8 COS */ |
| 751 | wb_data[0] = 0x8; |
| 752 | wb_data[1] = 0; |
| 753 | } |
| 754 | |
| 755 | REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_PFC_CONTROL, wb_data, 2); |
| 756 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 757 | /* |
| 758 | * Set Time (based unit is 512 bit time) between automatic |
| 759 | * re-sending of PP packets amd enable automatic re-send of |
| 760 | * Per-Priroity Packet as long as pp_gen is asserted and |
| 761 | * pp_disable is low. |
| 762 | */ |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 763 | val = 0x8000; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 764 | if (params->feature_config_flags & FEATURE_CONFIG_PFC_ENABLED) |
| 765 | val |= (1<<16); /* enable automatic re-send */ |
| 766 | |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 767 | wb_data[0] = val; |
| 768 | wb_data[1] = 0; |
| 769 | REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_TX_PAUSE_CONTROL, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 770 | wb_data, 2); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 771 | |
| 772 | /* mac control */ |
| 773 | val = 0x3; /* Enable RX and TX */ |
| 774 | if (is_lb) { |
| 775 | val |= 0x4; /* Local loopback */ |
| 776 | DP(NETIF_MSG_LINK, "enable bmac loopback\n"); |
| 777 | } |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 778 | /* When PFC enabled, Pass pause frames towards the NIG. */ |
| 779 | if (params->feature_config_flags & FEATURE_CONFIG_PFC_ENABLED) |
| 780 | val |= ((1<<6)|(1<<5)); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 781 | |
| 782 | wb_data[0] = val; |
| 783 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 784 | 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] | 785 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 786 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 787 | static void bnx2x_update_pfc_brb(struct link_params *params, |
| 788 | struct link_vars *vars, |
| 789 | struct bnx2x_nig_brb_pfc_port_params *pfc_params) |
| 790 | { |
| 791 | struct bnx2x *bp = params->bp; |
| 792 | int set_pfc = params->feature_config_flags & |
| 793 | FEATURE_CONFIG_PFC_ENABLED; |
| 794 | |
| 795 | /* default - pause configuration */ |
| 796 | u32 pause_xoff_th = PFC_BRB_MAC_PAUSE_XOFF_THRESHOLD_PAUSEABLE; |
| 797 | u32 pause_xon_th = PFC_BRB_MAC_PAUSE_XON_THRESHOLD_PAUSEABLE; |
| 798 | u32 full_xoff_th = PFC_BRB_MAC_FULL_XOFF_THRESHOLD_PAUSEABLE; |
| 799 | u32 full_xon_th = PFC_BRB_MAC_FULL_XON_THRESHOLD_PAUSEABLE; |
| 800 | |
| 801 | if (set_pfc && pfc_params) |
| 802 | /* First COS */ |
| 803 | if (!pfc_params->cos0_pauseable) { |
| 804 | pause_xoff_th = |
| 805 | PFC_BRB_MAC_PAUSE_XOFF_THRESHOLD_NON_PAUSEABLE; |
| 806 | pause_xon_th = |
| 807 | PFC_BRB_MAC_PAUSE_XON_THRESHOLD_NON_PAUSEABLE; |
| 808 | full_xoff_th = |
| 809 | PFC_BRB_MAC_FULL_XOFF_THRESHOLD_NON_PAUSEABLE; |
| 810 | full_xon_th = |
| 811 | PFC_BRB_MAC_FULL_XON_THRESHOLD_NON_PAUSEABLE; |
| 812 | } |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 813 | /* |
| 814 | * The number of free blocks below which the pause signal to class 0 |
| 815 | * of MAC #n is asserted. n=0,1 |
| 816 | */ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 817 | REG_WR(bp, BRB1_REG_PAUSE_0_XOFF_THRESHOLD_0 , pause_xoff_th); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 818 | /* |
| 819 | * The number of free blocks above which the pause signal to class 0 |
| 820 | * of MAC #n is de-asserted. n=0,1 |
| 821 | */ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 822 | REG_WR(bp, BRB1_REG_PAUSE_0_XON_THRESHOLD_0 , pause_xon_th); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 823 | /* |
| 824 | * The number of free blocks below which the full signal to class 0 |
| 825 | * of MAC #n is asserted. n=0,1 |
| 826 | */ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 827 | REG_WR(bp, BRB1_REG_FULL_0_XOFF_THRESHOLD_0 , full_xoff_th); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 828 | /* |
| 829 | * The number of free blocks above which the full signal to class 0 |
| 830 | * of MAC #n is de-asserted. n=0,1 |
| 831 | */ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 832 | REG_WR(bp, BRB1_REG_FULL_0_XON_THRESHOLD_0 , full_xon_th); |
| 833 | |
| 834 | if (set_pfc && pfc_params) { |
| 835 | /* Second COS */ |
| 836 | if (pfc_params->cos1_pauseable) { |
| 837 | pause_xoff_th = |
| 838 | PFC_BRB_MAC_PAUSE_XOFF_THRESHOLD_PAUSEABLE; |
| 839 | pause_xon_th = |
| 840 | PFC_BRB_MAC_PAUSE_XON_THRESHOLD_PAUSEABLE; |
| 841 | full_xoff_th = |
| 842 | PFC_BRB_MAC_FULL_XOFF_THRESHOLD_PAUSEABLE; |
| 843 | full_xon_th = |
| 844 | PFC_BRB_MAC_FULL_XON_THRESHOLD_PAUSEABLE; |
| 845 | } else { |
| 846 | pause_xoff_th = |
| 847 | PFC_BRB_MAC_PAUSE_XOFF_THRESHOLD_NON_PAUSEABLE; |
| 848 | pause_xon_th = |
| 849 | PFC_BRB_MAC_PAUSE_XON_THRESHOLD_NON_PAUSEABLE; |
| 850 | full_xoff_th = |
| 851 | PFC_BRB_MAC_FULL_XOFF_THRESHOLD_NON_PAUSEABLE; |
| 852 | full_xon_th = |
| 853 | PFC_BRB_MAC_FULL_XON_THRESHOLD_NON_PAUSEABLE; |
| 854 | } |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 855 | /* |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 856 | * The number of free blocks below which the pause signal to |
| 857 | * class 1 of MAC #n is asserted. n=0,1 |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 858 | */ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 859 | REG_WR(bp, BRB1_REG_PAUSE_1_XOFF_THRESHOLD_0, pause_xoff_th); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 860 | /* |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 861 | * The number of free blocks above which the pause signal to |
| 862 | * class 1 of MAC #n is de-asserted. n=0,1 |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 863 | */ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 864 | REG_WR(bp, BRB1_REG_PAUSE_1_XON_THRESHOLD_0, pause_xon_th); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 865 | /* |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 866 | * The number of free blocks below which the full signal to |
| 867 | * class 1 of MAC #n is asserted. n=0,1 |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 868 | */ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 869 | REG_WR(bp, BRB1_REG_FULL_1_XOFF_THRESHOLD_0, full_xoff_th); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 870 | /* |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 871 | * The number of free blocks above which the full signal to |
| 872 | * class 1 of MAC #n is de-asserted. n=0,1 |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 873 | */ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 874 | REG_WR(bp, BRB1_REG_FULL_1_XON_THRESHOLD_0, full_xon_th); |
| 875 | } |
| 876 | } |
| 877 | |
| 878 | static void bnx2x_update_pfc_nig(struct link_params *params, |
| 879 | struct link_vars *vars, |
| 880 | struct bnx2x_nig_brb_pfc_port_params *nig_params) |
| 881 | { |
| 882 | u32 xcm_mask = 0, ppp_enable = 0, pause_enable = 0, llfc_out_en = 0; |
| 883 | u32 llfc_enable = 0, xcm0_out_en = 0, p0_hwpfc_enable = 0; |
| 884 | u32 pkt_priority_to_cos = 0; |
| 885 | u32 val; |
| 886 | struct bnx2x *bp = params->bp; |
| 887 | int port = params->port; |
| 888 | int set_pfc = params->feature_config_flags & |
| 889 | FEATURE_CONFIG_PFC_ENABLED; |
| 890 | DP(NETIF_MSG_LINK, "updating pfc nig parameters\n"); |
| 891 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 892 | /* |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 893 | * When NIG_LLH0_XCM_MASK_REG_LLHX_XCM_MASK_BCN bit is set |
| 894 | * MAC control frames (that are not pause packets) |
| 895 | * will be forwarded to the XCM. |
| 896 | */ |
| 897 | xcm_mask = REG_RD(bp, |
| 898 | port ? NIG_REG_LLH1_XCM_MASK : |
| 899 | NIG_REG_LLH0_XCM_MASK); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 900 | /* |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 901 | * nig params will override non PFC params, since it's possible to |
| 902 | * do transition from PFC to SAFC |
| 903 | */ |
| 904 | if (set_pfc) { |
| 905 | pause_enable = 0; |
| 906 | llfc_out_en = 0; |
| 907 | llfc_enable = 0; |
| 908 | ppp_enable = 1; |
| 909 | xcm_mask &= ~(port ? NIG_LLH1_XCM_MASK_REG_LLH1_XCM_MASK_BCN : |
| 910 | NIG_LLH0_XCM_MASK_REG_LLH0_XCM_MASK_BCN); |
| 911 | xcm0_out_en = 0; |
| 912 | p0_hwpfc_enable = 1; |
| 913 | } else { |
| 914 | if (nig_params) { |
| 915 | llfc_out_en = nig_params->llfc_out_en; |
| 916 | llfc_enable = nig_params->llfc_enable; |
| 917 | pause_enable = nig_params->pause_enable; |
| 918 | } else /*defaul non PFC mode - PAUSE */ |
| 919 | pause_enable = 1; |
| 920 | |
| 921 | xcm_mask |= (port ? NIG_LLH1_XCM_MASK_REG_LLH1_XCM_MASK_BCN : |
| 922 | NIG_LLH0_XCM_MASK_REG_LLH0_XCM_MASK_BCN); |
| 923 | xcm0_out_en = 1; |
| 924 | } |
| 925 | |
| 926 | REG_WR(bp, port ? NIG_REG_LLFC_OUT_EN_1 : |
| 927 | NIG_REG_LLFC_OUT_EN_0, llfc_out_en); |
| 928 | REG_WR(bp, port ? NIG_REG_LLFC_ENABLE_1 : |
| 929 | NIG_REG_LLFC_ENABLE_0, llfc_enable); |
| 930 | REG_WR(bp, port ? NIG_REG_PAUSE_ENABLE_1 : |
| 931 | NIG_REG_PAUSE_ENABLE_0, pause_enable); |
| 932 | |
| 933 | REG_WR(bp, port ? NIG_REG_PPP_ENABLE_1 : |
| 934 | NIG_REG_PPP_ENABLE_0, ppp_enable); |
| 935 | |
| 936 | REG_WR(bp, port ? NIG_REG_LLH1_XCM_MASK : |
| 937 | NIG_REG_LLH0_XCM_MASK, xcm_mask); |
| 938 | |
| 939 | REG_WR(bp, NIG_REG_LLFC_EGRESS_SRC_ENABLE_0, 0x7); |
| 940 | |
| 941 | /* output enable for RX_XCM # IF */ |
| 942 | REG_WR(bp, NIG_REG_XCM0_OUT_EN, xcm0_out_en); |
| 943 | |
| 944 | /* HW PFC TX enable */ |
| 945 | REG_WR(bp, NIG_REG_P0_HWPFC_ENABLE, p0_hwpfc_enable); |
| 946 | |
| 947 | /* 0x2 = BMAC, 0x1= EMAC */ |
| 948 | switch (vars->mac_type) { |
| 949 | case MAC_TYPE_EMAC: |
| 950 | val = 1; |
| 951 | break; |
| 952 | case MAC_TYPE_BMAC: |
| 953 | val = 0; |
| 954 | break; |
| 955 | default: |
| 956 | val = 0; |
| 957 | break; |
| 958 | } |
| 959 | REG_WR(bp, NIG_REG_EGRESS_EMAC0_PORT, val); |
| 960 | |
| 961 | if (nig_params) { |
| 962 | pkt_priority_to_cos = nig_params->pkt_priority_to_cos; |
| 963 | |
| 964 | REG_WR(bp, port ? NIG_REG_P1_RX_COS0_PRIORITY_MASK : |
| 965 | NIG_REG_P0_RX_COS0_PRIORITY_MASK, |
| 966 | nig_params->rx_cos0_priority_mask); |
| 967 | |
| 968 | REG_WR(bp, port ? NIG_REG_P1_RX_COS1_PRIORITY_MASK : |
| 969 | NIG_REG_P0_RX_COS1_PRIORITY_MASK, |
| 970 | nig_params->rx_cos1_priority_mask); |
| 971 | |
| 972 | REG_WR(bp, port ? NIG_REG_LLFC_HIGH_PRIORITY_CLASSES_1 : |
| 973 | NIG_REG_LLFC_HIGH_PRIORITY_CLASSES_0, |
| 974 | nig_params->llfc_high_priority_classes); |
| 975 | |
| 976 | REG_WR(bp, port ? NIG_REG_LLFC_LOW_PRIORITY_CLASSES_1 : |
| 977 | NIG_REG_LLFC_LOW_PRIORITY_CLASSES_0, |
| 978 | nig_params->llfc_low_priority_classes); |
| 979 | } |
| 980 | REG_WR(bp, port ? NIG_REG_P1_PKT_PRIORITY_TO_COS : |
| 981 | NIG_REG_P0_PKT_PRIORITY_TO_COS, |
| 982 | pkt_priority_to_cos); |
| 983 | } |
| 984 | |
| 985 | |
| 986 | void bnx2x_update_pfc(struct link_params *params, |
| 987 | struct link_vars *vars, |
| 988 | struct bnx2x_nig_brb_pfc_port_params *pfc_params) |
| 989 | { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 990 | /* |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 991 | * The PFC and pause are orthogonal to one another, meaning when |
| 992 | * PFC is enabled, the pause are disabled, and when PFC is |
| 993 | * disabled, pause are set according to the pause result. |
| 994 | */ |
| 995 | u32 val; |
| 996 | struct bnx2x *bp = params->bp; |
| 997 | |
| 998 | /* update NIG params */ |
| 999 | bnx2x_update_pfc_nig(params, vars, pfc_params); |
| 1000 | |
| 1001 | /* update BRB params */ |
| 1002 | bnx2x_update_pfc_brb(params, vars, pfc_params); |
| 1003 | |
| 1004 | if (!vars->link_up) |
| 1005 | return; |
| 1006 | |
| 1007 | val = REG_RD(bp, MISC_REG_RESET_REG_2); |
| 1008 | if ((val & (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << params->port)) |
| 1009 | == 0) { |
| 1010 | DP(NETIF_MSG_LINK, "About to update PFC in EMAC\n"); |
| 1011 | bnx2x_emac_enable(params, vars, 0); |
| 1012 | return; |
| 1013 | } |
| 1014 | |
| 1015 | DP(NETIF_MSG_LINK, "About to update PFC in BMAC\n"); |
| 1016 | if (CHIP_IS_E2(bp)) |
| 1017 | bnx2x_update_pfc_bmac2(params, vars, 0); |
| 1018 | else |
| 1019 | bnx2x_update_pfc_bmac1(params, vars); |
| 1020 | |
| 1021 | val = 0; |
| 1022 | if ((params->feature_config_flags & |
| 1023 | FEATURE_CONFIG_PFC_ENABLED) || |
| 1024 | (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX)) |
| 1025 | val = 1; |
| 1026 | REG_WR(bp, NIG_REG_BMAC0_PAUSE_OUT_EN + params->port*4, val); |
| 1027 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1028 | |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1029 | static u8 bnx2x_bmac1_enable(struct link_params *params, |
| 1030 | struct link_vars *vars, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1031 | u8 is_lb) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1032 | { |
| 1033 | struct bnx2x *bp = params->bp; |
| 1034 | u8 port = params->port; |
| 1035 | u32 bmac_addr = port ? NIG_REG_INGRESS_BMAC1_MEM : |
| 1036 | NIG_REG_INGRESS_BMAC0_MEM; |
| 1037 | u32 wb_data[2]; |
| 1038 | u32 val; |
| 1039 | |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1040 | DP(NETIF_MSG_LINK, "Enabling BigMAC1\n"); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1041 | |
| 1042 | /* XGXS control */ |
| 1043 | wb_data[0] = 0x3c; |
| 1044 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1045 | REG_WR_DMAE(bp, bmac_addr + BIGMAC_REGISTER_BMAC_XGXS_CONTROL, |
| 1046 | wb_data, 2); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1047 | |
| 1048 | /* tx MAC SA */ |
| 1049 | wb_data[0] = ((params->mac_addr[2] << 24) | |
| 1050 | (params->mac_addr[3] << 16) | |
| 1051 | (params->mac_addr[4] << 8) | |
| 1052 | params->mac_addr[5]); |
| 1053 | wb_data[1] = ((params->mac_addr[0] << 8) | |
| 1054 | params->mac_addr[1]); |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1055 | 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] | 1056 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1057 | /* mac control */ |
| 1058 | val = 0x3; |
| 1059 | if (is_lb) { |
| 1060 | val |= 0x4; |
| 1061 | DP(NETIF_MSG_LINK, "enable bmac loopback\n"); |
| 1062 | } |
| 1063 | wb_data[0] = val; |
| 1064 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1065 | 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] | 1066 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1067 | /* set rx mtu */ |
| 1068 | wb_data[0] = ETH_MAX_JUMBO_PACKET_SIZE + ETH_OVREHEAD; |
| 1069 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1070 | 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] | 1071 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1072 | bnx2x_update_pfc_bmac1(params, vars); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1073 | |
| 1074 | /* set tx mtu */ |
| 1075 | wb_data[0] = ETH_MAX_JUMBO_PACKET_SIZE + ETH_OVREHEAD; |
| 1076 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1077 | 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] | 1078 | |
| 1079 | /* set cnt max size */ |
| 1080 | wb_data[0] = ETH_MAX_JUMBO_PACKET_SIZE + ETH_OVREHEAD; |
| 1081 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1082 | 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] | 1083 | |
| 1084 | /* configure safc */ |
| 1085 | wb_data[0] = 0x1000200; |
| 1086 | wb_data[1] = 0; |
| 1087 | REG_WR_DMAE(bp, bmac_addr + BIGMAC_REGISTER_RX_LLFC_MSG_FLDS, |
| 1088 | wb_data, 2); |
| 1089 | /* fix for emulation */ |
| 1090 | if (CHIP_REV_IS_EMUL(bp)) { |
| 1091 | wb_data[0] = 0xf000; |
| 1092 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1093 | REG_WR_DMAE(bp, bmac_addr + BIGMAC_REGISTER_TX_PAUSE_THRESHOLD, |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1094 | wb_data, 2); |
| 1095 | } |
| 1096 | |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1097 | |
| 1098 | return 0; |
| 1099 | } |
| 1100 | |
| 1101 | static u8 bnx2x_bmac2_enable(struct link_params *params, |
| 1102 | struct link_vars *vars, |
| 1103 | u8 is_lb) |
| 1104 | { |
| 1105 | struct bnx2x *bp = params->bp; |
| 1106 | u8 port = params->port; |
| 1107 | u32 bmac_addr = port ? NIG_REG_INGRESS_BMAC1_MEM : |
| 1108 | NIG_REG_INGRESS_BMAC0_MEM; |
| 1109 | u32 wb_data[2]; |
| 1110 | |
| 1111 | DP(NETIF_MSG_LINK, "Enabling BigMAC2\n"); |
| 1112 | |
| 1113 | wb_data[0] = 0; |
| 1114 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1115 | 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] | 1116 | udelay(30); |
| 1117 | |
| 1118 | /* XGXS control: Reset phy HW, MDIO registers, PHY PLL and BMAC */ |
| 1119 | wb_data[0] = 0x3c; |
| 1120 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1121 | REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_BMAC_XGXS_CONTROL, |
| 1122 | wb_data, 2); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1123 | |
| 1124 | udelay(30); |
| 1125 | |
| 1126 | /* tx MAC SA */ |
| 1127 | wb_data[0] = ((params->mac_addr[2] << 24) | |
| 1128 | (params->mac_addr[3] << 16) | |
| 1129 | (params->mac_addr[4] << 8) | |
| 1130 | params->mac_addr[5]); |
| 1131 | wb_data[1] = ((params->mac_addr[0] << 8) | |
| 1132 | params->mac_addr[1]); |
| 1133 | REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_TX_SOURCE_ADDR, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1134 | wb_data, 2); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1135 | |
| 1136 | udelay(30); |
| 1137 | |
| 1138 | /* Configure SAFC */ |
| 1139 | wb_data[0] = 0x1000200; |
| 1140 | wb_data[1] = 0; |
| 1141 | REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_RX_LLFC_MSG_FLDS, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1142 | wb_data, 2); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1143 | udelay(30); |
| 1144 | |
| 1145 | /* set rx mtu */ |
| 1146 | wb_data[0] = ETH_MAX_JUMBO_PACKET_SIZE + ETH_OVREHEAD; |
| 1147 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1148 | 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] | 1149 | udelay(30); |
| 1150 | |
| 1151 | /* set tx mtu */ |
| 1152 | wb_data[0] = ETH_MAX_JUMBO_PACKET_SIZE + ETH_OVREHEAD; |
| 1153 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1154 | 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] | 1155 | udelay(30); |
| 1156 | /* set cnt max size */ |
| 1157 | wb_data[0] = ETH_MAX_JUMBO_PACKET_SIZE + ETH_OVREHEAD - 2; |
| 1158 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1159 | 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] | 1160 | udelay(30); |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1161 | bnx2x_update_pfc_bmac2(params, vars, is_lb); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1162 | |
| 1163 | return 0; |
| 1164 | } |
| 1165 | |
stephen hemminger | 8d96286 | 2010-10-21 07:50:56 +0000 | [diff] [blame] | 1166 | static u8 bnx2x_bmac_enable(struct link_params *params, |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1167 | struct link_vars *vars, |
| 1168 | u8 is_lb) |
| 1169 | { |
| 1170 | u8 rc, port = params->port; |
| 1171 | struct bnx2x *bp = params->bp; |
| 1172 | u32 val; |
| 1173 | /* reset and unreset the BigMac */ |
| 1174 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_CLEAR, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1175 | (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << port)); |
Yaniv Rosner | 1d9c05d | 2010-11-01 05:32:25 +0000 | [diff] [blame] | 1176 | msleep(1); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1177 | |
| 1178 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_SET, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1179 | (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << port)); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1180 | |
| 1181 | /* enable access for bmac registers */ |
| 1182 | REG_WR(bp, NIG_REG_BMAC0_REGS_OUT_EN + port*4, 0x1); |
| 1183 | |
| 1184 | /* Enable BMAC according to BMAC type*/ |
| 1185 | if (CHIP_IS_E2(bp)) |
| 1186 | rc = bnx2x_bmac2_enable(params, vars, is_lb); |
| 1187 | else |
| 1188 | rc = bnx2x_bmac1_enable(params, vars, is_lb); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1189 | REG_WR(bp, NIG_REG_XGXS_SERDES0_MODE_SEL + port*4, 0x1); |
| 1190 | REG_WR(bp, NIG_REG_XGXS_LANE_SEL_P0 + port*4, 0x0); |
| 1191 | REG_WR(bp, NIG_REG_EGRESS_EMAC0_PORT + port*4, 0x0); |
| 1192 | val = 0; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1193 | if ((params->feature_config_flags & |
| 1194 | FEATURE_CONFIG_PFC_ENABLED) || |
| 1195 | (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX)) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1196 | val = 1; |
| 1197 | REG_WR(bp, NIG_REG_BMAC0_PAUSE_OUT_EN + port*4, val); |
| 1198 | REG_WR(bp, NIG_REG_EGRESS_EMAC0_OUT_EN + port*4, 0x0); |
| 1199 | REG_WR(bp, NIG_REG_EMAC0_IN_EN + port*4, 0x0); |
| 1200 | REG_WR(bp, NIG_REG_EMAC0_PAUSE_OUT_EN + port*4, 0x0); |
| 1201 | REG_WR(bp, NIG_REG_BMAC0_IN_EN + port*4, 0x1); |
| 1202 | REG_WR(bp, NIG_REG_BMAC0_OUT_EN + port*4, 0x1); |
| 1203 | |
| 1204 | vars->mac_type = MAC_TYPE_BMAC; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1205 | return rc; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1206 | } |
| 1207 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1208 | |
| 1209 | static void bnx2x_update_mng(struct link_params *params, u32 link_status) |
| 1210 | { |
| 1211 | struct bnx2x *bp = params->bp; |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 1212 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1213 | REG_WR(bp, params->shmem_base + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1214 | offsetof(struct shmem_region, |
| 1215 | port_mb[params->port].link_status), link_status); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1216 | } |
| 1217 | |
| 1218 | static void bnx2x_bmac_rx_disable(struct bnx2x *bp, u8 port) |
| 1219 | { |
| 1220 | u32 bmac_addr = port ? NIG_REG_INGRESS_BMAC1_MEM : |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1221 | NIG_REG_INGRESS_BMAC0_MEM; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1222 | u32 wb_data[2]; |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 1223 | 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] | 1224 | |
| 1225 | /* Only if the bmac is out of reset */ |
| 1226 | if (REG_RD(bp, MISC_REG_RESET_REG_2) & |
| 1227 | (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << port) && |
| 1228 | nig_bmac_enable) { |
| 1229 | |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1230 | if (CHIP_IS_E2(bp)) { |
| 1231 | /* Clear Rx Enable bit in BMAC_CONTROL register */ |
| 1232 | REG_RD_DMAE(bp, bmac_addr + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1233 | BIGMAC2_REGISTER_BMAC_CONTROL, |
| 1234 | wb_data, 2); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1235 | wb_data[0] &= ~BMAC_CONTROL_RX_ENABLE; |
| 1236 | REG_WR_DMAE(bp, bmac_addr + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1237 | BIGMAC2_REGISTER_BMAC_CONTROL, |
| 1238 | wb_data, 2); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1239 | } else { |
| 1240 | /* Clear Rx Enable bit in BMAC_CONTROL register */ |
| 1241 | REG_RD_DMAE(bp, bmac_addr + |
| 1242 | BIGMAC_REGISTER_BMAC_CONTROL, |
| 1243 | wb_data, 2); |
| 1244 | wb_data[0] &= ~BMAC_CONTROL_RX_ENABLE; |
| 1245 | REG_WR_DMAE(bp, bmac_addr + |
| 1246 | BIGMAC_REGISTER_BMAC_CONTROL, |
| 1247 | wb_data, 2); |
| 1248 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1249 | msleep(1); |
| 1250 | } |
| 1251 | } |
| 1252 | |
| 1253 | static u8 bnx2x_pbf_update(struct link_params *params, u32 flow_ctrl, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1254 | u32 line_speed) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1255 | { |
| 1256 | struct bnx2x *bp = params->bp; |
| 1257 | u8 port = params->port; |
| 1258 | u32 init_crd, crd; |
| 1259 | u32 count = 1000; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1260 | |
| 1261 | /* disable port */ |
| 1262 | REG_WR(bp, PBF_REG_DISABLE_NEW_TASK_PROC_P0 + port*4, 0x1); |
| 1263 | |
| 1264 | /* wait for init credit */ |
| 1265 | init_crd = REG_RD(bp, PBF_REG_P0_INIT_CRD + port*4); |
| 1266 | crd = REG_RD(bp, PBF_REG_P0_CREDIT + port*8); |
| 1267 | DP(NETIF_MSG_LINK, "init_crd 0x%x crd 0x%x\n", init_crd, crd); |
| 1268 | |
| 1269 | while ((init_crd != crd) && count) { |
| 1270 | msleep(5); |
| 1271 | |
| 1272 | crd = REG_RD(bp, PBF_REG_P0_CREDIT + port*8); |
| 1273 | count--; |
| 1274 | } |
| 1275 | crd = REG_RD(bp, PBF_REG_P0_CREDIT + port*8); |
| 1276 | if (init_crd != crd) { |
| 1277 | DP(NETIF_MSG_LINK, "BUG! init_crd 0x%x != crd 0x%x\n", |
| 1278 | init_crd, crd); |
| 1279 | return -EINVAL; |
| 1280 | } |
| 1281 | |
David S. Miller | c0700f9 | 2008-12-16 23:53:20 -0800 | [diff] [blame] | 1282 | if (flow_ctrl & BNX2X_FLOW_CTRL_RX || |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 1283 | line_speed == SPEED_10 || |
| 1284 | line_speed == SPEED_100 || |
| 1285 | line_speed == SPEED_1000 || |
| 1286 | line_speed == SPEED_2500) { |
| 1287 | REG_WR(bp, PBF_REG_P0_PAUSE_ENABLE + port*4, 1); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1288 | /* update threshold */ |
| 1289 | REG_WR(bp, PBF_REG_P0_ARB_THRSH + port*4, 0); |
| 1290 | /* update init credit */ |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1291 | init_crd = 778; /* (800-18-4) */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1292 | |
| 1293 | } else { |
| 1294 | u32 thresh = (ETH_MAX_JUMBO_PACKET_SIZE + |
| 1295 | ETH_OVREHEAD)/16; |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 1296 | REG_WR(bp, PBF_REG_P0_PAUSE_ENABLE + port*4, 0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1297 | /* update threshold */ |
| 1298 | REG_WR(bp, PBF_REG_P0_ARB_THRSH + port*4, thresh); |
| 1299 | /* update init credit */ |
| 1300 | switch (line_speed) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1301 | case SPEED_10000: |
| 1302 | init_crd = thresh + 553 - 22; |
| 1303 | break; |
| 1304 | |
| 1305 | case SPEED_12000: |
| 1306 | init_crd = thresh + 664 - 22; |
| 1307 | break; |
| 1308 | |
| 1309 | case SPEED_13000: |
| 1310 | init_crd = thresh + 742 - 22; |
| 1311 | break; |
| 1312 | |
| 1313 | case SPEED_16000: |
| 1314 | init_crd = thresh + 778 - 22; |
| 1315 | break; |
| 1316 | default: |
| 1317 | DP(NETIF_MSG_LINK, "Invalid line_speed 0x%x\n", |
| 1318 | line_speed); |
| 1319 | return -EINVAL; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1320 | } |
| 1321 | } |
| 1322 | REG_WR(bp, PBF_REG_P0_INIT_CRD + port*4, init_crd); |
| 1323 | DP(NETIF_MSG_LINK, "PBF updated to speed %d credit %d\n", |
| 1324 | line_speed, init_crd); |
| 1325 | |
| 1326 | /* probe the credit changes */ |
| 1327 | REG_WR(bp, PBF_REG_INIT_P0 + port*4, 0x1); |
| 1328 | msleep(5); |
| 1329 | REG_WR(bp, PBF_REG_INIT_P0 + port*4, 0x0); |
| 1330 | |
| 1331 | /* enable port */ |
| 1332 | REG_WR(bp, PBF_REG_DISABLE_NEW_TASK_PROC_P0 + port*4, 0x0); |
| 1333 | return 0; |
| 1334 | } |
| 1335 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 1336 | /* |
| 1337 | * get_emac_base |
| 1338 | * |
| 1339 | * @param cb |
| 1340 | * @param mdc_mdio_access |
| 1341 | * @param port |
| 1342 | * |
| 1343 | * @return u32 |
| 1344 | * |
| 1345 | * This function selects the MDC/MDIO access (through emac0 or |
| 1346 | * emac1) depend on the mdc_mdio_access, port, port swapped. Each |
| 1347 | * phy has a default access mode, which could also be overridden |
| 1348 | * by nvram configuration. This parameter, whether this is the |
| 1349 | * default phy configuration, or the nvram overrun |
| 1350 | * configuration, is passed here as mdc_mdio_access and selects |
| 1351 | * the emac_base for the CL45 read/writes operations |
| 1352 | */ |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 1353 | static u32 bnx2x_get_emac_base(struct bnx2x *bp, |
| 1354 | u32 mdc_mdio_access, u8 port) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1355 | { |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 1356 | u32 emac_base = 0; |
| 1357 | switch (mdc_mdio_access) { |
| 1358 | case SHARED_HW_CFG_MDC_MDIO_ACCESS1_PHY_TYPE: |
| 1359 | break; |
| 1360 | case SHARED_HW_CFG_MDC_MDIO_ACCESS1_EMAC0: |
| 1361 | if (REG_RD(bp, NIG_REG_PORT_SWAP)) |
| 1362 | emac_base = GRCBASE_EMAC1; |
| 1363 | else |
| 1364 | emac_base = GRCBASE_EMAC0; |
| 1365 | break; |
| 1366 | case SHARED_HW_CFG_MDC_MDIO_ACCESS1_EMAC1: |
Eilon Greenstein | 589abe3 | 2009-02-12 08:36:55 +0000 | [diff] [blame] | 1367 | if (REG_RD(bp, NIG_REG_PORT_SWAP)) |
| 1368 | emac_base = GRCBASE_EMAC0; |
| 1369 | else |
| 1370 | emac_base = GRCBASE_EMAC1; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1371 | break; |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 1372 | case SHARED_HW_CFG_MDC_MDIO_ACCESS1_BOTH: |
| 1373 | emac_base = (port) ? GRCBASE_EMAC1 : GRCBASE_EMAC0; |
| 1374 | break; |
| 1375 | case SHARED_HW_CFG_MDC_MDIO_ACCESS1_SWAPPED: |
Eilon Greenstein | 6378c02 | 2008-08-13 15:59:25 -0700 | [diff] [blame] | 1376 | emac_base = (port) ? GRCBASE_EMAC0 : GRCBASE_EMAC1; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1377 | break; |
| 1378 | default: |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1379 | break; |
| 1380 | } |
| 1381 | return emac_base; |
| 1382 | |
| 1383 | } |
| 1384 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 1385 | /******************************************************************/ |
| 1386 | /* CL45 access functions */ |
| 1387 | /******************************************************************/ |
Yaniv Rosner | 65a001b | 2011-01-31 04:22:03 +0000 | [diff] [blame^] | 1388 | static u8 bnx2x_cl45_write(struct bnx2x *bp, struct bnx2x_phy *phy, |
| 1389 | u8 devad, u16 reg, u16 val) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1390 | { |
| 1391 | u32 tmp, saved_mode; |
| 1392 | u8 i, rc = 0; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 1393 | /* |
| 1394 | * Set clause 45 mode, slow down the MDIO clock to 2.5MHz |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1395 | * (a value of 49==0x31) and make sure that the AUTO poll is off |
| 1396 | */ |
Eilon Greenstein | 589abe3 | 2009-02-12 08:36:55 +0000 | [diff] [blame] | 1397 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1398 | saved_mode = REG_RD(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_MODE); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1399 | tmp = saved_mode & ~(EMAC_MDIO_MODE_AUTO_POLL | |
| 1400 | EMAC_MDIO_MODE_CLOCK_CNT); |
| 1401 | tmp |= (EMAC_MDIO_MODE_CLAUSE_45 | |
| 1402 | (49 << EMAC_MDIO_MODE_CLOCK_CNT_BITSHIFT)); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1403 | REG_WR(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_MODE, tmp); |
| 1404 | REG_RD(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_MODE); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1405 | udelay(40); |
| 1406 | |
| 1407 | /* address */ |
| 1408 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1409 | tmp = ((phy->addr << 21) | (devad << 16) | reg | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1410 | EMAC_MDIO_COMM_COMMAND_ADDRESS | |
| 1411 | EMAC_MDIO_COMM_START_BUSY); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1412 | REG_WR(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM, tmp); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1413 | |
| 1414 | for (i = 0; i < 50; i++) { |
| 1415 | udelay(10); |
| 1416 | |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1417 | tmp = REG_RD(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1418 | if (!(tmp & EMAC_MDIO_COMM_START_BUSY)) { |
| 1419 | udelay(5); |
| 1420 | break; |
| 1421 | } |
| 1422 | } |
| 1423 | if (tmp & EMAC_MDIO_COMM_START_BUSY) { |
| 1424 | DP(NETIF_MSG_LINK, "write phy register failed\n"); |
| 1425 | rc = -EFAULT; |
| 1426 | } else { |
| 1427 | /* data */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1428 | tmp = ((phy->addr << 21) | (devad << 16) | val | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1429 | EMAC_MDIO_COMM_COMMAND_WRITE_45 | |
| 1430 | EMAC_MDIO_COMM_START_BUSY); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1431 | REG_WR(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM, tmp); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1432 | |
| 1433 | for (i = 0; i < 50; i++) { |
| 1434 | udelay(10); |
| 1435 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1436 | tmp = REG_RD(bp, phy->mdio_ctrl + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1437 | EMAC_REG_EMAC_MDIO_COMM); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1438 | if (!(tmp & EMAC_MDIO_COMM_START_BUSY)) { |
| 1439 | udelay(5); |
| 1440 | break; |
| 1441 | } |
| 1442 | } |
| 1443 | if (tmp & EMAC_MDIO_COMM_START_BUSY) { |
| 1444 | DP(NETIF_MSG_LINK, "write phy register failed\n"); |
| 1445 | rc = -EFAULT; |
| 1446 | } |
| 1447 | } |
| 1448 | |
| 1449 | /* Restore the saved mode */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1450 | REG_WR(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_MODE, saved_mode); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1451 | |
| 1452 | return rc; |
| 1453 | } |
| 1454 | |
Yaniv Rosner | 65a001b | 2011-01-31 04:22:03 +0000 | [diff] [blame^] | 1455 | static u8 bnx2x_cl45_read(struct bnx2x *bp, struct bnx2x_phy *phy, |
| 1456 | u8 devad, u16 reg, u16 *ret_val) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1457 | { |
| 1458 | u32 val, saved_mode; |
| 1459 | u16 i; |
| 1460 | u8 rc = 0; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 1461 | /* |
| 1462 | * Set clause 45 mode, slow down the MDIO clock to 2.5MHz |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1463 | * (a value of 49==0x31) and make sure that the AUTO poll is off |
| 1464 | */ |
Eilon Greenstein | 589abe3 | 2009-02-12 08:36:55 +0000 | [diff] [blame] | 1465 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1466 | saved_mode = REG_RD(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_MODE); |
| 1467 | val = saved_mode & ~((EMAC_MDIO_MODE_AUTO_POLL | |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1468 | EMAC_MDIO_MODE_CLOCK_CNT)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1469 | val |= (EMAC_MDIO_MODE_CLAUSE_45 | |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 1470 | (49L << EMAC_MDIO_MODE_CLOCK_CNT_BITSHIFT)); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1471 | REG_WR(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_MODE, val); |
| 1472 | REG_RD(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_MODE); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1473 | udelay(40); |
| 1474 | |
| 1475 | /* address */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1476 | val = ((phy->addr << 21) | (devad << 16) | reg | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1477 | EMAC_MDIO_COMM_COMMAND_ADDRESS | |
| 1478 | EMAC_MDIO_COMM_START_BUSY); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1479 | REG_WR(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM, val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1480 | |
| 1481 | for (i = 0; i < 50; i++) { |
| 1482 | udelay(10); |
| 1483 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1484 | val = REG_RD(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1485 | if (!(val & EMAC_MDIO_COMM_START_BUSY)) { |
| 1486 | udelay(5); |
| 1487 | break; |
| 1488 | } |
| 1489 | } |
| 1490 | if (val & EMAC_MDIO_COMM_START_BUSY) { |
| 1491 | DP(NETIF_MSG_LINK, "read phy register failed\n"); |
| 1492 | |
| 1493 | *ret_val = 0; |
| 1494 | rc = -EFAULT; |
| 1495 | |
| 1496 | } else { |
| 1497 | /* data */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1498 | val = ((phy->addr << 21) | (devad << 16) | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1499 | EMAC_MDIO_COMM_COMMAND_READ_45 | |
| 1500 | EMAC_MDIO_COMM_START_BUSY); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1501 | REG_WR(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM, val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1502 | |
| 1503 | for (i = 0; i < 50; i++) { |
| 1504 | udelay(10); |
| 1505 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1506 | val = REG_RD(bp, phy->mdio_ctrl + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1507 | EMAC_REG_EMAC_MDIO_COMM); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1508 | if (!(val & EMAC_MDIO_COMM_START_BUSY)) { |
| 1509 | *ret_val = (u16)(val & EMAC_MDIO_COMM_DATA); |
| 1510 | break; |
| 1511 | } |
| 1512 | } |
| 1513 | if (val & EMAC_MDIO_COMM_START_BUSY) { |
| 1514 | DP(NETIF_MSG_LINK, "read phy register failed\n"); |
| 1515 | |
| 1516 | *ret_val = 0; |
| 1517 | rc = -EFAULT; |
| 1518 | } |
| 1519 | } |
| 1520 | |
| 1521 | /* Restore the saved mode */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1522 | REG_WR(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_MODE, saved_mode); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1523 | |
| 1524 | return rc; |
| 1525 | } |
| 1526 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1527 | u8 bnx2x_phy_read(struct link_params *params, u8 phy_addr, |
| 1528 | u8 devad, u16 reg, u16 *ret_val) |
| 1529 | { |
| 1530 | u8 phy_index; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 1531 | /* |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1532 | * Probe for the phy according to the given phy_addr, and execute |
| 1533 | * the read request on it |
| 1534 | */ |
| 1535 | for (phy_index = 0; phy_index < params->num_phys; phy_index++) { |
| 1536 | if (params->phy[phy_index].addr == phy_addr) { |
| 1537 | return bnx2x_cl45_read(params->bp, |
| 1538 | ¶ms->phy[phy_index], devad, |
| 1539 | reg, ret_val); |
| 1540 | } |
| 1541 | } |
| 1542 | return -EINVAL; |
| 1543 | } |
| 1544 | |
| 1545 | u8 bnx2x_phy_write(struct link_params *params, u8 phy_addr, |
| 1546 | u8 devad, u16 reg, u16 val) |
| 1547 | { |
| 1548 | u8 phy_index; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 1549 | /* |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1550 | * Probe for the phy according to the given phy_addr, and execute |
| 1551 | * the write request on it |
| 1552 | */ |
| 1553 | for (phy_index = 0; phy_index < params->num_phys; phy_index++) { |
| 1554 | if (params->phy[phy_index].addr == phy_addr) { |
| 1555 | return bnx2x_cl45_write(params->bp, |
| 1556 | ¶ms->phy[phy_index], devad, |
| 1557 | reg, val); |
| 1558 | } |
| 1559 | } |
| 1560 | return -EINVAL; |
| 1561 | } |
| 1562 | |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1563 | static void bnx2x_set_aer_mmd_xgxs(struct link_params *params, |
| 1564 | struct bnx2x_phy *phy) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1565 | { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1566 | u32 ser_lane; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1567 | u16 offset, aer_val; |
| 1568 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1569 | ser_lane = ((params->lane_config & |
| 1570 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_MASK) >> |
| 1571 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_SHIFT); |
| 1572 | |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1573 | offset = phy->addr + ser_lane; |
| 1574 | if (CHIP_IS_E2(bp)) |
Yaniv Rosner | 82a0d47 | 2011-01-18 04:33:52 +0000 | [diff] [blame] | 1575 | aer_val = 0x3800 + offset - 1; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1576 | else |
| 1577 | aer_val = 0x3800 + offset; |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 1578 | CL22_WR_OVER_CL45(bp, phy, MDIO_REG_BANK_AER_BLOCK, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1579 | MDIO_AER_BLOCK_AER_REG, aer_val); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1580 | } |
| 1581 | static void bnx2x_set_aer_mmd_serdes(struct bnx2x *bp, |
| 1582 | struct bnx2x_phy *phy) |
| 1583 | { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 1584 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1585 | MDIO_REG_BANK_AER_BLOCK, |
| 1586 | MDIO_AER_BLOCK_AER_REG, 0x3800); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1587 | } |
| 1588 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 1589 | /******************************************************************/ |
| 1590 | /* Internal phy section */ |
| 1591 | /******************************************************************/ |
| 1592 | |
| 1593 | static void bnx2x_set_serdes_access(struct bnx2x *bp, u8 port) |
| 1594 | { |
| 1595 | u32 emac_base = (port) ? GRCBASE_EMAC1 : GRCBASE_EMAC0; |
| 1596 | |
| 1597 | /* Set Clause 22 */ |
| 1598 | REG_WR(bp, NIG_REG_SERDES0_CTRL_MD_ST + port*0x10, 1); |
| 1599 | REG_WR(bp, emac_base + EMAC_REG_EMAC_MDIO_COMM, 0x245f8000); |
| 1600 | udelay(500); |
| 1601 | REG_WR(bp, emac_base + EMAC_REG_EMAC_MDIO_COMM, 0x245d000f); |
| 1602 | udelay(500); |
| 1603 | /* Set Clause 45 */ |
| 1604 | REG_WR(bp, NIG_REG_SERDES0_CTRL_MD_ST + port*0x10, 0); |
| 1605 | } |
| 1606 | |
| 1607 | static void bnx2x_serdes_deassert(struct bnx2x *bp, u8 port) |
| 1608 | { |
| 1609 | u32 val; |
| 1610 | |
| 1611 | DP(NETIF_MSG_LINK, "bnx2x_serdes_deassert\n"); |
| 1612 | |
| 1613 | val = SERDES_RESET_BITS << (port*16); |
| 1614 | |
| 1615 | /* reset and unreset the SerDes/XGXS */ |
| 1616 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_3_CLEAR, val); |
| 1617 | udelay(500); |
| 1618 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_3_SET, val); |
| 1619 | |
| 1620 | bnx2x_set_serdes_access(bp, port); |
| 1621 | |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1622 | REG_WR(bp, NIG_REG_SERDES0_CTRL_MD_DEVAD + port*0x10, |
| 1623 | DEFAULT_PHY_DEV_ADDR); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 1624 | } |
| 1625 | |
| 1626 | static void bnx2x_xgxs_deassert(struct link_params *params) |
| 1627 | { |
| 1628 | struct bnx2x *bp = params->bp; |
| 1629 | u8 port; |
| 1630 | u32 val; |
| 1631 | DP(NETIF_MSG_LINK, "bnx2x_xgxs_deassert\n"); |
| 1632 | port = params->port; |
| 1633 | |
| 1634 | val = XGXS_RESET_BITS << (port*16); |
| 1635 | |
| 1636 | /* reset and unreset the SerDes/XGXS */ |
| 1637 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_3_CLEAR, val); |
| 1638 | udelay(500); |
| 1639 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_3_SET, val); |
| 1640 | |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1641 | REG_WR(bp, NIG_REG_XGXS0_CTRL_MD_ST + port*0x18, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 1642 | REG_WR(bp, NIG_REG_XGXS0_CTRL_MD_DEVAD + port*0x18, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1643 | params->phy[INT_PHY].def_md_devad); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 1644 | } |
| 1645 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 1646 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 1647 | void bnx2x_link_status_update(struct link_params *params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1648 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 1649 | { |
| 1650 | struct bnx2x *bp = params->bp; |
| 1651 | u8 link_10g; |
| 1652 | u8 port = params->port; |
| 1653 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 1654 | vars->link_status = REG_RD(bp, params->shmem_base + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1655 | offsetof(struct shmem_region, |
| 1656 | port_mb[port].link_status)); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 1657 | |
| 1658 | vars->link_up = (vars->link_status & LINK_STATUS_LINK_UP); |
| 1659 | |
| 1660 | if (vars->link_up) { |
| 1661 | DP(NETIF_MSG_LINK, "phy link up\n"); |
| 1662 | |
| 1663 | vars->phy_link_up = 1; |
| 1664 | vars->duplex = DUPLEX_FULL; |
| 1665 | switch (vars->link_status & |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1666 | LINK_STATUS_SPEED_AND_DUPLEX_MASK) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 1667 | case LINK_10THD: |
| 1668 | vars->duplex = DUPLEX_HALF; |
| 1669 | /* fall thru */ |
| 1670 | case LINK_10TFD: |
| 1671 | vars->line_speed = SPEED_10; |
| 1672 | break; |
| 1673 | |
| 1674 | case LINK_100TXHD: |
| 1675 | vars->duplex = DUPLEX_HALF; |
| 1676 | /* fall thru */ |
| 1677 | case LINK_100T4: |
| 1678 | case LINK_100TXFD: |
| 1679 | vars->line_speed = SPEED_100; |
| 1680 | break; |
| 1681 | |
| 1682 | case LINK_1000THD: |
| 1683 | vars->duplex = DUPLEX_HALF; |
| 1684 | /* fall thru */ |
| 1685 | case LINK_1000TFD: |
| 1686 | vars->line_speed = SPEED_1000; |
| 1687 | break; |
| 1688 | |
| 1689 | case LINK_2500THD: |
| 1690 | vars->duplex = DUPLEX_HALF; |
| 1691 | /* fall thru */ |
| 1692 | case LINK_2500TFD: |
| 1693 | vars->line_speed = SPEED_2500; |
| 1694 | break; |
| 1695 | |
| 1696 | case LINK_10GTFD: |
| 1697 | vars->line_speed = SPEED_10000; |
| 1698 | break; |
| 1699 | |
| 1700 | case LINK_12GTFD: |
| 1701 | vars->line_speed = SPEED_12000; |
| 1702 | break; |
| 1703 | |
| 1704 | case LINK_12_5GTFD: |
| 1705 | vars->line_speed = SPEED_12500; |
| 1706 | break; |
| 1707 | |
| 1708 | case LINK_13GTFD: |
| 1709 | vars->line_speed = SPEED_13000; |
| 1710 | break; |
| 1711 | |
| 1712 | case LINK_15GTFD: |
| 1713 | vars->line_speed = SPEED_15000; |
| 1714 | break; |
| 1715 | |
| 1716 | case LINK_16GTFD: |
| 1717 | vars->line_speed = SPEED_16000; |
| 1718 | break; |
| 1719 | |
| 1720 | default: |
| 1721 | break; |
| 1722 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 1723 | vars->flow_ctrl = 0; |
| 1724 | if (vars->link_status & LINK_STATUS_TX_FLOW_CONTROL_ENABLED) |
| 1725 | vars->flow_ctrl |= BNX2X_FLOW_CTRL_TX; |
| 1726 | |
| 1727 | if (vars->link_status & LINK_STATUS_RX_FLOW_CONTROL_ENABLED) |
| 1728 | vars->flow_ctrl |= BNX2X_FLOW_CTRL_RX; |
| 1729 | |
| 1730 | if (!vars->flow_ctrl) |
| 1731 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 1732 | |
| 1733 | if (vars->line_speed && |
| 1734 | ((vars->line_speed == SPEED_10) || |
| 1735 | (vars->line_speed == SPEED_100))) { |
| 1736 | vars->phy_flags |= PHY_SGMII_FLAG; |
| 1737 | } else { |
| 1738 | vars->phy_flags &= ~PHY_SGMII_FLAG; |
| 1739 | } |
| 1740 | |
| 1741 | /* anything 10 and over uses the bmac */ |
| 1742 | link_10g = ((vars->line_speed == SPEED_10000) || |
| 1743 | (vars->line_speed == SPEED_12000) || |
| 1744 | (vars->line_speed == SPEED_12500) || |
| 1745 | (vars->line_speed == SPEED_13000) || |
| 1746 | (vars->line_speed == SPEED_15000) || |
| 1747 | (vars->line_speed == SPEED_16000)); |
| 1748 | if (link_10g) |
| 1749 | vars->mac_type = MAC_TYPE_BMAC; |
| 1750 | else |
| 1751 | vars->mac_type = MAC_TYPE_EMAC; |
| 1752 | |
| 1753 | } else { /* link down */ |
| 1754 | DP(NETIF_MSG_LINK, "phy link down\n"); |
| 1755 | |
| 1756 | vars->phy_link_up = 0; |
| 1757 | |
| 1758 | vars->line_speed = 0; |
| 1759 | vars->duplex = DUPLEX_FULL; |
| 1760 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 1761 | |
| 1762 | /* indicate no mac active */ |
| 1763 | vars->mac_type = MAC_TYPE_NONE; |
| 1764 | } |
| 1765 | |
| 1766 | DP(NETIF_MSG_LINK, "link_status 0x%x phy_link_up %x\n", |
| 1767 | vars->link_status, vars->phy_link_up); |
| 1768 | DP(NETIF_MSG_LINK, "line_speed %x duplex %x flow_ctrl 0x%x\n", |
| 1769 | vars->line_speed, vars->duplex, vars->flow_ctrl); |
| 1770 | } |
| 1771 | |
| 1772 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1773 | static void bnx2x_set_master_ln(struct link_params *params, |
| 1774 | struct bnx2x_phy *phy) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1775 | { |
| 1776 | struct bnx2x *bp = params->bp; |
| 1777 | u16 new_master_ln, ser_lane; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1778 | ser_lane = ((params->lane_config & |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1779 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_MASK) >> |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1780 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_SHIFT); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1781 | |
| 1782 | /* set the master_ln for AN */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 1783 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1784 | MDIO_REG_BANK_XGXS_BLOCK2, |
| 1785 | MDIO_XGXS_BLOCK2_TEST_MODE_LANE, |
| 1786 | &new_master_ln); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1787 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 1788 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1789 | MDIO_REG_BANK_XGXS_BLOCK2 , |
| 1790 | MDIO_XGXS_BLOCK2_TEST_MODE_LANE, |
| 1791 | (new_master_ln | ser_lane)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1792 | } |
| 1793 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1794 | static u8 bnx2x_reset_unicore(struct link_params *params, |
| 1795 | struct bnx2x_phy *phy, |
| 1796 | u8 set_serdes) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1797 | { |
| 1798 | struct bnx2x *bp = params->bp; |
| 1799 | u16 mii_control; |
| 1800 | u16 i; |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 1801 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1802 | MDIO_REG_BANK_COMBO_IEEE0, |
| 1803 | MDIO_COMBO_IEEE0_MII_CONTROL, &mii_control); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1804 | |
| 1805 | /* reset the unicore */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 1806 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1807 | MDIO_REG_BANK_COMBO_IEEE0, |
| 1808 | MDIO_COMBO_IEEE0_MII_CONTROL, |
| 1809 | (mii_control | |
| 1810 | MDIO_COMBO_IEEO_MII_CONTROL_RESET)); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1811 | if (set_serdes) |
| 1812 | bnx2x_set_serdes_access(bp, params->port); |
Eilon Greenstein | c1b7399 | 2009-02-12 08:37:07 +0000 | [diff] [blame] | 1813 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1814 | /* wait for the reset to self clear */ |
| 1815 | for (i = 0; i < MDIO_ACCESS_TIMEOUT; i++) { |
| 1816 | udelay(5); |
| 1817 | |
| 1818 | /* the reset erased the previous bank value */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 1819 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1820 | MDIO_REG_BANK_COMBO_IEEE0, |
| 1821 | MDIO_COMBO_IEEE0_MII_CONTROL, |
| 1822 | &mii_control); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1823 | |
| 1824 | if (!(mii_control & MDIO_COMBO_IEEO_MII_CONTROL_RESET)) { |
| 1825 | udelay(5); |
| 1826 | return 0; |
| 1827 | } |
| 1828 | } |
| 1829 | |
| 1830 | DP(NETIF_MSG_LINK, "BUG! XGXS is still in reset!\n"); |
| 1831 | return -EINVAL; |
| 1832 | |
| 1833 | } |
| 1834 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1835 | static void bnx2x_set_swap_lanes(struct link_params *params, |
| 1836 | struct bnx2x_phy *phy) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1837 | { |
| 1838 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 1839 | /* |
| 1840 | * Each two bits represents a lane number: |
| 1841 | * No swap is 0123 => 0x1b no need to enable the swap |
| 1842 | */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1843 | u16 ser_lane, rx_lane_swap, tx_lane_swap; |
| 1844 | |
| 1845 | ser_lane = ((params->lane_config & |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1846 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_MASK) >> |
| 1847 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_SHIFT); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1848 | rx_lane_swap = ((params->lane_config & |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1849 | PORT_HW_CFG_LANE_SWAP_CFG_RX_MASK) >> |
| 1850 | PORT_HW_CFG_LANE_SWAP_CFG_RX_SHIFT); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1851 | tx_lane_swap = ((params->lane_config & |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1852 | PORT_HW_CFG_LANE_SWAP_CFG_TX_MASK) >> |
| 1853 | PORT_HW_CFG_LANE_SWAP_CFG_TX_SHIFT); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1854 | |
| 1855 | if (rx_lane_swap != 0x1b) { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 1856 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1857 | MDIO_REG_BANK_XGXS_BLOCK2, |
| 1858 | MDIO_XGXS_BLOCK2_RX_LN_SWAP, |
| 1859 | (rx_lane_swap | |
| 1860 | MDIO_XGXS_BLOCK2_RX_LN_SWAP_ENABLE | |
| 1861 | MDIO_XGXS_BLOCK2_RX_LN_SWAP_FORCE_ENABLE)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1862 | } else { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 1863 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1864 | MDIO_REG_BANK_XGXS_BLOCK2, |
| 1865 | MDIO_XGXS_BLOCK2_RX_LN_SWAP, 0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1866 | } |
| 1867 | |
| 1868 | if (tx_lane_swap != 0x1b) { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 1869 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1870 | MDIO_REG_BANK_XGXS_BLOCK2, |
| 1871 | MDIO_XGXS_BLOCK2_TX_LN_SWAP, |
| 1872 | (tx_lane_swap | |
| 1873 | MDIO_XGXS_BLOCK2_TX_LN_SWAP_ENABLE)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1874 | } else { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 1875 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1876 | MDIO_REG_BANK_XGXS_BLOCK2, |
| 1877 | MDIO_XGXS_BLOCK2_TX_LN_SWAP, 0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1878 | } |
| 1879 | } |
| 1880 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1881 | static void bnx2x_set_parallel_detection(struct bnx2x_phy *phy, |
| 1882 | struct link_params *params) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1883 | { |
| 1884 | struct bnx2x *bp = params->bp; |
| 1885 | u16 control2; |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 1886 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1887 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 1888 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL2, |
| 1889 | &control2); |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 1890 | if (phy->speed_cap_mask & PORT_HW_CFG_SPEED_CAPABILITY_D0_1G) |
Yaniv Rosner | 18afb0a | 2009-11-05 19:18:04 +0200 | [diff] [blame] | 1891 | control2 |= MDIO_SERDES_DIGITAL_A_1000X_CONTROL2_PRL_DT_EN; |
| 1892 | else |
| 1893 | control2 &= ~MDIO_SERDES_DIGITAL_A_1000X_CONTROL2_PRL_DT_EN; |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 1894 | DP(NETIF_MSG_LINK, "phy->speed_cap_mask = 0x%x, control2 = 0x%x\n", |
| 1895 | phy->speed_cap_mask, control2); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 1896 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1897 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 1898 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL2, |
| 1899 | control2); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1900 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1901 | if ((phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT) && |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 1902 | (phy->speed_cap_mask & |
Yaniv Rosner | 18afb0a | 2009-11-05 19:18:04 +0200 | [diff] [blame] | 1903 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G)) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1904 | DP(NETIF_MSG_LINK, "XGXS\n"); |
| 1905 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 1906 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1907 | MDIO_REG_BANK_10G_PARALLEL_DETECT, |
| 1908 | MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_LINK, |
| 1909 | MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_LINK_CNT); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1910 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 1911 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1912 | MDIO_REG_BANK_10G_PARALLEL_DETECT, |
| 1913 | MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_CONTROL, |
| 1914 | &control2); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1915 | |
| 1916 | |
| 1917 | control2 |= |
| 1918 | MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_CONTROL_PARDET10G_EN; |
| 1919 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 1920 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1921 | MDIO_REG_BANK_10G_PARALLEL_DETECT, |
| 1922 | MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_CONTROL, |
| 1923 | control2); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1924 | |
| 1925 | /* Disable parallel detection of HiG */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 1926 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1927 | MDIO_REG_BANK_XGXS_BLOCK2, |
| 1928 | MDIO_XGXS_BLOCK2_UNICORE_MODE_10G, |
| 1929 | MDIO_XGXS_BLOCK2_UNICORE_MODE_10G_CX4_XGXS | |
| 1930 | MDIO_XGXS_BLOCK2_UNICORE_MODE_10G_HIGIG_XGXS); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1931 | } |
| 1932 | } |
| 1933 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1934 | static void bnx2x_set_autoneg(struct bnx2x_phy *phy, |
| 1935 | struct link_params *params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1936 | struct link_vars *vars, |
| 1937 | u8 enable_cl73) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1938 | { |
| 1939 | struct bnx2x *bp = params->bp; |
| 1940 | u16 reg_val; |
| 1941 | |
| 1942 | /* CL37 Autoneg */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 1943 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1944 | MDIO_REG_BANK_COMBO_IEEE0, |
| 1945 | MDIO_COMBO_IEEE0_MII_CONTROL, ®_val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1946 | |
| 1947 | /* CL37 Autoneg Enabled */ |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 1948 | if (vars->line_speed == SPEED_AUTO_NEG) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1949 | reg_val |= MDIO_COMBO_IEEO_MII_CONTROL_AN_EN; |
| 1950 | else /* CL37 Autoneg Disabled */ |
| 1951 | reg_val &= ~(MDIO_COMBO_IEEO_MII_CONTROL_AN_EN | |
| 1952 | MDIO_COMBO_IEEO_MII_CONTROL_RESTART_AN); |
| 1953 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 1954 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1955 | MDIO_REG_BANK_COMBO_IEEE0, |
| 1956 | MDIO_COMBO_IEEE0_MII_CONTROL, reg_val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1957 | |
| 1958 | /* Enable/Disable Autodetection */ |
| 1959 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 1960 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1961 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 1962 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL1, ®_val); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 1963 | reg_val &= ~(MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_SIGNAL_DETECT_EN | |
| 1964 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_INVERT_SIGNAL_DETECT); |
| 1965 | reg_val |= MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_FIBER_MODE; |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 1966 | if (vars->line_speed == SPEED_AUTO_NEG) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1967 | reg_val |= MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_AUTODET; |
| 1968 | else |
| 1969 | reg_val &= ~MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_AUTODET; |
| 1970 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 1971 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1972 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 1973 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL1, reg_val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1974 | |
| 1975 | /* Enable TetonII and BAM autoneg */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 1976 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1977 | MDIO_REG_BANK_BAM_NEXT_PAGE, |
| 1978 | MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL, |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1979 | ®_val); |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 1980 | if (vars->line_speed == SPEED_AUTO_NEG) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1981 | /* Enable BAM aneg Mode and TetonII aneg Mode */ |
| 1982 | reg_val |= (MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL_BAM_MODE | |
| 1983 | MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL_TETON_AN); |
| 1984 | } else { |
| 1985 | /* TetonII and BAM Autoneg Disabled */ |
| 1986 | reg_val &= ~(MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL_BAM_MODE | |
| 1987 | MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL_TETON_AN); |
| 1988 | } |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 1989 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1990 | MDIO_REG_BANK_BAM_NEXT_PAGE, |
| 1991 | MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL, |
| 1992 | reg_val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1993 | |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 1994 | if (enable_cl73) { |
| 1995 | /* Enable Cl73 FSM status bits */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 1996 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1997 | MDIO_REG_BANK_CL73_USERB0, |
| 1998 | MDIO_CL73_USERB0_CL73_UCTRL, |
| 1999 | 0xe); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2000 | |
| 2001 | /* Enable BAM Station Manager*/ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2002 | CL22_WR_OVER_CL45(bp, phy, |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2003 | MDIO_REG_BANK_CL73_USERB0, |
| 2004 | MDIO_CL73_USERB0_CL73_BAM_CTRL1, |
| 2005 | MDIO_CL73_USERB0_CL73_BAM_CTRL1_BAM_EN | |
| 2006 | MDIO_CL73_USERB0_CL73_BAM_CTRL1_BAM_STATION_MNGR_EN | |
| 2007 | MDIO_CL73_USERB0_CL73_BAM_CTRL1_BAM_NP_AFTER_BP_EN); |
| 2008 | |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 2009 | /* Advertise CL73 link speeds */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2010 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2011 | MDIO_REG_BANK_CL73_IEEEB1, |
| 2012 | MDIO_CL73_IEEEB1_AN_ADV2, |
| 2013 | ®_val); |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 2014 | if (phy->speed_cap_mask & |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 2015 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G) |
| 2016 | reg_val |= MDIO_CL73_IEEEB1_AN_ADV2_ADVR_10G_KX4; |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 2017 | if (phy->speed_cap_mask & |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 2018 | PORT_HW_CFG_SPEED_CAPABILITY_D0_1G) |
| 2019 | reg_val |= MDIO_CL73_IEEEB1_AN_ADV2_ADVR_1000M_KX; |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2020 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2021 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2022 | MDIO_REG_BANK_CL73_IEEEB1, |
| 2023 | MDIO_CL73_IEEEB1_AN_ADV2, |
| 2024 | reg_val); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2025 | |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2026 | /* CL73 Autoneg Enabled */ |
| 2027 | reg_val = MDIO_CL73_IEEEB0_CL73_AN_CONTROL_AN_EN; |
| 2028 | |
| 2029 | } else /* CL73 Autoneg Disabled */ |
| 2030 | reg_val = 0; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2031 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2032 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2033 | MDIO_REG_BANK_CL73_IEEEB0, |
| 2034 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL, reg_val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2035 | } |
| 2036 | |
| 2037 | /* program SerDes, forced speed */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2038 | static void bnx2x_program_serdes(struct bnx2x_phy *phy, |
| 2039 | struct link_params *params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2040 | struct link_vars *vars) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2041 | { |
| 2042 | struct bnx2x *bp = params->bp; |
| 2043 | u16 reg_val; |
| 2044 | |
Eilon Greenstein | 5793720 | 2009-08-12 08:23:53 +0000 | [diff] [blame] | 2045 | /* program duplex, disable autoneg and sgmii*/ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2046 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2047 | MDIO_REG_BANK_COMBO_IEEE0, |
| 2048 | MDIO_COMBO_IEEE0_MII_CONTROL, ®_val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2049 | reg_val &= ~(MDIO_COMBO_IEEO_MII_CONTROL_FULL_DUPLEX | |
Eilon Greenstein | 5793720 | 2009-08-12 08:23:53 +0000 | [diff] [blame] | 2050 | MDIO_COMBO_IEEO_MII_CONTROL_AN_EN | |
| 2051 | MDIO_COMBO_IEEO_MII_CONTROL_MAN_SGMII_SP_MASK); |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 2052 | if (phy->req_duplex == DUPLEX_FULL) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2053 | reg_val |= MDIO_COMBO_IEEO_MII_CONTROL_FULL_DUPLEX; |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2054 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2055 | MDIO_REG_BANK_COMBO_IEEE0, |
| 2056 | MDIO_COMBO_IEEE0_MII_CONTROL, reg_val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2057 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2058 | /* |
| 2059 | * program speed |
| 2060 | * - needed only if the speed is greater than 1G (2.5G or 10G) |
| 2061 | */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2062 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2063 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 2064 | MDIO_SERDES_DIGITAL_MISC1, ®_val); |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 2065 | /* clearing the speed value before setting the right speed */ |
| 2066 | DP(NETIF_MSG_LINK, "MDIO_REG_BANK_SERDES_DIGITAL = 0x%x\n", reg_val); |
| 2067 | |
| 2068 | reg_val &= ~(MDIO_SERDES_DIGITAL_MISC1_FORCE_SPEED_MASK | |
| 2069 | MDIO_SERDES_DIGITAL_MISC1_FORCE_SPEED_SEL); |
| 2070 | |
| 2071 | if (!((vars->line_speed == SPEED_1000) || |
| 2072 | (vars->line_speed == SPEED_100) || |
| 2073 | (vars->line_speed == SPEED_10))) { |
| 2074 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2075 | reg_val |= (MDIO_SERDES_DIGITAL_MISC1_REFCLK_SEL_156_25M | |
| 2076 | MDIO_SERDES_DIGITAL_MISC1_FORCE_SPEED_SEL); |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 2077 | if (vars->line_speed == SPEED_10000) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2078 | reg_val |= |
| 2079 | MDIO_SERDES_DIGITAL_MISC1_FORCE_SPEED_10G_CX4; |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 2080 | if (vars->line_speed == SPEED_13000) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2081 | reg_val |= |
| 2082 | MDIO_SERDES_DIGITAL_MISC1_FORCE_SPEED_13G; |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 2083 | } |
| 2084 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2085 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2086 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 2087 | MDIO_SERDES_DIGITAL_MISC1, reg_val); |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 2088 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2089 | } |
| 2090 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2091 | static void bnx2x_set_brcm_cl37_advertisment(struct bnx2x_phy *phy, |
| 2092 | struct link_params *params) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2093 | { |
| 2094 | struct bnx2x *bp = params->bp; |
| 2095 | u16 val = 0; |
| 2096 | |
| 2097 | /* configure the 48 bits for BAM AN */ |
| 2098 | |
| 2099 | /* set extended capabilities */ |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 2100 | 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] | 2101 | val |= MDIO_OVER_1G_UP1_2_5G; |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 2102 | if (phy->speed_cap_mask & PORT_HW_CFG_SPEED_CAPABILITY_D0_10G) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2103 | val |= MDIO_OVER_1G_UP1_10G; |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2104 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2105 | MDIO_REG_BANK_OVER_1G, |
| 2106 | MDIO_OVER_1G_UP1, val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2107 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2108 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2109 | MDIO_REG_BANK_OVER_1G, |
| 2110 | MDIO_OVER_1G_UP3, 0x400); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2111 | } |
| 2112 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2113 | static void bnx2x_calc_ieee_aneg_adv(struct bnx2x_phy *phy, |
| 2114 | struct link_params *params, u16 *ieee_fc) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2115 | { |
Yaniv Rosner | d5cb9e9 | 2009-11-05 19:18:10 +0200 | [diff] [blame] | 2116 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 2117 | *ieee_fc = MDIO_COMBO_IEEE0_AUTO_NEG_ADV_FULL_DUPLEX; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2118 | /* |
| 2119 | * Resolve pause mode and advertisement. |
| 2120 | * Please refer to Table 28B-3 of the 802.3ab-1999 spec |
| 2121 | */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2122 | |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 2123 | switch (phy->req_flow_ctrl) { |
David S. Miller | c0700f9 | 2008-12-16 23:53:20 -0800 | [diff] [blame] | 2124 | case BNX2X_FLOW_CTRL_AUTO: |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2125 | if (params->req_fc_auto_adv == BNX2X_FLOW_CTRL_BOTH) |
| 2126 | *ieee_fc |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH; |
| 2127 | else |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 2128 | *ieee_fc |= |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2129 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2130 | break; |
David S. Miller | c0700f9 | 2008-12-16 23:53:20 -0800 | [diff] [blame] | 2131 | case BNX2X_FLOW_CTRL_TX: |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2132 | *ieee_fc |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2133 | break; |
| 2134 | |
David S. Miller | c0700f9 | 2008-12-16 23:53:20 -0800 | [diff] [blame] | 2135 | case BNX2X_FLOW_CTRL_RX: |
| 2136 | case BNX2X_FLOW_CTRL_BOTH: |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 2137 | *ieee_fc |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2138 | break; |
| 2139 | |
David S. Miller | c0700f9 | 2008-12-16 23:53:20 -0800 | [diff] [blame] | 2140 | case BNX2X_FLOW_CTRL_NONE: |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2141 | default: |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 2142 | *ieee_fc |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_NONE; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2143 | break; |
| 2144 | } |
Yaniv Rosner | d5cb9e9 | 2009-11-05 19:18:10 +0200 | [diff] [blame] | 2145 | DP(NETIF_MSG_LINK, "ieee_fc = 0x%x\n", *ieee_fc); |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 2146 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2147 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2148 | static void bnx2x_set_ieee_aneg_advertisment(struct bnx2x_phy *phy, |
| 2149 | struct link_params *params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2150 | u16 ieee_fc) |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 2151 | { |
| 2152 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 2153 | u16 val; |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 2154 | /* for AN, we are always publishing full duplex */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2155 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2156 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2157 | MDIO_REG_BANK_COMBO_IEEE0, |
| 2158 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV, ieee_fc); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2159 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2160 | MDIO_REG_BANK_CL73_IEEEB1, |
| 2161 | MDIO_CL73_IEEEB1_AN_ADV1, &val); |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 2162 | val &= ~MDIO_CL73_IEEEB1_AN_ADV1_PAUSE_BOTH; |
| 2163 | val |= ((ieee_fc<<3) & MDIO_CL73_IEEEB1_AN_ADV1_PAUSE_MASK); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2164 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2165 | MDIO_REG_BANK_CL73_IEEEB1, |
| 2166 | MDIO_CL73_IEEEB1_AN_ADV1, val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2167 | } |
| 2168 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2169 | static void bnx2x_restart_autoneg(struct bnx2x_phy *phy, |
| 2170 | struct link_params *params, |
| 2171 | u8 enable_cl73) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2172 | { |
| 2173 | struct bnx2x *bp = params->bp; |
Eilon Greenstein | 3a36f2e | 2009-02-12 08:37:09 +0000 | [diff] [blame] | 2174 | u16 mii_control; |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2175 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2176 | DP(NETIF_MSG_LINK, "bnx2x_restart_autoneg\n"); |
Eilon Greenstein | 3a36f2e | 2009-02-12 08:37:09 +0000 | [diff] [blame] | 2177 | /* Enable and restart BAM/CL37 aneg */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2178 | |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2179 | if (enable_cl73) { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2180 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2181 | MDIO_REG_BANK_CL73_IEEEB0, |
| 2182 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL, |
| 2183 | &mii_control); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2184 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2185 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2186 | MDIO_REG_BANK_CL73_IEEEB0, |
| 2187 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL, |
| 2188 | (mii_control | |
| 2189 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL_AN_EN | |
| 2190 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL_RESTART_AN)); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2191 | } else { |
| 2192 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2193 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2194 | MDIO_REG_BANK_COMBO_IEEE0, |
| 2195 | MDIO_COMBO_IEEE0_MII_CONTROL, |
| 2196 | &mii_control); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2197 | DP(NETIF_MSG_LINK, |
| 2198 | "bnx2x_restart_autoneg mii_control before = 0x%x\n", |
| 2199 | mii_control); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2200 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2201 | MDIO_REG_BANK_COMBO_IEEE0, |
| 2202 | MDIO_COMBO_IEEE0_MII_CONTROL, |
| 2203 | (mii_control | |
| 2204 | MDIO_COMBO_IEEO_MII_CONTROL_AN_EN | |
| 2205 | MDIO_COMBO_IEEO_MII_CONTROL_RESTART_AN)); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2206 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2207 | } |
| 2208 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2209 | static void bnx2x_initialize_sgmii_process(struct bnx2x_phy *phy, |
| 2210 | struct link_params *params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2211 | struct link_vars *vars) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2212 | { |
| 2213 | struct bnx2x *bp = params->bp; |
| 2214 | u16 control1; |
| 2215 | |
| 2216 | /* in SGMII mode, the unicore is always slave */ |
| 2217 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2218 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2219 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 2220 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL1, |
| 2221 | &control1); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2222 | control1 |= MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_INVERT_SIGNAL_DETECT; |
| 2223 | /* set sgmii mode (and not fiber) */ |
| 2224 | control1 &= ~(MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_FIBER_MODE | |
| 2225 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_AUTODET | |
| 2226 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_MSTR_MODE); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2227 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2228 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 2229 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL1, |
| 2230 | control1); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2231 | |
| 2232 | /* if forced speed */ |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 2233 | if (!(vars->line_speed == SPEED_AUTO_NEG)) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2234 | /* set speed, disable autoneg */ |
| 2235 | u16 mii_control; |
| 2236 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2237 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2238 | MDIO_REG_BANK_COMBO_IEEE0, |
| 2239 | MDIO_COMBO_IEEE0_MII_CONTROL, |
| 2240 | &mii_control); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2241 | mii_control &= ~(MDIO_COMBO_IEEO_MII_CONTROL_AN_EN | |
| 2242 | MDIO_COMBO_IEEO_MII_CONTROL_MAN_SGMII_SP_MASK| |
| 2243 | MDIO_COMBO_IEEO_MII_CONTROL_FULL_DUPLEX); |
| 2244 | |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 2245 | switch (vars->line_speed) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2246 | case SPEED_100: |
| 2247 | mii_control |= |
| 2248 | MDIO_COMBO_IEEO_MII_CONTROL_MAN_SGMII_SP_100; |
| 2249 | break; |
| 2250 | case SPEED_1000: |
| 2251 | mii_control |= |
| 2252 | MDIO_COMBO_IEEO_MII_CONTROL_MAN_SGMII_SP_1000; |
| 2253 | break; |
| 2254 | case SPEED_10: |
| 2255 | /* there is nothing to set for 10M */ |
| 2256 | break; |
| 2257 | default: |
| 2258 | /* invalid speed for SGMII */ |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 2259 | DP(NETIF_MSG_LINK, "Invalid line_speed 0x%x\n", |
| 2260 | vars->line_speed); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2261 | break; |
| 2262 | } |
| 2263 | |
| 2264 | /* setting the full duplex */ |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 2265 | if (phy->req_duplex == DUPLEX_FULL) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2266 | mii_control |= |
| 2267 | MDIO_COMBO_IEEO_MII_CONTROL_FULL_DUPLEX; |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2268 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2269 | MDIO_REG_BANK_COMBO_IEEE0, |
| 2270 | MDIO_COMBO_IEEE0_MII_CONTROL, |
| 2271 | mii_control); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2272 | |
| 2273 | } else { /* AN mode */ |
| 2274 | /* enable and restart AN */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2275 | bnx2x_restart_autoneg(phy, params, 0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2276 | } |
| 2277 | } |
| 2278 | |
| 2279 | |
| 2280 | /* |
| 2281 | * link management |
| 2282 | */ |
| 2283 | |
| 2284 | static void bnx2x_pause_resolve(struct link_vars *vars, u32 pause_result) |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 2285 | { /* LD LP */ |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2286 | switch (pause_result) { /* ASYM P ASYM P */ |
| 2287 | case 0xb: /* 1 0 1 1 */ |
David S. Miller | c0700f9 | 2008-12-16 23:53:20 -0800 | [diff] [blame] | 2288 | vars->flow_ctrl = BNX2X_FLOW_CTRL_TX; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2289 | break; |
| 2290 | |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2291 | case 0xe: /* 1 1 1 0 */ |
David S. Miller | c0700f9 | 2008-12-16 23:53:20 -0800 | [diff] [blame] | 2292 | vars->flow_ctrl = BNX2X_FLOW_CTRL_RX; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2293 | break; |
| 2294 | |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2295 | case 0x5: /* 0 1 0 1 */ |
| 2296 | case 0x7: /* 0 1 1 1 */ |
| 2297 | case 0xd: /* 1 1 0 1 */ |
| 2298 | case 0xf: /* 1 1 1 1 */ |
David S. Miller | c0700f9 | 2008-12-16 23:53:20 -0800 | [diff] [blame] | 2299 | vars->flow_ctrl = BNX2X_FLOW_CTRL_BOTH; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2300 | break; |
| 2301 | |
| 2302 | default: |
| 2303 | break; |
| 2304 | } |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 2305 | if (pause_result & (1<<0)) |
| 2306 | vars->link_status |= LINK_STATUS_LINK_PARTNER_SYMMETRIC_PAUSE; |
| 2307 | if (pause_result & (1<<1)) |
| 2308 | vars->link_status |= LINK_STATUS_LINK_PARTNER_ASYMMETRIC_PAUSE; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2309 | } |
| 2310 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2311 | static u8 bnx2x_direct_parallel_detect_used(struct bnx2x_phy *phy, |
| 2312 | struct link_params *params) |
Yaniv Rosner | 15ddd2d | 2009-11-05 19:18:12 +0200 | [diff] [blame] | 2313 | { |
| 2314 | struct bnx2x *bp = params->bp; |
| 2315 | u16 pd_10g, status2_1000x; |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 2316 | if (phy->req_line_speed != SPEED_AUTO_NEG) |
| 2317 | return 0; |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2318 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2319 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 2320 | MDIO_SERDES_DIGITAL_A_1000X_STATUS2, |
| 2321 | &status2_1000x); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2322 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2323 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 2324 | MDIO_SERDES_DIGITAL_A_1000X_STATUS2, |
| 2325 | &status2_1000x); |
Yaniv Rosner | 15ddd2d | 2009-11-05 19:18:12 +0200 | [diff] [blame] | 2326 | if (status2_1000x & MDIO_SERDES_DIGITAL_A_1000X_STATUS2_AN_DISABLED) { |
| 2327 | DP(NETIF_MSG_LINK, "1G parallel detect link on port %d\n", |
| 2328 | params->port); |
| 2329 | return 1; |
| 2330 | } |
| 2331 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2332 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2333 | MDIO_REG_BANK_10G_PARALLEL_DETECT, |
| 2334 | MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_STATUS, |
| 2335 | &pd_10g); |
Yaniv Rosner | 15ddd2d | 2009-11-05 19:18:12 +0200 | [diff] [blame] | 2336 | |
| 2337 | if (pd_10g & MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_STATUS_PD_LINK) { |
| 2338 | DP(NETIF_MSG_LINK, "10G parallel detect link on port %d\n", |
| 2339 | params->port); |
| 2340 | return 1; |
| 2341 | } |
| 2342 | return 0; |
| 2343 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2344 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2345 | static void bnx2x_flow_ctrl_resolve(struct bnx2x_phy *phy, |
| 2346 | struct link_params *params, |
| 2347 | struct link_vars *vars, |
| 2348 | u32 gp_status) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2349 | { |
| 2350 | struct bnx2x *bp = params->bp; |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 2351 | u16 ld_pause; /* local driver */ |
| 2352 | u16 lp_pause; /* link partner */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2353 | u16 pause_result; |
| 2354 | |
David S. Miller | c0700f9 | 2008-12-16 23:53:20 -0800 | [diff] [blame] | 2355 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2356 | |
| 2357 | /* resolve from gp_status in case of AN complete and not sgmii */ |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 2358 | if (phy->req_flow_ctrl != BNX2X_FLOW_CTRL_AUTO) |
| 2359 | vars->flow_ctrl = phy->req_flow_ctrl; |
| 2360 | else if (phy->req_line_speed != SPEED_AUTO_NEG) |
| 2361 | vars->flow_ctrl = params->req_fc_auto_adv; |
| 2362 | else if ((gp_status & MDIO_AN_CL73_OR_37_COMPLETE) && |
| 2363 | (!(vars->phy_flags & PHY_SGMII_FLAG))) { |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2364 | if (bnx2x_direct_parallel_detect_used(phy, params)) { |
Yaniv Rosner | 15ddd2d | 2009-11-05 19:18:12 +0200 | [diff] [blame] | 2365 | vars->flow_ctrl = params->req_fc_auto_adv; |
| 2366 | return; |
| 2367 | } |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 2368 | if ((gp_status & |
| 2369 | (MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_AUTONEG_COMPLETE | |
| 2370 | MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_MR_LP_NP_AN_ABLE)) == |
| 2371 | (MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_AUTONEG_COMPLETE | |
| 2372 | MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_MR_LP_NP_AN_ABLE)) { |
| 2373 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2374 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2375 | MDIO_REG_BANK_CL73_IEEEB1, |
| 2376 | MDIO_CL73_IEEEB1_AN_ADV1, |
| 2377 | &ld_pause); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2378 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2379 | MDIO_REG_BANK_CL73_IEEEB1, |
| 2380 | MDIO_CL73_IEEEB1_AN_LP_ADV1, |
| 2381 | &lp_pause); |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 2382 | pause_result = (ld_pause & |
| 2383 | MDIO_CL73_IEEEB1_AN_ADV1_PAUSE_MASK) |
| 2384 | >> 8; |
| 2385 | pause_result |= (lp_pause & |
| 2386 | MDIO_CL73_IEEEB1_AN_LP_ADV1_PAUSE_MASK) |
| 2387 | >> 10; |
| 2388 | DP(NETIF_MSG_LINK, "pause_result CL73 0x%x\n", |
| 2389 | pause_result); |
| 2390 | } else { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2391 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2392 | MDIO_REG_BANK_COMBO_IEEE0, |
| 2393 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV, |
| 2394 | &ld_pause); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2395 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2396 | MDIO_REG_BANK_COMBO_IEEE0, |
| 2397 | MDIO_COMBO_IEEE0_AUTO_NEG_LINK_PARTNER_ABILITY1, |
| 2398 | &lp_pause); |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 2399 | pause_result = (ld_pause & |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2400 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_MASK)>>5; |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 2401 | pause_result |= (lp_pause & |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2402 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_MASK)>>7; |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 2403 | DP(NETIF_MSG_LINK, "pause_result CL37 0x%x\n", |
| 2404 | pause_result); |
| 2405 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2406 | bnx2x_pause_resolve(vars, pause_result); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2407 | } |
| 2408 | DP(NETIF_MSG_LINK, "flow_ctrl 0x%x\n", vars->flow_ctrl); |
| 2409 | } |
| 2410 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2411 | static void bnx2x_check_fallback_to_cl37(struct bnx2x_phy *phy, |
| 2412 | struct link_params *params) |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2413 | { |
| 2414 | struct bnx2x *bp = params->bp; |
| 2415 | u16 rx_status, ustat_val, cl37_fsm_recieved; |
| 2416 | DP(NETIF_MSG_LINK, "bnx2x_check_fallback_to_cl37\n"); |
| 2417 | /* Step 1: Make sure signal is detected */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2418 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2419 | MDIO_REG_BANK_RX0, |
| 2420 | MDIO_RX0_RX_STATUS, |
| 2421 | &rx_status); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2422 | if ((rx_status & MDIO_RX0_RX_STATUS_SIGDET) != |
| 2423 | (MDIO_RX0_RX_STATUS_SIGDET)) { |
| 2424 | DP(NETIF_MSG_LINK, "Signal is not detected. Restoring CL73." |
| 2425 | "rx_status(0x80b0) = 0x%x\n", rx_status); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2426 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2427 | MDIO_REG_BANK_CL73_IEEEB0, |
| 2428 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL, |
| 2429 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL_AN_EN); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2430 | return; |
| 2431 | } |
| 2432 | /* Step 2: Check CL73 state machine */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2433 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2434 | MDIO_REG_BANK_CL73_USERB0, |
| 2435 | MDIO_CL73_USERB0_CL73_USTAT1, |
| 2436 | &ustat_val); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2437 | if ((ustat_val & |
| 2438 | (MDIO_CL73_USERB0_CL73_USTAT1_LINK_STATUS_CHECK | |
| 2439 | MDIO_CL73_USERB0_CL73_USTAT1_AN_GOOD_CHECK_BAM37)) != |
| 2440 | (MDIO_CL73_USERB0_CL73_USTAT1_LINK_STATUS_CHECK | |
| 2441 | MDIO_CL73_USERB0_CL73_USTAT1_AN_GOOD_CHECK_BAM37)) { |
| 2442 | DP(NETIF_MSG_LINK, "CL73 state-machine is not stable. " |
| 2443 | "ustat_val(0x8371) = 0x%x\n", ustat_val); |
| 2444 | return; |
| 2445 | } |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2446 | /* |
| 2447 | * Step 3: Check CL37 Message Pages received to indicate LP |
| 2448 | * supports only CL37 |
| 2449 | */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2450 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2451 | MDIO_REG_BANK_REMOTE_PHY, |
| 2452 | MDIO_REMOTE_PHY_MISC_RX_STATUS, |
| 2453 | &cl37_fsm_recieved); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2454 | if ((cl37_fsm_recieved & |
| 2455 | (MDIO_REMOTE_PHY_MISC_RX_STATUS_CL37_FSM_RECEIVED_OVER1G_MSG | |
| 2456 | MDIO_REMOTE_PHY_MISC_RX_STATUS_CL37_FSM_RECEIVED_BRCM_OUI_MSG)) != |
| 2457 | (MDIO_REMOTE_PHY_MISC_RX_STATUS_CL37_FSM_RECEIVED_OVER1G_MSG | |
| 2458 | MDIO_REMOTE_PHY_MISC_RX_STATUS_CL37_FSM_RECEIVED_BRCM_OUI_MSG)) { |
| 2459 | DP(NETIF_MSG_LINK, "No CL37 FSM were received. " |
| 2460 | "misc_rx_status(0x8330) = 0x%x\n", |
| 2461 | cl37_fsm_recieved); |
| 2462 | return; |
| 2463 | } |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2464 | /* |
| 2465 | * The combined cl37/cl73 fsm state information indicating that |
| 2466 | * we are connected to a device which does not support cl73, but |
| 2467 | * does support cl37 BAM. In this case we disable cl73 and |
| 2468 | * restart cl37 auto-neg |
| 2469 | */ |
| 2470 | |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2471 | /* Disable CL73 */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2472 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2473 | MDIO_REG_BANK_CL73_IEEEB0, |
| 2474 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL, |
| 2475 | 0); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2476 | /* Restart CL37 autoneg */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2477 | bnx2x_restart_autoneg(phy, params, 0); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2478 | DP(NETIF_MSG_LINK, "Disabling CL73, and restarting CL37 autoneg\n"); |
| 2479 | } |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 2480 | |
| 2481 | static void bnx2x_xgxs_an_resolve(struct bnx2x_phy *phy, |
| 2482 | struct link_params *params, |
| 2483 | struct link_vars *vars, |
| 2484 | u32 gp_status) |
| 2485 | { |
| 2486 | if (gp_status & MDIO_AN_CL73_OR_37_COMPLETE) |
| 2487 | vars->link_status |= |
| 2488 | LINK_STATUS_AUTO_NEGOTIATE_COMPLETE; |
| 2489 | |
| 2490 | if (bnx2x_direct_parallel_detect_used(phy, params)) |
| 2491 | vars->link_status |= |
| 2492 | LINK_STATUS_PARALLEL_DETECTION_USED; |
| 2493 | } |
| 2494 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 2495 | static u8 bnx2x_link_settings_status(struct bnx2x_phy *phy, |
| 2496 | struct link_params *params, |
| 2497 | struct link_vars *vars) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2498 | { |
| 2499 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2500 | u16 new_line_speed, gp_status; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2501 | u8 rc = 0; |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 2502 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 2503 | /* Read gp_status */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2504 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2505 | MDIO_REG_BANK_GP_STATUS, |
| 2506 | MDIO_GP_STATUS_TOP_AN_STATUS1, |
| 2507 | &gp_status); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 2508 | |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 2509 | if (phy->req_line_speed == SPEED_AUTO_NEG) |
| 2510 | vars->link_status |= LINK_STATUS_AUTO_NEGOTIATE_ENABLED; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2511 | if (gp_status & MDIO_GP_STATUS_TOP_AN_STATUS1_LINK_STATUS) { |
| 2512 | DP(NETIF_MSG_LINK, "phy link up gp_status=0x%x\n", |
| 2513 | gp_status); |
| 2514 | |
| 2515 | vars->phy_link_up = 1; |
| 2516 | vars->link_status |= LINK_STATUS_LINK_UP; |
| 2517 | |
| 2518 | if (gp_status & MDIO_GP_STATUS_TOP_AN_STATUS1_DUPLEX_STATUS) |
| 2519 | vars->duplex = DUPLEX_FULL; |
| 2520 | else |
| 2521 | vars->duplex = DUPLEX_HALF; |
| 2522 | |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 2523 | if (SINGLE_MEDIA_DIRECT(params)) { |
| 2524 | bnx2x_flow_ctrl_resolve(phy, params, vars, gp_status); |
| 2525 | if (phy->req_line_speed == SPEED_AUTO_NEG) |
| 2526 | bnx2x_xgxs_an_resolve(phy, params, vars, |
| 2527 | gp_status); |
| 2528 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2529 | |
| 2530 | switch (gp_status & GP_STATUS_SPEED_MASK) { |
| 2531 | case GP_STATUS_10M: |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 2532 | new_line_speed = SPEED_10; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2533 | if (vars->duplex == DUPLEX_FULL) |
| 2534 | vars->link_status |= LINK_10TFD; |
| 2535 | else |
| 2536 | vars->link_status |= LINK_10THD; |
| 2537 | break; |
| 2538 | |
| 2539 | case GP_STATUS_100M: |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 2540 | new_line_speed = SPEED_100; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2541 | if (vars->duplex == DUPLEX_FULL) |
| 2542 | vars->link_status |= LINK_100TXFD; |
| 2543 | else |
| 2544 | vars->link_status |= LINK_100TXHD; |
| 2545 | break; |
| 2546 | |
| 2547 | case GP_STATUS_1G: |
| 2548 | case GP_STATUS_1G_KX: |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 2549 | new_line_speed = SPEED_1000; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2550 | if (vars->duplex == DUPLEX_FULL) |
| 2551 | vars->link_status |= LINK_1000TFD; |
| 2552 | else |
| 2553 | vars->link_status |= LINK_1000THD; |
| 2554 | break; |
| 2555 | |
| 2556 | case GP_STATUS_2_5G: |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 2557 | new_line_speed = SPEED_2500; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2558 | if (vars->duplex == DUPLEX_FULL) |
| 2559 | vars->link_status |= LINK_2500TFD; |
| 2560 | else |
| 2561 | vars->link_status |= LINK_2500THD; |
| 2562 | break; |
| 2563 | |
| 2564 | case GP_STATUS_5G: |
| 2565 | case GP_STATUS_6G: |
| 2566 | DP(NETIF_MSG_LINK, |
| 2567 | "link speed unsupported gp_status 0x%x\n", |
| 2568 | gp_status); |
| 2569 | return -EINVAL; |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 2570 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2571 | case GP_STATUS_10G_KX4: |
| 2572 | case GP_STATUS_10G_HIG: |
| 2573 | case GP_STATUS_10G_CX4: |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 2574 | new_line_speed = SPEED_10000; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2575 | vars->link_status |= LINK_10GTFD; |
| 2576 | break; |
| 2577 | |
| 2578 | case GP_STATUS_12G_HIG: |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 2579 | new_line_speed = SPEED_12000; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2580 | vars->link_status |= LINK_12GTFD; |
| 2581 | break; |
| 2582 | |
| 2583 | case GP_STATUS_12_5G: |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 2584 | new_line_speed = SPEED_12500; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2585 | vars->link_status |= LINK_12_5GTFD; |
| 2586 | break; |
| 2587 | |
| 2588 | case GP_STATUS_13G: |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 2589 | new_line_speed = SPEED_13000; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2590 | vars->link_status |= LINK_13GTFD; |
| 2591 | break; |
| 2592 | |
| 2593 | case GP_STATUS_15G: |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 2594 | new_line_speed = SPEED_15000; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2595 | vars->link_status |= LINK_15GTFD; |
| 2596 | break; |
| 2597 | |
| 2598 | case GP_STATUS_16G: |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 2599 | new_line_speed = SPEED_16000; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2600 | vars->link_status |= LINK_16GTFD; |
| 2601 | break; |
| 2602 | |
| 2603 | default: |
| 2604 | DP(NETIF_MSG_LINK, |
| 2605 | "link speed unsupported gp_status 0x%x\n", |
| 2606 | gp_status); |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 2607 | return -EINVAL; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2608 | } |
| 2609 | |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 2610 | vars->line_speed = new_line_speed; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2611 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2612 | } else { /* link_down */ |
| 2613 | DP(NETIF_MSG_LINK, "phy link down\n"); |
| 2614 | |
| 2615 | vars->phy_link_up = 0; |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 2616 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2617 | vars->duplex = DUPLEX_FULL; |
David S. Miller | c0700f9 | 2008-12-16 23:53:20 -0800 | [diff] [blame] | 2618 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2619 | vars->mac_type = MAC_TYPE_NONE; |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2620 | |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 2621 | if ((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 2622 | SINGLE_MEDIA_DIRECT(params)) { |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2623 | /* Check signal is detected */ |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 2624 | bnx2x_check_fallback_to_cl37(phy, params); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2625 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2626 | } |
| 2627 | |
Frans Pop | 2381a55 | 2010-03-24 07:57:36 +0000 | [diff] [blame] | 2628 | DP(NETIF_MSG_LINK, "gp_status 0x%x phy_link_up %x line_speed %x\n", |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2629 | gp_status, vars->phy_link_up, vars->line_speed); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 2630 | DP(NETIF_MSG_LINK, "duplex %x flow_ctrl 0x%x link_status 0x%x\n", |
| 2631 | vars->duplex, vars->flow_ctrl, vars->link_status); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2632 | return rc; |
| 2633 | } |
| 2634 | |
Eilon Greenstein | ed8680a | 2009-02-12 08:37:12 +0000 | [diff] [blame] | 2635 | static void bnx2x_set_gmii_tx_driver(struct link_params *params) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2636 | { |
| 2637 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2638 | struct bnx2x_phy *phy = ¶ms->phy[INT_PHY]; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2639 | u16 lp_up2; |
| 2640 | u16 tx_driver; |
Eilon Greenstein | c2c8b03 | 2009-02-12 08:37:14 +0000 | [diff] [blame] | 2641 | u16 bank; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2642 | |
| 2643 | /* read precomp */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2644 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2645 | MDIO_REG_BANK_OVER_1G, |
| 2646 | MDIO_OVER_1G_LP_UP2, &lp_up2); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2647 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2648 | /* bits [10:7] at lp_up2, positioned at [15:12] */ |
| 2649 | lp_up2 = (((lp_up2 & MDIO_OVER_1G_LP_UP2_PREEMPHASIS_MASK) >> |
| 2650 | MDIO_OVER_1G_LP_UP2_PREEMPHASIS_SHIFT) << |
| 2651 | MDIO_TX0_TX_DRIVER_PREEMPHASIS_SHIFT); |
| 2652 | |
Eilon Greenstein | c2c8b03 | 2009-02-12 08:37:14 +0000 | [diff] [blame] | 2653 | if (lp_up2 == 0) |
| 2654 | return; |
| 2655 | |
| 2656 | for (bank = MDIO_REG_BANK_TX0; bank <= MDIO_REG_BANK_TX3; |
| 2657 | bank += (MDIO_REG_BANK_TX1 - MDIO_REG_BANK_TX0)) { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2658 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2659 | bank, |
| 2660 | MDIO_TX0_TX_DRIVER, &tx_driver); |
Eilon Greenstein | c2c8b03 | 2009-02-12 08:37:14 +0000 | [diff] [blame] | 2661 | |
| 2662 | /* replace tx_driver bits [15:12] */ |
| 2663 | if (lp_up2 != |
| 2664 | (tx_driver & MDIO_TX0_TX_DRIVER_PREEMPHASIS_MASK)) { |
| 2665 | tx_driver &= ~MDIO_TX0_TX_DRIVER_PREEMPHASIS_MASK; |
| 2666 | tx_driver |= lp_up2; |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2667 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2668 | bank, |
| 2669 | MDIO_TX0_TX_DRIVER, tx_driver); |
Eilon Greenstein | c2c8b03 | 2009-02-12 08:37:14 +0000 | [diff] [blame] | 2670 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2671 | } |
| 2672 | } |
| 2673 | |
| 2674 | static u8 bnx2x_emac_program(struct link_params *params, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 2675 | struct link_vars *vars) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2676 | { |
| 2677 | struct bnx2x *bp = params->bp; |
| 2678 | u8 port = params->port; |
| 2679 | u16 mode = 0; |
| 2680 | |
| 2681 | DP(NETIF_MSG_LINK, "setting link speed & duplex\n"); |
| 2682 | bnx2x_bits_dis(bp, GRCBASE_EMAC0 + port*0x400 + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2683 | EMAC_REG_EMAC_MODE, |
| 2684 | (EMAC_MODE_25G_MODE | |
| 2685 | EMAC_MODE_PORT_MII_10M | |
| 2686 | EMAC_MODE_HALF_DUPLEX)); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 2687 | switch (vars->line_speed) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2688 | case SPEED_10: |
| 2689 | mode |= EMAC_MODE_PORT_MII_10M; |
| 2690 | break; |
| 2691 | |
| 2692 | case SPEED_100: |
| 2693 | mode |= EMAC_MODE_PORT_MII; |
| 2694 | break; |
| 2695 | |
| 2696 | case SPEED_1000: |
| 2697 | mode |= EMAC_MODE_PORT_GMII; |
| 2698 | break; |
| 2699 | |
| 2700 | case SPEED_2500: |
| 2701 | mode |= (EMAC_MODE_25G_MODE | EMAC_MODE_PORT_GMII); |
| 2702 | break; |
| 2703 | |
| 2704 | default: |
| 2705 | /* 10G not valid for EMAC */ |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 2706 | DP(NETIF_MSG_LINK, "Invalid line_speed 0x%x\n", |
| 2707 | vars->line_speed); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2708 | return -EINVAL; |
| 2709 | } |
| 2710 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 2711 | if (vars->duplex == DUPLEX_HALF) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2712 | mode |= EMAC_MODE_HALF_DUPLEX; |
| 2713 | bnx2x_bits_en(bp, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2714 | GRCBASE_EMAC0 + port*0x400 + EMAC_REG_EMAC_MODE, |
| 2715 | mode); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2716 | |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 2717 | bnx2x_set_led(params, vars, LED_MODE_OPER, vars->line_speed); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2718 | return 0; |
| 2719 | } |
| 2720 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 2721 | static void bnx2x_set_preemphasis(struct bnx2x_phy *phy, |
| 2722 | struct link_params *params) |
| 2723 | { |
| 2724 | |
| 2725 | u16 bank, i = 0; |
| 2726 | struct bnx2x *bp = params->bp; |
| 2727 | |
| 2728 | for (bank = MDIO_REG_BANK_RX0, i = 0; bank <= MDIO_REG_BANK_RX3; |
| 2729 | bank += (MDIO_REG_BANK_RX1-MDIO_REG_BANK_RX0), i++) { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2730 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 2731 | bank, |
| 2732 | MDIO_RX0_RX_EQ_BOOST, |
| 2733 | phy->rx_preemphasis[i]); |
| 2734 | } |
| 2735 | |
| 2736 | for (bank = MDIO_REG_BANK_TX0, i = 0; bank <= MDIO_REG_BANK_TX3; |
| 2737 | bank += (MDIO_REG_BANK_TX1 - MDIO_REG_BANK_TX0), i++) { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2738 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 2739 | bank, |
| 2740 | MDIO_TX0_TX_DRIVER, |
| 2741 | phy->tx_preemphasis[i]); |
| 2742 | } |
| 2743 | } |
| 2744 | |
| 2745 | static void bnx2x_init_internal_phy(struct bnx2x_phy *phy, |
| 2746 | struct link_params *params, |
| 2747 | struct link_vars *vars) |
| 2748 | { |
| 2749 | struct bnx2x *bp = params->bp; |
| 2750 | u8 enable_cl73 = (SINGLE_MEDIA_DIRECT(params) || |
| 2751 | (params->loopback_mode == LOOPBACK_XGXS)); |
| 2752 | if (!(vars->phy_flags & PHY_SGMII_FLAG)) { |
| 2753 | if (SINGLE_MEDIA_DIRECT(params) && |
| 2754 | (params->feature_config_flags & |
| 2755 | FEATURE_CONFIG_OVERRIDE_PREEMPHASIS_ENABLED)) |
| 2756 | bnx2x_set_preemphasis(phy, params); |
| 2757 | |
| 2758 | /* forced speed requested? */ |
| 2759 | if (vars->line_speed != SPEED_AUTO_NEG || |
| 2760 | (SINGLE_MEDIA_DIRECT(params) && |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2761 | params->loopback_mode == LOOPBACK_EXT)) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 2762 | DP(NETIF_MSG_LINK, "not SGMII, no AN\n"); |
| 2763 | |
| 2764 | /* disable autoneg */ |
| 2765 | bnx2x_set_autoneg(phy, params, vars, 0); |
| 2766 | |
| 2767 | /* program speed and duplex */ |
| 2768 | bnx2x_program_serdes(phy, params, vars); |
| 2769 | |
| 2770 | } else { /* AN_mode */ |
| 2771 | DP(NETIF_MSG_LINK, "not SGMII, AN\n"); |
| 2772 | |
| 2773 | /* AN enabled */ |
| 2774 | bnx2x_set_brcm_cl37_advertisment(phy, params); |
| 2775 | |
| 2776 | /* program duplex & pause advertisement (for aneg) */ |
| 2777 | bnx2x_set_ieee_aneg_advertisment(phy, params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2778 | vars->ieee_fc); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 2779 | |
| 2780 | /* enable autoneg */ |
| 2781 | bnx2x_set_autoneg(phy, params, vars, enable_cl73); |
| 2782 | |
| 2783 | /* enable and restart AN */ |
| 2784 | bnx2x_restart_autoneg(phy, params, enable_cl73); |
| 2785 | } |
| 2786 | |
| 2787 | } else { /* SGMII mode */ |
| 2788 | DP(NETIF_MSG_LINK, "SGMII\n"); |
| 2789 | |
| 2790 | bnx2x_initialize_sgmii_process(phy, params, vars); |
| 2791 | } |
| 2792 | } |
| 2793 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 2794 | static u8 bnx2x_init_serdes(struct bnx2x_phy *phy, |
| 2795 | struct link_params *params, |
| 2796 | struct link_vars *vars) |
| 2797 | { |
| 2798 | u8 rc; |
| 2799 | vars->phy_flags |= PHY_SGMII_FLAG; |
| 2800 | bnx2x_calc_ieee_aneg_adv(phy, params, &vars->ieee_fc); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2801 | bnx2x_set_aer_mmd_serdes(params->bp, phy); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 2802 | rc = bnx2x_reset_unicore(params, phy, 1); |
| 2803 | /* reset the SerDes and wait for reset bit return low */ |
| 2804 | if (rc != 0) |
| 2805 | return rc; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2806 | bnx2x_set_aer_mmd_serdes(params->bp, phy); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2807 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 2808 | return rc; |
| 2809 | } |
| 2810 | |
| 2811 | static u8 bnx2x_init_xgxs(struct bnx2x_phy *phy, |
| 2812 | struct link_params *params, |
| 2813 | struct link_vars *vars) |
| 2814 | { |
| 2815 | u8 rc; |
| 2816 | vars->phy_flags = PHY_XGXS_FLAG; |
| 2817 | if ((phy->req_line_speed && |
| 2818 | ((phy->req_line_speed == SPEED_100) || |
| 2819 | (phy->req_line_speed == SPEED_10))) || |
| 2820 | (!phy->req_line_speed && |
| 2821 | (phy->speed_cap_mask >= |
| 2822 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_FULL) && |
| 2823 | (phy->speed_cap_mask < |
| 2824 | PORT_HW_CFG_SPEED_CAPABILITY_D0_1G) |
| 2825 | )) |
| 2826 | vars->phy_flags |= PHY_SGMII_FLAG; |
| 2827 | else |
| 2828 | vars->phy_flags &= ~PHY_SGMII_FLAG; |
| 2829 | |
| 2830 | bnx2x_calc_ieee_aneg_adv(phy, params, &vars->ieee_fc); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2831 | bnx2x_set_aer_mmd_xgxs(params, phy); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 2832 | bnx2x_set_master_ln(params, phy); |
| 2833 | |
| 2834 | rc = bnx2x_reset_unicore(params, phy, 0); |
| 2835 | /* reset the SerDes and wait for reset bit return low */ |
| 2836 | if (rc != 0) |
| 2837 | return rc; |
| 2838 | |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2839 | bnx2x_set_aer_mmd_xgxs(params, phy); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 2840 | |
| 2841 | /* setting the masterLn_def again after the reset */ |
| 2842 | bnx2x_set_master_ln(params, phy); |
| 2843 | bnx2x_set_swap_lanes(params, phy); |
| 2844 | |
| 2845 | return rc; |
| 2846 | } |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 2847 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 2848 | static u16 bnx2x_wait_reset_complete(struct bnx2x *bp, |
| 2849 | struct bnx2x_phy *phy) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2850 | { |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 2851 | u16 cnt, ctrl; |
Yaniv Rosner | 62b29a5 | 2010-09-07 11:40:58 +0000 | [diff] [blame] | 2852 | /* Wait for soft reset to get cleared upto 1 sec */ |
| 2853 | for (cnt = 0; cnt < 1000; cnt++) { |
| 2854 | bnx2x_cl45_read(bp, phy, |
| 2855 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, &ctrl); |
| 2856 | if (!(ctrl & (1<<15))) |
| 2857 | break; |
| 2858 | msleep(1); |
| 2859 | } |
| 2860 | DP(NETIF_MSG_LINK, "control reg 0x%x (after %d ms)\n", ctrl, cnt); |
| 2861 | return cnt; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 2862 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2863 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2864 | static void bnx2x_link_int_enable(struct link_params *params) |
| 2865 | { |
| 2866 | u8 port = params->port; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2867 | u32 mask; |
| 2868 | struct bnx2x *bp = params->bp; |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 2869 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2870 | /* Setting the status to report on link up for either XGXS or SerDes */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2871 | if (params->switch_cfg == SWITCH_CFG_10G) { |
| 2872 | mask = (NIG_MASK_XGXS0_LINK10G | |
| 2873 | NIG_MASK_XGXS0_LINK_STATUS); |
| 2874 | DP(NETIF_MSG_LINK, "enabled XGXS interrupt\n"); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2875 | if (!(SINGLE_MEDIA_DIRECT(params)) && |
| 2876 | params->phy[INT_PHY].type != |
| 2877 | PORT_HW_CFG_XGXS_EXT_PHY_TYPE_FAILURE) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2878 | mask |= NIG_MASK_MI_INT; |
| 2879 | DP(NETIF_MSG_LINK, "enabled external phy int\n"); |
| 2880 | } |
| 2881 | |
| 2882 | } else { /* SerDes */ |
| 2883 | mask = NIG_MASK_SERDES0_LINK_STATUS; |
| 2884 | DP(NETIF_MSG_LINK, "enabled SerDes interrupt\n"); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2885 | if (!(SINGLE_MEDIA_DIRECT(params)) && |
| 2886 | params->phy[INT_PHY].type != |
| 2887 | PORT_HW_CFG_SERDES_EXT_PHY_TYPE_NOT_CONN) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2888 | mask |= NIG_MASK_MI_INT; |
| 2889 | DP(NETIF_MSG_LINK, "enabled external phy int\n"); |
| 2890 | } |
| 2891 | } |
| 2892 | bnx2x_bits_en(bp, |
| 2893 | NIG_REG_MASK_INTERRUPT_PORT0 + port*4, |
| 2894 | mask); |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 2895 | |
| 2896 | 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] | 2897 | (params->switch_cfg == SWITCH_CFG_10G), |
| 2898 | REG_RD(bp, NIG_REG_STATUS_INTERRUPT_PORT0 + port*4)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2899 | DP(NETIF_MSG_LINK, " int_mask 0x%x, MI_INT %x, SERDES_LINK %x\n", |
| 2900 | REG_RD(bp, NIG_REG_MASK_INTERRUPT_PORT0 + port*4), |
| 2901 | REG_RD(bp, NIG_REG_EMAC0_STATUS_MISC_MI_INT + port*0x18), |
| 2902 | REG_RD(bp, NIG_REG_SERDES0_STATUS_LINK_STATUS+port*0x3c)); |
| 2903 | DP(NETIF_MSG_LINK, " 10G %x, XGXS_LINK %x\n", |
| 2904 | REG_RD(bp, NIG_REG_XGXS0_STATUS_LINK10G + port*0x68), |
| 2905 | REG_RD(bp, NIG_REG_XGXS0_STATUS_LINK_STATUS + port*0x68)); |
| 2906 | } |
| 2907 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 2908 | static void bnx2x_rearm_latch_signal(struct bnx2x *bp, u8 port, |
| 2909 | u8 exp_mi_int) |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 2910 | { |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 2911 | u32 latch_status = 0; |
| 2912 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2913 | /* |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 2914 | * Disable the MI INT ( external phy int ) by writing 1 to the |
| 2915 | * status register. Link down indication is high-active-signal, |
| 2916 | * 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] | 2917 | */ |
| 2918 | /* Read Latched signals */ |
| 2919 | latch_status = REG_RD(bp, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 2920 | NIG_REG_LATCH_STATUS_0 + port*8); |
| 2921 | DP(NETIF_MSG_LINK, "latch_status = 0x%x\n", latch_status); |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 2922 | /* Handle only those with latched-signal=up.*/ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 2923 | if (exp_mi_int) |
| 2924 | bnx2x_bits_en(bp, |
| 2925 | NIG_REG_STATUS_INTERRUPT_PORT0 |
| 2926 | + port*4, |
| 2927 | NIG_STATUS_EMAC0_MI_INT); |
| 2928 | else |
| 2929 | bnx2x_bits_dis(bp, |
| 2930 | NIG_REG_STATUS_INTERRUPT_PORT0 |
| 2931 | + port*4, |
| 2932 | NIG_STATUS_EMAC0_MI_INT); |
| 2933 | |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 2934 | if (latch_status & 1) { |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 2935 | |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 2936 | /* For all latched-signal=up : Re-Arm Latch signals */ |
| 2937 | REG_WR(bp, NIG_REG_LATCH_STATUS_0 + port*8, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2938 | (latch_status & 0xfffe) | (latch_status & 1)); |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 2939 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 2940 | /* For all latched-signal=up,Write original_signal to status */ |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 2941 | } |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2942 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2943 | static void bnx2x_link_int_ack(struct link_params *params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2944 | struct link_vars *vars, u8 is_10g) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2945 | { |
| 2946 | struct bnx2x *bp = params->bp; |
| 2947 | u8 port = params->port; |
| 2948 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2949 | /* |
| 2950 | * First reset all status we assume only one line will be |
| 2951 | * change at a time |
| 2952 | */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2953 | bnx2x_bits_dis(bp, NIG_REG_STATUS_INTERRUPT_PORT0 + port*4, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2954 | (NIG_STATUS_XGXS0_LINK10G | |
| 2955 | NIG_STATUS_XGXS0_LINK_STATUS | |
| 2956 | NIG_STATUS_SERDES0_LINK_STATUS)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2957 | if (vars->phy_link_up) { |
| 2958 | if (is_10g) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2959 | /* |
| 2960 | * Disable the 10G link interrupt by writing 1 to the |
| 2961 | * status register |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2962 | */ |
| 2963 | DP(NETIF_MSG_LINK, "10G XGXS phy link up\n"); |
| 2964 | bnx2x_bits_en(bp, |
| 2965 | NIG_REG_STATUS_INTERRUPT_PORT0 + port*4, |
| 2966 | NIG_STATUS_XGXS0_LINK10G); |
| 2967 | |
| 2968 | } else if (params->switch_cfg == SWITCH_CFG_10G) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2969 | /* |
| 2970 | * Disable the link interrupt by writing 1 to the |
| 2971 | * relevant lane in the status register |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2972 | */ |
| 2973 | u32 ser_lane = ((params->lane_config & |
| 2974 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_MASK) >> |
| 2975 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_SHIFT); |
| 2976 | |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 2977 | DP(NETIF_MSG_LINK, "%d speed XGXS phy link up\n", |
| 2978 | vars->line_speed); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2979 | bnx2x_bits_en(bp, |
| 2980 | NIG_REG_STATUS_INTERRUPT_PORT0 + port*4, |
| 2981 | ((1 << ser_lane) << |
| 2982 | NIG_STATUS_XGXS0_LINK_STATUS_SIZE)); |
| 2983 | |
| 2984 | } else { /* SerDes */ |
| 2985 | DP(NETIF_MSG_LINK, "SerDes phy link up\n"); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2986 | /* |
| 2987 | * Disable the link interrupt by writing 1 to the status |
| 2988 | * register |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2989 | */ |
| 2990 | bnx2x_bits_en(bp, |
| 2991 | NIG_REG_STATUS_INTERRUPT_PORT0 + port*4, |
| 2992 | NIG_STATUS_SERDES0_LINK_STATUS); |
| 2993 | } |
| 2994 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2995 | } |
| 2996 | } |
| 2997 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 2998 | static u8 bnx2x_format_ver(u32 num, u8 *str, u16 *len) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2999 | { |
| 3000 | u8 *str_ptr = str; |
| 3001 | u32 mask = 0xf0000000; |
| 3002 | u8 shift = 8*4; |
| 3003 | u8 digit; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3004 | u8 remove_leading_zeros = 1; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3005 | if (*len < 10) { |
Frederik Schwarzer | 025dfda | 2008-10-16 19:02:37 +0200 | [diff] [blame] | 3006 | /* Need more than 10chars for this format */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3007 | *str_ptr = '\0'; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3008 | (*len)--; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3009 | return -EINVAL; |
| 3010 | } |
| 3011 | while (shift > 0) { |
| 3012 | |
| 3013 | shift -= 4; |
| 3014 | digit = ((num & mask) >> shift); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3015 | if (digit == 0 && remove_leading_zeros) { |
| 3016 | mask = mask >> 4; |
| 3017 | continue; |
| 3018 | } else if (digit < 0xa) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3019 | *str_ptr = digit + '0'; |
| 3020 | else |
| 3021 | *str_ptr = digit - 0xa + 'a'; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3022 | remove_leading_zeros = 0; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3023 | str_ptr++; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3024 | (*len)--; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3025 | mask = mask >> 4; |
| 3026 | if (shift == 4*4) { |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3027 | *str_ptr = '.'; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3028 | str_ptr++; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3029 | (*len)--; |
| 3030 | remove_leading_zeros = 1; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3031 | } |
| 3032 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3033 | return 0; |
| 3034 | } |
| 3035 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3036 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3037 | static u8 bnx2x_null_format_ver(u32 spirom_ver, u8 *str, u16 *len) |
| 3038 | { |
| 3039 | str[0] = '\0'; |
| 3040 | (*len)--; |
| 3041 | return 0; |
| 3042 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3043 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3044 | u8 bnx2x_get_ext_phy_fw_version(struct link_params *params, u8 driver_loaded, |
| 3045 | u8 *version, u16 len) |
| 3046 | { |
Julia Lawall | 0376d5b | 2009-07-19 05:26:35 +0000 | [diff] [blame] | 3047 | struct bnx2x *bp; |
Eilon Greenstein | a35da8d | 2009-02-12 08:37:02 +0000 | [diff] [blame] | 3048 | u32 spirom_ver = 0; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3049 | u8 status = 0; |
| 3050 | u8 *ver_p = version; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3051 | u16 remain_len = len; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3052 | if (version == NULL || params == NULL) |
| 3053 | return -EINVAL; |
Julia Lawall | 0376d5b | 2009-07-19 05:26:35 +0000 | [diff] [blame] | 3054 | bp = params->bp; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3055 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3056 | /* Extract first external phy*/ |
| 3057 | version[0] = '\0'; |
| 3058 | spirom_ver = REG_RD(bp, params->phy[EXT_PHY1].ver_addr); |
Eilon Greenstein | a35da8d | 2009-02-12 08:37:02 +0000 | [diff] [blame] | 3059 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3060 | if (params->phy[EXT_PHY1].format_fw_ver) { |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3061 | status |= params->phy[EXT_PHY1].format_fw_ver(spirom_ver, |
| 3062 | ver_p, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3063 | &remain_len); |
| 3064 | ver_p += (len - remain_len); |
| 3065 | } |
| 3066 | if ((params->num_phys == MAX_PHYS) && |
| 3067 | (params->phy[EXT_PHY2].ver_addr != 0)) { |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3068 | spirom_ver = REG_RD(bp, params->phy[EXT_PHY2].ver_addr); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3069 | if (params->phy[EXT_PHY2].format_fw_ver) { |
| 3070 | *ver_p = '/'; |
| 3071 | ver_p++; |
| 3072 | remain_len--; |
| 3073 | status |= params->phy[EXT_PHY2].format_fw_ver( |
| 3074 | spirom_ver, |
| 3075 | ver_p, |
| 3076 | &remain_len); |
| 3077 | ver_p = version + (len - remain_len); |
| 3078 | } |
| 3079 | } |
| 3080 | *ver_p = '\0'; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3081 | return status; |
| 3082 | } |
| 3083 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3084 | static void bnx2x_set_xgxs_loopback(struct bnx2x_phy *phy, |
Yaniv Rosner | 62b29a5 | 2010-09-07 11:40:58 +0000 | [diff] [blame] | 3085 | struct link_params *params) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3086 | { |
| 3087 | u8 port = params->port; |
| 3088 | struct bnx2x *bp = params->bp; |
| 3089 | |
Yaniv Rosner | 62b29a5 | 2010-09-07 11:40:58 +0000 | [diff] [blame] | 3090 | if (phy->req_line_speed != SPEED_1000) { |
Eilon Greenstein | 6378c02 | 2008-08-13 15:59:25 -0700 | [diff] [blame] | 3091 | u32 md_devad; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3092 | |
| 3093 | DP(NETIF_MSG_LINK, "XGXS 10G loopback enable\n"); |
| 3094 | |
| 3095 | /* change the uni_phy_addr in the nig */ |
| 3096 | md_devad = REG_RD(bp, (NIG_REG_XGXS0_CTRL_MD_DEVAD + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3097 | port*0x18)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3098 | |
| 3099 | REG_WR(bp, NIG_REG_XGXS0_CTRL_MD_DEVAD + port*0x18, 0x5); |
| 3100 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3101 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3102 | 5, |
| 3103 | (MDIO_REG_BANK_AER_BLOCK + |
| 3104 | (MDIO_AER_BLOCK_AER_REG & 0xf)), |
| 3105 | 0x2800); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3106 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3107 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3108 | 5, |
| 3109 | (MDIO_REG_BANK_CL73_IEEEB0 + |
| 3110 | (MDIO_CL73_IEEEB0_CL73_AN_CONTROL & 0xf)), |
| 3111 | 0x6041); |
Eilon Greenstein | 3858276 | 2009-01-14 06:44:16 +0000 | [diff] [blame] | 3112 | msleep(200); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3113 | /* set aer mmd back */ |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 3114 | bnx2x_set_aer_mmd_xgxs(params, phy); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3115 | |
| 3116 | /* and md_devad */ |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3117 | REG_WR(bp, NIG_REG_XGXS0_CTRL_MD_DEVAD + port*0x18, md_devad); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3118 | } else { |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3119 | u16 mii_ctrl; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3120 | DP(NETIF_MSG_LINK, "XGXS 1G loopback enable\n"); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3121 | bnx2x_cl45_read(bp, phy, 5, |
| 3122 | (MDIO_REG_BANK_COMBO_IEEE0 + |
| 3123 | (MDIO_COMBO_IEEE0_MII_CONTROL & 0xf)), |
| 3124 | &mii_ctrl); |
| 3125 | bnx2x_cl45_write(bp, phy, 5, |
| 3126 | (MDIO_REG_BANK_COMBO_IEEE0 + |
| 3127 | (MDIO_COMBO_IEEE0_MII_CONTROL & 0xf)), |
| 3128 | mii_ctrl | |
| 3129 | MDIO_COMBO_IEEO_MII_CONTROL_LOOPBACK); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3130 | } |
| 3131 | } |
| 3132 | |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 3133 | u8 bnx2x_set_led(struct link_params *params, |
| 3134 | struct link_vars *vars, u8 mode, u32 speed) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3135 | { |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 3136 | u8 port = params->port; |
| 3137 | u16 hw_led_mode = params->hw_led_mode; |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 3138 | u8 rc = 0, phy_idx; |
Eilon Greenstein | 345b5d5 | 2008-08-13 15:58:12 -0700 | [diff] [blame] | 3139 | u32 tmp; |
| 3140 | u32 emac_base = port ? GRCBASE_EMAC1 : GRCBASE_EMAC0; |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 3141 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3142 | DP(NETIF_MSG_LINK, "bnx2x_set_led: port %x, mode %d\n", port, mode); |
| 3143 | DP(NETIF_MSG_LINK, "speed 0x%x, hw_led_mode 0x%x\n", |
| 3144 | speed, hw_led_mode); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 3145 | /* In case */ |
| 3146 | for (phy_idx = EXT_PHY1; phy_idx < MAX_PHYS; phy_idx++) { |
| 3147 | if (params->phy[phy_idx].set_link_led) { |
| 3148 | params->phy[phy_idx].set_link_led( |
| 3149 | ¶ms->phy[phy_idx], params, mode); |
| 3150 | } |
| 3151 | } |
| 3152 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3153 | switch (mode) { |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 3154 | case LED_MODE_FRONT_PANEL_OFF: |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3155 | case LED_MODE_OFF: |
| 3156 | REG_WR(bp, NIG_REG_LED_10G_P0 + port*4, 0); |
| 3157 | REG_WR(bp, NIG_REG_LED_MODE_P0 + port*4, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3158 | SHARED_HW_CFG_LED_MAC1); |
Eilon Greenstein | 345b5d5 | 2008-08-13 15:58:12 -0700 | [diff] [blame] | 3159 | |
| 3160 | tmp = EMAC_RD(bp, EMAC_REG_EMAC_LED); |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 3161 | EMAC_WR(bp, EMAC_REG_EMAC_LED, (tmp | EMAC_LED_OVERRIDE)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3162 | break; |
| 3163 | |
| 3164 | case LED_MODE_OPER: |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3165 | /* |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 3166 | * For all other phys, OPER mode is same as ON, so in case |
| 3167 | * link is down, do nothing |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3168 | */ |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 3169 | if (!vars->link_up) |
| 3170 | break; |
| 3171 | case LED_MODE_ON: |
Yaniv Rosner | 1f48353 | 2011-01-18 04:33:31 +0000 | [diff] [blame] | 3172 | if (params->phy[EXT_PHY1].type == |
| 3173 | PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727 && |
| 3174 | CHIP_IS_E2(bp) && params->num_phys == 2) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3175 | /* |
| 3176 | * This is a work-around for E2+8727 Configurations |
| 3177 | */ |
Yaniv Rosner | 1f48353 | 2011-01-18 04:33:31 +0000 | [diff] [blame] | 3178 | if (mode == LED_MODE_ON || |
| 3179 | speed == SPEED_10000){ |
| 3180 | REG_WR(bp, NIG_REG_LED_MODE_P0 + port*4, 0); |
| 3181 | REG_WR(bp, NIG_REG_LED_10G_P0 + port*4, 1); |
| 3182 | |
| 3183 | tmp = EMAC_RD(bp, EMAC_REG_EMAC_LED); |
| 3184 | EMAC_WR(bp, EMAC_REG_EMAC_LED, |
| 3185 | (tmp | EMAC_LED_OVERRIDE)); |
| 3186 | return rc; |
| 3187 | } |
| 3188 | } else if (SINGLE_MEDIA_DIRECT(params)) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3189 | /* |
| 3190 | * This is a work-around for HW issue found when link |
| 3191 | * is up in CL73 |
| 3192 | */ |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 3193 | REG_WR(bp, NIG_REG_LED_MODE_P0 + port*4, 0); |
| 3194 | REG_WR(bp, NIG_REG_LED_10G_P0 + port*4, 1); |
| 3195 | } else { |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3196 | REG_WR(bp, NIG_REG_LED_MODE_P0 + port*4, hw_led_mode); |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 3197 | } |
| 3198 | |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3199 | 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] | 3200 | /* Set blinking rate to ~15.9Hz */ |
| 3201 | REG_WR(bp, NIG_REG_LED_CONTROL_BLINK_RATE_P0 + port*4, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3202 | LED_BLINK_RATE_VAL); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3203 | REG_WR(bp, NIG_REG_LED_CONTROL_BLINK_RATE_ENA_P0 + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3204 | port*4, 1); |
Eilon Greenstein | 345b5d5 | 2008-08-13 15:58:12 -0700 | [diff] [blame] | 3205 | tmp = EMAC_RD(bp, EMAC_REG_EMAC_LED); |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3206 | EMAC_WR(bp, EMAC_REG_EMAC_LED, (tmp & (~EMAC_LED_OVERRIDE))); |
Eilon Greenstein | 345b5d5 | 2008-08-13 15:58:12 -0700 | [diff] [blame] | 3207 | |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 3208 | if (CHIP_IS_E1(bp) && |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 3209 | ((speed == SPEED_2500) || |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3210 | (speed == SPEED_1000) || |
| 3211 | (speed == SPEED_100) || |
| 3212 | (speed == SPEED_10))) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3213 | /* |
| 3214 | * On Everest 1 Ax chip versions for speeds less than |
| 3215 | * 10G LED scheme is different |
| 3216 | */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3217 | REG_WR(bp, NIG_REG_LED_CONTROL_OVERRIDE_TRAFFIC_P0 |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3218 | + port*4, 1); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3219 | REG_WR(bp, NIG_REG_LED_CONTROL_TRAFFIC_P0 + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3220 | port*4, 0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3221 | REG_WR(bp, NIG_REG_LED_CONTROL_BLINK_TRAFFIC_P0 + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3222 | port*4, 1); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3223 | } |
| 3224 | break; |
| 3225 | |
| 3226 | default: |
| 3227 | rc = -EINVAL; |
| 3228 | DP(NETIF_MSG_LINK, "bnx2x_set_led: Invalid led mode %d\n", |
| 3229 | mode); |
| 3230 | break; |
| 3231 | } |
| 3232 | return rc; |
| 3233 | |
| 3234 | } |
| 3235 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3236 | /* |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3237 | * This function comes to reflect the actual link state read DIRECTLY from the |
| 3238 | * HW |
| 3239 | */ |
| 3240 | u8 bnx2x_test_link(struct link_params *params, struct link_vars *vars, |
| 3241 | u8 is_serdes) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3242 | { |
| 3243 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 3244 | u16 gp_status = 0, phy_index = 0; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3245 | u8 ext_phy_link_up = 0, serdes_phy_type; |
| 3246 | struct link_vars temp_vars; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3247 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 3248 | CL22_RD_OVER_CL45(bp, ¶ms->phy[INT_PHY], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3249 | MDIO_REG_BANK_GP_STATUS, |
| 3250 | MDIO_GP_STATUS_TOP_AN_STATUS1, |
| 3251 | &gp_status); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3252 | /* 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] | 3253 | if (!(gp_status & MDIO_GP_STATUS_TOP_AN_STATUS1_LINK_STATUS)) |
| 3254 | return -ESRCH; |
| 3255 | |
| 3256 | switch (params->num_phys) { |
| 3257 | case 1: |
| 3258 | /* No external PHY */ |
| 3259 | return 0; |
| 3260 | case 2: |
| 3261 | ext_phy_link_up = params->phy[EXT_PHY1].read_status( |
| 3262 | ¶ms->phy[EXT_PHY1], |
| 3263 | params, &temp_vars); |
| 3264 | break; |
| 3265 | case 3: /* Dual Media */ |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 3266 | for (phy_index = EXT_PHY1; phy_index < params->num_phys; |
| 3267 | phy_index++) { |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3268 | serdes_phy_type = ((params->phy[phy_index].media_type == |
| 3269 | ETH_PHY_SFP_FIBER) || |
| 3270 | (params->phy[phy_index].media_type == |
| 3271 | ETH_PHY_XFP_FIBER)); |
| 3272 | |
| 3273 | if (is_serdes != serdes_phy_type) |
| 3274 | continue; |
| 3275 | if (params->phy[phy_index].read_status) { |
| 3276 | ext_phy_link_up |= |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 3277 | params->phy[phy_index].read_status( |
| 3278 | ¶ms->phy[phy_index], |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3279 | params, &temp_vars); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3280 | } |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 3281 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3282 | break; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3283 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3284 | if (ext_phy_link_up) |
| 3285 | return 0; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3286 | return -ESRCH; |
| 3287 | } |
| 3288 | |
| 3289 | static u8 bnx2x_link_initialize(struct link_params *params, |
Yaniv Rosner | d90d96b | 2010-09-07 11:41:04 +0000 | [diff] [blame] | 3290 | struct link_vars *vars) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3291 | { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3292 | u8 rc = 0; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3293 | u8 phy_index, non_ext_phy; |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 3294 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3295 | /* |
| 3296 | * In case of external phy existence, the line speed would be the |
| 3297 | * line speed linked up by the external phy. In case it is direct |
| 3298 | * only, then the line_speed during initialization will be |
| 3299 | * equal to the req_line_speed |
| 3300 | */ |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 3301 | vars->line_speed = params->phy[INT_PHY].req_line_speed; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3302 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3303 | /* |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 3304 | * Initialize the internal phy in case this is a direct board |
| 3305 | * (no external phys), or this board has external phy which requires |
| 3306 | * to first. |
| 3307 | */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3308 | |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 3309 | if (params->phy[INT_PHY].config_init) |
| 3310 | params->phy[INT_PHY].config_init( |
| 3311 | ¶ms->phy[INT_PHY], |
| 3312 | params, vars); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3313 | |
| 3314 | /* init ext phy and enable link state int */ |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 3315 | non_ext_phy = (SINGLE_MEDIA_DIRECT(params) || |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3316 | (params->loopback_mode == LOOPBACK_XGXS)); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3317 | |
| 3318 | if (non_ext_phy || |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 3319 | (params->phy[EXT_PHY1].flags & FLAGS_INIT_XGXS_FIRST) || |
Eilon Greenstein | 8660d8c | 2009-03-02 08:01:02 +0000 | [diff] [blame] | 3320 | (params->loopback_mode == LOOPBACK_EXT_PHY)) { |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 3321 | struct bnx2x_phy *phy = ¶ms->phy[INT_PHY]; |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3322 | if (vars->line_speed == SPEED_AUTO_NEG) |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 3323 | bnx2x_set_parallel_detection(phy, params); |
| 3324 | bnx2x_init_internal_phy(phy, params, vars); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3325 | } |
| 3326 | |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 3327 | /* Init external phy*/ |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3328 | if (!non_ext_phy) |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3329 | for (phy_index = EXT_PHY1; phy_index < params->num_phys; |
| 3330 | phy_index++) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3331 | /* |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3332 | * No need to initialize second phy in case of first |
| 3333 | * phy only selection. In case of second phy, we do |
| 3334 | * need to initialize the first phy, since they are |
| 3335 | * connected. |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3336 | */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3337 | if (phy_index == EXT_PHY2 && |
| 3338 | (bnx2x_phy_selection(params) == |
| 3339 | PORT_HW_CFG_PHY_SELECTION_FIRST_PHY)) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3340 | DP(NETIF_MSG_LINK, "Ignoring second phy\n"); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3341 | continue; |
| 3342 | } |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3343 | params->phy[phy_index].config_init( |
| 3344 | ¶ms->phy[phy_index], |
| 3345 | params, vars); |
| 3346 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3347 | |
Yaniv Rosner | d90d96b | 2010-09-07 11:41:04 +0000 | [diff] [blame] | 3348 | /* Reset the interrupt indication after phy was initialized */ |
| 3349 | bnx2x_bits_dis(bp, NIG_REG_STATUS_INTERRUPT_PORT0 + |
| 3350 | params->port*4, |
| 3351 | (NIG_STATUS_XGXS0_LINK10G | |
| 3352 | NIG_STATUS_XGXS0_LINK_STATUS | |
| 3353 | NIG_STATUS_SERDES0_LINK_STATUS | |
| 3354 | NIG_MASK_MI_INT)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3355 | return rc; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3356 | } |
| 3357 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3358 | static void bnx2x_int_link_reset(struct bnx2x_phy *phy, |
| 3359 | struct link_params *params) |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3360 | { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3361 | /* reset the SerDes/XGXS */ |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3362 | REG_WR(params->bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_3_CLEAR, |
| 3363 | (0x1ff << (params->port*16))); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3364 | } |
| 3365 | |
| 3366 | static void bnx2x_common_ext_link_reset(struct bnx2x_phy *phy, |
| 3367 | struct link_params *params) |
| 3368 | { |
| 3369 | struct bnx2x *bp = params->bp; |
| 3370 | u8 gpio_port; |
| 3371 | /* HW reset */ |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 3372 | if (CHIP_IS_E2(bp)) |
| 3373 | gpio_port = BP_PATH(bp); |
| 3374 | else |
| 3375 | gpio_port = params->port; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3376 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3377 | MISC_REGISTERS_GPIO_OUTPUT_LOW, |
| 3378 | gpio_port); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3379 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3380 | MISC_REGISTERS_GPIO_OUTPUT_LOW, |
| 3381 | gpio_port); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3382 | DP(NETIF_MSG_LINK, "reset external PHY\n"); |
| 3383 | } |
| 3384 | |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3385 | static u8 bnx2x_update_link_down(struct link_params *params, |
| 3386 | struct link_vars *vars) |
| 3387 | { |
| 3388 | struct bnx2x *bp = params->bp; |
| 3389 | u8 port = params->port; |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 3390 | |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3391 | DP(NETIF_MSG_LINK, "Port %x: Link is down\n", port); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 3392 | bnx2x_set_led(params, vars, LED_MODE_OFF, 0); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3393 | |
| 3394 | /* indicate no mac active */ |
| 3395 | vars->mac_type = MAC_TYPE_NONE; |
| 3396 | |
| 3397 | /* update shared memory */ |
| 3398 | vars->link_status = 0; |
| 3399 | vars->line_speed = 0; |
| 3400 | bnx2x_update_mng(params, vars->link_status); |
| 3401 | |
| 3402 | /* activate nig drain */ |
| 3403 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + port*4, 1); |
| 3404 | |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 3405 | /* disable emac */ |
| 3406 | REG_WR(bp, NIG_REG_NIG_EMAC0_EN + port*4, 0); |
| 3407 | |
| 3408 | msleep(10); |
| 3409 | |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3410 | /* reset BigMac */ |
| 3411 | bnx2x_bmac_rx_disable(bp, params->port); |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3412 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_CLEAR, |
| 3413 | (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << port)); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3414 | return 0; |
| 3415 | } |
| 3416 | |
| 3417 | static u8 bnx2x_update_link_up(struct link_params *params, |
| 3418 | struct link_vars *vars, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3419 | u8 link_10g) |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3420 | { |
| 3421 | struct bnx2x *bp = params->bp; |
| 3422 | u8 port = params->port; |
| 3423 | u8 rc = 0; |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 3424 | |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3425 | vars->link_status |= LINK_STATUS_LINK_UP; |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 3426 | |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 3427 | if (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX) |
| 3428 | vars->link_status |= |
| 3429 | LINK_STATUS_TX_FLOW_CONTROL_ENABLED; |
| 3430 | |
| 3431 | if (vars->flow_ctrl & BNX2X_FLOW_CTRL_RX) |
| 3432 | vars->link_status |= |
| 3433 | LINK_STATUS_RX_FLOW_CONTROL_ENABLED; |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 3434 | |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3435 | if (link_10g) { |
| 3436 | bnx2x_bmac_enable(params, vars, 0); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 3437 | bnx2x_set_led(params, vars, |
| 3438 | LED_MODE_OPER, SPEED_10000); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3439 | } else { |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3440 | rc = bnx2x_emac_program(params, vars); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3441 | |
Yaniv Rosner | 0c786f0 | 2009-11-05 19:18:32 +0200 | [diff] [blame] | 3442 | bnx2x_emac_enable(params, vars, 0); |
| 3443 | |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3444 | /* AN complete? */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3445 | if ((vars->link_status & LINK_STATUS_AUTO_NEGOTIATE_COMPLETE) |
| 3446 | && (!(vars->phy_flags & PHY_SGMII_FLAG)) && |
| 3447 | SINGLE_MEDIA_DIRECT(params)) |
| 3448 | bnx2x_set_gmii_tx_driver(params); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3449 | } |
| 3450 | |
| 3451 | /* PBF - link up */ |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 3452 | if (!(CHIP_IS_E2(bp))) |
| 3453 | rc |= bnx2x_pbf_update(params, vars->flow_ctrl, |
| 3454 | vars->line_speed); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3455 | |
| 3456 | /* disable drain */ |
| 3457 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + port*4, 0); |
| 3458 | |
| 3459 | /* update shared memory */ |
| 3460 | bnx2x_update_mng(params, vars->link_status); |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 3461 | msleep(20); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3462 | return rc; |
| 3463 | } |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3464 | /* |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3465 | * The bnx2x_link_update function should be called upon link |
| 3466 | * interrupt. |
| 3467 | * Link is considered up as follows: |
| 3468 | * - DIRECT_SINGLE_MEDIA - Only XGXS link (internal link) needs |
| 3469 | * to be up |
| 3470 | * - SINGLE_MEDIA - The link between the 577xx and the external |
| 3471 | * phy (XGXS) need to up as well as the external link of the |
| 3472 | * phy (PHY_EXT1) |
| 3473 | * - DUAL_MEDIA - The link between the 577xx and the first |
| 3474 | * external phy needs to be up, and at least one of the 2 |
| 3475 | * external phy link must be up. |
Yaniv Rosner | 62b29a5 | 2010-09-07 11:40:58 +0000 | [diff] [blame] | 3476 | */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3477 | u8 bnx2x_link_update(struct link_params *params, struct link_vars *vars) |
| 3478 | { |
| 3479 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3480 | struct link_vars phy_vars[MAX_PHYS]; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3481 | u8 port = params->port; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3482 | u8 link_10g, phy_index; |
| 3483 | u8 ext_phy_link_up = 0, cur_link_up, rc = 0; |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 3484 | u8 is_mi_int = 0; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3485 | u16 ext_phy_line_speed = 0, prev_line_speed = vars->line_speed; |
| 3486 | u8 active_external_phy = INT_PHY; |
| 3487 | vars->link_status = 0; |
| 3488 | for (phy_index = INT_PHY; phy_index < params->num_phys; |
| 3489 | phy_index++) { |
| 3490 | phy_vars[phy_index].flow_ctrl = 0; |
| 3491 | phy_vars[phy_index].link_status = 0; |
| 3492 | phy_vars[phy_index].line_speed = 0; |
| 3493 | phy_vars[phy_index].duplex = DUPLEX_FULL; |
| 3494 | phy_vars[phy_index].phy_link_up = 0; |
| 3495 | phy_vars[phy_index].link_up = 0; |
| 3496 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3497 | |
| 3498 | 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] | 3499 | port, (vars->phy_flags & PHY_XGXS_FLAG), |
| 3500 | REG_RD(bp, NIG_REG_STATUS_INTERRUPT_PORT0 + port*4)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3501 | |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 3502 | 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] | 3503 | port*0x18) > 0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3504 | 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] | 3505 | REG_RD(bp, NIG_REG_MASK_INTERRUPT_PORT0 + port*4), |
| 3506 | is_mi_int, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3507 | REG_RD(bp, NIG_REG_SERDES0_STATUS_LINK_STATUS + port*0x3c)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3508 | |
| 3509 | DP(NETIF_MSG_LINK, " 10G %x, XGXS_LINK %x\n", |
| 3510 | REG_RD(bp, NIG_REG_XGXS0_STATUS_LINK10G + port*0x68), |
| 3511 | REG_RD(bp, NIG_REG_XGXS0_STATUS_LINK_STATUS + port*0x68)); |
| 3512 | |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 3513 | /* disable emac */ |
| 3514 | REG_WR(bp, NIG_REG_NIG_EMAC0_EN + port*4, 0); |
| 3515 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3516 | /* |
| 3517 | * Step 1: |
| 3518 | * Check external link change only for external phys, and apply |
| 3519 | * priority selection between them in case the link on both phys |
| 3520 | * is up. Note that the instead of the common vars, a temporary |
| 3521 | * vars argument is used since each phy may have different link/ |
| 3522 | * speed/duplex result |
| 3523 | */ |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3524 | for (phy_index = EXT_PHY1; phy_index < params->num_phys; |
| 3525 | phy_index++) { |
| 3526 | struct bnx2x_phy *phy = ¶ms->phy[phy_index]; |
| 3527 | if (!phy->read_status) |
| 3528 | continue; |
| 3529 | /* Read link status and params of this ext phy */ |
| 3530 | cur_link_up = phy->read_status(phy, params, |
| 3531 | &phy_vars[phy_index]); |
| 3532 | if (cur_link_up) { |
| 3533 | DP(NETIF_MSG_LINK, "phy in index %d link is up\n", |
| 3534 | phy_index); |
| 3535 | } else { |
| 3536 | DP(NETIF_MSG_LINK, "phy in index %d link is down\n", |
| 3537 | phy_index); |
| 3538 | continue; |
| 3539 | } |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3540 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3541 | if (!ext_phy_link_up) { |
| 3542 | ext_phy_link_up = 1; |
| 3543 | active_external_phy = phy_index; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3544 | } else { |
| 3545 | switch (bnx2x_phy_selection(params)) { |
| 3546 | case PORT_HW_CFG_PHY_SELECTION_HARDWARE_DEFAULT: |
| 3547 | case PORT_HW_CFG_PHY_SELECTION_FIRST_PHY_PRIORITY: |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3548 | /* |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3549 | * In this option, the first PHY makes sure to pass the |
| 3550 | * traffic through itself only. |
| 3551 | * Its not clear how to reset the link on the second phy |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3552 | */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3553 | active_external_phy = EXT_PHY1; |
| 3554 | break; |
| 3555 | case PORT_HW_CFG_PHY_SELECTION_SECOND_PHY_PRIORITY: |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3556 | /* |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3557 | * In this option, the first PHY makes sure to pass the |
| 3558 | * traffic through the second PHY. |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3559 | */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3560 | active_external_phy = EXT_PHY2; |
| 3561 | break; |
| 3562 | default: |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3563 | /* |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3564 | * Link indication on both PHYs with the following cases |
| 3565 | * is invalid: |
| 3566 | * - FIRST_PHY means that second phy wasn't initialized, |
| 3567 | * hence its link is expected to be down |
| 3568 | * - SECOND_PHY means that first phy should not be able |
| 3569 | * to link up by itself (using configuration) |
| 3570 | * - DEFAULT should be overriden during initialiazation |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3571 | */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3572 | DP(NETIF_MSG_LINK, "Invalid link indication" |
| 3573 | "mpc=0x%x. DISABLING LINK !!!\n", |
| 3574 | params->multi_phy_config); |
| 3575 | ext_phy_link_up = 0; |
| 3576 | break; |
| 3577 | } |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3578 | } |
| 3579 | } |
| 3580 | prev_line_speed = vars->line_speed; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3581 | /* |
| 3582 | * Step 2: |
| 3583 | * Read the status of the internal phy. In case of |
| 3584 | * DIRECT_SINGLE_MEDIA board, this link is the external link, |
| 3585 | * otherwise this is the link between the 577xx and the first |
| 3586 | * external phy |
| 3587 | */ |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3588 | if (params->phy[INT_PHY].read_status) |
| 3589 | params->phy[INT_PHY].read_status( |
| 3590 | ¶ms->phy[INT_PHY], |
| 3591 | params, vars); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3592 | /* |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3593 | * The INT_PHY flow control reside in the vars. This include the |
| 3594 | * case where the speed or flow control are not set to AUTO. |
| 3595 | * Otherwise, the active external phy flow control result is set |
| 3596 | * to the vars. The ext_phy_line_speed is needed to check if the |
| 3597 | * speed is different between the internal phy and external phy. |
| 3598 | * This case may be result of intermediate link speed change. |
| 3599 | */ |
| 3600 | if (active_external_phy > INT_PHY) { |
| 3601 | vars->flow_ctrl = phy_vars[active_external_phy].flow_ctrl; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3602 | /* |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3603 | * Link speed is taken from the XGXS. AN and FC result from |
| 3604 | * the external phy. |
| 3605 | */ |
| 3606 | vars->link_status |= phy_vars[active_external_phy].link_status; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3607 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3608 | /* |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3609 | * if active_external_phy is first PHY and link is up - disable |
| 3610 | * disable TX on second external PHY |
| 3611 | */ |
| 3612 | if (active_external_phy == EXT_PHY1) { |
| 3613 | if (params->phy[EXT_PHY2].phy_specific_func) { |
| 3614 | DP(NETIF_MSG_LINK, "Disabling TX on" |
| 3615 | " EXT_PHY2\n"); |
| 3616 | params->phy[EXT_PHY2].phy_specific_func( |
| 3617 | ¶ms->phy[EXT_PHY2], |
| 3618 | params, DISABLE_TX); |
| 3619 | } |
| 3620 | } |
| 3621 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3622 | ext_phy_line_speed = phy_vars[active_external_phy].line_speed; |
| 3623 | vars->duplex = phy_vars[active_external_phy].duplex; |
| 3624 | if (params->phy[active_external_phy].supported & |
| 3625 | SUPPORTED_FIBRE) |
| 3626 | vars->link_status |= LINK_STATUS_SERDES_LINK; |
| 3627 | DP(NETIF_MSG_LINK, "Active external phy selected: %x\n", |
| 3628 | active_external_phy); |
| 3629 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3630 | |
| 3631 | for (phy_index = EXT_PHY1; phy_index < params->num_phys; |
| 3632 | phy_index++) { |
| 3633 | if (params->phy[phy_index].flags & |
| 3634 | FLAGS_REARM_LATCH_SIGNAL) { |
| 3635 | bnx2x_rearm_latch_signal(bp, port, |
| 3636 | phy_index == |
| 3637 | active_external_phy); |
| 3638 | break; |
| 3639 | } |
| 3640 | } |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3641 | DP(NETIF_MSG_LINK, "vars->flow_ctrl = 0x%x, vars->link_status = 0x%x," |
| 3642 | " ext_phy_line_speed = %d\n", vars->flow_ctrl, |
| 3643 | vars->link_status, ext_phy_line_speed); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3644 | /* |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3645 | * Upon link speed change set the NIG into drain mode. Comes to |
| 3646 | * deals with possible FIFO glitch due to clk change when speed |
| 3647 | * is decreased without link down indicator |
| 3648 | */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3649 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3650 | if (vars->phy_link_up) { |
| 3651 | if (!(SINGLE_MEDIA_DIRECT(params)) && ext_phy_link_up && |
| 3652 | (ext_phy_line_speed != vars->line_speed)) { |
| 3653 | DP(NETIF_MSG_LINK, "Internal link speed %d is" |
| 3654 | " different than the external" |
| 3655 | " link speed %d\n", vars->line_speed, |
| 3656 | ext_phy_line_speed); |
| 3657 | vars->phy_link_up = 0; |
| 3658 | } else if (prev_line_speed != vars->line_speed) { |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3659 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + params->port*4, |
| 3660 | 0); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3661 | msleep(1); |
| 3662 | } |
| 3663 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3664 | |
| 3665 | /* anything 10 and over uses the bmac */ |
| 3666 | link_10g = ((vars->line_speed == SPEED_10000) || |
| 3667 | (vars->line_speed == SPEED_12000) || |
| 3668 | (vars->line_speed == SPEED_12500) || |
| 3669 | (vars->line_speed == SPEED_13000) || |
| 3670 | (vars->line_speed == SPEED_15000) || |
| 3671 | (vars->line_speed == SPEED_16000)); |
| 3672 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3673 | bnx2x_link_int_ack(params, vars, link_10g); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3674 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3675 | /* |
| 3676 | * In case external phy link is up, and internal link is down |
| 3677 | * (not initialized yet probably after link initialization, it |
| 3678 | * needs to be initialized. |
| 3679 | * Note that after link down-up as result of cable plug, the xgxs |
| 3680 | * link would probably become up again without the need |
| 3681 | * initialize it |
| 3682 | */ |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3683 | if (!(SINGLE_MEDIA_DIRECT(params))) { |
| 3684 | DP(NETIF_MSG_LINK, "ext_phy_link_up = %d, int_link_up = %d," |
| 3685 | " init_preceding = %d\n", ext_phy_link_up, |
| 3686 | vars->phy_link_up, |
| 3687 | params->phy[EXT_PHY1].flags & |
| 3688 | FLAGS_INIT_XGXS_FIRST); |
| 3689 | if (!(params->phy[EXT_PHY1].flags & |
| 3690 | FLAGS_INIT_XGXS_FIRST) |
| 3691 | && ext_phy_link_up && !vars->phy_link_up) { |
| 3692 | vars->line_speed = ext_phy_line_speed; |
| 3693 | if (vars->line_speed < SPEED_1000) |
| 3694 | vars->phy_flags |= PHY_SGMII_FLAG; |
| 3695 | else |
| 3696 | vars->phy_flags &= ~PHY_SGMII_FLAG; |
| 3697 | bnx2x_init_internal_phy(¶ms->phy[INT_PHY], |
| 3698 | params, |
| 3699 | vars); |
| 3700 | } |
| 3701 | } |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3702 | /* |
| 3703 | * Link is up only if both local phy and external phy (in case of |
| 3704 | * non-direct board) are up |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3705 | */ |
| 3706 | vars->link_up = (vars->phy_link_up && |
| 3707 | (ext_phy_link_up || |
| 3708 | SINGLE_MEDIA_DIRECT(params))); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3709 | |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3710 | if (vars->link_up) |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3711 | rc = bnx2x_update_link_up(params, vars, link_10g); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3712 | else |
| 3713 | rc = bnx2x_update_link_down(params, vars); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3714 | |
| 3715 | return rc; |
| 3716 | } |
| 3717 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3718 | |
| 3719 | /*****************************************************************************/ |
| 3720 | /* External Phy section */ |
| 3721 | /*****************************************************************************/ |
| 3722 | void bnx2x_ext_phy_hw_reset(struct bnx2x *bp, u8 port) |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3723 | { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3724 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3725 | MISC_REGISTERS_GPIO_OUTPUT_LOW, port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3726 | msleep(1); |
| 3727 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3728 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, port); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3729 | } |
| 3730 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3731 | static void bnx2x_save_spirom_version(struct bnx2x *bp, u8 port, |
| 3732 | u32 spirom_ver, u32 ver_addr) |
| 3733 | { |
| 3734 | DP(NETIF_MSG_LINK, "FW version 0x%x:0x%x for port %d\n", |
| 3735 | (u16)(spirom_ver>>16), (u16)spirom_ver, port); |
| 3736 | |
| 3737 | if (ver_addr) |
| 3738 | REG_WR(bp, ver_addr, spirom_ver); |
| 3739 | } |
| 3740 | |
| 3741 | static void bnx2x_save_bcm_spirom_ver(struct bnx2x *bp, |
| 3742 | struct bnx2x_phy *phy, |
| 3743 | u8 port) |
| 3744 | { |
| 3745 | u16 fw_ver1, fw_ver2; |
| 3746 | |
| 3747 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3748 | MDIO_PMA_REG_ROM_VER1, &fw_ver1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3749 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3750 | MDIO_PMA_REG_ROM_VER2, &fw_ver2); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3751 | bnx2x_save_spirom_version(bp, port, (u32)(fw_ver1<<16 | fw_ver2), |
| 3752 | phy->ver_addr); |
| 3753 | } |
| 3754 | |
| 3755 | static void bnx2x_ext_phy_set_pause(struct link_params *params, |
| 3756 | struct bnx2x_phy *phy, |
| 3757 | struct link_vars *vars) |
| 3758 | { |
| 3759 | u16 val; |
| 3760 | struct bnx2x *bp = params->bp; |
| 3761 | /* read modify write pause advertizing */ |
| 3762 | bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_ADV_PAUSE, &val); |
| 3763 | |
| 3764 | val &= ~MDIO_AN_REG_ADV_PAUSE_BOTH; |
| 3765 | |
| 3766 | /* Please refer to Table 28B-3 of 802.3ab-1999 spec. */ |
| 3767 | bnx2x_calc_ieee_aneg_adv(phy, params, &vars->ieee_fc); |
| 3768 | if ((vars->ieee_fc & |
| 3769 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC) == |
| 3770 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC) { |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3771 | val |= MDIO_AN_REG_ADV_PAUSE_ASYMMETRIC; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3772 | } |
| 3773 | if ((vars->ieee_fc & |
| 3774 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) == |
| 3775 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) { |
| 3776 | val |= MDIO_AN_REG_ADV_PAUSE_PAUSE; |
| 3777 | } |
| 3778 | DP(NETIF_MSG_LINK, "Ext phy AN advertize 0x%x\n", val); |
| 3779 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_ADV_PAUSE, val); |
| 3780 | } |
| 3781 | |
| 3782 | static u8 bnx2x_ext_phy_resolve_fc(struct bnx2x_phy *phy, |
| 3783 | struct link_params *params, |
| 3784 | struct link_vars *vars) |
| 3785 | { |
| 3786 | struct bnx2x *bp = params->bp; |
| 3787 | u16 ld_pause; /* local */ |
| 3788 | u16 lp_pause; /* link partner */ |
| 3789 | u16 pause_result; |
| 3790 | u8 ret = 0; |
| 3791 | /* read twice */ |
| 3792 | |
| 3793 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 3794 | |
| 3795 | if (phy->req_flow_ctrl != BNX2X_FLOW_CTRL_AUTO) |
| 3796 | vars->flow_ctrl = phy->req_flow_ctrl; |
| 3797 | else if (phy->req_line_speed != SPEED_AUTO_NEG) |
| 3798 | vars->flow_ctrl = params->req_fc_auto_adv; |
| 3799 | else if (vars->link_status & LINK_STATUS_AUTO_NEGOTIATE_COMPLETE) { |
| 3800 | ret = 1; |
| 3801 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3802 | MDIO_AN_DEVAD, |
| 3803 | MDIO_AN_REG_ADV_PAUSE, &ld_pause); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3804 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3805 | MDIO_AN_DEVAD, |
| 3806 | MDIO_AN_REG_LP_AUTO_NEG, &lp_pause); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3807 | pause_result = (ld_pause & |
| 3808 | MDIO_AN_REG_ADV_PAUSE_MASK) >> 8; |
| 3809 | pause_result |= (lp_pause & |
| 3810 | MDIO_AN_REG_ADV_PAUSE_MASK) >> 10; |
| 3811 | DP(NETIF_MSG_LINK, "Ext PHY pause result 0x%x\n", |
| 3812 | pause_result); |
| 3813 | bnx2x_pause_resolve(vars, pause_result); |
| 3814 | } |
| 3815 | return ret; |
| 3816 | } |
| 3817 | |
| 3818 | static void bnx2x_ext_phy_10G_an_resolve(struct bnx2x *bp, |
| 3819 | struct bnx2x_phy *phy, |
| 3820 | struct link_vars *vars) |
| 3821 | { |
| 3822 | u16 val; |
| 3823 | bnx2x_cl45_read(bp, phy, |
| 3824 | MDIO_AN_DEVAD, |
| 3825 | MDIO_AN_REG_STATUS, &val); |
| 3826 | bnx2x_cl45_read(bp, phy, |
| 3827 | MDIO_AN_DEVAD, |
| 3828 | MDIO_AN_REG_STATUS, &val); |
| 3829 | if (val & (1<<5)) |
| 3830 | vars->link_status |= LINK_STATUS_AUTO_NEGOTIATE_COMPLETE; |
| 3831 | if ((val & (1<<0)) == 0) |
| 3832 | vars->link_status |= LINK_STATUS_PARALLEL_DETECTION_USED; |
| 3833 | } |
| 3834 | |
| 3835 | /******************************************************************/ |
| 3836 | /* common BCM8073/BCM8727 PHY SECTION */ |
| 3837 | /******************************************************************/ |
| 3838 | static void bnx2x_8073_resolve_fc(struct bnx2x_phy *phy, |
| 3839 | struct link_params *params, |
| 3840 | struct link_vars *vars) |
| 3841 | { |
| 3842 | struct bnx2x *bp = params->bp; |
| 3843 | if (phy->req_line_speed == SPEED_10 || |
| 3844 | phy->req_line_speed == SPEED_100) { |
| 3845 | vars->flow_ctrl = phy->req_flow_ctrl; |
| 3846 | return; |
| 3847 | } |
| 3848 | |
| 3849 | if (bnx2x_ext_phy_resolve_fc(phy, params, vars) && |
| 3850 | (vars->flow_ctrl == BNX2X_FLOW_CTRL_NONE)) { |
| 3851 | u16 pause_result; |
| 3852 | u16 ld_pause; /* local */ |
| 3853 | u16 lp_pause; /* link partner */ |
| 3854 | bnx2x_cl45_read(bp, phy, |
| 3855 | MDIO_AN_DEVAD, |
| 3856 | MDIO_AN_REG_CL37_FC_LD, &ld_pause); |
| 3857 | |
| 3858 | bnx2x_cl45_read(bp, phy, |
| 3859 | MDIO_AN_DEVAD, |
| 3860 | MDIO_AN_REG_CL37_FC_LP, &lp_pause); |
| 3861 | pause_result = (ld_pause & |
| 3862 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) >> 5; |
| 3863 | pause_result |= (lp_pause & |
| 3864 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) >> 7; |
| 3865 | |
| 3866 | bnx2x_pause_resolve(vars, pause_result); |
| 3867 | DP(NETIF_MSG_LINK, "Ext PHY CL37 pause result 0x%x\n", |
| 3868 | pause_result); |
| 3869 | } |
| 3870 | } |
Yaniv Rosner | 5c99274b | 2011-01-18 04:33:36 +0000 | [diff] [blame] | 3871 | static u8 bnx2x_8073_8727_external_rom_boot(struct bnx2x *bp, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3872 | struct bnx2x_phy *phy, |
| 3873 | u8 port) |
| 3874 | { |
Yaniv Rosner | 5c99274b | 2011-01-18 04:33:36 +0000 | [diff] [blame] | 3875 | u32 count = 0; |
| 3876 | u16 fw_ver1, fw_msgout; |
| 3877 | u8 rc = 0; |
| 3878 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3879 | /* Boot port from external ROM */ |
| 3880 | /* EDC grst */ |
| 3881 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3882 | MDIO_PMA_DEVAD, |
| 3883 | MDIO_PMA_REG_GEN_CTRL, |
| 3884 | 0x0001); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3885 | |
| 3886 | /* ucode reboot and rst */ |
| 3887 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3888 | MDIO_PMA_DEVAD, |
| 3889 | MDIO_PMA_REG_GEN_CTRL, |
| 3890 | 0x008c); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3891 | |
| 3892 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3893 | MDIO_PMA_DEVAD, |
| 3894 | MDIO_PMA_REG_MISC_CTRL1, 0x0001); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3895 | |
| 3896 | /* Reset internal microprocessor */ |
| 3897 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3898 | MDIO_PMA_DEVAD, |
| 3899 | MDIO_PMA_REG_GEN_CTRL, |
| 3900 | MDIO_PMA_REG_GEN_CTRL_ROM_MICRO_RESET); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3901 | |
| 3902 | /* Release srst bit */ |
| 3903 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3904 | MDIO_PMA_DEVAD, |
| 3905 | MDIO_PMA_REG_GEN_CTRL, |
| 3906 | MDIO_PMA_REG_GEN_CTRL_ROM_RESET_INTERNAL_MP); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3907 | |
Yaniv Rosner | 5c99274b | 2011-01-18 04:33:36 +0000 | [diff] [blame] | 3908 | /* Delay 100ms per the PHY specifications */ |
| 3909 | msleep(100); |
| 3910 | |
| 3911 | /* 8073 sometimes taking longer to download */ |
| 3912 | do { |
| 3913 | count++; |
| 3914 | if (count > 300) { |
| 3915 | DP(NETIF_MSG_LINK, |
| 3916 | "bnx2x_8073_8727_external_rom_boot port %x:" |
| 3917 | "Download failed. fw version = 0x%x\n", |
| 3918 | port, fw_ver1); |
| 3919 | rc = -EINVAL; |
| 3920 | break; |
| 3921 | } |
| 3922 | |
| 3923 | bnx2x_cl45_read(bp, phy, |
| 3924 | MDIO_PMA_DEVAD, |
| 3925 | MDIO_PMA_REG_ROM_VER1, &fw_ver1); |
| 3926 | bnx2x_cl45_read(bp, phy, |
| 3927 | MDIO_PMA_DEVAD, |
| 3928 | MDIO_PMA_REG_M8051_MSGOUT_REG, &fw_msgout); |
| 3929 | |
| 3930 | msleep(1); |
| 3931 | } while (fw_ver1 == 0 || fw_ver1 == 0x4321 || |
| 3932 | ((fw_msgout & 0xff) != 0x03 && (phy->type == |
| 3933 | PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073))); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3934 | |
| 3935 | /* Clear ser_boot_ctl bit */ |
| 3936 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3937 | MDIO_PMA_DEVAD, |
| 3938 | MDIO_PMA_REG_MISC_CTRL1, 0x0000); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3939 | bnx2x_save_bcm_spirom_ver(bp, phy, port); |
Yaniv Rosner | 5c99274b | 2011-01-18 04:33:36 +0000 | [diff] [blame] | 3940 | |
| 3941 | DP(NETIF_MSG_LINK, |
| 3942 | "bnx2x_8073_8727_external_rom_boot port %x:" |
| 3943 | "Download complete. fw version = 0x%x\n", |
| 3944 | port, fw_ver1); |
| 3945 | |
| 3946 | return rc; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3947 | } |
| 3948 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3949 | /******************************************************************/ |
| 3950 | /* BCM8073 PHY SECTION */ |
| 3951 | /******************************************************************/ |
| 3952 | static u8 bnx2x_8073_is_snr_needed(struct bnx2x *bp, struct bnx2x_phy *phy) |
| 3953 | { |
| 3954 | /* This is only required for 8073A1, version 102 only */ |
| 3955 | u16 val; |
| 3956 | |
| 3957 | /* Read 8073 HW revision*/ |
| 3958 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3959 | MDIO_PMA_DEVAD, |
| 3960 | MDIO_PMA_REG_8073_CHIP_REV, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3961 | |
| 3962 | if (val != 1) { |
| 3963 | /* No need to workaround in 8073 A1 */ |
| 3964 | return 0; |
| 3965 | } |
| 3966 | |
| 3967 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3968 | MDIO_PMA_DEVAD, |
| 3969 | MDIO_PMA_REG_ROM_VER2, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3970 | |
| 3971 | /* SNR should be applied only for version 0x102 */ |
| 3972 | if (val != 0x102) |
| 3973 | return 0; |
| 3974 | |
| 3975 | return 1; |
| 3976 | } |
| 3977 | |
| 3978 | static u8 bnx2x_8073_xaui_wa(struct bnx2x *bp, struct bnx2x_phy *phy) |
| 3979 | { |
| 3980 | u16 val, cnt, cnt1 ; |
| 3981 | |
| 3982 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3983 | MDIO_PMA_DEVAD, |
| 3984 | MDIO_PMA_REG_8073_CHIP_REV, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3985 | |
| 3986 | if (val > 0) { |
| 3987 | /* No need to workaround in 8073 A1 */ |
| 3988 | return 0; |
| 3989 | } |
| 3990 | /* XAUI workaround in 8073 A0: */ |
| 3991 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3992 | /* |
| 3993 | * After loading the boot ROM and restarting Autoneg, poll |
| 3994 | * Dev1, Reg $C820: |
| 3995 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3996 | |
| 3997 | for (cnt = 0; cnt < 1000; cnt++) { |
| 3998 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3999 | MDIO_PMA_DEVAD, |
| 4000 | MDIO_PMA_REG_8073_SPEED_LINK_STATUS, |
| 4001 | &val); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 4002 | /* |
| 4003 | * If bit [14] = 0 or bit [13] = 0, continue on with |
| 4004 | * system initialization (XAUI work-around not required, as |
| 4005 | * these bits indicate 2.5G or 1G link up). |
| 4006 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4007 | if (!(val & (1<<14)) || !(val & (1<<13))) { |
| 4008 | DP(NETIF_MSG_LINK, "XAUI work-around not required\n"); |
| 4009 | return 0; |
| 4010 | } else if (!(val & (1<<15))) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 4011 | DP(NETIF_MSG_LINK, "bit 15 went off\n"); |
| 4012 | /* |
| 4013 | * If bit 15 is 0, then poll Dev1, Reg $C841 until it's |
| 4014 | * MSB (bit15) goes to 1 (indicating that the XAUI |
| 4015 | * workaround has completed), then continue on with |
| 4016 | * system initialization. |
| 4017 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4018 | for (cnt1 = 0; cnt1 < 1000; cnt1++) { |
| 4019 | bnx2x_cl45_read(bp, phy, |
| 4020 | MDIO_PMA_DEVAD, |
| 4021 | MDIO_PMA_REG_8073_XAUI_WA, &val); |
| 4022 | if (val & (1<<15)) { |
| 4023 | DP(NETIF_MSG_LINK, |
| 4024 | "XAUI workaround has completed\n"); |
| 4025 | return 0; |
| 4026 | } |
| 4027 | msleep(3); |
| 4028 | } |
| 4029 | break; |
| 4030 | } |
| 4031 | msleep(3); |
| 4032 | } |
| 4033 | DP(NETIF_MSG_LINK, "Warning: XAUI work-around timeout !!!\n"); |
| 4034 | return -EINVAL; |
| 4035 | } |
| 4036 | |
| 4037 | static void bnx2x_807x_force_10G(struct bnx2x *bp, struct bnx2x_phy *phy) |
| 4038 | { |
| 4039 | /* Force KR or KX */ |
| 4040 | bnx2x_cl45_write(bp, phy, |
| 4041 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 0x2040); |
| 4042 | bnx2x_cl45_write(bp, phy, |
| 4043 | MDIO_PMA_DEVAD, MDIO_PMA_REG_10G_CTRL2, 0x000b); |
| 4044 | bnx2x_cl45_write(bp, phy, |
| 4045 | MDIO_PMA_DEVAD, MDIO_PMA_REG_BCM_CTRL, 0x0000); |
| 4046 | bnx2x_cl45_write(bp, phy, |
| 4047 | MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, 0x0000); |
| 4048 | } |
| 4049 | |
| 4050 | static void bnx2x_8073_set_pause_cl37(struct link_params *params, |
| 4051 | struct bnx2x_phy *phy, |
| 4052 | struct link_vars *vars) |
| 4053 | { |
| 4054 | u16 cl37_val; |
| 4055 | struct bnx2x *bp = params->bp; |
| 4056 | bnx2x_cl45_read(bp, phy, |
| 4057 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_FC_LD, &cl37_val); |
| 4058 | |
| 4059 | cl37_val &= ~MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH; |
| 4060 | /* Please refer to Table 28B-3 of 802.3ab-1999 spec. */ |
| 4061 | bnx2x_calc_ieee_aneg_adv(phy, params, &vars->ieee_fc); |
| 4062 | if ((vars->ieee_fc & |
| 4063 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_SYMMETRIC) == |
| 4064 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_SYMMETRIC) { |
| 4065 | cl37_val |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_SYMMETRIC; |
| 4066 | } |
| 4067 | if ((vars->ieee_fc & |
| 4068 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC) == |
| 4069 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC) { |
| 4070 | cl37_val |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC; |
| 4071 | } |
| 4072 | if ((vars->ieee_fc & |
| 4073 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) == |
| 4074 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) { |
| 4075 | cl37_val |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH; |
| 4076 | } |
| 4077 | DP(NETIF_MSG_LINK, |
| 4078 | "Ext phy AN advertize cl37 0x%x\n", cl37_val); |
| 4079 | |
| 4080 | bnx2x_cl45_write(bp, phy, |
| 4081 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_FC_LD, cl37_val); |
| 4082 | msleep(500); |
| 4083 | } |
| 4084 | |
| 4085 | static u8 bnx2x_8073_config_init(struct bnx2x_phy *phy, |
| 4086 | struct link_params *params, |
| 4087 | struct link_vars *vars) |
| 4088 | { |
| 4089 | struct bnx2x *bp = params->bp; |
| 4090 | u16 val = 0, tmp1; |
| 4091 | u8 gpio_port; |
| 4092 | DP(NETIF_MSG_LINK, "Init 8073\n"); |
| 4093 | |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 4094 | if (CHIP_IS_E2(bp)) |
| 4095 | gpio_port = BP_PATH(bp); |
| 4096 | else |
| 4097 | gpio_port = params->port; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4098 | /* Restore normal power mode*/ |
| 4099 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4100 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, gpio_port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4101 | |
| 4102 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4103 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, gpio_port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4104 | |
| 4105 | /* enable LASI */ |
| 4106 | bnx2x_cl45_write(bp, phy, |
| 4107 | MDIO_PMA_DEVAD, MDIO_PMA_REG_RX_ALARM_CTRL, (1<<2)); |
| 4108 | bnx2x_cl45_write(bp, phy, |
| 4109 | MDIO_PMA_DEVAD, MDIO_PMA_REG_LASI_CTRL, 0x0004); |
| 4110 | |
| 4111 | bnx2x_8073_set_pause_cl37(params, phy, vars); |
| 4112 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4113 | bnx2x_cl45_read(bp, phy, |
| 4114 | MDIO_PMA_DEVAD, MDIO_PMA_REG_M8051_MSGOUT_REG, &tmp1); |
| 4115 | |
| 4116 | bnx2x_cl45_read(bp, phy, |
| 4117 | MDIO_PMA_DEVAD, MDIO_PMA_REG_RX_ALARM, &tmp1); |
| 4118 | |
| 4119 | DP(NETIF_MSG_LINK, "Before rom RX_ALARM(port1): 0x%x\n", tmp1); |
| 4120 | |
Yaniv Rosner | 74d7a11 | 2011-01-18 04:33:18 +0000 | [diff] [blame] | 4121 | /* Swap polarity if required - Must be done only in non-1G mode */ |
| 4122 | if (params->lane_config & PORT_HW_CFG_SWAP_PHY_POLARITY_ENABLED) { |
| 4123 | /* Configure the 8073 to swap _P and _N of the KR lines */ |
| 4124 | DP(NETIF_MSG_LINK, "Swapping polarity for the 8073\n"); |
| 4125 | /* 10G Rx/Tx and 1G Tx signal polarity swap */ |
| 4126 | bnx2x_cl45_read(bp, phy, |
| 4127 | MDIO_PMA_DEVAD, |
| 4128 | MDIO_PMA_REG_8073_OPT_DIGITAL_CTRL, &val); |
| 4129 | bnx2x_cl45_write(bp, phy, |
| 4130 | MDIO_PMA_DEVAD, |
| 4131 | MDIO_PMA_REG_8073_OPT_DIGITAL_CTRL, |
| 4132 | (val | (3<<9))); |
| 4133 | } |
| 4134 | |
| 4135 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4136 | /* Enable CL37 BAM */ |
Yaniv Rosner | 121839b | 2010-11-01 05:32:38 +0000 | [diff] [blame] | 4137 | if (REG_RD(bp, params->shmem_base + |
| 4138 | offsetof(struct shmem_region, dev_info. |
| 4139 | port_hw_config[params->port].default_cfg)) & |
| 4140 | PORT_HW_CFG_ENABLE_BAM_ON_KR_ENABLED) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4141 | |
Yaniv Rosner | 121839b | 2010-11-01 05:32:38 +0000 | [diff] [blame] | 4142 | bnx2x_cl45_read(bp, phy, |
| 4143 | MDIO_AN_DEVAD, |
| 4144 | MDIO_AN_REG_8073_BAM, &val); |
| 4145 | bnx2x_cl45_write(bp, phy, |
| 4146 | MDIO_AN_DEVAD, |
| 4147 | MDIO_AN_REG_8073_BAM, val | 1); |
| 4148 | DP(NETIF_MSG_LINK, "Enable CL37 BAM on KR\n"); |
| 4149 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4150 | if (params->loopback_mode == LOOPBACK_EXT) { |
| 4151 | bnx2x_807x_force_10G(bp, phy); |
| 4152 | DP(NETIF_MSG_LINK, "Forced speed 10G on 807X\n"); |
| 4153 | return 0; |
| 4154 | } else { |
| 4155 | bnx2x_cl45_write(bp, phy, |
| 4156 | MDIO_PMA_DEVAD, MDIO_PMA_REG_BCM_CTRL, 0x0002); |
| 4157 | } |
| 4158 | if (phy->req_line_speed != SPEED_AUTO_NEG) { |
| 4159 | if (phy->req_line_speed == SPEED_10000) { |
| 4160 | val = (1<<7); |
| 4161 | } else if (phy->req_line_speed == SPEED_2500) { |
| 4162 | val = (1<<5); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 4163 | /* |
| 4164 | * Note that 2.5G works only when used with 1G |
| 4165 | * advertisment |
| 4166 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4167 | } else |
| 4168 | val = (1<<5); |
| 4169 | } else { |
| 4170 | val = 0; |
| 4171 | if (phy->speed_cap_mask & |
| 4172 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G) |
| 4173 | val |= (1<<7); |
| 4174 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 4175 | /* Note that 2.5G works only when used with 1G advertisment */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4176 | if (phy->speed_cap_mask & |
| 4177 | (PORT_HW_CFG_SPEED_CAPABILITY_D0_1G | |
| 4178 | PORT_HW_CFG_SPEED_CAPABILITY_D0_2_5G)) |
| 4179 | val |= (1<<5); |
| 4180 | DP(NETIF_MSG_LINK, "807x autoneg val = 0x%x\n", val); |
| 4181 | } |
| 4182 | |
| 4183 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_ADV, val); |
| 4184 | bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_8073_2_5G, &tmp1); |
| 4185 | |
| 4186 | if (((phy->speed_cap_mask & PORT_HW_CFG_SPEED_CAPABILITY_D0_2_5G) && |
| 4187 | (phy->req_line_speed == SPEED_AUTO_NEG)) || |
| 4188 | (phy->req_line_speed == SPEED_2500)) { |
| 4189 | u16 phy_ver; |
| 4190 | /* Allow 2.5G for A1 and above */ |
| 4191 | bnx2x_cl45_read(bp, phy, |
| 4192 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8073_CHIP_REV, |
| 4193 | &phy_ver); |
| 4194 | DP(NETIF_MSG_LINK, "Add 2.5G\n"); |
| 4195 | if (phy_ver > 0) |
| 4196 | tmp1 |= 1; |
| 4197 | else |
| 4198 | tmp1 &= 0xfffe; |
| 4199 | } else { |
| 4200 | DP(NETIF_MSG_LINK, "Disable 2.5G\n"); |
| 4201 | tmp1 &= 0xfffe; |
| 4202 | } |
| 4203 | |
| 4204 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_8073_2_5G, tmp1); |
| 4205 | /* Add support for CL37 (passive mode) II */ |
| 4206 | |
| 4207 | bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_CL37_FC_LD, &tmp1); |
| 4208 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_CL37_FC_LD, |
| 4209 | (tmp1 | ((phy->req_duplex == DUPLEX_FULL) ? |
| 4210 | 0x20 : 0x40))); |
| 4211 | |
| 4212 | /* Add support for CL37 (passive mode) III */ |
| 4213 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_CL37_AN, 0x1000); |
| 4214 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 4215 | /* |
| 4216 | * The SNR will improve about 2db by changing BW and FEE main |
| 4217 | * tap. Rest commands are executed after link is up |
| 4218 | * Change FFE main cursor to 5 in EDC register |
| 4219 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4220 | if (bnx2x_8073_is_snr_needed(bp, phy)) |
| 4221 | bnx2x_cl45_write(bp, phy, |
| 4222 | MDIO_PMA_DEVAD, MDIO_PMA_REG_EDC_FFE_MAIN, |
| 4223 | 0xFB0C); |
| 4224 | |
| 4225 | /* Enable FEC (Forware Error Correction) Request in the AN */ |
| 4226 | bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_ADV2, &tmp1); |
| 4227 | tmp1 |= (1<<15); |
| 4228 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_ADV2, tmp1); |
| 4229 | |
| 4230 | bnx2x_ext_phy_set_pause(params, phy, vars); |
| 4231 | |
| 4232 | /* Restart autoneg */ |
| 4233 | msleep(500); |
| 4234 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, 0x1200); |
| 4235 | DP(NETIF_MSG_LINK, "807x Autoneg Restart: Advertise 1G=%x, 10G=%x\n", |
| 4236 | ((val & (1<<5)) > 0), ((val & (1<<7)) > 0)); |
| 4237 | return 0; |
| 4238 | } |
| 4239 | |
| 4240 | static u8 bnx2x_8073_read_status(struct bnx2x_phy *phy, |
| 4241 | struct link_params *params, |
| 4242 | struct link_vars *vars) |
| 4243 | { |
| 4244 | struct bnx2x *bp = params->bp; |
| 4245 | u8 link_up = 0; |
| 4246 | u16 val1, val2; |
| 4247 | u16 link_status = 0; |
| 4248 | u16 an1000_status = 0; |
| 4249 | |
| 4250 | bnx2x_cl45_read(bp, phy, |
| 4251 | MDIO_PMA_DEVAD, MDIO_PMA_REG_LASI_STATUS, &val1); |
| 4252 | |
| 4253 | DP(NETIF_MSG_LINK, "8703 LASI status 0x%x\n", val1); |
| 4254 | |
| 4255 | /* clear the interrupt LASI status register */ |
| 4256 | bnx2x_cl45_read(bp, phy, |
| 4257 | MDIO_PCS_DEVAD, MDIO_PCS_REG_STATUS, &val2); |
| 4258 | bnx2x_cl45_read(bp, phy, |
| 4259 | MDIO_PCS_DEVAD, MDIO_PCS_REG_STATUS, &val1); |
| 4260 | DP(NETIF_MSG_LINK, "807x PCS status 0x%x->0x%x\n", val2, val1); |
| 4261 | /* Clear MSG-OUT */ |
| 4262 | bnx2x_cl45_read(bp, phy, |
| 4263 | MDIO_PMA_DEVAD, MDIO_PMA_REG_M8051_MSGOUT_REG, &val1); |
| 4264 | |
| 4265 | /* Check the LASI */ |
| 4266 | bnx2x_cl45_read(bp, phy, |
| 4267 | MDIO_PMA_DEVAD, MDIO_PMA_REG_RX_ALARM, &val2); |
| 4268 | |
| 4269 | DP(NETIF_MSG_LINK, "KR 0x9003 0x%x\n", val2); |
| 4270 | |
| 4271 | /* Check the link status */ |
| 4272 | bnx2x_cl45_read(bp, phy, |
| 4273 | MDIO_PCS_DEVAD, MDIO_PCS_REG_STATUS, &val2); |
| 4274 | DP(NETIF_MSG_LINK, "KR PCS status 0x%x\n", val2); |
| 4275 | |
| 4276 | bnx2x_cl45_read(bp, phy, |
| 4277 | MDIO_PMA_DEVAD, MDIO_PMA_REG_STATUS, &val2); |
| 4278 | bnx2x_cl45_read(bp, phy, |
| 4279 | MDIO_PMA_DEVAD, MDIO_PMA_REG_STATUS, &val1); |
| 4280 | link_up = ((val1 & 4) == 4); |
| 4281 | DP(NETIF_MSG_LINK, "PMA_REG_STATUS=0x%x\n", val1); |
| 4282 | |
| 4283 | if (link_up && |
| 4284 | ((phy->req_line_speed != SPEED_10000))) { |
| 4285 | if (bnx2x_8073_xaui_wa(bp, phy) != 0) |
| 4286 | return 0; |
| 4287 | } |
| 4288 | bnx2x_cl45_read(bp, phy, |
| 4289 | MDIO_AN_DEVAD, MDIO_AN_REG_LINK_STATUS, &an1000_status); |
| 4290 | bnx2x_cl45_read(bp, phy, |
| 4291 | MDIO_AN_DEVAD, MDIO_AN_REG_LINK_STATUS, &an1000_status); |
| 4292 | |
| 4293 | /* Check the link status on 1.1.2 */ |
| 4294 | bnx2x_cl45_read(bp, phy, |
| 4295 | MDIO_PMA_DEVAD, MDIO_PMA_REG_STATUS, &val2); |
| 4296 | bnx2x_cl45_read(bp, phy, |
| 4297 | MDIO_PMA_DEVAD, MDIO_PMA_REG_STATUS, &val1); |
| 4298 | DP(NETIF_MSG_LINK, "KR PMA status 0x%x->0x%x," |
| 4299 | "an_link_status=0x%x\n", val2, val1, an1000_status); |
| 4300 | |
| 4301 | link_up = (((val1 & 4) == 4) || (an1000_status & (1<<1))); |
| 4302 | if (link_up && bnx2x_8073_is_snr_needed(bp, phy)) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 4303 | /* |
| 4304 | * The SNR will improve about 2dbby changing the BW and FEE main |
| 4305 | * tap. The 1st write to change FFE main tap is set before |
| 4306 | * restart AN. Change PLL Bandwidth in EDC register |
| 4307 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4308 | bnx2x_cl45_write(bp, phy, |
| 4309 | MDIO_PMA_DEVAD, MDIO_PMA_REG_PLL_BANDWIDTH, |
| 4310 | 0x26BC); |
| 4311 | |
| 4312 | /* Change CDR Bandwidth in EDC register */ |
| 4313 | bnx2x_cl45_write(bp, phy, |
| 4314 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CDR_BANDWIDTH, |
| 4315 | 0x0333); |
| 4316 | } |
| 4317 | bnx2x_cl45_read(bp, phy, |
| 4318 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8073_SPEED_LINK_STATUS, |
| 4319 | &link_status); |
| 4320 | |
| 4321 | /* Bits 0..2 --> speed detected, bits 13..15--> link is down */ |
| 4322 | if ((link_status & (1<<2)) && (!(link_status & (1<<15)))) { |
| 4323 | link_up = 1; |
| 4324 | vars->line_speed = SPEED_10000; |
| 4325 | DP(NETIF_MSG_LINK, "port %x: External link up in 10G\n", |
| 4326 | params->port); |
| 4327 | } else if ((link_status & (1<<1)) && (!(link_status & (1<<14)))) { |
| 4328 | link_up = 1; |
| 4329 | vars->line_speed = SPEED_2500; |
| 4330 | DP(NETIF_MSG_LINK, "port %x: External link up in 2.5G\n", |
| 4331 | params->port); |
| 4332 | } else if ((link_status & (1<<0)) && (!(link_status & (1<<13)))) { |
| 4333 | link_up = 1; |
| 4334 | vars->line_speed = SPEED_1000; |
| 4335 | DP(NETIF_MSG_LINK, "port %x: External link up in 1G\n", |
| 4336 | params->port); |
| 4337 | } else { |
| 4338 | link_up = 0; |
| 4339 | DP(NETIF_MSG_LINK, "port %x: External link is down\n", |
| 4340 | params->port); |
| 4341 | } |
| 4342 | |
| 4343 | if (link_up) { |
Yaniv Rosner | 74d7a11 | 2011-01-18 04:33:18 +0000 | [diff] [blame] | 4344 | /* Swap polarity if required */ |
| 4345 | if (params->lane_config & |
| 4346 | PORT_HW_CFG_SWAP_PHY_POLARITY_ENABLED) { |
| 4347 | /* Configure the 8073 to swap P and N of the KR lines */ |
| 4348 | bnx2x_cl45_read(bp, phy, |
| 4349 | MDIO_XS_DEVAD, |
| 4350 | MDIO_XS_REG_8073_RX_CTRL_PCIE, &val1); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 4351 | /* |
| 4352 | * Set bit 3 to invert Rx in 1G mode and clear this bit |
| 4353 | * when it`s in 10G mode. |
| 4354 | */ |
Yaniv Rosner | 74d7a11 | 2011-01-18 04:33:18 +0000 | [diff] [blame] | 4355 | if (vars->line_speed == SPEED_1000) { |
| 4356 | DP(NETIF_MSG_LINK, "Swapping 1G polarity for" |
| 4357 | "the 8073\n"); |
| 4358 | val1 |= (1<<3); |
| 4359 | } else |
| 4360 | val1 &= ~(1<<3); |
| 4361 | |
| 4362 | bnx2x_cl45_write(bp, phy, |
| 4363 | MDIO_XS_DEVAD, |
| 4364 | MDIO_XS_REG_8073_RX_CTRL_PCIE, |
| 4365 | val1); |
| 4366 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4367 | bnx2x_ext_phy_10G_an_resolve(bp, phy, vars); |
| 4368 | bnx2x_8073_resolve_fc(phy, params, vars); |
Yaniv Rosner | 791f18c | 2011-01-18 04:33:42 +0000 | [diff] [blame] | 4369 | vars->duplex = DUPLEX_FULL; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4370 | } |
| 4371 | return link_up; |
| 4372 | } |
| 4373 | |
| 4374 | static void bnx2x_8073_link_reset(struct bnx2x_phy *phy, |
| 4375 | struct link_params *params) |
| 4376 | { |
| 4377 | struct bnx2x *bp = params->bp; |
| 4378 | u8 gpio_port; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 4379 | if (CHIP_IS_E2(bp)) |
| 4380 | gpio_port = BP_PATH(bp); |
| 4381 | else |
| 4382 | gpio_port = params->port; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4383 | DP(NETIF_MSG_LINK, "Setting 8073 port %d into low power mode\n", |
| 4384 | gpio_port); |
| 4385 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4386 | MISC_REGISTERS_GPIO_OUTPUT_LOW, |
| 4387 | gpio_port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4388 | } |
| 4389 | |
| 4390 | /******************************************************************/ |
| 4391 | /* BCM8705 PHY SECTION */ |
| 4392 | /******************************************************************/ |
| 4393 | static u8 bnx2x_8705_config_init(struct bnx2x_phy *phy, |
| 4394 | struct link_params *params, |
| 4395 | struct link_vars *vars) |
| 4396 | { |
| 4397 | struct bnx2x *bp = params->bp; |
| 4398 | DP(NETIF_MSG_LINK, "init 8705\n"); |
| 4399 | /* Restore normal power mode*/ |
| 4400 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4401 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, params->port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4402 | /* HW reset */ |
| 4403 | bnx2x_ext_phy_hw_reset(bp, params->port); |
| 4404 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 0xa040); |
| 4405 | bnx2x_wait_reset_complete(bp, phy); |
| 4406 | |
| 4407 | bnx2x_cl45_write(bp, phy, |
| 4408 | MDIO_PMA_DEVAD, MDIO_PMA_REG_MISC_CTRL, 0x8288); |
| 4409 | bnx2x_cl45_write(bp, phy, |
| 4410 | MDIO_PMA_DEVAD, MDIO_PMA_REG_PHY_IDENTIFIER, 0x7fbf); |
| 4411 | bnx2x_cl45_write(bp, phy, |
| 4412 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CMU_PLL_BYPASS, 0x0100); |
| 4413 | bnx2x_cl45_write(bp, phy, |
| 4414 | MDIO_WIS_DEVAD, MDIO_WIS_REG_LASI_CNTL, 0x1); |
| 4415 | /* BCM8705 doesn't have microcode, hence the 0 */ |
| 4416 | bnx2x_save_spirom_version(bp, params->port, params->shmem_base, 0); |
| 4417 | return 0; |
| 4418 | } |
| 4419 | |
| 4420 | static u8 bnx2x_8705_read_status(struct bnx2x_phy *phy, |
| 4421 | struct link_params *params, |
| 4422 | struct link_vars *vars) |
| 4423 | { |
| 4424 | u8 link_up = 0; |
| 4425 | u16 val1, rx_sd; |
| 4426 | struct bnx2x *bp = params->bp; |
| 4427 | DP(NETIF_MSG_LINK, "read status 8705\n"); |
| 4428 | bnx2x_cl45_read(bp, phy, |
| 4429 | MDIO_WIS_DEVAD, MDIO_WIS_REG_LASI_STATUS, &val1); |
| 4430 | DP(NETIF_MSG_LINK, "8705 LASI status 0x%x\n", val1); |
| 4431 | |
| 4432 | bnx2x_cl45_read(bp, phy, |
| 4433 | MDIO_WIS_DEVAD, MDIO_WIS_REG_LASI_STATUS, &val1); |
| 4434 | DP(NETIF_MSG_LINK, "8705 LASI status 0x%x\n", val1); |
| 4435 | |
| 4436 | bnx2x_cl45_read(bp, phy, |
| 4437 | MDIO_PMA_DEVAD, MDIO_PMA_REG_RX_SD, &rx_sd); |
| 4438 | |
| 4439 | bnx2x_cl45_read(bp, phy, |
| 4440 | MDIO_PMA_DEVAD, 0xc809, &val1); |
| 4441 | bnx2x_cl45_read(bp, phy, |
| 4442 | MDIO_PMA_DEVAD, 0xc809, &val1); |
| 4443 | |
| 4444 | DP(NETIF_MSG_LINK, "8705 1.c809 val=0x%x\n", val1); |
| 4445 | link_up = ((rx_sd & 0x1) && (val1 & (1<<9)) && ((val1 & (1<<8)) == 0)); |
| 4446 | if (link_up) { |
| 4447 | vars->line_speed = SPEED_10000; |
| 4448 | bnx2x_ext_phy_resolve_fc(phy, params, vars); |
| 4449 | } |
| 4450 | return link_up; |
| 4451 | } |
| 4452 | |
| 4453 | /******************************************************************/ |
| 4454 | /* SFP+ module Section */ |
| 4455 | /******************************************************************/ |
| 4456 | static void bnx2x_sfp_set_transmitter(struct bnx2x *bp, |
| 4457 | struct bnx2x_phy *phy, |
| 4458 | u8 port, |
| 4459 | u8 tx_en) |
| 4460 | { |
| 4461 | u16 val; |
| 4462 | |
| 4463 | DP(NETIF_MSG_LINK, "Setting transmitter tx_en=%x for port %x\n", |
| 4464 | tx_en, port); |
| 4465 | /* Disable/Enable transmitter ( TX laser of the SFP+ module.)*/ |
| 4466 | bnx2x_cl45_read(bp, phy, |
| 4467 | MDIO_PMA_DEVAD, |
| 4468 | MDIO_PMA_REG_PHY_IDENTIFIER, |
| 4469 | &val); |
| 4470 | |
| 4471 | if (tx_en) |
| 4472 | val &= ~(1<<15); |
| 4473 | else |
| 4474 | val |= (1<<15); |
| 4475 | |
| 4476 | bnx2x_cl45_write(bp, phy, |
| 4477 | MDIO_PMA_DEVAD, |
| 4478 | MDIO_PMA_REG_PHY_IDENTIFIER, |
| 4479 | val); |
| 4480 | } |
| 4481 | |
| 4482 | static u8 bnx2x_8726_read_sfp_module_eeprom(struct bnx2x_phy *phy, |
| 4483 | struct link_params *params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4484 | u16 addr, u8 byte_cnt, u8 *o_buf) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4485 | { |
| 4486 | struct bnx2x *bp = params->bp; |
| 4487 | u16 val = 0; |
| 4488 | u16 i; |
| 4489 | if (byte_cnt > 16) { |
| 4490 | DP(NETIF_MSG_LINK, "Reading from eeprom is" |
| 4491 | " is limited to 0xf\n"); |
| 4492 | return -EINVAL; |
| 4493 | } |
| 4494 | /* Set the read command byte count */ |
| 4495 | bnx2x_cl45_write(bp, phy, |
| 4496 | MDIO_PMA_DEVAD, MDIO_PMA_REG_SFP_TWO_WIRE_BYTE_CNT, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4497 | (byte_cnt | 0xa000)); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4498 | |
| 4499 | /* Set the read command address */ |
| 4500 | bnx2x_cl45_write(bp, phy, |
| 4501 | MDIO_PMA_DEVAD, MDIO_PMA_REG_SFP_TWO_WIRE_MEM_ADDR, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4502 | addr); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4503 | |
| 4504 | /* Activate read command */ |
| 4505 | bnx2x_cl45_write(bp, phy, |
| 4506 | MDIO_PMA_DEVAD, MDIO_PMA_REG_SFP_TWO_WIRE_CTRL, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4507 | 0x2c0f); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4508 | |
| 4509 | /* Wait up to 500us for command complete status */ |
| 4510 | for (i = 0; i < 100; i++) { |
| 4511 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4512 | MDIO_PMA_DEVAD, |
| 4513 | MDIO_PMA_REG_SFP_TWO_WIRE_CTRL, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4514 | if ((val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK) == |
| 4515 | MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_COMPLETE) |
| 4516 | break; |
| 4517 | udelay(5); |
| 4518 | } |
| 4519 | |
| 4520 | if ((val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK) != |
| 4521 | MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_COMPLETE) { |
| 4522 | DP(NETIF_MSG_LINK, |
| 4523 | "Got bad status 0x%x when reading from SFP+ EEPROM\n", |
| 4524 | (val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK)); |
| 4525 | return -EINVAL; |
| 4526 | } |
| 4527 | |
| 4528 | /* Read the buffer */ |
| 4529 | for (i = 0; i < byte_cnt; i++) { |
| 4530 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4531 | MDIO_PMA_DEVAD, |
| 4532 | MDIO_PMA_REG_8726_TWO_WIRE_DATA_BUF + i, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4533 | o_buf[i] = (u8)(val & MDIO_PMA_REG_8726_TWO_WIRE_DATA_MASK); |
| 4534 | } |
| 4535 | |
| 4536 | for (i = 0; i < 100; i++) { |
| 4537 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4538 | MDIO_PMA_DEVAD, |
| 4539 | MDIO_PMA_REG_SFP_TWO_WIRE_CTRL, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4540 | if ((val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK) == |
| 4541 | MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_IDLE) |
Joe Perches | 6f38ad9 | 2010-11-14 17:04:31 +0000 | [diff] [blame] | 4542 | return 0; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4543 | msleep(1); |
| 4544 | } |
| 4545 | return -EINVAL; |
| 4546 | } |
| 4547 | |
| 4548 | static u8 bnx2x_8727_read_sfp_module_eeprom(struct bnx2x_phy *phy, |
| 4549 | struct link_params *params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4550 | u16 addr, u8 byte_cnt, u8 *o_buf) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4551 | { |
| 4552 | struct bnx2x *bp = params->bp; |
| 4553 | u16 val, i; |
| 4554 | |
| 4555 | if (byte_cnt > 16) { |
| 4556 | DP(NETIF_MSG_LINK, "Reading from eeprom is" |
| 4557 | " is limited to 0xf\n"); |
| 4558 | return -EINVAL; |
| 4559 | } |
| 4560 | |
| 4561 | /* Need to read from 1.8000 to clear it */ |
| 4562 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4563 | MDIO_PMA_DEVAD, |
| 4564 | MDIO_PMA_REG_SFP_TWO_WIRE_CTRL, |
| 4565 | &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4566 | |
| 4567 | /* Set the read command byte count */ |
| 4568 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4569 | MDIO_PMA_DEVAD, |
| 4570 | MDIO_PMA_REG_SFP_TWO_WIRE_BYTE_CNT, |
| 4571 | ((byte_cnt < 2) ? 2 : byte_cnt)); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4572 | |
| 4573 | /* Set the read command address */ |
| 4574 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4575 | MDIO_PMA_DEVAD, |
| 4576 | MDIO_PMA_REG_SFP_TWO_WIRE_MEM_ADDR, |
| 4577 | addr); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4578 | /* Set the destination address */ |
| 4579 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4580 | MDIO_PMA_DEVAD, |
| 4581 | 0x8004, |
| 4582 | MDIO_PMA_REG_8727_TWO_WIRE_DATA_BUF); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4583 | |
| 4584 | /* Activate read command */ |
| 4585 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4586 | MDIO_PMA_DEVAD, |
| 4587 | MDIO_PMA_REG_SFP_TWO_WIRE_CTRL, |
| 4588 | 0x8002); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 4589 | /* |
| 4590 | * Wait appropriate time for two-wire command to finish before |
| 4591 | * polling the status register |
| 4592 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4593 | msleep(1); |
| 4594 | |
| 4595 | /* Wait up to 500us for command complete status */ |
| 4596 | for (i = 0; i < 100; i++) { |
| 4597 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4598 | MDIO_PMA_DEVAD, |
| 4599 | MDIO_PMA_REG_SFP_TWO_WIRE_CTRL, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4600 | if ((val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK) == |
| 4601 | MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_COMPLETE) |
| 4602 | break; |
| 4603 | udelay(5); |
| 4604 | } |
| 4605 | |
| 4606 | if ((val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK) != |
| 4607 | MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_COMPLETE) { |
| 4608 | DP(NETIF_MSG_LINK, |
| 4609 | "Got bad status 0x%x when reading from SFP+ EEPROM\n", |
| 4610 | (val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK)); |
Yaniv Rosner | 65a001b | 2011-01-31 04:22:03 +0000 | [diff] [blame^] | 4611 | return -EFAULT; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4612 | } |
| 4613 | |
| 4614 | /* Read the buffer */ |
| 4615 | for (i = 0; i < byte_cnt; i++) { |
| 4616 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4617 | MDIO_PMA_DEVAD, |
| 4618 | MDIO_PMA_REG_8727_TWO_WIRE_DATA_BUF + i, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4619 | o_buf[i] = (u8)(val & MDIO_PMA_REG_8727_TWO_WIRE_DATA_MASK); |
| 4620 | } |
| 4621 | |
| 4622 | for (i = 0; i < 100; i++) { |
| 4623 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4624 | MDIO_PMA_DEVAD, |
| 4625 | MDIO_PMA_REG_SFP_TWO_WIRE_CTRL, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4626 | if ((val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK) == |
| 4627 | MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_IDLE) |
Joe Perches | 6f38ad9 | 2010-11-14 17:04:31 +0000 | [diff] [blame] | 4628 | return 0; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4629 | msleep(1); |
| 4630 | } |
| 4631 | |
| 4632 | return -EINVAL; |
| 4633 | } |
| 4634 | |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4635 | u8 bnx2x_read_sfp_module_eeprom(struct bnx2x_phy *phy, |
| 4636 | struct link_params *params, u16 addr, |
| 4637 | u8 byte_cnt, u8 *o_buf) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4638 | { |
| 4639 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726) |
| 4640 | return bnx2x_8726_read_sfp_module_eeprom(phy, params, addr, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4641 | byte_cnt, o_buf); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4642 | else if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727) |
| 4643 | return bnx2x_8727_read_sfp_module_eeprom(phy, params, addr, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4644 | byte_cnt, o_buf); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4645 | return -EINVAL; |
| 4646 | } |
| 4647 | |
| 4648 | static u8 bnx2x_get_edc_mode(struct bnx2x_phy *phy, |
| 4649 | struct link_params *params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4650 | u16 *edc_mode) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4651 | { |
| 4652 | struct bnx2x *bp = params->bp; |
| 4653 | u8 val, check_limiting_mode = 0; |
| 4654 | *edc_mode = EDC_MODE_LIMITING; |
| 4655 | |
| 4656 | /* First check for copper cable */ |
| 4657 | if (bnx2x_read_sfp_module_eeprom(phy, |
| 4658 | params, |
| 4659 | SFP_EEPROM_CON_TYPE_ADDR, |
| 4660 | 1, |
| 4661 | &val) != 0) { |
| 4662 | DP(NETIF_MSG_LINK, "Failed to read from SFP+ module EEPROM\n"); |
| 4663 | return -EINVAL; |
| 4664 | } |
| 4665 | |
| 4666 | switch (val) { |
| 4667 | case SFP_EEPROM_CON_TYPE_VAL_COPPER: |
| 4668 | { |
| 4669 | u8 copper_module_type; |
| 4670 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 4671 | /* |
| 4672 | * Check if its active cable (includes SFP+ module) |
| 4673 | * of passive cable |
| 4674 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4675 | if (bnx2x_read_sfp_module_eeprom(phy, |
| 4676 | params, |
| 4677 | SFP_EEPROM_FC_TX_TECH_ADDR, |
| 4678 | 1, |
| 4679 | &copper_module_type) != |
| 4680 | 0) { |
| 4681 | DP(NETIF_MSG_LINK, |
| 4682 | "Failed to read copper-cable-type" |
| 4683 | " from SFP+ EEPROM\n"); |
| 4684 | return -EINVAL; |
| 4685 | } |
| 4686 | |
| 4687 | if (copper_module_type & |
| 4688 | SFP_EEPROM_FC_TX_TECH_BITMASK_COPPER_ACTIVE) { |
| 4689 | DP(NETIF_MSG_LINK, "Active Copper cable detected\n"); |
| 4690 | check_limiting_mode = 1; |
| 4691 | } else if (copper_module_type & |
| 4692 | SFP_EEPROM_FC_TX_TECH_BITMASK_COPPER_PASSIVE) { |
| 4693 | DP(NETIF_MSG_LINK, "Passive Copper" |
| 4694 | " cable detected\n"); |
| 4695 | *edc_mode = |
| 4696 | EDC_MODE_PASSIVE_DAC; |
| 4697 | } else { |
| 4698 | DP(NETIF_MSG_LINK, "Unknown copper-cable-" |
| 4699 | "type 0x%x !!!\n", copper_module_type); |
| 4700 | return -EINVAL; |
| 4701 | } |
| 4702 | break; |
| 4703 | } |
| 4704 | case SFP_EEPROM_CON_TYPE_VAL_LC: |
| 4705 | DP(NETIF_MSG_LINK, "Optic module detected\n"); |
| 4706 | check_limiting_mode = 1; |
| 4707 | break; |
| 4708 | default: |
| 4709 | DP(NETIF_MSG_LINK, "Unable to determine module type 0x%x !!!\n", |
| 4710 | val); |
| 4711 | return -EINVAL; |
| 4712 | } |
| 4713 | |
| 4714 | if (check_limiting_mode) { |
| 4715 | u8 options[SFP_EEPROM_OPTIONS_SIZE]; |
| 4716 | if (bnx2x_read_sfp_module_eeprom(phy, |
| 4717 | params, |
| 4718 | SFP_EEPROM_OPTIONS_ADDR, |
| 4719 | SFP_EEPROM_OPTIONS_SIZE, |
| 4720 | options) != 0) { |
| 4721 | DP(NETIF_MSG_LINK, "Failed to read Option" |
| 4722 | " field from module EEPROM\n"); |
| 4723 | return -EINVAL; |
| 4724 | } |
| 4725 | if ((options[0] & SFP_EEPROM_OPTIONS_LINEAR_RX_OUT_MASK)) |
| 4726 | *edc_mode = EDC_MODE_LINEAR; |
| 4727 | else |
| 4728 | *edc_mode = EDC_MODE_LIMITING; |
| 4729 | } |
| 4730 | DP(NETIF_MSG_LINK, "EDC mode is set to 0x%x\n", *edc_mode); |
| 4731 | return 0; |
| 4732 | } |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 4733 | /* |
| 4734 | * This function read the relevant field from the module (SFP+), and verify it |
| 4735 | * is compliant with this board |
| 4736 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4737 | static u8 bnx2x_verify_sfp_module(struct bnx2x_phy *phy, |
| 4738 | struct link_params *params) |
| 4739 | { |
| 4740 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 4741 | u32 val, cmd; |
| 4742 | u32 fw_resp, fw_cmd_param; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4743 | char vendor_name[SFP_EEPROM_VENDOR_NAME_SIZE+1]; |
| 4744 | char vendor_pn[SFP_EEPROM_PART_NO_SIZE+1]; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 4745 | phy->flags &= ~FLAGS_SFP_NOT_APPROVED; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4746 | val = REG_RD(bp, params->shmem_base + |
| 4747 | offsetof(struct shmem_region, dev_info. |
| 4748 | port_feature_config[params->port].config)); |
| 4749 | if ((val & PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK) == |
| 4750 | PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_NO_ENFORCEMENT) { |
| 4751 | DP(NETIF_MSG_LINK, "NOT enforcing module verification\n"); |
| 4752 | return 0; |
| 4753 | } |
| 4754 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 4755 | if (params->feature_config_flags & |
| 4756 | FEATURE_CONFIG_BC_SUPPORTS_DUAL_PHY_OPT_MDL_VRFY) { |
| 4757 | /* Use specific phy request */ |
| 4758 | cmd = DRV_MSG_CODE_VRFY_SPECIFIC_PHY_OPT_MDL; |
| 4759 | } else if (params->feature_config_flags & |
| 4760 | FEATURE_CONFIG_BC_SUPPORTS_OPT_MDL_VRFY) { |
| 4761 | /* Use first phy request only in case of non-dual media*/ |
| 4762 | if (DUAL_MEDIA(params)) { |
| 4763 | DP(NETIF_MSG_LINK, "FW does not support OPT MDL " |
| 4764 | "verification\n"); |
| 4765 | return -EINVAL; |
| 4766 | } |
| 4767 | cmd = DRV_MSG_CODE_VRFY_FIRST_PHY_OPT_MDL; |
| 4768 | } else { |
| 4769 | /* No support in OPT MDL detection */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4770 | DP(NETIF_MSG_LINK, "FW does not support OPT MDL " |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 4771 | "verification\n"); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4772 | return -EINVAL; |
| 4773 | } |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 4774 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 4775 | fw_cmd_param = FW_PARAM_SET(phy->addr, phy->type, phy->mdio_ctrl); |
| 4776 | fw_resp = bnx2x_fw_command(bp, cmd, fw_cmd_param); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4777 | if (fw_resp == FW_MSG_CODE_VRFY_OPT_MDL_SUCCESS) { |
| 4778 | DP(NETIF_MSG_LINK, "Approved module\n"); |
| 4779 | return 0; |
| 4780 | } |
| 4781 | |
| 4782 | /* format the warning message */ |
| 4783 | if (bnx2x_read_sfp_module_eeprom(phy, |
| 4784 | params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4785 | SFP_EEPROM_VENDOR_NAME_ADDR, |
| 4786 | SFP_EEPROM_VENDOR_NAME_SIZE, |
| 4787 | (u8 *)vendor_name)) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4788 | vendor_name[0] = '\0'; |
| 4789 | else |
| 4790 | vendor_name[SFP_EEPROM_VENDOR_NAME_SIZE] = '\0'; |
| 4791 | if (bnx2x_read_sfp_module_eeprom(phy, |
| 4792 | params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4793 | SFP_EEPROM_PART_NO_ADDR, |
| 4794 | SFP_EEPROM_PART_NO_SIZE, |
| 4795 | (u8 *)vendor_pn)) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4796 | vendor_pn[0] = '\0'; |
| 4797 | else |
| 4798 | vendor_pn[SFP_EEPROM_PART_NO_SIZE] = '\0'; |
| 4799 | |
| 4800 | netdev_info(bp->dev, "Warning: Unqualified SFP+ module detected," |
| 4801 | " Port %d from %s part number %s\n", |
| 4802 | params->port, vendor_name, vendor_pn); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 4803 | phy->flags |= FLAGS_SFP_NOT_APPROVED; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4804 | return -EINVAL; |
| 4805 | } |
| 4806 | |
| 4807 | static u8 bnx2x_wait_for_sfp_module_initialized(struct bnx2x_phy *phy, |
| 4808 | struct link_params *params) |
| 4809 | |
| 4810 | { |
| 4811 | u8 val; |
| 4812 | struct bnx2x *bp = params->bp; |
| 4813 | u16 timeout; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 4814 | /* |
| 4815 | * Initialization time after hot-plug may take up to 300ms for |
| 4816 | * some phys type ( e.g. JDSU ) |
| 4817 | */ |
| 4818 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4819 | for (timeout = 0; timeout < 60; timeout++) { |
| 4820 | if (bnx2x_read_sfp_module_eeprom(phy, params, 1, 1, &val) |
| 4821 | == 0) { |
| 4822 | DP(NETIF_MSG_LINK, "SFP+ module initialization " |
| 4823 | "took %d ms\n", timeout * 5); |
| 4824 | return 0; |
| 4825 | } |
| 4826 | msleep(5); |
| 4827 | } |
| 4828 | return -EINVAL; |
| 4829 | } |
| 4830 | |
| 4831 | static void bnx2x_8727_power_module(struct bnx2x *bp, |
| 4832 | struct bnx2x_phy *phy, |
| 4833 | u8 is_power_up) { |
| 4834 | /* Make sure GPIOs are not using for LED mode */ |
| 4835 | u16 val; |
| 4836 | /* |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 4837 | * 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] | 4838 | * operating as INPUT or as OUTPUT. Bit 1 is for input, and 0 for |
| 4839 | * output |
| 4840 | * Bits 0-1 determine the gpios value for OUTPUT in case bit 4 val is 0 |
| 4841 | * Bits 8-9 determine the gpios value for INPUT in case bit 4 val is 1 |
| 4842 | * where the 1st bit is the over-current(only input), and 2nd bit is |
| 4843 | * for power( only output ) |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 4844 | * |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4845 | * In case of NOC feature is disabled and power is up, set GPIO control |
| 4846 | * as input to enable listening of over-current indication |
| 4847 | */ |
| 4848 | if (phy->flags & FLAGS_NOC) |
| 4849 | return; |
| 4850 | if (!(phy->flags & |
| 4851 | FLAGS_NOC) && is_power_up) |
| 4852 | val = (1<<4); |
| 4853 | else |
| 4854 | /* |
| 4855 | * Set GPIO control to OUTPUT, and set the power bit |
| 4856 | * to according to the is_power_up |
| 4857 | */ |
| 4858 | val = ((!(is_power_up)) << 1); |
| 4859 | |
| 4860 | bnx2x_cl45_write(bp, phy, |
| 4861 | MDIO_PMA_DEVAD, |
| 4862 | MDIO_PMA_REG_8727_GPIO_CTRL, |
| 4863 | val); |
| 4864 | } |
| 4865 | |
| 4866 | static u8 bnx2x_8726_set_limiting_mode(struct bnx2x *bp, |
| 4867 | struct bnx2x_phy *phy, |
| 4868 | u16 edc_mode) |
| 4869 | { |
| 4870 | u16 cur_limiting_mode; |
| 4871 | |
| 4872 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4873 | MDIO_PMA_DEVAD, |
| 4874 | MDIO_PMA_REG_ROM_VER2, |
| 4875 | &cur_limiting_mode); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4876 | DP(NETIF_MSG_LINK, "Current Limiting mode is 0x%x\n", |
| 4877 | cur_limiting_mode); |
| 4878 | |
| 4879 | if (edc_mode == EDC_MODE_LIMITING) { |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4880 | DP(NETIF_MSG_LINK, "Setting LIMITING MODE\n"); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4881 | bnx2x_cl45_write(bp, phy, |
| 4882 | MDIO_PMA_DEVAD, |
| 4883 | MDIO_PMA_REG_ROM_VER2, |
| 4884 | EDC_MODE_LIMITING); |
| 4885 | } else { /* LRM mode ( default )*/ |
| 4886 | |
| 4887 | DP(NETIF_MSG_LINK, "Setting LRM MODE\n"); |
| 4888 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 4889 | /* |
| 4890 | * Changing to LRM mode takes quite few seconds. So do it only |
| 4891 | * if current mode is limiting (default is LRM) |
| 4892 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4893 | if (cur_limiting_mode != EDC_MODE_LIMITING) |
| 4894 | return 0; |
| 4895 | |
| 4896 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4897 | MDIO_PMA_DEVAD, |
| 4898 | MDIO_PMA_REG_LRM_MODE, |
| 4899 | 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4900 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4901 | MDIO_PMA_DEVAD, |
| 4902 | MDIO_PMA_REG_ROM_VER2, |
| 4903 | 0x128); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4904 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4905 | MDIO_PMA_DEVAD, |
| 4906 | MDIO_PMA_REG_MISC_CTRL0, |
| 4907 | 0x4008); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4908 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4909 | MDIO_PMA_DEVAD, |
| 4910 | MDIO_PMA_REG_LRM_MODE, |
| 4911 | 0xaaaa); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4912 | } |
| 4913 | return 0; |
| 4914 | } |
| 4915 | |
| 4916 | static u8 bnx2x_8727_set_limiting_mode(struct bnx2x *bp, |
| 4917 | struct bnx2x_phy *phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4918 | u16 edc_mode) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4919 | { |
| 4920 | u16 phy_identifier; |
| 4921 | u16 rom_ver2_val; |
| 4922 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4923 | MDIO_PMA_DEVAD, |
| 4924 | MDIO_PMA_REG_PHY_IDENTIFIER, |
| 4925 | &phy_identifier); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4926 | |
| 4927 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4928 | MDIO_PMA_DEVAD, |
| 4929 | MDIO_PMA_REG_PHY_IDENTIFIER, |
| 4930 | (phy_identifier & ~(1<<9))); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4931 | |
| 4932 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4933 | MDIO_PMA_DEVAD, |
| 4934 | MDIO_PMA_REG_ROM_VER2, |
| 4935 | &rom_ver2_val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4936 | /* Keep the MSB 8-bits, and set the LSB 8-bits with the edc_mode */ |
| 4937 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4938 | MDIO_PMA_DEVAD, |
| 4939 | MDIO_PMA_REG_ROM_VER2, |
| 4940 | (rom_ver2_val & 0xff00) | (edc_mode & 0x00ff)); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4941 | |
| 4942 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4943 | MDIO_PMA_DEVAD, |
| 4944 | MDIO_PMA_REG_PHY_IDENTIFIER, |
| 4945 | (phy_identifier | (1<<9))); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4946 | |
| 4947 | return 0; |
| 4948 | } |
| 4949 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 4950 | static void bnx2x_8727_specific_func(struct bnx2x_phy *phy, |
| 4951 | struct link_params *params, |
| 4952 | u32 action) |
| 4953 | { |
| 4954 | struct bnx2x *bp = params->bp; |
| 4955 | |
| 4956 | switch (action) { |
| 4957 | case DISABLE_TX: |
| 4958 | bnx2x_sfp_set_transmitter(bp, phy, params->port, 0); |
| 4959 | break; |
| 4960 | case ENABLE_TX: |
| 4961 | if (!(phy->flags & FLAGS_SFP_NOT_APPROVED)) |
| 4962 | bnx2x_sfp_set_transmitter(bp, phy, params->port, 1); |
| 4963 | break; |
| 4964 | default: |
| 4965 | DP(NETIF_MSG_LINK, "Function 0x%x not supported by 8727\n", |
| 4966 | action); |
| 4967 | return; |
| 4968 | } |
| 4969 | } |
| 4970 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4971 | static u8 bnx2x_sfp_module_detection(struct bnx2x_phy *phy, |
| 4972 | struct link_params *params) |
| 4973 | { |
| 4974 | struct bnx2x *bp = params->bp; |
| 4975 | u16 edc_mode; |
| 4976 | u8 rc = 0; |
| 4977 | |
| 4978 | u32 val = REG_RD(bp, params->shmem_base + |
| 4979 | offsetof(struct shmem_region, dev_info. |
| 4980 | port_feature_config[params->port].config)); |
| 4981 | |
| 4982 | DP(NETIF_MSG_LINK, "SFP+ module plugged in/out detected on port %d\n", |
| 4983 | params->port); |
| 4984 | |
| 4985 | if (bnx2x_get_edc_mode(phy, params, &edc_mode) != 0) { |
| 4986 | DP(NETIF_MSG_LINK, "Failed to get valid module type\n"); |
| 4987 | return -EINVAL; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4988 | } else if (bnx2x_verify_sfp_module(phy, params) != 0) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4989 | /* check SFP+ module compatibility */ |
| 4990 | DP(NETIF_MSG_LINK, "Module verification failed!!\n"); |
| 4991 | rc = -EINVAL; |
| 4992 | /* Turn on fault module-detected led */ |
| 4993 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_0, |
| 4994 | MISC_REGISTERS_GPIO_HIGH, |
| 4995 | params->port); |
| 4996 | if ((phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727) && |
| 4997 | ((val & PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK) == |
| 4998 | PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_POWER_DOWN)) { |
| 4999 | /* Shutdown SFP+ module */ |
| 5000 | DP(NETIF_MSG_LINK, "Shutdown SFP+ module!!\n"); |
| 5001 | bnx2x_8727_power_module(bp, phy, 0); |
| 5002 | return rc; |
| 5003 | } |
| 5004 | } else { |
| 5005 | /* Turn off fault module-detected led */ |
| 5006 | DP(NETIF_MSG_LINK, "Turn off fault module-detected led\n"); |
| 5007 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_0, |
| 5008 | MISC_REGISTERS_GPIO_LOW, |
| 5009 | params->port); |
| 5010 | } |
| 5011 | |
| 5012 | /* power up the SFP module */ |
| 5013 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727) |
| 5014 | bnx2x_8727_power_module(bp, phy, 1); |
| 5015 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5016 | /* |
| 5017 | * Check and set limiting mode / LRM mode on 8726. On 8727 it |
| 5018 | * is done automatically |
| 5019 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5020 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726) |
| 5021 | bnx2x_8726_set_limiting_mode(bp, phy, edc_mode); |
| 5022 | else |
| 5023 | bnx2x_8727_set_limiting_mode(bp, phy, edc_mode); |
| 5024 | /* |
| 5025 | * Enable transmit for this module if the module is approved, or |
| 5026 | * if unapproved modules should also enable the Tx laser |
| 5027 | */ |
| 5028 | if (rc == 0 || |
| 5029 | (val & PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK) != |
| 5030 | PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_DISABLE_TX_LASER) |
| 5031 | bnx2x_sfp_set_transmitter(bp, phy, params->port, 1); |
| 5032 | else |
| 5033 | bnx2x_sfp_set_transmitter(bp, phy, params->port, 0); |
| 5034 | |
| 5035 | return rc; |
| 5036 | } |
| 5037 | |
| 5038 | void bnx2x_handle_module_detect_int(struct link_params *params) |
| 5039 | { |
| 5040 | struct bnx2x *bp = params->bp; |
| 5041 | struct bnx2x_phy *phy = ¶ms->phy[EXT_PHY1]; |
| 5042 | u32 gpio_val; |
| 5043 | u8 port = params->port; |
| 5044 | |
| 5045 | /* Set valid module led off */ |
| 5046 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_0, |
| 5047 | MISC_REGISTERS_GPIO_HIGH, |
| 5048 | params->port); |
| 5049 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5050 | /* Get current gpio val reflecting module plugged in / out*/ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5051 | gpio_val = bnx2x_get_gpio(bp, MISC_REGISTERS_GPIO_3, port); |
| 5052 | |
| 5053 | /* Call the handling function in case module is detected */ |
| 5054 | if (gpio_val == 0) { |
| 5055 | |
| 5056 | bnx2x_set_gpio_int(bp, MISC_REGISTERS_GPIO_3, |
| 5057 | MISC_REGISTERS_GPIO_INT_OUTPUT_CLR, |
| 5058 | port); |
| 5059 | |
| 5060 | if (bnx2x_wait_for_sfp_module_initialized(phy, params) == 0) |
| 5061 | bnx2x_sfp_module_detection(phy, params); |
| 5062 | else |
| 5063 | DP(NETIF_MSG_LINK, "SFP+ module is not initialized\n"); |
| 5064 | } else { |
| 5065 | u32 val = REG_RD(bp, params->shmem_base + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5066 | offsetof(struct shmem_region, dev_info. |
| 5067 | port_feature_config[params->port]. |
| 5068 | config)); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5069 | |
| 5070 | bnx2x_set_gpio_int(bp, MISC_REGISTERS_GPIO_3, |
| 5071 | MISC_REGISTERS_GPIO_INT_OUTPUT_SET, |
| 5072 | port); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5073 | /* |
| 5074 | * Module was plugged out. |
| 5075 | * Disable transmit for this module |
| 5076 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5077 | if ((val & PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK) == |
| 5078 | PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_DISABLE_TX_LASER) |
| 5079 | bnx2x_sfp_set_transmitter(bp, phy, params->port, 0); |
| 5080 | } |
| 5081 | } |
| 5082 | |
| 5083 | /******************************************************************/ |
| 5084 | /* common BCM8706/BCM8726 PHY SECTION */ |
| 5085 | /******************************************************************/ |
| 5086 | static u8 bnx2x_8706_8726_read_status(struct bnx2x_phy *phy, |
| 5087 | struct link_params *params, |
| 5088 | struct link_vars *vars) |
| 5089 | { |
| 5090 | u8 link_up = 0; |
| 5091 | u16 val1, val2, rx_sd, pcs_status; |
| 5092 | struct bnx2x *bp = params->bp; |
| 5093 | DP(NETIF_MSG_LINK, "XGXS 8706/8726\n"); |
| 5094 | /* Clear RX Alarm*/ |
| 5095 | bnx2x_cl45_read(bp, phy, |
| 5096 | MDIO_PMA_DEVAD, MDIO_PMA_REG_RX_ALARM, &val2); |
| 5097 | /* clear LASI indication*/ |
| 5098 | bnx2x_cl45_read(bp, phy, |
| 5099 | MDIO_PMA_DEVAD, MDIO_PMA_REG_LASI_STATUS, &val1); |
| 5100 | bnx2x_cl45_read(bp, phy, |
| 5101 | MDIO_PMA_DEVAD, MDIO_PMA_REG_LASI_STATUS, &val2); |
| 5102 | DP(NETIF_MSG_LINK, "8706/8726 LASI status 0x%x--> 0x%x\n", val1, val2); |
| 5103 | |
| 5104 | bnx2x_cl45_read(bp, phy, |
| 5105 | MDIO_PMA_DEVAD, MDIO_PMA_REG_RX_SD, &rx_sd); |
| 5106 | bnx2x_cl45_read(bp, phy, |
| 5107 | MDIO_PCS_DEVAD, MDIO_PCS_REG_STATUS, &pcs_status); |
| 5108 | bnx2x_cl45_read(bp, phy, |
| 5109 | MDIO_AN_DEVAD, MDIO_AN_REG_LINK_STATUS, &val2); |
| 5110 | bnx2x_cl45_read(bp, phy, |
| 5111 | MDIO_AN_DEVAD, MDIO_AN_REG_LINK_STATUS, &val2); |
| 5112 | |
| 5113 | DP(NETIF_MSG_LINK, "8706/8726 rx_sd 0x%x pcs_status 0x%x 1Gbps" |
| 5114 | " link_status 0x%x\n", rx_sd, pcs_status, val2); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5115 | /* |
| 5116 | * link is up if both bit 0 of pmd_rx_sd and bit 0 of pcs_status |
| 5117 | * are set, or if the autoneg bit 1 is set |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5118 | */ |
| 5119 | link_up = ((rx_sd & pcs_status & 0x1) || (val2 & (1<<1))); |
| 5120 | if (link_up) { |
| 5121 | if (val2 & (1<<1)) |
| 5122 | vars->line_speed = SPEED_1000; |
| 5123 | else |
| 5124 | vars->line_speed = SPEED_10000; |
| 5125 | bnx2x_ext_phy_resolve_fc(phy, params, vars); |
Yaniv Rosner | 791f18c | 2011-01-18 04:33:42 +0000 | [diff] [blame] | 5126 | vars->duplex = DUPLEX_FULL; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5127 | } |
| 5128 | return link_up; |
| 5129 | } |
| 5130 | |
| 5131 | /******************************************************************/ |
| 5132 | /* BCM8706 PHY SECTION */ |
| 5133 | /******************************************************************/ |
| 5134 | static u8 bnx2x_8706_config_init(struct bnx2x_phy *phy, |
| 5135 | struct link_params *params, |
| 5136 | struct link_vars *vars) |
| 5137 | { |
| 5138 | u16 cnt, val; |
| 5139 | struct bnx2x *bp = params->bp; |
| 5140 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5141 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, params->port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5142 | /* HW reset */ |
| 5143 | bnx2x_ext_phy_hw_reset(bp, params->port); |
| 5144 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 0xa040); |
| 5145 | bnx2x_wait_reset_complete(bp, phy); |
| 5146 | |
| 5147 | /* Wait until fw is loaded */ |
| 5148 | for (cnt = 0; cnt < 100; cnt++) { |
| 5149 | bnx2x_cl45_read(bp, phy, |
| 5150 | MDIO_PMA_DEVAD, MDIO_PMA_REG_ROM_VER1, &val); |
| 5151 | if (val) |
| 5152 | break; |
| 5153 | msleep(10); |
| 5154 | } |
| 5155 | DP(NETIF_MSG_LINK, "XGXS 8706 is initialized after %d ms\n", cnt); |
| 5156 | if ((params->feature_config_flags & |
| 5157 | FEATURE_CONFIG_OVERRIDE_PREEMPHASIS_ENABLED)) { |
| 5158 | u8 i; |
| 5159 | u16 reg; |
| 5160 | for (i = 0; i < 4; i++) { |
| 5161 | reg = MDIO_XS_8706_REG_BANK_RX0 + |
| 5162 | i*(MDIO_XS_8706_REG_BANK_RX1 - |
| 5163 | MDIO_XS_8706_REG_BANK_RX0); |
| 5164 | bnx2x_cl45_read(bp, phy, MDIO_XS_DEVAD, reg, &val); |
| 5165 | /* Clear first 3 bits of the control */ |
| 5166 | val &= ~0x7; |
| 5167 | /* Set control bits according to configuration */ |
| 5168 | val |= (phy->rx_preemphasis[i] & 0x7); |
| 5169 | DP(NETIF_MSG_LINK, "Setting RX Equalizer to BCM8706" |
| 5170 | " reg 0x%x <-- val 0x%x\n", reg, val); |
| 5171 | bnx2x_cl45_write(bp, phy, MDIO_XS_DEVAD, reg, val); |
| 5172 | } |
| 5173 | } |
| 5174 | /* Force speed */ |
| 5175 | if (phy->req_line_speed == SPEED_10000) { |
| 5176 | DP(NETIF_MSG_LINK, "XGXS 8706 force 10Gbps\n"); |
| 5177 | |
| 5178 | bnx2x_cl45_write(bp, phy, |
| 5179 | MDIO_PMA_DEVAD, |
| 5180 | MDIO_PMA_REG_DIGITAL_CTRL, 0x400); |
| 5181 | bnx2x_cl45_write(bp, phy, |
| 5182 | MDIO_PMA_DEVAD, MDIO_PMA_REG_LASI_CTRL, 1); |
| 5183 | } else { |
| 5184 | /* Force 1Gbps using autoneg with 1G advertisment */ |
| 5185 | |
| 5186 | /* Allow CL37 through CL73 */ |
| 5187 | DP(NETIF_MSG_LINK, "XGXS 8706 AutoNeg\n"); |
| 5188 | bnx2x_cl45_write(bp, phy, |
| 5189 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_CL73, 0x040c); |
| 5190 | |
| 5191 | /* Enable Full-Duplex advertisment on CL37 */ |
| 5192 | bnx2x_cl45_write(bp, phy, |
| 5193 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_FC_LP, 0x0020); |
| 5194 | /* Enable CL37 AN */ |
| 5195 | bnx2x_cl45_write(bp, phy, |
| 5196 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_AN, 0x1000); |
| 5197 | /* 1G support */ |
| 5198 | bnx2x_cl45_write(bp, phy, |
| 5199 | MDIO_AN_DEVAD, MDIO_AN_REG_ADV, (1<<5)); |
| 5200 | |
| 5201 | /* Enable clause 73 AN */ |
| 5202 | bnx2x_cl45_write(bp, phy, |
| 5203 | MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, 0x1200); |
| 5204 | bnx2x_cl45_write(bp, phy, |
| 5205 | MDIO_PMA_DEVAD, MDIO_PMA_REG_RX_ALARM_CTRL, |
| 5206 | 0x0400); |
| 5207 | bnx2x_cl45_write(bp, phy, |
| 5208 | MDIO_PMA_DEVAD, MDIO_PMA_REG_LASI_CTRL, |
| 5209 | 0x0004); |
| 5210 | } |
| 5211 | bnx2x_save_bcm_spirom_ver(bp, phy, params->port); |
| 5212 | return 0; |
| 5213 | } |
| 5214 | |
| 5215 | static u8 bnx2x_8706_read_status(struct bnx2x_phy *phy, |
| 5216 | struct link_params *params, |
| 5217 | struct link_vars *vars) |
| 5218 | { |
| 5219 | return bnx2x_8706_8726_read_status(phy, params, vars); |
| 5220 | } |
| 5221 | |
| 5222 | /******************************************************************/ |
| 5223 | /* BCM8726 PHY SECTION */ |
| 5224 | /******************************************************************/ |
| 5225 | static void bnx2x_8726_config_loopback(struct bnx2x_phy *phy, |
| 5226 | struct link_params *params) |
| 5227 | { |
| 5228 | struct bnx2x *bp = params->bp; |
| 5229 | DP(NETIF_MSG_LINK, "PMA/PMD ext_phy_loopback: 8726\n"); |
| 5230 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 0x0001); |
| 5231 | } |
| 5232 | |
| 5233 | static void bnx2x_8726_external_rom_boot(struct bnx2x_phy *phy, |
| 5234 | struct link_params *params) |
| 5235 | { |
| 5236 | struct bnx2x *bp = params->bp; |
| 5237 | /* Need to wait 100ms after reset */ |
| 5238 | msleep(100); |
| 5239 | |
| 5240 | /* Micro controller re-boot */ |
| 5241 | bnx2x_cl45_write(bp, phy, |
| 5242 | MDIO_PMA_DEVAD, MDIO_PMA_REG_GEN_CTRL, 0x018B); |
| 5243 | |
| 5244 | /* Set soft reset */ |
| 5245 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5246 | MDIO_PMA_DEVAD, |
| 5247 | MDIO_PMA_REG_GEN_CTRL, |
| 5248 | MDIO_PMA_REG_GEN_CTRL_ROM_MICRO_RESET); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5249 | |
| 5250 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5251 | MDIO_PMA_DEVAD, |
| 5252 | MDIO_PMA_REG_MISC_CTRL1, 0x0001); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5253 | |
| 5254 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5255 | MDIO_PMA_DEVAD, |
| 5256 | MDIO_PMA_REG_GEN_CTRL, |
| 5257 | MDIO_PMA_REG_GEN_CTRL_ROM_RESET_INTERNAL_MP); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5258 | |
| 5259 | /* wait for 150ms for microcode load */ |
| 5260 | msleep(150); |
| 5261 | |
| 5262 | /* Disable serial boot control, tristates pins SS_N, SCK, MOSI, MISO */ |
| 5263 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5264 | MDIO_PMA_DEVAD, |
| 5265 | MDIO_PMA_REG_MISC_CTRL1, 0x0000); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5266 | |
| 5267 | msleep(200); |
| 5268 | bnx2x_save_bcm_spirom_ver(bp, phy, params->port); |
| 5269 | } |
| 5270 | |
| 5271 | static u8 bnx2x_8726_read_status(struct bnx2x_phy *phy, |
| 5272 | struct link_params *params, |
| 5273 | struct link_vars *vars) |
| 5274 | { |
| 5275 | struct bnx2x *bp = params->bp; |
| 5276 | u16 val1; |
| 5277 | u8 link_up = bnx2x_8706_8726_read_status(phy, params, vars); |
| 5278 | if (link_up) { |
| 5279 | bnx2x_cl45_read(bp, phy, |
| 5280 | MDIO_PMA_DEVAD, MDIO_PMA_REG_PHY_IDENTIFIER, |
| 5281 | &val1); |
| 5282 | if (val1 & (1<<15)) { |
| 5283 | DP(NETIF_MSG_LINK, "Tx is disabled\n"); |
| 5284 | link_up = 0; |
| 5285 | vars->line_speed = 0; |
| 5286 | } |
| 5287 | } |
| 5288 | return link_up; |
| 5289 | } |
| 5290 | |
| 5291 | |
| 5292 | static u8 bnx2x_8726_config_init(struct bnx2x_phy *phy, |
| 5293 | struct link_params *params, |
| 5294 | struct link_vars *vars) |
| 5295 | { |
| 5296 | struct bnx2x *bp = params->bp; |
| 5297 | u32 val; |
| 5298 | u32 swap_val, swap_override, aeu_gpio_mask, offset; |
| 5299 | DP(NETIF_MSG_LINK, "Initializing BCM8726\n"); |
| 5300 | /* Restore normal power mode*/ |
| 5301 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
| 5302 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, params->port); |
| 5303 | |
| 5304 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_1, |
| 5305 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, params->port); |
| 5306 | |
| 5307 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 1<<15); |
| 5308 | bnx2x_wait_reset_complete(bp, phy); |
| 5309 | |
| 5310 | bnx2x_8726_external_rom_boot(phy, params); |
| 5311 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5312 | /* |
| 5313 | * Need to call module detected on initialization since the module |
| 5314 | * detection triggered by actual module insertion might occur before |
| 5315 | * driver is loaded, and when driver is loaded, it reset all |
| 5316 | * registers, including the transmitter |
| 5317 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5318 | bnx2x_sfp_module_detection(phy, params); |
| 5319 | |
| 5320 | if (phy->req_line_speed == SPEED_1000) { |
| 5321 | DP(NETIF_MSG_LINK, "Setting 1G force\n"); |
| 5322 | bnx2x_cl45_write(bp, phy, |
| 5323 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 0x40); |
| 5324 | bnx2x_cl45_write(bp, phy, |
| 5325 | MDIO_PMA_DEVAD, MDIO_PMA_REG_10G_CTRL2, 0xD); |
| 5326 | bnx2x_cl45_write(bp, phy, |
| 5327 | MDIO_PMA_DEVAD, MDIO_PMA_REG_LASI_CTRL, 0x5); |
| 5328 | bnx2x_cl45_write(bp, phy, |
| 5329 | MDIO_PMA_DEVAD, MDIO_PMA_REG_RX_ALARM_CTRL, |
| 5330 | 0x400); |
| 5331 | } else if ((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 5332 | (phy->speed_cap_mask & |
| 5333 | PORT_HW_CFG_SPEED_CAPABILITY_D0_1G) && |
| 5334 | ((phy->speed_cap_mask & |
| 5335 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G) != |
| 5336 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G)) { |
| 5337 | DP(NETIF_MSG_LINK, "Setting 1G clause37\n"); |
| 5338 | /* Set Flow control */ |
| 5339 | bnx2x_ext_phy_set_pause(params, phy, vars); |
| 5340 | bnx2x_cl45_write(bp, phy, |
| 5341 | MDIO_AN_DEVAD, MDIO_AN_REG_ADV, 0x20); |
| 5342 | bnx2x_cl45_write(bp, phy, |
| 5343 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_CL73, 0x040c); |
| 5344 | bnx2x_cl45_write(bp, phy, |
| 5345 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_FC_LD, 0x0020); |
| 5346 | bnx2x_cl45_write(bp, phy, |
| 5347 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_AN, 0x1000); |
| 5348 | bnx2x_cl45_write(bp, phy, |
| 5349 | MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, 0x1200); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5350 | /* |
| 5351 | * Enable RX-ALARM control to receive interrupt for 1G speed |
| 5352 | * change |
| 5353 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5354 | bnx2x_cl45_write(bp, phy, |
| 5355 | MDIO_PMA_DEVAD, MDIO_PMA_REG_LASI_CTRL, 0x4); |
| 5356 | bnx2x_cl45_write(bp, phy, |
| 5357 | MDIO_PMA_DEVAD, MDIO_PMA_REG_RX_ALARM_CTRL, |
| 5358 | 0x400); |
| 5359 | |
| 5360 | } else { /* Default 10G. Set only LASI control */ |
| 5361 | bnx2x_cl45_write(bp, phy, |
| 5362 | MDIO_PMA_DEVAD, MDIO_PMA_REG_LASI_CTRL, 1); |
| 5363 | } |
| 5364 | |
| 5365 | /* Set TX PreEmphasis if needed */ |
| 5366 | if ((params->feature_config_flags & |
| 5367 | FEATURE_CONFIG_OVERRIDE_PREEMPHASIS_ENABLED)) { |
| 5368 | DP(NETIF_MSG_LINK, "Setting TX_CTRL1 0x%x," |
| 5369 | "TX_CTRL2 0x%x\n", |
| 5370 | phy->tx_preemphasis[0], |
| 5371 | phy->tx_preemphasis[1]); |
| 5372 | bnx2x_cl45_write(bp, phy, |
| 5373 | MDIO_PMA_DEVAD, |
| 5374 | MDIO_PMA_REG_8726_TX_CTRL1, |
| 5375 | phy->tx_preemphasis[0]); |
| 5376 | |
| 5377 | bnx2x_cl45_write(bp, phy, |
| 5378 | MDIO_PMA_DEVAD, |
| 5379 | MDIO_PMA_REG_8726_TX_CTRL2, |
| 5380 | phy->tx_preemphasis[1]); |
| 5381 | } |
| 5382 | |
| 5383 | /* Set GPIO3 to trigger SFP+ module insertion/removal */ |
| 5384 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_3, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5385 | MISC_REGISTERS_GPIO_INPUT_HI_Z, params->port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5386 | |
| 5387 | /* The GPIO should be swapped if the swap register is set and active */ |
| 5388 | swap_val = REG_RD(bp, NIG_REG_PORT_SWAP); |
| 5389 | swap_override = REG_RD(bp, NIG_REG_STRAP_OVERRIDE); |
| 5390 | |
| 5391 | /* Select function upon port-swap configuration */ |
| 5392 | if (params->port == 0) { |
| 5393 | offset = MISC_REG_AEU_ENABLE1_FUNC_0_OUT_0; |
| 5394 | aeu_gpio_mask = (swap_val && swap_override) ? |
| 5395 | AEU_INPUTS_ATTN_BITS_GPIO3_FUNCTION_1 : |
| 5396 | AEU_INPUTS_ATTN_BITS_GPIO3_FUNCTION_0; |
| 5397 | } else { |
| 5398 | offset = MISC_REG_AEU_ENABLE1_FUNC_1_OUT_0; |
| 5399 | aeu_gpio_mask = (swap_val && swap_override) ? |
| 5400 | AEU_INPUTS_ATTN_BITS_GPIO3_FUNCTION_0 : |
| 5401 | AEU_INPUTS_ATTN_BITS_GPIO3_FUNCTION_1; |
| 5402 | } |
| 5403 | val = REG_RD(bp, offset); |
| 5404 | /* add GPIO3 to group */ |
| 5405 | val |= aeu_gpio_mask; |
| 5406 | REG_WR(bp, offset, val); |
| 5407 | return 0; |
| 5408 | |
| 5409 | } |
| 5410 | |
| 5411 | static void bnx2x_8726_link_reset(struct bnx2x_phy *phy, |
| 5412 | struct link_params *params) |
| 5413 | { |
| 5414 | struct bnx2x *bp = params->bp; |
| 5415 | DP(NETIF_MSG_LINK, "bnx2x_8726_link_reset port %d\n", params->port); |
| 5416 | /* Set serial boot control for external load */ |
| 5417 | bnx2x_cl45_write(bp, phy, |
| 5418 | MDIO_PMA_DEVAD, |
| 5419 | MDIO_PMA_REG_GEN_CTRL, 0x0001); |
| 5420 | } |
| 5421 | |
| 5422 | /******************************************************************/ |
| 5423 | /* BCM8727 PHY SECTION */ |
| 5424 | /******************************************************************/ |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 5425 | |
| 5426 | static void bnx2x_8727_set_link_led(struct bnx2x_phy *phy, |
| 5427 | struct link_params *params, u8 mode) |
| 5428 | { |
| 5429 | struct bnx2x *bp = params->bp; |
| 5430 | u16 led_mode_bitmask = 0; |
| 5431 | u16 gpio_pins_bitmask = 0; |
| 5432 | u16 val; |
| 5433 | /* Only NOC flavor requires to set the LED specifically */ |
| 5434 | if (!(phy->flags & FLAGS_NOC)) |
| 5435 | return; |
| 5436 | switch (mode) { |
| 5437 | case LED_MODE_FRONT_PANEL_OFF: |
| 5438 | case LED_MODE_OFF: |
| 5439 | led_mode_bitmask = 0; |
| 5440 | gpio_pins_bitmask = 0x03; |
| 5441 | break; |
| 5442 | case LED_MODE_ON: |
| 5443 | led_mode_bitmask = 0; |
| 5444 | gpio_pins_bitmask = 0x02; |
| 5445 | break; |
| 5446 | case LED_MODE_OPER: |
| 5447 | led_mode_bitmask = 0x60; |
| 5448 | gpio_pins_bitmask = 0x11; |
| 5449 | break; |
| 5450 | } |
| 5451 | bnx2x_cl45_read(bp, phy, |
| 5452 | MDIO_PMA_DEVAD, |
| 5453 | MDIO_PMA_REG_8727_PCS_OPT_CTRL, |
| 5454 | &val); |
| 5455 | val &= 0xff8f; |
| 5456 | val |= led_mode_bitmask; |
| 5457 | bnx2x_cl45_write(bp, phy, |
| 5458 | MDIO_PMA_DEVAD, |
| 5459 | MDIO_PMA_REG_8727_PCS_OPT_CTRL, |
| 5460 | val); |
| 5461 | bnx2x_cl45_read(bp, phy, |
| 5462 | MDIO_PMA_DEVAD, |
| 5463 | MDIO_PMA_REG_8727_GPIO_CTRL, |
| 5464 | &val); |
| 5465 | val &= 0xffe0; |
| 5466 | val |= gpio_pins_bitmask; |
| 5467 | bnx2x_cl45_write(bp, phy, |
| 5468 | MDIO_PMA_DEVAD, |
| 5469 | MDIO_PMA_REG_8727_GPIO_CTRL, |
| 5470 | val); |
| 5471 | } |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 5472 | static void bnx2x_8727_hw_reset(struct bnx2x_phy *phy, |
| 5473 | struct link_params *params) { |
| 5474 | u32 swap_val, swap_override; |
| 5475 | u8 port; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5476 | /* |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 5477 | * The PHY reset is controlled by GPIO 1. Fake the port number |
| 5478 | * to cancel the swap done in set_gpio() |
| 5479 | */ |
| 5480 | struct bnx2x *bp = params->bp; |
| 5481 | swap_val = REG_RD(bp, NIG_REG_PORT_SWAP); |
| 5482 | swap_override = REG_RD(bp, NIG_REG_STRAP_OVERRIDE); |
| 5483 | port = (swap_val && swap_override) ^ 1; |
| 5484 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5485 | MISC_REGISTERS_GPIO_OUTPUT_LOW, port); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 5486 | } |
| 5487 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5488 | static u8 bnx2x_8727_config_init(struct bnx2x_phy *phy, |
| 5489 | struct link_params *params, |
| 5490 | struct link_vars *vars) |
| 5491 | { |
| 5492 | u16 tmp1, val, mod_abs; |
| 5493 | u16 rx_alarm_ctrl_val; |
| 5494 | u16 lasi_ctrl_val; |
| 5495 | struct bnx2x *bp = params->bp; |
| 5496 | /* Enable PMD link, MOD_ABS_FLT, and 1G link alarm */ |
| 5497 | |
| 5498 | bnx2x_wait_reset_complete(bp, phy); |
| 5499 | rx_alarm_ctrl_val = (1<<2) | (1<<5) ; |
| 5500 | lasi_ctrl_val = 0x0004; |
| 5501 | |
| 5502 | DP(NETIF_MSG_LINK, "Initializing BCM8727\n"); |
| 5503 | /* enable LASI */ |
| 5504 | bnx2x_cl45_write(bp, phy, |
| 5505 | MDIO_PMA_DEVAD, MDIO_PMA_REG_RX_ALARM_CTRL, |
| 5506 | rx_alarm_ctrl_val); |
| 5507 | |
| 5508 | bnx2x_cl45_write(bp, phy, |
| 5509 | MDIO_PMA_DEVAD, MDIO_PMA_REG_LASI_CTRL, lasi_ctrl_val); |
| 5510 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5511 | /* |
| 5512 | * Initially configure MOD_ABS to interrupt when module is |
| 5513 | * presence( bit 8) |
| 5514 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5515 | bnx2x_cl45_read(bp, phy, |
| 5516 | MDIO_PMA_DEVAD, MDIO_PMA_REG_PHY_IDENTIFIER, &mod_abs); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5517 | /* |
| 5518 | * Set EDC off by setting OPTXLOS signal input to low (bit 9). |
| 5519 | * When the EDC is off it locks onto a reference clock and avoids |
| 5520 | * becoming 'lost' |
| 5521 | */ |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 5522 | mod_abs &= ~(1<<8); |
| 5523 | if (!(phy->flags & FLAGS_NOC)) |
| 5524 | mod_abs &= ~(1<<9); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5525 | bnx2x_cl45_write(bp, phy, |
| 5526 | MDIO_PMA_DEVAD, MDIO_PMA_REG_PHY_IDENTIFIER, mod_abs); |
| 5527 | |
| 5528 | |
| 5529 | /* Make MOD_ABS give interrupt on change */ |
| 5530 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_PCS_OPT_CTRL, |
| 5531 | &val); |
| 5532 | val |= (1<<12); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 5533 | if (phy->flags & FLAGS_NOC) |
| 5534 | val |= (3<<5); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5535 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5536 | /* |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 5537 | * Set 8727 GPIOs to input to allow reading from the 8727 GPIO0 |
| 5538 | * status which reflect SFP+ module over-current |
| 5539 | */ |
| 5540 | if (!(phy->flags & FLAGS_NOC)) |
| 5541 | val &= 0xff8f; /* Reset bits 4-6 */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5542 | bnx2x_cl45_write(bp, phy, |
| 5543 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_PCS_OPT_CTRL, val); |
| 5544 | |
| 5545 | bnx2x_8727_power_module(bp, phy, 1); |
| 5546 | |
| 5547 | bnx2x_cl45_read(bp, phy, |
| 5548 | MDIO_PMA_DEVAD, MDIO_PMA_REG_M8051_MSGOUT_REG, &tmp1); |
| 5549 | |
| 5550 | bnx2x_cl45_read(bp, phy, |
| 5551 | MDIO_PMA_DEVAD, MDIO_PMA_REG_RX_ALARM, &tmp1); |
| 5552 | |
| 5553 | /* Set option 1G speed */ |
| 5554 | if (phy->req_line_speed == SPEED_1000) { |
| 5555 | DP(NETIF_MSG_LINK, "Setting 1G force\n"); |
| 5556 | bnx2x_cl45_write(bp, phy, |
| 5557 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 0x40); |
| 5558 | bnx2x_cl45_write(bp, phy, |
| 5559 | MDIO_PMA_DEVAD, MDIO_PMA_REG_10G_CTRL2, 0xD); |
| 5560 | bnx2x_cl45_read(bp, phy, |
| 5561 | MDIO_PMA_DEVAD, MDIO_PMA_REG_10G_CTRL2, &tmp1); |
| 5562 | DP(NETIF_MSG_LINK, "1.7 = 0x%x\n", tmp1); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5563 | /* |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5564 | * Power down the XAUI until link is up in case of dual-media |
| 5565 | * and 1G |
| 5566 | */ |
| 5567 | if (DUAL_MEDIA(params)) { |
| 5568 | bnx2x_cl45_read(bp, phy, |
| 5569 | MDIO_PMA_DEVAD, |
| 5570 | MDIO_PMA_REG_8727_PCS_GP, &val); |
| 5571 | val |= (3<<10); |
| 5572 | bnx2x_cl45_write(bp, phy, |
| 5573 | MDIO_PMA_DEVAD, |
| 5574 | MDIO_PMA_REG_8727_PCS_GP, val); |
| 5575 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5576 | } else if ((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 5577 | ((phy->speed_cap_mask & |
| 5578 | PORT_HW_CFG_SPEED_CAPABILITY_D0_1G)) && |
| 5579 | ((phy->speed_cap_mask & |
| 5580 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G) != |
| 5581 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G)) { |
| 5582 | |
| 5583 | DP(NETIF_MSG_LINK, "Setting 1G clause37\n"); |
| 5584 | bnx2x_cl45_write(bp, phy, |
| 5585 | MDIO_AN_DEVAD, MDIO_AN_REG_8727_MISC_CTRL, 0); |
| 5586 | bnx2x_cl45_write(bp, phy, |
| 5587 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_AN, 0x1300); |
| 5588 | } else { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5589 | /* |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5590 | * Since the 8727 has only single reset pin, need to set the 10G |
| 5591 | * registers although it is default |
| 5592 | */ |
| 5593 | bnx2x_cl45_write(bp, phy, |
| 5594 | MDIO_AN_DEVAD, MDIO_AN_REG_8727_MISC_CTRL, |
| 5595 | 0x0020); |
| 5596 | bnx2x_cl45_write(bp, phy, |
| 5597 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_AN, 0x0100); |
| 5598 | bnx2x_cl45_write(bp, phy, |
| 5599 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 0x2040); |
| 5600 | bnx2x_cl45_write(bp, phy, |
| 5601 | MDIO_PMA_DEVAD, MDIO_PMA_REG_10G_CTRL2, |
| 5602 | 0x0008); |
| 5603 | } |
| 5604 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5605 | /* |
| 5606 | * Set 2-wire transfer rate of SFP+ module EEPROM |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5607 | * to 100Khz since some DACs(direct attached cables) do |
| 5608 | * not work at 400Khz. |
| 5609 | */ |
| 5610 | bnx2x_cl45_write(bp, phy, |
| 5611 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_TWO_WIRE_SLAVE_ADDR, |
| 5612 | 0xa001); |
| 5613 | |
| 5614 | /* Set TX PreEmphasis if needed */ |
| 5615 | if ((params->feature_config_flags & |
| 5616 | FEATURE_CONFIG_OVERRIDE_PREEMPHASIS_ENABLED)) { |
| 5617 | DP(NETIF_MSG_LINK, "Setting TX_CTRL1 0x%x, TX_CTRL2 0x%x\n", |
| 5618 | phy->tx_preemphasis[0], |
| 5619 | phy->tx_preemphasis[1]); |
| 5620 | bnx2x_cl45_write(bp, phy, |
| 5621 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_TX_CTRL1, |
| 5622 | phy->tx_preemphasis[0]); |
| 5623 | |
| 5624 | bnx2x_cl45_write(bp, phy, |
| 5625 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_TX_CTRL2, |
| 5626 | phy->tx_preemphasis[1]); |
| 5627 | } |
| 5628 | |
| 5629 | return 0; |
| 5630 | } |
| 5631 | |
| 5632 | static void bnx2x_8727_handle_mod_abs(struct bnx2x_phy *phy, |
| 5633 | struct link_params *params) |
| 5634 | { |
| 5635 | struct bnx2x *bp = params->bp; |
| 5636 | u16 mod_abs, rx_alarm_status; |
| 5637 | u32 val = REG_RD(bp, params->shmem_base + |
| 5638 | offsetof(struct shmem_region, dev_info. |
| 5639 | port_feature_config[params->port]. |
| 5640 | config)); |
| 5641 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5642 | MDIO_PMA_DEVAD, |
| 5643 | MDIO_PMA_REG_PHY_IDENTIFIER, &mod_abs); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5644 | if (mod_abs & (1<<8)) { |
| 5645 | |
| 5646 | /* Module is absent */ |
| 5647 | DP(NETIF_MSG_LINK, "MOD_ABS indication " |
| 5648 | "show module is absent\n"); |
| 5649 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5650 | /* |
| 5651 | * 1. Set mod_abs to detect next module |
| 5652 | * presence event |
| 5653 | * 2. Set EDC off by setting OPTXLOS signal input to low |
| 5654 | * (bit 9). |
| 5655 | * When the EDC is off it locks onto a reference clock and |
| 5656 | * avoids becoming 'lost'. |
| 5657 | */ |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 5658 | mod_abs &= ~(1<<8); |
| 5659 | if (!(phy->flags & FLAGS_NOC)) |
| 5660 | mod_abs &= ~(1<<9); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5661 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5662 | MDIO_PMA_DEVAD, |
| 5663 | MDIO_PMA_REG_PHY_IDENTIFIER, mod_abs); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5664 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5665 | /* |
| 5666 | * Clear RX alarm since it stays up as long as |
| 5667 | * the mod_abs wasn't changed |
| 5668 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5669 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5670 | MDIO_PMA_DEVAD, |
| 5671 | MDIO_PMA_REG_RX_ALARM, &rx_alarm_status); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5672 | |
| 5673 | } else { |
| 5674 | /* Module is present */ |
| 5675 | DP(NETIF_MSG_LINK, "MOD_ABS indication " |
| 5676 | "show module is present\n"); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5677 | /* |
| 5678 | * First disable transmitter, and if the module is ok, the |
| 5679 | * module_detection will enable it |
| 5680 | * 1. Set mod_abs to detect next module absent event ( bit 8) |
| 5681 | * 2. Restore the default polarity of the OPRXLOS signal and |
| 5682 | * this signal will then correctly indicate the presence or |
| 5683 | * absence of the Rx signal. (bit 9) |
| 5684 | */ |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 5685 | mod_abs |= (1<<8); |
| 5686 | if (!(phy->flags & FLAGS_NOC)) |
| 5687 | mod_abs |= (1<<9); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5688 | bnx2x_cl45_write(bp, phy, |
| 5689 | MDIO_PMA_DEVAD, |
| 5690 | MDIO_PMA_REG_PHY_IDENTIFIER, mod_abs); |
| 5691 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5692 | /* |
| 5693 | * Clear RX alarm since it stays up as long as the mod_abs |
| 5694 | * wasn't changed. This is need to be done before calling the |
| 5695 | * module detection, otherwise it will clear* the link update |
| 5696 | * alarm |
| 5697 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5698 | bnx2x_cl45_read(bp, phy, |
| 5699 | MDIO_PMA_DEVAD, |
| 5700 | MDIO_PMA_REG_RX_ALARM, &rx_alarm_status); |
| 5701 | |
| 5702 | |
| 5703 | if ((val & PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK) == |
| 5704 | PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_DISABLE_TX_LASER) |
| 5705 | bnx2x_sfp_set_transmitter(bp, phy, params->port, 0); |
| 5706 | |
| 5707 | if (bnx2x_wait_for_sfp_module_initialized(phy, params) == 0) |
| 5708 | bnx2x_sfp_module_detection(phy, params); |
| 5709 | else |
| 5710 | DP(NETIF_MSG_LINK, "SFP+ module is not initialized\n"); |
| 5711 | } |
| 5712 | |
| 5713 | DP(NETIF_MSG_LINK, "8727 RX_ALARM_STATUS 0x%x\n", |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5714 | rx_alarm_status); |
| 5715 | /* 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] | 5716 | } |
| 5717 | |
| 5718 | static u8 bnx2x_8727_read_status(struct bnx2x_phy *phy, |
| 5719 | struct link_params *params, |
| 5720 | struct link_vars *vars) |
| 5721 | |
| 5722 | { |
| 5723 | struct bnx2x *bp = params->bp; |
| 5724 | u8 link_up = 0; |
| 5725 | u16 link_status = 0; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5726 | u16 rx_alarm_status, lasi_ctrl, val1; |
| 5727 | |
| 5728 | /* If PHY is not initialized, do not check link status */ |
| 5729 | bnx2x_cl45_read(bp, phy, |
| 5730 | MDIO_PMA_DEVAD, MDIO_PMA_REG_LASI_CTRL, |
| 5731 | &lasi_ctrl); |
| 5732 | if (!lasi_ctrl) |
| 5733 | return 0; |
| 5734 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5735 | /* Check the LASI */ |
| 5736 | bnx2x_cl45_read(bp, phy, |
| 5737 | MDIO_PMA_DEVAD, MDIO_PMA_REG_RX_ALARM, |
| 5738 | &rx_alarm_status); |
| 5739 | vars->line_speed = 0; |
| 5740 | DP(NETIF_MSG_LINK, "8727 RX_ALARM_STATUS 0x%x\n", rx_alarm_status); |
| 5741 | |
| 5742 | bnx2x_cl45_read(bp, phy, |
| 5743 | MDIO_PMA_DEVAD, MDIO_PMA_REG_LASI_STATUS, &val1); |
| 5744 | |
| 5745 | DP(NETIF_MSG_LINK, "8727 LASI status 0x%x\n", val1); |
| 5746 | |
| 5747 | /* Clear MSG-OUT */ |
| 5748 | bnx2x_cl45_read(bp, phy, |
| 5749 | MDIO_PMA_DEVAD, MDIO_PMA_REG_M8051_MSGOUT_REG, &val1); |
| 5750 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5751 | /* |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5752 | * If a module is present and there is need to check |
| 5753 | * for over current |
| 5754 | */ |
| 5755 | if (!(phy->flags & FLAGS_NOC) && !(rx_alarm_status & (1<<5))) { |
| 5756 | /* Check over-current using 8727 GPIO0 input*/ |
| 5757 | bnx2x_cl45_read(bp, phy, |
| 5758 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_GPIO_CTRL, |
| 5759 | &val1); |
| 5760 | |
| 5761 | if ((val1 & (1<<8)) == 0) { |
| 5762 | DP(NETIF_MSG_LINK, "8727 Power fault has been detected" |
| 5763 | " on port %d\n", params->port); |
| 5764 | netdev_err(bp->dev, "Error: Power fault on Port %d has" |
| 5765 | " been detected and the power to " |
| 5766 | "that SFP+ module has been removed" |
| 5767 | " to prevent failure of the card." |
| 5768 | " Please remove the SFP+ module and" |
| 5769 | " restart the system to clear this" |
| 5770 | " error.\n", |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5771 | params->port); |
| 5772 | /* Disable all RX_ALARMs except for mod_abs */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5773 | bnx2x_cl45_write(bp, phy, |
| 5774 | MDIO_PMA_DEVAD, |
| 5775 | MDIO_PMA_REG_RX_ALARM_CTRL, (1<<5)); |
| 5776 | |
| 5777 | bnx2x_cl45_read(bp, phy, |
| 5778 | MDIO_PMA_DEVAD, |
| 5779 | MDIO_PMA_REG_PHY_IDENTIFIER, &val1); |
| 5780 | /* Wait for module_absent_event */ |
| 5781 | val1 |= (1<<8); |
| 5782 | bnx2x_cl45_write(bp, phy, |
| 5783 | MDIO_PMA_DEVAD, |
| 5784 | MDIO_PMA_REG_PHY_IDENTIFIER, val1); |
| 5785 | /* Clear RX alarm */ |
| 5786 | bnx2x_cl45_read(bp, phy, |
| 5787 | MDIO_PMA_DEVAD, |
| 5788 | MDIO_PMA_REG_RX_ALARM, &rx_alarm_status); |
| 5789 | return 0; |
| 5790 | } |
| 5791 | } /* Over current check */ |
| 5792 | |
| 5793 | /* When module absent bit is set, check module */ |
| 5794 | if (rx_alarm_status & (1<<5)) { |
| 5795 | bnx2x_8727_handle_mod_abs(phy, params); |
| 5796 | /* Enable all mod_abs and link detection bits */ |
| 5797 | bnx2x_cl45_write(bp, phy, |
| 5798 | MDIO_PMA_DEVAD, MDIO_PMA_REG_RX_ALARM_CTRL, |
| 5799 | ((1<<5) | (1<<2))); |
| 5800 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5801 | DP(NETIF_MSG_LINK, "Enabling 8727 TX laser if SFP is approved\n"); |
| 5802 | bnx2x_8727_specific_func(phy, params, ENABLE_TX); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5803 | /* If transmitter is disabled, ignore false link up indication */ |
| 5804 | bnx2x_cl45_read(bp, phy, |
| 5805 | MDIO_PMA_DEVAD, MDIO_PMA_REG_PHY_IDENTIFIER, &val1); |
| 5806 | if (val1 & (1<<15)) { |
| 5807 | DP(NETIF_MSG_LINK, "Tx is disabled\n"); |
| 5808 | return 0; |
| 5809 | } |
| 5810 | |
| 5811 | bnx2x_cl45_read(bp, phy, |
| 5812 | MDIO_PMA_DEVAD, |
| 5813 | MDIO_PMA_REG_8073_SPEED_LINK_STATUS, &link_status); |
| 5814 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5815 | /* |
| 5816 | * Bits 0..2 --> speed detected, |
| 5817 | * Bits 13..15--> link is down |
| 5818 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5819 | if ((link_status & (1<<2)) && (!(link_status & (1<<15)))) { |
| 5820 | link_up = 1; |
| 5821 | vars->line_speed = SPEED_10000; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5822 | DP(NETIF_MSG_LINK, "port %x: External link up in 10G\n", |
| 5823 | params->port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5824 | } else if ((link_status & (1<<0)) && (!(link_status & (1<<13)))) { |
| 5825 | link_up = 1; |
| 5826 | vars->line_speed = SPEED_1000; |
| 5827 | DP(NETIF_MSG_LINK, "port %x: External link up in 1G\n", |
| 5828 | params->port); |
| 5829 | } else { |
| 5830 | link_up = 0; |
| 5831 | DP(NETIF_MSG_LINK, "port %x: External link is down\n", |
| 5832 | params->port); |
| 5833 | } |
Yaniv Rosner | 791f18c | 2011-01-18 04:33:42 +0000 | [diff] [blame] | 5834 | if (link_up) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5835 | bnx2x_ext_phy_resolve_fc(phy, params, vars); |
Yaniv Rosner | 791f18c | 2011-01-18 04:33:42 +0000 | [diff] [blame] | 5836 | vars->duplex = DUPLEX_FULL; |
| 5837 | DP(NETIF_MSG_LINK, "duplex = 0x%x\n", vars->duplex); |
| 5838 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5839 | |
| 5840 | if ((DUAL_MEDIA(params)) && |
| 5841 | (phy->req_line_speed == SPEED_1000)) { |
| 5842 | bnx2x_cl45_read(bp, phy, |
| 5843 | MDIO_PMA_DEVAD, |
| 5844 | MDIO_PMA_REG_8727_PCS_GP, &val1); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5845 | /* |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5846 | * In case of dual-media board and 1G, power up the XAUI side, |
| 5847 | * otherwise power it down. For 10G it is done automatically |
| 5848 | */ |
| 5849 | if (link_up) |
| 5850 | val1 &= ~(3<<10); |
| 5851 | else |
| 5852 | val1 |= (3<<10); |
| 5853 | bnx2x_cl45_write(bp, phy, |
| 5854 | MDIO_PMA_DEVAD, |
| 5855 | MDIO_PMA_REG_8727_PCS_GP, val1); |
| 5856 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5857 | return link_up; |
| 5858 | } |
| 5859 | |
| 5860 | static void bnx2x_8727_link_reset(struct bnx2x_phy *phy, |
| 5861 | struct link_params *params) |
| 5862 | { |
| 5863 | struct bnx2x *bp = params->bp; |
| 5864 | /* Disable Transmitter */ |
| 5865 | bnx2x_sfp_set_transmitter(bp, phy, params->port, 0); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5866 | /* Clear LASI */ |
| 5867 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, MDIO_PMA_REG_LASI_CTRL, 0); |
| 5868 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5869 | } |
| 5870 | |
| 5871 | /******************************************************************/ |
| 5872 | /* BCM8481/BCM84823/BCM84833 PHY SECTION */ |
| 5873 | /******************************************************************/ |
| 5874 | static void bnx2x_save_848xx_spirom_version(struct bnx2x_phy *phy, |
| 5875 | struct link_params *params) |
| 5876 | { |
| 5877 | u16 val, fw_ver1, fw_ver2, cnt; |
| 5878 | struct bnx2x *bp = params->bp; |
| 5879 | |
| 5880 | /* For the 32 bits registers in 848xx, access via MDIO2ARM interface.*/ |
| 5881 | /* (1) set register 0xc200_0014(SPI_BRIDGE_CTRL_2) to 0x03000000 */ |
| 5882 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA819, 0x0014); |
| 5883 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA81A, 0xc200); |
| 5884 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA81B, 0x0000); |
| 5885 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA81C, 0x0300); |
| 5886 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA817, 0x0009); |
| 5887 | |
| 5888 | for (cnt = 0; cnt < 100; cnt++) { |
| 5889 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, 0xA818, &val); |
| 5890 | if (val & 1) |
| 5891 | break; |
| 5892 | udelay(5); |
| 5893 | } |
| 5894 | if (cnt == 100) { |
| 5895 | DP(NETIF_MSG_LINK, "Unable to read 848xx phy fw version(1)\n"); |
| 5896 | bnx2x_save_spirom_version(bp, params->port, 0, |
| 5897 | phy->ver_addr); |
| 5898 | return; |
| 5899 | } |
| 5900 | |
| 5901 | |
| 5902 | /* 2) read register 0xc200_0000 (SPI_FW_STATUS) */ |
| 5903 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA819, 0x0000); |
| 5904 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA81A, 0xc200); |
| 5905 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA817, 0x000A); |
| 5906 | for (cnt = 0; cnt < 100; cnt++) { |
| 5907 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, 0xA818, &val); |
| 5908 | if (val & 1) |
| 5909 | break; |
| 5910 | udelay(5); |
| 5911 | } |
| 5912 | if (cnt == 100) { |
| 5913 | DP(NETIF_MSG_LINK, "Unable to read 848xx phy fw version(2)\n"); |
| 5914 | bnx2x_save_spirom_version(bp, params->port, 0, |
| 5915 | phy->ver_addr); |
| 5916 | return; |
| 5917 | } |
| 5918 | |
| 5919 | /* lower 16 bits of the register SPI_FW_STATUS */ |
| 5920 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, 0xA81B, &fw_ver1); |
| 5921 | /* upper 16 bits of register SPI_FW_STATUS */ |
| 5922 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, 0xA81C, &fw_ver2); |
| 5923 | |
| 5924 | bnx2x_save_spirom_version(bp, params->port, (fw_ver2<<16) | fw_ver1, |
| 5925 | phy->ver_addr); |
| 5926 | } |
| 5927 | |
| 5928 | static void bnx2x_848xx_set_led(struct bnx2x *bp, |
| 5929 | struct bnx2x_phy *phy) |
| 5930 | { |
| 5931 | u16 val; |
| 5932 | |
| 5933 | /* PHYC_CTL_LED_CTL */ |
| 5934 | bnx2x_cl45_read(bp, phy, |
| 5935 | MDIO_PMA_DEVAD, |
| 5936 | MDIO_PMA_REG_8481_LINK_SIGNAL, &val); |
| 5937 | val &= 0xFE00; |
| 5938 | val |= 0x0092; |
| 5939 | |
| 5940 | bnx2x_cl45_write(bp, phy, |
| 5941 | MDIO_PMA_DEVAD, |
| 5942 | MDIO_PMA_REG_8481_LINK_SIGNAL, val); |
| 5943 | |
| 5944 | bnx2x_cl45_write(bp, phy, |
| 5945 | MDIO_PMA_DEVAD, |
| 5946 | MDIO_PMA_REG_8481_LED1_MASK, |
| 5947 | 0x80); |
| 5948 | |
| 5949 | bnx2x_cl45_write(bp, phy, |
| 5950 | MDIO_PMA_DEVAD, |
| 5951 | MDIO_PMA_REG_8481_LED2_MASK, |
| 5952 | 0x18); |
| 5953 | |
Yaniv Rosner | f25b3c8 | 2011-01-18 04:33:47 +0000 | [diff] [blame] | 5954 | /* Select activity source by Tx and Rx, as suggested by PHY AE */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5955 | bnx2x_cl45_write(bp, phy, |
| 5956 | MDIO_PMA_DEVAD, |
| 5957 | MDIO_PMA_REG_8481_LED3_MASK, |
Yaniv Rosner | f25b3c8 | 2011-01-18 04:33:47 +0000 | [diff] [blame] | 5958 | 0x0006); |
| 5959 | |
| 5960 | /* Select the closest activity blink rate to that in 10/100/1000 */ |
| 5961 | bnx2x_cl45_write(bp, phy, |
| 5962 | MDIO_PMA_DEVAD, |
| 5963 | MDIO_PMA_REG_8481_LED3_BLINK, |
| 5964 | 0); |
| 5965 | |
| 5966 | bnx2x_cl45_read(bp, phy, |
| 5967 | MDIO_PMA_DEVAD, |
| 5968 | MDIO_PMA_REG_84823_CTL_LED_CTL_1, &val); |
| 5969 | val |= MDIO_PMA_REG_84823_LED3_STRETCH_EN; /* stretch_en for LED3*/ |
| 5970 | |
| 5971 | bnx2x_cl45_write(bp, phy, |
| 5972 | MDIO_PMA_DEVAD, |
| 5973 | MDIO_PMA_REG_84823_CTL_LED_CTL_1, val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5974 | |
| 5975 | /* 'Interrupt Mask' */ |
| 5976 | bnx2x_cl45_write(bp, phy, |
| 5977 | MDIO_AN_DEVAD, |
| 5978 | 0xFFFB, 0xFFFD); |
| 5979 | } |
| 5980 | |
| 5981 | static u8 bnx2x_848xx_cmn_config_init(struct bnx2x_phy *phy, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5982 | struct link_params *params, |
| 5983 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5984 | { |
| 5985 | struct bnx2x *bp = params->bp; |
| 5986 | u16 autoneg_val, an_1000_val, an_10_100_val; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5987 | /* |
| 5988 | * This phy uses the NIG latch mechanism since link indication |
| 5989 | * arrives through its LED4 and not via its LASI signal, so we |
| 5990 | * get steady signal instead of clear on read |
| 5991 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5992 | bnx2x_bits_en(bp, NIG_REG_LATCH_BC_0 + params->port*4, |
| 5993 | 1 << NIG_LATCH_BC_ENABLE_MI_INT); |
| 5994 | |
| 5995 | bnx2x_cl45_write(bp, phy, |
| 5996 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 0x0000); |
| 5997 | |
| 5998 | bnx2x_848xx_set_led(bp, phy); |
| 5999 | |
| 6000 | /* set 1000 speed advertisement */ |
| 6001 | bnx2x_cl45_read(bp, phy, |
| 6002 | MDIO_AN_DEVAD, MDIO_AN_REG_8481_1000T_CTRL, |
| 6003 | &an_1000_val); |
| 6004 | |
| 6005 | bnx2x_ext_phy_set_pause(params, phy, vars); |
| 6006 | bnx2x_cl45_read(bp, phy, |
| 6007 | MDIO_AN_DEVAD, |
| 6008 | MDIO_AN_REG_8481_LEGACY_AN_ADV, |
| 6009 | &an_10_100_val); |
| 6010 | bnx2x_cl45_read(bp, phy, |
| 6011 | MDIO_AN_DEVAD, MDIO_AN_REG_8481_LEGACY_MII_CTRL, |
| 6012 | &autoneg_val); |
| 6013 | /* Disable forced speed */ |
| 6014 | autoneg_val &= ~((1<<6) | (1<<8) | (1<<9) | (1<<12) | (1<<13)); |
| 6015 | an_10_100_val &= ~((1<<5) | (1<<6) | (1<<7) | (1<<8)); |
| 6016 | |
| 6017 | if (((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 6018 | (phy->speed_cap_mask & |
| 6019 | PORT_HW_CFG_SPEED_CAPABILITY_D0_1G)) || |
| 6020 | (phy->req_line_speed == SPEED_1000)) { |
| 6021 | an_1000_val |= (1<<8); |
| 6022 | autoneg_val |= (1<<9 | 1<<12); |
| 6023 | if (phy->req_duplex == DUPLEX_FULL) |
| 6024 | an_1000_val |= (1<<9); |
| 6025 | DP(NETIF_MSG_LINK, "Advertising 1G\n"); |
| 6026 | } else |
| 6027 | an_1000_val &= ~((1<<8) | (1<<9)); |
| 6028 | |
| 6029 | bnx2x_cl45_write(bp, phy, |
| 6030 | MDIO_AN_DEVAD, MDIO_AN_REG_8481_1000T_CTRL, |
| 6031 | an_1000_val); |
| 6032 | |
| 6033 | /* set 10 speed advertisement */ |
| 6034 | if (((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 6035 | (phy->speed_cap_mask & |
| 6036 | (PORT_HW_CFG_SPEED_CAPABILITY_D0_100M_FULL | |
| 6037 | PORT_HW_CFG_SPEED_CAPABILITY_D0_100M_HALF)))) { |
| 6038 | an_10_100_val |= (1<<7); |
| 6039 | /* Enable autoneg and restart autoneg for legacy speeds */ |
| 6040 | autoneg_val |= (1<<9 | 1<<12); |
| 6041 | |
| 6042 | if (phy->req_duplex == DUPLEX_FULL) |
| 6043 | an_10_100_val |= (1<<8); |
| 6044 | DP(NETIF_MSG_LINK, "Advertising 100M\n"); |
| 6045 | } |
| 6046 | /* set 10 speed advertisement */ |
| 6047 | if (((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 6048 | (phy->speed_cap_mask & |
| 6049 | (PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_FULL | |
| 6050 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_HALF)))) { |
| 6051 | an_10_100_val |= (1<<5); |
| 6052 | autoneg_val |= (1<<9 | 1<<12); |
| 6053 | if (phy->req_duplex == DUPLEX_FULL) |
| 6054 | an_10_100_val |= (1<<6); |
| 6055 | DP(NETIF_MSG_LINK, "Advertising 10M\n"); |
| 6056 | } |
| 6057 | |
| 6058 | /* Only 10/100 are allowed to work in FORCE mode */ |
| 6059 | if (phy->req_line_speed == SPEED_100) { |
| 6060 | autoneg_val |= (1<<13); |
| 6061 | /* Enabled AUTO-MDIX when autoneg is disabled */ |
| 6062 | bnx2x_cl45_write(bp, phy, |
| 6063 | MDIO_AN_DEVAD, MDIO_AN_REG_8481_AUX_CTRL, |
| 6064 | (1<<15 | 1<<9 | 7<<0)); |
| 6065 | DP(NETIF_MSG_LINK, "Setting 100M force\n"); |
| 6066 | } |
| 6067 | if (phy->req_line_speed == SPEED_10) { |
| 6068 | /* Enabled AUTO-MDIX when autoneg is disabled */ |
| 6069 | bnx2x_cl45_write(bp, phy, |
| 6070 | MDIO_AN_DEVAD, MDIO_AN_REG_8481_AUX_CTRL, |
| 6071 | (1<<15 | 1<<9 | 7<<0)); |
| 6072 | DP(NETIF_MSG_LINK, "Setting 10M force\n"); |
| 6073 | } |
| 6074 | |
| 6075 | bnx2x_cl45_write(bp, phy, |
| 6076 | MDIO_AN_DEVAD, MDIO_AN_REG_8481_LEGACY_AN_ADV, |
| 6077 | an_10_100_val); |
| 6078 | |
| 6079 | if (phy->req_duplex == DUPLEX_FULL) |
| 6080 | autoneg_val |= (1<<8); |
| 6081 | |
| 6082 | bnx2x_cl45_write(bp, phy, |
| 6083 | MDIO_AN_DEVAD, |
| 6084 | MDIO_AN_REG_8481_LEGACY_MII_CTRL, autoneg_val); |
| 6085 | |
| 6086 | if (((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 6087 | (phy->speed_cap_mask & |
| 6088 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G)) || |
| 6089 | (phy->req_line_speed == SPEED_10000)) { |
| 6090 | DP(NETIF_MSG_LINK, "Advertising 10G\n"); |
| 6091 | /* Restart autoneg for 10G*/ |
| 6092 | |
| 6093 | bnx2x_cl45_write(bp, phy, |
| 6094 | MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, |
| 6095 | 0x3200); |
| 6096 | } else if (phy->req_line_speed != SPEED_10 && |
| 6097 | phy->req_line_speed != SPEED_100) { |
| 6098 | bnx2x_cl45_write(bp, phy, |
| 6099 | MDIO_AN_DEVAD, |
| 6100 | MDIO_AN_REG_8481_10GBASE_T_AN_CTRL, |
| 6101 | 1); |
| 6102 | } |
| 6103 | /* Save spirom version */ |
| 6104 | bnx2x_save_848xx_spirom_version(phy, params); |
| 6105 | |
| 6106 | return 0; |
| 6107 | } |
| 6108 | |
| 6109 | static u8 bnx2x_8481_config_init(struct bnx2x_phy *phy, |
| 6110 | struct link_params *params, |
| 6111 | struct link_vars *vars) |
| 6112 | { |
| 6113 | struct bnx2x *bp = params->bp; |
| 6114 | /* Restore normal power mode*/ |
| 6115 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6116 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, params->port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6117 | |
| 6118 | /* HW reset */ |
| 6119 | bnx2x_ext_phy_hw_reset(bp, params->port); |
Yaniv Rosner | 9bffeac | 2010-11-01 05:32:27 +0000 | [diff] [blame] | 6120 | bnx2x_wait_reset_complete(bp, phy); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6121 | |
| 6122 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 1<<15); |
| 6123 | return bnx2x_848xx_cmn_config_init(phy, params, vars); |
| 6124 | } |
| 6125 | |
| 6126 | static u8 bnx2x_848x3_config_init(struct bnx2x_phy *phy, |
| 6127 | struct link_params *params, |
| 6128 | struct link_vars *vars) |
| 6129 | { |
| 6130 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 6a71bbe | 2010-11-01 05:32:31 +0000 | [diff] [blame] | 6131 | u8 port, initialize = 1; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6132 | u16 val; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6133 | u16 temp; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6134 | u32 actual_phy_selection; |
| 6135 | u8 rc = 0; |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6136 | |
| 6137 | /* This is just for MDIO_CTL_REG_84823_MEDIA register. */ |
| 6138 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6139 | msleep(1); |
Yaniv Rosner | 6a71bbe | 2010-11-01 05:32:31 +0000 | [diff] [blame] | 6140 | if (CHIP_IS_E2(bp)) |
| 6141 | port = BP_PATH(bp); |
| 6142 | else |
| 6143 | port = params->port; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6144 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_3, |
| 6145 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6146 | port); |
Yaniv Rosner | 9bffeac | 2010-11-01 05:32:27 +0000 | [diff] [blame] | 6147 | bnx2x_wait_reset_complete(bp, phy); |
| 6148 | /* Wait for GPHY to come out of reset */ |
| 6149 | msleep(50); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6150 | /* |
| 6151 | * BCM84823 requires that XGXS links up first @ 10G for normal behavior |
| 6152 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6153 | temp = vars->line_speed; |
| 6154 | vars->line_speed = SPEED_10000; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6155 | bnx2x_set_autoneg(¶ms->phy[INT_PHY], params, vars, 0); |
| 6156 | bnx2x_program_serdes(¶ms->phy[INT_PHY], params, vars); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6157 | vars->line_speed = temp; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6158 | |
| 6159 | /* Set dual-media configuration according to configuration */ |
| 6160 | |
| 6161 | bnx2x_cl45_read(bp, phy, MDIO_CTL_DEVAD, |
| 6162 | MDIO_CTL_REG_84823_MEDIA, &val); |
| 6163 | val &= ~(MDIO_CTL_REG_84823_MEDIA_MAC_MASK | |
| 6164 | MDIO_CTL_REG_84823_MEDIA_LINE_MASK | |
| 6165 | MDIO_CTL_REG_84823_MEDIA_COPPER_CORE_DOWN | |
| 6166 | MDIO_CTL_REG_84823_MEDIA_PRIORITY_MASK | |
| 6167 | MDIO_CTL_REG_84823_MEDIA_FIBER_1G); |
| 6168 | val |= MDIO_CTL_REG_84823_CTRL_MAC_XFI | |
| 6169 | MDIO_CTL_REG_84823_MEDIA_LINE_XAUI_L; |
| 6170 | |
| 6171 | actual_phy_selection = bnx2x_phy_selection(params); |
| 6172 | |
| 6173 | switch (actual_phy_selection) { |
| 6174 | case PORT_HW_CFG_PHY_SELECTION_HARDWARE_DEFAULT: |
| 6175 | /* Do nothing. Essentialy this is like the priority copper */ |
| 6176 | break; |
| 6177 | case PORT_HW_CFG_PHY_SELECTION_FIRST_PHY_PRIORITY: |
| 6178 | val |= MDIO_CTL_REG_84823_MEDIA_PRIORITY_COPPER; |
| 6179 | break; |
| 6180 | case PORT_HW_CFG_PHY_SELECTION_SECOND_PHY_PRIORITY: |
| 6181 | val |= MDIO_CTL_REG_84823_MEDIA_PRIORITY_FIBER; |
| 6182 | break; |
| 6183 | case PORT_HW_CFG_PHY_SELECTION_FIRST_PHY: |
| 6184 | /* Do nothing here. The first PHY won't be initialized at all */ |
| 6185 | break; |
| 6186 | case PORT_HW_CFG_PHY_SELECTION_SECOND_PHY: |
| 6187 | val |= MDIO_CTL_REG_84823_MEDIA_COPPER_CORE_DOWN; |
| 6188 | initialize = 0; |
| 6189 | break; |
| 6190 | } |
| 6191 | if (params->phy[EXT_PHY2].req_line_speed == SPEED_1000) |
| 6192 | val |= MDIO_CTL_REG_84823_MEDIA_FIBER_1G; |
| 6193 | |
| 6194 | bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD, |
| 6195 | MDIO_CTL_REG_84823_MEDIA, val); |
| 6196 | DP(NETIF_MSG_LINK, "Multi_phy config = 0x%x, Media control = 0x%x\n", |
| 6197 | params->multi_phy_config, val); |
| 6198 | |
| 6199 | if (initialize) |
| 6200 | rc = bnx2x_848xx_cmn_config_init(phy, params, vars); |
| 6201 | else |
| 6202 | bnx2x_save_848xx_spirom_version(phy, params); |
| 6203 | return rc; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6204 | } |
| 6205 | |
| 6206 | static u8 bnx2x_848xx_read_status(struct bnx2x_phy *phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6207 | struct link_params *params, |
| 6208 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6209 | { |
| 6210 | struct bnx2x *bp = params->bp; |
| 6211 | u16 val, val1, val2; |
| 6212 | u8 link_up = 0; |
| 6213 | |
| 6214 | /* Check 10G-BaseT link status */ |
| 6215 | /* Check PMD signal ok */ |
| 6216 | bnx2x_cl45_read(bp, phy, |
| 6217 | MDIO_AN_DEVAD, 0xFFFA, &val1); |
| 6218 | bnx2x_cl45_read(bp, phy, |
| 6219 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8481_PMD_SIGNAL, |
| 6220 | &val2); |
| 6221 | DP(NETIF_MSG_LINK, "BCM848xx: PMD_SIGNAL 1.a811 = 0x%x\n", val2); |
| 6222 | |
| 6223 | /* Check link 10G */ |
| 6224 | if (val2 & (1<<11)) { |
| 6225 | vars->line_speed = SPEED_10000; |
Yaniv Rosner | 791f18c | 2011-01-18 04:33:42 +0000 | [diff] [blame] | 6226 | vars->duplex = DUPLEX_FULL; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6227 | link_up = 1; |
| 6228 | bnx2x_ext_phy_10G_an_resolve(bp, phy, vars); |
| 6229 | } else { /* Check Legacy speed link */ |
| 6230 | u16 legacy_status, legacy_speed; |
| 6231 | |
| 6232 | /* Enable expansion register 0x42 (Operation mode status) */ |
| 6233 | bnx2x_cl45_write(bp, phy, |
| 6234 | MDIO_AN_DEVAD, |
| 6235 | MDIO_AN_REG_8481_EXPANSION_REG_ACCESS, 0xf42); |
| 6236 | |
| 6237 | /* Get legacy speed operation status */ |
| 6238 | bnx2x_cl45_read(bp, phy, |
| 6239 | MDIO_AN_DEVAD, |
| 6240 | MDIO_AN_REG_8481_EXPANSION_REG_RD_RW, |
| 6241 | &legacy_status); |
| 6242 | |
| 6243 | DP(NETIF_MSG_LINK, "Legacy speed status" |
| 6244 | " = 0x%x\n", legacy_status); |
| 6245 | link_up = ((legacy_status & (1<<11)) == (1<<11)); |
| 6246 | if (link_up) { |
| 6247 | legacy_speed = (legacy_status & (3<<9)); |
| 6248 | if (legacy_speed == (0<<9)) |
| 6249 | vars->line_speed = SPEED_10; |
| 6250 | else if (legacy_speed == (1<<9)) |
| 6251 | vars->line_speed = SPEED_100; |
| 6252 | else if (legacy_speed == (2<<9)) |
| 6253 | vars->line_speed = SPEED_1000; |
| 6254 | else /* Should not happen */ |
| 6255 | vars->line_speed = 0; |
| 6256 | |
| 6257 | if (legacy_status & (1<<8)) |
| 6258 | vars->duplex = DUPLEX_FULL; |
| 6259 | else |
| 6260 | vars->duplex = DUPLEX_HALF; |
| 6261 | |
| 6262 | DP(NETIF_MSG_LINK, "Link is up in %dMbps," |
| 6263 | " is_duplex_full= %d\n", vars->line_speed, |
| 6264 | (vars->duplex == DUPLEX_FULL)); |
| 6265 | /* Check legacy speed AN resolution */ |
| 6266 | bnx2x_cl45_read(bp, phy, |
| 6267 | MDIO_AN_DEVAD, |
| 6268 | MDIO_AN_REG_8481_LEGACY_MII_STATUS, |
| 6269 | &val); |
| 6270 | if (val & (1<<5)) |
| 6271 | vars->link_status |= |
| 6272 | LINK_STATUS_AUTO_NEGOTIATE_COMPLETE; |
| 6273 | bnx2x_cl45_read(bp, phy, |
| 6274 | MDIO_AN_DEVAD, |
| 6275 | MDIO_AN_REG_8481_LEGACY_AN_EXPANSION, |
| 6276 | &val); |
| 6277 | if ((val & (1<<0)) == 0) |
| 6278 | vars->link_status |= |
| 6279 | LINK_STATUS_PARALLEL_DETECTION_USED; |
| 6280 | } |
| 6281 | } |
| 6282 | if (link_up) { |
| 6283 | DP(NETIF_MSG_LINK, "BCM84823: link speed is %d\n", |
| 6284 | vars->line_speed); |
| 6285 | bnx2x_ext_phy_resolve_fc(phy, params, vars); |
| 6286 | } |
| 6287 | |
| 6288 | return link_up; |
| 6289 | } |
| 6290 | |
| 6291 | static u8 bnx2x_848xx_format_ver(u32 raw_ver, u8 *str, u16 *len) |
| 6292 | { |
| 6293 | u8 status = 0; |
| 6294 | u32 spirom_ver; |
| 6295 | spirom_ver = ((raw_ver & 0xF80) >> 7) << 16 | (raw_ver & 0x7F); |
| 6296 | status = bnx2x_format_ver(spirom_ver, str, len); |
| 6297 | return status; |
| 6298 | } |
| 6299 | |
| 6300 | static void bnx2x_8481_hw_reset(struct bnx2x_phy *phy, |
| 6301 | struct link_params *params) |
| 6302 | { |
| 6303 | bnx2x_set_gpio(params->bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6304 | MISC_REGISTERS_GPIO_OUTPUT_LOW, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6305 | bnx2x_set_gpio(params->bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6306 | MISC_REGISTERS_GPIO_OUTPUT_LOW, 1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6307 | } |
| 6308 | |
| 6309 | static void bnx2x_8481_link_reset(struct bnx2x_phy *phy, |
| 6310 | struct link_params *params) |
| 6311 | { |
| 6312 | bnx2x_cl45_write(params->bp, phy, |
| 6313 | MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, 0x0000); |
| 6314 | bnx2x_cl45_write(params->bp, phy, |
| 6315 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 1); |
| 6316 | } |
| 6317 | |
| 6318 | static void bnx2x_848x3_link_reset(struct bnx2x_phy *phy, |
| 6319 | struct link_params *params) |
| 6320 | { |
| 6321 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 6a71bbe | 2010-11-01 05:32:31 +0000 | [diff] [blame] | 6322 | u8 port; |
| 6323 | if (CHIP_IS_E2(bp)) |
| 6324 | port = BP_PATH(bp); |
| 6325 | else |
| 6326 | port = params->port; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6327 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_3, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6328 | MISC_REGISTERS_GPIO_OUTPUT_LOW, |
| 6329 | port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6330 | } |
| 6331 | |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6332 | static void bnx2x_848xx_set_link_led(struct bnx2x_phy *phy, |
| 6333 | struct link_params *params, u8 mode) |
| 6334 | { |
| 6335 | struct bnx2x *bp = params->bp; |
| 6336 | u16 val; |
| 6337 | |
| 6338 | switch (mode) { |
| 6339 | case LED_MODE_OFF: |
| 6340 | |
| 6341 | DP(NETIF_MSG_LINK, "Port 0x%x: LED MODE OFF\n", params->port); |
| 6342 | |
| 6343 | if ((params->hw_led_mode << SHARED_HW_CFG_LED_MODE_SHIFT) == |
| 6344 | SHARED_HW_CFG_LED_EXTPHY1) { |
| 6345 | |
| 6346 | /* Set LED masks */ |
| 6347 | bnx2x_cl45_write(bp, phy, |
| 6348 | MDIO_PMA_DEVAD, |
| 6349 | MDIO_PMA_REG_8481_LED1_MASK, |
| 6350 | 0x0); |
| 6351 | |
| 6352 | bnx2x_cl45_write(bp, phy, |
| 6353 | MDIO_PMA_DEVAD, |
| 6354 | MDIO_PMA_REG_8481_LED2_MASK, |
| 6355 | 0x0); |
| 6356 | |
| 6357 | bnx2x_cl45_write(bp, phy, |
| 6358 | MDIO_PMA_DEVAD, |
| 6359 | MDIO_PMA_REG_8481_LED3_MASK, |
| 6360 | 0x0); |
| 6361 | |
| 6362 | bnx2x_cl45_write(bp, phy, |
| 6363 | MDIO_PMA_DEVAD, |
| 6364 | MDIO_PMA_REG_8481_LED5_MASK, |
| 6365 | 0x0); |
| 6366 | |
| 6367 | } else { |
| 6368 | bnx2x_cl45_write(bp, phy, |
| 6369 | MDIO_PMA_DEVAD, |
| 6370 | MDIO_PMA_REG_8481_LED1_MASK, |
| 6371 | 0x0); |
| 6372 | } |
| 6373 | break; |
| 6374 | case LED_MODE_FRONT_PANEL_OFF: |
| 6375 | |
| 6376 | DP(NETIF_MSG_LINK, "Port 0x%x: LED MODE FRONT PANEL OFF\n", |
| 6377 | params->port); |
| 6378 | |
| 6379 | if ((params->hw_led_mode << SHARED_HW_CFG_LED_MODE_SHIFT) == |
| 6380 | SHARED_HW_CFG_LED_EXTPHY1) { |
| 6381 | |
| 6382 | /* Set LED masks */ |
| 6383 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6384 | MDIO_PMA_DEVAD, |
| 6385 | MDIO_PMA_REG_8481_LED1_MASK, |
| 6386 | 0x0); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6387 | |
| 6388 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6389 | MDIO_PMA_DEVAD, |
| 6390 | MDIO_PMA_REG_8481_LED2_MASK, |
| 6391 | 0x0); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6392 | |
| 6393 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6394 | MDIO_PMA_DEVAD, |
| 6395 | MDIO_PMA_REG_8481_LED3_MASK, |
| 6396 | 0x0); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6397 | |
| 6398 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6399 | MDIO_PMA_DEVAD, |
| 6400 | MDIO_PMA_REG_8481_LED5_MASK, |
| 6401 | 0x20); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6402 | |
| 6403 | } else { |
| 6404 | bnx2x_cl45_write(bp, phy, |
| 6405 | MDIO_PMA_DEVAD, |
| 6406 | MDIO_PMA_REG_8481_LED1_MASK, |
| 6407 | 0x0); |
| 6408 | } |
| 6409 | break; |
| 6410 | case LED_MODE_ON: |
| 6411 | |
| 6412 | DP(NETIF_MSG_LINK, "Port 0x%x: LED MODE ON\n", params->port); |
| 6413 | |
| 6414 | if ((params->hw_led_mode << SHARED_HW_CFG_LED_MODE_SHIFT) == |
| 6415 | SHARED_HW_CFG_LED_EXTPHY1) { |
| 6416 | /* Set control reg */ |
| 6417 | bnx2x_cl45_read(bp, phy, |
| 6418 | MDIO_PMA_DEVAD, |
| 6419 | MDIO_PMA_REG_8481_LINK_SIGNAL, |
| 6420 | &val); |
| 6421 | val &= 0x8000; |
| 6422 | val |= 0x2492; |
| 6423 | |
| 6424 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6425 | MDIO_PMA_DEVAD, |
| 6426 | MDIO_PMA_REG_8481_LINK_SIGNAL, |
| 6427 | val); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6428 | |
| 6429 | /* Set LED masks */ |
| 6430 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6431 | MDIO_PMA_DEVAD, |
| 6432 | MDIO_PMA_REG_8481_LED1_MASK, |
| 6433 | 0x0); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6434 | |
| 6435 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6436 | MDIO_PMA_DEVAD, |
| 6437 | MDIO_PMA_REG_8481_LED2_MASK, |
| 6438 | 0x20); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6439 | |
| 6440 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6441 | MDIO_PMA_DEVAD, |
| 6442 | MDIO_PMA_REG_8481_LED3_MASK, |
| 6443 | 0x20); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6444 | |
| 6445 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6446 | MDIO_PMA_DEVAD, |
| 6447 | MDIO_PMA_REG_8481_LED5_MASK, |
| 6448 | 0x0); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6449 | } else { |
| 6450 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6451 | MDIO_PMA_DEVAD, |
| 6452 | MDIO_PMA_REG_8481_LED1_MASK, |
| 6453 | 0x20); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6454 | } |
| 6455 | break; |
| 6456 | |
| 6457 | case LED_MODE_OPER: |
| 6458 | |
| 6459 | DP(NETIF_MSG_LINK, "Port 0x%x: LED MODE OPER\n", params->port); |
| 6460 | |
| 6461 | if ((params->hw_led_mode << SHARED_HW_CFG_LED_MODE_SHIFT) == |
| 6462 | SHARED_HW_CFG_LED_EXTPHY1) { |
| 6463 | |
| 6464 | /* Set control reg */ |
| 6465 | bnx2x_cl45_read(bp, phy, |
| 6466 | MDIO_PMA_DEVAD, |
| 6467 | MDIO_PMA_REG_8481_LINK_SIGNAL, |
| 6468 | &val); |
| 6469 | |
| 6470 | if (!((val & |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6471 | MDIO_PMA_REG_8481_LINK_SIGNAL_LED4_ENABLE_MASK) |
| 6472 | >> MDIO_PMA_REG_8481_LINK_SIGNAL_LED4_ENABLE_SHIFT)) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6473 | DP(NETIF_MSG_LINK, "Setting LINK_SIGNAL\n"); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6474 | bnx2x_cl45_write(bp, phy, |
| 6475 | MDIO_PMA_DEVAD, |
| 6476 | MDIO_PMA_REG_8481_LINK_SIGNAL, |
| 6477 | 0xa492); |
| 6478 | } |
| 6479 | |
| 6480 | /* Set LED masks */ |
| 6481 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6482 | MDIO_PMA_DEVAD, |
| 6483 | MDIO_PMA_REG_8481_LED1_MASK, |
| 6484 | 0x10); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6485 | |
| 6486 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6487 | MDIO_PMA_DEVAD, |
| 6488 | MDIO_PMA_REG_8481_LED2_MASK, |
| 6489 | 0x80); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6490 | |
| 6491 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6492 | MDIO_PMA_DEVAD, |
| 6493 | MDIO_PMA_REG_8481_LED3_MASK, |
| 6494 | 0x98); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6495 | |
| 6496 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6497 | MDIO_PMA_DEVAD, |
| 6498 | MDIO_PMA_REG_8481_LED5_MASK, |
| 6499 | 0x40); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6500 | |
| 6501 | } else { |
| 6502 | bnx2x_cl45_write(bp, phy, |
| 6503 | MDIO_PMA_DEVAD, |
| 6504 | MDIO_PMA_REG_8481_LED1_MASK, |
| 6505 | 0x80); |
Yaniv Rosner | 53eda06 | 2011-01-30 04:14:55 +0000 | [diff] [blame] | 6506 | |
| 6507 | /* Tell LED3 to blink on source */ |
| 6508 | bnx2x_cl45_read(bp, phy, |
| 6509 | MDIO_PMA_DEVAD, |
| 6510 | MDIO_PMA_REG_8481_LINK_SIGNAL, |
| 6511 | &val); |
| 6512 | val &= ~(7<<6); |
| 6513 | val |= (1<<6); /* A83B[8:6]= 1 */ |
| 6514 | bnx2x_cl45_write(bp, phy, |
| 6515 | MDIO_PMA_DEVAD, |
| 6516 | MDIO_PMA_REG_8481_LINK_SIGNAL, |
| 6517 | val); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6518 | } |
| 6519 | break; |
| 6520 | } |
| 6521 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6522 | /******************************************************************/ |
| 6523 | /* SFX7101 PHY SECTION */ |
| 6524 | /******************************************************************/ |
| 6525 | static void bnx2x_7101_config_loopback(struct bnx2x_phy *phy, |
| 6526 | struct link_params *params) |
| 6527 | { |
| 6528 | struct bnx2x *bp = params->bp; |
| 6529 | /* SFX7101_XGXS_TEST1 */ |
| 6530 | bnx2x_cl45_write(bp, phy, |
| 6531 | MDIO_XS_DEVAD, MDIO_XS_SFX7101_XGXS_TEST1, 0x100); |
| 6532 | } |
| 6533 | |
| 6534 | static u8 bnx2x_7101_config_init(struct bnx2x_phy *phy, |
| 6535 | struct link_params *params, |
| 6536 | struct link_vars *vars) |
| 6537 | { |
| 6538 | u16 fw_ver1, fw_ver2, val; |
| 6539 | struct bnx2x *bp = params->bp; |
| 6540 | DP(NETIF_MSG_LINK, "Setting the SFX7101 LASI indication\n"); |
| 6541 | |
| 6542 | /* Restore normal power mode*/ |
| 6543 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6544 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, params->port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6545 | /* HW reset */ |
| 6546 | bnx2x_ext_phy_hw_reset(bp, params->port); |
| 6547 | bnx2x_wait_reset_complete(bp, phy); |
| 6548 | |
| 6549 | bnx2x_cl45_write(bp, phy, |
| 6550 | MDIO_PMA_DEVAD, MDIO_PMA_REG_LASI_CTRL, 0x1); |
| 6551 | DP(NETIF_MSG_LINK, "Setting the SFX7101 LED to blink on traffic\n"); |
| 6552 | bnx2x_cl45_write(bp, phy, |
| 6553 | MDIO_PMA_DEVAD, MDIO_PMA_REG_7107_LED_CNTL, (1<<3)); |
| 6554 | |
| 6555 | bnx2x_ext_phy_set_pause(params, phy, vars); |
| 6556 | /* Restart autoneg */ |
| 6557 | bnx2x_cl45_read(bp, phy, |
| 6558 | MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, &val); |
| 6559 | val |= 0x200; |
| 6560 | bnx2x_cl45_write(bp, phy, |
| 6561 | MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, val); |
| 6562 | |
| 6563 | /* Save spirom version */ |
| 6564 | bnx2x_cl45_read(bp, phy, |
| 6565 | MDIO_PMA_DEVAD, MDIO_PMA_REG_7101_VER1, &fw_ver1); |
| 6566 | |
| 6567 | bnx2x_cl45_read(bp, phy, |
| 6568 | MDIO_PMA_DEVAD, MDIO_PMA_REG_7101_VER2, &fw_ver2); |
| 6569 | bnx2x_save_spirom_version(bp, params->port, |
| 6570 | (u32)(fw_ver1<<16 | fw_ver2), phy->ver_addr); |
| 6571 | return 0; |
| 6572 | } |
| 6573 | |
| 6574 | static u8 bnx2x_7101_read_status(struct bnx2x_phy *phy, |
| 6575 | struct link_params *params, |
| 6576 | struct link_vars *vars) |
| 6577 | { |
| 6578 | struct bnx2x *bp = params->bp; |
| 6579 | u8 link_up; |
| 6580 | u16 val1, val2; |
| 6581 | bnx2x_cl45_read(bp, phy, |
| 6582 | MDIO_PMA_DEVAD, MDIO_PMA_REG_LASI_STATUS, &val2); |
| 6583 | bnx2x_cl45_read(bp, phy, |
| 6584 | MDIO_PMA_DEVAD, MDIO_PMA_REG_LASI_STATUS, &val1); |
| 6585 | DP(NETIF_MSG_LINK, "10G-base-T LASI status 0x%x->0x%x\n", |
| 6586 | val2, val1); |
| 6587 | bnx2x_cl45_read(bp, phy, |
| 6588 | MDIO_PMA_DEVAD, MDIO_PMA_REG_STATUS, &val2); |
| 6589 | bnx2x_cl45_read(bp, phy, |
| 6590 | MDIO_PMA_DEVAD, MDIO_PMA_REG_STATUS, &val1); |
| 6591 | DP(NETIF_MSG_LINK, "10G-base-T PMA status 0x%x->0x%x\n", |
| 6592 | val2, val1); |
| 6593 | link_up = ((val1 & 4) == 4); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6594 | /* if link is up print the AN outcome of the SFX7101 PHY */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6595 | if (link_up) { |
| 6596 | bnx2x_cl45_read(bp, phy, |
| 6597 | MDIO_AN_DEVAD, MDIO_AN_REG_MASTER_STATUS, |
| 6598 | &val2); |
| 6599 | vars->line_speed = SPEED_10000; |
Yaniv Rosner | 791f18c | 2011-01-18 04:33:42 +0000 | [diff] [blame] | 6600 | vars->duplex = DUPLEX_FULL; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6601 | DP(NETIF_MSG_LINK, "SFX7101 AN status 0x%x->Master=%x\n", |
| 6602 | val2, (val2 & (1<<14))); |
| 6603 | bnx2x_ext_phy_10G_an_resolve(bp, phy, vars); |
| 6604 | bnx2x_ext_phy_resolve_fc(phy, params, vars); |
| 6605 | } |
| 6606 | return link_up; |
| 6607 | } |
| 6608 | |
| 6609 | |
| 6610 | static u8 bnx2x_7101_format_ver(u32 spirom_ver, u8 *str, u16 *len) |
| 6611 | { |
| 6612 | if (*len < 5) |
| 6613 | return -EINVAL; |
| 6614 | str[0] = (spirom_ver & 0xFF); |
| 6615 | str[1] = (spirom_ver & 0xFF00) >> 8; |
| 6616 | str[2] = (spirom_ver & 0xFF0000) >> 16; |
| 6617 | str[3] = (spirom_ver & 0xFF000000) >> 24; |
| 6618 | str[4] = '\0'; |
| 6619 | *len -= 5; |
| 6620 | return 0; |
| 6621 | } |
| 6622 | |
| 6623 | void bnx2x_sfx7101_sp_sw_reset(struct bnx2x *bp, struct bnx2x_phy *phy) |
| 6624 | { |
| 6625 | u16 val, cnt; |
| 6626 | |
| 6627 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6628 | MDIO_PMA_DEVAD, |
| 6629 | MDIO_PMA_REG_7101_RESET, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6630 | |
| 6631 | for (cnt = 0; cnt < 10; cnt++) { |
| 6632 | msleep(50); |
| 6633 | /* Writes a self-clearing reset */ |
| 6634 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6635 | MDIO_PMA_DEVAD, |
| 6636 | MDIO_PMA_REG_7101_RESET, |
| 6637 | (val | (1<<15))); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6638 | /* Wait for clear */ |
| 6639 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6640 | MDIO_PMA_DEVAD, |
| 6641 | MDIO_PMA_REG_7101_RESET, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6642 | |
| 6643 | if ((val & (1<<15)) == 0) |
| 6644 | break; |
| 6645 | } |
| 6646 | } |
| 6647 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6648 | static void bnx2x_7101_hw_reset(struct bnx2x_phy *phy, |
| 6649 | struct link_params *params) { |
| 6650 | /* Low power mode is controlled by GPIO 2 */ |
| 6651 | bnx2x_set_gpio(params->bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6652 | MISC_REGISTERS_GPIO_OUTPUT_LOW, params->port); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6653 | /* The PHY reset is controlled by GPIO 1 */ |
| 6654 | bnx2x_set_gpio(params->bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6655 | MISC_REGISTERS_GPIO_OUTPUT_LOW, params->port); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6656 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6657 | |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6658 | static void bnx2x_7101_set_link_led(struct bnx2x_phy *phy, |
| 6659 | struct link_params *params, u8 mode) |
| 6660 | { |
| 6661 | u16 val = 0; |
| 6662 | struct bnx2x *bp = params->bp; |
| 6663 | switch (mode) { |
| 6664 | case LED_MODE_FRONT_PANEL_OFF: |
| 6665 | case LED_MODE_OFF: |
| 6666 | val = 2; |
| 6667 | break; |
| 6668 | case LED_MODE_ON: |
| 6669 | val = 1; |
| 6670 | break; |
| 6671 | case LED_MODE_OPER: |
| 6672 | val = 0; |
| 6673 | break; |
| 6674 | } |
| 6675 | bnx2x_cl45_write(bp, phy, |
| 6676 | MDIO_PMA_DEVAD, |
| 6677 | MDIO_PMA_REG_7107_LINK_LED_CNTL, |
| 6678 | val); |
| 6679 | } |
| 6680 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6681 | /******************************************************************/ |
| 6682 | /* STATIC PHY DECLARATION */ |
| 6683 | /******************************************************************/ |
| 6684 | |
| 6685 | static struct bnx2x_phy phy_null = { |
| 6686 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_NOT_CONN, |
| 6687 | .addr = 0, |
| 6688 | .flags = FLAGS_INIT_XGXS_FIRST, |
| 6689 | .def_md_devad = 0, |
| 6690 | .reserved = 0, |
| 6691 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 6692 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 6693 | .mdio_ctrl = 0, |
| 6694 | .supported = 0, |
| 6695 | .media_type = ETH_PHY_NOT_PRESENT, |
| 6696 | .ver_addr = 0, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6697 | .req_flow_ctrl = 0, |
| 6698 | .req_line_speed = 0, |
| 6699 | .speed_cap_mask = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6700 | .req_duplex = 0, |
| 6701 | .rsrv = 0, |
| 6702 | .config_init = (config_init_t)NULL, |
| 6703 | .read_status = (read_status_t)NULL, |
| 6704 | .link_reset = (link_reset_t)NULL, |
| 6705 | .config_loopback = (config_loopback_t)NULL, |
| 6706 | .format_fw_ver = (format_fw_ver_t)NULL, |
| 6707 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6708 | .set_link_led = (set_link_led_t)NULL, |
| 6709 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6710 | }; |
| 6711 | |
| 6712 | static struct bnx2x_phy phy_serdes = { |
| 6713 | .type = PORT_HW_CFG_SERDES_EXT_PHY_TYPE_DIRECT, |
| 6714 | .addr = 0xff, |
| 6715 | .flags = 0, |
| 6716 | .def_md_devad = 0, |
| 6717 | .reserved = 0, |
| 6718 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 6719 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 6720 | .mdio_ctrl = 0, |
| 6721 | .supported = (SUPPORTED_10baseT_Half | |
| 6722 | SUPPORTED_10baseT_Full | |
| 6723 | SUPPORTED_100baseT_Half | |
| 6724 | SUPPORTED_100baseT_Full | |
| 6725 | SUPPORTED_1000baseT_Full | |
| 6726 | SUPPORTED_2500baseX_Full | |
| 6727 | SUPPORTED_TP | |
| 6728 | SUPPORTED_Autoneg | |
| 6729 | SUPPORTED_Pause | |
| 6730 | SUPPORTED_Asym_Pause), |
| 6731 | .media_type = ETH_PHY_UNSPECIFIED, |
| 6732 | .ver_addr = 0, |
| 6733 | .req_flow_ctrl = 0, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6734 | .req_line_speed = 0, |
| 6735 | .speed_cap_mask = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6736 | .req_duplex = 0, |
| 6737 | .rsrv = 0, |
| 6738 | .config_init = (config_init_t)bnx2x_init_serdes, |
| 6739 | .read_status = (read_status_t)bnx2x_link_settings_status, |
| 6740 | .link_reset = (link_reset_t)bnx2x_int_link_reset, |
| 6741 | .config_loopback = (config_loopback_t)NULL, |
| 6742 | .format_fw_ver = (format_fw_ver_t)NULL, |
| 6743 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6744 | .set_link_led = (set_link_led_t)NULL, |
| 6745 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6746 | }; |
| 6747 | |
| 6748 | static struct bnx2x_phy phy_xgxs = { |
| 6749 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT, |
| 6750 | .addr = 0xff, |
| 6751 | .flags = 0, |
| 6752 | .def_md_devad = 0, |
| 6753 | .reserved = 0, |
| 6754 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 6755 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 6756 | .mdio_ctrl = 0, |
| 6757 | .supported = (SUPPORTED_10baseT_Half | |
| 6758 | SUPPORTED_10baseT_Full | |
| 6759 | SUPPORTED_100baseT_Half | |
| 6760 | SUPPORTED_100baseT_Full | |
| 6761 | SUPPORTED_1000baseT_Full | |
| 6762 | SUPPORTED_2500baseX_Full | |
| 6763 | SUPPORTED_10000baseT_Full | |
| 6764 | SUPPORTED_FIBRE | |
| 6765 | SUPPORTED_Autoneg | |
| 6766 | SUPPORTED_Pause | |
| 6767 | SUPPORTED_Asym_Pause), |
| 6768 | .media_type = ETH_PHY_UNSPECIFIED, |
| 6769 | .ver_addr = 0, |
| 6770 | .req_flow_ctrl = 0, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6771 | .req_line_speed = 0, |
| 6772 | .speed_cap_mask = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6773 | .req_duplex = 0, |
| 6774 | .rsrv = 0, |
| 6775 | .config_init = (config_init_t)bnx2x_init_xgxs, |
| 6776 | .read_status = (read_status_t)bnx2x_link_settings_status, |
| 6777 | .link_reset = (link_reset_t)bnx2x_int_link_reset, |
| 6778 | .config_loopback = (config_loopback_t)bnx2x_set_xgxs_loopback, |
| 6779 | .format_fw_ver = (format_fw_ver_t)NULL, |
| 6780 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6781 | .set_link_led = (set_link_led_t)NULL, |
| 6782 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6783 | }; |
| 6784 | |
| 6785 | static struct bnx2x_phy phy_7101 = { |
| 6786 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_SFX7101, |
| 6787 | .addr = 0xff, |
| 6788 | .flags = FLAGS_FAN_FAILURE_DET_REQ, |
| 6789 | .def_md_devad = 0, |
| 6790 | .reserved = 0, |
| 6791 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 6792 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 6793 | .mdio_ctrl = 0, |
| 6794 | .supported = (SUPPORTED_10000baseT_Full | |
| 6795 | SUPPORTED_TP | |
| 6796 | SUPPORTED_Autoneg | |
| 6797 | SUPPORTED_Pause | |
| 6798 | SUPPORTED_Asym_Pause), |
| 6799 | .media_type = ETH_PHY_BASE_T, |
| 6800 | .ver_addr = 0, |
| 6801 | .req_flow_ctrl = 0, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6802 | .req_line_speed = 0, |
| 6803 | .speed_cap_mask = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6804 | .req_duplex = 0, |
| 6805 | .rsrv = 0, |
| 6806 | .config_init = (config_init_t)bnx2x_7101_config_init, |
| 6807 | .read_status = (read_status_t)bnx2x_7101_read_status, |
| 6808 | .link_reset = (link_reset_t)bnx2x_common_ext_link_reset, |
| 6809 | .config_loopback = (config_loopback_t)bnx2x_7101_config_loopback, |
| 6810 | .format_fw_ver = (format_fw_ver_t)bnx2x_7101_format_ver, |
| 6811 | .hw_reset = (hw_reset_t)bnx2x_7101_hw_reset, |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6812 | .set_link_led = (set_link_led_t)bnx2x_7101_set_link_led, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6813 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6814 | }; |
| 6815 | static struct bnx2x_phy phy_8073 = { |
| 6816 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073, |
| 6817 | .addr = 0xff, |
| 6818 | .flags = FLAGS_HW_LOCK_REQUIRED, |
| 6819 | .def_md_devad = 0, |
| 6820 | .reserved = 0, |
| 6821 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 6822 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 6823 | .mdio_ctrl = 0, |
| 6824 | .supported = (SUPPORTED_10000baseT_Full | |
| 6825 | SUPPORTED_2500baseX_Full | |
| 6826 | SUPPORTED_1000baseT_Full | |
| 6827 | SUPPORTED_FIBRE | |
| 6828 | SUPPORTED_Autoneg | |
| 6829 | SUPPORTED_Pause | |
| 6830 | SUPPORTED_Asym_Pause), |
| 6831 | .media_type = ETH_PHY_UNSPECIFIED, |
| 6832 | .ver_addr = 0, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6833 | .req_flow_ctrl = 0, |
| 6834 | .req_line_speed = 0, |
| 6835 | .speed_cap_mask = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6836 | .req_duplex = 0, |
| 6837 | .rsrv = 0, |
Yaniv Rosner | 62b29a5 | 2010-09-07 11:40:58 +0000 | [diff] [blame] | 6838 | .config_init = (config_init_t)bnx2x_8073_config_init, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6839 | .read_status = (read_status_t)bnx2x_8073_read_status, |
| 6840 | .link_reset = (link_reset_t)bnx2x_8073_link_reset, |
| 6841 | .config_loopback = (config_loopback_t)NULL, |
| 6842 | .format_fw_ver = (format_fw_ver_t)bnx2x_format_ver, |
| 6843 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6844 | .set_link_led = (set_link_led_t)NULL, |
| 6845 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6846 | }; |
| 6847 | static struct bnx2x_phy phy_8705 = { |
| 6848 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8705, |
| 6849 | .addr = 0xff, |
| 6850 | .flags = FLAGS_INIT_XGXS_FIRST, |
| 6851 | .def_md_devad = 0, |
| 6852 | .reserved = 0, |
| 6853 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 6854 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 6855 | .mdio_ctrl = 0, |
| 6856 | .supported = (SUPPORTED_10000baseT_Full | |
| 6857 | SUPPORTED_FIBRE | |
| 6858 | SUPPORTED_Pause | |
| 6859 | SUPPORTED_Asym_Pause), |
| 6860 | .media_type = ETH_PHY_XFP_FIBER, |
| 6861 | .ver_addr = 0, |
| 6862 | .req_flow_ctrl = 0, |
| 6863 | .req_line_speed = 0, |
| 6864 | .speed_cap_mask = 0, |
| 6865 | .req_duplex = 0, |
| 6866 | .rsrv = 0, |
| 6867 | .config_init = (config_init_t)bnx2x_8705_config_init, |
| 6868 | .read_status = (read_status_t)bnx2x_8705_read_status, |
| 6869 | .link_reset = (link_reset_t)bnx2x_common_ext_link_reset, |
| 6870 | .config_loopback = (config_loopback_t)NULL, |
| 6871 | .format_fw_ver = (format_fw_ver_t)bnx2x_null_format_ver, |
| 6872 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6873 | .set_link_led = (set_link_led_t)NULL, |
| 6874 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6875 | }; |
| 6876 | static struct bnx2x_phy phy_8706 = { |
| 6877 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8706, |
| 6878 | .addr = 0xff, |
| 6879 | .flags = FLAGS_INIT_XGXS_FIRST, |
| 6880 | .def_md_devad = 0, |
| 6881 | .reserved = 0, |
| 6882 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 6883 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 6884 | .mdio_ctrl = 0, |
| 6885 | .supported = (SUPPORTED_10000baseT_Full | |
| 6886 | SUPPORTED_1000baseT_Full | |
| 6887 | SUPPORTED_FIBRE | |
| 6888 | SUPPORTED_Pause | |
| 6889 | SUPPORTED_Asym_Pause), |
| 6890 | .media_type = ETH_PHY_SFP_FIBER, |
| 6891 | .ver_addr = 0, |
| 6892 | .req_flow_ctrl = 0, |
| 6893 | .req_line_speed = 0, |
| 6894 | .speed_cap_mask = 0, |
| 6895 | .req_duplex = 0, |
| 6896 | .rsrv = 0, |
| 6897 | .config_init = (config_init_t)bnx2x_8706_config_init, |
| 6898 | .read_status = (read_status_t)bnx2x_8706_read_status, |
| 6899 | .link_reset = (link_reset_t)bnx2x_common_ext_link_reset, |
| 6900 | .config_loopback = (config_loopback_t)NULL, |
| 6901 | .format_fw_ver = (format_fw_ver_t)bnx2x_format_ver, |
| 6902 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6903 | .set_link_led = (set_link_led_t)NULL, |
| 6904 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6905 | }; |
| 6906 | |
| 6907 | static struct bnx2x_phy phy_8726 = { |
| 6908 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726, |
| 6909 | .addr = 0xff, |
| 6910 | .flags = (FLAGS_HW_LOCK_REQUIRED | |
| 6911 | FLAGS_INIT_XGXS_FIRST), |
| 6912 | .def_md_devad = 0, |
| 6913 | .reserved = 0, |
| 6914 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 6915 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 6916 | .mdio_ctrl = 0, |
| 6917 | .supported = (SUPPORTED_10000baseT_Full | |
| 6918 | SUPPORTED_1000baseT_Full | |
| 6919 | SUPPORTED_Autoneg | |
| 6920 | SUPPORTED_FIBRE | |
| 6921 | SUPPORTED_Pause | |
| 6922 | SUPPORTED_Asym_Pause), |
| 6923 | .media_type = ETH_PHY_SFP_FIBER, |
| 6924 | .ver_addr = 0, |
| 6925 | .req_flow_ctrl = 0, |
| 6926 | .req_line_speed = 0, |
| 6927 | .speed_cap_mask = 0, |
| 6928 | .req_duplex = 0, |
| 6929 | .rsrv = 0, |
| 6930 | .config_init = (config_init_t)bnx2x_8726_config_init, |
| 6931 | .read_status = (read_status_t)bnx2x_8726_read_status, |
| 6932 | .link_reset = (link_reset_t)bnx2x_8726_link_reset, |
| 6933 | .config_loopback = (config_loopback_t)bnx2x_8726_config_loopback, |
| 6934 | .format_fw_ver = (format_fw_ver_t)bnx2x_format_ver, |
| 6935 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6936 | .set_link_led = (set_link_led_t)NULL, |
| 6937 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6938 | }; |
| 6939 | |
| 6940 | static struct bnx2x_phy phy_8727 = { |
| 6941 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727, |
| 6942 | .addr = 0xff, |
| 6943 | .flags = FLAGS_FAN_FAILURE_DET_REQ, |
| 6944 | .def_md_devad = 0, |
| 6945 | .reserved = 0, |
| 6946 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 6947 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 6948 | .mdio_ctrl = 0, |
| 6949 | .supported = (SUPPORTED_10000baseT_Full | |
| 6950 | SUPPORTED_1000baseT_Full | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6951 | SUPPORTED_FIBRE | |
| 6952 | SUPPORTED_Pause | |
| 6953 | SUPPORTED_Asym_Pause), |
| 6954 | .media_type = ETH_PHY_SFP_FIBER, |
| 6955 | .ver_addr = 0, |
| 6956 | .req_flow_ctrl = 0, |
| 6957 | .req_line_speed = 0, |
| 6958 | .speed_cap_mask = 0, |
| 6959 | .req_duplex = 0, |
| 6960 | .rsrv = 0, |
| 6961 | .config_init = (config_init_t)bnx2x_8727_config_init, |
| 6962 | .read_status = (read_status_t)bnx2x_8727_read_status, |
| 6963 | .link_reset = (link_reset_t)bnx2x_8727_link_reset, |
| 6964 | .config_loopback = (config_loopback_t)NULL, |
| 6965 | .format_fw_ver = (format_fw_ver_t)bnx2x_format_ver, |
| 6966 | .hw_reset = (hw_reset_t)bnx2x_8727_hw_reset, |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6967 | .set_link_led = (set_link_led_t)bnx2x_8727_set_link_led, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6968 | .phy_specific_func = (phy_specific_func_t)bnx2x_8727_specific_func |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6969 | }; |
| 6970 | static struct bnx2x_phy phy_8481 = { |
| 6971 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8481, |
| 6972 | .addr = 0xff, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6973 | .flags = FLAGS_FAN_FAILURE_DET_REQ | |
| 6974 | FLAGS_REARM_LATCH_SIGNAL, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6975 | .def_md_devad = 0, |
| 6976 | .reserved = 0, |
| 6977 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 6978 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 6979 | .mdio_ctrl = 0, |
| 6980 | .supported = (SUPPORTED_10baseT_Half | |
| 6981 | SUPPORTED_10baseT_Full | |
| 6982 | SUPPORTED_100baseT_Half | |
| 6983 | SUPPORTED_100baseT_Full | |
| 6984 | SUPPORTED_1000baseT_Full | |
| 6985 | SUPPORTED_10000baseT_Full | |
| 6986 | SUPPORTED_TP | |
| 6987 | SUPPORTED_Autoneg | |
| 6988 | SUPPORTED_Pause | |
| 6989 | SUPPORTED_Asym_Pause), |
| 6990 | .media_type = ETH_PHY_BASE_T, |
| 6991 | .ver_addr = 0, |
| 6992 | .req_flow_ctrl = 0, |
| 6993 | .req_line_speed = 0, |
| 6994 | .speed_cap_mask = 0, |
| 6995 | .req_duplex = 0, |
| 6996 | .rsrv = 0, |
| 6997 | .config_init = (config_init_t)bnx2x_8481_config_init, |
| 6998 | .read_status = (read_status_t)bnx2x_848xx_read_status, |
| 6999 | .link_reset = (link_reset_t)bnx2x_8481_link_reset, |
| 7000 | .config_loopback = (config_loopback_t)NULL, |
| 7001 | .format_fw_ver = (format_fw_ver_t)bnx2x_848xx_format_ver, |
| 7002 | .hw_reset = (hw_reset_t)bnx2x_8481_hw_reset, |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 7003 | .set_link_led = (set_link_led_t)bnx2x_848xx_set_link_led, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7004 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7005 | }; |
| 7006 | |
| 7007 | static struct bnx2x_phy phy_84823 = { |
| 7008 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84823, |
| 7009 | .addr = 0xff, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7010 | .flags = FLAGS_FAN_FAILURE_DET_REQ | |
| 7011 | FLAGS_REARM_LATCH_SIGNAL, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7012 | .def_md_devad = 0, |
| 7013 | .reserved = 0, |
| 7014 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 7015 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 7016 | .mdio_ctrl = 0, |
| 7017 | .supported = (SUPPORTED_10baseT_Half | |
| 7018 | SUPPORTED_10baseT_Full | |
| 7019 | SUPPORTED_100baseT_Half | |
| 7020 | SUPPORTED_100baseT_Full | |
| 7021 | SUPPORTED_1000baseT_Full | |
| 7022 | SUPPORTED_10000baseT_Full | |
| 7023 | SUPPORTED_TP | |
| 7024 | SUPPORTED_Autoneg | |
| 7025 | SUPPORTED_Pause | |
| 7026 | SUPPORTED_Asym_Pause), |
| 7027 | .media_type = ETH_PHY_BASE_T, |
| 7028 | .ver_addr = 0, |
| 7029 | .req_flow_ctrl = 0, |
| 7030 | .req_line_speed = 0, |
| 7031 | .speed_cap_mask = 0, |
| 7032 | .req_duplex = 0, |
| 7033 | .rsrv = 0, |
| 7034 | .config_init = (config_init_t)bnx2x_848x3_config_init, |
| 7035 | .read_status = (read_status_t)bnx2x_848xx_read_status, |
| 7036 | .link_reset = (link_reset_t)bnx2x_848x3_link_reset, |
| 7037 | .config_loopback = (config_loopback_t)NULL, |
| 7038 | .format_fw_ver = (format_fw_ver_t)bnx2x_848xx_format_ver, |
| 7039 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 7040 | .set_link_led = (set_link_led_t)bnx2x_848xx_set_link_led, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7041 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7042 | }; |
| 7043 | |
| 7044 | /*****************************************************************/ |
| 7045 | /* */ |
| 7046 | /* Populate the phy according. Main function: bnx2x_populate_phy */ |
| 7047 | /* */ |
| 7048 | /*****************************************************************/ |
| 7049 | |
| 7050 | static void bnx2x_populate_preemphasis(struct bnx2x *bp, u32 shmem_base, |
| 7051 | struct bnx2x_phy *phy, u8 port, |
| 7052 | u8 phy_index) |
| 7053 | { |
| 7054 | /* Get the 4 lanes xgxs config rx and tx */ |
| 7055 | u32 rx = 0, tx = 0, i; |
| 7056 | for (i = 0; i < 2; i++) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7057 | /* |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7058 | * INT_PHY and EXT_PHY1 share the same value location in the |
| 7059 | * shmem. When num_phys is greater than 1, than this value |
| 7060 | * applies only to EXT_PHY1 |
| 7061 | */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7062 | if (phy_index == INT_PHY || phy_index == EXT_PHY1) { |
| 7063 | rx = REG_RD(bp, shmem_base + |
| 7064 | offsetof(struct shmem_region, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7065 | dev_info.port_hw_config[port].xgxs_config_rx[i<<1])); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7066 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7067 | tx = REG_RD(bp, shmem_base + |
| 7068 | offsetof(struct shmem_region, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7069 | dev_info.port_hw_config[port].xgxs_config_tx[i<<1])); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7070 | } else { |
| 7071 | rx = REG_RD(bp, shmem_base + |
| 7072 | offsetof(struct shmem_region, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7073 | dev_info.port_hw_config[port].xgxs_config2_rx[i<<1])); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7074 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7075 | tx = REG_RD(bp, shmem_base + |
| 7076 | offsetof(struct shmem_region, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7077 | dev_info.port_hw_config[port].xgxs_config2_rx[i<<1])); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7078 | } |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7079 | |
| 7080 | phy->rx_preemphasis[i << 1] = ((rx>>16) & 0xffff); |
| 7081 | phy->rx_preemphasis[(i << 1) + 1] = (rx & 0xffff); |
| 7082 | |
| 7083 | phy->tx_preemphasis[i << 1] = ((tx>>16) & 0xffff); |
| 7084 | phy->tx_preemphasis[(i << 1) + 1] = (tx & 0xffff); |
| 7085 | } |
| 7086 | } |
| 7087 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 7088 | static u32 bnx2x_get_ext_phy_config(struct bnx2x *bp, u32 shmem_base, |
| 7089 | u8 phy_index, u8 port) |
| 7090 | { |
| 7091 | u32 ext_phy_config = 0; |
| 7092 | switch (phy_index) { |
| 7093 | case EXT_PHY1: |
| 7094 | ext_phy_config = REG_RD(bp, shmem_base + |
| 7095 | offsetof(struct shmem_region, |
| 7096 | dev_info.port_hw_config[port].external_phy_config)); |
| 7097 | break; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7098 | case EXT_PHY2: |
| 7099 | ext_phy_config = REG_RD(bp, shmem_base + |
| 7100 | offsetof(struct shmem_region, |
| 7101 | dev_info.port_hw_config[port].external_phy_config2)); |
| 7102 | break; |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 7103 | default: |
| 7104 | DP(NETIF_MSG_LINK, "Invalid phy_index %d\n", phy_index); |
| 7105 | return -EINVAL; |
| 7106 | } |
| 7107 | |
| 7108 | return ext_phy_config; |
| 7109 | } |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7110 | static u8 bnx2x_populate_int_phy(struct bnx2x *bp, u32 shmem_base, u8 port, |
| 7111 | struct bnx2x_phy *phy) |
| 7112 | { |
| 7113 | u32 phy_addr; |
| 7114 | u32 chip_id; |
| 7115 | u32 switch_cfg = (REG_RD(bp, shmem_base + |
| 7116 | offsetof(struct shmem_region, |
| 7117 | dev_info.port_feature_config[port].link_config)) & |
| 7118 | PORT_FEATURE_CONNECTED_SWITCH_MASK); |
| 7119 | chip_id = REG_RD(bp, MISC_REG_CHIP_NUM) << 16; |
| 7120 | switch (switch_cfg) { |
| 7121 | case SWITCH_CFG_1G: |
| 7122 | phy_addr = REG_RD(bp, |
| 7123 | NIG_REG_SERDES0_CTRL_PHY_ADDR + |
| 7124 | port * 0x10); |
| 7125 | *phy = phy_serdes; |
| 7126 | break; |
| 7127 | case SWITCH_CFG_10G: |
| 7128 | phy_addr = REG_RD(bp, |
| 7129 | NIG_REG_XGXS0_CTRL_PHY_ADDR + |
| 7130 | port * 0x18); |
| 7131 | *phy = phy_xgxs; |
| 7132 | break; |
| 7133 | default: |
| 7134 | DP(NETIF_MSG_LINK, "Invalid switch_cfg\n"); |
| 7135 | return -EINVAL; |
| 7136 | } |
| 7137 | phy->addr = (u8)phy_addr; |
| 7138 | phy->mdio_ctrl = bnx2x_get_emac_base(bp, |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 7139 | SHARED_HW_CFG_MDC_MDIO_ACCESS1_BOTH, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7140 | port); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 7141 | if (CHIP_IS_E2(bp)) |
| 7142 | phy->def_md_devad = E2_DEFAULT_PHY_DEV_ADDR; |
| 7143 | else |
| 7144 | phy->def_md_devad = DEFAULT_PHY_DEV_ADDR; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7145 | |
| 7146 | DP(NETIF_MSG_LINK, "Internal phy port=%d, addr=0x%x, mdio_ctl=0x%x\n", |
| 7147 | port, phy->addr, phy->mdio_ctrl); |
| 7148 | |
| 7149 | bnx2x_populate_preemphasis(bp, shmem_base, phy, port, INT_PHY); |
| 7150 | return 0; |
| 7151 | } |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 7152 | |
| 7153 | static u8 bnx2x_populate_ext_phy(struct bnx2x *bp, |
| 7154 | u8 phy_index, |
| 7155 | u32 shmem_base, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7156 | u32 shmem2_base, |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 7157 | u8 port, |
| 7158 | struct bnx2x_phy *phy) |
| 7159 | { |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 7160 | u32 ext_phy_config, phy_type, config2; |
| 7161 | u32 mdc_mdio_access = SHARED_HW_CFG_MDC_MDIO_ACCESS1_BOTH; |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 7162 | ext_phy_config = bnx2x_get_ext_phy_config(bp, shmem_base, |
| 7163 | phy_index, port); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7164 | phy_type = XGXS_EXT_PHY_TYPE(ext_phy_config); |
| 7165 | /* Select the phy type */ |
| 7166 | switch (phy_type) { |
| 7167 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073: |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 7168 | mdc_mdio_access = SHARED_HW_CFG_MDC_MDIO_ACCESS1_SWAPPED; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7169 | *phy = phy_8073; |
| 7170 | break; |
| 7171 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8705: |
| 7172 | *phy = phy_8705; |
| 7173 | break; |
| 7174 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8706: |
| 7175 | *phy = phy_8706; |
| 7176 | break; |
| 7177 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726: |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 7178 | mdc_mdio_access = SHARED_HW_CFG_MDC_MDIO_ACCESS1_EMAC1; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7179 | *phy = phy_8726; |
| 7180 | break; |
| 7181 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727_NOC: |
| 7182 | /* BCM8727_NOC => BCM8727 no over current */ |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 7183 | mdc_mdio_access = SHARED_HW_CFG_MDC_MDIO_ACCESS1_EMAC1; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7184 | *phy = phy_8727; |
| 7185 | phy->flags |= FLAGS_NOC; |
| 7186 | break; |
| 7187 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727: |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 7188 | mdc_mdio_access = SHARED_HW_CFG_MDC_MDIO_ACCESS1_EMAC1; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7189 | *phy = phy_8727; |
| 7190 | break; |
| 7191 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8481: |
| 7192 | *phy = phy_8481; |
| 7193 | break; |
| 7194 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84823: |
| 7195 | *phy = phy_84823; |
| 7196 | break; |
| 7197 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_SFX7101: |
| 7198 | *phy = phy_7101; |
| 7199 | break; |
| 7200 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_FAILURE: |
| 7201 | *phy = phy_null; |
| 7202 | return -EINVAL; |
| 7203 | default: |
| 7204 | *phy = phy_null; |
| 7205 | return 0; |
| 7206 | } |
| 7207 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 7208 | phy->addr = XGXS_EXT_PHY_ADDR(ext_phy_config); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7209 | bnx2x_populate_preemphasis(bp, shmem_base, phy, port, phy_index); |
Yaniv Rosner | 62b29a5 | 2010-09-07 11:40:58 +0000 | [diff] [blame] | 7210 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7211 | /* |
| 7212 | * The shmem address of the phy version is located on different |
| 7213 | * structures. In case this structure is too old, do not set |
| 7214 | * the address |
| 7215 | */ |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 7216 | config2 = REG_RD(bp, shmem_base + offsetof(struct shmem_region, |
| 7217 | dev_info.shared_hw_config.config2)); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7218 | if (phy_index == EXT_PHY1) { |
| 7219 | phy->ver_addr = shmem_base + offsetof(struct shmem_region, |
| 7220 | port_mb[port].ext_phy_fw_version); |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 7221 | |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7222 | /* Check specific mdc mdio settings */ |
| 7223 | if (config2 & SHARED_HW_CFG_MDC_MDIO_ACCESS1_MASK) |
| 7224 | mdc_mdio_access = config2 & |
| 7225 | SHARED_HW_CFG_MDC_MDIO_ACCESS1_MASK; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7226 | } else { |
| 7227 | u32 size = REG_RD(bp, shmem2_base); |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 7228 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7229 | if (size > |
| 7230 | offsetof(struct shmem2_region, ext_phy_fw_version2)) { |
| 7231 | phy->ver_addr = shmem2_base + |
| 7232 | offsetof(struct shmem2_region, |
| 7233 | ext_phy_fw_version2[port]); |
| 7234 | } |
| 7235 | /* Check specific mdc mdio settings */ |
| 7236 | if (config2 & SHARED_HW_CFG_MDC_MDIO_ACCESS2_MASK) |
| 7237 | mdc_mdio_access = (config2 & |
| 7238 | SHARED_HW_CFG_MDC_MDIO_ACCESS2_MASK) >> |
| 7239 | (SHARED_HW_CFG_MDC_MDIO_ACCESS2_SHIFT - |
| 7240 | SHARED_HW_CFG_MDC_MDIO_ACCESS1_SHIFT); |
| 7241 | } |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 7242 | phy->mdio_ctrl = bnx2x_get_emac_base(bp, mdc_mdio_access, port); |
| 7243 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7244 | /* |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 7245 | * In case mdc/mdio_access of the external phy is different than the |
| 7246 | * mdc/mdio access of the XGXS, a HW lock must be taken in each access |
| 7247 | * to prevent one port interfere with another port's CL45 operations. |
| 7248 | */ |
| 7249 | if (mdc_mdio_access != SHARED_HW_CFG_MDC_MDIO_ACCESS1_BOTH) |
| 7250 | phy->flags |= FLAGS_HW_LOCK_REQUIRED; |
| 7251 | DP(NETIF_MSG_LINK, "phy_type 0x%x port %d found in index %d\n", |
| 7252 | phy_type, port, phy_index); |
| 7253 | DP(NETIF_MSG_LINK, " addr=0x%x, mdio_ctl=0x%x\n", |
| 7254 | phy->addr, phy->mdio_ctrl); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 7255 | return 0; |
| 7256 | } |
| 7257 | |
| 7258 | static u8 bnx2x_populate_phy(struct bnx2x *bp, u8 phy_index, u32 shmem_base, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7259 | u32 shmem2_base, u8 port, struct bnx2x_phy *phy) |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 7260 | { |
| 7261 | u8 status = 0; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7262 | phy->type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_NOT_CONN; |
| 7263 | if (phy_index == INT_PHY) |
| 7264 | return bnx2x_populate_int_phy(bp, shmem_base, port, phy); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7265 | status = bnx2x_populate_ext_phy(bp, phy_index, shmem_base, shmem2_base, |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 7266 | port, phy); |
| 7267 | return status; |
| 7268 | } |
| 7269 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7270 | static void bnx2x_phy_def_cfg(struct link_params *params, |
| 7271 | struct bnx2x_phy *phy, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7272 | u8 phy_index) |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7273 | { |
| 7274 | struct bnx2x *bp = params->bp; |
| 7275 | u32 link_config; |
| 7276 | /* Populate the default phy configuration for MF mode */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7277 | if (phy_index == EXT_PHY2) { |
| 7278 | link_config = REG_RD(bp, params->shmem_base + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7279 | offsetof(struct shmem_region, dev_info. |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7280 | port_feature_config[params->port].link_config2)); |
| 7281 | phy->speed_cap_mask = REG_RD(bp, params->shmem_base + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7282 | offsetof(struct shmem_region, |
| 7283 | dev_info. |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7284 | port_hw_config[params->port].speed_capability_mask2)); |
| 7285 | } else { |
| 7286 | link_config = REG_RD(bp, params->shmem_base + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7287 | offsetof(struct shmem_region, dev_info. |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7288 | port_feature_config[params->port].link_config)); |
| 7289 | phy->speed_cap_mask = REG_RD(bp, params->shmem_base + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7290 | offsetof(struct shmem_region, |
| 7291 | dev_info. |
| 7292 | port_hw_config[params->port].speed_capability_mask)); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7293 | } |
| 7294 | DP(NETIF_MSG_LINK, "Default config phy idx %x cfg 0x%x speed_cap_mask" |
| 7295 | " 0x%x\n", phy_index, link_config, phy->speed_cap_mask); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7296 | |
| 7297 | phy->req_duplex = DUPLEX_FULL; |
| 7298 | switch (link_config & PORT_FEATURE_LINK_SPEED_MASK) { |
| 7299 | case PORT_FEATURE_LINK_SPEED_10M_HALF: |
| 7300 | phy->req_duplex = DUPLEX_HALF; |
| 7301 | case PORT_FEATURE_LINK_SPEED_10M_FULL: |
| 7302 | phy->req_line_speed = SPEED_10; |
| 7303 | break; |
| 7304 | case PORT_FEATURE_LINK_SPEED_100M_HALF: |
| 7305 | phy->req_duplex = DUPLEX_HALF; |
| 7306 | case PORT_FEATURE_LINK_SPEED_100M_FULL: |
| 7307 | phy->req_line_speed = SPEED_100; |
| 7308 | break; |
| 7309 | case PORT_FEATURE_LINK_SPEED_1G: |
| 7310 | phy->req_line_speed = SPEED_1000; |
| 7311 | break; |
| 7312 | case PORT_FEATURE_LINK_SPEED_2_5G: |
| 7313 | phy->req_line_speed = SPEED_2500; |
| 7314 | break; |
| 7315 | case PORT_FEATURE_LINK_SPEED_10G_CX4: |
| 7316 | phy->req_line_speed = SPEED_10000; |
| 7317 | break; |
| 7318 | default: |
| 7319 | phy->req_line_speed = SPEED_AUTO_NEG; |
| 7320 | break; |
| 7321 | } |
| 7322 | |
| 7323 | switch (link_config & PORT_FEATURE_FLOW_CONTROL_MASK) { |
| 7324 | case PORT_FEATURE_FLOW_CONTROL_AUTO: |
| 7325 | phy->req_flow_ctrl = BNX2X_FLOW_CTRL_AUTO; |
| 7326 | break; |
| 7327 | case PORT_FEATURE_FLOW_CONTROL_TX: |
| 7328 | phy->req_flow_ctrl = BNX2X_FLOW_CTRL_TX; |
| 7329 | break; |
| 7330 | case PORT_FEATURE_FLOW_CONTROL_RX: |
| 7331 | phy->req_flow_ctrl = BNX2X_FLOW_CTRL_RX; |
| 7332 | break; |
| 7333 | case PORT_FEATURE_FLOW_CONTROL_BOTH: |
| 7334 | phy->req_flow_ctrl = BNX2X_FLOW_CTRL_BOTH; |
| 7335 | break; |
| 7336 | default: |
| 7337 | phy->req_flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 7338 | break; |
| 7339 | } |
| 7340 | } |
| 7341 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7342 | u32 bnx2x_phy_selection(struct link_params *params) |
| 7343 | { |
| 7344 | u32 phy_config_swapped, prio_cfg; |
| 7345 | u32 return_cfg = PORT_HW_CFG_PHY_SELECTION_HARDWARE_DEFAULT; |
| 7346 | |
| 7347 | phy_config_swapped = params->multi_phy_config & |
| 7348 | PORT_HW_CFG_PHY_SWAPPED_ENABLED; |
| 7349 | |
| 7350 | prio_cfg = params->multi_phy_config & |
| 7351 | PORT_HW_CFG_PHY_SELECTION_MASK; |
| 7352 | |
| 7353 | if (phy_config_swapped) { |
| 7354 | switch (prio_cfg) { |
| 7355 | case PORT_HW_CFG_PHY_SELECTION_FIRST_PHY_PRIORITY: |
| 7356 | return_cfg = PORT_HW_CFG_PHY_SELECTION_SECOND_PHY_PRIORITY; |
| 7357 | break; |
| 7358 | case PORT_HW_CFG_PHY_SELECTION_SECOND_PHY_PRIORITY: |
| 7359 | return_cfg = PORT_HW_CFG_PHY_SELECTION_FIRST_PHY_PRIORITY; |
| 7360 | break; |
| 7361 | case PORT_HW_CFG_PHY_SELECTION_SECOND_PHY: |
| 7362 | return_cfg = PORT_HW_CFG_PHY_SELECTION_FIRST_PHY; |
| 7363 | break; |
| 7364 | case PORT_HW_CFG_PHY_SELECTION_FIRST_PHY: |
| 7365 | return_cfg = PORT_HW_CFG_PHY_SELECTION_SECOND_PHY; |
| 7366 | break; |
| 7367 | } |
| 7368 | } else |
| 7369 | return_cfg = prio_cfg; |
| 7370 | |
| 7371 | return return_cfg; |
| 7372 | } |
| 7373 | |
| 7374 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7375 | u8 bnx2x_phy_probe(struct link_params *params) |
| 7376 | { |
| 7377 | u8 phy_index, actual_phy_idx, link_cfg_idx; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7378 | u32 phy_config_swapped; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7379 | struct bnx2x *bp = params->bp; |
| 7380 | struct bnx2x_phy *phy; |
| 7381 | params->num_phys = 0; |
| 7382 | DP(NETIF_MSG_LINK, "Begin phy probe\n"); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7383 | phy_config_swapped = params->multi_phy_config & |
| 7384 | PORT_HW_CFG_PHY_SWAPPED_ENABLED; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7385 | |
| 7386 | for (phy_index = INT_PHY; phy_index < MAX_PHYS; |
| 7387 | phy_index++) { |
| 7388 | link_cfg_idx = LINK_CONFIG_IDX(phy_index); |
| 7389 | actual_phy_idx = phy_index; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7390 | if (phy_config_swapped) { |
| 7391 | if (phy_index == EXT_PHY1) |
| 7392 | actual_phy_idx = EXT_PHY2; |
| 7393 | else if (phy_index == EXT_PHY2) |
| 7394 | actual_phy_idx = EXT_PHY1; |
| 7395 | } |
| 7396 | DP(NETIF_MSG_LINK, "phy_config_swapped %x, phy_index %x," |
| 7397 | " actual_phy_idx %x\n", phy_config_swapped, |
| 7398 | phy_index, actual_phy_idx); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7399 | phy = ¶ms->phy[actual_phy_idx]; |
| 7400 | if (bnx2x_populate_phy(bp, phy_index, params->shmem_base, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7401 | params->shmem2_base, params->port, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7402 | phy) != 0) { |
| 7403 | params->num_phys = 0; |
| 7404 | DP(NETIF_MSG_LINK, "phy probe failed in phy index %d\n", |
| 7405 | phy_index); |
| 7406 | for (phy_index = INT_PHY; |
| 7407 | phy_index < MAX_PHYS; |
| 7408 | phy_index++) |
| 7409 | *phy = phy_null; |
| 7410 | return -EINVAL; |
| 7411 | } |
| 7412 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_NOT_CONN) |
| 7413 | break; |
| 7414 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7415 | bnx2x_phy_def_cfg(params, phy, phy_index); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7416 | params->num_phys++; |
| 7417 | } |
| 7418 | |
| 7419 | DP(NETIF_MSG_LINK, "End phy probe. #phys found %x\n", params->num_phys); |
| 7420 | return 0; |
| 7421 | } |
| 7422 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7423 | static void set_phy_vars(struct link_params *params) |
| 7424 | { |
| 7425 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7426 | u8 actual_phy_idx, phy_index, link_cfg_idx; |
| 7427 | u8 phy_config_swapped = params->multi_phy_config & |
| 7428 | PORT_HW_CFG_PHY_SWAPPED_ENABLED; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7429 | for (phy_index = INT_PHY; phy_index < params->num_phys; |
| 7430 | phy_index++) { |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7431 | link_cfg_idx = LINK_CONFIG_IDX(phy_index); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7432 | actual_phy_idx = phy_index; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7433 | if (phy_config_swapped) { |
| 7434 | if (phy_index == EXT_PHY1) |
| 7435 | actual_phy_idx = EXT_PHY2; |
| 7436 | else if (phy_index == EXT_PHY2) |
| 7437 | actual_phy_idx = EXT_PHY1; |
| 7438 | } |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7439 | params->phy[actual_phy_idx].req_flow_ctrl = |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7440 | params->req_flow_ctrl[link_cfg_idx]; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7441 | |
| 7442 | params->phy[actual_phy_idx].req_line_speed = |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7443 | params->req_line_speed[link_cfg_idx]; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7444 | |
| 7445 | params->phy[actual_phy_idx].speed_cap_mask = |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7446 | params->speed_cap_mask[link_cfg_idx]; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7447 | |
| 7448 | params->phy[actual_phy_idx].req_duplex = |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7449 | params->req_duplex[link_cfg_idx]; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7450 | |
| 7451 | DP(NETIF_MSG_LINK, "req_flow_ctrl %x, req_line_speed %x," |
| 7452 | " speed_cap_mask %x\n", |
| 7453 | params->phy[actual_phy_idx].req_flow_ctrl, |
| 7454 | params->phy[actual_phy_idx].req_line_speed, |
| 7455 | params->phy[actual_phy_idx].speed_cap_mask); |
| 7456 | } |
| 7457 | } |
| 7458 | |
| 7459 | u8 bnx2x_phy_init(struct link_params *params, struct link_vars *vars) |
| 7460 | { |
| 7461 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7462 | DP(NETIF_MSG_LINK, "Phy Initialization started\n"); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7463 | DP(NETIF_MSG_LINK, "(1) req_speed %d, req_flowctrl %d\n", |
| 7464 | params->req_line_speed[0], params->req_flow_ctrl[0]); |
| 7465 | DP(NETIF_MSG_LINK, "(2) req_speed %d, req_flowctrl %d\n", |
| 7466 | params->req_line_speed[1], params->req_flow_ctrl[1]); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7467 | vars->link_status = 0; |
| 7468 | vars->phy_link_up = 0; |
| 7469 | vars->link_up = 0; |
| 7470 | vars->line_speed = 0; |
| 7471 | vars->duplex = DUPLEX_FULL; |
| 7472 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 7473 | vars->mac_type = MAC_TYPE_NONE; |
| 7474 | vars->phy_flags = 0; |
| 7475 | |
| 7476 | /* disable attentions */ |
| 7477 | bnx2x_bits_dis(bp, NIG_REG_MASK_INTERRUPT_PORT0 + params->port*4, |
| 7478 | (NIG_MASK_XGXS0_LINK_STATUS | |
| 7479 | NIG_MASK_XGXS0_LINK10G | |
| 7480 | NIG_MASK_SERDES0_LINK_STATUS | |
| 7481 | NIG_MASK_MI_INT)); |
| 7482 | |
| 7483 | bnx2x_emac_init(params, vars); |
| 7484 | |
| 7485 | if (params->num_phys == 0) { |
| 7486 | DP(NETIF_MSG_LINK, "No phy found for initialization !!\n"); |
| 7487 | return -EINVAL; |
| 7488 | } |
| 7489 | set_phy_vars(params); |
| 7490 | |
| 7491 | DP(NETIF_MSG_LINK, "Num of phys on board: %d\n", params->num_phys); |
| 7492 | if (CHIP_REV_IS_FPGA(bp)) { |
| 7493 | |
| 7494 | vars->link_up = 1; |
| 7495 | vars->line_speed = SPEED_10000; |
| 7496 | vars->duplex = DUPLEX_FULL; |
| 7497 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 7498 | vars->link_status = (LINK_STATUS_LINK_UP | LINK_10GTFD); |
| 7499 | /* enable on E1.5 FPGA */ |
| 7500 | if (CHIP_IS_E1H(bp)) { |
| 7501 | vars->flow_ctrl |= |
| 7502 | (BNX2X_FLOW_CTRL_TX | |
| 7503 | BNX2X_FLOW_CTRL_RX); |
| 7504 | vars->link_status |= |
| 7505 | (LINK_STATUS_TX_FLOW_CONTROL_ENABLED | |
| 7506 | LINK_STATUS_RX_FLOW_CONTROL_ENABLED); |
| 7507 | } |
| 7508 | |
| 7509 | bnx2x_emac_enable(params, vars, 0); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 7510 | if (!(CHIP_IS_E2(bp))) |
| 7511 | bnx2x_pbf_update(params, vars->flow_ctrl, |
| 7512 | vars->line_speed); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7513 | /* disable drain */ |
| 7514 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + params->port*4, 0); |
| 7515 | |
| 7516 | /* update shared memory */ |
| 7517 | bnx2x_update_mng(params, vars->link_status); |
| 7518 | |
| 7519 | return 0; |
| 7520 | |
| 7521 | } else |
| 7522 | if (CHIP_REV_IS_EMUL(bp)) { |
| 7523 | |
| 7524 | vars->link_up = 1; |
| 7525 | vars->line_speed = SPEED_10000; |
| 7526 | vars->duplex = DUPLEX_FULL; |
| 7527 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 7528 | vars->link_status = (LINK_STATUS_LINK_UP | LINK_10GTFD); |
| 7529 | |
| 7530 | bnx2x_bmac_enable(params, vars, 0); |
| 7531 | |
| 7532 | bnx2x_pbf_update(params, vars->flow_ctrl, vars->line_speed); |
| 7533 | /* Disable drain */ |
| 7534 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE |
| 7535 | + params->port*4, 0); |
| 7536 | |
| 7537 | /* update shared memory */ |
| 7538 | bnx2x_update_mng(params, vars->link_status); |
| 7539 | |
| 7540 | return 0; |
| 7541 | |
| 7542 | } else |
| 7543 | if (params->loopback_mode == LOOPBACK_BMAC) { |
| 7544 | |
| 7545 | vars->link_up = 1; |
| 7546 | vars->line_speed = SPEED_10000; |
| 7547 | vars->duplex = DUPLEX_FULL; |
| 7548 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 7549 | vars->mac_type = MAC_TYPE_BMAC; |
| 7550 | |
| 7551 | vars->phy_flags = PHY_XGXS_FLAG; |
| 7552 | |
| 7553 | bnx2x_xgxs_deassert(params); |
| 7554 | |
| 7555 | /* set bmac loopback */ |
| 7556 | bnx2x_bmac_enable(params, vars, 1); |
| 7557 | |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7558 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + params->port*4, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7559 | |
| 7560 | } else if (params->loopback_mode == LOOPBACK_EMAC) { |
| 7561 | |
| 7562 | vars->link_up = 1; |
| 7563 | vars->line_speed = SPEED_1000; |
| 7564 | vars->duplex = DUPLEX_FULL; |
| 7565 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 7566 | vars->mac_type = MAC_TYPE_EMAC; |
| 7567 | |
| 7568 | vars->phy_flags = PHY_XGXS_FLAG; |
| 7569 | |
| 7570 | bnx2x_xgxs_deassert(params); |
| 7571 | /* set bmac loopback */ |
| 7572 | bnx2x_emac_enable(params, vars, 1); |
| 7573 | bnx2x_emac_program(params, vars); |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7574 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + params->port*4, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7575 | |
| 7576 | } else if ((params->loopback_mode == LOOPBACK_XGXS) || |
| 7577 | (params->loopback_mode == LOOPBACK_EXT_PHY)) { |
| 7578 | |
| 7579 | vars->link_up = 1; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7580 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7581 | vars->duplex = DUPLEX_FULL; |
| 7582 | if (params->req_line_speed[0] == SPEED_1000) { |
| 7583 | vars->line_speed = SPEED_1000; |
| 7584 | vars->mac_type = MAC_TYPE_EMAC; |
| 7585 | } else { |
| 7586 | vars->line_speed = SPEED_10000; |
| 7587 | vars->mac_type = MAC_TYPE_BMAC; |
| 7588 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7589 | |
| 7590 | bnx2x_xgxs_deassert(params); |
| 7591 | bnx2x_link_initialize(params, vars); |
| 7592 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7593 | if (params->req_line_speed[0] == SPEED_1000) { |
| 7594 | bnx2x_emac_program(params, vars); |
| 7595 | bnx2x_emac_enable(params, vars, 0); |
| 7596 | } else |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7597 | bnx2x_bmac_enable(params, vars, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7598 | if (params->loopback_mode == LOOPBACK_XGXS) { |
| 7599 | /* set 10G XGXS loopback */ |
| 7600 | params->phy[INT_PHY].config_loopback( |
| 7601 | ¶ms->phy[INT_PHY], |
| 7602 | params); |
| 7603 | |
| 7604 | } else { |
| 7605 | /* set external phy loopback */ |
| 7606 | u8 phy_index; |
| 7607 | for (phy_index = EXT_PHY1; |
| 7608 | phy_index < params->num_phys; phy_index++) { |
| 7609 | if (params->phy[phy_index].config_loopback) |
| 7610 | params->phy[phy_index].config_loopback( |
| 7611 | ¶ms->phy[phy_index], |
| 7612 | params); |
| 7613 | } |
| 7614 | } |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7615 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + params->port*4, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7616 | |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 7617 | bnx2x_set_led(params, vars, |
| 7618 | LED_MODE_OPER, vars->line_speed); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7619 | } else |
| 7620 | /* No loopback */ |
| 7621 | { |
| 7622 | if (params->switch_cfg == SWITCH_CFG_10G) |
| 7623 | bnx2x_xgxs_deassert(params); |
| 7624 | else |
| 7625 | bnx2x_serdes_deassert(bp, params->port); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 7626 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7627 | bnx2x_link_initialize(params, vars); |
| 7628 | msleep(30); |
| 7629 | bnx2x_link_int_enable(params); |
| 7630 | } |
| 7631 | return 0; |
| 7632 | } |
| 7633 | u8 bnx2x_link_reset(struct link_params *params, struct link_vars *vars, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7634 | u8 reset_ext_phy) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7635 | { |
| 7636 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | cf1d972 | 2010-11-01 05:32:34 +0000 | [diff] [blame] | 7637 | u8 phy_index, port = params->port, clear_latch_ind = 0; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7638 | DP(NETIF_MSG_LINK, "Resetting the link of port %d\n", port); |
| 7639 | /* disable attentions */ |
| 7640 | vars->link_status = 0; |
| 7641 | bnx2x_update_mng(params, vars->link_status); |
| 7642 | bnx2x_bits_dis(bp, NIG_REG_MASK_INTERRUPT_PORT0 + port*4, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7643 | (NIG_MASK_XGXS0_LINK_STATUS | |
| 7644 | NIG_MASK_XGXS0_LINK10G | |
| 7645 | NIG_MASK_SERDES0_LINK_STATUS | |
| 7646 | NIG_MASK_MI_INT)); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7647 | |
| 7648 | /* activate nig drain */ |
| 7649 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + port*4, 1); |
| 7650 | |
| 7651 | /* disable nig egress interface */ |
| 7652 | REG_WR(bp, NIG_REG_BMAC0_OUT_EN + port*4, 0); |
| 7653 | REG_WR(bp, NIG_REG_EGRESS_EMAC0_OUT_EN + port*4, 0); |
| 7654 | |
| 7655 | /* Stop BigMac rx */ |
| 7656 | bnx2x_bmac_rx_disable(bp, port); |
| 7657 | |
| 7658 | /* disable emac */ |
| 7659 | REG_WR(bp, NIG_REG_NIG_EMAC0_EN + port*4, 0); |
| 7660 | |
| 7661 | msleep(10); |
| 7662 | /* The PHY reset is controled by GPIO 1 |
| 7663 | * Hold it as vars low |
| 7664 | */ |
| 7665 | /* clear link led */ |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 7666 | bnx2x_set_led(params, vars, LED_MODE_OFF, 0); |
| 7667 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7668 | if (reset_ext_phy) { |
| 7669 | for (phy_index = EXT_PHY1; phy_index < params->num_phys; |
| 7670 | phy_index++) { |
| 7671 | if (params->phy[phy_index].link_reset) |
| 7672 | params->phy[phy_index].link_reset( |
| 7673 | ¶ms->phy[phy_index], |
| 7674 | params); |
Yaniv Rosner | cf1d972 | 2010-11-01 05:32:34 +0000 | [diff] [blame] | 7675 | if (params->phy[phy_index].flags & |
| 7676 | FLAGS_REARM_LATCH_SIGNAL) |
| 7677 | clear_latch_ind = 1; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7678 | } |
| 7679 | } |
| 7680 | |
Yaniv Rosner | cf1d972 | 2010-11-01 05:32:34 +0000 | [diff] [blame] | 7681 | if (clear_latch_ind) { |
| 7682 | /* Clear latching indication */ |
| 7683 | bnx2x_rearm_latch_signal(bp, port, 0); |
| 7684 | bnx2x_bits_dis(bp, NIG_REG_LATCH_BC_0 + port*4, |
| 7685 | 1 << NIG_LATCH_BC_ENABLE_MI_INT); |
| 7686 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7687 | if (params->phy[INT_PHY].link_reset) |
| 7688 | params->phy[INT_PHY].link_reset( |
| 7689 | ¶ms->phy[INT_PHY], params); |
| 7690 | /* reset BigMac */ |
| 7691 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_CLEAR, |
| 7692 | (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << port)); |
| 7693 | |
| 7694 | /* disable nig ingress interface */ |
| 7695 | REG_WR(bp, NIG_REG_BMAC0_IN_EN + port*4, 0); |
| 7696 | REG_WR(bp, NIG_REG_EMAC0_IN_EN + port*4, 0); |
| 7697 | REG_WR(bp, NIG_REG_BMAC0_OUT_EN + port*4, 0); |
| 7698 | REG_WR(bp, NIG_REG_EGRESS_EMAC0_OUT_EN + port*4, 0); |
| 7699 | vars->link_up = 0; |
| 7700 | return 0; |
| 7701 | } |
| 7702 | |
| 7703 | /****************************************************************************/ |
| 7704 | /* Common function */ |
| 7705 | /****************************************************************************/ |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 7706 | static u8 bnx2x_8073_common_init_phy(struct bnx2x *bp, |
| 7707 | u32 shmem_base_path[], |
| 7708 | u32 shmem2_base_path[], u8 phy_index, |
| 7709 | u32 chip_id) |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 7710 | { |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 7711 | struct bnx2x_phy phy[PORT_MAX]; |
| 7712 | struct bnx2x_phy *phy_blk[PORT_MAX]; |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 7713 | u16 val; |
Yaniv Rosner | c8e64df | 2011-01-30 04:15:00 +0000 | [diff] [blame] | 7714 | s8 port = 0; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 7715 | s8 port_of_path = 0; |
Yaniv Rosner | c8e64df | 2011-01-30 04:15:00 +0000 | [diff] [blame] | 7716 | u32 swap_val, swap_override; |
| 7717 | swap_val = REG_RD(bp, NIG_REG_PORT_SWAP); |
| 7718 | swap_override = REG_RD(bp, NIG_REG_STRAP_OVERRIDE); |
| 7719 | port ^= (swap_val && swap_override); |
| 7720 | bnx2x_ext_phy_hw_reset(bp, port); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 7721 | /* PART1 - Reset both phys */ |
| 7722 | for (port = PORT_MAX - 1; port >= PORT_0; port--) { |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 7723 | u32 shmem_base, shmem2_base; |
| 7724 | /* In E2, same phy is using for port0 of the two paths */ |
| 7725 | if (CHIP_IS_E2(bp)) { |
| 7726 | shmem_base = shmem_base_path[port]; |
| 7727 | shmem2_base = shmem2_base_path[port]; |
| 7728 | port_of_path = 0; |
| 7729 | } else { |
| 7730 | shmem_base = shmem_base_path[0]; |
| 7731 | shmem2_base = shmem2_base_path[0]; |
| 7732 | port_of_path = port; |
| 7733 | } |
| 7734 | |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 7735 | /* Extract the ext phy address for the port */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7736 | if (bnx2x_populate_phy(bp, phy_index, shmem_base, shmem2_base, |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 7737 | port_of_path, &phy[port]) != |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 7738 | 0) { |
| 7739 | DP(NETIF_MSG_LINK, "populate_phy failed\n"); |
| 7740 | return -EINVAL; |
| 7741 | } |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 7742 | /* disable attentions */ |
Yaniv Rosner | 6a71bbe | 2010-11-01 05:32:31 +0000 | [diff] [blame] | 7743 | bnx2x_bits_dis(bp, NIG_REG_MASK_INTERRUPT_PORT0 + |
| 7744 | port_of_path*4, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7745 | (NIG_MASK_XGXS0_LINK_STATUS | |
| 7746 | NIG_MASK_XGXS0_LINK10G | |
| 7747 | NIG_MASK_SERDES0_LINK_STATUS | |
| 7748 | NIG_MASK_MI_INT)); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 7749 | |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 7750 | /* Need to take the phy out of low power mode in order |
| 7751 | to write to access its registers */ |
| 7752 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7753 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, |
| 7754 | port); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 7755 | |
| 7756 | /* Reset the phy */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 7757 | bnx2x_cl45_write(bp, &phy[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7758 | MDIO_PMA_DEVAD, |
| 7759 | MDIO_PMA_REG_CTRL, |
| 7760 | 1<<15); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 7761 | } |
| 7762 | |
| 7763 | /* Add delay of 150ms after reset */ |
| 7764 | msleep(150); |
| 7765 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 7766 | if (phy[PORT_0].addr & 0x1) { |
| 7767 | phy_blk[PORT_0] = &(phy[PORT_1]); |
| 7768 | phy_blk[PORT_1] = &(phy[PORT_0]); |
| 7769 | } else { |
| 7770 | phy_blk[PORT_0] = &(phy[PORT_0]); |
| 7771 | phy_blk[PORT_1] = &(phy[PORT_1]); |
| 7772 | } |
| 7773 | |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 7774 | /* PART2 - Download firmware to both phys */ |
| 7775 | for (port = PORT_MAX - 1; port >= PORT_0; port--) { |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 7776 | if (CHIP_IS_E2(bp)) |
| 7777 | port_of_path = 0; |
| 7778 | else |
| 7779 | port_of_path = port; |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 7780 | |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 7781 | DP(NETIF_MSG_LINK, "Loading spirom for phy address 0x%x\n", |
| 7782 | phy_blk[port]->addr); |
Yaniv Rosner | 5c99274b | 2011-01-18 04:33:36 +0000 | [diff] [blame] | 7783 | if (bnx2x_8073_8727_external_rom_boot(bp, phy_blk[port], |
| 7784 | port_of_path)) |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 7785 | return -EINVAL; |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 7786 | |
| 7787 | /* Only set bit 10 = 1 (Tx power down) */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 7788 | bnx2x_cl45_read(bp, phy_blk[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7789 | MDIO_PMA_DEVAD, |
| 7790 | MDIO_PMA_REG_TX_POWER_DOWN, &val); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 7791 | |
| 7792 | /* Phase1 of TX_POWER_DOWN reset */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 7793 | bnx2x_cl45_write(bp, phy_blk[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7794 | MDIO_PMA_DEVAD, |
| 7795 | MDIO_PMA_REG_TX_POWER_DOWN, |
| 7796 | (val | 1<<10)); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 7797 | } |
| 7798 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7799 | /* |
| 7800 | * Toggle Transmitter: Power down and then up with 600ms delay |
| 7801 | * between |
| 7802 | */ |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 7803 | msleep(600); |
| 7804 | |
| 7805 | /* PART3 - complete TX_POWER_DOWN process, and set GPIO2 back to low */ |
| 7806 | for (port = PORT_MAX - 1; port >= PORT_0; port--) { |
Eilon Greenstein | f537225 | 2009-02-12 08:38:30 +0000 | [diff] [blame] | 7807 | /* Phase2 of POWER_DOWN_RESET */ |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 7808 | /* Release bit 10 (Release Tx power down) */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 7809 | bnx2x_cl45_read(bp, phy_blk[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7810 | MDIO_PMA_DEVAD, |
| 7811 | MDIO_PMA_REG_TX_POWER_DOWN, &val); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 7812 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 7813 | bnx2x_cl45_write(bp, phy_blk[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7814 | MDIO_PMA_DEVAD, |
| 7815 | MDIO_PMA_REG_TX_POWER_DOWN, (val & (~(1<<10)))); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 7816 | msleep(15); |
| 7817 | |
| 7818 | /* Read modify write the SPI-ROM version select register */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 7819 | bnx2x_cl45_read(bp, phy_blk[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7820 | MDIO_PMA_DEVAD, |
| 7821 | MDIO_PMA_REG_EDC_FFE_MAIN, &val); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 7822 | bnx2x_cl45_write(bp, phy_blk[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7823 | MDIO_PMA_DEVAD, |
| 7824 | MDIO_PMA_REG_EDC_FFE_MAIN, (val | (1<<12))); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 7825 | |
| 7826 | /* set GPIO2 back to LOW */ |
| 7827 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7828 | MISC_REGISTERS_GPIO_OUTPUT_LOW, port); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 7829 | } |
| 7830 | return 0; |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 7831 | } |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 7832 | static u8 bnx2x_8726_common_init_phy(struct bnx2x *bp, |
| 7833 | u32 shmem_base_path[], |
| 7834 | u32 shmem2_base_path[], u8 phy_index, |
| 7835 | u32 chip_id) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7836 | { |
| 7837 | u32 val; |
| 7838 | s8 port; |
| 7839 | struct bnx2x_phy phy; |
| 7840 | /* Use port1 because of the static port-swap */ |
| 7841 | /* Enable the module detection interrupt */ |
| 7842 | val = REG_RD(bp, MISC_REG_GPIO_EVENT_EN); |
| 7843 | val |= ((1<<MISC_REGISTERS_GPIO_3)| |
| 7844 | (1<<(MISC_REGISTERS_GPIO_3 + MISC_REGISTERS_GPIO_PORT_SHIFT))); |
| 7845 | REG_WR(bp, MISC_REG_GPIO_EVENT_EN, val); |
| 7846 | |
Yaniv Rosner | 650154b | 2010-11-01 05:32:36 +0000 | [diff] [blame] | 7847 | bnx2x_ext_phy_hw_reset(bp, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7848 | msleep(5); |
| 7849 | for (port = 0; port < PORT_MAX; port++) { |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 7850 | u32 shmem_base, shmem2_base; |
| 7851 | |
| 7852 | /* In E2, same phy is using for port0 of the two paths */ |
| 7853 | if (CHIP_IS_E2(bp)) { |
| 7854 | shmem_base = shmem_base_path[port]; |
| 7855 | shmem2_base = shmem2_base_path[port]; |
| 7856 | } else { |
| 7857 | shmem_base = shmem_base_path[0]; |
| 7858 | shmem2_base = shmem2_base_path[0]; |
| 7859 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7860 | /* Extract the ext phy address for the port */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7861 | if (bnx2x_populate_phy(bp, phy_index, shmem_base, shmem2_base, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7862 | port, &phy) != |
| 7863 | 0) { |
| 7864 | DP(NETIF_MSG_LINK, "populate phy failed\n"); |
| 7865 | return -EINVAL; |
| 7866 | } |
| 7867 | |
| 7868 | /* Reset phy*/ |
| 7869 | bnx2x_cl45_write(bp, &phy, |
| 7870 | MDIO_PMA_DEVAD, MDIO_PMA_REG_GEN_CTRL, 0x0001); |
| 7871 | |
| 7872 | |
| 7873 | /* Set fault module detected LED on */ |
| 7874 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_0, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7875 | MISC_REGISTERS_GPIO_HIGH, |
| 7876 | port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7877 | } |
| 7878 | |
| 7879 | return 0; |
| 7880 | } |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 7881 | static u8 bnx2x_8727_common_init_phy(struct bnx2x *bp, |
| 7882 | u32 shmem_base_path[], |
| 7883 | u32 shmem2_base_path[], u8 phy_index, |
| 7884 | u32 chip_id) |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 7885 | { |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7886 | s8 port; |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 7887 | u32 swap_val, swap_override; |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 7888 | struct bnx2x_phy phy[PORT_MAX]; |
| 7889 | struct bnx2x_phy *phy_blk[PORT_MAX]; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 7890 | s8 port_of_path; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7891 | swap_val = REG_RD(bp, NIG_REG_PORT_SWAP); |
| 7892 | swap_override = REG_RD(bp, NIG_REG_STRAP_OVERRIDE); |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 7893 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7894 | port = 1; |
| 7895 | |
| 7896 | bnx2x_ext_phy_hw_reset(bp, port ^ (swap_val && swap_override)); |
| 7897 | |
| 7898 | /* Calculate the port based on port swap */ |
| 7899 | port ^= (swap_val && swap_override); |
| 7900 | |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 7901 | msleep(5); |
| 7902 | |
| 7903 | /* PART1 - Reset both phys */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7904 | for (port = PORT_MAX - 1; port >= PORT_0; port--) { |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 7905 | u32 shmem_base, shmem2_base; |
| 7906 | |
| 7907 | /* In E2, same phy is using for port0 of the two paths */ |
| 7908 | if (CHIP_IS_E2(bp)) { |
| 7909 | shmem_base = shmem_base_path[port]; |
| 7910 | shmem2_base = shmem2_base_path[port]; |
| 7911 | port_of_path = 0; |
| 7912 | } else { |
| 7913 | shmem_base = shmem_base_path[0]; |
| 7914 | shmem2_base = shmem2_base_path[0]; |
| 7915 | port_of_path = port; |
| 7916 | } |
| 7917 | |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 7918 | /* Extract the ext phy address for the port */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7919 | if (bnx2x_populate_phy(bp, phy_index, shmem_base, shmem2_base, |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 7920 | port_of_path, &phy[port]) != |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 7921 | 0) { |
| 7922 | DP(NETIF_MSG_LINK, "populate phy failed\n"); |
| 7923 | return -EINVAL; |
| 7924 | } |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 7925 | /* disable attentions */ |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 7926 | bnx2x_bits_dis(bp, NIG_REG_MASK_INTERRUPT_PORT0 + |
| 7927 | port_of_path*4, |
| 7928 | (NIG_MASK_XGXS0_LINK_STATUS | |
| 7929 | NIG_MASK_XGXS0_LINK10G | |
| 7930 | NIG_MASK_SERDES0_LINK_STATUS | |
| 7931 | NIG_MASK_MI_INT)); |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 7932 | |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 7933 | |
| 7934 | /* Reset the phy */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 7935 | bnx2x_cl45_write(bp, &phy[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7936 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 1<<15); |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 7937 | } |
| 7938 | |
| 7939 | /* Add delay of 150ms after reset */ |
| 7940 | msleep(150); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 7941 | if (phy[PORT_0].addr & 0x1) { |
| 7942 | phy_blk[PORT_0] = &(phy[PORT_1]); |
| 7943 | phy_blk[PORT_1] = &(phy[PORT_0]); |
| 7944 | } else { |
| 7945 | phy_blk[PORT_0] = &(phy[PORT_0]); |
| 7946 | phy_blk[PORT_1] = &(phy[PORT_1]); |
| 7947 | } |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 7948 | /* PART2 - Download firmware to both phys */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 7949 | for (port = PORT_MAX - 1; port >= PORT_0; port--) { |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7950 | if (CHIP_IS_E2(bp)) |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 7951 | port_of_path = 0; |
| 7952 | else |
| 7953 | port_of_path = port; |
| 7954 | DP(NETIF_MSG_LINK, "Loading spirom for phy address 0x%x\n", |
| 7955 | phy_blk[port]->addr); |
Yaniv Rosner | 5c99274b | 2011-01-18 04:33:36 +0000 | [diff] [blame] | 7956 | if (bnx2x_8073_8727_external_rom_boot(bp, phy_blk[port], |
| 7957 | port_of_path)) |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 7958 | return -EINVAL; |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 7959 | |
Yaniv Rosner | 5c99274b | 2011-01-18 04:33:36 +0000 | [diff] [blame] | 7960 | } |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 7961 | return 0; |
| 7962 | } |
| 7963 | |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 7964 | static u8 bnx2x_ext_phy_common_init(struct bnx2x *bp, u32 shmem_base_path[], |
| 7965 | u32 shmem2_base_path[], u8 phy_index, |
| 7966 | u32 ext_phy_type, u32 chip_id) |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 7967 | { |
| 7968 | u8 rc = 0; |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 7969 | |
| 7970 | switch (ext_phy_type) { |
| 7971 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073: |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 7972 | rc = bnx2x_8073_common_init_phy(bp, shmem_base_path, |
| 7973 | shmem2_base_path, |
| 7974 | phy_index, chip_id); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 7975 | break; |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 7976 | |
| 7977 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727: |
| 7978 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727_NOC: |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 7979 | rc = bnx2x_8727_common_init_phy(bp, shmem_base_path, |
| 7980 | shmem2_base_path, |
| 7981 | phy_index, chip_id); |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 7982 | break; |
| 7983 | |
Eilon Greenstein | 589abe3 | 2009-02-12 08:36:55 +0000 | [diff] [blame] | 7984 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726: |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7985 | /* |
| 7986 | * GPIO1 affects both ports, so there's need to pull |
| 7987 | * it for single port alone |
| 7988 | */ |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 7989 | rc = bnx2x_8726_common_init_phy(bp, shmem_base_path, |
| 7990 | shmem2_base_path, |
| 7991 | phy_index, chip_id); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7992 | break; |
| 7993 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_FAILURE: |
| 7994 | rc = -EINVAL; |
Yaniv Rosner | 4f60dab | 2009-11-05 19:18:23 +0200 | [diff] [blame] | 7995 | break; |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 7996 | default: |
| 7997 | DP(NETIF_MSG_LINK, |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7998 | "ext_phy 0x%x common init not required\n", |
| 7999 | ext_phy_type); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 8000 | break; |
| 8001 | } |
| 8002 | |
| 8003 | return rc; |
| 8004 | } |
| 8005 | |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 8006 | u8 bnx2x_common_init_phy(struct bnx2x *bp, u32 shmem_base_path[], |
| 8007 | u32 shmem2_base_path[], u32 chip_id) |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8008 | { |
| 8009 | u8 rc = 0; |
Yaniv Rosner | b21a342 | 2011-01-18 04:33:24 +0000 | [diff] [blame] | 8010 | u32 phy_ver; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8011 | u8 phy_index; |
| 8012 | u32 ext_phy_type, ext_phy_config; |
| 8013 | DP(NETIF_MSG_LINK, "Begin common phy init\n"); |
Yaniv Rosner | d90d96b | 2010-09-07 11:41:04 +0000 | [diff] [blame] | 8014 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8015 | if (CHIP_REV_IS_EMUL(bp)) |
| 8016 | return 0; |
| 8017 | |
Yaniv Rosner | b21a342 | 2011-01-18 04:33:24 +0000 | [diff] [blame] | 8018 | /* Check if common init was already done */ |
| 8019 | phy_ver = REG_RD(bp, shmem_base_path[0] + |
| 8020 | offsetof(struct shmem_region, |
| 8021 | port_mb[PORT_0].ext_phy_fw_version)); |
| 8022 | if (phy_ver) { |
| 8023 | DP(NETIF_MSG_LINK, "Not doing common init; phy ver is 0x%x\n", |
| 8024 | phy_ver); |
| 8025 | return 0; |
| 8026 | } |
| 8027 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8028 | /* Read the ext_phy_type for arbitrary port(0) */ |
| 8029 | for (phy_index = EXT_PHY1; phy_index < MAX_PHYS; |
| 8030 | phy_index++) { |
| 8031 | ext_phy_config = bnx2x_get_ext_phy_config(bp, |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 8032 | shmem_base_path[0], |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8033 | phy_index, 0); |
| 8034 | ext_phy_type = XGXS_EXT_PHY_TYPE(ext_phy_config); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 8035 | rc |= bnx2x_ext_phy_common_init(bp, shmem_base_path, |
| 8036 | shmem2_base_path, |
| 8037 | phy_index, ext_phy_type, |
| 8038 | chip_id); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8039 | } |
| 8040 | return rc; |
| 8041 | } |
| 8042 | |
| 8043 | 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] | 8044 | { |
| 8045 | u8 phy_index; |
| 8046 | struct bnx2x_phy phy; |
| 8047 | for (phy_index = INT_PHY; phy_index < MAX_PHYS; |
| 8048 | phy_index++) { |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8049 | if (bnx2x_populate_phy(bp, phy_index, shmem_base, shmem2_base, |
Yaniv Rosner | d90d96b | 2010-09-07 11:41:04 +0000 | [diff] [blame] | 8050 | 0, &phy) != 0) { |
| 8051 | DP(NETIF_MSG_LINK, "populate phy failed\n"); |
| 8052 | return 0; |
| 8053 | } |
| 8054 | |
| 8055 | if (phy.flags & FLAGS_HW_LOCK_REQUIRED) |
| 8056 | return 1; |
| 8057 | } |
| 8058 | return 0; |
| 8059 | } |
| 8060 | |
| 8061 | u8 bnx2x_fan_failure_det_req(struct bnx2x *bp, |
| 8062 | u32 shmem_base, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8063 | u32 shmem2_base, |
Yaniv Rosner | d90d96b | 2010-09-07 11:41:04 +0000 | [diff] [blame] | 8064 | u8 port) |
| 8065 | { |
| 8066 | u8 phy_index, fan_failure_det_req = 0; |
| 8067 | struct bnx2x_phy phy; |
| 8068 | for (phy_index = EXT_PHY1; phy_index < MAX_PHYS; |
| 8069 | phy_index++) { |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8070 | if (bnx2x_populate_phy(bp, phy_index, shmem_base, shmem2_base, |
Yaniv Rosner | d90d96b | 2010-09-07 11:41:04 +0000 | [diff] [blame] | 8071 | port, &phy) |
| 8072 | != 0) { |
| 8073 | DP(NETIF_MSG_LINK, "populate phy failed\n"); |
| 8074 | return 0; |
| 8075 | } |
| 8076 | fan_failure_det_req |= (phy.flags & |
| 8077 | FLAGS_FAN_FAILURE_DET_REQ); |
| 8078 | } |
| 8079 | return fan_failure_det_req; |
| 8080 | } |
| 8081 | |
| 8082 | void bnx2x_hw_reset_phy(struct link_params *params) |
| 8083 | { |
| 8084 | u8 phy_index; |
| 8085 | for (phy_index = EXT_PHY1; phy_index < MAX_PHYS; |
| 8086 | phy_index++) { |
| 8087 | if (params->phy[phy_index].hw_reset) { |
| 8088 | params->phy[phy_index].hw_reset( |
| 8089 | ¶ms->phy[phy_index], |
| 8090 | params); |
| 8091 | params->phy[phy_index] = phy_null; |
| 8092 | } |
| 8093 | } |
| 8094 | } |