J-Core timer support
Subsystems (3)
Rich Felker
maintainerv4 cover J-Core timer support
This driver is used with the J2, an open-source VHDL reimplementation of SH-2.
I've split this out from the main J-Core support patches going upstream through my own linux-sh tree. Changes since the v3 are mainly cleanup/simplification, inclusion of sched_clock support based on suggestions by Daniel Lezcano, and reworking the DT bindings to use separate reg ranges per cpu rather than cpu-offset for greater flexibility.
Rich
Rich Felker (2):
of: add J-Core timer bindings
clocksource: add J-Core timer/clocksource driver
.../devicetree/bindings/timer/jcore,pit.txt | 25 ++ drivers/clocksource/Kconfig | 8 + drivers/clocksource/Makefile | 1 + drivers/clocksource/jcore-pit.c | 277 +++++++++++++++++++++ 4 files changed, 311 insertions(+) create mode 100644 Documentation/devicetree/bindings/timer/jcore,pit.txt create mode 100644 drivers/clocksource/jcore-pit.c
Signature · 6 lines
2.8.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Rich Felker
maintainerPATCH v4 1/2 of: add J-Core timer bindings
--- .../devicetree/bindings/timer/jcore,pit.txt | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Documentation/devicetree/bindings/timer/jcore,pit.txt
Documentation/devicetree/bindings/timer/jcore,pit.txt new file +25 -0
@@ -0,0 +1,25 @@ +J-Core Programmable Interval Timer and Clocksource + +Required properties: + +- compatible: Must be "jcore,pit". + +- reg: Memory region(s) for timer/clocksource registers. For SMP, + there should be one region per cpu, indexed by the sequential, + zero-based hardware cpu number (which is also the logical cpu + number). + +- interrupts: An interrupt to assign for the timer. The actual pit + core is integrated with the aic and allows the timer interrupt + assignment to be programmed by software, but this property is + required in order to reserve an interrupt number that doesn't + conflict with other devices. + + +Example: + +timer@200 { + compatible = "jcore,pit"; + reg = < 0x200 0x30 0x500 0x30 >; + interrupts = < 0x48 >; +};
Signature · 1 line
2.8.1
Rich Felker
maintainerPATCH v4 2/2 clocksource: add J-Core timer/clocksource driver
In reply to Rich FelkerAt the hardware level, the J-Core PIT is integrated with the interrupt controller, but it is represented as its own device and has an independent programming interface. It provides a 12-bit countdown timer, which is not presently used, and a periodic timer. The interval length for the latter is programmable via a 32-bit throttle register whose units are determined by a bus-period register. The periodic timer is used to implement both periodic and oneshot clock event modes; in oneshot mode the interrupt handler simply disables the timer as soon as it fires.
Despite its device tree node representing an interrupt for the PIT, the actual irq generated is programmable, not hard-wired. The driver is responsible for programming the PIT to generate the hardware irq number that the DT assigns to it.
On SMP configurations, J-Core provides cpu-local instances of the PIT; no broadcast timer is needed. This driver supports the creation of the necessary per-cpu clock_event_device instances. The code has been tested and works on SMP, but will not be usable without additional J-Core SMP-support patches and appropriate hardware capable of running SMP.
A nanosecond-resolution clocksource is provided using the J-Core "RTC" registers, which give a 64-bit seconds count and 32-bit nanoseconds. The driver converts these to a 64-bit nanoseconds count.
--- drivers/clocksource/Kconfig | 8 ++ drivers/clocksource/Makefile | 1 + drivers/clocksource/jcore-pit.c | 277 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 286 insertions(+) create mode 100644 drivers/clocksource/jcore-pit.c
drivers/clocksource/Kconfig +8 -0
@@ -313,6 +313,14 @@ config SYS_SUPPORTS_SH_TMU config SYS_SUPPORTS_EM_STI bool +config CLKSRC_JCORE_PIT + bool "J-Core PIT timer driver" + depends on GENERIC_CLOCKEVENTS + depends on HAS_IOMEM + help + This enables build of clocksource and clockevent driver for + the integrated PIT in the J-Core synthesizable, open source SoC. + config SH_TIMER_CMT bool "Renesas CMT timer driver" if COMPILE_TEST depends on GENERIC_CLOCKEVENTS
drivers/clocksource/Makefile +1 -0
@@ -5,6 +5,7 @@ obj-$(CONFIG_ATMEL_TCB_CLKSRC) += tcb_clksrc.o obj-$(CONFIG_X86_PM_TIMER) += acpi_pm.o obj-$(CONFIG_SCx200HR_TIMER) += scx200_hrt.o obj-$(CONFIG_CS5535_CLOCK_EVENT_SRC) += cs5535-clockevt.o +obj-$(CONFIG_CLKSRC_JCORE_PIT) += jcore-pit.o obj-$(CONFIG_SH_TIMER_CMT) += sh_cmt.o obj-$(CONFIG_SH_TIMER_MTU2) += sh_mtu2.o obj-$(CONFIG_SH_TIMER_TMU) += sh_tmu.o
drivers/clocksource/jcore-pit.c new file +277 -0
277 lines not on this page · raw message
Signature · 1 line
2.8.1
Re: [PATCH v4 2/2] clocksource: add J-Core timer/clocksource driver
drivers/clocksource/jcore-pit.c line 165
Quoted 11 lines · CEST Rich Felker
drivers/clocksource/jcore-pit.c new file +10
-0+ +static void __init jcore_pit_init (struct device_node *node) +{ +int err; +__iomem void *pit_base; +unsigned pit_irq; +unsigned cpu; +struct jcore_pit_nb *nb =0 ; +struct jcore_clocksource *cs =0 ; +struct jcore_pit __percpu *pit_percpu =0 ;
This no longer applies, as the return type of the init function is now 'int', not 'void'.
Arnd