# SPDX-License-Identifier: GPL-2.0-only
%YAML 1.2
---
$id: http://devicetree.org/schemas/spi/snps,dw-apb-ssi.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: Synopsys DesignWare AMBA 2.0 Synchronous Serial Interface

maintainers:
  - Mark Brown <broonie@kernel.org>

allOf:
  - $ref: spi-controller.yaml#
  - if:
      properties:
        compatible:
          contains:
            enum:
              - mscc,ocelot-spi
              - mscc,jaguar2-spi
    then:
      properties:
        reg:
          minItems: 2
  - if:
      properties:
        compatible:
          contains:
            const: amd,pensando-elba-spi
    then:
      required:
        - amd,pensando-elba-syscon
    else:
      properties:
        amd,pensando-elba-syscon: false
  - if:
      properties:
        compatible:
          contains:
            const: starfive,jhb100-sfc
    then:
      required:
        - starfive,sfc-filter-syscon
    else:
      properties:
        starfive,sfc-filter-syscon: false
  - if:
      properties:
        compatible:
          contains:
            const: ultrarisc,dp1000-spi
    then:
      properties:
        reg:
          maxItems: 1
        clocks:
          minItems: 2
        clock-names:
          minItems: 2
      required:
        - clock-names

properties:
  compatible:
    oneOf:
      - description: Generic DW SPI Controller
        enum:
          - snps,dw-apb-ssi
          - snps,dwc-ssi-1.01a
      - description: Microchip Sparx5 SoC SPI Controller
        const: microchip,sparx5-spi
      - description: Amazon Alpine SPI Controller
        const: amazon,alpine-dw-apb-ssi
      - description: Vendor controllers which use snps,dw-apb-ssi as fallback
        items:
          - enum:
              - mscc,ocelot-spi
              - mscc,jaguar2-spi
              - sophgo,sg2042-spi
              - syna,sl2610-spi
              - thead,th1520-spi
              - ultrarisc,dp1000-spi
          - const: snps,dw-apb-ssi
      - description: Vendor controllers compatible with v1.01a
        items:
          - enum:
              - axiado,ax3005-spi
          - const: snps,dwc-ssi-1.01a
      - description: Vendor controllers which use snps,dwc-ssi-2.00a as fallback
        items:
          - enum:
              - starfive,jhb100-spi
          - const: snps,dwc-ssi-2.00a
          - const: snps,dwc-ssi-1.01a
      - description: Intel Keem Bay SPI Controller
        const: intel,keembay-ssi
      - description: Intel Mount Evans Integrated Management Complex SPI Controller
        const: intel,mountevans-imc-ssi
      - description: AMD Pensando Elba SoC SPI Controller
        const: amd,pensando-elba-spi
      - description: Canaan Kendryte K210 SoS SPI Controller
        const: canaan,k210-spi
      - description: StarFive JHB100 SoC SPI Flash Controller
        const: starfive,jhb100-sfc
      - description: Renesas RZ/N1 SPI Controller
        items:
          - const: renesas,r9a06g032-spi # RZ/N1D
          - const: renesas,rzn1-spi   # RZ/N1

  reg:
    minItems: 1
    items:
      - description: DW APB SSI controller memory mapped registers
      - description: SPI MST region map or directly mapped SPI ROM

  interrupts:
    maxItems: 1

  clocks:
    minItems: 1
    items:
      - description: SPI Controller reference clock source
      - description: APB interface clock source

  clock-names:
    minItems: 1
    items:
      - const: ssi_clk
      - const: pclk

  power-domains:
    maxItems: 1

  resets:
    maxItems: 1

  reset-names:
    const: spi

  reg-io-width:
    description: I/O register width (in bytes) implemented by this device
    default: 4
    enum: [ 2, 4 ]

  num-cs:
    default: 4
    minimum: 1
    maximum: 16

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

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

  rx-sample-delay-ns:
    default: 0
    description: |
      Default value of the rx-sample-delay-ns property.
      This value will be used if the property is not explicitly defined
      for a SPI slave device.

      SPI Rx sample delay offset, unit is nanoseconds.
      The delay from the default sample time before the actual sample of the
      rxd input signal occurs. The "rx_sample_delay" is an optional feature
      of the designware controller, and the upper limit is also subject to
      controller configuration.

  amd,pensando-elba-syscon:
    $ref: /schemas/types.yaml#/definitions/phandle-array
    description:
      Block address to control SPI chip-selects. The Elba SoC system controller
      provides an interface to override the native DWC SSI CS control.

  starfive,sfc-filter-syscon:
    $ref: /schemas/types.yaml#/definitions/phandle-array
    description:
      Phandle to the system controller register that controls the SPI NOR flash
      address mode filter. This system controller interface provides additional
      configuration to switch between 3-byte and 4-byte addressing modes, which
      is required when accessing SPI NOR flash devices with different address
      width requirements.

patternProperties:
  "@[0-9a-f]$":
    type: object
    additionalProperties: true

    properties:
      reg:
        minimum: 0
        maximum: 0xf

unevaluatedProperties: false

required:
  - compatible
  - reg
  - "#address-cells"
  - "#size-cells"
  - clocks
  - interrupts

examples:
  - |
    spi@fff00000 {
      compatible = "snps,dw-apb-ssi";
      reg = <0xfff00000 0x1000>;
      #address-cells = <1>;
      #size-cells = <0>;
      interrupts = <0 154 4>;
      clocks = <&spi_m_clk>;
      num-cs = <2>;
      cs-gpios = <&gpio0 13 0>,
                 <&gpio0 14 0>;
      rx-sample-delay-ns = <3>;
      flash@1 {
        compatible = "spi-nand";
        reg = <1>;
        rx-sample-delay-ns = <7>;
      };
    };
...