Skip to contentSkip to conversation

clk: realtek: Add RTD1625 Clock Support

PATCH Superseded Yu-Chun Lin 4 participants 19 messages Mar 13 – Mar 18

Subsystems (4)

v4 of 17 Superseded Latest is v17 →

lore
Share & tools
lore

Yu-Chun Lin

author maintainer
#0 lore raw

v4 cover clk: realtek: Add RTD1625 Clock Support

Hello,

This patch series adds clock support for Realtek's RTD1625 platform The series includes:

1. Device Tree: Add clock controller nodes.
2. Infrastructure: reset controller, basic clocks, PLLs, gate clocks, mux clocks, and MMC-tuned PLLs.
3. Platform drivers: two clock controller drivers for RTD1625-CRT and RTD1625-ISO.

Best regards,
Yu-Chun Lin
---
Changes in v4:
In patch 1:
- Add include/dt-bindings/reset/realtek,rtd1625.h to the bindings.
- Drop Krzysztof Kozlowski's Reviewed-by tag due to the new changes. Patch 2:
- Add a new patch to introduce the clock device nodes in dts.
In patch 3:
- Added forward declaration for struct regmap in reset.c
- Moved struct rtk_reset_data definition into reset.c as it's only used there
- Removed rtk_reset_reset() due to unnecessary implementation
- Removed unnecessary parameter from rtk_reset_get_id()

v3: https://lore.kernel.org/lkml/[email protected]/
v2: https://lore.kernel.org/lkml/[email protected]/
v1: https://lore.kernel.org/lkml/[email protected]/

Yu-Chun Lin (10):
dt-bindings: clock: Add Realtek RTD1625 Clock & Reset Controller
arm64: dts: realtek: Add clock support for RTD1625
clk: realtek: Add basic reset support
clk: realtek: Introduce a common probe()
clk: realtek: Add support for phase locked loops (PLLs)
clk: realtek: Add support for gate clock
clk: realtek: Add support for mux clock
clk: realtek: Add support for MMC-tuned PLL clocks
clk: realtek: Add RTD1625-CRT clock controller driver
clk: realtek: Add RTD1625-ISO clock controller driver

 .../bindings/clock/realtek,rtd1625-clk.yaml   |  52 ++
 MAINTAINERS                                   |  18 +
 arch/arm64/boot/dts/realtek/kent.dtsi         |  30 +
 drivers/clk/Kconfig                           |   1 +
 drivers/clk/Makefile                          |   1 +
 drivers/clk/realtek/Kconfig                   |  45 +
 drivers/clk/realtek/Makefile                  |  14 +
 drivers/clk/realtek/clk-pll-mmc.c             | 399 +++++++++
 drivers/clk/realtek/clk-pll.c                 | 156 ++++
 drivers/clk/realtek/clk-pll.h                 |  68 ++
 drivers/clk/realtek/clk-regmap-gate.c         |  66 ++
 drivers/clk/realtek/clk-regmap-gate.h         |  65 ++
 drivers/clk/realtek/clk-regmap-mux.c          |  46 +
 drivers/clk/realtek/clk-regmap-mux.h          |  43 +
 drivers/clk/realtek/clk-rtd1625-crt.c         | 788 ++++++++++++++++++
 drivers/clk/realtek/clk-rtd1625-iso.c         | 153 ++++
 drivers/clk/realtek/common.c                  |  64 ++
 drivers/clk/realtek/common.h                  |  43 +
 drivers/clk/realtek/freq_table.c              |  35 +
 drivers/clk/realtek/freq_table.h              |  23 +
 drivers/clk/realtek/reset.c                   | 104 +++
 drivers/clk/realtek/reset.h                   |  28 +
 .../dt-bindings/clock/realtek,rtd1625-clk.h   | 164 ++++
 include/dt-bindings/reset/realtek,rtd1625.h   | 195 +++++
 24 files changed, 2601 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/realtek,rtd1625-clk.yaml
 create mode 100644 drivers/clk/realtek/Kconfig
 create mode 100644 drivers/clk/realtek/Makefile
 create mode 100644 drivers/clk/realtek/clk-pll-mmc.c
 create mode 100644 drivers/clk/realtek/clk-pll.c
 create mode 100644 drivers/clk/realtek/clk-pll.h
 create mode 100644 drivers/clk/realtek/clk-regmap-gate.c
 create mode 100644 drivers/clk/realtek/clk-regmap-gate.h
 create mode 100644 drivers/clk/realtek/clk-regmap-mux.c
 create mode 100644 drivers/clk/realtek/clk-regmap-mux.h
 create mode 100644 drivers/clk/realtek/clk-rtd1625-crt.c
 create mode 100644 drivers/clk/realtek/clk-rtd1625-iso.c
 create mode 100644 drivers/clk/realtek/common.c
 create mode 100644 drivers/clk/realtek/common.h
 create mode 100644 drivers/clk/realtek/freq_table.c
 create mode 100644 drivers/clk/realtek/freq_table.h
 create mode 100644 drivers/clk/realtek/reset.c
 create mode 100644 drivers/clk/realtek/reset.h
 create mode 100644 include/dt-bindings/clock/realtek,rtd1625-clk.h
 create mode 100644 include/dt-bindings/reset/realtek,rtd1625.h
Signature · 1 line
2.34.1
author maintainer
#1 lore raw

PATCH v4 1/10 dt-bindings: clock: Add Realtek RTD1625 Clock & Reset Controller

Add DT binding schema for Realtek RTD1625 clock and reset controller

---
Changes in v4:
- Add include/dt-bindings/reset/realtek,rtd1625.h and update the commit description accordingly.
- Drop Krzysztof Kozlowski's Reviewed-by tag due to the new changes.

---
 .../bindings/clock/realtek,rtd1625-clk.yaml   |  52 +++++
 MAINTAINERS                                   |   9 +
 .../dt-bindings/clock/realtek,rtd1625-clk.h   | 164 +++++++++++++++
 include/dt-bindings/reset/realtek,rtd1625.h   | 195 ++++++++++++++++++
 4 files changed, 420 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/realtek,rtd1625-clk.yaml
 create mode 100644 include/dt-bindings/clock/realtek,rtd1625-clk.h
 create mode 100644 include/dt-bindings/reset/realtek,rtd1625.h
