Skip to contentSkip to conversation

clk: realtek: Add RTD1625 Clock Support

PATCH Superseded Yu-Chun Lin 4 participants 14 messages Jan 13 – Jan 14

Subsystems (2)

v2 of 17 Superseded Latest is v17 →

lore
Share & tools
lore
#0 lore raw

v2 cover clk: realtek: Add RTD1625 Clock Support

Hello,

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

The series includes:

1. Infrastructure: reset controller, basic clocks, PLLs, gate clocks, mux clocks, and MMC-tuned PLLs.

2. Platform drivers: two clock controller drivers for RTD1625-CRT and RTD1625-ISO.

I welcome feedback and suggestions.

Best regards,
Yu-Chun Lin
---
Changes in v2:
- General: Added missing Co-developed-by tags.
- Patch 1:
- Shortened binding description.
- Updated MAINTAINERS entry (BINDINGS -> DRIVERS).
- Moved software variables from header to driver.
- Patch 2:
- Added missing maintainer entry for driver/clk.
- Removed explicit of_xlate/of_reset_n_cells assignment as it matches defaults.
- Added error handling for rtk_reset_read() return value
- Patch 3:
- Fixed coding style issues.
- Switched to using dev_err_probe() return value.
- Fixed format specifier (%zu instead of %lu) reported by kernel test robot.
- Patch 4:
- Fixed clk_pll_determine_rate() to properly update req->rate.
- Patch 5:
- Added error handling for regmap_update_bits.
- Removed .disable_unused callback in gate ops. The CCF handles the fallback to .disable automatically if .disable_unused is not present.
- Patch 6:
- Fixed return value signedness issue in clk_regmap_mux_get_parent (reported by smatch/Dan Carpenter).
- Patch 7
- Replaced eval_ssc_div_n() function with a macro.
- Removed clk_pll_mmc_disable_unused() and clk_pll_mmc_unprepare_unused() callbacks to rely on CCF default behavior and avoid unnecessary function calls.
- Fixed clk_pll_mmc_determine_rate() to properly write the calculated rate into

    req->rate.

- Patch 8:
- Fixed Kconfig indentation.
- Removed excessive CLK_IGNORE_UNUSED flags

Yu-Chun Lin (9):
dt-bindings: clock: Add Realtek RTD1625 Clock & Reset Controller
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   |  51 ++
 MAINTAINERS                                   |  18 +
 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             | 398 +++++++++
 drivers/clk/realtek/clk-pll.c                 | 193 +++++
 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         | 790 ++++++++++++++++++
 drivers/clk/realtek/clk-rtd1625-iso.c         | 153 ++++
 drivers/clk/realtek/common.c                  |  68 ++
 drivers/clk/realtek/common.h                  |  40 +
 drivers/clk/realtek/freq_table.c              |  35 +
 drivers/clk/realtek/freq_table.h              |  23 +
 drivers/clk/realtek/reset.c                   | 125 +++
 drivers/clk/realtek/reset.h                   |  36 +
 .../dt-bindings/clock/realtek,rtd1625-clk.h   | 164 ++++
 22 files changed, 2443 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
Signature · 1 line
2.34.1
#1 lore raw

PATCH v2 1/9 dt-bindings: clock: Add Realtek RTD1625 Clock & Reset Controller

Add DT binding schema for Realtek RTD1625 clock and reset controller

---
Changes in v2:
- Added missing Co-developed-by tag.
- Shortened binding description.
- Updated MAINTAINERS entry (BINDINGS -> DRIVERS).
- Moved software variables to driver.

---
 .../bindings/clock/realtek,rtd1625-clk.yaml   |  51 ++++++
 MAINTAINERS                                   |   9 +
 .../dt-bindings/clock/realtek,rtd1625-clk.h   | 164 ++++++++++++++++++
 3 files changed, 224 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/realtek,rtd1625-clk.yaml
 create mode 100644 include/dt-bindings/clock/realtek,rtd1625-clk.h
