Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1 | /**************************************************************************** |
Ben Hutchings | 177dfcd | 2008-12-12 21:50:08 -0800 | [diff] [blame] | 2 | * Driver for Solarflare Solarstorm network controllers and boards |
Ben Hutchings | 906bb26 | 2009-11-29 15:16:19 +0000 | [diff] [blame] | 3 | * Copyright 2007-2009 Solarflare Communications Inc. |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify it |
| 6 | * under the terms of the GNU General Public License version 2 as published |
| 7 | * by the Free Software Foundation, incorporated herein by reference. |
| 8 | */ |
| 9 | |
| 10 | #include <linux/delay.h> |
Herbert Xu | da3bc07 | 2009-01-18 21:50:16 -0800 | [diff] [blame] | 11 | #include <linux/rtnetlink.h> |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 12 | #include <linux/seq_file.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 13 | #include <linux/slab.h> |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 14 | #include "efx.h" |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 15 | #include "mdio_10g.h" |
Ben Hutchings | 744093c | 2009-11-29 15:12:08 +0000 | [diff] [blame] | 16 | #include "nic.h" |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 17 | #include "phy.h" |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 18 | #include "regs.h" |
Ben Hutchings | e6fa2eb | 2008-12-12 22:00:17 -0800 | [diff] [blame] | 19 | #include "workarounds.h" |
| 20 | #include "selftest.h" |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 21 | |
Ben Hutchings | 8fbca79 | 2010-09-22 10:00:11 +0000 | [diff] [blame] | 22 | /* We expect these MMDs to be in the package. */ |
Ben Hutchings | 68e7f45 | 2009-04-29 08:05:08 +0000 | [diff] [blame] | 23 | #define TENXPRESS_REQUIRED_DEVS (MDIO_DEVS_PMAPMD | \ |
| 24 | MDIO_DEVS_PCS | \ |
| 25 | MDIO_DEVS_PHYXS | \ |
| 26 | MDIO_DEVS_AN) |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 27 | |
Ben Hutchings | e6fa2eb | 2008-12-12 22:00:17 -0800 | [diff] [blame] | 28 | #define SFX7101_LOOPBACKS ((1 << LOOPBACK_PHYXS) | \ |
| 29 | (1 << LOOPBACK_PCS) | \ |
| 30 | (1 << LOOPBACK_PMAPMD) | \ |
Ben Hutchings | e58f69f | 2009-11-29 15:08:41 +0000 | [diff] [blame] | 31 | (1 << LOOPBACK_PHYXS_WS)) |
Ben Hutchings | e6fa2eb | 2008-12-12 22:00:17 -0800 | [diff] [blame] | 32 | |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 33 | /* We complain if we fail to see the link partner as 10G capable this many |
| 34 | * times in a row (must be > 1 as sampling the autoneg. registers is racy) |
| 35 | */ |
| 36 | #define MAX_BAD_LP_TRIES (5) |
| 37 | |
| 38 | /* Extended control register */ |
Ben Hutchings | e6fa2eb | 2008-12-12 22:00:17 -0800 | [diff] [blame] | 39 | #define PMA_PMD_XCONTROL_REG 49152 |
| 40 | #define PMA_PMD_EXT_GMII_EN_LBN 1 |
| 41 | #define PMA_PMD_EXT_GMII_EN_WIDTH 1 |
| 42 | #define PMA_PMD_EXT_CLK_OUT_LBN 2 |
| 43 | #define PMA_PMD_EXT_CLK_OUT_WIDTH 1 |
Ben Hutchings | 8fbca79 | 2010-09-22 10:00:11 +0000 | [diff] [blame] | 44 | #define PMA_PMD_LNPGA_POWERDOWN_LBN 8 |
Ben Hutchings | e6fa2eb | 2008-12-12 22:00:17 -0800 | [diff] [blame] | 45 | #define PMA_PMD_LNPGA_POWERDOWN_WIDTH 1 |
Ben Hutchings | e6fa2eb | 2008-12-12 22:00:17 -0800 | [diff] [blame] | 46 | #define PMA_PMD_EXT_CLK312_WIDTH 1 |
| 47 | #define PMA_PMD_EXT_LPOWER_LBN 12 |
| 48 | #define PMA_PMD_EXT_LPOWER_WIDTH 1 |
Steve Hodgson | 869b5b3 | 2009-01-29 17:48:10 +0000 | [diff] [blame] | 49 | #define PMA_PMD_EXT_ROBUST_LBN 14 |
| 50 | #define PMA_PMD_EXT_ROBUST_WIDTH 1 |
Ben Hutchings | e6fa2eb | 2008-12-12 22:00:17 -0800 | [diff] [blame] | 51 | #define PMA_PMD_EXT_SSR_LBN 15 |
| 52 | #define PMA_PMD_EXT_SSR_WIDTH 1 |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 53 | |
| 54 | /* extended status register */ |
Ben Hutchings | e6fa2eb | 2008-12-12 22:00:17 -0800 | [diff] [blame] | 55 | #define PMA_PMD_XSTATUS_REG 49153 |
Ben Hutchings | e762cd7 | 2009-06-10 05:30:05 +0000 | [diff] [blame] | 56 | #define PMA_PMD_XSTAT_MDIX_LBN 14 |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 57 | #define PMA_PMD_XSTAT_FLP_LBN (12) |
| 58 | |
| 59 | /* LED control register */ |
Ben Hutchings | e6fa2eb | 2008-12-12 22:00:17 -0800 | [diff] [blame] | 60 | #define PMA_PMD_LED_CTRL_REG 49159 |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 61 | #define PMA_PMA_LED_ACTIVITY_LBN (3) |
| 62 | |
| 63 | /* LED function override register */ |
Ben Hutchings | e6fa2eb | 2008-12-12 22:00:17 -0800 | [diff] [blame] | 64 | #define PMA_PMD_LED_OVERR_REG 49161 |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 65 | /* Bit positions for different LEDs (there are more but not wired on SFE4001)*/ |
| 66 | #define PMA_PMD_LED_LINK_LBN (0) |
| 67 | #define PMA_PMD_LED_SPEED_LBN (2) |
| 68 | #define PMA_PMD_LED_TX_LBN (4) |
| 69 | #define PMA_PMD_LED_RX_LBN (6) |
| 70 | /* Override settings */ |
| 71 | #define PMA_PMD_LED_AUTO (0) /* H/W control */ |
| 72 | #define PMA_PMD_LED_ON (1) |
| 73 | #define PMA_PMD_LED_OFF (2) |
| 74 | #define PMA_PMD_LED_FLASH (3) |
Ben Hutchings | 04cc8ca | 2008-12-12 21:50:46 -0800 | [diff] [blame] | 75 | #define PMA_PMD_LED_MASK 3 |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 76 | /* All LEDs under hardware control */ |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 77 | /* Green and Amber under hardware control, Red off */ |
Ben Hutchings | dcf477b | 2009-11-23 16:02:49 +0000 | [diff] [blame] | 78 | #define SFX7101_PMA_PMD_LED_DEFAULT (PMA_PMD_LED_OFF << PMA_PMD_LED_RX_LBN) |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 79 | |
Ben Hutchings | e6fa2eb | 2008-12-12 22:00:17 -0800 | [diff] [blame] | 80 | #define PMA_PMD_SPEED_ENABLE_REG 49192 |
| 81 | #define PMA_PMD_100TX_ADV_LBN 1 |
| 82 | #define PMA_PMD_100TX_ADV_WIDTH 1 |
| 83 | #define PMA_PMD_1000T_ADV_LBN 2 |
| 84 | #define PMA_PMD_1000T_ADV_WIDTH 1 |
| 85 | #define PMA_PMD_10000T_ADV_LBN 3 |
| 86 | #define PMA_PMD_10000T_ADV_WIDTH 1 |
| 87 | #define PMA_PMD_SPEED_LBN 4 |
| 88 | #define PMA_PMD_SPEED_WIDTH 4 |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 89 | |
Ben Hutchings | 8fbca79 | 2010-09-22 10:00:11 +0000 | [diff] [blame] | 90 | /* Misc register defines */ |
Ben Hutchings | e6fa2eb | 2008-12-12 22:00:17 -0800 | [diff] [blame] | 91 | #define PCS_CLOCK_CTRL_REG 55297 |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 92 | #define PLL312_RST_N_LBN 2 |
| 93 | |
Ben Hutchings | e6fa2eb | 2008-12-12 22:00:17 -0800 | [diff] [blame] | 94 | #define PCS_SOFT_RST2_REG 55302 |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 95 | #define SERDES_RST_N_LBN 13 |
| 96 | #define XGXS_RST_N_LBN 12 |
| 97 | |
Ben Hutchings | e6fa2eb | 2008-12-12 22:00:17 -0800 | [diff] [blame] | 98 | #define PCS_TEST_SELECT_REG 55303 /* PRM 10.5.8 */ |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 99 | #define CLK312_EN_LBN 3 |
| 100 | |
Ben Hutchings | 3273c2e | 2008-05-07 13:36:19 +0100 | [diff] [blame] | 101 | /* PHYXS registers */ |
Ben Hutchings | e6fa2eb | 2008-12-12 22:00:17 -0800 | [diff] [blame] | 102 | #define PHYXS_XCONTROL_REG 49152 |
| 103 | #define PHYXS_RESET_LBN 15 |
| 104 | #define PHYXS_RESET_WIDTH 1 |
| 105 | |
Ben Hutchings | 3273c2e | 2008-05-07 13:36:19 +0100 | [diff] [blame] | 106 | #define PHYXS_TEST1 (49162) |
| 107 | #define LOOPBACK_NEAR_LBN (8) |
| 108 | #define LOOPBACK_NEAR_WIDTH (1) |
| 109 | |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 110 | /* Boot status register */ |
Ben Hutchings | 190dbcf | 2009-02-27 13:06:45 +0000 | [diff] [blame] | 111 | #define PCS_BOOT_STATUS_REG 53248 |
| 112 | #define PCS_BOOT_FATAL_ERROR_LBN 0 |
| 113 | #define PCS_BOOT_PROGRESS_LBN 1 |
| 114 | #define PCS_BOOT_PROGRESS_WIDTH 2 |
| 115 | #define PCS_BOOT_PROGRESS_INIT 0 |
| 116 | #define PCS_BOOT_PROGRESS_WAIT_MDIO 1 |
| 117 | #define PCS_BOOT_PROGRESS_CHECKSUM 2 |
| 118 | #define PCS_BOOT_PROGRESS_JUMP 3 |
| 119 | #define PCS_BOOT_DOWNLOAD_WAIT_LBN 3 |
| 120 | #define PCS_BOOT_CODE_STARTED_LBN 4 |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 121 | |
Ben Hutchings | e6fa2eb | 2008-12-12 22:00:17 -0800 | [diff] [blame] | 122 | /* 100M/1G PHY registers */ |
| 123 | #define GPHY_XCONTROL_REG 49152 |
| 124 | #define GPHY_ISOLATE_LBN 10 |
| 125 | #define GPHY_ISOLATE_WIDTH 1 |
| 126 | #define GPHY_DUPLEX_LBN 8 |
| 127 | #define GPHY_DUPLEX_WIDTH 1 |
| 128 | #define GPHY_LOOPBACK_NEAR_LBN 14 |
| 129 | #define GPHY_LOOPBACK_NEAR_WIDTH 1 |
| 130 | |
| 131 | #define C22EXT_STATUS_REG 49153 |
| 132 | #define C22EXT_STATUS_LINK_LBN 2 |
| 133 | #define C22EXT_STATUS_LINK_WIDTH 1 |
| 134 | |
Ben Hutchings | af4ad9b | 2009-01-29 17:59:37 +0000 | [diff] [blame] | 135 | #define C22EXT_MSTSLV_CTRL 49161 |
| 136 | #define C22EXT_MSTSLV_CTRL_ADV_1000_HD_LBN 8 |
| 137 | #define C22EXT_MSTSLV_CTRL_ADV_1000_FD_LBN 9 |
| 138 | |
| 139 | #define C22EXT_MSTSLV_STATUS 49162 |
| 140 | #define C22EXT_MSTSLV_STATUS_LP_1000_HD_LBN 10 |
| 141 | #define C22EXT_MSTSLV_STATUS_LP_1000_FD_LBN 11 |
Ben Hutchings | e6fa2eb | 2008-12-12 22:00:17 -0800 | [diff] [blame] | 142 | |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 143 | /* Time to wait between powering down the LNPGA and turning off the power |
| 144 | * rails */ |
| 145 | #define LNPGA_PDOWN_WAIT (HZ / 5) |
| 146 | |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 147 | struct tenxpress_phy_data { |
Ben Hutchings | 3273c2e | 2008-05-07 13:36:19 +0100 | [diff] [blame] | 148 | enum efx_loopback_mode loopback_mode; |
Ben Hutchings | f8b87c1 | 2008-09-01 12:48:17 +0100 | [diff] [blame] | 149 | enum efx_phy_mode phy_mode; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 150 | int bad_lp_tries; |
| 151 | }; |
| 152 | |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 153 | static int tenxpress_init(struct efx_nic *efx) |
| 154 | { |
Ben Hutchings | 8fbca79 | 2010-09-22 10:00:11 +0000 | [diff] [blame] | 155 | /* Enable 312.5 MHz clock */ |
| 156 | efx_mdio_write(efx, MDIO_MMD_PCS, PCS_TEST_SELECT_REG, |
| 157 | 1 << CLK312_EN_LBN); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 158 | |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 159 | /* Set the LEDs up as: Green = Link, Amber = Link/Act, Red = Off */ |
Ben Hutchings | 8fbca79 | 2010-09-22 10:00:11 +0000 | [diff] [blame] | 160 | efx_mdio_set_flag(efx, MDIO_MMD_PMAPMD, PMA_PMD_LED_CTRL_REG, |
| 161 | 1 << PMA_PMA_LED_ACTIVITY_LBN, true); |
| 162 | efx_mdio_write(efx, MDIO_MMD_PMAPMD, PMA_PMD_LED_OVERR_REG, |
| 163 | SFX7101_PMA_PMD_LED_DEFAULT); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 164 | |
Ben Hutchings | 190dbcf | 2009-02-27 13:06:45 +0000 | [diff] [blame] | 165 | return 0; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 166 | } |
| 167 | |
Steve Hodgson | ff3b00a | 2009-12-23 13:46:36 +0000 | [diff] [blame] | 168 | static int tenxpress_phy_probe(struct efx_nic *efx) |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 169 | { |
| 170 | struct tenxpress_phy_data *phy_data; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 171 | |
Steve Hodgson | ff3b00a | 2009-12-23 13:46:36 +0000 | [diff] [blame] | 172 | /* Allocate phy private storage */ |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 173 | phy_data = kzalloc(sizeof(*phy_data), GFP_KERNEL); |
Ben Hutchings | 9b7bfc4 | 2008-05-16 21:20:20 +0100 | [diff] [blame] | 174 | if (!phy_data) |
| 175 | return -ENOMEM; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 176 | efx->phy_data = phy_data; |
Ben Hutchings | f8b87c1 | 2008-09-01 12:48:17 +0100 | [diff] [blame] | 177 | phy_data->phy_mode = efx->phy_mode; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 178 | |
Ben Hutchings | 8fbca79 | 2010-09-22 10:00:11 +0000 | [diff] [blame] | 179 | efx->mdio.mmds = TENXPRESS_REQUIRED_DEVS; |
| 180 | efx->mdio.mode_support = MDIO_SUPPORTS_C45; |
Steve Hodgson | ff3b00a | 2009-12-23 13:46:36 +0000 | [diff] [blame] | 181 | |
Ben Hutchings | 8fbca79 | 2010-09-22 10:00:11 +0000 | [diff] [blame] | 182 | efx->loopback_modes = SFX7101_LOOPBACKS | FALCON_XMAC_LOOPBACKS; |
Steve Hodgson | ff3b00a | 2009-12-23 13:46:36 +0000 | [diff] [blame] | 183 | |
Ben Hutchings | 8fbca79 | 2010-09-22 10:00:11 +0000 | [diff] [blame] | 184 | efx->link_advertising = (ADVERTISED_TP | ADVERTISED_Autoneg | |
| 185 | ADVERTISED_10000baseT_Full); |
Steve Hodgson | ff3b00a | 2009-12-23 13:46:36 +0000 | [diff] [blame] | 186 | |
| 187 | return 0; |
Steve Hodgson | ff3b00a | 2009-12-23 13:46:36 +0000 | [diff] [blame] | 188 | } |
| 189 | |
| 190 | static int tenxpress_phy_init(struct efx_nic *efx) |
| 191 | { |
| 192 | int rc; |
| 193 | |
| 194 | falcon_board(efx)->type->init_phy(efx); |
| 195 | |
Ben Hutchings | e6fa2eb | 2008-12-12 22:00:17 -0800 | [diff] [blame] | 196 | if (!(efx->phy_mode & PHY_MODE_SPECIAL)) { |
Ben Hutchings | 68e7f45 | 2009-04-29 08:05:08 +0000 | [diff] [blame] | 197 | rc = efx_mdio_wait_reset_mmds(efx, TENXPRESS_REQUIRED_DEVS); |
Ben Hutchings | e6fa2eb | 2008-12-12 22:00:17 -0800 | [diff] [blame] | 198 | if (rc < 0) |
Steve Hodgson | ff3b00a | 2009-12-23 13:46:36 +0000 | [diff] [blame] | 199 | return rc; |
Ben Hutchings | e6fa2eb | 2008-12-12 22:00:17 -0800 | [diff] [blame] | 200 | |
Ben Hutchings | 68e7f45 | 2009-04-29 08:05:08 +0000 | [diff] [blame] | 201 | rc = efx_mdio_check_mmds(efx, TENXPRESS_REQUIRED_DEVS, 0); |
Ben Hutchings | e6fa2eb | 2008-12-12 22:00:17 -0800 | [diff] [blame] | 202 | if (rc < 0) |
Steve Hodgson | ff3b00a | 2009-12-23 13:46:36 +0000 | [diff] [blame] | 203 | return rc; |
Ben Hutchings | e6fa2eb | 2008-12-12 22:00:17 -0800 | [diff] [blame] | 204 | } |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 205 | |
| 206 | rc = tenxpress_init(efx); |
| 207 | if (rc < 0) |
Steve Hodgson | ff3b00a | 2009-12-23 13:46:36 +0000 | [diff] [blame] | 208 | return rc; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 209 | |
Steve Hodgson | ff3b00a | 2009-12-23 13:46:36 +0000 | [diff] [blame] | 210 | /* Reinitialise flow control settings */ |
Ben Hutchings | d3245b2 | 2009-11-29 03:42:41 +0000 | [diff] [blame] | 211 | efx_link_set_wanted_fc(efx, efx->wanted_fc); |
| 212 | efx_mdio_an_reconfigure(efx); |
Ben Hutchings | c634263 | 2009-10-12 09:27:07 +0000 | [diff] [blame] | 213 | |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 214 | schedule_timeout_uninterruptible(HZ / 5); /* 200ms */ |
| 215 | |
Ben Hutchings | e6fa2eb | 2008-12-12 22:00:17 -0800 | [diff] [blame] | 216 | /* Let XGXS and SerDes out of reset */ |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 217 | falcon_reset_xaui(efx); |
| 218 | |
| 219 | return 0; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 220 | } |
| 221 | |
Ben Hutchings | e6fa2eb | 2008-12-12 22:00:17 -0800 | [diff] [blame] | 222 | /* Perform a "special software reset" on the PHY. The caller is |
| 223 | * responsible for saving and restoring the PHY hardware registers |
| 224 | * properly, and masking/unmasking LASI */ |
Ben Hutchings | 3273c2e | 2008-05-07 13:36:19 +0100 | [diff] [blame] | 225 | static int tenxpress_special_reset(struct efx_nic *efx) |
| 226 | { |
| 227 | int rc, reg; |
| 228 | |
Ben Hutchings | 8fbca79 | 2010-09-22 10:00:11 +0000 | [diff] [blame] | 229 | /* The XGMAC clock is driven from the SFX7101 312MHz clock, so |
Ben Hutchings | c8fcc49 | 2008-09-01 12:49:25 +0100 | [diff] [blame] | 230 | * a special software reset can glitch the XGMAC sufficiently for stats |
Ben Hutchings | 1974cc2 | 2009-01-29 18:00:07 +0000 | [diff] [blame] | 231 | * requests to fail. */ |
Ben Hutchings | 55edc6e | 2009-11-25 16:11:35 +0000 | [diff] [blame] | 232 | falcon_stop_nic_stats(efx); |
Ben Hutchings | 3273c2e | 2008-05-07 13:36:19 +0100 | [diff] [blame] | 233 | |
| 234 | /* Initiate reset */ |
Ben Hutchings | 68e7f45 | 2009-04-29 08:05:08 +0000 | [diff] [blame] | 235 | reg = efx_mdio_read(efx, MDIO_MMD_PMAPMD, PMA_PMD_XCONTROL_REG); |
Ben Hutchings | 3273c2e | 2008-05-07 13:36:19 +0100 | [diff] [blame] | 236 | reg |= (1 << PMA_PMD_EXT_SSR_LBN); |
Ben Hutchings | 68e7f45 | 2009-04-29 08:05:08 +0000 | [diff] [blame] | 237 | efx_mdio_write(efx, MDIO_MMD_PMAPMD, PMA_PMD_XCONTROL_REG, reg); |
Ben Hutchings | 3273c2e | 2008-05-07 13:36:19 +0100 | [diff] [blame] | 238 | |
Ben Hutchings | c8fcc49 | 2008-09-01 12:49:25 +0100 | [diff] [blame] | 239 | mdelay(200); |
Ben Hutchings | 3273c2e | 2008-05-07 13:36:19 +0100 | [diff] [blame] | 240 | |
| 241 | /* Wait for the blocks to come out of reset */ |
Ben Hutchings | 68e7f45 | 2009-04-29 08:05:08 +0000 | [diff] [blame] | 242 | rc = efx_mdio_wait_reset_mmds(efx, TENXPRESS_REQUIRED_DEVS); |
Ben Hutchings | 3273c2e | 2008-05-07 13:36:19 +0100 | [diff] [blame] | 243 | if (rc < 0) |
Ben Hutchings | 1974cc2 | 2009-01-29 18:00:07 +0000 | [diff] [blame] | 244 | goto out; |
Ben Hutchings | 3273c2e | 2008-05-07 13:36:19 +0100 | [diff] [blame] | 245 | |
| 246 | /* Try and reconfigure the device */ |
| 247 | rc = tenxpress_init(efx); |
| 248 | if (rc < 0) |
Ben Hutchings | 1974cc2 | 2009-01-29 18:00:07 +0000 | [diff] [blame] | 249 | goto out; |
Ben Hutchings | 3273c2e | 2008-05-07 13:36:19 +0100 | [diff] [blame] | 250 | |
Ben Hutchings | e6fa2eb | 2008-12-12 22:00:17 -0800 | [diff] [blame] | 251 | /* Wait for the XGXS state machine to churn */ |
| 252 | mdelay(10); |
Ben Hutchings | 1974cc2 | 2009-01-29 18:00:07 +0000 | [diff] [blame] | 253 | out: |
Ben Hutchings | 55edc6e | 2009-11-25 16:11:35 +0000 | [diff] [blame] | 254 | falcon_start_nic_stats(efx); |
Ben Hutchings | c8fcc49 | 2008-09-01 12:49:25 +0100 | [diff] [blame] | 255 | return rc; |
Ben Hutchings | 3273c2e | 2008-05-07 13:36:19 +0100 | [diff] [blame] | 256 | } |
| 257 | |
Ben Hutchings | e6fa2eb | 2008-12-12 22:00:17 -0800 | [diff] [blame] | 258 | static void sfx7101_check_bad_lp(struct efx_nic *efx, bool link_ok) |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 259 | { |
| 260 | struct tenxpress_phy_data *pd = efx->phy_data; |
Ben Hutchings | 04cc8ca | 2008-12-12 21:50:46 -0800 | [diff] [blame] | 261 | bool bad_lp; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 262 | int reg; |
| 263 | |
Ben Hutchings | 04cc8ca | 2008-12-12 21:50:46 -0800 | [diff] [blame] | 264 | if (link_ok) { |
| 265 | bad_lp = false; |
| 266 | } else { |
| 267 | /* Check that AN has started but not completed. */ |
Ben Hutchings | 68e7f45 | 2009-04-29 08:05:08 +0000 | [diff] [blame] | 268 | reg = efx_mdio_read(efx, MDIO_MMD_AN, MDIO_STAT1); |
| 269 | if (!(reg & MDIO_AN_STAT1_LPABLE)) |
Ben Hutchings | 04cc8ca | 2008-12-12 21:50:46 -0800 | [diff] [blame] | 270 | return; /* LP status is unknown */ |
Ben Hutchings | 68e7f45 | 2009-04-29 08:05:08 +0000 | [diff] [blame] | 271 | bad_lp = !(reg & MDIO_AN_STAT1_COMPLETE); |
Ben Hutchings | 04cc8ca | 2008-12-12 21:50:46 -0800 | [diff] [blame] | 272 | if (bad_lp) |
| 273 | pd->bad_lp_tries++; |
| 274 | } |
| 275 | |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 276 | /* Nothing to do if all is well and was previously so. */ |
Ben Hutchings | 04cc8ca | 2008-12-12 21:50:46 -0800 | [diff] [blame] | 277 | if (!pd->bad_lp_tries) |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 278 | return; |
| 279 | |
Ben Hutchings | 04cc8ca | 2008-12-12 21:50:46 -0800 | [diff] [blame] | 280 | /* Use the RX (red) LED as an error indicator once we've seen AN |
| 281 | * failure several times in a row, and also log a message. */ |
| 282 | if (!bad_lp || pd->bad_lp_tries == MAX_BAD_LP_TRIES) { |
Ben Hutchings | 68e7f45 | 2009-04-29 08:05:08 +0000 | [diff] [blame] | 283 | reg = efx_mdio_read(efx, MDIO_MMD_PMAPMD, |
| 284 | PMA_PMD_LED_OVERR_REG); |
Ben Hutchings | 04cc8ca | 2008-12-12 21:50:46 -0800 | [diff] [blame] | 285 | reg &= ~(PMA_PMD_LED_MASK << PMA_PMD_LED_RX_LBN); |
| 286 | if (!bad_lp) { |
| 287 | reg |= PMA_PMD_LED_OFF << PMA_PMD_LED_RX_LBN; |
| 288 | } else { |
| 289 | reg |= PMA_PMD_LED_FLASH << PMA_PMD_LED_RX_LBN; |
Ben Hutchings | 62776d0 | 2010-06-23 11:30:07 +0000 | [diff] [blame] | 290 | netif_err(efx, link, efx->net_dev, |
| 291 | "appears to be plugged into a port" |
| 292 | " that is not 10GBASE-T capable. The PHY" |
| 293 | " supports 10GBASE-T ONLY, so no link can" |
| 294 | " be established\n"); |
Ben Hutchings | 04cc8ca | 2008-12-12 21:50:46 -0800 | [diff] [blame] | 295 | } |
Ben Hutchings | 68e7f45 | 2009-04-29 08:05:08 +0000 | [diff] [blame] | 296 | efx_mdio_write(efx, MDIO_MMD_PMAPMD, |
| 297 | PMA_PMD_LED_OVERR_REG, reg); |
Ben Hutchings | 04cc8ca | 2008-12-12 21:50:46 -0800 | [diff] [blame] | 298 | pd->bad_lp_tries = bad_lp; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 299 | } |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 300 | } |
| 301 | |
Ben Hutchings | e6fa2eb | 2008-12-12 22:00:17 -0800 | [diff] [blame] | 302 | static bool sfx7101_link_ok(struct efx_nic *efx) |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 303 | { |
Ben Hutchings | 68e7f45 | 2009-04-29 08:05:08 +0000 | [diff] [blame] | 304 | return efx_mdio_links_ok(efx, |
| 305 | MDIO_DEVS_PMAPMD | |
| 306 | MDIO_DEVS_PCS | |
| 307 | MDIO_DEVS_PHYXS); |
Ben Hutchings | e6fa2eb | 2008-12-12 22:00:17 -0800 | [diff] [blame] | 308 | } |
| 309 | |
Ben Hutchings | e6fa2eb | 2008-12-12 22:00:17 -0800 | [diff] [blame] | 310 | static void tenxpress_ext_loopback(struct efx_nic *efx) |
Ben Hutchings | 3273c2e | 2008-05-07 13:36:19 +0100 | [diff] [blame] | 311 | { |
Ben Hutchings | 68e7f45 | 2009-04-29 08:05:08 +0000 | [diff] [blame] | 312 | efx_mdio_set_flag(efx, MDIO_MMD_PHYXS, PHYXS_TEST1, |
| 313 | 1 << LOOPBACK_NEAR_LBN, |
| 314 | efx->loopback_mode == LOOPBACK_PHYXS); |
Ben Hutchings | e6fa2eb | 2008-12-12 22:00:17 -0800 | [diff] [blame] | 315 | } |
| 316 | |
| 317 | static void tenxpress_low_power(struct efx_nic *efx) |
| 318 | { |
Ben Hutchings | 8fbca79 | 2010-09-22 10:00:11 +0000 | [diff] [blame] | 319 | efx_mdio_set_mmds_lpower( |
| 320 | efx, !!(efx->phy_mode & PHY_MODE_LOW_POWER), |
| 321 | TENXPRESS_REQUIRED_DEVS); |
Ben Hutchings | 3273c2e | 2008-05-07 13:36:19 +0100 | [diff] [blame] | 322 | } |
| 323 | |
Ben Hutchings | d3245b2 | 2009-11-29 03:42:41 +0000 | [diff] [blame] | 324 | static int tenxpress_phy_reconfigure(struct efx_nic *efx) |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 325 | { |
Ben Hutchings | 3273c2e | 2008-05-07 13:36:19 +0100 | [diff] [blame] | 326 | struct tenxpress_phy_data *phy_data = efx->phy_data; |
Steve Hodgson | 8b9dc8d | 2009-01-29 17:49:09 +0000 | [diff] [blame] | 327 | bool phy_mode_change, loop_reset; |
Ben Hutchings | 3273c2e | 2008-05-07 13:36:19 +0100 | [diff] [blame] | 328 | |
Ben Hutchings | e6fa2eb | 2008-12-12 22:00:17 -0800 | [diff] [blame] | 329 | if (efx->phy_mode & (PHY_MODE_OFF | PHY_MODE_SPECIAL)) { |
Ben Hutchings | f8b87c1 | 2008-09-01 12:48:17 +0100 | [diff] [blame] | 330 | phy_data->phy_mode = efx->phy_mode; |
Ben Hutchings | d3245b2 | 2009-11-29 03:42:41 +0000 | [diff] [blame] | 331 | return 0; |
Ben Hutchings | f8b87c1 | 2008-09-01 12:48:17 +0100 | [diff] [blame] | 332 | } |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 333 | |
Ben Hutchings | e6fa2eb | 2008-12-12 22:00:17 -0800 | [diff] [blame] | 334 | phy_mode_change = (efx->phy_mode == PHY_MODE_NORMAL && |
| 335 | phy_data->phy_mode != PHY_MODE_NORMAL); |
Ben Hutchings | c1c4f45 | 2009-11-29 15:08:55 +0000 | [diff] [blame] | 336 | loop_reset = (LOOPBACK_OUT_OF(phy_data, efx, LOOPBACKS_EXTERNAL(efx)) || |
Ben Hutchings | e6fa2eb | 2008-12-12 22:00:17 -0800 | [diff] [blame] | 337 | LOOPBACK_CHANGED(phy_data, efx, 1 << LOOPBACK_GPHY)); |
| 338 | |
Steve Hodgson | 8b9dc8d | 2009-01-29 17:49:09 +0000 | [diff] [blame] | 339 | if (loop_reset || phy_mode_change) { |
Ben Hutchings | d3245b2 | 2009-11-29 03:42:41 +0000 | [diff] [blame] | 340 | tenxpress_special_reset(efx); |
Ben Hutchings | 8fbca79 | 2010-09-22 10:00:11 +0000 | [diff] [blame] | 341 | falcon_reset_xaui(efx); |
Ben Hutchings | 3273c2e | 2008-05-07 13:36:19 +0100 | [diff] [blame] | 342 | } |
| 343 | |
Ben Hutchings | d3245b2 | 2009-11-29 03:42:41 +0000 | [diff] [blame] | 344 | tenxpress_low_power(efx); |
Ben Hutchings | 68e7f45 | 2009-04-29 08:05:08 +0000 | [diff] [blame] | 345 | efx_mdio_transmit_disable(efx); |
| 346 | efx_mdio_phy_reconfigure(efx); |
Ben Hutchings | e6fa2eb | 2008-12-12 22:00:17 -0800 | [diff] [blame] | 347 | tenxpress_ext_loopback(efx); |
Ben Hutchings | d3245b2 | 2009-11-29 03:42:41 +0000 | [diff] [blame] | 348 | efx_mdio_an_reconfigure(efx); |
Ben Hutchings | 3273c2e | 2008-05-07 13:36:19 +0100 | [diff] [blame] | 349 | |
Ben Hutchings | 3273c2e | 2008-05-07 13:36:19 +0100 | [diff] [blame] | 350 | phy_data->loopback_mode = efx->loopback_mode; |
Ben Hutchings | f8b87c1 | 2008-09-01 12:48:17 +0100 | [diff] [blame] | 351 | phy_data->phy_mode = efx->phy_mode; |
Ben Hutchings | d3245b2 | 2009-11-29 03:42:41 +0000 | [diff] [blame] | 352 | |
| 353 | return 0; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 354 | } |
| 355 | |
Steve Hodgson | fdaa9ae | 2009-11-28 05:34:05 +0000 | [diff] [blame] | 356 | static void |
| 357 | tenxpress_get_settings(struct efx_nic *efx, struct ethtool_cmd *ecmd); |
| 358 | |
| 359 | /* Poll for link state changes */ |
| 360 | static bool tenxpress_phy_poll(struct efx_nic *efx) |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 361 | { |
Steve Hodgson | fdaa9ae | 2009-11-28 05:34:05 +0000 | [diff] [blame] | 362 | struct efx_link_state old_state = efx->link_state; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 363 | |
Ben Hutchings | 8fbca79 | 2010-09-22 10:00:11 +0000 | [diff] [blame] | 364 | efx->link_state.up = sfx7101_link_ok(efx); |
| 365 | efx->link_state.speed = 10000; |
| 366 | efx->link_state.fd = true; |
| 367 | efx->link_state.fc = efx_mdio_get_pause(efx); |
Steve Hodgson | fdaa9ae | 2009-11-28 05:34:05 +0000 | [diff] [blame] | 368 | |
Ben Hutchings | 8fbca79 | 2010-09-22 10:00:11 +0000 | [diff] [blame] | 369 | sfx7101_check_bad_lp(efx, efx->link_state.up); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 370 | |
Steve Hodgson | fdaa9ae | 2009-11-28 05:34:05 +0000 | [diff] [blame] | 371 | return !efx_link_state_equal(&efx->link_state, &old_state); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 372 | } |
| 373 | |
Steve Hodgson | ff3b00a | 2009-12-23 13:46:36 +0000 | [diff] [blame] | 374 | static void sfx7101_phy_fini(struct efx_nic *efx) |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 375 | { |
| 376 | int reg; |
| 377 | |
Steve Hodgson | ff3b00a | 2009-12-23 13:46:36 +0000 | [diff] [blame] | 378 | /* Power down the LNPGA */ |
| 379 | reg = (1 << PMA_PMD_LNPGA_POWERDOWN_LBN); |
| 380 | efx_mdio_write(efx, MDIO_MMD_PMAPMD, PMA_PMD_XCONTROL_REG, reg); |
| 381 | |
| 382 | /* Waiting here ensures that the board fini, which can turn |
| 383 | * off the power to the PHY, won't get run until the LNPGA |
| 384 | * powerdown has been given long enough to complete. */ |
| 385 | schedule_timeout_uninterruptible(LNPGA_PDOWN_WAIT); /* 200 ms */ |
| 386 | } |
| 387 | |
| 388 | static void tenxpress_phy_remove(struct efx_nic *efx) |
| 389 | { |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 390 | kfree(efx->phy_data); |
| 391 | efx->phy_data = NULL; |
| 392 | } |
| 393 | |
| 394 | |
Ben Hutchings | 398468e | 2009-11-23 16:03:45 +0000 | [diff] [blame] | 395 | /* Override the RX, TX and link LEDs */ |
| 396 | void tenxpress_set_id_led(struct efx_nic *efx, enum efx_led_mode mode) |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 397 | { |
| 398 | int reg; |
| 399 | |
Ben Hutchings | 398468e | 2009-11-23 16:03:45 +0000 | [diff] [blame] | 400 | switch (mode) { |
| 401 | case EFX_LED_OFF: |
| 402 | reg = (PMA_PMD_LED_OFF << PMA_PMD_LED_TX_LBN) | |
| 403 | (PMA_PMD_LED_OFF << PMA_PMD_LED_RX_LBN) | |
| 404 | (PMA_PMD_LED_OFF << PMA_PMD_LED_LINK_LBN); |
| 405 | break; |
| 406 | case EFX_LED_ON: |
| 407 | reg = (PMA_PMD_LED_ON << PMA_PMD_LED_TX_LBN) | |
| 408 | (PMA_PMD_LED_ON << PMA_PMD_LED_RX_LBN) | |
| 409 | (PMA_PMD_LED_ON << PMA_PMD_LED_LINK_LBN); |
| 410 | break; |
| 411 | default: |
Ben Hutchings | 8fbca79 | 2010-09-22 10:00:11 +0000 | [diff] [blame] | 412 | reg = SFX7101_PMA_PMD_LED_DEFAULT; |
Ben Hutchings | 398468e | 2009-11-23 16:03:45 +0000 | [diff] [blame] | 413 | break; |
| 414 | } |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 415 | |
Ben Hutchings | 68e7f45 | 2009-04-29 08:05:08 +0000 | [diff] [blame] | 416 | efx_mdio_write(efx, MDIO_MMD_PMAPMD, PMA_PMD_LED_OVERR_REG, reg); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 417 | } |
| 418 | |
Ben Hutchings | 307505e | 2008-12-26 13:48:00 -0800 | [diff] [blame] | 419 | static const char *const sfx7101_test_names[] = { |
Ben Hutchings | 1796721 | 2008-12-26 13:47:25 -0800 | [diff] [blame] | 420 | "bist" |
| 421 | }; |
| 422 | |
Ben Hutchings | c1c4f45 | 2009-11-29 15:08:55 +0000 | [diff] [blame] | 423 | static const char *sfx7101_test_name(struct efx_nic *efx, unsigned int index) |
| 424 | { |
| 425 | if (index < ARRAY_SIZE(sfx7101_test_names)) |
| 426 | return sfx7101_test_names[index]; |
| 427 | return NULL; |
| 428 | } |
| 429 | |
Ben Hutchings | 1796721 | 2008-12-26 13:47:25 -0800 | [diff] [blame] | 430 | static int |
Ben Hutchings | 307505e | 2008-12-26 13:48:00 -0800 | [diff] [blame] | 431 | sfx7101_run_tests(struct efx_nic *efx, int *results, unsigned flags) |
Ben Hutchings | 8c8661e | 2008-09-01 12:49:02 +0100 | [diff] [blame] | 432 | { |
Ben Hutchings | 1796721 | 2008-12-26 13:47:25 -0800 | [diff] [blame] | 433 | int rc; |
| 434 | |
| 435 | if (!(flags & ETH_TEST_FL_OFFLINE)) |
| 436 | return 0; |
| 437 | |
Ben Hutchings | 8c8661e | 2008-09-01 12:49:02 +0100 | [diff] [blame] | 438 | /* BIST is automatically run after a special software reset */ |
Ben Hutchings | 1796721 | 2008-12-26 13:47:25 -0800 | [diff] [blame] | 439 | rc = tenxpress_special_reset(efx); |
| 440 | results[0] = rc ? -1 : 1; |
Ben Hutchings | d3245b2 | 2009-11-29 03:42:41 +0000 | [diff] [blame] | 441 | |
| 442 | efx_mdio_an_reconfigure(efx); |
| 443 | |
Ben Hutchings | 1796721 | 2008-12-26 13:47:25 -0800 | [diff] [blame] | 444 | return rc; |
Ben Hutchings | 8c8661e | 2008-09-01 12:49:02 +0100 | [diff] [blame] | 445 | } |
| 446 | |
Ben Hutchings | af4ad9b | 2009-01-29 17:59:37 +0000 | [diff] [blame] | 447 | static void |
| 448 | tenxpress_get_settings(struct efx_nic *efx, struct ethtool_cmd *ecmd) |
Ben Hutchings | 04cc8ca | 2008-12-12 21:50:46 -0800 | [diff] [blame] | 449 | { |
Ben Hutchings | af4ad9b | 2009-01-29 17:59:37 +0000 | [diff] [blame] | 450 | u32 adv = 0, lpa = 0; |
Ben Hutchings | 04cc8ca | 2008-12-12 21:50:46 -0800 | [diff] [blame] | 451 | int reg; |
| 452 | |
Ben Hutchings | 68e7f45 | 2009-04-29 08:05:08 +0000 | [diff] [blame] | 453 | reg = efx_mdio_read(efx, MDIO_MMD_AN, MDIO_AN_10GBT_CTRL); |
| 454 | if (reg & MDIO_AN_10GBT_CTRL_ADV10G) |
Ben Hutchings | af4ad9b | 2009-01-29 17:59:37 +0000 | [diff] [blame] | 455 | adv |= ADVERTISED_10000baseT_Full; |
Ben Hutchings | 68e7f45 | 2009-04-29 08:05:08 +0000 | [diff] [blame] | 456 | reg = efx_mdio_read(efx, MDIO_MMD_AN, MDIO_AN_10GBT_STAT); |
| 457 | if (reg & MDIO_AN_10GBT_STAT_LP10G) |
Ben Hutchings | 04cc8ca | 2008-12-12 21:50:46 -0800 | [diff] [blame] | 458 | lpa |= ADVERTISED_10000baseT_Full; |
Ben Hutchings | 04cc8ca | 2008-12-12 21:50:46 -0800 | [diff] [blame] | 459 | |
Ben Hutchings | 68e7f45 | 2009-04-29 08:05:08 +0000 | [diff] [blame] | 460 | mdio45_ethtool_gset_npage(&efx->mdio, ecmd, adv, lpa); |
Ben Hutchings | 04cc8ca | 2008-12-12 21:50:46 -0800 | [diff] [blame] | 461 | |
Steve Hodgson | 8b9dc8d | 2009-01-29 17:49:09 +0000 | [diff] [blame] | 462 | /* In loopback, the PHY automatically brings up the correct interface, |
| 463 | * but doesn't advertise the correct speed. So override it */ |
Ben Hutchings | 8fbca79 | 2010-09-22 10:00:11 +0000 | [diff] [blame] | 464 | if (LOOPBACK_EXTERNAL(efx)) |
Steve Hodgson | 8b9dc8d | 2009-01-29 17:49:09 +0000 | [diff] [blame] | 465 | ecmd->speed = SPEED_10000; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 466 | } |
| 467 | |
Ben Hutchings | af4ad9b | 2009-01-29 17:59:37 +0000 | [diff] [blame] | 468 | static int tenxpress_set_settings(struct efx_nic *efx, struct ethtool_cmd *ecmd) |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 469 | { |
Ben Hutchings | af4ad9b | 2009-01-29 17:59:37 +0000 | [diff] [blame] | 470 | if (!ecmd->autoneg) |
| 471 | return -EINVAL; |
Ben Hutchings | e6fa2eb | 2008-12-12 22:00:17 -0800 | [diff] [blame] | 472 | |
Ben Hutchings | 68e7f45 | 2009-04-29 08:05:08 +0000 | [diff] [blame] | 473 | return efx_mdio_set_settings(efx, ecmd); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 474 | } |
| 475 | |
Ben Hutchings | af4ad9b | 2009-01-29 17:59:37 +0000 | [diff] [blame] | 476 | static void sfx7101_set_npage_adv(struct efx_nic *efx, u32 advertising) |
Ben Hutchings | e6fa2eb | 2008-12-12 22:00:17 -0800 | [diff] [blame] | 477 | { |
Ben Hutchings | 68e7f45 | 2009-04-29 08:05:08 +0000 | [diff] [blame] | 478 | efx_mdio_set_flag(efx, MDIO_MMD_AN, MDIO_AN_10GBT_CTRL, |
| 479 | MDIO_AN_10GBT_CTRL_ADV10G, |
| 480 | advertising & ADVERTISED_10000baseT_Full); |
Ben Hutchings | af4ad9b | 2009-01-29 17:59:37 +0000 | [diff] [blame] | 481 | } |
Ben Hutchings | e6fa2eb | 2008-12-12 22:00:17 -0800 | [diff] [blame] | 482 | |
Ben Hutchings | e6fa2eb | 2008-12-12 22:00:17 -0800 | [diff] [blame] | 483 | struct efx_phy_operations falcon_sfx7101_phy_ops = { |
Steve Hodgson | ff3b00a | 2009-12-23 13:46:36 +0000 | [diff] [blame] | 484 | .probe = tenxpress_phy_probe, |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 485 | .init = tenxpress_phy_init, |
| 486 | .reconfigure = tenxpress_phy_reconfigure, |
Ben Hutchings | 766ca0f | 2008-12-12 21:59:24 -0800 | [diff] [blame] | 487 | .poll = tenxpress_phy_poll, |
Steve Hodgson | ff3b00a | 2009-12-23 13:46:36 +0000 | [diff] [blame] | 488 | .fini = sfx7101_phy_fini, |
| 489 | .remove = tenxpress_phy_remove, |
Ben Hutchings | af4ad9b | 2009-01-29 17:59:37 +0000 | [diff] [blame] | 490 | .get_settings = tenxpress_get_settings, |
| 491 | .set_settings = tenxpress_set_settings, |
| 492 | .set_npage_adv = sfx7101_set_npage_adv, |
Ben Hutchings | 4f16c07 | 2010-02-03 09:30:50 +0000 | [diff] [blame] | 493 | .test_alive = efx_mdio_test_alive, |
Ben Hutchings | c1c4f45 | 2009-11-29 15:08:55 +0000 | [diff] [blame] | 494 | .test_name = sfx7101_test_name, |
Ben Hutchings | 307505e | 2008-12-26 13:48:00 -0800 | [diff] [blame] | 495 | .run_tests = sfx7101_run_tests, |
Ben Hutchings | e6fa2eb | 2008-12-12 22:00:17 -0800 | [diff] [blame] | 496 | }; |