Merge remote-tracking branches 'asoc/topic/ad1980', 'asoc/topic/adsp', 'asoc/topic...
[linux-2.6-microblaze.git] / sound / soc / codecs / alc5623.c
index f500905..9d0755a 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>
@@ -998,8 +999,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);
@@ -1018,13 +1021,13 @@ static int alc5623_i2c_probe(struct i2c_client *client,
                dev_err(&client->dev, "failed to read vendor ID1: %d\n", ret);
                return ret;
        }
-       vid1 = ((vid1 & 0xff) << 8) | (vid1 >> 8);
 
        ret = regmap_read(alc5623->regmap, ALC5623_VENDOR_ID2, &vid2);
        if (ret < 0) {
                dev_err(&client->dev, "failed to read vendor ID2: %d\n", ret);
                return ret;
        }
+       vid2 >>= 8;
 
        if ((vid1 != 0x10ec) || (vid2 != id->driver_data)) {
                dev_err(&client->dev, "unknown or wrong codec\n");
@@ -1040,6 +1043,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 +1094,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,