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

title: Samsung ExynosAuto v920 SoC clock controller

maintainers:
  - Sunyeal Hong <sunyeal.hong@samsung.com>
  - Shin Son <shin.son@samsung.com>
  - Chanwoo Choi <cw00.choi@samsung.com>
  - Krzysztof Kozlowski <krzk@kernel.org>
  - Sylwester Nawrocki <s.nawrocki@samsung.com>

description: |
  ExynosAuto v920 clock controller is comprised of several CMU units, generating
  clocks for different domains. Those CMU units are modeled as separate device
  tree nodes, and might depend on each other. Root clocks in that clock tree are
  two external clocks: OSCCLK/XTCXO (38.4 MHz) and RTCCLK/XrtcXTI (32768 Hz).
  The external OSCCLK must be defined as fixed-rate clock in dts.

  CMU_TOP is a top-level CMU, where all base clocks are prepared using PLLs and
  dividers; all other clocks of function blocks (other CMUs) are usually
  derived from CMU_TOP.

  Each clock is assigned an identifier and client nodes can use this identifier
  to specify the clock which they consume. All clocks available for usage
  in clock consumer nodes are defined as preprocessor macros in
  'include/dt-bindings/clock/samsung,exynosautov920.h' header.

properties:
  compatible:
    enum:
      - samsung,exynosautov920-cmu-cpucl0
      - samsung,exynosautov920-cmu-cpucl1
      - samsung,exynosautov920-cmu-cpucl2
      - samsung,exynosautov920-cmu-g3d
      - samsung,exynosautov920-cmu-hsi0
      - samsung,exynosautov920-cmu-hsi1
      - samsung,exynosautov920-cmu-hsi2
      - samsung,exynosautov920-cmu-m2m
      - samsung,exynosautov920-cmu-mfc
      - samsung,exynosautov920-cmu-mfd
      - samsung,exynosautov920-cmu-misc
      - samsung,exynosautov920-cmu-peric0
      - samsung,exynosautov920-cmu-peric1
      - samsung,exynosautov920-cmu-top

  clocks:
    minItems: 1
    maxItems: 5

  clock-names:
    minItems: 1
    maxItems: 5

  "#clock-cells":
    const: 1

  reg:
    maxItems: 1

