[alsa-devel] [PATCH v2] ASoC: rt5663: Delay and retry reading rt5663 ID register
![](https://secure.gravatar.com/avatar/887cc82c4241591b21e4f09211df322b.jpg?s=120&d=mm&r=g)
In the probe, the codec may not be ready for I2C reading or there are some glitches on the i2c line. So if the i2c reading value is incorrect, it will read again after delay. This issue is similar the patch https://patchwork.kernel.org/patch/9681421/. In current project, these 2 devices were connected to the same i2c line, and they met the same problem.
Signed-off-by: Oder Chiou oder_chiou@realtek.com --- sound/soc/codecs/rt5663.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/sound/soc/codecs/rt5663.c b/sound/soc/codecs/rt5663.c index fcd1643..5985d8e 100644 --- a/sound/soc/codecs/rt5663.c +++ b/sound/soc/codecs/rt5663.c @@ -3429,7 +3429,16 @@ static int rt5663_i2c_probe(struct i2c_client *i2c, ret); return ret; } - regmap_read(regmap, RT5663_VENDOR_ID_2, &val); + + ret = regmap_read(regmap, RT5663_VENDOR_ID_2, &val); + if (ret || (val != RT5663_DEVICE_ID_2 && val != RT5663_DEVICE_ID_1)) { + dev_err(&i2c->dev, + "Device with ID register %#x is not rt5663," + " retry one time.\n", val); + msleep(100); + regmap_read(regmap, RT5663_VENDOR_ID_2, &val); + } + switch (val) { case RT5663_DEVICE_ID_2: rt5663->regmap = devm_regmap_init_i2c(i2c, &rt5663_v2_regmap);
![](https://secure.gravatar.com/avatar/d930951cb00393ecf9c3db3a56d78fa9.jpg?s=120&d=mm&r=g)
On Thu, Nov 09, 2017 at 02:48:11PM +0800, Oder Chiou wrote:
dev_err(&i2c->dev,
"Device with ID register %#x is not rt5663,"
" retry one time.\n", val);
This still splits the error message over two lines - like I said that'll make it harder for someone to search the kernel source to find where the error was generated and understand what it means.
participants (2)
-
Mark Brown
-
Oder Chiou