From patchwork Tue Sep 11 10:12:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10595415 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 47AA2920 for ; Tue, 11 Sep 2018 10:12:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 362FE291AB for ; Tue, 11 Sep 2018 10:12:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2A288291B3; Tue, 11 Sep 2018 10:12:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 996A1291AB for ; Tue, 11 Sep 2018 10:12:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726983AbeIKPLX (ORCPT ); Tue, 11 Sep 2018 11:11:23 -0400 Received: from mail-out.m-online.net ([212.18.0.10]:35584 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726612AbeIKPLX (ORCPT ); Tue, 11 Sep 2018 11:11:23 -0400 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 428ghW5phBz1qxRx; Tue, 11 Sep 2018 12:12:43 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 428ghW5Nbtz1qr2j; Tue, 11 Sep 2018 12:12:43 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id f8PP1wVLnQEr; Tue, 11 Sep 2018 12:12:42 +0200 (CEST) X-Auth-Info: rFYq3nnH75+yIzg1KT770heTc6VGOI6r4Lyg0Oz/2oE= Received: from kurokawa.lan (ip-86-49-107-50.net.upcbroadband.cz [86.49.107.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Tue, 11 Sep 2018 12:12:42 +0200 (CEST) From: Marek Vasut To: linux-usb@vger.kernel.org Cc: Marek Vasut , "David S . Miller" , Nisar Sayed , Woojung Huh Subject: [PATCH] smsc95xx: Add quirk for TJA1100 BroadRReach PHY Date: Tue, 11 Sep 2018 12:12:37 +0200 Message-Id: <20180911101237.4281-1-marex@denx.de> X-Mailer: git-send-email 2.18.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The company atmes.de manufactures a SMSC95xx device with default USB ID 0424:9e00 , but with external NXP TJA1100 PHY at address 0x4. This PHY is not 802.3 c22 compliant, but rather c96 compliant. The register set is slightly different and does not provide link state information in c22-compliant manner and any duplex information. This patch adds a quirk for such a setup. The PHY is detected by its PHY ID register values and if present, link detection is not performed and duplex is always forced to full. Signed-off-by: Marek Vasut Cc: David S. Miller Cc: Nisar Sayed Cc: Woojung Huh --- drivers/net/usb/smsc95xx.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c index 014bb71ce8a8..454a3994133d 100644 --- a/drivers/net/usb/smsc95xx.c +++ b/drivers/net/usb/smsc95xx.c @@ -74,6 +74,7 @@ struct smsc95xx_priv { u8 suspend_flags; u8 mdix_ctrl; bool link_ok; + bool has_tja1100_phy; struct delayed_work carrier_check; struct usbnet *dev; }; @@ -578,7 +579,8 @@ static int smsc95xx_link_reset(struct usbnet *dev) if (ret < 0) return ret; - mii_check_media(mii, 1, 1); + if (!pdata->has_tja1100_phy) + mii_check_media(mii, 1, 1); mii_ethtool_gset(&dev->mii, &ecmd); lcladv = smsc95xx_mdio_read(dev->net, mii->phy_id, MII_ADVERTISE); rmtadv = smsc95xx_mdio_read(dev->net, mii->phy_id, MII_LPA); @@ -588,7 +590,7 @@ static int smsc95xx_link_reset(struct usbnet *dev) ethtool_cmd_speed(&ecmd), ecmd.duplex, lcladv, rmtadv); spin_lock_irqsave(&pdata->mac_cr_lock, flags); - if (ecmd.duplex != DUPLEX_FULL) { + if (!pdata->has_tja1100_phy && ecmd.duplex != DUPLEX_FULL) { pdata->mac_cr &= ~MAC_CR_FDPX_; pdata->mac_cr |= MAC_CR_RCVOWN_; } else { @@ -985,6 +987,7 @@ static int smsc95xx_start_rx_path(struct usbnet *dev, int in_pm) static int smsc95xx_phy_address(struct usbnet *dev) { + struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); u32 read_buf; int ret, id1, id2, phyad; @@ -1006,9 +1009,19 @@ static int smsc95xx_phy_address(struct usbnet *dev) for (phyad = 0x1f; phyad >= 0; phyad--) { id1 = smsc95xx_mdio_read(dev->net, phyad, MII_PHYSID1); id2 = smsc95xx_mdio_read(dev->net, phyad, MII_PHYSID2); + /* Check for valid response from the PHY */ - if (id1 > 0 && id2 > 0 && id1 != 0x7fff && id2 != 0xffff) + if (id1 > 0 && id2 > 0 && id1 != 0x7fff && id2 != 0xffff) { + /* + * Check for special mutation of the SMSC95xx USB + * device with NXP TJA1100 BroadRReach PHY. If this + * is present, enable quirk. + */ + if (id1 == 0x0180 && id2 == 0xdc48) + pdata->has_tja1100_phy = true; + return phyad; + } } /* No PHY found. */