Commit Graph

1117 Commits

Author SHA1 Message Date
Glenn Andrews
1c19d43564 Driver: i2c_ll_stm32_v2: Remove log msg on boot
Converts the `<inf> i2c_ll_stm32_v2: I2C TIMING` message
displayed by the driver to a LOG_DBG. Also makes an actual
error message a LOG_ERR instead of a LOG_DBG.

Signed-off-by: Glenn Andrews <glenn.andrews.42@gmail.com>
2024-07-08 20:40:54 -04:00
Dev Joshi
a9e6fa4b29 drivers: I2C_DW: Fix I2C scan example
Solves two identical issues listed below:

Issue 1: I2C scanner example for DesignWare hardware gets stuck
indefenitely resulting in system hang up.This is because DW I2C driver
does not handle 0 byte transfer correctly which is the case for I2C
scan example.

Fixed it by overwriting the msg length to 1 if it is 0 and the
buffer is not NULL.

Issue 2: Similarly, if the I2C pins are not pulled up (nothing connected
 to I2C pins), the DW hardware does not actually send the data
(assuming contention on the bus) hence not releasing the semaphore
resulting in calling thread waiting forever.

Fixed it by adding a timeout to k_sem_take call and return error if
cannot successfully acquire it.

Tested scenarios where nothing was connected on the bus and saw the
I2C scan example complete the whole scan command. Then connected
two different sensors on the I2C bus and saw both the address on the
console. Tested both the uses cases on Raspberry Pi Pico.

Fixes #70332.

Found that micropython tackles the same issue by implementing I2C scan
commands with Soft I2C because the same reason mentioned in Issue 1.

Signed-off-by: Dev Joshi <quic_devbhave@quicinc.com>
2024-07-04 08:23:43 +02:00
Hao Luo
faa5fa1ab0 drivers: i2c: bugfix for ambiq i2c driver
Added k_sem_give for error return case.
Changed enabled interrupt bits.

Signed-off-by: Hao Luo <hluo@ambiq.com>
2024-07-01 09:06:05 -04:00
Nerijus Bendžiūnas
31ad324120 drivers: i2c: stm32: remove redundant new line
LOG_* adds "\n" by itself.

Fixes redundant lines during startup:

```
[00:00:00.100,000] <inf> i2c_ll_stm32_v2: I2C TIMING = 0xb0f6343d

[00:00:00.100,000] <inf> i2c_ll_stm32_v2: I2C TIMING = 0xb0f6343d

[00:00:00.100,000] <inf> i2c_ll_stm32_v2: I2C TIMING = 0xb0f6343d

[00:00:00.100,000] <inf> i2c_ll_stm32_v2: I2C TIMING = 0xb0f6343d

[00:00:00.100,000] <inf> flash_stm32_qspi: Reading SFDP
```

Signed-off-by: Nerijus Bendžiūnas <nerijus.bendziunas@astrolightspace.com>
2024-06-28 08:56:09 +02:00
Hao Luo
d1eea369b1 drivers: ambiq: Add dependencies to avoid showing to non-ambiq platforms
Fixed the Kconfig.ambiq under i2c and spi so that they don't litter.

Signed-off-by: Hao Luo <hluo@ambiq.com>
2024-06-27 08:59:40 -04:00
Ioannis Damigos
b9dab49b13 drivers/smartbond: Remove atomic flags from drivers
Remove atomic flags from drivers that use balanced calls
for PM locking.

Signed-off-by: Ioannis Damigos <ioannis.damigos.uj@renesas.com>
2024-06-21 08:45:10 -04:00
Ioannis Damigos
27c14042bd i2c_smartbond: Introcude TX_FIFO_DEPTH macro
Introcude TX_FIFO_DEPTH macro to avoid "magic"
numbers.

Signed-off-by: Ioannis Damigos <ioannis.damigos.uj@renesas.com>
2024-06-18 14:36:38 -04:00
Ioannis Damigos
d9ad8c9c99 i2c_smartbond: Fix spin locking
Fix spin locking

Signed-off-by: Ioannis Damigos <ioannis.damigos.uj@renesas.com>
2024-06-18 14:36:38 -04:00
Ioannis Damigos
0a0bccabd8 drivers/smartbond: Fix PM device runtime support
Removed PM device runtime support from drivers in PD_SYS domain.

Update the rest device drivers to call pm_device_runtime_get/put()
functions when CONFIG_PM_DEVICE_RUNTIME is enabled.

