# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
%YAML 1.2
---
$id: http://devicetree.org/schemas/phy/nvidia,tegra194-xusb-padctl.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: NVIDIA Tegra194 XUSB pad controller

maintainers:
  - Thierry Reding <thierry.reding@gmail.com>
  - Jon Hunter <jonathanh@nvidia.com>

description: |
  The Tegra XUSB pad controller manages a set of I/O lanes (with differential
  signals) which connect directly to pins/pads on the SoC package. Each lane
  is controlled by a HW block referred to as a "pad" in the Tegra hardware
  documentation. Each such "pad" may control either one or multiple lanes,
  and thus contains any logic common to all its lanes. Each lane can be
  separately configured and powered up.

  Some of the lanes are high-speed lanes, which can be used for PCIe, SATA or
  super-speed USB. Other lanes are for various types of low-speed, full-speed
  or high-speed USB (such as UTMI, ULPI and HSIC). The XUSB pad controller
  contains a software-configurable mux that sits between the I/O controller
  ports (e.g. PCIe) and the lanes.

  In addition to per-lane configuration, USB 3.0 ports may require additional
  settings on a per-board basis.

  Pads will be represented as children of the top-level XUSB pad controller
  device tree node. Each lane exposed by the pad will be represented by its
  own subnode and can be referenced by users of the lane using the standard
  PHY bindings, as described by the phy-bindings.txt file in this directory.

  The Tegra hardware documentation refers to the connection between the XUSB
  pad controller and the XUSB controller as "ports". This is confusing since
  "port" is typically used to denote the physical USB receptacle. The device
  tree binding in this document uses the term "port" to refer to the logical
  abstraction of the signals that are routed to a USB receptacle (i.e. a PHY
  for the USB signal, the VBUS power supply, the USB 2.0 companion port for
  USB 3.0 receptacles, ...).

