Skip to contentSkip to conversation

platform/chrome: cros_usbpd_logger: fail probe if HC not supported

PATCH In review Daniel Schaefer 2 participants 3 messages Feb 20, 2025 – Mar 3, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 platform/chrome: cros_usbpd_logger: fail probe if HC not supported

If the EC_CMD_PD_GET_LOG_ENTRY does not exist, the driver does not need to stay active.

Framework Computer systems don't use the PD infrastructure in the chrome EC firmware, so it does not support this host command.

Previously the driver probe would always succeed and periodically keep trying to use this host command, resulting in unnecessary EC traffic and EC log error messages.

Cc Benson Leung <[email protected]>
Cc Tzung-Bi Shih <[email protected]>
Cc Dustin L. Howett <[email protected]>

---

With this patch the following dmesg log appears on Framework systems.

[   25.171086] cros-usbpd-logger cros-usbpd-logger.8.auto: host command not supported.
 drivers/platform/chrome/cros_usbpd_logger.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/platform/chrome/cros_usbpd_logger.c +5 -0
index 7ce75e2e039e..df6b1d97589a 100644
@@ -207,6 +207,11 @@ static int cros_usbpd_logger_probe(struct platform_device *pd)
 	logger->dev = dev;
 	logger->ec_dev = ec_dev;
 
+	if (-EOPNOTSUPP == PTR_ERR(ec_get_log_entry(logger))) {
+		dev_info(dev, "host command not supported.\n");
+		return -ENODEV;
+	}
+
 	platform_set_drvdata(pd, logger);
 
 	/* Retrieve PD event logs periodically */
Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 5 lines · Daniel Schaefer

If the EC_CMD_PD_GET_LOG_ENTRY does not exist, the driver does not need to stay active.

Framework Computer systems don't use the PD infrastructure in the chrome EC firmware, so it does not support this host command.

Does the firmware still report EC_FEATURE_USB_PD feature [1]? Similarly, do "cros-charge-control" and "cros-usbpd-charger" need to stay active [2]?

[1]: https://elixir.bootlin.com/linux/v6.13/source/drivers/mfd/cros_ec_dev.c#L263
[2]: https://elixir.bootlin.com/linux/v6.13/source/drivers/mfd/cros_ec_dev.c#L89

#2 lore raw

You are right, if we remove this feature, the driver won't load. So we don't need this kernel patch.
We found there's a bug in Chrome EC where it enables this feature, even when the Kconfig is turned off.
We're including this patch in our future Framework EC builds:
https://github.com/FrameworkComputer/EmbeddedController/commit/57030a466bb7e130313cf2b2a305a753e9c9a55e

Quoted 13 lines · Tzung-Bi Shih
Quoted 5 lines · Daniel Schaefer

If the EC_CMD_PD_GET_LOG_ENTRY does not exist, the driver does not need to stay active.

Framework Computer systems don't use the PD infrastructure in the chrome EC firmware, so it does not support this host command.

Does the firmware still report EC_FEATURE_USB_PD feature [1]? Similarly, do "cros-charge-control" and "cros-usbpd-charger" need to stay active [2]?

[1]: https://elixir.bootlin.com/linux/v6.13/source/drivers/mfd/cros_ec_dev.c#L263
[2]: https://elixir.bootlin.com/linux/v6.13/source/drivers/mfd/cros_ec_dev.c#L89