This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM4376: Linux Device Tree with Marvell Switch and its Linux DSA Driver

Other Parts Discussed in Thread: AM4372

Hello,

i have a sitara 4376 and have problems with the devicetree am4372.dtsi. I have 2 Ethernetports (eth0,eth1), where eth0 is directly connected to a marvell-switch and eth1 to a phy. The davinci-MDIO driver is always assuming, that a phy is always directly connected to a eth-port. So this is why I can´t use the davinci-mdio driver, because at eth0 is a marvell-switch.

So I patched my Linux 4.0.5 to add a fake-mdio driver to run the eth-ports. Here is the device-tree part (.dtsi):

mac: ethernet@4a100000 {
compatible = "ti,am4372-cpsw","ti,cpsw";
reg = <0x4a100000 0x800
0x4a101200 0x100>;
interrupts = <GIC_SPI 40 IRQ_TYPE_LEVEL_HIGH
GIC_SPI 41 IRQ_TYPE_LEVEL_HIGH
GIC_SPI 42 IRQ_TYPE_LEVEL_HIGH
GIC_SPI 43 IRQ_TYPE_LEVEL_HIGH>;
#address-cells = <1>;
#size-cells = <1>;
ti,hwmods = "cpgmac0";
clocks = <&cpsw_125mhz_gclk>, <&cpsw_cpts_rft_clk>;
clock-names = "fck", "cpts";
status = "disabled";
cpdma_channels = <8>;
ale_entries = <1024>;
bd_ram_size = <0x2000>;
no_bd_ram = <0>;
rx_descs = <64>;
mac_control = <0x20>;
slaves = <1>;
active_slave = <0>;
cpts_clock_mult = <0x80000000>;
cpts_clock_shift = <29>;
ranges;

emac_arr = <&cpsw_emac1>;

fake_mdio: mdio@4a101000 {
compatible = "generic,fixed_mdio";
reg = <0x4a101000 0x100>;
#address-cells = <1>;
#size-cells = <0>;
// ti,hwmods = "davinci_mdio";
bus_freq = <1000000>;
// status = "disabled";

cpsw_emac1: slave@4a100300 {
compatible = "ethernet-phy-id0141.0cb0",
"ethernet-phy-ieee802.3-c22";
/* Filled in by U-Boot */
speed = <1000>;
full-duplex;
mac-address = [ 00 00 00 00 00 00 ];
reg = <0x00>;
};
};

// cpsw_emac0: slave@4a100200 {
// /* Filled in by U-Boot */
// mac-address = [ 00 00 00 00 00 00 ];
// //fixed-link = <0 1 1000 0 0>;
// //status = "disabled";
// //phy_id=0;
// };

// cpsw_emac1: slave@4a100300 {
// /* Filled in by U-Boot */
// mac-address = [ 00 00 00 00 00 00 ];
// //mii=0x01
// };

phy_sel: cpsw-phy-sel@44e10650 {
compatible = "ti,am43xx-cpsw-phy-sel";
reg= <0x44e10650 0x4>;
reg-names = "gmii-sel";
};
};

but then i get this error code:

