[03/11] dt-bindings: usb: Add binding for Cypress cypd4226 I2C driver

Message ID 20221024074128.1113554-4-waynec@nvidia.com
State New
Headers
Series Enable USB host and device functions on Jetson |

Commit Message

Wayne Chang Oct. 24, 2022, 7:41 a.m. UTC
  add device-tree binding documentation for Cypress cypd4226 type-C
controller's I2C interface. It is a standard i2c slave with GPIO
input as IRQ interface.

Signed-off-by: Wayne Chang <waynec@nvidia.com>
---
 .../bindings/usb/cypress,cypd4226.yaml        | 86 +++++++++++++++++++
 1 file changed, 86 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml
  

Comments

Rob Herring Oct. 26, 2022, 1:07 a.m. UTC | #1
On Mon, Oct 24, 2022 at 03:41:20PM +0800, Wayne Chang wrote:
> add device-tree binding documentation for Cypress cypd4226 type-C
> controller's I2C interface. It is a standard i2c slave with GPIO
> input as IRQ interface.
> 
> Signed-off-by: Wayne Chang <waynec@nvidia.com>
> ---
>  .../bindings/usb/cypress,cypd4226.yaml        | 86 +++++++++++++++++++
>  1 file changed, 86 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml
> 
> diff --git a/Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml b/Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml
> new file mode 100644
> index 000000000000..5ac28ab4e7a1
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml
> @@ -0,0 +1,86 @@
> +# 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 UCSI I2C Type-C Controller
> +
> +maintainers:
> +  - Wayne Chang <waynec@nvidia.com>
> +
> +description: |

Don't need '|'.

> +  The Cypress cypd4226 UCSI I2C type-C controller is a I2C interface type-C
> +  controller.
> +
> +properties:
> +  compatible:
> +    const: cypress,cypd4226
> +
> +  '#address-cells':
> +    const: 1
> +
> +  '#size-cells':
> +    const: 0
> +
> +  reg:
> +    const: 0x08
> +
> +  interrupts:
> +    maxItems: 1
> +
> +  cypress,firmware-build:
> +    enum:
> +      - nv
> +      - gn
> +    description: |
> +      the name of the CCGx firmware built for product series.
> +      should be set one of following:
> +      - "nv" for the RTX product series
> +      - "gn" for the Jetson product series
> +
> +patternProperties:
> +  '^connector@[0-9a-f]+$':

Looks like the part only has 2 PD controllers, so 2 connectors only, 
right?

> +    $ref: /schemas/connector/usb-connector.yaml#

       unevaluatedProperties: false

> +    properties:
> +      reg:
> +        maxItems: 1

maximum: 1

> +
> +required:
> +  - compatible
> +  - reg
> +  - interrupts
> +
> +additionalProperties: true

false

true is only for incomplete, common schemas.

> +
> +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>;
> +
> +      ucsi_ccg: ucsi_ccg@8 {
> +        compatible = "cypress,cypd4226";
> +        interrupt-parent = <&gpio_aon>;
> +        interrupts = <TEGRA194_AON_GPIO(BB, 2) IRQ_TYPE_LEVEL_LOW>;
> +        reg = <0x08>;
> +        cypress,firmware-build = "gn";
> +        status = "okay";

Don't need status in examples.

> +        #address-cells = <1>;
> +        #size-cells = <0>;
> +        ccg_typec_con0: connector@0 {
> +          compatible = "usb-c-connector";
> +          reg = <0>;
> +          label = "USB-C";
> +          data-role = "dual";
> +          port {
> +            ucsi_ccg_p0: endpoint {
> +              remote-endpoint = <&usb_role_switch0>;
> +            };
> +          };
> +        };
> +      };
> +    };
> -- 
> 2.25.1
> 
>
  
