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

ASoC: ad1980: Use core AC'97 reset helper

Use the new snd_ac97_reset() helper function to perform the reset and
verify the device ID.

Unfortunately the reset can't be done in snd_soc_new_ac97_codec() due to
the special requirements in order to support the non-standard 16-bit slot
mode of the ad1980.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Lars-Peter Clausen and committed by
Mark Brown
3ab3dbdf 7361fbea

+11 -23
+11 -23
sound/soc/codecs/ad1980.c
··· 202 202 .formats = SND_SOC_STD_AC97_FMTS, }, 203 203 }; 204 204 205 + #define AD1980_VENDOR_ID 0x41445300 206 + #define AD1980_VENDOR_MASK 0xffffff00 207 + 205 208 static int ad1980_reset(struct snd_soc_codec *codec, int try_warm) 206 209 { 207 210 struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec); 208 211 unsigned int retry_cnt = 0; 212 + int ret; 209 213 210 214 do { 211 - if (try_warm && soc_ac97_ops->warm_reset) { 212 - soc_ac97_ops->warm_reset(ac97); 213 - if (snd_soc_read(codec, AC97_RESET) == 0x0090) 214 - return 1; 215 - } 215 + ret = snd_ac97_reset(ac97, true, AD1980_VENDOR_ID, 216 + AD1980_VENDOR_MASK); 217 + if (ret >= 0) 218 + return 0; 216 219 217 - soc_ac97_ops->reset(ac97); 218 220 /* 219 221 * Set bit 16slot in register 74h, then every slot will has only 220 222 * 16 bits. This command is sent out in 20bit mode, in which ··· 225 223 */ 226 224 snd_soc_write(codec, AC97_AD_SERIAL_CFG, 0x9900); 227 225 228 - if (snd_soc_read(codec, AC97_RESET) == 0x0090) 229 - return 0; 230 226 } while (retry_cnt++ < 10); 231 227 232 228 dev_err(codec->dev, "Failed to reset: AC97 link error\n"); ··· 260 260 if (ret < 0) 261 261 goto reset_err; 262 262 263 - /* Read out vendor ID to make sure it is ad1980 */ 264 - if (snd_soc_read(codec, AC97_VENDOR_ID1) != 0x4144) { 265 - ret = -ENODEV; 266 - goto reset_err; 267 - } 268 - 269 263 vendor_id2 = snd_soc_read(codec, AC97_VENDOR_ID2); 270 - 271 - if (vendor_id2 != 0x5370) { 272 - if (vendor_id2 != 0x5374) { 273 - ret = -ENODEV; 274 - goto reset_err; 275 - } else { 276 - dev_warn(codec->dev, 277 - "Found AD1981 - only 2/2 IN/OUT Channels supported\n"); 278 - } 264 + if (vendor_id2 == 0x5374) { 265 + dev_warn(codec->dev, 266 + "Found AD1981 - only 2/2 IN/OUT Channels supported\n"); 279 267 } 280 268 281 269 /* unmute captures and playbacks volume */