Skip to content

Commit

Permalink
ASoC:rt5640: Retry 3 times when probing rt5640 codec
Browse files Browse the repository at this point in the history
Signed-off-by: Wan, Xinxin <[email protected]>
  • Loading branch information
xinxin-wan authored and JeevakaPrabu committed Jun 18, 2024
1 parent a2e0e29 commit e8a8c0c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion sound/soc/codecs/rt5640.c
Original file line number Diff line number Diff line change
Expand Up @@ -2990,6 +2990,7 @@ static int rt5640_i2c_probe(struct i2c_client *i2c)
struct rt5640_priv *rt5640;
int ret;
unsigned int val;
int i;

rt5640 = devm_kzalloc(&i2c->dev,
sizeof(struct rt5640_priv),
Expand Down Expand Up @@ -3025,7 +3026,15 @@ static int rt5640_i2c_probe(struct i2c_client *i2c)
msleep(400);
}

regmap_read(rt5640->regmap, RT5640_VENDOR_ID2, &val);
/* let's try 3 times when reading VENDOR_ID2 in case HW is not ready */
for (i = 0; i < 3; i++) {
regmap_read(rt5640->regmap, RT5640_VENDOR_ID2, &val);
if (val == RT5640_DEVICE_ID)
break;

msleep(10);
}

if (val != RT5640_DEVICE_ID) {
dev_err(&i2c->dev,
"Device with ID register %#x is not rt5640/39\n", val);
Expand Down

0 comments on commit e8a8c0c

Please sign in to comment.