Venu Byravarasu | de4217d | 2012-09-04 14:25:58 +0530 | [diff] [blame] | 1 | /* |
Peter Chen | 0767320 | 2014-12-30 14:02:28 +0800 | [diff] [blame] | 2 | * USB PHY defines |
Venu Byravarasu | de4217d | 2012-09-04 14:25:58 +0530 | [diff] [blame] | 3 | * |
| 4 | * These APIs may be used between USB controllers. USB device drivers |
| 5 | * (for either host or peripheral roles) don't use these calls; they |
| 6 | * continue to use just usb_device and usb_gadget. |
| 7 | */ |
| 8 | |
| 9 | #ifndef __LINUX_USB_PHY_H |
| 10 | #define __LINUX_USB_PHY_H |
| 11 | |
| 12 | #include <linux/notifier.h> |
Peter Chen | ac96511 | 2012-11-09 09:44:44 +0800 | [diff] [blame] | 13 | #include <linux/usb.h> |
Venu Byravarasu | de4217d | 2012-09-04 14:25:58 +0530 | [diff] [blame] | 14 | |
Mayank Rana | 83ad582 | 2016-08-09 14:17:22 -0700 | [diff] [blame] | 15 | #define ENABLE_DP_MANUAL_PULLUP BIT(0) |
| 16 | #define ENABLE_SECONDARY_PHY BIT(1) |
| 17 | #define PHY_HOST_MODE BIT(2) |
| 18 | #define PHY_CHARGER_CONNECTED BIT(3) |
| 19 | #define PHY_VBUS_VALID_OVERRIDE BIT(4) |
| 20 | #define DEVICE_IN_SS_MODE BIT(5) |
| 21 | #define PHY_LANE_A BIT(6) |
| 22 | #define PHY_LANE_B BIT(7) |
| 23 | #define PHY_HSFS_MODE BIT(8) |
| 24 | #define PHY_LS_MODE BIT(9) |
| 25 | |
Michael Grzeschik | 1c9af65 | 2013-06-13 17:59:55 +0300 | [diff] [blame] | 26 | enum usb_phy_interface { |
| 27 | USBPHY_INTERFACE_MODE_UNKNOWN, |
| 28 | USBPHY_INTERFACE_MODE_UTMI, |
| 29 | USBPHY_INTERFACE_MODE_UTMIW, |
| 30 | USBPHY_INTERFACE_MODE_ULPI, |
| 31 | USBPHY_INTERFACE_MODE_SERIAL, |
| 32 | USBPHY_INTERFACE_MODE_HSIC, |
| 33 | }; |
| 34 | |
Venu Byravarasu | de4217d | 2012-09-04 14:25:58 +0530 | [diff] [blame] | 35 | enum usb_phy_events { |
| 36 | USB_EVENT_NONE, /* no events or cable disconnected */ |
| 37 | USB_EVENT_VBUS, /* vbus valid event */ |
| 38 | USB_EVENT_ID, /* id was grounded */ |
| 39 | USB_EVENT_CHARGER, /* usb dedicated charger */ |
| 40 | USB_EVENT_ENUMERATED, /* gadget driver enumerated */ |
| 41 | }; |
| 42 | |
| 43 | /* associate a type with PHY */ |
| 44 | enum usb_phy_type { |
| 45 | USB_PHY_TYPE_UNDEFINED, |
| 46 | USB_PHY_TYPE_USB2, |
| 47 | USB_PHY_TYPE_USB3, |
Hemant Kumar | bce97a2 | 2017-12-07 16:17:38 -0800 | [diff] [blame] | 48 | USB_PHY_TYPE_USB3_OR_DP, |
| 49 | USB_PHY_TYPE_USB3_AND_DP, |
Venu Byravarasu | de4217d | 2012-09-04 14:25:58 +0530 | [diff] [blame] | 50 | }; |
| 51 | |
Venu Byravarasu | a4c3dde | 2012-09-06 10:42:15 +0530 | [diff] [blame] | 52 | /* OTG defines lots of enumeration states before device reset */ |
| 53 | enum usb_otg_state { |
| 54 | OTG_STATE_UNDEFINED = 0, |
| 55 | |
| 56 | /* single-role peripheral, and dual-role default-b */ |
| 57 | OTG_STATE_B_IDLE, |
| 58 | OTG_STATE_B_SRP_INIT, |
| 59 | OTG_STATE_B_PERIPHERAL, |
Mayank Rana | a99689a | 2016-08-10 17:39:47 -0700 | [diff] [blame] | 60 | OTG_STATE_B_SUSPEND, |
Venu Byravarasu | a4c3dde | 2012-09-06 10:42:15 +0530 | [diff] [blame] | 61 | |
| 62 | /* extra dual-role default-b states */ |
| 63 | OTG_STATE_B_WAIT_ACON, |
| 64 | OTG_STATE_B_HOST, |
| 65 | |
| 66 | /* dual-role default-a */ |
| 67 | OTG_STATE_A_IDLE, |
| 68 | OTG_STATE_A_WAIT_VRISE, |
| 69 | OTG_STATE_A_WAIT_BCON, |
| 70 | OTG_STATE_A_HOST, |
| 71 | OTG_STATE_A_SUSPEND, |
| 72 | OTG_STATE_A_PERIPHERAL, |
| 73 | OTG_STATE_A_WAIT_VFALL, |
| 74 | OTG_STATE_A_VBUS_ERR, |
| 75 | }; |
| 76 | |
Venu Byravarasu | de4217d | 2012-09-04 14:25:58 +0530 | [diff] [blame] | 77 | struct usb_phy; |
| 78 | struct usb_otg; |
| 79 | |
Peter Chen | 58efd4b0 | 2015-09-22 15:31:34 +0800 | [diff] [blame] | 80 | /* for phys connected thru an ULPI interface, the user must |
Venu Byravarasu | de4217d | 2012-09-04 14:25:58 +0530 | [diff] [blame] | 81 | * provide access ops |
| 82 | */ |
| 83 | struct usb_phy_io_ops { |
| 84 | int (*read)(struct usb_phy *x, u32 reg); |
| 85 | int (*write)(struct usb_phy *x, u32 val, u32 reg); |
| 86 | }; |
| 87 | |
| 88 | struct usb_phy { |
| 89 | struct device *dev; |
| 90 | const char *label; |
| 91 | unsigned int flags; |
| 92 | |
| 93 | enum usb_phy_type type; |
Venu Byravarasu | de4217d | 2012-09-04 14:25:58 +0530 | [diff] [blame] | 94 | enum usb_phy_events last_event; |
| 95 | |
| 96 | struct usb_otg *otg; |
| 97 | |
| 98 | struct device *io_dev; |
| 99 | struct usb_phy_io_ops *io_ops; |
| 100 | void __iomem *io_priv; |
| 101 | |
| 102 | /* for notification of usb_phy_events */ |
| 103 | struct atomic_notifier_head notifier; |
| 104 | |
| 105 | /* to pass extra port status to the root hub */ |
| 106 | u16 port_status; |
| 107 | u16 port_change; |
| 108 | |
Peter Chen | 58efd4b0 | 2015-09-22 15:31:34 +0800 | [diff] [blame] | 109 | /* to support controllers that have multiple phys */ |
Venu Byravarasu | de4217d | 2012-09-04 14:25:58 +0530 | [diff] [blame] | 110 | struct list_head head; |
| 111 | |
Peter Chen | 58efd4b0 | 2015-09-22 15:31:34 +0800 | [diff] [blame] | 112 | /* initialize/shutdown the phy */ |
Venu Byravarasu | de4217d | 2012-09-04 14:25:58 +0530 | [diff] [blame] | 113 | int (*init)(struct usb_phy *x); |
| 114 | void (*shutdown)(struct usb_phy *x); |
| 115 | |
Felipe Balbi | b774212 | 2013-03-08 13:22:58 +0200 | [diff] [blame] | 116 | /* enable/disable VBUS */ |
| 117 | int (*set_vbus)(struct usb_phy *x, int on); |
Hemant Kumar | 2bb3bdf | 2017-11-22 13:53:08 -0800 | [diff] [blame] | 118 | /* callback to indicate port is being reset or reset the port */ |
| 119 | void (*start_port_reset)(struct usb_phy *x); |
Felipe Balbi | b774212 | 2013-03-08 13:22:58 +0200 | [diff] [blame] | 120 | |
Venu Byravarasu | de4217d | 2012-09-04 14:25:58 +0530 | [diff] [blame] | 121 | /* effective for B devices, ignored for A-peripheral */ |
| 122 | int (*set_power)(struct usb_phy *x, |
| 123 | unsigned mA); |
| 124 | |
Peter Chen | 58efd4b0 | 2015-09-22 15:31:34 +0800 | [diff] [blame] | 125 | /* Set phy into suspend mode */ |
Venu Byravarasu | de4217d | 2012-09-04 14:25:58 +0530 | [diff] [blame] | 126 | int (*set_suspend)(struct usb_phy *x, |
| 127 | int suspend); |
| 128 | |
Peter Chen | 57bf9b0 | 2014-02-24 10:21:01 +0800 | [diff] [blame] | 129 | /* |
| 130 | * Set wakeup enable for PHY, in that case, the PHY can be |
| 131 | * woken up from suspend status due to external events, |
| 132 | * like vbus change, dp/dm change and id. |
| 133 | */ |
| 134 | int (*set_wakeup)(struct usb_phy *x, bool enabled); |
| 135 | |
Venu Byravarasu | de4217d | 2012-09-04 14:25:58 +0530 | [diff] [blame] | 136 | /* notify phy connect status change */ |
Peter Chen | ac96511 | 2012-11-09 09:44:44 +0800 | [diff] [blame] | 137 | int (*notify_connect)(struct usb_phy *x, |
| 138 | enum usb_device_speed speed); |
| 139 | int (*notify_disconnect)(struct usb_phy *x, |
| 140 | enum usb_device_speed speed); |
Mayank Rana | a99689a | 2016-08-10 17:39:47 -0700 | [diff] [blame] | 141 | |
| 142 | /* reset the PHY clocks */ |
| 143 | int (*reset)(struct usb_phy *x); |
Hemant Kumar | 91f5e54 | 2017-11-20 16:25:46 -0800 | [diff] [blame] | 144 | int (*disable_chirp)(struct usb_phy *x, bool disable); |
Venu Byravarasu | de4217d | 2012-09-04 14:25:58 +0530 | [diff] [blame] | 145 | }; |
| 146 | |
Kishon Vijay Abraham I | b4a83e4 | 2013-01-25 08:03:21 +0530 | [diff] [blame] | 147 | /** |
| 148 | * struct usb_phy_bind - represent the binding for the phy |
| 149 | * @dev_name: the device name of the device that will bind to the phy |
| 150 | * @phy_dev_name: the device name of the phy |
| 151 | * @index: used if a single controller uses multiple phys |
| 152 | * @phy: reference to the phy |
| 153 | * @list: to maintain a linked list of the binding information |
| 154 | */ |
| 155 | struct usb_phy_bind { |
| 156 | const char *dev_name; |
| 157 | const char *phy_dev_name; |
| 158 | u8 index; |
| 159 | struct usb_phy *phy; |
| 160 | struct list_head list; |
| 161 | }; |
Venu Byravarasu | de4217d | 2012-09-04 14:25:58 +0530 | [diff] [blame] | 162 | |
| 163 | /* for board-specific init logic */ |
| 164 | extern int usb_add_phy(struct usb_phy *, enum usb_phy_type type); |
Kishon Vijay Abraham I | 0fa4fab | 2013-01-25 08:03:22 +0530 | [diff] [blame] | 165 | extern int usb_add_phy_dev(struct usb_phy *); |
Venu Byravarasu | de4217d | 2012-09-04 14:25:58 +0530 | [diff] [blame] | 166 | extern void usb_remove_phy(struct usb_phy *); |
| 167 | |
| 168 | /* helpers for direct access thru low-level io interface */ |
| 169 | static inline int usb_phy_io_read(struct usb_phy *x, u32 reg) |
| 170 | { |
Felipe Balbi | 410aee7 | 2013-06-30 15:27:26 +0300 | [diff] [blame] | 171 | if (x && x->io_ops && x->io_ops->read) |
Venu Byravarasu | de4217d | 2012-09-04 14:25:58 +0530 | [diff] [blame] | 172 | return x->io_ops->read(x, reg); |
| 173 | |
| 174 | return -EINVAL; |
| 175 | } |
| 176 | |
| 177 | static inline int usb_phy_io_write(struct usb_phy *x, u32 val, u32 reg) |
| 178 | { |
Felipe Balbi | 410aee7 | 2013-06-30 15:27:26 +0300 | [diff] [blame] | 179 | if (x && x->io_ops && x->io_ops->write) |
Venu Byravarasu | de4217d | 2012-09-04 14:25:58 +0530 | [diff] [blame] | 180 | return x->io_ops->write(x, val, reg); |
| 181 | |
| 182 | return -EINVAL; |
| 183 | } |
| 184 | |
| 185 | static inline int |
| 186 | usb_phy_init(struct usb_phy *x) |
| 187 | { |
Felipe Balbi | 410aee7 | 2013-06-30 15:27:26 +0300 | [diff] [blame] | 188 | if (x && x->init) |
Venu Byravarasu | de4217d | 2012-09-04 14:25:58 +0530 | [diff] [blame] | 189 | return x->init(x); |
| 190 | |
| 191 | return 0; |
| 192 | } |
| 193 | |
| 194 | static inline void |
| 195 | usb_phy_shutdown(struct usb_phy *x) |
| 196 | { |
Felipe Balbi | 410aee7 | 2013-06-30 15:27:26 +0300 | [diff] [blame] | 197 | if (x && x->shutdown) |
Venu Byravarasu | de4217d | 2012-09-04 14:25:58 +0530 | [diff] [blame] | 198 | x->shutdown(x); |
| 199 | } |
| 200 | |
Felipe Balbi | b774212 | 2013-03-08 13:22:58 +0200 | [diff] [blame] | 201 | static inline int |
| 202 | usb_phy_vbus_on(struct usb_phy *x) |
| 203 | { |
Felipe Balbi | 410aee7 | 2013-06-30 15:27:26 +0300 | [diff] [blame] | 204 | if (!x || !x->set_vbus) |
Felipe Balbi | b774212 | 2013-03-08 13:22:58 +0200 | [diff] [blame] | 205 | return 0; |
| 206 | |
| 207 | return x->set_vbus(x, true); |
| 208 | } |
| 209 | |
| 210 | static inline int |
| 211 | usb_phy_vbus_off(struct usb_phy *x) |
| 212 | { |
Felipe Balbi | 410aee7 | 2013-06-30 15:27:26 +0300 | [diff] [blame] | 213 | if (!x || !x->set_vbus) |
Felipe Balbi | b774212 | 2013-03-08 13:22:58 +0200 | [diff] [blame] | 214 | return 0; |
| 215 | |
| 216 | return x->set_vbus(x, false); |
| 217 | } |
| 218 | |
Hemant Kumar | 2bb3bdf | 2017-11-22 13:53:08 -0800 | [diff] [blame] | 219 | static inline void |
| 220 | usb_phy_start_port_reset(struct usb_phy *x) |
| 221 | { |
| 222 | if (!x || !x->start_port_reset) |
| 223 | return; |
| 224 | |
| 225 | x->start_port_reset(x); |
| 226 | } |
| 227 | |
Mayank Rana | a99689a | 2016-08-10 17:39:47 -0700 | [diff] [blame] | 228 | static inline int |
| 229 | usb_phy_reset(struct usb_phy *x) |
| 230 | { |
| 231 | if (x && x->reset) |
| 232 | return x->reset(x); |
| 233 | |
| 234 | return 0; |
| 235 | } |
| 236 | |
Venu Byravarasu | de4217d | 2012-09-04 14:25:58 +0530 | [diff] [blame] | 237 | /* for usb host and peripheral controller drivers */ |
Felipe Balbi | edc7cb2 | 2013-03-07 11:13:43 +0200 | [diff] [blame] | 238 | #if IS_ENABLED(CONFIG_USB_PHY) |
Venu Byravarasu | de4217d | 2012-09-04 14:25:58 +0530 | [diff] [blame] | 239 | extern struct usb_phy *usb_get_phy(enum usb_phy_type type); |
| 240 | extern struct usb_phy *devm_usb_get_phy(struct device *dev, |
| 241 | enum usb_phy_type type); |
Kishon Vijay Abraham I | 0fa4fab | 2013-01-25 08:03:22 +0530 | [diff] [blame] | 242 | extern struct usb_phy *usb_get_phy_dev(struct device *dev, u8 index); |
| 243 | extern struct usb_phy *devm_usb_get_phy_dev(struct device *dev, u8 index); |
Kishon Vijay Abraham I | 5d3c28b | 2013-01-25 08:03:25 +0530 | [diff] [blame] | 244 | extern struct usb_phy *devm_usb_get_phy_by_phandle(struct device *dev, |
| 245 | const char *phandle, u8 index); |
NeilBrown | e842b84 | 2015-03-23 09:52:48 +1100 | [diff] [blame] | 246 | extern struct usb_phy *devm_usb_get_phy_by_node(struct device *dev, |
| 247 | struct device_node *node, struct notifier_block *nb); |
Venu Byravarasu | de4217d | 2012-09-04 14:25:58 +0530 | [diff] [blame] | 248 | extern void usb_put_phy(struct usb_phy *); |
| 249 | extern void devm_usb_put_phy(struct device *dev, struct usb_phy *x); |
Kishon Vijay Abraham I | b4a83e4 | 2013-01-25 08:03:21 +0530 | [diff] [blame] | 250 | extern int usb_bind_phy(const char *dev_name, u8 index, |
| 251 | const char *phy_dev_name); |
Kiran Raparthy | df9f7b3 | 2014-11-21 11:31:20 +0530 | [diff] [blame] | 252 | extern void usb_phy_set_event(struct usb_phy *x, unsigned long event); |
Venu Byravarasu | de4217d | 2012-09-04 14:25:58 +0530 | [diff] [blame] | 253 | #else |
| 254 | static inline struct usb_phy *usb_get_phy(enum usb_phy_type type) |
| 255 | { |
Felipe Balbi | b7fa5c2 | 2013-03-14 17:59:06 +0200 | [diff] [blame] | 256 | return ERR_PTR(-ENXIO); |
Venu Byravarasu | de4217d | 2012-09-04 14:25:58 +0530 | [diff] [blame] | 257 | } |
| 258 | |
| 259 | static inline struct usb_phy *devm_usb_get_phy(struct device *dev, |
| 260 | enum usb_phy_type type) |
| 261 | { |
Felipe Balbi | b7fa5c2 | 2013-03-14 17:59:06 +0200 | [diff] [blame] | 262 | return ERR_PTR(-ENXIO); |
Venu Byravarasu | de4217d | 2012-09-04 14:25:58 +0530 | [diff] [blame] | 263 | } |
| 264 | |
Kishon Vijay Abraham I | 0fa4fab | 2013-01-25 08:03:22 +0530 | [diff] [blame] | 265 | static inline struct usb_phy *usb_get_phy_dev(struct device *dev, u8 index) |
| 266 | { |
Felipe Balbi | b7fa5c2 | 2013-03-14 17:59:06 +0200 | [diff] [blame] | 267 | return ERR_PTR(-ENXIO); |
Kishon Vijay Abraham I | 0fa4fab | 2013-01-25 08:03:22 +0530 | [diff] [blame] | 268 | } |
| 269 | |
| 270 | static inline struct usb_phy *devm_usb_get_phy_dev(struct device *dev, u8 index) |
| 271 | { |
Felipe Balbi | b7fa5c2 | 2013-03-14 17:59:06 +0200 | [diff] [blame] | 272 | return ERR_PTR(-ENXIO); |
Kishon Vijay Abraham I | 0fa4fab | 2013-01-25 08:03:22 +0530 | [diff] [blame] | 273 | } |
| 274 | |
Kishon Vijay Abraham I | 5d3c28b | 2013-01-25 08:03:25 +0530 | [diff] [blame] | 275 | static inline struct usb_phy *devm_usb_get_phy_by_phandle(struct device *dev, |
| 276 | const char *phandle, u8 index) |
| 277 | { |
Felipe Balbi | b7fa5c2 | 2013-03-14 17:59:06 +0200 | [diff] [blame] | 278 | return ERR_PTR(-ENXIO); |
Kishon Vijay Abraham I | 5d3c28b | 2013-01-25 08:03:25 +0530 | [diff] [blame] | 279 | } |
| 280 | |
Arnd Bergmann | 307c858 | 2015-05-28 16:08:02 +0200 | [diff] [blame] | 281 | static inline struct usb_phy *devm_usb_get_phy_by_node(struct device *dev, |
| 282 | struct device_node *node, struct notifier_block *nb) |
| 283 | { |
| 284 | return ERR_PTR(-ENXIO); |
| 285 | } |
| 286 | |
Venu Byravarasu | de4217d | 2012-09-04 14:25:58 +0530 | [diff] [blame] | 287 | static inline void usb_put_phy(struct usb_phy *x) |
| 288 | { |
| 289 | } |
| 290 | |
| 291 | static inline void devm_usb_put_phy(struct device *dev, struct usb_phy *x) |
| 292 | { |
| 293 | } |
| 294 | |
Kishon Vijay Abraham I | b4a83e4 | 2013-01-25 08:03:21 +0530 | [diff] [blame] | 295 | static inline int usb_bind_phy(const char *dev_name, u8 index, |
| 296 | const char *phy_dev_name) |
| 297 | { |
| 298 | return -EOPNOTSUPP; |
| 299 | } |
Kiran Raparthy | df9f7b3 | 2014-11-21 11:31:20 +0530 | [diff] [blame] | 300 | |
| 301 | static inline void usb_phy_set_event(struct usb_phy *x, unsigned long event) |
| 302 | { |
| 303 | } |
Venu Byravarasu | de4217d | 2012-09-04 14:25:58 +0530 | [diff] [blame] | 304 | #endif |
| 305 | |
| 306 | static inline int |
| 307 | usb_phy_set_power(struct usb_phy *x, unsigned mA) |
| 308 | { |
| 309 | if (x && x->set_power) |
| 310 | return x->set_power(x, mA); |
| 311 | return 0; |
| 312 | } |
| 313 | |
| 314 | /* Context: can sleep */ |
| 315 | static inline int |
| 316 | usb_phy_set_suspend(struct usb_phy *x, int suspend) |
| 317 | { |
Felipe Balbi | 410aee7 | 2013-06-30 15:27:26 +0300 | [diff] [blame] | 318 | if (x && x->set_suspend != NULL) |
Venu Byravarasu | de4217d | 2012-09-04 14:25:58 +0530 | [diff] [blame] | 319 | return x->set_suspend(x, suspend); |
| 320 | else |
| 321 | return 0; |
| 322 | } |
| 323 | |
| 324 | static inline int |
Peter Chen | 57bf9b0 | 2014-02-24 10:21:01 +0800 | [diff] [blame] | 325 | usb_phy_set_wakeup(struct usb_phy *x, bool enabled) |
| 326 | { |
| 327 | if (x && x->set_wakeup) |
| 328 | return x->set_wakeup(x, enabled); |
| 329 | else |
| 330 | return 0; |
| 331 | } |
| 332 | |
| 333 | static inline int |
Peter Chen | ac96511 | 2012-11-09 09:44:44 +0800 | [diff] [blame] | 334 | usb_phy_notify_connect(struct usb_phy *x, enum usb_device_speed speed) |
Venu Byravarasu | de4217d | 2012-09-04 14:25:58 +0530 | [diff] [blame] | 335 | { |
Felipe Balbi | 410aee7 | 2013-06-30 15:27:26 +0300 | [diff] [blame] | 336 | if (x && x->notify_connect) |
Peter Chen | ac96511 | 2012-11-09 09:44:44 +0800 | [diff] [blame] | 337 | return x->notify_connect(x, speed); |
Venu Byravarasu | de4217d | 2012-09-04 14:25:58 +0530 | [diff] [blame] | 338 | else |
| 339 | return 0; |
| 340 | } |
| 341 | |
| 342 | static inline int |
Peter Chen | ac96511 | 2012-11-09 09:44:44 +0800 | [diff] [blame] | 343 | usb_phy_notify_disconnect(struct usb_phy *x, enum usb_device_speed speed) |
Venu Byravarasu | de4217d | 2012-09-04 14:25:58 +0530 | [diff] [blame] | 344 | { |
Felipe Balbi | 410aee7 | 2013-06-30 15:27:26 +0300 | [diff] [blame] | 345 | if (x && x->notify_disconnect) |
Peter Chen | ac96511 | 2012-11-09 09:44:44 +0800 | [diff] [blame] | 346 | return x->notify_disconnect(x, speed); |
Venu Byravarasu | de4217d | 2012-09-04 14:25:58 +0530 | [diff] [blame] | 347 | else |
| 348 | return 0; |
| 349 | } |
| 350 | |
| 351 | /* notifiers */ |
| 352 | static inline int |
| 353 | usb_register_notifier(struct usb_phy *x, struct notifier_block *nb) |
| 354 | { |
| 355 | return atomic_notifier_chain_register(&x->notifier, nb); |
| 356 | } |
| 357 | |
| 358 | static inline void |
| 359 | usb_unregister_notifier(struct usb_phy *x, struct notifier_block *nb) |
| 360 | { |
| 361 | atomic_notifier_chain_unregister(&x->notifier, nb); |
| 362 | } |
| 363 | |
| 364 | static inline const char *usb_phy_type_string(enum usb_phy_type type) |
| 365 | { |
| 366 | switch (type) { |
| 367 | case USB_PHY_TYPE_USB2: |
| 368 | return "USB2 PHY"; |
| 369 | case USB_PHY_TYPE_USB3: |
| 370 | return "USB3 PHY"; |
| 371 | default: |
| 372 | return "UNKNOWN PHY TYPE"; |
| 373 | } |
| 374 | } |
| 375 | #endif /* __LINUX_USB_PHY_H */ |