blob: 2f92957a5a7823bef6c913f04d654eba68677c0b [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Nobuhiro Iwamatsu61134dc2011-11-23 21:24:15 +00002/*
3 * SMSC PHY drivers
4 *
Nobuhiro Iwamatsu61134dc2011-11-23 21:24:15 +00005 * Base code from drivers/net/phy/davicom.c
6 * Copyright 2010-2011 Freescale Semiconductor, Inc.
7 * author Andy Fleming
8 *
Robert P. J. Day832d36e2013-09-16 07:15:45 -04009 * Some code copied from linux kernel
Nobuhiro Iwamatsu61134dc2011-11-23 21:24:15 +000010 * Copyright (c) 2006 Herbert Valerio Riedel <hvr@gnu.org>
Nobuhiro Iwamatsu61134dc2011-11-23 21:24:15 +000011 */
12#include <miiphy.h>
13
David Dueck6c96ca12013-11-05 17:23:03 +010014/* This code does not check the partner abilities. */
Nobuhiro Iwamatsu61134dc2011-11-23 21:24:15 +000015static 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{
Michal Simek5ff89662016-05-18 12:46:12 +020036 int ret;
37
38 ret = genphy_update_link(phydev);
39 if (ret)
40 return ret;
41
42 return smsc_parse_status(phydev);
Nobuhiro Iwamatsu61134dc2011-11-23 21:24:15 +000043}
44
45static struct phy_driver lan8700_driver = {
46 .name = "SMSC LAN8700",
47 .uid = 0x0007c0c0,
48 .mask = 0xffff0,
49 .features = PHY_BASIC_FEATURES,
50 .config = &genphy_config_aneg,
51 .startup = &smsc_startup,
52 .shutdown = &genphy_shutdown,
53};
54
55static struct phy_driver lan911x_driver = {
56 .name = "SMSC LAN911x Internal PHY",
57 .uid = 0x0007c0d0,
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 lan8710_driver = {
66 .name = "SMSC LAN8710/LAN8720",
67 .uid = 0x0007c0f0,
68 .mask = 0xffff0,
Fabio Estevam55e9a252013-06-06 21:04:19 -030069 .features = PHY_BASIC_FEATURES,
Nobuhiro Iwamatsu61134dc2011-11-23 21:24:15 +000070 .config = &genphy_config_aneg,
David Dueck6c96ca12013-11-05 17:23:03 +010071 .startup = &genphy_startup,
Nobuhiro Iwamatsu61134dc2011-11-23 21:24:15 +000072 .shutdown = &genphy_shutdown,
73};
74
Purna Chandra Mandald2499842016-01-28 15:30:20 +053075static struct phy_driver lan8740_driver = {
76 .name = "SMSC LAN8740",
77 .uid = 0x0007c110,
78 .mask = 0xffff0,
79 .features = PHY_BASIC_FEATURES,
80 .config = &genphy_config_aneg,
81 .startup = &genphy_startup,
82 .shutdown = &genphy_shutdown,
83};
Michael Kurz30c37f62017-01-22 16:04:28 +010084
Arno Steffens003e4372018-01-25 13:08:35 +010085static struct phy_driver lan8741_driver = {
86 .name = "SMSC LAN8741",
87 .uid = 0x0007c120,
88 .mask = 0xffff0,
89 .features = PHY_BASIC_FEATURES,
90 .config = &genphy_config_aneg,
91 .startup = &genphy_startup,
92 .shutdown = &genphy_shutdown,
93};
94
Michael Kurz30c37f62017-01-22 16:04:28 +010095static struct phy_driver lan8742_driver = {
96 .name = "SMSC LAN8742",
97 .uid = 0x0007c130,
98 .mask = 0xffff0,
99 .features = PHY_BASIC_FEATURES,
100 .config = &genphy_config_aneg,
101 .startup = &genphy_startup,
102 .shutdown = &genphy_shutdown,
103};
104
Nobuhiro Iwamatsu61134dc2011-11-23 21:24:15 +0000105int phy_smsc_init(void)
106{
107 phy_register(&lan8710_driver);
108 phy_register(&lan911x_driver);
109 phy_register(&lan8700_driver);
Purna Chandra Mandald2499842016-01-28 15:30:20 +0530110 phy_register(&lan8740_driver);
Arno Steffens003e4372018-01-25 13:08:35 +0100111 phy_register(&lan8741_driver);
Michael Kurz30c37f62017-01-22 16:04:28 +0100112 phy_register(&lan8742_driver);
Nobuhiro Iwamatsu61134dc2011-11-23 21:24:15 +0000113
114 return 0;
115}