2 * Generic PHY Management code
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of
7 * the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20 * Copyright 2011 Freescale Semiconductor, Inc.
23 * Based loosely off of Linux's PHY Lib
31 int gen10g_shutdown(struct phy_device *phydev)
36 int gen10g_startup(struct phy_device *phydev)
39 u32 mmd_mask = phydev->mmds & MDIO_DEVS_LINK;
43 /* For now just lie and say it's 10G all the time */
44 phydev->speed = SPEED_10000;
45 phydev->duplex = DUPLEX_FULL;
48 * Go through all the link-reporting devices, and make sure
49 * they're all up and happy
51 for (devad = 0; mmd_mask; devad++, mmd_mask = mmd_mask >> 1) {
55 /* Read twice because link state is latched and a
56 * read moves the current state into the register */
57 phy_read(phydev, devad, MDIO_STAT1);
58 reg = phy_read(phydev, devad, MDIO_STAT1);
59 if (reg < 0 || !(reg & MDIO_STAT1_LSTATUS))
66 int gen10g_discover_mmds(struct phy_device *phydev)
68 int mmd, stat2, devs1, devs2;
70 /* Assume PHY must have at least one of PMA/PMD, WIS, PCS, PHY
71 * XS or DTE XS; give up if none is present. */
72 for (mmd = 1; mmd <= 5; mmd++) {
73 /* Is this MMD present? */
74 stat2 = phy_read(phydev, mmd, MDIO_STAT2);
76 (stat2 & MDIO_STAT2_DEVPRST) != MDIO_STAT2_DEVPRST_VAL)
79 /* It should tell us about all the other MMDs */
80 devs1 = phy_read(phydev, mmd, MDIO_DEVS1);
81 devs2 = phy_read(phydev, mmd, MDIO_DEVS2);
82 if (devs1 < 0 || devs2 < 0)
85 phydev->mmds = devs1 | (devs2 << 16);
92 int gen10g_config(struct phy_device *phydev)
94 /* For now, assume 10000baseT. Fill in later */
95 phydev->supported = phydev->advertising = SUPPORTED_10000baseT_Full;
97 return gen10g_discover_mmds(phydev);
100 struct phy_driver gen10g_driver = {
103 .name = "Generic 10G PHY",
105 .config = gen10g_config,
106 .startup = gen10g_startup,
107 .shutdown = gen10g_shutdown,