Signed-off-by: Ioannis Damigos <ioannis.damigos.uj@renesas.com>
2024-06-18 14:36:38 -04:00
Tom Burdick
98b26c6ca8 rtio: Remove builtin iodev mpsc queue
I/O Devices were meant to be handles of sorts and had a built in mpsc queue
as this made sense initially. As time has gone on it turned out that often
we wanted the mpsc queue to be an implementation detail hidden in a driver.
In fact pretty much all drivers work this way now.

Keeping the struct mpsc queue as a member of rtio_iodev meant wasted memory
in cases where it wasn't used. It also meant a bit of confusion as the
queue might be accidently used in places where it shouldn't be.

Remove the mpsc queue member from struct rtio_iodev and the last remaining
usages of it. Will ensure RTIO for 3.7 LTS avoids causing unneeded churn
for future users.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2024-06-12 21:12:54 -04:00
Francois Ramu
29afef1e7d drivers: i2c: stm32 for V2 driver get_config with timings
Change the get_config API for the stm32 I2C V2 driver.
It will also return the value of the content of TIMING register
for the I2C V2 bus.
This is hold by a i2c_config_timing structure of the device data

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2024-06-12 14:35:48 +03:00
Francois Ramu
e5048c0c6d drivers: i2c: stm32 I2C v2 driver fix compliance with a Macro
Define Macro to fix the compliance check warning :
"DEEP_INDENTATION: Too many leading tabs - consider code refactoring
in the i2c_compute_scll_sclh() function
in the i2c_compute_presc_scldel_sdadel() function

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2024-06-12 14:35:48 +03:00
Francois Ramu
3aea45053c drivers: i2c: stm32 driver V2 new timing calculation
This PR is implementing a new formula to calculate the I2C timing
value from the I2C clock source and the bit rate.
This is done under flag CONFIG_I2C_STM32_V2_TIMING.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2024-06-12 14:35:48 +03:00
Tahsin Mutlugun
f037b95549 drivers: i2c: Add MAX32690 I2C driver
Add I2C driver for Analog Devices MAX32690 MCU. Supports target mode.

Co-Authored-By: Sadik Ozer <sadik.ozer@analog.com>
Co-Authored-By: Mert Vatansever <mert.vatansever@analog.com>
Signed-off-by: Tahsin Mutlugun <Tahsin.Mutlugun@analog.com>
2024-06-07 13:01:50 +02:00
Tom Burdick
d95caa51a4 sys: Add a lockfree mpsc and spsc queues
Moves the rtio_ prefixed lockfree queues to sys alongside existing
mpsc/spsc pbuf, ringbuf, and similar queue-like data structures.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2024-06-06 00:42:29 -07:00
Ioannis Karachalios
29026e8a89 drivers: i2c: smartbond: Update busy check condition
The controller should be considered
inactive when TX/RX FIFOs are empty
and there is no data in SPI_RX_TX_REG.

Signed-off-by: Ioannis Karachalios <ioannis.karachalios.px@renesas.com>
2024-05-30 09:48:31 -05:00
Bram Vlerick
3ea5f799dd i2c: target: eeprom_target: add addressable size assert
Add build-time assert to check if the size defined is actually addressable.
i.e: if address-width is set to 8, the maximum addressable size is 256
bytes.

Signed-off-by: Bram Vlerick <bram.vlerick@openpixelsystems.org>
2024-05-30 05:31:40 -07:00
Bram Vlerick
935e8c4b13 i2c: target: eeprom_target: add address_width parameter
Add a parameter to allow the configuration of the number of address
bytes used by the I2C master. This allows the driver to expose larger
buffer sizes.

Tested with standard linux at24 driver.

Signed-off-by: Bram Vlerick <bram.vlerick@openpixelsystems.org>
2024-05-30 05:31:40 -07:00
Ioannis Karachalios
c140053654 drivers: i2c: smartbond: Add support for PM
This commit should add all the functionality needed for the I2C
driver to work when PM is enabled.

Signed-off-by: Ioannis Karachalios <ioannis.karachalios.px@renesas.com>
2024-05-29 08:42:00 +02:00
Yong Cong Sin
bbe5e1e6eb build: namespace the generated headers with zephyr/
Namespaced the generated headers with `zephyr` to prevent
potential conflict with other headers.

Introduce a temporary Kconfig `LEGACY_GENERATED_INCLUDE_PATH`
that is enabled by default. This allows the developers to
continue the use of the old include paths for the time being
until it is deprecated and eventually removed. The Kconfig will
generate a build-time warning message, similar to the
`CONFIG_TIMER_RANDOM_GENERATOR`.

