All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Mohammad Athari Bin Ismail <mohammad.athari.ismail@intel.com>
Cc: Andrew Lunn <andrew@lunn.ch>,
	"David S . Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	Oleksij Rempel <linux@rempel-privat.de>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH net v2] net: phy: marvell: add Marvell specific PHY loopback
Date: Wed, 12 Jan 2022 13:12:53 +0000	[thread overview]
Message-ID: <Yd7T1e/R9jGWMK2B@shell.armlinux.org.uk> (raw)
In-Reply-To: <20220112093344.27894-1-mohammad.athari.ismail@intel.com>

On Wed, Jan 12, 2022 at 05:33:44PM +0800, Mohammad Athari Bin Ismail wrote:
> +static int marvell_loopback(struct phy_device *phydev, bool enable)
> +{
> +	if (enable) {
> +		u16 bmcr_ctl = 0, mscr2_ctl = 0;
> +
> +		if (phydev->speed == SPEED_1000)
> +			bmcr_ctl = BMCR_SPEED1000;
> +		else if (phydev->speed == SPEED_100)
> +			bmcr_ctl = BMCR_SPEED100;
> +
> +		if (phydev->duplex == DUPLEX_FULL)
> +			bmcr_ctl |= BMCR_FULLDPLX;
> +
> +		phy_modify(phydev, MII_BMCR, ~0, bmcr_ctl);

Is there any point in doing a read-modify-write here if you're just
setting all bits in the register? Wouldn't phy_write() be more
appropriate? What about error handing?

> +
> +		if (phydev->speed == SPEED_1000)
> +			mscr2_ctl = BMCR_SPEED1000;
> +		else if (phydev->speed == SPEED_100)
> +			mscr2_ctl = BMCR_SPEED100;
> +
> +		phy_modify_paged(phydev, MII_MARVELL_MSCR_PAGE,
> +				 MII_88E1510_MSCR_2, BMCR_SPEED1000 |
> +				 BMCR_SPEED100, mscr2_ctl);
> +
> +		/* Need soft reset to have speed configuration takes effect */
> +		genphy_soft_reset(phydev);
> +
> +		/* FIXME: Based on trial and error test, it seem 1G need to have
> +		 * delay between soft reset and loopback enablement.
> +		 */
> +		if (phydev->speed == SPEED_1000)
> +			msleep(1000);
> +
> +		return phy_modify(phydev, MII_BMCR, BMCR_LOOPBACK,
> +				  BMCR_LOOPBACK);
> +	} else {
> +		phy_modify(phydev, MII_BMCR, BMCR_LOOPBACK, 0);

Error handling?

Thanks.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

  reply	other threads:[~2022-01-12 13:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-12  9:33 [PATCH net v2] net: phy: marvell: add Marvell specific PHY loopback Mohammad Athari Bin Ismail
2022-01-12 13:12 ` Russell King (Oracle) [this message]
2022-01-12 22:55   ` Ismail, Mohammad Athari

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=Yd7T1e/R9jGWMK2B@shell.armlinux.org.uk \
    --to=linux@armlinux.org.uk \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rempel-privat.de \
    --cc=mohammad.athari.ismail@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=stable@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: link
Be 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.