Skip to contentSkip to conversation

Move Loongson1 PWM timer to clocksource framework

PATCH Applied Keguang Zhang 3 participants 8 messages May 12, 2023 – Jun 26, 2023

Subsystems (4)
lore
Share & tools
lore

Keguang Zhang

author maintainer
#0 lore raw

v4 cover Move Loongson1 PWM timer to clocksource framework

Move Loongson1 PWM timer to clocksource framework. Adapt the driver to clocksource framework with devicetree support. Update the Kconfig/Makefile options accordingly.

Changelog
V3 -> V4: Replaced the wildcard compatible string with specific one V2 -> V3: Remove the reference to regs-pwm.h
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/loongson1.h   |   1 -
 .../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 ++++++++++++++++++
 8 files changed, 294 insertions(+), 273 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: 31c6ed4e89187beef8fe2f979c8881ca94839427

Signature · 1 line
2.39.2
author maintainer
#1 lore raw

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

---
V3 -> V4: None
V2 -> V3: Remove the reference to regs-pwm.h V1 -> V2: Delete the obsolete header file regs-pwm.h

---
 .../include/asm/mach-loongson32/loongson1.h   |   1 -
 .../include/asm/mach-loongson32/regs-pwm.h    |  25 ---
 arch/mips/loongson32/Kconfig                  |  37 ---
 arch/mips/loongson32/common/time.c            | 210 ------------------
 4 files changed, 273 deletions(-)
 delete mode 100644 arch/mips/include/asm/mach-loongson32/regs-pwm.h
arch/mips/include/asm/mach-loongson32/loongson1.h +0 -1
index eb3ddbec1752..d8f9dec0ecc3 100644
@@ -47,7 +47,6 @@
 
 #include <regs-clk.h>
 #include <regs-mux.h>
-#include <regs-pwm.h>
 #include <regs-rtc.h>
 #include <regs-wdt.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.39.2
merge bot Applied
#2 lore raw

[tip: timers/core] MIPS: Loongson32: Remove deprecated PWM timer clocksource

The following commit has been merged into the timers/core branch of tip:

The following commit has been merged into the timers/core branch of tip:

Commit-ID:     9e130e2be4e7ac54de1ecc3fa424ca7ddfb1a748
Gitweb:        https://git.kernel.org/tip/9e130e2be4e7ac54de1ecc3fa424ca7ddfb1a748
Author:        Keguang Zhang <[email protected]>
AuthorDate:    Fri, 12 May 2023 18:37:22 +08:00
Committer:     Daniel Lezcano <[email protected]>
CommitterDate: Mon, 19 Jun 2023 17:06:55 +02:00

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.

---
 arch/mips/include/asm/mach-loongson32/loongson1.h |   1 +-
 arch/mips/include/asm/mach-loongson32/regs-pwm.h  |  25 +--
 arch/mips/loongson32/Kconfig                      |  37 +--
 arch/mips/loongson32/common/time.c                | 210 +-------------
 4 files changed, 273 deletions(-)
 delete mode 100644 arch/mips/include/asm/mach-loongson32/regs-pwm.h
arch/mips/include/asm/mach-loongson32/loongson1.h +0 -1
index eb3ddbe..d8f9dec 100644
@@ -47,7 +47,6 @@
 
 #include <regs-clk.h>
 #include <regs-mux.h>
-#include <regs-pwm.h>
 #include <regs-rtc.h>
 #include <regs-wdt.h>
 
arch/mips/include/asm/mach-loongson32/regs-pwm.h deleted +0 -25
deleted file mode 100644
index ec870c8..0000000
@@ -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 2ef9da0..a7c5009 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

author maintainer
#3 lore raw

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

In reply to Keguang Zhang

Add devicetree binding document for Loongson-1 clocksource.

---
V3 -> V4: Replaced the wildcard compatible string with specific one V2 -> V3: None
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..ad61ae55850b
@@ -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,ls1b-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,ls1b-pwmtimer";
+        reg = <0x1fe5c030 0x10>;
+
+        clocks = <&clkc LS1X_CLKID_APB>;
+        interrupt-parent = <&intc0>;
+        interrupts = <20 IRQ_TYPE_LEVEL_HIGH>;
+    };
Signature · 1 line
2.39.2
merge bot Applied
#5 lore raw

[tip: timers/core] dt-bindings: timer: Add Loongson-1 clocksource

In reply to Keguang Zhang
The following commit has been merged into the timers/core branch of tip:

The following commit has been merged into the timers/core branch of tip:

Commit-ID:     b25efff2a63f0d573f409f22e82904db9cc7d577
Gitweb:        https://git.kernel.org/tip/b25efff2a63f0d573f409f22e82904db9cc7d577
Author:        Keguang Zhang <[email protected]>
AuthorDate:    Fri, 12 May 2023 18:37:23 +08:00
Committer:     Daniel Lezcano <[email protected]>
CommitterDate: Mon, 19 Jun 2023 17:06:55 +02:00

dt-bindings: timer: Add Loongson-1 clocksource

Add devicetree binding document for Loongson-1 clocksource.

---
 Documentation/devicetree/bindings/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 0000000..ad61ae5
@@ -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,ls1b-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,ls1b-pwmtimer";
+        reg = <0x1fe5c030 0x10>;
+
+        clocks = <&clkc LS1X_CLKID_APB>;
+        interrupt-parent = <&intc0>;
+        interrupts = <20 IRQ_TYPE_LEVEL_HIGH>;
+    };
author maintainer
#6 lore raw

PATCH v4 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 with devicetree support and updates Kconfig/Makefile options.

---
V3 -> V4: Change the wildcard compatible string to the specific one V2 -> V3: None
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.39.2
merge bot Applied
#7 lore raw

[tip: timers/core] clocksource/drivers/loongson1: Move PWM timer to clocksource framework

The following commit has been merged into the timers/core branch of tip:

The following commit has been merged into the timers/core branch of tip:

Commit-ID:     e738521a11f13e40af89f66527e59306c4169782
Gitweb:        https://git.kernel.org/tip/e738521a11f13e40af89f66527e59306c4169782
Author:        Keguang Zhang <[email protected]>
AuthorDate:    Fri, 12 May 2023 18:37:24 +08:00
Committer:     Daniel Lezcano <[email protected]>
CommitterDate: Mon, 19 Jun 2023 17:07:03 +02:00

clocksource/drivers/loongson1: Move PWM timer to clocksource framework

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

Adapt the driver to clocksource framework with devicetree support and updates 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 526382d..c4d671a 100644
@@ -612,6 +612,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 f12d398..5d93c9e 100644
@@ -89,3 +89,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