From: Vincent Palatin <vpala...@chromium.org>

Support Fingerprint MCU as a special of CrOS EC devices. The current FP
MCU uses the same EC SPI protocol v3 as other CrOS EC devices on a SPI
bus.

When a MCU has fingerprint support (aka EC_FEATURE_FINGERPRINT), it is
instantiated as a special CrOS EC device with device name 'cros_fp'. So
regardless of the probing order between the actual cros_ec and cros_fp,
the userspace and other kernel drivers should not confuse them.

Signed-off-by: Vincent Palatin <vpala...@chromium.org>
Signed-off-by: Enric Balletbo i Serra <enric.balle...@collabora.com>
---

 drivers/mfd/cros_ec_dev.c   | 10 ++++++++++
 include/linux/mfd/cros_ec.h |  1 +
 2 files changed, 11 insertions(+)

diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c
index e6f538eca72b..51b318cbc0ed 100644
--- a/drivers/mfd/cros_ec_dev.c
+++ b/drivers/mfd/cros_ec_dev.c
@@ -644,6 +644,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 Fingerprint MCU rather than an EC */
+       if (cros_ec_check_features(ec, EC_FEATURE_FINGERPRINT)) {
+               dev_info(dev, "CrOS Fingerprint MCU detected.\n");
+               /*
+                * Help userspace differentiating ECs from FP MCU,
+                * regardless of the probing order.
+                */
+               ec_platform->ec_name = CROS_EC_DEV_FP_NAME;
+       }
+
        /*
         * Check whether this is actually an Integrated Sensor Hub (ISH)
         * rather than an EC.
diff --git a/include/linux/mfd/cros_ec.h b/include/linux/mfd/cros_ec.h
index 109292a60499..20fb5f298f73 100644
--- a/include/linux/mfd/cros_ec.h
+++ b/include/linux/mfd/cros_ec.h
@@ -23,6 +23,7 @@
 #include <linux/mutex.h>
 
 #define CROS_EC_DEV_NAME "cros_ec"
+#define CROS_EC_DEV_FP_NAME "cros_fp"
 #define CROS_EC_DEV_PD_NAME "cros_pd"
 #define CROS_EC_DEV_ISH_NAME "cros_ish"
 
-- 
2.20.1

Reply via email to