赞
踩
裕泰微YT8521SH PHY芯片在uboot下的代码适配(一)
本文主要是介绍uboot下的适配代码来源和具体修改。
https://github.com/starfive-tech/u-boot/blob/JH7110_VisionFive2_devel/drivers/net/phy/motorcomm.c#L307
星火科技的PHY用的裕泰微,所以基础的uboot demo可以用他们家的补丁。但是具体配置都不是很对,还是看我的代码为准。
kernel下的PHY驱动
https://github.com/ROCm/ROCK-Kernel-Driver/blob/cc2d8659760f7729b3bed35dc7870eecc5499fd4/drivers/net/phy/motorcomm.c
https://github.com/rockchip-linux/kernel/blob/9ed2be4b9c001ca8006cb4c72928c09927c44f89/drivers/net/phy/motorcomm.c#L2
https://github.com/cnxsoft/YT8521S/tree/main
这个写的很好,应该是正式的kernel 驱动补丁。
https://patchwork.kernel.org/project/netdevbpf/patch/20220620023621.1852-1-Frank.Sae@motor-comm.com/
在 …/u-boot/drivers/net/phy 目录下添加motorcomm.c
修改…/ u-boot/drivers/net/phy 目录下的 Kconfig 文件
添加
config PHY_YT
bool “YT Ethernet PHYs support”
修改…/ u-boot /drivers/net/phy 目录下的 Makefile
添加
obj-$(CONFIG_PHY_YT) += motorcomm.o
修改…/ u-boot /drivers/net/phy 目录下的 phy.c
添加
#ifdef CONFIG_PHY_YT
phy_yutai_init();
#endif
./include/configs/S1020.h中添加CONFIG_PHY_YT=y
,打开CONFIG_RGMII
在./board/中
这里需要同步修改,在uboot下使用哪一个网口进行传输就define哪一个BASE_ADDR
phy_addr的修改需要对照硬件原理图进行。
如图的话就是3。
motorcomm.c如下
// SPDX-License-Identifier: GPL-2.0+ /* * RealTek PHY drivers * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * * Copyright 2010-2011 Freescale Semiconductor, Inc. * author Andy Fleming * */ #include <config.h> #include <common.h> #include <phy.h> #include <bitfield.h> #define REG_PHY_SPEC_STATUS 0x11 #define REG_DEBUG_ADDR_OFFSET 0x1e #define REG_DEBUG_DATA 0x1f #define EXTREG_SLEEP_CONTROL 0x27
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。