#define ADAU1701_FIRMWARE "adau1701.bin"
struct adau1701 {
+ int gpio_nreset;
unsigned int dai_fmt;
};
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,
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;
"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);