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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
|
/* Copyright 2019 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*
* Test USB Type-C module.
*/
#include "common.h"
#include "usb_tc_sm.h"
#include "usb_pd.h"
__overridable int pd_is_vbus_present(int port)
{
return 0;
}
__overridable void pd_request_data_swap(int port)
{}
__overridable void pd_request_power_swap(int port)
{}
void pd_request_vconn_swap_off(int port)
{}
void pd_request_vconn_swap_on(int port)
{}
static enum pd_data_role data_role;
__overridable enum pd_data_role pd_get_data_role(int port)
{
return data_role;
}
__overridable void tc_set_data_role(int port, enum pd_data_role role)
{
data_role = role;
}
static enum pd_power_role power_role;
__overridable enum pd_power_role pd_get_power_role(int port)
{
return power_role;
}
__overridable void tc_set_power_role(int port, enum pd_power_role role)
{
power_role = role;
}
__overridable bool pd_get_partner_usb_comm_capable(int port)
{
return true;
}
__overridable enum pd_cable_plug tc_get_cable_plug(int port)
{
return PD_PLUG_FROM_DFP_UFP;
}
int tc_check_vconn_swap(int port)
{
return 0;
}
void tc_ctvpd_detected(int port)
{}
void tc_disc_ident_complete(int port)
{}
static int attached_snk;
int tc_is_attached_snk(int port)
{
return attached_snk;
}
static int attached_src;
int tc_is_attached_src(int port)
{
return attached_src;
}
int tc_is_vconn_src(int port)
{
return 0;
}
void tc_hard_reset_request(int port)
{}
void tc_hard_reset_complete(int port)
{}
void tc_partner_dr_data(int port, int en)
{}
void tc_partner_dr_power(int port, int en)
{}
void tc_partner_unconstrainedpower(int port, int en)
{}
void tc_partner_usb_comm(int port, int en)
{}
void tc_pd_connection(int port, int en)
{}
void tc_pr_swap_complete(int port, bool success)
{}
void tc_prs_snk_src_assert_rp(int port)
{
attached_snk = 0;
attached_src = 1;
}
void tc_prs_src_snk_assert_rd(int port)
{
attached_snk = 1;
attached_src = 0;
}
void tc_src_power_off(int port)
{}
void tc_set_timeout(int port, uint64_t timeout)
{}
__overridable void tc_start_error_recovery(int port)
{}
__overridable void tc_snk_power_off(int port)
{}
__overridable void pe_invalidate_explicit_contract(int port)
{
}
__overridable enum pd_dual_role_states pd_get_dual_role(int port)
{
return PD_DRP_TOGGLE_ON;
}
__overridable void pd_dev_get_rw_hash(int port, uint16_t *dev_id,
uint8_t *rw_hash, uint32_t *current_image)
{
}
__overridable int pd_comm_is_enabled(int port)
{
return 0;
}
bool pd_get_partner_data_swap_capable(int port)
{
return true;
}
bool pd_capable(int port)
{
return true;
}
#ifndef CONFIG_TEST_USB_PE_SM
enum idh_ptype get_usb_pd_mux_cable_type(int port)
{
return IDH_PTYPE_UNDEF;
}
const uint32_t * const pd_get_src_caps(int port)
{
return NULL;
}
void pd_set_src_caps(int port, int cnt, uint32_t *src_caps)
{
}
uint8_t pd_get_src_cap_cnt(int port)
{
return 0;
}
#endif
#if !defined(CONFIG_USB_DRP_ACC_TRYSRC) && \
!defined(CONFIG_USB_CTVPD)
int pd_is_connected(int port)
{
return true;
}
bool pd_is_disconnected(int port)
{
return false;
}
#endif /* !CONFIG_USB_DRP_ACC_TRYSRC && !CONFIG_USB_CTVPD */
#ifndef CONFIG_USB_DRP_ACC_TRYSRC
__overridable void pd_set_dual_role(int port, enum pd_dual_role_states state)
{
}
__overridable enum tcpc_cc_polarity pd_get_polarity(int port)
{
return POLARITY_CC1;
}
bool pd_get_vconn_state(int port)
{
return false;
}
bool pd_get_partner_dual_role_power(int port)
{
return false;
}
uint8_t pd_get_task_state(int port)
{
return 0;
}
enum pd_cc_states pd_get_task_cc_state(int port)
{
return PD_CC_NONE;
}
bool pd_get_partner_unconstr_power(int port)
{
return 0;
}
const char *pd_get_task_state_name(int port)
{
return NULL;
}
#endif /* CONFIG_USB_DRP_ACC_TRYSRC */
void dp_init(int port)
{
}
void dp_vdm_acked(int port, int cmd)
{
}
void dpm_init(int port)
{
}
void dpm_vdm_acked(int port, enum tcpm_transmit_type type, int vdo_count,
uint32_t *vdm)
{
}
void dpm_vdm_naked(int port, enum tcpm_transmit_type type, uint16_t svid,
uint8_t vdm_cmd)
{
}
void dpm_set_mode_entry_done(int port)
{
}
void dpm_set_mode_exit_request(int port)
{
}
void dpm_run(int port)
{
}
static enum tcpc_rp_value lcl_rp;
__overridable void typec_select_src_current_limit_rp(int port,
enum tcpc_rp_value rp)
{
lcl_rp = rp;
}
__overridable void typec_select_src_collision_rp(int port,
enum tcpc_rp_value rp)
{
lcl_rp = rp;
}
__overridable int typec_update_cc(int port)
{
return EC_SUCCESS;
}
|