Lines Matching +full:phy +full:- +full:device
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * phy.h -- generic phy header file
5 * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com
15 #include <linux/device.h>
19 #include <linux/phy/phy-dp.h>
20 #include <linux/phy/phy-lvds.h>
21 #include <linux/phy/phy-mipi-dphy.h>
23 struct phy;
55 * union phy_configure_opts - Opaque generic phy configuration
58 * the MIPI_DPHY phy mode.
62 * the LVDS phy mode.
71 * struct phy_ops - set of function pointers for performing phy operations
72 * @init: operation to be performed for initializing phy
74 * @power_on: powering on the phy
75 * @power_off: powering off the phy
76 * @set_mode: set the mode of the phy
77 * @set_media: set the media type of the phy (optional)
78 * @set_speed: set the speed of the phy (optional)
79 * @reset: resetting the phy
80 * @calibrate: calibrate the phy
81 * @release: ops to be performed while the consumer relinquishes the PHY
85 int (*init)(struct phy *phy);
86 int (*exit)(struct phy *phy);
87 int (*power_on)(struct phy *phy);
88 int (*power_off)(struct phy *phy);
89 int (*set_mode)(struct phy *phy, enum phy_mode mode, int submode);
90 int (*set_media)(struct phy *phy, enum phy_media media);
91 int (*set_speed)(struct phy *phy, int speed);
98 * Used to change the PHY parameters. phy_init() must have
99 * been called on the phy.
103 int (*configure)(struct phy *phy, union phy_configure_opts *opts);
111 * handled by the phy. Implementations are free to tune the
114 * any actual configuration of the PHY, so calling it as many
121 int (*validate)(struct phy *phy, enum phy_mode mode, int submode,
123 int (*reset)(struct phy *phy);
124 int (*calibrate)(struct phy *phy);
125 void (*release)(struct phy *phy);
130 * struct phy_attrs - represents phy attributes
131 * @bus_width: Data path width implemented by PHY
132 * @max_link_rate: Maximum link rate supported by PHY (units to be decided by producer and consumer)
133 * @mode: PHY mode
142 * struct phy - represents the phy device
143 * @dev: phy device
144 * @id: id of the phy device
145 * @ops: function pointers for performing phy operations
147 * @init_count: used to protect when the PHY is used by multiple consumers
148 * @power_count: used to protect when the PHY is used by multiple consumers
149 * @attrs: used to specify PHY specific attributes
150 * @pwr: power regulator associated with the phy
152 struct phy { struct
153 struct device dev;
164 * struct phy_provider - represents the phy provider argument
165 * @dev: phy provider device
166 * @children: can be used to override the default (dev->of_node) child node
168 * @list: to maintain a linked list of PHY providers
169 * @of_xlate: function pointer to obtain phy instance from phy pointer
172 struct device *dev;
176 struct phy * (*of_xlate)(struct device *dev,
181 * struct phy_lookup - PHY association in list of phys managed by the phy driver
183 * @dev_id: the device of the association
184 * @con_id: connection ID string on device
185 * @phy: the phy of the association
191 struct phy *phy; member
194 #define to_phy(a) (container_of((a), struct phy, dev))
208 static inline void phy_set_drvdata(struct phy *phy, void *data) in phy_set_drvdata() argument
210 dev_set_drvdata(&phy->dev, data); in phy_set_drvdata()
213 static inline void *phy_get_drvdata(struct phy *phy) in phy_get_drvdata() argument
215 return dev_get_drvdata(&phy->dev); in phy_get_drvdata()
219 int phy_pm_runtime_get(struct phy *phy);
220 int phy_pm_runtime_get_sync(struct phy *phy);
221 int phy_pm_runtime_put(struct phy *phy);
222 int phy_pm_runtime_put_sync(struct phy *phy);
223 void phy_pm_runtime_allow(struct phy *phy);
224 void phy_pm_runtime_forbid(struct phy *phy);
225 int phy_init(struct phy *phy);
226 int phy_exit(struct phy *phy);
227 int phy_power_on(struct phy *phy);
228 int phy_power_off(struct phy *phy);
229 int phy_set_mode_ext(struct phy *phy, enum phy_mode mode, int submode);
230 #define phy_set_mode(phy, mode) \ argument
231 phy_set_mode_ext(phy, mode, 0)
232 int phy_set_media(struct phy *phy, enum phy_media media);
233 int phy_set_speed(struct phy *phy, int speed);
234 int phy_configure(struct phy *phy, union phy_configure_opts *opts);
235 int phy_validate(struct phy *phy, enum phy_mode mode, int submode,
238 static inline enum phy_mode phy_get_mode(struct phy *phy) in phy_get_mode() argument
240 return phy->attrs.mode; in phy_get_mode()
242 int phy_reset(struct phy *phy);
243 int phy_calibrate(struct phy *phy);
244 static inline int phy_get_bus_width(struct phy *phy) in phy_get_bus_width() argument
246 return phy->attrs.bus_width; in phy_get_bus_width()
248 static inline void phy_set_bus_width(struct phy *phy, int bus_width) in phy_set_bus_width() argument
250 phy->attrs.bus_width = bus_width; in phy_set_bus_width()
252 struct phy *phy_get(struct device *dev, const char *string);
253 struct phy *phy_optional_get(struct device *dev, const char *string);
254 struct phy *devm_phy_get(struct device *dev, const char *string);
255 struct phy *devm_phy_optional_get(struct device *dev, const char *string);
256 struct phy *devm_of_phy_get(struct device *dev, struct device_node *np,
258 struct phy *devm_of_phy_get_by_index(struct device *dev, struct device_node *np,
260 void of_phy_put(struct phy *phy);
261 void phy_put(struct device *dev, struct phy *phy);
262 void devm_phy_put(struct device *dev, struct phy *phy);
263 struct phy *of_phy_get(struct device_node *np, const char *con_id);
264 struct phy *of_phy_simple_xlate(struct device *dev,
266 struct phy *phy_create(struct device *dev, struct device_node *node,
268 struct phy *devm_phy_create(struct device *dev, struct device_node *node,
270 void phy_destroy(struct phy *phy);
271 void devm_phy_destroy(struct device *dev, struct phy *phy);
272 struct phy_provider *__of_phy_provider_register(struct device *dev,
274 struct phy * (*of_xlate)(struct device *dev,
276 struct phy_provider *__devm_of_phy_provider_register(struct device *dev,
278 struct phy * (*of_xlate)(struct device *dev,
281 void devm_of_phy_provider_unregister(struct device *dev,
283 int phy_create_lookup(struct phy *phy, const char *con_id, const char *dev_id);
284 void phy_remove_lookup(struct phy *phy, const char *con_id, const char *dev_id);
286 static inline int phy_pm_runtime_get(struct phy *phy) in phy_pm_runtime_get() argument
288 if (!phy) in phy_pm_runtime_get()
290 return -ENOSYS; in phy_pm_runtime_get()
293 static inline int phy_pm_runtime_get_sync(struct phy *phy) in phy_pm_runtime_get_sync() argument
295 if (!phy) in phy_pm_runtime_get_sync()
297 return -ENOSYS; in phy_pm_runtime_get_sync()
300 static inline int phy_pm_runtime_put(struct phy *phy) in phy_pm_runtime_put() argument
302 if (!phy) in phy_pm_runtime_put()
304 return -ENOSYS; in phy_pm_runtime_put()
307 static inline int phy_pm_runtime_put_sync(struct phy *phy) in phy_pm_runtime_put_sync() argument
309 if (!phy) in phy_pm_runtime_put_sync()
311 return -ENOSYS; in phy_pm_runtime_put_sync()
314 static inline void phy_pm_runtime_allow(struct phy *phy) in phy_pm_runtime_allow() argument
319 static inline void phy_pm_runtime_forbid(struct phy *phy) in phy_pm_runtime_forbid() argument
324 static inline int phy_init(struct phy *phy) in phy_init() argument
326 if (!phy) in phy_init()
328 return -ENOSYS; in phy_init()
331 static inline int phy_exit(struct phy *phy) in phy_exit() argument
333 if (!phy) in phy_exit()
335 return -ENOSYS; in phy_exit()
338 static inline int phy_power_on(struct phy *phy) in phy_power_on() argument
340 if (!phy) in phy_power_on()
342 return -ENOSYS; in phy_power_on()
345 static inline int phy_power_off(struct phy *phy) in phy_power_off() argument
347 if (!phy) in phy_power_off()
349 return -ENOSYS; in phy_power_off()
352 static inline int phy_set_mode_ext(struct phy *phy, enum phy_mode mode, in phy_set_mode_ext() argument
355 if (!phy) in phy_set_mode_ext()
357 return -ENOSYS; in phy_set_mode_ext()
360 #define phy_set_mode(phy, mode) \ argument
361 phy_set_mode_ext(phy, mode, 0)
363 static inline int phy_set_media(struct phy *phy, enum phy_media media) in phy_set_media() argument
365 if (!phy) in phy_set_media()
367 return -ENODEV; in phy_set_media()
370 static inline int phy_set_speed(struct phy *phy, int speed) in phy_set_speed() argument
372 if (!phy) in phy_set_speed()
374 return -ENODEV; in phy_set_speed()
377 static inline enum phy_mode phy_get_mode(struct phy *phy) in phy_get_mode() argument
382 static inline int phy_reset(struct phy *phy) in phy_reset() argument
384 if (!phy) in phy_reset()
386 return -ENOSYS; in phy_reset()
389 static inline int phy_calibrate(struct phy *phy) in phy_calibrate() argument
391 if (!phy) in phy_calibrate()
393 return -ENOSYS; in phy_calibrate()
396 static inline int phy_configure(struct phy *phy, in phy_configure() argument
399 if (!phy) in phy_configure()
402 return -ENOSYS; in phy_configure()
405 static inline int phy_validate(struct phy *phy, enum phy_mode mode, int submode, in phy_validate() argument
408 if (!phy) in phy_validate()
411 return -ENOSYS; in phy_validate()
414 static inline int phy_get_bus_width(struct phy *phy) in phy_get_bus_width() argument
416 return -ENOSYS; in phy_get_bus_width()
419 static inline void phy_set_bus_width(struct phy *phy, int bus_width) in phy_set_bus_width() argument
424 static inline struct phy *phy_get(struct device *dev, const char *string) in phy_get()
426 return ERR_PTR(-ENOSYS); in phy_get()
429 static inline struct phy *phy_optional_get(struct device *dev, in phy_optional_get()
432 return ERR_PTR(-ENOSYS); in phy_optional_get()
435 static inline struct phy *devm_phy_get(struct device *dev, const char *string) in devm_phy_get()
437 return ERR_PTR(-ENOSYS); in devm_phy_get()
440 static inline struct phy *devm_phy_optional_get(struct device *dev, in devm_phy_optional_get()
446 static inline struct phy *devm_of_phy_get(struct device *dev, in devm_of_phy_get()
450 return ERR_PTR(-ENOSYS); in devm_of_phy_get()
453 static inline struct phy *devm_of_phy_get_by_index(struct device *dev, in devm_of_phy_get_by_index()
457 return ERR_PTR(-ENOSYS); in devm_of_phy_get_by_index()
460 static inline void of_phy_put(struct phy *phy) in of_phy_put() argument
464 static inline void phy_put(struct device *dev, struct phy *phy) in phy_put() argument
468 static inline void devm_phy_put(struct device *dev, struct phy *phy) in devm_phy_put() argument
472 static inline struct phy *of_phy_get(struct device_node *np, const char *con_id) in of_phy_get()
474 return ERR_PTR(-ENOSYS); in of_phy_get()
477 static inline struct phy *of_phy_simple_xlate(struct device *dev, in of_phy_simple_xlate()
480 return ERR_PTR(-ENOSYS); in of_phy_simple_xlate()
483 static inline struct phy *phy_create(struct device *dev, in phy_create()
487 return ERR_PTR(-ENOSYS); in phy_create()
490 static inline struct phy *devm_phy_create(struct device *dev, in devm_phy_create()
494 return ERR_PTR(-ENOSYS); in devm_phy_create()
497 static inline void phy_destroy(struct phy *phy) in phy_destroy() argument
501 static inline void devm_phy_destroy(struct device *dev, struct phy *phy) in devm_phy_destroy() argument
506 struct device *dev, struct device_node *children, struct module *owner, in __of_phy_provider_register()
507 struct phy * (*of_xlate)(struct device *dev, in __of_phy_provider_register()
510 return ERR_PTR(-ENOSYS); in __of_phy_provider_register()
513 static inline struct phy_provider *__devm_of_phy_provider_register(struct device in __devm_of_phy_provider_register()
515 struct phy * (*of_xlate)(struct device *dev, in __devm_of_phy_provider_register()
518 return ERR_PTR(-ENOSYS); in __devm_of_phy_provider_register()
525 static inline void devm_of_phy_provider_unregister(struct device *dev, in devm_of_phy_provider_unregister()
530 phy_create_lookup(struct phy *phy, const char *con_id, const char *dev_id) in phy_create_lookup() argument
534 static inline void phy_remove_lookup(struct phy *phy, const char *con_id, in phy_remove_lookup() argument