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

title: Rockchip Electronics Security Accelerator

maintainers:
  - Heiko Stuebner <heiko@sntech.de>

properties:
  compatible:
    enum:
      - rockchip,rk3288-crypto
      - rockchip,rk3328-crypto
      - rockchip,rk3399-crypto

  reg:
    maxItems: 1

  interrupts:
    maxItems: 1

  clocks:
    minItems: 3
    maxItems: 4

  clock-names:
    minItems: 3
    maxItems: 4

  resets:
    minItems: 1
    maxItems: 3

  reset-names:
    minItems: 1
    maxItems: 3

allOf:
  - if:
      properties:
        compatible:
          contains:
            const: rockchip,rk3288-crypto
    then:
      properties:
        clocks:
          minItems: 4
        clock-names:
          items:
            - const: aclk
            - const: hclk
            - const: sclk
            - const: apb_pclk
        resets:
          maxItems: 1
        reset-names:
          items:
            - const: crypto-rst
  - if:
      properties:
        compatible:
          contains:
            const: rockchip,rk3328-crypto
    then:
      properties:
        clocks:
          maxItems: 3
        clock-names:
          items:
            - const: hclk_master
            - const: hclk_slave
            - const: sclk
        resets:
          maxItems: 1
        reset-names:
          items:
            - const: crypto-rst
  - if:
      properties:
        compatible:
          contains:
            const: rockchip,rk3399-crypto
    then:
      properties:
        clocks:
          maxItems: 3
        clock-names:
          items:
            - const: hclk_master
            - const: hclk_slave
            - const: sclk
        resets:
          minItems: 3
        reset-names:
          items:
            - const: master
            - const: slave
            - const: crypto-rst

required:
  - compatible
  - reg
  - interrupts
  - clocks
  - clock-names
  - resets
  - reset-names

additionalProperties: false

examples:
  - |
    #include <dt-bindings/interrupt-controller/arm-gic.h>
    #include <dt-bindings/clock/rk3288-cru.h>
    crypto@ff8a0000 {
      compatible = "rockchip,rk3288-crypto";
      reg = <0xff8a0000 0x4000>;
      interrupts = <GIC_SPI 48 IRQ_TYPE_LEVEL_HIGH>;
      clocks = <&cru ACLK_CRYPTO>, <&cru HCLK_CRYPTO>,
               <&cru SCLK_CRYPTO>, <&cru ACLK_DMAC1>;
      clock-names = "aclk", "hclk", "sclk", "apb_pclk";
      resets = <&cru SRST_CRYPTO>;
      reset-names = "crypto-rst";
    };
