public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn•ch>
To: Jose Abreu <Jose.Abreu@synopsys•com>
Cc: netdev@vger•kernel.org, "David S. Miller" <davem@davemloft•net>,
	Joao Pinto <Joao.Pinto@synopsys•com>,
	Giuseppe Cavallaro <peppe.cavallaro@st•com>,
	Alexandre Torgue <alexandre.torgue@st•com>
Subject: Re: [PATCH net-next 5/9] net: stmmac: Add MDIO related functions for XGMAC2
Date: Thu, 2 Aug 2018 16:11:28 +0200	[thread overview]
Message-ID: <20180802141128.GC7462@lunn.ch> (raw)
In-Reply-To: <7b0f8758-1a77-5c30-ec2c-ee0a35f66950@synopsys.com>

On Thu, Aug 02, 2018 at 09:36:41AM +0100, Jose Abreu wrote:
> Hi Andrew,
> 
> On 01-08-2018 16:08, Andrew Lunn wrote:
> > Hi Jose
> >
> >> +static int stmmac_xgmac2_mdio_read(struct stmmac_priv *priv, int phyaddr,
> >> +				   int phyreg)
> >> +{
> >> +	unsigned int mii_address = priv->hw->mii.addr;
> >> +	unsigned int mii_data = priv->hw->mii.data;
> >> +	u32 tmp, addr, value = MII_XGMAC_BUSY;
> >> +	int data;
> >> +
> >> +	if (phyreg & MII_ADDR_C45) {
> >> +		addr = ((phyreg >> 16) & 0x1f) << 21;
> >> +		addr |= (phyaddr << 16) | (phyreg & 0xffff);
> > Do you need to tell the hardware this is a C45 transfer? Normally an
> > extra bit needs setting somewhere.
> 
> The organization of addr reg is the following:
>     DA [25:21] | PA [20:16] | RA [15:0]
> 
> DA is Device Address, PA is Port Address and RA is Register Address.

Hi Jose

Please read my question. That is not what i asked.

> >
> >> +	} else {
> >> +		if (phyaddr >= 4)
> >> +			return -ENODEV;
> > Can the MDIO bus be external? If so, is there a reason why there
> > cannot be a PHY at addresses > 4. So maybe there is an Ethernet
> > switch, which needs lots of addresses? And C45 can have devices > 4
> > but C22 cannot?
> 
> Only ports 0 to 3 can be configured as C22 ports, according to
> databook.

Please add a comment about this. And EOPNOTSUP might be a better error
code.
 
> >> +	value |= MII_XGMAC_READ;
> >> +
> >> +	if (readl_poll_timeout(priv->ioaddr + mii_data, tmp,
> >> +			       !(tmp & MII_XGMAC_BUSY), 100, 10000))
> >> +		return -EBUSY;
> >> +
> >> +	writel(addr, priv->ioaddr + mii_address);
> >> +	writel(value, priv->ioaddr + mii_data);
> >> +
> >> +	if (readl_poll_timeout(priv->ioaddr + mii_data, tmp,
> >> +			       !(tmp & MII_XGMAC_BUSY), 100, 10000))
> >> +		return -EBUSY;
> >> +
> >> +	/* Read the data from the MII data register */
> >> +	data = (int)readl(priv->ioaddr + mii_data) & GENMASK(15, 0);
> > Is the cast needed? And why use GENMASK here, but not in all the other
> > places you have masks in this code?
> 
> The GENMASK is needed, notice how we set more values into
> mii_data (clk_csr, bit(18), cmd), this is not cleared by XGMAC2
> upon the completion of the operation ...

Again, please read my question. That is not what i asked.

Has C45 been tested? Does the 1G PHY you have support C45 transfers?

       Andrew

  reply	other threads:[~2018-08-02 16:02 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-01 12:10 [PATCH net-next 0/9] Add 10GbE support in stmmac using XGMAC2 Jose Abreu
2018-08-01 12:10 ` [PATCH net-next 1/9] net: stmmac: Add XGMAC 2.10 HWIF entry Jose Abreu
2018-08-01 12:10 ` [PATCH net-next 2/9] net: stmmac: Add MAC related callbacks for XGMAC2 Jose Abreu
2018-08-01 12:10 ` [PATCH net-next 3/9] net: stmmac: Add DMA " Jose Abreu
2018-08-01 12:10 ` [PATCH net-next 4/9] net: stmmac: Add descriptor " Jose Abreu
2018-08-01 12:10 ` [PATCH net-next 5/9] net: stmmac: Add MDIO related functions " Jose Abreu
2018-08-01 15:08   ` Andrew Lunn
2018-08-02  8:36     ` Jose Abreu
2018-08-02 14:11       ` Andrew Lunn [this message]
2018-08-01 12:10 ` [PATCH net-next 6/9] net: stmmac: Add PTP support " Jose Abreu
2018-08-01 12:10 ` [PATCH net-next 7/9] net: stmmac: Integrate XGMAC into main driver flow Jose Abreu
2018-08-01 15:23   ` Andrew Lunn
2018-08-02  8:26     ` Jose Abreu
2018-08-02 14:03       ` Andrew Lunn
2018-08-02 14:15         ` Jose Abreu
2018-08-02 14:36           ` Andrew Lunn
2018-08-02 15:38             ` Jose Abreu
2018-08-02 16:00               ` Andrew Lunn
2018-08-01 12:10 ` [PATCH net-next 8/9] net: stmmac: Add the bindings parsing for XGMAC2 Jose Abreu
2018-08-01 12:10 ` [PATCH net-next 9/9] bindings: net: stmmac: Add the bindings documentation " Jose Abreu
2018-08-01 14:57   ` Sergei Shtylyov

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=20180802141128.GC7462@lunn.ch \
    --to=andrew@lunn$(echo .)ch \
    --cc=Joao.Pinto@synopsys$(echo .)com \
    --cc=Jose.Abreu@synopsys$(echo .)com \
    --cc=alexandre.torgue@st$(echo .)com \
    --cc=davem@davemloft$(echo .)net \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=peppe.cavallaro@st$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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