lkml.org 
[lkml]   [2014]   [Oct]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] net/phy: micrel: Add clock support for KSZ8021/KSZ8031
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 |


\
 
 \ /
  Last update: 2014-10-10 10:22    [W:0.036 / U:3.868 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site