16 #include <linux/slab.h>
23 #define TXC_REQUIRED_DEVS (MDIO_DEVS_PCS | \
27 #define TXC_LOOPBACKS ((1 << LOOPBACK_PCS) | \
28 (1 << LOOPBACK_PMAPMD) | \
29 (1 << LOOPBACK_PHYXS_WS))
37 #define TXCNAME "TXC43128"
39 #define TXC_MAX_RESET_TIME 500
41 #define TXC_RESET_WAIT 10
43 #define TXC_BIST_DURATION 50
53 #define TXC_GLRGS_GLCMD 0xc004
56 #define TXC_GLCMD_L01PD_LBN 5
57 #define TXC_GLCMD_L23PD_LBN 6
60 #define TXC_GLCMD_LMTSWRST_LBN 14
63 #define TXC_GLRGS_GSGQLCTL 0xc01a
65 #define TXC_GSGQLCT_SGQLEN_LBN 15
67 #define TXC_GSGQLCT_LNSL_LBN 13
68 #define TXC_GSGQLCT_LNSL_WIDTH 2
71 #define TXC_ALRGS_ATXCTL 0xc040
73 #define TXC_ATXCTL_TXPD3_LBN 15
74 #define TXC_ATXCTL_TXPD2_LBN 14
75 #define TXC_ATXCTL_TXPD1_LBN 13
76 #define TXC_ATXCTL_TXPD0_LBN 12
79 #define TXC_ALRGS_ATXAMP0 0xc041
81 #define TXC_ALRGS_ATXAMP1 0xc042
83 #define TXC_ATXAMP_LANE02_LBN 3
85 #define TXC_ATXAMP_LANE13_LBN 11
87 #define TXC_ATXAMP_1280_mV 0
88 #define TXC_ATXAMP_1200_mV 8
89 #define TXC_ATXAMP_1120_mV 12
90 #define TXC_ATXAMP_1060_mV 14
91 #define TXC_ATXAMP_0820_mV 25
92 #define TXC_ATXAMP_0720_mV 26
93 #define TXC_ATXAMP_0580_mV 27
94 #define TXC_ATXAMP_0440_mV 28
96 #define TXC_ATXAMP_0820_BOTH \
97 ((TXC_ATXAMP_0820_mV << TXC_ATXAMP_LANE02_LBN) \
98 | (TXC_ATXAMP_0820_mV << TXC_ATXAMP_LANE13_LBN))
100 #define TXC_ATXAMP_DEFAULT 0x6060
103 #define TXC_ALRGS_ATXPRE0 0xc043
105 #define TXC_ALRGS_ATXPRE1 0xc044
107 #define TXC_ATXPRE_NONE 0
108 #define TXC_ATXPRE_DEFAULT 0x1010
110 #define TXC_ALRGS_ARXCTL 0xc045
112 #define TXC_ARXCTL_RXPD3_LBN 15
113 #define TXC_ARXCTL_RXPD2_LBN 14
114 #define TXC_ARXCTL_RXPD1_LBN 13
115 #define TXC_ARXCTL_RXPD0_LBN 12
118 #define TXC_MRGS_CTL 0xc340
120 #define TXC_MCTL_RESET_LBN 15
121 #define TXC_MCTL_TXLED_LBN 14
122 #define TXC_MCTL_RXLED_LBN 13
125 #define TXC_GPIO_OUTPUT 0xc346
126 #define TXC_GPIO_DIR 0xc348
129 #define TXC_BIST_CTL 0xc280
130 #define TXC_BIST_TXFRMCNT 0xc281
131 #define TXC_BIST_RX0FRMCNT 0xc282
132 #define TXC_BIST_RX1FRMCNT 0xc283
133 #define TXC_BIST_RX2FRMCNT 0xc284
134 #define TXC_BIST_RX3FRMCNT 0xc285
135 #define TXC_BIST_RX0ERRCNT 0xc286
136 #define TXC_BIST_RX1ERRCNT 0xc287
137 #define TXC_BIST_RX2ERRCNT 0xc288
138 #define TXC_BIST_RX3ERRCNT 0xc289
141 #define TXC_BIST_CTRL_TYPE_LBN 10
142 #define TXC_BIST_CTRL_TYPE_TSD 0
143 #define TXC_BIST_CTRL_TYPE_CRP 1
144 #define TXC_BIST_CTRL_TYPE_CJP 2
145 #define TXC_BIST_CTRL_TYPE_TSR 3
147 #define TXC_BIST_CTRL_B10EN_LBN 12
149 #define TXC_BIST_CTRL_ENAB_LBN 13
151 #define TXC_BIST_CTRL_STOP_LBN 14
153 #define TXC_BIST_CTRL_STRT_LBN 15
156 #define TXC_MTDIABLO_CTRL 0xc34f
157 #define TXC_MTDIABLO_CTRL_PMA_LOOP_LBN 10
168 #define BUG10934_RESET_INTERVAL (5 * HZ)
171 static void txc_reset_logic(
struct efx_nic *efx);
187 static int txc_reset_phy(
struct efx_nic *efx)
208 static int txc_bist_one(
struct efx_nic *efx,
int mmd,
int test)
245 for (lane = 0; lane < 4; lane++) {
249 "Lane %d had %d errs\n", lane, count);
255 "Lane %d got 0 frames\n", lane);
273 static int txc_bist(
struct efx_nic *efx)
280 static void txc_apply_defaults(
struct efx_nic *efx)
319 txc_reset_logic(efx);
324 static int txc43128_phy_probe(
struct efx_nic *efx)
329 phy_data = kzalloc(
sizeof(*phy_data),
GFP_KERNEL);
344 static int txc43128_phy_init(
struct efx_nic *efx)
348 rc = txc_reset_phy(efx);
356 txc_apply_defaults(efx);
362 static void txc_glrgs_lane_power(
struct efx_nic *efx,
int mmd)
376 static void txc_analog_lane_power(
struct efx_nic *efx,
int mmd)
397 static void txc_set_power(
struct efx_nic *efx)
414 static void txc_reset_logic_mmd(
struct efx_nic *efx,
int mmd)
429 TXCNAME " Logic reset timed out!\n");
434 static void txc_reset_logic(
struct efx_nic *efx)
442 static bool txc43128_phy_read_link(
struct efx_nic *efx)
447 static int txc43128_phy_reconfigure(
struct efx_nic *efx)
455 txc_apply_defaults(efx);
457 mode_change &= ~PHY_MODE_TX_DISABLED;
469 if (loop_change || mode_change)
470 txc_reset_logic(efx);
478 static void txc43128_phy_fini(
struct efx_nic *efx)
484 static void txc43128_phy_remove(
struct efx_nic *efx)
492 static bool txc43128_phy_poll(
struct efx_nic *efx)
497 efx->
link_state.up = txc43128_phy_read_link(efx);
508 txc_reset_logic(efx);
515 static const char *
const txc43128_test_names[] = {
519 static const char *txc43128_test_name(
struct efx_nic *efx,
unsigned int index)
522 return txc43128_test_names[
index];
526 static int txc43128_run_tests(
struct efx_nic *efx,
int *results,
unsigned flags)
533 rc = txc_reset_phy(efx);
538 txc_apply_defaults(efx);
539 results[0] = rc ? -1 : 1;
545 mdio45_ethtool_gset(&efx->
mdio, ecmd);
549 .probe = txc43128_phy_probe,
550 .init = txc43128_phy_init,
551 .reconfigure = txc43128_phy_reconfigure,
552 .poll = txc43128_phy_poll,
553 .fini = txc43128_phy_fini,
554 .remove = txc43128_phy_remove,
555 .get_settings = txc43128_get_settings,
558 .run_tests = txc43128_run_tests,
559 .test_name = txc43128_test_name,