This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TLV320AIC3206EVM-U: About mixer control.

Part Number: TLV320AIC3206EVM-U
Other Parts Discussed in Thread: TLV320AIC3206, PCM1780,

Hi,

I have tried STM32MP157D-DK1 and PCM1780 before. However, I couldn't solve the problem, so I changed the device to TLV320AIC3206.

Using the sample device tree as a reference, I built the "simple audio card" device tree for the STM32MP157D and TLV320AIC3206.

I/F:i2c4 & sai1

----------------

STM32MP> i2c dev 0
  Setting bus to 0
STM32MP> i2c probe
  Valid chip addresses: 18 33
STM32MP> i2c bus 0
  Bus 0: i2c@5c002000 (active 0)
  33: stpmic@33, offset len 1, flags 0

  18: generic_18, offset len 1, flags 0 // TLVC320AIC3206
STM32MP> i2c md 18 32 10
  0032: 00 00 00 12 03 02 02 00 00 00 01 01 00 14 0c 00 ................
STM32MP> i2c mw 18 34 01
STM32MP> i2c md 18 32 10
  0032: 00 00 01 12 01 00 00 00 00 00 01 01 00 14 0c d8 ................

----------------

I can access TLV320AIC3206 via i2c from the u-boot console.

Attempting a mixer control from a Linux terminal fails.
Do you know where the cause of this problem is?

[ 3.609648] ALSA device list:
[ 3.611159] No soundcards found.
[ 70.881989] asoc-simple-card sound: tlv320aic32x4-hifi <-> 4400a004.audio-controller mapping ok

$ alsamixer
cannot load mixer controls: Operation not permitted
$ amixer -c0
amixer: Mixer hw:0 load error: Operation not permitted

$ sudo i2cdetect -y 0
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- UU -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

Thanks,

