2 * Generic PHY Management code
4 * SPDX-License-Identifier: GPL-2.0+
6 * Copyright 2011 Freescale Semiconductor, Inc.
9 * Based loosely off of Linux's PHY Lib
17 int gen10g_shutdown(struct phy_device
*phydev
)
22 int gen10g_startup(struct phy_device
*phydev
)
25 u32 mmd_mask
= phydev
->mmds
& MDIO_DEVS_LINK
;
29 /* For now just lie and say it's 10G all the time */
30 phydev
->speed
= SPEED_10000
;
31 phydev
->duplex
= DUPLEX_FULL
;
34 * Go through all the link-reporting devices, and make sure
35 * they're all up and happy
37 for (devad
= 0; mmd_mask
; devad
++, mmd_mask
= mmd_mask
>> 1) {
41 /* Read twice because link state is latched and a
42 * read moves the current state into the register */
43 phy_read(phydev
, devad
, MDIO_STAT1
);
44 reg
= phy_read(phydev
, devad
, MDIO_STAT1
);
45 if (reg
< 0 || !(reg
& MDIO_STAT1_LSTATUS
))
52 int gen10g_discover_mmds(struct phy_device
*phydev
)
54 int mmd
, stat2
, devs1
, devs2
;
56 /* Assume PHY must have at least one of PMA/PMD, WIS, PCS, PHY
57 * XS or DTE XS; give up if none is present. */
58 for (mmd
= 1; mmd
<= 5; mmd
++) {
59 /* Is this MMD present? */
60 stat2
= phy_read(phydev
, mmd
, MDIO_STAT2
);
62 (stat2
& MDIO_STAT2_DEVPRST
) != MDIO_STAT2_DEVPRST_VAL
)
65 /* It should tell us about all the other MMDs */
66 devs1
= phy_read(phydev
, mmd
, MDIO_DEVS1
);
67 devs2
= phy_read(phydev
, mmd
, MDIO_DEVS2
);
68 if (devs1
< 0 || devs2
< 0)
71 phydev
->mmds
= devs1
| (devs2
<< 16);
78 int gen10g_config(struct phy_device
*phydev
)
80 /* For now, assume 10000baseT. Fill in later */
81 phydev
->supported
= phydev
->advertising
= SUPPORTED_10000baseT_Full
;
83 return gen10g_discover_mmds(phydev
);
86 struct phy_driver gen10g_driver
= {
89 .name
= "Generic 10G PHY",
91 .config
= gen10g_config
,
92 .startup
= gen10g_startup
,
93 .shutdown
= gen10g_shutdown
,