Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 1 | /* |
| 2 | * phy.h -- generic phy header file |
| 3 | * |
| 4 | * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com |
| 5 | * |
| 6 | * Author: Kishon Vijay Abraham I <kishon@ti.com> |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | */ |
| 13 | |
| 14 | #ifndef __DRIVERS_PHY_H |
| 15 | #define __DRIVERS_PHY_H |
| 16 | |
| 17 | #include <linux/err.h> |
| 18 | #include <linux/of.h> |
| 19 | #include <linux/device.h> |
| 20 | #include <linux/pm_runtime.h> |
Roger Quadros | 3be8812 | 2014-07-04 12:55:45 +0300 | [diff] [blame] | 21 | #include <linux/regulator/consumer.h> |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 22 | |
| 23 | struct phy; |
| 24 | |
David Lechner | 300eb01 | 2016-05-09 18:39:59 -0500 | [diff] [blame] | 25 | enum phy_mode { |
| 26 | PHY_MODE_INVALID, |
| 27 | PHY_MODE_USB_HOST, |
Manu Gautam | 3b3cd24 | 2018-01-16 16:27:09 +0530 | [diff] [blame] | 28 | PHY_MODE_USB_HOST_LS, |
| 29 | PHY_MODE_USB_HOST_FS, |
| 30 | PHY_MODE_USB_HOST_HS, |
| 31 | PHY_MODE_USB_HOST_SS, |
David Lechner | 300eb01 | 2016-05-09 18:39:59 -0500 | [diff] [blame] | 32 | PHY_MODE_USB_DEVICE, |
Manu Gautam | 3b3cd24 | 2018-01-16 16:27:09 +0530 | [diff] [blame] | 33 | PHY_MODE_USB_DEVICE_LS, |
| 34 | PHY_MODE_USB_DEVICE_FS, |
| 35 | PHY_MODE_USB_DEVICE_HS, |
| 36 | PHY_MODE_USB_DEVICE_SS, |
David Lechner | 300eb01 | 2016-05-09 18:39:59 -0500 | [diff] [blame] | 37 | PHY_MODE_USB_OTG, |
Antoine Tenart | 5c23f2d | 2017-08-30 10:29:12 +0200 | [diff] [blame] | 38 | PHY_MODE_SGMII, |
Antoine Tenart | 5490b87 | 2018-05-17 10:29:32 +0200 | [diff] [blame] | 39 | PHY_MODE_2500SGMII, |
Antoine Tenart | 5c23f2d | 2017-08-30 10:29:12 +0200 | [diff] [blame] | 40 | PHY_MODE_10GKR, |
Vivek Gautam | fd3e4c9 | 2017-10-12 11:49:33 +0530 | [diff] [blame] | 41 | PHY_MODE_UFS_HS_A, |
| 42 | PHY_MODE_UFS_HS_B, |
David Lechner | 300eb01 | 2016-05-09 18:39:59 -0500 | [diff] [blame] | 43 | }; |
| 44 | |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 45 | /** |
| 46 | * struct phy_ops - set of function pointers for performing phy operations |
| 47 | * @init: operation to be performed for initializing phy |
| 48 | * @exit: operation to be performed while exiting |
| 49 | * @power_on: powering on the phy |
| 50 | * @power_off: powering off the phy |
David Lechner | 300eb01 | 2016-05-09 18:39:59 -0500 | [diff] [blame] | 51 | * @set_mode: set the mode of the phy |
Randy Li | cac18ec | 2016-09-10 02:59:37 +0800 | [diff] [blame] | 52 | * @reset: resetting the phy |
Andrzej Pietrasiewicz | 3691411 | 2017-10-09 14:00:50 +0200 | [diff] [blame] | 53 | * @calibrate: calibrate the phy |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 54 | * @owner: the module owner containing the ops |
| 55 | */ |
| 56 | struct phy_ops { |
| 57 | int (*init)(struct phy *phy); |
| 58 | int (*exit)(struct phy *phy); |
| 59 | int (*power_on)(struct phy *phy); |
| 60 | int (*power_off)(struct phy *phy); |
David Lechner | 300eb01 | 2016-05-09 18:39:59 -0500 | [diff] [blame] | 61 | int (*set_mode)(struct phy *phy, enum phy_mode mode); |
Randy Li | cac18ec | 2016-09-10 02:59:37 +0800 | [diff] [blame] | 62 | int (*reset)(struct phy *phy); |
Andrzej Pietrasiewicz | 3691411 | 2017-10-09 14:00:50 +0200 | [diff] [blame] | 63 | int (*calibrate)(struct phy *phy); |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 64 | struct module *owner; |
| 65 | }; |
| 66 | |
| 67 | /** |
Matt Porter | 8feed34 | 2013-12-19 09:23:02 -0500 | [diff] [blame] | 68 | * struct phy_attrs - represents phy attributes |
| 69 | * @bus_width: Data path width implemented by PHY |
| 70 | */ |
| 71 | struct phy_attrs { |
| 72 | u32 bus_width; |
Manu Gautam | 3b3cd24 | 2018-01-16 16:27:09 +0530 | [diff] [blame] | 73 | enum phy_mode mode; |
Matt Porter | 8feed34 | 2013-12-19 09:23:02 -0500 | [diff] [blame] | 74 | }; |
| 75 | |
| 76 | /** |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 77 | * struct phy - represents the phy device |
| 78 | * @dev: phy device |
| 79 | * @id: id of the phy device |
| 80 | * @ops: function pointers for performing phy operations |
| 81 | * @init_data: list of PHY consumers (non-dt only) |
| 82 | * @mutex: mutex to protect phy_ops |
| 83 | * @init_count: used to protect when the PHY is used by multiple consumers |
| 84 | * @power_count: used to protect when the PHY is used by multiple consumers |
Dov Levenglick | becaf17 | 2018-02-02 18:34:50 +0200 | [diff] [blame] | 85 | * @attrs: used to specify PHY specific attributes |
| 86 | * @pwr: power regulator associated with the phy |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 87 | */ |
| 88 | struct phy { |
| 89 | struct device dev; |
| 90 | int id; |
| 91 | const struct phy_ops *ops; |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 92 | struct mutex mutex; |
| 93 | int init_count; |
| 94 | int power_count; |
Matt Porter | 8feed34 | 2013-12-19 09:23:02 -0500 | [diff] [blame] | 95 | struct phy_attrs attrs; |
Roger Quadros | 3be8812 | 2014-07-04 12:55:45 +0300 | [diff] [blame] | 96 | struct regulator *pwr; |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 97 | }; |
| 98 | |
| 99 | /** |
| 100 | * struct phy_provider - represents the phy provider |
| 101 | * @dev: phy provider device |
Dov Levenglick | becaf17 | 2018-02-02 18:34:50 +0200 | [diff] [blame] | 102 | * @children: can be used to override the default (dev->of_node) child node |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 103 | * @owner: the module owner having of_xlate |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 104 | * @list: to maintain a linked list of PHY providers |
Dov Levenglick | becaf17 | 2018-02-02 18:34:50 +0200 | [diff] [blame] | 105 | * @of_xlate: function pointer to obtain phy instance from phy pointer |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 106 | */ |
| 107 | struct phy_provider { |
| 108 | struct device *dev; |
Thierry Reding | 1140f7c | 2016-04-05 17:17:34 +0200 | [diff] [blame] | 109 | struct device_node *children; |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 110 | struct module *owner; |
| 111 | struct list_head list; |
| 112 | struct phy * (*of_xlate)(struct device *dev, |
| 113 | struct of_phandle_args *args); |
| 114 | }; |
| 115 | |
Dov Levenglick | becaf17 | 2018-02-02 18:34:50 +0200 | [diff] [blame] | 116 | /** |
| 117 | * struct phy_lookup - PHY association in list of phys managed by the phy driver |
| 118 | * @node: list node |
| 119 | * @dev_id: the device of the association |
| 120 | * @con_id: connection ID string on device |
| 121 | * @phy: the phy of the association |
| 122 | */ |
Heikki Krogerus | b7bc15b | 2014-11-19 17:28:18 +0200 | [diff] [blame] | 123 | struct phy_lookup { |
| 124 | struct list_head node; |
| 125 | const char *dev_id; |
| 126 | const char *con_id; |
| 127 | struct phy *phy; |
| 128 | }; |
| 129 | |
Heikki Krogerus | d451057 | 2014-11-19 17:28:17 +0200 | [diff] [blame] | 130 | #define to_phy(a) (container_of((a), struct phy, dev)) |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 131 | |
| 132 | #define of_phy_provider_register(dev, xlate) \ |
Thierry Reding | 1140f7c | 2016-04-05 17:17:34 +0200 | [diff] [blame] | 133 | __of_phy_provider_register((dev), NULL, THIS_MODULE, (xlate)) |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 134 | |
| 135 | #define devm_of_phy_provider_register(dev, xlate) \ |
Thierry Reding | 1140f7c | 2016-04-05 17:17:34 +0200 | [diff] [blame] | 136 | __devm_of_phy_provider_register((dev), NULL, THIS_MODULE, (xlate)) |
| 137 | |
| 138 | #define of_phy_provider_register_full(dev, children, xlate) \ |
| 139 | __of_phy_provider_register(dev, children, THIS_MODULE, xlate) |
| 140 | |
| 141 | #define devm_of_phy_provider_register_full(dev, children, xlate) \ |
| 142 | __devm_of_phy_provider_register(dev, children, THIS_MODULE, xlate) |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 143 | |
| 144 | static inline void phy_set_drvdata(struct phy *phy, void *data) |
| 145 | { |
| 146 | dev_set_drvdata(&phy->dev, data); |
| 147 | } |
| 148 | |
| 149 | static inline void *phy_get_drvdata(struct phy *phy) |
| 150 | { |
| 151 | return dev_get_drvdata(&phy->dev); |
| 152 | } |
| 153 | |
| 154 | #if IS_ENABLED(CONFIG_GENERIC_PHY) |
| 155 | int phy_pm_runtime_get(struct phy *phy); |
| 156 | int phy_pm_runtime_get_sync(struct phy *phy); |
| 157 | int phy_pm_runtime_put(struct phy *phy); |
| 158 | int phy_pm_runtime_put_sync(struct phy *phy); |
| 159 | void phy_pm_runtime_allow(struct phy *phy); |
| 160 | void phy_pm_runtime_forbid(struct phy *phy); |
| 161 | int phy_init(struct phy *phy); |
| 162 | int phy_exit(struct phy *phy); |
| 163 | int phy_power_on(struct phy *phy); |
| 164 | int phy_power_off(struct phy *phy); |
David Lechner | 300eb01 | 2016-05-09 18:39:59 -0500 | [diff] [blame] | 165 | int phy_set_mode(struct phy *phy, enum phy_mode mode); |
Manu Gautam | 3b3cd24 | 2018-01-16 16:27:09 +0530 | [diff] [blame] | 166 | static inline enum phy_mode phy_get_mode(struct phy *phy) |
| 167 | { |
| 168 | return phy->attrs.mode; |
| 169 | } |
Randy Li | cac18ec | 2016-09-10 02:59:37 +0800 | [diff] [blame] | 170 | int phy_reset(struct phy *phy); |
Andrzej Pietrasiewicz | 3691411 | 2017-10-09 14:00:50 +0200 | [diff] [blame] | 171 | int phy_calibrate(struct phy *phy); |
Matt Porter | 8feed34 | 2013-12-19 09:23:02 -0500 | [diff] [blame] | 172 | static inline int phy_get_bus_width(struct phy *phy) |
| 173 | { |
| 174 | return phy->attrs.bus_width; |
| 175 | } |
| 176 | static inline void phy_set_bus_width(struct phy *phy, int bus_width) |
| 177 | { |
| 178 | phy->attrs.bus_width = bus_width; |
| 179 | } |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 180 | struct phy *phy_get(struct device *dev, const char *string); |
Andrew Lunn | 788a4d5 | 2014-02-04 18:33:12 +0100 | [diff] [blame] | 181 | struct phy *phy_optional_get(struct device *dev, const char *string); |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 182 | struct phy *devm_phy_get(struct device *dev, const char *string); |
Andrew Lunn | 788a4d5 | 2014-02-04 18:33:12 +0100 | [diff] [blame] | 183 | struct phy *devm_phy_optional_get(struct device *dev, const char *string); |
Kamil Debski | b5d682f | 2014-03-06 12:16:47 +0100 | [diff] [blame] | 184 | struct phy *devm_of_phy_get(struct device *dev, struct device_node *np, |
| 185 | const char *con_id); |
Arun Ramamurthy | 6be109b | 2015-04-22 16:04:11 -0700 | [diff] [blame] | 186 | struct phy *devm_of_phy_get_by_index(struct device *dev, struct device_node *np, |
| 187 | int index); |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 188 | void phy_put(struct phy *phy); |
| 189 | void devm_phy_put(struct device *dev, struct phy *phy); |
Kamil Debski | 0b3f3b2 | 2014-03-06 12:16:46 +0100 | [diff] [blame] | 190 | struct phy *of_phy_get(struct device_node *np, const char *con_id); |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 191 | struct phy *of_phy_simple_xlate(struct device *dev, |
| 192 | struct of_phandle_args *args); |
Kishon Vijay Abraham I | f0ed817 | 2014-07-14 15:55:02 +0530 | [diff] [blame] | 193 | struct phy *phy_create(struct device *dev, struct device_node *node, |
Heikki Krogerus | dbc9863 | 2014-11-19 17:28:21 +0200 | [diff] [blame] | 194 | const struct phy_ops *ops); |
Kishon Vijay Abraham I | f0ed817 | 2014-07-14 15:55:02 +0530 | [diff] [blame] | 195 | struct phy *devm_phy_create(struct device *dev, struct device_node *node, |
Heikki Krogerus | dbc9863 | 2014-11-19 17:28:21 +0200 | [diff] [blame] | 196 | const struct phy_ops *ops); |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 197 | void phy_destroy(struct phy *phy); |
| 198 | void devm_phy_destroy(struct device *dev, struct phy *phy); |
| 199 | struct phy_provider *__of_phy_provider_register(struct device *dev, |
Thierry Reding | 1140f7c | 2016-04-05 17:17:34 +0200 | [diff] [blame] | 200 | struct device_node *children, struct module *owner, |
| 201 | struct phy * (*of_xlate)(struct device *dev, |
| 202 | struct of_phandle_args *args)); |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 203 | struct phy_provider *__devm_of_phy_provider_register(struct device *dev, |
Thierry Reding | 1140f7c | 2016-04-05 17:17:34 +0200 | [diff] [blame] | 204 | struct device_node *children, struct module *owner, |
| 205 | struct phy * (*of_xlate)(struct device *dev, |
| 206 | struct of_phandle_args *args)); |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 207 | void of_phy_provider_unregister(struct phy_provider *phy_provider); |
| 208 | void devm_of_phy_provider_unregister(struct device *dev, |
| 209 | struct phy_provider *phy_provider); |
Heikki Krogerus | b7bc15b | 2014-11-19 17:28:18 +0200 | [diff] [blame] | 210 | int phy_create_lookup(struct phy *phy, const char *con_id, const char *dev_id); |
| 211 | void phy_remove_lookup(struct phy *phy, const char *con_id, const char *dev_id); |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 212 | #else |
| 213 | static inline int phy_pm_runtime_get(struct phy *phy) |
| 214 | { |
Grygorii Strashko | 2b97789 | 2014-04-19 08:51:44 +0530 | [diff] [blame] | 215 | if (!phy) |
| 216 | return 0; |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 217 | return -ENOSYS; |
| 218 | } |
| 219 | |
| 220 | static inline int phy_pm_runtime_get_sync(struct phy *phy) |
| 221 | { |
Grygorii Strashko | 2b97789 | 2014-04-19 08:51:44 +0530 | [diff] [blame] | 222 | if (!phy) |
| 223 | return 0; |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 224 | return -ENOSYS; |
| 225 | } |
| 226 | |
| 227 | static inline int phy_pm_runtime_put(struct phy *phy) |
| 228 | { |
Grygorii Strashko | 2b97789 | 2014-04-19 08:51:44 +0530 | [diff] [blame] | 229 | if (!phy) |
| 230 | return 0; |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 231 | return -ENOSYS; |
| 232 | } |
| 233 | |
| 234 | static inline int phy_pm_runtime_put_sync(struct phy *phy) |
| 235 | { |
Grygorii Strashko | 2b97789 | 2014-04-19 08:51:44 +0530 | [diff] [blame] | 236 | if (!phy) |
| 237 | return 0; |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 238 | return -ENOSYS; |
| 239 | } |
| 240 | |
| 241 | static inline void phy_pm_runtime_allow(struct phy *phy) |
| 242 | { |
| 243 | return; |
| 244 | } |
| 245 | |
| 246 | static inline void phy_pm_runtime_forbid(struct phy *phy) |
| 247 | { |
| 248 | return; |
| 249 | } |
| 250 | |
| 251 | static inline int phy_init(struct phy *phy) |
| 252 | { |
Grygorii Strashko | 2b97789 | 2014-04-19 08:51:44 +0530 | [diff] [blame] | 253 | if (!phy) |
| 254 | return 0; |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 255 | return -ENOSYS; |
| 256 | } |
| 257 | |
| 258 | static inline int phy_exit(struct phy *phy) |
| 259 | { |
Grygorii Strashko | 2b97789 | 2014-04-19 08:51:44 +0530 | [diff] [blame] | 260 | if (!phy) |
| 261 | return 0; |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 262 | return -ENOSYS; |
| 263 | } |
| 264 | |
| 265 | static inline int phy_power_on(struct phy *phy) |
| 266 | { |
Grygorii Strashko | 2b97789 | 2014-04-19 08:51:44 +0530 | [diff] [blame] | 267 | if (!phy) |
| 268 | return 0; |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 269 | return -ENOSYS; |
| 270 | } |
| 271 | |
| 272 | static inline int phy_power_off(struct phy *phy) |
| 273 | { |
Grygorii Strashko | 2b97789 | 2014-04-19 08:51:44 +0530 | [diff] [blame] | 274 | if (!phy) |
| 275 | return 0; |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 276 | return -ENOSYS; |
| 277 | } |
| 278 | |
David Lechner | 300eb01 | 2016-05-09 18:39:59 -0500 | [diff] [blame] | 279 | static inline int phy_set_mode(struct phy *phy, enum phy_mode mode) |
| 280 | { |
| 281 | if (!phy) |
| 282 | return 0; |
| 283 | return -ENOSYS; |
| 284 | } |
| 285 | |
Manu Gautam | 3b3cd24 | 2018-01-16 16:27:09 +0530 | [diff] [blame] | 286 | static inline enum phy_mode phy_get_mode(struct phy *phy) |
| 287 | { |
| 288 | return PHY_MODE_INVALID; |
| 289 | } |
| 290 | |
Randy Li | 98430c7 | 2016-10-25 22:15:34 +0800 | [diff] [blame] | 291 | static inline int phy_reset(struct phy *phy) |
| 292 | { |
| 293 | if (!phy) |
| 294 | return 0; |
| 295 | return -ENOSYS; |
| 296 | } |
| 297 | |
Andrzej Pietrasiewicz | 3691411 | 2017-10-09 14:00:50 +0200 | [diff] [blame] | 298 | static inline int phy_calibrate(struct phy *phy) |
| 299 | { |
| 300 | if (!phy) |
| 301 | return 0; |
| 302 | return -ENOSYS; |
| 303 | } |
| 304 | |
Matt Porter | 8feed34 | 2013-12-19 09:23:02 -0500 | [diff] [blame] | 305 | static inline int phy_get_bus_width(struct phy *phy) |
| 306 | { |
| 307 | return -ENOSYS; |
| 308 | } |
| 309 | |
| 310 | static inline void phy_set_bus_width(struct phy *phy, int bus_width) |
| 311 | { |
| 312 | return; |
| 313 | } |
| 314 | |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 315 | static inline struct phy *phy_get(struct device *dev, const char *string) |
| 316 | { |
| 317 | return ERR_PTR(-ENOSYS); |
| 318 | } |
| 319 | |
Andrew Lunn | 788a4d5 | 2014-02-04 18:33:12 +0100 | [diff] [blame] | 320 | static inline struct phy *phy_optional_get(struct device *dev, |
| 321 | const char *string) |
| 322 | { |
| 323 | return ERR_PTR(-ENOSYS); |
| 324 | } |
| 325 | |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 326 | static inline struct phy *devm_phy_get(struct device *dev, const char *string) |
| 327 | { |
| 328 | return ERR_PTR(-ENOSYS); |
| 329 | } |
| 330 | |
Andrew Lunn | 788a4d5 | 2014-02-04 18:33:12 +0100 | [diff] [blame] | 331 | static inline struct phy *devm_phy_optional_get(struct device *dev, |
| 332 | const char *string) |
| 333 | { |
Maxime Ripard | 11a6e41 | 2017-09-04 14:53:13 +0200 | [diff] [blame] | 334 | return NULL; |
Andrew Lunn | 788a4d5 | 2014-02-04 18:33:12 +0100 | [diff] [blame] | 335 | } |
| 336 | |
Kamil Debski | b5d682f | 2014-03-06 12:16:47 +0100 | [diff] [blame] | 337 | static inline struct phy *devm_of_phy_get(struct device *dev, |
| 338 | struct device_node *np, |
| 339 | const char *con_id) |
| 340 | { |
| 341 | return ERR_PTR(-ENOSYS); |
| 342 | } |
| 343 | |
Arun Ramamurthy | 6be109b | 2015-04-22 16:04:11 -0700 | [diff] [blame] | 344 | static inline struct phy *devm_of_phy_get_by_index(struct device *dev, |
| 345 | struct device_node *np, |
| 346 | int index) |
| 347 | { |
| 348 | return ERR_PTR(-ENOSYS); |
| 349 | } |
| 350 | |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 351 | static inline void phy_put(struct phy *phy) |
| 352 | { |
| 353 | } |
| 354 | |
| 355 | static inline void devm_phy_put(struct device *dev, struct phy *phy) |
| 356 | { |
| 357 | } |
| 358 | |
Kamil Debski | 0b3f3b2 | 2014-03-06 12:16:46 +0100 | [diff] [blame] | 359 | static inline struct phy *of_phy_get(struct device_node *np, const char *con_id) |
| 360 | { |
| 361 | return ERR_PTR(-ENOSYS); |
| 362 | } |
| 363 | |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 364 | static inline struct phy *of_phy_simple_xlate(struct device *dev, |
| 365 | struct of_phandle_args *args) |
| 366 | { |
| 367 | return ERR_PTR(-ENOSYS); |
| 368 | } |
| 369 | |
| 370 | static inline struct phy *phy_create(struct device *dev, |
Kishon Vijay Abraham I | f0ed817 | 2014-07-14 15:55:02 +0530 | [diff] [blame] | 371 | struct device_node *node, |
Heikki Krogerus | dbc9863 | 2014-11-19 17:28:21 +0200 | [diff] [blame] | 372 | const struct phy_ops *ops) |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 373 | { |
| 374 | return ERR_PTR(-ENOSYS); |
| 375 | } |
| 376 | |
| 377 | static inline struct phy *devm_phy_create(struct device *dev, |
Kishon Vijay Abraham I | f0ed817 | 2014-07-14 15:55:02 +0530 | [diff] [blame] | 378 | struct device_node *node, |
Heikki Krogerus | dbc9863 | 2014-11-19 17:28:21 +0200 | [diff] [blame] | 379 | const struct phy_ops *ops) |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 380 | { |
| 381 | return ERR_PTR(-ENOSYS); |
| 382 | } |
| 383 | |
| 384 | static inline void phy_destroy(struct phy *phy) |
| 385 | { |
| 386 | } |
| 387 | |
| 388 | static inline void devm_phy_destroy(struct device *dev, struct phy *phy) |
| 389 | { |
| 390 | } |
| 391 | |
| 392 | static inline struct phy_provider *__of_phy_provider_register( |
Thierry Reding | 1140f7c | 2016-04-05 17:17:34 +0200 | [diff] [blame] | 393 | struct device *dev, struct device_node *children, struct module *owner, |
| 394 | struct phy * (*of_xlate)(struct device *dev, |
| 395 | struct of_phandle_args *args)) |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 396 | { |
| 397 | return ERR_PTR(-ENOSYS); |
| 398 | } |
| 399 | |
| 400 | static inline struct phy_provider *__devm_of_phy_provider_register(struct device |
Thierry Reding | 1140f7c | 2016-04-05 17:17:34 +0200 | [diff] [blame] | 401 | *dev, struct device_node *children, struct module *owner, |
| 402 | struct phy * (*of_xlate)(struct device *dev, |
| 403 | struct of_phandle_args *args)) |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 404 | { |
| 405 | return ERR_PTR(-ENOSYS); |
| 406 | } |
| 407 | |
| 408 | static inline void of_phy_provider_unregister(struct phy_provider *phy_provider) |
| 409 | { |
| 410 | } |
| 411 | |
| 412 | static inline void devm_of_phy_provider_unregister(struct device *dev, |
| 413 | struct phy_provider *phy_provider) |
| 414 | { |
| 415 | } |
Heikki Krogerus | b7bc15b | 2014-11-19 17:28:18 +0200 | [diff] [blame] | 416 | static inline int |
| 417 | phy_create_lookup(struct phy *phy, const char *con_id, const char *dev_id) |
| 418 | { |
| 419 | return 0; |
| 420 | } |
| 421 | static inline void phy_remove_lookup(struct phy *phy, const char *con_id, |
| 422 | const char *dev_id) { } |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 423 | #endif |
| 424 | |
| 425 | #endif /* __DRIVERS_PHY_H */ |