Skip to content

Commit e6679fd

Browse files
djcampelloEnric Balletbo i Serra
authored andcommitted
platform/chrome: wilco_ec: Add debugfs test_event file
This change introduces a new debugfs file 'test_event' that when written to causes the EC to generate a test event. This adds a second sub cmd for the test event, and pulls out send_ec_cmd to be a common helper between h1_gpio_get and test_event_set. Signed-off-by: Daniel Campello <[email protected]> Reviewed-by: Benson Leung <[email protected]> Reviewed-by: Nick Crews <[email protected]> Signed-off-by: Enric Balletbo i Serra <[email protected]>
1 parent 54ecb8f commit e6679fd

File tree

1 file changed

+37
-10
lines changed

1 file changed

+37
-10
lines changed

drivers/platform/chrome/wilco_ec/debugfs.c

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -160,29 +160,29 @@ static const struct file_operations fops_raw = {
160160

161161
#define CMD_KB_CHROME 0x88
162162
#define SUB_CMD_H1_GPIO 0x0A
163+
#define SUB_CMD_TEST_EVENT 0x0B
163164

164-
struct h1_gpio_status_request {
165+
struct ec_request {
165166
u8 cmd; /* Always CMD_KB_CHROME */
166167
u8 reserved;
167-
u8 sub_cmd; /* Always SUB_CMD_H1_GPIO */
168+
u8 sub_cmd;
168169
} __packed;
169170

170-
struct hi_gpio_status_response {
171+
struct ec_response {
171172
u8 status; /* 0 if allowed */
172-
u8 val; /* BIT(0)=ENTRY_TO_FACT_MODE, BIT(1)=SPI_CHROME_SEL */
173+
u8 val;
173174
} __packed;
174175

175-
static int h1_gpio_get(void *arg, u64 *val)
176+
static int send_ec_cmd(struct wilco_ec_device *ec, u8 sub_cmd, u8 *out_val)
176177
{
177-
struct wilco_ec_device *ec = arg;
178-
struct h1_gpio_status_request rq;
179-
struct hi_gpio_status_response rs;
178+
struct ec_request rq;
179+
struct ec_response rs;
180180
struct wilco_ec_message msg;
181181
int ret;
182182

183183
memset(&rq, 0, sizeof(rq));
184184
rq.cmd = CMD_KB_CHROME;
185-
rq.sub_cmd = SUB_CMD_H1_GPIO;
185+
rq.sub_cmd = sub_cmd;
186186

187187
memset(&msg, 0, sizeof(msg));
188188
msg.type = WILCO_EC_MSG_LEGACY;
@@ -196,13 +196,38 @@ static int h1_gpio_get(void *arg, u64 *val)
196196
if (rs.status)
197197
return -EIO;
198198

199-
*val = rs.val;
199+
*out_val = rs.val;
200200

201201
return 0;
202202
}
203203

204+
/**
205+
* h1_gpio_get() - Gets h1 gpio status.
206+
* @arg: The wilco EC device.
207+
* @val: BIT(0)=ENTRY_TO_FACT_MODE, BIT(1)=SPI_CHROME_SEL
208+
*/
209+
static int h1_gpio_get(void *arg, u64 *val)
210+
{
211+
return send_ec_cmd(arg, SUB_CMD_H1_GPIO, (u8 *)val);
212+
}
213+
204214
DEFINE_DEBUGFS_ATTRIBUTE(fops_h1_gpio, h1_gpio_get, NULL, "0x%02llx\n");
205215

216+
/**
217+
* test_event_set() - Sends command to EC to cause an EC test event.
218+
* @arg: The wilco EC device.
219+
* @val: unused.
220+
*/
221+
static int test_event_set(void *arg, u64 val)
222+
{
223+
u8 ret;
224+
225+
return send_ec_cmd(arg, SUB_CMD_TEST_EVENT, &ret);
226+
}
227+
228+
/* Format is unused since it is only required for get method which is NULL */
229+
DEFINE_DEBUGFS_ATTRIBUTE(fops_test_event, NULL, test_event_set, "%llu\n");
230+
206231
/**
207232
* wilco_ec_debugfs_probe() - Create the debugfs node
208233
* @pdev: The platform device, probably created in core.c
@@ -226,6 +251,8 @@ static int wilco_ec_debugfs_probe(struct platform_device *pdev)
226251
debugfs_create_file("raw", 0644, debug_info->dir, NULL, &fops_raw);
227252
debugfs_create_file("h1_gpio", 0444, debug_info->dir, ec,
228253
&fops_h1_gpio);
254+
debugfs_create_file("test_event", 0200, debug_info->dir, ec,
255+
&fops_test_event);
229256

230257
return 0;
231258
}

0 commit comments

Comments
 (0)