]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
rt5639: add option for jack detection source
authorHarry Hong <hhong@nvidia.com>
Wed, 29 Jul 2015 04:56:52 +0000 (13:56 +0900)
committerDara Ramesh <dramesh@nvidia.com>
Thu, 6 Aug 2015 05:07:37 +0000 (22:07 -0700)
by default, only JD2 as jack detection source is available.
for other platforms using the different source, adding dt property,
sel_jd_source.

0 = OFF
1 = GPIO1
2 = JD1
3 = JD2
4 = GPIO2

Bug 200113589

Change-Id: Ic5ce3b1d6ddf8e238786072f140c4756d3c7640a
Signed-off-by: Harry Hong <hhong@nvidia.com>
Reviewed-on: http://git-master/r/776070
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Dara Ramesh <dramesh@nvidia.com>
sound/soc/codecs/rt5639.c
sound/soc/codecs/rt5639.h

index 21944cc0c81111988cfb12666c19a21d1c07134c..2302b0cbf3da3c975372c015e54f0ff058054764 100644 (file)
@@ -3,6 +3,7 @@
  *
  * Copyright (c) 2011-2015 REALTEK SEMICONDUCTOR CORP. All rights reserved.
  * Author: Johnny Hsu <johnnyhsu@realtek.com>
+ * Copyright (c) 2015, NVIDIA CORPORATION.  All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -17,6 +18,7 @@
 #include <linux/i2c.h>
 #include <linux/platform_device.h>
 #include <linux/spi/spi.h>
+#include <linux/of.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
@@ -3338,7 +3340,13 @@ static int rt5639_probe(struct snd_soc_codec *codec)
                        RT5639_JD1_IN4P_MASK | RT5639_JD2_IN4N_MASK,
                        RT5639_JD1_IN4P_EN | RT5639_JD2_IN4N_EN);
        }
+
        rt5639_reg_init(codec);
+
+       if (rt5639->sel_jd_source >= 0)
+               rt5639_soc_update_bits(codec, RT5639_JD_CTRL,
+                       RT5639_JD_MASK, rt5639->sel_jd_source << RT5639_JD_SFT);
+
        DC_Calibrate(codec);
        codec->dapm.bias_level = SND_SOC_BIAS_OFF;
        rt5639->codec = codec;
@@ -3500,6 +3508,8 @@ static int rt5639_i2c_probe(struct i2c_client *i2c,
 {
        struct rt5639_priv *rt5639;
        int ret;
+       struct device_node *np;
+       int jd_source;
 
        rt5639 = kzalloc(sizeof(struct rt5639_priv), GFP_KERNEL);
        if (NULL == rt5639)
@@ -3507,6 +3517,12 @@ static int rt5639_i2c_probe(struct i2c_client *i2c,
 
        i2c_set_clientdata(i2c, rt5639);
 
+       rt5639->sel_jd_source = -1;
+       if (i2c->dev.of_node) {
+               np = i2c->dev.of_node;
+               if (of_property_read_u32(np, "sel_jd_source", &jd_source) == 0)
+                       rt5639->sel_jd_source = jd_source;
+       }
        ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5639,
                        rt5639_dai, ARRAY_SIZE(rt5639_dai));
        if (ret < 0)
index 951efdf63bfafabed120ec547df28ed8551d7a9d..ecd9611dd7c7b0c6725966d9a1d3ac81d3dc1c91 100644 (file)
@@ -3,6 +3,7 @@
  *
  * Copyright (c) 2011-2013 REALTEK SEMICONDUCTOR CORP. All rights reserved.
  * Author: Johnny Hsu <johnnyhsu@realtek.com>
+ * Copyright (c) 2015, NVIDIA CORPORATION.  All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -2143,6 +2144,7 @@ struct rt5639_priv {
        unsigned int adb_reg_addr[0x100];
        unsigned int adb_reg_value[0x100];
        unsigned char adb_reg_num;
+       int sel_jd_source;
 };
 
 int rt5639_conn_mux_path(struct snd_soc_codec *codec,