blob: 41ffbe9d0ee6d67c9e640bad7b5e583db963b9fe [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
David Dueck6c96ca12013-11-05 17:23:03 +010015/* This code does not check the partner abilities. */
Nobuhiro Iwamatsu61134dc2011-11-23 21:24:15 +000016static int smsc_parse_status(struct phy_device *phydev)
17{
18 int mii_reg;
19
20 mii_reg = phy_read(phydev, MDIO_DEVAD_NONE, MII_BMSR);
21
22 if (mii_reg & (BMSR_100FULL | BMSR_100HALF))
23 phydev->speed = SPEED_100;
24 else
25 phydev->speed = SPEED_10;
26
27 if (mii_reg & (BMSR_10FULL | BMSR_100FULL))
28 phydev->duplex = DUPLEX_FULL;
29 else
30 phydev->duplex = DUPLEX_HALF;
31
32 return 0;
33}
34
35static int smsc_startup(struct phy_device *phydev)
36{
Michal Simek5ff89662016-05-18 12:46:12 +020037 int ret;
38
39 ret = genphy_update_link(phydev);
40 if (ret)
41 return ret;
42
43 return smsc_parse_status(phydev);
Nobuhiro Iwamatsu61134dc2011-11-23 21:24:15 +000044}
45
46static struct phy_driver lan8700_driver = {
47 .name = "SMSC LAN8700",
48 .uid = 0x0007c0c0,
49 .mask = 0xffff0,
50 .features = PHY_BASIC_FEATURES,
51 .config = &genphy_config_aneg,
52 .startup = &smsc_startup,
53 .shutdown = &genphy_shutdown,
54};
55
56static struct phy_driver lan911x_driver = {
57 .name = "SMSC LAN911x Internal PHY",
58 .uid = 0x0007c0d0,
59 .mask = 0xffff0,
60 .features = PHY_BASIC_FEATURES,
61 .config = &genphy_config_aneg,
62 .startup = &smsc_startup,
63 .shutdown = &genphy_shutdown,
64};
65
66static struct phy_driver lan8710_driver = {
67 .name = "SMSC LAN8710/LAN8720",
68 .uid = 0x0007c0f0,
69 .mask = 0xffff0,
Fabio Estevam55e9a252013-06-06 21:04:19 -030070 .features = PHY_BASIC_FEATURES,
Nobuhiro Iwamatsu61134dc2011-11-23 21:24:15 +000071 .config = &genphy_config_aneg,
David Dueck6c96ca12013-11-05 17:23:03 +010072 .startup = &genphy_startup,
Nobuhiro Iwamatsu61134dc2011-11-23 21:24:15 +000073 .shutdown = &genphy_shutdown,
74};
75
Purna Chandra Mandald2499842016-01-28 15:30:20 +053076static struct phy_driver lan8740_driver = {
77 .name = "SMSC LAN8740",
78 .uid = 0x0007c110,
79 .mask = 0xffff0,
80 .features = PHY_BASIC_FEATURES,
81 .config = &genphy_config_aneg,
82 .startup = &genphy_startup,
83 .shutdown = &genphy_shutdown,
84};
Michael Kurz30c37f62017-01-22 16:04:28 +010085
86static struct phy_driver lan8742_driver = {
87 .name = "SMSC LAN8742",
88 .uid = 0x0007c130,
89 .mask = 0xffff0,
90 .features = PHY_BASIC_FEATURES,
91 .config = &genphy_config_aneg,
92 .startup = &genphy_startup,
93 .shutdown = &genphy_shutdown,
94};
95
Nobuhiro Iwamatsu61134dc2011-11-23 21:24:15 +000096int phy_smsc_init(void)
97{
98 phy_register(&lan8710_driver);
99 phy_register(&lan911x_driver);
100 phy_register(&lan8700_driver);
Purna Chandra Mandald2499842016-01-28 15:30:20 +0530101 phy_register(&lan8740_driver);
Michael Kurz30c37f62017-01-22 16:04:28 +0100102 phy_register(&lan8742_driver);
Nobuhiro Iwamatsu61134dc2011-11-23 21:24:15 +0000103
104 return 0;
105}