From: Alexandre Belloni <alexandre.belloni@bootlin.com>
To: Andrew Lunn <andrew@lunn.ch>
Cc: "David S . Miller" <davem@davemloft.net>,
Allan Nielsen <Allan.Nielsen@microsemi.com>,
razvan.stefanescu@nxp.com, po.liu@nxp.com,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
Florian Fainelli <f.fainelli@gmail.com>,
netdev@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-mips@linux-mips.org
Subject: Re: [PATCH net-next 3/8] net: mscc: Add MDIO driver
Date: Thu, 29 Mar 2018 16:05:44 +0200 [thread overview]
Message-ID: <20180329140544.GB12066@piout.net> (raw)
In-Reply-To: <20180323204939.GS24361@lunn.ch>
On 23/03/2018 at 21:49:39 +0100, Andrew Lunn wrote:
> On Fri, Mar 23, 2018 at 09:11:12PM +0100, Alexandre Belloni wrote:
> > Add a driver for the Microsemi MII Management controller (MIIM) found on
> > Microsemi SoCs.
> > On Ocelot, there are two controllers, one is connected to the internal
> > PHYs, the other one can communicate with external PHYs.
>
> Hi Alexandre
>
> This looks to be standalone. Such drivers we try to put in
> drivers/net/phy.
>
> > +static int mscc_miim_read(struct mii_bus *bus, int mii_id, int regnum)
> > +{
> > + struct mscc_miim_dev *miim = bus->priv;
> > + u32 val;
> > + int ret;
> > +
> > + mutex_lock(&miim->lock);
>
> What are you locking against here?
>
> And you don't appear to initialize the mutex anywhere.
>
> > +static int mscc_miim_reset(struct mii_bus *bus)
> > +{
> > + struct mscc_miim_dev *miim = bus->priv;
> > + int i;
> > +
> > + if (miim->phy_regs) {
> > + writel(0, miim->phy_regs + MSCC_PHY_REG_PHY_CFG);
> > + writel(0x1ff, miim->phy_regs + MSCC_PHY_REG_PHY_CFG);
> > + mdelay(500);
> > + }
> > +
> > + for (i = 0; i < PHY_MAX_ADDR; i++) {
> > + if (mscc_miim_read(bus, i, MII_PHYSID1) < 0)
> > + bus->phy_mask |= BIT(i);
> > + }
>
> Why do this? Especially so for the external bus, where the PHYs might
> have a GPIO reset line, and won't respond until the gpio is
> released. The core code does that just before it scans the bus, or
> just before it scans the particular address on the bus, depending on
> the scope of the GPIO.
>
IIRC, this was needed when probing the bus without DT, in that case, the
mdiobus_scan loop of __mdiobus_register() will fail when doing the
get_phy_id for phys 0 to 31 because get_phy_id() transforms any error in
-EIO and so it is impossible to register the bus. Other drivers have a
similar code to handle that case.
Anyway, I'll remove that loop for now because I'm only supporting DT.
I'll get back to that later.
--
Alexandre Belloni, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
next prev parent reply other threads:[~2018-03-29 14:05 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-23 20:11 [PATCH net-next 0/8] Microsemi Ocelot switch support Alexandre Belloni
2018-03-23 20:11 ` [PATCH net-next 1/8] net: phy: Add initial support for Microsemi Ocelot internal PHYs Alexandre Belloni
2018-03-23 20:29 ` Andrew Lunn
2018-03-23 21:08 ` Florian Fainelli
2018-03-28 16:18 ` Alexandre Belloni
2018-03-23 20:11 ` [PATCH net-next 2/8] dt-bindings: net: add DT bindings for Microsemi MIIM Alexandre Belloni
2018-03-23 21:46 ` Florian Fainelli
2018-03-23 20:11 ` [PATCH net-next 3/8] net: mscc: Add MDIO driver Alexandre Belloni
2018-03-23 20:49 ` Andrew Lunn
2018-03-29 14:05 ` Alexandre Belloni [this message]
2018-03-29 14:40 ` Andrew Lunn
2018-03-29 14:53 ` Alexandre Belloni
2018-03-29 14:57 ` Andrew Lunn
2018-03-23 21:51 ` Florian Fainelli
2018-03-29 14:14 ` Alexandre Belloni
2018-03-23 20:11 ` [PATCH net-next 4/8] dt-bindings: net: add DT bindings for Microsemi Ocelot Switch Alexandre Belloni
2018-03-23 21:01 ` Andrew Lunn
2018-03-23 21:11 ` Florian Fainelli
2018-03-26 22:25 ` Rob Herring
2018-03-26 22:50 ` Andrew Lunn
2018-03-27 0:34 ` Rob Herring
2018-03-26 22:25 ` Rob Herring
2018-03-23 20:11 ` [PATCH net-next 5/8] net: mscc: Add initial Ocelot switch support Alexandre Belloni
2018-03-23 21:25 ` Andrew Lunn
2018-03-23 21:41 ` Florian Fainelli
2018-03-30 12:45 ` Alexandre Belloni
2018-03-30 13:54 ` Andrew Lunn
2018-03-30 14:16 ` Alexandre Belloni
2018-03-30 14:50 ` Andrew Lunn
2018-03-31 22:47 ` Florian Fainelli
2018-04-24 18:52 ` Alexandre Belloni
2018-03-26 19:13 ` kbuild test robot
2018-03-30 7:02 ` Razvan Stefanescu
2018-03-23 20:11 ` [PATCH net-next 6/8] MIPS: mscc: Add switch to ocelot Alexandre Belloni
2018-03-23 21:17 ` Florian Fainelli
2018-03-23 21:22 ` Alexandre Belloni
2018-03-23 21:33 ` Andrew Lunn
2018-03-23 21:44 ` Florian Fainelli
2018-03-23 22:06 ` Andrew Lunn
2018-03-23 22:11 ` Florian Fainelli
2018-03-24 14:48 ` Andrew Lunn
2018-03-23 20:11 ` [PATCH net-next 7/8] MIPS: mscc: connect phys to ports on ocelot_pcb123 Alexandre Belloni
2018-03-23 20:11 ` [PATCH net-next 8/8] MAINTAINERS: Add entry for Microsemi Ethernet switches Alexandre Belloni
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=20180329140544.GB12066@piout.net \
--to=alexandre.belloni@bootlin.com \
--cc=Allan.Nielsen@microsemi.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=f.fainelli@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@linux-mips.org \
--cc=netdev@vger.kernel.org \
--cc=po.liu@nxp.com \
--cc=razvan.stefanescu@nxp.com \
--cc=thomas.petazzoni@bootlin.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).