summaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2013-05-30 12:38:27 +0100
committerMark Brown <broonie@opensource.wolfsonmicro.com>2013-05-30 12:38:27 +0100
commitd5d6f42671c10add2f58a2272351d9fbd4721322 (patch)
tree881d988345a0a0b04013e1375d2c1d339ba0bd85 /sound
parentf250a6a601d821c202c2f23de00f50acf1fa66f6 (diff)
parent04561eacaa6ccd1988e468cdcbf4acc475ae2221 (diff)
Merge remote-tracking branch 'asoc/topic/adau1701' into asoc-next
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/codecs/adau1701.c44
1 files changed, 39 insertions, 5 deletions
diff --git a/sound/soc/codecs/adau1701.c b/sound/soc/codecs/adau1701.c
index dafdbe87edeb..3fc176387351 100644
--- a/sound/soc/codecs/adau1701.c
+++ b/sound/soc/codecs/adau1701.c
@@ -13,6 +13,9 @@
#include <linux/i2c.h>
#include <linux/delay.h>
#include <linux/slab.h>
+#include <linux/of.h>
+#include <linux/of_gpio.h>
+#include <linux/of_device.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
@@ -180,9 +183,9 @@ static unsigned int adau1701_read(struct snd_soc_codec *codec, unsigned int reg)
return value;
}
-static int adau1701_load_firmware(struct snd_soc_codec *codec)
+static int adau1701_load_firmware(struct i2c_client *client)
{
- return process_sigma_firmware(codec->control_data, ADAU1701_FIRMWARE);
+ return process_sigma_firmware(client, ADAU1701_FIRMWARE);
}
static int adau1701_set_capture_pcm_format(struct snd_soc_codec *codec,
@@ -452,13 +455,22 @@ static struct snd_soc_dai_driver adau1701_dai = {
.symmetric_rates = 1,
};
+#ifdef CONFIG_OF
+static const struct of_device_id adau1701_dt_ids[] = {
+ { .compatible = "adi,adau1701", },
+ { }
+};
+MODULE_DEVICE_TABLE(of, adau1701_dt_ids);
+#endif
+
static int adau1701_probe(struct snd_soc_codec *codec)
{
int ret;
+ struct i2c_client *client = to_i2c_client(codec->dev);
- codec->control_data = to_i2c_client(codec->dev);
+ codec->control_data = client;
- ret = adau1701_load_firmware(codec);
+ ret = adau1701_load_firmware(client);
if (ret)
dev_warn(codec->dev, "Failed to load firmware\n");
@@ -493,12 +505,33 @@ static int adau1701_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct adau1701 *adau1701;
+ struct device *dev = &client->dev;
+ int gpio_nreset = -EINVAL;
int ret;
- adau1701 = devm_kzalloc(&client->dev, sizeof(*adau1701), GFP_KERNEL);
+ adau1701 = devm_kzalloc(dev, sizeof(*adau1701), GFP_KERNEL);
if (!adau1701)
return -ENOMEM;
+ if (dev->of_node) {
+ gpio_nreset = of_get_named_gpio(dev->of_node, "reset-gpio", 0);
+ if (gpio_nreset < 0 && gpio_nreset != -ENOENT)
+ return gpio_nreset;
+ }
+
+ if (gpio_is_valid(gpio_nreset)) {
+ ret = devm_gpio_request_one(dev, gpio_nreset, GPIOF_OUT_INIT_LOW,
+ "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);
+ }
+
i2c_set_clientdata(client, adau1701);
ret = snd_soc_register_codec(&client->dev, &adau1701_codec_drv,
&adau1701_dai, 1);
@@ -521,6 +554,7 @@ static struct i2c_driver adau1701_i2c_driver = {
.driver = {
.name = "adau1701",
.owner = THIS_MODULE,
+ .of_match_table = of_match_ptr(adau1701_dt_ids),
},
.probe = adau1701_i2c_probe,
.remove = adau1701_i2c_remove,