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

title: ZTE zx297520v3 SoC top clock and reset controller

maintainers:
  - Stefan Dösinger <stefandoesinger@gmail.com>

description: |
  The zx297520v3 top clock and reset controller generates clocks for core
  devices on the board like the main bus, USB and timers. In addition to clocks
  it has reset controls for peripherals, a global board reset, watchdog reset
  controls and a USB status register.

  The controller has two clock inputs: a 26 MHz and a 32 kHz external
  oscillator. They need to be provided as input clocks. The controller provides
  PLL output frequencies to downstream clock controllers.

  The USB PHY is exposed as two PHYs, one for USB and another for HSIC. Note
  that while the controls for both PHYs are always present, the PHYs themselves
  may be absent. If this is the case the controller never signals that the
  missing PHY is ready.

  All available clocks are defined as preprocessor macros in the
  "include/dt-bindings/clock/zte,zx297520v3-clk.h" header. The resets are
  defined in the "include/dt-bindings/reset/zte,zx297520v3-reset.h" header. PHY
  defines are found in "include/dt-bindings/phy/zte,zx297520v3-topcrm.h".

properties:
  compatible:
    items:
      - const: zte,zx297520v3-topcrm
      - const: syscon

  reg:
    maxItems: 1

  clocks:
    items:
      - description: 26 MHz external oscillator
      - description: 32 kHz external oscillator

  clock-names:
    items:
      - const: osc26m
      - const: osc32k

  interrupts:
    items:
      - description: IRQ reporting USB connection
      - description: IRQ reporting USB disconnection
      - description: IRQ reporting HSIC connection
      - description: IRQ reporting HSIC disconnection

  interrupt-names:
    items:
      - const: usb-up
      - const: usb-down
      - const: hsic-up
      - const: hsic-down

  "#clock-cells":
    const: 1

  "#phy-cells":
    const: 1

  "#reset-cells":
    const: 1

  reboot:
    type: object
    $ref: /schemas/power/reset/syscon-reboot.yaml#
    unevaluatedProperties: false
    description:
      Reboot method for the SoC.

required:
  - compatible
  - reg
  - clocks
  - clock-names
  - interrupts
  - interrupt-names
  - reboot
  - "#clock-cells"
  - "#phy-cells"
  - "#reset-cells"

additionalProperties: false

examples:
  - |
    #include <dt-bindings/interrupt-controller/arm-gic.h>
    #include <dt-bindings/reset/zte,zx297520v3-reset.h>
    #include <dt-bindings/phy/zte,zx297520v3-topcrm.h>
    #include <dt-bindings/clock/zte,zx297520v3-clk.h>

    clock-controller@13b000 {
        compatible = "zte,zx297520v3-topcrm", "syscon";
        reg = <0x0013b000 0x400>;
        #clock-cells = <1>;
        clocks = <&osc26m>, <&osc32k>;
        clock-names = "osc26m", "osc32k";
        interrupts = <GIC_SPI 42 IRQ_TYPE_EDGE_RISING>,
                     <GIC_SPI 43 IRQ_TYPE_EDGE_RISING>,
                     <GIC_SPI 45 IRQ_TYPE_EDGE_RISING>,
                     <GIC_SPI 46 IRQ_TYPE_EDGE_RISING>;
        interrupt-names = "usb-up", "usb-down", "hsic-up", "hsic-down";
        #phy-cells = <1>;
        #reset-cells = <1>;

        reboot {
          compatible = "syscon-reboot";
          mask = <0x1>;
          offset = <0x0>;
          value = <0x1>;
        };
    };