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.

AM3354: CPSW switch configuration failure

Part Number: AM3354

CPSW switch configuration failure (4.19.38) - cant get it into switch mode. ETH0 and ETH1 work fine, just not the extra switch port. Original configuration came from Linux 3.12 version device tree that worked perfectly. Now, not so much:

Using KSZ8041 Ethernet phy and KSZ886X Switch on an Exor  "USOM1".

Kernel boot shows:

[ 1.264511] davinci_mdio 4a101000.mdio: phy[0]: device 4a101000.mdio:00, driver Micrel KSZ8041
[ 1.273658] davinci_mdio 4a101000.mdio: phy[1]: device 4a101000.mdio:01, driver Micrel KSZ886X Switch
[ 1.283381] davinci_mdio 4a101000.mdio: phy[2]: device 4a101000.mdio:02, driver Micrel KSZ886X Switch
[ 1.293036] davinci_mdio 4a101000.mdio: phy[3]: device 4a101000.mdio:03, driver Micrel KSZ886X Switch
[ 1.302689] davinci_mdio 4a101000.mdio: phy[5]: device 4a101000.mdio:05, driver Micrel KSZ8041

[ 1.312511] cpsw 4a100000.ethernet: Detected MACID = 68:c9:0b:b4:8c:df
[ 1.319487] cpsw 4a100000.ethernet: initialized cpsw ale version 1.4
[ 1.326114] cpsw 4a100000.ethernet: ALE Table size 1024
[ 1.331614] cpsw 4a100000.ethernet: cpts: overflow check period 500 (jiffies)
[ 1.339907] cpsw 4a100000.ethernet: cpsw: Detected MACID = 68:c9:0b:b4:8c:e1

Relevant device tree entries are:

mac: ethernet@4a100000 {
compatible = "ti,am335x-cpsw","ti,cpsw";
ti,hwmods = "cpgmac0";
clocks = <&cpsw_125mhz_gclk>, <&cpsw_cpts_rft_clk>;
clock-names = "fck", "cpts";
cpdma_channels = <8>;
ale_entries = <1024>;
bd_ram_size = <0x2000>;
mac_control = <0x20>;
slaves = <2>;
active_slave = <1>;
cpts_clock_mult = <0x80000000>;
cpts_clock_shift = <29>;
reg = <0x4a100000 0x800
0x4a101200 0x100>;
#address-cells = <1>;
#size-cells = <1>;
/*
* c0_rx_thresh_pend
* c0_rx_pend
* c0_tx_pend
* c0_misc_pend
*/
interrupts = <40 41 42 43>;
ranges;
syscon = <&scm_conf>;
dual_emac;
status = "disabled";

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

cpsw_emac0: slave@4a100200 {
/* Filled in by U-Boot */
mac-address = [ 00 00 00 00 00 00 ];
};

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

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

...

&mac {
pinctrl-names = "default", "sleep";
pinctrl-0 = <&cpsw_default>;
pinctrl-1 = <&cpsw_sleep>;
/*active_slave = <0>;*/
status = "okay";
};

&davinci_mdio {
pinctrl-names = "default", "sleep";
pinctrl-0 = <&davinci_mdio_default>;
pinctrl-1 = <&davinci_mdio_sleep>;
status = "okay";
};

&cpsw_emac0 {
phy_id = <&davinci_mdio>, <1>;
phy-mode = "rmii";
dual_emac_res_vlan = <1>;
ifname = "eth1";
};

&cpsw_emac1 {
phy_id = <&davinci_mdio>, <5>;
phy-mode = "rmii";
dual_emac_res_vlan = <2>;
ifname = "eth0";
};

&phy_sel {
rmii-clock-ext;
};

I played with all settings from "dual-emac" (which when I removed, I lost an Ethernet port - so I put it back). I am also not sure of "slaves" and "active-slaves" definitions, cant seem to find a definitive resource...

Any help please. Let me know if there is more info needed.

  • Hi,

    The way you have the values for slaves and dual_emac are correct. I want to confirm though that you are saying that eth0 and eth1 are working correctly, this means you get IP addresses for both ports and they are on different sub nets?

    TI is not able to support external switches so I will not be able to help with why the Micrel switch is not working. I am not following the topology of how the CPSW ports are connecting. Could you please attach a schematic snippet showing the networking on your board?

    Best Regards,

    Schuyler

  • The switch is fed by RMII1_* lines from the proc as well as MDIO and MDC (I cant get a copy of the schematic)

    The mac/phy is fed by RMII2_* with MDIO and MDC..

    My biggest problem other than the switch it is not working as a hub, is understanding the components "mac", "cpsw_emac0/1", "slaves", "active_slaves".

    So would the Micrel switch normally work as a hub on the two slave ports feeding the host port on the proc? I thought dual_emac would make that not work?

    Sorry, but most of the docs seem to assume a very high level of understanding of Ethernet parts, and I thought that building/modifying the kernel and drivers was complicated enough. 

    Thanks for any info.

  • eth0 and eth1 are working correctly, and I  get IP addresses for both ports and they are on different sub nets. Yes.

    They are set up via /etc/network/interfaces file, and they both function (via ping and ssh).

    One port is on the the switch, the other is on the mac/phy. That darned second switch port is the problem.

    Sorry - forgot to address that.

  • Are there any other AM335x boards that use a similar config (1 mac/phy) and a switch? Do they all use DUAL_EMAC mode? I am still looking for a definition of the DUAL_EMAC and which mode it is required for... 

  • Hi,

    There are not any TI EVM boards that use an external switches at the moment which is one of the reasons why TI does not support external switches attached to the SOC on the either CPSW or PRU ethernet ports. 

    Dual EMAC mode is a configuration that TI uses to turn the CPSW switch into a dual EMAC. The configuration essentially disables the ALE between the two external ports and uses VLANs internal to the switch to emulate the dual EMAC mode so it no longer acts as a switch. The internal VLANs are used to keep track of which port the packets ingressed/egressed on. Hopefully this helps explain the dual EMAC mode.

    Since the 3.14 kernel was working on your board the one recommendation I have is if the Micrel drivers changed and were updated in the filesystem. Since this is not supported by TI there may have been changes that were done locally at your company to the TI drivers or other drivers that may need to integrated with the current kernel that you are using.

    Best Regards,

    Schuyler

  • Thanks for the info.

    So  just discovered if I remove "dual_emac" from the tree, My micrel switch chip and the micrel mac/phy now both act as a switch (but the second phy on the micrel switch is dead). So dual_emac separates the two chips with "dual macs", but that means my switch is working, but not as a hub or switch...

    Is that the way this is supposed to work with dual_emac ?

    Now to understand the "slave*" configurations.

    Confused is an understatement.

    Thanks again for your insight.

  • Hi,

    I was reviewing threads and I see this one is still open. I thought I had posted an answer but I don't see my answer in the thread history. Is this still and issue?

    The dual emac flag only relates to how the internal AM3354 TI switch is configured. With an external switch such as your design I think you would want dual emac enalbed since one port of the CPSW probably has a phy connected to a connector to go off board and the other CPSW port connected to the switch. 

    Best Regards,

    Schuyler

  • Once I realized that the dual_emac was in reference to how the CPSW related to the two physical network chips and had nothing to do with the actual switch chip, the light bulb came on above my head. Also, turning off dual_emac forced the two physically different chips to work as a switch. That concept eluded me until that point.

    I managed to get the second port on the switch working even when nothing was plugged into the first port by modifying the phy driver for my switch chip. So now all ports on the switch say they are up even when no cable is plugged in.

    So maybe my slowness will help others confused by the information out there, who have not worked on ethernet subsystems before.