This source file includes following definitions.
- phy_set_drvdata
- phy_get_drvdata
- phy_get_mode
- phy_get_bus_width
- phy_set_bus_width
- phy_pm_runtime_get
- phy_pm_runtime_get_sync
- phy_pm_runtime_put
- phy_pm_runtime_put_sync
- phy_pm_runtime_allow
- phy_pm_runtime_forbid
- phy_init
- phy_exit
- phy_power_on
- phy_power_off
- phy_set_mode_ext
- phy_get_mode
- phy_reset
- phy_calibrate
- phy_configure
- phy_validate
- phy_get_bus_width
- phy_set_bus_width
- phy_get
- phy_optional_get
- devm_phy_get
- devm_phy_optional_get
- devm_of_phy_get
- devm_of_phy_get_by_index
- phy_put
- devm_phy_put
- of_phy_get
- of_phy_simple_xlate
- phy_create
- devm_phy_create
- phy_destroy
- devm_phy_destroy
- __of_phy_provider_register
- __devm_of_phy_provider_register
- of_phy_provider_unregister
- devm_of_phy_provider_unregister
- phy_create_lookup
- phy_remove_lookup
1
2
3
4
5
6
7
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-mipi-dphy.h>
20
21 struct phy;
22
23 enum phy_mode {
24 PHY_MODE_INVALID,
25 PHY_MODE_USB_HOST,
26 PHY_MODE_USB_HOST_LS,
27 PHY_MODE_USB_HOST_FS,
28 PHY_MODE_USB_HOST_HS,
29 PHY_MODE_USB_HOST_SS,
30 PHY_MODE_USB_DEVICE,
31 PHY_MODE_USB_DEVICE_LS,
32 PHY_MODE_USB_DEVICE_FS,
33 PHY_MODE_USB_DEVICE_HS,
34 PHY_MODE_USB_DEVICE_SS,
35 PHY_MODE_USB_OTG,
36 PHY_MODE_UFS_HS_A,
37 PHY_MODE_UFS_HS_B,
38 PHY_MODE_PCIE,
39 PHY_MODE_ETHERNET,
40 PHY_MODE_MIPI_DPHY,
41 PHY_MODE_SATA
42 };
43
44
45
46
47
48
49
50 union phy_configure_opts {
51 struct phy_configure_opts_mipi_dphy mipi_dphy;
52 };
53
54
55
56
57
58
59
60
61
62
63
64
65
66 struct phy_ops {
67 int (*init)(struct phy *phy);
68 int (*exit)(struct phy *phy);
69 int (*power_on)(struct phy *phy);
70 int (*power_off)(struct phy *phy);
71 int (*set_mode)(struct phy *phy, enum phy_mode mode, int submode);
72
73
74
75
76
77
78
79
80
81
82
83 int (*configure)(struct phy *phy, union phy_configure_opts *opts);
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101 int (*validate)(struct phy *phy, enum phy_mode mode, int submode,
102 union phy_configure_opts *opts);
103 int (*reset)(struct phy *phy);
104 int (*calibrate)(struct phy *phy);
105 void (*release)(struct phy *phy);
106 struct module *owner;
107 };
108
109
110
111
112
113
114 struct phy_attrs {
115 u32 bus_width;
116 enum phy_mode mode;
117 };
118
119
120
121
122
123
124
125
126
127
128
129
130 struct phy {
131 struct device dev;
132 int id;
133 const struct phy_ops *ops;
134 struct mutex mutex;
135 int init_count;
136 int power_count;
137 struct phy_attrs attrs;
138 struct regulator *pwr;
139 };
140
141
142
143
144
145
146
147
148
149 struct phy_provider {
150 struct device *dev;
151 struct device_node *children;
152 struct module *owner;
153 struct list_head list;
154 struct phy * (*of_xlate)(struct device *dev,
155 struct of_phandle_args *args);
156 };
157
158
159
160
161
162
163
164
165 struct phy_lookup {
166 struct list_head node;
167 const char *dev_id;
168 const char *con_id;
169 struct phy *phy;
170 };
171
172 #define to_phy(a) (container_of((a), struct phy, dev))
173
174 #define of_phy_provider_register(dev, xlate) \
175 __of_phy_provider_register((dev), NULL, THIS_MODULE, (xlate))
176
177 #define devm_of_phy_provider_register(dev, xlate) \
178 __devm_of_phy_provider_register((dev), NULL, THIS_MODULE, (xlate))
179
180 #define of_phy_provider_register_full(dev, children, xlate) \
181 __of_phy_provider_register(dev, children, THIS_MODULE, xlate)
182
183 #define devm_of_phy_provider_register_full(dev, children, xlate) \
184 __devm_of_phy_provider_register(dev, children, THIS_MODULE, xlate)
185
186 static inline void phy_set_drvdata(struct phy *phy, void *data)
187 {
188 dev_set_drvdata(&phy->dev, data);
189 }
190
191 static inline void *phy_get_drvdata(struct phy *phy)
192 {
193 return dev_get_drvdata(&phy->dev);
194 }
195
196 #if IS_ENABLED(CONFIG_GENERIC_PHY)
197 int phy_pm_runtime_get(struct phy *phy);
198 int phy_pm_runtime_get_sync(struct phy *phy);
199 int phy_pm_runtime_put(struct phy *phy);
200 int phy_pm_runtime_put_sync(struct phy *phy);
201 void phy_pm_runtime_allow(struct phy *phy);
202 void phy_pm_runtime_forbid(struct phy *phy);
203 int phy_init(struct phy *phy);
204 int phy_exit(struct phy *phy);
205 int phy_power_on(struct phy *phy);
206 int phy_power_off(struct phy *phy);
207 int phy_set_mode_ext(struct phy *phy, enum phy_mode mode, int submode);
208 #define phy_set_mode(phy, mode) \
209 phy_set_mode_ext(phy, mode, 0)
210 int phy_configure(struct phy *phy, union phy_configure_opts *opts);
211 int phy_validate(struct phy *phy, enum phy_mode mode, int submode,
212 union phy_configure_opts *opts);
213
214 static inline enum phy_mode phy_get_mode(struct phy *phy)
215 {
216 return phy->attrs.mode;
217 }
218 int phy_reset(struct phy *phy);
219 int phy_calibrate(struct phy *phy);
220 static inline int phy_get_bus_width(struct phy *phy)
221 {
222 return phy->attrs.bus_width;
223 }
224 static inline void phy_set_bus_width(struct phy *phy, int bus_width)
225 {
226 phy->attrs.bus_width = bus_width;
227 }
228 struct phy *phy_get(struct device *dev, const char *string);
229 struct phy *phy_optional_get(struct device *dev, const char *string);
230 struct phy *devm_phy_get(struct device *dev, const char *string);
231 struct phy *devm_phy_optional_get(struct device *dev, const char *string);
232 struct phy *devm_of_phy_get(struct device *dev, struct device_node *np,
233 const char *con_id);
234 struct phy *devm_of_phy_get_by_index(struct device *dev, struct device_node *np,
235 int index);
236 void phy_put(struct phy *phy);
237 void devm_phy_put(struct device *dev, struct phy *phy);
238 struct phy *of_phy_get(struct device_node *np, const char *con_id);
239 struct phy *of_phy_simple_xlate(struct device *dev,
240 struct of_phandle_args *args);
241 struct phy *phy_create(struct device *dev, struct device_node *node,
242 const struct phy_ops *ops);
243 struct phy *devm_phy_create(struct device *dev, struct device_node *node,
244 const struct phy_ops *ops);
245 void phy_destroy(struct phy *phy);
246 void devm_phy_destroy(struct device *dev, struct phy *phy);
247 struct phy_provider *__of_phy_provider_register(struct device *dev,
248 struct device_node *children, struct module *owner,
249 struct phy * (*of_xlate)(struct device *dev,
250 struct of_phandle_args *args));
251 struct phy_provider *__devm_of_phy_provider_register(struct device *dev,
252 struct device_node *children, struct module *owner,
253 struct phy * (*of_xlate)(struct device *dev,
254 struct of_phandle_args *args));
255 void of_phy_provider_unregister(struct phy_provider *phy_provider);
256 void devm_of_phy_provider_unregister(struct device *dev,
257 struct phy_provider *phy_provider);
258 int phy_create_lookup(struct phy *phy, const char *con_id, const char *dev_id);
259 void phy_remove_lookup(struct phy *phy, const char *con_id, const char *dev_id);
260 #else
261 static inline int phy_pm_runtime_get(struct phy *phy)
262 {
263 if (!phy)
264 return 0;
265 return -ENOSYS;
266 }
267
268 static inline int phy_pm_runtime_get_sync(struct phy *phy)
269 {
270 if (!phy)
271 return 0;
272 return -ENOSYS;
273 }
274
275 static inline int phy_pm_runtime_put(struct phy *phy)
276 {
277 if (!phy)
278 return 0;
279 return -ENOSYS;
280 }
281
282 static inline int phy_pm_runtime_put_sync(struct phy *phy)
283 {
284 if (!phy)
285 return 0;
286 return -ENOSYS;
287 }
288
289 static inline void phy_pm_runtime_allow(struct phy *phy)
290 {
291 return;
292 }
293
294 static inline void phy_pm_runtime_forbid(struct phy *phy)
295 {
296 return;
297 }
298
299 static inline int phy_init(struct phy *phy)
300 {
301 if (!phy)
302 return 0;
303 return -ENOSYS;
304 }
305
306 static inline int phy_exit(struct phy *phy)
307 {
308 if (!phy)
309 return 0;
310 return -ENOSYS;
311 }
312
313 static inline int phy_power_on(struct phy *phy)
314 {
315 if (!phy)
316 return 0;
317 return -ENOSYS;
318 }
319
320 static inline int phy_power_off(struct phy *phy)
321 {
322 if (!phy)
323 return 0;
324 return -ENOSYS;
325 }
326
327 static inline int phy_set_mode_ext(struct phy *phy, enum phy_mode mode,
328 int submode)
329 {
330 if (!phy)
331 return 0;
332 return -ENOSYS;
333 }
334
335 #define phy_set_mode(phy, mode) \
336 phy_set_mode_ext(phy, mode, 0)
337
338 static inline enum phy_mode phy_get_mode(struct phy *phy)
339 {
340 return PHY_MODE_INVALID;
341 }
342
343 static inline int phy_reset(struct phy *phy)
344 {
345 if (!phy)
346 return 0;
347 return -ENOSYS;
348 }
349
350 static inline int phy_calibrate(struct phy *phy)
351 {
352 if (!phy)
353 return 0;
354 return -ENOSYS;
355 }
356
357 static inline int phy_configure(struct phy *phy,
358 union phy_configure_opts *opts)
359 {
360 if (!phy)
361 return 0;
362
363 return -ENOSYS;
364 }
365
366 static inline int phy_validate(struct phy *phy, enum phy_mode mode, int submode,
367 union phy_configure_opts *opts)
368 {
369 if (!phy)
370 return 0;
371
372 return -ENOSYS;
373 }
374
375 static inline int phy_get_bus_width(struct phy *phy)
376 {
377 return -ENOSYS;
378 }
379
380 static inline void phy_set_bus_width(struct phy *phy, int bus_width)
381 {
382 return;
383 }
384
385 static inline struct phy *phy_get(struct device *dev, const char *string)
386 {
387 return ERR_PTR(-ENOSYS);
388 }
389
390 static inline struct phy *phy_optional_get(struct device *dev,
391 const char *string)
392 {
393 return ERR_PTR(-ENOSYS);
394 }
395
396 static inline struct phy *devm_phy_get(struct device *dev, const char *string)
397 {
398 return ERR_PTR(-ENOSYS);
399 }
400
401 static inline struct phy *devm_phy_optional_get(struct device *dev,
402 const char *string)
403 {
404 return NULL;
405 }
406
407 static inline struct phy *devm_of_phy_get(struct device *dev,
408 struct device_node *np,
409 const char *con_id)
410 {
411 return ERR_PTR(-ENOSYS);
412 }
413
414 static inline struct phy *devm_of_phy_get_by_index(struct device *dev,
415 struct device_node *np,
416 int index)
417 {
418 return ERR_PTR(-ENOSYS);
419 }
420
421 static inline void phy_put(struct phy *phy)
422 {
423 }
424
425 static inline void devm_phy_put(struct device *dev, struct phy *phy)
426 {
427 }
428
429 static inline struct phy *of_phy_get(struct device_node *np, const char *con_id)
430 {
431 return ERR_PTR(-ENOSYS);
432 }
433
434 static inline struct phy *of_phy_simple_xlate(struct device *dev,
435 struct of_phandle_args *args)
436 {
437 return ERR_PTR(-ENOSYS);
438 }
439
440 static inline struct phy *phy_create(struct device *dev,
441 struct device_node *node,
442 const struct phy_ops *ops)
443 {
444 return ERR_PTR(-ENOSYS);
445 }
446
447 static inline struct phy *devm_phy_create(struct device *dev,
448 struct device_node *node,
449 const struct phy_ops *ops)
450 {
451 return ERR_PTR(-ENOSYS);
452 }
453
454 static inline void phy_destroy(struct phy *phy)
455 {
456 }
457
458 static inline void devm_phy_destroy(struct device *dev, struct phy *phy)
459 {
460 }
461
462 static inline struct phy_provider *__of_phy_provider_register(
463 struct device *dev, struct device_node *children, struct module *owner,
464 struct phy * (*of_xlate)(struct device *dev,
465 struct of_phandle_args *args))
466 {
467 return ERR_PTR(-ENOSYS);
468 }
469
470 static inline struct phy_provider *__devm_of_phy_provider_register(struct device
471 *dev, struct device_node *children, struct module *owner,
472 struct phy * (*of_xlate)(struct device *dev,
473 struct of_phandle_args *args))
474 {
475 return ERR_PTR(-ENOSYS);
476 }
477
478 static inline void of_phy_provider_unregister(struct phy_provider *phy_provider)
479 {
480 }
481
482 static inline void devm_of_phy_provider_unregister(struct device *dev,
483 struct phy_provider *phy_provider)
484 {
485 }
486 static inline int
487 phy_create_lookup(struct phy *phy, const char *con_id, const char *dev_id)
488 {
489 return 0;
490 }
491 static inline void phy_remove_lookup(struct phy *phy, const char *con_id,
492 const char *dev_id) { }
493 #endif
494
495 #endif