mfd: cros_ec: differentiate SCP from EC by feature bit
authorPi-Hsun Shih <pihsun@chromium.org>
Mon, 3 Jun 2019 03:45:11 +0000 (11:45 +0800)
committerLee Jones <lee.jones@linaro.org>
Tue, 2 Jul 2019 11:11:31 +0000 (12:11 +0100)
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>
Acked-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
drivers/mfd/cros_ec_dev.c
include/linux/mfd/cros_ec.h

index d992365472b8d817522c39f99c4e4c955f486acd..a47223d2baf4cabd6deec1eda1df7186f4256dd9 100644 (file)
@@ -459,6 +459,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
index cfa78bb4990f7547470e9ebcfd0183ad13295e77..751cb3756d49c035eafc43f60c9b112c974bc1a1 100644 (file)
@@ -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