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 | */ |
Joe Hershberger | 14b4812 | 2018-07-25 12:59:22 -0500 | [diff] [blame] | 12 | #include <common.h> |
Nobuhiro Iwamatsu | 61134dc | 2011-11-23 21:24:15 +0000 | [diff] [blame] | 13 | #include <miiphy.h> |
| 14 | |
David Dueck | 6c96ca1 | 2013-11-05 17:23:03 +0100 | [diff] [blame] | 15 | /* This code does not check the partner abilities. */ |
Nobuhiro Iwamatsu | 61134dc | 2011-11-23 21:24:15 +0000 | [diff] [blame] | 16 | static 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 | |
| 35 | static int smsc_startup(struct phy_device *phydev) |
| 36 | { |
Michal Simek | 5ff8966 | 2016-05-18 12:46:12 +0200 | [diff] [blame] | 37 | int ret; |
| 38 | |
| 39 | ret = genphy_update_link(phydev); |
| 40 | if (ret) |
| 41 | return ret; |
| 42 | |
| 43 | return smsc_parse_status(phydev); |
Nobuhiro Iwamatsu | 61134dc | 2011-11-23 21:24:15 +0000 | [diff] [blame] | 44 | } |
| 45 | |
Marek Vasut | 9097368 | 2023-03-19 18:03:02 +0100 | [diff] [blame] | 46 | U_BOOT_PHY_DRIVER(lan8700) = { |
Nobuhiro Iwamatsu | 61134dc | 2011-11-23 21:24:15 +0000 | [diff] [blame] | 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 | |
Marek Vasut | 9097368 | 2023-03-19 18:03:02 +0100 | [diff] [blame] | 56 | U_BOOT_PHY_DRIVER(lan911x) = { |
Nobuhiro Iwamatsu | 61134dc | 2011-11-23 21:24:15 +0000 | [diff] [blame] | 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 | |
Marek Vasut | 9097368 | 2023-03-19 18:03:02 +0100 | [diff] [blame] | 66 | U_BOOT_PHY_DRIVER(lan8710) = { |
Nobuhiro Iwamatsu | 61134dc | 2011-11-23 21:24:15 +0000 | [diff] [blame] | 67 | .name = "SMSC LAN8710/LAN8720", |
| 68 | .uid = 0x0007c0f0, |
| 69 | .mask = 0xffff0, |
Fabio Estevam | 55e9a25 | 2013-06-06 21:04:19 -0300 | [diff] [blame] | 70 | .features = PHY_BASIC_FEATURES, |
Nobuhiro Iwamatsu | 61134dc | 2011-11-23 21:24:15 +0000 | [diff] [blame] | 71 | .config = &genphy_config_aneg, |
David Dueck | 6c96ca1 | 2013-11-05 17:23:03 +0100 | [diff] [blame] | 72 | .startup = &genphy_startup, |
Nobuhiro Iwamatsu | 61134dc | 2011-11-23 21:24:15 +0000 | [diff] [blame] | 73 | .shutdown = &genphy_shutdown, |
| 74 | }; |
| 75 | |
Marek Vasut | 9097368 | 2023-03-19 18:03:02 +0100 | [diff] [blame] | 76 | U_BOOT_PHY_DRIVER(lan8740) = { |
Purna Chandra Mandal | d249984 | 2016-01-28 15:30:20 +0530 | [diff] [blame] | 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 Kurz | 30c37f6 | 2017-01-22 16:04:28 +0100 | [diff] [blame] | 85 | |
Marek Vasut | 9097368 | 2023-03-19 18:03:02 +0100 | [diff] [blame] | 86 | U_BOOT_PHY_DRIVER(lan8741) = { |
Arno Steffens | 003e437 | 2018-01-25 13:08:35 +0100 | [diff] [blame] | 87 | .name = "SMSC LAN8741", |
| 88 | .uid = 0x0007c120, |
| 89 | .mask = 0xffff0, |
| 90 | .features = PHY_BASIC_FEATURES, |
| 91 | .config = &genphy_config_aneg, |
| 92 | .startup = &genphy_startup, |
| 93 | .shutdown = &genphy_shutdown, |
| 94 | }; |
| 95 | |
Marek Vasut | 9097368 | 2023-03-19 18:03:02 +0100 | [diff] [blame] | 96 | U_BOOT_PHY_DRIVER(lan8742) = { |
Michael Kurz | 30c37f6 | 2017-01-22 16:04:28 +0100 | [diff] [blame] | 97 | .name = "SMSC LAN8742", |
| 98 | .uid = 0x0007c130, |
| 99 | .mask = 0xffff0, |
| 100 | .features = PHY_BASIC_FEATURES, |
| 101 | .config = &genphy_config_aneg, |
| 102 | .startup = &genphy_startup, |
| 103 | .shutdown = &genphy_shutdown, |
| 104 | }; |