netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Piergiorgio Beruto <piergiorgio.beruto@gmail.com>
Cc: Heiner Kallweit <hkallweit1@gmail.com>,
	Russell King <linux@armlinux.org.uk>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	Oleksij Rempel <o.rempel@pengutronix.de>
Subject: Re: [PATCH v4 net-next 4/5] drivers/net/phy: add helpers to get/set PLCA configuration
Date: Tue, 6 Dec 2022 14:59:39 +0100	[thread overview]
Message-ID: <Y49Ky7aCUZxE5Fwg@lunn.ch> (raw)
In-Reply-To: <4c6bb420c2169edb31abd5c4d5fe04090ed329e4.1670329232.git.piergiorgio.beruto@gmail.com>

> +/* MDIO Manageable Devices (MMDs). */
> +#define MDIO_MMD_OATC14		MDIO_MMD_VEND2

As i said in a comment somewhere, i would prefer you use
MDIO_MMD_VEND2, not MDIO_MMD_OATC14. We want the gentle reminder that
these registers can contain anything the vendor wants, including, but
not limited to, PLCA.

> +/* Open Alliance TC14 PLCA CTRL0 register */
> +#define MDIO_OATC14_PLCA_EN	0x8000  /* PLCA enable */
> +#define MDIO_OATC14_PLCA_RST	0x4000  /* PLCA reset */

These are bits, so use the BIT macro. When this was part of mii.h,
that file used this hex format so it made sense to follow that
format. Now you are in a few file, you should use the macro.

> +/* Open Alliance TC14 PLCA CTRL1 register */
> +#define MDIO_OATC14_PLCA_NCNT	0xff00	/* PLCA node count */
> +#define MDIO_OATC14_PLCA_ID	0x00ff	/* PLCA local node ID */
> +
> +/* Open Alliance TC14 PLCA STATUS register */
> +#define MDIO_OATC14_PLCA_PST	0x8000	/* PLCA status indication */
> +
> +/* Open Alliance TC14 PLCA TOTMR register */
> +#define MDIO_OATC14_PLCA_TOT	0x00ff
> +
> +/* Open Alliance TC14 PLCA BURST register */
> +#define MDIO_OATC14_PLCA_MAXBC	0xff00
> +#define MDIO_OATC14_PLCA_BTMR	0x00ff
> +
> +#endif /* __MDIO_OPEN_ALLIANCE__ */
> diff --git a/drivers/net/phy/phy-c45.c b/drivers/net/phy/phy-c45.c
> index a87a4b3ffce4..dace5d3b29ad 100644
> --- a/drivers/net/phy/phy-c45.c
> +++ b/drivers/net/phy/phy-c45.c
> @@ -8,6 +8,8 @@
>  #include <linux/mii.h>
>  #include <linux/phy.h>
>  
> +#include "mdio-open-alliance.h"
> +
>  /**
>   * genphy_c45_baset1_able - checks if the PMA has BASE-T1 extended abilities
>   * @phydev: target phy_device struct
> @@ -931,6 +933,184 @@ int genphy_c45_fast_retrain(struct phy_device *phydev, bool enable)
>  }
>  EXPORT_SYMBOL_GPL(genphy_c45_fast_retrain);
>  
> +/**
> + * genphy_c45_plca_get_cfg - get PLCA configuration from standard registers
> + * @phydev: target phy_device struct
> + * @plca_cfg: output structure to store the PLCA configuration
> + *
> + * Description: if the PHY complies to the Open Alliance TC14 10BASE-T1S PLCA
> + *   Management Registers specifications, this function can be used to retrieve
> + *   the current PLCA configuration from the standard registers in MMD 31.
> + */
> +int genphy_c45_plca_get_cfg(struct phy_device *phydev,
> +			    struct phy_plca_cfg *plca_cfg)
> +{
> +	int ret;
> +
> +	ret = phy_read_mmd(phydev, MDIO_MMD_OATC14, MDIO_OATC14_PLCA_IDVER);
> +	if (ret < 0)
> +		return ret;
> +
> +	plca_cfg->version = ret;

It would be good to verify this value, and return -ENODEV if it is not
valid.

	Andrew

  reply	other threads:[~2022-12-06 13:59 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-06 12:52 [PATCH v4 net-next 0/5] add PLCA RS support and onsemi NCN26000 Piergiorgio Beruto
2022-12-06 12:52 ` [PATCH v4 net-next 1/5] net/ethtool: add netlink interface for the PLCA RS Piergiorgio Beruto
2022-12-06 12:52 ` [PATCH v4 net-next 2/5] drivers/net/phy: add the link modes for the 10BASE-T1S Ethernet PHY Piergiorgio Beruto
2022-12-06 12:53 ` [PATCH v4 net-next 3/5] drivers/net/phy: add connection between ethtool and phylib for PLCA Piergiorgio Beruto
2022-12-06 12:53 ` [PATCH v4 net-next 4/5] drivers/net/phy: add helpers to get/set PLCA configuration Piergiorgio Beruto
2022-12-06 13:59   ` Andrew Lunn [this message]
2022-12-06 18:07     ` Piergiorgio Beruto
2022-12-06 12:54 ` [PATCH v4 net-next 5/5] drivers/net/phy: add driver for the onsemi NCN26000 10BASE-T1S PHY Piergiorgio Beruto
2022-12-06 13:47   ` Andrew Lunn
2022-12-06 14:35     ` Piergiorgio Beruto
2022-12-06 14:57       ` Russell King (Oracle)
2022-12-06 18:06         ` Piergiorgio Beruto
2022-12-06 16:50       ` Andrew Lunn
2022-12-06 18:10         ` Piergiorgio Beruto
2022-12-06 19:12           ` Andrew Lunn
2022-12-07  0:33             ` Piergiorgio Beruto
2022-12-07 13:44               ` Andrew Lunn
2023-01-09 16:59 [PATCH v4 net-next 0/5] add PLCA RS support and onsemi NCN26000 Piergiorgio Beruto
2023-01-09 17:00 ` [PATCH v4 net-next 4/5] drivers/net/phy: add helpers to get/set PLCA configuration Piergiorgio Beruto

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=Y49Ky7aCUZxE5Fwg@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=o.rempel@pengutronix.de \
    --cc=pabeni@redhat.com \
    --cc=piergiorgio.beruto@gmail.com \
    /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).