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