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

Commit 239fe55c authored by Peter Ujfalusi's avatar Peter Ujfalusi Committed by Liam Girdwood
Browse files

ASoC: tlv320dac33: Revised module loading, and DAC33 ID read



Optimize the way how tlv320dac33 is powered uppon module and
soc initialization.
Also read the DAC33 ID registers, and update the reg_cache
to reflect it.

Signed-off-by: default avatarPeter Ujfalusi <peter.ujfalusi@nokia.com>
Acked-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: default avatarLiam Girdwood <lrg@slimlogic.co.uk>
parent ef909d67
Loading
Loading
Loading
Loading
+18 −19
Original line number Original line Diff line number Diff line
@@ -329,6 +329,15 @@ static void dac33_init_chip(struct snd_soc_codec *codec)
		    dac33_read_reg_cache(codec, DAC33_LINER_TO_RLO_VOL));
		    dac33_read_reg_cache(codec, DAC33_LINER_TO_RLO_VOL));
}
}


static inline void dac33_read_id(struct snd_soc_codec *codec)
{
	u8 reg;

	dac33_read(codec, DAC33_DEVICE_ID_MSB, &reg);
	dac33_read(codec, DAC33_DEVICE_ID_LSB, &reg);
	dac33_read(codec, DAC33_DEVICE_REV_ID, &reg);
}

static inline void dac33_soft_power(struct snd_soc_codec *codec, int power)
static inline void dac33_soft_power(struct snd_soc_codec *codec, int power)
{
{
	u8 reg;
	u8 reg;
@@ -1285,9 +1294,6 @@ static int dac33_soc_probe(struct platform_device *pdev)
	socdev->card->codec = codec;
	socdev->card->codec = codec;
	dac33 = snd_soc_codec_get_drvdata(codec);
	dac33 = snd_soc_codec_get_drvdata(codec);


	/* Power up the codec */
	dac33_hard_power(codec, 1);

	/* register pcms */
	/* register pcms */
	ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
	ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
	if (ret < 0) {
	if (ret < 0) {
@@ -1307,9 +1313,6 @@ static int dac33_soc_probe(struct platform_device *pdev)
	/* power on device */
	/* power on device */
	dac33_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
	dac33_set_bias_level(codec, SND_SOC_BIAS_STANDBY);


	/* Bias level configuration has enabled regulator an extra time */
	regulator_bulk_disable(ARRAY_SIZE(dac33->supplies), dac33->supplies);

	return 0;
	return 0;


pcm_err:
pcm_err:
@@ -1459,8 +1462,6 @@ static int __devinit dac33_i2c_probe(struct i2c_client *client,
			goto error_gpio;
			goto error_gpio;
		}
		}
		gpio_direction_output(dac33->power_gpio, 0);
		gpio_direction_output(dac33->power_gpio, 0);
	} else {
		dac33->chip_power = 1;
	}
	}


	/* Check if the IRQ number is valid and request it */
	/* Check if the IRQ number is valid and request it */
@@ -1498,12 +1499,14 @@ static int __devinit dac33_i2c_probe(struct i2c_client *client,
		goto err_get;
		goto err_get;
	}
	}


	ret = regulator_bulk_enable(ARRAY_SIZE(dac33->supplies),
	/* Read the tlv320dac33 ID registers */
				    dac33->supplies);
	ret = dac33_hard_power(codec, 1);
	if (ret != 0) {
	if (ret != 0) {
		dev_err(codec->dev, "Failed to enable supplies: %d\n", ret);
		dev_err(codec->dev, "Failed to power up codec: %d\n", ret);
		goto err_enable;
		goto error_codec;
	}
	}
	dac33_read_id(codec);
	dac33_hard_power(codec, 0);


	ret = snd_soc_register_codec(codec);
	ret = snd_soc_register_codec(codec);
	if (ret != 0) {
	if (ret != 0) {
@@ -1518,14 +1521,9 @@ static int __devinit dac33_i2c_probe(struct i2c_client *client,
		goto error_codec;
		goto error_codec;
	}
	}


	/* Shut down the codec for now */
	dac33_hard_power(codec, 0);

	return ret;
	return ret;


error_codec:
error_codec:
	regulator_bulk_disable(ARRAY_SIZE(dac33->supplies), dac33->supplies);
err_enable:
	regulator_bulk_free(ARRAY_SIZE(dac33->supplies), dac33->supplies);
	regulator_bulk_free(ARRAY_SIZE(dac33->supplies), dac33->supplies);
err_get:
err_get:
	if (dac33->irq >= 0) {
	if (dac33->irq >= 0) {
@@ -1549,6 +1547,8 @@ static int __devexit dac33_i2c_remove(struct i2c_client *client)
	struct tlv320dac33_priv *dac33;
	struct tlv320dac33_priv *dac33;


	dac33 = i2c_get_clientdata(client);
	dac33 = i2c_get_clientdata(client);

	if (unlikely(dac33->chip_power))
		dac33_hard_power(&dac33->codec, 0);
		dac33_hard_power(&dac33->codec, 0);


	if (dac33->power_gpio >= 0)
	if (dac33->power_gpio >= 0)
@@ -1556,7 +1556,6 @@ static int __devexit dac33_i2c_remove(struct i2c_client *client)
	if (dac33->irq >= 0)
	if (dac33->irq >= 0)
		free_irq(dac33->irq, &dac33->codec);
		free_irq(dac33->irq, &dac33->codec);


	regulator_bulk_disable(ARRAY_SIZE(dac33->supplies), dac33->supplies);
	regulator_bulk_free(ARRAY_SIZE(dac33->supplies), dac33->supplies);
	regulator_bulk_free(ARRAY_SIZE(dac33->supplies), dac33->supplies);


	destroy_workqueue(dac33->dac33_wq);
	destroy_workqueue(dac33->dac33_wq);