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
|
/* Copyright 2022 The ChromiumOS Authors.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
/* Tests for deprecated EC_CMD_HOST_EVENT_* commands */
#include <zephyr/ztest.h>
#include "include/lpc.h"
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
#define HOST_EVENT_TEST_MASK_VAL EC_HOST_EVENT_MASK(EC_HOST_EVENT_LID_OPEN)
static void
host_event_get_wake_mask_helper(struct ec_response_host_event_mask *r)
{
enum ec_status ret_val;
struct host_cmd_handler_args args = BUILD_HOST_COMMAND_RESPONSE(
EC_CMD_HOST_EVENT_GET_WAKE_MASK, 0, *r);
ret_val = host_command_process(&args);
/* EC_CMD_HOST_EVENT_GET_WAKE_MASK always returns success */
zassert_equal(ret_val, EC_RES_SUCCESS, "Expected %d, returned %d",
EC_RES_SUCCESS, ret_val);
}
static void host_event_set_wake_mask_helper(uint32_t mask)
{
enum ec_status ret_val;
struct ec_params_host_event_mask params = { .mask = mask };
struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS(
EC_CMD_HOST_EVENT_SET_WAKE_MASK, 0, params);
ret_val = host_command_process(&args);
/* EC_CMD_HOST_EVENT_SET_WAKE_MASK always returns success */
zassert_equal(ret_val, EC_RES_SUCCESS, "Expected %d, returned %d",
EC_RES_SUCCESS, ret_val);
}
/**
* @brief TestPurpose: Verify EC_CMD_HOST_EVENT_GET_WAKE_MASK host command.
*/
ZTEST_USER(host_cmd_host_event_commands, test_host_event_get_wake_mask)
{
#ifdef CONFIG_HOSTCMD_X86
struct ec_response_host_event_mask result = { 0 };
host_event_get_wake_mask_helper(&result);
#else
ztest_test_skip();
#endif
}
/**
* @brief TestPurpose: Verify EC_CMD_HOST_EVENT_SET_WAKE_MASK host command.
*/
ZTEST_USER(host_cmd_host_event_commands, test_host_event_set_wake_mask)
{
#ifdef CONFIG_HOSTCMD_X86
struct ec_response_host_event_mask result = { 0 };
/* Read the current mask */
host_event_get_wake_mask_helper(&result);
/* Default mask is expected to be clear */
zassert_false(result.mask, "Default host event wake mask is not clear");
host_event_set_wake_mask_helper(HOST_EVENT_TEST_MASK_VAL);
/* Verify the mask changed */
host_event_get_wake_mask_helper(&result);
zassert_equal(result.mask, HOST_EVENT_TEST_MASK_VAL,
"Expected wake mask 0x%08x, returned mask 0x%08x",
HOST_EVENT_TEST_MASK_VAL, result.mask);
/* Clean up the mask */
host_event_set_wake_mask_helper(0);
#else
ztest_test_skip();
#endif
}
static void
host_event_get_smi_mask_helper(struct ec_response_host_event_mask *r)
{
enum ec_status ret_val;
struct host_cmd_handler_args args = BUILD_HOST_COMMAND_RESPONSE(
EC_CMD_HOST_EVENT_GET_SMI_MASK, 0, *r);
ret_val = host_command_process(&args);
/* EC_CMD_HOST_EVENT_GET_SMI_MASK always returns success */
zassert_equal(ret_val, EC_RES_SUCCESS, "Expected %d, returned %d",
EC_RES_SUCCESS, ret_val);
}
static void host_event_set_smi_mask_helper(uint32_t mask)
{
enum ec_status ret_val;
struct ec_params_host_event_mask params = { .mask = mask };
struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS(
EC_CMD_HOST_EVENT_SET_SMI_MASK, 0, params);
ret_val = host_command_process(&args);
/* EC_CMD_HOST_EVENT_SET_SMI_MASK always returns success */
zassert_equal(ret_val, EC_RES_SUCCESS, "Expected %d, returned %d",
EC_RES_SUCCESS, ret_val);
}
/**
* @brief TestPurpose: Verify EC_CMD_HOST_EVENT_GET_SMI_MASK host command.
*/
ZTEST_USER(host_cmd_host_event_commands, test_host_event_get_smi_mask)
{
#ifdef CONFIG_HOSTCMD_X86
struct ec_response_host_event_mask result = { 0 };
host_event_get_smi_mask_helper(&result);
#else
ztest_test_skip();
#endif
}
/**
* @brief TestPurpose: Verify EC_CMD_HOST_EVENT_SET_SMI_MASK host command.
*/
ZTEST_USER(host_cmd_host_event_commands, test_host_event_set_smi_mask)
{
#ifdef CONFIG_HOSTCMD_X86
struct ec_response_host_event_mask result = { 0 };
/* Read the current mask */
host_event_get_smi_mask_helper(&result);
/* Default mask is expected to be clear */
zassert_false(result.mask, "Default host event SMI mask is not clear");
host_event_set_smi_mask_helper(HOST_EVENT_TEST_MASK_VAL);
/* Verify the mask changed */
host_event_get_smi_mask_helper(&result);
zassert_equal(result.mask, HOST_EVENT_TEST_MASK_VAL,
"Expected SMI mask 0x%08x, returned mask 0x%08x",
HOST_EVENT_TEST_MASK_VAL, result.mask);
/* Clean up the mask */
host_event_set_smi_mask_helper(0);
#else
ztest_test_skip();
#endif
}
static void host_event_get_b_helper(struct ec_response_host_event_mask *r)
{
enum ec_status ret_val;
struct host_cmd_handler_args args =
BUILD_HOST_COMMAND_RESPONSE(EC_CMD_HOST_EVENT_GET_B, 0, *r);
ret_val = host_command_process(&args);
/* EC_CMD_HOST_EVENT_GET_B always returns success */
zassert_equal(ret_val, EC_RES_SUCCESS, "Expected %d, returned %d",
EC_RES_SUCCESS, ret_val);
}
/**
* @brief TestPurpose: Verify EC_CMD_HOST_EVENT_GET_B host command.
*/
ZTEST_USER(host_cmd_host_event_commands, test_host_event_get_b)
{
#ifdef CONFIG_HOSTCMD_X86
struct ec_response_host_event_mask result = { 0 };
host_event_get_b_helper(&result);
#else
ztest_test_skip();
#endif
}
static void
host_event_get_sci_mask_helper(struct ec_response_host_event_mask *r)
{
enum ec_status ret_val;
struct host_cmd_handler_args args = BUILD_HOST_COMMAND_RESPONSE(
EC_CMD_HOST_EVENT_GET_SCI_MASK, 0, *r);
ret_val = host_command_process(&args);
/* EC_CMD_HOST_EVENT_GET_SCI_MASK always returns success */
zassert_equal(ret_val, EC_RES_SUCCESS, "Expected %d, returned %d",
EC_RES_SUCCESS, ret_val);
}
static void host_event_set_sci_mask_helper(uint32_t mask)
{
enum ec_status ret_val;
struct ec_params_host_event_mask params = { .mask = mask };
struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS(
EC_CMD_HOST_EVENT_SET_SCI_MASK, 0, params);
ret_val = host_command_process(&args);
/* EC_CMD_HOST_EVENT_SET_SCI_MASK always returns success */
zassert_equal(ret_val, EC_RES_SUCCESS, "Expected %d, returned %d",
EC_RES_SUCCESS, ret_val);
}
/**
* @brief TestPurpose: Verify EC_CMD_HOST_EVENT_GET_SCI_MASK host command.
*/
ZTEST_USER(host_cmd_host_event_commands, test_host_event_get_sci_mask)
{
#ifdef CONFIG_HOSTCMD_X86
struct ec_response_host_event_mask result = { 0 };
host_event_get_sci_mask_helper(&result);
#else
ztest_test_skip();
#endif
}
/**
* @brief TestPurpose: Verify EC_CMD_HOST_EVENT_SET_SCI_MASK host command.
*/
ZTEST_USER(host_cmd_host_event_commands, test_host_event_set_sci_mask)
{
#ifdef CONFIG_HOSTCMD_X86
struct ec_response_host_event_mask result = { 0 };
/* Read the current mask */
host_event_get_sci_mask_helper(&result);
/* Default mask is expected to be clear */
zassert_false(result.mask, "Default host event SCI mask is not clear");
host_event_set_sci_mask_helper(HOST_EVENT_TEST_MASK_VAL);
/* Verify the mask changed */
host_event_get_sci_mask_helper(&result);
zassert_equal(result.mask, HOST_EVENT_TEST_MASK_VAL,
"Expected SCI mask 0x%08x, returned mask 0x%08x",
HOST_EVENT_TEST_MASK_VAL, result.mask);
/* Clean up the mask */
host_event_set_sci_mask_helper(0);
#else
ztest_test_skip();
#endif
}
|