txc43128_phy.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  1. /****************************************************************************
  2. * Driver for Solarflare network controllers and boards
  3. * Copyright 2006-2011 Solarflare Communications Inc.
  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. * Driver for Transwitch/Mysticom CX4 retimer
  11. * see www.transwitch.com, part is TXC-43128
  12. */
  13. #include <linux/delay.h>
  14. #include <linux/slab.h>
  15. #include "efx.h"
  16. #include "mdio_10g.h"
  17. #include "phy.h"
  18. #include "nic.h"
  19. /* We expect these MMDs to be in the package */
  20. #define TXC_REQUIRED_DEVS (MDIO_DEVS_PCS | \
  21. MDIO_DEVS_PMAPMD | \
  22. MDIO_DEVS_PHYXS)
  23. #define TXC_LOOPBACKS ((1 << LOOPBACK_PCS) | \
  24. (1 << LOOPBACK_PMAPMD) | \
  25. (1 << LOOPBACK_PHYXS_WS))
  26. /**************************************************************************
  27. *
  28. * Compile-time config
  29. *
  30. **************************************************************************
  31. */
  32. #define TXCNAME "TXC43128"
  33. /* Total length of time we'll wait for the PHY to come out of reset (ms) */
  34. #define TXC_MAX_RESET_TIME 500
  35. /* Interval between checks (ms) */
  36. #define TXC_RESET_WAIT 10
  37. /* How long to run BIST (us) */
  38. #define TXC_BIST_DURATION 50
  39. /**************************************************************************
  40. *
  41. * Register definitions
  42. *
  43. **************************************************************************
  44. */
  45. /* Command register */
  46. #define TXC_GLRGS_GLCMD 0xc004
  47. /* Useful bits in command register */
  48. /* Lane power-down */
  49. #define TXC_GLCMD_L01PD_LBN 5
  50. #define TXC_GLCMD_L23PD_LBN 6
  51. /* Limited SW reset: preserves configuration but
  52. * initiates a logic reset. Self-clearing */
  53. #define TXC_GLCMD_LMTSWRST_LBN 14
  54. /* Signal Quality Control */
  55. #define TXC_GLRGS_GSGQLCTL 0xc01a
  56. /* Enable bit */
  57. #define TXC_GSGQLCT_SGQLEN_LBN 15
  58. /* Lane selection */
  59. #define TXC_GSGQLCT_LNSL_LBN 13
  60. #define TXC_GSGQLCT_LNSL_WIDTH 2
  61. /* Analog TX control */
  62. #define TXC_ALRGS_ATXCTL 0xc040
  63. /* Lane power-down */
  64. #define TXC_ATXCTL_TXPD3_LBN 15
  65. #define TXC_ATXCTL_TXPD2_LBN 14
  66. #define TXC_ATXCTL_TXPD1_LBN 13
  67. #define TXC_ATXCTL_TXPD0_LBN 12
  68. /* Amplitude on lanes 0, 1 */
  69. #define TXC_ALRGS_ATXAMP0 0xc041
  70. /* Amplitude on lanes 2, 3 */
  71. #define TXC_ALRGS_ATXAMP1 0xc042
  72. /* Bit position of value for lane 0 (or 2) */
  73. #define TXC_ATXAMP_LANE02_LBN 3
  74. /* Bit position of value for lane 1 (or 3) */
  75. #define TXC_ATXAMP_LANE13_LBN 11
  76. #define TXC_ATXAMP_1280_mV 0
  77. #define TXC_ATXAMP_1200_mV 8
  78. #define TXC_ATXAMP_1120_mV 12
  79. #define TXC_ATXAMP_1060_mV 14
  80. #define TXC_ATXAMP_0820_mV 25
  81. #define TXC_ATXAMP_0720_mV 26
  82. #define TXC_ATXAMP_0580_mV 27
  83. #define TXC_ATXAMP_0440_mV 28
  84. #define TXC_ATXAMP_0820_BOTH \
  85. ((TXC_ATXAMP_0820_mV << TXC_ATXAMP_LANE02_LBN) \
  86. | (TXC_ATXAMP_0820_mV << TXC_ATXAMP_LANE13_LBN))
  87. #define TXC_ATXAMP_DEFAULT 0x6060 /* From databook */
  88. /* Preemphasis on lanes 0, 1 */
  89. #define TXC_ALRGS_ATXPRE0 0xc043
  90. /* Preemphasis on lanes 2, 3 */
  91. #define TXC_ALRGS_ATXPRE1 0xc044
  92. #define TXC_ATXPRE_NONE 0
  93. #define TXC_ATXPRE_DEFAULT 0x1010 /* From databook */
  94. #define TXC_ALRGS_ARXCTL 0xc045
  95. /* Lane power-down */
  96. #define TXC_ARXCTL_RXPD3_LBN 15
  97. #define TXC_ARXCTL_RXPD2_LBN 14
  98. #define TXC_ARXCTL_RXPD1_LBN 13
  99. #define TXC_ARXCTL_RXPD0_LBN 12
  100. /* Main control */
  101. #define TXC_MRGS_CTL 0xc340
  102. /* Bits in main control */
  103. #define TXC_MCTL_RESET_LBN 15 /* Self clear */
  104. #define TXC_MCTL_TXLED_LBN 14 /* 1 to show align status */
  105. #define TXC_MCTL_RXLED_LBN 13 /* 1 to show align status */
  106. /* GPIO output */
  107. #define TXC_GPIO_OUTPUT 0xc346
  108. #define TXC_GPIO_DIR 0xc348
  109. /* Vendor-specific BIST registers */
  110. #define TXC_BIST_CTL 0xc280
  111. #define TXC_BIST_TXFRMCNT 0xc281
  112. #define TXC_BIST_RX0FRMCNT 0xc282
  113. #define TXC_BIST_RX1FRMCNT 0xc283
  114. #define TXC_BIST_RX2FRMCNT 0xc284
  115. #define TXC_BIST_RX3FRMCNT 0xc285
  116. #define TXC_BIST_RX0ERRCNT 0xc286
  117. #define TXC_BIST_RX1ERRCNT 0xc287
  118. #define TXC_BIST_RX2ERRCNT 0xc288
  119. #define TXC_BIST_RX3ERRCNT 0xc289
  120. /* BIST type (controls bit patter in test) */
  121. #define TXC_BIST_CTRL_TYPE_LBN 10
  122. #define TXC_BIST_CTRL_TYPE_TSD 0 /* TranSwitch Deterministic */
  123. #define TXC_BIST_CTRL_TYPE_CRP 1 /* CRPAT standard */
  124. #define TXC_BIST_CTRL_TYPE_CJP 2 /* CJPAT standard */
  125. #define TXC_BIST_CTRL_TYPE_TSR 3 /* TranSwitch pseudo-random */
  126. /* Set this to 1 for 10 bit and 0 for 8 bit */
  127. #define TXC_BIST_CTRL_B10EN_LBN 12
  128. /* Enable BIST (write 0 to disable) */
  129. #define TXC_BIST_CTRL_ENAB_LBN 13
  130. /* Stop BIST (self-clears when stop complete) */
  131. #define TXC_BIST_CTRL_STOP_LBN 14
  132. /* Start BIST (cleared by writing 1 to STOP) */
  133. #define TXC_BIST_CTRL_STRT_LBN 15
  134. /* Mt. Diablo test configuration */
  135. #define TXC_MTDIABLO_CTRL 0xc34f
  136. #define TXC_MTDIABLO_CTRL_PMA_LOOP_LBN 10
  137. struct txc43128_data {
  138. unsigned long bug10934_timer;
  139. enum efx_phy_mode phy_mode;
  140. enum efx_loopback_mode loopback_mode;
  141. };
  142. /* The PHY sometimes needs a reset to bring the link back up. So long as
  143. * it reports link down, we reset it every 5 seconds.
  144. */
  145. #define BUG10934_RESET_INTERVAL (5 * HZ)
  146. /* Perform a reset that doesn't clear configuration changes */
  147. static void txc_reset_logic(struct efx_nic *efx);
  148. /* Set the output value of a gpio */
  149. void falcon_txc_set_gpio_val(struct efx_nic *efx, int pin, int on)
  150. {
  151. efx_mdio_set_flag(efx, MDIO_MMD_PHYXS, TXC_GPIO_OUTPUT, 1 << pin, on);
  152. }
  153. /* Set up the GPIO direction register */
  154. void falcon_txc_set_gpio_dir(struct efx_nic *efx, int pin, int dir)
  155. {
  156. efx_mdio_set_flag(efx, MDIO_MMD_PHYXS, TXC_GPIO_DIR, 1 << pin, dir);
  157. }
  158. /* Reset the PMA/PMD MMD. The documentation is explicit that this does a
  159. * global reset (it's less clear what reset of other MMDs does).*/
  160. static int txc_reset_phy(struct efx_nic *efx)
  161. {
  162. int rc = efx_mdio_reset_mmd(efx, MDIO_MMD_PMAPMD,
  163. TXC_MAX_RESET_TIME / TXC_RESET_WAIT,
  164. TXC_RESET_WAIT);
  165. if (rc < 0)
  166. goto fail;
  167. /* Check that all the MMDs we expect are present and responding. */
  168. rc = efx_mdio_check_mmds(efx, TXC_REQUIRED_DEVS);
  169. if (rc < 0)
  170. goto fail;
  171. return 0;
  172. fail:
  173. netif_err(efx, hw, efx->net_dev, TXCNAME ": reset timed out!\n");
  174. return rc;
  175. }
  176. /* Run a single BIST on one MMD */
  177. static int txc_bist_one(struct efx_nic *efx, int mmd, int test)
  178. {
  179. int ctrl, bctl;
  180. int lane;
  181. int rc = 0;
  182. /* Set PMA to test into loopback using Mt Diablo reg as per app note */
  183. ctrl = efx_mdio_read(efx, MDIO_MMD_PCS, TXC_MTDIABLO_CTRL);
  184. ctrl |= (1 << TXC_MTDIABLO_CTRL_PMA_LOOP_LBN);
  185. efx_mdio_write(efx, MDIO_MMD_PCS, TXC_MTDIABLO_CTRL, ctrl);
  186. /* The BIST app. note lists these as 3 distinct steps. */
  187. /* Set the BIST type */
  188. bctl = (test << TXC_BIST_CTRL_TYPE_LBN);
  189. efx_mdio_write(efx, mmd, TXC_BIST_CTL, bctl);
  190. /* Set the BSTEN bit in the BIST Control register to enable */
  191. bctl |= (1 << TXC_BIST_CTRL_ENAB_LBN);
  192. efx_mdio_write(efx, mmd, TXC_BIST_CTL, bctl);
  193. /* Set the BSTRT bit in the BIST Control register */
  194. efx_mdio_write(efx, mmd, TXC_BIST_CTL,
  195. bctl | (1 << TXC_BIST_CTRL_STRT_LBN));
  196. /* Wait. */
  197. udelay(TXC_BIST_DURATION);
  198. /* Set the BSTOP bit in the BIST Control register */
  199. bctl |= (1 << TXC_BIST_CTRL_STOP_LBN);
  200. efx_mdio_write(efx, mmd, TXC_BIST_CTL, bctl);
  201. /* The STOP bit should go off when things have stopped */
  202. while (bctl & (1 << TXC_BIST_CTRL_STOP_LBN))
  203. bctl = efx_mdio_read(efx, mmd, TXC_BIST_CTL);
  204. /* Check all the error counts are 0 and all the frame counts are
  205. non-zero */
  206. for (lane = 0; lane < 4; lane++) {
  207. int count = efx_mdio_read(efx, mmd, TXC_BIST_RX0ERRCNT + lane);
  208. if (count != 0) {
  209. netif_err(efx, hw, efx->net_dev, TXCNAME": BIST error. "
  210. "Lane %d had %d errs\n", lane, count);
  211. rc = -EIO;
  212. }
  213. count = efx_mdio_read(efx, mmd, TXC_BIST_RX0FRMCNT + lane);
  214. if (count == 0) {
  215. netif_err(efx, hw, efx->net_dev, TXCNAME": BIST error. "
  216. "Lane %d got 0 frames\n", lane);
  217. rc = -EIO;
  218. }
  219. }
  220. if (rc == 0)
  221. netif_info(efx, hw, efx->net_dev, TXCNAME": BIST pass\n");
  222. /* Disable BIST */
  223. efx_mdio_write(efx, mmd, TXC_BIST_CTL, 0);
  224. /* Turn off loopback */
  225. ctrl &= ~(1 << TXC_MTDIABLO_CTRL_PMA_LOOP_LBN);
  226. efx_mdio_write(efx, MDIO_MMD_PCS, TXC_MTDIABLO_CTRL, ctrl);
  227. return rc;
  228. }
  229. static int txc_bist(struct efx_nic *efx)
  230. {
  231. return txc_bist_one(efx, MDIO_MMD_PCS, TXC_BIST_CTRL_TYPE_TSD);
  232. }
  233. /* Push the non-configurable defaults into the PHY. This must be
  234. * done after every full reset */
  235. static void txc_apply_defaults(struct efx_nic *efx)
  236. {
  237. int mctrl;
  238. /* Turn amplitude down and preemphasis off on the host side
  239. * (PHY<->MAC) as this is believed less likely to upset Falcon
  240. * and no adverse effects have been noted. It probably also
  241. * saves a picowatt or two */
  242. /* Turn off preemphasis */
  243. efx_mdio_write(efx, MDIO_MMD_PHYXS, TXC_ALRGS_ATXPRE0, TXC_ATXPRE_NONE);
  244. efx_mdio_write(efx, MDIO_MMD_PHYXS, TXC_ALRGS_ATXPRE1, TXC_ATXPRE_NONE);
  245. /* Turn down the amplitude */
  246. efx_mdio_write(efx, MDIO_MMD_PHYXS,
  247. TXC_ALRGS_ATXAMP0, TXC_ATXAMP_0820_BOTH);
  248. efx_mdio_write(efx, MDIO_MMD_PHYXS,
  249. TXC_ALRGS_ATXAMP1, TXC_ATXAMP_0820_BOTH);
  250. /* Set the line side amplitude and preemphasis to the databook
  251. * defaults as an erratum causes them to be 0 on at least some
  252. * PHY rev.s */
  253. efx_mdio_write(efx, MDIO_MMD_PMAPMD,
  254. TXC_ALRGS_ATXPRE0, TXC_ATXPRE_DEFAULT);
  255. efx_mdio_write(efx, MDIO_MMD_PMAPMD,
  256. TXC_ALRGS_ATXPRE1, TXC_ATXPRE_DEFAULT);
  257. efx_mdio_write(efx, MDIO_MMD_PMAPMD,
  258. TXC_ALRGS_ATXAMP0, TXC_ATXAMP_DEFAULT);
  259. efx_mdio_write(efx, MDIO_MMD_PMAPMD,
  260. TXC_ALRGS_ATXAMP1, TXC_ATXAMP_DEFAULT);
  261. /* Set up the LEDs */
  262. mctrl = efx_mdio_read(efx, MDIO_MMD_PHYXS, TXC_MRGS_CTL);
  263. /* Set the Green and Red LEDs to their default modes */
  264. mctrl &= ~((1 << TXC_MCTL_TXLED_LBN) | (1 << TXC_MCTL_RXLED_LBN));
  265. efx_mdio_write(efx, MDIO_MMD_PHYXS, TXC_MRGS_CTL, mctrl);
  266. /* Databook recommends doing this after configuration changes */
  267. txc_reset_logic(efx);
  268. falcon_board(efx)->type->init_phy(efx);
  269. }
  270. static int txc43128_phy_probe(struct efx_nic *efx)
  271. {
  272. struct txc43128_data *phy_data;
  273. /* Allocate phy private storage */
  274. phy_data = kzalloc(sizeof(*phy_data), GFP_KERNEL);
  275. if (!phy_data)
  276. return -ENOMEM;
  277. efx->phy_data = phy_data;
  278. phy_data->phy_mode = efx->phy_mode;
  279. efx->mdio.mmds = TXC_REQUIRED_DEVS;
  280. efx->mdio.mode_support = MDIO_SUPPORTS_C45 | MDIO_EMULATE_C22;
  281. efx->loopback_modes = TXC_LOOPBACKS | FALCON_XMAC_LOOPBACKS;
  282. return 0;
  283. }
  284. /* Initialisation entry point for this PHY driver */
  285. static int txc43128_phy_init(struct efx_nic *efx)
  286. {
  287. int rc;
  288. rc = txc_reset_phy(efx);
  289. if (rc < 0)
  290. return rc;
  291. rc = txc_bist(efx);
  292. if (rc < 0)
  293. return rc;
  294. txc_apply_defaults(efx);
  295. return 0;
  296. }
  297. /* Set the lane power down state in the global registers */
  298. static void txc_glrgs_lane_power(struct efx_nic *efx, int mmd)
  299. {
  300. int pd = (1 << TXC_GLCMD_L01PD_LBN) | (1 << TXC_GLCMD_L23PD_LBN);
  301. int ctl = efx_mdio_read(efx, mmd, TXC_GLRGS_GLCMD);
  302. if (!(efx->phy_mode & PHY_MODE_LOW_POWER))
  303. ctl &= ~pd;
  304. else
  305. ctl |= pd;
  306. efx_mdio_write(efx, mmd, TXC_GLRGS_GLCMD, ctl);
  307. }
  308. /* Set the lane power down state in the analog control registers */
  309. static void txc_analog_lane_power(struct efx_nic *efx, int mmd)
  310. {
  311. int txpd = (1 << TXC_ATXCTL_TXPD3_LBN) | (1 << TXC_ATXCTL_TXPD2_LBN)
  312. | (1 << TXC_ATXCTL_TXPD1_LBN) | (1 << TXC_ATXCTL_TXPD0_LBN);
  313. int rxpd = (1 << TXC_ARXCTL_RXPD3_LBN) | (1 << TXC_ARXCTL_RXPD2_LBN)
  314. | (1 << TXC_ARXCTL_RXPD1_LBN) | (1 << TXC_ARXCTL_RXPD0_LBN);
  315. int txctl = efx_mdio_read(efx, mmd, TXC_ALRGS_ATXCTL);
  316. int rxctl = efx_mdio_read(efx, mmd, TXC_ALRGS_ARXCTL);
  317. if (!(efx->phy_mode & PHY_MODE_LOW_POWER)) {
  318. txctl &= ~txpd;
  319. rxctl &= ~rxpd;
  320. } else {
  321. txctl |= txpd;
  322. rxctl |= rxpd;
  323. }
  324. efx_mdio_write(efx, mmd, TXC_ALRGS_ATXCTL, txctl);
  325. efx_mdio_write(efx, mmd, TXC_ALRGS_ARXCTL, rxctl);
  326. }
  327. static void txc_set_power(struct efx_nic *efx)
  328. {
  329. /* According to the data book, all the MMDs can do low power */
  330. efx_mdio_set_mmds_lpower(efx,
  331. !!(efx->phy_mode & PHY_MODE_LOW_POWER),
  332. TXC_REQUIRED_DEVS);
  333. /* Global register bank is in PCS, PHY XS. These control the host
  334. * side and line side settings respectively. */
  335. txc_glrgs_lane_power(efx, MDIO_MMD_PCS);
  336. txc_glrgs_lane_power(efx, MDIO_MMD_PHYXS);
  337. /* Analog register bank in PMA/PMD, PHY XS */
  338. txc_analog_lane_power(efx, MDIO_MMD_PMAPMD);
  339. txc_analog_lane_power(efx, MDIO_MMD_PHYXS);
  340. }
  341. static void txc_reset_logic_mmd(struct efx_nic *efx, int mmd)
  342. {
  343. int val = efx_mdio_read(efx, mmd, TXC_GLRGS_GLCMD);
  344. int tries = 50;
  345. val |= (1 << TXC_GLCMD_LMTSWRST_LBN);
  346. efx_mdio_write(efx, mmd, TXC_GLRGS_GLCMD, val);
  347. while (--tries) {
  348. val = efx_mdio_read(efx, mmd, TXC_GLRGS_GLCMD);
  349. if (!(val & (1 << TXC_GLCMD_LMTSWRST_LBN)))
  350. break;
  351. udelay(1);
  352. }
  353. if (!tries)
  354. netif_info(efx, hw, efx->net_dev,
  355. TXCNAME " Logic reset timed out!\n");
  356. }
  357. /* Perform a logic reset. This preserves the configuration registers
  358. * and is needed for some configuration changes to take effect */
  359. static void txc_reset_logic(struct efx_nic *efx)
  360. {
  361. /* The data sheet claims we can do the logic reset on either the
  362. * PCS or the PHYXS and the result is a reset of both host- and
  363. * line-side logic. */
  364. txc_reset_logic_mmd(efx, MDIO_MMD_PCS);
  365. }
  366. static bool txc43128_phy_read_link(struct efx_nic *efx)
  367. {
  368. return efx_mdio_links_ok(efx, TXC_REQUIRED_DEVS);
  369. }
  370. static int txc43128_phy_reconfigure(struct efx_nic *efx)
  371. {
  372. struct txc43128_data *phy_data = efx->phy_data;
  373. enum efx_phy_mode mode_change = efx->phy_mode ^ phy_data->phy_mode;
  374. bool loop_change = LOOPBACK_CHANGED(phy_data, efx, TXC_LOOPBACKS);
  375. if (efx->phy_mode & mode_change & PHY_MODE_TX_DISABLED) {
  376. txc_reset_phy(efx);
  377. txc_apply_defaults(efx);
  378. falcon_reset_xaui(efx);
  379. mode_change &= ~PHY_MODE_TX_DISABLED;
  380. }
  381. efx_mdio_transmit_disable(efx);
  382. efx_mdio_phy_reconfigure(efx);
  383. if (mode_change & PHY_MODE_LOW_POWER)
  384. txc_set_power(efx);
  385. /* The data sheet claims this is required after every reconfiguration
  386. * (note at end of 7.1), but we mustn't do it when nothing changes as
  387. * it glitches the link, and reconfigure gets called on link change,
  388. * so we get an IRQ storm on link up. */
  389. if (loop_change || mode_change)
  390. txc_reset_logic(efx);
  391. phy_data->phy_mode = efx->phy_mode;
  392. phy_data->loopback_mode = efx->loopback_mode;
  393. return 0;
  394. }
  395. static void txc43128_phy_fini(struct efx_nic *efx)
  396. {
  397. /* Disable link events */
  398. efx_mdio_write(efx, MDIO_MMD_PMAPMD, MDIO_PMA_LASI_CTRL, 0);
  399. }
  400. static void txc43128_phy_remove(struct efx_nic *efx)
  401. {
  402. kfree(efx->phy_data);
  403. efx->phy_data = NULL;
  404. }
  405. /* Periodic callback: this exists mainly to poll link status as we
  406. * don't use LASI interrupts */
  407. static bool txc43128_phy_poll(struct efx_nic *efx)
  408. {
  409. struct txc43128_data *data = efx->phy_data;
  410. bool was_up = efx->link_state.up;
  411. efx->link_state.up = txc43128_phy_read_link(efx);
  412. efx->link_state.speed = 10000;
  413. efx->link_state.fd = true;
  414. efx->link_state.fc = efx->wanted_fc;
  415. if (efx->link_state.up || (efx->loopback_mode != LOOPBACK_NONE)) {
  416. data->bug10934_timer = jiffies;
  417. } else {
  418. if (time_after_eq(jiffies, (data->bug10934_timer +
  419. BUG10934_RESET_INTERVAL))) {
  420. data->bug10934_timer = jiffies;
  421. txc_reset_logic(efx);
  422. }
  423. }
  424. return efx->link_state.up != was_up;
  425. }
  426. static const char *const txc43128_test_names[] = {
  427. "bist"
  428. };
  429. static const char *txc43128_test_name(struct efx_nic *efx, unsigned int index)
  430. {
  431. if (index < ARRAY_SIZE(txc43128_test_names))
  432. return txc43128_test_names[index];
  433. return NULL;
  434. }
  435. static int txc43128_run_tests(struct efx_nic *efx, int *results, unsigned flags)
  436. {
  437. int rc;
  438. if (!(flags & ETH_TEST_FL_OFFLINE))
  439. return 0;
  440. rc = txc_reset_phy(efx);
  441. if (rc < 0)
  442. return rc;
  443. rc = txc_bist(efx);
  444. txc_apply_defaults(efx);
  445. results[0] = rc ? -1 : 1;
  446. return rc;
  447. }
  448. static void txc43128_get_settings(struct efx_nic *efx, struct ethtool_cmd *ecmd)
  449. {
  450. mdio45_ethtool_gset(&efx->mdio, ecmd);
  451. }
  452. const struct efx_phy_operations falcon_txc_phy_ops = {
  453. .probe = txc43128_phy_probe,
  454. .init = txc43128_phy_init,
  455. .reconfigure = txc43128_phy_reconfigure,
  456. .poll = txc43128_phy_poll,
  457. .fini = txc43128_phy_fini,
  458. .remove = txc43128_phy_remove,
  459. .get_settings = txc43128_get_settings,
  460. .set_settings = efx_mdio_set_settings,
  461. .test_alive = efx_mdio_test_alive,
  462. .run_tests = txc43128_run_tests,
  463. .test_name = txc43128_test_name,
  464. };