VAR-SOM-MX6 DMic

From Variscite Wiki
Revision as of 11:49, 18 December 2016 by Eran (talk | contribs) (Created page with "{{PageHeader|Digital Mic}} {{DocImage|category1=Yocto|category2=VAR-SOM-MX6}} To get the digital microphone working, apply the following patch to the Linux kernel: <syntaxhigh...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Digital Mic

To get the digital microphone working, apply the following patch to the Linux kernel:

diff --git a/arch/arm/boot/dts/imx6qdl-var-dart.dtsi b/arch/arm/boot/dts/imx6qdl-var-dart.dtsi
index fce2b66ac2d2..a0fb9538c8dd 100644
--- a/arch/arm/boot/dts/imx6qdl-var-dart.dtsi
+++ b/arch/arm/boot/dts/imx6qdl-var-dart.dtsi
@@ -271,14 +271,7 @@
                AVDD-supply = <&reg_audio>;
                DRVDD-supply = <&reg_audio>;
                gpio-reset = <&gpio4 5 1>;
-               gpio-cfg = <
-                       0x0000 /* 0:Default */
-                       0x0000 /* 1:Default */
-                       0x0013 /* 2:FN_DMICCLK */
-                       0x0000 /* 3:Default */
-                       0x8014 /* 4:FN_DMICCDAT */
-                       0x0000 /* 5:Default */
-               >;
+               ai3x-gpio-func = <0xa 0x5 0x2 0x0 0x0>;
        };
 };

diff --git a/arch/arm/boot/dts/imx6qdl-var-som.dtsi b/arch/arm/boot/dts/imx6qdl-var-som.dtsi
index 73095da7ebeb..c8731bdc71bc 100644
--- a/arch/arm/boot/dts/imx6qdl-var-som.dtsi
+++ b/arch/arm/boot/dts/imx6qdl-var-som.dtsi
@@ -313,10 +313,7 @@
                AVDD-supply = <&reg_audio>;
                DRVDD-supply = <&reg_audio>;
                gpio-reset = <&gpio4 5 1>;
-               ai3x-gpio-func = <
-                       0 /* AIC3X_GPIO1_FUNC_DISABLED */
-                       5 /* AIC3X_GPIO2_FUNC_DIGITAL_MIC_INPUT */
-               >;
+               ai3x-gpio-func = <0xa 0x5 0x2 0x0 0x0>;
        };
 };

diff --git a/include/sound/tlv320aic3x.h b/include/sound/tlv320aic3x.h
index 9407fd00363b..421ad03e3395 100644
--- a/include/sound/tlv320aic3x.h
+++ b/include/sound/tlv320aic3x.h
@@ -54,7 +54,7 @@ enum aic3x_micbias_voltage {
 };

 struct aic3x_setup_data {
-       unsigned int gpio_func[2];
+       unsigned int gpio_func[5];
 };

 struct aic3x_pdata {
diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c
index 51c4713ac6e3..c9971965d279 100644
--- a/sound/soc/codecs/tlv320aic3x.c
+++ b/sound/soc/codecs/tlv320aic3x.c
@@ -687,26 +687,6 @@ static const struct snd_soc_dapm_widget aic3x_extra_dapm_widgets[] = {
        SND_SOC_DAPM_MUX("Right Line2R Mux", SND_SOC_NOPM, 0, 0,
                         &aic3x_right_line2_mux_controls),

-       /*
-        * Not a real mic bias widget but similar function. This is for dynamic
-        * control of GPIO1 digital mic modulator clock output function when
-        * using digital mic.
-        */
-       SND_SOC_DAPM_REG(snd_soc_dapm_micbias, "GPIO1 dmic modclk",
-                        AIC3X_GPIO1_REG, 4, 0xf,
-                        AIC3X_GPIO1_FUNC_DIGITAL_MIC_MODCLK,
-                        AIC3X_GPIO1_FUNC_DISABLED),
-
-       /*
-        * Also similar function like mic bias. Selects digital mic with
-        * configurable oversampling rate instead of ADC converter.
-        */
-       SND_SOC_DAPM_REG(snd_soc_dapm_micbias, "DMic Rate 128",
-                        AIC3X_ASD_INTF_CTRLA, 0, 3, 1, 0),
-       SND_SOC_DAPM_REG(snd_soc_dapm_micbias, "DMic Rate 64",
-                        AIC3X_ASD_INTF_CTRLA, 0, 3, 2, 0),
-       SND_SOC_DAPM_REG(snd_soc_dapm_micbias, "DMic Rate 32",
-                        AIC3X_ASD_INTF_CTRLA, 0, 3, 3, 0),

        /* Output mixers */
        SND_SOC_DAPM_MIXER("Left Line Mixer", SND_SOC_NOPM, 0, 0,
@@ -1573,8 +1553,18 @@ static int aic3x_probe(struct snd_soc_codec *codec)
                        /* setup GPIO functions */
                        snd_soc_write(codec, AIC3X_GPIO1_REG,
                                      (aic3x->setup->gpio_func[0] & 0xf) << 4);
+
                        snd_soc_write(codec, AIC3X_GPIO2_REG,
                                      (aic3x->setup->gpio_func[1] & 0xf) << 4);
+
+                       snd_soc_update_bits(codec, AIC3X_ASD_INTF_CTRLA,
+                                     0x3 << 0, (aic3x->setup->gpio_func[2] & 0x3) << 0);
+
+                       snd_soc_update_bits(codec, MICBIAS_CTRL,
+                                     0x3 << 4, (aic3x->setup->gpio_func[3] & 0x3) << 4);
+
+                       snd_soc_update_bits(codec, NEW_ADC_DIGITALPATH,
+                                     0x3 << 4, (aic3x->setup->gpio_func[4] & 0x3) << 4);
                } else {
                        dev_warn(codec->dev, "GPIO functionality is not supported on tlv320aic3104\n");
                }
@@ -1722,7 +1712,7 @@ static int aic3x_i2c_probe(struct i2c_client *i2c,
                        aic3x->gpio_reset = -1;

                if (of_property_read_u32_array(np, "ai3x-gpio-func",
-                                       ai3x_setup->gpio_func, 2) >= 0) {
+                                       ai3x_setup->gpio_func, 5) >= 0) {
                        aic3x->setup = ai3x_setup;
                }