Microchip-Ethernet / EVB-KSZ9477

Repository for using Microchip EVB-KSZ9477 board. Product Supported: KSZ9477, KSZ9567, KSZ9897, KSZ9896, KSZ8567, KSZ8565, KSZ9893, KSZ9563, KSZ8563, LAN9646, Phys(KSZ9031/9131, LAN8770
76 stars 78 forks source link

How to use setup_sw.c under the EVB-KSZ9477\KSZ\linux-drivers\ksz9897\linux-4.9\doc #25

Open majicjq opened 5 years ago

majicjq commented 5 years ago

I am using KSZ9477 port6 as phy in my network, port1 and port2 as ports for connetction. |——————-————| |——————-————| | e000b000—|— rgmii—|—port6 port1
| ZTNQ | | KSZ9477 port2
|——————-—--|--—| |—-|————--————| |_SPI___| I use linux kernel 4.9 in my device, i add source codes under KSZ\linux-drivers\ksz9897\linux-4.9\drivers\net\ethernet\micrel into my kernel tree, and device tree: &gem0 { phy-mode = "rgmii-id"; status = "okay"; xlnx,ptp-enet-clock = <0x7f28150>; fixed-link = <0 1 1000 0 0>; }; &spi0 { is-decoded-cs = <0>; num-cs = <2>; status = "okay"; ksz9477: ksz9477@0 { compatible = "microchip,ksz9477"; reg = <0>; phy-mode = "rgmii-id"; spi-max-frequency = <44000000>; spi-cpha; spi-cpol; interrupt-parent = <&intc>; interrupts = <0 19 8>; 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@6 {
            reg = <6>;
            label = "cpu";
            ethernet = <&gem0>;
            fixed-link {
                speed = <1000>;
                full-duplex;
            };
        };
    };
};

}; when booting there is some log for network: ksz9897 spi1.0: chip id 0x00947700 libphy: Switch MII bus: probed libphy: Fixed MDIO Bus: probed libphy: MACB_mii_bus: probed macb e000b000.ethernet eth0: Cadence GEM rev 0x00020118 at 0xe000b000 irq 30 (00:0a:35:00:1e:53) Generic PHY fixed-0:00: attached PHY driver [Generic PHY] (mii_bus:phy_addr=fixed-0:00, irq=-1) e1000e: Intel(R) PRO/1000 Network Driver - 3.2.6-k e1000e: Copyright(c) 1999 - 2015 Intel Corporation. Configuring network interfaces... IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready udhcpc (v1.24.1) started Sending discover... macb e000b000.ethernet eth0: link up (1000/Full) IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready but it seem not work, there is no sysfs in /sys/class/net/eth0 for ksz9477 like "sw1"、"sw2" etc. I don't wether other components like dsa and bridge should be added into my kernel tree? And I found functions in setup_sw.c are useful to setup ksz9477, but is seem dose not in the driver of ksz9477, how to use this?