configure the ksz8765 5 port Ethernet switch

cancel
Showing results for 
Search instead for 
Did you mean: 

configure the ksz8765 5 port Ethernet switch

9,817 Views
pavansingpatil
Contributor I

Hello,

we have custom board based on imx6sx connected with ksz8765 switch over spi bus using rgmii interface. we have enabled the fixed link driver in kernel and also configure same in dts file. Port 5 of the switch is connected to imx6sx MAC interface.

device tree configuration:

&fec1 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_enet1>;
phy-mode = "mii";
phy-reset-gpios = <&gpio1 25 GPIO_ACTIVE_LOW>;
fixed-link = <0 1 100 0 0>;
phy-supply = <&reg_vref_3v3>;
status = "okay";
};

kernel logs:

fec 2188000.ethernet (unnamed net_device) (uninitialized): Invalid MAC address: 00:00:00:00:00:00
fec 2188000.ethernet (unnamed net_device) (uninitialized): Using random MAC address: 7e:20:8b:ff:4b:22
libphy: fec_enet_mii_bus: probed
fec 2188000.ethernet eth0: registered PHC device 0
fec 2188000.ethernet eth0: Freescale FEC PHY driver [Generic PHY] (mii_bus:phy_addr=fixed-0:00, irq=-1)
fec 2188000.ethernet eth0: Link is Up - 100Mbps/Full - flow control off

we could see RX packets are 0, and Tx packet are also in queue.

eth0 Link encap:Ethernet HWaddr XX:XX:XX:XX:XX:XX 
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:7538 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:828904 (809.4 KiB)

there is spi driver to configure switch over spi for ksz8995...but it should work for ksz8765 after minor modification as chip id and family id is same.

linux-fslc/spi_ks8995.c at 4.1-2.0.x-imx · Freescale/linux-fslc · GitHub 

spi-ks8995 spi3.2: chip family id mismatch: expected 0x87 but 0x00 read
mx51_ecspi_clkdiv: fin: 60000000, fspi: 48000000, post: 0, pre: 1
mx51_ecspi_clkdiv: fin: 60000000, fspi: 48000000, post: 0, pre: 1
spi-ks8995 spi3.2: unsupported chip id for KSZ8795 family: 0x00

but it always reads 0.

Thanks in advance.

Labels (2)
0 Kudos
23 Replies

294 Views
Yang2021
Contributor I

I have same issue。RX  is 0.Who have right way?

0 Kudos

2,985 Views
emintolgasivri
Contributor II

Hi everyone

I am using ksz8895 and spi .My connection is as below.ksz8895.png

Should I have to use dsa drivers.Is my dts file correct?

&ecspi1{
    id = <1>;
    status = "okay";
    ksz8895: ksz8895@0 {
        compatible = "microchip,ksz8895";
        reg = <0>;

        spi-max-frequency = <40000000>;
        spi-cpha;
        spi-cpol;
        status = "okay";
        ports {
            #address-cells = <1>;
            #size-cells = <0>;
            port@0 {
                reg = <0>;
                label = "lan1";
            };
            port@1 {
                reg = <1>;
                label = "lan2";
            };
            port@2 {
                reg = <2>;
                label = "lan3";
            };
            port@3 {
                reg = <3>;
                label = "lan4";
            };
            port@4 {
                reg = <4>;
                label = "cpu";
                ethernet = <&ethphy0>;
                fixed-link {
                    speed = <100>;
                    full-duplex;
                };
            };
        };
    };
};

&fec1 {
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_enet1>;
    //pinctrl-assert-gpios = <&gpio7 15 GPIO_ACTIVE_LOW>;
    clocks = <&clks IMX7D_ENET_AXI_ROOT_CLK>,
        <&clks IMX7D_ENET_AXI_ROOT_CLK>,
        <&clks IMX7D_ENET1_TIME_ROOT_CLK>,
        <&clks IMX7D_PLL_ENET_MAIN_50M_CLK>,
        <&clks IMX7D_ENET1_REF_ROOT_CLK>;
        clock-names = "ipg", "ahb", "ptp","enet_clk_ref", "no_enet_out";
    assigned-clocks = <&clks IMX7D_ENET1_TIME_ROOT_SRC>,
              <&clks IMX7D_ENET1_TIME_ROOT_CLK>;
    assigned-clock-parents = <&clks IMX7D_PLL_ENET_MAIN_100M_CLK>;
    assigned-clock-rates = <0>, <100000000>;
    phy-mode = "rmii";
    phy-handle = <&ethphy0>;
    fsl,magic-packet;
    status = "okay";
    
    fixed-link {
      speed = <100>;
      full-duplex;
    };
    /*mdio {*/
        #address-cells = <1>;
        #size-cells = <0>;
        
        ethphy0: ethernet-phy@0 {
            compatible = "microchip,ksz8895";
            reg = <0>;
        };
        ethphy1: ethernet-phy@1 {
            compatible = "microchip,ksz8895";
            reg = <1>;
        };
    /*};*/
};

