blob: 6dee8eb5194ee697bf12eff9b424bda56851e312 [file] [log] [blame]
Nobuhiro Iwamatsu61134dc2011-11-23 21:24:15 +00001/*
2 * SMSC PHY drivers
3 *
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.
8 *
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.
13 *
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,
17 * MA 02111-1307 USA
18 *
19 * Base code from drivers/net/phy/davicom.c
20 * Copyright 2010-2011 Freescale Semiconductor, Inc.
21 * author Andy Fleming
22 *
23 * Some code get from linux kenrel
24 * Copyright (c) 2006 Herbert Valerio Riedel <hvr@gnu.org>
25 *
26 */
27#include <miiphy.h>
28
29static int smsc_parse_status(struct phy_device *phydev)
30{
31 int mii_reg;
32
33 mii_reg = phy_read(phydev, MDIO_DEVAD_NONE, MII_BMSR);
34
35 if (mii_reg & (BMSR_100FULL | BMSR_100HALF))
36 phydev->speed = SPEED_100;
37 else
38 phydev->speed = SPEED_10;
39
40 if (mii_reg & (BMSR_10FULL | BMSR_100FULL))
41 phydev->duplex = DUPLEX_FULL;
42 else
43 phydev->duplex = DUPLEX_HALF;
44
45 return 0;
46}
47
48static int smsc_startup(struct phy_device *phydev)
49{
50 genphy_update_link(phydev);
51 smsc_parse_status(phydev);
52 return 0;
53}
54
55static struct phy_driver lan8700_driver = {
56 .name = "SMSC LAN8700",
57 .uid = 0x0007c0c0,
58 .mask = 0xffff0,
59 .features = PHY_BASIC_FEATURES,
60 .config = &genphy_config_aneg,
61 .startup = &smsc_startup,
62 .shutdown = &genphy_shutdown,
63};
64
65static struct phy_driver lan911x_driver = {
66 .name = "SMSC LAN911x Internal PHY",
67 .uid = 0x0007c0d0,
68 .mask = 0xffff0,
69 .features = PHY_BASIC_FEATURES,
70 .config = &genphy_config_aneg,
71 .startup = &smsc_startup,
72 .shutdown = &genphy_shutdown,
73};
74
75static struct phy_driver lan8710_driver = {
76 .name = "SMSC LAN8710/LAN8720",
77 .uid = 0x0007c0f0,
78 .mask = 0xffff0,
79 .features = PHY_GBIT_FEATURES,
80 .config = &genphy_config_aneg,
81 .startup = &smsc_startup,
82 .shutdown = &genphy_shutdown,
83};
84
85int phy_smsc_init(void)
86{
87 phy_register(&lan8710_driver);
88 phy_register(&lan911x_driver);
89 phy_register(&lan8700_driver);
90
91 return 0;
92}