ASoC: rt5640: Allow specifying dmic data pins through device-properties
authorHans de Goede <hdegoede@redhat.com>
Tue, 8 May 2018 15:35:50 +0000 (17:35 +0200)
committerMark Brown <broonie@kernel.org>
Fri, 11 May 2018 02:23:06 +0000 (11:23 +0900)
Allow specifying dmic data pins through device-properties / dt. This will
allow us to stop exporting rt5640_dmic_enable() once all callers of it have
been converted to setting device-properties for this instead.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/rt5640.c

index 265a0786851dcd2953bcb45207a4c0c6cb2c5702..d7c7b207f3cc4741390cc3eafc82f6d4cf5197c7 100644 (file)
@@ -2097,6 +2097,10 @@ static int rt5640_probe(struct snd_soc_component *component)
 {
        struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
        struct rt5640_priv *rt5640 = snd_soc_component_get_drvdata(component);
+       u32 dmic1_data_pin = 0;
+       u32 dmic2_data_pin = 0;
+       bool dmic_en = false;
+       u32 val;
 
        /* Check if MCLK provided */
        rt5640->mclk = devm_clk_get(component->dev, "mclk");
@@ -2157,6 +2161,21 @@ static int rt5640_probe(struct snd_soc_component *component)
                snd_soc_component_update_bits(component, RT5640_IN1_IN2,
                                              RT5640_IN_DF2, RT5640_IN_DF2);
 
+       if (device_property_read_u32(component->dev, "realtek,dmic1-data-pin",
+                                    &val) == 0 && val) {
+               dmic1_data_pin = val - 1;
+               dmic_en = true;
+       }
+
+       if (device_property_read_u32(component->dev, "realtek,dmic2-data-pin",
+                                    &val) == 0 && val) {
+               dmic2_data_pin = val - 1;
+               dmic_en = true;
+       }
+
+       if (dmic_en)
+               rt5640_dmic_enable(component, dmic1_data_pin, dmic2_data_pin);
+
        return 0;
 }