diff options
author | David Woodhouse <David.Woodhouse@intel.com> | 2012-10-09 10:03:21 -0400 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2012-10-09 10:04:25 -0400 |
commit | ffe315012510165ce82e4dd4767f0a5dba9edbf7 (patch) | |
tree | f601cd980af9d0ced5ca9aedecef4fa0d2ca0e15 /include/linux/usb/otg.h | |
parent | e2d3a35ee427aaba99b6c68a56609ce276c51270 (diff) | |
parent | 4a8e43feeac7996b8de2d5b2823e316917493df4 (diff) |
Merge tag 'disintegrate-mtd-20121009' of git://git.infradead.org/users/dhowells/linux-headers
UAPI Disintegration 2012-10-09
Conflicts:
MAINTAINERS
arch/arm/configs/bcmring_defconfig
arch/arm/mach-imx/clk-imx51-imx53.c
drivers/mtd/nand/Kconfig
drivers/mtd/nand/bcm_umi_nand.c
drivers/mtd/nand/nand_bcm_umi.h
drivers/mtd/nand/orion_nand.c
Diffstat (limited to 'include/linux/usb/otg.h')
-rw-r--r-- | include/linux/usb/otg.h | 236 |
1 files changed, 1 insertions, 235 deletions
diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h index 45824be0a2f9..e8a5fe87c6bd 100644 --- a/include/linux/usb/otg.h +++ b/include/linux/usb/otg.h | |||
@@ -9,56 +9,7 @@ | |||
9 | #ifndef __LINUX_USB_OTG_H | 9 | #ifndef __LINUX_USB_OTG_H |
10 | #define __LINUX_USB_OTG_H | 10 | #define __LINUX_USB_OTG_H |
11 | 11 | ||
12 | #include <linux/notifier.h> | 12 | #include <linux/usb/phy.h> |
13 | |||
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 | |||
38 | enum usb_phy_events { | ||
39 | USB_EVENT_NONE, /* no events or cable disconnected */ | ||
40 | USB_EVENT_VBUS, /* vbus valid event */ | ||
41 | USB_EVENT_ID, /* id was grounded */ | ||
42 | USB_EVENT_CHARGER, /* usb dedicated charger */ | ||
43 | USB_EVENT_ENUMERATED, /* gadget driver enumerated */ | ||
44 | }; | ||
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 | |||
53 | struct usb_phy; | ||
54 | |||
55 | /* for transceivers connected thru an ULPI interface, the user must | ||
56 | * provide access ops | ||
57 | */ | ||
58 | struct usb_phy_io_ops { | ||
59 | int (*read)(struct usb_phy *x, u32 reg); | ||
60 | int (*write)(struct usb_phy *x, u32 val, u32 reg); | ||
61 | }; | ||
62 | 13 | ||
63 | struct usb_otg { | 14 | struct usb_otg { |
64 | u8 default_a; | 15 | u8 default_a; |
@@ -85,134 +36,9 @@ struct usb_otg { | |||
85 | 36 | ||
86 | }; | 37 | }; |
87 | 38 | ||
88 | /* | ||
89 | * the otg driver needs to interact with both device side and host side | ||
90 | * usb controllers. it decides which controller is active at a given | ||
91 | * moment, using the transceiver, ID signal, HNP and sometimes static | ||
92 | * configuration information (including "board isn't wired for otg"). | ||
93 | */ | ||
94 | struct usb_phy { | ||
95 | struct device *dev; | ||
96 | const char *label; | ||
97 | unsigned int flags; | ||
98 | |||
99 | enum usb_phy_type type; | ||
100 | enum usb_otg_state state; | ||
101 | enum usb_phy_events last_event; | ||
102 | |||
103 | struct usb_otg *otg; | ||
104 | |||
105 | struct device *io_dev; | ||
106 | struct usb_phy_io_ops *io_ops; | ||
107 | void __iomem *io_priv; | ||
108 | |||
109 | /* for notification of usb_phy_events */ | ||
110 | struct atomic_notifier_head notifier; | ||
111 | |||
112 | /* to pass extra port status to the root hub */ | ||
113 | u16 port_status; | ||
114 | u16 port_change; | ||
115 | |||
116 | /* to support controllers that have multiple transceivers */ | ||
117 | struct list_head head; | ||
118 | |||
119 | /* initialize/shutdown the OTG controller */ | ||
120 | int (*init)(struct usb_phy *x); | ||
121 | void (*shutdown)(struct usb_phy *x); | ||
122 | |||
123 | /* effective for B devices, ignored for A-peripheral */ | ||
124 | int (*set_power)(struct usb_phy *x, | ||
125 | unsigned mA); | ||
126 | |||
127 | /* for non-OTG B devices: set transceiver into suspend mode */ | ||
128 | int (*set_suspend)(struct usb_phy *x, | ||
129 | int suspend); | ||
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); | ||
134 | }; | ||
135 | |||
136 | |||
137 | /* for board-specific init logic */ | ||
138 | extern int usb_add_phy(struct usb_phy *, enum usb_phy_type type); | ||
139 | extern void usb_remove_phy(struct usb_phy *); | ||
140 | |||
141 | #if defined(CONFIG_NOP_USB_XCEIV) || (defined(CONFIG_NOP_USB_XCEIV_MODULE) && defined(MODULE)) | ||
142 | /* sometimes transceivers are accessed only through e.g. ULPI */ | ||
143 | extern void usb_nop_xceiv_register(void); | ||
144 | extern void usb_nop_xceiv_unregister(void); | ||
145 | #else | ||
146 | static inline void usb_nop_xceiv_register(void) | ||
147 | { | ||
148 | } | ||
149 | |||
150 | static inline void usb_nop_xceiv_unregister(void) | ||
151 | { | ||
152 | } | ||
153 | #endif | ||
154 | |||
155 | /* helpers for direct access thru low-level io interface */ | ||
156 | static inline int usb_phy_io_read(struct usb_phy *x, u32 reg) | ||
157 | { | ||
158 | if (x->io_ops && x->io_ops->read) | ||
159 | return x->io_ops->read(x, reg); | ||
160 | |||
161 | return -EINVAL; | ||
162 | } | ||
163 | |||
164 | static inline int usb_phy_io_write(struct usb_phy *x, u32 val, u32 reg) | ||
165 | { | ||
166 | if (x->io_ops && x->io_ops->write) | ||
167 | return x->io_ops->write(x, val, reg); | ||
168 | |||
169 | return -EINVAL; | ||
170 | } | ||
171 | |||
172 | static inline int | ||
173 | usb_phy_init(struct usb_phy *x) | ||
174 | { | ||
175 | if (x->init) | ||
176 | return x->init(x); | ||
177 | |||
178 | return 0; | ||
179 | } | ||
180 | |||
181 | static inline void | ||
182 | usb_phy_shutdown(struct usb_phy *x) | ||
183 | { | ||
184 | if (x->shutdown) | ||
185 | x->shutdown(x); | ||
186 | } | ||
187 | |||
188 | /* for usb host and peripheral controller drivers */ | ||
189 | #ifdef CONFIG_USB_OTG_UTILS | 39 | #ifdef CONFIG_USB_OTG_UTILS |
190 | extern struct usb_phy *usb_get_phy(enum usb_phy_type type); | ||
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); | ||
195 | extern const char *otg_state_string(enum usb_otg_state state); | 40 | extern const char *otg_state_string(enum usb_otg_state state); |
196 | #else | 41 | #else |
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) | ||
204 | { | ||
205 | return NULL; | ||
206 | } | ||
207 | |||
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) | ||
213 | { | ||
214 | } | ||
215 | |||
216 | static inline const char *otg_state_string(enum usb_otg_state state) | 42 | static inline const char *otg_state_string(enum usb_otg_state state) |
217 | { | 43 | { |
218 | return NULL; | 44 | return NULL; |
@@ -262,42 +88,6 @@ otg_set_peripheral(struct usb_otg *otg, struct usb_gadget *periph) | |||
262 | } | 88 | } |
263 | 89 | ||
264 | static inline int | 90 | static inline int |
265 | usb_phy_set_power(struct usb_phy *x, unsigned mA) | ||
266 | { | ||
267 | if (x && x->set_power) | ||
268 | return x->set_power(x, mA); | ||
269 | return 0; | ||
270 | } | ||
271 | |||
272 | /* Context: can sleep */ | ||
273 | static inline int | ||
274 | usb_phy_set_suspend(struct usb_phy *x, int suspend) | ||
275 | { | ||
276 | if (x->set_suspend != NULL) | ||
277 | return x->set_suspend(x, suspend); | ||
278 | else | ||
279 | return 0; | ||
280 | } | ||
281 | |||
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 | ||
301 | otg_start_srp(struct usb_otg *otg) | 91 | otg_start_srp(struct usb_otg *otg) |
302 | { | 92 | { |
303 | if (otg && otg->start_srp) | 93 | if (otg && otg->start_srp) |
@@ -306,31 +96,7 @@ otg_start_srp(struct usb_otg *otg) | |||
306 | return -ENOTSUPP; | 96 | return -ENOTSUPP; |
307 | } | 97 | } |
308 | 98 | ||
309 | /* notifiers */ | ||
310 | static inline int | ||
311 | usb_register_notifier(struct usb_phy *x, struct notifier_block *nb) | ||
312 | { | ||
313 | return atomic_notifier_chain_register(&x->notifier, nb); | ||
314 | } | ||
315 | |||
316 | static inline void | ||
317 | usb_unregister_notifier(struct usb_phy *x, struct notifier_block *nb) | ||
318 | { | ||
319 | atomic_notifier_chain_unregister(&x->notifier, nb); | ||
320 | } | ||
321 | |||
322 | /* for OTG controller drivers (and maybe other stuff) */ | 99 | /* for OTG controller drivers (and maybe other stuff) */ |
323 | extern int usb_bus_start_enum(struct usb_bus *bus, unsigned port_num); | 100 | extern int usb_bus_start_enum(struct usb_bus *bus, unsigned port_num); |
324 | 101 | ||
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 | } | ||
336 | #endif /* __LINUX_USB_OTG_H */ | 102 | #endif /* __LINUX_USB_OTG_H */ |