Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1973377imm; Thu, 24 May 2018 03:51:26 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo7q0CyhyP3QT+PrVLEJl+4Ni5uyLLF8efwYEYB6h3+YRdEH+HHlJIN7ug9RkwHPI5qq35x X-Received: by 2002:a65:654a:: with SMTP id a10-v6mr5366000pgw.107.1527159086294; Thu, 24 May 2018 03:51:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527159086; cv=none; d=google.com; s=arc-20160816; b=OUAVO5J1Hr0l95tFOmvqqpZzzFn6TXTVNeMW0gAuD0jP36AIFeLZsm5bU1ebrgz573 2Sb4iuDzV9PtJkSQ0DnjSZojeQgNzLg+TG0KZ4bI22CkbWvBHqBI86BAEm9FQKxYhckF Rbj7CyXFTwgE64igOHLFDZ9M+q+nbgjSamplzDR0XEMrvVPDK9/LR98qKMpbb2renDX9 NYOPEIPmbLcz6ZJ6I1OTVuD3XWmV3u8GndWzQGIrN2w/a0UnQZHSIgV1Ok+YMV6dcehW 1sH7gCIcH0PRwbCowj6tBEtXm3q2cpMz89zJLK5gN5bfkkJ99ijKTgzTHVr4AGyOpcW5 5ImA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=gc/l9UK5wSR9TC6C4otkNkWTJemLxU8W4eRKDzPySaA=; b=UqFYzYWQ+wTn4WwjPmCOU2W3NgsV4JCmkgsBfCtaiWlLycZJH834fJG9aotUg1XdAn 03PzEGUEdTonaFZhmccZb8XHdusd/v6+TDIN8Z+UFU7gRLmpniKXKmlOAHsy9NfpBCb9 mR9dt9yd42tSULHbprnbpn7AL0DOExSXiSXWW/4sOPELi9gw8E8SM15ACoNPfUywduUI wNNYBYe0QL87GI5UaOnIKzXVvYbL88+oI5r18CGaBn8UaA4piJuSQsYuqLC0w1c6QaOJ GxjvxG/2RNDjqLzVIHc2CBOUCfUzhZFBSFtWor1J8zSvsL2OfACUqs3xsdWMbsWwpEMU N9LA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=tLZmZeMX; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x61-v6si20483151plb.560.2018.05.24.03.51.11; Thu, 24 May 2018 03:51:26 -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=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=tLZmZeMX; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1032668AbeEXKud (ORCPT + 99 others); Thu, 24 May 2018 06:50:33 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:56127 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030471AbeEXJ5a (ORCPT ); Thu, 24 May 2018 05:57:30 -0400 Received: by mail-wm0-f68.google.com with SMTP id a8-v6so3357800wmg.5 for ; Thu, 24 May 2018 02:57:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=gc/l9UK5wSR9TC6C4otkNkWTJemLxU8W4eRKDzPySaA=; b=tLZmZeMXSn7EOpr1+bkK2RrpHa0Aljq/caqYJ2cEHF8Mqfe5i+gBlW1qcsSSmxqVKx m5+YLk5tLYK3nV4c8cXV/tlGOEimZMVfS83Rh95qHsV0QWDcep1Oa40J6vJnkinVxkZg OC28AZ0kZ8Kq7IwDqCpeE00N8sM4TGEwBrQBHY5rFyL+JBP8lZpNymqlOsw+KQbb87bP Y7vYRPc/6FRp2X/WRMlKfZPwiBDQTLH4EFwxqHoiOvTLXag3agzPOqwQTw0r9V6nHLyr vtL9nveq9sLDLisZe2Wavs6Vq6XjTt7vWKGVCvqfzsw1dZK5oIxzhs507CZaSJpPn2D9 Ltgg== 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:in-reply-to :references; bh=gc/l9UK5wSR9TC6C4otkNkWTJemLxU8W4eRKDzPySaA=; b=lBiaSqEkjabT6sfDoOIcVxdQ0ge9xf4hAUKoymFH3so5geyK0a3XqcIyUz8DlCx/fM CztBywO+EdQ9nYZXJzOhBKRUVQQQtJMJohT+AcQc4oLPnDnmdU7pn6yFWBtmJO4lI6Fu EvwsWWJ27oc9KRJHsy65aeaPfW0e2KRv9whTf6awZKbAxSwkeyR2f+Dv/D7VlwXsVzB7 oAtIMkXmgOIs0X1p3C44MTIAmXN+7pzji8NWbdMKOY8r2c3PkN4iNC5n4C52O046sh2B vcRBR3MFWmiF5XTaAFcmXhcUdrQqURrFoB9USGAYmI3whOunyJWBCaqqGwSGrE1Sf85H 9mPg== X-Gm-Message-State: ALKqPwdPeyrAlo2k5uMJLuEZ9YvuL/gfO+Ef26vmcgXf6akNJXHWzq9c 7pwZe1zmoeuhA28TmUpa9IceRA== X-Received: by 2002:a1c:2d93:: with SMTP id t141-v6mr7435408wmt.94.1527155849191; Thu, 24 May 2018 02:57:29 -0700 (PDT) Received: from bender.baylibre.local ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id b66-v6sm6868525wma.48.2018.05.24.02.57.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 24 May 2018 02:57:28 -0700 (PDT) From: Neil Armstrong To: airlied@linux.ie, hans.verkuil@cisco.com, lee.jones@linaro.org, olof@lixom.net, seanpaul@google.com Cc: Neil Armstrong , sadolfsson@google.com, felixe@google.com, bleung@google.com, darekm@google.com, marcheu@chromium.org, fparent@baylibre.com, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, eballetbo@gmail.com, Stefan Adolfsson Subject: [PATCH v6 3/6] mfd: cros-ec: Increase maximum mkbp event size Date: Thu, 24 May 2018 11:57:18 +0200 Message-Id: <1527155841-28494-4-git-send-email-narmstrong@baylibre.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1527155841-28494-1-git-send-email-narmstrong@baylibre.com> References: <1527155841-28494-1-git-send-email-narmstrong@baylibre.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Having a 16 byte mkbp event size makes it possible to send CEC messages from the EC to the AP directly inside the mkbp event instead of first doing a notification and then a read. Signed-off-by: Stefan Adolfsson Signed-off-by: Neil Armstrong Tested-by: Enric Balletbo i Serra --- drivers/platform/chrome/cros_ec_proto.c | 40 +++++++++++++++++++++++++-------- include/linux/mfd/cros_ec.h | 2 +- include/linux/mfd/cros_ec_commands.h | 19 ++++++++++++++++ 3 files changed, 51 insertions(+), 10 deletions(-) diff --git a/drivers/platform/chrome/cros_ec_proto.c b/drivers/platform/chrome/cros_ec_proto.c index e7bbdf9..c4f6c44 100644 --- a/drivers/platform/chrome/cros_ec_proto.c +++ b/drivers/platform/chrome/cros_ec_proto.c @@ -504,10 +504,31 @@ int cros_ec_cmd_xfer_status(struct cros_ec_device *ec_dev, } EXPORT_SYMBOL(cros_ec_cmd_xfer_status); +static int get_next_event_xfer(struct cros_ec_device *ec_dev, + struct cros_ec_command *msg, + int version, uint32_t size) +{ + int ret; + + msg->version = version; + msg->command = EC_CMD_GET_NEXT_EVENT; + msg->insize = size; + msg->outsize = 0; + + ret = cros_ec_cmd_xfer(ec_dev, msg); + if (ret > 0) { + ec_dev->event_size = ret - 1; + memcpy(&ec_dev->event_data, msg->data, ec_dev->event_size); + } + + return ret; +} + static int get_next_event(struct cros_ec_device *ec_dev) { u8 buffer[sizeof(struct cros_ec_command) + sizeof(ec_dev->event_data)]; struct cros_ec_command *msg = (struct cros_ec_command *)&buffer; + static int cmd_version = 1; int ret; if (ec_dev->suspended) { @@ -515,18 +536,19 @@ static int get_next_event(struct cros_ec_device *ec_dev) return -EHOSTDOWN; } - msg->version = 0; - msg->command = EC_CMD_GET_NEXT_EVENT; - msg->insize = sizeof(ec_dev->event_data); - msg->outsize = 0; + if (cmd_version == 1) { + ret = get_next_event_xfer(ec_dev, msg, cmd_version, + sizeof(struct ec_response_get_next_event_v1)); + if (ret < 0 || msg->result != EC_RES_INVALID_VERSION) + return ret; - ret = cros_ec_cmd_xfer(ec_dev, msg); - if (ret > 0) { - ec_dev->event_size = ret - 1; - memcpy(&ec_dev->event_data, msg->data, - sizeof(ec_dev->event_data)); + /* Fallback to version 0 for future send attempts */ + cmd_version = 0; } + ret = get_next_event_xfer(ec_dev, msg, cmd_version, + sizeof(struct ec_response_get_next_event)); + return ret; } diff --git a/include/linux/mfd/cros_ec.h b/include/linux/mfd/cros_ec.h index f36125e..32caef3 100644 --- a/include/linux/mfd/cros_ec.h +++ b/include/linux/mfd/cros_ec.h @@ -147,7 +147,7 @@ struct cros_ec_device { bool mkbp_event_supported; struct blocking_notifier_head event_notifier; - struct ec_response_get_next_event event_data; + struct ec_response_get_next_event_v1 event_data; int event_size; u32 host_event_wake_mask; }; diff --git a/include/linux/mfd/cros_ec_commands.h b/include/linux/mfd/cros_ec_commands.h index f2edd99..cc0768e 100644 --- a/include/linux/mfd/cros_ec_commands.h +++ b/include/linux/mfd/cros_ec_commands.h @@ -2093,12 +2093,31 @@ union ec_response_get_next_data { uint32_t sysrq; } __packed; +union ec_response_get_next_data_v1 { + uint8_t key_matrix[16]; + + /* Unaligned */ + uint32_t host_event; + + uint32_t buttons; + uint32_t switches; + uint32_t sysrq; + uint32_t cec_events; + uint8_t cec_message[16]; +} __packed; + struct ec_response_get_next_event { uint8_t event_type; /* Followed by event data if any */ union ec_response_get_next_data data; } __packed; +struct ec_response_get_next_event_v1 { + uint8_t event_type; + /* Followed by event data if any */ + union ec_response_get_next_data_v1 data; +} __packed; + /* Bit indices for buttons and switches.*/ /* Buttons */ #define EC_MKBP_POWER_BUTTON 0 -- 2.7.4