marvell.c 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215
  1. /*
  2. * drivers/net/phy/marvell.c
  3. *
  4. * Driver for Marvell PHYs
  5. *
  6. * Author: Andy Fleming
  7. *
  8. * Copyright (c) 2004 Freescale Semiconductor, Inc.
  9. *
  10. * Copyright (c) 2013 Michael Stapelberg <michael@stapelberg.de>
  11. *
  12. * This program is free software; you can redistribute it and/or modify it
  13. * under the terms of the GNU General Public License as published by the
  14. * Free Software Foundation; either version 2 of the License, or (at your
  15. * option) any later version.
  16. *
  17. */
  18. #include <linux/kernel.h>
  19. #include <linux/string.h>
  20. #include <linux/errno.h>
  21. #include <linux/unistd.h>
  22. #include <linux/interrupt.h>
  23. #include <linux/init.h>
  24. #include <linux/delay.h>
  25. #include <linux/netdevice.h>
  26. #include <linux/etherdevice.h>
  27. #include <linux/skbuff.h>
  28. #include <linux/spinlock.h>
  29. #include <linux/mm.h>
  30. #include <linux/module.h>
  31. #include <linux/mii.h>
  32. #include <linux/ethtool.h>
  33. #include <linux/phy.h>
  34. #include <linux/marvell_phy.h>
  35. #include <linux/of.h>
  36. #include <linux/io.h>
  37. #include <asm/irq.h>
  38. #include <linux/uaccess.h>
  39. #define MII_MARVELL_PHY_PAGE 22
  40. #define MII_M1011_IEVENT 0x13
  41. #define MII_M1011_IEVENT_CLEAR 0x0000
  42. #define MII_M1011_IMASK 0x12
  43. #define MII_M1011_IMASK_INIT 0x6400
  44. #define MII_M1011_IMASK_CLEAR 0x0000
  45. #define MII_M1011_PHY_SCR 0x10
  46. #define MII_M1011_PHY_SCR_MDI 0x0000
  47. #define MII_M1011_PHY_SCR_MDI_X 0x0020
  48. #define MII_M1011_PHY_SCR_AUTO_CROSS 0x0060
  49. #define MII_M1145_PHY_EXT_ADDR_PAGE 0x16
  50. #define MII_M1145_PHY_EXT_SR 0x1b
  51. #define MII_M1145_PHY_EXT_CR 0x14
  52. #define MII_M1145_RGMII_RX_DELAY 0x0080
  53. #define MII_M1145_RGMII_TX_DELAY 0x0002
  54. #define MII_M1145_HWCFG_MODE_SGMII_NO_CLK 0x4
  55. #define MII_M1145_HWCFG_MODE_MASK 0xf
  56. #define MII_M1145_HWCFG_FIBER_COPPER_AUTO 0x8000
  57. #define MII_M1145_HWCFG_MODE_SGMII_NO_CLK 0x4
  58. #define MII_M1145_HWCFG_MODE_MASK 0xf
  59. #define MII_M1145_HWCFG_FIBER_COPPER_AUTO 0x8000
  60. #define MII_M1111_PHY_LED_CONTROL 0x18
  61. #define MII_M1111_PHY_LED_DIRECT 0x4100
  62. #define MII_M1111_PHY_LED_COMBINE 0x411c
  63. #define MII_M1111_PHY_EXT_CR 0x14
  64. #define MII_M1111_RX_DELAY 0x80
  65. #define MII_M1111_TX_DELAY 0x2
  66. #define MII_M1111_PHY_EXT_SR 0x1b
  67. #define MII_M1111_HWCFG_MODE_MASK 0xf
  68. #define MII_M1111_HWCFG_MODE_COPPER_RGMII 0xb
  69. #define MII_M1111_HWCFG_MODE_FIBER_RGMII 0x3
  70. #define MII_M1111_HWCFG_MODE_SGMII_NO_CLK 0x4
  71. #define MII_M1111_HWCFG_MODE_COPPER_RTBI 0x9
  72. #define MII_M1111_HWCFG_FIBER_COPPER_AUTO 0x8000
  73. #define MII_M1111_HWCFG_FIBER_COPPER_RES 0x2000
  74. #define MII_M1111_COPPER 0
  75. #define MII_M1111_FIBER 1
  76. #define MII_88E1121_PHY_MSCR_PAGE 2
  77. #define MII_88E1121_PHY_MSCR_REG 21
  78. #define MII_88E1121_PHY_MSCR_RX_DELAY BIT(5)
  79. #define MII_88E1121_PHY_MSCR_TX_DELAY BIT(4)
  80. #define MII_88E1121_PHY_MSCR_DELAY_MASK (~(0x3 << 4))
  81. #define MII_88E1318S_PHY_MSCR1_REG 16
  82. #define MII_88E1318S_PHY_MSCR1_PAD_ODD BIT(6)
  83. /* Copper Specific Interrupt Enable Register */
  84. #define MII_88E1318S_PHY_CSIER 0x12
  85. /* WOL Event Interrupt Enable */
  86. #define MII_88E1318S_PHY_CSIER_WOL_EIE BIT(7)
  87. /* LED Timer Control Register */
  88. #define MII_88E1318S_PHY_LED_PAGE 0x03
  89. #define MII_88E1318S_PHY_LED_TCR 0x12
  90. #define MII_88E1318S_PHY_LED_TCR_FORCE_INT BIT(15)
  91. #define MII_88E1318S_PHY_LED_TCR_INTn_ENABLE BIT(7)
  92. #define MII_88E1318S_PHY_LED_TCR_INT_ACTIVE_LOW BIT(11)
  93. /* Magic Packet MAC address registers */
  94. #define MII_88E1318S_PHY_MAGIC_PACKET_WORD2 0x17
  95. #define MII_88E1318S_PHY_MAGIC_PACKET_WORD1 0x18
  96. #define MII_88E1318S_PHY_MAGIC_PACKET_WORD0 0x19
  97. #define MII_88E1318S_PHY_WOL_PAGE 0x11
  98. #define MII_88E1318S_PHY_WOL_CTRL 0x10
  99. #define MII_88E1318S_PHY_WOL_CTRL_CLEAR_WOL_STATUS BIT(12)
  100. #define MII_88E1318S_PHY_WOL_CTRL_MAGIC_PACKET_MATCH_ENABLE BIT(14)
  101. #define MII_88E1121_PHY_LED_CTRL 16
  102. #define MII_88E1121_PHY_LED_PAGE 3
  103. #define MII_88E1121_PHY_LED_DEF 0x0030
  104. #define MII_M1011_PHY_STATUS 0x11
  105. #define MII_M1011_PHY_STATUS_1000 0x8000
  106. #define MII_M1011_PHY_STATUS_100 0x4000
  107. #define MII_M1011_PHY_STATUS_SPD_MASK 0xc000
  108. #define MII_M1011_PHY_STATUS_FULLDUPLEX 0x2000
  109. #define MII_M1011_PHY_STATUS_RESOLVED 0x0800
  110. #define MII_M1011_PHY_STATUS_LINK 0x0400
  111. #define MII_M1116R_CONTROL_REG_MAC 21
  112. #define MII_88E3016_PHY_SPEC_CTRL 0x10
  113. #define MII_88E3016_DISABLE_SCRAMBLER 0x0200
  114. #define MII_88E3016_AUTO_MDIX_CROSSOVER 0x0030
  115. MODULE_DESCRIPTION("Marvell PHY driver");
  116. MODULE_AUTHOR("Andy Fleming");
  117. MODULE_LICENSE("GPL");
  118. static int marvell_ack_interrupt(struct phy_device *phydev)
  119. {
  120. int err;
  121. /* Clear the interrupts by reading the reg */
  122. err = phy_read(phydev, MII_M1011_IEVENT);
  123. if (err < 0)
  124. return err;
  125. return 0;
  126. }
  127. static int marvell_config_intr(struct phy_device *phydev)
  128. {
  129. int err;
  130. if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
  131. err = phy_write(phydev, MII_M1011_IMASK, MII_M1011_IMASK_INIT);
  132. else
  133. err = phy_write(phydev, MII_M1011_IMASK, MII_M1011_IMASK_CLEAR);
  134. return err;
  135. }
  136. static int marvell_set_polarity(struct phy_device *phydev, int polarity)
  137. {
  138. int reg;
  139. int err;
  140. int val;
  141. /* get the current settings */
  142. reg = phy_read(phydev, MII_M1011_PHY_SCR);
  143. if (reg < 0)
  144. return reg;
  145. val = reg;
  146. val &= ~MII_M1011_PHY_SCR_AUTO_CROSS;
  147. switch (polarity) {
  148. case ETH_TP_MDI:
  149. val |= MII_M1011_PHY_SCR_MDI;
  150. break;
  151. case ETH_TP_MDI_X:
  152. val |= MII_M1011_PHY_SCR_MDI_X;
  153. break;
  154. case ETH_TP_MDI_AUTO:
  155. case ETH_TP_MDI_INVALID:
  156. default:
  157. val |= MII_M1011_PHY_SCR_AUTO_CROSS;
  158. break;
  159. }
  160. if (val != reg) {
  161. /* Set the new polarity value in the register */
  162. err = phy_write(phydev, MII_M1011_PHY_SCR, val);
  163. if (err)
  164. return err;
  165. }
  166. return 0;
  167. }
  168. static int marvell_config_aneg(struct phy_device *phydev)
  169. {
  170. int err;
  171. err = marvell_set_polarity(phydev, phydev->mdix);
  172. if (err < 0)
  173. return err;
  174. err = phy_write(phydev, MII_M1111_PHY_LED_CONTROL,
  175. MII_M1111_PHY_LED_DIRECT);
  176. if (err < 0)
  177. return err;
  178. err = genphy_config_aneg(phydev);
  179. if (err < 0)
  180. return err;
  181. if (phydev->autoneg != AUTONEG_ENABLE) {
  182. int bmcr;
  183. /*
  184. * A write to speed/duplex bits (that is performed by
  185. * genphy_config_aneg() call above) must be followed by
  186. * a software reset. Otherwise, the write has no effect.
  187. */
  188. bmcr = phy_read(phydev, MII_BMCR);
  189. if (bmcr < 0)
  190. return bmcr;
  191. err = phy_write(phydev, MII_BMCR, bmcr | BMCR_RESET);
  192. if (err < 0)
  193. return err;
  194. }
  195. return 0;
  196. }
  197. static int m88e1101_config_aneg(struct phy_device *phydev)
  198. {
  199. int err;
  200. /* This Marvell PHY has an errata which requires
  201. * that certain registers get written in order
  202. * to restart autonegotiation
  203. */
  204. err = phy_write(phydev, MII_BMCR, BMCR_RESET);
  205. if (err < 0)
  206. return err;
  207. err = phy_write(phydev, 0x1d, 0x1f);
  208. if (err < 0)
  209. return err;
  210. err = phy_write(phydev, 0x1e, 0x200c);
  211. if (err < 0)
  212. return err;
  213. err = phy_write(phydev, 0x1d, 0x5);
  214. if (err < 0)
  215. return err;
  216. err = phy_write(phydev, 0x1e, 0);
  217. if (err < 0)
  218. return err;
  219. err = phy_write(phydev, 0x1e, 0x100);
  220. if (err < 0)
  221. return err;
  222. return marvell_config_aneg(phydev);
  223. }
  224. #ifdef CONFIG_OF_MDIO
  225. /*
  226. * Set and/or override some configuration registers based on the
  227. * marvell,reg-init property stored in the of_node for the phydev.
  228. *
  229. * marvell,reg-init = <reg-page reg mask value>,...;
  230. *
  231. * There may be one or more sets of <reg-page reg mask value>:
  232. *
  233. * reg-page: which register bank to use.
  234. * reg: the register.
  235. * mask: if non-zero, ANDed with existing register value.
  236. * value: ORed with the masked value and written to the regiser.
  237. *
  238. */
  239. static int marvell_of_reg_init(struct phy_device *phydev)
  240. {
  241. const __be32 *paddr;
  242. int len, i, saved_page, current_page, page_changed, ret;
  243. if (!phydev->dev.of_node)
  244. return 0;
  245. paddr = of_get_property(phydev->dev.of_node, "marvell,reg-init", &len);
  246. if (!paddr || len < (4 * sizeof(*paddr)))
  247. return 0;
  248. saved_page = phy_read(phydev, MII_MARVELL_PHY_PAGE);
  249. if (saved_page < 0)
  250. return saved_page;
  251. page_changed = 0;
  252. current_page = saved_page;
  253. ret = 0;
  254. len /= sizeof(*paddr);
  255. for (i = 0; i < len - 3; i += 4) {
  256. u16 reg_page = be32_to_cpup(paddr + i);
  257. u16 reg = be32_to_cpup(paddr + i + 1);
  258. u16 mask = be32_to_cpup(paddr + i + 2);
  259. u16 val_bits = be32_to_cpup(paddr + i + 3);
  260. int val;
  261. if (reg_page != current_page) {
  262. current_page = reg_page;
  263. page_changed = 1;
  264. ret = phy_write(phydev, MII_MARVELL_PHY_PAGE, reg_page);
  265. if (ret < 0)
  266. goto err;
  267. }
  268. val = 0;
  269. if (mask) {
  270. val = phy_read(phydev, reg);
  271. if (val < 0) {
  272. ret = val;
  273. goto err;
  274. }
  275. val &= mask;
  276. }
  277. val |= val_bits;
  278. ret = phy_write(phydev, reg, val);
  279. if (ret < 0)
  280. goto err;
  281. }
  282. err:
  283. if (page_changed) {
  284. i = phy_write(phydev, MII_MARVELL_PHY_PAGE, saved_page);
  285. if (ret == 0)
  286. ret = i;
  287. }
  288. return ret;
  289. }
  290. #else
  291. static int marvell_of_reg_init(struct phy_device *phydev)
  292. {
  293. return 0;
  294. }
  295. #endif /* CONFIG_OF_MDIO */
  296. static int m88e1121_config_aneg(struct phy_device *phydev)
  297. {
  298. int err, oldpage, mscr;
  299. oldpage = phy_read(phydev, MII_MARVELL_PHY_PAGE);
  300. err = phy_write(phydev, MII_MARVELL_PHY_PAGE,
  301. MII_88E1121_PHY_MSCR_PAGE);
  302. if (err < 0)
  303. return err;
  304. if (phy_interface_is_rgmii(phydev)) {
  305. mscr = phy_read(phydev, MII_88E1121_PHY_MSCR_REG) &
  306. MII_88E1121_PHY_MSCR_DELAY_MASK;
  307. if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID)
  308. mscr |= (MII_88E1121_PHY_MSCR_RX_DELAY |
  309. MII_88E1121_PHY_MSCR_TX_DELAY);
  310. else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID)
  311. mscr |= MII_88E1121_PHY_MSCR_RX_DELAY;
  312. else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID)
  313. mscr |= MII_88E1121_PHY_MSCR_TX_DELAY;
  314. err = phy_write(phydev, MII_88E1121_PHY_MSCR_REG, mscr);
  315. if (err < 0)
  316. return err;
  317. }
  318. phy_write(phydev, MII_MARVELL_PHY_PAGE, oldpage);
  319. err = phy_write(phydev, MII_BMCR, BMCR_RESET);
  320. if (err < 0)
  321. return err;
  322. err = phy_write(phydev, MII_M1011_PHY_SCR,
  323. MII_M1011_PHY_SCR_AUTO_CROSS);
  324. if (err < 0)
  325. return err;
  326. oldpage = phy_read(phydev, MII_MARVELL_PHY_PAGE);
  327. phy_write(phydev, MII_MARVELL_PHY_PAGE, MII_88E1121_PHY_LED_PAGE);
  328. phy_write(phydev, MII_88E1121_PHY_LED_CTRL, MII_88E1121_PHY_LED_DEF);
  329. phy_write(phydev, MII_MARVELL_PHY_PAGE, oldpage);
  330. err = genphy_config_aneg(phydev);
  331. return err;
  332. }
  333. static int m88e1318_config_aneg(struct phy_device *phydev)
  334. {
  335. int err, oldpage, mscr;
  336. oldpage = phy_read(phydev, MII_MARVELL_PHY_PAGE);
  337. err = phy_write(phydev, MII_MARVELL_PHY_PAGE,
  338. MII_88E1121_PHY_MSCR_PAGE);
  339. if (err < 0)
  340. return err;
  341. mscr = phy_read(phydev, MII_88E1318S_PHY_MSCR1_REG);
  342. mscr |= MII_88E1318S_PHY_MSCR1_PAD_ODD;
  343. err = phy_write(phydev, MII_88E1318S_PHY_MSCR1_REG, mscr);
  344. if (err < 0)
  345. return err;
  346. err = phy_write(phydev, MII_MARVELL_PHY_PAGE, oldpage);
  347. if (err < 0)
  348. return err;
  349. return m88e1121_config_aneg(phydev);
  350. }
  351. static int m88e1510_config_aneg(struct phy_device *phydev)
  352. {
  353. int err;
  354. err = m88e1318_config_aneg(phydev);
  355. if (err < 0)
  356. return err;
  357. return marvell_of_reg_init(phydev);
  358. }
  359. static int m88e1116r_config_init(struct phy_device *phydev)
  360. {
  361. int temp;
  362. int err;
  363. temp = phy_read(phydev, MII_BMCR);
  364. temp |= BMCR_RESET;
  365. err = phy_write(phydev, MII_BMCR, temp);
  366. if (err < 0)
  367. return err;
  368. mdelay(500);
  369. err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 0);
  370. if (err < 0)
  371. return err;
  372. temp = phy_read(phydev, MII_M1011_PHY_SCR);
  373. temp |= (7 << 12); /* max number of gigabit attempts */
  374. temp |= (1 << 11); /* enable downshift */
  375. temp |= MII_M1011_PHY_SCR_AUTO_CROSS;
  376. err = phy_write(phydev, MII_M1011_PHY_SCR, temp);
  377. if (err < 0)
  378. return err;
  379. err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 2);
  380. if (err < 0)
  381. return err;
  382. temp = phy_read(phydev, MII_M1116R_CONTROL_REG_MAC);
  383. temp |= (1 << 5);
  384. temp |= (1 << 4);
  385. err = phy_write(phydev, MII_M1116R_CONTROL_REG_MAC, temp);
  386. if (err < 0)
  387. return err;
  388. err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 0);
  389. if (err < 0)
  390. return err;
  391. temp = phy_read(phydev, MII_BMCR);
  392. temp |= BMCR_RESET;
  393. err = phy_write(phydev, MII_BMCR, temp);
  394. if (err < 0)
  395. return err;
  396. mdelay(500);
  397. return 0;
  398. }
  399. static int m88e3016_config_init(struct phy_device *phydev)
  400. {
  401. int reg;
  402. /* Enable Scrambler and Auto-Crossover */
  403. reg = phy_read(phydev, MII_88E3016_PHY_SPEC_CTRL);
  404. if (reg < 0)
  405. return reg;
  406. reg &= ~MII_88E3016_DISABLE_SCRAMBLER;
  407. reg |= MII_88E3016_AUTO_MDIX_CROSSOVER;
  408. reg = phy_write(phydev, MII_88E3016_PHY_SPEC_CTRL, reg);
  409. if (reg < 0)
  410. return reg;
  411. return 0;
  412. }
  413. static int m88e1111_config_init(struct phy_device *phydev)
  414. {
  415. int err;
  416. int temp;
  417. if (phy_interface_is_rgmii(phydev)) {
  418. temp = phy_read(phydev, MII_M1111_PHY_EXT_CR);
  419. if (temp < 0)
  420. return temp;
  421. if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) {
  422. temp |= (MII_M1111_RX_DELAY | MII_M1111_TX_DELAY);
  423. } else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) {
  424. temp &= ~MII_M1111_TX_DELAY;
  425. temp |= MII_M1111_RX_DELAY;
  426. } else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) {
  427. temp &= ~MII_M1111_RX_DELAY;
  428. temp |= MII_M1111_TX_DELAY;
  429. }
  430. err = phy_write(phydev, MII_M1111_PHY_EXT_CR, temp);
  431. if (err < 0)
  432. return err;
  433. temp = phy_read(phydev, MII_M1111_PHY_EXT_SR);
  434. if (temp < 0)
  435. return temp;
  436. temp &= ~(MII_M1111_HWCFG_MODE_MASK);
  437. if (temp & MII_M1111_HWCFG_FIBER_COPPER_RES)
  438. temp |= MII_M1111_HWCFG_MODE_FIBER_RGMII;
  439. else
  440. temp |= MII_M1111_HWCFG_MODE_COPPER_RGMII;
  441. err = phy_write(phydev, MII_M1111_PHY_EXT_SR, temp);
  442. if (err < 0)
  443. return err;
  444. }
  445. if (phydev->interface == PHY_INTERFACE_MODE_SGMII) {
  446. temp = phy_read(phydev, MII_M1111_PHY_EXT_SR);
  447. if (temp < 0)
  448. return temp;
  449. temp &= ~(MII_M1111_HWCFG_MODE_MASK);
  450. temp |= MII_M1111_HWCFG_MODE_SGMII_NO_CLK;
  451. temp |= MII_M1111_HWCFG_FIBER_COPPER_AUTO;
  452. err = phy_write(phydev, MII_M1111_PHY_EXT_SR, temp);
  453. if (err < 0)
  454. return err;
  455. /* make sure copper is selected */
  456. err = phy_read(phydev, MII_M1145_PHY_EXT_ADDR_PAGE);
  457. if (err < 0)
  458. return err;
  459. err = phy_write(phydev, MII_M1145_PHY_EXT_ADDR_PAGE,
  460. err & (~0xff));
  461. if (err < 0)
  462. return err;
  463. }
  464. if (phydev->interface == PHY_INTERFACE_MODE_RTBI) {
  465. temp = phy_read(phydev, MII_M1111_PHY_EXT_CR);
  466. if (temp < 0)
  467. return temp;
  468. temp |= (MII_M1111_RX_DELAY | MII_M1111_TX_DELAY);
  469. err = phy_write(phydev, MII_M1111_PHY_EXT_CR, temp);
  470. if (err < 0)
  471. return err;
  472. temp = phy_read(phydev, MII_M1111_PHY_EXT_SR);
  473. if (temp < 0)
  474. return temp;
  475. temp &= ~(MII_M1111_HWCFG_MODE_MASK | MII_M1111_HWCFG_FIBER_COPPER_RES);
  476. temp |= 0x7 | MII_M1111_HWCFG_FIBER_COPPER_AUTO;
  477. err = phy_write(phydev, MII_M1111_PHY_EXT_SR, temp);
  478. if (err < 0)
  479. return err;
  480. /* soft reset */
  481. err = phy_write(phydev, MII_BMCR, BMCR_RESET);
  482. if (err < 0)
  483. return err;
  484. do
  485. temp = phy_read(phydev, MII_BMCR);
  486. while (temp & BMCR_RESET);
  487. temp = phy_read(phydev, MII_M1111_PHY_EXT_SR);
  488. if (temp < 0)
  489. return temp;
  490. temp &= ~(MII_M1111_HWCFG_MODE_MASK | MII_M1111_HWCFG_FIBER_COPPER_RES);
  491. temp |= MII_M1111_HWCFG_MODE_COPPER_RTBI | MII_M1111_HWCFG_FIBER_COPPER_AUTO;
  492. err = phy_write(phydev, MII_M1111_PHY_EXT_SR, temp);
  493. if (err < 0)
  494. return err;
  495. }
  496. err = marvell_of_reg_init(phydev);
  497. if (err < 0)
  498. return err;
  499. return phy_write(phydev, MII_BMCR, BMCR_RESET);
  500. }
  501. static int m88e1118_config_aneg(struct phy_device *phydev)
  502. {
  503. int err;
  504. err = phy_write(phydev, MII_BMCR, BMCR_RESET);
  505. if (err < 0)
  506. return err;
  507. err = phy_write(phydev, MII_M1011_PHY_SCR,
  508. MII_M1011_PHY_SCR_AUTO_CROSS);
  509. if (err < 0)
  510. return err;
  511. err = genphy_config_aneg(phydev);
  512. return 0;
  513. }
  514. static int m88e1118_config_init(struct phy_device *phydev)
  515. {
  516. int err;
  517. /* Change address */
  518. err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 0x0002);
  519. if (err < 0)
  520. return err;
  521. /* Enable 1000 Mbit */
  522. err = phy_write(phydev, 0x15, 0x1070);
  523. if (err < 0)
  524. return err;
  525. /* Change address */
  526. err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 0x0003);
  527. if (err < 0)
  528. return err;
  529. /* Adjust LED Control */
  530. if (phydev->dev_flags & MARVELL_PHY_M1118_DNS323_LEDS)
  531. err = phy_write(phydev, 0x10, 0x1100);
  532. else
  533. err = phy_write(phydev, 0x10, 0x021e);
  534. if (err < 0)
  535. return err;
  536. err = marvell_of_reg_init(phydev);
  537. if (err < 0)
  538. return err;
  539. /* Reset address */
  540. err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 0x0);
  541. if (err < 0)
  542. return err;
  543. return phy_write(phydev, MII_BMCR, BMCR_RESET);
  544. }
  545. static int m88e1149_config_init(struct phy_device *phydev)
  546. {
  547. int err;
  548. /* Change address */
  549. err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 0x0002);
  550. if (err < 0)
  551. return err;
  552. /* Enable 1000 Mbit */
  553. err = phy_write(phydev, 0x15, 0x1048);
  554. if (err < 0)
  555. return err;
  556. err = marvell_of_reg_init(phydev);
  557. if (err < 0)
  558. return err;
  559. /* Reset address */
  560. err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 0x0);
  561. if (err < 0)
  562. return err;
  563. return phy_write(phydev, MII_BMCR, BMCR_RESET);
  564. }
  565. static int m88e1145_config_init(struct phy_device *phydev)
  566. {
  567. int err;
  568. int temp;
  569. /* Take care of errata E0 & E1 */
  570. err = phy_write(phydev, 0x1d, 0x001b);
  571. if (err < 0)
  572. return err;
  573. err = phy_write(phydev, 0x1e, 0x418f);
  574. if (err < 0)
  575. return err;
  576. err = phy_write(phydev, 0x1d, 0x0016);
  577. if (err < 0)
  578. return err;
  579. err = phy_write(phydev, 0x1e, 0xa2da);
  580. if (err < 0)
  581. return err;
  582. if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) {
  583. int temp = phy_read(phydev, MII_M1145_PHY_EXT_CR);
  584. if (temp < 0)
  585. return temp;
  586. temp |= (MII_M1145_RGMII_RX_DELAY | MII_M1145_RGMII_TX_DELAY);
  587. err = phy_write(phydev, MII_M1145_PHY_EXT_CR, temp);
  588. if (err < 0)
  589. return err;
  590. if (phydev->dev_flags & MARVELL_PHY_M1145_FLAGS_RESISTANCE) {
  591. err = phy_write(phydev, 0x1d, 0x0012);
  592. if (err < 0)
  593. return err;
  594. temp = phy_read(phydev, 0x1e);
  595. if (temp < 0)
  596. return temp;
  597. temp &= 0xf03f;
  598. temp |= 2 << 9; /* 36 ohm */
  599. temp |= 2 << 6; /* 39 ohm */
  600. err = phy_write(phydev, 0x1e, temp);
  601. if (err < 0)
  602. return err;
  603. err = phy_write(phydev, 0x1d, 0x3);
  604. if (err < 0)
  605. return err;
  606. err = phy_write(phydev, 0x1e, 0x8000);
  607. if (err < 0)
  608. return err;
  609. }
  610. }
  611. if (phydev->interface == PHY_INTERFACE_MODE_SGMII) {
  612. temp = phy_read(phydev, MII_M1145_PHY_EXT_SR);
  613. if (temp < 0)
  614. return temp;
  615. temp &= ~MII_M1145_HWCFG_MODE_MASK;
  616. temp |= MII_M1145_HWCFG_MODE_SGMII_NO_CLK;
  617. temp |= MII_M1145_HWCFG_FIBER_COPPER_AUTO;
  618. err = phy_write(phydev, MII_M1145_PHY_EXT_SR, temp);
  619. if (err < 0)
  620. return err;
  621. }
  622. err = marvell_of_reg_init(phydev);
  623. if (err < 0)
  624. return err;
  625. return 0;
  626. }
  627. /* marvell_read_status
  628. *
  629. * Generic status code does not detect Fiber correctly!
  630. * Description:
  631. * Check the link, then figure out the current state
  632. * by comparing what we advertise with what the link partner
  633. * advertises. Start by checking the gigabit possibilities,
  634. * then move on to 10/100.
  635. */
  636. static int marvell_read_status(struct phy_device *phydev)
  637. {
  638. int adv;
  639. int err;
  640. int lpa;
  641. int lpagb;
  642. int status = 0;
  643. /* Update the link, but return if there
  644. * was an error */
  645. err = genphy_update_link(phydev);
  646. if (err)
  647. return err;
  648. if (AUTONEG_ENABLE == phydev->autoneg) {
  649. status = phy_read(phydev, MII_M1011_PHY_STATUS);
  650. if (status < 0)
  651. return status;
  652. lpa = phy_read(phydev, MII_LPA);
  653. if (lpa < 0)
  654. return lpa;
  655. lpagb = phy_read(phydev, MII_STAT1000);
  656. if (lpagb < 0)
  657. return lpagb;
  658. adv = phy_read(phydev, MII_ADVERTISE);
  659. if (adv < 0)
  660. return adv;
  661. phydev->lp_advertising = mii_stat1000_to_ethtool_lpa_t(lpagb) |
  662. mii_lpa_to_ethtool_lpa_t(lpa);
  663. if (status & MII_M1011_PHY_STATUS_FULLDUPLEX)
  664. phydev->duplex = DUPLEX_FULL;
  665. else
  666. phydev->duplex = DUPLEX_HALF;
  667. status = status & MII_M1011_PHY_STATUS_SPD_MASK;
  668. phydev->pause = phydev->asym_pause = 0;
  669. switch (status) {
  670. case MII_M1011_PHY_STATUS_1000:
  671. phydev->speed = SPEED_1000;
  672. break;
  673. case MII_M1011_PHY_STATUS_100:
  674. phydev->speed = SPEED_100;
  675. break;
  676. default:
  677. phydev->speed = SPEED_10;
  678. break;
  679. }
  680. if (phydev->duplex == DUPLEX_FULL) {
  681. phydev->pause = lpa & LPA_PAUSE_CAP ? 1 : 0;
  682. phydev->asym_pause = lpa & LPA_PAUSE_ASYM ? 1 : 0;
  683. }
  684. } else {
  685. int bmcr = phy_read(phydev, MII_BMCR);
  686. if (bmcr < 0)
  687. return bmcr;
  688. if (bmcr & BMCR_FULLDPLX)
  689. phydev->duplex = DUPLEX_FULL;
  690. else
  691. phydev->duplex = DUPLEX_HALF;
  692. if (bmcr & BMCR_SPEED1000)
  693. phydev->speed = SPEED_1000;
  694. else if (bmcr & BMCR_SPEED100)
  695. phydev->speed = SPEED_100;
  696. else
  697. phydev->speed = SPEED_10;
  698. phydev->pause = phydev->asym_pause = 0;
  699. phydev->lp_advertising = 0;
  700. }
  701. return 0;
  702. }
  703. static int marvell_aneg_done(struct phy_device *phydev)
  704. {
  705. int retval = phy_read(phydev, MII_M1011_PHY_STATUS);
  706. return (retval < 0) ? retval : (retval & MII_M1011_PHY_STATUS_RESOLVED);
  707. }
  708. static int m88e1121_did_interrupt(struct phy_device *phydev)
  709. {
  710. int imask;
  711. imask = phy_read(phydev, MII_M1011_IEVENT);
  712. if (imask & MII_M1011_IMASK_INIT)
  713. return 1;
  714. return 0;
  715. }
  716. static void m88e1318_get_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol)
  717. {
  718. wol->supported = WAKE_MAGIC;
  719. wol->wolopts = 0;
  720. if (phy_write(phydev, MII_MARVELL_PHY_PAGE,
  721. MII_88E1318S_PHY_WOL_PAGE) < 0)
  722. return;
  723. if (phy_read(phydev, MII_88E1318S_PHY_WOL_CTRL) &
  724. MII_88E1318S_PHY_WOL_CTRL_MAGIC_PACKET_MATCH_ENABLE)
  725. wol->wolopts |= WAKE_MAGIC;
  726. if (phy_write(phydev, MII_MARVELL_PHY_PAGE, 0x00) < 0)
  727. return;
  728. }
  729. static int m88e1318_set_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol)
  730. {
  731. int err, oldpage, temp;
  732. oldpage = phy_read(phydev, MII_MARVELL_PHY_PAGE);
  733. if (wol->wolopts & WAKE_MAGIC) {
  734. /* Explicitly switch to page 0x00, just to be sure */
  735. err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 0x00);
  736. if (err < 0)
  737. return err;
  738. /* Enable the WOL interrupt */
  739. temp = phy_read(phydev, MII_88E1318S_PHY_CSIER);
  740. temp |= MII_88E1318S_PHY_CSIER_WOL_EIE;
  741. err = phy_write(phydev, MII_88E1318S_PHY_CSIER, temp);
  742. if (err < 0)
  743. return err;
  744. err = phy_write(phydev, MII_MARVELL_PHY_PAGE,
  745. MII_88E1318S_PHY_LED_PAGE);
  746. if (err < 0)
  747. return err;
  748. /* Setup LED[2] as interrupt pin (active low) */
  749. temp = phy_read(phydev, MII_88E1318S_PHY_LED_TCR);
  750. temp &= ~MII_88E1318S_PHY_LED_TCR_FORCE_INT;
  751. temp |= MII_88E1318S_PHY_LED_TCR_INTn_ENABLE;
  752. temp |= MII_88E1318S_PHY_LED_TCR_INT_ACTIVE_LOW;
  753. err = phy_write(phydev, MII_88E1318S_PHY_LED_TCR, temp);
  754. if (err < 0)
  755. return err;
  756. err = phy_write(phydev, MII_MARVELL_PHY_PAGE,
  757. MII_88E1318S_PHY_WOL_PAGE);
  758. if (err < 0)
  759. return err;
  760. /* Store the device address for the magic packet */
  761. err = phy_write(phydev, MII_88E1318S_PHY_MAGIC_PACKET_WORD2,
  762. ((phydev->attached_dev->dev_addr[5] << 8) |
  763. phydev->attached_dev->dev_addr[4]));
  764. if (err < 0)
  765. return err;
  766. err = phy_write(phydev, MII_88E1318S_PHY_MAGIC_PACKET_WORD1,
  767. ((phydev->attached_dev->dev_addr[3] << 8) |
  768. phydev->attached_dev->dev_addr[2]));
  769. if (err < 0)
  770. return err;
  771. err = phy_write(phydev, MII_88E1318S_PHY_MAGIC_PACKET_WORD0,
  772. ((phydev->attached_dev->dev_addr[1] << 8) |
  773. phydev->attached_dev->dev_addr[0]));
  774. if (err < 0)
  775. return err;
  776. /* Clear WOL status and enable magic packet matching */
  777. temp = phy_read(phydev, MII_88E1318S_PHY_WOL_CTRL);
  778. temp |= MII_88E1318S_PHY_WOL_CTRL_CLEAR_WOL_STATUS;
  779. temp |= MII_88E1318S_PHY_WOL_CTRL_MAGIC_PACKET_MATCH_ENABLE;
  780. err = phy_write(phydev, MII_88E1318S_PHY_WOL_CTRL, temp);
  781. if (err < 0)
  782. return err;
  783. } else {
  784. err = phy_write(phydev, MII_MARVELL_PHY_PAGE,
  785. MII_88E1318S_PHY_WOL_PAGE);
  786. if (err < 0)
  787. return err;
  788. /* Clear WOL status and disable magic packet matching */
  789. temp = phy_read(phydev, MII_88E1318S_PHY_WOL_CTRL);
  790. temp |= MII_88E1318S_PHY_WOL_CTRL_CLEAR_WOL_STATUS;
  791. temp &= ~MII_88E1318S_PHY_WOL_CTRL_MAGIC_PACKET_MATCH_ENABLE;
  792. err = phy_write(phydev, MII_88E1318S_PHY_WOL_CTRL, temp);
  793. if (err < 0)
  794. return err;
  795. }
  796. err = phy_write(phydev, MII_MARVELL_PHY_PAGE, oldpage);
  797. if (err < 0)
  798. return err;
  799. return 0;
  800. }
  801. static struct phy_driver marvell_drivers[] = {
  802. {
  803. .phy_id = MARVELL_PHY_ID_88E1101,
  804. .phy_id_mask = MARVELL_PHY_ID_MASK,
  805. .name = "Marvell 88E1101",
  806. .features = PHY_GBIT_FEATURES,
  807. .flags = PHY_HAS_INTERRUPT,
  808. .config_aneg = &m88e1101_config_aneg,
  809. .read_status = &genphy_read_status,
  810. .ack_interrupt = &marvell_ack_interrupt,
  811. .config_intr = &marvell_config_intr,
  812. .resume = &genphy_resume,
  813. .suspend = &genphy_suspend,
  814. .driver = { .owner = THIS_MODULE },
  815. },
  816. {
  817. .phy_id = MARVELL_PHY_ID_88E1112,
  818. .phy_id_mask = MARVELL_PHY_ID_MASK,
  819. .name = "Marvell 88E1112",
  820. .features = PHY_GBIT_FEATURES,
  821. .flags = PHY_HAS_INTERRUPT,
  822. .config_init = &m88e1111_config_init,
  823. .config_aneg = &marvell_config_aneg,
  824. .read_status = &genphy_read_status,
  825. .ack_interrupt = &marvell_ack_interrupt,
  826. .config_intr = &marvell_config_intr,
  827. .resume = &genphy_resume,
  828. .suspend = &genphy_suspend,
  829. .driver = { .owner = THIS_MODULE },
  830. },
  831. {
  832. .phy_id = MARVELL_PHY_ID_88E1111,
  833. .phy_id_mask = MARVELL_PHY_ID_MASK,
  834. .name = "Marvell 88E1111",
  835. .features = PHY_GBIT_FEATURES,
  836. .flags = PHY_HAS_INTERRUPT,
  837. .config_init = &m88e1111_config_init,
  838. .config_aneg = &marvell_config_aneg,
  839. .read_status = &marvell_read_status,
  840. .ack_interrupt = &marvell_ack_interrupt,
  841. .config_intr = &marvell_config_intr,
  842. .resume = &genphy_resume,
  843. .suspend = &genphy_suspend,
  844. .driver = { .owner = THIS_MODULE },
  845. },
  846. {
  847. .phy_id = MARVELL_PHY_ID_88E1118,
  848. .phy_id_mask = MARVELL_PHY_ID_MASK,
  849. .name = "Marvell 88E1118",
  850. .features = PHY_GBIT_FEATURES,
  851. .flags = PHY_HAS_INTERRUPT,
  852. .config_init = &m88e1118_config_init,
  853. .config_aneg = &m88e1118_config_aneg,
  854. .read_status = &genphy_read_status,
  855. .ack_interrupt = &marvell_ack_interrupt,
  856. .config_intr = &marvell_config_intr,
  857. .resume = &genphy_resume,
  858. .suspend = &genphy_suspend,
  859. .driver = {.owner = THIS_MODULE,},
  860. },
  861. {
  862. .phy_id = MARVELL_PHY_ID_88E1121R,
  863. .phy_id_mask = MARVELL_PHY_ID_MASK,
  864. .name = "Marvell 88E1121R",
  865. .features = PHY_GBIT_FEATURES,
  866. .flags = PHY_HAS_INTERRUPT,
  867. .config_aneg = &m88e1121_config_aneg,
  868. .read_status = &marvell_read_status,
  869. .ack_interrupt = &marvell_ack_interrupt,
  870. .config_intr = &marvell_config_intr,
  871. .did_interrupt = &m88e1121_did_interrupt,
  872. .resume = &genphy_resume,
  873. .suspend = &genphy_suspend,
  874. .driver = { .owner = THIS_MODULE },
  875. },
  876. {
  877. .phy_id = MARVELL_PHY_ID_88E1318S,
  878. .phy_id_mask = MARVELL_PHY_ID_MASK,
  879. .name = "Marvell 88E1318S",
  880. .features = PHY_GBIT_FEATURES,
  881. .flags = PHY_HAS_INTERRUPT,
  882. .config_aneg = &m88e1318_config_aneg,
  883. .read_status = &marvell_read_status,
  884. .ack_interrupt = &marvell_ack_interrupt,
  885. .config_intr = &marvell_config_intr,
  886. .did_interrupt = &m88e1121_did_interrupt,
  887. .get_wol = &m88e1318_get_wol,
  888. .set_wol = &m88e1318_set_wol,
  889. .resume = &genphy_resume,
  890. .suspend = &genphy_suspend,
  891. .driver = { .owner = THIS_MODULE },
  892. },
  893. {
  894. .phy_id = MARVELL_PHY_ID_88E1145,
  895. .phy_id_mask = MARVELL_PHY_ID_MASK,
  896. .name = "Marvell 88E1145",
  897. .features = PHY_GBIT_FEATURES,
  898. .flags = PHY_HAS_INTERRUPT,
  899. .config_init = &m88e1145_config_init,
  900. .config_aneg = &marvell_config_aneg,
  901. .read_status = &genphy_read_status,
  902. .ack_interrupt = &marvell_ack_interrupt,
  903. .config_intr = &marvell_config_intr,
  904. .resume = &genphy_resume,
  905. .suspend = &genphy_suspend,
  906. .driver = { .owner = THIS_MODULE },
  907. },
  908. {
  909. .phy_id = MARVELL_PHY_ID_88E1149R,
  910. .phy_id_mask = MARVELL_PHY_ID_MASK,
  911. .name = "Marvell 88E1149R",
  912. .features = PHY_GBIT_FEATURES,
  913. .flags = PHY_HAS_INTERRUPT,
  914. .config_init = &m88e1149_config_init,
  915. .config_aneg = &m88e1118_config_aneg,
  916. .read_status = &genphy_read_status,
  917. .ack_interrupt = &marvell_ack_interrupt,
  918. .config_intr = &marvell_config_intr,
  919. .resume = &genphy_resume,
  920. .suspend = &genphy_suspend,
  921. .driver = { .owner = THIS_MODULE },
  922. },
  923. {
  924. .phy_id = MARVELL_PHY_ID_88E1240,
  925. .phy_id_mask = MARVELL_PHY_ID_MASK,
  926. .name = "Marvell 88E1240",
  927. .features = PHY_GBIT_FEATURES,
  928. .flags = PHY_HAS_INTERRUPT,
  929. .config_init = &m88e1111_config_init,
  930. .config_aneg = &marvell_config_aneg,
  931. .read_status = &genphy_read_status,
  932. .ack_interrupt = &marvell_ack_interrupt,
  933. .config_intr = &marvell_config_intr,
  934. .resume = &genphy_resume,
  935. .suspend = &genphy_suspend,
  936. .driver = { .owner = THIS_MODULE },
  937. },
  938. {
  939. .phy_id = MARVELL_PHY_ID_88E1116R,
  940. .phy_id_mask = MARVELL_PHY_ID_MASK,
  941. .name = "Marvell 88E1116R",
  942. .features = PHY_GBIT_FEATURES,
  943. .flags = PHY_HAS_INTERRUPT,
  944. .config_init = &m88e1116r_config_init,
  945. .config_aneg = &genphy_config_aneg,
  946. .read_status = &genphy_read_status,
  947. .ack_interrupt = &marvell_ack_interrupt,
  948. .config_intr = &marvell_config_intr,
  949. .resume = &genphy_resume,
  950. .suspend = &genphy_suspend,
  951. .driver = { .owner = THIS_MODULE },
  952. },
  953. {
  954. .phy_id = MARVELL_PHY_ID_88E1510,
  955. .phy_id_mask = MARVELL_PHY_ID_MASK,
  956. .name = "Marvell 88E1510",
  957. .features = PHY_GBIT_FEATURES,
  958. .flags = PHY_HAS_INTERRUPT,
  959. .config_aneg = &m88e1510_config_aneg,
  960. .read_status = &marvell_read_status,
  961. .ack_interrupt = &marvell_ack_interrupt,
  962. .config_intr = &marvell_config_intr,
  963. .did_interrupt = &m88e1121_did_interrupt,
  964. .resume = &genphy_resume,
  965. .suspend = &genphy_suspend,
  966. .driver = { .owner = THIS_MODULE },
  967. },
  968. {
  969. .phy_id = MARVELL_PHY_ID_88E1540,
  970. .phy_id_mask = MARVELL_PHY_ID_MASK,
  971. .name = "Marvell 88E1540",
  972. .features = PHY_GBIT_FEATURES,
  973. .flags = PHY_HAS_INTERRUPT,
  974. .config_aneg = &m88e1510_config_aneg,
  975. .read_status = &marvell_read_status,
  976. .ack_interrupt = &marvell_ack_interrupt,
  977. .config_intr = &marvell_config_intr,
  978. .did_interrupt = &m88e1121_did_interrupt,
  979. .resume = &genphy_resume,
  980. .suspend = &genphy_suspend,
  981. .driver = { .owner = THIS_MODULE },
  982. },
  983. {
  984. .phy_id = MARVELL_PHY_ID_88E3016,
  985. .phy_id_mask = MARVELL_PHY_ID_MASK,
  986. .name = "Marvell 88E3016",
  987. .features = PHY_BASIC_FEATURES,
  988. .flags = PHY_HAS_INTERRUPT,
  989. .config_aneg = &genphy_config_aneg,
  990. .config_init = &m88e3016_config_init,
  991. .aneg_done = &marvell_aneg_done,
  992. .read_status = &marvell_read_status,
  993. .ack_interrupt = &marvell_ack_interrupt,
  994. .config_intr = &marvell_config_intr,
  995. .did_interrupt = &m88e1121_did_interrupt,
  996. .resume = &genphy_resume,
  997. .suspend = &genphy_suspend,
  998. .driver = { .owner = THIS_MODULE },
  999. },
  1000. };
  1001. module_phy_driver(marvell_drivers);
  1002. static struct mdio_device_id __maybe_unused marvell_tbl[] = {
  1003. { MARVELL_PHY_ID_88E1101, MARVELL_PHY_ID_MASK },
  1004. { MARVELL_PHY_ID_88E1112, MARVELL_PHY_ID_MASK },
  1005. { MARVELL_PHY_ID_88E1111, MARVELL_PHY_ID_MASK },
  1006. { MARVELL_PHY_ID_88E1118, MARVELL_PHY_ID_MASK },
  1007. { MARVELL_PHY_ID_88E1121R, MARVELL_PHY_ID_MASK },
  1008. { MARVELL_PHY_ID_88E1145, MARVELL_PHY_ID_MASK },
  1009. { MARVELL_PHY_ID_88E1149R, MARVELL_PHY_ID_MASK },
  1010. { MARVELL_PHY_ID_88E1240, MARVELL_PHY_ID_MASK },
  1011. { MARVELL_PHY_ID_88E1318S, MARVELL_PHY_ID_MASK },
  1012. { MARVELL_PHY_ID_88E1116R, MARVELL_PHY_ID_MASK },
  1013. { MARVELL_PHY_ID_88E1510, MARVELL_PHY_ID_MASK },
  1014. { MARVELL_PHY_ID_88E1540, MARVELL_PHY_ID_MASK },
  1015. { MARVELL_PHY_ID_88E3016, MARVELL_PHY_ID_MASK },
  1016. { }
  1017. };
  1018. MODULE_DEVICE_TABLE(mdio, marvell_tbl);