Skip to contentSkip to conversation

Move Loongson1 PWM timer to clocksource framework

PATCH Superseded Keguang Zhang 3 participants 8 messages Mar 28, 2023 – Mar 30, 2023

Subsystems (4)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Keguang Zhang

author maintainer
#0 lore raw

cover Move Loongson1 PWM timer to clocksource framework

Move Loongson1 PWM timer to clocksource framework and update the Kconfig/Makefile options accordingly.

Keguang Zhang (3):
MIPS: Loongson32: Remove deprecated PWM timer clocksource
dt-bindings: timer: Add Loongson-1 clocksource
clocksource: loongson1: Move PWM timer to clocksource framework

 .../timer/loongson,ls1x-pwmtimer.yaml         |  48 ++++
 arch/mips/loongson32/Kconfig                  |  37 ---
 arch/mips/loongson32/common/time.c            | 210 ----------------
 drivers/clocksource/Kconfig                   |   9 +
 drivers/clocksource/Makefile                  |   1 +
 drivers/clocksource/timer-loongson1-pwm.c     | 236 ++++++++++++++++++
 6 files changed, 294 insertions(+), 247 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/timer/loongson,ls1x-pwmtimer.yaml
 create mode 100644 drivers/clocksource/timer-loongson1-pwm.c

base-commit: f7b5a248213f0976c7944925f3f3ab7ff199e581

Signature · 1 line
2.34.1
author maintainer
#1 lore raw

PATCH 1/3 MIPS: Loongson32: Remove deprecated PWM timer clocksource

The Loongson1 PWM timer will be moved to clocksource framework. Then, the old driver is no longer needed.
Remove the deprecated code and update the Kconfig accordingly.

---
 arch/mips/loongson32/Kconfig       |  37 -----
 arch/mips/loongson32/common/time.c | 210 -----------------------------
 2 files changed, 247 deletions(-)
arch/mips/loongson32/Kconfig +0 -37
index 2ef9da0016df..a7c500959577 100644
@@ -35,41 +35,4 @@ config LOONGSON1_LS1C
 	select COMMON_CLK
 endchoice
 
-menuconfig CEVT_CSRC_LS1X
-	bool "Use PWM Timer for clockevent/clocksource"
-	select MIPS_EXTERNAL_TIMER
-	depends on CPU_LOONGSON32
-	help
-	  This option changes the default clockevent/clocksource to PWM Timer,
-	  and is required by Loongson1 CPUFreq support.
-
-	  If unsure, say N.
-
-choice
-	prompt "Select clockevent/clocksource"
-	depends on CEVT_CSRC_LS1X
-	default TIMER_USE_PWM0
-
-config TIMER_USE_PWM0
-	bool "Use PWM Timer 0"
-	help
-	  Use PWM Timer 0 as the default clockevent/clocksourcer.
-
-config TIMER_USE_PWM1
-	bool "Use PWM Timer 1"
-	help
-	  Use PWM Timer 1 as the default clockevent/clocksourcer.
-
-config TIMER_USE_PWM2
-	bool "Use PWM Timer 2"
-	help
-	  Use PWM Timer 2 as the default clockevent/clocksourcer.
-
-config TIMER_USE_PWM3
-	bool "Use PWM Timer 3"
-	help
-	  Use PWM Timer 3 as the default clockevent/clocksourcer.
-
-endchoice
-
 endif # MACH_LOONGSON32
arch/mips/loongson32/common/time.c +0 -210

228 lines not on this page · raw message

Signature · 1 line
2.34.1
maintainer Acked-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] MIPS: Loongson32: Remove deprecated PWM timer clocksource

Quoted 9 lines · Keguang Zhang

The Loongson1 PWM timer will be moved to clocksource framework. Then, the old driver is no longer needed.
Remove the deprecated code and update the Kconfig accordingly.

---
 arch/mips/loongson32/Kconfig       |  37 -----
 arch/mips/loongson32/common/time.c | 210 -----------------------------
 2 files changed, 247 deletions(-)
Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]
author maintainer
#3 lore raw

Re: [PATCH 1/3] MIPS: Loongson32: Remove deprecated PWM timer clocksource

Quoted 6 lines · Thomas Bogendoerfer
Quoted 4 lines · Keguang Zhang

The Loongson1 PWM timer will be moved to clocksource framework. Then, the old driver is no longer needed.
Remove the deprecated code and update the Kconfig accordingly.

Quoted 8 lines
Quoted 5 lines
---
 arch/mips/loongson32/Kconfig       |  37 -----
 arch/mips/loongson32/common/time.c | 210 -----------------------------
 2 files changed, 247 deletions(-)

Hi Thomas,
Sorry!
I have to send v2 to delete the obsolete header file regs-pwm.h.

Quoted 3 lines

--
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea. [ RFC1925, 2.3 ]

Signature · 3 lines
Best regards,

Keguang Zhang
author maintainer
#4 lore raw

PATCH 2/3 dt-bindings: timer: Add Loongson-1 clocksource

In reply to Keguang Zhang

Add devicetree binding document for Loongson-1 clocksource.

---
 .../timer/loongson,ls1x-pwmtimer.yaml         | 48 +++++++++++++++++++
 1 file changed, 48 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/timer/loongson,ls1x-pwmtimer.yaml