Nishimura

  • I have requested our driver expert to take a look.

  • It looks the soundcard does not register.

  • Hi,

    I have tried some commands.
    The device driver was built as a kernel module, so it doesn't seem to be in the list of ASLA sound cards.
    Is there a problem with the device tree?

    $ aplay -l
    **** List of PLAYBACK Hardware Devices ****
    card 0: BoardTLV32 [Board-TLV320AIC3206], device 0: 4400a004.audio-controller-tlv320aic32x4-hifi tlv320aic32x4-hifi [4400a004.audio-controller-tlv320aic32x4-hifi tlv320aic32x4-hifi]
    Subdevices: 1/1
    Subdevice #0: subdevice #0

    $ amixer controls
    numid=5,iface=MIXER,name='PCM Playback Volume'
    numid=13,iface=MIXER,name='Mic PGA Switch'
    ・・・

    $ cat /etc/group
    root:x:0:
    ・・・
    audio:x:29:debian
    ・・・

    $ aplay loop3.wav -D plughw:0,0
    Playing WAVE 'loop3.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
    aplay: pcm_write:2058: write error: Input/output error

    / {
      sound: sound {
        compatible = "simple-audio-card";
        simple-audio-card,name = "Board-TLV320AIC3206";
        simple-audio-card,format = "i2s";
        simple-audio-card,bitclock-master = <&dailink_master>;
        simple-audio-card,frame-master = <&dailink_master>;
        simple-audio-card,widgets =
          "Line", "Line In",
          "Line", "Line Out",
          "Headphone", "Headphone";
        simple-audio-card,routing =
          "Line Out", "LOL",
          "Line Out", "LOR",
          "Headphone", "HPL",
          "Headphone", "HPR",
          "IN1_L", "Line In",
          "IN1_R", "Line In";
        status = "okay";

        simple-audio-card,cpu {
          sound-dai = <&sai1a>;
        };

        dailink_master: simple-audio-card,codec {
          sound-dai = <&tlv3206_codec>;
          clocks = <&rcc SAI1>;
        };
      };
    }; /*root*/

    &i2c4 {
      pinctrl-names = "default", "sleep";
      pinctrl-0 = <&i2c4_pins_a>;
      pinctrl-1 = <&i2c4_pins_sleep_a>;
      i2c-scl-rising-time-ns = <185>;
      i2c-scl-falling-time-ns = <20>;
      clock-frequency = <400000>;
      status = "okay";
      /* spare dmas for other usage */
      /delete-property/dmas;
      /delete-property/dma-names;

      tlv3206_codec: tlv320aic32x6@18 {
        compatible = "ti,tlv320aic32x6";
        #sound-dai-cells = <0>;
        reg = <0x18>;

        clocks = <&sai1a>;
        clock-names = "mclk";
        aic32x4-gpio-func= <
          0x00 // MFP1 : DEFAULT VALUE=0xff
          0xff // MFP2 : DEFAULT VALUE=0xff, DOUT=enable/Primary
          0x00 // MFP3 : DEFAULT VALUE=0xff, DIN=disable
          0x00 // MFP4 : DEFAULT VALUE=0xff
          0x00 // MFP5 : DEFAULT VALUE=0xff
        >;

        iov-supply = <&v3v3>; // digital IO power supply
        ldoin-supply = <&v1v8_audio>; // LDO power supply
        dv-supply = <&v1v8_audio>; // Digital core power supply
        av-supply = <&v1v8_audio>; // Analog core power supply

        status = "okay";

        tlv3206_port: port {
          #address-cells = <1>;
          #size-cells = <0>;

            tlv3206_tx_endpoint: endpoint@0 {
              reg = <0>;
              remote-endpoint = <&sai1a_endpoint>;
              frame-master;
              bitclock-master;
            };
        };
      };
    };

    &sai1 {
      clocks = <&rcc SAI1>, <&rcc PLL3_Q>, <&rcc PLL3_R>;
      clock-names = "pclk", "x8k", "x11k";
      pinctrl-names = "default", "sleep";
      pinctrl-0 = <&sai1a_pins_a>;
      pinctrl-1 = <&sai1a_sleep_pins_a>;
      status = "okay";

      sai1a: audio-controller@4400a004 {
        #clock-cells = <0>;
        dma-names = "tx";
        clocks = <&rcc SAI1_K>;
        clock-names = "sai_ck";
        status = "okay";

        sai1a_port: port {
          sai1a_endpoint: endpoint {
            remote-endpoint = <&tlv3206_tx_endpoint>;
            format = "i2s";
            mclk-fs = <256>;
            dai-tdm-slot-num = <2>;
            dai-tdm-slot-width = <32>;
          };
        };
      };
      sai1b: audio-controller@4400a024 {
        status = "disabled";
      };
    };

    Thanks,

    Nishimura

  • Hi,

    An audio IC(cs42l51) is mounted on the STM32MP157D-DK1.(stm32mp15xx-dkx.dtsi)

    We want to replace CS42l51 with TLV320AIC3206.
    CS42l51 is connected to SAI2 and I2C1 in the device tree, can I replace it for TLV320AIC3206?
    I'm checking a sample device tree for the TLV320AIC3206. (am335x-boneblack-common.dtsi)

    Thanks,
    Nihsimura

  • Hi,

    Raphael will get back to you with his comment.

    Regards.

  • Hi, Nishimura.

    Can we have a conf-call, if you are available. my mail address: shenghao-ding@ti.com

  • Hi Shenghao-san,

    Can you support Japanese?

    Thanks,

    Nishimura

  • What about English?

  • Hi,

    I'm sorry, I don't speak English well, so I would like to exchange information on the support site if possible.

  • Hi Nishimura San,

    Before conf-call, let's check sound card first, kindly run following commands,

    cat /proc/asound/pcm

    cat /proc/asound/cards

    cat /sys/kernel/debug/asoc/components (for kernel 4.19 or above)

    cat /sys/kernel/debug/asoc/codecs (for kernel 4.14 or below)

    ls /dev/snd

    Thanks.

  • Hi,

    I have tried some commands.

    # cat /proc/asound/pcm
    00-00: 4400a004.audio-controller-tlv320aic32x4-hifi tlv320aic32x4-hifi : 4400a004.audio-controller-tlv320aic32x4-hifi tlv320aic32x4-hifi : playback 1

    # cat /proc/asound/pcm
    00-00: 4400a004.audio-controller-tlv320aic32x4-hifi tlv320aic32x4-hifi : 4400a004.audio-controller-tlv320aic32x4-hifi tlv320aic32x4-hifi : playback 1
    root@arm:/home/debian# cat /proc/asound/cards
    0 [IoTGatewayTLV32]: IoTGateway-TLV3 - IoTGateway-TLV320AIC3206
    IoTGateway-TLV320AIC3206

    # uname -a
    Linux arm 5.4.56 #33 SMP PREEMPT Wed Apr 20 10:05:56 JST 2022 armv7l GNU/Linux

    # cat /sys/kernel/debug/asoc/components
    tlv320aic32x4.0-0018
    4400a004.audio-controller
    4400a004.audio-controller
    snd-soc-dummy
    snd-soc-dummy

    # ls /dev/snd
    by-path controlC0 pcmC0D0p timer

    # alsactl init
    alsa-lib main.c:1014:(snd_use_case_mgr_open) error: failed to import hw:0 use case configuration -2
    Found hardware: "IoTGateway-TLV3" "" "" "" ""
    Hardware is initialized using a generic method
    /usr/share/alsa/init/default:181: value write error: No such device or address
    /usr/share/alsa/init/default:181: value write error: No such device or address

    # cat /etc/group | grep audio
    audio:x:29:debian

    Thanks,
    Nishimura

  • Hi,

    Additional Information.
    # cd snd/
    # ls -l
    total 0
    drwxr-xr-x 2 root root 60 Jun 20 2021 by-path
    crw-rw---- 1 root audio 116, 3 Jun 20 2021 controlC0
    crw-rw---- 1 root audio 116, 2 Jun 20 2021 pcmC0D0p
    crw-rw---- 1 root audio 116, 33 Jun 20 2021 timer

    Thanks,
    Nishimura

  • Hi,

    Additional Information.
    I added a debug print to the tlv320aic32x4_i2c driver and built it into the kernel.
    It was picked up in the ALSA sound card list, but the mixer didn't solve the problem.

    Starting kernel ...

    [ 0.252943] Advanced Linux Sound Architecture Driver Initialized.

    [ 3.330752] ASoC TLV320AIC32x4 codec driver I2C : aic32x4_i2c_probe()
    [ 3.336226] ASoC tlv320aic32x4 codec driver : aic32x4_probe() start
    [ 3.342444] ASoC tlv320aic32x4 codec driver : aic32x4_probe() np ---> aic32x4_parse_dt()
    [ 3.350652] ASoC tlv320aic32x4 codec driver : aic32x4_parse_dt()
    [ 3.356789] ASoC tlv320aic32x4 codec driver : aic32x4_parse_dt() aic32x4->mclk_name=audio-controller, aic32x4->rstn_gpio=-2, aic32x4_setup->gpio_func=0,ff,0,0,0
    [ 3.371214] ASoC TLV320AIC32x4 clk : aic32x4_register_clocks() mclk_name=audio-controller
    [ 3.379487] ASoC TLV320AIC32x4 clk : aic32x4_register_clk() devname=0-0018, desc->name=pll
    [ 3.388278] ASoC TLV320AIC32x4 clk : clk_aic32x4_pll_get_parent() val=17, ret=0
    [ 3.395307] ASoC TLV320AIC32x4 clk : clk_aic32x4_pll_recalc_rate()
    [ 3.401513] ASoC TLV320AIC32x4 clk : clk_aic32x4_pll_get_muldiv()
    [ 3.408810] ASoC TLV320AIC32x4 clk : clk_aic32x4_pll_calc_rate()
    [ 3.414072] ASoC TLV320AIC32x4 clk : clk_aic32x4_pll_get_parent() val=17, ret=0
    [ 3.421537] ASoC TLV320AIC32x4 clk : aic32x4_register_clk() devname=0-0018, desc->name=codec_clkin
    [ 3.430351] ASoC TLV320AIC32x4 clk : clk_aic32x4_codec_clkin_get_parent()
    [ 3.437498] ASoC TLV320AIC32x4 clk : clk_aic32x4_codec_clkin_get_parent()
    [ 3.444628] ASoC TLV320AIC32x4 clk : clk_aic32x4_pll_get_parent() val=17, ret=0
    [ 3.451647] ASoC TLV320AIC32x4 clk : aic32x4_register_clk() devname=0-0018, desc->name=ndac
    [ 3.460253] ASoC TLV320AIC32x4 clk : clk_aic32x4_div_recalc_rate() parent_rate=0, val=1, ret=0
    [ 3.468637] ASoC TLV320AIC32x4 clk : clk_aic32x4_codec_clkin_get_parent()
    [ 3.476073] ASoC TLV320AIC32x4 clk : clk_aic32x4_pll_get_parent() val=17, ret=0
    [ 3.483116] ASoC TLV320AIC32x4 clk : aic32x4_register_clk() devname=0-0018, desc->name=mdac
    [ 3.491715] ASoC TLV320AIC32x4 clk : clk_aic32x4_div_recalc_rate() parent_rate=0, val=1, ret=0
    [ 3.500081] ASoC TLV320AIC32x4 clk : clk_aic32x4_codec_clkin_get_parent()
    [ 3.507515] ASoC TLV320AIC32x4 clk : clk_aic32x4_pll_get_parent() val=17, ret=0
    [ 3.514571] ASoC TLV320AIC32x4 clk : aic32x4_register_clk() devname=0-0018, desc->name=nadc
    [ 3.523190] ASoC TLV320AIC32x4 clk : clk_aic32x4_div_recalc_rate() parent_rate=0, val=1, ret=0
    [ 3.531530] ASoC TLV320AIC32x4 clk : clk_aic32x4_codec_clkin_get_parent()
    [ 3.538962] ASoC TLV320AIC32x4 clk : clk_aic32x4_pll_get_parent() val=17, ret=0
    [ 3.546012] ASoC TLV320AIC32x4 clk : aic32x4_register_clk() devname=0-0018, desc->name=madc
    [ 3.554569] ASoC TLV320AIC32x4 clk : clk_aic32x4_div_recalc_rate() parent_rate=0, val=1, ret=0
    [ 3.562977] ASoC TLV320AIC32x4 clk : clk_aic32x4_codec_clkin_get_parent()
    [ 3.570413] ASoC TLV320AIC32x4 clk : clk_aic32x4_pll_get_parent() val=17, ret=0
    [ 3.577496] ASoC TLV320AIC32x4 clk : aic32x4_register_clk() devname=0-0018, desc->name=bdiv
    [ 3.585746] ASoC TLV320AIC32x4 clk : clk_aic32x4_bdiv_get_parent()
    [ 3.592540] ASoC TLV320AIC32x4 clk : clk_aic32x4_div_recalc_rate() parent_rate=0, val=1, ret=0
    [ 3.600699] ASoC TLV320AIC32x4 clk : clk_aic32x4_codec_clkin_get_parent()
    [ 3.608129] ASoC TLV320AIC32x4 clk : clk_aic32x4_pll_get_parent() val=17, ret=0
    [ 3.615225] ASoC tlv320aic32x4 codec driver : aic32x4_setup_regulators()
    [ 3.622194] ASoC tlv320aic32x4 codec driver : aic32x4_probe() success

    [ 3.709390] ASoC TLV320AIC32x4 clk : clk_aic32x4_codec_clkin_get_parent()
    [ 3.715920] ASoC TLV320AIC32x4 clk : clk_aic32x4_pll_get_parent() val=17, ret=0
    [ 3.723210] ASoC TLV320AIC32x4 clk : clk_aic32x4_codec_clkin_get_parent()
    [ 3.729883] ASoC TLV320AIC32x4 clk : clk_aic32x4_pll_get_parent() val=17, ret=0
    [ 3.737542] reg11: supplied by vdd
    [ 3.740210] reg18: supplied by vdd
    [ 3.744242] ASoC TLV320AIC32x4 clk : clk_aic32x4_codec_clkin_get_parent()
    [ 3.751005] ASoC TLV320AIC32x4 clk : clk_aic32x4_pll_get_parent() val=17, ret=0
    [ 3.758003] ASoC TLV320AIC32x4 clk : clk_aic32x4_codec_clkin_get_parent()

    [ 3.772763] ASoC TLV320AIC32x4 clk : clk_aic32x4_pll_get_parent() val=17, ret=0

    [ 3.948335] ASoC tlv320aic32x4 codec driver : aic32x4_component_probe()
    [ 3.954021] ASoC tlv320aic32x4 codec driver : aic32x4_setup_gpios()
    [ 3.961622] ASoC TLV320AIC32x4 clk : clk_aic32x4_div_recalc_rate() parent_rate=0, val=1, ret=0
    [ 3.969192] ASoC TLV320AIC32x4 clk : clk_aic32x4_div_recalc_rate() parent_rate=0, val=1, ret=0
    [ 3.977907] ASoC TLV320AIC32x4 clk : clk_aic32x4_div_recalc_rate() parent_rate=0, val=1, ret=0
    [ 3.986618] ASoC TLV320AIC32x4 clk : clk_aic32x4_div_recalc_rate() parent_rate=0, val=1, ret=0
    [ 3.995313] ASoC TLV320AIC32x4 clk : clk_aic32x4_div_recalc_rate() parent_rate=0, val=1, ret=0
    [ 4.003730] ASoC TLV320AIC32x4 clk : clk_aic32x4_codec_clkin_set_parent()
    [ 4.011444] ASoC TLV320AIC32x4 clk : clk_aic32x4_div_recalc_rate() parent_rate=0, val=1, ret=0
    [ 4.019627] ASoC TLV320AIC32x4 clk : clk_aic32x4_div_recalc_rate() parent_rate=0, val=1, ret=0
    [ 4.028335] ASoC TLV320AIC32x4 clk : clk_aic32x4_div_recalc_rate() parent_rate=0, val=1, ret=0
    [ 4.037051] ASoC TLV320AIC32x4 clk : clk_aic32x4_div_recalc_rate() parent_rate=0, val=1, ret=0
    [ 4.045750] ASoC TLV320AIC32x4 clk : clk_aic32x4_div_recalc_rate() parent_rate=0, val=1, ret=0
    [ 4.054445] ASoC TLV320AIC32x4 clk : clk_aic32x4_div_recalc_rate() parent_rate=0, val=1, ret=0
    [ 4.062909] ASoC TLV320AIC32x4 clk : clk_aic32x4_bdiv_set_parent()
    [ 4.070045] ASoC TLV320AIC32x4 clk : clk_aic32x4_div_recalc_rate() parent_rate=0, val=1, ret=0
    [ 4.093577] ASoC tlv320aic32x4 codec driver : aic32x4_set_dai_sysclk()
    [ 4.098788] ASoC tlv320aic32x4 codec driver : aic32x4_set_dai_fmt() SND_SOC_DAIFMT_CBM_CFM
    [ 4.107126] ASoC tlv320aic32x4 codec driver : aic32x4_set_dai_fmt() SND_SOC_DAIFMT_I2S
    [ 4.117132] asoc-simple-card sound: tlv320aic32x4-hifi <-> 4400a004.audio-controller mapping ok
    [ 4.128527] ASoC tlv320aic32x4 codec driver : aic32x4_set_bias_level()

    [ 4.144031] ASoC TLV320AIC32x4 clk : clk_aic32x4_pll_is_prepared()
    [ 4.149870] ALSA device list:
    [ 4.152224] #0: IoTGateway-TLV320AIC3206

    See 'systemctl status haveged.service' for details.
    Starting Save/Restore Sound Card State...
    [ OK ] Finished Save/Restore Sound Card State.
    [ OK ] Reached target Sound Card.


    debian@arm:~$ sudo alsamixer
    [ 141.652160] ASoC tlv320aic32x4 codec driver : aic32x4_get_mfp1_gpio() 0x1
    [ 141.658375] ASoC tlv320aic32x4 codec driver : aic32x4_get_mfp3_gpio() 0x0
    cannot load mixer controls: Operation not permitted

    Thanks,
    Nishimura

  • It seemed that it is caused by your user not being in the audio group. Have a look at usermode

  • Hi,

    The login user belongs to an audio group.

    debian@arm:~$ who
    debian ttySTM0 2022-04-21 15:20
    debian@arm:~$ cat /etc/group | grep audio
    audio:x:29:debian

    Thanks,
    Nishimura

  • Kindly use amixer instead of alsamixer, and try it.

  • debian@arm:~$ sudo amixer -c 0
    [ 6783.013828] ASoC tlv320aic32x4 codec driver : aic32x4_get_mfp1_gpio() 0x1
    [ 6783.019893] ASoC tlv320aic32x4 codec driver : aic32x4_get_mfp3_gpio() 0x0
    amixer: Mixer hw:0 load error: Operation not permitted
    debian@arm:~$ sudo amixer -c 0 sset PCM 50%,50% unmute
    [ 6791.775242] ASoC tlv320aic32x4 codec driver : aic32x4_get_mfp1_gpio() 0x1
    [ 6791.781315] ASoC tlv320aic32x4 codec driver : aic32x4_get_mfp3_gpio() 0x0
    amixer: Mixer hw:0 load error: Operation not permitted

  • I'm curious that there is no mixer name.

    debian@arm:~$ amixer info
    Card default 'IoTGatewayTLV32'/'IoTGateway-TLV320AIC3206'
    Mixer name : ''
    Components : ''
    Controls : 49
    [ 7075.330392] ASoC tlv320aic32x4 codec driver : aic32x4_get_mfp1_gpio() 0x1
    [ 7075.336385] ASoC tlv320aic32x4 codec driver : aic32x4_get_mfp3_gpio() 0x0
    amixer: Mixer load default error: Operation not permitted

  • It is a permission issue, can you change the permission to enable amixer to access the audio card. In our BBB, I never encounter such issue.

  • It resolve that there're 49 controls. Due to permission issue, can't get mixer name.

  • Can you share your current code?

  • I will check the settings again.

  • Hi,

    This is a placeholder message for recordkeeping purposes. Please respond once you have an update.

    Thank you,

    Jeff

  • Hi,

    I logged in as "root" and tried, but the problem didn't go away.
    Alsamixer worked by removing the following definition from the device tree.

    aic32x4-gpio-func= <
      0x00
      0xff
      0x00
      0x00
      0x00
    >;

    I then challenge the aplay error.
    I expect this to be "clock" issue.
      aplay: pcm_write:2058: write error: Input/output error

    Thanks,
    Nishimura

  • Hi,

    The driver is printing the following error, what should I check?

    ...
    [ 941.174812] Division by zero in kernel.
    [ 941.178582] CPU: 0 PID: 8178 Comm: aplay Not tainted 5.4.56 #40
    [ 941.184265] Hardware name: STM32 (Device Tree Support)
    [ 941.189355] systemd-journald[3711]: /dev/kmsg buffer overrun, some messages lost.
    [ 941.189440] [<c011253c>] (unwind_backtrace) from [<c010d780>] (show_stack+0x10/0x14)
    [ 941.204672] [<c010d780>] (show_stack) from [<c0b011f4>] (dump_stack+0xb0/0xc4)
    [ 941.211900] [<c0b011f4>] (dump_stack) from [<c0afe940>] (Ldiv0_64+0x8/0x18)
    [ 941.218871] [<c0afe940>] (Ldiv0_64) from [<c0989634>] (clk_aic32x4_pll_calc_muldiv+0xe8/0x134)
    [ 941.227497] [<c0989634>] (clk_aic32x4_pll_calc_muldiv) from [<c09896ac>] (clk_aic32x4_pll_round_rate+0x2c/0x68)
    [ 941.237605] [<c09896ac>] (clk_aic32x4_pll_round_rate) from [<c05acab0>] (clk_core_determine_round_nolock.part.0+0x44/0x60)
    [ 941.248670] [<c05acab0>] (clk_core_determine_round_nolock.part.0) from [<c05ada18>] (clk_round_rate+0x5c/0xe0)
    [ 941.258689] [<c05ada18>] (clk_round_rate) from [<c0987fcc>] (aic32x4_hw_params+0x270/0x4ec)
    [ 941.267059] [<c0987fcc>] (aic32x4_hw_params) from [<c097e6d8>] (snd_soc_dai_hw_params+0x5c/0xa4)
    [ 941.275859] [<c097e6d8>] (snd_soc_dai_hw_params) from [<c098039c>] (soc_pcm_hw_params+0x248/0x5b4)
    [ 941.284831] [<c098039c>] (soc_pcm_hw_params) from [<c0964634>] (snd_pcm_hw_params+0x118/0x388)
    [ 941.293457] [<c0964634>] (snd_pcm_hw_params) from [<c0965e88>] (snd_pcm_common_ioctl+0x250/0x1118)
    [ 941.302441] [<c0965e88>] (snd_pcm_common_ioctl) from [<c02d9af8>] (do_vfs_ioctl+0x404/0x7c8)
    [ 941.310886] [<c02d9af8>] (do_vfs_ioctl) from [<c02d9ef0>] (ksys_ioctl+0x34/0x60)
    [ 941.318292] [<c02d9ef0>] (ksys_ioctl) from [<c0101000>] (ret_fast_syscall+0x0/0x54)
    [ 941.325949] Exception stack(0xd1cd9fa8 to 0xd1cd9ff0)
    [ 941.331007] 9fa0: bef82680 004fdd98 00000004 c25c4111 bef82680 0002000e
    [ 941.339201] 9fc0: bef82680 004fdd98 004fdd48 00000036 bef822b0 004f33f8 bef822c0 0000ac44
    [ 941.347386] 9fe0: b6f46844 bef821e4 b6ee002b b6e10418
    [ 941.355365]tlv320aic32x4 0-0018: Could not set clocks to support sample rate.
    aplay: pcm_write:2058: write error: Input/output error

    Thanks,
    Nishimura

  • What's the sampre rate/bit clk/and Mclk in the error case?

  • Hi,

    I'm not familiar with setting up the device tree, so I'm worried if I can meet your request correctly.
    The following is set.

    "WAV" file for testing;
      'loop3.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo

    SAI1
      24MHz -> HSE -> DIVM3(/2) -> DIVN3(x34) -> DIVP3(/2) = PLL3P
      PLL3P -> ACUDIV(/1) -> APB2DIV(/2) = 104.438965MHz(PCLK2)

    SAI1_K
      24MHz -> HSE -> DIVM3(/2) -> DIVN3(x34) -> DIVQ3(/17) = 24.573874MHz(PLL3Q)


    / {
      ・・・
      sound: sound {
        compatible = "simple-audio-card";
        simple-audio-card,name = "IoTGateway-S";
        simple-audio-card,format = "i2s";
        simple-audio-card,bitclock-master = <&dailink_master>;
        simple-audio-card,frame-master = <&dailink_master>;
      ・・・
        simple-audio-card,cpu {
          sound-dai = <&sai1a>;
        };

        dailink_master: simple-audio-card,codec {
          sound-dai = <&tlv3206_codec>;
          clocks = <&rcc SAI1>;
        };
      ・・・
    }; /*root*/

    &i2c4 {
      ・・・
      i2c-scl-rising-time-ns = <185>;
      i2c-scl-falling-time-ns = <20>;
      clock-frequency = <400000>;
      ・・・
      tlv3206_codec: tlv320aic32x6@18 {
        compatible = "ti,tlv320aic32x6";
        #sound-dai-cells = <0>;
        reg = <0x18>;

        clocks = <&sai1a>;
        clock-names = "mclk";
      ・・・
      };
    };

    &sai1 {
      clocks = <&rcc SAI1>, <&rcc PLL3_Q>, <&rcc PLL3_R>;
      clock-names = "pclk", "x8k", "x11k";
      ・・・
      sai1a: audio-controller@4400a004 {
        ・・・
        clocks = <&rcc SAI1_K>;
        clock-names = "sai_ck";
        ・・・
      };
    };

    Thanks,
    Nishimura

  • Hi

    Five days ago, you have show me the log which shows that sound card has been registered to the system.

    Kindly check the mclk. bck, and ws clk with scope. I'will check the clk first. because the log yesterday told me that "Division by zero" in clk_aic32x4_pll_calc_muldiv called by aic32x4_hw_params. You may as well add some log these functions.

  • Hi,

    I'm checking mclk, but I can't solve the problem...
    Is there a problem with my device tree?

    wiki.st.com/.../SAI_device_tree_configuration

    Thanks,
    Nishimura

  • I think using scope to measure MCLK, bck clk and fyans clk pin is the best  way to check the issue first.

    After this, we can judge whether ii is config issue.

  • Hi,

    I checked each signal with an oscilloscope.
    It changes to the following state when Linux starts, but it does not change even if the aplay command is executed.

    MCLK = 3.3V
    WCLK(FSA) = 3.3V
    BCLK(SCKA) = 0.0V

    Thanks,
    Nishimura

  • Hi Nishimura,

    Thank you for your patience while we look into this for you. This may take some time.

    Best Regards,

    Jeff

  • Hi Nishimura

    For MCLK./WCLK/BCLK from platform, kindly offer the frequency instead of the voltage. kindly capture the picture with me.

    One more thing, why there's no bclk?

    Thanks

  • Hi,

    I'm sorry, there was a typo.
    The correct answer is as follows.

    MCLK = 0V
    WCLK(FSA) = 3.3V
    BCLK(SCKA) = 3.3V

    BCLK and WCLK change to 3.3V when Linux boots.
    After that, it does not change even if you execute the aplay command.
    That is, there is no frequency.

    # cat /sys/kernel/debug/clk/clk_summary
    My Board;
    pll3 1 1 0 417755859 0 0 50000
    pll3_r 0 0 0 11290699 0 0 50000
    pll3_q 0 0 0 24573875 0 0 47058
    adfsdm_k 0 0 0 24573875 0 0 50000
    sai1_k 0 0 0 24573875 0 0 50000
    sai1a_mclk 0 0 0 0 0 0 50000


    STM32MP157D-DK1;
    pll3 1 1 0 417755859 0 0 50000
    pll3_r 0 0 0 11290699 0 0 50000
    pll3_q 0 0 0 24573875 0 0 47058
    sai2_k 0 0 0 24573875 0 0 50000
    sai2a_mclk 0 0 0 0 0 0 50000

    After aplay command
    pll3 1 1 0 417755859 0 0 50000
    pll3_r 0 0 0 11290699 0 0 50000
    sai2_k 1 1 0 11290699 0 0 50000
    sai2a_mclk 1 1 0 11290699 0 0 50000
    pll3_q 0 0 0 24573875 0 0 47058

    Thanks,
    Nishimura

  • Tell me where you get the code.

  • For the clk issue, kindly consult the platform vendor.

  • Hi,

    BSP can be obtained from the following sites. I'm using 2.1.0.

    www.st.com/.../stm32mp1dev.html
    STM32MP1 OpenSTLinux Developer Package 2.1.0

    Does the TLV320AIC32x4 driver set the clock when executing the aplay command?

    # aplay loop3.wav
    Playing WAVE 'loop3.wav' : Signed 16 bit Little Endian, Rate 44100

    [ 233.977836] ASoC tlv320aic32x4 codec driver : aic32x4_hw_params()
    [ 233.984007] ASoC tlv320aic32x4 codec driver : aic32x4_setup_clocks() sample_rate=44100
    [ 233.992007] ASoC tlv320aic32x4 codec driver : aic32x4_set_processing_blocks()

    Thanks,
    Nishimura

  • If you set 3206E as master, it will output the clk. If set as slave, it can't output clk.

    One more thing, I want confirmed from you that the clk pin you have measured is from paltform side or 3206E side.

  • Hi, 

    I'm checking the clock settings.
    It turns out that the problem is caused by the failure of aic32x4_setup_clocks ().
    Successful cs42l51 calls ".set_sysclk", ".hw_params" after the aplay command.
    However, in TLV320AIC32x4, ".hw_params" is called first.
    Do you know why ".set_sysclk" is not called?

    static const struct snd_soc_dai_ops aic32x4_ops = {
     .hw_params = aic32x4_hw_params,
     .digital_mute = aic32x4_mute,
     .set_fmt = aic32x4_set_dai_fmt,
     .set_sysclk = aic32x4_set_dai_sysclk,
    };

    Thanks,

    Nishimura

  • Hi Nishimura

    Kindly remove .symmetric_rates=1; 

    Can we have a conf-call, my mail address is shenghao-ding@ti.com?

  • Hi,

    Thanks for your comment, I'll try it tomorrow.

    How can I switch between SND_SOC_DAIFMT_CBM_CFM and SND_SOC_DAIFMT_CBS_CFS in the aic32x4_set_dai_fmt() function?
    Is it a device tree? Or is it need to customize the driver?

    I'm sorry, I don't speak English well so I would like to exchange information by email.

    Thanks,
    Nishimura

  • Hi, Nishimura

    In aic32x4_set_dai_fmt, we have implement following code.

    switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
    case SND_SOC_DAIFMT_CBM_CFM:
    iface_reg_1 |= AIC32X4_BCLKMASTER | AIC32X4_WCLKMASTER;
    break;
    case SND_SOC_DAIFMT_CBS_CFS:
    break;
    default:
    printk(KERN_ERR "aic32x4: invalid DAI master/slave interface\n");
    return -EINVAL;
    }

    As to device tree setting, can you share the dst setting for CS. I'll check it. Thanks.

    BR

  • Hi,

    I tried some settings like below but couldn't find the correct one.

    fsl,mode = "i2s-slave"; // freescale?

    The fmt parameter did not change at 0x1001.

    Thanks,
    Nishimura

  • I'm not familiar with freescale setting. Hope the attachment can help you. At the bottom of Page 14

    AN5125 - device tree.pdf

  • Hi,

    I am using STM32MP157D.
    I tried "fsl.mode" because I couldn't find the definition of switching between master and slave.
    However, this was either dedicated to the Freescale driver or didn't work.

    Thanks,
    Nishimura

  • Hi 

    You may as well consult with platform vendor or you may as well study the freescale-related code.

  • Hi,

    I removed ".symmetric_rates = 1;" from the driver but ".set_sysclk" was not called.

    Thanks,

    Nishimura

  • What is the Linux kernel version did CS chip run? Does CS chip and Ti chip run the same Linux system.

    I go through the soc code, it seemed that mclk-fs should be define in device tree, then set_sysclk will be called. Can you share the device tree setting for CS chip. I can check what is the difference.

    static void simple_parse_mclk_fs(struct device_node *top,
    struct device_node *cpu,
    struct device_node *codec,
    struct simple_dai_props *props,
    char *prefix)
    {
    struct device_node *node = of_get_parent(cpu);
    char prop[128];

    snprintf(prop, sizeof(prop), "%smclk-fs", PREFIX);
    of_property_read_u32(top, prop, &props->mclk_fs);

    snprintf(prop, sizeof(prop), "%smclk-fs", prefix);
    of_property_read_u32(node, prop, &props->mclk_fs);
    of_property_read_u32(cpu, prop, &props->mclk_fs);
    of_property_read_u32(codec, prop, &props->mclk_fs);

    of_node_put(node);
    }

  • Hi,

    CS and Ti are using the same Linux version.
    Linux arm 5.4.56

    "mclk-fs" is described in the device tree of CS and Ti.
    Can I attach a file?

    Device tree for CS (partial excerpt)
    / {
    ...
    sound {
    compatible = "audio-graph-card";
    label = "STM32MP1-DK";
    routing =
    "Playback" , "MCLK",
    "Capture" , "MCLK",
    "MICL" , "Mic Bias";
    dais = <&sai2a_port &sai2b_port &i2s2_port>;
    status = "okay";
    };
    ...
    };

    &i2c1 {
    pinctrl-names = "default", "sleep";
    pinctrl-0 = <&i2c1_pins_a>;
    pinctrl-1 = <&i2c1_pins_sleep_a>;
    i2c-scl-rising-time-ns = <100>;
    i2c-scl-falling-time-ns = <7>;
    status = "okay";
    /delete-property/dmas;
    /delete-property/dma-names;
    ...
    cs42l51: cs42l51@4a {
    compatible = "cirrus,cs42l51";
    reg = <0x4a>;
    #sound-dai-cells = <0>;
    VL-supply = <&v3v3>;
    VD-supply = <&v1v8_audio>;
    VA-supply = <&v1v8_audio>;
    VAHP-supply = <&v1v8_audio>;
    reset-gpios = <&gpiog 9 GPIO_ACTIVE_LOW>;
    clocks = <&sai2a>;
    clock-names = "MCLK";
    status = "okay";

    cs42l51_port: port {
    #address-cells = <1>;
    #size-cells = <0>;

    cs42l51_tx_endpoint: endpoint@0 {
    reg = <0>;
    remote-endpoint = <&sai2a_endpoint>;
    frame-master;
    bitclock-master;
    };

    cs42l51_rx_endpoint: endpoint@1 {
    reg = <1>;
    remote-endpoint = <&sai2b_endpoint>;
    frame-master;
    bitclock-master;
    };
    };
    };
    };

    &sai2 {
    clocks = <&rcc SAI2>, <&rcc PLL3_Q>, <&rcc PLL3_R>;
    clock-names = "pclk", "x8k", "x11k";
    pinctrl-names = "default", "sleep";
    pinctrl-0 = <&sai2a_pins_a>, <&sai2b_pins_b>;
    pinctrl-1 = <&sai2a_sleep_pins_a>, <&sai2b_sleep_pins_b>;
    status = "okay";

    sai2a: audio-controller@4400b004 {
    #clock-cells = <0>;
    dma-names = "tx";
    clocks = <&rcc SAI2_K>;
    clock-names = "sai_ck";
    status = "okay";

    sai2a_port: port {
    sai2a_endpoint: endpoint {
    remote-endpoint = <&cs42l51_tx_endpoint>;
    format = "i2s";
    mclk-fs = <256>;
    dai-tdm-slot-num = <2>;
    dai-tdm-slot-width = <32>;
    };
    };
    };

    sai2b: audio-controller@4400b024 {
    dma-names = "rx";
    st,sync = <&sai2a 2>;
    clocks = <&rcc SAI2_K>, <&sai2a>;
    clock-names = "sai_ck", "MCLK";
    status = "okay";

    sai2b_port: port {
    sai2b_endpoint: endpoint {
    remote-endpoint = <&cs42l51_rx_endpoint>;
    format = "i2s";
    mclk-fs = <256>;
    dai-tdm-slot-num = <2>;
    dai-tdm-slot-width = <32>;
    };
    };
    };
    };

    Thanks,
    Nishimura