Jon Hunter Oct. 26, 2022, 7:13 a.m. UTC | #2
On 24/10/2022 08:41, Wayne Chang wrote:
> add device-tree binding documentation for Cypress cypd4226 type-C
> controller's I2C interface. It is a standard i2c slave with GPIO
> input as IRQ interface.
> 
> Signed-off-by: Wayne Chang <waynec@nvidia.com>
> ---
>   .../bindings/usb/cypress,cypd4226.yaml        | 86 +++++++++++++++++++
>   1 file changed, 86 insertions(+)
>   create mode 100644 Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml
> 
> diff --git a/Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml b/Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml
> new file mode 100644
> index 000000000000..5ac28ab4e7a1
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml
> @@ -0,0 +1,86 @@
> +# 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 UCSI I2C Type-C Controller
> +
> +maintainers:
> +  - Wayne Chang <waynec@nvidia.com>
> +
> +description: |
> +  The Cypress cypd4226 UCSI I2C type-C controller is a I2C interface type-C
> +  controller.
> +
> +properties:
> +  compatible:
> +    const: cypress,cypd4226
> +
> +  '#address-cells':
> +    const: 1
> +
> +  '#size-cells':
> +    const: 0
> +
> +  reg:
> +    const: 0x08
> +
> +  interrupts:
> +    maxItems: 1
> +
> +  cypress,firmware-build:
> +    enum:
> +      - nv
> +      - gn
> +    description: |
> +      the name of the CCGx firmware built for product series.
> +      should be set one of following:
> +      - "nv" for the RTX product series

Please add 'NVIDIA' so that it is 'for the NVIDIA RTX product series'

> +      - "gn" for the Jetson product series

Same here please add 'NVIDIA' so that it is 'for the NVIDIA Jetson 
product series'.

Rob, any concerns about this property in general? Unfortunately, ACPI 
choose a 16-bit type for this and used 'nv' for the RTX product. I don't 
find 'gn' for Jetson very descriptive but we need a way to differentiate 
from RTX.

This is needed in the Cypress CCGX driver for the following ...

https://lore.kernel.org/lkml/20220928150840.3804313-1-waynec@nvidia.com/

Ideally, this should have been included in this series but was sent 
before. We can always re-work/update the above patch even though it has 
been queued up now.

Jon
  
Thierry Reding Oct. 28, 2022, 12:31 p.m. UTC | #3
On Wed, Oct 26, 2022 at 08:13:57AM +0100, Jon Hunter wrote:
> 
> On 24/10/2022 08:41, Wayne Chang wrote:
> > add device-tree binding documentation for Cypress cypd4226 type-C
> > controller's I2C interface. It is a standard i2c slave with GPIO
> > input as IRQ interface.
> > 
> > Signed-off-by: Wayne Chang <waynec@nvidia.com>
> > ---
> >   .../bindings/usb/cypress,cypd4226.yaml        | 86 +++++++++++++++++++
> >   1 file changed, 86 insertions(+)
> >   create mode 100644 Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml
> > 
> > diff --git a/Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml b/Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml
> > new file mode 100644
> > index 000000000000..5ac28ab4e7a1
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml
> > @@ -0,0 +1,86 @@
> > +# 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 UCSI I2C Type-C Controller
> > +
> > +maintainers:
> > +  - Wayne Chang <waynec@nvidia.com>
> > +
> > +description: |
> > +  The Cypress cypd4226 UCSI I2C type-C controller is a I2C interface type-C
> > +  controller.
> > +
> > +properties:
> > +  compatible:
> > +    const: cypress,cypd4226
> > +
> > +  '#address-cells':
> > +    const: 1
> > +
> > +  '#size-cells':
> > +    const: 0
> > +
> > +  reg:
> > +    const: 0x08
> > +
> > +  interrupts:
> > +    maxItems: 1
> > +
> > +  cypress,firmware-build:
> > +    enum:
> > +      - nv
> > +      - gn
> > +    description: |
> > +      the name of the CCGx firmware built for product series.
> > +      should be set one of following:
> > +      - "nv" for the RTX product series
> 
> Please add 'NVIDIA' so that it is 'for the NVIDIA RTX product series'
> 
> > +      - "gn" for the Jetson product series
> 
> Same here please add 'NVIDIA' so that it is 'for the NVIDIA Jetson product
> series'.
> 
> Rob, any concerns about this property in general? Unfortunately, ACPI choose
> a 16-bit type for this and used 'nv' for the RTX product. I don't find 'gn'
> for Jetson very descriptive but we need a way to differentiate from RTX.
> 
> This is needed in the Cypress CCGX driver for the following ...
> 
> https://lore.kernel.org/lkml/20220928150840.3804313-1-waynec@nvidia.com/
> 
> Ideally, this should have been included in this series but was sent before.
> We can always re-work/update the above patch even though it has been queued
> up now.

