clocksource/drivers/atcpit100: Add andestech atcpit100 timer
Subsystems (6)
v7 cover clocksource/drivers/atcpit100: Add andestech atcpit100 timer
Hi, all:
ATCPIT100 is often used on the Andes architecture, This timer provide 4 PIT channels. Each PIT channel is a multi-function timer, can be configured as 32,16,8 bit timers or PWM as well.
For system timer it will set channel 1 32-bit timer0 as clock source and count downwards until underflow and restart again.
It also set channel 0 32-bit timer0 as clock event and count downwards until condition match. It will generate an interrupt for handling periodically.
Changes in v7:
- Fix atcpit100_clkevt_next_event(), before set reload register, clock source timer shall disable. And re-enable it after the setting. Without this modification, the test case 'clock_nanosleep02' of ltp_20170929 will fail.
Changes in v6:
- To select TIMER_OF in drivers/clocksource/Kconfig instead of arch/nds32/Kconfig
- Refine Kconfig
- Update license format to SPDX-License-Identifier
Rick Chen (3):
clocksource/drivers/atcpit100: Add andestech atcpit100 timer clocksource/drivers/atcpit100: VDSO support
dt-bindings: timer: Add andestech atcpit100 timer binding doc
.../bindings/timer/andestech,atcpit100-timer.txt | 33 +++ drivers/clocksource/Kconfig | 9 + drivers/clocksource/Makefile | 1 + drivers/clocksource/timer-atcpit100.c | 266 +++++++++++++++++++++ 4 files changed, 309 insertions(+) create mode 100644 Documentation/devicetree/bindings/timer/andestech,atcpit100-timer.txt create mode 100644 drivers/clocksource/timer-atcpit100.c
Signature · 1 line
2.16.1
PATCH v7 1/3 clocksource/drivers/atcpit100: Add andestech atcpit100 timer
From: Rick Chen <[email protected]>
ATCPIT100 is often used on the Andes architecture, This timer provide 4 PIT channels. Each PIT channel is a multi-function timer, can be configured as 32,16,8 bit timers or PWM as well.
For system timer it will set channel 1 32-bit timer0 as clock source and count downwards until underflow and restart again.
It also set channel 0 32-bit timer0 as clock event and count downwards until condition match. It will generate an interrupt for handling periodically.
Add andestech atcpit100 timer
--- drivers/clocksource/Kconfig | 9 ++ drivers/clocksource/Makefile | 1 + drivers/clocksource/timer-atcpit100.c | 248 ++++++++++++++++++++++++++++++++++ 3 files changed, 258 insertions(+) create mode 100644 drivers/clocksource/timer-atcpit100.c
drivers/clocksource/Kconfig +9 -0
@@ -591,4 +591,13 @@ config CLKSRC_ST_LPC Enable this option to use the Low Power controller timer as clocksource. +config ATCPIT100_TIMER + bool "ATCPIT100 timer driver" + depends on NDS32 || COMPILE_TEST + depends on HAS_IOMEM + select TIMER_OF + default NDS32 + help + This option enables support for the Andestech ATCPIT100 timers. + endmenu
drivers/clocksource/Makefile +1 -0
@@ -76,3 +76,4 @@ obj-$(CONFIG_H8300_TMR16) += h8300_timer16.o obj-$(CONFIG_H8300_TPU) += h8300_tpu.o obj-$(CONFIG_CLKSRC_ST_LPC) += clksrc_st_lpc.o obj-$(CONFIG_X86_NUMACHIP) += numachip.o +obj-$(CONFIG_ATCPIT100_TIMER) += timer-atcpit100.o
drivers/clocksource/timer-atcpit100.c new file +248 -0
248 lines not on this page · raw message
Signature · 1 line
2.16.1
PATCH v7 2/3 clocksource/drivers/atcpit100: VDSO support
In reply to Greentime HuFrom: Rick Chen <[email protected]>
VDSO needs real-time cycle count to ensure the time accuracy. Unlike others, nds32 architecture does not define clock source, hence VDSO needs atcpit100 offering real-time cycle count to derive the correct time.
--- drivers/clocksource/timer-atcpit100.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
drivers/clocksource/timer-atcpit100.c +18 -0
@@ -18,6 +18,9 @@#include <linux/of_irq.h> #include <linux/of_platform.h> #include "timer-of.h" +#ifdef CONFIG_NDS32 +#include <asm/vdso_timer_info.h> +#endif /* * Definition of register offsets
@@ -204,6 +207,17 @@ static u64 notrace atcpit100_timer_sched_read(void)return ~readl (timer_of_base (&to) +CH1_CNT ); } +#ifdef CONFIG_NDS32 +static void fill_vdso_need_info (struct device_node *node) +{ +struct resource timer_res; +of_address_to_resource (node,0 , &timer_res); + timer_info.mapping_base = (unsigned long )timer_res.start; + timer_info.cycle_count_down = true; + timer_info.cycle_count_reg_offset =CH1_CNT ; +} +#endif +static int __init atcpit100_timer_init (struct device_node *node) {int ret;
@@ -242,6 +256,10 @@ static int __init atcpit100_timer_init(struct device_node *node) val =readl (base +INT_EN );writel (val |CH0INT0EN , base +INT_EN ); +#ifdef CONFIG_NDS32 +fill_vdso_need_info (node); +#endif +return ret; }
Signature · 1 line
2.16.1
PATCH v7 3/3 dt-bindings: timer: Add andestech atcpit100 timer binding doc
In reply to Greentime HuFrom: Rick Chen <[email protected]>
Add a document to describe Andestech atcpit100 timer and binding information.
--- .../bindings/timer/andestech,atcpit100-timer.txt | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Documentation/devicetree/bindings/timer/andestech,atcpit100-timer.txt
Documentation/devicetree/bindings/timer/andestech,atcpit100-timer.txt new file +33 -0
@@ -0,0 +1,33 @@ +Andestech ATCPIT100 timer +------------------------------------------------------------------ +ATCPIT100 is a generic IP block from Andes Technology, embedded in +Andestech AE3XX platforms and other designs. + +This timer is a set of compact multi-function timers, which can be +used as pulse width modulators (PWM) as well as simple timers. + +It supports up to 4 PIT channels. Each PIT channel is a +multi-function timer and provide the following usage scenarios: +One 32-bit timer +Two 16-bit timers +Four 8-bit timers +One 16-bit PWM +One 16-bit timer and one 8-bit PWM +Two 8-bit timer and one 8-bit PWM + +Required properties: +- compatible : Should be "andestech,atcpit100" +- reg : Address and length of the register set +- interrupts : Reference to the timer interrupt +- clocks : a clock to provide the tick rate for "andestech,atcpit100" +- clock-names : should be "PCLK" for the peripheral clock source. + +Examples: + +timer0: timer@f0400000 { + compatible = "andestech,atcpit100"; + reg = <0xf0400000 0x1000>; + interrupts = <2>; + clocks = <&apb>; + clock-names = "PCLK"; +};
Signature · 1 line
2.16.1
2018-02-13 17:13 GMT+08:00 Greentime Hu <[email protected]>:
Quoted 31 lines
Hi, all:
ATCPIT100 is often used on the Andes architecture, This timer provide 4 PIT channels. Each PIT channel is a multi-function timer, can be configured as 32,16,8 bit timers or PWM as well.
For system timer it will set channel 1 32-bit timer0 as clock source and count downwards until underflow and restart again.
It also set channel 0 32-bit timer0 as clock event and count downwards until condition match. It will generate an interrupt for handling periodically.
Changes in v7:
- Fixatcpit100_clkevt_next_event(), before set reload register, clock source timer shall disable. And re-enable it after the setting. Without this modification, the test case 'clock_nanosleep02' ofltp_20170929will fail.Changes in v6:
- To selectTIMER_OFindrivers/clocksource/Kconfiginstead ofarch/nds32/Kconfig
- RefineKconfig
- Update license format to SPDX-License-IdentifierRick Chen (3):
clocksource/drivers/atcpit100: Add andestech atcpit100 timer clocksource/drivers/atcpit100: VDSO support
dt-bindings: timer: Add andestech atcpit100 timer binding doc
Quoted 8 lines
.../bindings/timer/andestech,atcpit100-timer.txt | 33 +++ drivers/clocksource/Kconfig | 9 + drivers/clocksource/Makefile | 1 + drivers/clocksource/timer-atcpit100.c | 266 +++++++++++++++++++++ 4 files changed, 309 insertions(+) create mode 100644 Documentation/devicetree/bindings/timer/andestech,atcpit100-timer.txt create mode 100644 drivers/clocksource/timer-atcpit100.c
Hi, Daniel:
Please merge this driver for 4.17 to go along with the nds32 architeture support.
Thank you.