From: Sascha Hauer <s.hauer@pengutronix.de>
To: Florian Fainelli <f.fainelli@gmail.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel@pengutronix.de
Subject: Re: [PATCH] net/phy: micrel: Add clock support for KSZ8021/KSZ8031
Date: Fri, 10 Oct 2014 09:44:54 +0200 [thread overview]
Message-ID: <20141010074454.GO4992@pengutronix.de> (raw)
In-Reply-To: <5436BF5B.5060006@gmail.com>
On Thu, Oct 09, 2014 at 10:01:15AM -0700, Florian Fainelli wrote:
> On 10/09/2014 05:32 AM, Sascha Hauer wrote:
> > static int ksz8021_config_init(struct phy_device *phydev)
> > {
> > + struct clk *clk;
> > const u16 val = KSZPHY_OMSO_B_CAST_OFF | KSZPHY_OMSO_RMII_OVERRIDE;
> > int rc;
> >
> > + clk = devm_clk_get(&phydev->dev, "rmii-ref");
> > + if (!IS_ERR(clk)) {
> > + unsigned long rate = clk_get_rate(clk);
> > +
> > + if (rate > 24500000 && rate < 25500000)
> > + phydev->dev_flags |= MICREL_PHY_25MHZ_CLK;
> > + else if (rate > 49500000 && rate < 50500000)
> > + phydev->dev_flags |= MICREL_PHY_50MHZ_CLK;
> > + }
>
> I suppose that you could move this to the PHY driver probe() callback,
> and perform the rate checking from here, rejecting a clock whose rate is
> out of the acceptable range, and return an error to prevent the PHY
> driver registration? It is really up to you though.
Oh, it seems doing this in config_init is really wrong as it can be
called multiple times, even as a response to the SIOCSMIIREG ioctl.
We would request the clock each time then without ever releasing it.
I'll send an updated version with clock handling in probe().
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
prev parent reply other threads:[~2014-10-10 7:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-09 12:32 [PATCH] net/phy: micrel: Add clock support for KSZ8021/KSZ8031 Sascha Hauer
2014-10-09 17:01 ` Florian Fainelli
2014-10-10 7:44 ` Sascha Hauer [this message]
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=20141010074454.GO4992@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=f.fainelli@gmail.com \
--cc=kernel@pengutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/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).