Skip to contentSkip to conversation

Devicetree support for Loongson-1 clock

PATCH In review Keguang Zhang 2 participants 5 messages Feb 9, 2023 – Feb 10, 2023

Subsystems (4)
lore
Share & tools
lore

Keguang Zhang

author maintainer
#0 lore raw

v2 cover Devicetree support for Loongson-1 clock

Removes the old Loongson-1 clock driver mainly because of no DT support and outdated implementation.
Then, re-implement it to solve the above issues, along with the devicetree binding document.

Keguang Zhang (3):
dt-bindings: clock: Add Loongson-1 clock
clk: loongson1: Remove the outdated driver
clk: loongson1: Re-implement the clock driver

 .../bindings/clock/loongson,ls1x-clk.yaml     |  49 +++
 drivers/clk/Makefile                          |   2 +-
 drivers/clk/clk-loongson1.c                   | 298 ++++++++++++++++++
 drivers/clk/loongson1/Makefile                |   4 -
 drivers/clk/loongson1/clk-loongson1b.c        | 118 -------
 drivers/clk/loongson1/clk-loongson1c.c        |  95 ------
 drivers/clk/loongson1/clk.c                   |  41 ---
 drivers/clk/loongson1/clk.h                   |  15 -
 include/dt-bindings/clock/loongson,ls1x-clk.h |  19 ++
 9 files changed, 367 insertions(+), 274 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/clock/loongson,ls1x-clk.yaml
 create mode 100644 drivers/clk/clk-loongson1.c
 delete mode 100644 drivers/clk/loongson1/Makefile
 delete mode 100644 drivers/clk/loongson1/clk-loongson1b.c
 delete mode 100644 drivers/clk/loongson1/clk-loongson1c.c
 delete mode 100644 drivers/clk/loongson1/clk.c
 delete mode 100644 drivers/clk/loongson1/clk.h
 create mode 100644 include/dt-bindings/clock/loongson,ls1x-clk.h

base-commit: 623880b500338017e010d76f31a41f0c0fe5c8ab

Signature · 1 line
2.34.1
author maintainer
#1 lore raw

PATCH v2 1/3 dt-bindings: clock: Add Loongson-1 clock

Add devicetree binding document and related header file for the Loongson-1 clock.

---
V1 -> V2: Change to one clock controller
Add clock-related dt-binding header file Fix the warning of dt_binding_check

---
 .../bindings/clock/loongson,ls1x-clk.yaml     | 49 +++++++++++++++++++
 include/dt-bindings/clock/loongson,ls1x-clk.h | 19 +++++++
 2 files changed, 68 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/loongson,ls1x-clk.yaml
 create mode 100644 include/dt-bindings/clock/loongson,ls1x-clk.h
Documentation/devicetree/bindings/clock/loongson,ls1x-clk.yaml new file +49 -0
new file mode 100644
index 000000000000..a911762dd01a
@@ -0,0 +1,49 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/clock/loongson,ls1x-clk.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Loongson-1 Clock Controller
+
+maintainers:
+  - Keguang Zhang <[email protected]>
+
+properties:
+  compatible:
+    enum:
+      - loongson,ls1b-clk
+      - loongson,ls1c-clk
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+  clock-names:
+    items:
+      - const: xtal
+
+  "#clock-cells":
+    const: 1
+
+required:
+  - "#clock-cells"
+  - compatible
+  - clocks
+
+additionalProperties: false
+
+examples:
+  - |
+    clkc: clock-controller@1fe78030 {
+        compatible = "loongson,ls1b-clk";
+        reg = <0x1fe78030 0x8>;
+
+        clocks = <&xtal>;
+        clock-names = "xtal";
+        #clock-cells = <1>;
+    };
+
+...
include/dt-bindings/clock/loongson,ls1x-clk.h new file +19 -0
new file mode 100644
index 000000000000..579552c5f14b
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Loongson-1 clock tree IDs
+ *
+ * Copyright (C) 2023 Keguang Zhang <[email protected]>
+ */
+
+#ifndef __DT_BINDINGS_CLOCK_LS1X_CLK_H__
+#define __DT_BINDINGS_CLOCK_LS1X_CLK_H__
+
+#define LS1X_CLKID_PLL	0
+#define LS1X_CLKID_CPU	1
+#define LS1X_CLKID_DC	2
+#define LS1X_CLKID_AHB	3
+#define LS1X_CLKID_APB	4
+
+#define CLK_NR_CLKS	(LS1X_CLKID_APB + 1)
+
+#endif /* __DT_BINDINGS_CLOCK_LS1X_CLK_H__ */
Signature · 1 line
2.34.1
#2 lore raw

Re: [PATCH V2 1/3] dt-bindings: clock: Add Loongson-1 clock

Quoted 9 lines · Keguang Zhang

Add devicetree binding document and related header file for the Loongson-1 clock.

---
V1 -> V2: Change to one clock controller
Add clock-related dt-binding header file Fix the warning of dt_binding_check
---

Thank you for your patch. There is something to discuss/improve.

include/dt-bindings/clock/loongson,ls1x-clk.h line 1