allOf:
  - if:
      properties:
        compatible:
          contains:
            const: samsung,exynosautov920-cmu-top

    then:
      properties:
        clocks:
          items:
            - description: External reference clock (38.4 MHz)

        clock-names:
          items:
            - const: oscclk

  - if:
      properties:
        compatible:
          contains:
            enum:
              - samsung,exynosautov920-cmu-cpucl0

    then:
      properties:
        clocks:
          items:
            - description: External reference clock (38.4 MHz)
            - description: CMU_CPUCL0 SWITCH clock (from CMU_TOP)
            - description: CMU_CPUCL0 CLUSTER clock (from CMU_TOP)
            - description: CMU_CPUCL0 DBG clock (from CMU_TOP)

        clock-names:
          items:
            - const: oscclk
            - const: switch
            - const: cluster
            - const: dbg

  - if:
      properties:
        compatible:
          contains:
            enum:
              - samsung,exynosautov920-cmu-cpucl1

    then:
      properties:
        clocks:
          items:
            - description: External reference clock (38.4 MHz)
            - description: CMU_CPUCL1 SWITCH clock (from CMU_TOP)
            - description: CMU_CPUCL1 CLUSTER clock (from CMU_TOP)

        clock-names:
          items:
            - const: oscclk
            - const: switch
            - const: cluster

  - if:
      properties:
        compatible:
          contains:
            enum:
              - samsung,exynosautov920-cmu-cpucl2

    then:
      properties:
        clocks:
          items:
            - description: External reference clock (38.4 MHz)
            - description: CMU_CPUCL2 SWITCH clock (from CMU_TOP)
            - description: CMU_CPUCL2 CLUSTER clock (from CMU_TOP)

        clock-names:
          items:
            - const: oscclk
            - const: switch
            - const: cluster

  - if:
      properties:
        compatible:
          contains:
            enum:
              - samsung,exynosautov920-cmu-peric0
              - samsung,exynosautov920-cmu-peric1

    then:
      properties:
        clocks:
          items:
            - description: External reference clock (38.4 MHz)
            - description: CMU_PERICn NOC clock (from CMU_TOP)
            - description: CMU_PERICn IP clock (from CMU_TOP)

        clock-names:
          items:
            - const: oscclk
            - const: noc
            - const: ip

  - if:
      properties:
        compatible:
          enum:
            - samsung,exynosautov920-cmu-misc
            - samsung,exynosautov920-cmu-hsi0

    then:
      properties:
        clocks:
          items:
            - description: External reference clock (38.4 MHz)
            - description: CMU_MISC/CMU_HSI0 NOC clock (from CMU_TOP)

        clock-names:
          items:
            - const: oscclk
            - const: noc

  - if:
      properties:
        compatible:
          contains:
            const: samsung,exynosautov920-cmu-hsi1

    then:
      properties:
        clocks:
          items:
            - description: External reference clock (38.4 MHz)
            - description: CMU_HSI1 NOC clock (from CMU_TOP)
            - description: CMU_HSI1 USBDRD clock (from CMU_TOP)
            - description: CMU_HSI1 MMC_CARD clock (from CMU_TOP)

        clock-names:
          items:
            - const: oscclk
            - const: noc
            - const: usbdrd
            - const: mmc_card

  - if:
      properties:
        compatible:
          contains:
            const: samsung,exynosautov920-cmu-hsi2

    then:
      properties:
        clocks:
          items:
            - description: External reference clock (38.4 MHz)
            - description: CMU_HSI2 NOC clock (from CMU_TOP)
            - description: CMU_HSI2 NOC UFS clock (from CMU_TOP)
            - description: CMU_HSI2 UFS EMBD clock (from CMU_TOP)
            - description: CMU_HSI2 ETHERNET clock (from CMU_TOP)

        clock-names:
          items:
            - const: oscclk
            - const: noc
            - const: ufs
            - const: embd
            - const: ethernet

  - if:
      properties:
        compatible:
          contains:
            const: samsung,exynosautov920-cmu-m2m

    then:
      properties:
        clocks:
          items:
            - description: External reference clock (38.4 MHz)
            - description: CMU_M2M NOC clock (from CMU_TOP)
            - description: CMU_M2M JPEG clock (from CMU_TOP)

        clock-names:
          items:
            - const: oscclk
            - const: noc
            - const: jpeg

  - if:
      properties:
        compatible:
          contains:
            const: samsung,exynosautov920-cmu-mfc

    then:
      properties:
        clocks:
          items:
            - description: External reference clock (38.4 MHz)
            - description: CMU_MFC MFC clock (from CMU_TOP)
            - description: CMU_MFC WFD clock (from CMU_TOP)

        clock-names:
          items:
            - const: oscclk
            - const: mfc
            - const: wfd

  - if:
      properties:
        compatible:
          contains:
            const: samsung,exynosautov920-cmu-mfd

    then:
      properties:
        clocks:
          items:
            - description: External reference clock (38.4 MHz)
            - description: CMU_MFD NOC clock (from CMU_TOP)

        clock-names:
          items:
            - const: oscclk
            - const: noc

  - if:
      properties:
        compatible:
          contains:
            const: samsung,exynosautov920-cmu-g3d

    then:
      properties:
        clocks:
          items:
            - description: External reference clock (38.4 MHz)
            - description: CMU_G3D SWITCH clock (from CMU_TOP)
            - description: CMU_G3D NOCP clock (from CMU_TOP)

        clock-names:
          items:
            - const: oscclk
            - const: switch
            - const: nocp

required:
  - compatible
  - "#clock-cells"
  - clocks
  - clock-names
  - reg

additionalProperties: false

examples:
  # Clock controller node for CMU_PERIC0
  - |
    #include <dt-bindings/clock/samsung,exynosautov920.h>

    cmu_peric0: clock-controller@10800000 {
        compatible = "samsung,exynosautov920-cmu-peric0";
        reg = <0x10800000 0x8000>;
        #clock-cells = <1>;

        clocks = <&xtcxo>,
                 <&cmu_top DOUT_CLKCMU_PERIC0_NOC>,
                 <&cmu_top DOUT_CLKCMU_PERIC0_IP>;
        clock-names = "oscclk",
                      "noc",
                      "ip";
    };

...