Commit graph

550 commits

Author SHA1 Message Date
Piotr Mienkowski aa2c27d007 soc: silabs_exx32: Add independent Kconfig options for HAL libraries
Zephyr gecko drivers depend on libraries provided by the vendor. The
same libraries may also be used directly by the application code or
RAIL library. To facilitate the latter use case scenario this commit
adds Kconfig options to independently enable compilation of vendor
HAL library modules.

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2019-01-08 13:31:42 -06:00
Piotr Mienkowski f17e7c5942 drivers: i2c: add missing I2C_GECKO Kconfig option
This commit adds missing I2C_GECKO Kconfig option which currently is
being set implicitly via .defconfig file.

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2019-01-08 13:31:42 -06:00
Piotr Mienkowski 973af2c8d7 dts: silabs: use 'aliases' to remove dts_fixup defines
By adding 'aliases' node in SoC .dtsi file it is possible to generate
DT_ defines which specify a logical name rather than relay on module
location on APB bus. E.g. DT_SILABS_GECKO_USART_40010000_LABEL becomes
DT_SILABS_GECKO_USART_USART_0_LABEL. Thus it is possible to remove
dts_fixup.h defines.

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2019-01-08 11:56:02 -06:00
Piotr Mienkowski 1bfc52b81b drivers: i2c: remove deprecated i2c_atmel_sam3 driver
The i2c_atmel_sam3 driver was deprecated at release 1.9, this commit
removes it. Also pinmux_dev_atmel_sam3x driver is removed.
i2c_atmel_sam3 was the last one which depended on it.

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2019-01-08 09:23:17 -06:00
Anas Nashif 74a74bb6b8 power: rename api sys_soc -> sys_
sys_soc is just redundant, just call APIs with sys_*.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-12-28 16:16:28 -05:00
Anas Nashif 9151fbebf2 power: rename APIs and removing leading _
Remove leading underscore from PM APIs. _ was used for internal APIs.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-12-28 16:16:28 -05:00
Andrzej Głąbek 4b43065cfc drivers: nrf: Enable nRF drivers by default in Kconfig
Make the following nRF peripheral drivers:
- ADC
- GPIO
- I2C
- SPI
- UART
- USB_DEVICE
enabled by default so that users do not need to explicitly enable them
in their applications after choosing an nRF SoC as the build target.

Kconfig options enabling these drivers depend on both a given hardware
feature (e.g. I2C) and an nRF family SoC selected, so effectively they
will be automatically enabled only when it is adequate (and in most
cases these drivers are the only option for a given hardware feature
on nRF SoCs).

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2018-12-21 21:01:37 +01:00
Pushpal Sidhu f603e2509d drivers: i2c_ll_stm32_v2: Handle errors during data transfers
Check for ARLO, BERR, OVR, and NACK errors during any kind of
transmission. Helps fix getting into a while(1) loop in any of these
scenarios when in polling mode.

Signed-off-by: Pushpal Sidhu <psidhu.devel@gmail.com>
2018-12-17 08:17:24 -06:00
Olivier Martin 0fc8a357a1 drivers: i2c: nrfx: Prevent transfer overlapping
I2C transfers could simultaneous be called that would
cause an inconsistent state in NRFX I2C state (and HW).
The NRFX TWI driver would expect to be in state
`NRFX_DRV_STATE_INITIALIZED` while being in state
`NRFX_DRV_STATE_POWERED_ON`.

Signed-off-by: Olivier Martin <olivier.martin@proglove.de>
2018-12-14 08:46:35 +01:00
Andrew Boie a68120de6d kernel: check retval of driver init
If initialization fails, zero the API struct so that
device_get_binding() can't fetch it, and do not mark
the driver object as initialized to user mode.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2018-12-07 19:33:23 -05:00
Mieszko Mierunski d1b3efd98b drivers: nrf: Fix TWI and TWIM current consumption issue
TWI and TWIM  peripheral is now enabled only during transfers.

Signed-off-by: Mieszko Mierunski <mieszko.mierunski@nordicsemi.no>
2018-12-07 12:54:25 -05: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
Michael Scott d39d5881c3 drivers: i2c: fix build break for nrfx_twi* with newlib
When running sanitycheck for reel_board which selects
CONFIG_NRFX_TWIM it fails the following tests:
tests/misc/test_build/test_newlib
tests/kernel/errno/kernel.common.errno.newlib
tests/lib/mem_alloc/libraries.libc.newlib

