# SPDX-License-Identifier: GPL-2.0
%YAML 1.2
---
$id: http://devicetree.org/schemas/pwm/allwinner,sun4i-a10-pwm.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: Allwinner A10 PWM Device Tree Bindings

maintainers:
  - Chen-Yu Tsai <wens@csie.org>
  - Maxime Ripard <mripard@kernel.org>

properties:
  "#pwm-cells":
    const: 3

  compatible:
    oneOf:
      - const: allwinner,sun4i-a10-pwm
      - const: allwinner,sun5i-a10s-pwm
      - const: allwinner,sun5i-a13-pwm
      - const: allwinner,sun7i-a20-pwm
      - const: allwinner,sun8i-h3-pwm
      - items:
          - const: allwinner,sun8i-a83t-pwm
          - const: allwinner,sun8i-h3-pwm
      - items:
          - const: allwinner,sun50i-a64-pwm
          - const: allwinner,sun5i-a13-pwm
      - items:
          - const: allwinner,sun50i-h5-pwm
          - const: allwinner,sun5i-a13-pwm
      - const: allwinner,sun50i-h6-pwm

  reg:
    maxItems: 1

  clocks:
    minItems: 1
    maxItems: 2
    items:
      - description: Module Clock
      - description: Bus Clock

  # Even though it only applies to subschemas under the conditionals,
  # not listing them here will trigger a warning because of the
  # additionalsProperties set to false.
  clock-names: true

  resets:
    maxItems: 1

if:
  properties:
    compatible:
      contains:
        const: allwinner,sun50i-h6-pwm

then:
  properties:
    clocks:
      maxItems: 2

    clock-names:
      items:
        - const: mod
        - const: bus

  required:
    - clock-names
    - resets

else:
  properties:
    clocks:
      maxItems: 1

required:
  - "#pwm-cells"
  - compatible
  - reg
  - clocks

additionalProperties: false

examples:
  - |
    pwm: pwm@1c20e00 {
        compatible = "allwinner,sun7i-a20-pwm";
        reg = <0x01c20e00 0xc>;
        clocks = <&osc24M>;
        #pwm-cells = <3>;
    };

  - |
    #include <dt-bindings/clock/sun50i-h6-ccu.h>
    #include <dt-bindings/reset/sun50i-h6-ccu.h>

    pwm@300a000 {
      compatible = "allwinner,sun50i-h6-pwm";
      reg = <0x0300a000 0x400>;
      clocks = <&osc24M>, <&ccu CLK_BUS_PWM>;
      clock-names = "mod", "bus";
      resets = <&ccu RST_BUS_PWM>;
      #pwm-cells = <3>;
    };

...
