Skip to contentSkip to conversation

Load cros_ec_ucsi from OF and ACPI definitions

PATCH In review Jameson Thies 3 participants 8 messages Oct 13, 2025 – Nov 6, 2025

Subsystems (6)
lore
Share & tools
lore

Jameson Thies

author maintainer
#0 lore raw

v4 cover Load cros_ec_ucsi from OF and ACPI definitions

The ChromeOS UCSI driver (cros_ec_ucsi) currently gets added as subdevice of cros_ec_dev. But without it being defined by an ACPI node or in the OF device tree, the typec connectors are not correctly associated with other part of the device tree. This series updates the cros_ec_ucsi driver to load based on device definitions in ACPI and OF. It also changes the cros_ec_dev driver to block adding cros_ec_ucsi as a subdevice if it is defined in the device tree.

For context, I initially sent out this series for review in March 2025
(https://lkml.kernel.org/[email protected]/).

Patch 1/3 has been updated to address comments from the initial review. There were some open questions on patch 3/3 regarding adding MFD children when there is no cros_ec_ucsi node and parents conditionally checking if a child exists to create one.

The expected behavior of this series is to only add the cros_ec_ucsi subdevice when there isn't a corresponding FW node because always adding it would result in multiple cros_ec_ucsi devices and too many ports being registered with the USB Type-C connector class on devices with correctly defined FW nodes. It also does not look for a child node to create a child. It is looking for a child of the parent EC device to only add cros_ec_ucsi if it does not already exist as a sibling.

v4 changes:
- added comment in cros_ec_ucsi probe explaining how the parent device depends on how the driver is loaded
- updated commit message of patch 3/3 clarifying the expected why cros_ec_ucsi doesn't need to be added as an mfd subdevice when an OF/ACPI node for cros_ec_ucsi is defined

v3 changes:
- adds cros-ec-ucsi compatibility string to google,cros-ec-typec.yaml instead of defining a new binding.
- updates maintainter list in google,cros-ec-typec.yaml
- cleaned up assignments to udata->ec in cros_ec_ucsi.c
- now using acpi_dev_found() to check for ACPI node in cros_ec_dev.c

v2 changes:
- updated google,cros-ec.yaml to support typec ports defined by google,cros-ec-ucsi.yaml. Tested with make dt_binding_check and dtbs_check

Jameson Thies (3):
dt-bindings: chrome: Add cros-ec-ucsi compatibility to typec binding
usb: typec: cros_ec_ucsi: Load driver from OF and ACPI definitions
mfd: cros_ec: Don't add cros_ec_ucsi if it is defined in OF or ACPI

 .../bindings/chrome/google,cros-ec-typec.yaml | 19 +++++++++++---
 drivers/mfd/cros_ec_dev.c                     | 23 ++++++++++++----
 drivers/usb/typec/ucsi/cros_ec_ucsi.c         | 26 +++++++++++++++++--
 3 files changed, 57 insertions(+), 11 deletions(-)

base-commit: 48633acccf38d706d7b368400647bb9db9caf1ae

Signature · 1 line
2.51.0.858.gf9c4a03a3a-goog
author maintainer
#1 lore raw

PATCH v4 1/3 dt-bindings: chrome: Add cros-ec-ucsi compatibility to typec binding

Chrome OS devices with discrete power delivery controllers (PDCs) allow the host to read port status and control port behavior through a USB Type-C Connector System Software (UCSI) interface with the embedded controller (EC). This uses a separate interface driver than other Chrome OS devices with a Type-C port manager in the EC FW. Those use a host command interface supported by cros-ec-typec. Add a cros-ec-ucsi compatibility string to the existing cros-ec-typec binding.

Additionally, update maintainer list to reflect cros-ec-ucsi and cros-ec-typec driver maintainers.

---
 .../bindings/chrome/google,cros-ec-typec.yaml | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)