Quoted 7 lines
include/dt-bindings/clock/loongson,ls1x-clk.h new file +1 -0
new file mode 100644
index 000000000000..579552c5f14b
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */

Same license as binding please.

include/dt-bindings/clock/loongson,ls1x-clk.h line 6

Quoted 5 lines
include/dt-bindings/clock/loongson,ls1x-clk.h new file +5 -0
+/*
+ * Loongson-1 clock tree IDs
+ *
+ * Copyright (C) 2023 Keguang Zhang <[email protected]>
+ */

Best regards,
Krzysztof

author maintainer
#3 lore raw

PATCH v2 2/3 clk: loongson1: Remove the outdated driver

In reply to Keguang Zhang

Remove the outdated driver due to the following aspects.
- no DT support
- duplicate code across LS1B and LS1C
- does not fit into the current clock framework

---
V1 -> V2: Split the driver removal to a separate patch

---
 drivers/clk/Makefile                   |   1 -
 drivers/clk/loongson1/Makefile         |   4 -
 drivers/clk/loongson1/clk-loongson1b.c | 118 -------------------------
 drivers/clk/loongson1/clk-loongson1c.c |  95 --------------------
 drivers/clk/loongson1/clk.c            |  41 ---------
 drivers/clk/loongson1/clk.h            |  15 ----
 6 files changed, 274 deletions(-)
 delete mode 100644 drivers/clk/loongson1/Makefile
 delete mode 100644 drivers/clk/loongson1/clk-loongson1b.c
 delete mode 100644 drivers/clk/loongson1/clk-loongson1c.c
 delete mode 100644 drivers/clk/loongson1/clk.c
 delete mode 100644 drivers/clk/loongson1/clk.h
drivers/clk/Makefile +0 -1
index e3ca0d058a25..b7b2c6d64636 100644
@@ -93,7 +93,6 @@ obj-y					+= imx/
 obj-y					+= ingenic/
 obj-$(CONFIG_ARCH_K3)			+= keystone/
 obj-$(CONFIG_ARCH_KEYSTONE)		+= keystone/
-obj-$(CONFIG_MACH_LOONGSON32)		+= loongson1/
 obj-y					+= mediatek/
 obj-$(CONFIG_ARCH_MESON)		+= meson/
 obj-y					+= microchip/
drivers/clk/loongson1/Makefile deleted +0 -4
deleted file mode 100644
index 251d0fe9dcd1..000000000000
@@ -1,4 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-only
-obj-y				+= clk.o
-obj-$(CONFIG_LOONGSON1_LS1B)	+= clk-loongson1b.o
-obj-$(CONFIG_LOONGSON1_LS1C)	+= clk-loongson1c.o
drivers/clk/loongson1/clk-loongson1b.c deleted +0 -118

118 lines not on this page · raw message

drivers/clk/loongson1/clk-loongson1c.c deleted +0 -95

95 lines not on this page · raw message

drivers/clk/loongson1/clk.c deleted +0 -41

41 lines not on this page · raw message

drivers/clk/loongson1/clk.h deleted +0 -15
deleted file mode 100644
index 124642302b12..000000000000
@@ -1,15 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/*
- * Copyright (c) 2012-2016 Zhang, Keguang <[email protected]>
- */
-
-#ifndef __LOONGSON1_CLK_H
-#define __LOONGSON1_CLK_H
-
-struct clk_hw *clk_hw_register_pll(struct device *dev,
-				   const char *name,
-				   const char *parent_name,
-				   const struct clk_ops *ops,
-				   unsigned long flags);
-
-#endif /* __LOONGSON1_CLK_H */
Signature · 1 line
2.34.1
author maintainer
#4 lore raw

PATCH v2 3/3 clk: loongson1: Re-implement the clock driver

In reply to Keguang Zhang

Re-implement the clock driver for Loongson-1 to add devicetree support and fit into the clock framework.

---
V1 -> V2: Implement one clock controller instead of single clocks

---
 drivers/clk/Makefile        |   1 +
 drivers/clk/clk-loongson1.c | 298 ++++++++++++++++++++++++++++++++++++
 2 files changed, 299 insertions(+)
 create mode 100644 drivers/clk/clk-loongson1.c
drivers/clk/Makefile +1 -0
index b7b2c6d64636..417bc27ab6e8 100644
@@ -43,6 +43,7 @@ obj-$(CONFIG_COMMON_CLK_K210)		+= clk-k210.o
 obj-$(CONFIG_LMK04832)			+= clk-lmk04832.o
 obj-$(CONFIG_COMMON_CLK_LAN966X)	+= clk-lan966x.o
 obj-$(CONFIG_COMMON_CLK_LOCHNAGAR)	+= clk-lochnagar.o
+obj-$(CONFIG_MACH_LOONGSON32)		+= clk-loongson1.o
 obj-$(CONFIG_COMMON_CLK_MAX77686)	+= clk-max77686.o
 obj-$(CONFIG_COMMON_CLK_MAX9485)	+= clk-max9485.o
 obj-$(CONFIG_ARCH_MILBEAUT_M10V)	+= clk-milbeaut.o
drivers/clk/clk-loongson1.c new file +298 -0

298 lines not on this page · raw message

Signature · 1 line
2.34.1