Loading...
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*
3 * phy.h -- generic phy header file
4 *
5 * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com
6 *
7 * Author: Kishon Vijay Abraham I <kishon@ti.com>
8 */
9
10#ifndef __DRIVERS_PHY_H
11#define __DRIVERS_PHY_H
12
13#include <linux/err.h>
14#include <linux/of.h>
15#include <linux/device.h>
16#include <linux/pm_runtime.h>
17#include <linux/regulator/consumer.h>
18
19#include <linux/phy/phy-dp.h>
20#include <linux/phy/phy-mipi-dphy.h>
21
22struct phy;
23
24enum phy_mode {
25 PHY_MODE_INVALID,
26 PHY_MODE_USB_HOST,
27 PHY_MODE_USB_HOST_LS,
28 PHY_MODE_USB_HOST_FS,
29 PHY_MODE_USB_HOST_HS,
30 PHY_MODE_USB_HOST_SS,
31 PHY_MODE_USB_DEVICE,
32 PHY_MODE_USB_DEVICE_LS,
33 PHY_MODE_USB_DEVICE_FS,
34 PHY_MODE_USB_DEVICE_HS,
35 PHY_MODE_USB_DEVICE_SS,
36 PHY_MODE_USB_OTG,
37 PHY_MODE_UFS_HS_A,
38 PHY_MODE_UFS_HS_B,
39 PHY_MODE_PCIE,
40 PHY_MODE_ETHERNET,
41 PHY_MODE_MIPI_DPHY,
42 PHY_MODE_SATA,
43 PHY_MODE_LVDS,
44 PHY_MODE_DP
45};
46
47/**
48 * union phy_configure_opts - Opaque generic phy configuration
49 *
50 * @mipi_dphy: Configuration set applicable for phys supporting
51 * the MIPI_DPHY phy mode.
52 * @dp: Configuration set applicable for phys supporting
53 * the DisplayPort protocol.
54 */
55union phy_configure_opts {
56 struct phy_configure_opts_mipi_dphy mipi_dphy;
57 struct phy_configure_opts_dp dp;
58};
59
60/**
61 * struct phy_ops - set of function pointers for performing phy operations
62 * @init: operation to be performed for initializing phy
63 * @exit: operation to be performed while exiting
64 * @power_on: powering on the phy
65 * @power_off: powering off the phy
66 * @set_mode: set the mode of the phy
67 * @reset: resetting the phy
68 * @calibrate: calibrate the phy
69 * @release: ops to be performed while the consumer relinquishes the PHY
70 * @owner: the module owner containing the ops
71 */
72struct phy_ops {
73 int (*init)(struct phy *phy);
74 int (*exit)(struct phy *phy);
75 int (*power_on)(struct phy *phy);
76 int (*power_off)(struct phy *phy);
77 int (*set_mode)(struct phy *phy, enum phy_mode mode, int submode);
78
79 /**
80 * @configure:
81 *
82 * Optional.
83 *
84 * Used to change the PHY parameters. phy_init() must have
85 * been called on the phy.
86 *
87 * Returns: 0 if successful, an negative error code otherwise
88 */
89 int (*configure)(struct phy *phy, union phy_configure_opts *opts);
90
91 /**
92 * @validate:
93 *
94 * Optional.
95 *
96 * Used to check that the current set of parameters can be
97 * handled by the phy. Implementations are free to tune the
98 * parameters passed as arguments if needed by some
99 * implementation detail or constraints. It must not change
100 * any actual configuration of the PHY, so calling it as many
101 * times as deemed fit by the consumer must have no side
102 * effect.
103 *
104 * Returns: 0 if the configuration can be applied, an negative
105 * error code otherwise
106 */
107 int (*validate)(struct phy *phy, enum phy_mode mode, int submode,
108 union phy_configure_opts *opts);
109 int (*reset)(struct phy *phy);
110 int (*calibrate)(struct phy *phy);
111 void (*release)(struct phy *phy);
112 struct module *owner;
113};
114
115/**
116 * struct phy_attrs - represents phy attributes
117 * @bus_width: Data path width implemented by PHY
118 * @mode: PHY mode
119 */
120struct phy_attrs {
121 u32 bus_width;
122 enum phy_mode mode;
123};
124
125/**
126 * struct phy - represents the phy device
127 * @dev: phy device
128 * @id: id of the phy device
129 * @ops: function pointers for performing phy operations
130 * @mutex: mutex to protect phy_ops
131 * @init_count: used to protect when the PHY is used by multiple consumers
132 * @power_count: used to protect when the PHY is used by multiple consumers
133 * @attrs: used to specify PHY specific attributes
134 * @pwr: power regulator associated with the phy
135 */
136struct phy {
137 struct device dev;
138 int id;
139 const struct phy_ops *ops;
140 struct mutex mutex;
141 int init_count;
142 int power_count;
143 struct phy_attrs attrs;
144 struct regulator *pwr;
145};
146
147/**
148 * struct phy_provider - represents the phy provider
149 * @dev: phy provider device
150 * @children: can be used to override the default (dev->of_node) child node
151 * @owner: the module owner having of_xlate
152 * @list: to maintain a linked list of PHY providers
153 * @of_xlate: function pointer to obtain phy instance from phy pointer
154 */
155struct phy_provider {
156 struct device *dev;
157 struct device_node *children;
158 struct module *owner;
159 struct list_head list;
160 struct phy * (*of_xlate)(struct device *dev,
161 struct of_phandle_args *args);
162};
163
164/**
165 * struct phy_lookup - PHY association in list of phys managed by the phy driver
166 * @node: list node
167 * @dev_id: the device of the association
168 * @con_id: connection ID string on device
169 * @phy: the phy of the association
170 */
171struct phy_lookup {
172 struct list_head node;
173 const char *dev_id;
174 const char *con_id;
175 struct phy *phy;
176};
177
178#define to_phy(a) (container_of((a), struct phy, dev))
179
180#define of_phy_provider_register(dev, xlate) \
181 __of_phy_provider_register((dev), NULL, THIS_MODULE, (xlate))
182
183#define devm_of_phy_provider_register(dev, xlate) \
184 __devm_of_phy_provider_register((dev), NULL, THIS_MODULE, (xlate))
185
186#define of_phy_provider_register_full(dev, children, xlate) \
187 __of_phy_provider_register(dev, children, THIS_MODULE, xlate)
188
189#define devm_of_phy_provider_register_full(dev, children, xlate) \
190 __devm_of_phy_provider_register(dev, children, THIS_MODULE, xlate)
191
192static inline void phy_set_drvdata(struct phy *phy, void *data)
193{
194 dev_set_drvdata(&phy->dev, data);
195}
196
197static inline void *phy_get_drvdata(struct phy *phy)
198{
199 return dev_get_drvdata(&phy->dev);
200}
201
202#if IS_ENABLED(CONFIG_GENERIC_PHY)
203int phy_pm_runtime_get(struct phy *phy);
204int phy_pm_runtime_get_sync(struct phy *phy);
205int phy_pm_runtime_put(struct phy *phy);
206int phy_pm_runtime_put_sync(struct phy *phy);
207void phy_pm_runtime_allow(struct phy *phy);
208void phy_pm_runtime_forbid(struct phy *phy);
209int phy_init(struct phy *phy);
210int phy_exit(struct phy *phy);
211int phy_power_on(struct phy *phy);
212int phy_power_off(struct phy *phy);
213int phy_set_mode_ext(struct phy *phy, enum phy_mode mode, int submode);
214#define phy_set_mode(phy, mode) \
215 phy_set_mode_ext(phy, mode, 0)
216int phy_configure(struct phy *phy, union phy_configure_opts *opts);
217int phy_validate(struct phy *phy, enum phy_mode mode, int submode,
218 union phy_configure_opts *opts);
219
220static inline enum phy_mode phy_get_mode(struct phy *phy)
221{
222 return phy->attrs.mode;
223}
224int phy_reset(struct phy *phy);
225int phy_calibrate(struct phy *phy);
226static inline int phy_get_bus_width(struct phy *phy)
227{
228 return phy->attrs.bus_width;
229}
230static inline void phy_set_bus_width(struct phy *phy, int bus_width)
231{
232 phy->attrs.bus_width = bus_width;
233}
234struct phy *phy_get(struct device *dev, const char *string);
235struct phy *phy_optional_get(struct device *dev, const char *string);
236struct phy *devm_phy_get(struct device *dev, const char *string);
237struct phy *devm_phy_optional_get(struct device *dev, const char *string);
238struct phy *devm_of_phy_get(struct device *dev, struct device_node *np,
239 const char *con_id);
240struct phy *devm_of_phy_get_by_index(struct device *dev, struct device_node *np,
241 int index);
242void of_phy_put(struct phy *phy);
243void phy_put(struct device *dev, struct phy *phy);
244void devm_phy_put(struct device *dev, struct phy *phy);
245struct phy *of_phy_get(struct device_node *np, const char *con_id);
246struct phy *of_phy_simple_xlate(struct device *dev,
247 struct of_phandle_args *args);
248struct phy *phy_create(struct device *dev, struct device_node *node,
249 const struct phy_ops *ops);
250struct phy *devm_phy_create(struct device *dev, struct device_node *node,
251 const struct phy_ops *ops);
252void phy_destroy(struct phy *phy);
253void devm_phy_destroy(struct device *dev, struct phy *phy);
254struct phy_provider *__of_phy_provider_register(struct device *dev,
255 struct device_node *children, struct module *owner,
256 struct phy * (*of_xlate)(struct device *dev,
257 struct of_phandle_args *args));
258struct phy_provider *__devm_of_phy_provider_register(struct device *dev,
259 struct device_node *children, struct module *owner,
260 struct phy * (*of_xlate)(struct device *dev,
261 struct of_phandle_args *args));
262void of_phy_provider_unregister(struct phy_provider *phy_provider);
263void devm_of_phy_provider_unregister(struct device *dev,
264 struct phy_provider *phy_provider);
265int phy_create_lookup(struct phy *phy, const char *con_id, const char *dev_id);
266void phy_remove_lookup(struct phy *phy, const char *con_id, const char *dev_id);
267#else
268static inline int phy_pm_runtime_get(struct phy *phy)
269{
270 if (!phy)
271 return 0;
272 return -ENOSYS;
273}
274
275static inline int phy_pm_runtime_get_sync(struct phy *phy)
276{
277 if (!phy)
278 return 0;
279 return -ENOSYS;
280}
281
282static inline int phy_pm_runtime_put(struct phy *phy)
283{
284 if (!phy)
285 return 0;
286 return -ENOSYS;
287}
288
289static inline int phy_pm_runtime_put_sync(struct phy *phy)
290{
291 if (!phy)
292 return 0;
293 return -ENOSYS;
294}
295
296static inline void phy_pm_runtime_allow(struct phy *phy)
297{
298 return;
299}
300
301static inline void phy_pm_runtime_forbid(struct phy *phy)
302{
303 return;
304}
305
306static inline int phy_init(struct phy *phy)
307{
308 if (!phy)
309 return 0;
310 return -ENOSYS;
311}
312
313static inline int phy_exit(struct phy *phy)
314{
315 if (!phy)
316 return 0;
317 return -ENOSYS;
318}
319
320static inline int phy_power_on(struct phy *phy)
321{
322 if (!phy)
323 return 0;
324 return -ENOSYS;
325}
326
327static inline int phy_power_off(struct phy *phy)
328{
329 if (!phy)
330 return 0;
331 return -ENOSYS;
332}
333
334static inline int phy_set_mode_ext(struct phy *phy, enum phy_mode mode,
335 int submode)
336{
337 if (!phy)
338 return 0;
339 return -ENOSYS;
340}
341
342#define phy_set_mode(phy, mode) \
343 phy_set_mode_ext(phy, mode, 0)
344
345static inline enum phy_mode phy_get_mode(struct phy *phy)
346{
347 return PHY_MODE_INVALID;
348}
349
350static inline int phy_reset(struct phy *phy)
351{
352 if (!phy)
353 return 0;
354 return -ENOSYS;
355}
356
357static inline int phy_calibrate(struct phy *phy)
358{
359 if (!phy)
360 return 0;
361 return -ENOSYS;
362}
363
364static inline int phy_configure(struct phy *phy,
365 union phy_configure_opts *opts)
366{
367 if (!phy)
368 return 0;
369
370 return -ENOSYS;
371}
372
373static inline int phy_validate(struct phy *phy, enum phy_mode mode, int submode,
374 union phy_configure_opts *opts)
375{
376 if (!phy)
377 return 0;
378
379 return -ENOSYS;
380}
381
382static inline int phy_get_bus_width(struct phy *phy)
383{
384 return -ENOSYS;
385}
386
387static inline void phy_set_bus_width(struct phy *phy, int bus_width)
388{
389 return;
390}
391
392static inline struct phy *phy_get(struct device *dev, const char *string)
393{
394 return ERR_PTR(-ENOSYS);
395}
396
397static inline struct phy *phy_optional_get(struct device *dev,
398 const char *string)
399{
400 return ERR_PTR(-ENOSYS);
401}
402
403static inline struct phy *devm_phy_get(struct device *dev, const char *string)
404{
405 return ERR_PTR(-ENOSYS);
406}
407
408static inline struct phy *devm_phy_optional_get(struct device *dev,
409 const char *string)
410{
411 return NULL;
412}
413
414static inline struct phy *devm_of_phy_get(struct device *dev,
415 struct device_node *np,
416 const char *con_id)
417{
418 return ERR_PTR(-ENOSYS);
419}
420
421static inline struct phy *devm_of_phy_get_by_index(struct device *dev,
422 struct device_node *np,
423 int index)
424{
425 return ERR_PTR(-ENOSYS);
426}
427
428static inline void of_phy_put(struct phy *phy)
429{
430}
431
432static inline void phy_put(struct device *dev, struct phy *phy)
433{
434}
435
436static inline void devm_phy_put(struct device *dev, struct phy *phy)
437{
438}
439
440static inline struct phy *of_phy_get(struct device_node *np, const char *con_id)
441{
442 return ERR_PTR(-ENOSYS);
443}
444
445static inline struct phy *of_phy_simple_xlate(struct device *dev,
446 struct of_phandle_args *args)
447{
448 return ERR_PTR(-ENOSYS);
449}
450
451static inline struct phy *phy_create(struct device *dev,
452 struct device_node *node,
453 const struct phy_ops *ops)
454{
455 return ERR_PTR(-ENOSYS);
456}
457
458static inline struct phy *devm_phy_create(struct device *dev,
459 struct device_node *node,
460 const struct phy_ops *ops)
461{
462 return ERR_PTR(-ENOSYS);
463}
464
465static inline void phy_destroy(struct phy *phy)
466{
467}
468
469static inline void devm_phy_destroy(struct device *dev, struct phy *phy)
470{
471}
472
473static inline struct phy_provider *__of_phy_provider_register(
474 struct device *dev, struct device_node *children, struct module *owner,
475 struct phy * (*of_xlate)(struct device *dev,
476 struct of_phandle_args *args))
477{
478 return ERR_PTR(-ENOSYS);
479}
480
481static inline struct phy_provider *__devm_of_phy_provider_register(struct device
482 *dev, struct device_node *children, struct module *owner,
483 struct phy * (*of_xlate)(struct device *dev,
484 struct of_phandle_args *args))
485{
486 return ERR_PTR(-ENOSYS);
487}
488
489static inline void of_phy_provider_unregister(struct phy_provider *phy_provider)
490{
491}
492
493static inline void devm_of_phy_provider_unregister(struct device *dev,
494 struct phy_provider *phy_provider)
495{
496}
497static inline int
498phy_create_lookup(struct phy *phy, const char *con_id, const char *dev_id)
499{
500 return 0;
501}
502static inline void phy_remove_lookup(struct phy *phy, const char *con_id,
503 const char *dev_id) { }
504#endif
505
506#endif /* __DRIVERS_PHY_H */
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*
3 * phy.h -- generic phy header file
4 *
5 * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com
6 *
7 * Author: Kishon Vijay Abraham I <kishon@ti.com>
8 */
9
10#ifndef __DRIVERS_PHY_H
11#define __DRIVERS_PHY_H
12
13#include <linux/err.h>
14#include <linux/of.h>
15#include <linux/device.h>
16#include <linux/pm_runtime.h>
17#include <linux/regulator/consumer.h>
18
19#include <linux/phy/phy-dp.h>
20#include <linux/phy/phy-lvds.h>
21#include <linux/phy/phy-mipi-dphy.h>
22
23struct phy;
24
25enum phy_mode {
26 PHY_MODE_INVALID,
27 PHY_MODE_USB_HOST,
28 PHY_MODE_USB_HOST_LS,
29 PHY_MODE_USB_HOST_FS,
30 PHY_MODE_USB_HOST_HS,
31 PHY_MODE_USB_HOST_SS,
32 PHY_MODE_USB_DEVICE,
33 PHY_MODE_USB_DEVICE_LS,
34 PHY_MODE_USB_DEVICE_FS,
35 PHY_MODE_USB_DEVICE_HS,
36 PHY_MODE_USB_DEVICE_SS,
37 PHY_MODE_USB_OTG,
38 PHY_MODE_UFS_HS_A,
39 PHY_MODE_UFS_HS_B,
40 PHY_MODE_PCIE,
41 PHY_MODE_ETHERNET,
42 PHY_MODE_MIPI_DPHY,
43 PHY_MODE_SATA,
44 PHY_MODE_LVDS,
45 PHY_MODE_DP
46};
47
48enum phy_media {
49 PHY_MEDIA_DEFAULT,
50 PHY_MEDIA_SR,
51 PHY_MEDIA_DAC,
52};
53
54/**
55 * union phy_configure_opts - Opaque generic phy configuration
56 *
57 * @mipi_dphy: Configuration set applicable for phys supporting
58 * the MIPI_DPHY phy mode.
59 * @dp: Configuration set applicable for phys supporting
60 * the DisplayPort protocol.
61 * @lvds: Configuration set applicable for phys supporting
62 * the LVDS phy mode.
63 */
64union phy_configure_opts {
65 struct phy_configure_opts_mipi_dphy mipi_dphy;
66 struct phy_configure_opts_dp dp;
67 struct phy_configure_opts_lvds lvds;
68};
69
70/**
71 * struct phy_ops - set of function pointers for performing phy operations
72 * @init: operation to be performed for initializing phy
73 * @exit: operation to be performed while exiting
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
82 * @owner: the module owner containing the ops
83 */
84struct phy_ops {
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);
92
93 /**
94 * @configure:
95 *
96 * Optional.
97 *
98 * Used to change the PHY parameters. phy_init() must have
99 * been called on the phy.
100 *
101 * Returns: 0 if successful, an negative error code otherwise
102 */
103 int (*configure)(struct phy *phy, union phy_configure_opts *opts);
104
105 /**
106 * @validate:
107 *
108 * Optional.
109 *
110 * Used to check that the current set of parameters can be
111 * handled by the phy. Implementations are free to tune the
112 * parameters passed as arguments if needed by some
113 * implementation detail or constraints. It must not change
114 * any actual configuration of the PHY, so calling it as many
115 * times as deemed fit by the consumer must have no side
116 * effect.
117 *
118 * Returns: 0 if the configuration can be applied, an negative
119 * error code otherwise
120 */
121 int (*validate)(struct phy *phy, enum phy_mode mode, int submode,
122 union phy_configure_opts *opts);
123 int (*reset)(struct phy *phy);
124 int (*calibrate)(struct phy *phy);
125 void (*release)(struct phy *phy);
126 struct module *owner;
127};
128
129/**
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
134 */
135struct phy_attrs {
136 u32 bus_width;
137 u32 max_link_rate;
138 enum phy_mode mode;
139};
140
141/**
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
146 * @mutex: mutex to protect phy_ops
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
151 * @debugfs: debugfs directory
152 */
153struct phy {
154 struct device dev;
155 int id;
156 const struct phy_ops *ops;
157 struct mutex mutex;
158 int init_count;
159 int power_count;
160 struct phy_attrs attrs;
161 struct regulator *pwr;
162 struct dentry *debugfs;
163};
164
165/**
166 * struct phy_provider - represents the phy provider
167 * @dev: phy provider device
168 * @children: can be used to override the default (dev->of_node) child node
169 * @owner: the module owner having of_xlate
170 * @list: to maintain a linked list of PHY providers
171 * @of_xlate: function pointer to obtain phy instance from phy pointer
172 */
173struct phy_provider {
174 struct device *dev;
175 struct device_node *children;
176 struct module *owner;
177 struct list_head list;
178 struct phy * (*of_xlate)(struct device *dev,
179 struct of_phandle_args *args);
180};
181
182/**
183 * struct phy_lookup - PHY association in list of phys managed by the phy driver
184 * @node: list node
185 * @dev_id: the device of the association
186 * @con_id: connection ID string on device
187 * @phy: the phy of the association
188 */
189struct phy_lookup {
190 struct list_head node;
191 const char *dev_id;
192 const char *con_id;
193 struct phy *phy;
194};
195
196#define to_phy(a) (container_of((a), struct phy, dev))
197
198#define of_phy_provider_register(dev, xlate) \
199 __of_phy_provider_register((dev), NULL, THIS_MODULE, (xlate))
200
201#define devm_of_phy_provider_register(dev, xlate) \
202 __devm_of_phy_provider_register((dev), NULL, THIS_MODULE, (xlate))
203
204#define of_phy_provider_register_full(dev, children, xlate) \
205 __of_phy_provider_register(dev, children, THIS_MODULE, xlate)
206
207#define devm_of_phy_provider_register_full(dev, children, xlate) \
208 __devm_of_phy_provider_register(dev, children, THIS_MODULE, xlate)
209
210static inline void phy_set_drvdata(struct phy *phy, void *data)
211{
212 dev_set_drvdata(&phy->dev, data);
213}
214
215static inline void *phy_get_drvdata(struct phy *phy)
216{
217 return dev_get_drvdata(&phy->dev);
218}
219
220#if IS_ENABLED(CONFIG_GENERIC_PHY)
221int phy_pm_runtime_get(struct phy *phy);
222int phy_pm_runtime_get_sync(struct phy *phy);
223int phy_pm_runtime_put(struct phy *phy);
224int phy_pm_runtime_put_sync(struct phy *phy);
225void phy_pm_runtime_allow(struct phy *phy);
226void phy_pm_runtime_forbid(struct phy *phy);
227int phy_init(struct phy *phy);
228int phy_exit(struct phy *phy);
229int phy_power_on(struct phy *phy);
230int phy_power_off(struct phy *phy);
231int phy_set_mode_ext(struct phy *phy, enum phy_mode mode, int submode);
232#define phy_set_mode(phy, mode) \
233 phy_set_mode_ext(phy, mode, 0)
234int phy_set_media(struct phy *phy, enum phy_media media);
235int phy_set_speed(struct phy *phy, int speed);
236int phy_configure(struct phy *phy, union phy_configure_opts *opts);
237int phy_validate(struct phy *phy, enum phy_mode mode, int submode,
238 union phy_configure_opts *opts);
239
240static inline enum phy_mode phy_get_mode(struct phy *phy)
241{
242 return phy->attrs.mode;
243}
244int phy_reset(struct phy *phy);
245int phy_calibrate(struct phy *phy);
246static inline int phy_get_bus_width(struct phy *phy)
247{
248 return phy->attrs.bus_width;
249}
250static inline void phy_set_bus_width(struct phy *phy, int bus_width)
251{
252 phy->attrs.bus_width = bus_width;
253}
254struct phy *phy_get(struct device *dev, const char *string);
255struct phy *devm_phy_get(struct device *dev, const char *string);
256struct phy *devm_phy_optional_get(struct device *dev, const char *string);
257struct phy *devm_of_phy_get(struct device *dev, struct device_node *np,
258 const char *con_id);
259struct phy *devm_of_phy_optional_get(struct device *dev, struct device_node *np,
260 const char *con_id);
261struct phy *devm_of_phy_get_by_index(struct device *dev, struct device_node *np,
262 int index);
263void of_phy_put(struct phy *phy);
264void phy_put(struct device *dev, struct phy *phy);
265void devm_phy_put(struct device *dev, struct phy *phy);
266struct phy *of_phy_get(struct device_node *np, const char *con_id);
267struct phy *of_phy_simple_xlate(struct device *dev,
268 struct of_phandle_args *args);
269struct phy *phy_create(struct device *dev, struct device_node *node,
270 const struct phy_ops *ops);
271struct phy *devm_phy_create(struct device *dev, struct device_node *node,
272 const struct phy_ops *ops);
273void phy_destroy(struct phy *phy);
274void devm_phy_destroy(struct device *dev, struct phy *phy);
275struct phy_provider *__of_phy_provider_register(struct device *dev,
276 struct device_node *children, struct module *owner,
277 struct phy * (*of_xlate)(struct device *dev,
278 struct of_phandle_args *args));
279struct phy_provider *__devm_of_phy_provider_register(struct device *dev,
280 struct device_node *children, struct module *owner,
281 struct phy * (*of_xlate)(struct device *dev,
282 struct of_phandle_args *args));
283void of_phy_provider_unregister(struct phy_provider *phy_provider);
284void devm_of_phy_provider_unregister(struct device *dev,
285 struct phy_provider *phy_provider);
286int phy_create_lookup(struct phy *phy, const char *con_id, const char *dev_id);
287void phy_remove_lookup(struct phy *phy, const char *con_id, const char *dev_id);
288#else
289static inline int phy_pm_runtime_get(struct phy *phy)
290{
291 if (!phy)
292 return 0;
293 return -ENOSYS;
294}
295
296static inline int phy_pm_runtime_get_sync(struct phy *phy)
297{
298 if (!phy)
299 return 0;
300 return -ENOSYS;
301}
302
303static inline int phy_pm_runtime_put(struct phy *phy)
304{
305 if (!phy)
306 return 0;
307 return -ENOSYS;
308}
309
310static inline int phy_pm_runtime_put_sync(struct phy *phy)
311{
312 if (!phy)
313 return 0;
314 return -ENOSYS;
315}
316
317static inline void phy_pm_runtime_allow(struct phy *phy)
318{
319 return;
320}
321
322static inline void phy_pm_runtime_forbid(struct phy *phy)
323{
324 return;
325}
326
327static inline int phy_init(struct phy *phy)
328{
329 if (!phy)
330 return 0;
331 return -ENOSYS;
332}
333
334static inline int phy_exit(struct phy *phy)
335{
336 if (!phy)
337 return 0;
338 return -ENOSYS;
339}
340
341static inline int phy_power_on(struct phy *phy)
342{
343 if (!phy)
344 return 0;
345 return -ENOSYS;
346}
347
348static inline int phy_power_off(struct phy *phy)
349{
350 if (!phy)
351 return 0;
352 return -ENOSYS;
353}
354
355static inline int phy_set_mode_ext(struct phy *phy, enum phy_mode mode,
356 int submode)
357{
358 if (!phy)
359 return 0;
360 return -ENOSYS;
361}
362
363#define phy_set_mode(phy, mode) \
364 phy_set_mode_ext(phy, mode, 0)
365
366static inline int phy_set_media(struct phy *phy, enum phy_media media)
367{
368 if (!phy)
369 return 0;
370 return -ENODEV;
371}
372
373static inline int phy_set_speed(struct phy *phy, int speed)
374{
375 if (!phy)
376 return 0;
377 return -ENODEV;
378}
379
380static inline enum phy_mode phy_get_mode(struct phy *phy)
381{
382 return PHY_MODE_INVALID;
383}
384
385static inline int phy_reset(struct phy *phy)
386{
387 if (!phy)
388 return 0;
389 return -ENOSYS;
390}
391
392static inline int phy_calibrate(struct phy *phy)
393{
394 if (!phy)
395 return 0;
396 return -ENOSYS;
397}
398
399static inline int phy_configure(struct phy *phy,
400 union phy_configure_opts *opts)
401{
402 if (!phy)
403 return 0;
404
405 return -ENOSYS;
406}
407
408static inline int phy_validate(struct phy *phy, enum phy_mode mode, int submode,
409 union phy_configure_opts *opts)
410{
411 if (!phy)
412 return 0;
413
414 return -ENOSYS;
415}
416
417static inline int phy_get_bus_width(struct phy *phy)
418{
419 return -ENOSYS;
420}
421
422static inline void phy_set_bus_width(struct phy *phy, int bus_width)
423{
424 return;
425}
426
427static inline struct phy *phy_get(struct device *dev, const char *string)
428{
429 return ERR_PTR(-ENOSYS);
430}
431
432static inline struct phy *devm_phy_get(struct device *dev, const char *string)
433{
434 return ERR_PTR(-ENOSYS);
435}
436
437static inline struct phy *devm_phy_optional_get(struct device *dev,
438 const char *string)
439{
440 return NULL;
441}
442
443static inline struct phy *devm_of_phy_get(struct device *dev,
444 struct device_node *np,
445 const char *con_id)
446{
447 return ERR_PTR(-ENOSYS);
448}
449
450static inline struct phy *devm_of_phy_optional_get(struct device *dev,
451 struct device_node *np,
452 const char *con_id)
453{
454 return NULL;
455}
456
457static inline struct phy *devm_of_phy_get_by_index(struct device *dev,
458 struct device_node *np,
459 int index)
460{
461 return ERR_PTR(-ENOSYS);
462}
463
464static inline void of_phy_put(struct phy *phy)
465{
466}
467
468static inline void phy_put(struct device *dev, struct phy *phy)
469{
470}
471
472static inline void devm_phy_put(struct device *dev, struct phy *phy)
473{
474}
475
476static inline struct phy *of_phy_get(struct device_node *np, const char *con_id)
477{
478 return ERR_PTR(-ENOSYS);
479}
480
481static inline struct phy *of_phy_simple_xlate(struct device *dev,
482 struct of_phandle_args *args)
483{
484 return ERR_PTR(-ENOSYS);
485}
486
487static inline struct phy *phy_create(struct device *dev,
488 struct device_node *node,
489 const struct phy_ops *ops)
490{
491 return ERR_PTR(-ENOSYS);
492}
493
494static inline struct phy *devm_phy_create(struct device *dev,
495 struct device_node *node,
496 const struct phy_ops *ops)
497{
498 return ERR_PTR(-ENOSYS);
499}
500
501static inline void phy_destroy(struct phy *phy)
502{
503}
504
505static inline void devm_phy_destroy(struct device *dev, struct phy *phy)
506{
507}
508
509static inline struct phy_provider *__of_phy_provider_register(
510 struct device *dev, struct device_node *children, struct module *owner,
511 struct phy * (*of_xlate)(struct device *dev,
512 struct of_phandle_args *args))
513{
514 return ERR_PTR(-ENOSYS);
515}
516
517static inline struct phy_provider *__devm_of_phy_provider_register(struct device
518 *dev, struct device_node *children, struct module *owner,
519 struct phy * (*of_xlate)(struct device *dev,
520 struct of_phandle_args *args))
521{
522 return ERR_PTR(-ENOSYS);
523}
524
525static inline void of_phy_provider_unregister(struct phy_provider *phy_provider)
526{
527}
528
529static inline void devm_of_phy_provider_unregister(struct device *dev,
530 struct phy_provider *phy_provider)
531{
532}
533static inline int
534phy_create_lookup(struct phy *phy, const char *con_id, const char *dev_id)
535{
536 return 0;
537}
538static inline void phy_remove_lookup(struct phy *phy, const char *con_id,
539 const char *dev_id) { }
540#endif
541
542#endif /* __DRIVERS_PHY_H */