Documentation/devicetree/bindings/clock/realtek,rtd1625-clk.yaml new file +51 -0
new file mode 100644
index 000000000000..26ec7d68b991
@@ -0,0 +1,51 @@
+# 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 are referenced by unique identifiers, which are defined as
+  preprocessor macros in dt-bindings/clock/realtek,rtd1625-clk.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 12f49de7fe03..66c0f4924c1e 100644
@@ -21968,6 +21968,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

Signature · 1 line
2.34.1
Reviewed-by on v2 1/9
#2 lore raw

Re: [PATCH v2 1/9] dt-bindings: clock: Add Realtek RTD1625 Clock & Reset Controller

Quoted 33 lines · Yu-Chun Lin

Add DT binding schema for Realtek RTD1625 clock and reset controller

---
Changes in v2:
- Added missing Co-developed-by tag.
- Shortened binding description.
- Updated MAINTAINERS entry (BINDINGS -> DRIVERS).
- Moved software variables to driver.

---
 .../bindings/clock/realtek,rtd1625-clk.yaml   |  51 ++++++
 MAINTAINERS                                   |   9 +
 .../dt-bindings/clock/realtek,rtd1625-clk.h   | 164 ++++++++++++++++++
 3 files changed, 224 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/realtek,rtd1625-clk.yaml
 create mode 100644 include/dt-bindings/clock/realtek,rtd1625-clk.h
Documentation/devicetree/bindings/clock/realtek,rtd1625-clk.yaml new file +8 -0
new file mode 100644
index 000000000000..26ec7d68b991
@@ -0,0 +1,51 @@
+# 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
+

Documentation/devicetree/bindings/clock/realtek,rtd1625-clk.yaml line 18

Quoted 10 lines
Documentation/devicetree/bindings/clock/realtek,rtd1625-clk.yaml new file +10 -0
+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 are referenced by unique identifiers, which are defined as
+  preprocessor macros in dt-bindings/clock/realtek,rtd1625-clk.h.

Full path needed.

Quoted 38 lines
Documentation/devicetree/bindings/clock/realtek,rtd1625-clk.yaml new file +33 -0
+
+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 +0 -0
index 12f49de7fe03..66c0f4924c1e 100644

MAINTAINERS S: Maintained · line 21972

Quoted 5 lines
MAINTAINERS +2 -0
@@ -21968,6 +21968,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]>

Just to clarify, because sometimes people add here authors not actual maintainers, this is a list of active maintainers, so reviewing in the future will be from both of you.

Best regards,
Krzysztof

#3 lore raw

PATCH v2 2/9 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 v2:
- Added missing Co-developed-by tag.
- Added missing maintainer entry for driver/clk.
- Removed explicit of_xlate/of_reset_n_cells assignment as it matches defaults.
- Added error handling for rtk_reset_read() return value

---
 MAINTAINERS                  |   1 +
 drivers/clk/Kconfig          |   1 +
 drivers/clk/Makefile         |   1 +
 drivers/clk/realtek/Kconfig  |  28 ++++++++
 drivers/clk/realtek/Makefile |   4 ++
 drivers/clk/realtek/reset.c  | 125 +++++++++++++++++++++++++++++++++++
 drivers/clk/realtek/reset.h  |  36 ++++++++++
 7 files changed, 196 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 66c0f4924c1e..de772e0026de 100644
@@ -21975,6 +21975,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 3a1611008e48..2f2cacf87c38 100644
@@ -530,6 +530,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 61ec08404442..075a1c410b90 100644
@@ -141,6 +141,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 +28 -0
new file mode 100644
index 000000000000..121158f11dd1
@@ -0,0 +1,28 @@
+# SPDX-License-Identifier: GPL-2.0-only
+config COMMON_CLK_REALTEK
+	bool "Clock driver for Realtek SoCs"
+	depends on ARCH_REALTEK || COMPILE_TEST
+	select MFD_SYSCON
+	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 +125 -0

