bcmmii.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  1. /*
  2. * Broadcom GENET MDIO routines
  3. *
  4. * Copyright (c) 2014-2017 Broadcom
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #include <linux/types.h>
  11. #include <linux/delay.h>
  12. #include <linux/wait.h>
  13. #include <linux/mii.h>
  14. #include <linux/ethtool.h>
  15. #include <linux/bitops.h>
  16. #include <linux/netdevice.h>
  17. #include <linux/platform_device.h>
  18. #include <linux/phy.h>
  19. #include <linux/phy_fixed.h>
  20. #include <linux/brcmphy.h>
  21. #include <linux/of.h>
  22. #include <linux/of_net.h>
  23. #include <linux/of_mdio.h>
  24. #include <linux/platform_data/bcmgenet.h>
  25. #include <linux/platform_data/mdio-bcm-unimac.h>
  26. #include "bcmgenet.h"
  27. /* setup netdev link state when PHY link status change and
  28. * update UMAC and RGMII block when link up
  29. */
  30. void bcmgenet_mii_setup(struct net_device *dev)
  31. {
  32. struct bcmgenet_priv *priv = netdev_priv(dev);
  33. struct phy_device *phydev = dev->phydev;
  34. u32 reg, cmd_bits = 0;
  35. bool status_changed = false;
  36. if (priv->old_link != phydev->link) {
  37. status_changed = true;
  38. priv->old_link = phydev->link;
  39. }
  40. if (phydev->link) {
  41. /* check speed/duplex/pause changes */
  42. if (priv->old_speed != phydev->speed) {
  43. status_changed = true;
  44. priv->old_speed = phydev->speed;
  45. }
  46. if (priv->old_duplex != phydev->duplex) {
  47. status_changed = true;
  48. priv->old_duplex = phydev->duplex;
  49. }
  50. if (priv->old_pause != phydev->pause) {
  51. status_changed = true;
  52. priv->old_pause = phydev->pause;
  53. }
  54. /* done if nothing has changed */
  55. if (!status_changed)
  56. return;
  57. /* speed */
  58. if (phydev->speed == SPEED_1000)
  59. cmd_bits = UMAC_SPEED_1000;
  60. else if (phydev->speed == SPEED_100)
  61. cmd_bits = UMAC_SPEED_100;
  62. else
  63. cmd_bits = UMAC_SPEED_10;
  64. cmd_bits <<= CMD_SPEED_SHIFT;
  65. /* duplex */
  66. if (phydev->duplex != DUPLEX_FULL)
  67. cmd_bits |= CMD_HD_EN;
  68. /* pause capability */
  69. if (!phydev->pause)
  70. cmd_bits |= CMD_RX_PAUSE_IGNORE | CMD_TX_PAUSE_IGNORE;
  71. /*
  72. * Program UMAC and RGMII block based on established
  73. * link speed, duplex, and pause. The speed set in
  74. * umac->cmd tell RGMII block which clock to use for
  75. * transmit -- 25MHz(100Mbps) or 125MHz(1Gbps).
  76. * Receive clock is provided by the PHY.
  77. */
  78. reg = bcmgenet_ext_readl(priv, EXT_RGMII_OOB_CTRL);
  79. reg &= ~OOB_DISABLE;
  80. reg |= RGMII_LINK;
  81. bcmgenet_ext_writel(priv, reg, EXT_RGMII_OOB_CTRL);
  82. reg = bcmgenet_umac_readl(priv, UMAC_CMD);
  83. reg &= ~((CMD_SPEED_MASK << CMD_SPEED_SHIFT) |
  84. CMD_HD_EN |
  85. CMD_RX_PAUSE_IGNORE | CMD_TX_PAUSE_IGNORE);
  86. reg |= cmd_bits;
  87. bcmgenet_umac_writel(priv, reg, UMAC_CMD);
  88. } else {
  89. /* done if nothing has changed */
  90. if (!status_changed)
  91. return;
  92. /* needed for MoCA fixed PHY to reflect correct link status */
  93. netif_carrier_off(dev);
  94. }
  95. phy_print_status(phydev);
  96. }
  97. static int bcmgenet_fixed_phy_link_update(struct net_device *dev,
  98. struct fixed_phy_status *status)
  99. {
  100. struct bcmgenet_priv *priv;
  101. u32 reg;
  102. if (dev && dev->phydev && status) {
  103. priv = netdev_priv(dev);
  104. reg = bcmgenet_umac_readl(priv, UMAC_MODE);
  105. status->link = !!(reg & MODE_LINK_STATUS);
  106. }
  107. return 0;
  108. }
  109. void bcmgenet_phy_power_set(struct net_device *dev, bool enable)
  110. {
  111. struct bcmgenet_priv *priv = netdev_priv(dev);
  112. u32 reg = 0;
  113. /* EXT_GPHY_CTRL is only valid for GENETv4 and onward */
  114. if (GENET_IS_V4(priv)) {
  115. reg = bcmgenet_ext_readl(priv, EXT_GPHY_CTRL);
  116. if (enable) {
  117. reg &= ~EXT_CK25_DIS;
  118. bcmgenet_ext_writel(priv, reg, EXT_GPHY_CTRL);
  119. mdelay(1);
  120. reg &= ~(EXT_CFG_IDDQ_BIAS | EXT_CFG_PWR_DOWN);
  121. reg |= EXT_GPHY_RESET;
  122. bcmgenet_ext_writel(priv, reg, EXT_GPHY_CTRL);
  123. mdelay(1);
  124. reg &= ~EXT_GPHY_RESET;
  125. } else {
  126. reg |= EXT_CFG_IDDQ_BIAS | EXT_CFG_PWR_DOWN |
  127. EXT_GPHY_RESET;
  128. bcmgenet_ext_writel(priv, reg, EXT_GPHY_CTRL);
  129. mdelay(1);
  130. reg |= EXT_CK25_DIS;
  131. }
  132. bcmgenet_ext_writel(priv, reg, EXT_GPHY_CTRL);
  133. udelay(60);
  134. } else {
  135. mdelay(1);
  136. }
  137. }
  138. static void bcmgenet_moca_phy_setup(struct bcmgenet_priv *priv)
  139. {
  140. u32 reg;
  141. if (!GENET_IS_V5(priv)) {
  142. /* Speed settings are set in bcmgenet_mii_setup() */
  143. reg = bcmgenet_sys_readl(priv, SYS_PORT_CTRL);
  144. reg |= LED_ACT_SOURCE_MAC;
  145. bcmgenet_sys_writel(priv, reg, SYS_PORT_CTRL);
  146. }
  147. if (priv->hw_params->flags & GENET_HAS_MOCA_LINK_DET)
  148. fixed_phy_set_link_update(priv->dev->phydev,
  149. bcmgenet_fixed_phy_link_update);
  150. }
  151. int bcmgenet_mii_config(struct net_device *dev, bool init)
  152. {
  153. struct bcmgenet_priv *priv = netdev_priv(dev);
  154. struct phy_device *phydev = dev->phydev;
  155. struct device *kdev = &priv->pdev->dev;
  156. const char *phy_name = NULL;
  157. u32 id_mode_dis = 0;
  158. u32 port_ctrl;
  159. int bmcr = -1;
  160. int ret;
  161. u32 reg;
  162. /* MAC clocking workaround during reset of umac state machines */
  163. reg = bcmgenet_umac_readl(priv, UMAC_CMD);
  164. if (reg & CMD_SW_RESET) {
  165. /* An MII PHY must be isolated to prevent TXC contention */
  166. if (priv->phy_interface == PHY_INTERFACE_MODE_MII) {
  167. ret = phy_read(phydev, MII_BMCR);
  168. if (ret >= 0) {
  169. bmcr = ret;
  170. ret = phy_write(phydev, MII_BMCR,
  171. bmcr | BMCR_ISOLATE);
  172. }
  173. if (ret) {
  174. netdev_err(dev, "failed to isolate PHY\n");
  175. return ret;
  176. }
  177. }
  178. /* Switch MAC clocking to RGMII generated clock */
  179. bcmgenet_sys_writel(priv, PORT_MODE_EXT_GPHY, SYS_PORT_CTRL);
  180. /* Ensure 5 clks with Rx disabled
  181. * followed by 5 clks with Reset asserted
  182. */
  183. udelay(4);
  184. reg &= ~(CMD_SW_RESET | CMD_LCL_LOOP_EN);
  185. bcmgenet_umac_writel(priv, reg, UMAC_CMD);
  186. /* Ensure 5 more clocks before Rx is enabled */
  187. udelay(2);
  188. }
  189. priv->ext_phy = !priv->internal_phy &&
  190. (priv->phy_interface != PHY_INTERFACE_MODE_MOCA);
  191. switch (priv->phy_interface) {
  192. case PHY_INTERFACE_MODE_INTERNAL:
  193. case PHY_INTERFACE_MODE_MOCA:
  194. /* Irrespective of the actually configured PHY speed (100 or
  195. * 1000) GENETv4 only has an internal GPHY so we will just end
  196. * up masking the Gigabit features from what we support, not
  197. * switching to the EPHY
  198. */
  199. if (GENET_IS_V4(priv))
  200. port_ctrl = PORT_MODE_INT_GPHY;
  201. else
  202. port_ctrl = PORT_MODE_INT_EPHY;
  203. bcmgenet_sys_writel(priv, port_ctrl, SYS_PORT_CTRL);
  204. if (priv->internal_phy) {
  205. phy_name = "internal PHY";
  206. } else if (priv->phy_interface == PHY_INTERFACE_MODE_MOCA) {
  207. phy_name = "MoCA";
  208. bcmgenet_moca_phy_setup(priv);
  209. }
  210. break;
  211. case PHY_INTERFACE_MODE_MII:
  212. phy_name = "external MII";
  213. phydev->supported &= PHY_BASIC_FEATURES;
  214. bcmgenet_sys_writel(priv,
  215. PORT_MODE_EXT_EPHY, SYS_PORT_CTRL);
  216. /* Restore the MII PHY after isolation */
  217. if (bmcr >= 0)
  218. phy_write(phydev, MII_BMCR, bmcr);
  219. break;
  220. case PHY_INTERFACE_MODE_REVMII:
  221. phy_name = "external RvMII";
  222. /* of_mdiobus_register took care of reading the 'max-speed'
  223. * PHY property for us, effectively limiting the PHY supported
  224. * capabilities, use that knowledge to also configure the
  225. * Reverse MII interface correctly.
  226. */
  227. if (dev->phydev->supported & PHY_1000BT_FEATURES)
  228. port_ctrl = PORT_MODE_EXT_RVMII_50;
  229. else
  230. port_ctrl = PORT_MODE_EXT_RVMII_25;
  231. bcmgenet_sys_writel(priv, port_ctrl, SYS_PORT_CTRL);
  232. break;
  233. case PHY_INTERFACE_MODE_RGMII:
  234. /* RGMII_NO_ID: TXC transitions at the same time as TXD
  235. * (requires PCB or receiver-side delay)
  236. * RGMII: Add 2ns delay on TXC (90 degree shift)
  237. *
  238. * ID is implicitly disabled for 100Mbps (RG)MII operation.
  239. */
  240. id_mode_dis = BIT(16);
  241. /* fall through */
  242. case PHY_INTERFACE_MODE_RGMII_TXID:
  243. if (id_mode_dis)
  244. phy_name = "external RGMII (no delay)";
  245. else
  246. phy_name = "external RGMII (TX delay)";
  247. bcmgenet_sys_writel(priv,
  248. PORT_MODE_EXT_GPHY, SYS_PORT_CTRL);
  249. break;
  250. default:
  251. dev_err(kdev, "unknown phy mode: %d\n", priv->phy_interface);
  252. return -EINVAL;
  253. }
  254. /* This is an external PHY (xMII), so we need to enable the RGMII
  255. * block for the interface to work
  256. */
  257. if (priv->ext_phy) {
  258. reg = bcmgenet_ext_readl(priv, EXT_RGMII_OOB_CTRL);
  259. reg |= id_mode_dis;
  260. if (GENET_IS_V1(priv) || GENET_IS_V2(priv) || GENET_IS_V3(priv))
  261. reg |= RGMII_MODE_EN_V123;
  262. else
  263. reg |= RGMII_MODE_EN;
  264. bcmgenet_ext_writel(priv, reg, EXT_RGMII_OOB_CTRL);
  265. }
  266. if (init)
  267. dev_info(kdev, "configuring instance for %s\n", phy_name);
  268. return 0;
  269. }
  270. int bcmgenet_mii_probe(struct net_device *dev)
  271. {
  272. struct bcmgenet_priv *priv = netdev_priv(dev);
  273. struct device_node *dn = priv->pdev->dev.of_node;
  274. struct phy_device *phydev;
  275. u32 phy_flags = 0;
  276. int ret;
  277. /* Communicate the integrated PHY revision */
  278. if (priv->internal_phy)
  279. phy_flags = priv->gphy_rev;
  280. /* Initialize link state variables that bcmgenet_mii_setup() uses */
  281. priv->old_link = -1;
  282. priv->old_speed = -1;
  283. priv->old_duplex = -1;
  284. priv->old_pause = -1;
  285. if (dn) {
  286. phydev = of_phy_connect(dev, priv->phy_dn, bcmgenet_mii_setup,
  287. phy_flags, priv->phy_interface);
  288. if (!phydev) {
  289. pr_err("could not attach to PHY\n");
  290. return -ENODEV;
  291. }
  292. } else {
  293. phydev = dev->phydev;
  294. phydev->dev_flags = phy_flags;
  295. ret = phy_connect_direct(dev, phydev, bcmgenet_mii_setup,
  296. priv->phy_interface);
  297. if (ret) {
  298. pr_err("could not attach to PHY\n");
  299. return -ENODEV;
  300. }
  301. }
  302. /* Configure port multiplexer based on what the probed PHY device since
  303. * reading the 'max-speed' property determines the maximum supported
  304. * PHY speed which is needed for bcmgenet_mii_config() to configure
  305. * things appropriately.
  306. */
  307. ret = bcmgenet_mii_config(dev, true);
  308. if (ret) {
  309. phy_disconnect(dev->phydev);
  310. return ret;
  311. }
  312. phydev->advertising = phydev->supported;
  313. /* The internal PHY has its link interrupts routed to the
  314. * Ethernet MAC ISRs. On GENETv5 there is a hardware issue
  315. * that prevents the signaling of link UP interrupts when
  316. * the link operates at 10Mbps, so fallback to polling for
  317. * those versions of GENET.
  318. */
  319. if (priv->internal_phy && !GENET_IS_V5(priv))
  320. dev->phydev->irq = PHY_IGNORE_INTERRUPT;
  321. return 0;
  322. }
  323. static struct device_node *bcmgenet_mii_of_find_mdio(struct bcmgenet_priv *priv)
  324. {
  325. struct device_node *dn = priv->pdev->dev.of_node;
  326. struct device *kdev = &priv->pdev->dev;
  327. char *compat;
  328. compat = kasprintf(GFP_KERNEL, "brcm,genet-mdio-v%d", priv->version);
  329. if (!compat)
  330. return NULL;
  331. priv->mdio_dn = of_get_compatible_child(dn, compat);
  332. kfree(compat);
  333. if (!priv->mdio_dn) {
  334. dev_err(kdev, "unable to find MDIO bus node\n");
  335. return NULL;
  336. }
  337. return priv->mdio_dn;
  338. }
  339. static void bcmgenet_mii_pdata_init(struct bcmgenet_priv *priv,
  340. struct unimac_mdio_pdata *ppd)
  341. {
  342. struct device *kdev = &priv->pdev->dev;
  343. struct bcmgenet_platform_data *pd = kdev->platform_data;
  344. if (pd->phy_interface != PHY_INTERFACE_MODE_MOCA && pd->mdio_enabled) {
  345. /*
  346. * Internal or external PHY with MDIO access
  347. */
  348. if (pd->phy_address >= 0 && pd->phy_address < PHY_MAX_ADDR)
  349. ppd->phy_mask = 1 << pd->phy_address;
  350. else
  351. ppd->phy_mask = 0;
  352. }
  353. }
  354. static int bcmgenet_mii_wait(void *wait_func_data)
  355. {
  356. struct bcmgenet_priv *priv = wait_func_data;
  357. wait_event_timeout(priv->wq,
  358. !(bcmgenet_umac_readl(priv, UMAC_MDIO_CMD)
  359. & MDIO_START_BUSY),
  360. HZ / 100);
  361. return 0;
  362. }
  363. static int bcmgenet_mii_register(struct bcmgenet_priv *priv)
  364. {
  365. struct platform_device *pdev = priv->pdev;
  366. struct bcmgenet_platform_data *pdata = pdev->dev.platform_data;
  367. struct device_node *dn = pdev->dev.of_node;
  368. struct unimac_mdio_pdata ppd;
  369. struct platform_device *ppdev;
  370. struct resource *pres, res;
  371. int id, ret;
  372. pres = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  373. memset(&res, 0, sizeof(res));
  374. memset(&ppd, 0, sizeof(ppd));
  375. ppd.wait_func = bcmgenet_mii_wait;
  376. ppd.wait_func_data = priv;
  377. ppd.bus_name = "bcmgenet MII bus";
  378. /* Unimac MDIO bus controller starts at UniMAC offset + MDIO_CMD
  379. * and is 2 * 32-bits word long, 8 bytes total.
  380. */
  381. res.start = pres->start + GENET_UMAC_OFF + UMAC_MDIO_CMD;
  382. res.end = res.start + 8;
  383. res.flags = IORESOURCE_MEM;
  384. if (dn)
  385. id = of_alias_get_id(dn, "eth");
  386. else
  387. id = pdev->id;
  388. ppdev = platform_device_alloc(UNIMAC_MDIO_DRV_NAME, id);
  389. if (!ppdev)
  390. return -ENOMEM;
  391. /* Retain this platform_device pointer for later cleanup */
  392. priv->mii_pdev = ppdev;
  393. ppdev->dev.parent = &pdev->dev;
  394. ppdev->dev.of_node = bcmgenet_mii_of_find_mdio(priv);
  395. if (pdata)
  396. bcmgenet_mii_pdata_init(priv, &ppd);
  397. ret = platform_device_add_resources(ppdev, &res, 1);
  398. if (ret)
  399. goto out;
  400. ret = platform_device_add_data(ppdev, &ppd, sizeof(ppd));
  401. if (ret)
  402. goto out;
  403. ret = platform_device_add(ppdev);
  404. if (ret)
  405. goto out;
  406. return 0;
  407. out:
  408. platform_device_put(ppdev);
  409. return ret;
  410. }
  411. static int bcmgenet_mii_of_init(struct bcmgenet_priv *priv)
  412. {
  413. struct device_node *dn = priv->pdev->dev.of_node;
  414. struct device *kdev = &priv->pdev->dev;
  415. struct phy_device *phydev;
  416. int phy_mode;
  417. int ret;
  418. /* Fetch the PHY phandle */
  419. priv->phy_dn = of_parse_phandle(dn, "phy-handle", 0);
  420. /* In the case of a fixed PHY, the DT node associated
  421. * to the PHY is the Ethernet MAC DT node.
  422. */
  423. if (!priv->phy_dn && of_phy_is_fixed_link(dn)) {
  424. ret = of_phy_register_fixed_link(dn);
  425. if (ret)
  426. return ret;
  427. priv->phy_dn = of_node_get(dn);
  428. }
  429. /* Get the link mode */
  430. phy_mode = of_get_phy_mode(dn);
  431. if (phy_mode < 0) {
  432. dev_err(kdev, "invalid PHY mode property\n");
  433. return phy_mode;
  434. }
  435. priv->phy_interface = phy_mode;
  436. /* We need to specifically look up whether this PHY interface is internal
  437. * or not *before* we even try to probe the PHY driver over MDIO as we
  438. * may have shut down the internal PHY for power saving purposes.
  439. */
  440. if (priv->phy_interface == PHY_INTERFACE_MODE_INTERNAL)
  441. priv->internal_phy = true;
  442. /* Make sure we initialize MoCA PHYs with a link down */
  443. if (phy_mode == PHY_INTERFACE_MODE_MOCA) {
  444. phydev = of_phy_find_device(dn);
  445. if (phydev) {
  446. phydev->link = 0;
  447. put_device(&phydev->mdio.dev);
  448. }
  449. }
  450. return 0;
  451. }
  452. static int bcmgenet_mii_pd_init(struct bcmgenet_priv *priv)
  453. {
  454. struct device *kdev = &priv->pdev->dev;
  455. struct bcmgenet_platform_data *pd = kdev->platform_data;
  456. char phy_name[MII_BUS_ID_SIZE + 3];
  457. char mdio_bus_id[MII_BUS_ID_SIZE];
  458. struct phy_device *phydev;
  459. snprintf(mdio_bus_id, MII_BUS_ID_SIZE, "%s-%d",
  460. UNIMAC_MDIO_DRV_NAME, priv->pdev->id);
  461. if (pd->phy_interface != PHY_INTERFACE_MODE_MOCA && pd->mdio_enabled) {
  462. snprintf(phy_name, MII_BUS_ID_SIZE, PHY_ID_FMT,
  463. mdio_bus_id, pd->phy_address);
  464. /*
  465. * Internal or external PHY with MDIO access
  466. */
  467. phydev = phy_attach(priv->dev, phy_name, pd->phy_interface);
  468. if (!phydev) {
  469. dev_err(kdev, "failed to register PHY device\n");
  470. return -ENODEV;
  471. }
  472. } else {
  473. /*
  474. * MoCA port or no MDIO access.
  475. * Use fixed PHY to represent the link layer.
  476. */
  477. struct fixed_phy_status fphy_status = {
  478. .link = 1,
  479. .speed = pd->phy_speed,
  480. .duplex = pd->phy_duplex,
  481. .pause = 0,
  482. .asym_pause = 0,
  483. };
  484. phydev = fixed_phy_register(PHY_POLL, &fphy_status, -1, NULL);
  485. if (!phydev || IS_ERR(phydev)) {
  486. dev_err(kdev, "failed to register fixed PHY device\n");
  487. return -ENODEV;
  488. }
  489. /* Make sure we initialize MoCA PHYs with a link down */
  490. phydev->link = 0;
  491. }
  492. priv->phy_interface = pd->phy_interface;
  493. return 0;
  494. }
  495. static int bcmgenet_mii_bus_init(struct bcmgenet_priv *priv)
  496. {
  497. struct device_node *dn = priv->pdev->dev.of_node;
  498. if (dn)
  499. return bcmgenet_mii_of_init(priv);
  500. else
  501. return bcmgenet_mii_pd_init(priv);
  502. }
  503. int bcmgenet_mii_init(struct net_device *dev)
  504. {
  505. struct bcmgenet_priv *priv = netdev_priv(dev);
  506. int ret;
  507. ret = bcmgenet_mii_register(priv);
  508. if (ret)
  509. return ret;
  510. ret = bcmgenet_mii_bus_init(priv);
  511. if (ret)
  512. goto out;
  513. return 0;
  514. out:
  515. bcmgenet_mii_exit(dev);
  516. return ret;
  517. }
  518. void bcmgenet_mii_exit(struct net_device *dev)
  519. {
  520. struct bcmgenet_priv *priv = netdev_priv(dev);
  521. struct device_node *dn = priv->pdev->dev.of_node;
  522. if (of_phy_is_fixed_link(dn))
  523. of_phy_deregister_fixed_link(dn);
  524. of_node_put(priv->phy_dn);
  525. platform_device_unregister(priv->mii_pdev);
  526. }