1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
|
#ifndef _CABLE_DETECT_H_
#define _CABLE_DETECT_H_
//#include <mach/board.h>
#define DOCK_STATE_UNDEFINED -1
#define DOCK_STATE_UNDOCKED 0
#define DOCK_STATE_DESK (1 << 0)
#define DOCK_STATE_CAR (1 << 1)
#define DOCK_STATE_USB_HEADSET (1 << 2)
#define DOCK_STATE_MHL (1 << 3)
#define DOCK_STATE_USB_HOST (1 << 4)
#define DOCK_STATE_DMB (1 << 5)
#define DOCK_STATE_AUDIO_DOCK (1 << 6)
#define DOCK_STATE_THREE_POGO_DOCK (1 << 7)
#define DOCK_DET_DELAY HZ/4
#ifdef CONFIG_MACH_TC2
__maybe_unused static int htc_cable_detect_retry_times = 5;
#define ADC_RETRY htc_cable_detect_retry_times
#else
__maybe_unused static int htc_cable_detect_retry_times = 3;
#define ADC_RETRY htc_cable_detect_retry_times
#endif
#define ADC_DELAY HZ/8
#define PM8058ADC_15BIT(adc) ((adc * 2200) / 32767) /* vref=2.2v, 15-bits resolution */
#define CABLE_ERR(fmt, args...) \
printk(KERN_ERR "[CABLE:ERR] " fmt, ## args)
#define CABLE_WARNING(fmt, args...) \
printk(KERN_WARNING "[CABLE] " fmt, ## args)
#define CABLE_INFO(fmt, args...) \
printk(KERN_INFO "[CABLE] " fmt, ## args)
#define CABLE_DEBUG(fmt, args...) \
printk(KERN_DEBUG "[CABLE] " fmt, ## args)
enum accessory_type {
CABLE_TYPE_UNKOWN = 0,
CABLE_TYPE_ID_PIN,
CABLE_TYPE_PMIC_ADC,
};
enum usb_id_pin_type {
CABLE_TYPE_APP_GPIO = 0,
CABLE_TYPE_PMIC_GPIO,
};
enum dpdn_path_type {
PATH_USB = 0,
PATH_MHL,
PATH_USB_AUD,
PATH_UART,
};
/*++ 2014/12/19 USB Team, PCN00060 ++*/
enum usb_host_mhl_type {
CABLE_TYPE_NONE = 0,
CABLE_TYPE_HOST,
CABLE_TYPE_MHL,
};
/*-- 2014/12/19 USB Team, PCN00060 --*/
#if 0
static struct switch_dev dock_switch = {
.name = "dock",
};
#endif
struct usb_id_mpp_config_data {
u32 usbid_mpp;
u32 usbid_amux;
};
#ifdef CONFIG_HTC_MHL_DETECTION_8620
/***********************************
Direction: sii9234 drvier -> cable detect driver
***********************************/
struct t_mhl_status_notifier{
struct list_head mhl_notifier_link;
const char *name;
void (*func)(int charging_type);
};
int mhl_detect_register_notifier(struct t_mhl_status_notifier *);
static LIST_HEAD(g_lh_mhl_detect_notifier_list);
#endif
struct cable_detect_platform_data {
int vbus_mpp_gpio;
int vbus_mpp_irq;
void (*vbus_mpp_config)(void);
/* 1 : uart, 0 : usb */
void (*usb_uart_switch)(int);
void (*usb_dpdn_switch)(int);
int ad_en_active_state;
int ad_en_gpio;
int ad_en_irq;
/* for accessory detection */
u8 accessory_type;
u8 mfg_usb_carkit_enable;
int usb_id_pin_type;
int usb_id_pin_gpio;
__u8 detect_type;
#ifdef CONFIG_HTC_MHL_DETECTION_8620
void (*switch_to_d3)(void);
void (*mhl_disable_irq)(void);
void (*mhl_wakeup)(void);
int (*mhl_detect_register_notifier)(struct t_mhl_status_notifier *notifier);
#endif
u8 mhl_reset_gpio;
bool mhl_version_ctrl_flag;
struct usb_id_mpp_config_data mpp_data;
void (*config_usb_id_gpios)(bool enable);
void (*mhl_1v2_power)(bool enable);
int (*is_wireless_charger)(void);
int64_t (*get_adc_cb)(void);
int ac_9v_gpio;
void (*configure_ac_9v_gpio) (int);
u8 mhl_internal_3v3;
#ifdef CONFIG_CABLE_DETECT_GPIO_DOCK
bool dock_detect;
int dock_pin_gpio;
#endif
int idpin_irq;
int carkit_only;
int (*detect_three_pogo_dock)(void);
int enable_vbus_usb_switch;
int (*is_pwr_src_plugged_in)(void);
int vbus_debounce_retry;
};
/* -----------------------------------------------------------------------------
» » » External routine declaration
-----------------------------------------------------------------------------*/
#ifdef CONFIG_FB_MSM_MDSS_HDMI_MHL_SII9234
extern void sii9234_mhl_device_wakeup(void);
#endif
extern int cable_get_connect_type(void);
extern void set_mfg_usb_carkit_enable(int enable);
extern int cable_get_accessory_type(void);
extern int cable_get_usb_id_level(void);
extern void cable_set_uart_switch(int);
extern irqreturn_t cable_detection_vbus_irq_handler(void);
extern int check_three_pogo_dock(void);
#endif
void msm_hsusb_set_vbus_state(int online);
void msm_otg_set_vbus_state(int online);
void htc_dwc3_msm_otg_set_vbus_state(int online);
#if 0
enum usb_connect_type {
CONNECT_TYPE_NOTIFY = -3,
CONNECT_TYPE_CLEAR = -2,
CONNECT_TYPE_UNKNOWN = -1,
CONNECT_TYPE_NONE = 0,
CONNECT_TYPE_USB,
CONNECT_TYPE_AC,
CONNECT_TYPE_9V_AC,
CONNECT_TYPE_WIRELESS,
CONNECT_TYPE_INTERNAL,
CONNECT_TYPE_UNSUPPORTED,
#ifdef CONFIG_MACH_VERDI_LTE
/* Y cable with USB and 9V charger */
CONNECT_TYPE_USB_9V_AC,
#endif
CONNECT_TYPE_MHL_AC,
};
/* START: add USB connected notify function */
struct t_usb_status_notifier{
struct list_head notifier_link;
const char *name;
void (*func)(int cable_type);
};
int htc_usb_register_notifier(struct t_usb_status_notifier *notifer);
int64_t htc_qpnp_adc_get_usbid_adc(void);
int usb_get_connect_type(void);
static LIST_HEAD(g_lh_usb_notifier_list);
/***********************************
Direction: cable detect drvier -> battery driver or other
***********************************/
struct t_cable_status_notifier{
struct list_head cable_notifier_link;
const char *name;
void (*func)(int cable_type);
};
int cable_detect_register_notifier(struct t_cable_status_notifier *);
static LIST_HEAD(g_lh_calbe_detect_notifier_list);
#endif
#ifdef CONFIG_HTC_MHL_DETECTION
/***********************************
Direction: sii9234 drvier -> cable detect driver
***********************************/
struct t_mhl_status_notifier{
struct list_head mhl_notifier_link;
const char *name;
void (*func)(bool isMHL, int charging_type);
};
int mhl_detect_register_notifier(struct t_mhl_status_notifier *);
static LIST_HEAD(g_lh_mhl_detect_notifier_list);
#endif
/***********************************
Direction: cable detect drvier -> usb driver
***********************************/
/*++ 2014/12/19 USB Team, PCN00060 ++*/
struct t_usb_host_mhl_status_notifier{
struct list_head usb_host_mhl_notifier_link;
const char *name;
void (*func)(enum usb_host_mhl_type);
};
int usb_host_mhl_detect_register_notifier(struct t_usb_host_mhl_status_notifier *);
static LIST_HEAD(g_lh_usb_host_mhl_detect_notifier_list);
/*-- 2014/12/19 USB Team, PCN00060 --*/
|