Skip to contentSkip to conversation

MPC85XX TSEC driver: fix for mdio speed

PATCH Andy Fleming 3 participants 3 messages Jul 14, 2004 1 message not in the archive Networking

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 6 lines

From: Stefan Nickl<[email protected]>
Date: June 29, 2004 5:17:44 AM CDT
To: linuxppc-embedded<[email protected]>
Cc: Kumar Gala<[email protected]>
Subject: [PATCH] MPC85XX TSEC driver: fix for mdio speed

Quoted 14 lines

In gianfar_phy.c, the divisor for the MDIO interface to the PHYs is set to a safe value as part of running a phy_cmd. However, there is one MDIO transaction that happens before any command is sent: reading the PHYs manufactuere identifier in get_phy_info. This patch adds a "dummy command" to use the side effect of phy_run_commands.
Background is that the initial revision of our hardware only works reliably with the slowest divisor as long as the FEC PHY is the only (MDIO) bus load. We kept reading slightly distorted ID from the FEC's PHY when the 2 Marvells were not yet up.
--
Stefan Nickl
Kontron Modular Computers

Ooh, good catch. Kumar Gala forwarded me this, since I wrote the driver (And now I have subscribed to linuxppc-embedded, as I should have ;). Rather than a dummy read, though, it might be better to abstract the code which configures the bus, and put it in a function that both get_phy_info and phy_run_commands can call.

Here's a patch that does that. Could you check that it fixes your problem? If so, we'll push it out.

Index: drivers/net/gianfar_phy.c
===================================================================
RCS file: /cvsroot/linuxppc/linuxppc-2.4/drivers/net/gianfar_phy.c,v retrieving revision 1.3.4.3

net/gianfar_phy.c 2004/06/29 21:32:09 renamed from net/gianfar_phy.c 2004/05/24 17:42:02 1.3.4.3 +20 -9
diff -u -r1.3.4.3 gianfar_phy.c
@@ -42,6 +42,8 @@
 #include "gianfar.h"
 #include "gianfar_phy.h"
 
+static void get_phy_bus(struct gfar *phyregs);
+
 /* Write value to the PHY for this device to the register at regnum, */
 /* waiting until the write is done before it returns.  All PHY */
 /* configuration has to be done through the TSEC1 MIIM regs */
@@ -430,6 +432,10 @@
        u32 phy_ID;
        int i;
        struct phy_info *theInfo = NULL;
+       struct gfar_private *priv = (struct gfar_private *)dev->priv;
+       struct gfar *phyregs = priv->phyregs;
+
+       get_phy_bus(phyregs);
 
        /* Grab the bits from PHYIR1, and put them in the upper half */
        phy_reg = read_phy_reg(dev, MIIM_PHYIR1);
@@ -456,6 +462,19 @@
        return theInfo;
 }
 
+static void get_phy_bus(struct gfar *phyregs)
+{
+       /* Reset the management interface */
+       gfar_write(&phyregs->miimcfg, MIIMCFG_RESET);
+
+       /* Setup the MII Mgmt clock speed */
+       gfar_write(&phyregs->miimcfg, MIIMCFG_INIT_VALUE);
+
+       /* Wait until the bus is free */
+       while (gfar_read(&phyregs->miimind) & MIIMIND_BUSY)
+               cpu_relax();
+}
+
 /* Take a list of struct phy_cmd, and, depending on the values, either */
 /* read or write, using a helper function if provided */
 /* It is assumed that all lists of struct phy_cmd will be terminated by */
@@ -466,16 +485,8 @@
        u16 result;
        struct gfar_private *priv = (struct gfar_private *) dev->priv;
        struct gfar *phyregs = priv->phyregs;
-
-       /* Reset the management interface */
-       gfar_write(&phyregs->miimcfg, MIIMCFG_RESET);
 
-       /* Setup the MII Mgmt clock speed */
-       gfar_write(&phyregs->miimcfg, MIIMCFG_INIT_VALUE);
-
-       /* Wait until the bus is free */
-       while (gfar_read(&phyregs->miimind) & MIIMIND_BUSY)
-               cpu_relax();
+       get_phy_bus(phyregs);
 
        for (i = 0; cmd->mii_reg != miim_end; i++) {
                /* The command is a read if mii_data is miim_read */

Sorry for the long delay: this window fell behind some others while I was investigating a couple of the other things you mentioned, and then my stack got corrupted.

Andy Fleming
PowerPC Software Enablement
Freescale Semiconductor, Inc.

#2 lore raw
Quoted 3 lines · Andy Fleming

Ooh, good catch. Kumar Gala forwarded me this, since I wrote the driver (And now I have subscribed to linuxppc-embedded, as I should have ;). Rather than a dummy read, though, it might be better to

You're actually a bit late, seems the list won't exist much longer... :(

Quoted 6 lines

abstract the code which configures the bus, and put it in a function that both get_phy_info and phy_run_commands can call.

Here's a patch that does that. Could you check that it fixes your problem? If so, we'll push it out.

Works like a charm.

I just added some "volatile"s, the compiler was complaining. You also may want to move that cast to struct gfar * into get_phy_bus().

Quoted 5 lines

______________________________________________________________________
Sorry for the long delay: this window fell behind some others while I was investigating a couple of the other things you mentioned, and then my stack got corrupted.

Well, at least it's good to know that somebody's working on it :)

Btw: Can support for the 8541 be expected anytime soon?
I added some #defines to my platform code, but I didn't look closely into it's incarnation of the CPM yet.

--
Stefan Nickl
Kontron Modular Computers

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

#3 lore raw
Quoted 7 lines · Stefan Nickl

Btw: Can support for the 8541 be expected anytime soon?
I added some #defines to my platform code, but I didn't look closely into it's incarnation of the CPM yet.

--
Stefan Nickl
Kontron Modular Computers

Just yesterday, I was given The Nod to release the 8555/8541 sources for U-Boot. Linux likely follows shortly.

jdl

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