VAR-SOM-MX6 DMic: Difference between revisions

From Variscite Wiki
No edit summary
No edit summary
Line 4: Line 4:
<syntaxhighlight lang="diff">
<syntaxhighlight lang="diff">
diff --git a/arch/arm/boot/dts/imx6qdl-var-dart.dtsi b/arch/arm/boot/dts/imx6qdl-var-dart.dtsi
diff --git a/arch/arm/boot/dts/imx6qdl-var-dart.dtsi b/arch/arm/boot/dts/imx6qdl-var-dart.dtsi
index fce2b66ac2d2..a0fb9538c8dd 100644
index 362be93..884c037 100644
--- a/arch/arm/boot/dts/imx6qdl-var-dart.dtsi
--- a/arch/arm/boot/dts/imx6qdl-var-dart.dtsi
+++ b/arch/arm/boot/dts/imx6qdl-var-dart.dtsi
+++ b/arch/arm/boot/dts/imx6qdl-var-dart.dtsi
@@ -271,14 +271,7 @@
@@ -279,14 +279,7 @@
                AVDD-supply = <&reg_audio>;
AVDD-supply = <&reg_audio>;
                DRVDD-supply = <&reg_audio>;
DRVDD-supply = <&reg_audio>;
                gpio-reset = <&gpio4 5 1>;
gpio-reset = <&gpio4 5 1>;
-               gpio-cfg = <
- gpio-cfg = <
-                       0x0000 /* 0:Default */
- 0x0000 /* 0:Default */
-                       0x0000 /* 1:Default */
- 0x0000 /* 1:Default */
-                       0x0013 /* 2:FN_DMICCLK */
- 0x0013 /* 2:FN_DMICCLK */
-                       0x0000 /* 3:Default */
- 0x0000 /* 3:Default */
-                       0x8014 /* 4:FN_DMICCDAT */
- 0x8014 /* 4:FN_DMICCDAT */
-                       0x0000 /* 5:Default */
- 0x0000 /* 5:Default */
-               >;
- >;
+              ai3x-gpio-func = <0xa 0x5 0x2 0x0 0x0>;
+              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
diff --git a/arch/arm/boot/dts/imx6qdl-var-som.dtsi b/arch/arm/boot/dts/imx6qdl-var-som.dtsi
index 73095da7ebeb..c8731bdc71bc 100644
index f221360..48bc48d 100644
--- a/arch/arm/boot/dts/imx6qdl-var-som.dtsi
--- a/arch/arm/boot/dts/imx6qdl-var-som.dtsi
+++ b/arch/arm/boot/dts/imx6qdl-var-som.dtsi
+++ b/arch/arm/boot/dts/imx6qdl-var-som.dtsi
@@ -313,10 +313,7 @@
@@ -321,10 +321,7 @@
                AVDD-supply = <&reg_audio>;
AVDD-supply = <&reg_audio>;
                DRVDD-supply = <&reg_audio>;
DRVDD-supply = <&reg_audio>;
                gpio-reset = <&gpio4 5 1>;
gpio-reset = <&gpio4 5 1>;
-               ai3x-gpio-func = <
- ai3x-gpio-func = <
-                       0 /* AIC3X_GPIO1_FUNC_DISABLED */
- 0 /* AIC3X_GPIO1_FUNC_DISABLED */
-                       5 /* AIC3X_GPIO2_FUNC_DIGITAL_MIC_INPUT */
- 5 /* AIC3X_GPIO2_FUNC_DIGITAL_MIC_INPUT */
-               >;
- >;
+              ai3x-gpio-func = <0xa 0x5 0x2 0x0 0x0>;
+              ai3x-gpio-func = <0xa 0x5 0x2 0x0 0x0>;
        };
};
  };
  };
 
