RK系列以太网卡驱动学习笔记

RK系列芯片已经内置了以太网控制器,所以只需要搭配一颗以太网 PHY 芯片就可以实现以太网功能!

所以不管是PHY 厂家有多少,基本的功能是都是使用 RK 的驱动配置基本就可以实现,就是调用RK 的通用的驱动接口。

10/100M以太网 PHY 与 MAC 之间的接口主要有 MII 和 RMII。而10/100/1000M 以太网 PHY 与MAC 之间的接口主要有  RGMII。

在用的比较多的 RK3288  RK3399 的芯片上面都是支持  RMII  和 RGMII  接口的,也就是都可以支持 100 M 网卡,或者 1000M网卡

 

一、RK系列以外网卡驱动调试

1、查看以太网设备是否打开;

 

 

 

Device Drivers ->

[*]      Network device support ->

-*-     PHY Device support and infrastructure->

<*>        Driver for Rockchip Ethernet PHYs

 

 

 

2、修改 dts 文件,看你是支持什么接口的,也就是你只有 100 M 网卡,还是 1000M 网卡即可。

修改 Y:\RK3399\kernel\arch\arm64\boot\dts\rockchip\ rgf-rk3399.dts

 

3、千兆网(1000M PHY)配置

 

       clkin_gmac: external-gmac-clock {

              compatible = "fixed-clock";

              clock-frequency = <125000000>;   /* PHY供给GMAC的时钟大小 */

              clock-output-names = "clkin_gmac";

              #clock-cells = <0>;

       };

 

 

 

&gmac {

       phy-supply = <&vcc_phy>;                                    /* PHY供电 */

       phy-mode = "rgmii";                                                     /* PHY接口 */

       clock_in_out = "input";                                            /*时钟方向 */

       snps,reset-gpio = <&gpio3 15 GPIO_ACTIVE_LOW>;  /* 复位IO及有效电平 */

       snps,reset-active-low;

       snps,reset-delays-us = <0 10000 50000>;

       assigned-clocks = <&cru SCLK_RMII_SRC>;

       assigned-clock-parents = <&clkin_gmac>;

       pinctrl-names = "default";

       pinctrl-0 = <&rgmii_pins>;

       tx_delay = <0x28>;                                                        /* TX线上的延时值 */

       rx_delay = <0x11>;                                                        /* RX线上的延时值 */

       status = "okay";

};

 

 

查看原理图里供电、复位脚是否正确

PMU

 

 

 

PHY_RST

 

 

 

 

然后就可以查看网卡是否存在

rk3399:/ # ifconfig

 

 

4、百兆网(100M PHY)配置

 

clkin_gmac: external-gmac-clock {

              compatible = "fixed-clock";

              clock-frequency = <50000000>;  //时钟 100M 使用 rmii 接口固定是 50M

              clock-output-names = "clkin_gmac";

              #clock-cells = <0>;

       };

 

&gmac {

       phy-supply = <&vcc_phy>;

       phy-mode = "rmii";  // 说明接口是什么 PHY

       clock_in_out = "output"; // 是 output 的时候,就由 RK芯片 提供 50M ,1000M 的是 input

       snps,reset-gpio = <&gpio3 15 GPIO_ACTIVE_LOW>; // 硬件接口看 原理图

       snps,reset-active-low;

       snps,reset-delays-us = <0 10000 50000>;

       assigned-clocks = <&cru SCLK_RMII_SRC>;

       assigned-clock-parents = <&clkin_gmac>;

       pinctrl-names = "default";

       pinctrl-0 = <&rgmii_pins>;

 

posted @ 2020-10-14 22:06  柳塘风淡  阅读(3785)  评论(0编辑  收藏  举报