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