From: Marek Vasut <marex@denx.de> To: netdev@vger.kernel.org Cc: Marek Vasut <marex@denx.de>, "David S . Miller" <davem@davemloft.net>, Nisar Sayed <Nisar.Sayed@microchip.com>, Woojung Huh <Woojung.Huh@microchip.com>, Andrew Lunn <andrew@lunn.ch>, Florian Fainelli <f.fainelli@gmail.com>, linux-usb@vger.kernel.org Subject: [PATCH 09/19] usbnet: smsc95xx: Connect to phydev Date: Thu, 3 Jan 2019 02:10:30 +0100 [thread overview] Message-ID: <20190103011040.25974-10-marex@denx.de> (raw) In-Reply-To: <20190103011040.25974-1-marex@denx.de> 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 <marex@denx.de> Cc: David S. Miller <davem@davemloft.net> Cc: Nisar Sayed <Nisar.Sayed@microchip.com> Cc: Woojung Huh <Woojung.Huh@microchip.com> Cc: Andrew Lunn <andrew@lunn.ch> Cc: Florian Fainelli <f.fainelli@gmail.com> 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) -- 2.19.2
WARNING: multiple messages have this Message-ID (diff)
From: Marek Vasut <marex@denx.de> To: netdev@vger.kernel.org Cc: Marek Vasut <marex@denx.de>, "David S . Miller" <davem@davemloft.net>, Nisar Sayed <Nisar.Sayed@microchip.com>, Woojung Huh <Woojung.Huh@microchip.com>, Andrew Lunn <andrew@lunn.ch>, Florian Fainelli <f.fainelli@gmail.com>, linux-usb@vger.kernel.org Subject: [09/19] usbnet: smsc95xx: Connect to phydev Date: Thu, 3 Jan 2019 02:10:30 +0100 [thread overview] Message-ID: <20190103011040.25974-10-marex@denx.de> (raw) 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 <marex@denx.de> Cc: David S. Miller <davem@davemloft.net> Cc: Nisar Sayed <Nisar.Sayed@microchip.com> Cc: Woojung Huh <Woojung.Huh@microchip.com> Cc: Andrew Lunn <andrew@lunn.ch> Cc: Florian Fainelli <f.fainelli@gmail.com> 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)
next prev parent reply other threads:[~2019-01-03 1:11 UTC|newest] Thread overview: 65+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-01-03 1:10 [PATCH 00/19] usbnet: smsc95xx: Convert to phydev Marek Vasut 2019-01-03 1:10 ` [PATCH 01/19] usbnet: smsc95xx: Fix memory leak in smsc95xx_bind Marek Vasut 2019-01-03 1:10 ` [01/19] " Marek Vasut 2019-01-03 1:10 ` [PATCH 02/19] usbnet: smsc95xx: Stop propagation of in_pm Marek Vasut 2019-01-03 1:10 ` [02/19] " Marek Vasut 2019-01-07 11:02 ` [PATCH 02/19] " Oliver Neukum 2019-01-07 11:02 ` [02/19] " Oliver Neukum 2019-01-07 11:50 ` [PATCH 02/19] " Marek Vasut 2019-01-07 11:50 ` [02/19] " Marek Vasut 2019-01-03 1:10 ` [PATCH 03/19] usbnet: smsc95xx: Remove smsc95xx_{read,write}_reg_nopm() Marek Vasut 2019-01-03 1:10 ` [03/19] " Marek Vasut 2019-01-03 1:10 ` [PATCH 04/19] usbnet: smsc95xx: Remove __smsc95xx_{read,write}_reg() Marek Vasut 2019-01-03 1:10 ` [04/19] " Marek Vasut 2019-01-03 1:10 ` [PATCH 05/19] usbnet: smsc95xx: Remove smsc95xx_{read,write}_nopm() Marek Vasut 2019-01-03 1:10 ` [05/19] " Marek Vasut 2019-01-03 1:10 ` [PATCH 06/19] usbnet: smsc95xx: Remove __smsc95xx_mdio_{read,write}() Marek Vasut 2019-01-03 1:10 ` [06/19] " Marek Vasut 2019-01-03 1:10 ` [PATCH 07/19] usbnet: smsc95xx: Split the reset function Marek Vasut 2019-01-03 1:10 ` [07/19] " Marek Vasut 2019-01-07 11:05 ` [PATCH 07/19] " Oliver Neukum 2019-01-07 11:05 ` [07/19] " Oliver Neukum 2019-01-03 1:10 ` [PATCH 08/19] usbnet: smsc95xx: Register MII bus Marek Vasut 2019-01-03 1:10 ` [08/19] " Marek Vasut 2019-01-03 1:10 ` Marek Vasut [this message] 2019-01-03 1:10 ` [09/19] usbnet: smsc95xx: Connect to phydev Marek Vasut 2019-01-03 13:22 ` [PATCH 09/19] " Andrew Lunn 2019-01-03 13:22 ` [09/19] " Andrew Lunn 2019-01-04 2:18 ` [PATCH 09/19] " Marek Vasut 2019-01-04 2:18 ` [09/19] " Marek Vasut 2019-01-03 1:10 ` [PATCH 10/19] usbnet: smsc95xx: Replace smsc95xx_mdio_read() with phy_read() Marek Vasut 2019-01-03 1:10 ` [10/19] " Marek Vasut 2019-01-03 13:39 ` [PATCH 10/19] " Andrew Lunn 2019-01-03 13:39 ` [10/19] " Andrew Lunn 2019-01-04 2:19 ` [PATCH 10/19] " Marek Vasut 2019-01-04 2:19 ` [10/19] " Marek Vasut 2019-01-04 13:24 ` [PATCH 10/19] " Andrew Lunn 2019-01-04 13:24 ` [10/19] " Andrew Lunn 2019-01-04 14:58 ` [PATCH 10/19] " Marek Vasut 2019-01-04 14:58 ` [10/19] " Marek Vasut 2019-01-04 15:57 ` [PATCH 10/19] " Andrew Lunn 2019-01-04 15:57 ` [10/19] " Andrew Lunn 2019-01-04 18:02 ` [PATCH 10/19] " Heiner Kallweit 2019-01-04 18:02 ` [10/19] " Heiner Kallweit 2019-01-03 1:10 ` [PATCH 11/19] usbnet: smsc95xx: Replace smsc95xx_mdio_write() with phy_write() Marek Vasut 2019-01-03 1:10 ` [11/19] " Marek Vasut 2019-01-03 1:10 ` [PATCH 12/19] usbnet: smsc95xx: Replace ad-hoc PHY functions with generic ones Marek Vasut 2019-01-03 1:10 ` [12/19] " Marek Vasut 2019-01-03 13:28 ` [PATCH 12/19] " Andrew Lunn 2019-01-03 13:28 ` [12/19] " Andrew Lunn 2019-01-04 2:19 ` [PATCH 12/19] " Marek Vasut 2019-01-04 2:19 ` [12/19] " Marek Vasut 2019-01-03 1:10 ` [PATCH 13/19] usbnet: smsc95xx: Replace smsc95xx_link_ok_nopm() Marek Vasut 2019-01-03 1:10 ` [13/19] " Marek Vasut 2019-01-03 1:10 ` [PATCH 14/19] usbnet: smsc95xx: Replace mii_nway_restart() Marek Vasut 2019-01-03 1:10 ` [14/19] " Marek Vasut 2019-01-03 1:10 ` [PATCH 15/19] usbnet: smsc95xx: Replace mii_ethtool_gset() Marek Vasut 2019-01-03 1:10 ` [15/19] " Marek Vasut 2019-01-03 1:10 ` [PATCH 16/19] usbnet: smsc95xx: Replace mii_check_media() Marek Vasut 2019-01-03 1:10 ` [16/19] " Marek Vasut 2019-01-03 1:10 ` [PATCH 17/19] usbnet: smsc95xx: Replace generic_mii_ioctl() Marek Vasut 2019-01-03 1:10 ` [17/19] " Marek Vasut 2019-01-03 1:10 ` [PATCH 18/19] usbnet: smsc95xx: Remove all of the carrier checking code Marek Vasut 2019-01-03 1:10 ` [18/19] " Marek Vasut 2019-01-03 1:10 ` [PATCH 19/19] usbnet: smsc95xx: Use phy bit operations Marek Vasut 2019-01-03 1:10 ` [19/19] " Marek Vasut
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20190103011040.25974-10-marex@denx.de \ --to=marex@denx.de \ --cc=Nisar.Sayed@microchip.com \ --cc=Woojung.Huh@microchip.com \ --cc=andrew@lunn.ch \ --cc=davem@davemloft.net \ --cc=f.fainelli@gmail.com \ --cc=linux-usb@vger.kernel.org \ --cc=netdev@vger.kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.