[meta-xilinx] Control of two PHYs from a single MAC (Device tree configuration)

Nathan Rossi nathan at nathanrossi.com
Fri May 22 00:25:22 PDT 2015


On Fri, May 22, 2015 at 12:54 AM, Stephen Mossom
<stephen.mossom at calnexsol.com> wrote:
> Hi Nathan,
>
> Thanks for getting back to me so quickly.
>
> I applied the change to remove the macb driver but I am now getting an error when the emacps driver probes the bus:-
>
> [    0.905950] libphy: XEMACPS mii bus: probed
> [    0.911400] xemacps e000b000.ps7-ethernet: invalid address, use assigned
> [    0.918106] xemacps e000b000.ps7-ethernet: MAC updated 92:6e:f5:23:e4:da
> [    0.924832] xemacps e000b000.ps7-ethernet: pdev->id -1, baseaddr 0xe000b000, irq 54
> [    0.933550] ------------[ cut here ]------------
> [    0.938270] WARNING: CPU: 1 PID: 1 at /home/dev/src/yocto/dizzy/zynq/tmp/work/springbank_zynq7-poky-linux-gnueabi/linux-xlnx/3.14-xilinx+gitAUTOINC+2b48a8aeea-r0/linux/fs/sysfs/dir.c:52 sysfs_warn_dup+0x7c/0x88()
> [    0.957062] sysfs: cannot create duplicate filename '/class/mdio_bus/e000c000'
> [    0.964239] Modules linked in:
> [    0.967285] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 3.14.2-xilinx #1
> [    0.973818] [<c001540c>] (unwind_backtrace) from [<c001170c>] (show_stack+0x10/0x14)
> [    0.981552] [<c001170c>] (show_stack) from [<c03f346c>] (dump_stack+0x80/0xc0)
> [    0.988760] [<c03f346c>] (dump_stack) from [<c0022d00>] (warn_slowpath_common+0x70/0x8c)
> [    0.996821] [<c0022d00>] (warn_slowpath_common) from [<c0022d4c>] (warn_slowpath_fmt+0x30/0x40)
> [    1.005497] [<c0022d4c>] (warn_slowpath_fmt) from [<c0124458>] (sysfs_warn_dup+0x7c/0x88)
> [    1.013642] [<c0124458>] (sysfs_warn_dup) from [<c0124744>] (sysfs_do_create_link_sd.isra.2+0xb4/0xbc)
> [    1.022957] [<c0124744>] (sysfs_do_create_link_sd.isra.2) from [<c026f218>] (device_add+0x2f8/0x538)
> [    1.032066] [<c026f218>] (device_add) from [<c02ca658>] (mdiobus_register+0x84/0x180)
> [    1.039867] [<c02ca658>] (mdiobus_register) from [<c032d0a4>] (of_mdiobus_register+0x4c/0x1b8)
> [    1.048463] [<c032d0a4>] (of_mdiobus_register) from [<c02d0cf0>] (xemacps_probe+0x668/0x6d8)
> [    1.056878] [<c02d0cf0>] (xemacps_probe) from [<c02730d8>] (platform_drv_probe+0x18/0x4c)
> [    1.065039] [<c02730d8>] (platform_drv_probe) from [<c02718fc>] (driver_probe_device+0x7c/0x21c)
> [    1.073791] [<c02718fc>] (driver_probe_device) from [<c0271b6c>] (__driver_attach+0x8c/0x90)
> [    1.082223] [<c0271b6c>] (__driver_attach) from [<c026ff08>] (bus_for_each_dev+0x6c/0xa0)
> [    1.090382] [<c026ff08>] (bus_for_each_dev) from [<c0271168>] (bus_add_driver+0x148/0x1f0)
> [    1.098628] [<c0271168>] (bus_add_driver) from [<c0272168>] (driver_register+0x78/0xf8)
> [    1.106614] [<c0272168>] (driver_register) from [<c000881c>] (do_one_initcall+0xf8/0x154)
> [    1.114770] [<c000881c>] (do_one_initcall) from [<c056ec50>] (kernel_init_freeable+0x138/0x1d8)
> [    1.123463] [<c056ec50>] (kernel_init_freeable) from [<c03ef05c>] (kernel_init+0x8/0xe8)
> [    1.131528] [<c03ef05c>] (kernel_init) from [<c000e4b8>] (ret_from_fork+0x14/0x3c)
>
>
> I am on the dizzy branch and I have the patch described in http://forums.xilinx.com/t5/Embedded-Linux/zynq-linux-dual-emacps-gem-problem/td-p/263964/page/4 applied to the emacps driver.
>
> My device tree looks like this:-
>
> Top level....
>
>         ps7_ethernet_0: ps7-ethernet at e000b000 {
>             phy-handle = <&phy0>;
>             phy-mode = "rgmii-id";
>
>         } ;
>         ps7_ethernet_1: ps7-ethernet at e000c000 {
>             phy-handle = <&phy1>;
>             phy-mode = "rgmii-id";
>             mdio {
>                 phy0: phy at 1 {
>                     compatible = "marvell,88e1116r";
>                     device_type = "ethernet-phy";
>                     reg = <1>;
>                 } ;
>                 phy1: phy at 2 {
>                     compatible = "marvell,88e1116r";
>                     device_type = "ethernet-phy";
>                     reg = <2>;
>                 } ;
>             };
>         } ;
>
> Base...
>
>                 ps7_ethernet_0: ps7-ethernet at e000b000 {
>                         #address-cells = <1>;
>                         #size-cells = <0>;
>                         clock-names = "pclk", "hclk", "tx_clk", "ref_clk", "aper_clk";
>                         clocks = <&clkc 30>, <&clkc 30>, <&clkc 13>, <&clkc 13>, <&clkc 30>;
>                         compatible = "xlnx,ps7-ethernet-1.00.a";
>                         interrupt-parent = <&ps7_scugic_0>;
>                         interrupts = <0 22 4>;
>                         local-mac-address = [ 00 0a 35 00 00 00 ];
>                         reg = <0xe000b000 0x1000>;
>                         xlnx,enet-reset = <0xffffffff>;
>                         xlnx,eth-mode = <0x1>;
>                         xlnx,has-mdio = <0x0>;
>                         xlnx,ptp-enet-clock = <111111115>;
>                 } ;
>                 ps7_ethernet_1: ps7-ethernet at e000c000 {
>                         #address-cells = <1>;
>                         #size-cells = <0>;
>                         clock-names = "pclk", "hclk", "tx_clk", "ref_clk", "aper_clk";
>                         clocks = <&clkc 31>, <&clkc 31>, <&clkc 14>, <&clkc 14>, <&clkc 31>;
>                         compatible = "xlnx,ps7-ethernet-1.00.a";
>                         interrupt-parent = <&ps7_scugic_0>;
>                         interrupts = <0 45 4>;
>                         local-mac-address = [ 00 0a 35 00 00 01 ];
>                         reg = <0xe000c000 0x1000>;
>                         xlnx,enet-reset = <0xffffffff>;
>                         xlnx,eth-mode = <0x1>;
>                         xlnx,has-mdio = <0x1>;
>                         xlnx,ptp-enet-clock = <111111115>;
>                         mdio {
>                                 #address-cells = <1>;
>                                 #size-cells = <0>;
>                         } ;
>                 } ;
>
> The error seems to suggest that two copies of the e000c000 mdio bus entry in sysfs are being created but I expected the patch to the driver combined with the changes to the device tree to prevent this.
>
> Any Ideas?

