162306a36Sopenharmony_ci# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
262306a36Sopenharmony_ci# Copyright (C) 2020 BAIKAL ELECTRONICS, JSC
362306a36Sopenharmony_ci%YAML 1.2
462306a36Sopenharmony_ci---
562306a36Sopenharmony_ci$id: http://devicetree.org/schemas/clock/baikal,bt1-ccu-pll.yaml#
662306a36Sopenharmony_ci$schema: http://devicetree.org/meta-schemas/core.yaml#
762306a36Sopenharmony_ci
862306a36Sopenharmony_cititle: Baikal-T1 Clock Control Unit PLL
962306a36Sopenharmony_ci
1062306a36Sopenharmony_cimaintainers:
1162306a36Sopenharmony_ci  - Serge Semin <fancer.lancer@gmail.com>
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_cidescription: |
1462306a36Sopenharmony_ci  Clocks Control Unit is the core of Baikal-T1 SoC System Controller
1562306a36Sopenharmony_ci  responsible for the chip subsystems clocking and resetting. The CCU is
1662306a36Sopenharmony_ci  connected with an external fixed rate oscillator, which signal is transformed
1762306a36Sopenharmony_ci  into clocks of various frequencies and then propagated to either individual
1862306a36Sopenharmony_ci  IP-blocks or to groups of blocks (clock domains). The transformation is done
1962306a36Sopenharmony_ci  by means of PLLs and gateable/non-gateable dividers embedded into the CCU.
2062306a36Sopenharmony_ci  It's logically divided into the next components:
2162306a36Sopenharmony_ci  1) External oscillator (normally XTAL's 25 MHz crystal oscillator, but
2262306a36Sopenharmony_ci     in general can provide any frequency supported by the CCU PLLs).
2362306a36Sopenharmony_ci  2) PLLs clocks generators (PLLs) - described in this binding file.
2462306a36Sopenharmony_ci  3) AXI-bus clock dividers (AXI).
2562306a36Sopenharmony_ci  4) System devices reference clock dividers (SYS).
2662306a36Sopenharmony_ci  which are connected with each other as shown on the next figure:
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_ci          +---------------+
2962306a36Sopenharmony_ci          | Baikal-T1 CCU |
3062306a36Sopenharmony_ci          |   +----+------|- MIPS P5600 cores
3162306a36Sopenharmony_ci          | +-|PLLs|------|- DDR controller
3262306a36Sopenharmony_ci          | | +----+      |
3362306a36Sopenharmony_ci  +----+  | |  |  |       |
3462306a36Sopenharmony_ci  |XTAL|--|-+  |  | +---+-|
3562306a36Sopenharmony_ci  +----+  | |  |  +-|AXI|-|- AXI-bus
3662306a36Sopenharmony_ci          | |  |    +---+-|
3762306a36Sopenharmony_ci          | |  |          |
3862306a36Sopenharmony_ci          | |  +----+---+-|- APB-bus
3962306a36Sopenharmony_ci          | +-------|SYS|-|- Low-speed Devices
4062306a36Sopenharmony_ci          |         +---+-|- High-speed Devices
4162306a36Sopenharmony_ci          +---------------+
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_ci  Each CCU sub-block is represented as a separate dts-node and has an
4462306a36Sopenharmony_ci  individual driver to be bound with.
4562306a36Sopenharmony_ci
4662306a36Sopenharmony_ci  In order to create signals of wide range frequencies the external oscillator
4762306a36Sopenharmony_ci  output is primarily connected to a set of CCU PLLs. There are five PLLs
4862306a36Sopenharmony_ci  to create a clock for the MIPS P5600 cores, the embedded DDR controller,
4962306a36Sopenharmony_ci  SATA, Ethernet and PCIe domains. The last three domains though named by the
5062306a36Sopenharmony_ci  biggest system interfaces in fact include nearly all of the rest SoC
5162306a36Sopenharmony_ci  peripherals. Each of the PLLs is based on True Circuits TSMC CLN28HPM core
5262306a36Sopenharmony_ci  with an interface wrapper (so called safe PLL' clocks switcher) to simplify
5362306a36Sopenharmony_ci  the PLL configuration procedure. The PLLs work as depicted on the next
5462306a36Sopenharmony_ci  diagram:
5562306a36Sopenharmony_ci
5662306a36Sopenharmony_ci      +--------------------------+
5762306a36Sopenharmony_ci      |                          |
5862306a36Sopenharmony_ci      +-->+---+    +---+   +---+ |  +---+   0|\
5962306a36Sopenharmony_ci  CLKF--->|/NF|--->|PFD|...|VCO|-+->|/OD|--->| |
6062306a36Sopenharmony_ci          +---+ +->+---+   +---+ /->+---+    | |--->CLKOUT
6162306a36Sopenharmony_ci  CLKOD---------C----------------+          1| |
6262306a36Sopenharmony_ci       +--------C--------------------------->|/
6362306a36Sopenharmony_ci       |        |                             ^
6462306a36Sopenharmony_ci  Rclk-+->+---+ |                             |
6562306a36Sopenharmony_ci  CLKR--->|/NR|-+                             |
6662306a36Sopenharmony_ci          +---+                               |
6762306a36Sopenharmony_ci  BYPASS--------------------------------------+
6862306a36Sopenharmony_ci  BWADJ--->
6962306a36Sopenharmony_ci
7062306a36Sopenharmony_ci  where Rclk is the reference clock coming  from XTAL, NR - reference clock
7162306a36Sopenharmony_ci  divider, NF - PLL clock multiplier, OD - VCO output clock divider, CLKOUT -
7262306a36Sopenharmony_ci  output clock, BWADJ is the PLL bandwidth adjustment parameter. At this moment
7362306a36Sopenharmony_ci  the binding supports the PLL dividers configuration in accordance with a
7462306a36Sopenharmony_ci  requested rate, while bypassing and bandwidth adjustment settings can be
7562306a36Sopenharmony_ci  added in future if it gets to be necessary.
7662306a36Sopenharmony_ci
7762306a36Sopenharmony_ci  The PLLs CLKOUT is then either directly connected with the corresponding
7862306a36Sopenharmony_ci  clocks consumer (like P5600 cores or DDR controller) or passed over a CCU
7962306a36Sopenharmony_ci  divider to create a signal required for the clock domain.
8062306a36Sopenharmony_ci
8162306a36Sopenharmony_ci  The CCU PLL dts-node uses the common clock bindings with no custom
8262306a36Sopenharmony_ci  parameters. The list of exported clocks can be found in
8362306a36Sopenharmony_ci  'include/dt-bindings/clock/bt1-ccu.h'. Since CCU PLL is a part of the
8462306a36Sopenharmony_ci  Baikal-T1 SoC System Controller its DT node is supposed to be a child of
8562306a36Sopenharmony_ci  later one.
8662306a36Sopenharmony_ci
8762306a36Sopenharmony_ciproperties:
8862306a36Sopenharmony_ci  compatible:
8962306a36Sopenharmony_ci    const: baikal,bt1-ccu-pll
9062306a36Sopenharmony_ci
9162306a36Sopenharmony_ci  reg:
9262306a36Sopenharmony_ci    maxItems: 1
9362306a36Sopenharmony_ci
9462306a36Sopenharmony_ci  "#clock-cells":
9562306a36Sopenharmony_ci    const: 1
9662306a36Sopenharmony_ci
9762306a36Sopenharmony_ci  clocks:
9862306a36Sopenharmony_ci    description: External reference clock
9962306a36Sopenharmony_ci    maxItems: 1
10062306a36Sopenharmony_ci
10162306a36Sopenharmony_ci  clock-names:
10262306a36Sopenharmony_ci    const: ref_clk
10362306a36Sopenharmony_ci
10462306a36Sopenharmony_ciadditionalProperties: false
10562306a36Sopenharmony_ci
10662306a36Sopenharmony_cirequired:
10762306a36Sopenharmony_ci  - compatible
10862306a36Sopenharmony_ci  - "#clock-cells"
10962306a36Sopenharmony_ci  - clocks
11062306a36Sopenharmony_ci  - clock-names
11162306a36Sopenharmony_ci
11262306a36Sopenharmony_ciexamples:
11362306a36Sopenharmony_ci  # Clock Control Unit PLL node:
11462306a36Sopenharmony_ci  - |
11562306a36Sopenharmony_ci    clock-controller@1f04d000 {
11662306a36Sopenharmony_ci      compatible = "baikal,bt1-ccu-pll";
11762306a36Sopenharmony_ci      reg = <0x1f04d000 0x028>;
11862306a36Sopenharmony_ci      #clock-cells = <1>;
11962306a36Sopenharmony_ci
12062306a36Sopenharmony_ci      clocks = <&clk25m>;
12162306a36Sopenharmony_ci      clock-names = "ref_clk";
12262306a36Sopenharmony_ci    };
12362306a36Sopenharmony_ci  # Required external oscillator:
12462306a36Sopenharmony_ci  - |
12562306a36Sopenharmony_ci    clk25m: clock-oscillator-25m {
12662306a36Sopenharmony_ci      compatible = "fixed-clock";
12762306a36Sopenharmony_ci      #clock-cells = <0>;
12862306a36Sopenharmony_ci      clock-frequency  = <25000000>;
12962306a36Sopenharmony_ci      clock-output-names = "clk25m";
13062306a36Sopenharmony_ci    };
13162306a36Sopenharmony_ci...
132