RK3588 调试 phy

参考:Rockchip_Developer_Guide_Linux_GMAC_CN

Rockchip_Developer_Guide_Linux_GMAC_Mode_Configuration_CN

GMAC 接口电路
RK3588 芯片拥有 2 GMAC 控制器,提供 RMII RGMII 接口连接外置的 Ethernet PHY
GMAC 控制器支持以下功能:
支持 10/100/1000 Mbps 数据传输速率的 RGMII 接口;
支持 10/100 Mbps 数据传输速率的 RMII 接口。
GMAC0 RGMII/RMII 接口复用在 VCCIO3 电源域。

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 千兆以太网的参数配置,主要有以下几个配置需要注意:

phy-mode :主要分为 RMII RGMII 模式
snps,reset-gpio PHY 的硬件复位脚
snps,reset-delays-us: PHY 的复位时序,三个时间分别表示 PHY 的不同阶段的复位时序,不同的
PHY 的复位时序是不一样的,如果是 snps,reset-active-low 属性,则表示三个时间分别表示 Reset pin
脚拉高,拉低,再拉高的时间;如果是 snps,reset-active-high 属性,则反之
phy-supply: 如果 PHY 的电源是常供方式,可以不用配置;否则,需要配置对应的 regulator
时钟配置。
pinctrl RGMII RMII 模式下配置不一样,另外对于时钟方式,如果是输出时钟的 pin 脚,该 pin
脚驱动强度一般也是不一样的,例如 RMII 模式下 ref_clock pin 脚输出时钟时,驱动强度也会配置
更大
tx_delay/rx_delay: RGMII 模式下需要配置该属性,

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是否数据一直在增加。

RMII 连接示图  具 体 电 路 请 见 参 考 图 (FEPHY 工 作 时 钟 使 用 外 置 25MHz 晶 体 ,
GMACx_MCLKINOUT 采用输入模式, RMII 接口的参考时钟由 FEPHY 提供, FEPHY TXCLK
需要配置为输出模式 )

  • 2
    点赞
  • 40
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值