Commit graph

452 commits

Author SHA1 Message Date
Carlo Caione 6f36300219 drivers: timer: Add per-core ARM architected timer
ARM cores may have a per-core architected timer, which provides per-cpu
timers, attached to a GIC to deliver its per-processor interrupts via
PPIs. This is the most common case supported by QEMU in the virt
platform.

This patch introduces support for this timer abstracting the way the
timer registers are actually accessed. This is needed because different
architectures (for example ARMv7-R vs ARMv8-A) use different registers
and even the same architecture (ARMv8-A) can actually use different
timers (ELx physical timers vs ELx virtual timers).

So we introduce the common driver here but the actual SoC / architecture
/ board must provide the three helpers (arm_arch_timer_set_compare(),
arm_arch_timer_toggle(), arm_arch_timer_count()) using an header file
imported through the arch/cpu.h header file.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2020-02-01 08:08:43 -05:00
Ulf Magnusson 92529da116 kernel: kconfig: Fix broken references to TICKLESS_KERNEL
The CONFIG_ prefixes were missing on these.

Found with a work-in-progress scripts/kconfig/lint.py check.

This symbol is defined in kernel/Kconfig.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-01-25 08:14:55 -05:00
Benjamin Valentin cd0873015a timer: sam0_rtc_timer: Add support for SAME54
The RTC peripheral found in the SAMD5x/SAME5x MCUs is very
simmilar to the one found in existing sam0 devices with only
a few changes to register names and the clock source selection.

Signed-off-by: Benjamin Valentin <benpicco@googlemail.com>
2019-12-21 11:15:52 -05:00
Carlo Caione aec9a8c4be arch: arm: Move ARM code to AArch32 sub-directory
Before introducing the code for ARM64 (AArch64) we need to relocate the
current ARM code to a new AArch32 sub-directory. For now we can assume
that no code is shared between ARM and ARM64.

There are no functional changes. The code is moved to the new location
and the file paths are fixed to reflect this change.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2019-12-20 11:40:59 -05:00
Krzysztof Chruscinski 00156ad80a drivers: clock_control: nrf: Switch to single clock device
Low frequency and high frequency clocks had separate devices
while they are actually handled by single peripheral with single
interrupt. The split was done probably because opaque subsys
argument in the API was used for other purposes and there was
no way to pass the information which clock should be controlled.
Implementation changes some time ago and subsys parameter was
no longer used. It now can be used to indicate which clock should
be controlled.

Change become necessary when nrf5340 is taken into account where
there are more clocks and current approach would lead to create
multiple devices - mess.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2019-12-17 14:38:19 +01:00
Ulf Magnusson 87e917a925 kconfig: Remove redundant 'default n' and 'prompt' properties
Bool symbols implicitly default to 'n'.

A 'default n' can make sense e.g. in a Kconfig.defconfig file, if you
want to override a 'default y' on the base definition of the symbol. It
isn't used like that on any of these symbols though.

Also replace some

    config
    	prompt "foo"
    	bool/int

with the more common shorthand

    config
    	bool/int "foo"

See the 'Style recommendations and shorthands' section in
https://docs.zephyrproject.org/latest/guides/kconfig/index.html.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-12-09 16:14:50 +01:00
Peter Bigot fd5b502b64 drivers: timer: nrf_rtc_timer: avoid starving clock announcements
When setting a timeout measure the number of accumulated unannounced
ticks.  If this value exceeds half the 24-bit cycle counter range
force an announcement so the unannounced cycles are incorporated into
the system tick counter.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2019-12-02 15:28:12 +01:00
Andy Ross 5f63c9d907 drivers/timer: Clamp after tick adjustment, not before
Some early tickless drivers had a common pattern where they would
compute a tick maximum for the request (i.e. the maximum the hardware
counter can handle) but apply it only on the input tick value and not
on the adjusted final value, opening up the overflow condition it was
supposed to have prevented.

Fixes #20939 (Strictly it fixes the specific pattern that was
discovered in that bug.  It's not impossible that other drivers with
alternative implementations have a similar issue, though they look OK
to me via a quick audit).

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-11-27 18:43:53 +01:00
Ioannis Glaropoulos ea2324dd2a drivers: timer: SysTick: enforce proper min & max SysTick LOAD values
Similar to what we do in other timer drivers, the maximum ticks
supplied in z_clock_set_timeout(..) needs to be MAX_TICKS at
maximum, when K_FOREVER is supplied as argument to the function.

In addition to that, the value we load onto the SysTick LOAD
register shall be truncated to MAX_CYCLES. This is required
to prevent loading a trash value to LOAD register, as only
the lowest 24 bits may be safely written.

