* [PATCH v2 0/3] Load cros_ec_ucsi from OF and ACPI definitions
@ 2025-10-01 19:33 Jameson Thies
2025-10-01 19:33 ` [PATCH v2 1/3] dt-bindings: chrome: Add Cros EC UCSI driver Jameson Thies
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: Jameson Thies @ 2025-10-01 19:33 UTC (permalink / raw)
To: akuchynski, abhishekpandit, krzk+dt, robh, bleung,
heikki.krogerus, ukaszb, tzungbi
Cc: devicetree, chrome-platform, linux-usb, linux-kernel,
Jameson Thies
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/20250312195951.1579682-1-jthies@google.com/).
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.
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 driver
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-ucsi.yaml | 71 +++++++++++++++++++
.../bindings/mfd/google,cros-ec.yaml | 4 +-
drivers/mfd/cros_ec_dev.c | 40 +++++++++--
drivers/usb/typec/ucsi/cros_ec_ucsi.c | 25 ++++++-
4 files changed, 132 insertions(+), 8 deletions(-)
create mode 100644 Documentation/devicetree/bindings/chrome/google,cros-ec-ucsi.yaml
base-commit: 48633acccf38d706d7b368400647bb9db9caf1ae
--
2.51.0.618.g983fd99d29-goog
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v2 1/3] dt-bindings: chrome: Add Cros EC UCSI driver
2025-10-01 19:33 [PATCH v2 0/3] Load cros_ec_ucsi from OF and ACPI definitions Jameson Thies
@ 2025-10-01 19:33 ` Jameson Thies
2025-10-07 19:23 ` Benson Leung
2025-10-08 16:03 ` Rob Herring
2025-10-01 19:33 ` [PATCH v2 2/3] usb: typec: cros_ec_ucsi: Load driver from OF and ACPI definitions Jameson Thies
2025-10-01 19:33 ` [PATCH v2 3/3] mfd: cros_ec: Don't add cros_ec_ucsi if it is defined in OF or ACPI Jameson Thies
2 siblings, 2 replies; 12+ messages in thread
From: Jameson Thies @ 2025-10-01 19:33 UTC (permalink / raw)
To: akuchynski, abhishekpandit, krzk+dt, robh, bleung,
heikki.krogerus, ukaszb, tzungbi
Cc: devicetree, chrome-platform, linux-usb, linux-kernel,
Jameson Thies
Chrome OS devices with PDCs allow the host to read port status and
control port behavior with UCSI commands sent to the embedded controller
(EC). Add documentation for cros-ec-ucsi node which loads the Chrome OS
UCSI driver.
Signed-off-by: Jameson Thies <jthies@google.com>
---
.../bindings/chrome/google,cros-ec-ucsi.yaml | 71 +++++++++++++++++++
.../bindings/mfd/google,cros-ec.yaml | 4 +-
2 files changed, 74 insertions(+), 1 deletion(-)
create mode 100644 Documentation/devicetree/bindings/chrome/google,cros-ec-ucsi.yaml
diff --git a/Documentation/devicetree/bindings/chrome/google,cros-ec-ucsi.yaml b/Documentation/devicetree/bindings/chrome/google,cros-ec-ucsi.yaml
new file mode 100644
index 000000000000..2121776e3ff0
--- /dev/null
+++ b/Documentation/devicetree/bindings/chrome/google,cros-ec-ucsi.yaml
@@ -0,0 +1,71 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/chrome/google,cros-ec-ucsi.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Google Chrome OS EC(Embedded Controller) UCSI driver.
+
+maintainers:
+ - Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
+ - Andrei Kuchynski <akuchynski@chromium.org>
+ - Benson Leung <bleung@chromium.org>
+ - Jameson Thies <jthies@google.com>
+ - Łukasz Bartosik <ukaszb@chromium.org>
+
+description:
+ Chrome OS devices with PDC-based USB-C ports expose a UCSI interface
+ from the Embedded Controller (EC) which allows the host to request
+ port state and control limited port behavior (DR/PR swap). This node
+ allows the host UCSI driver to send and receive UCSI commands to a
+ Chrome OS EC. The node for this device should be under a cros-ec node
+ like google,cros-ec-spi.
+
+properties:
+ compatible:
+ const: google,cros-ec-ucsi
+
+ '#address-cells':
+ const: 1
+
+ '#size-cells':
+ const: 0
+
+patternProperties:
+ '^connector@[0-9a-f]+$':
+ $ref: /schemas/connector/usb-connector.yaml#
+ required:
+ - reg
+
+required:
+ - compatible
+
+additionalProperties: false
+
+examples:
+ - |+
+ spi {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ cros_ec: ec@0 {
+ compatible = "google,cros-ec-spi";
+ reg = <0>;
+ interrupts = <35 0>;
+
+ typec {
+ compatible = "google,cros-ec-ucsi";
+
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ connector@0 {
+ compatible = "usb-c-connector";
+ reg = <0>;
+ power-role = "dual";
+ data-role = "dual";
+ try-power-role = "source";
+ };
+ };
+ };
+ };
diff --git a/Documentation/devicetree/bindings/mfd/google,cros-ec.yaml b/Documentation/devicetree/bindings/mfd/google,cros-ec.yaml
index 50f457090066..646bc81c526f 100644
--- a/Documentation/devicetree/bindings/mfd/google,cros-ec.yaml
+++ b/Documentation/devicetree/bindings/mfd/google,cros-ec.yaml
@@ -99,7 +99,9 @@ properties:
gpio-controller: true
typec:
- $ref: /schemas/chrome/google,cros-ec-typec.yaml#
+ oneOf:
+ - $ref: /schemas/chrome/google,cros-ec-typec.yaml#
+ - $ref: /schemas/chrome/google,cros-ec-ucsi.yaml#
ec-pwm:
$ref: /schemas/pwm/google,cros-ec-pwm.yaml#
--
2.51.0.618.g983fd99d29-goog
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v2 2/3] usb: typec: cros_ec_ucsi: Load driver from OF and ACPI definitions
2025-10-01 19:33 [PATCH v2 0/3] Load cros_ec_ucsi from OF and ACPI definitions Jameson Thies
2025-10-01 19:33 ` [PATCH v2 1/3] dt-bindings: chrome: Add Cros EC UCSI driver Jameson Thies
@ 2025-10-01 19:33 ` Jameson Thies
2025-10-07 19:24 ` Benson Leung
2025-10-08 11:51 ` Heikki Krogerus
2025-10-01 19:33 ` [PATCH v2 3/3] mfd: cros_ec: Don't add cros_ec_ucsi if it is defined in OF or ACPI Jameson Thies
2 siblings, 2 replies; 12+ messages in thread
From: Jameson Thies @ 2025-10-01 19:33 UTC (permalink / raw)
To: akuchynski, abhishekpandit, krzk+dt, robh, bleung,
heikki.krogerus, ukaszb, tzungbi
Cc: devicetree, chrome-platform, linux-usb, linux-kernel,
Jameson Thies
Add support for cros_ec_ucsi to load based on "google,cros-ec-ucsi"
compatible devices and "GOOG0021" ACPI nodes.
Signed-off-by: Jameson Thies <jthies@google.com>
---
drivers/usb/typec/ucsi/cros_ec_ucsi.c | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/typec/ucsi/cros_ec_ucsi.c b/drivers/usb/typec/ucsi/cros_ec_ucsi.c
index eed2a7d0ebc6..3d19560bbaa7 100644
--- a/drivers/usb/typec/ucsi/cros_ec_ucsi.c
+++ b/drivers/usb/typec/ucsi/cros_ec_ucsi.c
@@ -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,7 @@ 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_ec_dev *ec_data;
struct cros_ucsi_data *udata;
int ret;
@@ -244,8 +246,13 @@ static int cros_ucsi_probe(struct platform_device *pdev)
return -ENOMEM;
udata->dev = dev;
+ if (is_acpi_device_node(dev->fwnode) || is_of_node(dev->fwnode)) {
+ udata->ec = dev_get_drvdata(pdev->dev.parent);
+ } else {
+ ec_data = dev_get_drvdata(dev->parent);
+ udata->ec = ec_data->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 +333,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,
--
2.51.0.618.g983fd99d29-goog
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v2 3/3] mfd: cros_ec: Don't add cros_ec_ucsi if it is defined in OF or ACPI
2025-10-01 19:33 [PATCH v2 0/3] Load cros_ec_ucsi from OF and ACPI definitions Jameson Thies
2025-10-01 19:33 ` [PATCH v2 1/3] dt-bindings: chrome: Add Cros EC UCSI driver Jameson Thies
2025-10-01 19:33 ` [PATCH v2 2/3] usb: typec: cros_ec_ucsi: Load driver from OF and ACPI definitions Jameson Thies
@ 2025-10-01 19:33 ` Jameson Thies
2025-10-07 19:43 ` Benson Leung
2025-10-08 12:10 ` Heikki Krogerus
2 siblings, 2 replies; 12+ messages in thread
From: Jameson Thies @ 2025-10-01 19:33 UTC (permalink / raw)
To: akuchynski, abhishekpandit, krzk+dt, robh, bleung,
heikki.krogerus, ukaszb, tzungbi
Cc: devicetree, chrome-platform, linux-usb, linux-kernel,
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.
Signed-off-by: Jameson Thies <jthies@google.com>
---
drivers/mfd/cros_ec_dev.c | 40 ++++++++++++++++++++++++++++++++++-----
1 file changed, 35 insertions(+), 5 deletions(-)
diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c
index dc80a272726b..b0523f6541d2 100644
--- a/drivers/mfd/cros_ec_dev.c
+++ b/drivers/mfd/cros_ec_dev.c
@@ -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,
@@ -177,6 +173,16 @@ static const struct mfd_cell cros_ec_vbc_cells[] = {
{ .name = "cros-ec-vbc", }
};
+static int ucsi_acpi_match(struct device *dev, const void *data)
+{
+ struct acpi_device_id ucsi_acpi_device_ids[] = {
+ { "GOOG0021", 0 },
+ {"", 0},
+ };
+ return !!acpi_match_device(ucsi_acpi_device_ids, dev);
+}
+
+
static void cros_ec_class_release(struct device *dev)
{
kfree(to_cros_ec_dev(dev));
@@ -264,6 +270,30 @@ 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)) {
+ struct device *acpi_dev = device_find_child(ec->ec_dev->dev,
+ NULL,
+ ucsi_acpi_match);
+
+ if (!!acpi_dev) {
+ put_device(acpi_dev);
+ } else if (!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.
--
2.51.0.618.g983fd99d29-goog
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v2 1/3] dt-bindings: chrome: Add Cros EC UCSI driver
2025-10-01 19:33 ` [PATCH v2 1/3] dt-bindings: chrome: Add Cros EC UCSI driver Jameson Thies
@ 2025-10-07 19:23 ` Benson Leung
2025-10-08 16:03 ` Rob Herring
1 sibling, 0 replies; 12+ messages in thread
From: Benson Leung @ 2025-10-07 19:23 UTC (permalink / raw)
To: Jameson Thies
Cc: akuchynski, abhishekpandit, krzk+dt, robh, bleung,
heikki.krogerus, ukaszb, tzungbi, devicetree, chrome-platform,
linux-usb, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 3744 bytes --]
On Wed, Oct 01, 2025 at 07:33:41PM +0000, Jameson Thies wrote:
> Chrome OS devices with PDCs allow the host to read port status and
> control port behavior with UCSI commands sent to the embedded controller
> (EC). Add documentation for cros-ec-ucsi node which loads the Chrome OS
> UCSI driver.
>
> Signed-off-by: Jameson Thies <jthies@google.com>
Reviewed-by: Benson Leung <bleung@chromium.org>
> ---
> .../bindings/chrome/google,cros-ec-ucsi.yaml | 71 +++++++++++++++++++
> .../bindings/mfd/google,cros-ec.yaml | 4 +-
> 2 files changed, 74 insertions(+), 1 deletion(-)
> create mode 100644 Documentation/devicetree/bindings/chrome/google,cros-ec-ucsi.yaml
>
> diff --git a/Documentation/devicetree/bindings/chrome/google,cros-ec-ucsi.yaml b/Documentation/devicetree/bindings/chrome/google,cros-ec-ucsi.yaml
> new file mode 100644
> index 000000000000..2121776e3ff0
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/chrome/google,cros-ec-ucsi.yaml
> @@ -0,0 +1,71 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/chrome/google,cros-ec-ucsi.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Google Chrome OS EC(Embedded Controller) UCSI driver.
> +
> +maintainers:
> + - Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
> + - Andrei Kuchynski <akuchynski@chromium.org>
> + - Benson Leung <bleung@chromium.org>
> + - Jameson Thies <jthies@google.com>
> + - Łukasz Bartosik <ukaszb@chromium.org>
> +
> +description:
> + Chrome OS devices with PDC-based USB-C ports expose a UCSI interface
> + from the Embedded Controller (EC) which allows the host to request
> + port state and control limited port behavior (DR/PR swap). This node
> + allows the host UCSI driver to send and receive UCSI commands to a
> + Chrome OS EC. The node for this device should be under a cros-ec node
> + like google,cros-ec-spi.
> +
> +properties:
> + compatible:
> + const: google,cros-ec-ucsi
> +
> + '#address-cells':
> + const: 1
> +
> + '#size-cells':
> + const: 0
> +
> +patternProperties:
> + '^connector@[0-9a-f]+$':
> + $ref: /schemas/connector/usb-connector.yaml#
> + required:
> + - reg
> +
> +required:
> + - compatible
> +
> +additionalProperties: false
> +
> +examples:
> + - |+
> + spi {
> + #address-cells = <1>;
> + #size-cells = <0>;
> +
> + cros_ec: ec@0 {
> + compatible = "google,cros-ec-spi";
> + reg = <0>;
> + interrupts = <35 0>;
> +
> + typec {
> + compatible = "google,cros-ec-ucsi";
> +
> + #address-cells = <1>;
> + #size-cells = <0>;
> +
> + connector@0 {
> + compatible = "usb-c-connector";
> + reg = <0>;
> + power-role = "dual";
> + data-role = "dual";
> + try-power-role = "source";
> + };
> + };
> + };
> + };
> diff --git a/Documentation/devicetree/bindings/mfd/google,cros-ec.yaml b/Documentation/devicetree/bindings/mfd/google,cros-ec.yaml
> index 50f457090066..646bc81c526f 100644
> --- a/Documentation/devicetree/bindings/mfd/google,cros-ec.yaml
> +++ b/Documentation/devicetree/bindings/mfd/google,cros-ec.yaml
> @@ -99,7 +99,9 @@ properties:
> gpio-controller: true
>
> typec:
> - $ref: /schemas/chrome/google,cros-ec-typec.yaml#
> + oneOf:
> + - $ref: /schemas/chrome/google,cros-ec-typec.yaml#
> + - $ref: /schemas/chrome/google,cros-ec-ucsi.yaml#
>
> ec-pwm:
> $ref: /schemas/pwm/google,cros-ec-pwm.yaml#
> --
> 2.51.0.618.g983fd99d29-goog
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v2 2/3] usb: typec: cros_ec_ucsi: Load driver from OF and ACPI definitions
2025-10-01 19:33 ` [PATCH v2 2/3] usb: typec: cros_ec_ucsi: Load driver from OF and ACPI definitions Jameson Thies
@ 2025-10-07 19:24 ` Benson Leung
2025-10-08 11:51 ` Heikki Krogerus
1 sibling, 0 replies; 12+ messages in thread
From: Benson Leung @ 2025-10-07 19:24 UTC (permalink / raw)
To: Jameson Thies
Cc: akuchynski, abhishekpandit, krzk+dt, robh, bleung,
heikki.krogerus, ukaszb, tzungbi, devicetree, chrome-platform,
linux-usb, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 2804 bytes --]
On Wed, Oct 01, 2025 at 07:33:42PM +0000, Jameson Thies wrote:
> Add support for cros_ec_ucsi to load based on "google,cros-ec-ucsi"
> compatible devices and "GOOG0021" ACPI nodes.
>
> Signed-off-by: Jameson Thies <jthies@google.com>
Reviewed-by: Benson Leung <bleung@chromium.org>
> ---
> drivers/usb/typec/ucsi/cros_ec_ucsi.c | 25 +++++++++++++++++++++++--
> 1 file changed, 23 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/typec/ucsi/cros_ec_ucsi.c b/drivers/usb/typec/ucsi/cros_ec_ucsi.c
> index eed2a7d0ebc6..3d19560bbaa7 100644
> --- a/drivers/usb/typec/ucsi/cros_ec_ucsi.c
> +++ b/drivers/usb/typec/ucsi/cros_ec_ucsi.c
> @@ -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,7 @@ 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_ec_dev *ec_data;
> struct cros_ucsi_data *udata;
> int ret;
>
> @@ -244,8 +246,13 @@ static int cros_ucsi_probe(struct platform_device *pdev)
> return -ENOMEM;
>
> udata->dev = dev;
> + if (is_acpi_device_node(dev->fwnode) || is_of_node(dev->fwnode)) {
> + udata->ec = dev_get_drvdata(pdev->dev.parent);
> + } else {
> + ec_data = dev_get_drvdata(dev->parent);
> + udata->ec = ec_data->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 +333,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,
> --
> 2.51.0.618.g983fd99d29-goog
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v2 3/3] mfd: cros_ec: Don't add cros_ec_ucsi if it is defined in OF or ACPI
2025-10-01 19:33 ` [PATCH v2 3/3] mfd: cros_ec: Don't add cros_ec_ucsi if it is defined in OF or ACPI Jameson Thies
@ 2025-10-07 19:43 ` Benson Leung
2025-10-08 12:10 ` Heikki Krogerus
1 sibling, 0 replies; 12+ messages in thread
From: Benson Leung @ 2025-10-07 19:43 UTC (permalink / raw)
To: Jameson Thies
Cc: akuchynski, abhishekpandit, krzk+dt, robh, bleung,
heikki.krogerus, ukaszb, tzungbi, devicetree, chrome-platform,
linux-usb, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 2920 bytes --]
On Wed, Oct 01, 2025 at 07:33:43PM +0000, Jameson Thies wrote:
> 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.
>
> Signed-off-by: Jameson Thies <jthies@google.com>
Reviewed-by: Benson Leung <bleung@chromium.org>
> ---
> drivers/mfd/cros_ec_dev.c | 40 ++++++++++++++++++++++++++++++++++-----
> 1 file changed, 35 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c
> index dc80a272726b..b0523f6541d2 100644
> --- a/drivers/mfd/cros_ec_dev.c
> +++ b/drivers/mfd/cros_ec_dev.c
> @@ -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,
> @@ -177,6 +173,16 @@ static const struct mfd_cell cros_ec_vbc_cells[] = {
> { .name = "cros-ec-vbc", }
> };
>
> +static int ucsi_acpi_match(struct device *dev, const void *data)
> +{
> + struct acpi_device_id ucsi_acpi_device_ids[] = {
> + { "GOOG0021", 0 },
> + {"", 0},
> + };
> + return !!acpi_match_device(ucsi_acpi_device_ids, dev);
> +}
> +
> +
> static void cros_ec_class_release(struct device *dev)
> {
> kfree(to_cros_ec_dev(dev));
> @@ -264,6 +270,30 @@ 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)) {
> + struct device *acpi_dev = device_find_child(ec->ec_dev->dev,
> + NULL,
> + ucsi_acpi_match);
> +
> + if (!!acpi_dev) {
> + put_device(acpi_dev);
> + } else if (!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.
> --
> 2.51.0.618.g983fd99d29-goog
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v2 2/3] usb: typec: cros_ec_ucsi: Load driver from OF and ACPI definitions
2025-10-01 19:33 ` [PATCH v2 2/3] usb: typec: cros_ec_ucsi: Load driver from OF and ACPI definitions Jameson Thies
2025-10-07 19:24 ` Benson Leung
@ 2025-10-08 11:51 ` Heikki Krogerus
1 sibling, 0 replies; 12+ messages in thread
From: Heikki Krogerus @ 2025-10-08 11:51 UTC (permalink / raw)
To: Jameson Thies
Cc: akuchynski, abhishekpandit, krzk+dt, robh, bleung, ukaszb,
tzungbi, devicetree, chrome-platform, linux-usb, linux-kernel
On Wed, Oct 01, 2025 at 07:33:42PM +0000, Jameson Thies wrote:
> Add support for cros_ec_ucsi to load based on "google,cros-ec-ucsi"
> compatible devices and "GOOG0021" ACPI nodes.
>
> Signed-off-by: Jameson Thies <jthies@google.com>
One nitpick below. With that sorted out:
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
> drivers/usb/typec/ucsi/cros_ec_ucsi.c | 25 +++++++++++++++++++++++--
> 1 file changed, 23 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/typec/ucsi/cros_ec_ucsi.c b/drivers/usb/typec/ucsi/cros_ec_ucsi.c
> index eed2a7d0ebc6..3d19560bbaa7 100644
> --- a/drivers/usb/typec/ucsi/cros_ec_ucsi.c
> +++ b/drivers/usb/typec/ucsi/cros_ec_ucsi.c
> @@ -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,7 @@ 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_ec_dev *ec_data;
> struct cros_ucsi_data *udata;
> int ret;
>
> @@ -244,8 +246,13 @@ static int cros_ucsi_probe(struct platform_device *pdev)
> return -ENOMEM;
>
> udata->dev = dev;
> + if (is_acpi_device_node(dev->fwnode) || is_of_node(dev->fwnode)) {
> + udata->ec = dev_get_drvdata(pdev->dev.parent);
udata->ec = dev_get_drvdata(dev->parent);
> + } else {
> + ec_data = dev_get_drvdata(dev->parent);
> + udata->ec = ec_data->ec_dev;
and just as a proposal:
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 +333,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,
thanks,
--
heikki
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v2 3/3] mfd: cros_ec: Don't add cros_ec_ucsi if it is defined in OF or ACPI
2025-10-01 19:33 ` [PATCH v2 3/3] mfd: cros_ec: Don't add cros_ec_ucsi if it is defined in OF or ACPI Jameson Thies
2025-10-07 19:43 ` Benson Leung
@ 2025-10-08 12:10 ` Heikki Krogerus
2025-10-08 23:34 ` Jameson Thies
1 sibling, 1 reply; 12+ messages in thread
From: Heikki Krogerus @ 2025-10-08 12:10 UTC (permalink / raw)
To: Jameson Thies
Cc: akuchynski, abhishekpandit, krzk+dt, robh, bleung, ukaszb,
tzungbi, devicetree, chrome-platform, linux-usb, linux-kernel
On Wed, Oct 01, 2025 at 07:33:43PM +0000, Jameson Thies wrote:
> 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.
>
> Signed-off-by: Jameson Thies <jthies@google.com>
> ---
> drivers/mfd/cros_ec_dev.c | 40 ++++++++++++++++++++++++++++++++++-----
> 1 file changed, 35 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c
> index dc80a272726b..b0523f6541d2 100644
> --- a/drivers/mfd/cros_ec_dev.c
> +++ b/drivers/mfd/cros_ec_dev.c
> @@ -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,
> @@ -177,6 +173,16 @@ static const struct mfd_cell cros_ec_vbc_cells[] = {
> { .name = "cros-ec-vbc", }
> };
>
> +static int ucsi_acpi_match(struct device *dev, const void *data)
> +{
> + struct acpi_device_id ucsi_acpi_device_ids[] = {
> + { "GOOG0021", 0 },
> + {"", 0},
> + };
> + return !!acpi_match_device(ucsi_acpi_device_ids, dev);
> +}
> +
> +
> static void cros_ec_class_release(struct device *dev)
> {
> kfree(to_cros_ec_dev(dev));
> @@ -264,6 +270,30 @@ 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)) {
> + struct device *acpi_dev = device_find_child(ec->ec_dev->dev,
> + NULL,
> + ucsi_acpi_match);
> +
> + if (!!acpi_dev) {
> + put_device(acpi_dev);
If you are not using that for anything, then couldn't you just use
acpi_dev_found("GOOG0021") ?
Can there be multiple UCSI interfaces on these systems?
thanks,
> + } else if (!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.
> --
> 2.51.0.618.g983fd99d29-goog
--
heikki
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v2 1/3] dt-bindings: chrome: Add Cros EC UCSI driver
2025-10-01 19:33 ` [PATCH v2 1/3] dt-bindings: chrome: Add Cros EC UCSI driver Jameson Thies
2025-10-07 19:23 ` Benson Leung
@ 2025-10-08 16:03 ` Rob Herring
2025-10-08 20:25 ` Jameson Thies
1 sibling, 1 reply; 12+ messages in thread
From: Rob Herring @ 2025-10-08 16:03 UTC (permalink / raw)
To: Jameson Thies
Cc: akuchynski, abhishekpandit, krzk+dt, bleung, heikki.krogerus,
ukaszb, tzungbi, devicetree, chrome-platform, linux-usb,
linux-kernel
On Wed, Oct 01, 2025 at 07:33:41PM +0000, Jameson Thies wrote:
> Chrome OS devices with PDCs allow the host to read port status and
> control port behavior with UCSI commands sent to the embedded controller
> (EC). Add documentation for cros-ec-ucsi node which loads the Chrome OS
> UCSI driver.
What's PDC? What's UCSI?
>
> Signed-off-by: Jameson Thies <jthies@google.com>
> ---
> .../bindings/chrome/google,cros-ec-ucsi.yaml | 71 +++++++++++++++++++
> .../bindings/mfd/google,cros-ec.yaml | 4 +-
> 2 files changed, 74 insertions(+), 1 deletion(-)
> create mode 100644 Documentation/devicetree/bindings/chrome/google,cros-ec-ucsi.yaml
>
> diff --git a/Documentation/devicetree/bindings/chrome/google,cros-ec-ucsi.yaml b/Documentation/devicetree/bindings/chrome/google,cros-ec-ucsi.yaml
> new file mode 100644
> index 000000000000..2121776e3ff0
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/chrome/google,cros-ec-ucsi.yaml
> @@ -0,0 +1,71 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/chrome/google,cros-ec-ucsi.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Google Chrome OS EC(Embedded Controller) UCSI driver.
> +
> +maintainers:
> + - Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
> + - Andrei Kuchynski <akuchynski@chromium.org>
> + - Benson Leung <bleung@chromium.org>
> + - Jameson Thies <jthies@google.com>
> + - Łukasz Bartosik <ukaszb@chromium.org>
> +
> +description:
> + Chrome OS devices with PDC-based USB-C ports expose a UCSI interface
> + from the Embedded Controller (EC) which allows the host to request
> + port state and control limited port behavior (DR/PR swap). This node
> + allows the host UCSI driver to send and receive UCSI commands to a
> + Chrome OS EC. The node for this device should be under a cros-ec node
> + like google,cros-ec-spi.
> +
> +properties:
> + compatible:
> + const: google,cros-ec-ucsi
> +
> + '#address-cells':
> + const: 1
> +
> + '#size-cells':
> + const: 0
> +
> +patternProperties:
> + '^connector@[0-9a-f]+$':
> + $ref: /schemas/connector/usb-connector.yaml#
> + required:
> + - reg
This is the exact same binding as google,cros-ec-typec.yaml. Why are you
duplicating the whole thing rather than just adding a new compatible
string?
Rob
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v2 1/3] dt-bindings: chrome: Add Cros EC UCSI driver
2025-10-08 16:03 ` Rob Herring
@ 2025-10-08 20:25 ` Jameson Thies
0 siblings, 0 replies; 12+ messages in thread
From: Jameson Thies @ 2025-10-08 20:25 UTC (permalink / raw)
To: Rob Herring
Cc: akuchynski, abhishekpandit, krzk+dt, bleung, heikki.krogerus,
ukaszb, tzungbi, devicetree, chrome-platform, linux-usb,
linux-kernel
> What's PDC? What's UCSI?
PDCs are "Power Delivery Controllers". It refers to an IC which
manages PD communication for a USB-C port. UCSI stands for "USB Type-C
Connector System Software Interface". It is a specification maintained
by the USB-IF which defines a standardized interface for communicating
with PDCs. I'll update the description in the v3 series to provide the
full name for both of these terms.
> This is the exact same binding as google,cros-ec-typec.yaml. Why are you
> duplicating the whole thing rather than just adding a new compatible
> string?
I separated these bindings because they are associated with separate
mutually exclusive drivers. But, I'm fine with adding this as a
compatibility string in google,cros-ec-typec.yaml and will make that
change in the v3 series.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v2 3/3] mfd: cros_ec: Don't add cros_ec_ucsi if it is defined in OF or ACPI
2025-10-08 12:10 ` Heikki Krogerus
@ 2025-10-08 23:34 ` Jameson Thies
0 siblings, 0 replies; 12+ messages in thread
From: Jameson Thies @ 2025-10-08 23:34 UTC (permalink / raw)
To: Heikki Krogerus
Cc: akuchynski, abhishekpandit, krzk+dt, robh, bleung, ukaszb,
tzungbi, devicetree, chrome-platform, linux-usb, linux-kernel
> If you are not using that for anything, then couldn't you just use
> acpi_dev_found("GOOG0021") ?
Thanks, this is a good suggestion. I'll switch to acpi_dev_found() in
the v3 update.
> Can there be multiple UCSI interfaces on these systems?
None of our devices will support multiple UCSI interfaces.
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2025-10-08 23:35 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-01 19:33 [PATCH v2 0/3] Load cros_ec_ucsi from OF and ACPI definitions Jameson Thies
2025-10-01 19:33 ` [PATCH v2 1/3] dt-bindings: chrome: Add Cros EC UCSI driver Jameson Thies
2025-10-07 19:23 ` Benson Leung
2025-10-08 16:03 ` Rob Herring
2025-10-08 20:25 ` Jameson Thies
2025-10-01 19:33 ` [PATCH v2 2/3] usb: typec: cros_ec_ucsi: Load driver from OF and ACPI definitions Jameson Thies
2025-10-07 19:24 ` Benson Leung
2025-10-08 11:51 ` Heikki Krogerus
2025-10-01 19:33 ` [PATCH v2 3/3] mfd: cros_ec: Don't add cros_ec_ucsi if it is defined in OF or ACPI Jameson Thies
2025-10-07 19:43 ` Benson Leung
2025-10-08 12:10 ` Heikki Krogerus
2025-10-08 23:34 ` Jameson Thies
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).