Changing BB-BONE-AUDI-02-00A0 from McASP AXR2 to AXR3

So I wanted to make my own audio cape with 4 channels (and eventually 8).
Picture: https://dl.dropboxusercontent.com/u/82765462/BBB/4channel_audioCape.jpg

Right now I am running the clocks and i2s to a multichannel USB ADC/DAC which is working great off AXR2.

A basic first step is I wanted to change the boardzoo audio cape to using McASP_AXR3 by changing the device tree for BB-BONE-AUDI-02-00A0.dts from AXR2 to AXR3.

First off the comments in the dts file seem incorrect in some cases but thats ok, I got through it.

So I changed in the default dts file:
From:

/* state the resources this cape uses */

exclusive-use =

/* the pin header uses */

“P9.31”, /* mcasp0: mcasp0_aclkx */

“P9.29”, /* mcasp0: mcasp0_fsx */

“P9.28”, /* mcasp0: mcasp0_axr2 */

“P9.25”, /* mcasp0: mcasp0_ahclkx */

/* the hardware ip uses */

“gpio1_18”, “gpio1_19”,

“mcasp0”;

To:

/* state the resources this cape uses */

exclusive-use =

/* the pin header uses */

“P9.31”, /* mcasp0: mcasp0_aclkx */

“P9.29”, /* mcasp0: mcasp0_fsx */

“P9.27”, /* mcasp0: mcasp0_axr3 */

“P9.25”, /* mcasp0: mcasp0_ahclkx */

/* the hardware ip uses */

“gpio1_18”, “gpio1_19”,

“mcasp0”;

And the pinmux from:

bone_audio_cape_audio_pins: pinmux_bone_audio_cape_audio_pins {

pinctrl-single,pins = <

0x1ac 0x00 /* mcasp0_ahclkx, MODE0 | INPUT */

0x19c 0x22 /* mcasp0_axr2, */

0x194 0x20 /* mcasp0_fsx, MODE0 | OUTPUT */

0x190 0x20 /* mcasp0_aclkr.mcasp0_aclkx, MODE0 | OUTPUT_PULLDOWN */

0x198 0x20

;

To:

bone_audio_cape_audio_pins: pinmux_bone_audio_cape_audio_pins {

pinctrl-single,pins = <

0x1ac 0x00 /* mcasp0_ahclkx, MODE0 | INPUT */

0x1a4 0x22 /* mcasp0_axr3, */

0x194 0x20 /* mcasp0_fsx, MODE0 | OUTPUT */

0x190 0x20 /* mcasp0_aclkr.mcasp0_aclkx, MODE0 | OUTPUT_PULLDOWN */

0x198 0x20

;

Also changed the serializer from:

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>;

};

To:

op-mode = <0>; /* MCASP_IIS_MODE */

tdm-slots = <2>;

num-serializer = <16>;

serial-dir = < /* 0: INACTIVE, 1: TX, 2: RX */

2 0 0 1

0 0 0 0

0 0 0 0

0 0 0 0

;

tx-num-evt = <1>;

rx-num-evt = <1>;

};

};

Original file: https://dl.dropboxusercontent.com/u/82765462/BBB/BB-BONE-AUDI-02-00A0.dts

AXR2 to AXR3 changes outlined above: https://dl.dropboxusercontent.com/u/82765462/BBB/BB-BONE-AUDI-02-00A0swap.dts

Then I simply did:

cd /lib/firmware

**dtc -O dtb -o BB-BONE-AUDI-02-00A0.dtbo -b 0 -@ BB-BONE-AUDI-02-00A0swap.dts**
And reboot. 
When I play audio though it still comes out the old AXR2 i2s!!!

Eventually I want both AXR2 and AXR3 so I can get 2 stereo channels output. Then eventually 6 channels, 8 etc… what HDMI intended…

Anyways! Wondering where I went wrong in the device tree before I start mucking with tlv320aic3x.c, davinci-mcasp.c and davinci-evm.c

Thanks in advance!
-Jesse

Try the attached DTS and make the necessary changes. The DTS you are working from doesn’t make any sense to me. Looking at the serializer, 1 is for TX, but the GPIO shows AXR3 as an input. Also, the DTS doesn’t show have a mux for both AXR0 and AXR3. BTW, each channel is a stereo channel, supporting both left and right audio streams.

