Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5916301imu; Sun, 20 Jan 2019 23:21:41 -0800 (PST) X-Google-Smtp-Source: ALg8bN6pXAaczl4X/cHVFu0+GP3qNKLUd9ybPqvPQQQ/zUTTnnopprpAcy3vCE++mdDaPY1ho6i/ X-Received: by 2002:a62:345:: with SMTP id 66mr28649250pfd.189.1548055301431; Sun, 20 Jan 2019 23:21:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548055301; cv=none; d=google.com; s=arc-20160816; b=KAiAXX4NSrP2rw2DkuDMmUdzNk7WQd6ozsupxzGOAkwscd5GpvQSqHW0sLdXkI0txg c3Gep88zGX8iibYLmnyPz0DN9Kz7dnVYQBSEz+0JvHiCRTgflcNabXxMiw/1474sQuK2 9yyppr+TDWXK0E+nPcstQzFZVL53UauoZb+4iceMvtDez/qTKfo8+ikXWYX40kAXW4cL XzM0YEOJ+u+FwVaSIg6OBRpD++HuB8nmbIYERJZbuoA8zaQtv+WCTEZJHKs1mCoNwQYW uoZibF0qRz7b6SKLDyxzshL1S6iTi88BNH6BAqfgGq83zS71UFHMviEcdqSq7hFN7lpC LdjQ== 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=jVxi23+KZwyOYF+hkS3H0vh4j/QzNzCIQI81HIp2KyY=; b=uBPcXyXt5GVo8U5SmDRoU97x9S75IQvSM8ZC0h0+bF7bOCvMUExESp/t+UPxQ6IZYB RlkjKENVZLWimukwF/79LKhpAuRPhDpOpHOI6tkKLPACDeUBeYp2La+dtUjPW4rpig0l 1dCBqhjmi6npGFrK7kH+e2Kjxt2KmtL8D65+WAXu4cpVOh7ilfohY9rfCw5bXMCsK75e pvnY8+2EEpFTLAmFU8MtQc5hjntC7pVrw9Io8/El8WkTNqz/KaVgmBbCtqHrWx307BEY KCT87TMY1UcUxZFbp5oAWcKSERyokhLnpgKhs7lctPFqH3FHF5tZhqQee3VC5OMXqaix P2VA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@chromium.org header.s=google header.b=IHoooKSW; 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 l184si11957319pgd.523.2019.01.20.23.21.26; Sun, 20 Jan 2019 23:21:41 -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=IHoooKSW; 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 S1728452AbfAUHTN (ORCPT + 99 others); Mon, 21 Jan 2019 02:19:13 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:43684 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728430AbfAUHTH (ORCPT ); Mon, 21 Jan 2019 02:19:07 -0500 Received: by mail-pf1-f194.google.com with SMTP id w73so9694398pfk.10 for ; Sun, 20 Jan 2019 23:19:07 -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=jVxi23+KZwyOYF+hkS3H0vh4j/QzNzCIQI81HIp2KyY=; b=IHoooKSWYGmZ9GV6cdCB8Yh1YvRg9u1x5DoVPZMsEmfeiCujPvZ/LTFKnLBlITkMYc GXY6mwGRmZcBu50hTdgVATvJfevEIFstACpxGnxs/xpY/sjgclUvgy77EeT0My8T7V7R KxE+d2sPkfUsCXVQy2uIsOGyDUdVhTnAS/g2I= 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=jVxi23+KZwyOYF+hkS3H0vh4j/QzNzCIQI81HIp2KyY=; b=ovNjL9/Tix3KVEsqWmtuCBM9jGsErMJLeE19IrTkElf852uBbBdpDHU2DL7UPskak2 Bhy7eY85wJp89Ie5OrKxk/JdtRVjEws4S361V9SKkKB6FEanRC3wdpA9vXjeVXktbVWb RV1bbWDF+iQxEaYaDe5qllV920NM423J+sjQy1Ni5RgsWQ+yDLnM62+EWiWmyBaZvmcy NSt5HZUNmoqyTdpkoCNH9TVKGJ6jUGYRQ8Jgr6Hz9Xp9XhRlsmGu3Vu2/zn4lOJLnKXt E+TbMo7jLFVBEYDUj7XULCIqe1fGiD25imRO0DTbuG5Wq3sGJDXR8ID6KjtUi69IDzgK G3nQ== X-Gm-Message-State: AJcUukdpZFWvFiWhXKcKJRj4sNb8ymDSjw9+wO2ztNtFAs/D9yenaBib HqR9chW8uyOskfQA+n94xaDwLg== X-Received: by 2002:a62:1a44:: with SMTP id a65mr29228414pfa.30.1548055147045; Sun, 20 Jan 2019 23:19:07 -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 v15sm14941843pfn.94.2019.01.20.23.19.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 20 Jan 2019 23:19:06 -0800 (PST) From: Pi-Hsun Shih Cc: Pi-Hsun Shih , Nicolas Boichat , Enric Balletbo Serra , Guenter Roeck , Lee Jones , Benson Leung , Enric Balletbo i Serra , linux-kernel@vger.kernel.org (open list) Subject: [RFC v3 5/5] cros_ec: differentiate SCP from EC by feature bit. Date: Mon, 21 Jan 2019 15:18:33 +0800 Message-Id: <20190121071833.43443-6-pihsun@chromium.org> X-Mailer: git-send-email 2.20.1.321.g9e740568ce-goog In-Reply-To: <20190121071833.43443-1-pihsun@chromium.org> References: <20190121071833.43443-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 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.321.g9e740568ce-goog