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,
19 * Base code from drivers/net/phy/davicom.c
20 * Copyright 2010-2011 Freescale Semiconductor, Inc.
23 * Some code get from linux kenrel
24 * Copyright (c) 2006 Herbert Valerio Riedel <hvr@gnu.org>
29 static int smsc_parse_status(struct phy_device *phydev)
33 mii_reg = phy_read(phydev, MDIO_DEVAD_NONE, MII_BMSR);
35 if (mii_reg & (BMSR_100FULL | BMSR_100HALF))
36 phydev->speed = SPEED_100;
38 phydev->speed = SPEED_10;
40 if (mii_reg & (BMSR_10FULL | BMSR_100FULL))
41 phydev->duplex = DUPLEX_FULL;
43 phydev->duplex = DUPLEX_HALF;
48 static int smsc_startup(struct phy_device *phydev)
50 genphy_update_link(phydev);
51 smsc_parse_status(phydev);
55 static struct phy_driver lan8700_driver = {
56 .name = "SMSC LAN8700",
59 .features = PHY_BASIC_FEATURES,
60 .config = &genphy_config_aneg,
61 .startup = &smsc_startup,
62 .shutdown = &genphy_shutdown,
65 static struct phy_driver lan911x_driver = {
66 .name = "SMSC LAN911x Internal PHY",
69 .features = PHY_BASIC_FEATURES,
70 .config = &genphy_config_aneg,
71 .startup = &smsc_startup,
72 .shutdown = &genphy_shutdown,
75 static struct phy_driver lan8710_driver = {
76 .name = "SMSC LAN8710/LAN8720",
79 .features = PHY_GBIT_FEATURES,
80 .config = &genphy_config_aneg,
81 .startup = &smsc_startup,
82 .shutdown = &genphy_shutdown,
85 int phy_smsc_init(void)
87 phy_register(&lan8710_driver);
88 phy_register(&lan911x_driver);
89 phy_register(&lan8700_driver);