diff --git a/include/sound/tlv320aic3x.h b/include/sound/tlv320aic3x.h
diff --git a/include/sound/tlv320aic3x.h b/include/sound/tlv320aic3x.h
index 9407fd00363b..421ad03e3395 100644
index 9407fd0..421ad03 100644
--- a/include/sound/tlv320aic3x.h
--- a/include/sound/tlv320aic3x.h
+++ b/include/sound/tlv320aic3x.h
+++ b/include/sound/tlv320aic3x.h
@@ -54,7 +54,7 @@ enum aic3x_micbias_voltage {
@@ -54,7 +54,7 @@ enum aic3x_micbias_voltage {
  };
  };
 
  struct aic3x_setup_data {
  struct aic3x_setup_data {
-       unsigned int gpio_func[2];
- unsigned int gpio_func[2];
+       unsigned int gpio_func[5];
+ unsigned int gpio_func[5];
  };
  };
 
  struct aic3x_pdata {
  struct aic3x_pdata {
diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c
diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c
index 51c4713ac6e3..c9971965d279 100644
index 51c4713..8fc96d1 100644
--- a/sound/soc/codecs/tlv320aic3x.c
--- a/sound/soc/codecs/tlv320aic3x.c
+++ b/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[] = {
@@ -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,
SND_SOC_DAPM_MUX("Right Line2R Mux", SND_SOC_NOPM, 0, 0,
                        &aic3x_right_line2_mux_controls),
&aic3x_right_line2_mux_controls),
 
-       /*
- /*
-       * Not a real mic bias widget but similar function. This is for dynamic
- * Not a real mic bias widget but similar function. This is for dynamic
-       * control of GPIO1 digital mic modulator clock output function when
- * control of GPIO1 digital mic modulator clock output function when
-       * using digital mic.
- * using digital mic.
-       */
- */
-       SND_SOC_DAPM_REG(snd_soc_dapm_micbias, "GPIO1 dmic modclk",
- SND_SOC_DAPM_REG(snd_soc_dapm_micbias, "GPIO1 dmic modclk",
-                       AIC3X_GPIO1_REG, 4, 0xf,
- AIC3X_GPIO1_REG, 4, 0xf,
-                       AIC3X_GPIO1_FUNC_DIGITAL_MIC_MODCLK,
- AIC3X_GPIO1_FUNC_DIGITAL_MIC_MODCLK,
-                       AIC3X_GPIO1_FUNC_DISABLED),
- AIC3X_GPIO1_FUNC_DISABLED),
-
-
-       /*
- /*
-       * Also similar function like mic bias. Selects digital mic with
- * Also similar function like mic bias. Selects digital mic with
-       * configurable oversampling rate instead of ADC converter.
- * configurable oversampling rate instead of ADC converter.
-       */
- */
-       SND_SOC_DAPM_REG(snd_soc_dapm_micbias, "DMic Rate 128",
- SND_SOC_DAPM_REG(snd_soc_dapm_micbias, "DMic Rate 128",
-                       AIC3X_ASD_INTF_CTRLA, 0, 3, 1, 0),
- AIC3X_ASD_INTF_CTRLA, 0, 3, 1, 0),
-       SND_SOC_DAPM_REG(snd_soc_dapm_micbias, "DMic Rate 64",
- SND_SOC_DAPM_REG(snd_soc_dapm_micbias, "DMic Rate 64",
-                       AIC3X_ASD_INTF_CTRLA, 0, 3, 2, 0),
- AIC3X_ASD_INTF_CTRLA, 0, 3, 2, 0),
-       SND_SOC_DAPM_REG(snd_soc_dapm_micbias, "DMic Rate 32",
- SND_SOC_DAPM_REG(snd_soc_dapm_micbias, "DMic Rate 32",
-                       AIC3X_ASD_INTF_CTRLA, 0, 3, 3, 0),
- AIC3X_ASD_INTF_CTRLA, 0, 3, 3, 0),
 
        /* Output mixers */
/* Output mixers */
        SND_SOC_DAPM_MIXER("Left Line Mixer", SND_SOC_NOPM, 0, 0,
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)
@@ -1573,8 +1553,18 @@ static int aic3x_probe(struct snd_soc_codec *codec)
                        /* setup GPIO functions */
/* setup GPIO functions */
                        snd_soc_write(codec, AIC3X_GPIO1_REG,
snd_soc_write(codec, AIC3X_GPIO1_REG,
                                      (aic3x->setup->gpio_func[0] & 0xf) << 4);
      (aic3x->setup->gpio_func[0] & 0xf) << 4);
+
+
                        snd_soc_write(codec, AIC3X_GPIO2_REG,
snd_soc_write(codec, AIC3X_GPIO2_REG,
                                      (aic3x->setup->gpio_func[1] & 0xf) << 4);
      (aic3x->setup->gpio_func[1] & 0xf) << 4);
+
+
+                      snd_soc_update_bits(codec, AIC3X_ASD_INTF_CTRLA,
+                      snd_soc_update_bits(codec, AIC3X_ASD_INTF_CTRLA,
Line 99: Line 99:
+                      snd_soc_update_bits(codec, NEW_ADC_DIGITALPATH,
+                      snd_soc_update_bits(codec, NEW_ADC_DIGITALPATH,
+                                    0x3 << 4, (aic3x->setup->gpio_func[4] & 0x3) << 4);
+                                    0x3 << 4, (aic3x->setup->gpio_func[4] & 0x3) << 4);
                } else {
} else {
                        dev_warn(codec->dev, "GPIO functionality is not supported on tlv320aic3104\n");
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,
@@ -1722,7 +1712,7 @@ static int aic3x_i2c_probe(struct i2c_client *i2c,
                        aic3x->gpio_reset = -1;
aic3x->gpio_reset = -1;
 
                if (of_property_read_u32_array(np, "ai3x-gpio-func",
if (of_property_read_u32_array(np, "ai3x-gpio-func",
-                                       ai3x_setup->gpio_func, 2) >= 0) {
- ai3x_setup->gpio_func, 2) >= 0) {
+                                      ai3x_setup->gpio_func, 5) >= 0) {
+                                      ai3x_setup->gpio_func, 5) >= 0) {
                        aic3x->setup = ai3x_setup;
aic3x->setup = ai3x_setup;
                }
}
 
</syntaxhighlight>
</syntaxhighlight>

Revision as of 09:04, 29 October 2017

VAR-SOM-MX6 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 362be93..884c037 100644
--- a/arch/arm/boot/dts/imx6qdl-var-dart.dtsi
+++ b/arch/arm/boot/dts/imx6qdl-var-dart.dtsi
@@ -279,14 +279,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 f221360..48bc48d 100644
--- a/arch/arm/boot/dts/imx6qdl-var-som.dtsi
+++ b/arch/arm/boot/dts/imx6qdl-var-som.dtsi
@@ -321,10 +321,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 9407fd0..421ad03 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 51c4713..8fc96d1 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;
 		}