Cape4All (multichannel audio card connected via mcasp) for BBAI-64?

Hello, I am trying to find out if (and how) it would be possible to use the Cape4All (GitHub - HoerTech-gGmbH/Cape4all: Open Hardware Multichannel Sound Interface for Hearing Aid Research on Beaglebone Black) working on the BBAI-64. Looking at the forum posts, I’m still not sure if the mcasp is supported at all, or if it is “merely” a matter of writing the appropriate magic in the k3-j721e-beagleboneai64.dts file (see the patch in the github project).

The Cape4All basically has 3 ADAU1761 codecs on the mcasp interface, along with an EEPROM, using pins 19, 20, 25, 28, 29, 30 and 31 on P9, the last 4 seeming to be the ones carrying the high-speed data (BCLK ca. 6MHz) thus on the mcasp.

I see that in /opt/source/dtb-5.10-ti-arm64/src/arm64/k3-j721e-common-proc-board.dts there is a definition for mcasp10 (pin assignments and configuration), but in k3-j721e-beagleboneai64.dts all mcasp interfaces are disabled; would it be possible to write appropriate stanzas into k3-j721e-beagleboneai64.dts to get one of the mcasps onto the pins? Or some other pins?

The next problem would of course be the kernel drivers, but one problem at a time… and hopefully the boneblack-audio-extension source could be ported to an up-to-date kernel - but if the mcasp is not useable, there is no point looking at that yet.

Any help would be appreciated, I’m still learning much about device tree specifications and overlays.

Cheers,
psychoacoustic

It looks possible.

P9-19 & 20 are I2C2. I assume the eeprom is for the cape ID. Potentially you could just ignore this.

PP28-31 have pin muxing for MCASP0. You will more than likely have to make your own DTS file for that though. Just create an overlay and set the status to “okay” to enable the peripheral and include some pin muxing.

If you drill down /opt/source/dtsxxx/src/arm64 ( or there abouts) you will find the source for the current overlays. They should get you started.

Hi, thanks for the vote of confidence! I’m starting to work on it, let’s see how far I get…

Unfortunately, that is not the case. The ADAU1761s are wired into the i2c bus to control them. In the dts there is this block:

&i2c2 {
	pinctrl-names = "default";
	pinctrl-0 = <&i2c2_pins>;

	status = "okay";
	clock-frequency = <100000>;

	codec0: adau1761@38 {
		#sound-dai-cells = <0>;
		compatible = "adi,adau1761";
		reg = <0x38>;
		status = "okay";
	};

	codec1: adau1761@39 {
		#sound-dai-cells = <0>;
		compatible = "adi,adau1761";
		reg = <0x39>;
		status = "okay";
	};

	codec2: adau1761@3a {
		#sound-dai-cells = <0>;
		compatible = "adi,adau1761";
		reg = <0x3a>;
		status = "okay";
	};
};

So I have to somehow get that in there aswell. In k3-j721e-beagleboneai64.dts there are pins defined for main_i2c for 0,1,3-5; i2c2 is not yet defined, but that should not be too hard (address 0x208 and 0x20c, mode 4, AFAICT)

I’ve made a start with

        mcasp0_pins: mcasp0_pins {
                pinctrl-single,pins = <
                        /* P9.25(B) MCLK, should be 24.576MHz. Not sure what mode is appropiate 3 seems to make most sense (AUDIO_EXT_REFCLK2) */
                        J721E_IOPAD(0x1a4, PIN_INPUT_PULLUP, 3)
                        /* P9.28(B) MCASP0_AXR0 DAC (output) */
                        J721E_IOPAD(0x0b0, PIN_OUTPUT_PULLDOWN, 12)
                        /* P9.29(B) MCASP0_AFSX (frame sync outpu) */
                        J721E_IOPAD(0x0d8, PIN_OUTPUT_PULLUP, 12)
                        /* P9.30(B) MCASP0_AXR1 ADC (input) */
                        J721E_IOPAD(0x0b4, PIN_INPUT_PULLUP, 12)
                        /* P9.31(B) MCASP0_ACLK (bit clock, should be 6.144MHz) */
                        J721E_IOPAD(0x0d4, PIN_OUTPUT_PULLDOWN, 12)
                        /* not sure about the next one, it was labeled Y4 MCLK oscillator disable in the boneblack audio extension dts */
                        /* it was MODE7 in register 0x86c on the am335x (conf_gpmc_a11) */
                        /* J721E_IOPAD(UNKNOWN, PIN_INPUT_PULLUP | MUX_MODE7) */
                >;
        };

in the &main_pmx0 node, and a new node

&mcasp0 {
        #sound-dai-cells = <0>;
        status = "okay";
        pinctrl-names = "default";
        pinctrl-0 = <&mcasp0_pins>;

        op-mode = <0>;
        tdm-slots = <8>;
        serial-dir = <
                2 0 1 0
                0 0 0 0
                0 0 0 0
                0 0 0 0
        >;
        tx-num-evt = <1>;
        rx-num-evt = <1>;
};

but I am not sure how to properly rout the clock yet.

So far, I’m directly editing k3-j721e-beagleboneai64.dts - because I don’t actually know (yet) how I could start the BB-AI64 with an overlay, never mind modifying the build scripts etc. I’ll leave that as cleanup for later…

And how the %&§! do I debug this stuff anyways?

I’ll keep posting updates hopefully people will point out my mistakes and/or learn from them :slight_smile:

Cheers,
psychoacoustic

Most of it does not look too complicated to do.

I did manage to import the schematic into kicad and yes I can see the i2C goes to the codec.

The exception to this is probably MCLK on the BBB. The same pin is described as audio_ref_clk on the BBAI-64. Setting this to the correct speed will probably be the most painful part of getting it to work.

Good luck with the mcasp and the clock, I think you may need it!

AI-64: Page 6 - Bela and onwards