serdes.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  1. /*
  2. * Marvell 88E6xxx SERDES manipulation, via SMI bus
  3. *
  4. * Copyright (c) 2008 Marvell Semiconductor
  5. *
  6. * Copyright (c) 2017 Andrew Lunn <andrew@lunn.ch>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. */
  13. #include <linux/interrupt.h>
  14. #include <linux/irqdomain.h>
  15. #include <linux/mii.h>
  16. #include "chip.h"
  17. #include "global2.h"
  18. #include "phy.h"
  19. #include "port.h"
  20. #include "serdes.h"
  21. static int mv88e6352_serdes_read(struct mv88e6xxx_chip *chip, int reg,
  22. u16 *val)
  23. {
  24. return mv88e6xxx_phy_page_read(chip, MV88E6352_ADDR_SERDES,
  25. MV88E6352_SERDES_PAGE_FIBER,
  26. reg, val);
  27. }
  28. static int mv88e6352_serdes_write(struct mv88e6xxx_chip *chip, int reg,
  29. u16 val)
  30. {
  31. return mv88e6xxx_phy_page_write(chip, MV88E6352_ADDR_SERDES,
  32. MV88E6352_SERDES_PAGE_FIBER,
  33. reg, val);
  34. }
  35. static int mv88e6390_serdes_read(struct mv88e6xxx_chip *chip,
  36. int lane, int device, int reg, u16 *val)
  37. {
  38. int reg_c45 = MII_ADDR_C45 | device << 16 | reg;
  39. return mv88e6xxx_phy_read(chip, lane, reg_c45, val);
  40. }
  41. static int mv88e6390_serdes_write(struct mv88e6xxx_chip *chip,
  42. int lane, int device, int reg, u16 val)
  43. {
  44. int reg_c45 = MII_ADDR_C45 | device << 16 | reg;
  45. return mv88e6xxx_phy_write(chip, lane, reg_c45, val);
  46. }
  47. static int mv88e6352_serdes_power_set(struct mv88e6xxx_chip *chip, bool on)
  48. {
  49. u16 val, new_val;
  50. int err;
  51. err = mv88e6352_serdes_read(chip, MII_BMCR, &val);
  52. if (err)
  53. return err;
  54. if (on)
  55. new_val = val & ~BMCR_PDOWN;
  56. else
  57. new_val = val | BMCR_PDOWN;
  58. if (val != new_val)
  59. err = mv88e6352_serdes_write(chip, MII_BMCR, new_val);
  60. return err;
  61. }
  62. static bool mv88e6352_port_has_serdes(struct mv88e6xxx_chip *chip, int port)
  63. {
  64. u8 cmode = chip->ports[port].cmode;
  65. if ((cmode == MV88E6XXX_PORT_STS_CMODE_100BASE_X) ||
  66. (cmode == MV88E6XXX_PORT_STS_CMODE_1000BASE_X) ||
  67. (cmode == MV88E6XXX_PORT_STS_CMODE_SGMII))
  68. return true;
  69. return false;
  70. }
  71. int mv88e6352_serdes_power(struct mv88e6xxx_chip *chip, int port, bool on)
  72. {
  73. int err;
  74. if (mv88e6352_port_has_serdes(chip, port)) {
  75. err = mv88e6352_serdes_power_set(chip, on);
  76. if (err < 0)
  77. return err;
  78. }
  79. return 0;
  80. }
  81. struct mv88e6352_serdes_hw_stat {
  82. char string[ETH_GSTRING_LEN];
  83. int sizeof_stat;
  84. int reg;
  85. };
  86. static struct mv88e6352_serdes_hw_stat mv88e6352_serdes_hw_stats[] = {
  87. { "serdes_fibre_rx_error", 16, 21 },
  88. { "serdes_PRBS_error", 32, 24 },
  89. };
  90. int mv88e6352_serdes_get_sset_count(struct mv88e6xxx_chip *chip, int port)
  91. {
  92. if (mv88e6352_port_has_serdes(chip, port))
  93. return ARRAY_SIZE(mv88e6352_serdes_hw_stats);
  94. return 0;
  95. }
  96. int mv88e6352_serdes_get_strings(struct mv88e6xxx_chip *chip,
  97. int port, uint8_t *data)
  98. {
  99. struct mv88e6352_serdes_hw_stat *stat;
  100. int i;
  101. if (!mv88e6352_port_has_serdes(chip, port))
  102. return 0;
  103. for (i = 0; i < ARRAY_SIZE(mv88e6352_serdes_hw_stats); i++) {
  104. stat = &mv88e6352_serdes_hw_stats[i];
  105. memcpy(data + i * ETH_GSTRING_LEN, stat->string,
  106. ETH_GSTRING_LEN);
  107. }
  108. return ARRAY_SIZE(mv88e6352_serdes_hw_stats);
  109. }
  110. static uint64_t mv88e6352_serdes_get_stat(struct mv88e6xxx_chip *chip,
  111. struct mv88e6352_serdes_hw_stat *stat)
  112. {
  113. u64 val = 0;
  114. u16 reg;
  115. int err;
  116. err = mv88e6352_serdes_read(chip, stat->reg, &reg);
  117. if (err) {
  118. dev_err(chip->dev, "failed to read statistic\n");
  119. return 0;
  120. }
  121. val = reg;
  122. if (stat->sizeof_stat == 32) {
  123. err = mv88e6352_serdes_read(chip, stat->reg + 1, &reg);
  124. if (err) {
  125. dev_err(chip->dev, "failed to read statistic\n");
  126. return 0;
  127. }
  128. val = val << 16 | reg;
  129. }
  130. return val;
  131. }
  132. int mv88e6352_serdes_get_stats(struct mv88e6xxx_chip *chip, int port,
  133. uint64_t *data)
  134. {
  135. struct mv88e6xxx_port *mv88e6xxx_port = &chip->ports[port];
  136. struct mv88e6352_serdes_hw_stat *stat;
  137. u64 value;
  138. int i;
  139. if (!mv88e6352_port_has_serdes(chip, port))
  140. return 0;
  141. BUILD_BUG_ON(ARRAY_SIZE(mv88e6352_serdes_hw_stats) >
  142. ARRAY_SIZE(mv88e6xxx_port->serdes_stats));
  143. for (i = 0; i < ARRAY_SIZE(mv88e6352_serdes_hw_stats); i++) {
  144. stat = &mv88e6352_serdes_hw_stats[i];
  145. value = mv88e6352_serdes_get_stat(chip, stat);
  146. mv88e6xxx_port->serdes_stats[i] += value;
  147. data[i] = mv88e6xxx_port->serdes_stats[i];
  148. }
  149. return ARRAY_SIZE(mv88e6352_serdes_hw_stats);
  150. }
  151. /* Return the SERDES lane address a port is using. Only Ports 9 and 10
  152. * have SERDES lanes. Returns -ENODEV if a port does not have a lane.
  153. */
  154. static int mv88e6390_serdes_get_lane(struct mv88e6xxx_chip *chip, int port)
  155. {
  156. u8 cmode = chip->ports[port].cmode;
  157. switch (port) {
  158. case 9:
  159. if (cmode == MV88E6XXX_PORT_STS_CMODE_1000BASE_X ||
  160. cmode == MV88E6XXX_PORT_STS_CMODE_SGMII ||
  161. cmode == MV88E6XXX_PORT_STS_CMODE_2500BASEX)
  162. return MV88E6390_PORT9_LANE0;
  163. return -ENODEV;
  164. case 10:
  165. if (cmode == MV88E6XXX_PORT_STS_CMODE_1000BASE_X ||
  166. cmode == MV88E6XXX_PORT_STS_CMODE_SGMII ||
  167. cmode == MV88E6XXX_PORT_STS_CMODE_2500BASEX)
  168. return MV88E6390_PORT10_LANE0;
  169. return -ENODEV;
  170. default:
  171. return -ENODEV;
  172. }
  173. }
  174. /* Return the SERDES lane address a port is using. Ports 9 and 10 can
  175. * use multiple lanes. If so, return the first lane the port uses.
  176. * Returns -ENODEV if a port does not have a lane.
  177. */
  178. int mv88e6390x_serdes_get_lane(struct mv88e6xxx_chip *chip, int port)
  179. {
  180. u8 cmode_port9, cmode_port10, cmode_port;
  181. cmode_port9 = chip->ports[9].cmode;
  182. cmode_port10 = chip->ports[10].cmode;
  183. cmode_port = chip->ports[port].cmode;
  184. switch (port) {
  185. case 2:
  186. if (cmode_port9 == MV88E6XXX_PORT_STS_CMODE_1000BASE_X ||
  187. cmode_port9 == MV88E6XXX_PORT_STS_CMODE_SGMII ||
  188. cmode_port9 == MV88E6XXX_PORT_STS_CMODE_2500BASEX)
  189. if (cmode_port == MV88E6XXX_PORT_STS_CMODE_1000BASE_X)
  190. return MV88E6390_PORT9_LANE1;
  191. return -ENODEV;
  192. case 3:
  193. if (cmode_port9 == MV88E6XXX_PORT_STS_CMODE_1000BASE_X ||
  194. cmode_port9 == MV88E6XXX_PORT_STS_CMODE_SGMII ||
  195. cmode_port9 == MV88E6XXX_PORT_STS_CMODE_2500BASEX ||
  196. cmode_port9 == MV88E6XXX_PORT_STS_CMODE_RXAUI)
  197. if (cmode_port == MV88E6XXX_PORT_STS_CMODE_1000BASE_X)
  198. return MV88E6390_PORT9_LANE2;
  199. return -ENODEV;
  200. case 4:
  201. if (cmode_port9 == MV88E6XXX_PORT_STS_CMODE_1000BASE_X ||
  202. cmode_port9 == MV88E6XXX_PORT_STS_CMODE_SGMII ||
  203. cmode_port9 == MV88E6XXX_PORT_STS_CMODE_2500BASEX ||
  204. cmode_port9 == MV88E6XXX_PORT_STS_CMODE_RXAUI)
  205. if (cmode_port == MV88E6XXX_PORT_STS_CMODE_1000BASE_X)
  206. return MV88E6390_PORT9_LANE3;
  207. return -ENODEV;
  208. case 5:
  209. if (cmode_port10 == MV88E6XXX_PORT_STS_CMODE_1000BASE_X ||
  210. cmode_port10 == MV88E6XXX_PORT_STS_CMODE_SGMII ||
  211. cmode_port10 == MV88E6XXX_PORT_STS_CMODE_2500BASEX)
  212. if (cmode_port == MV88E6XXX_PORT_STS_CMODE_1000BASE_X)
  213. return MV88E6390_PORT10_LANE1;
  214. return -ENODEV;
  215. case 6:
  216. if (cmode_port10 == MV88E6XXX_PORT_STS_CMODE_1000BASE_X ||
  217. cmode_port10 == MV88E6XXX_PORT_STS_CMODE_SGMII ||
  218. cmode_port10 == MV88E6XXX_PORT_STS_CMODE_2500BASEX ||
  219. cmode_port10 == MV88E6XXX_PORT_STS_CMODE_RXAUI)
  220. if (cmode_port == MV88E6XXX_PORT_STS_CMODE_1000BASE_X)
  221. return MV88E6390_PORT10_LANE2;
  222. return -ENODEV;
  223. case 7:
  224. if (cmode_port10 == MV88E6XXX_PORT_STS_CMODE_1000BASE_X ||
  225. cmode_port10 == MV88E6XXX_PORT_STS_CMODE_SGMII ||
  226. cmode_port10 == MV88E6XXX_PORT_STS_CMODE_2500BASEX ||
  227. cmode_port10 == MV88E6XXX_PORT_STS_CMODE_RXAUI)
  228. if (cmode_port == MV88E6XXX_PORT_STS_CMODE_1000BASE_X)
  229. return MV88E6390_PORT10_LANE3;
  230. return -ENODEV;
  231. case 9:
  232. if (cmode_port9 == MV88E6XXX_PORT_STS_CMODE_1000BASE_X ||
  233. cmode_port9 == MV88E6XXX_PORT_STS_CMODE_SGMII ||
  234. cmode_port9 == MV88E6XXX_PORT_STS_CMODE_2500BASEX ||
  235. cmode_port9 == MV88E6XXX_PORT_STS_CMODE_XAUI ||
  236. cmode_port9 == MV88E6XXX_PORT_STS_CMODE_RXAUI)
  237. return MV88E6390_PORT9_LANE0;
  238. return -ENODEV;
  239. case 10:
  240. if (cmode_port10 == MV88E6XXX_PORT_STS_CMODE_1000BASE_X ||
  241. cmode_port10 == MV88E6XXX_PORT_STS_CMODE_SGMII ||
  242. cmode_port10 == MV88E6XXX_PORT_STS_CMODE_2500BASEX ||
  243. cmode_port10 == MV88E6XXX_PORT_STS_CMODE_XAUI ||
  244. cmode_port10 == MV88E6XXX_PORT_STS_CMODE_RXAUI)
  245. return MV88E6390_PORT10_LANE0;
  246. return -ENODEV;
  247. default:
  248. return -ENODEV;
  249. }
  250. }
  251. /* Set the power on/off for 10GBASE-R and 10GBASE-X4/X2 */
  252. static int mv88e6390_serdes_power_10g(struct mv88e6xxx_chip *chip, int lane,
  253. bool on)
  254. {
  255. u16 val, new_val;
  256. int err;
  257. err = mv88e6390_serdes_read(chip, lane, MDIO_MMD_PHYXS,
  258. MV88E6390_PCS_CONTROL_1, &val);
  259. if (err)
  260. return err;
  261. if (on)
  262. new_val = val & ~(MV88E6390_PCS_CONTROL_1_RESET |
  263. MV88E6390_PCS_CONTROL_1_LOOPBACK |
  264. MV88E6390_PCS_CONTROL_1_PDOWN);
  265. else
  266. new_val = val | MV88E6390_PCS_CONTROL_1_PDOWN;
  267. if (val != new_val)
  268. err = mv88e6390_serdes_write(chip, lane, MDIO_MMD_PHYXS,
  269. MV88E6390_PCS_CONTROL_1, new_val);
  270. return err;
  271. }
  272. /* Set the power on/off for SGMII and 1000Base-X */
  273. static int mv88e6390_serdes_power_sgmii(struct mv88e6xxx_chip *chip, int lane,
  274. bool on)
  275. {
  276. u16 val, new_val;
  277. int err;
  278. err = mv88e6390_serdes_read(chip, lane, MDIO_MMD_PHYXS,
  279. MV88E6390_SGMII_CONTROL, &val);
  280. if (err)
  281. return err;
  282. if (on)
  283. new_val = val & ~(MV88E6390_SGMII_CONTROL_RESET |
  284. MV88E6390_SGMII_CONTROL_LOOPBACK |
  285. MV88E6390_SGMII_CONTROL_PDOWN);
  286. else
  287. new_val = val | MV88E6390_SGMII_CONTROL_PDOWN;
  288. if (val != new_val)
  289. err = mv88e6390_serdes_write(chip, lane, MDIO_MMD_PHYXS,
  290. MV88E6390_SGMII_CONTROL, new_val);
  291. return err;
  292. }
  293. static int mv88e6390_serdes_power_lane(struct mv88e6xxx_chip *chip, int port,
  294. int lane, bool on)
  295. {
  296. u8 cmode = chip->ports[port].cmode;
  297. switch (cmode) {
  298. case MV88E6XXX_PORT_STS_CMODE_SGMII:
  299. case MV88E6XXX_PORT_STS_CMODE_1000BASE_X:
  300. case MV88E6XXX_PORT_STS_CMODE_2500BASEX:
  301. return mv88e6390_serdes_power_sgmii(chip, lane, on);
  302. case MV88E6XXX_PORT_STS_CMODE_XAUI:
  303. case MV88E6XXX_PORT_STS_CMODE_RXAUI:
  304. return mv88e6390_serdes_power_10g(chip, lane, on);
  305. }
  306. return 0;
  307. }
  308. int mv88e6390_serdes_power(struct mv88e6xxx_chip *chip, int port, bool on)
  309. {
  310. int lane;
  311. lane = mv88e6390_serdes_get_lane(chip, port);
  312. if (lane == -ENODEV)
  313. return 0;
  314. if (lane < 0)
  315. return lane;
  316. switch (port) {
  317. case 9 ... 10:
  318. return mv88e6390_serdes_power_lane(chip, port, lane, on);
  319. }
  320. return 0;
  321. }
  322. int mv88e6390x_serdes_power(struct mv88e6xxx_chip *chip, int port, bool on)
  323. {
  324. int lane;
  325. lane = mv88e6390x_serdes_get_lane(chip, port);
  326. if (lane == -ENODEV)
  327. return 0;
  328. if (lane < 0)
  329. return lane;
  330. switch (port) {
  331. case 2 ... 4:
  332. case 5 ... 7:
  333. case 9 ... 10:
  334. return mv88e6390_serdes_power_lane(chip, port, lane, on);
  335. }
  336. return 0;
  337. }
  338. static void mv88e6390_serdes_irq_link_sgmii(struct mv88e6xxx_chip *chip,
  339. int port, int lane)
  340. {
  341. struct dsa_switch *ds = chip->ds;
  342. u16 status;
  343. bool up;
  344. mv88e6390_serdes_read(chip, lane, MDIO_MMD_PHYXS,
  345. MV88E6390_SGMII_STATUS, &status);
  346. /* Status must be read twice in order to give the current link
  347. * status. Otherwise the change in link status since the last
  348. * read of the register is returned.
  349. */
  350. mv88e6390_serdes_read(chip, lane, MDIO_MMD_PHYXS,
  351. MV88E6390_SGMII_STATUS, &status);
  352. up = status & MV88E6390_SGMII_STATUS_LINK;
  353. dsa_port_phylink_mac_change(ds, port, up);
  354. }
  355. static int mv88e6390_serdes_irq_enable_sgmii(struct mv88e6xxx_chip *chip,
  356. int lane)
  357. {
  358. return mv88e6390_serdes_write(chip, lane, MDIO_MMD_PHYXS,
  359. MV88E6390_SGMII_INT_ENABLE,
  360. MV88E6390_SGMII_INT_LINK_DOWN |
  361. MV88E6390_SGMII_INT_LINK_UP);
  362. }
  363. static int mv88e6390_serdes_irq_disable_sgmii(struct mv88e6xxx_chip *chip,
  364. int lane)
  365. {
  366. return mv88e6390_serdes_write(chip, lane, MDIO_MMD_PHYXS,
  367. MV88E6390_SGMII_INT_ENABLE, 0);
  368. }
  369. int mv88e6390_serdes_irq_enable(struct mv88e6xxx_chip *chip, int port,
  370. int lane)
  371. {
  372. u8 cmode = chip->ports[port].cmode;
  373. int err = 0;
  374. switch (cmode) {
  375. case MV88E6XXX_PORT_STS_CMODE_SGMII:
  376. case MV88E6XXX_PORT_STS_CMODE_1000BASE_X:
  377. case MV88E6XXX_PORT_STS_CMODE_2500BASEX:
  378. err = mv88e6390_serdes_irq_enable_sgmii(chip, lane);
  379. }
  380. return err;
  381. }
  382. int mv88e6390_serdes_irq_disable(struct mv88e6xxx_chip *chip, int port,
  383. int lane)
  384. {
  385. u8 cmode = chip->ports[port].cmode;
  386. int err = 0;
  387. switch (cmode) {
  388. case MV88E6XXX_PORT_STS_CMODE_SGMII:
  389. case MV88E6XXX_PORT_STS_CMODE_1000BASE_X:
  390. case MV88E6XXX_PORT_STS_CMODE_2500BASEX:
  391. err = mv88e6390_serdes_irq_disable_sgmii(chip, lane);
  392. }
  393. return err;
  394. }
  395. static int mv88e6390_serdes_irq_status_sgmii(struct mv88e6xxx_chip *chip,
  396. int lane, u16 *status)
  397. {
  398. int err;
  399. err = mv88e6390_serdes_read(chip, lane, MDIO_MMD_PHYXS,
  400. MV88E6390_SGMII_INT_STATUS, status);
  401. return err;
  402. }
  403. static irqreturn_t mv88e6390_serdes_thread_fn(int irq, void *dev_id)
  404. {
  405. struct mv88e6xxx_port *port = dev_id;
  406. struct mv88e6xxx_chip *chip = port->chip;
  407. irqreturn_t ret = IRQ_NONE;
  408. u8 cmode = port->cmode;
  409. u16 status;
  410. int lane;
  411. int err;
  412. lane = mv88e6390x_serdes_get_lane(chip, port->port);
  413. mutex_lock(&chip->reg_lock);
  414. switch (cmode) {
  415. case MV88E6XXX_PORT_STS_CMODE_SGMII:
  416. case MV88E6XXX_PORT_STS_CMODE_1000BASE_X:
  417. case MV88E6XXX_PORT_STS_CMODE_2500BASEX:
  418. err = mv88e6390_serdes_irq_status_sgmii(chip, lane, &status);
  419. if (err)
  420. goto out;
  421. if (status & (MV88E6390_SGMII_INT_LINK_DOWN |
  422. MV88E6390_SGMII_INT_LINK_UP)) {
  423. ret = IRQ_HANDLED;
  424. mv88e6390_serdes_irq_link_sgmii(chip, port->port, lane);
  425. }
  426. }
  427. out:
  428. mutex_unlock(&chip->reg_lock);
  429. return ret;
  430. }
  431. int mv88e6390_serdes_irq_setup(struct mv88e6xxx_chip *chip, int port)
  432. {
  433. int lane;
  434. int err;
  435. /* Only support ports 9 and 10 at the moment */
  436. if (port < 9)
  437. return 0;
  438. lane = mv88e6390x_serdes_get_lane(chip, port);
  439. if (lane == -ENODEV)
  440. return 0;
  441. if (lane < 0)
  442. return lane;
  443. chip->ports[port].serdes_irq = irq_find_mapping(chip->g2_irq.domain,
  444. port);
  445. if (chip->ports[port].serdes_irq < 0) {
  446. dev_err(chip->dev, "Unable to map SERDES irq: %d\n",
  447. chip->ports[port].serdes_irq);
  448. return chip->ports[port].serdes_irq;
  449. }
  450. /* Requesting the IRQ will trigger irq callbacks. So we cannot
  451. * hold the reg_lock.
  452. */
  453. mutex_unlock(&chip->reg_lock);
  454. err = request_threaded_irq(chip->ports[port].serdes_irq, NULL,
  455. mv88e6390_serdes_thread_fn,
  456. IRQF_ONESHOT, "mv88e6xxx-serdes",
  457. &chip->ports[port]);
  458. mutex_lock(&chip->reg_lock);
  459. if (err) {
  460. dev_err(chip->dev, "Unable to request SERDES interrupt: %d\n",
  461. err);
  462. return err;
  463. }
  464. return mv88e6390_serdes_irq_enable(chip, port, lane);
  465. }
  466. void mv88e6390_serdes_irq_free(struct mv88e6xxx_chip *chip, int port)
  467. {
  468. int lane = mv88e6390x_serdes_get_lane(chip, port);
  469. if (port < 9)
  470. return;
  471. if (lane < 0)
  472. return;
  473. mv88e6390_serdes_irq_disable(chip, port, lane);
  474. /* Freeing the IRQ will trigger irq callbacks. So we cannot
  475. * hold the reg_lock.
  476. */
  477. mutex_unlock(&chip->reg_lock);
  478. free_irq(chip->ports[port].serdes_irq, &chip->ports[port]);
  479. mutex_lock(&chip->reg_lock);
  480. chip->ports[port].serdes_irq = 0;
  481. }
  482. int mv88e6341_serdes_power(struct mv88e6xxx_chip *chip, int port, bool on)
  483. {
  484. u8 cmode = chip->ports[port].cmode;
  485. if (port != 5)
  486. return 0;
  487. if (cmode == MV88E6XXX_PORT_STS_CMODE_1000BASE_X ||
  488. cmode == MV88E6XXX_PORT_STS_CMODE_SGMII ||
  489. cmode == MV88E6XXX_PORT_STS_CMODE_2500BASEX)
  490. return mv88e6390_serdes_power_sgmii(chip, MV88E6341_ADDR_SERDES,
  491. on);
  492. return 0;
  493. }