Commit graph

187 commits

Author SHA1 Message Date
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
Flavio Ceolin a1bfaa907c drivers: counter: stm32: Fix possible overflow
Cast ts to u32_t could cause an overflow in that multiplication, since
time_t is 8 bytes it is not necessary to cast the multiplication's
result too.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2019-03-26 07:48:43 -05:00
Erwan Gouriou a5cb920227 driver/counter: rtc_stm32: Incorrect time_t offset
When converted to time_t, RTC init date was missing 100 years
offset, as time_t starts in 1900 while RTC starts in 2000.
Besides, tm_mon calculation was wrong by 1 month as allowed range
is 0-11 and provided in range 1-12.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2019-03-26 07:29:08 -05:00
Erwan Gouriou 239e397167 drivers/counter: stm32: Fix time_t usage
Following upgrade of newlib version in SDK 0.10.0,
time_t changed from 4 to 8 bytes structure.
As a consequence, ts requires a cast to u32_t before conversion
to us to avoid overflow.
Additionally, add a comment on RTC init value and
fix a minor alignment issue.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2019-03-15 09:26:12 -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
Ulf Magnusson 53376394b7 kconfig: Remove blank lines at the beginning/end of files
Maybe this is some "just in case" thing that got copied around. There's
no need to have a blank line at the beginning or end of Kconfig files.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-13 07:29:42 -05: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
Ulf Magnusson 92a1f2ca72 kconfig: drivers: counter: Remove redundant COUNTER deps.
These symbols appear within an 'if COUNTER' (in
drivers/counter/Kconfig).

'if FOO' is just shorthand for adding 'depends on FOO' to each item
within the 'if'. Dependencies on menus work similarly. There are no
"conditional includes" in Kconfig, so 'if FOO' has no special meaning
around a source. Conditional includes wouldn't be possible, because an
if condition could include (directly or indirectly) forward references
to symbols not defined yet.

Tip: When adding a symbol, check its dependencies in the menuconfig
('ninja menuconfig', then / to jump to the symbol). The menuconfig also
shows how the file with the symbol got included, so if you see
duplicated dependencies, it's easy to hunt down where they come from.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-09 10:00:35 -05:00
Krzysztof Chruscinski f563ca338f drivers: counter: Fix handling of relative alarms on nrf platform
In case of relative alarm, nrf counter driver for TIMER peripheral
was not handling correctly case when new value exceeded top value.
Additionally, RTC implementation has been refactored to use similar
code for calculating alarm ticks.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2019-03-07 15:50:10 +01:00
Piotr Zięcik 05fa9c8318 drivers: counter_nrfx_timer: Port driver to DTS
This commit updates the counter_nrfx_timer driver in order to
use device tree infrastructure.

Signed-off-by: Piotr Zięcik <piotr.ziecik@nordicsemi.no>
2019-03-01 19:46:57 +01:00
Piotr Zięcik 298b841873 drivers: counter_nrfx_rtc: Port driver to DTS
This commit updates the counter_nrfx_rtc driver in order to
use device tree infrastructure.

Signed-off-by: Piotr Zięcik <piotr.ziecik@nordicsemi.no>
2019-03-01 19:46:57 +01:00
Savinay Dharmappa 5307953091 drivers: counter: Modify set top value api.
patch modifies the set top value api to return error only
when ticks passed from application is not equal top value
supported by hardware.

