# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
# Copyright (c) 2020 Facebook Inc.
%YAML 1.2
---
$id: http://devicetree.org/schemas/usb/aspeed,usb-vhub.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: ASPEED USB 2.0 Virtual Hub Controller

maintainers:
  - Benjamin Herrenschmidt <benh@kernel.crashing.org>

description: |+
  The ASPEED USB 2.0 Virtual Hub Controller implements 1 set of USB Hub
  register and several sets of Device and Endpoint registers to support
  the Virtual Hub's downstream USB devices.

  Supported number of devices and endpoints vary depending on hardware
  revisions. AST2400 and AST2500 Virtual Hub supports 5 downstream devices
  and 15 generic endpoints, while AST2600 Virtual Hub supports 7 downstream
  devices and 21 generic endpoints.

properties:
  compatible:
    enum:
      - aspeed,ast2400-usb-vhub
      - aspeed,ast2500-usb-vhub
      - aspeed,ast2600-usb-vhub

  reg:
    maxItems: 1

  clocks:
    maxItems: 1

  interrupts:
    maxItems: 1

  aspeed,vhub-downstream-ports:
    description: Number of downstream ports supported by the Virtual Hub
    $ref: /schemas/types.yaml#/definitions/uint32
    default: 5
    minimum: 1
    maximum: 7

  aspeed,vhub-generic-endpoints:
    description: Number of generic endpoints supported by the Virtual Hub
    $ref: /schemas/types.yaml#/definitions/uint32
    default: 15
    minimum: 1
    maximum: 21

  vhub-vendor-id:
    description: vhub Vendor ID
    $ref: /schemas/types.yaml#/definitions/uint32
    maximum: 65535

  vhub-product-id:
    description: vhub Product ID
    $ref: /schemas/types.yaml#/definitions/uint32
    maximum: 65535

  vhub-device-revision:
    description: vhub Device Revision in binary-coded decimal
    $ref: /schemas/types.yaml#/definitions/uint32
    maximum: 65535

  vhub-strings:
    type: object
    additionalProperties: false

    properties:
      '#address-cells':
        const: 1

      '#size-cells':
        const: 0

    patternProperties:
      '^string@[0-9a-f]+$':
        type: object
        additionalProperties: false
        description: string descriptors of the specific language

        properties:
          reg:
            maxItems: 1
            description: 16-bit Language Identifier defined by USB-IF

          manufacturer:
            description: vhub manufacturer
            $ref: /schemas/types.yaml#/definitions/string

          product:
            description: vhub product name
            $ref: /schemas/types.yaml#/definitions/string

          serial-number:
            description: vhub device serial number
            $ref: /schemas/types.yaml#/definitions/string

required:
  - compatible
  - reg
  - clocks
  - interrupts
  - aspeed,vhub-downstream-ports
  - aspeed,vhub-generic-endpoints

additionalProperties: false

examples:
  - |
    #include <dt-bindings/clock/aspeed-clock.h>
    vhub: usb-vhub@1e6a0000 {
        compatible = "aspeed,ast2500-usb-vhub";
        reg = <0x1e6a0000 0x300>;
        interrupts = <5>;
        clocks = <&syscon ASPEED_CLK_GATE_USBPORT1CLK>;
        aspeed,vhub-downstream-ports = <5>;
        aspeed,vhub-generic-endpoints = <15>;
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_usb2ad_default>;

        vhub-vendor-id = <0x1d6b>;
        vhub-product-id = <0x0107>;
        vhub-device-revision = <0x0100>;
        vhub-strings {
            #address-cells = <1>;
            #size-cells = <0>;

            string@409 {
                reg = <0x409>;
                manufacturer = "ASPEED";
                product = "USB Virtual Hub";
                serial-number = "0000";
            };
        };
    };
