Load cros_ec_ucsi from OF and ACPI definitions
Subsystems (6)
Jameson Thies
maintainerv2 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.
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
Signature · 1 line
2.51.0.618.g983fd99d29-goog
Jameson Thies
maintainerPATCH v2 1/3 dt-bindings: chrome: Add Cros EC UCSI driver
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.
--- .../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
Documentation/devicetree/bindings/chrome/google,cros-ec-ucsi.yaml new file +71 -0
@@ -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 <[email protected]> + - Andrei Kuchynski <[email protected]> + - Benson Leung <[email protected]> + - Jameson Thies <[email protected]> + - Łukasz Bartosik <[email protected]> + +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"; + }; + }; + }; + };
Documentation/devicetree/bindings/mfd/google,cros-ec.yaml +3 -1
@@ -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#
Signature · 1 line
2.51.0.618.g983fd99d29-goog
Jameson Thies
maintainerPATCH v2 2/3 usb: typec: cros_ec_ucsi: Load driver from OF and ACPI definitions
In reply to Jameson ThiesAdd 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 | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-)
drivers/usb/typec/ucsi/cros_ec_ucsi.c +23 -2
@@ -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,
Signature · 1 line
2.51.0.618.g983fd99d29-goog
Jameson Thies
maintainerPATCH v2 3/3 mfd: cros_ec: Don't add cros_ec_ucsi if it is defined in OF or ACPI
In reply to Jameson ThiesOn 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 | 40 ++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-)
drivers/mfd/cros_ec_dev.c +35 -5
@@ -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.
Signature · 1 line
2.51.0.618.g983fd99d29-goog
Re: [PATCH v2 1/3] dt-bindings: chrome: Add Cros EC UCSI driver
In reply to Jameson ThiesQuoted 6 lines · 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 <[email protected]>
Quoted 101 lines
--- .../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.yamlDocumentation/devicetree/bindings/chrome/google,cros-ec-ucsi.yaml new file +71
-0@@ -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 <[email protected]> + - Andrei Kuchynski <[email protected]> + - Benson Leung <[email protected]> + - Jameson Thies <[email protected]> + - Łukasz Bartosik <[email protected]> + +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"; + }; + }; + }; + };Documentation/devicetree/bindings/mfd/google,cros-ec.yaml +3
-1@@ -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#Signature · 1 line
2.51.0.618.g983fd99d29-goog
Re: [PATCH v2 2/3] usb: typec: cros_ec_ucsi: Load driver from OF and ACPI definitions
In reply to Jameson ThiesQuoted 4 lines · Jameson Thies
Add support for
cros_ec_ucsito load based on "google,cros-ec-ucsi" compatible devices and "GOOG0021" ACPI nodes.Signed-off-by Jameson Thies <[email protected]>
Quoted 74 lines
--- drivers/usb/typec/ucsi/cros_ec_ucsi.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-)drivers/usb/typec/ucsi/cros_ec_ucsi.c +23
-2@@ -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,Signature · 1 line
2.51.0.618.g983fd99d29-goog
Re: [PATCH v2 3/3] mfd: cros_ec: Don't add cros_ec_ucsi if it is defined in OF or ACPI
In reply to Jameson ThiesQuoted 6 lines · Jameson Thies
On devices with a UCSI PPM in the EC, check for
cros_ec_ucsito 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 ofcros_ec_dev.Signed-off-by Jameson Thies <[email protected]>
Quoted 79 lines
--- drivers/mfd/cros_ec_dev.c | 40 ++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-)drivers/mfd/cros_ec_dev.c +35
-5@@ -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. Signature · 1 line
2.51.0.618.g983fd99d29-goog
Re: [PATCH v2 2/3] usb: typec: cros_ec_ucsi: Load driver from OF and ACPI definitions
In reply to Jameson ThiesQuoted 4 lines · Jameson Thies
Add support for
cros_ec_ucsito load based on "google,cros-ec-ucsi" compatible devices and "GOOG0021" ACPI nodes.Signed-off-by Jameson Thies <[email protected]>
One nitpick below. With that sorted out:
Quoted 32 lines
--- drivers/usb/typec/ucsi/cros_ec_ucsi.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-)drivers/usb/typec/ucsi/cros_ec_ucsi.c +3
-1@@ -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;
drivers/usb/typec/ucsi/cros_ec_ucsi.c static int cros_ucsi_probe(struct platform_device *pdev) · line 250
Quoted 5 lines
drivers/usb/typec/ucsi/cros_ec_ucsi.c +2
-0@@ -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);
drivers/usb/typec/ucsi/cros_ec_ucsi.c static int cros_ucsi_probe(struct platform_device *pdev) · line 253
Quoted 3 lines
drivers/usb/typec/ucsi/cros_ec_ucsi.c +3
-0+ }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;
Quoted 20 lines
drivers/usb/typec/ucsi/cros_ec_ucsi.c +12
-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 +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);
drivers/usb/typec/ucsi/cros_ec_ucsi.c static const struct platform_device_id cros_ucsi_id[] = { · line 356
Quoted 10 lines
drivers/usb/typec/ucsi/cros_ec_ucsi.c +3
-0+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,
Signature · 1 line
heikki
Heikki Krogerus
maintainerRe: [PATCH v2 3/3] mfd: cros_ec: Don't add cros_ec_ucsi if it is defined in OF or ACPI
In reply to Jameson ThiesQuoted 58 lines · Jameson Thies
On devices with a UCSI PPM in the EC, check for
cros_ec_ucsito 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 ofcros_ec_dev.Signed-off-by Jameson Thies <[email protected]>--- drivers/mfd/cros_ec_dev.c | 40 ++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-)drivers/mfd/cros_ec_dev.c +14
-5@@ -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,
drivers/mfd/cros_ec_dev.c static int ec_device_probe(struct platform_device *pdev) · line 285
Quoted 10 lines
drivers/mfd/cros_ec_dev.c +10
-0+* 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,
Quoted 16 lines
drivers/mfd/cros_ec_dev.c +11
-0+ }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. Signature · 1 line
2.51.0.618.g983fd99d29-goog
Signature · 1 line
heikki
Rob Herring
maintainerRe: [PATCH v2 1/3] dt-bindings: chrome: Add Cros EC UCSI driver
In reply to Jameson ThiesQuoted 4 lines · 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.
What's PDC? What's UCSI?
Quoted 42 lines
Signed-off-by Jameson Thies <[email protected]>--- .../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.yamlDocumentation/devicetree/bindings/chrome/google,cros-ec-ucsi.yaml new file +28
-0@@ -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 <[email protected]> + - Andrei Kuchynski <[email protected]> + - Benson Leung <[email protected]> + - Jameson Thies <[email protected]> + - Łukasz Bartosik <[email protected]> + +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':
Documentation/devicetree/bindings/chrome/google,cros-ec-ucsi.yaml line 38
Quoted 10 lines
Documentation/devicetree/bindings/chrome/google,cros-ec-ucsi.yaml new file +10
-0+ 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
Jameson Thies
maintainerRe: [PATCH v2 1/3] dt-bindings: chrome: Add Cros EC UCSI driver
Quoted 1 line
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.
Quoted 3 lines
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.
Jameson Thies
maintainerRe: [PATCH v2 3/3] mfd: cros_ec: Don't add cros_ec_ucsi if it is defined in OF or ACPI
In reply to Heikki KrogerusQuoted 2 lines
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.
Quoted 1 line
Can there be multiple UCSI interfaces on these systems?
None of our devices will support multiple UCSI interfaces.