Received: by 10.223.185.116 with SMTP id b49csp1284825wrg; Wed, 21 Feb 2018 15:51:52 -0800 (PST) X-Google-Smtp-Source: AH8x224O1PYtS211j4jrrMLJ/4d+Foba/nD2urt5O6IzxN5egyR57dtYWRwo3Fz+dpKuY6OPr5iy X-Received: by 2002:a17:902:b40d:: with SMTP id x13-v6mr4602359plr.320.1519257111945; Wed, 21 Feb 2018 15:51:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519257111; cv=none; d=google.com; s=arc-20160816; b=CXiFaX4Jz42O9Rq36XyU3y81ZP+zsJtK3VzsTs2X+hyGv89lm1jZD/rzxfSOSFH84M tseNJl12BzHlAZbb8QzhFugCbN3RjdMlroXEkzaLfGwrc+wdAnhzvYdcd6yTOTsP8Vso t79qfJgFbGhSDTzouDgdgsYzZe85RfWsFOajx4aJFiD9KzcQHB4ZwI6Dt3L3piudRSSM 2yT+OKgeWbdnEsK/LabeD9+DUEFaTdM0H6rZcxuk++IiD9p27v5/GOl3fKieaVEBPaYv nT/UaTm64wFn61v7hjgR8o450Vt9aPWQl+F3oLFFemohYHVpvxJKjSoExrUWLJe07bva 4vTw== 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 :arc-authentication-results; bh=w+XOUZtP8l5ciOHFxd4F28idnB3qwcRUJTlTHGmZBV0=; b=qYS58oA+E7c8JbGjkK94VHonJwPnMn2u7UhNdGwIiwc9kjifg59TOQW4HF4gsTugYh N0uEOJ/MhWw3HbV+eG+S/4ZzxFbSXoOeoyR2vOcs7yv2wipQV1dPuLkufNMOzgzXsxER oYNeI+eNOQzVhmzDDdJcJLIwZXO5A8ikX1YGr9VnxXAMwqM+yseov88LSONoRubRxWgJ 2M5eSA3TI80DVvWUqfXP/6xVlox79wK3IeAproCLHiqes3Scz3mbiSDAvUKnBDaoUfMv CVVKWIioEIs6yRtcxpyErd4s18cMMI62pr6/KrM4HM5F10RZR0gcoclFgCyMmp32Z1y6 aWmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=mUBYGerS; 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 o2si2359798pfb.268.2018.02.21.15.51.37; Wed, 21 Feb 2018 15:51:51 -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=pass header.i=@google.com header.s=20161025 header.b=mUBYGerS; 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 S1751422AbeBUXtk (ORCPT + 99 others); Wed, 21 Feb 2018 18:49:40 -0500 Received: from mail-yw0-f194.google.com ([209.85.161.194]:39157 "EHLO mail-yw0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750741AbeBUXth (ORCPT ); Wed, 21 Feb 2018 18:49:37 -0500 Received: by mail-yw0-f194.google.com with SMTP id b20so1114866ywe.6 for ; Wed, 21 Feb 2018 15:49:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=w+XOUZtP8l5ciOHFxd4F28idnB3qwcRUJTlTHGmZBV0=; b=mUBYGerS41FczIxuFtnlB73bBx1c7FwV8AQwygwmxUjTz5itMvFytxUPf6yLYsQt3L b34LijhX9tNibb59tmHvGzBkGn99vYKDJzn++1jH18OMb29CZRnkDko3BSt4X0tgs7W1 qbfwLXVAwelML30oipSaLcMuixwtrv1gyN5GXmJrMfLo0iSdQljahNkmLS9E6vhIrBF+ 93ScoCXewitAo/7JuxPmCd3zBfMJxPRcBPCBUixY5RpOreD/YLYmvuySUFazV3GXsCVx /wt8hWczKuOqWl1D6/O6S/EwxCU/mCpiHDu4+tGua24y8dNySxqOy9Vuf6C1oRgj/BlT yi1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=w+XOUZtP8l5ciOHFxd4F28idnB3qwcRUJTlTHGmZBV0=; b=VaC1wZUZ9z9zO+EnyLuiCu9uyr9y121VdYssUXW6RaK+Ya+9m4xkv0fUQ1aZo0I/N6 Tb8ieGk8iLvtDH1ZZZDNY6RQUjbqcCb5iJPJv4pxy+LYK2rjf4FLhBVOXcP03HPUlEnD HtvtrNxqnIPX+AihSnzjktr5txMek8/oaL2fVMl0TGsjzDkE6xTROVt5oKCDT0d26LZl S+9Rx7k2a+hlNdPUD1cWyFtEXJV2yBS8gCnmINOBIW4H01T8qCQ3uulttAcoXq8V/tKB mJ+x4LjmzBxrLBzR2QV2hpiuJ62udQ3nxrbfrus/L5U8G1pO0x91iONcbWlPTP6OGRaG TFvQ== X-Gm-Message-State: APf1xPAb+LLBDJnhSRCjmCfsGr8x8pYLr1/ZCcYnKxFIqDa/oAJyYQK2 STkSSjYTI2qhqPYQUfqyDbVY9RuNhhHM5y1+VWy1dA== X-Received: by 10.129.132.74 with SMTP id u71mr3466578ywf.432.1519256975714; Wed, 21 Feb 2018 15:49:35 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a25:760e:0:0:0:0:0 with HTTP; Wed, 21 Feb 2018 15:49:15 -0800 (PST) In-Reply-To: <20180219224621.22676-1-enric.balletbo@collabora.com> References: <20180219224621.22676-1-enric.balletbo@collabora.com> From: Gwendal Grignou Date: Wed, 21 Feb 2018 15:49:15 -0800 Message-ID: Subject: Re: [PATCH 4/6] mfd: cros_ec_dev: Register cros_ec_accel_legacy driver as a subdevice. To: Enric Balletbo i Serra Cc: Lee Jones , Guenter Roeck , Gwendal Grignou , Benson Leung , Linux Kernel , kernel@collabora.com 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 Mon, Feb 19, 2018 at 2:46 PM, Enric Balletbo i Serra 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). > > Tested-by: Gwendal Grignou > Signed-off-by: Enric Balletbo i Serra Reviewed-by: Gwendal Grignou > --- > 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 e0c604ab380f..fc98e0564061 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 const struct mfd_cell cros_ec_rtc_cell = { > .name = "cros-ec-rtc", > }; > @@ -440,6 +497,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); > > /* check whether this EC instance has RTC host command support */ > if (cros_ec_check_features(ec, EC_FEATURE_RTC)) { > -- > 2.16.1 >