From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Lunn Subject: Re: [PATCH net-next] lan78xx: Lan7801 Support for Fixed PHY Date: Mon, 23 Apr 2018 14:42:03 +0200 Message-ID: <20180423124203.GC25919@lunn.ch> References: <20180423044630.2672-1-raghuramchary.jallipalli@microchip.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: davem@davemloft.net, netdev@vger.kernel.org, unglinuxdriver@microchip.com, woojung.huh@microchip.com To: Raghuram Chary J Return-path: Received: from vps0.lunn.ch ([185.16.172.187]:37021 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755126AbeDWMmH (ORCPT ); Mon, 23 Apr 2018 08:42:07 -0400 Content-Disposition: inline In-Reply-To: <20180423044630.2672-1-raghuramchary.jallipalli@microchip.com> Sender: netdev-owner@vger.kernel.org List-ID: > #define DRIVER_AUTHOR "WOOJUNG HUH " > #define DRIVER_DESC "LAN78XX USB 3.0 Gigabit Ethernet Devices" > #define DRIVER_NAME "lan78xx" > -#define DRIVER_VERSION "1.0.6" > +#define DRIVER_VERSION "1.0.7" Hi Raghuram Driver version strings a pretty pointless. You might want to remove it. > > #define TX_TIMEOUT_JIFFIES (5 * HZ) > #define THROTTLE_JIFFIES (HZ / 8) > @@ -426,6 +426,7 @@ struct lan78xx_net { > struct statstage stats; > > struct irq_domain_data domain_data; > + struct phy_device *fixedphy; > }; > > /* define external phy id */ > @@ -2062,11 +2063,39 @@ static int lan78xx_phy_init(struct lan78xx_net *dev) > int ret; > u32 mii_adv; > struct phy_device *phydev; > + struct fixed_phy_status fphy_status = { > + .link = 1, > + .speed = SPEED_1000, > + .duplex = DUPLEX_FULL, > + }; > > phydev = phy_find_first(dev->mdiobus); > if (!phydev) { > - netdev_err(dev->net, "no PHY found\n"); > - return -EIO; > + if (dev->chipid == ID_REV_CHIP_ID_7801_) { > + u32 buf; > + > + netdev_info(dev->net, "PHY Not Found!! Registering Fixed PHY\n"); > + phydev = fixed_phy_register(PHY_POLL, &fphy_status, -1, > + NULL); > + if (IS_ERR(phydev)) { > + netdev_err(dev->net, "No PHY/fixed_PHY found\n"); > + return -ENODEV; > + } > + netdev_info(dev->net, "Registered FIXED PHY\n"); There are too many detdev_info() messages here. Maybe make them both netdev_dbg(). > + dev->interface = PHY_INTERFACE_MODE_RGMII; > + dev->fixedphy = phydev; You can use if (!phy_is_pseudo_fixed_link(phydev)) to determine is a PHY is a fixed phy. I think you can then do without dev->fixedphy. > + ret = lan78xx_write_reg(dev, MAC_RGMII_ID, > + MAC_RGMII_ID_TXC_DELAY_EN_); > + ret = lan78xx_write_reg(dev, RGMII_TX_BYP_DLL, 0x3D00); > + ret = lan78xx_read_reg(dev, HW_CFG, &buf); > + buf |= HW_CFG_CLK125_EN_; > + buf |= HW_CFG_REFCLK25_EN_; > + ret = lan78xx_write_reg(dev, HW_CFG, buf); > + goto phyinit; Please don't use a goto like this. Maybe turn this into a switch statement? > + } else { > + netdev_err(dev->net, "no PHY found\n"); > + return -EIO; > + } > } > > if ((dev->chipid == ID_REV_CHIP_ID_7800_) || > @@ -2105,6 +2134,7 @@ static int lan78xx_phy_init(struct lan78xx_net *dev) > goto error; Please take a look at what happens at error: It does not look correct. Probably now is a good time to refactor the whole of lan78xx_phy_init() Andrew