&fec2 {
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_enet2>;
    clocks = <&clks IMX7D_ENET_AXI_ROOT_CLK>,
        <&clks IMX7D_ENET_AXI_ROOT_CLK>,
        <&clks IMX7D_ENET1_TIME_ROOT_CLK>,
        <&clks IMX7D_PLL_ENET_MAIN_50M_CLK>,
        <&clks IMX7D_ENET1_REF_ROOT_CLK>;
        clock-names = "ipg", "ahb", "ptp","enet_clk_ref", "no_enet_out";
    assigned-clocks = <&clks IMX7D_ENET2_TIME_ROOT_SRC>,
              <&clks IMX7D_ENET2_TIME_ROOT_CLK>;
    assigned-clock-parents = <&clks IMX7D_PLL_ENET_MAIN_100M_CLK>;
    assigned-clock-rates = <0>, <100000000>;
    phy-mode = "rmii";
    phy-handle = <&ethphy1>;
    fsl,magic-packet;
    status = "okay";
};

0 Kudos

3,019 Views
pavansingpatil
Contributor I

Hi,

Yes, I have resolved the issue.

check the sys directory  /sys/bus/mdio_bus/devices/fixed-0\:00 you should see something like this.

you should configure you switch properly to make it work in phy mode either you put strap in hardware options or write switch register using spi bus.9

is it configure in MII mode? is it configure in MAC(CPU)-PHY(switch) connection?

Regards,

Pavan

0 Kudos

3,019 Views
lvmh
Contributor I

Hi  pavansingpatil,

I use the RMII and spi mode, the manual says

0 Kudos

3,019 Views
lvmh
Contributor I

Hi  pavansingpatil,

I use the RMII and spi mode, the manual says:

MAC/PHY mode in RMII is different than MAC/PHY mode in MII. There is no strap pin and register configuration request
in RMI. Follow the signals connection in Table 3-11.TIM图片20180105164426.png

0 Kudos

3,019 Views
lvmh
Contributor I

Hi  pavansingpatil,

Find this directory with the following information

TIM图片20180105171456.png

Can you give me some advice?thanks 

0 Kudos

3,019 Views
pavansingpatil
Contributor I

Hi,

what issue exactly are you facing? Can you please elaborate?

--Pavan

0 Kudos

3,019 Views
lvmh
Contributor I

Hi pavansingpatil,

we could see RX packets are 0, and Tx packet are also in queue.

eth1 Link encap:Ethernet HWaddr 08:00:3E:26:0A:5C
inet addr:192.168.1.127 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::a00:3eff:fe26:a5c%1996281552/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:2722 dropped:0 overruns:0 frame:2722
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:648 (648.0 B)

The information above shows an error in the rx package

0 Kudos

3,019 Views
linwangzhao
Contributor II

Hi  lvmh,

I have a similar problem in debugging KSZ8895RQXCA, Can you give me a reference? Thanks.

root@imx6qsabresd:~# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 56:2e:8f:d5:53:a7
inet addr:192.168.1.4 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::542e:8fff:fed5:53a7/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:1123 dropped:0 overruns:0 frame:1123
TX packets:280 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:137336 (134.1 KiB)

0 Kudos

3,019 Views
lvmh
Contributor I

Hi ,

请检查cpu端的网口gpio ER引脚是否接下拉电阻,或者代码配置成下拉.

lvmh@qiyangtech.com

0 Kudos

3,019 Views
suifengrumeng
Contributor II

你好,我现在应该遇到了跟你一样的问题。目前我也是imx6生成的eth0不能够ping通两个下行口,CPU接口是RGMII,与交换机芯片KSZ8775的通讯接口是spi接口。查看sys目录已经生成:

root@imx6qdlsolo:~# ls /sys/bus/spi/devices/spi5.0/
driver power subsystem sw0 sw2 sw4
modalias registers sw sw1 sw3 uevent

root@imx6qdlsolo:~# ls /sys/bus/mdio_bus/devices/fixed-0\:00
driver phy_id power subsystem uevent