Documentation/devicetree/bindings/chrome/google,cros-ec-typec.yaml +15 -4
index 9f9816fbecbc..fd1a459879bd 100644
@@ -8,17 +8,28 @@ title: Google Chrome OS EC(Embedded Controller) Type C port driver.
 
 maintainers:
   - Benson Leung <[email protected]>
-  - Prashant Malani <[email protected]>
+  - Abhishek Pandit-Subedi <[email protected]>
+  - Andrei Kuchynski <[email protected]>
+  - Łukasz Bartosik <[email protected]>
+  - Jameson Thies <[email protected]>
 
 description:
   Chrome OS devices have an Embedded Controller(EC) which has access to
   Type C port state. This node is intended to allow the host to read and
-  control the Type C ports. The node for this device should be under a
-  cros-ec node like google,cros-ec-spi.
+  control the Type C ports. This binding is compatible with both the
+  cros-ec-typec and cros-ec-ucsi drivers. The cros-ec-typec driver
+  supports the host command interface used by the Chrome OS EC with a
+  built-in Type-C port manager and external Type-C Port Controller
+  (TCPC). The cros-ec-ucsi driver supports the USB Type-C Connector
+  System Software (UCSI) interface used by the Chrome OS EC when the
+  platform has a separate power delivery controller (PDC). The node for
+  this device should be under a cros-ec node like google,cros-ec-spi.
 
 properties:
   compatible:
-    const: google,cros-ec-typec
+    enum:
+      - google,cros-ec-typec
+      - google,cros-ec-ucsi
 
   '#address-cells':
     const: 1
Signature · 1 line
2.51.0.858.gf9c4a03a3a-goog
Reviewed-by on v4 1/3
#2 lore raw

Re: [PATCH v4 1/3] dt-bindings: chrome: Add cros-ec-ucsi compatibility to typec binding

Hi Jameson,

Quoted 8 lines · Jameson Thies

Chrome OS devices with discrete power delivery controllers (PDCs) allow the host to read port status and control port behavior through a USB Type-C Connector System Software (UCSI) interface with the embedded controller (EC). This uses a separate interface driver than other Chrome OS devices with a Type-C port manager in the EC FW. Those use a host command interface supported by cros-ec-typec. Add a cros-ec-ucsi compatibility string to the existing cros-ec-typec binding.

Quoted 5 lines

Additionally, update maintainer list to reflect cros-ec-ucsi and cros-ec-typec driver maintainers.

Quoted 44 lines
---
 .../bindings/chrome/google,cros-ec-typec.yaml | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)
Documentation/devicetree/bindings/chrome/google,cros-ec-typec.yaml +15 -4
index 9f9816fbecbc..fd1a459879bd 100644
@@ -8,17 +8,28 @@ title: Google Chrome OS EC(Embedded Controller) Type C port driver.
 
 maintainers:
   - Benson Leung <[email protected]>
-  - Prashant Malani <[email protected]>
+  - Abhishek Pandit-Subedi <[email protected]>
+  - Andrei Kuchynski <[email protected]>
+  - Łukasz Bartosik <[email protected]>
+  - Jameson Thies <[email protected]>
 
 description:
   Chrome OS devices have an Embedded Controller(EC) which has access to
   Type C port state. This node is intended to allow the host to read and
-  control the Type C ports. The node for this device should be under a
-  cros-ec node like google,cros-ec-spi.
+  control the Type C ports. This binding is compatible with both the
+  cros-ec-typec and cros-ec-ucsi drivers. The cros-ec-typec driver
+  supports the host command interface used by the Chrome OS EC with a
+  built-in Type-C port manager and external Type-C Port Controller
+  (TCPC). The cros-ec-ucsi driver supports the USB Type-C Connector
+  System Software (UCSI) interface used by the Chrome OS EC when the
+  platform has a separate power delivery controller (PDC). The node for
+  this device should be under a cros-ec node like google,cros-ec-spi.
 
 properties:
   compatible:
-    const: google,cros-ec-typec
+    enum:
+      - google,cros-ec-typec
+      - google,cros-ec-ucsi
 
   '#address-cells':
     const: 1
Signature · 1 line
2.51.0.858.gf9c4a03a3a-goog
maintainer Reviewed-by
#3 lore raw

Re: [PATCH v4 1/3] dt-bindings: chrome: Add cros-ec-ucsi compatibility to typec binding

Quoted 59 lines · Benson Leung

Hi Jameson,

Quoted 8 lines · Jameson Thies

Chrome OS devices with discrete power delivery controllers (PDCs) allow the host to read port status and control port behavior through a USB Type-C Connector System Software (UCSI) interface with the embedded controller (EC). This uses a separate interface driver than other Chrome OS devices with a Type-C port manager in the EC FW. Those use a host command interface supported by cros-ec-typec. Add a cros-ec-ucsi compatibility string to the existing cros-ec-typec binding.

Quoted 5 lines

Additionally, update maintainer list to reflect cros-ec-ucsi and cros-ec-typec driver maintainers.

Quoted 39 lines
---
 .../bindings/chrome/google,cros-ec-typec.yaml | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)
Documentation/devicetree/bindings/chrome/google,cros-ec-typec.yaml +15 -4
index 9f9816fbecbc..fd1a459879bd 100644
@@ -8,17 +8,28 @@ title: Google Chrome OS EC(Embedded Controller) Type C port driver.
 
 maintainers:
   - Benson Leung <[email protected]>
-  - Prashant Malani <[email protected]>
+  - Abhishek Pandit-Subedi <[email protected]>
+  - Andrei Kuchynski <[email protected]>
+  - Łukasz Bartosik <[email protected]>
+  - Jameson Thies <[email protected]>
 
 description:
   Chrome OS devices have an Embedded Controller(EC) which has access to
   Type C port state. This node is intended to allow the host to read and
-  control the Type C ports. The node for this device should be under a
-  cros-ec node like google,cros-ec-spi.
+  control the Type C ports. This binding is compatible with both the
+  cros-ec-typec and cros-ec-ucsi drivers. The cros-ec-typec driver
+  supports the host command interface used by the Chrome OS EC with a
+  built-in Type-C port manager and external Type-C Port Controller
+  (TCPC). The cros-ec-ucsi driver supports the USB Type-C Connector
+  System Software (UCSI) interface used by the Chrome OS EC when the
+  platform has a separate power delivery controller (PDC). The node for
+  this device should be under a cros-ec node like google,cros-ec-spi.
 
 properties:
   compatible:
-    const: google,cros-ec-typec
+    enum:
+      - google,cros-ec-typec
+      - google,cros-ec-ucsi
 
Quoted 5 lines
Quoted 5 lines
Documentation/devicetree/bindings/chrome/google,cros-ec-typec.yaml +0 -1
   '#address-cells':
     const: 1
--

2.51.0.858.gf9c4a03a3a-goog

author maintainer
#4 lore raw

PATCH v4 2/3 usb: typec: cros_ec_ucsi: Load driver from OF and ACPI definitions

In reply to Jameson Thies

Add support for cros_ec_ucsi to load based on "google,cros-ec-ucsi" compatible devices and "GOOG0021" ACPI nodes.

---
 drivers/usb/typec/ucsi/cros_ec_ucsi.c | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)
drivers/usb/typec/ucsi/cros_ec_ucsi.c +24 -2
index eed2a7d0ebc6..0c19ba84d11c 100644
@@ -5,11 +5,13 @@
  * Copyright 2024 Google LLC.
  */
 
+#include <linux/acpi.h>
 #include <linux/container_of.h>
 #include <linux/dev_printk.h>
 #include <linux/jiffies.h>
 #include <linux/mod_devicetable.h>
 #include <linux/module.h>
+#include <linux/of.h>
 #include <linux/platform_data/cros_ec_commands.h>
 #include <linux/platform_data/cros_usbpd_notify.h>
 #include <linux/platform_data/cros_ec_proto.h>
@@ -235,7 +237,6 @@ static void cros_ucsi_destroy(struct cros_ucsi_data *udata)
 static int cros_ucsi_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
-	struct cros_ec_dev *ec_data = dev_get_drvdata(dev->parent);
 	struct cros_ucsi_data *udata;
 	int ret;
 
@@ -243,9 +244,16 @@ static int cros_ucsi_probe(struct platform_device *pdev)
 	if (!udata)
 		return -ENOMEM;
 
+	/* ACPI and OF FW nodes for cros_ec_ucsi are children of the ChromeOS EC. If the
+	 * cros_ec_ucsi device has an ACPI or OF FW node, its parent is the ChromeOS EC device.
+	 * Platforms without a FW node for cros_ec_ucsi may add it as a subdevice of cros_ec_dev.
+	 */
 	udata->dev = dev;
+	if (is_acpi_device_node(dev->fwnode) || is_of_node(dev->fwnode))
+		udata->ec = dev_get_drvdata(dev->parent);
+	else
+		udata->ec = ((struct cros_ec_dev *)dev_get_drvdata(dev->parent))->ec_dev;
 
-	udata->ec = ec_data->ec_dev;
 	if (!udata->ec)
 		return dev_err_probe(dev, -ENODEV, "couldn't find parent EC device\n");
 
@@ -326,10 +334,24 @@ static const struct platform_device_id cros_ucsi_id[] = {
 };
 MODULE_DEVICE_TABLE(platform, cros_ucsi_id);
 
+static const struct acpi_device_id cros_ec_ucsi_acpi_device_ids[] = {
+	{ "GOOG0021", 0 },
+	{ }
+};
+MODULE_DEVICE_TABLE(acpi, cros_ec_ucsi_acpi_device_ids);
+
+static const struct of_device_id cros_ucsi_of_match[] = {
+	{ .compatible = "google,cros-ec-ucsi", },
+	{}
+};
+MODULE_DEVICE_TABLE(of, cros_ucsi_of_match);
+
 static struct platform_driver cros_ucsi_driver = {
 	.driver = {
 		.name = KBUILD_MODNAME,
 		.pm = &cros_ucsi_pm_ops,
+		.acpi_match_table = cros_ec_ucsi_acpi_device_ids,
+		.of_match_table = cros_ucsi_of_match,
 	},
 	.id_table = cros_ucsi_id,
 	.probe = cros_ucsi_probe,
Signature · 1 line
2.51.0.858.gf9c4a03a3a-goog
maintainer Reviewed-by on v4 2/3
#5 lore raw

Re: [PATCH v4 2/3] usb: typec: cros_ec_ucsi: Load driver from OF and ACPI definitions

Quoted 81 lines · Jameson Thies

Add support for cros_ec_ucsi to load based on "google,cros-ec-ucsi" compatible devices and "GOOG0021" ACPI nodes.

---
 drivers/usb/typec/ucsi/cros_ec_ucsi.c | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)
drivers/usb/typec/ucsi/cros_ec_ucsi.c +24 -3
index eed2a7d0ebc6..0c19ba84d11c 100644
@@ -5,11 +5,13 @@
  * Copyright 2024 Google LLC.
  */
 
+#include <linux/acpi.h>
 #include <linux/container_of.h>
 #include <linux/dev_printk.h>
 #include <linux/jiffies.h>
 #include <linux/mod_devicetable.h>
 #include <linux/module.h>
+#include <linux/of.h>
 #include <linux/platform_data/cros_ec_commands.h>
 #include <linux/platform_data/cros_usbpd_notify.h>
 #include <linux/platform_data/cros_ec_proto.h>
