From: Andrei Kuchynski Date: Mon, 3 Feb 2025 12:59:47 +0000 (+0000) Subject: platform/chrome: cros_ec_sysfs: Expose AP_MODE_ENTRY feature state X-Git-Tag: io_uring-6.15-20250403~98^2~1 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=435a3d78b87a93c52a4f84e36ba4a0857554c958;p=linux-block.git 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: Andrei Kuchynski Link: https://lore.kernel.org/r/20250203125947.2701106-3-akuchynski@chromium.org Signed-off-by: Tzung-Bi Shih --- diff --git a/Documentation/ABI/testing/sysfs-class-chromeos b/Documentation/ABI/testing/sysfs-class-chromeos index e067dbdab170..7fa5be6cc774 100644 --- a/Documentation/ABI/testing/sysfs-class-chromeos +++ b/Documentation/ABI/testing/sysfs-class-chromeos @@ -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. diff --git a/drivers/platform/chrome/cros_ec_sysfs.c b/drivers/platform/chrome/cros_ec_sysfs.c index 93e9ed87249c..f22e9523da3e 100644 --- a/drivers/platform/chrome/cros_ec_sysfs.c +++ b/drivers/platform/chrome/cros_ec_sysfs.c @@ -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))