Skip to content

Commit 06afec5

Browse files
simontrimmerbroonie
authored andcommitted
ASoC: cs35l56: Waiting for firmware to boot must be tolerant of I/O errors
Ignore failure to read from the cs35l56 when polling as the device will NAK i2c accesses until it has booted and this would terminate the poll of regmap_read_poll_timeout(). Fixes: 8a731fd ("ASoC: cs35l56: Move utility functions to shared file") Signed-off-by: Simon Trimmer <simont@opensource.cirrus.com Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com Link: https://lore.kernel.org/r/20230829160433.2647889-1-rf@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org
1 parent b5f3cec commit 06afec5

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

sound/soc/codecs/cs35l56-shared.c

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -243,26 +243,27 @@ int cs35l56_wait_for_firmware_boot(struct cs35l56_base *cs35l56_base)
243243
{
244244
unsigned int reg;
245245
unsigned int val;
246-
int ret;
246+
int read_ret, poll_ret;
247247

248248
if (cs35l56_base->rev < CS35L56_REVID_B0)
249249
reg = CS35L56_DSP1_HALO_STATE_A1;
250250
else
251251
reg = CS35L56_DSP1_HALO_STATE;
252252

253-
ret = regmap_read_poll_timeout(cs35l56_base->regmap, reg,
254-
val,
255-
(val < 0xFFFF) && (val >= CS35L56_HALO_STATE_BOOT_DONE),
256-
CS35L56_HALO_STATE_POLL_US,
257-
CS35L56_HALO_STATE_TIMEOUT_US);
258-
259-
if ((ret < 0) && (ret != -ETIMEDOUT)) {
260-
dev_err(cs35l56_base->dev, "Failed to read HALO_STATE: %d\n", ret);
261-
return ret;
262-
}
263-
264-
if ((ret == -ETIMEDOUT) || (val != CS35L56_HALO_STATE_BOOT_DONE)) {
265-
dev_err(cs35l56_base->dev, "Firmware boot fail: HALO_STATE=%#x\n", val);
253+
/*
254+
* This can't be a regmap_read_poll_timeout() because cs35l56 will NAK
255+
* I2C until it has booted which would terminate the poll
256+
*/
257+
poll_ret = read_poll_timeout(regmap_read, read_ret,
258+
(val < 0xFFFF) && (val >= CS35L56_HALO_STATE_BOOT_DONE),
259+
CS35L56_HALO_STATE_POLL_US,
260+
CS35L56_HALO_STATE_TIMEOUT_US,
261+
false,
262+
cs35l56_base->regmap, reg, &val);
263+
264+
if (poll_ret) {
265+
dev_err(cs35l56_base->dev, "Firmware boot timed out(%d): HALO_STATE=%#x\n",
266+
read_ret, val);
266267
return -EIO;
267268
}
268269

0 commit comments

Comments
 (0)