Regards,
John

BB-BONE-AUDI-03-00A0.dts (2.44 KB)

Thanks John,
Your DTS file comments make a lot more sense.

For some reason though even with your DTS file I change AXR2 to AXR3, recompile the DTS and the stereo audio is still coming from AXR2!

Here is my version of your file: https://dl.dropboxusercontent.com/u/82765462/BBB/McASP_mods/BB-BONE-AUDI-02-00A0_AXR3.dts

Your original pins: https://dl.dropboxusercontent.com/u/82765462/BBB/McASP_mods/BB-BONE-AUDI-02-00A0.dts

Nevermind my environment must be messed up.
I deleted the DTS files from cd /lib/firmware for the audio cape, rebooted and the audio cape still works!

I must be picking up the default dts file from somewhere else…

Shipped capes are built-into the kernel. Rename the file..

Regards,

Nevermind my environment must be messed up.
I deleted the DTS files from cd /lib/firmware for the audio cape,
rebooted
and the audio cape still works!

I must be picking up the default dts file from somewhere else...

Shipped capes are built-into the kernel. Rename the file..

Yeah, the name of the file I sent Jesse was BB-BONE-AUDIO-03-00A0

Regards,
John

Doh, thanks guys.

Changing:

nano /etc/default/capemgr

to:

CAPE=BB-BONE-AUDI-03

And using a different filename like John had, reboot.

root@beaglebone:~# cat /sys/devices/bone_capemgr*/slots

0: 54:PF—

1: 55:PF—

2: 56:PF—

3: 57:PF—

4: ff:P-O-L Bone-LT-eMMC-2G,00A0,Texas Instrument,BB-BONE-EMMC-2G

5: ff:P-O-- Bone-Black-HDMI,00A0,Texas Instrument,BB-BONELT-HDMI

6: ff:P-O-L Bone-Black-HDMIN,00A0,Texas Instrument,BB-BONELT-HDMIN

7: ff:P-O-L Override Board Name,00A0,Override Manuf,BB-BONE-AUDI-03

John, your DTS file still is not working however… as in I do not get any audio.

If I revert back to the dts file BoardZoo/CircuitCo provides audio works again: http://elinux.org/images/1/10/BB-BONE-AUDI-02-00A0.zip

Doh, thanks guys.

Changing:

nano /etc/default/capemgr

to:

CAPE=BB-BONE-AUDI-03

And using a different filename like John had, reboot.

root@beaglebone:~# cat /sys/devices/bone_capemgr*/slots

0: 54:PF—

1: 55:PF—

2: 56:PF—

3: 57:PF—

4: ff:P-O-L Bone-LT-eMMC-2G,00A0,Texas Instrument,BB-BONE-EMMC-2G

5: ff:P-O-- Bone-Black-HDMI,00A0,Texas Instrument,BB-BONELT-HDMI

6: ff:P-O-L Bone-Black-HDMIN,00A0,Texas Instrument,BB-BONELT-HDMIN

7: ff:P-O-L Override Board Name,00A0,Override Manuf,BB-BONE-AUDI-03

John, your DTS file still is not working however… as in I do not get any audio.

If I revert back to the dts file BoardZoo/CircuitCo provides audio works again: http://elinux.org/images/1/10/BB-BONE-AUDI-02-00A0.zip

I don’t have a audio cape. I’m using a TLV320AIC3106EVM which I wired up to the BBB and my DTS is working fine. I have attached a spreadsheet of how I connected the EVM to the BBB. Perhaps the connections on the audio cape are different. The spreadsheet also includes my own P8 and P9 mux tables derived from Derek Molloy and others.

Regards,
John

BBB - TLV320AIC3106.xlsx (91.8 KB)

Thanks for all the info John, I will take a look at your spreadsheet in detail because I have the audio cape and I have the TI TLV320 EVM that you mentioned as well.

My final version with good comments for the audio cape is attached.

BB-BONE-AUDI-04.dts (2.8 KB)

I patched the 3.8 davinci_mcasp ASoC driver with the multichannel patch from here: https://groups.google.com/forum/#!msg/linux.kernel/lQcez2q0R04/tBySUs-e4gIJ

And I am just happy to report I have 4 channels of audio output on AXR2 and AXR3!!!

