* ppc4xx emac support of phy-less devices patch + dts example
@ 2010-02-19 12:32 Staale.Aakermann
2010-04-07 0:27 ` Benjamin Herrenschmidt
0 siblings, 1 reply; 2+ messages in thread
From: Staale.Aakermann @ 2010-02-19 12:32 UTC (permalink / raw)
To: linuxppc-dev
[-- Attachment #1: Type: text/plain, Size: 4423 bytes --]
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@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@kongsberg.com<mailto:staale.aakermann@kongsberg.com>
Url: www.kongsberg.com<http://www.kongsberg.com/>
[-- Attachment #2: Type: text/html, Size: 24620 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: ppc4xx emac support of phy-less devices patch + dts example
2010-02-19 12:32 ppc4xx emac support of phy-less devices patch + dts example Staale.Aakermann
@ 2010-04-07 0:27 ` Benjamin Herrenschmidt
0 siblings, 0 replies; 2+ messages in thread
From: Benjamin Herrenschmidt @ 2010-04-07 0:27 UTC (permalink / raw)
To: Staale.Aakermann; +Cc: linuxppc-dev
On Fri, 2010-02-19 at 13:32 +0100, Staale.Aakermann@kongsberg.com wrote:
> Hi,
Hi !
Sorry for the delay, I've been busy with other things and your message
slipped a bit through the cracks.
> 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.
.../...
So first thing first, your patch is completely whitespace damaged :-)
Now, as for your aproach:
> + 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;
>
> +
No objection on the method above. It might be nicer to call those
fixed-phy-duplex, fixed-phy-speed, etc... and have a "fixed-phy" empty
property as a cleaner way to represent the phyless mode but that's not a
very big deal.
> 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;
>
So you remove the above which sets the 1000bT support...
> +
>
> + 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:
>
Ditto...
>
> + 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;
>
> + }
>
> +
And never add back any option for 1000bT ... Not nice :-)
You should add the case back for 1000bT (btw, turn the above into a
switch/case statement please). And if phy.speed is none of the above
(default, ie, the property is not present in the device-tree), then
revert to the old method, or something like that. Or you may break
existing stuff.
> 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
>
> +
Ok.
Cheers,
Ben.
> return 0;
>
> }
>
>
>
>
>
> 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 = </*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@kongsberg.com
>
> Url: www.kongsberg.com
>
>
>
>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-04-07 0:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-19 12:32 ppc4xx emac support of phy-less devices patch + dts example Staale.Aakermann
2010-04-07 0:27 ` Benjamin Herrenschmidt
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).