aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sound/soc/codecs/adau1701.c49
1 files changed, 36 insertions, 13 deletions
diff --git a/sound/soc/codecs/adau1701.c b/sound/soc/codecs/adau1701.c
index 3fc176387351..b6b1a773bd37 100644
--- a/sound/soc/codecs/adau1701.c
+++ b/sound/soc/codecs/adau1701.c
@@ -90,6 +90,7 @@
90#define ADAU1701_FIRMWARE "adau1701.bin" 90#define ADAU1701_FIRMWARE "adau1701.bin"
91 91
92struct adau1701 { 92struct adau1701 {
93 int gpio_nreset;
93 unsigned int dai_fmt; 94 unsigned int dai_fmt;
94}; 95};
95 96
@@ -183,9 +184,37 @@ static unsigned int adau1701_read(struct snd_soc_codec *codec, unsigned int reg)
183 return value; 184 return value;
184} 185}
185 186
186static int adau1701_load_firmware(struct i2c_client *client) 187static void adau1701_reset(struct snd_soc_codec *codec)
187{ 188{
188 return process_sigma_firmware(client, ADAU1701_FIRMWARE); 189 struct adau1701 *adau1701 = snd_soc_codec_get_drvdata(codec);
190
191 if (!gpio_is_valid(adau1701->gpio_nreset))
192 return;
193
194 gpio_set_value(adau1701->gpio_nreset, 0);
195 /* minimum reset time is 20ns */
196 udelay(1);
197 gpio_set_value(adau1701->gpio_nreset, 1);
198 /* power-up time may be as long as 85ms */
199 mdelay(85);
200}
201
202static int adau1701_init(struct snd_soc_codec *codec)
203{
204 int ret;
205 struct i2c_client *client = to_i2c_client(codec->dev);
206
207 adau1701_reset(codec);
208
209 ret = process_sigma_firmware(client, ADAU1701_FIRMWARE);
210 if (ret) {
211 dev_warn(codec->dev, "Failed to load firmware\n");
212 return ret;
213 }
214
215 snd_soc_write(codec, ADAU1701_DACSET, ADAU1701_DACSET_DACINIT);
216
217 return 0;
189} 218}
190 219
191static int adau1701_set_capture_pcm_format(struct snd_soc_codec *codec, 220static int adau1701_set_capture_pcm_format(struct snd_soc_codec *codec,
@@ -466,15 +495,13 @@ MODULE_DEVICE_TABLE(of, adau1701_dt_ids);
466static int adau1701_probe(struct snd_soc_codec *codec) 495static int adau1701_probe(struct snd_soc_codec *codec)
467{ 496{
468 int ret; 497 int ret;
469 struct i2c_client *client = to_i2c_client(codec->dev);
470 498
471 codec->control_data = client; 499 codec->control_data = to_i2c_client(codec->dev);
472 500
473 ret = adau1701_load_firmware(client); 501 ret = adau1701_init(codec);
474 if (ret) 502 if (ret)
475 dev_warn(codec->dev, "Failed to load firmware\n"); 503 return ret;
476 504
477 snd_soc_write(codec, ADAU1701_DACSET, ADAU1701_DACSET_DACINIT);
478 snd_soc_write(codec, ADAU1701_DSPCTRL, ADAU1701_DSPCTRL_CR); 505 snd_soc_write(codec, ADAU1701_DSPCTRL, ADAU1701_DSPCTRL_CR);
479 506
480 return 0; 507 return 0;
@@ -524,14 +551,10 @@ static int adau1701_i2c_probe(struct i2c_client *client,
524 "ADAU1701 Reset"); 551 "ADAU1701 Reset");
525 if (ret < 0) 552 if (ret < 0)
526 return ret; 553 return ret;
527
528 /* minimum reset time is 20ns */
529 udelay(1);
530 gpio_set_value(gpio_nreset, 1);
531 /* power-up time may be as long as 85ms */
532 mdelay(85);
533 } 554 }
534 555
556 adau1701->gpio_nreset = gpio_nreset;
557
535 i2c_set_clientdata(client, adau1701); 558 i2c_set_clientdata(client, adau1701);
536 ret = snd_soc_register_codec(&client->dev, &adau1701_codec_drv, 559 ret = snd_soc_register_codec(&client->dev, &adau1701_codec_drv,
537 &adau1701_dai, 1); 560 &adau1701_dai, 1);