mfd: cros_ec_dev: Load lightbar module only present
authorGwendal Grignou <gwendal@chromium.org>
Wed, 26 May 2021 03:45:00 +0000 (20:45 -0700)
committerLee Jones <lee.jones@linaro.org>
Wed, 2 Jun 2021 09:51:18 +0000 (10:51 +0100)
The pixel lightbar is only present on chromebook pixel (link), pixel 2
and pixel C. For the latter two, the EC reports its presence.
Instead of always loading the lightbar driver on all chromebook, only
load it when reported by the EC or Link device.

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Acked-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Tested-by: Stephen Boyd <swboyd@chromium.org>
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
drivers/mfd/cros_ec_dev.c

index d07b43d7c761a86596ed8efe86e3658b157faa6c..a9700436e5e515d62ecf53370dca6e56a508f5fa 100644 (file)
@@ -5,6 +5,7 @@
  * Copyright (C) 2014 Google, Inc.
  */
 
+#include <linux/dmi.h>
 #include <linux/kconfig.h>
 #include <linux/mfd/core.h>
 #include <linux/module.h>
@@ -112,10 +113,13 @@ static const struct cros_feature_to_cells cros_subdevices[] = {
 static const struct mfd_cell cros_ec_platform_cells[] = {
        { .name = "cros-ec-chardev", },
        { .name = "cros-ec-debugfs", },
-       { .name = "cros-ec-lightbar", },
        { .name = "cros-ec-sysfs", },
 };
 
+static const struct mfd_cell cros_ec_lightbar_cells[] = {
+       { .name = "cros-ec-lightbar", }
+};
+
 static const struct mfd_cell cros_ec_vbc_cells[] = {
        { .name = "cros-ec-vbc", }
 };
@@ -206,6 +210,20 @@ static int ec_device_probe(struct platform_device *pdev)
                }
        }
 
+       /*
+        * Lightbar is a special case. Newer devices support autodetection,
+        * but older ones do not.
+        */
+       if (cros_ec_check_features(ec, EC_FEATURE_LIGHTBAR) ||
+           dmi_match(DMI_PRODUCT_NAME, "Link")) {
+               retval = mfd_add_hotplug_devices(ec->dev,
+                                       cros_ec_lightbar_cells,
+                                       ARRAY_SIZE(cros_ec_lightbar_cells));
+               if (retval)
+                       dev_warn(ec->dev, "failed to add lightbar: %d\n",
+                                retval);
+       }
+
        /*
         * The PD notifier driver cell is separate since it only needs to be
         * explicitly added on platforms that don't have the PD notifier ACPI