From patchwork Fri Feb 19 12:32:15 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Staale.Aakermann@kongsberg.com X-Patchwork-Id: 45894 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from bilbo.ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 1F770B7DD4 for ; Sat, 20 Feb 2010 09:33:30 +1100 (EST) X-Greylist: delayed 314 seconds by postgrey-1.32 at bilbo; Fri, 19 Feb 2010 23:38:10 EST Received: from ukgl-edge-p01.kongsberg.com (ukgl-edge-p01.kongsberg.com [193.71.180.98]) by ozlabs.org (Postfix) with ESMTP id C772EB7CB6 for ; Fri, 19 Feb 2010 23:38:10 +1100 (EST) Received: from UKGW-EXHUB-VP01.kda.kongsberg.com ([10.50.100.12]) by ukgl-edge-p01.kongsberg.com (8.14.1/8.14.1) with ESMTP id o1JCWf74030188 for ; Fri, 19 Feb 2010 13:32:41 +0100 Received: from ukgw-exmb-p06.kda.kongsberg.com ([fe80:0000:0000:0000:e8d3:c31e:56.138.212.241]) by UKGW-EXHUB-VP01.kda.kongsberg.com ([10.50.100.12]) with mapi; Fri, 19 Feb 2010 13:32:07 +0100 From: To: Date: Fri, 19 Feb 2010 13:32:15 +0100 Subject: ppc4xx emac support of phy-less devices patch + dts example Thread-Topic: ppc4xx emac support of phy-less devices patch + dts example Thread-Index: AcqxX5+bTlVnwAWIRcKvsEnc2sO01g== Message-ID: Accept-Language: en-US, nb-NO Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US, nb-NO MIME-Version: 1.0 X-Mailman-Approved-At: Sat, 20 Feb 2010 09:33:20 +1100 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org 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. DTS example: EMAC1: ethernet@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 = ; 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@kongsberg.com Url: www.kongsberg.com --- 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; }