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

title: Texas Instruments 6598x Type-C Port Switch and Power Delivery controller

maintainers:
  - Bryan O'Donoghue <bryan.odonoghue@linaro.org>

description: |
  Texas Instruments 6598x Type-C Port Switch and Power Delivery controller

  A variant of this controller known as Apple CD321x or Apple ACE is also
  present on hardware with Apple SoCs such as the M1.

properties:
  compatible:
    enum:
      - ti,tps6598x
      - apple,cd321x
      - ti,tps25750

  reg:
    minItems: 1
    items:
      - description: main PD controller address
      - description: |
          I2C slave address field in PBMs input data
          which is used as the device address when writing the
          patch for TPS25750.
          The patch address can be any value except 0x00, 0x20,
          0x21, 0x22, and 0x23

  reg-names:
    items:
      - const: main
      - const: patch-address

  reset-gpios:
    description: GPIO used for the HRESET pin.
    maxItems: 1

  wakeup-source: true

  interrupts:
    maxItems: 1

  interrupt-names:
    items:
      - const: irq

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

  firmware-name:
    description: |
      Should contain the name of the default patch binary
      file located on the firmware search path which is
      used to switch the controller into APP mode.
      This is used when tps25750 doesn't have an EEPROM
      connected to it.
    maxItems: 1

required:
  - compatible
  - reg

allOf:
  - if:
      properties:
        compatible:
          contains:
            const: ti,tps25750
    then:
      properties:
        reg:
          maxItems: 2

        connector:
          required:
            - data-role

      required:
        - connector
        - reg-names
    else:
      properties:
        reg:
          maxItems: 1

additionalProperties: false

examples:
  - |
    #include <dt-bindings/gpio/gpio.h>
    #include <dt-bindings/interrupt-controller/irq.h>
    i2c {
        #address-cells = <1>;
        #size-cells = <0>;

        tps6598x: tps6598x@38 {
            compatible = "ti,tps6598x";
            reg = <0x38>;
            wakeup-source;

            interrupt-parent = <&msmgpio>;
            interrupts = <107 IRQ_TYPE_LEVEL_LOW>;
            interrupt-names = "irq";

            pinctrl-names = "default";
            pinctrl-0 = <&typec_pins>;
            reset-gpios = <&gpio1 6 GPIO_ACTIVE_HIGH>;

            typec_con: connector {
                compatible = "usb-c-connector";
                label = "USB-C";
                port {
                    typec_ep: endpoint {
                        remote-endpoint = <&otg_ep>;
                    };
                };
            };
        };
    };

  - |
    #include <dt-bindings/interrupt-controller/irq.h>
    i2c {
        #address-cells = <1>;
        #size-cells = <0>;

        typec@21 {
            compatible = "ti,tps25750";
            reg = <0x21>, <0x0f>;
            reg-names = "main", "patch-address";

            interrupt-parent = <&msmgpio>;
            interrupts = <100 IRQ_TYPE_LEVEL_LOW>;
            interrupt-names = "irq";
            firmware-name = "tps25750.bin";

            pinctrl-names = "default";
            pinctrl-0 = <&typec_pins>;

            typec_con0: connector {
                compatible = "usb-c-connector";
                label = "USB-C";
                data-role = "dual";
                port {
                    typec_ep0: endpoint {
                        remote-endpoint = <&otg_ep>;
                    };
                };
            };
        };
    };
...
