zturn开发板网口驱动的注册过程

z-turn网口设备树:


在zynq-7000.dtis文件:
gem0: ethernet@e000b000 {
compatible = "xlnx,ps7-ethernet-1.00.a";
reg = <0xe000b000 0x1000>;
status = "disabled";
interrupts = <0 22 4>;
clocks = <&clkc 13>, <&clkc 30>;
clock-names = "ref_clk", "aper_clk";
local-mac-address = [00 0a 35 00 00 00];
xlnx,has-mdio = <0x1>;
#address-cells = <1>;
#size-cells = <0>;
};


在zynq-zturn.dts将gen0设备修改成:
&gem0 {
    compatible = "cdns,gem";
    reg = <0xe000b000 0x4000>;
    status = "okay";
    interrupts = <0 22 4>;
    interrupt-parent = <&intc>;
    clocks = <&clkc 30>, <&clkc 30>, <&clkc 13>;
    clock-names = "pclk", "hclk", "tx_clk";
    phy-mode = "rgmii-id";
    phy-handle = <&phy0>;
    phy0: phy@0 {
        compatible = "atheros,ar8035";
        device_type = "ethernet-phy";
        reg = <0>;
    };
};


所以网口使用的是cadence的驱动,驱动源码位于drivers/net/ethernet/cadence/macb.c.
在macb_probe函数中分配net_device设备并初始化,设置mdio的clk:
/* Set MII management clock divider */
config = macb_mdc_clk_div(bp);
config |= macb_dbw(bp);
macb_writel(bp, NCFGR, config);
然后调用macb_mii_init进行phy设备的初始化.
phy设备挂在mdio bus下,所以先调用of_mdiobus_register注册了mdio bus设备,接着调用of_mdiobus_register_phy注册phy设备,
在of_mdiobus_register注册了phy设备之后,调用macb_mii_probe检测phy设备是否已经跟驱动关联,如果没有,调用phy_connect_direct
将phy设备的跟generic phy驱动关联.


函数调用关系:
macb_mii_init phy设备的初始化
-->of_mdiobus_register 注册mdio_bus
-->of_mdiobus_register_phy 注册phy_device,如果相关phy_driver驱动已经注册,测将phy_driver跟phy_device关联
-->macb_mii_probe 
如果phy_devide还没有驱动
-->phy_connect_direct 将phy_device跟generic phy驱动关联


所以z-turn开发板的phy芯片驱动是drivers\net\phy\phy_device.c.
内核相关配置:
Device Drivers > Network device support > Ethernet driver support 
[*]   Cadence devices                                                                 
<*>     Cadence MACB/GEM support


Device Drivers > Network device support
-*-   PHY Device support and infrastructure  --->  上面的选上后,该项自动选上,里边的其他驱动不用选

你可能感兴趣的:(zturn开发板网口驱动的注册过程)