android11:基于rk3568 适配裕泰以太网Phy芯片YT8512

使用裕太以太网 Phy 芯片YT8512C

在这里插入图片描述

确认硬件连接:

在这里插入图片描述

根据硬件连接修改设备:

rk3568设备树修改:

&gmac1 {
	phy-mode = "rmii";
	clock_in_out = "output";//phy input

	snps,reset-gpio = <&gpio3 RK_PB2 GPIO_ACTIVE_LOW>;
	snps,reset-active-low;
	/* Reset time is 20ms, 100ms for rtl8211f */
	snps,reset-delays-us = <0 20000 100000>;
	//snps,reset-delays-us = <0 10000 50000>;

	assigned-clocks =        <&cru SCLK_GMAC1_RX_TX>,     <&cru SCLK_GMAC1>;
	assigned-clock-parents = <&cru SCLK_GMAC1_RMII_SPEED>;
	assigned-clock-rates =   <0>,<50000000>;

	pinctrl-names = "default";
	pinctrl-0 = <&gmac1m1_miim &gmac1m1_clkinout &gmac1m1_rx_bus2 &gmac1m1_tx_bus2 &gmac1m1_rx_er>;
		
	//tx_delay = <0x3a>;
	//rx_delay = <0x29>

	tx_delay = <0x00>;
	rx_delay = <0x00>;
	phy-handle = <&rgmii_phy1>;
	status = "okay";
};

&mdio0 {
	rgmii_phy0: phy@0 {
		compatible = "ethernet-phy-ieee802.3-c22";
		reg = <0x0>;
		clocks = <&cru CLK_MAC0_OUT>;
	};
};

&mdio1 {
	rgmii_phy1: phy@0 {
		compatible = "ethernet-phy-ieee802.3-c22";
		reg = <0x1>;
		clocks = <&cru CLK_MAC1_OUT>;
	};
};

调试

PHY 寄存器读写

  1. 找phy 设备
$ ls -l /sys/devices/platform/ | grep eth
	drwxr-xr-x 5 root root 0 2011-01-01 13:00 ff290000.ethernet
  1. 上面例子里,找到 mac 设备 ff290000.ethernet,继续找到 phy 设备,如下:
$ ls -l /sys/devices/platform/ff290000.ethernet/mdio_bus/
total 0
drwxr-xr-x 5 root root 0 2011-01-01 13:00 stmmac-0
$ ls -l /sys/devices/platform/fe010000.ethernet/mdio_bus/stmmac-0/

total 0
lrwxrwxrwx 1 root root 0 2021-01-23 13:32 device -> ../../../ff290000.ethernet
drwxr-xr-x 2 root root 0 2011-01-01 13:00 power
drwxr-xr-x 3 root root 0 2011-01-01 13:00 stmmac-0:00
drwxr-xr-x 3 root root 0 2011-01-01 13:00 stmmac-0:04
lrwxrwxrwx 1 root root 0 2021-01-23 13:32 subsystem -> ../../../../../class/mdio_bus
-rw-r--r-- 1 root root 4096 2011-01-01 13:00 uevent
  1. 找到 phy 设备 stmmac-0:04:
$ cd /sys/devices/platform/ff290000.ethernet/mdio_bus/stmmac-0/stmmac-0:04
$ ls -l
total 0
lrwxrwxrwx 1 root root 0 2021-01-23 05:23 driver -> ../../../../../../bus/mdio_bus/drivers/YT8511 Gigabit Ethernet
-r--r--r-- 1 root root 4096 2021-01-23 05:23 phy_has_fixups
-r--r--r-- 1 root root 4096 2021-01-23 05:23 phy_id
-r--r--r-- 1 root root 4096 2021-01-23 05:23 phy_interface
-rw-r--r-- 1 root root 4096 2021-01-23 05:23 phy_registers
drwxr-xr-x 2 root root 0 2011-01-01 13:00 power
lrwxrwxrwx 1 root root 0 2021-01-23 05:23 subsystem -> ../../../../../../bus/mdio_bus
-rw-r--r-- 1 root root 4096 2011-01-01 13:00 uevent
  1. 对 phy 寄存器的读写就是操作文件 phy_registers,读寄存器
cat phy_registers
ls -l /sys/devices/platform/fe010000.ethernet/mdio_bus/stmmac-1

在这里插入图片描述

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值