diff options
Diffstat (limited to 'include/linux/usb/otg.h')
-rw-r--r-- | include/linux/usb/otg.h | 67 |
1 files changed, 62 insertions, 5 deletions
diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h index 38ab3f46346..45824be0a2f 100644 --- a/include/linux/usb/otg.h +++ b/include/linux/usb/otg.h | |||
@@ -43,6 +43,13 @@ enum usb_phy_events { | |||
43 | USB_EVENT_ENUMERATED, /* gadget driver enumerated */ | 43 | USB_EVENT_ENUMERATED, /* gadget driver enumerated */ |
44 | }; | 44 | }; |
45 | 45 | ||
46 | /* associate a type with PHY */ | ||
47 | enum usb_phy_type { | ||
48 | USB_PHY_TYPE_UNDEFINED, | ||
49 | USB_PHY_TYPE_USB2, | ||
50 | USB_PHY_TYPE_USB3, | ||
51 | }; | ||
52 | |||
46 | struct usb_phy; | 53 | struct usb_phy; |
47 | 54 | ||
48 | /* for transceivers connected thru an ULPI interface, the user must | 55 | /* for transceivers connected thru an ULPI interface, the user must |
@@ -89,6 +96,7 @@ struct usb_phy { | |||
89 | const char *label; | 96 | const char *label; |
90 | unsigned int flags; | 97 | unsigned int flags; |
91 | 98 | ||
99 | enum usb_phy_type type; | ||
92 | enum usb_otg_state state; | 100 | enum usb_otg_state state; |
93 | enum usb_phy_events last_event; | 101 | enum usb_phy_events last_event; |
94 | 102 | ||
@@ -105,6 +113,9 @@ struct usb_phy { | |||
105 | u16 port_status; | 113 | u16 port_status; |
106 | u16 port_change; | 114 | u16 port_change; |
107 | 115 | ||
116 | /* to support controllers that have multiple transceivers */ | ||
117 | struct list_head head; | ||
118 | |||
108 | /* initialize/shutdown the OTG controller */ | 119 | /* initialize/shutdown the OTG controller */ |
109 | int (*init)(struct usb_phy *x); | 120 | int (*init)(struct usb_phy *x); |
110 | void (*shutdown)(struct usb_phy *x); | 121 | void (*shutdown)(struct usb_phy *x); |
@@ -117,11 +128,15 @@ struct usb_phy { | |||
117 | int (*set_suspend)(struct usb_phy *x, | 128 | int (*set_suspend)(struct usb_phy *x, |
118 | int suspend); | 129 | int suspend); |
119 | 130 | ||
131 | /* notify phy connect status change */ | ||
132 | int (*notify_connect)(struct usb_phy *x, int port); | ||
133 | int (*notify_disconnect)(struct usb_phy *x, int port); | ||
120 | }; | 134 | }; |
121 | 135 | ||
122 | 136 | ||
123 | /* for board-specific init logic */ | 137 | /* for board-specific init logic */ |
124 | extern int usb_set_transceiver(struct usb_phy *); | 138 | extern int usb_add_phy(struct usb_phy *, enum usb_phy_type type); |
139 | extern void usb_remove_phy(struct usb_phy *); | ||
125 | 140 | ||
126 | #if defined(CONFIG_NOP_USB_XCEIV) || (defined(CONFIG_NOP_USB_XCEIV_MODULE) && defined(MODULE)) | 141 | #if defined(CONFIG_NOP_USB_XCEIV) || (defined(CONFIG_NOP_USB_XCEIV_MODULE) && defined(MODULE)) |
127 | /* sometimes transceivers are accessed only through e.g. ULPI */ | 142 | /* sometimes transceivers are accessed only through e.g. ULPI */ |
@@ -172,16 +187,29 @@ usb_phy_shutdown(struct usb_phy *x) | |||
172 | 187 | ||
173 | /* for usb host and peripheral controller drivers */ | 188 | /* for usb host and peripheral controller drivers */ |
174 | #ifdef CONFIG_USB_OTG_UTILS | 189 | #ifdef CONFIG_USB_OTG_UTILS |
175 | extern struct usb_phy *usb_get_transceiver(void); | 190 | extern struct usb_phy *usb_get_phy(enum usb_phy_type type); |
176 | extern void usb_put_transceiver(struct usb_phy *); | 191 | extern struct usb_phy *devm_usb_get_phy(struct device *dev, |
192 | enum usb_phy_type type); | ||
193 | extern void usb_put_phy(struct usb_phy *); | ||
194 | extern void devm_usb_put_phy(struct device *dev, struct usb_phy *x); | ||
177 | extern const char *otg_state_string(enum usb_otg_state state); | 195 | extern const char *otg_state_string(enum usb_otg_state state); |
178 | #else | 196 | #else |
179 | static inline struct usb_phy *usb_get_transceiver(void) | 197 | static inline struct usb_phy *usb_get_phy(enum usb_phy_type type) |
198 | { | ||
199 | return NULL; | ||
200 | } | ||
201 | |||
202 | static inline struct usb_phy *devm_usb_get_phy(struct device *dev, | ||
203 | enum usb_phy_type type) | ||
180 | { | 204 | { |
181 | return NULL; | 205 | return NULL; |
182 | } | 206 | } |
183 | 207 | ||
184 | static inline void usb_put_transceiver(struct usb_phy *x) | 208 | static inline void usb_put_phy(struct usb_phy *x) |
209 | { | ||
210 | } | ||
211 | |||
212 | static inline void devm_usb_put_phy(struct device *dev, struct usb_phy *x) | ||
185 | { | 213 | { |
186 | } | 214 | } |
187 | 215 | ||
@@ -252,6 +280,24 @@ usb_phy_set_suspend(struct usb_phy *x, int suspend) | |||
252 | } | 280 | } |
253 | 281 | ||
254 | static inline int | 282 | static inline int |
283 | usb_phy_notify_connect(struct usb_phy *x, int port) | ||
284 | { | ||
285 | if (x->notify_connect) | ||
286 | return x->notify_connect(x, port); | ||
287 | else | ||
288 | return 0; | ||
289 | } | ||
290 | |||
291 | static inline int | ||
292 | usb_phy_notify_disconnect(struct usb_phy *x, int port) | ||
293 | { | ||
294 | if (x->notify_disconnect) | ||
295 | return x->notify_disconnect(x, port); | ||
296 | else | ||
297 | return 0; | ||
298 | } | ||
299 | |||
300 | static inline int | ||
255 | otg_start_srp(struct usb_otg *otg) | 301 | otg_start_srp(struct usb_otg *otg) |
256 | { | 302 | { |
257 | if (otg && otg->start_srp) | 303 | if (otg && otg->start_srp) |
@@ -276,4 +322,15 @@ usb_unregister_notifier(struct usb_phy *x, struct notifier_block *nb) | |||
276 | /* for OTG controller drivers (and maybe other stuff) */ | 322 | /* for OTG controller drivers (and maybe other stuff) */ |
277 | extern int usb_bus_start_enum(struct usb_bus *bus, unsigned port_num); | 323 | extern int usb_bus_start_enum(struct usb_bus *bus, unsigned port_num); |
278 | 324 | ||
325 | static inline const char *usb_phy_type_string(enum usb_phy_type type) | ||
326 | { | ||
327 | switch (type) { | ||
328 | case USB_PHY_TYPE_USB2: | ||
329 | return "USB2 PHY"; | ||
330 | case USB_PHY_TYPE_USB3: | ||
331 | return "USB3 PHY"; | ||
332 | default: | ||
333 | return "UNKNOWN PHY TYPE"; | ||
334 | } | ||
335 | } | ||
279 | #endif /* __LINUX_USB_OTG_H */ | 336 | #endif /* __LINUX_USB_OTG_H */ |