arm64: Realtek RTD1295 clocks
Subsystems (3)
cover arm64: Realtek RTD1295 clocks
Hello,
This series adds two clock controllers for the Realtek RTD1295 SoC. Based on my reset controller and IRQ mux series.
There being no public source code for RTD1295, the implementation is based on register offsets, fields and names seen in the vendor DT, unified into 2 nodes.
The PLL calculations were experimentally found by comparing vendor Android /sys/kernel/debug/clk/clk_summary to the register field values in /dev/mem - thus the formulas may be incomplete or incorrect.
Together with the reset driver and IRQ mux, the clock gates allow to initialize UART1.
Code needs cleanups - sharing this for calculation findings and design.
More experimental patches at:
https://github.com/afaerber/linux/commits/rtd1295-next
Have a lot of fun!
Cheers,
Andreas
Andreas F?rber (4):
dt-bindings: clock: Add Realtek RTD1295
arm64: dts: realtek: Add clock nodes for RTD1295
clk: Add Realtek RTD1295
arm64: dts: realtek: Update RTD1295 UART nodes with clocks
.../devicetree/bindings/clock/realtek,rtd129x.txt | 20 ++ arch/arm64/boot/dts/realtek/rtd1295.dtsi | 28 +- drivers/clk/Kconfig | 7 + drivers/clk/Makefile | 1 + drivers/clk/clk-rtd1295.c | 385 +++++++++++++++++++++ include/dt-bindings/clock/realtek,rtd1295.h | 99 ++++++ 6 files changed, 537 insertions(+), 3 deletions(-) create mode 100644 Documentation/devicetree/bindings/clock/realtek,rtd129x.txt create mode 100644 drivers/clk/clk-rtd1295.c create mode 100644 include/dt-bindings/clock/realtek,rtd1295.h
Signature · 1 line
2.12.3
RFC 1/4 dt-bindings: clock: Add Realtek RTD1295
Naming inspired from Zidoo X9S Device Tree and clk_summary.
--- .../devicetree/bindings/clock/realtek,rtd129x.txt | 20 +++++ include/dt-bindings/clock/realtek,rtd1295.h | 99 ++++++++++++++++++++++ 2 files changed, 119 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/realtek,rtd129x.txt create mode 100644 include/dt-bindings/clock/realtek,rtd1295.h
Documentation/devicetree/bindings/clock/realtek,rtd129x.txt new file +20 -0
@@ -0,0 +1,20 @@ +Realtek RTD129x clock controllers +================================= + +Requires properties: +- compatible : Should be one of the following: + - "realtek,rtd1295-clk" + - "realtek,rtd1295-iso-clk" +- reg : Specifies physical base address and size +- clocks : Specifies the oscillator node +- #clock-cells : Shall be 1 + + +Example: + + clock-controller at 98000000 { + compatible = "realtek,rtd1295-clk"; + reg = <0x98000000 0x1000>; + clocks = <&osc27M>; + #clock-cells = <1>; + };
include/dt-bindings/clock/realtek,rtd1295.h new file +99 -0
99 lines not on this page · raw message
Signature · 1 line
2.12.3
Re: [RFC 1/4] dt-bindings: clock: Add Realtek RTD1295
Quoted 9 lines · Andreas F?rber
Naming inspired from Zidoo X9S Device Tree and
clk_summary.Signed-off-by Andreas F?rber <[email protected]>--- .../devicetree/bindings/clock/realtek,rtd129x.txt | 20 +++++ include/dt-bindings/clock/realtek,rtd1295.h | 99 ++++++++++++++++++++++ 2 files changed, 119 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/realtek,rtd129x.txt create mode 100644 include/dt-bindings/clock/realtek,rtd1295.h
RFC 2/4 arm64: dts: realtek: Add clock nodes for RTD1295
In reply to Andreas FärberAdd 27 MHz oscillator and two clock controller nodes.
--- arch/arm64/boot/dts/realtek/rtd1295.dtsi | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
arch/arm64/boot/dts/realtek/rtd1295.dtsi +21 -0
@@ -81,6 +81,13 @@ (GIC_CPU_MASK_RAW(0xf) | IRQ_TYPE_LEVEL_LOW)>; }; + osc27M: osc { + compatible = "fixed-clock"; + clock-frequency = <27000000>; + #clock-cells = <0>; + clock-output-names = "osc27M"; + }; + soc { compatible = "simple-bus"; #address-cells = <1>;
@@ -88,6 +95,13 @@ /* Exclude up to 2 GiB of RAM */ ranges = <0x80000000 0x80000000 0x80000000>; + clkc: clock-controller at 98000000 { + compatible = "realtek,rtd1295-clk"; + reg = <0x98000000 0x1000>; + clocks = <&osc27M>; + #clock-cells = <1>; + }; + reset1: reset-controller at 98000000 { compatible = "realtek,rtd1295-reset"; reg = <0x98000000 0x4>;
@@ -112,6 +126,13 @@ #reset-cells = <1>; }; + iso_clkc: clock-controller at 98007000 { + compatible = "realtek,rtd1295-iso-clk"; + reg = <0x98007000 0x100>; + clocks = <&osc27M>; + #clock-cells = <1>; + }; + iso_irq_mux: interrupt-controller at 98007000 { compatible = "realtek,rtd1295-iso-irq-mux"; reg = <0x98007000 0x100>;
Signature · 1 line
2.12.3
RFC 3/4 clk: Add Realtek RTD1295
In reply to Andreas FärberAdd two clock controller drivers for RTD1295.
Clock names are taken from vendor DT and clk_summary where possible. Clock rate calculations are guesses derived from Android register values and resulting rates in clk_summary.
Clock gate parents are mostly unknown - osc27M is chosen for UART baudrate.
--- drivers/clk/Kconfig | 7 + drivers/clk/Makefile | 1 + drivers/clk/clk-rtd1295.c | 385 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 393 insertions(+) create mode 100644 drivers/clk/clk-rtd1295.c
drivers/clk/Kconfig +7 -0
@@ -209,6 +209,13 @@ config COMMON_CLK_OXNAS ---help--- Support for the OXNAS SoC Family clocks. +config CLK_RTD129X + bool "Clock driver for the Realtek RTD129x SoC family" + default ARCH_REALTEK && ARM64 + depends on (ARCH_REALTEK && ARM64) || COMPILE_TEST + ---help--- + Support for the Realtek RTD1295 SoC. + config COMMON_CLK_VC5 tristate "Clock driver for IDT VersaClock 5,6 devices" depends on I2C
drivers/clk/Makefile +1 -0
@@ -37,6 +37,7 @@ obj-$(CONFIG_COMMON_CLK_PALMAS) += clk-palmas.o obj-$(CONFIG_COMMON_CLK_PWM) += clk-pwm.o obj-$(CONFIG_CLK_QORIQ) += clk-qoriq.o obj-$(CONFIG_COMMON_CLK_RK808) += clk-rk808.o +obj-$(CONFIG_CLK_RTD129X) += clk-rtd1295.o obj-$(CONFIG_COMMON_CLK_HI655X) += clk-hi655x.o obj-$(CONFIG_COMMON_CLK_S2MPS11) += clk-s2mps11.o obj-$(CONFIG_COMMON_CLK_SCPI) += clk-scpi.o
drivers/clk/clk-rtd1295.c new file +385 -0
385 lines not on this page · raw message
Signature · 1 line
2.12.3
RFC 4/4 arm64: dts: realtek: Update RTD1295 UART nodes with clocks
In reply to Andreas FärberReplace clock-frequency with a reference to the respective clock gates.
--- arch/arm64/boot/dts/realtek/rtd1295.dtsi | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
arch/arm64/boot/dts/realtek/rtd1295.dtsi +4 -3
@@ -6,6 +6,7 @@ * SPDX-License-Identifier: (GPL-2.0+ OR MIT) */ +#include <dt-bindings/clock/realtek,rtd1295.h> #include <dt-bindings/interrupt-controller/arm-gic.h> #include <dt-bindings/reset/realtek,rtd1295.h>
@@ -152,7 +153,7 @@ reg = <0x98007800 0x400>; reg-shift = <2>; reg-io-width = <4>; - clock-frequency = <27000000>; + clocks = <&iso_clkc RTD1295_ISO_CLK_EN_MISC_UR0>; interrupt-parent = <&iso_irq_mux>; interrupts = <2>; resets = <&iso_reset RTD1295_ISO_RSTN_UR0>;
@@ -172,7 +173,7 @@ reg = <0x9801b200 0x100>; reg-shift = <2>; reg-io-width = <4>; - clock-frequency = <432000000>; + clocks = <&clkc RTD1295_CLK_EN_UR1>; interrupt-parent = <&irq_mux>; interrupts = <3>, <5>; resets = <&reset2 RTD1295_RSTN_UR1>;
@@ -184,7 +185,7 @@ reg = <0x9801b400 0x100>; reg-shift = <2>; reg-io-width = <4>; - clock-frequency = <432000000>; + clocks = <&clkc RTD1295_CLK_EN_UR2>; interrupt-parent = <&irq_mux>; interrupts = <8>, <13>; resets = <&reset2 RTD1295_RSTN_UR2>;
Signature · 1 line
2.12.3