Commit graph

232 commits

Author SHA1 Message Date
Andrzej Głąbek 055a60e797 drivers: pwm: nrf: Correct dependency of PWM_NRFX Kconfig option
Correct it so that it is possible to use PWMs on nRF9160 as well,
not only on nRF5 family SoCs.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2019-01-21 10:13:34 +01:00
Varun Sharma 77c643a5a3 drivers: Modify drivers to use DEVICE_AND_API_INIT()
Modified drivers to use DEVICE_AND_API_INIT() instead of DEVICE_INIT()

This will make sure driver_api,is populated at build time and is exposed
to user space

Signed-off-by: Varun Sharma <varun.sharma@intel.com>
2019-01-15 10:39:34 -08:00
Gaute Gamnes 2d5ea10f31 drivers: pwm: nrf: Removed Kconfig prescaler option. Rewrite HW driver
1. Kconfig options clock_prescaler removed.
2. Rewritten pwm_nrfx.c nRF HW PWM driver.

Signed-off-by: Gaute Gamnes <gaute.gamnes@nordicsemi.no>
2018-12-11 15:18:14 +01:00
Gaute Gamnes d6e66d0453 drivers: pwm: nrf: Migrate Kconfig options to DT
1. Kconfig options CH pin removed.
2. Kconfig options CH inverted removed.
3. Modified pwm_nrfx.c driver to use DT
   defines instead of Kconfig.

Signed-off-by: Gaute Gamnes <gaute.gamnes@nordicsemi.no>
2018-12-11 15:18:14 +01:00
Erwan Gouriou 9062e97a45 drivers: stm32: check clock_control_on return value
Check clock_control_on return value now that it is checking appropriate
bus is used in the request.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2018-12-07 11:31:48 -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
Erwan Gouriou 3c009a7f2f drivers/pwm: stm32: Use device tree for clocks and base address config
Use device tree generated #define's to configure STM PWM devices

Fixes #10449

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2018-12-04 09:07:28 -06:00
Marek Pieta 39551cfbb8 drivers: pwm: Add power management to pwm_nrfx
Change adds power management to pwm_nrfx.

Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
2018-11-16 15:01:16 +01: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
Andrzej Głąbek 4750cf3b7b bluetooth: controller: nrf5: Reorder used PPI channels
The channels assigned to the controller are reordered so that the ones
previously used and now available for other purposes have continuous
numbers. When the controller can take advantage of the pre-programmed
PPI channels (when TIMER0 is used as the event timer), the now free
channels are 0-4, when it cannot, it is the channel 0.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2018-11-10 12:39:40 -05:00
Kumar Gala aa2bdbe322 drivers: Remove board.h include
We either don't need board.h in the driver or we should be include soc.h
instead.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-11-01 13:21:11 -04:00
Anas Nashif ff9c20826c driver: pwm: use new logger
move PWM driver to use new logger.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-10-08 17:49:12 -04: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
Henrik Brix Andersen 2d269bb194 drivers: pwm_nrf5_sw: Perform static initialization only once
Move static register initialization from _pin_set() to _init().

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2018-08-20 22:08:44 +02: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
Diego Sueiro 51d1708648 drivers: add i.MX PWM driver
Adds the PWM shim driver for i.MX

Signed-off-by: Diego Sueiro <diego.sueiro@gmail.com>
2018-07-17 16:08:22 -05:00
Andrzej Głąbek 28bf281231 drivers: pwm: nrf: Add nrfx_pwm.c to the build when PWM_NRFX is enabled
When the PWM_NRFX Kconfig option is enabled, add the nrfx driver
to the build automatically by selecting the NRFX_PWM option (it is
a hidden one, so the user cannot do it manually via menuconfig).

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2018-07-05 11:58:51 +02:00
Ulf Magnusson f30b163624 drivers: pwm: 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
Justin DeMartino cfc18f2102 drivers: pwm: Add shim for nrfx PWM HW driver
Adds a translation layer to make the nrfx driver for nrf52 PWM
peripheral accessible via the Zephyr's API.

Signed-off-by: Justin DeMartino <jdemarti@gmail.com>
2018-06-22 11:56:01 +02:00
Henrik Brix Andersen fc1898ccb5 drivers: pwm: pwm_nrf5_sw: Add prescaler support
Add support for specifying the clock prescaler value for the HF timer
used for generating the PWM signals. This allows for lower timer
frequency and thus slower PWM signals (e.g. for use as servo
controller).

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2018-06-13 18:55:22 +02:00
Henrik Brix Andersen f5310d5b54 drivers: pwm: pwm_nrf5_sw: Fix calculation of cycles per second
The nRF5x HF timer base frequency is 16 MHz, not 16777216 Hz.

The improved accurracy of the PWM signal was verified with an
oscilloscope on a BBC micro:bit.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2018-06-13 18:55:22 +02:00
Florian Vaussard 653d75cfba pwm: stm32: Add PWM fixup for STM32* and remove Kconfig options
Add fixup info for PWM nodes on STM32F0/F1/F3/F4/L4 and remove the
conflicting Kconfig symbols to fully switch STM32 PWM to device tree.

