]> www.infradead.org Git - users/willy/pagecache.git/commitdiff
platform/chrome: cros_ec_sysfs: Expose AP_MODE_ENTRY feature state
authorAndrei Kuchynski <akuchynski@chromium.org>
Mon, 3 Feb 2025 12:59:47 +0000 (12:59 +0000)
committerTzung-Bi Shih <tzungbi@kernel.org>
Wed, 5 Feb 2025 04:03:31 +0000 (04:03 +0000)
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 <akuchynski@chromium.org>
Link: https://lore.kernel.org/r/20250203125947.2701106-3-akuchynski@chromium.org
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
Documentation/ABI/testing/sysfs-class-chromeos
drivers/platform/chrome/cros_ec_sysfs.c

index e067dbdab170a22b1259012fd1f74cd2ffa947da..7fa5be6cc774847a889c79aacc31f7a732b3c2dc 100644 (file)
@@ -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.
index 93e9ed87249cf449ca80895232350ea3c06ad113..f22e9523da3e8a8d88d755bd520be85eeea554b1 100644 (file)
@@ -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))