参考:Rockchip_Developer_Guide_Linux_GMAC_CN
Rockchip_Developer_Guide_Linux_GMAC_Mode_Configuration_CN
RK3588 平台默认支持的是RTL8211f
代码路径:
kernel/drivers/net/phy/realteck.c
kernel/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c 和dwmac-rk.c
在代码中默认dts配置如下:
rk3588-firefly-port.dtsi
&gmac1 {
/* Use rgmii-rxid mode to disable rx delay inside Soc */
phy-mode = "rgmii-rxid";
clock_in_out = "output";
snps,reset-gpio = <&gpio3 RK_PB7 GPIO_ACTIVE_LOW>;
snps,reset-active-low;
/* Reset time is 20ms, 100ms for rtl8211f */
snps,reset-delays-us = <0 20000 100000>;
pinctrl-names = "default";
pinctrl-0 = <&gmac1_miim
&gmac1_tx_bus2
&gmac1_rx_bus2
&gmac1_rgmii_clk
&gmac1_rgmii_bus>;
tx_delay = <0x42>;
//rx_delay = <0x4f>;
phy-handle = <&rgmii_phy1>;
status = "disbaled";
};
rk3588-firefly-aio-3588q.dtsi
/* gmac1 */
&gmac1 {
snps,reset-gpio = <&gpio3 RK_PB7 GPIO_ACTIVE_LOW>;
tx_delay = <0x4f>;
status = "okay";
};
&gmac1_tx_bus2{
rockchip,pins =
/* gmac1_txd0 */
<3 RK_PB3 1 &pcfg_pull_up_drv_level_6>,
/* gmac1_txd1 */
<3 RK_PB4 1 &pcfg_pull_up_drv_level_6>,
/* gmac1_txen */
<3 RK_PB5 1 &pcfg_pull_none>;
};
&gmac1_rgmii_bus{
rockchip,pins =
/* gmac1_rxd2 */
<3 RK_PA2 1 &pcfg_pull_none>,
/* gmac1_rxd3 */
<3 RK_PA3 1 &pcfg_pull_none>,
/* gmac1_txd2 */
<3 RK_PA0 1 &pcfg_pull_up_drv_level_6>,
/* gmac1_txd3 */
<3 RK_PA1 1 &pcfg_pull_up_drv_level_6>;
};
以上是rtl8211f 千兆以太网的参数配置,主要有以下几个配置需要注意:
clock_in_out: clock_in_out:
description:
For RGMII, it must be "input", means main clock(125MHz)
is not sourced from SoC's PLL, but input from PHY.
For RMII, "input" means PHY provides the reference clock(50MHz),
"output" means GMAC provides the reference clock.
此项需要确认MAC使用的是PHY的clk还是mac的clk,根据自己原理图确认。
参考:kernel/Documentation/devicetree/bindings/net/rockchip-dwmac.yaml
二、zslxxx phy的修改:
1、需要增加对应的通用phy代码:kernel/drivers/net/phy/micrel.c
2、测量晶振25M时钟是否存在,测量VCC电压是否正常,是否需要上拉电阻等。需要注意phy的地址是多少,在这里是1,。
&mdio1 {
rgmii_phy1: phy@1 {
compatible = "ethernet-phy-ieee802.3-c22";
reg = <0x1>;
};
};
3、修改dts配置,根据原理图确认mac的时钟是否由phy提供,此时clock_in_out修改修改为input或者output。
4、确认是否phy已经识别到了,dmesg| grep eth进行查看。
5、ifconfig eth0 xxx up配置ip是否正常,与电脑连接,互相ping是否通,网线可以尝试换一根。
ifconfig查看rx package和tx package是否数据一直在增加。