/zephyr/drivers/i2c/i2c_nrfx_twim.c:144:3: error: expected declaration
specifiers or '...' before '(' token
   (bitrate == I2C_BITRATE_STANDARD ? NRF_TWIM_FREQ_100K         \
   ^
/zephyr/drivers/i2c/i2c_nrfx_twim.c:151:3: note: in expansion of macro
'I2C_NRFX_TWIM_FREQUENCY'
   I2C_NRFX_TWIM_FREQUENCY(           \
   ^~~~~~~~~~~~~~~~~~~~~~~
/zephyr/drivers/i2c/i2c_nrfx_twim.c:184:1: note: in expansion of macro
'I2C_NRFX_TWIM_DEVICE'
 I2C_NRFX_TWIM_DEVICE(0);
 ^~~~~~~~~~~~~~~~~~~~
/zephyr/drivers/i2c/i2c_nrfx_twim.c:154:3: error: expected declaration
specifiers or '...' before string constant
   "Wrong I2C " #idx " frequency setting in dts");         \
   ^
/zephyr/drivers/i2c/i2c_nrfx_twim.c:184:1: note: in expansion of macro
'I2C_NRFX_TWIM_DEVICE'
 I2C_NRFX_TWIM_DEVICE(0);
 ^~~~~~~~~~~~~~~~~~~~
zephyr/drivers/i2c/CMakeFiles/drivers__i2c.dir/build.make:62: recipe
for target
'zephyr/drivers/i2c/CMakeFiles/drivers__i2c.dir/i2c_nrfx_twim.c.obj'
failed

To fix this, let's replace the use of static_assert() with a more
generic macro: BUILD_ASSERT_MSG()  This should work across minimal
libc, newlibc and c++.

Signed-off-by: Michael Scott <mike@foundries.io>
2018-12-01 18:35:21 +01:00
Mieszko Mierunski 9dc3870276 drivers: nrf: Support I2C initial speed configuration from dts
Current implementation had fixed initial speed, this commit
fixes TWI and TWIM shims to use configuration from DTS.

Signed-off-by: Mieszko Mierunski <mieszko.mierunski@nordicsemi.no>
2018-11-23 12:39:36 -05:00
Mieszko Mierunski 5a10087a25 dts: nrf: Remove TWI dts.fixup defines and use aliases instead.
Changed driver to use alias defines instead of fixup.

Signed-off-by: Mieszko Mierunski <mieszko.mierunski@nordicsemi.no>
2018-11-20 22:18:09 +01:00
Kumar Gala fd6e9c6f58 dts: i2c: cleanup CONFIG_I2C_x_IRQ_PRI
The majority of cases of CONFIG_I2C_x_IRQ_PRI should be
DT_I2C_x_IRQ_PRI.  So go ahead and fix them up.  Only the i2c_nios
driver still uses Kconfig for getting priority.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-11-16 13:57:02 -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
Krzysztof Chruscinski 97345dbb1b logging: Fix errors in log usage
Couple of findings which were revealed after changing
LOG_MODULE_REGISTER macro:
- missing semicolons after LOG_MODULE_REGISTER()
- missing LOG_LEVEL defines
- other

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2018-11-10 12:38:29 -05:00
Himanshu Jha d0a98b7cf9 drivers: Remove redundant semicolon
Remove the redundant semicolon used as a terminator in
`if`, `switch`, `while` statements.

Found using Coccinelle.

Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com>
2018-11-07 10:34:06 -05:00
Erwan Gouriou 9df3a1f67f drivers/i2c: stm32: get clock bits/bus from dts files
Get STM32 I2C clocks bus and bits information from
device tree files.

Fixes #10435

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2018-11-06 16:14:13 -05:00
Aurelien Vouaillat 6282320427 drivers: i2c: i2c_nrfx_twi and twim: Return -EBUSY when I2C bus is busy
Return -EBUSY instead of -EIO

Signed-off-by: Aurelien Vouaillat <aurelien.vouaillat@proglove.de>
2018-11-05 14:23:17 +01: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
Diego Sueiro 4ce6555c1d drivers: Introduce Silabs i2c shim driver
Adds the I2C shim driver for Silabs Gecko Devices.

Signed-off-by: Diego Sueiro <diego.sueiro@gmail.com>
2018-10-31 09:00:38 -05:00
Sebastian Bøe b9c125f64c kconfig: Hide the DesignWare I2C driver on unsupported platforms
When users are configuring nRF applications they are given the option
to enable the DesignWare I2C driver. But they should not be given this
option because nRF SoCs do not have DesignWare I2C HW.

This commit hides the driver by default by introducing the config
option HAS_I2C_DW.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-10-25 07:32:05 +01:00
Anas Nashif 44f0a79dbb drivers: i2c: enable logging for drivers loading i2c-priv.h
i2c-priv.h is currently doing some logging and is included in various
i2c drivers, make sure the logger is enabled for those drivers.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-10-10 13:26:58 -04:00
Anas Nashif f7dac85d15 drivers: i2c: move to new logger
Move to new logger subsystem.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-10-08 17:49:12 -04:00
Maureen Helm 50d276f1ae drivers: i2c: Select HAS_DTS_I2C in designware and qmsi drivers
Makes the designware and qmsi i2c drivers consistent with other i2c
drivers by selecting HAS_DTS_I2C in the driver.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2018-09-27 05:54:54 +05:30
Mieszko Mierunski 1dd5dc63c1 drivers: i2c: Add dts support for i2c slaves.
Adding i2c slave requires overlay with node definitions and
proper aliases depending on driver implementation.

Modified i2c_slave_api test to use information from dts.

Signed-off-by: Mieszko Mierunski <mieszko.mierunski@nordicsemi.no>
2018-09-24 07:26:07 -05:00
Maureen Helm 873d63c59b drivers: i2c: Parse 10-bit addressing flag in mcux driver
Parses the new message-level flag for 10-bit addressing in the mcux i2c
driver.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2018-09-18 17:37:12 -04:00
Mieszko Mierunski fd04e7def2 drivers: nrf: Switched nrf i2c drivers to 10 bit address msg flag
10 bit addressing is still not supported on nrf chips, but now
I2C_MSG_ADDR_10_BITS flag is checked.

Signed-off-by: Mieszko Mierunski <mieszko.mierunski@nordicsemi.no>
2018-09-18 12:06:11 -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
Yannis Damigos 7b0632822b drivers: i2c_ll_stm32_v1: Handle NACK during address tranmsission
In polling mode, if a NACK is received during address transmission
the driver waits forever the ADDR flag. We need to check AF flag
and stop the transmission if it is set.

Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
2018-08-27 12:52:53 -04:00
Yannis Damigos 32d159e335 drivers: i2c_ll_stm32_v1: Generate STOP condition if NACK
Acknowledge failure (AF) error occurs when the interface detects
a NACK bit. According to the reference manual, the transmitter
which receives a NACK must reset the communication:
– If Slave: lines are released by hardware
– If Master: a Stop or repeated Start condition must be generated
  by software

Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
2018-08-27 12:52:53 -04:00
Diego Sueiro 4eee8a67f1 drivers/i2c/i2c_imx: Check for I2C bus busy before starting transaction
In some cases the minimum time between Stop and Start was not being
considered when starting a new transfer.
This patches adds a checking on the I2C Bus Busy flag before starting
a new transaction.

Signed-off-by: Diego Sueiro <diego.sueiro@gmail.com>
2018-08-21 18:54:41 -05:00
Flavio Ceolin 0866d18d03 irq: Fix irq_lock api usage
irq_lock returns an unsigned int, though, several places was using
signed int. This commit fix this behaviour.

In order to avoid this error happens again, a coccinelle script was
added and can be used to check violations.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2018-08-16 19:47:41 -07:00
Andrzej Głąbek 2469097b34 drivers: nrfx: Allow simultaneous use of SPI_0 and I2C_0 on nRF52810
In most Nordic SoCs the SPI and TWI peripherals with the same instance
number share certain resources and cannot be used at the same time.
In nRF52810 there are only single instances of these peripherals and
they are arranged in a different way so this limitation does not apply.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2018-08-13 18:45:04 -07:00
Ulf Magnusson ec3eff57e0 Kconfig: Use the first default with a satisfied condition
Up until now, Zephyr has patched Kconfig to use the last 'default' with
a satisfied condition, instead of the first one. I'm not sure why the
patch was added (it predates Kconfiglib), but I suspect it's related to
Kconfig.defconfig files.

There are at least three problems with the patch:

  1. It's inconsistent with how Kconfig works in other projects, which
     might confuse newcomers.

  2. Due to oversights, earlier 'range' properties are still preferred,
     as well as earlier 'default' properties on choices.

     In addition to being inconsistent, this makes it impossible to
     override 'range' properties and choice 'default' properties if the
     base definition of the symbol/choice already has 'range'/'default'
     properties.

     I've seen errors caused by the inconsistency, and I suspect there
     are more.

  3. A fork of Kconfiglib that adds the patch needs to be maintained.

Get rid of the patch and go back to standard Kconfig behavior, as
follows:

  1. Include the Kconfig.defconfig files first instead of last in
     Kconfig.zephyr.

  2. Include boards/Kconfig and arch/<arch>/Kconfig first instead of
     last in arch/Kconfig.

  3. Include arch/<arch>/soc/*/Kconfig first instead of last in
     arch/<arch>/Kconfig.

  4. Swap a few other 'source's to preserve behavior for some scattered
     symbols with multiple definitions.

     Swap 'source's in some no-op cases too, where it might match the
     intent.

  5. Reverse the defaults on symbol definitions that have more than one
     default.

     Skip defaults that are mutually exclusive, e.g. where each default
     has an 'if <some board>' condition. They are already safe.

  6. Remove the prefer-later-defaults patch from Kconfiglib.

Testing was done with a Python script that lists all Kconfig
symbols/choices with multiple defaults, along with a whitelist of fixed
symbols. The script also verifies that there are no "unreachable"
defaults hidden by defaults without conditions

As an additional test, zephyr/.config was generated before and after the
change for several samples and checked to be identical (after sorting).

This commit includes some default-related cleanups as well:

  - Simplify some symbol definitions, e.g. where a default has 'if FOO'
    when the symbol already has 'depends on FOO'.

  - Remove some redundant 'default ""' for string symbols. This is the
    implicit default.

Piggyback fixes for swapped ranges on BT_L2CAP_RX_MTU and
BT_L2CAP_TX_MTU (caused by confusing inconsistency).

Piggyback some fixes for style nits too, e.g. unindented help texts.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-10 12:38:28 -07:00
Andrzej Głąbek 16e8860f6c drivers: i2c: nrfx: Use HAS_HW_NRF_* in driver options dependencies
Use the HAS_HW_NRF_* symbols instead of the SOC_SERIES_NRF* ones
to filter out the driver options unavailable on particular SoCs.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2018-08-08 17:23:55 +02:00
Ulf Magnusson 995411f4e2 drivers/i2c: kconfig: Clean up I2C Kconfigs a bit
- Get rid of duplicate I2C dependencies, which show up in the
  documentation as e.g. 'I2C && I2C'. The 'source's in
  drivers/i2c/Kconfig are already within an 'if I2C' block.

- Factor out I2C_GPIO_<n> dependencies in drivers/i2c/Kconfig.gpio into
  'if I2C_GPIO_<n>' blocks.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-02 19:12:52 +02:00
Ulf Magnusson d1684a83a4 Kconfig: Clean up some symbol definitions
- Remove redundant 'n' defaults. 'n' is the default value for bool
  symbols.

  This makes the auto-generated documentation clearer as well: You get
  "implicitly defaults to n" instead of
  "- n if <propagated dependencies>".

- Shorten

      <type>
      prompt "foo"

  to

      <type> "foo"

  This works for all types, not just bool.

- Various formatting nits.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-01 12:47:17 -04:00
Daniel Leung 67b48ab2a8 drivers/i2c: i2c_dw: extends driver to support 8 controllers
This adds the necessary driver structs to support a total of 8
I2C controllers. This also allows each I2C controller to have
its own PCI vendor/device IDs.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2018-07-27 17:16:18 -04:00
Daniel Leung 982b4e14c4 drivers/i2c: extends Kconfig to support 8 controllers
This simply adds 3 set of new Kconfig options to support
a total of 8 I2C controllers.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2018-07-27 17:16:18 -04:00
Aurelien Jarno 6c49ce16c2 drivers: i2c: stm32: 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 ...'

This is basically reapplying commit 133a299b50 ("drivers: i2c: Kconfig:
Remove redundant 'default n' properties"), which has been partially
reverted in commit c7875b75aa ("i2c: stm32_v2: implement slave
support").

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2018-07-25 07:19:12 -04:00
Aurelien Jarno 97bc5abedf drivers: i2c: stm32: add support for STM32F7
The STM32F7 uses the V2 version of the STM32 I2C controller. Add the
corresponding Kconfig, DTS, DTS fixup and pinmux entries.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2018-07-25 07:19:12 -04:00
Vitor Massaru Iha f8718758e5 include: drivers: gpio: Turn functions generic - esp32
On 'drivers/i2c_esp32.c' there are functions useful for other
drivers. Functions and struct went moved to:

 * arch/xtensa/soc/esp32/peripheral.h
 * arch/xtensa/soc/esp32/soc.h
 * include/drivers/gpio/gpio_esp32.h

Signed-off-by: Vitor Massaru Iha <vitor@massaru.org>
2018-07-15 16:13:36 -04:00
Diego Sueiro 8c2acab53a drivers: add i.MX I2C driver shim
Adds a shim layer around the imx i2c driver to adapt it to the Zephyr
i2c master interface.

Signed-off-by: Diego Sueiro <diego.sueiro@gmail.com>
2018-07-06 15:55:57 -05:00
Daniel Wagenknecht c7875b75aa i2c: stm32_v2: implement slave support
This patch adds I2C Slave support conforming to the syscalls and funcs,
only for the STM32 V2 I2C Driver for the moment.

It is capable of handling multi-master bus setups.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: Daniel Wagenknecht <wagenknecht@clage.de>
2018-07-04 11:57:33 +02:00
Neil Armstrong 9a73cdfe9e i2c: slave: Add EEPROM I2C Slave driver
Add a new EEPROM simulated driver with all it's build infrastructure.

The EEPROM can be loaded/poked from applications by getting its funcs.

It is multi-instance capable, right now 2 instances are supported by
enabling them in KConfig.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: Daniel Wagenknecht <wagenknecht@clage.de>
2018-07-04 11:57:33 +02:00
Neil Armstrong d55a6aa32d i2c: Add new I2C Slave syscalls
This patchs adds new I2C Syscalls for :
- I2C controllers slave support
- I2C Slave drivers support

I2C Controllers slave support adds 2 new ops to :
- register new slave driver
- unregister slave driver

Slave funcs consists on all the I2C phases :
- read or write request once address matches
- read or write done once the byte has been received/sent
- stop when the trasmit stops

I2C Slave drivers syscall are also added to make new
"I2C Slave" drivers to :
- register them to their I2C controller
- unregister them to their I2C controller

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
2018-07-04 11:57:33 +02:00
Daniel Wagenknecht 81cfdec3a9 i2c: stm32_v2: restructure interrupt handling
This patch restructures stm32_i2c_v2 drivers Interrupts:
- NACK failures trigger an I2C event interrupt, so move
handling of NACK failure from error isr to event isr.
- Extract logic of interrupt handling to static functions. Use
isr functions (event & error OR combined) to call these. This
reduces duplication between error isr and combined isr.
- Restructure the error interrupt handling, so that it has no effect
when no errors occured and thus can be called by combined isr.
- Change interrupt logic from if/else to pure ifs for each flag.
This reduces code paths and leads to one call of the isr handling
multiple interrupt conditions, if there's more than one I2C
interrupt flags set.
This is the way it's done e.g. in linux kernels (since 4.14)
drivers/i2c/busses/i2c-stm32f7.c

Signed-off-by: Daniel Wagenknecht <wagenknecht@clage.de>
2018-07-04 11:57:33 +02:00
Daniel Wagenknecht cc4191666b i2c: stm32: check messages before starting transmission
In preparation to implementing slave and multi-master
capabilities for STM32 I2C V2 driver move the checks,
whether all messages of a transfer are valid, before
starting the transaction.

This prevents having to abort a transmission, that is
already partly transmitted.

Signed-off-by: Daniel Wagenknecht <wagenknecht@clage.de>
2018-07-04 11:57:33 +02:00
Ulf Magnusson 133a299b50 drivers: i2c: 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
Kumar Gala 1ce259d149 drivers: i2c: nrfx: Move device tree selection to driver Kconfig
Move HAS_DTS_I2C from board to the driver Kconfig.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-07-02 09:46:22 -05:00
Mieszko Mierunski dc1c2742b6 boards: nrf: Moved SDA and SCL pin configuration to DTS for nRF boards
SDA and SCL pins can now be configured through DTS.
Pins on development kits have been assigned according to arduino
headers.

Signed-off-by: Mieszko Mierunski <mieszko.mierunski@nordicsemi.no>
2018-06-20 13:38:18 +02:00
Mieszko Mierunski 1aa61d60c5 drivers: i2c: Removed redundant i2c_nrf5 shim
After switching to TWI and TWIM drivers, old i2c_nrf5 shim
is no longer needed.

Signed-off-by: Mieszko Mierunski <mieszko.mierunski@nordicsemi.no>
2018-06-20 13:38:18 +02:00
Mieszko Mierunski 1edc29c47f drivers: i2c: Add shims for nrfx TWI and TWIM drivers
Changes add a translation layer to make nrfx TWI and TWIM drivers
work with Zephyr API.

Signed-off-by: Mieszko Mierunski <mieszko.mierunski@nordicsemi.no>
2018-06-20 13:38:18 +02:00
Aurelien Jarno 8e15353de5 i2c: i2c_gpio: fix typos in Kconfig file
This file is about I2C bus, not the I2S one.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2018-05-26 19:07:55 -04:00
Tomasz Bursztyka 60d509f3d7 arch: Use dts to set i2c priorities for quark_se/quark_d2000
Fix the qmsi i2c driver and the relevant SoCs accordingly.
Also applying relevant changes on quark_se_c1000_ss as it can use i2c
qmsi driver as well along with qmsi ss i2c driver.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-05-18 20:18:50 +03: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 af601c22e6 i2c: stm32: add support for I2C4
Add the necessary Kconfigs and supporting code to enable I2C4 which can
be found on certain STM32L4.

Signed-off-by: Florian Vaussard <florian.vaussard@gmail.com>
2018-05-17 13:08:36 -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
Leandro Pereira 25fb83c6e0 drivers: i2c: Fix TOCTOU while transferring I2C messages
All the mesages are checked with _SYSCALL_MEMORY() prior to calling the
actual implementation function.  However, a race condition might happen
between the check and the call to _impl_i2c_transfer() itself.

Copy the msgs vector to a locally allocated array and pass it to the
transfer implementation.

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2018-04-24 18:30:00 -07:00
Tomasz Bursztyka 74d1835505 drivers/i2c: Make QMSI SS driver IRQs set via CONFIG_ options
Now that dts i2 qmsi ss nodes generate the right options, let's use
them. Apply the relevant fixup on the targeted SoC.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-03-23 10:42:33 +08:00
Tomasz Bursztyka 7af98f5e67 drivers/i2c: Use standard bitrate settings for QMSI SS driver
Apply the change on relevant arch/boards.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-03-23 10:42:33 +08:00
Tomasz Bursztyka 9b77741d63 drivers/i2c: Use standard bitrate settings for QMSI driver
Apply the change on relevant arch/boards.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-03-23 10:42:33 +08:00
Tomasz Bursztyka 8f891ba702 drivers/i2c: Use standard bitrate settings for DW driver
Applying the change to relevant arch/boards, either in their Kconfig or
the dts specific files.

Taking the opportunity in dw driver to rename the variable the same way
as they are everywhere else in the code (s/dev/dw and s/port/dev) in
init function.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-03-23 10:42:33 +08:00
Tomasz Bursztyka ae18040109 drivers/i2c: Removing useless configuration attribute in DW driver
Probably a left over form legacy interrupt handling.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-03-23 10:42:33 +08:00
Tomasz Bursztyka 860d40f94e drivers/i2c: Disable some QMSI SS option when HAS_DTS_I2C is enabled
These options will be generated through DTS.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-03-23 10:42:33 +08:00
Tomasz Bursztyka 6d247b5c2b drivers/i2c: Rename generic configure option in DW drivers
And adapt SoC's information relevantly.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-03-23 10:42:33 +08:00
Tomasz Bursztyka d506da2879 drivers/i2c: Indent sources the same way everywhere
Using tabs only.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-03-23 10:42:33 +08:00
Tomasz Bursztyka d95fa65270 drivers/i2c: Cleanup Kconfig
Move driver specific to dedicated file when relevant (i.e.: more than
1-2 options), use if/endif also.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-03-23 10:42:33 +08:00
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
Ilya Tagunov 9ae3fdc2ef arch: arm: soc: stm32l0: add I2C support
Add I2C support for STM32L0 series. LL-based driver
was already in place, so I've just enable it.

Signed-off-by: Ilya Tagunov <tagunil@gmail.com>
2018-03-14 09:02:25 -05:00
Aapo Vienamo 422bc240b4 soc: nrf5: Use i2c configure options generated from dts
SoC dts fixups are added and the i2c_nrf5 driver is modified to use
the values generated from the device tree.

The I2C_*_DEFAULT_CFG and I2C_*_IRQ_PRI options are removed from board
defconfigs. Bitrate and IRQ priority are configured using using the
device tree instead.

HAS_DTS_I2C is selected on all nrf5 boards to prevent generation of
conflicting defines from Kconfig.

Signed-off-by: Aapo Vienamo <aapo.vienamo@iki.fi>
2018-03-13 14:14:13 +01:00
Aapo Vienamo 1cf09e86ed drivers: i2c: nrf5: Make the driver thread-safe
Locking is added to externally callable API functions.

Signed-off-by: Aapo Vienamo <aapo.vienamo@iki.fi>
2018-03-03 20:41:37 +01:00
Ramakrishna Pallala 5f1b366713 drivers: i2c: i2c_nios2: Fix format specifiers in log messages
Fix format specifiers in SYS_LOG_ERR messages.

Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
2018-02-09 10:11:52 -05:00
Ramakrishna Pallala c9a4fd94ba drivers: i2c: i2c_nios2: Fix SYS_LOG warnings
Fix sys log compilation warnings by defining the
SYS_LOG_LEVEL to SYS_LOG_I2C_LEVEL in Nios-II i2c driver.

This commit fixes Issue #6062

Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
2018-02-08 23:28:28 -05:00
Ramakrishna Pallala 3eb62bc905 drivers: i2c: Add i2c master driver for Nios-II i2c core
Add I2C Master driver for Nios-II I2C soft IP core.

This driver relies upon the Altera HAL I2C driver for all the bus level
transactions, interrupt handling and register programming.

Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
2018-02-07 19:37:35 -05:00
Vitor Massaru Iha e9d1015da9 drivers: i2c: esp32: Fix to_read value on i2c_esp32_read_msg()
to_read is the minimum value between I2C_ESP32_BUFFER_SIZE
and (msg.len - 1) rather than the maximum value.

Signed-off-by: Vitor Massaru Iha <vitor@massaru.org>
2018-02-07 14:52:52 -05:00
Vitor Massaru Iha 74321ec9fd drivers: i2c: esp32: Fix msg.len on i2c_esp32_write_addr()
msg.len is incremented only when I2C master writes to slave.

Signed-off-by: Vitor Massaru Iha <vitor@massaru.org>
2018-02-07 14:52:52 -05:00
Vitor Massaru Iha 463bfb3489 drivers: i2c: esp32: Fix increase I2C_ESP32_SPIN_THRESHOLD
Increase I2C_ESP32_SPIN_THRESHOLD to avoid read or write timeout.
This is an empirical value.

Signed-off-by: Vitor Massaru Iha <vitor@massaru.org>
2018-02-07 14:52:52 -05:00
Vitor Massaru Iha 93c3def27e drivers: i2c: esp32: Fix command opcode on i2c_esp32_write_addr()
When I2C Master writes to slave on CMD_Controller, opcode WRITE
was set twice instead of 1 WRITE at the beginning of the
transmission.

And when Master reads from slave, on CMD_Controller,
byte_num = 1 + data_lenght instead of byte_num = 1 at the
beginning of the transmission.

Note that is for 7 bits addresses, to 10 bit adressess is added
more 1 in byte_num as can be seen in the code above this fix.

Signed-off-by: Vitor Massaru Iha <vitor@massaru.org>
2018-02-07 14:52:52 -05:00
Vitor Massaru Iha 6452b2e5e2 drivers: i2c: esp32: Fix command address on i2c_esp32_write_msg()
The wait address command must be the last command address.

Unncessary variable was removed.

Signed-off-by: Vitor Massaru Iha <vitor@massaru.org>
2018-02-07 14:52:52 -05:00
Vitor Massaru Iha 685f09779d drivers: i2c: esp32: Fix END opcode on i2c_esp32_write_msg()
After a STOP opcode the transmission stops. The END opcode in this
case is unnecessary.

Signed-off-by: Vitor Massaru Iha <vitor@massaru.org>
2018-02-07 14:52:52 -05:00
Vitor Massaru Iha 2ef5b6d128 drivers: i2c: esp32: Fix first command on I2C Master
On i2c_esp32_read_msg() and i2c_esp32_write_msg() first command
it should be always RSTART.

Signed-off-by: Vitor Massaru Iha <vitor@massaru.org>
2018-02-07 14:52:52 -05:00
Aapo Vienamo f09bab9662 drivers: i2c: nrf5: Make pins for Port 1 configurable
CONFIG_I2C_NRF5_GPIO_SDA_PIN and CONFIG_I2C_NRF5_GPIO_SCL_PIN are
replaced with port specific versions. Board defconfigs relying on the
original names are updated. The driver is also modified to pass the
configure values to registers.

Signed-off-by: Aapo Vienamo <aapo.vienamo@iki.fi>
2018-02-05 16:12:48 -05:00
Aapo Vienamo 22e5b07e52 drivers: i2c: nrf5: Fix SDA pin naming
The instances of where SDA has been typoed SCA are fixed.

Signed-off-by: Aapo Vienamo <aapo.vienamo@iki.fi>
2018-02-05 16:12:48 -05:00
Erwin Rol 5ed492e0c7 drivers: i2c: stm32: use Kconfig to select HAL/LL sources
Use "select USE_STM32_LL_I2C" to select the needed STM32 LL 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
Vitor Massaru Iha 53ccc84f88 drivers: i2c: esp32: Fix status address register
I2C_BUS_BUSY flag is in I2C_SR_REG according i2c_reg.h.

Signed-off-by: Vitor Massaru Iha <vitor@massaru.org>
2018-01-16 13:48:27 -05:00
Manivannan Sadhasivam 2b0821cce7 drivers: i2c: stm32f4: Fix incorrect buffer assignment
Wrong buffer assigned for receiving the last 2 bytes in multi
byte reception of STM32F4 i2c driver. Change the buffer to
correct one.

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
2018-01-13 11:36:15 -08:00
Manivannan Sadhasivam 1bd48edd26 drivers: i2c: stm32f4: Add check for BTF flag before reading N-2 byte
According to STM32F4 reference manual, software should wait for BTF=1
before reading N-2 data byte.

Reference:

"For N >2 -byte reception, from N-2 data reception" section, page
853 of STM32F4 Reference manual.

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
2018-01-12 09:33:27 -06:00
Florian Vaussard 5491c29314 i2c: stm32_ll: Fix spurious error while reading using IRQ
We can have a spurious error while performing a transfer using IRQ. This
happens when the last message of the transfer is a read with a STOP
condition. We must disable the RX interrupt while waiting for the STOP
interrupt, otherwise we will get a spurious RX interrupt which will lead
to an error.

Signed-off-by: Florian Vaussard <florian.vaussard@gmail.com>
2018-01-11 19:00:19 -05:00
Gil Pitney e5cef70abd drivers: i2c: Add support for cc32xx I2C bus
This was validated on the cc3220sf_launchxl board
using the Zephyr thermometer sample program
adapted to call the i2c driver directly, and fetching
samples from the on-board TMP006 temperature sensor.

Signed-off-by: Gil Pitney <gil.pitney@linaro.org>
2018-01-09 08:39:59 -06:00
Neil Armstrong 59d33b5f27 i2c: stm32_ll: add support for STM32F0 with combined irq
The STM32F0 has only a single IRQ line, add a combined IRQ handler.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
2017-12-12 12:36:08 -06:00
Daniel Wagenknecht 02a46e7197 drivers: i2c_ll_stm32_v2: don't use while loops in interrupt mode
Waiting for transfer complete and stop condition uses while loops
even when interrupt mode is enabled.
Implement use of TC, TCR and STOP interrupt for interrupt mode.
msg_done is not needed in interrupt mode anymore, so move it
to non-interrupt section
Tested with stm32f3_disco board.

Signed-off-by: Daniel Wagenknecht <wagenknecht@clage.de>
2017-11-28 11:21:06 -06:00
Daniel Wagenknecht 5380bc597f drivers: i2c_ll_stm32_v2: reorder to remove duplication
Disabling of Interrupts is duplicated. Move it to a position
that is common to messages that end with and without errors.

Signed-off-by: Daniel Wagenknecht <wagenknecht@clage.de>
2017-11-28 11:21:06 -06:00
Leandro Pereira 07e1a64e77 drivers: i2c_gpio: Use quoted #include directive for i2c_bitbang
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2017-11-22 18:49:17 -05:00
Piotr Mienkowski 8bfcfe5545 drivers: i2c: Add DTS support for i2c_sam_twihs driver
Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2017-11-15 11:13:08 -06:00
Piotr Mienkowski 1f47ed75b7 drivers: i2c: rename twihs_sam to i2c_sam_twihs
Rename the Atmel SAM I2C driver based on TWIHS module to match the
convention:
<driver class>_<SoC family>_<hardware module used by the driver>

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2017-11-15 11:13:08 -06:00
Piotr Mienkowski e7dd844c6a drivers: i2c: Refactor Atmel SAM (TWIHS) driver
Various minor changes to the Atmel SAM (TWIHS) driver
- clean up variable names, comments
- refactor i2c_clk_set function
- do not save configuration in dev_data
- improve ISR NACK handling
- print "Device initialized" string

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2017-11-15 11:13:08 -06:00
Yannis Damigos cf2eb7d1fa drivers: i2c_ll_stm32_v2: Use the correct flags in event ISR
Event ISR checks if the TX/RX interrupts is enabled instead
of the TXIS/RXNE interrupt status flags. Use the TXIS/RXNE
interrupt status flags to check which interrupt event
happened.

Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
Signed-off-by: Daniel Wagenknecht <wagenknecht@clage.de>
2017-11-15 09:09:58 -06:00
Yannis Damigos b80da2b710 drivers: i2c_ll_stm32: Use I2C API flags
STM32 I2C driver doesn't use the I2C API flags STOP/RESTART,
instead it uses its own RESTART flag. As a result, I2C API's
i2c_burst_write* funtions doesn't work. This patch makes
STM32 I2C driver to use I2C API flags.

Tested on: 96b_carbon, olimexino_stm32 (i2c_ll_stm32_v1)
Tested on: stm32f3_disco, disco_l475_iot1 (i2c_ll_stm32_v2)

Fixes: #4459

Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
Signed-off-by: Daniel Wagenknecht <wagenknecht@clage.de>
2017-11-15 09:09:58 -06:00
Sebastian Bøe 780d9facbe cmake: s/CONFIG_I2C_STM32_V1x/CONFIG_I2C_STM32_V1/
Fix typo in build scripts for STM's I2C driver. The typo was
introduced in the cmake migration.

Discovered by Dmitry:
https://lists.zephyrproject.org/pipermail/zephyr-devel/2017-November/008383.html

Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-15 07:06:26 -06:00
Sebastian Bøe f2a3977261 cmake: Added missing zephyr_sources() calls for esp32 drivers
Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-14 10:47:15 -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
Daniel Wagenknecht c404c3b241 i2c: fix issue of stm32-i2c-v2 (F0/F3/F7) driver hanging in endless loop
Fixes #4429
Driver didn't work properly when a transfer consisted of multiple
messages.
Fix doesn't use auto end mode anymore. msg_done function waits for
transfer to complete and issues stop condition if necessary.

Tested with stm32f3_disco board and samples/drivers/i2c_fujitsu_fram
example adapted to use I2C_1 as I2C_DEV

Signed-off-by: Daniel Wagenknecht <wagenknecht@clage.de>
2017-11-03 13:52:57 -05:00
Andrew Boie 2a2a855aa8 drivers: i2c: add system call handlers
i2c actually only has two entry points into the driver,
i2c_configure and i2c_transfer. All the other APIs are derived
from these.

All derived APIs now just call i2c_transfer() with appropriate args.

The handler for i2c_transfer() needs to examine the message array
and validate all the buffers involved depending on whether we are
reading or writing to them.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-10-30 13:20:19 -07:00
Rajavardhan Gundi c24b77f84f i2c/i2c_dw: configure ic_tar based on ic_10bitaddr_master
This ensures DW_apb_i2c correctly transmits the slave address (7 or
10 bit) based on ic_10bitaddr_master when configured in master mode.

Signed-off-by: Rajavardhan Gundi <rajavardhan.gundi@intel.com>
2017-10-28 07:22:28 -04:00
Rajavardhan Gundi 51e7fc7cf8 i2c/i2c_dw: correct the bitfield for ic_tar and ic_sar
The ic_tar and ic_sar were earlier set to 9 bits but now its
corrected to consider 10 bits.

Signed-off-by: Rajavardhan Gundi <rajavardhan.gundi@intel.com>
2017-10-28 07:22:28 -04:00
Piotr Mienkowski 5bb0172839 drivers: i2c: deprecate usage of i2c_atmel_sam3 driver
Atmel SAM3X series has been recently converted to use ASF and
should now use common SAM family drivers. The i2c_atmel_sam3
I2C driver will be removed in the future.

This commit also changes the default I2C driver for Arduino Due
board from i2c_atmel_sam3 to i2c_sam_twi.

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2017-10-23 10:18:08 +02:00
Piotr Mienkowski 26ba99e972 drivers: Add Atmel SAM family I2C (TWI) driver
Added I2C bus (TWI) driver for Atmel SAM MCU family. Only
I2C Master Mode with 7 bit addressing is currently supported.

Tested on Arduino Due board.

Origin: Original

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2017-10-23 10:18:08 +02:00
Yannis Damigos 1a85a80200 drivers: i2c_ll_stm32: STM32F0/3 set I2C clock source
STM32F0/3 I2C's independent clock source supports only
HSI and SYSCLK, not APB1. We force I2C clock source to SYSCLK.

Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
2017-10-20 12:28:11 -05:00
Ravi kumar Veeramally b2d3656c1d i2c: twihs_sam: fix mode config variable usage
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-10-20 13:22:25 -04:00
Leandro Pereira 803984837f drivers: i2c: esp32: Fix crash when enabling second I2C device
IRQ_CONNECT() was being expanded with the IRQ line for the first device
twice, causing spurious IRQs.

Should fix #4398.

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2017-10-19 20:09:23 -04:00
David B. Kinder 4600c37ff1 doc: Fix misspellings in header/doxygen comments
Occasional scan for misspellings missed during PR reviews

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2017-10-17 19:40:29 -04:00
Leandro Pereira e1effa0e73 drivers: esp32: I2C driver implementation
Supports both master and slave mode, standard and fast modes,
configurable timeouts, and a few other tunable settings.

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2017-10-09 20:53:22 -04:00
Anas Nashif 3b7dd6ef4e i2c: fix include for i2c_bitbang in some drivers
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-10-03 14:50:14 -04:00
Kumar Gala 83643a2266 drivers: i2c: remove usage of bitfield access for cfg
Cleanup I2C drivers to not use bitfield access for config information
and instead use accessor macros that use shifts & masks.  This is
cleanup towards removing the bitfield access in the future.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-09-20 10:16:14 -05:00
Leandro Pereira 4547b5ca06 drivers: i2c: sbcon: Only show SBCon when building for ARM
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2017-09-17 09:28:30 -04:00
Piotr Mienkowski af99f62237 drivers: i2c: hide I2C_x_DEFAULT_CFG for DTS drivers
I2C device drivers which support DTS have their default boot
configuration provided by DTS. The legacy I2C_x_DEFAULT_CFG
option in Kconfig is no longer required. This patch hides
this option from the Kconfig menu for I2C device drivers which
support DTS.

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2017-09-13 07:38:59 -05:00
Yannis Damigos 4428022dce drivers: i2c_ll_stm32: Fix building for interrupt mode
The compilation of the i2c_ll_stm32 fails when we
enable the interrupt mode. The struct i2c_stm32_data
is needed to initialize the semaphore. This patch adds
the missing struct for interrupt mode.

Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
2017-08-23 08:28:21 -05:00
Kumar Gala 99c19c62e1 i2c: stm32: Remove usage of CONFIG_I2C_x_DEFAULT_CFG
Stop using CONFIG_I2C_x_DEFAULT_CFG to get the initial value.  Since we
only support master mode we always default to it for initial config and
we get the bitrate from the device tree.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-08-16 10:03:34 -05:00
Kumar Gala 54933b3833 i2c: mcux: Remove usage of CONFIG_I2C_x_DEFAULT_CFG
Stop using CONFIG_I2C_x_DEFAULT_CFG to get the initial value.  Since we
only support master mode we always default to it for initial config and
we get the bitrate from the device tree.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-08-16 10:03:34 -05:00
Kumar Gala 9935581d8a i2c: Add helper function to map from bitrate values to zephyr cfg
Add _i2c_map_dt_bitrate() that maps from a bitrate to the I2C zephyr
cfg bit fields used in i2c_configure().

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-08-16 10:03:34 -05:00
Yannis Damigos 22912ffcf9 drivers: i2c_ll_stm32_v1: Fix RX for all receptions
This patch fixes the read operation of the I2C driver
for all the receptions (1-byte, 2-bytes, N-bytes when
N > 2)

Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
Tested-by: Yannis Damigos <giannis.damigos@gmail.com>
Tested-by: Martin Iñaki Malerba <inakimmalerba@gmail.com>
2017-08-10 12:45:44 -05:00
Yannis Damigos 9a9f65fd0c drivers: i2c_ll_stm32_v1: Fix TX if flag I2C_MSG_RESTART is set
In interrupt mode, the drivers entered a forever loop if the
I2C_MSG_RESTART flag was set. This patch fix this issue.

Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
2017-08-10 12:45:44 -05:00
Yannis Damigos 654b3381aa drivers: i2c_ll_stm32_v1: Disable/enable only Buffer interrupts
The EVENT interrupt is generated when:
– SB = 1
– ADDR = 1
– ADD10= 1
– BTF = 1 with no TxE or RxNE event
– TxE event to 1 if Buffer interrupt enabled
– RxNE event to 1 if Buffer interrupt enabled

We need to disable and enable the Buffer TxE and RxNE interrupt
inside the EVENT ISR. The LL_I2C_{Enable,Disable}IT_TX and
LL_I2C_{Enable,Disable}IT_RX functions, used now, enable and
disable both Buffer and Event interrupt. This patch uses the
LL_I2C_EnableIT_BUF and  LL_I2C_DisableIT_BUF functions to
enable and disable the Buffer interrupt (TxE, RxNE).

Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
2017-08-10 12:45:44 -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
Kumar Gala 563f8f1464 i2c: mcux: Convert to supporting device tree
Update the MCUX I2C driver and related platforms to get their I2C
information from the device tree.  We also updated a few of the sensor
drivers found on the FRDM & Hexiwear boards to get their I2C bus name
from the device tree instead of directly from Kconfig.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-07-19 14:28:08 -05:00
Yannis Damigos 5b3a71a810 i2c: stm32: Update driver to get I2C port base address from DT
Update the STM32 I2C driver to get I2C port base address
from the device tree

Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
2017-07-19 14:28:08 -05:00
Kumar Gala 710807fa1e i2c: Fix missing Kconfig !HAS_I2C_DTS dependencies
As I2C_0 (port 0) isn't used on the STM32 platforms we didn't exclude
the related Kconfig options if DTS was enabled.  However other SoCs
(like NXP) do use I2C_0 so we need to fixup the Kconfig dependencies

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-07-19 14:28:08 -05:00
Yannis Damigos 1bc2fdc704 dts: arm: STM32 boards use DT to configure I2C
Configure I2C using DT for the following STM32 boards:

disco_l475_iot1
nucleo_f401re
96b_carbon
olimexino_stm32

Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
2017-07-07 10:31:34 -05:00
Kumar Gala 9eddc82be3 i2c: remove I2C Slave Read config
The I2C Slave Read support isn't well defined and not actually supported
by any i2c driver at this point.  We can add this back when slave mode
is more thought out.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-07-07 10:01:38 -05:00
Kumar Gala 4c233bbc05 i2c: stm32: fix build issue
When building tests/kernel/test_build/test_debug on disco_l475_iot1 we
get the following build error:

drivers/i2c/i2c_ll_stm32_v2.c: In function ‘stm32_i2c_configure_timing’:
ext/hal/st/stm32cube/stm32l4xx/soc/stm32l4xx.h:207:38: error: ‘timing’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
 #define WRITE_REG(REG, VAL)   ((REG) = (VAL))
                                      ^
drivers/i2c/i2c_ll_stm32_v2.c:265:8: note: ‘timing’ was declared here
  u32_t timing;
        ^~~~~~

Fix by initializing timing to 0.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-07-06 09:53:00 -05:00
Jorge Ramirez-Ortiz 21fbc9b07e drivers: i2c: stm32 LL F1/F4 (v1) STM32 F3/L4X (v2)
Supports STM32 F1/F4 (v1 controller) and STM32 F3/L4X (v2
controller)

v1 could also support L1X.
v2 could also support F7X.

Signed-off-by: Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>
Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
Reviewed-by: Yannis Damigos <giannis.damigos@gmail.com>
Tested-by: Yannis Damigos <giannis.damigos@gmail.com>
Tested-by: Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>
2017-07-01 08:36:51 -04:00
Piotr Mienkowski ee66ee6c34 arch: sam3x: Use ASF library
This patch converts Atmel sam3x MCU series to use register
header files from Atmel Software Framework (ASF) library.
By using ASF different Atmel SAM MCU series can use common
device drivers.

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2017-05-19 10:06:48 -04:00
Justin Watson 558281b096 arch: sam3x: update Kconfig options after move to SAM SoC family tree
The files for the Arduino Due needed to be updated to use the new
configuration when the SoC moved from the atmel_sam3 directory to
the atmel_sam/sam3x directory.

Jira: ZEP-2067

Signed-off-by: Justin Watson <jwatson5@gmail.com>
2017-05-03 13:51:37 -04:00
Jon Medhurst 1c1507d4cd i2c: i2c_sbcon: Driver for ARM's SBCon 2-wire serial interface
SBCon is a simple device which allows directly setting and getting the
hardware state of two-bit serial interfaces like I2C. Therefore to be
useable we need to drive the lines with the appropriate protocol under
software control.

Change-Id: If9000bb75f7b0ad7bbb256b1cb38cc70fa6ca8ea
Signed-off-by: Jon Medhurst <tixy@linaro.org>
2017-05-03 13:51:37 -04:00
Piotr Mienkowski 068766f7be drivers: i2c: clean up Kconfig file
Several minor changes to clean up I2C Kconfig file
- align help text
- remove duplicate dependencies
- use unified naming for I2C port options
- replace outdated references to datasheet in help text
- add comments at the end of 'endif'

Change-Id: I452083feb29f40909e6e38324ff9d9961fc6bd07
Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2017-04-29 11:48:08 -04:00
Jon Medhurst 5b04bd9aa4 i2c: i2c_gpio: Driver for software driven I2C using GPIO lines
This driver implements an I2C interface by driving two GPIO lines under
software control.

Change-Id: Ie49cc67aed6acb30086ee851041fe2470da241cf
Signed-off-by: Jon Medhurst <tixy@linaro.org>
2017-04-28 15:26:40 -05:00
Jon Medhurst 0818564753 i2c: bitbang: Add library for software driven I2C
This library implements the I2C single master protocol in software.
It supports the Standard-mode and Fast-mode speeds and doesn't support
optional protocol feature like 10-bit addresses or clock stretching.

Change-Id: I375d572a83714522421f2967dc414b3bec169e95
Signed-off-by: Jon Medhurst <tixy@linaro.org>
2017-04-28 15:26:39 -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 cc334c7273 Convert remaining code 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.  This handles the remaining includes and kernel, plus
touching up various points that we skipped because of include
dependancies.  We also convert the PRI printf formatters in the arch
code over to normal formatters.

Jira: ZEP-2051

Change-Id: Iecbb12601a3ee4ea936fd7ddea37788a645b08b0
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-21 11:38:23 -05: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
Kumar Gala 789081673f Introduce new sized integer typedefs
This is a start to move away from the C99 {u}int{8,16,32,64}_t types to
Zephyr defined u{8,16,32,64}_t and s{8,16,32,64}_t.  This allows Zephyr
to define the sized types in a consistent manor across all the
architectures we support and not conflict with what various compilers
and libc might do with regards to the C99 types.

We introduce <zephyr/types.h> as part of this and have it include
<stdint.h> for now until we transition all the code away from the C99
types.

We go with u{8,16,32,64}_t and s{8,16,32,64}_t as there are some
existing variables defined u8 & u16 as well as to be consistent with
Zephyr naming conventions.

Jira: ZEP-2051

Change-Id: I451fed0623b029d65866622e478225dfab2c0ca8
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-20 16:07:08 +00:00
Piotr Mienkowski 5c83e3817d drivers: Add Atmel SAM family I2C (TWIHS) driver
Added I2C bus (TWIHS) driver for Atmel SAM MCU family. Only
I2C Master Mode with 7 bit addressing is currently supported.

Tested on Atmel SMART SAM E70 Xplained board

Origin: Original

Jira: ZEP-1866
Change-Id: Ic5aa7b6b21295feccae883d580b38bbeaf2ce291
Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2017-04-14 05:56:54 -05:00
Erwan Gouriou b8297e8fb8 drivers: i2c: stm32: fix i2c_2 instance config
Wrong base address has been provided to I2C_2 instance.
Fix this issue for proper behavior

Change-Id: I81e5cb71a5136e742f460db5db39b2adf2f10f2d
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2017-04-14 05:56:53 -05:00
Piotr Mienkowski a8de9ff438 drivers: i2c: rename IRQ SHARED/DIRECT Kconfig options
I2C_SHARED_IRQ, I2C_0_IRQ_SHARED, I2C_0_IRQ_DIRECT Kconfig options
are DW driver specific. Its presence is confusing for a user of any
other I2C driver than DW. This patch renames these options to include
DW string and makes it visible only for DW I2C driver. This is a
similar implementation to that used by ETH DW Ethernet driver.

Change-Id: I795506f9b103c028a22317df9ad632dce5cd1343
Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2017-04-14 01:58:33 +00:00
Piotr Mienkowski 06685e75ae drivers: i2c: place all I2C Kconfig options in submenu
To follow Zephyr convention this patch is placing all I2C driver
Kconfig options in submenu.

Change-Id: Ibc485305b7effb65ed7f24b933fe35d0fa0afee8
Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2017-04-08 00:12:30 +00:00
Piotr Mienkowski f33b277e6f drivers: i2c: rename I2C_CLOCK_SPEED Kconfig option
I2C_CLOCK_SPEED Kconfig option is DW driver specific. It does not
define I2C interface speed but rather the I2C DW module clock speed.
It is confusing for a user of any other I2C driver than DW.
This patch renames this option to I2C_DW_CLOCK_SPEED and makes it
visible only for DW I2C driver.

Change-Id: I97f57332fd5cca644eabdef0968a0b2174b885ff
Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2017-04-08 00:12:29 +00:00
Roger Lendenmann 5bcc8fa832 arm: spi: spi master support for nrf52 family
* SPIMx support for nrf52 spi interface with easy dma

Change-Id: I3221b14867924b91a9d809faf689090574f5dc1c
Signed-off-by: Roger Lendenmann <roger.lendenmann@intel.com>
2017-04-04 17:55:13 -05:00
Erwan Gouriou 8e85600a30 drivers: i2c: stm32lx: Add support for I2C_2
Add support for I2C_2 instance on stm32lx driver

Change-Id: Iaa17305dd21f92954274ca522d30d464e0a53b7b
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2017-04-04 17:55:13 -05:00
Erwan Gouriou 40286ec697 driver: i2c: stm32lx: align numbering scheme on data sheet
On stm32 family, IP instance numbering starts from 1.
Update i2c driver to this scheme to minimize user
confusion

Change-Id: I967d5975bbbad59cd8a3a7b6dfc665955d09cc9f
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2017-04-04 17:55:13 -05: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 bb2db5dbc5 i2c: update stm32 i2c_lx to support LL clock control driver
After introducing STM32Cube based clock control driver for
stm32 family, update stm32 i2c_lx driver to support it.
Clean up will be done in a following commit.

Change-Id: Ie5059bf4122d65fab1a663a5b00e0d761850a49d
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2017-02-10 14:47:41 -06:00
Erwan Gouriou 0a902c345c i2c: stm32: change deprecated constant
Use of SECONDARY in DEVICE_AND_API_INIT is now deprecated and should
be replaced by POST_KERNEL

Change-Id: I543ae70e493527e75b4a4bcb9191475065b49166
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 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
Marcus Shawcroft ec86145adf i2c/dw: Switch from EPERM to EIO
The DW i2c driver chooses to return -EPERM following a PCI error in
driver configuration.  This seems an odd choice.  All of the other I2C
drivers return -EIO for general failures detected during driver
configuration.

Switch the DW driver from EPERM to EIO.

Change-Id: Ia4f96386620319736ae4c09212b0a05ea38169b1
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2017-02-07 18:32:37 +00:00
Marcus Shawcroft ccf16c705d i2c/stm32lx: Fix layout.
Change-Id: Ifc474ff703f96e5edd9dfd280533f4d8fe6a6853
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2017-02-07 18:32:36 +00:00
Marcus Shawcroft ddb6b94bd7 i2c: Implement consistent i2c no msgs behaviour
The I2C drivers handle an empty list of I2C messages inconsistenty.
There are two different behaviours, one set of drivers dectects a
requests to transfer zero messages and return -EINVAL while the other
group simple transfer no data and return success.

Adopt the latter behaviour consistently across all drivers.  Update
the i2c.h API documentation to reflect this behaviour.

Change-Id: I427fc1b0e18ddc04b7b59c294e0240b3d6ca4073
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2017-02-07 18:32:35 +00:00
Marcus Shawcroft f5eeaf9527 i2c/nrf5: Remove r/w to POWER register.
The reset code that toggles the POWER register fails to build on
NRF52.  In discussion with the Nordic folks it transpires that we
don't actually need this code.

For future reference there is a related errata here:
http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.Rev1.errata/anomaly_832_89.html?cp=2_2_1_0_1_26

Change-Id: I2ba8c2bb814f8f95ff3f340862c75a8bc437c573
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2017-02-01 00:35:35 +00:00
Chuck Jordan ac34b99af3 i2c: Can pass IRQ vector constant to irq_enable
I found that I was not getting the i2C interrupt.
When CONFIG_I2C_0_IRQ_DIRECT=y, it is acceptable to just
pass the constant to irq_enable.

See ZEP-1651.

Change-Id: I10955e6d6fe5fdd2dda916c92c8bc8a2e871f41a
Signed-off-by: Chuck Jordan <cjordan@synopsys.com>
2017-01-30 17:52:58 +00:00
Marcus Shawcroft 2dd2dfc3f9 i2c/nrf5: Implement NRF5 I2C driver.
Basic interrupt driven i2c driver for the NRf5 series.

The NRf5 series hardware imposes a constraint that various peripherals
cannot be used simultaneously.  This driver does not implement mutual
exclusion against SPI, or SPIs drivers (yet).

Change-Id: I308d93bc486eef95db7b95c6b7c9beafc0d7e97f
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2017-01-25 09:59:27 +00:00
Marcus Shawcroft df632a7371 i2c: Sort Makefile in alphabetical order.
Change-Id: Id0b39b95a7f378d728ddbe0b92518af054072252
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2017-01-25 08:47:22 +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
Baohong Liu 9888bc8b9c drivers: i2c: remove an unnecessary condition check
Remove an unnecessary condition check in Kconfig.
All the config options already depend on I2C.

Change-Id: Ia8876442652df9f105e862d8c2db394699c81f63
Signed-off-by: Baohong Liu <baohong.liu@intel.com>
2017-01-18 17:13:10 -08:00
Maureen Helm b22bc6e69b i2c: Rename ksdk to mcux
Renames the ksdk i2c shim driver to mcux.

Change-Id: I1bcae2fa30cb698af32d6abc609d77dee42c608d
Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2017-01-12 09:46:26 -06:00
Qiu Peiyang e4ad31a231 i2c_qmsi_ss: add device_busy_set() to avoid re-enter deep sleep
When CONFIG_SYS_POWER_DEEP_SLEEP is enabled, i2c_qmsi_ss will
keep entering deep sleep because it needs to wait until the
current transfer completes, which blocks the current thread.
The system keeps entering deep sleep again and again and the
transfer will never complete.

Add device_busy_set() to i2c_qmsi_ss driver to indicate that
the device is busy and block the system from entering deep
sleep during transaction.

Jira: ZEP-1487

Change-Id: Ia681d242349bce5a9867e54df4e65dba09005930
Signed-off-by: Qiu Peiyang <peiyangx.qiu@intel.com>
2016-12-23 16:49:23 +00:00
Baohong Liu db09c2905b drivers: i2c_shim: grant arc the access to i2c on I/O fabric
Enable arc to access the i2c controller on I/O fabric.

There are two i2c controllers on quark se SoC. One is attached
to the I/O fabric and the other one is in the sensor system.
X86 cpu is only able to access the i2c controller on the I/O
fabric and the access is supported by existing code. HW allows
arc to access both controllers. But, the existing code only
gives arc access to the controller in the sensor sub-system.
Let's grant arc the access to the controller on I/O fabric as
well by the following changes.

1. Add i2c_qmsi.c into arc compilation.
2. Use the already defined macros to choose interrupt numbers
   and do interrupt unmasking automatically based on the
   compilation targets.
3. Add new symbols in Kconfig including driver names for both
   controllers

Jira: ZEP-1189

Change-Id: I317da6038c50e0c8bd16f446182c1f8bdf6d3ba2
Signed-off-by: Baohong Liu <baohong.liu@intel.com>
2016-12-22 01:22:52 +00:00
Anas Nashif 3d8e86c12c drivers: eliminate nano/micro kernel usage
Jira: ZEP-1415

Change-Id: I4a009ff57edb799750175aef574a865589f96c14
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-12-21 18:45:02 +00:00
Flavio Santes 501dd224ad drivers: Add the ARG_UNUSED macro
Add the ARG_UNUSED macro to avoid compiler warnings.

Change-Id: Ia62125b5e93671aa0ab0891c92ae9fa06fadb09b
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2016-12-21 12:54:52 +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
Baohong Liu fd314e721e drivers: i2c: replace device sync APIs with semaphores
Device sync APIs are actually wrappers for semaphores.
Let's replace them with semaphores.

Jira: ZEP-1411

Change-Id: I5662057222aec54f02db9d9cdcd7f4f006c6c530
Signed-off-by: Baohong Liu <baohong.liu@intel.com>
2016-12-11 11:23:34 +00:00
Neil Armstrong abae57ac30 stm32lx: add i2c driver for the L series
Add the I2C for the STM32Lx series

Change-Id: Id1694aeb3606b4fa9772bfb7a9f60e48a7cc93a8
Signed-off-by: Fabien Parent <fparent@baylibre.com>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2016-12-06 10:31:45 -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
JuanX Solano Menacho b4b612f1e4 i2c_qmsi_ss: Use qm_ss_i2c_save/restore_context APIs
This commit updates the i2c_qmsi_ss driver by adding save/restore
context functionality for power management, using the corresponsing
QMSI APIs.

Jira: ZEP-666

Change-Id: I36fb18b52edd4dac4c4b6cb98162adbca74800cb
Signed-off-by: JuanX Solano Menacho <juanx.solano.menacho@intel.com>
2016-11-11 23:33:20 +00:00
Baohong Liu 82193c59e3 drivers: i2c: update to unified kernel
Use new semaphore APIs from unified kernel.

Change-Id: I17cde2f2cf457ac60905824ae581ede495f02709
Signed-off-by: Baohong Liu <baohong.liu@intel.com>
2016-11-10 02:00:07 +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
Jesus Sanchez-Palencia 55c00ad721 ext qmsi: Update to 1.3.1 version
Update to QMSI 1.3.1 release.

The only build fix needed was due to the split of the I2C ISR on
qm_isr.h .

Change-Id: Ide7a1537572c72981ec3283dc5cf0d543d9ac7d1
Signed-off-by: Jesus Sanchez-Palencia <jesus.sanchez-palencia@intel.com>
2016-11-04 23:31:29 +00:00
JuanX Solano Menacho 6f8d48e0cb i2c_qmsi: Use qm_i2c_save/restore_context APIs
This commit updates the i2c_qmsi driver by removing the temporary Zephyr
save/restore context implementation and using the new QMSI APIs.

Jira: ZEP-996
Change-Id: I9fbd563f214b757f3435037b3e24da4bcf08da14
Signed-off-by: JuanX Solano Menacho <juanx.solano.menacho@intel.com>
2016-11-03 23:52:10 +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 c8a359c039 grove/i2c/dw: Limit name space, add static.
Change-Id: I949d07a962c9dc409de9c458a09a9d829f791496
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-10-26 20:51:02 +00:00
Marcus Shawcroft db22d3c8da drivers/i2c_qmsi_ss: Make driver_api structure const.
Change-Id: Id7671da509ce6082f2b85a0349d11ce5424a78a3
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-10-25 18:45:28 +00:00
Marcus Shawcroft 042f5da963 drivers/i2c_qmsi: Make driver_api structure const.
Change-Id: If51f4b6e0c37f5864ad24b433b44629f1195d85a
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-10-25 18:45:28 +00:00
Marcus Shawcroft 8707593b93 drivers/i2c_ksdk: Make driver_api structure const.
Change-Id: If8e674b581b75a31e1aa8ba08acf936fabdd44b3
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-10-25 18:45:27 +00:00
Marcus Shawcroft a2f7bed768 drivers/i2c_dw: Make driver_api structure const.
Change-Id: I104912a82920fea08bb32cc1838a80c7f952b1a1
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-10-25 18:45:27 +00:00
Marcus Shawcroft e6cd44fad8 drivers/i2c_atmel_sam3: Make driver_api structure const.
Change-Id: I285e05153beddc15d63ba4437a7d2757c4131e89
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-10-25 18:45:26 +00:00
Iván Briano 5a76185655 i2c qmsi: Fix enabling of the clock at driver init
Put the clk_perih_enable() call outside of the switch statement so it
actually runs.

Jira: ZEP-1048

Change-Id: Iee8efb4430d37dc74ce48f249bbf58d53125b520
Signed-off-by: Iván Briano <ivan.briano@intel.com>
2016-10-21 16:53:42 +00:00
Marcus Shawcroft ba30e3e59e i2c/qmsi_ss: Make driver config_info structure const.
Change-Id: I3718c34cc4cc7e70256321736b0981c147f319f5
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-10-20 16:48:51 +00:00
Marcus Shawcroft a4dd8e91d1 i2c/qmsi: Make driver config_info structure const.
Change-Id: Ic31f40c48a71fdc3a1745ee5685cc14fdbb7527b
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-10-20 16:48:51 +00:00
Marcus Shawcroft 49b0face1e i2c/ksdk: Make driver config_info structure const.
Change-Id: I605ab6f33222c11e8f336e1a981615e7b0c6cefa
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-10-20 16:48:51 +00:00
Marcus Shawcroft 72a70fa224 i2c/dw: Make driver config_info structure const.
Change-Id: I66ac4cf010affc6193d1d74dec8dc25e69454438
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-10-20 16:48:50 +00:00
Marcus Shawcroft 6919ef179e i2c/sam3: Make driver config_info structure const.
Change-Id: Idf49d5b5663f5e0375b7ea23e056d0465f32abce
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-10-20 16:48:50 +00:00
Marcus Shawcroft beb05f8661 i2c/dw: Move RW objects in config_info to driver_data
PCI enumeration modifies pci_dev, base_addaress at driver
initialization therefore this objects move from config_info to
driver_data in preparation for config_info becoming const..

We drop code that attempts to update irq_num based on PCI enumeration
because the interrupt found by PCI enumeration must always be the same
as the statically configured IRQ number.

Change-Id: Id5af682dac112ec6dc6e4aa14b655e0047972d38
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-10-19 12:10:58 +00:00
Marcus Shawcroft 0f1d0d465b i2c/qmsi_ss: Make pointers to config_info const.
Change-Id: I7786f9c65e62eee27395d53b6e923dec6c13f1f4
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-10-15 12:29:22 +00:00
Marcus Shawcroft 3d32b19726 i2c/qmsi: Make pointers to config_info const.
Change-Id: I95e17cda100c068bfd61e66c568b5adb6f58c42c
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-10-15 12:29:22 +00:00
Marcus Shawcroft 389e606b06 i2c/sam3: Make config_info pointers const.
Change-Id: I5e388ff91430d052c84553a8cf9ece12cae29993
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-10-15 12:29:19 +00:00
Anas Nashif 706f1b8bd8 drivers: gpio: i2c: make logging depend on SYS_LOG
Change-Id: Ia6af28598cf979f20e04cd2c74f3e75f4ae6630b
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-10-07 14:15:24 +00:00
Marcus Shawcroft 3924f46359 i2c/kdk: Make config_info pointers const.
Preparation for const driver configuration data.

Change-Id: Ifdef448b9b6899367d41bda2f492a8e9fbd0d483
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-10-07 08:05:50 -04:00
Qiu Peiyang 76549c1b79 I2C: remove obsolete i2c_quark_se_ss driver
i2c_quark_se_ss driver is deprecated and replaced
by i2c_qmsi_ss. So remove i2c_quark_se_ss definition.

Change-Id: Idcc6a7f01ffae626ae7d5f9966eac67be78599af
Signed-off-by: Qiu Peiyang <peiyangx.qiu@intel.com>
2016-10-05 10:07:30 +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 859a367d9c i2c_qmsi: Implement suspend and resume functions
In order to restore i2c context after entering
SYS_PM_DEEP_SLEEP, suspend and resume functions
are called.

The following parameters are restored:
 - All registers for the I2C device.
 - I2C clocks.

I2C depends on the DMA which is enabled separately.

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: I22ca2fb9884109f7b5ca75af572811187a531403
Signed-off-by: Julien Delayen <julien.delayen@intel.com>
2016-09-12 00:30:28 +00:00
Baohong Liu b0c28f2d00 drivers: i2c: fix a compilation dependency issue
Fix a compilation warning. Compilation of the i2c driver
requires QMSI dma object file. As a solution, the current
code has "selects DMA_QMSI" in i2c Kconfig. This results
in a compilation warning since "select DMA" is also
required. Adding "select DMA" and "select DMA_QMSI"
together in i2c Kconfig can solve the compilation issue.
But, this will cause the dma driver be unnecessarily
enabled. So, the solution is to fix the issue in the QMSI
part instead of in the shim driver.

Jira: ZEP-777 ZEP-778

Change-Id: Id4c1f749bf71eece1e70583bd586a69b596768b2
Signed-off-by: Baohong Liu <baohong.liu@intel.com>
2016-09-10 11:29:49 +00:00
Baohong Liu 20d85fefe9 i2c: qmsi_shim: change some i2c config parameters to SoC specific
Change the signal ramp up/down config parameters in i2c driver
module to SoC specific.

Jira: ZEP-753

Change-Id: Ie01f1d890a7133d30ea53eee07f60354734a8571
Signed-off-by: Baohong Liu <baohong.liu@intel.com>
2016-09-08 11:57:41 +00:00
Maureen Helm e4067638b7 i2c: ksdk: Add shim driver
Add a shim layer around the ksdk I2C driver to adapt it to the Zephyr
I2C interface. Currently only supports master mode.

Jira: ZEP-717
Change-Id: I704b8c38e22e456bb9fa4325682b2a354a27a7ba
Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2016-09-07 14:40:20 +00:00
Baohong Liu 1010927ba9 drivers: i2c_shim: fix i2c fast plus mode failure
Fix i2c failure seen on fast plus mode. With higher data
rate, signal ramp time becomes longer. The ramp time
required by the controller needs to be loosened.

Jira: ZEP-711

Change-Id: Icffa334ec3f059564e333d3b0759a11d1bebc5e4
Signed-off-by: Baohong Liu <baohong.liu@intel.com>
2016-08-30 21:09:49 +00:00
David B. Kinder d748577706 doc: Fix terminology in Kconfig files for 'platform'
Completing the terminology change started with change 4008
by updating the Kconfig files processed to produce the
online documentation, plus header files processed by
doxygen.  References to 'platform' are change to 'board'

Change-Id: Id0ed3dc1439a0ea0a4bd19d4904889cf79bec33e
Jira: ZEP-534
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2016-08-18 21:17:29 +00:00
Baohong Liu e8a852325f drivers: i2c: Fix i2c failure on multiple slaves
Fix i2c failure while multiple slaves are connected to the
same i2c interface. Higher load on the i2c bus makes i2c
signal less nice. The requirement for signal ramp up and
ramp down time needs to be loosened.

Jira: ZEP-646

Change-Id: If698d7ba741788857694f166ecc602c2a94cb12e
Signed-off-by: Baohong Liu <baohong.liu@intel.com>
2016-08-12 20:35:25 +00:00
Iván Briano 4be7d42db8 i2c: Remove suspend and resume hooks from i2c_driver_api
Drivers that implement power management should use the preferred
device_pm_ops method instead.

Change-Id: I9ae06e26b77325265bbe46bdee82ba39dedb6b79
Signed-off-by: Iván Briano <ivan.briano@intel.com>
2016-07-29 23:10:10 +00:00
Jani Pajarinen 485dde19da i2c: Fixed i2c_dw spamming when logs are enabled
Added CONFIG_SYS_LOG_I2C_LEVEL define, so that DW I2C driver will
not print traces unless requested with CONFIG_SYS_LOG_I2C_LEVEL.
Currently it doesn't obey it, so DW I2C spams DBG traces when
logging is enabled.

Change-Id: I87dc1d922ba61d39f26945627602864c75d9bf33
Signed-off-by: Jani Pajarinen <jani.pajarinen@intel.com>
2016-07-28 15:43:00 +00:00
Baohong Liu db17939c8a drivers: i2c: remove i2c master idle check
The idle status check before a i2c transfer is not a reliable
way to check whether i2c master is ready to transfer data. If
the data transfer for the previous API call is done, but, a
stop condition is not sent by the previous API, the i2c master
is not idle, but, it can start new data transfer.

Change-Id: I93dbf46cef6272f3da69a0d67fb737c9b480791f
Signed-off-by: Baohong Liu <baohong.liu@intel.com>
2016-07-27 14:44:54 +00:00
Genaro Saucedo Tejada 89e46d431a sys_log: replace old debug macros at i2c
Designware, Amtel and Quark SE i2c drivers are now using new system
log macros. also update the Kconfig variable to be a level rather than
a bool.
JIRA: ZEP-311

Change-Id: Iac009b20fb74deb8ce72098378651bbec3b2ef17
Signed-off-by: Genaro Saucedo Tejada <genaro.saucedo.tejada@intel.com>
2016-07-08 18:20:28 +00:00
Baohong Liu 5846bb6d65 drivers: i2c: qmsi shim driver bug fix
Fix a bug in i2c_qmsi_transfer function in the shim driver.
The function did not wait for the completion of a msg transfer
before starting another msg transfer. Similar issue exists in
the i2c sensor shim driver. It is also fixed.

Change-Id: I1f8ad2281fa185d85db25a4682ed596c02ea322e
Signed-off-by: Baohong Liu <baohong.liu@intel.com>
2016-07-06 17:43:49 +00:00
Jesus Sanchez-Palencia abd7496225 ext qmsi: Update to QMSI 1.1-Beta
QMSI 1.1 Beta is available on Github:
https://github.com/01org/qmsi/releases/tag/v1.1.0-beta

Update the QMSI drop we maintain in Zephyr and
keep the modification to qm_soc_regs.h introduced on commit
6b88a6b945 "ext qmsi: Add USB base and interrupt defines" since
that patch hasn't made into the QMSI 1.1-Beta release in time.

Also, fix the build where needed:
- add hard dependency from qm_i2c to qm_dma
- fix spi_qmsi_ss.c due to new parameter naming
- fix adc_qmsi.c and adc_qmsi_ss.c due to a new parameter

Change-Id: I01388c787f5ee6ee97fece2e42b24a717522207f
Signed-off-by: Jesus Sanchez-Palencia <jesus.sanchez-palencia@intel.com>
Signed-off-by: Kuo-Lang Tseng <kuo-lang.tseng@intel.com>
2016-07-01 13:43:02 -07:00
Bogdan Davidoaia 44ef3c182b i2c: qmsi: remove duplicate I2C_QMSI_SS Kconfig option
Remove duplicate I2C_QMSI_SS option from Kconfig file, as there is no
reason to have it twice.

Change-Id: I602677676419c3f9581a606e8e3ebb889b439eb7
Signed-off-by: Bogdan Davidoaia <bogdan.m.davidoaia@intel.com>
2016-06-09 12:26:38 +03:00
Anas Nashif 1cb62d0372 i2c: qmsi: use I2C_SPEED_FAST_PLUS from API
Do not use the QMSI specfic define, use the one define in the
i2c API instead.

Change-Id: I979673e35060d041cb97f4de178069e2bdfd2c7b
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-06-02 13:46:44 -04:00
Sergio Rodriguez ab833c74c5 i2c: quark_se ss: Use locking mechanism to guard critical regions.
This will allow the driver to be safe from fibers and task

Jira: ZEP-411

Change-Id: I714f22c8df7002c45bed981c493e11af91c70d93
Signed-off-by: Sergio Rodriguez <sergio.sf.rodriguez@intel.com>
2016-06-01 00:42:11 +00:00
Sergio Rodriguez 10e33ff779 i2c: Bug fix for the semaphore locking mechanism for i2c
The locking and synch mechanisms were configured after the interrupts
for the I2C controller are enabled, now the configuration is done before
the enabling of the interrupts.
Jira: ZEP-419
Change-Id: Ia1b0e790b9f5f8e7560cc3556b7a0f394048d171
Signed-off-by: Sergio Rodriguez <sergio.sf.rodriguez@intel.com>
2016-05-31 22:54:55 +00:00
Sergio Rodriguez bf45b0bd87 i2c: Use locking mechanism to guard critical regions.
This will allow the driver to be safe from fibers and task

Change-Id: I6c4c4fc387cf334f0287b8a02982be1941a311fd
Signed-off-by: Sergio Rodriguez <sergio.sf.rodriguez@intel.com>
2016-05-26 21:40:21 +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
Chuck Jordan 0fc41677b2 i2c: fix some spelling errors/grammar in comments
Some minor fixes to some comments

Change-Id: I0244d70c31b59ba189673e44c3919710414e9810
Signed-off-by: Chuck Jordan <cjordan@synopsys.com>
2016-05-24 10:14:10 -07:00
Sergio Rodriguez 92e9ffe481 i2c: quark se: Add QMSI 1.1-based I2C shim driver
Add I2C QMSI shim driver for sensor system based on QMSI 1.1

Origin: Original
Change-Id: I9c8efe49e8e9b7a5f8496fa49beb68e409148be7
Signed-off-by: Sergio Rodriguez <sergio.sf.rodriguez@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-05-23 21:31:27 +00: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
Anas Nashif 0140da310b i2c: unify kconfig options and share them across drivers
Reduces Kconfig variables by ~20

Change-Id: If39f7d49482d62417c621f98bc8c0c78df0d4139
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-05-12 10:57:22 +00:00
Chuck Jordan 61c5531430 i2c: IC_CON_SPEED_MASK should be 2 bit mask
IC_CON_SPEED_MASK isn't used, but I see it was defined wrong.
It should be a 2 bit mask.

Change-Id: I1003ae13b831ff481574bcf956daf2c54dbe7e47
Signed-off-by: Chuck Jordan <cjordan@synopsys.com>
2016-05-11 15:09:15 -07:00
Chuck Jordan 0ed3cf29c8 i2c: fix i2c_dw.c to have correct decl for i2c_dw_isr()
The function i2c_dw_isr() in this file appears to have the wrong
decl for the IRQ_CONNECT macro. It should be: void i2c_dw_isr(void *arg).
Also, at the 2nd use of IRQ_CONNECT there was a variable created
and then marked as UNUSED. I've removed this.

Change-Id: I3f2c4ecb5c13147d577c82a0ec4fe486ae38a475
Signed-off-by: Chuck Jordan <cjordan@synopsys.com>
2016-05-11 21:18:48 +00:00
Anas Nashif 9d8c332b21 i2c: use I2C_X nameing instead of I2CX
Other IOs use this format, so lets be consistent and use

I2C_0 instead of I2C0 and I2C_1 an instead of I2C1.

Change-Id: I591ab08e14bd533ef0fac38e596559da783863b8
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-04-25 17:01:48 +00:00
Jithu Joseph 18fc64dcff power_mgmt: Sample usage of device_xxx__busy() APIs
To show possible usage of the device_busy_xxx() APIs.
Meant to show how drivers and power policy manager can use them.

Change-Id: I49d1dedd9a7b8d6bf09080c6c7243f0666330941
Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
2016-04-23 02:14:21 +00:00
Anas Nashif a7d3329694 qmsi: i2c: use built-in qmsi driver
Change-Id: I2e650198117128cec79a64abcd2cc065b5f9804c
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-04-22 20:46:29 -04:00
Daniel Leung 267e6e639c i2c/quark_se_ss: make structs and functions const and static
() Make driver API into const, as it is not being modified
   at runtime. Saves 24 bytes of RAM by putting it into ROM.
() Make device config structs as static as they are local to
   the source file, and should not be referenced from outside at all.
() Same goes for the IRQ configuration functions, by declaring them
   static.

Change-Id: I5225dc550bdd65ec88a8930944da063efe16a3b2
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-04-22 12:32:26 +00:00
Daniel Leung 5250283c33 i2c/quark_se_ss: fix RX request pause conditions
The driver should not request any more bytes if it expects no empty
space in the FIFO. So fix the bail out condition to (<= 0) instead of
(< 0).

Change-Id: Ie16faf1da7df678fc8ab5af7ab33d7c0a2cdba7d
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-04-18 20:27:09 +00:00
Daniel Leung 8f9e38adc4 i2c/atmel_sam3: convert to use DEVICE_AND_API_INIT()
Change-Id: I810716d5eb99b7b8c0f06534877eccfc71d959eb
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-04-15 22:06:14 +00:00
Daniel Leung da782358aa i2c/quark_se_ss: convert to use DEVICE_AND_API_INIT()
Change-Id: Iefe73cf68355a02e78f328e5d13c354f6e1624c8
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-04-15 22:06:10 +00:00
Daniel Leung 21727b5d86 i2c/dw: convert to use DEVICE_AND_API_INIT()
Note that the failure case can only be reached when PCI is enabled.
Otherwise, the if-block is always false, which reduces code size
for non-PCI platforms.

Change-Id: I71656468eaee702bc481f5fbd490677b7bc491c1
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-04-15 22:06:10 +00:00
Andre Guedes 6e71586c37 i2c: qmsi: Add support for default configuration
This patch extends the i2c shim driver so it supports the 'default
configuration' infrastructure which enables the user to specify a
default configuration for the I2C device. The default configuration
is set during driver initialization.

This patch also changes Quark SE and D2000 Kconfig.defconfig files so
the i2c default configuration is set to '0x12' which means standard
bus speed, 7-bit addressing and master mode. This is the same value
used when DW driver is selected, by the way.

Change-Id: I06e0dc3c29e8da2f3317db5bef285177f2e92c9a
Signed-off-by: Andre Guedes <andre.guedes@intel.com>
2016-03-31 13:18:26 +00:00
Daniel Leung cb83db8c74 i2c/dw: remove kconfigs that are SoC specific
Remove those kconfig options that are SoC specific, and should not be
configurable via kconfig.

Change-Id: Ia62888838877da4627419bd36c261d5254761acd
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-03-31 01:11:23 +00:00
Andre Guedes 3c01cc6cff i2c: Remove redundancy in Kconfig.qmsi
Each option within Kconfig.qmsi already set its dependency so this
patch removes the 'if I2C_QMSI' block since it is redundant.

Change-Id: Ic221b96766ecac685491cb31525caf28e641ee45
Signed-off-by: Andre Guedes <andre.guedes@intel.com>
2016-03-30 20:03:02 +00:00
Daniel Leung e539888614 i2c: remove orphan kconfig I2C_STATUS_DELAY
No one is using it so remove it.

Change-Id: I79f19a7a9a784465d68a0fe85fe9f815279a240d
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-03-30 13:39:09 +00:00
Daniel Leung c65821718f i2c/quark_se_ss: Remove base address kconfig options
The base addresses are SoC specific so there is no need to make
configurable via kconfig.

Change-Id: Iaf8444f77513255d5f0112af6710243aae09f066
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-03-28 16:09:15 -07:00
Daniel Leung 3f408ee20a i2c/qmsi: rename *_INT_PRIORITY to *_IRQ_PRI
This is to standardize the kconfig for specifying IRQ priority.

Change-Id: Iab10655c6fc6f17c0c6dd49cb7a4e74fabcf852c
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-03-28 15:59:04 -07:00
Daniel Leung 36678521c3 i2c/dw: rename *_INT_PRIORITY to *_IRQ_PRI
This is to standardize the kconfig for specifying IRQ priority.

Change-Id: I3a51b35e633dc7b1b841e9fa504bf0cfc0d4d575
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-03-28 15:59:04 -07:00
Daniel Leung ee216548e6 i2c/atmel_sam3: rename *_INT_PRIORITY to *_IRQ_PRI
This is to standardize the kconfig for specifying IRQ priority.

Change-Id: I05ae4033e2c5431ba2727c5d4000ef07e14739c8
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-03-28 15:59:04 -07:00
Andre Guedes 3172fca3a0 drivers: qmsi: Fix gpio, i2c and wdt for D2000
This patch fixes the gpio, i2c and watchdog shim drivers so they set the
CLK_PERIPH_CLK bit during driver initialization. Differently from Quark
SE, the peripheral clock gate bit (CLK_PERIPH_CLK) is not enabled by
default in Quark D2000. We have to explicitly set this bit in order to
properly initialize the device.

This issue has been masked so far because the CLK_PERIPH_CLK bit is set
when UART NS16550 driver is enabled. The UART NS16550 driver is enabled
by default for Quark D2000 so gpio, i2c and watchdog sample apps were
working just fine. But if we disable the NS16550 driver, these samples
applications stop working.

The remaining shim drivers already set the CLK_PERIPH_CLK bit during
initialization so there is no need to fix them.

Change-Id: I3f658da564f87e9d52092ce7aac423c7b3e0c890
Signed-off-by: Andre Guedes <andre.guedes@intel.com>
2016-03-18 23:31:45 +00:00
Daniel Leung 68107289bd i2c: 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.
() Adds the missing copyright to Kconfig.atmel_sam3.

Origin: refactored from existing file
Change-Id: I2dacd3d9b2bfa052c9e0c078ddffed40dbc2ddbf
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 aca7cb1efd drivers: Replace DEV_NO_SUPPORT by -ENODEV
This patch replaces all occurences of the macro DEV_NO_SUPPORT by
-ENODEV 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: I03007527367b03e6fd72a85004b7d3b81046a6a6
Signed-off-by: Andre Guedes <andre.guedes@intel.com>
2016-03-16 19:30:04 -04:00