[PATCH v2 01/25] usb: otg: add unified otg_notify function for usb_otg_event notification

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch adds a unified otg_notify function to otg_transceiver data
structure. It is used for USB host/peripheral to notify otg related event
to otg_transceiver.

Signed-off-by: Hao Wu <hao.wu@xxxxxxxxx>
---
 include/linux/usb/otg.h |   42 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 42 insertions(+), 0 deletions(-)

diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h
index 0a5b371..97292ab 100644
--- a/include/linux/usb/otg.h
+++ b/include/linux/usb/otg.h
@@ -35,6 +35,29 @@ enum usb_otg_state {
 	OTG_STATE_A_VBUS_ERR,
 };
 
+enum usb_otg_events {
+	/* according to OTG Spec */
+	USB_OTG_CONNECT,	/* a_conn/b_conn */
+	USB_OTG_DISCON,
+	USB_OTG_HOST_SUSP,	/* bus request */
+	USB_OTG_HOST_RESU,
+	USB_OTG_DEV_SUSP,	/* bus suspend/resume event */
+	USB_OTG_DEV_RESU,
+
+	/* others */
+	USB_OTG_HOST_ACTIVE,	/* host driver added/active */
+	USB_OTG_HOST_STOP,	/* host driver removed/stopped */
+	USB_OTG_DEV_ACTIVE,	/* udc driver added/active */
+	USB_OTG_DEV_STOP,	/* udc driver removed/stopped */
+
+	/* Battery charging Spec 1.1, requires different charging
+	 * current in FullSpeed mode/HighSpeed mode with CDP, in
+	 * such case, transceiver needs these events to update the
+	 * current limitation */
+	USB_OTG_DEV_FS,		/* enter FS */
+	USB_OTG_DEV_HS,		/* enter HS */
+};
+
 enum usb_xceiv_events {
 	USB_EVENT_NONE,         /* no events or cable disconnected */
 	USB_EVENT_VBUS,         /* vbus valid event */
@@ -110,6 +133,9 @@ struct otg_transceiver {
 	/* start or continue HNP role switch */
 	int	(*start_hnp)(struct otg_transceiver *otg);
 
+	/* OTG events notifications to transceiver */
+	int	(*otg_notify)(struct otg_transceiver *otg,
+				enum usb_otg_events);
 };
 
 
@@ -230,6 +256,22 @@ otg_start_srp(struct otg_transceiver *otg)
 	return otg->start_srp(otg);
 }
 
+static inline int
+otg_notify_event(enum usb_otg_events event)
+{
+	struct otg_transceiver	*otg;
+	int			retval = 0;
+
+	otg = otg_get_transceiver();
+
+	if (otg && otg->otg_notify)
+		retval = otg->otg_notify(otg, event);
+
+	otg_put_transceiver(otg);
+
+	return retval;
+}
+
 /* notifiers */
 static inline int
 otg_register_notifier(struct otg_transceiver *otg, struct notifier_block *nb)
-- 
1.6.0.6

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux