Skip to content

Commit b23d8a0

Browse files
committed
Merge tag 'chrome-platform-v6.15' of git://git.kernel.org/pub/scm/linux/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
2 parents 2a2274e + 9fc8337 commit b23d8a0

File tree

6 files changed

+141
-10
lines changed

6 files changed

+141
-10
lines changed

Documentation/ABI/testing/sysfs-class-chromeos

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,23 @@ Date: August 2015
3131
KernelVersion: 4.2
3232
Description:
3333
Show the information about the EC software and hardware.
34+
35+
What: /sys/class/chromeos/cros_ec/usbpdmuxinfo
36+
Date: February 2025
37+
Description:
38+
Show PD mux status for each typec port with following flags:
39+
- "USB": USB connected
40+
- "DP": DP connected
41+
- "POLARITY": CC line Polarity inverted
42+
- "HPD_IRQ": Hot Plug Detect interrupt is asserted
43+
- "HPD_LVL": Hot Plug Detect level is asserted
44+
- "SAFE": DP is in safe mode
45+
- "TBT": TBT enabled
46+
- "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.

MAINTAINERS

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5485,16 +5485,19 @@ S: Maintained
54855485
F: drivers/platform/chrome/cros_ec_uart.c
54865486

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

54945496
CHROMEOS EC USB TYPE-C DRIVER
5495-
M: Prashant Malani <pmalani@chromium.org>
54965497
M: Benson Leung <bleung@chromium.org>
54975498
M: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
5499+
M: Jameson Thies <jthies@google.com>
5500+
M: Andrei Kuchynski <akuchynski@chromium.org>
54985501
L: chrome-platform@lists.linux.dev
54995502
S: Maintained
55005503
F: drivers/platform/chrome/cros_ec_typec.*
@@ -5517,6 +5520,8 @@ F: drivers/watchdog/cros_ec_wdt.c
55175520
CHROMEOS UCSI DRIVER
55185521
M: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
55195522
M: Łukasz Bartosik <ukaszb@chromium.org>
5523+
M: Jameson Thies <jthies@google.com>
5524+
M: Andrei Kuchynski <akuchynski@chromium.org>
55205525
L: chrome-platform@lists.linux.dev
55215526
S: Maintained
55225527
F: drivers/usb/typec/ucsi/cros_ec_ucsi.c

drivers/platform/chrome/cros_ec_lpc.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
#define DRV_NAME "cros_ec_lpcs"
3232
#define ACPI_DRV_NAME "GOOG0004"
33+
#define FRMW_ACPI_DRV_NAME "FRMWC004"
3334

3435
/* True if ACPI device is present */
3536
static bool cros_ec_lpc_acpi_device_found;
@@ -514,7 +515,7 @@ static int cros_ec_lpc_probe(struct platform_device *pdev)
514515
acpi_status status;
515516
struct cros_ec_device *ec_dev;
516517
struct cros_ec_lpc *ec_lpc;
517-
struct lpc_driver_data *driver_data;
518+
const struct lpc_driver_data *driver_data;
518519
u8 buf[2] = {};
519520
int irq, ret;
520521
u32 quirks;
@@ -526,6 +527,9 @@ static int cros_ec_lpc_probe(struct platform_device *pdev)
526527
ec_lpc->mmio_memory_base = EC_LPC_ADDR_MEMMAP;
527528

528529
driver_data = platform_get_drvdata(pdev);
530+
if (!driver_data)
531+
driver_data = acpi_device_get_match_data(dev);
532+
529533
if (driver_data) {
530534
quirks = driver_data->quirks;
531535

@@ -696,12 +700,6 @@ static void cros_ec_lpc_remove(struct platform_device *pdev)
696700
cros_ec_unregister(ec_dev);
697701
}
698702

699-
static const struct acpi_device_id cros_ec_lpc_acpi_device_ids[] = {
700-
{ ACPI_DRV_NAME, 0 },
701-
{ }
702-
};
703-
MODULE_DEVICE_TABLE(acpi, cros_ec_lpc_acpi_device_ids);
704-
705703
static const struct lpc_driver_data framework_laptop_npcx_lpc_driver_data __initconst = {
706704
.quirks = CROS_EC_LPC_QUIRK_REMAP_MEMORY,
707705
.quirk_mmio_memory_base = 0xE00,
@@ -713,6 +711,13 @@ static const struct lpc_driver_data framework_laptop_mec_lpc_driver_data __initc
713711
.quirk_aml_mutex_name = "ECMT",
714712
};
715713

714+
static const struct acpi_device_id cros_ec_lpc_acpi_device_ids[] = {
715+
{ ACPI_DRV_NAME, 0 },
716+
{ FRMW_ACPI_DRV_NAME, (kernel_ulong_t)&framework_laptop_npcx_lpc_driver_data },
717+
{ }
718+
};
719+
MODULE_DEVICE_TABLE(acpi, cros_ec_lpc_acpi_device_ids);
720+
716721
static const struct dmi_system_id cros_ec_lpc_dmi_table[] __initconst = {
717722
{
718723
/*
@@ -866,7 +871,8 @@ static int __init cros_ec_lpc_init(void)
866871
int ret;
867872
const struct dmi_system_id *dmi_match;
868873

869-
cros_ec_lpc_acpi_device_found = !!cros_ec_lpc_get_device(ACPI_DRV_NAME);
874+
cros_ec_lpc_acpi_device_found = !!cros_ec_lpc_get_device(ACPI_DRV_NAME) ||
875+
!!cros_ec_lpc_get_device(FRMW_ACPI_DRV_NAME);
870876

871877
dmi_match = dmi_first_match(cros_ec_lpc_dmi_table);
872878

drivers/platform/chrome/cros_ec_sysfs.c

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,18 +296,81 @@ static ssize_t kb_wake_angle_store(struct device *dev,
296296
return count;
297297
}
298298

299+
static ssize_t usbpdmuxinfo_show(struct device *dev,
300+
struct device_attribute *attr,
301+
char *buf)
302+
{
303+
struct cros_ec_dev *ec = to_cros_ec_dev(dev);
304+
ssize_t count = 0;
305+
struct ec_response_usb_pd_ports resp_pd_ports;
306+
int ret;
307+
int i;
308+
309+
ret = cros_ec_cmd(ec->ec_dev, 0, EC_CMD_USB_PD_PORTS, NULL, 0,
310+
&resp_pd_ports, sizeof(resp_pd_ports));
311+
if (ret < 0)
312+
return -EIO;
313+
314+
for (i = 0; i < resp_pd_ports.num_ports; i++) {
315+
struct ec_response_usb_pd_mux_info resp_mux;
316+
struct ec_params_usb_pd_mux_info req = {
317+
.port = i,
318+
};
319+
320+
ret = cros_ec_cmd(ec->ec_dev, 0, EC_CMD_USB_PD_MUX_INFO,
321+
&req, sizeof(req), &resp_mux, sizeof(resp_mux));
322+
323+
if (ret >= 0) {
324+
count += sysfs_emit_at(buf, count, "Port %d:", i);
325+
count += sysfs_emit_at(buf, count, " USB=%d",
326+
!!(resp_mux.flags & USB_PD_MUX_USB_ENABLED));
327+
count += sysfs_emit_at(buf, count, " DP=%d",
328+
!!(resp_mux.flags & USB_PD_MUX_DP_ENABLED));
329+
count += sysfs_emit_at(buf, count, " POLARITY=%s",
330+
(resp_mux.flags & USB_PD_MUX_POLARITY_INVERTED) ?
331+
"INVERTED" : "NORMAL");
332+
count += sysfs_emit_at(buf, count, " HPD_IRQ=%d",
333+
!!(resp_mux.flags & USB_PD_MUX_HPD_IRQ));
334+
count += sysfs_emit_at(buf, count, " HPD_LVL=%d",
335+
!!(resp_mux.flags & USB_PD_MUX_HPD_LVL));
336+
count += sysfs_emit_at(buf, count, " SAFE=%d",
337+
!!(resp_mux.flags & USB_PD_MUX_SAFE_MODE));
338+
count += sysfs_emit_at(buf, count, " TBT=%d",
339+
!!(resp_mux.flags & USB_PD_MUX_TBT_COMPAT_ENABLED));
340+
count += sysfs_emit_at(buf, count, " USB4=%d\n",
341+
!!(resp_mux.flags & USB_PD_MUX_USB4_ENABLED));
342+
}
343+
}
344+
345+
return count ? : -EIO;
346+
}
347+
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+
299358
/* Module initialization */
300359

301360
static DEVICE_ATTR_RW(reboot);
302361
static DEVICE_ATTR_RO(version);
303362
static DEVICE_ATTR_RO(flashinfo);
304363
static DEVICE_ATTR_RW(kb_wake_angle);
364+
static DEVICE_ATTR_RO(usbpdmuxinfo);
365+
static DEVICE_ATTR_RO(ap_mode_entry);
305366

306367
static struct attribute *__ec_attrs[] = {
307368
&dev_attr_kb_wake_angle.attr,
308369
&dev_attr_reboot.attr,
309370
&dev_attr_version.attr,
310371
&dev_attr_flashinfo.attr,
372+
&dev_attr_usbpdmuxinfo.attr,
373+
&dev_attr_ap_mode_entry.attr,
311374
NULL,
312375
};
313376

@@ -320,6 +383,14 @@ static umode_t cros_ec_ctrl_visible(struct kobject *kobj,
320383
if (a == &dev_attr_kb_wake_angle.attr && !ec->has_kb_wake_angle)
321384
return 0;
322385

386+
if (a == &dev_attr_usbpdmuxinfo.attr ||
387+
a == &dev_attr_ap_mode_entry.attr) {
388+
struct cros_ec_platform *ec_platform = dev_get_platdata(ec->dev);
389+
390+
if (strcmp(ec_platform->ec_name, CROS_EC_DEV_NAME))
391+
return 0;
392+
}
393+
323394
return a->mode;
324395
}
325396

drivers/platform/chrome/cros_ec_typec.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,24 @@ static void cros_typec_role_switch_quirk(struct fwnode_handle *fwnode)
4242
#endif
4343
}
4444

45+
static int cros_typec_enter_usb_mode(struct typec_port *tc_port, enum usb_mode mode)
46+
{
47+
struct cros_typec_port *port = typec_get_drvdata(tc_port);
48+
struct ec_params_typec_control req = {
49+
.port = port->port_num,
50+
.command = (mode == USB_MODE_USB4) ?
51+
TYPEC_CONTROL_COMMAND_ENTER_MODE : TYPEC_CONTROL_COMMAND_EXIT_MODES,
52+
.mode_to_enter = CROS_EC_ALTMODE_USB4
53+
};
54+
55+
return cros_ec_cmd(port->typec_data->ec, 0, EC_CMD_TYPEC_CONTROL,
56+
&req, sizeof(req), NULL, 0);
57+
}
58+
59+
static const struct typec_operations cros_typec_usb_mode_ops = {
60+
.enter_usb_mode = cros_typec_enter_usb_mode
61+
};
62+
4563
static int cros_typec_parse_port_props(struct typec_capability *cap,
4664
struct fwnode_handle *fwnode,
4765
struct device *dev)
@@ -84,6 +102,13 @@ static int cros_typec_parse_port_props(struct typec_capability *cap,
84102
cap->prefer_role = ret;
85103
}
86104

105+
if (fwnode_property_present(fwnode, "usb2-port"))
106+
cap->usb_capability |= USB_CAPABILITY_USB2;
107+
if (fwnode_property_present(fwnode, "usb3-port"))
108+
cap->usb_capability |= USB_CAPABILITY_USB3;
109+
if (fwnode_property_present(fwnode, "usb4-port"))
110+
cap->usb_capability |= USB_CAPABILITY_USB4;
111+
87112
cros_typec_role_switch_quirk(fwnode);
88113

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

407+
cap->driver_data = cros_port;
408+
cap->ops = &cros_typec_usb_mode_ops;
409+
382410
cros_port->port = typec_register_port(dev, cap);
383411
if (IS_ERR(cros_port->port)) {
384412
ret = PTR_ERR(cros_port->port);

drivers/platform/chrome/cros_ec_typec.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
enum {
1919
CROS_EC_ALTMODE_DP = 0,
2020
CROS_EC_ALTMODE_TBT,
21+
CROS_EC_ALTMODE_USB4,
2122
CROS_EC_ALTMODE_MAX,
2223
};
2324

0 commit comments

Comments
 (0)