Finally, we move the enforcement of the minimum delay to be
programmed on LOAD (i.e. MIN_DELAY) at the end step of the
calculation of the cycles-to-be-programmed. This prevents
from misscalculating the delay, as any required adjustment
is applied at the end, after the delay is rounded up to
the next tick boundary.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-11-26 13:34:30 -06:00
Peter Bigot 3594f136d7 drivers: systick: avoid starving clock announcements
When setting a timeout measure the number of accumulated unannounced
ticks.  If this value exceeds half the 32-bit cycle counter range
force an announcement so the unannounced cycles are incorporated into
the system tick counter.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2019-11-26 13:34:30 -06:00
Ioannis Glaropoulos b3574bdad7 drivers: systick: fix calculation of absolute cycles count in ISR
The commit fixes the update of the absolute counter of HW cycles
in the SysTick ISR for TICKLESS mode.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-11-26 13:34:30 -06:00
Peter Bigot f16a403e64 drivers: timer: SysTick: rework late overflow check
The previous solution depended on a magic number and was inefficient
(entered the second-wrap conditional even when a second wrap hadn't
been observed).  Replace with an algorithm that is deterministic.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2019-11-26 13:34:30 -06:00
Ioannis Glaropoulos f7aa227c07 drivers: timer: SysTick: document internal function and variables
Add detailed documentation for the internal 'elapsed()'
function, as well as for the local counter variables used
in the SysTick driver.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-11-26 13:34:30 -06:00
Ioannis Glaropoulos 35886463dd drivers: timer: SysTick: remove unnecessary masking
Unsupported bits of the Current Value Register
are read as zero, so we remove the redundant
ANDing with the max supported counter value.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-11-26 13:34:30 -06:00
Peter Bigot 4592ac8ca4 drivers: timer: nrf_rtc_timer: fix lost ticks from unannounced elapsed
The original code assumed that limiting the tick count to the maximum
cycle value representable without wrapping would guarantee that adding
the resulting cycle offset to last_count would not lap the counter.
This is not true when elapsed time, which is also added to the cycle
offset, exceeds one tick.  Cap the maximum offset at the number of
cycles corresponding to the maximum number of ticks without wrapping.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2019-11-26 08:23:50 -05:00
Ulf Magnusson d0a6f682d1 kconfig: Fix up newly-introduced copy-pasted headers
Same deal as in https://github.com/zephyrproject-rtos/zephyr/pull/20280,
for newly-introduced stuff.

Will avoid failures with the new CI test in
https://github.com/zephyrproject-rtos/ci-tools/pull/112, though it only
checks changed files.

Also fix some un-indented properties on choices. Choice properties work
the same as symbol properties syntactically.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-11-19 15:25:08 -05:00
Wayne Ren 66856e5478 drivers: timer: fix the bug for SMP
* fix the smp timer dirver bugs found in debug and test.
for smp case, GFRC is used as clock source, and local
internal timer is used to trigger time event.

* because 64-bits gfrc is used, so idle can be igored as no kernel
tick will be missed

Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2019-11-13 12:04:18 -08:00
Francois Ramu 80d58e7f39 driver: timer: st_stm32: add lptimer management to stm32wb series
This patch introduces the support of the LowPower Timer
     for the STM32WBxx from STMicroelectronics.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2019-11-13 10:31:06 -06:00
Francois Ramu 0ae7023405 driver: timer: st_stm32: add lptimer management to stm32xx series
This patch introduces the support of the LowPower Timer
 for the STM32xx from STMicroelectronics.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2019-11-08 10:04:21 -06:00
Andy Ross 8892406c1d kernel/sys_clock.h: Deprecate and convert uses of old conversions
Mark the old time conversion APIs deprecated, leave compatibility
macros in place, and replace all usage with the new API.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-11-08 11:08:58 +01:00
Andrew Boie 4f77c2ad53 kernel: rename z_arch_ to arch_
Promote the private z_arch_* namespace, which specifies
the interface between the core kernel and the
architecture code, to a new top-level namespace named
arch_*.

This allows our documentation generation to create
online documentation for this set of interfaces,
and this set of interfaces is worth treating in a
more formal way anyway.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-11-07 15:21:46 -08:00
Stephanos Ioannidis 2d7460482d headers: Refactor kernel and arch headers.
This commit refactors kernel and arch headers to establish a boundary
between private and public interface headers.

The refactoring strategy used in this commit is detailed in the issue

This commit introduces the following major changes:

1. Establish a clear boundary between private and public headers by
  removing "kernel/include" and "arch/*/include" from the global
  include paths. Ideally, only kernel/ and arch/*/ source files should
  reference the headers in these directories. If these headers must be
  used by a component, these include paths shall be manually added to
  the CMakeLists.txt file of the component. This is intended to
  discourage applications from including private kernel and arch
  headers either knowingly and unknowingly.

  - kernel/include/ (PRIVATE)
    This directory contains the private headers that provide private
   kernel definitions which should not be visible outside the kernel
   and arch source code. All public kernel definitions must be added
   to an appropriate header located under include/.

  - arch/*/include/ (PRIVATE)
    This directory contains the private headers that provide private
   architecture-specific definitions which should not be visible
   outside the arch and kernel source code. All public architecture-
   specific definitions must be added to an appropriate header located
   under include/arch/*/.

  - include/ AND include/sys/ (PUBLIC)
    This directory contains the public headers that provide public
   kernel definitions which can be referenced by both kernel and
   application code.

  - include/arch/*/ (PUBLIC)
    This directory contains the public headers that provide public
   architecture-specific definitions which can be referenced by both
   kernel and application code.

2. Split arch_interface.h into "kernel-to-arch interface" and "public
  arch interface" divisions.

  - kernel/include/kernel_arch_interface.h
    * provides private "kernel-to-arch interface" definition.
    * includes arch/*/include/kernel_arch_func.h to ensure that the
     interface function implementations are always available.
    * includes sys/arch_interface.h so that public arch interface
     definitions are automatically included when including this file.

  - arch/*/include/kernel_arch_func.h
    * provides architecture-specific "kernel-to-arch interface"
     implementation.
    * only the functions that will be used in kernel and arch source
     files are defined here.

  - include/sys/arch_interface.h
    * provides "public arch interface" definition.
    * includes include/arch/arch_inlines.h to ensure that the
     architecture-specific public inline interface function
     implementations are always available.

  - include/arch/arch_inlines.h
    * includes architecture-specific arch_inlines.h in
     include/arch/*/arch_inline.h.

  - include/arch/*/arch_inline.h
    * provides architecture-specific "public arch interface" inline
     function implementation.
    * supersedes include/sys/arch_inline.h.

