Lines Matching +full:phy +full:- +full:device
2 PHY subsystem
7 This document explains the Generic PHY Framework along with the APIs provided,
8 and how-to-use.
13 *PHY* is the abbreviation for physical layer. It is used to connect a device
14 to the physical medium e.g., the USB controller has a PHY to provide functions
15 such as serialization, de-serialization, encoding, decoding and is responsible
17 controllers have PHY functionality embedded into it and others use an external
18 PHY. Other peripherals that use PHY include Wireless LAN, Ethernet,
21 The intention of creating this framework is to bring the PHY drivers spread
22 all over the Linux kernel to drivers/phy to increase code re-use and for
25 This framework will be of use only to devices that use external PHY (PHY
28 Registering/Unregistering the PHY provider
31 PHY provider refers to an entity that implements one or more PHY instances.
32 For the simple case where the PHY provider implements only a single instance of
33 the PHY, the framework provides its own implementation of of_xlate in
34 of_phy_simple_xlate. If the PHY provider implements multiple instances, it
48 register the phy_provider and it takes device and of_xlate as
49 arguments. For the dt boot case, all PHY providers should use one of the above
50 2 macros to register the PHY provider.
52 Often the device tree nodes associated with a PHY provider will contain a set
53 of children that each represent a single PHY. Some bindings may nest the child
67 void devm_of_phy_provider_unregister(struct device *dev,
72 unregister the PHY.
74 Creating the PHY
77 The PHY driver should create the PHY in order for other peripheral controllers
78 to make use of it. The PHY framework provides 2 APIs to create the PHY.
82 struct phy *phy_create(struct device *dev, struct device_node *node,
84 struct phy *devm_phy_create(struct device *dev,
88 The PHY drivers can use one of the above 2 APIs to create the PHY by passing
89 the device pointer and phy ops.
90 phy_ops is a set of function pointers for performing PHY operations such as
93 Inorder to dereference the private data (in phy_ops), the phy provider driver
94 can use phy_set_drvdata() after creating the PHY and use phy_get_drvdata() in
97 Getting a reference to the PHY
100 Before the controller can make use of the PHY, it has to get a reference to
101 it. This framework provides the following APIs to get a reference to the PHY.
105 struct phy *phy_get(struct device *dev, const char *string);
106 struct phy *devm_phy_get(struct device *dev, const char *string);
107 struct phy *devm_phy_optional_get(struct device *dev,
109 struct phy *devm_of_phy_get(struct device *dev, struct device_node *np,
111 struct phy *devm_of_phy_optional_get(struct device *dev,
114 struct phy *devm_of_phy_get_by_index(struct device *dev,
118 phy_get, devm_phy_get and devm_phy_optional_get can be used to get the PHY.
120 should contain the phy name as given in the dt data and in the case of
121 non-dt boot, it should contain the label of the PHY. The two
122 devm_phy_get associates the device with the PHY using devres on
123 successful PHY get. On driver detach, release function is invoked on
125 The _optional_get variants should be used when the phy is optional. These
126 functions will never return -ENODEV, but instead return NULL when
127 the phy cannot be found.
129 devm_of_phy_get or devm_of_phy_get_by_index can be used to get a phy
132 It should be noted that NULL is a valid phy reference. All phy
133 consumer calls on the NULL phy become NOPs. That is the release calls,
135 phy_power_off() calls are all NOP when applied to a NULL phy. The NULL
136 phy is useful in devices for handling optional phy devices.
152 Some PHY drivers may not implement :c:func:`phy_init` or :c:func:`phy_power_on`,
158 :c:func:`phy_power_on`, although some PHY drivers may allow it at any time.
160 Releasing a reference to the PHY
163 When the controller no longer needs the PHY, it has to release the reference
164 to the PHY it has obtained using the APIs mentioned in the above section. The
165 PHY framework provides 2 APIs to release a reference to the PHY.
169 void phy_put(struct phy *phy);
170 void devm_phy_put(struct device *dev, struct phy *phy);
172 Both these APIs are used to release a reference to the PHY and devm_phy_put
173 destroys the devres associated with this PHY.
175 Destroying the PHY
178 When the driver that created the PHY is unloaded, it should destroy the PHY it
181 void phy_destroy(struct phy *phy);
182 void devm_phy_destroy(struct device *dev, struct phy *phy);
184 Both these APIs destroy the PHY and devm_phy_destroy destroys the devres
185 associated with this PHY.
190 This subsystem is pm runtime enabled. So while creating the PHY,
191 pm_runtime_enable of the phy device created by this subsystem is called and
192 while destroying the PHY, pm_runtime_disable is called. Note that the phy
193 device created by this subsystem will be a child of the device that calls
194 phy_create (PHY provider device).
197 pm_runtime_get_sync of PHY provider device because of parent-child relationship.
204 PHY Mappings
207 In order to get reference to a PHY without help from DeviceTree, the framework
210 struct phy already exists.
215 int phy_create_lookup(struct phy *phy, const char *con_id,
217 void phy_remove_lookup(struct phy *phy, const char *con_id,
223 The documentation for PHY dt binding can be found @
224 Documentation/devicetree/bindings/phy/phy-bindings.txt