]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/blobdiff - include/linux/usb/otg.h
Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6
[mirror_ubuntu-focal-kernel.git] / include / linux / usb / otg.h
index 52bb917641f050700d7c2ef06f8a28dd367f1631..f8302d036a7674e33109bf8fce16d67325d2d17a 100644 (file)
@@ -9,6 +9,8 @@
 #ifndef __LINUX_USB_OTG_H
 #define __LINUX_USB_OTG_H
 
+#include <linux/notifier.h>
+
 /* OTG defines lots of enumeration states before device reset */
 enum usb_otg_state {
        OTG_STATE_UNDEFINED = 0,
@@ -33,6 +35,14 @@ enum usb_otg_state {
        OTG_STATE_A_VBUS_ERR,
 };
 
+enum usb_xceiv_events {
+       USB_EVENT_NONE,         /* no events or cable disconnected */
+       USB_EVENT_VBUS,         /* vbus valid event */
+       USB_EVENT_ID,           /* id was grounded */
+       USB_EVENT_CHARGER,      /* usb dedicated charger */
+       USB_EVENT_ENUMERATED,   /* gadget driver enumerated */
+};
+
 #define USB_OTG_PULLUP_ID              (1 << 0)
 #define USB_OTG_PULLDOWN_DP            (1 << 1)
 #define USB_OTG_PULLDOWN_DM            (1 << 2)
@@ -70,6 +80,9 @@ struct otg_transceiver {
        struct otg_io_access_ops        *io_ops;
        void __iomem                    *io_priv;
 
+       /* for notification of usb_xceiv_events */
+       struct blocking_notifier_head   notifier;
+
        /* to pass extra port status to the root hub */
        u16                     port_status;
        u16                     port_change;
@@ -110,9 +123,19 @@ struct otg_transceiver {
 /* for board-specific init logic */
 extern int otg_set_transceiver(struct otg_transceiver *);
 
+#if defined(CONFIG_NOP_USB_XCEIV) || defined(CONFIG_NOP_USB_XCEIV_MODULE)
 /* sometimes transceivers are accessed only through e.g. ULPI */
 extern void usb_nop_xceiv_register(void);
 extern void usb_nop_xceiv_unregister(void);
+#else
+static inline void usb_nop_xceiv_register(void)
+{
+}
+
+static inline void usb_nop_xceiv_unregister(void)
+{
+}
+#endif
 
 /* helpers for direct access thru low-level io interface */
 static inline int otg_io_read(struct otg_transceiver *otg, u32 reg)
@@ -203,6 +226,18 @@ otg_start_srp(struct otg_transceiver *otg)
        return otg->start_srp(otg);
 }
 
+/* notifiers */
+static inline int
+otg_register_notifier(struct otg_transceiver *otg, struct notifier_block *nb)
+{
+       return blocking_notifier_chain_register(&otg->notifier, nb);
+}
+
+static inline void
+otg_unregister_notifier(struct otg_transceiver *otg, struct notifier_block *nb)
+{
+       blocking_notifier_chain_unregister(&otg->notifier, nb);
+}
 
 /* for OTG controller drivers (and maybe other stuff) */
 extern int usb_bus_start_enum(struct usb_bus *bus, unsigned port_num);