Skip to content

Commit eccbd8f

Browse files
committed
i2c: Add work-around to make i2c scan work
The I2C HW cannot support 0-byte transfer as I2C scan requests. Send one dummy byte for I2C scan to make it work. Signed-off-by: Dong Wang <dong.d.wang@intel.com>
1 parent cab34ab commit eccbd8f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

bsp_sedi/drivers/i2c/sedi_i2c_dw_apb_200a.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,6 @@ int32_t sedi_i2c_master_write_async(IN sedi_i2c_t i2c_device, IN uint32_t addr,
878878
DBG_CHECK(i2c_device < SEDI_I2C_NUM, SEDI_DRIVER_ERROR_PARAMETER);
879879
DBG_CHECK(0 != (addr & SEDI_RBFM(I2C, TAR, IC_TAR)), SEDI_DRIVER_ERROR_PARAMETER);
880880
DBG_CHECK(NULL != data, SEDI_DRIVER_ERROR_PARAMETER);
881-
DBG_CHECK(0 != num, SEDI_DRIVER_ERROR_PARAMETER);
882881

883882
struct i2c_context *context = &contexts[i2c_device];
884883

@@ -909,7 +908,12 @@ int32_t sedi_i2c_master_write_async(IN sedi_i2c_t i2c_device, IN uint32_t addr,
909908
context->status.event = SEDI_I2C_EVENT_TRANSFER_NONE;
910909

911910
context->buf = (uint8_t *)data;
912-
context->buf_size = num;
911+
if ((num == 0) && (data != NULL)) {
912+
/* Workaround for I2C scanner as HW does not support 0 byte transfers. */
913+
context->buf_size = 1;
914+
} else {
915+
context->buf_size = num;
916+
}
913917
context->rx_cmd_index = 0;
914918
context->buf_index = 0;
915919
context->pending = pending;

0 commit comments

Comments
 (0)