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, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 512 | struct link_vars *vars, u8 lb) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 513 | { |
| 514 | struct bnx2x *bp = params->bp; |
| 515 | u8 port = params->port; |
| 516 | u32 emac_base = port ? GRCBASE_EMAC1 : GRCBASE_EMAC0; |
| 517 | u32 val; |
| 518 | |
| 519 | DP(NETIF_MSG_LINK, "enabling EMAC\n"); |
| 520 | |
| 521 | /* enable emac and not bmac */ |
| 522 | REG_WR(bp, NIG_REG_EGRESS_EMAC0_PORT + port*4, 1); |
| 523 | |
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 | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 1616 | static void bnx2x_calc_ieee_aneg_adv(struct bnx2x_phy *phy, |
| 1617 | struct link_params *params, u16 *ieee_fc) |
| 1618 | { |
| 1619 | struct bnx2x *bp = params->bp; |
| 1620 | *ieee_fc = MDIO_COMBO_IEEE0_AUTO_NEG_ADV_FULL_DUPLEX; |
| 1621 | /** |
| 1622 | * resolve pause mode and advertisement Please refer to Table |
| 1623 | * 28B-3 of the 802.3ab-1999 spec |
| 1624 | */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 1625 | |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 1626 | switch (phy->req_flow_ctrl) { |
| 1627 | case BNX2X_FLOW_CTRL_AUTO: |
| 1628 | if (params->req_fc_auto_adv == BNX2X_FLOW_CTRL_BOTH) |
| 1629 | *ieee_fc |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH; |
| 1630 | else |
| 1631 | *ieee_fc |= |
| 1632 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC; |
| 1633 | break; |
| 1634 | |
| 1635 | case BNX2X_FLOW_CTRL_TX: |
| 1636 | *ieee_fc |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC; |
| 1637 | break; |
| 1638 | |
| 1639 | case BNX2X_FLOW_CTRL_RX: |
| 1640 | case BNX2X_FLOW_CTRL_BOTH: |
| 1641 | *ieee_fc |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH; |
| 1642 | break; |
| 1643 | |
| 1644 | case BNX2X_FLOW_CTRL_NONE: |
| 1645 | default: |
| 1646 | *ieee_fc |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_NONE; |
| 1647 | break; |
| 1648 | } |
| 1649 | DP(NETIF_MSG_LINK, "ieee_fc = 0x%x\n", *ieee_fc); |
| 1650 | } |
| 1651 | |
| 1652 | static void set_phy_vars(struct link_params *params, |
| 1653 | struct link_vars *vars) |
| 1654 | { |
| 1655 | struct bnx2x *bp = params->bp; |
| 1656 | u8 actual_phy_idx, phy_index, link_cfg_idx; |
| 1657 | u8 phy_config_swapped = params->multi_phy_config & |
| 1658 | PORT_HW_CFG_PHY_SWAPPED_ENABLED; |
| 1659 | for (phy_index = INT_PHY; phy_index < params->num_phys; |
| 1660 | phy_index++) { |
| 1661 | link_cfg_idx = LINK_CONFIG_IDX(phy_index); |
| 1662 | actual_phy_idx = phy_index; |
| 1663 | if (phy_config_swapped) { |
| 1664 | if (phy_index == EXT_PHY1) |
| 1665 | actual_phy_idx = EXT_PHY2; |
| 1666 | else if (phy_index == EXT_PHY2) |
| 1667 | actual_phy_idx = EXT_PHY1; |
| 1668 | } |
| 1669 | params->phy[actual_phy_idx].req_flow_ctrl = |
| 1670 | params->req_flow_ctrl[link_cfg_idx]; |
| 1671 | |
| 1672 | params->phy[actual_phy_idx].req_line_speed = |
| 1673 | params->req_line_speed[link_cfg_idx]; |
| 1674 | |
| 1675 | params->phy[actual_phy_idx].speed_cap_mask = |
| 1676 | params->speed_cap_mask[link_cfg_idx]; |
| 1677 | |
| 1678 | params->phy[actual_phy_idx].req_duplex = |
| 1679 | params->req_duplex[link_cfg_idx]; |
| 1680 | |
| 1681 | if (params->req_line_speed[link_cfg_idx] == |
| 1682 | SPEED_AUTO_NEG) |
| 1683 | vars->link_status |= LINK_STATUS_AUTO_NEGOTIATE_ENABLED; |
| 1684 | |
| 1685 | DP(NETIF_MSG_LINK, "req_flow_ctrl %x, req_line_speed %x," |
| 1686 | " speed_cap_mask %x\n", |
| 1687 | params->phy[actual_phy_idx].req_flow_ctrl, |
| 1688 | params->phy[actual_phy_idx].req_line_speed, |
| 1689 | params->phy[actual_phy_idx].speed_cap_mask); |
| 1690 | } |
| 1691 | } |
| 1692 | |
| 1693 | static void bnx2x_ext_phy_set_pause(struct link_params *params, |
| 1694 | struct bnx2x_phy *phy, |
| 1695 | struct link_vars *vars) |
| 1696 | { |
| 1697 | u16 val; |
| 1698 | struct bnx2x *bp = params->bp; |
| 1699 | /* read modify write pause advertizing */ |
| 1700 | bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_ADV_PAUSE, &val); |
| 1701 | |
| 1702 | val &= ~MDIO_AN_REG_ADV_PAUSE_BOTH; |
| 1703 | |
| 1704 | /* Please refer to Table 28B-3 of 802.3ab-1999 spec. */ |
| 1705 | bnx2x_calc_ieee_aneg_adv(phy, params, &vars->ieee_fc); |
| 1706 | if ((vars->ieee_fc & |
| 1707 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC) == |
| 1708 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC) { |
| 1709 | val |= MDIO_AN_REG_ADV_PAUSE_ASYMMETRIC; |
| 1710 | } |
| 1711 | if ((vars->ieee_fc & |
| 1712 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) == |
| 1713 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) { |
| 1714 | val |= MDIO_AN_REG_ADV_PAUSE_PAUSE; |
| 1715 | } |
| 1716 | DP(NETIF_MSG_LINK, "Ext phy AN advertize 0x%x\n", val); |
| 1717 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_ADV_PAUSE, val); |
| 1718 | } |
| 1719 | |
| 1720 | static void bnx2x_pause_resolve(struct link_vars *vars, u32 pause_result) |
| 1721 | { /* LD LP */ |
| 1722 | switch (pause_result) { /* ASYM P ASYM P */ |
| 1723 | case 0xb: /* 1 0 1 1 */ |
| 1724 | vars->flow_ctrl = BNX2X_FLOW_CTRL_TX; |
| 1725 | break; |
| 1726 | |
| 1727 | case 0xe: /* 1 1 1 0 */ |
| 1728 | vars->flow_ctrl = BNX2X_FLOW_CTRL_RX; |
| 1729 | break; |
| 1730 | |
| 1731 | case 0x5: /* 0 1 0 1 */ |
| 1732 | case 0x7: /* 0 1 1 1 */ |
| 1733 | case 0xd: /* 1 1 0 1 */ |
| 1734 | case 0xf: /* 1 1 1 1 */ |
| 1735 | vars->flow_ctrl = BNX2X_FLOW_CTRL_BOTH; |
| 1736 | break; |
| 1737 | |
| 1738 | default: |
| 1739 | break; |
| 1740 | } |
| 1741 | if (pause_result & (1<<0)) |
| 1742 | vars->link_status |= LINK_STATUS_LINK_PARTNER_SYMMETRIC_PAUSE; |
| 1743 | if (pause_result & (1<<1)) |
| 1744 | vars->link_status |= LINK_STATUS_LINK_PARTNER_ASYMMETRIC_PAUSE; |
| 1745 | } |
| 1746 | |
| 1747 | static u8 bnx2x_ext_phy_resolve_fc(struct bnx2x_phy *phy, |
| 1748 | struct link_params *params, |
| 1749 | struct link_vars *vars) |
| 1750 | { |
| 1751 | struct bnx2x *bp = params->bp; |
| 1752 | u16 ld_pause; /* local */ |
| 1753 | u16 lp_pause; /* link partner */ |
| 1754 | u16 pause_result; |
| 1755 | u8 ret = 0; |
| 1756 | /* read twice */ |
| 1757 | |
| 1758 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 1759 | |
| 1760 | if (phy->req_flow_ctrl != BNX2X_FLOW_CTRL_AUTO) |
| 1761 | vars->flow_ctrl = phy->req_flow_ctrl; |
| 1762 | else if (phy->req_line_speed != SPEED_AUTO_NEG) |
| 1763 | vars->flow_ctrl = params->req_fc_auto_adv; |
| 1764 | else if (vars->link_status & LINK_STATUS_AUTO_NEGOTIATE_COMPLETE) { |
| 1765 | ret = 1; |
| 1766 | bnx2x_cl45_read(bp, phy, |
| 1767 | MDIO_AN_DEVAD, |
| 1768 | MDIO_AN_REG_ADV_PAUSE, &ld_pause); |
| 1769 | bnx2x_cl45_read(bp, phy, |
| 1770 | MDIO_AN_DEVAD, |
| 1771 | MDIO_AN_REG_LP_AUTO_NEG, &lp_pause); |
| 1772 | pause_result = (ld_pause & |
| 1773 | MDIO_AN_REG_ADV_PAUSE_MASK) >> 8; |
| 1774 | pause_result |= (lp_pause & |
| 1775 | MDIO_AN_REG_ADV_PAUSE_MASK) >> 10; |
| 1776 | DP(NETIF_MSG_LINK, "Ext PHY pause result 0x%x\n", |
| 1777 | pause_result); |
| 1778 | bnx2x_pause_resolve(vars, pause_result); |
| 1779 | } |
| 1780 | return ret; |
| 1781 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 1782 | void bnx2x_link_status_update(struct link_params *params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1783 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 1784 | { |
| 1785 | struct bnx2x *bp = params->bp; |
| 1786 | u8 link_10g; |
| 1787 | u8 port = params->port; |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 1788 | u32 sync_offset, media_types; |
Yaniv Rosner | fd36a2e | 2011-05-31 21:29:05 +0000 | [diff] [blame^] | 1789 | /* Update PHY configuration */ |
| 1790 | set_phy_vars(params, vars); |
| 1791 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 1792 | vars->link_status = REG_RD(bp, params->shmem_base + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1793 | offsetof(struct shmem_region, |
| 1794 | port_mb[port].link_status)); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 1795 | |
| 1796 | vars->link_up = (vars->link_status & LINK_STATUS_LINK_UP); |
Yaniv Rosner | fd36a2e | 2011-05-31 21:29:05 +0000 | [diff] [blame^] | 1797 | vars->phy_flags = PHY_XGXS_FLAG; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 1798 | if (vars->link_up) { |
| 1799 | DP(NETIF_MSG_LINK, "phy link up\n"); |
| 1800 | |
| 1801 | vars->phy_link_up = 1; |
| 1802 | vars->duplex = DUPLEX_FULL; |
| 1803 | switch (vars->link_status & |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1804 | LINK_STATUS_SPEED_AND_DUPLEX_MASK) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 1805 | case LINK_10THD: |
| 1806 | vars->duplex = DUPLEX_HALF; |
| 1807 | /* fall thru */ |
| 1808 | case LINK_10TFD: |
| 1809 | vars->line_speed = SPEED_10; |
| 1810 | break; |
| 1811 | |
| 1812 | case LINK_100TXHD: |
| 1813 | vars->duplex = DUPLEX_HALF; |
| 1814 | /* fall thru */ |
| 1815 | case LINK_100T4: |
| 1816 | case LINK_100TXFD: |
| 1817 | vars->line_speed = SPEED_100; |
| 1818 | break; |
| 1819 | |
| 1820 | case LINK_1000THD: |
| 1821 | vars->duplex = DUPLEX_HALF; |
| 1822 | /* fall thru */ |
| 1823 | case LINK_1000TFD: |
| 1824 | vars->line_speed = SPEED_1000; |
| 1825 | break; |
| 1826 | |
| 1827 | case LINK_2500THD: |
| 1828 | vars->duplex = DUPLEX_HALF; |
| 1829 | /* fall thru */ |
| 1830 | case LINK_2500TFD: |
| 1831 | vars->line_speed = SPEED_2500; |
| 1832 | break; |
| 1833 | |
| 1834 | case LINK_10GTFD: |
| 1835 | vars->line_speed = SPEED_10000; |
| 1836 | break; |
| 1837 | |
| 1838 | case LINK_12GTFD: |
| 1839 | vars->line_speed = SPEED_12000; |
| 1840 | break; |
| 1841 | |
| 1842 | case LINK_12_5GTFD: |
| 1843 | vars->line_speed = SPEED_12500; |
| 1844 | break; |
| 1845 | |
| 1846 | case LINK_13GTFD: |
| 1847 | vars->line_speed = SPEED_13000; |
| 1848 | break; |
| 1849 | |
| 1850 | case LINK_15GTFD: |
| 1851 | vars->line_speed = SPEED_15000; |
| 1852 | break; |
| 1853 | |
| 1854 | case LINK_16GTFD: |
| 1855 | vars->line_speed = SPEED_16000; |
| 1856 | break; |
| 1857 | |
| 1858 | default: |
| 1859 | break; |
| 1860 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 1861 | vars->flow_ctrl = 0; |
| 1862 | if (vars->link_status & LINK_STATUS_TX_FLOW_CONTROL_ENABLED) |
| 1863 | vars->flow_ctrl |= BNX2X_FLOW_CTRL_TX; |
| 1864 | |
| 1865 | if (vars->link_status & LINK_STATUS_RX_FLOW_CONTROL_ENABLED) |
| 1866 | vars->flow_ctrl |= BNX2X_FLOW_CTRL_RX; |
| 1867 | |
| 1868 | if (!vars->flow_ctrl) |
| 1869 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 1870 | |
| 1871 | if (vars->line_speed && |
| 1872 | ((vars->line_speed == SPEED_10) || |
| 1873 | (vars->line_speed == SPEED_100))) { |
| 1874 | vars->phy_flags |= PHY_SGMII_FLAG; |
| 1875 | } else { |
| 1876 | vars->phy_flags &= ~PHY_SGMII_FLAG; |
| 1877 | } |
| 1878 | |
| 1879 | /* anything 10 and over uses the bmac */ |
| 1880 | link_10g = ((vars->line_speed == SPEED_10000) || |
| 1881 | (vars->line_speed == SPEED_12000) || |
| 1882 | (vars->line_speed == SPEED_12500) || |
| 1883 | (vars->line_speed == SPEED_13000) || |
| 1884 | (vars->line_speed == SPEED_15000) || |
| 1885 | (vars->line_speed == SPEED_16000)); |
| 1886 | if (link_10g) |
| 1887 | vars->mac_type = MAC_TYPE_BMAC; |
| 1888 | else |
| 1889 | vars->mac_type = MAC_TYPE_EMAC; |
| 1890 | |
| 1891 | } else { /* link down */ |
| 1892 | DP(NETIF_MSG_LINK, "phy link down\n"); |
| 1893 | |
| 1894 | vars->phy_link_up = 0; |
| 1895 | |
| 1896 | vars->line_speed = 0; |
| 1897 | vars->duplex = DUPLEX_FULL; |
| 1898 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 1899 | |
| 1900 | /* indicate no mac active */ |
| 1901 | vars->mac_type = MAC_TYPE_NONE; |
| 1902 | } |
| 1903 | |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 1904 | /* Sync media type */ |
| 1905 | sync_offset = params->shmem_base + |
| 1906 | offsetof(struct shmem_region, |
| 1907 | dev_info.port_hw_config[port].media_type); |
| 1908 | media_types = REG_RD(bp, sync_offset); |
| 1909 | |
| 1910 | params->phy[INT_PHY].media_type = |
| 1911 | (media_types & PORT_HW_CFG_MEDIA_TYPE_PHY0_MASK) >> |
| 1912 | PORT_HW_CFG_MEDIA_TYPE_PHY0_SHIFT; |
| 1913 | params->phy[EXT_PHY1].media_type = |
| 1914 | (media_types & PORT_HW_CFG_MEDIA_TYPE_PHY1_MASK) >> |
| 1915 | PORT_HW_CFG_MEDIA_TYPE_PHY1_SHIFT; |
| 1916 | params->phy[EXT_PHY2].media_type = |
| 1917 | (media_types & PORT_HW_CFG_MEDIA_TYPE_PHY2_MASK) >> |
| 1918 | PORT_HW_CFG_MEDIA_TYPE_PHY2_SHIFT; |
| 1919 | DP(NETIF_MSG_LINK, "media_types = 0x%x\n", media_types); |
| 1920 | |
Yaniv Rosner | 020c7e3 | 2011-05-31 21:28:43 +0000 | [diff] [blame] | 1921 | /* Sync AEU offset */ |
| 1922 | sync_offset = params->shmem_base + |
| 1923 | offsetof(struct shmem_region, |
| 1924 | dev_info.port_hw_config[port].aeu_int_mask); |
| 1925 | |
| 1926 | vars->aeu_int_mask = REG_RD(bp, sync_offset); |
| 1927 | |
| 1928 | DP(NETIF_MSG_LINK, "link_status 0x%x phy_link_up %x int_mask 0x%x\n", |
| 1929 | vars->link_status, vars->phy_link_up, vars->aeu_int_mask); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 1930 | DP(NETIF_MSG_LINK, "line_speed %x duplex %x flow_ctrl 0x%x\n", |
| 1931 | vars->line_speed, vars->duplex, vars->flow_ctrl); |
| 1932 | } |
| 1933 | |
| 1934 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1935 | static void bnx2x_set_master_ln(struct link_params *params, |
| 1936 | struct bnx2x_phy *phy) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1937 | { |
| 1938 | struct bnx2x *bp = params->bp; |
| 1939 | u16 new_master_ln, ser_lane; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1940 | ser_lane = ((params->lane_config & |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1941 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_MASK) >> |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1942 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_SHIFT); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1943 | |
| 1944 | /* set the master_ln for AN */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 1945 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1946 | MDIO_REG_BANK_XGXS_BLOCK2, |
| 1947 | MDIO_XGXS_BLOCK2_TEST_MODE_LANE, |
| 1948 | &new_master_ln); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1949 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 1950 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1951 | MDIO_REG_BANK_XGXS_BLOCK2 , |
| 1952 | MDIO_XGXS_BLOCK2_TEST_MODE_LANE, |
| 1953 | (new_master_ln | ser_lane)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1954 | } |
| 1955 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 1956 | static int bnx2x_reset_unicore(struct link_params *params, |
| 1957 | struct bnx2x_phy *phy, |
| 1958 | u8 set_serdes) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1959 | { |
| 1960 | struct bnx2x *bp = params->bp; |
| 1961 | u16 mii_control; |
| 1962 | u16 i; |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 1963 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1964 | MDIO_REG_BANK_COMBO_IEEE0, |
| 1965 | MDIO_COMBO_IEEE0_MII_CONTROL, &mii_control); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1966 | |
| 1967 | /* reset the unicore */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 1968 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1969 | MDIO_REG_BANK_COMBO_IEEE0, |
| 1970 | MDIO_COMBO_IEEE0_MII_CONTROL, |
| 1971 | (mii_control | |
| 1972 | MDIO_COMBO_IEEO_MII_CONTROL_RESET)); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 1973 | if (set_serdes) |
| 1974 | bnx2x_set_serdes_access(bp, params->port); |
Eilon Greenstein | c1b7399 | 2009-02-12 08:37:07 +0000 | [diff] [blame] | 1975 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1976 | /* wait for the reset to self clear */ |
| 1977 | for (i = 0; i < MDIO_ACCESS_TIMEOUT; i++) { |
| 1978 | udelay(5); |
| 1979 | |
| 1980 | /* the reset erased the previous bank value */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 1981 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 1982 | MDIO_REG_BANK_COMBO_IEEE0, |
| 1983 | MDIO_COMBO_IEEE0_MII_CONTROL, |
| 1984 | &mii_control); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1985 | |
| 1986 | if (!(mii_control & MDIO_COMBO_IEEO_MII_CONTROL_RESET)) { |
| 1987 | udelay(5); |
| 1988 | return 0; |
| 1989 | } |
| 1990 | } |
| 1991 | |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 1992 | netdev_err(bp->dev, "Warning: PHY was not initialized," |
| 1993 | " Port %d\n", |
| 1994 | params->port); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 1995 | DP(NETIF_MSG_LINK, "BUG! XGXS is still in reset!\n"); |
| 1996 | return -EINVAL; |
| 1997 | |
| 1998 | } |
| 1999 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2000 | static void bnx2x_set_swap_lanes(struct link_params *params, |
| 2001 | struct bnx2x_phy *phy) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2002 | { |
| 2003 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2004 | /* |
| 2005 | * Each two bits represents a lane number: |
| 2006 | * No swap is 0123 => 0x1b no need to enable the swap |
| 2007 | */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2008 | u16 ser_lane, rx_lane_swap, tx_lane_swap; |
| 2009 | |
| 2010 | ser_lane = ((params->lane_config & |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2011 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_MASK) >> |
| 2012 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_SHIFT); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2013 | rx_lane_swap = ((params->lane_config & |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2014 | PORT_HW_CFG_LANE_SWAP_CFG_RX_MASK) >> |
| 2015 | PORT_HW_CFG_LANE_SWAP_CFG_RX_SHIFT); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2016 | tx_lane_swap = ((params->lane_config & |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2017 | PORT_HW_CFG_LANE_SWAP_CFG_TX_MASK) >> |
| 2018 | PORT_HW_CFG_LANE_SWAP_CFG_TX_SHIFT); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2019 | |
| 2020 | if (rx_lane_swap != 0x1b) { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2021 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2022 | MDIO_REG_BANK_XGXS_BLOCK2, |
| 2023 | MDIO_XGXS_BLOCK2_RX_LN_SWAP, |
| 2024 | (rx_lane_swap | |
| 2025 | MDIO_XGXS_BLOCK2_RX_LN_SWAP_ENABLE | |
| 2026 | MDIO_XGXS_BLOCK2_RX_LN_SWAP_FORCE_ENABLE)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2027 | } else { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2028 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2029 | MDIO_REG_BANK_XGXS_BLOCK2, |
| 2030 | MDIO_XGXS_BLOCK2_RX_LN_SWAP, 0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2031 | } |
| 2032 | |
| 2033 | if (tx_lane_swap != 0x1b) { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2034 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2035 | MDIO_REG_BANK_XGXS_BLOCK2, |
| 2036 | MDIO_XGXS_BLOCK2_TX_LN_SWAP, |
| 2037 | (tx_lane_swap | |
| 2038 | MDIO_XGXS_BLOCK2_TX_LN_SWAP_ENABLE)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2039 | } else { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2040 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2041 | MDIO_REG_BANK_XGXS_BLOCK2, |
| 2042 | MDIO_XGXS_BLOCK2_TX_LN_SWAP, 0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2043 | } |
| 2044 | } |
| 2045 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2046 | static void bnx2x_set_parallel_detection(struct bnx2x_phy *phy, |
| 2047 | struct link_params *params) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2048 | { |
| 2049 | struct bnx2x *bp = params->bp; |
| 2050 | u16 control2; |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2051 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2052 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 2053 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL2, |
| 2054 | &control2); |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 2055 | if (phy->speed_cap_mask & PORT_HW_CFG_SPEED_CAPABILITY_D0_1G) |
Yaniv Rosner | 18afb0a | 2009-11-05 19:18:04 +0200 | [diff] [blame] | 2056 | control2 |= MDIO_SERDES_DIGITAL_A_1000X_CONTROL2_PRL_DT_EN; |
| 2057 | else |
| 2058 | control2 &= ~MDIO_SERDES_DIGITAL_A_1000X_CONTROL2_PRL_DT_EN; |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 2059 | DP(NETIF_MSG_LINK, "phy->speed_cap_mask = 0x%x, control2 = 0x%x\n", |
| 2060 | phy->speed_cap_mask, control2); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2061 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2062 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 2063 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL2, |
| 2064 | control2); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2065 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2066 | if ((phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT) && |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 2067 | (phy->speed_cap_mask & |
Yaniv Rosner | 18afb0a | 2009-11-05 19:18:04 +0200 | [diff] [blame] | 2068 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G)) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2069 | DP(NETIF_MSG_LINK, "XGXS\n"); |
| 2070 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2071 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2072 | MDIO_REG_BANK_10G_PARALLEL_DETECT, |
| 2073 | MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_LINK, |
| 2074 | MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_LINK_CNT); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2075 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2076 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2077 | MDIO_REG_BANK_10G_PARALLEL_DETECT, |
| 2078 | MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_CONTROL, |
| 2079 | &control2); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2080 | |
| 2081 | |
| 2082 | control2 |= |
| 2083 | MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_CONTROL_PARDET10G_EN; |
| 2084 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2085 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2086 | MDIO_REG_BANK_10G_PARALLEL_DETECT, |
| 2087 | MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_CONTROL, |
| 2088 | control2); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2089 | |
| 2090 | /* Disable parallel detection of HiG */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2091 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2092 | MDIO_REG_BANK_XGXS_BLOCK2, |
| 2093 | MDIO_XGXS_BLOCK2_UNICORE_MODE_10G, |
| 2094 | MDIO_XGXS_BLOCK2_UNICORE_MODE_10G_CX4_XGXS | |
| 2095 | MDIO_XGXS_BLOCK2_UNICORE_MODE_10G_HIGIG_XGXS); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2096 | } |
| 2097 | } |
| 2098 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2099 | static void bnx2x_set_autoneg(struct bnx2x_phy *phy, |
| 2100 | struct link_params *params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2101 | struct link_vars *vars, |
| 2102 | u8 enable_cl73) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2103 | { |
| 2104 | struct bnx2x *bp = params->bp; |
| 2105 | u16 reg_val; |
| 2106 | |
| 2107 | /* CL37 Autoneg */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2108 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2109 | MDIO_REG_BANK_COMBO_IEEE0, |
| 2110 | MDIO_COMBO_IEEE0_MII_CONTROL, ®_val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2111 | |
| 2112 | /* CL37 Autoneg Enabled */ |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 2113 | if (vars->line_speed == SPEED_AUTO_NEG) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2114 | reg_val |= MDIO_COMBO_IEEO_MII_CONTROL_AN_EN; |
| 2115 | else /* CL37 Autoneg Disabled */ |
| 2116 | reg_val &= ~(MDIO_COMBO_IEEO_MII_CONTROL_AN_EN | |
| 2117 | MDIO_COMBO_IEEO_MII_CONTROL_RESTART_AN); |
| 2118 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2119 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2120 | MDIO_REG_BANK_COMBO_IEEE0, |
| 2121 | MDIO_COMBO_IEEE0_MII_CONTROL, reg_val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2122 | |
| 2123 | /* Enable/Disable Autodetection */ |
| 2124 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2125 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2126 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 2127 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL1, ®_val); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2128 | reg_val &= ~(MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_SIGNAL_DETECT_EN | |
| 2129 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_INVERT_SIGNAL_DETECT); |
| 2130 | reg_val |= MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_FIBER_MODE; |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 2131 | if (vars->line_speed == SPEED_AUTO_NEG) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2132 | reg_val |= MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_AUTODET; |
| 2133 | else |
| 2134 | reg_val &= ~MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_AUTODET; |
| 2135 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2136 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2137 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 2138 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL1, reg_val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2139 | |
| 2140 | /* Enable TetonII and BAM autoneg */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2141 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2142 | MDIO_REG_BANK_BAM_NEXT_PAGE, |
| 2143 | MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL, |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2144 | ®_val); |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 2145 | if (vars->line_speed == SPEED_AUTO_NEG) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2146 | /* Enable BAM aneg Mode and TetonII aneg Mode */ |
| 2147 | reg_val |= (MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL_BAM_MODE | |
| 2148 | MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL_TETON_AN); |
| 2149 | } else { |
| 2150 | /* TetonII and BAM Autoneg Disabled */ |
| 2151 | reg_val &= ~(MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL_BAM_MODE | |
| 2152 | MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL_TETON_AN); |
| 2153 | } |
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_BAM_NEXT_PAGE, |
| 2156 | MDIO_BAM_NEXT_PAGE_MP5_NEXT_PAGE_CTRL, |
| 2157 | reg_val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2158 | |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2159 | if (enable_cl73) { |
| 2160 | /* Enable Cl73 FSM status bits */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2161 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2162 | MDIO_REG_BANK_CL73_USERB0, |
| 2163 | MDIO_CL73_USERB0_CL73_UCTRL, |
| 2164 | 0xe); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2165 | |
| 2166 | /* Enable BAM Station Manager*/ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2167 | CL22_WR_OVER_CL45(bp, phy, |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2168 | MDIO_REG_BANK_CL73_USERB0, |
| 2169 | MDIO_CL73_USERB0_CL73_BAM_CTRL1, |
| 2170 | MDIO_CL73_USERB0_CL73_BAM_CTRL1_BAM_EN | |
| 2171 | MDIO_CL73_USERB0_CL73_BAM_CTRL1_BAM_STATION_MNGR_EN | |
| 2172 | MDIO_CL73_USERB0_CL73_BAM_CTRL1_BAM_NP_AFTER_BP_EN); |
| 2173 | |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 2174 | /* Advertise CL73 link speeds */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2175 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2176 | MDIO_REG_BANK_CL73_IEEEB1, |
| 2177 | MDIO_CL73_IEEEB1_AN_ADV2, |
| 2178 | ®_val); |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 2179 | if (phy->speed_cap_mask & |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 2180 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G) |
| 2181 | reg_val |= MDIO_CL73_IEEEB1_AN_ADV2_ADVR_10G_KX4; |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 2182 | if (phy->speed_cap_mask & |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 2183 | PORT_HW_CFG_SPEED_CAPABILITY_D0_1G) |
| 2184 | reg_val |= MDIO_CL73_IEEEB1_AN_ADV2_ADVR_1000M_KX; |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2185 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2186 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2187 | MDIO_REG_BANK_CL73_IEEEB1, |
| 2188 | MDIO_CL73_IEEEB1_AN_ADV2, |
| 2189 | reg_val); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2190 | |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2191 | /* CL73 Autoneg Enabled */ |
| 2192 | reg_val = MDIO_CL73_IEEEB0_CL73_AN_CONTROL_AN_EN; |
| 2193 | |
| 2194 | } else /* CL73 Autoneg Disabled */ |
| 2195 | reg_val = 0; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2196 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2197 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2198 | MDIO_REG_BANK_CL73_IEEEB0, |
| 2199 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL, reg_val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2200 | } |
| 2201 | |
| 2202 | /* program SerDes, forced speed */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2203 | static void bnx2x_program_serdes(struct bnx2x_phy *phy, |
| 2204 | struct link_params *params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2205 | struct link_vars *vars) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2206 | { |
| 2207 | struct bnx2x *bp = params->bp; |
| 2208 | u16 reg_val; |
| 2209 | |
Eilon Greenstein | 5793720 | 2009-08-12 08:23:53 +0000 | [diff] [blame] | 2210 | /* program duplex, disable autoneg and sgmii*/ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2211 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2212 | MDIO_REG_BANK_COMBO_IEEE0, |
| 2213 | MDIO_COMBO_IEEE0_MII_CONTROL, ®_val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2214 | reg_val &= ~(MDIO_COMBO_IEEO_MII_CONTROL_FULL_DUPLEX | |
Eilon Greenstein | 5793720 | 2009-08-12 08:23:53 +0000 | [diff] [blame] | 2215 | MDIO_COMBO_IEEO_MII_CONTROL_AN_EN | |
| 2216 | MDIO_COMBO_IEEO_MII_CONTROL_MAN_SGMII_SP_MASK); |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 2217 | if (phy->req_duplex == DUPLEX_FULL) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2218 | reg_val |= MDIO_COMBO_IEEO_MII_CONTROL_FULL_DUPLEX; |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2219 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2220 | MDIO_REG_BANK_COMBO_IEEE0, |
| 2221 | MDIO_COMBO_IEEE0_MII_CONTROL, reg_val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2222 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2223 | /* |
| 2224 | * program speed |
| 2225 | * - needed only if the speed is greater than 1G (2.5G or 10G) |
| 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_SERDES_DIGITAL, |
| 2229 | MDIO_SERDES_DIGITAL_MISC1, ®_val); |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 2230 | /* clearing the speed value before setting the right speed */ |
| 2231 | DP(NETIF_MSG_LINK, "MDIO_REG_BANK_SERDES_DIGITAL = 0x%x\n", reg_val); |
| 2232 | |
| 2233 | reg_val &= ~(MDIO_SERDES_DIGITAL_MISC1_FORCE_SPEED_MASK | |
| 2234 | MDIO_SERDES_DIGITAL_MISC1_FORCE_SPEED_SEL); |
| 2235 | |
| 2236 | if (!((vars->line_speed == SPEED_1000) || |
| 2237 | (vars->line_speed == SPEED_100) || |
| 2238 | (vars->line_speed == SPEED_10))) { |
| 2239 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2240 | reg_val |= (MDIO_SERDES_DIGITAL_MISC1_REFCLK_SEL_156_25M | |
| 2241 | MDIO_SERDES_DIGITAL_MISC1_FORCE_SPEED_SEL); |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 2242 | if (vars->line_speed == SPEED_10000) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2243 | reg_val |= |
| 2244 | MDIO_SERDES_DIGITAL_MISC1_FORCE_SPEED_10G_CX4; |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 2245 | if (vars->line_speed == SPEED_13000) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2246 | reg_val |= |
| 2247 | MDIO_SERDES_DIGITAL_MISC1_FORCE_SPEED_13G; |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 2248 | } |
| 2249 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2250 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2251 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 2252 | MDIO_SERDES_DIGITAL_MISC1, reg_val); |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 2253 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2254 | } |
| 2255 | |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 2256 | static void bnx2x_set_brcm_cl37_advertisement(struct bnx2x_phy *phy, |
| 2257 | struct link_params *params) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2258 | { |
| 2259 | struct bnx2x *bp = params->bp; |
| 2260 | u16 val = 0; |
| 2261 | |
| 2262 | /* configure the 48 bits for BAM AN */ |
| 2263 | |
| 2264 | /* set extended capabilities */ |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 2265 | 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] | 2266 | val |= MDIO_OVER_1G_UP1_2_5G; |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 2267 | if (phy->speed_cap_mask & PORT_HW_CFG_SPEED_CAPABILITY_D0_10G) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2268 | val |= MDIO_OVER_1G_UP1_10G; |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2269 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2270 | MDIO_REG_BANK_OVER_1G, |
| 2271 | MDIO_OVER_1G_UP1, val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2272 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2273 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2274 | MDIO_REG_BANK_OVER_1G, |
| 2275 | MDIO_OVER_1G_UP3, 0x400); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2276 | } |
| 2277 | |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 2278 | static void bnx2x_set_ieee_aneg_advertisement(struct bnx2x_phy *phy, |
| 2279 | struct link_params *params, |
| 2280 | u16 ieee_fc) |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 2281 | { |
| 2282 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 2283 | u16 val; |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 2284 | /* for AN, we are always publishing full duplex */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2285 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2286 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2287 | MDIO_REG_BANK_COMBO_IEEE0, |
| 2288 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV, ieee_fc); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2289 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2290 | MDIO_REG_BANK_CL73_IEEEB1, |
| 2291 | MDIO_CL73_IEEEB1_AN_ADV1, &val); |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 2292 | val &= ~MDIO_CL73_IEEEB1_AN_ADV1_PAUSE_BOTH; |
| 2293 | val |= ((ieee_fc<<3) & MDIO_CL73_IEEEB1_AN_ADV1_PAUSE_MASK); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2294 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2295 | MDIO_REG_BANK_CL73_IEEEB1, |
| 2296 | MDIO_CL73_IEEEB1_AN_ADV1, val); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2297 | } |
| 2298 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2299 | static void bnx2x_restart_autoneg(struct bnx2x_phy *phy, |
| 2300 | struct link_params *params, |
| 2301 | u8 enable_cl73) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2302 | { |
| 2303 | struct bnx2x *bp = params->bp; |
Eilon Greenstein | 3a36f2e | 2009-02-12 08:37:09 +0000 | [diff] [blame] | 2304 | u16 mii_control; |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2305 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2306 | DP(NETIF_MSG_LINK, "bnx2x_restart_autoneg\n"); |
Eilon Greenstein | 3a36f2e | 2009-02-12 08:37:09 +0000 | [diff] [blame] | 2307 | /* Enable and restart BAM/CL37 aneg */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2308 | |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2309 | if (enable_cl73) { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2310 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2311 | MDIO_REG_BANK_CL73_IEEEB0, |
| 2312 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL, |
| 2313 | &mii_control); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2314 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2315 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2316 | MDIO_REG_BANK_CL73_IEEEB0, |
| 2317 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL, |
| 2318 | (mii_control | |
| 2319 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL_AN_EN | |
| 2320 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL_RESTART_AN)); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2321 | } else { |
| 2322 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2323 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2324 | MDIO_REG_BANK_COMBO_IEEE0, |
| 2325 | MDIO_COMBO_IEEE0_MII_CONTROL, |
| 2326 | &mii_control); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2327 | DP(NETIF_MSG_LINK, |
| 2328 | "bnx2x_restart_autoneg mii_control before = 0x%x\n", |
| 2329 | mii_control); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2330 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2331 | MDIO_REG_BANK_COMBO_IEEE0, |
| 2332 | MDIO_COMBO_IEEE0_MII_CONTROL, |
| 2333 | (mii_control | |
| 2334 | MDIO_COMBO_IEEO_MII_CONTROL_AN_EN | |
| 2335 | MDIO_COMBO_IEEO_MII_CONTROL_RESTART_AN)); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2336 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2337 | } |
| 2338 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2339 | static void bnx2x_initialize_sgmii_process(struct bnx2x_phy *phy, |
| 2340 | struct link_params *params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2341 | struct link_vars *vars) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2342 | { |
| 2343 | struct bnx2x *bp = params->bp; |
| 2344 | u16 control1; |
| 2345 | |
| 2346 | /* in SGMII mode, the unicore is always slave */ |
| 2347 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2348 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2349 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 2350 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL1, |
| 2351 | &control1); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2352 | control1 |= MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_INVERT_SIGNAL_DETECT; |
| 2353 | /* set sgmii mode (and not fiber) */ |
| 2354 | control1 &= ~(MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_FIBER_MODE | |
| 2355 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_AUTODET | |
| 2356 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL1_MSTR_MODE); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2357 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2358 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 2359 | MDIO_SERDES_DIGITAL_A_1000X_CONTROL1, |
| 2360 | control1); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2361 | |
| 2362 | /* if forced speed */ |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 2363 | if (!(vars->line_speed == SPEED_AUTO_NEG)) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2364 | /* set speed, disable autoneg */ |
| 2365 | u16 mii_control; |
| 2366 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2367 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2368 | MDIO_REG_BANK_COMBO_IEEE0, |
| 2369 | MDIO_COMBO_IEEE0_MII_CONTROL, |
| 2370 | &mii_control); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2371 | mii_control &= ~(MDIO_COMBO_IEEO_MII_CONTROL_AN_EN | |
| 2372 | MDIO_COMBO_IEEO_MII_CONTROL_MAN_SGMII_SP_MASK| |
| 2373 | MDIO_COMBO_IEEO_MII_CONTROL_FULL_DUPLEX); |
| 2374 | |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 2375 | switch (vars->line_speed) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2376 | case SPEED_100: |
| 2377 | mii_control |= |
| 2378 | MDIO_COMBO_IEEO_MII_CONTROL_MAN_SGMII_SP_100; |
| 2379 | break; |
| 2380 | case SPEED_1000: |
| 2381 | mii_control |= |
| 2382 | MDIO_COMBO_IEEO_MII_CONTROL_MAN_SGMII_SP_1000; |
| 2383 | break; |
| 2384 | case SPEED_10: |
| 2385 | /* there is nothing to set for 10M */ |
| 2386 | break; |
| 2387 | default: |
| 2388 | /* invalid speed for SGMII */ |
Yaniv Rosner | 8c99e7b | 2008-08-13 15:56:17 -0700 | [diff] [blame] | 2389 | DP(NETIF_MSG_LINK, "Invalid line_speed 0x%x\n", |
| 2390 | vars->line_speed); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2391 | break; |
| 2392 | } |
| 2393 | |
| 2394 | /* setting the full duplex */ |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 2395 | if (phy->req_duplex == DUPLEX_FULL) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2396 | mii_control |= |
| 2397 | MDIO_COMBO_IEEO_MII_CONTROL_FULL_DUPLEX; |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2398 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2399 | MDIO_REG_BANK_COMBO_IEEE0, |
| 2400 | MDIO_COMBO_IEEE0_MII_CONTROL, |
| 2401 | mii_control); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2402 | |
| 2403 | } else { /* AN mode */ |
| 2404 | /* enable and restart AN */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2405 | bnx2x_restart_autoneg(phy, params, 0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2406 | } |
| 2407 | } |
| 2408 | |
| 2409 | |
| 2410 | /* |
| 2411 | * link management |
| 2412 | */ |
| 2413 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 2414 | static int bnx2x_direct_parallel_detect_used(struct bnx2x_phy *phy, |
| 2415 | struct link_params *params) |
Yaniv Rosner | 15ddd2d0 | 2009-11-05 19:18:12 +0200 | [diff] [blame] | 2416 | { |
| 2417 | struct bnx2x *bp = params->bp; |
| 2418 | u16 pd_10g, status2_1000x; |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 2419 | if (phy->req_line_speed != SPEED_AUTO_NEG) |
| 2420 | return 0; |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2421 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2422 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 2423 | MDIO_SERDES_DIGITAL_A_1000X_STATUS2, |
| 2424 | &status2_1000x); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2425 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2426 | MDIO_REG_BANK_SERDES_DIGITAL, |
| 2427 | MDIO_SERDES_DIGITAL_A_1000X_STATUS2, |
| 2428 | &status2_1000x); |
Yaniv Rosner | 15ddd2d0 | 2009-11-05 19:18:12 +0200 | [diff] [blame] | 2429 | if (status2_1000x & MDIO_SERDES_DIGITAL_A_1000X_STATUS2_AN_DISABLED) { |
| 2430 | DP(NETIF_MSG_LINK, "1G parallel detect link on port %d\n", |
| 2431 | params->port); |
| 2432 | return 1; |
| 2433 | } |
| 2434 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2435 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2436 | MDIO_REG_BANK_10G_PARALLEL_DETECT, |
| 2437 | MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_STATUS, |
| 2438 | &pd_10g); |
Yaniv Rosner | 15ddd2d0 | 2009-11-05 19:18:12 +0200 | [diff] [blame] | 2439 | |
| 2440 | if (pd_10g & MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_STATUS_PD_LINK) { |
| 2441 | DP(NETIF_MSG_LINK, "10G parallel detect link on port %d\n", |
| 2442 | params->port); |
| 2443 | return 1; |
| 2444 | } |
| 2445 | return 0; |
| 2446 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2447 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2448 | static void bnx2x_flow_ctrl_resolve(struct bnx2x_phy *phy, |
| 2449 | struct link_params *params, |
| 2450 | struct link_vars *vars, |
| 2451 | u32 gp_status) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2452 | { |
| 2453 | struct bnx2x *bp = params->bp; |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 2454 | u16 ld_pause; /* local driver */ |
| 2455 | u16 lp_pause; /* link partner */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2456 | u16 pause_result; |
| 2457 | |
David S. Miller | c0700f9 | 2008-12-16 23:53:20 -0800 | [diff] [blame] | 2458 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2459 | |
| 2460 | /* resolve from gp_status in case of AN complete and not sgmii */ |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 2461 | if (phy->req_flow_ctrl != BNX2X_FLOW_CTRL_AUTO) |
| 2462 | vars->flow_ctrl = phy->req_flow_ctrl; |
| 2463 | else if (phy->req_line_speed != SPEED_AUTO_NEG) |
| 2464 | vars->flow_ctrl = params->req_fc_auto_adv; |
| 2465 | else if ((gp_status & MDIO_AN_CL73_OR_37_COMPLETE) && |
| 2466 | (!(vars->phy_flags & PHY_SGMII_FLAG))) { |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2467 | if (bnx2x_direct_parallel_detect_used(phy, params)) { |
Yaniv Rosner | 15ddd2d0 | 2009-11-05 19:18:12 +0200 | [diff] [blame] | 2468 | vars->flow_ctrl = params->req_fc_auto_adv; |
| 2469 | return; |
| 2470 | } |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 2471 | if ((gp_status & |
| 2472 | (MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_AUTONEG_COMPLETE | |
| 2473 | MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_MR_LP_NP_AN_ABLE)) == |
| 2474 | (MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_AUTONEG_COMPLETE | |
| 2475 | MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_MR_LP_NP_AN_ABLE)) { |
| 2476 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2477 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2478 | MDIO_REG_BANK_CL73_IEEEB1, |
| 2479 | MDIO_CL73_IEEEB1_AN_ADV1, |
| 2480 | &ld_pause); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2481 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2482 | MDIO_REG_BANK_CL73_IEEEB1, |
| 2483 | MDIO_CL73_IEEEB1_AN_LP_ADV1, |
| 2484 | &lp_pause); |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 2485 | pause_result = (ld_pause & |
| 2486 | MDIO_CL73_IEEEB1_AN_ADV1_PAUSE_MASK) |
| 2487 | >> 8; |
| 2488 | pause_result |= (lp_pause & |
| 2489 | MDIO_CL73_IEEEB1_AN_LP_ADV1_PAUSE_MASK) |
| 2490 | >> 10; |
| 2491 | DP(NETIF_MSG_LINK, "pause_result CL73 0x%x\n", |
| 2492 | pause_result); |
| 2493 | } else { |
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_COMBO_IEEE0, |
| 2496 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV, |
| 2497 | &ld_pause); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2498 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2499 | MDIO_REG_BANK_COMBO_IEEE0, |
| 2500 | MDIO_COMBO_IEEE0_AUTO_NEG_LINK_PARTNER_ABILITY1, |
| 2501 | &lp_pause); |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 2502 | pause_result = (ld_pause & |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2503 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_MASK)>>5; |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 2504 | pause_result |= (lp_pause & |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2505 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_MASK)>>7; |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 2506 | DP(NETIF_MSG_LINK, "pause_result CL37 0x%x\n", |
| 2507 | pause_result); |
| 2508 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2509 | bnx2x_pause_resolve(vars, pause_result); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2510 | } |
| 2511 | DP(NETIF_MSG_LINK, "flow_ctrl 0x%x\n", vars->flow_ctrl); |
| 2512 | } |
| 2513 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2514 | static void bnx2x_check_fallback_to_cl37(struct bnx2x_phy *phy, |
| 2515 | struct link_params *params) |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2516 | { |
| 2517 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 2518 | u16 rx_status, ustat_val, cl37_fsm_received; |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2519 | DP(NETIF_MSG_LINK, "bnx2x_check_fallback_to_cl37\n"); |
| 2520 | /* Step 1: Make sure signal is detected */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2521 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2522 | MDIO_REG_BANK_RX0, |
| 2523 | MDIO_RX0_RX_STATUS, |
| 2524 | &rx_status); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2525 | if ((rx_status & MDIO_RX0_RX_STATUS_SIGDET) != |
| 2526 | (MDIO_RX0_RX_STATUS_SIGDET)) { |
| 2527 | DP(NETIF_MSG_LINK, "Signal is not detected. Restoring CL73." |
| 2528 | "rx_status(0x80b0) = 0x%x\n", rx_status); |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2529 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2530 | MDIO_REG_BANK_CL73_IEEEB0, |
| 2531 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL, |
| 2532 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL_AN_EN); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2533 | return; |
| 2534 | } |
| 2535 | /* Step 2: Check CL73 state machine */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2536 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2537 | MDIO_REG_BANK_CL73_USERB0, |
| 2538 | MDIO_CL73_USERB0_CL73_USTAT1, |
| 2539 | &ustat_val); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2540 | if ((ustat_val & |
| 2541 | (MDIO_CL73_USERB0_CL73_USTAT1_LINK_STATUS_CHECK | |
| 2542 | MDIO_CL73_USERB0_CL73_USTAT1_AN_GOOD_CHECK_BAM37)) != |
| 2543 | (MDIO_CL73_USERB0_CL73_USTAT1_LINK_STATUS_CHECK | |
| 2544 | MDIO_CL73_USERB0_CL73_USTAT1_AN_GOOD_CHECK_BAM37)) { |
| 2545 | DP(NETIF_MSG_LINK, "CL73 state-machine is not stable. " |
| 2546 | "ustat_val(0x8371) = 0x%x\n", ustat_val); |
| 2547 | return; |
| 2548 | } |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2549 | /* |
| 2550 | * Step 3: Check CL37 Message Pages received to indicate LP |
| 2551 | * supports only CL37 |
| 2552 | */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2553 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2554 | MDIO_REG_BANK_REMOTE_PHY, |
| 2555 | MDIO_REMOTE_PHY_MISC_RX_STATUS, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 2556 | &cl37_fsm_received); |
| 2557 | if ((cl37_fsm_received & |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2558 | (MDIO_REMOTE_PHY_MISC_RX_STATUS_CL37_FSM_RECEIVED_OVER1G_MSG | |
| 2559 | MDIO_REMOTE_PHY_MISC_RX_STATUS_CL37_FSM_RECEIVED_BRCM_OUI_MSG)) != |
| 2560 | (MDIO_REMOTE_PHY_MISC_RX_STATUS_CL37_FSM_RECEIVED_OVER1G_MSG | |
| 2561 | MDIO_REMOTE_PHY_MISC_RX_STATUS_CL37_FSM_RECEIVED_BRCM_OUI_MSG)) { |
| 2562 | DP(NETIF_MSG_LINK, "No CL37 FSM were received. " |
| 2563 | "misc_rx_status(0x8330) = 0x%x\n", |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 2564 | cl37_fsm_received); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2565 | return; |
| 2566 | } |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2567 | /* |
| 2568 | * The combined cl37/cl73 fsm state information indicating that |
| 2569 | * we are connected to a device which does not support cl73, but |
| 2570 | * does support cl37 BAM. In this case we disable cl73 and |
| 2571 | * restart cl37 auto-neg |
| 2572 | */ |
| 2573 | |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2574 | /* Disable CL73 */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2575 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2576 | MDIO_REG_BANK_CL73_IEEEB0, |
| 2577 | MDIO_CL73_IEEEB0_CL73_AN_CONTROL, |
| 2578 | 0); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2579 | /* Restart CL37 autoneg */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2580 | bnx2x_restart_autoneg(phy, params, 0); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2581 | DP(NETIF_MSG_LINK, "Disabling CL73, and restarting CL37 autoneg\n"); |
| 2582 | } |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 2583 | |
| 2584 | static void bnx2x_xgxs_an_resolve(struct bnx2x_phy *phy, |
| 2585 | struct link_params *params, |
| 2586 | struct link_vars *vars, |
| 2587 | u32 gp_status) |
| 2588 | { |
| 2589 | if (gp_status & MDIO_AN_CL73_OR_37_COMPLETE) |
| 2590 | vars->link_status |= |
| 2591 | LINK_STATUS_AUTO_NEGOTIATE_COMPLETE; |
| 2592 | |
| 2593 | if (bnx2x_direct_parallel_detect_used(phy, params)) |
| 2594 | vars->link_status |= |
| 2595 | LINK_STATUS_PARALLEL_DETECTION_USED; |
| 2596 | } |
| 2597 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 2598 | static int bnx2x_link_settings_status(struct bnx2x_phy *phy, |
| 2599 | struct link_params *params, |
| 2600 | struct link_vars *vars) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2601 | { |
| 2602 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2603 | u16 new_line_speed, gp_status; |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 2604 | int rc = 0; |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 2605 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 2606 | /* Read gp_status */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2607 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2608 | MDIO_REG_BANK_GP_STATUS, |
| 2609 | MDIO_GP_STATUS_TOP_AN_STATUS1, |
| 2610 | &gp_status); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 2611 | |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 2612 | if (phy->req_line_speed == SPEED_AUTO_NEG) |
| 2613 | vars->link_status |= LINK_STATUS_AUTO_NEGOTIATE_ENABLED; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2614 | if (gp_status & MDIO_GP_STATUS_TOP_AN_STATUS1_LINK_STATUS) { |
| 2615 | DP(NETIF_MSG_LINK, "phy link up gp_status=0x%x\n", |
| 2616 | gp_status); |
| 2617 | |
| 2618 | vars->phy_link_up = 1; |
| 2619 | vars->link_status |= LINK_STATUS_LINK_UP; |
| 2620 | |
| 2621 | if (gp_status & MDIO_GP_STATUS_TOP_AN_STATUS1_DUPLEX_STATUS) |
| 2622 | vars->duplex = DUPLEX_FULL; |
| 2623 | else |
| 2624 | vars->duplex = DUPLEX_HALF; |
| 2625 | |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 2626 | if (SINGLE_MEDIA_DIRECT(params)) { |
| 2627 | bnx2x_flow_ctrl_resolve(phy, params, vars, gp_status); |
| 2628 | if (phy->req_line_speed == SPEED_AUTO_NEG) |
| 2629 | bnx2x_xgxs_an_resolve(phy, params, vars, |
| 2630 | gp_status); |
| 2631 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2632 | |
| 2633 | switch (gp_status & GP_STATUS_SPEED_MASK) { |
| 2634 | case GP_STATUS_10M: |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 2635 | new_line_speed = SPEED_10; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2636 | if (vars->duplex == DUPLEX_FULL) |
| 2637 | vars->link_status |= LINK_10TFD; |
| 2638 | else |
| 2639 | vars->link_status |= LINK_10THD; |
| 2640 | break; |
| 2641 | |
| 2642 | case GP_STATUS_100M: |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 2643 | new_line_speed = SPEED_100; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2644 | if (vars->duplex == DUPLEX_FULL) |
| 2645 | vars->link_status |= LINK_100TXFD; |
| 2646 | else |
| 2647 | vars->link_status |= LINK_100TXHD; |
| 2648 | break; |
| 2649 | |
| 2650 | case GP_STATUS_1G: |
| 2651 | case GP_STATUS_1G_KX: |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 2652 | new_line_speed = SPEED_1000; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2653 | if (vars->duplex == DUPLEX_FULL) |
| 2654 | vars->link_status |= LINK_1000TFD; |
| 2655 | else |
| 2656 | vars->link_status |= LINK_1000THD; |
| 2657 | break; |
| 2658 | |
| 2659 | case GP_STATUS_2_5G: |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 2660 | new_line_speed = SPEED_2500; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2661 | if (vars->duplex == DUPLEX_FULL) |
| 2662 | vars->link_status |= LINK_2500TFD; |
| 2663 | else |
| 2664 | vars->link_status |= LINK_2500THD; |
| 2665 | break; |
| 2666 | |
| 2667 | case GP_STATUS_5G: |
| 2668 | case GP_STATUS_6G: |
| 2669 | DP(NETIF_MSG_LINK, |
| 2670 | "link speed unsupported gp_status 0x%x\n", |
| 2671 | gp_status); |
| 2672 | return -EINVAL; |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 2673 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2674 | case GP_STATUS_10G_KX4: |
| 2675 | case GP_STATUS_10G_HIG: |
| 2676 | case GP_STATUS_10G_CX4: |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 2677 | new_line_speed = SPEED_10000; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2678 | vars->link_status |= LINK_10GTFD; |
| 2679 | break; |
| 2680 | |
| 2681 | case GP_STATUS_12G_HIG: |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 2682 | new_line_speed = SPEED_12000; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2683 | vars->link_status |= LINK_12GTFD; |
| 2684 | break; |
| 2685 | |
| 2686 | case GP_STATUS_12_5G: |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 2687 | new_line_speed = SPEED_12500; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2688 | vars->link_status |= LINK_12_5GTFD; |
| 2689 | break; |
| 2690 | |
| 2691 | case GP_STATUS_13G: |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 2692 | new_line_speed = SPEED_13000; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2693 | vars->link_status |= LINK_13GTFD; |
| 2694 | break; |
| 2695 | |
| 2696 | case GP_STATUS_15G: |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 2697 | new_line_speed = SPEED_15000; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2698 | vars->link_status |= LINK_15GTFD; |
| 2699 | break; |
| 2700 | |
| 2701 | case GP_STATUS_16G: |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 2702 | new_line_speed = SPEED_16000; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2703 | vars->link_status |= LINK_16GTFD; |
| 2704 | break; |
| 2705 | |
| 2706 | default: |
| 2707 | DP(NETIF_MSG_LINK, |
| 2708 | "link speed unsupported gp_status 0x%x\n", |
| 2709 | gp_status); |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 2710 | return -EINVAL; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2711 | } |
| 2712 | |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 2713 | vars->line_speed = new_line_speed; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2714 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2715 | } else { /* link_down */ |
| 2716 | DP(NETIF_MSG_LINK, "phy link down\n"); |
| 2717 | |
| 2718 | vars->phy_link_up = 0; |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 2719 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2720 | vars->duplex = DUPLEX_FULL; |
David S. Miller | c0700f9 | 2008-12-16 23:53:20 -0800 | [diff] [blame] | 2721 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2722 | vars->mac_type = MAC_TYPE_NONE; |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2723 | |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 2724 | if ((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 2725 | SINGLE_MEDIA_DIRECT(params)) { |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2726 | /* Check signal is detected */ |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 2727 | bnx2x_check_fallback_to_cl37(phy, params); |
Eilon Greenstein | 239d686 | 2009-08-12 08:23:04 +0000 | [diff] [blame] | 2728 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2729 | } |
| 2730 | |
Frans Pop | 2381a55 | 2010-03-24 07:57:36 +0000 | [diff] [blame] | 2731 | 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] | 2732 | gp_status, vars->phy_link_up, vars->line_speed); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 2733 | DP(NETIF_MSG_LINK, "duplex %x flow_ctrl 0x%x link_status 0x%x\n", |
| 2734 | vars->duplex, vars->flow_ctrl, vars->link_status); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2735 | return rc; |
| 2736 | } |
| 2737 | |
Eilon Greenstein | ed8680a | 2009-02-12 08:37:12 +0000 | [diff] [blame] | 2738 | static void bnx2x_set_gmii_tx_driver(struct link_params *params) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2739 | { |
| 2740 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2741 | struct bnx2x_phy *phy = ¶ms->phy[INT_PHY]; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2742 | u16 lp_up2; |
| 2743 | u16 tx_driver; |
Eilon Greenstein | c2c8b03 | 2009-02-12 08:37:14 +0000 | [diff] [blame] | 2744 | u16 bank; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2745 | |
| 2746 | /* read precomp */ |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2747 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2748 | MDIO_REG_BANK_OVER_1G, |
| 2749 | MDIO_OVER_1G_LP_UP2, &lp_up2); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2750 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2751 | /* bits [10:7] at lp_up2, positioned at [15:12] */ |
| 2752 | lp_up2 = (((lp_up2 & MDIO_OVER_1G_LP_UP2_PREEMPHASIS_MASK) >> |
| 2753 | MDIO_OVER_1G_LP_UP2_PREEMPHASIS_SHIFT) << |
| 2754 | MDIO_TX0_TX_DRIVER_PREEMPHASIS_SHIFT); |
| 2755 | |
Eilon Greenstein | c2c8b03 | 2009-02-12 08:37:14 +0000 | [diff] [blame] | 2756 | if (lp_up2 == 0) |
| 2757 | return; |
| 2758 | |
| 2759 | for (bank = MDIO_REG_BANK_TX0; bank <= MDIO_REG_BANK_TX3; |
| 2760 | bank += (MDIO_REG_BANK_TX1 - MDIO_REG_BANK_TX0)) { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2761 | CL22_RD_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2762 | bank, |
| 2763 | MDIO_TX0_TX_DRIVER, &tx_driver); |
Eilon Greenstein | c2c8b03 | 2009-02-12 08:37:14 +0000 | [diff] [blame] | 2764 | |
| 2765 | /* replace tx_driver bits [15:12] */ |
| 2766 | if (lp_up2 != |
| 2767 | (tx_driver & MDIO_TX0_TX_DRIVER_PREEMPHASIS_MASK)) { |
| 2768 | tx_driver &= ~MDIO_TX0_TX_DRIVER_PREEMPHASIS_MASK; |
| 2769 | tx_driver |= lp_up2; |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2770 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2771 | bank, |
| 2772 | MDIO_TX0_TX_DRIVER, tx_driver); |
Eilon Greenstein | c2c8b03 | 2009-02-12 08:37:14 +0000 | [diff] [blame] | 2773 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2774 | } |
| 2775 | } |
| 2776 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 2777 | static int bnx2x_emac_program(struct link_params *params, |
| 2778 | struct link_vars *vars) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2779 | { |
| 2780 | struct bnx2x *bp = params->bp; |
| 2781 | u8 port = params->port; |
| 2782 | u16 mode = 0; |
| 2783 | |
| 2784 | DP(NETIF_MSG_LINK, "setting link speed & duplex\n"); |
| 2785 | bnx2x_bits_dis(bp, GRCBASE_EMAC0 + port*0x400 + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2786 | EMAC_REG_EMAC_MODE, |
| 2787 | (EMAC_MODE_25G_MODE | |
| 2788 | EMAC_MODE_PORT_MII_10M | |
| 2789 | EMAC_MODE_HALF_DUPLEX)); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 2790 | switch (vars->line_speed) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2791 | case SPEED_10: |
| 2792 | mode |= EMAC_MODE_PORT_MII_10M; |
| 2793 | break; |
| 2794 | |
| 2795 | case SPEED_100: |
| 2796 | mode |= EMAC_MODE_PORT_MII; |
| 2797 | break; |
| 2798 | |
| 2799 | case SPEED_1000: |
| 2800 | mode |= EMAC_MODE_PORT_GMII; |
| 2801 | break; |
| 2802 | |
| 2803 | case SPEED_2500: |
| 2804 | mode |= (EMAC_MODE_25G_MODE | EMAC_MODE_PORT_GMII); |
| 2805 | break; |
| 2806 | |
| 2807 | default: |
| 2808 | /* 10G not valid for EMAC */ |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 2809 | DP(NETIF_MSG_LINK, "Invalid line_speed 0x%x\n", |
| 2810 | vars->line_speed); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2811 | return -EINVAL; |
| 2812 | } |
| 2813 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 2814 | if (vars->duplex == DUPLEX_HALF) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2815 | mode |= EMAC_MODE_HALF_DUPLEX; |
| 2816 | bnx2x_bits_en(bp, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2817 | GRCBASE_EMAC0 + port*0x400 + EMAC_REG_EMAC_MODE, |
| 2818 | mode); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2819 | |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 2820 | bnx2x_set_led(params, vars, LED_MODE_OPER, vars->line_speed); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2821 | return 0; |
| 2822 | } |
| 2823 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 2824 | static void bnx2x_set_preemphasis(struct bnx2x_phy *phy, |
| 2825 | struct link_params *params) |
| 2826 | { |
| 2827 | |
| 2828 | u16 bank, i = 0; |
| 2829 | struct bnx2x *bp = params->bp; |
| 2830 | |
| 2831 | for (bank = MDIO_REG_BANK_RX0, i = 0; bank <= MDIO_REG_BANK_RX3; |
| 2832 | bank += (MDIO_REG_BANK_RX1-MDIO_REG_BANK_RX0), i++) { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2833 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 2834 | bank, |
| 2835 | MDIO_RX0_RX_EQ_BOOST, |
| 2836 | phy->rx_preemphasis[i]); |
| 2837 | } |
| 2838 | |
| 2839 | for (bank = MDIO_REG_BANK_TX0, i = 0; bank <= MDIO_REG_BANK_TX3; |
| 2840 | bank += (MDIO_REG_BANK_TX1 - MDIO_REG_BANK_TX0), i++) { |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 2841 | CL22_WR_OVER_CL45(bp, phy, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 2842 | bank, |
| 2843 | MDIO_TX0_TX_DRIVER, |
| 2844 | phy->tx_preemphasis[i]); |
| 2845 | } |
| 2846 | } |
| 2847 | |
| 2848 | static void bnx2x_init_internal_phy(struct bnx2x_phy *phy, |
| 2849 | struct link_params *params, |
| 2850 | struct link_vars *vars) |
| 2851 | { |
| 2852 | struct bnx2x *bp = params->bp; |
| 2853 | u8 enable_cl73 = (SINGLE_MEDIA_DIRECT(params) || |
| 2854 | (params->loopback_mode == LOOPBACK_XGXS)); |
| 2855 | if (!(vars->phy_flags & PHY_SGMII_FLAG)) { |
| 2856 | if (SINGLE_MEDIA_DIRECT(params) && |
| 2857 | (params->feature_config_flags & |
| 2858 | FEATURE_CONFIG_OVERRIDE_PREEMPHASIS_ENABLED)) |
| 2859 | bnx2x_set_preemphasis(phy, params); |
| 2860 | |
| 2861 | /* forced speed requested? */ |
| 2862 | if (vars->line_speed != SPEED_AUTO_NEG || |
| 2863 | (SINGLE_MEDIA_DIRECT(params) && |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 2864 | params->loopback_mode == LOOPBACK_EXT)) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 2865 | DP(NETIF_MSG_LINK, "not SGMII, no AN\n"); |
| 2866 | |
| 2867 | /* disable autoneg */ |
| 2868 | bnx2x_set_autoneg(phy, params, vars, 0); |
| 2869 | |
| 2870 | /* program speed and duplex */ |
| 2871 | bnx2x_program_serdes(phy, params, vars); |
| 2872 | |
| 2873 | } else { /* AN_mode */ |
| 2874 | DP(NETIF_MSG_LINK, "not SGMII, AN\n"); |
| 2875 | |
| 2876 | /* AN enabled */ |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 2877 | bnx2x_set_brcm_cl37_advertisement(phy, params); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 2878 | |
| 2879 | /* program duplex & pause advertisement (for aneg) */ |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 2880 | bnx2x_set_ieee_aneg_advertisement(phy, params, |
| 2881 | vars->ieee_fc); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 2882 | |
| 2883 | /* enable autoneg */ |
| 2884 | bnx2x_set_autoneg(phy, params, vars, enable_cl73); |
| 2885 | |
| 2886 | /* enable and restart AN */ |
| 2887 | bnx2x_restart_autoneg(phy, params, enable_cl73); |
| 2888 | } |
| 2889 | |
| 2890 | } else { /* SGMII mode */ |
| 2891 | DP(NETIF_MSG_LINK, "SGMII\n"); |
| 2892 | |
| 2893 | bnx2x_initialize_sgmii_process(phy, params, vars); |
| 2894 | } |
| 2895 | } |
| 2896 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 2897 | static int bnx2x_init_serdes(struct bnx2x_phy *phy, |
| 2898 | struct link_params *params, |
| 2899 | struct link_vars *vars) |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 2900 | { |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 2901 | int rc; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 2902 | vars->phy_flags |= PHY_SGMII_FLAG; |
| 2903 | bnx2x_calc_ieee_aneg_adv(phy, params, &vars->ieee_fc); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2904 | bnx2x_set_aer_mmd_serdes(params->bp, phy); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 2905 | rc = bnx2x_reset_unicore(params, phy, 1); |
| 2906 | /* reset the SerDes and wait for reset bit return low */ |
| 2907 | if (rc != 0) |
| 2908 | return rc; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2909 | bnx2x_set_aer_mmd_serdes(params->bp, phy); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2910 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 2911 | return rc; |
| 2912 | } |
| 2913 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 2914 | static int bnx2x_init_xgxs(struct bnx2x_phy *phy, |
| 2915 | struct link_params *params, |
| 2916 | struct link_vars *vars) |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 2917 | { |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 2918 | int rc; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 2919 | vars->phy_flags = PHY_XGXS_FLAG; |
| 2920 | if ((phy->req_line_speed && |
| 2921 | ((phy->req_line_speed == SPEED_100) || |
| 2922 | (phy->req_line_speed == SPEED_10))) || |
| 2923 | (!phy->req_line_speed && |
| 2924 | (phy->speed_cap_mask >= |
| 2925 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_FULL) && |
| 2926 | (phy->speed_cap_mask < |
| 2927 | PORT_HW_CFG_SPEED_CAPABILITY_D0_1G) |
| 2928 | )) |
| 2929 | vars->phy_flags |= PHY_SGMII_FLAG; |
| 2930 | else |
| 2931 | vars->phy_flags &= ~PHY_SGMII_FLAG; |
| 2932 | |
| 2933 | bnx2x_calc_ieee_aneg_adv(phy, params, &vars->ieee_fc); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2934 | bnx2x_set_aer_mmd_xgxs(params, phy); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 2935 | bnx2x_set_master_ln(params, phy); |
| 2936 | |
| 2937 | rc = bnx2x_reset_unicore(params, phy, 0); |
| 2938 | /* reset the SerDes and wait for reset bit return low */ |
| 2939 | if (rc != 0) |
| 2940 | return rc; |
| 2941 | |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 2942 | bnx2x_set_aer_mmd_xgxs(params, phy); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 2943 | |
| 2944 | /* setting the masterLn_def again after the reset */ |
| 2945 | bnx2x_set_master_ln(params, phy); |
| 2946 | bnx2x_set_swap_lanes(params, phy); |
| 2947 | |
| 2948 | return rc; |
| 2949 | } |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 2950 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 2951 | static u16 bnx2x_wait_reset_complete(struct bnx2x *bp, |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 2952 | struct bnx2x_phy *phy, |
| 2953 | struct link_params *params) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2954 | { |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 2955 | u16 cnt, ctrl; |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 2956 | /* Wait for soft reset to get cleared up to 1 sec */ |
Yaniv Rosner | 62b29a5 | 2010-09-07 11:40:58 +0000 | [diff] [blame] | 2957 | for (cnt = 0; cnt < 1000; cnt++) { |
| 2958 | bnx2x_cl45_read(bp, phy, |
| 2959 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, &ctrl); |
| 2960 | if (!(ctrl & (1<<15))) |
| 2961 | break; |
| 2962 | msleep(1); |
| 2963 | } |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 2964 | |
| 2965 | if (cnt == 1000) |
| 2966 | netdev_err(bp->dev, "Warning: PHY was not initialized," |
| 2967 | " Port %d\n", |
| 2968 | params->port); |
Yaniv Rosner | 62b29a5 | 2010-09-07 11:40:58 +0000 | [diff] [blame] | 2969 | DP(NETIF_MSG_LINK, "control reg 0x%x (after %d ms)\n", ctrl, cnt); |
| 2970 | return cnt; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 2971 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2972 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2973 | static void bnx2x_link_int_enable(struct link_params *params) |
| 2974 | { |
| 2975 | u8 port = params->port; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2976 | u32 mask; |
| 2977 | struct bnx2x *bp = params->bp; |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 2978 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 2979 | /* 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] | 2980 | if (params->switch_cfg == SWITCH_CFG_10G) { |
| 2981 | mask = (NIG_MASK_XGXS0_LINK10G | |
| 2982 | NIG_MASK_XGXS0_LINK_STATUS); |
| 2983 | DP(NETIF_MSG_LINK, "enabled XGXS interrupt\n"); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2984 | if (!(SINGLE_MEDIA_DIRECT(params)) && |
| 2985 | params->phy[INT_PHY].type != |
| 2986 | PORT_HW_CFG_XGXS_EXT_PHY_TYPE_FAILURE) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2987 | mask |= NIG_MASK_MI_INT; |
| 2988 | DP(NETIF_MSG_LINK, "enabled external phy int\n"); |
| 2989 | } |
| 2990 | |
| 2991 | } else { /* SerDes */ |
| 2992 | mask = NIG_MASK_SERDES0_LINK_STATUS; |
| 2993 | DP(NETIF_MSG_LINK, "enabled SerDes interrupt\n"); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 2994 | if (!(SINGLE_MEDIA_DIRECT(params)) && |
| 2995 | params->phy[INT_PHY].type != |
| 2996 | PORT_HW_CFG_SERDES_EXT_PHY_TYPE_NOT_CONN) { |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 2997 | mask |= NIG_MASK_MI_INT; |
| 2998 | DP(NETIF_MSG_LINK, "enabled external phy int\n"); |
| 2999 | } |
| 3000 | } |
| 3001 | bnx2x_bits_en(bp, |
| 3002 | NIG_REG_MASK_INTERRUPT_PORT0 + port*4, |
| 3003 | mask); |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 3004 | |
| 3005 | 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] | 3006 | (params->switch_cfg == SWITCH_CFG_10G), |
| 3007 | REG_RD(bp, NIG_REG_STATUS_INTERRUPT_PORT0 + port*4)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3008 | DP(NETIF_MSG_LINK, " int_mask 0x%x, MI_INT %x, SERDES_LINK %x\n", |
| 3009 | REG_RD(bp, NIG_REG_MASK_INTERRUPT_PORT0 + port*4), |
| 3010 | REG_RD(bp, NIG_REG_EMAC0_STATUS_MISC_MI_INT + port*0x18), |
| 3011 | REG_RD(bp, NIG_REG_SERDES0_STATUS_LINK_STATUS+port*0x3c)); |
| 3012 | DP(NETIF_MSG_LINK, " 10G %x, XGXS_LINK %x\n", |
| 3013 | REG_RD(bp, NIG_REG_XGXS0_STATUS_LINK10G + port*0x68), |
| 3014 | REG_RD(bp, NIG_REG_XGXS0_STATUS_LINK_STATUS + port*0x68)); |
| 3015 | } |
| 3016 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3017 | static void bnx2x_rearm_latch_signal(struct bnx2x *bp, u8 port, |
| 3018 | u8 exp_mi_int) |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 3019 | { |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3020 | u32 latch_status = 0; |
| 3021 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3022 | /* |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3023 | * Disable the MI INT ( external phy int ) by writing 1 to the |
| 3024 | * status register. Link down indication is high-active-signal, |
| 3025 | * 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] | 3026 | */ |
| 3027 | /* Read Latched signals */ |
| 3028 | latch_status = REG_RD(bp, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3029 | NIG_REG_LATCH_STATUS_0 + port*8); |
| 3030 | DP(NETIF_MSG_LINK, "latch_status = 0x%x\n", latch_status); |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 3031 | /* Handle only those with latched-signal=up.*/ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3032 | if (exp_mi_int) |
| 3033 | bnx2x_bits_en(bp, |
| 3034 | NIG_REG_STATUS_INTERRUPT_PORT0 |
| 3035 | + port*4, |
| 3036 | NIG_STATUS_EMAC0_MI_INT); |
| 3037 | else |
| 3038 | bnx2x_bits_dis(bp, |
| 3039 | NIG_REG_STATUS_INTERRUPT_PORT0 |
| 3040 | + port*4, |
| 3041 | NIG_STATUS_EMAC0_MI_INT); |
| 3042 | |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 3043 | if (latch_status & 1) { |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3044 | |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 3045 | /* For all latched-signal=up : Re-Arm Latch signals */ |
| 3046 | REG_WR(bp, NIG_REG_LATCH_STATUS_0 + port*8, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3047 | (latch_status & 0xfffe) | (latch_status & 1)); |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 3048 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3049 | /* For all latched-signal=up,Write original_signal to status */ |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 3050 | } |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3051 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3052 | static void bnx2x_link_int_ack(struct link_params *params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3053 | struct link_vars *vars, u8 is_10g) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3054 | { |
| 3055 | struct bnx2x *bp = params->bp; |
| 3056 | u8 port = params->port; |
| 3057 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3058 | /* |
| 3059 | * First reset all status we assume only one line will be |
| 3060 | * change at a time |
| 3061 | */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3062 | bnx2x_bits_dis(bp, NIG_REG_STATUS_INTERRUPT_PORT0 + port*4, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3063 | (NIG_STATUS_XGXS0_LINK10G | |
| 3064 | NIG_STATUS_XGXS0_LINK_STATUS | |
| 3065 | NIG_STATUS_SERDES0_LINK_STATUS)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3066 | if (vars->phy_link_up) { |
| 3067 | if (is_10g) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3068 | /* |
| 3069 | * Disable the 10G link interrupt by writing 1 to the |
| 3070 | * status register |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3071 | */ |
| 3072 | DP(NETIF_MSG_LINK, "10G XGXS phy link up\n"); |
| 3073 | bnx2x_bits_en(bp, |
| 3074 | NIG_REG_STATUS_INTERRUPT_PORT0 + port*4, |
| 3075 | NIG_STATUS_XGXS0_LINK10G); |
| 3076 | |
| 3077 | } else if (params->switch_cfg == SWITCH_CFG_10G) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3078 | /* |
| 3079 | * Disable the link interrupt by writing 1 to the |
| 3080 | * relevant lane in the status register |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3081 | */ |
| 3082 | u32 ser_lane = ((params->lane_config & |
| 3083 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_MASK) >> |
| 3084 | PORT_HW_CFG_LANE_SWAP_CFG_MASTER_SHIFT); |
| 3085 | |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 3086 | DP(NETIF_MSG_LINK, "%d speed XGXS phy link up\n", |
| 3087 | vars->line_speed); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3088 | bnx2x_bits_en(bp, |
| 3089 | NIG_REG_STATUS_INTERRUPT_PORT0 + port*4, |
| 3090 | ((1 << ser_lane) << |
| 3091 | NIG_STATUS_XGXS0_LINK_STATUS_SIZE)); |
| 3092 | |
| 3093 | } else { /* SerDes */ |
| 3094 | DP(NETIF_MSG_LINK, "SerDes phy link up\n"); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3095 | /* |
| 3096 | * Disable the link interrupt by writing 1 to the status |
| 3097 | * register |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3098 | */ |
| 3099 | bnx2x_bits_en(bp, |
| 3100 | NIG_REG_STATUS_INTERRUPT_PORT0 + port*4, |
| 3101 | NIG_STATUS_SERDES0_LINK_STATUS); |
| 3102 | } |
| 3103 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3104 | } |
| 3105 | } |
| 3106 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 3107 | static int bnx2x_format_ver(u32 num, u8 *str, u16 *len) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3108 | { |
| 3109 | u8 *str_ptr = str; |
| 3110 | u32 mask = 0xf0000000; |
| 3111 | u8 shift = 8*4; |
| 3112 | u8 digit; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3113 | u8 remove_leading_zeros = 1; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3114 | if (*len < 10) { |
Frederik Schwarzer | 025dfda | 2008-10-16 19:02:37 +0200 | [diff] [blame] | 3115 | /* Need more than 10chars for this format */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3116 | *str_ptr = '\0'; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3117 | (*len)--; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3118 | return -EINVAL; |
| 3119 | } |
| 3120 | while (shift > 0) { |
| 3121 | |
| 3122 | shift -= 4; |
| 3123 | digit = ((num & mask) >> shift); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3124 | if (digit == 0 && remove_leading_zeros) { |
| 3125 | mask = mask >> 4; |
| 3126 | continue; |
| 3127 | } else if (digit < 0xa) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3128 | *str_ptr = digit + '0'; |
| 3129 | else |
| 3130 | *str_ptr = digit - 0xa + 'a'; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3131 | remove_leading_zeros = 0; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3132 | str_ptr++; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3133 | (*len)--; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3134 | mask = mask >> 4; |
| 3135 | if (shift == 4*4) { |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3136 | *str_ptr = '.'; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3137 | str_ptr++; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3138 | (*len)--; |
| 3139 | remove_leading_zeros = 1; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3140 | } |
| 3141 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3142 | return 0; |
| 3143 | } |
| 3144 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3145 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 3146 | 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] | 3147 | { |
| 3148 | str[0] = '\0'; |
| 3149 | (*len)--; |
| 3150 | return 0; |
| 3151 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3152 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 3153 | int bnx2x_get_ext_phy_fw_version(struct link_params *params, u8 driver_loaded, |
| 3154 | u8 *version, u16 len) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3155 | { |
Julia Lawall | 0376d5b | 2009-07-19 05:26:35 +0000 | [diff] [blame] | 3156 | struct bnx2x *bp; |
Eilon Greenstein | a35da8d | 2009-02-12 08:37:02 +0000 | [diff] [blame] | 3157 | u32 spirom_ver = 0; |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 3158 | int status = 0; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3159 | u8 *ver_p = version; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3160 | u16 remain_len = len; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3161 | if (version == NULL || params == NULL) |
| 3162 | return -EINVAL; |
Julia Lawall | 0376d5b | 2009-07-19 05:26:35 +0000 | [diff] [blame] | 3163 | bp = params->bp; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3164 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3165 | /* Extract first external phy*/ |
| 3166 | version[0] = '\0'; |
| 3167 | spirom_ver = REG_RD(bp, params->phy[EXT_PHY1].ver_addr); |
Eilon Greenstein | a35da8d | 2009-02-12 08:37:02 +0000 | [diff] [blame] | 3168 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3169 | if (params->phy[EXT_PHY1].format_fw_ver) { |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3170 | status |= params->phy[EXT_PHY1].format_fw_ver(spirom_ver, |
| 3171 | ver_p, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3172 | &remain_len); |
| 3173 | ver_p += (len - remain_len); |
| 3174 | } |
| 3175 | if ((params->num_phys == MAX_PHYS) && |
| 3176 | (params->phy[EXT_PHY2].ver_addr != 0)) { |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3177 | spirom_ver = REG_RD(bp, params->phy[EXT_PHY2].ver_addr); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3178 | if (params->phy[EXT_PHY2].format_fw_ver) { |
| 3179 | *ver_p = '/'; |
| 3180 | ver_p++; |
| 3181 | remain_len--; |
| 3182 | status |= params->phy[EXT_PHY2].format_fw_ver( |
| 3183 | spirom_ver, |
| 3184 | ver_p, |
| 3185 | &remain_len); |
| 3186 | ver_p = version + (len - remain_len); |
| 3187 | } |
| 3188 | } |
| 3189 | *ver_p = '\0'; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3190 | return status; |
| 3191 | } |
| 3192 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3193 | static void bnx2x_set_xgxs_loopback(struct bnx2x_phy *phy, |
Yaniv Rosner | 62b29a5 | 2010-09-07 11:40:58 +0000 | [diff] [blame] | 3194 | struct link_params *params) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3195 | { |
| 3196 | u8 port = params->port; |
| 3197 | struct bnx2x *bp = params->bp; |
| 3198 | |
Yaniv Rosner | 62b29a5 | 2010-09-07 11:40:58 +0000 | [diff] [blame] | 3199 | if (phy->req_line_speed != SPEED_1000) { |
Eilon Greenstein | 6378c02 | 2008-08-13 15:59:25 -0700 | [diff] [blame] | 3200 | u32 md_devad; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3201 | |
| 3202 | DP(NETIF_MSG_LINK, "XGXS 10G loopback enable\n"); |
| 3203 | |
| 3204 | /* change the uni_phy_addr in the nig */ |
| 3205 | md_devad = REG_RD(bp, (NIG_REG_XGXS0_CTRL_MD_DEVAD + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3206 | port*0x18)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3207 | |
| 3208 | REG_WR(bp, NIG_REG_XGXS0_CTRL_MD_DEVAD + port*0x18, 0x5); |
| 3209 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3210 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3211 | 5, |
| 3212 | (MDIO_REG_BANK_AER_BLOCK + |
| 3213 | (MDIO_AER_BLOCK_AER_REG & 0xf)), |
| 3214 | 0x2800); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3215 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3216 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3217 | 5, |
| 3218 | (MDIO_REG_BANK_CL73_IEEEB0 + |
| 3219 | (MDIO_CL73_IEEEB0_CL73_AN_CONTROL & 0xf)), |
| 3220 | 0x6041); |
Eilon Greenstein | 3858276 | 2009-01-14 06:44:16 +0000 | [diff] [blame] | 3221 | msleep(200); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3222 | /* set aer mmd back */ |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 3223 | bnx2x_set_aer_mmd_xgxs(params, phy); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3224 | |
| 3225 | /* and md_devad */ |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3226 | 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] | 3227 | } else { |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3228 | u16 mii_ctrl; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3229 | DP(NETIF_MSG_LINK, "XGXS 1G loopback enable\n"); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3230 | bnx2x_cl45_read(bp, phy, 5, |
| 3231 | (MDIO_REG_BANK_COMBO_IEEE0 + |
| 3232 | (MDIO_COMBO_IEEE0_MII_CONTROL & 0xf)), |
| 3233 | &mii_ctrl); |
| 3234 | bnx2x_cl45_write(bp, phy, 5, |
| 3235 | (MDIO_REG_BANK_COMBO_IEEE0 + |
| 3236 | (MDIO_COMBO_IEEE0_MII_CONTROL & 0xf)), |
| 3237 | mii_ctrl | |
| 3238 | MDIO_COMBO_IEEO_MII_CONTROL_LOOPBACK); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3239 | } |
| 3240 | } |
| 3241 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 3242 | int bnx2x_set_led(struct link_params *params, |
| 3243 | struct link_vars *vars, u8 mode, u32 speed) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3244 | { |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 3245 | u8 port = params->port; |
| 3246 | u16 hw_led_mode = params->hw_led_mode; |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 3247 | int rc = 0; |
| 3248 | u8 phy_idx; |
Eilon Greenstein | 345b5d5 | 2008-08-13 15:58:12 -0700 | [diff] [blame] | 3249 | u32 tmp; |
| 3250 | u32 emac_base = port ? GRCBASE_EMAC1 : GRCBASE_EMAC0; |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 3251 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3252 | DP(NETIF_MSG_LINK, "bnx2x_set_led: port %x, mode %d\n", port, mode); |
| 3253 | DP(NETIF_MSG_LINK, "speed 0x%x, hw_led_mode 0x%x\n", |
| 3254 | speed, hw_led_mode); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 3255 | /* In case */ |
| 3256 | for (phy_idx = EXT_PHY1; phy_idx < MAX_PHYS; phy_idx++) { |
| 3257 | if (params->phy[phy_idx].set_link_led) { |
| 3258 | params->phy[phy_idx].set_link_led( |
| 3259 | ¶ms->phy[phy_idx], params, mode); |
| 3260 | } |
| 3261 | } |
| 3262 | |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3263 | switch (mode) { |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 3264 | case LED_MODE_FRONT_PANEL_OFF: |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3265 | case LED_MODE_OFF: |
| 3266 | REG_WR(bp, NIG_REG_LED_10G_P0 + port*4, 0); |
| 3267 | REG_WR(bp, NIG_REG_LED_MODE_P0 + port*4, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3268 | SHARED_HW_CFG_LED_MAC1); |
Eilon Greenstein | 345b5d5 | 2008-08-13 15:58:12 -0700 | [diff] [blame] | 3269 | |
| 3270 | tmp = EMAC_RD(bp, EMAC_REG_EMAC_LED); |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 3271 | EMAC_WR(bp, EMAC_REG_EMAC_LED, (tmp | EMAC_LED_OVERRIDE)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3272 | break; |
| 3273 | |
| 3274 | case LED_MODE_OPER: |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3275 | /* |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 3276 | * For all other phys, OPER mode is same as ON, so in case |
| 3277 | * link is down, do nothing |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3278 | */ |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 3279 | if (!vars->link_up) |
| 3280 | break; |
| 3281 | case LED_MODE_ON: |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 3282 | if (((params->phy[EXT_PHY1].type == |
| 3283 | PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727) || |
| 3284 | (params->phy[EXT_PHY1].type == |
| 3285 | PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8722)) && |
Yaniv Rosner | 1f48353 | 2011-01-18 04:33:31 +0000 | [diff] [blame] | 3286 | CHIP_IS_E2(bp) && params->num_phys == 2) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3287 | /* |
| 3288 | * This is a work-around for E2+8727 Configurations |
| 3289 | */ |
Yaniv Rosner | 1f48353 | 2011-01-18 04:33:31 +0000 | [diff] [blame] | 3290 | if (mode == LED_MODE_ON || |
| 3291 | speed == SPEED_10000){ |
| 3292 | REG_WR(bp, NIG_REG_LED_MODE_P0 + port*4, 0); |
| 3293 | REG_WR(bp, NIG_REG_LED_10G_P0 + port*4, 1); |
| 3294 | |
| 3295 | tmp = EMAC_RD(bp, EMAC_REG_EMAC_LED); |
| 3296 | EMAC_WR(bp, EMAC_REG_EMAC_LED, |
| 3297 | (tmp | EMAC_LED_OVERRIDE)); |
| 3298 | return rc; |
| 3299 | } |
| 3300 | } else if (SINGLE_MEDIA_DIRECT(params)) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3301 | /* |
| 3302 | * This is a work-around for HW issue found when link |
| 3303 | * is up in CL73 |
| 3304 | */ |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 3305 | REG_WR(bp, NIG_REG_LED_MODE_P0 + port*4, 0); |
| 3306 | REG_WR(bp, NIG_REG_LED_10G_P0 + port*4, 1); |
| 3307 | } else { |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3308 | 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] | 3309 | } |
| 3310 | |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3311 | 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] | 3312 | /* Set blinking rate to ~15.9Hz */ |
| 3313 | REG_WR(bp, NIG_REG_LED_CONTROL_BLINK_RATE_P0 + port*4, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3314 | LED_BLINK_RATE_VAL); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3315 | REG_WR(bp, NIG_REG_LED_CONTROL_BLINK_RATE_ENA_P0 + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3316 | port*4, 1); |
Eilon Greenstein | 345b5d5 | 2008-08-13 15:58:12 -0700 | [diff] [blame] | 3317 | tmp = EMAC_RD(bp, EMAC_REG_EMAC_LED); |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3318 | EMAC_WR(bp, EMAC_REG_EMAC_LED, (tmp & (~EMAC_LED_OVERRIDE))); |
Eilon Greenstein | 345b5d5 | 2008-08-13 15:58:12 -0700 | [diff] [blame] | 3319 | |
Yaniv Rosner | 7846e47 | 2009-11-05 19:18:07 +0200 | [diff] [blame] | 3320 | if (CHIP_IS_E1(bp) && |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 3321 | ((speed == SPEED_2500) || |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3322 | (speed == SPEED_1000) || |
| 3323 | (speed == SPEED_100) || |
| 3324 | (speed == SPEED_10))) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3325 | /* |
| 3326 | * On Everest 1 Ax chip versions for speeds less than |
| 3327 | * 10G LED scheme is different |
| 3328 | */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3329 | REG_WR(bp, NIG_REG_LED_CONTROL_OVERRIDE_TRAFFIC_P0 |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3330 | + port*4, 1); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3331 | REG_WR(bp, NIG_REG_LED_CONTROL_TRAFFIC_P0 + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3332 | port*4, 0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3333 | REG_WR(bp, NIG_REG_LED_CONTROL_BLINK_TRAFFIC_P0 + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3334 | port*4, 1); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3335 | } |
| 3336 | break; |
| 3337 | |
| 3338 | default: |
| 3339 | rc = -EINVAL; |
| 3340 | DP(NETIF_MSG_LINK, "bnx2x_set_led: Invalid led mode %d\n", |
| 3341 | mode); |
| 3342 | break; |
| 3343 | } |
| 3344 | return rc; |
| 3345 | |
| 3346 | } |
| 3347 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3348 | /* |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3349 | * This function comes to reflect the actual link state read DIRECTLY from the |
| 3350 | * HW |
| 3351 | */ |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 3352 | int bnx2x_test_link(struct link_params *params, struct link_vars *vars, |
| 3353 | u8 is_serdes) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3354 | { |
| 3355 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 3356 | u16 gp_status = 0, phy_index = 0; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3357 | u8 ext_phy_link_up = 0, serdes_phy_type; |
| 3358 | struct link_vars temp_vars; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3359 | |
Yaniv Rosner | cd2be89 | 2011-01-31 04:21:45 +0000 | [diff] [blame] | 3360 | CL22_RD_OVER_CL45(bp, ¶ms->phy[INT_PHY], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3361 | MDIO_REG_BANK_GP_STATUS, |
| 3362 | MDIO_GP_STATUS_TOP_AN_STATUS1, |
| 3363 | &gp_status); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3364 | /* 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] | 3365 | if (!(gp_status & MDIO_GP_STATUS_TOP_AN_STATUS1_LINK_STATUS)) |
| 3366 | return -ESRCH; |
| 3367 | |
| 3368 | switch (params->num_phys) { |
| 3369 | case 1: |
| 3370 | /* No external PHY */ |
| 3371 | return 0; |
| 3372 | case 2: |
| 3373 | ext_phy_link_up = params->phy[EXT_PHY1].read_status( |
| 3374 | ¶ms->phy[EXT_PHY1], |
| 3375 | params, &temp_vars); |
| 3376 | break; |
| 3377 | case 3: /* Dual Media */ |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 3378 | for (phy_index = EXT_PHY1; phy_index < params->num_phys; |
| 3379 | phy_index++) { |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3380 | serdes_phy_type = ((params->phy[phy_index].media_type == |
| 3381 | ETH_PHY_SFP_FIBER) || |
| 3382 | (params->phy[phy_index].media_type == |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 3383 | ETH_PHY_XFP_FIBER) || |
| 3384 | (params->phy[phy_index].media_type == |
| 3385 | ETH_PHY_DA_TWINAX)); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3386 | |
| 3387 | if (is_serdes != serdes_phy_type) |
| 3388 | continue; |
| 3389 | if (params->phy[phy_index].read_status) { |
| 3390 | ext_phy_link_up |= |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 3391 | params->phy[phy_index].read_status( |
| 3392 | ¶ms->phy[phy_index], |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3393 | params, &temp_vars); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3394 | } |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 3395 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3396 | break; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3397 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3398 | if (ext_phy_link_up) |
| 3399 | return 0; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3400 | return -ESRCH; |
| 3401 | } |
| 3402 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 3403 | static int bnx2x_link_initialize(struct link_params *params, |
| 3404 | struct link_vars *vars) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3405 | { |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 3406 | int rc = 0; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3407 | u8 phy_index, non_ext_phy; |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 3408 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3409 | /* |
| 3410 | * In case of external phy existence, the line speed would be the |
| 3411 | * line speed linked up by the external phy. In case it is direct |
| 3412 | * only, then the line_speed during initialization will be |
| 3413 | * equal to the req_line_speed |
| 3414 | */ |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 3415 | vars->line_speed = params->phy[INT_PHY].req_line_speed; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3416 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3417 | /* |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 3418 | * Initialize the internal phy in case this is a direct board |
| 3419 | * (no external phys), or this board has external phy which requires |
| 3420 | * to first. |
| 3421 | */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3422 | |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 3423 | if (params->phy[INT_PHY].config_init) |
| 3424 | params->phy[INT_PHY].config_init( |
| 3425 | ¶ms->phy[INT_PHY], |
| 3426 | params, vars); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3427 | |
| 3428 | /* init ext phy and enable link state int */ |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 3429 | non_ext_phy = (SINGLE_MEDIA_DIRECT(params) || |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3430 | (params->loopback_mode == LOOPBACK_XGXS)); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3431 | |
| 3432 | if (non_ext_phy || |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 3433 | (params->phy[EXT_PHY1].flags & FLAGS_INIT_XGXS_FIRST) || |
Eilon Greenstein | 8660d8c | 2009-03-02 08:01:02 +0000 | [diff] [blame] | 3434 | (params->loopback_mode == LOOPBACK_EXT_PHY)) { |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 3435 | struct bnx2x_phy *phy = ¶ms->phy[INT_PHY]; |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3436 | if (vars->line_speed == SPEED_AUTO_NEG) |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 3437 | bnx2x_set_parallel_detection(phy, params); |
| 3438 | bnx2x_init_internal_phy(phy, params, vars); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3439 | } |
| 3440 | |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 3441 | /* Init external phy*/ |
Yaniv Rosner | fd36a2e | 2011-05-31 21:29:05 +0000 | [diff] [blame^] | 3442 | if (non_ext_phy) { |
| 3443 | if (params->phy[INT_PHY].supported & |
| 3444 | SUPPORTED_FIBRE) |
| 3445 | vars->link_status |= LINK_STATUS_SERDES_LINK; |
| 3446 | } else { |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3447 | for (phy_index = EXT_PHY1; phy_index < params->num_phys; |
| 3448 | phy_index++) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3449 | /* |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3450 | * No need to initialize second phy in case of first |
| 3451 | * phy only selection. In case of second phy, we do |
| 3452 | * need to initialize the first phy, since they are |
| 3453 | * connected. |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3454 | */ |
Yaniv Rosner | fd36a2e | 2011-05-31 21:29:05 +0000 | [diff] [blame^] | 3455 | if (params->phy[phy_index].supported & |
| 3456 | SUPPORTED_FIBRE) |
| 3457 | vars->link_status |= LINK_STATUS_SERDES_LINK; |
| 3458 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3459 | if (phy_index == EXT_PHY2 && |
| 3460 | (bnx2x_phy_selection(params) == |
| 3461 | PORT_HW_CFG_PHY_SELECTION_FIRST_PHY)) { |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 3462 | DP(NETIF_MSG_LINK, "Not initializing" |
| 3463 | " second phy\n"); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3464 | continue; |
| 3465 | } |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3466 | params->phy[phy_index].config_init( |
| 3467 | ¶ms->phy[phy_index], |
| 3468 | params, vars); |
| 3469 | } |
Yaniv Rosner | fd36a2e | 2011-05-31 21:29:05 +0000 | [diff] [blame^] | 3470 | } |
Yaniv Rosner | d90d96b | 2010-09-07 11:41:04 +0000 | [diff] [blame] | 3471 | /* Reset the interrupt indication after phy was initialized */ |
| 3472 | bnx2x_bits_dis(bp, NIG_REG_STATUS_INTERRUPT_PORT0 + |
| 3473 | params->port*4, |
| 3474 | (NIG_STATUS_XGXS0_LINK10G | |
| 3475 | NIG_STATUS_XGXS0_LINK_STATUS | |
| 3476 | NIG_STATUS_SERDES0_LINK_STATUS | |
| 3477 | NIG_MASK_MI_INT)); |
Yaniv Rosner | fd36a2e | 2011-05-31 21:29:05 +0000 | [diff] [blame^] | 3478 | bnx2x_update_mng(params, vars->link_status); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3479 | return rc; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3480 | } |
| 3481 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3482 | static void bnx2x_int_link_reset(struct bnx2x_phy *phy, |
| 3483 | struct link_params *params) |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3484 | { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3485 | /* reset the SerDes/XGXS */ |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3486 | REG_WR(params->bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_3_CLEAR, |
| 3487 | (0x1ff << (params->port*16))); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3488 | } |
| 3489 | |
| 3490 | static void bnx2x_common_ext_link_reset(struct bnx2x_phy *phy, |
| 3491 | struct link_params *params) |
| 3492 | { |
| 3493 | struct bnx2x *bp = params->bp; |
| 3494 | u8 gpio_port; |
| 3495 | /* HW reset */ |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 3496 | if (CHIP_IS_E2(bp)) |
| 3497 | gpio_port = BP_PATH(bp); |
| 3498 | else |
| 3499 | gpio_port = params->port; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3500 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3501 | MISC_REGISTERS_GPIO_OUTPUT_LOW, |
| 3502 | gpio_port); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3503 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3504 | MISC_REGISTERS_GPIO_OUTPUT_LOW, |
| 3505 | gpio_port); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3506 | DP(NETIF_MSG_LINK, "reset external PHY\n"); |
| 3507 | } |
| 3508 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 3509 | static int bnx2x_update_link_down(struct link_params *params, |
| 3510 | struct link_vars *vars) |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3511 | { |
| 3512 | struct bnx2x *bp = params->bp; |
| 3513 | u8 port = params->port; |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 3514 | |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3515 | DP(NETIF_MSG_LINK, "Port %x: Link is down\n", port); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 3516 | bnx2x_set_led(params, vars, LED_MODE_OFF, 0); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3517 | |
| 3518 | /* indicate no mac active */ |
| 3519 | vars->mac_type = MAC_TYPE_NONE; |
| 3520 | |
| 3521 | /* update shared memory */ |
Yaniv Rosner | fd36a2e | 2011-05-31 21:29:05 +0000 | [diff] [blame^] | 3522 | vars->link_status &= ~(LINK_STATUS_SPEED_AND_DUPLEX_MASK | |
| 3523 | LINK_STATUS_LINK_UP | |
| 3524 | LINK_STATUS_AUTO_NEGOTIATE_COMPLETE | |
| 3525 | LINK_STATUS_RX_FLOW_CONTROL_FLAG_MASK | |
| 3526 | LINK_STATUS_TX_FLOW_CONTROL_FLAG_MASK | |
| 3527 | LINK_STATUS_PARALLEL_DETECTION_FLAG_MASK); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3528 | vars->line_speed = 0; |
| 3529 | bnx2x_update_mng(params, vars->link_status); |
| 3530 | |
| 3531 | /* activate nig drain */ |
| 3532 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + port*4, 1); |
| 3533 | |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 3534 | /* disable emac */ |
| 3535 | REG_WR(bp, NIG_REG_NIG_EMAC0_EN + port*4, 0); |
| 3536 | |
| 3537 | msleep(10); |
| 3538 | |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3539 | /* reset BigMac */ |
| 3540 | bnx2x_bmac_rx_disable(bp, params->port); |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3541 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_CLEAR, |
| 3542 | (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << port)); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3543 | return 0; |
| 3544 | } |
| 3545 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 3546 | static int bnx2x_update_link_up(struct link_params *params, |
| 3547 | struct link_vars *vars, |
| 3548 | u8 link_10g) |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3549 | { |
| 3550 | struct bnx2x *bp = params->bp; |
| 3551 | u8 port = params->port; |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 3552 | int rc = 0; |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 3553 | |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3554 | vars->link_status |= LINK_STATUS_LINK_UP; |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 3555 | |
Yaniv Rosner | 7aa0711 | 2010-09-07 11:41:01 +0000 | [diff] [blame] | 3556 | if (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX) |
| 3557 | vars->link_status |= |
| 3558 | LINK_STATUS_TX_FLOW_CONTROL_ENABLED; |
| 3559 | |
| 3560 | if (vars->flow_ctrl & BNX2X_FLOW_CTRL_RX) |
| 3561 | vars->link_status |= |
| 3562 | LINK_STATUS_RX_FLOW_CONTROL_ENABLED; |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 3563 | |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3564 | if (link_10g) { |
| 3565 | bnx2x_bmac_enable(params, vars, 0); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 3566 | bnx2x_set_led(params, vars, |
| 3567 | LED_MODE_OPER, SPEED_10000); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3568 | } else { |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3569 | rc = bnx2x_emac_program(params, vars); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3570 | |
Yaniv Rosner | 0c786f0 | 2009-11-05 19:18:32 +0200 | [diff] [blame] | 3571 | bnx2x_emac_enable(params, vars, 0); |
| 3572 | |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3573 | /* AN complete? */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 3574 | if ((vars->link_status & LINK_STATUS_AUTO_NEGOTIATE_COMPLETE) |
| 3575 | && (!(vars->phy_flags & PHY_SGMII_FLAG)) && |
| 3576 | SINGLE_MEDIA_DIRECT(params)) |
| 3577 | bnx2x_set_gmii_tx_driver(params); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3578 | } |
| 3579 | |
| 3580 | /* PBF - link up */ |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 3581 | if (!(CHIP_IS_E2(bp))) |
| 3582 | rc |= bnx2x_pbf_update(params, vars->flow_ctrl, |
| 3583 | vars->line_speed); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3584 | |
| 3585 | /* disable drain */ |
| 3586 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + port*4, 0); |
| 3587 | |
| 3588 | /* update shared memory */ |
| 3589 | bnx2x_update_mng(params, vars->link_status); |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 3590 | msleep(20); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3591 | return rc; |
| 3592 | } |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3593 | /* |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3594 | * The bnx2x_link_update function should be called upon link |
| 3595 | * interrupt. |
| 3596 | * Link is considered up as follows: |
| 3597 | * - DIRECT_SINGLE_MEDIA - Only XGXS link (internal link) needs |
| 3598 | * to be up |
| 3599 | * - SINGLE_MEDIA - The link between the 577xx and the external |
| 3600 | * phy (XGXS) need to up as well as the external link of the |
| 3601 | * phy (PHY_EXT1) |
| 3602 | * - DUAL_MEDIA - The link between the 577xx and the first |
| 3603 | * external phy needs to be up, and at least one of the 2 |
| 3604 | * external phy link must be up. |
Yaniv Rosner | 62b29a5 | 2010-09-07 11:40:58 +0000 | [diff] [blame] | 3605 | */ |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 3606 | int bnx2x_link_update(struct link_params *params, struct link_vars *vars) |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3607 | { |
| 3608 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3609 | struct link_vars phy_vars[MAX_PHYS]; |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3610 | u8 port = params->port; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3611 | u8 link_10g, phy_index; |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 3612 | u8 ext_phy_link_up = 0, cur_link_up; |
| 3613 | int rc = 0; |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 3614 | u8 is_mi_int = 0; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3615 | u16 ext_phy_line_speed = 0, prev_line_speed = vars->line_speed; |
| 3616 | u8 active_external_phy = INT_PHY; |
Yaniv Rosner | fd36a2e | 2011-05-31 21:29:05 +0000 | [diff] [blame^] | 3617 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3618 | for (phy_index = INT_PHY; phy_index < params->num_phys; |
| 3619 | phy_index++) { |
| 3620 | phy_vars[phy_index].flow_ctrl = 0; |
| 3621 | phy_vars[phy_index].link_status = 0; |
| 3622 | phy_vars[phy_index].line_speed = 0; |
| 3623 | phy_vars[phy_index].duplex = DUPLEX_FULL; |
| 3624 | phy_vars[phy_index].phy_link_up = 0; |
| 3625 | phy_vars[phy_index].link_up = 0; |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 3626 | phy_vars[phy_index].fault_detected = 0; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3627 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3628 | |
| 3629 | 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] | 3630 | port, (vars->phy_flags & PHY_XGXS_FLAG), |
| 3631 | REG_RD(bp, NIG_REG_STATUS_INTERRUPT_PORT0 + port*4)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3632 | |
Eilon Greenstein | 2f90446 | 2009-08-12 08:22:16 +0000 | [diff] [blame] | 3633 | 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] | 3634 | port*0x18) > 0); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3635 | 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] | 3636 | REG_RD(bp, NIG_REG_MASK_INTERRUPT_PORT0 + port*4), |
| 3637 | is_mi_int, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3638 | REG_RD(bp, NIG_REG_SERDES0_STATUS_LINK_STATUS + port*0x3c)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3639 | |
| 3640 | DP(NETIF_MSG_LINK, " 10G %x, XGXS_LINK %x\n", |
| 3641 | REG_RD(bp, NIG_REG_XGXS0_STATUS_LINK10G + port*0x68), |
| 3642 | REG_RD(bp, NIG_REG_XGXS0_STATUS_LINK_STATUS + port*0x68)); |
| 3643 | |
Eilon Greenstein | 6c55c3cd | 2009-01-14 06:44:13 +0000 | [diff] [blame] | 3644 | /* disable emac */ |
| 3645 | REG_WR(bp, NIG_REG_NIG_EMAC0_EN + port*4, 0); |
| 3646 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3647 | /* |
| 3648 | * Step 1: |
| 3649 | * Check external link change only for external phys, and apply |
| 3650 | * priority selection between them in case the link on both phys |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 3651 | * is up. Note that instead of the common vars, a temporary |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3652 | * vars argument is used since each phy may have different link/ |
| 3653 | * speed/duplex result |
| 3654 | */ |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3655 | for (phy_index = EXT_PHY1; phy_index < params->num_phys; |
| 3656 | phy_index++) { |
| 3657 | struct bnx2x_phy *phy = ¶ms->phy[phy_index]; |
| 3658 | if (!phy->read_status) |
| 3659 | continue; |
| 3660 | /* Read link status and params of this ext phy */ |
| 3661 | cur_link_up = phy->read_status(phy, params, |
| 3662 | &phy_vars[phy_index]); |
| 3663 | if (cur_link_up) { |
| 3664 | DP(NETIF_MSG_LINK, "phy in index %d link is up\n", |
| 3665 | phy_index); |
| 3666 | } else { |
| 3667 | DP(NETIF_MSG_LINK, "phy in index %d link is down\n", |
| 3668 | phy_index); |
| 3669 | continue; |
| 3670 | } |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3671 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3672 | if (!ext_phy_link_up) { |
| 3673 | ext_phy_link_up = 1; |
| 3674 | active_external_phy = phy_index; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3675 | } else { |
| 3676 | switch (bnx2x_phy_selection(params)) { |
| 3677 | case PORT_HW_CFG_PHY_SELECTION_HARDWARE_DEFAULT: |
| 3678 | case PORT_HW_CFG_PHY_SELECTION_FIRST_PHY_PRIORITY: |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3679 | /* |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3680 | * In this option, the first PHY makes sure to pass the |
| 3681 | * traffic through itself only. |
| 3682 | * Its not clear how to reset the link on the second phy |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3683 | */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3684 | active_external_phy = EXT_PHY1; |
| 3685 | break; |
| 3686 | case PORT_HW_CFG_PHY_SELECTION_SECOND_PHY_PRIORITY: |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3687 | /* |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3688 | * In this option, the first PHY makes sure to pass the |
| 3689 | * traffic through the second PHY. |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3690 | */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3691 | active_external_phy = EXT_PHY2; |
| 3692 | break; |
| 3693 | default: |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3694 | /* |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3695 | * Link indication on both PHYs with the following cases |
| 3696 | * is invalid: |
| 3697 | * - FIRST_PHY means that second phy wasn't initialized, |
| 3698 | * hence its link is expected to be down |
| 3699 | * - SECOND_PHY means that first phy should not be able |
| 3700 | * to link up by itself (using configuration) |
| 3701 | * - DEFAULT should be overriden during initialiazation |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3702 | */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3703 | DP(NETIF_MSG_LINK, "Invalid link indication" |
| 3704 | "mpc=0x%x. DISABLING LINK !!!\n", |
| 3705 | params->multi_phy_config); |
| 3706 | ext_phy_link_up = 0; |
| 3707 | break; |
| 3708 | } |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3709 | } |
| 3710 | } |
| 3711 | prev_line_speed = vars->line_speed; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3712 | /* |
| 3713 | * Step 2: |
| 3714 | * Read the status of the internal phy. In case of |
| 3715 | * DIRECT_SINGLE_MEDIA board, this link is the external link, |
| 3716 | * otherwise this is the link between the 577xx and the first |
| 3717 | * external phy |
| 3718 | */ |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3719 | if (params->phy[INT_PHY].read_status) |
| 3720 | params->phy[INT_PHY].read_status( |
| 3721 | ¶ms->phy[INT_PHY], |
| 3722 | params, vars); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3723 | /* |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3724 | * The INT_PHY flow control reside in the vars. This include the |
| 3725 | * case where the speed or flow control are not set to AUTO. |
| 3726 | * Otherwise, the active external phy flow control result is set |
| 3727 | * to the vars. The ext_phy_line_speed is needed to check if the |
| 3728 | * speed is different between the internal phy and external phy. |
| 3729 | * This case may be result of intermediate link speed change. |
| 3730 | */ |
| 3731 | if (active_external_phy > INT_PHY) { |
| 3732 | vars->flow_ctrl = phy_vars[active_external_phy].flow_ctrl; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3733 | /* |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3734 | * Link speed is taken from the XGXS. AN and FC result from |
| 3735 | * the external phy. |
| 3736 | */ |
| 3737 | vars->link_status |= phy_vars[active_external_phy].link_status; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3738 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3739 | /* |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3740 | * if active_external_phy is first PHY and link is up - disable |
| 3741 | * disable TX on second external PHY |
| 3742 | */ |
| 3743 | if (active_external_phy == EXT_PHY1) { |
| 3744 | if (params->phy[EXT_PHY2].phy_specific_func) { |
| 3745 | DP(NETIF_MSG_LINK, "Disabling TX on" |
| 3746 | " EXT_PHY2\n"); |
| 3747 | params->phy[EXT_PHY2].phy_specific_func( |
| 3748 | ¶ms->phy[EXT_PHY2], |
| 3749 | params, DISABLE_TX); |
| 3750 | } |
| 3751 | } |
| 3752 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3753 | ext_phy_line_speed = phy_vars[active_external_phy].line_speed; |
| 3754 | vars->duplex = phy_vars[active_external_phy].duplex; |
| 3755 | if (params->phy[active_external_phy].supported & |
| 3756 | SUPPORTED_FIBRE) |
| 3757 | vars->link_status |= LINK_STATUS_SERDES_LINK; |
Yaniv Rosner | fd36a2e | 2011-05-31 21:29:05 +0000 | [diff] [blame^] | 3758 | else |
| 3759 | vars->link_status &= ~LINK_STATUS_SERDES_LINK; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3760 | DP(NETIF_MSG_LINK, "Active external phy selected: %x\n", |
| 3761 | active_external_phy); |
| 3762 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3763 | |
| 3764 | for (phy_index = EXT_PHY1; phy_index < params->num_phys; |
| 3765 | phy_index++) { |
| 3766 | if (params->phy[phy_index].flags & |
| 3767 | FLAGS_REARM_LATCH_SIGNAL) { |
| 3768 | bnx2x_rearm_latch_signal(bp, port, |
| 3769 | phy_index == |
| 3770 | active_external_phy); |
| 3771 | break; |
| 3772 | } |
| 3773 | } |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3774 | DP(NETIF_MSG_LINK, "vars->flow_ctrl = 0x%x, vars->link_status = 0x%x," |
| 3775 | " ext_phy_line_speed = %d\n", vars->flow_ctrl, |
| 3776 | vars->link_status, ext_phy_line_speed); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3777 | /* |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3778 | * Upon link speed change set the NIG into drain mode. Comes to |
| 3779 | * deals with possible FIFO glitch due to clk change when speed |
| 3780 | * is decreased without link down indicator |
| 3781 | */ |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3782 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3783 | if (vars->phy_link_up) { |
| 3784 | if (!(SINGLE_MEDIA_DIRECT(params)) && ext_phy_link_up && |
| 3785 | (ext_phy_line_speed != vars->line_speed)) { |
| 3786 | DP(NETIF_MSG_LINK, "Internal link speed %d is" |
| 3787 | " different than the external" |
| 3788 | " link speed %d\n", vars->line_speed, |
| 3789 | ext_phy_line_speed); |
| 3790 | vars->phy_link_up = 0; |
| 3791 | } else if (prev_line_speed != vars->line_speed) { |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3792 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + params->port*4, |
| 3793 | 0); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3794 | msleep(1); |
| 3795 | } |
| 3796 | } |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3797 | |
| 3798 | /* anything 10 and over uses the bmac */ |
| 3799 | link_10g = ((vars->line_speed == SPEED_10000) || |
| 3800 | (vars->line_speed == SPEED_12000) || |
| 3801 | (vars->line_speed == SPEED_12500) || |
| 3802 | (vars->line_speed == SPEED_13000) || |
| 3803 | (vars->line_speed == SPEED_15000) || |
| 3804 | (vars->line_speed == SPEED_16000)); |
| 3805 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 3806 | bnx2x_link_int_ack(params, vars, link_10g); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3807 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3808 | /* |
| 3809 | * In case external phy link is up, and internal link is down |
| 3810 | * (not initialized yet probably after link initialization, it |
| 3811 | * needs to be initialized. |
| 3812 | * Note that after link down-up as result of cable plug, the xgxs |
| 3813 | * link would probably become up again without the need |
| 3814 | * initialize it |
| 3815 | */ |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3816 | if (!(SINGLE_MEDIA_DIRECT(params))) { |
| 3817 | DP(NETIF_MSG_LINK, "ext_phy_link_up = %d, int_link_up = %d," |
| 3818 | " init_preceding = %d\n", ext_phy_link_up, |
| 3819 | vars->phy_link_up, |
| 3820 | params->phy[EXT_PHY1].flags & |
| 3821 | FLAGS_INIT_XGXS_FIRST); |
| 3822 | if (!(params->phy[EXT_PHY1].flags & |
| 3823 | FLAGS_INIT_XGXS_FIRST) |
| 3824 | && ext_phy_link_up && !vars->phy_link_up) { |
| 3825 | vars->line_speed = ext_phy_line_speed; |
| 3826 | if (vars->line_speed < SPEED_1000) |
| 3827 | vars->phy_flags |= PHY_SGMII_FLAG; |
| 3828 | else |
| 3829 | vars->phy_flags &= ~PHY_SGMII_FLAG; |
| 3830 | bnx2x_init_internal_phy(¶ms->phy[INT_PHY], |
| 3831 | params, |
| 3832 | vars); |
| 3833 | } |
| 3834 | } |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 3835 | /* |
| 3836 | * Link is up only if both local phy and external phy (in case of |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 3837 | * non-direct board) are up and no fault detected on active PHY. |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3838 | */ |
| 3839 | vars->link_up = (vars->phy_link_up && |
| 3840 | (ext_phy_link_up || |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 3841 | SINGLE_MEDIA_DIRECT(params)) && |
| 3842 | (phy_vars[active_external_phy].fault_detected == 0)); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3843 | |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3844 | if (vars->link_up) |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3845 | rc = bnx2x_update_link_up(params, vars, link_10g); |
Yaniv Rosner | 57963ed | 2008-08-13 15:55:28 -0700 | [diff] [blame] | 3846 | else |
| 3847 | rc = bnx2x_update_link_down(params, vars); |
Yaniv Rosner | ea4e040 | 2008-06-23 20:27:26 -0700 | [diff] [blame] | 3848 | |
| 3849 | return rc; |
| 3850 | } |
| 3851 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3852 | |
| 3853 | /*****************************************************************************/ |
| 3854 | /* External Phy section */ |
| 3855 | /*****************************************************************************/ |
| 3856 | void bnx2x_ext_phy_hw_reset(struct bnx2x *bp, u8 port) |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3857 | { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3858 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3859 | MISC_REGISTERS_GPIO_OUTPUT_LOW, port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3860 | msleep(1); |
| 3861 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3862 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, port); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 3863 | } |
| 3864 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3865 | static void bnx2x_save_spirom_version(struct bnx2x *bp, u8 port, |
| 3866 | u32 spirom_ver, u32 ver_addr) |
| 3867 | { |
| 3868 | DP(NETIF_MSG_LINK, "FW version 0x%x:0x%x for port %d\n", |
| 3869 | (u16)(spirom_ver>>16), (u16)spirom_ver, port); |
| 3870 | |
| 3871 | if (ver_addr) |
| 3872 | REG_WR(bp, ver_addr, spirom_ver); |
| 3873 | } |
| 3874 | |
| 3875 | static void bnx2x_save_bcm_spirom_ver(struct bnx2x *bp, |
| 3876 | struct bnx2x_phy *phy, |
| 3877 | u8 port) |
| 3878 | { |
| 3879 | u16 fw_ver1, fw_ver2; |
| 3880 | |
| 3881 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3882 | MDIO_PMA_REG_ROM_VER1, &fw_ver1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3883 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3884 | MDIO_PMA_REG_ROM_VER2, &fw_ver2); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3885 | bnx2x_save_spirom_version(bp, port, (u32)(fw_ver1<<16 | fw_ver2), |
| 3886 | phy->ver_addr); |
| 3887 | } |
| 3888 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3889 | static void bnx2x_ext_phy_10G_an_resolve(struct bnx2x *bp, |
| 3890 | struct bnx2x_phy *phy, |
| 3891 | struct link_vars *vars) |
| 3892 | { |
| 3893 | u16 val; |
| 3894 | bnx2x_cl45_read(bp, phy, |
| 3895 | MDIO_AN_DEVAD, |
| 3896 | MDIO_AN_REG_STATUS, &val); |
| 3897 | bnx2x_cl45_read(bp, phy, |
| 3898 | MDIO_AN_DEVAD, |
| 3899 | MDIO_AN_REG_STATUS, &val); |
| 3900 | if (val & (1<<5)) |
| 3901 | vars->link_status |= LINK_STATUS_AUTO_NEGOTIATE_COMPLETE; |
| 3902 | if ((val & (1<<0)) == 0) |
| 3903 | vars->link_status |= LINK_STATUS_PARALLEL_DETECTION_USED; |
| 3904 | } |
| 3905 | |
| 3906 | /******************************************************************/ |
| 3907 | /* common BCM8073/BCM8727 PHY SECTION */ |
| 3908 | /******************************************************************/ |
| 3909 | static void bnx2x_8073_resolve_fc(struct bnx2x_phy *phy, |
| 3910 | struct link_params *params, |
| 3911 | struct link_vars *vars) |
| 3912 | { |
| 3913 | struct bnx2x *bp = params->bp; |
| 3914 | if (phy->req_line_speed == SPEED_10 || |
| 3915 | phy->req_line_speed == SPEED_100) { |
| 3916 | vars->flow_ctrl = phy->req_flow_ctrl; |
| 3917 | return; |
| 3918 | } |
| 3919 | |
| 3920 | if (bnx2x_ext_phy_resolve_fc(phy, params, vars) && |
| 3921 | (vars->flow_ctrl == BNX2X_FLOW_CTRL_NONE)) { |
| 3922 | u16 pause_result; |
| 3923 | u16 ld_pause; /* local */ |
| 3924 | u16 lp_pause; /* link partner */ |
| 3925 | bnx2x_cl45_read(bp, phy, |
| 3926 | MDIO_AN_DEVAD, |
| 3927 | MDIO_AN_REG_CL37_FC_LD, &ld_pause); |
| 3928 | |
| 3929 | bnx2x_cl45_read(bp, phy, |
| 3930 | MDIO_AN_DEVAD, |
| 3931 | MDIO_AN_REG_CL37_FC_LP, &lp_pause); |
| 3932 | pause_result = (ld_pause & |
| 3933 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) >> 5; |
| 3934 | pause_result |= (lp_pause & |
| 3935 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) >> 7; |
| 3936 | |
| 3937 | bnx2x_pause_resolve(vars, pause_result); |
| 3938 | DP(NETIF_MSG_LINK, "Ext PHY CL37 pause result 0x%x\n", |
| 3939 | pause_result); |
| 3940 | } |
| 3941 | } |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 3942 | static int bnx2x_8073_8727_external_rom_boot(struct bnx2x *bp, |
| 3943 | struct bnx2x_phy *phy, |
| 3944 | u8 port) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3945 | { |
Yaniv Rosner | 5c99274b | 2011-01-18 04:33:36 +0000 | [diff] [blame] | 3946 | u32 count = 0; |
| 3947 | u16 fw_ver1, fw_msgout; |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 3948 | int rc = 0; |
Yaniv Rosner | 5c99274b | 2011-01-18 04:33:36 +0000 | [diff] [blame] | 3949 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3950 | /* Boot port from external ROM */ |
| 3951 | /* EDC grst */ |
| 3952 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3953 | MDIO_PMA_DEVAD, |
| 3954 | MDIO_PMA_REG_GEN_CTRL, |
| 3955 | 0x0001); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3956 | |
| 3957 | /* ucode reboot and rst */ |
| 3958 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3959 | MDIO_PMA_DEVAD, |
| 3960 | MDIO_PMA_REG_GEN_CTRL, |
| 3961 | 0x008c); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3962 | |
| 3963 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3964 | MDIO_PMA_DEVAD, |
| 3965 | MDIO_PMA_REG_MISC_CTRL1, 0x0001); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3966 | |
| 3967 | /* Reset internal microprocessor */ |
| 3968 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3969 | MDIO_PMA_DEVAD, |
| 3970 | MDIO_PMA_REG_GEN_CTRL, |
| 3971 | MDIO_PMA_REG_GEN_CTRL_ROM_MICRO_RESET); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3972 | |
| 3973 | /* Release srst bit */ |
| 3974 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 3975 | MDIO_PMA_DEVAD, |
| 3976 | MDIO_PMA_REG_GEN_CTRL, |
| 3977 | MDIO_PMA_REG_GEN_CTRL_ROM_RESET_INTERNAL_MP); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 3978 | |
Yaniv Rosner | 5c99274b | 2011-01-18 04:33:36 +0000 | [diff] [blame] | 3979 | /* Delay 100ms per the PHY specifications */ |
| 3980 | msleep(100); |
| 3981 | |
| 3982 | /* 8073 sometimes taking longer to download */ |
| 3983 | do { |
| 3984 | count++; |
| 3985 | if (count > 300) { |
| 3986 | DP(NETIF_MSG_LINK, |
| 3987 | "bnx2x_8073_8727_external_rom_boot port %x:" |
| 3988 | "Download failed. fw version = 0x%x\n", |
| 3989 | port, fw_ver1); |
| 3990 | rc = -EINVAL; |
| 3991 | break; |
| 3992 | } |
| 3993 | |
| 3994 | bnx2x_cl45_read(bp, phy, |
| 3995 | MDIO_PMA_DEVAD, |
| 3996 | MDIO_PMA_REG_ROM_VER1, &fw_ver1); |
| 3997 | bnx2x_cl45_read(bp, phy, |
| 3998 | MDIO_PMA_DEVAD, |
| 3999 | MDIO_PMA_REG_M8051_MSGOUT_REG, &fw_msgout); |
| 4000 | |
| 4001 | msleep(1); |
| 4002 | } while (fw_ver1 == 0 || fw_ver1 == 0x4321 || |
| 4003 | ((fw_msgout & 0xff) != 0x03 && (phy->type == |
| 4004 | PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073))); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4005 | |
| 4006 | /* Clear ser_boot_ctl bit */ |
| 4007 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4008 | MDIO_PMA_DEVAD, |
| 4009 | MDIO_PMA_REG_MISC_CTRL1, 0x0000); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4010 | bnx2x_save_bcm_spirom_ver(bp, phy, port); |
Yaniv Rosner | 5c99274b | 2011-01-18 04:33:36 +0000 | [diff] [blame] | 4011 | |
| 4012 | DP(NETIF_MSG_LINK, |
| 4013 | "bnx2x_8073_8727_external_rom_boot port %x:" |
| 4014 | "Download complete. fw version = 0x%x\n", |
| 4015 | port, fw_ver1); |
| 4016 | |
| 4017 | return rc; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4018 | } |
| 4019 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4020 | /******************************************************************/ |
| 4021 | /* BCM8073 PHY SECTION */ |
| 4022 | /******************************************************************/ |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 4023 | 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] | 4024 | { |
| 4025 | /* This is only required for 8073A1, version 102 only */ |
| 4026 | u16 val; |
| 4027 | |
| 4028 | /* Read 8073 HW revision*/ |
| 4029 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4030 | MDIO_PMA_DEVAD, |
| 4031 | MDIO_PMA_REG_8073_CHIP_REV, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4032 | |
| 4033 | if (val != 1) { |
| 4034 | /* No need to workaround in 8073 A1 */ |
| 4035 | return 0; |
| 4036 | } |
| 4037 | |
| 4038 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4039 | MDIO_PMA_DEVAD, |
| 4040 | MDIO_PMA_REG_ROM_VER2, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4041 | |
| 4042 | /* SNR should be applied only for version 0x102 */ |
| 4043 | if (val != 0x102) |
| 4044 | return 0; |
| 4045 | |
| 4046 | return 1; |
| 4047 | } |
| 4048 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 4049 | 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] | 4050 | { |
| 4051 | u16 val, cnt, cnt1 ; |
| 4052 | |
| 4053 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4054 | MDIO_PMA_DEVAD, |
| 4055 | MDIO_PMA_REG_8073_CHIP_REV, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4056 | |
| 4057 | if (val > 0) { |
| 4058 | /* No need to workaround in 8073 A1 */ |
| 4059 | return 0; |
| 4060 | } |
| 4061 | /* XAUI workaround in 8073 A0: */ |
| 4062 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 4063 | /* |
| 4064 | * After loading the boot ROM and restarting Autoneg, poll |
| 4065 | * Dev1, Reg $C820: |
| 4066 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4067 | |
| 4068 | for (cnt = 0; cnt < 1000; cnt++) { |
| 4069 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4070 | MDIO_PMA_DEVAD, |
| 4071 | MDIO_PMA_REG_8073_SPEED_LINK_STATUS, |
| 4072 | &val); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 4073 | /* |
| 4074 | * If bit [14] = 0 or bit [13] = 0, continue on with |
| 4075 | * system initialization (XAUI work-around not required, as |
| 4076 | * these bits indicate 2.5G or 1G link up). |
| 4077 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4078 | if (!(val & (1<<14)) || !(val & (1<<13))) { |
| 4079 | DP(NETIF_MSG_LINK, "XAUI work-around not required\n"); |
| 4080 | return 0; |
| 4081 | } else if (!(val & (1<<15))) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 4082 | DP(NETIF_MSG_LINK, "bit 15 went off\n"); |
| 4083 | /* |
| 4084 | * If bit 15 is 0, then poll Dev1, Reg $C841 until it's |
| 4085 | * MSB (bit15) goes to 1 (indicating that the XAUI |
| 4086 | * workaround has completed), then continue on with |
| 4087 | * system initialization. |
| 4088 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4089 | for (cnt1 = 0; cnt1 < 1000; cnt1++) { |
| 4090 | bnx2x_cl45_read(bp, phy, |
| 4091 | MDIO_PMA_DEVAD, |
| 4092 | MDIO_PMA_REG_8073_XAUI_WA, &val); |
| 4093 | if (val & (1<<15)) { |
| 4094 | DP(NETIF_MSG_LINK, |
| 4095 | "XAUI workaround has completed\n"); |
| 4096 | return 0; |
| 4097 | } |
| 4098 | msleep(3); |
| 4099 | } |
| 4100 | break; |
| 4101 | } |
| 4102 | msleep(3); |
| 4103 | } |
| 4104 | DP(NETIF_MSG_LINK, "Warning: XAUI work-around timeout !!!\n"); |
| 4105 | return -EINVAL; |
| 4106 | } |
| 4107 | |
| 4108 | static void bnx2x_807x_force_10G(struct bnx2x *bp, struct bnx2x_phy *phy) |
| 4109 | { |
| 4110 | /* Force KR or KX */ |
| 4111 | bnx2x_cl45_write(bp, phy, |
| 4112 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 0x2040); |
| 4113 | bnx2x_cl45_write(bp, phy, |
| 4114 | MDIO_PMA_DEVAD, MDIO_PMA_REG_10G_CTRL2, 0x000b); |
| 4115 | bnx2x_cl45_write(bp, phy, |
| 4116 | MDIO_PMA_DEVAD, MDIO_PMA_REG_BCM_CTRL, 0x0000); |
| 4117 | bnx2x_cl45_write(bp, phy, |
| 4118 | MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, 0x0000); |
| 4119 | } |
| 4120 | |
| 4121 | static void bnx2x_8073_set_pause_cl37(struct link_params *params, |
| 4122 | struct bnx2x_phy *phy, |
| 4123 | struct link_vars *vars) |
| 4124 | { |
| 4125 | u16 cl37_val; |
| 4126 | struct bnx2x *bp = params->bp; |
| 4127 | bnx2x_cl45_read(bp, phy, |
| 4128 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_FC_LD, &cl37_val); |
| 4129 | |
| 4130 | cl37_val &= ~MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH; |
| 4131 | /* Please refer to Table 28B-3 of 802.3ab-1999 spec. */ |
| 4132 | bnx2x_calc_ieee_aneg_adv(phy, params, &vars->ieee_fc); |
| 4133 | if ((vars->ieee_fc & |
| 4134 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_SYMMETRIC) == |
| 4135 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_SYMMETRIC) { |
| 4136 | cl37_val |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_SYMMETRIC; |
| 4137 | } |
| 4138 | if ((vars->ieee_fc & |
| 4139 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC) == |
| 4140 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC) { |
| 4141 | cl37_val |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC; |
| 4142 | } |
| 4143 | if ((vars->ieee_fc & |
| 4144 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) == |
| 4145 | MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) { |
| 4146 | cl37_val |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH; |
| 4147 | } |
| 4148 | DP(NETIF_MSG_LINK, |
| 4149 | "Ext phy AN advertize cl37 0x%x\n", cl37_val); |
| 4150 | |
| 4151 | bnx2x_cl45_write(bp, phy, |
| 4152 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_FC_LD, cl37_val); |
| 4153 | msleep(500); |
| 4154 | } |
| 4155 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 4156 | static int bnx2x_8073_config_init(struct bnx2x_phy *phy, |
| 4157 | struct link_params *params, |
| 4158 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4159 | { |
| 4160 | struct bnx2x *bp = params->bp; |
| 4161 | u16 val = 0, tmp1; |
| 4162 | u8 gpio_port; |
| 4163 | DP(NETIF_MSG_LINK, "Init 8073\n"); |
| 4164 | |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 4165 | if (CHIP_IS_E2(bp)) |
| 4166 | gpio_port = BP_PATH(bp); |
| 4167 | else |
| 4168 | gpio_port = params->port; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4169 | /* Restore normal power mode*/ |
| 4170 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4171 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, gpio_port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4172 | |
| 4173 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4174 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, gpio_port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4175 | |
| 4176 | /* enable LASI */ |
| 4177 | bnx2x_cl45_write(bp, phy, |
| 4178 | MDIO_PMA_DEVAD, MDIO_PMA_REG_RX_ALARM_CTRL, (1<<2)); |
| 4179 | bnx2x_cl45_write(bp, phy, |
| 4180 | MDIO_PMA_DEVAD, MDIO_PMA_REG_LASI_CTRL, 0x0004); |
| 4181 | |
| 4182 | bnx2x_8073_set_pause_cl37(params, phy, vars); |
| 4183 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4184 | bnx2x_cl45_read(bp, phy, |
| 4185 | MDIO_PMA_DEVAD, MDIO_PMA_REG_M8051_MSGOUT_REG, &tmp1); |
| 4186 | |
| 4187 | bnx2x_cl45_read(bp, phy, |
| 4188 | MDIO_PMA_DEVAD, MDIO_PMA_REG_RX_ALARM, &tmp1); |
| 4189 | |
| 4190 | DP(NETIF_MSG_LINK, "Before rom RX_ALARM(port1): 0x%x\n", tmp1); |
| 4191 | |
Yaniv Rosner | 74d7a11 | 2011-01-18 04:33:18 +0000 | [diff] [blame] | 4192 | /* Swap polarity if required - Must be done only in non-1G mode */ |
| 4193 | if (params->lane_config & PORT_HW_CFG_SWAP_PHY_POLARITY_ENABLED) { |
| 4194 | /* Configure the 8073 to swap _P and _N of the KR lines */ |
| 4195 | DP(NETIF_MSG_LINK, "Swapping polarity for the 8073\n"); |
| 4196 | /* 10G Rx/Tx and 1G Tx signal polarity swap */ |
| 4197 | bnx2x_cl45_read(bp, phy, |
| 4198 | MDIO_PMA_DEVAD, |
| 4199 | MDIO_PMA_REG_8073_OPT_DIGITAL_CTRL, &val); |
| 4200 | bnx2x_cl45_write(bp, phy, |
| 4201 | MDIO_PMA_DEVAD, |
| 4202 | MDIO_PMA_REG_8073_OPT_DIGITAL_CTRL, |
| 4203 | (val | (3<<9))); |
| 4204 | } |
| 4205 | |
| 4206 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4207 | /* Enable CL37 BAM */ |
Yaniv Rosner | 121839b | 2010-11-01 05:32:38 +0000 | [diff] [blame] | 4208 | if (REG_RD(bp, params->shmem_base + |
| 4209 | offsetof(struct shmem_region, dev_info. |
| 4210 | port_hw_config[params->port].default_cfg)) & |
| 4211 | PORT_HW_CFG_ENABLE_BAM_ON_KR_ENABLED) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4212 | |
Yaniv Rosner | 121839b | 2010-11-01 05:32:38 +0000 | [diff] [blame] | 4213 | bnx2x_cl45_read(bp, phy, |
| 4214 | MDIO_AN_DEVAD, |
| 4215 | MDIO_AN_REG_8073_BAM, &val); |
| 4216 | bnx2x_cl45_write(bp, phy, |
| 4217 | MDIO_AN_DEVAD, |
| 4218 | MDIO_AN_REG_8073_BAM, val | 1); |
| 4219 | DP(NETIF_MSG_LINK, "Enable CL37 BAM on KR\n"); |
| 4220 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4221 | if (params->loopback_mode == LOOPBACK_EXT) { |
| 4222 | bnx2x_807x_force_10G(bp, phy); |
| 4223 | DP(NETIF_MSG_LINK, "Forced speed 10G on 807X\n"); |
| 4224 | return 0; |
| 4225 | } else { |
| 4226 | bnx2x_cl45_write(bp, phy, |
| 4227 | MDIO_PMA_DEVAD, MDIO_PMA_REG_BCM_CTRL, 0x0002); |
| 4228 | } |
| 4229 | if (phy->req_line_speed != SPEED_AUTO_NEG) { |
| 4230 | if (phy->req_line_speed == SPEED_10000) { |
| 4231 | val = (1<<7); |
| 4232 | } else if (phy->req_line_speed == SPEED_2500) { |
| 4233 | val = (1<<5); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 4234 | /* |
| 4235 | * Note that 2.5G works only when used with 1G |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 4236 | * advertisement |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 4237 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4238 | } else |
| 4239 | val = (1<<5); |
| 4240 | } else { |
| 4241 | val = 0; |
| 4242 | if (phy->speed_cap_mask & |
| 4243 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G) |
| 4244 | val |= (1<<7); |
| 4245 | |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 4246 | /* Note that 2.5G works only when used with 1G advertisement */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4247 | if (phy->speed_cap_mask & |
| 4248 | (PORT_HW_CFG_SPEED_CAPABILITY_D0_1G | |
| 4249 | PORT_HW_CFG_SPEED_CAPABILITY_D0_2_5G)) |
| 4250 | val |= (1<<5); |
| 4251 | DP(NETIF_MSG_LINK, "807x autoneg val = 0x%x\n", val); |
| 4252 | } |
| 4253 | |
| 4254 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_ADV, val); |
| 4255 | bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_8073_2_5G, &tmp1); |
| 4256 | |
| 4257 | if (((phy->speed_cap_mask & PORT_HW_CFG_SPEED_CAPABILITY_D0_2_5G) && |
| 4258 | (phy->req_line_speed == SPEED_AUTO_NEG)) || |
| 4259 | (phy->req_line_speed == SPEED_2500)) { |
| 4260 | u16 phy_ver; |
| 4261 | /* Allow 2.5G for A1 and above */ |
| 4262 | bnx2x_cl45_read(bp, phy, |
| 4263 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8073_CHIP_REV, |
| 4264 | &phy_ver); |
| 4265 | DP(NETIF_MSG_LINK, "Add 2.5G\n"); |
| 4266 | if (phy_ver > 0) |
| 4267 | tmp1 |= 1; |
| 4268 | else |
| 4269 | tmp1 &= 0xfffe; |
| 4270 | } else { |
| 4271 | DP(NETIF_MSG_LINK, "Disable 2.5G\n"); |
| 4272 | tmp1 &= 0xfffe; |
| 4273 | } |
| 4274 | |
| 4275 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_8073_2_5G, tmp1); |
| 4276 | /* Add support for CL37 (passive mode) II */ |
| 4277 | |
| 4278 | bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_CL37_FC_LD, &tmp1); |
| 4279 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_CL37_FC_LD, |
| 4280 | (tmp1 | ((phy->req_duplex == DUPLEX_FULL) ? |
| 4281 | 0x20 : 0x40))); |
| 4282 | |
| 4283 | /* Add support for CL37 (passive mode) III */ |
| 4284 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_CL37_AN, 0x1000); |
| 4285 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 4286 | /* |
| 4287 | * The SNR will improve about 2db by changing BW and FEE main |
| 4288 | * tap. Rest commands are executed after link is up |
| 4289 | * Change FFE main cursor to 5 in EDC register |
| 4290 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4291 | if (bnx2x_8073_is_snr_needed(bp, phy)) |
| 4292 | bnx2x_cl45_write(bp, phy, |
| 4293 | MDIO_PMA_DEVAD, MDIO_PMA_REG_EDC_FFE_MAIN, |
| 4294 | 0xFB0C); |
| 4295 | |
| 4296 | /* Enable FEC (Forware Error Correction) Request in the AN */ |
| 4297 | bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_ADV2, &tmp1); |
| 4298 | tmp1 |= (1<<15); |
| 4299 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_ADV2, tmp1); |
| 4300 | |
| 4301 | bnx2x_ext_phy_set_pause(params, phy, vars); |
| 4302 | |
| 4303 | /* Restart autoneg */ |
| 4304 | msleep(500); |
| 4305 | bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, 0x1200); |
| 4306 | DP(NETIF_MSG_LINK, "807x Autoneg Restart: Advertise 1G=%x, 10G=%x\n", |
| 4307 | ((val & (1<<5)) > 0), ((val & (1<<7)) > 0)); |
| 4308 | return 0; |
| 4309 | } |
| 4310 | |
| 4311 | static u8 bnx2x_8073_read_status(struct bnx2x_phy *phy, |
| 4312 | struct link_params *params, |
| 4313 | struct link_vars *vars) |
| 4314 | { |
| 4315 | struct bnx2x *bp = params->bp; |
| 4316 | u8 link_up = 0; |
| 4317 | u16 val1, val2; |
| 4318 | u16 link_status = 0; |
| 4319 | u16 an1000_status = 0; |
| 4320 | |
| 4321 | bnx2x_cl45_read(bp, phy, |
| 4322 | MDIO_PMA_DEVAD, MDIO_PMA_REG_LASI_STATUS, &val1); |
| 4323 | |
| 4324 | DP(NETIF_MSG_LINK, "8703 LASI status 0x%x\n", val1); |
| 4325 | |
| 4326 | /* clear the interrupt LASI status register */ |
| 4327 | bnx2x_cl45_read(bp, phy, |
| 4328 | MDIO_PCS_DEVAD, MDIO_PCS_REG_STATUS, &val2); |
| 4329 | bnx2x_cl45_read(bp, phy, |
| 4330 | MDIO_PCS_DEVAD, MDIO_PCS_REG_STATUS, &val1); |
| 4331 | DP(NETIF_MSG_LINK, "807x PCS status 0x%x->0x%x\n", val2, val1); |
| 4332 | /* Clear MSG-OUT */ |
| 4333 | bnx2x_cl45_read(bp, phy, |
| 4334 | MDIO_PMA_DEVAD, MDIO_PMA_REG_M8051_MSGOUT_REG, &val1); |
| 4335 | |
| 4336 | /* Check the LASI */ |
| 4337 | bnx2x_cl45_read(bp, phy, |
| 4338 | MDIO_PMA_DEVAD, MDIO_PMA_REG_RX_ALARM, &val2); |
| 4339 | |
| 4340 | DP(NETIF_MSG_LINK, "KR 0x9003 0x%x\n", val2); |
| 4341 | |
| 4342 | /* Check the link status */ |
| 4343 | bnx2x_cl45_read(bp, phy, |
| 4344 | MDIO_PCS_DEVAD, MDIO_PCS_REG_STATUS, &val2); |
| 4345 | DP(NETIF_MSG_LINK, "KR PCS status 0x%x\n", val2); |
| 4346 | |
| 4347 | bnx2x_cl45_read(bp, phy, |
| 4348 | MDIO_PMA_DEVAD, MDIO_PMA_REG_STATUS, &val2); |
| 4349 | bnx2x_cl45_read(bp, phy, |
| 4350 | MDIO_PMA_DEVAD, MDIO_PMA_REG_STATUS, &val1); |
| 4351 | link_up = ((val1 & 4) == 4); |
| 4352 | DP(NETIF_MSG_LINK, "PMA_REG_STATUS=0x%x\n", val1); |
| 4353 | |
| 4354 | if (link_up && |
| 4355 | ((phy->req_line_speed != SPEED_10000))) { |
| 4356 | if (bnx2x_8073_xaui_wa(bp, phy) != 0) |
| 4357 | return 0; |
| 4358 | } |
| 4359 | bnx2x_cl45_read(bp, phy, |
| 4360 | MDIO_AN_DEVAD, MDIO_AN_REG_LINK_STATUS, &an1000_status); |
| 4361 | bnx2x_cl45_read(bp, phy, |
| 4362 | MDIO_AN_DEVAD, MDIO_AN_REG_LINK_STATUS, &an1000_status); |
| 4363 | |
| 4364 | /* Check the link status on 1.1.2 */ |
| 4365 | bnx2x_cl45_read(bp, phy, |
| 4366 | MDIO_PMA_DEVAD, MDIO_PMA_REG_STATUS, &val2); |
| 4367 | bnx2x_cl45_read(bp, phy, |
| 4368 | MDIO_PMA_DEVAD, MDIO_PMA_REG_STATUS, &val1); |
| 4369 | DP(NETIF_MSG_LINK, "KR PMA status 0x%x->0x%x," |
| 4370 | "an_link_status=0x%x\n", val2, val1, an1000_status); |
| 4371 | |
| 4372 | link_up = (((val1 & 4) == 4) || (an1000_status & (1<<1))); |
| 4373 | if (link_up && bnx2x_8073_is_snr_needed(bp, phy)) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 4374 | /* |
| 4375 | * The SNR will improve about 2dbby changing the BW and FEE main |
| 4376 | * tap. The 1st write to change FFE main tap is set before |
| 4377 | * restart AN. Change PLL Bandwidth in EDC register |
| 4378 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4379 | bnx2x_cl45_write(bp, phy, |
| 4380 | MDIO_PMA_DEVAD, MDIO_PMA_REG_PLL_BANDWIDTH, |
| 4381 | 0x26BC); |
| 4382 | |
| 4383 | /* Change CDR Bandwidth in EDC register */ |
| 4384 | bnx2x_cl45_write(bp, phy, |
| 4385 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CDR_BANDWIDTH, |
| 4386 | 0x0333); |
| 4387 | } |
| 4388 | bnx2x_cl45_read(bp, phy, |
| 4389 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8073_SPEED_LINK_STATUS, |
| 4390 | &link_status); |
| 4391 | |
| 4392 | /* Bits 0..2 --> speed detected, bits 13..15--> link is down */ |
| 4393 | if ((link_status & (1<<2)) && (!(link_status & (1<<15)))) { |
| 4394 | link_up = 1; |
| 4395 | vars->line_speed = SPEED_10000; |
| 4396 | DP(NETIF_MSG_LINK, "port %x: External link up in 10G\n", |
| 4397 | params->port); |
| 4398 | } else if ((link_status & (1<<1)) && (!(link_status & (1<<14)))) { |
| 4399 | link_up = 1; |
| 4400 | vars->line_speed = SPEED_2500; |
| 4401 | DP(NETIF_MSG_LINK, "port %x: External link up in 2.5G\n", |
| 4402 | params->port); |
| 4403 | } else if ((link_status & (1<<0)) && (!(link_status & (1<<13)))) { |
| 4404 | link_up = 1; |
| 4405 | vars->line_speed = SPEED_1000; |
| 4406 | DP(NETIF_MSG_LINK, "port %x: External link up in 1G\n", |
| 4407 | params->port); |
| 4408 | } else { |
| 4409 | link_up = 0; |
| 4410 | DP(NETIF_MSG_LINK, "port %x: External link is down\n", |
| 4411 | params->port); |
| 4412 | } |
| 4413 | |
| 4414 | if (link_up) { |
Yaniv Rosner | 74d7a11 | 2011-01-18 04:33:18 +0000 | [diff] [blame] | 4415 | /* Swap polarity if required */ |
| 4416 | if (params->lane_config & |
| 4417 | PORT_HW_CFG_SWAP_PHY_POLARITY_ENABLED) { |
| 4418 | /* Configure the 8073 to swap P and N of the KR lines */ |
| 4419 | bnx2x_cl45_read(bp, phy, |
| 4420 | MDIO_XS_DEVAD, |
| 4421 | MDIO_XS_REG_8073_RX_CTRL_PCIE, &val1); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 4422 | /* |
| 4423 | * Set bit 3 to invert Rx in 1G mode and clear this bit |
| 4424 | * when it`s in 10G mode. |
| 4425 | */ |
Yaniv Rosner | 74d7a11 | 2011-01-18 04:33:18 +0000 | [diff] [blame] | 4426 | if (vars->line_speed == SPEED_1000) { |
| 4427 | DP(NETIF_MSG_LINK, "Swapping 1G polarity for" |
| 4428 | "the 8073\n"); |
| 4429 | val1 |= (1<<3); |
| 4430 | } else |
| 4431 | val1 &= ~(1<<3); |
| 4432 | |
| 4433 | bnx2x_cl45_write(bp, phy, |
| 4434 | MDIO_XS_DEVAD, |
| 4435 | MDIO_XS_REG_8073_RX_CTRL_PCIE, |
| 4436 | val1); |
| 4437 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4438 | bnx2x_ext_phy_10G_an_resolve(bp, phy, vars); |
| 4439 | bnx2x_8073_resolve_fc(phy, params, vars); |
Yaniv Rosner | 791f18c | 2011-01-18 04:33:42 +0000 | [diff] [blame] | 4440 | vars->duplex = DUPLEX_FULL; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4441 | } |
| 4442 | return link_up; |
| 4443 | } |
| 4444 | |
| 4445 | static void bnx2x_8073_link_reset(struct bnx2x_phy *phy, |
| 4446 | struct link_params *params) |
| 4447 | { |
| 4448 | struct bnx2x *bp = params->bp; |
| 4449 | u8 gpio_port; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 4450 | if (CHIP_IS_E2(bp)) |
| 4451 | gpio_port = BP_PATH(bp); |
| 4452 | else |
| 4453 | gpio_port = params->port; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4454 | DP(NETIF_MSG_LINK, "Setting 8073 port %d into low power mode\n", |
| 4455 | gpio_port); |
| 4456 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4457 | MISC_REGISTERS_GPIO_OUTPUT_LOW, |
| 4458 | gpio_port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4459 | } |
| 4460 | |
| 4461 | /******************************************************************/ |
| 4462 | /* BCM8705 PHY SECTION */ |
| 4463 | /******************************************************************/ |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 4464 | static int bnx2x_8705_config_init(struct bnx2x_phy *phy, |
| 4465 | struct link_params *params, |
| 4466 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4467 | { |
| 4468 | struct bnx2x *bp = params->bp; |
| 4469 | DP(NETIF_MSG_LINK, "init 8705\n"); |
| 4470 | /* Restore normal power mode*/ |
| 4471 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4472 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, params->port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4473 | /* HW reset */ |
| 4474 | bnx2x_ext_phy_hw_reset(bp, params->port); |
| 4475 | 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] | 4476 | bnx2x_wait_reset_complete(bp, phy, params); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4477 | |
| 4478 | bnx2x_cl45_write(bp, phy, |
| 4479 | MDIO_PMA_DEVAD, MDIO_PMA_REG_MISC_CTRL, 0x8288); |
| 4480 | bnx2x_cl45_write(bp, phy, |
| 4481 | MDIO_PMA_DEVAD, MDIO_PMA_REG_PHY_IDENTIFIER, 0x7fbf); |
| 4482 | bnx2x_cl45_write(bp, phy, |
| 4483 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CMU_PLL_BYPASS, 0x0100); |
| 4484 | bnx2x_cl45_write(bp, phy, |
| 4485 | MDIO_WIS_DEVAD, MDIO_WIS_REG_LASI_CNTL, 0x1); |
| 4486 | /* BCM8705 doesn't have microcode, hence the 0 */ |
| 4487 | bnx2x_save_spirom_version(bp, params->port, params->shmem_base, 0); |
| 4488 | return 0; |
| 4489 | } |
| 4490 | |
| 4491 | static u8 bnx2x_8705_read_status(struct bnx2x_phy *phy, |
| 4492 | struct link_params *params, |
| 4493 | struct link_vars *vars) |
| 4494 | { |
| 4495 | u8 link_up = 0; |
| 4496 | u16 val1, rx_sd; |
| 4497 | struct bnx2x *bp = params->bp; |
| 4498 | DP(NETIF_MSG_LINK, "read status 8705\n"); |
| 4499 | bnx2x_cl45_read(bp, phy, |
| 4500 | MDIO_WIS_DEVAD, MDIO_WIS_REG_LASI_STATUS, &val1); |
| 4501 | DP(NETIF_MSG_LINK, "8705 LASI status 0x%x\n", val1); |
| 4502 | |
| 4503 | bnx2x_cl45_read(bp, phy, |
| 4504 | MDIO_WIS_DEVAD, MDIO_WIS_REG_LASI_STATUS, &val1); |
| 4505 | DP(NETIF_MSG_LINK, "8705 LASI status 0x%x\n", val1); |
| 4506 | |
| 4507 | bnx2x_cl45_read(bp, phy, |
| 4508 | MDIO_PMA_DEVAD, MDIO_PMA_REG_RX_SD, &rx_sd); |
| 4509 | |
| 4510 | bnx2x_cl45_read(bp, phy, |
| 4511 | MDIO_PMA_DEVAD, 0xc809, &val1); |
| 4512 | bnx2x_cl45_read(bp, phy, |
| 4513 | MDIO_PMA_DEVAD, 0xc809, &val1); |
| 4514 | |
| 4515 | DP(NETIF_MSG_LINK, "8705 1.c809 val=0x%x\n", val1); |
| 4516 | link_up = ((rx_sd & 0x1) && (val1 & (1<<9)) && ((val1 & (1<<8)) == 0)); |
| 4517 | if (link_up) { |
| 4518 | vars->line_speed = SPEED_10000; |
| 4519 | bnx2x_ext_phy_resolve_fc(phy, params, vars); |
| 4520 | } |
| 4521 | return link_up; |
| 4522 | } |
| 4523 | |
| 4524 | /******************************************************************/ |
| 4525 | /* SFP+ module Section */ |
| 4526 | /******************************************************************/ |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 4527 | static u8 bnx2x_get_gpio_port(struct link_params *params) |
| 4528 | { |
| 4529 | u8 gpio_port; |
| 4530 | u32 swap_val, swap_override; |
| 4531 | struct bnx2x *bp = params->bp; |
| 4532 | if (CHIP_IS_E2(bp)) |
| 4533 | gpio_port = BP_PATH(bp); |
| 4534 | else |
| 4535 | gpio_port = params->port; |
| 4536 | swap_val = REG_RD(bp, NIG_REG_PORT_SWAP); |
| 4537 | swap_override = REG_RD(bp, NIG_REG_STRAP_OVERRIDE); |
| 4538 | return gpio_port ^ (swap_val && swap_override); |
| 4539 | } |
| 4540 | static void bnx2x_sfp_set_transmitter(struct link_params *params, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4541 | struct bnx2x_phy *phy, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4542 | u8 tx_en) |
| 4543 | { |
| 4544 | u16 val; |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 4545 | u8 port = params->port; |
| 4546 | struct bnx2x *bp = params->bp; |
| 4547 | u32 tx_en_mode; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4548 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4549 | /* Disable/Enable transmitter ( TX laser of the SFP+ module.)*/ |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 4550 | tx_en_mode = REG_RD(bp, params->shmem_base + |
| 4551 | offsetof(struct shmem_region, |
| 4552 | dev_info.port_hw_config[port].sfp_ctrl)) & |
| 4553 | PORT_HW_CFG_TX_LASER_MASK; |
| 4554 | DP(NETIF_MSG_LINK, "Setting transmitter tx_en=%x for port %x " |
| 4555 | "mode = %x\n", tx_en, port, tx_en_mode); |
| 4556 | switch (tx_en_mode) { |
| 4557 | case PORT_HW_CFG_TX_LASER_MDIO: |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4558 | |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 4559 | bnx2x_cl45_read(bp, phy, |
| 4560 | MDIO_PMA_DEVAD, |
| 4561 | MDIO_PMA_REG_PHY_IDENTIFIER, |
| 4562 | &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4563 | |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 4564 | if (tx_en) |
| 4565 | val &= ~(1<<15); |
| 4566 | else |
| 4567 | val |= (1<<15); |
| 4568 | |
| 4569 | bnx2x_cl45_write(bp, phy, |
| 4570 | MDIO_PMA_DEVAD, |
| 4571 | MDIO_PMA_REG_PHY_IDENTIFIER, |
| 4572 | val); |
| 4573 | break; |
| 4574 | case PORT_HW_CFG_TX_LASER_GPIO0: |
| 4575 | case PORT_HW_CFG_TX_LASER_GPIO1: |
| 4576 | case PORT_HW_CFG_TX_LASER_GPIO2: |
| 4577 | case PORT_HW_CFG_TX_LASER_GPIO3: |
| 4578 | { |
| 4579 | u16 gpio_pin; |
| 4580 | u8 gpio_port, gpio_mode; |
| 4581 | if (tx_en) |
| 4582 | gpio_mode = MISC_REGISTERS_GPIO_OUTPUT_HIGH; |
| 4583 | else |
| 4584 | gpio_mode = MISC_REGISTERS_GPIO_OUTPUT_LOW; |
| 4585 | |
| 4586 | gpio_pin = tx_en_mode - PORT_HW_CFG_TX_LASER_GPIO0; |
| 4587 | gpio_port = bnx2x_get_gpio_port(params); |
| 4588 | bnx2x_set_gpio(bp, gpio_pin, gpio_mode, gpio_port); |
| 4589 | break; |
| 4590 | } |
| 4591 | default: |
| 4592 | DP(NETIF_MSG_LINK, "Invalid TX_LASER_MDIO 0x%x\n", tx_en_mode); |
| 4593 | break; |
| 4594 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4595 | } |
| 4596 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 4597 | static int bnx2x_8726_read_sfp_module_eeprom(struct bnx2x_phy *phy, |
| 4598 | struct link_params *params, |
| 4599 | u16 addr, u8 byte_cnt, u8 *o_buf) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4600 | { |
| 4601 | struct bnx2x *bp = params->bp; |
| 4602 | u16 val = 0; |
| 4603 | u16 i; |
| 4604 | if (byte_cnt > 16) { |
| 4605 | DP(NETIF_MSG_LINK, "Reading from eeprom is" |
| 4606 | " is limited to 0xf\n"); |
| 4607 | return -EINVAL; |
| 4608 | } |
| 4609 | /* Set the read command byte count */ |
| 4610 | bnx2x_cl45_write(bp, phy, |
| 4611 | MDIO_PMA_DEVAD, MDIO_PMA_REG_SFP_TWO_WIRE_BYTE_CNT, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4612 | (byte_cnt | 0xa000)); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4613 | |
| 4614 | /* Set the read command address */ |
| 4615 | bnx2x_cl45_write(bp, phy, |
| 4616 | MDIO_PMA_DEVAD, MDIO_PMA_REG_SFP_TWO_WIRE_MEM_ADDR, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4617 | addr); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4618 | |
| 4619 | /* Activate read command */ |
| 4620 | bnx2x_cl45_write(bp, phy, |
| 4621 | MDIO_PMA_DEVAD, MDIO_PMA_REG_SFP_TWO_WIRE_CTRL, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4622 | 0x2c0f); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4623 | |
| 4624 | /* Wait up to 500us for command complete status */ |
| 4625 | for (i = 0; i < 100; i++) { |
| 4626 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4627 | MDIO_PMA_DEVAD, |
| 4628 | MDIO_PMA_REG_SFP_TWO_WIRE_CTRL, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4629 | if ((val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK) == |
| 4630 | MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_COMPLETE) |
| 4631 | break; |
| 4632 | udelay(5); |
| 4633 | } |
| 4634 | |
| 4635 | if ((val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK) != |
| 4636 | MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_COMPLETE) { |
| 4637 | DP(NETIF_MSG_LINK, |
| 4638 | "Got bad status 0x%x when reading from SFP+ EEPROM\n", |
| 4639 | (val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK)); |
| 4640 | return -EINVAL; |
| 4641 | } |
| 4642 | |
| 4643 | /* Read the buffer */ |
| 4644 | for (i = 0; i < byte_cnt; 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_8726_TWO_WIRE_DATA_BUF + i, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4648 | o_buf[i] = (u8)(val & MDIO_PMA_REG_8726_TWO_WIRE_DATA_MASK); |
| 4649 | } |
| 4650 | |
| 4651 | for (i = 0; i < 100; i++) { |
| 4652 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4653 | MDIO_PMA_DEVAD, |
| 4654 | MDIO_PMA_REG_SFP_TWO_WIRE_CTRL, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4655 | if ((val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK) == |
| 4656 | MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_IDLE) |
Joe Perches | 6f38ad9 | 2010-11-14 17:04:31 +0000 | [diff] [blame] | 4657 | return 0; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4658 | msleep(1); |
| 4659 | } |
| 4660 | return -EINVAL; |
| 4661 | } |
| 4662 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 4663 | static int bnx2x_8727_read_sfp_module_eeprom(struct bnx2x_phy *phy, |
| 4664 | struct link_params *params, |
| 4665 | u16 addr, u8 byte_cnt, u8 *o_buf) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4666 | { |
| 4667 | struct bnx2x *bp = params->bp; |
| 4668 | u16 val, i; |
| 4669 | |
| 4670 | if (byte_cnt > 16) { |
| 4671 | DP(NETIF_MSG_LINK, "Reading from eeprom is" |
| 4672 | " is limited to 0xf\n"); |
| 4673 | return -EINVAL; |
| 4674 | } |
| 4675 | |
| 4676 | /* Need to read from 1.8000 to clear it */ |
| 4677 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4678 | MDIO_PMA_DEVAD, |
| 4679 | MDIO_PMA_REG_SFP_TWO_WIRE_CTRL, |
| 4680 | &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4681 | |
| 4682 | /* Set the read command byte count */ |
| 4683 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4684 | MDIO_PMA_DEVAD, |
| 4685 | MDIO_PMA_REG_SFP_TWO_WIRE_BYTE_CNT, |
| 4686 | ((byte_cnt < 2) ? 2 : byte_cnt)); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4687 | |
| 4688 | /* Set the read command address */ |
| 4689 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4690 | MDIO_PMA_DEVAD, |
| 4691 | MDIO_PMA_REG_SFP_TWO_WIRE_MEM_ADDR, |
| 4692 | addr); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4693 | /* Set the destination address */ |
| 4694 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4695 | MDIO_PMA_DEVAD, |
| 4696 | 0x8004, |
| 4697 | MDIO_PMA_REG_8727_TWO_WIRE_DATA_BUF); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4698 | |
| 4699 | /* Activate read command */ |
| 4700 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4701 | MDIO_PMA_DEVAD, |
| 4702 | MDIO_PMA_REG_SFP_TWO_WIRE_CTRL, |
| 4703 | 0x8002); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 4704 | /* |
| 4705 | * Wait appropriate time for two-wire command to finish before |
| 4706 | * polling the status register |
| 4707 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4708 | msleep(1); |
| 4709 | |
| 4710 | /* Wait up to 500us for command complete status */ |
| 4711 | for (i = 0; i < 100; i++) { |
| 4712 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4713 | MDIO_PMA_DEVAD, |
| 4714 | MDIO_PMA_REG_SFP_TWO_WIRE_CTRL, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4715 | if ((val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK) == |
| 4716 | MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_COMPLETE) |
| 4717 | break; |
| 4718 | udelay(5); |
| 4719 | } |
| 4720 | |
| 4721 | if ((val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK) != |
| 4722 | MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_COMPLETE) { |
| 4723 | DP(NETIF_MSG_LINK, |
| 4724 | "Got bad status 0x%x when reading from SFP+ EEPROM\n", |
| 4725 | (val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK)); |
Yaniv Rosner | 65a001b | 2011-01-31 04:22:03 +0000 | [diff] [blame] | 4726 | return -EFAULT; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4727 | } |
| 4728 | |
| 4729 | /* Read the buffer */ |
| 4730 | for (i = 0; i < byte_cnt; i++) { |
| 4731 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4732 | MDIO_PMA_DEVAD, |
| 4733 | MDIO_PMA_REG_8727_TWO_WIRE_DATA_BUF + i, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4734 | o_buf[i] = (u8)(val & MDIO_PMA_REG_8727_TWO_WIRE_DATA_MASK); |
| 4735 | } |
| 4736 | |
| 4737 | for (i = 0; i < 100; i++) { |
| 4738 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4739 | MDIO_PMA_DEVAD, |
| 4740 | MDIO_PMA_REG_SFP_TWO_WIRE_CTRL, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4741 | if ((val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK) == |
| 4742 | MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_IDLE) |
Joe Perches | 6f38ad9 | 2010-11-14 17:04:31 +0000 | [diff] [blame] | 4743 | return 0; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4744 | msleep(1); |
| 4745 | } |
| 4746 | |
| 4747 | return -EINVAL; |
| 4748 | } |
| 4749 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 4750 | int bnx2x_read_sfp_module_eeprom(struct bnx2x_phy *phy, |
| 4751 | struct link_params *params, u16 addr, |
| 4752 | u8 byte_cnt, u8 *o_buf) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4753 | { |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 4754 | int rc = -EINVAL; |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 4755 | switch (phy->type) { |
| 4756 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726: |
| 4757 | rc = bnx2x_8726_read_sfp_module_eeprom(phy, params, addr, |
| 4758 | byte_cnt, o_buf); |
| 4759 | break; |
| 4760 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727: |
| 4761 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8722: |
| 4762 | rc = bnx2x_8727_read_sfp_module_eeprom(phy, params, addr, |
| 4763 | byte_cnt, o_buf); |
| 4764 | break; |
| 4765 | } |
| 4766 | return rc; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4767 | } |
| 4768 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 4769 | static int bnx2x_get_edc_mode(struct bnx2x_phy *phy, |
| 4770 | struct link_params *params, |
| 4771 | u16 *edc_mode) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4772 | { |
| 4773 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 4774 | u32 sync_offset = 0, phy_idx, media_types; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4775 | u8 val, check_limiting_mode = 0; |
| 4776 | *edc_mode = EDC_MODE_LIMITING; |
| 4777 | |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 4778 | phy->media_type = ETH_PHY_UNSPECIFIED; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4779 | /* First check for copper cable */ |
| 4780 | if (bnx2x_read_sfp_module_eeprom(phy, |
| 4781 | params, |
| 4782 | SFP_EEPROM_CON_TYPE_ADDR, |
| 4783 | 1, |
| 4784 | &val) != 0) { |
| 4785 | DP(NETIF_MSG_LINK, "Failed to read from SFP+ module EEPROM\n"); |
| 4786 | return -EINVAL; |
| 4787 | } |
| 4788 | |
| 4789 | switch (val) { |
| 4790 | case SFP_EEPROM_CON_TYPE_VAL_COPPER: |
| 4791 | { |
| 4792 | u8 copper_module_type; |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 4793 | phy->media_type = ETH_PHY_DA_TWINAX; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 4794 | /* |
| 4795 | * Check if its active cable (includes SFP+ module) |
| 4796 | * of passive cable |
| 4797 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4798 | if (bnx2x_read_sfp_module_eeprom(phy, |
| 4799 | params, |
| 4800 | SFP_EEPROM_FC_TX_TECH_ADDR, |
| 4801 | 1, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 4802 | &copper_module_type) != 0) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4803 | DP(NETIF_MSG_LINK, |
| 4804 | "Failed to read copper-cable-type" |
| 4805 | " from SFP+ EEPROM\n"); |
| 4806 | return -EINVAL; |
| 4807 | } |
| 4808 | |
| 4809 | if (copper_module_type & |
| 4810 | SFP_EEPROM_FC_TX_TECH_BITMASK_COPPER_ACTIVE) { |
| 4811 | DP(NETIF_MSG_LINK, "Active Copper cable detected\n"); |
| 4812 | check_limiting_mode = 1; |
| 4813 | } else if (copper_module_type & |
| 4814 | SFP_EEPROM_FC_TX_TECH_BITMASK_COPPER_PASSIVE) { |
| 4815 | DP(NETIF_MSG_LINK, "Passive Copper" |
| 4816 | " cable detected\n"); |
| 4817 | *edc_mode = |
| 4818 | EDC_MODE_PASSIVE_DAC; |
| 4819 | } else { |
| 4820 | DP(NETIF_MSG_LINK, "Unknown copper-cable-" |
| 4821 | "type 0x%x !!!\n", copper_module_type); |
| 4822 | return -EINVAL; |
| 4823 | } |
| 4824 | break; |
| 4825 | } |
| 4826 | case SFP_EEPROM_CON_TYPE_VAL_LC: |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 4827 | phy->media_type = ETH_PHY_SFP_FIBER; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4828 | DP(NETIF_MSG_LINK, "Optic module detected\n"); |
| 4829 | check_limiting_mode = 1; |
| 4830 | break; |
| 4831 | default: |
| 4832 | DP(NETIF_MSG_LINK, "Unable to determine module type 0x%x !!!\n", |
| 4833 | val); |
| 4834 | return -EINVAL; |
| 4835 | } |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 4836 | sync_offset = params->shmem_base + |
| 4837 | offsetof(struct shmem_region, |
| 4838 | dev_info.port_hw_config[params->port].media_type); |
| 4839 | media_types = REG_RD(bp, sync_offset); |
| 4840 | /* Update media type for non-PMF sync */ |
| 4841 | for (phy_idx = INT_PHY; phy_idx < MAX_PHYS; phy_idx++) { |
| 4842 | if (&(params->phy[phy_idx]) == phy) { |
| 4843 | media_types &= ~(PORT_HW_CFG_MEDIA_TYPE_PHY0_MASK << |
| 4844 | (PORT_HW_CFG_MEDIA_TYPE_PHY1_SHIFT * phy_idx)); |
| 4845 | media_types |= ((phy->media_type & |
| 4846 | PORT_HW_CFG_MEDIA_TYPE_PHY0_MASK) << |
| 4847 | (PORT_HW_CFG_MEDIA_TYPE_PHY1_SHIFT * phy_idx)); |
| 4848 | break; |
| 4849 | } |
| 4850 | } |
| 4851 | REG_WR(bp, sync_offset, media_types); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4852 | if (check_limiting_mode) { |
| 4853 | u8 options[SFP_EEPROM_OPTIONS_SIZE]; |
| 4854 | if (bnx2x_read_sfp_module_eeprom(phy, |
| 4855 | params, |
| 4856 | SFP_EEPROM_OPTIONS_ADDR, |
| 4857 | SFP_EEPROM_OPTIONS_SIZE, |
| 4858 | options) != 0) { |
| 4859 | DP(NETIF_MSG_LINK, "Failed to read Option" |
| 4860 | " field from module EEPROM\n"); |
| 4861 | return -EINVAL; |
| 4862 | } |
| 4863 | if ((options[0] & SFP_EEPROM_OPTIONS_LINEAR_RX_OUT_MASK)) |
| 4864 | *edc_mode = EDC_MODE_LINEAR; |
| 4865 | else |
| 4866 | *edc_mode = EDC_MODE_LIMITING; |
| 4867 | } |
| 4868 | DP(NETIF_MSG_LINK, "EDC mode is set to 0x%x\n", *edc_mode); |
| 4869 | return 0; |
| 4870 | } |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 4871 | /* |
| 4872 | * This function read the relevant field from the module (SFP+), and verify it |
| 4873 | * is compliant with this board |
| 4874 | */ |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 4875 | static int bnx2x_verify_sfp_module(struct bnx2x_phy *phy, |
| 4876 | struct link_params *params) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4877 | { |
| 4878 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 4879 | u32 val, cmd; |
| 4880 | u32 fw_resp, fw_cmd_param; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4881 | char vendor_name[SFP_EEPROM_VENDOR_NAME_SIZE+1]; |
| 4882 | char vendor_pn[SFP_EEPROM_PART_NO_SIZE+1]; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 4883 | phy->flags &= ~FLAGS_SFP_NOT_APPROVED; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4884 | val = REG_RD(bp, params->shmem_base + |
| 4885 | offsetof(struct shmem_region, dev_info. |
| 4886 | port_feature_config[params->port].config)); |
| 4887 | if ((val & PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK) == |
| 4888 | PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_NO_ENFORCEMENT) { |
| 4889 | DP(NETIF_MSG_LINK, "NOT enforcing module verification\n"); |
| 4890 | return 0; |
| 4891 | } |
| 4892 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 4893 | if (params->feature_config_flags & |
| 4894 | FEATURE_CONFIG_BC_SUPPORTS_DUAL_PHY_OPT_MDL_VRFY) { |
| 4895 | /* Use specific phy request */ |
| 4896 | cmd = DRV_MSG_CODE_VRFY_SPECIFIC_PHY_OPT_MDL; |
| 4897 | } else if (params->feature_config_flags & |
| 4898 | FEATURE_CONFIG_BC_SUPPORTS_OPT_MDL_VRFY) { |
| 4899 | /* Use first phy request only in case of non-dual media*/ |
| 4900 | if (DUAL_MEDIA(params)) { |
| 4901 | DP(NETIF_MSG_LINK, "FW does not support OPT MDL " |
| 4902 | "verification\n"); |
| 4903 | return -EINVAL; |
| 4904 | } |
| 4905 | cmd = DRV_MSG_CODE_VRFY_FIRST_PHY_OPT_MDL; |
| 4906 | } else { |
| 4907 | /* No support in OPT MDL detection */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4908 | DP(NETIF_MSG_LINK, "FW does not support OPT MDL " |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 4909 | "verification\n"); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4910 | return -EINVAL; |
| 4911 | } |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 4912 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 4913 | fw_cmd_param = FW_PARAM_SET(phy->addr, phy->type, phy->mdio_ctrl); |
| 4914 | fw_resp = bnx2x_fw_command(bp, cmd, fw_cmd_param); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4915 | if (fw_resp == FW_MSG_CODE_VRFY_OPT_MDL_SUCCESS) { |
| 4916 | DP(NETIF_MSG_LINK, "Approved module\n"); |
| 4917 | return 0; |
| 4918 | } |
| 4919 | |
| 4920 | /* format the warning message */ |
| 4921 | if (bnx2x_read_sfp_module_eeprom(phy, |
| 4922 | params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4923 | SFP_EEPROM_VENDOR_NAME_ADDR, |
| 4924 | SFP_EEPROM_VENDOR_NAME_SIZE, |
| 4925 | (u8 *)vendor_name)) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4926 | vendor_name[0] = '\0'; |
| 4927 | else |
| 4928 | vendor_name[SFP_EEPROM_VENDOR_NAME_SIZE] = '\0'; |
| 4929 | if (bnx2x_read_sfp_module_eeprom(phy, |
| 4930 | params, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 4931 | SFP_EEPROM_PART_NO_ADDR, |
| 4932 | SFP_EEPROM_PART_NO_SIZE, |
| 4933 | (u8 *)vendor_pn)) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4934 | vendor_pn[0] = '\0'; |
| 4935 | else |
| 4936 | vendor_pn[SFP_EEPROM_PART_NO_SIZE] = '\0'; |
| 4937 | |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 4938 | netdev_err(bp->dev, "Warning: Unqualified SFP+ module detected," |
| 4939 | " Port %d from %s part number %s\n", |
| 4940 | params->port, vendor_name, vendor_pn); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 4941 | phy->flags |= FLAGS_SFP_NOT_APPROVED; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4942 | return -EINVAL; |
| 4943 | } |
| 4944 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 4945 | static int bnx2x_wait_for_sfp_module_initialized(struct bnx2x_phy *phy, |
| 4946 | struct link_params *params) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4947 | |
| 4948 | { |
| 4949 | u8 val; |
| 4950 | struct bnx2x *bp = params->bp; |
| 4951 | u16 timeout; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 4952 | /* |
| 4953 | * Initialization time after hot-plug may take up to 300ms for |
| 4954 | * some phys type ( e.g. JDSU ) |
| 4955 | */ |
| 4956 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4957 | for (timeout = 0; timeout < 60; timeout++) { |
| 4958 | if (bnx2x_read_sfp_module_eeprom(phy, params, 1, 1, &val) |
| 4959 | == 0) { |
| 4960 | DP(NETIF_MSG_LINK, "SFP+ module initialization " |
| 4961 | "took %d ms\n", timeout * 5); |
| 4962 | return 0; |
| 4963 | } |
| 4964 | msleep(5); |
| 4965 | } |
| 4966 | return -EINVAL; |
| 4967 | } |
| 4968 | |
| 4969 | static void bnx2x_8727_power_module(struct bnx2x *bp, |
| 4970 | struct bnx2x_phy *phy, |
| 4971 | u8 is_power_up) { |
| 4972 | /* Make sure GPIOs are not using for LED mode */ |
| 4973 | u16 val; |
| 4974 | /* |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 4975 | * 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] | 4976 | * operating as INPUT or as OUTPUT. Bit 1 is for input, and 0 for |
| 4977 | * output |
| 4978 | * Bits 0-1 determine the gpios value for OUTPUT in case bit 4 val is 0 |
| 4979 | * Bits 8-9 determine the gpios value for INPUT in case bit 4 val is 1 |
| 4980 | * where the 1st bit is the over-current(only input), and 2nd bit is |
| 4981 | * for power( only output ) |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 4982 | * |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4983 | * In case of NOC feature is disabled and power is up, set GPIO control |
| 4984 | * as input to enable listening of over-current indication |
| 4985 | */ |
| 4986 | if (phy->flags & FLAGS_NOC) |
| 4987 | return; |
Yaniv Rosner | 27d0243 | 2011-05-31 21:27:48 +0000 | [diff] [blame] | 4988 | if (is_power_up) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4989 | val = (1<<4); |
| 4990 | else |
| 4991 | /* |
| 4992 | * Set GPIO control to OUTPUT, and set the power bit |
| 4993 | * to according to the is_power_up |
| 4994 | */ |
Yaniv Rosner | 27d0243 | 2011-05-31 21:27:48 +0000 | [diff] [blame] | 4995 | val = (1<<1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 4996 | |
| 4997 | bnx2x_cl45_write(bp, phy, |
| 4998 | MDIO_PMA_DEVAD, |
| 4999 | MDIO_PMA_REG_8727_GPIO_CTRL, |
| 5000 | val); |
| 5001 | } |
| 5002 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 5003 | static int bnx2x_8726_set_limiting_mode(struct bnx2x *bp, |
| 5004 | struct bnx2x_phy *phy, |
| 5005 | u16 edc_mode) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5006 | { |
| 5007 | u16 cur_limiting_mode; |
| 5008 | |
| 5009 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5010 | MDIO_PMA_DEVAD, |
| 5011 | MDIO_PMA_REG_ROM_VER2, |
| 5012 | &cur_limiting_mode); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5013 | DP(NETIF_MSG_LINK, "Current Limiting mode is 0x%x\n", |
| 5014 | cur_limiting_mode); |
| 5015 | |
| 5016 | if (edc_mode == EDC_MODE_LIMITING) { |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5017 | DP(NETIF_MSG_LINK, "Setting LIMITING MODE\n"); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5018 | bnx2x_cl45_write(bp, phy, |
| 5019 | MDIO_PMA_DEVAD, |
| 5020 | MDIO_PMA_REG_ROM_VER2, |
| 5021 | EDC_MODE_LIMITING); |
| 5022 | } else { /* LRM mode ( default )*/ |
| 5023 | |
| 5024 | DP(NETIF_MSG_LINK, "Setting LRM MODE\n"); |
| 5025 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5026 | /* |
| 5027 | * Changing to LRM mode takes quite few seconds. So do it only |
| 5028 | * if current mode is limiting (default is LRM) |
| 5029 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5030 | if (cur_limiting_mode != EDC_MODE_LIMITING) |
| 5031 | return 0; |
| 5032 | |
| 5033 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5034 | MDIO_PMA_DEVAD, |
| 5035 | MDIO_PMA_REG_LRM_MODE, |
| 5036 | 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5037 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5038 | MDIO_PMA_DEVAD, |
| 5039 | MDIO_PMA_REG_ROM_VER2, |
| 5040 | 0x128); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5041 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5042 | MDIO_PMA_DEVAD, |
| 5043 | MDIO_PMA_REG_MISC_CTRL0, |
| 5044 | 0x4008); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5045 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5046 | MDIO_PMA_DEVAD, |
| 5047 | MDIO_PMA_REG_LRM_MODE, |
| 5048 | 0xaaaa); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5049 | } |
| 5050 | return 0; |
| 5051 | } |
| 5052 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 5053 | static int bnx2x_8727_set_limiting_mode(struct bnx2x *bp, |
| 5054 | struct bnx2x_phy *phy, |
| 5055 | u16 edc_mode) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5056 | { |
| 5057 | u16 phy_identifier; |
| 5058 | u16 rom_ver2_val; |
| 5059 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5060 | MDIO_PMA_DEVAD, |
| 5061 | MDIO_PMA_REG_PHY_IDENTIFIER, |
| 5062 | &phy_identifier); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5063 | |
| 5064 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5065 | MDIO_PMA_DEVAD, |
| 5066 | MDIO_PMA_REG_PHY_IDENTIFIER, |
| 5067 | (phy_identifier & ~(1<<9))); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5068 | |
| 5069 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5070 | MDIO_PMA_DEVAD, |
| 5071 | MDIO_PMA_REG_ROM_VER2, |
| 5072 | &rom_ver2_val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5073 | /* Keep the MSB 8-bits, and set the LSB 8-bits with the edc_mode */ |
| 5074 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5075 | MDIO_PMA_DEVAD, |
| 5076 | MDIO_PMA_REG_ROM_VER2, |
| 5077 | (rom_ver2_val & 0xff00) | (edc_mode & 0x00ff)); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5078 | |
| 5079 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5080 | MDIO_PMA_DEVAD, |
| 5081 | MDIO_PMA_REG_PHY_IDENTIFIER, |
| 5082 | (phy_identifier | (1<<9))); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5083 | |
| 5084 | return 0; |
| 5085 | } |
| 5086 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5087 | static void bnx2x_8727_specific_func(struct bnx2x_phy *phy, |
| 5088 | struct link_params *params, |
| 5089 | u32 action) |
| 5090 | { |
| 5091 | struct bnx2x *bp = params->bp; |
| 5092 | |
| 5093 | switch (action) { |
| 5094 | case DISABLE_TX: |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 5095 | bnx2x_sfp_set_transmitter(params, phy, 0); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5096 | break; |
| 5097 | case ENABLE_TX: |
| 5098 | if (!(phy->flags & FLAGS_SFP_NOT_APPROVED)) |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 5099 | bnx2x_sfp_set_transmitter(params, phy, 1); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5100 | break; |
| 5101 | default: |
| 5102 | DP(NETIF_MSG_LINK, "Function 0x%x not supported by 8727\n", |
| 5103 | action); |
| 5104 | return; |
| 5105 | } |
| 5106 | } |
| 5107 | |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 5108 | static void bnx2x_set_sfp_module_fault_led(struct link_params *params, |
| 5109 | u8 gpio_mode) |
| 5110 | { |
| 5111 | struct bnx2x *bp = params->bp; |
| 5112 | |
| 5113 | u32 fault_led_gpio = REG_RD(bp, params->shmem_base + |
| 5114 | offsetof(struct shmem_region, |
| 5115 | dev_info.port_hw_config[params->port].sfp_ctrl)) & |
| 5116 | PORT_HW_CFG_FAULT_MODULE_LED_MASK; |
| 5117 | switch (fault_led_gpio) { |
| 5118 | case PORT_HW_CFG_FAULT_MODULE_LED_DISABLED: |
| 5119 | return; |
| 5120 | case PORT_HW_CFG_FAULT_MODULE_LED_GPIO0: |
| 5121 | case PORT_HW_CFG_FAULT_MODULE_LED_GPIO1: |
| 5122 | case PORT_HW_CFG_FAULT_MODULE_LED_GPIO2: |
| 5123 | case PORT_HW_CFG_FAULT_MODULE_LED_GPIO3: |
| 5124 | { |
| 5125 | u8 gpio_port = bnx2x_get_gpio_port(params); |
| 5126 | u16 gpio_pin = fault_led_gpio - |
| 5127 | PORT_HW_CFG_FAULT_MODULE_LED_GPIO0; |
| 5128 | DP(NETIF_MSG_LINK, "Set fault module-detected led " |
| 5129 | "pin %x port %x mode %x\n", |
| 5130 | gpio_pin, gpio_port, gpio_mode); |
| 5131 | bnx2x_set_gpio(bp, gpio_pin, gpio_mode, gpio_port); |
| 5132 | } |
| 5133 | break; |
| 5134 | default: |
| 5135 | DP(NETIF_MSG_LINK, "Error: Invalid fault led mode 0x%x\n", |
| 5136 | fault_led_gpio); |
| 5137 | } |
| 5138 | } |
| 5139 | |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 5140 | static void bnx2x_power_sfp_module(struct link_params *params, |
| 5141 | struct bnx2x_phy *phy, |
| 5142 | u8 power) |
| 5143 | { |
| 5144 | struct bnx2x *bp = params->bp; |
| 5145 | DP(NETIF_MSG_LINK, "Setting SFP+ power to %x\n", power); |
| 5146 | |
| 5147 | switch (phy->type) { |
| 5148 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727: |
| 5149 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8722: |
| 5150 | bnx2x_8727_power_module(params->bp, phy, power); |
| 5151 | break; |
| 5152 | default: |
| 5153 | break; |
| 5154 | } |
| 5155 | } |
| 5156 | |
| 5157 | static void bnx2x_set_limiting_mode(struct link_params *params, |
| 5158 | struct bnx2x_phy *phy, |
| 5159 | u16 edc_mode) |
| 5160 | { |
| 5161 | switch (phy->type) { |
| 5162 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726: |
| 5163 | bnx2x_8726_set_limiting_mode(params->bp, phy, edc_mode); |
| 5164 | break; |
| 5165 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727: |
| 5166 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8722: |
| 5167 | bnx2x_8727_set_limiting_mode(params->bp, phy, edc_mode); |
| 5168 | break; |
| 5169 | } |
| 5170 | } |
| 5171 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 5172 | int bnx2x_sfp_module_detection(struct bnx2x_phy *phy, |
| 5173 | struct link_params *params) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5174 | { |
| 5175 | struct bnx2x *bp = params->bp; |
| 5176 | u16 edc_mode; |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 5177 | int rc = 0; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5178 | |
| 5179 | u32 val = REG_RD(bp, params->shmem_base + |
| 5180 | offsetof(struct shmem_region, dev_info. |
| 5181 | port_feature_config[params->port].config)); |
| 5182 | |
| 5183 | DP(NETIF_MSG_LINK, "SFP+ module plugged in/out detected on port %d\n", |
| 5184 | params->port); |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 5185 | /* Power up module */ |
| 5186 | bnx2x_power_sfp_module(params, phy, 1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5187 | if (bnx2x_get_edc_mode(phy, params, &edc_mode) != 0) { |
| 5188 | DP(NETIF_MSG_LINK, "Failed to get valid module type\n"); |
| 5189 | return -EINVAL; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5190 | } else if (bnx2x_verify_sfp_module(phy, params) != 0) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5191 | /* check SFP+ module compatibility */ |
| 5192 | DP(NETIF_MSG_LINK, "Module verification failed!!\n"); |
| 5193 | rc = -EINVAL; |
| 5194 | /* Turn on fault module-detected led */ |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 5195 | bnx2x_set_sfp_module_fault_led(params, |
| 5196 | MISC_REGISTERS_GPIO_HIGH); |
| 5197 | |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 5198 | /* Check if need to power down the SFP+ module */ |
| 5199 | if ((val & PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK) == |
| 5200 | PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_POWER_DOWN) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5201 | DP(NETIF_MSG_LINK, "Shutdown SFP+ module!!\n"); |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 5202 | bnx2x_power_sfp_module(params, phy, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5203 | return rc; |
| 5204 | } |
| 5205 | } else { |
| 5206 | /* Turn off fault module-detected led */ |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 5207 | bnx2x_set_sfp_module_fault_led(params, MISC_REGISTERS_GPIO_LOW); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5208 | } |
| 5209 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5210 | /* |
| 5211 | * Check and set limiting mode / LRM mode on 8726. On 8727 it |
| 5212 | * is done automatically |
| 5213 | */ |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 5214 | bnx2x_set_limiting_mode(params, phy, edc_mode); |
| 5215 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5216 | /* |
| 5217 | * Enable transmit for this module if the module is approved, or |
| 5218 | * if unapproved modules should also enable the Tx laser |
| 5219 | */ |
| 5220 | if (rc == 0 || |
| 5221 | (val & PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK) != |
| 5222 | PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_DISABLE_TX_LASER) |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 5223 | bnx2x_sfp_set_transmitter(params, phy, 1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5224 | else |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 5225 | bnx2x_sfp_set_transmitter(params, phy, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5226 | |
| 5227 | return rc; |
| 5228 | } |
| 5229 | |
| 5230 | void bnx2x_handle_module_detect_int(struct link_params *params) |
| 5231 | { |
| 5232 | struct bnx2x *bp = params->bp; |
| 5233 | struct bnx2x_phy *phy = ¶ms->phy[EXT_PHY1]; |
| 5234 | u32 gpio_val; |
| 5235 | u8 port = params->port; |
| 5236 | |
| 5237 | /* Set valid module led off */ |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 5238 | bnx2x_set_sfp_module_fault_led(params, MISC_REGISTERS_GPIO_HIGH); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5239 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5240 | /* Get current gpio val reflecting module plugged in / out*/ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5241 | gpio_val = bnx2x_get_gpio(bp, MISC_REGISTERS_GPIO_3, port); |
| 5242 | |
| 5243 | /* Call the handling function in case module is detected */ |
| 5244 | if (gpio_val == 0) { |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 5245 | bnx2x_power_sfp_module(params, phy, 1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5246 | bnx2x_set_gpio_int(bp, MISC_REGISTERS_GPIO_3, |
| 5247 | MISC_REGISTERS_GPIO_INT_OUTPUT_CLR, |
| 5248 | port); |
| 5249 | |
| 5250 | if (bnx2x_wait_for_sfp_module_initialized(phy, params) == 0) |
| 5251 | bnx2x_sfp_module_detection(phy, params); |
| 5252 | else |
| 5253 | DP(NETIF_MSG_LINK, "SFP+ module is not initialized\n"); |
| 5254 | } else { |
| 5255 | u32 val = REG_RD(bp, params->shmem_base + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5256 | offsetof(struct shmem_region, dev_info. |
| 5257 | port_feature_config[params->port]. |
| 5258 | config)); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5259 | |
| 5260 | bnx2x_set_gpio_int(bp, MISC_REGISTERS_GPIO_3, |
| 5261 | MISC_REGISTERS_GPIO_INT_OUTPUT_SET, |
| 5262 | port); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5263 | /* |
| 5264 | * Module was plugged out. |
| 5265 | * Disable transmit for this module |
| 5266 | */ |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 5267 | phy->media_type = ETH_PHY_NOT_PRESENT; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5268 | if ((val & PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK) == |
| 5269 | PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_DISABLE_TX_LASER) |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 5270 | bnx2x_sfp_set_transmitter(params, phy, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5271 | } |
| 5272 | } |
| 5273 | |
| 5274 | /******************************************************************/ |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 5275 | /* Used by 8706 and 8727 */ |
| 5276 | /******************************************************************/ |
| 5277 | static void bnx2x_sfp_mask_fault(struct bnx2x *bp, |
| 5278 | struct bnx2x_phy *phy, |
| 5279 | u16 alarm_status_offset, |
| 5280 | u16 alarm_ctrl_offset) |
| 5281 | { |
| 5282 | u16 alarm_status, val; |
| 5283 | bnx2x_cl45_read(bp, phy, |
| 5284 | MDIO_PMA_DEVAD, alarm_status_offset, |
| 5285 | &alarm_status); |
| 5286 | bnx2x_cl45_read(bp, phy, |
| 5287 | MDIO_PMA_DEVAD, alarm_status_offset, |
| 5288 | &alarm_status); |
| 5289 | /* Mask or enable the fault event. */ |
| 5290 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, alarm_ctrl_offset, &val); |
| 5291 | if (alarm_status & (1<<0)) |
| 5292 | val &= ~(1<<0); |
| 5293 | else |
| 5294 | val |= (1<<0); |
| 5295 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, alarm_ctrl_offset, val); |
| 5296 | } |
| 5297 | /******************************************************************/ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5298 | /* common BCM8706/BCM8726 PHY SECTION */ |
| 5299 | /******************************************************************/ |
| 5300 | static u8 bnx2x_8706_8726_read_status(struct bnx2x_phy *phy, |
| 5301 | struct link_params *params, |
| 5302 | struct link_vars *vars) |
| 5303 | { |
| 5304 | u8 link_up = 0; |
| 5305 | u16 val1, val2, rx_sd, pcs_status; |
| 5306 | struct bnx2x *bp = params->bp; |
| 5307 | DP(NETIF_MSG_LINK, "XGXS 8706/8726\n"); |
| 5308 | /* Clear RX Alarm*/ |
| 5309 | bnx2x_cl45_read(bp, phy, |
| 5310 | MDIO_PMA_DEVAD, MDIO_PMA_REG_RX_ALARM, &val2); |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 5311 | |
| 5312 | bnx2x_sfp_mask_fault(bp, phy, MDIO_PMA_REG_TX_ALARM, |
| 5313 | MDIO_PMA_REG_TX_ALARM_CTRL); |
| 5314 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5315 | /* clear LASI indication*/ |
| 5316 | bnx2x_cl45_read(bp, phy, |
| 5317 | MDIO_PMA_DEVAD, MDIO_PMA_REG_LASI_STATUS, &val1); |
| 5318 | bnx2x_cl45_read(bp, phy, |
| 5319 | MDIO_PMA_DEVAD, MDIO_PMA_REG_LASI_STATUS, &val2); |
| 5320 | DP(NETIF_MSG_LINK, "8706/8726 LASI status 0x%x--> 0x%x\n", val1, val2); |
| 5321 | |
| 5322 | bnx2x_cl45_read(bp, phy, |
| 5323 | MDIO_PMA_DEVAD, MDIO_PMA_REG_RX_SD, &rx_sd); |
| 5324 | bnx2x_cl45_read(bp, phy, |
| 5325 | MDIO_PCS_DEVAD, MDIO_PCS_REG_STATUS, &pcs_status); |
| 5326 | bnx2x_cl45_read(bp, phy, |
| 5327 | MDIO_AN_DEVAD, MDIO_AN_REG_LINK_STATUS, &val2); |
| 5328 | bnx2x_cl45_read(bp, phy, |
| 5329 | MDIO_AN_DEVAD, MDIO_AN_REG_LINK_STATUS, &val2); |
| 5330 | |
| 5331 | DP(NETIF_MSG_LINK, "8706/8726 rx_sd 0x%x pcs_status 0x%x 1Gbps" |
| 5332 | " link_status 0x%x\n", rx_sd, pcs_status, val2); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5333 | /* |
| 5334 | * link is up if both bit 0 of pmd_rx_sd and bit 0 of pcs_status |
| 5335 | * are set, or if the autoneg bit 1 is set |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5336 | */ |
| 5337 | link_up = ((rx_sd & pcs_status & 0x1) || (val2 & (1<<1))); |
| 5338 | if (link_up) { |
| 5339 | if (val2 & (1<<1)) |
| 5340 | vars->line_speed = SPEED_1000; |
| 5341 | else |
| 5342 | vars->line_speed = SPEED_10000; |
| 5343 | bnx2x_ext_phy_resolve_fc(phy, params, vars); |
Yaniv Rosner | 791f18c | 2011-01-18 04:33:42 +0000 | [diff] [blame] | 5344 | vars->duplex = DUPLEX_FULL; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5345 | } |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 5346 | |
| 5347 | /* Capture 10G link fault. Read twice to clear stale value. */ |
| 5348 | if (vars->line_speed == SPEED_10000) { |
| 5349 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, |
| 5350 | MDIO_PMA_REG_TX_ALARM, &val1); |
| 5351 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, |
| 5352 | MDIO_PMA_REG_TX_ALARM, &val1); |
| 5353 | if (val1 & (1<<0)) |
| 5354 | vars->fault_detected = 1; |
| 5355 | } |
| 5356 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5357 | return link_up; |
| 5358 | } |
| 5359 | |
| 5360 | /******************************************************************/ |
| 5361 | /* BCM8706 PHY SECTION */ |
| 5362 | /******************************************************************/ |
| 5363 | static u8 bnx2x_8706_config_init(struct bnx2x_phy *phy, |
| 5364 | struct link_params *params, |
| 5365 | struct link_vars *vars) |
| 5366 | { |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 5367 | u32 tx_en_mode; |
| 5368 | u16 cnt, val, tmp1; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5369 | struct bnx2x *bp = params->bp; |
| 5370 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5371 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, params->port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5372 | /* HW reset */ |
| 5373 | bnx2x_ext_phy_hw_reset(bp, params->port); |
| 5374 | 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] | 5375 | bnx2x_wait_reset_complete(bp, phy, params); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5376 | |
| 5377 | /* Wait until fw is loaded */ |
| 5378 | for (cnt = 0; cnt < 100; cnt++) { |
| 5379 | bnx2x_cl45_read(bp, phy, |
| 5380 | MDIO_PMA_DEVAD, MDIO_PMA_REG_ROM_VER1, &val); |
| 5381 | if (val) |
| 5382 | break; |
| 5383 | msleep(10); |
| 5384 | } |
| 5385 | DP(NETIF_MSG_LINK, "XGXS 8706 is initialized after %d ms\n", cnt); |
| 5386 | if ((params->feature_config_flags & |
| 5387 | FEATURE_CONFIG_OVERRIDE_PREEMPHASIS_ENABLED)) { |
| 5388 | u8 i; |
| 5389 | u16 reg; |
| 5390 | for (i = 0; i < 4; i++) { |
| 5391 | reg = MDIO_XS_8706_REG_BANK_RX0 + |
| 5392 | i*(MDIO_XS_8706_REG_BANK_RX1 - |
| 5393 | MDIO_XS_8706_REG_BANK_RX0); |
| 5394 | bnx2x_cl45_read(bp, phy, MDIO_XS_DEVAD, reg, &val); |
| 5395 | /* Clear first 3 bits of the control */ |
| 5396 | val &= ~0x7; |
| 5397 | /* Set control bits according to configuration */ |
| 5398 | val |= (phy->rx_preemphasis[i] & 0x7); |
| 5399 | DP(NETIF_MSG_LINK, "Setting RX Equalizer to BCM8706" |
| 5400 | " reg 0x%x <-- val 0x%x\n", reg, val); |
| 5401 | bnx2x_cl45_write(bp, phy, MDIO_XS_DEVAD, reg, val); |
| 5402 | } |
| 5403 | } |
| 5404 | /* Force speed */ |
| 5405 | if (phy->req_line_speed == SPEED_10000) { |
| 5406 | DP(NETIF_MSG_LINK, "XGXS 8706 force 10Gbps\n"); |
| 5407 | |
| 5408 | bnx2x_cl45_write(bp, phy, |
| 5409 | MDIO_PMA_DEVAD, |
| 5410 | MDIO_PMA_REG_DIGITAL_CTRL, 0x400); |
| 5411 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 5412 | MDIO_PMA_DEVAD, MDIO_PMA_REG_TX_ALARM_CTRL, |
| 5413 | 0); |
| 5414 | /* Arm LASI for link and Tx fault. */ |
| 5415 | bnx2x_cl45_write(bp, phy, |
| 5416 | MDIO_PMA_DEVAD, MDIO_PMA_REG_LASI_CTRL, 3); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5417 | } else { |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 5418 | /* Force 1Gbps using autoneg with 1G advertisement */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5419 | |
| 5420 | /* Allow CL37 through CL73 */ |
| 5421 | DP(NETIF_MSG_LINK, "XGXS 8706 AutoNeg\n"); |
| 5422 | bnx2x_cl45_write(bp, phy, |
| 5423 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_CL73, 0x040c); |
| 5424 | |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 5425 | /* Enable Full-Duplex advertisement on CL37 */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5426 | bnx2x_cl45_write(bp, phy, |
| 5427 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_FC_LP, 0x0020); |
| 5428 | /* Enable CL37 AN */ |
| 5429 | bnx2x_cl45_write(bp, phy, |
| 5430 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_AN, 0x1000); |
| 5431 | /* 1G support */ |
| 5432 | bnx2x_cl45_write(bp, phy, |
| 5433 | MDIO_AN_DEVAD, MDIO_AN_REG_ADV, (1<<5)); |
| 5434 | |
| 5435 | /* Enable clause 73 AN */ |
| 5436 | bnx2x_cl45_write(bp, phy, |
| 5437 | MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, 0x1200); |
| 5438 | bnx2x_cl45_write(bp, phy, |
| 5439 | MDIO_PMA_DEVAD, MDIO_PMA_REG_RX_ALARM_CTRL, |
| 5440 | 0x0400); |
| 5441 | bnx2x_cl45_write(bp, phy, |
| 5442 | MDIO_PMA_DEVAD, MDIO_PMA_REG_LASI_CTRL, |
| 5443 | 0x0004); |
| 5444 | } |
| 5445 | bnx2x_save_bcm_spirom_ver(bp, phy, params->port); |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 5446 | |
| 5447 | /* |
| 5448 | * If TX Laser is controlled by GPIO_0, do not let PHY go into low |
| 5449 | * power mode, if TX Laser is disabled |
| 5450 | */ |
| 5451 | |
| 5452 | tx_en_mode = REG_RD(bp, params->shmem_base + |
| 5453 | offsetof(struct shmem_region, |
| 5454 | dev_info.port_hw_config[params->port].sfp_ctrl)) |
| 5455 | & PORT_HW_CFG_TX_LASER_MASK; |
| 5456 | |
| 5457 | if (tx_en_mode == PORT_HW_CFG_TX_LASER_GPIO0) { |
| 5458 | DP(NETIF_MSG_LINK, "Enabling TXONOFF_PWRDN_DIS\n"); |
| 5459 | bnx2x_cl45_read(bp, phy, |
| 5460 | MDIO_PMA_DEVAD, MDIO_PMA_REG_DIGITAL_CTRL, &tmp1); |
| 5461 | tmp1 |= 0x1; |
| 5462 | bnx2x_cl45_write(bp, phy, |
| 5463 | MDIO_PMA_DEVAD, MDIO_PMA_REG_DIGITAL_CTRL, tmp1); |
| 5464 | } |
| 5465 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5466 | return 0; |
| 5467 | } |
| 5468 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 5469 | static int bnx2x_8706_read_status(struct bnx2x_phy *phy, |
| 5470 | struct link_params *params, |
| 5471 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5472 | { |
| 5473 | return bnx2x_8706_8726_read_status(phy, params, vars); |
| 5474 | } |
| 5475 | |
| 5476 | /******************************************************************/ |
| 5477 | /* BCM8726 PHY SECTION */ |
| 5478 | /******************************************************************/ |
| 5479 | static void bnx2x_8726_config_loopback(struct bnx2x_phy *phy, |
| 5480 | struct link_params *params) |
| 5481 | { |
| 5482 | struct bnx2x *bp = params->bp; |
| 5483 | DP(NETIF_MSG_LINK, "PMA/PMD ext_phy_loopback: 8726\n"); |
| 5484 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 0x0001); |
| 5485 | } |
| 5486 | |
| 5487 | static void bnx2x_8726_external_rom_boot(struct bnx2x_phy *phy, |
| 5488 | struct link_params *params) |
| 5489 | { |
| 5490 | struct bnx2x *bp = params->bp; |
| 5491 | /* Need to wait 100ms after reset */ |
| 5492 | msleep(100); |
| 5493 | |
| 5494 | /* Micro controller re-boot */ |
| 5495 | bnx2x_cl45_write(bp, phy, |
| 5496 | MDIO_PMA_DEVAD, MDIO_PMA_REG_GEN_CTRL, 0x018B); |
| 5497 | |
| 5498 | /* Set soft reset */ |
| 5499 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5500 | MDIO_PMA_DEVAD, |
| 5501 | MDIO_PMA_REG_GEN_CTRL, |
| 5502 | MDIO_PMA_REG_GEN_CTRL_ROM_MICRO_RESET); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5503 | |
| 5504 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5505 | MDIO_PMA_DEVAD, |
| 5506 | MDIO_PMA_REG_MISC_CTRL1, 0x0001); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5507 | |
| 5508 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5509 | MDIO_PMA_DEVAD, |
| 5510 | MDIO_PMA_REG_GEN_CTRL, |
| 5511 | MDIO_PMA_REG_GEN_CTRL_ROM_RESET_INTERNAL_MP); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5512 | |
| 5513 | /* wait for 150ms for microcode load */ |
| 5514 | msleep(150); |
| 5515 | |
| 5516 | /* Disable serial boot control, tristates pins SS_N, SCK, MOSI, MISO */ |
| 5517 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5518 | MDIO_PMA_DEVAD, |
| 5519 | MDIO_PMA_REG_MISC_CTRL1, 0x0000); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5520 | |
| 5521 | msleep(200); |
| 5522 | bnx2x_save_bcm_spirom_ver(bp, phy, params->port); |
| 5523 | } |
| 5524 | |
| 5525 | static u8 bnx2x_8726_read_status(struct bnx2x_phy *phy, |
| 5526 | struct link_params *params, |
| 5527 | struct link_vars *vars) |
| 5528 | { |
| 5529 | struct bnx2x *bp = params->bp; |
| 5530 | u16 val1; |
| 5531 | u8 link_up = bnx2x_8706_8726_read_status(phy, params, vars); |
| 5532 | if (link_up) { |
| 5533 | bnx2x_cl45_read(bp, phy, |
| 5534 | MDIO_PMA_DEVAD, MDIO_PMA_REG_PHY_IDENTIFIER, |
| 5535 | &val1); |
| 5536 | if (val1 & (1<<15)) { |
| 5537 | DP(NETIF_MSG_LINK, "Tx is disabled\n"); |
| 5538 | link_up = 0; |
| 5539 | vars->line_speed = 0; |
| 5540 | } |
| 5541 | } |
| 5542 | return link_up; |
| 5543 | } |
| 5544 | |
| 5545 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 5546 | static int bnx2x_8726_config_init(struct bnx2x_phy *phy, |
| 5547 | struct link_params *params, |
| 5548 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5549 | { |
| 5550 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5551 | DP(NETIF_MSG_LINK, "Initializing BCM8726\n"); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5552 | |
| 5553 | 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] | 5554 | bnx2x_wait_reset_complete(bp, phy, params); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5555 | |
| 5556 | bnx2x_8726_external_rom_boot(phy, params); |
| 5557 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5558 | /* |
| 5559 | * Need to call module detected on initialization since the module |
| 5560 | * detection triggered by actual module insertion might occur before |
| 5561 | * driver is loaded, and when driver is loaded, it reset all |
| 5562 | * registers, including the transmitter |
| 5563 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5564 | bnx2x_sfp_module_detection(phy, params); |
| 5565 | |
| 5566 | if (phy->req_line_speed == SPEED_1000) { |
| 5567 | DP(NETIF_MSG_LINK, "Setting 1G force\n"); |
| 5568 | bnx2x_cl45_write(bp, phy, |
| 5569 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 0x40); |
| 5570 | bnx2x_cl45_write(bp, phy, |
| 5571 | MDIO_PMA_DEVAD, MDIO_PMA_REG_10G_CTRL2, 0xD); |
| 5572 | bnx2x_cl45_write(bp, phy, |
| 5573 | MDIO_PMA_DEVAD, MDIO_PMA_REG_LASI_CTRL, 0x5); |
| 5574 | bnx2x_cl45_write(bp, phy, |
| 5575 | MDIO_PMA_DEVAD, MDIO_PMA_REG_RX_ALARM_CTRL, |
| 5576 | 0x400); |
| 5577 | } else if ((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 5578 | (phy->speed_cap_mask & |
| 5579 | PORT_HW_CFG_SPEED_CAPABILITY_D0_1G) && |
| 5580 | ((phy->speed_cap_mask & |
| 5581 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G) != |
| 5582 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G)) { |
| 5583 | DP(NETIF_MSG_LINK, "Setting 1G clause37\n"); |
| 5584 | /* Set Flow control */ |
| 5585 | bnx2x_ext_phy_set_pause(params, phy, vars); |
| 5586 | bnx2x_cl45_write(bp, phy, |
| 5587 | MDIO_AN_DEVAD, MDIO_AN_REG_ADV, 0x20); |
| 5588 | bnx2x_cl45_write(bp, phy, |
| 5589 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_CL73, 0x040c); |
| 5590 | bnx2x_cl45_write(bp, phy, |
| 5591 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_FC_LD, 0x0020); |
| 5592 | bnx2x_cl45_write(bp, phy, |
| 5593 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_AN, 0x1000); |
| 5594 | bnx2x_cl45_write(bp, phy, |
| 5595 | MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, 0x1200); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5596 | /* |
| 5597 | * Enable RX-ALARM control to receive interrupt for 1G speed |
| 5598 | * change |
| 5599 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5600 | bnx2x_cl45_write(bp, phy, |
| 5601 | MDIO_PMA_DEVAD, MDIO_PMA_REG_LASI_CTRL, 0x4); |
| 5602 | bnx2x_cl45_write(bp, phy, |
| 5603 | MDIO_PMA_DEVAD, MDIO_PMA_REG_RX_ALARM_CTRL, |
| 5604 | 0x400); |
| 5605 | |
| 5606 | } else { /* Default 10G. Set only LASI control */ |
| 5607 | bnx2x_cl45_write(bp, phy, |
| 5608 | MDIO_PMA_DEVAD, MDIO_PMA_REG_LASI_CTRL, 1); |
| 5609 | } |
| 5610 | |
| 5611 | /* Set TX PreEmphasis if needed */ |
| 5612 | if ((params->feature_config_flags & |
| 5613 | FEATURE_CONFIG_OVERRIDE_PREEMPHASIS_ENABLED)) { |
| 5614 | DP(NETIF_MSG_LINK, "Setting TX_CTRL1 0x%x," |
| 5615 | "TX_CTRL2 0x%x\n", |
| 5616 | phy->tx_preemphasis[0], |
| 5617 | phy->tx_preemphasis[1]); |
| 5618 | bnx2x_cl45_write(bp, phy, |
| 5619 | MDIO_PMA_DEVAD, |
| 5620 | MDIO_PMA_REG_8726_TX_CTRL1, |
| 5621 | phy->tx_preemphasis[0]); |
| 5622 | |
| 5623 | bnx2x_cl45_write(bp, phy, |
| 5624 | MDIO_PMA_DEVAD, |
| 5625 | MDIO_PMA_REG_8726_TX_CTRL2, |
| 5626 | phy->tx_preemphasis[1]); |
| 5627 | } |
| 5628 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5629 | return 0; |
| 5630 | |
| 5631 | } |
| 5632 | |
| 5633 | static void bnx2x_8726_link_reset(struct bnx2x_phy *phy, |
| 5634 | struct link_params *params) |
| 5635 | { |
| 5636 | struct bnx2x *bp = params->bp; |
| 5637 | DP(NETIF_MSG_LINK, "bnx2x_8726_link_reset port %d\n", params->port); |
| 5638 | /* Set serial boot control for external load */ |
| 5639 | bnx2x_cl45_write(bp, phy, |
| 5640 | MDIO_PMA_DEVAD, |
| 5641 | MDIO_PMA_REG_GEN_CTRL, 0x0001); |
| 5642 | } |
| 5643 | |
| 5644 | /******************************************************************/ |
| 5645 | /* BCM8727 PHY SECTION */ |
| 5646 | /******************************************************************/ |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 5647 | |
| 5648 | static void bnx2x_8727_set_link_led(struct bnx2x_phy *phy, |
| 5649 | struct link_params *params, u8 mode) |
| 5650 | { |
| 5651 | struct bnx2x *bp = params->bp; |
| 5652 | u16 led_mode_bitmask = 0; |
| 5653 | u16 gpio_pins_bitmask = 0; |
| 5654 | u16 val; |
| 5655 | /* Only NOC flavor requires to set the LED specifically */ |
| 5656 | if (!(phy->flags & FLAGS_NOC)) |
| 5657 | return; |
| 5658 | switch (mode) { |
| 5659 | case LED_MODE_FRONT_PANEL_OFF: |
| 5660 | case LED_MODE_OFF: |
| 5661 | led_mode_bitmask = 0; |
| 5662 | gpio_pins_bitmask = 0x03; |
| 5663 | break; |
| 5664 | case LED_MODE_ON: |
| 5665 | led_mode_bitmask = 0; |
| 5666 | gpio_pins_bitmask = 0x02; |
| 5667 | break; |
| 5668 | case LED_MODE_OPER: |
| 5669 | led_mode_bitmask = 0x60; |
| 5670 | gpio_pins_bitmask = 0x11; |
| 5671 | break; |
| 5672 | } |
| 5673 | bnx2x_cl45_read(bp, phy, |
| 5674 | MDIO_PMA_DEVAD, |
| 5675 | MDIO_PMA_REG_8727_PCS_OPT_CTRL, |
| 5676 | &val); |
| 5677 | val &= 0xff8f; |
| 5678 | val |= led_mode_bitmask; |
| 5679 | bnx2x_cl45_write(bp, phy, |
| 5680 | MDIO_PMA_DEVAD, |
| 5681 | MDIO_PMA_REG_8727_PCS_OPT_CTRL, |
| 5682 | val); |
| 5683 | bnx2x_cl45_read(bp, phy, |
| 5684 | MDIO_PMA_DEVAD, |
| 5685 | MDIO_PMA_REG_8727_GPIO_CTRL, |
| 5686 | &val); |
| 5687 | val &= 0xffe0; |
| 5688 | val |= gpio_pins_bitmask; |
| 5689 | bnx2x_cl45_write(bp, phy, |
| 5690 | MDIO_PMA_DEVAD, |
| 5691 | MDIO_PMA_REG_8727_GPIO_CTRL, |
| 5692 | val); |
| 5693 | } |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 5694 | static void bnx2x_8727_hw_reset(struct bnx2x_phy *phy, |
| 5695 | struct link_params *params) { |
| 5696 | u32 swap_val, swap_override; |
| 5697 | u8 port; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5698 | /* |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 5699 | * The PHY reset is controlled by GPIO 1. Fake the port number |
| 5700 | * to cancel the swap done in set_gpio() |
| 5701 | */ |
| 5702 | struct bnx2x *bp = params->bp; |
| 5703 | swap_val = REG_RD(bp, NIG_REG_PORT_SWAP); |
| 5704 | swap_override = REG_RD(bp, NIG_REG_STRAP_OVERRIDE); |
| 5705 | port = (swap_val && swap_override) ^ 1; |
| 5706 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5707 | MISC_REGISTERS_GPIO_OUTPUT_LOW, port); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 5708 | } |
| 5709 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 5710 | static int bnx2x_8727_config_init(struct bnx2x_phy *phy, |
| 5711 | struct link_params *params, |
| 5712 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5713 | { |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 5714 | u32 tx_en_mode; |
| 5715 | u16 tmp1, val, mod_abs, tmp2; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5716 | u16 rx_alarm_ctrl_val; |
| 5717 | u16 lasi_ctrl_val; |
| 5718 | struct bnx2x *bp = params->bp; |
| 5719 | /* Enable PMD link, MOD_ABS_FLT, and 1G link alarm */ |
| 5720 | |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 5721 | bnx2x_wait_reset_complete(bp, phy, params); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5722 | rx_alarm_ctrl_val = (1<<2) | (1<<5) ; |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 5723 | /* Should be 0x6 to enable XS on Tx side. */ |
| 5724 | lasi_ctrl_val = 0x0006; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5725 | |
| 5726 | DP(NETIF_MSG_LINK, "Initializing BCM8727\n"); |
| 5727 | /* enable LASI */ |
| 5728 | bnx2x_cl45_write(bp, phy, |
| 5729 | MDIO_PMA_DEVAD, MDIO_PMA_REG_RX_ALARM_CTRL, |
| 5730 | rx_alarm_ctrl_val); |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 5731 | bnx2x_cl45_write(bp, phy, |
| 5732 | MDIO_PMA_DEVAD, MDIO_PMA_REG_TX_ALARM_CTRL, |
| 5733 | 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5734 | bnx2x_cl45_write(bp, phy, |
| 5735 | MDIO_PMA_DEVAD, MDIO_PMA_REG_LASI_CTRL, lasi_ctrl_val); |
| 5736 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5737 | /* |
| 5738 | * Initially configure MOD_ABS to interrupt when module is |
| 5739 | * presence( bit 8) |
| 5740 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5741 | bnx2x_cl45_read(bp, phy, |
| 5742 | MDIO_PMA_DEVAD, MDIO_PMA_REG_PHY_IDENTIFIER, &mod_abs); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5743 | /* |
| 5744 | * Set EDC off by setting OPTXLOS signal input to low (bit 9). |
| 5745 | * When the EDC is off it locks onto a reference clock and avoids |
| 5746 | * becoming 'lost' |
| 5747 | */ |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 5748 | mod_abs &= ~(1<<8); |
| 5749 | if (!(phy->flags & FLAGS_NOC)) |
| 5750 | mod_abs &= ~(1<<9); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5751 | bnx2x_cl45_write(bp, phy, |
| 5752 | MDIO_PMA_DEVAD, MDIO_PMA_REG_PHY_IDENTIFIER, mod_abs); |
| 5753 | |
| 5754 | |
| 5755 | /* Make MOD_ABS give interrupt on change */ |
| 5756 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_PCS_OPT_CTRL, |
| 5757 | &val); |
| 5758 | val |= (1<<12); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 5759 | if (phy->flags & FLAGS_NOC) |
| 5760 | val |= (3<<5); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5761 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5762 | /* |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 5763 | * Set 8727 GPIOs to input to allow reading from the 8727 GPIO0 |
| 5764 | * status which reflect SFP+ module over-current |
| 5765 | */ |
| 5766 | if (!(phy->flags & FLAGS_NOC)) |
| 5767 | val &= 0xff8f; /* Reset bits 4-6 */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5768 | bnx2x_cl45_write(bp, phy, |
| 5769 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_PCS_OPT_CTRL, val); |
| 5770 | |
| 5771 | bnx2x_8727_power_module(bp, phy, 1); |
| 5772 | |
| 5773 | bnx2x_cl45_read(bp, phy, |
| 5774 | MDIO_PMA_DEVAD, MDIO_PMA_REG_M8051_MSGOUT_REG, &tmp1); |
| 5775 | |
| 5776 | bnx2x_cl45_read(bp, phy, |
| 5777 | MDIO_PMA_DEVAD, MDIO_PMA_REG_RX_ALARM, &tmp1); |
| 5778 | |
| 5779 | /* Set option 1G speed */ |
| 5780 | if (phy->req_line_speed == SPEED_1000) { |
| 5781 | DP(NETIF_MSG_LINK, "Setting 1G force\n"); |
| 5782 | bnx2x_cl45_write(bp, phy, |
| 5783 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 0x40); |
| 5784 | bnx2x_cl45_write(bp, phy, |
| 5785 | MDIO_PMA_DEVAD, MDIO_PMA_REG_10G_CTRL2, 0xD); |
| 5786 | bnx2x_cl45_read(bp, phy, |
| 5787 | MDIO_PMA_DEVAD, MDIO_PMA_REG_10G_CTRL2, &tmp1); |
| 5788 | DP(NETIF_MSG_LINK, "1.7 = 0x%x\n", tmp1); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5789 | /* |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5790 | * Power down the XAUI until link is up in case of dual-media |
| 5791 | * and 1G |
| 5792 | */ |
| 5793 | if (DUAL_MEDIA(params)) { |
| 5794 | bnx2x_cl45_read(bp, phy, |
| 5795 | MDIO_PMA_DEVAD, |
| 5796 | MDIO_PMA_REG_8727_PCS_GP, &val); |
| 5797 | val |= (3<<10); |
| 5798 | bnx2x_cl45_write(bp, phy, |
| 5799 | MDIO_PMA_DEVAD, |
| 5800 | MDIO_PMA_REG_8727_PCS_GP, val); |
| 5801 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5802 | } else if ((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 5803 | ((phy->speed_cap_mask & |
| 5804 | PORT_HW_CFG_SPEED_CAPABILITY_D0_1G)) && |
| 5805 | ((phy->speed_cap_mask & |
| 5806 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G) != |
| 5807 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G)) { |
| 5808 | |
| 5809 | DP(NETIF_MSG_LINK, "Setting 1G clause37\n"); |
| 5810 | bnx2x_cl45_write(bp, phy, |
| 5811 | MDIO_AN_DEVAD, MDIO_AN_REG_8727_MISC_CTRL, 0); |
| 5812 | bnx2x_cl45_write(bp, phy, |
| 5813 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_AN, 0x1300); |
| 5814 | } else { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5815 | /* |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5816 | * Since the 8727 has only single reset pin, need to set the 10G |
| 5817 | * registers although it is default |
| 5818 | */ |
| 5819 | bnx2x_cl45_write(bp, phy, |
| 5820 | MDIO_AN_DEVAD, MDIO_AN_REG_8727_MISC_CTRL, |
| 5821 | 0x0020); |
| 5822 | bnx2x_cl45_write(bp, phy, |
| 5823 | MDIO_AN_DEVAD, MDIO_AN_REG_CL37_AN, 0x0100); |
| 5824 | bnx2x_cl45_write(bp, phy, |
| 5825 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 0x2040); |
| 5826 | bnx2x_cl45_write(bp, phy, |
| 5827 | MDIO_PMA_DEVAD, MDIO_PMA_REG_10G_CTRL2, |
| 5828 | 0x0008); |
| 5829 | } |
| 5830 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5831 | /* |
| 5832 | * Set 2-wire transfer rate of SFP+ module EEPROM |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5833 | * to 100Khz since some DACs(direct attached cables) do |
| 5834 | * not work at 400Khz. |
| 5835 | */ |
| 5836 | bnx2x_cl45_write(bp, phy, |
| 5837 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_TWO_WIRE_SLAVE_ADDR, |
| 5838 | 0xa001); |
| 5839 | |
| 5840 | /* Set TX PreEmphasis if needed */ |
| 5841 | if ((params->feature_config_flags & |
| 5842 | FEATURE_CONFIG_OVERRIDE_PREEMPHASIS_ENABLED)) { |
| 5843 | DP(NETIF_MSG_LINK, "Setting TX_CTRL1 0x%x, TX_CTRL2 0x%x\n", |
| 5844 | phy->tx_preemphasis[0], |
| 5845 | phy->tx_preemphasis[1]); |
| 5846 | bnx2x_cl45_write(bp, phy, |
| 5847 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_TX_CTRL1, |
| 5848 | phy->tx_preemphasis[0]); |
| 5849 | |
| 5850 | bnx2x_cl45_write(bp, phy, |
| 5851 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_TX_CTRL2, |
| 5852 | phy->tx_preemphasis[1]); |
| 5853 | } |
| 5854 | |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 5855 | /* |
| 5856 | * If TX Laser is controlled by GPIO_0, do not let PHY go into low |
| 5857 | * power mode, if TX Laser is disabled |
| 5858 | */ |
| 5859 | tx_en_mode = REG_RD(bp, params->shmem_base + |
| 5860 | offsetof(struct shmem_region, |
| 5861 | dev_info.port_hw_config[params->port].sfp_ctrl)) |
| 5862 | & PORT_HW_CFG_TX_LASER_MASK; |
| 5863 | |
| 5864 | if (tx_en_mode == PORT_HW_CFG_TX_LASER_GPIO0) { |
| 5865 | |
| 5866 | DP(NETIF_MSG_LINK, "Enabling TXONOFF_PWRDN_DIS\n"); |
| 5867 | bnx2x_cl45_read(bp, phy, |
| 5868 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_OPT_CFG_REG, &tmp2); |
| 5869 | tmp2 |= 0x1000; |
| 5870 | tmp2 &= 0xFFEF; |
| 5871 | bnx2x_cl45_write(bp, phy, |
| 5872 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_OPT_CFG_REG, tmp2); |
| 5873 | } |
| 5874 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5875 | return 0; |
| 5876 | } |
| 5877 | |
| 5878 | static void bnx2x_8727_handle_mod_abs(struct bnx2x_phy *phy, |
| 5879 | struct link_params *params) |
| 5880 | { |
| 5881 | struct bnx2x *bp = params->bp; |
| 5882 | u16 mod_abs, rx_alarm_status; |
| 5883 | u32 val = REG_RD(bp, params->shmem_base + |
| 5884 | offsetof(struct shmem_region, dev_info. |
| 5885 | port_feature_config[params->port]. |
| 5886 | config)); |
| 5887 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5888 | MDIO_PMA_DEVAD, |
| 5889 | MDIO_PMA_REG_PHY_IDENTIFIER, &mod_abs); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5890 | if (mod_abs & (1<<8)) { |
| 5891 | |
| 5892 | /* Module is absent */ |
| 5893 | DP(NETIF_MSG_LINK, "MOD_ABS indication " |
| 5894 | "show module is absent\n"); |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 5895 | phy->media_type = ETH_PHY_NOT_PRESENT; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5896 | /* |
| 5897 | * 1. Set mod_abs to detect next module |
| 5898 | * presence event |
| 5899 | * 2. Set EDC off by setting OPTXLOS signal input to low |
| 5900 | * (bit 9). |
| 5901 | * When the EDC is off it locks onto a reference clock and |
| 5902 | * avoids becoming 'lost'. |
| 5903 | */ |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 5904 | mod_abs &= ~(1<<8); |
| 5905 | if (!(phy->flags & FLAGS_NOC)) |
| 5906 | mod_abs &= ~(1<<9); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5907 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5908 | MDIO_PMA_DEVAD, |
| 5909 | MDIO_PMA_REG_PHY_IDENTIFIER, mod_abs); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5910 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5911 | /* |
| 5912 | * Clear RX alarm since it stays up as long as |
| 5913 | * the mod_abs wasn't changed |
| 5914 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5915 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 5916 | MDIO_PMA_DEVAD, |
| 5917 | MDIO_PMA_REG_RX_ALARM, &rx_alarm_status); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5918 | |
| 5919 | } else { |
| 5920 | /* Module is present */ |
| 5921 | DP(NETIF_MSG_LINK, "MOD_ABS indication " |
| 5922 | "show module is present\n"); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5923 | /* |
| 5924 | * First disable transmitter, and if the module is ok, the |
| 5925 | * module_detection will enable it |
| 5926 | * 1. Set mod_abs to detect next module absent event ( bit 8) |
| 5927 | * 2. Restore the default polarity of the OPRXLOS signal and |
| 5928 | * this signal will then correctly indicate the presence or |
| 5929 | * absence of the Rx signal. (bit 9) |
| 5930 | */ |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 5931 | mod_abs |= (1<<8); |
| 5932 | if (!(phy->flags & FLAGS_NOC)) |
| 5933 | mod_abs |= (1<<9); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5934 | bnx2x_cl45_write(bp, phy, |
| 5935 | MDIO_PMA_DEVAD, |
| 5936 | MDIO_PMA_REG_PHY_IDENTIFIER, mod_abs); |
| 5937 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5938 | /* |
| 5939 | * Clear RX alarm since it stays up as long as the mod_abs |
| 5940 | * wasn't changed. This is need to be done before calling the |
| 5941 | * module detection, otherwise it will clear* the link update |
| 5942 | * alarm |
| 5943 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5944 | bnx2x_cl45_read(bp, phy, |
| 5945 | MDIO_PMA_DEVAD, |
| 5946 | MDIO_PMA_REG_RX_ALARM, &rx_alarm_status); |
| 5947 | |
| 5948 | |
| 5949 | if ((val & PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_MASK) == |
| 5950 | PORT_FEAT_CFG_OPT_MDL_ENFRCMNT_DISABLE_TX_LASER) |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 5951 | bnx2x_sfp_set_transmitter(params, phy, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5952 | |
| 5953 | if (bnx2x_wait_for_sfp_module_initialized(phy, params) == 0) |
| 5954 | bnx2x_sfp_module_detection(phy, params); |
| 5955 | else |
| 5956 | DP(NETIF_MSG_LINK, "SFP+ module is not initialized\n"); |
| 5957 | } |
| 5958 | |
| 5959 | DP(NETIF_MSG_LINK, "8727 RX_ALARM_STATUS 0x%x\n", |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 5960 | rx_alarm_status); |
| 5961 | /* 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] | 5962 | } |
| 5963 | |
| 5964 | static u8 bnx2x_8727_read_status(struct bnx2x_phy *phy, |
| 5965 | struct link_params *params, |
| 5966 | struct link_vars *vars) |
| 5967 | |
| 5968 | { |
| 5969 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 27d0243 | 2011-05-31 21:27:48 +0000 | [diff] [blame] | 5970 | u8 link_up = 0, oc_port = params->port; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5971 | u16 link_status = 0; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 5972 | u16 rx_alarm_status, lasi_ctrl, val1; |
| 5973 | |
| 5974 | /* If PHY is not initialized, do not check link status */ |
| 5975 | bnx2x_cl45_read(bp, phy, |
| 5976 | MDIO_PMA_DEVAD, MDIO_PMA_REG_LASI_CTRL, |
| 5977 | &lasi_ctrl); |
| 5978 | if (!lasi_ctrl) |
| 5979 | return 0; |
| 5980 | |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 5981 | /* Check the LASI on Rx */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5982 | bnx2x_cl45_read(bp, phy, |
| 5983 | MDIO_PMA_DEVAD, MDIO_PMA_REG_RX_ALARM, |
| 5984 | &rx_alarm_status); |
| 5985 | vars->line_speed = 0; |
| 5986 | DP(NETIF_MSG_LINK, "8727 RX_ALARM_STATUS 0x%x\n", rx_alarm_status); |
| 5987 | |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 5988 | bnx2x_sfp_mask_fault(bp, phy, MDIO_PMA_REG_TX_ALARM, |
| 5989 | MDIO_PMA_REG_TX_ALARM_CTRL); |
| 5990 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 5991 | bnx2x_cl45_read(bp, phy, |
| 5992 | MDIO_PMA_DEVAD, MDIO_PMA_REG_LASI_STATUS, &val1); |
| 5993 | |
| 5994 | DP(NETIF_MSG_LINK, "8727 LASI status 0x%x\n", val1); |
| 5995 | |
| 5996 | /* Clear MSG-OUT */ |
| 5997 | bnx2x_cl45_read(bp, phy, |
| 5998 | MDIO_PMA_DEVAD, MDIO_PMA_REG_M8051_MSGOUT_REG, &val1); |
| 5999 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6000 | /* |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6001 | * If a module is present and there is need to check |
| 6002 | * for over current |
| 6003 | */ |
| 6004 | if (!(phy->flags & FLAGS_NOC) && !(rx_alarm_status & (1<<5))) { |
| 6005 | /* Check over-current using 8727 GPIO0 input*/ |
| 6006 | bnx2x_cl45_read(bp, phy, |
| 6007 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_GPIO_CTRL, |
| 6008 | &val1); |
| 6009 | |
| 6010 | if ((val1 & (1<<8)) == 0) { |
Yaniv Rosner | 27d0243 | 2011-05-31 21:27:48 +0000 | [diff] [blame] | 6011 | if (!CHIP_IS_E1x(bp)) |
| 6012 | oc_port = BP_PATH(bp) + (params->port << 1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6013 | DP(NETIF_MSG_LINK, "8727 Power fault has been detected" |
Yaniv Rosner | 27d0243 | 2011-05-31 21:27:48 +0000 | [diff] [blame] | 6014 | " on port %d\n", oc_port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6015 | netdev_err(bp->dev, "Error: Power fault on Port %d has" |
| 6016 | " been detected and the power to " |
| 6017 | "that SFP+ module has been removed" |
| 6018 | " to prevent failure of the card." |
| 6019 | " Please remove the SFP+ module and" |
| 6020 | " restart the system to clear this" |
| 6021 | " error.\n", |
Yaniv Rosner | 27d0243 | 2011-05-31 21:27:48 +0000 | [diff] [blame] | 6022 | oc_port); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6023 | /* Disable all RX_ALARMs except for mod_abs */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6024 | bnx2x_cl45_write(bp, phy, |
| 6025 | MDIO_PMA_DEVAD, |
| 6026 | MDIO_PMA_REG_RX_ALARM_CTRL, (1<<5)); |
| 6027 | |
| 6028 | bnx2x_cl45_read(bp, phy, |
| 6029 | MDIO_PMA_DEVAD, |
| 6030 | MDIO_PMA_REG_PHY_IDENTIFIER, &val1); |
| 6031 | /* Wait for module_absent_event */ |
| 6032 | val1 |= (1<<8); |
| 6033 | bnx2x_cl45_write(bp, phy, |
| 6034 | MDIO_PMA_DEVAD, |
| 6035 | MDIO_PMA_REG_PHY_IDENTIFIER, val1); |
| 6036 | /* Clear RX alarm */ |
| 6037 | bnx2x_cl45_read(bp, phy, |
| 6038 | MDIO_PMA_DEVAD, |
| 6039 | MDIO_PMA_REG_RX_ALARM, &rx_alarm_status); |
| 6040 | return 0; |
| 6041 | } |
| 6042 | } /* Over current check */ |
| 6043 | |
| 6044 | /* When module absent bit is set, check module */ |
| 6045 | if (rx_alarm_status & (1<<5)) { |
| 6046 | bnx2x_8727_handle_mod_abs(phy, params); |
| 6047 | /* Enable all mod_abs and link detection bits */ |
| 6048 | bnx2x_cl45_write(bp, phy, |
| 6049 | MDIO_PMA_DEVAD, MDIO_PMA_REG_RX_ALARM_CTRL, |
| 6050 | ((1<<5) | (1<<2))); |
| 6051 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6052 | DP(NETIF_MSG_LINK, "Enabling 8727 TX laser if SFP is approved\n"); |
| 6053 | bnx2x_8727_specific_func(phy, params, ENABLE_TX); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6054 | /* If transmitter is disabled, ignore false link up indication */ |
| 6055 | bnx2x_cl45_read(bp, phy, |
| 6056 | MDIO_PMA_DEVAD, MDIO_PMA_REG_PHY_IDENTIFIER, &val1); |
| 6057 | if (val1 & (1<<15)) { |
| 6058 | DP(NETIF_MSG_LINK, "Tx is disabled\n"); |
| 6059 | return 0; |
| 6060 | } |
| 6061 | |
| 6062 | bnx2x_cl45_read(bp, phy, |
| 6063 | MDIO_PMA_DEVAD, |
| 6064 | MDIO_PMA_REG_8073_SPEED_LINK_STATUS, &link_status); |
| 6065 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6066 | /* |
| 6067 | * Bits 0..2 --> speed detected, |
| 6068 | * Bits 13..15--> link is down |
| 6069 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6070 | if ((link_status & (1<<2)) && (!(link_status & (1<<15)))) { |
| 6071 | link_up = 1; |
| 6072 | vars->line_speed = SPEED_10000; |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6073 | DP(NETIF_MSG_LINK, "port %x: External link up in 10G\n", |
| 6074 | params->port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6075 | } else if ((link_status & (1<<0)) && (!(link_status & (1<<13)))) { |
| 6076 | link_up = 1; |
| 6077 | vars->line_speed = SPEED_1000; |
| 6078 | DP(NETIF_MSG_LINK, "port %x: External link up in 1G\n", |
| 6079 | params->port); |
| 6080 | } else { |
| 6081 | link_up = 0; |
| 6082 | DP(NETIF_MSG_LINK, "port %x: External link is down\n", |
| 6083 | params->port); |
| 6084 | } |
Yaniv Rosner | c688fe2 | 2011-05-31 21:27:06 +0000 | [diff] [blame] | 6085 | |
| 6086 | /* Capture 10G link fault. */ |
| 6087 | if (vars->line_speed == SPEED_10000) { |
| 6088 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, |
| 6089 | MDIO_PMA_REG_TX_ALARM, &val1); |
| 6090 | |
| 6091 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, |
| 6092 | MDIO_PMA_REG_TX_ALARM, &val1); |
| 6093 | |
| 6094 | if (val1 & (1<<0)) { |
| 6095 | vars->fault_detected = 1; |
| 6096 | } |
| 6097 | } |
| 6098 | |
Yaniv Rosner | 791f18c | 2011-01-18 04:33:42 +0000 | [diff] [blame] | 6099 | if (link_up) { |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6100 | bnx2x_ext_phy_resolve_fc(phy, params, vars); |
Yaniv Rosner | 791f18c | 2011-01-18 04:33:42 +0000 | [diff] [blame] | 6101 | vars->duplex = DUPLEX_FULL; |
| 6102 | DP(NETIF_MSG_LINK, "duplex = 0x%x\n", vars->duplex); |
| 6103 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6104 | |
| 6105 | if ((DUAL_MEDIA(params)) && |
| 6106 | (phy->req_line_speed == SPEED_1000)) { |
| 6107 | bnx2x_cl45_read(bp, phy, |
| 6108 | MDIO_PMA_DEVAD, |
| 6109 | MDIO_PMA_REG_8727_PCS_GP, &val1); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6110 | /* |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6111 | * In case of dual-media board and 1G, power up the XAUI side, |
| 6112 | * otherwise power it down. For 10G it is done automatically |
| 6113 | */ |
| 6114 | if (link_up) |
| 6115 | val1 &= ~(3<<10); |
| 6116 | else |
| 6117 | val1 |= (3<<10); |
| 6118 | bnx2x_cl45_write(bp, phy, |
| 6119 | MDIO_PMA_DEVAD, |
| 6120 | MDIO_PMA_REG_8727_PCS_GP, val1); |
| 6121 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6122 | return link_up; |
| 6123 | } |
| 6124 | |
| 6125 | static void bnx2x_8727_link_reset(struct bnx2x_phy *phy, |
| 6126 | struct link_params *params) |
| 6127 | { |
| 6128 | struct bnx2x *bp = params->bp; |
| 6129 | /* Disable Transmitter */ |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 6130 | bnx2x_sfp_set_transmitter(params, phy, 0); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6131 | /* Clear LASI */ |
| 6132 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, MDIO_PMA_REG_LASI_CTRL, 0); |
| 6133 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6134 | } |
| 6135 | |
| 6136 | /******************************************************************/ |
| 6137 | /* BCM8481/BCM84823/BCM84833 PHY SECTION */ |
| 6138 | /******************************************************************/ |
| 6139 | static void bnx2x_save_848xx_spirom_version(struct bnx2x_phy *phy, |
| 6140 | struct link_params *params) |
| 6141 | { |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 6142 | u16 val, fw_ver1, fw_ver2, cnt; |
| 6143 | u8 port; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6144 | struct bnx2x *bp = params->bp; |
| 6145 | |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 6146 | port = params->port; |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 6147 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6148 | /* For the 32 bits registers in 848xx, access via MDIO2ARM interface.*/ |
| 6149 | /* (1) set register 0xc200_0014(SPI_BRIDGE_CTRL_2) to 0x03000000 */ |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 6150 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA819, 0x0014); |
| 6151 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA81A, 0xc200); |
| 6152 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA81B, 0x0000); |
| 6153 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA81C, 0x0300); |
| 6154 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA817, 0x0009); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6155 | |
| 6156 | for (cnt = 0; cnt < 100; cnt++) { |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 6157 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, 0xA818, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6158 | if (val & 1) |
| 6159 | break; |
| 6160 | udelay(5); |
| 6161 | } |
| 6162 | if (cnt == 100) { |
| 6163 | DP(NETIF_MSG_LINK, "Unable to read 848xx phy fw version(1)\n"); |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 6164 | bnx2x_save_spirom_version(bp, port, 0, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6165 | phy->ver_addr); |
| 6166 | return; |
| 6167 | } |
| 6168 | |
| 6169 | |
| 6170 | /* 2) read register 0xc200_0000 (SPI_FW_STATUS) */ |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 6171 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA819, 0x0000); |
| 6172 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA81A, 0xc200); |
| 6173 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 0xA817, 0x000A); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6174 | for (cnt = 0; cnt < 100; cnt++) { |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 6175 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, 0xA818, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6176 | if (val & 1) |
| 6177 | break; |
| 6178 | udelay(5); |
| 6179 | } |
| 6180 | if (cnt == 100) { |
| 6181 | DP(NETIF_MSG_LINK, "Unable to read 848xx phy fw version(2)\n"); |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 6182 | bnx2x_save_spirom_version(bp, port, 0, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6183 | phy->ver_addr); |
| 6184 | return; |
| 6185 | } |
| 6186 | |
| 6187 | /* lower 16 bits of the register SPI_FW_STATUS */ |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 6188 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, 0xA81B, &fw_ver1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6189 | /* upper 16 bits of register SPI_FW_STATUS */ |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 6190 | bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, 0xA81C, &fw_ver2); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6191 | |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 6192 | bnx2x_save_spirom_version(bp, port, (fw_ver2<<16) | fw_ver1, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6193 | phy->ver_addr); |
| 6194 | } |
| 6195 | |
| 6196 | static void bnx2x_848xx_set_led(struct bnx2x *bp, |
| 6197 | struct bnx2x_phy *phy) |
| 6198 | { |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 6199 | u16 val; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6200 | |
| 6201 | /* PHYC_CTL_LED_CTL */ |
| 6202 | bnx2x_cl45_read(bp, phy, |
| 6203 | MDIO_PMA_DEVAD, |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 6204 | MDIO_PMA_REG_8481_LINK_SIGNAL, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6205 | val &= 0xFE00; |
| 6206 | val |= 0x0092; |
| 6207 | |
| 6208 | bnx2x_cl45_write(bp, phy, |
| 6209 | MDIO_PMA_DEVAD, |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 6210 | MDIO_PMA_REG_8481_LINK_SIGNAL, val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6211 | |
| 6212 | bnx2x_cl45_write(bp, phy, |
| 6213 | MDIO_PMA_DEVAD, |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 6214 | MDIO_PMA_REG_8481_LED1_MASK, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6215 | 0x80); |
| 6216 | |
| 6217 | bnx2x_cl45_write(bp, phy, |
| 6218 | MDIO_PMA_DEVAD, |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 6219 | MDIO_PMA_REG_8481_LED2_MASK, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6220 | 0x18); |
| 6221 | |
Yaniv Rosner | f25b3c8 | 2011-01-18 04:33:47 +0000 | [diff] [blame] | 6222 | /* Select activity source by Tx and Rx, as suggested by PHY AE */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6223 | bnx2x_cl45_write(bp, phy, |
| 6224 | MDIO_PMA_DEVAD, |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 6225 | MDIO_PMA_REG_8481_LED3_MASK, |
Yaniv Rosner | f25b3c8 | 2011-01-18 04:33:47 +0000 | [diff] [blame] | 6226 | 0x0006); |
| 6227 | |
| 6228 | /* Select the closest activity blink rate to that in 10/100/1000 */ |
| 6229 | bnx2x_cl45_write(bp, phy, |
| 6230 | MDIO_PMA_DEVAD, |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 6231 | MDIO_PMA_REG_8481_LED3_BLINK, |
Yaniv Rosner | f25b3c8 | 2011-01-18 04:33:47 +0000 | [diff] [blame] | 6232 | 0); |
| 6233 | |
| 6234 | bnx2x_cl45_read(bp, phy, |
| 6235 | MDIO_PMA_DEVAD, |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 6236 | MDIO_PMA_REG_84823_CTL_LED_CTL_1, &val); |
Yaniv Rosner | f25b3c8 | 2011-01-18 04:33:47 +0000 | [diff] [blame] | 6237 | val |= MDIO_PMA_REG_84823_LED3_STRETCH_EN; /* stretch_en for LED3*/ |
| 6238 | |
| 6239 | bnx2x_cl45_write(bp, phy, |
| 6240 | MDIO_PMA_DEVAD, |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 6241 | MDIO_PMA_REG_84823_CTL_LED_CTL_1, val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6242 | |
| 6243 | /* 'Interrupt Mask' */ |
| 6244 | bnx2x_cl45_write(bp, phy, |
| 6245 | MDIO_AN_DEVAD, |
| 6246 | 0xFFFB, 0xFFFD); |
| 6247 | } |
| 6248 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6249 | static int bnx2x_848xx_cmn_config_init(struct bnx2x_phy *phy, |
| 6250 | struct link_params *params, |
| 6251 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6252 | { |
| 6253 | struct bnx2x *bp = params->bp; |
| 6254 | u16 autoneg_val, an_1000_val, an_10_100_val; |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 6255 | u16 tmp_req_line_speed; |
| 6256 | |
| 6257 | tmp_req_line_speed = phy->req_line_speed; |
| 6258 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833) |
| 6259 | if (phy->req_line_speed == SPEED_10000) |
| 6260 | phy->req_line_speed = SPEED_AUTO_NEG; |
| 6261 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6262 | /* |
| 6263 | * This phy uses the NIG latch mechanism since link indication |
| 6264 | * arrives through its LED4 and not via its LASI signal, so we |
| 6265 | * get steady signal instead of clear on read |
| 6266 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6267 | bnx2x_bits_en(bp, NIG_REG_LATCH_BC_0 + params->port*4, |
| 6268 | 1 << NIG_LATCH_BC_ENABLE_MI_INT); |
| 6269 | |
| 6270 | bnx2x_cl45_write(bp, phy, |
| 6271 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 0x0000); |
| 6272 | |
| 6273 | bnx2x_848xx_set_led(bp, phy); |
| 6274 | |
| 6275 | /* set 1000 speed advertisement */ |
| 6276 | bnx2x_cl45_read(bp, phy, |
| 6277 | MDIO_AN_DEVAD, MDIO_AN_REG_8481_1000T_CTRL, |
| 6278 | &an_1000_val); |
| 6279 | |
| 6280 | bnx2x_ext_phy_set_pause(params, phy, vars); |
| 6281 | bnx2x_cl45_read(bp, phy, |
| 6282 | MDIO_AN_DEVAD, |
| 6283 | MDIO_AN_REG_8481_LEGACY_AN_ADV, |
| 6284 | &an_10_100_val); |
| 6285 | bnx2x_cl45_read(bp, phy, |
| 6286 | MDIO_AN_DEVAD, MDIO_AN_REG_8481_LEGACY_MII_CTRL, |
| 6287 | &autoneg_val); |
| 6288 | /* Disable forced speed */ |
| 6289 | autoneg_val &= ~((1<<6) | (1<<8) | (1<<9) | (1<<12) | (1<<13)); |
| 6290 | an_10_100_val &= ~((1<<5) | (1<<6) | (1<<7) | (1<<8)); |
| 6291 | |
| 6292 | if (((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 6293 | (phy->speed_cap_mask & |
| 6294 | PORT_HW_CFG_SPEED_CAPABILITY_D0_1G)) || |
| 6295 | (phy->req_line_speed == SPEED_1000)) { |
| 6296 | an_1000_val |= (1<<8); |
| 6297 | autoneg_val |= (1<<9 | 1<<12); |
| 6298 | if (phy->req_duplex == DUPLEX_FULL) |
| 6299 | an_1000_val |= (1<<9); |
| 6300 | DP(NETIF_MSG_LINK, "Advertising 1G\n"); |
| 6301 | } else |
| 6302 | an_1000_val &= ~((1<<8) | (1<<9)); |
| 6303 | |
| 6304 | bnx2x_cl45_write(bp, phy, |
| 6305 | MDIO_AN_DEVAD, MDIO_AN_REG_8481_1000T_CTRL, |
| 6306 | an_1000_val); |
| 6307 | |
| 6308 | /* set 10 speed advertisement */ |
| 6309 | if (((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 6310 | (phy->speed_cap_mask & |
| 6311 | (PORT_HW_CFG_SPEED_CAPABILITY_D0_100M_FULL | |
| 6312 | PORT_HW_CFG_SPEED_CAPABILITY_D0_100M_HALF)))) { |
| 6313 | an_10_100_val |= (1<<7); |
| 6314 | /* Enable autoneg and restart autoneg for legacy speeds */ |
| 6315 | autoneg_val |= (1<<9 | 1<<12); |
| 6316 | |
| 6317 | if (phy->req_duplex == DUPLEX_FULL) |
| 6318 | an_10_100_val |= (1<<8); |
| 6319 | DP(NETIF_MSG_LINK, "Advertising 100M\n"); |
| 6320 | } |
| 6321 | /* set 10 speed advertisement */ |
| 6322 | if (((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 6323 | (phy->speed_cap_mask & |
| 6324 | (PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_FULL | |
| 6325 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_HALF)))) { |
| 6326 | an_10_100_val |= (1<<5); |
| 6327 | autoneg_val |= (1<<9 | 1<<12); |
| 6328 | if (phy->req_duplex == DUPLEX_FULL) |
| 6329 | an_10_100_val |= (1<<6); |
| 6330 | DP(NETIF_MSG_LINK, "Advertising 10M\n"); |
| 6331 | } |
| 6332 | |
| 6333 | /* Only 10/100 are allowed to work in FORCE mode */ |
| 6334 | if (phy->req_line_speed == SPEED_100) { |
| 6335 | autoneg_val |= (1<<13); |
| 6336 | /* Enabled AUTO-MDIX when autoneg is disabled */ |
| 6337 | bnx2x_cl45_write(bp, phy, |
| 6338 | MDIO_AN_DEVAD, MDIO_AN_REG_8481_AUX_CTRL, |
| 6339 | (1<<15 | 1<<9 | 7<<0)); |
| 6340 | DP(NETIF_MSG_LINK, "Setting 100M force\n"); |
| 6341 | } |
| 6342 | if (phy->req_line_speed == SPEED_10) { |
| 6343 | /* Enabled AUTO-MDIX when autoneg is disabled */ |
| 6344 | bnx2x_cl45_write(bp, phy, |
| 6345 | MDIO_AN_DEVAD, MDIO_AN_REG_8481_AUX_CTRL, |
| 6346 | (1<<15 | 1<<9 | 7<<0)); |
| 6347 | DP(NETIF_MSG_LINK, "Setting 10M force\n"); |
| 6348 | } |
| 6349 | |
| 6350 | bnx2x_cl45_write(bp, phy, |
| 6351 | MDIO_AN_DEVAD, MDIO_AN_REG_8481_LEGACY_AN_ADV, |
| 6352 | an_10_100_val); |
| 6353 | |
| 6354 | if (phy->req_duplex == DUPLEX_FULL) |
| 6355 | autoneg_val |= (1<<8); |
| 6356 | |
| 6357 | bnx2x_cl45_write(bp, phy, |
| 6358 | MDIO_AN_DEVAD, |
| 6359 | MDIO_AN_REG_8481_LEGACY_MII_CTRL, autoneg_val); |
| 6360 | |
| 6361 | if (((phy->req_line_speed == SPEED_AUTO_NEG) && |
| 6362 | (phy->speed_cap_mask & |
| 6363 | PORT_HW_CFG_SPEED_CAPABILITY_D0_10G)) || |
| 6364 | (phy->req_line_speed == SPEED_10000)) { |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 6365 | DP(NETIF_MSG_LINK, "Advertising 10G\n"); |
| 6366 | /* Restart autoneg for 10G*/ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6367 | |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 6368 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6369 | MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, |
| 6370 | 0x3200); |
| 6371 | } else if (phy->req_line_speed != SPEED_10 && |
| 6372 | phy->req_line_speed != SPEED_100) { |
| 6373 | bnx2x_cl45_write(bp, phy, |
| 6374 | MDIO_AN_DEVAD, |
| 6375 | MDIO_AN_REG_8481_10GBASE_T_AN_CTRL, |
| 6376 | 1); |
| 6377 | } |
| 6378 | /* Save spirom version */ |
| 6379 | bnx2x_save_848xx_spirom_version(phy, params); |
| 6380 | |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 6381 | phy->req_line_speed = tmp_req_line_speed; |
| 6382 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6383 | return 0; |
| 6384 | } |
| 6385 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6386 | static int bnx2x_8481_config_init(struct bnx2x_phy *phy, |
| 6387 | struct link_params *params, |
| 6388 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6389 | { |
| 6390 | struct bnx2x *bp = params->bp; |
| 6391 | /* Restore normal power mode*/ |
| 6392 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6393 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, params->port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6394 | |
| 6395 | /* HW reset */ |
| 6396 | bnx2x_ext_phy_hw_reset(bp, params->port); |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 6397 | bnx2x_wait_reset_complete(bp, phy, params); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6398 | |
| 6399 | bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 1<<15); |
| 6400 | return bnx2x_848xx_cmn_config_init(phy, params, vars); |
| 6401 | } |
| 6402 | |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 6403 | |
| 6404 | #define PHY84833_HDSHK_WAIT 300 |
| 6405 | static int bnx2x_84833_pair_swap_cfg(struct bnx2x_phy *phy, |
| 6406 | struct link_params *params, |
| 6407 | struct link_vars *vars) |
| 6408 | { |
| 6409 | u32 idx; |
| 6410 | u16 val; |
| 6411 | u16 data = 0x01b1; |
| 6412 | struct bnx2x *bp = params->bp; |
| 6413 | /* Do pair swap */ |
| 6414 | |
| 6415 | |
| 6416 | /* Write CMD_OPEN_OVERRIDE to STATUS reg */ |
| 6417 | bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD, |
| 6418 | MDIO_84833_TOP_CFG_SCRATCH_REG2, |
| 6419 | PHY84833_CMD_OPEN_OVERRIDE); |
| 6420 | for (idx = 0; idx < PHY84833_HDSHK_WAIT; idx++) { |
| 6421 | bnx2x_cl45_read(bp, phy, MDIO_CTL_DEVAD, |
| 6422 | MDIO_84833_TOP_CFG_SCRATCH_REG2, &val); |
| 6423 | if (val == PHY84833_CMD_OPEN_FOR_CMDS) |
| 6424 | break; |
| 6425 | msleep(1); |
| 6426 | } |
| 6427 | if (idx >= PHY84833_HDSHK_WAIT) { |
| 6428 | DP(NETIF_MSG_LINK, "Pairswap: FW not ready.\n"); |
| 6429 | return -EINVAL; |
| 6430 | } |
| 6431 | |
| 6432 | bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD, |
| 6433 | MDIO_84833_TOP_CFG_SCRATCH_REG4, |
| 6434 | data); |
| 6435 | /* Issue pair swap command */ |
| 6436 | bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD, |
| 6437 | MDIO_84833_TOP_CFG_SCRATCH_REG0, |
| 6438 | PHY84833_DIAG_CMD_PAIR_SWAP_CHANGE); |
| 6439 | for (idx = 0; idx < PHY84833_HDSHK_WAIT; idx++) { |
| 6440 | bnx2x_cl45_read(bp, phy, MDIO_CTL_DEVAD, |
| 6441 | MDIO_84833_TOP_CFG_SCRATCH_REG2, &val); |
| 6442 | if ((val == PHY84833_CMD_COMPLETE_PASS) || |
| 6443 | (val == PHY84833_CMD_COMPLETE_ERROR)) |
| 6444 | break; |
| 6445 | msleep(1); |
| 6446 | } |
| 6447 | if ((idx >= PHY84833_HDSHK_WAIT) || |
| 6448 | (val == PHY84833_CMD_COMPLETE_ERROR)) { |
| 6449 | DP(NETIF_MSG_LINK, "Pairswap: override failed.\n"); |
| 6450 | return -EINVAL; |
| 6451 | } |
| 6452 | bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD, |
| 6453 | MDIO_84833_TOP_CFG_SCRATCH_REG2, |
| 6454 | PHY84833_CMD_CLEAR_COMPLETE); |
| 6455 | DP(NETIF_MSG_LINK, "Pairswap OK, val=0x%x\n", data); |
| 6456 | return 0; |
| 6457 | } |
| 6458 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6459 | static int bnx2x_848x3_config_init(struct bnx2x_phy *phy, |
| 6460 | struct link_params *params, |
| 6461 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6462 | { |
| 6463 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 6a71bbe | 2010-11-01 05:32:31 +0000 | [diff] [blame] | 6464 | u8 port, initialize = 1; |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 6465 | u16 val; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6466 | u16 temp; |
Yaniv Rosner | 1bef68e | 2011-01-31 04:22:46 +0000 | [diff] [blame] | 6467 | u32 actual_phy_selection, cms_enable; |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6468 | int rc = 0; |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6469 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6470 | msleep(1); |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 6471 | |
| 6472 | if (!(CHIP_IS_E1(bp))) |
Yaniv Rosner | 6a71bbe | 2010-11-01 05:32:31 +0000 | [diff] [blame] | 6473 | port = BP_PATH(bp); |
| 6474 | else |
| 6475 | port = params->port; |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 6476 | |
| 6477 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84823) { |
| 6478 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_3, |
| 6479 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, |
| 6480 | port); |
| 6481 | } else { |
| 6482 | bnx2x_cl45_write(bp, phy, |
| 6483 | MDIO_PMA_DEVAD, |
| 6484 | MDIO_PMA_REG_CTRL, 0x8000); |
| 6485 | } |
| 6486 | |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 6487 | bnx2x_wait_reset_complete(bp, phy, params); |
Yaniv Rosner | 9bffeac | 2010-11-01 05:32:27 +0000 | [diff] [blame] | 6488 | /* Wait for GPHY to come out of reset */ |
| 6489 | msleep(50); |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 6490 | |
| 6491 | /* Bring PHY out of super isolate mode */ |
| 6492 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833) { |
| 6493 | bnx2x_cl45_read(bp, phy, |
| 6494 | MDIO_CTL_DEVAD, |
| 6495 | MDIO_84833_TOP_CFG_XGPHY_STRAP1, &val); |
| 6496 | val &= ~MDIO_84833_SUPER_ISOLATE; |
| 6497 | bnx2x_cl45_write(bp, phy, |
| 6498 | MDIO_CTL_DEVAD, |
| 6499 | MDIO_84833_TOP_CFG_XGPHY_STRAP1, val); |
| 6500 | bnx2x_wait_reset_complete(bp, phy, params); |
| 6501 | } |
| 6502 | |
| 6503 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833) |
| 6504 | bnx2x_84833_pair_swap_cfg(phy, params, vars); |
| 6505 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6506 | /* |
| 6507 | * BCM84823 requires that XGXS links up first @ 10G for normal behavior |
| 6508 | */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6509 | temp = vars->line_speed; |
| 6510 | vars->line_speed = SPEED_10000; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6511 | bnx2x_set_autoneg(¶ms->phy[INT_PHY], params, vars, 0); |
| 6512 | bnx2x_program_serdes(¶ms->phy[INT_PHY], params, vars); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6513 | vars->line_speed = temp; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6514 | |
| 6515 | /* Set dual-media configuration according to configuration */ |
| 6516 | |
| 6517 | bnx2x_cl45_read(bp, phy, MDIO_CTL_DEVAD, |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 6518 | MDIO_CTL_REG_84823_MEDIA, &val); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6519 | val &= ~(MDIO_CTL_REG_84823_MEDIA_MAC_MASK | |
| 6520 | MDIO_CTL_REG_84823_MEDIA_LINE_MASK | |
| 6521 | MDIO_CTL_REG_84823_MEDIA_COPPER_CORE_DOWN | |
| 6522 | MDIO_CTL_REG_84823_MEDIA_PRIORITY_MASK | |
| 6523 | MDIO_CTL_REG_84823_MEDIA_FIBER_1G); |
| 6524 | val |= MDIO_CTL_REG_84823_CTRL_MAC_XFI | |
| 6525 | MDIO_CTL_REG_84823_MEDIA_LINE_XAUI_L; |
| 6526 | |
| 6527 | actual_phy_selection = bnx2x_phy_selection(params); |
| 6528 | |
| 6529 | switch (actual_phy_selection) { |
| 6530 | case PORT_HW_CFG_PHY_SELECTION_HARDWARE_DEFAULT: |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 6531 | /* Do nothing. Essentially this is like the priority copper */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6532 | break; |
| 6533 | case PORT_HW_CFG_PHY_SELECTION_FIRST_PHY_PRIORITY: |
| 6534 | val |= MDIO_CTL_REG_84823_MEDIA_PRIORITY_COPPER; |
| 6535 | break; |
| 6536 | case PORT_HW_CFG_PHY_SELECTION_SECOND_PHY_PRIORITY: |
| 6537 | val |= MDIO_CTL_REG_84823_MEDIA_PRIORITY_FIBER; |
| 6538 | break; |
| 6539 | case PORT_HW_CFG_PHY_SELECTION_FIRST_PHY: |
| 6540 | /* Do nothing here. The first PHY won't be initialized at all */ |
| 6541 | break; |
| 6542 | case PORT_HW_CFG_PHY_SELECTION_SECOND_PHY: |
| 6543 | val |= MDIO_CTL_REG_84823_MEDIA_COPPER_CORE_DOWN; |
| 6544 | initialize = 0; |
| 6545 | break; |
| 6546 | } |
| 6547 | if (params->phy[EXT_PHY2].req_line_speed == SPEED_1000) |
| 6548 | val |= MDIO_CTL_REG_84823_MEDIA_FIBER_1G; |
| 6549 | |
| 6550 | bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD, |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 6551 | MDIO_CTL_REG_84823_MEDIA, val); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6552 | DP(NETIF_MSG_LINK, "Multi_phy config = 0x%x, Media control = 0x%x\n", |
| 6553 | params->multi_phy_config, val); |
| 6554 | |
| 6555 | if (initialize) |
| 6556 | rc = bnx2x_848xx_cmn_config_init(phy, params, vars); |
| 6557 | else |
| 6558 | bnx2x_save_848xx_spirom_version(phy, params); |
Yaniv Rosner | 1bef68e | 2011-01-31 04:22:46 +0000 | [diff] [blame] | 6559 | cms_enable = REG_RD(bp, params->shmem_base + |
| 6560 | offsetof(struct shmem_region, |
| 6561 | dev_info.port_hw_config[params->port].default_cfg)) & |
| 6562 | PORT_HW_CFG_ENABLE_CMS_MASK; |
| 6563 | |
| 6564 | bnx2x_cl45_read(bp, phy, MDIO_CTL_DEVAD, |
| 6565 | MDIO_CTL_REG_84823_USER_CTRL_REG, &val); |
| 6566 | if (cms_enable) |
| 6567 | val |= MDIO_CTL_REG_84823_USER_CTRL_CMS; |
| 6568 | else |
| 6569 | val &= ~MDIO_CTL_REG_84823_USER_CTRL_CMS; |
| 6570 | bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD, |
| 6571 | MDIO_CTL_REG_84823_USER_CTRL_REG, val); |
| 6572 | |
| 6573 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 6574 | return rc; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6575 | } |
| 6576 | |
| 6577 | static u8 bnx2x_848xx_read_status(struct bnx2x_phy *phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6578 | struct link_params *params, |
| 6579 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6580 | { |
| 6581 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 6582 | u16 val, val1, val2; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6583 | u8 link_up = 0; |
| 6584 | |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 6585 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6586 | /* Check 10G-BaseT link status */ |
| 6587 | /* Check PMD signal ok */ |
| 6588 | bnx2x_cl45_read(bp, phy, |
| 6589 | MDIO_AN_DEVAD, 0xFFFA, &val1); |
| 6590 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 6591 | MDIO_PMA_DEVAD, MDIO_PMA_REG_8481_PMD_SIGNAL, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6592 | &val2); |
| 6593 | DP(NETIF_MSG_LINK, "BCM848xx: PMD_SIGNAL 1.a811 = 0x%x\n", val2); |
| 6594 | |
| 6595 | /* Check link 10G */ |
| 6596 | if (val2 & (1<<11)) { |
| 6597 | vars->line_speed = SPEED_10000; |
Yaniv Rosner | 791f18c | 2011-01-18 04:33:42 +0000 | [diff] [blame] | 6598 | vars->duplex = DUPLEX_FULL; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6599 | link_up = 1; |
| 6600 | bnx2x_ext_phy_10G_an_resolve(bp, phy, vars); |
| 6601 | } else { /* Check Legacy speed link */ |
| 6602 | u16 legacy_status, legacy_speed; |
| 6603 | |
| 6604 | /* Enable expansion register 0x42 (Operation mode status) */ |
| 6605 | bnx2x_cl45_write(bp, phy, |
| 6606 | MDIO_AN_DEVAD, |
| 6607 | MDIO_AN_REG_8481_EXPANSION_REG_ACCESS, 0xf42); |
| 6608 | |
| 6609 | /* Get legacy speed operation status */ |
| 6610 | bnx2x_cl45_read(bp, phy, |
| 6611 | MDIO_AN_DEVAD, |
| 6612 | MDIO_AN_REG_8481_EXPANSION_REG_RD_RW, |
| 6613 | &legacy_status); |
| 6614 | |
| 6615 | DP(NETIF_MSG_LINK, "Legacy speed status" |
| 6616 | " = 0x%x\n", legacy_status); |
| 6617 | link_up = ((legacy_status & (1<<11)) == (1<<11)); |
| 6618 | if (link_up) { |
| 6619 | legacy_speed = (legacy_status & (3<<9)); |
| 6620 | if (legacy_speed == (0<<9)) |
| 6621 | vars->line_speed = SPEED_10; |
| 6622 | else if (legacy_speed == (1<<9)) |
| 6623 | vars->line_speed = SPEED_100; |
| 6624 | else if (legacy_speed == (2<<9)) |
| 6625 | vars->line_speed = SPEED_1000; |
| 6626 | else /* Should not happen */ |
| 6627 | vars->line_speed = 0; |
| 6628 | |
| 6629 | if (legacy_status & (1<<8)) |
| 6630 | vars->duplex = DUPLEX_FULL; |
| 6631 | else |
| 6632 | vars->duplex = DUPLEX_HALF; |
| 6633 | |
| 6634 | DP(NETIF_MSG_LINK, "Link is up in %dMbps," |
| 6635 | " is_duplex_full= %d\n", vars->line_speed, |
| 6636 | (vars->duplex == DUPLEX_FULL)); |
| 6637 | /* Check legacy speed AN resolution */ |
| 6638 | bnx2x_cl45_read(bp, phy, |
| 6639 | MDIO_AN_DEVAD, |
| 6640 | MDIO_AN_REG_8481_LEGACY_MII_STATUS, |
| 6641 | &val); |
| 6642 | if (val & (1<<5)) |
| 6643 | vars->link_status |= |
| 6644 | LINK_STATUS_AUTO_NEGOTIATE_COMPLETE; |
| 6645 | bnx2x_cl45_read(bp, phy, |
| 6646 | MDIO_AN_DEVAD, |
| 6647 | MDIO_AN_REG_8481_LEGACY_AN_EXPANSION, |
| 6648 | &val); |
| 6649 | if ((val & (1<<0)) == 0) |
| 6650 | vars->link_status |= |
| 6651 | LINK_STATUS_PARALLEL_DETECTION_USED; |
| 6652 | } |
| 6653 | } |
| 6654 | if (link_up) { |
| 6655 | DP(NETIF_MSG_LINK, "BCM84823: link speed is %d\n", |
| 6656 | vars->line_speed); |
| 6657 | bnx2x_ext_phy_resolve_fc(phy, params, vars); |
| 6658 | } |
| 6659 | |
| 6660 | return link_up; |
| 6661 | } |
| 6662 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6663 | |
| 6664 | 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] | 6665 | { |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6666 | int status = 0; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6667 | u32 spirom_ver; |
| 6668 | spirom_ver = ((raw_ver & 0xF80) >> 7) << 16 | (raw_ver & 0x7F); |
| 6669 | status = bnx2x_format_ver(spirom_ver, str, len); |
| 6670 | return status; |
| 6671 | } |
| 6672 | |
| 6673 | static void bnx2x_8481_hw_reset(struct bnx2x_phy *phy, |
| 6674 | struct link_params *params) |
| 6675 | { |
| 6676 | bnx2x_set_gpio(params->bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6677 | MISC_REGISTERS_GPIO_OUTPUT_LOW, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6678 | bnx2x_set_gpio(params->bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6679 | MISC_REGISTERS_GPIO_OUTPUT_LOW, 1); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6680 | } |
| 6681 | |
| 6682 | static void bnx2x_8481_link_reset(struct bnx2x_phy *phy, |
| 6683 | struct link_params *params) |
| 6684 | { |
| 6685 | bnx2x_cl45_write(params->bp, phy, |
| 6686 | MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, 0x0000); |
| 6687 | bnx2x_cl45_write(params->bp, phy, |
| 6688 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 1); |
| 6689 | } |
| 6690 | |
| 6691 | static void bnx2x_848x3_link_reset(struct bnx2x_phy *phy, |
| 6692 | struct link_params *params) |
| 6693 | { |
| 6694 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 6a71bbe | 2010-11-01 05:32:31 +0000 | [diff] [blame] | 6695 | u8 port; |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 6696 | |
| 6697 | if (!(CHIP_IS_E1(bp))) |
Yaniv Rosner | 6a71bbe | 2010-11-01 05:32:31 +0000 | [diff] [blame] | 6698 | port = BP_PATH(bp); |
| 6699 | else |
| 6700 | port = params->port; |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 6701 | |
| 6702 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84823) { |
| 6703 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_3, |
| 6704 | MISC_REGISTERS_GPIO_OUTPUT_LOW, |
| 6705 | port); |
| 6706 | } else { |
| 6707 | bnx2x_cl45_write(bp, phy, |
| 6708 | MDIO_PMA_DEVAD, |
| 6709 | MDIO_PMA_REG_CTRL, 0x800); |
| 6710 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6711 | } |
| 6712 | |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6713 | static void bnx2x_848xx_set_link_led(struct bnx2x_phy *phy, |
| 6714 | struct link_params *params, u8 mode) |
| 6715 | { |
| 6716 | struct bnx2x *bp = params->bp; |
| 6717 | u16 val; |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 6718 | u8 port; |
| 6719 | |
| 6720 | if (!(CHIP_IS_E1(bp))) |
| 6721 | port = BP_PATH(bp); |
| 6722 | else |
| 6723 | port = params->port; |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6724 | |
| 6725 | switch (mode) { |
| 6726 | case LED_MODE_OFF: |
| 6727 | |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 6728 | DP(NETIF_MSG_LINK, "Port 0x%x: LED MODE OFF\n", port); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6729 | |
| 6730 | if ((params->hw_led_mode << SHARED_HW_CFG_LED_MODE_SHIFT) == |
| 6731 | SHARED_HW_CFG_LED_EXTPHY1) { |
| 6732 | |
| 6733 | /* Set LED masks */ |
| 6734 | bnx2x_cl45_write(bp, phy, |
| 6735 | MDIO_PMA_DEVAD, |
| 6736 | MDIO_PMA_REG_8481_LED1_MASK, |
| 6737 | 0x0); |
| 6738 | |
| 6739 | bnx2x_cl45_write(bp, phy, |
| 6740 | MDIO_PMA_DEVAD, |
| 6741 | MDIO_PMA_REG_8481_LED2_MASK, |
| 6742 | 0x0); |
| 6743 | |
| 6744 | bnx2x_cl45_write(bp, phy, |
| 6745 | MDIO_PMA_DEVAD, |
| 6746 | MDIO_PMA_REG_8481_LED3_MASK, |
| 6747 | 0x0); |
| 6748 | |
| 6749 | bnx2x_cl45_write(bp, phy, |
| 6750 | MDIO_PMA_DEVAD, |
| 6751 | MDIO_PMA_REG_8481_LED5_MASK, |
| 6752 | 0x0); |
| 6753 | |
| 6754 | } else { |
| 6755 | bnx2x_cl45_write(bp, phy, |
| 6756 | MDIO_PMA_DEVAD, |
| 6757 | MDIO_PMA_REG_8481_LED1_MASK, |
| 6758 | 0x0); |
| 6759 | } |
| 6760 | break; |
| 6761 | case LED_MODE_FRONT_PANEL_OFF: |
| 6762 | |
| 6763 | DP(NETIF_MSG_LINK, "Port 0x%x: LED MODE FRONT PANEL OFF\n", |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 6764 | port); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6765 | |
| 6766 | if ((params->hw_led_mode << SHARED_HW_CFG_LED_MODE_SHIFT) == |
| 6767 | SHARED_HW_CFG_LED_EXTPHY1) { |
| 6768 | |
| 6769 | /* Set LED masks */ |
| 6770 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6771 | MDIO_PMA_DEVAD, |
| 6772 | MDIO_PMA_REG_8481_LED1_MASK, |
| 6773 | 0x0); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6774 | |
| 6775 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6776 | MDIO_PMA_DEVAD, |
| 6777 | MDIO_PMA_REG_8481_LED2_MASK, |
| 6778 | 0x0); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6779 | |
| 6780 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6781 | MDIO_PMA_DEVAD, |
| 6782 | MDIO_PMA_REG_8481_LED3_MASK, |
| 6783 | 0x0); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6784 | |
| 6785 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6786 | MDIO_PMA_DEVAD, |
| 6787 | MDIO_PMA_REG_8481_LED5_MASK, |
| 6788 | 0x20); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6789 | |
| 6790 | } else { |
| 6791 | bnx2x_cl45_write(bp, phy, |
| 6792 | MDIO_PMA_DEVAD, |
| 6793 | MDIO_PMA_REG_8481_LED1_MASK, |
| 6794 | 0x0); |
| 6795 | } |
| 6796 | break; |
| 6797 | case LED_MODE_ON: |
| 6798 | |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 6799 | DP(NETIF_MSG_LINK, "Port 0x%x: LED MODE ON\n", port); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6800 | |
| 6801 | if ((params->hw_led_mode << SHARED_HW_CFG_LED_MODE_SHIFT) == |
| 6802 | SHARED_HW_CFG_LED_EXTPHY1) { |
| 6803 | /* Set control reg */ |
| 6804 | bnx2x_cl45_read(bp, phy, |
| 6805 | MDIO_PMA_DEVAD, |
| 6806 | MDIO_PMA_REG_8481_LINK_SIGNAL, |
| 6807 | &val); |
| 6808 | val &= 0x8000; |
| 6809 | val |= 0x2492; |
| 6810 | |
| 6811 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6812 | MDIO_PMA_DEVAD, |
| 6813 | MDIO_PMA_REG_8481_LINK_SIGNAL, |
| 6814 | val); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6815 | |
| 6816 | /* Set LED masks */ |
| 6817 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6818 | MDIO_PMA_DEVAD, |
| 6819 | MDIO_PMA_REG_8481_LED1_MASK, |
| 6820 | 0x0); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6821 | |
| 6822 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6823 | MDIO_PMA_DEVAD, |
| 6824 | MDIO_PMA_REG_8481_LED2_MASK, |
| 6825 | 0x20); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6826 | |
| 6827 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6828 | MDIO_PMA_DEVAD, |
| 6829 | MDIO_PMA_REG_8481_LED3_MASK, |
| 6830 | 0x20); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6831 | |
| 6832 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6833 | MDIO_PMA_DEVAD, |
| 6834 | MDIO_PMA_REG_8481_LED5_MASK, |
| 6835 | 0x0); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6836 | } else { |
| 6837 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6838 | MDIO_PMA_DEVAD, |
| 6839 | MDIO_PMA_REG_8481_LED1_MASK, |
| 6840 | 0x20); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6841 | } |
| 6842 | break; |
| 6843 | |
| 6844 | case LED_MODE_OPER: |
| 6845 | |
Yaniv Rosner | bac27bd | 2011-05-31 21:28:10 +0000 | [diff] [blame] | 6846 | DP(NETIF_MSG_LINK, "Port 0x%x: LED MODE OPER\n", port); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6847 | |
| 6848 | if ((params->hw_led_mode << SHARED_HW_CFG_LED_MODE_SHIFT) == |
| 6849 | SHARED_HW_CFG_LED_EXTPHY1) { |
| 6850 | |
| 6851 | /* Set control reg */ |
| 6852 | bnx2x_cl45_read(bp, phy, |
| 6853 | MDIO_PMA_DEVAD, |
| 6854 | MDIO_PMA_REG_8481_LINK_SIGNAL, |
| 6855 | &val); |
| 6856 | |
| 6857 | if (!((val & |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6858 | MDIO_PMA_REG_8481_LINK_SIGNAL_LED4_ENABLE_MASK) |
| 6859 | >> MDIO_PMA_REG_8481_LINK_SIGNAL_LED4_ENABLE_SHIFT)) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6860 | DP(NETIF_MSG_LINK, "Setting LINK_SIGNAL\n"); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6861 | bnx2x_cl45_write(bp, phy, |
| 6862 | MDIO_PMA_DEVAD, |
| 6863 | MDIO_PMA_REG_8481_LINK_SIGNAL, |
| 6864 | 0xa492); |
| 6865 | } |
| 6866 | |
| 6867 | /* Set LED masks */ |
| 6868 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6869 | MDIO_PMA_DEVAD, |
| 6870 | MDIO_PMA_REG_8481_LED1_MASK, |
| 6871 | 0x10); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6872 | |
| 6873 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6874 | MDIO_PMA_DEVAD, |
| 6875 | MDIO_PMA_REG_8481_LED2_MASK, |
| 6876 | 0x80); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6877 | |
| 6878 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6879 | MDIO_PMA_DEVAD, |
| 6880 | MDIO_PMA_REG_8481_LED3_MASK, |
| 6881 | 0x98); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6882 | |
| 6883 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6884 | MDIO_PMA_DEVAD, |
| 6885 | MDIO_PMA_REG_8481_LED5_MASK, |
| 6886 | 0x40); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6887 | |
| 6888 | } else { |
| 6889 | bnx2x_cl45_write(bp, phy, |
| 6890 | MDIO_PMA_DEVAD, |
| 6891 | MDIO_PMA_REG_8481_LED1_MASK, |
| 6892 | 0x80); |
Yaniv Rosner | 53eda06 | 2011-01-30 04:14:55 +0000 | [diff] [blame] | 6893 | |
| 6894 | /* Tell LED3 to blink on source */ |
| 6895 | bnx2x_cl45_read(bp, phy, |
| 6896 | MDIO_PMA_DEVAD, |
| 6897 | MDIO_PMA_REG_8481_LINK_SIGNAL, |
| 6898 | &val); |
| 6899 | val &= ~(7<<6); |
| 6900 | val |= (1<<6); /* A83B[8:6]= 1 */ |
| 6901 | bnx2x_cl45_write(bp, phy, |
| 6902 | MDIO_PMA_DEVAD, |
| 6903 | MDIO_PMA_REG_8481_LINK_SIGNAL, |
| 6904 | val); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 6905 | } |
| 6906 | break; |
| 6907 | } |
| 6908 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6909 | /******************************************************************/ |
| 6910 | /* SFX7101 PHY SECTION */ |
| 6911 | /******************************************************************/ |
| 6912 | static void bnx2x_7101_config_loopback(struct bnx2x_phy *phy, |
| 6913 | struct link_params *params) |
| 6914 | { |
| 6915 | struct bnx2x *bp = params->bp; |
| 6916 | /* SFX7101_XGXS_TEST1 */ |
| 6917 | bnx2x_cl45_write(bp, phy, |
| 6918 | MDIO_XS_DEVAD, MDIO_XS_SFX7101_XGXS_TEST1, 0x100); |
| 6919 | } |
| 6920 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6921 | static int bnx2x_7101_config_init(struct bnx2x_phy *phy, |
| 6922 | struct link_params *params, |
| 6923 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6924 | { |
| 6925 | u16 fw_ver1, fw_ver2, val; |
| 6926 | struct bnx2x *bp = params->bp; |
| 6927 | DP(NETIF_MSG_LINK, "Setting the SFX7101 LASI indication\n"); |
| 6928 | |
| 6929 | /* Restore normal power mode*/ |
| 6930 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 6931 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, params->port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6932 | /* HW reset */ |
| 6933 | bnx2x_ext_phy_hw_reset(bp, params->port); |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 6934 | bnx2x_wait_reset_complete(bp, phy, params); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6935 | |
| 6936 | bnx2x_cl45_write(bp, phy, |
| 6937 | MDIO_PMA_DEVAD, MDIO_PMA_REG_LASI_CTRL, 0x1); |
| 6938 | DP(NETIF_MSG_LINK, "Setting the SFX7101 LED to blink on traffic\n"); |
| 6939 | bnx2x_cl45_write(bp, phy, |
| 6940 | MDIO_PMA_DEVAD, MDIO_PMA_REG_7107_LED_CNTL, (1<<3)); |
| 6941 | |
| 6942 | bnx2x_ext_phy_set_pause(params, phy, vars); |
| 6943 | /* Restart autoneg */ |
| 6944 | bnx2x_cl45_read(bp, phy, |
| 6945 | MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, &val); |
| 6946 | val |= 0x200; |
| 6947 | bnx2x_cl45_write(bp, phy, |
| 6948 | MDIO_AN_DEVAD, MDIO_AN_REG_CTRL, val); |
| 6949 | |
| 6950 | /* Save spirom version */ |
| 6951 | bnx2x_cl45_read(bp, phy, |
| 6952 | MDIO_PMA_DEVAD, MDIO_PMA_REG_7101_VER1, &fw_ver1); |
| 6953 | |
| 6954 | bnx2x_cl45_read(bp, phy, |
| 6955 | MDIO_PMA_DEVAD, MDIO_PMA_REG_7101_VER2, &fw_ver2); |
| 6956 | bnx2x_save_spirom_version(bp, params->port, |
| 6957 | (u32)(fw_ver1<<16 | fw_ver2), phy->ver_addr); |
| 6958 | return 0; |
| 6959 | } |
| 6960 | |
| 6961 | static u8 bnx2x_7101_read_status(struct bnx2x_phy *phy, |
| 6962 | struct link_params *params, |
| 6963 | struct link_vars *vars) |
| 6964 | { |
| 6965 | struct bnx2x *bp = params->bp; |
| 6966 | u8 link_up; |
| 6967 | u16 val1, val2; |
| 6968 | bnx2x_cl45_read(bp, phy, |
| 6969 | MDIO_PMA_DEVAD, MDIO_PMA_REG_LASI_STATUS, &val2); |
| 6970 | bnx2x_cl45_read(bp, phy, |
| 6971 | MDIO_PMA_DEVAD, MDIO_PMA_REG_LASI_STATUS, &val1); |
| 6972 | DP(NETIF_MSG_LINK, "10G-base-T LASI status 0x%x->0x%x\n", |
| 6973 | val2, val1); |
| 6974 | bnx2x_cl45_read(bp, phy, |
| 6975 | MDIO_PMA_DEVAD, MDIO_PMA_REG_STATUS, &val2); |
| 6976 | bnx2x_cl45_read(bp, phy, |
| 6977 | MDIO_PMA_DEVAD, MDIO_PMA_REG_STATUS, &val1); |
| 6978 | DP(NETIF_MSG_LINK, "10G-base-T PMA status 0x%x->0x%x\n", |
| 6979 | val2, val1); |
| 6980 | link_up = ((val1 & 4) == 4); |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 6981 | /* if link is up print the AN outcome of the SFX7101 PHY */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6982 | if (link_up) { |
| 6983 | bnx2x_cl45_read(bp, phy, |
| 6984 | MDIO_AN_DEVAD, MDIO_AN_REG_MASTER_STATUS, |
| 6985 | &val2); |
| 6986 | vars->line_speed = SPEED_10000; |
Yaniv Rosner | 791f18c | 2011-01-18 04:33:42 +0000 | [diff] [blame] | 6987 | vars->duplex = DUPLEX_FULL; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 6988 | DP(NETIF_MSG_LINK, "SFX7101 AN status 0x%x->Master=%x\n", |
| 6989 | val2, (val2 & (1<<14))); |
| 6990 | bnx2x_ext_phy_10G_an_resolve(bp, phy, vars); |
| 6991 | bnx2x_ext_phy_resolve_fc(phy, params, vars); |
| 6992 | } |
| 6993 | return link_up; |
| 6994 | } |
| 6995 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 6996 | 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] | 6997 | { |
| 6998 | if (*len < 5) |
| 6999 | return -EINVAL; |
| 7000 | str[0] = (spirom_ver & 0xFF); |
| 7001 | str[1] = (spirom_ver & 0xFF00) >> 8; |
| 7002 | str[2] = (spirom_ver & 0xFF0000) >> 16; |
| 7003 | str[3] = (spirom_ver & 0xFF000000) >> 24; |
| 7004 | str[4] = '\0'; |
| 7005 | *len -= 5; |
| 7006 | return 0; |
| 7007 | } |
| 7008 | |
| 7009 | void bnx2x_sfx7101_sp_sw_reset(struct bnx2x *bp, struct bnx2x_phy *phy) |
| 7010 | { |
| 7011 | u16 val, cnt; |
| 7012 | |
| 7013 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7014 | MDIO_PMA_DEVAD, |
| 7015 | MDIO_PMA_REG_7101_RESET, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7016 | |
| 7017 | for (cnt = 0; cnt < 10; cnt++) { |
| 7018 | msleep(50); |
| 7019 | /* Writes a self-clearing reset */ |
| 7020 | bnx2x_cl45_write(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7021 | MDIO_PMA_DEVAD, |
| 7022 | MDIO_PMA_REG_7101_RESET, |
| 7023 | (val | (1<<15))); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7024 | /* Wait for clear */ |
| 7025 | bnx2x_cl45_read(bp, phy, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7026 | MDIO_PMA_DEVAD, |
| 7027 | MDIO_PMA_REG_7101_RESET, &val); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7028 | |
| 7029 | if ((val & (1<<15)) == 0) |
| 7030 | break; |
| 7031 | } |
| 7032 | } |
| 7033 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7034 | static void bnx2x_7101_hw_reset(struct bnx2x_phy *phy, |
| 7035 | struct link_params *params) { |
| 7036 | /* Low power mode is controlled by GPIO 2 */ |
| 7037 | bnx2x_set_gpio(params->bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7038 | MISC_REGISTERS_GPIO_OUTPUT_LOW, params->port); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7039 | /* The PHY reset is controlled by GPIO 1 */ |
| 7040 | bnx2x_set_gpio(params->bp, MISC_REGISTERS_GPIO_1, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7041 | MISC_REGISTERS_GPIO_OUTPUT_LOW, params->port); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7042 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7043 | |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 7044 | static void bnx2x_7101_set_link_led(struct bnx2x_phy *phy, |
| 7045 | struct link_params *params, u8 mode) |
| 7046 | { |
| 7047 | u16 val = 0; |
| 7048 | struct bnx2x *bp = params->bp; |
| 7049 | switch (mode) { |
| 7050 | case LED_MODE_FRONT_PANEL_OFF: |
| 7051 | case LED_MODE_OFF: |
| 7052 | val = 2; |
| 7053 | break; |
| 7054 | case LED_MODE_ON: |
| 7055 | val = 1; |
| 7056 | break; |
| 7057 | case LED_MODE_OPER: |
| 7058 | val = 0; |
| 7059 | break; |
| 7060 | } |
| 7061 | bnx2x_cl45_write(bp, phy, |
| 7062 | MDIO_PMA_DEVAD, |
| 7063 | MDIO_PMA_REG_7107_LINK_LED_CNTL, |
| 7064 | val); |
| 7065 | } |
| 7066 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7067 | /******************************************************************/ |
| 7068 | /* STATIC PHY DECLARATION */ |
| 7069 | /******************************************************************/ |
| 7070 | |
| 7071 | static struct bnx2x_phy phy_null = { |
| 7072 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_NOT_CONN, |
| 7073 | .addr = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7074 | .def_md_devad = 0, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 7075 | .flags = FLAGS_INIT_XGXS_FIRST, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7076 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 7077 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 7078 | .mdio_ctrl = 0, |
| 7079 | .supported = 0, |
| 7080 | .media_type = ETH_PHY_NOT_PRESENT, |
| 7081 | .ver_addr = 0, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7082 | .req_flow_ctrl = 0, |
| 7083 | .req_line_speed = 0, |
| 7084 | .speed_cap_mask = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7085 | .req_duplex = 0, |
| 7086 | .rsrv = 0, |
| 7087 | .config_init = (config_init_t)NULL, |
| 7088 | .read_status = (read_status_t)NULL, |
| 7089 | .link_reset = (link_reset_t)NULL, |
| 7090 | .config_loopback = (config_loopback_t)NULL, |
| 7091 | .format_fw_ver = (format_fw_ver_t)NULL, |
| 7092 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7093 | .set_link_led = (set_link_led_t)NULL, |
| 7094 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7095 | }; |
| 7096 | |
| 7097 | static struct bnx2x_phy phy_serdes = { |
| 7098 | .type = PORT_HW_CFG_SERDES_EXT_PHY_TYPE_DIRECT, |
| 7099 | .addr = 0xff, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7100 | .def_md_devad = 0, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 7101 | .flags = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7102 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 7103 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 7104 | .mdio_ctrl = 0, |
| 7105 | .supported = (SUPPORTED_10baseT_Half | |
| 7106 | SUPPORTED_10baseT_Full | |
| 7107 | SUPPORTED_100baseT_Half | |
| 7108 | SUPPORTED_100baseT_Full | |
| 7109 | SUPPORTED_1000baseT_Full | |
| 7110 | SUPPORTED_2500baseX_Full | |
| 7111 | SUPPORTED_TP | |
| 7112 | SUPPORTED_Autoneg | |
| 7113 | SUPPORTED_Pause | |
| 7114 | SUPPORTED_Asym_Pause), |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 7115 | .media_type = ETH_PHY_BASE_T, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7116 | .ver_addr = 0, |
| 7117 | .req_flow_ctrl = 0, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7118 | .req_line_speed = 0, |
| 7119 | .speed_cap_mask = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7120 | .req_duplex = 0, |
| 7121 | .rsrv = 0, |
| 7122 | .config_init = (config_init_t)bnx2x_init_serdes, |
| 7123 | .read_status = (read_status_t)bnx2x_link_settings_status, |
| 7124 | .link_reset = (link_reset_t)bnx2x_int_link_reset, |
| 7125 | .config_loopback = (config_loopback_t)NULL, |
| 7126 | .format_fw_ver = (format_fw_ver_t)NULL, |
| 7127 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7128 | .set_link_led = (set_link_led_t)NULL, |
| 7129 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7130 | }; |
| 7131 | |
| 7132 | static struct bnx2x_phy phy_xgxs = { |
| 7133 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT, |
| 7134 | .addr = 0xff, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7135 | .def_md_devad = 0, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 7136 | .flags = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7137 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 7138 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 7139 | .mdio_ctrl = 0, |
| 7140 | .supported = (SUPPORTED_10baseT_Half | |
| 7141 | SUPPORTED_10baseT_Full | |
| 7142 | SUPPORTED_100baseT_Half | |
| 7143 | SUPPORTED_100baseT_Full | |
| 7144 | SUPPORTED_1000baseT_Full | |
| 7145 | SUPPORTED_2500baseX_Full | |
| 7146 | SUPPORTED_10000baseT_Full | |
| 7147 | SUPPORTED_FIBRE | |
| 7148 | SUPPORTED_Autoneg | |
| 7149 | SUPPORTED_Pause | |
| 7150 | SUPPORTED_Asym_Pause), |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 7151 | .media_type = ETH_PHY_CX4, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7152 | .ver_addr = 0, |
| 7153 | .req_flow_ctrl = 0, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7154 | .req_line_speed = 0, |
| 7155 | .speed_cap_mask = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7156 | .req_duplex = 0, |
| 7157 | .rsrv = 0, |
| 7158 | .config_init = (config_init_t)bnx2x_init_xgxs, |
| 7159 | .read_status = (read_status_t)bnx2x_link_settings_status, |
| 7160 | .link_reset = (link_reset_t)bnx2x_int_link_reset, |
| 7161 | .config_loopback = (config_loopback_t)bnx2x_set_xgxs_loopback, |
| 7162 | .format_fw_ver = (format_fw_ver_t)NULL, |
| 7163 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7164 | .set_link_led = (set_link_led_t)NULL, |
| 7165 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7166 | }; |
| 7167 | |
| 7168 | static struct bnx2x_phy phy_7101 = { |
| 7169 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_SFX7101, |
| 7170 | .addr = 0xff, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7171 | .def_md_devad = 0, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 7172 | .flags = FLAGS_FAN_FAILURE_DET_REQ, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7173 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 7174 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 7175 | .mdio_ctrl = 0, |
| 7176 | .supported = (SUPPORTED_10000baseT_Full | |
| 7177 | SUPPORTED_TP | |
| 7178 | SUPPORTED_Autoneg | |
| 7179 | SUPPORTED_Pause | |
| 7180 | SUPPORTED_Asym_Pause), |
| 7181 | .media_type = ETH_PHY_BASE_T, |
| 7182 | .ver_addr = 0, |
| 7183 | .req_flow_ctrl = 0, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7184 | .req_line_speed = 0, |
| 7185 | .speed_cap_mask = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7186 | .req_duplex = 0, |
| 7187 | .rsrv = 0, |
| 7188 | .config_init = (config_init_t)bnx2x_7101_config_init, |
| 7189 | .read_status = (read_status_t)bnx2x_7101_read_status, |
| 7190 | .link_reset = (link_reset_t)bnx2x_common_ext_link_reset, |
| 7191 | .config_loopback = (config_loopback_t)bnx2x_7101_config_loopback, |
| 7192 | .format_fw_ver = (format_fw_ver_t)bnx2x_7101_format_ver, |
| 7193 | .hw_reset = (hw_reset_t)bnx2x_7101_hw_reset, |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 7194 | .set_link_led = (set_link_led_t)bnx2x_7101_set_link_led, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7195 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7196 | }; |
| 7197 | static struct bnx2x_phy phy_8073 = { |
| 7198 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073, |
| 7199 | .addr = 0xff, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7200 | .def_md_devad = 0, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 7201 | .flags = FLAGS_HW_LOCK_REQUIRED, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 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_2500baseX_Full | |
| 7207 | SUPPORTED_1000baseT_Full | |
| 7208 | SUPPORTED_FIBRE | |
| 7209 | SUPPORTED_Autoneg | |
| 7210 | SUPPORTED_Pause | |
| 7211 | SUPPORTED_Asym_Pause), |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 7212 | .media_type = ETH_PHY_KR, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7213 | .ver_addr = 0, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7214 | .req_flow_ctrl = 0, |
| 7215 | .req_line_speed = 0, |
| 7216 | .speed_cap_mask = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7217 | .req_duplex = 0, |
| 7218 | .rsrv = 0, |
Yaniv Rosner | 62b29a5 | 2010-09-07 11:40:58 +0000 | [diff] [blame] | 7219 | .config_init = (config_init_t)bnx2x_8073_config_init, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7220 | .read_status = (read_status_t)bnx2x_8073_read_status, |
| 7221 | .link_reset = (link_reset_t)bnx2x_8073_link_reset, |
| 7222 | .config_loopback = (config_loopback_t)NULL, |
| 7223 | .format_fw_ver = (format_fw_ver_t)bnx2x_format_ver, |
| 7224 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7225 | .set_link_led = (set_link_led_t)NULL, |
| 7226 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7227 | }; |
| 7228 | static struct bnx2x_phy phy_8705 = { |
| 7229 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8705, |
| 7230 | .addr = 0xff, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7231 | .def_md_devad = 0, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 7232 | .flags = FLAGS_INIT_XGXS_FIRST, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7233 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 7234 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 7235 | .mdio_ctrl = 0, |
| 7236 | .supported = (SUPPORTED_10000baseT_Full | |
| 7237 | SUPPORTED_FIBRE | |
| 7238 | SUPPORTED_Pause | |
| 7239 | SUPPORTED_Asym_Pause), |
| 7240 | .media_type = ETH_PHY_XFP_FIBER, |
| 7241 | .ver_addr = 0, |
| 7242 | .req_flow_ctrl = 0, |
| 7243 | .req_line_speed = 0, |
| 7244 | .speed_cap_mask = 0, |
| 7245 | .req_duplex = 0, |
| 7246 | .rsrv = 0, |
| 7247 | .config_init = (config_init_t)bnx2x_8705_config_init, |
| 7248 | .read_status = (read_status_t)bnx2x_8705_read_status, |
| 7249 | .link_reset = (link_reset_t)bnx2x_common_ext_link_reset, |
| 7250 | .config_loopback = (config_loopback_t)NULL, |
| 7251 | .format_fw_ver = (format_fw_ver_t)bnx2x_null_format_ver, |
| 7252 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7253 | .set_link_led = (set_link_led_t)NULL, |
| 7254 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7255 | }; |
| 7256 | static struct bnx2x_phy phy_8706 = { |
| 7257 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8706, |
| 7258 | .addr = 0xff, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7259 | .def_md_devad = 0, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 7260 | .flags = FLAGS_INIT_XGXS_FIRST, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7261 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 7262 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 7263 | .mdio_ctrl = 0, |
| 7264 | .supported = (SUPPORTED_10000baseT_Full | |
| 7265 | SUPPORTED_1000baseT_Full | |
| 7266 | SUPPORTED_FIBRE | |
| 7267 | SUPPORTED_Pause | |
| 7268 | SUPPORTED_Asym_Pause), |
| 7269 | .media_type = ETH_PHY_SFP_FIBER, |
| 7270 | .ver_addr = 0, |
| 7271 | .req_flow_ctrl = 0, |
| 7272 | .req_line_speed = 0, |
| 7273 | .speed_cap_mask = 0, |
| 7274 | .req_duplex = 0, |
| 7275 | .rsrv = 0, |
| 7276 | .config_init = (config_init_t)bnx2x_8706_config_init, |
| 7277 | .read_status = (read_status_t)bnx2x_8706_read_status, |
| 7278 | .link_reset = (link_reset_t)bnx2x_common_ext_link_reset, |
| 7279 | .config_loopback = (config_loopback_t)NULL, |
| 7280 | .format_fw_ver = (format_fw_ver_t)bnx2x_format_ver, |
| 7281 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7282 | .set_link_led = (set_link_led_t)NULL, |
| 7283 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7284 | }; |
| 7285 | |
| 7286 | static struct bnx2x_phy phy_8726 = { |
| 7287 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726, |
| 7288 | .addr = 0xff, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 7289 | .def_md_devad = 0, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7290 | .flags = (FLAGS_HW_LOCK_REQUIRED | |
| 7291 | FLAGS_INIT_XGXS_FIRST), |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7292 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 7293 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 7294 | .mdio_ctrl = 0, |
| 7295 | .supported = (SUPPORTED_10000baseT_Full | |
| 7296 | SUPPORTED_1000baseT_Full | |
| 7297 | SUPPORTED_Autoneg | |
| 7298 | SUPPORTED_FIBRE | |
| 7299 | SUPPORTED_Pause | |
| 7300 | SUPPORTED_Asym_Pause), |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 7301 | .media_type = ETH_PHY_NOT_PRESENT, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7302 | .ver_addr = 0, |
| 7303 | .req_flow_ctrl = 0, |
| 7304 | .req_line_speed = 0, |
| 7305 | .speed_cap_mask = 0, |
| 7306 | .req_duplex = 0, |
| 7307 | .rsrv = 0, |
| 7308 | .config_init = (config_init_t)bnx2x_8726_config_init, |
| 7309 | .read_status = (read_status_t)bnx2x_8726_read_status, |
| 7310 | .link_reset = (link_reset_t)bnx2x_8726_link_reset, |
| 7311 | .config_loopback = (config_loopback_t)bnx2x_8726_config_loopback, |
| 7312 | .format_fw_ver = (format_fw_ver_t)bnx2x_format_ver, |
| 7313 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7314 | .set_link_led = (set_link_led_t)NULL, |
| 7315 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7316 | }; |
| 7317 | |
| 7318 | static struct bnx2x_phy phy_8727 = { |
| 7319 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727, |
| 7320 | .addr = 0xff, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7321 | .def_md_devad = 0, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 7322 | .flags = FLAGS_FAN_FAILURE_DET_REQ, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7323 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 7324 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 7325 | .mdio_ctrl = 0, |
| 7326 | .supported = (SUPPORTED_10000baseT_Full | |
| 7327 | SUPPORTED_1000baseT_Full | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7328 | SUPPORTED_FIBRE | |
| 7329 | SUPPORTED_Pause | |
| 7330 | SUPPORTED_Asym_Pause), |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 7331 | .media_type = ETH_PHY_NOT_PRESENT, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7332 | .ver_addr = 0, |
| 7333 | .req_flow_ctrl = 0, |
| 7334 | .req_line_speed = 0, |
| 7335 | .speed_cap_mask = 0, |
| 7336 | .req_duplex = 0, |
| 7337 | .rsrv = 0, |
| 7338 | .config_init = (config_init_t)bnx2x_8727_config_init, |
| 7339 | .read_status = (read_status_t)bnx2x_8727_read_status, |
| 7340 | .link_reset = (link_reset_t)bnx2x_8727_link_reset, |
| 7341 | .config_loopback = (config_loopback_t)NULL, |
| 7342 | .format_fw_ver = (format_fw_ver_t)bnx2x_format_ver, |
| 7343 | .hw_reset = (hw_reset_t)bnx2x_8727_hw_reset, |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 7344 | .set_link_led = (set_link_led_t)bnx2x_8727_set_link_led, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7345 | .phy_specific_func = (phy_specific_func_t)bnx2x_8727_specific_func |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7346 | }; |
| 7347 | static struct bnx2x_phy phy_8481 = { |
| 7348 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8481, |
| 7349 | .addr = 0xff, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 7350 | .def_md_devad = 0, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7351 | .flags = FLAGS_FAN_FAILURE_DET_REQ | |
| 7352 | FLAGS_REARM_LATCH_SIGNAL, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7353 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 7354 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 7355 | .mdio_ctrl = 0, |
| 7356 | .supported = (SUPPORTED_10baseT_Half | |
| 7357 | SUPPORTED_10baseT_Full | |
| 7358 | SUPPORTED_100baseT_Half | |
| 7359 | SUPPORTED_100baseT_Full | |
| 7360 | SUPPORTED_1000baseT_Full | |
| 7361 | SUPPORTED_10000baseT_Full | |
| 7362 | SUPPORTED_TP | |
| 7363 | SUPPORTED_Autoneg | |
| 7364 | SUPPORTED_Pause | |
| 7365 | SUPPORTED_Asym_Pause), |
| 7366 | .media_type = ETH_PHY_BASE_T, |
| 7367 | .ver_addr = 0, |
| 7368 | .req_flow_ctrl = 0, |
| 7369 | .req_line_speed = 0, |
| 7370 | .speed_cap_mask = 0, |
| 7371 | .req_duplex = 0, |
| 7372 | .rsrv = 0, |
| 7373 | .config_init = (config_init_t)bnx2x_8481_config_init, |
| 7374 | .read_status = (read_status_t)bnx2x_848xx_read_status, |
| 7375 | .link_reset = (link_reset_t)bnx2x_8481_link_reset, |
| 7376 | .config_loopback = (config_loopback_t)NULL, |
| 7377 | .format_fw_ver = (format_fw_ver_t)bnx2x_848xx_format_ver, |
| 7378 | .hw_reset = (hw_reset_t)bnx2x_8481_hw_reset, |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 7379 | .set_link_led = (set_link_led_t)bnx2x_848xx_set_link_led, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7380 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7381 | }; |
| 7382 | |
| 7383 | static struct bnx2x_phy phy_84823 = { |
| 7384 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84823, |
| 7385 | .addr = 0xff, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 7386 | .def_md_devad = 0, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7387 | .flags = FLAGS_FAN_FAILURE_DET_REQ | |
| 7388 | FLAGS_REARM_LATCH_SIGNAL, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7389 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 7390 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 7391 | .mdio_ctrl = 0, |
| 7392 | .supported = (SUPPORTED_10baseT_Half | |
| 7393 | SUPPORTED_10baseT_Full | |
| 7394 | SUPPORTED_100baseT_Half | |
| 7395 | SUPPORTED_100baseT_Full | |
| 7396 | SUPPORTED_1000baseT_Full | |
| 7397 | SUPPORTED_10000baseT_Full | |
| 7398 | SUPPORTED_TP | |
| 7399 | SUPPORTED_Autoneg | |
| 7400 | SUPPORTED_Pause | |
| 7401 | SUPPORTED_Asym_Pause), |
| 7402 | .media_type = ETH_PHY_BASE_T, |
| 7403 | .ver_addr = 0, |
| 7404 | .req_flow_ctrl = 0, |
| 7405 | .req_line_speed = 0, |
| 7406 | .speed_cap_mask = 0, |
| 7407 | .req_duplex = 0, |
| 7408 | .rsrv = 0, |
| 7409 | .config_init = (config_init_t)bnx2x_848x3_config_init, |
| 7410 | .read_status = (read_status_t)bnx2x_848xx_read_status, |
| 7411 | .link_reset = (link_reset_t)bnx2x_848x3_link_reset, |
| 7412 | .config_loopback = (config_loopback_t)NULL, |
| 7413 | .format_fw_ver = (format_fw_ver_t)bnx2x_848xx_format_ver, |
| 7414 | .hw_reset = (hw_reset_t)NULL, |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 7415 | .set_link_led = (set_link_led_t)bnx2x_848xx_set_link_led, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7416 | .phy_specific_func = (phy_specific_func_t)NULL |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7417 | }; |
| 7418 | |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 7419 | static struct bnx2x_phy phy_84833 = { |
| 7420 | .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833, |
| 7421 | .addr = 0xff, |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 7422 | .def_md_devad = 0, |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 7423 | .flags = FLAGS_FAN_FAILURE_DET_REQ | |
| 7424 | FLAGS_REARM_LATCH_SIGNAL, |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 7425 | .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 7426 | .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, |
| 7427 | .mdio_ctrl = 0, |
| 7428 | .supported = (SUPPORTED_10baseT_Half | |
| 7429 | SUPPORTED_10baseT_Full | |
| 7430 | SUPPORTED_100baseT_Half | |
| 7431 | SUPPORTED_100baseT_Full | |
| 7432 | SUPPORTED_1000baseT_Full | |
| 7433 | SUPPORTED_10000baseT_Full | |
| 7434 | SUPPORTED_TP | |
| 7435 | SUPPORTED_Autoneg | |
| 7436 | SUPPORTED_Pause | |
| 7437 | SUPPORTED_Asym_Pause), |
| 7438 | .media_type = ETH_PHY_BASE_T, |
| 7439 | .ver_addr = 0, |
| 7440 | .req_flow_ctrl = 0, |
| 7441 | .req_line_speed = 0, |
| 7442 | .speed_cap_mask = 0, |
| 7443 | .req_duplex = 0, |
| 7444 | .rsrv = 0, |
| 7445 | .config_init = (config_init_t)bnx2x_848x3_config_init, |
| 7446 | .read_status = (read_status_t)bnx2x_848xx_read_status, |
| 7447 | .link_reset = (link_reset_t)bnx2x_848x3_link_reset, |
| 7448 | .config_loopback = (config_loopback_t)NULL, |
| 7449 | .format_fw_ver = (format_fw_ver_t)bnx2x_848xx_format_ver, |
| 7450 | .hw_reset = (hw_reset_t)NULL, |
| 7451 | .set_link_led = (set_link_led_t)bnx2x_848xx_set_link_led, |
| 7452 | .phy_specific_func = (phy_specific_func_t)NULL |
| 7453 | }; |
| 7454 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7455 | /*****************************************************************/ |
| 7456 | /* */ |
| 7457 | /* Populate the phy according. Main function: bnx2x_populate_phy */ |
| 7458 | /* */ |
| 7459 | /*****************************************************************/ |
| 7460 | |
| 7461 | static void bnx2x_populate_preemphasis(struct bnx2x *bp, u32 shmem_base, |
| 7462 | struct bnx2x_phy *phy, u8 port, |
| 7463 | u8 phy_index) |
| 7464 | { |
| 7465 | /* Get the 4 lanes xgxs config rx and tx */ |
| 7466 | u32 rx = 0, tx = 0, i; |
| 7467 | for (i = 0; i < 2; i++) { |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7468 | /* |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7469 | * INT_PHY and EXT_PHY1 share the same value location in the |
| 7470 | * shmem. When num_phys is greater than 1, than this value |
| 7471 | * applies only to EXT_PHY1 |
| 7472 | */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7473 | if (phy_index == INT_PHY || phy_index == EXT_PHY1) { |
| 7474 | rx = REG_RD(bp, shmem_base + |
| 7475 | offsetof(struct shmem_region, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7476 | dev_info.port_hw_config[port].xgxs_config_rx[i<<1])); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7477 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7478 | tx = REG_RD(bp, shmem_base + |
| 7479 | offsetof(struct shmem_region, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7480 | dev_info.port_hw_config[port].xgxs_config_tx[i<<1])); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7481 | } else { |
| 7482 | rx = REG_RD(bp, shmem_base + |
| 7483 | offsetof(struct shmem_region, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7484 | dev_info.port_hw_config[port].xgxs_config2_rx[i<<1])); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7485 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7486 | tx = REG_RD(bp, shmem_base + |
| 7487 | offsetof(struct shmem_region, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7488 | dev_info.port_hw_config[port].xgxs_config2_rx[i<<1])); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7489 | } |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7490 | |
| 7491 | phy->rx_preemphasis[i << 1] = ((rx>>16) & 0xffff); |
| 7492 | phy->rx_preemphasis[(i << 1) + 1] = (rx & 0xffff); |
| 7493 | |
| 7494 | phy->tx_preemphasis[i << 1] = ((tx>>16) & 0xffff); |
| 7495 | phy->tx_preemphasis[(i << 1) + 1] = (tx & 0xffff); |
| 7496 | } |
| 7497 | } |
| 7498 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 7499 | static u32 bnx2x_get_ext_phy_config(struct bnx2x *bp, u32 shmem_base, |
| 7500 | u8 phy_index, u8 port) |
| 7501 | { |
| 7502 | u32 ext_phy_config = 0; |
| 7503 | switch (phy_index) { |
| 7504 | case EXT_PHY1: |
| 7505 | ext_phy_config = REG_RD(bp, shmem_base + |
| 7506 | offsetof(struct shmem_region, |
| 7507 | dev_info.port_hw_config[port].external_phy_config)); |
| 7508 | break; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7509 | case EXT_PHY2: |
| 7510 | ext_phy_config = REG_RD(bp, shmem_base + |
| 7511 | offsetof(struct shmem_region, |
| 7512 | dev_info.port_hw_config[port].external_phy_config2)); |
| 7513 | break; |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 7514 | default: |
| 7515 | DP(NETIF_MSG_LINK, "Invalid phy_index %d\n", phy_index); |
| 7516 | return -EINVAL; |
| 7517 | } |
| 7518 | |
| 7519 | return ext_phy_config; |
| 7520 | } |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 7521 | static int bnx2x_populate_int_phy(struct bnx2x *bp, u32 shmem_base, u8 port, |
| 7522 | struct bnx2x_phy *phy) |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7523 | { |
| 7524 | u32 phy_addr; |
| 7525 | u32 chip_id; |
| 7526 | u32 switch_cfg = (REG_RD(bp, shmem_base + |
| 7527 | offsetof(struct shmem_region, |
| 7528 | dev_info.port_feature_config[port].link_config)) & |
| 7529 | PORT_FEATURE_CONNECTED_SWITCH_MASK); |
| 7530 | chip_id = REG_RD(bp, MISC_REG_CHIP_NUM) << 16; |
| 7531 | switch (switch_cfg) { |
| 7532 | case SWITCH_CFG_1G: |
| 7533 | phy_addr = REG_RD(bp, |
| 7534 | NIG_REG_SERDES0_CTRL_PHY_ADDR + |
| 7535 | port * 0x10); |
| 7536 | *phy = phy_serdes; |
| 7537 | break; |
| 7538 | case SWITCH_CFG_10G: |
| 7539 | phy_addr = REG_RD(bp, |
| 7540 | NIG_REG_XGXS0_CTRL_PHY_ADDR + |
| 7541 | port * 0x18); |
| 7542 | *phy = phy_xgxs; |
| 7543 | break; |
| 7544 | default: |
| 7545 | DP(NETIF_MSG_LINK, "Invalid switch_cfg\n"); |
| 7546 | return -EINVAL; |
| 7547 | } |
| 7548 | phy->addr = (u8)phy_addr; |
| 7549 | phy->mdio_ctrl = bnx2x_get_emac_base(bp, |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 7550 | SHARED_HW_CFG_MDC_MDIO_ACCESS1_BOTH, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7551 | port); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 7552 | if (CHIP_IS_E2(bp)) |
| 7553 | phy->def_md_devad = E2_DEFAULT_PHY_DEV_ADDR; |
| 7554 | else |
| 7555 | phy->def_md_devad = DEFAULT_PHY_DEV_ADDR; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7556 | |
| 7557 | DP(NETIF_MSG_LINK, "Internal phy port=%d, addr=0x%x, mdio_ctl=0x%x\n", |
| 7558 | port, phy->addr, phy->mdio_ctrl); |
| 7559 | |
| 7560 | bnx2x_populate_preemphasis(bp, shmem_base, phy, port, INT_PHY); |
| 7561 | return 0; |
| 7562 | } |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 7563 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 7564 | static int bnx2x_populate_ext_phy(struct bnx2x *bp, |
| 7565 | u8 phy_index, |
| 7566 | u32 shmem_base, |
| 7567 | u32 shmem2_base, |
| 7568 | u8 port, |
| 7569 | struct bnx2x_phy *phy) |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 7570 | { |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 7571 | u32 ext_phy_config, phy_type, config2; |
| 7572 | u32 mdc_mdio_access = SHARED_HW_CFG_MDC_MDIO_ACCESS1_BOTH; |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 7573 | ext_phy_config = bnx2x_get_ext_phy_config(bp, shmem_base, |
| 7574 | phy_index, port); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7575 | phy_type = XGXS_EXT_PHY_TYPE(ext_phy_config); |
| 7576 | /* Select the phy type */ |
| 7577 | switch (phy_type) { |
| 7578 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073: |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 7579 | mdc_mdio_access = SHARED_HW_CFG_MDC_MDIO_ACCESS1_SWAPPED; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7580 | *phy = phy_8073; |
| 7581 | break; |
| 7582 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8705: |
| 7583 | *phy = phy_8705; |
| 7584 | break; |
| 7585 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8706: |
| 7586 | *phy = phy_8706; |
| 7587 | break; |
| 7588 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726: |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 7589 | mdc_mdio_access = SHARED_HW_CFG_MDC_MDIO_ACCESS1_EMAC1; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7590 | *phy = phy_8726; |
| 7591 | break; |
| 7592 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727_NOC: |
| 7593 | /* BCM8727_NOC => BCM8727 no over current */ |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 7594 | mdc_mdio_access = SHARED_HW_CFG_MDC_MDIO_ACCESS1_EMAC1; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7595 | *phy = phy_8727; |
| 7596 | phy->flags |= FLAGS_NOC; |
| 7597 | break; |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 7598 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8722: |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7599 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727: |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 7600 | mdc_mdio_access = SHARED_HW_CFG_MDC_MDIO_ACCESS1_EMAC1; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7601 | *phy = phy_8727; |
| 7602 | break; |
| 7603 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8481: |
| 7604 | *phy = phy_8481; |
| 7605 | break; |
| 7606 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84823: |
| 7607 | *phy = phy_84823; |
| 7608 | break; |
Yaniv Rosner | c87bca1 | 2011-01-31 04:22:41 +0000 | [diff] [blame] | 7609 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833: |
| 7610 | *phy = phy_84833; |
| 7611 | break; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7612 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_SFX7101: |
| 7613 | *phy = phy_7101; |
| 7614 | break; |
| 7615 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_FAILURE: |
| 7616 | *phy = phy_null; |
| 7617 | return -EINVAL; |
| 7618 | default: |
| 7619 | *phy = phy_null; |
| 7620 | return 0; |
| 7621 | } |
| 7622 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 7623 | phy->addr = XGXS_EXT_PHY_ADDR(ext_phy_config); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7624 | bnx2x_populate_preemphasis(bp, shmem_base, phy, port, phy_index); |
Yaniv Rosner | 62b29a5 | 2010-09-07 11:40:58 +0000 | [diff] [blame] | 7625 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7626 | /* |
| 7627 | * The shmem address of the phy version is located on different |
| 7628 | * structures. In case this structure is too old, do not set |
| 7629 | * the address |
| 7630 | */ |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 7631 | config2 = REG_RD(bp, shmem_base + offsetof(struct shmem_region, |
| 7632 | dev_info.shared_hw_config.config2)); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7633 | if (phy_index == EXT_PHY1) { |
| 7634 | phy->ver_addr = shmem_base + offsetof(struct shmem_region, |
| 7635 | port_mb[port].ext_phy_fw_version); |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 7636 | |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7637 | /* Check specific mdc mdio settings */ |
| 7638 | if (config2 & SHARED_HW_CFG_MDC_MDIO_ACCESS1_MASK) |
| 7639 | mdc_mdio_access = config2 & |
| 7640 | SHARED_HW_CFG_MDC_MDIO_ACCESS1_MASK; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7641 | } else { |
| 7642 | u32 size = REG_RD(bp, shmem2_base); |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 7643 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7644 | if (size > |
| 7645 | offsetof(struct shmem2_region, ext_phy_fw_version2)) { |
| 7646 | phy->ver_addr = shmem2_base + |
| 7647 | offsetof(struct shmem2_region, |
| 7648 | ext_phy_fw_version2[port]); |
| 7649 | } |
| 7650 | /* Check specific mdc mdio settings */ |
| 7651 | if (config2 & SHARED_HW_CFG_MDC_MDIO_ACCESS2_MASK) |
| 7652 | mdc_mdio_access = (config2 & |
| 7653 | SHARED_HW_CFG_MDC_MDIO_ACCESS2_MASK) >> |
| 7654 | (SHARED_HW_CFG_MDC_MDIO_ACCESS2_SHIFT - |
| 7655 | SHARED_HW_CFG_MDC_MDIO_ACCESS1_SHIFT); |
| 7656 | } |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 7657 | phy->mdio_ctrl = bnx2x_get_emac_base(bp, mdc_mdio_access, port); |
| 7658 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 7659 | /* |
Yaniv Rosner | c18aa15 | 2010-09-07 11:41:07 +0000 | [diff] [blame] | 7660 | * In case mdc/mdio_access of the external phy is different than the |
| 7661 | * mdc/mdio access of the XGXS, a HW lock must be taken in each access |
| 7662 | * to prevent one port interfere with another port's CL45 operations. |
| 7663 | */ |
| 7664 | if (mdc_mdio_access != SHARED_HW_CFG_MDC_MDIO_ACCESS1_BOTH) |
| 7665 | phy->flags |= FLAGS_HW_LOCK_REQUIRED; |
| 7666 | DP(NETIF_MSG_LINK, "phy_type 0x%x port %d found in index %d\n", |
| 7667 | phy_type, port, phy_index); |
| 7668 | DP(NETIF_MSG_LINK, " addr=0x%x, mdio_ctl=0x%x\n", |
| 7669 | phy->addr, phy->mdio_ctrl); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 7670 | return 0; |
| 7671 | } |
| 7672 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 7673 | static int bnx2x_populate_phy(struct bnx2x *bp, u8 phy_index, u32 shmem_base, |
| 7674 | u32 shmem2_base, u8 port, struct bnx2x_phy *phy) |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 7675 | { |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 7676 | int status = 0; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7677 | phy->type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_NOT_CONN; |
| 7678 | if (phy_index == INT_PHY) |
| 7679 | return bnx2x_populate_int_phy(bp, shmem_base, port, phy); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7680 | status = bnx2x_populate_ext_phy(bp, phy_index, shmem_base, shmem2_base, |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 7681 | port, phy); |
| 7682 | return status; |
| 7683 | } |
| 7684 | |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7685 | static void bnx2x_phy_def_cfg(struct link_params *params, |
| 7686 | struct bnx2x_phy *phy, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7687 | u8 phy_index) |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7688 | { |
| 7689 | struct bnx2x *bp = params->bp; |
| 7690 | u32 link_config; |
| 7691 | /* Populate the default phy configuration for MF mode */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7692 | if (phy_index == EXT_PHY2) { |
| 7693 | link_config = REG_RD(bp, params->shmem_base + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7694 | offsetof(struct shmem_region, dev_info. |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7695 | port_feature_config[params->port].link_config2)); |
| 7696 | phy->speed_cap_mask = REG_RD(bp, params->shmem_base + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7697 | offsetof(struct shmem_region, |
| 7698 | dev_info. |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7699 | port_hw_config[params->port].speed_capability_mask2)); |
| 7700 | } else { |
| 7701 | link_config = REG_RD(bp, params->shmem_base + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7702 | offsetof(struct shmem_region, dev_info. |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7703 | port_feature_config[params->port].link_config)); |
| 7704 | phy->speed_cap_mask = REG_RD(bp, params->shmem_base + |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 7705 | offsetof(struct shmem_region, |
| 7706 | dev_info. |
| 7707 | port_hw_config[params->port].speed_capability_mask)); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7708 | } |
| 7709 | DP(NETIF_MSG_LINK, "Default config phy idx %x cfg 0x%x speed_cap_mask" |
| 7710 | " 0x%x\n", phy_index, link_config, phy->speed_cap_mask); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7711 | |
| 7712 | phy->req_duplex = DUPLEX_FULL; |
| 7713 | switch (link_config & PORT_FEATURE_LINK_SPEED_MASK) { |
| 7714 | case PORT_FEATURE_LINK_SPEED_10M_HALF: |
| 7715 | phy->req_duplex = DUPLEX_HALF; |
| 7716 | case PORT_FEATURE_LINK_SPEED_10M_FULL: |
| 7717 | phy->req_line_speed = SPEED_10; |
| 7718 | break; |
| 7719 | case PORT_FEATURE_LINK_SPEED_100M_HALF: |
| 7720 | phy->req_duplex = DUPLEX_HALF; |
| 7721 | case PORT_FEATURE_LINK_SPEED_100M_FULL: |
| 7722 | phy->req_line_speed = SPEED_100; |
| 7723 | break; |
| 7724 | case PORT_FEATURE_LINK_SPEED_1G: |
| 7725 | phy->req_line_speed = SPEED_1000; |
| 7726 | break; |
| 7727 | case PORT_FEATURE_LINK_SPEED_2_5G: |
| 7728 | phy->req_line_speed = SPEED_2500; |
| 7729 | break; |
| 7730 | case PORT_FEATURE_LINK_SPEED_10G_CX4: |
| 7731 | phy->req_line_speed = SPEED_10000; |
| 7732 | break; |
| 7733 | default: |
| 7734 | phy->req_line_speed = SPEED_AUTO_NEG; |
| 7735 | break; |
| 7736 | } |
| 7737 | |
| 7738 | switch (link_config & PORT_FEATURE_FLOW_CONTROL_MASK) { |
| 7739 | case PORT_FEATURE_FLOW_CONTROL_AUTO: |
| 7740 | phy->req_flow_ctrl = BNX2X_FLOW_CTRL_AUTO; |
| 7741 | break; |
| 7742 | case PORT_FEATURE_FLOW_CONTROL_TX: |
| 7743 | phy->req_flow_ctrl = BNX2X_FLOW_CTRL_TX; |
| 7744 | break; |
| 7745 | case PORT_FEATURE_FLOW_CONTROL_RX: |
| 7746 | phy->req_flow_ctrl = BNX2X_FLOW_CTRL_RX; |
| 7747 | break; |
| 7748 | case PORT_FEATURE_FLOW_CONTROL_BOTH: |
| 7749 | phy->req_flow_ctrl = BNX2X_FLOW_CTRL_BOTH; |
| 7750 | break; |
| 7751 | default: |
| 7752 | phy->req_flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 7753 | break; |
| 7754 | } |
| 7755 | } |
| 7756 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7757 | u32 bnx2x_phy_selection(struct link_params *params) |
| 7758 | { |
| 7759 | u32 phy_config_swapped, prio_cfg; |
| 7760 | u32 return_cfg = PORT_HW_CFG_PHY_SELECTION_HARDWARE_DEFAULT; |
| 7761 | |
| 7762 | phy_config_swapped = params->multi_phy_config & |
| 7763 | PORT_HW_CFG_PHY_SWAPPED_ENABLED; |
| 7764 | |
| 7765 | prio_cfg = params->multi_phy_config & |
| 7766 | PORT_HW_CFG_PHY_SELECTION_MASK; |
| 7767 | |
| 7768 | if (phy_config_swapped) { |
| 7769 | switch (prio_cfg) { |
| 7770 | case PORT_HW_CFG_PHY_SELECTION_FIRST_PHY_PRIORITY: |
| 7771 | return_cfg = PORT_HW_CFG_PHY_SELECTION_SECOND_PHY_PRIORITY; |
| 7772 | break; |
| 7773 | case PORT_HW_CFG_PHY_SELECTION_SECOND_PHY_PRIORITY: |
| 7774 | return_cfg = PORT_HW_CFG_PHY_SELECTION_FIRST_PHY_PRIORITY; |
| 7775 | break; |
| 7776 | case PORT_HW_CFG_PHY_SELECTION_SECOND_PHY: |
| 7777 | return_cfg = PORT_HW_CFG_PHY_SELECTION_FIRST_PHY; |
| 7778 | break; |
| 7779 | case PORT_HW_CFG_PHY_SELECTION_FIRST_PHY: |
| 7780 | return_cfg = PORT_HW_CFG_PHY_SELECTION_SECOND_PHY; |
| 7781 | break; |
| 7782 | } |
| 7783 | } else |
| 7784 | return_cfg = prio_cfg; |
| 7785 | |
| 7786 | return return_cfg; |
| 7787 | } |
| 7788 | |
| 7789 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 7790 | int bnx2x_phy_probe(struct link_params *params) |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7791 | { |
| 7792 | u8 phy_index, actual_phy_idx, link_cfg_idx; |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 7793 | u32 phy_config_swapped, sync_offset, media_types; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7794 | struct bnx2x *bp = params->bp; |
| 7795 | struct bnx2x_phy *phy; |
| 7796 | params->num_phys = 0; |
| 7797 | DP(NETIF_MSG_LINK, "Begin phy probe\n"); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7798 | phy_config_swapped = params->multi_phy_config & |
| 7799 | PORT_HW_CFG_PHY_SWAPPED_ENABLED; |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7800 | |
| 7801 | for (phy_index = INT_PHY; phy_index < MAX_PHYS; |
| 7802 | phy_index++) { |
| 7803 | link_cfg_idx = LINK_CONFIG_IDX(phy_index); |
| 7804 | actual_phy_idx = phy_index; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7805 | if (phy_config_swapped) { |
| 7806 | if (phy_index == EXT_PHY1) |
| 7807 | actual_phy_idx = EXT_PHY2; |
| 7808 | else if (phy_index == EXT_PHY2) |
| 7809 | actual_phy_idx = EXT_PHY1; |
| 7810 | } |
| 7811 | DP(NETIF_MSG_LINK, "phy_config_swapped %x, phy_index %x," |
| 7812 | " actual_phy_idx %x\n", phy_config_swapped, |
| 7813 | phy_index, actual_phy_idx); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7814 | phy = ¶ms->phy[actual_phy_idx]; |
| 7815 | if (bnx2x_populate_phy(bp, phy_index, params->shmem_base, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7816 | params->shmem2_base, params->port, |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7817 | phy) != 0) { |
| 7818 | params->num_phys = 0; |
| 7819 | DP(NETIF_MSG_LINK, "phy probe failed in phy index %d\n", |
| 7820 | phy_index); |
| 7821 | for (phy_index = INT_PHY; |
| 7822 | phy_index < MAX_PHYS; |
| 7823 | phy_index++) |
| 7824 | *phy = phy_null; |
| 7825 | return -EINVAL; |
| 7826 | } |
| 7827 | if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_NOT_CONN) |
| 7828 | break; |
| 7829 | |
Yaniv Rosner | 1ac9e42 | 2011-05-31 21:26:11 +0000 | [diff] [blame] | 7830 | sync_offset = params->shmem_base + |
| 7831 | offsetof(struct shmem_region, |
| 7832 | dev_info.port_hw_config[params->port].media_type); |
| 7833 | media_types = REG_RD(bp, sync_offset); |
| 7834 | |
| 7835 | /* |
| 7836 | * Update media type for non-PMF sync only for the first time |
| 7837 | * In case the media type changes afterwards, it will be updated |
| 7838 | * using the update_status function |
| 7839 | */ |
| 7840 | if ((media_types & (PORT_HW_CFG_MEDIA_TYPE_PHY0_MASK << |
| 7841 | (PORT_HW_CFG_MEDIA_TYPE_PHY1_SHIFT * |
| 7842 | actual_phy_idx))) == 0) { |
| 7843 | media_types |= ((phy->media_type & |
| 7844 | PORT_HW_CFG_MEDIA_TYPE_PHY0_MASK) << |
| 7845 | (PORT_HW_CFG_MEDIA_TYPE_PHY1_SHIFT * |
| 7846 | actual_phy_idx)); |
| 7847 | } |
| 7848 | REG_WR(bp, sync_offset, media_types); |
| 7849 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7850 | bnx2x_phy_def_cfg(params, phy, phy_index); |
Yaniv Rosner | b7737c9 | 2010-09-07 11:40:54 +0000 | [diff] [blame] | 7851 | params->num_phys++; |
| 7852 | } |
| 7853 | |
| 7854 | DP(NETIF_MSG_LINK, "End phy probe. #phys found %x\n", params->num_phys); |
| 7855 | return 0; |
| 7856 | } |
| 7857 | |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 7858 | void bnx2x_init_bmac_loopback(struct link_params *params, |
| 7859 | struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7860 | { |
| 7861 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 7862 | vars->link_up = 1; |
| 7863 | vars->line_speed = SPEED_10000; |
| 7864 | vars->duplex = DUPLEX_FULL; |
| 7865 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 7866 | vars->mac_type = MAC_TYPE_BMAC; |
| 7867 | |
| 7868 | vars->phy_flags = PHY_XGXS_FLAG; |
| 7869 | |
| 7870 | bnx2x_xgxs_deassert(params); |
| 7871 | |
| 7872 | /* set bmac loopback */ |
| 7873 | bnx2x_bmac_enable(params, vars, 1); |
| 7874 | |
| 7875 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + params->port*4, 0); |
| 7876 | } |
| 7877 | |
| 7878 | void bnx2x_init_emac_loopback(struct link_params *params, |
| 7879 | struct link_vars *vars) |
| 7880 | { |
| 7881 | struct bnx2x *bp = params->bp; |
| 7882 | vars->link_up = 1; |
| 7883 | vars->line_speed = SPEED_1000; |
| 7884 | vars->duplex = DUPLEX_FULL; |
| 7885 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 7886 | vars->mac_type = MAC_TYPE_EMAC; |
| 7887 | |
| 7888 | vars->phy_flags = PHY_XGXS_FLAG; |
| 7889 | |
| 7890 | bnx2x_xgxs_deassert(params); |
| 7891 | /* set bmac loopback */ |
| 7892 | bnx2x_emac_enable(params, vars, 1); |
| 7893 | bnx2x_emac_program(params, vars); |
| 7894 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + params->port*4, 0); |
| 7895 | } |
| 7896 | |
| 7897 | void bnx2x_init_xgxs_loopback(struct link_params *params, |
| 7898 | struct link_vars *vars) |
| 7899 | { |
| 7900 | struct bnx2x *bp = params->bp; |
| 7901 | vars->link_up = 1; |
| 7902 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 7903 | vars->duplex = DUPLEX_FULL; |
| 7904 | if (params->req_line_speed[0] == SPEED_1000) |
| 7905 | vars->line_speed = SPEED_1000; |
| 7906 | else |
| 7907 | vars->line_speed = SPEED_10000; |
| 7908 | |
| 7909 | |
| 7910 | bnx2x_xgxs_deassert(params); |
| 7911 | bnx2x_link_initialize(params, vars); |
| 7912 | |
| 7913 | if (params->req_line_speed[0] == SPEED_1000) { |
| 7914 | bnx2x_emac_program(params, vars); |
| 7915 | bnx2x_emac_enable(params, vars, 0); |
| 7916 | |
| 7917 | } else |
| 7918 | bnx2x_bmac_enable(params, vars, 0); |
| 7919 | |
| 7920 | |
| 7921 | if (params->loopback_mode == LOOPBACK_XGXS) { |
| 7922 | /* set 10G XGXS loopback */ |
| 7923 | params->phy[INT_PHY].config_loopback( |
| 7924 | ¶ms->phy[INT_PHY], |
| 7925 | params); |
| 7926 | |
| 7927 | } else { |
| 7928 | /* set external phy loopback */ |
| 7929 | u8 phy_index; |
| 7930 | for (phy_index = EXT_PHY1; |
| 7931 | phy_index < params->num_phys; phy_index++) { |
| 7932 | if (params->phy[phy_index].config_loopback) |
| 7933 | params->phy[phy_index].config_loopback( |
| 7934 | ¶ms->phy[phy_index], |
| 7935 | params); |
| 7936 | } |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7937 | } |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 7938 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + params->port*4, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7939 | |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 7940 | bnx2x_set_led(params, vars, LED_MODE_OPER, vars->line_speed); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7941 | } |
| 7942 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 7943 | int bnx2x_phy_init(struct link_params *params, struct link_vars *vars) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7944 | { |
| 7945 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7946 | DP(NETIF_MSG_LINK, "Phy Initialization started\n"); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 7947 | DP(NETIF_MSG_LINK, "(1) req_speed %d, req_flowctrl %d\n", |
| 7948 | params->req_line_speed[0], params->req_flow_ctrl[0]); |
| 7949 | DP(NETIF_MSG_LINK, "(2) req_speed %d, req_flowctrl %d\n", |
| 7950 | params->req_line_speed[1], params->req_flow_ctrl[1]); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7951 | vars->link_status = 0; |
| 7952 | vars->phy_link_up = 0; |
| 7953 | vars->link_up = 0; |
| 7954 | vars->line_speed = 0; |
| 7955 | vars->duplex = DUPLEX_FULL; |
| 7956 | vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; |
| 7957 | vars->mac_type = MAC_TYPE_NONE; |
| 7958 | vars->phy_flags = 0; |
| 7959 | |
| 7960 | /* disable attentions */ |
| 7961 | bnx2x_bits_dis(bp, NIG_REG_MASK_INTERRUPT_PORT0 + params->port*4, |
| 7962 | (NIG_MASK_XGXS0_LINK_STATUS | |
| 7963 | NIG_MASK_XGXS0_LINK10G | |
| 7964 | NIG_MASK_SERDES0_LINK_STATUS | |
| 7965 | NIG_MASK_MI_INT)); |
| 7966 | |
| 7967 | bnx2x_emac_init(params, vars); |
| 7968 | |
| 7969 | if (params->num_phys == 0) { |
| 7970 | DP(NETIF_MSG_LINK, "No phy found for initialization !!\n"); |
| 7971 | return -EINVAL; |
| 7972 | } |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 7973 | set_phy_vars(params, vars); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7974 | |
| 7975 | DP(NETIF_MSG_LINK, "Num of phys on board: %d\n", params->num_phys); |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 7976 | switch (params->loopback_mode) { |
| 7977 | case LOOPBACK_BMAC: |
| 7978 | bnx2x_init_bmac_loopback(params, vars); |
| 7979 | break; |
| 7980 | case LOOPBACK_EMAC: |
| 7981 | bnx2x_init_emac_loopback(params, vars); |
| 7982 | break; |
| 7983 | case LOOPBACK_XGXS: |
| 7984 | case LOOPBACK_EXT_PHY: |
| 7985 | bnx2x_init_xgxs_loopback(params, vars); |
| 7986 | break; |
| 7987 | default: |
| 7988 | /* No loopback */ |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7989 | if (params->switch_cfg == SWITCH_CFG_10G) |
| 7990 | bnx2x_xgxs_deassert(params); |
| 7991 | else |
| 7992 | bnx2x_serdes_deassert(bp, params->port); |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 7993 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7994 | bnx2x_link_initialize(params, vars); |
| 7995 | msleep(30); |
| 7996 | bnx2x_link_int_enable(params); |
Yaniv Rosner | 9045f6b | 2011-05-31 21:28:27 +0000 | [diff] [blame] | 7997 | break; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 7998 | } |
| 7999 | return 0; |
| 8000 | } |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 8001 | |
| 8002 | int bnx2x_link_reset(struct link_params *params, struct link_vars *vars, |
| 8003 | u8 reset_ext_phy) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8004 | { |
| 8005 | struct bnx2x *bp = params->bp; |
Yaniv Rosner | cf1d972 | 2010-11-01 05:32:34 +0000 | [diff] [blame] | 8006 | u8 phy_index, port = params->port, clear_latch_ind = 0; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8007 | DP(NETIF_MSG_LINK, "Resetting the link of port %d\n", port); |
| 8008 | /* disable attentions */ |
| 8009 | vars->link_status = 0; |
| 8010 | bnx2x_update_mng(params, vars->link_status); |
| 8011 | bnx2x_bits_dis(bp, NIG_REG_MASK_INTERRUPT_PORT0 + port*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 | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8016 | |
| 8017 | /* activate nig drain */ |
| 8018 | REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE + port*4, 1); |
| 8019 | |
| 8020 | /* disable nig egress interface */ |
| 8021 | REG_WR(bp, NIG_REG_BMAC0_OUT_EN + port*4, 0); |
| 8022 | REG_WR(bp, NIG_REG_EGRESS_EMAC0_OUT_EN + port*4, 0); |
| 8023 | |
| 8024 | /* Stop BigMac rx */ |
| 8025 | bnx2x_bmac_rx_disable(bp, port); |
| 8026 | |
| 8027 | /* disable emac */ |
| 8028 | REG_WR(bp, NIG_REG_NIG_EMAC0_EN + port*4, 0); |
| 8029 | |
| 8030 | msleep(10); |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 8031 | /* The PHY reset is controlled by GPIO 1 |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8032 | * Hold it as vars low |
| 8033 | */ |
| 8034 | /* clear link led */ |
Yaniv Rosner | 7f02c4a | 2010-09-07 11:41:23 +0000 | [diff] [blame] | 8035 | bnx2x_set_led(params, vars, LED_MODE_OFF, 0); |
| 8036 | |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8037 | if (reset_ext_phy) { |
| 8038 | for (phy_index = EXT_PHY1; phy_index < params->num_phys; |
| 8039 | phy_index++) { |
| 8040 | if (params->phy[phy_index].link_reset) |
| 8041 | params->phy[phy_index].link_reset( |
| 8042 | ¶ms->phy[phy_index], |
| 8043 | params); |
Yaniv Rosner | cf1d972 | 2010-11-01 05:32:34 +0000 | [diff] [blame] | 8044 | if (params->phy[phy_index].flags & |
| 8045 | FLAGS_REARM_LATCH_SIGNAL) |
| 8046 | clear_latch_ind = 1; |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8047 | } |
| 8048 | } |
| 8049 | |
Yaniv Rosner | cf1d972 | 2010-11-01 05:32:34 +0000 | [diff] [blame] | 8050 | if (clear_latch_ind) { |
| 8051 | /* Clear latching indication */ |
| 8052 | bnx2x_rearm_latch_signal(bp, port, 0); |
| 8053 | bnx2x_bits_dis(bp, NIG_REG_LATCH_BC_0 + port*4, |
| 8054 | 1 << NIG_LATCH_BC_ENABLE_MI_INT); |
| 8055 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8056 | if (params->phy[INT_PHY].link_reset) |
| 8057 | params->phy[INT_PHY].link_reset( |
| 8058 | ¶ms->phy[INT_PHY], params); |
| 8059 | /* reset BigMac */ |
| 8060 | REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_CLEAR, |
| 8061 | (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << port)); |
| 8062 | |
| 8063 | /* disable nig ingress interface */ |
| 8064 | REG_WR(bp, NIG_REG_BMAC0_IN_EN + port*4, 0); |
| 8065 | REG_WR(bp, NIG_REG_EMAC0_IN_EN + port*4, 0); |
| 8066 | REG_WR(bp, NIG_REG_BMAC0_OUT_EN + port*4, 0); |
| 8067 | REG_WR(bp, NIG_REG_EGRESS_EMAC0_OUT_EN + port*4, 0); |
| 8068 | vars->link_up = 0; |
| 8069 | return 0; |
| 8070 | } |
| 8071 | |
| 8072 | /****************************************************************************/ |
| 8073 | /* Common function */ |
| 8074 | /****************************************************************************/ |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 8075 | static int bnx2x_8073_common_init_phy(struct bnx2x *bp, |
| 8076 | u32 shmem_base_path[], |
| 8077 | u32 shmem2_base_path[], u8 phy_index, |
| 8078 | u32 chip_id) |
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 | struct bnx2x_phy phy[PORT_MAX]; |
| 8081 | struct bnx2x_phy *phy_blk[PORT_MAX]; |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 8082 | u16 val; |
Yaniv Rosner | c8e64df | 2011-01-30 04:15:00 +0000 | [diff] [blame] | 8083 | s8 port = 0; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 8084 | s8 port_of_path = 0; |
Yaniv Rosner | c8e64df | 2011-01-30 04:15:00 +0000 | [diff] [blame] | 8085 | u32 swap_val, swap_override; |
| 8086 | swap_val = REG_RD(bp, NIG_REG_PORT_SWAP); |
| 8087 | swap_override = REG_RD(bp, NIG_REG_STRAP_OVERRIDE); |
| 8088 | port ^= (swap_val && swap_override); |
| 8089 | bnx2x_ext_phy_hw_reset(bp, port); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 8090 | /* PART1 - Reset both phys */ |
| 8091 | for (port = PORT_MAX - 1; port >= PORT_0; port--) { |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 8092 | u32 shmem_base, shmem2_base; |
| 8093 | /* In E2, same phy is using for port0 of the two paths */ |
| 8094 | if (CHIP_IS_E2(bp)) { |
| 8095 | shmem_base = shmem_base_path[port]; |
| 8096 | shmem2_base = shmem2_base_path[port]; |
| 8097 | port_of_path = 0; |
| 8098 | } else { |
| 8099 | shmem_base = shmem_base_path[0]; |
| 8100 | shmem2_base = shmem2_base_path[0]; |
| 8101 | port_of_path = port; |
| 8102 | } |
| 8103 | |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 8104 | /* Extract the ext phy address for the port */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8105 | if (bnx2x_populate_phy(bp, phy_index, shmem_base, shmem2_base, |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 8106 | port_of_path, &phy[port]) != |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 8107 | 0) { |
| 8108 | DP(NETIF_MSG_LINK, "populate_phy failed\n"); |
| 8109 | return -EINVAL; |
| 8110 | } |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 8111 | /* disable attentions */ |
Yaniv Rosner | 6a71bbe | 2010-11-01 05:32:31 +0000 | [diff] [blame] | 8112 | bnx2x_bits_dis(bp, NIG_REG_MASK_INTERRUPT_PORT0 + |
| 8113 | port_of_path*4, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8114 | (NIG_MASK_XGXS0_LINK_STATUS | |
| 8115 | NIG_MASK_XGXS0_LINK10G | |
| 8116 | NIG_MASK_SERDES0_LINK_STATUS | |
| 8117 | NIG_MASK_MI_INT)); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 8118 | |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 8119 | /* Need to take the phy out of low power mode in order |
| 8120 | to write to access its registers */ |
| 8121 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8122 | MISC_REGISTERS_GPIO_OUTPUT_HIGH, |
| 8123 | port); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 8124 | |
| 8125 | /* Reset the phy */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 8126 | bnx2x_cl45_write(bp, &phy[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8127 | MDIO_PMA_DEVAD, |
| 8128 | MDIO_PMA_REG_CTRL, |
| 8129 | 1<<15); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 8130 | } |
| 8131 | |
| 8132 | /* Add delay of 150ms after reset */ |
| 8133 | msleep(150); |
| 8134 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 8135 | if (phy[PORT_0].addr & 0x1) { |
| 8136 | phy_blk[PORT_0] = &(phy[PORT_1]); |
| 8137 | phy_blk[PORT_1] = &(phy[PORT_0]); |
| 8138 | } else { |
| 8139 | phy_blk[PORT_0] = &(phy[PORT_0]); |
| 8140 | phy_blk[PORT_1] = &(phy[PORT_1]); |
| 8141 | } |
| 8142 | |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 8143 | /* PART2 - Download firmware to both phys */ |
| 8144 | for (port = PORT_MAX - 1; port >= PORT_0; port--) { |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 8145 | if (CHIP_IS_E2(bp)) |
| 8146 | port_of_path = 0; |
| 8147 | else |
| 8148 | port_of_path = port; |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 8149 | |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 8150 | DP(NETIF_MSG_LINK, "Loading spirom for phy address 0x%x\n", |
| 8151 | phy_blk[port]->addr); |
Yaniv Rosner | 5c99274b | 2011-01-18 04:33:36 +0000 | [diff] [blame] | 8152 | if (bnx2x_8073_8727_external_rom_boot(bp, phy_blk[port], |
| 8153 | port_of_path)) |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 8154 | return -EINVAL; |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 8155 | |
| 8156 | /* Only set bit 10 = 1 (Tx power down) */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 8157 | bnx2x_cl45_read(bp, phy_blk[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8158 | MDIO_PMA_DEVAD, |
| 8159 | MDIO_PMA_REG_TX_POWER_DOWN, &val); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 8160 | |
| 8161 | /* Phase1 of TX_POWER_DOWN reset */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 8162 | bnx2x_cl45_write(bp, phy_blk[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8163 | MDIO_PMA_DEVAD, |
| 8164 | MDIO_PMA_REG_TX_POWER_DOWN, |
| 8165 | (val | 1<<10)); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 8166 | } |
| 8167 | |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8168 | /* |
| 8169 | * Toggle Transmitter: Power down and then up with 600ms delay |
| 8170 | * between |
| 8171 | */ |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 8172 | msleep(600); |
| 8173 | |
| 8174 | /* PART3 - complete TX_POWER_DOWN process, and set GPIO2 back to low */ |
| 8175 | for (port = PORT_MAX - 1; port >= PORT_0; port--) { |
Eilon Greenstein | f537225 | 2009-02-12 08:38:30 +0000 | [diff] [blame] | 8176 | /* Phase2 of POWER_DOWN_RESET */ |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 8177 | /* Release bit 10 (Release Tx power down) */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 8178 | bnx2x_cl45_read(bp, phy_blk[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8179 | MDIO_PMA_DEVAD, |
| 8180 | MDIO_PMA_REG_TX_POWER_DOWN, &val); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 8181 | |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 8182 | bnx2x_cl45_write(bp, phy_blk[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8183 | MDIO_PMA_DEVAD, |
| 8184 | MDIO_PMA_REG_TX_POWER_DOWN, (val & (~(1<<10)))); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 8185 | msleep(15); |
| 8186 | |
| 8187 | /* Read modify write the SPI-ROM version select register */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 8188 | bnx2x_cl45_read(bp, phy_blk[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8189 | MDIO_PMA_DEVAD, |
| 8190 | MDIO_PMA_REG_EDC_FFE_MAIN, &val); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 8191 | bnx2x_cl45_write(bp, phy_blk[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8192 | MDIO_PMA_DEVAD, |
| 8193 | MDIO_PMA_REG_EDC_FFE_MAIN, (val | (1<<12))); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 8194 | |
| 8195 | /* set GPIO2 back to LOW */ |
| 8196 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8197 | MISC_REGISTERS_GPIO_OUTPUT_LOW, port); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 8198 | } |
| 8199 | return 0; |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 8200 | } |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 8201 | static int bnx2x_8726_common_init_phy(struct bnx2x *bp, |
| 8202 | u32 shmem_base_path[], |
| 8203 | u32 shmem2_base_path[], u8 phy_index, |
| 8204 | u32 chip_id) |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8205 | { |
| 8206 | u32 val; |
| 8207 | s8 port; |
| 8208 | struct bnx2x_phy phy; |
| 8209 | /* Use port1 because of the static port-swap */ |
| 8210 | /* Enable the module detection interrupt */ |
| 8211 | val = REG_RD(bp, MISC_REG_GPIO_EVENT_EN); |
| 8212 | val |= ((1<<MISC_REGISTERS_GPIO_3)| |
| 8213 | (1<<(MISC_REGISTERS_GPIO_3 + MISC_REGISTERS_GPIO_PORT_SHIFT))); |
| 8214 | REG_WR(bp, MISC_REG_GPIO_EVENT_EN, val); |
| 8215 | |
Yaniv Rosner | 650154b | 2010-11-01 05:32:36 +0000 | [diff] [blame] | 8216 | bnx2x_ext_phy_hw_reset(bp, 0); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8217 | msleep(5); |
| 8218 | for (port = 0; port < PORT_MAX; port++) { |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 8219 | u32 shmem_base, shmem2_base; |
| 8220 | |
| 8221 | /* In E2, same phy is using for port0 of the two paths */ |
| 8222 | if (CHIP_IS_E2(bp)) { |
| 8223 | shmem_base = shmem_base_path[port]; |
| 8224 | shmem2_base = shmem2_base_path[port]; |
| 8225 | } else { |
| 8226 | shmem_base = shmem_base_path[0]; |
| 8227 | shmem2_base = shmem2_base_path[0]; |
| 8228 | } |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8229 | /* Extract the ext phy address for the port */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8230 | if (bnx2x_populate_phy(bp, phy_index, shmem_base, shmem2_base, |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8231 | port, &phy) != |
| 8232 | 0) { |
| 8233 | DP(NETIF_MSG_LINK, "populate phy failed\n"); |
| 8234 | return -EINVAL; |
| 8235 | } |
| 8236 | |
| 8237 | /* Reset phy*/ |
| 8238 | bnx2x_cl45_write(bp, &phy, |
| 8239 | MDIO_PMA_DEVAD, MDIO_PMA_REG_GEN_CTRL, 0x0001); |
| 8240 | |
| 8241 | |
| 8242 | /* Set fault module detected LED on */ |
| 8243 | bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_0, |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8244 | MISC_REGISTERS_GPIO_HIGH, |
| 8245 | port); |
Yaniv Rosner | de6eae1 | 2010-09-07 11:41:13 +0000 | [diff] [blame] | 8246 | } |
| 8247 | |
| 8248 | return 0; |
| 8249 | } |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8250 | static void bnx2x_get_ext_phy_reset_gpio(struct bnx2x *bp, u32 shmem_base, |
| 8251 | u8 *io_gpio, u8 *io_port) |
| 8252 | { |
| 8253 | |
| 8254 | u32 phy_gpio_reset = REG_RD(bp, shmem_base + |
| 8255 | offsetof(struct shmem_region, |
| 8256 | dev_info.port_hw_config[PORT_0].default_cfg)); |
| 8257 | switch (phy_gpio_reset) { |
| 8258 | case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO0_P0: |
| 8259 | *io_gpio = 0; |
| 8260 | *io_port = 0; |
| 8261 | break; |
| 8262 | case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO1_P0: |
| 8263 | *io_gpio = 1; |
| 8264 | *io_port = 0; |
| 8265 | break; |
| 8266 | case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO2_P0: |
| 8267 | *io_gpio = 2; |
| 8268 | *io_port = 0; |
| 8269 | break; |
| 8270 | case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO3_P0: |
| 8271 | *io_gpio = 3; |
| 8272 | *io_port = 0; |
| 8273 | break; |
| 8274 | case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO0_P1: |
| 8275 | *io_gpio = 0; |
| 8276 | *io_port = 1; |
| 8277 | break; |
| 8278 | case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO1_P1: |
| 8279 | *io_gpio = 1; |
| 8280 | *io_port = 1; |
| 8281 | break; |
| 8282 | case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO2_P1: |
| 8283 | *io_gpio = 2; |
| 8284 | *io_port = 1; |
| 8285 | break; |
| 8286 | case PORT_HW_CFG_EXT_PHY_GPIO_RST_GPIO3_P1: |
| 8287 | *io_gpio = 3; |
| 8288 | *io_port = 1; |
| 8289 | break; |
| 8290 | default: |
| 8291 | /* Don't override the io_gpio and io_port */ |
| 8292 | break; |
| 8293 | } |
| 8294 | } |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 8295 | |
| 8296 | static int bnx2x_8727_common_init_phy(struct bnx2x *bp, |
| 8297 | u32 shmem_base_path[], |
| 8298 | u32 shmem2_base_path[], u8 phy_index, |
| 8299 | u32 chip_id) |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 8300 | { |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8301 | s8 port, reset_gpio; |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 8302 | u32 swap_val, swap_override; |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 8303 | struct bnx2x_phy phy[PORT_MAX]; |
| 8304 | struct bnx2x_phy *phy_blk[PORT_MAX]; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 8305 | s8 port_of_path; |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8306 | swap_val = REG_RD(bp, NIG_REG_PORT_SWAP); |
| 8307 | swap_override = REG_RD(bp, NIG_REG_STRAP_OVERRIDE); |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 8308 | |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8309 | reset_gpio = MISC_REGISTERS_GPIO_1; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8310 | port = 1; |
| 8311 | |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8312 | /* |
| 8313 | * Retrieve the reset gpio/port which control the reset. |
| 8314 | * Default is GPIO1, PORT1 |
| 8315 | */ |
| 8316 | bnx2x_get_ext_phy_reset_gpio(bp, shmem_base_path[0], |
| 8317 | (u8 *)&reset_gpio, (u8 *)&port); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8318 | |
| 8319 | /* Calculate the port based on port swap */ |
| 8320 | port ^= (swap_val && swap_override); |
| 8321 | |
Yaniv Rosner | a8db5b4 | 2011-01-31 04:22:28 +0000 | [diff] [blame] | 8322 | /* Initiate PHY reset*/ |
| 8323 | bnx2x_set_gpio(bp, reset_gpio, MISC_REGISTERS_GPIO_OUTPUT_LOW, |
| 8324 | port); |
| 8325 | msleep(1); |
| 8326 | bnx2x_set_gpio(bp, reset_gpio, MISC_REGISTERS_GPIO_OUTPUT_HIGH, |
| 8327 | port); |
| 8328 | |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 8329 | msleep(5); |
| 8330 | |
| 8331 | /* PART1 - Reset both phys */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8332 | for (port = PORT_MAX - 1; port >= PORT_0; port--) { |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 8333 | u32 shmem_base, shmem2_base; |
| 8334 | |
| 8335 | /* In E2, same phy is using for port0 of the two paths */ |
| 8336 | if (CHIP_IS_E2(bp)) { |
| 8337 | shmem_base = shmem_base_path[port]; |
| 8338 | shmem2_base = shmem2_base_path[port]; |
| 8339 | port_of_path = 0; |
| 8340 | } else { |
| 8341 | shmem_base = shmem_base_path[0]; |
| 8342 | shmem2_base = shmem2_base_path[0]; |
| 8343 | port_of_path = port; |
| 8344 | } |
| 8345 | |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 8346 | /* Extract the ext phy address for the port */ |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8347 | if (bnx2x_populate_phy(bp, phy_index, shmem_base, shmem2_base, |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 8348 | port_of_path, &phy[port]) != |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 8349 | 0) { |
| 8350 | DP(NETIF_MSG_LINK, "populate phy failed\n"); |
| 8351 | return -EINVAL; |
| 8352 | } |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 8353 | /* disable attentions */ |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 8354 | bnx2x_bits_dis(bp, NIG_REG_MASK_INTERRUPT_PORT0 + |
| 8355 | port_of_path*4, |
| 8356 | (NIG_MASK_XGXS0_LINK_STATUS | |
| 8357 | NIG_MASK_XGXS0_LINK10G | |
| 8358 | NIG_MASK_SERDES0_LINK_STATUS | |
| 8359 | NIG_MASK_MI_INT)); |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 8360 | |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 8361 | |
| 8362 | /* Reset the phy */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 8363 | bnx2x_cl45_write(bp, &phy[port], |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8364 | MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 1<<15); |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 8365 | } |
| 8366 | |
| 8367 | /* Add delay of 150ms after reset */ |
| 8368 | msleep(150); |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 8369 | if (phy[PORT_0].addr & 0x1) { |
| 8370 | phy_blk[PORT_0] = &(phy[PORT_1]); |
| 8371 | phy_blk[PORT_1] = &(phy[PORT_0]); |
| 8372 | } else { |
| 8373 | phy_blk[PORT_0] = &(phy[PORT_0]); |
| 8374 | phy_blk[PORT_1] = &(phy[PORT_1]); |
| 8375 | } |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 8376 | /* PART2 - Download firmware to both phys */ |
Yaniv Rosner | e10bc84 | 2010-09-07 11:40:50 +0000 | [diff] [blame] | 8377 | for (port = PORT_MAX - 1; port >= PORT_0; port--) { |
Yaniv Rosner | cd88cce | 2011-01-31 04:21:34 +0000 | [diff] [blame] | 8378 | if (CHIP_IS_E2(bp)) |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 8379 | port_of_path = 0; |
| 8380 | else |
| 8381 | port_of_path = port; |
| 8382 | DP(NETIF_MSG_LINK, "Loading spirom for phy address 0x%x\n", |
| 8383 | phy_blk[port]->addr); |
Yaniv Rosner | 5c99274b | 2011-01-18 04:33:36 +0000 | [diff] [blame] | 8384 | if (bnx2x_8073_8727_external_rom_boot(bp, phy_blk[port], |
| 8385 | port_of_path)) |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 8386 | return -EINVAL; |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 8387 | |
Yaniv Rosner | 5c99274b | 2011-01-18 04:33:36 +0000 | [diff] [blame] | 8388 | } |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 8389 | return 0; |
| 8390 | } |
| 8391 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 8392 | static int bnx2x_ext_phy_common_init(struct bnx2x *bp, u32 shmem_base_path[], |
| 8393 | u32 shmem2_base_path[], u8 phy_index, |
| 8394 | u32 ext_phy_type, u32 chip_id) |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 8395 | { |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 8396 | int rc = 0; |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 8397 | |
| 8398 | switch (ext_phy_type) { |
| 8399 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073: |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 8400 | rc = bnx2x_8073_common_init_phy(bp, shmem_base_path, |
| 8401 | shmem2_base_path, |
| 8402 | phy_index, chip_id); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 8403 | break; |
Yaniv Rosner | e4d78f1 | 2011-05-31 21:25:55 +0000 | [diff] [blame] | 8404 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8722: |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 8405 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727: |
| 8406 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727_NOC: |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 8407 | rc = bnx2x_8727_common_init_phy(bp, shmem_base_path, |
| 8408 | shmem2_base_path, |
| 8409 | phy_index, chip_id); |
Eilon Greenstein | 4d295db | 2009-07-21 05:47:47 +0000 | [diff] [blame] | 8410 | break; |
| 8411 | |
Eilon Greenstein | 589abe3 | 2009-02-12 08:36:55 +0000 | [diff] [blame] | 8412 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726: |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8413 | /* |
| 8414 | * GPIO1 affects both ports, so there's need to pull |
| 8415 | * it for single port alone |
| 8416 | */ |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 8417 | rc = bnx2x_8726_common_init_phy(bp, shmem_base_path, |
| 8418 | shmem2_base_path, |
| 8419 | phy_index, chip_id); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8420 | break; |
| 8421 | case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_FAILURE: |
| 8422 | rc = -EINVAL; |
Yaniv Rosner | 4f60dab | 2009-11-05 19:18:23 +0200 | [diff] [blame] | 8423 | break; |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 8424 | default: |
| 8425 | DP(NETIF_MSG_LINK, |
Yaniv Rosner | 2cf7acf | 2011-01-31 04:21:55 +0000 | [diff] [blame] | 8426 | "ext_phy 0x%x common init not required\n", |
| 8427 | ext_phy_type); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 8428 | break; |
| 8429 | } |
| 8430 | |
Yaniv Rosner | 6d870c3 | 2011-01-31 04:22:20 +0000 | [diff] [blame] | 8431 | if (rc != 0) |
| 8432 | netdev_err(bp->dev, "Warning: PHY was not initialized," |
| 8433 | " Port %d\n", |
| 8434 | 0); |
Yaniv Rosner | 6bbca91 | 2008-08-13 15:57:28 -0700 | [diff] [blame] | 8435 | return rc; |
| 8436 | } |
| 8437 | |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 8438 | int bnx2x_common_init_phy(struct bnx2x *bp, u32 shmem_base_path[], |
| 8439 | u32 shmem2_base_path[], u32 chip_id) |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8440 | { |
Yaniv Rosner | fcf5b65 | 2011-05-31 21:26:28 +0000 | [diff] [blame] | 8441 | int rc = 0; |
Yaniv Rosner | b21a342 | 2011-01-18 04:33:24 +0000 | [diff] [blame] | 8442 | u32 phy_ver; |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8443 | u8 phy_index; |
| 8444 | u32 ext_phy_type, ext_phy_config; |
| 8445 | DP(NETIF_MSG_LINK, "Begin common phy init\n"); |
Yaniv Rosner | d90d96b | 2010-09-07 11:41:04 +0000 | [diff] [blame] | 8446 | |
Yaniv Rosner | b21a342 | 2011-01-18 04:33:24 +0000 | [diff] [blame] | 8447 | /* Check if common init was already done */ |
| 8448 | phy_ver = REG_RD(bp, shmem_base_path[0] + |
| 8449 | offsetof(struct shmem_region, |
| 8450 | port_mb[PORT_0].ext_phy_fw_version)); |
| 8451 | if (phy_ver) { |
| 8452 | DP(NETIF_MSG_LINK, "Not doing common init; phy ver is 0x%x\n", |
| 8453 | phy_ver); |
| 8454 | return 0; |
| 8455 | } |
| 8456 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8457 | /* Read the ext_phy_type for arbitrary port(0) */ |
| 8458 | for (phy_index = EXT_PHY1; phy_index < MAX_PHYS; |
| 8459 | phy_index++) { |
| 8460 | ext_phy_config = bnx2x_get_ext_phy_config(bp, |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 8461 | shmem_base_path[0], |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8462 | phy_index, 0); |
| 8463 | ext_phy_type = XGXS_EXT_PHY_TYPE(ext_phy_config); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 8464 | rc |= bnx2x_ext_phy_common_init(bp, shmem_base_path, |
| 8465 | shmem2_base_path, |
| 8466 | phy_index, ext_phy_type, |
| 8467 | chip_id); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8468 | } |
| 8469 | return rc; |
| 8470 | } |
| 8471 | |
| 8472 | 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] | 8473 | { |
| 8474 | u8 phy_index; |
| 8475 | struct bnx2x_phy phy; |
| 8476 | for (phy_index = INT_PHY; phy_index < MAX_PHYS; |
| 8477 | phy_index++) { |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8478 | if (bnx2x_populate_phy(bp, phy_index, shmem_base, shmem2_base, |
Yaniv Rosner | d90d96b | 2010-09-07 11:41:04 +0000 | [diff] [blame] | 8479 | 0, &phy) != 0) { |
| 8480 | DP(NETIF_MSG_LINK, "populate phy failed\n"); |
| 8481 | return 0; |
| 8482 | } |
| 8483 | |
| 8484 | if (phy.flags & FLAGS_HW_LOCK_REQUIRED) |
| 8485 | return 1; |
| 8486 | } |
| 8487 | return 0; |
| 8488 | } |
| 8489 | |
| 8490 | u8 bnx2x_fan_failure_det_req(struct bnx2x *bp, |
| 8491 | u32 shmem_base, |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8492 | u32 shmem2_base, |
Yaniv Rosner | d90d96b | 2010-09-07 11:41:04 +0000 | [diff] [blame] | 8493 | u8 port) |
| 8494 | { |
| 8495 | u8 phy_index, fan_failure_det_req = 0; |
| 8496 | struct bnx2x_phy phy; |
| 8497 | for (phy_index = EXT_PHY1; phy_index < MAX_PHYS; |
| 8498 | phy_index++) { |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 8499 | if (bnx2x_populate_phy(bp, phy_index, shmem_base, shmem2_base, |
Yaniv Rosner | d90d96b | 2010-09-07 11:41:04 +0000 | [diff] [blame] | 8500 | port, &phy) |
| 8501 | != 0) { |
| 8502 | DP(NETIF_MSG_LINK, "populate phy failed\n"); |
| 8503 | return 0; |
| 8504 | } |
| 8505 | fan_failure_det_req |= (phy.flags & |
| 8506 | FLAGS_FAN_FAILURE_DET_REQ); |
| 8507 | } |
| 8508 | return fan_failure_det_req; |
| 8509 | } |
| 8510 | |
| 8511 | void bnx2x_hw_reset_phy(struct link_params *params) |
| 8512 | { |
| 8513 | u8 phy_index; |
| 8514 | for (phy_index = EXT_PHY1; phy_index < MAX_PHYS; |
| 8515 | phy_index++) { |
| 8516 | if (params->phy[phy_index].hw_reset) { |
| 8517 | params->phy[phy_index].hw_reset( |
| 8518 | ¶ms->phy[phy_index], |
| 8519 | params); |
| 8520 | params->phy[phy_index] = phy_null; |
| 8521 | } |
| 8522 | } |
| 8523 | } |
Yaniv Rosner | 020c7e3 | 2011-05-31 21:28:43 +0000 | [diff] [blame] | 8524 | |
| 8525 | void bnx2x_init_mod_abs_int(struct bnx2x *bp, struct link_vars *vars, |
| 8526 | u32 chip_id, u32 shmem_base, u32 shmem2_base, |
| 8527 | u8 port) |
| 8528 | { |
| 8529 | u8 gpio_num = 0xff, gpio_port = 0xff, phy_index; |
| 8530 | u32 val; |
| 8531 | u32 offset, aeu_mask, swap_val, swap_override, sync_offset; |
| 8532 | |
| 8533 | { |
| 8534 | struct bnx2x_phy phy; |
| 8535 | for (phy_index = EXT_PHY1; phy_index < MAX_PHYS; |
| 8536 | phy_index++) { |
| 8537 | if (bnx2x_populate_phy(bp, phy_index, shmem_base, |
| 8538 | shmem2_base, port, &phy) |
| 8539 | != 0) { |
| 8540 | DP(NETIF_MSG_LINK, "populate phy failed\n"); |
| 8541 | return; |
| 8542 | } |
| 8543 | if (phy.type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726) { |
| 8544 | gpio_num = MISC_REGISTERS_GPIO_3; |
| 8545 | gpio_port = port; |
| 8546 | break; |
| 8547 | } |
| 8548 | } |
| 8549 | } |
| 8550 | |
| 8551 | if (gpio_num == 0xff) |
| 8552 | return; |
| 8553 | |
| 8554 | /* Set GPIO3 to trigger SFP+ module insertion/removal */ |
| 8555 | bnx2x_set_gpio(bp, gpio_num, MISC_REGISTERS_GPIO_INPUT_HI_Z, gpio_port); |
| 8556 | |
| 8557 | swap_val = REG_RD(bp, NIG_REG_PORT_SWAP); |
| 8558 | swap_override = REG_RD(bp, NIG_REG_STRAP_OVERRIDE); |
| 8559 | gpio_port ^= (swap_val && swap_override); |
| 8560 | |
| 8561 | vars->aeu_int_mask = AEU_INPUTS_ATTN_BITS_GPIO0_FUNCTION_0 << |
| 8562 | (gpio_num + (gpio_port << 2)); |
| 8563 | |
| 8564 | sync_offset = shmem_base + |
| 8565 | offsetof(struct shmem_region, |
| 8566 | dev_info.port_hw_config[port].aeu_int_mask); |
| 8567 | REG_WR(bp, sync_offset, vars->aeu_int_mask); |
| 8568 | |
| 8569 | DP(NETIF_MSG_LINK, "Setting MOD_ABS (GPIO%d_P%d) AEU to 0x%x\n", |
| 8570 | gpio_num, gpio_port, vars->aeu_int_mask); |
| 8571 | |
| 8572 | if (port == 0) |
| 8573 | offset = MISC_REG_AEU_ENABLE1_FUNC_0_OUT_0; |
| 8574 | else |
| 8575 | offset = MISC_REG_AEU_ENABLE1_FUNC_1_OUT_0; |
| 8576 | |
| 8577 | /* Open appropriate AEU for interrupts */ |
| 8578 | aeu_mask = REG_RD(bp, offset); |
| 8579 | aeu_mask |= vars->aeu_int_mask; |
| 8580 | REG_WR(bp, offset, aeu_mask); |
| 8581 | |
| 8582 | /* Enable the GPIO to trigger interrupt */ |
| 8583 | val = REG_RD(bp, MISC_REG_GPIO_EVENT_EN); |
| 8584 | val |= 1 << (gpio_num + (gpio_port << 2)); |
| 8585 | REG_WR(bp, MISC_REG_GPIO_EVENT_EN, val); |
| 8586 | } |