linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* RE: MDIO clock speed computation
@ 2002-07-23 19:41 Jean-Denis Boyer
  2002-07-24  7:38 ` Pavel Bartusek
  0 siblings, 1 reply; 12+ messages in thread
From: Jean-Denis Boyer @ 2002-07-23 19:41 UTC (permalink / raw)
  To: 'Dan Malek'; +Cc: Pavel Bartusek, linuxppc-embedded


Dan,

> I never expected to see someone run something like 46.5 MHz.

I agree, this might be impossible to achieve, since the PLL gain is an
integer. But the externcal clock does not necessarily have a frequency which
is a multiple of 1MHz.

For example, some of our 860T based boards have an external clock of
4096kHz, which is multiplied by 12, and yields a core clock of 49152MHz.

I don't know much about clock devices, but I guess there are many
possibilities.

> Will this work for all cases? :
>
> ((((bd->bi_intfreq + 4999999) / 2500000) / 2 ) & 0x3F ) << 1;

I hope so ;-)


--------------------------------------------
 Jean-Denis Boyer, B.Eng., System Architect
 Mediatrix Telecom Inc.
 4229 Garlock Street
 Sherbrooke (Québec)
 J1L 2C8  CANADA
 (819)829-8749 x241
--------------------------------------------

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 12+ messages in thread
* RE: MDIO clock speed computation
@ 2002-07-23 15:47 Jean-Denis Boyer
  2002-07-23 17:34 ` Dan Malek
  0 siblings, 1 reply; 12+ messages in thread
From: Jean-Denis Boyer @ 2002-07-23 15:47 UTC (permalink / raw)
  To: 'Dan Malek'; +Cc: Pavel Bartusek, linuxppc-embedded


Dan,

> try this (since the problem is the divisor register truncation):
>
> (((((bd->bi_intfreq + 500000) / 2500000) + 1) / 2 ) & 0x3F ) << 1;

