Skip to contentSkip to conversation

Devicetree support for Loongson-1 clock

PATCH Applied Keguang Zhang 2 participants 9 messages Mar 21, 2023

Subsystems (4)

v5 of 12 Applied Latest is v12 →

lore
Share & tools
lore

Keguang Zhang

author maintainer
#0 lore raw

v5 cover Devicetree support for Loongson-1 clock

Removes the old Loongson-1 clock driver and related code mainly because of no DT support and outdated implementation.

Then, re-implement it to solve the above issues,
along with the devicetree binding document.

Changelog
V4 -> V5: Include the necessary header files
Add error handling for ls1x_clk_init()
Remove MODULE_AUTHOR and MODULE_DESCRIPTION
Some fixes and cleanups
V3 -> V4: Fix the build error of missing linux/module.h
Add Reviewed-by tag from Krzysztof Kozlowski
V2 -> V3: Add 'reg' property into the 'required' field
Delete the unnecessary property 'clock-names'
Use the same license as binding document for the header file. Add MODULE_AUTHOR and MODULE_DESCRIPTION info
Add patch "MIPS: loongson32: Update the clock initialization" into this series Add Acked-by tag from Stephen Boyd and Thomas Bogendoerfer
V1 -> V2: Change to one clock controller (suggested by Krzysztof Kozlowski)
Add clock-related dt-binding header file
Fix the warning of dt_binding_check
Split the driver removal to a separate patch
Implement one clock controller instead of single clocks (suggested by Krzysztof Kozlowski)

Keguang Zhang (4):
dt-bindings: clock: Add Loongson-1 clock
clk: loongson1: Remove the outdated driver
clk: loongson1: Re-implement the clock driver
MIPS: loongson32: Update the clock initialization

 .../bindings/clock/loongson,ls1x-clk.yaml     |  45 +++
 .../include/asm/mach-loongson32/platform.h    |   1 -
 arch/mips/loongson32/common/time.c            |   3 +-
 drivers/clk/Makefile                          |   2 +-
 drivers/clk/clk-loongson1.c                   | 303 ++++++++++++++++++
 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 ++
 11 files changed, 370 insertions(+), 276 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: d8bb7bcf754c39de7347b746766ed45932e787d1

Signature · 1 line
2.34.1
author maintainer
#1 lore raw

PATCH v5 1/4 dt-bindings: clock: Add Loongson-1 clock

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

---
V4 -> V5: None
V3 -> V4: Add Reviewed-by tag from Krzysztof Kozlowski
V2 -> V3: Add 'reg' property into the 'required' field
Delete the unnecessary property 'clock-names'
Use the same license as binding document for the header file.
V1 -> V2: Change to one clock controller (suggested by Krzysztof Kozlowski)
Add clock-related dt-binding header file
Fix the warning of dt_binding_check

---
 .../bindings/clock/loongson,ls1x-clk.yaml     | 45 +++++++++++++++++++
 include/dt-bindings/clock/loongson,ls1x-clk.h | 19 ++++++++
 2 files changed, 64 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 +45 -0
new file mode 100644
index 000000000000..01561a0f35d5
@@ -0,0 +1,45 @@
+# 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-cells":
+    const: 1
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - "#clock-cells"
+
+additionalProperties: false
+
+examples:
+  - |
+    clkc: clock-controller@1fe78030 {
+        compatible = "loongson,ls1b-clk";
+        reg = <0x1fe78030 0x8>;
+
+        clocks = <&xtal>;
+        #clock-cells = <1>;
+    };
+
+...
include/dt-bindings/clock/loongson,ls1x-clk.h new file +19 -0
new file mode 100644
index 000000000000..d400e9ac6002
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
+/*
+ * 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
author maintainer
#3 lore raw

PATCH v5 2/4 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

---
V4 -> V5: None
V3 -> V4: None
V2 -> V3: None
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
maintainer Applied
#4 lore raw

Re: [PATCH v5 2/4] clk: loongson1: Remove the outdated driver

Quoting Keguang Zhang (2023-03-21 04:18:15)

Quoted 7 lines

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

---

Applied to clk-next

author maintainer
#5 lore raw

PATCH v5 3/4 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.

---
V4 -> V5: Include the necessary header files
Add error handling for ls1x_clk_init()
Remove MODULE_AUTHOR and MODULE_DESCRIPTION Some fixes and cleanups
V3 -> V4: Fix the build error of missing linux/module.h V2 -> V3: Add MODULE_AUTHOR and MODULE_DESCRIPTION info V1 -> V2: Implement one clock controller instead of single clocks
(suggested by Krzysztof Kozlowski)

---
 drivers/clk/Makefile        |   1 +
 drivers/clk/clk-loongson1.c | 303 ++++++++++++++++++++++++++++++++++++
 2 files changed, 304 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 +303 -0

303 lines not on this page · raw message

Signature · 1 line
2.34.1
maintainer Applied
#6 lore raw

Re: [PATCH v5 3/4] clk: loongson1: Re-implement the clock driver

Quoting Keguang Zhang (2023-03-21 04:18:16)

Quoted 5 lines

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

---

Applied to clk-next

author maintainer
#7 lore raw

PATCH v5 4/4 MIPS: loongson32: Update the clock initialization

In reply to Keguang Zhang

The Loongson-1 clock driver is under re-implementation
to add DT support. As a result, ls1x_clk_init() will be dropped soon. Therefore, call of_clk_init() for clock initialization instead.

---
V4 -> V5: None
V3 -> V4: None
V2 -> V3: Add this patch to "Devicetree support for Loongson-1 clock" series
Add Acked-by tag from Stephen Boyd and Thomas Bogendoerfer
V1 -> V2: None

---
 arch/mips/include/asm/mach-loongson32/platform.h | 1 -
 arch/mips/loongson32/common/time.c               | 3 ++-
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/mips/include/asm/mach-loongson32/platform.h +0 -1
index 86e1a6aab4e5..2cdcfb5f6012 100644
@@ -20,7 +20,6 @@ extern struct platform_device ls1x_gpio1_pdev;
 extern struct platform_device ls1x_rtc_pdev;
 extern struct platform_device ls1x_wdt_pdev;
 
-void __init ls1x_clk_init(void);
 void __init ls1x_rtc_set_extclk(struct platform_device *pdev);
 void __init ls1x_serial_set_uartclk(struct platform_device *pdev);
 
arch/mips/loongson32/common/time.c +2 -1
index 459b15c96d3b..965c04aa56fd 100644
@@ -4,6 +4,7 @@
  */
 
 #include <linux/clk.h>
+#include <linux/of_clk.h>
 #include <linux/interrupt.h>
 #include <linux/sizes.h>
 #include <asm/time.h>
@@ -211,7 +212,7 @@ void __init plat_time_init(void)
 	struct clk *clk = NULL;
 
 	/* initialize LS1X clocks */
-	ls1x_clk_init();
+	of_clk_init(NULL);
 
 #ifdef CONFIG_CEVT_CSRC_LS1X
 	/* setup LS1X PWM timer */
Signature · 1 line
2.34.1
maintainer Applied
#8 lore raw

Re: [PATCH v5 4/4] MIPS: loongson32: Update the clock initialization

Quoting Keguang Zhang (2023-03-21 04:18:17)

Quoted 8 lines

The Loongson-1 clock driver is under re-implementation
to add DT support. As a result, ls1x_clk_init() will be dropped soon. Therefore, call of_clk_init() for clock initialization instead.

---

Applied to clk-next