Skip to content

Commit

Permalink
Merge tag 'chrome-platform-v6.15' of git://git.kernel.org/pub/scm/lin…
Browse files Browse the repository at this point in the history
…ux/kernel/git/chrome-platform/linux

Pull chrome platform updates from Tzung-Bi Shih:

 - Support ACPI match for Framework systems

  - Expose new sysfs for:
     - PD mux status for each EC-managed Type-C port
     - EC feature of AP mode entry
     - Setting USB mode of EC Type-C

* tag 'chrome-platform-v6.15' of git://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux:
  platform/chrome: cros_ec_typec: Add support for setting USB mode via sysfs
  platform/chrome: cros_ec_sysfs: Expose AP_MODE_ENTRY feature state
  platform/chrome: cros_ec_sysfs: Expose PD mux status
  platform/chrome: cros_ec_lpc: Match on Framework ACPI device
  MAINTAINERS: Update maintainers for ChromeOS USBC related drivers
  • Loading branch information
Linus Torvalds committed Mar 26, 2025
2 parents 2a2274e + 9fc8337 commit b23d8a0
Show file tree
Hide file tree
Showing 6 changed files with 141 additions and 10 deletions.
20 changes: 20 additions & 0 deletions Documentation/ABI/testing/sysfs-class-chromeos
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,23 @@ Date: August 2015
KernelVersion: 4.2
Description:
Show the information about the EC software and hardware.

What: /sys/class/chromeos/cros_ec/usbpdmuxinfo
Date: February 2025
Description:
Show PD mux status for each typec port with following flags:
- "USB": USB connected
- "DP": DP connected
- "POLARITY": CC line Polarity inverted
- "HPD_IRQ": Hot Plug Detect interrupt is asserted
- "HPD_LVL": Hot Plug Detect level is asserted
- "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.
9 changes: 7 additions & 2 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -5485,16 +5485,19 @@ S: Maintained
F: drivers/platform/chrome/cros_ec_uart.c

CHROMEOS EC USB PD NOTIFY DRIVER
M: Prashant Malani <pmalani@chromium.org>
M: Łukasz Bartosik <ukaszb@chromium.org>
M: Andrei Kuchynski <akuchynski@chromium.org>
M: Jameson Thies <jthies@google.com>
L: chrome-platform@lists.linux.dev
S: Maintained
F: drivers/platform/chrome/cros_usbpd_notify.c
F: include/linux/platform_data/cros_usbpd_notify.h

CHROMEOS EC USB TYPE-C DRIVER
M: Prashant Malani <pmalani@chromium.org>
M: Benson Leung <bleung@chromium.org>
M: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
M: Jameson Thies <jthies@google.com>
M: Andrei Kuchynski <akuchynski@chromium.org>
L: chrome-platform@lists.linux.dev
S: Maintained
F: drivers/platform/chrome/cros_ec_typec.*
Expand All @@ -5517,6 +5520,8 @@ F: drivers/watchdog/cros_ec_wdt.c
CHROMEOS UCSI DRIVER
M: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
M: Łukasz Bartosik <ukaszb@chromium.org>
M: Jameson Thies <jthies@google.com>
M: Andrei Kuchynski <akuchynski@chromium.org>
L: chrome-platform@lists.linux.dev
S: Maintained
F: drivers/usb/typec/ucsi/cros_ec_ucsi.c
Expand Down
22 changes: 14 additions & 8 deletions drivers/platform/chrome/cros_ec_lpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#define DRV_NAME "cros_ec_lpcs"
#define ACPI_DRV_NAME "GOOG0004"
#define FRMW_ACPI_DRV_NAME "FRMWC004"

