Skip to contentSkip to conversation

Load cros_ec_ucsi from OF and ACPI definitions

PATCH Superseded Jameson Thies 4 participants 15 messages Oct 9, 2025 – Oct 13, 2025

Subsystems (6)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Jameson Thies

author maintainer
#0 lore raw

v3 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.

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         | 22 ++++++++++++++++--
 3 files changed, 53 insertions(+), 11 deletions(-)

base-commit: 48633acccf38d706d7b368400647bb9db9caf1ae

Signature · 1 line
2.51.0.710.ga91ca5db03-goog
author maintainer
#1 lore raw

PATCH v3 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.710.ga91ca5db03-goog
Reviewed-by on v3 1/3
#2 lore raw

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

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 4 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.710.ga91ca5db03-goog
maintainer Reviewed-by on v3 1/3
#3 lore raw

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

In reply to Jameson Thies
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 8 lines

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(-)
author maintainer
#4 lore raw

PATCH v3 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 | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)
drivers/usb/typec/ucsi/cros_ec_ucsi.c +20 -2
index eed2a7d0ebc6..62b80ad85a68 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;
 
@@ -244,8 +245,11 @@ 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(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 +330,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.710.ga91ca5db03-goog
Reviewed-by on v3 2/3
#5 lore raw

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

Quoted 5 lines · Jameson Thies

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

Quoted 71 lines
---
 drivers/usb/typec/ucsi/cros_ec_ucsi.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)
drivers/usb/typec/ucsi/cros_ec_ucsi.c +20 -2
index eed2a7d0ebc6..62b80ad85a68 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;
 
@@ -244,8 +245,11 @@ 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(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 +330,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.710.ga91ca5db03-goog
#6 lore raw

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

In reply to Jameson Thies
Quoted 36 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 | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)
drivers/usb/typec/ucsi/cros_ec_ucsi.c +2 -1
index eed2a7d0ebc6..62b80ad85a68 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;
 

drivers/usb/typec/ucsi/cros_ec_ucsi.c static int cros_ucsi_probe(struct platform_device *pdev) · line 251

Quoted 7 lines
drivers/usb/typec/ucsi/cros_ec_ucsi.c +4 -0
@@ -244,8 +245,11 @@ 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(dev->parent);
+	else
+		udata->ec = ((struct cros_ec_dev *)dev_get_drvdata(dev->parent))->ec_dev;

Hmm, could you please comment, why does it depend on a way UCSI device is instantiated?

Quoted 33 lines
drivers/usb/typec/ucsi/cros_ec_ucsi.c +14 -1
-	udata->ec = ec_data->ec_dev;
 	if (!udata->ec)
 		return dev_err_probe(dev, -ENODEV, "couldn't find parent EC device\n");
 
@@ -326,10 +330,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.710.ga91ca5db03-goog
Signature · 2 lines
With best wishes
Dmitry
author maintainer
#7 lore raw

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

Hi Dmitry,
on early ChromeOS devices using this driver it gets added as a subdevice of the cros_ec_dev mfd. But, we want to change this to load the device from OF/ACPI nodes. The issue here is that older devices which don't define the OF/ACPI nodes to load cros_ec_ucsi will still need to add the device through cros_ec_dev.

So cros_ec_ucsi needs to support multiple methods of being instantiated, and going through cros_ec_dev creates an intermediary device in the path which doesn't exist when the driver is loaded through OF/ACPI. I'll add a comment explaining this in the v4 series.

#8 lore raw

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

Quoted 6 lines · Jameson Thies

Hi Dmitry,
on early ChromeOS devices using this driver it gets added as a subdevice of the cros_ec_dev mfd. But, we want to change this to load the device from OF/ACPI nodes. The issue here is that older devices which don't define the OF/ACPI nodes to load cros_ec_ucsi will still need to add the device through cros_ec_dev.

IIRC, MFD devices support binding subdevices to the OF nodes. Do you plan to use it? Could you possibly point out the example DTs?

Quoted 5 lines

So cros_ec_ucsi needs to support multiple methods of being instantiated, and going through cros_ec_dev creates an intermediary device in the path which doesn't exist when the driver is loaded through OF/ACPI. I'll add a comment explaining this in the v4 series.

Signature · 2 lines
With best wishes
Dmitry
author maintainer
#9 lore raw

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

Quoted 2 lines

IIRC, MFD devices support binding subdevices to the OF nodes. Do you plan to use it? Could you possibly point out the example DTs?

I'm not planning to add this, we want to move away from using the cros_ec_dev mfd to load cros_ec_ucsi. On upcoming devices using cros_ec_ucsi will just be loaded based on ACPI/DT. Regarding example DTs, I'll point this out in the comment.

#10 lore raw

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

Quoted 7 lines · Jameson Thies
Quoted 2 lines

IIRC, MFD devices support binding subdevices to the OF nodes. Do you plan to use it? Could you possibly point out the example DTs?

I'm not planning to add this, we want to move away from using the cros_ec_dev mfd to load cros_ec_ucsi. On upcoming devices using cros_ec_ucsi will just be loaded based on ACPI/DT. Regarding example DTs, I'll point this out in the comment.

Ack, thanks for the explanation. It might be a good idea to add something similar to the commit message.

Signature · 2 lines
With best wishes
Dmitry
author maintainer
#11 lore raw

PATCH v3 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.

---
 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.710.ga91ca5db03-goog
Reviewed-by on v3 3/3
#12 lore raw

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

Quoted 6 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.

Quoted 55 lines
---
 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.710.ga91ca5db03-goog
#13 lore raw

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

In reply to Jameson Thies
Quoted 4 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.

It still can be a subdevice of the EC, if it has a correct DT node.

Quoted 57 lines
---
 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.710.ga91ca5db03-goog
Signature · 2 lines
With best wishes
Dmitry
author maintainer
#14 lore raw

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

Quoted 1 line

It still can be a subdevice of the EC, if it has a correct DT node.

That's correct. What I meant to say in the commit message is that it does not need to be added as a subdevice of the cros_ec_dev mfd. I'll clarify the commit message in the v4 series.