当前位置:网站首页>88Q2110 通过C22方式访问C45 phy地址
88Q2110 通过C22方式访问C45 phy地址
2022-08-11 01:23:00 【王二车】
问题现象
MTK T800平台,内核版本4.19.98,使用两片88Q2110芯片,分别RGMII和SGMII,驱动识别phy id失败:
DTS配置
88Q2110支持C45和C22访问:
phy id的电阻没有焊接,默认地址0:
C22访问寄存器
配置和驱动默认使用C45访问寄存器,但使用C45读phy id失败,改为C22访问寄存器:
使用C22方式通过访问外部寄存器13和14读写寄存器:
C45读寄存器:
没看懂怎么操作的。
static int get_phy_c45_devs_in_pkg(struct mii_bus *bus, int addr, int dev_addr,
u32 *devices_in_package)
{
int phy_reg, reg_addr;
reg_addr = MII_ADDR_C45 | dev_addr << 16 | MDIO_DEVS2;
phy_reg = mdiobus_read(bus, addr, reg_addr);
if (phy_reg < 0)
return -EIO;
*devices_in_package = (phy_reg & 0xffff) << 16;
reg_addr = MII_ADDR_C45 | dev_addr << 16 | MDIO_DEVS1;
phy_reg = mdiobus_read(bus, addr, reg_addr);
if (phy_reg < 0)
return -EIO;
*devices_in_package |= (phy_reg & 0xffff);
return 0;
}
C22读寄存器:
static int get_phy_c45_devs_in_pkg(struct mii_bus *bus, int addr, int dev_addr,
u32 *devices_in_package)
{
int phy_reg, reg_addr;
mdiobus_write(bus, addr, 0xd, 0x0001);
mdiobus_write(bus, addr, 0xe, 0x0002);
mdiobus_write(bus, addr, 0xd, 0x4001);
phy_reg = mdiobus_read(bus, addr, 0xe);
printk("PHY_REG = %x\n",phy_reg);
if (phy_reg < 0)
return -EIO;
*devices_in_package = (phy_reg & 0xffff) << 16;
mdiobus_write(bus, addr, 0xd, 0x0001);
mdiobus_write(bus, addr, 0xe, 0x0003);
mdiobus_write(bus, addr, 0xd, 0x4001);
phy_reg = mdiobus_read(bus, addr, 0xe);
if (phy_reg < 0)
return -EIO;
*devices_in_package |= (phy_reg & 0xffff);
printk("phy IDDDD = %x\n",*devices_in_package);
return 0;
}
步骤:
mdiobus_write(bus, addr, 0xd, 0x0001);
1、先写寄存器13(0xd),写00到bit[15:14]表示00=Address地址功能,写1到bit[4:0]表示设备地址。
mdiobus_write(bus, addr, 0xe, 0x0002);
2、后写寄存器14(0xe),写0x0002到bit[15:0]表示寄存器地址,表示读设备ID
mdiobus_write(bus, addr, 0xd, 0x4001);
3、写寄存器13(0xd),写01到[15:14]表示从寄存器读写数据功能,写1到bit[4:0]表示设备地址。
phy_reg = mdiobus_read(bus, addr, 0xe);
4、读寄存器14(0xe),返回寄存器0x0002的数据。
获取到设备ID数据是0x2B,
0x0003寄存器读出是0x0982,10,011000 ,0010,对应0x02,0x18,0x2。修订编号为2,这就一一对应上了。
寄存器操作命令
yike支持客户通过读写文件得方式进行设置和读取PHY寄存器,具体命令格式如下。
(1)通过如下命令读取寄存器:
echo 协议类型r 寄存器地址 > /sys/devices/platform/11021000.ethernet/stmmac
例如:通过clause22协议读取寄存器0x1:
echo cl22r 1 > /sys/devices/platform/soc/1101a000.eth/stmmac
(2)通过如下命令写寄存器:
echo 协议类型w 寄存器地址 value > /sys/devices/platform/11021000.ethernet/stmmac
例如:通过clause22协议写寄存器0x0值为0x5040
echo cl22w 0 0x5040 > /sys/devices/platform/11021000.ethernet/stmmac
以realtek8211F PHY为例,
(1)设置phy为loopback模式:
echo cl22r 0 > /sys/devices/platform/11021000.ethernet/stmmac (读出 PHY register0的值)
echo cl45r 1 0x834 > /sys/devices/platform/11021000.ethernet/stmmac(c45读方式)
echo cl22w 0 xxx > /sys/devices/platform/11021000.ethernet/stmmac (xxx:为上一步register0读出的值,将bit14置1后的十六进制值)
echo cl45w 1 0x834 0x8001 > /sys/devices/platform/11021000.ethernet/stmmac
(2)复位phy,进行reset:
echo cl22r 0 > /sys/devices/platform/11021000.ethernet/stmmac (读出 PHY register0的值)
echo cl22w 0 0x9040> /sys/devices/platform/11021000.ethernet/stmmac (xxx:为上一步register0读出的值,将bit15置1后的十六进制值)
疑问:为何T800使用C45就读不出ID呢?
边栏推荐
- MySQL advanced query
- R语言多元线性回归、ARIMA分析美国不同候选人对经济GDP时间序列影响
- Volatile和CAS
- C# string与stream的相互转换
- 导入数据包上传宝贝提示“类目不能为空”是什么原因,怎么解决?
- More parameter exposure of Pico 4: Pancake + color perspective, and Pro version
- [21 Days Learning Challenge] Half Insertion Sort
- 如何防止离职员工把企业文件拷贝带走?法律+技术,4步走
- 使用mysql语句操作数据表(table)
- 22/8/9 Collection of Greedy Problems
猜你喜欢
Distributed. Performance optimization
Is container technology really the savior of environmental management?
Data Filters in ABP
关于编程本质那些事
构建资源的弹性伸缩
异常和异常处理机制
22、库存服务
J9 Digital Theory: DAO governance is more like an ecological process: governance is native to the network and continues to evolve
Volatile和CAS
Elastic scaling of construction resources
随机推荐
什么是数组
MSTP - Multiple Spanning Tree (Case + Configuration)
@Autowired注入RedisCache报错空指针
循环单词
C# JObject解析JSON数据
单片机人机交互--矩阵按键
Ambari迁移Spark2到其它机器(图文教程)
总结Qt中常用文件信息QFileInfo的获取:后缀,名称,路径,链接
paddle2.3和torch1.8在SentenceBert上的性能对比
Summarize the acquisition of commonly used file information QFileInfo in Qt: suffix, name, path, link
Exceptions and exception handling mechanisms
C# string与stream的相互转换
J9数字论:DAO治理更像一种生态过程:治理原生于网络,不断演变
时间戳转换为日期格式、获取当前时间戳
BEVDepth: Acquisition of Reliable Depth for Multi-view 3D Object Detection 论文笔记
Pico 4更多参数曝光:Pancake+彩色透视,还有Pro版本
MySQL indexes and transactions
导入数据包上传宝贝提示“类目不能为空”是什么原因,怎么解决?
Mysql数据库安装配置详细教程
Sub-database sub-table ShardingSphere-JDBC notes arrangement