From: yj Date: Tue, 25 Mar 2014 04:16:02 +0000 (+0800) Subject: rt5631: add phone_det_level for phone detect X-Git-Tag: firefly_0821_release~5856 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=038787e7fd58bba4d3c7a338aa775e2e0bc00eb8;p=firefly-linux-kernel-4.4.55.git rt5631: add phone_det_level for phone detect --- diff --git a/sound/soc/codecs/rt5631.c b/sound/soc/codecs/rt5631.c index dc691fcbcdd1..3527e97626de 100755 --- a/sound/soc/codecs/rt5631.c +++ b/sound/soc/codecs/rt5631.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -53,6 +54,7 @@ struct rt5631_priv { int sysclk; int dmic_used_flag; int eq_mode; + int phone_det_level; int pll_used_flag; }; #if (RT5631_SPK_TIMER == 1) @@ -217,7 +219,7 @@ static struct rt5631_init_reg init_list[] = { {RT5631_MIC_CTRL_1 , 0x8000},//set mic 1 to differnetial mode {RT5631_GPIO_CTRL , 0x0000},//set GPIO to input pin // {RT5631_JACK_DET_CTRL , 0x4e80},//Jack detect for GPIO,high is HP,low is speaker - {RT5631_JACK_DET_CTRL , 0x4bc0},//Jack detect for GPIO,high is speaker,low is hp +// {RT5631_JACK_DET_CTRL , 0x4bc0},//Jack detect for GPIO,high is speaker,low is hp }; #define RT5631_INIT_REG_LEN ARRAY_SIZE(init_list) @@ -2005,6 +2007,10 @@ static int rt5631_probe(struct snd_soc_codec *codec) rt5631_write_mask(codec, RT5631_PWR_MANAG_ADD3, PWR_FAST_VREF_CTRL, PWR_FAST_VREF_CTRL); rt5631_reg_init(codec); + if (rt5631->phone_det_level == 1) + rt5631_write(codec, RT5631_JACK_DET_CTRL,0x4e80); + else + rt5631_write(codec, RT5631_JACK_DET_CTRL,0x4bc0); /* power off ClassD auto Recovery */ if (rt5631->codec_version) @@ -2140,14 +2146,22 @@ static int rt5631_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct rt5631_priv *rt5631; + struct device_node *node = i2c->dev.of_node; int ret; printk("RT5631 Audio Codec %s\n", RT5631_VERSION); rt5631 = kzalloc(sizeof(struct rt5631_priv), GFP_KERNEL); if (NULL == rt5631) - return -ENOMEM; + return -ENOMEM; +#ifdef CONFIG_OF + ret = of_property_read_u32(node,"phone_det_level",&rt5631->phone_det_level); + if (ret < 0) + printk("%s get phone_det_level error\n",__func__); + else + printk("RT5631 codec: phone_det_level %s",rt5631->phone_det_level ? "HIGH":"LOW"); +#endif i2c_set_clientdata(i2c, rt5631); ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5631,