Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp8561452ybn; Tue, 1 Oct 2019 09:50:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqyHBmSaODfHGkxoQ+l/xgRp+KHLy86xiUxi/yxpIFAL6mYrgNStMIH9t7fcC7+RBKqwQ5w5 X-Received: by 2002:a50:c209:: with SMTP id n9mr26497133edf.215.1569948618919; Tue, 01 Oct 2019 09:50:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569948618; cv=none; d=google.com; s=arc-20160816; b=xzlFVTkpVExSZWn8pl8/Z54erI/TpfEIpo6V+1mKAlrq05m+ThVuD0uJVcOuYp8AN3 4fHe7oIStYLwmZ87XvD7YnI5zl1o0GiC9DAY2Tz9XxasaUMQpqwBlljjQslG+1xNvDJ9 CbStoOer9tKtufhpw1odFdFnQuN/SKGqkJVAmjnRHkLG3bvwvwSnAvfNzZZIC/FmtFyO JPuXI0iKU+/AGBHmo/KoqfHMKAu0FhMg3vcDjmGO00xN+1EI0WDJHOZCpNdmESrl/tTW gUem/bstBbbI6INT93SQ9sv7qjEdDjAzyE61vzg81pySPe/WcYz7vOWjIV65Yt8MnJQu j0tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=/sAvEhVXJ6wm/xCoqA/ZmDyzbkGdWiWTPdgTaOzzcDc=; b=j9p+krLlDdSaE+nibsOJZb18+6f9iFKbWhuPyxLR1EFU9h1hYQatZvfhpUIYuX6dxj GHGKC6EyFp5w3r7qGBBTnJUlwdvbivVH/QXJSfa3llLo5Xl/oGRwY1uEqEwkXBh8wbAc yomiX54tPm69Al1Xhs9IcsVSh5Qy0DDkdp9uV0692HGJwcJiCCoJla9nslTH4QUmaQF3 eKqzSaizMPlWi7zXeolM9cAv9U3VR3BS9LF2TWDpd2uE9DdZb+tEoT6TU7NFInD2NPJR rQuxFoHFPc5hbUiBcD8JetGcgHUyJDSkYPIG45QZOeZS7eQuttx9Pi3dE1fATt4gc0v+ IgJQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gz26si9370331ejb.65.2019.10.01.09.49.53; Tue, 01 Oct 2019 09:50:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730084AbfJAQGk (ORCPT + 99 others); Tue, 1 Oct 2019 12:06:40 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:42954 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729418AbfJAQGk (ORCPT ); Tue, 1 Oct 2019 12:06:40 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: eballetbo) with ESMTPSA id 6CC9128B56C Subject: Re: [PATCH v5] platform/chrome: wilco_ec: Add debugfs test_event file To: Benson Leung , Daniel Campello Cc: LKML , Benson Leung , Alexandre Belloni , Duncan Laurie , Nick Crews References: <20190924203716.209420-1-campello@chromium.org> <20190924213613.GB210752@google.com> From: Enric Balletbo i Serra Message-ID: <0097a619-439d-6257-7b4a-301b23ba046b@collabora.com> Date: Tue, 1 Oct 2019 18:06:35 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <20190924213613.GB210752@google.com> Content-Type: text/plain; charset=windows-1252 Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 24/9/19 23:36, Benson Leung wrote: > Hi Daniel, > > On Tue, Sep 24, 2019 at 02:37:16PM -0600, Daniel Campello wrote: >> 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 > > LGTM. > Reviewed-by: Benson Leung > > Merge window is open right now for v5.4, so we can't quite merge this change > for chrome-platform-5.5 yet. > > Enric, can you queue this for the next branch if you have no objections? > Queued for the autobuilders to play with. If all goes well will appear in chrome-platform-5.5 and linux-next in 24/48h Thanks, Enric > Thanks, > Benson > >> --- >> Changes for v2: >> - Cleaned up and added comments. >> - Renamed and updated function signature from write_to_mailbox to >> send_ec_cmd. >> Changes for v3: >> - Switched NULL format string to empty format string >> - Renamed val parameter on send_ec_cmd to out_val >> Changes for v4: >> - Provided a format string to avoid -Wformat-zero-length warning >> Changes for v5: >> - Updated commit message to include more implementation details >> - Restored removed empty line between functions >> >> drivers/platform/chrome/wilco_ec/debugfs.c | 47 +++++++++++++++++----- >> 1 file changed, 37 insertions(+), 10 deletions(-) >> >> diff --git a/drivers/platform/chrome/wilco_ec/debugfs.c b/drivers/platform/chrome/wilco_ec/debugfs.c >> index 8d65a1e2f1a3..df5a5f6c3ec6 100644 >> --- a/drivers/platform/chrome/wilco_ec/debugfs.c >> +++ b/drivers/platform/chrome/wilco_ec/debugfs.c >> @@ -160,29 +160,29 @@ static const struct file_operations fops_raw = { >> >> #define CMD_KB_CHROME 0x88 >> #define SUB_CMD_H1_GPIO 0x0A >> +#define SUB_CMD_TEST_EVENT 0x0B >> >> -struct h1_gpio_status_request { >> +struct ec_request { >> u8 cmd; /* Always CMD_KB_CHROME */ >> u8 reserved; >> - u8 sub_cmd; /* Always SUB_CMD_H1_GPIO */ >> + u8 sub_cmd; >> } __packed; >> >> -struct hi_gpio_status_response { >> +struct ec_response { >> u8 status; /* 0 if allowed */ >> - u8 val; /* BIT(0)=ENTRY_TO_FACT_MODE, BIT(1)=SPI_CHROME_SEL */ >> + u8 val; >> } __packed; >> >> -static int h1_gpio_get(void *arg, u64 *val) >> +static int send_ec_cmd(struct wilco_ec_device *ec, u8 sub_cmd, u8 *out_val) >> { >> - struct wilco_ec_device *ec = arg; >> - struct h1_gpio_status_request rq; >> - struct hi_gpio_status_response rs; >> + struct ec_request rq; >> + struct ec_response rs; >> struct wilco_ec_message msg; >> int ret; >> >> memset(&rq, 0, sizeof(rq)); >> rq.cmd = CMD_KB_CHROME; >> - rq.sub_cmd = SUB_CMD_H1_GPIO; >> + rq.sub_cmd = sub_cmd; >> >> memset(&msg, 0, sizeof(msg)); >> msg.type = WILCO_EC_MSG_LEGACY; >> @@ -196,13 +196,38 @@ static int h1_gpio_get(void *arg, u64 *val) >> if (rs.status) >> return -EIO; >> >> - *val = rs.val; >> + *out_val = rs.val; >> >> return 0; >> } >> >> +/** >> + * h1_gpio_get() - Gets h1 gpio status. >> + * @arg: The wilco EC device. >> + * @val: BIT(0)=ENTRY_TO_FACT_MODE, BIT(1)=SPI_CHROME_SEL >> + */ >> +static int h1_gpio_get(void *arg, u64 *val) >> +{ >> + return send_ec_cmd(arg, SUB_CMD_H1_GPIO, (u8 *)val); >> +} >> + >> DEFINE_DEBUGFS_ATTRIBUTE(fops_h1_gpio, h1_gpio_get, NULL, "0x%02llx\n"); >> >> +/** >> + * test_event_set() - Sends command to EC to cause an EC test event. >> + * @arg: The wilco EC device. >> + * @val: unused. >> + */ >> +static int test_event_set(void *arg, u64 val) >> +{ >> + u8 ret; >> + >> + return send_ec_cmd(arg, SUB_CMD_TEST_EVENT, &ret); >> +} >> + >> +/* Format is unused since it is only required for get method which is NULL */ >> +DEFINE_DEBUGFS_ATTRIBUTE(fops_test_event, NULL, test_event_set, "%llu\n"); >> + >> /** >> * wilco_ec_debugfs_probe() - Create the debugfs node >> * @pdev: The platform device, probably created in core.c >> @@ -226,6 +251,8 @@ static int wilco_ec_debugfs_probe(struct platform_device *pdev) >> debugfs_create_file("raw", 0644, debug_info->dir, NULL, &fops_raw); >> debugfs_create_file("h1_gpio", 0444, debug_info->dir, ec, >> &fops_h1_gpio); >> + debugfs_create_file("test_event", 0200, debug_info->dir, ec, >> + &fops_test_event); >> >> return 0; >> } >> -- >> 2.23.0.351.gc4317032e6-goog >> >