aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Boyd <swboyd@chromium.org>2022-04-18 17:04:08 -0700
committerLee Jones <lee.jones@linaro.org>2022-04-26 19:23:24 +0100
commitff23a46e4657a4ac2d2f4a481ca8e1e45a892136 (patch)
treef541ca200a272c57aec14e5d3988c3c29ec00eb8
parentmfd: mt6397-core: Add resources for PMIC keys for MT6359 (diff)
downloadlinux-dev-ff23a46e4657a4ac2d2f4a481ca8e1e45a892136.tar.xz
linux-dev-ff23a46e4657a4ac2d2f4a481ca8e1e45a892136.zip
mfd: cros_ec_dev: Only register PCHG device if present
Don't create a device for the peripheral charger (PCHG) if there aren't any peripheral charger ports. This removes a device on most ChromeOS systems, because the peripheral charger functionality isn't always present. Cc: Prashant Malani <pmalani@chromium.org> Cc: Tzung-Bi Shih <tzungbi@kernel.org> Cc: Daisuke Nojiri <dnojiri@chromium.org> Cc: Benson Leung <bleung@chromium.org> Cc: Guenter Roeck <groeck@chromium.org> Cc: <chrome-platform@lists.linux.dev> Signed-off-by: Stephen Boyd <swboyd@chromium.org> Reviewed-by: Prashant Malani <pmalani@chromium.org> Signed-off-by: Lee Jones <lee.jones@linaro.org> Link: https://lore.kernel.org/r/20220419000408.3202635-1-swboyd@chromium.org
-rw-r--r--drivers/mfd/cros_ec_dev.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c
index 546feef851ab..596731caf407 100644
--- a/drivers/mfd/cros_ec_dev.c
+++ b/drivers/mfd/cros_ec_dev.c
@@ -114,6 +114,9 @@ static const struct mfd_cell cros_ec_platform_cells[] = {
{ .name = "cros-ec-chardev", },
{ .name = "cros-ec-debugfs", },
{ .name = "cros-ec-sysfs", },
+};
+
+static const struct mfd_cell cros_ec_pchg_cells[] = {
{ .name = "cros-ec-pchg", },
};
@@ -137,6 +140,7 @@ static int ec_device_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
struct cros_ec_platform *ec_platform = dev_get_platdata(dev);
struct cros_ec_dev *ec = kzalloc(sizeof(*ec), GFP_KERNEL);
+ struct ec_response_pchg_count pchg_count;
int i;
if (!ec)
@@ -243,6 +247,21 @@ static int ec_device_probe(struct platform_device *pdev)
}
/*
+ * The PCHG device cannot be detected by sending EC_FEATURE_GET_CMD, but
+ * it can be detected by querying the number of peripheral chargers.
+ */
+ retval = cros_ec_command(ec->ec_dev, 0, EC_CMD_PCHG_COUNT, NULL, 0,
+ &pchg_count, sizeof(pchg_count));
+ if (retval >= 0 && pchg_count.port_count) {
+ retval = mfd_add_hotplug_devices(ec->dev,
+ cros_ec_pchg_cells,
+ ARRAY_SIZE(cros_ec_pchg_cells));
+ if (retval)
+ dev_warn(ec->dev, "failed to add pchg: %d\n",
+ retval);
+ }
+
+ /*
* The following subdevices cannot be detected by sending the
* EC_FEATURE_GET_CMD to the Embedded Controller device.
*/