Skip to content

Commit

Permalink
drivers/timer: New xtensa timer with tickless support
Browse files Browse the repository at this point in the history
Rewritten Xtensa CCOUNT driver along the lines of all the other new
drivers.  The new API permits much smaller code.

Notably: The Xtensa counter is a 32 bit up-counter with a comparator
register.  It's in some sense the archetype of this kind of timer as
it's the simplest of the bunch (everything else has quirks: NRF is
very slow and 24 bit, HPET has a runtime frequency detection, RISC-V
is 64 bit...).  I should have written this one first.

Note also that this includes a blacklist of the xtensa architecture on
the tests/driver/ipm test.  I'm getting spurious failures there where
a k_sem_take() call with a non-zero timeout is being made out of the
console output code in interrupt context.  This seems to have nothing
to do with the timer; I suspect it's because the old timer drivers
would (incorrectly!) call z_clock_announce() in non-interrupt context
in some contexts (e.g. "expiring really soon").  Apparently this test
(or something in the IPM or Xtensa console code) was somehow relying
on that on Xtensa.  But IPM is a Quark thing and there's no particular
reason to run this test there.

Signed-off-by: Andy Ross <[email protected]>
  • Loading branch information
Andy Ross committed Nov 9, 2018
1 parent 7442ade commit 872bb80
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 618 deletions.
48 changes: 14 additions & 34 deletions drivers/timer/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -186,43 +186,23 @@ config XTENSA_TIMER
bool "Xtensa timer support"
depends on XTENSA
default y
select TICKLESS_CAPABLE
help
This module implements a kernel device driver for the Xtensa processor and
provides the standard "system clock driver" interfaces.
If unchecked, no timer will be used.
If checked it will use either an internal timer (default option) or an
external timer. In that case one shall unselect XTENSA_INTERNAL_TIMER and
define XTENSA_TIMER_IRQ and XTENSA_TIMER_IRQ_PRIORITY.

config XTENSA_INTERNAL_TIMER
bool "Xtensa internal timer"
depends on XTENSA_TIMER
default y
help
This module implements a kernel device driver for the Xtensa processor
internal timer and provides the standard "system clock driver" interfaces.
If unchecked, an external timer will be used. It will rely on a tick
interrupt connected to an IRQ line. In this case one shall define
both XTENSA_TIMER_IRQ and XTENSA_TIMER_IRQ_PRIORITY.

config XTENSA_TIMER_IRQ
int "Xtensa external timer interrupt number"
depends on XTENSA_TIMER && !XTENSA_INTERNAL_TIMER
range -1 31
default -1
help
This is the number of interrupt line used by the external timer.
The special value of -1 allows using the internal timer in order to
emulate an external timer. This is generally useful for running the project on
a simulator where it is hard to emulate an external interrupt.

config XTENSA_TIMER_IRQ_PRIORITY
int "Xtensa external timer interrupt priority"
depends on XTENSA_TIMER && !XTENSA_INTERNAL_TIMER
range 1 6
Enables a system timer driver for Xtensa based on the CCOUNT
and CCOMPARE special registers.

config XTENSA_TIMER_ID
int "System timer CCOMPAREn register index"
default 1
depends on XTENSA_TIMER
help
This is the priority of interrupt line.
Index of the CCOMPARE register (and associated interrupt)
used for the system timer. Xtensa CPUs have hard-configured
interrupt priorities associated with each timer, and some of
them can be unmaskable (and thus not usable by OS code that
need synchronization, like the timer subsystem!). Choose
carefully. Generally you want the timer with the highest
priority maskable interrupt.

config SYSTEM_CLOCK_DISABLE
bool "API to disable system clock"
Expand Down
Loading

0 comments on commit 872bb80

Please sign in to comment.