The driver seems to use this 16-bit value only to compare with a
corresponding field in the firmware headers. How exactly we obtain this
value is therefore not important. However, since this 16-bit value is
embedded in firmware images, we also cannot substitute them with
something more sensible.

However, I'm also a little confused as to the meaning of the property.
Looking at the driver, the fw_build field is used to check for
"supported vendors". "nv" and "gn" are clearly the same vendor (NVIDIA),
so that's at least not 100% accurate. The DT bindings say that this
denotes the product series, which seems to be more in line with how the
driver uses it.

The driver also uses it to implement changes in behavior across
different variants, which is something that we would typically describe
using compatible strings. So I wonder if we should, at least for device
tree, switch to using different compatible strings rather than this
separate matching mechanism. We could then associate a "product series"
with the compatible string rather than having this extra field.

There's also an argument to be made for keeping the interface the same
between ACPI and DT.

Rob, Krzysztof?

Thierry
  
Jon Hunter Oct. 28, 2022, 12:42 p.m. UTC | #4
On 28/10/2022 13:31, Thierry Reding wrote:
> On Wed, Oct 26, 2022 at 08:13:57AM +0100, Jon Hunter wrote:
>>
>> On 24/10/2022 08:41, Wayne Chang wrote:
>>> add device-tree binding documentation for Cypress cypd4226 type-C
>>> controller's I2C interface. It is a standard i2c slave with GPIO
>>> input as IRQ interface.
>>>
>>> Signed-off-by: Wayne Chang <waynec@nvidia.com>
>>> ---
>>>    .../bindings/usb/cypress,cypd4226.yaml        | 86 +++++++++++++++++++
>>>    1 file changed, 86 insertions(+)
>>>    create mode 100644 Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml
>>>
>>> diff --git a/Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml b/Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml
>>> new file mode 100644
>>> index 000000000000..5ac28ab4e7a1
>>> --- /dev/null
>>> +++ b/Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml
>>> @@ -0,0 +1,86 @@
>>> +# 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 UCSI I2C Type-C Controller
>>> +
>>> +maintainers:
>>> +  - Wayne Chang <waynec@nvidia.com>
>>> +
>>> +description: |
>>> +  The Cypress cypd4226 UCSI I2C type-C controller is a I2C interface type-C
>>> +  controller.
>>> +
>>> +properties:
>>> +  compatible:
>>> +    const: cypress,cypd4226
>>> +
>>> +  '#address-cells':
>>> +    const: 1
>>> +
>>> +  '#size-cells':
>>> +    const: 0
>>> +
>>> +  reg:
>>> +    const: 0x08
>>> +
>>> +  interrupts:
>>> +    maxItems: 1
>>> +
>>> +  cypress,firmware-build:
>>> +    enum:
>>> +      - nv
>>> +      - gn
>>> +    description: |
>>> +      the name of the CCGx firmware built for product series.
>>> +      should be set one of following:
>>> +      - "nv" for the RTX product series
>>
>> Please add 'NVIDIA' so that it is 'for the NVIDIA RTX product series'
>>
>>> +      - "gn" for the Jetson product series
>>
>> Same here please add 'NVIDIA' so that it is 'for the NVIDIA Jetson product
>> series'.
>>
>> Rob, any concerns about this property in general? Unfortunately, ACPI choose
>> a 16-bit type for this and used 'nv' for the RTX product. I don't find 'gn'
>> for Jetson very descriptive but we need a way to differentiate from RTX.
>>
>> This is needed in the Cypress CCGX driver for the following ...
>>
>> https://lore.kernel.org/lkml/20220928150840.3804313-1-waynec@nvidia.com/
>>
>> Ideally, this should have been included in this series but was sent before.
>> We can always re-work/update the above patch even though it has been queued
>> up now.
> 
> The driver seems to use this 16-bit value only to compare with a
> corresponding field in the firmware headers. How exactly we obtain this
> value is therefore not important. However, since this 16-bit value is
> embedded in firmware images, we also cannot substitute them with
> something more sensible.

I am actually wondering if this is actually embedded in any images 
because I see it populated by the i2c-nvidia-gpu.c driver [0]. So I am 
wondering if we can use PROPERTY_ENTRY_STRING() for this driver instead 
and have a more descriptive name such as 'nvidia,rtx'?

