Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Nobuhiro Iwamatsu | 61134dc | 2011-11-23 21:24:15 +0000 | [diff] [blame] | 2 | /* |
| 3 | * SMSC PHY drivers |
| 4 | * |
Nobuhiro Iwamatsu | 61134dc | 2011-11-23 21:24:15 +0000 | [diff] [blame] | 5 | * Base code from drivers/net/phy/davicom.c |
| 6 | * Copyright 2010-2011 Freescale Semiconductor, Inc. |
| 7 | * author Andy Fleming |
| 8 | * |
Robert P. J. Day | 832d36e | 2013-09-16 07:15:45 -0400 | [diff] [blame] | 9 | * Some code copied from linux kernel |
Nobuhiro Iwamatsu | 61134dc | 2011-11-23 21:24:15 +0000 | [diff] [blame] | 10 | * Copyright (c) 2006 Herbert Valerio Riedel <hvr@gnu.org> |
Nobuhiro Iwamatsu | 61134dc | 2011-11-23 21:24:15 +0000 | [diff] [blame] | 11 | */ |
| 12 | #include <miiphy.h> |
| 13 | |
David Dueck | 6c96ca1 | 2013-11-05 17:23:03 +0100 | [diff] [blame] | 14 | /* This code does not check the partner abilities. */ |
Nobuhiro Iwamatsu | 61134dc | 2011-11-23 21:24:15 +0000 | [diff] [blame] | 15 | static 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 | |
| 34 | static int smsc_startup(struct phy_device *phydev) |
| 35 | { |
Michal Simek | 5ff8966 | 2016-05-18 12:46:12 +0200 | [diff] [blame] | 36 | int ret; |
| 37 | |
| 38 | ret = genphy_update_link(phydev); |
| 39 | if (ret) |
| 40 | return ret; |
| 41 | |
| 42 | return smsc_parse_status(phydev); |
Nobuhiro Iwamatsu | 61134dc | 2011-11-23 21:24:15 +0000 | [diff] [blame] | 43 | } |
| 44 | |
| 45 | static 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 | |
| 55 | static 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 | |
| 65 | static struct phy_driver lan8710_driver = { |
| 66 | .name = "SMSC LAN8710/LAN8720", |
| 67 | .uid = 0x0007c0f0, |
| 68 | .mask = 0xffff0, |
Fabio Estevam | 55e9a25 | 2013-06-06 21:04:19 -0300 | [diff] [blame] | 69 | .features = PHY_BASIC_FEATURES, |
Nobuhiro Iwamatsu | 61134dc | 2011-11-23 21:24:15 +0000 | [diff] [blame] | 70 | .config = &genphy_config_aneg, |
David Dueck | 6c96ca1 | 2013-11-05 17:23:03 +0100 | [diff] [blame] | 71 | .startup = &genphy_startup, |
Nobuhiro Iwamatsu | 61134dc | 2011-11-23 21:24:15 +0000 | [diff] [blame] | 72 | .shutdown = &genphy_shutdown, |
| 73 | }; |
| 74 | |
Purna Chandra Mandal | d249984 | 2016-01-28 15:30:20 +0530 | [diff] [blame] | 75 | static 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 Kurz | 30c37f6 | 2017-01-22 16:04:28 +0100 | [diff] [blame] | 84 | |
Arno Steffens | 003e437 | 2018-01-25 13:08:35 +0100 | [diff] [blame] | 85 | static 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 Kurz | 30c37f6 | 2017-01-22 16:04:28 +0100 | [diff] [blame] | 95 | static 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 Iwamatsu | 61134dc | 2011-11-23 21:24:15 +0000 | [diff] [blame] | 105 | int phy_smsc_init(void) |
| 106 | { |
| 107 | phy_register(&lan8710_driver); |
| 108 | phy_register(&lan911x_driver); |
| 109 | phy_register(&lan8700_driver); |
Purna Chandra Mandal | d249984 | 2016-01-28 15:30:20 +0530 | [diff] [blame] | 110 | phy_register(&lan8740_driver); |
Arno Steffens | 003e437 | 2018-01-25 13:08:35 +0100 | [diff] [blame] | 111 | phy_register(&lan8741_driver); |
Michael Kurz | 30c37f6 | 2017-01-22 16:04:28 +0100 | [diff] [blame] | 112 | phy_register(&lan8742_driver); |
Nobuhiro Iwamatsu | 61134dc | 2011-11-23 21:24:15 +0000 | [diff] [blame] | 113 | |
| 114 | return 0; |
| 115 | } |