Nobuhiro Iwamatsu | 5751aa2 | 2011-11-23 21:24:15 +0000 | [diff] [blame] | 1 | /* |
| 2 | * SMSC PHY drivers |
| 3 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 4 | * SPDX-License-Identifier: GPL-2.0+ |
Nobuhiro Iwamatsu | 5751aa2 | 2011-11-23 21:24:15 +0000 | [diff] [blame] | 5 | * |
| 6 | * Base code from drivers/net/phy/davicom.c |
| 7 | * Copyright 2010-2011 Freescale Semiconductor, Inc. |
| 8 | * author Andy Fleming |
| 9 | * |
Robert P. J. Day | 1bce2ae | 2013-09-16 07:15:45 -0400 | [diff] [blame] | 10 | * Some code copied from linux kernel |
Nobuhiro Iwamatsu | 5751aa2 | 2011-11-23 21:24:15 +0000 | [diff] [blame] | 11 | * Copyright (c) 2006 Herbert Valerio Riedel <hvr@gnu.org> |
Nobuhiro Iwamatsu | 5751aa2 | 2011-11-23 21:24:15 +0000 | [diff] [blame] | 12 | */ |
| 13 | #include <miiphy.h> |
| 14 | |
David Dueck | f27f3b5 | 2013-11-05 17:23:03 +0100 | [diff] [blame^] | 15 | /* This code does not check the partner abilities. */ |
Nobuhiro Iwamatsu | 5751aa2 | 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 | { |
| 37 | genphy_update_link(phydev); |
| 38 | smsc_parse_status(phydev); |
| 39 | return 0; |
| 40 | } |
| 41 | |
| 42 | static struct phy_driver lan8700_driver = { |
| 43 | .name = "SMSC LAN8700", |
| 44 | .uid = 0x0007c0c0, |
| 45 | .mask = 0xffff0, |
| 46 | .features = PHY_BASIC_FEATURES, |
| 47 | .config = &genphy_config_aneg, |
| 48 | .startup = &smsc_startup, |
| 49 | .shutdown = &genphy_shutdown, |
| 50 | }; |
| 51 | |
| 52 | static struct phy_driver lan911x_driver = { |
| 53 | .name = "SMSC LAN911x Internal PHY", |
| 54 | .uid = 0x0007c0d0, |
| 55 | .mask = 0xffff0, |
| 56 | .features = PHY_BASIC_FEATURES, |
| 57 | .config = &genphy_config_aneg, |
| 58 | .startup = &smsc_startup, |
| 59 | .shutdown = &genphy_shutdown, |
| 60 | }; |
| 61 | |
| 62 | static struct phy_driver lan8710_driver = { |
| 63 | .name = "SMSC LAN8710/LAN8720", |
| 64 | .uid = 0x0007c0f0, |
| 65 | .mask = 0xffff0, |
Fabio Estevam | 2563421 | 2013-06-06 21:04:19 -0300 | [diff] [blame] | 66 | .features = PHY_BASIC_FEATURES, |
Nobuhiro Iwamatsu | 5751aa2 | 2011-11-23 21:24:15 +0000 | [diff] [blame] | 67 | .config = &genphy_config_aneg, |
David Dueck | f27f3b5 | 2013-11-05 17:23:03 +0100 | [diff] [blame^] | 68 | .startup = &genphy_startup, |
Nobuhiro Iwamatsu | 5751aa2 | 2011-11-23 21:24:15 +0000 | [diff] [blame] | 69 | .shutdown = &genphy_shutdown, |
| 70 | }; |
| 71 | |
| 72 | int phy_smsc_init(void) |
| 73 | { |
| 74 | phy_register(&lan8710_driver); |
| 75 | phy_register(&lan911x_driver); |
| 76 | phy_register(&lan8700_driver); |
| 77 | |
| 78 | return 0; |
| 79 | } |