ADAU1372 on Beaglebone Black

I'm trying to compile the ADAU1372 modules for the Beaglebone Black and not having much luck.  I noted that the supposedly mainlined ADAU1373 didn't pop up as an option in my menuconfig, either, so I figured I finally needed to ask folks here as I'm clearly not doing something right.

To compile, I do the following (I'm on Ubuntu 16.10, but that shouldn't be that important since this is a cross compile):

git clone github.com/.../ti-linux-kernel-dev.git
cd ti-linux-kernel-dev
git checkout tags/4.4.54-ti-r93
git checkout -b 4.4.54-ti-r93-adau1372
./build_kernel.sh

After letting that grind away a bit and getting all of the prerequisites downloaded, a "make menuconfig" window pops up.  When I go down into "Device Drivers"->"Sound card support"->"Advanced Linux Sound Architecture"->"ALSA for SoC audio support"->"CODEC drivers"  I see that neither the ADAU1372 that I tried to add nor the ADAU1373 which is supposed to be mainlined are present.

Where and how do I add the adau1372 modules in order to get them to compile?

Thanks.

  • It would sure be nice to start from a known good board and configuration if I'm going to have to start backporting patches.

    What Linux board are you folks using to test these modules?  I'm happy to buy the board if it means that I have identical hardware to the people developing these drivers.

  • Okay.

    Should I send you folks a Beaglebone Black as a way to encourage these drivers to be checked out against hardware that exists off the shelf?

    I can assure you that the TI-favoring contingent in my company is having more than a little bit of schadenfreude at my expense right now.

  • Okay, I managed to get the drivers compiled into modules and it seems like I got things installed after I figured out which modules to insmod manually in which order to resolve the symbols:

    root@beaglebone:~# lsmod | sort
    <... deleted ...>
    snd                    72473  3 snd_soc_core,snd_timer,snd_pcm
    snd_pcm               104314  3 snd_soc_core,snd_pcm_dmaengine,snd_soc_adau1372
    snd_pcm_dmaengine       5894  1 snd_soc_core
    snd_soc_adau1372       33838  1 snd_soc_adau1372_i2c
    snd_soc_adau1372_i2c    1549  0
    snd_soc_adau_utils      1389  1 snd_soc_adau1372
    snd_soc_core          190453  2 snd_soc_adau1372_i2c,snd_soc_adau1372
    snd_timer              24761  1 snd_pcm
    soundcore               8661  1 snd
    <... deleted ...>

     

    However, when I attempt to play something:

     

    root@beaglebone:~# aplay -l
    aplay: device_list:268: no soundcards found...
    root@beaglebone:~# speaker-test -c 2

    speaker-test 1.0.28

    Playback device is default
    Stream parameters are 48000Hz, S16_LE, 2 channels
    Using 16 octaves of pink noise
    ALSA lib confmisc.c:768:(parse_card) cannot find card '0'
    ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
    ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
    ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
    ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name
    ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM default
    Playback open error: -2,No such file or directory

     

    So, what's my next step?  Is this an ALSA configuration issue, or is this a device tree overlay issue that I need to go beat on?

     

    Thanks.

     

    Edit: "Currently being moderated."  Odd.  Wonder what I did to trip a spam filter ...

  • Hi,

    There are a few things to consider. Since the hardware is not self-describing or on an enumerable bus you need to provide a description of how the CODEC is wired up in your setup. This can be done using a devicetree entry. The CODEC driver needs at least the SPI/I2C address and a reference to the MCLK provider.

    A devicetree entry for I2C could look like this:

    adau1372: codec@3c {
       compatible = "adi,adau1372";
       reg = <0x3c>;

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

    The other thing to consider is that the CODEC driver is just that. Only a CODEC driver. The final soundcard is made up of the combination of multiple components. For example in your case the host I2S controller, host DMA and the CODEC. You need to provide a description how these components are connected. One way to do this is using the simple-card devicetree binding.

    - Lars

  • Okay, at this point I'm stuck.  I need some help to figure this out.  Can someone send me an overlay file that is known to work (even on different hardware)?  Here is what I have:

    modprobe seems to do the right thing.  The appropriate kernel modules get found and loaded:

    root@beaglebone:~# modprobe snd-soc-adau1372-i2c
    root@beaglebone:~# lsmod | grep snd
    snd_soc_adau1372_i2c     1549  0
    snd_soc_adau1372       33838  1 snd_soc_adau1372_i2c
    snd_soc_adau_utils      1389  1 snd_soc_adau1372
    snd_soc_core          190930  2 snd_soc_adau1372_i2c,snd_soc_adau1372
    snd_pcm_dmaengine       5894  1 snd_soc_core
    snd_pcm               103892  3 snd_soc_core,snd_pcm_dmaengine,snd_soc_adau1372
    snd_timer              24844  1 snd_pcm
    snd                    72703  3 snd_soc_core,snd_timer,snd_pcm
    soundcore               8625  1 snd

     

    Loading a cape ... not so much:

     

    root@beaglebone:~# echo BB-BONE-ADAU1372 >/sys/devices/platform/bone_capemgr/slots
    -bash: echo: write error: Invalid argument
     
    The hangup from dmesg:
    [  217.756236] bone_capemgr bone_capemgr: part_number 'BB-BONE-ADAU1372', version 'N/A'
    [  217.756289] bone_capemgr bone_capemgr: slot #5: override
    [  217.756312] bone_capemgr bone_capemgr: Using override eeprom data at slot 5
    [  217.756338] bone_capemgr bone_capemgr: slot #5: 'Override Board Name,00A0,Override Manuf,BB-BONE-ADAU1372'
    [  217.769788] of_resolve_phandles: Could not find symbol 'audio_clock'
    [  217.776389] bone_capemgr bone_capemgr: slot #5: Failed to resolve tree

     

    I can't even *FIND* that symbol in relevant source code or overlays.  My trusty "find . -type f -exec grep -i audio_clock {} /dev/null \; 2>/dev/null" pulls up a few references, all of which appear to be dead ends.  I would love to know how to even locate where that symbol is coming from...

     

    Thanks.

     

    My overlay file "BB-BONE-ADAU1372-01-00A0.dts":

     

    /*
    * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
    *
    * This program is free software; you can redistribute it and/or modify
    * it under the terms of the GNU General Public License version 2 as
    * published by the Free Software Foundation.
    */
    /dts-v1/;
    /plugin/;

    #include <dt-bindings/gpio/gpio.h>
    #include <dt-bindings/pinctrl/am33xx.h>

    / {
    compatible = "ti,beaglebone", "ti,beaglebone-black", "ti,beaglebone-green";

    /* identification */
    part-number = "BB-BONE-ADAU1372-01";
    version = "00A0", "A0";

    /* state the resources this cape uses */
    exclusive-use =
      /* the pin header uses */
      "P9.41", /* mcasp0: mcasp0_axr1 */
      "P9.31", /* mcasp0: mcasp0_aclkx */
      "P9.30", /* mcasp0: mcasp0_axr0 */
      "P9.29", /* mcasp0: mcasp0_fsx */
      "P9.28", /* mcasp0: mcasp0_axr2 */
      "P9.25", /* mcasp0: mcasp0_ahclkx */
      "P9.30", /* mcasp0: mcasp0_axr0 */
      /* the hardware ip uses */
      "gpio3_21",
      "mcasp0";

    fragment@0 {
      target = <&am33xx_pinmux>;
      __overlay__ {
       bone_audio_cape_audio_pins: pinmux_bone_audio_cape_audio_pins {
        pinctrl-single,pins = <
         0x190 (PIN_INPUT_PULLDOWN | MUX_MODE0) /* mcasp0_aclkx.mcasp0_aclkx */
         0x194 (PIN_INPUT_PULLDOWN | MUX_MODE0) /* mcasp0_fsx.mcasp0_fsx, INPUT */
         0x198 (PIN_INPUT_PULLDOWN | MUX_MODE0) /* mcasp0_axr0.mcasp0_axr0 */
         0x19c (PIN_INPUT_PULLDOWN | MUX_MODE2) /* mcasp0_ahclkr.mcasp0_axr2 */
         0x1a8 (PIN_INPUT_PULLDOWN | MUX_MODE0) /* mcasp0_axr1 */
         0x1ac (PIN_INPUT_PULLDOWN | MUX_MODE0) /* MCASP0_AHCLKX -> MCASP0_AHCLKX (I2S_MCLK_OUT)- in */
         0x1b4 (PIN_INPUT | MUX_MODE7) /* gpio0_20 in input mode to avoid interfering on P9.41 */
        >;
       };
      };
    };

    fragment@1 {
      target = <&i2c2>;
      __overlay__ {
       #address-cells = <1>;
       #size-cells = <0>;
       clock-frequency = <100000>;
       status = "okay";
       pinctrl-names = "default";
       pinctrl-0 = <&i2c2_pins>;

       adau1372: adau1372@3D {
        #sound-dai-cells = <0>;
        compatible = "adi,adau1372";
        reg = <0x3D>;
       };
      };
    };

    fragment@2 {
      target = <&mcasp0>;
      __overlay__ {
       #sound-dai-cells = <0>;
       pinctrl-names = "default";
       pinctrl-0 = <&bone_audio_cape_audio_pins>;
       status = "okay";
       op-mode = <0>;          /* MCASP_IIS_MODE */
       tdm-slots = <2>;
       num-serializer = <16>;
       serial-dir = <  /* 0: INACTIVE, 1: TX, 2: RX */
        2 0 1 0
        0 0 0 0
        0 0 0 0
        0 0 0 0
       >;
       tx-num-evt = <1>;
       rx-num-evt = <1>;
      };
    };


    fragment@3 {
      target-path="/";
      __overlay__ {
       sound {
        compatible = "simple-audio-card";
        simple-audio-card,name = "ADAU1372 Audio Cape";
        simple-audio-card,widgets =
         "Headphone", "Headphone Jack",
         "Line", "Line In";
        simple-audio-card,routing =
         "Headphone Jack",       "HPLOUT",
         "Headphone Jack",       "HPROUT",
         "LINE1L",               "Line In",
         "LINE1R",               "Line In";
        simple-audio-card,format = "dsp_b";
        simple-audio-card,bitclock-master = <&sound_master>;
        simple-audio-card,frame-master = <&sound_master>;
        simple-audio-card,bitclock-inversion;

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

                      sound_master: simple-audio-card,codec {
         #sound-dai-cells = <0>;
         sound-dai = <&adau1372>;
         clocks = <&clk_mcasp0>;
         clock-names = "mclk";
        };
       };
      };

    };
    };