blob: 5a36a4f90964cce06167f2d3d661e5703219137d [file] [log] [blame]
Ido Shayevitzcdeef4c2012-05-29 13:17:41 +02001/**
2 * dwc3_otg.h - DesignWare USB3 DRD Controller OTG
3 *
4 * Copyright (c) 2012, Code Aurora Forum. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 and
8 * only version 2 as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#ifndef __LINUX_USB_DWC3_OTG_H
17#define __LINUX_USB_DWC3_OTG_H
18
19#include <linux/workqueue.h>
Vijayavardhan Vennapusa42eeea32012-10-22 17:56:11 +053020#include <linux/power_supply.h>
Ido Shayevitzcdeef4c2012-05-29 13:17:41 +020021
22#include <linux/usb/otg.h>
23
Vijayavardhan Vennapusa42eeea32012-10-22 17:56:11 +053024#define DWC3_IDEV_CHG_MAX 1500
25
Manu Gautam8c642812012-06-07 10:35:10 +053026struct dwc3_charger;
27
Ido Shayevitzcdeef4c2012-05-29 13:17:41 +020028/**
29 * struct dwc3_otg: OTG driver data. Shared by HCD and DCD.
30 * @otg: USB OTG Transceiver structure.
31 * @irq: IRQ number assigned for HSUSB controller.
32 * @regs: ioremapped register base address.
33 * @sm_work: OTG state machine work.
Manu Gautam8c642812012-06-07 10:35:10 +053034 * @charger: DWC3 external charger detector
35 * @inputs: OTG state machine inputs
Ido Shayevitzcdeef4c2012-05-29 13:17:41 +020036 */
37struct dwc3_otg {
Manu Gautamf1fceddf2012-10-12 14:02:50 +053038 struct usb_otg otg;
39 int irq;
40 struct dwc3 *dwc;
41 void __iomem *regs;
42 struct regulator *vbus_otg;
Manu Gautamb5067272012-07-02 09:53:41 +053043 struct work_struct sm_work;
44 struct dwc3_charger *charger;
45 struct dwc3_ext_xceiv *ext_xceiv;
Manu Gautam8c642812012-06-07 10:35:10 +053046#define ID 0
47#define B_SESS_VLD 1
48 unsigned long inputs;
Vijayavardhan Vennapusa42eeea32012-10-22 17:56:11 +053049 struct power_supply *psy;
50 struct completion dwc3_xcvr_vbus_init;
Ido Shayevitzcdeef4c2012-05-29 13:17:41 +020051};
Manu Gautam8c642812012-06-07 10:35:10 +053052
53/**
54 * USB charger types
55 *
56 * DWC3_INVALID_CHARGER Invalid USB charger.
57 * DWC3_SDP_CHARGER Standard downstream port. Refers to a downstream port
58 * on USB compliant host/hub.
59 * DWC3_DCP_CHARGER Dedicated charger port (AC charger/ Wall charger).
60 * DWC3_CDP_CHARGER Charging downstream port. Enumeration can happen and
61 * IDEV_CHG_MAX can be drawn irrespective of USB state.
62 */
63enum dwc3_chg_type {
64 DWC3_INVALID_CHARGER = 0,
65 DWC3_SDP_CHARGER,
66 DWC3_DCP_CHARGER,
67 DWC3_CDP_CHARGER,
68};
69
70struct dwc3_charger {
71 enum dwc3_chg_type chg_type;
Vijayavardhan Vennapusa42eeea32012-10-22 17:56:11 +053072 unsigned max_power;
Manu Gautam6c0ff032012-11-02 14:55:35 +053073 bool charging_disabled;
Manu Gautam8c642812012-06-07 10:35:10 +053074
75 /* start/stop charger detection, provided by external charger module */
76 void (*start_detection)(struct dwc3_charger *charger, bool start);
77
78 /* to notify OTG about charger detection completion, provided by OTG */
79 void (*notify_detection_complete)(struct usb_otg *otg,
80 struct dwc3_charger *charger);
81};
82
83/* for external charger driver */
84extern int dwc3_set_charger(struct usb_otg *otg, struct dwc3_charger *charger);
85
Manu Gautamb5067272012-07-02 09:53:41 +053086enum dwc3_ext_events {
87 DWC3_EVENT_NONE = 0, /* no change event */
88 DWC3_EVENT_PHY_RESUME, /* PHY has come out of LPM */
89 DWC3_EVENT_XCEIV_STATE, /* XCEIV state (id/bsv) has changed */
90};
91
92enum dwc3_id_state {
93 DWC3_ID_GROUND = 0,
94 DWC3_ID_FLOAT,
95};
96
97/* external transceiver that can perform connect/disconnect monitoring in LPM */
98struct dwc3_ext_xceiv {
99 enum dwc3_id_state id;
100 bool bsv;
Vijayavardhan Vennapusad2993b82012-10-22 13:08:21 +0530101 bool otg_capability;
Manu Gautamb5067272012-07-02 09:53:41 +0530102
103 /* to notify OTG about LPM exit event, provided by OTG */
104 void (*notify_ext_events)(struct usb_otg *otg,
105 enum dwc3_ext_events ext_event);
Vijayavardhan Vennapusab7434562012-12-12 16:48:49 +0530106 /* for block reset USB core */
107 void (*ext_block_reset)(void);
Manu Gautamb5067272012-07-02 09:53:41 +0530108};
109
110/* for external transceiver driver */
111extern int dwc3_set_ext_xceiv(struct usb_otg *otg,
112 struct dwc3_ext_xceiv *ext_xceiv);
113
Ido Shayevitzcdeef4c2012-05-29 13:17:41 +0200114#endif /* __LINUX_USB_DWC3_OTG_H */