Commit Graph

1338 Commits

Author SHA1 Message Date
Michał Bainczyk
2e06c4ed20 drivers: nrf: add build asserts for memory-regions property
Add build asserts for "memory-regions" property in nrf drivers which is
required on targets with DMM for saadc, pdm, pwm, twim, twim_rtio, twis,
tdm, uarte, spim and spis. On targets where the property is not required
the assertion macro expands to nothing.

Signed-off-by: Michał Bainczyk <michal.bainczyk@nordicsemi.no>
2025-07-28 04:27:25 -04:00
Tim Lin
2d18c7ec81 drivers/i2c: it51xxx: Avoid entering power policy during PIO transfers
Avoid entering low-power state during I2C host transfers in PIO mode.
Entering a low-power state during an active PIO transfer may prevent
the peripheral from generating the clock signal correctly,
resulting in transmission errors.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2025-07-23 17:29:18 +01:00
Tim Lin
f0af5be2b4 drivers/i2c: it8xxx2: Avoid entering power policy during PIO transfers
Avoid entering low-power state during I2C host transfers in PIO mode.
Entering a low-power state during an active PIO transfer may prevent
the peripheral from generating the clock signal correctly,
resulting in transmission errors.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2025-07-23 17:29:18 +01:00
Tim Lin
7cf9a58b7b drivers/i2c: it81xx2: Avoid entering power policy during PIO transfers
Avoid entering low-power state during I2C host transfers in PIO mode.
Entering a low-power state during an active PIO transfer may prevent
the peripheral from generating the clock signal correctly,
resulting in transmission errors.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2025-07-23 17:29:18 +01:00
Tim Lin
648919f6df drivers/i2c: it51xxx: Refactor ISR to reduce clock stretch in PIO mode
Move handling of write-to-clear status and stop detect to the
beginning of the ISR for PIO mode to reduce unnecessary clock
stretching and improve responsiveness during transfers.

This patch also separates status clearing for shared FIFO mode,
ensuring it is done at the appropriate point after data handling
completes, maintaining correct transfer behavior.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2025-07-23 09:36:37 +02:00
Xiaolu Sun
b623663ffc drivers: i2c_sedi: Apply DTS clock_frequency to I2C during initialization
Previously, the clock_frequency property defined in the Device Tree was
not applied to the I2C controller, causing the controller to ignore the
specified bitrate configuration if no other config for speed. When using
default hardware settings, the lack of an explicit timing or frequency
config may result in the controller ignoring bitrate settings. This change
ensures that the clock_frequency value from DTS is now correctly mapped
and set during controller initialization, allowing the bitrate to take
effect as intended. This improves hardware configurability and ensures
the I2C bus operates at the desired speed specified in the Device Tree.

Signed-off-by: Xiaolu Sun <xiaolu.sun@intel.com>
2025-07-22 19:32:08 -04:00
Tim Lin
daaacd2998 drivers/i2c: it51xxx: Add support two target addresses for each target
This commit adds support for configuring two user-defined target
addresses in the I2C target driver.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2025-07-19 13:42:42 -04:00
Tom Burdick
508676ca11 i2c: Use I2C log level for lpi2c rtio
Driver simply registered itself without setting the level based on the
I2C Kconfig which wasn't quite right, need the log level set based on
the Kconfig for I2C.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2025-07-19 09:53:21 +02:00
Fabrice DJIATSA
1804eb7bc3 drivers: i2c: stm32: exclude stm32f7 family for PM
The STM32F7 family does not yet support power management in Zephyr.

Besides, LL_I2C_EnableWakeUpFromStop and LL_I2C_DisableWakeUpFromStop

are not implemented in the H7 HAL/LL drivers

Signed-off-by: Fabrice DJIATSA <fabrice.djiatsa-ext@st.com>
2025-07-09 17:16:16 -05:00
Sylvio Alves
c358861280 drivers: i2c: esp32: drop transfer log error
Drop LOG_ERR calls from driver level related to transfer calls.
Application can handle the result and decide whether to log or not.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2025-07-04 13:08:23 -05:00
Alex Hogen
075662d8dc drivers: i2c: gecko: Fix EFM32 I2C target
clang-format on drivers/i2c/i2c_gecko.c

