18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Driver for the Texas Instruments DP83TC811 PHY 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/ 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci */ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#include <linux/ethtool.h> 108c2ecf20Sopenharmony_ci#include <linux/etherdevice.h> 118c2ecf20Sopenharmony_ci#include <linux/kernel.h> 128c2ecf20Sopenharmony_ci#include <linux/mii.h> 138c2ecf20Sopenharmony_ci#include <linux/module.h> 148c2ecf20Sopenharmony_ci#include <linux/of.h> 158c2ecf20Sopenharmony_ci#include <linux/phy.h> 168c2ecf20Sopenharmony_ci#include <linux/netdevice.h> 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci#define DP83TC811_PHY_ID 0x2000a253 198c2ecf20Sopenharmony_ci#define DP83811_DEVADDR 0x1f 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci#define MII_DP83811_SGMII_CTRL 0x09 228c2ecf20Sopenharmony_ci#define MII_DP83811_INT_STAT1 0x12 238c2ecf20Sopenharmony_ci#define MII_DP83811_INT_STAT2 0x13 248c2ecf20Sopenharmony_ci#define MII_DP83811_INT_STAT3 0x18 258c2ecf20Sopenharmony_ci#define MII_DP83811_RESET_CTRL 0x1f 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci#define DP83811_HW_RESET BIT(15) 288c2ecf20Sopenharmony_ci#define DP83811_SW_RESET BIT(14) 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci/* INT_STAT1 bits */ 318c2ecf20Sopenharmony_ci#define DP83811_RX_ERR_HF_INT_EN BIT(0) 328c2ecf20Sopenharmony_ci#define DP83811_MS_TRAINING_INT_EN BIT(1) 338c2ecf20Sopenharmony_ci#define DP83811_ANEG_COMPLETE_INT_EN BIT(2) 348c2ecf20Sopenharmony_ci#define DP83811_ESD_EVENT_INT_EN BIT(3) 358c2ecf20Sopenharmony_ci#define DP83811_WOL_INT_EN BIT(4) 368c2ecf20Sopenharmony_ci#define DP83811_LINK_STAT_INT_EN BIT(5) 378c2ecf20Sopenharmony_ci#define DP83811_ENERGY_DET_INT_EN BIT(6) 388c2ecf20Sopenharmony_ci#define DP83811_LINK_QUAL_INT_EN BIT(7) 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci/* INT_STAT2 bits */ 418c2ecf20Sopenharmony_ci#define DP83811_JABBER_DET_INT_EN BIT(0) 428c2ecf20Sopenharmony_ci#define DP83811_POLARITY_INT_EN BIT(1) 438c2ecf20Sopenharmony_ci#define DP83811_SLEEP_MODE_INT_EN BIT(2) 448c2ecf20Sopenharmony_ci#define DP83811_OVERTEMP_INT_EN BIT(3) 458c2ecf20Sopenharmony_ci#define DP83811_OVERVOLTAGE_INT_EN BIT(6) 468c2ecf20Sopenharmony_ci#define DP83811_UNDERVOLTAGE_INT_EN BIT(7) 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci/* INT_STAT3 bits */ 498c2ecf20Sopenharmony_ci#define DP83811_LPS_INT_EN BIT(0) 508c2ecf20Sopenharmony_ci#define DP83811_NO_FRAME_INT_EN BIT(3) 518c2ecf20Sopenharmony_ci#define DP83811_POR_DONE_INT_EN BIT(4) 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ci#define MII_DP83811_RXSOP1 0x04a5 548c2ecf20Sopenharmony_ci#define MII_DP83811_RXSOP2 0x04a6 558c2ecf20Sopenharmony_ci#define MII_DP83811_RXSOP3 0x04a7 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci/* WoL Registers */ 588c2ecf20Sopenharmony_ci#define MII_DP83811_WOL_CFG 0x04a0 598c2ecf20Sopenharmony_ci#define MII_DP83811_WOL_STAT 0x04a1 608c2ecf20Sopenharmony_ci#define MII_DP83811_WOL_DA1 0x04a2 618c2ecf20Sopenharmony_ci#define MII_DP83811_WOL_DA2 0x04a3 628c2ecf20Sopenharmony_ci#define MII_DP83811_WOL_DA3 0x04a4 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci/* WoL bits */ 658c2ecf20Sopenharmony_ci#define DP83811_WOL_MAGIC_EN BIT(0) 668c2ecf20Sopenharmony_ci#define DP83811_WOL_SECURE_ON BIT(5) 678c2ecf20Sopenharmony_ci#define DP83811_WOL_EN BIT(7) 688c2ecf20Sopenharmony_ci#define DP83811_WOL_INDICATION_SEL BIT(8) 698c2ecf20Sopenharmony_ci#define DP83811_WOL_CLR_INDICATION BIT(11) 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ci/* SGMII CTRL bits */ 728c2ecf20Sopenharmony_ci#define DP83811_TDR_AUTO BIT(8) 738c2ecf20Sopenharmony_ci#define DP83811_SGMII_EN BIT(12) 748c2ecf20Sopenharmony_ci#define DP83811_SGMII_AUTO_NEG_EN BIT(13) 758c2ecf20Sopenharmony_ci#define DP83811_SGMII_TX_ERR_DIS BIT(14) 768c2ecf20Sopenharmony_ci#define DP83811_SGMII_SOFT_RESET BIT(15) 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_cistatic int dp83811_ack_interrupt(struct phy_device *phydev) 798c2ecf20Sopenharmony_ci{ 808c2ecf20Sopenharmony_ci int err; 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_ci err = phy_read(phydev, MII_DP83811_INT_STAT1); 838c2ecf20Sopenharmony_ci if (err < 0) 848c2ecf20Sopenharmony_ci return err; 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_ci err = phy_read(phydev, MII_DP83811_INT_STAT2); 878c2ecf20Sopenharmony_ci if (err < 0) 888c2ecf20Sopenharmony_ci return err; 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_ci err = phy_read(phydev, MII_DP83811_INT_STAT3); 918c2ecf20Sopenharmony_ci if (err < 0) 928c2ecf20Sopenharmony_ci return err; 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ci return 0; 958c2ecf20Sopenharmony_ci} 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_cistatic int dp83811_set_wol(struct phy_device *phydev, 988c2ecf20Sopenharmony_ci struct ethtool_wolinfo *wol) 998c2ecf20Sopenharmony_ci{ 1008c2ecf20Sopenharmony_ci struct net_device *ndev = phydev->attached_dev; 1018c2ecf20Sopenharmony_ci const u8 *mac; 1028c2ecf20Sopenharmony_ci u16 value; 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_ci if (wol->wolopts & (WAKE_MAGIC | WAKE_MAGICSECURE)) { 1058c2ecf20Sopenharmony_ci mac = (const u8 *)ndev->dev_addr; 1068c2ecf20Sopenharmony_ci 1078c2ecf20Sopenharmony_ci if (!is_valid_ether_addr(mac)) 1088c2ecf20Sopenharmony_ci return -EINVAL; 1098c2ecf20Sopenharmony_ci 1108c2ecf20Sopenharmony_ci /* MAC addresses start with byte 5, but stored in mac[0]. 1118c2ecf20Sopenharmony_ci * 811 PHYs store bytes 4|5, 2|3, 0|1 1128c2ecf20Sopenharmony_ci */ 1138c2ecf20Sopenharmony_ci phy_write_mmd(phydev, DP83811_DEVADDR, MII_DP83811_WOL_DA1, 1148c2ecf20Sopenharmony_ci (mac[1] << 8) | mac[0]); 1158c2ecf20Sopenharmony_ci phy_write_mmd(phydev, DP83811_DEVADDR, MII_DP83811_WOL_DA2, 1168c2ecf20Sopenharmony_ci (mac[3] << 8) | mac[2]); 1178c2ecf20Sopenharmony_ci phy_write_mmd(phydev, DP83811_DEVADDR, MII_DP83811_WOL_DA3, 1188c2ecf20Sopenharmony_ci (mac[5] << 8) | mac[4]); 1198c2ecf20Sopenharmony_ci 1208c2ecf20Sopenharmony_ci value = phy_read_mmd(phydev, DP83811_DEVADDR, 1218c2ecf20Sopenharmony_ci MII_DP83811_WOL_CFG); 1228c2ecf20Sopenharmony_ci if (wol->wolopts & WAKE_MAGIC) 1238c2ecf20Sopenharmony_ci value |= DP83811_WOL_MAGIC_EN; 1248c2ecf20Sopenharmony_ci else 1258c2ecf20Sopenharmony_ci value &= ~DP83811_WOL_MAGIC_EN; 1268c2ecf20Sopenharmony_ci 1278c2ecf20Sopenharmony_ci if (wol->wolopts & WAKE_MAGICSECURE) { 1288c2ecf20Sopenharmony_ci phy_write_mmd(phydev, DP83811_DEVADDR, 1298c2ecf20Sopenharmony_ci MII_DP83811_RXSOP1, 1308c2ecf20Sopenharmony_ci (wol->sopass[1] << 8) | wol->sopass[0]); 1318c2ecf20Sopenharmony_ci phy_write_mmd(phydev, DP83811_DEVADDR, 1328c2ecf20Sopenharmony_ci MII_DP83811_RXSOP2, 1338c2ecf20Sopenharmony_ci (wol->sopass[3] << 8) | wol->sopass[2]); 1348c2ecf20Sopenharmony_ci phy_write_mmd(phydev, DP83811_DEVADDR, 1358c2ecf20Sopenharmony_ci MII_DP83811_RXSOP3, 1368c2ecf20Sopenharmony_ci (wol->sopass[5] << 8) | wol->sopass[4]); 1378c2ecf20Sopenharmony_ci value |= DP83811_WOL_SECURE_ON; 1388c2ecf20Sopenharmony_ci } else { 1398c2ecf20Sopenharmony_ci value &= ~DP83811_WOL_SECURE_ON; 1408c2ecf20Sopenharmony_ci } 1418c2ecf20Sopenharmony_ci 1428c2ecf20Sopenharmony_ci /* Clear any pending WoL interrupt */ 1438c2ecf20Sopenharmony_ci phy_read(phydev, MII_DP83811_INT_STAT1); 1448c2ecf20Sopenharmony_ci 1458c2ecf20Sopenharmony_ci value |= DP83811_WOL_EN | DP83811_WOL_INDICATION_SEL | 1468c2ecf20Sopenharmony_ci DP83811_WOL_CLR_INDICATION; 1478c2ecf20Sopenharmony_ci 1488c2ecf20Sopenharmony_ci return phy_write_mmd(phydev, DP83811_DEVADDR, 1498c2ecf20Sopenharmony_ci MII_DP83811_WOL_CFG, value); 1508c2ecf20Sopenharmony_ci } else { 1518c2ecf20Sopenharmony_ci return phy_clear_bits_mmd(phydev, DP83811_DEVADDR, 1528c2ecf20Sopenharmony_ci MII_DP83811_WOL_CFG, DP83811_WOL_EN); 1538c2ecf20Sopenharmony_ci } 1548c2ecf20Sopenharmony_ci 1558c2ecf20Sopenharmony_ci} 1568c2ecf20Sopenharmony_ci 1578c2ecf20Sopenharmony_cistatic void dp83811_get_wol(struct phy_device *phydev, 1588c2ecf20Sopenharmony_ci struct ethtool_wolinfo *wol) 1598c2ecf20Sopenharmony_ci{ 1608c2ecf20Sopenharmony_ci u16 sopass_val; 1618c2ecf20Sopenharmony_ci int value; 1628c2ecf20Sopenharmony_ci 1638c2ecf20Sopenharmony_ci wol->supported = (WAKE_MAGIC | WAKE_MAGICSECURE); 1648c2ecf20Sopenharmony_ci wol->wolopts = 0; 1658c2ecf20Sopenharmony_ci 1668c2ecf20Sopenharmony_ci value = phy_read_mmd(phydev, DP83811_DEVADDR, MII_DP83811_WOL_CFG); 1678c2ecf20Sopenharmony_ci 1688c2ecf20Sopenharmony_ci if (value & DP83811_WOL_MAGIC_EN) 1698c2ecf20Sopenharmony_ci wol->wolopts |= WAKE_MAGIC; 1708c2ecf20Sopenharmony_ci 1718c2ecf20Sopenharmony_ci if (value & DP83811_WOL_SECURE_ON) { 1728c2ecf20Sopenharmony_ci sopass_val = phy_read_mmd(phydev, DP83811_DEVADDR, 1738c2ecf20Sopenharmony_ci MII_DP83811_RXSOP1); 1748c2ecf20Sopenharmony_ci wol->sopass[0] = (sopass_val & 0xff); 1758c2ecf20Sopenharmony_ci wol->sopass[1] = (sopass_val >> 8); 1768c2ecf20Sopenharmony_ci 1778c2ecf20Sopenharmony_ci sopass_val = phy_read_mmd(phydev, DP83811_DEVADDR, 1788c2ecf20Sopenharmony_ci MII_DP83811_RXSOP2); 1798c2ecf20Sopenharmony_ci wol->sopass[2] = (sopass_val & 0xff); 1808c2ecf20Sopenharmony_ci wol->sopass[3] = (sopass_val >> 8); 1818c2ecf20Sopenharmony_ci 1828c2ecf20Sopenharmony_ci sopass_val = phy_read_mmd(phydev, DP83811_DEVADDR, 1838c2ecf20Sopenharmony_ci MII_DP83811_RXSOP3); 1848c2ecf20Sopenharmony_ci wol->sopass[4] = (sopass_val & 0xff); 1858c2ecf20Sopenharmony_ci wol->sopass[5] = (sopass_val >> 8); 1868c2ecf20Sopenharmony_ci 1878c2ecf20Sopenharmony_ci wol->wolopts |= WAKE_MAGICSECURE; 1888c2ecf20Sopenharmony_ci } 1898c2ecf20Sopenharmony_ci 1908c2ecf20Sopenharmony_ci /* WoL is not enabled so set wolopts to 0 */ 1918c2ecf20Sopenharmony_ci if (!(value & DP83811_WOL_EN)) 1928c2ecf20Sopenharmony_ci wol->wolopts = 0; 1938c2ecf20Sopenharmony_ci} 1948c2ecf20Sopenharmony_ci 1958c2ecf20Sopenharmony_cistatic int dp83811_config_intr(struct phy_device *phydev) 1968c2ecf20Sopenharmony_ci{ 1978c2ecf20Sopenharmony_ci int misr_status, err; 1988c2ecf20Sopenharmony_ci 1998c2ecf20Sopenharmony_ci if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { 2008c2ecf20Sopenharmony_ci misr_status = phy_read(phydev, MII_DP83811_INT_STAT1); 2018c2ecf20Sopenharmony_ci if (misr_status < 0) 2028c2ecf20Sopenharmony_ci return misr_status; 2038c2ecf20Sopenharmony_ci 2048c2ecf20Sopenharmony_ci misr_status |= (DP83811_RX_ERR_HF_INT_EN | 2058c2ecf20Sopenharmony_ci DP83811_MS_TRAINING_INT_EN | 2068c2ecf20Sopenharmony_ci DP83811_ANEG_COMPLETE_INT_EN | 2078c2ecf20Sopenharmony_ci DP83811_ESD_EVENT_INT_EN | 2088c2ecf20Sopenharmony_ci DP83811_WOL_INT_EN | 2098c2ecf20Sopenharmony_ci DP83811_LINK_STAT_INT_EN | 2108c2ecf20Sopenharmony_ci DP83811_ENERGY_DET_INT_EN | 2118c2ecf20Sopenharmony_ci DP83811_LINK_QUAL_INT_EN); 2128c2ecf20Sopenharmony_ci 2138c2ecf20Sopenharmony_ci err = phy_write(phydev, MII_DP83811_INT_STAT1, misr_status); 2148c2ecf20Sopenharmony_ci if (err < 0) 2158c2ecf20Sopenharmony_ci return err; 2168c2ecf20Sopenharmony_ci 2178c2ecf20Sopenharmony_ci misr_status = phy_read(phydev, MII_DP83811_INT_STAT2); 2188c2ecf20Sopenharmony_ci if (misr_status < 0) 2198c2ecf20Sopenharmony_ci return misr_status; 2208c2ecf20Sopenharmony_ci 2218c2ecf20Sopenharmony_ci misr_status |= (DP83811_JABBER_DET_INT_EN | 2228c2ecf20Sopenharmony_ci DP83811_POLARITY_INT_EN | 2238c2ecf20Sopenharmony_ci DP83811_SLEEP_MODE_INT_EN | 2248c2ecf20Sopenharmony_ci DP83811_OVERTEMP_INT_EN | 2258c2ecf20Sopenharmony_ci DP83811_OVERVOLTAGE_INT_EN | 2268c2ecf20Sopenharmony_ci DP83811_UNDERVOLTAGE_INT_EN); 2278c2ecf20Sopenharmony_ci 2288c2ecf20Sopenharmony_ci err = phy_write(phydev, MII_DP83811_INT_STAT2, misr_status); 2298c2ecf20Sopenharmony_ci if (err < 0) 2308c2ecf20Sopenharmony_ci return err; 2318c2ecf20Sopenharmony_ci 2328c2ecf20Sopenharmony_ci misr_status = phy_read(phydev, MII_DP83811_INT_STAT3); 2338c2ecf20Sopenharmony_ci if (misr_status < 0) 2348c2ecf20Sopenharmony_ci return misr_status; 2358c2ecf20Sopenharmony_ci 2368c2ecf20Sopenharmony_ci misr_status |= (DP83811_LPS_INT_EN | 2378c2ecf20Sopenharmony_ci DP83811_NO_FRAME_INT_EN | 2388c2ecf20Sopenharmony_ci DP83811_POR_DONE_INT_EN); 2398c2ecf20Sopenharmony_ci 2408c2ecf20Sopenharmony_ci err = phy_write(phydev, MII_DP83811_INT_STAT3, misr_status); 2418c2ecf20Sopenharmony_ci 2428c2ecf20Sopenharmony_ci } else { 2438c2ecf20Sopenharmony_ci err = phy_write(phydev, MII_DP83811_INT_STAT1, 0); 2448c2ecf20Sopenharmony_ci if (err < 0) 2458c2ecf20Sopenharmony_ci return err; 2468c2ecf20Sopenharmony_ci 2478c2ecf20Sopenharmony_ci err = phy_write(phydev, MII_DP83811_INT_STAT2, 0); 2488c2ecf20Sopenharmony_ci if (err < 0) 2498c2ecf20Sopenharmony_ci return err; 2508c2ecf20Sopenharmony_ci 2518c2ecf20Sopenharmony_ci err = phy_write(phydev, MII_DP83811_INT_STAT3, 0); 2528c2ecf20Sopenharmony_ci } 2538c2ecf20Sopenharmony_ci 2548c2ecf20Sopenharmony_ci return err; 2558c2ecf20Sopenharmony_ci} 2568c2ecf20Sopenharmony_ci 2578c2ecf20Sopenharmony_cistatic int dp83811_config_aneg(struct phy_device *phydev) 2588c2ecf20Sopenharmony_ci{ 2598c2ecf20Sopenharmony_ci int value, err; 2608c2ecf20Sopenharmony_ci 2618c2ecf20Sopenharmony_ci if (phydev->interface == PHY_INTERFACE_MODE_SGMII) { 2628c2ecf20Sopenharmony_ci value = phy_read(phydev, MII_DP83811_SGMII_CTRL); 2638c2ecf20Sopenharmony_ci if (phydev->autoneg == AUTONEG_ENABLE) { 2648c2ecf20Sopenharmony_ci err = phy_write(phydev, MII_DP83811_SGMII_CTRL, 2658c2ecf20Sopenharmony_ci (DP83811_SGMII_AUTO_NEG_EN | value)); 2668c2ecf20Sopenharmony_ci if (err < 0) 2678c2ecf20Sopenharmony_ci return err; 2688c2ecf20Sopenharmony_ci } else { 2698c2ecf20Sopenharmony_ci err = phy_write(phydev, MII_DP83811_SGMII_CTRL, 2708c2ecf20Sopenharmony_ci (~DP83811_SGMII_AUTO_NEG_EN & value)); 2718c2ecf20Sopenharmony_ci if (err < 0) 2728c2ecf20Sopenharmony_ci return err; 2738c2ecf20Sopenharmony_ci } 2748c2ecf20Sopenharmony_ci } 2758c2ecf20Sopenharmony_ci 2768c2ecf20Sopenharmony_ci return genphy_config_aneg(phydev); 2778c2ecf20Sopenharmony_ci} 2788c2ecf20Sopenharmony_ci 2798c2ecf20Sopenharmony_cistatic int dp83811_config_init(struct phy_device *phydev) 2808c2ecf20Sopenharmony_ci{ 2818c2ecf20Sopenharmony_ci int value, err; 2828c2ecf20Sopenharmony_ci 2838c2ecf20Sopenharmony_ci value = phy_read(phydev, MII_DP83811_SGMII_CTRL); 2848c2ecf20Sopenharmony_ci if (phydev->interface == PHY_INTERFACE_MODE_SGMII) { 2858c2ecf20Sopenharmony_ci err = phy_write(phydev, MII_DP83811_SGMII_CTRL, 2868c2ecf20Sopenharmony_ci (DP83811_SGMII_EN | value)); 2878c2ecf20Sopenharmony_ci } else { 2888c2ecf20Sopenharmony_ci err = phy_write(phydev, MII_DP83811_SGMII_CTRL, 2898c2ecf20Sopenharmony_ci (~DP83811_SGMII_EN & value)); 2908c2ecf20Sopenharmony_ci } 2918c2ecf20Sopenharmony_ci 2928c2ecf20Sopenharmony_ci if (err < 0) 2938c2ecf20Sopenharmony_ci 2948c2ecf20Sopenharmony_ci return err; 2958c2ecf20Sopenharmony_ci 2968c2ecf20Sopenharmony_ci value = DP83811_WOL_MAGIC_EN | DP83811_WOL_SECURE_ON | DP83811_WOL_EN; 2978c2ecf20Sopenharmony_ci 2988c2ecf20Sopenharmony_ci return phy_clear_bits_mmd(phydev, DP83811_DEVADDR, MII_DP83811_WOL_CFG, 2998c2ecf20Sopenharmony_ci value); 3008c2ecf20Sopenharmony_ci} 3018c2ecf20Sopenharmony_ci 3028c2ecf20Sopenharmony_cistatic int dp83811_phy_reset(struct phy_device *phydev) 3038c2ecf20Sopenharmony_ci{ 3048c2ecf20Sopenharmony_ci int err; 3058c2ecf20Sopenharmony_ci 3068c2ecf20Sopenharmony_ci err = phy_write(phydev, MII_DP83811_RESET_CTRL, DP83811_HW_RESET); 3078c2ecf20Sopenharmony_ci if (err < 0) 3088c2ecf20Sopenharmony_ci return err; 3098c2ecf20Sopenharmony_ci 3108c2ecf20Sopenharmony_ci return 0; 3118c2ecf20Sopenharmony_ci} 3128c2ecf20Sopenharmony_ci 3138c2ecf20Sopenharmony_cistatic int dp83811_suspend(struct phy_device *phydev) 3148c2ecf20Sopenharmony_ci{ 3158c2ecf20Sopenharmony_ci int value; 3168c2ecf20Sopenharmony_ci 3178c2ecf20Sopenharmony_ci value = phy_read_mmd(phydev, DP83811_DEVADDR, MII_DP83811_WOL_CFG); 3188c2ecf20Sopenharmony_ci 3198c2ecf20Sopenharmony_ci if (!(value & DP83811_WOL_EN)) 3208c2ecf20Sopenharmony_ci genphy_suspend(phydev); 3218c2ecf20Sopenharmony_ci 3228c2ecf20Sopenharmony_ci return 0; 3238c2ecf20Sopenharmony_ci} 3248c2ecf20Sopenharmony_ci 3258c2ecf20Sopenharmony_cistatic int dp83811_resume(struct phy_device *phydev) 3268c2ecf20Sopenharmony_ci{ 3278c2ecf20Sopenharmony_ci genphy_resume(phydev); 3288c2ecf20Sopenharmony_ci 3298c2ecf20Sopenharmony_ci phy_set_bits_mmd(phydev, DP83811_DEVADDR, MII_DP83811_WOL_CFG, 3308c2ecf20Sopenharmony_ci DP83811_WOL_CLR_INDICATION); 3318c2ecf20Sopenharmony_ci 3328c2ecf20Sopenharmony_ci return 0; 3338c2ecf20Sopenharmony_ci} 3348c2ecf20Sopenharmony_ci 3358c2ecf20Sopenharmony_cistatic struct phy_driver dp83811_driver[] = { 3368c2ecf20Sopenharmony_ci { 3378c2ecf20Sopenharmony_ci .phy_id = DP83TC811_PHY_ID, 3388c2ecf20Sopenharmony_ci .phy_id_mask = 0xfffffff0, 3398c2ecf20Sopenharmony_ci .name = "TI DP83TC811", 3408c2ecf20Sopenharmony_ci /* PHY_BASIC_FEATURES */ 3418c2ecf20Sopenharmony_ci .config_init = dp83811_config_init, 3428c2ecf20Sopenharmony_ci .config_aneg = dp83811_config_aneg, 3438c2ecf20Sopenharmony_ci .soft_reset = dp83811_phy_reset, 3448c2ecf20Sopenharmony_ci .get_wol = dp83811_get_wol, 3458c2ecf20Sopenharmony_ci .set_wol = dp83811_set_wol, 3468c2ecf20Sopenharmony_ci .ack_interrupt = dp83811_ack_interrupt, 3478c2ecf20Sopenharmony_ci .config_intr = dp83811_config_intr, 3488c2ecf20Sopenharmony_ci .suspend = dp83811_suspend, 3498c2ecf20Sopenharmony_ci .resume = dp83811_resume, 3508c2ecf20Sopenharmony_ci }, 3518c2ecf20Sopenharmony_ci}; 3528c2ecf20Sopenharmony_cimodule_phy_driver(dp83811_driver); 3538c2ecf20Sopenharmony_ci 3548c2ecf20Sopenharmony_cistatic struct mdio_device_id __maybe_unused dp83811_tbl[] = { 3558c2ecf20Sopenharmony_ci { DP83TC811_PHY_ID, 0xfffffff0 }, 3568c2ecf20Sopenharmony_ci { }, 3578c2ecf20Sopenharmony_ci}; 3588c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(mdio, dp83811_tbl); 3598c2ecf20Sopenharmony_ci 3608c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("Texas Instruments DP83TC811 PHY driver"); 3618c2ecf20Sopenharmony_ciMODULE_AUTHOR("Dan Murphy <dmurphy@ti.com"); 3628c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL"); 363