From patchwork Thu Feb 26 23:35:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gwendal Grignou X-Patchwork-Id: 5896761 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2343C9F373 for ; Thu, 26 Feb 2015 23:35:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F1E33203B1 for ; Thu, 26 Feb 2015 23:35:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B4271203AB for ; Thu, 26 Feb 2015 23:35:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932373AbbBZXf3 (ORCPT ); Thu, 26 Feb 2015 18:35:29 -0500 Received: from mail-vc0-f172.google.com ([209.85.220.172]:61728 "EHLO mail-vc0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932355AbbBZXf1 (ORCPT ); Thu, 26 Feb 2015 18:35:27 -0500 Received: by mail-vc0-f172.google.com with SMTP id kv7so5176303vcb.3 for ; Thu, 26 Feb 2015 15:35:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=xb4vUMIWgPDfAmhFiXPsNz0PFT4eycksPzfPov0EU+k=; b=MJdSfr8IzlmhJVRoxnUG+/qnHtlZmiJoXkmz0ZDtwgpLDYyM7+5YMmSF5nVXMW9tc6 c+rIcY6HoqmJaM7emMvAX7LLf0pehUdKKEwc3qv/I3LYR0K4dTM404h8S3X2H7EIcvEY +v5kBKGUFe3bXq4/rOAy1OrOIuHjD26hdBkVqiDNclDde5OuHrLkBluZ/OPLwzo5vtuV gz3mtcD4fxOJRoi8ttz1/ri7cauHAS3iF/YSnuCZCBazR4imA5UIf2jvwn6qrQFEbVCr ORXZEM/fBjzo4Xkv5uJttoZZpYl1l0a6ZgSIj+0aCPB3IFSwfLIR/wFD60ldlN8RcTry x02g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=xb4vUMIWgPDfAmhFiXPsNz0PFT4eycksPzfPov0EU+k=; b=hc4jxovu1qcAkD7xzl7gaWkhH1I3CjaS6Roft3xZYA51WjHieuUJ9/9U2HppKLIg0u FtuCm1LTJWeB8a3ojq84cb+8G9nJb+cUjklU2tSoSkMECHl+l9QEx2/aPuqc5SP4QC0H akWRlMVl93bzi9uaNNZSntzHGTebwLBJEzBBU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc:content-type; bh=xb4vUMIWgPDfAmhFiXPsNz0PFT4eycksPzfPov0EU+k=; b=YBhrfLOHiOXSF++dEeQYY0ErxofH6gj1QkNdFaWi9naucN5T3690HGjP4LTVxdZ66b 6blJ2w+d+8npbvspXx2SQb+WbbDspL0/1VJfxQI1xL9G7wf1nd+qTHmegs9qzi7yKcMm oZjjVcRupQl2LxshID5oh/3VwiBRe48jvWfnNKxZ9yTpSo0PzgVMTFcvuE5/y7bGmV4J KdeDH89pc2HqKsY63ZogZHglc1khB8FFH+xhwClhwB+46M/WC7Se8vn8pnXmQofsxEZy qC9+xGP6C7jE8riuht3nQYEPyHaRSzNIL+JhcfSCDXhuLemWgok5DFQdStZBl11W5169 xAdw== X-Gm-Message-State: ALoCoQnLHLbLemAC+iwOVmBjT2EG37XFJUQtPDZYBZR53Oy/rOvceWLQ9zyRguT+Qob8hOjgqKWc X-Received: by 10.52.110.226 with SMTP id id2mr10928265vdb.23.1424993726519; Thu, 26 Feb 2015 15:35:26 -0800 (PST) MIME-Version: 1.0 Received: by 10.52.141.42 with HTTP; Thu, 26 Feb 2015 15:35:06 -0800 (PST) In-Reply-To: <1422876388-16540-1-git-send-email-javier.martinez@collabora.co.uk> References: <1422876388-16540-1-git-send-email-javier.martinez@collabora.co.uk> From: Gwendal Grignou Date: Thu, 26 Feb 2015 15:35:06 -0800 X-Google-Sender-Auth: LoPLDHGpco75EydiwDd646Di9Lg Message-ID: Subject: Re: [PATCH v5 0/7] platform/chrome: Add user-space dev inferface support To: Javier Martinez Canillas Cc: Olof Johansson , Lee Jones , Doug Anderson , Bill Richardson , Simon Glass , Jonathan Corbet , Varka Bhadram , Paul Bolle , linux-samsung-soc@vger.kernel.org, Linux Kernel Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Tested-by: Gwendal Grignou Reviewed-by: Gwendal Grignou Tested on a chromebook pixel with kernel 4.0.0-rc1 and ectool using the enclosed patch in chromiumos platform/ec tree. I checked the lightbar is working, check the calls with "strace ectool ...", check the sysfs interface calls. --- util/comm-dev.c | 6 +++--- util/cros_ec_dev.h | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) --. 2.2.0.rc0.207.ga3a616c On Mon, Feb 2, 2015 at 3:26 AM, Javier Martinez Canillas wrote: > Hello, > > The mainline ChromeOS Embedded Controller (EC) driver is still missing some > features that are present in the downstream ChromiumOS tree. These are: > > - Low Pin Count (LPC) interface > - User-space device interface > - Access to vboot context stored on a block device > - Access to vboot context stored on EC's nvram > - Power Delivery Device > - Support for multiple EC in a system > > This is a fifth version of a series that adds support for the first two of > the missing features: the EC LPC and EC character device interfaces that > are used by user-space to access the ChromeOS EC. The support patches were > taken from the downstream ChromiumOS 3.14 tree with the fixes and cleanups > squashed to have a minimal patch-set. > > The version of the ChromeOS EC chardev driver in this series still does not > reflect the latest one that is in the downstream ChromiumOS 3.14 kernel but > makes the delta shorter. Following patches will add the remaining missing > features until both trees are in sync. I preferred to first add the initial > support and then adding the other features to both maintain the original > patch history in the downstream kernel and so preserve the patch authorship > and also make the diff to have a working cros user-space interface smaller. > > This version solves the issues pointed out in the earlier revision. > > A big difference between this series and the downstream ChromiumOS kernel is > that the ioctl API is modified to make it 64-bit safe and compatible with both > 64 and 32 bit user-space binaries. The data structures passed as arguments in > the ChromiumOS ioctl interface commands has pointers fields and since these > have different byte boundaries alignment requirement, the ChromiumOS driver > has a compat ioctl interface. The feedback was that this had to be avoided > since this was a new ioctl API so the pointers fields were replaced with a set > of fixed-size arrays to be used instead. This has the drawback that more data > could be used and copied between user and kernel space so feedback is welcomed > if there is a better approach to solve this kind of issues. > > The patches were tested on an Exynos5420 Peach Pit Chromebook and (thanks to > Bill Richardson) on an x86 Pixel Chromebook using a modified ectool [0] to use > the new ioctl API. The LPC interface driver and the lightbar sysfs driver were > also tested on the Pixel Chromebook. > > The series is composed of the following patches: > > Bill Richardson (4): > platform/chrome: Add cros_ec_lpc driver for x86 devices > platform/chrome: Add Chrome OS EC userspace device interface > platform/chrome: Create sysfs attributes for the ChromeOS EC > platform/chrome: Expose Chrome OS Lightbar to users > > Javier Martinez Canillas (3): > mfd: cros_ec: Use fixed size arrays to transfer data with the EC > mfd: cros_ec: Add char dev and virtual dev pointers > mfd: cros_ec: Instantiate ChromeOS EC character device > > Documentation/ioctl/ioctl-number.txt | 1 + > drivers/i2c/busses/i2c-cros-ec-tunnel.c | 51 +--- > drivers/input/keyboard/cros_ec_keyb.c | 13 +- > drivers/mfd/cros_ec.c | 19 +- > drivers/platform/chrome/Kconfig | 26 +- > drivers/platform/chrome/Makefile | 3 + > drivers/platform/chrome/cros_ec_dev.c | 274 +++++++++++++++++++++ > drivers/platform/chrome/cros_ec_dev.h | 53 +++++ > drivers/platform/chrome/cros_ec_lightbar.c | 367 +++++++++++++++++++++++++++++ > drivers/platform/chrome/cros_ec_lpc.c | 319 +++++++++++++++++++++++++ > drivers/platform/chrome/cros_ec_sysfs.c | 271 +++++++++++++++++++++ > include/linux/mfd/cros_ec.h | 23 +- > 12 files changed, 1358 insertions(+), 62 deletions(-) > create mode 100644 drivers/platform/chrome/cros_ec_dev.c > create mode 100644 drivers/platform/chrome/cros_ec_dev.h > create mode 100644 drivers/platform/chrome/cros_ec_lightbar.c > create mode 100644 drivers/platform/chrome/cros_ec_lpc.c > create mode 100644 drivers/platform/chrome/cros_ec_sysfs.c > > Patch #1 modified the struct cros_ec_command structure so it can be used > as an ioctl argument and be 64 and 32 bit safe and patch #2 adds fields > to the struct cros_ec_device that will be needed by the EC chardev driver. > > Patch #3 adds support for the EC LPC interface used on x86 Chromebooks. > > Patch #4 adds the ChromeOS chardev driver and patch #5 instantiates it > from the mfd cros_ec driver. > > Patch #6 exposes sysfs attributes that can be used by user space programs > to get information and control the ChromeOS EC. > > Patch #7 exposes sysfs attributes that are used to control the lightbar > RGB LEDs found on the Pixel Chromebook. > > The patches must be applied together and in order due dependencies. > Lee Jones has already acked the MFD changes so I think this could go > through Olof's chrome-platform tree. > > Best regards, > Javier > > [0]: git://git.collabora.co.uk/git/user/javier/ec.git mainline-ioctl -- To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/util/comm-dev.c b/util/comm-dev.c index cdbbbdf..1b9958d 100644 --- a/util/comm-dev.c +++ b/util/comm-dev.c @@ -13,9 +13,9 @@ #include #include . +#include "ec_commands.h" #include "cros_ec_dev.h" #include "comm-host.h" -#include "ec_commands.h" . static int fd = -1; . @@ -61,9 +61,8 @@ static int ec_command_dev(int command, int version, s_cmd.version = version; s_cmd.result = 0xff; s_cmd.outsize = outsize; - s_cmd.outdata = (uint8_t *)outdata; s_cmd.insize = insize; - s_cmd.indata = indata; + memcpy(s_cmd.outdata, outdata, outsize); . r = ioctl(fd, CROS_EC_DEV_IOCXCMD, &s_cmd); if (r < 0) { @@ -83,6 +82,7 @@ static int ec_command_dev(int command, int version, strresult(s_cmd.result)); return -EECRESULT - s_cmd.result; } + memcpy(indata, s_cmd.indata, insize); . return r; } diff --git a/util/cros_ec_dev.h b/util/cros_ec_dev.h index f6f5a55..55184ca 100644 --- a/util/cros_ec_dev.h +++ b/util/cros_ec_dev.h @@ -26,11 +26,11 @@ struct cros_ec_command { uint32_t version; uint32_t command; - uint8_t *outdata; uint32_t outsize; - uint8_t *indata; uint32_t insize; uint32_t result; + uint8_t outdata[EC_PROTO2_MAX_PARAM_SIZE]; + uint8_t indata[EC_PROTO2_MAX_PARAM_SIZE]; }; . /* @@ -46,8 +46,8 @@ struct cros_ec_readmem { char *buffer; }; . -#define CROS_EC_DEV_IOC ':' -#define CROS_EC_DEV_IOCXCMD _IOWR(':', 0, struct cros_ec_command) -#define CROS_EC_DEV_IOCRDMEM _IOWR(':', 1, struct cros_ec_readmem) +#define CROS_EC_DEV_IOC 0xEC +#define CROS_EC_DEV_IOCXCMD _IOWR(0xEC, 0, struct cros_ec_command) +#define CROS_EC_DEV_IOCRDMEM _IOWR(0xEC, 1, struct cros_ec_readmem) . #endif /* _CROS_EC_DEV_H_ */