Signed-off-by: Alex Hogen <alex@edt.com>
2025-07-04 13:07:45 -05:00
Alex Hogen
257bcb8d58 drivers: i2c: gecko: Fix EFM32 I2C target
Fix I2C target implementation so NACKs are issued if the callback returns
an error. This allows for proper signaling to the I2C host when commands
or data are invalid for the I2C target.

Signed-off-by: Alex Hogen <alex@edt.com>
2025-07-04 13:07:45 -05:00
Alex Hogen
92f7e8d84b drivers: i2c: gecko: Fix EFM32 I2C target
Fix compile error due to unknown macro when building CONFIG_I2C_TARGET for
Silabs Thunderboard EFM32GG12 (SLTB009A). The previous macro exists in
(all?) EFR32 part headers but not EFM32.

Signed-off-by: Alex Hogen <alex@edt.com>
2025-07-04 13:07:45 -05:00
Yuval Peress
d8d6637a1f i2c_shell: Only include target commands if I2C_TARGET
The extra shell commands are useless unless you also enable
I2C_TARGET. Conditionally include them based on the I2C_TARGET
kconfig.

Signed-off-by: Yuval Peress <peress@google.com>
2025-06-27 18:26:33 -05:00
Eason Huang
f1b59c2cd2 drivers: i2c_dw: fix request_bytes overflow when receiving > 256 bytes
The original definition of request_bytes as uint8_t caused incorrect
behavior when attempting to receive more than 256 bytes, as the variable
would overflow. This patch changes its type to uint32_t to allow
correct tracking of large I2C transfers.

Signed-off-by: Eason Huang <eason.huang@tronfuture.com>
2025-06-27 09:08:18 -10:00
Sebastian Huber
9132ac48bf drivers: i2c: mchp_mss: Add reset support
Add support to reset the device through a reset controller.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2025-06-27 09:59:08 -05:00
Tony Han
9f0ca750f8 drivers: i2c: sam: fix the exception when transferring without data
The issue is found when doing shell command "i2c scan" on sama7g54-ek.
In this case no data will be transferred besides START and STOP. Data
abort would occur on accessing "msg->buf[msg->idx++]" when MMU is
enabled and "msg->idx" is very large.

Signed-off-by: Tony Han <tony.han@microchip.com>
2025-06-26 22:19:09 -05:00
Bjarki Arge Andreasen
f22ffee5c3 drivers: i2c: nrfx_twis: impl device deinit
Implement device deinit hooks for nRF TWIS device driver.

Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
2025-06-26 22:15:52 -05:00
Bjarki Arge Andreasen
bd73c739b4 drivers: i2c: nrfx_twim: impl device deinit
Implement device deinit for the nRF TWIM device drivers.

Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
2025-06-26 22:15:52 -05:00
Sebastian Głąb
031040872e drivers: i2c: Support i2c23 and i2c24 instances
Extend I2C driver with possibility to use
- TWIM23, TWIM24,
- TWIS23, TWIS24.

Signed-off-by: Sebastian Głąb <sebastian.glab@nordicsemi.no>
2025-06-26 14:07:55 +02:00
Benjamin Cabé
a06454f61f drivers: i2c: renesas_rz_riic: fix apply state in init code
Fixed the reverse logic of checking if `pin_config` is set in the init
code.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-06-26 09:39:39 +02:00
Fabio Baltieri
4f3523d9af i2c: stm32: drop few redundant guards
Drop few CONFIG_PM_DEVICE_RUNTIME guards, the pm_device_runtime
functions they are masking are no-op automatically when the
corresponding config option is not selected.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2025-06-25 14:08:08 +02:00
Fabio Baltieri
67f80e35b8 i2c: stm32: always call runtime_get when registering targets
Current code only calls pm_device_runtime_get when registering target
devices if the device is marked as wakeup capable by the application.

