Moreover, whenever I try to connect the clock (MCASP1_ACLKR (Bit Clock) - P9_42) with my oscilloscope, I don't see any pulses. Looks like there is no proper clock signal on this pin. What can I do to debug, and fix this?
Any ideas?
Parag
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.
Tool/software: Linux
I am trying to interface an I2S microphone (https://www.adafruit.com/product/3421) with BeagleBone Black. I followed the article (http://www.ti.com/lit/an/sprac97/sprac97.pdf), and able to update the device tree, and the Linux kernel as suggested in the article.
The I2S component (for microphone) of the device tree is included as a dtsi in the main device tree source. The content of the dtsi is as below
&am33xx_pinmux {
mcasp1_pins: mcasp1_pins {
pinctrl-single,pins = <
/* sink must enable receivers */
0x1a0 0x23
/* P9_42 mcasp1_aclkx - bit clock */
0x1a4 0x23
/* P9_27 mcasp1_fsx - frame sync */
0x1a8 0x23
/* P9_41 mcasp1_axr0 - i2s input */
>;
};
};
&mcasp1 {
#sound-dai-cells = <0>;
pinctrl-names = "default";
pinctrl-0 = <&mcasp1_pins>;
status = "okay";
op-mode = <0>;
tdm-slots = <2>;
num-serializer = <4>;
serial-dir = < /* 1 TX 2 RX 0 unused */
2 0 0 0
>;
rx-num-evt = <1>;
tx-num-evt = <1>;
};
/ {
pcm5102a: pcm5102a {
#sound-dai-cells = <0>;
compatible = "ti,pcm5102a";
status = "okay";
};
sound1: sound@1 {
compatible = "simple-audio-card";
simple-audio-card,name = "PCM5102a";
simple-audio-card,format = "i2s";
simple-audio-card,bitclock-master = <&sound1_master>;
simple-audio-card,frame-master = <&sound1_master>;
simple-audio-card,bitclock-inversion;
simple-audio-card,cpu {
sound-dai = <&mcasp1>;
};
sound1_master: simple-audio-card,codec {
#sound-dai-cells = <0>;
sound-dai = <&pcm5102a>;
clocks = <&mcasp1_fck>;
clock-names = "mclk";
};
};
};
I have also compiled the kernel with a new driver pcm5102 as suggested in the document. Finally, I see the driver listed in the output of the arecord command.
root@arm:/sys/class/gpio# arecord -l **** List of CAPTURE Hardware Devices **** card 0: PCM5102a [PCM5102a], device 0: davinci-mcasp.0-pcm5102a-hifi pcm5102a-hifi-0 [] Subdevices: 1/1 Subdevice #0: subdevice #0
However whenever I try to record audio, I am not getting any audio data. The audio file is formed, but the file size is always 44 bytes irrespective of how long I try to record audio for. Clearly no data is there in the file.
Recording using arecord command gives error as below
arecord -d 10 -Dhw:0,0 -f dat audio.wav Recording WAVE 'audio.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo arecord: pcm_read:2032: read error: Input/output error
Moreover, whenever I try to connect the clock (MCASP1_ACLKR (Bit Clock) - P9_42) with my oscilloscope, I don't see any pulses. Looks like there is no proper clock signal on this pin. What can I do to debug, and fix this?
Any ideas?
Parag
Hi Parag,
Parag Sharma said:mcasp1_pins: mcasp1_pins { pinctrl-single,pins = < /* sink must enable receivers */ 0x1a0 0x23 /* P9_42 mcasp1_aclkx - bit clock */
Parag Sharma said:simple-audio-card,bitclock-master = <&sound1_master>;
Parag Sharma said:sound1_master: simple-audio-card,codec { #sound-dai-cells = <0>; sound-dai = <&pcm5102a>; clocks = <&mcasp1_fck>; clock-names = "mclk"; };
Parag Sharma said:Moreover, whenever I try to connect the clock (MCASP1_ACLKR (Bit Clock) - P9_42) with my oscilloscope, I don't see any pulses. Looks like there is no proper clock signal on this pin. What can I do to debug, and fix this?
You configure your AM335x McASP1 module as slave, thus you need to provide the bit clock from PCM5102A dummy codec to AM335x pin B12 MCASP0_ACLKR.mcasp1_aclkx
Check in user space (with devmem2 or omapconf tool) that you have the correct value in register CONF_MCASP0_ACLKR/0x44E109A0.
The bit clock scheme of the link you have provided is:
PCM1864 ADC --> C5517 DSP J29_Pin3 --> AM335x McASP1 P9_42/B12
Your bit clock scheme should be:
Adafruit MIC --> AM335x McASP1 P9_42/B12
Check also below pointers for audio debug guidelines:
http://processors.wiki.ti.com/index.php/Linux_Core_Audio_User's_Guide#If_there.27s_an_issue
Regards,
Pavel
Hi Pavel,
Thanks for your help in figuring this out. However is it possible to configure AM335x McASP1 module as master instead of slave so it itself can drive the clock?
Hi ,Pavel
I Configured the Mcasp0 and device tree according to the processors.wiki.ti.com/.../Sitara_Linux_Audio_DAC_Example
I am seeing clock out on both bclk and fsclk and data is being transmitted ,but
when i try to configure it in Capture mode the bitclock is present but it is not of the required form and the fsclk is entirely missing.
Please suggest a solution.
/* * 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/; #include "am33xx.dtsi" #include "am335x-bone-common.dtsi" &ldo3_reg { regulator-min-microvolt = <1800000>; regulator-max-microvolt = <3300000>; regulator-always-on; }; &mmc1 { vmmc-supply = <&ldo3_reg>; }; &am33xx_pinmux { mcasp0_pins: mcasp0_pins { pinctrl-single,pins = < 0x190 (PIN_OUTPUT_PULLDOWN | MUX_MODE0) /* mcasp0_aclkx */ 0x194 (PIN_OUTPUT_PULLDOWN | MUX_MODE0) /* mcasp0_fsx*/ 0x198 (PIN_INPUT_PULLDOWN | MUX_MODE0) /* mcasp0_axr0 */ >; }; }; &mcasp0 { pinctrl-names = "default"; pinctrl-0 = <&mcasp0_pins>; status = "okay"; op-mode = <0>; /* MCASP_IIS_MODE */ tdm-slots = <2>; /* 16 serializer */ serial-dir = < /* 0: INACTIVE, 1: TX, 2: RX */ 2 1 0 0 >; tx-num-evt = <32>; rx-num-evt = <32>; }; / { pcm5102a: pcm5102a { compatible = "ti,pcm5102a"; }; sound { compatible = "ti,pcm5102a-evm-audio"; ti,model = "TI PCM5102A"; ti,audio-codec = <&pcm5102a>; ti,mcasp-controller = <&mcasp0>; ti,codec-clock-rate = <24000000>; }; };
Hi Pavel I am using ti-processor-sdk-linux-am335x-evm-04.03.00.05
and the dts I am using is
changing it from
sound { compatible = "ti,pcm5102a-evm-audio";
to
sound { compatible = "simple-audio-card";
causes this :
sh-3.2# arecord -l arecord: device_list:268: no soundcards found... sh-3.2# aplay -l aplay: device_list:268: no soundcards found...
using pcm5102a-evm-audio gives this
sh-3.2# aplay -l **** List of PLAYBACK Hardware Devices **** card 0: PCM5102A [TI PCM5102A], device 0: Capture pcm5102a-hifi-0 [] Subdevices: 1/1 Subdevice #0: subdevice #0 sh-3.2# arecord -l **** List of CAPTURE Hardware Devices **** card 0: PCM5102A [TI PCM5102A], device 0: Capture pcm5102a-hifi-0 [] Subdevices: 1/1 Subdevice #0: subdevice #0
using pcm5102a-evm-audio give both clocks for aplay
and BCLK
But arecord gives:
(arecord -Dhw:0,0 -f dat asddd.wav)
for FSCLK
BCLK
AJINKYA PRABHU said:changing it from
sound { compatible = "ti,pcm5102a-evm-audio";to
sound { compatible = "simple-audio-card";causes this :
sh-3.2# arecord -l arecord: device_list:268: no soundcards found... sh-3.2# aplay -l aplay: device_list:268: no soundcards found...
This is because you change only "compatible", but that is not enough. You should change more things in DTS, as explained in sprac97.pdf
4.2.3.1 Simple Audio Card
Plumbing between the PCM5102A device driver and the AM335X processor is done in the device tree with the simple-audio-card device tree bindings. For more information about available simple-audio-card device tree properties, see the following kernel documentation:
Documentation/devicetree/bindings/sound/simple-card.txt
pcm5102a: pcm5102a {
#sound-dai-cells = <0>;
compatible = "ti,pcm5102a";
status = "okay";
};
sound1: sound@1 {
compatible = "simple-audio-card";
simple-audio-card,name = "PCM5102a";
simple-audio-card,format = "i2s";
simple-audio-card,bitclock-master = <&sound1_master>;
simple-audio-card,frame-master = <&sound1_master>;
simple-audio-card,bitclock-inversion;
simple-audio-card,cpu {
sound-dai = <&mcasp1>;
};
sound1_master: simple-audio-card,codec {
#sound-dai-cells = <0>;
sound-dai = <&pcm5102a>;
clocks = <&mcasp1_fck>;
clock-names = "mclk";
};
AJINKYA PRABHU said:using pcm5102a-evm-audio gives this
sh-3.2# aplay -l **** List of PLAYBACK Hardware Devices **** card 0: PCM5102A [TI PCM5102A], device 0: Capture pcm5102a-hifi-0 [] Subdevices: 1/1 Subdevice #0: subdevice #0 sh-3.2# arecord -l **** List of CAPTURE Hardware Devices **** card 0: PCM5102A [TI PCM5102A], device 0: Capture pcm5102a-hifi-0 [] Subdevices: 1/1 Subdevice #0: subdevice #0using pcm5102a-evm-audio give both clocks for aplay
Who is supposed to provide the FS and BCLK signals? Is it AM335x device?
Please provide full console log of arecord and aplay commands. Provide also register dump of McASP pinmux registers and McASP module registers.
Regard,
Pavel
This is the device tree after The changes mentioned in the document:
/* * Copyright (C) 2012 Texas Instruments Incorporated - <a href="www.ti.com/.../a> * * 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/; #include "am33xx.dtsi" #include "am335x-bone-common.dtsi" &ldo3_reg { regulator-min-microvolt = <1800000>; regulator-max-microvolt = <3300000>; regulator-always-on; }; &mmc1 { vmmc-supply = <&ldo3_reg>; }; &am33xx_pinmux { mcasp1_pins: mcasp1_pins { pinctrl-single,pins = < /* sink must enable receivers */ 0x1a0 0x23 /* P9_42 mcasp1_aclkx - bit clock */ 0x1a4 0x23 /* P9_27 mcasp1_fsx - frame sync */ 0x1a8 0x23 /* P9_41 mcasp1_axr0 - i2s input */ >; }; }; &mcasp1 { #sound-dai-cells = <0>; pinctrl-names = "default"; pinctrl-0 = <&mcasp1_pins>; status = "okay"; op-mode = <0>; tdm-slots = <2>; num-serializer = <4>; serial-dir = < /* 1 TX 2 RX 0 unused */ 2 0 0 0 >; rx-num-evt = <1>; tx-num-evt = <1>; }; / { pcm5102a: pcm5102a { #sound-dai-cells = <0>; compatible = "ti,pcm5102a"; status = "okay"; }; sound1: sound@1 { compatible = "simple-audio-card"; simple-audio-card,name = "PCM5102a"; simple-audio-card,format = "i2s"; simple-audio-card,bitclock-master = <&sound1_master>; simple-audio-card,frame-master = <&sound1_master>; simple-audio-card,bitclock-inversion; simple-audio-card,cpu { sound-dai = <&mcasp1>; }; sound1_master: simple-audio-card,codec { #sound-dai-cells = <0>; sound-dai = <&pcm5102a>; clocks = <&mcasp1_fck>; clock-names = "mclk"; }; }; };
Console logs for aplay and arecord:
sh-3.2# aplay aj.wav Playing WAVE 'aj.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo [ 36.741784] davinci-mcasp 4803c000.mcasp: stream has more channels (2) than are enabled in mcasp (0) [ 36.755080] davinci-mcasp 4803c000.mcasp: ASoC: can't set 4803c000.mcasp hw params: -22 aplay: set_params:1361: Unable to install hw params: ACCESS: RW_INTERLEAVED FORMAT: S16_LE SUBFORMAT: STD SAMPLE_BITS: 16 FRAME_BITS: 32 CHANNELS: 2 RATE: 48000 PERIOD_TIME: 125000 PERIOD_SIZE: 6000 PERIOD_BYTES: 24000 PERIODS: 4 BUFFER_TIME: 500000 BUFFER_SIZE: 24000 BUFFER_BYTES: 96000 TICK_TIME: 0
sh-3.2# arecord -Dhw:0,0 -d 10 -f dat asd.wav Recording WAVE 'asd.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo arecord: pcm_read:2096: read error: Input/output error
sh-3.2# arecord -l **** List of CAPTURE Hardware Devices **** card 0: PCM5102a [PCM5102a], device 0: davinci-mcasp.0-pcm5102a-hifi pcm5102a-hifi-0 [] Subdevices: 1/1 Subdevice #0: subdevice #0
sh-3.2# aplay -l **** List of PLAYBACK Hardware Devices **** card 0: PCM5102a [PCM5102a], device 0: davinci-mcasp.0-pcm5102a-hifi pcm5102a-hifi-0 [] Subdevices: 1/1 Subdevice #0: subdevice #0
Hi Pavel ,
1)How do I resolve the Input/Output error?
2)What changes would you recommend to make the am335x to be the master?
regards,
Ajinkya
1) How do I resolve the Input/Output error?
The arecord I/O error happens when there is no data flowing from the hardware to ALSA in 10 secs. One likely reason for that to happen is if the master (in your case, the AM335x device) is not providing FSYNC and BCLK. Without them, external codec doesn't move any data on axr0 pin. I suggest you make sure that the AM335x is correctly providing the BCLK/FYSNC.
See also below doc:
www.ti.com/.../sprac10.pdf
6.7 Input/Output Error During Audio Record
2)What changes would you recommend to make the am335x to be the master?
sound1: sound@1 {
compatible = "simple-audio-card";
simple-audio-card,name = "PCM5102a";
simple-audio-card,format = "i2s";
simple-audio-card,bitclock-master = <&sound1_master>;
simple-audio-card,frame-master = <&sound1_master>;
simple-audio-card,bitclock-inversion;
sound1_master: simple-audio-card,cpu {
sound-dai = <&mcasp1>;
};
simple-audio-card,codec {
#sound-dai-cells = <0>;
sound-dai = <&pcm5102a>;
clocks = <&mcasp1_fck>;
clock-names = "mclk";
};
};
Hi Pavel
when I run the command
arecord -d 10 -Dhw:0,0 -f dat audio.wav
the file is created but the duration of recording isn't very long, I thought since -d 10 would tell it to record for 10 secs
but what could be the issue for this?
Hi Pavel ,
The Input/Output Error seems to have gone but I am still not getting a proper clock on BCLK and no clock on LRCLK
And also when I try to do
omapconf show mcasp1
it gives me:
HW Platform: Generic AM33XX (Flattened Device Tree) AM3358 ES2.1 GP Device (UNKNOWN performance ZCZ package (1.0GHz)) Error: I2C Read failed Error: I2C Read failed Error: I2C Read failed TPS65217C ES1.2 Error: I2C Read failed UNKNOWN AUDIO IC
Can you suggest a solution for this?
AJINKYA PRABHU said:when I run the command
arecord -d 10 -Dhw:0,0 -f dat audio.wavthe file is created but the duration of recording isn't very long, I thought since -d 10 would tell it to record for 10 secs
but what could be the issue for this?
With this command you setup 48KHz frame sync and 1.536MHz bit clock. Do you observe these frequencies (48KHz FS and 1.536MHz BCLK)?
Please provide me register dump of McASP1 pinmux values and McASP1 registers. You can get these from user space with devmem2 tool or omapconf tool. See the below pointers for more info:
3 McASP Register Settings
AJINKYA PRABHU said:The Input/Output Error seems to have gone but I am still not getting a proper clock on BCLK and no clock on LRCLK
And also when I try to do
omapconf show mcasp1it gives me:
HW Platform: Generic AM33XX (Flattened Device Tree) AM3358 ES2.1 GP Device (UNKNOWN performance ZCZ package (1.0GHz)) Error: I2C Read failed Error: I2C Read failed Error: I2C Read failed TPS65217C ES1.2 Error: I2C Read failed UNKNOWN AUDIO ICCan you suggest a solution for this?
Actually I will suggest you to dump only Control Module McASP1 pinmux registers in user space (devmem2 or omapconf). While the McASP1 module registers should be check inside the kernel, with printk. See the below e2e thread for more info:
Regards,
Pavel
1)This is the what I get when I run
devmem2 0x4803c000
0x4803c000 is for Mcasp 1
/dev/mem opened.[ 3042.065899] Unhandled fault: external abort on non-linefetch (0 [ 3042.074752] pgd = dc54c000 [ 3042.077470] [b6f38000] *pgd=9a108831, *pte=4803c303, *ppte=4803ca33 Memory mapped at address 0xb6f38000. [ 3042.085144] audit: type=1701 audit(1522080492.952:4): auid=4294967295 uid=0 gi7 Bus error (core dumped)
2)What should i printk in the kernel?
3) Should I add a clock node inside the ,cpu node?
&am33xx_pinmux { mcasp1_pins: mcasp1_pins { pinctrl-single,pins = < /* sink must enable receivers */ 0x1a0 0x23 /* P9_42 mcasp1_aclkx - bit clock */ 0x1a4 0x23 /* P9_27 mcasp1_fsx - frame sync */ 0x1a8 0x23 /* P9_41 mcasp1_axr0 - i2s input */ >; }; }; &mcasp1 { #sound-dai-cells = <0>; pinctrl-names = "default"; pinctrl-0 = <&mcasp1_pins>; status = "okay"; op-mode = <0>; tdm-slots = <2>; num-serializer = <4>; serial-dir = < /* 1 TX 2 RX 0 unused */ 2 0 0 0 >; rx-num-evt = <1>; tx-num-evt = <1>; }; / { pcm5102a: pcm5102a { #sound-dai-cells = <0>; compatible = "ti,pcm5102a"; status = "okay"; }; sound1: sound@1 { compatible = "simple-audio-card"; simple-audio-card,name = "PCM5102a"; simple-audio-card,format = "i2s"; simple-audio-card,bitclock-master = <&sound1_master>; simple-audio-card,frame-master = <&sound1_master>; simple-audio-card,bitclock-inversion; sound1_master:simple-audio-card,cpu { sound-dai = <&mcasp1>; }; simple-audio-card,codec { #sound-dai-cells = <0>; sound-dai = <&pcm5102a>; clocks = <&mcasp1_fck>; clock-names = "mclk"; }; }; };
When I run
arecord -d 10 -Dhw:0,0 -f dat audio.wav
I get only a 24Mhz clock on the BCLK pin and
NO clk on the LRCLK pin
AJINKYA PRABHU said:1)This is the what I get when I run
devmem2 0x4803c0000x4803c000 is for Mcasp 1
/dev/mem opened.[ 3042.065899] Unhandled fault: external abort on non-linefetch (0 [ 3042.074752] pgd = dc54c000 [ 3042.077470] [b6f38000] *pgd=9a108831, *pte=4803c303, *ppte=4803ca33 Memory mapped at address 0xb6f38000. [ 3042.085144] audit: type=1701 audit(1522080492.952:4): auid=4294967295 uid=0 gi7 Bus error (core dumped)
This is expected. Do not dump McASP1 module register in user space.
AJINKYA PRABHU said:2)What should i printk in the kernel?
McASP1 module registers, at start addr 0x4803C000
AJINKYA PRABHU said:3) Should I add a clock node inside the ,cpu node?
I do not see cpu node in your DTS extract, thus I can not comment.
AJINKYA PRABHU said:arecord -d 10 -Dhw:0,0 -f dat audio.wavI get only a 24Mhz clock on the BCLK pin and
NO clk on the LRCLK pin
Provide McASP1 module register dump after/during arecord execution
Hi Pavel ,
I wanted to know where I can get the McASP1 module registers from ? As in which file and where should I edit the printk statement to get the value of the McASP1 module Registers?
Moreover ,
/sys/kernel/debug
is empty and the pinctrl directory is missing .
thanks
AJINKYA PRABHU said:I wanted to know where I can get the McASP1 module registers from ? As in which file and where should I edit the printk statement to get the value of the McASP1 module Registers?
dump the McASP1 registers at the end of the mcasp_start_rx() function at mcasp driver:
linux-kernel/sound/soc/davinci/davinci-mcasp.c
See below e2e thread for details:
AJINKYA PRABHU said:Moreover ,
/sys/kernel/debug
is empty and the pinctrl directory is missing .
You do not need /sys/kernel/debug. Just read the McASP1 Control Module pinmux registers with devmem2 and provide me the result.
Here is the code I used to dump the register values
printk("0x%x\n", mcasp->base);
printk("mcasp_start_rx: DAVINCI_MCASP_TXFMCTL_REG:0x%x \n", mcasp_get_reg(mcasp, DAVINCI_MCASP_TXFMCTL_REG));
printk("mcasp_start_rx: DAVINCI_MCASP_RXFMCTL_REG:0x%x \n", mcasp_get_reg(mcasp, DAVINCI_MCASP_RXFMCTL_REG));
printk("mcasp_start_rx: DAVINCI_MCASP_TXFMT_REG:0x%x \n", mcasp_get_reg(mcasp, DAVINCI_MCASP_TXFMT_REG));
printk("mcasp_start_rx: DAVINCI_MCASP_RXFMT_REG:0x%x \n", mcasp_get_reg(mcasp, DAVINCI_MCASP_RXFMT_REG));
printk("mcasp_start_rx: DAVINCI_MCASP_ACLKXCTL_REG:0x%x \n", mcasp_get_reg(mcasp, DAVINCI_MCASP_ACLKXCTL_REG));
printk("mcasp_start_rx: DAVINCI_MCASP_ACLKRCTL_REG:0x%x \n", mcasp_get_reg(mcasp, DAVINCI_MCASP_ACLKRCTL_REG));
printk("mcasp_start_rx: DAVINCI_MCASP_PDIR_REG:0x%x \n", mcasp_get_reg(mcasp, DAVINCI_MCASP_PDIR_REG));
printk("mcasp_start_rx: DAVINCI_MCASP_RXMASK_REG:0x%x \n", mcasp_get_reg(mcasp, DAVINCI_MCASP_RXMASK_REG));
printk("mcasp_start_rx: DAVINCI_MCASP_TXMASK_REG:0x%x \n", mcasp_get_reg(mcasp, DAVINCI_MCASP_TXMASK_REG));
printk("mcasp_start_rx: DAVINCI_MCASP_RXTDM_REG:0x%x \n", mcasp_get_reg(mcasp, DAVINCI_MCASP_RXTDM_REG));
printk("mcasp_start_rx: DAVINCI_MCASP_TXTDM_REG:0x%x \n", mcasp_get_reg(mcasp, DAVINCI_MCASP_TXTDM_REG));
And below is the output from the above code
[ 636.578439] 0xfa03c000
[ 636.580807] mcasp_start_rx: DAVINCI_MCASP_TXFMCTL_REG:0x13
[ 636.586399] mcasp_start_rx: DAVINCI_MCASP_RXFMCTL_REG:0x113
[ 636.592079] mcasp_start_rx: DAVINCI_MCASP_TXFMT_REG:0x10074
[ 636.597759] mcasp_start_rx: DAVINCI_MCASP_RXFMT_REG:0x18070
[ 636.603439] mcasp_start_rx: DAVINCI_MCASP_ACLKXCTL_REG:0x180060
[ 636.609467] mcasp_start_rx: DAVINCI_MCASP_ACLKRCTL_REG:0x20
[ 636.615147] mcasp_start_rx: DAVINCI_MCASP_PDIR_REG:0xb4000000
[ 636.621001] mcasp_start_rx: DAVINCI_MCASP_RXMASK_REG:0xffff
[ 636.626680] mcasp_start_rx: DAVINCI_MCASP_TXMASK_REG:0xffff
[ 636.632360] mcasp_start_rx: DAVINCI_MCASP_RXTDM_REG:0x3
[ 636.637691] mcasp_start_rx: DAVINCI_MCASP_TXTDM_REG:0x0
Running
u32 address_1 = phys_to_virt(0x4803c000); printk("McASP 1 AJINKYA address 0x%x",address_1);
Gives
[ 143.096451] davinci_mcasp_triggerMcASP 1 AJINKYA address 0x8803c000
Hi Pavel ,
I printed theses Values
printk("0x%x\n", mcasp->base); printk("mcasp_start_rx: DAVINCI_MCASP_TXFMCTL_REG:0x%x \n", mcasp_get_reg(mcasp, DAVINCI_MCASP_TXFMCTL_REG)); printk("mcasp_start_rx: DAVINCI_MCASP_RXFMCTL_REG:0x%x \n", mcasp_get_reg(mcasp, DAVINCI_MCASP_RXFMCTL_REG)); printk("mcasp_start_rx: DAVINCI_MCASP_TXFMT_REG:0x%x \n", mcasp_get_reg(mcasp, DAVINCI_MCASP_TXFMT_REG)); printk("mcasp_start_rx: DAVINCI_MCASP_RXFMT_REG:0x%x \n", mcasp_get_reg(mcasp, DAVINCI_MCASP_RXFMT_REG)); printk("mcasp_start_rx: DAVINCI_MCASP_ACLKXCTL_REG:0x%x \n", mcasp_get_reg(mcasp, DAVINCI_MCASP_ACLKXCTL_REG)); printk("mcasp_start_rx: DAVINCI_MCASP_ACLKRCTL_REG:0x%x \n", mcasp_get_reg(mcasp, DAVINCI_MCASP_ACLKRCTL_REG)); printk("mcasp_start_rx: DAVINCI_MCASP_PDIR_REG:0x%x \n", mcasp_get_reg(mcasp, DAVINCI_MCASP_PDIR_REG)); printk("mcasp_start_rx: DAVINCI_MCASP_RXMASK_REG:0x%x \n", mcasp_get_reg(mcasp, DAVINCI_MCASP_RXMASK_REG)); printk("mcasp_start_rx: DAVINCI_MCASP_TXMASK_REG:0x%x \n", mcasp_get_reg(mcasp, DAVINCI_MCASP_TXMASK_REG)); printk("mcasp_start_rx: DAVINCI_MCASP_RXTDM_REG:0x%x \n", mcasp_get_reg(mcasp, DAVINCI_MCASP_RXTDM_REG)); printk("mcasp_start_rx: DAVINCI_MCASP_TXTDM_REG:0x%x \n", mcasp_get_reg(mcasp, DAVINCI_MCASP_TXTDM_REG));
Dump
[ 636.578439] 0xfa03c000 [ 636.580807] mcasp_start_rx: DAVINCI_MCASP_TXFMCTL_REG:0x13 [ 636.586399] mcasp_start_rx: DAVINCI_MCASP_RXFMCTL_REG:0x113 [ 636.592079] mcasp_start_rx: DAVINCI_MCASP_TXFMT_REG:0x10074 [ 636.597759] mcasp_start_rx: DAVINCI_MCASP_RXFMT_REG:0x18070 [ 636.603439] mcasp_start_rx: DAVINCI_MCASP_ACLKXCTL_REG:0x180060 [ 636.609467] mcasp_start_rx: DAVINCI_MCASP_ACLKRCTL_REG:0x20 [ 636.615147] mcasp_start_rx: DAVINCI_MCASP_PDIR_REG:0xb4000000 [ 636.621001] mcasp_start_rx: DAVINCI_MCASP_RXMASK_REG:0xffff [ 636.626680] mcasp_start_rx: DAVINCI_MCASP_TXMASK_REG:0xffff [ 636.632360] mcasp_start_rx: DAVINCI_MCASP_RXTDM_REG:0x3 [ 636.637691] mcasp_start_rx: DAVINCI_MCASP_TXTDM_REG:0x0
Hi Pavel,
Can you also help me understand the role of this setting?
enable-gpios = <&gpio1 27 0>; /* BeagleBone Black Clk enable on GPIO1_27 */
Why do we need to do this on our clock? Why do we choose GPIO1_27? Why not any other GPIO pin? What is so special about this pin that when set in the manner above, it enables the clock?
Parag Sharma said:*pin 104 (44e109a0.0) 00000003 pinctrl-single
pin 105 (44e109a4.0) 00000003 pinctrl-single
pin 106 (44e109a8.0) 00000023 pinctrl-single *
Parag Sharma said:&am33xx_pinmux {
mcasp1_pins: mcasp1_pins{
pinctrl-single,pins = <
/* sink must enable receivers */
AM33XX_IOPAD(0x9a0, PIN_OUTPUT_PULLDOWN | MUX_MODE3) /* P9_42 mcasp1_aclkx - bit clock */
AM33XX_IOPAD(0x9a4, PIN_OUTPUT_PULLDOWN | MUX_MODE3) /* P9_27 mcasp1_fsx - frame sync */
AM33XX_IOPAD(0x9a8, PIN_INPUT_PULLDOWN | MUX_MODE3) /* P9_41 mcasp1_axr0 - i2s input */
>;
Please change pins mcasp1_aclkx and mcasp1_fsx from output to input/output, as we have re-time requirement. For more info check AM335x TRM, section 22.2.3 McASP Pin List
Parag Sharma said:[ 54.532208] DAVINCI_MCASP_GBLCTLX_REG:0x1f
This does NOT looks ok. Can you check if your flow goes through setting TX signals in mcasp_start_rx() function?
static void mcasp_start_rx(struct davinci_mcasp *mcasp)
{
/* Start clocks */
mcasp_set_ctl_reg(mcasp, DAVINCI_MCASP_GBLCTLR_REG, RXHCLKRST);
mcasp_set_ctl_reg(mcasp, DAVINCI_MCASP_GBLCTLR_REG, RXCLKRST);
/*
* When ASYNC == 0 the transmit and receive sections operate
* synchronously from the transmit clock and frame sync. We need to make
* sure that the TX signlas are enabled when starting reception.
*/
if (mcasp_is_synchronous(mcasp)) {
printk("enable TX signals\n");
mcasp_set_ctl_reg(mcasp, DAVINCI_MCASP_GBLCTLX_REG, TXHCLKRST);
mcasp_set_ctl_reg(mcasp, DAVINCI_MCASP_GBLCTLX_REG, TXCLKRST);
}
Hi Pavel,
The flow is not going inside "mcasp_is_synchronous" function. When I make the program to forcibly go inside the function (by putting a ! in the "if" condition), the clock starts showing correctly.
What could be wrong here? What am I missing?
Also frame sync clock (P9_27 mcasp1_fsx) is not showing up? Something wrong here?
Parag
I added some logs in the mcasp_is_synchronous function
static bool mcasp_is_synchronous(struct davinci_mcasp *mcasp)
{
u32 rxfmctl = mcasp_get_reg(mcasp, DAVINCI_MCASP_RXFMCTL_REG);
printk("DAVINCI_MCASP_RXFMCTL_REG: 0x%x\n", rxfmctl);
u32 aclkxctl = mcasp_get_reg(mcasp, DAVINCI_MCASP_ACLKXCTL_REG);
printk("DAVINCI_MCASP_ACLKXCTL_REG: 0x%x\n", aclkxctl);
printk("TX_ASYNC 0x%x\n", TX_ASYNC);
printk("aclkxctl & TX_ASYNC 0x%x\n", aclkxctl & TX_ASYNC);
printk("AFSRE 0x%x\n", AFSRE);
printk("output: 0x%x\n", !(aclkxctl & TX_ASYNC) && rxfmctl & AFSRE);
return !(aclkxctl & TX_ASYNC) && rxfmctl & AFSRE;
}
The logs are showing as
[ 103.785057] DAVINCI_MCASP_RXFMCTL_REG: 0x113
[ 103.789342] DAVINCI_MCASP_ACLKXCTL_REG: 0x18006f
[ 103.793975] TX_ASYNC 0x40
[ 103.796601] aclkxctl & TX_ASYNC 0x40
[ 103.800187] AFSRE 0x2
[ 103.802463] output: 0x0
Where is the problem? Why this function returns 0 instead of 1?
Parag,
DTS file seems to be correct, you have "op-mode = <0>;" there. 0 is for i2S mode (ASYNC = 0), while 1 is for DIT/SPDIF mode (ASYNC = 1). You need to debug davinci-mcasp.c file to see if and why DIR/SPDIF mode is selected (instead of I2S).
&mcasp1 {
op-mode = <0>;
}
static struct davinci_mcasp_pdata *davinci_mcasp_set_pdata_from_of(struct platform_device *pdev)
{
ret = of_property_read_u32(np, "op-mode", &val);
if (ret >= 0)
pdata->op_mode = val;
}
static int davinci_mcasp_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *cpu_dai)
{
if (mcasp->op_mode == DAVINCI_MCASP_DIT_MODE)
ret = mcasp_dit_hw_param(mcasp, params_rate(params));
else
ret = mcasp_i2s_hw_param(mcasp, substream->stream, channels);
}
static int mcasp_i2s_hw_param(struct davinci_mcasp *mcasp, int stream, int channels)
{
mcasp_clr_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, TX_ASYNC); //ASYNC = 0
}
/* S/PDIF */
static int mcasp_dit_hw_param(struct davinci_mcasp *mcasp, unsigned int rate)
{
/* Set the TX clock controls : div = 1 and internal */
mcasp_set_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, ACLKXE | TX_ASYNC); //ASYNC = 1
}
Hi Pavel,
Thanks for your help.
I finally tried the linux kernel shipped with TI SDK along with the RFS from TI SDK itself, and most of the things (including the bitclock, dataout, etc) seems working in the first instance.
However I still don't see a proper signal on frame sync on P9_27 (mcasp1_fsx). All I see is that the signal on this pin goes from high to low on start of recording, but does't change. No wave. Is that ok to expect given that I am using a single channel (No of channels in arecord command is 1 by default).
Even when I try to record using
arecord -f dat -Dhw:1,0 -c 2 /tmp/audio.wav
I still don't see a proper high low signal on P9_27. Signal just remains flat.
Also the recorded file has some data, but what was recorded. Its just completely silent.
Parag,
From what I understand, you have the correct and expected clock signal on mcasp1_aclkx pin. But you do not see the correct and expected signal on mcasp1_fsx pin.
Please change this mcasp1_fsx pin from output to input/output. We have re-time requirement. For more info check AM335x TRM, section 22.2.3 McASP Pin List
You might observe not expected FSX signal, as it also depends on the data received from mcasp1_axr0 pin. See the timing diagrams:
AM335x datasheet: Figure 7-86. McASP Input Timing
AM335x TRM: 22.3.3.1.2 Inter-Integrated Sound (I2S) Format
"All I see is that the signal on this pin goes from high to low on start of recording, but does't change. No wave."
If you do not have the proper audio data bits received on mcasp1_axr0, this FSX signal is staying low. You need to receive all audio data bits till LSB.
Does you Microphone need only these two clock signals (bit clock and frame sync)? Because Audio Codec need one more, MCLK, which can be provided by AHCLKX pin.
Regards,
Pavel
Pavel,
What is meant by making the framesync pin INPUT/OUTPUT?
The current configuration is
AM33XX_IOPAD(0x9a4, PIN_OUTPUT_PULLDOWN | MUX_MODE3) /* P9_27 mcasp1_fsx - frame sync */
Should it be modified to
AM33XX_IOPAD(0x9a4, PIN_INPUT_PULLDOWN | PIN_OUTPUT_PULLDOWN | MUX_MODE3)
Also I just realised that I am getting the right frameclock as well. I didn't see the written frequency below on the oscilloscope :(. The framesync freq I am getting is 46kz (for mono sound, i.e. c = 1)
with the following command : arecord -fdat -Dhw:1,0 -c 1 -d 100 /tmp/audio.wav
With # of channels = 2, the freq still remains the same at 46khz. I don't think its right. Shouldn't the frequency be 48kz for c = 1 and 96khz for c = 2?
The recorded however seems all garbage :(
Also another amusing thing is the signal recorded on the data pin is a square wave even when no recording is happening. When I start recording using arecord, the signal shows some small changes in the signal, however they do not seem to go with the sound actually made in the surroundings.
Parag Sharma said:What is meant by making the framesync pin INPUT/OUTPUT?
These signals (aclkx, fsx) are also used as inputs to re-time or sync data. The associated CONF_<module>_<pin>_RXACTIVE bit for these signals must be set to 1 to enable the inputs back to the module. It is also recommended to place a 33-ohm resistor in series (close to the processor) on each of these signals to avoid signal reflections.
Parag Sharma said:The current configuration is
AM33XX_IOPAD(0x9a4, PIN_OUTPUT_PULLDOWN | MUX_MODE3) /* P9_27 mcasp1_fsx - frame sync */
Should it be modified to
AM33XX_IOPAD(0x9a4, PIN_INPUT_PULLDOWN | PIN_OUTPUT_PULLDOWN | MUX_MODE3)
AM33XX_IOPAD(0x9a4, PIN_INPUT_PULLDOWN | MUX_MODE3)
Then check if bit RXACTIVE is set to 1. See AM335x TRM, section 9.2.2 Pad Control Registers
Parag Sharma said:Also I just realised that I am getting the right frameclock as well.
If you have the correct bit clock and frame sync output from AM335x McASP, then you should focus on configuration of your external microphone, seems like this microphone is not working properly, thus not providing the correct audio data on AXR pin. You should work with external microphone documents and support team.
You can also configure AM335x McASP AXR as output, for testing purpose. You can use an o-scope to probe the audio data line and clocks to see that the AM335x McASP driver is working. Then it is up to external microphone to provide correct audio data.
Regards,
Pavel
Hi Pavel,
I changed the pixmux settings of framesync and bitclock to INPUT/OUTPUT as you suggested.
Getting correct Bitclock (1.5MHz), and framesync clock (46.9KHz), but the recorded file is still all garbage as earlier.
However one interesting observation is that I see a perfectly square wave of frequency 32KHz even when there is no recording going on. Why should the Oscilloscope show this signal? Shouldn't this be all low when not recording or playing?