@@ -235,7 +237,6 @@ static void cros_ucsi_destroy(struct cros_ucsi_data *udata)
 static int cros_ucsi_probe(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
-       struct cros_ec_dev *ec_data = dev_get_drvdata(dev->parent);
        struct cros_ucsi_data *udata;
        int ret;
 
@@ -243,9 +244,16 @@ static int cros_ucsi_probe(struct platform_device *pdev)
        if (!udata)
                return -ENOMEM;
 
+       /* ACPI and OF FW nodes for cros_ec_ucsi are children of the ChromeOS EC. If the
+        * cros_ec_ucsi device has an ACPI or OF FW node, its parent is the ChromeOS EC device.
+        * Platforms without a FW node for cros_ec_ucsi may add it as a subdevice of cros_ec_dev.
+        */
        udata->dev = dev;
+       if (is_acpi_device_node(dev->fwnode) || is_of_node(dev->fwnode))
+               udata->ec = dev_get_drvdata(dev->parent);
+       else
+               udata->ec = ((struct cros_ec_dev *)dev_get_drvdata(dev->parent))->ec_dev;
 
-       udata->ec = ec_data->ec_dev;
        if (!udata->ec)
                return dev_err_probe(dev, -ENODEV, "couldn't find parent EC device\n");
 
@@ -326,10 +334,24 @@ static const struct platform_device_id cros_ucsi_id[] = {
 };
 MODULE_DEVICE_TABLE(platform, cros_ucsi_id);
 
+static const struct acpi_device_id cros_ec_ucsi_acpi_device_ids[] = {
+       { "GOOG0021", 0 },
+       { }
+};
+MODULE_DEVICE_TABLE(acpi, cros_ec_ucsi_acpi_device_ids);
+
+static const struct of_device_id cros_ucsi_of_match[] = {
+       { .compatible = "google,cros-ec-ucsi", },
+       {}
+};
+MODULE_DEVICE_TABLE(of, cros_ucsi_of_match);
+
 static struct platform_driver cros_ucsi_driver = {
        .driver = {
                .name = KBUILD_MODNAME,
                .pm = &cros_ucsi_pm_ops,
+               .acpi_match_table = cros_ec_ucsi_acpi_device_ids,
+               .of_match_table = cros_ucsi_of_match,
        },
        .id_table = cros_ucsi_id,
        .probe = cros_ucsi_probe,
--
Quoted 2 lines

2.51.0.858.gf9c4a03a3a-goog

author maintainer
#6 lore raw

PATCH v4 3/3 mfd: cros_ec: Don't add cros_ec_ucsi if it is defined in OF or ACPI

In reply to Jameson Thies

On devices with a UCSI PPM in the EC, check for cros_ec_ucsi to be defined in the OF device tree or an ACPI node. If it is defined by either OF or ACPI, it does not need to be added as a subdevice of cros_ec_dev mfd. cros_ec_ucsi will load from the OF or ACPI node.

---
 drivers/mfd/cros_ec_dev.c | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)
drivers/mfd/cros_ec_dev.c +18 -5
index dc80a272726b..1928c2ea2b8f 100644
@@ -5,6 +5,7 @@
  * Copyright (C) 2014 Google, Inc.
  */
 
+#include <linux/acpi.h>
 #include <linux/dmi.h>
 #include <linux/kconfig.h>
 #include <linux/mfd/core.h>
@@ -131,11 +132,6 @@ static const struct cros_feature_to_cells cros_subdevices[] = {
 		.mfd_cells	= cros_ec_rtc_cells,
 		.num_cells	= ARRAY_SIZE(cros_ec_rtc_cells),
 	},
-	{
-		.id		= EC_FEATURE_UCSI_PPM,
-		.mfd_cells	= cros_ec_ucsi_cells,
-		.num_cells	= ARRAY_SIZE(cros_ec_ucsi_cells),
-	},
 	{
 		.id		= EC_FEATURE_HANG_DETECT,
 		.mfd_cells	= cros_ec_wdt_cells,
@@ -264,6 +260,23 @@ static int ec_device_probe(struct platform_device *pdev)
 		}
 	}
 
