Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4343565imu; Mon, 7 Jan 2019 21:28:46 -0800 (PST) X-Google-Smtp-Source: ALg8bN5ouO7em3+yD+cwihn2gFNUuFp2FNGlT0Jcwt+jotxGzFgTpg0j6Rayu1B3ad66+5OOuJtt X-Received: by 2002:a62:ca9c:: with SMTP id y28mr388033pfk.236.1546925326045; Mon, 07 Jan 2019 21:28:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546925326; cv=none; d=google.com; s=arc-20160816; b=ZOqowhCMH9InmlLQKBXWl6fIXKOEiD+tTtTZHxLzww+87Gko+HNH4DLbLN7rBO8etm zED2hfeAE/2pUnpo9quElEbJSoP80c7DF+ymGAbiQjNI4yJacJXAmR7Zangc+LfBgwDj VTJbvkBOgOKr6f8Oc0we/8hviHUYIFY+1FCnhB0NkVkyI11u3+wbMxFPtQWrPtS8fpmP pBCxIczInvtY9Gl4qEh9NEqHark4XI68B1XtqeEfOZ8TqPHOWfVE6RCnqxSabjACgcag 6HjBTID2bap7kpx1W4kLIdVrmFY7JoJJb3fh21fpbBUloRwSiw3a0JZ9StHjMdZPqxMl 8uWQ== 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=goWLrpBG2Y75dOn+Zd/80yByFqC7jGRkIE9SI0uzL8o=; b=C4MRHrvaeVoCT0GWhonsNnHo9P5TSgGdtv5s4TIRVWCUL9FEofqR0rlpLxRUT2wvmY sdoA0r/tg08RPMGiVKMIjqSIG4vyvS/5NqEko6tzf6tj0Y+57HWdbN4nJnxM0ahaISAy M5oB3gyrr8g+UidfUpJYlU86ny1ZgkYP6eUygl9h1vartwr9RSygEkLcp9U0IbObwKyn u/M6eMQxMZpCo3686ipggxrUPO9eqwzlWcdIGMBMNHGaKJX5A9gSjzelWwuZH5dkgTLq fGi0mG/iaIginRPuAtrNKT4TB/yAzonwBhcAeZWrjuF/BXvtdl8wsRy8Zyz4J252cUQu 38jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@chromium.org header.s=google header.b=dVgmwhqt; 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 k12si8257460pgg.382.2019.01.07.21.28.30; Mon, 07 Jan 2019 21:28:46 -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=dVgmwhqt; 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 S1728031AbfAHF0p (ORCPT + 99 others); Tue, 8 Jan 2019 00:26:45 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:45896 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727693AbfAHF0n (ORCPT ); Tue, 8 Jan 2019 00:26:43 -0500 Received: by mail-pg1-f196.google.com with SMTP id y4so1180662pgc.12 for ; Mon, 07 Jan 2019 21:26:43 -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=goWLrpBG2Y75dOn+Zd/80yByFqC7jGRkIE9SI0uzL8o=; b=dVgmwhqt8+l4tYfK/ipyPgMUzH3yzB/uoHWfG0/1whmo6oqZdnlJSledcuPnER6Nj3 FBKNE6vWsZjDPrd9jGUyKtByUcMOC0LMB2nVe7d3REgZuceozm7J16a8H7pcP5QMLfbi LMM6WLGAxf5DrIp0MT1ZrMDe3uP+EADNyiajk= 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=goWLrpBG2Y75dOn+Zd/80yByFqC7jGRkIE9SI0uzL8o=; b=GVXVbP0MJKBNPso+fyCQZzjQBB8GWhJu27e2pkcJh3a6fMh0odmTiyplx9giiz70WI PPHJP/fwZ+qRTIbdun0DFA5F2poC75Y3AWwhRq4+lnTZYZIt6nKNa5rUHF2uCur33b83 UroF/CbqpJ3g7xiilOBAwN9CHFBbicwI8z6qw3Sy2QxU7ezIrpL7i9nz/feJ56lzBwZB Ym5fIvCHuAJVcbDKVEyE6ewsaxSg2tjZH4PQyfPWas5Jxd4fHhysfw5J4Y3pMdHcu8lI kP9TmOsmjelGVFmCekNjrBtrVe72/EcZchbtkZzBShCS3wvPNs3uBjk/Z1kQIdj3za1O NpWQ== X-Gm-Message-State: AJcUukeFqYli0j7dj0IenVeHfGMA2qxvU5TZx3OknWvx1VdP9ky5+PYz vMX91OeT3Zs99b/AeCVKtlhjPg== X-Received: by 2002:a62:c583:: with SMTP id j125mr386680pfg.37.1546925202738; Mon, 07 Jan 2019 21:26:42 -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 64sm88106874pff.101.2019.01.07.21.26.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Jan 2019 21:26:42 -0800 (PST) From: Pi-Hsun Shih Cc: Pi-Hsun Shih , Nicolas Boichat , Enric Balletbo Serra , Guenter Roeck , Lee Jones , linux-kernel@vger.kernel.org (open list) Subject: [RFC v2 6/6] cros_ec: differentiate SCP from EC by feature bit. Date: Tue, 8 Jan 2019 13:26:06 +0800 Message-Id: <20190108052606.59426-7-pihsun@chromium.org> X-Mailer: git-send-email 2.20.1.97.g81188d93c3-goog In-Reply-To: <20190108052606.59426-1-pihsun@chromium.org> References: <20190108052606.59426-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 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.97.g81188d93c3-goog