ppc4xx emac support of phy-less devices patch + dts example

Staale.Aakermann at kongsberg.com Staale.Aakermann at kongsberg.com
Fri Feb 19 23:32:15 EST 2010


Hi,

I'm currently working on a custom embedded card with ppc405ex installed.
On this card, EMAC1 is "phy-less", and connected directly to a MAC on a micrel switch (ks8995ma).
I've tried the default phy-less mode currently supported by the core driver for ibm_newmac, but found
this insufficient. I've made a patch for the core driver so it supports some more scenarios.

Since the simultanious operation of both EMACS on PPC405EX requires utilization of the RGMII bridge, I did not
manage setting the speed to less than 1Gbps using the current phy-less mode. I've moved the phy-less setup to
the dts. I've also added a clock-internal which was required for my case, as the SDR0_MFR E1CS register was set
by default in phy-less mode.

--- drivers/net/ibm_newemac/core.c 2010-02-19 11:13:00.000000000 +0100
+++ drivers/net/ibm_newemac/core.c 2010-02-19 12:53:56.000000000 +0100
@@ -2393,14 +2393,54 @@
            /* PHY-less configuration.
             * XXX I probably should move these settings to the dev tree
             */
+
+    if (emac_read_uint_prop(np, "phy-duplex", &dev->phy.duplex, 0))
+        dev->phy.duplex = 1;
+
+    if (emac_read_uint_prop(np, "phy-speed", &dev->phy.speed, 0))
+        dev->phy.speed = 100;
+
+    if (emac_read_uint_prop(np, "phy-autoneg", &dev->phy.autoneg, 0))
+        dev->phy.autoneg = 0;
+
            dev->phy.address = -1;
            dev->phy.features = SUPPORTED_MII;
-           if (emac_phy_supports_gige(dev->phy_mode))
-                 dev->phy.features |= SUPPORTED_1000baseT_Full;
-           else
-                 dev->phy.features |= SUPPORTED_100baseT_Full;
+
+        if (dev->phy.autoneg == 1 )
+            dev->phy.features |= SUPPORTED_Autoneg;
+
+        switch (dev->phy.duplex)
+        {
+            case 0:
+
+                if (dev->phy.speed == 10 )
+                    dev->phy.features |= SUPPORTED_10baseT_Half;
+
+                if (dev->phy.speed == 100 )
+                    dev->phy.features |= SUPPORTED_100baseT_Half;
+
+                if (dev->phy.speed == 100 )
+                    dev->phy.features |= SUPPORTED_100baseT_Half;
+
+            default:
+
+                if (dev->phy.speed == 10 )
+                    dev->phy.features |= SUPPORTED_10baseT_Full;
+
+                if (dev->phy.speed == 100 )
+                    dev->phy.features |= SUPPORTED_100baseT_Full;
+
+                if (dev->phy.speed == 100 )
+                    dev->phy.features |= SUPPORTED_100baseT_Full;
+        }
+
            dev->phy.pause = 1;

+        #if defined (CONFIG_PPC_DCR_NATIVE) && defined (CONFIG_405EX)
+        if (of_get_property(np, "phy-clock-internal", NULL))
+            dcri_clrset(SDR0, SDR0_MFR, ( dev->rgmii_port ? SDR0_MFR_ECS >> 1 : SDR0_MFR_ECS ),0 );
+        #endif
+
            return 0;
      }


DTS example:

EMAC1: ethernet at ef600a00 {
      linux,network-index = <0x1>;
      device_type = "network";
      compatible = "ibm,emac-405ex", "ibm,emac4sync";
      interrupt-parent = <&EMAC1>;
      interrupts = <0x0 0x1>;
      #interrupt-cells = <1>;
      #address-cells = <0>;
      #size-cells = <0>;
      interrupt-map = </*Status*/ 0x0 &UIC0 0x19 0x4
                   /*Wake*/  0x1  &UIC1 0x1f 0x4>;
      reg = <0xef600a00 0x000000c4>;
      local-mac-address = [0000000000];
      mal-device = <&MAL0>;
      mal-tx-channel = <1>;
      mal-rx-channel = <1>;
      cell-index = <1>;
      max-frame-size = <9000>;
      rx-fifo-size = <4096>;
      tx-fifo-size = <2048>;
      phy-mode = "rgmii";
      phy-map = <0xffffffff>;      // Be sure that the emac use phy-less configuration
      phy-address = <0xffffffff>;  // Be sure that the emac use phy-less configuration
      phy-speed = <100>;
      phy-duplex = <1>;
      phy-autoneg = <0>;
      phy-clock-internal;
      rgmii-device = <&RGMII0>;
      rgmii-channel = <1>;
      has-inverted-stacr-oc;
      has-new-stacr-staopc;
};



Best regards
Staale Aakermann, Systems Engineer
Kongsberg Defence Systems / Defence Communication
Olav Brunborgsv 6, P.O.Box 87, 1375 Billingstad, Norway
Phone: +47 66 84 24 00, Direct Phone: +47 66 74 48 51,
Fax: +47 66 84 82 30, Mobile: +47 928 29 879
Mail: staale.aakermann at kongsberg.com<mailto:staale.aakermann at kongsberg.com>
Url: www.kongsberg.com<http://www.kongsberg.com/>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ozlabs.org/pipermail/linuxppc-dev/attachments/20100219/000a1342/attachment-0001.htm>


More information about the Linuxppc-dev mailing list