Not really, it looks like the emacps driver is just broken for this use case :|.

I had a look at the macb driver and I have created a preliminary patch
to add the use of the phy-handle property. I have only tested it on
QEMU (with some tricks to make the kernel think there are two phys,
see the below dts).

The patch should apply to the linux-xlnx "xlnx_3.14" branch, aka the
linux-xlnx_3.14 kernel.
See this commit here:
https://github.com/nathanrossi/linux/commit/0e7f523124b21abf2c3fd9028f348e7b34fe63be

Would you be able to give it a try, remove the "disable-macb.scc" and
use the macb driver. I don't have hardware that has the dual ethernet,
one mdio bus setup so I have not tested on hardware.

When booting i get it attaching both phys with their respectively
correct bus attachments:

[    2.765541] libphy: MACB_mii_bus: probed
[    3.292934] macb e000b000.ps7-ethernet eth0: Cadence GEM at
0xe000b000 irq 54 (00:0a:35:00:00:00)
[    3.294237] macb e000b000.ps7-ethernet eth0: attached PHY driver
[Marvell 88E1111] (mii_bus:phy_addr=e000b000.ps7-eth:17, irq=-1)
[    3.303783] libphy: MACB_mii_bus: probed
[    4.131375] macb e000c000.ps7-ethernet eth1: Cadence GEM at
0xe000c000 irq 77 (00:0a:35:00:00:01)
[    4.131941] macb e000c000.ps7-ethernet eth1: attached PHY driver
[Marvell 88E1111] (mii_bus:phy_addr=e000b000.ps7-eth:00, irq=-1)

