linux内核phy子系统
参考文档:
https://www.kernel.org/doc/html/latest/driver-api/phy/index.html
Generic PHY Framework
https://elixir.bootlin.com/linux/v6.8-rc6/source/Documentation/devicetree/bindings/phy/phy-bindings.txt
PHY is the abbreviation for physical layer.
PHY是物理层的缩写。
This framework will be of use only to devices that use external PHY (PHY functionality is not embedded within the controller).
该框架仅适用于使用外部PHY的设备(PHY功能未嵌入控制器中)
Inorder to dereference the private data (in phy_ops), the phy provider driver can use phy_set_drvdata() after creating the PHY and use phy_get_drvdata() in phy_ops to get back the private data.
为了取消引用私有数据(在phy_ops中),phy提供程序驱动程序可以在创建phy后使用phy_set_drvdata(),并在phy_op中使用phy_get_drvdata()来获取私有数据。
例如:如下PHY layer
如下图来自于:https://stephenzhou.blog.csdn.net/article/details/123648751 MIPI 系列之 DSI
例子:
https://elixir.bootlin.com/linux/v6.8-rc5/source/drivers/phy/rockchip/phy-rockchip-inno-dsidphy.c
数据类型是一个值的集合和定义在该集合上的一组操作的总称
数据类型是:一组值和一组操作
phy framework框架:Provider-Consumer 生产者消费者
phy驱动开发:
PHY provider:phy提供者
1,创建phy设备
2,关联phy设备相关的一组值和一组操作
(即:phy设备的一组寄存器和一组对寄存器的操作函数)
3,注册phy设备
phy consumer: phy使用者
1,获取phy设备
2,操作phy设备
PHY provider:phy提供者 demo
devm_phy_create()
phy_set_drvdata()
phy_get_drvdata()
devm_of_phy_provider_register()
设备树:
phy consumer: phy使用者 demo
devm_phy_optional_get()
The general order of calls should be:
[devm_][of_]phy_get()
phy_init()
phy_power_on()
[phy_set_mode[_ext]()]
...
phy_power_off()
phy_exit()
[[of_]phy_put()]
设备树:
phys = <&dsidphy>;
phy-names = “dphy”;
phy设备树
https://elixir.bootlin.com/linux/v6.8-rc6/source/Documentation/devicetree/bindings/phy/phy-bindings.txt
1, PHY device node
phys: phy {
compatible = "xxx";
reg = <...>;
.
.
#phy-cells = <1>;
.
.
};
2, PHY user node
Example 1:
usb1: usb_otg_ss@xxx {
compatible = "xxx";
reg = <xxx>;
.
.
phys = <&usb2_phy>, <&usb3_phy>;
phy-names = "usb2phy", "usb3phy";
.
.
};
Example 2:
usb2: usb_otg_ss@xxx {
compatible = "xxx";
reg = <xxx>;
.
.
phys = <&phys 1>;
phy-names = "usbphy";
.
.
};