Signed-off-by: Florian Vaussard <florian.vaussard@gmail.com>
2018-06-12 03:54:26 -04:00
Florian Vaussard bef42fad57 pwm: stm32: Fix driver to compile with STM32F0
CONFIG_CLOCK_STM32_APB2_PRESCALER does not exist for STM32F0 as it was
removed from the RCC Kconfig by commit d0678201c3 ("drivers:
clock_control: provide support for stm32f0."). This will break the PWM
driver if compiled for STM32F0.

Conditionally disable usage of this symbol for STM32F0 as all PWMs are
on APB1 for this family.

Signed-off-by: Florian Vaussard <florian.vaussard@gmail.com>
2018-06-12 03:54:26 -04:00
Florian Vaussard 079087483d pwm: stm32: Add STM32F0-specific clocks
PWM1 / PWM15 / PWM16 and PWM17 on STM32F0 do not use the same clocks
compared to the other series.

Add the STM32F0-specific clocks where needed.

Signed-off-by: Florian Vaussard <florian.vaussard@gmail.com>
2018-06-12 03:54:26 -04:00
Florian Vaussard c65499d485 pwm: stm32: Add clock group information
Not all PWM clocks belong to the GRP1, for example TIM1 on STM32F0. Add
the group information to the macro to enable supporting these PWMs in
the future.

Signed-off-by: Florian Vaussard <florian.vaussard@gmail.com>
2018-06-12 03:54:26 -04:00
Florian Vaussard 20365bac0e pwm: stm32: Do not hardcode the prescalers
The prescalers are currently hardcoded and are not user-selectable. As a
result, the frequency of the timer can be inadequate to the task. For
instance, the frequency of the 16-bit timers (prescaler 10000) is
usually too low to correctly generate of PWM of a few kilohertz.

Hardcoded prescalers are replaced by Kconfigs so the user can choose at
compile time. The default value of each Kconfig matches the hardcoded
prescaler, so the change will be transparent.

Signed-off-by: Florian Vaussard <florian.vaussard@gmail.com>
2018-06-12 03:54:26 -04:00
Florian Vaussard f34e74dba2 pwm: stm32: Add support for all PWMs up to PWM20
All the PWM between 1 and 20 can be found on the STM32 depending on the
serie and the specific model. Add all the missing PWMs up to PWM20 to
plan for the future needs.

Tested on STM32L496 with available PWMs.

Signed-off-by: Florian Vaussard <florian.vaussard@gmail.com>
2018-06-12 03:54:26 -04:00
Florian Vaussard 0bdcef9e00 pwm: stm32: Use macro to simplify registration
The registration of each PWM differs only by a few details.
These differences can be factorized in order to create a generic
registration macro.

This has several advantages:
- Less code
- Easier to add new PWM

Signed-off-by: Florian Vaussard <florian.vaussard@gmail.com>
2018-06-12 03:54:26 -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
Florian Vaussard e681f9cbeb pwm: stm32: fix off-by-one on PWM period
TimerHandle->Init.Period is used to initialize TIMx ARR register. The
timer will count from 0 up to ARR including, thus it will tick
(ARR + 1) timers per period. As the "period_cycles" variable holds the
number of desired ticks, the ARR register is computed as

ARR = period_cycles - 1

Update the code to reflect this relationship. Otherwise the timer will
count one more tick for each period, leading to a wrong PWM frequency.

Signed-off-by: Florian Vaussard <florian.vaussard@gmail.com>
2018-05-17 13:07:43 -05:00
Kumar Gala 7de55a07fc pwm: stm32: Fix type for PMW3 support
When we called DEVICE_AND_API_INIT for PMW3, we accidently had
pwm_stm32_2 instead of pwm_stm32_3.

Fixes: #6625

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-05-15 14:48:44 -05: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
Carles Cufi f49150cab6 arch: arm: nrf: Rename nrf5 SoC Family to nrf
Upcoming Nordic ICs that share many of the peripherals and architecture
with the currently supported nRF5x ones are no longer part of the nRF5
family. In order to accomodate that, rename the SoC family from nrf5 to
nrf, so that it can contain all of the members of the wider Nordic
family.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-03-20 11:57:14 +01:00
Vitor Massaru Iha fbaddfb079 drivers: pwm: Add PWM LED driver for ESP32
This is a initial support for PWM LED controller on ESP32.

Signed-off-by: Vitor Massaru Iha <vitor@massaru.org>
2018-02-23 13:13:12 -05:00
Anas Nashif 8949233390 kconfig: fix more help spacing issues
Fix Kconfig help sections and add spacing to be consistent across all
Kconfig file. In a previous run we missed a few.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-02-15 23:20:55 -05:00
Johan Hedberg 8f5378b9de pwm: nrf5_sw: Fix configuration for nRF51
nRF51 boards require different values for the timer and ppi_base.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-02-08 11:21:51 +02:00
Ricardo Salveti 3f1dbfda15 pwm: nrf5_sw: don't disable timer if another channel is still active
Check if all channels are inactive before stopping the timer.

Signed-off-by: Ricardo Salveti <ricardo@opensourcefoundries.com>
2018-01-31 19:51:12 -05:00
Ricardo Salveti ab399a1cf0 pwm: nrf5_sw: do not use 'inversed' polarity by default
The default PWM polarity was 'inversed', which is not aligned with the
other PWM drivers. Unfortunately there is not yet an API to define the
default polarity to be used by the driver, but assume that 'normal'
(signal starts high for the duration of the duty cycle) should be the
default.

Signed-off-by: Ricardo Salveti <ricardo@opensourcefoundries.com>
2018-01-31 19:51:12 -05:00
Ricardo Salveti cec073c35c pwm: nrf5_sw: add support for SYS_LOG
Useful for debugging the period and pulse values used by the driver.

Signed-off-by: Ricardo Salveti <ricardo@opensourcefoundries.com>
2018-01-31 19:51:12 -05:00
Erwin Rol d54aaa0326 drivers: pwm: stm32: use Kconfig to select HAL/LL sources
Use "select USE_STM32_HAL_TIM" to select the needed STM32 HAL files,
instead of editing ext/hal/st/stm32cube/CMakeLists.txt

Signed-off-by: Erwin Rol <erwin@erwinrol.com>
2018-01-23 08:46:16 -06:00
Vinayak Kariappa Chettimada c983f670f6 drivers: pwm: nRF5x: Use TIMER2 and PPI indices 14-19
As the nRF5x BLE controller uses TIMER1, TIMER2 and PPI
indices 0-13 (and 14-15, if PA/LNA feature is enabled),
the software based PWM driver needing 6 PPI channels has
to use PPI indices outside the BLE controller used range.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2017-11-22 18:46:20 -05:00
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 0f66b9f7d8 drivers: pwm: add system call handlers
pwm_pin_set_usec now defined in terms of the other two APIs.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-10-30 13:20:19 -07:00
Maureen Helm 694c7f5ca4 mcux: nxp_kinetis: Move HAS_FTM config to ext
SoCs outside the Kinetis family can have the FTM module, so move the
HAS_FTM config from arch/arm/soc/nxp_kinetis to ext/hal/nxp/mcux

Note that 'select HAS_FTM' was previously missing from Kconfig.soc and
is now fixed.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2017-09-25 12:31:59 -05:00
Ricardo Salveti 7714c9a7aa pwm: stm32: Fix check for APB prescale
RCC_HCLK_DIV1 translates to 0x0 while apb_psc uses the value defined
by CONFIG_CLOCK_STM32_APB1/2_PRESCALER (range from 1 to 16).

Manually check if the defined prescaler is 1 or not and use that to
calculate the correct timer clock.

Signed-off-by: Ricardo Salveti <ricardo.salveti@linaro.org>
2017-09-13 10:07:44 -05:00
Ricardo Salveti 0dca1f5bd3 pwm: stm32: Add PWM 3 (TIM3)
Add support for TIM3 as it is widely available and pins available via
headers on several devices.

Signed-off-by: Ricardo Salveti <ricardo.salveti@linaro.org>
2017-09-13 10:07:44 -05:00
Maureen Helm 469ddab780 pwm: Remove k64-specific driver and k20_sim.h
Now that we have an mcux shim driver, remove the old k64-specific
driver. Also remove include/drivers/k20_sim.h, since the old
k64-specific driver was the only thing left using it.

Jira: ZEP-2025

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2017-08-09 18:13:29 -04:00
Maureen Helm 060bf8ea6a pwm: Introduce new mcux ftm shim driver
Adds a shim layer around the mcux ftm driver to adapt it to the Zephyr
pwm interface.

Jira: ZEP-2025

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2017-08-09 18:13:29 -04:00
Maureen Helm bebc94e043 pwm: Add shared configs for log level and instances
Adds shared pwm driver configs for log level and instances

Jira: ZEP-2025

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2017-08-09 18:13:29 -04:00
Anas Nashif 09bcd8ee74 Kconfig: make all syslog variables depend on SYS_LOG
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-08-04 14:34:54 -05: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
Erwan Gouriou 9413c8ba4d stm32: clean up after completion of transition to ll Clock control
Following migration of stm32f1xx series clock control driver to
STM32Cube LL API, cleanup stm32 code base in order to take into
account that this is the only clock driver available for stm32
family.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2017-06-02 14:11:13 -04:00
Adithya Baglody 34ac008d0e drivers: pwm: remove deprecated PWM API usage.
Removed the old PWM APIs usage and added support for the new PWM API.

JIRA: ZEP-2018

Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-05-19 18:38:01 -04:00
Erwan Gouriou 242ed389a3 stm32f4: Clean references to stm32f4 specific clock control
Following activation of stm32 common clock driver for stm32f4 series
remove references to stm32f4 specific driver.

Change-Id: I372a0ea046007bcb34944d6b2b8880077583b1d3
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2017-04-28 15:26:11 -05:00
David B. Kinder 93e4d7258d spell: fix Kconfig help typos: /boards /drivers
Fix misspellings in Kconfig help text

Change-Id: I3ae28a5d23d8e266612114bc0eb8a6e158129dc7
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2017-04-21 21:31:30 +00: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
Vinayak Chettimada 9584456fc9 drivers: pwm: Add nRF5x GPIOTE based PWM driver
Add support for nRF5x series GPIOTE based PWM driver
implementation.

Provides upto 3 pins/channels using one HF timer, two PPI
channels per pin, and one GPIOTE config per pin.

Change-id: I6056b199ec2cff595ba8fea9f659a0338ed4635b
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2017-04-14 01:53:07 +00:00
Erwan Gouriou 726d4dc437 drivers: stm32: clean up after stm23cube based clock control
After activation of cube based driver support on L4 and F3 series,
this commits performs the clean up of F3 and L4 relative code to
native clock control drivers.
Indirectly, it makes pwm driver supported de facto on F3 series

Change-Id: Idac17103a9b5ef6eab540719343cc8f5865f15fa
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2017-02-10 14:47:41 -06:00
Erwan Gouriou 2ab8250c5b pwm: update stm32 pwm to support LL clock control driver
After introducing STM32Cube based clock control driver for
stm32 family, update stm32 pwm driver to support it.
Once supported across the whole family, a clean up will be done.

Change-Id: I2ed38763b706e34ea1dceea50e97ce836dd9e195
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2017-02-10 14:47:41 -06: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
Kuo-Lang Tseng 0e91e84122 drivers: QMSI PWM: simplify driver reentrancy code using IS_ENABLED macro
This is one the series patches that simplifies the driver code by
using the IS_ENABLED macro. This removes the need of the const
variable and the wrapper functions on semaphore APIs.

Jira: ZEP-1251

Change-Id: Ic2df5d04966d2a066478ca3e119f76d24fc4dfb3
Signed-off-by: Kuo-Lang Tseng <kuo-lang.tseng@intel.com>
2017-02-08 19:08:31 +00: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
Anas Nashif a9e879e273 logging: move sys_log to subsys/logging
Move logging out of misc/ to its own subsystem. Anything related to
logging and any new logging features or backends could be added here
instead of the generic location in misc/ which is overcrowded with
options that are not related to eachother.

Jira: ZEP-1467
Change-Id: If6a3ea625c3a3562a7a61a0ba5fd7e6ca75518ba
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-12-19 19:58:39 +00:00
Erwan Gouriou 4827f2f386 pwm/stm32: add PWM driver for STM32 F1/F4/L4
Provide PWM driver for STM32 series F1/F4/L4.
Driver is ported on STM32Cube HAL and should support other STM32
series with minor updates.
Configuration is done so that PWM sample driver could be run on
all nucleo boards supporting PWM driver.

Change-Id: I6522a565451085df932e0eefd8404268380b5bfe
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2016-12-06 10:31:46 -06:00
Flavio Santes b04cdcd6e6 drivers: Remove legacy nanokernel.h include
This commit replaces the nanokernel.h include by kernel.h.

Change-Id: Ib42fbf2d9f77a73c0831f569b3dbbfb342ea2e1d
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2016-12-04 14:59:37 -06:00
Sergio Rodriguez 39b06e676f drivers: pwm: Fix uninitialized pointer
This fixes an uninitialized pointer being pass and evaluated by
a subsequent function

This issue was reported by Coverity (CID 150824)

Change-Id: If1f636a44cc675b56e426b1de85895b74ba7105e
Signed-off-by: Sergio Rodriguez <sergio.sf.rodriguez@intel.com>
2016-11-16 12:37:07 +00:00
Baohong Liu 14d079a13c drivers: pwm: update to unified kernel
Use new semaphore APIs from unified kernel.

Change-Id: I76eeab4dbb4259aa1147f524645c4ca8a8a48398
Signed-off-by: Baohong Liu <baohong.liu@intel.com>
2016-11-10 05:12:38 +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
Baohong Liu 05bed1c663 drivers: pwm_qmsi: add type cast to prevent overflow
Add type cast to prevent overflow.

In the pwm driver function pwm_qmsi_get_cycles_per_sec(),
there is a multiplication which takes ticks_per_us (32 bit
unsigned integer) and USEC_PER_SEC. Practically, overflow
will not happen, since the sys clock is not that high. But,
it can trigger an overflow alarm by automatic tools.

Change-Id: I67e6f6a4763e62f6674fcdd364880d93829e739e
Signed-off-by: Baohong Liu <baohong.liu@intel.com>
2016-11-08 14:28:26 +00:00
JuanX Solano Menacho 5a4c3e3fbb pwm_qmsi: Use qm_pwm_save/restore_context APIs
This commit updates the pwm_qmsi driver by removing the temporary Zephyr
save/restore context implementation and using the new QMSI APIs.

Jira: ZEP-1008
Change-Id: Ic92feeb906539f506eb521b7302f8cf5af3edc64
Signed-off-by: JuanX Solano Menacho <juanx.solano.menacho@intel.com>
2016-11-03 23:52:08 +00:00
Baohong Liu 8ecfcc8ca4 pwm: qmsi_shim: implement pwm driver required by new APIs
Implement qmsi shim driver based on the new API interfaces.

Recently, a RFC was sent and discussed on the re-design of
PWM interfaces. A API change was already posted.

The API new design will deprecate all existing APIs and three
new APIs will be added. The new APIs are pwm_pin_set_cycles,
pwm_pin_set_usec and pwm_get_cycles_per_sec. Pwm_pin_set_cycles
and pwm_pin_set_usec will rely on two driver functions to set
the period and pulse width. This change is to implement the
driver functions pwm_qmsi_pin_set and pwm_qmsi_get_cycles_per_
sec.

Jira: ZEP-745

Change-Id: I39bb973f8c5b19cb7dbd496d10e7f0b6735efc12
Signed-off-by: Baohong Liu <baohong.liu@intel.com>
2016-10-31 20:01:05 +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 08615c7b6b drivers/pwm_qmsi: Make driver_api structure const.
Change-Id: I03050db2015f7a641127bdfb41659b93032feb9c
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-10-25 18:45:30 +00:00
Marcus Shawcroft 46e39befea drivers/pwm_pca9685: Make driver_api structure const.
Change-Id: I60d2c8c408aab59b85a3b756439b2d22a4ad7d49
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-10-25 18:45:29 +00:00
Marcus Shawcroft ae6802329c drivers/pwm_k64_ftm: Make driver_api structure const.
Change-Id: I79159bce07ab9a5928cf01103451401ab42a7a7a
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-10-25 18:45:29 +00:00
Qiu Peiyang 2901f89170 drivers/pwm: fix pwm_qmsi_set_values() return error
When user wants to set all the PWM ports in one call,
pwm_qmsi_set_values() should call __set_one_port() for
each PWM port. The current pwm_qmsi_set_values() will
return after setting the first PWM port. It's illogical.

Change-Id: I5776bf636c2dc58683c629e26f72fca335e781db
Signed-off-by: Qiu Peiyang <peiyangx.qiu@intel.com>
2016-10-25 13:05:18 +00:00
Marcus Shawcroft caa6bf3419 pwm/pca9685: Make driver config_info structure const.
Change-Id: I1bb5a5502c0d2e643c8fb82540a3e94ea7d5d46f
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-10-20 16:48:57 +00:00
Marcus Shawcroft 12810d7e54 pwm/ftm: Make driver config_info structure const.
Change-Id: I14ff0d15ea2b2da08ac4dd60fb4b477e9e51d8aa
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-10-20 16:48:56 +00:00
Marcus Shawcroft 58ed60457c pwm/dw: Make config_info pointers const.
Mutable driver state relocated from config_info to driver_info.

This driver is unused by any board, nor can it be compiled for any
board.  Hence this patch reflects the mechanical change that should be
made to the driver in order to support a const config_info, but the
patch has been neither compiled, nor tested.

Change-Id: I28597962e81d6e02f1f4befe48c3a3324691cfeb
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-10-19 12:10:59 +00:00
Marcus Shawcroft 9f308df473 pwm: qmsi: Remove RW data from driver config structure.
Move the RW channel_period object from the driver config structure to
the driver context.  Remove the now empty driver config structure.

Change-Id: I38df7877f1bfb9bb55bcd61e7f35cebb6e4916bd
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-10-15 12:29:23 +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
Baohong Liu 9cfed4940c drivers: pwm_shim: correct api argument inconsistency
Correct the argument definition inconsistency for the set
value API. To be consistent with other pwm sub drivers, the
on and off arguments for the set value api are re-defined.

On: how far (number of timer count) from the beginning of a PWM
    cycle the PWM pin will be asserted.
Off:how far (number of timer count) from the beginning of a PWM
    cycle the PWM pin will be de-asserted.

Jira: ZEP-642

Change-Id: I7b39f98f1935fc3499fb36dd813abed62b86c1e7
Signed-off-by: Baohong Liu <baohong.liu@intel.com>
2016-08-25 14:24:03 -07:00
Iván Briano 1a47abe5bf pwm qmsi: Add suspend/resume
Implement saving and restoring context of the PWM controller when the
application goes to SYS_PM_DEEP_SLEEP. No action is taken for other
states at the moment.

This functionality is implemented in the shim driver first to enable
the feature, but will later be moved into QMSI.

Change-Id: I5784f6a2c63caaea5785ca5d92bb6cc3bc9fa4cc
Signed-off-by: Iván Briano <ivan.briano@intel.com>
2016-08-02 06:48:21 +00:00
Genaro Saucedo Tejada aaa66ee9f2 sys_log: replace debug macros at Freescale K64 PWM driver
Freescale K64 PWM driver is now using new system log macros, updated
the Kconfig variable to be a level rather than a bool.

JIRA: ZEP-311

Change-Id: I80d01ba75e8b186ef32861b372af4e2d15dd4131
Signed-off-by: Genaro Saucedo Tejada <genaro.saucedo.tejada@intel.com>
2016-07-31 18:15:24 +00:00
Iván Briano 20029c8c2d pwm: Remove suspend and resume hooks from pwm_driver_api
Drivers that implement power management should use the preferred
device_pm_ops method instead.

Change-Id: Ice9e0469a1fcb50eb64dcb240dddea56755b6e84
Signed-off-by: Iván Briano <ivan.briano@intel.com>
2016-07-29 23:10:09 +00:00
Iván Briano 6e367c4db0 pwm: k64_ftm: Move suspend and resume hooks to pm_ops
The suspend and resume hooks in the pwm_driver_api struct are relics
from before the current power management infrastructure was in place.
The correct way to implement this now is through the device_pm_ops
struct, by way of the DEFINE_DEVICE_PM_OPS and DEVICE_AND_API_INIT_PM
macros, which make the hooks available through a generic mechanism for
all devices, rather than using per-type APIs.

Since the existing pwm_suspend() and pwm_resume() functions don't check
if the driver_api hooks are NULL, there's now a place holder function
to prevent breaking functionality until the hooks are removed.

Change-Id: Ib6b03053b483f97a1f7441af5ba51503270b8674
Signed-off-by: Iván Briano <ivan.briano@intel.com>
2016-07-29 23:10:08 +00:00
Kuo-Lang Tseng 6911589c13 qmsi: pwm: Use locking mechanism to guard critical regions
Guard critical section of the driver API, so that multiple
simultaneous calls from tasks/fibers won't corrupt the driver
state.

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

CONFIG_PWM_QMSI_API_REENTRANCY

Jira: ZEP-430

Change-Id: Ia3eb2a962f4176a3ac94163b9843ab068abe4b4e
Signed-off-by: Kuo-Lang Tseng <kuo-lang.tseng@intel.com>
Signed-off-by: Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
2016-07-28 15:29:49 +00:00
Sergio Rodriguez 9852ee5573 pwm: Implement set period and duty cycle API
This allow the PWM QMSI shim driver to implement the set duty cycle
API, and correct the behavior of Set Value

Jira: ZEP-69 ZEP-156 ZEP-158

Change-Id: I47744958fed889116fbb5024343ea00f76ed7706
Signed-off-by: Sergio Rodriguez <sergio.sf.rodriguez@intel.com>
Signed-off-by: Baohong Liu <baohong.liu@intel.com>
2016-07-06 22:01:51 +00:00
Baohong Liu 0ccc831452 drivers: PWM QMSI dev name fix
Change the dev name from PWM to PWM_0. This will make it
consistent with other drivers and also fix the device binding
failure in the PWM sample app.

Jira: ZEP-395

Change-Id: I90b945a7e57700d384eaa52e5300c881a3251d83
Signed-off-by: Baohong Liu <baohong.liu@intel.com>
2016-05-26 22:35:33 +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 bb7e4ffa6e pwm/qmsi: use new DEVICE_AND_API_INIT()
Change-Id: I2ec5bb2e00d78755f8db1e960f747f9099163eaf
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-04-28 01:03:39 +00:00
Anas Nashif 940d539834 qmsi: pwm: use built-in qmsi driver
Change-Id: I154840f704b9cfec269addaf3cbd7e71bb6310af
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-04-22 20:46:29 -04:00
Anas Nashif 82d4c96bd4 pwm: unify driver names
Use same string for driver name used for binding and fix
sample app to work with multiple drivers, not only DW driver.

Change-Id: I4d40aa9d4e83fcf16dc883bb74c3f0e3e30e3502
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-04-22 20:46:29 -04:00
Anas Nashif 65c06afa58 kinetis: reorganise soc directory using soc family
Add Kinetis SoC family and rename fsl_frdm_k64f to mk64f12.
This will allow adding new SoCs of the same family and the reuse of code
among SoCs of the family and series.

Change-Id: Iea1a663aef7ce0487f147bdd36f668bebe80deb5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-04-18 21:24:58 +00:00
Daniel Leung c8bc070d72 pwm/k64_ftm: convert to use DEVICE_AND_API_INIT()
Change-Id: Ia9f7c31f62046970a77fabad61fcbbd64b91aea2
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-04-15 22:06:13 +00:00
Daniel Leung 317922a3b6 pwm/dw: convert to use DEVICE_AND_API_INIT()
Change-Id: I31ee7b631293f1bd94085adec5979d113adf6026
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-04-15 22:06:11 +00:00
Daniel Leung aa98192cad pwm/pca_9685: move driver_api assignment later
This moves the assignment of driver_api to just before
the init function returns. This is in preparation to
make device_get_binding() return NULL if driver
initialization fails.

Change-Id: Ia0c7a0014eb28624cbf363f994d6149f1aa5aadd
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-04-12 11:25:03 +00:00
Daniel Leung 2d1ed03a8f pwm/k64_ftm: remove kconfigs that are SoC specific
Remove those kconfig options that are SoC specific, and
should not be configurable via kconfig.

Change-Id: Ifd65097a65f80539cac073f95aadc2d8e42efb9f
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-03-31 23:17:24 +00:00
Daniel Leung 17b3a85308 pwm/dw: remove kconfigs that are SoC specific
Remove those kconfig options that are SoC specific, and
should not be configurable via kconfig.

Change-Id: Ifdbb5e3a997795ef577350d88f8cb06877eb6463
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-03-31 23:17:24 +00:00
Andre Guedes 114e5ba186 pwm: Remove redundancy in Kconfig.qmsi
The PWM_QMSI_DEV_NAME and PWM_QMSI_NUM_PORTS options depend on PWM_QMSI
already so this patch removes the 'if PWM_QMSI' block since it is
redundant.

Change-Id: Iec303d27f088b96662fc58933eaa82fe9459cb59
Signed-off-by: Andre Guedes <andre.guedes@intel.com>
2016-03-29 11:05:23 +00:00
Yannis Damigos 489477b6b9 drivers: pwm: Make K64 pwm submenu available only for K64 soc
Makes K64 pwm driver submenu available only if K64 soc is
selected.

Change-Id: I9959b4785c6deab01977f86bbbebe3d671a4eec7
Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
2016-03-23 15:36:42 +00:00
Daniel Leung bf40dec92e pwm: restructure Kconfig options
() Moves config options for each controllers into their own
   Kconfig files. This keeps upper level Kconfig from getting
   too big.
() Options for each controller are moved under their own
   submenus.

Origin: refactored from existing file
Change-Id: I77e92f72f8de85abaedfbe078283607b7c242c81
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-03-17 21:05:12 +00:00
Andre Guedes 136d171588 drivers: Replace DEV_NOT_CONFIG by -EPERM
This patch replaces all occurences of the macro DEV_NOT_CONFIG by
-EPERM at the driver level. This patch is part of the effort to
transition from DEV_* codes to errno.h codes.

Change-Id: I3054c8aa76319a58a2eec089b8a72bf301c85391
Signed-off-by: Andre Guedes <andre.guedes@intel.com>
2016-03-16 19:30:04 -04:00
Andre Guedes b3cb3a1f68 drivers: Replace DEV_INVALID_CONF by -EINVAL
This patch replaces all occurences of the macro DEV_INVALID_CONF by
-EINVAL at the driver level. So this patch touch the files under
drivers/, include/ and samples/drivers/ when applicable.

This patch is part of the effort to transition from DEV_* codes to
errno.h codes.

Change-Id: Idae0d5af8dd780416977c9261a5fb6188c3aab64
Signed-off-by: Andre Guedes <andre.guedes@intel.com>
2016-03-16 19:30:04 -04:00
Andre Guedes 245e140da6 drivers: Replace DEV_INVALID_OP by -ENOTSUP
This patch replaces all occurences of the macro DEV_INVALID_OP by
-ENOTSUP at the driver level. So this patch touch the files under
drivers/, include/ and samples/drivers/ when applicable.

This patch is part of the effort to transition from DEV_* codes to
errno.h codes.

Change-Id: I46aec3c65963018c479b01602e4a3eec8650eaff
Signed-off-by: Andre Guedes <andre.guedes@intel.com>
2016-03-16 19:30:04 -04:00
Andre Guedes 7c956d2ece drivers: Replace DEV_FAIL by -EIO
This patch replaces all occurences of the macro DEV_FAIL by -EIO
at the driver level. So this patch touch the files under drivers/,
include/ and samples/drivers/ when applicable.

This patch is part of the effort to transition from DEV_* codes to
errno.h codes.

Change-Id: I0594ab5dbe667e074c250129e7c13ce512ac940f
Signed-off-by: Andre Guedes <andre.guedes@intel.com>
2016-03-16 19:30:04 -04:00
Andre Guedes 024cfe754e drivers: Replace DEV_OK by 0
This patch replaces all occurences of the macro DEV_OK by the actual
value 0 at the driver level. So this patch touch the files under
drivers/, include/ and samples/drivers/.

This patch is part of the effort to transition from DEV_* codes to
errno.h codes.

Change-Id: I69980ecb9755f2fb026de5668ae9c21a4ae62d1e
Signed-off-by: Andre Guedes <andre.guedes@intel.com>
2016-03-16 19:30:04 -04:00
Maciek Borzecki 2ca921867d pwm: fix K64 PWM config options dependencies
Fix dependencies of K64 PWM config options so that they do not appear at
incorrect places in the menuconfig tree hierarchy.

Change-Id: Iea8077400a1bdf3ef1c38b3bf45b7a72373bd096
Signed-off-by: Maciek Borzecki <maciek.borzecki@gmail.com>
2016-03-10 23:22:49 +00:00
Jeff Blais 1f90470a27 arm: K64F Pulse Width Modulation (PWM) support
PWM support using the Freescale K64 FlexTimer Module (FTM)

Change-Id: Iaad429c01bd877babba04e84d6a4679bd7e38120
Work-by: Mike Hirst <michael.hirst@windriver.com>
Signed-off-by: Jeff Blais <jeff.blais@windriver.com>
2016-03-09 15:49:44 +00:00
Sergio Rodriguez d8910a419b pwm: QMSI PWM driver
This creates the QMSI PWM driver which is simply a shim driver based
on the PWM driver provided by QMSI BSP.

In order to enable this driver, the following options should be set:
CONFIG_QMSI_DRIVERS=y
CONFIG_QMSI_INSTALL_PATH="/path/to/libqmsi/directory"
CONFIG_PWM=y
CONFIG_PWM_QMSI=y

Optionally this can be set:
CONFIG_PWM_QMSI_NUM_PORTS=Number of ports available, default is 1

Origin of the file: This file has been created from scratch

Change-Id: Icac90154d020babca1c11147056a3438b84b0d3f
Signed-off-by: Sergio Rodriguez <sergio.sf.rodriguez@intel.com>
2016-03-05 18:22:03 +00:00
Dan Kalowsky 4743684e4f struct packing
Looking at all structs as to where we can pack them a little better, and
calling out the padding/stride at the end for future expansion.

Change-Id: I4a651092e950dd3d915af9fa0ee0d7d59803e58f
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-10 16:21:26 +00:00
Benjamin Walsh d340d4cb3f device: use DEVICE_INIT everwhere
This is the last step before obsoleting DEVICE_DEFINE() and
DEVICE_INIT_CONFIG_DEFINE().

Change-Id: Ica4257662969048083ab9839872b4b437b8b351b
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-02-05 20:25:25 -05:00
Benjamin Walsh 0303d8cab9 device: rename SYS_DEFINE_DEVICE()
Rename it to DEVICE_DEFINE() so that it fits in the 'device' namespace.

Change-Id: I3af3a39cf9154359b31d22729d0db9f710cd202b
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-02-05 20:25:25 -05:00
Benjamin Walsh bfc27206b2 device: rename DECLARE_DEVICE_INIT_CONFIG()
Rename it to DEVICE_INIT_CONFIG_DEFINE(), because (a) it was not fitting
in any namespace and (b) it is not used to declare, but rather define a
object.

Change-Id: I1da5822f06b85a9fb024b5b184afd0ccc01012ec
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-02-05 20:25:25 -05:00
Peter Mitsis a0e4568760 c++: Add extern "C" { } block to header files
Adds extern "C" { } blocks to header files so that they can be
safely used by C++ source files.

Change-Id: Ia4db0c36a5dac5d3de351184a297d2af0df64532
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-02-05 20:25:22 -05:00
Anas Nashif 6bca3724c1 drivers: set default priority for drivers
Use a default priority to avoid Kconfig blocking when priority
is not set in SoC or Board.

Change-Id: I4edda47b955a7ee834f04dc40d0decbd8dee6305
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:25:11 -05:00
Daniel Leung 6604381c11 drivers: add new DesignWare PWM driver
This adds a driver to utilize the DesignWare timer IP block
to do PWM.

Change-Id: I11ba689350b664209ad2440e3001e57eb38fd982
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-02-05 20:25:11 -05:00
Dmitriy Korovkin dcda679c72 gpio, pwm, rgb lcd: Replace polling i2c requests
Now that i2c_transfer/i2c_read/i2c_write are fully synchronous, no need
to use the polling based function.

Change-Id: Ib578cf4a6d72ad0817e1aaeebc7e4dab9f9d293f
Signed-off-by: Dmitriy Korovkin <dmitriy.korovkin@windriver.com>
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-02-05 20:24:57 -05:00
Dmitriy Korovkin 57f2741e4f init: Implement fine-grained initialization policy
Put initialization priorities as device driver Kconfig
parameter.

Initialization priority value for each platform is defined
in the platform Kconfig file.

Drivers and platform code use SYS_DEFINE_DEVICE to add
and initialization function.

Change-Id: I2f4f3c7370dac02408a1b50a0a1bade8b427a282
Signed-off-by: Dmitriy Korovkin <dmitriy.korovkin@windriver.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:24:54 -05:00
Johan Kruger 7a9fa51b61 pwm: Changes to PWM driver for the PCA9685.
- Changed behavior of duty cycle to have the signal ON time as the
  duty percentage instead off the off time. Note however, this requires
  that the off time is controlled. The behavior seems to be inverse of
  what the user will expect on the header IO.

Change-Id: I1e7abf0324509de375d545a0215fd1edf2283814
Work-by: Johan Kruger <johan.kruger@windriver.com>
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-02-05 20:24:43 -05:00
Dan Kalowsky 3bc4039601 checkpatch: error - switch_case_indent_level
Change-Id: I9cbd6ab80b0c0f170626bb1c6b2d07498038fb8f
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
2016-02-05 20:24:31 -05:00
Dan Kalowsky 247dc8f2d1 checkpatch: removing C++ comment style
checkpatch currently reports several files failing the C99 comment
verification.  Cleaning these up now.

Change-Id: I35766c1f6c88a280c5e844b3f02668d6e1ad11d2
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
2016-02-05 20:24:31 -05:00
Dan Kalowsky 70b8230397 pwm: renaming files to use underscore
Naming convention states we should be using an underscore (_) for
filenames not a dash (-).

Change-Id: I51a6ae02957bfc556b8718aae713636bd14c8b2c
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
2016-02-05 20:24:31 -05:00
Javier B Perez Hernandez f7fffae8aa Change BSD-3 licenses to Apache 2
Change all the Intel and Wind River code license from BSD-3 to Apache 2.

Change-Id: Id8be2c1c161a06ea8a0b9f38e17660e11dbb384b
Signed-off-by: Javier B Perez Hernandez <javier.b.perez.hernandez@linux.intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-02-05 20:24:29 -05:00
Daniel Leung a5f0974131 pwm: pca9685: use polling I2C write instead
The polling I2C write function guarantees the write operation
is completed. It is to make sure each write has been commited.

Change-Id: I37cd3b8a65c605837b1fae3ccd1c2b0235c07a37
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-02-05 20:24:21 -05:00
Daniel Leung 8c27aedb79 pwm: pca9685: remove call to i2c_configure for every write
The I2C controller should have been already setup before this driver.

Since the only use right now is on Gelileo and I2C_DW driver. it is
safe to remove the i2c_configure() call now as the driver has default
configuration at boot.

Change-Id: Ia384e28871bf76dcfec899860f93da4bf0948ba6
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-02-05 20:24:21 -05:00
Daniel Leung cb1c7816f8 pwm: add driver for PCA9685 PWM chip
This adds the driver for PCA9685 I2C-based PWM chip, and provides
basic PWM functionality.

Change-Id: I8c711d9b703fdaf5ccb23657e07495a95cbe16ee
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-02-05 20:24:19 -05:00
Daniel Leung 56bfe61544 PWM: add public APIs for PWM drivers
This adds the public APIs for PWM drivers. Also, this adds a Kconfig
and an empty makefile for drivers to extend.

Change-Id: I1cc0c908b6f5aeeb678b6368640d5b9a1cc9751d
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-02-05 20:24:19 -05:00