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

Commit 1479c3fb authored by Mark Brown's avatar Mark Brown
Browse files

ASoC: Handle spurious wm_hubs DC servo done interrupts



Don't assume the first fire indicates that we're done.

Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent 6b3860b0
Loading
Loading
Loading
Loading
+16 −14
Original line number Original line Diff line number Diff line
@@ -66,8 +66,8 @@ static void wait_for_dc_servo(struct snd_soc_codec *codec, unsigned int op)
	struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec);
	struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec);
	unsigned int reg;
	unsigned int reg;
	int count = 0;
	int count = 0;
	int timeout;
	unsigned int val;
	unsigned int val;
	unsigned long timeout;


	val = op | WM8993_DCS_ENA_CHAN_0 | WM8993_DCS_ENA_CHAN_1;
	val = op | WM8993_DCS_ENA_CHAN_0 | WM8993_DCS_ENA_CHAN_1;


@@ -76,21 +76,23 @@ static void wait_for_dc_servo(struct snd_soc_codec *codec, unsigned int op)


	dev_dbg(codec->dev, "Waiting for DC servo...\n");
	dev_dbg(codec->dev, "Waiting for DC servo...\n");


	if (hubs->dcs_done_irq) {
	if (hubs->dcs_done_irq)
		timeout = wait_for_completion_timeout(&hubs->dcs_done,
		timeout = 4;
						      msecs_to_jiffies(500));
	else
		if (timeout == 0)
		timeout = 400;
			dev_warn(codec->dev, "No DC servo interrupt\n");


		reg = snd_soc_read(codec, WM8993_DC_SERVO_0);
	} else {
	do {
	do {
		count++;
		count++;

		if (hubs->dcs_done_irq)
			wait_for_completion_timeout(&hubs->dcs_done,
						    msecs_to_jiffies(250));
		else
			msleep(1);
			msleep(1);

		reg = snd_soc_read(codec, WM8993_DC_SERVO_0);
		reg = snd_soc_read(codec, WM8993_DC_SERVO_0);
		dev_dbg(codec->dev, "DC servo: %x\n", reg);
		dev_dbg(codec->dev, "DC servo: %x\n", reg);
		} while (reg & op && count < 400);
	} while (reg & op && count < timeout);
	}


	if (reg & op)
	if (reg & op)
		dev_err(codec->dev, "Timed out waiting for DC Servo %x\n",
		dev_err(codec->dev, "Timed out waiting for DC Servo %x\n",