This does quite work for a setup with PM=n and PM_DEVICE=y and
PM_DEVICE_RUNTIME=y, where the CPU does not really go in stop mode ever,
and results in the i2c target device not working at all.

Fix this by always claiming the device when PM_DEVICE_RUNTIME is
enabled.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2025-06-25 14:08:08 +02:00
Duy Nguyen
92a631e836 drivers: i2c: Add support i2c driver for Renesas RX MCU
Add initial support for i2c on Renesas RX MCU
This driver is controlling the RIIC HW of RX MCU for i2c bus
interface on Zephyr
Only master mode is supported

Signed-off-by: Duy Nguyen <duy.nguyen.xa@renesas.com>
2025-06-23 16:26:51 -05:00
Etienne Carriere
79d1803efe drivers: i2c: stm32: add target mode in RTIO drivers
Implement I2C target mode in STM32 I2C RTIO drivers. The implementation
in respectively i2c_ll_stm32_v1_rtio.c and i2c_ll_stm32_v2_rtio.c is
based on the implementation of the non-RTIO drivers, respectively
i2c_ll_stm32_v1.c and i2c_ll_stm32_v2_rtio.c.

Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
2025-06-23 12:47:00 -07:00
Etienne Carriere
e16c9bb41d drivers: i2c: stm32: report error case in v1 RTIO driver
Report error event to the RTIO framework in STM32 I2C v1 driver.

Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
2025-06-23 12:47:00 -07:00
Etienne Carriere
5740dfe77b drivers: i2c: stm32: fix write burst in RTIO drivers
Correct management of I2C write transfers that are driven from 2
I2C messages, one for the transfer of the address to write
to and a following message for the transfer of the data to be written.
In this case, no START and STOP bit should be triggered between the 2
I2C transfers.

In STM32 I2C v1 driver, this simply means not emitting a START
condition when the input sequence does not set the RESTART flag.

In STM32 I2C v2 driver, this can only be achieved using the SoC I2C
controller Reload Mode feature, hence update Reload Mode implementation
to use reload mode for both transfers over 255 bytes (splitted in
chunks) and for cases where no STOP and START bits are emitted between
2 transfer in the same transaction.

Regarding STM32 I2C v2 driver, the reload mode must be enable before the
first transaction, known that it's needed due to the following
transaction. Therefore we need to parse the messages grouped in the same
transaction to detect such sequences (a message without STOP flag
followed by a message without RESTART flag) and when so, pass the
information to the I2C driver through RTIO framework. To achieve that,
let's use a free bit from I2C message flags (bit 7) in the message
for which we need to enable SoC ReloadMode from the first transfer.
We check that this bit flag is not used by the I2C framework prior
using it.

Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
2025-06-23 12:47:00 -07:00
Etienne Carriere
2ccc1eab89 drivers: i2c: stm32: I2C transaction first transfer must set RESTART flag
The first transfer in an I2C transaction series must always set
the RESTART flag. Since this is not always done by callers,
enforce the flag is set, both in the I2C API and RTIO API entry
points of STM32 I2C RTIO drivers.

Add a sanity test in STM32 I2C v2 RTIO driver on transaction
chunks regarding RESTART and STOP flags, as done on the non-RTIO
driver.


Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
2025-06-23 12:47:00 -07:00
Tony Han
42a017cfde drivers: i2c: sam: update i2c_clock_set() for sama7g5 FLEXCOM TWI
The TWI offered by sama7g5 FLEXCOM is compatible with "atmel,sam-i2c-twi".

Signed-off-by: Tony Han <tony.han@microchip.com>
2025-06-22 18:44:04 -07:00
Hao Luo
f1348d3954 drivers: i2c: ambiq: buffer overflow issue fixed
Bugfix for possible out-of-bounds operation when buffer address
is not 4 bytes aligned

