Received: by 10.213.65.68 with SMTP id h4csp1891033imn; Sun, 8 Apr 2018 14:00:01 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/tOgBMr9x5mwMx6dZhFlsxQgZUaPFQUzu/EVVAQkLxvl1Iul0diUysT8Ux0GNNTeenGKmR X-Received: by 2002:a17:902:24c7:: with SMTP id l7-v6mr35661724plg.320.1523221201110; Sun, 08 Apr 2018 14:00:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523221201; cv=none; d=google.com; s=arc-20160816; b=imBV+xCjSIjAOTKhBwkx+jsZGPHOUhe1qXrOgVudd8VmTMReamI++dfpVx8ztRXRnL NLGIOnyY8plMKftBzJ11uecRa2HaSMlaIIymvbXIFauBlB00IOZp4bVsKGzCwzoLr8+A HK1wE1cNSN7abB+8F7M335ver095UF8NjbSuou0Gtl6n7BRUp4MjsEARrZ4oH3p6UCb/ Mnfm41P87jCLxW8QNyCFsKY89mn+2mJr7NT1vvOKLhNrk0kt+1jqC63TgQxDQKsC8AVm Tst140wbw0yjcN8x0kMKbPlMNgPq2vBT+7tPyYAs77T3B22GRj9P/bGuLISvUIDGwCBz 2Jqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=yLpZIOSI3P40stUkvCaHvYu9QTcWGLzhE+XIY40LtZ4=; b=jN53oSiktebEthp3Ydt5EMYfARAlM7el4mdadlF8IvM9eA5izKbslvYKdDu+9kTO6r cugBdH71RcsHNMpXJoByYIS3jtZWOIkPGX+c4Pvwa8wE1RVvaix7BG2VOLiUt1v2Yu5T 4mwCJdEtVOUjIdRbE/PttgwZAP9Bzh2CwhMq+cbP3MkeSxJWqMcO4wWr6TNqRhzes4Hn wHcxqO8QxsE7P5cJRawEDsG9bgcOMdZiidwvNIqb/q231ay26T/9mTDwEpnctxFmBqB+ GmgnVepGRc1y2b7KfgdmgqypoXuBaO1nUGsekXlY2x0WmSBniCiJ651gErlOfRzmGqvK kkyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=p9xI0PRL; 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=fail (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 k1-v6si12828271pld.267.2018.04.08.13.59.24; Sun, 08 Apr 2018 14:00:01 -0700 (PDT) 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=fail header.i=@gmail.com header.s=20161025 header.b=p9xI0PRL; 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=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752401AbeDHURO (ORCPT + 99 others); Sun, 8 Apr 2018 16:17:14 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:40694 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751552AbeDHURM (ORCPT ); Sun, 8 Apr 2018 16:17:12 -0400 Received: by mail-wm0-f66.google.com with SMTP id x4so12073914wmh.5; Sun, 08 Apr 2018 13:17:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=yLpZIOSI3P40stUkvCaHvYu9QTcWGLzhE+XIY40LtZ4=; b=p9xI0PRLeKo95zJGm3Dx+w8YuDoXiOuUK8elmUfNDy3Y7+TAUHetcia5DNTFm0/jCy HIE3340+DQv1HzJa0EoY7uw6650BsR/ZfnSiBCJcMpndIPlikdehd20d8cxE+DCZorOv E0z9WLA9TMYf7yydx6+vU1ICxIDuAJsEHbRf7rcpojQlpoDrbHYm04VXk7tfKmPB61eI iyTwBXx9Pypqn4v7qiZQidZVynMkoDVIPP5yymncKLNneqF6CS8C7DPBlsIti7WuQeES Zuq9WP0pOlV83h8NbJ+pAd7kfGwaPvnzCgPjtYUmKpMffmE0Kaw0x1wJi5+e2xkdf3Lp 9k5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=yLpZIOSI3P40stUkvCaHvYu9QTcWGLzhE+XIY40LtZ4=; b=kfc83tWkeER6gCiNA4NvMV0lQgfjj8Bw92W/VIZymm3Gz/DXnZQUmkuGiRhgKzwjTc ItAQddP+Mt6JRMVs0TUbjgo8QNSCcF+O4A4q9TWllZ/nqC+cH1JdJ0MrqEoHqU0+jngx XEfKx1xCxBrMohgNuqyIldWX6MR4OcTr4xtS330qFS24+WQH1MUsL7HIpBFcYJNik/2C W6fWbGZWoT2Kd+aFbOYgVgX9WE1sWTJ7X1S416g+fngFH9SuypQZ/rNJUXCrFZTFOPli 27eYIPQlPlVj1Rp/JKj2sPwxV3vwgxaBTqGsd64uLPeDU+BFZ2gOYnIyLGEdm6HftTfJ E4fg== X-Gm-Message-State: ALQs6tA8o0VQqviRWZsXMTMVYsmcIXgTGoV5DqUGSOG1NLZ+ktwQlzpR z2Iyg+YLa1KDXcZ93vmz80f+7Tu9 X-Received: by 10.46.18.150 with SMTP id 22mr20674909ljs.120.1523218630998; Sun, 08 Apr 2018 13:17:10 -0700 (PDT) Received: from localhost (87-57-30-174-static.dk.customer.tdc.net. [87.57.30.174]) by smtp.gmail.com with ESMTPSA id o203-v6sm1394244lff.25.2018.04.08.13.17.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 08 Apr 2018 13:17:10 -0700 (PDT) From: Esben Haabendal To: netdev@vger.kernel.org Cc: Esben Haabendal , Richard Cochran , Andrew Lunn , Florian Fainelli , linux-kernel@vger.kernel.org Subject: [PATCH v3] dp83640: Ensure against premature access to PHY registers after reset Date: Sun, 8 Apr 2018 22:17:01 +0200 Message-Id: <20180408201702.23299-1-esben.haabendal@gmail.com> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180406170844.4248-1-esben.haabendal@gmail.com> References: <20180406170844.4248-1-esben.haabendal@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Esben Haabendal The datasheet specifies a 3uS pause after performing a software reset. The default implementation of genphy_soft_reset() does not provide this, so implement soft_reset with the needed pause. Signed-off-by: Esben Haabendal Reviewed-by: Andrew Lunn --- drivers/net/phy/dp83640.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/net/phy/dp83640.c b/drivers/net/phy/dp83640.c index 654f42d00092..a6c87793d899 100644 --- a/drivers/net/phy/dp83640.c +++ b/drivers/net/phy/dp83640.c @@ -1207,6 +1207,23 @@ static void dp83640_remove(struct phy_device *phydev) kfree(dp83640); } +static int dp83640_soft_reset(struct phy_device *phydev) +{ + int ret; + + ret = genphy_soft_reset(phydev); + if (ret < 0) + return ret; + + /* From DP83640 datasheet: "Software driver code must wait 3 us + * following a software reset before allowing further serial MII + * operations with the DP83640." + */ + udelay(10); /* Taking udelay inaccuracy into account */ + + return 0; +} + static int dp83640_config_init(struct phy_device *phydev) { struct dp83640_private *dp83640 = phydev->priv; @@ -1501,6 +1518,7 @@ static struct phy_driver dp83640_driver = { .flags = PHY_HAS_INTERRUPT, .probe = dp83640_probe, .remove = dp83640_remove, + .soft_reset = dp83640_soft_reset, .config_init = dp83640_config_init, .ack_interrupt = dp83640_ack_interrupt, .config_intr = dp83640_config_intr, -- 2.16.3