3. Refactor kernel and the existing architecture implementations.

  - Remove circular dependency of kernel and arch headers. The
   following general rules should be observed:

    * Never include any private headers from public headers
    * Never include kernel_internal.h in kernel_arch_data.h
    * Always include kernel_arch_data.h from kernel_arch_func.h
    * Never include kernel.h from kernel_struct.h either directly or
     indirectly. Only add the kernel structures that must be referenced
     from public arch headers in this file.

  - Relocate syscall_handler.h to include/ so it can be used in the
   public code. This is necessary because many user-mode public codes
   reference the functions defined in this header.

  - Relocate kernel_arch_thread.h to include/arch/*/thread.h. This is
   necessary to provide architecture-specific thread definition for
   'struct k_thread' in kernel.h.

  - Remove any private header dependencies from public headers using
   the following methods:

    * If dependency is not required, simply omit
    * If dependency is required,
      - Relocate a portion of the required dependencies from the
       private header to an appropriate public header OR
      - Relocate the required private header to make it public.

This commit supersedes #20047, addresses #19666, and fixes #3056.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2019-11-06 16:07:32 -08:00
Ulf Magnusson bd6e04411e kconfig: Clean up header comments and make them consistent
Use this short header style in all Kconfig files:

    # <description>

    # <copyright>
    # <license>

    ...

Also change all <description>s from

    # Kconfig[.extension] - Foo-related options

to just

    # Foo-related options

It's clear enough that it's about Kconfig.

The <description> cleanup was done with this command, along with some
manual cleanup (big letter at the start, etc.)

    git ls-files '*Kconfig*' | \
        xargs sed -i -E '1 s/#\s*Kconfig[\w.-]*\s*-\s*/# /'

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-11-04 17:31:27 -05:00
Ulf Magnusson 975de21858 kconfig: Global whitespace/consistency cleanup
Clean up space errors and use a consistent style throughout the Kconfig
files. This makes reading the Kconfig files more distraction-free, helps
with grepping, and encourages the same style getting copied around
everywhere (meaning another pass hopefully won't be needed).

Go for the most common style:

 - Indent properties with a single tab, including for choices.

   Properties on choices work exactly the same syntactically as
   properties on symbols, so not sure how the no-indentation thing
   happened.

 - Indent help texts with a tab followed by two spaces

 - Put a space between 'config' and the symbol name, not a tab. This
   also helps when grepping for definitions.

 - Do '# A comment' instead of '#A comment'

I tweaked Kconfiglib a bit to find most of the stuff.

Some help texts were reflowed to 79 columns with 'gq' in Vim as well,
though not all, because I was afraid I'd accidentally mess up
formatting.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-11-01 15:53:23 +01:00
Daniel Leung b7eb04b300 x86: consolidate x86_64 architecture, SoC and boards
There are two set of code supporting x86_64: x86_64 using x32 ABI,
and x86 long mode, and this consolidates both into one x86_64
architecture and SoC supporting truly 64-bit mode.

() Removes the x86_64:x32 architecture and SoC, and replaces
   them with the existing x86 long mode arch and SoC.
() Replace qemu_x86_64 with qemu_x86_long as qemu_x86_64.
() Updates samples and tests to remove reference to
   qemu_x86_long.
() Renames CONFIG_X86_LONGMODE to CONFIG_X86_64.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2019-10-25 17:57:55 -04:00
Andrei Gansari 2adccabf6a drivers: remove arm's qemu systick workaround
Removed workarounds in systick driver as they prevent normal usage in
TICKLESS systems. Driver still behaved like an interrupt based ticker.

Signed-off-by: Andrei Gansari <andrei.gansari@nxp.com>
2019-10-22 23:06:41 -04:00
Ulf Magnusson 677f1e6db9 kconfig: Turn pointless/confusing 'menuconfig's into 'config's
Defining a symbol with 'menuconfig' just tells the menuconfig to display
any dependent symbols that immediately follow it in a separate menu.
'menuconfig' has no effect on symbol values.

Making a symbol that doesn't have any dependent symbols after it a
'menuconfig' should be avoided, because then you end up with an empty
menu, which is shown as e.g.

    [*] Enable foo ---

This is how it would be shown if there were children but they all
happened to be invisible as well.

With a regular 'config', it turns into

    [*] Enable foo

Change all pointless 'menuconfig's to 'config's.

See the section on 'menuconfig' on the Kconfig - Tips and Best Practices
page as well.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-10-22 13:53:06 -05:00
Mateusz Holenko a524373004 drivers: litex_timer: fix usage of DT_ defines
This commit switches from using device tree automatically
generated address-based defines to the instance id-based ones.

Without this change it is not be possible to re-use the driver
on boards where the device is located at different location
than 0xe0002800.

Signed-off-by: Mateusz Holenko <mholenko@antmicro.com>
2019-10-18 07:48:14 -05:00
Andrew Boie b12a094d63 drivers: hpet: fix includes
IRQ APIs were being used without pulling in the proper header.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-10-09 09:14:18 -04:00
Krzysztof Chruscinski 43af941131 drivers: Align nrf counter, timer and usb driver to new clock_control
Align drivers to use new clock control API.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2019-10-04 17:15:39 +02:00
Andrew Boie 8c98a97581 arm: arch code naming cleanup
This patch re-namespaces global variables and functions
that are used only within the arch/arm/ code to be
prefixed with z_arm_.

Some instances of CamelCase have been corrected.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-10-04 10:46:23 +02:00
Ioannis Glaropoulos b0ef6d0693 drivers: timer: nrf: minor comment fix
Fix an inline comment in nrf_rtc_timer.c correcting the
path to the mentioned test.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-10-02 21:06:54 -04:00
Andrew Boie 9e1dda8804 timing_info: rename globals
Global variables related to timing information have been
renamed to be prefixed with z_arch, with naming arranged
in increasing order of specificity.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-09-30 15:25:55 -04:00
Andy Ross bab348e915 drivers/timer/hpet: Work around crazy qemu behavior
At least twice (to be fair: twice among thousands of test runs), I've
seen this device return "backwards" times in SMP, where the counter
value read from one CPU is behind the saved value already seen on the
other.  On hardware this should obviously never happen, HPET is a
single global device.

Add a simple workaround on QEMU targets so the math doesn't blow up.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-09-26 16:54:06 -04:00
Andrzej Głąbek 57c6cfc9cd nordic: Use hal/ in all inclusions of nrfx HAL header files
Header files of nrfx HALs are not supposed to be included directly
but only with their names prepended with the hal/ directory (so that
an inclusion of an nrfx HAL header clearly differs from an inclusion
of an nrfx driver header).

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2019-09-24 16:20:16 +02:00
Vincent Wan aeb8d017b5 drivers: timer: add RTC support as system clock for CC13X2/CC26X2
Add RTC timer driver for CC13X2/CC26X2, and use it instead of systick
as system clock. It is necessary to use this timer for power
management support, so that the system can exit from deep sleep upon
expiry of timeouts.

Signed-off-by: Vincent Wan <vincent.wan@linaro.org>
2019-09-19 13:43:10 -05:00
Charles E. Youse 3038209695 drivers/timer/hpet.c: migrate to devicetree
This driver was still using CONFIG_* values to determine its address,
IRQ, etc. Add a binding for an "intel,hpet" device and migrate this
driver to devicetree.

Fixes: #18657

Signed-off-by: Charles E. Youse <charles.youse@intel.com>
2019-09-17 22:37:09 +08:00
Andrew Boie 6fd6b7e50a xtensa: remove legacy arch implementation
We re-wrote the xtensa arch code, but never got around
to purging the old implementation.

Removed those boards which hadn't been moved to the new
arch code. These were all xt-sim simulator targets and not
real hardware.

Fixes: #18138

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-09-12 01:26:34 -04:00
Scott Worley 26c411f6bd drivers : timer : MEC1501 RTOS timer load delay work-around.
MEC1501 RTOS timer internal counter is on the 32KHz clock domain.
The register interface is on the AHB clock. When the timer is started
hardware synchronizes to the next 32KHz clock edge resulting is a
variable delay moving the value in the preload register into the
count register. The maximum delay is one 32KHz clock period (30.5 us).
We work-around this delay by checking if the timer has been started
and not using the count value which is still 0. Instead we state zero
counts have elapsed.

Signed-off-by: Scott Worley <scott.worley@microchip.com>
2019-09-03 18:37:46 +02:00
Peter Bigot d28e65a784 drivers/timer/nrf_rtc_timer: clarify intent of ZLI compensation
The variable enabling entry to the zero latency interrupt compensation
loop was named generically, and its logic inverted, making the code
difficult to understand.  Change the name and initial value to more
clearly indicate its role.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2019-08-20 08:34:15 +02:00
Wayne Ren cca39204c2 arch: arc: add initial support of ARC TEE
* it's based on ARC SecureShield
* add basic secure service in arch/arc/core/secureshield
* necesssary changes in arch level
   * thread switch
   * irq/exception handling
   * initialization
* add secure time support

Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2019-08-10 17:45:22 +02:00
Wendy Liang 4ef9d4b6bf timer: Add Xilinx ZynqMP PS ttc timer
Add Xilinx PS ttc timer for Xilinx ZynqMP platform.

Signed-off-by: Wendy Liang <wendy.liang@xilinx.com>
2019-08-09 22:50:50 +02:00
Wayne Ren 31a0371a0a drivers: arcv2_timer0: add support for smp
* use global free running counter as global wall clock (clock source)
* use arc internal timer 0 as local time event (clock event)

Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2019-08-07 12:21:00 +02:00
Robert Lubos 9f34d17cc1 drivers: timer: nrf_rtc_timer: Fix set_comparator corner case
Update the logic in a corner case, when the target comparator value is
one cycle ahead of the counter value.

Experiments have shown, that `set_comparator(cyc + 1);` might be not
enough in that case, and we still may (rarely) miss the interrupt.
This could happen when the counter incremented its value after the `dt`
variable was set. As we should set the comparator value two cycles
ahead to be on the safe side, increment the target comparator value
by 2 instead of 1.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2019-08-01 12:29:36 +02:00
Scott Worley bdaab8cfa0 drivers : timer : Add MEC1501 32KHz kernel timer driver
Add a kernel timer driver for the MEC1501 32KHz RTOS timer.
This timer is a count down 32-bit counter clocked at a fixed
32768 Hz. It features one-shot, auto-reload, and halt count down
while the Cortex-M is halted by JTAG/SWD. This driver is based
on the new Intel local APIC driver. The driver was tuned for
accuracy at small sleep values. Added a work-around for RTOS
timer restart issue. RTOS timer driver requires board ticks per
second to be 32768 if tickless operation is configured.

Signed-off-by: Scott Worley <scott.worley@microchip.com>
2019-07-24 14:58:41 -07:00
Piotr Zięcik 0c0c0d93ea drivers: timer: Do not use CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC
On some SoCs the frequency of the system clock is obtained at run time
as the exact configuration of the hardware is not known at compile time.
On such platforms using CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC define
directly introduces timing errors.

This commit replaces CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC by the call
to inline function sys_clock_hw_cycles_per_sec() which always returns
correct frequency of the system clock.

Signed-off-by: Piotr Zięcik <piotr.ziecik@nordicsemi.no>
2019-07-24 15:10:02 +02:00
Alberto Escolar Piedras f16ea52e11 native_posix: Replace system timer driver
The native_posix timer driver was still using the
legacy timer API.
Replace it with a new version, which is aligned with
the new kernel<->system timer driver API,
and which has TICKLESS_CAPABLE support

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2019-07-15 14:15:16 +02:00
Wentong Wu f4ff0a66b2 driver: timer: loapic_timer: fix compile issue
fix compile issue when DEVICE_POWER_MANAGEMENT enabled.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2019-07-03 11:56:40 -04:00
Andy Ross 0baf72e1c7 drivers/timer/nrf_rtc_timer: Fix round-up for rapid tick rates
When the tick rate was less than MIN_DELAY, bumping a "too soon"
expiration by just one tick may not be enough and we could
theoretically miss the counter.

Instead, eliminate the MIN_DELAY computation and write to the spec:
NRF guarantees that the RTC will generate an interrupt for a
comparator value two cycles in the future.  And further, we can test
at the set point to see if we "just missed" the interrupt (i.e. zero
cycles delay) and flag a synchronous interrupt.  So we only need to
miss a requested interrupt now for the special case of exactly one
cycle in the future, and then we're only late by one cycle.  That's
optimal.

Also fixes an off-by-one in the next cycle computation.  By API
convention, an ticks argument of one or less means "at the next tick"
and not "right now".  So we need to add one to the target cycle to
avoid incorrectly triggering a synchronous interrupt.  This was a
non-issue when a tick is longer than a hardware cycle but is needed
now.

Also handles the edge case with zero latency interrupts (which are
unmaskable) which might mess up timing.  This was always a problem,
but we're more sensitive now and it's comparatively more likely to
occur.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-07-02 22:52:29 -04:00
Charles E. Youse 0325a3d972 arch/x86: eliminate include/arch/x86/irq_controller.h
The MVIC is no longer supported, and only the APIC-based interrupt
subsystem remains. Thus this layer of indirection is unnecessary.

This also corrects an oversight left over from the Jailhouse x2APIC
implementation affecting EOI delivery for direct ISRs only.

Signed-off-by: Charles E. Youse <charles.youse@intel.com>
2019-07-02 19:30:00 -04:00
Andy Ross 1db9f18a08 kernel/timeout: Remove "clock_always_on", replace with "SLOPPY_IDLE"
This is an oddball API.  It's untested.  In fact testing its proper
behavior requires very elaborate automation (you need a device outside
the Zephyr hardware to measure real world time, and a mechanism for
getting the device into and out of idle without using the timer
driver).  And this makes for needless difficulty managing code
coverage metrics.

It was always just a hint anyway.  Mark the old API deprecated and
replace it with a kconfig tunable.  The effect of that is just to
change the timeout value passed to the timer driver, where we can
manage code coverage metrics more easily (only one driver cares to
actually support this feature anyway).

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-06-28 14:24:56 -07:00
Anas Nashif a2fd7d70ec cleanup: include/: move misc/util.h to sys/util.h
move misc/util.h to sys/util.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif 17ddd1714c cleanup: include/: move clock_control.h to drivers/clock_control.h
move clock_control.h to drivers/clock_control.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif 190e368275 cleanup: include/: move power.h to power/power.h
move power.h to power/power.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif 0eee0a3c6c drivers: apic_timer: fix include of system_timer.h
Fix path for system_timer.h and loapic.h, we moved it to
include/drivers/timer/ and include/drivers/interrupt_controller/

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 10:51:32 -07:00
Charles E. Youse c17c298749 drivers/timer/apic_timer.c: new local APIC timer for TICKLESS_KERNEL
The existing local APIC timer driver (loapic_timer.c) has bitrotted
and doesn't support TICKLESS_KERNEL, which is the preferred mode of
operation. This patch introduces a completely new driver, called
the APIC timer driver - the name is changed to allow the drivers to
continue to coexist in the short term, and also because "APIC timer"
isn't ambiguous (the I/O APICs do not have timers).

This driver makes no attempt to work with the MVIC timer as the
previous version did, because MVIC support is deprecated.

Signed-off-by: Charles E. Youse <charles.youse@intel.com>
2019-06-27 07:20:54 -04:00
Anas Nashif 68c389c1f8 include: move system timer headers to include/drivers/timer/
Move internal and architecture specific headers from include/drivers to
subfolder for timer:

   include/drivers/timer

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-25 15:27:00 -04:00
Charles E. Youse 3dc7c7a6ea drivers/interrupt_controller/mvic.c: remove MVIC interrupt controller
The Quark D2000 is the only x86 with an MVIC, and since support for
it has been dropped, the interrupt controller is orphaned. Removed.

Signed-off-by: Charles E. Youse <charles.youse@intel.com>
2019-06-25 08:06:43 -04:00
Kumar Gala f20d2b6f41 drivers: rv32m1: remove bogus IRQ_PRI related defines
The defines related to IRQ priority don't exist and aren't used.  So
just pass 0 to IRQ_CONNECT for the priority field.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-06-24 07:22:27 -04:00
Kumar Gala dba65ce47c drivers: Update DT IRQ alias defines
The defines should have had a _0 on them, now that we generate the
proper defines, fixup the cases that used that old scheme.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-06-21 07:53:05 -05:00
Anas Nashif f2cb20c772 docs: fix misspelling across the tree
Found a few annoying typos and figured I better run script and
fix anything it can find, here are the results...

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-19 15:34:13 -05:00
Kumar Gala a2693975d7 dts: Convert from DT_<COMPAT>_<INSTANCE>_<PROP> to DT_INST...
Change code from using now deprecated DT_<COMPAT>_<INSTANCE>_<PROP>
defines to using DT_INST_<INSTANCE>_<COMPAT>_<PROP>.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-06-14 08:02:15 -05:00
Charles E. Youse e9f6cb2594 drivers/timer/loapic_timer.c: migrate to new local APIC accessors
More clearly differentiate MVIC vs. APIC timer code, and use new APIC
accessors in include/drivers/loapic.h. Remove extraneous comments, and
other light cleanup work.

This driver is in need of a serious overhaul -- despite appearing to
have support for TICKLESS_KERNEL and DEVICE_POWER_MANAGEMENT, bitrot
has taken its toll and the driver will not build with these enabled.
These should be removed or made to work... but not in this patch.

Old x2APIC-related accessors in kernel_arch_func.h are eliminated.

Signed-off-by: Charles E. Youse <charles.youse@intel.com>
2019-06-08 15:41:36 -04:00
Charles E. Youse 0fe4e1b3a8 arch/x86: x2APIC support is not specific to jailhouse
Simple renaming and Kconfig reorganization. Choice of local APIC
access method isn't specific to the Jailhouse hypervisor.

Signed-off-by: Charles E. Youse <charles.youse@intel.com>
2019-06-08 15:41:36 -04:00
Piotr Zięcik 2af4c1575b drivers: litex_timer: Do not hard code tick rate
The litex_timer driver used hard coded tick rate (set to 100 ticks
per second). This commit replaces the fixed value with a call to
system function which takes under account system configuration.

Signed-off-by: Piotr Zięcik <piotr.ziecik@nordicsemi.no>
2019-05-30 11:21:44 -04:00
Filip Kokosinski c0c3cdfc57 drivers: timer: add LiteX timer driver
Add LiteX timer driver with bindings for this device.

Signed-off-by: Filip Kokosinski <fkokosinski@internships.antmicro.com>
Signed-off-by: Mateusz Holenko <mholenko@antmicro.com>
2019-05-15 12:52:16 -05:00
Derek Hageman b6cc998776 drivers: timer: sam0: Remove RTC defines from dts_fixup.h
Move SAM0 flash to use the raw defines generated from the DTS
parsing.

Signed-off-by: Derek Hageman <hageman@inthat.cloud>
2019-05-03 08:46:57 -05:00
Ioannis Glaropoulos 236c5ac28f soc: arm: remove default selection of system timer for ARM platforms
We shall not enable by default a system timer in ARM
platforms, namely the SysTick, the Nordic, or the SAM0
RTC timer, simply by assessing the hardware capabilities
(e.g. by conditioning on CPU_CORTEX_M_HAS_SYSTICK).
Instead, now, all ARM platforms needs to explicitly set
their system timer module. Note that this has already
been the case for ca 80% of the ARM platforms.

This clean-up allows us to decouple HW capabilities from
system configuration (for example, Nordic platforms may
enable option CPU_CORTEX_M_HAS_SYSTICK, and still use
the platform-specific RTC timer for system timing).

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-04-25 23:09:23 -07:00
Ioannis Glaropoulos 894eca5e4f soc: arm: rename CPU_HAS_SYSTICK to CPU_CORTEX_M_HAS_SYSTICK
This commit renames the symbol CPU_HAS_SYSTICK to
CPU_CORTEX_M_HAS_SYSTICK, to look similar to all
other CPU_CORTEX_M_HAS_ options, and moves the
K-config symbol definition from arm/core/Kconfig to
arm/core/cortex_m/Kconfig.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-04-25 23:09:23 -07:00
Peter A. Bigot 68a950a87b drivers: timer: nrf: remove unnecessary event feature
Enabling the RTC event is intended to support peripheral-to-peripheral
interconnects, so introduces a request for HFCLK and PCLK16M when the
event is triggered.  This specific event is never used with PPI so
enabling events apparently does nothing but increase power consumption.

Closes #15513

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-04-25 08:40:46 -05:00
Ioannis Glaropoulos 4a1ebfa049 drivers: timer: SysTick: revert clearing pending events
Clearing the pending IRQs when resetting the timeout fixes the
forward time drifting, but the change needs more investigation
until we are sure this won't break kernel time management.
Reverting the change to get 1.14 release out.

This reverts commit 2895da02a4.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-04-15 20:37:44 -04:00
Ioannis Glaropoulos 2895da02a4 drivers: timer: systick: clear pending events when resetting timeout
In the unlucky scenario of a SysTick event (wrap) occurring
while we re-program the last_load value, the SysTick ISR
will run immediately after we unlock interrupts. In that
case the timeout we have just configured will expire
instantaneously, leading to operations being executed
much earlier than expected. Avoid this by clearing possibly
pending SysTick exceptions (writing 1 to ICSR.PENDSTCLR).

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-04-11 13:50:41 -04:00
Ioannis Glaropoulos a0a861bfd7 drivers: timer: systick: fix off-by-one setting in tickless mode
When the counter reaches zero, it reloads the value in
SYST_RVR on the next clock edge. This means that if the
LOAD value is N, the interrupt ("tick") is triggered
every N+1 cycles. Therefore, when we operate in tickless
mode, and we want to schedule the next timeout, we need
to configure the LOAD value with last_load - 1, in order
to get an event in last_load cycles.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-04-11 13:50:41 -04:00
Ioannis Glaropoulos b1b4ec126d drivers: timer: systick: fix off-by-one setting
When the counter reaches zero, it reloads the value in
SYST_RVR on the next clock edge. This means that if the
LOAD value is N, the interrupt ("tick") is triggered
every N+1 cycles. Therefore, when we operate in non-
tickless mode, we need to configure the LOAD value
with CYC_PER_TICK - 1, in order to get an event
every CYC_PER_TICK cycles.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-04-11 13:50:41 -04:00
Andy Ross 110cab8aa3 drivers/timer/systick: Improve clock slippage under irq_lock load
The SysTick logic looked logically sound, but it was allowing us to
set a LOAD value as low as 512 cycles.  On other platforms, that
minimum future interrupt delay is there to protect the "read, compute,
write, unmask" cycle that sets the new interrupt from trying to set
one sooner than it can handle.

But with SysTick, that value then becomes the value of the LOAD
register, which is effectively the frequency with which timer
interrupts arrive.  This has two side effects:

1. It opens up the possibility that future code that masks interrupts
   longer than 512 cycles will miss more than one overflow, slipping
   the clock backward as viewed by z_clock_announce().

2. The original code only understood one overflow cycle, so in the
   event we do set one of these very near timeouts and then mask
   interrupts, we'll only add at most one overflow to the "elapsed()"
   time, slipping the CURRENT time backward (actually turning it into
   a non-monotonic sawtooth which would slip every LOAD cycle) and
   thus messing up future scheduled interrupts, slipping those forward
   relative to what the ISR was counting.

This patch simplifies the logic for reading SysTick VAL/CTRL (the loop
wasn't needed), handles the case where we see more than one overflow,
and increases the MIN_DELAY cycles from 512 to 1/16th of a tick.

Fixes #15216

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-04-10 22:05:57 -04:00
Anas Nashif 3ae52624ff license: cleanup: add SPDX Apache-2.0 license identifier
Update the files which contain no license information with the
'Apache-2.0' SPDX license identifier.  Many source files in the tree are
missing licensing information, which makes it harder for compliance
tools to determine the correct license.

By default all files without license information are under the default
license of Zephyr, which is Apache version 2.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-04-07 08:45:22 -04:00
Patrik Flykt 97b3bd11a7 drivers: Rename reserved function names
Rename reserved function names in drivers/ subdirectory. Update
function macros concatenatenating function names with '##'. As
there is a conflict between the existing gpio_sch_manage_callback()
and _gpio_sch_manage_callback() names, leave the latter unmodified.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2019-04-03 17:31:00 -04:00
Patrik Flykt 24d71431e9 all: Add 'U' suffix when using unsigned variables
Add a 'U' suffix to values when computing and comparing against
unsigned variables.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2019-03-28 17:15:58 -05:00
Wayne Ren 7051eecaed arch: arc: make the boot time more accurate
* start timer0 when cpu runs at __start
* add an offset to cycle_count

Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2019-03-19 08:46:30 -04:00
Andy Ross 222fd8f1ab drivers/timer/nrf_rtc_timer: Revert recent changes
Per #13610, recent changes to this driver seem to have introduced
unexpected latency regressions.  This patch effectively reverts these
patches which changed the meat of the driver:

ac36886e62 drivers: nrf: timer: add inline qualifier where
           inlining is intended
084363a0dc drivers: timer: nrf: refactor for speed and correctness
71882ff8c4 drivers: timer: nrf: drop unnecessary counter mask
4b24e88fa4 drivers: timer: nrf: use irq_lock instead of spinlock

While backporting these seemingly unrelated hygiene patches:

7cbdb6c5c0 drivers/timer: Restore non-tickless tick count behavior
d30c9aeafd drivers: nrf_power_clock: Migrate to DTS.
75f77db432 include: misc: util.h: Rename min/max to MIN/MAX

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-03-15 07:01:27 -05:00
Ramakrishna Pallala e1639b5345 device: Extend device_set_power_state API to support async requests
The existing device_set_power_state() API works only in synchronous
mode and this is not desirable for devices(ex: Gyro) which take
longer time (few 100 mSec) to suspend/resume.

To support async mode, a new callback argument is added to the API.
The device drivers can asynchronously suspend/resume and call the
callback function upon completion of the async request.

This commit adds the missing callback parameter to all the drivers
to make it compliant with the new API.

Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
2019-03-14 14:26:15 +01:00
Andy Ross 0a2d2413e0 drivers/timer/hpet: Add noop SMP initialization function
This is intended to initialize CPU-local timer devices, but HPET is
global so we have nothing to do.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-03-13 19:15:20 +01:00
Thomas Stenersen a3fc1a1f53 drivers: nrf5: Don't force specific drivers from soc/arm/nordic_nrf
Redefining the config will not let another (out-of-source) driver be
chosen instead of the default. The driver is practically forced by the
soc settings. This commit moves default settings from soc/arm/nordic_nrf
into the drivers themselves.

Signed-off-by: Thomas Stenersen <thomas.stenersen@nordicsemi.no>
2019-03-12 19:42:40 +01:00
Patrik Flykt 4344e27c26 all: Update reserved function names
Update reserved function names starting with one underscore, replacing
them as follows:
   '_k_' with 'z_'
   '_K_' with 'Z_'
   '_handler_' with 'z_handl_'
   '_Cstart' with 'z_cstart'
   '_Swap' with 'z_swap'

This renaming is done on both global and those static function names
in kernel/include and include/. Other static function names in kernel/
are renamed by removing the leading underscore. Other function names
not starting with any prefix listed above are renamed starting with
a 'z_' or 'Z_' prefix.

Function names starting with two or three leading underscores are not
automatcally renamed since these names will collide with the variants
with two or three leading underscores.

Various generator scripts have also been updated as well as perf,
linker and usb files. These are
   drivers/serial/uart_handlers.c
   include/linker/kobject-text.ld
   kernel/include/syscall_handler.h
   scripts/gen_kobject_list.py
   scripts/gen_syscall_header.py

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2019-03-11 13:48:42 -04:00
Maureen Helm d5ce82b01a drivers: timer: Fix build warnings in rv32m1 driver
Converts the rv32m1 timer driver to use 'DT_' prefixed defines instead
of deprecated non-prefixed defines.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2019-03-05 08:18:52 -05:00
Andy Ross 7cbdb6c5c0 drivers/timer: Restore non-tickless tick count behavior
The newer series of timer drivers will compare counters vs. the last
tick boundary to compute a number of ticks to announce to the kernel.
In the case of CONFIG_TICKLESS=n, this actually represents a change of
behavior from our old scheme where "ticks" always reflected the number
of interrupts received.

The distinction only matters when an interrupt is delayed more than a
full tick, of course.  But that actually makes a difference to some
timekeeping code.  Restore the old behavior.

This also has the benefit of further reducing code size when !TICKLESS
and improving performance of the ISR by removing the division
(remember Cortex M0 has no hardware divide!).

Fixes #12409

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-02-28 16:11:02 -08:00
Piotr Zięcik d30c9aeafd drivers: nrf_power_clock: Migrate to DTS.
This commit migrates the nrf_power_clock driver to DTS.

Signed-off-by: Piotr Zięcik <piotr.ziecik@nordicsemi.no>
2019-02-25 17:51:24 +01:00
Carlos Stuart 75f77db432 include: misc: util.h: Rename min/max to MIN/MAX
There are issues using lowercase min and max macros when compiling a C++
application with a third-party toolchain such as GNU ARM Embedded when
using some STL headers i.e. <chrono>.

This is because there are actual C++ functions called min and max
defined in some of the STL headers and these macros interfere with them.
By changing the macros to UPPERCASE, which is consistent with almost all
other pre-processor macros this naming conflict is avoided.

All files that use these macros have been updated.

Signed-off-by: Carlos Stuart <carlosstuart1970@gmail.com>
2019-02-14 22:16:03 -05:00
Krzysztof Chruscinski 5bfe8612a2 drivers: timer: Fix broken dependency for nrf_rtc_timer
nrf_rtc_timer was selecting counter RTC1 instance even though it
is not using counter API at all.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2019-02-07 16:14:00 -05:00
Krzysztof Chruscinski 5d0d5c0a7a drivers: counter: Counter API implementation for nRF Series (RTC).
Shim for counter API using nrfx_rtc driver.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2019-02-07 16:14:00 -05:00
Peter A. Bigot e03c3d8f79 drivers: timer: conflict RTC timer with RTC1 counter
The system timer uses RTC1, but does not implement the counter API with
it.  Instead of auto-enabling the counter API on the system timer make
the two conflict until/unless both APIs are supported by the peripheral.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-02-07 16:14:00 -05:00
Krzysztof Chruscinski da0d9bab2d drivers: counter: Counter API implementation for nRF Series (RTC).
Shim for counter API using nrfx_rtc driver.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2019-02-07 16:14:00 -05:00
Bobby Noelte 666cf22c60 arch: allow system clock driver selection for cortex m
The selection of the Cortex M systick driver to be used
as a system clock driver is controlled by
CONFIG_CORTEX_M_SYSTICK.

To replace it by another driver CONFIG_CORTEX_M_SYSTICK
must be set to 'n'. Unfortunately this also controls
the interrupt vector for the systick interrupt. It is
now routed to __reserved. More bad the interrupt vector
can not be set by IRQ_CONNECT as it is one of the hard
coded interrupts in the interrupt table.

Route the hard coded systick interrupt to z_clock_isr
and make z_clock_isr a weak symbol that can be overwritten
by an alternative systick system clock driver.

Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
2019-02-05 18:43:03 -06:00
Anas Nashif a93651085e boards: remove pulpino board
This board is unmaintained and unsupported. It is not known to work and
has lots of conditional code across the tree that makes code
unmaintainable.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-01-31 22:47:18 -05:00
Wayne Ren c48971cc61 driver: arcv2_timer0: fixes and optimize the timer driver
* MIN_DELAY: 1024 -> 512
* optimzie some code sequence
* fix a bug in setting the new timer limit value
   * case: before set limit register with new value,
     if counter rolls back to 0, the limit value should be
     adjusted.

Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2019-01-31 06:37:32 -05:00
Daniel Leung d0ad419737 timer: xtensa: restore smp_timer_init()
The smp_timer_init() was removed during timer re-write.
This results in undefined references error during compilation
when CONFIG_SMP=y. So add it back so we can compile for SMP.
The logic is updated from the previous version to the latest
in the driver.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2019-01-31 06:15:39 -05:00
Martin Benda 9653e15139 drivers: timer: Add RTC-based system timer for Atmel SAM0 series MCU
Add sam0_rtc_driver that implements system timer API on top of the RTC
and can be used as a replacement for the default systick timer.

Signed-off-by: Martin Benda <martin.benda@omsquare.com>
2019-01-29 17:58:05 +01:00
Marti Bolivar 58d8afb476 interrupt_controller: RV32M1: add intmux driver / DT bindings
Add a level 2 interrupt controller for the RV32M1 SoC. This uses the
INTMUX peripheral.

As a first customer, convert the timer driver over to using this,
adding nodes for the LPTMR peripherals. This lets users select the
timer instance they want to use, and what intmux channel they want to
route its interrupt to, using DT overlays.

Signed-off-by: Marti Bolivar <marti@foundries.io>
Signed-off-by: Mike Scott <mike@foundries.io>
2019-01-25 11:59:46 -05:00
Marti Bolivar 502d306630 soc: riscv32: add RV32M1 SoC as openisa_rv32m1
The OpenISA RV32M1 SoC has four CPU cores. Two of these are RISC-V
32-bit cores, which are named "RI5CY" and "ZERO-RISCY". (The other two
cores are ARM Cortex-M0+ and -M4.) This patch adds basic SoC
enablement for the RISC-V cores:

- basic dtsi, to be extended as additional drivers are added
- SoC definition in soc/riscv32/openisa_rv32m1 for RI5CY / ZERO-RISCY
- system timer driver for RI5CY, based on LPTMR0 peripheral

The timer driver will be generalized a bit soon once proper
multi-level interrupt support is available.

Emphasis is on supporting the RI5CY core as the more capable of the
two; the ZERO-RISCY SoC definitions are a good starting point, but
additional work setting up a dtsi and initial drivers is needed to
support that core.

Signed-off-by: Marti Bolivar <marti@foundries.io>
Signed-off-by: Michael Scott <mike@foundries.io>
2019-01-25 11:59:46 -05:00
Peter A. Bigot ac36886e62 drivers: nrf: timer: add inline qualifier where inlining is intended
Not necessary with gcc, and Zephyr is inconsistent about using the
qualifier, but making the intent explicit is a good thing.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-01-23 21:38:09 +01:00