This is bad :-(
With a frequency of 46.5MHz, you get a MII clock of 2.58MHz.

Why adding 500000 (0.5MHz) to the internal clock in this computation?
We usually do that to round up (or down) to the nearest integer.
But we do NOT want to round down, or the divisor (MII_SPEED) will be too
low.
We want to round up to the nearest integer when divided by 2*2.5MHz.

--------------------------------------------
 Jean-Denis Boyer, B.Eng., System Architect
 Mediatrix Telecom Inc.
 4229 Garlock Street
 Sherbrooke (Québec)
 J1L 2C8  CANADA
 (819)829-8749 x241
--------------------------------------------

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 12+ messages in thread
* RE: MDIO clock speed computation
@ 2002-07-22 20:54 Jean-Denis Boyer
  0 siblings, 0 replies; 12+ messages in thread
From: Jean-Denis Boyer @ 2002-07-22 20:54 UTC (permalink / raw)
  To: 'Dan Malek'; +Cc: 'Pavel Bartusek', linuxppc-embedded


Dan,

> The MII clock is not derived from the core speed, but rather the
> system/bus clock speed.

Motorola documentation says the MDIO clock is a fraction of the system clock
frequency. I tought the system clock was the core clock, and the external
bus clock was divided using SCCR[EBDF]. Where is it told the system clock is
the bus clock?

> Up to this point, I don't believe there are
> any 8xx parts that are qualified to run beyond a 50 MHz CPU/bus
> speed, so the software is just fine.

The value of 82.5MHz was only a example to show the
erroneous computation. May be it was badly choosed, I admit.
You can also try with 47.5MHz (more realistic) and
see this yields to a MII clock of 2.64MHz.

> Also, the 2.5 MHz is a suggestion, I think all PHYs run much
> faster, you will have to check the data sheet.

I think this is a bad assumption. A PHY from National,
the DP83846A, specifies a MDIO clock of 2.5MHz (MAX).
A PHY of Intel, the LXT972A, as a maximum speed of 8MHz.

> The only thing that will happen if this speed is out of spec
> for either side is you will have problems configuring
> or detecting the PHY (the exchange of control/status messages).

The funniest thing is that the problem that Pavel reported today
seems to fix a problem that was submitted to me a couple of
weeks ago, and that I just begun to work on this morning!!!

My 860T is clocked at 49.152MHz, and the MII clock (with the
erroneous calculation) was output to 2.73MHz to my DP83846A PHY.

During FEC initialization, I have a couple of MDIO accesses
thightly serialized. Sometimes, the system was hanging, waiting
for an MDIO to complete. The answer was never received by the FEC.
With my BDI2000, I just set the MII_DATA register again to force
the read command to be resent, and the board continued to boot.

Changing the MII clock to 2.46MHz just seemed to fix the problem.
I successfully ran tests for more than an hour now...

Regards,
--------------------------------------------
 Jean-Denis Boyer, B.Eng., System Architect
 Mediatrix Telecom Inc.
 4229 Garlock Street
 Sherbrooke (Québec)
 J1L 2C8  CANADA
 (819)829-8749 x241
--------------------------------------------

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 12+ messages in thread
* RE: MDIO clock speed computation
@ 2002-07-22 18:19 Jean-Denis Boyer
  2002-07-22 19:51 ` Dan Malek
  0 siblings, 1 reply; 12+ messages in thread
From: Jean-Denis Boyer @ 2002-07-22 18:19 UTC (permalink / raw)
  To: 'Pavel Bartusek'; +Cc: linuxppc-embedded


Pavel,

You have found a interesting problem in the calculation of the MII_SPEED.
And it seems to be there since a long time!

However, your fix seems incomplete.
If I have a frequency of 82,5MHz, for example,
it yields exactly to the same result before and after your patch,
that is an MDIO clock of 2.58MHz.

Since the divisor is 2 * MDCLOCK,
I would suggest something like:

  (((bd->bi_intfreq + (2 * 2500000 - 1 )) / 2500000 / 2) & 0x3F) << 1;

Regards,

--------------------------------------------
 Jean-Denis Boyer, B.Eng., System Architect
 Mediatrix Telecom Inc.
 4229 Garlock Street
 Sherbrooke (Québec)
 J1L 2C8  CANADA
 (819)829-8749 x241
--------------------------------------------

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 12+ messages in thread
* MDIO clock speed computation
@ 2002-07-22 17:19 Pavel Bartusek
  0 siblings, 0 replies; 12+ messages in thread
From: Pavel Bartusek @ 2002-07-22 17:19 UTC (permalink / raw)
  To: linuxppc-embedded


Hi there,

I found a little problem with computation of MDIO clock speed in
linux/arch/ppc/8xx_io/fec.c
The MPC855T users manual: "The MII_SPEED field must be programmed with a
value to provide an MDC frequency of less than or equal to 2.5 MHz to
comply with the IEEE MII specification."
The code produces ie. value 0x18 to the MII Speed Control Register for
64MHz system clock it means 2.67Mhz MDIO clock.

This patch will repair it.


        /* Set MII speed to 2.5 MHz
        */
        fecp->fec_mii_speed = fep->phy_speed =
-               (( (bd->bi_intfreq + 500000) / 2500000 / 2 ) & 0x3F ) << 1;
+               (( (bd->bi_intfreq + (2500000-1)) / 2500000 / 2 ) & 0x3F
) << 1;
 #else
        fecp->fec_mii_speed = 0;        /* turn off MDIO */
 #endif /* CONFIG_USE_MDIO */

--

----------------------------------------------------------------------
|                          Pavel Bartusek                            |
|                                                                    |
| Sysgo RTS GmbH,                     phone: +49 (0) 6136 9948-722   |
| Am Pfaffenstein 14                  fax:   +49 (0) 6136 9948-10    |
| D-55270 Klein-Winternheim           email: pba@sysgo.de            |
| Germany                                                            |
|                                                                    |
|       http://www.sysgo.de           http://www.elinos.com          |
|                                                                    |
----------------------------------------------------------------------


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2002-07-24  7:38 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-07-23 19:41 MDIO clock speed computation Jean-Denis Boyer
2002-07-24  7:38 ` Pavel Bartusek
  -- strict thread matches above, loose matches on Subject: below --
2002-07-23 15:47 Jean-Denis Boyer
2002-07-23 17:34 ` Dan Malek
2002-07-22 20:54 Jean-Denis Boyer
2002-07-22 18:19 Jean-Denis Boyer
2002-07-22 19:51 ` Dan Malek
2002-07-22 20:12   ` Dan Malek
2002-07-22 20:15   ` Wolfgang Denk
2002-07-23 10:22   ` Pavel Bartusek
2002-07-23 15:01     ` Dan Malek
2002-07-22 17:19 Pavel Bartusek

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).