Documentation/devicetree/bindings/timer/loongson,ls1x-pwmtimer.yaml new file +48 -0
new file mode 100644
index 000000000000..c4771aab8d75
@@ -0,0 +1,48 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/timer/loongson,ls1x-pwmtimer.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Loongson-1 PWM timer
+
+maintainers:
+  - Keguang Zhang <[email protected]>
+
+description:
+  Loongson-1 PWM timer can be used for system clock source
+  and clock event timers.
+
+properties:
+  compatible:
+    const: loongson,ls1x-pwmtimer
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - interrupts
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/loongson,ls1x-clk.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+    clocksource: timer@1fe5c030 {
+        compatible = "loongson,ls1x-pwmtimer";
+        reg = <0x1fe5c030 0x10>;
+
+        clocks = <&clkc LS1X_CLKID_APB>;
+        interrupt-parent = <&intc0>;
+        interrupts = <20 IRQ_TYPE_LEVEL_HIGH>;
+    };
Signature · 1 line
2.34.1
maintainer
#5 lore raw

Re: [PATCH 2/3] dt-bindings: timer: Add Loongson-1 clocksource

Quoted 8 lines · Keguang Zhang

Add devicetree binding document for Loongson-1 clocksource.

---
 .../timer/loongson,ls1x-pwmtimer.yaml         | 48 +++++++++++++++++++
 1 file changed, 48 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/timer/loongson,ls1x-pwmtimer.yaml

My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13):

yamllint warnings/errors:

dtschema/dtc warnings/errors:
Documentation/devicetree/bindings/timer/loongson,ls1x-pwmtimer.example.dts:21:18: fatal error: dt-bindings/clock/loongson,ls1x-clk.h: No such file or directory
21 | #include <dt-bindings/clock/loongson,ls1x-clk.h>

      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

compilation terminated.
make[1]: *** [scripts/Makefile.lib:419: Documentation/devicetree/bindings/timer/loongson,ls1x-pwmtimer.example.dtb] Error 1 make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:1512: dt_binding_check] Error 2

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/[email protected]

The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch.

If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:

pip3 install dtschema --upgrade

Please check and re-submit after running the above command yourself. Note that DT_SCHEMA_FILES can be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema.

author maintainer
#6 lore raw

Re: [PATCH 2/3] dt-bindings: timer: Add Loongson-1 clocksource

Hi Rob,

Quoted 15 lines · Rob Herring
Quoted 8 lines · Keguang Zhang

Add devicetree binding document for Loongson-1 clocksource.

---
 .../timer/loongson,ls1x-pwmtimer.yaml         | 48 +++++++++++++++++++
 1 file changed, 48 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/timer/loongson,ls1x-pwmtimer.yaml

My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13):

Quoted 6 lines

yamllint warnings/errors:

dtschema/dtc warnings/errors:
Documentation/devicetree/bindings/timer/loongson,ls1x-pwmtimer.example.dts:21:18: fatal error: dt-bindings/clock/loongson,ls1x-clk.h: No such file or directory
21 | #include <dt-bindings/clock/loongson,ls1x-clk.h>

      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This file is contained in commit 12de2f50244efdbc8e98f89a340255c3c847e1dc, which is already available in 6.3-rc4.

Quoted 22 lines

compilation terminated.
make[1]: *** [scripts/Makefile.lib:419: Documentation/devicetree/bindings/timer/loongson,ls1x-pwmtimer.example.dtb] Error 1 make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:1512: dt_binding_check] Error 2

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/[email protected]

The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch.

If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:

pip3 install dtschema --upgrade

Please check and re-submit after running the above command yourself. Note that DT_SCHEMA_FILES can be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema.

Signature · 3 lines
Best regards,

Keguang Zhang
author maintainer
#7 lore raw

PATCH 3/3 clocksource: loongson1: Move PWM timer to clocksource framework

In reply to Keguang Zhang

This patch moves most part of arch/mips/loongson32/common/time.c into drivers/clocksource.

Adapt the driver to clocksource framework and
updates the Kconfig/Makefile options.

---
 drivers/clocksource/Kconfig               |   9 +
 drivers/clocksource/Makefile              |   1 +
 drivers/clocksource/timer-loongson1-pwm.c | 236 ++++++++++++++++++++++
 3 files changed, 246 insertions(+)
 create mode 100644 drivers/clocksource/timer-loongson1-pwm.c
drivers/clocksource/Kconfig +9 -0
index 5fc8f0e7fb38..6e37b26d532d 100644
@@ -603,6 +603,15 @@ config TIMER_IMX_SYS_CTR
 	  Enable this option to use i.MX system counter timer as a
 	  clockevent.
 
+config CLKSRC_LOONGSON1_PWM
+	bool "Clocksource using Loongson1 PWM"
+	depends on MACH_LOONGSON32 || COMPILE_TEST
+	select MIPS_EXTERNAL_TIMER
+	select TIMER_OF
+	help
+	  Enable this option to use Loongson1 PWM timer as clocksource
+	  instead of the performance counter.
+
 config CLKSRC_ST_LPC
 	bool "Low power clocksource found in the LPC" if COMPILE_TEST
 	select TIMER_OF if OF
drivers/clocksource/Makefile +1 -0
index 64ab547de97b..f969a9eedfca 100644
@@ -88,3 +88,4 @@ obj-$(CONFIG_MICROCHIP_PIT64B)		+= timer-microchip-pit64b.o
 obj-$(CONFIG_MSC313E_TIMER)		+= timer-msc313e.o
 obj-$(CONFIG_GOLDFISH_TIMER)		+= timer-goldfish.o
 obj-$(CONFIG_GXP_TIMER)			+= timer-gxp.o
+obj-$(CONFIG_CLKSRC_LOONGSON1_PWM)	+= timer-loongson1-pwm.o
drivers/clocksource/timer-loongson1-pwm.c new file +236 -0

236 lines not on this page · raw message

Signature · 1 line
2.34.1