From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from wf-out-1314.google.com (wf-out-1314.google.com [209.85.200.170]) by ozlabs.org (Postfix) with ESMTP id D512DDDF82 for ; Fri, 8 May 2009 12:09:28 +1000 (EST) Received: by wf-out-1314.google.com with SMTP id 24so922764wfg.15 for ; Thu, 07 May 2009 19:09:26 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <1241641262-5202-6-git-send-email-wd@denx.de> References: <1241641262-5202-1-git-send-email-wd@denx.de> <1241641262-5202-6-git-send-email-wd@denx.de> Date: Thu, 7 May 2009 20:09:26 -0600 Message-ID: <4b73d43f0905071909v6e6e8b2el9eb6d4a1b9038f45@mail.gmail.com> Subject: Re: [PATCH 05/04] *** NOT FOR RELEASE *** HACK *** Work around MII clock issue *** From: John Rigby To: Wolfgang Denk Content-Type: multipart/alternative; boundary=001636e90eea2e6f4704695d1e5b Cc: linuxppc-dev@ozlabs.org List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , --001636e90eea2e6f4704695d1e5b Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit I think the fec's parent clock is the ipb clock not the ppc core clock. Could that be the problem? On Wed, May 6, 2009 at 2:21 PM, Wolfgang Denk wrote: > Signed-off-by: Wolfgang Denk > Cc: Grant Likely > Cc: John Rigby > --- > This patch is NOT intended for inclusion into mainline, but rather a > request for help. For some reason which I don't understand yet, the > Ethernet interface on the ARIA board does not work in the default > configuration, because MII probing fails. > > What I'm seeing is this; the problem is with this part of code in > "drivers/net/fs_enet/mii-fec.c": > > 156 fec->mii_speed = ((ppc_proc_freq + 4999999) / 5000000) << 1; > ... > 163 out_be32(&fec->fecp->fec_mii_speed, fec->mii_speed); > > I added some debug messages, and this is what I see: > > On the ADS5121, we have the CPU clocked at 400 MHz. I get: > ... > ## ppc_proc_freq = 399999996, fec->mii_speed = 160 > FEC MII Bus: probed > ... > It works fine. > > According to the Ref. Man.: > A value of 0 in this field turns off the MDC and leaves it in > a low-voltage state. Any non-zero value results in the MDC > frequency of 1/(mii_speed*2) of the system clock frequency. > that means we have a MDC frequency of > 400 MHz / (2 * 160) = 1.25 MHz > which is obviously within the 2.5 MHz limit. > > Now ARIA is currently running at 316.8 MHz, and this is what I get: > ... > ## ppc_proc_freq = 316800000, fec->mii_speed = 128 > fsl-fec-mdio: probe of 80002800.mdio failed with error -5 > ... > It fails. MDC frequency is > 316.8 MHz / (2 * 128) = 1.24 MHz > which should be fine. > > However, If I change the code to > > fec->mii_speed = (((ppc_proc_freq / 1000000) / 30) + 1) << 1; > > then I get: > ... > ## ppc_proc_freq = 316800000, fec->mii_speed = 22 > FEC MII Bus: probed > ... and it's working!!! However, I compute MDC frequency as > 316.8 MHz / (2 * 22) = 7.2 MHz > which is far above the maximum allowed clock of 2.5 MHz ??? > > Has anybody any idea what might be going on here? > > > drivers/net/fs_enet/mii-fec.c | 6 +++++- > 1 files changed, 5 insertions(+), 1 deletions(-) > > diff --git a/drivers/net/fs_enet/mii-fec.c b/drivers/net/fs_enet/mii-fec.c > index 9d8bd97..a51dd83 100644 > --- a/drivers/net/fs_enet/mii-fec.c > +++ b/drivers/net/fs_enet/mii-fec.c > @@ -153,8 +153,12 @@ static int __devinit fs_enet_mdio_probe(struct > of_device *ofdev, > if (!fec->fecp) > goto out_fec; > > +#if 0 > fec->mii_speed = ((ppc_proc_freq + 4999999) / 5000000) << 1; > - > +#else > + fec->mii_speed = (((ppc_proc_freq / 1000000) / 30) + 1) << 1; > + printk("## ppc_proc_freq = %d, fec->mii_speed = %d\n", > ppc_proc_freq, fec->mii_speed); > +#endif > setbits32(&fec->fecp->fec_r_cntrl, FEC_RCNTRL_MII_MODE); > setbits32(&fec->fecp->fec_ecntrl, FEC_ECNTRL_PINMUX | > FEC_ECNTRL_ETHER_EN); > -- > 1.6.0.6 > > --001636e90eea2e6f4704695d1e5b Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable I think the fec's parent clock is the ipb clock not the ppc core clock.= =A0 Could that be the problem?

On Wed, Ma= y 6, 2009 at 2:21 PM, Wolfgang Denk <wd@denx.de> wrote:
Signed-off-by: Wo= lfgang Denk <wd@denx.de>
Cc: Grant Likely <grant.lik= ely@secretlab.ca>
Cc: John Rigby <jcrigby@gmail.com>
---
This patch is NOT intended for inclusion into mainline, but rather a
request for help. For some reason which I don't understand yet, the
Ethernet interface on the ARIA board does not work in the default
configuration, because MII probing fails.

What I'm seeing is this; the problem is with this part of code in
"drivers/net/fs_enet/mii-fec.c":

156 =A0 =A0 =A0 =A0 fec->mii_speed =3D ((ppc_proc_freq + 4999999) / 5000= 000) << 1;
...
163 =A0 =A0 =A0 =A0 out_be32(&fec->fecp->fec_mii_speed, fec->m= ii_speed);

I added some debug messages, and this is what I see:

On the ADS5121, we have the CPU clocked at 400 MHz. =A0I get:
...
## ppc_proc_freq =3D 399999996, fec->mii_speed =3D 160
FEC MII Bus: probed
...
It works fine.

According to the Ref. Man.:
=A0 =A0 =A0 =A0A value of 0 in this field turns off the MDC and leaves it = in
=A0 =A0 =A0 =A0a low-voltage state. Any non-zero value results in the MDC<= br> =A0 =A0 =A0 =A0frequency of 1/(mii_speed*2) of the system clock frequency.=
that means we have a MDC frequency of
=A0 =A0 =A0 =A0400 MHz / (2 * 160) =3D 1.25 MHz
which is obviously within the 2.5 MHz limit.

Now ARIA is currently running at 316.8 MHz, and this is what I get:
...
## ppc_proc_freq =3D 316800000, fec->mii_speed =3D 128
fsl-fec-mdio: probe of 80002800.mdio failed with error -5
...
It fails. MDC frequency is
=A0 =A0 =A0 =A0316.8 MHz / (2 * 128) =3D 1.24 MHz
which should be fine.

However, If I change the code to

fec->mii_speed =3D (((ppc_proc_freq / 1000000) / 30) + 1) << 1;
then I get:
...
## ppc_proc_freq =3D 316800000, fec->mii_speed =3D 22
FEC MII Bus: probed
... and it's working!!! However, I compute MDC frequency as
=A0 =A0 =A0 =A0316.8 MHz / (2 * 22) =3D 7.2 MHz
which is far above the maximum allowed clock of 2.5 MHz ???

Has anybody any idea what might be going on here?


=A0drivers/net/fs_enet/mii-fec.c | =A0 =A06 +++++-
=A01 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/drivers/net/fs_enet/mii-fec.c b/drivers/net/fs_enet/mii-fec.c<= br> index 9d8bd97..a51dd83 100644
--- a/drivers/net/fs_enet/mii-fec.c
+++ b/drivers/net/fs_enet/mii-fec.c
@@ -153,8 +153,12 @@ static int __devinit fs_enet_mdio_probe(struct of_devi= ce *ofdev,
=A0 =A0 =A0 =A0if (!fec->fecp)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0goto out_fec;

+#if 0
=A0 =A0 =A0 =A0fec->mii_speed =3D ((ppc_proc_freq + 4999999) / 5000000)= << 1;
-
+#else
+ =A0 =A0 =A0 fec->mii_speed =3D (((ppc_proc_freq / 1000000) / 30) + 1) = << 1;
+ =A0 =A0 =A0 printk("## ppc_proc_freq =3D %d, fec->mii_speed =3D %= d\n", ppc_proc_freq, fec->mii_speed);
+#endif
=A0 =A0 =A0 =A0setbits32(&fec->fecp->fec_r_cntrl, FEC_RCNTRL_MII= _MODE);
=A0 =A0 =A0 =A0setbits32(&fec->fecp->fec_ecntrl, FEC_ECNTRL_PINM= UX |
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0FEC_ECNTRL_ETHER_EN);
--
1.6.0.6


--001636e90eea2e6f4704695d1e5b--