Next up, 8 channels from the BeagleBone Black!!!

Thanks for all the help with rebuilding the 3.8.13 kernel and the Device Tree changes, never would have figured this out myself…

I patched the 3.8 davinci_mcasp ASoC driver with the multichannel patch from here: https://groups.google.com/forum/#!msg/linux.kernel/lQcez2q0R04/tBySUs-e4gIJ

And I am just happy to report I have 4 channels of audio output on AXR2 and AXR3!!!

Next up, 8 channels from the BeagleBone Black!!!

Thanks for all the help with rebuilding the 3.8.13 kernel and the Device Tree changes, never would have figured this out myself…

Good to hear that everything is working out for you. BTW, did you determine why the Audio DT I sent you did not work on the Audio Cape?

Regards,
John

For some reason we need to have the serializer the complete opposite of yours!

For example you had:

serial-dir = < /* 0: INACTIVE, 1: TX, 2: RX */

1 0 2 0

0 0 0 0

0 0 0 0

0 0 0 0

We needed to use:

serial-dir = < /* 0: INACTIVE, 1: TX, 2: RX */

2 0 1 0

0 0 0 0

0 0 0 0

0 0 0 0

But perhaps its because above that we also had different settings:

you had (that 8 must be a typo):

0x1ac 0x20 /* mcasp0_ahclkx, INPUT | MODE0 */

0x19c 0x22 /* mcasp0_axr2, INPUT | MODE2 */

0x194 0x20 /* mcasp0_fsx, INPUT | MODE0 */

0x198 0x08 /* mcasp0_axr0, OUTPUT | MODE0 */

0x190 0x20 /* mcasp0_aclkx, INPUT | MODE0 */

We used (which worked):

0x1ac 0x00 /* mcasp0_ahclkx, OUTPUT | MODE0 */

0x19c 0x22 /* mcasp0_axr2, INPUT | MODE2 */

0x194 0x20 /* mcasp0_fsx, INPUT | MODE0 */

0x198 0x20 /* mcasp0_axr0, INPUT | MODE0 */

0x190 0x20 /* mcasp0_aclkx, INPUT | MODE0 */

That said we are off the AudioCape now with the extra pins and using an XMOS based USB Streamer ADC/DAC for I2S testing back and forth and it is working fantastic!

Here are the final values we used for AXR0-3, 4 I2S lines, 4 channels in, 4 channels out (and attached the file)

We have only tested 2 channels in and 4 out however.

/*

Forgot to attach the file!

Also note in order to get multichannel audio working with the 3.8 kernel you need to apply these patches that are not in the 3.8 kernel:
http://lkml.iu.edu//hypermail/linux/kernel/1302.3/02415.html

I believe the newer kernel (3.13?) contains these patches but it broke all sorts of others things I am working on so I stuck with a customized 3.8.13 for now…

BB-BONE-AUDI-04-00A0.dts (2.78 KB)

For some reason we need to have the serializer the complete opposite of yours!

For example you had:

serial-dir = < /* 0: INACTIVE, 1: TX, 2: RX */

1 0 2 0

0 0 0 0

0 0 0 0

0 0 0 0

We needed to use:

serial-dir = < /* 0: INACTIVE, 1: TX, 2: RX */

2 0 1 0

0 0 0 0

0 0 0 0

0 0 0 0

But perhaps its because above that we also had different settings:

you had (that 8 must be a typo):

8 just means the pull-up is disabled, but I think it will work better with the pull-up enabled.

0x1ac 0x20 /* mcasp0_ahclkx, INPUT | MODE0 */

0x19c 0x22 /* mcasp0_axr2, INPUT | MODE2 */

0x194 0x20 /* mcasp0_fsx, INPUT | MODE0 */

0x198 0x08 /* mcasp0_axr0, OUTPUT | MODE0 */

0x190 0x20 /* mcasp0_aclkx, INPUT | MODE0 */

We used (which worked):

0x1ac 0x00 /* mcasp0_ahclkx, OUTPUT | MODE0 */

0x19c 0x22 /* mcasp0_axr2, INPUT | MODE2 */

0x194 0x20 /* mcasp0_fsx, INPUT | MODE0 */

0x198 0x20 /* mcasp0_axr0, INPUT | MODE0 */

0x190 0x20 /* mcasp0_aclkx, INPUT | MODE0 */