Documentation/devicetree/bindings/clock/realtek,rtd1625-clk.yaml new file +52 -0
new file mode 100644
index 000000000000..6fabc2da3975
@@ -0,0 +1,52 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/clock/realtek,rtd1625-clk.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Realtek RTD1625 Clock & Reset Controller
+
+maintainers:
+  - Yu-Chun Lin <[email protected]>
+
+description: |
+  The Realtek RTD1625 Clock Controller manages and distributes clock
+  signals to various controllers and implements a Reset Controller for the
+  SoC peripherals.
+
+  Clocks and resets are referenced by unique identifiers, which are defined as
+  preprocessor macros in include/dt-bindings/clock/realtek,rtd1625-clk.h and
+  include/dt-bindings/reset/realtek,rtd1625.h.
+
+properties:
+  compatible:
+    enum:
+      - realtek,rtd1625-crt-clk
+      - realtek,rtd1625-iso-clk
+      - realtek,rtd1625-iso-s-clk
+
+  reg:
+    maxItems: 1
+
+  "#clock-cells":
+    const: 1
+
+  "#reset-cells":
+    const: 1
+
+required:
+  - compatible
+  - reg
+  - "#clock-cells"
+  - "#reset-cells"
+
+additionalProperties: false
+
+examples:
+  - |
+    clock-controller@98000000 {
+      compatible = "realtek,rtd1625-crt-clk";
+      reg = <98000000 0x1000>;
+      #clock-cells = <1>;
+      #reset-cells = <1>;
+    };
MAINTAINERS +9 -0
index 61bf550fd37c..9b7d64cc8d90 100644
@@ -22240,6 +22240,15 @@ S:	Maintained
 F:	Documentation/devicetree/bindings/net/dsa/realtek.yaml
 F:	drivers/net/dsa/realtek/*
 
+REALTEK SOC CLOCK AND RESET DRIVERS
+M:	Cheng-Yu Lee <[email protected]>
+M:	Yu-Chun Lin <[email protected]>
+L:	[email protected]
+L:	[email protected]
+S:	Supported
+F:	Documentation/devicetree/bindings/clock/realtek*
+F:	include/dt-bindings/clock/realtek*
+
 REALTEK SPI-NAND
 M:	Chris Packham <[email protected]>
 S:	Maintained
include/dt-bindings/clock/realtek,rtd1625-clk.h new file +164 -0

164 lines not on this page · raw message

include/dt-bindings/reset/realtek,rtd1625.h new file +195 -0

195 lines not on this page · raw message

Signature · 1 line
2.34.1
#2 lore raw

Re: [PATCH v4 01/10] dt-bindings: clock: Add Realtek RTD1625 Clock & Reset Controller

Quoted 19 lines · Yu-Chun Lin
include/dt-bindings/clock/realtek,rtd1625-clk.h new file +1 -0
+#endif /* __DT_BINDINGS_RTK_CLOCK_RTD1625_H */
include/dt-bindings/reset/realtek,rtd1625.h new file +12 -0
new file mode 100644
index 000000000000..e69b5ee14cc6
@@ -0,0 +1,195 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
+/*
+ * Copyright (C) 2025 Realtek Semiconductor Corp.
+ */
+#ifndef __DT_BINDINGS_RTK_RESET_RTD1625_H
+#define __DT_BINDINGS_RTK_RESET_RTD1625_H
+
+#define RTD1625_RSTN_REG_ID_SOFT_RESET1     0
+#define RTD1625_RSTN_REG_ID_SOFT_RESET2     1
+#define RTD1625_RSTN_REG_ID_SOFT_RESET3     2
+#define RTD1625_RSTN_REG_ID_SOFT_RESET4     3
+#define RTD1625_RSTN_REG_ID_SOFT_RESET7     4

include/dt-bindings/reset/realtek,rtd1625.h line 22

Quoted 10 lines
include/dt-bindings/reset/realtek,rtd1625.h new file +10 -0
+#define RTD1625_RSTN_REG_ID_SOFT_RESET9     5
+#define RTD1625_RSTN_REG_ID_SOFT_RESET_BIST 6
+#define RTD1625_RSTN_REG_ID_DUMMY0          7
+#define RTD1625_RSTN_REG_ID_DUMMY1          8
+#define RTD1625_RSTN_REG_ID_DUMMY4          9
+#define RTD1625_RSTN_REG_ID_SOFT_RESET11    10
+#define RTD1625_RSTN_REG_ID_SOFT_RESET12    11
+
+#define _REG_ID(n) ((RTD1625_RSTN_REG_ID_ ## n) << 5)
+

Not a binding.

include/dt-bindings/reset/realtek,rtd1625.h line 25

Quoted 3 lines
include/dt-bindings/reset/realtek,rtd1625.h new file +3 -0
+#define RTD1625_CRT_RSTN_MISC      (_REG_ID(SOFT_RESET1) | 0)
+#define RTD1625_CRT_RSTN_DIP       (_REG_ID(SOFT_RESET1) | 2)
+#define RTD1625_CRT_RSTN_GSPI      (_REG_ID(SOFT_RESET1) | 4)

None of these are really bindings. Register offsets is hardware data, not a binding.

Drop all of this above and further - actually nothing in this header look like a binding, since you called these "REG".

Best regards,
Krzysztof

author maintainer
#3 lore raw

RE: [PATCH v4 01/10] dt-bindings: clock: Add Realtek RTD1625 Clock & Reset Controller

Quoted 41 lines · Yu-Chun Lin
Quoted 20 lines
include/dt-bindings/clock/realtek,rtd1625-clk.h new file +1 -0
+#endif /* __DT_BINDINGS_RTK_CLOCK_RTD1625_H */
include/dt-bindings/reset/realtek,rtd1625.h new file +12 -0
new file mode 100644
index 000000000000..e69b5ee14cc6
@@ -0,0 +1,195 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
+/*
+ * Copyright (C) 2025 Realtek Semiconductor Corp.
+ */
+#ifndef __DT_BINDINGS_RTK_RESET_RTD1625_H #define
+__DT_BINDINGS_RTK_RESET_RTD1625_H
+
+#define RTD1625_RSTN_REG_ID_SOFT_RESET1     0
+#define RTD1625_RSTN_REG_ID_SOFT_RESET2     1
+#define RTD1625_RSTN_REG_ID_SOFT_RESET3     2
+#define RTD1625_RSTN_REG_ID_SOFT_RESET4     3
+#define RTD1625_RSTN_REG_ID_SOFT_RESET7     4

include/dt-bindings/reset/realtek,rtd1625.h line 22

Quoted 10 lines
include/dt-bindings/reset/realtek,rtd1625.h new file +10 -0
+#define RTD1625_RSTN_REG_ID_SOFT_RESET9     5
+#define RTD1625_RSTN_REG_ID_SOFT_RESET_BIST 6
+#define RTD1625_RSTN_REG_ID_DUMMY0          7
+#define RTD1625_RSTN_REG_ID_DUMMY1          8
+#define RTD1625_RSTN_REG_ID_DUMMY4          9
+#define RTD1625_RSTN_REG_ID_SOFT_RESET11    10
+#define RTD1625_RSTN_REG_ID_SOFT_RESET12    11
+
+#define _REG_ID(n) ((RTD1625_RSTN_REG_ID_ ## n) << 5)
+

Not a binding.

include/dt-bindings/reset/realtek,rtd1625.h line 25

Quoted 3 lines
include/dt-bindings/reset/realtek,rtd1625.h new file +3 -0
+#define RTD1625_CRT_RSTN_MISC      (_REG_ID(SOFT_RESET1) | 0)
+#define RTD1625_CRT_RSTN_DIP       (_REG_ID(SOFT_RESET1) | 2)
+#define RTD1625_CRT_RSTN_GSPI      (_REG_ID(SOFT_RESET1) | 4)

None of these are really bindings. Register offsets is hardware data, not a binding.

Quoted 5 lines

Drop all of this above and further - actually nothing in this header look like a binding, since you called these "REG".

Best regards,
Krzysztof

The defines in this header are NOT register offsets. They encode "Bank ID+ Bit Position" for use in Device Tree.

Agreed, The naming with "REG_ID" is misleading. I will improve naming all reset IDs in v5.

Best regards,
Yu-Chun

#4 lore raw

Re: [PATCH v4 01/10] dt-bindings: clock: Add Realtek RTD1625 Clock & Reset Controller

Quoted 41 lines · Yu-Chun Lin [林祐君]
Quoted 41 lines · Yu-Chun Lin
Quoted 20 lines
include/dt-bindings/clock/realtek,rtd1625-clk.h new file +1 -0
+#endif /* __DT_BINDINGS_RTK_CLOCK_RTD1625_H */
include/dt-bindings/reset/realtek,rtd1625.h new file +12 -0
new file mode 100644
index 000000000000..e69b5ee14cc6
@@ -0,0 +1,195 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
+/*
+ * Copyright (C) 2025 Realtek Semiconductor Corp.
+ */
+#ifndef __DT_BINDINGS_RTK_RESET_RTD1625_H #define
+__DT_BINDINGS_RTK_RESET_RTD1625_H
+
+#define RTD1625_RSTN_REG_ID_SOFT_RESET1     0
+#define RTD1625_RSTN_REG_ID_SOFT_RESET2     1
+#define RTD1625_RSTN_REG_ID_SOFT_RESET3     2
+#define RTD1625_RSTN_REG_ID_SOFT_RESET4     3
+#define RTD1625_RSTN_REG_ID_SOFT_RESET7     4

