Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp1768184ybn; Thu, 26 Sep 2019 01:48:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqxsLOR9vRHZo7F8/g97baZJTQxpmUlE1X1B0DcdHnj8xzGJhsjMPML1qpeCDXL+oL6ADPTk X-Received: by 2002:a17:906:b316:: with SMTP id n22mr2046616ejz.54.1569487722443; Thu, 26 Sep 2019 01:48:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569487722; cv=none; d=google.com; s=arc-20160816; b=CN5mvgqo5/b8SoPnsURia8h8htiExHISK7PXCZ+a5hDG+vYA+Dnv059jYFX9XDM31A tAFre0el9WGhxeQrJAR2yjVH+q8Dbt3J0YQX4sSyQyBrMUwDCZ41a1KQ2NSlSrFDOkkP YqGApBhH2dfM2++ek+k32ul1qrduLO3/mcdv9SyrQE4/lih0wqK38MbbdayTbDP+iGGZ 73nAm9lx00v2zB/giveoRX2g8Asf01VXTaIry9Usx325VsWsLttNPAz1X0DRACFxucNN vFiyLHfHVhvWH/lQyLd2RBKkK806oanBdqjBkr3i1yeL/vHaj1L2kPvq20oWygE74wQ7 p0wA== 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:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=uaeaWBdArEAfa39+a057CzHk1IE9AGe9Y48nXTxnl5Y=; b=NJVmMBgKNtHUN7LrTchHfuQWVHE/QQGDzeSSlz1I1w/CTpl0LYXtbBF7ZdH1hT6lUq lAgxpHfsvz3bIUs8aPvz56JQvw5Sx2WYLG+vIR9XrGw1snPlZlN9dP1nspFvfl19beTJ /DEoXMzo1mdZADj09EM9vdNsneG2vQqUa4Ed6t5vi8KJrMfZDFDFPFEf2KEiz6UL69Vn W/7hXFRn4cVR7QDudL2IkPOgzX/ofp3nO0muwFhPSZNb3XS0PcYOffCWQPDEkKzUxmv2 7/gF9bUhZjO7JYwkhqXnlo2Nug1r0+nkzgReXZXuJusblxt8wpkkdhReDWlDVqprIcZb 8gAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=W1PlBy5P; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l48si909444edc.276.2019.09.26.01.48.19; Thu, 26 Sep 2019 01:48:42 -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; dkim=pass header.i=@chromium.org header.s=google header.b=W1PlBy5P; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2441972AbfIXUhX (ORCPT + 99 others); Tue, 24 Sep 2019 16:37:23 -0400 Received: from mail-io1-f68.google.com ([209.85.166.68]:44421 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727071AbfIXUhX (ORCPT ); Tue, 24 Sep 2019 16:37:23 -0400 Received: by mail-io1-f68.google.com with SMTP id j4so7760530iog.11 for ; Tue, 24 Sep 2019 13:37:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=uaeaWBdArEAfa39+a057CzHk1IE9AGe9Y48nXTxnl5Y=; b=W1PlBy5P5VtV3sQkddl5oJuJMX55KxCaG67/yBgqducKodDImfrDuvr2N862waA2nj HQ5wdmPprUhTQMt+Hn9AIRQuuANbNohI7f3KbNc68ZWBmo/JAcWledMia/LrjmLWnQzN IsB3ZwPhyfjP9RMJweb+tOAkpq3xdcTfNcsYo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=uaeaWBdArEAfa39+a057CzHk1IE9AGe9Y48nXTxnl5Y=; b=MU0G7IrCfeLHD2q+4xg5ZHz1zHj+GLFV6SMIOlFChSX0IT4dxx82SBxyw/ii9kRgeb JcjaiKObS8AAgYN9GK76oypo+uzj5JkK0NBBCSS8F2r56zUcNtqQmFkyR7NUY1j7oXwH ggn0kmKV23Wgr0bi3AIrjjTtoqkRCuIqb88Qjwrt9AKLL8g1Ko7XNUbFy42gFzpDHY1J VqJF1VpeWp6rnArwiSCQhx95izsFkTiaUD+9qyklrUfe299gwLdVJioAyih9XVbdD7VT n7JDK6oeT2FtZAWiAZVOvJAUuQ7749x5qoddF2mtnymz4w9u+nH3ptKFKK0sDrPHY/q+ MraQ== X-Gm-Message-State: APjAAAUXR0mrRyYkNpJy3vb8j4Ht1UpQlRYNB+N9W/xuQTScyxfUnlHF ty5wxfVOBnkZS1cySMslrZb0AtCeJJw= X-Received: by 2002:a02:a617:: with SMTP id c23mr870925jam.14.1569357441958; Tue, 24 Sep 2019 13:37:21 -0700 (PDT) Received: from localhost ([2620:15c:183:200:798c:e494:921c:d544]) by smtp.gmail.com with ESMTPSA id u11sm3787705iof.22.2019.09.24.13.37.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 24 Sep 2019 13:37:21 -0700 (PDT) From: Daniel Campello To: LKML Cc: Daniel Campello , Enric Balletbo i Serra , Benson Leung , Alexandre Belloni , Duncan Laurie , Nick Crews Subject: [PATCH v5] platform/chrome: wilco_ec: Add debugfs test_event file Date: Tue, 24 Sep 2019 14:37:16 -0600 Message-Id: <20190924203716.209420-1-campello@chromium.org> X-Mailer: git-send-email 2.23.0.351.gc4317032e6-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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