/* True if ACPI device is present */
static bool cros_ec_lpc_acpi_device_found;
Expand Down Expand Up @@ -514,7 +515,7 @@ static int cros_ec_lpc_probe(struct platform_device *pdev)
acpi_status status;
struct cros_ec_device *ec_dev;
struct cros_ec_lpc *ec_lpc;
struct lpc_driver_data *driver_data;
const struct lpc_driver_data *driver_data;
u8 buf[2] = {};
int irq, ret;
u32 quirks;
Expand All @@ -526,6 +527,9 @@ static int cros_ec_lpc_probe(struct platform_device *pdev)
ec_lpc->mmio_memory_base = EC_LPC_ADDR_MEMMAP;

driver_data = platform_get_drvdata(pdev);
if (!driver_data)
driver_data = acpi_device_get_match_data(dev);

if (driver_data) {
quirks = driver_data->quirks;

Expand Down Expand Up @@ -696,12 +700,6 @@ static void cros_ec_lpc_remove(struct platform_device *pdev)
cros_ec_unregister(ec_dev);
}

static const struct acpi_device_id cros_ec_lpc_acpi_device_ids[] = {
{ ACPI_DRV_NAME, 0 },
{ }
};
MODULE_DEVICE_TABLE(acpi, cros_ec_lpc_acpi_device_ids);

static const struct lpc_driver_data framework_laptop_npcx_lpc_driver_data __initconst = {
.quirks = CROS_EC_LPC_QUIRK_REMAP_MEMORY,
.quirk_mmio_memory_base = 0xE00,
Expand All @@ -713,6 +711,13 @@ static const struct lpc_driver_data framework_laptop_mec_lpc_driver_data __initc
.quirk_aml_mutex_name = "ECMT",
};

static const struct acpi_device_id cros_ec_lpc_acpi_device_ids[] = {
{ ACPI_DRV_NAME, 0 },
{ FRMW_ACPI_DRV_NAME, (kernel_ulong_t)&framework_laptop_npcx_lpc_driver_data },
{ }
};
MODULE_DEVICE_TABLE(acpi, cros_ec_lpc_acpi_device_ids);

