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

title: TI DaVinci/Keystone SPI Controller

maintainers:
  - Bartosz Golaszewski <brgl@kernel.org>

properties:
  compatible:
    oneOf:
      - enum:
          - ti,da830-spi
          - ti,keystone-spi
          - ti,dm6441-spi
      - items:
          - const: ti,keystone-spi
          - const: ti,dm6441-spi

  reg:
    maxItems: 1

  interrupts:
    maxItems: 1

  clocks:
    maxItems: 1

  power-domains:
    maxItems: 1
    description:
      Should contain a phandle to a PM domain provider node
      and an args specifier containing the SPI device id
      value.

  num-cs:
    minimum: 1
    default: 1
    description:
      Number of chip selects supported by the controller. This
      includes both internal and GPIO chip selects.

  ti,davinci-spi-intr-line:
    $ref: /schemas/types.yaml#/definitions/uint32
    enum: [0, 1]
    description:
      Interrupt line used to connect the SPI IP to the interrupt
      controller within the SoC.  The SPI peripheral can route its
      interrupt output to one of two lines (INT0 or INT1). Set
      this based on the SoC-specific wiring to the interrupt
      controller.

  dmas:
    items:
      - description: RX DMA channel
      - description: TX DMA channel

  dma-names:
    items:
      - const: rx
      - const: tx

  "#address-cells":
    const: 1

required:
  - compatible
  - reg
  - interrupts
  - clocks
  - ti,davinci-spi-intr-line
  - num-cs
  - "#address-cells"
  - "#size-cells"

allOf:
  - $ref: spi-controller.yaml#
  - if:
      properties:
        compatible:
          items:
            - const: ti,keystone-spi
    then:
      required:
        - power-domains

unevaluatedProperties: false

examples:
  - |
    spi@20bf0000 {
        compatible = "ti,keystone-spi", "ti,dm6441-spi";
        reg = <0x20bf0000 0x1000>;
        num-cs = <4>;
        ti,davinci-spi-intr-line = <0>;
        interrupts = <338>;
        clocks = <&clkspi>;
        #address-cells = <1>;
        #size-cells = <0>;

        flash@0 {
            compatible = "jedec,spi-nor";
            spi-max-frequency = <25000000>;
            reg = <0>;
            ti,spi-wdelay = <8>;
        };
    };

  - |
    spi@41000 {
        compatible = "ti,da830-spi";
        reg = <0x41000 0x1000>;
        num-cs = <6>;
        ti,davinci-spi-intr-line = <1>;
        interrupts = <20>;
        dmas = <&edma0 14 0>, <&edma0 15 0>;
        dma-names = "rx", "tx";
        clocks = <&psc0 4>;
        power-domains = <&psc0 4>;
        #address-cells = <1>;
        #size-cells = <0>;
    };