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

title: SpacemiT K1/K3 SoC System Controller

maintainers:
  - Haylen Chu <heylenay@4d2.org>

description:
  System controllers found on SpacemiT K1/K3 SoC, which are capable of
  clock, reset and power-management functions.

properties:
  compatible:
    enum:
      - spacemit,k1-syscon-apbc
      - spacemit,k1-syscon-apmu
      - spacemit,k1-syscon-mpmu
      - spacemit,k1-syscon-rcpu
      - spacemit,k1-syscon-rcpu2
      - spacemit,k1-syscon-apbc2
      - spacemit,k3-syscon-apbc
      - spacemit,k3-syscon-apmu
      - spacemit,k3-syscon-dciu
      - spacemit,k3-syscon-mpmu

  reg:
    maxItems: 1

  clocks:
    maxItems: 4

  clock-names:
    items:
      - const: osc
      - const: vctcxo_1m
      - const: vctcxo_3m
      - const: vctcxo_24m

  "#clock-cells":
    const: 1
    description:
      For K1 SoC, check <dt-bindings/clock/spacemit,k1-syscon.h> for valid indices.
      For K3 SoC, check <dt-bindings/clock/spacemit,k3-clocks.h> for valid indices.

  "#power-domain-cells":
    const: 1

  "#reset-cells":
    const: 1
    description: |
      ID of the reset controller line. Valid IDs are defined in corresponding
      files:

      For SpacemiT K1, see include/dt-bindings/clock/spacemit,k1-syscon.h
      For SpacemiT K3, see include/dt-bindings/reset/spacemit,k3-resets.h

required:
  - compatible
  - reg
  - "#reset-cells"

allOf:
  - if:
      properties:
        compatible:
          contains:
            enum:
              - spacemit,k1-syscon-apmu
              - spacemit,k1-syscon-mpmu
              - spacemit,k3-syscon-apmu
              - spacemit,k3-syscon-mpmu
    then:
      required:
        - "#power-domain-cells"
    else:
      properties:
        "#power-domain-cells": false
  - if:
      properties:
        compatible:
          contains:
            enum:
              - spacemit,k1-syscon-apbc
              - spacemit,k1-syscon-apmu
              - spacemit,k1-syscon-mpmu
              - spacemit,k3-syscon-apbc
              - spacemit,k3-syscon-apmu
              - spacemit,k3-syscon-mpmu
    then:
      required:
        - clocks
        - clock-names
        - "#clock-cells"

additionalProperties: false

examples:
  - |
    system-controller@d4050000 {
        compatible = "spacemit,k1-syscon-mpmu";
        reg = <0xd4050000 0x209c>;
        clocks = <&osc>, <&vctcxo_1m>, <&vctcxo_3m>, <&vctcxo_24m>;
        clock-names = "osc", "vctcxo_1m", "vctcxo_3m", "vctcxo_24m";
        #clock-cells = <1>;
        #power-domain-cells = <1>;
        #reset-cells = <1>;
    };
