Skip to contentSkip to conversation

Move Loongson1 PWM timer to clocksource framework

PATCH Superseded Keguang Zhang 2 participants 5 messages Mar 30, 2023

Subsystems (4)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Keguang Zhang

author maintainer
#0 lore raw

v2 cover Move Loongson1 PWM timer to clocksource framework

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

Changelog
V1 -> V2: Delete the obsolete header file regs-pwm.h

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 ++++
 .../include/asm/mach-loongson32/regs-pwm.h    |  25 --
 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 ++++++++++++++++++
 7 files changed, 294 insertions(+), 272 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/timer/loongson,ls1x-pwmtimer.yaml
 delete mode 100644 arch/mips/include/asm/mach-loongson32/regs-pwm.h
 create mode 100644 drivers/clocksource/timer-loongson1-pwm.c

base-commit: f7b5a248213f0976c7944925f3f3ab7ff199e581

Signature · 1 line
2.34.1
author maintainer
#1 lore raw

PATCH v2 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.

---
V1 -> V2: Delete the obsolete header file regs-pwm.h

---
 .../include/asm/mach-loongson32/regs-pwm.h    |  25 ---
 arch/mips/loongson32/Kconfig                  |  37 ---
 arch/mips/loongson32/common/time.c            | 210 ------------------
 3 files changed, 272 deletions(-)
 delete mode 100644 arch/mips/include/asm/mach-loongson32/regs-pwm.h
arch/mips/include/asm/mach-loongson32/regs-pwm.h deleted +0 -25
deleted file mode 100644
index ec870c82d492..000000000000
@@ -1,25 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/*
- * Copyright (c) 2014 Zhang, Keguang <[email protected]>
- *
- * Loongson 1 PWM Register Definitions.
- */
-
-#ifndef __ASM_MACH_LOONGSON32_REGS_PWM_H
-#define __ASM_MACH_LOONGSON32_REGS_PWM_H
-
-/* Loongson 1 PWM Timer Register Definitions */
-#define PWM_CNT			0x0
-#define PWM_HRC			0x4
-#define PWM_LRC			0x8
-#define PWM_CTRL		0xc
-
-/* PWM Control Register Bits */
-#define CNT_RST			BIT(7)
-#define INT_SR			BIT(6)
-#define INT_EN			BIT(5)
-#define PWM_SINGLE		BIT(4)
-#define PWM_OE			BIT(3)
-#define CNT_EN			BIT(0)
-
-#endif /* __ASM_MACH_LOONGSON32_REGS_PWM_H */
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 v2 1/3
#2 lore raw

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

Quoted 5 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.

Quoted 8 lines

---
V1 -> V2: Delete the obsolete header file regs-pwm.h

---
 .../include/asm/mach-loongson32/regs-pwm.h    |  25 ---
 arch/mips/loongson32/Kconfig                  |  37 ---
 arch/mips/loongson32/common/time.c            | 210 ------------------
 3 files changed, 272 deletions(-)
 delete mode 100644 arch/mips/include/asm/mach-loongson32/regs-pwm.h
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

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

In reply to Keguang Zhang

Add devicetree binding document for Loongson-1 clocksource.

---
V1 -> V2: None

---
 .../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
author maintainer
#4 lore raw

PATCH v2 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.

---
V1 -> V2: None

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