Add device-tree support for Cypress CYPD4226
Subsystems (6)
Jon Hunter
maintainerv7 cover Add device-tree support for Cypress CYPD4226
Add device-tree support for Cypress CYPD4226 Type-C controller and enable for the Jetson AGX Orin board. This series is derived from the series to enable USB host and device support for Jetson AGX Orin [0]. I have split this out from that series because it was getting quite big.
[0] https://lore.kernel.org/linux-tegra/[email protected]/
Jon Hunter (2):
arm64: tegra: Populate USB Type-C Controller for Jetson AGX Orin
arm64: defconfig: Enable UCSI support
Wayne Chang (4):
dt-bindings: usb: Add Cypress cypd4226 Type-C controller
i2c: nvidia-gpu: Add ACPI property to align with device-tree
usb: typec: ucsi_ccg: Add OF support
i2c: nvidia-gpu: Remove ccgx,firmware-build property
.../bindings/usb/cypress,cypd4226.yaml | 88 +++++++++++++++++++ .../nvidia/tegra234-p3737-0000+p3701-0000.dts | 14 +++ arch/arm64/configs/defconfig | 2 + drivers/i2c/busses/i2c-nvidia-gpu.c | 4 +- drivers/usb/typec/ucsi/ucsi_ccg.c | 23 ++++- 5 files changed, 125 insertions(+), 6 deletions(-) create mode 100644 Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml
Signature · 1 line
2.25.1
Jon Hunter
maintainerPATCH v7 1/6 dt-bindings: usb: Add Cypress cypd4226 Type-C controller
From: Wayne Chang <[email protected]>
Add the device-tree binding documentation for Cypress cypd4226 dual Type-C controller.
---
V6 -> V7: updated example to use 'typec' for the node name V5 -> V6: no changes
V4 -> V5: updated subject and updated binding to use 'firmware-name'. V3 -> V4: no changes
V2 -> V3: fix additionalProperties warning on new schema V1 -> V2: based on the review comments. Fix some addressed issues on
.../bindings/usb/cypress,cypd4226.yaml | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml
Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml new file +88 -0
@@ -0,0 +1,88 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/usb/cypress,cypd4226.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Cypress cypd4226 Type-C Controller + +maintainers: + - Wayne Chang <[email protected]> + +description: + The Cypress cypd4226 is a dual Type-C controller that is controlled + via an I2C interface. + +properties: + compatible: + const: cypress,cypd4226 + + '#address-cells': + const: 1 + + '#size-cells': + const: 0 + + reg: + const: 0x08 + + interrupts: + items: + - description: cypd4226 host interrupt + + firmware-name: + enum: + - nvidia,gpu + - nvidia,jetson-agx-xavier + description: | + The name of the CCGx firmware built for product series. + should be set one of following: + - "nvidia,gpu" for the NVIDIA RTX product series + - "nvidia,jetson-agx-xavier" for the NVIDIA Jetson product series + +patternProperties: + '^connector@[0-1]+$': + $ref: /schemas/connector/usb-connector.yaml# + properties: + reg: + maxItems: 1 + +unevaluatedProperties: false + +required: + - compatible + - reg + - interrupts + +additionalProperties: false + +examples: + - | + #include <dt-bindings/gpio/tegra194-gpio.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + i2c { + #address-cells = <1>; + #size-cells = <0>; + #interrupt-cells = <2>; + + typec@8 { + compatible = "cypress,cypd4226"; + reg = <0x08>; + interrupt-parent = <&gpio_aon>; + interrupts = <TEGRA194_AON_GPIO(BB, 2) IRQ_TYPE_LEVEL_LOW>; + firmware-name = "nvidia,jetson-agx-xavier"; + #address-cells = <1>; + #size-cells = <0>; + connector@0 { + compatible = "usb-c-connector"; + reg = <0>; + label = "USB-C"; + data-role = "dual"; + port { + endpoint { + remote-endpoint = <&usb_role_switch0>; + }; + }; + }; + }; + };
Signature · 1 line
2.25.1
Rob Herring
maintainerRe: [PATCH V7 1/6] dt-bindings: usb: Add Cypress cypd4226 Type-C controller
Quoted 15 lines · Jon Hunter
From: Wayne Chang <[email protected]>
Add the device-tree binding documentation for Cypress cypd4226 dual Type-C controller.
Signed-off-by Wayne Chang <[email protected]>Signed-off-by Jon Hunter <[email protected]>---
V6 -> V7: updated example to use 'typec' for the node name V5 -> V6: no changes
V4 -> V5: updated subject and updated binding to use 'firmware-name'. V3 -> V4: no changes
V2 -> V3: fix additionalProperties warning on new schema V1 -> V2: based on the review comments. Fix some addressed issues on
Quoted 4 lines
.../bindings/usb/cypress,cypd4226.yaml | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml
My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13):
yamllint warnings/errors:
dtschema/dtc warnings/errors:
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml: More than one condition true in oneOf schema:
{'description': 'Either unevaluatedProperties or additionalProperties '
'must be present',
'oneOf': [{'required': ['unevaluatedProperties']},
{'required': ['additionalProperties']}]}
hint: Either unevaluatedProperties or additionalProperties must be present
from schema $id: http://devicetree.org/meta-schemas/core.yaml#
doc reference errors (make refcheckdocs):
See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/[email protected]
The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch.
If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:
pip3 install dtschema --upgrade
Please check and re-submit after running the above command yourself. Note that DT_SCHEMA_FILES can be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema.
Jon Hunter
maintainerRe: [PATCH V7 1/6] dt-bindings: usb: Add Cypress cypd4226 Type-C controller
Quoted 40 lines · Rob Herring
Quoted 15 lines · Jon Hunter
From: Wayne Chang <[email protected]>
Add the device-tree binding documentation for Cypress cypd4226 dual Type-C controller.
Signed-off-by Wayne Chang <[email protected]>Signed-off-by Jon Hunter <[email protected]>---
V6 -> V7: updated example to use 'typec' for the node name V5 -> V6: no changes
V4 -> V5: updated subject and updated binding to use 'firmware-name'. V3 -> V4: no changes
V2 -> V3: fix additionalProperties warning on new schema V1 -> V2: based on the review comments. Fix some addressed issues onQuoted 4 lines
.../bindings/usb/cypress,cypd4226.yaml | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+)create mode 100644
Documentation/devicetree/bindings/usb/cypress,cypd4226.yamlMy bot found errors running 'make DT_CHECKER_FLAGS=-m
dt_binding_check' on your patch (DT_CHECKER_FLAGSis new in v5.13):yamllint warnings/errors:
dtschema/dtc warnings/errors:
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml: More than one condition true in oneOf schema:
{'description': 'Either unevaluatedProperties or additionalProperties '
'must be present',
'oneOf': [{'required': ['unevaluatedProperties']},
{'required': ['additionalProperties']}]}
hint: Either unevaluatedProperties or additionalProperties must be present
from schema $id: http://devicetree.org/meta-schemas/core.yaml#doc reference errors (make refcheckdocs):
See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/[email protected]
Quoted 8 lines
The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch.
If you already ran 'make
dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:pip3 install dtschema --upgrade
Indeed. My schema was not up to date :-(
I see the error now and will fix this. Sorry for not catching.
Jon
Signature · 1 line
nvpublic
Jon Hunter
maintainerPATCH v7 2/6 i2c: nvidia-gpu: Add ACPI property to align with device-tree
In reply to Jon HunterFrom: Wayne Chang <[email protected]>
Device-tree uses the 'firmware-name' string property to pass a name of the firmware build to the Cypress CCGx driver. Add a new ACPI string property to the NVIDIA GPU I2C driver to align with device-tree so that we can migrate to using a common property name for both ACPI and device-tree.
---
V7: Added Heikki's reviewed-by
V6: no changes
V5: Added this patch from V3
drivers/i2c/busses/i2c-nvidia-gpu.c | 1 + 1 file changed, 1 insertion(+)
drivers/i2c/busses/i2c-nvidia-gpu.c +1 -0
@@ -261,6 +261,7 @@ MODULE_DEVICE_TABLE(pci, gpu_i2c_ids);static const struct property_entry ccgx_props[] = {/* Use FW built for NVIDIA (nv) only */ PROPERTY_ENTRY_U16 ("ccgx,firmware-build" , ('n' <<8 ) |'v' ), +PROPERTY_ENTRY_STRING ("firmware-name" ,"nvidia,gpu" ), { } };
Signature · 1 line
2.25.1
Jon Hunter
maintainerPATCH v7 3/6 usb: typec: ucsi_ccg: Add OF support
In reply to Jon HunterFrom: Wayne Chang <[email protected]>
Add device-tree support for the Cypress CCG UCSI driver. The device-tree binding for the Cypress CCG device uses the standard device-tree 'firmware-name' string property to indicate the firmware build that is used.
The NVIDIA GPU I2C driver has been updated to use an ACPI string property that is also named 'firmware-build' and given that this was the only users of the 'ccgx,firmware-build' property, we can now remove support for this legacy property.
---
V6 -> V7: removed 'ccgx,firmware-build' property
V5 -> V6: fixed compilation
V4 -> V5: add support for 'firmware-name'
V1 -> V4: nothing has changed
drivers/usb/typec/ucsi/ucsi_ccg.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-)
drivers/usb/typec/ucsi/ucsi_ccg.c +19 -4
@@ -643,7 +643,7 @@ static int ccg_request_irq(struct ucsi_ccg *uc) {unsigned long flags =IRQF_ONESHOT ; -if (!has_acpi_companion (uc->dev)) +if (!dev_fwnode (uc->dev)) flags |=IRQF_TRIGGER_HIGH ;return request_threaded_irq (uc->irq,NULL , ccg_irq_handler, flags,dev_name (uc->dev), uc);
@@ -1342,6 +1342,7 @@ static int ucsi_ccg_probe(struct i2c_client *client) {struct device *dev = &client->dev;struct ucsi_ccg *uc; +const char *fw_name;int status; uc =devm_kzalloc (dev,sizeof (*uc),GFP_KERNEL );
@@ -1357,9 +1358,16 @@ static int ucsi_ccg_probe(struct i2c_client *client)INIT_WORK (&uc->pm_work, ccg_pm_workaround_work);/* Only fail FW flashing when FW build information is not provided */ - status =device_property_read_u16 (dev,"ccgx,firmware-build" , - &uc->fw_build); -if (status) + status =device_property_read_string (dev,"firmware-name" , + &fw_name); +if (!status) { +if (!strcmp (fw_name,"nvidia,jetson-agx-xavier" )) + uc->fw_build =CCG_FW_BUILD_NVIDIA_TEGRA ; +else if (!strcmp (fw_name,"nvidia,gpu" )) + uc->fw_build =CCG_FW_BUILD_NVIDIA ; + } + +if (!uc->fw_build)dev_err (uc->dev,"failed to get FW build information\n" );/* reset ccg device and initialize ucsi */
@@ -1426,6 +1434,12 @@ static void ucsi_ccg_remove(struct i2c_client *client)free_irq (uc->irq, uc); } +static const struct of_device_id ucsi_ccg_of_match_table[] = { + { .compatible ="cypress,cypd4226" , }, + {/* sentinel */ } +}; +MODULE_DEVICE_TABLE (of, ucsi_ccg_of_match_table); +static const struct i2c_device_id ucsi_ccg_device_id[] = { {"ccgx-ucsi" ,0 }, {}
@@ -1480,6 +1494,7 @@ static struct i2c_driver ucsi_ccg_driver = { .pm = &ucsi_ccg_pm, .dev_groups = ucsi_ccg_groups, .acpi_match_table = amd_i2c_ucsi_match, + .of_match_table = ucsi_ccg_of_match_table, }, .probe_new = ucsi_ccg_probe, .remove = ucsi_ccg_remove,
Signature · 1 line
2.25.1
Re: [PATCH V7 3/6] usb: typec: ucsi_ccg: Add OF support
Hi,
Quoted 7 lines · Jon Hunter
From: Wayne Chang <[email protected]>
Add device-tree support for the Cypress CCG UCSI driver. The device-tree binding for the Cypress CCG device uses the standard device-tree 'firmware-name' string property to indicate the firmware build that is used.
Quoted 8 lines
The NVIDIA GPU I2C driver has been updated to use an ACPI string property that is also named 'firmware-build' and given that this was the only users of the 'ccgx,firmware-build' property, we can now remove support for this legacy property.
Signed-off-by Wayne Chang <[email protected]>Co-developed-by Jon Hunter <[email protected]>Signed-off-by Jon Hunter <[email protected]>
You missed one nitpick in v6 - check below. But that's minor, so if there's nothing else:
Quoted 31 lines
---
V6 -> V7: removed 'ccgx,firmware-build' property
V5 -> V6: fixed compilation
V4 -> V5: add support for 'firmware-name'
V1 -> V4: nothing has changeddrivers/usb/typec/ucsi/ucsi_ccg.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-)drivers/usb/typec/ucsi/ucsi_ccg.c +2
-1@@ -643,7 +643,7 @@ static int ccg_request_irq(struct ucsi_ccg *uc) {unsigned long flags =IRQF_ONESHOT ; -if (!has_acpi_companion (uc->dev)) +if (!dev_fwnode (uc->dev)) flags |=IRQF_TRIGGER_HIGH ;return request_threaded_irq (uc->irq,NULL , ccg_irq_handler, flags,dev_name (uc->dev), uc);@@ -1342,6 +1342,7 @@ static int ucsi_ccg_probe(struct i2c_client *client) {struct device *dev = &client->dev;struct ucsi_ccg *uc; +const char *fw_name;int status; uc =devm_kzalloc (dev,sizeof (*uc),GFP_KERNEL );
drivers/usb/typec/ucsi/ucsi_ccg.c static int ucsi_ccg_probe(struct i2c_client *client) · line 1362
Quoted 8 lines
drivers/usb/typec/ucsi/ucsi_ccg.c +2
-3@@ -1357,9 +1358,16 @@ static int ucsi_ccg_probe(struct i2c_client *client)INIT_WORK (&uc->pm_work, ccg_pm_workaround_work);/* Only fail FW flashing when FW build information is not provided */ - status =device_property_read_u16 (dev,"ccgx,firmware-build" , - &uc->fw_build); -if (status) + status =device_property_read_string (dev,"firmware-name" , + &fw_name);
One line is enough:
status = device_property_read_string(dev, "firmware-name", &fw_name);
Quoted 34 lines
drivers/usb/typec/ucsi/ucsi_ccg.c +15
-0+if (!status) { +if (!strcmp (fw_name,"nvidia,jetson-agx-xavier" )) + uc->fw_build =CCG_FW_BUILD_NVIDIA_TEGRA ; +else if (!strcmp (fw_name,"nvidia,gpu" )) + uc->fw_build =CCG_FW_BUILD_NVIDIA ; + } + +if (!uc->fw_build)dev_err (uc->dev,"failed to get FW build information\n" );/* reset ccg device and initialize ucsi */ @@ -1426,6 +1434,12 @@ static void ucsi_ccg_remove(struct i2c_client *client)free_irq (uc->irq, uc); } +static const struct of_device_id ucsi_ccg_of_match_table[] = { + { .compatible ="cypress,cypd4226" , }, + {/* sentinel */ } +}; +MODULE_DEVICE_TABLE (of, ucsi_ccg_of_match_table); +static const struct i2c_device_id ucsi_ccg_device_id[] = { {"ccgx-ucsi" ,0 }, {}@@ -1480,6 +1494,7 @@ static struct i2c_driver ucsi_ccg_driver = { .pm = &ucsi_ccg_pm, .dev_groups = ucsi_ccg_groups, .acpi_match_table = amd_i2c_ucsi_match, + .of_match_table = ucsi_ccg_of_match_table, }, .probe_new = ucsi_ccg_probe, .remove = ucsi_ccg_remove,Signature · 1 line
2.25.1
thanks,
Signature · 1 line
heikki
Jon Hunter
maintainerRe: [PATCH V7 3/6] usb: typec: ucsi_ccg: Add OF support
On 24/01/2023 11:50, Heikki Krogerus wrote:
...
Quoted 66 lines
Hi,
Quoted 7 lines · Jon Hunter
From: Wayne Chang <[email protected]>
Add device-tree support for the Cypress CCG UCSI driver. The device-tree binding for the Cypress CCG device uses the standard device-tree 'firmware-name' string property to indicate the firmware build that is used.
Quoted 8 lines
The NVIDIA GPU I2C driver has been updated to use an ACPI string property that is also named 'firmware-build' and given that this was the only users of the 'ccgx,firmware-build' property, we can now remove support for this legacy property.
Signed-off-by Wayne Chang <[email protected]>Co-developed-by Jon Hunter <[email protected]>Signed-off-by Jon Hunter <[email protected]>You missed one nitpick in v6 - check below. But that's minor, so if there's nothing else:
Reviewed-by Heikki Krogerus <[email protected]>Quoted 31 lines
---
V6 -> V7: removed 'ccgx,firmware-build' property
V5 -> V6: fixed compilation
V4 -> V5: add support for 'firmware-name'
V1 -> V4: nothing has changeddrivers/usb/typec/ucsi/ucsi_ccg.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-)drivers/usb/typec/ucsi/ucsi_ccg.c +2
-1@@ -643,7 +643,7 @@ static int ccg_request_irq(struct ucsi_ccg *uc) {unsigned long flags =IRQF_ONESHOT ; -if (!has_acpi_companion (uc->dev)) +if (!dev_fwnode (uc->dev)) flags |=IRQF_TRIGGER_HIGH ;return request_threaded_irq (uc->irq,NULL , ccg_irq_handler, flags,dev_name (uc->dev), uc);@@ -1342,6 +1342,7 @@ static int ucsi_ccg_probe(struct i2c_client *client) {struct device *dev = &client->dev;struct ucsi_ccg *uc; +const char *fw_name;int status; uc =devm_kzalloc (dev,sizeof (*uc),GFP_KERNEL );drivers/usb/typec/ucsi/ucsi_ccg.c static int ucsi_ccg_probe(struct i2c_client *client) · line 1362
Quoted 8 lines
drivers/usb/typec/ucsi/ucsi_ccg.c +2
-3@@ -1357,9 +1358,16 @@ static int ucsi_ccg_probe(struct i2c_client *client)INIT_WORK (&uc->pm_work, ccg_pm_workaround_work);/* Only fail FW flashing when FW build information is not provided */ - status =device_property_read_u16 (dev,"ccgx,firmware-build" , - &uc->fw_build); -if (status) + status =device_property_read_string (dev,"firmware-name" , + &fw_name);One line is enough:
Quoted 1 line
status = device_property_read_string(dev, "firmware-name", &fw_name);
Ah sorry yes I forgot this!
Jon
Signature · 1 line
nvpublic
Jon Hunter
maintainerPATCH v7 4/6 i2c: nvidia-gpu: Remove ccgx,firmware-build property
In reply to Jon HunterFrom: Wayne Chang <[email protected]>
Now the Cypress CCG driver has been updated to support the 'firmware-name' property to align with device-tree, remove the 'ccgx,firmware-build' property as this is no longer needed.
---
V7: no changes
V6: no changes
V5: Added this patch from V3
drivers/i2c/busses/i2c-nvidia-gpu.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/i2c/busses/i2c-nvidia-gpu.c +1 -2
@@ -259,8 +259,7 @@ static const struct pci_device_id gpu_i2c_ids[] = {MODULE_DEVICE_TABLE (pci, gpu_i2c_ids);static const struct property_entry ccgx_props[] = { -/* Use FW built for NVIDIA (nv) only */ -PROPERTY_ENTRY_U16 ("ccgx,firmware-build" , ('n' <<8 ) |'v' ), +/* Use FW built for NVIDIA GPU only */ PROPERTY_ENTRY_STRING ("firmware-name" ,"nvidia,gpu" ), { } };
Signature · 1 line
2.25.1
Jon Hunter
maintainerPATCH v7 5/6 arm64: tegra: Populate USB Type-C Controller for Jetson AGX Orin
In reply to Jon HunterAdd the USB Type-C controller that is present on the Jetson AGX Orin board. The ports for the Type-C controller are not populated yet, but will be added later once the USB host and device support for Jetson AGX Orin is enabled.
This is based upon a patch from Wayne Chang <[email protected]>.
---
V7: updated to use 'typec' for the node name
V6: no changes
V5: no changes
V4: added in this version
.../dts/nvidia/tegra234-p3737-0000+p3701-0000.dts | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
arch/arm64/boot/dts/nvidia/tegra234-p3737-0000+p3701-0000.dts +14 -0
@@ -2190,6 +2190,20 @@ TEGRA234_AON_GPIO(AA, 4) phy-names = "p2u-0", "p2u-1", "p2u-2", "p2u-3", "p2u-4", "p2u-5", "p2u-6", "p2u-7"; }; + + i2c@c240000 { + status = "okay"; + typec@8 { + compatible = "cypress,cypd4226"; + reg = <0x08>; + interrupt-parent = <&gpio>; + interrupts = <TEGRA234_MAIN_GPIO(Y, 4) IRQ_TYPE_LEVEL_LOW>; + firmware-name = "nvidia,jetson-agx-xavier"; + status = "okay"; + #address-cells = <1>; + #size-cells = <0>; + }; + }; }; gpio-keys {
Signature · 1 line
2.25.1
Jon Hunter
maintainerPATCH v7 6/6 arm64: defconfig: Enable UCSI support
In reply to Jon HunterEnable the TYPEC UCSI support and the Cypress UCSI driver that is used on the NVIDIA Jetson platforms.
---
V7: Added in V7
arch/arm64/configs/defconfig | 2 ++ 1 file changed, 2 insertions(+)
arch/arm64/configs/defconfig +2 -0
@@ -959,6 +959,8 @@ CONFIG_TYPEC_TCPCI=m CONFIG_TYPEC_FUSB302=m CONFIG_TYPEC_TPS6598X=m CONFIG_TYPEC_HD3SS3220=m +CONFIG_TYPEC_UCSI=m +CONFIG_UCSI_CCG=m CONFIG_MMC=y CONFIG_MMC_BLOCK_MINORS=32 CONFIG_MMC_ARMMMCI=y
Signature · 1 line
2.25.1