Skip to content

Commit

Permalink
fix dw read state error
Browse files Browse the repository at this point in the history
  • Loading branch information
SamulKyull authored Apr 12, 2024
1 parent 42d51b2 commit 5e4affd
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions bsp/drivers/drm/sunxi_device/hardware/lowlevel_hdmi20/dw_i2cm.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ int _dw_i2cm_read(unsigned char *buf, unsigned int length)
{
u8 state = 0x0;
int timeout = DW_I2CM_TIMEOUT;
u8 retry_cnt = 5;
u8 retry_cnt = 2;

log_trace1(length);

Expand All @@ -87,11 +87,13 @@ int _dw_i2cm_read(unsigned char *buf, unsigned int length)
dw_write(I2CM_OPERATION, I2CM_OPERATION_RD_MASK);

do {
udelay(20);
state = dw_read(IH_I2CM_STAT0);
udelay(10);
state = dw_read_mask(IH_I2CM_STAT0,
IH_I2CM_STAT0_I2CMASTERERROR_MASK
| IH_I2CM_STAT0_I2CMASTERDONE_MASK);
} while ((state == 0) && (timeout--));

if ((state == 0) && (timeout == 0)) {
if ((state == 0) || (timeout == 0)) {
/* TODO, i2c may has issue. try to sw reset */
hdmi_inf("i2c read wait state timeout\n");
return -2;
Expand Down Expand Up @@ -154,8 +156,9 @@ int _dw_i2cm_write(unsigned char *buf, unsigned int length)
state = dw_read(IH_I2CM_STAT0);
} while ((state == 0) && (timeout--));

if ((state == 0) && (timeout == 0)) {
if ((state == 0) || (timeout == 0)) {
/* TODO, i2c may has issue. try to sw reset */
hdmi_inf("i2c read wait state timeout\n");
return -2;
}

Expand Down

0 comments on commit 5e4affd

Please sign in to comment.