运行ping命令一段时间后,得到如下的结果:

root@imx6qdlsolo:~#
root@imx6qdlsolo:~# ping 192.168.1.1
PING 192.168.1.1 (192.168.1.1): 56 data bytes
^C
--- 192.168.1.1 ping statistics ---
655 packets transmitted, 0 packets received, 100% packet loss
root@imx6qdlsolo:~#
root@imx6qdlsolo:~#
root@imx6qdlsolo:~# ifconfig
eth0 Link encap:Ethernet HWaddr 6A:E2:44:00:BE:96
inet addr:192.168.1.111 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::68e2:44ff:fe00:be96/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1513 errors:0 dropped:0 overruns:0 frame:0
TX packets:891 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:129433 (126.3 KiB) TX bytes:88685 (86.6 KiB)

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:718 errors:0 dropped:0 overruns:0 frame:0
TX packets:718 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:79872 (78.0 KiB) TX bytes:79872 (78.0 KiB)

不知道这些能不能反应一些问题呢?求点播。。。。。。。我现在不确定是软件问题还是硬件问题,不知道这个有没有什么办法确定呢?我测量CPU的TX信号都是有的

0 Kudos

2,992 Views
zhangzhencai
Contributor II

你好,你们dts中是怎么配置的?

0 Kudos

2,985 Views
suifengrumeng
Contributor II

我是按照楼主那样配置的,不知道能否加个联系方式讨论下?我目前也是卡在这里了,QQ:541237941

0 Kudos

3,019 Views
linwangzhao
Contributor II

Hi lvmh,

          我向你的邮箱(lvmh@qiyangtech.com)发了邮件,请查收,谢谢!

0 Kudos

3,019 Views
pavansingpatil
Contributor I

Hi, 

in my case i had hardware issue. cross verify your schematics with micrel LAN service.

fixed-link and fec driver is enough to get Ethernet communication working.

Regards,

--Pavan

0 Kudos

3,019 Views
lvmh
Contributor I

Hi,

What's wrong with your hardware?Can you give me a reference?

0 Kudos

3,019 Views
lvmh
Contributor I

Hi,

My problem now is that ksz8794 can be fixed to the CPU, but the network doesn't ping.

0 Kudos

3,019 Views
igorpadykov
NXP TechSupport
NXP TechSupport

Hi pavansingpatil

from log: "spi-ks8995 spi3.2: unsupported chip id for KSZ8795 family: 0x00"

seems driver did not receive correct data and one can check with oscilloscope

what data actually sent from ksz8765.

Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

3,019 Views
pavansingpatil
Contributor I

right driver is not getting correct data, but i guess driver is just for switch configuration using spi bus.

Do you think Ethernet driver fec_main.c need any modification to detect switch phy using spi bus? or it should work with fixed link driver?

0 Kudos

3,019 Views
pavansingpatil
Contributor I

we are able to resolve spi communication issue, now can read/write switch resistor using spi bus. the problem was fec driver ignores the reset flag polarity and always works on active low.

we have configured switch in mii mode and now we see proper 25 MHz clk on ENET_RX_CLK  and RX_ENET1_TX_CLK .

eth0   Link encap:Ethernet  HWaddr XX::XX:XX:01:1b:b9 
          inet6 addr: fe80::204:9fff:fe01:1bb9/64 Scope:Link
          inet6 addr: fd00:1:2:3:204:9fff:fe01:1bb9/64 Scope:Global
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4189 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:460514 (449.7 KiB)

lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:163 errors:0 dropped:0 overruns:0 frame:0
          TX packets:163 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:12460 (12.1 KiB)  TX bytes:12460 (12.1 KiB)

imx6 side MAC works fine as I tried loopback and and also localhost ping as you can see lo interface statistics. But we are still having issue with communication as you can see TX packets on eth0 interface but no response from phy. As mentioned earlier we are using fixed link driver as phy is not connected using normal mdio bus.

This is my dmesg output

## dmesg | grep fec
libphy: fec_enet_mii_bus: probed
fec 2188000.ethernet eth0: registered PHC device 0
fec 2188000.ethernet eth0: Freescale FEC PHY driver [Generic PHY] (mii_bus:phy_addr=fixed-0:00, irq=-1)
fec 2188000.ethernet eth0: Link is Up - 100Mbps/Full - flow control off 

we have verified Clk and Tx data signal on oscilloscope and we some data going out on TX data lines.

so is there any modification required in fec driver to make it work? Thanks in advance.

0 Kudos