Skip to content

Commit 435a3d7

Browse files
Andrei KuchynskiTzung-Bi Shih
authored andcommitted
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 <akuchynski@chromium.org> Link: https://lore.kernel.org/r/20250203125947.2701106-3-akuchynski@chromium.org Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
1 parent e6a3215 commit 435a3d7

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

Documentation/ABI/testing/sysfs-class-chromeos

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,10 @@ Description:
4444
- "SAFE": DP is in safe mode
4545
- "TBT": TBT enabled
4646
- "USB4": USB4 enabled
47+
48+
What: /sys/class/chromeos/cros_ec/ap_mode_entry
49+
Date: February 2025
50+
Description:
51+
Show if the AP mode entry EC feature is supported.
52+
It indicates whether the EC waits for direction from the AP
53+
to enter Type-C altmodes or USB4 mode.

drivers/platform/chrome/cros_ec_sysfs.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,20 +345,32 @@ static ssize_t usbpdmuxinfo_show(struct device *dev,
345345
return count ? : -EIO;
346346
}
347347

348+
static ssize_t ap_mode_entry_show(struct device *dev,
349+
struct device_attribute *attr, char *buf)
350+
{
351+
struct cros_ec_dev *ec = to_cros_ec_dev(dev);
352+
const bool ap_driven_altmode = cros_ec_check_features(
353+
ec, EC_FEATURE_TYPEC_REQUIRE_AP_MODE_ENTRY);
354+
355+
return sysfs_emit(buf, "%s\n", ap_driven_altmode ? "yes" : "no");
356+
}
357+
348358
/* Module initialization */
349359

350360
static DEVICE_ATTR_RW(reboot);
351361
static DEVICE_ATTR_RO(version);
352362
static DEVICE_ATTR_RO(flashinfo);
353363
static DEVICE_ATTR_RW(kb_wake_angle);
354364
static DEVICE_ATTR_RO(usbpdmuxinfo);
365+
static DEVICE_ATTR_RO(ap_mode_entry);
355366

356367
static struct attribute *__ec_attrs[] = {
357368
&dev_attr_kb_wake_angle.attr,
358369
&dev_attr_reboot.attr,
359370
&dev_attr_version.attr,
360371
&dev_attr_flashinfo.attr,
361372
&dev_attr_usbpdmuxinfo.attr,
373+
&dev_attr_ap_mode_entry.attr,
362374
NULL,
363375
};
364376

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

374-
if (a == &dev_attr_usbpdmuxinfo.attr) {
386+
if (a == &dev_attr_usbpdmuxinfo.attr ||
387+
a == &dev_attr_ap_mode_entry.attr) {
375388
struct cros_ec_platform *ec_platform = dev_get_platdata(ec->dev);
376389

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

0 commit comments

Comments
 (0)