Jon

[0] 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/i2c/busses/i2c-nvidia-gpu.c#n261
  
Thierry Reding Oct. 28, 2022, 2:07 p.m. UTC | #5
On Fri, Oct 28, 2022 at 01:42:36PM +0100, Jon Hunter wrote:
> 
> On 28/10/2022 13:31, Thierry Reding wrote:
> > On Wed, Oct 26, 2022 at 08:13:57AM +0100, Jon Hunter wrote:
> > > 
> > > On 24/10/2022 08:41, Wayne Chang wrote:
> > > > add device-tree binding documentation for Cypress cypd4226 type-C
> > > > controller's I2C interface. It is a standard i2c slave with GPIO
> > > > input as IRQ interface.
> > > > 
> > > > Signed-off-by: Wayne Chang <waynec@nvidia.com>
> > > > ---
> > > >    .../bindings/usb/cypress,cypd4226.yaml        | 86 +++++++++++++++++++
> > > >    1 file changed, 86 insertions(+)
> > > >    create mode 100644 Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml
> > > > 
> > > > diff --git a/Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml b/Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml
> > > > new file mode 100644
> > > > index 000000000000..5ac28ab4e7a1
> > > > --- /dev/null
> > > > +++ b/Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml
> > > > @@ -0,0 +1,86 @@
> > > > +# 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 UCSI I2C Type-C Controller
> > > > +
> > > > +maintainers:
> > > > +  - Wayne Chang <waynec@nvidia.com>
> > > > +
> > > > +description: |
> > > > +  The Cypress cypd4226 UCSI I2C type-C controller is a I2C interface type-C
> > > > +  controller.
> > > > +
> > > > +properties:
> > > > +  compatible:
> > > > +    const: cypress,cypd4226
> > > > +
> > > > +  '#address-cells':
> > > > +    const: 1
> > > > +
> > > > +  '#size-cells':
> > > > +    const: 0
> > > > +
> > > > +  reg:
> > > > +    const: 0x08
> > > > +
> > > > +  interrupts:
> > > > +    maxItems: 1
> > > > +
> > > > +  cypress,firmware-build:
> > > > +    enum:
> > > > +      - nv
> > > > +      - gn
> > > > +    description: |
> > > > +      the name of the CCGx firmware built for product series.
> > > > +      should be set one of following:
> > > > +      - "nv" for the RTX product series
> > > 
> > > Please add 'NVIDIA' so that it is 'for the NVIDIA RTX product series'
> > > 
> > > > +      - "gn" for the Jetson product series
> > > 
> > > Same here please add 'NVIDIA' so that it is 'for the NVIDIA Jetson product
> > > series'.
> > > 
> > > Rob, any concerns about this property in general? Unfortunately, ACPI choose
> > > a 16-bit type for this and used 'nv' for the RTX product. I don't find 'gn'
> > > for Jetson very descriptive but we need a way to differentiate from RTX.
> > > 
> > > This is needed in the Cypress CCGX driver for the following ...
> > > 
> > > https://lore.kernel.org/lkml/20220928150840.3804313-1-waynec@nvidia.com/
> > > 
> > > Ideally, this should have been included in this series but was sent before.
> > > We can always re-work/update the above patch even though it has been queued
> > > up now.
> > 
> > The driver seems to use this 16-bit value only to compare with a
> > corresponding field in the firmware headers. How exactly we obtain this
> > value is therefore not important. However, since this 16-bit value is
> > embedded in firmware images, we also cannot substitute them with
> > something more sensible.
> 
> I am actually wondering if this is actually embedded in any images because I
> see it populated by the i2c-nvidia-gpu.c driver [0]. So I am wondering if we
> can use PROPERTY_ENTRY_STRING() for this driver instead and have a more
> descriptive name such as 'nvidia,rtx'?

What I mean by "embedded in firmware images" is that the value read from
the property is compared to values read from a firmware blob (either one
read back from the chip or one loaded using request_firmware()). See for
example ccg_check_vendor_version() and ccg_check_fw_version().

So the way that this 16-bit number is used is to define what type of
vendor firmware we support. So this is also used to avoid trying to load
a Tegra firmware on a GPU and vice versa.