Updated the includes path of in-tree sources accordingly.

Most of the changes here are scripted, check the PR for more
info.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-05-28 22:03:55 +02:00
Yong Cong Sin
97ba7fd48d drivers: i2c: add Broadcom iProc I2C driver
Add device driver, bindings and build-only test for
Broadcom iProc I2C.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-05-28 09:57:40 +02:00
Fin Maaß
cefbcc5323 drivers: i2c: i2c_sbcon: use frequency from device tree
use the clock frequency from the device tree.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-05-28 09:56:48 +02:00
Fin Maaß
dd1f9c346d drivers: i2c: litex: add get_config and recover_bus
add get_config and recover_bus for the litex i2c driver.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-05-28 09:56:48 +02:00
Fin Maaß
2be9ed7103 drivers: i2c: litex: use frequency from device tree
use the clock frequency from the device tree.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-05-28 09:56:48 +02:00
Fin Maaß
dd897b51e0 drivers: i2c: i2c_sbcon: add get_config and recover_bus
add get_config and recover_bus for the sbcon i2c driver.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-05-28 09:56:48 +02:00
Fin Maaß
e7a088b467 drivers: i2c: gpio: add get_config
add get_config for the gpio i2c driver.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-05-28 09:56:48 +02:00
Fin Maaß
b4e81054f2 drivers: i2c: bitbang: add get_config
add get_config for the i2c bitbang driver.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-05-28 09:56:48 +02:00
Luis Ubieda
4ae093eaf0 drivers: i2c: nrfx_twi_rtio: Minor indentation fixes
Not necessarily related to the namespacing changes, but just
establishing proper indentation formatting throughout the whole file.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2024-05-24 07:46:27 -04:00
Luis Ubieda
98c121d262 i2c: nrfx_twi_rtio: Establish proper namespacing in driver
To clearly distinguish between common code and RTIO-only code
on nrfx_twi and nrfx_twi_rtio.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2024-05-24 07:46:27 -04:00
Hao Luo
c8ae26549d drivers: i2c: Add support for Apollo3 SoCs I2C
This commit adds support for the I2C which
can be found in Apollo3 SoCs, it can work in
both DMA and non-DMA modes

Signed-off-by: Hao Luo <hluo@ambiq.com>
2024-05-21 20:55:34 -04:00
Declan Snyder
eeb3e808f5 drivers: nxp: Add reset code to driver inits
Add peripheral reset handling code to driver init for:

- mcan
- i2c flexcomm
- spi flexcomm
- lpc mailbox
- mrt timer

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2024-05-21 16:49:42 -04:00
Luis Ubieda
788b985509 i2c: nrfx_twi: Refactor nrfx_twi to utilize common code
Code is refactored to take advantage of common codebase shared with
i2c_nrfx_twi_rtio driver.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2024-05-21 16:48:00 -04:00
Luis Ubieda
7d5265f610 i2c: Add nRFX TWI RTIO-compatible driver
First version of RTIO-compatible nrfx_twi driver.

Test Setup:
- Board: nrf52840dk
- Test: `tests/drivers/i2c/i2c_ram`
- Additional Kconfig: `CONFIG_I2C_RTIO=y`

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2024-05-21 16:48:00 -04:00
Fin Maaß
3b87a0b939 drivers: esp32: i2c: configure clock frequency
Be able to configure the clock frequency during runtime
using `i2c_configure()` and be able to use `i2c_get_config()`
of the i2c api for the esp32.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-05-15 09:29:31 +02:00
Luis Ubieda
215cdb65df drivers: i2c: rtio: Remove extra clear of RTIO_SQE_TRANSACTION
Already handled within `i2c_rtio_copy()`. Not needed.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2024-05-10 14:41:34 -05:00
Rafael Laya
a55ebe1377 drivers: Fixes Controller Mode for I2C DW Driver
4996a9be26 adds Target Support for the
Designware I2C Driver

But the change missed guarding some places with
CONFIG_I2C_TARGET

This commit fixes regressions caused by such change

Signed-off-by: Rafael Laya <rafael_laya97@hotmail.com>
2024-05-08 09:30:45 -04:00
Eran Gal
a3660d178c drivers: i2c_shell: Add direct_read sub command
Adds a direct_read subcommand to the I2C command.
Usage: I2C direct_read <device> <addr> [<nbytes>].
This command reads directly from the I2C device without first writing
a register address.