Signed-off-by: Hao Luo <hluo@ambiq.com>
2025-06-19 22:31:06 -07:00
Etienne Carriere
ba4b9819f5 drivers: i2c: stm32: disable error interrupts for RTIO
Add missing disable of I2C error interrupt when disabling I2C interrupts
in STM32 v1 and v2 RTIO drivers.

Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
2025-06-18 10:56:04 +02:00
Etienne Carriere
5065edb417 drivers: i2c: stm32: support more than 256 bytes transfer for RTIO
Add support for transfer of more than 256 byte in STM32 v1 and v2
RTIO drivers.

Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
2025-06-18 10:56:04 +02:00
Jun Lin
8ab712a235 drivers: i2c: npcx: prevent unexpected target address match ISR
This commit prevents the hardware from generating an unexpected
target slave address match ISR by the following change:
1. Enable the New Match Interrupt Enable bit (NMINTEN) only when
   necessary.
2. Explicitly clear all SMBnADDRx registers because they are not
   cleared when the I2C hardware is disabled. It will cause the
   asynchrinization between SMBnADDRx and registered_target_mask if the
   system jumps from the RO image to the RW image.

Signed-off-by: Jun Lin <CHLin56@nuvoton.com>
Signed-off-by: Alvis Sun <yfsun@nuvoton.com>
2025-06-17 08:20:39 +02:00
Hao Luo
37134f5a4e drivers: i2c: ambiq: optimize ambiq i2c device pm
This commit optimizes the device pm for ambiq i2c driver
by adding pinctrl sleep/resume.

Signed-off-by: Hao Luo <hluo@ambiq.com>
2025-06-17 07:22:44 +02:00
Tomasz Bursztyka
3703027b42 i2c: Add target related commands to the shell module
For testing/debugging purposes, it will be possible then to register
or unregister an i2c target.

Signed-off-by: Tomasz Bursztyka <tobu@bang-olufsen.dk>
Co-authored-by: Hans Binderup <habi@bang-olufsen.dk>
2025-06-16 14:13:13 +02:00
Yuval Peress
c8415cd76b i2c: npcx: Verify msg is not null
When using target mode, we've found that some times the msg field can
be null through some of the code paths of the interrupt event handler.

Signed-off-by: Yuval Peress <peress@google.com>
2025-06-13 07:37:14 +02:00
Guillaume Gautier
9798606340 drivers: i2c: stm32: fix some macro name
Some macros haven't been properly renamed in previous commits.
Fixes the wrong names that caused compilation errors.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2025-06-12 11:33:48 +02:00
Fabio Baltieri
33f6b76110 drivers: i2c: i2c_dw: only includ cmsis_core on ARM platforms
Only include cmsis_core.h on ARM platforms, including it unconditionally
as it is now causes a build failure on all other platforms, namely x86
on the weekly build run.

Tested with:

west build -p -b up_squared/apollo_lake tests/drivers/build_all/led
(and others)

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2025-06-11 08:20:40 +02:00
Jean Nanchen
bc097a6fe6 drivers: i2c: stm32: fix build error after timeout patch
Follow-up to PR #88631: fix missing variable declarations introduced in
the STM32 I2C LL driver after adding timeouts to blocking loops.

The missing declarations caused a build failure when interrupts were
disabled (CONFIG_I2C_STM32_INTERRUPT=n).

Fixes a regression introduced in #88631.

Signed-off-by: Jean Nanchen <jean.nanchen@gmail.com>
2025-06-10 12:10:59 +02:00
Henrik Lindblom
24b4ce189f drivers: stm32: dma: fix external dcache support
Several drivers checked for the presense and availability of data cache
through Kconfig symbol. This is supported according to the current
documentation, but the symbol DCACHE masks two types of cache devices: arch
and external caches. The latter is present on some Cortex-M33 chips, like
the STM32U5xx. The external dcache is bypassed when accessing internal
SRAM and only used for external memories.

In commit a2dd232410 ("drivers: adc: stm32: dma support") the rationale
for gating dcache for adc_stm32 behind STM32H7X is only hinted at, but
reason seems to be that it was the only SOC the change was tested on. The
SOC configures DCACHE=y so it is most likely safe to swap the SOC gate for
DCACHE.

The DCACHE ifdefs are now hidden inside the shared stm32_buf_in_nocache()
implementation.

