summaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/sgtl5000.c
diff options
context:
space:
mode:
authorFabio Estevam <fabio.estevam@freescale.com>2013-05-09 21:15:47 -0300
committerMark Brown <broonie@opensource.wolfsonmicro.com>2013-05-12 20:50:02 +0400
commitaf8ee11209e749c75eabf32b2a4ca631f396acf8 (patch)
tree488b9ca686b984d92611e18b50c724f177679723 /sound/soc/codecs/sgtl5000.c
parentb871f1ad3c8a1ac2fb862f9261f14a67dc2c7b7d (diff)
downloadlinux-af8ee11209e749c75eabf32b2a4ca631f396acf8.tar.bz2
ASoC: sgtl5000: Fix driver probe after reset
After a 'reboot' command in Linux or after pressing the system's reset button the sgtl5000 driver fails to probe: sgtl5000 0-000a: Device with ID register ffff is not a sgtl5000 sgtl5000 0-000a: ASoC: failed to probe CODEC -19 imx-sgtl5000 sound.12: ASoC: failed to instantiate card -19 imx-sgtl5000 sound.12: snd_soc_register_card failed (-19) sgtl5000 codec does not have a reset line, nor a reset command in software, so after a system reset the codec does not contain the default register values from sgtl5000_reg_defaults[] anymore, as these are only valid after a power-on-reset cycle. Fix this issue by explicitly reading all the reset register values from sgtl5000_reg_defaults[] and writing them back into sgtl5000 to ensure a sane state. Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Tested-by: Eric Nelson <eric.nelson@boundarydevices.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/codecs/sgtl5000.c')
-rw-r--r--sound/soc/codecs/sgtl5000.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c
index 1ab356ab0f31..1c3b20fc7ec3 100644
--- a/sound/soc/codecs/sgtl5000.c
+++ b/sound/soc/codecs/sgtl5000.c
@@ -1468,6 +1468,31 @@ static const struct regmap_config sgtl5000_regmap = {
.num_reg_defaults = ARRAY_SIZE(sgtl5000_reg_defaults),
};
+/*
+ * Write all the default values from sgtl5000_reg_defaults[] array into the
+ * sgtl5000 registers, to make sure we always start with the sane registers
+ * values as stated in the datasheet.
+ *
+ * Since sgtl5000 does not have a reset line, nor a reset command in software,
+ * we follow this approach to guarantee we always start from the default values
+ * and avoid problems like, not being able to probe after an audio playback
+ * followed by a system reset or a 'reboot' command in Linux
+ */
+static int sgtl5000_fill_defaults(struct sgtl5000_priv *sgtl5000)
+{
+ int i, ret, val, index;
+
+ for (i = 0; i < ARRAY_SIZE(sgtl5000_reg_defaults); i++) {
+ val = sgtl5000_reg_defaults[i].def;
+ index = sgtl5000_reg_defaults[i].reg;
+ ret = regmap_write(sgtl5000->regmap, index, val);
+ if (ret)
+ return ret;
+ }
+
+ return 0;
+}
+
static int sgtl5000_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
@@ -1503,6 +1528,11 @@ static int sgtl5000_i2c_probe(struct i2c_client *client,
i2c_set_clientdata(client, sgtl5000);
+ /* Ensure sgtl5000 will start with sane register values */
+ ret = sgtl5000_fill_defaults(sgtl5000);
+ if (ret)
+ return ret;
+
ret = snd_soc_register_codec(&client->dev,
&sgtl5000_driver, &sgtl5000_dai, 1);
return ret;