~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/Documentation/driver-api/phy/phy.rst

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /Documentation/driver-api/phy/phy.rst (Version linux-6.12-rc7) and /Documentation/driver-api/phy/phy.rst (Version linux-6.2.16)


  1 =============                                       1 =============
  2 PHY subsystem                                       2 PHY subsystem
  3 =============                                       3 =============
  4                                                     4 
  5 :Author: Kishon Vijay Abraham I <kishon@ti.com>      5 :Author: Kishon Vijay Abraham I <kishon@ti.com>
  6                                                     6 
  7 This document explains the Generic PHY Framewo      7 This document explains the Generic PHY Framework along with the APIs provided,
  8 and how-to-use.                                     8 and how-to-use.
  9                                                     9 
 10 Introduction                                       10 Introduction
 11 ============                                       11 ============
 12                                                    12 
 13 *PHY* is the abbreviation for physical layer.      13 *PHY* is the abbreviation for physical layer. It is used to connect a device
 14 to the physical medium e.g., the USB controlle     14 to the physical medium e.g., the USB controller has a PHY to provide functions
 15 such as serialization, de-serialization, encod     15 such as serialization, de-serialization, encoding, decoding and is responsible
 16 for obtaining the required data transmission r     16 for obtaining the required data transmission rate. Note that some USB
 17 controllers have PHY functionality embedded in     17 controllers have PHY functionality embedded into it and others use an external
 18 PHY. Other peripherals that use PHY include Wi     18 PHY. Other peripherals that use PHY include Wireless LAN, Ethernet,
 19 SATA etc.                                          19 SATA etc.
 20                                                    20 
 21 The intention of creating this framework is to     21 The intention of creating this framework is to bring the PHY drivers spread
 22 all over the Linux kernel to drivers/phy to in     22 all over the Linux kernel to drivers/phy to increase code re-use and for
 23 better code maintainability.                       23 better code maintainability.
 24                                                    24 
 25 This framework will be of use only to devices      25 This framework will be of use only to devices that use external PHY (PHY
 26 functionality is not embedded within the contr     26 functionality is not embedded within the controller).
 27                                                    27 
 28 Registering/Unregistering the PHY provider         28 Registering/Unregistering the PHY provider
 29 ==========================================         29 ==========================================
 30                                                    30 
 31 PHY provider refers to an entity that implemen     31 PHY provider refers to an entity that implements one or more PHY instances.
 32 For the simple case where the PHY provider imp     32 For the simple case where the PHY provider implements only a single instance of
 33 the PHY, the framework provides its own implem     33 the PHY, the framework provides its own implementation of of_xlate in
 34 of_phy_simple_xlate. If the PHY provider imple     34 of_phy_simple_xlate. If the PHY provider implements multiple instances, it
 35 should provide its own implementation of of_xl     35 should provide its own implementation of of_xlate. of_xlate is used only for
 36 dt boot case.                                      36 dt boot case.
 37                                                    37 
 38 ::                                                 38 ::
 39                                                    39 
 40         #define of_phy_provider_register(dev,      40         #define of_phy_provider_register(dev, xlate)    \
 41                 __of_phy_provider_register((de     41                 __of_phy_provider_register((dev), NULL, THIS_MODULE, (xlate))
 42                                                    42 
 43         #define devm_of_phy_provider_register(     43         #define devm_of_phy_provider_register(dev, xlate)       \
 44                 __devm_of_phy_provider_registe     44                 __devm_of_phy_provider_register((dev), NULL, THIS_MODULE,
 45                                                    45                                                 (xlate))
 46                                                    46 
 47 of_phy_provider_register and devm_of_phy_provi     47 of_phy_provider_register and devm_of_phy_provider_register macros can be used to
 48 register the phy_provider and it takes device      48 register the phy_provider and it takes device and of_xlate as
 49 arguments. For the dt boot case, all PHY provi     49 arguments. For the dt boot case, all PHY providers should use one of the above
 50 2 macros to register the PHY provider.             50 2 macros to register the PHY provider.
 51                                                    51 
 52 Often the device tree nodes associated with a      52 Often the device tree nodes associated with a PHY provider will contain a set
 53 of children that each represent a single PHY.      53 of children that each represent a single PHY. Some bindings may nest the child
 54 nodes within extra levels for context and exte     54 nodes within extra levels for context and extensibility, in which case the low
 55 level of_phy_provider_register_full() and devm     55 level of_phy_provider_register_full() and devm_of_phy_provider_register_full()
 56 macros can be used to override the node contai     56 macros can be used to override the node containing the children.
 57                                                    57 
 58 ::                                                 58 ::
 59                                                    59 
 60         #define of_phy_provider_register_full(     60         #define of_phy_provider_register_full(dev, children, xlate) \
 61                 __of_phy_provider_register(dev     61                 __of_phy_provider_register(dev, children, THIS_MODULE, xlate)
 62                                                    62 
 63         #define devm_of_phy_provider_register_     63         #define devm_of_phy_provider_register_full(dev, children, xlate) \
 64                 __devm_of_phy_provider_registe     64                 __devm_of_phy_provider_register_full(dev, children,
 65                                                    65                                                      THIS_MODULE, xlate)
 66                                                    66 
 67         void devm_of_phy_provider_unregister(s     67         void devm_of_phy_provider_unregister(struct device *dev,
 68                 struct phy_provider *phy_provi     68                 struct phy_provider *phy_provider);
 69         void of_phy_provider_unregister(struct     69         void of_phy_provider_unregister(struct phy_provider *phy_provider);
 70                                                    70 
 71 devm_of_phy_provider_unregister and of_phy_pro     71 devm_of_phy_provider_unregister and of_phy_provider_unregister can be used to
 72 unregister the PHY.                                72 unregister the PHY.
 73                                                    73 
 74 Creating the PHY                                   74 Creating the PHY
 75 ================                                   75 ================
 76                                                    76 
 77 The PHY driver should create the PHY in order      77 The PHY driver should create the PHY in order for other peripheral controllers
 78 to make use of it. The PHY framework provides      78 to make use of it. The PHY framework provides 2 APIs to create the PHY.
 79                                                    79 
 80 ::                                                 80 ::
 81                                                    81 
 82         struct phy *phy_create(struct device *     82         struct phy *phy_create(struct device *dev, struct device_node *node,
 83                                const struct ph     83                                const struct phy_ops *ops);
 84         struct phy *devm_phy_create(struct dev     84         struct phy *devm_phy_create(struct device *dev,
 85                                     struct dev     85                                     struct device_node *node,
 86                                     const stru     86                                     const struct phy_ops *ops);
 87                                                    87 
 88 The PHY drivers can use one of the above 2 API     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.                    89 the device pointer and phy ops.
 90 phy_ops is a set of function pointers for perf     90 phy_ops is a set of function pointers for performing PHY operations such as
 91 init, exit, power_on and power_off.                91 init, exit, power_on and power_off.
 92                                                    92 
 93 Inorder to dereference the private data (in ph     93 Inorder to dereference the private data (in phy_ops), the phy provider driver
 94 can use phy_set_drvdata() after creating the P     94 can use phy_set_drvdata() after creating the PHY and use phy_get_drvdata() in
 95 phy_ops to get back the private data.              95 phy_ops to get back the private data.
 96                                                    96 
 97 Getting a reference to the PHY                     97 Getting a reference to the PHY
 98 ==============================                     98 ==============================
 99                                                    99 
100 Before the controller can make use of 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    101 it. This framework provides the following APIs to get a reference to the PHY.
102                                                   102 
103 ::                                                103 ::
104                                                   104 
105         struct phy *phy_get(struct device *dev    105         struct phy *phy_get(struct device *dev, const char *string);
                                                   >> 106         struct phy *phy_optional_get(struct device *dev, const char *string);
106         struct phy *devm_phy_get(struct device    107         struct phy *devm_phy_get(struct device *dev, const char *string);
107         struct phy *devm_phy_optional_get(stru    108         struct phy *devm_phy_optional_get(struct device *dev,
108                                           cons    109                                           const char *string);
109         struct phy *devm_of_phy_get(struct dev << 
110                                     const char << 
111         struct phy *devm_of_phy_optional_get(s << 
112                                              s << 
113                                              c << 
114         struct phy *devm_of_phy_get_by_index(s    110         struct phy *devm_of_phy_get_by_index(struct device *dev,
115                                              s    111                                              struct device_node *np,
116                                              i    112                                              int index);
117                                                   113 
118 phy_get, devm_phy_get and devm_phy_optional_ge !! 114 phy_get, phy_optional_get, devm_phy_get and devm_phy_optional_get can
119 In the case of dt boot, the string arguments   !! 115 be used to get the PHY. In the case of dt boot, the string arguments
120 should contain the phy name as given in the dt    116 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 th    117 non-dt boot, it should contain the label of the PHY.  The two
122 devm_phy_get associates the device with the PH    118 devm_phy_get associates the device with the PHY using devres on
123 successful PHY get. On driver detach, release     119 successful PHY get. On driver detach, release function is invoked on
124 the devres data and devres data is freed.      !! 120 the devres data and devres data is freed. phy_optional_get and
125 The _optional_get variants should be used when !! 121 devm_phy_optional_get should be used when the phy is optional. These
126 functions will never return -ENODEV, but inste !! 122 two functions will never return -ENODEV, but instead returns NULL when
127 the phy cannot be found.                       !! 123 the phy cannot be found.Some generic drivers, such as ehci, may use multiple
128 Some generic drivers, such as ehci, may use mu !! 124 phys and for such drivers referencing phy(s) by name(s) does not make sense. In
129 devm_of_phy_get or devm_of_phy_get_by_index ca !! 125 this case, devm_of_phy_get_by_index can be used to get a phy reference based on
130 reference based on name or index.              !! 126 the index.
131                                                   127 
132 It should be noted that NULL is a valid phy re    128 It should be noted that NULL is a valid phy reference. All phy
133 consumer calls on the NULL phy become NOPs. Th    129 consumer calls on the NULL phy become NOPs. That is the release calls,
134 the phy_init() and phy_exit() calls, and phy_p    130 the phy_init() and phy_exit() calls, and phy_power_on() and
135 phy_power_off() calls are all NOP when applied    131 phy_power_off() calls are all NOP when applied to a NULL phy. The NULL
136 phy is useful in devices for handling optional    132 phy is useful in devices for handling optional phy devices.
137                                                   133 
138 Order of API calls                                134 Order of API calls
139 ==================                                135 ==================
140                                                   136 
141 The general order of calls should be::            137 The general order of calls should be::
142                                                   138 
143     [devm_][of_]phy_get()                         139     [devm_][of_]phy_get()
144     phy_init()                                    140     phy_init()
145     phy_power_on()                                141     phy_power_on()
146     [phy_set_mode[_ext]()]                        142     [phy_set_mode[_ext]()]
147     ...                                           143     ...
148     phy_power_off()                               144     phy_power_off()
149     phy_exit()                                    145     phy_exit()
150     [[of_]phy_put()]                              146     [[of_]phy_put()]
151                                                   147 
152 Some PHY drivers may not implement :c:func:`ph    148 Some PHY drivers may not implement :c:func:`phy_init` or :c:func:`phy_power_on`,
153 but controllers should always call these funct    149 but controllers should always call these functions to be compatible with other
154 PHYs. Some PHYs may require :c:func:`phy_set_m    150 PHYs. Some PHYs may require :c:func:`phy_set_mode <phy_set_mode_ext>`, while
155 others may use a default mode (typically confi    151 others may use a default mode (typically configured via devicetree or other
156 firmware). For compatibility, you should alway    152 firmware). For compatibility, you should always call this function if you know
157 what mode you will be using. Generally, this f    153 what mode you will be using. Generally, this function should be called after
158 :c:func:`phy_power_on`, although some PHY driv    154 :c:func:`phy_power_on`, although some PHY drivers may allow it at any time.
159                                                   155 
160 Releasing a reference to the PHY                  156 Releasing a reference to the PHY
161 ================================                  157 ================================
162                                                   158 
163 When the controller no longer needs the PHY, i    159 When the controller no longer needs the PHY, it has to release the reference
164 to the PHY it has obtained using the APIs ment    160 to the PHY it has obtained using the APIs mentioned in the above section. The
165 PHY framework provides 2 APIs to release a ref    161 PHY framework provides 2 APIs to release a reference to the PHY.
166                                                   162 
167 ::                                                163 ::
168                                                   164 
169         void phy_put(struct phy *phy);            165         void phy_put(struct phy *phy);
170         void devm_phy_put(struct device *dev,     166         void devm_phy_put(struct device *dev, struct phy *phy);
171                                                   167 
172 Both these APIs are used to release a referenc    168 Both these APIs are used to release a reference to the PHY and devm_phy_put
173 destroys the devres associated with this PHY.     169 destroys the devres associated with this PHY.
174                                                   170 
175 Destroying the PHY                                171 Destroying the PHY
176 ==================                                172 ==================
177                                                   173 
178 When the driver that created the PHY is unload    174 When the driver that created the PHY is unloaded, it should destroy the PHY it
179 created using one of the following 2 APIs::       175 created using one of the following 2 APIs::
180                                                   176 
181         void phy_destroy(struct phy *phy);        177         void phy_destroy(struct phy *phy);
182         void devm_phy_destroy(struct device *d    178         void devm_phy_destroy(struct device *dev, struct phy *phy);
183                                                   179 
184 Both these APIs destroy the PHY and devm_phy_d    180 Both these APIs destroy the PHY and devm_phy_destroy destroys the devres
185 associated with this PHY.                         181 associated with this PHY.
186                                                   182 
187 PM Runtime                                        183 PM Runtime
188 ==========                                        184 ==========
189                                                   185 
190 This subsystem is pm runtime enabled. So while    186 This subsystem is pm runtime enabled. So while creating the PHY,
191 pm_runtime_enable of the phy device created by    187 pm_runtime_enable of the phy device created by this subsystem is called and
192 while destroying the PHY, pm_runtime_disable i    188 while destroying the PHY, pm_runtime_disable is called. Note that the phy
193 device created by this subsystem will be a chi    189 device created by this subsystem will be a child of the device that calls
194 phy_create (PHY provider device).                 190 phy_create (PHY provider device).
195                                                   191 
196 So pm_runtime_get_sync of the phy_device creat    192 So pm_runtime_get_sync of the phy_device created by this subsystem will invoke
197 pm_runtime_get_sync of PHY provider device bec    193 pm_runtime_get_sync of PHY provider device because of parent-child relationship.
198 It should also be noted that phy_power_on and     194 It should also be noted that phy_power_on and phy_power_off performs
199 phy_pm_runtime_get_sync and phy_pm_runtime_put    195 phy_pm_runtime_get_sync and phy_pm_runtime_put respectively.
200 There are exported APIs like phy_pm_runtime_ge    196 There are exported APIs like phy_pm_runtime_get, phy_pm_runtime_get_sync,
201 phy_pm_runtime_put, phy_pm_runtime_put_sync, p    197 phy_pm_runtime_put, phy_pm_runtime_put_sync, phy_pm_runtime_allow and
202 phy_pm_runtime_forbid for performing PM operat    198 phy_pm_runtime_forbid for performing PM operations.
203                                                   199 
204 PHY Mappings                                      200 PHY Mappings
205 ============                                      201 ============
206                                                   202 
207 In order to get reference to a PHY without hel    203 In order to get reference to a PHY without help from DeviceTree, the framework
208 offers lookups which can be compared to clkdev    204 offers lookups which can be compared to clkdev that allow clk structures to be
209 bound to devices. A lookup can be made during     205 bound to devices. A lookup can be made during runtime when a handle to the
210 struct phy already exists.                        206 struct phy already exists.
211                                                   207 
212 The framework offers the following API for reg    208 The framework offers the following API for registering and unregistering the
213 lookups::                                         209 lookups::
214                                                   210 
215         int phy_create_lookup(struct phy *phy,    211         int phy_create_lookup(struct phy *phy, const char *con_id,
216                               const char *dev_    212                               const char *dev_id);
217         void phy_remove_lookup(struct phy *phy    213         void phy_remove_lookup(struct phy *phy, const char *con_id,
218                                const char *dev    214                                const char *dev_id);
219                                                   215 
220 DeviceTree Binding                                216 DeviceTree Binding
221 ==================                                217 ==================
222                                                   218 
223 The documentation for PHY dt binding can be fo    219 The documentation for PHY dt binding can be found @
224 Documentation/devicetree/bindings/phy/phy-bind    220 Documentation/devicetree/bindings/phy/phy-bindings.txt
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php