0.192924] cpsw 4a100000.ethernet: Random MACID = aa:38:ba:31:ab:75
[ 0.199787]
ss_res->name=/ocp/ethernet@4a100000
[ 166.597483] Unable to handle kernel paging request at virtual address 4a100000
[ 166.605329] pgd = c0004000
[ 166.608232] [4a100000] *pgd=00000000
[ 166.612034] Internal error: Oops: 5 [#1] ARM
[ 166.616551] Modules linked in:
[ 166.619795] CPU: 0 PID: 1 Comm: swapper Not tainted 4.0.5-tim1531 #1
[ 166.626519] Hardware name: Generic AM43 (Flattened Device Tree)
[ 166.632782] task: df458000 ti: df456000 task.ti: df456000
[ 166.638505] PC is at cpsw_probe+0x278/0x87c
[ 166.642943] LR is at rpm_resume+0x7c/0x42c
[ 166.647279] pc : [<c02686b8>] lr : [<c0219784>] psr: 60000153
[ 166.647279] sp : df457d90 ip : 00000000 fp : 00000000
[ 166.659419] r10: df4bd800 r9 : 00000000 r8 : 5ca4a608
[ 166.664942] r7 : df4bd810 r6 : 00000000 r5 : decb4280 r4 : decb4000
[ 166.671847] r3 : 4a100000 r2 : 00000001 r1 : 00000004 r0 : 00000001
[ 166.678757] Flags: nZCv IRQs on FIQs off Mode SVC_32 ISA ARM Segment kernel
[ 166.686583] Control: 10c53c7d Table: 80004059 DAC: 00000015
[ 166.692661] Process swapper (pid: 1, stack limit = 0xdf456208)
[ 166.698830] Stack: (0xdf457d90 to 0xdf458000)

[ 166.876582] [<c02686b8>] (cpsw_probe) from [<c0213fa0>] (platform_drv_probe+0x48/0xa0)
[ 166.884974] [<c0213fa0>] (platform_drv_probe) from [<c0212930>] (really_probe+0xec/0x1ec)
[ 166.893640] [<c0212930>] (really_probe) from [<c0212a78>] (driver_probe_device+0x2c/0x4c)
[ 166.902302] [<c0212a78>] (driver_probe_device) from [<c0212b38>] (__driver_attach+0x60/0x84)
[ 166.911239] [<c0212b38>] (__driver_attach) from [<c02110cc>] (bus_for_each_dev+0x54/0xa0)
[ 166.919896] [<c02110cc>] (bus_for_each_dev) from [<c02125cc>] (driver_attach+0x1c/0x20)
[ 166.928379] [<c02125cc>] (driver_attach) from [<c02120f4>] (bus_add_driver+0xb0/0x1a8)
[ 166.936765] [<c02120f4>] (bus_add_driver) from [<c0212f7c>] (driver_register+0xa8/0xe8)
[ 166.945239] [<c0212f7c>] (driver_register) from [<c0213ef8>] (__platform_driver_register+0x54/0x5c)
[ 166.954834] [<c0213ef8>] (__platform_driver_register) from [<c05fc108>] (cpsw_init+0x14/0x18)
[ 166.963876] [<c05fc108>] (cpsw_init) from [<c00088b8>] (do_one_initcall_debug+0x40/0x8c)
[ 166.972443] [<c00088b8>] (do_one_initcall_debug) from [<c0008958>] (do_one_initcall+0x54/0x134)
[ 166.981663] [<c0008958>] (do_one_initcall) from [<c05e3e38>] (do_initcall_level+0x8c/0xa0)
[ 166.990420] [<c05e3e38>] (do_initcall_level) from [<c05e3e5c>] (do_initcalls+0x10/0x20)
[ 166.998901] [<c05e3e5c>] (do_initcalls) from [<c05e3e8c>] (do_basic_setup+0x20/0x28)
[ 167.007106] [<c05e3e8c>] (do_basic_setup) from [<c05e3ef4>] (kernel_init_freeable+0x54/0xec)
[ 167.016046] [<c05e3ef4>] (kernel_init_freeable) from [<c0436f34>] (kernel_init+0x8/0xf8)
[ 167.024626] [<c0436f34>] (kernel_init) from [<c000e508>] (ret_from_fork+0x14/0x2c)

it looks like the problem is the mac-entry of my device-tree (here the part of my .dts):

&mac {
status = "okay";
dual_emac;
};

&cpsw_emac1 {
phy_id = <&fake_mdio>, <0x00>;
phy-mode = "rgmii";
//phy-mode = "rgmii-txid";
dual_emac_res_vlan = <0>;
};

&phy_sel {
rmii-clock-ext;
};

could somebody help me out with this kind of issue? If there is a question for more detailed information, let me know.

Thanks

R Fritz

  • Hi,

    Direct MAC-to-MAC connection is not supported in the Linux SDK. You should use a switch on which the MAC port facing the AM437X can be configured in PHY mode. I will ask the Ethernet experts to look at this too.
  • Hi,

    thanks for the quick answer! Our switch is on-board. But my problem is, how can I configure the DSA-Driver to port0 in my device-tree. Now I did this:



    mac: ethernet@4a100000 {
    compatible = "ti,am4372-cpsw","ti,cpsw";
    reg = <0x4a100000 0x800
    0x4a101200 0x100>;
    interrupts = <GIC_SPI 40 IRQ_TYPE_LEVEL_HIGH
    GIC_SPI 41 IRQ_TYPE_LEVEL_HIGH
    GIC_SPI 42 IRQ_TYPE_LEVEL_HIGH
    GIC_SPI 43 IRQ_TYPE_LEVEL_HIGH>;
    #address-cells = <1>;
    #size-cells = <1>;
    ti,hwmods = "cpgmac0";
    clocks = <&cpsw_125mhz_gclk>, <&cpsw_cpts_rft_clk>;
    clock-names = "fck", "cpts";
    // fixed-link = <0 1 1000 0 0>;
    status = "disabled";
    cpdma_channels = <8>;
    ale_entries = <1024>;
    bd_ram_size = <0x2000>;
    no_bd_ram = <0>;
    rx_descs = <64>;
    mac_control = <0x20>;
    slaves = <1>;
    active_slave = <0>;
    cpts_clock_mult = <0x80000000>;
    cpts_clock_shift = <29>;
    ranges;

    emac_arr = <&cpsw_emac1>;


    davinci_mdio: mdio@4a101000 {
    compatible = "ti,am4372-mdio","ti,davinci_mdio";
    reg = <0x4a101000 0x100>;
    #address-cells = <1>;
    #size-cells = <0>;
    ti,hwmods = "davinci_mdio";
    bus_freq = <1000000>;
    // status = "disabled";

    cpsw_emac1: slave@4a100300 {
    compatible = "ethernet-phy-id0141.0cb0",
    "ethernet-phy-ieee802.3-c22";
    /* Filled in by U-Boot */
    speed = <1000>;
    full-duplex;
    mac-address = [ 00 00 00 00 00 00 ];
    reg = <0x00>;
    };

    cpsw_emac0: slave@4a100200 {
    /* Filled in by U-Boot */
    mac-address = [ 00 00 00 00 00 00 ];
    //fixed-link = <0 1 1000 0 0>;
    //status = "disabled";
    //phy_id=0;
    };
    };

    // cpsw_emac0: slave@4a100200 {
    // /* Filled in by U-Boot */
    // mac-address = [ 00 00 00 00 00 00 ];
    // //fixed-link = <0 1 1000 0 0>;
    // //status = "disabled";
    // //phy_id=0;
    // };

    // cpsw_emac1: slave@4a100300 {
    // /* Filled in by U-Boot */
    // mac-address = [ 00 00 00 00 00 00 ];
    // //mii=0x01
    // };

    phy_sel: cpsw-phy-sel@44e10650 {
    compatible = "ti,am43xx-cpsw-phy-sel";
    reg= <0x44e10650 0x4>;
    reg-names = "gmii-sel";
    };
    };

    dsa@0 {
    compatible = "marvell,dsa";
    #address-cells = <2>;
    #size-cells = <0>;

    interrupts = <10>;
    dsa,ethernet = <&cpsw_emac0>;
    dsa,mii-bus = <&davinci_mdio>;

    switch@0 {
    #address-cells = <1>;
    #size-cells = <0>;
    reg = <0x17 0>; // MDIO address 24dezimal, switch 0 in tree

    port@0 {
    reg = <0x18>; // hier vielleicht den offset mit 24 berücksichtigen. absolute mdio-adresse: 0x18
    label = "port0";
    //phy-handle = <&phy0>;
    };

    port@1 {
    reg = <0x19>;
    label = "port1";
    //phy-handle = <&phy1>;
    };

    port@5 {
    reg = <0x1D>;
    label = "cpu";
    };
    };
    };



    But the davinci-mdio driver is looking for a phy at port0:

    [ 38.767985] mdio_bus 4a101000.mdio: /ocp/ethernet@4a100000/mdio@4a101000/slave@4a100200 has invalid PHY address

    [ 38.778769] mdio_bus 4a101000.mdio: scan phy slave at address 1

    ......

    [ 38.973032] mdio_bus 4a101000.mdio: scan phy slave at address 31



    the kernel is searching for a phy, but I have a switch instead.

    Do you have some idea, why this is happening?

    thanks
  • There were some changes in the cpsw driver necessary to support a PHY-less setup. It looks like you are using a mainline kernel rather than a TI processors SDK. Right now I don't see the patches I expected in the 4.1 tree. Could you post the patches you have done?
  • Hi,

    I didn´t patch the cpsw-driver of TI. I have the linux kernel-version 4.0.5. here is a link which cpsw.c code I´m using:


    http://lxr.free-electrons.com/source/drivers/net/ethernet/ti/cpsw.c?v=4.0

    hope that helps. Thanks

  • If you have been able to use DSA with 4376 can you provide your solution as example?