# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/watchdog/renesas,rcar-gen3-wwdt.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: Renesas Window Watchdog Timer (WWDT) Controller

maintainers:
  - Wolfram Sang <wsa+renesas@sang-engineering.com>

properties:
  compatible:
    oneOf:
      - items:
          - enum:
              - renesas,r8a77970-wwdt  # R-Car V3M
              - renesas,r8a77980-wwdt  # R-Car V3H
          - const: renesas,rcar-gen3-wwdt

      - items:
          - enum:
              - renesas,r8a779a0-wwdt  # R-Car V3U
              - renesas,r8a779f0-wwdt  # R-Car S4
              - renesas,r8a779g0-wwdt  # R-Car V4H
              - renesas,r8a779h0-wwdt  # R-Car V4M
          - const: renesas,rcar-gen4-wwdt

  reg:
    maxItems: 1

  interrupts:
    items:
      - description: Pretimeout, 75% of overflow reached
      - description: Error occurred

  interrupt-names:
    items:
      - const: pretimeout
      - const: error

  clocks:
    items:
      - description: Counting clock
      - description: Bus clock

  clock-names:
    items:
      - const: cnt
      - const: bus

  resets:
    minItems: 1
    maxItems: 2

  reset-names:
    minItems: 1
    items:
      - const: cnt
      - const: bus

  power-domains:
    maxItems: 1

required:
  - compatible
  - reg
  - interrupts
  - interrupt-names
  - clocks
  - clock-names
  - resets
  - reset-names
  - power-domains

allOf:
  - $ref: watchdog.yaml#

  - if:
      properties:
        compatible:
          contains:
            enum:
              - renesas,r8a779a0-wwdt
              - renesas,r8a779f0-wwdt
    then:
      properties:
        resets:
          minItems: 2
        reset-names:
          minItems: 2

additionalProperties: false

examples:
  - |
    #include <dt-bindings/clock/r8a779g0-cpg-mssr.h>
    #include <dt-bindings/power/r8a779g0-sysc.h>
    #include <dt-bindings/interrupt-controller/arm-gic.h>

    watchdog@ffc90000 {
            compatible = "renesas,r8a779g0-wwdt",
                         "renesas,rcar-gen4-wwdt";
            reg = <0xffc90000 0x10>;
            interrupts = <GIC_SPI 310 IRQ_TYPE_LEVEL_HIGH>,
                         <GIC_SPI 311 IRQ_TYPE_LEVEL_HIGH>;
            interrupt-names = "pretimeout", "error";
            clocks = <&cpg CPG_CORE R8A779G0_CLK_R>,
                     <&cpg CPG_CORE R8A779G0_CLK_SASYNCRT>;
            clock-names = "cnt", "bus";
            power-domains = <&sysc R8A779G0_PD_ALWAYS_ON>;
            resets = <&cpg 1200>;
            reset-names = "cnt";
    };
