Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6908895imu; Thu, 31 Jan 2019 01:33:22 -0800 (PST) X-Google-Smtp-Source: ALg8bN7ODqtqgZ65zV4oYJL5so5KohphrZm51DC/tAr3SB8z18vHJFe7IVW0owaUGpUakvhh7xV5 X-Received: by 2002:a62:ea09:: with SMTP id t9mr35750258pfh.228.1548927202085; Thu, 31 Jan 2019 01:33:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548927202; cv=none; d=google.com; s=arc-20160816; b=YfIbzc5cIJsIUdX8c2xJWc760itSjKk5K4vAnDRDd89neefkJJdLTnWH/v91kwZqvy j8HsRPtEWkHCxvo2oVmUW/V6uKQwhPm1UPjoTVcx636lZGkZgP20JY2jLJzTO4j6ShiG PpmLQ+Zsvt6SSxGM2A77zwtw2wkaMBAS2pB7jLyOWfIHKyhAFzIU4G+XABUWXN8k1bAu CQ+zj+MC9ybG5qSvftS0F95ZG19CW0MADRV7MKC8tn2QbakWnz96MF2yka6XHy/rlUZD bNbGY0de+Dtsc1gudXIe5IWiK2mviGURrhZm/TeDUHMdGz0q8uAgoPz2FuTBG2oCwC0u B5UA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from :dkim-signature; bh=XfC9+eAikTn1H/a1iW03wD6rYHQGLgaCvt1m7j56SP4=; b=vlABOMl5pUrwQZ6VKgEnX1HYWBtmvMFjkI/1p60Rww+N6iuBH5vhIFdc9FGPcNFuXa Vo9iBnsIEYL23Nc+qwdxiEp0PTmXrzyLmgTpBZpHVlmQQDWMwYAn2TJDZ6x6U5QMrgt4 L4sDUSjJ6/YBIXCZWVO8V4sHp3KCUbvcFiJO0rkofo3YblBcuTSgKTqDLMT2HMxyD1mS EupV5J99ksCzYPKPaEThSbyHj32LZYeejqWQ95tn+LdIOE+SYvcQK2m6AjFd58xFKOVa l+paU4zyPN07u+nEVZ3b+0ErIiHM4jP/uV5SpKJfOhUwADVeYgTC/24n2vqDRl933j3O z9FQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@chromium.org header.s=google header.b=NjXoAcLP; 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 r14si3796156pgh.39.2019.01.31.01.33.06; Thu, 31 Jan 2019 01:33:22 -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=@chromium.org header.s=google header.b=NjXoAcLP; 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 S1731635AbfAaJcE (ORCPT + 99 others); Thu, 31 Jan 2019 04:32:04 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:42209 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731267AbfAaJcD (ORCPT ); Thu, 31 Jan 2019 04:32:03 -0500 Received: by mail-pl1-f196.google.com with SMTP id y1so1218299plp.9 for ; Thu, 31 Jan 2019 01:32:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=XfC9+eAikTn1H/a1iW03wD6rYHQGLgaCvt1m7j56SP4=; b=NjXoAcLPt4BQXlvSgW9NNwbQfE3cDmurrkDmSsaM1U8DT6U76TteHgSH51Qx+20JoP +L+JbN1UOB19rGXfEY99O8O9MrhkLzNZGtOxdf6Uv+UJ+WFuBfC531jzHb4i4tE5wsTb q4WC3v9mUOtT+SfZjgzwY5j+K0lp3I77A9Sn0= 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:mime-version:content-transfer-encoding; bh=XfC9+eAikTn1H/a1iW03wD6rYHQGLgaCvt1m7j56SP4=; b=bpg69l1djFEDiF6F8OgZjQ5UndmfHBl6ZTAnAGtRC61Z3WD5HJLL4dZWWCtx1KRP3t rR0nCjMV4etaTxKry9+qFmCieKfjicCWW/UzGzQBlnRhDxtfkJ+bx9sM2zfMuo4Dj6rO YszAnlADzykHSDUXHj2fDvA13rTRRVx8kcjjhVs2vkgSK4JiwCYqLBtMMBrRBHUZj6Z4 z4n45FsqpHW3IiOdRA/c+JOJmz/Fx8u8wzi3K4WDzvDrTyQUrvSBRISZaXDlKjzrZCSp 9W+cFJk/DUkgDRR0lQLXqCBqiypXqh+uk61OPAPPa8LwedDKD++Un+QDvuCBBD7TXN+x 7fXw== X-Gm-Message-State: AJcUuke/0h6vHdaLr+qoQeDdvyVuR4F/NXTFum5iZDJxTRK0EZK6OjtL 7zsQgtC/fLDOyx2iA3VnnwGZ1w== X-Received: by 2002:a17:902:76cb:: with SMTP id j11mr34892596plt.179.1548927122757; Thu, 31 Jan 2019 01:32:02 -0800 (PST) Received: from pihsun-z840.tpe.corp.google.com ([2401:fa00:1:10:7889:7a43:f899:134c]) by smtp.googlemail.com with ESMTPSA id w184sm4531197pgd.34.2019.01.31.01.32.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 Jan 2019 01:32:02 -0800 (PST) From: Pi-Hsun Shih Cc: Pi-Hsun Shih , Erin Lo , Enric Balletbo Serra , Guenter Roeck , Lee Jones , Benson Leung , Enric Balletbo i Serra , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v4 5/6] cros_ec: differentiate SCP from EC by feature bit. Date: Thu, 31 Jan 2019 17:31:30 +0800 Message-Id: <20190131093131.245531-6-pihsun@chromium.org> X-Mailer: git-send-email 2.20.1.611.gfbb209baf1-goog In-Reply-To: <20190131093131.245531-1-pihsun@chromium.org> References: <20190131093131.245531-1-pihsun@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since a SCP and EC would both exist on a system, and use the cros_ec_dev driver, we need to differentiate between them for the userspace, or they would both be registered at /dev/cros_ec, causing a conflict. Cc: Enric Balletbo Serra Cc: Guenter Roeck Signed-off-by: Pi-Hsun Shih --- Changes from v3: - No change. Changes from v2: - No change. Changes from v1: - New patch extracted from Patch 5. --- drivers/mfd/cros_ec_dev.c | 9 +++++++++ include/linux/mfd/cros_ec.h | 1 + include/linux/mfd/cros_ec_commands.h | 2 ++ 3 files changed, 12 insertions(+) diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c index 2d0fee488c5aa8..67983853413d07 100644 --- a/drivers/mfd/cros_ec_dev.c +++ b/drivers/mfd/cros_ec_dev.c @@ -414,6 +414,15 @@ static int ec_device_probe(struct platform_device *pdev) device_initialize(&ec->class_dev); cdev_init(&ec->cdev, &fops); + if (cros_ec_check_features(ec, EC_FEATURE_SCP)) { + dev_info(dev, "SCP detected.\n"); + /* + * Help userspace differentiating ECs from SCP, + * regardless of the probing order. + */ + ec_platform->ec_name = CROS_EC_DEV_SCP_NAME; + } + /* * Add the class device * Link to the character device for creating the /dev entry diff --git a/include/linux/mfd/cros_ec.h b/include/linux/mfd/cros_ec.h index de8b588c8776da..fd297cf8f97295 100644 --- a/include/linux/mfd/cros_ec.h +++ b/include/linux/mfd/cros_ec.h @@ -24,6 +24,7 @@ #define CROS_EC_DEV_NAME "cros_ec" #define CROS_EC_DEV_PD_NAME "cros_pd" +#define CROS_EC_DEV_SCP_NAME "cros_scp" /* * The EC is unresponsive for a time after a reboot command. Add a diff --git a/include/linux/mfd/cros_ec_commands.h b/include/linux/mfd/cros_ec_commands.h index fc91082d4c357b..3e5da6e93b2f42 100644 --- a/include/linux/mfd/cros_ec_commands.h +++ b/include/linux/mfd/cros_ec_commands.h @@ -856,6 +856,8 @@ enum ec_feature_code { EC_FEATURE_RTC = 27, /* EC supports CEC commands */ EC_FEATURE_CEC = 35, + /* The MCU exposes a SCP */ + EC_FEATURE_SCP = 39, }; #define EC_FEATURE_MASK_0(event_code) (1UL << (event_code % 32)) -- 2.20.1.611.gfbb209baf1-goog