Signed-off-by: Savinay Dharmappa <savinay.dharmappa@intel.com>
2019-02-27 12:33:53 -08:00
Ulf Magnusson 40436f730b kconfig: Use a short consistent prompt style
Same change as in commit 8cf8db3a73 ("Kconfig: Use a short, consistent
style for prompts"), fixing stuff that got introduced since then.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-02-27 09:23:30 +01: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
Kumar Gala d6a19afb29 drivers: counter: mcux: Fix sanitycheck test build issue
The generated defines RTC_0_CLOCK_FREQUENCY and RTC_0_PRESCALER are
maked as deprecated by dts generation.  This causes a build warning and
an error during sanitycheck runs.  Replace with the DT_ prefixed
versions that are not deprecated.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-02-11 09:40:27 -06:00
Anas Nashif 8e5ac20665 counter: qmsi: use correct function prototype
rtc_qmsi_cancel_alarm requires channel id argument.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-02-08 08:56:45 -05:00
Savinay Dharmappa 60348e8081 drivers: counter: incorporate changes of api name and signature.
patch incorporates new api name and signature changes.

Signed-off-by: Savinay Dharmappa <savinay.dharmappa@intel.com>
2019-02-08 08:56:45 -05:00
Piotr Mienkowski 8a86b5aaac api: counter: rename counter_disable_channel_alarm()
The function to set channel alarm is called counter_set_channel_alarm.
To match the name of the function performing the reverse operation this
commit renames counter_disable_channel_alarm() function to
counter_cancel_channel_alarm().

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2019-02-08 10:47:40 +01:00
Erwan Gouriou d2e305491f soc: stm32: Convert CONFIG_RTC leftover to DT_
Convert CONFIG_RTC_0_IRQ_PRI to DT_ namespace.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2019-02-07 16:14:00 -05:00
Erwan Gouriou 3074e393db drivers/counter: stm32 rtc: Use dts to get RTC clock information
RTC clock information should be provided by dts files

Fixes #10451

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2019-02-07 16:14:00 -05:00
Erwan Gouriou 458226e1f7 drivers/counter: stm32: Provide STM32 RTC driver using counter API
Provides a STM32 RTC driver using new counter API.
Driver does not support wrap related functions (set, get, ..)

Fixes #11373

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2019-02-07 16:14:00 -05:00
Kumar Gala 7809970c8a drivers: counter: cmsdk: Convert to new DT_<COMPAT>_<INSTANCE> defines
Convert cmsdk driver to use new defines so we can remove the
dts_fixup.h code for it.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-02-07 16:14:00 -05:00
Kumar Gala 36427f8bbb drivers: timer: Move Dual Timer API to unified interface
The CMSDK Dual Timer can be used as a timer or as a counter.
The unified interface proposed in #8340 unifies counter.h and rtc.h to
provide a common interface.

This patch modifies the timer implementation of the dual timer to
make it compliant with the new proposed interface.

Signed-off-by: Vincenzo Frascino <vincenzo.frascino@linaro.org>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-02-07 16:14:00 -05:00
Kumar Gala 6fca18de60 drivers: timer: Move Timer API to unified interface
The CMSDK Timer can be used as a timer or as a counter.
The unified interface proposed in #8340 unifies counter.h and rtc.h to
provide a common interface.

This patch modifies the timer implementation of the single timer to
make it compliant with the new proposed interface.

Signed-off-by: Vincenzo Frascino <vincenzo.frascino@linaro.org>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-02-07 16:14:00 -05:00
Maureen Helm 210a71f108 tests: counter: Enable debug logging
Enables debug logging in the counter_basic_api test. Fixes a build error
in the nrf counter drivers when logging is enabled.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2019-02-07 16:14:00 -05:00
Maureen Helm eb338915bb drivers: counter: Introduce mcux rtc shim
Adds a shim layer around the mcux rtc driver to adapt it to the zephyr
counter interface. Portions of this driver are reused from the existing
rtc driver in drivers/rtc/rtc_mcux.c.

The hardware supports a single alarm only and a fixed wrap value.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2019-02-07 16:14:00 -05:00
Krzysztof Chruscinski 7de898d337 drivers: counter: Fix default top value callback in counter_nrfx_rtc.c
In case of default top value, driver was calling top value
callback only on the first period. This was not expected behavior.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2019-02-07 16:14:00 -05:00
Stanislav Poboril f51ef0551c imx: Add IMX EPIT driver for i.MX socs
Add shim driver for i.MX EPIT (Enhanced Periodic Interrupt Timer)
peripheral which can be used for i.MX6SoloX, i.MX7D and other i.MX socs.

Origin: Original

Signed-off-by: Stanislav Poboril <stanislav.poboril@nxp.com>
2019-02-07 16:14:00 -05:00
Krzysztof Chruscinski 708f08a4be drivers: counter: Rename wrap to top_value
Renamed:
- counter_set_wrap to counter_set_top_value
- counter_get_wrap to counter_get_top_value
- counter_get_max_wrap to counter_get_max_top_value

Updated nRF implementations and counter test.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2019-02-07 16:14:00 -05:00
Krzysztof Chruscinski b745355315 drivers: counter: Add user_data to alarm callback
Modify alarm callback to return user_data and channel_id.
Set_alarm and disable_alarm updated accordingly. Renamed
counter_*_ch_alarm to counter_*_channel_alarm. Updated test
and nrf implementations.

Updated doxygen comments.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2019-02-07 16:14:00 -05:00
Peter A. Bigot 49c8325339 drivers: counter: nrfx: update to newer HAL API
Upstream trunk moved to a newer Nordic HAL that changed file and
constant names.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
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
Peter A. Bigot 889a55c86a drivers: counter: nrf: make name configuration consistent
Using `COUNTER_2_NAME` when all other properties are
`COUNTER_TIMER2_foo` is confusing.  Make the names consistent.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-02-07 16:14:00 -05:00
Savinay Dharmappa 0f492149ad rtc: rename CONFIG_RTC_0_NAME to DT_RTC_0_NAME.
patch renames CONFIG_RTC_0_NAME to DT_RTC_0_NAME.

Signed-off-by: Savinay Dharmappa <savinay.dharmappa@intel.com>
2019-02-07 16:14:00 -05:00
Savinay Dharmappa aa15f3973a drivers: rtc_qmsi: Move rtc driver apis to unified interface
patch modifies rtc apis to unified interface.

Signed-off-by: Savinay Dharmappa <savinay.dharmappa@intel.com>
2019-02-07 16:14:00 -05:00
Savinay Dharmappa 9cd7803579 drivers: counter: Move AON and AONPT driver api to unified interface
patch modifies AON and AONPT driver api to unified interface

Signed-off-by: Savinay Dharmappa <savinay.dharmappa@intel.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
Krzysztof Chruściński 6b4ff1252a drivers: counter: Counter API implementation for nRF Series (TIMER).
Shim for counter API using nrfx_timer driver.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2019-02-07 16:14:00 -05:00
Patrik Flykt 8ff96b5a57 drivers: Add 'U' to unsigned variable assignments
Add 'U' to a value when assigning it to an unsigned variable.
MISRA-C rule 7.2

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2018-12-04 22:51:56 -05:00
Andrzej Głąbek 20202902f2 dts_fixups: Use DT_ prefix in all defined labels not related to Kconfig
These changes were obtained by running a script  created by
Ulf Magnusson <Ulf.Magnusson@nordicsemi.no> for the following
specification:

1. Read the contents of all dts_fixup.h files in Zephyr
2. Check the left-hand side of the #define macros (i.e. the X in
   #define X Y)
3. Check if that name is also the name of a Kconfig option
   3.a If it is, then do nothing
   3.b If it is not, then replace CONFIG_ with DT_ or add DT_ if it
       has neither of these two prefixes
4. Replace the use of the changed #define in the code itself
   (.c, .h, .ld)

Additionally, some tweaks had to be added to this script to catch some
of the macros used in the code in a parameterized form, e.g.:
- CONFIG_GPIO_STM32_GPIO##__SUFFIX##_BASE_ADDRESS
- CONFIG_UART_##idx##_TX_PIN
- I2C_SBCON_##_num##_BASE_ADDR
and to prevent adding DT_ prefix to the following symbols:
- FLASH_START
- FLASH_SIZE
- SRAM_START
- SRAM_SIZE
- _ROM_ADDR
- _ROM_SIZE
- _RAM_ADDR
- _RAM_SIZE
which are surprisingly also defined in some dts_fixup.h files.

Finally, some manual corrections had to be done as well:
- name##_IRQ -> DT_##name##_IRQ in uart_stm32.c

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2018-11-13 10:44:42 -06:00
Flavio Ceolin 67ca176754 headers: Fix headers across the project
Any word started with underscore followed by and uppercase letter or a
second underscore is a reserved word according with C99.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2018-09-17 15:49:26 -04:00
Ulf Magnusson 8cf8db3a73 Kconfig: Use a short, consistent style for prompts
Consistently use

    config FOO
            bool/int/hex/string "Prompt text"

instead of

    config FOO
            bool/int/hex/string
            prompt "Prompt text"

(...and a bunch of other variations that e.g. swapped the order of the
type and the 'prompt', or put other properties between them).

The shorthand is fully equivalent to using 'prompt'. It saves lines and
avoids tricking people into thinking there is some semantic difference.

Most of the grunt work was done by a modified version of
https://unix.stackexchange.com/questions/26284/
how-can-i-use-sed-to-replace-a-multi-line-string/26290#26290, but some
of the rarer variations had to be converted manually.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-15 04:10:10 -07:00
Anas Nashif a2ad4b2dd1 drivers: qmsi: Fix types and u32_t/uint32_t conflicts
We have been mixing u32_t and uint32_t. Using u32_t when the API expects
something else.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-07-18 12:32:23 -04:00
Ulf Magnusson 8308a51930 drivers: counter: Kconfig: Remove redundant 'default n' 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, and is
inconsistent.

This will make the auto-generated Kconfig documentation have "No
defaults. Implicitly defaults to n." as well, which is clearer than
'default n if ...'

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-07-03 17:11:31 -04:00
Andrew Boie 8345e5ebf0 syscalls: remove policy from handler checks
The various macros to do checks in system call handlers all
implictly would generate a kernel oops if a check failed.
This is undesirable for a few reasons:

* System call handlers that acquire resources in the handler
  have no good recourse for cleanup if a check fails.
* In some cases we may want to propagate a return value back
  to the caller instead of just killing the calling thread,
  even though the base API doesn't do these checks.

These macros now all return a value, if nonzero is returned
the check failed. K_OOPS() now wraps these calls to generate
a kernel oops.

At the moment, the policy for all APIs has not changed. They
still all oops upon a failed check/

The macros now use the Z_ notation for private APIs.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2018-05-17 23:34:03 +03:00
Adithya Baglody b0db28b512 drivers: Cmake: Add __ZEPHYR_SUPERVISOR__ macro for driver files.
Normally a syscall would check the current privilege level and then
decide to go to _impl_<syscall> directly or go through a
_handler_<syscall>.
__ZEPHYR_SUPERVISOR__ is a compiler optimization flag which will
make all the system calls from the driver files directly link
to the _impl_<syscall>. Thereby reducing the overhead of checking the
privileges.

In the previous implementation all the source files would be compiled
by zephyr_source() rule. This means that zephyr_* is a catchall CMake
library for source files that can be built purely with the include
paths, defines, and other compiler flags that all zephyr source
files uses. This states that adding one extra compiler flag for only
one complete directory would fail.
This limitation can be overcome by using zephyr_libray* APIs. This
creates a library for the required directories and it also supports
directory level properties.
Hence we use zephyr_library* to create a new library with
macro _ZEPHYR_SUPERVISOR_ for the optimization.

Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
2018-05-15 17:48:18 +03:00
Leandro Pereira c200367b68 drivers: Perform a runtime check if a driver is capable of an operation
Driver APIs might not implement all operations, making it possible for
a user thread to get the kernel to execute a function at 0x00000000.

Perform runtime checks in all the driver handlers, checking if they're
capable of performing the requested operation.

Fixes #6907.

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2018-04-26 02:57:12 +05:30
Sebastian Bøe 0829ddfe9a kbuild: Removed KBuild
Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-08 20:00:22 -05:00
Sebastian Bøe 12f8f76165 Introduce cmake-based rewrite of KBuild
Introducing CMake is an important step in a larger effort to make
Zephyr easy to use for application developers working on different
platforms with different development environment needs.

Simplified, this change retains Kconfig as-is, and replaces all
Makefiles with CMakeLists.txt. The DSL-like Make language that KBuild
offers is replaced by a set of CMake extentions. These extentions have
either provided simple one-to-one translations of KBuild features or
introduced new concepts that replace KBuild concepts.

This is a breaking change for existing test infrastructure and build
scripts that are maintained out-of-tree. But for FW itself, no porting
should be necessary.

For users that just want to continue their work with minimal
disruption the following should suffice:

Install CMake 3.8.2+

Port any out-of-tree Makefiles to CMake.

Learn the absolute minimum about the new command line interface:

$ cd samples/hello_world
$ mkdir build && cd build
$ cmake -DBOARD=nrf52_pca10040 ..

$ cd build
$ make

PR: zephyrproject-rtos#4692
docs: http://docs.zephyrproject.org/getting_started/getting_started.html

Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-08 20:00:22 -05:00
Andrew Boie 678314b7b2 drivers: counter: add syscall handlers
counter_set_alarm() registers a callback and has been skipped.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-10-30 13:20:19 -07:00
Leandro Pereira 732424f065 drivers, net: Clean up semaphore initialization
Change the common "init with 0" + "give" idiom to "init with 1".  This
won't change the behavior or performance, but should decrease the size
ever so slightly.

This change has been performed mechanically with the following
Coccinelle script:

    @@
    expression SEM;
    expression LIMIT;
    expression TIMEOUT;
    @@

    - k_sem_init(SEM, 0, LIMIT);
    - k_sem_give(SEM);
    + k_sem_init(SEM, 1, LIMIT);

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2017-07-27 15:23:07 -04:00
Kumar Gala ccad5bf3e3 drivers: convert to using newly introduced integer sized types
Convert code to use u{8,16,32,64}_t and s{8,16,32,64}_t instead of C99
integer types.

Jira: ZEP-2051

Change-Id: I08f51e2bfd475f6245771c1bd2df7ffc744c48c4
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-21 10:06:48 -05:00
Juan Solano ee623d21de drivers: Remove unnecessary CONFIG_SYS_POWER_DEEP_SLEEP
This commit removes unnecessary CONFIG_SYS_POWER_DEEP_SLEEP protection
in shim drivers as QMSI 1.4 has introduced empty context save/restore
functions that can be called in Quark D2000, therefore keeping common
code at the shim driver level for Quark SE and D2000.

Change-Id: Ia2a466327f999668c6511c0193014e9151bff6ae
Signed-off-by: Juan Solano <juanx.solano.menacho@intel.com>
2017-02-10 16:27:32 +00:00
Juan Solano 48b8dddd95 aonpt_qmsi: Call QMSI 1.4 context save/restore functions.
This commit removes the aonpt interrupt masking/unmasking needed after
wake up as that functionality is now available in QMSI 1.4. The QMSI
save/restore functions are called instead.

Change-Id: I61a4a6952e959d0834904bbc8e1eb98092ae4b1c
Signed-off-by: Juan Solano <juanx.solano.menacho@intel.com>
2017-02-08 13:40:51 +00:00
Kuo-Lang Tseng 23b0074012 ext qmsi: Update to QMSI 1.4 RC2
Update the builtin QMSI code to 1.4 (RC2).
The below shim drivers were updated for API or interface changes:
- aio
- counter
- i2c_ss
- rtc
- wdt.

Also, arch soc specific power management code were updated.

Jira: ZEP-1572

Change-Id: Ibc8fae032a39ffb2c2c997f697835bc0208fd308
Signed-off-by: Jesus Sanchez-Palencia <jesus.sanchez-palencia@intel.com>
Signed-off-by: Kuo-Lang Tseng <kuo-lang.tseng@intel.com>
2017-02-08 11:59:12 +00:00
Vincenzo Frascino a93b88789b counter: cmsdk: Add Dualtimer as a Timer
This patch adds Dualtimer support to be used as a Timer.

Jira: ZEP-1300
Change-Id: If13143c8a8bdb07210daca66deca44710a18406f
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@linaro.org>
2017-01-23 15:15:54 -06:00
Vincenzo Frascino b1e02a594a counter: cmsdk: Add DualTimer as Counter
This patch adds Dualtimer to be used as a counter.

Jira: ZEP-1300
Change-Id: Ic4a2d89ec7fc0c0c2a0bc7f6d32d97637049faaf
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@linaro.org>
2017-01-23 15:15:54 -06:00
Vincenzo Frascino b11242d11f counter: cmsdk: Add Timer 0 and 1 as Timers
This patch adds Timer 0 and 1 to be used as timers.

Jira: ZEP-1300
Change-Id: I57112a8ed6f5daa22345e8807e9ebe87bb09e782
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@linaro.org>
2017-01-23 15:15:54 -06:00
Vincenzo Frascino d36543828b counter: cmsdk: Add clock control to TMR Counters.
This patch adds clock control to the counters based on Timer 0 and 1.

Jira: ZEP-1300
Change-Id: I14499a833fe9720496ab7905bc1466e9b03bb316
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@linaro.org>
2017-01-23 15:15:54 -06:00
Vincenzo Frascino 06f6d3837b counter: cmsdk: Add common interface
This patch adds a common interface for timers and counters based on
CMSDK APB timers.

Jira: ZEP-1300
Change-Id: I1f89f674d31410f19b651cd904c79f8d173a5357
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@linaro.org>
2017-01-23 15:15:53 -06:00
David B. Kinder ac74d8b652 license: Replace Apache boilerplate with SPDX tag
Replace the existing Apache 2.0 boilerplate header with an SPDX tag
throughout the zephyr code tree. This patch was generated via a
script run over the master branch.

Also updated doc/porting/application.rst that had a dependency on
line numbers in a literal include.

Manually updated subsys/logging/sys_log.c that had a malformed
header in the original file.  Also cleanup several cases that already
had a SPDX tag and we either got a duplicate or missed updating.

Jira: ZEP-1457

Change-Id: I6131a1d4ee0e58f5b938300c2d2fc77d2e69572c
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-01-19 03:50:58 +00:00
Kuo-Lang Tseng c0a546ed33 drivers: QMSI AON counter: Simplify driver reentrancy code
With the use of the IS_ENABLED macro
(https://gerrit.zephyrproject.org/r/#/c/9882), the driver
reentrancy code is simplified:

The original const variable which used to serve the purpose of
making the build to compile out the reentrancy code when the
reentrancy configuration flag is not enabled is no longer
needed as the use of the IS_ENABLED macro achieves the same result.
Also the original 3 wrapper functions around semaphores API are
not necessary; instead, just use the semaphore API directly.

Jira: ZEP-1251

Change-Id: I23552b77d19044dc94de443018759cb3ec10a52b
Signed-off-by: Kuo-Lang Tseng <kuo-lang.tseng@intel.com>
2017-01-17 19:04:46 +00:00
Vincenzo Frascino fb7d483fbe counter: cmsdk: Add Timer 0 and 1 as Counters
This patch adds Timer 0 and 1 to be used as counters.

Jira: ZEP-1300
Change-Id: I9d8b971d8a3d76eee2f9cc4600e95729d67717a3
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@linaro.org>
2016-12-06 10:31:45 -06:00
Vincenzo Frascino 73ee7e2d1c counter: Fix interface
With the current interface if multiple counters/timers are present in
the system, it is not possible to select from which one to read the
current value.

This patch fixes the behavior.

Change-Id: Id1ae1f2330e98d078f755c0b81c3b176e90b8389
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@linaro.org>
2016-11-30 14:39:10 +00:00
Vincenzo Frascino f0fd6c2634 counter: Refactor main Kconfig file
This patch refactors the main Kconfig file in order to align it with the
Zephyr code style and to make sure that each Kconfig configuration
portion is easily identifiable.

Change-Id: Iba83be8ae154df4b29ff423b4c3cc97a78c93e00
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@linaro.org>
2016-11-30 14:39:10 +00:00
Baohong Liu aa32a0914a drivers: counter: update to unified kernel
Use new semaphore APIs from unified kernel.

Change-Id: I05e4bf18da89c521e0de1216c074019dfed4ac37
Signed-off-by: Baohong Liu <baohong.liu@intel.com>
2016-11-09 20:27:42 +00:00
Andrew Boie 0b474eef9c kernel: deprecate old init levels
PRIMARY, SECONDARY, NANOKERNEL, MICROKERNEL init levels are now
deprecated.

New init levels introduced: PRE_KERNEL_1, PRE_KERNEL_2, POST_KERNEL
to replace them.

Most existing code has instances of PRIMARY replaced with PRE_KERNEL_1,
SECONDARY with POST_KERNEL as SECONDARY has had a longstanding bug
where the documentation specified SECONDARY ran before the kernel started
up, but actually ran afterwards.

Change-Id: I771bc634e9caf7f17dbf214a270bc9967eed7d32
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-11-09 17:59:44 +00:00
Iván Briano f4764fc348 counter qmsi: Enable the driver to work on ARC
Jira: ZEP-1030

Change-Id: I3f5e26f399a163467ec8371802b7472d87416940
Signed-off-by: Iván Briano <ivan.briano@intel.com>
2016-11-08 14:37:35 -02:00
Iván Briano b7f2fafdab counter qmsi: Update suspend/resume implementation
Update the suspend and resume hook after changes in QMSI and the resume
from sleep flow.

Change-Id: I14637b5a29b1942740012243fb8217803cf27e9b
Jira: ZEP-1004
Signed-off-by: Iván Briano <ivan.briano@intel.com>
2016-11-03 23:52:37 +00:00
Julien Delayen 74799a326e counter_qmsi_aonpt: Add get_pending_int API
For AON peripherals on Quark SE C1000, an API is needed
to retrieve the interrupt status after wake up.
This enables the application to know the wake source before
enabling again the interrupts.
Add this API to the periodic timer as this is a wake event
on Quark SE C1000.

Jira: ZEP-1188

Change-Id: I79976230bccb1f970b6856d28bf7428175167828
Signed-off-by: Julien Delayen <julien.delayen@intel.com>
2016-11-03 21:29:48 +00:00
Iván Briano 0094ab228d ext qmsi: Update to QMSI 1.3 release
Update the QMSI drop we maintain in Zephyr, and fix the build where
needed:

- QM_SCSS_INT is renamed to QM_INTERRUPT_ROUTER;
- every member of QM_INTERRUPT_ROUTER was renamed as well;
- QM_IRQ_* renamed too, mostly added _INT at the end;
- some isr functions were renamed to keep their names consistent;
- build for x86 needs to define QM_LAKEMONT, as QM_SENSOR was for ARC.

Change-Id: I459029ca0d373f6c831e2bb8ebd52402a55994d1
Signed-off-by: Iván Briano <ivan.briano@intel.com>
2016-10-31 13:26:06 +00:00
Marcus Shawcroft c172c0792a drivers/counter_qmsi_aonpt: Make driver_api structure const.
Change-Id: If20f5ad587b9398adf1827ec50970c789cfec1a1
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-10-25 18:45:48 +00:00
Marcus Shawcroft c5ec6bdc45 drivers/counter_qmsi_aon: Make driver_api structure const.
Change-Id: Ic455d13543d48700e10c051c85a3c46bddbe98fc
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-10-25 18:45:48 +00:00
Jesus Sanchez-Palencia 7c0fc99c79 ext qmsi: Update to QMSI 1.2 release
Update the QMSI drop we maintain in Zephyr, and fix the build where
needed:

- QM_USB_BASE is renamed to QM_USB_0_BASE;
- parameter int_en from qm_uart cfg struct was removed;
- driver's folder now has a new structure, fix makefiles accordingly;
- QM_WDT_MODE and related renamed to QM_WDT_CR_RMOD;
- QM_SCSS_AON renamed to QM_AONC.

Change-Id: Iffe9c66b7a3f2fe64418326e20ff0894149b3044
Signed-off-by: Jesus Sanchez-Palencia <jesus.sanchez-palencia@intel.com>
2016-10-18 23:26:01 +00:00
Iván Briano aba245daad drivers qmsi: Fix power management with reentrancy disabled
The new device control API added a 'device_power_state' variable to the
driver's data structure to keep track of the current power state set
for a device. This member variable is conditionally built into the
runtime data structure of each driver, but in some cases the whole data
structure is conditional on its respective API_REENTRANCY config
variable.

In those cases where the runtime data was previously used only for
reentrancy protection, the runtime data pointer used for device
initialization is NULL, and when power management is enabled, this
invalid pointer ends up dereferenced to get the device_power_state
member.

Make the declaration of the runtime data dependent on any of its
conditional members, and NULL only when all of those settings are
disabled.

Change-Id: I4f41e00ad8551a096db639e31d33f43752b6672f
Signed-off-by: Iván Briano <ivan.briano@intel.com>
2016-10-05 09:51:09 +00:00
amirkapl c490219d1e power_mgmt: Update sample and drivers according to new pm device API
Update the power sample and drivers with the new device driver power
management API using the existing logic

Jira: ZEP-954
Change-Id: Idd94232e458767635973e94e9fc673c01612c1e2
Signed-off-by: Amir Kaplan <amir.kaplan@intel.com>
2016-09-22 00:23:43 +00:00
Julien Delayen fa1d6fb1c9 aonpt_qmsi: Implement suspend and resume functions
In order to restore aonpt context after entering
SYS_PM_DEEP_SLEEP, suspend and resume functions
are called.

Only the interrupt mask is restored as it is reset by
the QMSI ROM and other registers are sticky.

The suspend/resume functionality is implemented in
the QMSI shim layer as a fast and temporary solution,
it will be removed and migrated to QMSI later.

Change-Id: I0dcd4552cd8c60ecb4eb650fc3ad85566b726a38
Signed-off-by: Julien Delayen <julien.delayen@intel.com>
2016-09-12 00:31:54 +00:00
Kuo-Lang Tseng aebe38465f qmsi: aon counter: Use locking mechanism to guard critical regions of API call
This will guard critical regions in the driver API so that the API
operation called from one thread (task or fiber) can complete
without the context being over-written by any simultaneous call
of the API from other thread (task or fiber).

The locking mechanism is by default disabled in the build. To enable it,
the following flag needs to be defined:

CONFIG_AON_API_REENTRANCY

Jira: ZEP-424
Change-Id: I1b0eae70a4ab97229931033153662874d7c4a68e
Signed-off-by: Kuo-Lang Tseng <kuo-lang.tseng@intel.com>
Signed-off-by: Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
2016-07-21 02:05:43 +00:00
Kumar Gala 9ec2f3be80 Cleanup whitespace in Kconfig files
Convert leading whitespace into tabs in Kconfig files.  Also replaced
double spaces between config and <prompt>.

Change-Id: I341c718ecf4143529b477c239bbde88e18f37062
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2016-05-25 13:28:07 -05:00
Anas Nashif f35d6e04e3 qmsi: update qmsi to 1.1 alpha
Change-Id: Ib35ebcb32954f764ef8e33f6a1c11ad9f63931bc
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-05-23 21:30:04 +00:00
Daniel Leung 0eca2bfc98 counter/qmsi: use new DEVICE_AND_API_INIT()
Change-Id: I3a2eb5bfc7f131c9a700b2d96674c238482ef164
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-04-28 01:03:38 +00:00
Anas Nashif f4feacf8b2 qmsi: aon_counters: use built-in qmsi driver
Change-Id: I5df98e9eacf429f017a094c861dcf54ab61566c1
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-04-22 20:46:29 -04:00
Andre Guedes 4048a59be3 counter: Fix returning code
Counter API and drivers were merged without fixing the new returning
error convention (errno.h codes). This patch fixes all occurrences of
DEV_* codes so -E* codes are used instead.

Change-Id: I85007e8565686b52121410badea547ed904460a0
Signed-off-by: Andre Guedes <andre.guedes@intel.com>
2016-03-23 15:55:11 +00:00
Baohong Liu 97c5df695e drivers: Quark AON counter and timer support
Quark AON counter and timer sub-drivers. They are based
on the QMSI drivers.

In order to enable this driver, the following options
must be set.
CONFIG_QMSI_DRIVERS
CONFIG_QMSI_INSTALL_PATH
CONFIG_COUNTER

Origin: Original

Change-Id: Idbeabfaef3408f4d645b0e64a337d7f5f0f357c7
Signed-off-by: Baohong Liu <baohong.liu@intel.com>
2016-03-17 08:59:04 -04:00
Baohong Liu ea5b4e4943 API: Add public counter API
Add the public API for counter devices and the drivers infrastructure.

Origin: Original

Change-Id: If100fbc9b3d119ce2be6c131bd64dbeb4fe346f2
Signed-off-by: Baohong Liu <baohong.liu@intel.com>
2016-03-17 08:59:04 -04:00