blob: 60ed92d2039ba36846a7ef83ceb870b01bec8795 [file] [log] [blame]
Nobuhiro Iwamatsu61134dc2011-11-23 21:24:15 +00001/*
2 * SMSC PHY drivers
3 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02004 * SPDX-License-Identifier: GPL-2.0+
Nobuhiro Iwamatsu61134dc2011-11-23 21:24:15 +00005 *
6 * Base code from drivers/net/phy/davicom.c
7 * Copyright 2010-2011 Freescale Semiconductor, Inc.
8 * author Andy Fleming
9 *
Robert P. J. Day832d36e2013-09-16 07:15:45 -040010 * Some code copied from linux kernel
Nobuhiro Iwamatsu61134dc2011-11-23 21:24:15 +000011 * Copyright (c) 2006 Herbert Valerio Riedel <hvr@gnu.org>
Nobuhiro Iwamatsu61134dc2011-11-23 21:24:15 +000012 */
13#include <miiphy.h>
14
15static int smsc_parse_status(struct phy_device *phydev)
16{
17 int mii_reg;
18
19 mii_reg = phy_read(phydev, MDIO_DEVAD_NONE, MII_BMSR);
20
21 if (mii_reg & (BMSR_100FULL | BMSR_100HALF))
22 phydev->speed = SPEED_100;
23 else
24 phydev->speed = SPEED_10;
25
26 if (mii_reg & (BMSR_10FULL | BMSR_100FULL))
27 phydev->duplex = DUPLEX_FULL;
28 else
29 phydev->duplex = DUPLEX_HALF;
30
31 return 0;
32}
33
34static int smsc_startup(struct phy_device *phydev)
35{
36 genphy_update_link(phydev);
37 smsc_parse_status(phydev);
38 return 0;
39}
40
41static struct phy_driver lan8700_driver = {
42 .name = "SMSC LAN8700",
43 .uid = 0x0007c0c0,
44 .mask = 0xffff0,
45 .features = PHY_BASIC_FEATURES,
46 .config = &genphy_config_aneg,
47 .startup = &smsc_startup,
48 .shutdown = &genphy_shutdown,
49};
50
51static struct phy_driver lan911x_driver = {
52 .name = "SMSC LAN911x Internal PHY",
53 .uid = 0x0007c0d0,
54 .mask = 0xffff0,
55 .features = PHY_BASIC_FEATURES,
56 .config = &genphy_config_aneg,
57 .startup = &smsc_startup,
58 .shutdown = &genphy_shutdown,
59};
60
61static struct phy_driver lan8710_driver = {
62 .name = "SMSC LAN8710/LAN8720",
63 .uid = 0x0007c0f0,
64 .mask = 0xffff0,
Fabio Estevam55e9a252013-06-06 21:04:19 -030065 .features = PHY_BASIC_FEATURES,
Nobuhiro Iwamatsu61134dc2011-11-23 21:24:15 +000066 .config = &genphy_config_aneg,
67 .startup = &smsc_startup,
68 .shutdown = &genphy_shutdown,
69};
70
71int phy_smsc_init(void)
72{
73 phy_register(&lan8710_driver);
74 phy_register(&lan911x_driver);
75 phy_register(&lan8700_driver);
76
77 return 0;
78}