(note the phy's bus addr and controller address)

I tricked qemu like so (for reference), note that i used the broadcast
address as the second phy just so that it would actually be able to
communicate with something.

ps7_ethernet_0: ps7-ethernet at e000b000 {
        clocks = <&clkc 30>, <&clkc 30>, <&clk125mhz>, <&clk125mhz>, <&clkc 30>;
        phy-handle = <&phy0>;
        phy-mode = "gmii";
        phy1: phy at 0 {
                device_type = "ethernet-phy";
                reg = <0>;
        } ;
        phy0: phy at 23 {
                device_type = "ethernet-phy";
                reg = <23>;
        } ;
} ;
ps7_ethernet_1: ps7-ethernet at e000c000 {
        clocks = <&clkc 30>, <&clkc 30>, <&clk125mhz>, <&clk125mhz>, <&clkc 30>;
        phy-handle = <&phy1>;
        phy-mode = "gmii";
};

Regards,
Nathan

>
> Thanks
>
> Stephen
>
>
> -----Original Message-----
> From: Nathan Rossi [mailto:nathan at nathanrossi.com]
> Sent: 21 May 2015 13:40
> To: Stephen Mossom
> Cc: meta-xilinx at yoctoproject.org
> Subject: Re: [meta-xilinx] Control of two PHYs from a single MAC (Device tree configuration)
>
> On Thu, May 21, 2015 at 9:37 PM, Stephen Mossom <stephen.mossom at calnexsol.com> wrote:
>> Hi All
>>
>>
>>
>> I made use of a  patch to the dizzy branch to get my Ethernet PHY
>> detected but my configuration is slightly different. I have a second
>> PHY which has a MDIO connection from the same MAC.
>>
>>
>>
>> The patch is discussed here:-
>>
>>
>>
>> https://lists.yoctoproject.org/pipermail/meta-xilinx/2015-April/000960
>> .html
>>
>>
>>
>> I have 2 MACS (MAC0, MAC1) and 2 PHYS (PHY0, PHY1) but one of the MACs
>> controls both PHYs.
>>
>>
>>
>> The MDIO for both PHY0 and PHY1 is connected to MAC1.
>>
>>
>>
>> The GMII for PHY0 is connected to MAC0 and the GMII for PHY1 is
>> connected to MAC1.
>>
>>
>>
>> It's a similar setup to that discussed here....
>>
>>
>>
>> http://forums.xilinx.com/t5/Embedded-Linux/zynq-linux-dual-emacps-gem-
>> problem/td-p/263964/page/3
>>
>>
>>
>> ...except the PHYs are both connected to the second MAC rather than
>> the first one.
>>
>>
>>
>> With the device tree like this the PHY for MAC1 (ps7_ethernet_1) is
>> detected
>> only:-
>>
>>
>>
>>        ps7_ethernet_0: ps7-ethernet at e000b000 {
>>
>>             phy-handle = <&phy0>;
>>
>>             phy-mode = "rgmii-id";
>>
>>             phy0: phy at 1 {
>>
>>                 compatible = "marvell,88e1116r";
>>
>>                 device_type = "ethernet-phy";
>>
>>                 reg = <1>;
>>
>>             } ;
>>
>>         } ;
>>
>>         ps7_ethernet_1: ps7-ethernet at e000c000 {
>>
>>             phy-handle = <&phy1>;
>>
>>             phy-mode = "rgmii-id";
>>
>>             phy1: phy at 2 {
>>
>>                 compatible = "marvell,88e1116r";
>>
>>                 device_type = "ethernet-phy";
>>
>>                 reg = <2>;
>>
>>             } ;
>>
>>         } ;
>>
>>
>>
>>
>>
>> I also tried this (which is something like the link in the forums) and
>> neither PHY is detected:-
>>
>>
>>
>>        ps7_ethernet_0: ps7-ethernet at e000b000 {
>>
>>             phy-handle = <&phy0>;
>>
>>             phy-mode = "rgmii-id";
>>
>>         } ;
>>
>>         ps7_ethernet_1: ps7-ethernet at e000c000 {
>>
>>             phy-handle = <&phy1>;
>>
>>             phy-mode = "rgmii-id";
>>
>>             phy1: phy at 2 {
>>
>>                 compatible = "marvell,88e1116r";
>>
>>                 device_type = "ethernet-phy";
>>
>>                 reg = <2>;
>>
>>             } ;
>>
>>             phy0: phy at 1 {
>>
>>                 compatible = "marvell,88e1116r";
>>
>>                 device_type = "ethernet-phy";
>>
>>                 reg = <1>;
>>
>>             } ;
>>
>>         } ;
>
> This is the right way to setup the device tree for 2 phys off one mac's mdio bus.
>
> I assume you have not disabled the macb driver, which is most likely the reason this doesn't work right. This is because the macb driver does not follow the "phy-handle" property (and thus ps7_ethernet_0 in this case doesn't know how to probe its phy). In this specific case you will need to use the linux-xlnx vendor tree xemacps driver, to do that you use the kernel feature to disable the macb driver (use the following in your local.conf or in your <machine>.conf):
>
> KERNEL_FEATURES_append += "bsp/xilinx/disable-macb.scc"
>
> I have been meaning to make a patch for the macb driver so that it can handle the phy-handle property (which is the standard way to do ethernet phy's in device-trees), will have to sort that out.
>
> Regards,
> Nathan
>
>>
>>
>>
>> How do I configure the device tree to get both PHYs detected through
>> the second MAC?
>>
>>
>>
>> Thanks
>>
>>
>>
>> Stephen
>>
>>
>>
>>
>>
>> Stephen Mossom  |  Calnex Solutions Ltd  |  +44 (0) 1506-671-416
>>
>>
>>
>>
>> --
>> _______________________________________________
>> meta-xilinx mailing list
>> meta-xilinx at yoctoproject.org
>> https://lists.yoctoproject.org/listinfo/meta-xilinx
>>



More information about the meta-xilinx mailing list