So yes, we could potentially still make the i2c-nvidia-gpu.c driver add
a "nvidia,rtx" string to make it more descriptive like DT, but then we'd
still need to somehow resolve that to the "nv" string for the assignment
to uc->fw_build.

Not sure about how that would impact the AMD bits. Another of those CCGX
UCSI devices is registered by the i2c-designware-pcidrv.c driver, but it
doesn't pass a software node. From what I can tell that simply means all
of those checks will work with fw_build == 0x00. Primarily I think that
will cause flashing of the firmware not to be supported.

So yeah, having that string be something else (i.e. more descriptive)
and then match on that instead would definitely work. After looking at
this some more, using existing driver-matching may not work after all
because while there's ACPI matching and with this series DT matching,
the various GPU I2C instantiations are purely done in software, so they
have neither and therefore would need a secondary lookup mechanism. We
may be stuck with that ccgx,firmware-build property, but as you said it
should be possible to at least sanitize it.

Thierry

> 
> Jon
> 
> [0] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/i2c/busses/i2c-nvidia-gpu.c#n261
> -- 
> nvpublic
  
Wayne Chang Nov. 3, 2022, 10:47 a.m. UTC | #6
On 10/28/22 22:07, Thierry Reding wrote:
> On Fri, Oct 28, 2022 at 01:42:36PM +0100, Jon Hunter wrote:
>> On 28/10/2022 13:31, Thierry Reding wrote:
>>> On Wed, Oct 26, 2022 at 08:13:57AM +0100, Jon Hunter wrote:
>>>> On 24/10/2022 08:41, Wayne Chang wrote:
>>>>> add device-tree binding documentation for Cypress cypd4226 type-C
>>>>> controller's I2C interface. It is a standard i2c slave with GPIO
>>>>> input as IRQ interface.
>>>>>
>>>>> Signed-off-by: Wayne Chang<waynec@nvidia.com>
>>>>> ---
>>>>>     .../bindings/usb/cypress,cypd4226.yaml        | 86 +++++++++++++++++++
>>>>>     1 file changed, 86 insertions(+)
>>>>>     create mode 100644 Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml
>>>>>
>>>>> diff --git a/Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml b/Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml
>>>>> new file mode 100644
>>>>> index 000000000000..5ac28ab4e7a1
>>>>> --- /dev/null
>>>>> +++ b/Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml
>>>>> @@ -0,0 +1,86 @@
>>>>> +# 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 UCSI I2C Type-C Controller
>>>>> +
>>>>> +maintainers:
>>>>> +  - Wayne Chang<waynec@nvidia.com>
>>>>> +
>>>>> +description: |
>>>>> +  The Cypress cypd4226 UCSI I2C type-C controller is a I2C interface type-C
>>>>> +  controller.
>>>>> +
>>>>> +properties:
>>>>> +  compatible:
>>>>> +    const: cypress,cypd4226
>>>>> +
>>>>> +  '#address-cells':
>>>>> +    const: 1
>>>>> +
>>>>> +  '#size-cells':
>>>>> +    const: 0
>>>>> +
>>>>> +  reg:
>>>>> +    const: 0x08
>>>>> +
>>>>> +  interrupts:
>>>>> +    maxItems: 1
>>>>> +
>>>>> +  cypress,firmware-build:
>>>>> +    enum:
>>>>> +      - nv
>>>>> +      - gn
>>>>> +    description: |
>>>>> +      the name of the CCGx firmware built for product series.
>>>>> +      should be set one of following:
>>>>> +      - "nv" for the RTX product series
>>>> Please add 'NVIDIA' so that it is 'for the NVIDIA RTX product series'
>>>>
>>>>> +      - "gn" for the Jetson product series
>>>> Same here please add 'NVIDIA' so that it is 'for the NVIDIA Jetson product
>>>> series'.
>>>>
>>>> Rob, any concerns about this property in general? Unfortunately, ACPI choose
>>>> a 16-bit type for this and used 'nv' for the RTX product. I don't find 'gn'
>>>> for Jetson very descriptive but we need a way to differentiate from RTX.
>>>>
>>>> This is needed in the Cypress CCGX driver for the following ...
>>>>
>>>> https://lore.kernel.org/lkml/20220928150840.3804313-1-waynec@nvidia.com/
>>>>
>>>> Ideally, this should have been included in this series but was sent before.
>>>> We can always re-work/update the above patch even though it has been queued
>>>> up now.
>>> The driver seems to use this 16-bit value only to compare with a
>>> corresponding field in the firmware headers. How exactly we obtain this
>>> value is therefore not important. However, since this 16-bit value is
>>> embedded in firmware images, we also cannot substitute them with
>>> something more sensible.
>> I am actually wondering if this is actually embedded in any images because I
>> see it populated by the i2c-nvidia-gpu.c driver [0]. So I am wondering if we
>> can use PROPERTY_ENTRY_STRING() for this driver instead and have a more
>> descriptive name such as 'nvidia,rtx'?
> What I mean by "embedded in firmware images" is that the value read from
> the property is compared to values read from a firmware blob (either one
> read back from the chip or one loaded using request_firmware()). See for
> example ccg_check_vendor_version() and ccg_check_fw_version().
> 
> So the way that this 16-bit number is used is to define what type of
> vendor firmware we support. So this is also used to avoid trying to load
> a Tegra firmware on a GPU and vice versa.
> 
> So yes, we could potentially still make the i2c-nvidia-gpu.c driver add
> a "nvidia,rtx" string to make it more descriptive like DT, but then we'd
> still need to somehow resolve that to the "nv" string for the assignment
> to uc->fw_build.
> 
> Not sure about how that would impact the AMD bits. Another of those CCGX
> UCSI devices is registered by the i2c-designware-pcidrv.c driver, but it
> doesn't pass a software node. From what I can tell that simply means all
> of those checks will work with fw_build == 0x00. Primarily I think that
> will cause flashing of the firmware not to be supported.
> 
> So yeah, having that string be something else (i.e. more descriptive)
> and then match on that instead would definitely work. After looking at
> this some more, using existing driver-matching may not work after all
> because while there's ACPI matching and with this series DT matching,
> the various GPU I2C instantiations are purely done in software, so they
> have neither and therefore would need a secondary lookup mechanism. We
> may be stuck with that ccgx,firmware-build property, but as you said it
> should be possible to at least sanitize it.
> 

