# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/usb/chipidea,usb2-imx.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: NXP USB2 ChipIdea USB controller

maintainers:
  - Xu Yang <xu.yang_2@nxp.com>

properties:
  compatible:
    oneOf:
      - enum:
          - fsl,imx27-usb
      - items:
          - enum:
              - fsl,imx23-usb
              - fsl,imx25-usb
              - fsl,imx28-usb
              - fsl,imx35-usb
              - fsl,imx50-usb
              - fsl,imx51-usb
              - fsl,imx53-usb
              - fsl,imx6q-usb
              - fsl,imx6sl-usb
              - fsl,imx6sx-usb
              - fsl,imx6ul-usb
              - fsl,imx7d-usb
              - fsl,vf610-usb
          - const: fsl,imx27-usb
      - items:
          - enum:
              - fsl,imx8dxl-usb
              - fsl,imx8ulp-usb
          - const: fsl,imx7ulp-usb
          - const: fsl,imx6ul-usb
      - items:
          - enum:
              - fsl,imx8mm-usb
              - fsl,imx8mn-usb
              - fsl,imx93-usb
          - const: fsl,imx7d-usb
          - const: fsl,imx27-usb
      - items:
          - enum:
              - fsl,imx6sll-usb
              - fsl,imx7ulp-usb
          - const: fsl,imx6ul-usb
          - const: fsl,imx27-usb

  reg:
    maxItems: 1

  interrupts:
    maxItems: 1

  clocks:
    minItems: 1
    maxItems: 3

  clock-names:
    minItems: 1
    maxItems: 3

  fsl,usbmisc:
    description:
      Phandler of non-core register device, with one argument that
      indicate usb controller index
    $ref: /schemas/types.yaml#/definitions/phandle-array
    items:
      - items:
          - description: phandle to usbmisc node
          - description: index of usb controller

  disable-over-current:
    type: boolean
    description: disable over current detect

  over-current-active-low:
    type: boolean
    description: over current signal polarity is active low

  over-current-active-high:
    type: boolean
    description:
      Over current signal polarity is active high. It's recommended to
      specify the over current polarity.

  power-active-high:
    type: boolean
    description: power signal polarity is active high

  external-vbus-divider:
    type: boolean
    description: enables off-chip resistor divider for Vbus

  samsung,picophy-pre-emp-curr-control:
    description:
      HS Transmitter Pre-Emphasis Current Control. This signal controls
      the amount of current sourced to the USB_OTG*_DP and USB_OTG*_DN
      pins after a J-to-K or K-to-J transition. The range is from 0x0 to
      0x3, the default value is 0x1. Details can refer to TXPREEMPAMPTUNE0
      bits of USBNC_n_PHY_CFG1.
    $ref: /schemas/types.yaml#/definitions/uint32
    minimum: 0x0
    maximum: 0x3

  samsung,picophy-dc-vol-level-adjust:
    description:
      HS DC Voltage Level Adjustment. Adjust the high-speed transmitter DC
      level voltage. The range is from 0x0 to 0xf, the default value is
      0x3. Details can refer to TXVREFTUNE0 bits of USBNC_n_PHY_CFG1.
    $ref: /schemas/types.yaml#/definitions/uint32
    minimum: 0x0
    maximum: 0xf

  fsl,picophy-rise-fall-time-adjust:
    description:
      HS Transmitter Rise/Fall Time Adjustment. Adjust the rise/fall times
      of the high-speed transmitter waveform. It has no unit. The rise/fall
      time will be increased or decreased by a certain percentage relative
      to design default time. (0:-10%; 1:design default; 2:+15%; 3:+20%)
      Details can refer to TXRISETUNE0 bit of USBNC_n_PHY_CFG1.
    $ref: /schemas/types.yaml#/definitions/uint32
    minimum: 0
    maximum: 3
    default: 1

  fsl,usbphy:
    description: phandle of usb phy that connects to the port. Use "phys" instead.
    $ref: /schemas/types.yaml#/definitions/phandle
    deprecated: true

required:
  - compatible

allOf:
  - $ref: chipidea,usb2-common.yaml#
  - if:
      properties:
        phy_type:
          const: hsic
      required:
        - phy_type
    then:
      properties:
        pinctrl-names:
          items:
            - const: idle
            - const: active

  # imx27 Soc needs three clocks
  - if:
      properties:
        compatible:
          const: fsl,imx27-usb
    then:
      properties:
        clocks:
          minItems: 3
        clock-names:
          items:
            - const: ipg
            - const: ahb
            - const: per

  # imx25 and imx35 Soc need three clocks
  - if:
      properties:
        compatible:
          contains:
            enum:
              - fsl,imx25-usb
              - fsl,imx35-usb
    then:
      properties:
        clocks:
          minItems: 3
        clock-names:
          items:
            - const: ipg
            - const: ahb
            - const: per

  # imx93 Soc needs two clocks
  - if:
      properties:
        compatible:
          contains:
            enum:
              - fsl,imx93-usb
    then:
      properties:
        clocks:
          minItems: 2
          maxItems: 2
        clock-names:
          items:
            - const: usb_ctrl_root
            - const: usb_wakeup

  # imx7d Soc need one clock
  - if:
      properties:
        compatible:
          items:
            - const: fsl,imx7d-usb
            - const: fsl,imx27-usb
    then:
      properties:
        clocks:
          maxItems: 1
        clock-names: false

  # other Soc need one clock
  - if:
      properties:
        compatible:
          contains:
            enum:
              - fsl,imx23-usb
              - fsl,imx28-usb
              - fsl,imx50-usb
              - fsl,imx51-usb
              - fsl,imx53-usb
              - fsl,imx6q-usb
              - fsl,imx6sl-usb
              - fsl,imx6sx-usb
              - fsl,imx6ul-usb
              - fsl,imx8mm-usb
              - fsl,imx8mn-usb
              - fsl,vf610-usb
    then:
      properties:
        clocks:
          maxItems: 1
        clock-names: false

unevaluatedProperties: false

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

    usb@30b10000 {
        compatible = "fsl,imx7d-usb", "fsl,imx27-usb";
        reg = <0x30b10000 0x200>;
        interrupts = <GIC_SPI 43 IRQ_TYPE_LEVEL_HIGH>;
        clocks = <&clks IMX7D_USB_CTRL_CLK>;
        fsl,usbphy = <&usbphynop1>;
        fsl,usbmisc = <&usbmisc1 0>;
        phy-clkgate-delay-us = <400>;
    };

  # Example for HSIC:
  - |
    #include <dt-bindings/interrupt-controller/arm-gic.h>
    #include <dt-bindings/clock/imx6qdl-clock.h>

    usb@2184400 {
        compatible = "fsl,imx6q-usb", "fsl,imx27-usb";
        reg = <0x02184400 0x200>;
        interrupts = <0 41 IRQ_TYPE_LEVEL_HIGH>;
        clocks = <&clks IMX6QDL_CLK_USBOH3>;
        fsl,usbphy = <&usbphynop1>;
        fsl,usbmisc = <&usbmisc 2>;
        phy_type = "hsic";
        dr_mode = "host";
        ahb-burst-config = <0x0>;
        tx-burst-size-dword = <0x10>;
        rx-burst-size-dword = <0x10>;
        pinctrl-names = "idle", "active";
        pinctrl-0 = <&pinctrl_usbh2_idle>;
        pinctrl-1 = <&pinctrl_usbh2_active>;
        #address-cells = <1>;
        #size-cells = <0>;

        ethernet@1 {
            compatible = "usb424,9730";
            reg = <1>;
        };
    };

...
