mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <sha@pengutronix.de>
To: yegorslists@googlemail.com
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] net: phy: add driver for MotorComm PHY
Date: Thu, 1 Jun 2023 10:17:16 +0200	[thread overview]
Message-ID: <20230601081716.GK18491@pengutronix.de> (raw)
In-Reply-To: <20230531143500.165837-1-yegorslists@googlemail.com>

Hi Yegor,

On Wed, May 31, 2023 at 04:35:00PM +0200, yegorslists@googlemail.com wrote:
> From: Yegor Yefremov <yegorslists@googlemail.com>
> 

Could you add a word here on which kernel version this is based on? It
will help synchronizing with newer kernels later.

> Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
> ---
>  drivers/net/phy/Kconfig     |   5 ++
>  drivers/net/phy/Makefile    |   1 +
>  drivers/net/phy/motorcomm.c | 128 ++++++++++++++++++++++++++++++++++++
>  3 files changed, 134 insertions(+)
>  create mode 100644 drivers/net/phy/motorcomm.c
> 

[...]

> +static int yt8511_config_init(struct phy_device *phydev)
> +{
> +	int oldpage, ret = 0;
> +	unsigned int ge, fe;
> +
> +	oldpage = phy_select_page(phydev, YT8511_EXT_CLK_GATE);
> +	if (oldpage < 0)
> +		goto err_restore_page;
> +
> +	/* set rgmii delay mode */
> +	switch (phydev->interface) {
> +	case PHY_INTERFACE_MODE_RGMII:
> +		ge = YT8511_DELAY_GE_TX_DIS;
> +		fe = YT8511_DELAY_FE_TX_DIS;
> +		break;
> +	case PHY_INTERFACE_MODE_RGMII_RXID:
> +		ge = YT8511_DELAY_RX | YT8511_DELAY_GE_TX_DIS;
> +		fe = YT8511_DELAY_FE_TX_DIS;
> +		break;
> +	case PHY_INTERFACE_MODE_RGMII_TXID:
> +		ge = YT8511_DELAY_GE_TX_EN;
> +		fe = YT8511_DELAY_FE_TX_EN;
> +		break;
> +	case PHY_INTERFACE_MODE_RGMII_ID:
> +		ge = YT8511_DELAY_RX | YT8511_DELAY_GE_TX_EN;
> +		fe = YT8511_DELAY_FE_TX_EN;
> +		break;
> +	default: /* do not support other modes */
> +		ret = -EOPNOTSUPP;
> +		goto err_restore_page;
> +	}
> +
> +	ret = phy_modify(phydev, YT8511_PAGE, (YT8511_DELAY_RX | YT8511_DELAY_GE_TX_EN), ge);
> +	if (ret < 0)
> +		goto err_restore_page;
> +
> +	/* set clock mode to 125mhz */
> +	ret = phy_modify(phydev, YT8511_PAGE, 0, YT8511_CLK_125M);
> +	if (ret < 0)
> +		goto err_restore_page;
> +
> +	/* fast ethernet delay is in a separate page */
> +	ret = phy_write(phydev, YT8511_PAGE_SELECT, YT8511_EXT_DELAY_DRIVE);
> +	if (ret < 0)
> +		goto err_restore_page;
> +
> +	ret = phy_modify(phydev, YT8511_PAGE, YT8511_DELAY_FE_TX_EN, fe);
> +	if (ret < 0)
> +		goto err_restore_page;
> +
> +	/* leave pll enabled in sleep */
> +	ret = phy_write(phydev, YT8511_PAGE_SELECT, YT8511_EXT_SLEEP_CTRL);
> +	if (ret < 0)
> +		goto err_restore_page;
> +
> +	ret = phy_modify(phydev, YT8511_PAGE, 0, YT8511_PLLON_SLP);
> +	if (ret < 0)
> +		goto err_restore_page;
> +
> +err_restore_page:
> +	return phy_restore_page(phydev, oldpage, ret);

This should likely return 'ret' and not the return value of
phy_restore_page().

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



  reply	other threads:[~2023-06-01  8:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-31 14:35 yegorslists
2023-06-01  8:17 ` Sascha Hauer [this message]
2023-06-01  8:51   ` Yegor Yefremov

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=20230601081716.GK18491@pengutronix.de \
    --to=sha@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=yegorslists@googlemail.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