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 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 345 | int bnx2x_ets_strict(const struct link_params *params, const u8 strict_cos) |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 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 | /******************************************************************/ |
Dmitry Kravkov | e892067 | 2011-05-04 23:52:40 +0000 | [diff] [blame] | 388 | /* PFC section */ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 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 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 511 | static int bnx2x_emac_enable(struct link_params *params, |
| 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 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 524 | /* ASIC */ |
| 525 | if (vars->phy_flags & PHY_XGXS_FLAG) { |
| 526 | u32 ser_lane = ((params->lane_config & |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 527 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_MASK) >> |
| 528 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_SHIFT); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 529 | |
| 530 | DP(NETIF_MSG_LINK, "XGXS\n"); |
| 531 | /* select the master lanes (out of 0-3) */ |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 532 | 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] | 533 | /* select XGXS */ |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 534 | REG_WR(bp, NIG_REG_XGXS_SERDES0_MODE_SEL + port*4, 1); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 535 | |
| 536 | } else { /* SerDes */ |
| 537 | DP(NETIF_MSG_LINK, "SerDes\n"); |
| 538 | /* select SerDes */ |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 539 | REG_WR(bp, NIG_REG_XGXS_SERDES0_MODE_SEL + port*4, 0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 540 | } |
| 541 | |
Eilon Greenstein | 811a2f2 | 2009-02-12 08:37:04 +0000 | [diff] [blame] | 542 | bnx2x_bits_en(bp, emac_base + EMAC_REG_EMAC_RX_MODE, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 543 | EMAC_RX_MODE_RESET); |
Eilon Greenstein | 811a2f2 | 2009-02-12 08:37:04 +0000 | [diff] [blame] | 544 | bnx2x_bits_en(bp, emac_base + EMAC_REG_EMAC_TX_MODE, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 545 | EMAC_TX_MODE_RESET); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 546 | |
| 547 | if (CHIP_REV_IS_SLOW(bp)) { |
| 548 | /* config GMII mode */ |
| 549 | val = REG_RD(bp, emac_base + EMAC_REG_EMAC_MODE); |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 550 | EMAC_WR(bp, EMAC_REG_EMAC_MODE, (val | EMAC_MODE_PORT_GMII)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 551 | } else { /* ASIC */ |
| 552 | /* pause enable/disable */ |
| 553 | bnx2x_bits_dis(bp, emac_base + EMAC_REG_EMAC_RX_MODE, |
| 554 | EMAC_RX_MODE_FLOW_EN); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 555 | |
| 556 | bnx2x_bits_dis(bp, emac_base + EMAC_REG_EMAC_TX_MODE, |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 557 | (EMAC_TX_MODE_EXT_PAUSE_EN | |
| 558 | EMAC_TX_MODE_FLOW_EN)); |
| 559 | if (!(params->feature_config_flags & |
| 560 | FEATURE_CONFIG_PFC_ENABLED)) { |
| 561 | if (vars->flow_ctrl & BNX2X_FLOW_CTRL_RX) |
| 562 | bnx2x_bits_en(bp, emac_base + |
| 563 | EMAC_REG_EMAC_RX_MODE, |
| 564 | EMAC_RX_MODE_FLOW_EN); |
| 565 | |
| 566 | if (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX) |
| 567 | bnx2x_bits_en(bp, emac_base + |
| 568 | EMAC_REG_EMAC_TX_MODE, |
| 569 | (EMAC_TX_MODE_EXT_PAUSE_EN | |
| 570 | EMAC_TX_MODE_FLOW_EN)); |
| 571 | } else |
| 572 | bnx2x_bits_en(bp, emac_base + EMAC_REG_EMAC_TX_MODE, |
| 573 | EMAC_TX_MODE_FLOW_EN); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 574 | } |
| 575 | |
| 576 | /* KEEP_VLAN_TAG, promiscuous */ |
| 577 | val = REG_RD(bp, emac_base + EMAC_REG_EMAC_RX_MODE); |
| 578 | val |= EMAC_RX_MODE_KEEP_VLAN_TAG | EMAC_RX_MODE_PROMISCUOUS; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 579 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 580 | /* |
| 581 | * Setting this bit causes MAC control frames (except for pause |
| 582 | * frames) to be passed on for processing. This setting has no |
| 583 | * affect on the operation of the pause frames. This bit effects |
| 584 | * all packets regardless of RX Parser packet sorting logic. |
| 585 | * Turn the PFC off to make sure we are in Xon state before |
| 586 | * enabling it. |
| 587 | */ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 588 | EMAC_WR(bp, EMAC_REG_RX_PFC_MODE, 0); |
| 589 | if (params->feature_config_flags & FEATURE_CONFIG_PFC_ENABLED) { |
| 590 | DP(NETIF_MSG_LINK, "PFC is enabled\n"); |
| 591 | /* Enable PFC again */ |
| 592 | EMAC_WR(bp, EMAC_REG_RX_PFC_MODE, |
| 593 | EMAC_REG_RX_PFC_MODE_RX_EN | |
| 594 | EMAC_REG_RX_PFC_MODE_TX_EN | |
| 595 | EMAC_REG_RX_PFC_MODE_PRIORITIES); |
| 596 | |
| 597 | EMAC_WR(bp, EMAC_REG_RX_PFC_PARAM, |
| 598 | ((0x0101 << |
| 599 | EMAC_REG_RX_PFC_PARAM_OPCODE_BITSHIFT) | |
| 600 | (0x00ff << |
| 601 | EMAC_REG_RX_PFC_PARAM_PRIORITY_EN_BITSHIFT))); |
| 602 | val |= EMAC_RX_MODE_KEEP_MAC_CONTROL; |
| 603 | } |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 604 | EMAC_WR(bp, EMAC_REG_EMAC_RX_MODE, val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 605 | |
| 606 | /* Set Loopback */ |
| 607 | val = REG_RD(bp, emac_base + EMAC_REG_EMAC_MODE); |
| 608 | if (lb) |
| 609 | val |= 0x810; |
| 610 | else |
| 611 | val &= ~0x810; |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 612 | EMAC_WR(bp, EMAC_REG_EMAC_MODE, val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 613 | |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 614 | /* enable emac */ |
| 615 | REG_WR(bp, NIG_REG_NIG_EMAC0_EN + port*4, 1); |
| 616 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 617 | /* enable emac for jumbo packets */ |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 618 | EMAC_WR(bp, EMAC_REG_EMAC_RX_MTU_SIZE, |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 619 | (EMAC_RX_MTU_SIZE_JUMBO_ENA | |
| 620 | (ETH_MAX_JUMBO_PACKET_SIZE + ETH_OVREHEAD))); |
| 621 | |
| 622 | /* strip CRC */ |
| 623 | REG_WR(bp, NIG_REG_NIG_INGRESS_EMAC0_NO_CRC + port*4, 0x1); |
| 624 | |
| 625 | /* disable the NIG in/out to the bmac */ |
| 626 | REG_WR(bp, NIG_REG_BMAC0_IN_EN + port*4, 0x0); |
| 627 | REG_WR(bp, NIG_REG_BMAC0_PAUSE_OUT_EN + port*4, 0x0); |
| 628 | REG_WR(bp, NIG_REG_BMAC0_OUT_EN + port*4, 0x0); |
| 629 | |
| 630 | /* enable the NIG in/out to the emac */ |
| 631 | REG_WR(bp, NIG_REG_EMAC0_IN_EN + port*4, 0x1); |
| 632 | val = 0; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 633 | if ((params->feature_config_flags & |
| 634 | FEATURE_CONFIG_PFC_ENABLED) || |
| 635 | (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX)) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 636 | val = 1; |
| 637 | |
| 638 | REG_WR(bp, NIG_REG_EMAC0_PAUSE_OUT_EN + port*4, val); |
| 639 | REG_WR(bp, NIG_REG_EGRESS_EMAC0_OUT_EN + port*4, 0x1); |
| 640 | |
Yaniv Rosner | 02a2316 | 2011-01-31 04:22:53 +0000 | [diff] [blame] | 641 | REG_WR(bp, NIG_REG_BMAC0_REGS_OUT_EN + port*4, 0x0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 642 | |
| 643 | vars->mac_type = MAC_TYPE_EMAC; |
| 644 | return 0; |
| 645 | } |
| 646 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 647 | static void bnx2x_update_pfc_bmac1(struct link_params *params, |
| 648 | struct link_vars *vars) |
| 649 | { |
| 650 | u32 wb_data[2]; |
| 651 | struct bnx2x *bp = params->bp; |
| 652 | u32 bmac_addr = params->port ? NIG_REG_INGRESS_BMAC1_MEM : |
| 653 | NIG_REG_INGRESS_BMAC0_MEM; |
| 654 | |
| 655 | u32 val = 0x14; |
| 656 | if ((!(params->feature_config_flags & |
| 657 | FEATURE_CONFIG_PFC_ENABLED)) && |
| 658 | (vars->flow_ctrl & BNX2X_FLOW_CTRL_RX)) |
| 659 | /* Enable BigMAC to react on received Pause packets */ |
| 660 | val |= (1<<5); |
| 661 | wb_data[0] = val; |
| 662 | wb_data[1] = 0; |
| 663 | REG_WR_DMAE(bp, bmac_addr + BIGMAC_REGISTER_RX_CONTROL, wb_data, 2); |
| 664 | |
| 665 | /* tx control */ |
| 666 | val = 0xc0; |
| 667 | if (!(params->feature_config_flags & |
| 668 | FEATURE_CONFIG_PFC_ENABLED) && |
| 669 | (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX)) |
| 670 | val |= 0x800000; |
| 671 | wb_data[0] = val; |
| 672 | wb_data[1] = 0; |
| 673 | REG_WR_DMAE(bp, bmac_addr + BIGMAC_REGISTER_TX_CONTROL, wb_data, 2); |
| 674 | } |
| 675 | |
| 676 | static void bnx2x_update_pfc_bmac2(struct link_params *params, |
| 677 | struct link_vars *vars, |
| 678 | u8 is_lb) |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 679 | { |
| 680 | /* |
| 681 | * Set rx control: Strip CRC and enable BigMAC to relay |
| 682 | * control packets to the system as well |
| 683 | */ |
| 684 | u32 wb_data[2]; |
| 685 | struct bnx2x *bp = params->bp; |
| 686 | u32 bmac_addr = params->port ? NIG_REG_INGRESS_BMAC1_MEM : |
| 687 | NIG_REG_INGRESS_BMAC0_MEM; |
| 688 | u32 val = 0x14; |
| 689 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 690 | if ((!(params->feature_config_flags & |
| 691 | FEATURE_CONFIG_PFC_ENABLED)) && |
| 692 | (vars->flow_ctrl & BNX2X_FLOW_CTRL_RX)) |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 693 | /* Enable BigMAC to react on received Pause packets */ |
| 694 | val |= (1<<5); |
| 695 | wb_data[0] = val; |
| 696 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 697 | 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] | 698 | udelay(30); |
| 699 | |
| 700 | /* Tx control */ |
| 701 | val = 0xc0; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 702 | if (!(params->feature_config_flags & |
| 703 | FEATURE_CONFIG_PFC_ENABLED) && |
| 704 | (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX)) |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 705 | val |= 0x800000; |
| 706 | wb_data[0] = val; |
| 707 | wb_data[1] = 0; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 708 | 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] | 709 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 710 | if (params->feature_config_flags & FEATURE_CONFIG_PFC_ENABLED) { |
| 711 | DP(NETIF_MSG_LINK, "PFC is enabled\n"); |
| 712 | /* Enable PFC RX & TX & STATS and set 8 COS */ |
| 713 | wb_data[0] = 0x0; |
| 714 | wb_data[0] |= (1<<0); /* RX */ |
| 715 | wb_data[0] |= (1<<1); /* TX */ |
| 716 | wb_data[0] |= (1<<2); /* Force initial Xon */ |
| 717 | wb_data[0] |= (1<<3); /* 8 cos */ |
| 718 | wb_data[0] |= (1<<5); /* STATS */ |
| 719 | wb_data[1] = 0; |
| 720 | REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_PFC_CONTROL, |
| 721 | wb_data, 2); |
| 722 | /* Clear the force Xon */ |
| 723 | wb_data[0] &= ~(1<<2); |
| 724 | } else { |
| 725 | DP(NETIF_MSG_LINK, "PFC is disabled\n"); |
| 726 | /* disable PFC RX & TX & STATS and set 8 COS */ |
| 727 | wb_data[0] = 0x8; |
| 728 | wb_data[1] = 0; |
| 729 | } |
| 730 | |
| 731 | REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_PFC_CONTROL, wb_data, 2); |
| 732 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 733 | /* |
| 734 | * Set Time (based unit is 512 bit time) between automatic |
| 735 | * re-sending of PP packets amd enable automatic re-send of |
| 736 | * Per-Priroity Packet as long as pp_gen is asserted and |
| 737 | * pp_disable is low. |
| 738 | */ |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 739 | val = 0x8000; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 740 | if (params->feature_config_flags & FEATURE_CONFIG_PFC_ENABLED) |
| 741 | val |= (1<<16); /* enable automatic re-send */ |
| 742 | |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 743 | wb_data[0] = val; |
| 744 | wb_data[1] = 0; |
| 745 | REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_TX_PAUSE_CONTROL, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 746 | wb_data, 2); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 747 | |
| 748 | /* mac control */ |
| 749 | val = 0x3; /* Enable RX and TX */ |
| 750 | if (is_lb) { |
| 751 | val |= 0x4; /* Local loopback */ |
| 752 | DP(NETIF_MSG_LINK, "enable bmac loopback\n"); |
| 753 | } |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 754 | /* When PFC enabled, Pass pause frames towards the NIG. */ |
| 755 | if (params->feature_config_flags & FEATURE_CONFIG_PFC_ENABLED) |
| 756 | val |= ((1<<6)|(1<<5)); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 757 | |
| 758 | wb_data[0] = val; |
| 759 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 760 | 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] | 761 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 762 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 763 | static void bnx2x_update_pfc_brb(struct link_params *params, |
| 764 | struct link_vars *vars, |
| 765 | struct bnx2x_nig_brb_pfc_port_params *pfc_params) |
| 766 | { |
| 767 | struct bnx2x *bp = params->bp; |
| 768 | int set_pfc = params->feature_config_flags & |
| 769 | FEATURE_CONFIG_PFC_ENABLED; |
| 770 | |
| 771 | /* default - pause configuration */ |
| 772 | u32 pause_xoff_th = PFC_BRB_MAC_PAUSE_XOFF_THRESHOLD_PAUSEABLE; |
| 773 | u32 pause_xon_th = PFC_BRB_MAC_PAUSE_XON_THRESHOLD_PAUSEABLE; |
| 774 | u32 full_xoff_th = PFC_BRB_MAC_FULL_XOFF_THRESHOLD_PAUSEABLE; |
| 775 | u32 full_xon_th = PFC_BRB_MAC_FULL_XON_THRESHOLD_PAUSEABLE; |
| 776 | |
| 777 | if (set_pfc && pfc_params) |
| 778 | /* First COS */ |
| 779 | if (!pfc_params->cos0_pauseable) { |
| 780 | pause_xoff_th = |
| 781 | PFC_BRB_MAC_PAUSE_XOFF_THRESHOLD_NON_PAUSEABLE; |
| 782 | pause_xon_th = |
| 783 | PFC_BRB_MAC_PAUSE_XON_THRESHOLD_NON_PAUSEABLE; |
| 784 | full_xoff_th = |
| 785 | PFC_BRB_MAC_FULL_XOFF_THRESHOLD_NON_PAUSEABLE; |
| 786 | full_xon_th = |
| 787 | PFC_BRB_MAC_FULL_XON_THRESHOLD_NON_PAUSEABLE; |
| 788 | } |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 789 | /* |
| 790 | * The number of free blocks below which the pause signal to class 0 |
| 791 | * of MAC #n is asserted. n=0,1 |
| 792 | */ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 793 | 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] | 794 | /* |
| 795 | * The number of free blocks above which the pause signal to class 0 |
| 796 | * of MAC #n is de-asserted. n=0,1 |
| 797 | */ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 798 | 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] | 799 | /* |
| 800 | * The number of free blocks below which the full signal to class 0 |
| 801 | * of MAC #n is asserted. n=0,1 |
| 802 | */ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 803 | 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] | 804 | /* |
| 805 | * The number of free blocks above which the full signal to class 0 |
| 806 | * of MAC #n is de-asserted. n=0,1 |
| 807 | */ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 808 | REG_WR(bp, BRB1_REG_FULL_0_XON_THRESHOLD_0 , full_xon_th); |
| 809 | |
| 810 | if (set_pfc && pfc_params) { |
| 811 | /* Second COS */ |
| 812 | if (pfc_params->cos1_pauseable) { |
| 813 | pause_xoff_th = |
| 814 | PFC_BRB_MAC_PAUSE_XOFF_THRESHOLD_PAUSEABLE; |
| 815 | pause_xon_th = |
| 816 | PFC_BRB_MAC_PAUSE_XON_THRESHOLD_PAUSEABLE; |
| 817 | full_xoff_th = |
| 818 | PFC_BRB_MAC_FULL_XOFF_THRESHOLD_PAUSEABLE; |
| 819 | full_xon_th = |
| 820 | PFC_BRB_MAC_FULL_XON_THRESHOLD_PAUSEABLE; |
| 821 | } else { |
| 822 | pause_xoff_th = |
| 823 | PFC_BRB_MAC_PAUSE_XOFF_THRESHOLD_NON_PAUSEABLE; |
| 824 | pause_xon_th = |
| 825 | PFC_BRB_MAC_PAUSE_XON_THRESHOLD_NON_PAUSEABLE; |
| 826 | full_xoff_th = |
| 827 | PFC_BRB_MAC_FULL_XOFF_THRESHOLD_NON_PAUSEABLE; |
| 828 | full_xon_th = |
| 829 | PFC_BRB_MAC_FULL_XON_THRESHOLD_NON_PAUSEABLE; |
| 830 | } |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 831 | /* |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 832 | * The number of free blocks below which the pause signal to |
| 833 | * class 1 of MAC #n is asserted. n=0,1 |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 834 | */ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 835 | 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] | 836 | /* |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 837 | * The number of free blocks above which the pause signal to |
| 838 | * class 1 of MAC #n is de-asserted. n=0,1 |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 839 | */ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 840 | 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] | 841 | /* |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 842 | * The number of free blocks below which the full signal to |
| 843 | * class 1 of MAC #n is asserted. n=0,1 |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 844 | */ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 845 | 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] | 846 | /* |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 847 | * The number of free blocks above which the full signal to |
| 848 | * class 1 of MAC #n is de-asserted. n=0,1 |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 849 | */ |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 850 | REG_WR(bp, BRB1_REG_FULL_1_XON_THRESHOLD_0, full_xon_th); |
| 851 | } |
| 852 | } |
| 853 | |
| 854 | static void bnx2x_update_pfc_nig(struct link_params *params, |
| 855 | struct link_vars *vars, |
| 856 | struct bnx2x_nig_brb_pfc_port_params *nig_params) |
| 857 | { |
| 858 | u32 xcm_mask = 0, ppp_enable = 0, pause_enable = 0, llfc_out_en = 0; |
| 859 | u32 llfc_enable = 0, xcm0_out_en = 0, p0_hwpfc_enable = 0; |
| 860 | u32 pkt_priority_to_cos = 0; |
| 861 | u32 val; |
| 862 | struct bnx2x *bp = params->bp; |
| 863 | int port = params->port; |
| 864 | int set_pfc = params->feature_config_flags & |
| 865 | FEATURE_CONFIG_PFC_ENABLED; |
| 866 | DP(NETIF_MSG_LINK, "updating pfc nig parameters\n"); |
| 867 | |
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 | * When NIG_LLH0_XCM_MASK_REG_LLHX_XCM_MASK_BCN bit is set |
| 870 | * MAC control frames (that are not pause packets) |
| 871 | * will be forwarded to the XCM. |
| 872 | */ |
| 873 | xcm_mask = REG_RD(bp, |
| 874 | port ? NIG_REG_LLH1_XCM_MASK : |
| 875 | NIG_REG_LLH0_XCM_MASK); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 876 | /* |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 877 | * nig params will override non PFC params, since it's possible to |
| 878 | * do transition from PFC to SAFC |
| 879 | */ |
| 880 | if (set_pfc) { |
| 881 | pause_enable = 0; |
| 882 | llfc_out_en = 0; |
| 883 | llfc_enable = 0; |
| 884 | ppp_enable = 1; |
| 885 | xcm_mask &= ~(port ? NIG_LLH1_XCM_MASK_REG_LLH1_XCM_MASK_BCN : |
| 886 | NIG_LLH0_XCM_MASK_REG_LLH0_XCM_MASK_BCN); |
| 887 | xcm0_out_en = 0; |
| 888 | p0_hwpfc_enable = 1; |
| 889 | } else { |
| 890 | if (nig_params) { |
| 891 | llfc_out_en = nig_params->llfc_out_en; |
| 892 | llfc_enable = nig_params->llfc_enable; |
| 893 | pause_enable = nig_params->pause_enable; |
| 894 | } else /*defaul non PFC mode - PAUSE */ |
| 895 | pause_enable = 1; |
| 896 | |
| 897 | xcm_mask |= (port ? NIG_LLH1_XCM_MASK_REG_LLH1_XCM_MASK_BCN : |
| 898 | NIG_LLH0_XCM_MASK_REG_LLH0_XCM_MASK_BCN); |
| 899 | xcm0_out_en = 1; |
| 900 | } |
| 901 | |
| 902 | REG_WR(bp, port ? NIG_REG_LLFC_OUT_EN_1 : |
| 903 | NIG_REG_LLFC_OUT_EN_0, llfc_out_en); |
| 904 | REG_WR(bp, port ? NIG_REG_LLFC_ENABLE_1 : |
| 905 | NIG_REG_LLFC_ENABLE_0, llfc_enable); |
| 906 | REG_WR(bp, port ? NIG_REG_PAUSE_ENABLE_1 : |
| 907 | NIG_REG_PAUSE_ENABLE_0, pause_enable); |
| 908 | |
| 909 | REG_WR(bp, port ? NIG_REG_PPP_ENABLE_1 : |
| 910 | NIG_REG_PPP_ENABLE_0, ppp_enable); |
| 911 | |
| 912 | REG_WR(bp, port ? NIG_REG_LLH1_XCM_MASK : |
| 913 | NIG_REG_LLH0_XCM_MASK, xcm_mask); |
| 914 | |
| 915 | REG_WR(bp, NIG_REG_LLFC_EGRESS_SRC_ENABLE_0, 0x7); |
| 916 | |
| 917 | /* output enable for RX_XCM # IF */ |
| 918 | REG_WR(bp, NIG_REG_XCM0_OUT_EN, xcm0_out_en); |
| 919 | |
| 920 | /* HW PFC TX enable */ |
| 921 | REG_WR(bp, NIG_REG_P0_HWPFC_ENABLE, p0_hwpfc_enable); |
| 922 | |
| 923 | /* 0x2 = BMAC, 0x1= EMAC */ |
| 924 | switch (vars->mac_type) { |
| 925 | case MAC_TYPE_EMAC: |
| 926 | val = 1; |
| 927 | break; |
| 928 | case MAC_TYPE_BMAC: |
| 929 | val = 0; |
| 930 | break; |
| 931 | default: |
| 932 | val = 0; |
| 933 | break; |
| 934 | } |
| 935 | REG_WR(bp, NIG_REG_EGRESS_EMAC0_PORT, val); |
| 936 | |
| 937 | if (nig_params) { |
| 938 | pkt_priority_to_cos = nig_params->pkt_priority_to_cos; |
| 939 | |
| 940 | REG_WR(bp, port ? NIG_REG_P1_RX_COS0_PRIORITY_MASK : |
| 941 | NIG_REG_P0_RX_COS0_PRIORITY_MASK, |
| 942 | nig_params->rx_cos0_priority_mask); |
| 943 | |
| 944 | REG_WR(bp, port ? NIG_REG_P1_RX_COS1_PRIORITY_MASK : |
| 945 | NIG_REG_P0_RX_COS1_PRIORITY_MASK, |
| 946 | nig_params->rx_cos1_priority_mask); |
| 947 | |
| 948 | REG_WR(bp, port ? NIG_REG_LLFC_HIGH_PRIORITY_CLASSES_1 : |
| 949 | NIG_REG_LLFC_HIGH_PRIORITY_CLASSES_0, |
| 950 | nig_params->llfc_high_priority_classes); |
| 951 | |
| 952 | REG_WR(bp, port ? NIG_REG_LLFC_LOW_PRIORITY_CLASSES_1 : |
| 953 | NIG_REG_LLFC_LOW_PRIORITY_CLASSES_0, |
| 954 | nig_params->llfc_low_priority_classes); |
| 955 | } |
| 956 | REG_WR(bp, port ? NIG_REG_P1_PKT_PRIORITY_TO_COS : |
| 957 | NIG_REG_P0_PKT_PRIORITY_TO_COS, |
| 958 | pkt_priority_to_cos); |
| 959 | } |
| 960 | |
| 961 | |
| 962 | void bnx2x_update_pfc(struct link_params *params, |
| 963 | struct link_vars *vars, |
| 964 | struct bnx2x_nig_brb_pfc_port_params *pfc_params) |
| 965 | { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 966 | /* |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 967 | * The PFC and pause are orthogonal to one another, meaning when |
| 968 | * PFC is enabled, the pause are disabled, and when PFC is |
| 969 | * disabled, pause are set according to the pause result. |
| 970 | */ |
| 971 | u32 val; |
| 972 | struct bnx2x *bp = params->bp; |
| 973 | |
| 974 | /* update NIG params */ |
| 975 | bnx2x_update_pfc_nig(params, vars, pfc_params); |
| 976 | |
| 977 | /* update BRB params */ |
| 978 | bnx2x_update_pfc_brb(params, vars, pfc_params); |
| 979 | |
| 980 | if (!vars->link_up) |
| 981 | return; |
| 982 | |
| 983 | val = REG_RD(bp, MISC_REG_RESET_REG_2); |
| 984 | if ((val & (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << params->port)) |
| 985 | == 0) { |
| 986 | DP(NETIF_MSG_LINK, "About to update PFC in EMAC\n"); |
| 987 | bnx2x_emac_enable(params, vars, 0); |
| 988 | return; |
| 989 | } |
| 990 | |
| 991 | DP(NETIF_MSG_LINK, "About to update PFC in BMAC\n"); |
| 992 | if (CHIP_IS_E2(bp)) |
| 993 | bnx2x_update_pfc_bmac2(params, vars, 0); |
| 994 | else |
| 995 | bnx2x_update_pfc_bmac1(params, vars); |
| 996 | |
| 997 | val = 0; |
| 998 | if ((params->feature_config_flags & |
| 999 | FEATURE_CONFIG_PFC_ENABLED) || |
| 1000 | (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX)) |
| 1001 | val = 1; |
| 1002 | REG_WR(bp, NIG_REG_BMAC0_PAUSE_OUT_EN + params->port*4, val); |
| 1003 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1004 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 1005 | static int bnx2x_bmac1_enable(struct link_params *params, |
| 1006 | struct link_vars *vars, |
| 1007 | u8 is_lb) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1008 | { |
| 1009 | struct bnx2x *bp = params->bp; |
| 1010 | u8 port = params->port; |
| 1011 | u32 bmac_addr = port ? NIG_REG_INGRESS_BMAC1_MEM : |
| 1012 | NIG_REG_INGRESS_BMAC0_MEM; |
| 1013 | u32 wb_data[2]; |
| 1014 | u32 val; |
| 1015 | |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1016 | DP(NETIF_MSG_LINK, "Enabling BigMAC1\n"); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1017 | |
| 1018 | /* XGXS control */ |
| 1019 | wb_data[0] = 0x3c; |
| 1020 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1021 | REG_WR_DMAE(bp, bmac_addr + BIGMAC_REGISTER_BMAC_XGXS_CONTROL, |
| 1022 | wb_data, 2); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1023 | |
| 1024 | /* tx MAC SA */ |
| 1025 | wb_data[0] = ((params->mac_addr[2] << 24) | |
| 1026 | (params->mac_addr[3] << 16) | |
| 1027 | (params->mac_addr[4] << 8) | |
| 1028 | params->mac_addr[5]); |
| 1029 | wb_data[1] = ((params->mac_addr[0] << 8) | |
| 1030 | params->mac_addr[1]); |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1031 | 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] | 1032 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1033 | /* mac control */ |
| 1034 | val = 0x3; |
| 1035 | if (is_lb) { |
| 1036 | val |= 0x4; |
| 1037 | DP(NETIF_MSG_LINK, "enable bmac loopback\n"); |
| 1038 | } |
| 1039 | wb_data[0] = val; |
| 1040 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1041 | 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] | 1042 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1043 | /* set rx mtu */ |
| 1044 | wb_data[0] = ETH_MAX_JUMBO_PACKET_SIZE + ETH_OVREHEAD; |
| 1045 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1046 | 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] | 1047 | |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1048 | bnx2x_update_pfc_bmac1(params, vars); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1049 | |
| 1050 | /* set tx mtu */ |
| 1051 | wb_data[0] = ETH_MAX_JUMBO_PACKET_SIZE + ETH_OVREHEAD; |
| 1052 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1053 | 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] | 1054 | |
| 1055 | /* set cnt max size */ |
| 1056 | wb_data[0] = ETH_MAX_JUMBO_PACKET_SIZE + ETH_OVREHEAD; |
| 1057 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1058 | 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] | 1059 | |
| 1060 | /* configure safc */ |
| 1061 | wb_data[0] = 0x1000200; |
| 1062 | wb_data[1] = 0; |
| 1063 | REG_WR_DMAE(bp, bmac_addr + BIGMAC_REGISTER_RX_LLFC_MSG_FLDS, |
| 1064 | wb_data, 2); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1065 | |
| 1066 | return 0; |
| 1067 | } |
| 1068 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 1069 | static int bnx2x_bmac2_enable(struct link_params *params, |
| 1070 | struct link_vars *vars, |
| 1071 | u8 is_lb) |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1072 | { |
| 1073 | struct bnx2x *bp = params->bp; |
| 1074 | u8 port = params->port; |
| 1075 | u32 bmac_addr = port ? NIG_REG_INGRESS_BMAC1_MEM : |
| 1076 | NIG_REG_INGRESS_BMAC0_MEM; |
| 1077 | u32 wb_data[2]; |
| 1078 | |
| 1079 | DP(NETIF_MSG_LINK, "Enabling BigMAC2\n"); |
| 1080 | |
| 1081 | wb_data[0] = 0; |
| 1082 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1083 | 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] | 1084 | udelay(30); |
| 1085 | |
| 1086 | /* XGXS control: Reset phy HW, MDIO registers, PHY PLL and BMAC */ |
| 1087 | wb_data[0] = 0x3c; |
| 1088 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1089 | REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_BMAC_XGXS_CONTROL, |
| 1090 | wb_data, 2); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1091 | |
| 1092 | udelay(30); |
| 1093 | |
| 1094 | /* tx MAC SA */ |
| 1095 | wb_data[0] = ((params->mac_addr[2] << 24) | |
| 1096 | (params->mac_addr[3] << 16) | |
| 1097 | (params->mac_addr[4] << 8) | |
| 1098 | params->mac_addr[5]); |
| 1099 | wb_data[1] = ((params->mac_addr[0] << 8) | |
| 1100 | params->mac_addr[1]); |
| 1101 | REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_TX_SOURCE_ADDR, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1102 | wb_data, 2); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1103 | |
| 1104 | udelay(30); |
| 1105 | |
| 1106 | /* Configure SAFC */ |
| 1107 | wb_data[0] = 0x1000200; |
| 1108 | wb_data[1] = 0; |
| 1109 | REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_RX_LLFC_MSG_FLDS, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1110 | wb_data, 2); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1111 | udelay(30); |
| 1112 | |
| 1113 | /* set rx mtu */ |
| 1114 | wb_data[0] = ETH_MAX_JUMBO_PACKET_SIZE + ETH_OVREHEAD; |
| 1115 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1116 | 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] | 1117 | udelay(30); |
| 1118 | |
| 1119 | /* set tx mtu */ |
| 1120 | wb_data[0] = ETH_MAX_JUMBO_PACKET_SIZE + ETH_OVREHEAD; |
| 1121 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1122 | 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] | 1123 | udelay(30); |
| 1124 | /* set cnt max size */ |
| 1125 | wb_data[0] = ETH_MAX_JUMBO_PACKET_SIZE + ETH_OVREHEAD - 2; |
| 1126 | wb_data[1] = 0; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1127 | 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] | 1128 | udelay(30); |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1129 | bnx2x_update_pfc_bmac2(params, vars, is_lb); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1130 | |
| 1131 | return 0; |
| 1132 | } |
| 1133 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 1134 | static int bnx2x_bmac_enable(struct link_params *params, |
| 1135 | struct link_vars *vars, |
| 1136 | u8 is_lb) |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1137 | { |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 1138 | int rc = 0; |
| 1139 | u8 port = params->port; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1140 | struct bnx2x *bp = params->bp; |
| 1141 | u32 val; |
| 1142 | /* reset and unreset the BigMac */ |
| 1143 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_CLEAR, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1144 | (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << port)); |
Yaniv Rosner | 1d9c05d | 2010-11-01 05:32:25 +0000 | [diff] [blame] | 1145 | msleep(1); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1146 | |
| 1147 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_SET, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1148 | (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << port)); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1149 | |
| 1150 | /* enable access for bmac registers */ |
| 1151 | REG_WR(bp, NIG_REG_BMAC0_REGS_OUT_EN + port*4, 0x1); |
| 1152 | |
| 1153 | /* Enable BMAC according to BMAC type*/ |
| 1154 | if (CHIP_IS_E2(bp)) |
| 1155 | rc = bnx2x_bmac2_enable(params, vars, is_lb); |
| 1156 | else |
| 1157 | rc = bnx2x_bmac1_enable(params, vars, is_lb); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1158 | REG_WR(bp, NIG_REG_XGXS_SERDES0_MODE_SEL + port*4, 0x1); |
| 1159 | REG_WR(bp, NIG_REG_XGXS_LANE_SEL_P0 + port*4, 0x0); |
| 1160 | REG_WR(bp, NIG_REG_EGRESS_EMAC0_PORT + port*4, 0x0); |
| 1161 | val = 0; |
Vladislav Zolotarov | bcab15c | 2010-12-13 05:44:25 +0000 | [diff] [blame] | 1162 | if ((params->feature_config_flags & |
| 1163 | FEATURE_CONFIG_PFC_ENABLED) || |
| 1164 | (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX)) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1165 | val = 1; |
| 1166 | REG_WR(bp, NIG_REG_BMAC0_PAUSE_OUT_EN + port*4, val); |
| 1167 | REG_WR(bp, NIG_REG_EGRESS_EMAC0_OUT_EN + port*4, 0x0); |
| 1168 | REG_WR(bp, NIG_REG_EMAC0_IN_EN + port*4, 0x0); |
| 1169 | REG_WR(bp, NIG_REG_EMAC0_PAUSE_OUT_EN + port*4, 0x0); |
| 1170 | REG_WR(bp, NIG_REG_BMAC0_IN_EN + port*4, 0x1); |
| 1171 | REG_WR(bp, NIG_REG_BMAC0_OUT_EN + port*4, 0x1); |
| 1172 | |
| 1173 | vars->mac_type = MAC_TYPE_BMAC; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1174 | return rc; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1175 | } |
| 1176 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1177 | |
| 1178 | static void bnx2x_update_mng(struct link_params *params, u32 link_status) |
| 1179 | { |
| 1180 | struct bnx2x *bp = params->bp; |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 1181 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1182 | REG_WR(bp, params->shmem_base + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1183 | offsetof(struct shmem_region, |
| 1184 | port_mb[params->port].link_status), link_status); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1185 | } |
| 1186 | |
| 1187 | static void bnx2x_bmac_rx_disable(struct bnx2x *bp, u8 port) |
| 1188 | { |
| 1189 | u32 bmac_addr = port ? NIG_REG_INGRESS_BMAC1_MEM : |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1190 | NIG_REG_INGRESS_BMAC0_MEM; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1191 | u32 wb_data[2]; |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 1192 | 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] | 1193 | |
| 1194 | /* Only if the bmac is out of reset */ |
| 1195 | if (REG_RD(bp, MISC_REG_RESET_REG_2) & |
| 1196 | (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << port) && |
| 1197 | nig_bmac_enable) { |
| 1198 | |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1199 | if (CHIP_IS_E2(bp)) { |
| 1200 | /* Clear Rx Enable bit in BMAC_CONTROL register */ |
| 1201 | REG_RD_DMAE(bp, bmac_addr + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1202 | BIGMAC2_REGISTER_BMAC_CONTROL, |
| 1203 | wb_data, 2); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1204 | wb_data[0] &= ~BMAC_CONTROL_RX_ENABLE; |
| 1205 | REG_WR_DMAE(bp, bmac_addr + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1206 | BIGMAC2_REGISTER_BMAC_CONTROL, |
| 1207 | wb_data, 2); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1208 | } else { |
| 1209 | /* Clear Rx Enable bit in BMAC_CONTROL register */ |
| 1210 | REG_RD_DMAE(bp, bmac_addr + |
| 1211 | BIGMAC_REGISTER_BMAC_CONTROL, |
| 1212 | wb_data, 2); |
| 1213 | wb_data[0] &= ~BMAC_CONTROL_RX_ENABLE; |
| 1214 | REG_WR_DMAE(bp, bmac_addr + |
| 1215 | BIGMAC_REGISTER_BMAC_CONTROL, |
| 1216 | wb_data, 2); |
| 1217 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1218 | msleep(1); |
| 1219 | } |
| 1220 | } |
| 1221 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 1222 | static int bnx2x_pbf_update(struct link_params *params, u32 flow_ctrl, |
| 1223 | u32 line_speed) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1224 | { |
| 1225 | struct bnx2x *bp = params->bp; |
| 1226 | u8 port = params->port; |
| 1227 | u32 init_crd, crd; |
| 1228 | u32 count = 1000; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1229 | |
| 1230 | /* disable port */ |
| 1231 | REG_WR(bp, PBF_REG_DISABLE_NEW_TASK_PROC_P0 + port*4, 0x1); |
| 1232 | |
| 1233 | /* wait for init credit */ |
| 1234 | init_crd = REG_RD(bp, PBF_REG_P0_INIT_CRD + port*4); |
| 1235 | crd = REG_RD(bp, PBF_REG_P0_CREDIT + port*8); |
| 1236 | DP(NETIF_MSG_LINK, "init_crd 0x%x crd 0x%x\n", init_crd, crd); |
| 1237 | |
| 1238 | while ((init_crd != crd) && count) { |
| 1239 | msleep(5); |
| 1240 | |
| 1241 | crd = REG_RD(bp, PBF_REG_P0_CREDIT + port*8); |
| 1242 | count--; |
| 1243 | } |
| 1244 | crd = REG_RD(bp, PBF_REG_P0_CREDIT + port*8); |
| 1245 | if (init_crd != crd) { |
| 1246 | DP(NETIF_MSG_LINK, "BUG! init_crd 0x%x != crd 0x%x\n", |
| 1247 | init_crd, crd); |
| 1248 | return -EINVAL; |
| 1249 | } |
| 1250 | |
David S. Miller | c0700f9 | 2008-12-16 23:53:20 -0800 | [diff] [blame] | 1251 | if (flow_ctrl & BNX2X_FLOW_CTRL_RX || |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 1252 | line_speed == SPEED_10 || |
| 1253 | line_speed == SPEED_100 || |
| 1254 | line_speed == SPEED_1000 || |
| 1255 | line_speed == SPEED_2500) { |
| 1256 | REG_WR(bp, PBF_REG_P0_PAUSE_ENABLE + port*4, 1); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1257 | /* update threshold */ |
| 1258 | REG_WR(bp, PBF_REG_P0_ARB_THRSH + port*4, 0); |
| 1259 | /* update init credit */ |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1260 | init_crd = 778; /* (800-18-4) */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1261 | |
| 1262 | } else { |
| 1263 | u32 thresh = (ETH_MAX_JUMBO_PACKET_SIZE + |
| 1264 | ETH_OVREHEAD)/16; |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 1265 | REG_WR(bp, PBF_REG_P0_PAUSE_ENABLE + port*4, 0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1266 | /* update threshold */ |
| 1267 | REG_WR(bp, PBF_REG_P0_ARB_THRSH + port*4, thresh); |
| 1268 | /* update init credit */ |
| 1269 | switch (line_speed) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1270 | case SPEED_10000: |
| 1271 | init_crd = thresh + 553 - 22; |
| 1272 | break; |
| 1273 | |
| 1274 | case SPEED_12000: |
| 1275 | init_crd = thresh + 664 - 22; |
| 1276 | break; |
| 1277 | |
| 1278 | case SPEED_13000: |
| 1279 | init_crd = thresh + 742 - 22; |
| 1280 | break; |
| 1281 | |
| 1282 | case SPEED_16000: |
| 1283 | init_crd = thresh + 778 - 22; |
| 1284 | break; |
| 1285 | default: |
| 1286 | DP(NETIF_MSG_LINK, "Invalid line_speed 0x%x\n", |
| 1287 | line_speed); |
| 1288 | return -EINVAL; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1289 | } |
| 1290 | } |
| 1291 | REG_WR(bp, PBF_REG_P0_INIT_CRD + port*4, init_crd); |
| 1292 | DP(NETIF_MSG_LINK, "PBF updated to speed %d credit %d\n", |
| 1293 | line_speed, init_crd); |
| 1294 | |
| 1295 | /* probe the credit changes */ |
| 1296 | REG_WR(bp, PBF_REG_INIT_P0 + port*4, 0x1); |
| 1297 | msleep(5); |
| 1298 | REG_WR(bp, PBF_REG_INIT_P0 + port*4, 0x0); |
| 1299 | |
| 1300 | /* enable port */ |
| 1301 | REG_WR(bp, PBF_REG_DISABLE_NEW_TASK_PROC_P0 + port*4, 0x0); |
| 1302 | return 0; |
| 1303 | } |
| 1304 | |
Dmitry Kravkov | e892067 | 2011-05-04 23:52:40 +0000 | [diff] [blame] | 1305 | /** |
| 1306 | * bnx2x_get_emac_base - retrive emac base address |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 1307 | * |
Dmitry Kravkov | e892067 | 2011-05-04 23:52:40 +0000 | [diff] [blame] | 1308 | * @bp: driver handle |
| 1309 | * @mdc_mdio_access: access type |
| 1310 | * @port: port id |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 1311 | * |
| 1312 | * This function selects the MDC/MDIO access (through emac0 or |
| 1313 | * emac1) depend on the mdc_mdio_access, port, port swapped. Each |
| 1314 | * phy has a default access mode, which could also be overridden |
| 1315 | * by nvram configuration. This parameter, whether this is the |
| 1316 | * default phy configuration, or the nvram overrun |
| 1317 | * configuration, is passed here as mdc_mdio_access and selects |
| 1318 | * the emac_base for the CL45 read/writes operations |
| 1319 | */ |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 1320 | static u32 bnx2x_get_emac_base(struct bnx2x *bp, |
| 1321 | u32 mdc_mdio_access, u8 port) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1322 | { |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 1323 | u32 emac_base = 0; |
| 1324 | switch (mdc_mdio_access) { |
| 1325 | case SHARED_HW_CFG_MDC_MDIO_ACCESS1_PHY_TYPE: |
| 1326 | break; |
| 1327 | case SHARED_HW_CFG_MDC_MDIO_ACCESS1_EMAC0: |
| 1328 | if (REG_RD(bp, NIG_REG_PORT_SWAP)) |
| 1329 | emac_base = GRCBASE_EMAC1; |
| 1330 | else |
| 1331 | emac_base = GRCBASE_EMAC0; |
| 1332 | break; |
| 1333 | case SHARED_HW_CFG_MDC_MDIO_ACCESS1_EMAC1: |
Eilon Greenstein | 589abe3 | 2009-02-12 08:36:55 +0000 | [diff] [blame] | 1334 | if (REG_RD(bp, NIG_REG_PORT_SWAP)) |
| 1335 | emac_base = GRCBASE_EMAC0; |
| 1336 | else |
| 1337 | emac_base = GRCBASE_EMAC1; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1338 | break; |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 1339 | case SHARED_HW_CFG_MDC_MDIO_ACCESS1_BOTH: |
| 1340 | emac_base = (port) ? GRCBASE_EMAC1 : GRCBASE_EMAC0; |
| 1341 | break; |
| 1342 | case SHARED_HW_CFG_MDC_MDIO_ACCESS1_SWAPPED: |
Eilon Greenstein | 6378c02 | 2008-08-13 15:59:25 -0700 | [diff] [blame] | 1343 | emac_base = (port) ? GRCBASE_EMAC0 : GRCBASE_EMAC1; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1344 | break; |
| 1345 | default: |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1346 | break; |
| 1347 | } |
| 1348 | return emac_base; |
| 1349 | |
| 1350 | } |
| 1351 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 1352 | /******************************************************************/ |
| 1353 | /* CL45 access functions */ |
| 1354 | /******************************************************************/ |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 1355 | static int bnx2x_cl45_write(struct bnx2x *bp, struct bnx2x_phy *phy, |
| 1356 | u8 devad, u16 reg, u16 val) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1357 | { |
| 1358 | u32 tmp, saved_mode; |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 1359 | u8 i; |
| 1360 | int rc = 0; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 1361 | /* |
| 1362 | * Set clause 45 mode, slow down the MDIO clock to 2.5MHz |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1363 | * (a value of 49==0x31) and make sure that the AUTO poll is off |
| 1364 | */ |
Eilon Greenstein | 589abe3 | 2009-02-12 08:36:55 +0000 | [diff] [blame] | 1365 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1366 | 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] | 1367 | tmp = saved_mode & ~(EMAC_MDIO_MODE_AUTO_POLL | |
| 1368 | EMAC_MDIO_MODE_CLOCK_CNT); |
| 1369 | tmp |= (EMAC_MDIO_MODE_CLAUSE_45 | |
| 1370 | (49 << EMAC_MDIO_MODE_CLOCK_CNT_BITSHIFT)); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1371 | REG_WR(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_MODE, tmp); |
| 1372 | REG_RD(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_MODE); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1373 | udelay(40); |
| 1374 | |
| 1375 | /* address */ |
| 1376 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1377 | tmp = ((phy->addr << 21) | (devad << 16) | reg | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1378 | EMAC_MDIO_COMM_COMMAND_ADDRESS | |
| 1379 | EMAC_MDIO_COMM_START_BUSY); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1380 | REG_WR(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM, tmp); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1381 | |
| 1382 | for (i = 0; i < 50; i++) { |
| 1383 | udelay(10); |
| 1384 | |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1385 | tmp = REG_RD(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1386 | if (!(tmp & EMAC_MDIO_COMM_START_BUSY)) { |
| 1387 | udelay(5); |
| 1388 | break; |
| 1389 | } |
| 1390 | } |
| 1391 | if (tmp & EMAC_MDIO_COMM_START_BUSY) { |
| 1392 | DP(NETIF_MSG_LINK, "write phy register failed\n"); |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 1393 | netdev_err(bp->dev, "MDC/MDIO access timeout\n"); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1394 | rc = -EFAULT; |
| 1395 | } else { |
| 1396 | /* data */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1397 | tmp = ((phy->addr << 21) | (devad << 16) | val | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1398 | EMAC_MDIO_COMM_COMMAND_WRITE_45 | |
| 1399 | EMAC_MDIO_COMM_START_BUSY); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1400 | REG_WR(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM, tmp); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1401 | |
| 1402 | for (i = 0; i < 50; i++) { |
| 1403 | udelay(10); |
| 1404 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1405 | tmp = REG_RD(bp, phy->mdio_ctrl + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1406 | EMAC_REG_EMAC_MDIO_COMM); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1407 | if (!(tmp & EMAC_MDIO_COMM_START_BUSY)) { |
| 1408 | udelay(5); |
| 1409 | break; |
| 1410 | } |
| 1411 | } |
| 1412 | if (tmp & EMAC_MDIO_COMM_START_BUSY) { |
| 1413 | DP(NETIF_MSG_LINK, "write phy register failed\n"); |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 1414 | netdev_err(bp->dev, "MDC/MDIO access timeout\n"); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1415 | rc = -EFAULT; |
| 1416 | } |
| 1417 | } |
| 1418 | |
| 1419 | /* Restore the saved mode */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1420 | 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] | 1421 | |
| 1422 | return rc; |
| 1423 | } |
| 1424 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 1425 | static int bnx2x_cl45_read(struct bnx2x *bp, struct bnx2x_phy *phy, |
| 1426 | u8 devad, u16 reg, u16 *ret_val) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1427 | { |
| 1428 | u32 val, saved_mode; |
| 1429 | u16 i; |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 1430 | int rc = 0; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 1431 | /* |
| 1432 | * Set clause 45 mode, slow down the MDIO clock to 2.5MHz |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1433 | * (a value of 49==0x31) and make sure that the AUTO poll is off |
| 1434 | */ |
Eilon Greenstein | 589abe3 | 2009-02-12 08:36:55 +0000 | [diff] [blame] | 1435 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1436 | saved_mode = REG_RD(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_MODE); |
| 1437 | val = saved_mode & ~((EMAC_MDIO_MODE_AUTO_POLL | |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1438 | EMAC_MDIO_MODE_CLOCK_CNT)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1439 | val |= (EMAC_MDIO_MODE_CLAUSE_45 | |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 1440 | (49L << EMAC_MDIO_MODE_CLOCK_CNT_BITSHIFT)); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1441 | REG_WR(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_MODE, val); |
| 1442 | REG_RD(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_MODE); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1443 | udelay(40); |
| 1444 | |
| 1445 | /* address */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1446 | val = ((phy->addr << 21) | (devad << 16) | reg | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1447 | EMAC_MDIO_COMM_COMMAND_ADDRESS | |
| 1448 | EMAC_MDIO_COMM_START_BUSY); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1449 | REG_WR(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM, val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1450 | |
| 1451 | for (i = 0; i < 50; i++) { |
| 1452 | udelay(10); |
| 1453 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1454 | val = REG_RD(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1455 | if (!(val & EMAC_MDIO_COMM_START_BUSY)) { |
| 1456 | udelay(5); |
| 1457 | break; |
| 1458 | } |
| 1459 | } |
| 1460 | if (val & EMAC_MDIO_COMM_START_BUSY) { |
| 1461 | DP(NETIF_MSG_LINK, "read phy register failed\n"); |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 1462 | netdev_err(bp->dev, "MDC/MDIO access timeout\n"); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1463 | *ret_val = 0; |
| 1464 | rc = -EFAULT; |
| 1465 | |
| 1466 | } else { |
| 1467 | /* data */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1468 | val = ((phy->addr << 21) | (devad << 16) | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1469 | EMAC_MDIO_COMM_COMMAND_READ_45 | |
| 1470 | EMAC_MDIO_COMM_START_BUSY); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1471 | REG_WR(bp, phy->mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM, val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1472 | |
| 1473 | for (i = 0; i < 50; i++) { |
| 1474 | udelay(10); |
| 1475 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1476 | val = REG_RD(bp, phy->mdio_ctrl + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1477 | EMAC_REG_EMAC_MDIO_COMM); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1478 | if (!(val & EMAC_MDIO_COMM_START_BUSY)) { |
| 1479 | *ret_val = (u16)(val & EMAC_MDIO_COMM_DATA); |
| 1480 | break; |
| 1481 | } |
| 1482 | } |
| 1483 | if (val & EMAC_MDIO_COMM_START_BUSY) { |
| 1484 | DP(NETIF_MSG_LINK, "read phy register failed\n"); |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 1485 | netdev_err(bp->dev, "MDC/MDIO access timeout\n"); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1486 | *ret_val = 0; |
| 1487 | rc = -EFAULT; |
| 1488 | } |
| 1489 | } |
| 1490 | |
| 1491 | /* Restore the saved mode */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1492 | 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] | 1493 | |
| 1494 | return rc; |
| 1495 | } |
| 1496 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 1497 | int bnx2x_phy_read(struct link_params *params, u8 phy_addr, |
| 1498 | u8 devad, u16 reg, u16 *ret_val) |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1499 | { |
| 1500 | u8 phy_index; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 1501 | /* |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1502 | * Probe for the phy according to the given phy_addr, and execute |
| 1503 | * the read request on it |
| 1504 | */ |
| 1505 | for (phy_index = 0; phy_index < params->num_phys; phy_index++) { |
| 1506 | if (params->phy[phy_index].addr == phy_addr) { |
| 1507 | return bnx2x_cl45_read(params->bp, |
| 1508 | ¶ms->phy[phy_index], devad, |
| 1509 | reg, ret_val); |
| 1510 | } |
| 1511 | } |
| 1512 | return -EINVAL; |
| 1513 | } |
| 1514 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 1515 | int bnx2x_phy_write(struct link_params *params, u8 phy_addr, |
| 1516 | u8 devad, u16 reg, u16 val) |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1517 | { |
| 1518 | u8 phy_index; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 1519 | /* |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1520 | * Probe for the phy according to the given phy_addr, and execute |
| 1521 | * the write request on it |
| 1522 | */ |
| 1523 | for (phy_index = 0; phy_index < params->num_phys; phy_index++) { |
| 1524 | if (params->phy[phy_index].addr == phy_addr) { |
| 1525 | return bnx2x_cl45_write(params->bp, |
| 1526 | ¶ms->phy[phy_index], devad, |
| 1527 | reg, val); |
| 1528 | } |
| 1529 | } |
| 1530 | return -EINVAL; |
| 1531 | } |
| 1532 | |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1533 | static void bnx2x_set_aer_mmd_xgxs(struct link_params *params, |
| 1534 | struct bnx2x_phy *phy) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1535 | { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1536 | u32 ser_lane; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1537 | u16 offset, aer_val; |
| 1538 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1539 | ser_lane = ((params->lane_config & |
| 1540 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_MASK) >> |
| 1541 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_SHIFT); |
| 1542 | |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1543 | offset = phy->addr + ser_lane; |
| 1544 | if (CHIP_IS_E2(bp)) |
Yaniv Rosner | 82a0d47 | 2011-01-18 04:33:52 +0000 | [diff] [blame] | 1545 | aer_val = 0x3800 + offset - 1; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1546 | else |
| 1547 | aer_val = 0x3800 + offset; |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 1548 | CL22_WR_OVER_CL45(bp, phy, MDIO_REG_BANK_AER_BLOCK, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1549 | MDIO_AER_BLOCK_AER_REG, aer_val); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1550 | } |
| 1551 | static void bnx2x_set_aer_mmd_serdes(struct bnx2x *bp, |
| 1552 | struct bnx2x_phy *phy) |
| 1553 | { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 1554 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1555 | MDIO_REG_BANK_AER_BLOCK, |
| 1556 | MDIO_AER_BLOCK_AER_REG, 0x3800); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1557 | } |
| 1558 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 1559 | /******************************************************************/ |
| 1560 | /* Internal phy section */ |
| 1561 | /******************************************************************/ |
| 1562 | |
| 1563 | static void bnx2x_set_serdes_access(struct bnx2x *bp, u8 port) |
| 1564 | { |
| 1565 | u32 emac_base = (port) ? GRCBASE_EMAC1 : GRCBASE_EMAC0; |
| 1566 | |
| 1567 | /* Set Clause 22 */ |
| 1568 | REG_WR(bp, NIG_REG_SERDES0_CTRL_MD_ST + port*0x10, 1); |
| 1569 | REG_WR(bp, emac_base + EMAC_REG_EMAC_MDIO_COMM, 0x245f8000); |
| 1570 | udelay(500); |
| 1571 | REG_WR(bp, emac_base + EMAC_REG_EMAC_MDIO_COMM, 0x245d000f); |
| 1572 | udelay(500); |
| 1573 | /* Set Clause 45 */ |
| 1574 | REG_WR(bp, NIG_REG_SERDES0_CTRL_MD_ST + port*0x10, 0); |
| 1575 | } |
| 1576 | |
| 1577 | static void bnx2x_serdes_deassert(struct bnx2x *bp, u8 port) |
| 1578 | { |
| 1579 | u32 val; |
| 1580 | |
| 1581 | DP(NETIF_MSG_LINK, "bnx2x_serdes_deassert\n"); |
| 1582 | |
| 1583 | val = SERDES_RESET_BITS << (port*16); |
| 1584 | |
| 1585 | /* reset and unreset the SerDes/XGXS */ |
| 1586 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_3_CLEAR, val); |
| 1587 | udelay(500); |
| 1588 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_3_SET, val); |
| 1589 | |
| 1590 | bnx2x_set_serdes_access(bp, port); |
| 1591 | |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1592 | REG_WR(bp, NIG_REG_SERDES0_CTRL_MD_DEVAD + port*0x10, |
| 1593 | DEFAULT_PHY_DEV_ADDR); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 1594 | } |
| 1595 | |
| 1596 | static void bnx2x_xgxs_deassert(struct link_params *params) |
| 1597 | { |
| 1598 | struct bnx2x *bp = params->bp; |
| 1599 | u8 port; |
| 1600 | u32 val; |
| 1601 | DP(NETIF_MSG_LINK, "bnx2x_xgxs_deassert\n"); |
| 1602 | port = params->port; |
| 1603 | |
| 1604 | val = XGXS_RESET_BITS << (port*16); |
| 1605 | |
| 1606 | /* reset and unreset the SerDes/XGXS */ |
| 1607 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_3_CLEAR, val); |
| 1608 | udelay(500); |
| 1609 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_3_SET, val); |
| 1610 | |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1611 | REG_WR(bp, NIG_REG_XGXS0_CTRL_MD_ST + port*0x18, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 1612 | REG_WR(bp, NIG_REG_XGXS0_CTRL_MD_DEVAD + port*0x18, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1613 | params->phy[INT_PHY].def_md_devad); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 1614 | } |
| 1615 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 1616 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 1617 | void bnx2x_link_status_update(struct link_params *params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1618 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 1619 | { |
| 1620 | struct bnx2x *bp = params->bp; |
| 1621 | u8 link_10g; |
| 1622 | u8 port = params->port; |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 1623 | u32 sync_offset, media_types; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 1624 | vars->link_status = REG_RD(bp, params->shmem_base + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1625 | offsetof(struct shmem_region, |
| 1626 | port_mb[port].link_status)); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 1627 | |
| 1628 | vars->link_up = (vars->link_status & LINK_STATUS_LINK_UP); |
| 1629 | |
| 1630 | if (vars->link_up) { |
| 1631 | DP(NETIF_MSG_LINK, "phy link up\n"); |
| 1632 | |
| 1633 | vars->phy_link_up = 1; |
| 1634 | vars->duplex = DUPLEX_FULL; |
| 1635 | switch (vars->link_status & |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1636 | LINK_STATUS_SPEED_AND_DUPLEX_MASK) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 1637 | case LINK_10THD: |
| 1638 | vars->duplex = DUPLEX_HALF; |
| 1639 | /* fall thru */ |
| 1640 | case LINK_10TFD: |
| 1641 | vars->line_speed = SPEED_10; |
| 1642 | break; |
| 1643 | |
| 1644 | case LINK_100TXHD: |
| 1645 | vars->duplex = DUPLEX_HALF; |
| 1646 | /* fall thru */ |
| 1647 | case LINK_100T4: |
| 1648 | case LINK_100TXFD: |
| 1649 | vars->line_speed = SPEED_100; |
| 1650 | break; |
| 1651 | |
| 1652 | case LINK_1000THD: |
| 1653 | vars->duplex = DUPLEX_HALF; |
| 1654 | /* fall thru */ |
| 1655 | case LINK_1000TFD: |
| 1656 | vars->line_speed = SPEED_1000; |
| 1657 | break; |
| 1658 | |
| 1659 | case LINK_2500THD: |
| 1660 | vars->duplex = DUPLEX_HALF; |
| 1661 | /* fall thru */ |
| 1662 | case LINK_2500TFD: |
| 1663 | vars->line_speed = SPEED_2500; |
| 1664 | break; |
| 1665 | |
| 1666 | case LINK_10GTFD: |
| 1667 | vars->line_speed = SPEED_10000; |
| 1668 | break; |
| 1669 | |
| 1670 | case LINK_12GTFD: |
| 1671 | vars->line_speed = SPEED_12000; |
| 1672 | break; |
| 1673 | |
| 1674 | case LINK_12_5GTFD: |
| 1675 | vars->line_speed = SPEED_12500; |
| 1676 | break; |
| 1677 | |
| 1678 | case LINK_13GTFD: |
| 1679 | vars->line_speed = SPEED_13000; |
| 1680 | break; |
| 1681 | |
| 1682 | case LINK_15GTFD: |
| 1683 | vars->line_speed = SPEED_15000; |
| 1684 | break; |
| 1685 | |
| 1686 | case LINK_16GTFD: |
| 1687 | vars->line_speed = SPEED_16000; |
| 1688 | break; |
| 1689 | |
| 1690 | default: |
| 1691 | break; |
| 1692 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 1693 | vars->flow_ctrl = 0; |
| 1694 | if (vars->link_status & LINK_STATUS_TX_FLOW_CONTROL_ENABLED) |
| 1695 | vars->flow_ctrl |= BNX2X_FLOW_CTRL_TX; |
| 1696 | |
| 1697 | if (vars->link_status & LINK_STATUS_RX_FLOW_CONTROL_ENABLED) |
| 1698 | vars->flow_ctrl |= BNX2X_FLOW_CTRL_RX; |
| 1699 | |
| 1700 | if (!vars->flow_ctrl) |
| 1701 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 1702 | |
| 1703 | if (vars->line_speed && |
| 1704 | ((vars->line_speed == SPEED_10) || |
| 1705 | (vars->line_speed == SPEED_100))) { |
| 1706 | vars->phy_flags |= PHY_SGMII_FLAG; |
| 1707 | } else { |
| 1708 | vars->phy_flags &= ~PHY_SGMII_FLAG; |
| 1709 | } |
| 1710 | |
| 1711 | /* anything 10 and over uses the bmac */ |
| 1712 | link_10g = ((vars->line_speed == SPEED_10000) || |
| 1713 | (vars->line_speed == SPEED_12000) || |
| 1714 | (vars->line_speed == SPEED_12500) || |
| 1715 | (vars->line_speed == SPEED_13000) || |
| 1716 | (vars->line_speed == SPEED_15000) || |
| 1717 | (vars->line_speed == SPEED_16000)); |
| 1718 | if (link_10g) |
| 1719 | vars->mac_type = MAC_TYPE_BMAC; |
| 1720 | else |
| 1721 | vars->mac_type = MAC_TYPE_EMAC; |
| 1722 | |
| 1723 | } else { /* link down */ |
| 1724 | DP(NETIF_MSG_LINK, "phy link down\n"); |
| 1725 | |
| 1726 | vars->phy_link_up = 0; |
| 1727 | |
| 1728 | vars->line_speed = 0; |
| 1729 | vars->duplex = DUPLEX_FULL; |
| 1730 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 1731 | |
| 1732 | /* indicate no mac active */ |
| 1733 | vars->mac_type = MAC_TYPE_NONE; |
| 1734 | } |
| 1735 | |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 1736 | /* Sync media type */ |
| 1737 | sync_offset = params->shmem_base + |
| 1738 | offsetof(struct shmem_region, |
| 1739 | dev_info.port_hw_config[port].media_type); |
| 1740 | media_types = REG_RD(bp, sync_offset); |
| 1741 | |
| 1742 | params->phy[INT_PHY].media_type = |
| 1743 | (media_types & PORT_HW_CFG_MEDIA_TYPE_PHY0_MASK) >> |
| 1744 | PORT_HW_CFG_MEDIA_TYPE_PHY0_SHIFT; |
| 1745 | params->phy[EXT_PHY1].media_type = |
| 1746 | (media_types & PORT_HW_CFG_MEDIA_TYPE_PHY1_MASK) >> |
| 1747 | PORT_HW_CFG_MEDIA_TYPE_PHY1_SHIFT; |
| 1748 | params->phy[EXT_PHY2].media_type = |
| 1749 | (media_types & PORT_HW_CFG_MEDIA_TYPE_PHY2_MASK) >> |
| 1750 | PORT_HW_CFG_MEDIA_TYPE_PHY2_SHIFT; |
| 1751 | DP(NETIF_MSG_LINK, "media_types = 0x%x\n", media_types); |
| 1752 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 1753 | DP(NETIF_MSG_LINK, "link_status 0x%x phy_link_up %x\n", |
| 1754 | vars->link_status, vars->phy_link_up); |
| 1755 | DP(NETIF_MSG_LINK, "line_speed %x duplex %x flow_ctrl 0x%x\n", |
| 1756 | vars->line_speed, vars->duplex, vars->flow_ctrl); |
| 1757 | } |
| 1758 | |
| 1759 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1760 | static void bnx2x_set_master_ln(struct link_params *params, |
| 1761 | struct bnx2x_phy *phy) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1762 | { |
| 1763 | struct bnx2x *bp = params->bp; |
| 1764 | u16 new_master_ln, ser_lane; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1765 | ser_lane = ((params->lane_config & |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1766 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_MASK) >> |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1767 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_SHIFT); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1768 | |
| 1769 | /* set the master_ln for AN */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 1770 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1771 | MDIO_REG_BANK_XGXS_BLOCK2, |
| 1772 | MDIO_XGXS_BLOCK2_TEST_MODE_LANE, |
| 1773 | &new_master_ln); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1774 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 1775 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1776 | MDIO_REG_BANK_XGXS_BLOCK2 , |
| 1777 | MDIO_XGXS_BLOCK2_TEST_MODE_LANE, |
| 1778 | (new_master_ln | ser_lane)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1779 | } |
| 1780 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 1781 | static int bnx2x_reset_unicore(struct link_params *params, |
| 1782 | struct bnx2x_phy *phy, |
| 1783 | u8 set_serdes) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1784 | { |
| 1785 | struct bnx2x *bp = params->bp; |
| 1786 | u16 mii_control; |
| 1787 | u16 i; |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 1788 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1789 | MDIO_REG_BANK_COMBO_IEEE0, |
| 1790 | MDIO_COMBO_IEEE0_MII_CONTROL, &mii_control); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1791 | |
| 1792 | /* reset the unicore */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 1793 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1794 | MDIO_REG_BANK_COMBO_IEEE0, |
| 1795 | MDIO_COMBO_IEEE0_MII_CONTROL, |
| 1796 | (mii_control | |
| 1797 | MDIO_COMBO_IEEO_MII_CONTROL_RESET)); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1798 | if (set_serdes) |
| 1799 | bnx2x_set_serdes_access(bp, params->port); |
Eilon Greenstein | c1b7399 | 2009-02-12 08:37:07 +0000 | [diff] [blame] | 1800 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1801 | /* wait for the reset to self clear */ |
| 1802 | for (i = 0; i < MDIO_ACCESS_TIMEOUT; i++) { |
| 1803 | udelay(5); |
| 1804 | |
| 1805 | /* the reset erased the previous bank value */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 1806 | CL22_RD_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); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1810 | |
| 1811 | if (!(mii_control & MDIO_COMBO_IEEO_MII_CONTROL_RESET)) { |
| 1812 | udelay(5); |
| 1813 | return 0; |
| 1814 | } |
| 1815 | } |
| 1816 | |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 1817 | netdev_err(bp->dev, "Warning: PHY was not initialized," |
| 1818 | " Port %d\n", |
| 1819 | params->port); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1820 | DP(NETIF_MSG_LINK, "BUG! XGXS is still in reset!\n"); |
| 1821 | return -EINVAL; |
| 1822 | |
| 1823 | } |
| 1824 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1825 | static void bnx2x_set_swap_lanes(struct link_params *params, |
| 1826 | struct bnx2x_phy *phy) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1827 | { |
| 1828 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 1829 | /* |
| 1830 | * Each two bits represents a lane number: |
| 1831 | * No swap is 0123 => 0x1b no need to enable the swap |
| 1832 | */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1833 | u16 ser_lane, rx_lane_swap, tx_lane_swap; |
| 1834 | |
| 1835 | ser_lane = ((params->lane_config & |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1836 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_MASK) >> |
| 1837 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_SHIFT); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1838 | rx_lane_swap = ((params->lane_config & |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1839 | PORT_HW_CFG_LANE_SWAP_CFG_RX_MASK) >> |
| 1840 | PORT_HW_CFG_LANE_SWAP_CFG_RX_SHIFT); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1841 | tx_lane_swap = ((params->lane_config & |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1842 | PORT_HW_CFG_LANE_SWAP_CFG_TX_MASK) >> |
| 1843 | PORT_HW_CFG_LANE_SWAP_CFG_TX_SHIFT); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1844 | |
| 1845 | if (rx_lane_swap != 0x1b) { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 1846 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1847 | MDIO_REG_BANK_XGXS_BLOCK2, |
| 1848 | MDIO_XGXS_BLOCK2_RX_LN_SWAP, |
| 1849 | (rx_lane_swap | |
| 1850 | MDIO_XGXS_BLOCK2_RX_LN_SWAP_ENABLE | |
| 1851 | MDIO_XGXS_BLOCK2_RX_LN_SWAP_FORCE_ENABLE)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1852 | } else { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 1853 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1854 | MDIO_REG_BANK_XGXS_BLOCK2, |
| 1855 | MDIO_XGXS_BLOCK2_RX_LN_SWAP, 0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1856 | } |
| 1857 | |
| 1858 | if (tx_lane_swap != 0x1b) { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 1859 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1860 | MDIO_REG_BANK_XGXS_BLOCK2, |
| 1861 | MDIO_XGXS_BLOCK2_TX_LN_SWAP, |
| 1862 | (tx_lane_swap | |
| 1863 | MDIO_XGXS_BLOCK2_TX_LN_SWAP_ENABLE)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1864 | } else { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 1865 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1866 | MDIO_REG_BANK_XGXS_BLOCK2, |
| 1867 | MDIO_XGXS_BLOCK2_TX_LN_SWAP, 0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1868 | } |
| 1869 | } |
| 1870 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1871 | static void bnx2x_set_parallel_detection(struct bnx2x_phy *phy, |
| 1872 | struct link_params *params) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1873 | { |
| 1874 | struct bnx2x *bp = params->bp; |
| 1875 | u16 control2; |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 1876 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1877 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 1878 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL2, |
| 1879 | &control2); |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 1880 | if (phy->speed_cap_mask & PORT_HW_CFG_SPEED_CAPABILITY_D0_1G) |
Yaniv Rosner | 18afb0a | 2009-11-05 19:18:04 +0200 | [diff] [blame] | 1881 | control2 |= MDIO_SERDES_DIGITAL_A_1000X_CONTROL2_PRL_DT_EN; |
| 1882 | else |
| 1883 | control2 &= ~MDIO_SERDES_DIGITAL_A_1000X_CONTROL2_PRL_DT_EN; |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 1884 | DP(NETIF_MSG_LINK, "phy->speed_cap_mask = 0x%x, control2 = 0x%x\n", |
| 1885 | phy->speed_cap_mask, control2); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 1886 | CL22_WR_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 | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1890 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1891 | if ((phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT) && |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 1892 | (phy->speed_cap_mask & |
Yaniv Rosner | 18afb0a | 2009-11-05 19:18:04 +0200 | [diff] [blame] | 1893 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G)) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1894 | DP(NETIF_MSG_LINK, "XGXS\n"); |
| 1895 | |
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_10G_PARALLEL_DETECT, |
| 1898 | MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_LINK, |
| 1899 | MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_LINK_CNT); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1900 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 1901 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1902 | MDIO_REG_BANK_10G_PARALLEL_DETECT, |
| 1903 | MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_CONTROL, |
| 1904 | &control2); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1905 | |
| 1906 | |
| 1907 | control2 |= |
| 1908 | MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_CONTROL_PARDET10G_EN; |
| 1909 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 1910 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1911 | MDIO_REG_BANK_10G_PARALLEL_DETECT, |
| 1912 | MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_CONTROL, |
| 1913 | control2); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1914 | |
| 1915 | /* Disable parallel detection of HiG */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 1916 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1917 | MDIO_REG_BANK_XGXS_BLOCK2, |
| 1918 | MDIO_XGXS_BLOCK2_UNICORE_MODE_10G, |
| 1919 | MDIO_XGXS_BLOCK2_UNICORE_MODE_10G_CX4_XGXS | |
| 1920 | MDIO_XGXS_BLOCK2_UNICORE_MODE_10G_HIGIG_XGXS); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1921 | } |
| 1922 | } |
| 1923 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1924 | static void bnx2x_set_autoneg(struct bnx2x_phy *phy, |
| 1925 | struct link_params *params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1926 | struct link_vars *vars, |
| 1927 | u8 enable_cl73) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1928 | { |
| 1929 | struct bnx2x *bp = params->bp; |
| 1930 | u16 reg_val; |
| 1931 | |
| 1932 | /* CL37 Autoneg */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 1933 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1934 | MDIO_REG_BANK_COMBO_IEEE0, |
| 1935 | MDIO_COMBO_IEEE0_MII_CONTROL, ®_val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1936 | |
| 1937 | /* CL37 Autoneg Enabled */ |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 1938 | if (vars->line_speed == SPEED_AUTO_NEG) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1939 | reg_val |= MDIO_COMBO_IEEO_MII_CONTROL_AN_EN; |
| 1940 | else /* CL37 Autoneg Disabled */ |
| 1941 | reg_val &= ~(MDIO_COMBO_IEEO_MII_CONTROL_AN_EN | |
| 1942 | MDIO_COMBO_IEEO_MII_CONTROL_RESTART_AN); |
| 1943 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 1944 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1945 | MDIO_REG_BANK_COMBO_IEEE0, |
| 1946 | MDIO_COMBO_IEEE0_MII_CONTROL, reg_val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1947 | |
| 1948 | /* Enable/Disable Autodetection */ |
| 1949 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 1950 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1951 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 1952 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL1, ®_val); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 1953 | reg_val &= ~(MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_SIGNAL_DETECT_EN | |
| 1954 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_INVERT_SIGNAL_DETECT); |
| 1955 | reg_val |= MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_FIBER_MODE; |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 1956 | if (vars->line_speed == SPEED_AUTO_NEG) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1957 | reg_val |= MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_AUTODET; |
| 1958 | else |
| 1959 | reg_val &= ~MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_AUTODET; |
| 1960 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 1961 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1962 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 1963 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL1, reg_val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1964 | |
| 1965 | /* Enable TetonII and BAM autoneg */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 1966 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1967 | MDIO_REG_BANK_BAM_NEXT_PAGE, |
| 1968 | MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL, |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1969 | ®_val); |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 1970 | if (vars->line_speed == SPEED_AUTO_NEG) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1971 | /* Enable BAM aneg Mode and TetonII aneg Mode */ |
| 1972 | reg_val |= (MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL_BAM_MODE | |
| 1973 | MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL_TETON_AN); |
| 1974 | } else { |
| 1975 | /* TetonII and BAM Autoneg Disabled */ |
| 1976 | reg_val &= ~(MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL_BAM_MODE | |
| 1977 | MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL_TETON_AN); |
| 1978 | } |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 1979 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1980 | MDIO_REG_BANK_BAM_NEXT_PAGE, |
| 1981 | MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL, |
| 1982 | reg_val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1983 | |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 1984 | if (enable_cl73) { |
| 1985 | /* Enable Cl73 FSM status bits */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 1986 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1987 | MDIO_REG_BANK_CL73_USERB0, |
| 1988 | MDIO_CL73_USERB0_CL73_UCTRL, |
| 1989 | 0xe); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 1990 | |
| 1991 | /* Enable BAM Station Manager*/ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 1992 | CL22_WR_OVER_CL45(bp, phy, |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 1993 | MDIO_REG_BANK_CL73_USERB0, |
| 1994 | MDIO_CL73_USERB0_CL73_BAM_CTRL1, |
| 1995 | MDIO_CL73_USERB0_CL73_BAM_CTRL1_BAM_EN | |
| 1996 | MDIO_CL73_USERB0_CL73_BAM_CTRL1_BAM_STATION_MNGR_EN | |
| 1997 | MDIO_CL73_USERB0_CL73_BAM_CTRL1_BAM_NP_AFTER_BP_EN); |
| 1998 | |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 1999 | /* Advertise CL73 link speeds */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2000 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2001 | MDIO_REG_BANK_CL73_IEEEB1, |
| 2002 | MDIO_CL73_IEEEB1_AN_ADV2, |
| 2003 | ®_val); |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 2004 | if (phy->speed_cap_mask & |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 2005 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G) |
| 2006 | reg_val |= MDIO_CL73_IEEEB1_AN_ADV2_ADVR_10G_KX4; |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 2007 | if (phy->speed_cap_mask & |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 2008 | PORT_HW_CFG_SPEED_CAPABILITY_D0_1G) |
| 2009 | reg_val |= MDIO_CL73_IEEEB1_AN_ADV2_ADVR_1000M_KX; |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2010 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2011 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2012 | MDIO_REG_BANK_CL73_IEEEB1, |
| 2013 | MDIO_CL73_IEEEB1_AN_ADV2, |
| 2014 | reg_val); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2015 | |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2016 | /* CL73 Autoneg Enabled */ |
| 2017 | reg_val = MDIO_CL73_IEEEB0_CL73_AN_CONTROL_AN_EN; |
| 2018 | |
| 2019 | } else /* CL73 Autoneg Disabled */ |
| 2020 | reg_val = 0; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2021 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2022 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2023 | MDIO_REG_BANK_CL73_IEEEB0, |
| 2024 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL, reg_val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2025 | } |
| 2026 | |
| 2027 | /* program SerDes, forced speed */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2028 | static void bnx2x_program_serdes(struct bnx2x_phy *phy, |
| 2029 | struct link_params *params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2030 | struct link_vars *vars) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2031 | { |
| 2032 | struct bnx2x *bp = params->bp; |
| 2033 | u16 reg_val; |
| 2034 | |
Eilon Greenstein | 5793720 | 2009-08-12 08:23:53 +0000 | [diff] [blame] | 2035 | /* program duplex, disable autoneg and sgmii*/ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2036 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2037 | MDIO_REG_BANK_COMBO_IEEE0, |
| 2038 | MDIO_COMBO_IEEE0_MII_CONTROL, ®_val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2039 | reg_val &= ~(MDIO_COMBO_IEEO_MII_CONTROL_FULL_DUPLEX | |
Eilon Greenstein | 5793720 | 2009-08-12 08:23:53 +0000 | [diff] [blame] | 2040 | MDIO_COMBO_IEEO_MII_CONTROL_AN_EN | |
| 2041 | MDIO_COMBO_IEEO_MII_CONTROL_MAN_SGMII_SP_MASK); |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 2042 | if (phy->req_duplex == DUPLEX_FULL) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2043 | reg_val |= MDIO_COMBO_IEEO_MII_CONTROL_FULL_DUPLEX; |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2044 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2045 | MDIO_REG_BANK_COMBO_IEEE0, |
| 2046 | MDIO_COMBO_IEEE0_MII_CONTROL, reg_val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2047 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2048 | /* |
| 2049 | * program speed |
| 2050 | * - needed only if the speed is greater than 1G (2.5G or 10G) |
| 2051 | */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2052 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2053 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 2054 | MDIO_SERDES_DIGITAL_MISC1, ®_val); |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 2055 | /* clearing the speed value before setting the right speed */ |
| 2056 | DP(NETIF_MSG_LINK, "MDIO_REG_BANK_SERDES_DIGITAL = 0x%x\n", reg_val); |
| 2057 | |
| 2058 | reg_val &= ~(MDIO_SERDES_DIGITAL_MISC1_FORCE_SPEED_MASK | |
| 2059 | MDIO_SERDES_DIGITAL_MISC1_FORCE_SPEED_SEL); |
| 2060 | |
| 2061 | if (!((vars->line_speed == SPEED_1000) || |
| 2062 | (vars->line_speed == SPEED_100) || |
| 2063 | (vars->line_speed == SPEED_10))) { |
| 2064 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2065 | reg_val |= (MDIO_SERDES_DIGITAL_MISC1_REFCLK_SEL_156_25M | |
| 2066 | MDIO_SERDES_DIGITAL_MISC1_FORCE_SPEED_SEL); |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 2067 | if (vars->line_speed == SPEED_10000) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2068 | reg_val |= |
| 2069 | MDIO_SERDES_DIGITAL_MISC1_FORCE_SPEED_10G_CX4; |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 2070 | if (vars->line_speed == SPEED_13000) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2071 | reg_val |= |
| 2072 | MDIO_SERDES_DIGITAL_MISC1_FORCE_SPEED_13G; |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 2073 | } |
| 2074 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2075 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2076 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 2077 | MDIO_SERDES_DIGITAL_MISC1, reg_val); |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 2078 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2079 | } |
| 2080 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2081 | static void bnx2x_set_brcm_cl37_advertisment(struct bnx2x_phy *phy, |
| 2082 | struct link_params *params) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2083 | { |
| 2084 | struct bnx2x *bp = params->bp; |
| 2085 | u16 val = 0; |
| 2086 | |
| 2087 | /* configure the 48 bits for BAM AN */ |
| 2088 | |
| 2089 | /* set extended capabilities */ |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 2090 | 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] | 2091 | val |= MDIO_OVER_1G_UP1_2_5G; |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 2092 | if (phy->speed_cap_mask & PORT_HW_CFG_SPEED_CAPABILITY_D0_10G) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2093 | val |= MDIO_OVER_1G_UP1_10G; |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2094 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2095 | MDIO_REG_BANK_OVER_1G, |
| 2096 | MDIO_OVER_1G_UP1, val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2097 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2098 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2099 | MDIO_REG_BANK_OVER_1G, |
| 2100 | MDIO_OVER_1G_UP3, 0x400); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2101 | } |
| 2102 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2103 | static void bnx2x_calc_ieee_aneg_adv(struct bnx2x_phy *phy, |
| 2104 | struct link_params *params, u16 *ieee_fc) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2105 | { |
Yaniv Rosner | d5cb9e9 | 2009-11-05 19:18:10 +0200 | [diff] [blame] | 2106 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 2107 | *ieee_fc = MDIO_COMBO_IEEE0_AUTO_NEG_ADV_FULL_DUPLEX; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2108 | /* |
| 2109 | * Resolve pause mode and advertisement. |
| 2110 | * Please refer to Table 28B-3 of the 802.3ab-1999 spec |
| 2111 | */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2112 | |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 2113 | switch (phy->req_flow_ctrl) { |
David S. Miller | c0700f9 | 2008-12-16 23:53:20 -0800 | [diff] [blame] | 2114 | case BNX2X_FLOW_CTRL_AUTO: |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2115 | if (params->req_fc_auto_adv == BNX2X_FLOW_CTRL_BOTH) |
| 2116 | *ieee_fc |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH; |
| 2117 | else |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 2118 | *ieee_fc |= |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2119 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2120 | break; |
David S. Miller | c0700f9 | 2008-12-16 23:53:20 -0800 | [diff] [blame] | 2121 | case BNX2X_FLOW_CTRL_TX: |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2122 | *ieee_fc |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2123 | break; |
| 2124 | |
David S. Miller | c0700f9 | 2008-12-16 23:53:20 -0800 | [diff] [blame] | 2125 | case BNX2X_FLOW_CTRL_RX: |
| 2126 | case BNX2X_FLOW_CTRL_BOTH: |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 2127 | *ieee_fc |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2128 | break; |
| 2129 | |
David S. Miller | c0700f9 | 2008-12-16 23:53:20 -0800 | [diff] [blame] | 2130 | case BNX2X_FLOW_CTRL_NONE: |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2131 | default: |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 2132 | *ieee_fc |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_NONE; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2133 | break; |
| 2134 | } |
Yaniv Rosner | d5cb9e9 | 2009-11-05 19:18:10 +0200 | [diff] [blame] | 2135 | DP(NETIF_MSG_LINK, "ieee_fc = 0x%x\n", *ieee_fc); |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 2136 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2137 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2138 | static void bnx2x_set_ieee_aneg_advertisment(struct bnx2x_phy *phy, |
| 2139 | struct link_params *params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2140 | u16 ieee_fc) |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 2141 | { |
| 2142 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 2143 | u16 val; |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 2144 | /* for AN, we are always publishing full duplex */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2145 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2146 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2147 | MDIO_REG_BANK_COMBO_IEEE0, |
| 2148 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV, ieee_fc); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2149 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2150 | MDIO_REG_BANK_CL73_IEEEB1, |
| 2151 | MDIO_CL73_IEEEB1_AN_ADV1, &val); |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 2152 | val &= ~MDIO_CL73_IEEEB1_AN_ADV1_PAUSE_BOTH; |
| 2153 | val |= ((ieee_fc<<3) & MDIO_CL73_IEEEB1_AN_ADV1_PAUSE_MASK); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2154 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2155 | MDIO_REG_BANK_CL73_IEEEB1, |
| 2156 | MDIO_CL73_IEEEB1_AN_ADV1, val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2157 | } |
| 2158 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2159 | static void bnx2x_restart_autoneg(struct bnx2x_phy *phy, |
| 2160 | struct link_params *params, |
| 2161 | u8 enable_cl73) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2162 | { |
| 2163 | struct bnx2x *bp = params->bp; |
Eilon Greenstein | 3a36f2e | 2009-02-12 08:37:09 +0000 | [diff] [blame] | 2164 | u16 mii_control; |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2165 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2166 | DP(NETIF_MSG_LINK, "bnx2x_restart_autoneg\n"); |
Eilon Greenstein | 3a36f2e | 2009-02-12 08:37:09 +0000 | [diff] [blame] | 2167 | /* Enable and restart BAM/CL37 aneg */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2168 | |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2169 | if (enable_cl73) { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2170 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2171 | MDIO_REG_BANK_CL73_IEEEB0, |
| 2172 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL, |
| 2173 | &mii_control); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2174 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2175 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2176 | MDIO_REG_BANK_CL73_IEEEB0, |
| 2177 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL, |
| 2178 | (mii_control | |
| 2179 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL_AN_EN | |
| 2180 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL_RESTART_AN)); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2181 | } else { |
| 2182 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2183 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2184 | MDIO_REG_BANK_COMBO_IEEE0, |
| 2185 | MDIO_COMBO_IEEE0_MII_CONTROL, |
| 2186 | &mii_control); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2187 | DP(NETIF_MSG_LINK, |
| 2188 | "bnx2x_restart_autoneg mii_control before = 0x%x\n", |
| 2189 | mii_control); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2190 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2191 | MDIO_REG_BANK_COMBO_IEEE0, |
| 2192 | MDIO_COMBO_IEEE0_MII_CONTROL, |
| 2193 | (mii_control | |
| 2194 | MDIO_COMBO_IEEO_MII_CONTROL_AN_EN | |
| 2195 | MDIO_COMBO_IEEO_MII_CONTROL_RESTART_AN)); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2196 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2197 | } |
| 2198 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2199 | static void bnx2x_initialize_sgmii_process(struct bnx2x_phy *phy, |
| 2200 | struct link_params *params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2201 | struct link_vars *vars) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2202 | { |
| 2203 | struct bnx2x *bp = params->bp; |
| 2204 | u16 control1; |
| 2205 | |
| 2206 | /* in SGMII mode, the unicore is always slave */ |
| 2207 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2208 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2209 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 2210 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL1, |
| 2211 | &control1); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2212 | control1 |= MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_INVERT_SIGNAL_DETECT; |
| 2213 | /* set sgmii mode (and not fiber) */ |
| 2214 | control1 &= ~(MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_FIBER_MODE | |
| 2215 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_AUTODET | |
| 2216 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_MSTR_MODE); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2217 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2218 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 2219 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL1, |
| 2220 | control1); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2221 | |
| 2222 | /* if forced speed */ |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 2223 | if (!(vars->line_speed == SPEED_AUTO_NEG)) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2224 | /* set speed, disable autoneg */ |
| 2225 | u16 mii_control; |
| 2226 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2227 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2228 | MDIO_REG_BANK_COMBO_IEEE0, |
| 2229 | MDIO_COMBO_IEEE0_MII_CONTROL, |
| 2230 | &mii_control); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2231 | mii_control &= ~(MDIO_COMBO_IEEO_MII_CONTROL_AN_EN | |
| 2232 | MDIO_COMBO_IEEO_MII_CONTROL_MAN_SGMII_SP_MASK| |
| 2233 | MDIO_COMBO_IEEO_MII_CONTROL_FULL_DUPLEX); |
| 2234 | |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 2235 | switch (vars->line_speed) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2236 | case SPEED_100: |
| 2237 | mii_control |= |
| 2238 | MDIO_COMBO_IEEO_MII_CONTROL_MAN_SGMII_SP_100; |
| 2239 | break; |
| 2240 | case SPEED_1000: |
| 2241 | mii_control |= |
| 2242 | MDIO_COMBO_IEEO_MII_CONTROL_MAN_SGMII_SP_1000; |
| 2243 | break; |
| 2244 | case SPEED_10: |
| 2245 | /* there is nothing to set for 10M */ |
| 2246 | break; |
| 2247 | default: |
| 2248 | /* invalid speed for SGMII */ |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 2249 | DP(NETIF_MSG_LINK, "Invalid line_speed 0x%x\n", |
| 2250 | vars->line_speed); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2251 | break; |
| 2252 | } |
| 2253 | |
| 2254 | /* setting the full duplex */ |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 2255 | if (phy->req_duplex == DUPLEX_FULL) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2256 | mii_control |= |
| 2257 | MDIO_COMBO_IEEO_MII_CONTROL_FULL_DUPLEX; |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2258 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2259 | MDIO_REG_BANK_COMBO_IEEE0, |
| 2260 | MDIO_COMBO_IEEE0_MII_CONTROL, |
| 2261 | mii_control); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2262 | |
| 2263 | } else { /* AN mode */ |
| 2264 | /* enable and restart AN */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2265 | bnx2x_restart_autoneg(phy, params, 0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2266 | } |
| 2267 | } |
| 2268 | |
| 2269 | |
| 2270 | /* |
| 2271 | * link management |
| 2272 | */ |
| 2273 | |
| 2274 | static void bnx2x_pause_resolve(struct link_vars *vars, u32 pause_result) |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 2275 | { /* LD LP */ |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2276 | switch (pause_result) { /* ASYM P ASYM P */ |
| 2277 | case 0xb: /* 1 0 1 1 */ |
David S. Miller | c0700f9 | 2008-12-16 23:53:20 -0800 | [diff] [blame] | 2278 | vars->flow_ctrl = BNX2X_FLOW_CTRL_TX; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2279 | break; |
| 2280 | |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2281 | case 0xe: /* 1 1 1 0 */ |
David S. Miller | c0700f9 | 2008-12-16 23:53:20 -0800 | [diff] [blame] | 2282 | vars->flow_ctrl = BNX2X_FLOW_CTRL_RX; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2283 | break; |
| 2284 | |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2285 | case 0x5: /* 0 1 0 1 */ |
| 2286 | case 0x7: /* 0 1 1 1 */ |
| 2287 | case 0xd: /* 1 1 0 1 */ |
| 2288 | case 0xf: /* 1 1 1 1 */ |
David S. Miller | c0700f9 | 2008-12-16 23:53:20 -0800 | [diff] [blame] | 2289 | vars->flow_ctrl = BNX2X_FLOW_CTRL_BOTH; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2290 | break; |
| 2291 | |
| 2292 | default: |
| 2293 | break; |
| 2294 | } |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 2295 | if (pause_result & (1<<0)) |
| 2296 | vars->link_status |= LINK_STATUS_LINK_PARTNER_SYMMETRIC_PAUSE; |
| 2297 | if (pause_result & (1<<1)) |
| 2298 | vars->link_status |= LINK_STATUS_LINK_PARTNER_ASYMMETRIC_PAUSE; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2299 | } |
| 2300 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 2301 | static int bnx2x_direct_parallel_detect_used(struct bnx2x_phy *phy, |
| 2302 | struct link_params *params) |
Yaniv Rosner | 15ddd2d | 2009-11-05 19:18:12 +0200 | [diff] [blame] | 2303 | { |
| 2304 | struct bnx2x *bp = params->bp; |
| 2305 | u16 pd_10g, status2_1000x; |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 2306 | if (phy->req_line_speed != SPEED_AUTO_NEG) |
| 2307 | return 0; |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2308 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2309 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 2310 | MDIO_SERDES_DIGITAL_A_1000X_STATUS2, |
| 2311 | &status2_1000x); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2312 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2313 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 2314 | MDIO_SERDES_DIGITAL_A_1000X_STATUS2, |
| 2315 | &status2_1000x); |
Yaniv Rosner | 15ddd2d | 2009-11-05 19:18:12 +0200 | [diff] [blame] | 2316 | if (status2_1000x & MDIO_SERDES_DIGITAL_A_1000X_STATUS2_AN_DISABLED) { |
| 2317 | DP(NETIF_MSG_LINK, "1G parallel detect link on port %d\n", |
| 2318 | params->port); |
| 2319 | return 1; |
| 2320 | } |
| 2321 | |
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_10G_PARALLEL_DETECT, |
| 2324 | MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_STATUS, |
| 2325 | &pd_10g); |
Yaniv Rosner | 15ddd2d | 2009-11-05 19:18:12 +0200 | [diff] [blame] | 2326 | |
| 2327 | if (pd_10g & MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_STATUS_PD_LINK) { |
| 2328 | DP(NETIF_MSG_LINK, "10G parallel detect link on port %d\n", |
| 2329 | params->port); |
| 2330 | return 1; |
| 2331 | } |
| 2332 | return 0; |
| 2333 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2334 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2335 | static void bnx2x_flow_ctrl_resolve(struct bnx2x_phy *phy, |
| 2336 | struct link_params *params, |
| 2337 | struct link_vars *vars, |
| 2338 | u32 gp_status) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2339 | { |
| 2340 | struct bnx2x *bp = params->bp; |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 2341 | u16 ld_pause; /* local driver */ |
| 2342 | u16 lp_pause; /* link partner */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2343 | u16 pause_result; |
| 2344 | |
David S. Miller | c0700f9 | 2008-12-16 23:53:20 -0800 | [diff] [blame] | 2345 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2346 | |
| 2347 | /* resolve from gp_status in case of AN complete and not sgmii */ |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 2348 | if (phy->req_flow_ctrl != BNX2X_FLOW_CTRL_AUTO) |
| 2349 | vars->flow_ctrl = phy->req_flow_ctrl; |
| 2350 | else if (phy->req_line_speed != SPEED_AUTO_NEG) |
| 2351 | vars->flow_ctrl = params->req_fc_auto_adv; |
| 2352 | else if ((gp_status & MDIO_AN_CL73_OR_37_COMPLETE) && |
| 2353 | (!(vars->phy_flags & PHY_SGMII_FLAG))) { |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2354 | if (bnx2x_direct_parallel_detect_used(phy, params)) { |
Yaniv Rosner | 15ddd2d | 2009-11-05 19:18:12 +0200 | [diff] [blame] | 2355 | vars->flow_ctrl = params->req_fc_auto_adv; |
| 2356 | return; |
| 2357 | } |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 2358 | if ((gp_status & |
| 2359 | (MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_AUTONEG_COMPLETE | |
| 2360 | MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_MR_LP_NP_AN_ABLE)) == |
| 2361 | (MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_AUTONEG_COMPLETE | |
| 2362 | MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_MR_LP_NP_AN_ABLE)) { |
| 2363 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2364 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2365 | MDIO_REG_BANK_CL73_IEEEB1, |
| 2366 | MDIO_CL73_IEEEB1_AN_ADV1, |
| 2367 | &ld_pause); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2368 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2369 | MDIO_REG_BANK_CL73_IEEEB1, |
| 2370 | MDIO_CL73_IEEEB1_AN_LP_ADV1, |
| 2371 | &lp_pause); |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 2372 | pause_result = (ld_pause & |
| 2373 | MDIO_CL73_IEEEB1_AN_ADV1_PAUSE_MASK) |
| 2374 | >> 8; |
| 2375 | pause_result |= (lp_pause & |
| 2376 | MDIO_CL73_IEEEB1_AN_LP_ADV1_PAUSE_MASK) |
| 2377 | >> 10; |
| 2378 | DP(NETIF_MSG_LINK, "pause_result CL73 0x%x\n", |
| 2379 | pause_result); |
| 2380 | } else { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2381 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2382 | MDIO_REG_BANK_COMBO_IEEE0, |
| 2383 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV, |
| 2384 | &ld_pause); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2385 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2386 | MDIO_REG_BANK_COMBO_IEEE0, |
| 2387 | MDIO_COMBO_IEEE0_AUTO_NEG_LINK_PARTNER_ABILITY1, |
| 2388 | &lp_pause); |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 2389 | pause_result = (ld_pause & |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2390 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_MASK)>>5; |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 2391 | pause_result |= (lp_pause & |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2392 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_MASK)>>7; |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 2393 | DP(NETIF_MSG_LINK, "pause_result CL37 0x%x\n", |
| 2394 | pause_result); |
| 2395 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2396 | bnx2x_pause_resolve(vars, pause_result); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2397 | } |
| 2398 | DP(NETIF_MSG_LINK, "flow_ctrl 0x%x\n", vars->flow_ctrl); |
| 2399 | } |
| 2400 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2401 | static void bnx2x_check_fallback_to_cl37(struct bnx2x_phy *phy, |
| 2402 | struct link_params *params) |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2403 | { |
| 2404 | struct bnx2x *bp = params->bp; |
| 2405 | u16 rx_status, ustat_val, cl37_fsm_recieved; |
| 2406 | DP(NETIF_MSG_LINK, "bnx2x_check_fallback_to_cl37\n"); |
| 2407 | /* Step 1: Make sure signal is detected */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2408 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2409 | MDIO_REG_BANK_RX0, |
| 2410 | MDIO_RX0_RX_STATUS, |
| 2411 | &rx_status); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2412 | if ((rx_status & MDIO_RX0_RX_STATUS_SIGDET) != |
| 2413 | (MDIO_RX0_RX_STATUS_SIGDET)) { |
| 2414 | DP(NETIF_MSG_LINK, "Signal is not detected. Restoring CL73." |
| 2415 | "rx_status(0x80b0) = 0x%x\n", rx_status); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2416 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2417 | MDIO_REG_BANK_CL73_IEEEB0, |
| 2418 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL, |
| 2419 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL_AN_EN); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2420 | return; |
| 2421 | } |
| 2422 | /* Step 2: Check CL73 state machine */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2423 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2424 | MDIO_REG_BANK_CL73_USERB0, |
| 2425 | MDIO_CL73_USERB0_CL73_USTAT1, |
| 2426 | &ustat_val); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2427 | if ((ustat_val & |
| 2428 | (MDIO_CL73_USERB0_CL73_USTAT1_LINK_STATUS_CHECK | |
| 2429 | MDIO_CL73_USERB0_CL73_USTAT1_AN_GOOD_CHECK_BAM37)) != |
| 2430 | (MDIO_CL73_USERB0_CL73_USTAT1_LINK_STATUS_CHECK | |
| 2431 | MDIO_CL73_USERB0_CL73_USTAT1_AN_GOOD_CHECK_BAM37)) { |
| 2432 | DP(NETIF_MSG_LINK, "CL73 state-machine is not stable. " |
| 2433 | "ustat_val(0x8371) = 0x%x\n", ustat_val); |
| 2434 | return; |
| 2435 | } |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2436 | /* |
| 2437 | * Step 3: Check CL37 Message Pages received to indicate LP |
| 2438 | * supports only CL37 |
| 2439 | */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2440 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2441 | MDIO_REG_BANK_REMOTE_PHY, |
| 2442 | MDIO_REMOTE_PHY_MISC_RX_STATUS, |
| 2443 | &cl37_fsm_recieved); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2444 | if ((cl37_fsm_recieved & |
| 2445 | (MDIO_REMOTE_PHY_MISC_RX_STATUS_CL37_FSM_RECEIVED_OVER1G_MSG | |
| 2446 | MDIO_REMOTE_PHY_MISC_RX_STATUS_CL37_FSM_RECEIVED_BRCM_OUI_MSG)) != |
| 2447 | (MDIO_REMOTE_PHY_MISC_RX_STATUS_CL37_FSM_RECEIVED_OVER1G_MSG | |
| 2448 | MDIO_REMOTE_PHY_MISC_RX_STATUS_CL37_FSM_RECEIVED_BRCM_OUI_MSG)) { |
| 2449 | DP(NETIF_MSG_LINK, "No CL37 FSM were received. " |
| 2450 | "misc_rx_status(0x8330) = 0x%x\n", |
| 2451 | cl37_fsm_recieved); |
| 2452 | return; |
| 2453 | } |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2454 | /* |
| 2455 | * The combined cl37/cl73 fsm state information indicating that |
| 2456 | * we are connected to a device which does not support cl73, but |
| 2457 | * does support cl37 BAM. In this case we disable cl73 and |
| 2458 | * restart cl37 auto-neg |
| 2459 | */ |
| 2460 | |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2461 | /* Disable CL73 */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2462 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2463 | MDIO_REG_BANK_CL73_IEEEB0, |
| 2464 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL, |
| 2465 | 0); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2466 | /* Restart CL37 autoneg */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2467 | bnx2x_restart_autoneg(phy, params, 0); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2468 | DP(NETIF_MSG_LINK, "Disabling CL73, and restarting CL37 autoneg\n"); |
| 2469 | } |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 2470 | |
| 2471 | static void bnx2x_xgxs_an_resolve(struct bnx2x_phy *phy, |
| 2472 | struct link_params *params, |
| 2473 | struct link_vars *vars, |
| 2474 | u32 gp_status) |
| 2475 | { |
| 2476 | if (gp_status & MDIO_AN_CL73_OR_37_COMPLETE) |
| 2477 | vars->link_status |= |
| 2478 | LINK_STATUS_AUTO_NEGOTIATE_COMPLETE; |
| 2479 | |
| 2480 | if (bnx2x_direct_parallel_detect_used(phy, params)) |
| 2481 | vars->link_status |= |
| 2482 | LINK_STATUS_PARALLEL_DETECTION_USED; |
| 2483 | } |
| 2484 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 2485 | static int bnx2x_link_settings_status(struct bnx2x_phy *phy, |
| 2486 | struct link_params *params, |
| 2487 | struct link_vars *vars) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2488 | { |
| 2489 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2490 | u16 new_line_speed, gp_status; |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 2491 | int rc = 0; |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 2492 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 2493 | /* Read gp_status */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2494 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2495 | MDIO_REG_BANK_GP_STATUS, |
| 2496 | MDIO_GP_STATUS_TOP_AN_STATUS1, |
| 2497 | &gp_status); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 2498 | |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 2499 | if (phy->req_line_speed == SPEED_AUTO_NEG) |
| 2500 | vars->link_status |= LINK_STATUS_AUTO_NEGOTIATE_ENABLED; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2501 | if (gp_status & MDIO_GP_STATUS_TOP_AN_STATUS1_LINK_STATUS) { |
| 2502 | DP(NETIF_MSG_LINK, "phy link up gp_status=0x%x\n", |
| 2503 | gp_status); |
| 2504 | |
| 2505 | vars->phy_link_up = 1; |
| 2506 | vars->link_status |= LINK_STATUS_LINK_UP; |
| 2507 | |
| 2508 | if (gp_status & MDIO_GP_STATUS_TOP_AN_STATUS1_DUPLEX_STATUS) |
| 2509 | vars->duplex = DUPLEX_FULL; |
| 2510 | else |
| 2511 | vars->duplex = DUPLEX_HALF; |
| 2512 | |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 2513 | if (SINGLE_MEDIA_DIRECT(params)) { |
| 2514 | bnx2x_flow_ctrl_resolve(phy, params, vars, gp_status); |
| 2515 | if (phy->req_line_speed == SPEED_AUTO_NEG) |
| 2516 | bnx2x_xgxs_an_resolve(phy, params, vars, |
| 2517 | gp_status); |
| 2518 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2519 | |
| 2520 | switch (gp_status & GP_STATUS_SPEED_MASK) { |
| 2521 | case GP_STATUS_10M: |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 2522 | new_line_speed = SPEED_10; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2523 | if (vars->duplex == DUPLEX_FULL) |
| 2524 | vars->link_status |= LINK_10TFD; |
| 2525 | else |
| 2526 | vars->link_status |= LINK_10THD; |
| 2527 | break; |
| 2528 | |
| 2529 | case GP_STATUS_100M: |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 2530 | new_line_speed = SPEED_100; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2531 | if (vars->duplex == DUPLEX_FULL) |
| 2532 | vars->link_status |= LINK_100TXFD; |
| 2533 | else |
| 2534 | vars->link_status |= LINK_100TXHD; |
| 2535 | break; |
| 2536 | |
| 2537 | case GP_STATUS_1G: |
| 2538 | case GP_STATUS_1G_KX: |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 2539 | new_line_speed = SPEED_1000; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2540 | if (vars->duplex == DUPLEX_FULL) |
| 2541 | vars->link_status |= LINK_1000TFD; |
| 2542 | else |
| 2543 | vars->link_status |= LINK_1000THD; |
| 2544 | break; |
| 2545 | |
| 2546 | case GP_STATUS_2_5G: |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 2547 | new_line_speed = SPEED_2500; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2548 | if (vars->duplex == DUPLEX_FULL) |
| 2549 | vars->link_status |= LINK_2500TFD; |
| 2550 | else |
| 2551 | vars->link_status |= LINK_2500THD; |
| 2552 | break; |
| 2553 | |
| 2554 | case GP_STATUS_5G: |
| 2555 | case GP_STATUS_6G: |
| 2556 | DP(NETIF_MSG_LINK, |
| 2557 | "link speed unsupported gp_status 0x%x\n", |
| 2558 | gp_status); |
| 2559 | return -EINVAL; |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 2560 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2561 | case GP_STATUS_10G_KX4: |
| 2562 | case GP_STATUS_10G_HIG: |
| 2563 | case GP_STATUS_10G_CX4: |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 2564 | new_line_speed = SPEED_10000; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2565 | vars->link_status |= LINK_10GTFD; |
| 2566 | break; |
| 2567 | |
| 2568 | case GP_STATUS_12G_HIG: |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 2569 | new_line_speed = SPEED_12000; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2570 | vars->link_status |= LINK_12GTFD; |
| 2571 | break; |
| 2572 | |
| 2573 | case GP_STATUS_12_5G: |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 2574 | new_line_speed = SPEED_12500; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2575 | vars->link_status |= LINK_12_5GTFD; |
| 2576 | break; |
| 2577 | |
| 2578 | case GP_STATUS_13G: |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 2579 | new_line_speed = SPEED_13000; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2580 | vars->link_status |= LINK_13GTFD; |
| 2581 | break; |
| 2582 | |
| 2583 | case GP_STATUS_15G: |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 2584 | new_line_speed = SPEED_15000; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2585 | vars->link_status |= LINK_15GTFD; |
| 2586 | break; |
| 2587 | |
| 2588 | case GP_STATUS_16G: |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 2589 | new_line_speed = SPEED_16000; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2590 | vars->link_status |= LINK_16GTFD; |
| 2591 | break; |
| 2592 | |
| 2593 | default: |
| 2594 | DP(NETIF_MSG_LINK, |
| 2595 | "link speed unsupported gp_status 0x%x\n", |
| 2596 | gp_status); |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 2597 | return -EINVAL; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2598 | } |
| 2599 | |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 2600 | vars->line_speed = new_line_speed; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2601 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2602 | } else { /* link_down */ |
| 2603 | DP(NETIF_MSG_LINK, "phy link down\n"); |
| 2604 | |
| 2605 | vars->phy_link_up = 0; |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 2606 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2607 | vars->duplex = DUPLEX_FULL; |
David S. Miller | c0700f9 | 2008-12-16 23:53:20 -0800 | [diff] [blame] | 2608 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2609 | vars->mac_type = MAC_TYPE_NONE; |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2610 | |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 2611 | if ((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 2612 | SINGLE_MEDIA_DIRECT(params)) { |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2613 | /* Check signal is detected */ |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 2614 | bnx2x_check_fallback_to_cl37(phy, params); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2615 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2616 | } |
| 2617 | |
Frans Pop | 2381a55 | 2010-03-24 07:57:36 +0000 | [diff] [blame] | 2618 | 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] | 2619 | gp_status, vars->phy_link_up, vars->line_speed); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 2620 | DP(NETIF_MSG_LINK, "duplex %x flow_ctrl 0x%x link_status 0x%x\n", |
| 2621 | vars->duplex, vars->flow_ctrl, vars->link_status); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2622 | return rc; |
| 2623 | } |
| 2624 | |
Eilon Greenstein | ed8680a | 2009-02-12 08:37:12 +0000 | [diff] [blame] | 2625 | static void bnx2x_set_gmii_tx_driver(struct link_params *params) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2626 | { |
| 2627 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2628 | struct bnx2x_phy *phy = ¶ms->phy[INT_PHY]; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2629 | u16 lp_up2; |
| 2630 | u16 tx_driver; |
Eilon Greenstein | c2c8b03 | 2009-02-12 08:37:14 +0000 | [diff] [blame] | 2631 | u16 bank; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2632 | |
| 2633 | /* read precomp */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2634 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2635 | MDIO_REG_BANK_OVER_1G, |
| 2636 | MDIO_OVER_1G_LP_UP2, &lp_up2); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2637 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2638 | /* bits [10:7] at lp_up2, positioned at [15:12] */ |
| 2639 | lp_up2 = (((lp_up2 & MDIO_OVER_1G_LP_UP2_PREEMPHASIS_MASK) >> |
| 2640 | MDIO_OVER_1G_LP_UP2_PREEMPHASIS_SHIFT) << |
| 2641 | MDIO_TX0_TX_DRIVER_PREEMPHASIS_SHIFT); |
| 2642 | |
Eilon Greenstein | c2c8b03 | 2009-02-12 08:37:14 +0000 | [diff] [blame] | 2643 | if (lp_up2 == 0) |
| 2644 | return; |
| 2645 | |
| 2646 | for (bank = MDIO_REG_BANK_TX0; bank <= MDIO_REG_BANK_TX3; |
| 2647 | bank += (MDIO_REG_BANK_TX1 - MDIO_REG_BANK_TX0)) { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2648 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2649 | bank, |
| 2650 | MDIO_TX0_TX_DRIVER, &tx_driver); |
Eilon Greenstein | c2c8b03 | 2009-02-12 08:37:14 +0000 | [diff] [blame] | 2651 | |
| 2652 | /* replace tx_driver bits [15:12] */ |
| 2653 | if (lp_up2 != |
| 2654 | (tx_driver & MDIO_TX0_TX_DRIVER_PREEMPHASIS_MASK)) { |
| 2655 | tx_driver &= ~MDIO_TX0_TX_DRIVER_PREEMPHASIS_MASK; |
| 2656 | tx_driver |= lp_up2; |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2657 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2658 | bank, |
| 2659 | MDIO_TX0_TX_DRIVER, tx_driver); |
Eilon Greenstein | c2c8b03 | 2009-02-12 08:37:14 +0000 | [diff] [blame] | 2660 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2661 | } |
| 2662 | } |
| 2663 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 2664 | static int bnx2x_emac_program(struct link_params *params, |
| 2665 | struct link_vars *vars) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2666 | { |
| 2667 | struct bnx2x *bp = params->bp; |
| 2668 | u8 port = params->port; |
| 2669 | u16 mode = 0; |
| 2670 | |
| 2671 | DP(NETIF_MSG_LINK, "setting link speed & duplex\n"); |
| 2672 | bnx2x_bits_dis(bp, GRCBASE_EMAC0 + port*0x400 + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2673 | EMAC_REG_EMAC_MODE, |
| 2674 | (EMAC_MODE_25G_MODE | |
| 2675 | EMAC_MODE_PORT_MII_10M | |
| 2676 | EMAC_MODE_HALF_DUPLEX)); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 2677 | switch (vars->line_speed) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2678 | case SPEED_10: |
| 2679 | mode |= EMAC_MODE_PORT_MII_10M; |
| 2680 | break; |
| 2681 | |
| 2682 | case SPEED_100: |
| 2683 | mode |= EMAC_MODE_PORT_MII; |
| 2684 | break; |
| 2685 | |
| 2686 | case SPEED_1000: |
| 2687 | mode |= EMAC_MODE_PORT_GMII; |
| 2688 | break; |
| 2689 | |
| 2690 | case SPEED_2500: |
| 2691 | mode |= (EMAC_MODE_25G_MODE | EMAC_MODE_PORT_GMII); |
| 2692 | break; |
| 2693 | |
| 2694 | default: |
| 2695 | /* 10G not valid for EMAC */ |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 2696 | DP(NETIF_MSG_LINK, "Invalid line_speed 0x%x\n", |
| 2697 | vars->line_speed); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2698 | return -EINVAL; |
| 2699 | } |
| 2700 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 2701 | if (vars->duplex == DUPLEX_HALF) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2702 | mode |= EMAC_MODE_HALF_DUPLEX; |
| 2703 | bnx2x_bits_en(bp, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2704 | GRCBASE_EMAC0 + port*0x400 + EMAC_REG_EMAC_MODE, |
| 2705 | mode); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2706 | |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 2707 | bnx2x_set_led(params, vars, LED_MODE_OPER, vars->line_speed); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2708 | return 0; |
| 2709 | } |
| 2710 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 2711 | static void bnx2x_set_preemphasis(struct bnx2x_phy *phy, |
| 2712 | struct link_params *params) |
| 2713 | { |
| 2714 | |
| 2715 | u16 bank, i = 0; |
| 2716 | struct bnx2x *bp = params->bp; |
| 2717 | |
| 2718 | for (bank = MDIO_REG_BANK_RX0, i = 0; bank <= MDIO_REG_BANK_RX3; |
| 2719 | bank += (MDIO_REG_BANK_RX1-MDIO_REG_BANK_RX0), i++) { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2720 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 2721 | bank, |
| 2722 | MDIO_RX0_RX_EQ_BOOST, |
| 2723 | phy->rx_preemphasis[i]); |
| 2724 | } |
| 2725 | |
| 2726 | for (bank = MDIO_REG_BANK_TX0, i = 0; bank <= MDIO_REG_BANK_TX3; |
| 2727 | bank += (MDIO_REG_BANK_TX1 - MDIO_REG_BANK_TX0), i++) { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2728 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 2729 | bank, |
| 2730 | MDIO_TX0_TX_DRIVER, |
| 2731 | phy->tx_preemphasis[i]); |
| 2732 | } |
| 2733 | } |
| 2734 | |
| 2735 | static void bnx2x_init_internal_phy(struct bnx2x_phy *phy, |
| 2736 | struct link_params *params, |
| 2737 | struct link_vars *vars) |
| 2738 | { |
| 2739 | struct bnx2x *bp = params->bp; |
| 2740 | u8 enable_cl73 = (SINGLE_MEDIA_DIRECT(params) || |
| 2741 | (params->loopback_mode == LOOPBACK_XGXS)); |
| 2742 | if (!(vars->phy_flags & PHY_SGMII_FLAG)) { |
| 2743 | if (SINGLE_MEDIA_DIRECT(params) && |
| 2744 | (params->feature_config_flags & |
| 2745 | FEATURE_CONFIG_OVERRIDE_PREEMPHASIS_ENABLED)) |
| 2746 | bnx2x_set_preemphasis(phy, params); |
| 2747 | |
| 2748 | /* forced speed requested? */ |
| 2749 | if (vars->line_speed != SPEED_AUTO_NEG || |
| 2750 | (SINGLE_MEDIA_DIRECT(params) && |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2751 | params->loopback_mode == LOOPBACK_EXT)) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 2752 | DP(NETIF_MSG_LINK, "not SGMII, no AN\n"); |
| 2753 | |
| 2754 | /* disable autoneg */ |
| 2755 | bnx2x_set_autoneg(phy, params, vars, 0); |
| 2756 | |
| 2757 | /* program speed and duplex */ |
| 2758 | bnx2x_program_serdes(phy, params, vars); |
| 2759 | |
| 2760 | } else { /* AN_mode */ |
| 2761 | DP(NETIF_MSG_LINK, "not SGMII, AN\n"); |
| 2762 | |
| 2763 | /* AN enabled */ |
| 2764 | bnx2x_set_brcm_cl37_advertisment(phy, params); |
| 2765 | |
| 2766 | /* program duplex & pause advertisement (for aneg) */ |
| 2767 | bnx2x_set_ieee_aneg_advertisment(phy, params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2768 | vars->ieee_fc); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 2769 | |
| 2770 | /* enable autoneg */ |
| 2771 | bnx2x_set_autoneg(phy, params, vars, enable_cl73); |
| 2772 | |
| 2773 | /* enable and restart AN */ |
| 2774 | bnx2x_restart_autoneg(phy, params, enable_cl73); |
| 2775 | } |
| 2776 | |
| 2777 | } else { /* SGMII mode */ |
| 2778 | DP(NETIF_MSG_LINK, "SGMII\n"); |
| 2779 | |
| 2780 | bnx2x_initialize_sgmii_process(phy, params, vars); |
| 2781 | } |
| 2782 | } |
| 2783 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 2784 | static int bnx2x_init_serdes(struct bnx2x_phy *phy, |
| 2785 | struct link_params *params, |
| 2786 | struct link_vars *vars) |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 2787 | { |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 2788 | int rc; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 2789 | vars->phy_flags |= PHY_SGMII_FLAG; |
| 2790 | bnx2x_calc_ieee_aneg_adv(phy, params, &vars->ieee_fc); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2791 | bnx2x_set_aer_mmd_serdes(params->bp, phy); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 2792 | rc = bnx2x_reset_unicore(params, phy, 1); |
| 2793 | /* reset the SerDes and wait for reset bit return low */ |
| 2794 | if (rc != 0) |
| 2795 | return rc; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2796 | bnx2x_set_aer_mmd_serdes(params->bp, phy); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2797 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 2798 | return rc; |
| 2799 | } |
| 2800 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 2801 | static int bnx2x_init_xgxs(struct bnx2x_phy *phy, |
| 2802 | struct link_params *params, |
| 2803 | struct link_vars *vars) |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 2804 | { |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 2805 | int rc; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 2806 | vars->phy_flags = PHY_XGXS_FLAG; |
| 2807 | if ((phy->req_line_speed && |
| 2808 | ((phy->req_line_speed == SPEED_100) || |
| 2809 | (phy->req_line_speed == SPEED_10))) || |
| 2810 | (!phy->req_line_speed && |
| 2811 | (phy->speed_cap_mask >= |
| 2812 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_FULL) && |
| 2813 | (phy->speed_cap_mask < |
| 2814 | PORT_HW_CFG_SPEED_CAPABILITY_D0_1G) |
| 2815 | )) |
| 2816 | vars->phy_flags |= PHY_SGMII_FLAG; |
| 2817 | else |
| 2818 | vars->phy_flags &= ~PHY_SGMII_FLAG; |
| 2819 | |
| 2820 | bnx2x_calc_ieee_aneg_adv(phy, params, &vars->ieee_fc); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2821 | bnx2x_set_aer_mmd_xgxs(params, phy); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 2822 | bnx2x_set_master_ln(params, phy); |
| 2823 | |
| 2824 | rc = bnx2x_reset_unicore(params, phy, 0); |
| 2825 | /* reset the SerDes and wait for reset bit return low */ |
| 2826 | if (rc != 0) |
| 2827 | return rc; |
| 2828 | |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2829 | bnx2x_set_aer_mmd_xgxs(params, phy); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 2830 | |
| 2831 | /* setting the masterLn_def again after the reset */ |
| 2832 | bnx2x_set_master_ln(params, phy); |
| 2833 | bnx2x_set_swap_lanes(params, phy); |
| 2834 | |
| 2835 | return rc; |
| 2836 | } |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 2837 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 2838 | static u16 bnx2x_wait_reset_complete(struct bnx2x *bp, |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 2839 | struct bnx2x_phy *phy, |
| 2840 | struct link_params *params) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2841 | { |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 2842 | u16 cnt, ctrl; |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 2843 | /* Wait for soft reset to get cleared up to 1 sec */ |
Yaniv Rosner | 62b29a5 | 2010-09-07 11:40:58 +0000 | [diff] [blame] | 2844 | for (cnt = 0; cnt < 1000; cnt++) { |
| 2845 | bnx2x_cl45_read(bp, phy, |
| 2846 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, &ctrl); |
| 2847 | if (!(ctrl & (1<<15))) |
| 2848 | break; |
| 2849 | msleep(1); |
| 2850 | } |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 2851 | |
| 2852 | if (cnt == 1000) |
| 2853 | netdev_err(bp->dev, "Warning: PHY was not initialized," |
| 2854 | " Port %d\n", |
| 2855 | params->port); |
Yaniv Rosner | 62b29a5 | 2010-09-07 11:40:58 +0000 | [diff] [blame] | 2856 | DP(NETIF_MSG_LINK, "control reg 0x%x (after %d ms)\n", ctrl, cnt); |
| 2857 | return cnt; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 2858 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2859 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2860 | static void bnx2x_link_int_enable(struct link_params *params) |
| 2861 | { |
| 2862 | u8 port = params->port; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2863 | u32 mask; |
| 2864 | struct bnx2x *bp = params->bp; |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 2865 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2866 | /* 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] | 2867 | if (params->switch_cfg == SWITCH_CFG_10G) { |
| 2868 | mask = (NIG_MASK_XGXS0_LINK10G | |
| 2869 | NIG_MASK_XGXS0_LINK_STATUS); |
| 2870 | DP(NETIF_MSG_LINK, "enabled XGXS interrupt\n"); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2871 | if (!(SINGLE_MEDIA_DIRECT(params)) && |
| 2872 | params->phy[INT_PHY].type != |
| 2873 | PORT_HW_CFG_XGXS_EXT_PHY_TYPE_FAILURE) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2874 | mask |= NIG_MASK_MI_INT; |
| 2875 | DP(NETIF_MSG_LINK, "enabled external phy int\n"); |
| 2876 | } |
| 2877 | |
| 2878 | } else { /* SerDes */ |
| 2879 | mask = NIG_MASK_SERDES0_LINK_STATUS; |
| 2880 | DP(NETIF_MSG_LINK, "enabled SerDes interrupt\n"); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2881 | if (!(SINGLE_MEDIA_DIRECT(params)) && |
| 2882 | params->phy[INT_PHY].type != |
| 2883 | PORT_HW_CFG_SERDES_EXT_PHY_TYPE_NOT_CONN) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2884 | mask |= NIG_MASK_MI_INT; |
| 2885 | DP(NETIF_MSG_LINK, "enabled external phy int\n"); |
| 2886 | } |
| 2887 | } |
| 2888 | bnx2x_bits_en(bp, |
| 2889 | NIG_REG_MASK_INTERRUPT_PORT0 + port*4, |
| 2890 | mask); |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 2891 | |
| 2892 | 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] | 2893 | (params->switch_cfg == SWITCH_CFG_10G), |
| 2894 | REG_RD(bp, NIG_REG_STATUS_INTERRUPT_PORT0 + port*4)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2895 | DP(NETIF_MSG_LINK, " int_mask 0x%x, MI_INT %x, SERDES_LINK %x\n", |
| 2896 | REG_RD(bp, NIG_REG_MASK_INTERRUPT_PORT0 + port*4), |
| 2897 | REG_RD(bp, NIG_REG_EMAC0_STATUS_MISC_MI_INT + port*0x18), |
| 2898 | REG_RD(bp, NIG_REG_SERDES0_STATUS_LINK_STATUS+port*0x3c)); |
| 2899 | DP(NETIF_MSG_LINK, " 10G %x, XGXS_LINK %x\n", |
| 2900 | REG_RD(bp, NIG_REG_XGXS0_STATUS_LINK10G + port*0x68), |
| 2901 | REG_RD(bp, NIG_REG_XGXS0_STATUS_LINK_STATUS + port*0x68)); |
| 2902 | } |
| 2903 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 2904 | static void bnx2x_rearm_latch_signal(struct bnx2x *bp, u8 port, |
| 2905 | u8 exp_mi_int) |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 2906 | { |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 2907 | u32 latch_status = 0; |
| 2908 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2909 | /* |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 2910 | * Disable the MI INT ( external phy int ) by writing 1 to the |
| 2911 | * status register. Link down indication is high-active-signal, |
| 2912 | * 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] | 2913 | */ |
| 2914 | /* Read Latched signals */ |
| 2915 | latch_status = REG_RD(bp, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 2916 | NIG_REG_LATCH_STATUS_0 + port*8); |
| 2917 | DP(NETIF_MSG_LINK, "latch_status = 0x%x\n", latch_status); |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 2918 | /* Handle only those with latched-signal=up.*/ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 2919 | if (exp_mi_int) |
| 2920 | bnx2x_bits_en(bp, |
| 2921 | NIG_REG_STATUS_INTERRUPT_PORT0 |
| 2922 | + port*4, |
| 2923 | NIG_STATUS_EMAC0_MI_INT); |
| 2924 | else |
| 2925 | bnx2x_bits_dis(bp, |
| 2926 | NIG_REG_STATUS_INTERRUPT_PORT0 |
| 2927 | + port*4, |
| 2928 | NIG_STATUS_EMAC0_MI_INT); |
| 2929 | |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 2930 | if (latch_status & 1) { |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 2931 | |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 2932 | /* For all latched-signal=up : Re-Arm Latch signals */ |
| 2933 | REG_WR(bp, NIG_REG_LATCH_STATUS_0 + port*8, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2934 | (latch_status & 0xfffe) | (latch_status & 1)); |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 2935 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 2936 | /* For all latched-signal=up,Write original_signal to status */ |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 2937 | } |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2938 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2939 | static void bnx2x_link_int_ack(struct link_params *params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2940 | struct link_vars *vars, u8 is_10g) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2941 | { |
| 2942 | struct bnx2x *bp = params->bp; |
| 2943 | u8 port = params->port; |
| 2944 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2945 | /* |
| 2946 | * First reset all status we assume only one line will be |
| 2947 | * change at a time |
| 2948 | */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2949 | bnx2x_bits_dis(bp, NIG_REG_STATUS_INTERRUPT_PORT0 + port*4, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2950 | (NIG_STATUS_XGXS0_LINK10G | |
| 2951 | NIG_STATUS_XGXS0_LINK_STATUS | |
| 2952 | NIG_STATUS_SERDES0_LINK_STATUS)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2953 | if (vars->phy_link_up) { |
| 2954 | if (is_10g) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2955 | /* |
| 2956 | * Disable the 10G link interrupt by writing 1 to the |
| 2957 | * status register |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2958 | */ |
| 2959 | DP(NETIF_MSG_LINK, "10G XGXS phy link up\n"); |
| 2960 | bnx2x_bits_en(bp, |
| 2961 | NIG_REG_STATUS_INTERRUPT_PORT0 + port*4, |
| 2962 | NIG_STATUS_XGXS0_LINK10G); |
| 2963 | |
| 2964 | } else if (params->switch_cfg == SWITCH_CFG_10G) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2965 | /* |
| 2966 | * Disable the link interrupt by writing 1 to the |
| 2967 | * relevant lane in the status register |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2968 | */ |
| 2969 | u32 ser_lane = ((params->lane_config & |
| 2970 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_MASK) >> |
| 2971 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_SHIFT); |
| 2972 | |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 2973 | DP(NETIF_MSG_LINK, "%d speed XGXS phy link up\n", |
| 2974 | vars->line_speed); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2975 | bnx2x_bits_en(bp, |
| 2976 | NIG_REG_STATUS_INTERRUPT_PORT0 + port*4, |
| 2977 | ((1 << ser_lane) << |
| 2978 | NIG_STATUS_XGXS0_LINK_STATUS_SIZE)); |
| 2979 | |
| 2980 | } else { /* SerDes */ |
| 2981 | DP(NETIF_MSG_LINK, "SerDes phy link up\n"); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2982 | /* |
| 2983 | * Disable the link interrupt by writing 1 to the status |
| 2984 | * register |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2985 | */ |
| 2986 | bnx2x_bits_en(bp, |
| 2987 | NIG_REG_STATUS_INTERRUPT_PORT0 + port*4, |
| 2988 | NIG_STATUS_SERDES0_LINK_STATUS); |
| 2989 | } |
| 2990 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2991 | } |
| 2992 | } |
| 2993 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 2994 | static int bnx2x_format_ver(u32 num, u8 *str, u16 *len) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2995 | { |
| 2996 | u8 *str_ptr = str; |
| 2997 | u32 mask = 0xf0000000; |
| 2998 | u8 shift = 8*4; |
| 2999 | u8 digit; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3000 | u8 remove_leading_zeros = 1; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3001 | if (*len < 10) { |
Frederik Schwarzer | 025dfda | 2008-10-16 19:02:37 +0200 | [diff] [blame] | 3002 | /* Need more than 10chars for this format */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3003 | *str_ptr = '\0'; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3004 | (*len)--; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3005 | return -EINVAL; |
| 3006 | } |
| 3007 | while (shift > 0) { |
| 3008 | |
| 3009 | shift -= 4; |
| 3010 | digit = ((num & mask) >> shift); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3011 | if (digit == 0 && remove_leading_zeros) { |
| 3012 | mask = mask >> 4; |
| 3013 | continue; |
| 3014 | } else if (digit < 0xa) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3015 | *str_ptr = digit + '0'; |
| 3016 | else |
| 3017 | *str_ptr = digit - 0xa + 'a'; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3018 | remove_leading_zeros = 0; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3019 | str_ptr++; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3020 | (*len)--; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3021 | mask = mask >> 4; |
| 3022 | if (shift == 4*4) { |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3023 | *str_ptr = '.'; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3024 | str_ptr++; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3025 | (*len)--; |
| 3026 | remove_leading_zeros = 1; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3027 | } |
| 3028 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3029 | return 0; |
| 3030 | } |
| 3031 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3032 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 3033 | static int bnx2x_null_format_ver(u32 spirom_ver, u8 *str, u16 *len) |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3034 | { |
| 3035 | str[0] = '\0'; |
| 3036 | (*len)--; |
| 3037 | return 0; |
| 3038 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3039 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 3040 | int bnx2x_get_ext_phy_fw_version(struct link_params *params, u8 driver_loaded, |
| 3041 | u8 *version, u16 len) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3042 | { |
Julia Lawall | 0376d5b | 2009-07-19 05:26:35 +0000 | [diff] [blame] | 3043 | struct bnx2x *bp; |
Eilon Greenstein | a35da8d | 2009-02-12 08:37:02 +0000 | [diff] [blame] | 3044 | u32 spirom_ver = 0; |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 3045 | int status = 0; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3046 | u8 *ver_p = version; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3047 | u16 remain_len = len; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3048 | if (version == NULL || params == NULL) |
| 3049 | return -EINVAL; |
Julia Lawall | 0376d5b | 2009-07-19 05:26:35 +0000 | [diff] [blame] | 3050 | bp = params->bp; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3051 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3052 | /* Extract first external phy*/ |
| 3053 | version[0] = '\0'; |
| 3054 | spirom_ver = REG_RD(bp, params->phy[EXT_PHY1].ver_addr); |
Eilon Greenstein | a35da8d | 2009-02-12 08:37:02 +0000 | [diff] [blame] | 3055 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3056 | if (params->phy[EXT_PHY1].format_fw_ver) { |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3057 | status |= params->phy[EXT_PHY1].format_fw_ver(spirom_ver, |
| 3058 | ver_p, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3059 | &remain_len); |
| 3060 | ver_p += (len - remain_len); |
| 3061 | } |
| 3062 | if ((params->num_phys == MAX_PHYS) && |
| 3063 | (params->phy[EXT_PHY2].ver_addr != 0)) { |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3064 | spirom_ver = REG_RD(bp, params->phy[EXT_PHY2].ver_addr); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3065 | if (params->phy[EXT_PHY2].format_fw_ver) { |
| 3066 | *ver_p = '/'; |
| 3067 | ver_p++; |
| 3068 | remain_len--; |
| 3069 | status |= params->phy[EXT_PHY2].format_fw_ver( |
| 3070 | spirom_ver, |
| 3071 | ver_p, |
| 3072 | &remain_len); |
| 3073 | ver_p = version + (len - remain_len); |
| 3074 | } |
| 3075 | } |
| 3076 | *ver_p = '\0'; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3077 | return status; |
| 3078 | } |
| 3079 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3080 | static void bnx2x_set_xgxs_loopback(struct bnx2x_phy *phy, |
Yaniv Rosner | 62b29a5 | 2010-09-07 11:40:58 +0000 | [diff] [blame] | 3081 | struct link_params *params) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3082 | { |
| 3083 | u8 port = params->port; |
| 3084 | struct bnx2x *bp = params->bp; |
| 3085 | |
Yaniv Rosner | 62b29a5 | 2010-09-07 11:40:58 +0000 | [diff] [blame] | 3086 | if (phy->req_line_speed != SPEED_1000) { |
Eilon Greenstein | 6378c02 | 2008-08-13 15:59:25 -0700 | [diff] [blame] | 3087 | u32 md_devad; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3088 | |
| 3089 | DP(NETIF_MSG_LINK, "XGXS 10G loopback enable\n"); |
| 3090 | |
| 3091 | /* change the uni_phy_addr in the nig */ |
| 3092 | md_devad = REG_RD(bp, (NIG_REG_XGXS0_CTRL_MD_DEVAD + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3093 | port*0x18)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3094 | |
| 3095 | REG_WR(bp, NIG_REG_XGXS0_CTRL_MD_DEVAD + port*0x18, 0x5); |
| 3096 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3097 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3098 | 5, |
| 3099 | (MDIO_REG_BANK_AER_BLOCK + |
| 3100 | (MDIO_AER_BLOCK_AER_REG & 0xf)), |
| 3101 | 0x2800); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3102 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3103 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3104 | 5, |
| 3105 | (MDIO_REG_BANK_CL73_IEEEB0 + |
| 3106 | (MDIO_CL73_IEEEB0_CL73_AN_CONTROL & 0xf)), |
| 3107 | 0x6041); |
Eilon Greenstein | 3858276 | 2009-01-14 06:44:16 +0000 | [diff] [blame] | 3108 | msleep(200); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3109 | /* set aer mmd back */ |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 3110 | bnx2x_set_aer_mmd_xgxs(params, phy); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3111 | |
| 3112 | /* and md_devad */ |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3113 | 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] | 3114 | } else { |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3115 | u16 mii_ctrl; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3116 | DP(NETIF_MSG_LINK, "XGXS 1G loopback enable\n"); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3117 | bnx2x_cl45_read(bp, phy, 5, |
| 3118 | (MDIO_REG_BANK_COMBO_IEEE0 + |
| 3119 | (MDIO_COMBO_IEEE0_MII_CONTROL & 0xf)), |
| 3120 | &mii_ctrl); |
| 3121 | bnx2x_cl45_write(bp, phy, 5, |
| 3122 | (MDIO_REG_BANK_COMBO_IEEE0 + |
| 3123 | (MDIO_COMBO_IEEE0_MII_CONTROL & 0xf)), |
| 3124 | mii_ctrl | |
| 3125 | MDIO_COMBO_IEEO_MII_CONTROL_LOOPBACK); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3126 | } |
| 3127 | } |
| 3128 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 3129 | int bnx2x_set_led(struct link_params *params, |
| 3130 | struct link_vars *vars, u8 mode, u32 speed) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3131 | { |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 3132 | u8 port = params->port; |
| 3133 | u16 hw_led_mode = params->hw_led_mode; |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 3134 | int rc = 0; |
| 3135 | u8 phy_idx; |
Eilon Greenstein | 345b5d5 | 2008-08-13 15:58:12 -0700 | [diff] [blame] | 3136 | u32 tmp; |
| 3137 | u32 emac_base = port ? GRCBASE_EMAC1 : GRCBASE_EMAC0; |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 3138 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3139 | DP(NETIF_MSG_LINK, "bnx2x_set_led: port %x, mode %d\n", port, mode); |
| 3140 | DP(NETIF_MSG_LINK, "speed 0x%x, hw_led_mode 0x%x\n", |
| 3141 | speed, hw_led_mode); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 3142 | /* In case */ |
| 3143 | for (phy_idx = EXT_PHY1; phy_idx < MAX_PHYS; phy_idx++) { |
| 3144 | if (params->phy[phy_idx].set_link_led) { |
| 3145 | params->phy[phy_idx].set_link_led( |
| 3146 | ¶ms->phy[phy_idx], params, mode); |
| 3147 | } |
| 3148 | } |
| 3149 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3150 | switch (mode) { |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 3151 | case LED_MODE_FRONT_PANEL_OFF: |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3152 | case LED_MODE_OFF: |
| 3153 | REG_WR(bp, NIG_REG_LED_10G_P0 + port*4, 0); |
| 3154 | REG_WR(bp, NIG_REG_LED_MODE_P0 + port*4, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3155 | SHARED_HW_CFG_LED_MAC1); |
Eilon Greenstein | 345b5d5 | 2008-08-13 15:58:12 -0700 | [diff] [blame] | 3156 | |
| 3157 | tmp = EMAC_RD(bp, EMAC_REG_EMAC_LED); |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 3158 | EMAC_WR(bp, EMAC_REG_EMAC_LED, (tmp | EMAC_LED_OVERRIDE)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3159 | break; |
| 3160 | |
| 3161 | case LED_MODE_OPER: |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3162 | /* |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 3163 | * For all other phys, OPER mode is same as ON, so in case |
| 3164 | * link is down, do nothing |
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 | if (!vars->link_up) |
| 3167 | break; |
| 3168 | case LED_MODE_ON: |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 3169 | if (((params->phy[EXT_PHY1].type == |
| 3170 | PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727) || |
| 3171 | (params->phy[EXT_PHY1].type == |
| 3172 | PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8722)) && |
Yaniv Rosner | 1f48353 | 2011-01-18 04:33:31 +0000 | [diff] [blame] | 3173 | CHIP_IS_E2(bp) && params->num_phys == 2) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3174 | /* |
| 3175 | * This is a work-around for E2+8727 Configurations |
| 3176 | */ |
Yaniv Rosner | 1f48353 | 2011-01-18 04:33:31 +0000 | [diff] [blame] | 3177 | if (mode == LED_MODE_ON || |
| 3178 | speed == SPEED_10000){ |
| 3179 | REG_WR(bp, NIG_REG_LED_MODE_P0 + port*4, 0); |
| 3180 | REG_WR(bp, NIG_REG_LED_10G_P0 + port*4, 1); |
| 3181 | |
| 3182 | tmp = EMAC_RD(bp, EMAC_REG_EMAC_LED); |
| 3183 | EMAC_WR(bp, EMAC_REG_EMAC_LED, |
| 3184 | (tmp | EMAC_LED_OVERRIDE)); |
| 3185 | return rc; |
| 3186 | } |
| 3187 | } else if (SINGLE_MEDIA_DIRECT(params)) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3188 | /* |
| 3189 | * This is a work-around for HW issue found when link |
| 3190 | * is up in CL73 |
| 3191 | */ |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 3192 | REG_WR(bp, NIG_REG_LED_MODE_P0 + port*4, 0); |
| 3193 | REG_WR(bp, NIG_REG_LED_10G_P0 + port*4, 1); |
| 3194 | } else { |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3195 | 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] | 3196 | } |
| 3197 | |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3198 | 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] | 3199 | /* Set blinking rate to ~15.9Hz */ |
| 3200 | REG_WR(bp, NIG_REG_LED_CONTROL_BLINK_RATE_P0 + port*4, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3201 | LED_BLINK_RATE_VAL); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3202 | REG_WR(bp, NIG_REG_LED_CONTROL_BLINK_RATE_ENA_P0 + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3203 | port*4, 1); |
Eilon Greenstein | 345b5d5 | 2008-08-13 15:58:12 -0700 | [diff] [blame] | 3204 | tmp = EMAC_RD(bp, EMAC_REG_EMAC_LED); |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3205 | EMAC_WR(bp, EMAC_REG_EMAC_LED, (tmp & (~EMAC_LED_OVERRIDE))); |
Eilon Greenstein | 345b5d5 | 2008-08-13 15:58:12 -0700 | [diff] [blame] | 3206 | |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 3207 | if (CHIP_IS_E1(bp) && |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 3208 | ((speed == SPEED_2500) || |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3209 | (speed == SPEED_1000) || |
| 3210 | (speed == SPEED_100) || |
| 3211 | (speed == SPEED_10))) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3212 | /* |
| 3213 | * On Everest 1 Ax chip versions for speeds less than |
| 3214 | * 10G LED scheme is different |
| 3215 | */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3216 | REG_WR(bp, NIG_REG_LED_CONTROL_OVERRIDE_TRAFFIC_P0 |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3217 | + port*4, 1); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3218 | REG_WR(bp, NIG_REG_LED_CONTROL_TRAFFIC_P0 + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3219 | port*4, 0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3220 | REG_WR(bp, NIG_REG_LED_CONTROL_BLINK_TRAFFIC_P0 + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3221 | port*4, 1); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3222 | } |
| 3223 | break; |
| 3224 | |
| 3225 | default: |
| 3226 | rc = -EINVAL; |
| 3227 | DP(NETIF_MSG_LINK, "bnx2x_set_led: Invalid led mode %d\n", |
| 3228 | mode); |
| 3229 | break; |
| 3230 | } |
| 3231 | return rc; |
| 3232 | |
| 3233 | } |
| 3234 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3235 | /* |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3236 | * This function comes to reflect the actual link state read DIRECTLY from the |
| 3237 | * HW |
| 3238 | */ |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 3239 | int bnx2x_test_link(struct link_params *params, struct link_vars *vars, |
| 3240 | u8 is_serdes) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3241 | { |
| 3242 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 3243 | u16 gp_status = 0, phy_index = 0; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3244 | u8 ext_phy_link_up = 0, serdes_phy_type; |
| 3245 | struct link_vars temp_vars; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3246 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 3247 | CL22_RD_OVER_CL45(bp, ¶ms->phy[INT_PHY], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3248 | MDIO_REG_BANK_GP_STATUS, |
| 3249 | MDIO_GP_STATUS_TOP_AN_STATUS1, |
| 3250 | &gp_status); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3251 | /* 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] | 3252 | if (!(gp_status & MDIO_GP_STATUS_TOP_AN_STATUS1_LINK_STATUS)) |
| 3253 | return -ESRCH; |
| 3254 | |
| 3255 | switch (params->num_phys) { |
| 3256 | case 1: |
| 3257 | /* No external PHY */ |
| 3258 | return 0; |
| 3259 | case 2: |
| 3260 | ext_phy_link_up = params->phy[EXT_PHY1].read_status( |
| 3261 | ¶ms->phy[EXT_PHY1], |
| 3262 | params, &temp_vars); |
| 3263 | break; |
| 3264 | case 3: /* Dual Media */ |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 3265 | for (phy_index = EXT_PHY1; phy_index < params->num_phys; |
| 3266 | phy_index++) { |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3267 | serdes_phy_type = ((params->phy[phy_index].media_type == |
| 3268 | ETH_PHY_SFP_FIBER) || |
| 3269 | (params->phy[phy_index].media_type == |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 3270 | ETH_PHY_XFP_FIBER) || |
| 3271 | (params->phy[phy_index].media_type == |
| 3272 | ETH_PHY_DA_TWINAX)); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3273 | |
| 3274 | if (is_serdes != serdes_phy_type) |
| 3275 | continue; |
| 3276 | if (params->phy[phy_index].read_status) { |
| 3277 | ext_phy_link_up |= |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 3278 | params->phy[phy_index].read_status( |
| 3279 | ¶ms->phy[phy_index], |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3280 | params, &temp_vars); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3281 | } |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 3282 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3283 | break; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3284 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3285 | if (ext_phy_link_up) |
| 3286 | return 0; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3287 | return -ESRCH; |
| 3288 | } |
| 3289 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 3290 | static int bnx2x_link_initialize(struct link_params *params, |
| 3291 | struct link_vars *vars) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3292 | { |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 3293 | int rc = 0; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3294 | u8 phy_index, non_ext_phy; |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 3295 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3296 | /* |
| 3297 | * In case of external phy existence, the line speed would be the |
| 3298 | * line speed linked up by the external phy. In case it is direct |
| 3299 | * only, then the line_speed during initialization will be |
| 3300 | * equal to the req_line_speed |
| 3301 | */ |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 3302 | vars->line_speed = params->phy[INT_PHY].req_line_speed; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3303 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3304 | /* |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 3305 | * Initialize the internal phy in case this is a direct board |
| 3306 | * (no external phys), or this board has external phy which requires |
| 3307 | * to first. |
| 3308 | */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3309 | |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 3310 | if (params->phy[INT_PHY].config_init) |
| 3311 | params->phy[INT_PHY].config_init( |
| 3312 | ¶ms->phy[INT_PHY], |
| 3313 | params, vars); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3314 | |
| 3315 | /* init ext phy and enable link state int */ |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 3316 | non_ext_phy = (SINGLE_MEDIA_DIRECT(params) || |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3317 | (params->loopback_mode == LOOPBACK_XGXS)); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3318 | |
| 3319 | if (non_ext_phy || |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 3320 | (params->phy[EXT_PHY1].flags & FLAGS_INIT_XGXS_FIRST) || |
Eilon Greenstein | 8660d8c | 2009-03-02 08:01:02 +0000 | [diff] [blame] | 3321 | (params->loopback_mode == LOOPBACK_EXT_PHY)) { |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 3322 | struct bnx2x_phy *phy = ¶ms->phy[INT_PHY]; |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3323 | if (vars->line_speed == SPEED_AUTO_NEG) |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 3324 | bnx2x_set_parallel_detection(phy, params); |
| 3325 | bnx2x_init_internal_phy(phy, params, vars); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3326 | } |
| 3327 | |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 3328 | /* Init external phy*/ |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3329 | if (!non_ext_phy) |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3330 | for (phy_index = EXT_PHY1; phy_index < params->num_phys; |
| 3331 | phy_index++) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3332 | /* |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3333 | * No need to initialize second phy in case of first |
| 3334 | * phy only selection. In case of second phy, we do |
| 3335 | * need to initialize the first phy, since they are |
| 3336 | * connected. |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3337 | */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3338 | if (phy_index == EXT_PHY2 && |
| 3339 | (bnx2x_phy_selection(params) == |
| 3340 | PORT_HW_CFG_PHY_SELECTION_FIRST_PHY)) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3341 | DP(NETIF_MSG_LINK, "Ignoring second phy\n"); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3342 | continue; |
| 3343 | } |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3344 | params->phy[phy_index].config_init( |
| 3345 | ¶ms->phy[phy_index], |
| 3346 | params, vars); |
| 3347 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3348 | |
Yaniv Rosner | d90d96b | 2010-09-07 11:41:04 +0000 | [diff] [blame] | 3349 | /* Reset the interrupt indication after phy was initialized */ |
| 3350 | bnx2x_bits_dis(bp, NIG_REG_STATUS_INTERRUPT_PORT0 + |
| 3351 | params->port*4, |
| 3352 | (NIG_STATUS_XGXS0_LINK10G | |
| 3353 | NIG_STATUS_XGXS0_LINK_STATUS | |
| 3354 | NIG_STATUS_SERDES0_LINK_STATUS | |
| 3355 | NIG_MASK_MI_INT)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3356 | return rc; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3357 | } |
| 3358 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3359 | static void bnx2x_int_link_reset(struct bnx2x_phy *phy, |
| 3360 | struct link_params *params) |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3361 | { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3362 | /* reset the SerDes/XGXS */ |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3363 | REG_WR(params->bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_3_CLEAR, |
| 3364 | (0x1ff << (params->port*16))); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3365 | } |
| 3366 | |
| 3367 | static void bnx2x_common_ext_link_reset(struct bnx2x_phy *phy, |
| 3368 | struct link_params *params) |
| 3369 | { |
| 3370 | struct bnx2x *bp = params->bp; |
| 3371 | u8 gpio_port; |
| 3372 | /* HW reset */ |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 3373 | if (CHIP_IS_E2(bp)) |
| 3374 | gpio_port = BP_PATH(bp); |
| 3375 | else |
| 3376 | gpio_port = params->port; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3377 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3378 | MISC_REGISTERS_GPIO_OUTPUT_LOW, |
| 3379 | gpio_port); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3380 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3381 | MISC_REGISTERS_GPIO_OUTPUT_LOW, |
| 3382 | gpio_port); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3383 | DP(NETIF_MSG_LINK, "reset external PHY\n"); |
| 3384 | } |
| 3385 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 3386 | static int bnx2x_update_link_down(struct link_params *params, |
| 3387 | struct link_vars *vars) |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3388 | { |
| 3389 | struct bnx2x *bp = params->bp; |
| 3390 | u8 port = params->port; |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 3391 | |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3392 | DP(NETIF_MSG_LINK, "Port %x: Link is down\n", port); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 3393 | bnx2x_set_led(params, vars, LED_MODE_OFF, 0); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3394 | |
| 3395 | /* indicate no mac active */ |
| 3396 | vars->mac_type = MAC_TYPE_NONE; |
| 3397 | |
| 3398 | /* update shared memory */ |
| 3399 | vars->link_status = 0; |
| 3400 | vars->line_speed = 0; |
| 3401 | bnx2x_update_mng(params, vars->link_status); |
| 3402 | |
| 3403 | /* activate nig drain */ |
| 3404 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + port*4, 1); |
| 3405 | |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 3406 | /* disable emac */ |
| 3407 | REG_WR(bp, NIG_REG_NIG_EMAC0_EN + port*4, 0); |
| 3408 | |
| 3409 | msleep(10); |
| 3410 | |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3411 | /* reset BigMac */ |
| 3412 | bnx2x_bmac_rx_disable(bp, params->port); |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3413 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_CLEAR, |
| 3414 | (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << port)); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3415 | return 0; |
| 3416 | } |
| 3417 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 3418 | static int bnx2x_update_link_up(struct link_params *params, |
| 3419 | struct link_vars *vars, |
| 3420 | u8 link_10g) |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3421 | { |
| 3422 | struct bnx2x *bp = params->bp; |
| 3423 | u8 port = params->port; |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 3424 | int rc = 0; |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 3425 | |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3426 | vars->link_status |= LINK_STATUS_LINK_UP; |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 3427 | |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 3428 | if (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX) |
| 3429 | vars->link_status |= |
| 3430 | LINK_STATUS_TX_FLOW_CONTROL_ENABLED; |
| 3431 | |
| 3432 | if (vars->flow_ctrl & BNX2X_FLOW_CTRL_RX) |
| 3433 | vars->link_status |= |
| 3434 | LINK_STATUS_RX_FLOW_CONTROL_ENABLED; |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 3435 | |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3436 | if (link_10g) { |
| 3437 | bnx2x_bmac_enable(params, vars, 0); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 3438 | bnx2x_set_led(params, vars, |
| 3439 | LED_MODE_OPER, SPEED_10000); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3440 | } else { |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3441 | rc = bnx2x_emac_program(params, vars); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3442 | |
Yaniv Rosner | 0c786f0 | 2009-11-05 19:18:32 +0200 | [diff] [blame] | 3443 | bnx2x_emac_enable(params, vars, 0); |
| 3444 | |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3445 | /* AN complete? */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3446 | if ((vars->link_status & LINK_STATUS_AUTO_NEGOTIATE_COMPLETE) |
| 3447 | && (!(vars->phy_flags & PHY_SGMII_FLAG)) && |
| 3448 | SINGLE_MEDIA_DIRECT(params)) |
| 3449 | bnx2x_set_gmii_tx_driver(params); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3450 | } |
| 3451 | |
| 3452 | /* PBF - link up */ |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 3453 | if (!(CHIP_IS_E2(bp))) |
| 3454 | rc |= bnx2x_pbf_update(params, vars->flow_ctrl, |
| 3455 | vars->line_speed); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3456 | |
| 3457 | /* disable drain */ |
| 3458 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + port*4, 0); |
| 3459 | |
| 3460 | /* update shared memory */ |
| 3461 | bnx2x_update_mng(params, vars->link_status); |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 3462 | msleep(20); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3463 | return rc; |
| 3464 | } |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3465 | /* |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3466 | * The bnx2x_link_update function should be called upon link |
| 3467 | * interrupt. |
| 3468 | * Link is considered up as follows: |
| 3469 | * - DIRECT_SINGLE_MEDIA - Only XGXS link (internal link) needs |
| 3470 | * to be up |
| 3471 | * - SINGLE_MEDIA - The link between the 577xx and the external |
| 3472 | * phy (XGXS) need to up as well as the external link of the |
| 3473 | * phy (PHY_EXT1) |
| 3474 | * - DUAL_MEDIA - The link between the 577xx and the first |
| 3475 | * external phy needs to be up, and at least one of the 2 |
| 3476 | * external phy link must be up. |
Yaniv Rosner | 62b29a5 | 2010-09-07 11:40:58 +0000 | [diff] [blame] | 3477 | */ |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 3478 | int bnx2x_link_update(struct link_params *params, struct link_vars *vars) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3479 | { |
| 3480 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3481 | struct link_vars phy_vars[MAX_PHYS]; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3482 | u8 port = params->port; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3483 | u8 link_10g, phy_index; |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 3484 | u8 ext_phy_link_up = 0, cur_link_up; |
| 3485 | int rc = 0; |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 3486 | u8 is_mi_int = 0; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3487 | u16 ext_phy_line_speed = 0, prev_line_speed = vars->line_speed; |
| 3488 | u8 active_external_phy = INT_PHY; |
| 3489 | vars->link_status = 0; |
| 3490 | for (phy_index = INT_PHY; phy_index < params->num_phys; |
| 3491 | phy_index++) { |
| 3492 | phy_vars[phy_index].flow_ctrl = 0; |
| 3493 | phy_vars[phy_index].link_status = 0; |
| 3494 | phy_vars[phy_index].line_speed = 0; |
| 3495 | phy_vars[phy_index].duplex = DUPLEX_FULL; |
| 3496 | phy_vars[phy_index].phy_link_up = 0; |
| 3497 | phy_vars[phy_index].link_up = 0; |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 3498 | phy_vars[phy_index].fault_detected = 0; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3499 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3500 | |
| 3501 | 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] | 3502 | port, (vars->phy_flags & PHY_XGXS_FLAG), |
| 3503 | REG_RD(bp, NIG_REG_STATUS_INTERRUPT_PORT0 + port*4)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3504 | |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 3505 | 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] | 3506 | port*0x18) > 0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3507 | 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] | 3508 | REG_RD(bp, NIG_REG_MASK_INTERRUPT_PORT0 + port*4), |
| 3509 | is_mi_int, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3510 | REG_RD(bp, NIG_REG_SERDES0_STATUS_LINK_STATUS + port*0x3c)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3511 | |
| 3512 | DP(NETIF_MSG_LINK, " 10G %x, XGXS_LINK %x\n", |
| 3513 | REG_RD(bp, NIG_REG_XGXS0_STATUS_LINK10G + port*0x68), |
| 3514 | REG_RD(bp, NIG_REG_XGXS0_STATUS_LINK_STATUS + port*0x68)); |
| 3515 | |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 3516 | /* disable emac */ |
| 3517 | REG_WR(bp, NIG_REG_NIG_EMAC0_EN + port*4, 0); |
| 3518 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3519 | /* |
| 3520 | * Step 1: |
| 3521 | * Check external link change only for external phys, and apply |
| 3522 | * priority selection between them in case the link on both phys |
| 3523 | * is up. Note that the instead of the common vars, a temporary |
| 3524 | * vars argument is used since each phy may have different link/ |
| 3525 | * speed/duplex result |
| 3526 | */ |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3527 | for (phy_index = EXT_PHY1; phy_index < params->num_phys; |
| 3528 | phy_index++) { |
| 3529 | struct bnx2x_phy *phy = ¶ms->phy[phy_index]; |
| 3530 | if (!phy->read_status) |
| 3531 | continue; |
| 3532 | /* Read link status and params of this ext phy */ |
| 3533 | cur_link_up = phy->read_status(phy, params, |
| 3534 | &phy_vars[phy_index]); |
| 3535 | if (cur_link_up) { |
| 3536 | DP(NETIF_MSG_LINK, "phy in index %d link is up\n", |
| 3537 | phy_index); |
| 3538 | } else { |
| 3539 | DP(NETIF_MSG_LINK, "phy in index %d link is down\n", |
| 3540 | phy_index); |
| 3541 | continue; |
| 3542 | } |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3543 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3544 | if (!ext_phy_link_up) { |
| 3545 | ext_phy_link_up = 1; |
| 3546 | active_external_phy = phy_index; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3547 | } else { |
| 3548 | switch (bnx2x_phy_selection(params)) { |
| 3549 | case PORT_HW_CFG_PHY_SELECTION_HARDWARE_DEFAULT: |
| 3550 | case PORT_HW_CFG_PHY_SELECTION_FIRST_PHY_PRIORITY: |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3551 | /* |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3552 | * In this option, the first PHY makes sure to pass the |
| 3553 | * traffic through itself only. |
| 3554 | * Its not clear how to reset the link on the second phy |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3555 | */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3556 | active_external_phy = EXT_PHY1; |
| 3557 | break; |
| 3558 | case PORT_HW_CFG_PHY_SELECTION_SECOND_PHY_PRIORITY: |
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 | * In this option, the first PHY makes sure to pass the |
| 3561 | * traffic through the second PHY. |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3562 | */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3563 | active_external_phy = EXT_PHY2; |
| 3564 | break; |
| 3565 | default: |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3566 | /* |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3567 | * Link indication on both PHYs with the following cases |
| 3568 | * is invalid: |
| 3569 | * - FIRST_PHY means that second phy wasn't initialized, |
| 3570 | * hence its link is expected to be down |
| 3571 | * - SECOND_PHY means that first phy should not be able |
| 3572 | * to link up by itself (using configuration) |
| 3573 | * - DEFAULT should be overriden during initialiazation |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3574 | */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3575 | DP(NETIF_MSG_LINK, "Invalid link indication" |
| 3576 | "mpc=0x%x. DISABLING LINK !!!\n", |
| 3577 | params->multi_phy_config); |
| 3578 | ext_phy_link_up = 0; |
| 3579 | break; |
| 3580 | } |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3581 | } |
| 3582 | } |
| 3583 | prev_line_speed = vars->line_speed; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3584 | /* |
| 3585 | * Step 2: |
| 3586 | * Read the status of the internal phy. In case of |
| 3587 | * DIRECT_SINGLE_MEDIA board, this link is the external link, |
| 3588 | * otherwise this is the link between the 577xx and the first |
| 3589 | * external phy |
| 3590 | */ |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3591 | if (params->phy[INT_PHY].read_status) |
| 3592 | params->phy[INT_PHY].read_status( |
| 3593 | ¶ms->phy[INT_PHY], |
| 3594 | params, vars); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3595 | /* |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3596 | * The INT_PHY flow control reside in the vars. This include the |
| 3597 | * case where the speed or flow control are not set to AUTO. |
| 3598 | * Otherwise, the active external phy flow control result is set |
| 3599 | * to the vars. The ext_phy_line_speed is needed to check if the |
| 3600 | * speed is different between the internal phy and external phy. |
| 3601 | * This case may be result of intermediate link speed change. |
| 3602 | */ |
| 3603 | if (active_external_phy > INT_PHY) { |
| 3604 | vars->flow_ctrl = phy_vars[active_external_phy].flow_ctrl; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3605 | /* |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3606 | * Link speed is taken from the XGXS. AN and FC result from |
| 3607 | * the external phy. |
| 3608 | */ |
| 3609 | vars->link_status |= phy_vars[active_external_phy].link_status; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3610 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3611 | /* |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3612 | * if active_external_phy is first PHY and link is up - disable |
| 3613 | * disable TX on second external PHY |
| 3614 | */ |
| 3615 | if (active_external_phy == EXT_PHY1) { |
| 3616 | if (params->phy[EXT_PHY2].phy_specific_func) { |
| 3617 | DP(NETIF_MSG_LINK, "Disabling TX on" |
| 3618 | " EXT_PHY2\n"); |
| 3619 | params->phy[EXT_PHY2].phy_specific_func( |
| 3620 | ¶ms->phy[EXT_PHY2], |
| 3621 | params, DISABLE_TX); |
| 3622 | } |
| 3623 | } |
| 3624 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3625 | ext_phy_line_speed = phy_vars[active_external_phy].line_speed; |
| 3626 | vars->duplex = phy_vars[active_external_phy].duplex; |
| 3627 | if (params->phy[active_external_phy].supported & |
| 3628 | SUPPORTED_FIBRE) |
| 3629 | vars->link_status |= LINK_STATUS_SERDES_LINK; |
| 3630 | DP(NETIF_MSG_LINK, "Active external phy selected: %x\n", |
| 3631 | active_external_phy); |
| 3632 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3633 | |
| 3634 | for (phy_index = EXT_PHY1; phy_index < params->num_phys; |
| 3635 | phy_index++) { |
| 3636 | if (params->phy[phy_index].flags & |
| 3637 | FLAGS_REARM_LATCH_SIGNAL) { |
| 3638 | bnx2x_rearm_latch_signal(bp, port, |
| 3639 | phy_index == |
| 3640 | active_external_phy); |
| 3641 | break; |
| 3642 | } |
| 3643 | } |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3644 | DP(NETIF_MSG_LINK, "vars->flow_ctrl = 0x%x, vars->link_status = 0x%x," |
| 3645 | " ext_phy_line_speed = %d\n", vars->flow_ctrl, |
| 3646 | vars->link_status, ext_phy_line_speed); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3647 | /* |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3648 | * Upon link speed change set the NIG into drain mode. Comes to |
| 3649 | * deals with possible FIFO glitch due to clk change when speed |
| 3650 | * is decreased without link down indicator |
| 3651 | */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3652 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3653 | if (vars->phy_link_up) { |
| 3654 | if (!(SINGLE_MEDIA_DIRECT(params)) && ext_phy_link_up && |
| 3655 | (ext_phy_line_speed != vars->line_speed)) { |
| 3656 | DP(NETIF_MSG_LINK, "Internal link speed %d is" |
| 3657 | " different than the external" |
| 3658 | " link speed %d\n", vars->line_speed, |
| 3659 | ext_phy_line_speed); |
| 3660 | vars->phy_link_up = 0; |
| 3661 | } else if (prev_line_speed != vars->line_speed) { |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3662 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + params->port*4, |
| 3663 | 0); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3664 | msleep(1); |
| 3665 | } |
| 3666 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3667 | |
| 3668 | /* anything 10 and over uses the bmac */ |
| 3669 | link_10g = ((vars->line_speed == SPEED_10000) || |
| 3670 | (vars->line_speed == SPEED_12000) || |
| 3671 | (vars->line_speed == SPEED_12500) || |
| 3672 | (vars->line_speed == SPEED_13000) || |
| 3673 | (vars->line_speed == SPEED_15000) || |
| 3674 | (vars->line_speed == SPEED_16000)); |
| 3675 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3676 | bnx2x_link_int_ack(params, vars, link_10g); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3677 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3678 | /* |
| 3679 | * In case external phy link is up, and internal link is down |
| 3680 | * (not initialized yet probably after link initialization, it |
| 3681 | * needs to be initialized. |
| 3682 | * Note that after link down-up as result of cable plug, the xgxs |
| 3683 | * link would probably become up again without the need |
| 3684 | * initialize it |
| 3685 | */ |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3686 | if (!(SINGLE_MEDIA_DIRECT(params))) { |
| 3687 | DP(NETIF_MSG_LINK, "ext_phy_link_up = %d, int_link_up = %d," |
| 3688 | " init_preceding = %d\n", ext_phy_link_up, |
| 3689 | vars->phy_link_up, |
| 3690 | params->phy[EXT_PHY1].flags & |
| 3691 | FLAGS_INIT_XGXS_FIRST); |
| 3692 | if (!(params->phy[EXT_PHY1].flags & |
| 3693 | FLAGS_INIT_XGXS_FIRST) |
| 3694 | && ext_phy_link_up && !vars->phy_link_up) { |
| 3695 | vars->line_speed = ext_phy_line_speed; |
| 3696 | if (vars->line_speed < SPEED_1000) |
| 3697 | vars->phy_flags |= PHY_SGMII_FLAG; |
| 3698 | else |
| 3699 | vars->phy_flags &= ~PHY_SGMII_FLAG; |
| 3700 | bnx2x_init_internal_phy(¶ms->phy[INT_PHY], |
| 3701 | params, |
| 3702 | vars); |
| 3703 | } |
| 3704 | } |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3705 | /* |
| 3706 | * Link is up only if both local phy and external phy (in case of |
| 3707 | * non-direct board) are up |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3708 | */ |
| 3709 | vars->link_up = (vars->phy_link_up && |
| 3710 | (ext_phy_link_up || |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 3711 | SINGLE_MEDIA_DIRECT(params)) && |
| 3712 | (phy_vars[active_external_phy].fault_detected == 0)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3713 | |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3714 | if (vars->link_up) |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3715 | rc = bnx2x_update_link_up(params, vars, link_10g); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3716 | else |
| 3717 | rc = bnx2x_update_link_down(params, vars); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3718 | |
| 3719 | return rc; |
| 3720 | } |
| 3721 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3722 | |
| 3723 | /*****************************************************************************/ |
| 3724 | /* External Phy section */ |
| 3725 | /*****************************************************************************/ |
| 3726 | void bnx2x_ext_phy_hw_reset(struct bnx2x *bp, u8 port) |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3727 | { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3728 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3729 | MISC_REGISTERS_GPIO_OUTPUT_LOW, port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3730 | msleep(1); |
| 3731 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3732 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, port); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3733 | } |
| 3734 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3735 | static void bnx2x_save_spirom_version(struct bnx2x *bp, u8 port, |
| 3736 | u32 spirom_ver, u32 ver_addr) |
| 3737 | { |
| 3738 | DP(NETIF_MSG_LINK, "FW version 0x%x:0x%x for port %d\n", |
| 3739 | (u16)(spirom_ver>>16), (u16)spirom_ver, port); |
| 3740 | |
| 3741 | if (ver_addr) |
| 3742 | REG_WR(bp, ver_addr, spirom_ver); |
| 3743 | } |
| 3744 | |
| 3745 | static void bnx2x_save_bcm_spirom_ver(struct bnx2x *bp, |
| 3746 | struct bnx2x_phy *phy, |
| 3747 | u8 port) |
| 3748 | { |
| 3749 | u16 fw_ver1, fw_ver2; |
| 3750 | |
| 3751 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3752 | MDIO_PMA_REG_ROM_VER1, &fw_ver1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3753 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3754 | MDIO_PMA_REG_ROM_VER2, &fw_ver2); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3755 | bnx2x_save_spirom_version(bp, port, (u32)(fw_ver1<<16 | fw_ver2), |
| 3756 | phy->ver_addr); |
| 3757 | } |
| 3758 | |
| 3759 | static void bnx2x_ext_phy_set_pause(struct link_params *params, |
| 3760 | struct bnx2x_phy *phy, |
| 3761 | struct link_vars *vars) |
| 3762 | { |
| 3763 | u16 val; |
| 3764 | struct bnx2x *bp = params->bp; |
| 3765 | /* read modify write pause advertizing */ |
| 3766 | bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_ADV_PAUSE, &val); |
| 3767 | |
| 3768 | val &= ~MDIO_AN_REG_ADV_PAUSE_BOTH; |
| 3769 | |
| 3770 | /* Please refer to Table 28B-3 of 802.3ab-1999 spec. */ |
| 3771 | bnx2x_calc_ieee_aneg_adv(phy, params, &vars->ieee_fc); |
| 3772 | if ((vars->ieee_fc & |
| 3773 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC) == |
| 3774 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC) { |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3775 | val |= MDIO_AN_REG_ADV_PAUSE_ASYMMETRIC; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3776 | } |
| 3777 | if ((vars->ieee_fc & |
| 3778 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) == |
| 3779 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) { |
| 3780 | val |= MDIO_AN_REG_ADV_PAUSE_PAUSE; |
| 3781 | } |
| 3782 | DP(NETIF_MSG_LINK, "Ext phy AN advertize 0x%x\n", val); |
| 3783 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_ADV_PAUSE, val); |
| 3784 | } |
| 3785 | |
| 3786 | static u8 bnx2x_ext_phy_resolve_fc(struct bnx2x_phy *phy, |
| 3787 | struct link_params *params, |
| 3788 | struct link_vars *vars) |
| 3789 | { |
| 3790 | struct bnx2x *bp = params->bp; |
| 3791 | u16 ld_pause; /* local */ |
| 3792 | u16 lp_pause; /* link partner */ |
| 3793 | u16 pause_result; |
| 3794 | u8 ret = 0; |
| 3795 | /* read twice */ |
| 3796 | |
| 3797 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 3798 | |
| 3799 | if (phy->req_flow_ctrl != BNX2X_FLOW_CTRL_AUTO) |
| 3800 | vars->flow_ctrl = phy->req_flow_ctrl; |
| 3801 | else if (phy->req_line_speed != SPEED_AUTO_NEG) |
| 3802 | vars->flow_ctrl = params->req_fc_auto_adv; |
| 3803 | else if (vars->link_status & LINK_STATUS_AUTO_NEGOTIATE_COMPLETE) { |
| 3804 | ret = 1; |
| 3805 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3806 | MDIO_AN_DEVAD, |
| 3807 | MDIO_AN_REG_ADV_PAUSE, &ld_pause); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3808 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3809 | MDIO_AN_DEVAD, |
| 3810 | MDIO_AN_REG_LP_AUTO_NEG, &lp_pause); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3811 | pause_result = (ld_pause & |
| 3812 | MDIO_AN_REG_ADV_PAUSE_MASK) >> 8; |
| 3813 | pause_result |= (lp_pause & |
| 3814 | MDIO_AN_REG_ADV_PAUSE_MASK) >> 10; |
| 3815 | DP(NETIF_MSG_LINK, "Ext PHY pause result 0x%x\n", |
| 3816 | pause_result); |
| 3817 | bnx2x_pause_resolve(vars, pause_result); |
| 3818 | } |
| 3819 | return ret; |
| 3820 | } |
| 3821 | |
| 3822 | static void bnx2x_ext_phy_10G_an_resolve(struct bnx2x *bp, |
| 3823 | struct bnx2x_phy *phy, |
| 3824 | struct link_vars *vars) |
| 3825 | { |
| 3826 | u16 val; |
| 3827 | bnx2x_cl45_read(bp, phy, |
| 3828 | MDIO_AN_DEVAD, |
| 3829 | MDIO_AN_REG_STATUS, &val); |
| 3830 | bnx2x_cl45_read(bp, phy, |
| 3831 | MDIO_AN_DEVAD, |
| 3832 | MDIO_AN_REG_STATUS, &val); |
| 3833 | if (val & (1<<5)) |
| 3834 | vars->link_status |= LINK_STATUS_AUTO_NEGOTIATE_COMPLETE; |
| 3835 | if ((val & (1<<0)) == 0) |
| 3836 | vars->link_status |= LINK_STATUS_PARALLEL_DETECTION_USED; |
| 3837 | } |
| 3838 | |
| 3839 | /******************************************************************/ |
| 3840 | /* common BCM8073/BCM8727 PHY SECTION */ |
| 3841 | /******************************************************************/ |
| 3842 | static void bnx2x_8073_resolve_fc(struct bnx2x_phy *phy, |
| 3843 | struct link_params *params, |
| 3844 | struct link_vars *vars) |
| 3845 | { |
| 3846 | struct bnx2x *bp = params->bp; |
| 3847 | if (phy->req_line_speed == SPEED_10 || |
| 3848 | phy->req_line_speed == SPEED_100) { |
| 3849 | vars->flow_ctrl = phy->req_flow_ctrl; |
| 3850 | return; |
| 3851 | } |
| 3852 | |
| 3853 | if (bnx2x_ext_phy_resolve_fc(phy, params, vars) && |
| 3854 | (vars->flow_ctrl == BNX2X_FLOW_CTRL_NONE)) { |
| 3855 | u16 pause_result; |
| 3856 | u16 ld_pause; /* local */ |
| 3857 | u16 lp_pause; /* link partner */ |
| 3858 | bnx2x_cl45_read(bp, phy, |
| 3859 | MDIO_AN_DEVAD, |
| 3860 | MDIO_AN_REG_CL37_FC_LD, &ld_pause); |
| 3861 | |
| 3862 | bnx2x_cl45_read(bp, phy, |
| 3863 | MDIO_AN_DEVAD, |
| 3864 | MDIO_AN_REG_CL37_FC_LP, &lp_pause); |
| 3865 | pause_result = (ld_pause & |
| 3866 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) >> 5; |
| 3867 | pause_result |= (lp_pause & |
| 3868 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) >> 7; |
| 3869 | |
| 3870 | bnx2x_pause_resolve(vars, pause_result); |
| 3871 | DP(NETIF_MSG_LINK, "Ext PHY CL37 pause result 0x%x\n", |
| 3872 | pause_result); |
| 3873 | } |
| 3874 | } |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 3875 | static int bnx2x_8073_8727_external_rom_boot(struct bnx2x *bp, |
| 3876 | struct bnx2x_phy *phy, |
| 3877 | u8 port) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3878 | { |
Yaniv Rosner | 5c99274b | 2011-01-18 04:33:36 +0000 | [diff] [blame] | 3879 | u32 count = 0; |
| 3880 | u16 fw_ver1, fw_msgout; |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 3881 | int rc = 0; |
Yaniv Rosner | 5c99274b | 2011-01-18 04:33:36 +0000 | [diff] [blame] | 3882 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3883 | /* Boot port from external ROM */ |
| 3884 | /* EDC grst */ |
| 3885 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3886 | MDIO_PMA_DEVAD, |
| 3887 | MDIO_PMA_REG_GEN_CTRL, |
| 3888 | 0x0001); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3889 | |
| 3890 | /* ucode reboot and rst */ |
| 3891 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3892 | MDIO_PMA_DEVAD, |
| 3893 | MDIO_PMA_REG_GEN_CTRL, |
| 3894 | 0x008c); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3895 | |
| 3896 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3897 | MDIO_PMA_DEVAD, |
| 3898 | MDIO_PMA_REG_MISC_CTRL1, 0x0001); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3899 | |
| 3900 | /* Reset internal microprocessor */ |
| 3901 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3902 | MDIO_PMA_DEVAD, |
| 3903 | MDIO_PMA_REG_GEN_CTRL, |
| 3904 | MDIO_PMA_REG_GEN_CTRL_ROM_MICRO_RESET); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3905 | |
| 3906 | /* Release srst bit */ |
| 3907 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3908 | MDIO_PMA_DEVAD, |
| 3909 | MDIO_PMA_REG_GEN_CTRL, |
| 3910 | MDIO_PMA_REG_GEN_CTRL_ROM_RESET_INTERNAL_MP); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3911 | |
Yaniv Rosner | 5c99274b | 2011-01-18 04:33:36 +0000 | [diff] [blame] | 3912 | /* Delay 100ms per the PHY specifications */ |
| 3913 | msleep(100); |
| 3914 | |
| 3915 | /* 8073 sometimes taking longer to download */ |
| 3916 | do { |
| 3917 | count++; |
| 3918 | if (count > 300) { |
| 3919 | DP(NETIF_MSG_LINK, |
| 3920 | "bnx2x_8073_8727_external_rom_boot port %x:" |
| 3921 | "Download failed. fw version = 0x%x\n", |
| 3922 | port, fw_ver1); |
| 3923 | rc = -EINVAL; |
| 3924 | break; |
| 3925 | } |
| 3926 | |
| 3927 | bnx2x_cl45_read(bp, phy, |
| 3928 | MDIO_PMA_DEVAD, |
| 3929 | MDIO_PMA_REG_ROM_VER1, &fw_ver1); |
| 3930 | bnx2x_cl45_read(bp, phy, |
| 3931 | MDIO_PMA_DEVAD, |
| 3932 | MDIO_PMA_REG_M8051_MSGOUT_REG, &fw_msgout); |
| 3933 | |
| 3934 | msleep(1); |
| 3935 | } while (fw_ver1 == 0 || fw_ver1 == 0x4321 || |
| 3936 | ((fw_msgout & 0xff) != 0x03 && (phy->type == |
| 3937 | PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073))); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3938 | |
| 3939 | /* Clear ser_boot_ctl bit */ |
| 3940 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3941 | MDIO_PMA_DEVAD, |
| 3942 | MDIO_PMA_REG_MISC_CTRL1, 0x0000); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3943 | bnx2x_save_bcm_spirom_ver(bp, phy, port); |
Yaniv Rosner | 5c99274b | 2011-01-18 04:33:36 +0000 | [diff] [blame] | 3944 | |
| 3945 | DP(NETIF_MSG_LINK, |
| 3946 | "bnx2x_8073_8727_external_rom_boot port %x:" |
| 3947 | "Download complete. fw version = 0x%x\n", |
| 3948 | port, fw_ver1); |
| 3949 | |
| 3950 | return rc; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3951 | } |
| 3952 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3953 | /******************************************************************/ |
| 3954 | /* BCM8073 PHY SECTION */ |
| 3955 | /******************************************************************/ |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 3956 | static int bnx2x_8073_is_snr_needed(struct bnx2x *bp, struct bnx2x_phy *phy) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3957 | { |
| 3958 | /* This is only required for 8073A1, version 102 only */ |
| 3959 | u16 val; |
| 3960 | |
| 3961 | /* Read 8073 HW revision*/ |
| 3962 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3963 | MDIO_PMA_DEVAD, |
| 3964 | MDIO_PMA_REG_8073_CHIP_REV, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3965 | |
| 3966 | if (val != 1) { |
| 3967 | /* No need to workaround in 8073 A1 */ |
| 3968 | return 0; |
| 3969 | } |
| 3970 | |
| 3971 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3972 | MDIO_PMA_DEVAD, |
| 3973 | MDIO_PMA_REG_ROM_VER2, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3974 | |
| 3975 | /* SNR should be applied only for version 0x102 */ |
| 3976 | if (val != 0x102) |
| 3977 | return 0; |
| 3978 | |
| 3979 | return 1; |
| 3980 | } |
| 3981 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 3982 | static int bnx2x_8073_xaui_wa(struct bnx2x *bp, struct bnx2x_phy *phy) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3983 | { |
| 3984 | u16 val, cnt, cnt1 ; |
| 3985 | |
| 3986 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3987 | MDIO_PMA_DEVAD, |
| 3988 | MDIO_PMA_REG_8073_CHIP_REV, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3989 | |
| 3990 | if (val > 0) { |
| 3991 | /* No need to workaround in 8073 A1 */ |
| 3992 | return 0; |
| 3993 | } |
| 3994 | /* XAUI workaround in 8073 A0: */ |
| 3995 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3996 | /* |
| 3997 | * After loading the boot ROM and restarting Autoneg, poll |
| 3998 | * Dev1, Reg $C820: |
| 3999 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4000 | |
| 4001 | for (cnt = 0; cnt < 1000; cnt++) { |
| 4002 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4003 | MDIO_PMA_DEVAD, |
| 4004 | MDIO_PMA_REG_8073_SPEED_LINK_STATUS, |
| 4005 | &val); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 4006 | /* |
| 4007 | * If bit [14] = 0 or bit [13] = 0, continue on with |
| 4008 | * system initialization (XAUI work-around not required, as |
| 4009 | * these bits indicate 2.5G or 1G link up). |
| 4010 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4011 | if (!(val & (1<<14)) || !(val & (1<<13))) { |
| 4012 | DP(NETIF_MSG_LINK, "XAUI work-around not required\n"); |
| 4013 | return 0; |
| 4014 | } else if (!(val & (1<<15))) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 4015 | DP(NETIF_MSG_LINK, "bit 15 went off\n"); |
| 4016 | /* |
| 4017 | * If bit 15 is 0, then poll Dev1, Reg $C841 until it's |
| 4018 | * MSB (bit15) goes to 1 (indicating that the XAUI |
| 4019 | * workaround has completed), then continue on with |
| 4020 | * system initialization. |
| 4021 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4022 | for (cnt1 = 0; cnt1 < 1000; cnt1++) { |
| 4023 | bnx2x_cl45_read(bp, phy, |
| 4024 | MDIO_PMA_DEVAD, |
| 4025 | MDIO_PMA_REG_8073_XAUI_WA, &val); |
| 4026 | if (val & (1<<15)) { |
| 4027 | DP(NETIF_MSG_LINK, |
| 4028 | "XAUI workaround has completed\n"); |
| 4029 | return 0; |
| 4030 | } |
| 4031 | msleep(3); |
| 4032 | } |
| 4033 | break; |
| 4034 | } |
| 4035 | msleep(3); |
| 4036 | } |
| 4037 | DP(NETIF_MSG_LINK, "Warning: XAUI work-around timeout !!!\n"); |
| 4038 | return -EINVAL; |
| 4039 | } |
| 4040 | |
| 4041 | static void bnx2x_807x_force_10G(struct bnx2x *bp, struct bnx2x_phy *phy) |
| 4042 | { |
| 4043 | /* Force KR or KX */ |
| 4044 | bnx2x_cl45_write(bp, phy, |
| 4045 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 0x2040); |
| 4046 | bnx2x_cl45_write(bp, phy, |
| 4047 | MDIO_PMA_DEVAD, MDIO_PMA_REG_10G_CTRL2, 0x000b); |
| 4048 | bnx2x_cl45_write(bp, phy, |
| 4049 | MDIO_PMA_DEVAD, MDIO_PMA_REG_BCM_CTRL, 0x0000); |
| 4050 | bnx2x_cl45_write(bp, phy, |
| 4051 | MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, 0x0000); |
| 4052 | } |
| 4053 | |
| 4054 | static void bnx2x_8073_set_pause_cl37(struct link_params *params, |
| 4055 | struct bnx2x_phy *phy, |
| 4056 | struct link_vars *vars) |
| 4057 | { |
| 4058 | u16 cl37_val; |
| 4059 | struct bnx2x *bp = params->bp; |
| 4060 | bnx2x_cl45_read(bp, phy, |
| 4061 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_FC_LD, &cl37_val); |
| 4062 | |
| 4063 | cl37_val &= ~MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH; |
| 4064 | /* Please refer to Table 28B-3 of 802.3ab-1999 spec. */ |
| 4065 | bnx2x_calc_ieee_aneg_adv(phy, params, &vars->ieee_fc); |
| 4066 | if ((vars->ieee_fc & |
| 4067 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_SYMMETRIC) == |
| 4068 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_SYMMETRIC) { |
| 4069 | cl37_val |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_SYMMETRIC; |
| 4070 | } |
| 4071 | if ((vars->ieee_fc & |
| 4072 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC) == |
| 4073 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC) { |
| 4074 | cl37_val |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC; |
| 4075 | } |
| 4076 | if ((vars->ieee_fc & |
| 4077 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) == |
| 4078 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) { |
| 4079 | cl37_val |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH; |
| 4080 | } |
| 4081 | DP(NETIF_MSG_LINK, |
| 4082 | "Ext phy AN advertize cl37 0x%x\n", cl37_val); |
| 4083 | |
| 4084 | bnx2x_cl45_write(bp, phy, |
| 4085 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_FC_LD, cl37_val); |
| 4086 | msleep(500); |
| 4087 | } |
| 4088 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 4089 | static int bnx2x_8073_config_init(struct bnx2x_phy *phy, |
| 4090 | struct link_params *params, |
| 4091 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4092 | { |
| 4093 | struct bnx2x *bp = params->bp; |
| 4094 | u16 val = 0, tmp1; |
| 4095 | u8 gpio_port; |
| 4096 | DP(NETIF_MSG_LINK, "Init 8073\n"); |
| 4097 | |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 4098 | if (CHIP_IS_E2(bp)) |
| 4099 | gpio_port = BP_PATH(bp); |
| 4100 | else |
| 4101 | gpio_port = params->port; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4102 | /* Restore normal power mode*/ |
| 4103 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4104 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, gpio_port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4105 | |
| 4106 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4107 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, gpio_port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4108 | |
| 4109 | /* enable LASI */ |
| 4110 | bnx2x_cl45_write(bp, phy, |
| 4111 | MDIO_PMA_DEVAD, MDIO_PMA_REG_RX_ALARM_CTRL, (1<<2)); |
| 4112 | bnx2x_cl45_write(bp, phy, |
| 4113 | MDIO_PMA_DEVAD, MDIO_PMA_REG_LASI_CTRL, 0x0004); |
| 4114 | |
| 4115 | bnx2x_8073_set_pause_cl37(params, phy, vars); |
| 4116 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4117 | bnx2x_cl45_read(bp, phy, |
| 4118 | MDIO_PMA_DEVAD, MDIO_PMA_REG_M8051_MSGOUT_REG, &tmp1); |
| 4119 | |
| 4120 | bnx2x_cl45_read(bp, phy, |
| 4121 | MDIO_PMA_DEVAD, MDIO_PMA_REG_RX_ALARM, &tmp1); |
| 4122 | |
| 4123 | DP(NETIF_MSG_LINK, "Before rom RX_ALARM(port1): 0x%x\n", tmp1); |
| 4124 | |
Yaniv Rosner | 74d7a11 | 2011-01-18 04:33:18 +0000 | [diff] [blame] | 4125 | /* Swap polarity if required - Must be done only in non-1G mode */ |
| 4126 | if (params->lane_config & PORT_HW_CFG_SWAP_PHY_POLARITY_ENABLED) { |
| 4127 | /* Configure the 8073 to swap _P and _N of the KR lines */ |
| 4128 | DP(NETIF_MSG_LINK, "Swapping polarity for the 8073\n"); |
| 4129 | /* 10G Rx/Tx and 1G Tx signal polarity swap */ |
| 4130 | bnx2x_cl45_read(bp, phy, |
| 4131 | MDIO_PMA_DEVAD, |
| 4132 | MDIO_PMA_REG_8073_OPT_DIGITAL_CTRL, &val); |
| 4133 | bnx2x_cl45_write(bp, phy, |
| 4134 | MDIO_PMA_DEVAD, |
| 4135 | MDIO_PMA_REG_8073_OPT_DIGITAL_CTRL, |
| 4136 | (val | (3<<9))); |
| 4137 | } |
| 4138 | |
| 4139 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4140 | /* Enable CL37 BAM */ |
Yaniv Rosner | 121839b | 2010-11-01 05:32:38 +0000 | [diff] [blame] | 4141 | if (REG_RD(bp, params->shmem_base + |
| 4142 | offsetof(struct shmem_region, dev_info. |
| 4143 | port_hw_config[params->port].default_cfg)) & |
| 4144 | PORT_HW_CFG_ENABLE_BAM_ON_KR_ENABLED) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4145 | |
Yaniv Rosner | 121839b | 2010-11-01 05:32:38 +0000 | [diff] [blame] | 4146 | bnx2x_cl45_read(bp, phy, |
| 4147 | MDIO_AN_DEVAD, |
| 4148 | MDIO_AN_REG_8073_BAM, &val); |
| 4149 | bnx2x_cl45_write(bp, phy, |
| 4150 | MDIO_AN_DEVAD, |
| 4151 | MDIO_AN_REG_8073_BAM, val | 1); |
| 4152 | DP(NETIF_MSG_LINK, "Enable CL37 BAM on KR\n"); |
| 4153 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4154 | if (params->loopback_mode == LOOPBACK_EXT) { |
| 4155 | bnx2x_807x_force_10G(bp, phy); |
| 4156 | DP(NETIF_MSG_LINK, "Forced speed 10G on 807X\n"); |
| 4157 | return 0; |
| 4158 | } else { |
| 4159 | bnx2x_cl45_write(bp, phy, |
| 4160 | MDIO_PMA_DEVAD, MDIO_PMA_REG_BCM_CTRL, 0x0002); |
| 4161 | } |
| 4162 | if (phy->req_line_speed != SPEED_AUTO_NEG) { |
| 4163 | if (phy->req_line_speed == SPEED_10000) { |
| 4164 | val = (1<<7); |
| 4165 | } else if (phy->req_line_speed == SPEED_2500) { |
| 4166 | val = (1<<5); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 4167 | /* |
| 4168 | * Note that 2.5G works only when used with 1G |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 4169 | * advertisement |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 4170 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4171 | } else |
| 4172 | val = (1<<5); |
| 4173 | } else { |
| 4174 | val = 0; |
| 4175 | if (phy->speed_cap_mask & |
| 4176 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G) |
| 4177 | val |= (1<<7); |
| 4178 | |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 4179 | /* Note that 2.5G works only when used with 1G advertisement */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4180 | if (phy->speed_cap_mask & |
| 4181 | (PORT_HW_CFG_SPEED_CAPABILITY_D0_1G | |
| 4182 | PORT_HW_CFG_SPEED_CAPABILITY_D0_2_5G)) |
| 4183 | val |= (1<<5); |
| 4184 | DP(NETIF_MSG_LINK, "807x autoneg val = 0x%x\n", val); |
| 4185 | } |
| 4186 | |
| 4187 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_ADV, val); |
| 4188 | bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_8073_2_5G, &tmp1); |
| 4189 | |
| 4190 | if (((phy->speed_cap_mask & PORT_HW_CFG_SPEED_CAPABILITY_D0_2_5G) && |
| 4191 | (phy->req_line_speed == SPEED_AUTO_NEG)) || |
| 4192 | (phy->req_line_speed == SPEED_2500)) { |
| 4193 | u16 phy_ver; |
| 4194 | /* Allow 2.5G for A1 and above */ |
| 4195 | bnx2x_cl45_read(bp, phy, |
| 4196 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8073_CHIP_REV, |
| 4197 | &phy_ver); |
| 4198 | DP(NETIF_MSG_LINK, "Add 2.5G\n"); |
| 4199 | if (phy_ver > 0) |
| 4200 | tmp1 |= 1; |
| 4201 | else |
| 4202 | tmp1 &= 0xfffe; |
| 4203 | } else { |
| 4204 | DP(NETIF_MSG_LINK, "Disable 2.5G\n"); |
| 4205 | tmp1 &= 0xfffe; |
| 4206 | } |
| 4207 | |
| 4208 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_8073_2_5G, tmp1); |
| 4209 | /* Add support for CL37 (passive mode) II */ |
| 4210 | |
| 4211 | bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_CL37_FC_LD, &tmp1); |
| 4212 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_CL37_FC_LD, |
| 4213 | (tmp1 | ((phy->req_duplex == DUPLEX_FULL) ? |
| 4214 | 0x20 : 0x40))); |
| 4215 | |
| 4216 | /* Add support for CL37 (passive mode) III */ |
| 4217 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_CL37_AN, 0x1000); |
| 4218 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 4219 | /* |
| 4220 | * The SNR will improve about 2db by changing BW and FEE main |
| 4221 | * tap. Rest commands are executed after link is up |
| 4222 | * Change FFE main cursor to 5 in EDC register |
| 4223 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4224 | if (bnx2x_8073_is_snr_needed(bp, phy)) |
| 4225 | bnx2x_cl45_write(bp, phy, |
| 4226 | MDIO_PMA_DEVAD, MDIO_PMA_REG_EDC_FFE_MAIN, |
| 4227 | 0xFB0C); |
| 4228 | |
| 4229 | /* Enable FEC (Forware Error Correction) Request in the AN */ |
| 4230 | bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_ADV2, &tmp1); |
| 4231 | tmp1 |= (1<<15); |
| 4232 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_ADV2, tmp1); |
| 4233 | |
| 4234 | bnx2x_ext_phy_set_pause(params, phy, vars); |
| 4235 | |
| 4236 | /* Restart autoneg */ |
| 4237 | msleep(500); |
| 4238 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, 0x1200); |
| 4239 | DP(NETIF_MSG_LINK, "807x Autoneg Restart: Advertise 1G=%x, 10G=%x\n", |
| 4240 | ((val & (1<<5)) > 0), ((val & (1<<7)) > 0)); |
| 4241 | return 0; |
| 4242 | } |
| 4243 | |
| 4244 | static u8 bnx2x_8073_read_status(struct bnx2x_phy *phy, |
| 4245 | struct link_params *params, |
| 4246 | struct link_vars *vars) |
| 4247 | { |
| 4248 | struct bnx2x *bp = params->bp; |
| 4249 | u8 link_up = 0; |
| 4250 | u16 val1, val2; |
| 4251 | u16 link_status = 0; |
| 4252 | u16 an1000_status = 0; |
| 4253 | |
| 4254 | bnx2x_cl45_read(bp, phy, |
| 4255 | MDIO_PMA_DEVAD, MDIO_PMA_REG_LASI_STATUS, &val1); |
| 4256 | |
| 4257 | DP(NETIF_MSG_LINK, "8703 LASI status 0x%x\n", val1); |
| 4258 | |
| 4259 | /* clear the interrupt LASI status register */ |
| 4260 | bnx2x_cl45_read(bp, phy, |
| 4261 | MDIO_PCS_DEVAD, MDIO_PCS_REG_STATUS, &val2); |
| 4262 | bnx2x_cl45_read(bp, phy, |
| 4263 | MDIO_PCS_DEVAD, MDIO_PCS_REG_STATUS, &val1); |
| 4264 | DP(NETIF_MSG_LINK, "807x PCS status 0x%x->0x%x\n", val2, val1); |
| 4265 | /* Clear MSG-OUT */ |
| 4266 | bnx2x_cl45_read(bp, phy, |
| 4267 | MDIO_PMA_DEVAD, MDIO_PMA_REG_M8051_MSGOUT_REG, &val1); |
| 4268 | |
| 4269 | /* Check the LASI */ |
| 4270 | bnx2x_cl45_read(bp, phy, |
| 4271 | MDIO_PMA_DEVAD, MDIO_PMA_REG_RX_ALARM, &val2); |
| 4272 | |
| 4273 | DP(NETIF_MSG_LINK, "KR 0x9003 0x%x\n", val2); |
| 4274 | |
| 4275 | /* Check the link status */ |
| 4276 | bnx2x_cl45_read(bp, phy, |
| 4277 | MDIO_PCS_DEVAD, MDIO_PCS_REG_STATUS, &val2); |
| 4278 | DP(NETIF_MSG_LINK, "KR PCS status 0x%x\n", val2); |
| 4279 | |
| 4280 | bnx2x_cl45_read(bp, phy, |
| 4281 | MDIO_PMA_DEVAD, MDIO_PMA_REG_STATUS, &val2); |
| 4282 | bnx2x_cl45_read(bp, phy, |
| 4283 | MDIO_PMA_DEVAD, MDIO_PMA_REG_STATUS, &val1); |
| 4284 | link_up = ((val1 & 4) == 4); |
| 4285 | DP(NETIF_MSG_LINK, "PMA_REG_STATUS=0x%x\n", val1); |
| 4286 | |
| 4287 | if (link_up && |
| 4288 | ((phy->req_line_speed != SPEED_10000))) { |
| 4289 | if (bnx2x_8073_xaui_wa(bp, phy) != 0) |
| 4290 | return 0; |
| 4291 | } |
| 4292 | bnx2x_cl45_read(bp, phy, |
| 4293 | MDIO_AN_DEVAD, MDIO_AN_REG_LINK_STATUS, &an1000_status); |
| 4294 | bnx2x_cl45_read(bp, phy, |
| 4295 | MDIO_AN_DEVAD, MDIO_AN_REG_LINK_STATUS, &an1000_status); |
| 4296 | |
| 4297 | /* Check the link status on 1.1.2 */ |
| 4298 | bnx2x_cl45_read(bp, phy, |
| 4299 | MDIO_PMA_DEVAD, MDIO_PMA_REG_STATUS, &val2); |
| 4300 | bnx2x_cl45_read(bp, phy, |
| 4301 | MDIO_PMA_DEVAD, MDIO_PMA_REG_STATUS, &val1); |
| 4302 | DP(NETIF_MSG_LINK, "KR PMA status 0x%x->0x%x," |
| 4303 | "an_link_status=0x%x\n", val2, val1, an1000_status); |
| 4304 | |
| 4305 | link_up = (((val1 & 4) == 4) || (an1000_status & (1<<1))); |
| 4306 | if (link_up && bnx2x_8073_is_snr_needed(bp, phy)) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 4307 | /* |
| 4308 | * The SNR will improve about 2dbby changing the BW and FEE main |
| 4309 | * tap. The 1st write to change FFE main tap is set before |
| 4310 | * restart AN. Change PLL Bandwidth in EDC register |
| 4311 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4312 | bnx2x_cl45_write(bp, phy, |
| 4313 | MDIO_PMA_DEVAD, MDIO_PMA_REG_PLL_BANDWIDTH, |
| 4314 | 0x26BC); |
| 4315 | |
| 4316 | /* Change CDR Bandwidth in EDC register */ |
| 4317 | bnx2x_cl45_write(bp, phy, |
| 4318 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CDR_BANDWIDTH, |
| 4319 | 0x0333); |
| 4320 | } |
| 4321 | bnx2x_cl45_read(bp, phy, |
| 4322 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8073_SPEED_LINK_STATUS, |
| 4323 | &link_status); |
| 4324 | |
| 4325 | /* Bits 0..2 --> speed detected, bits 13..15--> link is down */ |
| 4326 | if ((link_status & (1<<2)) && (!(link_status & (1<<15)))) { |
| 4327 | link_up = 1; |
| 4328 | vars->line_speed = SPEED_10000; |
| 4329 | DP(NETIF_MSG_LINK, "port %x: External link up in 10G\n", |
| 4330 | params->port); |
| 4331 | } else if ((link_status & (1<<1)) && (!(link_status & (1<<14)))) { |
| 4332 | link_up = 1; |
| 4333 | vars->line_speed = SPEED_2500; |
| 4334 | DP(NETIF_MSG_LINK, "port %x: External link up in 2.5G\n", |
| 4335 | params->port); |
| 4336 | } else if ((link_status & (1<<0)) && (!(link_status & (1<<13)))) { |
| 4337 | link_up = 1; |
| 4338 | vars->line_speed = SPEED_1000; |
| 4339 | DP(NETIF_MSG_LINK, "port %x: External link up in 1G\n", |
| 4340 | params->port); |
| 4341 | } else { |
| 4342 | link_up = 0; |
| 4343 | DP(NETIF_MSG_LINK, "port %x: External link is down\n", |
| 4344 | params->port); |
| 4345 | } |
| 4346 | |
| 4347 | if (link_up) { |
Yaniv Rosner | 74d7a11 | 2011-01-18 04:33:18 +0000 | [diff] [blame] | 4348 | /* Swap polarity if required */ |
| 4349 | if (params->lane_config & |
| 4350 | PORT_HW_CFG_SWAP_PHY_POLARITY_ENABLED) { |
| 4351 | /* Configure the 8073 to swap P and N of the KR lines */ |
| 4352 | bnx2x_cl45_read(bp, phy, |
| 4353 | MDIO_XS_DEVAD, |
| 4354 | MDIO_XS_REG_8073_RX_CTRL_PCIE, &val1); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 4355 | /* |
| 4356 | * Set bit 3 to invert Rx in 1G mode and clear this bit |
| 4357 | * when it`s in 10G mode. |
| 4358 | */ |
Yaniv Rosner | 74d7a11 | 2011-01-18 04:33:18 +0000 | [diff] [blame] | 4359 | if (vars->line_speed == SPEED_1000) { |
| 4360 | DP(NETIF_MSG_LINK, "Swapping 1G polarity for" |
| 4361 | "the 8073\n"); |
| 4362 | val1 |= (1<<3); |
| 4363 | } else |
| 4364 | val1 &= ~(1<<3); |
| 4365 | |
| 4366 | bnx2x_cl45_write(bp, phy, |
| 4367 | MDIO_XS_DEVAD, |
| 4368 | MDIO_XS_REG_8073_RX_CTRL_PCIE, |
| 4369 | val1); |
| 4370 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4371 | bnx2x_ext_phy_10G_an_resolve(bp, phy, vars); |
| 4372 | bnx2x_8073_resolve_fc(phy, params, vars); |
Yaniv Rosner | 791f18c | 2011-01-18 04:33:42 +0000 | [diff] [blame] | 4373 | vars->duplex = DUPLEX_FULL; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4374 | } |
| 4375 | return link_up; |
| 4376 | } |
| 4377 | |
| 4378 | static void bnx2x_8073_link_reset(struct bnx2x_phy *phy, |
| 4379 | struct link_params *params) |
| 4380 | { |
| 4381 | struct bnx2x *bp = params->bp; |
| 4382 | u8 gpio_port; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 4383 | if (CHIP_IS_E2(bp)) |
| 4384 | gpio_port = BP_PATH(bp); |
| 4385 | else |
| 4386 | gpio_port = params->port; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4387 | DP(NETIF_MSG_LINK, "Setting 8073 port %d into low power mode\n", |
| 4388 | gpio_port); |
| 4389 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4390 | MISC_REGISTERS_GPIO_OUTPUT_LOW, |
| 4391 | gpio_port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4392 | } |
| 4393 | |
| 4394 | /******************************************************************/ |
| 4395 | /* BCM8705 PHY SECTION */ |
| 4396 | /******************************************************************/ |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 4397 | static int bnx2x_8705_config_init(struct bnx2x_phy *phy, |
| 4398 | struct link_params *params, |
| 4399 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4400 | { |
| 4401 | struct bnx2x *bp = params->bp; |
| 4402 | DP(NETIF_MSG_LINK, "init 8705\n"); |
| 4403 | /* Restore normal power mode*/ |
| 4404 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4405 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, params->port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4406 | /* HW reset */ |
| 4407 | bnx2x_ext_phy_hw_reset(bp, params->port); |
| 4408 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 0xa040); |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 4409 | bnx2x_wait_reset_complete(bp, phy, params); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4410 | |
| 4411 | bnx2x_cl45_write(bp, phy, |
| 4412 | MDIO_PMA_DEVAD, MDIO_PMA_REG_MISC_CTRL, 0x8288); |
| 4413 | bnx2x_cl45_write(bp, phy, |
| 4414 | MDIO_PMA_DEVAD, MDIO_PMA_REG_PHY_IDENTIFIER, 0x7fbf); |
| 4415 | bnx2x_cl45_write(bp, phy, |
| 4416 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CMU_PLL_BYPASS, 0x0100); |
| 4417 | bnx2x_cl45_write(bp, phy, |
| 4418 | MDIO_WIS_DEVAD, MDIO_WIS_REG_LASI_CNTL, 0x1); |
| 4419 | /* BCM8705 doesn't have microcode, hence the 0 */ |
| 4420 | bnx2x_save_spirom_version(bp, params->port, params->shmem_base, 0); |
| 4421 | return 0; |
| 4422 | } |
| 4423 | |
| 4424 | static u8 bnx2x_8705_read_status(struct bnx2x_phy *phy, |
| 4425 | struct link_params *params, |
| 4426 | struct link_vars *vars) |
| 4427 | { |
| 4428 | u8 link_up = 0; |
| 4429 | u16 val1, rx_sd; |
| 4430 | struct bnx2x *bp = params->bp; |
| 4431 | DP(NETIF_MSG_LINK, "read status 8705\n"); |
| 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_WIS_DEVAD, MDIO_WIS_REG_LASI_STATUS, &val1); |
| 4438 | DP(NETIF_MSG_LINK, "8705 LASI status 0x%x\n", val1); |
| 4439 | |
| 4440 | bnx2x_cl45_read(bp, phy, |
| 4441 | MDIO_PMA_DEVAD, MDIO_PMA_REG_RX_SD, &rx_sd); |
| 4442 | |
| 4443 | bnx2x_cl45_read(bp, phy, |
| 4444 | MDIO_PMA_DEVAD, 0xc809, &val1); |
| 4445 | bnx2x_cl45_read(bp, phy, |
| 4446 | MDIO_PMA_DEVAD, 0xc809, &val1); |
| 4447 | |
| 4448 | DP(NETIF_MSG_LINK, "8705 1.c809 val=0x%x\n", val1); |
| 4449 | link_up = ((rx_sd & 0x1) && (val1 & (1<<9)) && ((val1 & (1<<8)) == 0)); |
| 4450 | if (link_up) { |
| 4451 | vars->line_speed = SPEED_10000; |
| 4452 | bnx2x_ext_phy_resolve_fc(phy, params, vars); |
| 4453 | } |
| 4454 | return link_up; |
| 4455 | } |
| 4456 | |
| 4457 | /******************************************************************/ |
| 4458 | /* SFP+ module Section */ |
| 4459 | /******************************************************************/ |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 4460 | static u8 bnx2x_get_gpio_port(struct link_params *params) |
| 4461 | { |
| 4462 | u8 gpio_port; |
| 4463 | u32 swap_val, swap_override; |
| 4464 | struct bnx2x *bp = params->bp; |
| 4465 | if (CHIP_IS_E2(bp)) |
| 4466 | gpio_port = BP_PATH(bp); |
| 4467 | else |
| 4468 | gpio_port = params->port; |
| 4469 | swap_val = REG_RD(bp, NIG_REG_PORT_SWAP); |
| 4470 | swap_override = REG_RD(bp, NIG_REG_STRAP_OVERRIDE); |
| 4471 | return gpio_port ^ (swap_val && swap_override); |
| 4472 | } |
| 4473 | static void bnx2x_sfp_set_transmitter(struct link_params *params, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4474 | struct bnx2x_phy *phy, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4475 | u8 tx_en) |
| 4476 | { |
| 4477 | u16 val; |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 4478 | u8 port = params->port; |
| 4479 | struct bnx2x *bp = params->bp; |
| 4480 | u32 tx_en_mode; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4481 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4482 | /* Disable/Enable transmitter ( TX laser of the SFP+ module.)*/ |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 4483 | tx_en_mode = REG_RD(bp, params->shmem_base + |
| 4484 | offsetof(struct shmem_region, |
| 4485 | dev_info.port_hw_config[port].sfp_ctrl)) & |
| 4486 | PORT_HW_CFG_TX_LASER_MASK; |
| 4487 | DP(NETIF_MSG_LINK, "Setting transmitter tx_en=%x for port %x " |
| 4488 | "mode = %x\n", tx_en, port, tx_en_mode); |
| 4489 | switch (tx_en_mode) { |
| 4490 | case PORT_HW_CFG_TX_LASER_MDIO: |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4491 | |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 4492 | bnx2x_cl45_read(bp, phy, |
| 4493 | MDIO_PMA_DEVAD, |
| 4494 | MDIO_PMA_REG_PHY_IDENTIFIER, |
| 4495 | &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4496 | |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 4497 | if (tx_en) |
| 4498 | val &= ~(1<<15); |
| 4499 | else |
| 4500 | val |= (1<<15); |
| 4501 | |
| 4502 | bnx2x_cl45_write(bp, phy, |
| 4503 | MDIO_PMA_DEVAD, |
| 4504 | MDIO_PMA_REG_PHY_IDENTIFIER, |
| 4505 | val); |
| 4506 | break; |
| 4507 | case PORT_HW_CFG_TX_LASER_GPIO0: |
| 4508 | case PORT_HW_CFG_TX_LASER_GPIO1: |
| 4509 | case PORT_HW_CFG_TX_LASER_GPIO2: |
| 4510 | case PORT_HW_CFG_TX_LASER_GPIO3: |
| 4511 | { |
| 4512 | u16 gpio_pin; |
| 4513 | u8 gpio_port, gpio_mode; |
| 4514 | if (tx_en) |
| 4515 | gpio_mode = MISC_REGISTERS_GPIO_OUTPUT_HIGH; |
| 4516 | else |
| 4517 | gpio_mode = MISC_REGISTERS_GPIO_OUTPUT_LOW; |
| 4518 | |
| 4519 | gpio_pin = tx_en_mode - PORT_HW_CFG_TX_LASER_GPIO0; |
| 4520 | gpio_port = bnx2x_get_gpio_port(params); |
| 4521 | bnx2x_set_gpio(bp, gpio_pin, gpio_mode, gpio_port); |
| 4522 | break; |
| 4523 | } |
| 4524 | default: |
| 4525 | DP(NETIF_MSG_LINK, "Invalid TX_LASER_MDIO 0x%x\n", tx_en_mode); |
| 4526 | break; |
| 4527 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4528 | } |
| 4529 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 4530 | static int bnx2x_8726_read_sfp_module_eeprom(struct bnx2x_phy *phy, |
| 4531 | struct link_params *params, |
| 4532 | u16 addr, u8 byte_cnt, u8 *o_buf) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4533 | { |
| 4534 | struct bnx2x *bp = params->bp; |
| 4535 | u16 val = 0; |
| 4536 | u16 i; |
| 4537 | if (byte_cnt > 16) { |
| 4538 | DP(NETIF_MSG_LINK, "Reading from eeprom is" |
| 4539 | " is limited to 0xf\n"); |
| 4540 | return -EINVAL; |
| 4541 | } |
| 4542 | /* Set the read command byte count */ |
| 4543 | bnx2x_cl45_write(bp, phy, |
| 4544 | MDIO_PMA_DEVAD, MDIO_PMA_REG_SFP_TWO_WIRE_BYTE_CNT, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4545 | (byte_cnt | 0xa000)); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4546 | |
| 4547 | /* Set the read command address */ |
| 4548 | bnx2x_cl45_write(bp, phy, |
| 4549 | MDIO_PMA_DEVAD, MDIO_PMA_REG_SFP_TWO_WIRE_MEM_ADDR, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4550 | addr); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4551 | |
| 4552 | /* Activate read command */ |
| 4553 | bnx2x_cl45_write(bp, phy, |
| 4554 | MDIO_PMA_DEVAD, MDIO_PMA_REG_SFP_TWO_WIRE_CTRL, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4555 | 0x2c0f); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4556 | |
| 4557 | /* Wait up to 500us for command complete status */ |
| 4558 | for (i = 0; i < 100; i++) { |
| 4559 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4560 | MDIO_PMA_DEVAD, |
| 4561 | MDIO_PMA_REG_SFP_TWO_WIRE_CTRL, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4562 | if ((val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK) == |
| 4563 | MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_COMPLETE) |
| 4564 | break; |
| 4565 | udelay(5); |
| 4566 | } |
| 4567 | |
| 4568 | if ((val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK) != |
| 4569 | MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_COMPLETE) { |
| 4570 | DP(NETIF_MSG_LINK, |
| 4571 | "Got bad status 0x%x when reading from SFP+ EEPROM\n", |
| 4572 | (val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK)); |
| 4573 | return -EINVAL; |
| 4574 | } |
| 4575 | |
| 4576 | /* Read the buffer */ |
| 4577 | for (i = 0; i < byte_cnt; i++) { |
| 4578 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4579 | MDIO_PMA_DEVAD, |
| 4580 | MDIO_PMA_REG_8726_TWO_WIRE_DATA_BUF + i, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4581 | o_buf[i] = (u8)(val & MDIO_PMA_REG_8726_TWO_WIRE_DATA_MASK); |
| 4582 | } |
| 4583 | |
| 4584 | for (i = 0; i < 100; i++) { |
| 4585 | bnx2x_cl45_read(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, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4588 | if ((val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK) == |
| 4589 | MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_IDLE) |
Joe Perches | 6f38ad9 | 2010-11-14 17:04:31 +0000 | [diff] [blame] | 4590 | return 0; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4591 | msleep(1); |
| 4592 | } |
| 4593 | return -EINVAL; |
| 4594 | } |
| 4595 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 4596 | static int bnx2x_8727_read_sfp_module_eeprom(struct bnx2x_phy *phy, |
| 4597 | struct link_params *params, |
| 4598 | u16 addr, u8 byte_cnt, u8 *o_buf) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4599 | { |
| 4600 | struct bnx2x *bp = params->bp; |
| 4601 | u16 val, i; |
| 4602 | |
| 4603 | if (byte_cnt > 16) { |
| 4604 | DP(NETIF_MSG_LINK, "Reading from eeprom is" |
| 4605 | " is limited to 0xf\n"); |
| 4606 | return -EINVAL; |
| 4607 | } |
| 4608 | |
| 4609 | /* Need to read from 1.8000 to clear it */ |
| 4610 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4611 | MDIO_PMA_DEVAD, |
| 4612 | MDIO_PMA_REG_SFP_TWO_WIRE_CTRL, |
| 4613 | &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4614 | |
| 4615 | /* Set the read command byte count */ |
| 4616 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4617 | MDIO_PMA_DEVAD, |
| 4618 | MDIO_PMA_REG_SFP_TWO_WIRE_BYTE_CNT, |
| 4619 | ((byte_cnt < 2) ? 2 : byte_cnt)); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4620 | |
| 4621 | /* Set the read command address */ |
| 4622 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4623 | MDIO_PMA_DEVAD, |
| 4624 | MDIO_PMA_REG_SFP_TWO_WIRE_MEM_ADDR, |
| 4625 | addr); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4626 | /* Set the destination address */ |
| 4627 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4628 | MDIO_PMA_DEVAD, |
| 4629 | 0x8004, |
| 4630 | MDIO_PMA_REG_8727_TWO_WIRE_DATA_BUF); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4631 | |
| 4632 | /* Activate read command */ |
| 4633 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4634 | MDIO_PMA_DEVAD, |
| 4635 | MDIO_PMA_REG_SFP_TWO_WIRE_CTRL, |
| 4636 | 0x8002); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 4637 | /* |
| 4638 | * Wait appropriate time for two-wire command to finish before |
| 4639 | * polling the status register |
| 4640 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4641 | msleep(1); |
| 4642 | |
| 4643 | /* Wait up to 500us for command complete status */ |
| 4644 | for (i = 0; i < 100; i++) { |
| 4645 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4646 | MDIO_PMA_DEVAD, |
| 4647 | MDIO_PMA_REG_SFP_TWO_WIRE_CTRL, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4648 | if ((val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK) == |
| 4649 | MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_COMPLETE) |
| 4650 | break; |
| 4651 | udelay(5); |
| 4652 | } |
| 4653 | |
| 4654 | if ((val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK) != |
| 4655 | MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_COMPLETE) { |
| 4656 | DP(NETIF_MSG_LINK, |
| 4657 | "Got bad status 0x%x when reading from SFP+ EEPROM\n", |
| 4658 | (val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK)); |
Yaniv Rosner | 65a001b | 2011-01-31 04:22:03 +0000 | [diff] [blame] | 4659 | return -EFAULT; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4660 | } |
| 4661 | |
| 4662 | /* Read the buffer */ |
| 4663 | for (i = 0; i < byte_cnt; i++) { |
| 4664 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4665 | MDIO_PMA_DEVAD, |
| 4666 | MDIO_PMA_REG_8727_TWO_WIRE_DATA_BUF + i, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4667 | o_buf[i] = (u8)(val & MDIO_PMA_REG_8727_TWO_WIRE_DATA_MASK); |
| 4668 | } |
| 4669 | |
| 4670 | for (i = 0; i < 100; i++) { |
| 4671 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4672 | MDIO_PMA_DEVAD, |
| 4673 | MDIO_PMA_REG_SFP_TWO_WIRE_CTRL, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4674 | if ((val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK) == |
| 4675 | MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_IDLE) |
Joe Perches | 6f38ad9 | 2010-11-14 17:04:31 +0000 | [diff] [blame] | 4676 | return 0; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4677 | msleep(1); |
| 4678 | } |
| 4679 | |
| 4680 | return -EINVAL; |
| 4681 | } |
| 4682 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 4683 | int bnx2x_read_sfp_module_eeprom(struct bnx2x_phy *phy, |
| 4684 | struct link_params *params, u16 addr, |
| 4685 | u8 byte_cnt, u8 *o_buf) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4686 | { |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 4687 | int rc = -EINVAL; |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 4688 | switch (phy->type) { |
| 4689 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726: |
| 4690 | rc = bnx2x_8726_read_sfp_module_eeprom(phy, params, addr, |
| 4691 | byte_cnt, o_buf); |
| 4692 | break; |
| 4693 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727: |
| 4694 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8722: |
| 4695 | rc = bnx2x_8727_read_sfp_module_eeprom(phy, params, addr, |
| 4696 | byte_cnt, o_buf); |
| 4697 | break; |
| 4698 | } |
| 4699 | return rc; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4700 | } |
| 4701 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 4702 | static int bnx2x_get_edc_mode(struct bnx2x_phy *phy, |
| 4703 | struct link_params *params, |
| 4704 | u16 *edc_mode) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4705 | { |
| 4706 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 4707 | u32 sync_offset = 0, phy_idx, media_types; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4708 | u8 val, check_limiting_mode = 0; |
| 4709 | *edc_mode = EDC_MODE_LIMITING; |
| 4710 | |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 4711 | phy->media_type = ETH_PHY_UNSPECIFIED; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4712 | /* First check for copper cable */ |
| 4713 | if (bnx2x_read_sfp_module_eeprom(phy, |
| 4714 | params, |
| 4715 | SFP_EEPROM_CON_TYPE_ADDR, |
| 4716 | 1, |
| 4717 | &val) != 0) { |
| 4718 | DP(NETIF_MSG_LINK, "Failed to read from SFP+ module EEPROM\n"); |
| 4719 | return -EINVAL; |
| 4720 | } |
| 4721 | |
| 4722 | switch (val) { |
| 4723 | case SFP_EEPROM_CON_TYPE_VAL_COPPER: |
| 4724 | { |
| 4725 | u8 copper_module_type; |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 4726 | phy->media_type = ETH_PHY_DA_TWINAX; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 4727 | /* |
| 4728 | * Check if its active cable (includes SFP+ module) |
| 4729 | * of passive cable |
| 4730 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4731 | if (bnx2x_read_sfp_module_eeprom(phy, |
| 4732 | params, |
| 4733 | SFP_EEPROM_FC_TX_TECH_ADDR, |
| 4734 | 1, |
| 4735 | &copper_module_type) != |
| 4736 | 0) { |
| 4737 | DP(NETIF_MSG_LINK, |
| 4738 | "Failed to read copper-cable-type" |
| 4739 | " from SFP+ EEPROM\n"); |
| 4740 | return -EINVAL; |
| 4741 | } |
| 4742 | |
| 4743 | if (copper_module_type & |
| 4744 | SFP_EEPROM_FC_TX_TECH_BITMASK_COPPER_ACTIVE) { |
| 4745 | DP(NETIF_MSG_LINK, "Active Copper cable detected\n"); |
| 4746 | check_limiting_mode = 1; |
| 4747 | } else if (copper_module_type & |
| 4748 | SFP_EEPROM_FC_TX_TECH_BITMASK_COPPER_PASSIVE) { |
| 4749 | DP(NETIF_MSG_LINK, "Passive Copper" |
| 4750 | " cable detected\n"); |
| 4751 | *edc_mode = |
| 4752 | EDC_MODE_PASSIVE_DAC; |
| 4753 | } else { |
| 4754 | DP(NETIF_MSG_LINK, "Unknown copper-cable-" |
| 4755 | "type 0x%x !!!\n", copper_module_type); |
| 4756 | return -EINVAL; |
| 4757 | } |
| 4758 | break; |
| 4759 | } |
| 4760 | case SFP_EEPROM_CON_TYPE_VAL_LC: |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 4761 | phy->media_type = ETH_PHY_SFP_FIBER; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4762 | DP(NETIF_MSG_LINK, "Optic module detected\n"); |
| 4763 | check_limiting_mode = 1; |
| 4764 | break; |
| 4765 | default: |
| 4766 | DP(NETIF_MSG_LINK, "Unable to determine module type 0x%x !!!\n", |
| 4767 | val); |
| 4768 | return -EINVAL; |
| 4769 | } |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 4770 | sync_offset = params->shmem_base + |
| 4771 | offsetof(struct shmem_region, |
| 4772 | dev_info.port_hw_config[params->port].media_type); |
| 4773 | media_types = REG_RD(bp, sync_offset); |
| 4774 | /* Update media type for non-PMF sync */ |
| 4775 | for (phy_idx = INT_PHY; phy_idx < MAX_PHYS; phy_idx++) { |
| 4776 | if (&(params->phy[phy_idx]) == phy) { |
| 4777 | media_types &= ~(PORT_HW_CFG_MEDIA_TYPE_PHY0_MASK << |
| 4778 | (PORT_HW_CFG_MEDIA_TYPE_PHY1_SHIFT * phy_idx)); |
| 4779 | media_types |= ((phy->media_type & |
| 4780 | PORT_HW_CFG_MEDIA_TYPE_PHY0_MASK) << |
| 4781 | (PORT_HW_CFG_MEDIA_TYPE_PHY1_SHIFT * phy_idx)); |
| 4782 | break; |
| 4783 | } |
| 4784 | } |
| 4785 | REG_WR(bp, sync_offset, media_types); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4786 | if (check_limiting_mode) { |
| 4787 | u8 options[SFP_EEPROM_OPTIONS_SIZE]; |
| 4788 | if (bnx2x_read_sfp_module_eeprom(phy, |
| 4789 | params, |
| 4790 | SFP_EEPROM_OPTIONS_ADDR, |
| 4791 | SFP_EEPROM_OPTIONS_SIZE, |
| 4792 | options) != 0) { |
| 4793 | DP(NETIF_MSG_LINK, "Failed to read Option" |
| 4794 | " field from module EEPROM\n"); |
| 4795 | return -EINVAL; |
| 4796 | } |
| 4797 | if ((options[0] & SFP_EEPROM_OPTIONS_LINEAR_RX_OUT_MASK)) |
| 4798 | *edc_mode = EDC_MODE_LINEAR; |
| 4799 | else |
| 4800 | *edc_mode = EDC_MODE_LIMITING; |
| 4801 | } |
| 4802 | DP(NETIF_MSG_LINK, "EDC mode is set to 0x%x\n", *edc_mode); |
| 4803 | return 0; |
| 4804 | } |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 4805 | /* |
| 4806 | * This function read the relevant field from the module (SFP+), and verify it |
| 4807 | * is compliant with this board |
| 4808 | */ |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 4809 | static int bnx2x_verify_sfp_module(struct bnx2x_phy *phy, |
| 4810 | struct link_params *params) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4811 | { |
| 4812 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 4813 | u32 val, cmd; |
| 4814 | u32 fw_resp, fw_cmd_param; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4815 | char vendor_name[SFP_EEPROM_VENDOR_NAME_SIZE+1]; |
| 4816 | char vendor_pn[SFP_EEPROM_PART_NO_SIZE+1]; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 4817 | phy->flags &= ~FLAGS_SFP_NOT_APPROVED; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4818 | val = REG_RD(bp, params->shmem_base + |
| 4819 | offsetof(struct shmem_region, dev_info. |
| 4820 | port_feature_config[params->port].config)); |
| 4821 | if ((val & PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK) == |
| 4822 | PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_NO_ENFORCEMENT) { |
| 4823 | DP(NETIF_MSG_LINK, "NOT enforcing module verification\n"); |
| 4824 | return 0; |
| 4825 | } |
| 4826 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 4827 | if (params->feature_config_flags & |
| 4828 | FEATURE_CONFIG_BC_SUPPORTS_DUAL_PHY_OPT_MDL_VRFY) { |
| 4829 | /* Use specific phy request */ |
| 4830 | cmd = DRV_MSG_CODE_VRFY_SPECIFIC_PHY_OPT_MDL; |
| 4831 | } else if (params->feature_config_flags & |
| 4832 | FEATURE_CONFIG_BC_SUPPORTS_OPT_MDL_VRFY) { |
| 4833 | /* Use first phy request only in case of non-dual media*/ |
| 4834 | if (DUAL_MEDIA(params)) { |
| 4835 | DP(NETIF_MSG_LINK, "FW does not support OPT MDL " |
| 4836 | "verification\n"); |
| 4837 | return -EINVAL; |
| 4838 | } |
| 4839 | cmd = DRV_MSG_CODE_VRFY_FIRST_PHY_OPT_MDL; |
| 4840 | } else { |
| 4841 | /* No support in OPT MDL detection */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4842 | DP(NETIF_MSG_LINK, "FW does not support OPT MDL " |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 4843 | "verification\n"); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4844 | return -EINVAL; |
| 4845 | } |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 4846 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 4847 | fw_cmd_param = FW_PARAM_SET(phy->addr, phy->type, phy->mdio_ctrl); |
| 4848 | fw_resp = bnx2x_fw_command(bp, cmd, fw_cmd_param); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4849 | if (fw_resp == FW_MSG_CODE_VRFY_OPT_MDL_SUCCESS) { |
| 4850 | DP(NETIF_MSG_LINK, "Approved module\n"); |
| 4851 | return 0; |
| 4852 | } |
| 4853 | |
| 4854 | /* format the warning message */ |
| 4855 | if (bnx2x_read_sfp_module_eeprom(phy, |
| 4856 | params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4857 | SFP_EEPROM_VENDOR_NAME_ADDR, |
| 4858 | SFP_EEPROM_VENDOR_NAME_SIZE, |
| 4859 | (u8 *)vendor_name)) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4860 | vendor_name[0] = '\0'; |
| 4861 | else |
| 4862 | vendor_name[SFP_EEPROM_VENDOR_NAME_SIZE] = '\0'; |
| 4863 | if (bnx2x_read_sfp_module_eeprom(phy, |
| 4864 | params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4865 | SFP_EEPROM_PART_NO_ADDR, |
| 4866 | SFP_EEPROM_PART_NO_SIZE, |
| 4867 | (u8 *)vendor_pn)) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4868 | vendor_pn[0] = '\0'; |
| 4869 | else |
| 4870 | vendor_pn[SFP_EEPROM_PART_NO_SIZE] = '\0'; |
| 4871 | |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 4872 | netdev_err(bp->dev, "Warning: Unqualified SFP+ module detected," |
| 4873 | " Port %d from %s part number %s\n", |
| 4874 | params->port, vendor_name, vendor_pn); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 4875 | phy->flags |= FLAGS_SFP_NOT_APPROVED; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4876 | return -EINVAL; |
| 4877 | } |
| 4878 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 4879 | static int bnx2x_wait_for_sfp_module_initialized(struct bnx2x_phy *phy, |
| 4880 | struct link_params *params) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4881 | |
| 4882 | { |
| 4883 | u8 val; |
| 4884 | struct bnx2x *bp = params->bp; |
| 4885 | u16 timeout; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 4886 | /* |
| 4887 | * Initialization time after hot-plug may take up to 300ms for |
| 4888 | * some phys type ( e.g. JDSU ) |
| 4889 | */ |
| 4890 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4891 | for (timeout = 0; timeout < 60; timeout++) { |
| 4892 | if (bnx2x_read_sfp_module_eeprom(phy, params, 1, 1, &val) |
| 4893 | == 0) { |
| 4894 | DP(NETIF_MSG_LINK, "SFP+ module initialization " |
| 4895 | "took %d ms\n", timeout * 5); |
| 4896 | return 0; |
| 4897 | } |
| 4898 | msleep(5); |
| 4899 | } |
| 4900 | return -EINVAL; |
| 4901 | } |
| 4902 | |
| 4903 | static void bnx2x_8727_power_module(struct bnx2x *bp, |
| 4904 | struct bnx2x_phy *phy, |
| 4905 | u8 is_power_up) { |
| 4906 | /* Make sure GPIOs are not using for LED mode */ |
| 4907 | u16 val; |
| 4908 | /* |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 4909 | * 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] | 4910 | * operating as INPUT or as OUTPUT. Bit 1 is for input, and 0 for |
| 4911 | * output |
| 4912 | * Bits 0-1 determine the gpios value for OUTPUT in case bit 4 val is 0 |
| 4913 | * Bits 8-9 determine the gpios value for INPUT in case bit 4 val is 1 |
| 4914 | * where the 1st bit is the over-current(only input), and 2nd bit is |
| 4915 | * for power( only output ) |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 4916 | * |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4917 | * In case of NOC feature is disabled and power is up, set GPIO control |
| 4918 | * as input to enable listening of over-current indication |
| 4919 | */ |
| 4920 | if (phy->flags & FLAGS_NOC) |
| 4921 | return; |
Yaniv Rosner | 27d0243 | 2011-05-31 21:27:48 +0000 | [diff] [blame^] | 4922 | if (is_power_up) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4923 | val = (1<<4); |
| 4924 | else |
| 4925 | /* |
| 4926 | * Set GPIO control to OUTPUT, and set the power bit |
| 4927 | * to according to the is_power_up |
| 4928 | */ |
Yaniv Rosner | 27d0243 | 2011-05-31 21:27:48 +0000 | [diff] [blame^] | 4929 | val = (1<<1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4930 | |
| 4931 | bnx2x_cl45_write(bp, phy, |
| 4932 | MDIO_PMA_DEVAD, |
| 4933 | MDIO_PMA_REG_8727_GPIO_CTRL, |
| 4934 | val); |
| 4935 | } |
| 4936 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 4937 | static int bnx2x_8726_set_limiting_mode(struct bnx2x *bp, |
| 4938 | struct bnx2x_phy *phy, |
| 4939 | u16 edc_mode) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4940 | { |
| 4941 | u16 cur_limiting_mode; |
| 4942 | |
| 4943 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4944 | MDIO_PMA_DEVAD, |
| 4945 | MDIO_PMA_REG_ROM_VER2, |
| 4946 | &cur_limiting_mode); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4947 | DP(NETIF_MSG_LINK, "Current Limiting mode is 0x%x\n", |
| 4948 | cur_limiting_mode); |
| 4949 | |
| 4950 | if (edc_mode == EDC_MODE_LIMITING) { |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4951 | DP(NETIF_MSG_LINK, "Setting LIMITING MODE\n"); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4952 | bnx2x_cl45_write(bp, phy, |
| 4953 | MDIO_PMA_DEVAD, |
| 4954 | MDIO_PMA_REG_ROM_VER2, |
| 4955 | EDC_MODE_LIMITING); |
| 4956 | } else { /* LRM mode ( default )*/ |
| 4957 | |
| 4958 | DP(NETIF_MSG_LINK, "Setting LRM MODE\n"); |
| 4959 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 4960 | /* |
| 4961 | * Changing to LRM mode takes quite few seconds. So do it only |
| 4962 | * if current mode is limiting (default is LRM) |
| 4963 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4964 | if (cur_limiting_mode != EDC_MODE_LIMITING) |
| 4965 | return 0; |
| 4966 | |
| 4967 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4968 | MDIO_PMA_DEVAD, |
| 4969 | MDIO_PMA_REG_LRM_MODE, |
| 4970 | 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4971 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4972 | MDIO_PMA_DEVAD, |
| 4973 | MDIO_PMA_REG_ROM_VER2, |
| 4974 | 0x128); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4975 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4976 | MDIO_PMA_DEVAD, |
| 4977 | MDIO_PMA_REG_MISC_CTRL0, |
| 4978 | 0x4008); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4979 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4980 | MDIO_PMA_DEVAD, |
| 4981 | MDIO_PMA_REG_LRM_MODE, |
| 4982 | 0xaaaa); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4983 | } |
| 4984 | return 0; |
| 4985 | } |
| 4986 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 4987 | static int bnx2x_8727_set_limiting_mode(struct bnx2x *bp, |
| 4988 | struct bnx2x_phy *phy, |
| 4989 | u16 edc_mode) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4990 | { |
| 4991 | u16 phy_identifier; |
| 4992 | u16 rom_ver2_val; |
| 4993 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4994 | MDIO_PMA_DEVAD, |
| 4995 | MDIO_PMA_REG_PHY_IDENTIFIER, |
| 4996 | &phy_identifier); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4997 | |
| 4998 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4999 | MDIO_PMA_DEVAD, |
| 5000 | MDIO_PMA_REG_PHY_IDENTIFIER, |
| 5001 | (phy_identifier & ~(1<<9))); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5002 | |
| 5003 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5004 | MDIO_PMA_DEVAD, |
| 5005 | MDIO_PMA_REG_ROM_VER2, |
| 5006 | &rom_ver2_val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5007 | /* Keep the MSB 8-bits, and set the LSB 8-bits with the edc_mode */ |
| 5008 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5009 | MDIO_PMA_DEVAD, |
| 5010 | MDIO_PMA_REG_ROM_VER2, |
| 5011 | (rom_ver2_val & 0xff00) | (edc_mode & 0x00ff)); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5012 | |
| 5013 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5014 | MDIO_PMA_DEVAD, |
| 5015 | MDIO_PMA_REG_PHY_IDENTIFIER, |
| 5016 | (phy_identifier | (1<<9))); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5017 | |
| 5018 | return 0; |
| 5019 | } |
| 5020 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5021 | static void bnx2x_8727_specific_func(struct bnx2x_phy *phy, |
| 5022 | struct link_params *params, |
| 5023 | u32 action) |
| 5024 | { |
| 5025 | struct bnx2x *bp = params->bp; |
| 5026 | |
| 5027 | switch (action) { |
| 5028 | case DISABLE_TX: |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 5029 | bnx2x_sfp_set_transmitter(params, phy, 0); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5030 | break; |
| 5031 | case ENABLE_TX: |
| 5032 | if (!(phy->flags & FLAGS_SFP_NOT_APPROVED)) |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 5033 | bnx2x_sfp_set_transmitter(params, phy, 1); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5034 | break; |
| 5035 | default: |
| 5036 | DP(NETIF_MSG_LINK, "Function 0x%x not supported by 8727\n", |
| 5037 | action); |
| 5038 | return; |
| 5039 | } |
| 5040 | } |
| 5041 | |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 5042 | static void bnx2x_set_sfp_module_fault_led(struct link_params *params, |
| 5043 | u8 gpio_mode) |
| 5044 | { |
| 5045 | struct bnx2x *bp = params->bp; |
| 5046 | |
| 5047 | u32 fault_led_gpio = REG_RD(bp, params->shmem_base + |
| 5048 | offsetof(struct shmem_region, |
| 5049 | dev_info.port_hw_config[params->port].sfp_ctrl)) & |
| 5050 | PORT_HW_CFG_FAULT_MODULE_LED_MASK; |
| 5051 | switch (fault_led_gpio) { |
| 5052 | case PORT_HW_CFG_FAULT_MODULE_LED_DISABLED: |
| 5053 | return; |
| 5054 | case PORT_HW_CFG_FAULT_MODULE_LED_GPIO0: |
| 5055 | case PORT_HW_CFG_FAULT_MODULE_LED_GPIO1: |
| 5056 | case PORT_HW_CFG_FAULT_MODULE_LED_GPIO2: |
| 5057 | case PORT_HW_CFG_FAULT_MODULE_LED_GPIO3: |
| 5058 | { |
| 5059 | u8 gpio_port = bnx2x_get_gpio_port(params); |
| 5060 | u16 gpio_pin = fault_led_gpio - |
| 5061 | PORT_HW_CFG_FAULT_MODULE_LED_GPIO0; |
| 5062 | DP(NETIF_MSG_LINK, "Set fault module-detected led " |
| 5063 | "pin %x port %x mode %x\n", |
| 5064 | gpio_pin, gpio_port, gpio_mode); |
| 5065 | bnx2x_set_gpio(bp, gpio_pin, gpio_mode, gpio_port); |
| 5066 | } |
| 5067 | break; |
| 5068 | default: |
| 5069 | DP(NETIF_MSG_LINK, "Error: Invalid fault led mode 0x%x\n", |
| 5070 | fault_led_gpio); |
| 5071 | } |
| 5072 | } |
| 5073 | |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 5074 | static void bnx2x_power_sfp_module(struct link_params *params, |
| 5075 | struct bnx2x_phy *phy, |
| 5076 | u8 power) |
| 5077 | { |
| 5078 | struct bnx2x *bp = params->bp; |
| 5079 | DP(NETIF_MSG_LINK, "Setting SFP+ power to %x\n", power); |
| 5080 | |
| 5081 | switch (phy->type) { |
| 5082 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727: |
| 5083 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8722: |
| 5084 | bnx2x_8727_power_module(params->bp, phy, power); |
| 5085 | break; |
| 5086 | default: |
| 5087 | break; |
| 5088 | } |
| 5089 | } |
| 5090 | |
| 5091 | static void bnx2x_set_limiting_mode(struct link_params *params, |
| 5092 | struct bnx2x_phy *phy, |
| 5093 | u16 edc_mode) |
| 5094 | { |
| 5095 | switch (phy->type) { |
| 5096 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726: |
| 5097 | bnx2x_8726_set_limiting_mode(params->bp, phy, edc_mode); |
| 5098 | break; |
| 5099 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727: |
| 5100 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8722: |
| 5101 | bnx2x_8727_set_limiting_mode(params->bp, phy, edc_mode); |
| 5102 | break; |
| 5103 | } |
| 5104 | } |
| 5105 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 5106 | int bnx2x_sfp_module_detection(struct bnx2x_phy *phy, |
| 5107 | struct link_params *params) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5108 | { |
| 5109 | struct bnx2x *bp = params->bp; |
| 5110 | u16 edc_mode; |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 5111 | int rc = 0; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5112 | |
| 5113 | u32 val = REG_RD(bp, params->shmem_base + |
| 5114 | offsetof(struct shmem_region, dev_info. |
| 5115 | port_feature_config[params->port].config)); |
| 5116 | |
| 5117 | DP(NETIF_MSG_LINK, "SFP+ module plugged in/out detected on port %d\n", |
| 5118 | params->port); |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 5119 | /* Power up module */ |
| 5120 | bnx2x_power_sfp_module(params, phy, 1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5121 | if (bnx2x_get_edc_mode(phy, params, &edc_mode) != 0) { |
| 5122 | DP(NETIF_MSG_LINK, "Failed to get valid module type\n"); |
| 5123 | return -EINVAL; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5124 | } else if (bnx2x_verify_sfp_module(phy, params) != 0) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5125 | /* check SFP+ module compatibility */ |
| 5126 | DP(NETIF_MSG_LINK, "Module verification failed!!\n"); |
| 5127 | rc = -EINVAL; |
| 5128 | /* Turn on fault module-detected led */ |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 5129 | bnx2x_set_sfp_module_fault_led(params, |
| 5130 | MISC_REGISTERS_GPIO_HIGH); |
| 5131 | |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 5132 | /* Check if need to power down the SFP+ module */ |
| 5133 | if ((val & PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK) == |
| 5134 | PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_POWER_DOWN) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5135 | DP(NETIF_MSG_LINK, "Shutdown SFP+ module!!\n"); |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 5136 | bnx2x_power_sfp_module(params, phy, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5137 | return rc; |
| 5138 | } |
| 5139 | } else { |
| 5140 | /* Turn off fault module-detected led */ |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 5141 | bnx2x_set_sfp_module_fault_led(params, MISC_REGISTERS_GPIO_LOW); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5142 | } |
| 5143 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5144 | /* |
| 5145 | * Check and set limiting mode / LRM mode on 8726. On 8727 it |
| 5146 | * is done automatically |
| 5147 | */ |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 5148 | bnx2x_set_limiting_mode(params, phy, edc_mode); |
| 5149 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5150 | /* |
| 5151 | * Enable transmit for this module if the module is approved, or |
| 5152 | * if unapproved modules should also enable the Tx laser |
| 5153 | */ |
| 5154 | if (rc == 0 || |
| 5155 | (val & PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK) != |
| 5156 | PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_DISABLE_TX_LASER) |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 5157 | bnx2x_sfp_set_transmitter(params, phy, 1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5158 | else |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 5159 | bnx2x_sfp_set_transmitter(params, phy, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5160 | |
| 5161 | return rc; |
| 5162 | } |
| 5163 | |
| 5164 | void bnx2x_handle_module_detect_int(struct link_params *params) |
| 5165 | { |
| 5166 | struct bnx2x *bp = params->bp; |
| 5167 | struct bnx2x_phy *phy = ¶ms->phy[EXT_PHY1]; |
| 5168 | u32 gpio_val; |
| 5169 | u8 port = params->port; |
| 5170 | |
| 5171 | /* Set valid module led off */ |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 5172 | bnx2x_set_sfp_module_fault_led(params, MISC_REGISTERS_GPIO_HIGH); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5173 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5174 | /* Get current gpio val reflecting module plugged in / out*/ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5175 | gpio_val = bnx2x_get_gpio(bp, MISC_REGISTERS_GPIO_3, port); |
| 5176 | |
| 5177 | /* Call the handling function in case module is detected */ |
| 5178 | if (gpio_val == 0) { |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 5179 | bnx2x_power_sfp_module(params, phy, 1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5180 | bnx2x_set_gpio_int(bp, MISC_REGISTERS_GPIO_3, |
| 5181 | MISC_REGISTERS_GPIO_INT_OUTPUT_CLR, |
| 5182 | port); |
| 5183 | |
| 5184 | if (bnx2x_wait_for_sfp_module_initialized(phy, params) == 0) |
| 5185 | bnx2x_sfp_module_detection(phy, params); |
| 5186 | else |
| 5187 | DP(NETIF_MSG_LINK, "SFP+ module is not initialized\n"); |
| 5188 | } else { |
| 5189 | u32 val = REG_RD(bp, params->shmem_base + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5190 | offsetof(struct shmem_region, dev_info. |
| 5191 | port_feature_config[params->port]. |
| 5192 | config)); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5193 | |
| 5194 | bnx2x_set_gpio_int(bp, MISC_REGISTERS_GPIO_3, |
| 5195 | MISC_REGISTERS_GPIO_INT_OUTPUT_SET, |
| 5196 | port); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5197 | /* |
| 5198 | * Module was plugged out. |
| 5199 | * Disable transmit for this module |
| 5200 | */ |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 5201 | phy->media_type = ETH_PHY_NOT_PRESENT; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5202 | if ((val & PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK) == |
| 5203 | PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_DISABLE_TX_LASER) |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 5204 | bnx2x_sfp_set_transmitter(params, phy, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5205 | } |
| 5206 | } |
| 5207 | |
| 5208 | /******************************************************************/ |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 5209 | /* Used by 8706 and 8727 */ |
| 5210 | /******************************************************************/ |
| 5211 | static void bnx2x_sfp_mask_fault(struct bnx2x *bp, |
| 5212 | struct bnx2x_phy *phy, |
| 5213 | u16 alarm_status_offset, |
| 5214 | u16 alarm_ctrl_offset) |
| 5215 | { |
| 5216 | u16 alarm_status, val; |
| 5217 | bnx2x_cl45_read(bp, phy, |
| 5218 | MDIO_PMA_DEVAD, alarm_status_offset, |
| 5219 | &alarm_status); |
| 5220 | bnx2x_cl45_read(bp, phy, |
| 5221 | MDIO_PMA_DEVAD, alarm_status_offset, |
| 5222 | &alarm_status); |
| 5223 | /* Mask or enable the fault event. */ |
| 5224 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, alarm_ctrl_offset, &val); |
| 5225 | if (alarm_status & (1<<0)) |
| 5226 | val &= ~(1<<0); |
| 5227 | else |
| 5228 | val |= (1<<0); |
| 5229 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, alarm_ctrl_offset, val); |
| 5230 | } |
| 5231 | /******************************************************************/ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5232 | /* common BCM8706/BCM8726 PHY SECTION */ |
| 5233 | /******************************************************************/ |
| 5234 | static u8 bnx2x_8706_8726_read_status(struct bnx2x_phy *phy, |
| 5235 | struct link_params *params, |
| 5236 | struct link_vars *vars) |
| 5237 | { |
| 5238 | u8 link_up = 0; |
| 5239 | u16 val1, val2, rx_sd, pcs_status; |
| 5240 | struct bnx2x *bp = params->bp; |
| 5241 | DP(NETIF_MSG_LINK, "XGXS 8706/8726\n"); |
| 5242 | /* Clear RX Alarm*/ |
| 5243 | bnx2x_cl45_read(bp, phy, |
| 5244 | MDIO_PMA_DEVAD, MDIO_PMA_REG_RX_ALARM, &val2); |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 5245 | |
| 5246 | bnx2x_sfp_mask_fault(bp, phy, MDIO_PMA_REG_TX_ALARM, |
| 5247 | MDIO_PMA_REG_TX_ALARM_CTRL); |
| 5248 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5249 | /* clear LASI indication*/ |
| 5250 | bnx2x_cl45_read(bp, phy, |
| 5251 | MDIO_PMA_DEVAD, MDIO_PMA_REG_LASI_STATUS, &val1); |
| 5252 | bnx2x_cl45_read(bp, phy, |
| 5253 | MDIO_PMA_DEVAD, MDIO_PMA_REG_LASI_STATUS, &val2); |
| 5254 | DP(NETIF_MSG_LINK, "8706/8726 LASI status 0x%x--> 0x%x\n", val1, val2); |
| 5255 | |
| 5256 | bnx2x_cl45_read(bp, phy, |
| 5257 | MDIO_PMA_DEVAD, MDIO_PMA_REG_RX_SD, &rx_sd); |
| 5258 | bnx2x_cl45_read(bp, phy, |
| 5259 | MDIO_PCS_DEVAD, MDIO_PCS_REG_STATUS, &pcs_status); |
| 5260 | bnx2x_cl45_read(bp, phy, |
| 5261 | MDIO_AN_DEVAD, MDIO_AN_REG_LINK_STATUS, &val2); |
| 5262 | bnx2x_cl45_read(bp, phy, |
| 5263 | MDIO_AN_DEVAD, MDIO_AN_REG_LINK_STATUS, &val2); |
| 5264 | |
| 5265 | DP(NETIF_MSG_LINK, "8706/8726 rx_sd 0x%x pcs_status 0x%x 1Gbps" |
| 5266 | " link_status 0x%x\n", rx_sd, pcs_status, val2); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5267 | /* |
| 5268 | * link is up if both bit 0 of pmd_rx_sd and bit 0 of pcs_status |
| 5269 | * are set, or if the autoneg bit 1 is set |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5270 | */ |
| 5271 | link_up = ((rx_sd & pcs_status & 0x1) || (val2 & (1<<1))); |
| 5272 | if (link_up) { |
| 5273 | if (val2 & (1<<1)) |
| 5274 | vars->line_speed = SPEED_1000; |
| 5275 | else |
| 5276 | vars->line_speed = SPEED_10000; |
| 5277 | bnx2x_ext_phy_resolve_fc(phy, params, vars); |
Yaniv Rosner | 791f18c | 2011-01-18 04:33:42 +0000 | [diff] [blame] | 5278 | vars->duplex = DUPLEX_FULL; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5279 | } |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 5280 | |
| 5281 | /* Capture 10G link fault. Read twice to clear stale value. */ |
| 5282 | if (vars->line_speed == SPEED_10000) { |
| 5283 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, |
| 5284 | MDIO_PMA_REG_TX_ALARM, &val1); |
| 5285 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, |
| 5286 | MDIO_PMA_REG_TX_ALARM, &val1); |
| 5287 | if (val1 & (1<<0)) |
| 5288 | vars->fault_detected = 1; |
| 5289 | } |
| 5290 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5291 | return link_up; |
| 5292 | } |
| 5293 | |
| 5294 | /******************************************************************/ |
| 5295 | /* BCM8706 PHY SECTION */ |
| 5296 | /******************************************************************/ |
| 5297 | static u8 bnx2x_8706_config_init(struct bnx2x_phy *phy, |
| 5298 | struct link_params *params, |
| 5299 | struct link_vars *vars) |
| 5300 | { |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 5301 | u32 tx_en_mode; |
| 5302 | u16 cnt, val, tmp1; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5303 | struct bnx2x *bp = params->bp; |
| 5304 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5305 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, params->port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5306 | /* HW reset */ |
| 5307 | bnx2x_ext_phy_hw_reset(bp, params->port); |
| 5308 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 0xa040); |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 5309 | bnx2x_wait_reset_complete(bp, phy, params); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5310 | |
| 5311 | /* Wait until fw is loaded */ |
| 5312 | for (cnt = 0; cnt < 100; cnt++) { |
| 5313 | bnx2x_cl45_read(bp, phy, |
| 5314 | MDIO_PMA_DEVAD, MDIO_PMA_REG_ROM_VER1, &val); |
| 5315 | if (val) |
| 5316 | break; |
| 5317 | msleep(10); |
| 5318 | } |
| 5319 | DP(NETIF_MSG_LINK, "XGXS 8706 is initialized after %d ms\n", cnt); |
| 5320 | if ((params->feature_config_flags & |
| 5321 | FEATURE_CONFIG_OVERRIDE_PREEMPHASIS_ENABLED)) { |
| 5322 | u8 i; |
| 5323 | u16 reg; |
| 5324 | for (i = 0; i < 4; i++) { |
| 5325 | reg = MDIO_XS_8706_REG_BANK_RX0 + |
| 5326 | i*(MDIO_XS_8706_REG_BANK_RX1 - |
| 5327 | MDIO_XS_8706_REG_BANK_RX0); |
| 5328 | bnx2x_cl45_read(bp, phy, MDIO_XS_DEVAD, reg, &val); |
| 5329 | /* Clear first 3 bits of the control */ |
| 5330 | val &= ~0x7; |
| 5331 | /* Set control bits according to configuration */ |
| 5332 | val |= (phy->rx_preemphasis[i] & 0x7); |
| 5333 | DP(NETIF_MSG_LINK, "Setting RX Equalizer to BCM8706" |
| 5334 | " reg 0x%x <-- val 0x%x\n", reg, val); |
| 5335 | bnx2x_cl45_write(bp, phy, MDIO_XS_DEVAD, reg, val); |
| 5336 | } |
| 5337 | } |
| 5338 | /* Force speed */ |
| 5339 | if (phy->req_line_speed == SPEED_10000) { |
| 5340 | DP(NETIF_MSG_LINK, "XGXS 8706 force 10Gbps\n"); |
| 5341 | |
| 5342 | bnx2x_cl45_write(bp, phy, |
| 5343 | MDIO_PMA_DEVAD, |
| 5344 | MDIO_PMA_REG_DIGITAL_CTRL, 0x400); |
| 5345 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 5346 | MDIO_PMA_DEVAD, MDIO_PMA_REG_TX_ALARM_CTRL, |
| 5347 | 0); |
| 5348 | /* Arm LASI for link and Tx fault. */ |
| 5349 | bnx2x_cl45_write(bp, phy, |
| 5350 | MDIO_PMA_DEVAD, MDIO_PMA_REG_LASI_CTRL, 3); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5351 | } else { |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 5352 | /* Force 1Gbps using autoneg with 1G advertisement */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5353 | |
| 5354 | /* Allow CL37 through CL73 */ |
| 5355 | DP(NETIF_MSG_LINK, "XGXS 8706 AutoNeg\n"); |
| 5356 | bnx2x_cl45_write(bp, phy, |
| 5357 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_CL73, 0x040c); |
| 5358 | |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 5359 | /* Enable Full-Duplex advertisement on CL37 */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5360 | bnx2x_cl45_write(bp, phy, |
| 5361 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_FC_LP, 0x0020); |
| 5362 | /* Enable CL37 AN */ |
| 5363 | bnx2x_cl45_write(bp, phy, |
| 5364 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_AN, 0x1000); |
| 5365 | /* 1G support */ |
| 5366 | bnx2x_cl45_write(bp, phy, |
| 5367 | MDIO_AN_DEVAD, MDIO_AN_REG_ADV, (1<<5)); |
| 5368 | |
| 5369 | /* Enable clause 73 AN */ |
| 5370 | bnx2x_cl45_write(bp, phy, |
| 5371 | MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, 0x1200); |
| 5372 | bnx2x_cl45_write(bp, phy, |
| 5373 | MDIO_PMA_DEVAD, MDIO_PMA_REG_RX_ALARM_CTRL, |
| 5374 | 0x0400); |
| 5375 | bnx2x_cl45_write(bp, phy, |
| 5376 | MDIO_PMA_DEVAD, MDIO_PMA_REG_LASI_CTRL, |
| 5377 | 0x0004); |
| 5378 | } |
| 5379 | bnx2x_save_bcm_spirom_ver(bp, phy, params->port); |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 5380 | |
| 5381 | /* |
| 5382 | * If TX Laser is controlled by GPIO_0, do not let PHY go into low |
| 5383 | * power mode, if TX Laser is disabled |
| 5384 | */ |
| 5385 | |
| 5386 | tx_en_mode = REG_RD(bp, params->shmem_base + |
| 5387 | offsetof(struct shmem_region, |
| 5388 | dev_info.port_hw_config[params->port].sfp_ctrl)) |
| 5389 | & PORT_HW_CFG_TX_LASER_MASK; |
| 5390 | |
| 5391 | if (tx_en_mode == PORT_HW_CFG_TX_LASER_GPIO0) { |
| 5392 | DP(NETIF_MSG_LINK, "Enabling TXONOFF_PWRDN_DIS\n"); |
| 5393 | bnx2x_cl45_read(bp, phy, |
| 5394 | MDIO_PMA_DEVAD, MDIO_PMA_REG_DIGITAL_CTRL, &tmp1); |
| 5395 | tmp1 |= 0x1; |
| 5396 | bnx2x_cl45_write(bp, phy, |
| 5397 | MDIO_PMA_DEVAD, MDIO_PMA_REG_DIGITAL_CTRL, tmp1); |
| 5398 | } |
| 5399 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5400 | return 0; |
| 5401 | } |
| 5402 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 5403 | static int bnx2x_8706_read_status(struct bnx2x_phy *phy, |
| 5404 | struct link_params *params, |
| 5405 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5406 | { |
| 5407 | return bnx2x_8706_8726_read_status(phy, params, vars); |
| 5408 | } |
| 5409 | |
| 5410 | /******************************************************************/ |
| 5411 | /* BCM8726 PHY SECTION */ |
| 5412 | /******************************************************************/ |
| 5413 | static void bnx2x_8726_config_loopback(struct bnx2x_phy *phy, |
| 5414 | struct link_params *params) |
| 5415 | { |
| 5416 | struct bnx2x *bp = params->bp; |
| 5417 | DP(NETIF_MSG_LINK, "PMA/PMD ext_phy_loopback: 8726\n"); |
| 5418 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 0x0001); |
| 5419 | } |
| 5420 | |
| 5421 | static void bnx2x_8726_external_rom_boot(struct bnx2x_phy *phy, |
| 5422 | struct link_params *params) |
| 5423 | { |
| 5424 | struct bnx2x *bp = params->bp; |
| 5425 | /* Need to wait 100ms after reset */ |
| 5426 | msleep(100); |
| 5427 | |
| 5428 | /* Micro controller re-boot */ |
| 5429 | bnx2x_cl45_write(bp, phy, |
| 5430 | MDIO_PMA_DEVAD, MDIO_PMA_REG_GEN_CTRL, 0x018B); |
| 5431 | |
| 5432 | /* Set soft reset */ |
| 5433 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5434 | MDIO_PMA_DEVAD, |
| 5435 | MDIO_PMA_REG_GEN_CTRL, |
| 5436 | MDIO_PMA_REG_GEN_CTRL_ROM_MICRO_RESET); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5437 | |
| 5438 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5439 | MDIO_PMA_DEVAD, |
| 5440 | MDIO_PMA_REG_MISC_CTRL1, 0x0001); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5441 | |
| 5442 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5443 | MDIO_PMA_DEVAD, |
| 5444 | MDIO_PMA_REG_GEN_CTRL, |
| 5445 | MDIO_PMA_REG_GEN_CTRL_ROM_RESET_INTERNAL_MP); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5446 | |
| 5447 | /* wait for 150ms for microcode load */ |
| 5448 | msleep(150); |
| 5449 | |
| 5450 | /* Disable serial boot control, tristates pins SS_N, SCK, MOSI, MISO */ |
| 5451 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5452 | MDIO_PMA_DEVAD, |
| 5453 | MDIO_PMA_REG_MISC_CTRL1, 0x0000); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5454 | |
| 5455 | msleep(200); |
| 5456 | bnx2x_save_bcm_spirom_ver(bp, phy, params->port); |
| 5457 | } |
| 5458 | |
| 5459 | static u8 bnx2x_8726_read_status(struct bnx2x_phy *phy, |
| 5460 | struct link_params *params, |
| 5461 | struct link_vars *vars) |
| 5462 | { |
| 5463 | struct bnx2x *bp = params->bp; |
| 5464 | u16 val1; |
| 5465 | u8 link_up = bnx2x_8706_8726_read_status(phy, params, vars); |
| 5466 | if (link_up) { |
| 5467 | bnx2x_cl45_read(bp, phy, |
| 5468 | MDIO_PMA_DEVAD, MDIO_PMA_REG_PHY_IDENTIFIER, |
| 5469 | &val1); |
| 5470 | if (val1 & (1<<15)) { |
| 5471 | DP(NETIF_MSG_LINK, "Tx is disabled\n"); |
| 5472 | link_up = 0; |
| 5473 | vars->line_speed = 0; |
| 5474 | } |
| 5475 | } |
| 5476 | return link_up; |
| 5477 | } |
| 5478 | |
| 5479 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 5480 | static int bnx2x_8726_config_init(struct bnx2x_phy *phy, |
| 5481 | struct link_params *params, |
| 5482 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5483 | { |
| 5484 | struct bnx2x *bp = params->bp; |
| 5485 | u32 val; |
| 5486 | u32 swap_val, swap_override, aeu_gpio_mask, offset; |
| 5487 | DP(NETIF_MSG_LINK, "Initializing BCM8726\n"); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5488 | |
| 5489 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 1<<15); |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 5490 | bnx2x_wait_reset_complete(bp, phy, params); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5491 | |
| 5492 | bnx2x_8726_external_rom_boot(phy, params); |
| 5493 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5494 | /* |
| 5495 | * Need to call module detected on initialization since the module |
| 5496 | * detection triggered by actual module insertion might occur before |
| 5497 | * driver is loaded, and when driver is loaded, it reset all |
| 5498 | * registers, including the transmitter |
| 5499 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5500 | bnx2x_sfp_module_detection(phy, params); |
| 5501 | |
| 5502 | if (phy->req_line_speed == SPEED_1000) { |
| 5503 | DP(NETIF_MSG_LINK, "Setting 1G force\n"); |
| 5504 | bnx2x_cl45_write(bp, phy, |
| 5505 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 0x40); |
| 5506 | bnx2x_cl45_write(bp, phy, |
| 5507 | MDIO_PMA_DEVAD, MDIO_PMA_REG_10G_CTRL2, 0xD); |
| 5508 | bnx2x_cl45_write(bp, phy, |
| 5509 | MDIO_PMA_DEVAD, MDIO_PMA_REG_LASI_CTRL, 0x5); |
| 5510 | bnx2x_cl45_write(bp, phy, |
| 5511 | MDIO_PMA_DEVAD, MDIO_PMA_REG_RX_ALARM_CTRL, |
| 5512 | 0x400); |
| 5513 | } else if ((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 5514 | (phy->speed_cap_mask & |
| 5515 | PORT_HW_CFG_SPEED_CAPABILITY_D0_1G) && |
| 5516 | ((phy->speed_cap_mask & |
| 5517 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G) != |
| 5518 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G)) { |
| 5519 | DP(NETIF_MSG_LINK, "Setting 1G clause37\n"); |
| 5520 | /* Set Flow control */ |
| 5521 | bnx2x_ext_phy_set_pause(params, phy, vars); |
| 5522 | bnx2x_cl45_write(bp, phy, |
| 5523 | MDIO_AN_DEVAD, MDIO_AN_REG_ADV, 0x20); |
| 5524 | bnx2x_cl45_write(bp, phy, |
| 5525 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_CL73, 0x040c); |
| 5526 | bnx2x_cl45_write(bp, phy, |
| 5527 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_FC_LD, 0x0020); |
| 5528 | bnx2x_cl45_write(bp, phy, |
| 5529 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_AN, 0x1000); |
| 5530 | bnx2x_cl45_write(bp, phy, |
| 5531 | MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, 0x1200); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5532 | /* |
| 5533 | * Enable RX-ALARM control to receive interrupt for 1G speed |
| 5534 | * change |
| 5535 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5536 | bnx2x_cl45_write(bp, phy, |
| 5537 | MDIO_PMA_DEVAD, MDIO_PMA_REG_LASI_CTRL, 0x4); |
| 5538 | bnx2x_cl45_write(bp, phy, |
| 5539 | MDIO_PMA_DEVAD, MDIO_PMA_REG_RX_ALARM_CTRL, |
| 5540 | 0x400); |
| 5541 | |
| 5542 | } else { /* Default 10G. Set only LASI control */ |
| 5543 | bnx2x_cl45_write(bp, phy, |
| 5544 | MDIO_PMA_DEVAD, MDIO_PMA_REG_LASI_CTRL, 1); |
| 5545 | } |
| 5546 | |
| 5547 | /* Set TX PreEmphasis if needed */ |
| 5548 | if ((params->feature_config_flags & |
| 5549 | FEATURE_CONFIG_OVERRIDE_PREEMPHASIS_ENABLED)) { |
| 5550 | DP(NETIF_MSG_LINK, "Setting TX_CTRL1 0x%x," |
| 5551 | "TX_CTRL2 0x%x\n", |
| 5552 | phy->tx_preemphasis[0], |
| 5553 | phy->tx_preemphasis[1]); |
| 5554 | bnx2x_cl45_write(bp, phy, |
| 5555 | MDIO_PMA_DEVAD, |
| 5556 | MDIO_PMA_REG_8726_TX_CTRL1, |
| 5557 | phy->tx_preemphasis[0]); |
| 5558 | |
| 5559 | bnx2x_cl45_write(bp, phy, |
| 5560 | MDIO_PMA_DEVAD, |
| 5561 | MDIO_PMA_REG_8726_TX_CTRL2, |
| 5562 | phy->tx_preemphasis[1]); |
| 5563 | } |
| 5564 | |
| 5565 | /* Set GPIO3 to trigger SFP+ module insertion/removal */ |
| 5566 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_3, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5567 | MISC_REGISTERS_GPIO_INPUT_HI_Z, params->port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5568 | |
| 5569 | /* The GPIO should be swapped if the swap register is set and active */ |
| 5570 | swap_val = REG_RD(bp, NIG_REG_PORT_SWAP); |
| 5571 | swap_override = REG_RD(bp, NIG_REG_STRAP_OVERRIDE); |
| 5572 | |
| 5573 | /* Select function upon port-swap configuration */ |
| 5574 | if (params->port == 0) { |
| 5575 | offset = MISC_REG_AEU_ENABLE1_FUNC_0_OUT_0; |
| 5576 | aeu_gpio_mask = (swap_val && swap_override) ? |
| 5577 | AEU_INPUTS_ATTN_BITS_GPIO3_FUNCTION_1 : |
| 5578 | AEU_INPUTS_ATTN_BITS_GPIO3_FUNCTION_0; |
| 5579 | } else { |
| 5580 | offset = MISC_REG_AEU_ENABLE1_FUNC_1_OUT_0; |
| 5581 | aeu_gpio_mask = (swap_val && swap_override) ? |
| 5582 | AEU_INPUTS_ATTN_BITS_GPIO3_FUNCTION_0 : |
| 5583 | AEU_INPUTS_ATTN_BITS_GPIO3_FUNCTION_1; |
| 5584 | } |
| 5585 | val = REG_RD(bp, offset); |
| 5586 | /* add GPIO3 to group */ |
| 5587 | val |= aeu_gpio_mask; |
| 5588 | REG_WR(bp, offset, val); |
| 5589 | return 0; |
| 5590 | |
| 5591 | } |
| 5592 | |
| 5593 | static void bnx2x_8726_link_reset(struct bnx2x_phy *phy, |
| 5594 | struct link_params *params) |
| 5595 | { |
| 5596 | struct bnx2x *bp = params->bp; |
| 5597 | DP(NETIF_MSG_LINK, "bnx2x_8726_link_reset port %d\n", params->port); |
| 5598 | /* Set serial boot control for external load */ |
| 5599 | bnx2x_cl45_write(bp, phy, |
| 5600 | MDIO_PMA_DEVAD, |
| 5601 | MDIO_PMA_REG_GEN_CTRL, 0x0001); |
| 5602 | } |
| 5603 | |
| 5604 | /******************************************************************/ |
| 5605 | /* BCM8727 PHY SECTION */ |
| 5606 | /******************************************************************/ |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 5607 | |
| 5608 | static void bnx2x_8727_set_link_led(struct bnx2x_phy *phy, |
| 5609 | struct link_params *params, u8 mode) |
| 5610 | { |
| 5611 | struct bnx2x *bp = params->bp; |
| 5612 | u16 led_mode_bitmask = 0; |
| 5613 | u16 gpio_pins_bitmask = 0; |
| 5614 | u16 val; |
| 5615 | /* Only NOC flavor requires to set the LED specifically */ |
| 5616 | if (!(phy->flags & FLAGS_NOC)) |
| 5617 | return; |
| 5618 | switch (mode) { |
| 5619 | case LED_MODE_FRONT_PANEL_OFF: |
| 5620 | case LED_MODE_OFF: |
| 5621 | led_mode_bitmask = 0; |
| 5622 | gpio_pins_bitmask = 0x03; |
| 5623 | break; |
| 5624 | case LED_MODE_ON: |
| 5625 | led_mode_bitmask = 0; |
| 5626 | gpio_pins_bitmask = 0x02; |
| 5627 | break; |
| 5628 | case LED_MODE_OPER: |
| 5629 | led_mode_bitmask = 0x60; |
| 5630 | gpio_pins_bitmask = 0x11; |
| 5631 | break; |
| 5632 | } |
| 5633 | bnx2x_cl45_read(bp, phy, |
| 5634 | MDIO_PMA_DEVAD, |
| 5635 | MDIO_PMA_REG_8727_PCS_OPT_CTRL, |
| 5636 | &val); |
| 5637 | val &= 0xff8f; |
| 5638 | val |= led_mode_bitmask; |
| 5639 | bnx2x_cl45_write(bp, phy, |
| 5640 | MDIO_PMA_DEVAD, |
| 5641 | MDIO_PMA_REG_8727_PCS_OPT_CTRL, |
| 5642 | val); |
| 5643 | bnx2x_cl45_read(bp, phy, |
| 5644 | MDIO_PMA_DEVAD, |
| 5645 | MDIO_PMA_REG_8727_GPIO_CTRL, |
| 5646 | &val); |
| 5647 | val &= 0xffe0; |
| 5648 | val |= gpio_pins_bitmask; |
| 5649 | bnx2x_cl45_write(bp, phy, |
| 5650 | MDIO_PMA_DEVAD, |
| 5651 | MDIO_PMA_REG_8727_GPIO_CTRL, |
| 5652 | val); |
| 5653 | } |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 5654 | static void bnx2x_8727_hw_reset(struct bnx2x_phy *phy, |
| 5655 | struct link_params *params) { |
| 5656 | u32 swap_val, swap_override; |
| 5657 | u8 port; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5658 | /* |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 5659 | * The PHY reset is controlled by GPIO 1. Fake the port number |
| 5660 | * to cancel the swap done in set_gpio() |
| 5661 | */ |
| 5662 | struct bnx2x *bp = params->bp; |
| 5663 | swap_val = REG_RD(bp, NIG_REG_PORT_SWAP); |
| 5664 | swap_override = REG_RD(bp, NIG_REG_STRAP_OVERRIDE); |
| 5665 | port = (swap_val && swap_override) ^ 1; |
| 5666 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5667 | MISC_REGISTERS_GPIO_OUTPUT_LOW, port); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 5668 | } |
| 5669 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 5670 | static int bnx2x_8727_config_init(struct bnx2x_phy *phy, |
| 5671 | struct link_params *params, |
| 5672 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5673 | { |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 5674 | u32 tx_en_mode; |
| 5675 | u16 tmp1, val, mod_abs, tmp2; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5676 | u16 rx_alarm_ctrl_val; |
| 5677 | u16 lasi_ctrl_val; |
| 5678 | struct bnx2x *bp = params->bp; |
| 5679 | /* Enable PMD link, MOD_ABS_FLT, and 1G link alarm */ |
| 5680 | |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 5681 | bnx2x_wait_reset_complete(bp, phy, params); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5682 | rx_alarm_ctrl_val = (1<<2) | (1<<5) ; |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 5683 | /* Should be 0x6 to enable XS on Tx side. */ |
| 5684 | lasi_ctrl_val = 0x0006; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5685 | |
| 5686 | DP(NETIF_MSG_LINK, "Initializing BCM8727\n"); |
| 5687 | /* enable LASI */ |
| 5688 | bnx2x_cl45_write(bp, phy, |
| 5689 | MDIO_PMA_DEVAD, MDIO_PMA_REG_RX_ALARM_CTRL, |
| 5690 | rx_alarm_ctrl_val); |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 5691 | bnx2x_cl45_write(bp, phy, |
| 5692 | MDIO_PMA_DEVAD, MDIO_PMA_REG_TX_ALARM_CTRL, |
| 5693 | 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5694 | bnx2x_cl45_write(bp, phy, |
| 5695 | MDIO_PMA_DEVAD, MDIO_PMA_REG_LASI_CTRL, lasi_ctrl_val); |
| 5696 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5697 | /* |
| 5698 | * Initially configure MOD_ABS to interrupt when module is |
| 5699 | * presence( bit 8) |
| 5700 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5701 | bnx2x_cl45_read(bp, phy, |
| 5702 | MDIO_PMA_DEVAD, MDIO_PMA_REG_PHY_IDENTIFIER, &mod_abs); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5703 | /* |
| 5704 | * Set EDC off by setting OPTXLOS signal input to low (bit 9). |
| 5705 | * When the EDC is off it locks onto a reference clock and avoids |
| 5706 | * becoming 'lost' |
| 5707 | */ |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 5708 | mod_abs &= ~(1<<8); |
| 5709 | if (!(phy->flags & FLAGS_NOC)) |
| 5710 | mod_abs &= ~(1<<9); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5711 | bnx2x_cl45_write(bp, phy, |
| 5712 | MDIO_PMA_DEVAD, MDIO_PMA_REG_PHY_IDENTIFIER, mod_abs); |
| 5713 | |
| 5714 | |
| 5715 | /* Make MOD_ABS give interrupt on change */ |
| 5716 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_PCS_OPT_CTRL, |
| 5717 | &val); |
| 5718 | val |= (1<<12); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 5719 | if (phy->flags & FLAGS_NOC) |
| 5720 | val |= (3<<5); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5721 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5722 | /* |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 5723 | * Set 8727 GPIOs to input to allow reading from the 8727 GPIO0 |
| 5724 | * status which reflect SFP+ module over-current |
| 5725 | */ |
| 5726 | if (!(phy->flags & FLAGS_NOC)) |
| 5727 | val &= 0xff8f; /* Reset bits 4-6 */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5728 | bnx2x_cl45_write(bp, phy, |
| 5729 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_PCS_OPT_CTRL, val); |
| 5730 | |
| 5731 | bnx2x_8727_power_module(bp, phy, 1); |
| 5732 | |
| 5733 | bnx2x_cl45_read(bp, phy, |
| 5734 | MDIO_PMA_DEVAD, MDIO_PMA_REG_M8051_MSGOUT_REG, &tmp1); |
| 5735 | |
| 5736 | bnx2x_cl45_read(bp, phy, |
| 5737 | MDIO_PMA_DEVAD, MDIO_PMA_REG_RX_ALARM, &tmp1); |
| 5738 | |
| 5739 | /* Set option 1G speed */ |
| 5740 | if (phy->req_line_speed == SPEED_1000) { |
| 5741 | DP(NETIF_MSG_LINK, "Setting 1G force\n"); |
| 5742 | bnx2x_cl45_write(bp, phy, |
| 5743 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 0x40); |
| 5744 | bnx2x_cl45_write(bp, phy, |
| 5745 | MDIO_PMA_DEVAD, MDIO_PMA_REG_10G_CTRL2, 0xD); |
| 5746 | bnx2x_cl45_read(bp, phy, |
| 5747 | MDIO_PMA_DEVAD, MDIO_PMA_REG_10G_CTRL2, &tmp1); |
| 5748 | DP(NETIF_MSG_LINK, "1.7 = 0x%x\n", tmp1); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5749 | /* |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5750 | * Power down the XAUI until link is up in case of dual-media |
| 5751 | * and 1G |
| 5752 | */ |
| 5753 | if (DUAL_MEDIA(params)) { |
| 5754 | bnx2x_cl45_read(bp, phy, |
| 5755 | MDIO_PMA_DEVAD, |
| 5756 | MDIO_PMA_REG_8727_PCS_GP, &val); |
| 5757 | val |= (3<<10); |
| 5758 | bnx2x_cl45_write(bp, phy, |
| 5759 | MDIO_PMA_DEVAD, |
| 5760 | MDIO_PMA_REG_8727_PCS_GP, val); |
| 5761 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5762 | } else if ((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 5763 | ((phy->speed_cap_mask & |
| 5764 | PORT_HW_CFG_SPEED_CAPABILITY_D0_1G)) && |
| 5765 | ((phy->speed_cap_mask & |
| 5766 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G) != |
| 5767 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G)) { |
| 5768 | |
| 5769 | DP(NETIF_MSG_LINK, "Setting 1G clause37\n"); |
| 5770 | bnx2x_cl45_write(bp, phy, |
| 5771 | MDIO_AN_DEVAD, MDIO_AN_REG_8727_MISC_CTRL, 0); |
| 5772 | bnx2x_cl45_write(bp, phy, |
| 5773 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_AN, 0x1300); |
| 5774 | } else { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5775 | /* |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5776 | * Since the 8727 has only single reset pin, need to set the 10G |
| 5777 | * registers although it is default |
| 5778 | */ |
| 5779 | bnx2x_cl45_write(bp, phy, |
| 5780 | MDIO_AN_DEVAD, MDIO_AN_REG_8727_MISC_CTRL, |
| 5781 | 0x0020); |
| 5782 | bnx2x_cl45_write(bp, phy, |
| 5783 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_AN, 0x0100); |
| 5784 | bnx2x_cl45_write(bp, phy, |
| 5785 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 0x2040); |
| 5786 | bnx2x_cl45_write(bp, phy, |
| 5787 | MDIO_PMA_DEVAD, MDIO_PMA_REG_10G_CTRL2, |
| 5788 | 0x0008); |
| 5789 | } |
| 5790 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5791 | /* |
| 5792 | * Set 2-wire transfer rate of SFP+ module EEPROM |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5793 | * to 100Khz since some DACs(direct attached cables) do |
| 5794 | * not work at 400Khz. |
| 5795 | */ |
| 5796 | bnx2x_cl45_write(bp, phy, |
| 5797 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_TWO_WIRE_SLAVE_ADDR, |
| 5798 | 0xa001); |
| 5799 | |
| 5800 | /* Set TX PreEmphasis if needed */ |
| 5801 | if ((params->feature_config_flags & |
| 5802 | FEATURE_CONFIG_OVERRIDE_PREEMPHASIS_ENABLED)) { |
| 5803 | DP(NETIF_MSG_LINK, "Setting TX_CTRL1 0x%x, TX_CTRL2 0x%x\n", |
| 5804 | phy->tx_preemphasis[0], |
| 5805 | phy->tx_preemphasis[1]); |
| 5806 | bnx2x_cl45_write(bp, phy, |
| 5807 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_TX_CTRL1, |
| 5808 | phy->tx_preemphasis[0]); |
| 5809 | |
| 5810 | bnx2x_cl45_write(bp, phy, |
| 5811 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_TX_CTRL2, |
| 5812 | phy->tx_preemphasis[1]); |
| 5813 | } |
| 5814 | |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 5815 | /* |
| 5816 | * If TX Laser is controlled by GPIO_0, do not let PHY go into low |
| 5817 | * power mode, if TX Laser is disabled |
| 5818 | */ |
| 5819 | tx_en_mode = REG_RD(bp, params->shmem_base + |
| 5820 | offsetof(struct shmem_region, |
| 5821 | dev_info.port_hw_config[params->port].sfp_ctrl)) |
| 5822 | & PORT_HW_CFG_TX_LASER_MASK; |
| 5823 | |
| 5824 | if (tx_en_mode == PORT_HW_CFG_TX_LASER_GPIO0) { |
| 5825 | |
| 5826 | DP(NETIF_MSG_LINK, "Enabling TXONOFF_PWRDN_DIS\n"); |
| 5827 | bnx2x_cl45_read(bp, phy, |
| 5828 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_OPT_CFG_REG, &tmp2); |
| 5829 | tmp2 |= 0x1000; |
| 5830 | tmp2 &= 0xFFEF; |
| 5831 | bnx2x_cl45_write(bp, phy, |
| 5832 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_OPT_CFG_REG, tmp2); |
| 5833 | } |
| 5834 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5835 | return 0; |
| 5836 | } |
| 5837 | |
| 5838 | static void bnx2x_8727_handle_mod_abs(struct bnx2x_phy *phy, |
| 5839 | struct link_params *params) |
| 5840 | { |
| 5841 | struct bnx2x *bp = params->bp; |
| 5842 | u16 mod_abs, rx_alarm_status; |
| 5843 | u32 val = REG_RD(bp, params->shmem_base + |
| 5844 | offsetof(struct shmem_region, dev_info. |
| 5845 | port_feature_config[params->port]. |
| 5846 | config)); |
| 5847 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5848 | MDIO_PMA_DEVAD, |
| 5849 | MDIO_PMA_REG_PHY_IDENTIFIER, &mod_abs); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5850 | if (mod_abs & (1<<8)) { |
| 5851 | |
| 5852 | /* Module is absent */ |
| 5853 | DP(NETIF_MSG_LINK, "MOD_ABS indication " |
| 5854 | "show module is absent\n"); |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 5855 | phy->media_type = ETH_PHY_NOT_PRESENT; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5856 | /* |
| 5857 | * 1. Set mod_abs to detect next module |
| 5858 | * presence event |
| 5859 | * 2. Set EDC off by setting OPTXLOS signal input to low |
| 5860 | * (bit 9). |
| 5861 | * When the EDC is off it locks onto a reference clock and |
| 5862 | * avoids becoming 'lost'. |
| 5863 | */ |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 5864 | mod_abs &= ~(1<<8); |
| 5865 | if (!(phy->flags & FLAGS_NOC)) |
| 5866 | mod_abs &= ~(1<<9); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5867 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5868 | MDIO_PMA_DEVAD, |
| 5869 | MDIO_PMA_REG_PHY_IDENTIFIER, mod_abs); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5870 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5871 | /* |
| 5872 | * Clear RX alarm since it stays up as long as |
| 5873 | * the mod_abs wasn't changed |
| 5874 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5875 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5876 | MDIO_PMA_DEVAD, |
| 5877 | MDIO_PMA_REG_RX_ALARM, &rx_alarm_status); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5878 | |
| 5879 | } else { |
| 5880 | /* Module is present */ |
| 5881 | DP(NETIF_MSG_LINK, "MOD_ABS indication " |
| 5882 | "show module is present\n"); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5883 | /* |
| 5884 | * First disable transmitter, and if the module is ok, the |
| 5885 | * module_detection will enable it |
| 5886 | * 1. Set mod_abs to detect next module absent event ( bit 8) |
| 5887 | * 2. Restore the default polarity of the OPRXLOS signal and |
| 5888 | * this signal will then correctly indicate the presence or |
| 5889 | * absence of the Rx signal. (bit 9) |
| 5890 | */ |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 5891 | mod_abs |= (1<<8); |
| 5892 | if (!(phy->flags & FLAGS_NOC)) |
| 5893 | mod_abs |= (1<<9); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5894 | bnx2x_cl45_write(bp, phy, |
| 5895 | MDIO_PMA_DEVAD, |
| 5896 | MDIO_PMA_REG_PHY_IDENTIFIER, mod_abs); |
| 5897 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5898 | /* |
| 5899 | * Clear RX alarm since it stays up as long as the mod_abs |
| 5900 | * wasn't changed. This is need to be done before calling the |
| 5901 | * module detection, otherwise it will clear* the link update |
| 5902 | * alarm |
| 5903 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5904 | bnx2x_cl45_read(bp, phy, |
| 5905 | MDIO_PMA_DEVAD, |
| 5906 | MDIO_PMA_REG_RX_ALARM, &rx_alarm_status); |
| 5907 | |
| 5908 | |
| 5909 | if ((val & PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK) == |
| 5910 | PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_DISABLE_TX_LASER) |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 5911 | bnx2x_sfp_set_transmitter(params, phy, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5912 | |
| 5913 | if (bnx2x_wait_for_sfp_module_initialized(phy, params) == 0) |
| 5914 | bnx2x_sfp_module_detection(phy, params); |
| 5915 | else |
| 5916 | DP(NETIF_MSG_LINK, "SFP+ module is not initialized\n"); |
| 5917 | } |
| 5918 | |
| 5919 | DP(NETIF_MSG_LINK, "8727 RX_ALARM_STATUS 0x%x\n", |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5920 | rx_alarm_status); |
| 5921 | /* 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] | 5922 | } |
| 5923 | |
| 5924 | static u8 bnx2x_8727_read_status(struct bnx2x_phy *phy, |
| 5925 | struct link_params *params, |
| 5926 | struct link_vars *vars) |
| 5927 | |
| 5928 | { |
| 5929 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 27d0243 | 2011-05-31 21:27:48 +0000 | [diff] [blame^] | 5930 | u8 link_up = 0, oc_port = params->port; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5931 | u16 link_status = 0; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5932 | u16 rx_alarm_status, lasi_ctrl, val1; |
| 5933 | |
| 5934 | /* If PHY is not initialized, do not check link status */ |
| 5935 | bnx2x_cl45_read(bp, phy, |
| 5936 | MDIO_PMA_DEVAD, MDIO_PMA_REG_LASI_CTRL, |
| 5937 | &lasi_ctrl); |
| 5938 | if (!lasi_ctrl) |
| 5939 | return 0; |
| 5940 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5941 | /* Check the LASI */ |
| 5942 | bnx2x_cl45_read(bp, phy, |
| 5943 | MDIO_PMA_DEVAD, MDIO_PMA_REG_RX_ALARM, |
| 5944 | &rx_alarm_status); |
| 5945 | vars->line_speed = 0; |
| 5946 | DP(NETIF_MSG_LINK, "8727 RX_ALARM_STATUS 0x%x\n", rx_alarm_status); |
| 5947 | |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 5948 | bnx2x_sfp_mask_fault(bp, phy, MDIO_PMA_REG_TX_ALARM, |
| 5949 | MDIO_PMA_REG_TX_ALARM_CTRL); |
| 5950 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5951 | bnx2x_cl45_read(bp, phy, |
| 5952 | MDIO_PMA_DEVAD, MDIO_PMA_REG_LASI_STATUS, &val1); |
| 5953 | |
| 5954 | DP(NETIF_MSG_LINK, "8727 LASI status 0x%x\n", val1); |
| 5955 | |
| 5956 | /* Clear MSG-OUT */ |
| 5957 | bnx2x_cl45_read(bp, phy, |
| 5958 | MDIO_PMA_DEVAD, MDIO_PMA_REG_M8051_MSGOUT_REG, &val1); |
| 5959 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5960 | /* |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5961 | * If a module is present and there is need to check |
| 5962 | * for over current |
| 5963 | */ |
| 5964 | if (!(phy->flags & FLAGS_NOC) && !(rx_alarm_status & (1<<5))) { |
| 5965 | /* Check over-current using 8727 GPIO0 input*/ |
| 5966 | bnx2x_cl45_read(bp, phy, |
| 5967 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_GPIO_CTRL, |
| 5968 | &val1); |
| 5969 | |
| 5970 | if ((val1 & (1<<8)) == 0) { |
Yaniv Rosner | 27d0243 | 2011-05-31 21:27:48 +0000 | [diff] [blame^] | 5971 | if (!CHIP_IS_E1x(bp)) |
| 5972 | oc_port = BP_PATH(bp) + (params->port << 1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5973 | DP(NETIF_MSG_LINK, "8727 Power fault has been detected" |
Yaniv Rosner | 27d0243 | 2011-05-31 21:27:48 +0000 | [diff] [blame^] | 5974 | " on port %d\n", oc_port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5975 | netdev_err(bp->dev, "Error: Power fault on Port %d has" |
| 5976 | " been detected and the power to " |
| 5977 | "that SFP+ module has been removed" |
| 5978 | " to prevent failure of the card." |
| 5979 | " Please remove the SFP+ module and" |
| 5980 | " restart the system to clear this" |
| 5981 | " error.\n", |
Yaniv Rosner | 27d0243 | 2011-05-31 21:27:48 +0000 | [diff] [blame^] | 5982 | oc_port); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5983 | /* Disable all RX_ALARMs except for mod_abs */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5984 | bnx2x_cl45_write(bp, phy, |
| 5985 | MDIO_PMA_DEVAD, |
| 5986 | MDIO_PMA_REG_RX_ALARM_CTRL, (1<<5)); |
| 5987 | |
| 5988 | bnx2x_cl45_read(bp, phy, |
| 5989 | MDIO_PMA_DEVAD, |
| 5990 | MDIO_PMA_REG_PHY_IDENTIFIER, &val1); |
| 5991 | /* Wait for module_absent_event */ |
| 5992 | val1 |= (1<<8); |
| 5993 | bnx2x_cl45_write(bp, phy, |
| 5994 | MDIO_PMA_DEVAD, |
| 5995 | MDIO_PMA_REG_PHY_IDENTIFIER, val1); |
| 5996 | /* Clear RX alarm */ |
| 5997 | bnx2x_cl45_read(bp, phy, |
| 5998 | MDIO_PMA_DEVAD, |
| 5999 | MDIO_PMA_REG_RX_ALARM, &rx_alarm_status); |
| 6000 | return 0; |
| 6001 | } |
| 6002 | } /* Over current check */ |
| 6003 | |
| 6004 | /* When module absent bit is set, check module */ |
| 6005 | if (rx_alarm_status & (1<<5)) { |
| 6006 | bnx2x_8727_handle_mod_abs(phy, params); |
| 6007 | /* Enable all mod_abs and link detection bits */ |
| 6008 | bnx2x_cl45_write(bp, phy, |
| 6009 | MDIO_PMA_DEVAD, MDIO_PMA_REG_RX_ALARM_CTRL, |
| 6010 | ((1<<5) | (1<<2))); |
| 6011 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6012 | DP(NETIF_MSG_LINK, "Enabling 8727 TX laser if SFP is approved\n"); |
| 6013 | bnx2x_8727_specific_func(phy, params, ENABLE_TX); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6014 | /* If transmitter is disabled, ignore false link up indication */ |
| 6015 | bnx2x_cl45_read(bp, phy, |
| 6016 | MDIO_PMA_DEVAD, MDIO_PMA_REG_PHY_IDENTIFIER, &val1); |
| 6017 | if (val1 & (1<<15)) { |
| 6018 | DP(NETIF_MSG_LINK, "Tx is disabled\n"); |
| 6019 | return 0; |
| 6020 | } |
| 6021 | |
| 6022 | bnx2x_cl45_read(bp, phy, |
| 6023 | MDIO_PMA_DEVAD, |
| 6024 | MDIO_PMA_REG_8073_SPEED_LINK_STATUS, &link_status); |
| 6025 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6026 | /* |
| 6027 | * Bits 0..2 --> speed detected, |
| 6028 | * Bits 13..15--> link is down |
| 6029 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6030 | if ((link_status & (1<<2)) && (!(link_status & (1<<15)))) { |
| 6031 | link_up = 1; |
| 6032 | vars->line_speed = SPEED_10000; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6033 | DP(NETIF_MSG_LINK, "port %x: External link up in 10G\n", |
| 6034 | params->port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6035 | } else if ((link_status & (1<<0)) && (!(link_status & (1<<13)))) { |
| 6036 | link_up = 1; |
| 6037 | vars->line_speed = SPEED_1000; |
| 6038 | DP(NETIF_MSG_LINK, "port %x: External link up in 1G\n", |
| 6039 | params->port); |
| 6040 | } else { |
| 6041 | link_up = 0; |
| 6042 | DP(NETIF_MSG_LINK, "port %x: External link is down\n", |
| 6043 | params->port); |
| 6044 | } |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 6045 | |
| 6046 | /* Capture 10G link fault. */ |
| 6047 | if (vars->line_speed == SPEED_10000) { |
| 6048 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, |
| 6049 | MDIO_PMA_REG_TX_ALARM, &val1); |
| 6050 | |
| 6051 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, |
| 6052 | MDIO_PMA_REG_TX_ALARM, &val1); |
| 6053 | |
| 6054 | if (val1 & (1<<0)) { |
| 6055 | vars->fault_detected = 1; |
| 6056 | } |
| 6057 | } |
| 6058 | |
Yaniv Rosner | 791f18c | 2011-01-18 04:33:42 +0000 | [diff] [blame] | 6059 | if (link_up) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6060 | bnx2x_ext_phy_resolve_fc(phy, params, vars); |
Yaniv Rosner | 791f18c | 2011-01-18 04:33:42 +0000 | [diff] [blame] | 6061 | vars->duplex = DUPLEX_FULL; |
| 6062 | DP(NETIF_MSG_LINK, "duplex = 0x%x\n", vars->duplex); |
| 6063 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6064 | |
| 6065 | if ((DUAL_MEDIA(params)) && |
| 6066 | (phy->req_line_speed == SPEED_1000)) { |
| 6067 | bnx2x_cl45_read(bp, phy, |
| 6068 | MDIO_PMA_DEVAD, |
| 6069 | MDIO_PMA_REG_8727_PCS_GP, &val1); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6070 | /* |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6071 | * In case of dual-media board and 1G, power up the XAUI side, |
| 6072 | * otherwise power it down. For 10G it is done automatically |
| 6073 | */ |
| 6074 | if (link_up) |
| 6075 | val1 &= ~(3<<10); |
| 6076 | else |
| 6077 | val1 |= (3<<10); |
| 6078 | bnx2x_cl45_write(bp, phy, |
| 6079 | MDIO_PMA_DEVAD, |
| 6080 | MDIO_PMA_REG_8727_PCS_GP, val1); |
| 6081 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6082 | return link_up; |
| 6083 | } |
| 6084 | |
| 6085 | static void bnx2x_8727_link_reset(struct bnx2x_phy *phy, |
| 6086 | struct link_params *params) |
| 6087 | { |
| 6088 | struct bnx2x *bp = params->bp; |
| 6089 | /* Disable Transmitter */ |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 6090 | bnx2x_sfp_set_transmitter(params, phy, 0); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6091 | /* Clear LASI */ |
| 6092 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, MDIO_PMA_REG_LASI_CTRL, 0); |
| 6093 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6094 | } |
| 6095 | |
| 6096 | /******************************************************************/ |
| 6097 | /* BCM8481/BCM84823/BCM84833 PHY SECTION */ |
| 6098 | /******************************************************************/ |
| 6099 | static void bnx2x_save_848xx_spirom_version(struct bnx2x_phy *phy, |
| 6100 | struct link_params *params) |
| 6101 | { |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 6102 | u16 val, fw_ver1, fw_ver2, cnt, adj; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6103 | struct bnx2x *bp = params->bp; |
| 6104 | |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 6105 | adj = 0; |
| 6106 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833) |
| 6107 | adj = -1; |
| 6108 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6109 | /* For the 32 bits registers in 848xx, access via MDIO2ARM interface.*/ |
| 6110 | /* (1) set register 0xc200_0014(SPI_BRIDGE_CTRL_2) to 0x03000000 */ |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 6111 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA819 + adj, 0x0014); |
| 6112 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA81A + adj, 0xc200); |
| 6113 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA81B + adj, 0x0000); |
| 6114 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA81C + adj, 0x0300); |
| 6115 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA817 + adj, 0x0009); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6116 | |
| 6117 | for (cnt = 0; cnt < 100; cnt++) { |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 6118 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, 0xA818 + adj, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6119 | if (val & 1) |
| 6120 | break; |
| 6121 | udelay(5); |
| 6122 | } |
| 6123 | if (cnt == 100) { |
| 6124 | DP(NETIF_MSG_LINK, "Unable to read 848xx phy fw version(1)\n"); |
| 6125 | bnx2x_save_spirom_version(bp, params->port, 0, |
| 6126 | phy->ver_addr); |
| 6127 | return; |
| 6128 | } |
| 6129 | |
| 6130 | |
| 6131 | /* 2) read register 0xc200_0000 (SPI_FW_STATUS) */ |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 6132 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA819 + adj, 0x0000); |
| 6133 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA81A + adj, 0xc200); |
| 6134 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA817 + adj, 0x000A); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6135 | for (cnt = 0; cnt < 100; cnt++) { |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 6136 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, 0xA818 + adj, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6137 | if (val & 1) |
| 6138 | break; |
| 6139 | udelay(5); |
| 6140 | } |
| 6141 | if (cnt == 100) { |
| 6142 | DP(NETIF_MSG_LINK, "Unable to read 848xx phy fw version(2)\n"); |
| 6143 | bnx2x_save_spirom_version(bp, params->port, 0, |
| 6144 | phy->ver_addr); |
| 6145 | return; |
| 6146 | } |
| 6147 | |
| 6148 | /* lower 16 bits of the register SPI_FW_STATUS */ |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 6149 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, 0xA81B + adj, &fw_ver1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6150 | /* upper 16 bits of register SPI_FW_STATUS */ |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 6151 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, 0xA81C + adj, &fw_ver2); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6152 | |
| 6153 | bnx2x_save_spirom_version(bp, params->port, (fw_ver2<<16) | fw_ver1, |
| 6154 | phy->ver_addr); |
| 6155 | } |
| 6156 | |
| 6157 | static void bnx2x_848xx_set_led(struct bnx2x *bp, |
| 6158 | struct bnx2x_phy *phy) |
| 6159 | { |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 6160 | u16 val, adj; |
| 6161 | |
| 6162 | adj = 0; |
| 6163 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833) |
| 6164 | adj = -1; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6165 | |
| 6166 | /* PHYC_CTL_LED_CTL */ |
| 6167 | bnx2x_cl45_read(bp, phy, |
| 6168 | MDIO_PMA_DEVAD, |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 6169 | MDIO_PMA_REG_8481_LINK_SIGNAL + adj, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6170 | val &= 0xFE00; |
| 6171 | val |= 0x0092; |
| 6172 | |
| 6173 | bnx2x_cl45_write(bp, phy, |
| 6174 | MDIO_PMA_DEVAD, |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 6175 | MDIO_PMA_REG_8481_LINK_SIGNAL + adj, val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6176 | |
| 6177 | bnx2x_cl45_write(bp, phy, |
| 6178 | MDIO_PMA_DEVAD, |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 6179 | MDIO_PMA_REG_8481_LED1_MASK + adj, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6180 | 0x80); |
| 6181 | |
| 6182 | bnx2x_cl45_write(bp, phy, |
| 6183 | MDIO_PMA_DEVAD, |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 6184 | MDIO_PMA_REG_8481_LED2_MASK + adj, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6185 | 0x18); |
| 6186 | |
Yaniv Rosner | f25b3c8 | 2011-01-18 04:33:47 +0000 | [diff] [blame] | 6187 | /* Select activity source by Tx and Rx, as suggested by PHY AE */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6188 | bnx2x_cl45_write(bp, phy, |
| 6189 | MDIO_PMA_DEVAD, |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 6190 | MDIO_PMA_REG_8481_LED3_MASK + adj, |
Yaniv Rosner | f25b3c8 | 2011-01-18 04:33:47 +0000 | [diff] [blame] | 6191 | 0x0006); |
| 6192 | |
| 6193 | /* Select the closest activity blink rate to that in 10/100/1000 */ |
| 6194 | bnx2x_cl45_write(bp, phy, |
| 6195 | MDIO_PMA_DEVAD, |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 6196 | MDIO_PMA_REG_8481_LED3_BLINK + adj, |
Yaniv Rosner | f25b3c8 | 2011-01-18 04:33:47 +0000 | [diff] [blame] | 6197 | 0); |
| 6198 | |
| 6199 | bnx2x_cl45_read(bp, phy, |
| 6200 | MDIO_PMA_DEVAD, |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 6201 | MDIO_PMA_REG_84823_CTL_LED_CTL_1 + adj, &val); |
Yaniv Rosner | f25b3c8 | 2011-01-18 04:33:47 +0000 | [diff] [blame] | 6202 | val |= MDIO_PMA_REG_84823_LED3_STRETCH_EN; /* stretch_en for LED3*/ |
| 6203 | |
| 6204 | bnx2x_cl45_write(bp, phy, |
| 6205 | MDIO_PMA_DEVAD, |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 6206 | MDIO_PMA_REG_84823_CTL_LED_CTL_1 + adj, val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6207 | |
| 6208 | /* 'Interrupt Mask' */ |
| 6209 | bnx2x_cl45_write(bp, phy, |
| 6210 | MDIO_AN_DEVAD, |
| 6211 | 0xFFFB, 0xFFFD); |
| 6212 | } |
| 6213 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6214 | static int bnx2x_848xx_cmn_config_init(struct bnx2x_phy *phy, |
| 6215 | struct link_params *params, |
| 6216 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6217 | { |
| 6218 | struct bnx2x *bp = params->bp; |
| 6219 | u16 autoneg_val, an_1000_val, an_10_100_val; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6220 | /* |
| 6221 | * This phy uses the NIG latch mechanism since link indication |
| 6222 | * arrives through its LED4 and not via its LASI signal, so we |
| 6223 | * get steady signal instead of clear on read |
| 6224 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6225 | bnx2x_bits_en(bp, NIG_REG_LATCH_BC_0 + params->port*4, |
| 6226 | 1 << NIG_LATCH_BC_ENABLE_MI_INT); |
| 6227 | |
| 6228 | bnx2x_cl45_write(bp, phy, |
| 6229 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 0x0000); |
| 6230 | |
| 6231 | bnx2x_848xx_set_led(bp, phy); |
| 6232 | |
| 6233 | /* set 1000 speed advertisement */ |
| 6234 | bnx2x_cl45_read(bp, phy, |
| 6235 | MDIO_AN_DEVAD, MDIO_AN_REG_8481_1000T_CTRL, |
| 6236 | &an_1000_val); |
| 6237 | |
| 6238 | bnx2x_ext_phy_set_pause(params, phy, vars); |
| 6239 | bnx2x_cl45_read(bp, phy, |
| 6240 | MDIO_AN_DEVAD, |
| 6241 | MDIO_AN_REG_8481_LEGACY_AN_ADV, |
| 6242 | &an_10_100_val); |
| 6243 | bnx2x_cl45_read(bp, phy, |
| 6244 | MDIO_AN_DEVAD, MDIO_AN_REG_8481_LEGACY_MII_CTRL, |
| 6245 | &autoneg_val); |
| 6246 | /* Disable forced speed */ |
| 6247 | autoneg_val &= ~((1<<6) | (1<<8) | (1<<9) | (1<<12) | (1<<13)); |
| 6248 | an_10_100_val &= ~((1<<5) | (1<<6) | (1<<7) | (1<<8)); |
| 6249 | |
| 6250 | if (((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 6251 | (phy->speed_cap_mask & |
| 6252 | PORT_HW_CFG_SPEED_CAPABILITY_D0_1G)) || |
| 6253 | (phy->req_line_speed == SPEED_1000)) { |
| 6254 | an_1000_val |= (1<<8); |
| 6255 | autoneg_val |= (1<<9 | 1<<12); |
| 6256 | if (phy->req_duplex == DUPLEX_FULL) |
| 6257 | an_1000_val |= (1<<9); |
| 6258 | DP(NETIF_MSG_LINK, "Advertising 1G\n"); |
| 6259 | } else |
| 6260 | an_1000_val &= ~((1<<8) | (1<<9)); |
| 6261 | |
| 6262 | bnx2x_cl45_write(bp, phy, |
| 6263 | MDIO_AN_DEVAD, MDIO_AN_REG_8481_1000T_CTRL, |
| 6264 | an_1000_val); |
| 6265 | |
| 6266 | /* set 10 speed advertisement */ |
| 6267 | if (((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 6268 | (phy->speed_cap_mask & |
| 6269 | (PORT_HW_CFG_SPEED_CAPABILITY_D0_100M_FULL | |
| 6270 | PORT_HW_CFG_SPEED_CAPABILITY_D0_100M_HALF)))) { |
| 6271 | an_10_100_val |= (1<<7); |
| 6272 | /* Enable autoneg and restart autoneg for legacy speeds */ |
| 6273 | autoneg_val |= (1<<9 | 1<<12); |
| 6274 | |
| 6275 | if (phy->req_duplex == DUPLEX_FULL) |
| 6276 | an_10_100_val |= (1<<8); |
| 6277 | DP(NETIF_MSG_LINK, "Advertising 100M\n"); |
| 6278 | } |
| 6279 | /* set 10 speed advertisement */ |
| 6280 | if (((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 6281 | (phy->speed_cap_mask & |
| 6282 | (PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_FULL | |
| 6283 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_HALF)))) { |
| 6284 | an_10_100_val |= (1<<5); |
| 6285 | autoneg_val |= (1<<9 | 1<<12); |
| 6286 | if (phy->req_duplex == DUPLEX_FULL) |
| 6287 | an_10_100_val |= (1<<6); |
| 6288 | DP(NETIF_MSG_LINK, "Advertising 10M\n"); |
| 6289 | } |
| 6290 | |
| 6291 | /* Only 10/100 are allowed to work in FORCE mode */ |
| 6292 | if (phy->req_line_speed == SPEED_100) { |
| 6293 | autoneg_val |= (1<<13); |
| 6294 | /* Enabled AUTO-MDIX when autoneg is disabled */ |
| 6295 | bnx2x_cl45_write(bp, phy, |
| 6296 | MDIO_AN_DEVAD, MDIO_AN_REG_8481_AUX_CTRL, |
| 6297 | (1<<15 | 1<<9 | 7<<0)); |
| 6298 | DP(NETIF_MSG_LINK, "Setting 100M force\n"); |
| 6299 | } |
| 6300 | if (phy->req_line_speed == SPEED_10) { |
| 6301 | /* Enabled AUTO-MDIX when autoneg is disabled */ |
| 6302 | bnx2x_cl45_write(bp, phy, |
| 6303 | MDIO_AN_DEVAD, MDIO_AN_REG_8481_AUX_CTRL, |
| 6304 | (1<<15 | 1<<9 | 7<<0)); |
| 6305 | DP(NETIF_MSG_LINK, "Setting 10M force\n"); |
| 6306 | } |
| 6307 | |
| 6308 | bnx2x_cl45_write(bp, phy, |
| 6309 | MDIO_AN_DEVAD, MDIO_AN_REG_8481_LEGACY_AN_ADV, |
| 6310 | an_10_100_val); |
| 6311 | |
| 6312 | if (phy->req_duplex == DUPLEX_FULL) |
| 6313 | autoneg_val |= (1<<8); |
| 6314 | |
| 6315 | bnx2x_cl45_write(bp, phy, |
| 6316 | MDIO_AN_DEVAD, |
| 6317 | MDIO_AN_REG_8481_LEGACY_MII_CTRL, autoneg_val); |
| 6318 | |
| 6319 | if (((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 6320 | (phy->speed_cap_mask & |
| 6321 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G)) || |
| 6322 | (phy->req_line_speed == SPEED_10000)) { |
| 6323 | DP(NETIF_MSG_LINK, "Advertising 10G\n"); |
| 6324 | /* Restart autoneg for 10G*/ |
| 6325 | |
| 6326 | bnx2x_cl45_write(bp, phy, |
| 6327 | MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, |
| 6328 | 0x3200); |
| 6329 | } else if (phy->req_line_speed != SPEED_10 && |
| 6330 | phy->req_line_speed != SPEED_100) { |
| 6331 | bnx2x_cl45_write(bp, phy, |
| 6332 | MDIO_AN_DEVAD, |
| 6333 | MDIO_AN_REG_8481_10GBASE_T_AN_CTRL, |
| 6334 | 1); |
| 6335 | } |
| 6336 | /* Save spirom version */ |
| 6337 | bnx2x_save_848xx_spirom_version(phy, params); |
| 6338 | |
| 6339 | return 0; |
| 6340 | } |
| 6341 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6342 | static int bnx2x_8481_config_init(struct bnx2x_phy *phy, |
| 6343 | struct link_params *params, |
| 6344 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6345 | { |
| 6346 | struct bnx2x *bp = params->bp; |
| 6347 | /* Restore normal power mode*/ |
| 6348 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6349 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, params->port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6350 | |
| 6351 | /* HW reset */ |
| 6352 | bnx2x_ext_phy_hw_reset(bp, params->port); |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 6353 | bnx2x_wait_reset_complete(bp, phy, params); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6354 | |
| 6355 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 1<<15); |
| 6356 | return bnx2x_848xx_cmn_config_init(phy, params, vars); |
| 6357 | } |
| 6358 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6359 | static int bnx2x_848x3_config_init(struct bnx2x_phy *phy, |
| 6360 | struct link_params *params, |
| 6361 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6362 | { |
| 6363 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 6a71bbe | 2010-11-01 05:32:31 +0000 | [diff] [blame] | 6364 | u8 port, initialize = 1; |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 6365 | u16 val, adj; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6366 | u16 temp; |
Yaniv Rosner | 1bef68e | 2011-01-31 04:22:46 +0000 | [diff] [blame] | 6367 | u32 actual_phy_selection, cms_enable; |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6368 | int rc = 0; |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6369 | |
| 6370 | /* This is just for MDIO_CTL_REG_84823_MEDIA register. */ |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 6371 | adj = 0; |
| 6372 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833) |
| 6373 | adj = 3; |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6374 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6375 | msleep(1); |
Yaniv Rosner | 6a71bbe | 2010-11-01 05:32:31 +0000 | [diff] [blame] | 6376 | if (CHIP_IS_E2(bp)) |
| 6377 | port = BP_PATH(bp); |
| 6378 | else |
| 6379 | port = params->port; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6380 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_3, |
| 6381 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6382 | port); |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 6383 | bnx2x_wait_reset_complete(bp, phy, params); |
Yaniv Rosner | 9bffeac | 2010-11-01 05:32:27 +0000 | [diff] [blame] | 6384 | /* Wait for GPHY to come out of reset */ |
| 6385 | msleep(50); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6386 | /* |
| 6387 | * BCM84823 requires that XGXS links up first @ 10G for normal behavior |
| 6388 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6389 | temp = vars->line_speed; |
| 6390 | vars->line_speed = SPEED_10000; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6391 | bnx2x_set_autoneg(¶ms->phy[INT_PHY], params, vars, 0); |
| 6392 | bnx2x_program_serdes(¶ms->phy[INT_PHY], params, vars); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6393 | vars->line_speed = temp; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6394 | |
| 6395 | /* Set dual-media configuration according to configuration */ |
| 6396 | |
| 6397 | bnx2x_cl45_read(bp, phy, MDIO_CTL_DEVAD, |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 6398 | MDIO_CTL_REG_84823_MEDIA + adj, &val); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6399 | val &= ~(MDIO_CTL_REG_84823_MEDIA_MAC_MASK | |
| 6400 | MDIO_CTL_REG_84823_MEDIA_LINE_MASK | |
| 6401 | MDIO_CTL_REG_84823_MEDIA_COPPER_CORE_DOWN | |
| 6402 | MDIO_CTL_REG_84823_MEDIA_PRIORITY_MASK | |
| 6403 | MDIO_CTL_REG_84823_MEDIA_FIBER_1G); |
| 6404 | val |= MDIO_CTL_REG_84823_CTRL_MAC_XFI | |
| 6405 | MDIO_CTL_REG_84823_MEDIA_LINE_XAUI_L; |
| 6406 | |
| 6407 | actual_phy_selection = bnx2x_phy_selection(params); |
| 6408 | |
| 6409 | switch (actual_phy_selection) { |
| 6410 | case PORT_HW_CFG_PHY_SELECTION_HARDWARE_DEFAULT: |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 6411 | /* Do nothing. Essentially this is like the priority copper */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6412 | break; |
| 6413 | case PORT_HW_CFG_PHY_SELECTION_FIRST_PHY_PRIORITY: |
| 6414 | val |= MDIO_CTL_REG_84823_MEDIA_PRIORITY_COPPER; |
| 6415 | break; |
| 6416 | case PORT_HW_CFG_PHY_SELECTION_SECOND_PHY_PRIORITY: |
| 6417 | val |= MDIO_CTL_REG_84823_MEDIA_PRIORITY_FIBER; |
| 6418 | break; |
| 6419 | case PORT_HW_CFG_PHY_SELECTION_FIRST_PHY: |
| 6420 | /* Do nothing here. The first PHY won't be initialized at all */ |
| 6421 | break; |
| 6422 | case PORT_HW_CFG_PHY_SELECTION_SECOND_PHY: |
| 6423 | val |= MDIO_CTL_REG_84823_MEDIA_COPPER_CORE_DOWN; |
| 6424 | initialize = 0; |
| 6425 | break; |
| 6426 | } |
| 6427 | if (params->phy[EXT_PHY2].req_line_speed == SPEED_1000) |
| 6428 | val |= MDIO_CTL_REG_84823_MEDIA_FIBER_1G; |
| 6429 | |
| 6430 | bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD, |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 6431 | MDIO_CTL_REG_84823_MEDIA + adj, val); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6432 | DP(NETIF_MSG_LINK, "Multi_phy config = 0x%x, Media control = 0x%x\n", |
| 6433 | params->multi_phy_config, val); |
| 6434 | |
| 6435 | if (initialize) |
| 6436 | rc = bnx2x_848xx_cmn_config_init(phy, params, vars); |
| 6437 | else |
| 6438 | bnx2x_save_848xx_spirom_version(phy, params); |
Yaniv Rosner | 1bef68e | 2011-01-31 04:22:46 +0000 | [diff] [blame] | 6439 | cms_enable = REG_RD(bp, params->shmem_base + |
| 6440 | offsetof(struct shmem_region, |
| 6441 | dev_info.port_hw_config[params->port].default_cfg)) & |
| 6442 | PORT_HW_CFG_ENABLE_CMS_MASK; |
| 6443 | |
| 6444 | bnx2x_cl45_read(bp, phy, MDIO_CTL_DEVAD, |
| 6445 | MDIO_CTL_REG_84823_USER_CTRL_REG, &val); |
| 6446 | if (cms_enable) |
| 6447 | val |= MDIO_CTL_REG_84823_USER_CTRL_CMS; |
| 6448 | else |
| 6449 | val &= ~MDIO_CTL_REG_84823_USER_CTRL_CMS; |
| 6450 | bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD, |
| 6451 | MDIO_CTL_REG_84823_USER_CTRL_REG, val); |
| 6452 | |
| 6453 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6454 | return rc; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6455 | } |
| 6456 | |
| 6457 | static u8 bnx2x_848xx_read_status(struct bnx2x_phy *phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6458 | struct link_params *params, |
| 6459 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6460 | { |
| 6461 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 6462 | u16 val, val1, val2, adj; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6463 | u8 link_up = 0; |
| 6464 | |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 6465 | /* Reg offset adjustment for 84833 */ |
| 6466 | adj = 0; |
| 6467 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833) |
| 6468 | adj = -1; |
| 6469 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6470 | /* Check 10G-BaseT link status */ |
| 6471 | /* Check PMD signal ok */ |
| 6472 | bnx2x_cl45_read(bp, phy, |
| 6473 | MDIO_AN_DEVAD, 0xFFFA, &val1); |
| 6474 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 6475 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8481_PMD_SIGNAL + adj, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6476 | &val2); |
| 6477 | DP(NETIF_MSG_LINK, "BCM848xx: PMD_SIGNAL 1.a811 = 0x%x\n", val2); |
| 6478 | |
| 6479 | /* Check link 10G */ |
| 6480 | if (val2 & (1<<11)) { |
| 6481 | vars->line_speed = SPEED_10000; |
Yaniv Rosner | 791f18c | 2011-01-18 04:33:42 +0000 | [diff] [blame] | 6482 | vars->duplex = DUPLEX_FULL; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6483 | link_up = 1; |
| 6484 | bnx2x_ext_phy_10G_an_resolve(bp, phy, vars); |
| 6485 | } else { /* Check Legacy speed link */ |
| 6486 | u16 legacy_status, legacy_speed; |
| 6487 | |
| 6488 | /* Enable expansion register 0x42 (Operation mode status) */ |
| 6489 | bnx2x_cl45_write(bp, phy, |
| 6490 | MDIO_AN_DEVAD, |
| 6491 | MDIO_AN_REG_8481_EXPANSION_REG_ACCESS, 0xf42); |
| 6492 | |
| 6493 | /* Get legacy speed operation status */ |
| 6494 | bnx2x_cl45_read(bp, phy, |
| 6495 | MDIO_AN_DEVAD, |
| 6496 | MDIO_AN_REG_8481_EXPANSION_REG_RD_RW, |
| 6497 | &legacy_status); |
| 6498 | |
| 6499 | DP(NETIF_MSG_LINK, "Legacy speed status" |
| 6500 | " = 0x%x\n", legacy_status); |
| 6501 | link_up = ((legacy_status & (1<<11)) == (1<<11)); |
| 6502 | if (link_up) { |
| 6503 | legacy_speed = (legacy_status & (3<<9)); |
| 6504 | if (legacy_speed == (0<<9)) |
| 6505 | vars->line_speed = SPEED_10; |
| 6506 | else if (legacy_speed == (1<<9)) |
| 6507 | vars->line_speed = SPEED_100; |
| 6508 | else if (legacy_speed == (2<<9)) |
| 6509 | vars->line_speed = SPEED_1000; |
| 6510 | else /* Should not happen */ |
| 6511 | vars->line_speed = 0; |
| 6512 | |
| 6513 | if (legacy_status & (1<<8)) |
| 6514 | vars->duplex = DUPLEX_FULL; |
| 6515 | else |
| 6516 | vars->duplex = DUPLEX_HALF; |
| 6517 | |
| 6518 | DP(NETIF_MSG_LINK, "Link is up in %dMbps," |
| 6519 | " is_duplex_full= %d\n", vars->line_speed, |
| 6520 | (vars->duplex == DUPLEX_FULL)); |
| 6521 | /* Check legacy speed AN resolution */ |
| 6522 | bnx2x_cl45_read(bp, phy, |
| 6523 | MDIO_AN_DEVAD, |
| 6524 | MDIO_AN_REG_8481_LEGACY_MII_STATUS, |
| 6525 | &val); |
| 6526 | if (val & (1<<5)) |
| 6527 | vars->link_status |= |
| 6528 | LINK_STATUS_AUTO_NEGOTIATE_COMPLETE; |
| 6529 | bnx2x_cl45_read(bp, phy, |
| 6530 | MDIO_AN_DEVAD, |
| 6531 | MDIO_AN_REG_8481_LEGACY_AN_EXPANSION, |
| 6532 | &val); |
| 6533 | if ((val & (1<<0)) == 0) |
| 6534 | vars->link_status |= |
| 6535 | LINK_STATUS_PARALLEL_DETECTION_USED; |
| 6536 | } |
| 6537 | } |
| 6538 | if (link_up) { |
| 6539 | DP(NETIF_MSG_LINK, "BCM84823: link speed is %d\n", |
| 6540 | vars->line_speed); |
| 6541 | bnx2x_ext_phy_resolve_fc(phy, params, vars); |
| 6542 | } |
| 6543 | |
| 6544 | return link_up; |
| 6545 | } |
| 6546 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6547 | |
| 6548 | static int bnx2x_848xx_format_ver(u32 raw_ver, u8 *str, u16 *len) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6549 | { |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6550 | int status = 0; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6551 | u32 spirom_ver; |
| 6552 | spirom_ver = ((raw_ver & 0xF80) >> 7) << 16 | (raw_ver & 0x7F); |
| 6553 | status = bnx2x_format_ver(spirom_ver, str, len); |
| 6554 | return status; |
| 6555 | } |
| 6556 | |
| 6557 | static void bnx2x_8481_hw_reset(struct bnx2x_phy *phy, |
| 6558 | struct link_params *params) |
| 6559 | { |
| 6560 | bnx2x_set_gpio(params->bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6561 | MISC_REGISTERS_GPIO_OUTPUT_LOW, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6562 | bnx2x_set_gpio(params->bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6563 | MISC_REGISTERS_GPIO_OUTPUT_LOW, 1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6564 | } |
| 6565 | |
| 6566 | static void bnx2x_8481_link_reset(struct bnx2x_phy *phy, |
| 6567 | struct link_params *params) |
| 6568 | { |
| 6569 | bnx2x_cl45_write(params->bp, phy, |
| 6570 | MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, 0x0000); |
| 6571 | bnx2x_cl45_write(params->bp, phy, |
| 6572 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 1); |
| 6573 | } |
| 6574 | |
| 6575 | static void bnx2x_848x3_link_reset(struct bnx2x_phy *phy, |
| 6576 | struct link_params *params) |
| 6577 | { |
| 6578 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 6a71bbe | 2010-11-01 05:32:31 +0000 | [diff] [blame] | 6579 | u8 port; |
| 6580 | if (CHIP_IS_E2(bp)) |
| 6581 | port = BP_PATH(bp); |
| 6582 | else |
| 6583 | port = params->port; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6584 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_3, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6585 | MISC_REGISTERS_GPIO_OUTPUT_LOW, |
| 6586 | port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6587 | } |
| 6588 | |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6589 | static void bnx2x_848xx_set_link_led(struct bnx2x_phy *phy, |
| 6590 | struct link_params *params, u8 mode) |
| 6591 | { |
| 6592 | struct bnx2x *bp = params->bp; |
| 6593 | u16 val; |
| 6594 | |
| 6595 | switch (mode) { |
| 6596 | case LED_MODE_OFF: |
| 6597 | |
| 6598 | DP(NETIF_MSG_LINK, "Port 0x%x: LED MODE OFF\n", params->port); |
| 6599 | |
| 6600 | if ((params->hw_led_mode << SHARED_HW_CFG_LED_MODE_SHIFT) == |
| 6601 | SHARED_HW_CFG_LED_EXTPHY1) { |
| 6602 | |
| 6603 | /* Set LED masks */ |
| 6604 | bnx2x_cl45_write(bp, phy, |
| 6605 | MDIO_PMA_DEVAD, |
| 6606 | MDIO_PMA_REG_8481_LED1_MASK, |
| 6607 | 0x0); |
| 6608 | |
| 6609 | bnx2x_cl45_write(bp, phy, |
| 6610 | MDIO_PMA_DEVAD, |
| 6611 | MDIO_PMA_REG_8481_LED2_MASK, |
| 6612 | 0x0); |
| 6613 | |
| 6614 | bnx2x_cl45_write(bp, phy, |
| 6615 | MDIO_PMA_DEVAD, |
| 6616 | MDIO_PMA_REG_8481_LED3_MASK, |
| 6617 | 0x0); |
| 6618 | |
| 6619 | bnx2x_cl45_write(bp, phy, |
| 6620 | MDIO_PMA_DEVAD, |
| 6621 | MDIO_PMA_REG_8481_LED5_MASK, |
| 6622 | 0x0); |
| 6623 | |
| 6624 | } else { |
| 6625 | bnx2x_cl45_write(bp, phy, |
| 6626 | MDIO_PMA_DEVAD, |
| 6627 | MDIO_PMA_REG_8481_LED1_MASK, |
| 6628 | 0x0); |
| 6629 | } |
| 6630 | break; |
| 6631 | case LED_MODE_FRONT_PANEL_OFF: |
| 6632 | |
| 6633 | DP(NETIF_MSG_LINK, "Port 0x%x: LED MODE FRONT PANEL OFF\n", |
| 6634 | params->port); |
| 6635 | |
| 6636 | if ((params->hw_led_mode << SHARED_HW_CFG_LED_MODE_SHIFT) == |
| 6637 | SHARED_HW_CFG_LED_EXTPHY1) { |
| 6638 | |
| 6639 | /* Set LED masks */ |
| 6640 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6641 | MDIO_PMA_DEVAD, |
| 6642 | MDIO_PMA_REG_8481_LED1_MASK, |
| 6643 | 0x0); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6644 | |
| 6645 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6646 | MDIO_PMA_DEVAD, |
| 6647 | MDIO_PMA_REG_8481_LED2_MASK, |
| 6648 | 0x0); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6649 | |
| 6650 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6651 | MDIO_PMA_DEVAD, |
| 6652 | MDIO_PMA_REG_8481_LED3_MASK, |
| 6653 | 0x0); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6654 | |
| 6655 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6656 | MDIO_PMA_DEVAD, |
| 6657 | MDIO_PMA_REG_8481_LED5_MASK, |
| 6658 | 0x20); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6659 | |
| 6660 | } else { |
| 6661 | bnx2x_cl45_write(bp, phy, |
| 6662 | MDIO_PMA_DEVAD, |
| 6663 | MDIO_PMA_REG_8481_LED1_MASK, |
| 6664 | 0x0); |
| 6665 | } |
| 6666 | break; |
| 6667 | case LED_MODE_ON: |
| 6668 | |
| 6669 | DP(NETIF_MSG_LINK, "Port 0x%x: LED MODE ON\n", params->port); |
| 6670 | |
| 6671 | if ((params->hw_led_mode << SHARED_HW_CFG_LED_MODE_SHIFT) == |
| 6672 | SHARED_HW_CFG_LED_EXTPHY1) { |
| 6673 | /* Set control reg */ |
| 6674 | bnx2x_cl45_read(bp, phy, |
| 6675 | MDIO_PMA_DEVAD, |
| 6676 | MDIO_PMA_REG_8481_LINK_SIGNAL, |
| 6677 | &val); |
| 6678 | val &= 0x8000; |
| 6679 | val |= 0x2492; |
| 6680 | |
| 6681 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6682 | MDIO_PMA_DEVAD, |
| 6683 | MDIO_PMA_REG_8481_LINK_SIGNAL, |
| 6684 | val); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6685 | |
| 6686 | /* Set LED masks */ |
| 6687 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6688 | MDIO_PMA_DEVAD, |
| 6689 | MDIO_PMA_REG_8481_LED1_MASK, |
| 6690 | 0x0); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6691 | |
| 6692 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6693 | MDIO_PMA_DEVAD, |
| 6694 | MDIO_PMA_REG_8481_LED2_MASK, |
| 6695 | 0x20); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6696 | |
| 6697 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6698 | MDIO_PMA_DEVAD, |
| 6699 | MDIO_PMA_REG_8481_LED3_MASK, |
| 6700 | 0x20); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6701 | |
| 6702 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6703 | MDIO_PMA_DEVAD, |
| 6704 | MDIO_PMA_REG_8481_LED5_MASK, |
| 6705 | 0x0); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6706 | } else { |
| 6707 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6708 | MDIO_PMA_DEVAD, |
| 6709 | MDIO_PMA_REG_8481_LED1_MASK, |
| 6710 | 0x20); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6711 | } |
| 6712 | break; |
| 6713 | |
| 6714 | case LED_MODE_OPER: |
| 6715 | |
| 6716 | DP(NETIF_MSG_LINK, "Port 0x%x: LED MODE OPER\n", params->port); |
| 6717 | |
| 6718 | if ((params->hw_led_mode << SHARED_HW_CFG_LED_MODE_SHIFT) == |
| 6719 | SHARED_HW_CFG_LED_EXTPHY1) { |
| 6720 | |
| 6721 | /* Set control reg */ |
| 6722 | bnx2x_cl45_read(bp, phy, |
| 6723 | MDIO_PMA_DEVAD, |
| 6724 | MDIO_PMA_REG_8481_LINK_SIGNAL, |
| 6725 | &val); |
| 6726 | |
| 6727 | if (!((val & |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6728 | MDIO_PMA_REG_8481_LINK_SIGNAL_LED4_ENABLE_MASK) |
| 6729 | >> MDIO_PMA_REG_8481_LINK_SIGNAL_LED4_ENABLE_SHIFT)) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6730 | DP(NETIF_MSG_LINK, "Setting LINK_SIGNAL\n"); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6731 | bnx2x_cl45_write(bp, phy, |
| 6732 | MDIO_PMA_DEVAD, |
| 6733 | MDIO_PMA_REG_8481_LINK_SIGNAL, |
| 6734 | 0xa492); |
| 6735 | } |
| 6736 | |
| 6737 | /* Set LED masks */ |
| 6738 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6739 | MDIO_PMA_DEVAD, |
| 6740 | MDIO_PMA_REG_8481_LED1_MASK, |
| 6741 | 0x10); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6742 | |
| 6743 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6744 | MDIO_PMA_DEVAD, |
| 6745 | MDIO_PMA_REG_8481_LED2_MASK, |
| 6746 | 0x80); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6747 | |
| 6748 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6749 | MDIO_PMA_DEVAD, |
| 6750 | MDIO_PMA_REG_8481_LED3_MASK, |
| 6751 | 0x98); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6752 | |
| 6753 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6754 | MDIO_PMA_DEVAD, |
| 6755 | MDIO_PMA_REG_8481_LED5_MASK, |
| 6756 | 0x40); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6757 | |
| 6758 | } else { |
| 6759 | bnx2x_cl45_write(bp, phy, |
| 6760 | MDIO_PMA_DEVAD, |
| 6761 | MDIO_PMA_REG_8481_LED1_MASK, |
| 6762 | 0x80); |
Yaniv Rosner | 53eda06 | 2011-01-30 04:14:55 +0000 | [diff] [blame] | 6763 | |
| 6764 | /* Tell LED3 to blink on source */ |
| 6765 | bnx2x_cl45_read(bp, phy, |
| 6766 | MDIO_PMA_DEVAD, |
| 6767 | MDIO_PMA_REG_8481_LINK_SIGNAL, |
| 6768 | &val); |
| 6769 | val &= ~(7<<6); |
| 6770 | val |= (1<<6); /* A83B[8:6]= 1 */ |
| 6771 | bnx2x_cl45_write(bp, phy, |
| 6772 | MDIO_PMA_DEVAD, |
| 6773 | MDIO_PMA_REG_8481_LINK_SIGNAL, |
| 6774 | val); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6775 | } |
| 6776 | break; |
| 6777 | } |
| 6778 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6779 | /******************************************************************/ |
| 6780 | /* SFX7101 PHY SECTION */ |
| 6781 | /******************************************************************/ |
| 6782 | static void bnx2x_7101_config_loopback(struct bnx2x_phy *phy, |
| 6783 | struct link_params *params) |
| 6784 | { |
| 6785 | struct bnx2x *bp = params->bp; |
| 6786 | /* SFX7101_XGXS_TEST1 */ |
| 6787 | bnx2x_cl45_write(bp, phy, |
| 6788 | MDIO_XS_DEVAD, MDIO_XS_SFX7101_XGXS_TEST1, 0x100); |
| 6789 | } |
| 6790 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6791 | static int bnx2x_7101_config_init(struct bnx2x_phy *phy, |
| 6792 | struct link_params *params, |
| 6793 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6794 | { |
| 6795 | u16 fw_ver1, fw_ver2, val; |
| 6796 | struct bnx2x *bp = params->bp; |
| 6797 | DP(NETIF_MSG_LINK, "Setting the SFX7101 LASI indication\n"); |
| 6798 | |
| 6799 | /* Restore normal power mode*/ |
| 6800 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6801 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, params->port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6802 | /* HW reset */ |
| 6803 | bnx2x_ext_phy_hw_reset(bp, params->port); |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 6804 | bnx2x_wait_reset_complete(bp, phy, params); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6805 | |
| 6806 | bnx2x_cl45_write(bp, phy, |
| 6807 | MDIO_PMA_DEVAD, MDIO_PMA_REG_LASI_CTRL, 0x1); |
| 6808 | DP(NETIF_MSG_LINK, "Setting the SFX7101 LED to blink on traffic\n"); |
| 6809 | bnx2x_cl45_write(bp, phy, |
| 6810 | MDIO_PMA_DEVAD, MDIO_PMA_REG_7107_LED_CNTL, (1<<3)); |
| 6811 | |
| 6812 | bnx2x_ext_phy_set_pause(params, phy, vars); |
| 6813 | /* Restart autoneg */ |
| 6814 | bnx2x_cl45_read(bp, phy, |
| 6815 | MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, &val); |
| 6816 | val |= 0x200; |
| 6817 | bnx2x_cl45_write(bp, phy, |
| 6818 | MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, val); |
| 6819 | |
| 6820 | /* Save spirom version */ |
| 6821 | bnx2x_cl45_read(bp, phy, |
| 6822 | MDIO_PMA_DEVAD, MDIO_PMA_REG_7101_VER1, &fw_ver1); |
| 6823 | |
| 6824 | bnx2x_cl45_read(bp, phy, |
| 6825 | MDIO_PMA_DEVAD, MDIO_PMA_REG_7101_VER2, &fw_ver2); |
| 6826 | bnx2x_save_spirom_version(bp, params->port, |
| 6827 | (u32)(fw_ver1<<16 | fw_ver2), phy->ver_addr); |
| 6828 | return 0; |
| 6829 | } |
| 6830 | |
| 6831 | static u8 bnx2x_7101_read_status(struct bnx2x_phy *phy, |
| 6832 | struct link_params *params, |
| 6833 | struct link_vars *vars) |
| 6834 | { |
| 6835 | struct bnx2x *bp = params->bp; |
| 6836 | u8 link_up; |
| 6837 | u16 val1, val2; |
| 6838 | bnx2x_cl45_read(bp, phy, |
| 6839 | MDIO_PMA_DEVAD, MDIO_PMA_REG_LASI_STATUS, &val2); |
| 6840 | bnx2x_cl45_read(bp, phy, |
| 6841 | MDIO_PMA_DEVAD, MDIO_PMA_REG_LASI_STATUS, &val1); |
| 6842 | DP(NETIF_MSG_LINK, "10G-base-T LASI status 0x%x->0x%x\n", |
| 6843 | val2, val1); |
| 6844 | bnx2x_cl45_read(bp, phy, |
| 6845 | MDIO_PMA_DEVAD, MDIO_PMA_REG_STATUS, &val2); |
| 6846 | bnx2x_cl45_read(bp, phy, |
| 6847 | MDIO_PMA_DEVAD, MDIO_PMA_REG_STATUS, &val1); |
| 6848 | DP(NETIF_MSG_LINK, "10G-base-T PMA status 0x%x->0x%x\n", |
| 6849 | val2, val1); |
| 6850 | link_up = ((val1 & 4) == 4); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6851 | /* if link is up print the AN outcome of the SFX7101 PHY */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6852 | if (link_up) { |
| 6853 | bnx2x_cl45_read(bp, phy, |
| 6854 | MDIO_AN_DEVAD, MDIO_AN_REG_MASTER_STATUS, |
| 6855 | &val2); |
| 6856 | vars->line_speed = SPEED_10000; |
Yaniv Rosner | 791f18c | 2011-01-18 04:33:42 +0000 | [diff] [blame] | 6857 | vars->duplex = DUPLEX_FULL; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6858 | DP(NETIF_MSG_LINK, "SFX7101 AN status 0x%x->Master=%x\n", |
| 6859 | val2, (val2 & (1<<14))); |
| 6860 | bnx2x_ext_phy_10G_an_resolve(bp, phy, vars); |
| 6861 | bnx2x_ext_phy_resolve_fc(phy, params, vars); |
| 6862 | } |
| 6863 | return link_up; |
| 6864 | } |
| 6865 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6866 | static int bnx2x_7101_format_ver(u32 spirom_ver, u8 *str, u16 *len) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6867 | { |
| 6868 | if (*len < 5) |
| 6869 | return -EINVAL; |
| 6870 | str[0] = (spirom_ver & 0xFF); |
| 6871 | str[1] = (spirom_ver & 0xFF00) >> 8; |
| 6872 | str[2] = (spirom_ver & 0xFF0000) >> 16; |
| 6873 | str[3] = (spirom_ver & 0xFF000000) >> 24; |
| 6874 | str[4] = '\0'; |
| 6875 | *len -= 5; |
| 6876 | return 0; |
| 6877 | } |
| 6878 | |
| 6879 | void bnx2x_sfx7101_sp_sw_reset(struct bnx2x *bp, struct bnx2x_phy *phy) |
| 6880 | { |
| 6881 | u16 val, cnt; |
| 6882 | |
| 6883 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6884 | MDIO_PMA_DEVAD, |
| 6885 | MDIO_PMA_REG_7101_RESET, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6886 | |
| 6887 | for (cnt = 0; cnt < 10; cnt++) { |
| 6888 | msleep(50); |
| 6889 | /* Writes a self-clearing reset */ |
| 6890 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6891 | MDIO_PMA_DEVAD, |
| 6892 | MDIO_PMA_REG_7101_RESET, |
| 6893 | (val | (1<<15))); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6894 | /* Wait for clear */ |
| 6895 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6896 | MDIO_PMA_DEVAD, |
| 6897 | MDIO_PMA_REG_7101_RESET, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6898 | |
| 6899 | if ((val & (1<<15)) == 0) |
| 6900 | break; |
| 6901 | } |
| 6902 | } |
| 6903 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6904 | static void bnx2x_7101_hw_reset(struct bnx2x_phy *phy, |
| 6905 | struct link_params *params) { |
| 6906 | /* Low power mode is controlled by GPIO 2 */ |
| 6907 | bnx2x_set_gpio(params->bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6908 | MISC_REGISTERS_GPIO_OUTPUT_LOW, params->port); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6909 | /* The PHY reset is controlled by GPIO 1 */ |
| 6910 | bnx2x_set_gpio(params->bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6911 | MISC_REGISTERS_GPIO_OUTPUT_LOW, params->port); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6912 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6913 | |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6914 | static void bnx2x_7101_set_link_led(struct bnx2x_phy *phy, |
| 6915 | struct link_params *params, u8 mode) |
| 6916 | { |
| 6917 | u16 val = 0; |
| 6918 | struct bnx2x *bp = params->bp; |
| 6919 | switch (mode) { |
| 6920 | case LED_MODE_FRONT_PANEL_OFF: |
| 6921 | case LED_MODE_OFF: |
| 6922 | val = 2; |
| 6923 | break; |
| 6924 | case LED_MODE_ON: |
| 6925 | val = 1; |
| 6926 | break; |
| 6927 | case LED_MODE_OPER: |
| 6928 | val = 0; |
| 6929 | break; |
| 6930 | } |
| 6931 | bnx2x_cl45_write(bp, phy, |
| 6932 | MDIO_PMA_DEVAD, |
| 6933 | MDIO_PMA_REG_7107_LINK_LED_CNTL, |
| 6934 | val); |
| 6935 | } |
| 6936 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6937 | /******************************************************************/ |
| 6938 | /* STATIC PHY DECLARATION */ |
| 6939 | /******************************************************************/ |
| 6940 | |
| 6941 | static struct bnx2x_phy phy_null = { |
| 6942 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_NOT_CONN, |
| 6943 | .addr = 0, |
| 6944 | .flags = FLAGS_INIT_XGXS_FIRST, |
| 6945 | .def_md_devad = 0, |
| 6946 | .reserved = 0, |
| 6947 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 6948 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 6949 | .mdio_ctrl = 0, |
| 6950 | .supported = 0, |
| 6951 | .media_type = ETH_PHY_NOT_PRESENT, |
| 6952 | .ver_addr = 0, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6953 | .req_flow_ctrl = 0, |
| 6954 | .req_line_speed = 0, |
| 6955 | .speed_cap_mask = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6956 | .req_duplex = 0, |
| 6957 | .rsrv = 0, |
| 6958 | .config_init = (config_init_t)NULL, |
| 6959 | .read_status = (read_status_t)NULL, |
| 6960 | .link_reset = (link_reset_t)NULL, |
| 6961 | .config_loopback = (config_loopback_t)NULL, |
| 6962 | .format_fw_ver = (format_fw_ver_t)NULL, |
| 6963 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6964 | .set_link_led = (set_link_led_t)NULL, |
| 6965 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6966 | }; |
| 6967 | |
| 6968 | static struct bnx2x_phy phy_serdes = { |
| 6969 | .type = PORT_HW_CFG_SERDES_EXT_PHY_TYPE_DIRECT, |
| 6970 | .addr = 0xff, |
| 6971 | .flags = 0, |
| 6972 | .def_md_devad = 0, |
| 6973 | .reserved = 0, |
| 6974 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 6975 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 6976 | .mdio_ctrl = 0, |
| 6977 | .supported = (SUPPORTED_10baseT_Half | |
| 6978 | SUPPORTED_10baseT_Full | |
| 6979 | SUPPORTED_100baseT_Half | |
| 6980 | SUPPORTED_100baseT_Full | |
| 6981 | SUPPORTED_1000baseT_Full | |
| 6982 | SUPPORTED_2500baseX_Full | |
| 6983 | SUPPORTED_TP | |
| 6984 | SUPPORTED_Autoneg | |
| 6985 | SUPPORTED_Pause | |
| 6986 | SUPPORTED_Asym_Pause), |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 6987 | .media_type = ETH_PHY_BASE_T, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6988 | .ver_addr = 0, |
| 6989 | .req_flow_ctrl = 0, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6990 | .req_line_speed = 0, |
| 6991 | .speed_cap_mask = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 6992 | .req_duplex = 0, |
| 6993 | .rsrv = 0, |
| 6994 | .config_init = (config_init_t)bnx2x_init_serdes, |
| 6995 | .read_status = (read_status_t)bnx2x_link_settings_status, |
| 6996 | .link_reset = (link_reset_t)bnx2x_int_link_reset, |
| 6997 | .config_loopback = (config_loopback_t)NULL, |
| 6998 | .format_fw_ver = (format_fw_ver_t)NULL, |
| 6999 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7000 | .set_link_led = (set_link_led_t)NULL, |
| 7001 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7002 | }; |
| 7003 | |
| 7004 | static struct bnx2x_phy phy_xgxs = { |
| 7005 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT, |
| 7006 | .addr = 0xff, |
| 7007 | .flags = 0, |
| 7008 | .def_md_devad = 0, |
| 7009 | .reserved = 0, |
| 7010 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 7011 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 7012 | .mdio_ctrl = 0, |
| 7013 | .supported = (SUPPORTED_10baseT_Half | |
| 7014 | SUPPORTED_10baseT_Full | |
| 7015 | SUPPORTED_100baseT_Half | |
| 7016 | SUPPORTED_100baseT_Full | |
| 7017 | SUPPORTED_1000baseT_Full | |
| 7018 | SUPPORTED_2500baseX_Full | |
| 7019 | SUPPORTED_10000baseT_Full | |
| 7020 | SUPPORTED_FIBRE | |
| 7021 | SUPPORTED_Autoneg | |
| 7022 | SUPPORTED_Pause | |
| 7023 | SUPPORTED_Asym_Pause), |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 7024 | .media_type = ETH_PHY_CX4, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7025 | .ver_addr = 0, |
| 7026 | .req_flow_ctrl = 0, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7027 | .req_line_speed = 0, |
| 7028 | .speed_cap_mask = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7029 | .req_duplex = 0, |
| 7030 | .rsrv = 0, |
| 7031 | .config_init = (config_init_t)bnx2x_init_xgxs, |
| 7032 | .read_status = (read_status_t)bnx2x_link_settings_status, |
| 7033 | .link_reset = (link_reset_t)bnx2x_int_link_reset, |
| 7034 | .config_loopback = (config_loopback_t)bnx2x_set_xgxs_loopback, |
| 7035 | .format_fw_ver = (format_fw_ver_t)NULL, |
| 7036 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7037 | .set_link_led = (set_link_led_t)NULL, |
| 7038 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7039 | }; |
| 7040 | |
| 7041 | static struct bnx2x_phy phy_7101 = { |
| 7042 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_SFX7101, |
| 7043 | .addr = 0xff, |
| 7044 | .flags = FLAGS_FAN_FAILURE_DET_REQ, |
| 7045 | .def_md_devad = 0, |
| 7046 | .reserved = 0, |
| 7047 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 7048 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 7049 | .mdio_ctrl = 0, |
| 7050 | .supported = (SUPPORTED_10000baseT_Full | |
| 7051 | SUPPORTED_TP | |
| 7052 | SUPPORTED_Autoneg | |
| 7053 | SUPPORTED_Pause | |
| 7054 | SUPPORTED_Asym_Pause), |
| 7055 | .media_type = ETH_PHY_BASE_T, |
| 7056 | .ver_addr = 0, |
| 7057 | .req_flow_ctrl = 0, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7058 | .req_line_speed = 0, |
| 7059 | .speed_cap_mask = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7060 | .req_duplex = 0, |
| 7061 | .rsrv = 0, |
| 7062 | .config_init = (config_init_t)bnx2x_7101_config_init, |
| 7063 | .read_status = (read_status_t)bnx2x_7101_read_status, |
| 7064 | .link_reset = (link_reset_t)bnx2x_common_ext_link_reset, |
| 7065 | .config_loopback = (config_loopback_t)bnx2x_7101_config_loopback, |
| 7066 | .format_fw_ver = (format_fw_ver_t)bnx2x_7101_format_ver, |
| 7067 | .hw_reset = (hw_reset_t)bnx2x_7101_hw_reset, |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 7068 | .set_link_led = (set_link_led_t)bnx2x_7101_set_link_led, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7069 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7070 | }; |
| 7071 | static struct bnx2x_phy phy_8073 = { |
| 7072 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073, |
| 7073 | .addr = 0xff, |
| 7074 | .flags = FLAGS_HW_LOCK_REQUIRED, |
| 7075 | .def_md_devad = 0, |
| 7076 | .reserved = 0, |
| 7077 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 7078 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 7079 | .mdio_ctrl = 0, |
| 7080 | .supported = (SUPPORTED_10000baseT_Full | |
| 7081 | SUPPORTED_2500baseX_Full | |
| 7082 | SUPPORTED_1000baseT_Full | |
| 7083 | SUPPORTED_FIBRE | |
| 7084 | SUPPORTED_Autoneg | |
| 7085 | SUPPORTED_Pause | |
| 7086 | SUPPORTED_Asym_Pause), |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 7087 | .media_type = ETH_PHY_KR, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7088 | .ver_addr = 0, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7089 | .req_flow_ctrl = 0, |
| 7090 | .req_line_speed = 0, |
| 7091 | .speed_cap_mask = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7092 | .req_duplex = 0, |
| 7093 | .rsrv = 0, |
Yaniv Rosner | 62b29a5 | 2010-09-07 11:40:58 +0000 | [diff] [blame] | 7094 | .config_init = (config_init_t)bnx2x_8073_config_init, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7095 | .read_status = (read_status_t)bnx2x_8073_read_status, |
| 7096 | .link_reset = (link_reset_t)bnx2x_8073_link_reset, |
| 7097 | .config_loopback = (config_loopback_t)NULL, |
| 7098 | .format_fw_ver = (format_fw_ver_t)bnx2x_format_ver, |
| 7099 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7100 | .set_link_led = (set_link_led_t)NULL, |
| 7101 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7102 | }; |
| 7103 | static struct bnx2x_phy phy_8705 = { |
| 7104 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8705, |
| 7105 | .addr = 0xff, |
| 7106 | .flags = FLAGS_INIT_XGXS_FIRST, |
| 7107 | .def_md_devad = 0, |
| 7108 | .reserved = 0, |
| 7109 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 7110 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 7111 | .mdio_ctrl = 0, |
| 7112 | .supported = (SUPPORTED_10000baseT_Full | |
| 7113 | SUPPORTED_FIBRE | |
| 7114 | SUPPORTED_Pause | |
| 7115 | SUPPORTED_Asym_Pause), |
| 7116 | .media_type = ETH_PHY_XFP_FIBER, |
| 7117 | .ver_addr = 0, |
| 7118 | .req_flow_ctrl = 0, |
| 7119 | .req_line_speed = 0, |
| 7120 | .speed_cap_mask = 0, |
| 7121 | .req_duplex = 0, |
| 7122 | .rsrv = 0, |
| 7123 | .config_init = (config_init_t)bnx2x_8705_config_init, |
| 7124 | .read_status = (read_status_t)bnx2x_8705_read_status, |
| 7125 | .link_reset = (link_reset_t)bnx2x_common_ext_link_reset, |
| 7126 | .config_loopback = (config_loopback_t)NULL, |
| 7127 | .format_fw_ver = (format_fw_ver_t)bnx2x_null_format_ver, |
| 7128 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7129 | .set_link_led = (set_link_led_t)NULL, |
| 7130 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7131 | }; |
| 7132 | static struct bnx2x_phy phy_8706 = { |
| 7133 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8706, |
| 7134 | .addr = 0xff, |
| 7135 | .flags = FLAGS_INIT_XGXS_FIRST, |
| 7136 | .def_md_devad = 0, |
| 7137 | .reserved = 0, |
| 7138 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 7139 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 7140 | .mdio_ctrl = 0, |
| 7141 | .supported = (SUPPORTED_10000baseT_Full | |
| 7142 | SUPPORTED_1000baseT_Full | |
| 7143 | SUPPORTED_FIBRE | |
| 7144 | SUPPORTED_Pause | |
| 7145 | SUPPORTED_Asym_Pause), |
| 7146 | .media_type = ETH_PHY_SFP_FIBER, |
| 7147 | .ver_addr = 0, |
| 7148 | .req_flow_ctrl = 0, |
| 7149 | .req_line_speed = 0, |
| 7150 | .speed_cap_mask = 0, |
| 7151 | .req_duplex = 0, |
| 7152 | .rsrv = 0, |
| 7153 | .config_init = (config_init_t)bnx2x_8706_config_init, |
| 7154 | .read_status = (read_status_t)bnx2x_8706_read_status, |
| 7155 | .link_reset = (link_reset_t)bnx2x_common_ext_link_reset, |
| 7156 | .config_loopback = (config_loopback_t)NULL, |
| 7157 | .format_fw_ver = (format_fw_ver_t)bnx2x_format_ver, |
| 7158 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7159 | .set_link_led = (set_link_led_t)NULL, |
| 7160 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7161 | }; |
| 7162 | |
| 7163 | static struct bnx2x_phy phy_8726 = { |
| 7164 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726, |
| 7165 | .addr = 0xff, |
| 7166 | .flags = (FLAGS_HW_LOCK_REQUIRED | |
| 7167 | FLAGS_INIT_XGXS_FIRST), |
| 7168 | .def_md_devad = 0, |
| 7169 | .reserved = 0, |
| 7170 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 7171 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 7172 | .mdio_ctrl = 0, |
| 7173 | .supported = (SUPPORTED_10000baseT_Full | |
| 7174 | SUPPORTED_1000baseT_Full | |
| 7175 | SUPPORTED_Autoneg | |
| 7176 | SUPPORTED_FIBRE | |
| 7177 | SUPPORTED_Pause | |
| 7178 | SUPPORTED_Asym_Pause), |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 7179 | .media_type = ETH_PHY_NOT_PRESENT, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7180 | .ver_addr = 0, |
| 7181 | .req_flow_ctrl = 0, |
| 7182 | .req_line_speed = 0, |
| 7183 | .speed_cap_mask = 0, |
| 7184 | .req_duplex = 0, |
| 7185 | .rsrv = 0, |
| 7186 | .config_init = (config_init_t)bnx2x_8726_config_init, |
| 7187 | .read_status = (read_status_t)bnx2x_8726_read_status, |
| 7188 | .link_reset = (link_reset_t)bnx2x_8726_link_reset, |
| 7189 | .config_loopback = (config_loopback_t)bnx2x_8726_config_loopback, |
| 7190 | .format_fw_ver = (format_fw_ver_t)bnx2x_format_ver, |
| 7191 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7192 | .set_link_led = (set_link_led_t)NULL, |
| 7193 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7194 | }; |
| 7195 | |
| 7196 | static struct bnx2x_phy phy_8727 = { |
| 7197 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727, |
| 7198 | .addr = 0xff, |
| 7199 | .flags = FLAGS_FAN_FAILURE_DET_REQ, |
| 7200 | .def_md_devad = 0, |
| 7201 | .reserved = 0, |
| 7202 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 7203 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 7204 | .mdio_ctrl = 0, |
| 7205 | .supported = (SUPPORTED_10000baseT_Full | |
| 7206 | SUPPORTED_1000baseT_Full | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7207 | SUPPORTED_FIBRE | |
| 7208 | SUPPORTED_Pause | |
| 7209 | SUPPORTED_Asym_Pause), |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 7210 | .media_type = ETH_PHY_NOT_PRESENT, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7211 | .ver_addr = 0, |
| 7212 | .req_flow_ctrl = 0, |
| 7213 | .req_line_speed = 0, |
| 7214 | .speed_cap_mask = 0, |
| 7215 | .req_duplex = 0, |
| 7216 | .rsrv = 0, |
| 7217 | .config_init = (config_init_t)bnx2x_8727_config_init, |
| 7218 | .read_status = (read_status_t)bnx2x_8727_read_status, |
| 7219 | .link_reset = (link_reset_t)bnx2x_8727_link_reset, |
| 7220 | .config_loopback = (config_loopback_t)NULL, |
| 7221 | .format_fw_ver = (format_fw_ver_t)bnx2x_format_ver, |
| 7222 | .hw_reset = (hw_reset_t)bnx2x_8727_hw_reset, |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 7223 | .set_link_led = (set_link_led_t)bnx2x_8727_set_link_led, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7224 | .phy_specific_func = (phy_specific_func_t)bnx2x_8727_specific_func |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7225 | }; |
| 7226 | static struct bnx2x_phy phy_8481 = { |
| 7227 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8481, |
| 7228 | .addr = 0xff, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7229 | .flags = FLAGS_FAN_FAILURE_DET_REQ | |
| 7230 | FLAGS_REARM_LATCH_SIGNAL, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7231 | .def_md_devad = 0, |
| 7232 | .reserved = 0, |
| 7233 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 7234 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 7235 | .mdio_ctrl = 0, |
| 7236 | .supported = (SUPPORTED_10baseT_Half | |
| 7237 | SUPPORTED_10baseT_Full | |
| 7238 | SUPPORTED_100baseT_Half | |
| 7239 | SUPPORTED_100baseT_Full | |
| 7240 | SUPPORTED_1000baseT_Full | |
| 7241 | SUPPORTED_10000baseT_Full | |
| 7242 | SUPPORTED_TP | |
| 7243 | SUPPORTED_Autoneg | |
| 7244 | SUPPORTED_Pause | |
| 7245 | SUPPORTED_Asym_Pause), |
| 7246 | .media_type = ETH_PHY_BASE_T, |
| 7247 | .ver_addr = 0, |
| 7248 | .req_flow_ctrl = 0, |
| 7249 | .req_line_speed = 0, |
| 7250 | .speed_cap_mask = 0, |
| 7251 | .req_duplex = 0, |
| 7252 | .rsrv = 0, |
| 7253 | .config_init = (config_init_t)bnx2x_8481_config_init, |
| 7254 | .read_status = (read_status_t)bnx2x_848xx_read_status, |
| 7255 | .link_reset = (link_reset_t)bnx2x_8481_link_reset, |
| 7256 | .config_loopback = (config_loopback_t)NULL, |
| 7257 | .format_fw_ver = (format_fw_ver_t)bnx2x_848xx_format_ver, |
| 7258 | .hw_reset = (hw_reset_t)bnx2x_8481_hw_reset, |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 7259 | .set_link_led = (set_link_led_t)bnx2x_848xx_set_link_led, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7260 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7261 | }; |
| 7262 | |
| 7263 | static struct bnx2x_phy phy_84823 = { |
| 7264 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84823, |
| 7265 | .addr = 0xff, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7266 | .flags = FLAGS_FAN_FAILURE_DET_REQ | |
| 7267 | FLAGS_REARM_LATCH_SIGNAL, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7268 | .def_md_devad = 0, |
| 7269 | .reserved = 0, |
| 7270 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 7271 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 7272 | .mdio_ctrl = 0, |
| 7273 | .supported = (SUPPORTED_10baseT_Half | |
| 7274 | SUPPORTED_10baseT_Full | |
| 7275 | SUPPORTED_100baseT_Half | |
| 7276 | SUPPORTED_100baseT_Full | |
| 7277 | SUPPORTED_1000baseT_Full | |
| 7278 | SUPPORTED_10000baseT_Full | |
| 7279 | SUPPORTED_TP | |
| 7280 | SUPPORTED_Autoneg | |
| 7281 | SUPPORTED_Pause | |
| 7282 | SUPPORTED_Asym_Pause), |
| 7283 | .media_type = ETH_PHY_BASE_T, |
| 7284 | .ver_addr = 0, |
| 7285 | .req_flow_ctrl = 0, |
| 7286 | .req_line_speed = 0, |
| 7287 | .speed_cap_mask = 0, |
| 7288 | .req_duplex = 0, |
| 7289 | .rsrv = 0, |
| 7290 | .config_init = (config_init_t)bnx2x_848x3_config_init, |
| 7291 | .read_status = (read_status_t)bnx2x_848xx_read_status, |
| 7292 | .link_reset = (link_reset_t)bnx2x_848x3_link_reset, |
| 7293 | .config_loopback = (config_loopback_t)NULL, |
| 7294 | .format_fw_ver = (format_fw_ver_t)bnx2x_848xx_format_ver, |
| 7295 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 7296 | .set_link_led = (set_link_led_t)bnx2x_848xx_set_link_led, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7297 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7298 | }; |
| 7299 | |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 7300 | static struct bnx2x_phy phy_84833 = { |
| 7301 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833, |
| 7302 | .addr = 0xff, |
| 7303 | .flags = FLAGS_FAN_FAILURE_DET_REQ | |
| 7304 | FLAGS_REARM_LATCH_SIGNAL, |
| 7305 | .def_md_devad = 0, |
| 7306 | .reserved = 0, |
| 7307 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 7308 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 7309 | .mdio_ctrl = 0, |
| 7310 | .supported = (SUPPORTED_10baseT_Half | |
| 7311 | SUPPORTED_10baseT_Full | |
| 7312 | SUPPORTED_100baseT_Half | |
| 7313 | SUPPORTED_100baseT_Full | |
| 7314 | SUPPORTED_1000baseT_Full | |
| 7315 | SUPPORTED_10000baseT_Full | |
| 7316 | SUPPORTED_TP | |
| 7317 | SUPPORTED_Autoneg | |
| 7318 | SUPPORTED_Pause | |
| 7319 | SUPPORTED_Asym_Pause), |
| 7320 | .media_type = ETH_PHY_BASE_T, |
| 7321 | .ver_addr = 0, |
| 7322 | .req_flow_ctrl = 0, |
| 7323 | .req_line_speed = 0, |
| 7324 | .speed_cap_mask = 0, |
| 7325 | .req_duplex = 0, |
| 7326 | .rsrv = 0, |
| 7327 | .config_init = (config_init_t)bnx2x_848x3_config_init, |
| 7328 | .read_status = (read_status_t)bnx2x_848xx_read_status, |
| 7329 | .link_reset = (link_reset_t)bnx2x_848x3_link_reset, |
| 7330 | .config_loopback = (config_loopback_t)NULL, |
| 7331 | .format_fw_ver = (format_fw_ver_t)bnx2x_848xx_format_ver, |
| 7332 | .hw_reset = (hw_reset_t)NULL, |
| 7333 | .set_link_led = (set_link_led_t)bnx2x_848xx_set_link_led, |
| 7334 | .phy_specific_func = (phy_specific_func_t)NULL |
| 7335 | }; |
| 7336 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7337 | /*****************************************************************/ |
| 7338 | /* */ |
| 7339 | /* Populate the phy according. Main function: bnx2x_populate_phy */ |
| 7340 | /* */ |
| 7341 | /*****************************************************************/ |
| 7342 | |
| 7343 | static void bnx2x_populate_preemphasis(struct bnx2x *bp, u32 shmem_base, |
| 7344 | struct bnx2x_phy *phy, u8 port, |
| 7345 | u8 phy_index) |
| 7346 | { |
| 7347 | /* Get the 4 lanes xgxs config rx and tx */ |
| 7348 | u32 rx = 0, tx = 0, i; |
| 7349 | for (i = 0; i < 2; i++) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7350 | /* |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7351 | * INT_PHY and EXT_PHY1 share the same value location in the |
| 7352 | * shmem. When num_phys is greater than 1, than this value |
| 7353 | * applies only to EXT_PHY1 |
| 7354 | */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7355 | if (phy_index == INT_PHY || phy_index == EXT_PHY1) { |
| 7356 | rx = REG_RD(bp, shmem_base + |
| 7357 | offsetof(struct shmem_region, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7358 | dev_info.port_hw_config[port].xgxs_config_rx[i<<1])); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7359 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7360 | tx = REG_RD(bp, shmem_base + |
| 7361 | offsetof(struct shmem_region, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7362 | dev_info.port_hw_config[port].xgxs_config_tx[i<<1])); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7363 | } else { |
| 7364 | rx = REG_RD(bp, shmem_base + |
| 7365 | offsetof(struct shmem_region, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7366 | dev_info.port_hw_config[port].xgxs_config2_rx[i<<1])); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7367 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7368 | tx = REG_RD(bp, shmem_base + |
| 7369 | offsetof(struct shmem_region, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7370 | dev_info.port_hw_config[port].xgxs_config2_rx[i<<1])); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7371 | } |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7372 | |
| 7373 | phy->rx_preemphasis[i << 1] = ((rx>>16) & 0xffff); |
| 7374 | phy->rx_preemphasis[(i << 1) + 1] = (rx & 0xffff); |
| 7375 | |
| 7376 | phy->tx_preemphasis[i << 1] = ((tx>>16) & 0xffff); |
| 7377 | phy->tx_preemphasis[(i << 1) + 1] = (tx & 0xffff); |
| 7378 | } |
| 7379 | } |
| 7380 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 7381 | static u32 bnx2x_get_ext_phy_config(struct bnx2x *bp, u32 shmem_base, |
| 7382 | u8 phy_index, u8 port) |
| 7383 | { |
| 7384 | u32 ext_phy_config = 0; |
| 7385 | switch (phy_index) { |
| 7386 | case EXT_PHY1: |
| 7387 | ext_phy_config = REG_RD(bp, shmem_base + |
| 7388 | offsetof(struct shmem_region, |
| 7389 | dev_info.port_hw_config[port].external_phy_config)); |
| 7390 | break; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7391 | case EXT_PHY2: |
| 7392 | ext_phy_config = REG_RD(bp, shmem_base + |
| 7393 | offsetof(struct shmem_region, |
| 7394 | dev_info.port_hw_config[port].external_phy_config2)); |
| 7395 | break; |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 7396 | default: |
| 7397 | DP(NETIF_MSG_LINK, "Invalid phy_index %d\n", phy_index); |
| 7398 | return -EINVAL; |
| 7399 | } |
| 7400 | |
| 7401 | return ext_phy_config; |
| 7402 | } |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 7403 | static int bnx2x_populate_int_phy(struct bnx2x *bp, u32 shmem_base, u8 port, |
| 7404 | struct bnx2x_phy *phy) |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7405 | { |
| 7406 | u32 phy_addr; |
| 7407 | u32 chip_id; |
| 7408 | u32 switch_cfg = (REG_RD(bp, shmem_base + |
| 7409 | offsetof(struct shmem_region, |
| 7410 | dev_info.port_feature_config[port].link_config)) & |
| 7411 | PORT_FEATURE_CONNECTED_SWITCH_MASK); |
| 7412 | chip_id = REG_RD(bp, MISC_REG_CHIP_NUM) << 16; |
| 7413 | switch (switch_cfg) { |
| 7414 | case SWITCH_CFG_1G: |
| 7415 | phy_addr = REG_RD(bp, |
| 7416 | NIG_REG_SERDES0_CTRL_PHY_ADDR + |
| 7417 | port * 0x10); |
| 7418 | *phy = phy_serdes; |
| 7419 | break; |
| 7420 | case SWITCH_CFG_10G: |
| 7421 | phy_addr = REG_RD(bp, |
| 7422 | NIG_REG_XGXS0_CTRL_PHY_ADDR + |
| 7423 | port * 0x18); |
| 7424 | *phy = phy_xgxs; |
| 7425 | break; |
| 7426 | default: |
| 7427 | DP(NETIF_MSG_LINK, "Invalid switch_cfg\n"); |
| 7428 | return -EINVAL; |
| 7429 | } |
| 7430 | phy->addr = (u8)phy_addr; |
| 7431 | phy->mdio_ctrl = bnx2x_get_emac_base(bp, |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 7432 | SHARED_HW_CFG_MDC_MDIO_ACCESS1_BOTH, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7433 | port); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 7434 | if (CHIP_IS_E2(bp)) |
| 7435 | phy->def_md_devad = E2_DEFAULT_PHY_DEV_ADDR; |
| 7436 | else |
| 7437 | phy->def_md_devad = DEFAULT_PHY_DEV_ADDR; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7438 | |
| 7439 | DP(NETIF_MSG_LINK, "Internal phy port=%d, addr=0x%x, mdio_ctl=0x%x\n", |
| 7440 | port, phy->addr, phy->mdio_ctrl); |
| 7441 | |
| 7442 | bnx2x_populate_preemphasis(bp, shmem_base, phy, port, INT_PHY); |
| 7443 | return 0; |
| 7444 | } |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 7445 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 7446 | static int bnx2x_populate_ext_phy(struct bnx2x *bp, |
| 7447 | u8 phy_index, |
| 7448 | u32 shmem_base, |
| 7449 | u32 shmem2_base, |
| 7450 | u8 port, |
| 7451 | struct bnx2x_phy *phy) |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 7452 | { |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 7453 | u32 ext_phy_config, phy_type, config2; |
| 7454 | u32 mdc_mdio_access = SHARED_HW_CFG_MDC_MDIO_ACCESS1_BOTH; |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 7455 | ext_phy_config = bnx2x_get_ext_phy_config(bp, shmem_base, |
| 7456 | phy_index, port); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7457 | phy_type = XGXS_EXT_PHY_TYPE(ext_phy_config); |
| 7458 | /* Select the phy type */ |
| 7459 | switch (phy_type) { |
| 7460 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073: |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 7461 | mdc_mdio_access = SHARED_HW_CFG_MDC_MDIO_ACCESS1_SWAPPED; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7462 | *phy = phy_8073; |
| 7463 | break; |
| 7464 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8705: |
| 7465 | *phy = phy_8705; |
| 7466 | break; |
| 7467 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8706: |
| 7468 | *phy = phy_8706; |
| 7469 | break; |
| 7470 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726: |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 7471 | mdc_mdio_access = SHARED_HW_CFG_MDC_MDIO_ACCESS1_EMAC1; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7472 | *phy = phy_8726; |
| 7473 | break; |
| 7474 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727_NOC: |
| 7475 | /* BCM8727_NOC => BCM8727 no over current */ |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 7476 | mdc_mdio_access = SHARED_HW_CFG_MDC_MDIO_ACCESS1_EMAC1; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7477 | *phy = phy_8727; |
| 7478 | phy->flags |= FLAGS_NOC; |
| 7479 | break; |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 7480 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8722: |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7481 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727: |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 7482 | mdc_mdio_access = SHARED_HW_CFG_MDC_MDIO_ACCESS1_EMAC1; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7483 | *phy = phy_8727; |
| 7484 | break; |
| 7485 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8481: |
| 7486 | *phy = phy_8481; |
| 7487 | break; |
| 7488 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84823: |
| 7489 | *phy = phy_84823; |
| 7490 | break; |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 7491 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833: |
| 7492 | *phy = phy_84833; |
| 7493 | break; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7494 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_SFX7101: |
| 7495 | *phy = phy_7101; |
| 7496 | break; |
| 7497 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_FAILURE: |
| 7498 | *phy = phy_null; |
| 7499 | return -EINVAL; |
| 7500 | default: |
| 7501 | *phy = phy_null; |
| 7502 | return 0; |
| 7503 | } |
| 7504 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 7505 | phy->addr = XGXS_EXT_PHY_ADDR(ext_phy_config); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7506 | bnx2x_populate_preemphasis(bp, shmem_base, phy, port, phy_index); |
Yaniv Rosner | 62b29a5 | 2010-09-07 11:40:58 +0000 | [diff] [blame] | 7507 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7508 | /* |
| 7509 | * The shmem address of the phy version is located on different |
| 7510 | * structures. In case this structure is too old, do not set |
| 7511 | * the address |
| 7512 | */ |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 7513 | config2 = REG_RD(bp, shmem_base + offsetof(struct shmem_region, |
| 7514 | dev_info.shared_hw_config.config2)); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7515 | if (phy_index == EXT_PHY1) { |
| 7516 | phy->ver_addr = shmem_base + offsetof(struct shmem_region, |
| 7517 | port_mb[port].ext_phy_fw_version); |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 7518 | |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7519 | /* Check specific mdc mdio settings */ |
| 7520 | if (config2 & SHARED_HW_CFG_MDC_MDIO_ACCESS1_MASK) |
| 7521 | mdc_mdio_access = config2 & |
| 7522 | SHARED_HW_CFG_MDC_MDIO_ACCESS1_MASK; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7523 | } else { |
| 7524 | u32 size = REG_RD(bp, shmem2_base); |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 7525 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7526 | if (size > |
| 7527 | offsetof(struct shmem2_region, ext_phy_fw_version2)) { |
| 7528 | phy->ver_addr = shmem2_base + |
| 7529 | offsetof(struct shmem2_region, |
| 7530 | ext_phy_fw_version2[port]); |
| 7531 | } |
| 7532 | /* Check specific mdc mdio settings */ |
| 7533 | if (config2 & SHARED_HW_CFG_MDC_MDIO_ACCESS2_MASK) |
| 7534 | mdc_mdio_access = (config2 & |
| 7535 | SHARED_HW_CFG_MDC_MDIO_ACCESS2_MASK) >> |
| 7536 | (SHARED_HW_CFG_MDC_MDIO_ACCESS2_SHIFT - |
| 7537 | SHARED_HW_CFG_MDC_MDIO_ACCESS1_SHIFT); |
| 7538 | } |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 7539 | phy->mdio_ctrl = bnx2x_get_emac_base(bp, mdc_mdio_access, port); |
| 7540 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7541 | /* |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 7542 | * In case mdc/mdio_access of the external phy is different than the |
| 7543 | * mdc/mdio access of the XGXS, a HW lock must be taken in each access |
| 7544 | * to prevent one port interfere with another port's CL45 operations. |
| 7545 | */ |
| 7546 | if (mdc_mdio_access != SHARED_HW_CFG_MDC_MDIO_ACCESS1_BOTH) |
| 7547 | phy->flags |= FLAGS_HW_LOCK_REQUIRED; |
| 7548 | DP(NETIF_MSG_LINK, "phy_type 0x%x port %d found in index %d\n", |
| 7549 | phy_type, port, phy_index); |
| 7550 | DP(NETIF_MSG_LINK, " addr=0x%x, mdio_ctl=0x%x\n", |
| 7551 | phy->addr, phy->mdio_ctrl); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 7552 | return 0; |
| 7553 | } |
| 7554 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 7555 | static int bnx2x_populate_phy(struct bnx2x *bp, u8 phy_index, u32 shmem_base, |
| 7556 | u32 shmem2_base, u8 port, struct bnx2x_phy *phy) |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 7557 | { |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 7558 | int status = 0; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7559 | phy->type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_NOT_CONN; |
| 7560 | if (phy_index == INT_PHY) |
| 7561 | return bnx2x_populate_int_phy(bp, shmem_base, port, phy); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7562 | status = bnx2x_populate_ext_phy(bp, phy_index, shmem_base, shmem2_base, |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 7563 | port, phy); |
| 7564 | return status; |
| 7565 | } |
| 7566 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7567 | static void bnx2x_phy_def_cfg(struct link_params *params, |
| 7568 | struct bnx2x_phy *phy, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7569 | u8 phy_index) |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7570 | { |
| 7571 | struct bnx2x *bp = params->bp; |
| 7572 | u32 link_config; |
| 7573 | /* Populate the default phy configuration for MF mode */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7574 | if (phy_index == EXT_PHY2) { |
| 7575 | link_config = REG_RD(bp, params->shmem_base + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7576 | offsetof(struct shmem_region, dev_info. |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7577 | port_feature_config[params->port].link_config2)); |
| 7578 | phy->speed_cap_mask = REG_RD(bp, params->shmem_base + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7579 | offsetof(struct shmem_region, |
| 7580 | dev_info. |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7581 | port_hw_config[params->port].speed_capability_mask2)); |
| 7582 | } else { |
| 7583 | link_config = REG_RD(bp, params->shmem_base + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7584 | offsetof(struct shmem_region, dev_info. |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7585 | port_feature_config[params->port].link_config)); |
| 7586 | phy->speed_cap_mask = REG_RD(bp, params->shmem_base + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7587 | offsetof(struct shmem_region, |
| 7588 | dev_info. |
| 7589 | port_hw_config[params->port].speed_capability_mask)); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7590 | } |
| 7591 | DP(NETIF_MSG_LINK, "Default config phy idx %x cfg 0x%x speed_cap_mask" |
| 7592 | " 0x%x\n", phy_index, link_config, phy->speed_cap_mask); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7593 | |
| 7594 | phy->req_duplex = DUPLEX_FULL; |
| 7595 | switch (link_config & PORT_FEATURE_LINK_SPEED_MASK) { |
| 7596 | case PORT_FEATURE_LINK_SPEED_10M_HALF: |
| 7597 | phy->req_duplex = DUPLEX_HALF; |
| 7598 | case PORT_FEATURE_LINK_SPEED_10M_FULL: |
| 7599 | phy->req_line_speed = SPEED_10; |
| 7600 | break; |
| 7601 | case PORT_FEATURE_LINK_SPEED_100M_HALF: |
| 7602 | phy->req_duplex = DUPLEX_HALF; |
| 7603 | case PORT_FEATURE_LINK_SPEED_100M_FULL: |
| 7604 | phy->req_line_speed = SPEED_100; |
| 7605 | break; |
| 7606 | case PORT_FEATURE_LINK_SPEED_1G: |
| 7607 | phy->req_line_speed = SPEED_1000; |
| 7608 | break; |
| 7609 | case PORT_FEATURE_LINK_SPEED_2_5G: |
| 7610 | phy->req_line_speed = SPEED_2500; |
| 7611 | break; |
| 7612 | case PORT_FEATURE_LINK_SPEED_10G_CX4: |
| 7613 | phy->req_line_speed = SPEED_10000; |
| 7614 | break; |
| 7615 | default: |
| 7616 | phy->req_line_speed = SPEED_AUTO_NEG; |
| 7617 | break; |
| 7618 | } |
| 7619 | |
| 7620 | switch (link_config & PORT_FEATURE_FLOW_CONTROL_MASK) { |
| 7621 | case PORT_FEATURE_FLOW_CONTROL_AUTO: |
| 7622 | phy->req_flow_ctrl = BNX2X_FLOW_CTRL_AUTO; |
| 7623 | break; |
| 7624 | case PORT_FEATURE_FLOW_CONTROL_TX: |
| 7625 | phy->req_flow_ctrl = BNX2X_FLOW_CTRL_TX; |
| 7626 | break; |
| 7627 | case PORT_FEATURE_FLOW_CONTROL_RX: |
| 7628 | phy->req_flow_ctrl = BNX2X_FLOW_CTRL_RX; |
| 7629 | break; |
| 7630 | case PORT_FEATURE_FLOW_CONTROL_BOTH: |
| 7631 | phy->req_flow_ctrl = BNX2X_FLOW_CTRL_BOTH; |
| 7632 | break; |
| 7633 | default: |
| 7634 | phy->req_flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 7635 | break; |
| 7636 | } |
| 7637 | } |
| 7638 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7639 | u32 bnx2x_phy_selection(struct link_params *params) |
| 7640 | { |
| 7641 | u32 phy_config_swapped, prio_cfg; |
| 7642 | u32 return_cfg = PORT_HW_CFG_PHY_SELECTION_HARDWARE_DEFAULT; |
| 7643 | |
| 7644 | phy_config_swapped = params->multi_phy_config & |
| 7645 | PORT_HW_CFG_PHY_SWAPPED_ENABLED; |
| 7646 | |
| 7647 | prio_cfg = params->multi_phy_config & |
| 7648 | PORT_HW_CFG_PHY_SELECTION_MASK; |
| 7649 | |
| 7650 | if (phy_config_swapped) { |
| 7651 | switch (prio_cfg) { |
| 7652 | case PORT_HW_CFG_PHY_SELECTION_FIRST_PHY_PRIORITY: |
| 7653 | return_cfg = PORT_HW_CFG_PHY_SELECTION_SECOND_PHY_PRIORITY; |
| 7654 | break; |
| 7655 | case PORT_HW_CFG_PHY_SELECTION_SECOND_PHY_PRIORITY: |
| 7656 | return_cfg = PORT_HW_CFG_PHY_SELECTION_FIRST_PHY_PRIORITY; |
| 7657 | break; |
| 7658 | case PORT_HW_CFG_PHY_SELECTION_SECOND_PHY: |
| 7659 | return_cfg = PORT_HW_CFG_PHY_SELECTION_FIRST_PHY; |
| 7660 | break; |
| 7661 | case PORT_HW_CFG_PHY_SELECTION_FIRST_PHY: |
| 7662 | return_cfg = PORT_HW_CFG_PHY_SELECTION_SECOND_PHY; |
| 7663 | break; |
| 7664 | } |
| 7665 | } else |
| 7666 | return_cfg = prio_cfg; |
| 7667 | |
| 7668 | return return_cfg; |
| 7669 | } |
| 7670 | |
| 7671 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 7672 | int bnx2x_phy_probe(struct link_params *params) |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7673 | { |
| 7674 | u8 phy_index, actual_phy_idx, link_cfg_idx; |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 7675 | u32 phy_config_swapped, sync_offset, media_types; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7676 | struct bnx2x *bp = params->bp; |
| 7677 | struct bnx2x_phy *phy; |
| 7678 | params->num_phys = 0; |
| 7679 | DP(NETIF_MSG_LINK, "Begin phy probe\n"); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7680 | phy_config_swapped = params->multi_phy_config & |
| 7681 | PORT_HW_CFG_PHY_SWAPPED_ENABLED; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7682 | |
| 7683 | for (phy_index = INT_PHY; phy_index < MAX_PHYS; |
| 7684 | phy_index++) { |
| 7685 | link_cfg_idx = LINK_CONFIG_IDX(phy_index); |
| 7686 | actual_phy_idx = phy_index; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7687 | if (phy_config_swapped) { |
| 7688 | if (phy_index == EXT_PHY1) |
| 7689 | actual_phy_idx = EXT_PHY2; |
| 7690 | else if (phy_index == EXT_PHY2) |
| 7691 | actual_phy_idx = EXT_PHY1; |
| 7692 | } |
| 7693 | DP(NETIF_MSG_LINK, "phy_config_swapped %x, phy_index %x," |
| 7694 | " actual_phy_idx %x\n", phy_config_swapped, |
| 7695 | phy_index, actual_phy_idx); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7696 | phy = ¶ms->phy[actual_phy_idx]; |
| 7697 | if (bnx2x_populate_phy(bp, phy_index, params->shmem_base, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7698 | params->shmem2_base, params->port, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7699 | phy) != 0) { |
| 7700 | params->num_phys = 0; |
| 7701 | DP(NETIF_MSG_LINK, "phy probe failed in phy index %d\n", |
| 7702 | phy_index); |
| 7703 | for (phy_index = INT_PHY; |
| 7704 | phy_index < MAX_PHYS; |
| 7705 | phy_index++) |
| 7706 | *phy = phy_null; |
| 7707 | return -EINVAL; |
| 7708 | } |
| 7709 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_NOT_CONN) |
| 7710 | break; |
| 7711 | |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 7712 | sync_offset = params->shmem_base + |
| 7713 | offsetof(struct shmem_region, |
| 7714 | dev_info.port_hw_config[params->port].media_type); |
| 7715 | media_types = REG_RD(bp, sync_offset); |
| 7716 | |
| 7717 | /* |
| 7718 | * Update media type for non-PMF sync only for the first time |
| 7719 | * In case the media type changes afterwards, it will be updated |
| 7720 | * using the update_status function |
| 7721 | */ |
| 7722 | if ((media_types & (PORT_HW_CFG_MEDIA_TYPE_PHY0_MASK << |
| 7723 | (PORT_HW_CFG_MEDIA_TYPE_PHY1_SHIFT * |
| 7724 | actual_phy_idx))) == 0) { |
| 7725 | media_types |= ((phy->media_type & |
| 7726 | PORT_HW_CFG_MEDIA_TYPE_PHY0_MASK) << |
| 7727 | (PORT_HW_CFG_MEDIA_TYPE_PHY1_SHIFT * |
| 7728 | actual_phy_idx)); |
| 7729 | } |
| 7730 | REG_WR(bp, sync_offset, media_types); |
| 7731 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7732 | bnx2x_phy_def_cfg(params, phy, phy_index); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7733 | params->num_phys++; |
| 7734 | } |
| 7735 | |
| 7736 | DP(NETIF_MSG_LINK, "End phy probe. #phys found %x\n", params->num_phys); |
| 7737 | return 0; |
| 7738 | } |
| 7739 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7740 | static void set_phy_vars(struct link_params *params) |
| 7741 | { |
| 7742 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7743 | u8 actual_phy_idx, phy_index, link_cfg_idx; |
| 7744 | u8 phy_config_swapped = params->multi_phy_config & |
| 7745 | PORT_HW_CFG_PHY_SWAPPED_ENABLED; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7746 | for (phy_index = INT_PHY; phy_index < params->num_phys; |
| 7747 | phy_index++) { |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7748 | link_cfg_idx = LINK_CONFIG_IDX(phy_index); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7749 | actual_phy_idx = phy_index; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7750 | if (phy_config_swapped) { |
| 7751 | if (phy_index == EXT_PHY1) |
| 7752 | actual_phy_idx = EXT_PHY2; |
| 7753 | else if (phy_index == EXT_PHY2) |
| 7754 | actual_phy_idx = EXT_PHY1; |
| 7755 | } |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7756 | params->phy[actual_phy_idx].req_flow_ctrl = |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7757 | params->req_flow_ctrl[link_cfg_idx]; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7758 | |
| 7759 | params->phy[actual_phy_idx].req_line_speed = |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7760 | params->req_line_speed[link_cfg_idx]; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7761 | |
| 7762 | params->phy[actual_phy_idx].speed_cap_mask = |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7763 | params->speed_cap_mask[link_cfg_idx]; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7764 | |
| 7765 | params->phy[actual_phy_idx].req_duplex = |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7766 | params->req_duplex[link_cfg_idx]; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7767 | |
| 7768 | DP(NETIF_MSG_LINK, "req_flow_ctrl %x, req_line_speed %x," |
| 7769 | " speed_cap_mask %x\n", |
| 7770 | params->phy[actual_phy_idx].req_flow_ctrl, |
| 7771 | params->phy[actual_phy_idx].req_line_speed, |
| 7772 | params->phy[actual_phy_idx].speed_cap_mask); |
| 7773 | } |
| 7774 | } |
| 7775 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 7776 | int bnx2x_phy_init(struct link_params *params, struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7777 | { |
| 7778 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7779 | DP(NETIF_MSG_LINK, "Phy Initialization started\n"); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7780 | DP(NETIF_MSG_LINK, "(1) req_speed %d, req_flowctrl %d\n", |
| 7781 | params->req_line_speed[0], params->req_flow_ctrl[0]); |
| 7782 | DP(NETIF_MSG_LINK, "(2) req_speed %d, req_flowctrl %d\n", |
| 7783 | params->req_line_speed[1], params->req_flow_ctrl[1]); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7784 | vars->link_status = 0; |
| 7785 | vars->phy_link_up = 0; |
| 7786 | vars->link_up = 0; |
| 7787 | vars->line_speed = 0; |
| 7788 | vars->duplex = DUPLEX_FULL; |
| 7789 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 7790 | vars->mac_type = MAC_TYPE_NONE; |
| 7791 | vars->phy_flags = 0; |
| 7792 | |
| 7793 | /* disable attentions */ |
| 7794 | bnx2x_bits_dis(bp, NIG_REG_MASK_INTERRUPT_PORT0 + params->port*4, |
| 7795 | (NIG_MASK_XGXS0_LINK_STATUS | |
| 7796 | NIG_MASK_XGXS0_LINK10G | |
| 7797 | NIG_MASK_SERDES0_LINK_STATUS | |
| 7798 | NIG_MASK_MI_INT)); |
| 7799 | |
| 7800 | bnx2x_emac_init(params, vars); |
| 7801 | |
| 7802 | if (params->num_phys == 0) { |
| 7803 | DP(NETIF_MSG_LINK, "No phy found for initialization !!\n"); |
| 7804 | return -EINVAL; |
| 7805 | } |
| 7806 | set_phy_vars(params); |
| 7807 | |
| 7808 | DP(NETIF_MSG_LINK, "Num of phys on board: %d\n", params->num_phys); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7809 | if (params->loopback_mode == LOOPBACK_BMAC) { |
| 7810 | |
| 7811 | vars->link_up = 1; |
| 7812 | vars->line_speed = SPEED_10000; |
| 7813 | vars->duplex = DUPLEX_FULL; |
| 7814 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 7815 | vars->mac_type = MAC_TYPE_BMAC; |
| 7816 | |
| 7817 | vars->phy_flags = PHY_XGXS_FLAG; |
| 7818 | |
| 7819 | bnx2x_xgxs_deassert(params); |
| 7820 | |
| 7821 | /* set bmac loopback */ |
| 7822 | bnx2x_bmac_enable(params, vars, 1); |
| 7823 | |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7824 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + params->port*4, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7825 | |
| 7826 | } else if (params->loopback_mode == LOOPBACK_EMAC) { |
| 7827 | |
| 7828 | vars->link_up = 1; |
| 7829 | vars->line_speed = SPEED_1000; |
| 7830 | vars->duplex = DUPLEX_FULL; |
| 7831 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 7832 | vars->mac_type = MAC_TYPE_EMAC; |
| 7833 | |
| 7834 | vars->phy_flags = PHY_XGXS_FLAG; |
| 7835 | |
| 7836 | bnx2x_xgxs_deassert(params); |
| 7837 | /* set bmac loopback */ |
| 7838 | bnx2x_emac_enable(params, vars, 1); |
| 7839 | bnx2x_emac_program(params, vars); |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7840 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + params->port*4, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7841 | |
| 7842 | } else if ((params->loopback_mode == LOOPBACK_XGXS) || |
| 7843 | (params->loopback_mode == LOOPBACK_EXT_PHY)) { |
| 7844 | |
| 7845 | vars->link_up = 1; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7846 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7847 | vars->duplex = DUPLEX_FULL; |
| 7848 | if (params->req_line_speed[0] == SPEED_1000) { |
| 7849 | vars->line_speed = SPEED_1000; |
| 7850 | vars->mac_type = MAC_TYPE_EMAC; |
| 7851 | } else { |
| 7852 | vars->line_speed = SPEED_10000; |
| 7853 | vars->mac_type = MAC_TYPE_BMAC; |
| 7854 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7855 | |
| 7856 | bnx2x_xgxs_deassert(params); |
| 7857 | bnx2x_link_initialize(params, vars); |
| 7858 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7859 | if (params->req_line_speed[0] == SPEED_1000) { |
| 7860 | bnx2x_emac_program(params, vars); |
| 7861 | bnx2x_emac_enable(params, vars, 0); |
| 7862 | } else |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7863 | bnx2x_bmac_enable(params, vars, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7864 | if (params->loopback_mode == LOOPBACK_XGXS) { |
| 7865 | /* set 10G XGXS loopback */ |
| 7866 | params->phy[INT_PHY].config_loopback( |
| 7867 | ¶ms->phy[INT_PHY], |
| 7868 | params); |
| 7869 | |
| 7870 | } else { |
| 7871 | /* set external phy loopback */ |
| 7872 | u8 phy_index; |
| 7873 | for (phy_index = EXT_PHY1; |
| 7874 | phy_index < params->num_phys; phy_index++) { |
| 7875 | if (params->phy[phy_index].config_loopback) |
| 7876 | params->phy[phy_index].config_loopback( |
| 7877 | ¶ms->phy[phy_index], |
| 7878 | params); |
| 7879 | } |
| 7880 | } |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7881 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + params->port*4, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7882 | |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 7883 | bnx2x_set_led(params, vars, |
| 7884 | LED_MODE_OPER, vars->line_speed); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7885 | } else |
| 7886 | /* No loopback */ |
| 7887 | { |
| 7888 | if (params->switch_cfg == SWITCH_CFG_10G) |
| 7889 | bnx2x_xgxs_deassert(params); |
| 7890 | else |
| 7891 | bnx2x_serdes_deassert(bp, params->port); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 7892 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7893 | bnx2x_link_initialize(params, vars); |
| 7894 | msleep(30); |
| 7895 | bnx2x_link_int_enable(params); |
| 7896 | } |
| 7897 | return 0; |
| 7898 | } |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 7899 | |
| 7900 | int bnx2x_link_reset(struct link_params *params, struct link_vars *vars, |
| 7901 | u8 reset_ext_phy) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7902 | { |
| 7903 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | cf1d972 | 2010-11-01 05:32:34 +0000 | [diff] [blame] | 7904 | u8 phy_index, port = params->port, clear_latch_ind = 0; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7905 | DP(NETIF_MSG_LINK, "Resetting the link of port %d\n", port); |
| 7906 | /* disable attentions */ |
| 7907 | vars->link_status = 0; |
| 7908 | bnx2x_update_mng(params, vars->link_status); |
| 7909 | bnx2x_bits_dis(bp, NIG_REG_MASK_INTERRUPT_PORT0 + port*4, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7910 | (NIG_MASK_XGXS0_LINK_STATUS | |
| 7911 | NIG_MASK_XGXS0_LINK10G | |
| 7912 | NIG_MASK_SERDES0_LINK_STATUS | |
| 7913 | NIG_MASK_MI_INT)); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7914 | |
| 7915 | /* activate nig drain */ |
| 7916 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + port*4, 1); |
| 7917 | |
| 7918 | /* disable nig egress interface */ |
| 7919 | REG_WR(bp, NIG_REG_BMAC0_OUT_EN + port*4, 0); |
| 7920 | REG_WR(bp, NIG_REG_EGRESS_EMAC0_OUT_EN + port*4, 0); |
| 7921 | |
| 7922 | /* Stop BigMac rx */ |
| 7923 | bnx2x_bmac_rx_disable(bp, port); |
| 7924 | |
| 7925 | /* disable emac */ |
| 7926 | REG_WR(bp, NIG_REG_NIG_EMAC0_EN + port*4, 0); |
| 7927 | |
| 7928 | msleep(10); |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 7929 | /* The PHY reset is controlled by GPIO 1 |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7930 | * Hold it as vars low |
| 7931 | */ |
| 7932 | /* clear link led */ |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 7933 | bnx2x_set_led(params, vars, LED_MODE_OFF, 0); |
| 7934 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7935 | if (reset_ext_phy) { |
| 7936 | for (phy_index = EXT_PHY1; phy_index < params->num_phys; |
| 7937 | phy_index++) { |
| 7938 | if (params->phy[phy_index].link_reset) |
| 7939 | params->phy[phy_index].link_reset( |
| 7940 | ¶ms->phy[phy_index], |
| 7941 | params); |
Yaniv Rosner | cf1d972 | 2010-11-01 05:32:34 +0000 | [diff] [blame] | 7942 | if (params->phy[phy_index].flags & |
| 7943 | FLAGS_REARM_LATCH_SIGNAL) |
| 7944 | clear_latch_ind = 1; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7945 | } |
| 7946 | } |
| 7947 | |
Yaniv Rosner | cf1d972 | 2010-11-01 05:32:34 +0000 | [diff] [blame] | 7948 | if (clear_latch_ind) { |
| 7949 | /* Clear latching indication */ |
| 7950 | bnx2x_rearm_latch_signal(bp, port, 0); |
| 7951 | bnx2x_bits_dis(bp, NIG_REG_LATCH_BC_0 + port*4, |
| 7952 | 1 << NIG_LATCH_BC_ENABLE_MI_INT); |
| 7953 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7954 | if (params->phy[INT_PHY].link_reset) |
| 7955 | params->phy[INT_PHY].link_reset( |
| 7956 | ¶ms->phy[INT_PHY], params); |
| 7957 | /* reset BigMac */ |
| 7958 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_CLEAR, |
| 7959 | (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << port)); |
| 7960 | |
| 7961 | /* disable nig ingress interface */ |
| 7962 | REG_WR(bp, NIG_REG_BMAC0_IN_EN + port*4, 0); |
| 7963 | REG_WR(bp, NIG_REG_EMAC0_IN_EN + port*4, 0); |
| 7964 | REG_WR(bp, NIG_REG_BMAC0_OUT_EN + port*4, 0); |
| 7965 | REG_WR(bp, NIG_REG_EGRESS_EMAC0_OUT_EN + port*4, 0); |
| 7966 | vars->link_up = 0; |
| 7967 | return 0; |
| 7968 | } |
| 7969 | |
| 7970 | /****************************************************************************/ |
| 7971 | /* Common function */ |
| 7972 | /****************************************************************************/ |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 7973 | static int bnx2x_8073_common_init_phy(struct bnx2x *bp, |
| 7974 | u32 shmem_base_path[], |
| 7975 | u32 shmem2_base_path[], u8 phy_index, |
| 7976 | u32 chip_id) |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 7977 | { |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 7978 | struct bnx2x_phy phy[PORT_MAX]; |
| 7979 | struct bnx2x_phy *phy_blk[PORT_MAX]; |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 7980 | u16 val; |
Yaniv Rosner | c8e64df | 2011-01-30 04:15:00 +0000 | [diff] [blame] | 7981 | s8 port = 0; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 7982 | s8 port_of_path = 0; |
Yaniv Rosner | c8e64df | 2011-01-30 04:15:00 +0000 | [diff] [blame] | 7983 | u32 swap_val, swap_override; |
| 7984 | swap_val = REG_RD(bp, NIG_REG_PORT_SWAP); |
| 7985 | swap_override = REG_RD(bp, NIG_REG_STRAP_OVERRIDE); |
| 7986 | port ^= (swap_val && swap_override); |
| 7987 | bnx2x_ext_phy_hw_reset(bp, port); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 7988 | /* PART1 - Reset both phys */ |
| 7989 | for (port = PORT_MAX - 1; port >= PORT_0; port--) { |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 7990 | u32 shmem_base, shmem2_base; |
| 7991 | /* In E2, same phy is using for port0 of the two paths */ |
| 7992 | if (CHIP_IS_E2(bp)) { |
| 7993 | shmem_base = shmem_base_path[port]; |
| 7994 | shmem2_base = shmem2_base_path[port]; |
| 7995 | port_of_path = 0; |
| 7996 | } else { |
| 7997 | shmem_base = shmem_base_path[0]; |
| 7998 | shmem2_base = shmem2_base_path[0]; |
| 7999 | port_of_path = port; |
| 8000 | } |
| 8001 | |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 8002 | /* Extract the ext phy address for the port */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8003 | if (bnx2x_populate_phy(bp, phy_index, shmem_base, shmem2_base, |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 8004 | port_of_path, &phy[port]) != |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 8005 | 0) { |
| 8006 | DP(NETIF_MSG_LINK, "populate_phy failed\n"); |
| 8007 | return -EINVAL; |
| 8008 | } |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 8009 | /* disable attentions */ |
Yaniv Rosner | 6a71bbe | 2010-11-01 05:32:31 +0000 | [diff] [blame] | 8010 | bnx2x_bits_dis(bp, NIG_REG_MASK_INTERRUPT_PORT0 + |
| 8011 | port_of_path*4, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8012 | (NIG_MASK_XGXS0_LINK_STATUS | |
| 8013 | NIG_MASK_XGXS0_LINK10G | |
| 8014 | NIG_MASK_SERDES0_LINK_STATUS | |
| 8015 | NIG_MASK_MI_INT)); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 8016 | |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 8017 | /* Need to take the phy out of low power mode in order |
| 8018 | to write to access its registers */ |
| 8019 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8020 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, |
| 8021 | port); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 8022 | |
| 8023 | /* Reset the phy */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 8024 | bnx2x_cl45_write(bp, &phy[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8025 | MDIO_PMA_DEVAD, |
| 8026 | MDIO_PMA_REG_CTRL, |
| 8027 | 1<<15); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 8028 | } |
| 8029 | |
| 8030 | /* Add delay of 150ms after reset */ |
| 8031 | msleep(150); |
| 8032 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 8033 | if (phy[PORT_0].addr & 0x1) { |
| 8034 | phy_blk[PORT_0] = &(phy[PORT_1]); |
| 8035 | phy_blk[PORT_1] = &(phy[PORT_0]); |
| 8036 | } else { |
| 8037 | phy_blk[PORT_0] = &(phy[PORT_0]); |
| 8038 | phy_blk[PORT_1] = &(phy[PORT_1]); |
| 8039 | } |
| 8040 | |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 8041 | /* PART2 - Download firmware to both phys */ |
| 8042 | for (port = PORT_MAX - 1; port >= PORT_0; port--) { |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 8043 | if (CHIP_IS_E2(bp)) |
| 8044 | port_of_path = 0; |
| 8045 | else |
| 8046 | port_of_path = port; |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 8047 | |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 8048 | DP(NETIF_MSG_LINK, "Loading spirom for phy address 0x%x\n", |
| 8049 | phy_blk[port]->addr); |
Yaniv Rosner | 5c99274b | 2011-01-18 04:33:36 +0000 | [diff] [blame] | 8050 | if (bnx2x_8073_8727_external_rom_boot(bp, phy_blk[port], |
| 8051 | port_of_path)) |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 8052 | return -EINVAL; |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 8053 | |
| 8054 | /* Only set bit 10 = 1 (Tx power down) */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 8055 | bnx2x_cl45_read(bp, phy_blk[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8056 | MDIO_PMA_DEVAD, |
| 8057 | MDIO_PMA_REG_TX_POWER_DOWN, &val); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 8058 | |
| 8059 | /* Phase1 of TX_POWER_DOWN reset */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 8060 | bnx2x_cl45_write(bp, phy_blk[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8061 | MDIO_PMA_DEVAD, |
| 8062 | MDIO_PMA_REG_TX_POWER_DOWN, |
| 8063 | (val | 1<<10)); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 8064 | } |
| 8065 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8066 | /* |
| 8067 | * Toggle Transmitter: Power down and then up with 600ms delay |
| 8068 | * between |
| 8069 | */ |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 8070 | msleep(600); |
| 8071 | |
| 8072 | /* PART3 - complete TX_POWER_DOWN process, and set GPIO2 back to low */ |
| 8073 | for (port = PORT_MAX - 1; port >= PORT_0; port--) { |
Eilon Greenstein | f537225 | 2009-02-12 08:38:30 +0000 | [diff] [blame] | 8074 | /* Phase2 of POWER_DOWN_RESET */ |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 8075 | /* Release bit 10 (Release Tx power down) */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 8076 | bnx2x_cl45_read(bp, phy_blk[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8077 | MDIO_PMA_DEVAD, |
| 8078 | MDIO_PMA_REG_TX_POWER_DOWN, &val); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 8079 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 8080 | bnx2x_cl45_write(bp, phy_blk[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8081 | MDIO_PMA_DEVAD, |
| 8082 | MDIO_PMA_REG_TX_POWER_DOWN, (val & (~(1<<10)))); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 8083 | msleep(15); |
| 8084 | |
| 8085 | /* Read modify write the SPI-ROM version select register */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 8086 | bnx2x_cl45_read(bp, phy_blk[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8087 | MDIO_PMA_DEVAD, |
| 8088 | MDIO_PMA_REG_EDC_FFE_MAIN, &val); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 8089 | bnx2x_cl45_write(bp, phy_blk[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8090 | MDIO_PMA_DEVAD, |
| 8091 | MDIO_PMA_REG_EDC_FFE_MAIN, (val | (1<<12))); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 8092 | |
| 8093 | /* set GPIO2 back to LOW */ |
| 8094 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8095 | MISC_REGISTERS_GPIO_OUTPUT_LOW, port); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 8096 | } |
| 8097 | return 0; |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 8098 | } |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 8099 | static int bnx2x_8726_common_init_phy(struct bnx2x *bp, |
| 8100 | u32 shmem_base_path[], |
| 8101 | u32 shmem2_base_path[], u8 phy_index, |
| 8102 | u32 chip_id) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8103 | { |
| 8104 | u32 val; |
| 8105 | s8 port; |
| 8106 | struct bnx2x_phy phy; |
| 8107 | /* Use port1 because of the static port-swap */ |
| 8108 | /* Enable the module detection interrupt */ |
| 8109 | val = REG_RD(bp, MISC_REG_GPIO_EVENT_EN); |
| 8110 | val |= ((1<<MISC_REGISTERS_GPIO_3)| |
| 8111 | (1<<(MISC_REGISTERS_GPIO_3 + MISC_REGISTERS_GPIO_PORT_SHIFT))); |
| 8112 | REG_WR(bp, MISC_REG_GPIO_EVENT_EN, val); |
| 8113 | |
Yaniv Rosner | 650154b | 2010-11-01 05:32:36 +0000 | [diff] [blame] | 8114 | bnx2x_ext_phy_hw_reset(bp, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8115 | msleep(5); |
| 8116 | for (port = 0; port < PORT_MAX; port++) { |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 8117 | u32 shmem_base, shmem2_base; |
| 8118 | |
| 8119 | /* In E2, same phy is using for port0 of the two paths */ |
| 8120 | if (CHIP_IS_E2(bp)) { |
| 8121 | shmem_base = shmem_base_path[port]; |
| 8122 | shmem2_base = shmem2_base_path[port]; |
| 8123 | } else { |
| 8124 | shmem_base = shmem_base_path[0]; |
| 8125 | shmem2_base = shmem2_base_path[0]; |
| 8126 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8127 | /* Extract the ext phy address for the port */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8128 | if (bnx2x_populate_phy(bp, phy_index, shmem_base, shmem2_base, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8129 | port, &phy) != |
| 8130 | 0) { |
| 8131 | DP(NETIF_MSG_LINK, "populate phy failed\n"); |
| 8132 | return -EINVAL; |
| 8133 | } |
| 8134 | |
| 8135 | /* Reset phy*/ |
| 8136 | bnx2x_cl45_write(bp, &phy, |
| 8137 | MDIO_PMA_DEVAD, MDIO_PMA_REG_GEN_CTRL, 0x0001); |
| 8138 | |
| 8139 | |
| 8140 | /* Set fault module detected LED on */ |
| 8141 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_0, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8142 | MISC_REGISTERS_GPIO_HIGH, |
| 8143 | port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8144 | } |
| 8145 | |
| 8146 | return 0; |
| 8147 | } |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8148 | static void bnx2x_get_ext_phy_reset_gpio(struct bnx2x *bp, u32 shmem_base, |
| 8149 | u8 *io_gpio, u8 *io_port) |
| 8150 | { |
| 8151 | |
| 8152 | u32 phy_gpio_reset = REG_RD(bp, shmem_base + |
| 8153 | offsetof(struct shmem_region, |
| 8154 | dev_info.port_hw_config[PORT_0].default_cfg)); |
| 8155 | switch (phy_gpio_reset) { |
| 8156 | case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO0_P0: |
| 8157 | *io_gpio = 0; |
| 8158 | *io_port = 0; |
| 8159 | break; |
| 8160 | case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO1_P0: |
| 8161 | *io_gpio = 1; |
| 8162 | *io_port = 0; |
| 8163 | break; |
| 8164 | case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO2_P0: |
| 8165 | *io_gpio = 2; |
| 8166 | *io_port = 0; |
| 8167 | break; |
| 8168 | case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO3_P0: |
| 8169 | *io_gpio = 3; |
| 8170 | *io_port = 0; |
| 8171 | break; |
| 8172 | case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO0_P1: |
| 8173 | *io_gpio = 0; |
| 8174 | *io_port = 1; |
| 8175 | break; |
| 8176 | case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO1_P1: |
| 8177 | *io_gpio = 1; |
| 8178 | *io_port = 1; |
| 8179 | break; |
| 8180 | case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO2_P1: |
| 8181 | *io_gpio = 2; |
| 8182 | *io_port = 1; |
| 8183 | break; |
| 8184 | case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO3_P1: |
| 8185 | *io_gpio = 3; |
| 8186 | *io_port = 1; |
| 8187 | break; |
| 8188 | default: |
| 8189 | /* Don't override the io_gpio and io_port */ |
| 8190 | break; |
| 8191 | } |
| 8192 | } |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 8193 | |
| 8194 | static int bnx2x_8727_common_init_phy(struct bnx2x *bp, |
| 8195 | u32 shmem_base_path[], |
| 8196 | u32 shmem2_base_path[], u8 phy_index, |
| 8197 | u32 chip_id) |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 8198 | { |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8199 | s8 port, reset_gpio; |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 8200 | u32 swap_val, swap_override; |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 8201 | struct bnx2x_phy phy[PORT_MAX]; |
| 8202 | struct bnx2x_phy *phy_blk[PORT_MAX]; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 8203 | s8 port_of_path; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8204 | swap_val = REG_RD(bp, NIG_REG_PORT_SWAP); |
| 8205 | swap_override = REG_RD(bp, NIG_REG_STRAP_OVERRIDE); |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 8206 | |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8207 | reset_gpio = MISC_REGISTERS_GPIO_1; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8208 | port = 1; |
| 8209 | |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8210 | /* |
| 8211 | * Retrieve the reset gpio/port which control the reset. |
| 8212 | * Default is GPIO1, PORT1 |
| 8213 | */ |
| 8214 | bnx2x_get_ext_phy_reset_gpio(bp, shmem_base_path[0], |
| 8215 | (u8 *)&reset_gpio, (u8 *)&port); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8216 | |
| 8217 | /* Calculate the port based on port swap */ |
| 8218 | port ^= (swap_val && swap_override); |
| 8219 | |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8220 | /* Initiate PHY reset*/ |
| 8221 | bnx2x_set_gpio(bp, reset_gpio, MISC_REGISTERS_GPIO_OUTPUT_LOW, |
| 8222 | port); |
| 8223 | msleep(1); |
| 8224 | bnx2x_set_gpio(bp, reset_gpio, MISC_REGISTERS_GPIO_OUTPUT_HIGH, |
| 8225 | port); |
| 8226 | |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 8227 | msleep(5); |
| 8228 | |
| 8229 | /* PART1 - Reset both phys */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8230 | for (port = PORT_MAX - 1; port >= PORT_0; port--) { |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 8231 | u32 shmem_base, shmem2_base; |
| 8232 | |
| 8233 | /* In E2, same phy is using for port0 of the two paths */ |
| 8234 | if (CHIP_IS_E2(bp)) { |
| 8235 | shmem_base = shmem_base_path[port]; |
| 8236 | shmem2_base = shmem2_base_path[port]; |
| 8237 | port_of_path = 0; |
| 8238 | } else { |
| 8239 | shmem_base = shmem_base_path[0]; |
| 8240 | shmem2_base = shmem2_base_path[0]; |
| 8241 | port_of_path = port; |
| 8242 | } |
| 8243 | |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 8244 | /* Extract the ext phy address for the port */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8245 | if (bnx2x_populate_phy(bp, phy_index, shmem_base, shmem2_base, |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 8246 | port_of_path, &phy[port]) != |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 8247 | 0) { |
| 8248 | DP(NETIF_MSG_LINK, "populate phy failed\n"); |
| 8249 | return -EINVAL; |
| 8250 | } |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 8251 | /* disable attentions */ |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 8252 | bnx2x_bits_dis(bp, NIG_REG_MASK_INTERRUPT_PORT0 + |
| 8253 | port_of_path*4, |
| 8254 | (NIG_MASK_XGXS0_LINK_STATUS | |
| 8255 | NIG_MASK_XGXS0_LINK10G | |
| 8256 | NIG_MASK_SERDES0_LINK_STATUS | |
| 8257 | NIG_MASK_MI_INT)); |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 8258 | |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 8259 | |
| 8260 | /* Reset the phy */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 8261 | bnx2x_cl45_write(bp, &phy[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8262 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 1<<15); |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 8263 | } |
| 8264 | |
| 8265 | /* Add delay of 150ms after reset */ |
| 8266 | msleep(150); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 8267 | if (phy[PORT_0].addr & 0x1) { |
| 8268 | phy_blk[PORT_0] = &(phy[PORT_1]); |
| 8269 | phy_blk[PORT_1] = &(phy[PORT_0]); |
| 8270 | } else { |
| 8271 | phy_blk[PORT_0] = &(phy[PORT_0]); |
| 8272 | phy_blk[PORT_1] = &(phy[PORT_1]); |
| 8273 | } |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 8274 | /* PART2 - Download firmware to both phys */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 8275 | for (port = PORT_MAX - 1; port >= PORT_0; port--) { |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8276 | if (CHIP_IS_E2(bp)) |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 8277 | port_of_path = 0; |
| 8278 | else |
| 8279 | port_of_path = port; |
| 8280 | DP(NETIF_MSG_LINK, "Loading spirom for phy address 0x%x\n", |
| 8281 | phy_blk[port]->addr); |
Yaniv Rosner | 5c99274b | 2011-01-18 04:33:36 +0000 | [diff] [blame] | 8282 | if (bnx2x_8073_8727_external_rom_boot(bp, phy_blk[port], |
| 8283 | port_of_path)) |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 8284 | return -EINVAL; |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 8285 | |
Yaniv Rosner | 5c99274b | 2011-01-18 04:33:36 +0000 | [diff] [blame] | 8286 | } |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 8287 | return 0; |
| 8288 | } |
| 8289 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 8290 | static int bnx2x_ext_phy_common_init(struct bnx2x *bp, u32 shmem_base_path[], |
| 8291 | u32 shmem2_base_path[], u8 phy_index, |
| 8292 | u32 ext_phy_type, u32 chip_id) |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 8293 | { |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 8294 | int rc = 0; |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 8295 | |
| 8296 | switch (ext_phy_type) { |
| 8297 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073: |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 8298 | rc = bnx2x_8073_common_init_phy(bp, shmem_base_path, |
| 8299 | shmem2_base_path, |
| 8300 | phy_index, chip_id); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 8301 | break; |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 8302 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8722: |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 8303 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727: |
| 8304 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727_NOC: |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 8305 | rc = bnx2x_8727_common_init_phy(bp, shmem_base_path, |
| 8306 | shmem2_base_path, |
| 8307 | phy_index, chip_id); |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 8308 | break; |
| 8309 | |
Eilon Greenstein | 589abe3 | 2009-02-12 08:36:55 +0000 | [diff] [blame] | 8310 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726: |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8311 | /* |
| 8312 | * GPIO1 affects both ports, so there's need to pull |
| 8313 | * it for single port alone |
| 8314 | */ |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 8315 | rc = bnx2x_8726_common_init_phy(bp, shmem_base_path, |
| 8316 | shmem2_base_path, |
| 8317 | phy_index, chip_id); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8318 | break; |
| 8319 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_FAILURE: |
| 8320 | rc = -EINVAL; |
Yaniv Rosner | 4f60dab | 2009-11-05 19:18:23 +0200 | [diff] [blame] | 8321 | break; |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 8322 | default: |
| 8323 | DP(NETIF_MSG_LINK, |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8324 | "ext_phy 0x%x common init not required\n", |
| 8325 | ext_phy_type); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 8326 | break; |
| 8327 | } |
| 8328 | |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 8329 | if (rc != 0) |
| 8330 | netdev_err(bp->dev, "Warning: PHY was not initialized," |
| 8331 | " Port %d\n", |
| 8332 | 0); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 8333 | return rc; |
| 8334 | } |
| 8335 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 8336 | int bnx2x_common_init_phy(struct bnx2x *bp, u32 shmem_base_path[], |
| 8337 | u32 shmem2_base_path[], u32 chip_id) |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8338 | { |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 8339 | int rc = 0; |
Yaniv Rosner | b21a342 | 2011-01-18 04:33:24 +0000 | [diff] [blame] | 8340 | u32 phy_ver; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8341 | u8 phy_index; |
| 8342 | u32 ext_phy_type, ext_phy_config; |
| 8343 | DP(NETIF_MSG_LINK, "Begin common phy init\n"); |
Yaniv Rosner | d90d96b | 2010-09-07 11:41:04 +0000 | [diff] [blame] | 8344 | |
Yaniv Rosner | b21a342 | 2011-01-18 04:33:24 +0000 | [diff] [blame] | 8345 | /* Check if common init was already done */ |
| 8346 | phy_ver = REG_RD(bp, shmem_base_path[0] + |
| 8347 | offsetof(struct shmem_region, |
| 8348 | port_mb[PORT_0].ext_phy_fw_version)); |
| 8349 | if (phy_ver) { |
| 8350 | DP(NETIF_MSG_LINK, "Not doing common init; phy ver is 0x%x\n", |
| 8351 | phy_ver); |
| 8352 | return 0; |
| 8353 | } |
| 8354 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8355 | /* Read the ext_phy_type for arbitrary port(0) */ |
| 8356 | for (phy_index = EXT_PHY1; phy_index < MAX_PHYS; |
| 8357 | phy_index++) { |
| 8358 | ext_phy_config = bnx2x_get_ext_phy_config(bp, |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 8359 | shmem_base_path[0], |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8360 | phy_index, 0); |
| 8361 | ext_phy_type = XGXS_EXT_PHY_TYPE(ext_phy_config); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 8362 | rc |= bnx2x_ext_phy_common_init(bp, shmem_base_path, |
| 8363 | shmem2_base_path, |
| 8364 | phy_index, ext_phy_type, |
| 8365 | chip_id); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8366 | } |
| 8367 | return rc; |
| 8368 | } |
| 8369 | |
| 8370 | 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] | 8371 | { |
| 8372 | u8 phy_index; |
| 8373 | struct bnx2x_phy phy; |
| 8374 | for (phy_index = INT_PHY; phy_index < MAX_PHYS; |
| 8375 | phy_index++) { |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8376 | if (bnx2x_populate_phy(bp, phy_index, shmem_base, shmem2_base, |
Yaniv Rosner | d90d96b | 2010-09-07 11:41:04 +0000 | [diff] [blame] | 8377 | 0, &phy) != 0) { |
| 8378 | DP(NETIF_MSG_LINK, "populate phy failed\n"); |
| 8379 | return 0; |
| 8380 | } |
| 8381 | |
| 8382 | if (phy.flags & FLAGS_HW_LOCK_REQUIRED) |
| 8383 | return 1; |
| 8384 | } |
| 8385 | return 0; |
| 8386 | } |
| 8387 | |
| 8388 | u8 bnx2x_fan_failure_det_req(struct bnx2x *bp, |
| 8389 | u32 shmem_base, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8390 | u32 shmem2_base, |
Yaniv Rosner | d90d96b | 2010-09-07 11:41:04 +0000 | [diff] [blame] | 8391 | u8 port) |
| 8392 | { |
| 8393 | u8 phy_index, fan_failure_det_req = 0; |
| 8394 | struct bnx2x_phy phy; |
| 8395 | for (phy_index = EXT_PHY1; phy_index < MAX_PHYS; |
| 8396 | phy_index++) { |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8397 | if (bnx2x_populate_phy(bp, phy_index, shmem_base, shmem2_base, |
Yaniv Rosner | d90d96b | 2010-09-07 11:41:04 +0000 | [diff] [blame] | 8398 | port, &phy) |
| 8399 | != 0) { |
| 8400 | DP(NETIF_MSG_LINK, "populate phy failed\n"); |
| 8401 | return 0; |
| 8402 | } |
| 8403 | fan_failure_det_req |= (phy.flags & |
| 8404 | FLAGS_FAN_FAILURE_DET_REQ); |
| 8405 | } |
| 8406 | return fan_failure_det_req; |
| 8407 | } |
| 8408 | |
| 8409 | void bnx2x_hw_reset_phy(struct link_params *params) |
| 8410 | { |
| 8411 | u8 phy_index; |
| 8412 | for (phy_index = EXT_PHY1; phy_index < MAX_PHYS; |
| 8413 | phy_index++) { |
| 8414 | if (params->phy[phy_index].hw_reset) { |
| 8415 | params->phy[phy_index].hw_reset( |
| 8416 | ¶ms->phy[phy_index], |
| 8417 | params); |
| 8418 | params->phy[phy_index] = phy_null; |
| 8419 | } |
| 8420 | } |
| 8421 | } |