include/dt-bindings/reset/realtek,rtd1625.h line 22

Quoted 10 lines
include/dt-bindings/reset/realtek,rtd1625.h new file +10 -0
+#define RTD1625_RSTN_REG_ID_SOFT_RESET9     5
+#define RTD1625_RSTN_REG_ID_SOFT_RESET_BIST 6
+#define RTD1625_RSTN_REG_ID_DUMMY0          7
+#define RTD1625_RSTN_REG_ID_DUMMY1          8
+#define RTD1625_RSTN_REG_ID_DUMMY4          9
+#define RTD1625_RSTN_REG_ID_SOFT_RESET11    10
+#define RTD1625_RSTN_REG_ID_SOFT_RESET12    11
+
+#define _REG_ID(n) ((RTD1625_RSTN_REG_ID_ ## n) << 5)
+

Not a binding.

include/dt-bindings/reset/realtek,rtd1625.h line 25

Quoted 3 lines
include/dt-bindings/reset/realtek,rtd1625.h new file +3 -0
+#define RTD1625_CRT_RSTN_MISC      (_REG_ID(SOFT_RESET1) | 0)
+#define RTD1625_CRT_RSTN_DIP       (_REG_ID(SOFT_RESET1) | 2)
+#define RTD1625_CRT_RSTN_GSPI      (_REG_ID(SOFT_RESET1) | 4)

None of these are really bindings. Register offsets is hardware data, not a binding.

Quoted 8 lines
Quoted 5 lines

Drop all of this above and further - actually nothing in this header look like a binding, since you called these "REG".

Best regards,
Krzysztof

The defines in this header are NOT register offsets. They encode "Bank ID+ Bit Position" for use in Device Tree.

Bit position as in register bit position? That's still not a binding.

Quoted 3 lines

Agreed, The naming with "REG_ID" is misleading. I will improve naming all reset IDs in v5.

No, all are to be dropped or renamed to standard IDs (incremented by one from 0 or 1).

Best regards,
Krzysztof

#5 lore raw

Re: [PATCH v4 01/10] dt-bindings: clock: Add Realtek RTD1625 Clock & Reset Controller

Quoted 55 lines · Yu-Chun Lin [林祐君]
Quoted 41 lines
Quoted 41 lines · Yu-Chun Lin
Quoted 20 lines
include/dt-bindings/clock/realtek,rtd1625-clk.h new file +1 -0
+#endif /* __DT_BINDINGS_RTK_CLOCK_RTD1625_H */
include/dt-bindings/reset/realtek,rtd1625.h new file +12 -0
new file mode 100644
index 000000000000..e69b5ee14cc6
@@ -0,0 +1,195 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
+/*
+ * Copyright (C) 2025 Realtek Semiconductor Corp.
+ */
+#ifndef __DT_BINDINGS_RTK_RESET_RTD1625_H #define
+__DT_BINDINGS_RTK_RESET_RTD1625_H
+
+#define RTD1625_RSTN_REG_ID_SOFT_RESET1     0
+#define RTD1625_RSTN_REG_ID_SOFT_RESET2     1
+#define RTD1625_RSTN_REG_ID_SOFT_RESET3     2
+#define RTD1625_RSTN_REG_ID_SOFT_RESET4     3
+#define RTD1625_RSTN_REG_ID_SOFT_RESET7     4

include/dt-bindings/reset/realtek,rtd1625.h line 22

Quoted 10 lines
include/dt-bindings/reset/realtek,rtd1625.h new file +10 -0
+#define RTD1625_RSTN_REG_ID_SOFT_RESET9     5
+#define RTD1625_RSTN_REG_ID_SOFT_RESET_BIST 6
+#define RTD1625_RSTN_REG_ID_DUMMY0          7
+#define RTD1625_RSTN_REG_ID_DUMMY1          8
+#define RTD1625_RSTN_REG_ID_DUMMY4          9
+#define RTD1625_RSTN_REG_ID_SOFT_RESET11    10
+#define RTD1625_RSTN_REG_ID_SOFT_RESET12    11
+
+#define _REG_ID(n) ((RTD1625_RSTN_REG_ID_ ## n) << 5)
+

Not a binding.

include/dt-bindings/reset/realtek,rtd1625.h line 25

Quoted 3 lines
include/dt-bindings/reset/realtek,rtd1625.h new file +3 -0
+#define RTD1625_CRT_RSTN_MISC      (_REG_ID(SOFT_RESET1) | 0)
+#define RTD1625_CRT_RSTN_DIP       (_REG_ID(SOFT_RESET1) | 2)
+#define RTD1625_CRT_RSTN_GSPI      (_REG_ID(SOFT_RESET1) | 4)

None of these are really bindings. Register offsets is hardware data, not a binding.

Quoted 8 lines
Quoted 5 lines

Drop all of this above and further - actually nothing in this header look like a binding, since you called these "REG".

Best regards,
Krzysztof

The defines in this header are NOT register offsets. They encode "Bank ID+ Bit Position" for use in Device Tree.

Bit position as in register bit position? That's still not a binding.

Quoted 1 line
Quoted 8 lines
Quoted 2 lines

Agreed, The naming with "REG_ID" is misleading. I will improve naming all reset IDs in v5.

No, all are to be dropped or renamed to standard IDs (incremented by one from 0 or 1).

Best regards,
Krzysztof

Hi Krzysztof,

Understood. I will redesign as follows:

1. Binding header: Sequential IDs (0, 1, 2, ...) without hardware details.
2. Driver: Internal mapping table to convert IDs to register/bit positions.
3. DT: Uses abstract IDs from binding header.

Regards,
Yu-Chun

author maintainer
#6 lore raw

PATCH v4 2/10 arm64: dts: realtek: Add clock support for RTD1625

In reply to Yu-Chun Lin

Add the clock controller nodes and osc27m fixed clock for the Realtek RTD1625 SoC.

---
Changes in v4:
- This is a new patch.

---
 arch/arm64/boot/dts/realtek/kent.dtsi | 30 +++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
arch/arm64/boot/dts/realtek/kent.dtsi +30 -0
index ae006ce24420..eaff586c1806 100644
@@ -26,6 +26,15 @@ timer {
 			     <GIC_PPI  9 IRQ_TYPE_LEVEL_HIGH>;
 	};
 
