11 #include <linux/rtnetlink.h>
13 #include <linux/slab.h>
21 #define TENXPRESS_REQUIRED_DEVS (MDIO_DEVS_PMAPMD | \
26 #define SFX7101_LOOPBACKS ((1 << LOOPBACK_PHYXS) | \
27 (1 << LOOPBACK_PCS) | \
28 (1 << LOOPBACK_PMAPMD) | \
29 (1 << LOOPBACK_PHYXS_WS))
34 #define MAX_BAD_LP_TRIES (5)
37 #define PMA_PMD_XCONTROL_REG 49152
38 #define PMA_PMD_EXT_GMII_EN_LBN 1
39 #define PMA_PMD_EXT_GMII_EN_WIDTH 1
40 #define PMA_PMD_EXT_CLK_OUT_LBN 2
41 #define PMA_PMD_EXT_CLK_OUT_WIDTH 1
42 #define PMA_PMD_LNPGA_POWERDOWN_LBN 8
43 #define PMA_PMD_LNPGA_POWERDOWN_WIDTH 1
44 #define PMA_PMD_EXT_CLK312_WIDTH 1
45 #define PMA_PMD_EXT_LPOWER_LBN 12
46 #define PMA_PMD_EXT_LPOWER_WIDTH 1
47 #define PMA_PMD_EXT_ROBUST_LBN 14
48 #define PMA_PMD_EXT_ROBUST_WIDTH 1
49 #define PMA_PMD_EXT_SSR_LBN 15
50 #define PMA_PMD_EXT_SSR_WIDTH 1
53 #define PMA_PMD_XSTATUS_REG 49153
54 #define PMA_PMD_XSTAT_MDIX_LBN 14
55 #define PMA_PMD_XSTAT_FLP_LBN (12)
58 #define PMA_PMD_LED_CTRL_REG 49159
59 #define PMA_PMA_LED_ACTIVITY_LBN (3)
62 #define PMA_PMD_LED_OVERR_REG 49161
64 #define PMA_PMD_LED_LINK_LBN (0)
65 #define PMA_PMD_LED_SPEED_LBN (2)
66 #define PMA_PMD_LED_TX_LBN (4)
67 #define PMA_PMD_LED_RX_LBN (6)
69 #define PMA_PMD_LED_AUTO (0)
70 #define PMA_PMD_LED_ON (1)
71 #define PMA_PMD_LED_OFF (2)
72 #define PMA_PMD_LED_FLASH (3)
73 #define PMA_PMD_LED_MASK 3
76 #define SFX7101_PMA_PMD_LED_DEFAULT (PMA_PMD_LED_OFF << PMA_PMD_LED_RX_LBN)
78 #define PMA_PMD_SPEED_ENABLE_REG 49192
79 #define PMA_PMD_100TX_ADV_LBN 1
80 #define PMA_PMD_100TX_ADV_WIDTH 1
81 #define PMA_PMD_1000T_ADV_LBN 2
82 #define PMA_PMD_1000T_ADV_WIDTH 1
83 #define PMA_PMD_10000T_ADV_LBN 3
84 #define PMA_PMD_10000T_ADV_WIDTH 1
85 #define PMA_PMD_SPEED_LBN 4
86 #define PMA_PMD_SPEED_WIDTH 4
89 #define PCS_CLOCK_CTRL_REG 55297
90 #define PLL312_RST_N_LBN 2
92 #define PCS_SOFT_RST2_REG 55302
93 #define SERDES_RST_N_LBN 13
94 #define XGXS_RST_N_LBN 12
96 #define PCS_TEST_SELECT_REG 55303
97 #define CLK312_EN_LBN 3
100 #define PHYXS_XCONTROL_REG 49152
101 #define PHYXS_RESET_LBN 15
102 #define PHYXS_RESET_WIDTH 1
104 #define PHYXS_TEST1 (49162)
105 #define LOOPBACK_NEAR_LBN (8)
106 #define LOOPBACK_NEAR_WIDTH (1)
109 #define PCS_BOOT_STATUS_REG 53248
110 #define PCS_BOOT_FATAL_ERROR_LBN 0
111 #define PCS_BOOT_PROGRESS_LBN 1
112 #define PCS_BOOT_PROGRESS_WIDTH 2
113 #define PCS_BOOT_PROGRESS_INIT 0
114 #define PCS_BOOT_PROGRESS_WAIT_MDIO 1
115 #define PCS_BOOT_PROGRESS_CHECKSUM 2
116 #define PCS_BOOT_PROGRESS_JUMP 3
117 #define PCS_BOOT_DOWNLOAD_WAIT_LBN 3
118 #define PCS_BOOT_CODE_STARTED_LBN 4
121 #define GPHY_XCONTROL_REG 49152
122 #define GPHY_ISOLATE_LBN 10
123 #define GPHY_ISOLATE_WIDTH 1
124 #define GPHY_DUPLEX_LBN 8
125 #define GPHY_DUPLEX_WIDTH 1
126 #define GPHY_LOOPBACK_NEAR_LBN 14
127 #define GPHY_LOOPBACK_NEAR_WIDTH 1
129 #define C22EXT_STATUS_REG 49153
130 #define C22EXT_STATUS_LINK_LBN 2
131 #define C22EXT_STATUS_LINK_WIDTH 1
133 #define C22EXT_MSTSLV_CTRL 49161
134 #define C22EXT_MSTSLV_CTRL_ADV_1000_HD_LBN 8
135 #define C22EXT_MSTSLV_CTRL_ADV_1000_FD_LBN 9
137 #define C22EXT_MSTSLV_STATUS 49162
138 #define C22EXT_MSTSLV_STATUS_LP_1000_HD_LBN 10
139 #define C22EXT_MSTSLV_STATUS_LP_1000_FD_LBN 11
143 #define LNPGA_PDOWN_WAIT (HZ / 5)
151 static int tenxpress_init(
struct efx_nic *efx)
166 static int tenxpress_phy_probe(
struct efx_nic *efx)
171 phy_data = kzalloc(
sizeof(*phy_data),
GFP_KERNEL);
188 static int tenxpress_phy_init(
struct efx_nic *efx)
204 rc = tenxpress_init(efx);
223 static int tenxpress_special_reset(
struct efx_nic *efx)
245 rc = tenxpress_init(efx);
256 static void sfx7101_check_bad_lp(
struct efx_nic *efx,
bool link_ok)
289 "appears to be plugged into a port"
290 " that is not 10GBASE-T capable. The PHY"
291 " supports 10GBASE-T ONLY, so no link can"
292 " be established\n");
300 static bool sfx7101_link_ok(
struct efx_nic *efx)
308 static void tenxpress_ext_loopback(
struct efx_nic *efx)
315 static void tenxpress_low_power(
struct efx_nic *efx)
322 static int tenxpress_phy_reconfigure(
struct efx_nic *efx)
325 bool phy_mode_change, loop_reset;
337 if (loop_reset || phy_mode_change) {
338 tenxpress_special_reset(efx);
342 tenxpress_low_power(efx);
345 tenxpress_ext_loopback(efx);
358 static bool tenxpress_phy_poll(
struct efx_nic *efx)
367 sfx7101_check_bad_lp(efx, efx->
link_state.up);
369 return !efx_link_state_equal(&efx->
link_state, &old_state);
372 static void sfx7101_phy_fini(
struct efx_nic *efx)
386 static void tenxpress_phy_remove(
struct efx_nic *efx)
417 static const char *
const sfx7101_test_names[] = {
421 static const char *sfx7101_test_name(
struct efx_nic *efx,
unsigned int index)
424 return sfx7101_test_names[
index];
429 sfx7101_run_tests(
struct efx_nic *efx,
int *results,
unsigned flags)
437 rc = tenxpress_special_reset(efx);
438 results[0] = rc ? -1 : 1;
448 u32 adv = 0, lpa = 0;
474 static void sfx7101_set_npage_adv(
struct efx_nic *efx,
u32 advertising)
477 MDIO_AN_10GBT_CTRL_ADV10G,
482 .probe = tenxpress_phy_probe,
483 .init = tenxpress_phy_init,
484 .reconfigure = tenxpress_phy_reconfigure,
485 .poll = tenxpress_phy_poll,
486 .fini = sfx7101_phy_fini,
487 .remove = tenxpress_phy_remove,
488 .get_settings = tenxpress_get_settings,
489 .set_settings = tenxpress_set_settings,
490 .set_npage_adv = sfx7101_set_npage_adv,
492 .test_name = sfx7101_test_name,
493 .run_tests = sfx7101_run_tests,