Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp149609yba; Fri, 12 Apr 2019 00:22:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqzJ5rv6RiOmxCxTGhr02XiX8zssWNn9XcXEShLiqaB6GESRKcqd30QUNsWeYUd+LrstL//7 X-Received: by 2002:a63:5947:: with SMTP id j7mr50692785pgm.62.1555053745749; Fri, 12 Apr 2019 00:22:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555053745; cv=none; d=google.com; s=arc-20160816; b=wuVxkfDJCcklYVzlAceCbVE39EMLEyGiBHGTv2tvVExk89LK/9mm2pw1ciE3DM7yPG NxOP1g/1znfLWowhWahFp1S6k37YneEkKDQsACMz7Lk2nDbKw1rggTEQD045QYdHZbZE srQ7kAYL4PyS9CiPTJLHPONSq2csWJb/WtkDBwzo0vovI9wxnC63TQ9mk7QCAJW3XYQP l6wVo3iUbKC/XCJXrzhFGEbxTvErRmI74U3m6rwddITn7nCtAxkqosbymucsfgTuQfVC GeRie00V1dpqtjqVbkbYkD9VR5zK1MKVkxn63h+c33X8NmN2KWQt2SCgXiNJCMc3yxDu 1z8A== 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=bIIDGU5Rwf2fFuegJzHqGLPfs4xhEbyGoQqnP916+kk=; b=smzeCDUijDpWfz0u1h4fnZF6cpMt60YYVJ1Y1E0C/ViDOxN1Kx8mFEEqmMoAfaEtRE nBX4rzqKKOn9itUo3lIXl7Vql2DZtXrWcdIKXj6rKKsqEoyXvJlUSapqzbUGSLAaGT3A nIhdXoab582r1453EcAdOZQydfh/JG5QZQtGpMIipwMsUMUWfOPAN3x1dSeSq0U4RLfG l7DCe4qn4vICCUNwtcSEThSMvtj7oSg2Xh1dATKHMHRRy/wbovV4PzdQQzFlSdLNLdqx g70O7faSBd642/3y/QxSjhsOlhhl2KOAnMyuf1irVryLqzwdwq5HW3woFr+fT2GMAVtK jI/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@chromium.org header.s=google header.b=l3YyFirG; 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 j127si35734967pfb.25.2019.04.12.00.22.09; Fri, 12 Apr 2019 00:22:25 -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=l3YyFirG; 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 S1727230AbfDLHT7 (ORCPT + 99 others); Fri, 12 Apr 2019 03:19:59 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:37770 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727204AbfDLHT4 (ORCPT ); Fri, 12 Apr 2019 03:19:56 -0400 Received: by mail-pl1-f196.google.com with SMTP id w23so4675873ply.4 for ; Fri, 12 Apr 2019 00:19:55 -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=bIIDGU5Rwf2fFuegJzHqGLPfs4xhEbyGoQqnP916+kk=; b=l3YyFirGkLQLSxIFRy9SRpGNBcYwgZAGQN3KdHBQFf913ZChc1dlAhdZhWra6L6+/p tLEitNFN+U856bF2RSWqypLr4RBVDYgYilsj1OGQF3IDuV8EQSRwabC5WXXiYwlNBwar 20m+SkRbOLcTcMPEJxj7357gufpRqpBPK2rpA= 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=bIIDGU5Rwf2fFuegJzHqGLPfs4xhEbyGoQqnP916+kk=; b=kIDurCcO5BEwIvNodNu3dHlceGarBv94l9mheop9u34Y/6PJ/vVMH0O5HtrJgOW6wc JI8muwuJFG/4gL7P/kstK3pHJKq+EsbsneN76pFLmH/0g4eqjvMbl75Kle0y08dDPj/y DvKYhebVnzINwsSu1TyKUWOBO1ZVFwLr2XNtvY9uVYGTS/gcuUuL3RBLKZVPEEqqMqM1 t19rtw/WKVSXtxwRDqtINO+tlW40KYGC/j42k3CXEajaJauq5obH/cIdbiorL21WfR7c XOPqtKKYLQ7Aef6rWlj0Ey9OgTwYpZoXriZfee7r56Rntqq2K2U+iYi3XbQRlvk5JbD2 yzXg== X-Gm-Message-State: APjAAAWAb8KD1co6hkZJLXq525sDMOdeHXWNws7c4OALgHg3wQlJzSRF SHDRibRjiQ4etIefbW9dIxSttG68MtAKAA== X-Received: by 2002:a17:902:8bc3:: with SMTP id r3mr56525988plo.53.1555053595367; Fri, 12 Apr 2019 00:19:55 -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 k124sm67466862pgc.65.2019.04.12.00.19.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Apr 2019 00:19:54 -0700 (PDT) From: Pi-Hsun Shih Cc: Pi-Hsun Shih , Lee Jones , Benson Leung , Enric Balletbo i Serra , Guenter Roeck , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v8 7/7] mfd: cros_ec: differentiate SCP from EC by feature bit. Date: Fri, 12 Apr 2019 15:18:51 +0800 Message-Id: <20190412071851.60332-8-pihsun@chromium.org> X-Mailer: git-send-email 2.21.0.392.gf8f6787159e-goog In-Reply-To: <20190412071851.60332-1-pihsun@chromium.org> References: <20190412071851.60332-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 System Companion Processor (SCP) is Cortex M4 co-processor on some MediaTek platform that can run EC-style firmware. 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 v7: - Address comments in v7. - Rebase the series onto https://lore.kernel.org/patchwork/patch/1059196/. 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, 12 insertions(+), 1 deletion(-) diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c index a3b319913097..5b52b648abf2 100644 --- a/drivers/mfd/cros_ec_dev.c +++ b/drivers/mfd/cros_ec_dev.c @@ -432,6 +432,16 @@ static int ec_device_probe(struct platform_device *pdev) ec_platform->ec_name = CROS_EC_DEV_ISH_NAME; } + /* Check whether this is actually a SCP rather than an EC. */ + if (cros_ec_check_features(ec, EC_FEATURE_SCP)) { + dev_info(dev, "CrOS SCP MCU 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 109292a60499..a3e3d6beb19a 100644 --- a/include/linux/mfd/cros_ec.h +++ b/include/linux/mfd/cros_ec.h @@ -25,6 +25,7 @@ #define CROS_EC_DEV_NAME "cros_ec" #define CROS_EC_DEV_PD_NAME "cros_pd" #define CROS_EC_DEV_ISH_NAME "cros_ish" +#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 d5bf909af661..80a904ed7d7f 100644 --- a/include/linux/mfd/cros_ec_commands.h +++ b/include/linux/mfd/cros_ec_commands.h @@ -884,7 +884,7 @@ enum ec_feature_code { EC_FEATURE_REFINED_TABLET_MODE_HYSTERESIS = 37, /* EC supports audio codec. */ EC_FEATURE_AUDIO_CODEC = 38, - /* EC Supports SCP. */ + /* The MCU is a System Companion Processor (SCP). */ EC_FEATURE_SCP = 39, /* The MCU is an Integrated Sensor Hub */ EC_FEATURE_ISH = 40, -- 2.21.0.392.gf8f6787159e-goog