Commit 435a3d78 authored by Andrei Kuchynski's avatar Andrei Kuchynski Committed by Tzung-Bi Shih
Browse files

platform/chrome: cros_ec_sysfs: Expose AP_MODE_ENTRY feature state



This adds sysfs attribute /sys/class/chromeos/cros_ec/ap_mode_entry
to expose the status of the AP_MODE_ENTRY feature. This attribute
indicate whether the EC requires direction from the Application
Processor (AP) before entering Type-C alternate modes or USB4 mode.
This allows user-space applications to easily determine if the AP needs
to be involved in mode entry.

Signed-off-by: default avatarAndrei Kuchynski <akuchynski@chromium.org>
Link: https://lore.kernel.org/r/20250203125947.2701106-3-akuchynski@chromium.org


Signed-off-by: default avatarTzung-Bi Shih <tzungbi@kernel.org>
parent e6a3215f
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -44,3 +44,10 @@ Description:
		- "SAFE": DP is in safe mode
		- "TBT": TBT enabled
		- "USB4": USB4 enabled

What:		/sys/class/chromeos/cros_ec/ap_mode_entry
Date:		February 2025
Description:
		Show if the AP mode entry EC feature is supported.
		It indicates whether the EC waits for direction from the AP
		to enter Type-C altmodes or USB4 mode.
+14 −1
Original line number Diff line number Diff line
@@ -345,6 +345,16 @@ static ssize_t usbpdmuxinfo_show(struct device *dev,
	return count ? : -EIO;
}

static ssize_t ap_mode_entry_show(struct device *dev,
			      struct device_attribute *attr, char *buf)
{
	struct cros_ec_dev *ec = to_cros_ec_dev(dev);
	const bool ap_driven_altmode = cros_ec_check_features(
		ec, EC_FEATURE_TYPEC_REQUIRE_AP_MODE_ENTRY);

	return sysfs_emit(buf, "%s\n", ap_driven_altmode ? "yes" : "no");
}

/* Module initialization */

static DEVICE_ATTR_RW(reboot);
@@ -352,6 +362,7 @@ static DEVICE_ATTR_RO(version);
static DEVICE_ATTR_RO(flashinfo);
static DEVICE_ATTR_RW(kb_wake_angle);
static DEVICE_ATTR_RO(usbpdmuxinfo);
static DEVICE_ATTR_RO(ap_mode_entry);

static struct attribute *__ec_attrs[] = {
	&dev_attr_kb_wake_angle.attr,
@@ -359,6 +370,7 @@ static struct attribute *__ec_attrs[] = {
	&dev_attr_version.attr,
	&dev_attr_flashinfo.attr,
	&dev_attr_usbpdmuxinfo.attr,
	&dev_attr_ap_mode_entry.attr,
	NULL,
};

@@ -371,7 +383,8 @@ static umode_t cros_ec_ctrl_visible(struct kobject *kobj,
	if (a == &dev_attr_kb_wake_angle.attr && !ec->has_kb_wake_angle)
		return 0;

	if (a == &dev_attr_usbpdmuxinfo.attr) {
	if (a == &dev_attr_usbpdmuxinfo.attr ||
		a == &dev_attr_ap_mode_entry.attr) {
		struct cros_ec_platform *ec_platform = dev_get_platdata(ec->dev);

		if (strcmp(ec_platform->ec_name, CROS_EC_DEV_NAME))