+	/*
+	 * FW nodes can load cros_ec_ucsi, but early PDC devices did not define
+	 * the required nodes. On PDC systems without FW nodes for cros_ec_ucsi,
+	 * the driver should be added as an mfd subdevice.
+	 */
+	if (cros_ec_check_features(ec, EC_FEATURE_USB_PD) &&
+	    cros_ec_check_features(ec, EC_FEATURE_UCSI_PPM) &&
+	    !acpi_dev_found("GOOG0021") &&
+	    !of_find_compatible_node(NULL, NULL, "google,cros-ec-ucsi")) {
+		retval = mfd_add_hotplug_devices(ec->dev,
+						 cros_ec_ucsi_cells,
+						 ARRAY_SIZE(cros_ec_ucsi_cells));
+
+		if (retval)
+			dev_warn(ec->dev, "failed to add cros_ec_ucsi: %d\n", retval);
+	}
+
 	/*
 	 * UCSI provides power supply information so we don't need to separately
 	 * load the cros_usbpd_charger driver.
Signature · 1 line
2.51.0.858.gf9c4a03a3a-goog
maintainer Reviewed-by on v4 3/3
#7 lore raw

Re: [PATCH v4 3/3] mfd: cros_ec: Don't add cros_ec_ucsi if it is defined in OF or ACPI

Quoted 61 lines · Jameson Thies

On devices with a UCSI PPM in the EC, check for cros_ec_ucsi to be defined in the OF device tree or an ACPI node. If it is defined by either OF or ACPI, it does not need to be added as a subdevice of cros_ec_dev mfd. cros_ec_ucsi will load from the OF or ACPI node.

---
 drivers/mfd/cros_ec_dev.c | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)
drivers/mfd/cros_ec_dev.c +18 -6
index dc80a272726b..1928c2ea2b8f 100644
@@ -5,6 +5,7 @@
  * Copyright (C) 2014 Google, Inc.
  */
 
+#include <linux/acpi.h>
 #include <linux/dmi.h>
 #include <linux/kconfig.h>
 #include <linux/mfd/core.h>
@@ -131,11 +132,6 @@ static const struct cros_feature_to_cells cros_subdevices[] = {
                .mfd_cells      = cros_ec_rtc_cells,
                .num_cells      = ARRAY_SIZE(cros_ec_rtc_cells),
        },
-       {
-               .id             = EC_FEATURE_UCSI_PPM,
-               .mfd_cells      = cros_ec_ucsi_cells,
-               .num_cells      = ARRAY_SIZE(cros_ec_ucsi_cells),
-       },
        {
                .id             = EC_FEATURE_HANG_DETECT,
                .mfd_cells      = cros_ec_wdt_cells,
@@ -264,6 +260,23 @@ static int ec_device_probe(struct platform_device *pdev)
                }
        }
 
+       /*
+        * FW nodes can load cros_ec_ucsi, but early PDC devices did not define
+        * the required nodes. On PDC systems without FW nodes for cros_ec_ucsi,
+        * the driver should be added as an mfd subdevice.
+        */
+       if (cros_ec_check_features(ec, EC_FEATURE_USB_PD) &&
+           cros_ec_check_features(ec, EC_FEATURE_UCSI_PPM) &&
+           !acpi_dev_found("GOOG0021") &&
+           !of_find_compatible_node(NULL, NULL, "google,cros-ec-ucsi")) {
+               retval = mfd_add_hotplug_devices(ec->dev,
+                                                cros_ec_ucsi_cells,
+                                                ARRAY_SIZE(cros_ec_ucsi_cells));
+
+               if (retval)
+                       dev_warn(ec->dev, "failed to add cros_ec_ucsi: %d\n", retval);
+       }
+
        /*
         * UCSI provides power supply information so we don't need to separately
         * load the cros_usbpd_charger driver.
--
Quoted 2 lines

2.51.0.858.gf9c4a03a3a-goog