Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp4961763img; Tue, 26 Mar 2019 22:17:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqyeC+QsnuS8SbQza6jIDD21ngXUWwUe9qNU6KGjlDDvE+hGj3wU+gsnmzvu4TBu80R+yZJ9 X-Received: by 2002:a63:464c:: with SMTP id v12mr32220623pgk.431.1553663834422; Tue, 26 Mar 2019 22:17:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553663834; cv=none; d=google.com; s=arc-20160816; b=Hk2246FAmZJ0l9jEaKPLrj5PGnV/hWVPtduZySM/Wo1jKZXKKJeTvHo7KEZaa3yGJV wji1xadAXgOB0w2IGbf1LQLnchnn/H2zkrmnSZ1KOw/RPDxNavV/TgcikrjmTFY+RTrx C28iBXbwLmCghc4aZzfsoeP+FQRgIKUBqCNtJZHpmbv48BzsXrNIwd8v0WL2NR7AAH+D aqMIW8+pxdikM4Fzoz5/JlcNOVv0qAccuzZGfWJlcIjO3dTEv1o27QCUg6q5Ax4bABfd YzRW7qDx6KGDiF3BuRgX4ZqLAIc/OtpknXcSWDEGiM5lEc4hvNF7ZywUXHI6fU+Ux7L1 wpRg== 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=/8zaTUk0BnVa2J8hDxdZEkl8OZGwBzmzq9A3ZT/PfYw=; b=tnUNT6zTxRv54a8SfMchGhN3Jt+FuTtCoq80iBV8rIybFcQcwJuUrywrtHsLino79+ lAEnxb8BYJbl0IWjupaHmoGCLXQZqMUJprIRThTvhQacnimgt3M2FuHnSJraTb6HoPa3 kAB3kVbiM04T/UhFcGWfMaytYjue0GkufHqNKu2Lx0aETMlhKSIKBQ9QqyK+D8veSot9 /BBZ4F2JBExQHYBZUHN+6RlzUsBrtFVQljxOccpRta/juZswtpZ2s7+Cr+l0bXb+6VWk HhDlWGQwou+SGV5yg6zbpegtY4eza0L+q/kkkdvSMwaBeu8MzuHncr/LSPzhK9OFD0CP 5/eQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@chromium.org header.s=google header.b=bMiKxb8z; 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 t21si9145273plr.366.2019.03.26.22.16.59; Tue, 26 Mar 2019 22:17:14 -0700 (PDT) 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=bMiKxb8z; 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 S1732615AbfC0FPj (ORCPT + 99 others); Wed, 27 Mar 2019 01:15:39 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:42439 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732489AbfC0FPe (ORCPT ); Wed, 27 Mar 2019 01:15:34 -0400 Received: by mail-pf1-f195.google.com with SMTP id r15so9141606pfn.9 for ; Tue, 26 Mar 2019 22:15:33 -0700 (PDT) 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=/8zaTUk0BnVa2J8hDxdZEkl8OZGwBzmzq9A3ZT/PfYw=; b=bMiKxb8zfFn6v1B4IR+KfLysRcMJ1Lr6yAiSMzf+2TixaUxY332f+8eDB5A7r8Q7GU /fZsTA/epa+yZl31H6KQOGw3ipFkB/tkTQvBu9AL5rAAH5i2A9QdRlN1NMa3TwIY9eMZ OgyFEUDObjO+jZ2+BSr3wPrC0l1/Iiprqd/L4= 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=/8zaTUk0BnVa2J8hDxdZEkl8OZGwBzmzq9A3ZT/PfYw=; b=OZllpqjHcHavb014huqhP/uo53npuUwYPe3PIjRIMiSTm3655UwARycRF8Wq5hg4dB yWU0pSIN1nuPMqaY+2jkX2VBQoNjOnbgxTE2MkQ0lBorjpXsoFD20ZZXabOqqTjRUP5d 3ap3M6pWLCu1f7nVpGAUE/gooRwTInODYTcdak3IzWisthIQe/sp5LuV+tA4QT60kcc2 zh9GN7WCb4y4XybvMc8HdlI59EnuUZv9t5xRVnGYQUPe4MhXJg9JQNt2ZO4Xbi8k915M FS2PaM71SynYMii/+NR+WA0mZafDtV2JThhe482K5GLS9Crpp/qPCURcmYnVV3/k35yy dRLg== X-Gm-Message-State: APjAAAWdRTpFhFRNjsWP6pX/7RZmJeFJGLZMtsywN7e4fRp3ptRon4fm fBmhrpC6tqEDEOLLegAHJf0fy1t1dbk= X-Received: by 2002:a63:530e:: with SMTP id h14mr8291121pgb.136.1553663733152; Tue, 26 Mar 2019 22:15:33 -0700 (PDT) Received: from pihsun-z840.tpe.corp.google.com ([2401:fa00:1:10:7889:7a43:f899:134c]) by smtp.googlemail.com with ESMTPSA id k72sm58622609pfb.122.2019.03.26.22.15.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Mar 2019 22:15:32 -0700 (PDT) From: Peter Shih Cc: Pi-Hsun Shih , Lee Jones , Benson Leung , Enric Balletbo i Serra , Guenter Roeck , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v7 7/7] cros_ec: differentiate SCP from EC by feature bit. Date: Wed, 27 Mar 2019 13:14:49 +0800 Message-Id: <20190327051450.16222-8-pihsun@chromium.org> X-Mailer: git-send-email 2.21.0.392.gf8f6787159e-goog In-Reply-To: <20190327051450.16222-1-pihsun@chromium.org> References: <20190327051450.16222-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 From: Pi-Hsun Shih 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. Signed-off-by: Pi-Hsun Shih --- Changes from v6: - No change. Changes from v5: - No change. Changes from v4: - No change. 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 | 10 ++++++++++ include/linux/mfd/cros_ec.h | 1 + include/linux/mfd/cros_ec_commands.h | 2 ++ 3 files changed, 13 insertions(+) diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c index d275deaecb12..da2f2145d31d 100644 --- a/drivers/mfd/cros_ec_dev.c +++ b/drivers/mfd/cros_ec_dev.c @@ -418,6 +418,16 @@ static int ec_device_probe(struct platform_device *pdev) device_initialize(&ec->class_dev); cdev_init(&ec->cdev, &fops); + /* check whether this is actually a SCP rather than an EC */ + 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 8f2a8918bfa3..a971399bad82 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 fc91082d4c35..3e5da6e93b2f 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.21.0.392.gf8f6787159e-goog