linux phy_read
时间: 2023-11-02 16:05:10 浏览: 287
在Linux中,`phy_read`函数是定义在`linux-4.9.225\include\linux\phy.h`文件中的。该函数用于从物理设备中读取寄存器的值。具体的定义如下:
```c
static inline int phy_read(struct phy_device *phydev, u32 regnum) {
return mdiobus_read(phydev->mdio.bus, phydev->mdio.addr, regnum);
}
```
在该函数中,调用了`mdiobus_read`函数来实际执行读取操作。`phydev`参数是一个指向`struct phy_device`结构体的指针,表示物理设备。`regnum`参数表示要读取的寄存器的编号。函数返回读取到的寄存器值。
另外,`phy_write`函数也是定义在同样的文件中,用于向物理设备中写入寄存器的值。具体的定义如下:
```c
static inline int phy_write(struct phy_device *phydev, u32 regnum, u16 val) {
return mdiobus_write(phydev->mdio.bus, phydev->mdio.addr, regnum, val);
}
```
该函数调用了`mdiobus_write`函数来实际执行写入操作。`phydev`参数和`regnum`参数的含义与`phy_read`函数相同,`val`参数表示要写入的寄存器值。
综上所述,`phy_read`和`phy_write`函数是用于在Linux中读取和写入物理设备寄存器的函数。
#### 引用[.reference_title]
- *1* [PHY驱动调试之 --- PHY控制器驱动(二)](https://blog.csdn.net/enlaihe/article/details/125172195)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* *3* [Linux Phy 驱动解析](https://blog.csdn.net/pwl999/article/details/128339747)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文
相关推荐

















