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
|
/*
* include/linux/ifconn/ifconn_manager.h
*
* header file supporting CCIC notifier call chain information
*
* Copyright (C) 2010 Samsung Electronics
* Sejong Park <sejong.park@samsung.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef __IFCONN_MANAGER_H__
#define __IFCONN_MANAGER_H__
typedef enum {
/* MUIC */
IFCONN_CABLE_TYPE_MUIC_NONE = 0,
IFCONN_CABLE_TYPE_MUIC_DOCK,
IFCONN_CABLE_TYPE_MUIC_MHL,
IFCONN_CABLE_TYPE_MUIC_USB,
IFCONN_CABLE_TYPE_MUIC_TSP,
IFCONN_CABLE_TYPE_MUIC_CHARGER,
IFCONN_CABLE_TYPE_MUIC_CPUIDLE,
IFCONN_CABLE_TYPE_MUIC_CPUFREQ,
IFCONN_CABLE_TYPE_MUIC_TIMEOUT_OPEN_DEVICE,
/* CCIC */
IFCONN_CABLE_TYPE_CCIC_INITIAL = 20,
IFCONN_CABLE_TYPE_CCIC_MUIC,
IFCONN_CABLE_TYPE_CCIC_USB,
IFCONN_CABLE_TYPE_CCIC_BATTERY,
IFCONN_CABLE_TYPE_CCIC_DP,
IFCONN_CABLE_TYPE_CCIC_USBDP,
IFCONN_CABLE_TYPE_CCIC_SENSORHUB,
/* VBUS */
IFCONN_CABLE_TYPE_VBUS_USB = 30,
IFCONN_CABLE_TYPE_VBUS_CHARGER,
} ifconn_cable_type_t;
typedef enum {
IFCONN_PD_USB_TYPE,
IFCONN_PD_TA_TYPE,
} ifconn_pd_usb_state_t;
typedef enum {
IFCONN_MANAGER_USB_STATUS_DETACH = 0,
IFCONN_MANAGER_USB_STATUS_ATTACH_DFP = 1, /* Host */
IFCONN_MANAGER_USB_STATUS_ATTACH_UFP = 2, /* Device */
IFCONN_MANAGER_USB_STATUS_ATTACH_DRP = 3, /* Dual role */
IFCONN_MANAGER_USB_STATUS_ATTACH_HPD = 4, /* DP : Hot Plugged Detect */
} ifconn_manager_usb_status_t;
typedef enum {
IFCONN_MANAGER_VBUS_STATUS_UNKNOWN = 0,
IFCONN_MANAGER_VBUS_STATUS_LOW,
IFCONN_MANAGER_VBUS_STATUS_HIGH,
} ifconn_manager_vbus_status_t;
typedef enum {
IFCONN_MANAGER_RID_UNDEFINED = 0,
IFCONN_MANAGER_RID_000K,
IFCONN_MANAGER_RID_001K,
IFCONN_MANAGER_RID_255K,
IFCONN_MANAGER_RID_301K,
IFCONN_MANAGER_RID_523K,
IFCONN_MANAGER_RID_619K,
IFCONN_MANAGER_RID_OPEN,
} ifconn_manager_rid_t;
struct ifconn_manager_platform_data {
void (*initial_check)(void);
void (*select_pdo)(int);
const char *usbpd_name;
const char *muic_name;
};
#define IFCONN_SEND_NOTI(dest, id, event, data) \
{ \
int ret; \
ret = ifconn_notifier_notify( \
IFCONN_NOTIFY_MANAGER, \
IFCONN_NOTIFY_##dest, \
IFCONN_NOTIFY_ID_##id, \
IFCONN_NOTIFY_EVENT_##event, \
IFCONN_NOTIFY_PARAM_DATA, \
data); \
if (ret < 0) { \
pr_err("%s: Fail to send noti : "#dest" "#id"\n", \
__func__); \
} \
}
#define IFCONN_SEND_TEMPLATE_NOTI(data) \
{ \
int ret; \
struct ifconn_notifier_template *template \
= (struct ifconn_notifier_template *)data; \
ret = ifconn_notifier_notify( \
template->src, \
template->dest, \
template->id, \
template->event, \
IFCONN_NOTIFY_PARAM_TEMPLATE, \
&template); \
if (ret < 0) { \
pr_err("%s: Fail to send noti\n", \
__func__); \
} \
}
#define IFCONN_SEND_TEMPLATE_UP_NOTI(nd) \
{ \
int ret; \
struct ifconn_notifier_template *template \
= (struct ifconn_notifier_template *)nd; \
pr_info("%s: dbg, line : %d\n", __func__, __LINE__);\
ret = ifconn_notifier_notify( \
template->src, \
template->dest, \
template->id, \
template->event, \
IFCONN_NOTIFY_PARAM_TEMPLATE, \
nd); \
if (ret < 0) { \
pr_err("%s: Fail to send noti\n", \
__func__); \
} \
}
struct ifconn_manager_template {
struct ifconn_notifier_template node;
void *rp;
void *np;
};
struct ifconn_manager_data {
struct ifconn_manager_platform_data *pdata;
struct notifier_block nb;
struct ifconn_notifier_template *template;
struct ifconn_manager_template *hp;
struct ifconn_manager_template *tp;
int template_cnt;
struct device *dev;
struct mutex noti_mutex;
struct mutex workqueue_mutex;
struct mutex enqueue_mutex;
struct work_struct noti_work;
int muic_action;
int muic_cable_type;
int muic_data_refresh;
int muic_attach_state_without_ccic;
#if defined(CONFIG_VBUS_NOTIFIER)
int muic_fake_event_wq_processing;
#endif
int vbus_state;
/* USB_STATUS_NOTIFY_DETACH, UFP, DFP, DRP, NO_USB */
int ccic_attach_state;
int ccic_drp_state;
int ccic_rid_state;
int cable_type;
int usb_enum_state;
bool usb_enable_state;
int pd_con_state;
int water_det;
int is_UFPS;
void *pd;
int water_count;
int dry_count;
int usb210_count;
int usb310_count;
int waterChg_count;
unsigned long waterDet_duration;
unsigned long waterDet_time;
unsigned long dryDet_time;
int dp_attach_state;
int dp_cable_type;
int dp_hpd_state;
int dp_is_connect;
int dp_hs_connect;
int dp_check_done;
};
extern void _ifconn_show_attr(struct ifconn_notifier_template *t);
#endif /* __IFCONN_MANAGER_H__ */
|