usb: dwc3-msm: Add support for charger detection
DWC3 OTG driver can detect charger detection using DWC3 core or
external charger detection circuitry. Add support for external
charger detector in DWC3 OTG driver for MSM platform. This module
detects DCD and SDP/CDP/DCP type of chargers.
Change-Id: I5d1aec183fbcdc9b03aac74d626a4c39c56ed3b7
Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
diff --git a/drivers/usb/dwc3/dwc3_otg.h b/drivers/usb/dwc3/dwc3_otg.h
index a048306..0d8b61b 100644
--- a/drivers/usb/dwc3/dwc3_otg.h
+++ b/drivers/usb/dwc3/dwc3_otg.h
@@ -20,19 +20,57 @@
#include <linux/usb/otg.h>
+struct dwc3_charger;
+
/**
* struct dwc3_otg: OTG driver data. Shared by HCD and DCD.
* @otg: USB OTG Transceiver structure.
* @irq: IRQ number assigned for HSUSB controller.
* @regs: ioremapped register base address.
* @sm_work: OTG state machine work.
- * @osts: last value of the OSTS register, as read from HW.
+ * @charger: DWC3 external charger detector
+ * @inputs: OTG state machine inputs
*/
struct dwc3_otg {
struct usb_otg otg;
int irq;
void __iomem *regs;
struct work_struct sm_work;
- u32 osts;
+ struct dwc3_charger *charger;
+#define ID 0
+#define B_SESS_VLD 1
+ unsigned long inputs;
};
+
+/**
+ * USB charger types
+ *
+ * DWC3_INVALID_CHARGER Invalid USB charger.
+ * DWC3_SDP_CHARGER Standard downstream port. Refers to a downstream port
+ * on USB compliant host/hub.
+ * DWC3_DCP_CHARGER Dedicated charger port (AC charger/ Wall charger).
+ * DWC3_CDP_CHARGER Charging downstream port. Enumeration can happen and
+ * IDEV_CHG_MAX can be drawn irrespective of USB state.
+ */
+enum dwc3_chg_type {
+ DWC3_INVALID_CHARGER = 0,
+ DWC3_SDP_CHARGER,
+ DWC3_DCP_CHARGER,
+ DWC3_CDP_CHARGER,
+};
+
+struct dwc3_charger {
+ enum dwc3_chg_type chg_type;
+
+ /* start/stop charger detection, provided by external charger module */
+ void (*start_detection)(struct dwc3_charger *charger, bool start);
+
+ /* to notify OTG about charger detection completion, provided by OTG */
+ void (*notify_detection_complete)(struct usb_otg *otg,
+ struct dwc3_charger *charger);
+};
+
+/* for external charger driver */
+extern int dwc3_set_charger(struct usb_otg *otg, struct dwc3_charger *charger);
+
#endif /* __LINUX_USB_DWC3_OTG_H */