Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1701935imm; Wed, 23 May 2018 22:50:07 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrRHNOytXVt+0gKELj9VWj1PEDeDNs8bWhTpcSW3B/0uHRswdRtvrVZaDGT0SyFV+nbACk2 X-Received: by 2002:a17:902:694b:: with SMTP id k11-v6mr5944874plt.334.1527141007624; Wed, 23 May 2018 22:50:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527141007; cv=none; d=google.com; s=arc-20160816; b=BphQ1BjCRzudr5s6/ctpSB9/a3O+H07RwVx+mQ9qlcw5CAPtTHL5/2cREifeJupGaR r+5I4sJ2PvqtGTxIE20JcXh4UQiDbQbqz5la1WMy5j0KNUw2xKer4vm8Q6JbOSBHQy/N Qt5OwDvzea2Xx/LSVUA7I2z33zsjVK5rM3bbQstgITpjk6a1a7dt5BBctI49jHHWlorC rKFsIHphgNJHGIYrHlSkk1MJ2aKXwcKx3VVteXu3EAXbxYBfGzPUqPzpIzCyc3dt0UHt YK0DEfpLB72lwNiZxnBDSHftfuL6bhv0Y6zxjJi8amokufYrsxG7dpNkxgp+w4tiQJ+m AMVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=XawJdkovb6j/ERi9UVl21x/NNSLlTkh+2dZULodia2s=; b=w7qNoW67uedIaagI/zrByd8EPzAI1aMEvJErQouWxpmDjEAw2ywF11nwTEpJpMzMMw Yjj3RSmdJz63PsEUOBzhiq2YyDbZ0vHuSnLTIH1ebvYBst9VEJgdkCTTyJiDMELWDziQ IFDMQwdhZJLVVybA3wZdXE7r/JRgsEDMeesuwaNMaw6F93SYsteZgTaEXapv5PHBmRKN 2sWz9lp1f9hElx2VEuIHjzrb+bnlZ0UdCjo7ughGVxCP/s8FIN5Wh4wKAqZQWcNXknVS Tqnm4D6AP9Y0MfDTO8gyR7YTTGdwVpKzlW67KQrA/FzzzqCuAs1Y1NiSM3U8ok6AoHwQ LfCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Dxzt9Zku; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z14-v6si2729050pgz.284.2018.05.23.22.49.52; Wed, 23 May 2018 22:50:07 -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=@google.com header.s=20161025 header.b=Dxzt9Zku; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755239AbeEXFr6 (ORCPT + 99 others); Thu, 24 May 2018 01:47:58 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:45138 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755046AbeEXFrz (ORCPT ); Thu, 24 May 2018 01:47:55 -0400 Received: by mail-pl0-f67.google.com with SMTP id bi12-v6so343103plb.12 for ; Wed, 23 May 2018 22:47:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=XawJdkovb6j/ERi9UVl21x/NNSLlTkh+2dZULodia2s=; b=Dxzt9Zku6It96u0fN2/V8ZcJQLg2Hw0w6nHFQX0WxzM77CpniIM3tDRXz0cvcFHxy9 dvJ/IZEOTPxeZoEAiMAq1gVpfjhA0NpsseJ2XRyv5nrBKTatjAnYwUwC9w0nx9ypjHA0 Jolcc3BC4DeZSw3qWhLhKoWPjtjTA4+wuUMG7Q0QQ/cnV/A7sLiKB9qlUmS0cPdNKAcH Fg9B9eE8l2N/vjLmSr44IDjh1jl33chnTHHer+dUVUYt1ZSpgF1YdpMJtSziuzDo64Jm KFGL3NEUBG/nRclETZ78FjOjhiNnKDI1xsWYL9HNWHNvnKMbb0SQ8573mzBebGyckcZT 7TiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=XawJdkovb6j/ERi9UVl21x/NNSLlTkh+2dZULodia2s=; b=o3MxXdxg/3a/SvMAPlL6OR5ARceVI4uaUp4vWN6BW+mJTNYh3U3z7dfItYkHELPfBR JPZE1blS7y4g51dIAZPRTrdQEVzRUxDVRbFZbV1gQR50OM2lTnmecnj2YNa/nfC3rtnS pRzYYM6TW9/3wTH1jRBDBr1fMOtTmQOKqnD2RtBg/wR0MPYAPVEQ2ABa32UQszX3fe1G hpMO3TEjdi62A37ynQf0uiKK7Uf+wdkNZV57P8E4pKR0VbMpCu9jJdR7AMiFJMv6OE78 Whc1bl8vrGhmcXyd/5e0ArGFekKj+USkDzKsSOBlf141JCzzP7X/rQr/AzV2+MIFQ8M/ rG5w== X-Gm-Message-State: ALKqPweOZI5k16mwe7pOCp/SOkNUbMP8kwF3D/2AeREfbfdeRDAXSB62 gTzNw4cw691hpgAyRMi2cajlew== X-Received: by 2002:a17:902:7844:: with SMTP id e4-v6mr5789121pln.296.1527140874232; Wed, 23 May 2018 22:47:54 -0700 (PDT) Received: from decatoncale.mtv.corp.google.com ([2620:0:1000:1501:e4e8:e3c6:19f1:ae51]) by smtp.gmail.com with ESMTPSA id z13-v6sm31410698pfe.77.2018.05.23.22.47.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 23 May 2018 22:47:52 -0700 (PDT) Date: Wed, 23 May 2018 22:47:50 -0700 From: Benson Leung To: Neil Armstrong Cc: airlied@linux.ie, hans.verkuil@cisco.com, lee.jones@linaro.org, olof@lixom.net, seanpaul@google.com, sadolfsson@google.com, felixe@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, Stefan Adolfsson , bleung@chromium.org Subject: Re: [PATCH v2 3/5] mfd: cros-ec: Introduce CEC commands and events definitions. Message-ID: <20180524054750.GA245608@decatoncale.mtv.corp.google.com> References: <1526648704-16873-1-git-send-email-narmstrong@baylibre.com> <1526648704-16873-4-git-send-email-narmstrong@baylibre.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="9jxsPFA5p3P2qPhR" Content-Disposition: inline In-Reply-To: <1526648704-16873-4-git-send-email-narmstrong@baylibre.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --9jxsPFA5p3P2qPhR Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi Neil, Hi Stefan, On Fri, May 18, 2018 at 03:05:02PM +0200, Neil Armstrong wrote: > The EC can expose a CEC bus, this patch adds the CEC related definitions > needed by the cros-ec-cec driver. > 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. >=20 > Signed-off-by: Stefan Adolfsson > Signed-off-by: Neil Armstrong It looks like this change squashes together this chromeos-4.4 CL https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/= 1061879 and some other new changes to add cec to cros_ec_commands. Could you separate the two? One patch that's as close to Stefan's which introduces the 16 byte mkbp, and a second one that adds the HDMI CEC commands?=20 Thanks, Benson > --- > drivers/platform/chrome/cros_ec_proto.c | 40 +++++++++++++---- > include/linux/mfd/cros_ec.h | 2 +- > include/linux/mfd/cros_ec_commands.h | 80 +++++++++++++++++++++++++++= ++++++ > 3 files changed, 112 insertions(+), 10 deletions(-) >=20 > diff --git a/drivers/platform/chrome/cros_ec_proto.c b/drivers/platform/c= hrome/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); > =20 > +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 =3D version; > + msg->command =3D EC_CMD_GET_NEXT_EVENT; > + msg->insize =3D size; > + msg->outsize =3D 0; > + > + ret =3D cros_ec_cmd_xfer(ec_dev, msg); > + if (ret > 0) { > + ec_dev->event_size =3D 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 =3D (struct cros_ec_command *)&buffer; > + static int cmd_version =3D 1; > int ret; > =20 > if (ec_dev->suspended) { > @@ -515,18 +536,19 @@ static int get_next_event(struct cros_ec_device *ec= _dev) > return -EHOSTDOWN; > } > =20 > - msg->version =3D 0; > - msg->command =3D EC_CMD_GET_NEXT_EVENT; > - msg->insize =3D sizeof(ec_dev->event_data); > - msg->outsize =3D 0; > + if (cmd_version =3D=3D 1) { > + ret =3D get_next_event_xfer(ec_dev, msg, cmd_version, > + sizeof(struct ec_response_get_next_event_v1)); > + if (ret < 0 || msg->result !=3D EC_RES_INVALID_VERSION) > + return ret; > =20 > - ret =3D cros_ec_cmd_xfer(ec_dev, msg); > - if (ret > 0) { > - ec_dev->event_size =3D ret - 1; > - memcpy(&ec_dev->event_data, msg->data, > - sizeof(ec_dev->event_data)); > + /* Fallback to version 0 for future send attempts */ > + cmd_version =3D 0; > } > =20 > + ret =3D get_next_event_xfer(ec_dev, msg, cmd_version, > + sizeof(struct ec_response_get_next_event)); > + > return ret; > } > =20 > 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; > =20 > - 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/cro= s_ec_commands.h > index f2edd99..16c3a2b 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 =3D 24, > /* EC has RTC feature that can be controlled by host commands */ > EC_FEATURE_RTC =3D 27, > + /* EC supports CEC commands */ > + EC_FEATURE_CEC =3D 35, > }; > =20 > #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 =3D 6, > =20 > + /* Notify the AP that something happened on CEC */ > + EC_MKBP_CEC_EVENT =3D 8, > + > + /* Send an incoming CEC message to the AP */ > + EC_MKBP_EVENT_CEC_MESSAGE =3D 9, > + > /* Number of MKBP events */ > EC_MKBP_EVENT_COUNT, > }; > @@ -2093,12 +2101,31 @@ union ec_response_get_next_data { > uint32_t sysrq; > } __packed; > =20 > +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; > =20 > +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 > @@ -2828,6 +2855,59 @@ struct ec_params_reboot_ec { > /* Current version of ACPI memory address space */ > #define EC_ACPI_MEM_VERSION_CURRENT 1 > =20 > +/***********************************************************************= ******/ > +/* > + * HDMI CEC commands > + * > + * These commands are for sending and receiving message via HDMI CEC > + */ > +#define MAX_CEC_MSG_LEN 16 > + > +/* CEC message from the AP to be written on the CEC bus */ > +#define EC_CMD_CEC_WRITE_MSG 0x00B8 > + > +/* Message to write to the CEC bus */ > +struct ec_params_cec_write { > + uint8_t msg[MAX_CEC_MSG_LEN]; > +} __packed; > + > +/* Set various CEC parameters */ > +#define EC_CMD_CEC_SET 0x00BA > + > +struct ec_params_cec_set { > + uint8_t cmd; /* enum cec_command */ > + union { > + uint8_t enable; > + uint8_t address; > + }; > +} __packed; > + > +/* Read various CEC parameters */ > +#define EC_CMD_CEC_GET 0x00BB > + > +struct ec_params_cec_get { > + uint8_t cmd; /* enum cec_command */ > +} __packed; > + > +struct ec_response_cec_get { > + union { > + uint8_t enable; > + uint8_t address; > + }; > +} __packed; > + > +enum 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 { > + EC_MKBP_CEC_SEND_OK =3D 1 << 0, > + EC_MKBP_CEC_SEND_FAILED =3D 1 << 1, > +}; > =20 > /***********************************************************************= ******/ > /* > --=20 > 2.7.4 >=20 --=20 Benson Leung Staff Software Engineer Chrome OS Kernel Google Inc. bleung@google.com Chromium OS Project bleung@chromium.org --9jxsPFA5p3P2qPhR Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEE6gYDF28Li+nEiKLaHwn1ewov5lgFAlsGUgYACgkQHwn1ewov 5lilCQ/6AjK9oxG0+ZKxZ8hyw6p3SoHgwZ38dum0f3LMsJW7xUZXhBW8HGktLRRc dZtmLpa9RM69gUg8dPk16aNfFaSw+w0yqqdUoHFVmIttK/Aj8o4QPWSUnqa7Pkbb 8Gnqa8v+PC9e2Pft9mhqkQPwDDfN5NsPDgNgnFzJwgBA5GkHjG8Q3vtZoKK/qZUw J8ltsrRgxwfTlAU9NYGrIBrhrPeGxSIwR/7fPBYTYdfd5B7rQ18qOoVZcBuwrUkv wvW+Lb72EmFl97TmSNPlxywErU4UgqBhIQkm24ejkKYXCKTQ2XsZxA7Dgukd7taH H7EZEpOVbVtgAUTnQ5yhpbQR+sszzGIDcEmEDzsZBdxgQa9Q1j+OXUMavnUYGCpl dST6g4opvtZNc3PJejwAIqjjm5XNnjK2BSYsFK3X30Paic2+2mV9jNRG3FuxwkT3 XY27dU+8SX9VyvS9aPcJCqnzM2SpURB0ZNraoiZ9yYF2BolFV0eC8//sTD/AL6ZX 8n2G/9PmgQGPAVOEREV9GHklLd2dDvujVvWNB4rfbjUslRW7DoE7jDl4AaYIbzr6 thMhhxRh6MiLYIxP4a6AR64wX7Rc7X31BXAMNhhpNcz7ZQJ5GmsNy9evSpg8fmEF gPTHAVENIuXO4ZjPbHUilXNNKDfdTOKuLCOI3JxIo4Dm6cobgPQ= =QF2U -----END PGP SIGNATURE----- --9jxsPFA5p3P2qPhR--