properties:
  compatible:
    enum:
      - nvidia,tegra194-xusb-padctl
      - nvidia,tegra234-xusb-padctl

  reg:
    items:
      - description: pad controller registers
      - description: AO registers

  reg-names:
    items:
      - const: padctl
      - const: ao

  interrupts:
    items:
      - description: XUSB pad controller interrupt

  resets:
    items:
      - description: pad controller reset

  reset-names:
    items:
      - const: padctl

  avdd-usb-supply:
    description: USB I/Os, VBUS, ID, REXT, D+/D- power supply. Must
      supply 3.3 V.

  vclamp-usb-supply:
    description: Bias rail for USB pad. Must supply 1.8 V.

  pads:
    description: A required child node named "pads" contains a list of
      subnodes, one for each of the pads exposed by the XUSB pad controller.
      Each pad may need additional resources that can be referenced in its
      pad node.

      The "status" property is used to enable or disable the use of a pad.
      If set to "disabled", the pad will not be used on the given board. In
      order to use the pad and any of its lanes, this property must be set
      to "okay" or absent.
    type: object
    additionalProperties: false
    properties:
      usb2:
        type: object
        additionalProperties: false
        properties:
          clocks:
            items:
              - description: USB2 tracking clock

          clock-names:
            items:
              - const: trk

          lanes:
            type: object
            additionalProperties: false
            properties:
              usb2-0:
                type: object
                additionalProperties: false
                properties:
                  "#phy-cells":
                    const: 0

                  nvidia,function:
                    description: Function selection for this lane.
                    $ref: /schemas/types.yaml#/definitions/string
                    enum: [ xusb ]

              usb2-1:
                type: object
                additionalProperties: false
                properties:
                  "#phy-cells":
                    const: 0

                  nvidia,function:
                    description: Function selection for this lane.
                    $ref: /schemas/types.yaml#/definitions/string
                    enum: [ xusb ]

              usb2-2:
                type: object
                additionalProperties: false
                properties:
                  "#phy-cells":
                    const: 0

                  nvidia,function:
                    description: Function selection for this lane.
                    $ref: /schemas/types.yaml#/definitions/string
                    enum: [ xusb ]

              usb2-3:
                type: object
                additionalProperties: false
                properties:
                  "#phy-cells":
                    const: 0

                  nvidia,function:
                    description: Function selection for this lane.
                    $ref: /schemas/types.yaml#/definitions/string
                    enum: [ xusb ]

      usb3:
        type: object
        additionalProperties: false
        properties:
          lanes:
            type: object
            additionalProperties: false
            properties:
              usb3-0:
                type: object
                additionalProperties: false
                properties:
                  "#phy-cells":
                    const: 0

                  nvidia,function:
                    description: Function selection for this lane.
                    $ref: /schemas/types.yaml#/definitions/string
                    enum: [ xusb ]

              usb3-1:
                type: object
                additionalProperties: false
                properties:
                  "#phy-cells":
                    const: 0

                  nvidia,function:
                    description: Function selection for this lane.
                    $ref: /schemas/types.yaml#/definitions/string
                    enum: [ xusb ]

              usb3-2:
                type: object
                additionalProperties: false
                properties:
                  "#phy-cells":
                    const: 0

                  nvidia,function:
                    description: Function selection for this lane.
                    $ref: /schemas/types.yaml#/definitions/string
                    enum: [ xusb ]

              usb3-3:
                type: object
                additionalProperties: false
                properties:
                  "#phy-cells":
                    const: 0

                  nvidia,function:
                    description: Function selection for this lane.
                    $ref: /schemas/types.yaml#/definitions/string
                    enum: [ xusb ]

  ports:
    description: A required child node named "ports" contains a list of
      subnodes, one for each of the ports exposed by the XUSB pad controller.
      Each port may need additional resources that can be referenced in its
      port node.

      The "status" property is used to enable or disable the use of a port.
      If set to "disabled", the port will not be used on the given board. In
      order to use the port, this property must be set to "okay".
    type: object
    additionalProperties: false
    properties:
      usb2-0:
        type: object
        additionalProperties: false
        properties:
          # no need to further describe this because the connector will
          # match on gpio-usb-b-connector or usb-b-connector and cause
          # that binding to be selected for the subnode
          connector:
            type: object

          mode:
            description: A string that determines the mode in which to
              run the port.
            $ref: /schemas/types.yaml#/definitions/string
            enum: [ host, peripheral, otg ]

          nvidia,internal:
            description: A boolean property whose presence determines
              that a port is internal. In the absence of this property
              the port is considered to be external.
            $ref: /schemas/types.yaml#/definitions/flag

          usb-role-switch:
            description: |
              A boolean property whole presence indicates that the port
              supports OTG or peripheral mode. If present, the port
              supports switching between USB host and peripheral roles.
              A connector must be added as a subnode in that case.

              See ../connector/usb-connector.yaml.

          vbus-supply:
            description: A phandle to the regulator supplying the VBUS
              voltage.

        dependencies:
          usb-role-switch: [ connector ]

      usb2-1:
        type: object
        additionalProperties: false
        properties:
          # no need to further describe this because the connector will
          # match on gpio-usb-b-connector or usb-b-connector and cause
          # that binding to be selected for the subnode
          connector:
            type: object

          mode:
            description: A string that determines the mode in which to
              run the port.
            $ref: /schemas/types.yaml#/definitions/string
            enum: [ host, peripheral, otg ]

          nvidia,internal:
            description: A boolean property whose presence determines
              that a port is internal. In the absence of this property
              the port is considered to be external.
            $ref: /schemas/types.yaml#/definitions/flag

          usb-role-switch:
            description: |
              A boolean property whole presence indicates that the port
              supports OTG or peripheral mode. If present, the port
              supports switching between USB host and peripheral roles.
              A connector must be added as a subnode in that case.

              See ../connector/usb-connector.yaml.

          vbus-supply:
            description: A phandle to the regulator supplying the VBUS
              voltage.

        dependencies:
          usb-role-switch: [ connector ]

      usb2-2:
        type: object
        additionalProperties: false
        properties:
          # no need to further describe this because the connector will
          # match on gpio-usb-b-connector or usb-b-connector and cause
          # that binding to be selected for the subnode
          connector:
            type: object

          mode:
            description: A string that determines the mode in which to
              run the port.
            $ref: /schemas/types.yaml#/definitions/string
            enum: [ host, peripheral, otg ]

          nvidia,internal:
            description: A boolean property whose presence determines
              that a port is internal. In the absence of this property
              the port is considered to be external.
            $ref: /schemas/types.yaml#/definitions/flag

          usb-role-switch:
            description: |
              A boolean property whole presence indicates that the port
              supports OTG or peripheral mode. If present, the port
              supports switching between USB host and peripheral roles.
              A connector must be added as a subnode in that case.

              See ../connector/usb-connector.yaml.

          vbus-supply:
            description: A phandle to the regulator supplying the VBUS
              voltage.

        dependencies:
          usb-role-switch: [ connector ]

      usb2-3:
        type: object
        additionalProperties: false
        properties:
          # no need to further describe this because the connector will
          # match on gpio-usb-b-connector or usb-b-connector and cause
          # that binding to be selected for the subnode
          connector:
            type: object

          mode:
            description: A string that determines the mode in which to
              run the port.
            $ref: /schemas/types.yaml#/definitions/string
            enum: [ host, peripheral, otg ]

          nvidia,internal:
            description: A boolean property whose presence determines
              that a port is internal. In the absence of this property
              the port is considered to be external.
            $ref: /schemas/types.yaml#/definitions/flag

          usb-role-switch:
            description: |
              A boolean property whole presence indicates that the port
              supports OTG or peripheral mode. If present, the port
              supports switching between USB host and peripheral roles.
              A connector must be added as a subnode in that case.

              See ../connector/usb-connector.yaml.

          vbus-supply:
            description: A phandle to the regulator supplying the VBUS
              voltage.

        dependencies:
          usb-role-switch: [ connector ]

      usb3-0:
        type: object
        additionalProperties: false
        properties:
          maximum-speed:
            description: A string property that specifies the maximum
              supported speed of a USB3 port.
            $ref: /schemas/types.yaml#/definitions/string
            oneOf:
              - description: The USB3 port supports USB 3.1 Gen 2 speed.
                  This is the default.
                const: super-speed-plus
              - description: The USB3 port supports USB 3.1 Gen 1 speed
                  only.
                const: super-speed

          nvidia,internal:
            description: A boolean property whose presence determines
              that a port is internal. In the absence of this property
              the port is considered to be external.
            $ref: /schemas/types.yaml#/definitions/flag

          nvidia,usb2-companion:
            description: A single cell that specifies the physical port
              number to map this super-speed USB port to. The range of
              valid port numbers varies with the SoC generation.
            $ref: /schemas/types.yaml#/definitions/uint32
            enum: [ 0, 1, 2, 3 ]

          vbus-supply:
            description: A phandle to the regulator supplying the VBUS
              voltage.

      usb3-1:
        type: object
        additionalProperties: false
        properties:
          maximum-speed:
            description: A string property that specifies the maximum
              supported speed of a USB3 port.
            $ref: /schemas/types.yaml#/definitions/string
            oneOf:
              - description: The USB3 port supports USB 3.1 Gen 2 speed.
                  This is the default.
                const: super-speed-plus
              - description: The USB3 port supports USB 3.1 Gen 1 speed
                  only.
                const: super-speed

          nvidia,internal:
            description: A boolean property whose presence determines
              that a port is internal. In the absence of this property
              the port is considered to be external.
            $ref: /schemas/types.yaml#/definitions/flag

          nvidia,usb2-companion:
            description: A single cell that specifies the physical port
              number to map this super-speed USB port to. The range of
              valid port numbers varies with the SoC generation.
            $ref: /schemas/types.yaml#/definitions/uint32
            enum: [ 0, 1, 2, 3 ]

          vbus-supply:
            description: A phandle to the regulator supplying the VBUS
              voltage.

      usb3-2:
        type: object
        additionalProperties: false
        properties:
          maximum-speed:
            description: A string property that specifies the maximum
              supported speed of a USB3 port.
            $ref: /schemas/types.yaml#/definitions/string
            oneOf:
              - description: The USB3 port supports USB 3.1 Gen 2 speed.
                  This is the default.
                const: super-speed-plus
              - description: The USB3 port supports USB 3.1 Gen 1 speed
                  only.
                const: super-speed

          nvidia,internal:
            description: A boolean property whose presence determines
              that a port is internal. In the absence of this property
              the port is considered to be external.
            $ref: /schemas/types.yaml#/definitions/flag

          nvidia,usb2-companion:
            description: A single cell that specifies the physical port
              number to map this super-speed USB port to. The range of
              valid port numbers varies with the SoC generation.
            $ref: /schemas/types.yaml#/definitions/uint32
            enum: [ 0, 1, 2, 3 ]

          vbus-supply:
            description: A phandle to the regulator supplying the VBUS
              voltage.

      usb3-3:
        type: object
        additionalProperties: false
        properties:
          maximum-speed:
            description: A string property that specifies the maximum
              supported speed of a USB3 port.
            $ref: /schemas/types.yaml#/definitions/string
            oneOf:
              - description: The USB3 port supports USB 3.1 Gen 2 speed.
                  This is the default.
                const: super-speed-plus
              - description: The USB3 port supports USB 3.1 Gen 1 speed
                  only.
                const: super-speed

          nvidia,internal:
            description: A boolean property whose presence determines
              that a port is internal. In the absence of this property
              the port is considered to be external.
            $ref: /schemas/types.yaml#/definitions/flag

          nvidia,usb2-companion:
            description: A single cell that specifies the physical port
              number to map this super-speed USB port to. The range of
              valid port numbers varies with the SoC generation.
            $ref: /schemas/types.yaml#/definitions/uint32
            enum: [ 0, 1, 2, 3 ]

          vbus-supply:
            description: A phandle to the regulator supplying the VBUS
              voltage.

