From patchwork Thu May 24 09:57:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 10424059 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 01C536019D for ; Thu, 24 May 2018 10:50:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F1CE929385 for ; Thu, 24 May 2018 10:50:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 11B8F293FC; Thu, 24 May 2018 10:50:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AAD5D29360 for ; Thu, 24 May 2018 10:50:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1032371AbeEXKuD (ORCPT ); Thu, 24 May 2018 06:50:03 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:35600 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030474AbeEXJ5d (ORCPT ); Thu, 24 May 2018 05:57:33 -0400 Received: by mail-wr0-f196.google.com with SMTP id i14-v6so1967241wre.2 for ; Thu, 24 May 2018 02:57:31 -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=Pfscn+GlTJSPBsu+JELxk/VKBBrBmfjzBtu7ZuaQMMk=; b=OWIVlGYyspW/AAx7dpmo2ffXRT8xhBkVPdtTWIfkDW4aV7M1tUKbmU6NaY9elWFmAD fJoivJIilj41jF2IYvghN4gMKRVpYp2AvuFmpMmFOJ9UUiQpjyPCeNiiXEdU0aT5Eu3+ xj5m8kcImTerrgk4gLO14MnWyKAKinT7TG/KAhLI4jIdQRMd1kvBV7vkl3293m4lHVIu BenJeprVzLzV0IqRbzRRpT7bgkfSGmWq/BQsYawYABMqpE7Gm0cVV7Dw48GeeMwSxj4R Cx9R3tjg02Chh1pedQ+4/HXkCp2iynB136AAX0/g6wPFG8qWVwy6DdsPGyP/CgGuwWm6 c0LQ== 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=Pfscn+GlTJSPBsu+JELxk/VKBBrBmfjzBtu7ZuaQMMk=; b=ZkCMRxgOg4tIRLwWMP+6XNO+G5H/3TUHK5sqz9plp0L7ws440uHphA43KnOyl+7gvY 3fyrfGokBeUAuq7fc0D7TR0elvolXVQXdqrj8orfFW+Z70TlmXmcXUUdWlRfPzSI7Dka IMLfL1Aqosf3coCKdqIKeU/WnfzQVmBFcyFA/9GNI/gexpfjYNzV7pZOXZZYCw9+0YtD r9QrROYTZjZVO6O+m9hsB2e2erkgpEaXiriQXg4Cx0tjvLCBJdktsfl1xT18wvvFDESI LEMNy6+TrCCBLBk3Gr1dBVajfK6htT4fJkK5MBUAkvCBhrJ4goCNm70NiwVkJgY35sqM qsEg== X-Gm-Message-State: ALKqPwc37lEB/bhO6zHF8fyFtnQYFEfU3qZqGst4YsJ9BDcqH27pOuVm vJV7QGWxpgk1mitxZ7HOvMc/Tg== X-Google-Smtp-Source: AB8JxZpQiTiH0QaOFPXjme+OmXkS8oBcnOp1oqf6PFyYRjp6Z+P7r8pyj2jeSUfw6za302YoLkYsqQ== X-Received: by 2002:adf:c444:: with SMTP id a4-v6mr1171601wrg.20.1527155850860; Thu, 24 May 2018 02:57:30 -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.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 24 May 2018 02:57:29 -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 Subject: [PATCH v6 4/6] mfd: cros-ec: Introduce CEC commands and events definitions. Date: Thu, 24 May 2018 11:57:19 +0200 Message-Id: <1527155841-28494-5-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-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The EC can expose a CEC bus, this patch adds the CEC related definitions needed by the cros-ec-cec driver. Signed-off-by: Neil Armstrong Tested-by: Enric Balletbo i Serra Reviewed-by: Hans Verkuil --- include/linux/mfd/cros_ec_commands.h | 81 ++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/include/linux/mfd/cros_ec_commands.h b/include/linux/mfd/cros_ec_commands.h index cc0768e..fe33a81 100644 --- a/include/linux/mfd/cros_ec_commands.h +++ b/include/linux/mfd/cros_ec_commands.h @@ -804,6 +804,8 @@ enum ec_feature_code { EC_FEATURE_MOTION_SENSE_FIFO = 24, /* EC has RTC feature that can be controlled by host commands */ EC_FEATURE_RTC = 27, + /* EC supports CEC commands */ + EC_FEATURE_CEC = 35, }; #define EC_FEATURE_MASK_0(event_code) (1UL << (event_code % 32)) @@ -2078,6 +2080,12 @@ enum ec_mkbp_event { /* EC sent a sysrq command */ EC_MKBP_EVENT_SYSRQ = 6, + /* Notify the AP that something happened on CEC */ + EC_MKBP_EVENT_CEC_EVENT = 8, + + /* Send an incoming CEC message to the AP */ + EC_MKBP_EVENT_CEC_MESSAGE = 9, + /* Number of MKBP events */ EC_MKBP_EVENT_COUNT, }; @@ -2850,6 +2858,79 @@ struct ec_params_reboot_ec { /*****************************************************************************/ /* + * HDMI CEC commands + * + * These commands are for sending and receiving message via HDMI CEC + */ +#define EC_MAX_CEC_MSG_LEN 16 + +/* CEC message from the AP to be written on the CEC bus */ +#define EC_CMD_CEC_WRITE_MSG 0x00B8 + +/** + * struct ec_params_cec_write - Message to write to the CEC bus + * @msg: message content to write to the CEC bus + */ +struct ec_params_cec_write { + uint8_t msg[EC_MAX_CEC_MSG_LEN]; +} __packed; + +/* Set various CEC parameters */ +#define EC_CMD_CEC_SET 0x00BA + +/** + * struct ec_params_cec_set - CEC parameters set + * @cmd: parameter type, can be CEC_CMD_ENABLE or CEC_CMD_LOGICAL_ADDRESS + * @val: in case cmd is CEC_CMD_ENABLE, this field can be 0 to disable CEC + * or 1 to enable CEC functionnality, in case cmd is CEC_CMD_LOGICAL_ADDRESS, + * this field encodes the requested logical address between 0 and 15 + * or 0xff to unregister + */ +struct ec_params_cec_set { + uint8_t cmd; /* enum cec_command */ + uint8_t val; +} __packed; + +/* Read various CEC parameters */ +#define EC_CMD_CEC_GET 0x00BB + +/** + * struct ec_params_cec_get - CEC parameters get + * @cmd: parameter type, can be CEC_CMD_ENABLE or CEC_CMD_LOGICAL_ADDRESS + */ +struct ec_params_cec_get { + uint8_t cmd; /* enum cec_command */ +} __packed; + +/** + * struct ec_response_cec_get - CEC parameters get response + * @val: in case cmd was CEC_CMD_ENABLE, this field will 0 if CEC is + * disabled or 1 if CEC functionnality is enabled, + * in case cmd was CEC_CMD_LOGICAL_ADDRESS, this will encode the + * configured logical address between 0 and 15 or 0xff if unregistered + */ +struct ec_response_cec_get { + uint8_t val; +} __packed; + +/* CEC parameters command */ +enum ec_cec_command { + /* CEC reading, writing and events enable */ + CEC_CMD_ENABLE, + /* CEC logical address */ + CEC_CMD_LOGICAL_ADDRESS, +}; + +/* Events from CEC to AP */ +enum mkbp_cec_event { + /* Outgoing message was acknowledged by a follower */ + EC_MKBP_CEC_SEND_OK = BIT(0), + /* Outgoing message was not acknowledged */ + EC_MKBP_CEC_SEND_FAILED = BIT(1), +}; + +/*****************************************************************************/ +/* * Special commands * * These do not follow the normal rules for commands. See each command for