xref: /linux-6.15/include/linux/phy/phy.h (revision b02d41d8)
12874c5fdSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */
2ff764963SKishon Vijay Abraham I /*
3ff764963SKishon Vijay Abraham I  * phy.h -- generic phy header file
4ff764963SKishon Vijay Abraham I  *
5ff764963SKishon Vijay Abraham I  * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com
6ff764963SKishon Vijay Abraham I  *
7ff764963SKishon Vijay Abraham I  * Author: Kishon Vijay Abraham I <[email protected]>
8ff764963SKishon Vijay Abraham I  */
9ff764963SKishon Vijay Abraham I 
10ff764963SKishon Vijay Abraham I #ifndef __DRIVERS_PHY_H
11ff764963SKishon Vijay Abraham I #define __DRIVERS_PHY_H
12ff764963SKishon Vijay Abraham I 
13ff764963SKishon Vijay Abraham I #include <linux/err.h>
14ff764963SKishon Vijay Abraham I #include <linux/of.h>
15ff764963SKishon Vijay Abraham I #include <linux/device.h>
16ff764963SKishon Vijay Abraham I #include <linux/pm_runtime.h>
173be88125SRoger Quadros #include <linux/regulator/consumer.h>
18ff764963SKishon Vijay Abraham I 
1942d06847SYuti Amonkar #include <linux/phy/phy-dp.h>
203abfaefbSLiu Ying #include <linux/phy/phy-lvds.h>
212ed86999SMaxime Ripard #include <linux/phy/phy-mipi-dphy.h>
222ed86999SMaxime Ripard 
23ff764963SKishon Vijay Abraham I struct phy;
24ff764963SKishon Vijay Abraham I 
25300eb013SDavid Lechner enum phy_mode {
26300eb013SDavid Lechner 	PHY_MODE_INVALID,
27300eb013SDavid Lechner 	PHY_MODE_USB_HOST,
283b3cd24aSManu Gautam 	PHY_MODE_USB_HOST_LS,
293b3cd24aSManu Gautam 	PHY_MODE_USB_HOST_FS,
303b3cd24aSManu Gautam 	PHY_MODE_USB_HOST_HS,
313b3cd24aSManu Gautam 	PHY_MODE_USB_HOST_SS,
32300eb013SDavid Lechner 	PHY_MODE_USB_DEVICE,
333b3cd24aSManu Gautam 	PHY_MODE_USB_DEVICE_LS,
343b3cd24aSManu Gautam 	PHY_MODE_USB_DEVICE_FS,
353b3cd24aSManu Gautam 	PHY_MODE_USB_DEVICE_HS,
363b3cd24aSManu Gautam 	PHY_MODE_USB_DEVICE_SS,
37300eb013SDavid Lechner 	PHY_MODE_USB_OTG,
38fd3e4c98SVivek Gautam 	PHY_MODE_UFS_HS_A,
39fd3e4c98SVivek Gautam 	PHY_MODE_UFS_HS_B,
40c2a90025SQuentin Schulz 	PHY_MODE_PCIE,
412af8caeeSGrygorii Strashko 	PHY_MODE_ETHERNET,
42c8457828SMaxime Ripard 	PHY_MODE_MIPI_DPHY,
43711b2bfbSHeiko Stuebner 	PHY_MODE_SATA,
44711b2bfbSHeiko Stuebner 	PHY_MODE_LVDS,
4542d06847SYuti Amonkar 	PHY_MODE_DP
46300eb013SDavid Lechner };
47300eb013SDavid Lechner 
486c172e73SSteen Hegelund enum phy_media {
496c172e73SSteen Hegelund 	PHY_MEDIA_DEFAULT,
506c172e73SSteen Hegelund 	PHY_MEDIA_SR,
516c172e73SSteen Hegelund 	PHY_MEDIA_DAC,
526c172e73SSteen Hegelund };
536c172e73SSteen Hegelund 
54ff764963SKishon Vijay Abraham I /**
55aeaac93dSMaxime Ripard  * union phy_configure_opts - Opaque generic phy configuration
562ed86999SMaxime Ripard  *
572ed86999SMaxime Ripard  * @mipi_dphy:	Configuration set applicable for phys supporting
582ed86999SMaxime Ripard  *		the MIPI_DPHY phy mode.
5942d06847SYuti Amonkar  * @dp:		Configuration set applicable for phys supporting
6042d06847SYuti Amonkar  *		the DisplayPort protocol.
613abfaefbSLiu Ying  * @lvds:	Configuration set applicable for phys supporting
623abfaefbSLiu Ying  *		the LVDS phy mode.
63aeaac93dSMaxime Ripard  */
64aeaac93dSMaxime Ripard union phy_configure_opts {
652ed86999SMaxime Ripard 	struct phy_configure_opts_mipi_dphy	mipi_dphy;
6642d06847SYuti Amonkar 	struct phy_configure_opts_dp		dp;
673abfaefbSLiu Ying 	struct phy_configure_opts_lvds		lvds;
68aeaac93dSMaxime Ripard };
69aeaac93dSMaxime Ripard 
70aeaac93dSMaxime Ripard /**
71ff764963SKishon Vijay Abraham I  * struct phy_ops - set of function pointers for performing phy operations
72ff764963SKishon Vijay Abraham I  * @init: operation to be performed for initializing phy
73ff764963SKishon Vijay Abraham I  * @exit: operation to be performed while exiting
74ff764963SKishon Vijay Abraham I  * @power_on: powering on the phy
75ff764963SKishon Vijay Abraham I  * @power_off: powering off the phy
76300eb013SDavid Lechner  * @set_mode: set the mode of the phy
776c172e73SSteen Hegelund  * @set_media: set the media type of the phy (optional)
786c172e73SSteen Hegelund  * @set_speed: set the speed of the phy (optional)
79cac18ecbSRandy Li  * @reset: resetting the phy
8036914111SAndrzej Pietrasiewicz  * @calibrate: calibrate the phy
81fec06b2bSKishon Vijay Abraham I  * @release: ops to be performed while the consumer relinquishes the PHY
82ff764963SKishon Vijay Abraham I  * @owner: the module owner containing the ops
83ff764963SKishon Vijay Abraham I  */
84ff764963SKishon Vijay Abraham I struct phy_ops {
85ff764963SKishon Vijay Abraham I 	int	(*init)(struct phy *phy);
86ff764963SKishon Vijay Abraham I 	int	(*exit)(struct phy *phy);
87ff764963SKishon Vijay Abraham I 	int	(*power_on)(struct phy *phy);
88ff764963SKishon Vijay Abraham I 	int	(*power_off)(struct phy *phy);
8979a5a18aSGrygorii Strashko 	int	(*set_mode)(struct phy *phy, enum phy_mode mode, int submode);
906c172e73SSteen Hegelund 	int	(*set_media)(struct phy *phy, enum phy_media media);
916c172e73SSteen Hegelund 	int	(*set_speed)(struct phy *phy, int speed);
92aeaac93dSMaxime Ripard 
93aeaac93dSMaxime Ripard 	/**
94aeaac93dSMaxime Ripard 	 * @configure:
95aeaac93dSMaxime Ripard 	 *
96aeaac93dSMaxime Ripard 	 * Optional.
97aeaac93dSMaxime Ripard 	 *
98aeaac93dSMaxime Ripard 	 * Used to change the PHY parameters. phy_init() must have
99aeaac93dSMaxime Ripard 	 * been called on the phy.
100aeaac93dSMaxime Ripard 	 *
101aeaac93dSMaxime Ripard 	 * Returns: 0 if successful, an negative error code otherwise
102aeaac93dSMaxime Ripard 	 */
103aeaac93dSMaxime Ripard 	int	(*configure)(struct phy *phy, union phy_configure_opts *opts);
104aeaac93dSMaxime Ripard 
105aeaac93dSMaxime Ripard 	/**
106aeaac93dSMaxime Ripard 	 * @validate:
107aeaac93dSMaxime Ripard 	 *
108aeaac93dSMaxime Ripard 	 * Optional.
109aeaac93dSMaxime Ripard 	 *
110aeaac93dSMaxime Ripard 	 * Used to check that the current set of parameters can be
111aeaac93dSMaxime Ripard 	 * handled by the phy. Implementations are free to tune the
112aeaac93dSMaxime Ripard 	 * parameters passed as arguments if needed by some
113aeaac93dSMaxime Ripard 	 * implementation detail or constraints. It must not change
114aeaac93dSMaxime Ripard 	 * any actual configuration of the PHY, so calling it as many
115aeaac93dSMaxime Ripard 	 * times as deemed fit by the consumer must have no side
116aeaac93dSMaxime Ripard 	 * effect.
117aeaac93dSMaxime Ripard 	 *
118aeaac93dSMaxime Ripard 	 * Returns: 0 if the configuration can be applied, an negative
119aeaac93dSMaxime Ripard 	 * error code otherwise
120aeaac93dSMaxime Ripard 	 */
121aeaac93dSMaxime Ripard 	int	(*validate)(struct phy *phy, enum phy_mode mode, int submode,
122aeaac93dSMaxime Ripard 			    union phy_configure_opts *opts);
123cac18ecbSRandy Li 	int	(*reset)(struct phy *phy);
12436914111SAndrzej Pietrasiewicz 	int	(*calibrate)(struct phy *phy);
1255de5f1e2SStanley Chang 
1265de5f1e2SStanley Chang 	/* notify phy connect status change */
1275de5f1e2SStanley Chang 	int	(*connect)(struct phy *phy, int port);
1285de5f1e2SStanley Chang 	int	(*disconnect)(struct phy *phy, int port);
1295de5f1e2SStanley Chang 
130fec06b2bSKishon Vijay Abraham I 	void	(*release)(struct phy *phy);
131ff764963SKishon Vijay Abraham I 	struct module *owner;
132ff764963SKishon Vijay Abraham I };
133ff764963SKishon Vijay Abraham I 
134ff764963SKishon Vijay Abraham I /**
1358feed347SMatt Porter  * struct phy_attrs - represents phy attributes
1368feed347SMatt Porter  * @bus_width: Data path width implemented by PHY
137307773f5SAswath Govindraju  * @max_link_rate: Maximum link rate supported by PHY (units to be decided by producer and consumer)
138a3c9311fSRobert P. J. Day  * @mode: PHY mode
1398feed347SMatt Porter  */
1408feed347SMatt Porter struct phy_attrs {
1418feed347SMatt Porter 	u32			bus_width;
142a25536e8SSwapnil Jakhade 	u32			max_link_rate;
1433b3cd24aSManu Gautam 	enum phy_mode		mode;
1448feed347SMatt Porter };
1458feed347SMatt Porter 
1468feed347SMatt Porter /**
147ff764963SKishon Vijay Abraham I  * struct phy - represents the phy device
148ff764963SKishon Vijay Abraham I  * @dev: phy device
149ff764963SKishon Vijay Abraham I  * @id: id of the phy device
150ff764963SKishon Vijay Abraham I  * @ops: function pointers for performing phy operations
151ff764963SKishon Vijay Abraham I  * @mutex: mutex to protect phy_ops
152ff764963SKishon Vijay Abraham I  * @init_count: used to protect when the PHY is used by multiple consumers
153ff764963SKishon Vijay Abraham I  * @power_count: used to protect when the PHY is used by multiple consumers
154becaf17aSDov Levenglick  * @attrs: used to specify PHY specific attributes
155becaf17aSDov Levenglick  * @pwr: power regulator associated with the phy
15691694772SChunfeng Yun  * @debugfs: debugfs directory
157ff764963SKishon Vijay Abraham I  */
158ff764963SKishon Vijay Abraham I struct phy {
159ff764963SKishon Vijay Abraham I 	struct device		dev;
160ff764963SKishon Vijay Abraham I 	int			id;
161ff764963SKishon Vijay Abraham I 	const struct phy_ops	*ops;
162ff764963SKishon Vijay Abraham I 	struct mutex		mutex;
163ff764963SKishon Vijay Abraham I 	int			init_count;
164ff764963SKishon Vijay Abraham I 	int			power_count;
1658feed347SMatt Porter 	struct phy_attrs	attrs;
1663be88125SRoger Quadros 	struct regulator	*pwr;
16791694772SChunfeng Yun 	struct dentry		*debugfs;
168ff764963SKishon Vijay Abraham I };
169ff764963SKishon Vijay Abraham I 
170ff764963SKishon Vijay Abraham I /**
171ff764963SKishon Vijay Abraham I  * struct phy_provider - represents the phy provider
172ff764963SKishon Vijay Abraham I  * @dev: phy provider device
173becaf17aSDov Levenglick  * @children: can be used to override the default (dev->of_node) child node
174ff764963SKishon Vijay Abraham I  * @owner: the module owner having of_xlate
175ff764963SKishon Vijay Abraham I  * @list: to maintain a linked list of PHY providers
176becaf17aSDov Levenglick  * @of_xlate: function pointer to obtain phy instance from phy pointer
177ff764963SKishon Vijay Abraham I  */
178ff764963SKishon Vijay Abraham I struct phy_provider {
179ff764963SKishon Vijay Abraham I 	struct device		*dev;
1801140f7c8SThierry Reding 	struct device_node	*children;
181ff764963SKishon Vijay Abraham I 	struct module		*owner;
182ff764963SKishon Vijay Abraham I 	struct list_head	list;
183ff764963SKishon Vijay Abraham I 	struct phy * (*of_xlate)(struct device *dev,
184*00ca8a15SKrzysztof Kozlowski 				 const struct of_phandle_args *args);
185ff764963SKishon Vijay Abraham I };
186ff764963SKishon Vijay Abraham I 
187becaf17aSDov Levenglick /**
188becaf17aSDov Levenglick  * struct phy_lookup - PHY association in list of phys managed by the phy driver
189becaf17aSDov Levenglick  * @node: list node
190becaf17aSDov Levenglick  * @dev_id: the device of the association
191becaf17aSDov Levenglick  * @con_id: connection ID string on device
192becaf17aSDov Levenglick  * @phy: the phy of the association
193becaf17aSDov Levenglick  */
194b7bc15b9SHeikki Krogerus struct phy_lookup {
195b7bc15b9SHeikki Krogerus 	struct list_head node;
196b7bc15b9SHeikki Krogerus 	const char *dev_id;
197b7bc15b9SHeikki Krogerus 	const char *con_id;
198b7bc15b9SHeikki Krogerus 	struct phy *phy;
199b7bc15b9SHeikki Krogerus };
200b7bc15b9SHeikki Krogerus 
201d4510574SHeikki Krogerus #define	to_phy(a)	(container_of((a), struct phy, dev))
202ff764963SKishon Vijay Abraham I 
203ff764963SKishon Vijay Abraham I #define	of_phy_provider_register(dev, xlate)	\
2041140f7c8SThierry Reding 	__of_phy_provider_register((dev), NULL, THIS_MODULE, (xlate))
205ff764963SKishon Vijay Abraham I 
206ff764963SKishon Vijay Abraham I #define	devm_of_phy_provider_register(dev, xlate)	\
2071140f7c8SThierry Reding 	__devm_of_phy_provider_register((dev), NULL, THIS_MODULE, (xlate))
2081140f7c8SThierry Reding 
2091140f7c8SThierry Reding #define of_phy_provider_register_full(dev, children, xlate) \
2101140f7c8SThierry Reding 	__of_phy_provider_register(dev, children, THIS_MODULE, xlate)
2111140f7c8SThierry Reding 
2121140f7c8SThierry Reding #define devm_of_phy_provider_register_full(dev, children, xlate) \
2131140f7c8SThierry Reding 	__devm_of_phy_provider_register(dev, children, THIS_MODULE, xlate)
214ff764963SKishon Vijay Abraham I 
phy_set_drvdata(struct phy * phy,void * data)215ff764963SKishon Vijay Abraham I static inline void phy_set_drvdata(struct phy *phy, void *data)
216ff764963SKishon Vijay Abraham I {
217ff764963SKishon Vijay Abraham I 	dev_set_drvdata(&phy->dev, data);
218ff764963SKishon Vijay Abraham I }
219ff764963SKishon Vijay Abraham I 
phy_get_drvdata(struct phy * phy)220ff764963SKishon Vijay Abraham I static inline void *phy_get_drvdata(struct phy *phy)
221ff764963SKishon Vijay Abraham I {
222ff764963SKishon Vijay Abraham I 	return dev_get_drvdata(&phy->dev);
223ff764963SKishon Vijay Abraham I }
224ff764963SKishon Vijay Abraham I 
225ff764963SKishon Vijay Abraham I #if IS_ENABLED(CONFIG_GENERIC_PHY)
226ff764963SKishon Vijay Abraham I int phy_pm_runtime_get(struct phy *phy);
227ff764963SKishon Vijay Abraham I int phy_pm_runtime_get_sync(struct phy *phy);
228ff764963SKishon Vijay Abraham I int phy_pm_runtime_put(struct phy *phy);
229ff764963SKishon Vijay Abraham I int phy_pm_runtime_put_sync(struct phy *phy);
230ff764963SKishon Vijay Abraham I int phy_init(struct phy *phy);
231ff764963SKishon Vijay Abraham I int phy_exit(struct phy *phy);
232ff764963SKishon Vijay Abraham I int phy_power_on(struct phy *phy);
233ff764963SKishon Vijay Abraham I int phy_power_off(struct phy *phy);
23479a5a18aSGrygorii Strashko int phy_set_mode_ext(struct phy *phy, enum phy_mode mode, int submode);
23579a5a18aSGrygorii Strashko #define phy_set_mode(phy, mode) \
23679a5a18aSGrygorii Strashko 	phy_set_mode_ext(phy, mode, 0)
2376c172e73SSteen Hegelund int phy_set_media(struct phy *phy, enum phy_media media);
2386c172e73SSteen Hegelund int phy_set_speed(struct phy *phy, int speed);
239aeaac93dSMaxime Ripard int phy_configure(struct phy *phy, union phy_configure_opts *opts);
240aeaac93dSMaxime Ripard int phy_validate(struct phy *phy, enum phy_mode mode, int submode,
241aeaac93dSMaxime Ripard 		 union phy_configure_opts *opts);
24279a5a18aSGrygorii Strashko 
phy_get_mode(struct phy * phy)2433b3cd24aSManu Gautam static inline enum phy_mode phy_get_mode(struct phy *phy)
2443b3cd24aSManu Gautam {
2453b3cd24aSManu Gautam 	return phy->attrs.mode;
2463b3cd24aSManu Gautam }
247cac18ecbSRandy Li int phy_reset(struct phy *phy);
24836914111SAndrzej Pietrasiewicz int phy_calibrate(struct phy *phy);
2495de5f1e2SStanley Chang int phy_notify_connect(struct phy *phy, int port);
2505de5f1e2SStanley Chang int phy_notify_disconnect(struct phy *phy, int port);
phy_get_bus_width(struct phy * phy)2518feed347SMatt Porter static inline int phy_get_bus_width(struct phy *phy)
2528feed347SMatt Porter {
2538feed347SMatt Porter 	return phy->attrs.bus_width;
2548feed347SMatt Porter }
phy_set_bus_width(struct phy * phy,int bus_width)2558feed347SMatt Porter static inline void phy_set_bus_width(struct phy *phy, int bus_width)
2568feed347SMatt Porter {
2578feed347SMatt Porter 	phy->attrs.bus_width = bus_width;
2588feed347SMatt Porter }
259ff764963SKishon Vijay Abraham I struct phy *phy_get(struct device *dev, const char *string);
260ff764963SKishon Vijay Abraham I struct phy *devm_phy_get(struct device *dev, const char *string);
261788a4d56SAndrew Lunn struct phy *devm_phy_optional_get(struct device *dev, const char *string);
262b5d682f4SKamil Debski struct phy *devm_of_phy_get(struct device *dev, struct device_node *np,
263b5d682f4SKamil Debski 			    const char *con_id);
264d02aa181SGeert Uytterhoeven struct phy *devm_of_phy_optional_get(struct device *dev, struct device_node *np,
265d02aa181SGeert Uytterhoeven 				     const char *con_id);
2666be109b3SArun Ramamurthy struct phy *devm_of_phy_get_by_index(struct device *dev, struct device_node *np,
2676be109b3SArun Ramamurthy 				     int index);
268987351e1SAlexandre Torgue void of_phy_put(struct phy *phy);
269987351e1SAlexandre Torgue void phy_put(struct device *dev, struct phy *phy);
270ff764963SKishon Vijay Abraham I void devm_phy_put(struct device *dev, struct phy *phy);
2710b3f3b2cSKamil Debski struct phy *of_phy_get(struct device_node *np, const char *con_id);
272ff764963SKishon Vijay Abraham I struct phy *of_phy_simple_xlate(struct device *dev,
273*00ca8a15SKrzysztof Kozlowski 				const struct of_phandle_args *args);
274f0ed8176SKishon Vijay Abraham I struct phy *phy_create(struct device *dev, struct device_node *node,
275dbc98635SHeikki Krogerus 		       const struct phy_ops *ops);
276f0ed8176SKishon Vijay Abraham I struct phy *devm_phy_create(struct device *dev, struct device_node *node,
277dbc98635SHeikki Krogerus 			    const struct phy_ops *ops);
278ff764963SKishon Vijay Abraham I void phy_destroy(struct phy *phy);
279ff764963SKishon Vijay Abraham I void devm_phy_destroy(struct device *dev, struct phy *phy);
280ff764963SKishon Vijay Abraham I struct phy_provider *__of_phy_provider_register(struct device *dev,
2811140f7c8SThierry Reding 	struct device_node *children, struct module *owner,
2821140f7c8SThierry Reding 	struct phy * (*of_xlate)(struct device *dev,
283*00ca8a15SKrzysztof Kozlowski 				 const struct of_phandle_args *args));
284ff764963SKishon Vijay Abraham I struct phy_provider *__devm_of_phy_provider_register(struct device *dev,
2851140f7c8SThierry Reding 	struct device_node *children, struct module *owner,
2861140f7c8SThierry Reding 	struct phy * (*of_xlate)(struct device *dev,
287*00ca8a15SKrzysztof Kozlowski 				 const struct of_phandle_args *args));
288ff764963SKishon Vijay Abraham I void of_phy_provider_unregister(struct phy_provider *phy_provider);
289ff764963SKishon Vijay Abraham I void devm_of_phy_provider_unregister(struct device *dev,
290ff764963SKishon Vijay Abraham I 	struct phy_provider *phy_provider);
291b7bc15b9SHeikki Krogerus int phy_create_lookup(struct phy *phy, const char *con_id, const char *dev_id);
292b7bc15b9SHeikki Krogerus void phy_remove_lookup(struct phy *phy, const char *con_id, const char *dev_id);
293ff764963SKishon Vijay Abraham I #else
phy_pm_runtime_get(struct phy * phy)294ff764963SKishon Vijay Abraham I static inline int phy_pm_runtime_get(struct phy *phy)
295ff764963SKishon Vijay Abraham I {
2962b97789fSGrygorii Strashko 	if (!phy)
2972b97789fSGrygorii Strashko 		return 0;
298ff764963SKishon Vijay Abraham I 	return -ENOSYS;
299ff764963SKishon Vijay Abraham I }
300ff764963SKishon Vijay Abraham I 
phy_pm_runtime_get_sync(struct phy * phy)301ff764963SKishon Vijay Abraham I static inline int phy_pm_runtime_get_sync(struct phy *phy)
302ff764963SKishon Vijay Abraham I {
3032b97789fSGrygorii Strashko 	if (!phy)
3042b97789fSGrygorii Strashko 		return 0;
305ff764963SKishon Vijay Abraham I 	return -ENOSYS;
306ff764963SKishon Vijay Abraham I }
307ff764963SKishon Vijay Abraham I 
phy_pm_runtime_put(struct phy * phy)308ff764963SKishon Vijay Abraham I static inline int phy_pm_runtime_put(struct phy *phy)
309ff764963SKishon Vijay Abraham I {
3102b97789fSGrygorii Strashko 	if (!phy)
3112b97789fSGrygorii Strashko 		return 0;
312ff764963SKishon Vijay Abraham I 	return -ENOSYS;
313ff764963SKishon Vijay Abraham I }
314ff764963SKishon Vijay Abraham I 
phy_pm_runtime_put_sync(struct phy * phy)315ff764963SKishon Vijay Abraham I static inline int phy_pm_runtime_put_sync(struct phy *phy)
316ff764963SKishon Vijay Abraham I {
3172b97789fSGrygorii Strashko 	if (!phy)
3182b97789fSGrygorii Strashko 		return 0;
319ff764963SKishon Vijay Abraham I 	return -ENOSYS;
320ff764963SKishon Vijay Abraham I }
321ff764963SKishon Vijay Abraham I 
phy_init(struct phy * phy)322ff764963SKishon Vijay Abraham I static inline int phy_init(struct phy *phy)
323ff764963SKishon Vijay Abraham I {
3242b97789fSGrygorii Strashko 	if (!phy)
3252b97789fSGrygorii Strashko 		return 0;
326ff764963SKishon Vijay Abraham I 	return -ENOSYS;
327ff764963SKishon Vijay Abraham I }
328ff764963SKishon Vijay Abraham I 
phy_exit(struct phy * phy)329ff764963SKishon Vijay Abraham I static inline int phy_exit(struct phy *phy)
330ff764963SKishon Vijay Abraham I {
3312b97789fSGrygorii Strashko 	if (!phy)
3322b97789fSGrygorii Strashko 		return 0;
333ff764963SKishon Vijay Abraham I 	return -ENOSYS;
334ff764963SKishon Vijay Abraham I }
335ff764963SKishon Vijay Abraham I 
phy_power_on(struct phy * phy)336ff764963SKishon Vijay Abraham I static inline int phy_power_on(struct phy *phy)
337ff764963SKishon Vijay Abraham I {
3382b97789fSGrygorii Strashko 	if (!phy)
3392b97789fSGrygorii Strashko 		return 0;
340ff764963SKishon Vijay Abraham I 	return -ENOSYS;
341ff764963SKishon Vijay Abraham I }
342ff764963SKishon Vijay Abraham I 
phy_power_off(struct phy * phy)343ff764963SKishon Vijay Abraham I static inline int phy_power_off(struct phy *phy)
344ff764963SKishon Vijay Abraham I {
3452b97789fSGrygorii Strashko 	if (!phy)
3462b97789fSGrygorii Strashko 		return 0;
347ff764963SKishon Vijay Abraham I 	return -ENOSYS;
348ff764963SKishon Vijay Abraham I }
349ff764963SKishon Vijay Abraham I 
phy_set_mode_ext(struct phy * phy,enum phy_mode mode,int submode)35079a5a18aSGrygorii Strashko static inline int phy_set_mode_ext(struct phy *phy, enum phy_mode mode,
35179a5a18aSGrygorii Strashko 				   int submode)
352300eb013SDavid Lechner {
353300eb013SDavid Lechner 	if (!phy)
354300eb013SDavid Lechner 		return 0;
355300eb013SDavid Lechner 	return -ENOSYS;
356300eb013SDavid Lechner }
357300eb013SDavid Lechner 
35879a5a18aSGrygorii Strashko #define phy_set_mode(phy, mode) \
35979a5a18aSGrygorii Strashko 	phy_set_mode_ext(phy, mode, 0)
36079a5a18aSGrygorii Strashko 
phy_set_media(struct phy * phy,enum phy_media media)3616c172e73SSteen Hegelund static inline int phy_set_media(struct phy *phy, enum phy_media media)
3626c172e73SSteen Hegelund {
3636c172e73SSteen Hegelund 	if (!phy)
3646c172e73SSteen Hegelund 		return 0;
3656c172e73SSteen Hegelund 	return -ENODEV;
3666c172e73SSteen Hegelund }
3676c172e73SSteen Hegelund 
phy_set_speed(struct phy * phy,int speed)3686c172e73SSteen Hegelund static inline int phy_set_speed(struct phy *phy, int speed)
3696c172e73SSteen Hegelund {
3706c172e73SSteen Hegelund 	if (!phy)
3716c172e73SSteen Hegelund 		return 0;
3726c172e73SSteen Hegelund 	return -ENODEV;
3736c172e73SSteen Hegelund }
3746c172e73SSteen Hegelund 
phy_get_mode(struct phy * phy)3753b3cd24aSManu Gautam static inline enum phy_mode phy_get_mode(struct phy *phy)
3763b3cd24aSManu Gautam {
3773b3cd24aSManu Gautam 	return PHY_MODE_INVALID;
3783b3cd24aSManu Gautam }
3793b3cd24aSManu Gautam 
phy_reset(struct phy * phy)38098430c7aSRandy Li static inline int phy_reset(struct phy *phy)
38198430c7aSRandy Li {
38298430c7aSRandy Li 	if (!phy)
38398430c7aSRandy Li 		return 0;
38498430c7aSRandy Li 	return -ENOSYS;
38598430c7aSRandy Li }
38698430c7aSRandy Li 
phy_calibrate(struct phy * phy)38736914111SAndrzej Pietrasiewicz static inline int phy_calibrate(struct phy *phy)
38836914111SAndrzej Pietrasiewicz {
38936914111SAndrzej Pietrasiewicz 	if (!phy)
39036914111SAndrzej Pietrasiewicz 		return 0;
39136914111SAndrzej Pietrasiewicz 	return -ENOSYS;
39236914111SAndrzej Pietrasiewicz }
39336914111SAndrzej Pietrasiewicz 
phy_notify_connect(struct phy * phy,int index)3945de5f1e2SStanley Chang static inline int phy_notify_connect(struct phy *phy, int index)
3955de5f1e2SStanley Chang {
3965de5f1e2SStanley Chang 	if (!phy)
3975de5f1e2SStanley Chang 		return 0;
3985de5f1e2SStanley Chang 	return -ENOSYS;
3995de5f1e2SStanley Chang }
4005de5f1e2SStanley Chang 
phy_notify_disconnect(struct phy * phy,int index)4015de5f1e2SStanley Chang static inline int phy_notify_disconnect(struct phy *phy, int index)
4025de5f1e2SStanley Chang {
4035de5f1e2SStanley Chang 	if (!phy)
4045de5f1e2SStanley Chang 		return 0;
4055de5f1e2SStanley Chang 	return -ENOSYS;
4065de5f1e2SStanley Chang }
4075de5f1e2SStanley Chang 
phy_configure(struct phy * phy,union phy_configure_opts * opts)408aeaac93dSMaxime Ripard static inline int phy_configure(struct phy *phy,
409aeaac93dSMaxime Ripard 				union phy_configure_opts *opts)
410aeaac93dSMaxime Ripard {
411aeaac93dSMaxime Ripard 	if (!phy)
412aeaac93dSMaxime Ripard 		return 0;
413aeaac93dSMaxime Ripard 
414aeaac93dSMaxime Ripard 	return -ENOSYS;
415aeaac93dSMaxime Ripard }
416aeaac93dSMaxime Ripard 
phy_validate(struct phy * phy,enum phy_mode mode,int submode,union phy_configure_opts * opts)417aeaac93dSMaxime Ripard static inline int phy_validate(struct phy *phy, enum phy_mode mode, int submode,
418aeaac93dSMaxime Ripard 			       union phy_configure_opts *opts)
419aeaac93dSMaxime Ripard {
420aeaac93dSMaxime Ripard 	if (!phy)
421aeaac93dSMaxime Ripard 		return 0;
422aeaac93dSMaxime Ripard 
423aeaac93dSMaxime Ripard 	return -ENOSYS;
424aeaac93dSMaxime Ripard }
425aeaac93dSMaxime Ripard 
phy_get_bus_width(struct phy * phy)4268feed347SMatt Porter static inline int phy_get_bus_width(struct phy *phy)
4278feed347SMatt Porter {
4288feed347SMatt Porter 	return -ENOSYS;
4298feed347SMatt Porter }
4308feed347SMatt Porter 
phy_set_bus_width(struct phy * phy,int bus_width)4318feed347SMatt Porter static inline void phy_set_bus_width(struct phy *phy, int bus_width)
4328feed347SMatt Porter {
4338feed347SMatt Porter 	return;
4348feed347SMatt Porter }
4358feed347SMatt Porter 
phy_get(struct device * dev,const char * string)436ff764963SKishon Vijay Abraham I static inline struct phy *phy_get(struct device *dev, const char *string)
437ff764963SKishon Vijay Abraham I {
438ff764963SKishon Vijay Abraham I 	return ERR_PTR(-ENOSYS);
439ff764963SKishon Vijay Abraham I }
440ff764963SKishon Vijay Abraham I 
devm_phy_get(struct device * dev,const char * string)441ff764963SKishon Vijay Abraham I static inline struct phy *devm_phy_get(struct device *dev, const char *string)
442ff764963SKishon Vijay Abraham I {
443ff764963SKishon Vijay Abraham I 	return ERR_PTR(-ENOSYS);
444ff764963SKishon Vijay Abraham I }
445ff764963SKishon Vijay Abraham I 
devm_phy_optional_get(struct device * dev,const char * string)446788a4d56SAndrew Lunn static inline struct phy *devm_phy_optional_get(struct device *dev,
447788a4d56SAndrew Lunn 						const char *string)
448788a4d56SAndrew Lunn {
44911a6e41cSMaxime Ripard 	return NULL;
450788a4d56SAndrew Lunn }
451788a4d56SAndrew Lunn 
devm_of_phy_get(struct device * dev,struct device_node * np,const char * con_id)452b5d682f4SKamil Debski static inline struct phy *devm_of_phy_get(struct device *dev,
453b5d682f4SKamil Debski 					  struct device_node *np,
454b5d682f4SKamil Debski 					  const char *con_id)
455b5d682f4SKamil Debski {
456b5d682f4SKamil Debski 	return ERR_PTR(-ENOSYS);
457b5d682f4SKamil Debski }
458b5d682f4SKamil Debski 
devm_of_phy_optional_get(struct device * dev,struct device_node * np,const char * con_id)459d02aa181SGeert Uytterhoeven static inline struct phy *devm_of_phy_optional_get(struct device *dev,
460d02aa181SGeert Uytterhoeven 						   struct device_node *np,
461d02aa181SGeert Uytterhoeven 						   const char *con_id)
462d02aa181SGeert Uytterhoeven {
463d02aa181SGeert Uytterhoeven 	return NULL;
464d02aa181SGeert Uytterhoeven }
465d02aa181SGeert Uytterhoeven 
devm_of_phy_get_by_index(struct device * dev,struct device_node * np,int index)4666be109b3SArun Ramamurthy static inline struct phy *devm_of_phy_get_by_index(struct device *dev,
4676be109b3SArun Ramamurthy 						   struct device_node *np,
4686be109b3SArun Ramamurthy 						   int index)
4696be109b3SArun Ramamurthy {
4706be109b3SArun Ramamurthy 	return ERR_PTR(-ENOSYS);
4716be109b3SArun Ramamurthy }
4726be109b3SArun Ramamurthy 
of_phy_put(struct phy * phy)473987351e1SAlexandre Torgue static inline void of_phy_put(struct phy *phy)
474987351e1SAlexandre Torgue {
475987351e1SAlexandre Torgue }
476987351e1SAlexandre Torgue 
phy_put(struct device * dev,struct phy * phy)477987351e1SAlexandre Torgue static inline void phy_put(struct device *dev, struct phy *phy)
478ff764963SKishon Vijay Abraham I {
479ff764963SKishon Vijay Abraham I }
480ff764963SKishon Vijay Abraham I 
devm_phy_put(struct device * dev,struct phy * phy)481ff764963SKishon Vijay Abraham I static inline void devm_phy_put(struct device *dev, struct phy *phy)
482ff764963SKishon Vijay Abraham I {
483ff764963SKishon Vijay Abraham I }
484ff764963SKishon Vijay Abraham I 
of_phy_get(struct device_node * np,const char * con_id)4850b3f3b2cSKamil Debski static inline struct phy *of_phy_get(struct device_node *np, const char *con_id)
4860b3f3b2cSKamil Debski {
4870b3f3b2cSKamil Debski 	return ERR_PTR(-ENOSYS);
4880b3f3b2cSKamil Debski }
4890b3f3b2cSKamil Debski 
of_phy_simple_xlate(struct device * dev,const struct of_phandle_args * args)490ff764963SKishon Vijay Abraham I static inline struct phy *of_phy_simple_xlate(struct device *dev,
491*00ca8a15SKrzysztof Kozlowski 					      const struct of_phandle_args *args)
492ff764963SKishon Vijay Abraham I {
493ff764963SKishon Vijay Abraham I 	return ERR_PTR(-ENOSYS);
494ff764963SKishon Vijay Abraham I }
495ff764963SKishon Vijay Abraham I 
phy_create(struct device * dev,struct device_node * node,const struct phy_ops * ops)496ff764963SKishon Vijay Abraham I static inline struct phy *phy_create(struct device *dev,
497f0ed8176SKishon Vijay Abraham I 				     struct device_node *node,
498dbc98635SHeikki Krogerus 				     const struct phy_ops *ops)
499ff764963SKishon Vijay Abraham I {
500ff764963SKishon Vijay Abraham I 	return ERR_PTR(-ENOSYS);
501ff764963SKishon Vijay Abraham I }
502ff764963SKishon Vijay Abraham I 
devm_phy_create(struct device * dev,struct device_node * node,const struct phy_ops * ops)503ff764963SKishon Vijay Abraham I static inline struct phy *devm_phy_create(struct device *dev,
504f0ed8176SKishon Vijay Abraham I 					  struct device_node *node,
505dbc98635SHeikki Krogerus 					  const struct phy_ops *ops)
506ff764963SKishon Vijay Abraham I {
507ff764963SKishon Vijay Abraham I 	return ERR_PTR(-ENOSYS);
508ff764963SKishon Vijay Abraham I }
509ff764963SKishon Vijay Abraham I 
phy_destroy(struct phy * phy)510ff764963SKishon Vijay Abraham I static inline void phy_destroy(struct phy *phy)
511ff764963SKishon Vijay Abraham I {
512ff764963SKishon Vijay Abraham I }
513ff764963SKishon Vijay Abraham I 
devm_phy_destroy(struct device * dev,struct phy * phy)514ff764963SKishon Vijay Abraham I static inline void devm_phy_destroy(struct device *dev, struct phy *phy)
515ff764963SKishon Vijay Abraham I {
516ff764963SKishon Vijay Abraham I }
517ff764963SKishon Vijay Abraham I 
__of_phy_provider_register(struct device * dev,struct device_node * children,struct module * owner,struct phy * (* of_xlate)(struct device * dev,const struct of_phandle_args * args))518ff764963SKishon Vijay Abraham I static inline struct phy_provider *__of_phy_provider_register(
5191140f7c8SThierry Reding 	struct device *dev, struct device_node *children, struct module *owner,
5201140f7c8SThierry Reding 	struct phy * (*of_xlate)(struct device *dev,
521*00ca8a15SKrzysztof Kozlowski 				 const struct of_phandle_args *args))
522ff764963SKishon Vijay Abraham I {
523ff764963SKishon Vijay Abraham I 	return ERR_PTR(-ENOSYS);
524ff764963SKishon Vijay Abraham I }
525ff764963SKishon Vijay Abraham I 
__devm_of_phy_provider_register(struct device * dev,struct device_node * children,struct module * owner,struct phy * (* of_xlate)(struct device * dev,const struct of_phandle_args * args))526ff764963SKishon Vijay Abraham I static inline struct phy_provider *__devm_of_phy_provider_register(struct device
5271140f7c8SThierry Reding 	*dev, struct device_node *children, struct module *owner,
5281140f7c8SThierry Reding 	struct phy * (*of_xlate)(struct device *dev,
529*00ca8a15SKrzysztof Kozlowski 				 const struct of_phandle_args *args))
530ff764963SKishon Vijay Abraham I {
531ff764963SKishon Vijay Abraham I 	return ERR_PTR(-ENOSYS);
532ff764963SKishon Vijay Abraham I }
533ff764963SKishon Vijay Abraham I 
of_phy_provider_unregister(struct phy_provider * phy_provider)534ff764963SKishon Vijay Abraham I static inline void of_phy_provider_unregister(struct phy_provider *phy_provider)
535ff764963SKishon Vijay Abraham I {
536ff764963SKishon Vijay Abraham I }
537ff764963SKishon Vijay Abraham I 
devm_of_phy_provider_unregister(struct device * dev,struct phy_provider * phy_provider)538ff764963SKishon Vijay Abraham I static inline void devm_of_phy_provider_unregister(struct device *dev,
539ff764963SKishon Vijay Abraham I 	struct phy_provider *phy_provider)
540ff764963SKishon Vijay Abraham I {
541ff764963SKishon Vijay Abraham I }
542b7bc15b9SHeikki Krogerus static inline int
phy_create_lookup(struct phy * phy,const char * con_id,const char * dev_id)543b7bc15b9SHeikki Krogerus phy_create_lookup(struct phy *phy, const char *con_id, const char *dev_id)
544b7bc15b9SHeikki Krogerus {
545b7bc15b9SHeikki Krogerus 	return 0;
546b7bc15b9SHeikki Krogerus }
phy_remove_lookup(struct phy * phy,const char * con_id,const char * dev_id)547b7bc15b9SHeikki Krogerus static inline void phy_remove_lookup(struct phy *phy, const char *con_id,
548b7bc15b9SHeikki Krogerus 				     const char *dev_id) { }
549ff764963SKishon Vijay Abraham I #endif
550ff764963SKishon Vijay Abraham I 
551ff764963SKishon Vijay Abraham I #endif /* __DRIVERS_PHY_H */
552