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 | |
| 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 | { |
| 36 | genphy_update_link(phydev); |
| 37 | smsc_parse_status(phydev); |
| 38 | return 0; |
| 39 | } |
| 40 | |
| 41 | static struct phy_driver lan8700_driver = { |
| 42 | .name = "SMSC LAN8700", |
| 43 | .uid = 0x0007c0c0, |
| 44 | .mask = 0xffff0, |
| 45 | .features = PHY_BASIC_FEATURES, |
| 46 | .config = &genphy_config_aneg, |
| 47 | .startup = &smsc_startup, |
| 48 | .shutdown = &genphy_shutdown, |
| 49 | }; |
| 50 | |
| 51 | static struct phy_driver lan911x_driver = { |
| 52 | .name = "SMSC LAN911x Internal PHY", |
| 53 | .uid = 0x0007c0d0, |
| 54 | .mask = 0xffff0, |
| 55 | .features = PHY_BASIC_FEATURES, |
| 56 | .config = &genphy_config_aneg, |
| 57 | .startup = &smsc_startup, |
| 58 | .shutdown = &genphy_shutdown, |
| 59 | }; |
| 60 | |
| 61 | static struct phy_driver lan8710_driver = { |
| 62 | .name = "SMSC LAN8710/LAN8720", |
| 63 | .uid = 0x0007c0f0, |
| 64 | .mask = 0xffff0, |
Fabio Estevam | 2563421 | 2013-06-06 21:04:19 -0300 | [diff] [blame] | 65 | .features = PHY_BASIC_FEATURES, |
Nobuhiro Iwamatsu | 5751aa2 | 2011-11-23 21:24:15 +0000 | [diff] [blame] | 66 | .config = &genphy_config_aneg, |
| 67 | .startup = &smsc_startup, |
| 68 | .shutdown = &genphy_shutdown, |
| 69 | }; |
| 70 | |
| 71 | int phy_smsc_init(void) |
| 72 | { |
| 73 | phy_register(&lan8710_driver); |
| 74 | phy_register(&lan911x_driver); |
| 75 | phy_register(&lan8700_driver); |
| 76 | |
| 77 | return 0; |
| 78 | } |