Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: rt5677: Wait for DSP to boot before loading firmware

Wait for hardware to startup. If we load before hardware is ready we
could end up corrupting the firmware.

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
Link: https://lore.kernel.org/r/20191106011335.223061-12-cujomalainey@chromium.org
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Curtis Malainey and committed by
Mark Brown
9da776ba ba0b3a97

+13
+13
sound/soc/codecs/rt5677.c
··· 892 892 container_of(work, struct rt5677_priv, dsp_work.work); 893 893 static bool activity; 894 894 bool enable = rt5677->dsp_vad_en; 895 + int i, val; 895 896 896 897 897 898 dev_info(rt5677->component->dev, "DSP VAD: enable=%d, activity=%d\n", ··· 913 912 914 913 rt5677_set_vad_source(rt5677); 915 914 rt5677_set_dsp_mode(rt5677, true); 915 + 916 + #define RT5677_BOOT_RETRY 20 917 + for (i = 0; i < RT5677_BOOT_RETRY; i++) { 918 + regmap_read(rt5677->regmap, RT5677_PWR_DSP_ST, &val); 919 + if (val == 0x3ff) 920 + break; 921 + udelay(500); 922 + } 923 + if (i == RT5677_BOOT_RETRY && val != 0x3ff) { 924 + dev_err(rt5677->component->dev, "DSP Boot Timed Out!"); 925 + return; 926 + } 916 927 917 928 /* Boot the firmware from IRAM instead of SRAM0. */ 918 929 rt5677_dsp_mode_i2c_write_addr(rt5677, RT5677_DSP_BOOT_VECTOR,