netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Russell King - ARM Linux admin <linux@armlinux.org.uk>
To: Andrew Lunn <andrew@lunn.ch>, Heiner Kallweit <hkallweit1@gmail.com>
Cc: Jeremy Linton <jeremy.linton@arm.com>,
	Florian Fainelli <f.fainelli@gmail.com>,
	netdev@vger.kernel.org
Subject: Re: [PATCH RFC 4/7] net: phy: add support for probing MMDs >= 8 for devices-in-package
Date: Tue, 26 May 2020 18:14:54 +0100	[thread overview]
Message-ID: <20200526171454.GH1551@shell.armlinux.org.uk> (raw)
In-Reply-To: <E1jdabs-0005sW-P8@rmk-PC.armlinux.org.uk>

On Tue, May 26, 2020 at 03:31:16PM +0100, Russell King wrote:
> Add support for probing MMDs above 7 for a valid devices-in-package
> specifier.
> 
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
> ---
>  drivers/net/phy/phy_device.c | 39 ++++++++++++++++++++++++++++++++++--
>  include/linux/phy.h          |  2 ++
>  2 files changed, 39 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
> index 0d6b6ca66216..fa9164ac0f3d 100644
> --- a/drivers/net/phy/phy_device.c
> +++ b/drivers/net/phy/phy_device.c
> @@ -659,6 +659,28 @@ struct phy_device *phy_device_create(struct mii_bus *bus, int addr, u32 phy_id,
>  }
>  EXPORT_SYMBOL(phy_device_create);
>  
> +/* phy_c45_probe_present - checks to see if a MMD is present in the package
> + * @bus: the target MII bus
> + * @prtad: PHY package address on the MII bus
> + * @devad: PHY device (MMD) address
> + *
> + * Read the MDIO_STAT2 register, and check whether a device is responding
> + * at this address.
> + *
> + * Returns: negative error number on bus access error, zero if no device
> + * is responding, or positive if a device is present.
> + */
> +static int phy_c45_probe_present(struct mii_bus *bus, int prtad, int devad)
> +{
> +	int stat2;
> +
> +	stat2 = mdiobus_c45_read(bus, prtad, devad, MDIO_STAT2);
> +	if (stat2 < 0)
> +		return stat2;
> +
> +	return (stat2 & MDIO_STAT2_DEVPRST) == MDIO_STAT2_DEVPRST_VAL;
> +}
> +
>  /* get_phy_c45_devs_in_pkg - reads a MMD's devices in package registers.
>   * @bus: the target MII bus
>   * @addr: PHY address on the MII bus
> @@ -709,12 +731,25 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr, u32 *phy_id,
>  {
>  	const int num_ids = ARRAY_SIZE(c45_ids->device_ids);
>  	u32 *devs = &c45_ids->devices_in_package;
> -	int i, phy_reg;
> +	int i, ret, phy_reg;
>  
>  	/* Find first non-zero Devices In package. Device zero is reserved
>  	 * for 802.3 c45 complied PHYs, so don't probe it at first.
>  	 */
> -	for (i = 1; i < num_ids && *devs == 0; i++) {
> +	for (i = 1; i < MDIO_MMD_NUM && *devs == 0; i++) {
> +		if (i >= 8) {
> +			/* Only probe for the devices-in-package if there
> +			 * is a PHY reporting as present here; this avoids
> +			 * picking up on PHYs that implement non-IEEE802.3
> +			 * compliant register spaces.
> +			 */
> +			ret = phy_c45_probe_present(bus, addr, i);
> +			if (ret < 0)
> +				return -EIO;
> +
> +			if (!ret)
> +				continue;
> +		}

A second look at 802.3, this can't be done for all MMDs (which becomes
visible when I look at the results from the 88x3310.)  Only MMDs 1, 2,
3, 4, 5, 30 and 31 are defined to have this register with the "Device
Present" bit pair.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTC for 0.8m (est. 1762m) line in suburbia: sync at 13.1Mbps down 424kbps up

  reply	other threads:[~2020-05-26 17:15 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-26 14:29 [PATCH RFC 0/7] Clause 45 PHY probing cleanups Russell King - ARM Linux admin
2020-05-26 14:31 ` [PATCH RFC 1/7] net: mdiobus: add clause 45 mdiobus accessors Russell King
2020-05-26 14:39   ` Andrew Lunn
2020-05-26 15:21     ` Russell King - ARM Linux admin
2020-05-26 14:31 ` [PATCH RFC 2/7] net: phy: clean up cortina workaround Russell King
2020-05-26 14:31 ` [PATCH RFC 3/7] net: phy: clean up PHY ID reading Russell King
2020-05-26 15:38   ` Jeremy Linton
2020-05-26 15:46     ` Russell King - ARM Linux admin
2020-05-26 14:31 ` [PATCH RFC 4/7] net: phy: add support for probing MMDs >= 8 for devices-in-package Russell King
2020-05-26 17:14   ` Russell King - ARM Linux admin [this message]
2020-05-26 17:20     ` Jeremy Linton
2020-05-26 17:53       ` Russell King - ARM Linux admin
2020-05-26 14:31 ` [PATCH RFC 5/7] net: phy: set devices_in_package only after validation Russell King
2020-05-26 15:39   ` Jeremy Linton
2020-05-26 15:50     ` Russell King - ARM Linux admin
2020-05-26 16:33       ` Russell King - ARM Linux admin
2020-05-26 14:31 ` [PATCH RFC 6/7] net: phy: split devices_in_package Russell King
2020-05-26 15:39   ` Jeremy Linton
2020-05-26 15:47     ` Russell King - ARM Linux admin
2020-05-26 16:00       ` Russell King - ARM Linux admin
2020-05-26 14:31 ` [PATCH RFC 7/7] net: phy: read MMD ID from all present MMDs Russell King
2020-05-26 15:35   ` Jeremy Linton
2020-05-26 15:46     ` Russell King - ARM Linux admin
2020-05-26 15:43 ` [PATCH RFC 0/7] Clause 45 PHY probing cleanups Russell King - ARM Linux admin

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=20200526171454.GH1551@shell.armlinux.org.uk \
    --to=linux@armlinux.org.uk \
    --cc=andrew@lunn.ch \
    --cc=f.fainelli@gmail.com \
    --cc=hkallweit1@gmail.com \
    --cc=jeremy.linton@arm.com \
    --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: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).