clk: ralink: add clock driver for mt7621 SoC
authorSergio Paracuellos <sergio.paracuellos@gmail.com>
Sat, 10 Apr 2021 05:50:56 +0000 (07:50 +0200)
committerStephen Boyd <sboyd@kernel.org>
Tue, 13 Apr 2021 02:10:54 +0000 (19:10 -0700)
commit48df7a26f4700aac8b7e5ab68796daf25c27e062
treee2865f8d10ef4dbf0e0ef1b3191d5af6fcb0dfa2
parent704f6af2e0c67a1f63f61159f040e827b290ba38
clk: ralink: add clock driver for mt7621 SoC

The documentation for this SOC only talks about two
registers regarding to the clocks:
* SYSC_REG_CPLL_CLKCFG0 - provides some information about
boostrapped refclock. PLL and dividers used for CPU and some
sort of BUS.
* SYSC_REG_CPLL_CLKCFG1 - a banch of gates to enable/disable
clocks for all or some ip cores.

Looking into driver code, and some openWRT patched there are
another frequencies which are used in some drivers (uart, sd...).
According to all of this information the clock plan for this
SoC is set as follows:
- Main top clock "xtal" from where all the rest of the world is
derived.
- CPU clock "cpu" derived from "xtal" frequencies and a bunch of
register reads and predividers.
- BUS clock "bus" derived from "cpu" and with (cpu / 4) MHz.
- Fixed clocks from "xtal":
    * "50m": 50 MHz.
    * "125m": 125 MHz.
    * "150m": 150 MHz.
    * "250m": 250 MHz.
    * "270m": 270 MHz.

We also have a buch of gate clocks with their parents:
  * "hsdma": "150m"
  * "fe": "250m"
  * "sp_divtx": "270m"
  * "timer": "50m"
  * "pcm": "270m"
  * "pio": "50m"
  * "gdma": "bus"
  * "nand": "125m"
  * "i2c": "50m"
  * "i2s": "270m"
  * "spi": "bus"
  * "uart1": "50m"
  * "uart2": "50m"
  * "uart3": "50m"
  * "eth": "50m"
  * "pcie0": "125m"
  * "pcie1": "125m"
  * "pcie2": "125m"
  * "crypto": "250m"
  * "shxc": "50m"

With this information the clk driver will provide clock and gates
functionality from a a set of hardcoded clocks allowing to define
a nice device tree without fixed clocks.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Link: https://lore.kernel.org/r/20210410055059.13518-2-sergio.paracuellos@gmail.com
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
drivers/clk/Kconfig
drivers/clk/Makefile
drivers/clk/ralink/Kconfig [new file with mode: 0644]
drivers/clk/ralink/Makefile [new file with mode: 0644]
drivers/clk/ralink/clk-mt7621.c [new file with mode: 0644]