Thomas Gleixner | 2874c5f | 2019-05-27 08:55:01 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 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> |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 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> |
Roger Quadros | 3be8812 | 2014-07-04 12:55:45 +0300 | [diff] [blame] | 17 | #include <linux/regulator/consumer.h> |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 18 | |
Maxime Ripard | 2ed8699 | 2018-12-07 14:55:30 +0100 | [diff] [blame] | 19 | #include <linux/phy/phy-mipi-dphy.h> |
| 20 | |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 21 | struct phy; |
| 22 | |
David Lechner | 300eb01 | 2016-05-09 18:39:59 -0500 | [diff] [blame] | 23 | enum phy_mode { |
| 24 | PHY_MODE_INVALID, |
| 25 | PHY_MODE_USB_HOST, |
Manu Gautam | 3b3cd24 | 2018-01-16 16:27:09 +0530 | [diff] [blame] | 26 | PHY_MODE_USB_HOST_LS, |
| 27 | PHY_MODE_USB_HOST_FS, |
| 28 | PHY_MODE_USB_HOST_HS, |
| 29 | PHY_MODE_USB_HOST_SS, |
David Lechner | 300eb01 | 2016-05-09 18:39:59 -0500 | [diff] [blame] | 30 | PHY_MODE_USB_DEVICE, |
Manu Gautam | 3b3cd24 | 2018-01-16 16:27:09 +0530 | [diff] [blame] | 31 | PHY_MODE_USB_DEVICE_LS, |
| 32 | PHY_MODE_USB_DEVICE_FS, |
| 33 | PHY_MODE_USB_DEVICE_HS, |
| 34 | PHY_MODE_USB_DEVICE_SS, |
David Lechner | 300eb01 | 2016-05-09 18:39:59 -0500 | [diff] [blame] | 35 | PHY_MODE_USB_OTG, |
Vivek Gautam | fd3e4c9 | 2017-10-12 11:49:33 +0530 | [diff] [blame] | 36 | PHY_MODE_UFS_HS_A, |
| 37 | PHY_MODE_UFS_HS_B, |
Quentin Schulz | c2a9002 | 2018-10-04 14:22:03 +0200 | [diff] [blame] | 38 | PHY_MODE_PCIE, |
Grygorii Strashko | 2af8cae | 2018-11-19 19:24:21 -0600 | [diff] [blame] | 39 | PHY_MODE_ETHERNET, |
Maxime Ripard | c845782 | 2018-12-07 14:55:28 +0100 | [diff] [blame] | 40 | PHY_MODE_MIPI_DPHY, |
John Hubbard | e170672 | 2019-01-12 17:29:09 -0800 | [diff] [blame] | 41 | PHY_MODE_SATA |
David Lechner | 300eb01 | 2016-05-09 18:39:59 -0500 | [diff] [blame] | 42 | }; |
| 43 | |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 44 | /** |
Maxime Ripard | aeaac93 | 2018-12-07 14:55:29 +0100 | [diff] [blame] | 45 | * union phy_configure_opts - Opaque generic phy configuration |
Maxime Ripard | 2ed8699 | 2018-12-07 14:55:30 +0100 | [diff] [blame] | 46 | * |
| 47 | * @mipi_dphy: Configuration set applicable for phys supporting |
| 48 | * the MIPI_DPHY phy mode. |
Maxime Ripard | aeaac93 | 2018-12-07 14:55:29 +0100 | [diff] [blame] | 49 | */ |
| 50 | union phy_configure_opts { |
Maxime Ripard | 2ed8699 | 2018-12-07 14:55:30 +0100 | [diff] [blame] | 51 | struct phy_configure_opts_mipi_dphy mipi_dphy; |
Maxime Ripard | aeaac93 | 2018-12-07 14:55:29 +0100 | [diff] [blame] | 52 | }; |
| 53 | |
| 54 | /** |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 55 | * struct phy_ops - set of function pointers for performing phy operations |
| 56 | * @init: operation to be performed for initializing phy |
| 57 | * @exit: operation to be performed while exiting |
| 58 | * @power_on: powering on the phy |
| 59 | * @power_off: powering off the phy |
David Lechner | 300eb01 | 2016-05-09 18:39:59 -0500 | [diff] [blame] | 60 | * @set_mode: set the mode of the phy |
Randy Li | cac18ec | 2016-09-10 02:59:37 +0800 | [diff] [blame] | 61 | * @reset: resetting the phy |
Andrzej Pietrasiewicz | 3691411 | 2017-10-09 14:00:50 +0200 | [diff] [blame] | 62 | * @calibrate: calibrate the phy |
Kishon Vijay Abraham I | fec06b2 | 2019-04-05 16:38:30 +0530 | [diff] [blame] | 63 | * @release: ops to be performed while the consumer relinquishes the PHY |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 64 | * @owner: the module owner containing the ops |
| 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); |
Grygorii Strashko | 79a5a18 | 2018-11-19 19:24:20 -0600 | [diff] [blame] | 71 | int (*set_mode)(struct phy *phy, enum phy_mode mode, int submode); |
Maxime Ripard | aeaac93 | 2018-12-07 14:55:29 +0100 | [diff] [blame] | 72 | |
| 73 | /** |
| 74 | * @configure: |
| 75 | * |
| 76 | * Optional. |
| 77 | * |
| 78 | * Used to change the PHY parameters. phy_init() must have |
| 79 | * been called on the phy. |
| 80 | * |
| 81 | * Returns: 0 if successful, an negative error code otherwise |
| 82 | */ |
| 83 | int (*configure)(struct phy *phy, union phy_configure_opts *opts); |
| 84 | |
| 85 | /** |
| 86 | * @validate: |
| 87 | * |
| 88 | * Optional. |
| 89 | * |
| 90 | * Used to check that the current set of parameters can be |
| 91 | * handled by the phy. Implementations are free to tune the |
| 92 | * parameters passed as arguments if needed by some |
| 93 | * implementation detail or constraints. It must not change |
| 94 | * any actual configuration of the PHY, so calling it as many |
| 95 | * times as deemed fit by the consumer must have no side |
| 96 | * effect. |
| 97 | * |
| 98 | * Returns: 0 if the configuration can be applied, an negative |
| 99 | * error code otherwise |
| 100 | */ |
| 101 | int (*validate)(struct phy *phy, enum phy_mode mode, int submode, |
| 102 | union phy_configure_opts *opts); |
Randy Li | cac18ec | 2016-09-10 02:59:37 +0800 | [diff] [blame] | 103 | int (*reset)(struct phy *phy); |
Andrzej Pietrasiewicz | 3691411 | 2017-10-09 14:00:50 +0200 | [diff] [blame] | 104 | int (*calibrate)(struct phy *phy); |
Kishon Vijay Abraham I | fec06b2 | 2019-04-05 16:38:30 +0530 | [diff] [blame] | 105 | void (*release)(struct phy *phy); |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 106 | struct module *owner; |
| 107 | }; |
| 108 | |
| 109 | /** |
Matt Porter | 8feed34 | 2013-12-19 09:23:02 -0500 | [diff] [blame] | 110 | * struct phy_attrs - represents phy attributes |
| 111 | * @bus_width: Data path width implemented by PHY |
Robert P. J. Day | a3c9311 | 2018-12-27 16:10:59 -0500 | [diff] [blame] | 112 | * @mode: PHY mode |
Matt Porter | 8feed34 | 2013-12-19 09:23:02 -0500 | [diff] [blame] | 113 | */ |
| 114 | struct phy_attrs { |
| 115 | u32 bus_width; |
Manu Gautam | 3b3cd24 | 2018-01-16 16:27:09 +0530 | [diff] [blame] | 116 | enum phy_mode mode; |
Matt Porter | 8feed34 | 2013-12-19 09:23:02 -0500 | [diff] [blame] | 117 | }; |
| 118 | |
| 119 | /** |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 120 | * struct phy - represents the phy device |
| 121 | * @dev: phy device |
| 122 | * @id: id of the phy device |
| 123 | * @ops: function pointers for performing phy operations |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 124 | * @mutex: mutex to protect phy_ops |
| 125 | * @init_count: used to protect when the PHY is used by multiple consumers |
| 126 | * @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] | 127 | * @attrs: used to specify PHY specific attributes |
| 128 | * @pwr: power regulator associated with the phy |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 129 | */ |
| 130 | struct phy { |
| 131 | struct device dev; |
| 132 | int id; |
| 133 | const struct phy_ops *ops; |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 134 | struct mutex mutex; |
| 135 | int init_count; |
| 136 | int power_count; |
Matt Porter | 8feed34 | 2013-12-19 09:23:02 -0500 | [diff] [blame] | 137 | struct phy_attrs attrs; |
Roger Quadros | 3be8812 | 2014-07-04 12:55:45 +0300 | [diff] [blame] | 138 | struct regulator *pwr; |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 139 | }; |
| 140 | |
| 141 | /** |
| 142 | * struct phy_provider - represents the phy provider |
| 143 | * @dev: phy provider device |
Dov Levenglick | becaf17 | 2018-02-02 18:34:50 +0200 | [diff] [blame] | 144 | * @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] | 145 | * @owner: the module owner having of_xlate |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 146 | * @list: to maintain a linked list of PHY providers |
Dov Levenglick | becaf17 | 2018-02-02 18:34:50 +0200 | [diff] [blame] | 147 | * @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] | 148 | */ |
| 149 | struct phy_provider { |
| 150 | struct device *dev; |
Thierry Reding | 1140f7c | 2016-04-05 17:17:34 +0200 | [diff] [blame] | 151 | struct device_node *children; |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 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 | |
Dov Levenglick | becaf17 | 2018-02-02 18:34:50 +0200 | [diff] [blame] | 158 | /** |
| 159 | * struct phy_lookup - PHY association in list of phys managed by the phy driver |
| 160 | * @node: list node |
| 161 | * @dev_id: the device of the association |
| 162 | * @con_id: connection ID string on device |
| 163 | * @phy: the phy of the association |
| 164 | */ |
Heikki Krogerus | b7bc15b | 2014-11-19 17:28:18 +0200 | [diff] [blame] | 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 | |
Heikki Krogerus | d451057 | 2014-11-19 17:28:17 +0200 | [diff] [blame] | 172 | #define to_phy(a) (container_of((a), struct phy, dev)) |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 173 | |
| 174 | #define of_phy_provider_register(dev, xlate) \ |
Thierry Reding | 1140f7c | 2016-04-05 17:17:34 +0200 | [diff] [blame] | 175 | __of_phy_provider_register((dev), NULL, THIS_MODULE, (xlate)) |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 176 | |
| 177 | #define devm_of_phy_provider_register(dev, xlate) \ |
Thierry Reding | 1140f7c | 2016-04-05 17:17:34 +0200 | [diff] [blame] | 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) |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 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); |
Grygorii Strashko | 79a5a18 | 2018-11-19 19:24:20 -0600 | [diff] [blame] | 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) |
Maxime Ripard | aeaac93 | 2018-12-07 14:55:29 +0100 | [diff] [blame] | 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); |
Grygorii Strashko | 79a5a18 | 2018-11-19 19:24:20 -0600 | [diff] [blame] | 213 | |
Manu Gautam | 3b3cd24 | 2018-01-16 16:27:09 +0530 | [diff] [blame] | 214 | static inline enum phy_mode phy_get_mode(struct phy *phy) |
| 215 | { |
| 216 | return phy->attrs.mode; |
| 217 | } |
Randy Li | cac18ec | 2016-09-10 02:59:37 +0800 | [diff] [blame] | 218 | int phy_reset(struct phy *phy); |
Andrzej Pietrasiewicz | 3691411 | 2017-10-09 14:00:50 +0200 | [diff] [blame] | 219 | int phy_calibrate(struct phy *phy); |
Matt Porter | 8feed34 | 2013-12-19 09:23:02 -0500 | [diff] [blame] | 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 | } |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 228 | struct phy *phy_get(struct device *dev, const char *string); |
Andrew Lunn | 788a4d5 | 2014-02-04 18:33:12 +0100 | [diff] [blame] | 229 | 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] | 230 | struct phy *devm_phy_get(struct device *dev, const char *string); |
Andrew Lunn | 788a4d5 | 2014-02-04 18:33:12 +0100 | [diff] [blame] | 231 | struct phy *devm_phy_optional_get(struct device *dev, const char *string); |
Kamil Debski | b5d682f | 2014-03-06 12:16:47 +0100 | [diff] [blame] | 232 | struct phy *devm_of_phy_get(struct device *dev, struct device_node *np, |
| 233 | const char *con_id); |
Arun Ramamurthy | 6be109b | 2015-04-22 16:04:11 -0700 | [diff] [blame] | 234 | struct phy *devm_of_phy_get_by_index(struct device *dev, struct device_node *np, |
| 235 | int index); |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 236 | void phy_put(struct phy *phy); |
| 237 | void devm_phy_put(struct device *dev, struct phy *phy); |
Kamil Debski | 0b3f3b2 | 2014-03-06 12:16:46 +0100 | [diff] [blame] | 238 | 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] | 239 | struct phy *of_phy_simple_xlate(struct device *dev, |
| 240 | struct of_phandle_args *args); |
Kishon Vijay Abraham I | f0ed817 | 2014-07-14 15:55:02 +0530 | [diff] [blame] | 241 | struct phy *phy_create(struct device *dev, struct device_node *node, |
Heikki Krogerus | dbc9863 | 2014-11-19 17:28:21 +0200 | [diff] [blame] | 242 | const struct phy_ops *ops); |
Kishon Vijay Abraham I | f0ed817 | 2014-07-14 15:55:02 +0530 | [diff] [blame] | 243 | struct phy *devm_phy_create(struct device *dev, struct device_node *node, |
Heikki Krogerus | dbc9863 | 2014-11-19 17:28:21 +0200 | [diff] [blame] | 244 | const struct phy_ops *ops); |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 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, |
Thierry Reding | 1140f7c | 2016-04-05 17:17:34 +0200 | [diff] [blame] | 248 | struct device_node *children, struct module *owner, |
| 249 | struct phy * (*of_xlate)(struct device *dev, |
| 250 | struct of_phandle_args *args)); |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 251 | struct phy_provider *__devm_of_phy_provider_register(struct device *dev, |
Thierry Reding | 1140f7c | 2016-04-05 17:17:34 +0200 | [diff] [blame] | 252 | struct device_node *children, struct module *owner, |
| 253 | struct phy * (*of_xlate)(struct device *dev, |
| 254 | struct of_phandle_args *args)); |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 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); |
Heikki Krogerus | b7bc15b | 2014-11-19 17:28:18 +0200 | [diff] [blame] | 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); |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 260 | #else |
| 261 | static inline int phy_pm_runtime_get(struct phy *phy) |
| 262 | { |
Grygorii Strashko | 2b97789 | 2014-04-19 08:51:44 +0530 | [diff] [blame] | 263 | if (!phy) |
| 264 | return 0; |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 265 | return -ENOSYS; |
| 266 | } |
| 267 | |
| 268 | static inline int phy_pm_runtime_get_sync(struct phy *phy) |
| 269 | { |
Grygorii Strashko | 2b97789 | 2014-04-19 08:51:44 +0530 | [diff] [blame] | 270 | if (!phy) |
| 271 | return 0; |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 272 | return -ENOSYS; |
| 273 | } |
| 274 | |
| 275 | static inline int phy_pm_runtime_put(struct phy *phy) |
| 276 | { |
Grygorii Strashko | 2b97789 | 2014-04-19 08:51:44 +0530 | [diff] [blame] | 277 | if (!phy) |
| 278 | return 0; |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 279 | return -ENOSYS; |
| 280 | } |
| 281 | |
| 282 | static inline int phy_pm_runtime_put_sync(struct phy *phy) |
| 283 | { |
Grygorii Strashko | 2b97789 | 2014-04-19 08:51:44 +0530 | [diff] [blame] | 284 | if (!phy) |
| 285 | return 0; |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 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 | { |
Grygorii Strashko | 2b97789 | 2014-04-19 08:51:44 +0530 | [diff] [blame] | 301 | if (!phy) |
| 302 | return 0; |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 303 | return -ENOSYS; |
| 304 | } |
| 305 | |
| 306 | static inline int phy_exit(struct phy *phy) |
| 307 | { |
Grygorii Strashko | 2b97789 | 2014-04-19 08:51:44 +0530 | [diff] [blame] | 308 | if (!phy) |
| 309 | return 0; |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 310 | return -ENOSYS; |
| 311 | } |
| 312 | |
| 313 | static inline int phy_power_on(struct phy *phy) |
| 314 | { |
Grygorii Strashko | 2b97789 | 2014-04-19 08:51:44 +0530 | [diff] [blame] | 315 | if (!phy) |
| 316 | return 0; |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 317 | return -ENOSYS; |
| 318 | } |
| 319 | |
| 320 | static inline int phy_power_off(struct phy *phy) |
| 321 | { |
Grygorii Strashko | 2b97789 | 2014-04-19 08:51:44 +0530 | [diff] [blame] | 322 | if (!phy) |
| 323 | return 0; |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 324 | return -ENOSYS; |
| 325 | } |
| 326 | |
Grygorii Strashko | 79a5a18 | 2018-11-19 19:24:20 -0600 | [diff] [blame] | 327 | static inline int phy_set_mode_ext(struct phy *phy, enum phy_mode mode, |
| 328 | int submode) |
David Lechner | 300eb01 | 2016-05-09 18:39:59 -0500 | [diff] [blame] | 329 | { |
| 330 | if (!phy) |
| 331 | return 0; |
| 332 | return -ENOSYS; |
| 333 | } |
| 334 | |
Grygorii Strashko | 79a5a18 | 2018-11-19 19:24:20 -0600 | [diff] [blame] | 335 | #define phy_set_mode(phy, mode) \ |
| 336 | phy_set_mode_ext(phy, mode, 0) |
| 337 | |
Manu Gautam | 3b3cd24 | 2018-01-16 16:27:09 +0530 | [diff] [blame] | 338 | static inline enum phy_mode phy_get_mode(struct phy *phy) |
| 339 | { |
| 340 | return PHY_MODE_INVALID; |
| 341 | } |
| 342 | |
Randy Li | 98430c7 | 2016-10-25 22:15:34 +0800 | [diff] [blame] | 343 | static inline int phy_reset(struct phy *phy) |
| 344 | { |
| 345 | if (!phy) |
| 346 | return 0; |
| 347 | return -ENOSYS; |
| 348 | } |
| 349 | |
Andrzej Pietrasiewicz | 3691411 | 2017-10-09 14:00:50 +0200 | [diff] [blame] | 350 | static inline int phy_calibrate(struct phy *phy) |
| 351 | { |
| 352 | if (!phy) |
| 353 | return 0; |
| 354 | return -ENOSYS; |
| 355 | } |
| 356 | |
Maxime Ripard | aeaac93 | 2018-12-07 14:55:29 +0100 | [diff] [blame] | 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 | |
Matt Porter | 8feed34 | 2013-12-19 09:23:02 -0500 | [diff] [blame] | 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 | |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 385 | static inline struct phy *phy_get(struct device *dev, const char *string) |
| 386 | { |
| 387 | return ERR_PTR(-ENOSYS); |
| 388 | } |
| 389 | |
Andrew Lunn | 788a4d5 | 2014-02-04 18:33:12 +0100 | [diff] [blame] | 390 | static inline struct phy *phy_optional_get(struct device *dev, |
| 391 | const char *string) |
| 392 | { |
| 393 | return ERR_PTR(-ENOSYS); |
| 394 | } |
| 395 | |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 396 | static inline struct phy *devm_phy_get(struct device *dev, const char *string) |
| 397 | { |
| 398 | return ERR_PTR(-ENOSYS); |
| 399 | } |
| 400 | |
Andrew Lunn | 788a4d5 | 2014-02-04 18:33:12 +0100 | [diff] [blame] | 401 | static inline struct phy *devm_phy_optional_get(struct device *dev, |
| 402 | const char *string) |
| 403 | { |
Maxime Ripard | 11a6e41 | 2017-09-04 14:53:13 +0200 | [diff] [blame] | 404 | return NULL; |
Andrew Lunn | 788a4d5 | 2014-02-04 18:33:12 +0100 | [diff] [blame] | 405 | } |
| 406 | |
Kamil Debski | b5d682f | 2014-03-06 12:16:47 +0100 | [diff] [blame] | 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 | |
Arun Ramamurthy | 6be109b | 2015-04-22 16:04:11 -0700 | [diff] [blame] | 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 | |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 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 | |
Kamil Debski | 0b3f3b2 | 2014-03-06 12:16:46 +0100 | [diff] [blame] | 429 | static inline struct phy *of_phy_get(struct device_node *np, const char *con_id) |
| 430 | { |
| 431 | return ERR_PTR(-ENOSYS); |
| 432 | } |
| 433 | |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 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, |
Kishon Vijay Abraham I | f0ed817 | 2014-07-14 15:55:02 +0530 | [diff] [blame] | 441 | struct device_node *node, |
Heikki Krogerus | dbc9863 | 2014-11-19 17:28:21 +0200 | [diff] [blame] | 442 | const struct phy_ops *ops) |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 443 | { |
| 444 | return ERR_PTR(-ENOSYS); |
| 445 | } |
| 446 | |
| 447 | static inline struct phy *devm_phy_create(struct device *dev, |
Kishon Vijay Abraham I | f0ed817 | 2014-07-14 15:55:02 +0530 | [diff] [blame] | 448 | struct device_node *node, |
Heikki Krogerus | dbc9863 | 2014-11-19 17:28:21 +0200 | [diff] [blame] | 449 | const struct phy_ops *ops) |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 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( |
Thierry Reding | 1140f7c | 2016-04-05 17:17:34 +0200 | [diff] [blame] | 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)) |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 466 | { |
| 467 | return ERR_PTR(-ENOSYS); |
| 468 | } |
| 469 | |
| 470 | static inline struct phy_provider *__devm_of_phy_provider_register(struct device |
Thierry Reding | 1140f7c | 2016-04-05 17:17:34 +0200 | [diff] [blame] | 471 | *dev, struct device_node *children, struct module *owner, |
| 472 | struct phy * (*of_xlate)(struct device *dev, |
| 473 | struct of_phandle_args *args)) |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 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 | } |
Heikki Krogerus | b7bc15b | 2014-11-19 17:28:18 +0200 | [diff] [blame] | 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) { } |
Kishon Vijay Abraham I | ff76496 | 2013-09-27 11:53:25 +0530 | [diff] [blame] | 493 | #endif |
| 494 | |
| 495 | #endif /* __DRIVERS_PHY_H */ |