125 lines not on this page · raw message

drivers/clk/realtek/reset.h new file +36 -0
new file mode 100644
index 000000000000..cd446b098429
@@ -0,0 +1,36 @@
+/* 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/regmap.h>
+#include <linux/reset-controller.h>
+#include <linux/hwspinlock.h>
+
+struct rtk_reset_bank {
+	u32 ofs;
+	u32 write_en;
+};
+
+struct rtk_reset_data {
+	struct device *dev;
+	struct reset_controller_dev rcdev;
+	struct rtk_reset_bank *banks;
+	u32 num_banks;
+	struct regmap *regmap;
+};
+
+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
#4 lore raw

Re: [PATCH v2 2/9] clk: realtek: Add basic reset support

Quoted 116 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 v2:
- Added missing Co-developed-by tag.
- Added missing maintainer entry for driver/clk.
- Removed explicit of_xlate/of_reset_n_cells assignment as it matches defaults.
- Added error handling for rtk_reset_read() return value

---
 MAINTAINERS                  |   1 +
 drivers/clk/Kconfig          |   1 +
 drivers/clk/Makefile         |   1 +
 drivers/clk/realtek/Kconfig  |  28 ++++++++
 drivers/clk/realtek/Makefile |   4 ++
 drivers/clk/realtek/reset.c  | 125 +++++++++++++++++++++++++++++++++++
 drivers/clk/realtek/reset.h  |  36 ++++++++++
 7 files changed, 196 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 66c0f4924c1e..de772e0026de 100644
@@ -21975,6 +21975,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 3a1611008e48..2f2cacf87c38 100644
@@ -530,6 +530,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 61ec08404442..075a1c410b90 100644
@@ -141,6 +141,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 +28 -0
new file mode 100644
index 000000000000..121158f11dd1
@@ -0,0 +1,28 @@
+# SPDX-License-Identifier: GPL-2.0-only
+config COMMON_CLK_REALTEK
+	bool "Clock driver for Realtek SoCs"
+	depends on ARCH_REALTEK || COMPILE_TEST
+	select MFD_SYSCON
+	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 +1 -0
new file mode 100644
index 000000000000..0ba0d46811d4
@@ -0,0 +1,125 @@
+// SPDX-License-Identifier: GPL-2.0-only

drivers/clk/realtek/reset.c line 11

Quoted 10 lines
drivers/clk/realtek/reset.c new file +10 -0
+/*
+ * Copyright (C) 2019 Realtek Semiconductor Corporation
+ */
+
+#include <linux/of.h>
+#include <linux/device.h>
+#include "reset.h"
+
+#define RTK_RESET_BANK_SHIFT         8
+#define RTK_RESET_ID_MASK            0xff

Why are there 256 possible ids per bank? Each bank is only a 32-bit register, containing 32 (or in the case of write_en) 16 reset controls.

drivers/clk/realtek/reset.c line 12

Quoted 1 line
drivers/clk/realtek/reset.c new file +1 -0
+#define to_rtk_reset_controller(r) container_of(r, struct rtk_reset_data, rcdev)

Please make this an inline function.

Quoted 20 lines
drivers/clk/realtek/reset.c new file +20 -0
+static inline struct rtk_reset_bank *
+rtk_reset_get_bank(struct rtk_reset_data *data, unsigned long idx)
+{
+	int bank_id = idx >> RTK_RESET_BANK_SHIFT;
+
+	return &data->banks[bank_id];
+}
+
+static inline int rtk_reset_get_id(struct rtk_reset_data *data,
+				   unsigned long idx)
+{
+	return idx & RTK_RESET_ID_MASK;
+}
+
+static int rtk_reset_update_bits(struct rtk_reset_data *data, u32 offset,
+				 u32 mask, u32 val)
+{
+	int ret;
+
+	ret = regmap_update_bits(data->regmap, offset, mask, val);

drivers/clk/realtek/reset.c line 43

Quoted 10 lines
drivers/clk/realtek/reset.c new file +10 -0
+	return ret;
+}
+
+static int rtk_reset_read(struct rtk_reset_data *data, u32 offset, u32 *val)
+{
+	int ret;
+
+	ret = regmap_read(data->regmap, offset, val);
+	return ret;
+}

