Received: by 10.223.176.5 with SMTP id f5csp3440442wra; Mon, 29 Jan 2018 13:12:44 -0800 (PST) X-Google-Smtp-Source: AH8x227VbmAvYyKFi1dYJ6Zl1LE6JpIdFJBMju/Lw9uxYyCONTfn0hAHadBGDY5PdpUAD/JM2WVL X-Received: by 10.98.57.27 with SMTP id g27mr28418234pfa.128.1517260364290; Mon, 29 Jan 2018 13:12:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517260364; cv=none; d=google.com; s=arc-20160816; b=hJj+5DiZfPsgfA865aAA10gWbgzUH1SYPInSlOFmaWe8nJ4S/uTRxx7Sbu+NZ9OKqw 8lHii8Q5TwFpnQeuYA7h5W86D28+d4eQBBPZi3se79th1qULmUFoQreoFS0x8g9crWdB fLZbiOpkJzklHMxvmn0gXmb4TIQrIL8omaqWWZbJVncHW2N63ujwfT48bcrETuQp+/O7 mnQQtMlN19xYOlMkBFhpPtOU5R01j2ewAyqzhPfL7bjrQpmKKGyXxzD1AFR72Hol9bfz 4OBI2/2C7t2n7pIKuxI44vDF71ISZqAXqPK+hlTtSRDHi+lMR0keoCqb0dj/xF4TbaCV sW0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature:dkim-signature :arc-authentication-results; bh=XIv3VC1VwSkVdDk93trYfCQ3zECjq31kkHWVmHP4sMM=; b=viqOalgHzssQsbG9I6vyQJKDp5I1glPyK/u9iBk/1vwsfslxSQ7Vk0mH0fPt9Nius7 gc6gObO/+2I8rjItVmHS4HlE+SMLKzwzV4Laylh9ReelWGXz0Fg78gGO490Ycev72y/g VW2fMUgwRjeETHIoKTUA7+E23Mhw02u1zmaBRu1LY8jkKV9y/9h2jxo31lqkHmLY/daC 96wfcnafyuMAlLmdYE2K2iVMJAvlzSYEcfYakUxrAUbU535/W8xJy1Qr0QWmPKQ+2zbl 2fzy1PvWd660esCDZlOV0i5X9FHkkc5kywtDZBX347sLPjNWLASu3MeX97Zf9UhX2ZS/ 0a9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@google.com header.s=20161025 header.b=Bya6rc3q; dkim=fail header.i=@chromium.org header.s=google header.b=IjwhGCsC; 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=fail (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 i135si7954980pgc.459.2018.01.29.13.12.29; Mon, 29 Jan 2018 13:12:44 -0800 (PST) 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=fail header.i=@google.com header.s=20161025 header.b=Bya6rc3q; dkim=fail header.i=@chromium.org header.s=google header.b=IjwhGCsC; 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=fail (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752445AbeA2VKy (ORCPT + 99 others); Mon, 29 Jan 2018 16:10:54 -0500 Received: from mail-yb0-f195.google.com ([209.85.213.195]:37971 "EHLO mail-yb0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751739AbeA2VKu (ORCPT ); Mon, 29 Jan 2018 16:10:50 -0500 Received: by mail-yb0-f195.google.com with SMTP id l3so3359812ybk.5 for ; Mon, 29 Jan 2018 13:10:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=XIv3VC1VwSkVdDk93trYfCQ3zECjq31kkHWVmHP4sMM=; b=Bya6rc3qSFtNndxCB98VzXJxobzcSKYWoQFv2ytxFyNj6w/a/PWDStI7tN8hNC0k4F WXldjvVn6LMDWcZTQHphlShWRyz3grVG1y/2c+ILsdmCw4W69e/oQH8ZG1mJ267hKz6i 5qcnQB5I/EHhUY/+h4ES7VH3y3HBsnV+Ny548ksbpg5Ju65ZHgH1dYAq3lce5I6Mb4RV yeD6/V2YcgHnkVSc11rqhJ7UEl9/0Wp4b0AQ8a9862AlClqo3k9+HjJSUj8S7ElvY9S4 xUHDRm9cZrg7GQqEPPnlmbJmEZjQjF26Fv2SCoWmTYBFsHdmD0zHhDpvVxJY63R+Y0HI pC/A== 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; bh=XIv3VC1VwSkVdDk93trYfCQ3zECjq31kkHWVmHP4sMM=; b=IjwhGCsCoWjr9OEyKtCMMv5VldrbOrbI/Mfxrs9+0vrdmVY5jmOL0C97L7RvxL2Zss VI0WgrlvTo8nkIYGZeBzzu7LGte+ZkSzMbxhzKun0vGXkQuBGcRZRp+F4XkzTm414XFQ 2oIH/oxmaPWKqsVIe3JlWix8zrf9DQGWSNCfE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=XIv3VC1VwSkVdDk93trYfCQ3zECjq31kkHWVmHP4sMM=; b=QKcY7zaOMbeWm50FQTlh2fvW17Bx7wUATES/9Z7x420aNmd8E56LmxHq9hgWV5FqkI G94mPWgIp81K364K9xb9qe5Dc5mEGEeclhr/3VdJRW6XlPWCEdAd6Zo9uz/4aJxt5PFN t2rSB9QJxJ29qfEN43OoI4FOR4sosHPDSLKXP0LAhe3A+nWq9mlkzi2JyNePG4abFXYt nXfy9Y4SDOvKZXsSfsq5ei5PmO/1JXeIf09pvFNOztga55EAGUBsMyX4iTZVouZNRMTe RhHd1viaXfK0RNF1NbZqnu8ZjS5uIZnyTnjVBwfiTnjuYTHzlxdxHjFy1k1LVg7bwJf+ bytA== X-Gm-Message-State: AKwxytcV0MvO5lN/wyZtjALW24zfxoJDlWW6DPzaoiGO5plDuLUgOW/F i2RhjrAZ4qossex0832IA1K+U0r3UY9cgca4tm9NVQ== X-Received: by 10.37.175.146 with SMTP id g18mr17965355ybh.506.1517260249182; Mon, 29 Jan 2018 13:10:49 -0800 (PST) MIME-Version: 1.0 Received: by 10.37.73.7 with HTTP; Mon, 29 Jan 2018 13:10:28 -0800 (PST) In-Reply-To: <20180119110028.18800-2-thierry.escande@collabora.com> References: <20180119110028.18800-1-thierry.escande@collabora.com> <20180119110028.18800-2-thierry.escande@collabora.com> From: Gwendal Grignou Date: Mon, 29 Jan 2018 13:10:28 -0800 X-Google-Sender-Auth: KUciRBt2HjE_UjjoeRNJtmyG-XQ Message-ID: Subject: Re: [PATCH v6 3/3] platform/chrome: Register cros_ec_accel_legacy driver To: Thierry Escande Cc: Benson Leung , Lee Jones , Jonathan Cameron , Enric Balletbo i Serra , Linux Kernel Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 19, 2018 at 3:00 AM, Thierry Escande wrote: > > With this patch, the cros_ec_ctl driver will register the legacy > accelerometer driver (named cros_ec_accel_legacy) if it fails to > register sensors through the usual path cros_ec_sensors_register(). > This legacy device is present on Chromebook devices with older EC > firmware only supporting deprecated EC commands (Glimmer based devices). > > Signed-off-by: Thierry Escande Tested-by: Gwendal Grignou Integrated into chromeos kernel [internal CL:891664] Tested with Glimmer (legacy driver required) and Samus (check driver is not loaded). [Retry in text mode only] > > --- > drivers/mfd/cros_ec_dev.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 60 insertions(+) > > diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c > index 3c4859d9c3c1..ec518a9f564f 100644 > --- a/drivers/mfd/cros_ec_dev.c > +++ b/drivers/mfd/cros_ec_dev.c > @@ -389,6 +389,63 @@ static void cros_ec_sensors_register(struct cros_ec_dev *ec) > kfree(msg); > } > > +#define CROS_EC_SENSOR_LEGACY_NUM 2 > +static struct mfd_cell cros_ec_accel_legacy_cells[CROS_EC_SENSOR_LEGACY_NUM]; > + > +static void cros_ec_accel_legacy_register(struct cros_ec_dev *ec) > +{ > + struct cros_ec_device *ec_dev = ec->ec_dev; > + u8 status; > + int i, ret; > + struct cros_ec_sensor_platform > + sensor_platforms[CROS_EC_SENSOR_LEGACY_NUM]; > + > + /* > + * EC that need legacy support are the main EC, directly connected to > + * the AP. > + */ > + if (ec->cmd_offset != 0) > + return; > + > + /* > + * Check if EC supports direct memory reads and if EC has > + * accelerometers. > + */ > + if (!ec_dev->cmd_readmem) > + return; > + > + ret = ec_dev->cmd_readmem(ec_dev, EC_MEMMAP_ACC_STATUS, 1, &status); > + if (ret < 0) { > + dev_warn(ec->dev, "EC does not support direct reads.\n"); > + return; > + } > + > + /* Check if EC has accelerometers. */ > + if (!(status & EC_MEMMAP_ACC_STATUS_PRESENCE_BIT)) { > + dev_info(ec->dev, "EC does not have accelerometers.\n"); > + return; > + } > + > + /* > + * Register 2 accelerometers > + */ > + for (i = 0; i < CROS_EC_SENSOR_LEGACY_NUM; i++) { > + cros_ec_accel_legacy_cells[i].name = "cros-ec-accel-legacy"; > + sensor_platforms[i].sensor_num = i; > + cros_ec_accel_legacy_cells[i].id = i; > + cros_ec_accel_legacy_cells[i].platform_data = > + &sensor_platforms[i]; > + cros_ec_accel_legacy_cells[i].pdata_size = > + sizeof(struct cros_ec_sensor_platform); > + } > + ret = mfd_add_devices(ec->dev, PLATFORM_DEVID_AUTO, > + cros_ec_accel_legacy_cells, > + CROS_EC_SENSOR_LEGACY_NUM, > + NULL, 0, NULL); > + if (ret) > + dev_err(ec_dev->dev, "failed to add EC sensors\n"); > +} > + > static int ec_device_probe(struct platform_device *pdev) > { > int retval = -ENOMEM; > @@ -436,6 +493,9 @@ static int ec_device_probe(struct platform_device *pdev) > /* check whether this EC is a sensor hub. */ > if (cros_ec_check_features(ec, EC_FEATURE_MOTION_SENSE)) > cros_ec_sensors_register(ec); > + else > + /* Workaroud for older EC firmware */ > + cros_ec_accel_legacy_register(ec); > > /* Take control of the lightbar from the EC. */ > lb_manual_suspend_ctrl(ec, 1); > -- > 2.14.1 >