| Greg Kroah-Hartman | 41dceed | 2008-01-30 15:21:33 -0800 | [diff] [blame] | 1 | /* USB OTG (On The Go) defines */ |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
| Robert P. J. Day | dda43a0 | 2008-03-07 13:45:32 -0500 | [diff] [blame] | 3 | * |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
| Robert P. J. Day | dda43a0 | 2008-03-07 13:45:32 -0500 | [diff] [blame] | 9 | #ifndef __LINUX_USB_OTG_H |
| 10 | #define __LINUX_USB_OTG_H |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | |
| Felipe Balbi | e9a2017 | 2009-12-17 13:01:36 +0200 | [diff] [blame] | 12 | #include <linux/notifier.h> |
| 13 | |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | /* OTG defines lots of enumeration states before device reset */ |
| 15 | enum usb_otg_state { |
| 16 | OTG_STATE_UNDEFINED = 0, |
| 17 | |
| 18 | /* single-role peripheral, and dual-role default-b */ |
| 19 | OTG_STATE_B_IDLE, |
| 20 | OTG_STATE_B_SRP_INIT, |
| 21 | OTG_STATE_B_PERIPHERAL, |
| 22 | |
| 23 | /* extra dual-role default-b states */ |
| 24 | OTG_STATE_B_WAIT_ACON, |
| 25 | OTG_STATE_B_HOST, |
| 26 | |
| 27 | /* dual-role default-a */ |
| 28 | OTG_STATE_A_IDLE, |
| 29 | OTG_STATE_A_WAIT_VRISE, |
| 30 | OTG_STATE_A_WAIT_BCON, |
| 31 | OTG_STATE_A_HOST, |
| 32 | OTG_STATE_A_SUSPEND, |
| 33 | OTG_STATE_A_PERIPHERAL, |
| 34 | OTG_STATE_A_WAIT_VFALL, |
| 35 | OTG_STATE_A_VBUS_ERR, |
| 36 | }; |
| 37 | |
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 38 | enum usb_otg_event { |
| 39 | /* Device is not connected within |
| 40 | * TA_WAIT_BCON or not responding. |
| 41 | */ |
| 42 | OTG_EVENT_DEV_CONN_TMOUT, |
| 43 | /* B-device returned STALL for |
| 44 | * B_HNP_ENABLE feature request. |
| 45 | */ |
| 46 | OTG_EVENT_NO_RESP_FOR_HNP_ENABLE, |
| 47 | /* HUB class devices are not |
| 48 | * supported. |
| 49 | */ |
| 50 | OTG_EVENT_HUB_NOT_SUPPORTED, |
| 51 | /* Device is not supported i.e |
| 52 | * not listed in TPL. |
| 53 | */ |
| 54 | OTG_EVENT_DEV_NOT_SUPPORTED, |
| 55 | /* HNP failed due to |
| 56 | * TA_AIDL_BDIS timeout or |
| 57 | * TB_ASE0_BRST timeout |
| 58 | */ |
| 59 | OTG_EVENT_HNP_FAILED, |
| 60 | /* B-device did not detect VBUS |
| 61 | * within TB_SRP_FAIL time. |
| 62 | */ |
| 63 | OTG_EVENT_NO_RESP_FOR_SRP, |
| Flemmard | 77ad321 | 2013-02-12 16:25:42 +0100 | [diff] [blame] | 64 | #ifdef CONFIG_MACH_HTC |
| 65 | /* broadcast uevent when device vbus ouput is |
| 66 | lower than the repuirement of otg device. |
| 67 | */ |
| 68 | OTG_EVENT_INSUFFICIENT_POWER, |
| 69 | #endif |
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 70 | }; |
| 71 | |
| Heikki Krogerus | de07e18 | 2012-02-13 13:24:03 +0200 | [diff] [blame] | 72 | enum usb_phy_events { |
| Felipe Balbi | e9a2017 | 2009-12-17 13:01:36 +0200 | [diff] [blame] | 73 | USB_EVENT_NONE, /* no events or cable disconnected */ |
| 74 | USB_EVENT_VBUS, /* vbus valid event */ |
| 75 | USB_EVENT_ID, /* id was grounded */ |
| 76 | USB_EVENT_CHARGER, /* usb dedicated charger */ |
| 77 | USB_EVENT_ENUMERATED, /* gadget driver enumerated */ |
| 78 | }; |
| 79 | |
| Heikki Krogerus | 8675381 | 2012-02-13 13:24:02 +0200 | [diff] [blame] | 80 | struct usb_phy; |
| Daniel Mack | 91c8a5a | 2009-10-15 17:09:34 +0300 | [diff] [blame] | 81 | |
| 82 | /* for transceivers connected thru an ULPI interface, the user must |
| 83 | * provide access ops |
| 84 | */ |
| Heikki Krogerus | 7a8a3a9 | 2012-02-13 13:24:04 +0200 | [diff] [blame] | 85 | struct usb_phy_io_ops { |
| Heikki Krogerus | 8675381 | 2012-02-13 13:24:02 +0200 | [diff] [blame] | 86 | int (*read)(struct usb_phy *x, u32 reg); |
| 87 | int (*write)(struct usb_phy *x, u32 val, u32 reg); |
| James Sullins | 0ada967 | 2013-12-25 17:12:35 -0600 | [diff] [blame] | 88 | #ifdef CONFIG_USB_MULTIPLE_CHARGER_DETECT |
| 89 | int (*read_with_reset)(struct usb_phy *x, u32 reg); |
| 90 | int (*write_with_reset)(struct usb_phy *x, u32 val, u32 reg); |
| 91 | #endif |
| Daniel Mack | 91c8a5a | 2009-10-15 17:09:34 +0300 | [diff] [blame] | 92 | }; |
| 93 | |
| Heikki Krogerus | 7a8a3a9 | 2012-02-13 13:24:04 +0200 | [diff] [blame] | 94 | struct usb_otg { |
| 95 | u8 default_a; |
| 96 | |
| 97 | struct usb_phy *phy; |
| 98 | struct usb_bus *host; |
| 99 | struct usb_gadget *gadget; |
| 100 | |
| 101 | /* bind/unbind the host controller */ |
| 102 | int (*set_host)(struct usb_otg *otg, struct usb_bus *host); |
| 103 | |
| 104 | /* bind/unbind the peripheral controller */ |
| 105 | int (*set_peripheral)(struct usb_otg *otg, |
| 106 | struct usb_gadget *gadget); |
| 107 | |
| 108 | /* effective for A-peripheral, ignored for B devices */ |
| 109 | int (*set_vbus)(struct usb_otg *otg, bool enabled); |
| 110 | |
| 111 | /* for B devices only: start session with A-Host */ |
| 112 | int (*start_srp)(struct usb_otg *otg); |
| 113 | |
| 114 | /* start or continue HNP role switch */ |
| 115 | int (*start_hnp)(struct usb_otg *otg); |
| 116 | |
| Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 117 | /* send events to user space */ |
| 118 | int (*send_event)(struct usb_otg *otg, |
| 119 | enum usb_otg_event event); |
| 120 | |
| Heikki Krogerus | 7a8a3a9 | 2012-02-13 13:24:04 +0200 | [diff] [blame] | 121 | }; |
| 122 | |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | /* |
| 124 | * the otg driver needs to interact with both device side and host side |
| 125 | * usb controllers. it decides which controller is active at a given |
| 126 | * moment, using the transceiver, ID signal, HNP and sometimes static |
| 127 | * configuration information (including "board isn't wired for otg"). |
| 128 | */ |
| Heikki Krogerus | 8675381 | 2012-02-13 13:24:02 +0200 | [diff] [blame] | 129 | struct usb_phy { |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | struct device *dev; |
| 131 | const char *label; |
| Daniel Mack | 91c8a5a | 2009-10-15 17:09:34 +0300 | [diff] [blame] | 132 | unsigned int flags; |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | enum usb_otg_state state; |
| Heikki Krogerus | de07e18 | 2012-02-13 13:24:03 +0200 | [diff] [blame] | 135 | enum usb_phy_events last_event; |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | |
| Heikki Krogerus | 7a8a3a9 | 2012-02-13 13:24:04 +0200 | [diff] [blame] | 137 | struct usb_otg *otg; |
| 138 | |
| Grazvydas Ignotas | bf070bc | 2012-03-21 16:35:52 +0200 | [diff] [blame] | 139 | struct device *io_dev; |
| Heikki Krogerus | 7a8a3a9 | 2012-02-13 13:24:04 +0200 | [diff] [blame] | 140 | struct usb_phy_io_ops *io_ops; |
| 141 | void __iomem *io_priv; |
| Daniel Mack | 91c8a5a | 2009-10-15 17:09:34 +0300 | [diff] [blame] | 142 | |
| Heikki Krogerus | de07e18 | 2012-02-13 13:24:03 +0200 | [diff] [blame] | 143 | /* for notification of usb_phy_events */ |
| Felipe Balbi | cccad6d | 2010-09-29 10:55:49 +0300 | [diff] [blame] | 144 | struct atomic_notifier_head notifier; |
| Felipe Balbi | e9a2017 | 2009-12-17 13:01:36 +0200 | [diff] [blame] | 145 | |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | /* to pass extra port status to the root hub */ |
| 147 | u16 port_status; |
| 148 | u16 port_change; |
| 149 | |
| Daniel Mack | 91c8a5a | 2009-10-15 17:09:34 +0300 | [diff] [blame] | 150 | /* initialize/shutdown the OTG controller */ |
| Heikki Krogerus | 8675381 | 2012-02-13 13:24:02 +0200 | [diff] [blame] | 151 | int (*init)(struct usb_phy *x); |
| 152 | void (*shutdown)(struct usb_phy *x); |
| Daniel Mack | 91c8a5a | 2009-10-15 17:09:34 +0300 | [diff] [blame] | 153 | |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | /* effective for B devices, ignored for A-peripheral */ |
| Heikki Krogerus | 8675381 | 2012-02-13 13:24:02 +0200 | [diff] [blame] | 155 | int (*set_power)(struct usb_phy *x, |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 156 | unsigned mA); |
| 157 | |
| Juha Yrj?l? | 4e67185 | 2005-10-16 15:47:04 -0700 | [diff] [blame] | 158 | /* for non-OTG B devices: set transceiver into suspend mode */ |
| Heikki Krogerus | 8675381 | 2012-02-13 13:24:02 +0200 | [diff] [blame] | 159 | int (*set_suspend)(struct usb_phy *x, |
| Juha Yrj?l? | 4e67185 | 2005-10-16 15:47:04 -0700 | [diff] [blame] | 160 | int suspend); |
| 161 | |
| Flemmard | 77ad321 | 2013-02-12 16:25:42 +0100 | [diff] [blame] | 162 | #ifdef CONFIG_MACH_HTC |
| 163 | /* send events to user space */ |
| 164 | int (*send_event)(struct usb_phy *phy, |
| 165 | enum usb_otg_event event); |
| 166 | |
| 167 | void (*notify_usb_attached)(void); |
| 168 | #endif |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | }; |
| 170 | |
| 171 | |
| 172 | /* for board-specific init logic */ |
| Heikki Krogerus | 7a8a3a9 | 2012-02-13 13:24:04 +0200 | [diff] [blame] | 173 | extern int usb_set_transceiver(struct usb_phy *); |
| David Brownell | cc835e3 | 2009-03-31 12:28:31 -0700 | [diff] [blame] | 174 | |
| Guennadi Liakhovetski | 352a337 | 2010-12-09 22:46:29 +0100 | [diff] [blame] | 175 | #if defined(CONFIG_NOP_USB_XCEIV) || (defined(CONFIG_NOP_USB_XCEIV_MODULE) && defined(MODULE)) |
| David Brownell | cc835e3 | 2009-03-31 12:28:31 -0700 | [diff] [blame] | 176 | /* sometimes transceivers are accessed only through e.g. ULPI */ |
| Ajay Kumar Gupta | f6d92a0 | 2009-02-06 17:32:35 +0530 | [diff] [blame] | 177 | extern void usb_nop_xceiv_register(void); |
| 178 | extern void usb_nop_xceiv_unregister(void); |
| Maulik Mankad | 224e154 | 2010-02-17 14:09:29 -0800 | [diff] [blame] | 179 | #else |
| 180 | static inline void usb_nop_xceiv_register(void) |
| 181 | { |
| 182 | } |
| 183 | |
| 184 | static inline void usb_nop_xceiv_unregister(void) |
| 185 | { |
| 186 | } |
| 187 | #endif |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 188 | |
| Daniel Mack | 91c8a5a | 2009-10-15 17:09:34 +0300 | [diff] [blame] | 189 | /* helpers for direct access thru low-level io interface */ |
| Heikki Krogerus | 7a8a3a9 | 2012-02-13 13:24:04 +0200 | [diff] [blame] | 190 | static inline int usb_phy_io_read(struct usb_phy *x, u32 reg) |
| Daniel Mack | 91c8a5a | 2009-10-15 17:09:34 +0300 | [diff] [blame] | 191 | { |
| Heikki Krogerus | 8675381 | 2012-02-13 13:24:02 +0200 | [diff] [blame] | 192 | if (x->io_ops && x->io_ops->read) |
| 193 | return x->io_ops->read(x, reg); |
| Daniel Mack | 91c8a5a | 2009-10-15 17:09:34 +0300 | [diff] [blame] | 194 | |
| 195 | return -EINVAL; |
| 196 | } |
| 197 | |
| Heikki Krogerus | 7a8a3a9 | 2012-02-13 13:24:04 +0200 | [diff] [blame] | 198 | static inline int usb_phy_io_write(struct usb_phy *x, u32 val, u32 reg) |
| Daniel Mack | 91c8a5a | 2009-10-15 17:09:34 +0300 | [diff] [blame] | 199 | { |
| Heikki Krogerus | 8675381 | 2012-02-13 13:24:02 +0200 | [diff] [blame] | 200 | if (x->io_ops && x->io_ops->write) |
| 201 | return x->io_ops->write(x, val, reg); |
| Daniel Mack | 91c8a5a | 2009-10-15 17:09:34 +0300 | [diff] [blame] | 202 | |
| 203 | return -EINVAL; |
| 204 | } |
| 205 | |
| 206 | static inline int |
| Heikki Krogerus | 7a8a3a9 | 2012-02-13 13:24:04 +0200 | [diff] [blame] | 207 | usb_phy_init(struct usb_phy *x) |
| Daniel Mack | 91c8a5a | 2009-10-15 17:09:34 +0300 | [diff] [blame] | 208 | { |
| Heikki Krogerus | 8675381 | 2012-02-13 13:24:02 +0200 | [diff] [blame] | 209 | if (x->init) |
| 210 | return x->init(x); |
| Daniel Mack | 91c8a5a | 2009-10-15 17:09:34 +0300 | [diff] [blame] | 211 | |
| 212 | return 0; |
| 213 | } |
| 214 | |
| 215 | static inline void |
| Heikki Krogerus | 7a8a3a9 | 2012-02-13 13:24:04 +0200 | [diff] [blame] | 216 | usb_phy_shutdown(struct usb_phy *x) |
| Daniel Mack | 91c8a5a | 2009-10-15 17:09:34 +0300 | [diff] [blame] | 217 | { |
| Heikki Krogerus | 8675381 | 2012-02-13 13:24:02 +0200 | [diff] [blame] | 218 | if (x->shutdown) |
| 219 | x->shutdown(x); |
| Daniel Mack | 91c8a5a | 2009-10-15 17:09:34 +0300 | [diff] [blame] | 220 | } |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | |
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 222 | /* for USB core, host and peripheral controller drivers */ |
| 223 | /* Context: can sleep */ |
| 224 | extern int otg_send_event(enum usb_otg_event event); |
| 225 | |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 226 | /* for usb host and peripheral controller drivers */ |
| Grazvydas Ignotas | 748eee0 | 2010-09-27 15:17:18 +0300 | [diff] [blame] | 227 | #ifdef CONFIG_USB_OTG_UTILS |
| Heikki Krogerus | 7a8a3a9 | 2012-02-13 13:24:04 +0200 | [diff] [blame] | 228 | extern struct usb_phy *usb_get_transceiver(void); |
| 229 | extern void usb_put_transceiver(struct usb_phy *); |
| Anatolij Gustschin | 3df0045 | 2011-05-05 12:11:21 +0200 | [diff] [blame] | 230 | extern const char *otg_state_string(enum usb_otg_state state); |
| Grazvydas Ignotas | 748eee0 | 2010-09-27 15:17:18 +0300 | [diff] [blame] | 231 | #else |
| Heikki Krogerus | 7a8a3a9 | 2012-02-13 13:24:04 +0200 | [diff] [blame] | 232 | static inline struct usb_phy *usb_get_transceiver(void) |
| Grazvydas Ignotas | 748eee0 | 2010-09-27 15:17:18 +0300 | [diff] [blame] | 233 | { |
| 234 | return NULL; |
| 235 | } |
| 236 | |
| Heikki Krogerus | 7a8a3a9 | 2012-02-13 13:24:04 +0200 | [diff] [blame] | 237 | static inline void usb_put_transceiver(struct usb_phy *x) |
| Grazvydas Ignotas | 748eee0 | 2010-09-27 15:17:18 +0300 | [diff] [blame] | 238 | { |
| 239 | } |
| Anatolij Gustschin | 3df0045 | 2011-05-05 12:11:21 +0200 | [diff] [blame] | 240 | |
| 241 | static inline const char *otg_state_string(enum usb_otg_state state) |
| 242 | { |
| 243 | return NULL; |
| 244 | } |
| Grazvydas Ignotas | 748eee0 | 2010-09-27 15:17:18 +0300 | [diff] [blame] | 245 | #endif |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 246 | |
| Robert Jarzmik | c2344f1 | 2009-01-24 23:54:31 -0800 | [diff] [blame] | 247 | /* Context: can sleep */ |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | static inline int |
| Heikki Krogerus | 6e13c65 | 2012-02-13 13:24:20 +0200 | [diff] [blame] | 249 | otg_start_hnp(struct usb_otg *otg) |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 250 | { |
| Heikki Krogerus | 6e13c65 | 2012-02-13 13:24:20 +0200 | [diff] [blame] | 251 | if (otg && otg->start_hnp) |
| 252 | return otg->start_hnp(otg); |
| Heikki Krogerus | 7a8a3a9 | 2012-02-13 13:24:04 +0200 | [diff] [blame] | 253 | |
| Heikki Krogerus | 136ced8 | 2012-02-13 13:24:19 +0200 | [diff] [blame] | 254 | return -ENOTSUPP; |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 255 | } |
| 256 | |
| Daniel Mack | 91c8a5a | 2009-10-15 17:09:34 +0300 | [diff] [blame] | 257 | /* Context: can sleep */ |
| 258 | static inline int |
| Heikki Krogerus | 6e13c65 | 2012-02-13 13:24:20 +0200 | [diff] [blame] | 259 | otg_set_vbus(struct usb_otg *otg, bool enabled) |
| Daniel Mack | 91c8a5a | 2009-10-15 17:09:34 +0300 | [diff] [blame] | 260 | { |
| Heikki Krogerus | 6e13c65 | 2012-02-13 13:24:20 +0200 | [diff] [blame] | 261 | if (otg && otg->set_vbus) |
| 262 | return otg->set_vbus(otg, enabled); |
| Heikki Krogerus | 7a8a3a9 | 2012-02-13 13:24:04 +0200 | [diff] [blame] | 263 | |
| Heikki Krogerus | 136ced8 | 2012-02-13 13:24:19 +0200 | [diff] [blame] | 264 | return -ENOTSUPP; |
| Daniel Mack | 91c8a5a | 2009-10-15 17:09:34 +0300 | [diff] [blame] | 265 | } |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 266 | |
| 267 | /* for HCDs */ |
| 268 | static inline int |
| Heikki Krogerus | 6e13c65 | 2012-02-13 13:24:20 +0200 | [diff] [blame] | 269 | otg_set_host(struct usb_otg *otg, struct usb_bus *host) |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 270 | { |
| Heikki Krogerus | 6e13c65 | 2012-02-13 13:24:20 +0200 | [diff] [blame] | 271 | if (otg && otg->set_host) |
| 272 | return otg->set_host(otg, host); |
| Heikki Krogerus | 7a8a3a9 | 2012-02-13 13:24:04 +0200 | [diff] [blame] | 273 | |
| Heikki Krogerus | 136ced8 | 2012-02-13 13:24:19 +0200 | [diff] [blame] | 274 | return -ENOTSUPP; |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | } |
| 276 | |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 277 | /* for usb peripheral controller drivers */ |
| Robert Jarzmik | c2344f1 | 2009-01-24 23:54:31 -0800 | [diff] [blame] | 278 | |
| 279 | /* Context: can sleep */ |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 280 | static inline int |
| Heikki Krogerus | 6e13c65 | 2012-02-13 13:24:20 +0200 | [diff] [blame] | 281 | otg_set_peripheral(struct usb_otg *otg, struct usb_gadget *periph) |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 282 | { |
| Heikki Krogerus | 6e13c65 | 2012-02-13 13:24:20 +0200 | [diff] [blame] | 283 | if (otg && otg->set_peripheral) |
| 284 | return otg->set_peripheral(otg, periph); |
| Heikki Krogerus | 7a8a3a9 | 2012-02-13 13:24:04 +0200 | [diff] [blame] | 285 | |
| Heikki Krogerus | 136ced8 | 2012-02-13 13:24:19 +0200 | [diff] [blame] | 286 | return -ENOTSUPP; |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 287 | } |
| 288 | |
| 289 | static inline int |
| Heikki Krogerus | 7a8a3a9 | 2012-02-13 13:24:04 +0200 | [diff] [blame] | 290 | usb_phy_set_power(struct usb_phy *x, unsigned mA) |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | { |
| Heikki Krogerus | 7a8a3a9 | 2012-02-13 13:24:04 +0200 | [diff] [blame] | 292 | if (x && x->set_power) |
| 293 | return x->set_power(x, mA); |
| 294 | return 0; |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 295 | } |
| 296 | |
| Robert Jarzmik | c2344f1 | 2009-01-24 23:54:31 -0800 | [diff] [blame] | 297 | /* Context: can sleep */ |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 298 | static inline int |
| Heikki Krogerus | 7a8a3a9 | 2012-02-13 13:24:04 +0200 | [diff] [blame] | 299 | usb_phy_set_suspend(struct usb_phy *x, int suspend) |
| Juha Yrj?l? | 4e67185 | 2005-10-16 15:47:04 -0700 | [diff] [blame] | 300 | { |
| Heikki Krogerus | 8675381 | 2012-02-13 13:24:02 +0200 | [diff] [blame] | 301 | if (x->set_suspend != NULL) |
| 302 | return x->set_suspend(x, suspend); |
| Juha Yrj?l? | 4e67185 | 2005-10-16 15:47:04 -0700 | [diff] [blame] | 303 | else |
| 304 | return 0; |
| 305 | } |
| 306 | |
| 307 | static inline int |
| Heikki Krogerus | 6e13c65 | 2012-02-13 13:24:20 +0200 | [diff] [blame] | 308 | otg_start_srp(struct usb_otg *otg) |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 309 | { |
| Heikki Krogerus | 6e13c65 | 2012-02-13 13:24:20 +0200 | [diff] [blame] | 310 | if (otg && otg->start_srp) |
| 311 | return otg->start_srp(otg); |
| Heikki Krogerus | 7a8a3a9 | 2012-02-13 13:24:04 +0200 | [diff] [blame] | 312 | |
| Heikki Krogerus | 136ced8 | 2012-02-13 13:24:19 +0200 | [diff] [blame] | 313 | return -ENOTSUPP; |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 314 | } |
| 315 | |
| Felipe Balbi | e9a2017 | 2009-12-17 13:01:36 +0200 | [diff] [blame] | 316 | /* notifiers */ |
| 317 | static inline int |
| Heikki Krogerus | 7a8a3a9 | 2012-02-13 13:24:04 +0200 | [diff] [blame] | 318 | usb_register_notifier(struct usb_phy *x, struct notifier_block *nb) |
| Felipe Balbi | e9a2017 | 2009-12-17 13:01:36 +0200 | [diff] [blame] | 319 | { |
| Heikki Krogerus | 8675381 | 2012-02-13 13:24:02 +0200 | [diff] [blame] | 320 | return atomic_notifier_chain_register(&x->notifier, nb); |
| Felipe Balbi | e9a2017 | 2009-12-17 13:01:36 +0200 | [diff] [blame] | 321 | } |
| 322 | |
| 323 | static inline void |
| Heikki Krogerus | 7a8a3a9 | 2012-02-13 13:24:04 +0200 | [diff] [blame] | 324 | usb_unregister_notifier(struct usb_phy *x, struct notifier_block *nb) |
| Felipe Balbi | e9a2017 | 2009-12-17 13:01:36 +0200 | [diff] [blame] | 325 | { |
| Heikki Krogerus | 8675381 | 2012-02-13 13:24:02 +0200 | [diff] [blame] | 326 | atomic_notifier_chain_unregister(&x->notifier, nb); |
| Felipe Balbi | e9a2017 | 2009-12-17 13:01:36 +0200 | [diff] [blame] | 327 | } |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 328 | |
| 329 | /* for OTG controller drivers (and maybe other stuff) */ |
| 330 | extern int usb_bus_start_enum(struct usb_bus *bus, unsigned port_num); |
| Robert P. J. Day | dda43a0 | 2008-03-07 13:45:32 -0500 | [diff] [blame] | 331 | |
| 332 | #endif /* __LINUX_USB_OTG_H */ |