From patchwork Thu Jan 3 01:10:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10746857 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 03A4817D2 for ; Thu, 3 Jan 2019 01:12:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E8E8E28409 for ; Thu, 3 Jan 2019 01:12:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DCD4F28417; Thu, 3 Jan 2019 01:12:44 +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 7925C28409 for ; Thu, 3 Jan 2019 01:12:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726776AbfACBMl (ORCPT ); Wed, 2 Jan 2019 20:12:41 -0500 Received: from mail-out.m-online.net ([212.18.0.10]:51436 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726553AbfACBLR (ORCPT ); Wed, 2 Jan 2019 20:11:17 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 43VVH70DV3z1qvSr; Thu, 3 Jan 2019 02:11:15 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 43VVH7035Lz1qvWh; Thu, 3 Jan 2019 02:11:15 +0100 (CET) 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 XjxeMPklKouF; Thu, 3 Jan 2019 02:11:13 +0100 (CET) X-Auth-Info: MrZqCBrsz0xCs9v1uGwwyVhWdR2olXbtXFNoljhD/Vo= Received: from kurokawa.lan (ip-86-49-110-70.net.upcbroadband.cz [86.49.110.70]) (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; Thu, 3 Jan 2019 02:11:13 +0100 (CET) From: Marek Vasut To: netdev@vger.kernel.org Cc: Marek Vasut , "David S . Miller" , Nisar Sayed , Woojung Huh , Andrew Lunn , Florian Fainelli , linux-usb@vger.kernel.org Subject: [PATCH 09/19] usbnet: smsc95xx: Connect to phydev Date: Thu, 3 Jan 2019 02:10:30 +0100 Message-Id: <20190103011040.25974-10-marex@denx.de> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190103011040.25974-1-marex@denx.de> References: <20190103011040.25974-1-marex@denx.de> MIME-Version: 1.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 Add code to detect and connect to PHY. The internal PHY of the SMSC95xx is a regular SMSC LAN8700 and the driver only supports the internal PHY, so just use the SMSC PHY driver to configure the PHY. Note that the driver does a lot of extra configuration of the PHY, which is left in to avoid breakage. Some of the extra configuration is sorted out by later patches in this series. Signed-off-by: Marek Vasut Cc: David S. Miller Cc: Nisar Sayed Cc: Woojung Huh Cc: Andrew Lunn Cc: Florian Fainelli Cc: linux-usb@vger.kernel.org To: netdev@vger.kernel.org --- drivers/net/usb/smsc95xx.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c index 2cd5e1d34559..ce61be8ee32b 100644 --- a/drivers/net/usb/smsc95xx.c +++ b/drivers/net/usb/smsc95xx.c @@ -78,6 +78,7 @@ struct smsc95xx_priv { struct delayed_work carrier_check; struct usbnet *dev; struct mii_bus *mii_bus; + struct phy_device *phydev; }; static bool turbo_mode = true; @@ -960,6 +961,11 @@ static int smsc95xx_start_rx_path(struct usbnet *dev) return smsc95xx_write_reg(dev, MAC_CR, pdata->mac_cr); } + +static void smsc95xx_adjust_link(struct net_device *netdev) +{ +} + static int smsc95xx_phy_initialize(struct usbnet *dev) { int bmcr, ret, timeout = 0; @@ -1308,6 +1314,10 @@ static int smsc95xx_bind(struct usbnet *dev, struct usb_interface *intf) if (ret) goto err_mdiobus_alloc; + ret = mdiobus_register(bus); + if (ret) + goto err_mdiobus_register; + /* Initialize MII structure */ dev->mii.dev = dev->net; dev->mii.mdio_read = smsc95xx_mdio_read; @@ -1316,9 +1326,24 @@ static int smsc95xx_bind(struct usbnet *dev, struct usb_interface *intf) dev->mii.reg_num_mask = 0x1f; dev->mii.phy_id = SMSC95XX_INTERNAL_PHY_ID; - ret = mdiobus_register(bus); - if (ret) + /* Connect to PHY */ + pdata->phydev = phy_find_first(pdata->mii_bus); + if (!pdata->phydev) { + netdev_err(dev->net, "no PHY found\n"); + ret = -EIO; goto err_mdiobus_register; + } + + ret = phy_connect_direct(dev->net, pdata->phydev, + &smsc95xx_adjust_link, + PHY_INTERFACE_MODE_MII); + if (ret) { + netdev_err(dev->net, "Could not connect to PHY device\n"); + goto err_mdiobus_register; + } + + genphy_resume(pdata->phydev); + phy_start(pdata->phydev); ret = smsc95xx_reset_post(dev); if (ret)