aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/usb/otg.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/usb/otg.h')
-rw-r--r--include/linux/usb/otg.h44
1 files changed, 36 insertions, 8 deletions
diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h
index 52bb917641f0..545cba73ccaf 100644
--- a/include/linux/usb/otg.h
+++ b/include/linux/usb/otg.h
@@ -9,6 +9,8 @@
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>
13
12/* OTG defines lots of enumeration states before device reset */ 14/* OTG defines lots of enumeration states before device reset */
13enum usb_otg_state { 15enum usb_otg_state {
14 OTG_STATE_UNDEFINED = 0, 16 OTG_STATE_UNDEFINED = 0,
@@ -33,12 +35,13 @@ enum usb_otg_state {
33 OTG_STATE_A_VBUS_ERR, 35 OTG_STATE_A_VBUS_ERR,
34}; 36};
35 37
36#define USB_OTG_PULLUP_ID (1 << 0) 38enum usb_xceiv_events {
37#define USB_OTG_PULLDOWN_DP (1 << 1) 39 USB_EVENT_NONE, /* no events or cable disconnected */
38#define USB_OTG_PULLDOWN_DM (1 << 2) 40 USB_EVENT_VBUS, /* vbus valid event */
39#define USB_OTG_EXT_VBUS_INDICATOR (1 << 3) 41 USB_EVENT_ID, /* id was grounded */
40#define USB_OTG_DRV_VBUS (1 << 4) 42 USB_EVENT_CHARGER, /* usb dedicated charger */
41#define USB_OTG_DRV_VBUS_EXT (1 << 5) 43 USB_EVENT_ENUMERATED, /* gadget driver enumerated */
44};
42 45
43struct otg_transceiver; 46struct otg_transceiver;
44 47
@@ -70,6 +73,9 @@ struct otg_transceiver {
70 struct otg_io_access_ops *io_ops; 73 struct otg_io_access_ops *io_ops;
71 void __iomem *io_priv; 74 void __iomem *io_priv;
72 75
76 /* for notification of usb_xceiv_events */
77 struct blocking_notifier_head notifier;
78
73 /* to pass extra port status to the root hub */ 79 /* to pass extra port status to the root hub */
74 u16 port_status; 80 u16 port_status;
75 u16 port_change; 81 u16 port_change;
@@ -110,9 +116,19 @@ struct otg_transceiver {
110/* for board-specific init logic */ 116/* for board-specific init logic */
111extern int otg_set_transceiver(struct otg_transceiver *); 117extern int otg_set_transceiver(struct otg_transceiver *);
112 118
119#if defined(CONFIG_NOP_USB_XCEIV) || defined(CONFIG_NOP_USB_XCEIV_MODULE)
113/* sometimes transceivers are accessed only through e.g. ULPI */ 120/* sometimes transceivers are accessed only through e.g. ULPI */
114extern void usb_nop_xceiv_register(void); 121extern void usb_nop_xceiv_register(void);
115extern void usb_nop_xceiv_unregister(void); 122extern void usb_nop_xceiv_unregister(void);
123#else
124static inline void usb_nop_xceiv_register(void)
125{
126}
127
128static inline void usb_nop_xceiv_unregister(void)
129{
130}
131#endif
116 132
117/* helpers for direct access thru low-level io interface */ 133/* helpers for direct access thru low-level io interface */
118static inline int otg_io_read(struct otg_transceiver *otg, u32 reg) 134static inline int otg_io_read(struct otg_transceiver *otg, u32 reg)
@@ -123,10 +139,10 @@ static inline int otg_io_read(struct otg_transceiver *otg, u32 reg)
123 return -EINVAL; 139 return -EINVAL;
124} 140}
125 141
126static inline int otg_io_write(struct otg_transceiver *otg, u32 reg, u32 val) 142static inline int otg_io_write(struct otg_transceiver *otg, u32 val, u32 reg)
127{ 143{
128 if (otg->io_ops && otg->io_ops->write) 144 if (otg->io_ops && otg->io_ops->write)
129 return otg->io_ops->write(otg, reg, val); 145 return otg->io_ops->write(otg, val, reg);
130 146
131 return -EINVAL; 147 return -EINVAL;
132} 148}
@@ -203,6 +219,18 @@ otg_start_srp(struct otg_transceiver *otg)
203 return otg->start_srp(otg); 219 return otg->start_srp(otg);
204} 220}
205 221
222/* notifiers */
223static inline int
224otg_register_notifier(struct otg_transceiver *otg, struct notifier_block *nb)
225{
226 return blocking_notifier_chain_register(&otg->notifier, nb);
227}
228
229static inline void
230otg_unregister_notifier(struct otg_transceiver *otg, struct notifier_block *nb)
231{
232 blocking_notifier_chain_unregister(&otg->notifier, nb);
233}
206 234
207/* for OTG controller drivers (and maybe other stuff) */ 235/* for OTG controller drivers (and maybe other stuff) */
208extern int usb_bus_start_enum(struct usb_bus *bus, unsigned port_num); 236extern int usb_bus_start_enum(struct usb_bus *bus, unsigned port_num);