linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: "Radu Pirea (NXP OSS)" <radu-nicolae.pirea@oss.nxp.com>
Cc: hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net,
	kuba@kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/2] phy: nxp-c45: add driver for tja1103
Date: Fri, 16 Apr 2021 00:56:26 +0200	[thread overview]
Message-ID: <YHjEmtWjhhH6412w@lunn.ch> (raw)
In-Reply-To: <20210415092538.78398-3-radu-nicolae.pirea@oss.nxp.com>

> +config NXP_C45_TJA11XX_PHY
> +	tristate "NXP C45 TJA11XX PHYs"
> +	help
> +	  Enable support for NXP C45 TJA11XX PHYs.
> +	  Currently supports only the TJA1103 PHY.

> +#define PHY_ID_BASE_T1			0x001BB010

It would be better to use PHY_ID_TJA_1103 here.

> +
> +#define PMAPMD_B100T1_PMAPMD_CTL		0x0834
> +#define B100T1_PMAPMD_CONFIG_EN		BIT(15)
> +#define B100T1_PMAPMD_MASTER		BIT(14)
> +#define MASTER_MODE			(B100T1_PMAPMD_CONFIG_EN | \
> +	B100T1_PMAPMD_MASTER)

You would normally align this with the B100T1_PMAPMD_CONFIG_EN

> +static int nxp_c45_reset_done(struct phy_device *phydev)
> +{
> +	return !(phy_read_mmd(phydev, MDIO_MMD_VEND1, VEND1_DEVICE_CONTROL) &
> +		DEVICE_CONTROL_RESET);
> +}
> +
> +static int nxp_c45_reset_done_or_timeout(struct phy_device *phydev,
> +					 ktime_t timeout)
> +{
> +	ktime_t cur = ktime_get();
> +
> +	return nxp_c45_reset_done(phydev) || ktime_after(cur, timeout);
> +}
> +
> +static int nxp_c45_soft_reset(struct phy_device *phydev)
> +{
> +	ktime_t timeout;
> +	int ret;
> +
> +	ret = phy_write_mmd(phydev, MDIO_MMD_VEND1, VEND1_DEVICE_CONTROL,
> +			    DEVICE_CONTROL_RESET);
> +	if (ret)
> +		return ret;
> +
> +	timeout = ktime_add_ns(ktime_get(), RESET_POLL_NS);
> +	spin_until_cond(nxp_c45_reset_done_or_timeout(phydev, timeout));

phy_read_mmd_poll_timeout() i think does what you need.

> +	if (!nxp_c45_reset_done(phydev)) {
> +		phydev_err(phydev, "reset fail\n");
> +		return -EIO;
> +	}
> +	return 0;
> +}

> +static struct phy_driver nxp_c45_driver[] = {
> +	{
> +		PHY_ID_MATCH_MODEL(PHY_ID_BASE_T1),
> +		.name			= "NXP C45 BASE-T1",

"NXP C45 TJA1103"

     Andrew

      reply	other threads:[~2021-04-15 22:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-15  9:25 [PATCH v2 0/2] TJA1103 driver Radu Pirea (NXP OSS)
2021-04-15  9:25 ` [PATCH v2 1/2] net: phy: add genphy_c45_pma_suspend/resume Radu Pirea (NXP OSS)
2021-04-15 22:57   ` Andrew Lunn
2021-04-15  9:25 ` [PATCH v2 2/2] phy: nxp-c45: add driver for tja1103 Radu Pirea (NXP OSS)
2021-04-15 22:56   ` Andrew Lunn [this message]

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=YHjEmtWjhhH6412w@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --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=radu-nicolae.pirea@oss.nxp.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).