broadcom.c 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * drivers/net/phy/broadcom.c
  4. *
  5. * Broadcom BCM5411, BCM5421 and BCM5461 Gigabit Ethernet
  6. * transceivers.
  7. *
  8. * Broadcom BCM54810, BCM54811 BroadR-Reach transceivers.
  9. *
  10. * Copyright (c) 2006 Maciej W. Rozycki
  11. *
  12. * Inspired by code written by Amy Fong.
  13. */
  14. #include "bcm-phy-lib.h"
  15. #include <linux/delay.h>
  16. #include <linux/module.h>
  17. #include <linux/phy.h>
  18. #include <linux/pm_wakeup.h>
  19. #include <linux/brcmphy.h>
  20. #include <linux/of.h>
  21. #include <linux/interrupt.h>
  22. #include <linux/irq.h>
  23. #include <linux/gpio/consumer.h>
  24. #define BRCM_PHY_MODEL(phydev) \
  25. ((phydev)->drv->phy_id & (phydev)->drv->phy_id_mask)
  26. #define BRCM_PHY_REV(phydev) \
  27. ((phydev)->drv->phy_id & ~((phydev)->drv->phy_id_mask))
  28. MODULE_DESCRIPTION("Broadcom PHY driver");
  29. MODULE_AUTHOR("Maciej W. Rozycki");
  30. MODULE_LICENSE("GPL");
  31. struct bcm54xx_phy_priv {
  32. u64 *stats;
  33. struct bcm_ptp_private *ptp;
  34. int wake_irq;
  35. bool wake_irq_enabled;
  36. bool brr_mode;
  37. };
  38. /* Link modes for BCM58411 PHY */
  39. static const int bcm54811_linkmodes[] = {
  40. ETHTOOL_LINK_MODE_100baseT1_Full_BIT,
  41. ETHTOOL_LINK_MODE_10baseT1BRR_Full_BIT,
  42. ETHTOOL_LINK_MODE_1000baseT_Full_BIT,
  43. ETHTOOL_LINK_MODE_1000baseX_Full_BIT,
  44. ETHTOOL_LINK_MODE_1000baseT_Half_BIT,
  45. ETHTOOL_LINK_MODE_100baseT_Full_BIT,
  46. ETHTOOL_LINK_MODE_100baseT_Half_BIT,
  47. ETHTOOL_LINK_MODE_10baseT_Full_BIT,
  48. ETHTOOL_LINK_MODE_10baseT_Half_BIT
  49. };
  50. /* Long-Distance Signaling (BroadR-Reach mode aneg) relevant linkmode bits */
  51. static const int lds_br_bits[] = {
  52. ETHTOOL_LINK_MODE_Autoneg_BIT,
  53. ETHTOOL_LINK_MODE_Pause_BIT,
  54. ETHTOOL_LINK_MODE_Asym_Pause_BIT,
  55. ETHTOOL_LINK_MODE_10baseT1BRR_Full_BIT,
  56. ETHTOOL_LINK_MODE_100baseT1_Full_BIT
  57. };
  58. static bool bcm54xx_phy_can_wakeup(struct phy_device *phydev)
  59. {
  60. struct bcm54xx_phy_priv *priv = phydev->priv;
  61. return phy_interrupt_is_valid(phydev) || priv->wake_irq >= 0;
  62. }
  63. static int bcm54xx_config_clock_delay(struct phy_device *phydev)
  64. {
  65. int rc, val;
  66. /* handling PHY's internal RX clock delay */
  67. val = bcm54xx_auxctl_read(phydev, MII_BCM54XX_AUXCTL_SHDWSEL_MISC);
  68. val |= MII_BCM54XX_AUXCTL_MISC_WREN;
  69. if (phydev->interface == PHY_INTERFACE_MODE_RGMII ||
  70. phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) {
  71. /* Disable RGMII RXC-RXD skew */
  72. val &= ~MII_BCM54XX_AUXCTL_SHDWSEL_MISC_RGMII_SKEW_EN;
  73. }
  74. if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID ||
  75. phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) {
  76. /* Enable RGMII RXC-RXD skew */
  77. val |= MII_BCM54XX_AUXCTL_SHDWSEL_MISC_RGMII_SKEW_EN;
  78. }
  79. rc = bcm54xx_auxctl_write(phydev, MII_BCM54XX_AUXCTL_SHDWSEL_MISC,
  80. val);
  81. if (rc < 0)
  82. return rc;
  83. /* handling PHY's internal TX clock delay */
  84. val = bcm_phy_read_shadow(phydev, BCM54810_SHD_CLK_CTL);
  85. if (phydev->interface == PHY_INTERFACE_MODE_RGMII ||
  86. phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) {
  87. /* Disable internal TX clock delay */
  88. val &= ~BCM54810_SHD_CLK_CTL_GTXCLK_EN;
  89. }
  90. if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID ||
  91. phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) {
  92. /* Enable internal TX clock delay */
  93. val |= BCM54810_SHD_CLK_CTL_GTXCLK_EN;
  94. }
  95. rc = bcm_phy_write_shadow(phydev, BCM54810_SHD_CLK_CTL, val);
  96. if (rc < 0)
  97. return rc;
  98. return 0;
  99. }
  100. static int bcm54210e_config_init(struct phy_device *phydev)
  101. {
  102. int val;
  103. bcm54xx_config_clock_delay(phydev);
  104. if (phydev->dev_flags & PHY_BRCM_EN_MASTER_MODE) {
  105. val = phy_read(phydev, MII_CTRL1000);
  106. val |= CTL1000_AS_MASTER | CTL1000_ENABLE_MASTER;
  107. phy_write(phydev, MII_CTRL1000, val);
  108. }
  109. return 0;
  110. }
  111. static int bcm54612e_config_init(struct phy_device *phydev)
  112. {
  113. int reg;
  114. bcm54xx_config_clock_delay(phydev);
  115. /* Enable CLK125 MUX on LED4 if ref clock is enabled. */
  116. if (!(phydev->dev_flags & PHY_BRCM_RX_REFCLK_UNUSED)) {
  117. int err;
  118. reg = bcm_phy_read_exp(phydev, BCM54612E_EXP_SPARE0);
  119. err = bcm_phy_write_exp(phydev, BCM54612E_EXP_SPARE0,
  120. BCM54612E_LED4_CLK125OUT_EN | reg);
  121. if (err < 0)
  122. return err;
  123. }
  124. return 0;
  125. }
  126. static int bcm54616s_config_init(struct phy_device *phydev)
  127. {
  128. int rc, val;
  129. if (phydev->interface != PHY_INTERFACE_MODE_SGMII &&
  130. phydev->interface != PHY_INTERFACE_MODE_1000BASEX)
  131. return 0;
  132. /* Ensure proper interface mode is selected. */
  133. /* Disable RGMII mode */
  134. val = bcm54xx_auxctl_read(phydev, MII_BCM54XX_AUXCTL_SHDWSEL_MISC);
  135. if (val < 0)
  136. return val;
  137. val &= ~MII_BCM54XX_AUXCTL_SHDWSEL_MISC_RGMII_EN;
  138. val |= MII_BCM54XX_AUXCTL_MISC_WREN;
  139. rc = bcm54xx_auxctl_write(phydev, MII_BCM54XX_AUXCTL_SHDWSEL_MISC,
  140. val);
  141. if (rc < 0)
  142. return rc;
  143. /* Select 1000BASE-X register set (primary SerDes) */
  144. val = bcm_phy_read_shadow(phydev, BCM54XX_SHD_MODE);
  145. if (val < 0)
  146. return val;
  147. val |= BCM54XX_SHD_MODE_1000BX;
  148. rc = bcm_phy_write_shadow(phydev, BCM54XX_SHD_MODE, val);
  149. if (rc < 0)
  150. return rc;
  151. /* Power down SerDes interface */
  152. rc = phy_set_bits(phydev, MII_BMCR, BMCR_PDOWN);
  153. if (rc < 0)
  154. return rc;
  155. /* Select proper interface mode */
  156. val &= ~BCM54XX_SHD_INTF_SEL_MASK;
  157. val |= phydev->interface == PHY_INTERFACE_MODE_SGMII ?
  158. BCM54XX_SHD_INTF_SEL_SGMII :
  159. BCM54XX_SHD_INTF_SEL_GBIC;
  160. rc = bcm_phy_write_shadow(phydev, BCM54XX_SHD_MODE, val);
  161. if (rc < 0)
  162. return rc;
  163. /* Power up SerDes interface */
  164. rc = phy_clear_bits(phydev, MII_BMCR, BMCR_PDOWN);
  165. if (rc < 0)
  166. return rc;
  167. /* Select copper register set */
  168. val &= ~BCM54XX_SHD_MODE_1000BX;
  169. rc = bcm_phy_write_shadow(phydev, BCM54XX_SHD_MODE, val);
  170. if (rc < 0)
  171. return rc;
  172. /* Power up copper interface */
  173. return phy_clear_bits(phydev, MII_BMCR, BMCR_PDOWN);
  174. }
  175. /* Needs SMDSP clock enabled via bcm54xx_phydsp_config() */
  176. static int bcm50610_a0_workaround(struct phy_device *phydev)
  177. {
  178. int err;
  179. err = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_AADJ1CH0,
  180. MII_BCM54XX_EXP_AADJ1CH0_SWP_ABCD_OEN |
  181. MII_BCM54XX_EXP_AADJ1CH0_SWSEL_THPF);
  182. if (err < 0)
  183. return err;
  184. err = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_AADJ1CH3,
  185. MII_BCM54XX_EXP_AADJ1CH3_ADCCKADJ);
  186. if (err < 0)
  187. return err;
  188. err = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_EXP75,
  189. MII_BCM54XX_EXP_EXP75_VDACCTRL);
  190. if (err < 0)
  191. return err;
  192. err = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_EXP96,
  193. MII_BCM54XX_EXP_EXP96_MYST);
  194. if (err < 0)
  195. return err;
  196. err = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_EXP97,
  197. MII_BCM54XX_EXP_EXP97_MYST);
  198. return err;
  199. }
  200. static int bcm54xx_phydsp_config(struct phy_device *phydev)
  201. {
  202. int err, err2;
  203. /* Enable the SMDSP clock */
  204. err = bcm54xx_auxctl_write(phydev,
  205. MII_BCM54XX_AUXCTL_SHDWSEL_AUXCTL,
  206. MII_BCM54XX_AUXCTL_ACTL_SMDSP_ENA |
  207. MII_BCM54XX_AUXCTL_ACTL_TX_6DB);
  208. if (err < 0)
  209. return err;
  210. if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM50610 ||
  211. BRCM_PHY_MODEL(phydev) == PHY_ID_BCM50610M) {
  212. /* Clear bit 9 to fix a phy interop issue. */
  213. err = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_EXP08,
  214. MII_BCM54XX_EXP_EXP08_RJCT_2MHZ);
  215. if (err < 0)
  216. goto error;
  217. if (phydev->drv->phy_id == PHY_ID_BCM50610) {
  218. err = bcm50610_a0_workaround(phydev);
  219. if (err < 0)
  220. goto error;
  221. }
  222. }
  223. if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM57780) {
  224. int val;
  225. val = bcm_phy_read_exp(phydev, MII_BCM54XX_EXP_EXP75);
  226. if (val < 0)
  227. goto error;
  228. val |= MII_BCM54XX_EXP_EXP75_CM_OSC;
  229. err = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_EXP75, val);
  230. }
  231. error:
  232. /* Disable the SMDSP clock */
  233. err2 = bcm54xx_auxctl_write(phydev,
  234. MII_BCM54XX_AUXCTL_SHDWSEL_AUXCTL,
  235. MII_BCM54XX_AUXCTL_ACTL_TX_6DB);
  236. /* Return the first error reported. */
  237. return err ? err : err2;
  238. }
  239. static void bcm54xx_adjust_rxrefclk(struct phy_device *phydev)
  240. {
  241. u32 orig;
  242. int val;
  243. bool clk125en = true;
  244. /* Abort if we are using an untested phy. */
  245. if (BRCM_PHY_MODEL(phydev) != PHY_ID_BCM57780 &&
  246. BRCM_PHY_MODEL(phydev) != PHY_ID_BCM50610 &&
  247. BRCM_PHY_MODEL(phydev) != PHY_ID_BCM50610M &&
  248. BRCM_PHY_MODEL(phydev) != PHY_ID_BCM54210E &&
  249. BRCM_PHY_MODEL(phydev) != PHY_ID_BCM54810 &&
  250. BRCM_PHY_MODEL(phydev) != PHY_ID_BCM54811)
  251. return;
  252. val = bcm_phy_read_shadow(phydev, BCM54XX_SHD_SCR3);
  253. if (val < 0)
  254. return;
  255. orig = val;
  256. if ((BRCM_PHY_MODEL(phydev) == PHY_ID_BCM50610 ||
  257. BRCM_PHY_MODEL(phydev) == PHY_ID_BCM50610M) &&
  258. BRCM_PHY_REV(phydev) >= 0x3) {
  259. /*
  260. * Here, bit 0 _disables_ CLK125 when set.
  261. * This bit is set by default.
  262. */
  263. clk125en = false;
  264. } else {
  265. if (phydev->dev_flags & PHY_BRCM_RX_REFCLK_UNUSED) {
  266. if (BRCM_PHY_MODEL(phydev) != PHY_ID_BCM54811) {
  267. /* Here, bit 0 _enables_ CLK125 when set */
  268. val &= ~BCM54XX_SHD_SCR3_DEF_CLK125;
  269. }
  270. clk125en = false;
  271. }
  272. }
  273. if (!clk125en || (phydev->dev_flags & PHY_BRCM_AUTO_PWRDWN_ENABLE))
  274. val &= ~BCM54XX_SHD_SCR3_DLLAPD_DIS;
  275. else
  276. val |= BCM54XX_SHD_SCR3_DLLAPD_DIS;
  277. if (phydev->dev_flags & PHY_BRCM_DIS_TXCRXC_NOENRGY) {
  278. if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54210E ||
  279. BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54810 ||
  280. BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54811)
  281. val |= BCM54XX_SHD_SCR3_RXCTXC_DIS;
  282. else
  283. val |= BCM54XX_SHD_SCR3_TRDDAPD;
  284. }
  285. if (orig != val)
  286. bcm_phy_write_shadow(phydev, BCM54XX_SHD_SCR3, val);
  287. val = bcm_phy_read_shadow(phydev, BCM54XX_SHD_APD);
  288. if (val < 0)
  289. return;
  290. orig = val;
  291. if (!clk125en || (phydev->dev_flags & PHY_BRCM_AUTO_PWRDWN_ENABLE))
  292. val |= BCM54XX_SHD_APD_EN;
  293. else
  294. val &= ~BCM54XX_SHD_APD_EN;
  295. if (orig != val)
  296. bcm_phy_write_shadow(phydev, BCM54XX_SHD_APD, val);
  297. }
  298. static void bcm54xx_ptp_stop(struct phy_device *phydev)
  299. {
  300. struct bcm54xx_phy_priv *priv = phydev->priv;
  301. if (priv->ptp)
  302. bcm_ptp_stop(priv->ptp);
  303. }
  304. static void bcm54xx_ptp_config_init(struct phy_device *phydev)
  305. {
  306. struct bcm54xx_phy_priv *priv = phydev->priv;
  307. if (priv->ptp)
  308. bcm_ptp_config_init(phydev);
  309. }
  310. static int bcm5481x_set_brrmode(struct phy_device *phydev, bool on)
  311. {
  312. int reg;
  313. int err;
  314. u16 val;
  315. reg = bcm_phy_read_exp(phydev, BCM54810_EXP_BROADREACH_LRE_MISC_CTL);
  316. if (reg < 0)
  317. return reg;
  318. if (on)
  319. reg |= BCM54810_EXP_BROADREACH_LRE_MISC_CTL_EN;
  320. else
  321. reg &= ~BCM54810_EXP_BROADREACH_LRE_MISC_CTL_EN;
  322. err = bcm_phy_write_exp(phydev,
  323. BCM54810_EXP_BROADREACH_LRE_MISC_CTL, reg);
  324. if (err)
  325. return err;
  326. /* Ensure LRE or IEEE register set is accessed according to the brr
  327. * on/off, thus set the override
  328. */
  329. val = BCM54811_EXP_BROADREACH_LRE_OVERLAY_CTL_EN;
  330. if (!on)
  331. val |= BCM54811_EXP_BROADREACH_LRE_OVERLAY_CTL_OVERRIDE_VAL;
  332. return bcm_phy_write_exp(phydev,
  333. BCM54811_EXP_BROADREACH_LRE_OVERLAY_CTL, val);
  334. }
  335. static int bcm54811_config_init(struct phy_device *phydev)
  336. {
  337. struct bcm54xx_phy_priv *priv = phydev->priv;
  338. int err, reg;
  339. /* Enable CLK125 MUX on LED4 if ref clock is enabled. */
  340. if (!(phydev->dev_flags & PHY_BRCM_RX_REFCLK_UNUSED)) {
  341. reg = bcm_phy_read_exp(phydev, BCM54612E_EXP_SPARE0);
  342. if (reg < 0)
  343. return reg;
  344. err = bcm_phy_write_exp(phydev, BCM54612E_EXP_SPARE0,
  345. BCM54612E_LED4_CLK125OUT_EN | reg);
  346. if (err < 0)
  347. return err;
  348. }
  349. /* With BCM54811, BroadR-Reach implies no autoneg */
  350. if (priv->brr_mode)
  351. phydev->autoneg = 0;
  352. return bcm5481x_set_brrmode(phydev, priv->brr_mode);
  353. }
  354. static int bcm54xx_config_init(struct phy_device *phydev)
  355. {
  356. int reg, err, val;
  357. reg = phy_read(phydev, MII_BCM54XX_ECR);
  358. if (reg < 0)
  359. return reg;
  360. /* Mask interrupts globally. */
  361. reg |= MII_BCM54XX_ECR_IM;
  362. err = phy_write(phydev, MII_BCM54XX_ECR, reg);
  363. if (err < 0)
  364. return err;
  365. /* Unmask events we are interested in. */
  366. reg = ~(MII_BCM54XX_INT_DUPLEX |
  367. MII_BCM54XX_INT_SPEED |
  368. MII_BCM54XX_INT_LINK);
  369. err = phy_write(phydev, MII_BCM54XX_IMR, reg);
  370. if (err < 0)
  371. return err;
  372. if ((BRCM_PHY_MODEL(phydev) == PHY_ID_BCM50610 ||
  373. BRCM_PHY_MODEL(phydev) == PHY_ID_BCM50610M) &&
  374. (phydev->dev_flags & PHY_BRCM_CLEAR_RGMII_MODE))
  375. bcm_phy_write_shadow(phydev, BCM54XX_SHD_RGMII_MODE, 0);
  376. bcm54xx_adjust_rxrefclk(phydev);
  377. switch (BRCM_PHY_MODEL(phydev)) {
  378. case PHY_ID_BCM50610:
  379. case PHY_ID_BCM50610M:
  380. err = bcm54xx_config_clock_delay(phydev);
  381. break;
  382. case PHY_ID_BCM54210E:
  383. err = bcm54210e_config_init(phydev);
  384. break;
  385. case PHY_ID_BCM54612E:
  386. err = bcm54612e_config_init(phydev);
  387. break;
  388. case PHY_ID_BCM54616S:
  389. err = bcm54616s_config_init(phydev);
  390. break;
  391. case PHY_ID_BCM54810:
  392. /* For BCM54810, we need to disable BroadR-Reach function */
  393. val = bcm_phy_read_exp(phydev,
  394. BCM54810_EXP_BROADREACH_LRE_MISC_CTL);
  395. val &= ~BCM54810_EXP_BROADREACH_LRE_MISC_CTL_EN;
  396. err = bcm_phy_write_exp(phydev,
  397. BCM54810_EXP_BROADREACH_LRE_MISC_CTL,
  398. val);
  399. break;
  400. case PHY_ID_BCM54811:
  401. err = bcm54811_config_init(phydev);
  402. break;
  403. }
  404. if (err)
  405. return err;
  406. bcm54xx_phydsp_config(phydev);
  407. /* For non-SFP setups, encode link speed into LED1 and LED3 pair
  408. * (green/amber).
  409. * Also flash these two LEDs on activity. This means configuring
  410. * them for MULTICOLOR and encoding link/activity into them.
  411. * Don't do this for devices on an SFP module, since some of these
  412. * use the LED outputs to control the SFP LOS signal, and changing
  413. * these settings will cause LOS to malfunction.
  414. */
  415. if (!phy_on_sfp(phydev)) {
  416. val = BCM54XX_SHD_LEDS1_LED1(BCM_LED_SRC_MULTICOLOR1) |
  417. BCM54XX_SHD_LEDS1_LED3(BCM_LED_SRC_MULTICOLOR1);
  418. bcm_phy_write_shadow(phydev, BCM54XX_SHD_LEDS1, val);
  419. val = BCM_LED_MULTICOLOR_IN_PHASE |
  420. BCM54XX_SHD_LEDS1_LED1(BCM_LED_MULTICOLOR_LINK_ACT) |
  421. BCM54XX_SHD_LEDS1_LED3(BCM_LED_MULTICOLOR_LINK_ACT);
  422. bcm_phy_write_exp(phydev, BCM_EXP_MULTICOLOR, val);
  423. }
  424. bcm54xx_ptp_config_init(phydev);
  425. /* Acknowledge any left over interrupt and charge the device for
  426. * wake-up.
  427. */
  428. err = bcm_phy_read_exp(phydev, BCM54XX_WOL_INT_STATUS);
  429. if (err < 0)
  430. return err;
  431. if (err)
  432. pm_wakeup_event(&phydev->mdio.dev, 0);
  433. return 0;
  434. }
  435. static int bcm54xx_iddq_set(struct phy_device *phydev, bool enable)
  436. {
  437. int ret = 0;
  438. if (!(phydev->dev_flags & PHY_BRCM_IDDQ_SUSPEND))
  439. return ret;
  440. ret = bcm_phy_read_exp(phydev, BCM54XX_TOP_MISC_IDDQ_CTRL);
  441. if (ret < 0)
  442. goto out;
  443. if (enable)
  444. ret |= BCM54XX_TOP_MISC_IDDQ_SR | BCM54XX_TOP_MISC_IDDQ_LP;
  445. else
  446. ret &= ~(BCM54XX_TOP_MISC_IDDQ_SR | BCM54XX_TOP_MISC_IDDQ_LP);
  447. ret = bcm_phy_write_exp(phydev, BCM54XX_TOP_MISC_IDDQ_CTRL, ret);
  448. out:
  449. return ret;
  450. }
  451. static int bcm54xx_set_wakeup_irq(struct phy_device *phydev, bool state)
  452. {
  453. struct bcm54xx_phy_priv *priv = phydev->priv;
  454. int ret = 0;
  455. if (!bcm54xx_phy_can_wakeup(phydev))
  456. return ret;
  457. if (priv->wake_irq_enabled != state) {
  458. if (state)
  459. ret = enable_irq_wake(priv->wake_irq);
  460. else
  461. ret = disable_irq_wake(priv->wake_irq);
  462. priv->wake_irq_enabled = state;
  463. }
  464. return ret;
  465. }
  466. static int bcm54xx_suspend(struct phy_device *phydev)
  467. {
  468. int ret = 0;
  469. bcm54xx_ptp_stop(phydev);
  470. /* Acknowledge any Wake-on-LAN interrupt prior to suspend */
  471. ret = bcm_phy_read_exp(phydev, BCM54XX_WOL_INT_STATUS);
  472. if (ret < 0)
  473. return ret;
  474. if (phydev->wol_enabled)
  475. return bcm54xx_set_wakeup_irq(phydev, true);
  476. /* We cannot use a read/modify/write here otherwise the PHY gets into
  477. * a bad state where its LEDs keep flashing, thus defeating the purpose
  478. * of low power mode.
  479. */
  480. ret = phy_write(phydev, MII_BMCR, BMCR_PDOWN);
  481. if (ret < 0)
  482. return ret;
  483. return bcm54xx_iddq_set(phydev, true);
  484. }
  485. static int bcm54xx_resume(struct phy_device *phydev)
  486. {
  487. int ret = 0;
  488. if (phydev->wol_enabled) {
  489. ret = bcm54xx_set_wakeup_irq(phydev, false);
  490. if (ret)
  491. return ret;
  492. }
  493. ret = bcm54xx_iddq_set(phydev, false);
  494. if (ret < 0)
  495. return ret;
  496. /* Writes to register other than BMCR would be ignored
  497. * unless we clear the PDOWN bit first
  498. */
  499. ret = genphy_resume(phydev);
  500. if (ret < 0)
  501. return ret;
  502. /* Upon exiting power down, the PHY remains in an internal reset state
  503. * for 40us
  504. */
  505. fsleep(40);
  506. /* Issue a soft reset after clearing the power down bit
  507. * and before doing any other configuration.
  508. */
  509. if (phydev->dev_flags & PHY_BRCM_IDDQ_SUSPEND) {
  510. ret = genphy_soft_reset(phydev);
  511. if (ret < 0)
  512. return ret;
  513. }
  514. return bcm54xx_config_init(phydev);
  515. }
  516. static int bcm54810_read_mmd(struct phy_device *phydev, int devnum, u16 regnum)
  517. {
  518. return -EOPNOTSUPP;
  519. }
  520. static int bcm54810_write_mmd(struct phy_device *phydev, int devnum, u16 regnum,
  521. u16 val)
  522. {
  523. return -EOPNOTSUPP;
  524. }
  525. /**
  526. * bcm5481x_read_abilities - read PHY abilities from LRESR or Clause 22
  527. * (BMSR) registers, based on whether the PHY is in BroadR-Reach or IEEE mode
  528. * @phydev: target phy_device struct
  529. *
  530. * Description: Reads the PHY's abilities and populates phydev->supported
  531. * accordingly. The register to read the abilities from is determined by
  532. * the brr mode setting of the PHY as read from the device tree.
  533. * Note that the LRE and IEEE sets of abilities are disjunct, in other words,
  534. * not only the link modes differ, but also the auto-negotiation and
  535. * master-slave setup is controlled differently.
  536. *
  537. * Returns: 0 on success, < 0 on failure
  538. */
  539. static int bcm5481x_read_abilities(struct phy_device *phydev)
  540. {
  541. struct device_node *np = phydev->mdio.dev.of_node;
  542. struct bcm54xx_phy_priv *priv = phydev->priv;
  543. int i, val, err, aneg;
  544. for (i = 0; i < ARRAY_SIZE(bcm54811_linkmodes); i++)
  545. linkmode_clear_bit(bcm54811_linkmodes[i], phydev->supported);
  546. priv->brr_mode = of_property_read_bool(np, "brr-mode");
  547. /* Set BroadR-Reach mode as configured in the DT. */
  548. err = bcm5481x_set_brrmode(phydev, priv->brr_mode);
  549. if (err)
  550. return err;
  551. if (priv->brr_mode) {
  552. linkmode_set_bit_array(phy_basic_ports_array,
  553. ARRAY_SIZE(phy_basic_ports_array),
  554. phydev->supported);
  555. val = phy_read(phydev, MII_BCM54XX_LRESR);
  556. if (val < 0)
  557. return val;
  558. /* BCM54811 is not capable of LDS but the corresponding bit
  559. * in LRESR is set to 1 and marked "Ignore" in the datasheet.
  560. * So we must read the bcm54811 as unable to auto-negotiate
  561. * in BroadR-Reach mode.
  562. */
  563. if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54811)
  564. aneg = 0;
  565. else
  566. aneg = val & LRESR_LDSABILITY;
  567. linkmode_mod_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
  568. phydev->supported,
  569. aneg);
  570. linkmode_mod_bit(ETHTOOL_LINK_MODE_100baseT1_Full_BIT,
  571. phydev->supported,
  572. val & LRESR_100_1PAIR);
  573. linkmode_mod_bit(ETHTOOL_LINK_MODE_10baseT1BRR_Full_BIT,
  574. phydev->supported,
  575. val & LRESR_10_1PAIR);
  576. return 0;
  577. }
  578. return genphy_read_abilities(phydev);
  579. }
  580. static int bcm5481x_config_delay_swap(struct phy_device *phydev)
  581. {
  582. struct device_node *np = phydev->mdio.dev.of_node;
  583. /* Set up the delay. */
  584. bcm54xx_config_clock_delay(phydev);
  585. if (of_property_read_bool(np, "enet-phy-lane-swap")) {
  586. /* Lane Swap - Undocumented register...magic! */
  587. int ret = bcm_phy_write_exp(phydev,
  588. MII_BCM54XX_EXP_SEL_ER + 0x9,
  589. 0x11B);
  590. if (ret < 0)
  591. return ret;
  592. }
  593. return 0;
  594. }
  595. static int bcm5481_config_aneg(struct phy_device *phydev)
  596. {
  597. struct bcm54xx_phy_priv *priv = phydev->priv;
  598. int ret;
  599. /* Aneg firstly. */
  600. if (priv->brr_mode)
  601. ret = bcm_config_lre_aneg(phydev, false);
  602. else
  603. ret = genphy_config_aneg(phydev);
  604. if (ret)
  605. return ret;
  606. /* Then we can set up the delay and swap. */
  607. return bcm5481x_config_delay_swap(phydev);
  608. }
  609. static int bcm54811_config_aneg(struct phy_device *phydev)
  610. {
  611. struct bcm54xx_phy_priv *priv = phydev->priv;
  612. int ret;
  613. /* Aneg firstly. */
  614. if (priv->brr_mode) {
  615. /* BCM54811 is only capable of autonegotiation in IEEE mode.
  616. * In BroadR-Reach mode, disable the Long Distance Signaling,
  617. * the BRR mode autoneg as supported in other Broadcom PHYs.
  618. * This bit is marked as "Reserved" and "Default 1, must be
  619. * written to 0 after every device reset" in the datasheet.
  620. */
  621. ret = phy_modify(phydev, MII_BCM54XX_LRECR, LRECR_LDSEN, 0);
  622. if (ret < 0)
  623. return ret;
  624. ret = bcm_config_lre_aneg(phydev, false);
  625. } else {
  626. ret = genphy_config_aneg(phydev);
  627. }
  628. if (ret)
  629. return ret;
  630. /* Then we can set up the delay and swap. */
  631. return bcm5481x_config_delay_swap(phydev);
  632. }
  633. struct bcm54616s_phy_priv {
  634. bool mode_1000bx_en;
  635. };
  636. static int bcm54616s_probe(struct phy_device *phydev)
  637. {
  638. struct bcm54616s_phy_priv *priv;
  639. int val;
  640. priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL);
  641. if (!priv)
  642. return -ENOMEM;
  643. phydev->priv = priv;
  644. val = bcm_phy_read_shadow(phydev, BCM54XX_SHD_MODE);
  645. if (val < 0)
  646. return val;
  647. /* The PHY is strapped in RGMII-fiber mode when INTERF_SEL[1:0]
  648. * is 01b, and the link between PHY and its link partner can be
  649. * either 1000Base-X or 100Base-FX.
  650. * RGMII-1000Base-X is properly supported, but RGMII-100Base-FX
  651. * support is still missing as of now.
  652. */
  653. if ((val & BCM54XX_SHD_INTF_SEL_MASK) == BCM54XX_SHD_INTF_SEL_RGMII) {
  654. val = bcm_phy_read_shadow(phydev, BCM54616S_SHD_100FX_CTRL);
  655. if (val < 0)
  656. return val;
  657. /* Bit 0 of the SerDes 100-FX Control register, when set
  658. * to 1, sets the MII/RGMII -> 100BASE-FX configuration.
  659. * When this bit is set to 0, it sets the GMII/RGMII ->
  660. * 1000BASE-X configuration.
  661. */
  662. if (!(val & BCM54616S_100FX_MODE))
  663. priv->mode_1000bx_en = true;
  664. phydev->port = PORT_FIBRE;
  665. }
  666. return 0;
  667. }
  668. static int bcm54616s_config_aneg(struct phy_device *phydev)
  669. {
  670. struct bcm54616s_phy_priv *priv = phydev->priv;
  671. int ret;
  672. /* Aneg firstly. */
  673. if (priv->mode_1000bx_en)
  674. ret = genphy_c37_config_aneg(phydev);
  675. else
  676. ret = genphy_config_aneg(phydev);
  677. /* Then we can set up the delay. */
  678. bcm54xx_config_clock_delay(phydev);
  679. return ret;
  680. }
  681. static int bcm54616s_read_status(struct phy_device *phydev)
  682. {
  683. struct bcm54616s_phy_priv *priv = phydev->priv;
  684. bool changed;
  685. int err;
  686. if (priv->mode_1000bx_en)
  687. err = genphy_c37_read_status(phydev, &changed);
  688. else
  689. err = genphy_read_status(phydev);
  690. return err;
  691. }
  692. static int brcm_fet_config_init(struct phy_device *phydev)
  693. {
  694. int reg, err, err2, brcmtest;
  695. /* Reset the PHY to bring it to a known state. */
  696. err = phy_write(phydev, MII_BMCR, BMCR_RESET);
  697. if (err < 0)
  698. return err;
  699. /* The datasheet indicates the PHY needs up to 1us to complete a reset,
  700. * build some slack here.
  701. */
  702. usleep_range(1000, 2000);
  703. /* The PHY requires 65 MDC clock cycles to complete a write operation
  704. * and turnaround the line properly.
  705. *
  706. * We ignore -EIO here as the MDIO controller (e.g.: mdio-bcm-unimac)
  707. * may flag the lack of turn-around as a read failure. This is
  708. * particularly true with this combination since the MDIO controller
  709. * only used 64 MDC cycles. This is not a critical failure in this
  710. * specific case and it has no functional impact otherwise, so we let
  711. * that one go through. If there is a genuine bus error, the next read
  712. * of MII_BRCM_FET_INTREG will error out.
  713. */
  714. err = phy_read(phydev, MII_BMCR);
  715. if (err < 0 && err != -EIO)
  716. return err;
  717. /* Read to clear status bits */
  718. reg = phy_read(phydev, MII_BRCM_FET_INTREG);
  719. if (reg < 0)
  720. return reg;
  721. /* Unmask events we are interested in and mask interrupts globally. */
  722. if (phydev->drv->phy_id == PHY_ID_BCM5221)
  723. reg = MII_BRCM_FET_IR_ENABLE |
  724. MII_BRCM_FET_IR_MASK;
  725. else
  726. reg = MII_BRCM_FET_IR_DUPLEX_EN |
  727. MII_BRCM_FET_IR_SPEED_EN |
  728. MII_BRCM_FET_IR_LINK_EN |
  729. MII_BRCM_FET_IR_ENABLE |
  730. MII_BRCM_FET_IR_MASK;
  731. err = phy_write(phydev, MII_BRCM_FET_INTREG, reg);
  732. if (err < 0)
  733. return err;
  734. /* Enable shadow register access */
  735. brcmtest = phy_read(phydev, MII_BRCM_FET_BRCMTEST);
  736. if (brcmtest < 0)
  737. return brcmtest;
  738. reg = brcmtest | MII_BRCM_FET_BT_SRE;
  739. phy_lock_mdio_bus(phydev);
  740. err = __phy_write(phydev, MII_BRCM_FET_BRCMTEST, reg);
  741. if (err < 0) {
  742. phy_unlock_mdio_bus(phydev);
  743. return err;
  744. }
  745. if (phydev->drv->phy_id != PHY_ID_BCM5221) {
  746. /* Set the LED mode */
  747. reg = __phy_read(phydev, MII_BRCM_FET_SHDW_AUXMODE4);
  748. if (reg < 0) {
  749. err = reg;
  750. goto done;
  751. }
  752. err = __phy_modify(phydev, MII_BRCM_FET_SHDW_AUXMODE4,
  753. MII_BRCM_FET_SHDW_AM4_LED_MASK,
  754. MII_BRCM_FET_SHDW_AM4_LED_MODE1);
  755. if (err < 0)
  756. goto done;
  757. /* Enable auto MDIX */
  758. err = __phy_set_bits(phydev, MII_BRCM_FET_SHDW_MISCCTRL,
  759. MII_BRCM_FET_SHDW_MC_FAME);
  760. if (err < 0)
  761. goto done;
  762. }
  763. if (phydev->dev_flags & PHY_BRCM_AUTO_PWRDWN_ENABLE) {
  764. /* Enable auto power down */
  765. err = __phy_set_bits(phydev, MII_BRCM_FET_SHDW_AUXSTAT2,
  766. MII_BRCM_FET_SHDW_AS2_APDE);
  767. }
  768. done:
  769. /* Disable shadow register access */
  770. err2 = __phy_write(phydev, MII_BRCM_FET_BRCMTEST, brcmtest);
  771. if (!err)
  772. err = err2;
  773. phy_unlock_mdio_bus(phydev);
  774. return err;
  775. }
  776. static int brcm_fet_ack_interrupt(struct phy_device *phydev)
  777. {
  778. int reg;
  779. /* Clear pending interrupts. */
  780. reg = phy_read(phydev, MII_BRCM_FET_INTREG);
  781. if (reg < 0)
  782. return reg;
  783. return 0;
  784. }
  785. static int brcm_fet_config_intr(struct phy_device *phydev)
  786. {
  787. int reg, err;
  788. reg = phy_read(phydev, MII_BRCM_FET_INTREG);
  789. if (reg < 0)
  790. return reg;
  791. if (phydev->interrupts == PHY_INTERRUPT_ENABLED) {
  792. err = brcm_fet_ack_interrupt(phydev);
  793. if (err)
  794. return err;
  795. reg &= ~MII_BRCM_FET_IR_MASK;
  796. err = phy_write(phydev, MII_BRCM_FET_INTREG, reg);
  797. } else {
  798. reg |= MII_BRCM_FET_IR_MASK;
  799. err = phy_write(phydev, MII_BRCM_FET_INTREG, reg);
  800. if (err)
  801. return err;
  802. err = brcm_fet_ack_interrupt(phydev);
  803. }
  804. return err;
  805. }
  806. static irqreturn_t brcm_fet_handle_interrupt(struct phy_device *phydev)
  807. {
  808. int irq_status;
  809. irq_status = phy_read(phydev, MII_BRCM_FET_INTREG);
  810. if (irq_status < 0) {
  811. phy_error(phydev);
  812. return IRQ_NONE;
  813. }
  814. if (irq_status == 0)
  815. return IRQ_NONE;
  816. phy_trigger_machine(phydev);
  817. return IRQ_HANDLED;
  818. }
  819. static int brcm_fet_suspend(struct phy_device *phydev)
  820. {
  821. int reg, err, err2, brcmtest;
  822. /* We cannot use a read/modify/write here otherwise the PHY continues
  823. * to drive LEDs which defeats the purpose of low power mode.
  824. */
  825. err = phy_write(phydev, MII_BMCR, BMCR_PDOWN);
  826. if (err < 0)
  827. return err;
  828. /* Enable shadow register access */
  829. brcmtest = phy_read(phydev, MII_BRCM_FET_BRCMTEST);
  830. if (brcmtest < 0)
  831. return brcmtest;
  832. reg = brcmtest | MII_BRCM_FET_BT_SRE;
  833. phy_lock_mdio_bus(phydev);
  834. err = __phy_write(phydev, MII_BRCM_FET_BRCMTEST, reg);
  835. if (err < 0) {
  836. phy_unlock_mdio_bus(phydev);
  837. return err;
  838. }
  839. if (phydev->drv->phy_id == PHY_ID_BCM5221)
  840. /* Force Low Power Mode with clock enabled */
  841. reg = BCM5221_SHDW_AM4_EN_CLK_LPM | BCM5221_SHDW_AM4_FORCE_LPM;
  842. else
  843. /* Set standby mode */
  844. reg = MII_BRCM_FET_SHDW_AM4_STANDBY;
  845. err = __phy_set_bits(phydev, MII_BRCM_FET_SHDW_AUXMODE4, reg);
  846. /* Disable shadow register access */
  847. err2 = __phy_write(phydev, MII_BRCM_FET_BRCMTEST, brcmtest);
  848. if (!err)
  849. err = err2;
  850. phy_unlock_mdio_bus(phydev);
  851. return err;
  852. }
  853. static int bcm5221_config_aneg(struct phy_device *phydev)
  854. {
  855. int ret, val;
  856. ret = genphy_config_aneg(phydev);
  857. if (ret)
  858. return ret;
  859. switch (phydev->mdix_ctrl) {
  860. case ETH_TP_MDI:
  861. val = BCM5221_AEGSR_MDIX_DIS;
  862. break;
  863. case ETH_TP_MDI_X:
  864. val = BCM5221_AEGSR_MDIX_DIS | BCM5221_AEGSR_MDIX_MAN_SWAP;
  865. break;
  866. case ETH_TP_MDI_AUTO:
  867. val = 0;
  868. break;
  869. default:
  870. return 0;
  871. }
  872. return phy_modify(phydev, BCM5221_AEGSR, BCM5221_AEGSR_MDIX_MAN_SWAP |
  873. BCM5221_AEGSR_MDIX_DIS,
  874. val);
  875. }
  876. static int bcm5221_read_status(struct phy_device *phydev)
  877. {
  878. int ret;
  879. /* Read MDIX status */
  880. ret = phy_read(phydev, BCM5221_AEGSR);
  881. if (ret < 0)
  882. return ret;
  883. if (ret & BCM5221_AEGSR_MDIX_DIS) {
  884. if (ret & BCM5221_AEGSR_MDIX_MAN_SWAP)
  885. phydev->mdix_ctrl = ETH_TP_MDI_X;
  886. else
  887. phydev->mdix_ctrl = ETH_TP_MDI;
  888. } else {
  889. phydev->mdix_ctrl = ETH_TP_MDI_AUTO;
  890. }
  891. if (ret & BCM5221_AEGSR_MDIX_STATUS)
  892. phydev->mdix = ETH_TP_MDI_X;
  893. else
  894. phydev->mdix = ETH_TP_MDI;
  895. return genphy_read_status(phydev);
  896. }
  897. static void bcm54xx_phy_get_wol(struct phy_device *phydev,
  898. struct ethtool_wolinfo *wol)
  899. {
  900. /* We cannot wake-up if we do not have a dedicated PHY interrupt line
  901. * or an out of band GPIO descriptor for wake-up. Zeroing
  902. * wol->supported allows the caller (MAC driver) to play through and
  903. * offer its own Wake-on-LAN scheme if available.
  904. */
  905. if (!bcm54xx_phy_can_wakeup(phydev)) {
  906. wol->supported = 0;
  907. return;
  908. }
  909. bcm_phy_get_wol(phydev, wol);
  910. }
  911. static int bcm54xx_phy_set_wol(struct phy_device *phydev,
  912. struct ethtool_wolinfo *wol)
  913. {
  914. int ret;
  915. /* We cannot wake-up if we do not have a dedicated PHY interrupt line
  916. * or an out of band GPIO descriptor for wake-up. Returning -EOPNOTSUPP
  917. * allows the caller (MAC driver) to play through and offer its own
  918. * Wake-on-LAN scheme if available.
  919. */
  920. if (!bcm54xx_phy_can_wakeup(phydev))
  921. return -EOPNOTSUPP;
  922. ret = bcm_phy_set_wol(phydev, wol);
  923. if (ret < 0)
  924. return ret;
  925. return 0;
  926. }
  927. static int bcm54xx_phy_probe(struct phy_device *phydev)
  928. {
  929. struct bcm54xx_phy_priv *priv;
  930. struct gpio_desc *wakeup_gpio;
  931. int ret = 0;
  932. priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL);
  933. if (!priv)
  934. return -ENOMEM;
  935. priv->wake_irq = -ENXIO;
  936. phydev->priv = priv;
  937. priv->stats = devm_kcalloc(&phydev->mdio.dev,
  938. bcm_phy_get_sset_count(phydev), sizeof(u64),
  939. GFP_KERNEL);
  940. if (!priv->stats)
  941. return -ENOMEM;
  942. priv->ptp = bcm_ptp_probe(phydev);
  943. if (IS_ERR(priv->ptp))
  944. return PTR_ERR(priv->ptp);
  945. /* We cannot utilize the _optional variant here since we want to know
  946. * whether the GPIO descriptor exists or not to advertise Wake-on-LAN
  947. * support or not.
  948. */
  949. wakeup_gpio = devm_gpiod_get(&phydev->mdio.dev, "wakeup", GPIOD_IN);
  950. if (PTR_ERR(wakeup_gpio) == -EPROBE_DEFER)
  951. return PTR_ERR(wakeup_gpio);
  952. if (!IS_ERR(wakeup_gpio)) {
  953. priv->wake_irq = gpiod_to_irq(wakeup_gpio);
  954. /* Dummy interrupt handler which is not enabled but is provided
  955. * in order for the interrupt descriptor to be fully set-up.
  956. */
  957. ret = devm_request_irq(&phydev->mdio.dev, priv->wake_irq,
  958. bcm_phy_wol_isr,
  959. IRQF_TRIGGER_LOW | IRQF_NO_AUTOEN,
  960. dev_name(&phydev->mdio.dev), phydev);
  961. if (ret)
  962. return ret;
  963. }
  964. /* If we do not have a main interrupt or a side-band wake-up interrupt,
  965. * then the device cannot be marked as wake-up capable.
  966. */
  967. if (!bcm54xx_phy_can_wakeup(phydev))
  968. return 0;
  969. return device_init_wakeup(&phydev->mdio.dev, true);
  970. }
  971. static void bcm54xx_get_stats(struct phy_device *phydev,
  972. struct ethtool_stats *stats, u64 *data)
  973. {
  974. struct bcm54xx_phy_priv *priv = phydev->priv;
  975. bcm_phy_get_stats(phydev, priv->stats, stats, data);
  976. }
  977. static void bcm54xx_link_change_notify(struct phy_device *phydev)
  978. {
  979. u16 mask = MII_BCM54XX_EXP_EXP08_EARLY_DAC_WAKE |
  980. MII_BCM54XX_EXP_EXP08_FORCE_DAC_WAKE;
  981. int ret;
  982. if (phydev->state != PHY_RUNNING)
  983. return;
  984. /* Don't change the DAC wake settings if auto power down
  985. * is not requested.
  986. */
  987. if (!(phydev->dev_flags & PHY_BRCM_AUTO_PWRDWN_ENABLE))
  988. return;
  989. ret = bcm_phy_read_exp(phydev, MII_BCM54XX_EXP_EXP08);
  990. if (ret < 0)
  991. return;
  992. /* Enable/disable 10BaseT auto and forced early DAC wake depending
  993. * on the negotiated speed, those settings should only be done
  994. * for 10Mbits/sec.
  995. */
  996. if (phydev->speed == SPEED_10)
  997. ret |= mask;
  998. else
  999. ret &= ~mask;
  1000. bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_EXP08, ret);
  1001. }
  1002. static int lre_read_master_slave(struct phy_device *phydev)
  1003. {
  1004. int cfg = MASTER_SLAVE_CFG_UNKNOWN, state;
  1005. int val;
  1006. /* In BroadR-Reach mode we are always capable of master-slave
  1007. * and there is no preferred master or slave configuration
  1008. */
  1009. phydev->master_slave_get = MASTER_SLAVE_CFG_UNKNOWN;
  1010. phydev->master_slave_state = MASTER_SLAVE_STATE_UNKNOWN;
  1011. val = phy_read(phydev, MII_BCM54XX_LRECR);
  1012. if (val < 0)
  1013. return val;
  1014. if ((val & LRECR_LDSEN) == 0) {
  1015. if (val & LRECR_MASTER)
  1016. cfg = MASTER_SLAVE_CFG_MASTER_FORCE;
  1017. else
  1018. cfg = MASTER_SLAVE_CFG_SLAVE_FORCE;
  1019. }
  1020. val = phy_read(phydev, MII_BCM54XX_LRELDSE);
  1021. if (val < 0)
  1022. return val;
  1023. if (val & LDSE_MASTER)
  1024. state = MASTER_SLAVE_STATE_MASTER;
  1025. else
  1026. state = MASTER_SLAVE_STATE_SLAVE;
  1027. phydev->master_slave_get = cfg;
  1028. phydev->master_slave_state = state;
  1029. return 0;
  1030. }
  1031. /* Read LDS Link Partner Ability in BroadR-Reach mode */
  1032. static int lre_read_lpa(struct phy_device *phydev)
  1033. {
  1034. int i, lrelpa;
  1035. if (phydev->autoneg != AUTONEG_ENABLE) {
  1036. if (!phydev->autoneg_complete) {
  1037. /* aneg not yet done, reset all relevant bits */
  1038. for (i = 0; i < ARRAY_SIZE(lds_br_bits); i++)
  1039. linkmode_clear_bit(lds_br_bits[i],
  1040. phydev->lp_advertising);
  1041. return 0;
  1042. }
  1043. /* Long-Distance Signaling Link Partner Ability */
  1044. lrelpa = phy_read(phydev, MII_BCM54XX_LRELPA);
  1045. if (lrelpa < 0)
  1046. return lrelpa;
  1047. linkmode_mod_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT,
  1048. phydev->lp_advertising,
  1049. lrelpa & LRELPA_PAUSE_ASYM);
  1050. linkmode_mod_bit(ETHTOOL_LINK_MODE_Pause_BIT,
  1051. phydev->lp_advertising,
  1052. lrelpa & LRELPA_PAUSE);
  1053. linkmode_mod_bit(ETHTOOL_LINK_MODE_100baseT1_Full_BIT,
  1054. phydev->lp_advertising,
  1055. lrelpa & LRELPA_100_1PAIR);
  1056. linkmode_mod_bit(ETHTOOL_LINK_MODE_10baseT1BRR_Full_BIT,
  1057. phydev->lp_advertising,
  1058. lrelpa & LRELPA_10_1PAIR);
  1059. } else {
  1060. linkmode_zero(phydev->lp_advertising);
  1061. }
  1062. return 0;
  1063. }
  1064. static int lre_read_status_fixed(struct phy_device *phydev)
  1065. {
  1066. int lrecr = phy_read(phydev, MII_BCM54XX_LRECR);
  1067. if (lrecr < 0)
  1068. return lrecr;
  1069. phydev->duplex = DUPLEX_FULL;
  1070. if (lrecr & LRECR_SPEED100)
  1071. phydev->speed = SPEED_100;
  1072. else
  1073. phydev->speed = SPEED_10;
  1074. return 0;
  1075. }
  1076. /**
  1077. * lre_update_link - update link status in @phydev
  1078. * @phydev: target phy_device struct
  1079. * Return: 0 on success, < 0 on error
  1080. *
  1081. * Description: Update the value in phydev->link to reflect the
  1082. * current link value. In order to do this, we need to read
  1083. * the status register twice, keeping the second value.
  1084. * This is a genphy_update_link modified to work on LRE registers
  1085. * of BroadR-Reach PHY
  1086. */
  1087. static int lre_update_link(struct phy_device *phydev)
  1088. {
  1089. int status = 0, lrecr;
  1090. lrecr = phy_read(phydev, MII_BCM54XX_LRECR);
  1091. if (lrecr < 0)
  1092. return lrecr;
  1093. /* Autoneg is being started, therefore disregard BMSR value and
  1094. * report link as down.
  1095. */
  1096. if (lrecr & BMCR_ANRESTART)
  1097. goto done;
  1098. /* The link state is latched low so that momentary link
  1099. * drops can be detected. Do not double-read the status
  1100. * in polling mode to detect such short link drops except
  1101. * the link was already down.
  1102. */
  1103. if (!phy_polling_mode(phydev) || !phydev->link) {
  1104. status = phy_read(phydev, MII_BCM54XX_LRESR);
  1105. if (status < 0)
  1106. return status;
  1107. else if (status & LRESR_LSTATUS)
  1108. goto done;
  1109. }
  1110. /* Read link and autonegotiation status */
  1111. status = phy_read(phydev, MII_BCM54XX_LRESR);
  1112. if (status < 0)
  1113. return status;
  1114. done:
  1115. phydev->link = status & LRESR_LSTATUS ? 1 : 0;
  1116. phydev->autoneg_complete = status & LRESR_LDSCOMPLETE ? 1 : 0;
  1117. /* Consider the case that autoneg was started and "aneg complete"
  1118. * bit has been reset, but "link up" bit not yet.
  1119. */
  1120. if (phydev->autoneg == AUTONEG_ENABLE && !phydev->autoneg_complete)
  1121. phydev->link = 0;
  1122. return 0;
  1123. }
  1124. /* Get the status in BroadRReach mode just like genphy_read_status does
  1125. * in normal mode
  1126. */
  1127. static int bcm54811_lre_read_status(struct phy_device *phydev)
  1128. {
  1129. int err, old_link = phydev->link;
  1130. /* Update the link, but return if there was an error */
  1131. err = lre_update_link(phydev);
  1132. if (err)
  1133. return err;
  1134. /* why bother the PHY if nothing can have changed */
  1135. if (phydev->autoneg ==
  1136. AUTONEG_ENABLE && old_link && phydev->link)
  1137. return 0;
  1138. phydev->speed = SPEED_UNKNOWN;
  1139. phydev->duplex = DUPLEX_UNKNOWN;
  1140. phydev->pause = 0;
  1141. phydev->asym_pause = 0;
  1142. err = lre_read_master_slave(phydev);
  1143. if (err < 0)
  1144. return err;
  1145. /* Read LDS Link Partner Ability */
  1146. err = lre_read_lpa(phydev);
  1147. if (err < 0)
  1148. return err;
  1149. if (phydev->autoneg == AUTONEG_ENABLE && phydev->autoneg_complete)
  1150. phy_resolve_aneg_linkmode(phydev);
  1151. else if (phydev->autoneg == AUTONEG_DISABLE)
  1152. err = lre_read_status_fixed(phydev);
  1153. return err;
  1154. }
  1155. static int bcm54811_read_status(struct phy_device *phydev)
  1156. {
  1157. struct bcm54xx_phy_priv *priv = phydev->priv;
  1158. if (priv->brr_mode)
  1159. return bcm54811_lre_read_status(phydev);
  1160. return genphy_read_status(phydev);
  1161. }
  1162. static struct phy_driver broadcom_drivers[] = {
  1163. {
  1164. .phy_id = PHY_ID_BCM5411,
  1165. .phy_id_mask = 0xfffffff0,
  1166. .name = "Broadcom BCM5411",
  1167. /* PHY_GBIT_FEATURES */
  1168. .get_sset_count = bcm_phy_get_sset_count,
  1169. .get_strings = bcm_phy_get_strings,
  1170. .get_stats = bcm54xx_get_stats,
  1171. .probe = bcm54xx_phy_probe,
  1172. .config_init = bcm54xx_config_init,
  1173. .config_intr = bcm_phy_config_intr,
  1174. .handle_interrupt = bcm_phy_handle_interrupt,
  1175. .link_change_notify = bcm54xx_link_change_notify,
  1176. }, {
  1177. .phy_id = PHY_ID_BCM5421,
  1178. .phy_id_mask = 0xfffffff0,
  1179. .name = "Broadcom BCM5421",
  1180. /* PHY_GBIT_FEATURES */
  1181. .get_sset_count = bcm_phy_get_sset_count,
  1182. .get_strings = bcm_phy_get_strings,
  1183. .get_stats = bcm54xx_get_stats,
  1184. .probe = bcm54xx_phy_probe,
  1185. .config_init = bcm54xx_config_init,
  1186. .config_intr = bcm_phy_config_intr,
  1187. .handle_interrupt = bcm_phy_handle_interrupt,
  1188. .link_change_notify = bcm54xx_link_change_notify,
  1189. }, {
  1190. .phy_id = PHY_ID_BCM54210E,
  1191. .phy_id_mask = 0xfffffff0,
  1192. .name = "Broadcom BCM54210E",
  1193. /* PHY_GBIT_FEATURES */
  1194. .flags = PHY_ALWAYS_CALL_SUSPEND,
  1195. .get_sset_count = bcm_phy_get_sset_count,
  1196. .get_strings = bcm_phy_get_strings,
  1197. .get_stats = bcm54xx_get_stats,
  1198. .probe = bcm54xx_phy_probe,
  1199. .config_init = bcm54xx_config_init,
  1200. .config_intr = bcm_phy_config_intr,
  1201. .handle_interrupt = bcm_phy_handle_interrupt,
  1202. .link_change_notify = bcm54xx_link_change_notify,
  1203. .suspend = bcm54xx_suspend,
  1204. .resume = bcm54xx_resume,
  1205. .get_wol = bcm54xx_phy_get_wol,
  1206. .set_wol = bcm54xx_phy_set_wol,
  1207. .led_brightness_set = bcm_phy_led_brightness_set,
  1208. }, {
  1209. .phy_id = PHY_ID_BCM5461,
  1210. .phy_id_mask = 0xfffffff0,
  1211. .name = "Broadcom BCM5461",
  1212. /* PHY_GBIT_FEATURES */
  1213. .get_sset_count = bcm_phy_get_sset_count,
  1214. .get_strings = bcm_phy_get_strings,
  1215. .get_stats = bcm54xx_get_stats,
  1216. .probe = bcm54xx_phy_probe,
  1217. .config_init = bcm54xx_config_init,
  1218. .config_intr = bcm_phy_config_intr,
  1219. .handle_interrupt = bcm_phy_handle_interrupt,
  1220. .link_change_notify = bcm54xx_link_change_notify,
  1221. .led_brightness_set = bcm_phy_led_brightness_set,
  1222. }, {
  1223. .phy_id = PHY_ID_BCM54612E,
  1224. .phy_id_mask = 0xfffffff0,
  1225. .name = "Broadcom BCM54612E",
  1226. /* PHY_GBIT_FEATURES */
  1227. .get_sset_count = bcm_phy_get_sset_count,
  1228. .get_strings = bcm_phy_get_strings,
  1229. .get_stats = bcm54xx_get_stats,
  1230. .probe = bcm54xx_phy_probe,
  1231. .config_init = bcm54xx_config_init,
  1232. .config_intr = bcm_phy_config_intr,
  1233. .handle_interrupt = bcm_phy_handle_interrupt,
  1234. .link_change_notify = bcm54xx_link_change_notify,
  1235. .led_brightness_set = bcm_phy_led_brightness_set,
  1236. .suspend = bcm54xx_suspend,
  1237. .resume = bcm54xx_resume,
  1238. }, {
  1239. .phy_id = PHY_ID_BCM54616S,
  1240. .phy_id_mask = 0xfffffff0,
  1241. .name = "Broadcom BCM54616S",
  1242. /* PHY_GBIT_FEATURES */
  1243. .soft_reset = genphy_soft_reset,
  1244. .config_init = bcm54xx_config_init,
  1245. .config_aneg = bcm54616s_config_aneg,
  1246. .config_intr = bcm_phy_config_intr,
  1247. .handle_interrupt = bcm_phy_handle_interrupt,
  1248. .read_status = bcm54616s_read_status,
  1249. .probe = bcm54616s_probe,
  1250. .link_change_notify = bcm54xx_link_change_notify,
  1251. .led_brightness_set = bcm_phy_led_brightness_set,
  1252. }, {
  1253. .phy_id = PHY_ID_BCM5464,
  1254. .phy_id_mask = 0xfffffff0,
  1255. .name = "Broadcom BCM5464",
  1256. /* PHY_GBIT_FEATURES */
  1257. .get_sset_count = bcm_phy_get_sset_count,
  1258. .get_strings = bcm_phy_get_strings,
  1259. .get_stats = bcm54xx_get_stats,
  1260. .probe = bcm54xx_phy_probe,
  1261. .config_init = bcm54xx_config_init,
  1262. .config_intr = bcm_phy_config_intr,
  1263. .handle_interrupt = bcm_phy_handle_interrupt,
  1264. .suspend = genphy_suspend,
  1265. .resume = genphy_resume,
  1266. .link_change_notify = bcm54xx_link_change_notify,
  1267. .led_brightness_set = bcm_phy_led_brightness_set,
  1268. }, {
  1269. .phy_id = PHY_ID_BCM5481,
  1270. .phy_id_mask = 0xfffffff0,
  1271. .name = "Broadcom BCM5481",
  1272. /* PHY_GBIT_FEATURES */
  1273. .get_sset_count = bcm_phy_get_sset_count,
  1274. .get_strings = bcm_phy_get_strings,
  1275. .get_stats = bcm54xx_get_stats,
  1276. .probe = bcm54xx_phy_probe,
  1277. .config_init = bcm54xx_config_init,
  1278. .config_aneg = bcm5481_config_aneg,
  1279. .config_intr = bcm_phy_config_intr,
  1280. .handle_interrupt = bcm_phy_handle_interrupt,
  1281. .link_change_notify = bcm54xx_link_change_notify,
  1282. .led_brightness_set = bcm_phy_led_brightness_set,
  1283. }, {
  1284. .phy_id = PHY_ID_BCM54810,
  1285. .phy_id_mask = 0xfffffff0,
  1286. .name = "Broadcom BCM54810",
  1287. /* PHY_GBIT_FEATURES */
  1288. .get_sset_count = bcm_phy_get_sset_count,
  1289. .get_strings = bcm_phy_get_strings,
  1290. .get_stats = bcm54xx_get_stats,
  1291. .probe = bcm54xx_phy_probe,
  1292. .read_mmd = bcm54810_read_mmd,
  1293. .write_mmd = bcm54810_write_mmd,
  1294. .config_init = bcm54xx_config_init,
  1295. .config_aneg = bcm5481_config_aneg,
  1296. .config_intr = bcm_phy_config_intr,
  1297. .handle_interrupt = bcm_phy_handle_interrupt,
  1298. .suspend = bcm54xx_suspend,
  1299. .resume = bcm54xx_resume,
  1300. .link_change_notify = bcm54xx_link_change_notify,
  1301. .led_brightness_set = bcm_phy_led_brightness_set,
  1302. }, {
  1303. .phy_id = PHY_ID_BCM54811,
  1304. .phy_id_mask = 0xfffffff0,
  1305. .name = "Broadcom BCM54811",
  1306. /* PHY_GBIT_FEATURES */
  1307. .get_sset_count = bcm_phy_get_sset_count,
  1308. .get_strings = bcm_phy_get_strings,
  1309. .get_stats = bcm54xx_get_stats,
  1310. .probe = bcm54xx_phy_probe,
  1311. .config_init = bcm54xx_config_init,
  1312. .config_aneg = bcm54811_config_aneg,
  1313. .config_intr = bcm_phy_config_intr,
  1314. .handle_interrupt = bcm_phy_handle_interrupt,
  1315. .read_status = bcm54811_read_status,
  1316. .get_features = bcm5481x_read_abilities,
  1317. .suspend = bcm54xx_suspend,
  1318. .resume = bcm54xx_resume,
  1319. .link_change_notify = bcm54xx_link_change_notify,
  1320. .led_brightness_set = bcm_phy_led_brightness_set,
  1321. }, {
  1322. .phy_id = PHY_ID_BCM5482,
  1323. .phy_id_mask = 0xfffffff0,
  1324. .name = "Broadcom BCM5482",
  1325. /* PHY_GBIT_FEATURES */
  1326. .get_sset_count = bcm_phy_get_sset_count,
  1327. .get_strings = bcm_phy_get_strings,
  1328. .get_stats = bcm54xx_get_stats,
  1329. .probe = bcm54xx_phy_probe,
  1330. .config_init = bcm54xx_config_init,
  1331. .config_intr = bcm_phy_config_intr,
  1332. .handle_interrupt = bcm_phy_handle_interrupt,
  1333. .link_change_notify = bcm54xx_link_change_notify,
  1334. .led_brightness_set = bcm_phy_led_brightness_set,
  1335. }, {
  1336. .phy_id = PHY_ID_BCM50610,
  1337. .phy_id_mask = 0xfffffff0,
  1338. .name = "Broadcom BCM50610",
  1339. /* PHY_GBIT_FEATURES */
  1340. .get_sset_count = bcm_phy_get_sset_count,
  1341. .get_strings = bcm_phy_get_strings,
  1342. .get_stats = bcm54xx_get_stats,
  1343. .probe = bcm54xx_phy_probe,
  1344. .config_init = bcm54xx_config_init,
  1345. .config_intr = bcm_phy_config_intr,
  1346. .handle_interrupt = bcm_phy_handle_interrupt,
  1347. .link_change_notify = bcm54xx_link_change_notify,
  1348. .suspend = bcm54xx_suspend,
  1349. .resume = bcm54xx_resume,
  1350. .led_brightness_set = bcm_phy_led_brightness_set,
  1351. }, {
  1352. .phy_id = PHY_ID_BCM50610M,
  1353. .phy_id_mask = 0xfffffff0,
  1354. .name = "Broadcom BCM50610M",
  1355. /* PHY_GBIT_FEATURES */
  1356. .get_sset_count = bcm_phy_get_sset_count,
  1357. .get_strings = bcm_phy_get_strings,
  1358. .get_stats = bcm54xx_get_stats,
  1359. .probe = bcm54xx_phy_probe,
  1360. .config_init = bcm54xx_config_init,
  1361. .config_intr = bcm_phy_config_intr,
  1362. .handle_interrupt = bcm_phy_handle_interrupt,
  1363. .link_change_notify = bcm54xx_link_change_notify,
  1364. .suspend = bcm54xx_suspend,
  1365. .resume = bcm54xx_resume,
  1366. .led_brightness_set = bcm_phy_led_brightness_set,
  1367. }, {
  1368. .phy_id = PHY_ID_BCM57780,
  1369. .phy_id_mask = 0xfffffff0,
  1370. .name = "Broadcom BCM57780",
  1371. /* PHY_GBIT_FEATURES */
  1372. .get_sset_count = bcm_phy_get_sset_count,
  1373. .get_strings = bcm_phy_get_strings,
  1374. .get_stats = bcm54xx_get_stats,
  1375. .probe = bcm54xx_phy_probe,
  1376. .config_init = bcm54xx_config_init,
  1377. .config_intr = bcm_phy_config_intr,
  1378. .handle_interrupt = bcm_phy_handle_interrupt,
  1379. .link_change_notify = bcm54xx_link_change_notify,
  1380. .led_brightness_set = bcm_phy_led_brightness_set,
  1381. }, {
  1382. .phy_id = PHY_ID_BCMAC131,
  1383. .phy_id_mask = 0xfffffff0,
  1384. .name = "Broadcom BCMAC131",
  1385. /* PHY_BASIC_FEATURES */
  1386. .config_init = brcm_fet_config_init,
  1387. .config_intr = brcm_fet_config_intr,
  1388. .handle_interrupt = brcm_fet_handle_interrupt,
  1389. .suspend = brcm_fet_suspend,
  1390. .resume = brcm_fet_config_init,
  1391. }, {
  1392. .phy_id = PHY_ID_BCM5241,
  1393. .phy_id_mask = 0xfffffff0,
  1394. .name = "Broadcom BCM5241",
  1395. /* PHY_BASIC_FEATURES */
  1396. .config_init = brcm_fet_config_init,
  1397. .config_intr = brcm_fet_config_intr,
  1398. .handle_interrupt = brcm_fet_handle_interrupt,
  1399. .suspend = brcm_fet_suspend,
  1400. .resume = brcm_fet_config_init,
  1401. }, {
  1402. .phy_id = PHY_ID_BCM5221,
  1403. .phy_id_mask = 0xfffffff0,
  1404. .name = "Broadcom BCM5221",
  1405. /* PHY_BASIC_FEATURES */
  1406. .config_init = brcm_fet_config_init,
  1407. .config_intr = brcm_fet_config_intr,
  1408. .handle_interrupt = brcm_fet_handle_interrupt,
  1409. .suspend = brcm_fet_suspend,
  1410. .resume = brcm_fet_config_init,
  1411. .config_aneg = bcm5221_config_aneg,
  1412. .read_status = bcm5221_read_status,
  1413. }, {
  1414. .phy_id = PHY_ID_BCM5395,
  1415. .phy_id_mask = 0xfffffff0,
  1416. .name = "Broadcom BCM5395",
  1417. .flags = PHY_IS_INTERNAL,
  1418. /* PHY_GBIT_FEATURES */
  1419. .get_sset_count = bcm_phy_get_sset_count,
  1420. .get_strings = bcm_phy_get_strings,
  1421. .get_stats = bcm54xx_get_stats,
  1422. .probe = bcm54xx_phy_probe,
  1423. .link_change_notify = bcm54xx_link_change_notify,
  1424. .led_brightness_set = bcm_phy_led_brightness_set,
  1425. }, {
  1426. .phy_id = PHY_ID_BCM53125,
  1427. .phy_id_mask = 0xfffffff0,
  1428. .name = "Broadcom BCM53125",
  1429. .flags = PHY_IS_INTERNAL,
  1430. /* PHY_GBIT_FEATURES */
  1431. .get_sset_count = bcm_phy_get_sset_count,
  1432. .get_strings = bcm_phy_get_strings,
  1433. .get_stats = bcm54xx_get_stats,
  1434. .probe = bcm54xx_phy_probe,
  1435. .config_init = bcm54xx_config_init,
  1436. .config_intr = bcm_phy_config_intr,
  1437. .handle_interrupt = bcm_phy_handle_interrupt,
  1438. .link_change_notify = bcm54xx_link_change_notify,
  1439. .led_brightness_set = bcm_phy_led_brightness_set,
  1440. }, {
  1441. .phy_id = PHY_ID_BCM53128,
  1442. .phy_id_mask = 0xfffffff0,
  1443. .name = "Broadcom BCM53128",
  1444. .flags = PHY_IS_INTERNAL,
  1445. /* PHY_GBIT_FEATURES */
  1446. .get_sset_count = bcm_phy_get_sset_count,
  1447. .get_strings = bcm_phy_get_strings,
  1448. .get_stats = bcm54xx_get_stats,
  1449. .probe = bcm54xx_phy_probe,
  1450. .config_init = bcm54xx_config_init,
  1451. .config_intr = bcm_phy_config_intr,
  1452. .handle_interrupt = bcm_phy_handle_interrupt,
  1453. .link_change_notify = bcm54xx_link_change_notify,
  1454. .led_brightness_set = bcm_phy_led_brightness_set,
  1455. }, {
  1456. .phy_id = PHY_ID_BCM89610,
  1457. .phy_id_mask = 0xfffffff0,
  1458. .name = "Broadcom BCM89610",
  1459. /* PHY_GBIT_FEATURES */
  1460. .get_sset_count = bcm_phy_get_sset_count,
  1461. .get_strings = bcm_phy_get_strings,
  1462. .get_stats = bcm54xx_get_stats,
  1463. .probe = bcm54xx_phy_probe,
  1464. .config_init = bcm54xx_config_init,
  1465. .config_intr = bcm_phy_config_intr,
  1466. .handle_interrupt = bcm_phy_handle_interrupt,
  1467. .link_change_notify = bcm54xx_link_change_notify,
  1468. } };
  1469. module_phy_driver(broadcom_drivers);
  1470. static struct mdio_device_id __maybe_unused broadcom_tbl[] = {
  1471. { PHY_ID_BCM5411, 0xfffffff0 },
  1472. { PHY_ID_BCM5421, 0xfffffff0 },
  1473. { PHY_ID_BCM54210E, 0xfffffff0 },
  1474. { PHY_ID_BCM5461, 0xfffffff0 },
  1475. { PHY_ID_BCM54612E, 0xfffffff0 },
  1476. { PHY_ID_BCM54616S, 0xfffffff0 },
  1477. { PHY_ID_BCM5464, 0xfffffff0 },
  1478. { PHY_ID_BCM5481, 0xfffffff0 },
  1479. { PHY_ID_BCM54810, 0xfffffff0 },
  1480. { PHY_ID_BCM54811, 0xfffffff0 },
  1481. { PHY_ID_BCM5482, 0xfffffff0 },
  1482. { PHY_ID_BCM50610, 0xfffffff0 },
  1483. { PHY_ID_BCM50610M, 0xfffffff0 },
  1484. { PHY_ID_BCM57780, 0xfffffff0 },
  1485. { PHY_ID_BCMAC131, 0xfffffff0 },
  1486. { PHY_ID_BCM5221, 0xfffffff0 },
  1487. { PHY_ID_BCM5241, 0xfffffff0 },
  1488. { PHY_ID_BCM5395, 0xfffffff0 },
  1489. { PHY_ID_BCM53125, 0xfffffff0 },
  1490. { PHY_ID_BCM53128, 0xfffffff0 },
  1491. { PHY_ID_BCM89610, 0xfffffff0 },
  1492. { }
  1493. };
  1494. MODULE_DEVICE_TABLE(mdio, broadcom_tbl);