From: Lars-Peter Clausen <lars@metafoo.de>
To: Daniel Mack <zonque@gmail.com>
Cc: alsa-devel@alsa-project.org, broonie@kernel.org
Subject: Re: [PATCH 1/4] ASoC: codecs: adau1701: factor out firmware reset
Date: Mon, 10 Jun 2013 15:08:24 +0200 [thread overview]
Message-ID: <51B5CFC8.3060608@metafoo.de> (raw)
In-Reply-To: <1370605987-19290-2-git-send-email-zonque@gmail.com>
On 06/07/2013 01:53 PM, Daniel Mack wrote:
> Some runtime-determined constraints might need to be satisfied prior to
> firmware loading, so the actual download and releasing the device from
> reset has to be postponed. Factor it out first, so we have everything at
> one place.
>
> This also changes the behaviour in a way that adau1701_i2c_probe() will
> assert the reset line, and wait for the codec probe to release it.
>
> Signed-off-by: Daniel Mack <zonque@gmail.com>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Thanks.
> ---
> sound/soc/codecs/adau1701.c | 49 +++++++++++++++++++++++++++++++++------------
> 1 file changed, 36 insertions(+), 13 deletions(-)
>
> diff --git a/sound/soc/codecs/adau1701.c b/sound/soc/codecs/adau1701.c
> index 3fc1763..b6b1a77 100644
> --- a/sound/soc/codecs/adau1701.c
> +++ b/sound/soc/codecs/adau1701.c
> @@ -90,6 +90,7 @@
> #define ADAU1701_FIRMWARE "adau1701.bin"
>
> struct adau1701 {
> + int gpio_nreset;
> unsigned int dai_fmt;
> };
>
> @@ -183,9 +184,37 @@ static unsigned int adau1701_read(struct snd_soc_codec *codec, unsigned int reg)
> return value;
> }
>
> -static int adau1701_load_firmware(struct i2c_client *client)
> +static void adau1701_reset(struct snd_soc_codec *codec)
> {
> - return process_sigma_firmware(client, ADAU1701_FIRMWARE);
> + struct adau1701 *adau1701 = snd_soc_codec_get_drvdata(codec);
> +
> + if (!gpio_is_valid(adau1701->gpio_nreset))
> + return;
> +
> + gpio_set_value(adau1701->gpio_nreset, 0);
> + /* minimum reset time is 20ns */
> + udelay(1);
> + gpio_set_value(adau1701->gpio_nreset, 1);
> + /* power-up time may be as long as 85ms */
> + mdelay(85);
> +}
> +
> +static int adau1701_init(struct snd_soc_codec *codec)
> +{
> + int ret;
> + struct i2c_client *client = to_i2c_client(codec->dev);
> +
> + adau1701_reset(codec);
> +
> + ret = process_sigma_firmware(client, ADAU1701_FIRMWARE);
> + if (ret) {
> + dev_warn(codec->dev, "Failed to load firmware\n");
> + return ret;
> + }
> +
> + snd_soc_write(codec, ADAU1701_DACSET, ADAU1701_DACSET_DACINIT);
> +
> + return 0;
> }
>
> static int adau1701_set_capture_pcm_format(struct snd_soc_codec *codec,
> @@ -466,15 +495,13 @@ MODULE_DEVICE_TABLE(of, adau1701_dt_ids);
> static int adau1701_probe(struct snd_soc_codec *codec)
> {
> int ret;
> - struct i2c_client *client = to_i2c_client(codec->dev);
>
> - codec->control_data = client;
> + codec->control_data = to_i2c_client(codec->dev);
>
> - ret = adau1701_load_firmware(client);
> + ret = adau1701_init(codec);
> if (ret)
> - dev_warn(codec->dev, "Failed to load firmware\n");
> + return ret;
>
> - snd_soc_write(codec, ADAU1701_DACSET, ADAU1701_DACSET_DACINIT);
> snd_soc_write(codec, ADAU1701_DSPCTRL, ADAU1701_DSPCTRL_CR);
>
> return 0;
> @@ -524,14 +551,10 @@ static int adau1701_i2c_probe(struct i2c_client *client,
> "ADAU1701 Reset");
> if (ret < 0)
> return ret;
> -
> - /* minimum reset time is 20ns */
> - udelay(1);
> - gpio_set_value(gpio_nreset, 1);
> - /* power-up time may be as long as 85ms */
> - mdelay(85);
> }
>
> + adau1701->gpio_nreset = gpio_nreset;
> +
> i2c_set_clientdata(client, adau1701);
> ret = snd_soc_register_codec(&client->dev, &adau1701_codec_drv,
> &adau1701_dai, 1);
next prev parent reply other threads:[~2013-06-10 13:08 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-07 11:53 [PATCH 0/4] ASoC: codecs: some more improvements for adau1701 Daniel Mack
2013-06-07 11:53 ` [PATCH 1/4] ASoC: codecs: adau1701: factor out firmware reset Daniel Mack
2013-06-10 13:08 ` Lars-Peter Clausen [this message]
2013-06-10 13:09 ` Mark Brown
2013-06-07 11:53 ` [PATCH 2/4] ASoC: codecs: adau1701: allow configuration of PLL mode pins Daniel Mack
2013-06-09 17:12 ` Lars-Peter Clausen
2013-06-07 11:53 ` [PATCH 3/4] ASoC: codecs: adau1701: switch to direct regmap API usage Daniel Mack
2013-06-09 17:39 ` Lars-Peter Clausen
2013-06-07 11:53 ` [PATCH 4/4] ASoC: codecs: adau1701: add support for pin muxing Daniel Mack
2013-06-09 17:43 ` Lars-Peter Clausen
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=51B5CFC8.3060608@metafoo.de \
--to=lars@metafoo.de \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=zonque@gmail.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.