+	clocks {
+		osc27m: osc {
+			compatible = "fixed-clock";
+			clock-frequency = <27000000>;
+			clock-output-names = "osc27m";
+			#clock-cells = <0>;
+		};
+	};
+
 	cpus {
 		#address-cells = <1>;
 		#size-cells = <0>;
@@ -141,6 +150,20 @@ rbus: bus@98000000 {
 			#address-cells = <1>;
 			#size-cells = <1>;
 
+			cc: clock-controller@0 {
+				compatible = "realtek,rtd1625-crt-clk";
+				reg = <0x0 0x900>;
+				#clock-cells = <1>;
+				#reset-cells = <1>;
+			};
+
+			ic: clock-controller@7088 {
+				compatible = "realtek,rtd1625-iso-clk";
+				reg = <0x7088 0x8>;
+				#clock-cells = <1>;
+				#reset-cells = <1>;
+			};
+
 			uart0: serial@7800 {
 				compatible = "snps,dw-apb-uart";
 				reg = <0x7800 0x100>;
@@ -150,6 +173,13 @@ uart0: serial@7800 {
 				reg-shift = <2>;
 				status = "disabled";
 			};
+
+			iso_s_cc: clock-controller@146310 {
+				compatible = "realtek,rtd1625-iso-s-clk";
+				reg = <0x146310 0x8>;
+				#clock-cells = <1>;
+				#reset-cells = <1>;
+			};
 		};
 
 		gic: interrupt-controller@ff100000 {
Signature · 1 line
2.34.1
author maintainer
#7 lore raw

PATCH v4 3/10 clk: realtek: Add basic reset support

In reply to Yu-Chun Lin

From: Cheng-Yu Lee <[email protected]>

Define the reset operations backed by a regmap-based register interface and prepare the reset controller to be registered through the reset framework.

---
Changes in v4:
- Add forward declaration for struct regmap in reset.h.
- Move struct rtk_reset_data definition into reset.c as it's only used there.
- Remove rtk_reset_reset() due to unnecessary implementation.
- Remove unnecessary parameter from rtk_reset_get_id().

---
 MAINTAINERS                  |   1 +
 drivers/clk/Kconfig          |   1 +
 drivers/clk/Makefile         |   1 +
 drivers/clk/realtek/Kconfig  |  27 ++++++++++
 drivers/clk/realtek/Makefile |   4 ++
 drivers/clk/realtek/reset.c  | 104 +++++++++++++++++++++++++++++++++++
 drivers/clk/realtek/reset.h  |  28 ++++++++++
 7 files changed, 167 insertions(+)
 create mode 100644 drivers/clk/realtek/Kconfig
 create mode 100644 drivers/clk/realtek/Makefile
 create mode 100644 drivers/clk/realtek/reset.c
 create mode 100644 drivers/clk/realtek/reset.h
MAINTAINERS +1 -0
index 9b7d64cc8d90..53a2f3575c37 100644
@@ -22247,6 +22247,7 @@ L:	[email protected]
 L:	[email protected]
 S:	Supported
 F:	Documentation/devicetree/bindings/clock/realtek*
+F:	drivers/clk/realtek/*
 F:	include/dt-bindings/clock/realtek*
 
 REALTEK SPI-NAND
drivers/clk/Kconfig +1 -0
index 3d803b4cf5c1..d60f6415b0a3 100644
@@ -519,6 +519,7 @@ source "drivers/clk/nuvoton/Kconfig"
 source "drivers/clk/pistachio/Kconfig"
 source "drivers/clk/qcom/Kconfig"
 source "drivers/clk/ralink/Kconfig"
+source "drivers/clk/realtek/Kconfig"
 source "drivers/clk/renesas/Kconfig"
 source "drivers/clk/rockchip/Kconfig"
 source "drivers/clk/samsung/Kconfig"
drivers/clk/Makefile +1 -0
index f7bce3951a30..69b84d1e7bcc 100644
@@ -140,6 +140,7 @@ obj-$(CONFIG_COMMON_CLK_PISTACHIO)	+= pistachio/
 obj-$(CONFIG_COMMON_CLK_PXA)		+= pxa/
 obj-$(CONFIG_COMMON_CLK_QCOM)		+= qcom/
 obj-y					+= ralink/
+obj-$(CONFIG_COMMON_CLK_REALTEK)	+= realtek/
 obj-y					+= renesas/
 obj-$(CONFIG_ARCH_ROCKCHIP)		+= rockchip/
 obj-$(CONFIG_COMMON_CLK_SAMSUNG)	+= samsung/
drivers/clk/realtek/Kconfig new file +27 -0
new file mode 100644
index 000000000000..121158f11dd1
@@ -0,0 +1,27 @@
+# SPDX-License-Identifier: GPL-2.0-only
+config COMMON_CLK_REALTEK
+	bool "Clock driver for Realtek SoCs"
+	depends on ARCH_REALTEK || COMPILE_TEST
+	default y
+	help
+	  Enable the common clock framework infrastructure for Realtek
+	  system-on-chip platforms.
+
+	  This provides the base support required by individual Realtek
+	  clock controller drivers to expose clocks to peripheral devices.
+
+	  If you have a Realtek-based platform, say Y.
+
+if COMMON_CLK_REALTEK
+
+config RTK_CLK_COMMON
+	tristate "Realtek Clock Common"
+	select RESET_CONTROLLER
+	help
+	  Common helper code shared by Realtek clock controller drivers.
+
+	  This provides utility functions and data structures used by
+	  multiple Realtek clock implementations, and include integration
+	  with reset controllers where required.
+
+endif
drivers/clk/realtek/Makefile new file +4 -0
new file mode 100644
index 000000000000..52267de2eef4
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0-only
+obj-$(CONFIG_RTK_CLK_COMMON) += clk-rtk.o
+
+clk-rtk-y += reset.o
drivers/clk/realtek/reset.c new file +104 -0

104 lines not on this page · raw message

drivers/clk/realtek/reset.h new file +28 -0
new file mode 100644
index 000000000000..56f944b1dcdd
@@ -0,0 +1,28 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (C) 2019 Realtek Semiconductor Corporation
+ * Author: Cheng-Yu Lee <[email protected]>
+ */
+
+#ifndef __CLK_REALTEK_RESET_H
+#define __CLK_REALTEK_RESET_H
+
+#include <linux/reset-controller.h>
+
+struct regmap;
+
+struct rtk_reset_bank {
+	u32 ofs;
+	u32 write_en;
+};
+
+struct rtk_reset_initdata {
+	struct rtk_reset_bank *banks;
+	u32 num_banks;
+	struct regmap *regmap;
+};
+
+int rtk_reset_controller_add(struct device *dev,
+			     struct rtk_reset_initdata *initdata);
+
+#endif /* __CLK_REALTEK_RESET_H */
Signature · 1 line
2.34.1
#8 lore raw

Re: [PATCH v4 03/10] clk: realtek: Add basic reset support

Quoted 79 lines · Yu-Chun Lin

From: Cheng-Yu Lee <[email protected]>

Define the reset operations backed by a regmap-based register interface and prepare the reset controller to be registered through the reset framework.

---
Changes in v4:
- Add forward declaration for struct regmap in reset.h.
- Move struct rtk_reset_data definition into reset.c as it's only used there.
- Remove rtk_reset_reset() due to unnecessary implementation.
- Remove unnecessary parameter from rtk_reset_get_id().

---
 MAINTAINERS                  |   1 +
 drivers/clk/Kconfig          |   1 +
 drivers/clk/Makefile         |   1 +
 drivers/clk/realtek/Kconfig  |  27 ++++++++++
 drivers/clk/realtek/Makefile |   4 ++
 drivers/clk/realtek/reset.c  | 104 +++++++++++++++++++++++++++++++++++
 drivers/clk/realtek/reset.h  |  28 ++++++++++
 7 files changed, 167 insertions(+)
 create mode 100644 drivers/clk/realtek/Kconfig
 create mode 100644 drivers/clk/realtek/Makefile
 create mode 100644 drivers/clk/realtek/reset.c
 create mode 100644 drivers/clk/realtek/reset.h
MAINTAINERS +1 -0
index 9b7d64cc8d90..53a2f3575c37 100644
@@ -22247,6 +22247,7 @@ L:	[email protected]
 L:	[email protected]
 S:	Supported
 F:	Documentation/devicetree/bindings/clock/realtek*
+F:	drivers/clk/realtek/*
 F:	include/dt-bindings/clock/realtek*
 
 REALTEK SPI-NAND
drivers/clk/Kconfig +1 -0
index 3d803b4cf5c1..d60f6415b0a3 100644
@@ -519,6 +519,7 @@ source "drivers/clk/nuvoton/Kconfig"
 source "drivers/clk/pistachio/Kconfig"
 source "drivers/clk/qcom/Kconfig"
 source "drivers/clk/ralink/Kconfig"
+source "drivers/clk/realtek/Kconfig"
 source "drivers/clk/renesas/Kconfig"
 source "drivers/clk/rockchip/Kconfig"
 source "drivers/clk/samsung/Kconfig"
drivers/clk/Makefile +1 -0
index f7bce3951a30..69b84d1e7bcc 100644
@@ -140,6 +140,7 @@ obj-$(CONFIG_COMMON_CLK_PISTACHIO)	+= pistachio/
 obj-$(CONFIG_COMMON_CLK_PXA)		+= pxa/
 obj-$(CONFIG_COMMON_CLK_QCOM)		+= qcom/
 obj-y					+= ralink/
+obj-$(CONFIG_COMMON_CLK_REALTEK)	+= realtek/
 obj-y					+= renesas/
 obj-$(CONFIG_ARCH_ROCKCHIP)		+= rockchip/
 obj-$(CONFIG_COMMON_CLK_SAMSUNG)	+= samsung/
drivers/clk/realtek/Kconfig new file +8 -0
new file mode 100644
index 000000000000..121158f11dd1
@@ -0,0 +1,27 @@
+# SPDX-License-Identifier: GPL-2.0-only
+config COMMON_CLK_REALTEK
+	bool "Clock driver for Realtek SoCs"
+	depends on ARCH_REALTEK || COMPILE_TEST
+	default y
+	help
+	  Enable the common clock framework infrastructure for Realtek
+	  system-on-chip platforms.

drivers/clk/realtek/Kconfig line 18

Quoted 10 lines
drivers/clk/realtek/Kconfig new file +10 -0
+
+	  This provides the base support required by individual Realtek
+	  clock controller drivers to expose clocks to peripheral devices.
+
+	  If you have a Realtek-based platform, say Y.
+
+if COMMON_CLK_REALTEK
+
+config RTK_CLK_COMMON
+	tristate "Realtek Clock Common"

Reset drivers go to reset directory.

Quoted 25 lines
drivers/clk/realtek/Kconfig new file +9 -0
+	select RESET_CONTROLLER
+	help
+	  Common helper code shared by Realtek clock controller drivers.
+
+	  This provides utility functions and data structures used by
+	  multiple Realtek clock implementations, and include integration
+	  with reset controllers where required.
+
+endif
drivers/clk/realtek/Makefile new file +4 -0
new file mode 100644
index 000000000000..52267de2eef4
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0-only
+obj-$(CONFIG_RTK_CLK_COMMON) += clk-rtk.o
+
+clk-rtk-y += reset.o
drivers/clk/realtek/reset.c new file +0 -0
new file mode 100644
index 000000000000..45713785d76d

drivers/clk/realtek/reset.c line 9

Quoted 9 lines
drivers/clk/realtek/reset.c new file +9 -0
@@ -0,0 +1,104 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (C) 2019 Realtek Semiconductor Corporation
+ */
+
+#include <linux/device.h>
+#include <linux/of.h>
+#include <linux/regmap.h>
+#include "reset.h"

And here is the proof that none of your reset header constants are bindings - do you see the header here above? No.

Best regards,
Krzysztof

author maintainer
#9 lore raw

RE: [PATCH v4 03/10] clk: realtek: Add basic reset support

Quoted 84 lines · Yu-Chun Lin

drivers/clk/Makefile obj-$(CONFIG_COMMON_CLK_PISTACHIO)

Quoted 59 lines

From: Cheng-Yu Lee <[email protected]>

Define the reset operations backed by a regmap-based register interface and prepare the reset controller to be registered through the reset framework.

---
Changes in v4:
- Add forward declaration for struct regmap in reset.h.
- Move struct rtk_reset_data definition into reset.c as it's only used there.
- Remove rtk_reset_reset() due to unnecessary implementation.
- Remove unnecessary parameter from rtk_reset_get_id().

---
 MAINTAINERS                  |   1 +
 drivers/clk/Kconfig          |   1 +
 drivers/clk/Makefile         |   1 +
 drivers/clk/realtek/Kconfig  |  27 ++++++++++
 drivers/clk/realtek/Makefile |   4 ++
 drivers/clk/realtek/reset.c  | 104
+++++++++++++++++++++++++++++++++++
 drivers/clk/realtek/reset.h  |  28 ++++++++++
 7 files changed, 167 insertions(+)
 create mode 100644 drivers/clk/realtek/Kconfig  create mode 100644

drivers/clk/realtek/Makefile create mode 100644
drivers/clk/realtek/reset.c create mode 100644
drivers/clk/realtek/reset.h

MAINTAINERS index renamed from MAINTAINERS +0 -0

9b7d64cc8d90..53a2f3575c37 100644

MAINTAINERS +1 -0
@@ -22247,6 +22247,7 @@ L:    [email protected]
 L:   [email protected]
 S:   Supported
 F:   Documentation/devicetree/bindings/clock/realtek*
+F:   drivers/clk/realtek/*
 F:   include/dt-bindings/clock/realtek*
 
 REALTEK SPI-NAND
drivers/clk/Kconfig index renamed from drivers/clk/Kconfig +0 -0

3d803b4cf5c1..d60f6415b0a3 100644

drivers/clk/Kconfig +1 -0
@@ -519,6 +519,7 @@ source "drivers/clk/nuvoton/Kconfig"
 source "drivers/clk/pistachio/Kconfig"
 source "drivers/clk/qcom/Kconfig"
 source "drivers/clk/ralink/Kconfig"
+source "drivers/clk/realtek/Kconfig"
 source "drivers/clk/renesas/Kconfig"
 source "drivers/clk/rockchip/Kconfig"
 source "drivers/clk/samsung/Kconfig"
drivers/clk/Makefile index renamed from drivers/clk/Makefile +0 -0

f7bce3951a30..69b84d1e7bcc 100644

drivers/clk/Makefile +0 -0
@@ -140,6 +140,7 @@ obj-$(CONFIG_COMMON_CLK_PISTACHIO)
+= pistachio/
>  obj-$(CONFIG_COMMON_CLK_PXA)         += pxa/
>  obj-$(CONFIG_COMMON_CLK_QCOM)                += qcom/
>  obj-y                                        += ralink/
> +obj-$(CONFIG_COMMON_CLK_REALTEK)     += realtek/
>  obj-y                                        += renesas/
>  obj-$(CONFIG_ARCH_ROCKCHIP)          += rockchip/
>  obj-$(CONFIG_COMMON_CLK_SAMSUNG)     += samsung/
Quoted 16 lines
drivers/clk/realtek/Kconfig new file +11 -0
new file mode 100644 index 000000000000..121158f11dd1
@@ -0,0 +1,27 @@
+# SPDX-License-Identifier: GPL-2.0-only config COMMON_CLK_REALTEK
+     bool "Clock driver for Realtek SoCs"
+     depends on ARCH_REALTEK || COMPILE_TEST
+     default y
+     help
+       Enable the common clock framework infrastructure for Realtek
+       system-on-chip platforms.
+
+       This provides the base support required by individual Realtek
+       clock controller drivers to expose clocks to peripheral devices.
+
Quoted 9 lines

drivers/clk/realtek/Kconfig line 18

Quoted 6 lines
drivers/clk/realtek/Kconfig new file +6 -0
+       If you have a Realtek-based platform, say Y.
+
+if COMMON_CLK_REALTEK
+
+config RTK_CLK_COMMON
+     tristate "Realtek Clock Common"

Reset drivers go to reset directory.

Several vendors (e.g. qcom, mediatek, visconti) also place reset code in drivers/clk/ when the reset controller is integrated with the clock controller.

Quoted 27 lines
Quoted 27 lines
drivers/clk/realtek/Kconfig new file +9 -0
+     select RESET_CONTROLLER
+     help
+       Common helper code shared by Realtek clock controller drivers.
+
+       This provides utility functions and data structures used by
+       multiple Realtek clock implementations, and include integration
+       with reset controllers where required.
+
+endif
(quoted diff) +0 -0

b/drivers/clk/realtek/Makefile new file mode 100644 index 000000000000..52267de2eef4

drivers/clk/realtek/Makefile new file +4 -0
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0-only
+obj-$(CONFIG_RTK_CLK_COMMON) += clk-rtk.o
+
+clk-rtk-y += reset.o
drivers/clk/realtek/reset.c new file +3 -0
new file mode 100644 index 000000000000..45713785d76d
@@ -0,0 +1,104 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (C) 2019 Realtek Semiconductor Corporation  */
Quoted 9 lines

drivers/clk/realtek/reset.c line 9

Quoted 5 lines
drivers/clk/realtek/reset.c new file +5 -0
+
+#include <linux/device.h>
+#include <linux/of.h>
+#include <linux/regmap.h>
+#include "reset.h"

And here is the proof that none of your reset header constants are bindings - do you see the header here above? No.

The bank mapping is implicitly hardcoded in drivers:

Example: clk-rtd1625-crt.c

static struct rtk_reset_bank rtd1625_crt_reset_banks[] = {
    {.ofs = 0x0, .write_en = 1,},   /* Bank 0 */
    {.ofs = 0x4, .write_en = 1,},   /* Bank 1 */
    {.ofs = 0x8, .write_en = 1,},   /* Bank 2 */
    /* ... */
};

The array index implicitly corresponds to the bank ID in the header. In v5, I will explicitly use the header defines to make this mapping clear:

static struct rtk_reset_desc rtd1625_cc_reset_descs[] = {
	/* Bank 0: offset 0x000 */
	[RTD1625_CRT_RSTN_MISC] = {.ofs = 0x000, .bit = 0,  .write_en = 1},

[RTD1625_CRT_RSTN_DIP] = {.ofs = 0x000, .bit = 2, .write_en = 1}, /* ... */
};

Best regards,
Yu-Chun

Quoted 2 lines

Best regards,
Krzysztof

#10 lore raw

Re: [PATCH v4 03/10] clk: realtek: Add basic reset support

Quoted 18 lines · Yu-Chun Lin [林祐君]
Quoted 8 lines
Quoted 8 lines
drivers/clk/realtek/reset.c new file +3 -0
new file mode 100644 index 000000000000..45713785d76d
@@ -0,0 +1,104 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (C) 2019 Realtek Semiconductor Corporation  */
Quoted 9 lines

drivers/clk/realtek/reset.c line 9

Quoted 5 lines
drivers/clk/realtek/reset.c new file +5 -0
+
+#include <linux/device.h>
+#include <linux/of.h>
+#include <linux/regmap.h>
+#include "reset.h"

And here is the proof that none of your reset header constants are bindings - do you see the header here above? No.

Quoted 1 line

The bank mapping is implicitly hardcoded in drivers:

Does not matter. Here is the proof this is not a binding.

Best regards,
Krzysztof

maintainer
#11 lore raw

Re: [PATCH v4 03/10] clk: realtek: Add basic reset support

In reply to Yu-Chun Lin [林祐君]
Quoted 93 lines · Yu-Chun Lin [林祐君]
Quoted 84 lines · Yu-Chun Lin

drivers/clk/Makefile obj-$(CONFIG_COMMON_CLK_PISTACHIO)

Quoted 59 lines

From: Cheng-Yu Lee <[email protected]>

Define the reset operations backed by a regmap-based register interface and prepare the reset controller to be registered through the reset framework.

---
Changes in v4:
- Add forward declaration for struct regmap in reset.h.
- Move struct rtk_reset_data definition into reset.c as it's only used there.
- Remove rtk_reset_reset() due to unnecessary implementation.
- Remove unnecessary parameter from rtk_reset_get_id().
---

 MAINTAINERS                  |   1 +
 drivers/clk/Kconfig          |   1 +
 drivers/clk/Makefile         |   1 +
 drivers/clk/realtek/Kconfig  |  27 ++++++++++
 drivers/clk/realtek/Makefile |   4 ++
 drivers/clk/realtek/reset.c  | 104
+++++++++++++++++++++++++++++++++++
 drivers/clk/realtek/reset.h  |  28 ++++++++++
 7 files changed, 167 insertions(+)

 create mode 100644 drivers/clk/realtek/Kconfig create mode 100644 drivers/clk/realtek/Makefile create mode 100644 drivers/clk/realtek/reset.c create mode 100644 drivers/clk/realtek/reset.h

MAINTAINERS index renamed from MAINTAINERS +0 -0

9b7d64cc8d90..53a2f3575c37 100644

MAINTAINERS +0 -0
@@ -22247,6 +22247,7 @@ L:    [email protected]
 L:   [email protected]
 S:   Supported
 F:   Documentation/devicetree/bindings/clock/realtek*

+F: drivers/clk/realtek/*
 F: include/dt-bindings/clock/realtek*

 REALTEK SPI-NAND

drivers/clk/Kconfig index renamed from drivers/clk/Kconfig +0 -0

3d803b4cf5c1..d60f6415b0a3 100644

drivers/clk/Kconfig +0 -0
@@ -519,6 +519,7 @@ source "drivers/clk/nuvoton/Kconfig"

 source "drivers/clk/pistachio/Kconfig"
 source "drivers/clk/qcom/Kconfig"
 source "drivers/clk/ralink/Kconfig"
+source "drivers/clk/realtek/Kconfig"
 source "drivers/clk/renesas/Kconfig"
 source "drivers/clk/rockchip/Kconfig"
 source "drivers/clk/samsung/Kconfig"

drivers/clk/Makefile index renamed from drivers/clk/Makefile +0 -0

f7bce3951a30..69b84d1e7bcc 100644

drivers/clk/Makefile +0 -0
@@ -140,6 +140,7 @@ obj-$(CONFIG_COMMON_CLK_PISTACHIO)
+= pistachio/
>  obj-$(CONFIG_COMMON_CLK_PXA)         += pxa/
>  obj-$(CONFIG_COMMON_CLK_QCOM)                += qcom/
>  obj-y                                        += ralink/
> +obj-$(CONFIG_COMMON_CLK_REALTEK)     += realtek/
>  obj-y                                        += renesas/
>  obj-$(CONFIG_ARCH_ROCKCHIP)          += rockchip/
>  obj-$(CONFIG_COMMON_CLK_SAMSUNG)     += samsung/
Quoted 16 lines
drivers/clk/realtek/Kconfig new file +11 -0
new file mode 100644 index 000000000000..121158f11dd1
@@ -0,0 +1,27 @@
+# SPDX-License-Identifier: GPL-2.0-only config COMMON_CLK_REALTEK
+     bool "Clock driver for Realtek SoCs"
+     depends on ARCH_REALTEK || COMPILE_TEST
+     default y
+     help
+       Enable the common clock framework infrastructure for Realtek
+       system-on-chip platforms.
+
+       This provides the base support required by individual Realtek
+       clock controller drivers to expose clocks to peripheral devices.
+
Quoted 8 lines

drivers/clk/realtek/Kconfig line 18

Quoted 6 lines
drivers/clk/realtek/Kconfig new file +6 -0
+       If you have a Realtek-based platform, say Y.
+
+if COMMON_CLK_REALTEK
+
+config RTK_CLK_COMMON
+     tristate "Realtek Clock Common"

Reset drivers go to reset directory.

Quoted 2 lines

Several vendors (e.g. qcom, mediatek, visconti) also place reset code in drivers/clk/ when the reset controller is integrated with the clock controller.

Mostly for historical reasons (qcom and mediatek drivers were implemented long before the auxiliary bus existed).

Can you turn this into an auxiliary device driver under drivers/reset?

regards
Philipp

author maintainer
#12 lore raw

PATCH v4 4/10 clk: realtek: Introduce a common probe()

In reply to Yu-Chun Lin

From: Cheng-Yu Lee <[email protected]>

Add rtk_clk_probe() to set up the shared regmap, register clock hardware, add the clock provider, and optionally register a reset controller when reset bank data is provided.

---
Changes in v4:
- None.

---
 drivers/clk/realtek/Makefile |  1 +
 drivers/clk/realtek/common.c | 64 ++++++++++++++++++++++++++++++++++++
 drivers/clk/realtek/common.h | 43 ++++++++++++++++++++++++
 3 files changed, 108 insertions(+)
 create mode 100644 drivers/clk/realtek/common.c
 create mode 100644 drivers/clk/realtek/common.h
drivers/clk/realtek/Makefile +1 -0
index 52267de2eef4..4041951b7c62 100644
@@ -1,4 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0-only
 obj-$(CONFIG_RTK_CLK_COMMON) += clk-rtk.o
 
+clk-rtk-y += common.o
 clk-rtk-y += reset.o
drivers/clk/realtek/common.c new file +64 -0

64 lines not on this page · raw message

drivers/clk/realtek/common.h new file +43 -0

43 lines not on this page · raw message

Signature · 1 line
2.34.1
author maintainer
#13 lore raw

PATCH v4 5/10 clk: realtek: Add support for phase locked loops (PLLs)

In reply to Yu-Chun Lin

From: Cheng-Yu Lee <[email protected]>

Provide a full set of PLL operations for programmable PLLs and a read-only variant for fixed or hardware-managed PLLs.

---
Changes in v4:
- None.

---
 drivers/clk/realtek/Makefile     |   2 +
 drivers/clk/realtek/clk-pll.c    | 156 +++++++++++++++++++++++++++++++
 drivers/clk/realtek/clk-pll.h    |  47 ++++++++++
 drivers/clk/realtek/freq_table.c |  35 +++++++
 drivers/clk/realtek/freq_table.h |  23 +++++
 5 files changed, 263 insertions(+)
 create mode 100644 drivers/clk/realtek/clk-pll.c
 create mode 100644 drivers/clk/realtek/clk-pll.h
 create mode 100644 drivers/clk/realtek/freq_table.c
 create mode 100644 drivers/clk/realtek/freq_table.h
drivers/clk/realtek/Makefile +2 -0
index 4041951b7c62..c173ea3b10e3 100644
@@ -2,4 +2,6 @@
 obj-$(CONFIG_RTK_CLK_COMMON) += clk-rtk.o
 
 clk-rtk-y += common.o
+clk-rtk-y += clk-pll.o
+clk-rtk-y += freq_table.o
 clk-rtk-y += reset.o
drivers/clk/realtek/clk-pll.c new file +156 -0

156 lines not on this page · raw message

drivers/clk/realtek/clk-pll.h new file +47 -0

47 lines not on this page · raw message

drivers/clk/realtek/freq_table.c new file +35 -0
new file mode 100644
index 000000000000..26a0d2d3e851
@@ -0,0 +1,35 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#include "freq_table.h"
+
+const struct freq_table *ftbl_find_by_rate(const struct freq_table *ftbl,
+					   unsigned long rate)
+{
+	unsigned long best_rate = 0;
+	const struct freq_table *best = NULL;
+
+	for (; !IS_FREQ_TABLE_END(ftbl); ftbl++) {
+		if (ftbl->rate == rate)
+			return ftbl;
+
+		if (ftbl->rate > rate)
+			continue;
+
+		if (ftbl->rate > best_rate) {
+			best_rate = ftbl->rate;
+			best = ftbl;
+		}
+	}
+
+	return best;
+}
+
+const struct freq_table *
+ftbl_find_by_val_with_mask(const struct freq_table *ftbl, u32 mask, u32 value)
+{
+	for (; !IS_FREQ_TABLE_END(ftbl); ftbl++) {
+		if ((ftbl->val & mask) == (value & mask))
+			return ftbl;
+	}
+	return NULL;
+};
drivers/clk/realtek/freq_table.h new file +23 -0
new file mode 100644
index 000000000000..383ae939fd1e
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#include <linux/bitops.h>
+
+struct freq_table {
+	u32 val;
+	unsigned long rate;
+};
+
+/* ofs check */
+#define CLK_OFS_INVALID        -1
+#define CLK_OFS_IS_VALID(_ofs) ((_ofs) != CLK_OFS_INVALID)
+
+#define FREQ_TABLE_END    \
+	{                 \
+		.rate = 0 \
+	}
+#define IS_FREQ_TABLE_END(_f) ((_f)->rate == 0)
+
+const struct freq_table *ftbl_find_by_rate(const struct freq_table *ftbl,
+					   unsigned long rate);
+const struct freq_table *
+ftbl_find_by_val_with_mask(const struct freq_table *ftbl, u32 mask, u32 value);
Signature · 1 line
2.34.1
author maintainer
#14 lore raw

PATCH v4 6/10 clk: realtek: Add support for gate clock

In reply to Yu-Chun Lin

From: Cheng-Yu Lee <[email protected]>

Introduce clk_regmap_gate_ops supporting enable, disable, is_enabled, and disable_unused for standard regmap gate clocks.

Add clk_regmap_gate_ro_ops as a read-only variant exposing only is_enabled.

---
Changes in v4:
- None.

---
 drivers/clk/realtek/Makefile          |  2 +
 drivers/clk/realtek/clk-regmap-gate.c | 66 +++++++++++++++++++++++++++
 drivers/clk/realtek/clk-regmap-gate.h | 65 ++++++++++++++++++++++++++
 3 files changed, 133 insertions(+)
 create mode 100644 drivers/clk/realtek/clk-regmap-gate.c
 create mode 100644 drivers/clk/realtek/clk-regmap-gate.h
drivers/clk/realtek/Makefile +2 -0
index c173ea3b10e3..97058d48a176 100644
@@ -2,6 +2,8 @@
 obj-$(CONFIG_RTK_CLK_COMMON) += clk-rtk.o
 
 clk-rtk-y += common.o
+
 clk-rtk-y += clk-pll.o
+clk-rtk-y += clk-regmap-gate.o
 clk-rtk-y += freq_table.o
 clk-rtk-y += reset.o
drivers/clk/realtek/clk-regmap-gate.c new file +66 -0

66 lines not on this page · raw message

drivers/clk/realtek/clk-regmap-gate.h new file +65 -0

65 lines not on this page · raw message

Signature · 1 line
2.34.1
author maintainer
#15 lore raw

PATCH v4 7/10 clk: realtek: Add support for mux clock

In reply to Yu-Chun Lin

From: Cheng-Yu Lee <[email protected]>

Add a simple regmap-based clk_ops implementation for Realtek mux clocks.

The implementation supports parent selection and rate determination through regmap-backed register access.

---
Changes in v4:
- None.

---
 drivers/clk/realtek/Makefile         |  1 +
 drivers/clk/realtek/clk-regmap-mux.c | 46 ++++++++++++++++++++++++++++
 drivers/clk/realtek/clk-regmap-mux.h | 43 ++++++++++++++++++++++++++
 3 files changed, 90 insertions(+)
 create mode 100644 drivers/clk/realtek/clk-regmap-mux.c
 create mode 100644 drivers/clk/realtek/clk-regmap-mux.h
drivers/clk/realtek/Makefile +1 -0
index 97058d48a176..b40dd5a26653 100644
@@ -5,5 +5,6 @@ clk-rtk-y += common.o
 
 clk-rtk-y += clk-pll.o
 clk-rtk-y += clk-regmap-gate.o
+clk-rtk-y += clk-regmap-mux.o
 clk-rtk-y += freq_table.o
 clk-rtk-y += reset.o
drivers/clk/realtek/clk-regmap-mux.c new file +46 -0

46 lines not on this page · raw message

drivers/clk/realtek/clk-regmap-mux.h new file +43 -0

43 lines not on this page · raw message

Signature · 1 line
2.34.1
author maintainer
#16 lore raw

PATCH v4 8/10 clk: realtek: Add support for MMC-tuned PLL clocks

In reply to Yu-Chun Lin

From: Cheng-Yu Lee <[email protected]>

Add clk_pll_mmc_ops for enable/disable, prepare, rate control, and status operations on MMC PLL clocks.

Also add clk_pll_mmc_phase_ops to support phase get/set operations.

---
Changes in v4:
- None.

---
 MAINTAINERS                       |   8 +
 drivers/clk/realtek/Kconfig       |   3 +
 drivers/clk/realtek/Makefile      |   2 +
 drivers/clk/realtek/clk-pll-mmc.c | 399 ++++++++++++++++++++++++++++++
 drivers/clk/realtek/clk-pll.h     |  21 ++
 5 files changed, 433 insertions(+)
 create mode 100644 drivers/clk/realtek/clk-pll-mmc.c
MAINTAINERS +8 -0
index 53a2f3575c37..20616b7b1acb 100644
@@ -22250,6 +22250,14 @@ F:	Documentation/devicetree/bindings/clock/realtek*
 F:	drivers/clk/realtek/*
 F:	include/dt-bindings/clock/realtek*
 
+REALTEK SOC PLL CLOCK FOR MMC SUPPORT
+M:	Cheng-Yu Lee <[email protected]>
+M:	Jyan Chou <[email protected]>
+M:	Yu-Chun Lin <[email protected]>
+L:	[email protected]
+S:	Supported
+F:	drivers/clk/realtek/clk-pll-mmc.c
+
 REALTEK SPI-NAND
 M:	Chris Packham <[email protected]>
 S:	Maintained
drivers/clk/realtek/Kconfig +3 -0
index 121158f11dd1..de462c2bb892 100644
@@ -25,4 +25,7 @@ config RTK_CLK_COMMON
 	  multiple Realtek clock implementations, and include integration
 	  with reset controllers where required.
 
+config RTK_CLK_PLL_MMC
+	bool
+
 endif
drivers/clk/realtek/Makefile +2 -0
index b40dd5a26653..3d5c93e79dbd 100644
@@ -8,3 +8,5 @@ clk-rtk-y += clk-regmap-gate.o
 clk-rtk-y += clk-regmap-mux.o
 clk-rtk-y += freq_table.o
 clk-rtk-y += reset.o
+
+clk-rtk-$(CONFIG_RTK_CLK_PLL_MMC) += clk-pll-mmc.o
drivers/clk/realtek/clk-pll-mmc.c new file +399 -0

399 lines not on this page · raw message

drivers/clk/realtek/clk-pll.h +21 -0
index 2d27a44a270c..9cf219871218 100644
@@ -44,4 +44,25 @@ static inline struct clk_pll *to_clk_pll(struct clk_hw *hw)
 extern const struct clk_ops rtk_clk_pll_ops;
 extern const struct clk_ops rtk_clk_pll_ro_ops;
 
+struct clk_pll_mmc {
+	struct clk_regmap clkr;
+	int pll_ofs;
+	int ssc_dig_ofs;
+	struct clk_hw phase0_hw;
+	struct clk_hw phase1_hw;
+	u32 set_rate_val_53_97_set_ipc: 1;
+};
+
+#define __clk_pll_mmc_hw(_ptr)  __clk_regmap_hw(&(_ptr)->clkr)
+
+static inline struct clk_pll_mmc *to_clk_pll_mmc(struct clk_hw *hw)
+{
+	struct clk_regmap *clkr = to_clk_regmap(hw);
+
+	return container_of(clkr, struct clk_pll_mmc, clkr);
+}
+
+extern const struct clk_ops rtk_clk_pll_mmc_ops;
+extern const struct clk_ops rtk_clk_pll_mmc_phase_ops;
+
 #endif /* __CLK_REALTEK_CLK_PLL_H */
Signature · 1 line
2.34.1
author maintainer
#17 lore raw

PATCH v4 9/10 clk: realtek: Add RTD1625-CRT clock controller driver

In reply to Yu-Chun Lin

From: Cheng-Yu Lee <[email protected]>

Add support for the CRT (Clock, Reset, and Test) controller on the Realtek RTD1625 SoC. This driver provides clock and reset management for the system, allowing peripheral clients to request necessary resources for operation.

---
Changes in v4:
- None.

---
 drivers/clk/realtek/Kconfig           |  14 +
 drivers/clk/realtek/Makefile          |   1 +
 drivers/clk/realtek/clk-rtd1625-crt.c | 788 ++++++++++++++++++++++++++
 3 files changed, 803 insertions(+)
 create mode 100644 drivers/clk/realtek/clk-rtd1625-crt.c
drivers/clk/realtek/Kconfig +14 -0
index de462c2bb892..34a7607a9e7e 100644
@@ -28,4 +28,18 @@ config RTK_CLK_COMMON
 config RTK_CLK_PLL_MMC
 	bool
 
+config COMMON_CLK_RTD1625
+	tristate "RTD1625 Clock Controller"
+	select RTK_CLK_COMMON
+	select RTK_CLK_PLL_MMC
+	default y
+	help
+	  Support for the clock controller on Realtek RTD1625 SoCs.
+
+	  This driver provides clock sources, gating, multiplexing, and
+	  reset control for peripherals on the RTD1625 platform.
+
+	  Say Y here if your system is based on the RTD1625 and you need
+	  its peripheral devices to function.
+
 endif
drivers/clk/realtek/Makefile +1 -0
index 3d5c93e79dbd..3cda1e600172 100644
@@ -10,3 +10,4 @@ clk-rtk-y += freq_table.o
 clk-rtk-y += reset.o
 
 clk-rtk-$(CONFIG_RTK_CLK_PLL_MMC) += clk-pll-mmc.o
+obj-$(CONFIG_COMMON_CLK_RTD1625) += clk-rtd1625-crt.o
drivers/clk/realtek/clk-rtd1625-crt.c new file +788 -0

788 lines not on this page · raw message

Signature · 1 line
2.34.1
author maintainer
#18 lore raw

PATCH v4 10/10 clk: realtek: Add RTD1625-ISO clock controller driver

In reply to Yu-Chun Lin

From: Cheng-Yu Lee <[email protected]>

Add support for the ISO (Isolation) domain clock controller on the Realtek RTD1625 SoC. This controller manages clocks in the always-on power domain, ensuring essential services remain functional even when the main system power is gated.

---
Changes in v4:
- Modfiy the offsets.

---
 drivers/clk/realtek/Makefile          |   1 +
 drivers/clk/realtek/clk-rtd1625-iso.c | 153 ++++++++++++++++++++++++++
 2 files changed, 154 insertions(+)
 create mode 100644 drivers/clk/realtek/clk-rtd1625-iso.c
drivers/clk/realtek/Makefile +1 -0
index 3cda1e600172..e90fce42a85e 100644
@@ -11,3 +11,4 @@ clk-rtk-y += reset.o
 
 clk-rtk-$(CONFIG_RTK_CLK_PLL_MMC) += clk-pll-mmc.o
 obj-$(CONFIG_COMMON_CLK_RTD1625) += clk-rtd1625-crt.o
+obj-$(CONFIG_COMMON_CLK_RTD1625) += clk-rtd1625-iso.o
drivers/clk/realtek/clk-rtd1625-iso.c new file +153 -0

153 lines not on this page · raw message

Signature · 1 line
2.34.1