Signed-off-by: Henrik Lindblom <henrik.lindblom@vaisala.com>
2025-06-06 10:19:58 +02:00
Abderrahmane JARMOUNI
b31251b4b4 drivers: stm32: i2c rtio: Fix 'timings' array size
'timings' is an array of 'struct i2c_config_timing' (3 x uint32_t).
'i2c_timings_##index' is an array of uint32_t (hence the cast when it
is assigned to 'timings'). Therefore 'ARRAY_SIZE(i2c_timings_##index)' is
off by a factor 3 when used for n_timings.

Signed-off-by: Abderrahmane JARMOUNI <git@jarmouni.me>
2025-06-06 10:11:59 +02:00
Al Semjonovs
d7e7839244 i2c: npcx_i2c_ctrl_transfer does not match original declaration
Fix npcx_i2c_ctrl_transfer arguments to match header to prevent
warning: type of 'npcx_i2c_ctrl_transfer' does not match original
declaration

Signed-off-by: Al Semjonovs <asemjonovs@google.com>
2025-06-05 15:11:14 -05:00
Bjarki Arge Andreasen
a8d44c37c4 pm: policy: remove redundant ifdef exclusion of device_power_lock
Remove redundant ifdef exclusion of calls to
pm_policy_device_power_lock_get() and
pm_policy_device_power_lock_put().

Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
2025-06-05 09:34:31 +02:00
Ayush Singh
debdd80da1 drivers: i2c: omap: Make reg pointers volatile
Since the __IO macro use has been removed, make the whole reg pointer
volatile. This is similar to what is done in the gpio-davinci driver.

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-06-02 17:37:43 +02:00
Ayush Singh
9c1f59264e drivers: i2c: i2c_omap: Fix for PocketBeagle 2 A53
Remove __IO macro.

Fix build errors for PocketBeagle 2 A53 target

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-06-02 17:37:43 +02:00
Bas van Loon
e7dd7abc0e drivers: i2c: Add support for clock stretching in the i2c-gpio module.
Some I2C peripherals like TI charger or gauge chips need support for I2C
clock stretching. This patch includes that and makes these modules
usable with I2C emulation over GPIO.

Signed-off-by: Bas van Loon <bas@arch-embedded.com>
2025-05-31 06:55:10 -04:00
Khoa Nguyen
463f518192 drivers: Update dtc transfer info alignment
Update dtc transfer info alignment for Renesas drivers

Signed-off-by: Khoa Nguyen <khoa.nguyen.xh@renesas.com>
2025-05-30 10:26:34 +02:00
Titan Chen
13a024218e drivers: i2c: add i2c dw support error checks.
support errors check for
1. tx_abrt: nack and sda stuck low
2. scl stuck low

Signed-off-by: Titan Chen <titan.chen@realtek.com>
2025-05-29 20:17:05 +02:00
Titan Chen
748789eadf drivers: i2c: rts5912 i2c dirver
base on DesignWare I2C driver to implement RTS5912 I2C driver.

1. support customize bus recovery function.
2. fix isr timing issue by enable tx empty control.
3. support stuck at low handle by enable bus clear feature.
4. support custom stuck at low timeout set from dts
5. disable block mode in rts5912 i2c.
6. support I2C_ALLOW_NO_STOP_TRANSACTIONS

Signed-off-by: Titan Chen <titan.chen@realtek.com>
2025-05-29 20:17:05 +02:00
Tim Lin
e1b5b8b5f9 drivers/i2c: ite: Add handling for read operation with 0-byte length
The current I2C driver assumes that at least one byte will be read in CQ
(command queue) mode. However, when a 0-byte read is issued
(e.g., by cmd_i2c_scan),
The read handler uses (len - 1) to set the command queue length.
When len is 0, this underflows to 0xFF, leading to an incorrect transfer
length and possible crash.

To fix this, add a check in cq_mode_allowed() for reads with length 0:

-Fallback to PIO mode in such cases.
-Properly handle 0-byte reads by issuing STOP (E_FINISH) when the slave
 address is acknowledged.
-Add appropriate handling for NACK conditions when the slave address is
 not acknowledged.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2025-05-29 10:46:47 +02:00