Re: [PATCH v1 1/2] clocksource: loongson2_hpet: add hpet driver support

From: Yinbo Zhu
Date: Fri Oct 07 2022 - 23:00:16 EST




在 2022/9/30 下午10:43, WANG Xuerui 写道:
Hi,

On 9/30/22 17:35, Yinbo Zhu wrote:
HPET (High Precision Event Timer) defines a new set of timers, which
are used by the operating system to schedule threads, interrupt the
kernel and interrupt the multimedia timer server. The operating
system can assign different timers to different applications. By
configuration, each timer can generate interrupt independently.

The loongson2 HPET module includes a main count and three comparators
, all of which are 32 bits wide. Among the three comparators, only
one comparator supports periodic interrupt, all three comparators
support non periodic interrupts.

Signed-off-by: Yinbo Zhu <zhuyinbo@xxxxxxxxxxx>
---
  MAINTAINERS                          |   6 +
  arch/loongarch/kernel/time.c         |   3 +
  drivers/clocksource/Kconfig          |   9 +
  drivers/clocksource/Makefile         |   1 +
  drivers/clocksource/loongson2_hpet.c | 332 +++++++++++++++++++++++++++
  5 files changed, 351 insertions(+)
  create mode 100644 drivers/clocksource/loongson2_hpet.c

Thanks for the contribution, but as HPET is a fairly common peripheral that have well standardized behavior, why not simply add DT support to the drivers/char/hpet.c and be done with it?
At present, the drivers/char/hpet.c doesn't support DT(dts parse) and
loongson2 soc wasn't belong to X86 or IA64 architecture, Although it is
an option to add DT support for this driver, I consider that the hpet
design of loongson2 series socs may not be universal. In addition, I
notice that mips and x86 have their own hpet drivers. In order to reduce
the impact on the public driver and make more flexible modifications to
the loongson2 hpet driver under its own architecture, a separate
loongson2 hpet driver was submitted.

config HPET
bool "HPET - High Precision Event Timer" if (X86 || IA64)
default n
depends on ACPI
help
If you say Y here, you will have a miscdevice named "/dev/hpet/". Each
open selects one of the timers supported by the HPET. The timers are
non-periodic and/or periodic.


BRs
Yinbo Zhu.