additionalProperties: false

required:
  - compatible
  - reg
  - resets
  - reset-names
  - avdd-usb-supply
  - vclamp-usb-supply

examples:
  - |
    #include <dt-bindings/clock/tegra194-clock.h>
    #include <dt-bindings/gpio/tegra194-gpio.h>
    #include <dt-bindings/interrupt-controller/arm-gic.h>
    #include <dt-bindings/reset/tegra194-reset.h>

    padctl@3520000 {
        compatible = "nvidia,tegra194-xusb-padctl";
        reg = <0x03520000 0x1000>,
              <0x03540000 0x1000>;
        reg-names = "padctl", "ao";
        interrupts = <GIC_SPI 167 IRQ_TYPE_LEVEL_HIGH>;

        resets = <&bpmp TEGRA194_RESET_XUSB_PADCTL>;
        reset-names = "padctl";

        avdd-usb-supply = <&vdd_usb_3v3>;
        vclamp-usb-supply = <&vdd_1v8ao>;

        pads {
            usb2 {
                clocks = <&bpmp TEGRA194_CLK_USB2_TRK>;
                clock-names = "trk";

                lanes {
                    usb2-0 {
                        nvidia,function = "xusb";
                        status = "disabled";
                        #phy-cells = <0>;
                    };

                    usb2-1 {
                        nvidia,function = "xusb";
                        #phy-cells = <0>;
                    };

                    usb2-2 {
                        nvidia,function = "xusb";
                        status = "disabled";
                        #phy-cells = <0>;
                    };

                    usb2-3 {
                        nvidia,function = "xusb";
                        #phy-cells = <0>;
                    };
                };
            };

            usb3 {
                lanes {
                    usb3-0 {
                        nvidia,function = "xusb";
                        #phy-cells = <0>;
                    };

                    usb3-1 {
                        nvidia,function = "xusb";
                        status = "disabled";
                        #phy-cells = <0>;
                    };

                    usb3-2 {
                        nvidia,function = "xusb";
                        status = "disabled";
                        #phy-cells = <0>;
                    };

                    usb3-3 {
                        nvidia,function = "xusb";
                        #phy-cells = <0>;
                    };
                };
            };
        };

        ports {
            usb2-0 {
                status = "disabled";
            };

            usb2-1 {
                vbus-supply = <&vdd_5v0_sys>;
                mode = "host";
            };

            usb2-2 {
                status = "disabled";
            };

            usb2-3 {
                vbus-supply = <&vdd_5v_sata>;
                mode = "host";
            };

            usb3-0 {
                vbus-supply = <&vdd_5v0_sys>;
                nvidia,usb2-companion = <1>;
            };

            usb3-1 {
                status = "disabled";
            };

            usb3-2 {
                status = "disabled";
            };

            usb3-3 {
                maximum-speed = "super-speed";
                vbus-supply = <&vdd_5v0_sys>;
                nvidia,usb2-companion = <3>;
            };
        };
    };
