From: Troy Kisky <troy.kisky@boundarydevices.com>
To: Fabio Estevam <festevam@gmail.com>
Cc: Fabio Estevam <fabio.estevam@freescale.com>,
alsa-devel@alsa-project.org, lars@metafoo.de,
matt@genesi-usa.com, eric.nelson@boundarydevices.com,
broonie@kernel.org
Subject: Re: [PATCH v4] ASoC: sgtl5000: Fix driver probe after reset
Date: Thu, 09 May 2013 16:13:56 -0700 [thread overview]
Message-ID: <518C2DB4.5000404@boundarydevices.com> (raw)
In-Reply-To: <1368140116-15289-1-git-send-email-festevam@gmail.com>
On 5/9/2013 3:55 PM, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@freescale.com>
>
> 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>
> ---
> Changes since v3:
> - Read sgtl5000_reg_defaults and write these values into sgtl5000
> Changes since v2:
> - Do not use reg_defaults_raw as it is not the correct purpose
> - Manually build sgtl5000_reg_default
> - Improve commitlog
> Changes since v1:
> - Remove sgtl5000_reg_defaults array
> - Do not use num_reg_defaults_raw
> sound/soc/codecs/sgtl5000.c | 30 ++++++++++++++++++++++++++++++
> 1 file changed, 30 insertions(+)
>
> diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c
> index 327b443..be23fce 100644
> --- a/sound/soc/codecs/sgtl5000.c
> +++ b/sound/soc/codecs/sgtl5000.c
> @@ -1474,6 +1474,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)
> {
> @@ -1494,6 +1519,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;
It seems strange to write all the registers before even verifying that
yes this is an SGTL5000.
Could you possibly write the 1 register that make SGTL5000_CHIP_ID read
correctly,
and write the others afterwards?
Troy
prev parent reply other threads:[~2013-05-09 23:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-09 22:55 [PATCH v4] ASoC: sgtl5000: Fix driver probe after reset Fabio Estevam
2013-05-09 23:13 ` Troy Kisky [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=518C2DB4.5000404@boundarydevices.com \
--to=troy.kisky@boundarydevices.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=eric.nelson@boundarydevices.com \
--cc=fabio.estevam@freescale.com \
--cc=festevam@gmail.com \
--cc=lars@metafoo.de \
--cc=matt@genesi-usa.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.