Signed-off-by: Eran Gal <erang@google.com>
2024-05-08 09:29:58 -04:00
Tom Burdick
cb384cd5a9 i2c: LPI2C selects HAS_I2C_RTIO
LPI2C from NXP supports the RTIO interface and therefore now selects the
HAS_I2C_RTIO Kconfig.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2024-05-04 13:23:22 +03:00
Tom Burdick
804a4faf3d i2c: sam twihs driver supports rtio
select HAS_I2C_RTIO when sam twihs is selected

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2024-05-04 13:23:22 +03:00
Tom Burdick
06e025aeee i2c: Add Kconfig HAS_I2C_RTIO
This config should be selected by any driver that supports the RTIO
interface and can then be checked on by things like tests or drivers
that subsequently require the feature exist.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2024-05-04 13:23:22 +03:00
Mikhail Skobov
7d362e0a77 drivers: i2c: i2c_ll_stm32_v1
In rare cases, the I2C driver runs the N==2 logic
for I2C receives when N>2. This change breaks early
when handling the last 2 bytes for transactions with N>2

Signed-off-by: Mikhail Skobov <skobovm@meta.com>
2024-05-03 07:53:31 -04:00
Robert Hancock
1ad4b5c617 i2c: i2c_xilinx_axi: Fix for target mode interrupt handling
When a target was registered with the controller but a controller-mode
request was performed, the driver failed to mask the interrupts that
were occurring as a result of the controller-mode transfer, causing an
interrupt flood. Ensure that all interrupts not handled by target mode
are handled as potential controller-mode events and acknowledged
properly.

Signed-off-by: Robert Hancock <robert.hancock@calian.com>
2024-04-29 07:11:16 +03:00
Robert Hancock
083a42d734 i2c: i2c_xilinx_axi: Fix switching from controller to target mode
It appears that a controller re-initialization is sometimes needed for
proper operation when handling target mode requests after a request from
the core is completed in controller mode. Add this re-initialization as
was already done between controller mode requests.

Signed-off-by: Robert Hancock <robert.hancock@calian.com>
2024-04-29 07:11:16 +03:00
Yong Cong Sin
0291c551a2 drivers: use DT_INST_NODE_HAS_COMPAT
Replace occurances of:

  DT_NODE_HAS_COMPAT\(DT_DRV_INST\((.*)\), (.*)\)

With:

  DT_INST_NODE_HAS_COMPAT($1, $2)

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-04-26 20:04:38 +01:00
Benjamin Cabé
8304e82328 drivers: i2c: fix leaking Kconfig option for dw driver
Fix leaking I2C_DW_LPSS_DMA option that was showing up for all I2C
drivers

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2024-04-26 19:48:11 +01:00
Benjamin Cabé
c165446993 drivers: i2c: fix leaking Kconfig option for mcux driver
Fix leaking I2C_NXP_TRANSFER_TIMEOUT option. It was showing up for all
I2C drivers.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2024-04-26 19:48:11 +01:00
Bram Vlerick
1e8051af34 i2c: i2c_mcux_flexcomm: add multi target support
When registering a target device, the driver will check if a slave address
is free in the peripheral. If so, the new slave address gets configured and
enabled.

Signed-off-by: Bram Vlerick <bram.vlerick@openpixelsystems.org>
2024-04-26 19:47:19 +01:00
Bram Vlerick
e0daad64a4 i2c: i2c_mcux_flexcomm: move slave init to helper function
Move slave initialization to a separate helper function. This helper will
also be needed in the multi target support during unregistration. When
unregistering, the slave needs to be reinitialized if other remaining
targets are still attached.

Signed-off-by: Bram Vlerick <bram.vlerick@openpixelsystems.org>
2024-04-26 19:47:19 +01:00
Bram Vlerick
20cc510df4 i2c: i2c_mcux_flexcomm: add find target functions
Add helper functions to find a free target for configuration and find a
target based on the configured slave address. These functions are in
preparation for multi-target mode.

Signed-off-by: Bram Vlerick <bram.vlerick@openpixelsystems.org>
2024-04-26 19:47:19 +01:00
Bram Vlerick
39bae54b53 i2c: i2c_mcux_flexcomm: move target data to separate struct
Move target data to dedicated struct. This is in preparation for multi
target support. The target_handle can stay global since this handle is
unique per peripheral and not per slave address.

Signed-off-by: Bram Vlerick <bram.vlerick@openpixelsystems.org>
2024-04-26 19:47:19 +01:00