Lines Matching +full:phy +full:- +full:mode
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
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);
126 /* notify phy connect status change */
127 int (*connect)(struct phy *phy, int port);
128 int (*disconnect)(struct phy *phy, int port);
130 void (*release)(struct phy *phy);
135 * struct phy_attrs - represents phy attributes
136 * @bus_width: Data path width implemented by PHY
137 * @max_link_rate: Maximum link rate supported by PHY (units to be decided by producer and consumer)
138 * @mode: PHY mode
143 enum phy_mode mode; member
147 * struct phy - represents the phy device
148 * @dev: phy device
149 * @id: id of the phy device
150 * @ops: function pointers for performing phy operations
152 * @init_count: used to protect when the PHY is used by multiple consumers
153 * @power_count: used to protect when the PHY is used by multiple consumers
154 * @attrs: used to specify PHY specific attributes
155 * @pwr: power regulator associated with the phy
158 struct phy { struct
171 * struct phy_provider - represents the phy provider argument
172 * @dev: phy provider device
173 * @children: can be used to override the default (dev->of_node) child node
175 * @list: to maintain a linked list of PHY providers
176 * @of_xlate: function pointer to obtain phy instance from phy pointer
183 struct phy * (*of_xlate)(struct device *dev,
188 * struct phy_lookup - PHY association in list of phys managed by the phy driver
192 * @phy: the phy of the association
198 struct phy *phy; member
201 #define to_phy(a) (container_of((a), struct phy, dev))
215 static inline void phy_set_drvdata(struct phy *phy, void *data) in phy_set_drvdata() argument
217 dev_set_drvdata(&phy->dev, data); in phy_set_drvdata()
220 static inline void *phy_get_drvdata(struct phy *phy) in phy_get_drvdata() argument
222 return dev_get_drvdata(&phy->dev); in phy_get_drvdata()
226 int phy_pm_runtime_get(struct phy *phy);
227 int phy_pm_runtime_get_sync(struct phy *phy);
228 int phy_pm_runtime_put(struct phy *phy);
229 int phy_pm_runtime_put_sync(struct phy *phy);
230 int phy_init(struct phy *phy);
231 int phy_exit(struct phy *phy);
232 int phy_power_on(struct phy *phy);
233 int phy_power_off(struct phy *phy);
234 int phy_set_mode_ext(struct phy *phy, enum phy_mode mode, int submode);
235 #define phy_set_mode(phy, mode) \ argument
236 phy_set_mode_ext(phy, mode, 0)
237 int phy_set_media(struct phy *phy, enum phy_media media);
238 int phy_set_speed(struct phy *phy, int speed);
239 int phy_configure(struct phy *phy, union phy_configure_opts *opts);
240 int phy_validate(struct phy *phy, enum phy_mode mode, int submode,
243 static inline enum phy_mode phy_get_mode(struct phy *phy) in phy_get_mode() argument
245 return phy->attrs.mode; in phy_get_mode()
247 int phy_reset(struct phy *phy);
248 int phy_calibrate(struct phy *phy);
249 int phy_notify_connect(struct phy *phy, int port);
250 int phy_notify_disconnect(struct phy *phy, int port);
251 static inline int phy_get_bus_width(struct phy *phy) in phy_get_bus_width() argument
253 return phy->attrs.bus_width; in phy_get_bus_width()
255 static inline void phy_set_bus_width(struct phy *phy, int bus_width) in phy_set_bus_width() argument
257 phy->attrs.bus_width = bus_width; in phy_set_bus_width()
259 struct phy *phy_get(struct device *dev, const char *string);
260 struct phy *devm_phy_get(struct device *dev, const char *string);
261 struct phy *devm_phy_optional_get(struct device *dev, const char *string);
262 struct phy *devm_of_phy_get(struct device *dev, struct device_node *np,
264 struct phy *devm_of_phy_optional_get(struct device *dev, struct device_node *np,
266 struct phy *devm_of_phy_get_by_index(struct device *dev, struct device_node *np,
268 void of_phy_put(struct phy *phy);
269 void phy_put(struct device *dev, struct phy *phy);
270 void devm_phy_put(struct device *dev, struct phy *phy);
271 struct phy *of_phy_get(struct device_node *np, const char *con_id);
272 struct phy *of_phy_simple_xlate(struct device *dev,
274 struct phy *phy_create(struct device *dev, struct device_node *node,
276 struct phy *devm_phy_create(struct device *dev, struct device_node *node,
278 void phy_destroy(struct phy *phy);
279 void devm_phy_destroy(struct device *dev, struct phy *phy);
282 struct phy * (*of_xlate)(struct device *dev,
286 struct phy * (*of_xlate)(struct device *dev,
291 int phy_create_lookup(struct phy *phy, const char *con_id, const char *dev_id);
292 void phy_remove_lookup(struct phy *phy, const char *con_id, const char *dev_id);
294 static inline int phy_pm_runtime_get(struct phy *phy) in phy_pm_runtime_get() argument
296 if (!phy) in phy_pm_runtime_get()
298 return -ENOSYS; in phy_pm_runtime_get()
301 static inline int phy_pm_runtime_get_sync(struct phy *phy) in phy_pm_runtime_get_sync() argument
303 if (!phy) in phy_pm_runtime_get_sync()
305 return -ENOSYS; in phy_pm_runtime_get_sync()
308 static inline int phy_pm_runtime_put(struct phy *phy) in phy_pm_runtime_put() argument
310 if (!phy) in phy_pm_runtime_put()
312 return -ENOSYS; in phy_pm_runtime_put()
315 static inline int phy_pm_runtime_put_sync(struct phy *phy) in phy_pm_runtime_put_sync() argument
317 if (!phy) in phy_pm_runtime_put_sync()
319 return -ENOSYS; in phy_pm_runtime_put_sync()
322 static inline int phy_init(struct phy *phy) in phy_init() argument
324 if (!phy) in phy_init()
326 return -ENOSYS; in phy_init()
329 static inline int phy_exit(struct phy *phy) in phy_exit() argument
331 if (!phy) in phy_exit()
333 return -ENOSYS; in phy_exit()
336 static inline int phy_power_on(struct phy *phy) in phy_power_on() argument
338 if (!phy) in phy_power_on()
340 return -ENOSYS; in phy_power_on()
343 static inline int phy_power_off(struct phy *phy) in phy_power_off() argument
345 if (!phy) in phy_power_off()
347 return -ENOSYS; in phy_power_off()
350 static inline int phy_set_mode_ext(struct phy *phy, enum phy_mode mode, in phy_set_mode_ext() argument
353 if (!phy) in phy_set_mode_ext()
355 return -ENOSYS; in phy_set_mode_ext()
358 #define phy_set_mode(phy, mode) \ argument
359 phy_set_mode_ext(phy, mode, 0)
361 static inline int phy_set_media(struct phy *phy, enum phy_media media) in phy_set_media() argument
363 if (!phy) in phy_set_media()
365 return -ENODEV; in phy_set_media()
368 static inline int phy_set_speed(struct phy *phy, int speed) in phy_set_speed() argument
370 if (!phy) in phy_set_speed()
372 return -ENODEV; in phy_set_speed()
375 static inline enum phy_mode phy_get_mode(struct phy *phy) in phy_get_mode() argument
380 static inline int phy_reset(struct phy *phy) in phy_reset() argument
382 if (!phy) in phy_reset()
384 return -ENOSYS; in phy_reset()
387 static inline int phy_calibrate(struct phy *phy) in phy_calibrate() argument
389 if (!phy) in phy_calibrate()
391 return -ENOSYS; in phy_calibrate()
394 static inline int phy_notify_connect(struct phy *phy, int index) in phy_notify_connect() argument
396 if (!phy) in phy_notify_connect()
398 return -ENOSYS; in phy_notify_connect()
401 static inline int phy_notify_disconnect(struct phy *phy, int index) in phy_notify_disconnect() argument
403 if (!phy) in phy_notify_disconnect()
405 return -ENOSYS; in phy_notify_disconnect()
408 static inline int phy_configure(struct phy *phy, in phy_configure() argument
411 if (!phy) in phy_configure()
414 return -ENOSYS; in phy_configure()
417 static inline int phy_validate(struct phy *phy, enum phy_mode mode, int submode, in phy_validate() argument
420 if (!phy) in phy_validate()
423 return -ENOSYS; in phy_validate()
426 static inline int phy_get_bus_width(struct phy *phy) in phy_get_bus_width() argument
428 return -ENOSYS; in phy_get_bus_width()
431 static inline void phy_set_bus_width(struct phy *phy, int bus_width) in phy_set_bus_width() argument
436 static inline struct phy *phy_get(struct device *dev, const char *string) in phy_get()
438 return ERR_PTR(-ENOSYS); in phy_get()
441 static inline struct phy *devm_phy_get(struct device *dev, const char *string) in devm_phy_get()
443 return ERR_PTR(-ENOSYS); in devm_phy_get()
446 static inline struct phy *devm_phy_optional_get(struct device *dev, in devm_phy_optional_get()
452 static inline struct phy *devm_of_phy_get(struct device *dev, in devm_of_phy_get()
456 return ERR_PTR(-ENOSYS); in devm_of_phy_get()
459 static inline struct phy *devm_of_phy_optional_get(struct device *dev, in devm_of_phy_optional_get()
466 static inline struct phy *devm_of_phy_get_by_index(struct device *dev, in devm_of_phy_get_by_index()
470 return ERR_PTR(-ENOSYS); in devm_of_phy_get_by_index()
473 static inline void of_phy_put(struct phy *phy) in of_phy_put() argument
477 static inline void phy_put(struct device *dev, struct phy *phy) in phy_put() argument
481 static inline void devm_phy_put(struct device *dev, struct phy *phy) in devm_phy_put() argument
485 static inline struct phy *of_phy_get(struct device_node *np, const char *con_id) in of_phy_get()
487 return ERR_PTR(-ENOSYS); in of_phy_get()
490 static inline struct phy *of_phy_simple_xlate(struct device *dev, in of_phy_simple_xlate()
493 return ERR_PTR(-ENOSYS); in of_phy_simple_xlate()
496 static inline struct phy *phy_create(struct device *dev, in phy_create()
500 return ERR_PTR(-ENOSYS); in phy_create()
503 static inline struct phy *devm_phy_create(struct device *dev, in devm_phy_create()
507 return ERR_PTR(-ENOSYS); in devm_phy_create()
510 static inline void phy_destroy(struct phy *phy) in phy_destroy() argument
514 static inline void devm_phy_destroy(struct device *dev, struct phy *phy) in devm_phy_destroy() argument
520 struct phy * (*of_xlate)(struct device *dev, in __of_phy_provider_register()
523 return ERR_PTR(-ENOSYS); in __of_phy_provider_register()
528 struct phy * (*of_xlate)(struct device *dev, in __devm_of_phy_provider_register()
531 return ERR_PTR(-ENOSYS); in __devm_of_phy_provider_register()
543 phy_create_lookup(struct phy *phy, const char *con_id, const char *dev_id) in phy_create_lookup() argument
547 static inline void phy_remove_lookup(struct phy *phy, const char *con_id, in phy_remove_lookup() argument