All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pi-Hsun Shih <pihsun@chromium.org>
To: unlisted-recipients:; (no To-header on input)
Cc: Pi-Hsun Shih <pihsun@chromium.org>,
	Lee Jones <lee.jones@linaro.org>,
	Benson Leung <bleung@chromium.org>,
	Enric Balletbo i Serra <enric.balletbo@collabora.com>,
	Guenter Roeck <groeck@chromium.org>,
	linux-kernel@vger.kernel.org (open list)
Subject: [PATCH v9 6/7] mfd: cros_ec: differentiate SCP from EC by feature bit.
Date: Fri, 31 May 2019 15:38:47 +0800	[thread overview]
Message-ID: <20190531073848.155444-7-pihsun@chromium.org> (raw)
In-Reply-To: <20190531073848.155444-1-pihsun@chromium.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 <pihsun@chromium.org>

---
Changes from v8:
 - No change.

Changes from v7:
 - Address comments in v7.
 - Rebase the series onto https://lore.kernel.org/patchwork/patch/1059196/.

Changes from v6, v5, v4, v3, 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 a5391f96eafd..66107de3dbce 100644
--- a/drivers/mfd/cros_ec_dev.c
+++ b/drivers/mfd/cros_ec_dev.c
@@ -440,6 +440,16 @@ static int ec_device_probe(struct platform_device *pdev)
 		ec_platform->ec_name = CROS_EC_DEV_TP_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 cfa78bb4990f..751cb3756d49 100644
--- a/include/linux/mfd/cros_ec.h
+++ b/include/linux/mfd/cros_ec.h
@@ -27,6 +27,7 @@
 #define CROS_EC_DEV_PD_NAME "cros_pd"
 #define CROS_EC_DEV_TP_NAME "cros_tp"
 #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 dcec96f01879..8b578b4c1ec7 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.22.0.rc1.257.g3120a18244-goog


  parent reply	other threads:[~2019-05-31  7:39 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-31  7:38 [PATCH v9 0/7] Add support for mt8183 SCP Pi-Hsun Shih
2019-05-31  7:38 ` Pi-Hsun Shih
2019-05-31  7:38 ` [PATCH v9 1/7] dt-bindings: Add a binding for Mediatek SCP Pi-Hsun Shih
2019-05-31  7:38   ` Pi-Hsun Shih
2019-05-31  7:38   ` Pi-Hsun Shih
2019-05-31  7:38 ` [PATCH v9 2/7] remoteproc/mediatek: add SCP support for mt8183 Pi-Hsun Shih
2019-05-31  7:38   ` Pi-Hsun Shih
2019-05-31  7:38   ` Pi-Hsun Shih
2019-05-31  7:38 ` [PATCH v9 3/7] remoteproc: mt8183: add reserved memory manager API Pi-Hsun Shih
2019-05-31  7:38   ` Pi-Hsun Shih
2019-05-31  7:38   ` Pi-Hsun Shih
2019-05-31  7:38 ` [PATCH v9 4/7] rpmsg: add rpmsg support for mt8183 SCP Pi-Hsun Shih
2019-05-31  7:38   ` Pi-Hsun Shih
2019-05-31  7:38   ` Pi-Hsun Shih
2019-05-31  7:38 ` [PATCH v9 5/7] dt-bindings: Add binding for cros-ec-rpmsg Pi-Hsun Shih
2019-05-31  7:38   ` Pi-Hsun Shih
2019-06-04 17:57   ` Benson Leung
2019-06-04 17:57     ` Benson Leung
2019-05-31  7:38 ` Pi-Hsun Shih [this message]
2019-05-31  8:54   ` [PATCH v9 6/7] mfd: cros_ec: differentiate SCP from EC by feature bit Enric Balletbo i Serra
2019-06-04 17:55   ` Benson Leung
2019-05-31  7:38 ` [PATCH v9 7/7] arm64: dts: mt8183: add scp node Pi-Hsun Shih
2019-05-31  7:38   ` Pi-Hsun Shih
2019-05-31  7:38   ` Pi-Hsun Shih

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190531073848.155444-7-pihsun@chromium.org \
    --to=pihsun@chromium.org \
    --cc=bleung@chromium.org \
    --cc=enric.balletbo@collabora.com \
    --cc=groeck@chromium.org \
    --cc=lee.jones@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.