zephyr/drivers/i2c
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
..
target drivers: i2c: Add zephyr-keep-sorted defines 2025-01-08 01:30:34 +01:00
CMakeLists.txt drivers: i2c: stm32 i2cv1 controller driver using rtio 2025-05-22 20:56:28 +02:00
gpio_i2c_switch.c drivers: i2c: Place API into iterable section 2024-12-16 18:25:36 +01:00
i2c_ambiq.c drivers/i2c/i2c_ambiq: Fix code compliance issues 2025-05-21 12:35:28 +02:00
i2c_andes_atciic100.c drivers: i2c: Place API into iterable section 2024-12-16 18:25:36 +01:00
i2c_andes_atciic100.h
i2c_b91.c drivers: i2c: Place API into iterable section 2024-12-16 18:25:36 +01:00
i2c_bcm_iproc.c drivers: i2c: Place API into iterable section 2024-12-16 18:25:36 +01:00
i2c_bitbang.c doc: i2c: Update I2C specification link 2024-11-21 09:17:50 +01:00
i2c_bitbang.h
i2c_cc13xx_cc26xx.c drivers: i2c: cc13xx_cc26xx: Add support for I2C_MSG_RESTART 2025-01-14 17:57:40 +01:00
i2c_cc32xx.c drivers: i2c: Place API into iterable section 2024-12-16 18:25:36 +01:00
i2c_cdns.c drivers: i2c: Add Cadence I2C support 2025-03-12 19:02:04 +01:00
i2c_common.c
i2c_dw_registers.h drivers: i2c_dw: issue transfer abort on timeout 2025-03-19 20:31:25 +01:00
i2c_dw.c drivers: i2c_dw: issue transfer abort on timeout 2025-03-19 20:31:25 +01:00
i2c_dw.h drivers: i2c_dw: add devicetree property to offset clock settings 2024-12-16 20:51:32 +01:00
i2c_emul.c drivers,test: use the new DT_FOREACH_PROP_ELEM_SEP 2025-02-04 09:18:55 +01:00
i2c_ene_kb1200.c driver: i2c: ene_kb1200 i2c slave address 2025-04-22 09:58:32 +02:00
i2c_esp32.c drivers: i2c: Place API into iterable section 2024-12-16 18:25:36 +01:00
i2c_gd32.c drivers: i2c: Place API into iterable section 2024-12-16 18:25:36 +01:00
i2c_gecko.c drivers: i2c: Place API into iterable section 2024-12-16 18:25:36 +01:00
i2c_gpio.c drivers: i2c: Place API into iterable section 2024-12-16 18:25:36 +01:00
i2c_handlers.c
i2c_ifx_cat1.c drivers: ifx_cat1: Updates to support latest version of HAL/PDL 2025-01-14 20:49:14 +01:00
i2c_ifx_xmc4.c drivers: i2c: Place API into iterable section 2024-12-16 18:25:36 +01:00
i2c_imx.c drivers: i2c: Place API into iterable section 2024-12-16 18:25:36 +01:00
i2c_ite_enhance.c drivers/i2c: ite: Add handling for read operation with 0-byte length 2025-05-29 10:46:47 +02:00
i2c_ite_it8xxx2.c drivers/i2c: ite: Use i2c_bitbang API for bus recovery 2025-04-17 09:06:29 +02:00
i2c_ite_it51xxx.c drivers/i2c: Add I2C driver of it51xxx 2025-04-29 16:48:06 +02:00
i2c_litex_litei2c.c drivers: i2c: litex: add mutex in litei2c 2025-03-27 14:01:11 +01:00
i2c_litex.c drivers: i2c: Place API into iterable section 2024-12-16 18:25:36 +01:00
i2c_ll_stm32_common.c drivers: i2c: move functions to a common file 2025-05-22 20:56:28 +02:00
i2c_ll_stm32_rtio.c drivers: i2c: stm32 i2cv2 controller driver using rtio 2025-05-22 20:56:28 +02:00
i2c_ll_stm32_v1_rtio.c drivers: i2c: stm32 i2cv1 controller driver using rtio 2025-05-22 20:56:28 +02:00
i2c_ll_stm32_v1.c drivers: i2c: move functions to a common file 2025-05-22 20:56:28 +02:00
i2c_ll_stm32_v2_rtio.c drivers: i2c: stm32 i2cv2 controller driver using rtio 2025-05-22 20:56:28 +02:00
i2c_ll_stm32_v2.c drivers: i2c: stm32: add timeout to avoid infinite loop 2025-05-27 12:01:31 +01:00
i2c_ll_stm32.c drivers: i2c: stm32: Fix size calculation of n_timings 2025-05-27 17:55:36 +02:00
i2c_ll_stm32.h drivers: i2c: stm32 i2cv1 controller driver using rtio 2025-05-22 20:56:28 +02:00
i2c_lpc11u6x.c drivers: i2c: Place API into iterable section 2024-12-16 18:25:36 +01:00
i2c_lpc11u6x.h
i2c_max32_rtio.c drivers: i2c_rtio: max32: Inform the rtio executor on errors 2025-04-22 12:10:12 +02:00
i2c_max32.c drivers: i2c: Update driver to enable I2C for MAX32650 SoC 2025-05-14 11:03:22 +01:00
i2c_mchp_mss.c drivers: i2c: Place API into iterable section 2024-12-16 18:25:36 +01:00
i2c_mchp_xec_v2.c drivers: i2c: Place API into iterable section 2024-12-16 18:25:36 +01:00
i2c_mchp_xec.c drivers: i2c: Place API into iterable section 2024-12-16 18:25:36 +01:00
i2c_mcux_flexcomm.c drivers: i2c_mcux_flexcomm: adds PM TURN_ON low-power recovery support 2025-04-25 18:59:57 +02:00
i2c_mcux_lpi2c_rtio.c drivers: i2c_rtio: MCUX LPflexcomm determine by inst 2025-04-14 23:06:53 +02:00
i2c_mcux_lpi2c.c i2c_mcux_lpspi: LPflexcomm determine by inst 2025-01-21 19:28:01 +01:00
i2c_mcux.c drivers: i2c: Place API into iterable section 2024-12-16 18:25:36 +01:00
i2c_nios2.c drivers: i2c: Place API into iterable section 2024-12-16 18:25:36 +01:00
i2c_npcx_controller.c i2c: npcx: Loosen requirements for target registration 2025-05-22 23:57:08 +02:00
i2c_npcx_controller.h drivers: i2c: npcx: add support to wake up from sleep mode 2025-01-20 07:05:48 +01:00
i2c_npcx_port.c drivers: i2c: npcx: add support for multi-address in target mode 2025-03-25 08:43:52 +01:00
i2c_nrfx_twi_common.c
i2c_nrfx_twi_common.h drivers: i2c: nrfx_twi[m]: default to I2C_BITRATE_STANDARD 2024-10-29 09:27:05 -07:00
i2c_nrfx_twi_rtio.c drivers: i2c: nrfx_twi_rtio: support RTIO_OP_AWAIT 2025-04-29 16:47:26 +02:00
i2c_nrfx_twi.c drivers: i2c: Place API into iterable section 2024-12-16 18:25:36 +01:00
i2c_nrfx_twim_common.c i2c: i2c_nrfx_twim: update callback context to dev 2024-10-21 15:53:05 +02:00
i2c_nrfx_twim_common.h drivers: i2c: nrfx_twi[m]: default to I2C_BITRATE_STANDARD 2024-10-29 09:27:05 -07:00
i2c_nrfx_twim_rtio.c drivers: i2c: nrfx_twim_rtio: support RTIO_OP_AWAIT 2025-04-29 16:47:26 +02:00
i2c_nrfx_twim.c drivers: i2c_nrfx_twim: add exclusive access API 2025-03-27 17:17:32 +01:00
i2c_nrfx_twis.c drivers: i2c: i2c_nrfx_twis: patch dma buf mem section 2025-02-10 14:32:52 +01:00
i2c_numaker.c drivers: i2c: Place API into iterable section 2024-12-16 18:25:36 +01:00
i2c_nxp_ii2c.c drivers: i2c: add NXP i2c driver used on imx8m platforms 2025-01-24 19:15:57 +01:00
i2c_omap.c drivers: i2c: omap: Fix for RAM MMIO 2025-05-23 11:04:00 +02:00
i2c_rcar.c drivers: i2c: Place API into iterable section 2024-12-16 18:25:36 +01:00
i2c_renesas_ra_iic.c drivers: Correct value of event macro for all Renesas SoC 2025-02-28 18:29:17 +01:00
i2c_renesas_ra_sci_b.c drivers: i2c: initial support for i2c sci-b driver on Renesas RA family 2025-03-24 19:22:18 +01:00
i2c_renesas_rz_riic.c drivers: i2c: Initial support for RZ/G3S 2025-03-07 19:45:11 +01:00
i2c_rtio_default.c i2c: Fix default RTIO handler transactions 2024-10-22 18:29:34 -04:00
i2c_rtio.c drivers: i2c: rtio 2025-03-07 19:43:22 +01:00
i2c_rv32m1_lpi2c.c drivers: i2c: Place API into iterable section 2024-12-16 18:25:36 +01:00
i2c_sam0.c clocks: atmel: sam0: Fix gclk and mclk clock bindings 2025-01-14 20:49:03 +01:00
i2c_sam4l_twim.c drivers: i2c: Place API into iterable section 2024-12-16 18:25:36 +01:00
i2c_sam_twi.c drivers: i2c: Place API into iterable section 2024-12-16 18:25:36 +01:00
i2c_sam_twihs_rtio.c drivers: i2c: Place API into iterable section 2024-12-16 18:25:36 +01:00
i2c_sam_twihs.c drivers: i2c: Place API into iterable section 2024-12-16 18:25:36 +01:00
i2c_sbcon.c drivers: i2c: add pinctrl support to Arm sbcon driver 2025-04-07 15:18:10 +02:00
i2c_sc18im704.c drivers: i2c: Place API into iterable section 2024-12-16 18:25:36 +01:00
i2c_sc18im704.h
i2c_sedi.c drivers: sedi: Update device definition macros to use DT_INST variants 2025-01-08 19:10:52 +01:00
i2c_shell.c drivers: i2c: shell: use shell_fprintf_normal instead of shell_fprintf 2025-03-25 00:31:48 +01:00
i2c_sifive.c drivers: i2c: Place API into iterable section 2024-12-16 18:25:36 +01:00
i2c_smartbond.c drivers: i2c: Place API into iterable section 2024-12-16 18:25:36 +01:00
i2c_sy1xx.c drivers: i2c: sy1xx add support for i2c 2025-03-14 14:39:55 +01:00
i2c_tca954x.c drivers: i2c: tca954x: add support for idle disconnect 2025-04-04 18:17:07 +02:00
i2c_test.c drivers: i2c: Place API into iterable section 2024-12-16 18:25:36 +01:00
i2c_wch.c drivers: wch: fix the ch32vfun.h path after the recent HAL update 2025-05-28 05:54:28 +02:00
i2c_xilinx_axi.c drivers: i2c: xilinx_axi: Remove nested spinlock 2025-03-17 02:20:20 +01:00
i2c_xilinx_axi.h
i2c-priv.h
Kconfig drivers/i2c: Add I2C driver of it51xxx 2025-04-29 16:48:06 +02:00
Kconfig.ambiq drivers: iom: define ambiq spi/i2c dma mode as a binding property 2025-05-13 16:23:26 +02:00
Kconfig.andes_atciic100
Kconfig.b91 drivers: all: telink-b91: select PINCTRL 2024-12-05 15:17:47 +01:00
Kconfig.bcm_iproc
Kconfig.cc13xx_cc26xx drivers: all: cc12xx_cc26xx: select PINCTRL 2024-12-05 15:18:01 +01:00
Kconfig.cdns drivers: i2c: Add Cadence I2C support 2025-03-12 19:02:04 +01:00
Kconfig.dw drivers: i2c: dw: Enable PINCTRL conjuction with dt prop 'pinctrl-0' 2025-03-20 07:21:03 +01:00
Kconfig.ene
Kconfig.esp32
Kconfig.gd32 soc: gd32: Drop PINCTRL from Kconfig.defconfig 2024-11-04 13:40:42 -06:00
Kconfig.gpio
Kconfig.i2c_emul
Kconfig.ifx_cat1 drivers: Remove CONFIG_PINCTRL in defconfig files 2024-09-23 18:08:14 -04:00
Kconfig.ifx_xmc4 drivers: Remove CONFIG_PINCTRL in defconfig files 2024-09-23 18:08:14 -04:00
Kconfig.it8xxx2 drivers/i2c: ite: Use i2c_bitbang API for bus recovery 2025-04-17 09:06:29 +02:00
Kconfig.it51xxx drivers/i2c: Add I2C driver of it51xxx 2025-04-29 16:48:06 +02:00
Kconfig.litex drivers: i2c: litex: add driver for litei2c 2025-03-27 14:01:11 +01:00
Kconfig.lpc11u6x boards: nxp: Removing CONFIG_PINCTRL from the boards defconfig 2024-10-15 19:09:45 -04:00
Kconfig.max32 drivers: i2c: Select PINCTRL for MAX32 MCUs 2024-08-16 16:29:55 +01:00
Kconfig.mchp_mss
Kconfig.mcux drivers: i2c_mcux_flexcomm: add support for bus recovery. 2025-01-08 09:33:16 +01:00
Kconfig.npcx board: npcx: remove CONFIG_PINCTRL from defconfig of npcx boards 2024-11-07 08:59:14 -08:00
Kconfig.nrfx drivers: i2c: add nrf twis suppport 2024-12-20 16:14:05 +01:00
Kconfig.numaker boards: nuvoton: numaker: Drop PINCTRL from board defconfig 2024-11-20 08:23:58 -05:00
Kconfig.omap drivers: i2c: i2c_omap: Add pinctrl 2025-02-14 13:36:26 +01:00
Kconfig.rcar
Kconfig.renesas_ra drivers: i2c: initial support for i2c sci-b driver on Renesas RA family 2025-03-24 19:22:18 +01:00
Kconfig.renesas_rz drivers: i2c: Initial support for RZ/G3S 2025-03-07 19:45:11 +01:00
Kconfig.sam0 drivers: i2c: I2C_SAM0_TRANSFER_TIMEOUT depends on I2C_SAM0 2025-02-19 14:51:04 +00:00
Kconfig.sam_twihs soc: atmel: Drop PINCTRL from Kconfig.defconfig 2024-11-04 13:43:26 -06:00
Kconfig.sbcon drivers: i2c: add pinctrl support to Arm sbcon driver 2025-04-07 15:18:10 +02:00
Kconfig.sc18im704
Kconfig.sedi
Kconfig.sifive
Kconfig.smartbond da1469x: Remove CONFIG_PINCTRL from all defconfig files 2024-10-08 16:57:41 +02:00
Kconfig.stm32 i2c: stm32: Add config option to enable DMA support 2025-03-20 12:17:50 +01:00
Kconfig.sy1xx drivers: i2c: sy1xx add support for i2c 2025-03-14 14:39:55 +01:00
Kconfig.tca954x drivers: i2c: tca9544a 2024-11-22 22:47:17 +00:00
Kconfig.test
Kconfig.wch drivers: i2c: added wch i2c driver 2025-04-17 21:17:06 +02:00
Kconfig.xec drivers: microchip xec: select PINCTRL 2024-11-29 05:41:53 +01:00
Kconfig.xilinx_axi