static const struct dmi_system_id cros_ec_lpc_dmi_table[] __initconst = {
{
/*
Expand Down Expand Up @@ -866,7 +871,8 @@ static int __init cros_ec_lpc_init(void)
int ret;
const struct dmi_system_id *dmi_match;

cros_ec_lpc_acpi_device_found = !!cros_ec_lpc_get_device(ACPI_DRV_NAME);
cros_ec_lpc_acpi_device_found = !!cros_ec_lpc_get_device(ACPI_DRV_NAME) ||
!!cros_ec_lpc_get_device(FRMW_ACPI_DRV_NAME);

dmi_match = dmi_first_match(cros_ec_lpc_dmi_table);

Expand Down
71 changes: 71 additions & 0 deletions drivers/platform/chrome/cros_ec_sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,18 +296,81 @@ static ssize_t kb_wake_angle_store(struct device *dev,
return count;
}

static ssize_t usbpdmuxinfo_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct cros_ec_dev *ec = to_cros_ec_dev(dev);
ssize_t count = 0;
struct ec_response_usb_pd_ports resp_pd_ports;
int ret;
int i;

ret = cros_ec_cmd(ec->ec_dev, 0, EC_CMD_USB_PD_PORTS, NULL, 0,
&resp_pd_ports, sizeof(resp_pd_ports));
if (ret < 0)
return -EIO;

for (i = 0; i < resp_pd_ports.num_ports; i++) {
struct ec_response_usb_pd_mux_info resp_mux;
struct ec_params_usb_pd_mux_info req = {
.port = i,
};

ret = cros_ec_cmd(ec->ec_dev, 0, EC_CMD_USB_PD_MUX_INFO,
&req, sizeof(req), &resp_mux, sizeof(resp_mux));

if (ret >= 0) {
count += sysfs_emit_at(buf, count, "Port %d:", i);
count += sysfs_emit_at(buf, count, " USB=%d",
!!(resp_mux.flags & USB_PD_MUX_USB_ENABLED));
count += sysfs_emit_at(buf, count, " DP=%d",
!!(resp_mux.flags & USB_PD_MUX_DP_ENABLED));
count += sysfs_emit_at(buf, count, " POLARITY=%s",
(resp_mux.flags & USB_PD_MUX_POLARITY_INVERTED) ?
"INVERTED" : "NORMAL");
count += sysfs_emit_at(buf, count, " HPD_IRQ=%d",
!!(resp_mux.flags & USB_PD_MUX_HPD_IRQ));
count += sysfs_emit_at(buf, count, " HPD_LVL=%d",
!!(resp_mux.flags & USB_PD_MUX_HPD_LVL));
count += sysfs_emit_at(buf, count, " SAFE=%d",
!!(resp_mux.flags & USB_PD_MUX_SAFE_MODE));
count += sysfs_emit_at(buf, count, " TBT=%d",
!!(resp_mux.flags & USB_PD_MUX_TBT_COMPAT_ENABLED));
count += sysfs_emit_at(buf, count, " USB4=%d\n",
!!(resp_mux.flags & USB_PD_MUX_USB4_ENABLED));
}
}

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);
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,
&dev_attr_reboot.attr,
&dev_attr_version.attr,
&dev_attr_flashinfo.attr,
&dev_attr_usbpdmuxinfo.attr,
&dev_attr_ap_mode_entry.attr,
NULL,
};

Expand All @@ -320,6 +383,14 @@ 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 ||
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))
return 0;
}

return a->mode;
}

Expand Down
28 changes: 28 additions & 0 deletions drivers/platform/chrome/cros_ec_typec.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,24 @@ static void cros_typec_role_switch_quirk(struct fwnode_handle *fwnode)
#endif
}

static int cros_typec_enter_usb_mode(struct typec_port *tc_port, enum usb_mode mode)
{
struct cros_typec_port *port = typec_get_drvdata(tc_port);
struct ec_params_typec_control req = {
.port = port->port_num,
.command = (mode == USB_MODE_USB4) ?
TYPEC_CONTROL_COMMAND_ENTER_MODE : TYPEC_CONTROL_COMMAND_EXIT_MODES,
.mode_to_enter = CROS_EC_ALTMODE_USB4
};

return cros_ec_cmd(port->typec_data->ec, 0, EC_CMD_TYPEC_CONTROL,
&req, sizeof(req), NULL, 0);
}

static const struct typec_operations cros_typec_usb_mode_ops = {
.enter_usb_mode = cros_typec_enter_usb_mode
};

static int cros_typec_parse_port_props(struct typec_capability *cap,
struct fwnode_handle *fwnode,
struct device *dev)
Expand Down Expand Up @@ -84,6 +102,13 @@ static int cros_typec_parse_port_props(struct typec_capability *cap,
cap->prefer_role = ret;
}

if (fwnode_property_present(fwnode, "usb2-port"))
cap->usb_capability |= USB_CAPABILITY_USB2;
if (fwnode_property_present(fwnode, "usb3-port"))
cap->usb_capability |= USB_CAPABILITY_USB3;
if (fwnode_property_present(fwnode, "usb4-port"))
cap->usb_capability |= USB_CAPABILITY_USB4;

cros_typec_role_switch_quirk(fwnode);

cap->fwnode = fwnode;
Expand Down Expand Up @@ -379,6 +404,9 @@ static int cros_typec_init_ports(struct cros_typec_data *typec)
if (ret < 0)
goto unregister_ports;

cap->driver_data = cros_port;
cap->ops = &cros_typec_usb_mode_ops;

cros_port->port = typec_register_port(dev, cap);
if (IS_ERR(cros_port->port)) {
ret = PTR_ERR(cros_port->port);
Expand Down
1 change: 1 addition & 0 deletions drivers/platform/chrome/cros_ec_typec.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
enum {
CROS_EC_ALTMODE_DP = 0,
CROS_EC_ALTMODE_TBT,
CROS_EC_ALTMODE_USB4,
CROS_EC_ALTMODE_MAX,
};

Expand Down

0 comments on commit b23d8a0

Please sign in to comment.