OK. Thanks for the review. I'll make the change to extend the property 
into string in the next patch series.

thanks,
Wayne.


> Thierry
> 
>> Jon
>>
>> [0]https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/i2c/busses/i2c-nvidia-gpu.c#n261
>> -- 
>> nvpublic
  

Patch

diff --git a/Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml b/Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml
new file mode 100644
index 000000000000..5ac28ab4e7a1
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml
@@ -0,0 +1,86 @@ 
+# 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 UCSI I2C Type-C Controller
+
+maintainers:
+  - Wayne Chang <waynec@nvidia.com>
+
+description: |
+  The Cypress cypd4226 UCSI I2C type-C controller is a I2C interface type-C
+  controller.
+
+properties:
+  compatible:
+    const: cypress,cypd4226
+
+  '#address-cells':
+    const: 1
+
+  '#size-cells':
+    const: 0
+
+  reg:
+    const: 0x08
+
+  interrupts:
+    maxItems: 1
+
+  cypress,firmware-build:
+    enum:
+      - nv
+      - gn
+    description: |
+      the name of the CCGx firmware built for product series.
+      should be set one of following:
+      - "nv" for the RTX product series
+      - "gn" for the Jetson product series
+
+patternProperties:
+  '^connector@[0-9a-f]+$':
+    $ref: /schemas/connector/usb-connector.yaml#
+    properties:
+      reg:
+        maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - interrupts
+
+additionalProperties: true
+
+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>;
+
+      ucsi_ccg: ucsi_ccg@8 {
+        compatible = "cypress,cypd4226";
+        interrupt-parent = <&gpio_aon>;
+        interrupts = <TEGRA194_AON_GPIO(BB, 2) IRQ_TYPE_LEVEL_LOW>;
+        reg = <0x08>;
+        cypress,firmware-build = "gn";
+        status = "okay";
+        #address-cells = <1>;
+        #size-cells = <0>;
+        ccg_typec_con0: connector@0 {
+          compatible = "usb-c-connector";
+          reg = <0>;
+          label = "USB-C";
+          data-role = "dual";
+          port {
+            ucsi_ccg_p0: endpoint {
+              remote-endpoint = <&usb_role_switch0>;
+            };
+          };
+        };
+      };
+    };