ASoC: wm8962: Replace w->codec snd_soc_dapm_to_codec(w->dapm)
[deliverable/linux.git] / sound / soc / codecs / alc5623.c
index 2acf82f4a08a8bed4db26c6c444a0eabec688412..bdf8c5ac8ca460b8e07310674f90109cc6e6965a 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/i2c.h>
 #include <linux/regmap.h>
 #include <linux/slab.h>
+#include <linux/of.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
@@ -865,7 +866,6 @@ static int alc5623_suspend(struct snd_soc_codec *codec)
 {
        struct alc5623_priv *alc5623 = snd_soc_codec_get_drvdata(codec);
 
-       alc5623_set_bias_level(codec, SND_SOC_BIAS_OFF);
        regcache_cache_only(alc5623->regmap, true);
 
        return 0;
@@ -886,15 +886,6 @@ static int alc5623_resume(struct snd_soc_codec *codec)
                return ret;
        }
 
-       alc5623_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
-
-       /* charge alc5623 caps */
-       if (codec->dapm.suspend_bias_level == SND_SOC_BIAS_ON) {
-               alc5623_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
-               codec->dapm.bias_level = SND_SOC_BIAS_ON;
-               alc5623_set_bias_level(codec, codec->dapm.bias_level);
-       }
-
        return 0;
 }
 
@@ -905,9 +896,6 @@ static int alc5623_probe(struct snd_soc_codec *codec)
 
        alc5623_reset(codec);
 
-       /* power on device */
-       alc5623_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
-
        if (alc5623->add_ctrl) {
                snd_soc_write(codec, ALC5623_ADD_CTRL_REG,
                                alc5623->add_ctrl);
@@ -963,19 +951,12 @@ static int alc5623_probe(struct snd_soc_codec *codec)
        return 0;
 }
 
-/* power down chip */
-static int alc5623_remove(struct snd_soc_codec *codec)
-{
-       alc5623_set_bias_level(codec, SND_SOC_BIAS_OFF);
-       return 0;
-}
-
 static struct snd_soc_codec_driver soc_codec_device_alc5623 = {
        .probe = alc5623_probe,
-       .remove = alc5623_remove,
        .suspend = alc5623_suspend,
        .resume = alc5623_resume,
        .set_bias_level = alc5623_set_bias_level,
+       .suspend_bias_off = true,
 };
 
 static const struct regmap_config alc5623_regmap = {
@@ -998,8 +979,10 @@ static int alc5623_i2c_probe(struct i2c_client *client,
 {
        struct alc5623_platform_data *pdata;
        struct alc5623_priv *alc5623;
+       struct device_node *np;
        unsigned int vid1, vid2;
        int ret;
+       u32 val32;
 
        alc5623 = devm_kzalloc(&client->dev, sizeof(struct alc5623_priv),
                               GFP_KERNEL);
@@ -1040,6 +1023,16 @@ static int alc5623_i2c_probe(struct i2c_client *client,
        if (pdata) {
                alc5623->add_ctrl = pdata->add_ctrl;
                alc5623->jack_det_ctrl = pdata->jack_det_ctrl;
+       } else {
+               if (client->dev.of_node) {
+                       np = client->dev.of_node;
+                       ret = of_property_read_u32(np, "add-ctrl", &val32);
+                       if (!ret)
+                               alc5623->add_ctrl = val32;
+                       ret = of_property_read_u32(np, "jack-det-ctrl", &val32);
+                       if (!ret)
+                               alc5623->jack_det_ctrl = val32;
+               }
        }
 
        alc5623->id = vid2;
@@ -1081,11 +1074,18 @@ static const struct i2c_device_id alc5623_i2c_table[] = {
 };
 MODULE_DEVICE_TABLE(i2c, alc5623_i2c_table);
 
+static const struct of_device_id alc5623_of_match[] = {
+       { .compatible = "realtek,alc5623", },
+       { }
+};
+MODULE_DEVICE_TABLE(of, alc5623_of_match);
+
 /*  i2c codec control layer */
 static struct i2c_driver alc5623_i2c_driver = {
        .driver = {
                .name = "alc562x-codec",
                .owner = THIS_MODULE,
+               .of_match_table = of_match_ptr(alc5623_of_match),
        },
        .probe = alc5623_i2c_probe,
        .remove =  alc5623_i2c_remove,
This page took 0.031456 seconds and 5 git commands to generate.