Looking at the Audio Cape RevB schematic and the TLV320AIC3104 datasheet. Pin 4 of the of the codec is DIN (Pin is defined as an input) is connected to P9_30 which is AXR0, so this pin on BBB should be defined as an output in DTS, but you have it defined as an input. Also, since AXR0 is defined as an output, then the serializer above should be defined as TX, but you have it defined as RX. What am I missing?

Pin1 of the codec is MCLK which is defined as an input, so MCASP0_AHCLKX should be defined as an output (My bad)

Hmmm, what I see is - pin 4 of the codec is connected to P9_28, which is AXR2, so that’s why AXR2 is defined as output?

Hmmm, what I see is - pin 4 of the codec is connected to P9_28, which is AXR2, so that’s why AXR2 is defined as output?

We used (which worked):

0x1ac 0x00 /* mcasp0_ahclkx, OUTPUT | MODE0 */

0x19c 0x22 /* mcasp0_axr2, INPUT | MODE2 */

0x194 0x20 /* mcasp0_fsx, INPUT | MODE0 */

0x198 0x20 /* mcasp0_axr0, INPUT | MODE0 */

0x190 0x20 /* mcasp0_aclkx, INPUT | MODE0 */

Looks like you define AXR2 as input.

Regards,
John

True but the serializer seems to set the direction for us…

bone_audio_cape_audio_pins: pinmux_bone_audio_cape_audio_pins {

pinctrl-single,pins = <

0x1ac 0x00 /* mcasp0_ahclkx, OUTPUT | MODE0 */

0x194 0x20 /* mcasp0_fsx, INPUT | MODE0 */

0x190 0x20 /* mcasp0_aclkx, INPUT | MODE0 */

0x198 0x20 /* mcasp0_axr0, INPUT | MODE0 */

0x1a8 0x20 /* mcasp0_axr1, INPUT | MODE0 */

0x19c 0x22 /* mcasp0_axr2, INPUT | MODE2 */

0x1a4 0x22 /* mcasp0_axr3, INPUT | MODE2 */

;

serial-dir = < /* 0: INACTIVE, 1: TX, 2: RX */

2 2 1 1

0 0 0 0

0 0 0 0

0 0 0 0

;

tx-num-evt = <1>;

rx-num-evt = <1>;

True but the serializer seems to set the direction for us…

Just looked in /sound/soc/davinci/davinci_mcasp.c and the code sets the PDIR register based on the contents of serial-dir so you are correct, there is no need to set the pin I/O direction.

Regards,
John

Yep and just to verify I tried it:

I tried setting it as 0x02 and it still works! So I get the exact same behavior whether it is:

pinctrl-single,pins = <

0x198 0x20 /* mcasp0_axr0, INPUT | MODE0 */

0x1a8 0x20 /* mcasp0_axr1, INPUT | MODE0 */

0x19c 0x02 /* mcasp0_axr2, OUTPUT | MODE2 */

0x1a4 0x02 /* mcasp0_axr3, OUTPUT | MODE2 */

Or

pinctrl-single,pins = <

0x198 0x20 /* mcasp0_axr0, INPUT | MODE0 */

0x1a8 0x20 /* mcasp0_axr1, INPUT | MODE0 */

0x19c 0x22 /* mcasp0_axr2, INPUT | MODE2 */

0x1a4 0x22 /* mcasp0_axr3, INPUT | MODE2 */

As long as the serializer is correct…

Thanks for all your help and explanations John!!!

We are going to try 8 channels TDM next using 1 pin… not sure if you tried anything like this yet…

Forgot to attach the file!

Also note in order to get multichannel audio working with the 3.8 kernel you need to apply these patches that are not in the 3.8 kernel:
http://lkml.iu.edu//hypermail/linux/kernel/1302.3/02415.html

I believe the newer kernel (3.13?) contains these patches but it broke all sorts of others things I am working on so I stuck with a customized 3.8.13 for now…

Hi Jesse,

I’ve attached a patch file to enable the audio cape in V3.15.4-bone4. I’ve only configured this for two channels, but it is simple to add the other channels for your setup.

If you can confirm that it works for you, I’ll submit it to Robert for inclusion into his kernel repo.

Regards,
John

0003-enable-audio-cape.patch (6.72 KB)