Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Device tree overlay for I2S ADC (via McASP peripheral) on BeagleBone Black #227

Open
thylacine1975 opened this issue Jun 14, 2022 · 0 comments

Comments

@thylacine1975
Copy link

Hi all,

We're trying to connect an ADC (AD4134) to the McASP peripheral of the beaglebone black (AM335x), but are having some issues getting it to work.

We have a created a device tree overlay by trying to piece together a number of different resources, including:
https://elixir.bootlin.com/linux/v4.19.94/source/Documentation/devicetree/bindings/sound/davinci-mcasp-audio.txt
https://elixir.bootlin.com/linux/v4.19.94/source/Documentation/devicetree/bindings/sound/simple-card.txt
https://kilobaser.com/beaglebone-black-device-tree-overlay-generator/

Our kernel version is v4.19.94

/*
 *  Enables mcasp0 pins on BBB header to allow communication with the external
 *  ADC
 *
 *  dtc -O dtb -o /lib/firmware/ad4134.dtbo -b 0 -@ ad4134.dts
 *  dtc -O dtb -o ad4134.dtbo -b 0 -@ ad4134.dts
 */


/dts-v1/;
/plugin/;

/ {
        compatible = "ti,beaglebone-black";
        part-number = "AD4134";
        version = "00A0";

        exclusive-use =
      "P9.41", "mcasp0_axr1",
      "P9.42B","mcasp0_aclkr",
      "P9.27","mcasp0_fsr";

    fragment@0 {
        target = <&am33xx_pinmux>;
        __overlay__ {
            bbb_i2s_pins: pinmux_bbb_i2s_pins {
                pinctrl-single,pins = <0x1a4 0x28 0x1a8 0x28 0x1a0 0x28>;
            };
        };
    };

    fragment@1 {
        target = <&mcasp0>;
        __overlay__ {
                status = "okay";
                pinctrl-names = "default";
                pinctrl-0 = <&bbb_i2s_pins>;
        };
    };


    mcasp0: mcasp0@1d0000 {
      compatible = "ti,am33xx-mcasp-audio";
      reg = <0x46400000>;
      reg-names = "mpu";
      op-mode = <0>;
      tdm-slots = <4>;
      serial-dir = <    // 0: INACTIVE, 1: TX, 2: RX
                    2 2 2 2>;
      /* dmas = <>;
      dma-names = "rx"; */
      tx-num-evt = <1>;
      rx-num-evt = <1>;
    };


    sound: sound@0 {
      compatible = "simple-audio-card";
      simple-audio-card,name = "AD4134";
      simple-audio-card,mcasp-controller = <&mcasp0>;

      simple-audio-card,widgets =
              "Line", "Line In Geophone 1",
              "Line", "Line In Geophone 2",
              "Line", "Line In Geophone 3",
              "Line", "Line In Empty";

      simple-audio-card,routing =
              "Line In Geophone 1", "Geophone_1",
              "Line In Geophone 2", "Geophone_2",
              "Line In Geophone 3", "Geophone_3",
              "Line In Empty", "Dummy_ADC";


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

  };

There are 3 outputs from the ADC;

  • Clock out
  • Data out
  • Data framing

The data out is formatted as 4x 24 bit adc readings
The data framing pulse is either side of the set of 4 readings
So the beaglebone doesn't need to generate any signals, just receive

We are able to compile this file, but it gives a number of warnings:
dtc -O dtb -o ad4134.dtbo -b 0 -@ ad4134.dts

ad4134.dtbo: Warning (unit_address_vs_reg): /sound@0: node has a unit name, but no reg property
ad4134.dtbo: Warning (pci_device_reg): Failed prerequisite 'reg_format'
ad4134.dtbo: Warning (pci_device_bus_num): Failed prerequisite 'reg_format'
ad4134.dtbo: Warning (simple_bus_reg): Failed prerequisite 'reg_format'
ad4134.dtbo: Warning (avoid_default_addr_size): /mcasp0@1d0000: Relying on default #address-cells value
ad4134.dtbo: Warning (avoid_default_addr_size): /mcasp0@1d0000: Relying on default #size-cells value
ad4134.dtbo: Warning (avoid_unnecessary_addr_size): Failed prerequisite 'avoid_default_addr_size'
ad4134.dtbo: Warning (unique_unit_address): Failed prerequisite 'avoid_default_addr_size'
ad4134.dtbo: Warning (sound_dai_property): /sound@0/simple-audio-card,cpu: Missing property '#sound-dai-cells' in node /mcasp0@1d0000 or bad phandle (referred from sound-dai[0])

It seems that a number of these warnings are related to the 'reg' parameter. In almost all of the other examples we've seen, this is omitted from the file but according to the linux documentation linked above, it is a required property.

The documentation also says that dmas is a required field, but again, none of the examples include this. Any advice on this and the reg field would be greatly appreciated.

When loading the compiled .dtbo file using /boot/uEnv.txt

###Additional custom capes
uboot_overlay_addr4=/lib/firmware/ad4134.dtbo

and rebooting the beaglebone, the beaglebone is able to start happily, but it doesn't appear to have worked.
We were judging 'working' off the output of arecord -L

null
    Discard all samples (playback) or generate zero samples (capture)
onboard
onboard_capture_left
onboard_playback_left
onboard_capture_right
onboard_playback_right
plug_onboard_capture_left
plug_onboard_playback_left
default

and hoping that it would list the mcasp peripheral as a device to be used for capture, in the same way that aplay -L lists a number of devices

null
    Discard all samples (playback) or generate zero samples (capture)
onboard
onboard_capture_left
onboard_playback_left
onboard_capture_right
onboard_playback_right
plug_onboard_capture_left
plug_onboard_playback_left
default
sysdefault:CARD=Black
    TI BeagleBone Black, davinci-mcasp.0-i2s-hifi i2s-hifi-0
    Default Audio Device
dmix:CARD=Black,DEV=0
    TI BeagleBone Black, davinci-mcasp.0-i2s-hifi i2s-hifi-0
    Direct sample mixing device
dsnoop:CARD=Black,DEV=0
    TI BeagleBone Black, davinci-mcasp.0-i2s-hifi i2s-hifi-0
    Direct sample snooping device
hw:CARD=Black,DEV=0
    TI BeagleBone Black, davinci-mcasp.0-i2s-hifi i2s-hifi-0
    Direct hardware device without any conversions
plughw:CARD=Black,DEV=0
    TI BeagleBone Black, davinci-mcasp.0-i2s-hifi i2s-hifi-0
    Hardware device with all software conversions

Any pointers on what we might be doing wrong, or how to better connect the ADC to the beaglebone so that we can record the measurements that it makes would be greatly appreciated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant