Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3ab3dbdf authored by Lars-Peter Clausen's avatar Lars-Peter Clausen Committed by Mark Brown
Browse files

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: default avatarLars-Peter Clausen <lars@metafoo.de>
Reviewed-by: default avatarTakashi Iwai <tiwai@suse.de>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 7361fbea
Loading
Loading
Loading
Loading
+11 −23
Original line number Original line Diff line number Diff line
@@ -202,19 +202,21 @@ static struct snd_soc_dai_driver ad1980_dai = {
		.formats = SND_SOC_STD_AC97_FMTS, },
		.formats = SND_SOC_STD_AC97_FMTS, },
};
};


#define AD1980_VENDOR_ID 0x41445300
#define AD1980_VENDOR_MASK 0xffffff00

static int ad1980_reset(struct snd_soc_codec *codec, int try_warm)
static int ad1980_reset(struct snd_soc_codec *codec, int try_warm)
{
{
	struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec);
	struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec);
	unsigned int retry_cnt = 0;
	unsigned int retry_cnt = 0;
	int ret;


	do {
	do {
		if (try_warm && soc_ac97_ops->warm_reset) {
		ret = snd_ac97_reset(ac97, true, AD1980_VENDOR_ID,
			soc_ac97_ops->warm_reset(ac97);
			AD1980_VENDOR_MASK);
			if (snd_soc_read(codec, AC97_RESET) == 0x0090)
		if (ret >= 0)
				return 1;
			return 0;
		}


		soc_ac97_ops->reset(ac97);
		/*
		/*
		 * Set bit 16slot in register 74h, then every slot will has only
		 * Set bit 16slot in register 74h, then every slot will has only
		 * 16 bits. This command is sent out in 20bit mode, in which
		 * 16 bits. This command is sent out in 20bit mode, in which
@@ -223,8 +225,6 @@ static int ad1980_reset(struct snd_soc_codec *codec, int try_warm)
		 */
		 */
		snd_soc_write(codec, AC97_AD_SERIAL_CFG, 0x9900);
		snd_soc_write(codec, AC97_AD_SERIAL_CFG, 0x9900);


		if (snd_soc_read(codec, AC97_RESET)  == 0x0090)
			return 0;
	} while (retry_cnt++ < 10);
	} while (retry_cnt++ < 10);


	dev_err(codec->dev, "Failed to reset: AC97 link error\n");
	dev_err(codec->dev, "Failed to reset: AC97 link error\n");
@@ -260,23 +260,11 @@ static int ad1980_soc_probe(struct snd_soc_codec *codec)
	if (ret < 0)
	if (ret < 0)
		goto reset_err;
		goto reset_err;


	/* Read out vendor ID to make sure it is ad1980 */
	if (snd_soc_read(codec, AC97_VENDOR_ID1) != 0x4144) {
		ret = -ENODEV;
		goto reset_err;
	}

	vendor_id2 = snd_soc_read(codec, AC97_VENDOR_ID2);
	vendor_id2 = snd_soc_read(codec, AC97_VENDOR_ID2);

	if (vendor_id2 == 0x5374) {
	if (vendor_id2 != 0x5370) {
		if (vendor_id2 != 0x5374) {
			ret = -ENODEV;
			goto reset_err;
		} else {
		dev_warn(codec->dev,
		dev_warn(codec->dev,
			"Found AD1981 - only 2/2 IN/OUT Channels supported\n");
			"Found AD1981 - only 2/2 IN/OUT Channels supported\n");
	}
	}
	}


	/* unmute captures and playbacks volume */
	/* unmute captures and playbacks volume */
	snd_soc_write(codec, AC97_MASTER, 0x0000);
	snd_soc_write(codec, AC97_MASTER, 0x0000);