The local variable ret is superfluous. And why not use regmap_read/update_bits() directly below?

drivers/clk/realtek/reset.c line 52

Quoted 9 lines
drivers/clk/realtek/reset.c new file +9 -0
+
+static int rtk_reset_assert(struct reset_controller_dev *rcdev,
+			    unsigned long idx)
+{
+	struct rtk_reset_data *data = to_rtk_reset_controller(rcdev);
+	struct rtk_reset_bank *bank = rtk_reset_get_bank(data, idx);
+	u32 id = rtk_reset_get_id(data, idx);
+	u32 mask = bank->write_en ? (0x3 << id) : BIT(id);
+	u32 val = bank->write_en ? (0x2 << id) : 0;

I'd use UL(0x3) / UL(0x2) to avoid UB when compiling for 32-bit.

Only even ids are allowed for banks with write_en set?

Quoted 58 lines
drivers/clk/realtek/reset.c new file +58 -0
+
+	return rtk_reset_update_bits(data, bank->ofs, mask, val);
+}
+
+static int rtk_reset_deassert(struct reset_controller_dev *rcdev,
+			      unsigned long idx)
+{
+	struct rtk_reset_data *data = to_rtk_reset_controller(rcdev);
+	struct rtk_reset_bank *bank = rtk_reset_get_bank(data, idx);
+	u32 id = rtk_reset_get_id(data, idx);
+	u32 mask = bank->write_en ? (0x3 << id) : BIT(id);
+	u32 val = mask;
+
+	return rtk_reset_update_bits(data, bank->ofs, mask, val);
+}
+
+static int rtk_reset_reset(struct reset_controller_dev *rcdev,
+			   unsigned long idx)
+{
+	int ret;
+
+	ret = rtk_reset_assert(rcdev, idx);
+	if (ret)
+		return ret;
+	return rtk_reset_deassert(rcdev, idx);
+}
+
+static int rtk_reset_status(struct reset_controller_dev *rcdev,
+			    unsigned long idx)
+{
+	struct rtk_reset_data *data = to_rtk_reset_controller(rcdev);
+	struct rtk_reset_bank *bank = &data->banks[idx >> RTK_RESET_BANK_SHIFT];
+	u32 id = idx & RTK_RESET_ID_MASK;
+	u32 val;
+	int ret;
+
+	ret = rtk_reset_read(data, bank->ofs, &val);
+	if (ret)
+		return ret;
+
+	return !((val >> id) & 1);
+}
+
+static const struct reset_control_ops rtk_reset_ops = {
+	.reset    = rtk_reset_reset,
+	.assert   = rtk_reset_assert,
+	.deassert = rtk_reset_deassert,
+	.status   = rtk_reset_status,
+};
+
+int rtk_reset_controller_add(struct device *dev,
+			     struct rtk_reset_initdata *initdata)
+{
+	struct rtk_reset_data *data;
+
+	data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
+	if (!data)
+		return -ENOMEM;

drivers/clk/realtek/reset.c line 120

Quoted 10 lines
drivers/clk/realtek/reset.c new file +10 -0
+
+	data->dev = dev;
+	data->num_banks = initdata->num_banks;
+	data->banks = initdata->banks;
+	data->regmap = initdata->regmap;
+	data->rcdev.owner = THIS_MODULE;
+	data->rcdev.ops = &rtk_reset_ops;
+	data->rcdev.dev = dev;
+	data->rcdev.of_node = dev->of_node;
+	data->rcdev.nr_resets = initdata->num_banks * 0x100;

This is misleading. Surely there's not num_banks * 256 resets, since each bank can only carry 16 or 32 resets. It'd probably better to not use nr_resets at all and implement your own of_xlate.

regards
Philipp

#5 lore raw

RE: [PATCH v2 2/9] clk: realtek: Add basic reset support

Hi, Philipp,
Thanks for your review!

Quoted 121 lines · Yu-Chun Lin
Quoted 6 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.

Quoted 8 lines

---
Changes in v2:
- Added missing Co-developed-by tag.
- Added missing maintainer entry for driver/clk.
- Removed explicit of_xlate/of_reset_n_cells assignment as it matches

defaults.

drivers/clk/Makefile obj-$(CONFIG_COMMON_CLK_PISTACHIO)

Quoted 45 lines

- Added error handling for rtk_reset_read() return value

---
 MAINTAINERS                  |   1 +
 drivers/clk/Kconfig          |   1 +
 drivers/clk/Makefile         |   1 +
 drivers/clk/realtek/Kconfig  |  28 ++++++++
 drivers/clk/realtek/Makefile |   4 ++
 drivers/clk/realtek/reset.c  | 125
+++++++++++++++++++++++++++++++++++
 drivers/clk/realtek/reset.h  |  36 ++++++++++
 7 files changed, 196 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

66c0f4924c1e..de772e0026de 100644

MAINTAINERS +1 -0
@@ -21975,6 +21975,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

3a1611008e48..2f2cacf87c38 100644

drivers/clk/Kconfig +1 -0
@@ -530,6 +530,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

61ec08404442..075a1c410b90 100644

drivers/clk/Makefile +0 -0
@@ -141,6 +141,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 52 lines
drivers/clk/realtek/Kconfig new file +27 -0
new file mode 100644 index 000000000000..121158f11dd1
@@ -0,0 +1,28 @@
+# SPDX-License-Identifier: GPL-2.0-only config COMMON_CLK_REALTEK
+     bool "Clock driver for Realtek SoCs"
+     depends on ARCH_REALTEK || COMPILE_TEST
+     select MFD_SYSCON
+     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
(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 +5 -0
new file mode 100644 index 000000000000..0ba0d46811d4
@@ -0,0 +1,125 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (C) 2019 Realtek Semiconductor Corporation  */
+
+#include <linux/of.h>
Quoted 9 lines

drivers/clk/realtek/reset.c line 11

Quoted 5 lines
drivers/clk/realtek/reset.c new file +5 -0
+#include <linux/device.h>
+#include "reset.h"
+
+#define RTK_RESET_BANK_SHIFT         8
+#define RTK_RESET_ID_MASK            0xff

Why are there 256 possible ids per bank? Each bank is only a 32-bit register, containing 32 (or in the case of write_en) 16 reset controls.

You are right. Using 256 IDs per bank creates a sparse ID map with unnecessary holes. We plan to change the stride to 32 (<< 5). With this change, nr_resets will simply be num_banks * 32.

Quoted 5 lines

drivers/clk/realtek/reset.c line 12

Quoted 2 lines
drivers/clk/realtek/reset.c new file +2 -0
+#define to_rtk_reset_controller(r) container_of(r, struct
+rtk_reset_data, rcdev)

Please make this an inline function.

I will fix it in v3.

Quoted 22 lines
Quoted 22 lines
drivers/clk/realtek/reset.c new file +22 -0
+static inline struct rtk_reset_bank * rtk_reset_get_bank(struct
+rtk_reset_data *data, unsigned long idx) {
+     int bank_id = idx >> RTK_RESET_BANK_SHIFT;
+
+     return &data->banks[bank_id];
+}
+
+static inline int rtk_reset_get_id(struct rtk_reset_data *data,
+                                unsigned long idx) {
+     return idx & RTK_RESET_ID_MASK;
+}
+
+static int rtk_reset_update_bits(struct rtk_reset_data *data, u32 offset,
+                              u32 mask, u32 val) {
+     int ret;
+
+     ret = regmap_update_bits(data->regmap, offset, mask, val);
+     return ret;
+}
+
+static int rtk_reset_read(struct rtk_reset_data *data, u32 offset,
+u32 *val) {
Quoted 9 lines

drivers/clk/realtek/reset.c line 43

Quoted 5 lines
drivers/clk/realtek/reset.c new file +5 -0
+     int ret;
+
+     ret = regmap_read(data->regmap, offset, val);
+     return ret;
+}

The local variable ret is superfluous. And why not use regmap_read/update_bits() directly below?

I will drop the function.

Quoted 11 lines

drivers/clk/realtek/reset.c line 52

Quoted 8 lines
drivers/clk/realtek/reset.c new file +8 -0
+
+static int rtk_reset_assert(struct reset_controller_dev *rcdev,
+                         unsigned long idx) {
+     struct rtk_reset_data *data = to_rtk_reset_controller(rcdev);
+     struct rtk_reset_bank *bank = rtk_reset_get_bank(data, idx);
+     u32 id = rtk_reset_get_id(data, idx);
+     u32 mask = bank->write_en ? (0x3 << id) : BIT(id);
+     u32 val = bank->write_en ? (0x2 << id) : 0;

I'd use UL(0x3) / UL(0x2) to avoid UB when compiling for 32-bit.

I will apply UL() as suggested.

Quoted 2 lines

Only even ids are allowed for banks with write_en set?

Yes, for banks with write_en, the hardware layout uses 2 bits per control (Bit N for reset, Bit N+1 for enable).

Quoted 68 lines
Quoted 16 lines
drivers/clk/realtek/reset.c new file +16 -0
+
+     return rtk_reset_update_bits(data, bank->ofs, mask, val); }
+
+static int rtk_reset_deassert(struct reset_controller_dev *rcdev,
+                           unsigned long idx) {
+     struct rtk_reset_data *data = to_rtk_reset_controller(rcdev);
+     struct rtk_reset_bank *bank = rtk_reset_get_bank(data, idx);
+     u32 id = rtk_reset_get_id(data, idx);
+     u32 mask = bank->write_en ? (0x3 << id) : BIT(id);
+     u32 val = mask;
+
+     return rtk_reset_update_bits(data, bank->ofs, mask, val); }
+
+static int rtk_reset_reset(struct reset_controller_dev *rcdev,
+                        unsigned long idx) {
+     int ret;

drivers/clk/realtek/reset.c

Quoted 10 lines
drivers/clk/realtek/reset.c new file +10 -0
+
+     ret = rtk_reset_assert(rcdev, idx);
+     if (ret)
+             return ret;
+     return rtk_reset_deassert(rcdev, idx); }
+
+static int rtk_reset_status(struct reset_controller_dev *rcdev,
+                         unsigned long idx) {
+     struct rtk_reset_data *data = to_rtk_reset_controller(rcdev);
+     struct rtk_reset_bank *bank = &data->banks[idx >>

RTK_RESET_BANK_SHIFT];

Quoted 25 lines
drivers/clk/realtek/reset.c new file +25 -0
+     u32 id = idx & RTK_RESET_ID_MASK;
+     u32 val;
+     int ret;
+
+     ret = rtk_reset_read(data, bank->ofs, &val);
+     if (ret)
+             return ret;
+
+     return !((val >> id) & 1);
+}
+
+static const struct reset_control_ops rtk_reset_ops = {
+     .reset    = rtk_reset_reset,
+     .assert   = rtk_reset_assert,
+     .deassert = rtk_reset_deassert,
+     .status   = rtk_reset_status,
+};
+
+int rtk_reset_controller_add(struct device *dev,
+                          struct rtk_reset_initdata *initdata) {
+     struct rtk_reset_data *data;
+
+     data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
+     if (!data)
+             return -ENOMEM;

drivers/clk/realtek/reset.c line 120

Quoted 10 lines
drivers/clk/realtek/reset.c new file +10 -0
+
+     data->dev = dev;
+     data->num_banks = initdata->num_banks;
+     data->banks = initdata->banks;
+     data->regmap = initdata->regmap;
+     data->rcdev.owner = THIS_MODULE;
+     data->rcdev.ops = &rtk_reset_ops;
+     data->rcdev.dev = dev;
+     data->rcdev.of_node = dev->of_node;
+     data->rcdev.nr_resets = initdata->num_banks * 0x100;

This is misleading. Surely there's not num_banks * 256 resets, since each bank can only carry 16 or 32 resets. It'd probably better to not use nr_resets at all and implement your own of_xlate.

Quoted 2 lines

regards
Philipp

As mentioned above, by changing the shift to 5, nr_resets becomes num_banks * 32. Since the mapping becomes linear, We believe of_reset_simple_xlate is still suitable.

Best Regards,
Yu-Chun

#6 lore raw

PATCH v2 3/9 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 v2:
- Added missing Co-developed-by tag.
- Fixed coding style issues.
- Switched to using dev_err_probe() return value.
- Fixed format specifier (%zu instead of %lu)

---
 drivers/clk/realtek/Makefile |  1 +
 drivers/clk/realtek/common.c | 68 ++++++++++++++++++++++++++++++++++++
 drivers/clk/realtek/common.h | 40 +++++++++++++++++++++
 3 files changed, 109 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 +68 -0

68 lines not on this page · raw message

drivers/clk/realtek/common.h new file +40 -0
new file mode 100644
index 000000000000..7b700f144e9e
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (C) 2016-2019 Realtek Semiconductor Corporation
+ * Author: Cheng-Yu Lee <[email protected]>
+ */
+
+#ifndef __CLK_REALTEK_COMMON_H
+#define __CLK_REALTEK_COMMON_H
+
+#include <linux/clk-provider.h>
+#include <linux/device.h>
+#include <linux/hwspinlock.h>
+#include <linux/io.h>
+#include <linux/of.h>
+#include <linux/regmap.h>
+#include "reset.h"
+
+struct device;
+struct platform_device;
+
+struct clk_regmap {
+	struct clk_hw hw;
+	struct regmap *regmap;
+};
+
+#define to_clk_regmap(_hw) container_of(_hw, struct clk_regmap, hw)
+#define __clk_regmap_hw(_p) ((_p)->hw)
+
+struct rtk_clk_desc {
+	struct clk_hw_onecell_data *clk_data;
+	struct clk_regmap **clks;
+	size_t num_clks;
+	struct rtk_reset_bank *reset_banks;
+	size_t num_reset_banks;
+};
+
+int rtk_clk_probe(struct platform_device *pdev,
+		  const struct rtk_clk_desc *desc);
+
+#endif /* __CLK_REALTEK_COMMON_H */
Signature · 1 line
2.34.1
#7 lore raw

PATCH v2 4/9 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 v2:
- Added missing Co-developed-by tag.
- Fixed clk_pll_determine_rate() to properly update req->rate.
- Removed the redundant .disable_unused callback.

---
 drivers/clk/realtek/Makefile     |   2 +
 drivers/clk/realtek/clk-pll.c    | 189 +++++++++++++++++++++++++++++++
 drivers/clk/realtek/clk-pll.h    |  47 ++++++++
 drivers/clk/realtek/freq_table.c |  35 ++++++
 drivers/clk/realtek/freq_table.h |  23 ++++
 5 files changed, 296 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 +189 -0

189 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..66a0b0610e38
@@ -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
#8 lore raw

PATCH v2 5/9 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 v2:
- Added missing Co-developed-by tag.
- Added error handling for regmap_update_bits.
- Removed .disable_unused callback in gate ops. The CCF handles the fallback to .disable automatically if .disable_unused is not present.

---
 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
#9 lore raw

Re: [PATCH v2 5/9] clk: realtek: Add support for gate clock

kernel test robot noticed the following build errors:

Hi Yu-Chun,

kernel test robot noticed the following build errors:

[auto build test ERROR on clk/clk-next]
[also build test ERROR on linus/master v6.19-rc5 next-20260113] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Yu-Chun-Lin/dt-bindings-clock-Add-Realtek-RTD1625-Clock-Reset-Controller/20260113-192709
base:   https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next
patch link:    https://lore.kernel.org/r/20260113112333.821-6-eleanor.lin%40realtek.com
patch subject: [PATCH v2 5/9] clk: realtek: Add support for gate clock
config: arm64-randconfig-002-20260114 (https://download.01.org/0day-ci/archive/20260114/[email protected]/config)
compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 9b8addffa70cee5b2acc5454712d9cf78ce45710)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260114/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

>> ld.lld: error: duplicate symbol: clk_regmap_gate_ops
   >>> defined at clk-regmap.c
   >>>            drivers/clk/meson/clk-regmap.o:(clk_regmap_gate_ops) in archive vmlinux.a
   >>> defined at clk-regmap-gate.c
   >>>            drivers/clk/realtek/clk-regmap-gate.o:(.rodata+0x0) in archive vmlinux.a
--
>> ld.lld: error: duplicate symbol: clk_regmap_gate_ro_ops
   >>> defined at clk-regmap.c
   >>>            drivers/clk/meson/clk-regmap.o:(clk_regmap_gate_ro_ops) in archive vmlinux.a
   >>> defined at clk-regmap-gate.c
   >>>            drivers/clk/realtek/clk-regmap-gate.o:(.rodata+0xc8) in archive vmlinux.a
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#10 lore raw

PATCH v2 6/9 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 v2:
- Added missing Co-developed-by tag.
- Fixed return value signedness issue in clk_regmap_mux_get_parent.

---
 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
#11 lore raw

PATCH v2 7/9 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 v2:
- Added missing Co-developed-by tag.
- Replaced eval_ssc_div_n() function with a macro PLL_MMC_SSC_DIV_N_VAL.
- Removed clk_pll_mmc_disable_unused() and clk_pll_mmc_unprepare_unused() callbacks to rely on CCF default behavior and avoid unnecessary function calls.
- Fixed clk_pll_mmc_determine_rate() to properly write the calculated rate into req->rate.

---
 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 de772e0026de..5b8c0d9eebaa 100644
@@ -21978,6 +21978,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 c3e2e5ca641f..90c47279410b 100644
@@ -44,4 +44,25 @@ static inline struct clk_pll *to_clk_pll(struct clk_hw *hw)
 extern const struct clk_ops clk_pll_ops;
 extern const struct clk_ops 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 clk_pll_mmc_ops;
+extern const struct clk_ops clk_pll_mmc_phase_ops;
+
 #endif /* __CLK_REALTEK_CLK_PLL_H */
Signature · 1 line
2.34.1
#12 lore raw

PATCH v2 8/9 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 v2:
- Added missing Co-developed-by tag.
- Fixed Kconfig indentation.
- Removed excessive CLK_IGNORE_UNUSED flags

---
 drivers/clk/realtek/Kconfig           |  14 +
 drivers/clk/realtek/Makefile          |   1 +
 drivers/clk/realtek/clk-rtd1625-crt.c | 786 ++++++++++++++++++++++++++
 3 files changed, 801 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 +786 -0

786 lines not on this page · raw message

Signature · 1 line
2.34.1
#13 lore raw

PATCH v2 9/9 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 v2:
- Added missing Co-developed-by tag.

---
 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