1 // SPDX-License-Identifier: GPL-2.0+ 2 /* 3 * SMSC PHY drivers 4 * 5 * Base code from drivers/net/phy/davicom.c 6 * Copyright 2010-2011 Freescale Semiconductor, Inc. 7 * author Andy Fleming 8 * 9 * Some code copied from linux kernel 10 * Copyright (c) 2006 Herbert Valerio Riedel <hvr@gnu.org> 11 */ 12 #include <miiphy.h> 13 14 /* This code does not check the partner abilities. */ 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 int ret; 37 38 ret = genphy_update_link(phydev); 39 if (ret) 40 return ret; 41 42 return smsc_parse_status(phydev); 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, 69 .features = PHY_BASIC_FEATURES, 70 .config = &genphy_config_aneg, 71 .startup = &genphy_startup, 72 .shutdown = &genphy_shutdown, 73 }; 74 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 }; 84 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 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 105 int phy_smsc_init(void) 106 { 107 phy_register(&lan8710_driver); 108 phy_register(&lan911x_driver); 109 phy_register(&lan8700_driver); 110 phy_register(&lan8740_driver); 111 phy_register(&lan8741_driver); 112 phy_register(&lan8742_driver); 113 114 return 0; 115 } 116