linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Subbaraya Sundeep <sbhatta@marvell.com>
To: Sean Anderson <sean.anderson@linux.dev>
Cc: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	<netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Michal Simek <michal.simek@amd.com>,
	<linux-arm-kernel@lists.infradead.org>,
	Leon Romanovsky <leon@kernel.org>
Subject: Re: [PATCH net-next v3 2/7] net: axienet: Use ioread32/iowrite32 directly
Date: Tue, 29 Jul 2025 04:28:35 +0000	[thread overview]
Message-ID: <aIhN85EwjsUaSHXk@opensource> (raw)
In-Reply-To: <20250728221823.11968-3-sean.anderson@linux.dev>

Hi,

On 2025-07-28 at 22:18:18, Sean Anderson (sean.anderson@linux.dev) wrote:
> In preparation for splitting the MDIO bus into a separate driver,
> convert all register reads/writes to use ioread32/iowrite32 directly
> instead of using the axienet_ior/iow helpers. While we're at it, clean
> up the register calculations a bit.
> 
> Signed-off-by: Sean Anderson <sean.anderson@linux.dev>
> ---
> 
> Changes in v3:
> - New
> 
>  .../net/ethernet/xilinx/xilinx_axienet_mdio.c | 43 +++++++++----------
>  1 file changed, 20 insertions(+), 23 deletions(-)
> 
> diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c b/drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c
> index 9ca2643c921e..16f3581390dd 100644
> --- a/drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c
> +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c
> @@ -32,7 +32,7 @@ static int axienet_mdio_wait_until_ready(struct axienet_local *lp)
>  {
>  	u32 val;
>  
> -	return readx_poll_timeout(axinet_ior_read_mcr, lp,
> +	return readx_poll_timeout(ioread32, lp->regs + XAE_MDIO_MCR_OFFSET,
>  				  val, val & XAE_MDIO_MCR_READY_MASK,
>  				  1, 20000);
>  }
> @@ -45,8 +45,8 @@ static int axienet_mdio_wait_until_ready(struct axienet_local *lp)
>   */
>  static void axienet_mdio_mdc_enable(struct axienet_local *lp)
>  {
> -	axienet_iow(lp, XAE_MDIO_MC_OFFSET,
> -		    ((u32)lp->mii_clk_div | XAE_MDIO_MC_MDIOEN_MASK));
> +	iowrite32((u32)lp->mii_clk_div | XAE_MDIO_MC_MDIOEN_MASK,
> +		  lp->regs + XAE_MDIO_MC_OFFSET);
>  }
>  
>  /**
> @@ -59,9 +59,9 @@ static void axienet_mdio_mdc_disable(struct axienet_local *lp)
>  {
>  	u32 mc_reg;
>  
> -	mc_reg = axienet_ior(lp, XAE_MDIO_MC_OFFSET);
> -	axienet_iow(lp, XAE_MDIO_MC_OFFSET,
> -		    (mc_reg & ~XAE_MDIO_MC_MDIOEN_MASK));
> +	mc_reg = ioread32(lp->regs + XAE_MDIO_MC_OFFSET);
> +	iowrite32(mc_reg & ~XAE_MDIO_MC_MDIOEN_MASK,
> +		  lp->regs + XAE_MDIO_MC_OFFSET);
>  }
>  
>  /**
> @@ -90,13 +90,11 @@ static int axienet_mdio_read(struct mii_bus *bus, int phy_id, int reg)
>  		return ret;
>  	}
>  
> -	axienet_iow(lp, XAE_MDIO_MCR_OFFSET,
> -		    (((phy_id << XAE_MDIO_MCR_PHYAD_SHIFT) &
> -		      XAE_MDIO_MCR_PHYAD_MASK) |
> -		     ((reg << XAE_MDIO_MCR_REGAD_SHIFT) &
> -		      XAE_MDIO_MCR_REGAD_MASK) |
> -		     XAE_MDIO_MCR_INITIATE_MASK |
> -		     XAE_MDIO_MCR_OP_READ_MASK));
> +	rc = FIELD_PREP(XAE_MDIO_MCR_PHYAD_MASK, phy_id) |
> +	     FIELD_PREP(XAE_MDIO_MCR_REGAD_MASK, reg) |
> +	     XAE_MDIO_MCR_INITIATE_MASK |
> +	     XAE_MDIO_MCR_OP_READ_MASK;
> +	iowrite32(rc, lp->regs + XAE_MDIO_MCR_OFFSET);
nit: remove XAE_MDIO_MCR_REGAD_SHIFT macros in header file too in this patch.

Thanks,
Sundeep
>  
>  	ret = axienet_mdio_wait_until_ready(lp);
>  	if (ret < 0) {
> @@ -104,7 +102,7 @@ static int axienet_mdio_read(struct mii_bus *bus, int phy_id, int reg)
>  		return ret;
>  	}
>  
> -	rc = axienet_ior(lp, XAE_MDIO_MRD_OFFSET) & 0x0000FFFF;
> +	rc = ioread32(lp->regs + XAE_MDIO_MRD_OFFSET) & 0x0000FFFF;
>  
>  	dev_dbg(lp->dev, "axienet_mdio_read(phy_id=%i, reg=%x) == %x\n",
>  		phy_id, reg, rc);
> @@ -129,8 +127,9 @@ static int axienet_mdio_read(struct mii_bus *bus, int phy_id, int reg)
>  static int axienet_mdio_write(struct mii_bus *bus, int phy_id, int reg,
>  			      u16 val)
>  {
> -	int ret;
>  	struct axienet_local *lp = bus->priv;
> +	int ret;
> +	u32 mcr;
>  
>  	dev_dbg(lp->dev, "axienet_mdio_write(phy_id=%i, reg=%x, val=%x)\n",
>  		phy_id, reg, val);
> @@ -143,14 +142,12 @@ static int axienet_mdio_write(struct mii_bus *bus, int phy_id, int reg,
>  		return ret;
>  	}
>  
> -	axienet_iow(lp, XAE_MDIO_MWD_OFFSET, (u32)val);
> -	axienet_iow(lp, XAE_MDIO_MCR_OFFSET,
> -		    (((phy_id << XAE_MDIO_MCR_PHYAD_SHIFT) &
> -		      XAE_MDIO_MCR_PHYAD_MASK) |
> -		     ((reg << XAE_MDIO_MCR_REGAD_SHIFT) &
> -		      XAE_MDIO_MCR_REGAD_MASK) |
> -		     XAE_MDIO_MCR_INITIATE_MASK |
> -		     XAE_MDIO_MCR_OP_WRITE_MASK));
> +	iowrite32(val, lp->regs + XAE_MDIO_MWD_OFFSET);
> +	mcr = FIELD_PREP(XAE_MDIO_MCR_PHYAD_MASK, phy_id) |
> +	      FIELD_PREP(XAE_MDIO_MCR_REGAD_MASK, reg) |
> +	      XAE_MDIO_MCR_INITIATE_MASK |
> +	      XAE_MDIO_MCR_OP_WRITE_MASK;
> +	iowrite32(mcr, lp->regs + XAE_MDIO_MCR_OFFSET);
>  
>  	ret = axienet_mdio_wait_until_ready(lp);
>  	if (ret < 0) {
> -- 
> 2.35.1.1320.gc452695387.dirty
> 


  reply	other threads:[~2025-07-29  4:31 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-28 22:18 [PATCH net-next v3 0/7] net: axienet: Fix deferred probe loop Sean Anderson
2025-07-28 22:18 ` [PATCH net-next v3 1/7] net: axienet: Fix resource release ordering Sean Anderson
2025-07-30  9:27   ` Gupta, Suraj
2025-07-28 22:18 ` [PATCH net-next v3 2/7] net: axienet: Use ioread32/iowrite32 directly Sean Anderson
2025-07-29  4:28   ` Subbaraya Sundeep [this message]
2025-07-28 22:18 ` [PATCH net-next v3 3/7] net: axienet: Use MDIO bus device in prints Sean Anderson
2025-07-29  9:07   ` kernel test robot
2025-07-28 22:18 ` [PATCH net-next v3 4/7] net: axienet: Simplify axienet_mdio_setup Sean Anderson
2025-07-28 22:18 ` [PATCH net-next v3 5/7] net: axienet: Use device variable in probe Sean Anderson
2025-07-28 22:18 ` [PATCH net-next v3 6/7] net: axienet: Rearrange lifetime functions Sean Anderson
2025-07-28 22:18 ` [PATCH net-next v3 7/7] net: axienet: Split into MAC and MDIO drivers Sean Anderson
2025-07-29  4:16   ` Subbaraya Sundeep

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=aIhN85EwjsUaSHXk@opensource \
    --to=sbhatta@marvell.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.simek@amd.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=radhey.shyam.pandey@amd.com \
    --cc=sean.anderson@linux.dev \
    /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).