audio: fix adc3101 8ch PCM format support
authorRenjun Xu <renjun.xu@amlogic.com>
Fri, 3 Aug 2018 05:54:52 +0000 (13:54 +0800)
committerJianxin Pan <jianxin.pan@amlogic.com>
Fri, 3 Aug 2018 11:20:53 +0000 (04:20 -0700)
PD#171085: fix adc3101 8ch PCM format support

For S400 & S420 board, please modify dts to enable adc3101 8ch PCM
please read following file:
Documentation/devicetree/bindings/amlogic/axg-adc3010-pcm.txt

Change-Id: I945441f80d269b167148ccf3d6c33093a20a4f2f
Signed-off-by: Renjun Xu <renjun.xu@amlogic.com>
Documentation/devicetree/bindings/amlogic/axg-adc3010-pcm.txt [new file with mode: 0644]
MAINTAINERS
sound/soc/codecs/amlogic/tlv320adc3101.c

diff --git a/Documentation/devicetree/bindings/amlogic/axg-adc3010-pcm.txt b/Documentation/devicetree/bindings/amlogic/axg-adc3010-pcm.txt
new file mode 100644 (file)
index 0000000..ae96780
--- /dev/null
@@ -0,0 +1,114 @@
+diff --git a/arch/arm64/boot/dts/amlogic/axg_s420_v03.dts
+       b/arch/arm64/boot/dts/amlogic/axg_s420_v03.dts
+index f184fce..5a43ba1 100644
+--- a/arch/arm64/boot/dts/amlogic/axg_s420_v03.dts
++++ b/arch/arm64/boot/dts/amlogic/axg_s420_v03.dts
+@@ -383,24 +383,24 @@
+               };
+               aml-audio-card,dai-link@1 {
+-                      format = "i2s";
++      format = "dsp_a";
+                       mclk-fs = <256>;
+                       //continuous-clock;
+-                      //bitclock-inversion;
++                      bitclock-inversion;
+                       //frame-inversion;
+                       bitclock-master = <&aml_tdmb>;
+                       frame-master = <&aml_tdmb>;
+                       cpu {
+                               sound-dai = <&aml_tdmb>;
+-      dai-tdm-slot-tx-mask = <1 1>;
+-      dai-tdm-slot-rx-mask = <1 1>;
+-      dai-tdm-slot-num = <2>;
++      dai-tdm-slot-tx-mask = <1 1 1 1 1 1 1 1>;
++      dai-tdm-slot-rx-mask = <1 1 1 1 1 1 1 1>;
++      dai-tdm-slot-num = <8>;
+       dai-tdm-slot-width = <32>;
+       system-clock-frequency = <12288000>;
+                       };
+                       codec {
+-                              sound-dai = <&tlv320adc3101_32>;
+-                                      /*&tlv320adc3101_30>;*/
++      prefix-names = "3101_A", "3101_B",
++                              "3101_C", "3101_D";
++      sound-dai = <&tlv320adc3101_30 &tlv320adc3101_32
++                              &tlv320adc3101_34 &tlv320adc3101_36>;
+                       };
+               };
+@@ -728,7 +728,7 @@
+       status = "okay";
+       pinctrl-names="default";
+       pinctrl-0=<&b_i2c_master>;
+-
++/*
+       tlv320adc3101_32: tlv320adc3101_32@30 {
+               compatible = "ti,tlv320adc3101";
+               #sound-dai-cells = <0>;
+@@ -736,7 +736,7 @@
+               differential_pair = <1>;
+               status = "okay";
+       };
+-
++*/
+       tas5707_36: tas5707_36@36 {
+               compatible = "ti,tas5707";
+               #sound-dai-cells = <0>;
+@@ -771,23 +771,34 @@
+               status = "okay";
+       };
++      tlv320adc3101_32: tlv320adc3101_32@32 {
++              compatible = "ti,tlv320adc3101";
++              #sound-dai-cells = <0>;
++              reg = <0x19>;
++              slot_number = <3>;
++              //differential_pair = <1>;
++              status = "okay";
++      };
+       tlv320adc3101_30: tlv320adc3101_30@30 {
+               compatible = "ti,tlv320adc3101";
+               #sound-dai-cells = <0>;
+               reg = <0x18>;
+-              status = "disable";
++              slot_number = <0>;
++              status = "okay";
+       };
+-      tlv320adc3101_34: tlv320adc3101_34@30 {
++      tlv320adc3101_34: tlv320adc3101_34@34 {
+               compatible = "ti,tlv320adc3101";
+               #sound-dai-cells = <0>;
+               reg = <0x1a>;
+-              status = "disable";
++              slot_number = <2>;
++              status = "okay";
+       };
+-      tlv320adc3101_36: tlv320adc3101_36@30 {
++      tlv320adc3101_36: tlv320adc3101_36@36 {
+               compatible = "ti,tlv320adc3101";
+               #sound-dai-cells = <0>;
+               reg = <0x1b>;
+-              status = "disable";
++              slot_number = <1>;
++              status = "okay";
+       };
+       es7243_10: es7243_10@10 {
+               compatible = "MicArray_0";
+@@ -928,8 +939,8 @@
+       aml_tdmb: tdmb {
+               compatible = "amlogic, axg-snd-tdmb";
+               #sound-dai-cells = <0>;
+-              dai-tdm-lane-slot-mask-out = <1 0>;
+-              dai-tdm-lane-slot-mask-in = <0 1>;
++              dai-tdm-lane-slot-mask-out = <1 1>;
++              dai-tdm-lane-slot-mask-in = <1 0>;
+               dai-tdm-clk-sel = <1>;
+               clocks = <&clkaudio CLKID_AUDIO_MCLK_B
+                               &clkc CLKID_MPLL1>;
+@@ -1089,8 +1100,7 @@
+       tdmin_b: tdmin_b {
+               mux {
+-                      groups = "tdmb_din0",
+-                              "tdmb_din1";
++                      groups = "tdmb_din0";
+                       function = "tdmb_in";
+               };
+       };
index df4636af1e108974b749f11c305d50a67d6a1e15..1eb2ed20d749c4798f43f0c6da85bd611ca2e0af 100644 (file)
@@ -14583,3 +14583,7 @@ F: sound/soc/codecs/amlogic/cs42528.h
 AMLOGIC SPIDEV
 M:    Ivan Nie <Ivan.nie@amlogic.com>
 F:    Documentation/devicetree/bindings/spi/spidev.txt
+
+AMLOGIC SOUND ADC3101
+M: Renjun Xu <renjun.xu@amlogic.com>
+F: Documentation/devicetree/bindings/amlogic/axg-sound-adc3010-d608mic-pcm.txt
index acb1cc9aa9a8f5d5e84fbdf61ea9c41817ca4829..6c3a742f707badd2f4ff6606e83fe7f780c5b082 100644 (file)
@@ -65,6 +65,7 @@ struct adc3101_priv {
        /* for more control */
        int codec_cnt;
        int codec_mask;
+       unsigned int slot_number;
        struct i2c_client *client[4];
        u8 page_no;
        /* differential_pair
@@ -300,11 +301,16 @@ static int adc3101_set_dai_sysclk(struct snd_soc_dai *codec_dai,
 static int adc3101_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
 {
        struct snd_soc_codec *codec = codec_dai->codec;
+       struct adc3101_priv *adc3101 = NULL;
        u8 iface_reg_1;
        u8 dsp_a_val;
        u8 iface_reg_2;
 
-       pr_info("%s ...\n", __func__);
+       adc3101 = snd_soc_codec_get_drvdata(codec);
+       if (adc3101 == NULL)
+               return -EINVAL;
+
+       pr_info("[%s]:slot_number=%d\n", __func__, adc3101->slot_number);
 
        iface_reg_1 = snd_soc_read(codec, ADC3101_IFACE1);
        iface_reg_1 = iface_reg_1 & ~(3 << 6 | 3 << 2);
@@ -344,7 +350,18 @@ static int adc3101_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
        case SND_SOC_DAIFMT_DSP_A:
                iface_reg_1 |= (ADC3101_DSP_MODE << ADC3101_PLLJ_SHIFT);
                iface_reg_2 |= (1 << 3); /* invert bit clock */
-               dsp_a_val = 0x01; /* add offset 1 */
+
+               /* set bclk offset according to diffrent adc */
+               if (adc3101->slot_number == 0)
+                       dsp_a_val = 0;
+               else if (adc3101->slot_number == 1)
+                       dsp_a_val = 64;
+               else if (adc3101->slot_number == 2)
+                       dsp_a_val = 128;
+               else if (adc3101->slot_number == 3)
+                       dsp_a_val = 192;
+               else
+                       dsp_a_val = 0x01; /* default add offset 1 */
                break;
        case SND_SOC_DAIFMT_DSP_B:
                iface_reg_1 |= (ADC3101_DSP_MODE << ADC3101_PLLJ_SHIFT);
@@ -840,6 +857,14 @@ static int adc3101_i2c_probe(struct i2c_client *i2c,
                adc3101->differential_pair = 0;
                ret = 0;
        }
+
+       ret = of_property_read_u32(i2c->dev.of_node, "slot_number",
+               &adc3101->slot_number);
+       if (ret) {
+               pr_err("failed to get slot_number, set it default\n");
+               adc3101->slot_number = 0;
+               ret = 0;
+       }
        pr_info("%s i2c:%p\n", __func__, i2c);
        ret = snd_soc_register_codec(&i2c->dev,
                                &soc_codec_dev_adc3101, adc3101_dai, 1);