diff options
Diffstat (limited to 'include/linux/usb/otg.h')
| -rw-r--r-- | include/linux/usb/otg.h | 44 |
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 */ |
| 13 | enum usb_otg_state { | 15 | enum 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) | 38 | enum 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 | ||
| 43 | struct otg_transceiver; | 46 | struct 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 */ |
| 111 | extern int otg_set_transceiver(struct otg_transceiver *); | 117 | extern 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 */ |
| 114 | extern void usb_nop_xceiv_register(void); | 121 | extern void usb_nop_xceiv_register(void); |
| 115 | extern void usb_nop_xceiv_unregister(void); | 122 | extern void usb_nop_xceiv_unregister(void); |
| 123 | #else | ||
| 124 | static inline void usb_nop_xceiv_register(void) | ||
| 125 | { | ||
| 126 | } | ||
| 127 | |||
| 128 | static 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 */ |
| 118 | static inline int otg_io_read(struct otg_transceiver *otg, u32 reg) | 134 | static 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 | ||
| 126 | static inline int otg_io_write(struct otg_transceiver *otg, u32 reg, u32 val) | 142 | static 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 */ | ||
| 223 | static inline int | ||
| 224 | otg_register_notifier(struct otg_transceiver *otg, struct notifier_block *nb) | ||
| 225 | { | ||
| 226 | return blocking_notifier_chain_register(&otg->notifier, nb); | ||
| 227 | } | ||
| 228 | |||
| 229 | static inline void | ||
| 230 | otg_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) */ |
| 208 | extern int usb_bus_start_enum(struct usb_bus *bus, unsigned port_num); | 236 | extern int usb_bus_start_enum(struct usb_bus *bus, unsigned port_num); |
