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