aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/rt5640.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/codecs/rt5640.c')
-rw-r--r--sound/soc/codecs/rt5640.c49
1 files changed, 30 insertions, 19 deletions
diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c
index f1ec6e6bd08a..c3f2decd643c 100644
--- a/sound/soc/codecs/rt5640.c
+++ b/sound/soc/codecs/rt5640.c
@@ -1906,6 +1906,32 @@ static int rt5640_set_bias_level(struct snd_soc_codec *codec,
1906 return 0; 1906 return 0;
1907} 1907}
1908 1908
1909int rt5640_dmic_enable(struct snd_soc_codec *codec,
1910 bool dmic1_data_pin, bool dmic2_data_pin)
1911{
1912 struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec);
1913
1914 regmap_update_bits(rt5640->regmap, RT5640_GPIO_CTRL1,
1915 RT5640_GP2_PIN_MASK, RT5640_GP2_PIN_DMIC1_SCL);
1916
1917 if (dmic1_data_pin) {
1918 regmap_update_bits(rt5640->regmap, RT5640_DMIC,
1919 RT5640_DMIC_1_DP_MASK, RT5640_DMIC_1_DP_GPIO3);
1920 regmap_update_bits(rt5640->regmap, RT5640_GPIO_CTRL1,
1921 RT5640_GP3_PIN_MASK, RT5640_GP3_PIN_DMIC1_SDA);
1922 }
1923
1924 if (dmic2_data_pin) {
1925 regmap_update_bits(rt5640->regmap, RT5640_DMIC,
1926 RT5640_DMIC_2_DP_MASK, RT5640_DMIC_2_DP_GPIO4);
1927 regmap_update_bits(rt5640->regmap, RT5640_GPIO_CTRL1,
1928 RT5640_GP4_PIN_MASK, RT5640_GP4_PIN_DMIC2_SDA);
1929 }
1930
1931 return 0;
1932}
1933EXPORT_SYMBOL_GPL(rt5640_dmic_enable);
1934
1909static int rt5640_probe(struct snd_soc_codec *codec) 1935static int rt5640_probe(struct snd_soc_codec *codec)
1910{ 1936{
1911 struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec); 1937 struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec);
@@ -1945,6 +1971,10 @@ static int rt5640_probe(struct snd_soc_codec *codec)
1945 return -ENODEV; 1971 return -ENODEV;
1946 } 1972 }
1947 1973
1974 if (rt5640->pdata.dmic_en)
1975 rt5640_dmic_enable(codec, rt5640->pdata.dmic1_data_pin,
1976 rt5640->pdata.dmic2_data_pin);
1977
1948 return 0; 1978 return 0;
1949} 1979}
1950 1980
@@ -2195,25 +2225,6 @@ static int rt5640_i2c_probe(struct i2c_client *i2c,
2195 regmap_update_bits(rt5640->regmap, RT5640_IN3_IN4, 2225 regmap_update_bits(rt5640->regmap, RT5640_IN3_IN4,
2196 RT5640_IN_DF2, RT5640_IN_DF2); 2226 RT5640_IN_DF2, RT5640_IN_DF2);
2197 2227
2198 if (rt5640->pdata.dmic_en) {
2199 regmap_update_bits(rt5640->regmap, RT5640_GPIO_CTRL1,
2200 RT5640_GP2_PIN_MASK, RT5640_GP2_PIN_DMIC1_SCL);
2201
2202 if (rt5640->pdata.dmic1_data_pin) {
2203 regmap_update_bits(rt5640->regmap, RT5640_DMIC,
2204 RT5640_DMIC_1_DP_MASK, RT5640_DMIC_1_DP_GPIO3);
2205 regmap_update_bits(rt5640->regmap, RT5640_GPIO_CTRL1,
2206 RT5640_GP3_PIN_MASK, RT5640_GP3_PIN_DMIC1_SDA);
2207 }
2208
2209 if (rt5640->pdata.dmic2_data_pin) {
2210 regmap_update_bits(rt5640->regmap, RT5640_DMIC,
2211 RT5640_DMIC_2_DP_MASK, RT5640_DMIC_2_DP_GPIO4);
2212 regmap_update_bits(rt5640->regmap, RT5640_GPIO_CTRL1,
2213 RT5640_GP4_PIN_MASK, RT5640_GP4_PIN_DMIC2_SDA);
2214 }
2215 }
2216
2217 rt5640->hp_mute = 1; 2228 rt5640->hp_mute = 1;
2218 2229
2219 return snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5640, 2230 return snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5640,