Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp970847imu; Fri, 21 Dec 2018 10:16:22 -0800 (PST) X-Google-Smtp-Source: ALg8bN57BtI+kOfwGCpsLuzwnTj2ptUNymkLPmduVuP9e8PoZs1dtECvNuT6szjC2U/vOfunuVjK X-Received: by 2002:a63:2263:: with SMTP id t35mr3392151pgm.69.1545416182609; Fri, 21 Dec 2018 10:16:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545416182; cv=none; d=google.com; s=arc-20160816; b=mRm9Vxsh78XEuWit6NJN7SJyZF4K35epUgLjYlPIazT/zuUtNVCJH++1oCGrl82fed LN9HYMowdJv/rlufSol87UiITmz3RqiqSoEgT/sAoS3Eu3zgKjhnpNyYV7biWTLpT+a+ 5q/xU+OFuk5NE1U6WfoAP3sdqNlZae1QtCOCBkpq2M9tQihz2NzDsQUW5SVrw7OS9wcD UUwwD1Bb2yRvKV2txjC0tu7R4hB3HmURzs4hDNXXIQRNS/UT4RFp0/Tk3VijcINrMQup KP0trTMQhnNMGGxTFspLQU+xBn57ZDr/6kIjepL17PusioGTBXojG1pIuv0k9lYvnLHe vobA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=rZpt6IZJExB+1DUmVUcp0qlAQJqjtaoSfZntRDcDJUk=; b=05l5s4RwPgJla1YfmxPNdhUDwPlGXXcE/7XKDgIBQPUSixtZPkqS3FfhXIBVkAb8It wKusEwX+7XVRwrNoiHpm9GL4KF6QOjHiLaw4f3Wu0mdo5noLUfrY6TMLBhXO5XJi75hp XhMQKrgj/5lKMbDZ2S4yQt2zjWnQb/IfkqaVsiBHQV3z7jBIp2xk/iScJnAW0HUFj4dI W2I4QULlPmbMYKGAX2endUi6YPZG7twXQNuK/CcuPIDt+klo16UBLilFfa8rH2v6asM5 XQ0UsJxSUZ5J9yO4IuGzTSQIrwgh9EebV3qQwOc7IpUv17cfCgRPKMpma/zDvzzcq/jP Z1Fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZFRLZWj3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d12si20752975pln.340.2018.12.21.10.16.07; Fri, 21 Dec 2018 10:16:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZFRLZWj3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388670AbeLUJqI (ORCPT + 99 others); Fri, 21 Dec 2018 04:46:08 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:36304 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729789AbeLUJqH (ORCPT ); Fri, 21 Dec 2018 04:46:07 -0500 Received: by mail-lf1-f66.google.com with SMTP id a16so3463984lfg.3 for ; Fri, 21 Dec 2018 01:46:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=rZpt6IZJExB+1DUmVUcp0qlAQJqjtaoSfZntRDcDJUk=; b=ZFRLZWj3jysGlW8tRcnKahfc7Hn9I/Q/3aY1xlR6XRRvH2M620GzqtmSuVOKQ8Hj9m FQuxO9RKLXFKE0edPbzw7DuqhYHBS3kcaMj9z795CREqe28DSSVASXW08ktQLDvCSIq0 5rfbCeipeqiZ6j1QEGeMNgC9TiqSwBmhG9gJ+YwYC37Gkqr8t/G1gg1pNbRHtHWS0gou ChB/gJCsmw+nhgiuh12gqtooIlTYdJgWDSYe9qvx4ZDpjEU8bmZUEuxavO5dB26jr2SG kyZ16UGaeiOvBjvMwKI4Cev34enYc390T9wUuj3CgN7fPSqLeZinVdw3/1EomWm9281E UYAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=rZpt6IZJExB+1DUmVUcp0qlAQJqjtaoSfZntRDcDJUk=; b=TuZ5T0lEo6T3VV9LPExaWrGD9Lmnb8SZCLL3ydfEpGSz8xG820arN/EofQ4CmKo51Z Vbd5r/B0rRIaVVPcNn3+T7VSNoYAqpfEVUDRBXwd0XRvoNysIbPZrfSyIw3pAmx4REh4 faHbzkk/P4VeZwhQvekPuFuNgAsEN7Epytn1Q3yDnE1H66EOyxl4q8VSccik6dvx0hhv OBvFG5JfK70dPwMnEV2CMK91gnQ0ZJTDDLLUD6Eqp9JJByRIBnOgv5qJwjW0d2gydN34 P72kCZ3eJzmxKKQy5Pkv7PPLNRYU+AC1r4Fpp3VmWKITYpiVSreTv2HXxkR5TEzayoR4 LMVA== X-Gm-Message-State: AA+aEWZgm4UYRj9tj1K4LLyq30j9jTND5xUPRxSFvd1dlqHZLLKLW8l7 ktm6k5cypwEdVTIMEHzDm3rPaXB5 X-Received: by 2002:a19:9904:: with SMTP id b4mr927334lfe.95.1545385565244; Fri, 21 Dec 2018 01:46:05 -0800 (PST) Received: from maxim-H61M-D2-B3.d-systems.local ([185.75.190.112]) by smtp.gmail.com with ESMTPSA id k21-v6sm4430909ljc.15.2018.12.21.01.46.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Dec 2018 01:46:04 -0800 (PST) From: Max Uvarov To: linux-kernel@vger.kernel.org Cc: UNGLinuxDriver@microchip.com, steve.glendinning@shawell.net, Max Uvarov Subject: [PATCH] usbnet: smsc95xx: allow to down ethernet link Date: Fri, 21 Dec 2018 12:45:53 +0300 Message-Id: <20181221094553.13137-1-muvarov@gmail.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org allow ifconfig ethX to down ethernet link. Ethernet part of chip is switched to power down more and on ifconfig up driver does soft reset and restores it's state. Signed-off-by: Max Uvarov --- drivers/net/usb/smsc95xx.c | 34 +++++++++++++++++++++++++++++++++- drivers/net/usb/smsc95xx.h | 5 +++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c index 41e283f3eeb9..e72b038cfb79 100644 --- a/drivers/net/usb/smsc95xx.c +++ b/drivers/net/usb/smsc95xx.c @@ -1142,9 +1142,41 @@ static int smsc95xx_reset(struct usbnet *dev) return 0; } +static int smsc95xx_lan_power_down(struct net_device *net) +{ + struct usbnet *dev = netdev_priv(net); + struct mii_if_info *mii = &dev->mii; + int ret; + + ret = smsc95xx_mdio_read_nopm(net, mii->phy_id, SMSC95XX_PHY_BASIC); + if (ret < 0) + return ret; + ret &= ~SMSC95XX_PHY_BASIC_BIT_AUTONEG; /* disable autoneg */ + smsc95xx_mdio_write_nopm(net, mii->phy_id, SMSC95XX_PHY_BASIC, ret); + + ret = smsc95xx_mdio_read_nopm(net, mii->phy_id, SMSC95XX_PHY_BASIC); + if (ret < 0) + return ret; + ret |= SMSC95XX_PHY_BASIC_BIT_POWER_DOWN; /* enable power down */ + smsc95xx_mdio_write_nopm(net, mii->phy_id, SMSC95XX_PHY_BASIC, ret); + + return 0; +} + +static int smsc95xx_stop(struct net_device *net) +{ + int ret; + + ret = smsc95xx_lan_power_down(net); + if (ret) + netdev_err(net, "err switch to power down mode\n"); + + return usbnet_stop(net); +} + static const struct net_device_ops smsc95xx_netdev_ops = { .ndo_open = usbnet_open, - .ndo_stop = usbnet_stop, + .ndo_stop = smsc95xx_stop, .ndo_start_xmit = usbnet_start_xmit, .ndo_tx_timeout = usbnet_tx_timeout, .ndo_change_mtu = usbnet_change_mtu, diff --git a/drivers/net/usb/smsc95xx.h b/drivers/net/usb/smsc95xx.h index 526faa0c44e6..547e8053feba 100644 --- a/drivers/net/usb/smsc95xx.h +++ b/drivers/net/usb/smsc95xx.h @@ -47,6 +47,11 @@ #define RX_STS_DB_ (0x00000004) /* Dribbling */ #define RX_STS_CRC_ (0x00000002) /* CRC Error */ +/* Basic Control Register */ +#define SMSC95XX_PHY_BASIC (0x0) +#define SMSC95XX_PHY_BASIC_BIT_AUTONEG BIT(12) +#define SMSC95XX_PHY_BASIC_BIT_POWER_DOWN BIT(11) + /* SCSRs */ #define ID_REV (0x00) #define ID_REV_CHIP_ID_MASK_ (0xFFFF0000) -- 2.17.1