public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Michal Simek <michal.simek@xilinx.com>
To: u-boot@lists.denx.de
Subject: [PATCH v3 3/5] net: phy: Add helper routines to set and clear bits
Date: Mon, 4 May 2020 11:46:06 +0200	[thread overview]
Message-ID: <4f6cd5da-e4ca-307e-6e71-bef441215d2b@xilinx.com> (raw)
In-Reply-To: <20200430163047.6898-4-dmurphy@ti.com>

On 30. 04. 20 18:30, Dan Murphy wrote:
> Add phy_set/clear_bit helper routines so that ported drivers from the
> kernel can use these functions.
> 
> Signed-off-by: Dan Murphy <dmurphy@ti.com>
> ---
>  include/phy.h | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 54 insertions(+)
> 
> diff --git a/include/phy.h b/include/phy.h
> index 34c2af719b67..fedd14609192 100644
> --- a/include/phy.h
> +++ b/include/phy.h
> @@ -296,6 +296,60 @@ static inline int phy_write_mmd(struct phy_device *phydev, int devad,
>  	return phy_write(phydev, MDIO_DEVAD_NONE, MII_MMD_DATA, val);
>  }
>  
> +/**
> + * phy_set_bits_mmd - Convenience function for setting bits in a register
> + * on MMD
> + * @phydev: the phy_device struct
> + * @devad: the MMD containing register to modify
> + * @regnum: register number to modify
> + * @val: bits to set
> + * @return: 0 for success or negative errno for failure
> + */
> +static inline int phy_set_bits_mmd(struct phy_device *phydev, int devad,
> +				   u32 regnum, u16 val)
> +{
> +	int value, ret;
> +
> +	value = phy_read_mmd(phydev, devad, regnum);
> +	if (value < 0)
> +		return value;
> +
> +	value |= val;
> +
> +	ret = phy_write_mmd(phydev, devad, regnum, value);
> +	if (ret < 0)
> +		return ret;
> +
> +	return 0;
> +}
> +
> +/**
> + * phy_clear_bits_mmd - Convenience function for clearing bits in a register
> + * on MMD
> + * @phydev: the phy_device struct
> + * @devad: the MMD containing register to modify
> + * @regnum: register number to modify
> + * @val: bits to clear
> + * @return: 0 for success or negative errno for failure
> + */
> +static inline int phy_clear_bits_mmd(struct phy_device *phydev, int devad,
> +				     u32 regnum, u16 val)
> +{
> +	int value, ret;
> +
> +	value = phy_read_mmd(phydev, devad, regnum);
> +	if (value < 0)
> +		return value;
> +
> +	value &= ~val;
> +
> +	ret = phy_write_mmd(phydev, devad, regnum, value);
> +	if (ret < 0)
> +		return ret;
> +
> +	return 0;
> +}
> +
>  #ifdef CONFIG_PHYLIB_10G
>  extern struct phy_driver gen10g_driver;
>  
> 

Acked-by: Michal Simek <michal.simek@xilinx.com>

Thanks,
Michal

  reply	other threads:[~2020-05-04  9:46 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-30 16:30 [PATCH v3 0/5] TI Ethernet PHY changes Dan Murphy
2020-04-30 16:30 ` [PATCH v3 1/5] net: phy: Add missing kernel doc to phy functions Dan Murphy
2020-05-04  9:45   ` Michal Simek
2020-04-30 16:30 ` [PATCH v3 2/5] net: phy: Fix kernel doc issues in phy.h Dan Murphy
2020-05-04  9:45   ` Michal Simek
2020-04-30 16:30 ` [PATCH v3 3/5] net: phy: Add helper routines to set and clear bits Dan Murphy
2020-05-04  9:46   ` Michal Simek [this message]
2020-04-30 16:30 ` [PATCH v3 4/5] net: phy: Add support for TI PHY init Dan Murphy
2020-05-04  9:46   ` Michal Simek
2020-05-04 16:59     ` Dan Murphy
2020-04-30 16:30 ` [PATCH v3 5/5] net: phy: Add DP8382x phy registration to " Dan Murphy

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=4f6cd5da-e4ca-307e-6e71-bef441215d2b@xilinx.com \
    --to=michal.simek@xilinx.com \
    --cc=u-boot@lists.denx.de \
    /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